Skip to main content

Error Codes

Error codes are platform-specific. iOS and Android often use different names for the same condition (for example USER_CANCEL on iOS and USER_CANCELED on Android), so check for both when you branch on a code.

How codes are returned​

  • Rejected promise, code in error.code: simplePrompt(), authenticateWithOptions(), createKeys(), createKeysWithOptions(), deleteKeys(), getPublicKey(), getAllKeys() and configureKeyAlias().
  • Resolved result, code in result.errorCode: isSensorAvailable() (with available: false), signWithOptions(), verifyKeySignature() and sign() (with success: false), and getKeyAttributes() on iOS.

validateKeyIntegrity() and validateSignature() report failures only as an error message, without a code.

try {
await simplePrompt('Confirm your identity');
} catch (error: any) {
if (error.code === 'USER_CANCEL' || error.code === 'USER_CANCELED') {
// The user dismissed the prompt
}
}

const result = await signWithOptions({ data: payload });
if (!result.success && result.errorCode === 'KEY_NOT_FOUND') {
// Create the key first
}

Setup codes​

Calls that need the native module reject with this code when it is missing — in Expo Go or when the app wasn't rebuilt after installing the library. This applies even to functions that otherwise resolve with an errorCode, such as isSensorAvailable(). APIs that run only in JavaScript keep working: configure() without a keyAlias, getLogs(), clearLogs(), and subscribeToBiometricChanges() (which never fires). Don't treat their success as a sign that biometrics are available.

CodeDescriptionPlatform
NATIVE_MODULE_UNAVAILABLEThe native module isn't linked. Use a development build instead of Expo Go, or rebuild the app (and run pod install on iOS).Both

Same condition, different code​

ConditioniOSAndroid
User canceled the promptUSER_CANCELUSER_CANCELED
System canceled the promptSYSTEM_CANCELSYSTEM_CANCELED
Too many failed attemptsBIOMETRY_LOCKOUTBIOMETRIC_LOCKOUT, BIOMETRIC_LOCKOUT_PERMANENT
No biometrics enrolledBIOMETRY_NOT_ENROLLEDNO_BIOMETRICS_ENROLLED (prompts), BiometricErrorNoneEnrolled (isSensorAvailable)
No biometric hardwareBIOMETRY_NOT_AVAILABLENO_BIOMETRIC_HARDWARE (prompts), BiometricErrorNoHardware (isSensorAvailable)
No passcode / device credential setPASSCODE_NOT_SETNO_DEVICE_CREDENTIAL

Authentication codes​

simplePrompt() and authenticateWithOptions() reject with these codes. signWithOptions() and verifyKeySignature() resolve with the Android codes in errorCode when the prompt fails. On iOS, isSensorAvailable() reports its errorCode from the same iOS set.

