{"id":21529176,"url":"https://github.com/everx-labs/tor-service","last_synced_at":"2025-07-25T07:38:28.295Z","repository":{"id":53176644,"uuid":"329274416","full_name":"everx-labs/tor-service","owner":"everx-labs","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-20T15:07:46.000Z","size":58,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-14T02:52:16.253Z","etag":null,"topics":["everscale"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/everx-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-13T10:38:21.000Z","updated_at":"2024-01-18T10:48:35.000Z","dependencies_parsed_at":"2024-04-16T15:33:09.691Z","dependency_job_id":"12dda414-b2ac-45e1-8fe0-3c37bd88b665","html_url":"https://github.com/everx-labs/tor-service","commit_stats":null,"previous_names":["everx-labs/tor-service"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/everx-labs/tor-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Ftor-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Ftor-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Ftor-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Ftor-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/everx-labs","download_url":"https://codeload.github.com/everx-labs/tor-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everx-labs%2Ftor-service/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266974493,"owners_count":24014922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["everscale"],"created_at":"2024-11-24T01:56:07.152Z","updated_at":"2025-07-25T07:38:28.269Z","avatar_url":"https://github.com/everx-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authentication and authorization package for a website\n\n## Prerequisites\n\nPython 3.x (code was tested with Python 3.8.6)\n\nNetwork connection: external public API (https://zxing.org) is used to decode QR code\n\n## Implemented functionality\n\n-   Ability to deploy Multisig wallet with one custodian in TON blockchain\n-   Signing in / Signing up using Surf wallet\n-   Binding Surf wallet by an logged-in user\n\nTo complete the last two tasks, the following steps are performed:\n\n-   Backend generates QR code containing some \"random string\"\n\n-   The user is shown the QR code and (in the case of binding Surf wallet) PIN code\n\n-   User scans this QR code and is redirected to Surf\n\n-   The user inputs PIN (in the case of binding Surf wallet)\n\n-   The user signs received \"random string\" with his keys\n\n-   Backend gets signed string and checks if it is equal to the generated one\n\n-   Backend calls back with authentication result, user wallet address and public key\n\n## Installation\n\n```\npip install --user -r requirements.txt\n\n```\n\n## Run test\n\n```\npython -m unittest -v tests/UserAuthSuccess.py\npython -m unittest -v tests/UserAuthFail.py\n```\n\n## Example\n\n```\nimport asyncio\nfrom tests.mocks.Surf import Surf\nfrom torauth import Authenticator, Config, deploy_wallet\n\nconfig = Config()\nauth = Authenticator(config)\n\n# Define authentication callback\nasync def on_auth_callback(\n                context: str, result: bool,  public_key: str = None, wallet_address: str = None):\n    print(f'Authentication result is {result}') # Here we here all needed user data\n\n\n# Initialize auth module by passing a callback function\nawait auth.init(on_auth_callback)\n\n# if you need to change callback function,\n# call auth.close(), before re-initialization\n\nasync def authenticate_user(user_id):\n\n    # Ask for QR code to start authentication procedure\n    base64_qr_code = await auth.start_authentication(\n        webhook_url=WEBHOOK_URL,     # Endpoint where Surf returns signed data\n        pin=PIN,                     # Used when logged-in user wants to bind Surf wallet\n        retention_sec = 600,         # The period of time this QR code is valid\n        context = {\"user_id\": ....}  # Any serializable context. It will be\n                                     # used as a parameter of the callback\n    )\n\n    # Show this code to the user so they can scan it,\n    # If the logged-in user wants to bind the Surf wallet, additionally show him the PIN code\n    #\n    # For automated testing we using Surf mock \n    surf = Surf(config, wallet_address, public_key, secret_key, callback_type='webhook')\n    task = asyncio.create_task(surf.sign(base64_qr_code, PIN))\n\n    # When the user completes the authentication procedure in Surf or\n    # `retention_sec` period has passed, will be executed callback:\n    # `on_auth_callback(context, result, public_key, wallet_address:)` \n```\n\nYou can find a real example here: `tests/UserAuthSuccess.py`\n\n### TODO\n\n    - Implement exponential backoff in case of network errors\n    - Rights management ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverx-labs%2Ftor-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feverx-labs%2Ftor-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverx-labs%2Ftor-service/lists"}