@pagopa/io-react-native-cie 1.2.1 → 1.2.3
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 +73 -23
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/pagopa/ioreactnativecie/IoReactNativeCieModule.kt +71 -3
- 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 +36 -0
- package/lib/module/manager/index.js +22 -2
- package/lib/module/manager/index.js.map +1 -1
- package/lib/module/manager/types.js +13 -12
- 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 +26 -4
- package/lib/typescript/src/manager/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/manager/index.ts +34 -5
- package/src/manager/types.ts +18 -11
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
|
|
|
@@ -322,6 +323,7 @@ List of error event that may be emitted during CIE reading process
|
|
|
322
323
|
| APDU_ERROR | Protocol error or not supported |
|
|
323
324
|
| CARD_BLOCKED | Too many PIN attempts, card is blocked |
|
|
324
325
|
| WRONG_PIN | Wrong PIN |
|
|
326
|
+
| WRONG_CAN | Wrong CAN |
|
|
325
327
|
| NO_INTERNET_CONNECTION | Missing internet connection |
|
|
326
328
|
| CERTIFICATE_EXPIRED | CIE expired |
|
|
327
329
|
| CERTIFICATE_REVOKED | CIE revoked |
|
|
@@ -396,6 +398,54 @@ type NfcError = {
|
|
|
396
398
|
|
|
397
399
|
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
400
|
|
|
401
|
+
```typescript
|
|
402
|
+
type InternalAuthResponse = {
|
|
403
|
+
nis: string,
|
|
404
|
+
publicKey: string,
|
|
405
|
+
sod: string,
|
|
406
|
+
signedChallenge: string,
|
|
407
|
+
});
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Represent the CIE response coming from NIS Internal Auth.
|
|
411
|
+
All string value are Hex, Base64 or Base64 url encoded
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
type MrtdResponse = {
|
|
415
|
+
dg1: string,
|
|
416
|
+
dg11: string,
|
|
417
|
+
sod: string,
|
|
418
|
+
});
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Represent the CIE response coming from MRTD with PACE reading
|
|
422
|
+
All string value are Hex, Base64 or Base64 url encoded.
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
type InternalAuthAndMrtdResponse = {
|
|
426
|
+
nis_data: {
|
|
427
|
+
nis: string,
|
|
428
|
+
publicKey: string,
|
|
429
|
+
sod: string,
|
|
430
|
+
signedChallenge: string,
|
|
431
|
+
},
|
|
432
|
+
mrtd_data: {
|
|
433
|
+
dg1: string,
|
|
434
|
+
dg11: string,
|
|
435
|
+
sod: string,
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Represent the CIE response coming from NIS Internal Auth and MRTD with PACE reading during the same NFC session.
|
|
441
|
+
All string value are Hex, Base64 or Base64 url encoded.
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
type ResultEncoding = 'hex' | 'base64' | 'base64url';
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Supported types of encoding for Internal Auth and Mrtd reponse payloads.
|
|
448
|
+
|
|
399
449
|
## Errors
|
|
400
450
|
|
|
401
451
|
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) :
|
|
@@ -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() {
|
|
@@ -420,6 +482,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
420
482
|
NfcError.APDU_ERROR -> ErrorType.APDU_ERROR
|
|
421
483
|
NfcError.EXTENDED_APDU_NOT_SUPPORTED -> ErrorType.APDU_ERROR
|
|
422
484
|
NfcError.WRONG_PIN -> ErrorType.WRONG_PIN
|
|
485
|
+
NfcError.WRONG_CAN -> ErrorType.WRONG_CAN
|
|
423
486
|
NfcError.PIN_BLOCKED -> ErrorType.CARD_BLOCKED
|
|
424
487
|
else -> ErrorType.GENERIC_ERROR
|
|
425
488
|
}
|
|
@@ -439,12 +502,14 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
439
502
|
const val NAME = "IoReactNativeCie"
|
|
440
503
|
|
|
441
504
|
enum class ResultEncoding(val value: String) {
|
|
505
|
+
HEX("hex"),
|
|
442
506
|
BASE64("base64"),
|
|
443
|
-
|
|
507
|
+
BASE64URL("base64url");
|
|
444
508
|
|
|
445
509
|
fun encode(data: ByteArray): String = when (this) {
|
|
446
|
-
BASE64 -> Base64.encodeToString(data, Base64.URL_SAFE or Base64.NO_WRAP)
|
|
447
510
|
HEX -> data.toHex().uppercase()
|
|
511
|
+
BASE64 -> Base64.encodeToString(data, Base64.DEFAULT or Base64.NO_WRAP)
|
|
512
|
+
BASE64URL -> Base64.encodeToString(data, Base64.URL_SAFE or Base64.NO_WRAP)
|
|
448
513
|
}
|
|
449
514
|
|
|
450
515
|
companion object {
|
|
@@ -452,6 +517,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
452
517
|
return when (value) {
|
|
453
518
|
"hex" -> HEX
|
|
454
519
|
"base64" -> BASE64
|
|
520
|
+
"base64url" -> BASE64URL
|
|
455
521
|
else -> BASE64 // Default
|
|
456
522
|
}
|
|
457
523
|
}
|
|
@@ -465,7 +531,8 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
465
531
|
INTERNAL_AUTHENTICATION_SUCCESS("onInternalAuthenticationSuccess"),
|
|
466
532
|
MRTD_WITH_PACE_SUCCESS("onMRTDWithPaceSuccess"),
|
|
467
533
|
INTERNAL_AUTH_AND_MRTD_WITH_PACE_SUCCESS("onInternalAuthAndMRTDWithPaceSuccess"),
|
|
468
|
-
SUCCESS("onSuccess")
|
|
534
|
+
SUCCESS("onSuccess"),
|
|
535
|
+
CERTIFICATE_SUCCESS("onCertificateSuccess")
|
|
469
536
|
}
|
|
470
537
|
|
|
471
538
|
enum class ErrorType {
|
|
@@ -473,6 +540,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
|
|
|
473
540
|
TAG_LOST,
|
|
474
541
|
APDU_ERROR,
|
|
475
542
|
WRONG_PIN,
|
|
543
|
+
WRONG_CAN,
|
|
476
544
|
CARD_BLOCKED,
|
|
477
545
|
NO_INTERNET_CONNECTION,
|
|
478
546
|
CERTIFICATE_EXPIRED,
|
|
@@ -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)
|
|
@@ -284,6 +316,8 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
284
316
|
payload = [ "name": ErrorType.APDU_ERROR.rawValue, "message": error.description ]
|
|
285
317
|
case .wrongPin(let attemptsLeft):
|
|
286
318
|
payload = [ "name":ErrorType.WRONG_PIN.rawValue, "message": error.description, "attemptsLeft": attemptsLeft ]
|
|
319
|
+
case .wrongCan:
|
|
320
|
+
payload = [ "name":ErrorType.WRONG_CAN.rawValue, "message": error.description ]
|
|
287
321
|
case .cardBlocked:
|
|
288
322
|
payload = [ "name": ErrorType.CARD_BLOCKED.rawValue, "message": error.description ]
|
|
289
323
|
case .sslError:
|
|
@@ -303,6 +337,7 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
303
337
|
case onMRTDWithPaceSuccess
|
|
304
338
|
case onInternalAuthAndMRTDWithPaceSuccess
|
|
305
339
|
case onSuccess
|
|
340
|
+
case onCertificateSuccess
|
|
306
341
|
}
|
|
307
342
|
|
|
308
343
|
private enum ErrorType: String, CaseIterable {
|
|
@@ -311,6 +346,7 @@ class IoReactNativeCie: RCTEventEmitter {
|
|
|
311
346
|
case CANCELLED_BY_USER
|
|
312
347
|
case APDU_ERROR
|
|
313
348
|
case WRONG_PIN
|
|
349
|
+
case WRONG_CAN
|
|
314
350
|
case CARD_BLOCKED
|
|
315
351
|
case NO_INTERNET_CONNECTION
|
|
316
352
|
case CERTIFICATE_EXPIRED
|
|
@@ -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":[]}
|
|
@@ -19,7 +19,7 @@ export const NfcEvent = z.object({
|
|
|
19
19
|
/**
|
|
20
20
|
* Name of the error emitted during the CIE reading process
|
|
21
21
|
*/
|
|
22
|
-
export const NfcErrorName = z.enum(['NOT_A_CIE', 'TAG_LOST', 'CANCELLED_BY_USER', 'APDU_ERROR', 'WRONG_PIN', 'CARD_BLOCKED', 'NO_INTERNET_CONNECTION', 'CERTIFICATE_EXPIRED', 'CERTIFICATE_REVOKED', 'AUTHENTICATION_ERROR', 'GENERIC_ERROR']);
|
|
22
|
+
export const NfcErrorName = z.enum(['NOT_A_CIE', 'TAG_LOST', 'CANCELLED_BY_USER', 'APDU_ERROR', 'WRONG_PIN', 'WRONG_CAN', 'CARD_BLOCKED', 'NO_INTERNET_CONNECTION', 'CERTIFICATE_EXPIRED', 'CERTIFICATE_REVOKED', 'AUTHENTICATION_ERROR', 'GENERIC_ERROR']);
|
|
23
23
|
/**
|
|
24
24
|
* Represent an NFC error emitted during the CIE reading process
|
|
25
25
|
*/
|
|
@@ -58,17 +58,8 @@ export const MrtdResponseObject = z.object({
|
|
|
58
58
|
* All string value are Hex or Base64 encoded
|
|
59
59
|
*/
|
|
60
60
|
export const InternalAuthAndMrtdResponse = z.object({
|
|
61
|
-
nis_data:
|
|
62
|
-
|
|
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
|
-
})
|
|
61
|
+
nis_data: InternalAuthResponseObject,
|
|
62
|
+
mrtd_data: MrtdResponseObject
|
|
72
63
|
});
|
|
73
64
|
/**
|
|
74
65
|
* Represent the CIE attributes containing the CIE type
|
|
@@ -77,6 +68,16 @@ export const CieAttributes = z.object({
|
|
|
77
68
|
type: z.string(),
|
|
78
69
|
base64: z.string()
|
|
79
70
|
});
|
|
71
|
+
export const CertificateData = z.object({
|
|
72
|
+
name: z.string().optional(),
|
|
73
|
+
surname: z.string().optional(),
|
|
74
|
+
fiscalCode: z.string().optional(),
|
|
75
|
+
docSerialNumber: z.string().optional()
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Possible encodings for the CIE reading results
|
|
80
|
+
*/
|
|
80
81
|
|
|
81
82
|
/**
|
|
82
83
|
* 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,CAAC;EAC/BC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,C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,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,
|
|
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":["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,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAChB,CAAC;AAIF;AACA;AACA;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AAa,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,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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;;;;;;GAeG;AACH,QAAA,MAAM,uBAAuB,GAC3B,KAAK,MAAM,EACX,UAAS,MAAwB,KAChC,OAAO,CAAC,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"}
|
|
@@ -24,19 +24,19 @@ export type NfcEvent = z.infer<typeof NfcEvent>;
|
|
|
24
24
|
/**
|
|
25
25
|
* Name of the error emitted during the CIE reading process
|
|
26
26
|
*/
|
|
27
|
-
export declare const NfcErrorName: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "WRONG_PIN", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
|
|
27
|
+
export declare const NfcErrorName: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "WRONG_PIN", "WRONG_CAN", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
|
|
28
28
|
export type NfcErrorName = z.infer<typeof NfcErrorName>;
|
|
29
29
|
/**
|
|
30
30
|
* Represent an NFC error emitted during the CIE reading process
|
|
31
31
|
*/
|
|
32
32
|
export declare const NfcError: z.ZodUnion<[z.ZodObject<{
|
|
33
|
-
name: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
|
|
33
|
+
name: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "WRONG_CAN", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
|
|
34
34
|
message: z.ZodOptional<z.ZodString>;
|
|
35
35
|
}, "strip", z.ZodTypeAny, {
|
|
36
|
-
name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
|
|
36
|
+
name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "WRONG_CAN" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
|
|
37
37
|
message?: string | undefined;
|
|
38
38
|
}, {
|
|
39
|
-
name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
|
|
39
|
+
name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "WRONG_CAN" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
|
|
40
40
|
message?: string | undefined;
|
|
41
41
|
}>, z.ZodObject<{
|
|
42
42
|
name: z.ZodEnum<["WRONG_PIN"]>;
|
|
@@ -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"],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AAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
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
|
@@ -40,6 +40,7 @@ export const NfcErrorName = z.enum([
|
|
|
40
40
|
'CANCELLED_BY_USER',
|
|
41
41
|
'APDU_ERROR',
|
|
42
42
|
'WRONG_PIN',
|
|
43
|
+
'WRONG_CAN',
|
|
43
44
|
'CARD_BLOCKED',
|
|
44
45
|
'NO_INTERNET_CONNECTION',
|
|
45
46
|
'CERTIFICATE_EXPIRED',
|
|
@@ -99,17 +100,8 @@ export type MrtdResponse = z.infer<typeof MrtdResponseObject>;
|
|
|
99
100
|
* All string value are Hex or Base64 encoded
|
|
100
101
|
*/
|
|
101
102
|
export const InternalAuthAndMrtdResponse = z.object({
|
|
102
|
-
nis_data:
|
|
103
|
-
|
|
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
|
-
}),
|
|
103
|
+
nis_data: InternalAuthResponseObject,
|
|
104
|
+
mrtd_data: MrtdResponseObject,
|
|
113
105
|
});
|
|
114
106
|
|
|
115
107
|
export type InternalAuthAndMrtdResponse = z.infer<
|
|
@@ -126,6 +118,20 @@ export const CieAttributes = z.object({
|
|
|
126
118
|
|
|
127
119
|
export type CieAttributes = z.infer<typeof CieAttributes>;
|
|
128
120
|
|
|
121
|
+
export const CertificateData = z.object({
|
|
122
|
+
name: z.string().optional(),
|
|
123
|
+
surname: z.string().optional(),
|
|
124
|
+
fiscalCode: z.string().optional(),
|
|
125
|
+
docSerialNumber: z.string().optional(),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export type CertificateData = z.infer<typeof CertificateData>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Possible encodings for the CIE reading results
|
|
132
|
+
*/
|
|
133
|
+
export type ResultEncoding = 'hex' | 'base64' | 'base64url';
|
|
134
|
+
|
|
129
135
|
/**
|
|
130
136
|
* Event handler that can be used to handle the CIE events during the reading process
|
|
131
137
|
*/
|
|
@@ -141,6 +147,7 @@ export type CieEventHandlers = {
|
|
|
141
147
|
) => void;
|
|
142
148
|
onAttributesSuccess: (attributes: CieAttributes) => void;
|
|
143
149
|
onSuccess: (uri: string) => void;
|
|
150
|
+
onCertificateSuccess: (certificateData: CertificateData) => void;
|
|
144
151
|
};
|
|
145
152
|
|
|
146
153
|
/**
|