forked from naoufal/react-native-touch-id
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
120 lines (114 loc) · 3.18 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
declare module 'react-native-touch-id' {
/**
* The supported biometry type
*/
type BiometryType = 'FaceID' | 'TouchID' | 'Fingerprint';
/**
* Base config to pass to `TouchID.isSupported` and `TouchID.authenticate`
*/
interface IsSupportedConfig {
/**
* Return unified error messages
*/
unifiedErrors?: boolean;
}
/**
* Authentication config
*/
export interface AuthenticateConfig extends IsSupportedConfig {
/**
* **Android only** - Title of confirmation dialog
*/
title?: string;
/**
* **Android only** - Color of fingerprint image
*/
imageColor?: string;
/**
* **Android only** - Color of fingerprint image after failed attempt
*/
imageErrorColor?: string;
/**
* **Android only** - Text shown next to the fingerprint image
*/
sensorDescription?: string;
/**
* **Android only** - Text shown next to the fingerprint image after failed attempt
*/
sensorErrorDescription?: string;
/**
* **Android only** - Cancel button text
*/
cancelText?: string;
/**
* **Android only** - Cancel button text color
*/
cancelTextColor?: string;
/**
* **Android only** - Cancel button color
*/
cancelButtonColor?: string;
/**
* **iOS only** - By default specified 'Show Password' label. If set to empty string label is invisible.
*/
fallbackLabel?: string;
/**
* **iOS only** - By default set to false. If set to true, will allow use of keypad passcode.
*/
passcodeFallback?: boolean;
}
/**
* `isSupported` error code
*/
type IsSupportedErrorCode =
| 'NOT_SUPPORTED'
| 'NOT_AVAILABLE'
| 'NOT_PRESENT'
| 'NOT_ENROLLED';
/**
* `authenticate` error code
*/
type AuthenticateErrorCode =
| IsSupportedErrorCode
| 'AUTHENTICATION_FAILED'
| 'USER_CANCELED'
| 'SYSTEM_CANCELED'
| 'TIMEOUT'
| 'LOCKOUT'
| 'LOCKOUT_PERMANENT'
| 'PROCESSING_ERROR'
| 'USER_FALLBACK'
| 'UNKNOWN_ERROR';
/**
* Error returned from `authenticate`
*/
export interface AuthenticationError {
name: 'TouchIDError';
message: string;
code: AuthenticateErrorCode;
details: string;
}
/**
* Error returned from `isSupported`
*/
export interface IsSupportedError {
name: 'TouchIDError';
message: string;
code: IsSupportedErrorCode;
details: string;
}
const TouchID: {
/**
*
* @param reason String that provides a clear reason for requesting authentication.
* @param config Configuration object for more detailed dialog setup
*/
authenticate(reason?: string, config?: AuthenticateConfig): Promise<true>;
/**
*
* @param config - Returns a `Promise` that rejects if TouchID is not supported. On iOS resolves with a `biometryType` `String` of `FaceID` or `TouchID`
*/
isSupported(config?: IsSupportedConfig): Promise<BiometryType>;
};
export default TouchID;
}