-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from savelichalex/types
Change TS types to use string literals instead enums, and added missing methods
- Loading branch information
Showing
2 changed files
with
70 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<null>; | ||
export declare function getItem(key: string, options: RNSensitiveInfoOptions): Promise<string>; | ||
export declare function getAllItems(options: RNSensitiveInfoOptions): Promise<Object>; | ||
export declare function deleteItem(key: string, options: RNSensitiveInfoOptions): Promise<null>; | ||
export declare function isSensorAvailable(): Promise<RNSensitiveInfoBiometryType | boolean>; | ||
export declare function setItem( | ||
key: string, | ||
value: string, | ||
options: RNSensitiveInfoOptions | ||
): Promise<null>; | ||
export declare function getItem( | ||
key: string, | ||
options: RNSensitiveInfoOptions | ||
): Promise<string>; | ||
export declare function getAllItems( | ||
options: RNSensitiveInfoOptions | ||
): Promise<Object>; | ||
export declare function deleteItem( | ||
key: string, | ||
options: RNSensitiveInfoOptions | ||
): Promise<null>; | ||
export declare function isSensorAvailable(): Promise< | ||
RNSensitiveInfoBiometryType | boolean | ||
>; | ||
export declare function isHardwareDetected(): Promise<boolean>; | ||
export declare function hasEnrolledFingerprints(): Promise<boolean>; | ||
export declare function cancelFingerprintAuth(): void; | ||
export declare function setInvalidatedByBiometricEnrollment(boolean): void; |