Types
import type {
AuthenticateOptions,
AuthenticationError,
AuthenticationResult,
AuthenticationType,
BiometricsSecurityLevel,
SecurityLevel,
} from 'nitro-local-auth'
| Type | Kind | Used by |
|---|---|---|
AuthenticateOptions | interface | authenticate |
AuthenticationResult | interface | authenticate |
AuthenticationError | string union | AuthenticationResult.error |
AuthenticationType | string union | getSupportedAuthenticationTypes |
SecurityLevel | string union | getEnrolledLevel |
BiometricsSecurityLevel | string union | AuthenticateOptions |
AuthenticateOptions
Options for authenticate. Every field is optional.
| Field | Type | Description |
|---|---|---|
promptMessage | string | The reason shown in the prompt. Defaults to "Authenticate" on iOS, and to the app name on Android, where the prompt requires a title. |
promptSubtitle | string | A subtitle under the title. Android only. |
promptDescription | string | A description under the subtitle. Android only. |
cancelLabel | string | The label of the cancel button. On Android it applies when the device fallback is disabled, and defaults to "Cancel". |
disableDeviceFallback | boolean | Whether only biometrics may authenticate. When false, the default, the user can fall back to the device passcode, PIN, pattern or password. |
requireConfirmation | boolean | Whether the user must confirm after a passive biometric, such as face unlock, matches. Android only. Defaults to true. |
biometricsSecurityLevel | BiometricsSecurityLevel | The biometric class Android accepts. Defaults to weak. Android only. |
fallbackLabel | string | The 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.
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the user authenticated. |
error | AuthenticationError? | Why it did not succeed. |
warning | string? | 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'
| Value | Meaning |
|---|---|
fingerprint | Touch ID on iOS, a fingerprint sensor on Android. |
facial_recognition | Face ID on iOS, face unlock on Android. |
iris | An iris scanner on Android. |
optic_id | Optic ID on Apple Vision Pro. |
SecurityLevel
The strongest kind of authentication the device has enrolled.
type SecurityLevel = 'none' | 'secret' | 'biometric_weak' | 'biometric_strong'
| Value | Meaning |
|---|---|
none | No passcode, PIN, pattern, password or biometrics. |
secret | A passcode, PIN, pattern or password, but no biometrics. |
biometric_weak | Class 2 biometrics on Android, such as most face unlock implementations. |
biometric_strong | Touch 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'
| Value | Meaning |
|---|---|
weak | Class 2 and Class 3 biometrics. Default. |
strong | Class 3 biometrics only. |