Implement Secure device lock authentication (biometrics) with offline App PIN support

This commit is contained in:
mansi-dev
2026-01-17 23:54:33 +05:30
parent e4f91128ed
commit 6b328f1733
4 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import * as Keychain from 'react-native-keychain';
const PIN_KEY = 'APP_PIN';
export const savePin = async (pin: string) => {
await Keychain.setGenericPassword(PIN_KEY, pin, {
accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED,
});
};
export const verifyPin = async (inputPin: string) => {
const creds = await Keychain.getGenericPassword();
if (!creds) return false;
return creds.password === inputPin;
};
export const isPinSet = async () => {
const creds = await Keychain.getGenericPassword();
return !!creds;
};