CodeDescriptionPlatform
USER_CANCELThe user canceled authentication.iOS
USER_FALLBACKThe user tapped the fallback button (for example "Enter Password").iOS
SYSTEM_CANCELThe system canceled authentication, for example because the app moved to the background.iOS
AUTHENTICATION_FAILEDThe user did not provide valid credentials.iOS
BIOMETRY_NOT_AVAILABLEBiometry can't be used. simplePrompt() and authenticateWithOptions() return this for any failed pre-check, including no enrollment; call isSensorAvailable() for the specific reason.iOS
BIOMETRY_NOT_ENROLLEDNo Face ID, Touch ID or Optic ID identity is enrolled.iOS
BIOMETRY_LOCKOUTBiometry is locked after too many failed attempts; the passcode is needed to unlock it.iOS
PASSCODE_NOT_SETNo device passcode is set.iOS
INVALID_CONTEXTThe authentication context was invalidated.iOS
NOT_INTERACTIVEAuthentication needs UI, but showing UI is not allowed.iOS
UNKNOWN_ERRORAny other LocalAuthentication error (for example an app cancel); the message includes the native code.iOS
USER_CANCELEDThe user canceled authentication or tapped the cancel button.Android
SYSTEM_CANCELEDThe system canceled authentication, for example because the app moved to the background.Android
BIOMETRIC_UNAVAILABLEThe biometric hardware is temporarily unavailable.Android
BIOMETRIC_TIMEOUTThe prompt timed out.Android
BIOMETRIC_LOCKOUTToo many failed attempts; biometrics are locked for a while.Android
BIOMETRIC_LOCKOUT_PERMANENTToo many failed attempts; biometrics stay locked until the user unlocks the device with their PIN, pattern or password.Android
NO_BIOMETRICS_ENROLLEDNo biometric is enrolled.Android
NO_BIOMETRIC_HARDWAREThe device has no biometric hardware.Android
NO_DEVICE_CREDENTIALDevice credentials were requested, but no PIN, pattern or password is set.Android
BIOMETRIC_ERRORAny other BiometricPrompt error (unable to process, no space, vendor error). isSensorAvailable() also rejects with it on an unexpected exception.Android
PROMPT_ERRORThe biometric prompt could not be shown.Android
ACTIVITY_ERRORsimplePrompt() only: there is no active activity to show the prompt in.Android
NO_ACTIVITYauthenticateWithOptions() only: there is no active activity to show the prompt in.Android

Sensor availability codes (Android)​

On Android, isSensorAvailable() resolves with available: false and one of these errorCode values. iOS uses the codes from Authentication codes.

CodeDescriptionPlatform
BiometricErrorNoHardwareThe device has no biometric hardware.Android
BiometricErrorHwUnavailableThe biometric hardware is temporarily unavailable.Android
BiometricErrorNoneEnrolledNo biometric of the requested strength is enrolled.Android
BiometricErrorSecurityUpdateRequiredA security update is required before biometrics can be used.Android
BiometricErrorUnsupportedThe requested authenticator type is not supported on this Android version.Android
BiometricStatusUnknownAndroid could not determine biometric availability.Android

Signing codes​

signWithOptions(), verifyKeySignature() and sign() resolve with success: false and one of these codes in errorCode. On Android, prompt failures in signWithOptions() and verifyKeySignature() use the Android authentication codes. On iOS, Keychain lookup failures use the iOS Keychain status codes.

CodeDescriptionPlatform
INVALID_INPUTsign() was called with empty data.Both
INVALID_INPUT_ENCODINGinputEncoding is 'base64', but data is not valid base64.Both
KEY_NOT_FOUNDNo key exists for the alias.Both
KEY_REQUIRES_AUTHENTICATIONsign() was called on a key that needs user authentication; use signWithOptions() for those keys.Both
INVALID_ALGORITHMsign(): the requested algorithm does not match the key type.Both
UNSUPPORTED_ALGORITHMsign(): the key does not support the requested algorithm (for example SHA-512 on an Android key created before SHA-512 support or inside StrongBox).Both
SIGNATURE_CREATION_FAILEDSigning failed, including Keystore or Secure Enclave errors after a successful prompt; error contains the native message.Both
INVALID_KEY_TYPEThe alias does not refer to a private key entry.Android
BIOMETRIC_NOT_AVAILABLEsignWithOptions(): no authenticator the key accepts is available, or disableDeviceFallback is set for a key that only accepts device credentials.Android
ACTIVITY_NOT_AVAILABLEsignWithOptions(): there is no active activity to show the prompt in.Android
PROMPT_ERRORsignWithOptions(): the biometric prompt could not be shown.Android
KEY_USER_NOT_AUTHENTICATEDKeystore rejected the signing operation despite successful authentication (OEM auth-token delivery bug; automatically retried before this is returned — prompt the user to try again)Android
SIGNATURE_OPERATION_EXPIREDKeystore discarded the signing operation after a successful prompt, usually because the prompt was open too long (seen with StrongBox keys). Returned only after an automatic second prompt failed the same way. Prompt the user to try again.Android
BIOMETRY_CURRENT_SET_CHANGEDsignWithOptions(): biometric enrollment changed since a key created with biometricStrength: 'strong' was made, so the key must be recreated.iOS
USER_CANCELsignWithOptions(): the user canceled authentication.iOS
AUTHENTICATION_FAILEDsignWithOptions(): authentication failed.iOS
KEY_ACCESS_FAILEDsignWithOptions(): the Secure Enclave reported corrupted key data.iOS

