import RNSecureKeyStore , { ACCESSIBLE } from "react-native-secure-key-store" ; export default class KeyStoreWrapper { private static readonly IS_BIOMETRICS_ENABLED = "isBiometricsEnabled" ; private static readonly PIN = "PIN" ; private static readonly PIN_ATTEMPTS = "pinAttempts" ; public static async getIsBiometricsEnabled ( ) { try { await RNSecureKeyStore . get ( KeyStoreWrapper . IS_BIOMETRICS_ENABLED ) ; return true ; } catch { return false ; } } public static async setIsBiometricsEnabled ( ) { try { await RNSecureKeyStore . set ( KeyStoreWrapper . IS_BIOMETRICS_ENABLED , "1" , { accessible : ACCESSIBLE . ALWAYS_THIS_DEVICE_ONLY , } ) ; return true ; } catch { return false ; } } public static async removeIsBiometricsEnabled ( ) { try { await RNSecureKeyStore . remove ( KeyStoreWrapper . IS_BIOMETRICS_ENABLED ) ; return true ; } catch { return false ; } } public static async getIsPinEnabled ( ) { try { await RNSecureKeyStore . get ( KeyStoreWrapper . PIN ) ; return true ; } catch { return false ; } } public static async getPinOrEmptyString ( ) { try { return await RNSecureKeyStore . get ( KeyStoreWrapper . PIN ) ; } catch { return "" ; } } public static async setPin ( pin ) { try { await RNSecureKeyStore . set ( KeyStoreWrapper . PIN , pin , { accessible : ACCESSIBLE . ALWAYS_THIS_DEVICE_ONLY , } ) ; return true ; } catch { return false ; } } public static async removePin ( ) { try { await RNSecureKeyStore . remove ( KeyStoreWrapper . PIN ) ; return true ; } catch { return false ; } } public static async getPinAttemptsOrZero ( ) { try { return Number ( await RNSecureKeyStore . get ( KeyStoreWrapper . PIN_ATTEMPTS ) ) ; } catch { return 0 ; } } public static async setPinAttempts ( pinAttempts ) { try { await RNSecureKeyStore . set ( KeyStoreWrapper . PIN_ATTEMPTS , pinAttempts , { accessible : ACCESSIBLE . ALWAYS_THIS_DEVICE_ONLY , } ) ; return true ; } catch { return false ; } } public static async resetPinAttempts ( ) { return await KeyStoreWrapper . setPinAttempts ( "0" ) ; } public static async removePinAttempts ( ) { try { await RNSecureKeyStore . remove ( KeyStoreWrapper . PIN_ATTEMPTS ) ; return true ; } catch { return false ; } } }