@tauri-apps/plugin-biometric
此内容尚不支持你的语言。
Prompt the user for biometric authentication on Android, iOS and macOS.
Enumerations
Section titled “Enumerations”BiometryType
Section titled “BiometryType”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L16
The kind of biometry hardware detected on the device.
Enumeration Members
Section titled “Enumeration Members”FaceID
Section titled “FaceID”FaceID: 2;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L22
Apple FaceID or Android face authentication.
Iris: 3;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L24
Android iris authentication.
None: 0;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L18
No biometry hardware is available, or it is not enrolled with the operating system.
TouchID
Section titled “TouchID”TouchID: 1;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L20
Apple TouchID or Android fingerprint.
Interfaces
Section titled “Interfaces”AuthOptions
Section titled “AuthOptions”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L56
Options for the authenticate biometric prompt.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
allowDeviceCredential? |
boolean |
Enables authentication using the device’s password or PIN. Available on Android, iOS and macOS. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L58 |
cancelTitle? |
string |
Label for the cancel button. Available on Android, iOS and macOS. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L60 |
confirmationRequired? |
boolean |
Whether additional user confirmation is required, such as pressing a button, after successful biometric authentication. Android only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L76 |
dataToDecrypt? |
string |
The encrypted data that must be decrypted after successful biometric authentication. Used by biometricCipher. Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L64 |
dataToEncrypt? |
string |
The plain data that must be encrypted after successful biometric authentication. Used by biometricCipher. Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L62 |
fallbackTitle? |
string |
Text displayed on the fallback button if biometric authentication fails. iOS and macOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L68 |
maxAttemps? |
number |
Maximum number of attempts allowed before the prompt is dismissed. Defaults to 3. Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L78 |
subtitle? |
string |
Subtitle providing contextual information of the biometric verification. Android only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L74 |
title? |
string |
Title indicating the purpose of the biometric verification. Android only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L72 |
Status
Section titled “Status”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L31
The result of checkStatus, describing whether biometric authentication can
currently be used.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
biometryType |
BiometryType |
The kind of biometry hardware detected on the device, even when isAvailable is false. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L35 |
error? |
string |
A human-readable reason why biometric authentication is unavailable. Only set when isAvailable is false. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L37 |
errorCode? |
| "appCancel" | "authenticationFailed" | "invalidContext" | "notInteractive" | "passcodeNotSet" | "systemCancel" | "userCancel" | "userFallback" | "biometryLockout" | "biometryNotAvailable" | "biometryNotEnrolled" |
A platform-specific error code describing why biometric authentication is unavailable. Only set when isAvailable is false. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L39 |
isAvailable |
boolean |
Whether the device can currently authenticate using biometrics. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L33 |
Functions
Section titled “Functions”authenticate()
Section titled “authenticate()”function authenticate(reason, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L113
Prompts the user for authentication using the system interface (touchID, faceID or Android Iris).
Rejects if the authentication fails, with an error object containing a message and, when the platform provides one, a code (e.g. userCancel).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
reason |
string |
A message shown to the user explaining why authentication is requested. |
options? |
AuthOptions |
Configuration for the biometric prompt. |
Returns
Section titled “Returns”Promise<void>
a promise resolving to void once the user is successfully authenticated.
Example
Section titled “Example”import { authenticate } from "@tauri-apps/plugin-biometric";await authenticate('Open your wallet');2.0.0
biometricCipher()
Section titled “biometricCipher()”function biometricCipher(reason, options?): Promise<{ data: string;}>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L151
Encrypts/Decrypts some payload using biometric authentication. It will Prompt the user to authenticate using the system interface (touchID, faceID or Android Iris). Rejects if the authentication fails.
Warning: consider that if the data is encrypted and the user changes the biometric settings, the key needed to decrypt the data will be lost. So, it’s recommended to use this only to data that the user can get back by other means (i.e. storing their password in a secure way so they can login passwordless with biometric authentication).
import { biometricCipher } from "@tauri-apps/plugin-biometric";
// how to encrypt some dataconst options = { dataToEncrypt: "...", // if not empty, will encrypt this data};const encryptedData = await biometricCipher('Open your wallet', options);
// how to decrypt the encrypted dataconst options = { dataToDecrypt: encryptedData // if not empty, will decrypt the data (that was previously encrypted by this method)};const decryptedData = await biometricCipher('Open your wallet', options);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
reason |
string |
- |
options? |
AuthOptions |
- |
Returns
Section titled “Returns”Promise<{
data: string;
}>
checkStatus()
Section titled “checkStatus()”function checkStatus(): Promise<Status>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/biometric/guest-js/index.ts#L95
Checks if the biometric authentication is available.
Returns
Section titled “Returns”a promise resolving to an object containing all the information about the status of the biometry.
Example
Section titled “Example”import { checkStatus } from '@tauri-apps/plugin-biometric';
const status = await checkStatus();if (status.isAvailable) { // do something}2.0.0
© 2026 Tauri Contributors. CC-BY / MIT