Skip to content

Commit

Permalink
Merge pull request xtekky#285 from Akash98Sky/main
Browse files Browse the repository at this point in the history
forefront: update account creation logic
  • Loading branch information
xtekky authored Apr 30, 2023
2 parents 22b9b1f + afae712 commit ed196d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 75 deletions.
41 changes: 18 additions & 23 deletions gpt4free/forefront/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from json import loads
from re import match
from re import findall
from time import time, sleep
from typing import Generator, Optional
from uuid import uuid4

from fake_useragent import UserAgent
from requests import post
from pymailtm import MailTm, Message
from tls_client import Session

from .mail import Mail
from .typing import ForeFrontResponse


Expand All @@ -19,11 +19,8 @@ def create(proxy: Optional[str] = None, logging: bool = False):

start = time()

mail_client = Mail(proxies)
mail_token = None
mail_address = mail_client.get_mail()

# print(mail_address)
mail_client = MailTm().get_account()
mail_address = mail_client.address

client = Session(client_identifier='chrome110')
client.proxies = proxies
Expand All @@ -33,7 +30,7 @@ def create(proxy: Optional[str] = None, logging: bool = False):
}

response = client.post(
'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.32.6',
'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
data={'email_address': mail_address},
)

Expand All @@ -45,9 +42,10 @@ def create(proxy: Optional[str] = None, logging: bool = False):
return 'Failed to create account!'

response = client.post(
f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.32.6',
f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4',
data={
'strategy': 'email_code',
'strategy': 'email_link',
'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'
},
)

Expand All @@ -59,26 +57,23 @@ def create(proxy: Optional[str] = None, logging: bool = False):

while True:
sleep(1)
for _ in mail_client.fetch_inbox():
if logging:
print(mail_client.get_message_content(_['id']))
mail_token = match(r'(\d){5,6}', mail_client.get_message_content(_['id'])).group(0)
new_message: Message = mail_client.wait_for_message()
if logging:
print(new_message.data['id'])

verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0]

if mail_token:
if verification_url:
break

if logging:
print(mail_token)
print(verification_url)

response = client.post(
f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/attempt_verification?_clerk_js_version=4.38.4',
data={'code': mail_token, 'strategy': 'email_code'},
)
response = client.get(verification_url)

if logging:
print(response.json())
response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')

token = response.json()['client']['sessions'][0]['last_active_token']['jwt']
token = response.json()['response']['sessions'][0]['last_active_token']['jwt']

with open('accounts.txt', 'a') as f:
f.write(f'{mail_address}:{token}\n')
Expand Down
52 changes: 0 additions & 52 deletions gpt4free/forefront/mail.py

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ fake-useragent
twocaptcha
https://github.com/AI-Yash/st-chat/archive/refs/pull/24/head.zip
pydantic
pymailtm

0 comments on commit ed196d8

Please sign in to comment.