On iOS, signWithOptions(), verifyKeySignature() and sign() reject with DATA_ENCODING_FAILED if UTF-8 data can't be encoded.

Key management codes​

createKeys(), createKeysWithOptions(), deleteKeys(), getPublicKey(), getAllKeys() and configureKeyAlias() reject with these codes.

CodeDescriptionPlatform
KEY_ALREADY_EXISTScreateKeys() with failIfExists: true found an existing key with the alias.Both
KEY_NOT_FOUNDgetPublicKey(): no key exists for the alias.Both
CREATE_KEYS_ERRORKey creation failed: invalid key type or biometric strength, allowDeviceCredentials below API 30, no enrolled biometric, or a Keystore error.Android
DELETE_KEYS_ERRORKey deletion failed or could not be verified.Android
GET_PUBLIC_KEY_ERRORReading the public key failed.Android
GET_ALL_KEYS_ERRORListing keys failed.Android
INVALID_KEY_ALIASconfigureKeyAlias() was called with an empty alias.Android
INVALID_PARAMETERScreateKeys(): unsupported key type or biometric strength.iOS
DATA_ENCODING_FAILEDThe key alias could not be encoded.iOS
ACCESS_CONTROL_CREATION_FAILEDThe Keychain access control for the key could not be created.iOS
KEY_CREATION_FAILEDThe Secure Enclave or Keychain could not generate the key.iOS
PUBLIC_KEY_EXTRACTION_FAILEDThe public key could not be derived from the new or stored key.iOS
KEY_EXPORT_FAILEDThe public key could not be exported.iOS
KEY_DELETION_FAILEDThe key still exists after deletion.iOS
KEY_REQUIRES_AUTHENTICATIONgetPublicKey(): the Keychain refused a non-interactive lookup of a biometric-gated key; use the publicKey returned by createKeys().iOS
KEYCHAIN_QUERY_FAILEDgetAllKeys(): the Keychain query returned an unexpected result.iOS
EMPTY_KEY_ALIASconfigureKeyAlias() was called with an empty alias.iOS
INVALID_KEY_REFERENCEgetKeyAttributes() (in errorCode): the Keychain returned an invalid key reference.iOS

iOS Keychain status codes​

When a Keychain call fails, iOS maps the status to one of these codes. deleteKeys(), getPublicKey() and getAllKeys() reject with them; signWithOptions(), verifyKeySignature(), sign() and getKeyAttributes() return them in errorCode.

CodeDescriptionPlatform
KEY_NOT_FOUNDNo Keychain item was found (errSecItemNotFound).iOS
AUTHENTICATION_FAILEDThe Keychain reported an authentication failure (errSecAuthFailed).iOS
USER_CANCELThe user canceled a Keychain operation (errSecUserCanceled).iOS
SECURE_ENCLAVE_NOT_AVAILABLEThe Keychain or Secure Enclave is not available (errSecNotAvailable).iOS
INVALID_PARAMETERSThe Keychain rejected the query parameters (errSecParam).iOS
MEMORY_ALLOCATION_FAILEDThe Keychain could not allocate memory (errSecAllocate).iOS
KEY_ALREADY_EXISTSA Keychain item already exists (errSecDuplicateItem).iOS
INVALID_SIGNATURE_FORMATThe Keychain could not decode the data (errSecDecode).iOS
UNKNOWN_ERRORAny other status; the message includes the numeric status.iOS