@pagopa/io-react-native-cie 1.3.2 → 1.3.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.
@@ -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.17"
19
+ s.dependency "CieSDK", "~> 0.1.19"
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
@@ -15,6 +15,7 @@ Module to handle CIE (Electronic Identity Card) operations natively in React Nat
15
15
  - [API](#api)
16
16
  - [Usage](#usage)
17
17
  - [Check NFC Status](#check-nfc-status)
18
+ - [Logs](#logs)
18
19
  - [Reading CIE Data](#reading-cie-data)
19
20
  - [Reading Attributes](#reading-attributes)
20
21
  - [Authentication](#authentication)
@@ -116,13 +117,17 @@ List of available functions
116
117
  | `startReadingAttributes(timeout: number)` | `Promise<void>` | Start the CIE attributes reading process |
117
118
  | `startReading(pin: string, authenticationUrl: string, timeout: number)` | `Promise<void>` | Start the CIE reading process fro authentication |
118
119
  | `stopReading()` | `Promise<void>` | (Android) Stops all reading process |
120
+ | `setLogMode(mode: LogMode)` | `void` | (iOS) Sets the log mode for the CIE SDK |
121
+ | `getLogsFilePath()` | `Promise<string>` | (iOS) Returns file path of CIE SDK logs |
122
+ | `getLogs()` | `Promise<string>` | (iOS) Returns content of CIE SDK logs |
119
123
 
120
124
  ## Usage
121
125
 
122
- The package is split into two modules:
126
+ The package is split into three modules:
123
127
 
124
128
  - [CieUtils](/src/utils): Provides functions to check the NFC status of the device.
125
129
  - [CieManager](/src/manager): Provides CIE read and authentication capabilities.
130
+ - [CieLogger](/src/logger): Provides logging utils
126
131
 
127
132
  ### Check NFC Status
128
133
 
@@ -139,6 +144,29 @@ await CieUtils.isNfcEnabled();
139
144
  await CieUtils.isCieAuthenticationSupported();
140
145
  ```
141
146
 
147
+ ### Logs
148
+
149
+ **Note:** Logging is only supported on iOS. On Android, these methods will throw an error.
150
+
151
+ ```typescript
152
+ import { CieLogger } from '@pagopa/io-react-native-cie';
153
+
154
+ // Enable logging to local file
155
+ CieLogger.setLogMode('localFile');
156
+
157
+ // Enable logging to console
158
+ CieLogger.setLogMode('console');
159
+
160
+ // Disable logging
161
+ CieLogger.setLogMode('disabled');
162
+
163
+ // Get logs file path
164
+ const path = await CieLogger.getLogsFilePath();
165
+
166
+ // Get logs content
167
+ const logs = await CieLogger.getLogs();
168
+ ```
169
+
142
170
  ### Reading CIE Data
143
171
 
144
172
  #### Internal Authentication
@@ -447,17 +475,39 @@ type ResultEncoding = 'hex' | 'base64' | 'base64url';
447
475
 
448
476
  Supported types of encoding for Internal Auth and Mrtd reponse payloads.
449
477
 
478
+ ```typescript
479
+ type LogMode = 'localFile' | 'console' | 'disabled';
480
+ ```
481
+
482
+ Log mode for the CIE SDK:
483
+
484
+ - `localFile`: Logs saved to device for later retrieval
485
+ - `console`: Logs output to console for real-time monitoring
486
+ - `disabled`: Disables all logging
487
+
488
+ ```typescript
489
+ type CertificateData = {
490
+ name?: string;
491
+ surname?: string;
492
+ fiscalCode?: string;
493
+ docSerialNumber?: string;
494
+ };
495
+ ```
496
+
497
+ Contains CIE certificate data read from the card.
498
+
450
499
  ## Errors
451
500
 
452
501
  The CIE reading function may throw exceptions if the reading process cannot be initiated. These exceptions indicate issues with input validation or system compatibility.
453
502
  Below is a comprehensive list of possible exceptions that may be thrown during initialization:
454
503
 
455
- | Error Code | Platform | Description |
456
- | --------------------- | ----------- | ----------------------- |
457
- | `PIN_REGEX_NOT_VALID` | ios/Android | Invalid PIN format |
458
- | `INVALID_AUTH_URL` | ios/Android | Invalid auth url format |
459
- | `THREADING_ERROR` | iOS | Unexpected error |
460
- | `UNKNOWN_EXCEPTION` | iOS/Android | Unexpected error |
504
+ | Error Code | Platform | Description |
505
+ | --------------------- | ----------- | --------------------------------- |
506
+ | `PIN_REGEX_NOT_VALID` | iOS/Android | Invalid PIN format |
507
+ | `INVALID_AUTH_URL` | iOS/Android | Invalid auth url format |
508
+ | `THREADING_ERROR` | iOS | Unexpected error |
509
+ | `UNSUPPORTED` | Android | Feature not supported on platform |
510
+ | `UNKNOWN_EXCEPTION` | iOS/Android | Unexpected error |
461
511
 
462
512
  ## Contributing
463
513
 
@@ -78,6 +78,6 @@ dependencies {
78
78
  implementation "com.facebook.react:react-android"
79
79
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
80
80
  // CIE SDK
81
- implementation "it.pagopa.io.app.cie:cie:0.1.9"
81
+ implementation "it.pagopa.io.app.cie:cie:0.1.10"
82
82
  }
83
83
 
@@ -149,7 +149,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
149
149
  ) {
150
150
  val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
151
151
  try {
152
- cieSdk.startReadingNis(challenge, timeout, object : NfcEvents {
152
+ cieSdk.startReadingNis(challenge, timeout, true, object : NfcEvents {
153
153
  override fun event(event: NfcEvent) {
154
154
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
155
155
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -204,7 +204,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
204
204
  ) {
205
205
  val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
206
206
  try {
207
- cieSdk.startDoPace(can, timeout, object : NfcEvents {
207
+ cieSdk.startDoPace(can, timeout, true, object : NfcEvents {
208
208
  override fun event(event: NfcEvent) {
209
209
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
210
210
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -259,7 +259,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
259
259
  ) {
260
260
  val encoding: ResultEncoding = ResultEncoding.fromString(resultEncoding)
261
261
  try {
262
- cieSdk.startNisAndPace(challenge, can, timeout, object : NfcEvents {
262
+ cieSdk.startNisAndPace(challenge, can, timeout, true, object : NfcEvents {
263
263
  override fun event(event: NfcEvent) {
264
264
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
265
265
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -326,7 +326,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
326
326
  promise: Promise,
327
327
  ) {
328
328
  try {
329
- cieSdk.startReadingCieAtr(timeout, object : NfcEvents {
329
+ cieSdk.startReadingCieAtr(timeout, true, object : NfcEvents {
330
330
  override fun event(event: NfcEvent) {
331
331
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
332
332
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -392,7 +392,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
392
392
  }
393
393
 
394
394
  try {
395
- cieSdk.startReading(timeout, object : NfcEvents {
395
+ cieSdk.startReading(timeout, true, object : NfcEvents {
396
396
  override fun event(event: NfcEvent) {
397
397
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
398
398
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -447,7 +447,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
447
447
  }
448
448
 
449
449
  try {
450
- cieSdk.startReadingCertificate(timeout, object : NfcEvents {
450
+ cieSdk.startReadingCertificate(timeout, true, object : NfcEvents {
451
451
  override fun event(event: NfcEvent) {
452
452
  this@IoReactNativeCieModule.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
453
453
  .emit(EventType.EVENT.value, WritableNativeMap().apply {
@@ -492,6 +492,24 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
492
492
  }
493
493
  }
494
494
 
495
+ @Suppress("unused")
496
+ @ReactMethod
497
+ fun setLogMode(mode: String, promise: Promise) {
498
+ promise.reject(ModuleException.UNSUPPORTED, "Logging is not supported on Android", null)
499
+ }
500
+
501
+ @Suppress("unused")
502
+ @ReactMethod
503
+ fun getLogsFilePath(promise: Promise) {
504
+ promise.reject(ModuleException.UNSUPPORTED, "Logging is not supported on Android", null)
505
+ }
506
+
507
+ @Suppress("unused")
508
+ @ReactMethod
509
+ fun getLogs(promise: Promise) {
510
+ promise.reject(ModuleException.UNSUPPORTED, "Logging is not supported on Android", null)
511
+ }
512
+
495
513
  @Suppress("unused")
496
514
  @ReactMethod
497
515
  fun stopReading() {
@@ -576,6 +594,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
576
594
  const val PIN_REGEX_NOT_VALID = "PIN_REGEX_NOT_VALID"
577
595
  const val INVALID_AUTH_URL = "INVALID_AUTH_URL"
578
596
  const val UNKNOWN_EXCEPTION = "UNKNOWN_EXCEPTION"
597
+ const val UNSUPPORTED = "UNSUPPORTED"
579
598
  }
580
599
  }
581
600
  }
@@ -59,6 +59,14 @@ RCT_EXTERN_METHOD(startReadingCertificate: (NSString)pin
59
59
  withResolver: (RCTPromiseResolveBlock)resolve
60
60
  withRejecter: (RCTPromiseRejectBlock)reject)
61
61
 
62
+ RCT_EXTERN_METHOD(setLogMode: (NSString)mode)
63
+
64
+ RCT_EXTERN_METHOD(getLogsFilePath: (RCTPromiseResolveBlock)resolve
65
+ withRejecter: (RCTPromiseRejectBlock)reject)
66
+
67
+ RCT_EXTERN_METHOD(getLogs: (RCTPromiseResolveBlock)resolve
68
+ withRejecter: (RCTPromiseRejectBlock)reject)
69
+
62
70
  + (BOOL)requiresMainQueueSetup
63
71
  {
64
72
  return NO;
@@ -6,11 +6,7 @@ class IoReactNativeCie: RCTEventEmitter {
6
6
  private let cieSdk: CieDigitalId
7
7
 
8
8
  override init() {
9
- #if DEBUG
10
- self.cieSdk = CieDigitalId.init(.console)
11
- #else
12
9
  self.cieSdk = CieDigitalId.init()
13
- #endif
14
10
  super.init()
15
11
  }
16
12
 
@@ -292,6 +288,33 @@ class IoReactNativeCie: RCTEventEmitter {
292
288
  }
293
289
  }
294
290
 
291
+ @objc func setLogMode(_ mode: NSString) {
292
+ let logMode = CieDigitalId.LogMode(rawValue: mode as String) ?? .disabled
293
+ cieSdk.setLogMode(logMode)
294
+ }
295
+
296
+ @objc func getLogsFilePath(
297
+ _ resolve: RCTPromiseResolveBlock,
298
+ withRejecter reject: RCTPromiseRejectBlock
299
+ ) {
300
+ if let fileUrl = CieDigitalId.retriveLastLogFilePath() {
301
+ resolve(fileUrl)
302
+ } else {
303
+ reject(ModuleException.unexpected.rawValue, "Failed to retrieve last log file path", nil)
304
+ }
305
+ }
306
+
307
+ @objc func getLogs(
308
+ _ resolve: RCTPromiseResolveBlock,
309
+ withRejecter reject: RCTPromiseRejectBlock
310
+ ) {
311
+ if let logs = CieDigitalId.retriveLastLogFile() {
312
+ resolve(logs)
313
+ } else {
314
+ reject(ModuleException.unexpected.rawValue, "Failed to retrieve last log", nil)
315
+ }
316
+ }
317
+
295
318
  func handleReadEvent(event: CieSDK.CieDigitalIdEvent, progress: Float) {
296
319
  let payload: NSDictionary = ["name": "\(event)", "progress": progress]
297
320
  self.sendEvent(withName: EventType.onEvent.rawValue, body: payload)
@@ -34,7 +34,7 @@ const ModuleErrorIosSchema = z.object({
34
34
  */
35
35
  const ModuleErrorCodesSchema = z.enum(['PIN_REGEX_NOT_VALID', 'INVALID_AUTH_URL', 'THREADING_ERROR',
36
36
  // iOS only
37
- 'UNKNOWN_EXCEPTION']);
37
+ 'UNSUPPORTED', 'UNKNOWN_EXCEPTION']);
38
38
  /**
39
39
  * Schema which can be used to parse a rejected promise error the module.
40
40
  * This schema contains the common parameters that are shared across both Android and iOS native modules.
@@ -1 +1 @@
1
- {"version":3,"names":["z","StackTraceElementSchema","object","lineNumber","number","file","string","methodName","class","ModuleErrorAndroidSchema","nativeStackAndroid","array","partial","ModuleErrorIosSchema","domain","nativeStackIOS","ModuleErrorCodesSchema","enum","CieErrorSchema","code","message","name","userInfo","record","any","optional","or","null","and"],"sourceRoot":"../../src","sources":["errors.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACvCC,UAAU,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACtBC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,UAAU,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EACtBE,KAAK,EAAER,CAAC,CAACM,MAAM,CAAC;AAClB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,MAAMG,wBAAwB,GAAGT,CAAC,CAC/BE,MAAM,CAAC;EACNQ,kBAAkB,EAAEV,CAAC,CAACW,KAAK,CAACV,uBAAuB;AACrD,CAAC,CAAC,CACDW,OAAO,CAAC,CAAC;;AAEZ;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGb,CAAC,CAC3BE,MAAM,CAAC;EACNY,MAAM,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC;EAClBS,cAAc,EAAEf,CAAC,CAACW,KAAK,CAACX,CAAC,CAACM,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC,CACDM,OAAO,CAAC,CAAC;;AAEZ;AACA;AACA;AACA,MAAMI,sBAAsB,GAAGhB,CAAC,CAACiB,IAAI,CAAC,CACpC,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB;AAAE;AACnB,mBAAmB,CACpB,CAAC;AAIF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,cAAc,GAAGlB,CAAC,CAC5BE,MAAM,CAAC;EACNiB,IAAI,EAAEH,sBAAsB;EAC5BI,OAAO,EAAEpB,CAAC,CAACM,MAAM,CAAC,CAAC;EACnBe,IAAI,EAAErB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBgB,QAAQ,EAAEtB,CAAC,CAACuB,MAAM,CAACvB,CAAC,CAACM,MAAM,CAAC,CAAC,EAAEN,CAAC,CAACwB,GAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,EAAE,CAAC1B,CAAC,CAAC2B,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC,CACDC,GAAG,CAACnB,wBAAwB,CAAC,CAC7BmB,GAAG,CAACf,oBAAoB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["z","StackTraceElementSchema","object","lineNumber","number","file","string","methodName","class","ModuleErrorAndroidSchema","nativeStackAndroid","array","partial","ModuleErrorIosSchema","domain","nativeStackIOS","ModuleErrorCodesSchema","enum","CieErrorSchema","code","message","name","userInfo","record","any","optional","or","null","and"],"sourceRoot":"../../src","sources":["errors.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACvCC,UAAU,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACtBC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,UAAU,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EACtBE,KAAK,EAAER,CAAC,CAACM,MAAM,CAAC;AAClB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,MAAMG,wBAAwB,GAAGT,CAAC,CAC/BE,MAAM,CAAC;EACNQ,kBAAkB,EAAEV,CAAC,CAACW,KAAK,CAACV,uBAAuB;AACrD,CAAC,CAAC,CACDW,OAAO,CAAC,CAAC;;AAEZ;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGb,CAAC,CAC3BE,MAAM,CAAC;EACNY,MAAM,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC;EAClBS,cAAc,EAAEf,CAAC,CAACW,KAAK,CAACX,CAAC,CAACM,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC,CACDM,OAAO,CAAC,CAAC;;AAEZ;AACA;AACA;AACA,MAAMI,sBAAsB,GAAGhB,CAAC,CAACiB,IAAI,CAAC,CACpC,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB;AAAE;AACnB,aAAa,EACb,mBAAmB,CACpB,CAAC;AAIF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,cAAc,GAAGlB,CAAC,CAC5BE,MAAM,CAAC;EACNiB,IAAI,EAAEH,sBAAsB;EAC5BI,OAAO,EAAEpB,CAAC,CAACM,MAAM,CAAC,CAAC;EACnBe,IAAI,EAAErB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBgB,QAAQ,EAAEtB,CAAC,CAACuB,MAAM,CAACvB,CAAC,CAACM,MAAM,CAAC,CAAC,EAAEN,CAAC,CAACwB,GAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,EAAE,CAAC1B,CAAC,CAAC2B,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC,CACDC,GAAG,CAACnB,wBAAwB,CAAC,CAC7BmB,GAAG,CAACf,oBAAoB,CAAC","ignoreList":[]}
@@ -2,5 +2,6 @@
2
2
 
3
3
  import * as CieUtils from "./utils/index.js";
4
4
  import * as CieManager from "./manager/index.js";
5
- export { CieUtils, CieManager };
5
+ import * as CieLogger from "./logger/index.js";
6
+ export { CieUtils, CieManager, CieLogger };
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CieUtils","CieManager"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAO,KAAKA,QAAQ,MAAM,kBAAS;AACnC,OAAO,KAAKC,UAAU,MAAM,oBAAW;AAEvC,SAASD,QAAQ,EAAEC,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["CieUtils","CieManager","CieLogger"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAO,KAAKA,QAAQ,MAAM,kBAAS;AACnC,OAAO,KAAKC,UAAU,MAAM,oBAAW;AACvC,OAAO,KAAKC,SAAS,MAAM,mBAAU;AAErC,SAASF,QAAQ,EAAEC,UAAU,EAAEC,SAAS","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ import { IoReactNativeCie } from "../native.js";
4
+ /**
5
+ * Sets the log mode for the CIE SDK.
6
+ *
7
+ * **Note**: Logging is only supported on iOS. On Android, this method will throw an error.
8
+ *
9
+ * @param mode - The log mode to set ('console', 'localFile', or 'disabled').
10
+ * @example
11
+ * ```typescript
12
+ * CieManager.setLogMode('console');
13
+ * ```
14
+ */
15
+ const setLogMode = mode => {
16
+ IoReactNativeCie.setLogMode(mode);
17
+ };
18
+
19
+ /**
20
+ * Retrieves the file path of the latest logs generated by the CIE SDK.
21
+ * @returns A promise that resolves to a string representing the file path of the latest logs.
22
+ * @throws {CieError} If cannot retrieve the logs path.
23
+ */
24
+ const getLogsFilePath = async () => {
25
+ return IoReactNativeCie.getLogsFilePath();
26
+ };
27
+
28
+ /**
29
+ * Retrieves the contetent of the latest logs generated by the CIE SDK.
30
+ * @returns A promise that resolves to a string representing the content of the latest logs.
31
+ * @throws {CieError} If cannot retrieve the logs content.
32
+ */
33
+ const getLogs = async () => {
34
+ return IoReactNativeCie.getLogs();
35
+ };
36
+ export { setLogMode, getLogsFilePath, getLogs };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IoReactNativeCie","setLogMode","mode","getLogsFilePath","getLogs"],"sourceRoot":"../../../src","sources":["logger/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,cAAW;AAG5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,IAAa,IAAK;EACpCF,gBAAgB,CAACC,UAAU,CAACC,IAAI,CAAC;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAA6B;EACnD,OAAOH,gBAAgB,CAACG,eAAe,CAAC,CAAC;AAC3C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAG,MAAAA,CAAA,KAA6B;EAC3C,OAAOJ,gBAAgB,CAACI,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,SAASH,UAAU,EAAEE,eAAe,EAAEC,OAAO","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Represent the log mode for the CIE SDK
7
+ *
8
+ * - `localFile`: Logs are saved to a local file on the device for later retrieval.
9
+ * - `console`: Logs are output to the console for real-time monitoring.
10
+ * - `disabled`: Disables all logging
11
+ *
12
+ * **Note**: Logging is only supported on iOS. On Android, setting the log mode will throw an error.
13
+ */
14
+ export const LogMode = z.enum(['localFile', 'console', 'disabled']);
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","LogMode","enum"],"sourceRoot":"../../../src","sources":["logger/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGD,CAAC,CAACE,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  /**
3
3
  * Error codes which the module uses to reject a promise.
4
4
  */
5
- declare const ModuleErrorCodesSchema: z.ZodEnum<["PIN_REGEX_NOT_VALID", "INVALID_AUTH_URL", "THREADING_ERROR", "UNKNOWN_EXCEPTION"]>;
5
+ declare const ModuleErrorCodesSchema: z.ZodEnum<["PIN_REGEX_NOT_VALID", "INVALID_AUTH_URL", "THREADING_ERROR", "UNSUPPORTED", "UNKNOWN_EXCEPTION"]>;
6
6
  export type CieErrorCodes = z.infer<typeof ModuleErrorCodesSchema>;
7
7
  /**
8
8
  * Schema which can be used to parse a rejected promise error the module.
@@ -12,17 +12,17 @@ export type CieErrorCodes = z.infer<typeof ModuleErrorCodesSchema>;
12
12
  * @returns A schema for the common parameters of a rejected promise error in a native module.
13
13
  */
14
14
  export declare const CieErrorSchema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
15
- code: z.ZodEnum<["PIN_REGEX_NOT_VALID", "INVALID_AUTH_URL", "THREADING_ERROR", "UNKNOWN_EXCEPTION"]>;
15
+ code: z.ZodEnum<["PIN_REGEX_NOT_VALID", "INVALID_AUTH_URL", "THREADING_ERROR", "UNSUPPORTED", "UNKNOWN_EXCEPTION"]>;
16
16
  message: z.ZodString;
17
17
  name: z.ZodString;
18
18
  userInfo: z.ZodUnion<[z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>, z.ZodNull]>;
19
19
  }, "strip", z.ZodTypeAny, {
20
- code: "PIN_REGEX_NOT_VALID" | "INVALID_AUTH_URL" | "THREADING_ERROR" | "UNKNOWN_EXCEPTION";
20
+ code: "PIN_REGEX_NOT_VALID" | "INVALID_AUTH_URL" | "THREADING_ERROR" | "UNSUPPORTED" | "UNKNOWN_EXCEPTION";
21
21
  message: string;
22
22
  name: string;
23
23
  userInfo?: Record<string, any> | null | undefined;
24
24
  }, {
25
- code: "PIN_REGEX_NOT_VALID" | "INVALID_AUTH_URL" | "THREADING_ERROR" | "UNKNOWN_EXCEPTION";
25
+ code: "PIN_REGEX_NOT_VALID" | "INVALID_AUTH_URL" | "THREADING_ERROR" | "UNSUPPORTED" | "UNKNOWN_EXCEPTION";
26
26
  message: string;
27
27
  name: string;
28
28
  userInfo?: Record<string, any> | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB;;GAEG;AACH,QAAA,MAAM,sBAAsB,gGAK1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEnE;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQC,CAAC;AAE7B,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB;;GAEG;AACH,QAAA,MAAM,sBAAsB,+GAM1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEnE;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQC,CAAC;AAE7B,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import * as CieUtils from './utils';
2
2
  import * as CieManager from './manager';
3
- export { CieUtils, CieManager };
4
- export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, ResultEncoding, } from './manager/types';
3
+ import * as CieLogger from './logger';
4
+ export { CieUtils, CieManager, CieLogger };
5
+ export type { NfcEvent, NfcError, CieAttributes, CieEventHandlers, CieEvent, InternalAuthResponse, MrtdResponse, InternalAuthAndMrtdResponse, ResultEncoding, CertificateData, } from './manager/types';
6
+ export type { LogMode } from './logger/types';
5
7
  export type { CieErrorSchema, CieError, CieErrorCodes } from './errors';
6
8
  //# 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,EAC3B,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
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;AACxC,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAE3C,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,EACd,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type LogMode } from './types';
2
+ /**
3
+ * Sets the log mode for the CIE SDK.
4
+ *
5
+ * **Note**: Logging is only supported on iOS. On Android, this method will throw an error.
6
+ *
7
+ * @param mode - The log mode to set ('console', 'localFile', or 'disabled').
8
+ * @example
9
+ * ```typescript
10
+ * CieManager.setLogMode('console');
11
+ * ```
12
+ */
13
+ declare const setLogMode: (mode: LogMode) => void;
14
+ /**
15
+ * Retrieves the file path of the latest logs generated by the CIE SDK.
16
+ * @returns A promise that resolves to a string representing the file path of the latest logs.
17
+ * @throws {CieError} If cannot retrieve the logs path.
18
+ */
19
+ declare const getLogsFilePath: () => Promise<string>;
20
+ /**
21
+ * Retrieves the contetent of the latest logs generated by the CIE SDK.
22
+ * @returns A promise that resolves to a string representing the content of the latest logs.
23
+ * @throws {CieError} If cannot retrieve the logs content.
24
+ */
25
+ declare const getLogs: () => Promise<string>;
26
+ export { setLogMode, getLogsFilePath, getLogs };
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,UAAU,GAAI,MAAM,OAAO,SAEhC,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,eAAe,QAAa,OAAO,CAAC,MAAM,CAE/C,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,OAAO,QAAa,OAAO,CAAC,MAAM,CAEvC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Represent the log mode for the CIE SDK
4
+ *
5
+ * - `localFile`: Logs are saved to a local file on the device for later retrieval.
6
+ * - `console`: Logs are output to the console for real-time monitoring.
7
+ * - `disabled`: Disables all logging
8
+ *
9
+ * **Note**: Logging is only supported on iOS. On Android, setting the log mode will throw an error.
10
+ */
11
+ export declare const LogMode: z.ZodEnum<["localFile", "console", "disabled"]>;
12
+ export type LogMode = z.infer<typeof LogMode>;
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/logger/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,iDAA+C,CAAC;AAEpE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-cie",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Native support for CIE",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
package/src/errors.ts CHANGED
@@ -38,6 +38,7 @@ const ModuleErrorCodesSchema = z.enum([
38
38
  'PIN_REGEX_NOT_VALID',
39
39
  'INVALID_AUTH_URL',
40
40
  'THREADING_ERROR', // iOS only
41
+ 'UNSUPPORTED',
41
42
  'UNKNOWN_EXCEPTION',
42
43
  ]);
43
44
 
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as CieUtils from './utils';
2
2
  import * as CieManager from './manager';
3
+ import * as CieLogger from './logger';
3
4
 
4
- export { CieUtils, CieManager };
5
+ export { CieUtils, CieManager, CieLogger };
5
6
 
6
7
  export type {
7
8
  NfcEvent,
@@ -13,6 +14,9 @@ export type {
13
14
  MrtdResponse,
14
15
  InternalAuthAndMrtdResponse,
15
16
  ResultEncoding,
17
+ CertificateData,
16
18
  } from './manager/types';
17
19
 
20
+ export type { LogMode } from './logger/types';
21
+
18
22
  export type { CieErrorSchema, CieError, CieErrorCodes } from './errors';
@@ -0,0 +1,37 @@
1
+ import { IoReactNativeCie } from '../native';
2
+ import { type LogMode } from './types';
3
+
4
+ /**
5
+ * Sets the log mode for the CIE SDK.
6
+ *
7
+ * **Note**: Logging is only supported on iOS. On Android, this method will throw an error.
8
+ *
9
+ * @param mode - The log mode to set ('console', 'localFile', or 'disabled').
10
+ * @example
11
+ * ```typescript
12
+ * CieManager.setLogMode('console');
13
+ * ```
14
+ */
15
+ const setLogMode = (mode: LogMode) => {
16
+ IoReactNativeCie.setLogMode(mode);
17
+ };
18
+
19
+ /**
20
+ * Retrieves the file path of the latest logs generated by the CIE SDK.
21
+ * @returns A promise that resolves to a string representing the file path of the latest logs.
22
+ * @throws {CieError} If cannot retrieve the logs path.
23
+ */
24
+ const getLogsFilePath = async (): Promise<string> => {
25
+ return IoReactNativeCie.getLogsFilePath();
26
+ };
27
+
28
+ /**
29
+ * Retrieves the contetent of the latest logs generated by the CIE SDK.
30
+ * @returns A promise that resolves to a string representing the content of the latest logs.
31
+ * @throws {CieError} If cannot retrieve the logs content.
32
+ */
33
+ const getLogs = async (): Promise<string> => {
34
+ return IoReactNativeCie.getLogs();
35
+ };
36
+
37
+ export { setLogMode, getLogsFilePath, getLogs };
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Represent the log mode for the CIE SDK
5
+ *
6
+ * - `localFile`: Logs are saved to a local file on the device for later retrieval.
7
+ * - `console`: Logs are output to the console for real-time monitoring.
8
+ * - `disabled`: Disables all logging
9
+ *
10
+ * **Note**: Logging is only supported on iOS. On Android, setting the log mode will throw an error.
11
+ */
12
+ export const LogMode = z.enum(['localFile', 'console', 'disabled']);
13
+
14
+ export type LogMode = z.infer<typeof LogMode>;