diff --git a/RNSensitiveInfo.js b/RNSensitiveInfo.js index 8a986494..a21aa7ba 100644 --- a/RNSensitiveInfo.js +++ b/RNSensitiveInfo.js @@ -1,3 +1,21 @@ -import { NativeModules } from 'react-native'; +import { NativeModules } from "react-native"; -module.exports = NativeModules.RNSensitiveInfo; +const RNSensitiveInfo = NativeModules.RNSensitiveInfo; + +module.exports = { + ...RNSensitiveInfo, + setInvalidatedByBiometricEnrollment() { + if (RNSensitiveInfo.setInvalidatedByBiometricEnrollment == null) { + return; + } + + return RNSensitiveInfo.setInvalidatedByBiometricEnrollment(); + }, + cancelFingerprintAuth() { + if (RNSensitiveInfo.cancelFingerprintAuth == null) { + return; + } + + return RNSensitiveInfo.cancelFingerprintAuth(); + } +}; diff --git a/index.d.ts b/index.d.ts index 1bfa2b21..5925bcd9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,43 +1,65 @@ -export enum RNSensitiveInfoBiometryType { - "Touch ID", - "Face ID", -} +type RNSensitiveInfoBiometryType = "Touch ID" | "Face ID"; -export enum RNSensitiveInfoAccessControlOptions { - 'kSecAccessControlApplicationPassword', - 'kSecAccessControlPrivateKeyUsage', - 'kSecAccessControlDevicePasscode', - 'kSecAccessControlTouchIDAny', - 'kSecAccessControlTouchIDCurrentSet', - 'kSecAccessControlUserPresence', - 'kSecAccessControlBiometryAny', - 'kSecAccessControlBiometryCurrentSet', -} +type RNSensitiveInfoAccessControlOptions = + | "kSecAccessControlApplicationPassword" + | "kSecAccessControlPrivateKeyUsage" + | "kSecAccessControlDevicePasscode" + | "kSecAccessControlTouchIDAny" + | "kSecAccessControlTouchIDCurrentSet" + | "kSecAccessControlUserPresence" + | "kSecAccessControlBiometryAny" + | "kSecAccessControlBiometryCurrentSet"; + +type RNSensitiveInfoAttrAccessibleOptions = + | "kSecAttrAccessibleAfterFirstUnlock" + | "kSecAttrAccessibleAlways" + | "kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly" + | "kSecAttrAccessibleWhenUnlockedThisDeviceOnly" + | "kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly" + | "kSecAttrAccessibleAlwaysThisDeviceOnly" + | "kSecAttrAccessibleWhenUnlocked"; -export enum RNSensitiveInfoAttrAccessibleOptions { - 'kSecAttrAccessibleAfterFirstUnlock', - 'kSecAttrAccessibleAlways', - 'kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly', - 'kSecAttrAccessibleWhenUnlockedThisDeviceOnly', - 'kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly', - 'kSecAttrAccessibleAlwaysThisDeviceOnly', - 'kSecAttrAccessibleWhenUnlocked', +interface RNSensitiveInfoAndroidDialogStrings { + header?: string; + description?: string; + hint?: string; + success?: string; + notRecognized?: string; + cancel?: string; + cancelled?: string; } export interface RNSensitiveInfoOptions { kSecAccessControl?: RNSensitiveInfoAccessControlOptions; kSecAttrAccessible?: RNSensitiveInfoAttrAccessibleOptions; keychainService?: string; - kSecUseOperationPrompt?: string; sharedPreferencesName?: string; touchID?: boolean; + showModal?: boolean; + kSecUseOperationPrompt?: string; + strings?: RNSensitiveInfoAndroidDialogStrings; } -export declare function setItem(key: string, value: string, options: RNSensitiveInfoOptions): Promise; -export declare function getItem(key: string, options: RNSensitiveInfoOptions): Promise; -export declare function getAllItems(options: RNSensitiveInfoOptions): Promise; -export declare function deleteItem(key: string, options: RNSensitiveInfoOptions): Promise; -export declare function isSensorAvailable(): Promise; +export declare function setItem( + key: string, + value: string, + options: RNSensitiveInfoOptions +): Promise; +export declare function getItem( + key: string, + options: RNSensitiveInfoOptions +): Promise; +export declare function getAllItems( + options: RNSensitiveInfoOptions +): Promise; +export declare function deleteItem( + key: string, + options: RNSensitiveInfoOptions +): Promise; +export declare function isSensorAvailable(): Promise< + RNSensitiveInfoBiometryType | boolean +>; export declare function isHardwareDetected(): Promise; export declare function hasEnrolledFingerprints(): Promise; export declare function cancelFingerprintAuth(): void; +export declare function setInvalidatedByBiometricEnrollment(boolean): void;