Skip to content

feat: add async client base, AsyncHTTPClient, AsyncDescopeClient, and async TOTP#1562

Draft
LioriE wants to merge 4 commits into
mainfrom
feat/poc-async-base-and-totp
Draft

feat: add async client base, AsyncHTTPClient, AsyncDescopeClient, and async TOTP#1562
LioriE wants to merge 4 commits into
mainfrom
feat/poc-async-base-and-totp

Conversation

@LioriE
Copy link
Copy Markdown
Contributor

@LioriE LioriE commented Jun 5, 2026

Summary

  • Introduced _ClientBase and _AuthBase to extract shared sync/async logic
  • Added AsyncHTTPClient with httpx.AsyncClient for non-blocking HTTP
  • Added AsyncDescopeClient as the async counterpart to DescopeClient
  • Added async TOTP support via AsyncTOTP backed by a shared _TOTPBase
  • Refactored DescopeClient and TOTP to reuse the new base classes

Status

Draft / POC — async infrastructure is in place; remaining auth methods need to be ported to async.

Test plan

  • tests/test_async_http_client.py — AsyncHTTPClient unit tests
  • tests/test_descope_client_parity.py — sync/async client behaviour parity
  • tests/test_totp_parity.py — sync/async TOTP parity

… async TOTP

Introduces an async execution layer alongside the existing sync client:
- AsyncHTTPClient (httpx.AsyncClient-based) with retry, verbose, and lifecycle support
- DescopeClientBase shared base for sync/async clients (init validation, pure-CPU helpers)
- TOTPBase shared base for sign_up/sign_in_code/update_user validation logic
- AsyncTOTP and AsyncDescopeClient as async-native counterparts
- Unified pytest fixtures (conftest.py) and test suites covering both clients:
  test_async_http_client.py, test_totp_unified.py, test_descope_client_unified.py
Comment thread tests/test_descope_client_unified.py Fixed
Co-Authored-By: LioriE <lior.eliav@descope.com>
Comment thread tests/test_descope_client_parity.py
client = client_factory.make(PROJECT_ID, PUBLIC_KEY_DICT)

data = json.loads(
"""{"jwts": ["eyJhbGciOiJFUzM4NCIsImtpZCI6IjJCdDVXTGNjTFVleTFEcDd1dHB0WmIzRng5SyIsInR5cCI6IkpXVCJ9.eyJjb29raWVEb21haW4iOiIiLCJjb29raWVFeHBpcmF0aW9uIjoxNjYwMzg4MDc4LCJjb29raWVNYXhBZ2UiOjI1OTE5OTksImNvb2tpZU5hbWUiOiJEU1IiLCJjb29raWVQYXRoIjoiLyIsImV4cCI6MTY2MDIxNTI3OCwiaWF0IjoxNjU3Nzk2MDc4LCJpc3MiOiIyQnQ1V0xjY0xVZXkxRHA3dXRwdFpiM0Z4OUsiLCJzdWIiOiIyQnRFSGtnT3UwMmxtTXh6UElleGRNdFV3MU0ifQ.oAnvJ7MJvCyL_33oM7YCF12JlQ0m6HWRuteUVAdaswfnD4rHEBmPeuVHGljN6UvOP4_Cf0559o39UHVgm3Fwb-q7zlBbsu_nP1-PRl-F8NJjvBgC5RsAYabtJq7LlQmh"], "user": {"loginIds": ["guyp@descope.com"], "name": "", "email": "guyp@descope.com", "phone": "", "verifiedEmail": true, "verifiedPhone": false}, "firstSeen": false}"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id jwt in commit e44fd59.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo e44fd5977ffd62c56f63c32e2422bf2c0e87c816:tests/test_descope_client_parity.py:jwt:761 >> .gitleaksignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant