@pagopa/io-react-native-cie 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/IoReactNativeCie.podspec +1 -1
- package/README.md +18 -16
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/pagopa/ioreactnativecie/IoReactNativeCieModule.kt +227 -7
- package/ios/Data/Data+StringRepresentations.swift +2 -2
- package/ios/IoReactNativeCie.mm +13 -0
- package/ios/IoReactNativeCie.swift +88 -2
- package/lib/module/manager/index.js +98 -1
- package/lib/module/manager/index.js.map +1 -1
- package/lib/module/manager/types.js +29 -2
- package/lib/module/manager/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/manager/index.d.ts +92 -1
- package/lib/typescript/src/manager/index.d.ts.map +1 -1
- package/lib/typescript/src/manager/types.d.ts +84 -3
- package/lib/typescript/src/manager/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/manager/index.ts +113 -0
- package/src/manager/types.ts +44 -3
package/IoReactNativeCie.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
17
|
|
|
18
18
|
# CieSDK dependency
|
|
19
|
-
s.dependency "CieSDK", "~> 0.1.
|
|
19
|
+
s.dependency "CieSDK", "~> 0.1.13"
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/README.md
CHANGED
|
@@ -97,22 +97,24 @@ To run the example app, follow the instructions in [example/README.md](./example
|
|
|
97
97
|
|
|
98
98
|
List of available functions
|
|
99
99
|
|
|
100
|
-
| Function
|
|
101
|
-
|
|
|
102
|
-
| `hasNFCFeature()`
|
|
103
|
-
| `isNfcEnabled()`
|
|
104
|
-
| `isCieAuthenticationSupported()`
|
|
105
|
-
| `openNfcSettings()`
|
|
106
|
-
| `addListener(event: CieEvent, listener: CieEventHandlers)`
|
|
107
|
-
| `removeListener(event: CieEvent)`
|
|
108
|
-
| `removeAllListeners()`
|
|
109
|
-
| `setCustomIdpUrl(url?: string)`
|
|
110
|
-
| `setAlertMessage(key: AlertMessageKey, value: string)`
|
|
111
|
-
| `setCurrentAlertMessage(value: string)`
|
|
112
|
-
| `startInternalAuthentication(challenge: string)`
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
100
|
+
| Function | Return | Description |
|
|
101
|
+
| :---------------------------------------------------------------------------------------------------------------------- | :----------------- | :----------------------------------------------------------------------------- |
|
|
102
|
+
| `hasNFCFeature()` | `Promise<boolean>` | (Android) Checks if the device supports NFC feature |
|
|
103
|
+
| `isNfcEnabled()` | `Promise<boolean>` | (Android) Checks if the NFC is currently enabled |
|
|
104
|
+
| `isCieAuthenticationSupported()` | `Promise<boolean>` | (Android) Checks if the device supports CIE autentication |
|
|
105
|
+
| `openNfcSettings()` | `Promise<void>` | (Android) Opens NFC system settings page |
|
|
106
|
+
| `addListener(event: CieEvent, listener: CieEventHandlers)` | `() => void` | Adds a NFC event listener and returns a function to unsubscribe from the event |
|
|
107
|
+
| `removeListener(event: CieEvent)` | `void` | Removes all listeners for the specified event |
|
|
108
|
+
| `removeAllListeners()` | `void` | Removes all registered listeners |
|
|
109
|
+
| `setCustomIdpUrl(url?: string)` | `void` | Updates IDP url, if `undefined` will use the default IDP url |
|
|
110
|
+
| `setAlertMessage(key: AlertMessageKey, value: string)` | `void` | (iOS) Updates iOS NFC modal alert message |
|
|
111
|
+
| `setCurrentAlertMessage(value: string)` | `void` | (iOS) Updates currently displayed iOS NFC modal alert message |
|
|
112
|
+
| `startInternalAuthentication(challenge: string, resultEncoding?: 'hex' \| 'base64', timeout?: number)` | `Promise<void>` | Start the CIE IAS/NIS Internal Authentication |
|
|
113
|
+
| `startMRTDReading(can: string, resultEncoding?: 'hex' \| 'base64', timeout?: number)` | `Promise<void>` | Start PACE MRTD reading (reads MRTD data using CAN) |
|
|
114
|
+
| `startInternalAuthAndMRTDReading(can: string, challenge: string, resultEncoding?: 'hex' \| 'base64', timeout?: number)` | `Promise<void>` | Start combined Internal Authentication + PACE MRTD reading |
|
|
115
|
+
| `startReadingAttributes(timeout: number)` | `Promise<void>` | Start the CIE attributes reading process |
|
|
116
|
+
| `startReading(pin: string, authenticationUrl: string, timeout: number)` | `Promise<void>` | Start the CIE reading process fro authentication |
|
|
117
|
+
| `stopReading()` | `Promise<void>` | (Android) Stops all reading process |
|
|
116
118
|
|
|
117
119
|
## Usage
|
|
118
120
|
|
package/android/build.gradle
CHANGED
|
@@ -5,18 +5,24 @@ import com.facebook.react.bridge.Promise
|
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
7
|
import com.facebook.react.bridge.ReactMethod
|
|
8
|
-
import com.facebook.react.bridge.WritableMap
|
|
9
8
|
import com.facebook.react.bridge.WritableNativeMap
|
|
10
9
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
11
10
|
import com.pagopa.ioreactnativecie.cie.Atr
|
|
12
11
|
import it.pagopa.io.app.cie.CieLogger
|
|
13
12
|
import it.pagopa.io.app.cie.CieSDK
|
|
13
|
+
import it.pagopa.io.app.cie.IntAuthMRTDResponse
|
|
14
|
+
import it.pagopa.io.app.cie.NisAndPaceCallback
|
|
14
15
|
import it.pagopa.io.app.cie.cie.CieAtrCallback
|
|
15
16
|
import it.pagopa.io.app.cie.cie.NfcError
|
|
16
17
|
import it.pagopa.io.app.cie.cie.NfcEvent
|
|
17
18
|
import it.pagopa.io.app.cie.network.NetworkCallback
|
|
18
19
|
import it.pagopa.io.app.cie.network.NetworkError
|
|
19
20
|
import it.pagopa.io.app.cie.nfc.NfcEvents
|
|
21
|
+
import it.pagopa.io.app.cie.nis.InternalAuthenticationResponse
|
|
22
|
+
import it.pagopa.io.app.cie.nis.NisCallback
|
|
23
|
+
import it.pagopa.io.app.cie.pace.MRTDResponse
|
|
24
|
+
import it.pagopa.io.app.cie.pace.PaceCallback
|
|
25
|
+
import it.pagopa.io.app.cie.toHex
|
|
20
26
|
import java.net.URL
|
|
21
27
|
|
|
22
28
|
class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
@@ -35,16 +41,19 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
35
41
|
*/
|
|
36
42
|
val cieSdk: CieSDK by lazy {
|
|
37
43
|
CieSDK.withContext(currentActivity)
|
|
38
|
-
}
|
|
44
|
+
}
|
|
39
45
|
|
|
46
|
+
@Suppress("unused")
|
|
40
47
|
@ReactMethod
|
|
41
48
|
fun addListener(eventName: String) {
|
|
42
49
|
}
|
|
43
50
|
|
|
51
|
+
@Suppress("unused")
|
|
44
52
|
@ReactMethod
|
|
45
53
|
fun removeListeners(count: Int) {
|
|
46
54
|
}
|
|
47
55
|
|
|
56
|
+
@Suppress("unused")
|
|
48
57
|
@ReactMethod
|
|
49
58
|
fun hasNfcFeature(promise: Promise) {
|
|
50
59
|
try {
|
|
@@ -56,6 +65,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
|
|
68
|
+
@Suppress("unused")
|
|
59
69
|
@ReactMethod
|
|
60
70
|
fun isNfcEnabled(promise: Promise) {
|
|
61
71
|
try {
|
|
@@ -67,6 +77,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
|
|
80
|
+
@Suppress("unused")
|
|
70
81
|
@ReactMethod
|
|
71
82
|
fun isCieAuthenticationSupported(promise: Promise) {
|
|
72
83
|
cieSdk.isCieAuthenticationSupported().apply {
|
|
@@ -74,6 +85,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
87
|
|
|
88
|
+
@Suppress("unused")
|
|
77
89
|
@ReactMethod
|
|
78
90
|
fun openNfcSettings(promise: Promise) {
|
|
79
91
|
try {
|
|
@@ -84,21 +96,205 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
|
|
99
|
+
@Suppress("unused")
|
|
87
100
|
@ReactMethod
|
|
88
101
|
fun setAlertMessage(key: String, value: String) {
|
|
89
102
|
// Android does not support alert messages for NFC reading
|
|
90
103
|
}
|
|
91
104
|
|
|
105
|
+
@Suppress("unused")
|
|
92
106
|
@ReactMethod
|
|
93
107
|
fun setCurrentAlertMessage(value: String) {
|
|
94
108
|
// Android does not support alert messages for NFC reading
|
|
95
109
|
}
|
|
96
110
|
|
|
111
|
+
@Suppress("unused")
|
|
97
112
|
@ReactMethod
|
|
98
113
|
fun setCustomIdpUrl(url: String) {
|
|
99
114
|
cieSdk.withCustomIdpUrl(url)
|
|
100
115
|
}
|
|
101
116
|
|
|
117
|
+
@Suppress("unused")
|
|
118
|
+
@ReactMethod
|
|
119
|
+
fun startInternalAuthentication(
|
|
120
|
+
challenge: String,
|
|
121
|
+
resultEncoding: String,
|
|
122
|
+
timeout: Int = 10000,
|
|
123
|
+
promise: Promise,
|
|
124
|
+
) {
|
|
125
|
+
val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
|
|
126
|
+
try {
|
|
127
|
+
cieSdk.startReadingNis(challenge, timeout, object : NfcEvents {
|
|
128
|
+
override fun event(event: NfcEvent) {
|
|
129
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
130
|
+
.emit(EventType.EVENT.value, WritableNativeMap().apply {
|
|
131
|
+
putString("name", event.name)
|
|
132
|
+
putDouble(
|
|
133
|
+
"progress",
|
|
134
|
+
(event.numeratorForNis.toDouble() / NfcEvent.totalNisOfNumeratorEvent.toDouble())
|
|
135
|
+
)
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
override fun error(error: NfcError) {
|
|
140
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
141
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
142
|
+
putString("name", mapNfcError(error).name)
|
|
143
|
+
error.msg?.let { putString("message", it) }
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
}, object : NisCallback {
|
|
148
|
+
override fun onSuccess(nisAuth: InternalAuthenticationResponse) {
|
|
149
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
150
|
+
.emit(EventType.INTERNAL_AUTHENTICATION_SUCCESS.value, WritableNativeMap().apply {
|
|
151
|
+
putString("nis", encoding.encode(nisAuth.nis))
|
|
152
|
+
putString("publicKey", encoding.encode(nisAuth.kpubIntServ))
|
|
153
|
+
putString("sod", encoding.encode(nisAuth.sod))
|
|
154
|
+
putString("signedChallenge", encoding.encode(nisAuth.challengeSigned))
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
override fun onError(error: NfcError) {
|
|
159
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
160
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
161
|
+
putString("name", mapNfcError(error).name)
|
|
162
|
+
error.msg?.let { putString("message", it) }
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
promise.resolve(null)
|
|
167
|
+
} catch (e: Exception) {
|
|
168
|
+
promise.reject(ModuleException.UNKNOWN_EXCEPTION, e.message, e)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@Suppress("unused")
|
|
173
|
+
@ReactMethod
|
|
174
|
+
fun startMRTDReading(
|
|
175
|
+
can: String,
|
|
176
|
+
resultEncoding: String,
|
|
177
|
+
timeout: Int = 10000,
|
|
178
|
+
promise: Promise,
|
|
179
|
+
) {
|
|
180
|
+
val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
|
|
181
|
+
try {
|
|
182
|
+
cieSdk.startDoPace(can, timeout, object : NfcEvents {
|
|
183
|
+
override fun event(event: NfcEvent) {
|
|
184
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
185
|
+
.emit(EventType.EVENT.value, WritableNativeMap().apply {
|
|
186
|
+
putString("name", event.name)
|
|
187
|
+
putDouble(
|
|
188
|
+
"progress",
|
|
189
|
+
(event.numeratorForPace.toDouble() / NfcEvent.totalPaceOfNumeratorEvent.toDouble())
|
|
190
|
+
)
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
override fun error(error: NfcError) {
|
|
195
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
196
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
197
|
+
putString("name", mapNfcError(error).name)
|
|
198
|
+
error.msg?.let { putString("message", it) }
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
}, object : PaceCallback {
|
|
203
|
+
override fun onSuccess(eMRTDResponse: MRTDResponse) {
|
|
204
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
205
|
+
.emit(EventType.MRTD_WITH_PACE_SUCCESS.value, WritableNativeMap().apply {
|
|
206
|
+
putString("dg1", encoding.encode(eMRTDResponse.dg1))
|
|
207
|
+
putString("dg11", encoding.encode(eMRTDResponse.dg11))
|
|
208
|
+
putString("sod", encoding.encode(eMRTDResponse.sod))
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
override fun onError(error: NfcError) {
|
|
213
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
214
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
215
|
+
putString("name", mapNfcError(error).name)
|
|
216
|
+
error.msg?.let { putString("message", it) }
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
promise.resolve(null)
|
|
221
|
+
} catch (e: Exception) {
|
|
222
|
+
promise.reject(ModuleException.UNKNOWN_EXCEPTION, e.message, e)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@Suppress("unused")
|
|
227
|
+
@ReactMethod
|
|
228
|
+
fun startInternalAuthAndMRTDReading(
|
|
229
|
+
can: String,
|
|
230
|
+
challenge: String,
|
|
231
|
+
resultEncoding: String,
|
|
232
|
+
timeout: Int = 10000,
|
|
233
|
+
promise: Promise,
|
|
234
|
+
) {
|
|
235
|
+
val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
|
|
236
|
+
try {
|
|
237
|
+
cieSdk.startNisAndPace(challenge, can, timeout, object : NfcEvents {
|
|
238
|
+
override fun event(event: NfcEvent) {
|
|
239
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
240
|
+
.emit(EventType.EVENT.value, WritableNativeMap().apply {
|
|
241
|
+
putString("name", event.name)
|
|
242
|
+
putDouble(
|
|
243
|
+
"progress",
|
|
244
|
+
(event.numeratorForNisAndPace.toDouble() / NfcEvent.totalNisAndPaceOfNumeratorEvent.toDouble())
|
|
245
|
+
)
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
override fun error(error: NfcError) {
|
|
250
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
251
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
252
|
+
putString("name", mapNfcError(error).name)
|
|
253
|
+
error.msg?.let { putString("message", it) }
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
}, object : NisAndPaceCallback {
|
|
258
|
+
override fun onSuccess(intAuthMRTDResponse: IntAuthMRTDResponse) {
|
|
259
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
260
|
+
.emit(
|
|
261
|
+
EventType.INTERNAL_AUTH_AND_MRTD_WITH_PACE_SUCCESS.value,
|
|
262
|
+
WritableNativeMap().apply {
|
|
263
|
+
putMap("nis_data", WritableNativeMap().apply {
|
|
264
|
+
putString("nis", encoding.encode(intAuthMRTDResponse.internalAuthentication.nis))
|
|
265
|
+
putString(
|
|
266
|
+
"publicKey",
|
|
267
|
+
encoding.encode(intAuthMRTDResponse.internalAuthentication.kpubIntServ)
|
|
268
|
+
)
|
|
269
|
+
putString("sod", encoding.encode(intAuthMRTDResponse.internalAuthentication.sod))
|
|
270
|
+
putString(
|
|
271
|
+
"signedChallenge",
|
|
272
|
+
encoding.encode(intAuthMRTDResponse.internalAuthentication.challengeSigned)
|
|
273
|
+
)
|
|
274
|
+
})
|
|
275
|
+
putMap("mrtd_data", WritableNativeMap().apply {
|
|
276
|
+
putString("dg1", encoding.encode(intAuthMRTDResponse.mrtd.dg1))
|
|
277
|
+
putString("dg11", encoding.encode(intAuthMRTDResponse.mrtd.dg11))
|
|
278
|
+
putString("sod", encoding.encode(intAuthMRTDResponse.mrtd.sod))
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
override fun onError(error: NfcError) {
|
|
284
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
285
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
286
|
+
putString("name", mapNfcError(error).name)
|
|
287
|
+
error.msg?.let { putString("message", it) }
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
promise.resolve(null)
|
|
292
|
+
} catch (e: Exception) {
|
|
293
|
+
promise.reject(ModuleException.UNKNOWN_EXCEPTION, e.message, e)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@Suppress("unused")
|
|
102
298
|
@ReactMethod
|
|
103
299
|
fun startReadingAttributes(
|
|
104
300
|
timeout: Int = 10000,
|
|
@@ -148,6 +344,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
148
344
|
}
|
|
149
345
|
}
|
|
150
346
|
|
|
347
|
+
@Suppress("unused")
|
|
151
348
|
@ReactMethod
|
|
152
349
|
fun startReading(
|
|
153
350
|
pin: String,
|
|
@@ -159,7 +356,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
159
356
|
cieSdk.setPin(pin)
|
|
160
357
|
} catch (e: Exception) {
|
|
161
358
|
promise.reject(ModuleException.PIN_REGEX_NOT_VALID, e.message, e)
|
|
162
|
-
return
|
|
359
|
+
return
|
|
163
360
|
}
|
|
164
361
|
|
|
165
362
|
try {
|
|
@@ -210,6 +407,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
210
407
|
}
|
|
211
408
|
}
|
|
212
409
|
|
|
410
|
+
@Suppress("unused")
|
|
213
411
|
@ReactMethod
|
|
214
412
|
fun stopReading() {
|
|
215
413
|
cieSdk.stopNFCListening()
|
|
@@ -239,12 +437,34 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
239
437
|
|
|
240
438
|
companion object {
|
|
241
439
|
const val NAME = "IoReactNativeCie"
|
|
242
|
-
|
|
440
|
+
|
|
441
|
+
enum class ResultEncoding(val value: String) {
|
|
442
|
+
BASE64("base64"),
|
|
443
|
+
HEX("hex");
|
|
444
|
+
|
|
445
|
+
fun encode(data: ByteArray): String = when (this) {
|
|
446
|
+
BASE64 -> Base64.encodeToString(data, Base64.URL_SAFE or Base64.NO_WRAP)
|
|
447
|
+
HEX -> data.toHex().uppercase()
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
companion object {
|
|
451
|
+
fun fromString(value: String?): ResultEncoding {
|
|
452
|
+
return when (value) {
|
|
453
|
+
"hex" -> HEX
|
|
454
|
+
"base64" -> BASE64
|
|
455
|
+
else -> BASE64 // Default
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
243
460
|
|
|
244
461
|
enum class EventType(val value: String) {
|
|
245
462
|
EVENT("onEvent"),
|
|
246
463
|
ERROR("onError"),
|
|
247
464
|
ATTRIBUTES_SUCCESS("onAttributesSuccess"),
|
|
465
|
+
INTERNAL_AUTHENTICATION_SUCCESS("onInternalAuthenticationSuccess"),
|
|
466
|
+
MRTD_WITH_PACE_SUCCESS("onMRTDWithPaceSuccess"),
|
|
467
|
+
INTERNAL_AUTH_AND_MRTD_WITH_PACE_SUCCESS("onInternalAuthAndMRTDWithPaceSuccess"),
|
|
248
468
|
SUCCESS("onSuccess")
|
|
249
469
|
}
|
|
250
470
|
|
|
@@ -262,9 +482,9 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
262
482
|
}
|
|
263
483
|
|
|
264
484
|
private object ModuleException {
|
|
265
|
-
const val PIN_REGEX_NOT_VALID = "PIN_REGEX_NOT_VALID"
|
|
266
|
-
const val INVALID_AUTH_URL = "INVALID_AUTH_URL"
|
|
267
|
-
const val UNKNOWN_EXCEPTION = "UNKNOWN_EXCEPTION"
|
|
485
|
+
const val PIN_REGEX_NOT_VALID = "PIN_REGEX_NOT_VALID"
|
|
486
|
+
const val INVALID_AUTH_URL = "INVALID_AUTH_URL"
|
|
487
|
+
const val UNKNOWN_EXCEPTION = "UNKNOWN_EXCEPTION"
|
|
268
488
|
}
|
|
269
489
|
}
|
|
270
490
|
}
|
|
@@ -9,9 +9,9 @@ import Foundation
|
|
|
9
9
|
|
|
10
10
|
extension Data {
|
|
11
11
|
|
|
12
|
-
/// Converts the data to
|
|
12
|
+
/// Converts the data to an uppercase hexadecimal string.
|
|
13
13
|
func toHexString() -> String {
|
|
14
|
-
return self.map { String(format: "%
|
|
14
|
+
return self.map { String(format: "%02X", $0) }.joined()
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/// Converts the data to a base64url encoded string (RFC 7515), without padding.
|
package/ios/IoReactNativeCie.mm
CHANGED
|
@@ -31,6 +31,19 @@ RCT_EXTERN_METHOD(startInternalAuthentication: (NSString)challenge
|
|
|
31
31
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
32
32
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
33
33
|
|
|
34
|
+
RCT_EXTERN_METHOD(startMRTDReading: (NSString)can
|
|
35
|
+
withResultEncoding: (NSString)encodingString
|
|
36
|
+
withTimeout: (NSNumber)timeout
|
|
37
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
38
|
+
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
39
|
+
|
|
40
|
+
RCT_EXTERN_METHOD(startInternalAuthAndMRTDReading: (NSString)can
|
|
41
|
+
withChallenge: (NSString)challenge
|
|
42
|
+
withResultEncoding: (NSString)encodingString
|
|
43
|
+
withTimeout: (NSNumber)timeout
|
|
44
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
45
|
+
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
46
|
+
|
|
34
47
|
RCT_EXTERN_METHOD(startReadingAttributes: (NSNumber)timeout
|
|
35
48
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
36
49
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
@@ -85,15 +85,99 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
85
85
|
)
|
|
86
86
|
let encoding = DataEncoding.from(string: encodingString)
|
|
87
87
|
let payload: NSDictionary = [
|
|
88
|
-
"
|
|
88
|
+
"nis": internalAuthResponse.nis.encodedDataString(encoding: encoding),
|
|
89
|
+
"publicKey": internalAuthResponse.publicKey.encodedDataString(encoding: encoding),
|
|
90
|
+
"sod": internalAuthResponse.sod.encodedDataString(encoding: encoding),
|
|
91
|
+
"signedChallenge": internalAuthResponse.signedChallenge.encodedDataString(encoding: encoding)
|
|
92
|
+
]
|
|
93
|
+
self.sendEvent(
|
|
94
|
+
withName: EventType.onInternalAuthenticationSuccess.rawValue, body: payload)
|
|
95
|
+
resolve(nil)
|
|
96
|
+
} catch {
|
|
97
|
+
guard let nfcDigitalIdError = error as? NfcDigitalIdError else {
|
|
98
|
+
reject(ModuleException.unexpected.rawValue, error.localizedDescription, error)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
handleReadError(nfcDigitalIdError)
|
|
102
|
+
resolve(nil)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@objc func startMRTDReading(
|
|
108
|
+
_ can: String,
|
|
109
|
+
withResultEncoding encodingString: String,
|
|
110
|
+
withTimeout timeout: Int,
|
|
111
|
+
withResolver resolve: @escaping RCTPromiseResolveBlock,
|
|
112
|
+
withRejecter reject: @escaping RCTPromiseRejectBlock
|
|
113
|
+
) {
|
|
114
|
+
Task { [weak self] in
|
|
115
|
+
guard let self = self else {
|
|
116
|
+
reject(ModuleException.threadingError.rawValue, "Failed to perform background operation, self was deallocated", nil)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
do {
|
|
121
|
+
let mrtdResponse = try await self.cieSdk.performMtrd(
|
|
122
|
+
can: can,
|
|
123
|
+
handleReadEvent
|
|
124
|
+
)
|
|
125
|
+
let encoding = DataEncoding.from(string: encodingString)
|
|
126
|
+
let payload: NSDictionary = [
|
|
127
|
+
"dg1": mrtdResponse.dg1.encodedDataString(encoding: encoding),
|
|
128
|
+
"dg11": mrtdResponse.dg11.encodedDataString(encoding: encoding),
|
|
129
|
+
"sod": mrtdResponse.sod.encodedDataString(encoding: encoding)
|
|
130
|
+
]
|
|
131
|
+
self.sendEvent(
|
|
132
|
+
withName: EventType.onMRTDWithPaceSuccess.rawValue, body: payload)
|
|
133
|
+
resolve(nil)
|
|
134
|
+
} catch {
|
|
135
|
+
guard let nfcDigitalIdError = error as? NfcDigitalIdError else {
|
|
136
|
+
reject(ModuleException.unexpected.rawValue, error.localizedDescription, error)
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
handleReadError(nfcDigitalIdError)
|
|
140
|
+
resolve(nil)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@objc func startInternalAuthAndMRTDReading(
|
|
146
|
+
_ can: String,
|
|
147
|
+
withChallenge challenge: String,
|
|
148
|
+
withResultEncoding encodingString: String,
|
|
149
|
+
withTimeout timeout: Int,
|
|
150
|
+
withResolver resolve: @escaping RCTPromiseResolveBlock,
|
|
151
|
+
withRejecter reject: @escaping RCTPromiseRejectBlock
|
|
152
|
+
) {
|
|
153
|
+
Task { [weak self] in
|
|
154
|
+
guard let self = self else {
|
|
155
|
+
reject(ModuleException.threadingError.rawValue, "Failed to perform background operation, self was deallocated", nil)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
do {
|
|
160
|
+
let (mrtdResponse, internalAuthResponse) = try await self.cieSdk.performMRTDAndInternalAuthentication(
|
|
161
|
+
challenge: Array(challenge.utf8),
|
|
162
|
+
can: can,
|
|
163
|
+
handleReadEvent
|
|
164
|
+
)
|
|
165
|
+
let encoding = DataEncoding.from(string: encodingString)
|
|
166
|
+
let payload: NSDictionary = [
|
|
167
|
+
"nis_data": [
|
|
89
168
|
"nis": internalAuthResponse.nis.encodedDataString(encoding: encoding),
|
|
90
169
|
"publicKey": internalAuthResponse.publicKey.encodedDataString(encoding: encoding),
|
|
91
170
|
"sod": internalAuthResponse.sod.encodedDataString(encoding: encoding),
|
|
92
171
|
"signedChallenge": internalAuthResponse.signedChallenge.encodedDataString(encoding: encoding)
|
|
172
|
+
],
|
|
173
|
+
"mrtd_data": [
|
|
174
|
+
"dg1": mrtdResponse.dg1.encodedDataString(encoding: encoding),
|
|
175
|
+
"dg11": mrtdResponse.dg11.encodedDataString(encoding: encoding),
|
|
176
|
+
"sod": mrtdResponse.sod.encodedDataString(encoding: encoding)
|
|
93
177
|
]
|
|
94
178
|
]
|
|
95
179
|
self.sendEvent(
|
|
96
|
-
withName: EventType.
|
|
180
|
+
withName: EventType.onInternalAuthAndMRTDWithPaceSuccess.rawValue, body: payload)
|
|
97
181
|
resolve(nil)
|
|
98
182
|
} catch {
|
|
99
183
|
guard let nfcDigitalIdError = error as? NfcDigitalIdError else {
|
|
@@ -216,6 +300,8 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
216
300
|
case onError
|
|
217
301
|
case onAttributesSuccess
|
|
218
302
|
case onInternalAuthenticationSuccess
|
|
303
|
+
case onMRTDWithPaceSuccess
|
|
304
|
+
case onInternalAuthAndMRTDWithPaceSuccess
|
|
219
305
|
case onSuccess
|
|
220
306
|
}
|
|
221
307
|
|
|
@@ -108,6 +108,103 @@ const startInternalAuthentication = async (challenge, resultEncoding = 'base64',
|
|
|
108
108
|
return IoReactNativeCie.startInternalAuthentication(challenge, resultEncoding, timeout);
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Initiates a PACE (Password Authenticated Connection Establishment) reading
|
|
113
|
+
* session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
|
|
114
|
+
* Access Number) to read the MRTD information.
|
|
115
|
+
*
|
|
116
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
117
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
118
|
+
* native events.
|
|
119
|
+
*
|
|
120
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
121
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
122
|
+
* string; validation (if any) occurs in the native layer.
|
|
123
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
124
|
+
* produced during the reading process. Defaults to
|
|
125
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
126
|
+
* hexadecimal representation.
|
|
127
|
+
* @param timeout Maximum time (in milliseconds) allowed for the PACE reading
|
|
128
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
129
|
+
* A larger value may be required on older devices or in
|
|
130
|
+
* environments with slower NFC interactions.
|
|
131
|
+
*
|
|
132
|
+
* @returns Promise that resolves when the reading process has started.
|
|
133
|
+
*
|
|
134
|
+
* @throws May reject with:
|
|
135
|
+
* - Invalid input (e.g., malformed CAN).
|
|
136
|
+
* - NFC subsystem unavailable or disabled.
|
|
137
|
+
* - Operation timeout exceeded.
|
|
138
|
+
* - Native module internal errors.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* await startPaceReading("123456"); // Uses base64 encoding and default timeout.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* await startPaceReading("654321", "hex", 15000);
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
148
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
149
|
+
*
|
|
150
|
+
* Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
|
|
151
|
+
* while when the reading process produces data, the `'onSuccess'` event has been called.
|
|
152
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
153
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
154
|
+
*/
|
|
155
|
+
const startMRTDReading = async (can, resultEncoding = 'base64', timeout = DEFAULT_TIMEOUT) => {
|
|
156
|
+
return IoReactNativeCie.startMRTDReading(can, resultEncoding, timeout);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
|
|
161
|
+
* that performs both Internal Authentication and MRTD reading using PACE.
|
|
162
|
+
*
|
|
163
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
164
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
165
|
+
* native events.
|
|
166
|
+
*
|
|
167
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
168
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
169
|
+
* string; validation (if any) occurs in the native layer.
|
|
170
|
+
* @param challenge The challenge string to be used for Internal Authentication.
|
|
171
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
172
|
+
* produced during the reading process. Defaults to
|
|
173
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
174
|
+
* hexadecimal representation.
|
|
175
|
+
* @param timeout Maximum time (in milliseconds) allowed for the combined reading
|
|
176
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
177
|
+
* A larger value may be required on older devices or in
|
|
178
|
+
* environments with slower NFC interactions.
|
|
179
|
+
*
|
|
180
|
+
* @returns Promise that resolves when the reading process has started.
|
|
181
|
+
*
|
|
182
|
+
* @throws May reject with:
|
|
183
|
+
* - Invalid input (e.g., malformed CAN or challenge).
|
|
184
|
+
* - NFC subsystem unavailable or disabled.
|
|
185
|
+
* - Operation timeout exceeded.
|
|
186
|
+
* - Native module internal errors.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* await startInternalAuthAndMRTDReading("123456", "challengeString");
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
196
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
197
|
+
*
|
|
198
|
+
* Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
|
|
199
|
+
* a Promise resolves, while when the reading process produces data,
|
|
200
|
+
* the `'onSuccess'` event has been called.
|
|
201
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
202
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
203
|
+
*/
|
|
204
|
+
const startInternalAuthAndMRTDReading = async (can, challenge, resultEncoding = 'base64', timeout = DEFAULT_TIMEOUT) => {
|
|
205
|
+
return IoReactNativeCie.startInternalAuthAndMRTDReading(can, challenge, resultEncoding, timeout);
|
|
206
|
+
};
|
|
207
|
+
|
|
111
208
|
/**
|
|
112
209
|
* Starts the process of reading attributes from the CIE card.
|
|
113
210
|
*
|
|
@@ -159,5 +256,5 @@ const startReading = async (pin, authenticationUrl, timeout = DEFAULT_TIMEOUT) =
|
|
|
159
256
|
const stopReading = async () => {
|
|
160
257
|
return IoReactNativeCie.stopReading();
|
|
161
258
|
};
|
|
162
|
-
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startReading, stopReading };
|
|
259
|
+
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading };
|
|
163
260
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","IoReactNativeCie","getDefaultIdpUrl","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startInternalAuthentication","challenge","resultEncoding","timeout","startReadingAttributes","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,cAAW;AAE5C,SAASC,gBAAgB,QAAQ,YAAS;AAE1C,MAAMC,eAAe,GAAG,KAAK;AAE7B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KAAK,CAAC;AAChD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,2BAA2B,GAAG,MAAAA,CAClCC,SAAiB,EACjBC,cAAgC,GAAG,QAAQ,EAC3CC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACiB,2BAA2B,CACjDC,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","IoReactNativeCie","getDefaultIdpUrl","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startInternalAuthentication","challenge","resultEncoding","timeout","startMRTDReading","can","startInternalAuthAndMRTDReading","startReadingAttributes","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,cAAW;AAE5C,SAASC,gBAAgB,QAAQ,YAAS;AAE1C,MAAMC,eAAe,GAAG,KAAK;AAE7B,MAAMC,YAAY,GAAG,IAAIJ,kBAAkB,CAACC,gBAAgB,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAGA,CAClBC,KAAQ,EACRC,QAA6B,KAC1B;EACH,MAAMC,YAAY,GAAGJ,YAAY,CAACC,WAAW,CAACC,KAAK,EAAEC,QAAQ,CAAC;EAC9D,OAAOC,YAAY,CAACC,MAAM;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAIJ,KAAe,IAAK;EAC1CF,YAAY,CAACO,kBAAkB,CAACL,KAAK,CAAC;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,kBAAkB,GAAGA,CAAA,KAAM;EAC/BP,YAAY,CAACO,kBAAkB,CAAC,SAAS,CAAC;EAC1CP,YAAY,CAACO,kBAAkB,CAAC,SAAS,CAAC;EAC1CP,YAAY,CAACO,kBAAkB,CAAC,qBAAqB,CAAC;EACtDP,YAAY,CAACO,kBAAkB,CAAC,WAAW,CAAC;AAC9C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAIC,GAAuB,IAAK;EACnDZ,gBAAgB,CAACW,eAAe,CAACC,GAAG,IAAIX,gBAAgB,CAAC,CAAC,CAAC;AAC7D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,eAAe,GAAGA,CAACC,GAAoB,EAAEC,KAAa,KAAK;EACtEf,gBAAgB,CAACa,eAAe,CAACC,GAAG,EAAEC,KAAK,CAAC;AAC9C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAID,KAAa,IAAK;EACvDf,gBAAgB,CAACgB,sBAAsB,CAACD,KAAK,CAAC;AAChD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,2BAA2B,GAAG,MAAAA,CAClCC,SAAiB,EACjBC,cAAgC,GAAG,QAAQ,EAC3CC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACiB,2BAA2B,CACjDC,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,MAAAA,CACvBC,GAAW,EACXH,cAAgC,GAAG,QAAQ,EAC3CC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACqB,gBAAgB,CAACC,GAAG,EAAEH,cAAc,EAAEC,OAAO,CAAC;AACxE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,+BAA+B,GAAG,MAAAA,CACtCD,GAAW,EACXJ,SAAiB,EACjBC,cAAgC,GAAG,QAAQ,EAC3CC,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACuB,+BAA+B,CACrDD,GAAG,EACHJ,SAAS,EACTC,cAAc,EACdC,OACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,sBAAsB,GAAG,MAAAA,CAC7BJ,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACwB,sBAAsB,CAACJ,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,YAAY,GAAG,MAAAA,CACnBC,GAAW,EACXC,iBAAyB,EACzBP,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACyB,YAAY,CAACC,GAAG,EAAEC,iBAAiB,EAAEP,OAAO,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMQ,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAO5B,gBAAgB,CAAC4B,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACExB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfa,sBAAsB,EACtBP,2BAA2B,EAC3BI,gBAAgB,EAChBE,+BAA+B,EAC/BE,YAAY,EACZG,WAAW","ignoreList":[]}
|
|
@@ -34,8 +34,8 @@ z.object({
|
|
|
34
34
|
attemptsLeft: z.number()
|
|
35
35
|
})]);
|
|
36
36
|
/**
|
|
37
|
-
* Represent the CIE
|
|
38
|
-
* All string value are Hex encoded
|
|
37
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
38
|
+
* All string value are Hex or Base64 encoded
|
|
39
39
|
*/
|
|
40
40
|
export const InternalAuthResponseObject = z.object({
|
|
41
41
|
nis: z.string(),
|
|
@@ -43,6 +43,33 @@ export const InternalAuthResponseObject = z.object({
|
|
|
43
43
|
sod: z.string(),
|
|
44
44
|
signedChallenge: z.string()
|
|
45
45
|
});
|
|
46
|
+
/**
|
|
47
|
+
* Represent the CIE response coming from MRTD with PACE reading
|
|
48
|
+
* All string value are Hex or Base64 encoded
|
|
49
|
+
*/
|
|
50
|
+
export const MrtdResponseObject = z.object({
|
|
51
|
+
dg1: z.string(),
|
|
52
|
+
dg11: z.string(),
|
|
53
|
+
sod: z.string()
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
57
|
+
* and MRTD with PACE reading during the same NFC session.
|
|
58
|
+
* All string value are Hex or Base64 encoded
|
|
59
|
+
*/
|
|
60
|
+
export const InternalAuthAndMrtdResponse = z.object({
|
|
61
|
+
nis_data: z.object({
|
|
62
|
+
nis: z.string(),
|
|
63
|
+
publicKey: z.string(),
|
|
64
|
+
sod: z.string(),
|
|
65
|
+
signedChallenge: z.string()
|
|
66
|
+
}),
|
|
67
|
+
mrtd_data: z.object({
|
|
68
|
+
dg1: z.string(),
|
|
69
|
+
dg11: z.string(),
|
|
70
|
+
sod: z.string()
|
|
71
|
+
})
|
|
72
|
+
});
|
|
46
73
|
/**
|
|
47
74
|
* Represent the CIE attributes containing the CIE type
|
|
48
75
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","exclude","message","optional","extract","attemptsLeft","InternalAuthResponseObject","nis","publicKey","sod","signedChallenge","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC/BC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,QAAQ,EAAEP,CAAC,CAACQ,MAAM,CAACC,MAAM,CAAC;AAC5B,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGV,CAAC,CAACE,IAAI,CAAC,CACjC,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAChB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMS,QAAQ,GAAGX,CAAC,CAACY,KAAK,CAAC,CAC9BZ,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEK,YAAY,CAACG,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;EACzCC,OAAO,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC;AAC/B,CAAC,CAAC;AACF;AACAf,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEK,YAAY,CAACM,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;EACzCF,OAAO,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC,CAAC;EAC9BE,YAAY,EAAEjB,CAAC,CAACS,MAAM,CAAC;AACzB,CAAC,CAAC,CACH,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMS,0BAA0B,GAAGlB,CAAC,CAACI,MAAM,CAAC;EACjDe,GAAG,EAAEnB,CAAC,CAACM,MAAM,CAAC,CAAC;EACfc,SAAS,EAAEpB,CAAC,CAACM,MAAM,CAAC,CAAC;EACrBe,GAAG,EAAErB,CAAC,CAACM,MAAM,CAAC,CAAC;EACfgB,eAAe,EAAEtB,CAAC,CAACM,MAAM,CAAC;AAC5B,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMiB,
|
|
1
|
+
{"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","exclude","message","optional","extract","attemptsLeft","InternalAuthResponseObject","nis","publicKey","sod","signedChallenge","MrtdResponseObject","dg1","dg11","InternalAuthAndMrtdResponse","nis_data","mrtd_data","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGH,CAAC,CAACI,MAAM,CA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CAACI,MAAM,CAAC;EACzCoB,GAAG,EAAExB,CAAC,CAACM,MAAM,CAAC,CAAC;EACfmB,IAAI,EAAEzB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBe,GAAG,EAAErB,CAAC,CAACM,MAAM,CAAC;AAChB,CAAC,CAAC;AAIF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMoB,2BAA2B,GAAG1B,CAAC,CAACI,MAAM,CAAC;EAClDuB,QAAQ,EAAE3B,CAAC,CAACI,MAAM,CAAC;IACjBe,GAAG,EAAEnB,CAAC,CAACM,MAAM,CAAC,CAAC;IACfc,SAAS,EAAEpB,CAAC,CAACM,MAAM,CAAC,CAAC;IACrBe,GAAG,EAAErB,CAAC,CAACM,MAAM,CAAC,CAAC;IACfgB,eAAe,EAAEtB,CAAC,CAACM,MAAM,CAAC;EAC5B,CAAC,CAAC;EACFsB,SAAS,EAAE5B,CAAC,CAACI,MAAM,CAAC;IAClBoB,GAAG,EAAExB,CAAC,CAACM,MAAM,CAAC,CAAC;IACfmB,IAAI,EAAEzB,CAAC,CAACM,MAAM,CAAC,CAAC;IAChBe,GAAG,EAAErB,CAAC,CAACM,MAAM,CAAC;EAChB,CAAC;AACH,CAAC,CAAC;AAMF;AACA;AACA;AACA,OAAO,MAAMuB,aAAa,GAAG7B,CAAC,CAACI,MAAM,CAAC;EACpC0B,IAAI,EAAE9B,CAAC,CAACM,MAAM,CAAC,CAAC;EAChByB,MAAM,EAAE/B,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;;AAIF;AACA;AACA;;AAeA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as CieUtils from './utils';
|
|
2
2
|
import * as CieManager from './manager';
|
|
3
3
|
export { CieUtils, CieManager };
|
|
4
|
-
export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, } from './manager/types';
|
|
4
|
+
export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, } from './manager/types';
|
|
5
5
|
export type { CieErrorSchema, CieError, CieErrorCodes } from './errors';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEhC,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEhC,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -76,6 +76,97 @@ export declare const setCurrentAlertMessage: (value: string) => void;
|
|
|
76
76
|
* @returns A promise that resolves when the authentication process has ended.
|
|
77
77
|
*/
|
|
78
78
|
declare const startInternalAuthentication: (challenge: string, resultEncoding?: "base64" | "hex", timeout?: number) => Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Initiates a PACE (Password Authenticated Connection Establishment) reading
|
|
81
|
+
* session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
|
|
82
|
+
* Access Number) to read the MRTD information.
|
|
83
|
+
*
|
|
84
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
85
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
86
|
+
* native events.
|
|
87
|
+
*
|
|
88
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
89
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
90
|
+
* string; validation (if any) occurs in the native layer.
|
|
91
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
92
|
+
* produced during the reading process. Defaults to
|
|
93
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
94
|
+
* hexadecimal representation.
|
|
95
|
+
* @param timeout Maximum time (in milliseconds) allowed for the PACE reading
|
|
96
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
97
|
+
* A larger value may be required on older devices or in
|
|
98
|
+
* environments with slower NFC interactions.
|
|
99
|
+
*
|
|
100
|
+
* @returns Promise that resolves when the reading process has started.
|
|
101
|
+
*
|
|
102
|
+
* @throws May reject with:
|
|
103
|
+
* - Invalid input (e.g., malformed CAN).
|
|
104
|
+
* - NFC subsystem unavailable or disabled.
|
|
105
|
+
* - Operation timeout exceeded.
|
|
106
|
+
* - Native module internal errors.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* await startPaceReading("123456"); // Uses base64 encoding and default timeout.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* await startPaceReading("654321", "hex", 15000);
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
116
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
117
|
+
*
|
|
118
|
+
* Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
|
|
119
|
+
* while when the reading process produces data, the `'onSuccess'` event has been called.
|
|
120
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
121
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
122
|
+
*/
|
|
123
|
+
declare const startMRTDReading: (can: string, resultEncoding?: "base64" | "hex", timeout?: number) => Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
|
|
126
|
+
* that performs both Internal Authentication and MRTD reading using PACE.
|
|
127
|
+
*
|
|
128
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
129
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
130
|
+
* native events.
|
|
131
|
+
*
|
|
132
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
133
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
134
|
+
* string; validation (if any) occurs in the native layer.
|
|
135
|
+
* @param challenge The challenge string to be used for Internal Authentication.
|
|
136
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
137
|
+
* produced during the reading process. Defaults to
|
|
138
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
139
|
+
* hexadecimal representation.
|
|
140
|
+
* @param timeout Maximum time (in milliseconds) allowed for the combined reading
|
|
141
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
142
|
+
* A larger value may be required on older devices or in
|
|
143
|
+
* environments with slower NFC interactions.
|
|
144
|
+
*
|
|
145
|
+
* @returns Promise that resolves when the reading process has started.
|
|
146
|
+
*
|
|
147
|
+
* @throws May reject with:
|
|
148
|
+
* - Invalid input (e.g., malformed CAN or challenge).
|
|
149
|
+
* - NFC subsystem unavailable or disabled.
|
|
150
|
+
* - Operation timeout exceeded.
|
|
151
|
+
* - Native module internal errors.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* await startInternalAuthAndMRTDReading("123456", "challengeString");
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
161
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
162
|
+
*
|
|
163
|
+
* Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
|
|
164
|
+
* a Promise resolves, while when the reading process produces data,
|
|
165
|
+
* the `'onSuccess'` event has been called.
|
|
166
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
167
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
168
|
+
*/
|
|
169
|
+
declare const startInternalAuthAndMRTDReading: (can: string, challenge: string, resultEncoding?: "base64" | "hex", timeout?: number) => Promise<void>;
|
|
79
170
|
/**
|
|
80
171
|
* Starts the process of reading attributes from the CIE card.
|
|
81
172
|
*
|
|
@@ -119,5 +210,5 @@ declare const startReading: (pin: string, authenticationUrl: string, timeout?: n
|
|
|
119
210
|
* ```
|
|
120
211
|
*/
|
|
121
212
|
declare const stopReading: () => Promise<void>;
|
|
122
|
-
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startReading, stopReading, };
|
|
213
|
+
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading, };
|
|
123
214
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAOhF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,QAAQ,EACrC,OAAO,CAAC,EACR,UAAU,gBAAgB,CAAC,CAAC,CAAC,eAI9B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,GAAI,OAAO,QAAQ,SAEtC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,YAKvB,CAAC;AAEF;;;;;;;;;;;GAWG;AAC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AEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,+BAA+B,EAC/B,YAAY,EACZ,WAAW,GACZ,CAAC"}
|
|
@@ -53,8 +53,8 @@ export declare const NfcError: z.ZodUnion<[z.ZodObject<{
|
|
|
53
53
|
}>]>;
|
|
54
54
|
export type NfcError = z.infer<typeof NfcError>;
|
|
55
55
|
/**
|
|
56
|
-
* Represent the CIE
|
|
57
|
-
* All string value are Hex encoded
|
|
56
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
57
|
+
* All string value are Hex or Base64 encoded
|
|
58
58
|
*/
|
|
59
59
|
export declare const InternalAuthResponseObject: z.ZodObject<{
|
|
60
60
|
nis: z.ZodString;
|
|
@@ -73,6 +73,85 @@ export declare const InternalAuthResponseObject: z.ZodObject<{
|
|
|
73
73
|
signedChallenge: string;
|
|
74
74
|
}>;
|
|
75
75
|
export type InternalAuthResponse = z.infer<typeof InternalAuthResponseObject>;
|
|
76
|
+
/**
|
|
77
|
+
* Represent the CIE response coming from MRTD with PACE reading
|
|
78
|
+
* All string value are Hex or Base64 encoded
|
|
79
|
+
*/
|
|
80
|
+
export declare const MrtdResponseObject: z.ZodObject<{
|
|
81
|
+
dg1: z.ZodString;
|
|
82
|
+
dg11: z.ZodString;
|
|
83
|
+
sod: z.ZodString;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
sod: string;
|
|
86
|
+
dg1: string;
|
|
87
|
+
dg11: string;
|
|
88
|
+
}, {
|
|
89
|
+
sod: string;
|
|
90
|
+
dg1: string;
|
|
91
|
+
dg11: string;
|
|
92
|
+
}>;
|
|
93
|
+
export type MrtdResponse = z.infer<typeof MrtdResponseObject>;
|
|
94
|
+
/**
|
|
95
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
96
|
+
* and MRTD with PACE reading during the same NFC session.
|
|
97
|
+
* All string value are Hex or Base64 encoded
|
|
98
|
+
*/
|
|
99
|
+
export declare const InternalAuthAndMrtdResponse: z.ZodObject<{
|
|
100
|
+
nis_data: z.ZodObject<{
|
|
101
|
+
nis: z.ZodString;
|
|
102
|
+
publicKey: z.ZodString;
|
|
103
|
+
sod: z.ZodString;
|
|
104
|
+
signedChallenge: z.ZodString;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
nis: string;
|
|
107
|
+
publicKey: string;
|
|
108
|
+
sod: string;
|
|
109
|
+
signedChallenge: string;
|
|
110
|
+
}, {
|
|
111
|
+
nis: string;
|
|
112
|
+
publicKey: string;
|
|
113
|
+
sod: string;
|
|
114
|
+
signedChallenge: string;
|
|
115
|
+
}>;
|
|
116
|
+
mrtd_data: z.ZodObject<{
|
|
117
|
+
dg1: z.ZodString;
|
|
118
|
+
dg11: z.ZodString;
|
|
119
|
+
sod: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
sod: string;
|
|
122
|
+
dg1: string;
|
|
123
|
+
dg11: string;
|
|
124
|
+
}, {
|
|
125
|
+
sod: string;
|
|
126
|
+
dg1: string;
|
|
127
|
+
dg11: string;
|
|
128
|
+
}>;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
nis_data: {
|
|
131
|
+
nis: string;
|
|
132
|
+
publicKey: string;
|
|
133
|
+
sod: string;
|
|
134
|
+
signedChallenge: string;
|
|
135
|
+
};
|
|
136
|
+
mrtd_data: {
|
|
137
|
+
sod: string;
|
|
138
|
+
dg1: string;
|
|
139
|
+
dg11: string;
|
|
140
|
+
};
|
|
141
|
+
}, {
|
|
142
|
+
nis_data: {
|
|
143
|
+
nis: string;
|
|
144
|
+
publicKey: string;
|
|
145
|
+
sod: string;
|
|
146
|
+
signedChallenge: string;
|
|
147
|
+
};
|
|
148
|
+
mrtd_data: {
|
|
149
|
+
sod: string;
|
|
150
|
+
dg1: string;
|
|
151
|
+
dg11: string;
|
|
152
|
+
};
|
|
153
|
+
}>;
|
|
154
|
+
export type InternalAuthAndMrtdResponse = z.infer<typeof InternalAuthAndMrtdResponse>;
|
|
76
155
|
/**
|
|
77
156
|
* Represent the CIE attributes containing the CIE type
|
|
78
157
|
*/
|
|
@@ -93,7 +172,9 @@ export type CieAttributes = z.infer<typeof CieAttributes>;
|
|
|
93
172
|
export type CieEventHandlers = {
|
|
94
173
|
onEvent: (event: NfcEvent) => void;
|
|
95
174
|
onError: (error: NfcError) => void;
|
|
96
|
-
onInternalAuthenticationSuccess: (
|
|
175
|
+
onInternalAuthenticationSuccess: (internalAuthResponse: InternalAuthResponse) => void;
|
|
176
|
+
onMRTDWithPaceSuccess: (mrtdResponse: MrtdResponse) => void;
|
|
177
|
+
onInternalAuthAndMRTDWithPaceSuccess: (internalAuthAndMrtdResponse: InternalAuthAndMrtdResponse) => void;
|
|
97
178
|
onAttributesSuccess: (attributes: CieAttributes) => void;
|
|
98
179
|
onSuccess: (uri: string) => void;
|
|
99
180
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,eAAe,+LAW1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;EAGnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,YAAY,uNAYvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;IAWnB,CAA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|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/manager/index.ts
CHANGED
|
@@ -120,6 +120,117 @@ const startInternalAuthentication = async (
|
|
|
120
120
|
);
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Initiates a PACE (Password Authenticated Connection Establishment) reading
|
|
125
|
+
* session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
|
|
126
|
+
* Access Number) to read the MRTD information.
|
|
127
|
+
*
|
|
128
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
129
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
130
|
+
* native events.
|
|
131
|
+
*
|
|
132
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
133
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
134
|
+
* string; validation (if any) occurs in the native layer.
|
|
135
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
136
|
+
* produced during the reading process. Defaults to
|
|
137
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
138
|
+
* hexadecimal representation.
|
|
139
|
+
* @param timeout Maximum time (in milliseconds) allowed for the PACE reading
|
|
140
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
141
|
+
* A larger value may be required on older devices or in
|
|
142
|
+
* environments with slower NFC interactions.
|
|
143
|
+
*
|
|
144
|
+
* @returns Promise that resolves when the reading process has started.
|
|
145
|
+
*
|
|
146
|
+
* @throws May reject with:
|
|
147
|
+
* - Invalid input (e.g., malformed CAN).
|
|
148
|
+
* - NFC subsystem unavailable or disabled.
|
|
149
|
+
* - Operation timeout exceeded.
|
|
150
|
+
* - Native module internal errors.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* await startPaceReading("123456"); // Uses base64 encoding and default timeout.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* await startPaceReading("654321", "hex", 15000);
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
160
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
161
|
+
*
|
|
162
|
+
* Once the MRTD reading with PACE flow has been initiated, a Promise resolves,
|
|
163
|
+
* while when the reading process produces data, the `'onSuccess'` event has been called.
|
|
164
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
165
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
166
|
+
*/
|
|
167
|
+
const startMRTDReading = async (
|
|
168
|
+
can: string,
|
|
169
|
+
resultEncoding: 'base64' | 'hex' = 'base64',
|
|
170
|
+
timeout: number = DEFAULT_TIMEOUT
|
|
171
|
+
): Promise<void> => {
|
|
172
|
+
return IoReactNativeCie.startMRTDReading(can, resultEncoding, timeout);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
|
|
177
|
+
* that performs both Internal Authentication and MRTD reading using PACE.
|
|
178
|
+
*
|
|
179
|
+
* The operation is asynchronous; Since the Promise resolves
|
|
180
|
+
* with `void`, any resulting data or errors are expected to be surfaced through
|
|
181
|
+
* native events.
|
|
182
|
+
*
|
|
183
|
+
* @param can The 6‑digit Card Access Number printed on the CIE, used to
|
|
184
|
+
* bootstrap the PACE secure messaging protocol. Must be a numeric
|
|
185
|
+
* string; validation (if any) occurs in the native layer.
|
|
186
|
+
* @param challenge The challenge string to be used for Internal Authentication.
|
|
187
|
+
* @param resultEncoding The encoding format expected for any binary payloads
|
|
188
|
+
* produced during the reading process. Defaults to
|
|
189
|
+
* `'base64'`. Use `'hex'` if downstream consumers require
|
|
190
|
+
* hexadecimal representation.
|
|
191
|
+
* @param timeout Maximum time (in milliseconds) allowed for the combined reading
|
|
192
|
+
* session before it is aborted. Defaults to `DEFAULT_TIMEOUT`.
|
|
193
|
+
* A larger value may be required on older devices or in
|
|
194
|
+
* environments with slower NFC interactions.
|
|
195
|
+
*
|
|
196
|
+
* @returns Promise that resolves when the reading process has started.
|
|
197
|
+
*
|
|
198
|
+
* @throws May reject with:
|
|
199
|
+
* - Invalid input (e.g., malformed CAN or challenge).
|
|
200
|
+
* - NFC subsystem unavailable or disabled.
|
|
201
|
+
* - Operation timeout exceeded.
|
|
202
|
+
* - Native module internal errors.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* await startInternalAuthAndMRTDReading("123456", "challengeString");
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* await startInternalAuthAndMRTDReading("654321", "challengeString", "hex", 15000);
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* Ensure NFC is enabled and the user has positioned the CIE correctly before
|
|
212
|
+
* calling this function to minimize timeouts and improve reliability.
|
|
213
|
+
*
|
|
214
|
+
* Once the Internal Authentication and MRTD reading with PACE flow has been initiated,
|
|
215
|
+
* a Promise resolves, while when the reading process produces data,
|
|
216
|
+
* the `'onSuccess'` event has been called.
|
|
217
|
+
* The `'onError'` event is called if an error occurs during the reading process.
|
|
218
|
+
* The `'onEvent'` event is called to provide progress updates.
|
|
219
|
+
*/
|
|
220
|
+
const startInternalAuthAndMRTDReading = async (
|
|
221
|
+
can: string,
|
|
222
|
+
challenge: string,
|
|
223
|
+
resultEncoding: 'base64' | 'hex' = 'base64',
|
|
224
|
+
timeout: number = DEFAULT_TIMEOUT
|
|
225
|
+
): Promise<void> => {
|
|
226
|
+
return IoReactNativeCie.startInternalAuthAndMRTDReading(
|
|
227
|
+
can,
|
|
228
|
+
challenge,
|
|
229
|
+
resultEncoding,
|
|
230
|
+
timeout
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
|
|
123
234
|
/**
|
|
124
235
|
* Starts the process of reading attributes from the CIE card.
|
|
125
236
|
*
|
|
@@ -185,6 +296,8 @@ export {
|
|
|
185
296
|
setCustomIdpUrl,
|
|
186
297
|
startReadingAttributes,
|
|
187
298
|
startInternalAuthentication,
|
|
299
|
+
startMRTDReading,
|
|
300
|
+
startInternalAuthAndMRTDReading,
|
|
188
301
|
startReading,
|
|
189
302
|
stopReading,
|
|
190
303
|
};
|
package/src/manager/types.ts
CHANGED
|
@@ -69,8 +69,8 @@ export const NfcError = z.union([
|
|
|
69
69
|
export type NfcError = z.infer<typeof NfcError>;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Represent the CIE
|
|
73
|
-
* All string value are Hex encoded
|
|
72
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
73
|
+
* All string value are Hex or Base64 encoded
|
|
74
74
|
*/
|
|
75
75
|
export const InternalAuthResponseObject = z.object({
|
|
76
76
|
nis: z.string(),
|
|
@@ -81,6 +81,41 @@ export const InternalAuthResponseObject = z.object({
|
|
|
81
81
|
|
|
82
82
|
export type InternalAuthResponse = z.infer<typeof InternalAuthResponseObject>;
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Represent the CIE response coming from MRTD with PACE reading
|
|
86
|
+
* All string value are Hex or Base64 encoded
|
|
87
|
+
*/
|
|
88
|
+
export const MrtdResponseObject = z.object({
|
|
89
|
+
dg1: z.string(),
|
|
90
|
+
dg11: z.string(),
|
|
91
|
+
sod: z.string(),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export type MrtdResponse = z.infer<typeof MrtdResponseObject>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Represent the CIE response coming from NIS Internal Auth
|
|
98
|
+
* and MRTD with PACE reading during the same NFC session.
|
|
99
|
+
* All string value are Hex or Base64 encoded
|
|
100
|
+
*/
|
|
101
|
+
export const InternalAuthAndMrtdResponse = z.object({
|
|
102
|
+
nis_data: z.object({
|
|
103
|
+
nis: z.string(),
|
|
104
|
+
publicKey: z.string(),
|
|
105
|
+
sod: z.string(),
|
|
106
|
+
signedChallenge: z.string(),
|
|
107
|
+
}),
|
|
108
|
+
mrtd_data: z.object({
|
|
109
|
+
dg1: z.string(),
|
|
110
|
+
dg11: z.string(),
|
|
111
|
+
sod: z.string(),
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export type InternalAuthAndMrtdResponse = z.infer<
|
|
116
|
+
typeof InternalAuthAndMrtdResponse
|
|
117
|
+
>;
|
|
118
|
+
|
|
84
119
|
/**
|
|
85
120
|
* Represent the CIE attributes containing the CIE type
|
|
86
121
|
*/
|
|
@@ -97,7 +132,13 @@ export type CieAttributes = z.infer<typeof CieAttributes>;
|
|
|
97
132
|
export type CieEventHandlers = {
|
|
98
133
|
onEvent: (event: NfcEvent) => void;
|
|
99
134
|
onError: (error: NfcError) => void;
|
|
100
|
-
onInternalAuthenticationSuccess: (
|
|
135
|
+
onInternalAuthenticationSuccess: (
|
|
136
|
+
internalAuthResponse: InternalAuthResponse
|
|
137
|
+
) => void;
|
|
138
|
+
onMRTDWithPaceSuccess: (mrtdResponse: MrtdResponse) => void;
|
|
139
|
+
onInternalAuthAndMRTDWithPaceSuccess: (
|
|
140
|
+
internalAuthAndMrtdResponse: InternalAuthAndMrtdResponse
|
|
141
|
+
) => void;
|
|
101
142
|
onAttributesSuccess: (attributes: CieAttributes) => void;
|
|
102
143
|
onSuccess: (uri: string) => void;
|
|
103
144
|
};
|