LynxBiometrics
Asks the person to confirm who they are with Face ID, Touch ID or a fingerprint. import { LynxBiometrics, BiometricsError, type BiometricsAvailability, type BiometricsAuthenticateOptions, type BiometricsErrorCode, type BiometryType } from '@blotch/angular-lynx';
To keep a secret, such as a refresh token, readable only after the person confirms, store it with LynxSecureStorage's requireBiometrics. The platform then won't hand it over without a face or a finger, which a check in your own code can't promise.
Turn it on
Add permissions.biometrics to the build target's options in angular.json, with the reason iOS shows the first time the app uses Face ID:
The reason is also the prompt's default text on both platforms.
What it adds:
- iOS:
NSFaceIDUsageDescription. Touch ID needs no reason, but Face ID fails without one. - Android: the
USE_BIOMETRICpermission, granted at install, and the AndroidX Biometric library that shows the prompt.
It also turns on LynxSecureStorage's requireBiometrics.
Without it, ng build --platform leaves the module out of the app, and on Android AndroidX Biometric too. LynxBiometrics then behaves as in the web preview: availability() reports none, and authenticate() rejects with unavailable.
See Turn on device features for every setting.
Usage
API
LynxBiometrics
- iOS:
LAContext. - Android: AndroidX's
BiometricPrompt. - Elsewhere: only the apps
ng build --platformmakes withpermissions.biometricshave it. In Lynx Explorer and the web preview, for example,availability()reportsnoneandauthenticate()rejects withunavailable. - The testing library stands for a phone with Face ID set up.
Android counts only strong (Class 3) biometrics, the ones that can unlock a Keystore key. That way authenticate() and the values kept behind biometrics agree on what confirms the person. A phone whose face unlock is weak reports its fingerprint sensor, or none.
LynxBiometrics.availability()
Never prompts or rejects.
LynxBiometrics.authenticate()
Shows the platform's prompt and resolves once the person is confirmed. Rejects with a BiometricsError, or a TypeError without a reason. One prompt can be open at a time.
