@didit-protocol/auth-react-native package signs your React Native app’s end users up and in with Didit Authentication on Android and iOS.
It opens your application’s hosted Didit page, supports passkeys, keeps the session in the iOS Keychain or the Android Keystore, and handles sign-out and step-up.
It is published on npm at version 0.1.4 and wraps the native Authentication modules at release 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.
Requirements
Below iOS 17.4 the hosted page cannot return to an HTTPS redirect, so
signIn fails with browser_unavailable, and so does stepUp when a check has to run.
Session, token and sign-out calls are not affected.
Install
cd ios && pod install, then run the app).
Identity verification has its own package, @didit-protocol/sdk-react-native.
Both can be installed in one app, because they pin the same native release.
Set up the redirect and passkeys
Didit sends the person back to your app with an HTTPS redirect, and accepts no custom URL schemes. Register the redirect URI under Authentication > Security and sessions and copy the publishable key from Authentication > Developers in the console, then follow the setup of each platform:- Android: the App Link, the redirect activity and passkeys in the Android quickstart.
- iOS: the associated domains and passkeys in the iOS quickstart.
Install the native modules
On Android nothing else is needed: the package adds Didit’s Maven repository (theme.didit group only) to your build, and Gradle resolves me.didit:didit-auth from it.
If your android/settings.gradle sets repositoriesMode to PREFER_SETTINGS, which ignores repositories added by a build file, list https://raw.githubusercontent.com/didit-protocol/sdk-android/main/repository there.
On iOS, CocoaPods is the default.
Name the Didit podspec at the pinned version in ios/Podfile:
$DiditSdkIosLinkage = 'spm' before use_native_modules! and leave the pod line out.
The package then adds the DiditAuth product of sdk-ios.
Sign in
S256) and a random state, and a redirect for any other sign-in is refused.
Closing the page rejects with cancelled.
A session Didit ended (revoked, expired, a reused refresh token) reads as signed out: currentSession and getToken resolve with null.
reauthenticate asks the signed-in person to sign in again, on the hosted page or with { method: 'passkey' }, and resolves with their new session.
It rejects with 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.
Refresh tokens stay in the Keychain or the Android Keystore and never reach JavaScript.
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
stepUp also takes { action: 'bank' } (adding or changing a bank account) and { action: 'contact' } (changing the email or phone), and follows the step-up rules of your application.
When a rule applies, the identity check opens on the hosted page.
The result’s status is what Didit recorded when the person came back: not_required, approved, pending, review, declined or expired.
Errors
Every call rejects with aDiditAuthError that has a code and a message, plus status, fields and retryAfter (seconds) when Didit sent them.
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, invalid_request, network_error, rate_limited (with retryAfter) and server_error.
The codes are the same on Android and iOS.
browser_unavailable when no screen of the app is in the foreground.
In a build without the native module, such as Expo Go, importing the package works and every call rejects with DiditAuthUnavailableError (code ERR_DIDIT_AUTH_UNAVAILABLE).
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 React Native verification SDK for identity verification, and follow SDK transaction submission for monitoring.
Treat sign-in, verification and transaction decisions separately.