Status: built (2026-10-05) in packages/swift. Tested without Xcode: swift run passkin-selftest (95 checks against an in-memory Passkin, attacks included) and packages/swift/scripts/test-live.sh (the same plus the whole protocol — hosted page, PKCE, code exchange, refresh rotation, /v1/me, revoke — against a real broker started for the purpose). Not exercised on a device or simulator: the system sheet, the iOS window lookup and the Sign in with Apple / Google SDK calls need Xcode.
Before this, an iPhone app used AppAuth and hand-wrote the Sign in with Apple exchange. The SDK is the same protocol, packaged: what Clerk, Auth0 and Supabase ship as their Swift SDKs.
Set up
- Dashboard → Applications → Add an iPhone app. Give it the bundle id and a redirect URI: its own reverse-domain scheme (
com.example.shop:/callback) or a Universal Link. The page shows the application's client id. - Add the scheme under URL Types in
Info.plist(a Universal Link needs Associated Domains instead). - Add the package (see Distribution), and:
import Passkin
let passkin = Passkin(configuration: .init(
publishableKey: "pk_live_…", clientID: "<the iPhone application's client id>",
redirectURL: URL(string: "com.example.shop:/callback")!))
let session = try await passkin.signIn()
let token = try await passkin.accessToken() // for your backend: Authorization: Bearer …
For Sign in with Apple natively, add the capability in Xcode, turn it on under the application's Native sign-in, then:
let nonce = try await passkin.nativeNonce()
let request = ASAuthorizationAppleIDProvider().createRequest()
request.requestedScopes = [.fullName, .email]
request.nonce = nonce
// …present ASAuthorizationController; in its delegate:
let session = try await passkin.signInWithApple(identityToken: credential.identityToken!, nonce: nonce,
givenName: credential.fullName?.givenName, familyName: credential.fullName?.familyName)
If that throws PasskinError.interactionRequired (the person has a second factor, or the project requires one — STEP-UP.md) call passkin.signIn(): the sheet can ask.
Behaviour worth knowing
| Sign-in | PKCE S256, a state and nonce per sign-in, and the redirect's iss must be the project's (RFC 9207: a mix-up is refused). A wrong state, issuer, nonce, audience or an expired ID token throws invalidResponse and stores nothing |
| Discovery | Read from <baseURL>/p/<pk>/.well-known/openid-configuration and used only if it names the issuer it was fetched for (OpenID Connect Discovery §4.3) |
| Storage | Keychain, AfterFirstUnlockThisDeviceOnly: not in backups, not synced. Replace it with a TokenStore of your own (an app group, say) |
| Refresh | accessToken(minimumValidity: 30): simultaneous callers share one refresh; the refresh token is rotated and the new one stored before anyone sees the new access token. invalid_grant (signed out elsewhere, banned, reuse detected) drops the session and throws notSignedIn; a network failure keeps it |
| Sign-out | Revokes the refresh token at Passkin (which ends the session) and forgets it here, even offline. signOutEverywhereOnThisDevice() also ends the hosted page's own cookie in the sheet |
| Your domain | baseURL: URL(string: "https://auth.example.com")! (CUSTOM-DOMAIN.md) |
| Org and step-up | SignInOptions(organization:), acrValues: [SignInOptions.multiFactor], maxAge; User.isMultiFactor, organizationID/Role, session.organizationPermissions |
| Platforms | iOS 16+, macOS 13+, tvOS 16+, visionOS 1+, watchOS 9+ (no sheet on tvOS/watchOS: pass a presenter, or authorizationURL and handleRedirect) |
Distribution (owner action)
SwiftPM resolves a package from a repository's root Package.swift, and this repository is private and a monorepo. Release it by mirroring packages/swift to a public repository (for example passkin/passkin-swift) with a version tag; .package(url: "https://github.com/passkin/passkin-swift", from: "0.1.0") then works. A mirroring workflow is not set up. Until then the folder can be added as a local package.
Not built
Kotlin / Android, React Native and Flutter SDKs (no toolchain to compile them with here; the AppAuth recipes in INTEGRATION.md §8 still apply); native passkey calls (ASAuthorizationPlatformPublicKeyCredentialProvider: passkeys already work inside the sheet, and native ones need the Associated Domains webcredentials entry for the relying-party id); an XCTest target (needs Xcode — the self-test is an executable for that reason); a SwiftUI sign-in button and user-profile views; App Attest / device binding of the refresh token; a published release.