DiditAuth module signs your iOS app’s end users up and in with Didit Authentication.
It opens your application’s hosted Didit page in ASWebAuthenticationSession, supports passkeys through ASAuthorization, keeps the session in the Keychain, and handles sign-out and step-up.
It ships in the native SDKs since version 4.11.0, and the current release is 4.15.4.
Use a Sandbox application while you build.
Every Sandbox application has Authentication turned on from the start.
A Live application turns Authentication on from the Products page of the console: see Prepare your application.
Install
Add the Swift Packagehttps://github.com/didit-protocol/sdk-ios.git at 4.15.4 and add the DiditAuth product to your target:
Package.swift
Auth subspec.
The podspec URL embeds the git tag, which must equal the SDK version you install.
Never point it at main.
Podfile
DiditAuth module needs iOS 15 and you write import DiditAuth.
Every DiditSDK variant of the iOS verification SDK already includes it, and an app that installs one keeps import DiditSDK.
Install one or the other, not both.
The hosted pages (sign-in and step-up checks) need iOS 17.4.
Below that, those calls throw browser_unavailable, and signInWithPasskey still works.
Set up the redirect and passkeys
Didit returns people to your app through an HTTPS redirect only. Custom URL schemes are not accepted.- In the console, under Authentication > Security and sessions, add your redirect URL, for example
https://app.example.com/didit/callback. Copy the publishable key from Authentication > Developers. - Add the redirect’s host to your app’s Associated Domains as
webcredentials:app.example.com, and servehttps://app.example.com/.well-known/apple-app-site-associationlisting your app (TEAMID.bundle.id) underwebcredentials. iOS checks both before it opens the page. - For passkeys, register your app ID with
PUT native-apps/on the Authentication management API, and addwebcredentials:<your application's Didit host>to your Associated Domains too. A redirect URL on that same Didit host also satisfies step 2.
Sign in
S256) and a random state, and a redirect for any other sign-in is refused.
Closing the page throws cancelled.
Refresh tokens rotate and Didit revokes the session when a used one comes back, so every DiditAuth instance of the application refreshes under one lock and only once.
A session Didit ended (revoked, expired, a reused refresh token) reads as signed out.
reauthenticate asks the signed-in person to sign in again, on the hosted page or with method: .passkey, and returns their new session.
It throws not_signed_in without a session and step_up_user_mismatch when a different person signs in: that new session is ended and the current one stays.
Tokens stay in the Keychain on this device only (kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly).
DiditSession holds userId, sessionId, applicationId, vendorData, email, emailVerified, phone, methods, mfaVerified, verified, organizations and expiresAt.
vendorData is the id that ties the person to their verifications and transactions: see keep one person across products.
Verify the token on your backend
SendgetToken() to your backend as a Bearer token and verify it there, against the issuer’s JWKS at <origin>/.well-known/jwks.json, before you trust it.
Use a server SDK or see tokens and JWKS.
Call getToken() right before each request: after a refresh, the previous access token stops working at GET session/ and DELETE session/.
Step-up before sensitive actions
.payout, .bankAccount and .contactChange follow the step-up rules of your application.
When a rule applies, the identity check opens on the hosted page.
The result is what Didit recorded when the person came back: not_required, approved, pending, review, declined or expired.
Errors
Every call throwsDiditAuthError with a code.
The code is the Didit API’s own (invalid_grant, method_unavailable, reauthentication_required) or one of cancelled, invalid_state, not_signed_in, step_up_user_mismatch, passkey_cancelled, passkey_unavailable, browser_unavailable, storage_unavailable, invalid_publishable_key, invalid_redirect_uri, network_error, rate_limited (with retryAfter) and server_error.
A sign-out without network still signs the person out on the device.
Connect verification and monitoring
Your backend derivesvendor_data from the verified token.
It creates verification sessions or mints scoped monitoring tokens for that person, and returns only the session credential or scoped token to your app.
The API key stays on the server.
Use the iOS verification SDK for identity verification, and follow SDK transaction submission for monitoring.
Treat sign-in, verification and transaction decisions separately.