Implement Secure device lock authentication (biometrics) with offline App PIN support
This commit is contained in:
20
src/screen/authorised/AppPinService.ts
Normal file
20
src/screen/authorised/AppPinService.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user