UNPKG

@capgo/capacitor-native-biometric

Version:

This plugin gives access to the native biometric apis for android and iOS

887 lines 25.6 kB
{ "api": { "name": "NativeBiometricPlugin", "slug": "nativebiometricplugin", "docs": "", "tags": [], "methods": [ { "name": "isAvailable", "signature": "(options?: IsAvailableOptions | undefined) => Promise<AvailableResult>", "parameters": [ { "name": "options", "docs": "", "type": "IsAvailableOptions | undefined" } ], "returns": "Promise<AvailableResult>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "1.0.0" } ], "docs": "Checks if biometric authentication hardware is available.", "complexTypes": [ "AvailableResult", "IsAvailableOptions" ], "slug": "isavailable" }, { "name": "addListener", "signature": "(eventName: 'biometryChange', listener: BiometryChangeListener) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "- Must be 'biometryChange'", "type": "'biometryChange'" }, { "name": "listener", "docs": "- Callback function that receives the updated AvailableResult", "type": "BiometryChangeListener" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "param", "text": "eventName - Must be 'biometryChange'" }, { "name": "param", "text": "listener - Callback function that receives the updated AvailableResult" }, { "name": "returns", "text": "Handle to remove the listener" }, { "name": "since", "text": "7.6.0" }, { "name": "example", "text": "```typescript\nconst handle = await NativeBiometric.addListener('biometryChange', (result) => {\n console.log('Biometry availability changed:', result.isAvailable);\n});\n\n// To remove the listener:\nawait handle.remove();\n```" } ], "docs": "Adds a listener that is called when the app resumes from background.\nThis is useful to detect if biometry availability has changed while\nthe app was in the background (e.g., user enrolled/unenrolled biometrics).", "complexTypes": [ "PluginListenerHandle", "BiometryChangeListener" ], "slug": "addlistenerbiometrychange-" }, { "name": "verifyIdentity", "signature": "(options?: BiometricOptions | undefined) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "BiometricOptions | undefined" } ], "returns": "Promise<void>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "1.0.0" } ], "docs": "Prompts the user to authenticate with biometrics.", "complexTypes": [ "BiometricOptions" ], "slug": "verifyidentity" }, { "name": "getCredentials", "signature": "(options: GetCredentialOptions) => Promise<Credentials>", "parameters": [ { "name": "options", "docs": "", "type": "GetCredentialOptions" } ], "returns": "Promise<Credentials>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "1.0.0" } ], "docs": "Gets the stored credentials for a given server.", "complexTypes": [ "Credentials", "GetCredentialOptions" ], "slug": "getcredentials" }, { "name": "setCredentials", "signature": "(options: SetCredentialOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "SetCredentialOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "1.0.0" } ], "docs": "Stores the given credentials for a given server.", "complexTypes": [ "SetCredentialOptions" ], "slug": "setcredentials" }, { "name": "deleteCredentials", "signature": "(options: DeleteCredentialOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "DeleteCredentialOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "1.0.0" } ], "docs": "Deletes the stored credentials for a given server.", "complexTypes": [ "DeleteCredentialOptions" ], "slug": "deletecredentials" }, { "name": "getSecureCredentials", "signature": "(options: GetSecureCredentialsOptions) => Promise<Credentials>", "parameters": [ { "name": "options", "docs": "", "type": "GetSecureCredentialsOptions" } ], "returns": "Promise<Credentials>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "8.4.0" } ], "docs": "Gets the stored credentials for a given server, requiring biometric authentication.\nCredentials must have been stored with accessControl set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY.\n\nOn iOS, the system automatically shows the biometric prompt when accessing the protected Keychain item.\nOn Android, BiometricPrompt is shown with a CryptoObject bound to the credential decryption key.", "complexTypes": [ "Credentials", "GetSecureCredentialsOptions" ], "slug": "getsecurecredentials" }, { "name": "isCredentialsSaved", "signature": "(options: IsCredentialsSavedOptions) => Promise<IsCredentialsSavedResult>", "parameters": [ { "name": "options", "docs": "", "type": "IsCredentialsSavedOptions" } ], "returns": "Promise<IsCredentialsSavedResult>", "tags": [ { "name": "param", "text": "options" }, { "name": "returns" }, { "name": "memberof", "text": "NativeBiometricPlugin" }, { "name": "since", "text": "7.3.0" } ], "docs": "Checks if credentials are already saved for a given server.", "complexTypes": [ "IsCredentialsSavedResult", "IsCredentialsSavedOptions" ], "slug": "iscredentialssaved" }, { "name": "getPluginVersion", "signature": "() => Promise<{ version: string; }>", "parameters": [], "returns": "Promise<{ version: string; }>", "tags": [ { "name": "returns", "text": "Promise that resolves with the plugin version" }, { "name": "since", "text": "1.0.0" } ], "docs": "Get the native Capacitor plugin version.", "complexTypes": [], "slug": "getpluginversion" } ], "properties": [] }, "interfaces": [ { "name": "AvailableResult", "slug": "availableresult", "docs": "Result from isAvailable() method indicating biometric authentication availability.", "tags": [], "methods": [], "properties": [ { "name": "isAvailable", "tags": [], "docs": "Whether authentication is available (biometric or fallback if useFallback is true)", "complexTypes": [], "type": "boolean" }, { "name": "authenticationStrength", "tags": [], "docs": "The strength of available authentication method (STRONG, WEAK, or NONE)", "complexTypes": [ "AuthenticationStrength" ], "type": "AuthenticationStrength" }, { "name": "biometryType", "tags": [], "docs": "The primary biometry type available on the device.\nOn Android devices with multiple biometry types, this returns MULTIPLE.\nUse this for display purposes only - always use isAvailable for logic decisions.", "complexTypes": [ "BiometryType" ], "type": "BiometryType" }, { "name": "deviceIsSecure", "tags": [], "docs": "Whether the device has a secure lock screen (PIN, pattern, or password).\nThis is independent of biometric enrollment.", "complexTypes": [], "type": "boolean" }, { "name": "strongBiometryIsAvailable", "tags": [], "docs": "Whether strong biometry (Face ID, Touch ID, or fingerprint on devices that consider it strong)\nis specifically available, separate from weak biometry or device credentials.", "complexTypes": [], "type": "boolean" }, { "name": "errorCode", "tags": [ { "text": "BiometricAuthError", "name": "see" } ], "docs": "Error code from BiometricAuthError enum. Only present when isAvailable is false.\nIndicates why biometric authentication is not available.", "complexTypes": [ "BiometricAuthError" ], "type": "BiometricAuthError" } ] }, { "name": "IsAvailableOptions", "slug": "isavailableoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "useFallback", "tags": [], "docs": "Only for iOS.\nSpecifies if should fallback to passcode authentication if biometric authentication is not available.\nOn Android, this parameter is ignored due to BiometricPrompt API constraints:\nDEVICE_CREDENTIAL authenticator and negative button (cancel) are mutually exclusive.", "complexTypes": [], "type": "boolean" } ] }, { "name": "PluginListenerHandle", "slug": "pluginlistenerhandle", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "remove", "tags": [], "docs": "", "complexTypes": [], "type": "() => Promise<void>" } ] }, { "name": "BiometricOptions", "slug": "biometricoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "reason", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "title", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "subtitle", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "description", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "negativeButtonText", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "useFallback", "tags": [], "docs": "Only for iOS.\nSpecifies if should fallback to passcode authentication if biometric authentication fails.\nOn Android, this parameter is ignored due to BiometricPrompt API constraints:\nDEVICE_CREDENTIAL authenticator and negative button (cancel) are mutually exclusive.", "complexTypes": [], "type": "boolean | undefined" }, { "name": "fallbackTitle", "tags": [], "docs": "Only for iOS.\nSet the text for the fallback button in the authentication dialog.\nIf this property is not specified, the default text is set by the system.", "complexTypes": [], "type": "string | undefined" }, { "name": "maxAttempts", "tags": [ { "text": "1", "name": "default" } ], "docs": "Only for Android.\nSet a maximum number of attempts for biometric authentication. The maximum allowed by android is 5.", "complexTypes": [], "type": "number | undefined" }, { "name": "allowedBiometryTypes", "tags": [ { "text": "[BiometryType.FINGERPRINT, BiometryType.FACE_AUTHENTICATION]", "name": "example" } ], "docs": "Only for Android.\nSpecify which biometry types are allowed for authentication.\nIf not specified, all available types will be allowed.", "complexTypes": [ "BiometryType" ], "type": "BiometryType[] | undefined" } ] }, { "name": "Credentials", "slug": "credentials", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "username", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "password", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] }, { "name": "GetCredentialOptions", "slug": "getcredentialoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "server", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] }, { "name": "SetCredentialOptions", "slug": "setcredentialoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "username", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "password", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "server", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "accessControl", "tags": [ { "text": "AccessControl.NONE", "name": "default" }, { "text": "8.4.0", "name": "since" } ], "docs": "Access control level for the stored credentials.\nWhen set to BIOMETRY_CURRENT_SET or BIOMETRY_ANY, the credentials are\nhardware-protected and require biometric authentication to access.\n\nOn iOS, this adds SecAccessControl to the Keychain item.\nOn Android, this creates a biometric-protected Keystore key and requires\nBiometricPrompt authentication for both storing and retrieving credentials.", "complexTypes": [ "AccessControl" ], "type": "AccessControl" } ] }, { "name": "DeleteCredentialOptions", "slug": "deletecredentialoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "server", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] }, { "name": "GetSecureCredentialsOptions", "slug": "getsecurecredentialsoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "server", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "reason", "tags": [], "docs": "Reason for requesting biometric authentication.\nDisplayed in the biometric prompt on both iOS and Android.", "complexTypes": [], "type": "string | undefined" }, { "name": "title", "tags": [], "docs": "Title for the biometric prompt.\nOnly for Android.", "complexTypes": [], "type": "string | undefined" }, { "name": "subtitle", "tags": [], "docs": "Subtitle for the biometric prompt.\nOnly for Android.", "complexTypes": [], "type": "string | undefined" }, { "name": "description", "tags": [], "docs": "Description for the biometric prompt.\nOnly for Android.", "complexTypes": [], "type": "string | undefined" }, { "name": "negativeButtonText", "tags": [], "docs": "Text for the negative/cancel button.\nOnly for Android.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "IsCredentialsSavedResult", "slug": "iscredentialssavedresult", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "isSaved", "tags": [], "docs": "", "complexTypes": [], "type": "boolean" } ] }, { "name": "IsCredentialsSavedOptions", "slug": "iscredentialssavedoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "server", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] } ], "enums": [ { "name": "AuthenticationStrength", "slug": "authenticationstrength", "members": [ { "name": "NONE", "value": "0", "tags": [], "docs": "No authentication available, even if PIN is available but useFallback = false" }, { "name": "STRONG", "value": "1", "tags": [], "docs": "Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\nNote: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true." }, { "name": "WEAK", "value": "2", "tags": [], "docs": "Weak authentication: Face authentication on Android devices that consider face weak,\nor PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG)." } ] }, { "name": "BiometryType", "slug": "biometrytype", "members": [ { "name": "NONE", "value": "0", "tags": [], "docs": "" }, { "name": "TOUCH_ID", "value": "1", "tags": [], "docs": "" }, { "name": "FACE_ID", "value": "2", "tags": [], "docs": "" }, { "name": "FINGERPRINT", "value": "3", "tags": [], "docs": "" }, { "name": "FACE_AUTHENTICATION", "value": "4", "tags": [], "docs": "" }, { "name": "IRIS_AUTHENTICATION", "value": "5", "tags": [], "docs": "" }, { "name": "MULTIPLE", "value": "6", "tags": [], "docs": "" }, { "name": "DEVICE_CREDENTIAL", "value": "7", "tags": [], "docs": "" } ] }, { "name": "BiometricAuthError", "slug": "biometricautherror", "members": [ { "name": "UNKNOWN_ERROR", "value": "0", "tags": [], "docs": "Unknown error occurred" }, { "name": "BIOMETRICS_UNAVAILABLE", "value": "1", "tags": [], "docs": "Biometrics are unavailable (no hardware or hardware error)\nPlatform: Android, iOS" }, { "name": "USER_LOCKOUT", "value": "2", "tags": [], "docs": "User has been locked out due to too many failed attempts\nPlatform: Android, iOS" }, { "name": "BIOMETRICS_NOT_ENROLLED", "value": "3", "tags": [], "docs": "No biometrics are enrolled on the device\nPlatform: Android, iOS" }, { "name": "USER_TEMPORARY_LOCKOUT", "value": "4", "tags": [], "docs": "User is temporarily locked out (Android: 30 second lockout)\nPlatform: Android" }, { "name": "AUTHENTICATION_FAILED", "value": "10", "tags": [], "docs": "Authentication failed (user did not authenticate successfully)\nPlatform: Android, iOS" }, { "name": "APP_CANCEL", "value": "11", "tags": [], "docs": "App canceled the authentication (iOS only)\nPlatform: iOS" }, { "name": "INVALID_CONTEXT", "value": "12", "tags": [], "docs": "Invalid context (iOS only)\nPlatform: iOS" }, { "name": "NOT_INTERACTIVE", "value": "13", "tags": [], "docs": "Authentication was not interactive (iOS only)\nPlatform: iOS" }, { "name": "PASSCODE_NOT_SET", "value": "14", "tags": [], "docs": "Passcode/PIN is not set on the device\nPlatform: Android, iOS" }, { "name": "SYSTEM_CANCEL", "value": "15", "tags": [], "docs": "System canceled the authentication (e.g., due to screen lock)\nPlatform: Android, iOS" }, { "name": "USER_CANCEL", "value": "16", "tags": [], "docs": "User canceled the authentication\nPlatform: Android, iOS" }, { "name": "USER_FALLBACK", "value": "17", "tags": [], "docs": "User chose to use fallback authentication method\nPlatform: Android, iOS" } ] }, { "name": "AccessControl", "slug": "accesscontrol", "members": [ { "name": "NONE", "value": "0", "tags": [], "docs": "No biometric protection. Credentials are accessible without authentication.\nThis is the default behavior for backward compatibility." }, { "name": "BIOMETRY_CURRENT_SET", "value": "1", "tags": [], "docs": "Biometric authentication required for credential access.\nCredentials are invalidated if biometrics change (e.g., new fingerprint enrolled).\nMore secure but credentials are lost if user modifies their biometric enrollment." }, { "name": "BIOMETRY_ANY", "value": "2", "tags": [], "docs": "Biometric authentication required for credential access.\nCredentials survive new biometric enrollment (e.g., adding a new fingerprint).\nMore lenient — recommended for most apps." } ] } ], "typeAliases": [ { "name": "BiometryChangeListener", "slug": "biometrychangelistener", "docs": "Callback type for biometry change listener", "types": [ { "text": "(result: AvailableResult): void", "complexTypes": [ "AvailableResult" ] } ] } ], "pluginConfigs": [] }