Commit Graph

13 Commits

Author SHA1 Message Date
Ejiro Asiuwhu
8060bc67ff feat: export auth types and functions from stack_auth package
- Add AuthState, TokenPartialUser, decode_access_token_claims to public API
- Add sync_authenticate_request and async_authenticate_request exports
- Existing exports unchanged
2026-03-25 00:51:27 +01:00
Ejiro Asiuwhu
3ca550191b feat: add authenticate_request with jwt verification and partial decode
- TokenPartialUser frozen dataclass for unverified JWT payload extraction
- AuthState frozen dataclass for authentication results
- decode_access_token_claims extracts user info without signature verification
- _extract_token_from_headers handles Authorization and x-stack-auth headers
- sync_authenticate_request and async_authenticate_request compose with JWKS verifier
2026-03-25 00:50:59 +01:00
Ejiro Asiuwhu
ad63cf03a0 test: add failing tests for token store subsystem
- TokenStore ABC, MemoryTokenStore, ExplicitTokenStore, RequestTokenStore
- Registry with shared instances per project_id
- CAS refresh algorithm with timing thresholds (20s/75s)
- Sync and async variants of get_or_fetch_likely_valid_tokens
- Helper functions: _is_fresh_enough, _is_expired, _decode_jwt_payload
2026-03-25 00:50:23 +01:00
Ejiro Asiuwhu
ea427ed423 test: add failing tests for auth module
- Tests for decode_access_token_claims (valid JWT, defaults, malformed, missing sub, base64url)
- Tests for _extract_token_from_headers (Authorization, lowercase, x-stack-auth, missing)
- Tests for sync_authenticate_request and async_authenticate_request
2026-03-25 00:50:06 +01:00
Ejiro Asiuwhu
07c32d4a6e feat: add pagination support with cursor-based PaginatedResult
- PaginatedResult[T] generic wrapping nested {items, pagination: {next_cursor}} shape
- Convenience properties .next_cursor and .has_next_page
- Package __init__.py exports all models, errors, and PaginatedResult
- SyncAPIClient/AsyncAPIClient intentionally excluded from public API
- Tests verify pagination with ServerUser and Team types
2026-03-24 22:25:13 +01:00
Ejiro Asiuwhu
aecd4aa6e7 feat: add project, api key, oauth, payment, and notification models
- Project with nested ProjectConfig and OAuthProviderConfig
- ApiKey hierarchy: ApiKey, UserApiKey, UserApiKeyFirstView, TeamApiKey, TeamApiKeyFirstView
- OAuthConnection and OAuthProvider models
- Item and Product payment models
- NotificationCategory model
- models/__init__.py re-exports all 20+ model classes
2026-03-24 22:23:58 +01:00
Ejiro Asiuwhu
28171d43cf feat: add sync and async HTTP client with retry logic
- BaseAPIClient generic base with header construction, URL building,
  response parsing via x-stack-actual-status and x-stack-known-error
- SyncAPIClient wrapping httpx.Client with context manager support
- AsyncAPIClient wrapping httpx.AsyncClient with async context manager
- Exponential backoff retry for idempotent methods (GET/PUT/DELETE)
- 429 rate limit handling with Retry-After header support
- POST/PUT/PATCH with no body sends {} as JSON
- All 26 tests passing
2026-03-24 22:23:56 +01:00
Ejiro Asiuwhu
7b75ba81a8 feat: add jwt verification with async jwks fetcher and ttl cache
- AsyncJWKSFetcher and SyncJWKSFetcher with 5-minute in-memory TTL cache
- verify_token (async + sync) decodes RS256 JWTs via PyJWT
- Algorithm hardcoded to RS256 to prevent CVE-2022-29217 algorithm confusion
- Force-refresh on unknown kid for key rotation handling
2026-03-24 22:23:23 +01:00
Ejiro Asiuwhu
488e72a9cf feat: add user, team, session, contact channel, and permission pydantic models
- BaseUser and ServerUser with camelCase aliases and millis-to-datetime properties
- Team, ServerTeam, TeamMemberProfile, TeamInvitation with timestamp conversions
- ActiveSession with GeoInfo nested model
- ContactChannel and TeamPermission/ProjectPermission
- Tests for user and team model parsing, inheritance, and field conversion
2026-03-24 22:23:11 +01:00
Ejiro Asiuwhu
6b4cd35875 test: add failing tests for jwt verification and jwks fetching
- AsyncJWKSFetcher and SyncJWKSFetcher construction and key retrieval
- TTL cache behavior with 5-minute expiry
- Force-refresh on unknown kid
- verify_token for valid, expired, invalid signature, missing kid tokens
- CVE-2022-29217 protection: HS256 tokens rejected
2026-03-24 22:22:34 +01:00
Ejiro Asiuwhu
fbe1c5bfc3 test: add failing tests for sync and async HTTP client
- 22 tests covering construction, headers, URL building, request pipeline
- Response processing with x-stack-actual-status and x-stack-known-error
- Retry logic with exponential backoff for idempotent methods
- 429 rate limit handling with Retry-After header
- Context manager protocol for both sync and async clients
2026-03-24 22:22:32 +01:00
Ejiro Asiuwhu
a8c18f366b feat: add python sdk package skeleton with error hierarchy
- StackAuthError base with code/message/details and from_response() factory
- 13 category subclasses: Authentication, NotFound, Validation, PermissionDenied,
  Conflict, OAuth, Passkey, ApiKey, Payment, Email, RateLimit, Cli, Analytics
- Complete _ERROR_CODE_MAP with 143 error codes from known-errors.tsx
- StackAuthModel base class with Pydantic v2 ConfigDict and millis conversion
- Package exports via __init__.py with __all__
2026-03-24 22:18:36 +01:00
Ejiro Asiuwhu
728533c87f test: add failing tests for python sdk error hierarchy and base model
- Test StackAuthError base class storage and string representation
- Test all 13 category subclasses inherit from StackAuthError
- Test from_response() dispatch for known and unknown error codes
- Test StackAuthModel config and millis conversion
- Package skeleton with pyproject.toml (stubs only, tests expected to fail)
2026-03-24 22:17:03 +01:00