fix(#75): add biometric authentication#521
Merged
Merged
Conversation
- src/services/auth/biometricService.ts:
- Lazy-loads expo-local-authentication so app never crashes if the
native module is not yet linked
- isAvailable(): checks hardware + enrollment
- getSupportedTypes(): fingerprint / facial / iris
- authenticate(): wraps authenticateAsync with PIN fallback option
- authenticateIfEnabled(): reads settings and skips prompt when
biometrics are disabled
- getSettings() / saveSettings(): persists { enabled, fallbackToPIN }
to AsyncStorage
- src/hooks/useBiometricAuth.ts:
- Loads availability, supported types, and settings on mount
- authenticate() triggers prompt and tracks loading/error/cancelled
- saveSettings() persists user preference changes
- src/components/BiometricGate.tsx:
- Lock screen shown on launch when biometrics are enabled
- Auto-prompts on mount and on foreground (AppState listener)
- Shows biometric icon (Face ID / fingerprint / iris / lock)
- Error card with retry button on failure
- Passes through immediately when biometrics disabled or unavailable
Requires: npx expo install expo-local-authentication
- Wrap AppNavigator with BiometricGate inside ErrorBoundary - Import BiometricGate from src/components/BiometricGate - Gate renders lock screen on launch when biometrics are enabled; passes through immediately when disabled or unavailable
|
@rindicomfort Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #75
Adds Face ID / Touch ID / fingerprint authentication with PIN fallback, an optional setting, and a lock screen that prompts on launch and on foreground.
Files
src/services/auth/biometricService.ts(new)expo-local-authentication— app never crashes if module not linkedisAvailable()— checks hardware + enrollmentgetSupportedTypes()— fingerprint / facial / irisauthenticate(reason, fallbackToPIN)— wrapsauthenticateAsyncwith PIN fallbackauthenticateIfEnabled()— skips prompt when user has disabled biometricsgetSettings()/saveSettings()— persists{ enabled, fallbackToPIN }to AsyncStoragesrc/hooks/useBiometricAuth.ts(new)authenticate()tracks loading / error / cancelled statesaveSettings()persists preference changessrc/components/BiometricGate.tsx(new)AppStatelistener — re-locks on background)App.tsxAppNavigatorwithBiometricGateinsideErrorBoundarySetup
Acceptance Criteria
biometricService.saveSettings({ enabled }))