@pagopa/io-react-native-cie 1.3.0-beta.1 → 1.3.0-experimental
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 +72 -23
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/pagopa/ioreactnativecie/IoReactNativeCieModule.kt +71 -5
- package/ios/Data/Data+StringRepresentations.swift +7 -0
- package/ios/Data/DataEncoding.swift +1 -0
- package/ios/IoReactNativeCie.mm +5 -0
- package/ios/IoReactNativeCie.swift +33 -0
- package/lib/module/manager/index.js +22 -2
- package/lib/module/manager/index.js.map +1 -1
- package/lib/module/manager/types.js +10 -0
- 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 +23 -6
- package/lib/typescript/src/manager/index.d.ts.map +1 -1
- package/lib/typescript/src/manager/types.d.ts +22 -0
- package/lib/typescript/src/manager/types.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/index.ts +1 -0
- package/src/manager/index.ts +34 -5
- package/src/manager/types.ts +15 -0
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.15"
|
|
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
|
@@ -73,14 +73,15 @@ More info in the [official Android documentation](https://developer.android.com/
|
|
|
73
73
|
<string>We need to use NFC</string>
|
|
74
74
|
```
|
|
75
75
|
[More info on Apple's doc](https://developer.apple.com/documentation/bundleresources/information-property-list/nfcreaderusagedescription?language=objc)
|
|
76
|
-
3. Add the required ISO7816 identifiers into your `info.plist
|
|
76
|
+
3. Add the required ISO7816 identifiers into your `info.plist`. **IMPORTART**: the NFC tags order is important!
|
|
77
77
|
```xml
|
|
78
78
|
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
|
|
79
79
|
<array>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
<string>A0000002471001</string>
|
|
81
|
+
<string>A0000000308000000009816001</string>
|
|
82
|
+
<string>A00000000039</string>
|
|
83
|
+
<string>A0000002472001</string>
|
|
84
|
+
<string>00000000000000</string>
|
|
84
85
|
</array>
|
|
85
86
|
```
|
|
86
87
|
[More info on Apple's doc](https://developer.apple.com/documentation/corenfc/nfciso7816tag).
|
|
@@ -97,24 +98,24 @@ To run the example app, follow the instructions in [example/README.md](./example
|
|
|
97
98
|
|
|
98
99
|
List of available functions
|
|
99
100
|
|
|
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, resultEncoding?:
|
|
113
|
-
| `startMRTDReading(can: string, resultEncoding?:
|
|
114
|
-
| `startInternalAuthAndMRTDReading(can: string, challenge: string, resultEncoding?:
|
|
115
|
-
| `startReadingAttributes(timeout: number)`
|
|
116
|
-
| `startReading(pin: string, authenticationUrl: string, timeout: number)`
|
|
117
|
-
| `stopReading()`
|
|
101
|
+
| Function | Return | Description |
|
|
102
|
+
| :------------------------------------------------------------------------------------------------------------------- | :----------------- | :----------------------------------------------------------------------------- |
|
|
103
|
+
| `hasNFCFeature()` | `Promise<boolean>` | (Android) Checks if the device supports NFC feature |
|
|
104
|
+
| `isNfcEnabled()` | `Promise<boolean>` | (Android) Checks if the NFC is currently enabled |
|
|
105
|
+
| `isCieAuthenticationSupported()` | `Promise<boolean>` | (Android) Checks if the device supports CIE autentication |
|
|
106
|
+
| `openNfcSettings()` | `Promise<void>` | (Android) Opens NFC system settings page |
|
|
107
|
+
| `addListener(event: CieEvent, listener: CieEventHandlers)` | `() => void` | Adds a NFC event listener and returns a function to unsubscribe from the event |
|
|
108
|
+
| `removeListener(event: CieEvent)` | `void` | Removes all listeners for the specified event |
|
|
109
|
+
| `removeAllListeners()` | `void` | Removes all registered listeners |
|
|
110
|
+
| `setCustomIdpUrl(url?: string)` | `void` | Updates IDP url, if `undefined` will use the default IDP url |
|
|
111
|
+
| `setAlertMessage(key: AlertMessageKey, value: string)` | `void` | (iOS) Updates iOS NFC modal alert message |
|
|
112
|
+
| `setCurrentAlertMessage(value: string)` | `void` | (iOS) Updates currently displayed iOS NFC modal alert message |
|
|
113
|
+
| `startInternalAuthentication(challenge: string, resultEncoding?: ResultEncoding, timeout?: number)` | `Promise<void>` | Start the CIE IAS/NIS Internal Authentication |
|
|
114
|
+
| `startMRTDReading(can: string, resultEncoding?: ResultEncoding, timeout?: number)` | `Promise<void>` | Start PACE MRTD reading (reads MRTD data using CAN) |
|
|
115
|
+
| `startInternalAuthAndMRTDReading(can: string, challenge: string, resultEncoding?: ResultEncoding, timeout?: number)` | `Promise<void>` | Start combined Internal Authentication + PACE MRTD reading |
|
|
116
|
+
| `startReadingAttributes(timeout: number)` | `Promise<void>` | Start the CIE attributes reading process |
|
|
117
|
+
| `startReading(pin: string, authenticationUrl: string, timeout: number)` | `Promise<void>` | Start the CIE reading process fro authentication |
|
|
118
|
+
| `stopReading()` | `Promise<void>` | (Android) Stops all reading process |
|
|
118
119
|
|
|
119
120
|
## Usage
|
|
120
121
|
|
|
@@ -396,6 +397,54 @@ type NfcError = {
|
|
|
396
397
|
|
|
397
398
|
Error event that may be sent during the CIE reading process. Contains the name of the error and an optional message. Error names and order may vary based on the platform.
|
|
398
399
|
|
|
400
|
+
```typescript
|
|
401
|
+
type InternalAuthResponse = {
|
|
402
|
+
nis: string,
|
|
403
|
+
publicKey: string,
|
|
404
|
+
sod: string,
|
|
405
|
+
signedChallenge: string,
|
|
406
|
+
});
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Represent the CIE response coming from NIS Internal Auth.
|
|
410
|
+
All string value are Hex, Base64 or Base64 url encoded
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
type MrtdResponse = {
|
|
414
|
+
dg1: string,
|
|
415
|
+
dg11: string,
|
|
416
|
+
sod: string,
|
|
417
|
+
});
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Represent the CIE response coming from MRTD with PACE reading
|
|
421
|
+
All string value are Hex, Base64 or Base64 url encoded.
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
type InternalAuthAndMrtdResponse = {
|
|
425
|
+
nis_data: {
|
|
426
|
+
nis: string,
|
|
427
|
+
publicKey: string,
|
|
428
|
+
sod: string,
|
|
429
|
+
signedChallenge: string,
|
|
430
|
+
},
|
|
431
|
+
mrtd_data: {
|
|
432
|
+
dg1: string,
|
|
433
|
+
dg11: string,
|
|
434
|
+
sod: string,
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Represent the CIE response coming from NIS Internal Auth and MRTD with PACE reading during the same NFC session.
|
|
440
|
+
All string value are Hex, Base64 or Base64 url encoded.
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
type ResultEncoding = 'hex' | 'base64' | 'base64url';
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Supported types of encoding for Internal Auth and Mrtd reponse payloads.
|
|
447
|
+
|
|
399
448
|
## Errors
|
|
400
449
|
|
|
401
450
|
The CIE reading function may throw exceptions if the reading process cannot be initiated. These exceptions indicate issues with input validation or system compatibility.
|
package/android/build.gradle
CHANGED
|
@@ -12,6 +12,7 @@ import it.pagopa.io.app.cie.CieLogger
|
|
|
12
12
|
import it.pagopa.io.app.cie.CieSDK
|
|
13
13
|
import it.pagopa.io.app.cie.IntAuthMRTDResponse
|
|
14
14
|
import it.pagopa.io.app.cie.NisAndPaceCallback
|
|
15
|
+
import it.pagopa.io.app.cie.cie.CertificateData
|
|
15
16
|
import it.pagopa.io.app.cie.cie.CieAtrCallback
|
|
16
17
|
import it.pagopa.io.app.cie.cie.NfcError
|
|
17
18
|
import it.pagopa.io.app.cie.cie.NfcEvent
|
|
@@ -23,6 +24,7 @@ import it.pagopa.io.app.cie.nis.NisCallback
|
|
|
23
24
|
import it.pagopa.io.app.cie.pace.MRTDResponse
|
|
24
25
|
import it.pagopa.io.app.cie.pace.PaceCallback
|
|
25
26
|
import it.pagopa.io.app.cie.toHex
|
|
27
|
+
import it.pagopa.io.app.cie.cie.CieCertificateDataCallback
|
|
26
28
|
import java.net.URL
|
|
27
29
|
|
|
28
30
|
class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
@@ -40,8 +42,8 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
40
42
|
* Lazy value ensures it is initialized with a valid activity when first used.
|
|
41
43
|
*/
|
|
42
44
|
val cieSdk: CieSDK by lazy {
|
|
43
|
-
CieSDK.withContext(
|
|
44
|
-
}
|
|
45
|
+
CieSDK.withContext(currentActivity)
|
|
46
|
+
}
|
|
45
47
|
|
|
46
48
|
@Suppress("unused")
|
|
47
49
|
@ReactMethod
|
|
@@ -407,6 +409,66 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
|
|
412
|
+
@Suppress("unused")
|
|
413
|
+
@ReactMethod
|
|
414
|
+
fun startReadingCertificate(
|
|
415
|
+
pin: String,
|
|
416
|
+
timeout: Int = 10000,
|
|
417
|
+
promise: Promise,
|
|
418
|
+
) {
|
|
419
|
+
try {
|
|
420
|
+
cieSdk.setPin(pin)
|
|
421
|
+
} catch (e: Exception) {
|
|
422
|
+
promise.reject(ModuleException.PIN_REGEX_NOT_VALID, e.message, e)
|
|
423
|
+
return
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
try {
|
|
427
|
+
cieSdk.startReadingCertificate(timeout, object : NfcEvents {
|
|
428
|
+
override fun event(event: NfcEvent) {
|
|
429
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
430
|
+
.emit(EventType.EVENT.value, WritableNativeMap().apply {
|
|
431
|
+
putString("name", event.name)
|
|
432
|
+
putDouble(
|
|
433
|
+
"progress", (event.numerator.toDouble() / NfcEvent.totalNumeratorEvent.toDouble())
|
|
434
|
+
)
|
|
435
|
+
})
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
override fun error(error: NfcError) {
|
|
439
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
440
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
441
|
+
putString("name", mapNfcError(error).name)
|
|
442
|
+
error.msg?.let { putString("msg", it) }
|
|
443
|
+
error.numberOfAttempts?.let { putInt("attemptsLeft", it) }
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
}
|
|
447
|
+
}, object : CieCertificateDataCallback {
|
|
448
|
+
override fun onSuccess(data: CertificateData) {
|
|
449
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
450
|
+
.emit(EventType.CERTIFICATE_SUCCESS.value, WritableNativeMap().apply {
|
|
451
|
+
putString("name", data.name)
|
|
452
|
+
putString("surname", data.surname)
|
|
453
|
+
putString("fiscalCode", data.fiscalCode)
|
|
454
|
+
putString("docSerialNumber", data.docSerialNumber)
|
|
455
|
+
})
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
override fun onError(error: NfcError) {
|
|
459
|
+
this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
460
|
+
.emit(EventType.ERROR.value, WritableNativeMap().apply {
|
|
461
|
+
putString("name", mapNfcError(error).name)
|
|
462
|
+
error.msg?.let { putString("message", it) }
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
promise.resolve(null)
|
|
467
|
+
} catch (e: Exception) {
|
|
468
|
+
promise.reject(ModuleException.UNKNOWN_EXCEPTION, e.message, e)
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
410
472
|
@Suppress("unused")
|
|
411
473
|
@ReactMethod
|
|
412
474
|
fun stopReading() {
|
|
@@ -439,12 +501,14 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
439
501
|
const val NAME = "IoReactNativeCie"
|
|
440
502
|
|
|
441
503
|
enum class ResultEncoding(val value: String) {
|
|
504
|
+
HEX("hex"),
|
|
442
505
|
BASE64("base64"),
|
|
443
|
-
|
|
506
|
+
BASE64URL("base64url");
|
|
444
507
|
|
|
445
508
|
fun encode(data: ByteArray): String = when (this) {
|
|
446
|
-
BASE64 -> Base64.encodeToString(data, Base64.URL_SAFE or Base64.NO_WRAP)
|
|
447
509
|
HEX -> data.toHex().uppercase()
|
|
510
|
+
BASE64 -> Base64.encodeToString(data, Base64.DEFAULT or Base64.NO_WRAP)
|
|
511
|
+
BASE64URL -> Base64.encodeToString(data, Base64.URL_SAFE or Base64.NO_WRAP)
|
|
448
512
|
}
|
|
449
513
|
|
|
450
514
|
companion object {
|
|
@@ -452,6 +516,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
452
516
|
return when (value) {
|
|
453
517
|
"hex" -> HEX
|
|
454
518
|
"base64" -> BASE64
|
|
519
|
+
"base64url" -> BASE64URL
|
|
455
520
|
else -> BASE64 // Default
|
|
456
521
|
}
|
|
457
522
|
}
|
|
@@ -465,7 +530,8 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
465
530
|
INTERNAL_AUTHENTICATION_SUCCESS("onInternalAuthenticationSuccess"),
|
|
466
531
|
MRTD_WITH_PACE_SUCCESS("onMRTDWithPaceSuccess"),
|
|
467
532
|
INTERNAL_AUTH_AND_MRTD_WITH_PACE_SUCCESS("onInternalAuthAndMRTDWithPaceSuccess"),
|
|
468
|
-
SUCCESS("onSuccess")
|
|
533
|
+
SUCCESS("onSuccess"),
|
|
534
|
+
CERTIFICATE_SUCCESS("onCertificateSuccess")
|
|
469
535
|
}
|
|
470
536
|
|
|
471
537
|
enum class ErrorType {
|
|
@@ -32,6 +32,11 @@ extension Array where Element == UInt8 {
|
|
|
32
32
|
return Data(self).toHexString()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/// Converts the byte array to a base64 encoded string.
|
|
36
|
+
func base64EncodedString() -> String {
|
|
37
|
+
return Data(self).base64EncodedString()
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
/// Converts the byte array to a base64url encoded string.
|
|
36
41
|
func base64UrlEncodedString() -> String {
|
|
37
42
|
return Data(self).base64UrlEncodedString()
|
|
@@ -42,6 +47,8 @@ extension Array where Element == UInt8 {
|
|
|
42
47
|
case .HEX:
|
|
43
48
|
return Data(self).toHexString()
|
|
44
49
|
case .BASE64:
|
|
50
|
+
return Data(self).base64EncodedString()
|
|
51
|
+
case .BASE64URL:
|
|
45
52
|
return Data(self).base64UrlEncodedString()
|
|
46
53
|
}
|
|
47
54
|
}
|
package/ios/IoReactNativeCie.mm
CHANGED
|
@@ -54,6 +54,11 @@ RCT_EXTERN_METHOD(startReading: (NSString)pin
|
|
|
54
54
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
55
55
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
56
56
|
|
|
57
|
+
RCT_EXTERN_METHOD(startReadingCertificate: (NSString)pin
|
|
58
|
+
withTimeout: (NSNumber)timeout
|
|
59
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
60
|
+
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
61
|
+
|
|
57
62
|
+ (BOOL)requiresMainQueueSetup
|
|
58
63
|
{
|
|
59
64
|
return NO;
|
|
@@ -260,6 +260,38 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
@objc func startReadingCertificate(
|
|
264
|
+
_ pin: String,
|
|
265
|
+
withTimeout timeout: Int,
|
|
266
|
+
withResolver resolve: @escaping RCTPromiseResolveBlock,
|
|
267
|
+
withRejecter reject: @escaping RCTPromiseRejectBlock
|
|
268
|
+
) {
|
|
269
|
+
Task { [weak self] in
|
|
270
|
+
guard let self = self else {
|
|
271
|
+
reject(ModuleException.threadingError.rawValue, "Failed to perform background operation, self was deallocated", nil)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
guard pin.count == 8, pin.allSatisfy(\.isNumber) else {
|
|
276
|
+
reject(ModuleException.invalidPin.rawValue, "Pin must be exactly 8 digits", nil)
|
|
277
|
+
return
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
do {
|
|
281
|
+
let data = try await self.cieSdk.performCertificate(withPin: pin, handleReadEvent)
|
|
282
|
+
self.sendEvent(
|
|
283
|
+
withName: EventType.onCertificateSuccess.rawValue, body: ["name": data.name, "surname": data.surname, "docSerialNumber": data.docSerialNumber, "fiscalCode": data.fiscalCode])
|
|
284
|
+
} catch {
|
|
285
|
+
guard let nfcDigitalIdError = error as? NfcDigitalIdError else {
|
|
286
|
+
reject(ModuleException.unexpected.rawValue, error.localizedDescription, error)
|
|
287
|
+
return
|
|
288
|
+
}
|
|
289
|
+
handleReadError(nfcDigitalIdError)
|
|
290
|
+
resolve(nil)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
263
295
|
func handleReadEvent(event: CieSDK.CieDigitalIdEvent, progress: Float) {
|
|
264
296
|
let payload: NSDictionary = ["name": "\(event)", "progress": progress]
|
|
265
297
|
self.sendEvent(withName: EventType.onEvent.rawValue, body: payload)
|
|
@@ -303,6 +335,7 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
303
335
|
case onMRTDWithPaceSuccess
|
|
304
336
|
case onInternalAuthAndMRTDWithPaceSuccess
|
|
305
337
|
case onSuccess
|
|
338
|
+
case onCertificateSuccess
|
|
306
339
|
}
|
|
307
340
|
|
|
308
341
|
private enum ErrorType: String, CaseIterable {
|
|
@@ -100,7 +100,7 @@ export const setCurrentAlertMessage = value => {
|
|
|
100
100
|
* Initiates the internal authentication process using the provided challenge and timeout.
|
|
101
101
|
*
|
|
102
102
|
* @param challenge - The challenge string to be used for authentication.
|
|
103
|
-
* @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
|
|
103
|
+
* @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
|
|
104
104
|
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
105
105
|
* @returns A promise that resolves when the authentication process has ended.
|
|
106
106
|
*/
|
|
@@ -241,6 +241,26 @@ const startReading = async (pin, authenticationUrl, timeout = DEFAULT_TIMEOUT) =
|
|
|
241
241
|
return IoReactNativeCie.startReading(pin, authenticationUrl, timeout);
|
|
242
242
|
};
|
|
243
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Starts the CIE certificate reading process.
|
|
246
|
+
* This method extracts the data from the CIE card certificate.
|
|
247
|
+
* Upon success, the `onCertificateSuccess` event is emitted with the certificate data.
|
|
248
|
+
*
|
|
249
|
+
* @param pin - The CIE card PIN code
|
|
250
|
+
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
251
|
+
* @returns Promise<void>
|
|
252
|
+
* @throws {CieError} If could not start reading for authentication
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* await CieManager.startReadingCertificate('12345678');
|
|
256
|
+
* // or with custom timeout
|
|
257
|
+
* await CieManager.startReadingCertificate('12345678', 20000);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
const startReadingCertificate = async (pin, timeout = DEFAULT_TIMEOUT) => {
|
|
261
|
+
return IoReactNativeCie.startReadingCertificate(pin, timeout);
|
|
262
|
+
};
|
|
263
|
+
|
|
244
264
|
/**
|
|
245
265
|
* Stops any ongoing CIE reading process.
|
|
246
266
|
*
|
|
@@ -256,5 +276,5 @@ const startReading = async (pin, authenticationUrl, timeout = DEFAULT_TIMEOUT) =
|
|
|
256
276
|
const stopReading = async () => {
|
|
257
277
|
return IoReactNativeCie.stopReading();
|
|
258
278
|
};
|
|
259
|
-
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading };
|
|
279
|
+
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, startReadingCertificate, stopReading };
|
|
260
280
|
//# 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","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;
|
|
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","startReadingCertificate","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,cAAW;AAO5C,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,cAA8B,GAAG,QAAQ,EACzCC,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,cAA8B,GAAG,QAAQ,EACzCC,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,cAA8B,GAAG,QAAQ,EACzCC,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;AACA;AACA;AACA;AACA,MAAMQ,uBAAuB,GAAG,MAAAA,CAC9BF,GAAW,EACXN,OAAe,GAAGlB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAAC4B,uBAAuB,CAACF,GAAG,EAAEN,OAAO,CAAC;AAC/D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMS,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAO7B,gBAAgB,CAAC6B,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACEzB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfa,sBAAsB,EACtBP,2BAA2B,EAC3BI,gBAAgB,EAChBE,+BAA+B,EAC/BE,YAAY,EACZG,uBAAuB,EACvBC,WAAW","ignoreList":[]}
|
|
@@ -77,6 +77,16 @@ export const CieAttributes = z.object({
|
|
|
77
77
|
type: z.string(),
|
|
78
78
|
base64: z.string()
|
|
79
79
|
});
|
|
80
|
+
export const CertificateData = z.object({
|
|
81
|
+
name: z.string().optional(),
|
|
82
|
+
surname: z.string().optional(),
|
|
83
|
+
fiscalCode: z.string().optional(),
|
|
84
|
+
docSerialNumber: z.string().optional()
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Possible encodings for the CIE reading results
|
|
89
|
+
*/
|
|
80
90
|
|
|
81
91
|
/**
|
|
82
92
|
* Event handler that can be used to handle the CIE events during the reading process
|
|
@@ -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","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,CAA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AACI,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;;
|
|
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","CertificateData","surname","fiscalCode","docSerialNumber"],"sourceRoot":"../../../src","sources":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EAChByB,MAAM,EAAE/B,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;AAIF,OAAO,MAAM0B,eAAe,GAAGhC,CAAC,CAACI,MAAM,CAAC;EACtCC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC,CAAC;EAC3BkB,OAAO,EAAEjC,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC,CAAC;EAC9BmB,UAAU,EAAElC,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC,CAAC;EACjCoB,eAAe,EAAEnC,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC;AACvC,CAAC,CAAC;;AAIF;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;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, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, } from './manager/types';
|
|
4
|
+
export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, ResultEncoding, } 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,EACR,oBAAoB,EACpB,YAAY,EACZ,2BAA2B,
|
|
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,EAC3B,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlertMessageKey, type CieEvent, type CieEventHandlers } from './types';
|
|
1
|
+
import { AlertMessageKey, type CieEvent, type CieEventHandlers, type ResultEncoding } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Adds a listener for a specific CIE event.
|
|
4
4
|
*
|
|
@@ -71,11 +71,11 @@ export declare const setCurrentAlertMessage: (value: string) => void;
|
|
|
71
71
|
* Initiates the internal authentication process using the provided challenge and timeout.
|
|
72
72
|
*
|
|
73
73
|
* @param challenge - The challenge string to be used for authentication.
|
|
74
|
-
* @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
|
|
74
|
+
* @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
|
|
75
75
|
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
76
76
|
* @returns A promise that resolves when the authentication process has ended.
|
|
77
77
|
*/
|
|
78
|
-
declare const startInternalAuthentication: (challenge: string, resultEncoding?:
|
|
78
|
+
declare const startInternalAuthentication: (challenge: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
|
|
79
79
|
/**
|
|
80
80
|
* Initiates a PACE (Password Authenticated Connection Establishment) reading
|
|
81
81
|
* session on a CIE (Carta d'Identità Elettronica) using the provided CAN (Card
|
|
@@ -120,7 +120,7 @@ declare const startInternalAuthentication: (challenge: string, resultEncoding?:
|
|
|
120
120
|
* The `'onError'` event is called if an error occurs during the reading process.
|
|
121
121
|
* The `'onEvent'` event is called to provide progress updates.
|
|
122
122
|
*/
|
|
123
|
-
declare const startMRTDReading: (can: string, resultEncoding?:
|
|
123
|
+
declare const startMRTDReading: (can: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
|
|
124
124
|
/**
|
|
125
125
|
* Initiates a combined reading session on a CIE (Carta d'Identità Elettronica)
|
|
126
126
|
* that performs both Internal Authentication and MRTD reading using PACE.
|
|
@@ -166,7 +166,7 @@ declare const startMRTDReading: (can: string, resultEncoding?: "base64" | "hex",
|
|
|
166
166
|
* The `'onError'` event is called if an error occurs during the reading process.
|
|
167
167
|
* The `'onEvent'` event is called to provide progress updates.
|
|
168
168
|
*/
|
|
169
|
-
declare const startInternalAuthAndMRTDReading: (can: string, challenge: string, resultEncoding?:
|
|
169
|
+
declare const startInternalAuthAndMRTDReading: (can: string, challenge: string, resultEncoding?: ResultEncoding, timeout?: number) => Promise<void>;
|
|
170
170
|
/**
|
|
171
171
|
* Starts the process of reading attributes from the CIE card.
|
|
172
172
|
*
|
|
@@ -197,6 +197,23 @@ declare const startReadingAttributes: (timeout?: number) => Promise<void>;
|
|
|
197
197
|
* ```
|
|
198
198
|
*/
|
|
199
199
|
declare const startReading: (pin: string, authenticationUrl: string, timeout?: number) => Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Starts the CIE certificate reading process.
|
|
202
|
+
* This method extracts the data from the CIE card certificate.
|
|
203
|
+
* Upon success, the `onCertificateSuccess` event is emitted with the certificate data.
|
|
204
|
+
*
|
|
205
|
+
* @param pin - The CIE card PIN code
|
|
206
|
+
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
207
|
+
* @returns Promise<void>
|
|
208
|
+
* @throws {CieError} If could not start reading for authentication
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* await CieManager.startReadingCertificate('12345678');
|
|
212
|
+
* // or with custom timeout
|
|
213
|
+
* await CieManager.startReadingCertificate('12345678', 20000);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
declare const startReadingCertificate: (pin: string, timeout?: number) => Promise<void>;
|
|
200
217
|
/**
|
|
201
218
|
* Stops any ongoing CIE reading process.
|
|
202
219
|
*
|
|
@@ -210,5 +227,5 @@ declare const startReading: (pin: string, authenticationUrl: string, timeout?: n
|
|
|
210
227
|
* ```
|
|
211
228
|
*/
|
|
212
229
|
declare const stopReading: () => Promise<void>;
|
|
213
|
-
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, stopReading, };
|
|
230
|
+
export { addListener, removeListener, removeAllListeners, setCustomIdpUrl, startReadingAttributes, startInternalAuthentication, startMRTDReading, startInternalAuthAndMRTDReading, startReading, startReadingCertificate, stopReading, };
|
|
214
231
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAOjB;;;;;;;;;;;;;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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AC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CAEzC,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,+BAA+B,EAC/B,YAAY,EACZ,uBAAuB,EACvB,WAAW,GACZ,CAAC"}
|
|
@@ -166,6 +166,27 @@ export declare const CieAttributes: z.ZodObject<{
|
|
|
166
166
|
base64: string;
|
|
167
167
|
}>;
|
|
168
168
|
export type CieAttributes = z.infer<typeof CieAttributes>;
|
|
169
|
+
export declare const CertificateData: z.ZodObject<{
|
|
170
|
+
name: z.ZodOptional<z.ZodString>;
|
|
171
|
+
surname: z.ZodOptional<z.ZodString>;
|
|
172
|
+
fiscalCode: z.ZodOptional<z.ZodString>;
|
|
173
|
+
docSerialNumber: z.ZodOptional<z.ZodString>;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
name?: string | undefined;
|
|
176
|
+
surname?: string | undefined;
|
|
177
|
+
fiscalCode?: string | undefined;
|
|
178
|
+
docSerialNumber?: string | undefined;
|
|
179
|
+
}, {
|
|
180
|
+
name?: string | undefined;
|
|
181
|
+
surname?: string | undefined;
|
|
182
|
+
fiscalCode?: string | undefined;
|
|
183
|
+
docSerialNumber?: string | undefined;
|
|
184
|
+
}>;
|
|
185
|
+
export type CertificateData = z.infer<typeof CertificateData>;
|
|
186
|
+
/**
|
|
187
|
+
* Possible encodings for the CIE reading results
|
|
188
|
+
*/
|
|
189
|
+
export type ResultEncoding = 'hex' | 'base64' | 'base64url';
|
|
169
190
|
/**
|
|
170
191
|
* Event handler that can be used to handle the CIE events during the reading process
|
|
171
192
|
*/
|
|
@@ -177,6 +198,7 @@ export type CieEventHandlers = {
|
|
|
177
198
|
onInternalAuthAndMRTDWithPaceSuccess: (internalAuthAndMrtdResponse: InternalAuthAndMrtdResponse) => void;
|
|
178
199
|
onAttributesSuccess: (attributes: CieAttributes) => void;
|
|
179
200
|
onSuccess: (uri: string) => void;
|
|
201
|
+
onCertificateSuccess: (certificateData: CertificateData) => void;
|
|
180
202
|
};
|
|
181
203
|
/**
|
|
182
204
|
* Possible events that can be listened to
|
|
@@ -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,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,2BAA2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AC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnC,+BAA+B,EAAE,CAC/B,oBAAoB,EAAE,oBAAoB,KACvC,IAAI,CAAC;IACV,qBAAqB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5D,oCAAoC,EAAE,CACpC,2BAA2B,EAAE,2BAA2B,KACrD,IAAI,CAAC;IACV,mBAAmB,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAC;IACzD,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,oBAAoB,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-react-native-cie",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-experimental",
|
|
4
4
|
"description": "Native support for CIE",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -59,10 +59,6 @@
|
|
|
59
59
|
"registry": "https://registry.npmjs.org/"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "^7.28.4",
|
|
63
|
-
"@babel/preset-env": "^7.28.3",
|
|
64
|
-
"@babel/preset-flow": "^7.27.1",
|
|
65
|
-
"@babel/preset-typescript": "^7.27.1",
|
|
66
62
|
"@commitlint/config-conventional": "^19.6.0",
|
|
67
63
|
"@eslint/compat": "^1.2.7",
|
|
68
64
|
"@eslint/eslintrc": "^3.3.0",
|
|
@@ -70,8 +66,6 @@
|
|
|
70
66
|
"@evilmartians/lefthook": "^1.5.0",
|
|
71
67
|
"@react-native/eslint-config": "^0.78.0",
|
|
72
68
|
"@release-it/conventional-changelog": "^9.0.2",
|
|
73
|
-
"@types/babel__core": "^7",
|
|
74
|
-
"@types/babel__preset-env": "^7",
|
|
75
69
|
"@types/jest": "^29.5.5",
|
|
76
70
|
"@types/react": "^19.0.0",
|
|
77
71
|
"commitlint": "^19.6.1",
|
|
@@ -79,25 +73,31 @@
|
|
|
79
73
|
"eslint": "^9.22.0",
|
|
80
74
|
"eslint-config-prettier": "^10.1.1",
|
|
81
75
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
82
|
-
"eslint-plugin-ft-flow": "^3.0.11",
|
|
83
76
|
"eslint-plugin-prettier": "^5.2.3",
|
|
84
77
|
"jest": "^29.7.0",
|
|
85
78
|
"prettier": "^3.0.3",
|
|
86
|
-
"react": "19.
|
|
87
|
-
"react-native": "0.
|
|
79
|
+
"react": "19.0.0",
|
|
80
|
+
"react-native": "0.78.2",
|
|
88
81
|
"react-native-builder-bob": "^0.40.6",
|
|
89
82
|
"release-it": "^17.10.0",
|
|
90
83
|
"turbo": "^1.10.7",
|
|
91
84
|
"typescript": "^5.2.2"
|
|
92
85
|
},
|
|
93
86
|
"peerDependencies": {
|
|
94
|
-
"react": "
|
|
95
|
-
"react-native": "
|
|
87
|
+
"react": "*",
|
|
88
|
+
"react-native": "*"
|
|
96
89
|
},
|
|
97
90
|
"workspaces": [
|
|
98
91
|
"example"
|
|
99
92
|
],
|
|
100
93
|
"packageManager": "yarn@3.6.1",
|
|
94
|
+
"jest": {
|
|
95
|
+
"preset": "react-native",
|
|
96
|
+
"modulePathIgnorePatterns": [
|
|
97
|
+
"<rootDir>/example/node_modules",
|
|
98
|
+
"<rootDir>/lib/"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
101
|
"commitlint": {
|
|
102
102
|
"extends": [
|
|
103
103
|
"@commitlint/config-conventional"
|
package/src/index.ts
CHANGED
package/src/manager/index.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import { IoReactNativeCie } from '../native';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AlertMessageKey,
|
|
5
|
+
type CieEvent,
|
|
6
|
+
type CieEventHandlers,
|
|
7
|
+
type ResultEncoding,
|
|
8
|
+
} from './types';
|
|
4
9
|
import { getDefaultIdpUrl } from './utils';
|
|
5
10
|
|
|
6
11
|
const DEFAULT_TIMEOUT = 10000;
|
|
@@ -104,13 +109,13 @@ export const setCurrentAlertMessage = (value: string) => {
|
|
|
104
109
|
* Initiates the internal authentication process using the provided challenge and timeout.
|
|
105
110
|
*
|
|
106
111
|
* @param challenge - The challenge string to be used for authentication.
|
|
107
|
-
* @param resultEncoding - The encoding of the result byte arrays, either 'base64' or 'hex' (default: 'base64')
|
|
112
|
+
* @param resultEncoding - The encoding of the result byte arrays, either 'base64', 'base64url' or 'hex' (default: 'base64')
|
|
108
113
|
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
109
114
|
* @returns A promise that resolves when the authentication process has ended.
|
|
110
115
|
*/
|
|
111
116
|
const startInternalAuthentication = async (
|
|
112
117
|
challenge: string,
|
|
113
|
-
resultEncoding:
|
|
118
|
+
resultEncoding: ResultEncoding = 'base64',
|
|
114
119
|
timeout: number = DEFAULT_TIMEOUT
|
|
115
120
|
): Promise<void> => {
|
|
116
121
|
return IoReactNativeCie.startInternalAuthentication(
|
|
@@ -166,7 +171,7 @@ const startInternalAuthentication = async (
|
|
|
166
171
|
*/
|
|
167
172
|
const startMRTDReading = async (
|
|
168
173
|
can: string,
|
|
169
|
-
resultEncoding:
|
|
174
|
+
resultEncoding: ResultEncoding = 'base64',
|
|
170
175
|
timeout: number = DEFAULT_TIMEOUT
|
|
171
176
|
): Promise<void> => {
|
|
172
177
|
return IoReactNativeCie.startMRTDReading(can, resultEncoding, timeout);
|
|
@@ -220,7 +225,7 @@ const startMRTDReading = async (
|
|
|
220
225
|
const startInternalAuthAndMRTDReading = async (
|
|
221
226
|
can: string,
|
|
222
227
|
challenge: string,
|
|
223
|
-
resultEncoding:
|
|
228
|
+
resultEncoding: ResultEncoding = 'base64',
|
|
224
229
|
timeout: number = DEFAULT_TIMEOUT
|
|
225
230
|
): Promise<void> => {
|
|
226
231
|
return IoReactNativeCie.startInternalAuthAndMRTDReading(
|
|
@@ -273,6 +278,29 @@ const startReading = async (
|
|
|
273
278
|
return IoReactNativeCie.startReading(pin, authenticationUrl, timeout);
|
|
274
279
|
};
|
|
275
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Starts the CIE certificate reading process.
|
|
283
|
+
* This method extracts the data from the CIE card certificate.
|
|
284
|
+
* Upon success, the `onCertificateSuccess` event is emitted with the certificate data.
|
|
285
|
+
*
|
|
286
|
+
* @param pin - The CIE card PIN code
|
|
287
|
+
* @param timeout - Optional timeout in milliseconds (default: 10000) (**Note**: Android only)
|
|
288
|
+
* @returns Promise<void>
|
|
289
|
+
* @throws {CieError} If could not start reading for authentication
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* await CieManager.startReadingCertificate('12345678');
|
|
293
|
+
* // or with custom timeout
|
|
294
|
+
* await CieManager.startReadingCertificate('12345678', 20000);
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
const startReadingCertificate = async (
|
|
298
|
+
pin: string,
|
|
299
|
+
timeout: number = DEFAULT_TIMEOUT
|
|
300
|
+
): Promise<void> => {
|
|
301
|
+
return IoReactNativeCie.startReadingCertificate(pin, timeout);
|
|
302
|
+
};
|
|
303
|
+
|
|
276
304
|
/**
|
|
277
305
|
* Stops any ongoing CIE reading process.
|
|
278
306
|
*
|
|
@@ -299,5 +327,6 @@ export {
|
|
|
299
327
|
startMRTDReading,
|
|
300
328
|
startInternalAuthAndMRTDReading,
|
|
301
329
|
startReading,
|
|
330
|
+
startReadingCertificate,
|
|
302
331
|
stopReading,
|
|
303
332
|
};
|
package/src/manager/types.ts
CHANGED
|
@@ -126,6 +126,20 @@ export const CieAttributes = z.object({
|
|
|
126
126
|
|
|
127
127
|
export type CieAttributes = z.infer<typeof CieAttributes>;
|
|
128
128
|
|
|
129
|
+
export const CertificateData = z.object({
|
|
130
|
+
name: z.string().optional(),
|
|
131
|
+
surname: z.string().optional(),
|
|
132
|
+
fiscalCode: z.string().optional(),
|
|
133
|
+
docSerialNumber: z.string().optional(),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export type CertificateData = z.infer<typeof CertificateData>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Possible encodings for the CIE reading results
|
|
140
|
+
*/
|
|
141
|
+
export type ResultEncoding = 'hex' | 'base64' | 'base64url';
|
|
142
|
+
|
|
129
143
|
/**
|
|
130
144
|
* Event handler that can be used to handle the CIE events during the reading process
|
|
131
145
|
*/
|
|
@@ -141,6 +155,7 @@ export type CieEventHandlers = {
|
|
|
141
155
|
) => void;
|
|
142
156
|
onAttributesSuccess: (attributes: CieAttributes) => void;
|
|
143
157
|
onSuccess: (uri: string) => void;
|
|
158
|
+
onCertificateSuccess: (certificateData: CertificateData) => void;
|
|
144
159
|
};
|
|
145
160
|
|
|
146
161
|
/**
|