Prompt the user for biometric authentication on Android and iOS.
Prompt the user for biometric authentication on Android and iOS. Also allows to use assymetric cryptography with the keys protected by biometric authentication.
| Platform | Supported |
| -------- | --------- |
@ -8,7 +8,7 @@ Prompt the user for biometric authentication on Android and iOS.
| Windows | x |
| macOS | x |
| Android | ✓ |
| iOS | ✓ |
| iOS | ✓ (except biometric cryptography ) |
## Install
@ -70,8 +70,27 @@ fn main() {
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { authenticate } from '@tauri-apps/plugin-biometric'
await authenticate('Open your wallet')
import { checkStatus, authenticate, biometricCipher } from '@tauri-apps/plugin-biometric'
const status = await checkStatus();
if (status.isAvailble) {
await authenticate('Open your wallet')
}
// ... or using biometric-protected cryptography:
if (status.isAvailable) {
const encryptOptions = {
dataToEncrypt: getData(),
};
const encrypted = await biometricCipher('Login without typing password', encryptOptions);
const decryptOptions = {
dataToDecrypt: encrypted.data,
};
const originalData = await biometricCipher('Login without typing password', decryptOptions);
/** Enables authentication using the device's password. This feature is available on both Android and iOS. */
allowDeviceCredential?: boolean
/** Label for the Cancel button. This feature is available on both Android and iOS. */
cancelTitle?: string
/** The plain data that must be encrypted after successfull biometric authentication */
dataToEncrypt?: string
/** The encrypted data that must be decrypted after successfull biometric authentication */
dataToDecrypt?: string
// iOS options
/** Specifies the text displayed on the fallback button if biometric authentication fails. This feature is available iOS only. */
fallbackTitle?: string
// android options
/** Title indicating the purpose of biometric verification. This feature is available Android only. */
title?: string
/** SubTitle providing contextual information of biometric verification. This feature is available Android only. */
subtitle?: string
/** Specifies whether additional user confirmation is required, such as pressing a button after successful biometric authentication. This feature is available Android only. */
confirmationRequired?: boolean
maxAttemps?: number
}
@ -75,3 +86,43 @@ export async function authenticate(
/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the biometric APIs.