{"id":51623354,"url":"https://github.com/hexclave/swift-sdk-prerelease","last_synced_at":"2026-07-12T21:30:40.918Z","repository":{"id":340420979,"uuid":"1137344215","full_name":"hexclave/swift-sdk-prerelease","owner":"hexclave","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-20T19:24:41.000Z","size":138,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T00:57:31.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexclave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-19T08:48:59.000Z","updated_at":"2026-05-20T19:24:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hexclave/swift-sdk-prerelease","commit_stats":null,"previous_names":["stack-auth/swift-sdk-prerelease","hexclave/swift-sdk-prerelease"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/hexclave/swift-sdk-prerelease","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexclave%2Fswift-sdk-prerelease","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexclave%2Fswift-sdk-prerelease/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexclave%2Fswift-sdk-prerelease/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexclave%2Fswift-sdk-prerelease/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexclave","download_url":"https://codeload.github.com/hexclave/swift-sdk-prerelease/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexclave%2Fswift-sdk-prerelease/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35403794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-12T02:00:06.386Z","response_time":87,"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":[],"created_at":"2026-07-12T21:30:40.234Z","updated_at":"2026-07-12T21:30:40.913Z","avatar_url":"https://github.com/hexclave.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hexclave Swift SDK\n\nSwift SDK for Hexclave. Supports iOS, macOS, watchOS, tvOS, and visionOS.\n\n## Requirements\n\n- Swift 5.9+\n- iOS 15+ / macOS 12+ / watchOS 8+ / tvOS 15+ / visionOS 1+\n\n## Installation\n\nAdd to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/hexclave/swift-sdk-prerelease\", from: \u003cversion\u003e)\n]\n```\n\n## Quick Start\n\n```swift\nimport StackAuth\n\nlet stack = StackClientApp(\n    projectId: \"your-project-id\",\n    publishableClientKey: \"your-key\"\n)\n\n// Sign in with email/password\ntry await stack.signInWithCredential(email: \"user@example.com\", password: \"password\")\n\n// Get current user\nif let user = try await stack.getUser() {\n    print(\"Signed in as \\(user.displayName ?? \"Unknown\")\")\n}\n\n// Sign out\ntry await stack.signOut()\n```\n\n## Design Decisions\n\n### Error Handling\n\nAll functions that can fail use Swift's native `throws`. Errors conform to `StackAuthError`:\n\n```swift\ndo {\n    try await stack.signInWithCredential(email: email, password: password)\n} catch let error as StackAuthError {\n    switch error.code {\n    case \"email_password_mismatch\":\n        print(\"Wrong password\")\n    default:\n        print(error.message)\n    }\n}\n```\n\n### Token Storage\n\n- **Default**: Keychain (secure, persists across app launches)\n- **Option**: Memory (for testing or ephemeral sessions)\n- **Option**: Custom `TokenStoreProtocol` implementation\n\n```swift\n// Memory storage (for testing)\nlet stack = StackClientApp(\n    projectId: \"...\",\n    publishableClientKey: \"...\",\n    tokenStore: .memory\n)\n\n// Custom storage\nlet stack = StackClientApp(\n    projectId: \"...\",\n    publishableClientKey: \"...\",\n    tokenStore: .custom(MyTokenStore())\n)\n```\n\n### OAuth Flows\n\nTwo approaches for OAuth authentication:\n\n**1. Integrated (recommended)** - Uses `ASWebAuthenticationSession`:\n\n```swift\n// Opens auth session, handles callback automatically\n// Uses fixed callback scheme: hexclave-mobile-oauth-url://\ntry await stack.signInWithOAuth(provider: \"google\")\n```\n\n**2. Manual URL handling** - For custom implementations:\n\n\u003e **Note:** The `hexclave-mobile-oauth-url://` scheme is automatically accepted (the legacy `stack-auth-mobile-oauth-url://` scheme also remains accepted for backwards compatibility).\n\n```swift\n// Get the OAuth URL (must provide absolute URLs)\nlet oauth = try await stack.getOAuthUrl(\n    provider: \"google\",\n    redirectUrl: \"hexclave-mobile-oauth-url://success\",\n    errorRedirectUrl: \"hexclave-mobile-oauth-url://error\"\n)\n\n// Open oauth.url in your own browser/webview\n// Store oauth.state, oauth.codeVerifier, and oauth.redirectUrl\n\n// When callback received:\ntry await stack.callOAuthCallback(\n    url: callbackUrl,\n    codeVerifier: oauth.codeVerifier,\n    redirectUrl: oauth.redirectUrl\n)\n```\n\n### Async/Await\n\nAll async operations use Swift's native concurrency:\n\n```swift\nTask {\n    let user = try await stack.getUser()\n    let teams = try await user?.listTeams()\n}\n```\n\n## Key Differences from JavaScript SDK\n\n| Aspect | JavaScript | Swift |\n|--------|-----------|-------|\n| Token Storage | Cookies | Keychain |\n| OAuth | Browser redirect | ASWebAuthenticationSession |\n| Redirect methods | Available | Not available (browser-only) |\n| React hooks | `useUser()` etc. | Not applicable |\n\n### Not Available in Swift\n\nThe following are browser-only and not exposed:\n\n- `redirectToSignIn()`, `redirectToSignUp()`, etc.\n- Cookie-based token storage\n- `redirectMethod` constructor option\n\n## Examples\n\nInteractive example apps are available for testing all SDK functions:\n\n### macOS Example\n\n```bash\ncd Examples/StackAuthMacOS\nswift run\n```\n\nFeatures a sidebar-based UI for testing authentication, user management, teams, OAuth, tokens, and server-side operations.\n\n### iOS Example\n\n```bash\ncd Examples/StackAuthiOS\nopen Package.swift  # Opens in Xcode\n```\n\nFeatures a tab-based UI optimized for iOS with the same comprehensive SDK coverage.\n\nBoth examples include:\n- Configurable API endpoints\n- Real-time operation logs\n- Error testing scenarios (wrong password, unauthorized access, etc.)\n- Client and server app operations\n\n## Testing\n\nTests use Swift Testing framework against a running backend.\n\n### Running Tests\n\n1. Start the development server:\n   ```bash\n   pnpm dev\n   ```\n\n2. Run tests:\n   ```bash\n   cd sdks/implementations/swift\n   swift test\n   ```\n\nThe tests connect to `http://localhost:8102` (or `${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX}02`).\n\n## API Reference\n\nSee the [SDK Specification](../../spec/README.md) for complete API documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexclave%2Fswift-sdk-prerelease","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexclave%2Fswift-sdk-prerelease","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexclave%2Fswift-sdk-prerelease/lists"}