-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
133 lines (111 loc) · 3.08 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
121
122
123
124
125
126
127
128
129
130
131
132
133
// Type definitions for react-native-cie
// Project: https://github.com/pagopa/io-cie-android-sdk
// All events returned by onEvent callback
type CIEEvent =
| "ON_TAG_DISCOVERED_NOT_CIE"
| "ON_TAG_DISCOVERED"
| "ON_TAG_LOST"
| "ON_CARD_PIN_LOCKED"
| "ON_PIN_ERROR"
| "PIN_INPUT_ERROR"
| "CERTIFICATE_EXPIRED"
| "CERTIFICATE_REVOKED"
| "AUTHENTICATION_ERROR"
| "ON_NO_INTERNET_CONNECTION"
| "STOP_NFC_ERROR"
| "START_NFC_ERROR"
| "EXTENDED_APDU_NOT_SUPPORTED"
// iOS dedicated events
| "PIN Locked"
| "TAG_ERROR_NFC_NOT_SUPPORTED"
| "Transmission Error";
type iOSAlertMessageKeys =
| "readingInstructions"
| "moreTags"
| "readingInProgress"
| "readingSuccess"
| "invalidCard"
| "tagLost"
| "cardLocked"
| "wrongPin1AttemptLeft"
| "wrongPin2AttemptLeft"
| "genericError";
export type Event = {
event: CIEEvent;
attemptsLeft: number;
};
declare class CieManager {
/**
* check if the OS support CIE autentication
*/
hasApiLevelSupport(): Promise<boolean>;
/**
* check if the device has NFC feature
*/
hasNFCFeature(): Promise<boolean>;
/**
* check if the device running the code supports CIE authentication
*/
isCIEAuthenticationSupported(): Promise<boolean>;
/**
* check if NFC is enabled
*/
isNFCEnabled(): Promise<boolean>;
/**
* launch CieID app (https://play.google.com/store/apps/details?id=it.ipzs.cieid&hl=it)
* if it's installed. Otherwise the default browser is opened on the app url
*/
launchCieID(): Promise<void>;
/**
* register a callback to receive all Event raised while reading/writing CIE
*/
onEvent(callback: (event: Event) => void): void;
/**
* opens OS Settings on NFC section
*/
openNFCSettings(): Promise<void>;
/**
* register a callback to receive errors occured while reading/writing CIE
*/
onError(callback: (error: Error) => void): void;
/**
* register a callback to receive the success event containing the consent form url
*/
onSuccess(callback: (url: string) => void): void;
/**
* Enable/Disable CIE SDK logs
* @param isEnabled true to enable logs, false to disable
*/
enableLog(isEnabled: boolean): void;
/**
* set a custom IdP url, leave it empty to use the default one
* @param idpUrl the cutom IdP url
*/
setCustomIdpUrl(idpUrl: string?): void;
setAuthenticationUrl(url: string): void;
/**
* set the CIE pin. It has to be a 8 length string of 8 digits
*/
setPin(pin: string): Promise<void>;
start(
alertMessagesConfig?: Partial<Record<iOSAlertMessageKeys, string>>
): Promise<void>;
/**
* command CIE SDK to start reading/writing CIE CARD
*/
startListeningNFC(): Promise<void>;
/**
* command CIE SDK to stop reading/writing CIE CARD
*/
stopListeningNFC(): Promise<void>;
/**
* Remove all events callbacks: onEvent / onError / onSuccess
*/
removeAllListeners(): void;
/**
* only iOS.
* customize the info and error messages shown on NFC reading card alert
*/
setAlertMessage(key: iOSAlertMessageKeys, value: string): void;
}
export default new CieManager();