Files
AuthenticationSdk/src/screen/authorised/AppPinService.ts

21 lines
549 B
TypeScript

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;
};