Skip to main content

Types

import type {
AuthenticateOptions,
AuthenticationError,
AuthenticationResult,
AuthenticationType,
BiometricsSecurityLevel,
SecurityLevel,
} from 'nitro-local-auth'
TypeKindUsed by
AuthenticateOptionsinterfaceauthenticate
AuthenticationResultinterfaceauthenticate
AuthenticationErrorstring unionAuthenticationResult.error
AuthenticationTypestring uniongetSupportedAuthenticationTypes
SecurityLevelstring uniongetEnrolledLevel
BiometricsSecurityLevelstring unionAuthenticateOptions

AuthenticateOptions​

Options for authenticate. Every field is optional.

FieldTypeDescription
promptMessagestringThe reason shown in the prompt. Defaults to "Authenticate" on iOS, and to the app name on Android, where the prompt requires a title.
promptSubtitlestringA subtitle under the title. Android only.
promptDescriptionstringA description under the subtitle. Android only.
cancelLabelstringThe label of the cancel button. On Android it applies when the device fallback is disabled, and defaults to "Cancel".
disableDeviceFallbackbooleanWhether only biometrics may authenticate. When false, the default, the user can fall back to the device passcode, PIN, pattern or password.
requireConfirmationbooleanWhether the user must confirm after a passive biometric, such as face unlock, matches. Android only. Defaults to true.
biometricsSecurityLevelBiometricsSecurityLevelThe biometric class Android accepts. Defaults to weak. Android only.
fallbackLabelstringThe label of the fallback button that shows after a failed biometric attempt. iOS only. An empty string hides the button. Defaults to the system's "Enter Passcode", or hidden when the device fallback is disabled.

AuthenticationResult​

The outcome of authenticate. error is set exactly when success is false.

FieldTypeDescription
successbooleanWhether the user authenticated.
errorAuthenticationError?Why it did not succeed.
warningstring?The platform's description of a failure, for logging. Do not show it to users.

AuthenticationType​

A biometric method the device supports.

type AuthenticationType = 'fingerprint' | 'facial_recognition' | 'iris' | 'optic_id'
ValueMeaning
fingerprintTouch ID on iOS, a fingerprint sensor on Android.
facial_recognitionFace ID on iOS, face unlock on Android.
irisAn iris scanner on Android.
optic_idOptic ID on Apple Vision Pro.

SecurityLevel​

The strongest kind of authentication the device has enrolled.

type SecurityLevel = 'none' | 'secret' | 'biometric_weak' | 'biometric_strong'
ValueMeaning
noneNo passcode, PIN, pattern, password or biometrics.
secretA passcode, PIN, pattern or password, but no biometrics.
biometric_weakClass 2 biometrics on Android, such as most face unlock implementations.
biometric_strongTouch ID, Face ID or Optic ID on iOS, Class 3 biometrics on Android.

BiometricsSecurityLevel​

The biometric class Android accepts. iOS biometrics are always strong.

type BiometricsSecurityLevel = 'weak' | 'strong'
ValueMeaning
weakClass 2 and Class 3 biometrics. Default.
strongClass 3 biometrics only.