-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.d.ts
100 lines (92 loc) · 3.76 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export interface ISecureElement {
decrypt(key: string, value: string, opts: AndroidKeyGenOptions | IOSKeyGenOptions): Promise<string | null>;
encrypt(key: string, value: string, opts: AndroidKeyGenOptions | IOSKeyGenOptions): Promise<string | null>;
clearElement(key: string, keyProvider: AndroidKeyGenProvider): Promise<void>;
clearAll(keyProvider: AndroidKeyGenProvider): Promise<void>;
isSecureDevice(): Promise<boolean>;
getDeviceFeatures(): Promise<DeviceFeature[]>;
performAuthentication(withFeature: DeviceFeature): Promise<boolean>;
}
export interface ISecureElementNativeModule {
decrypt(
key: string,
value: string,
opts: AndroidKeyGenOptions,
callback: (errors: Error, result: string) => void
): void;
encrypt(
key: string,
value: string,
opts: AndroidKeyGenOptions,
callback: (errors: Error, result: string) => void
): void;
clearElement(key: string, keyProvider: AndroidKeyGenProvider, callback: (errors: Error) => void): void;
clearAll(keyProvider: AndroidKeyGenProvider, callback: (errors: Error) => void): void;
isSecureDevice(callback: (errors: Error, isSecureDevice: boolean) => void): void;
getDeviceFeatures(callback: (errors: Error, deviceFeatures: [DeviceFeature]) => void): void;
performAuthentication(
withFeature: DeviceFeature,
callback: (errors: Error, success: boolean) => void
): void;
}
export type DeviceFeature =
| 'IOS_PASSCODELOCK'
| 'IOS_TOUCHID'
| 'IOS_FACEID'
| 'IOS_BIOMETRICS'
| 'ANDROID_FINGERPRINT'
| 'ANDROID_DEVICE_SECURE';
export type AndroidKeyGenAlgorithm = 'RSA'; //TODO: [mr] see docs
export type AndroidKeyGenProvider = 'AndroidKeyStore' | ''; //TODO: [mr] see docs
export type AndroidKeyGenPurpose = 'ENCRYPT' | 'DECRYPT' | 'SIGN' | 'VERIFY';
export type AndroidKeyGenBlockMode = 'ECB' | 'CBC' | 'CTR' | 'GCM';
export type AndroidKeyGenEncryptionPadding =
| 'NoPadding'
| 'PKCS7Padding'
| 'PKCS1Padding'
| 'OAEPPadding';
export type IOSSecAccessControlCreateFlags =
| 'kSecAccessControlUserPresence'
| 'kSecAccessControlBiometryAny'
| 'kSecAccessControlTouchIDAny'
| 'kSecAccessControlBiometryCurrentSet'
| 'kSecAccessControlTouchIDCurrentSet'
| 'kSecAccessControlDevicePasscode'
| 'kSecAccessControlOr'
| 'kSecAccessControlAnd'
| 'kSecAccessControlPrivateKeyUsage'
| 'kSecAccessControlApplicationPassword';
export type IOSSecAttrAccessible =
| 'kSecAttrAccessibleWhenUnlocked'
| 'kSecAttrAccessibleAfterFirstUnlock'
| 'kSecAttrAccessibleAlways'
| 'kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly'
| 'kSecAttrAccessibleWhenUnlockedThisDeviceOnly'
| 'kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly'
| 'kSecAttrAccessibleAlwaysThisDeviceOnly';
export type IOSAlgorithm = 'SHA1' | 'SHA224' | 'SHA384' | 'SHA256' | 'SHA512';
export type IOSSecAttrType = 'EC' | 'ECSECPrimeRandom';
export interface AndroidKeyGenOptions {
keyPairGeneratorAlgorithm: AndroidKeyGenAlgorithm;
keyPairGeneratorProvider: AndroidKeyGenProvider;
keyGenBlockMode: AndroidKeyGenBlockMode;
keyGenEncryptionPadding: AndroidKeyGenEncryptionPadding;
keyGenUserAuthenticationRequired: boolean;
keyGenInvalidatedByBiometricEnrollment: boolean;
userAuthenticationValidityDurationSeconds: number;
purposes: AndroidKeyGenPurpose[];
}
export interface IOSKeyGenOptions {
userPrompt: string;
privateSACFlags: IOSSecAccessControlCreateFlags[] | [];
publicSACFlags: IOSSecAccessControlCreateFlags[] | [];
privateSACAccessible: IOSSecAttrAccessible;
publicSACAccessible: IOSSecAttrAccessible;
secAttrType: IOSSecAttrType;
saveInSecureEnclaveIfPossible: boolean;
algorithm: IOSAlgorithm; // defaults to "SHA256"
privateKeySizeInBits: number;
publicKeyName: string;
privateKeyName: string;
touchIDAuthenticationAllowableReuseDuration?: number; // defaults to "300"
}