@pagopa/io-react-native-iso18013 0.2.0 → 0.4.0

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.
Files changed (95) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeCborModule.kt +67 -164
  3. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Module.kt +102 -146
  4. package/ios/Base64Utils.swift +10 -3
  5. package/ios/IoReactNativeCbor.swift +55 -125
  6. package/ios/IoReactNativeIso18013.swift +88 -117
  7. package/lib/module/cbor/cbor/README.md +37 -5
  8. package/lib/module/cbor/cbor/error.js +15 -0
  9. package/lib/module/cbor/cbor/error.js.map +1 -0
  10. package/lib/module/cbor/cbor/index.js +1 -0
  11. package/lib/module/cbor/cbor/index.js.map +1 -1
  12. package/lib/module/cbor/cose/README.md +39 -9
  13. package/lib/module/cbor/cose/error.js +17 -0
  14. package/lib/module/cbor/cose/error.js.map +1 -0
  15. package/lib/module/cbor/cose/index.js +1 -0
  16. package/lib/module/cbor/cose/index.js.map +1 -1
  17. package/lib/module/cbor/index.js +1 -1
  18. package/lib/module/cbor/index.js.map +1 -1
  19. package/lib/module/iso18013/index.js +2 -3
  20. package/lib/module/iso18013/index.js.map +1 -1
  21. package/lib/module/iso18013/iso18013-5/README.md +52 -16
  22. package/lib/module/iso18013/iso18013-5/error.js +25 -0
  23. package/lib/module/iso18013/iso18013-5/error.js.map +1 -0
  24. package/lib/module/iso18013/iso18013-5/index.js +3 -2
  25. package/lib/module/iso18013/iso18013-5/index.js.map +1 -1
  26. package/lib/module/iso18013/iso18013-5/proximity.js +10 -18
  27. package/lib/module/iso18013/iso18013-5/proximity.js.map +1 -1
  28. package/lib/module/iso18013/iso18013-5/{schema.js → request.js} +1 -20
  29. package/lib/module/iso18013/iso18013-5/request.js.map +1 -0
  30. package/lib/module/iso18013/iso18013-7/README.md +38 -9
  31. package/lib/module/iso18013/iso18013-7/error.js +15 -0
  32. package/lib/module/iso18013/iso18013-7/error.js.map +1 -0
  33. package/lib/module/iso18013/iso18013-7/index.js +1 -0
  34. package/lib/module/iso18013/iso18013-7/index.js.map +1 -1
  35. package/lib/module/iso18013/iso18013-7/remote.js +2 -14
  36. package/lib/module/iso18013/iso18013-7/remote.js.map +1 -1
  37. package/lib/module/schema.js +46 -0
  38. package/lib/module/schema.js.map +1 -0
  39. package/lib/typescript/src/cbor/cbor/error.d.ts +68 -0
  40. package/lib/typescript/src/cbor/cbor/error.d.ts.map +1 -0
  41. package/lib/typescript/src/cbor/cbor/index.d.ts +1 -1
  42. package/lib/typescript/src/cbor/cbor/index.d.ts.map +1 -1
  43. package/lib/typescript/src/cbor/cose/error.d.ts +68 -0
  44. package/lib/typescript/src/cbor/cose/error.d.ts.map +1 -0
  45. package/lib/typescript/src/cbor/cose/index.d.ts +1 -1
  46. package/lib/typescript/src/cbor/cose/index.d.ts.map +1 -1
  47. package/lib/typescript/src/iso18013/index.d.ts +1 -2
  48. package/lib/typescript/src/iso18013/index.d.ts.map +1 -1
  49. package/lib/typescript/src/iso18013/iso18013-5/error.d.ts +73 -0
  50. package/lib/typescript/src/iso18013/iso18013-5/error.d.ts.map +1 -0
  51. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts +3 -2
  52. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts.map +1 -1
  53. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts +2 -7
  54. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts.map +1 -1
  55. package/lib/typescript/src/iso18013/iso18013-5/{schema.d.ts → request.d.ts} +1 -16
  56. package/lib/typescript/src/iso18013/iso18013-5/request.d.ts.map +1 -0
  57. package/lib/typescript/src/iso18013/iso18013-7/error.d.ts +68 -0
  58. package/lib/typescript/src/iso18013/iso18013-7/error.d.ts.map +1 -0
  59. package/lib/typescript/src/iso18013/iso18013-7/index.d.ts +2 -1
  60. package/lib/typescript/src/iso18013/iso18013-7/index.d.ts.map +1 -1
  61. package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts +0 -14
  62. package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts.map +1 -1
  63. package/lib/typescript/src/schema.d.ts +76 -0
  64. package/lib/typescript/src/schema.d.ts.map +1 -0
  65. package/package.json +1 -1
  66. package/src/cbor/cbor/README.md +37 -5
  67. package/src/cbor/cbor/error.ts +23 -0
  68. package/src/cbor/cbor/index.ts +5 -1
  69. package/src/cbor/cose/README.md +39 -9
  70. package/src/cbor/cose/error.ts +23 -0
  71. package/src/cbor/cose/index.ts +5 -1
  72. package/src/cbor/index.ts +1 -1
  73. package/src/iso18013/index.ts +2 -9
  74. package/src/iso18013/iso18013-5/README.md +52 -16
  75. package/src/iso18013/iso18013-5/error.ts +35 -0
  76. package/src/iso18013/iso18013-5/index.ts +9 -4
  77. package/src/iso18013/iso18013-5/proximity.ts +11 -19
  78. package/src/iso18013/iso18013-5/{schema.ts → request.ts} +0 -20
  79. package/src/iso18013/iso18013-7/README.md +38 -9
  80. package/src/iso18013/iso18013-7/error.ts +21 -0
  81. package/src/iso18013/iso18013-7/index.ts +5 -4
  82. package/src/iso18013/iso18013-7/remote.ts +2 -22
  83. package/src/schema.ts +55 -0
  84. package/lib/module/cbor/cbor/failure.js +0 -2
  85. package/lib/module/cbor/cbor/failure.js.map +0 -1
  86. package/lib/module/cbor/cose/failure.js +0 -2
  87. package/lib/module/cbor/cose/failure.js.map +0 -1
  88. package/lib/module/iso18013/iso18013-5/schema.js.map +0 -1
  89. package/lib/typescript/src/cbor/cbor/failure.d.ts +0 -15
  90. package/lib/typescript/src/cbor/cbor/failure.d.ts.map +0 -1
  91. package/lib/typescript/src/cbor/cose/failure.d.ts +0 -15
  92. package/lib/typescript/src/cbor/cose/failure.d.ts.map +0 -1
  93. package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts.map +0 -1
  94. package/src/cbor/cbor/failure.ts +0 -18
  95. package/src/cbor/cose/failure.ts +0 -20
@@ -42,12 +42,42 @@ try {
42
42
  }
43
43
  ```
44
44
 
45
- ### Error Codes
46
-
47
- | Type | Platform | Description |
48
- | -------------------- | ----------- | -------------------------------------------------- |
49
- | PUBLIC_KEY_NOT_FOUND | Android/iOS | The public key is missing for the specified keyTag |
50
- | INVALID_ENCODING | Android/iOS | Provided payload has incorrect encoding |
51
- | UNABLE_TO_SIGN | Android/iOS | It was not possible to sign the given string |
52
- | THREADING_ERROR | iOS | Unexpected failure |
53
- | UNKNOWN_EXCEPTION | Android/iOS | Unexpected failure |
45
+ ### Error
46
+
47
+ This table contains the list of error codes that can be thrown by the `COSE` module which are mapped via the `ModuleErrorCodes` type:
48
+ | Type | Platform | Description |
49
+ | -------------------------- | ----------- | ------------------------------------------------------------ |
50
+ | SIGN_ERROR | Android/iOS | An error occurred while signing the data |
51
+ | VERIFY_ERROR | Android/iOS | An error occurred while verifying the signature |
52
+ | THREADING_ERROR | iOS | An error occurred while performing the sign operation in background |
53
+
54
+ An error can be parsed using the `ModuleErrorSchema` with type `ModuleErrorCodes` exposed by the `COSE` module. The error can be parsed as follows:
55
+
56
+ ```typescript
57
+ import { COSE } from '@pagopa/io-react-native-iso18013';
58
+ try {
59
+ await COSE.func();
60
+ } catch (error) {
61
+ const parsedError = COSE.ModuleErrorSchema.parse(error); // Or ModuleErrorSchema.safeParse(error) for safe parsing
62
+ console.log(JSON.stringify(parsedError, null, 2));
63
+ }
64
+ ```
65
+
66
+ The parsed object will contain properties from both iOS and Android platforms:
67
+
68
+ ```typescript
69
+ {
70
+ code: string; // Defined in ModuleErrorCodes
71
+ message: string;
72
+ name: string;
73
+ userInfo?: Record<string, any> | null;
74
+ nativeStackAndroid?: Array<{
75
+ lineNumber: number;
76
+ file: string;
77
+ methodName: string;
78
+ class: string;
79
+ }>;
80
+ domain?: string;
81
+ nativeStackIOS?: Array<string>;
82
+ };
83
+ ```
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ import z from 'zod';
4
+ import { GenericModuleErrorSchema } from "../../schema.js";
5
+
6
+ /**
7
+ * Error codes which the COSE module uses to reject a promise.
8
+ */
9
+ const ModuleErrorCodesSchema = z.enum(['SIGN_ERROR', 'VERIFY_ERROR', 'THREADING_ERROR',
10
+ // iOS only
11
+ 'EUNSPECIFIED' // Android only default when no other error is specified
12
+ ]);
13
+ /**
14
+ * Schema which can be used to parse a rejected promise error by the COSE module.
15
+ */
16
+ export const ModuleErrorSchema = GenericModuleErrorSchema(ModuleErrorCodesSchema);
17
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","GenericModuleErrorSchema","ModuleErrorCodesSchema","enum","ModuleErrorSchema"],"sourceRoot":"../../../../src","sources":["cbor/cose/error.ts"],"mappings":";;AAAA,OAAOA,CAAC,MAAM,KAAK;AACnB,SAASC,wBAAwB,QAAQ,iBAAc;;AAEvD;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGF,CAAC,CAACG,IAAI,CAAC,CACpC,YAAY,EACZ,cAAc,EACd,iBAAiB;AAAE;AACnB,cAAc,CAAE;AAAA,CACjB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGH,wBAAwB,CACvDC,sBACF,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
3
  export { sign, verify } from "./sign.js";
4
+ export { ModuleErrorSchema } from "./error.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sign","verify"],"sourceRoot":"../../../../src","sources":["cbor/cose/index.ts"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,MAAM,QAAQ,WAAQ","ignoreList":[]}
1
+ {"version":3,"names":["sign","verify","ModuleErrorSchema"],"sourceRoot":"../../../../src","sources":["cbor/cose/index.ts"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,MAAM,QAAQ,WAAQ;AACrC,SAGEC,iBAAiB,QACZ,YAAS","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { NativeModules, Platform } from 'react-native';
4
- const LINKING_ERROR = `The package '@pagopa/io-react-native-cbor' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
4
+ const LINKING_ERROR = `The package '@pagopa/io-react-native-iso18013' (IoReactNativeCbor) doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
5
  ios: "- You have run 'pod install'\n",
6
6
  default: ''
7
7
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","IoReactNativeCbor","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["cbor/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,uFAAuF,GACvFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,iBAAiB,GAAGN,aAAa,CAACM,iBAAiB,GAC5DN,aAAa,CAACM,iBAAiB,GAC/B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","IoReactNativeCbor","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["cbor/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,+GAA+G,GAC/GD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,iBAAiB,GAAGN,aAAa,CAACM,iBAAiB,GAC5DN,aAAa,CAACM,iBAAiB,GAC/B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  import { NativeModules, Platform } from 'react-native';
4
- export { parseEventError, parseVerifierRequest } from "./iso18013-5/schema.js";
5
- const LINKING_ERROR = `The package '@pagopa/io-react-native-proximity' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
4
+ const LINKING_ERROR = `The package '@pagopa/io-react-native-iso18013' (IoReactNativeIso18013) doesn't seem to be linked. Make sure: \n\n` + Platform.select({
6
5
  ios: "- You have run 'pod install'\n",
7
6
  default: ''
8
7
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
9
- export const IoReactNativeProximity = NativeModules.IoReactNativeIso18013 ? NativeModules.IoReactNativeIso18013 : new Proxy({}, {
8
+ export const IoReactNativeIso18013 = NativeModules.IoReactNativeIso18013 ? NativeModules.IoReactNativeIso18013 : new Proxy({}, {
10
9
  get() {
11
10
  throw new Error(LINKING_ERROR);
12
11
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","parseEventError","parseVerifierRequest","LINKING_ERROR","select","ios","default","IoReactNativeProximity","IoReactNativeIso18013","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["iso18013/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAIEC,eAAe,EACfC,oBAAoB,QACf,wBAAqB;AAE5B,MAAMC,aAAa,GACjB,4FAA4F,GAC5FH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,sBAAsB,GAAGR,aAAa,CAACS,qBAAqB,GACrET,aAAa,CAACS,qBAAqB,GACnC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","IoReactNativeIso18013","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["iso18013/index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,mHAAmH,GACnHD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,qBAAqB,GAAGN,aAAa,CAACM,qBAAqB,GACpEN,aAAa,CAACM,qBAAqB,GACnC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC","ignoreList":[]}
@@ -18,14 +18,16 @@ This library emits the following events:
18
18
  | onDeviceDisconnected | `undefined` | Event dispatched when the verifier app disconnects. |
19
19
  | onError | `{ error: string } \| undefined` | Event dispatched when an error occurs which is contained in the error payload. It can be parsed via the `parseError` provided [here](src/schema.ts). |
20
20
 
21
- Listeners can be added using the `addListener` method and removed using the `removeListener` method.
21
+ Listeners can be added using the `addListener` method and removed by using the returned reference by calling the `remove` method.
22
22
 
23
23
  ```typescript
24
24
  import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
25
25
 
26
- ISO18013_5.addListener('event', () => console.log('event occurred'));
26
+ const listener = ISO18013_5.addListener('event', () =>
27
+ console.log('event occurred')
28
+ );
27
29
 
28
- ISO18013_5.removeListener('event');
30
+ listener.remove();
29
31
  ```
30
32
 
31
33
  #### `onDeviceConnecting`
@@ -173,7 +175,7 @@ await ISO18013_5.sendErrorResponse({
173
175
 
174
176
  Closes the QR engagement by releasing the resources allocated during the `start` method.
175
177
  Before starting a new flow, it is necessary to call this method to ensure that the previous flow is properly closed.
176
- The listeners can be removed using the `removeListener` method.
178
+ Listeners can be added using the `addListener` method and removed using the `removeListener` method.
177
179
 
178
180
  ```typescript
179
181
  import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
@@ -220,15 +222,49 @@ sequenceDiagram
220
222
  proximity->>+app: Calls the onDeviceDisconnected callback
221
223
  ```
222
224
 
223
- ## Error Codes
224
-
225
- | Type | Platform | Description |
226
- | ------------------------------- | ----------- | ---------------------------------------------------------------------------- |
227
- | DRH_NOT_DEFINED | Android | The device retrieval helper hasn't been initialized, call the `start` method |
228
- | QR_ENGAGEMENT_NOT_DEFINED_ERROR | Android | The QR engagement hasn't been initialized, call the `start` method |
229
- | START_ERROR | Android/iOS | An error occurred while initializing the required resources |
230
- | GET_QR_CODE_ERROR | Android/iOS | An error occurred while generating the engagement QR code |
231
- | GENERATE_RESPONSE_ERROR | Android/iOS | An error occurred while generating the response for the verifier app |
232
- | SEND_RESPONSE_ERROR | Android/iOS | An error occurred while sending the response to the verifier app |
233
- | SEND_ERROR_RESPONSE_ERROR | Android/iOS | An error occurred while sending the error response to the verifier app |
234
- | CLOSE_ERROR | Android | An error occured while closing the required resources |
225
+ ## Errors
226
+
227
+ This table contains the list of error codes that can be thrown by the `ISO18013_5` module which are mapped via the `ModuleErrorCodes` type:
228
+
229
+ | Type | Platform | Description |
230
+ | ------------------------- | ----------- | ---------------------------------------------------------------------------- |
231
+ | DRH_NOT_DEFINED | Android | The device retrieval helper hasn't been initialized, call the `start` method |
232
+ | QR_ENGAGEMENT_NOT_DEFINED | Android | The QR engagement hasn't been initialized, call the `start` method |
233
+ | START_ERROR | Android/iOS | An error occurred while initializing the required resources |
234
+ | GET_QR_CODE_ERROR | Android/iOS | An error occurred while generating the engagement QR code |
235
+ | SEND_RESPONSE_ERROR | Android/iOS | An error occurred while sending the response for the verifier app |
236
+ | SEND_ERROR_RESPONSE_ERROR | Android/iOS | An error occurred while sending the error response to the verifier app |
237
+ | GENERATE_RESPONSE_ERROR | Android/iOS | An error occurred while generating the response for the verifier app |
238
+ | CLOSE_ERROR | Android | An error occured while closing the required resources |
239
+ | EUNSPECIFIED | Android | Default error when no other error is specified |
240
+
241
+ An error can be parsed using the `ModuleErrorSchema` with type `ModuleErrorCodes` exposed by the `ISO18013_5` module. The error can be parsed as follows:
242
+
243
+ ```typescript
244
+ import { ISO18013_5 } from '@pagopa/io-react-native-iso18013';
245
+ try {
246
+ await ISO18013_5.func();
247
+ } catch (error) {
248
+ const parsedError = ISO18013_5.ModuleErrorSchema.parse(error); // Or ModuleErrorSchema.safeParse(error) for safe parsing
249
+ console.log(JSON.stringify(parsedError, null, 2));
250
+ }
251
+ ```
252
+
253
+ The parsed object will contain properties from both iOS and Android platforms:
254
+
255
+ ```typescript
256
+ {
257
+ code: string; // Defined in ModuleErrorCodes
258
+ message: string;
259
+ name: string;
260
+ userInfo?: Record<string, any> | null;
261
+ nativeStackAndroid?: Array<{
262
+ lineNumber: number;
263
+ file: string;
264
+ methodName: string;
265
+ class: string;
266
+ }>;
267
+ domain?: string;
268
+ nativeStackIOS?: Array<string>;
269
+ };
270
+ ```
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ import z from 'zod';
4
+ import { GenericModuleErrorSchema } from "../../schema.js";
5
+
6
+ /**
7
+ * Schema for parsing the payload returned by the `onError` event in Proximity `Events`, along with its type definition.
8
+ */
9
+ export const OnErrorPayloadSchema = z.string().catch('Unknown error');
10
+ /**
11
+ * Error codes which the ISO18013_5 module uses to reject a promise.
12
+ */
13
+ const ModuleErrorCodesSchema = z.enum(['DRH_NOT_DEFINED',
14
+ // Android only
15
+ 'QR_ENGAGEMENT_NOT_DEFINED',
16
+ // Android only
17
+ 'START_ERROR', 'GET_QR_CODE_ERROR', 'SEND_RESPONSE_ERROR', 'SEND_ERROR_RESPONSE_ERROR', 'GENERATE_RESPONSE_ERROR', 'CLOSE_ERROR',
18
+ // Android only
19
+ 'EUNSPECIFIED' // Android only default when no other error is specified
20
+ ]);
21
+ /**
22
+ * Schema which can be used to parse a rejected promise error by the ISO18013_5 module.
23
+ */
24
+ export const ModuleErrorSchema = GenericModuleErrorSchema(ModuleErrorCodesSchema);
25
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","GenericModuleErrorSchema","OnErrorPayloadSchema","string","catch","ModuleErrorCodesSchema","enum","ModuleErrorSchema"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/error.ts"],"mappings":";;AAAA,OAAOA,CAAC,MAAM,KAAK;AACnB,SAASC,wBAAwB,QAAQ,iBAAc;;AAEvD;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGF,CAAC,CAACG,MAAM,CAAC,CAAC,CAACC,KAAK,CAAC,eAAe,CAAC;AAIrE;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGL,CAAC,CAACM,IAAI,CAAC,CACpC,iBAAiB;AAAE;AACnB,2BAA2B;AAAE;AAC7B,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,aAAa;AAAE;AACf,cAAc,CAAE;AAAA,CACjB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGN,wBAAwB,CACvDI,sBACF,CAAC","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
- export { parseEventError, parseVerifierRequest } from "./schema.js";
4
- export { ErrorCode, addListener, close, generateResponse, getQrCodeString, removeListener, sendErrorResponse, sendResponse, start } from "./proximity.js";
3
+ export { parseVerifierRequest } from "./request.js";
4
+ export { OnErrorPayloadSchema, ModuleErrorSchema } from "./error.js";
5
+ export { ErrorCode, addListener, close, generateResponse, getQrCodeString, sendErrorResponse, sendResponse, start } from "./proximity.js";
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["parseEventError","parseVerifierRequest","ErrorCode","addListener","close","generateResponse","getQrCodeString","removeListener","sendErrorResponse","sendResponse","start"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/index.ts"],"mappings":";;AAAA,SAIEA,eAAe,EACfC,oBAAoB,QACf,aAAU;AAEjB,SACEC,SAAS,EAGTC,WAAW,EACXC,KAAK,EACLC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,EACdC,iBAAiB,EACjBC,YAAY,EACZC,KAAK,QACA,gBAAa","ignoreList":[]}
1
+ {"version":3,"names":["parseVerifierRequest","OnErrorPayloadSchema","ModuleErrorSchema","ErrorCode","addListener","close","generateResponse","getQrCodeString","sendErrorResponse","sendResponse","start"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/index.ts"],"mappings":";;AAAA,SAGEA,oBAAoB,QACf,cAAW;AAElB,SAEEC,oBAAoB,EACpBC,iBAAiB,QAGZ,YAAS;AAEhB,SACEC,SAAS,EAGTC,WAAW,EACXC,KAAK,EACLC,gBAAgB,EAChBC,eAAe,EACfC,iBAAiB,EACjBC,YAAY,EACZC,KAAK,QACA,gBAAa","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import { NativeEventEmitter, Platform } from 'react-native';
4
- import { IoReactNativeProximity } from "../index.js";
5
- const eventEmitter = new NativeEventEmitter(IoReactNativeProximity);
4
+ import { IoReactNativeIso18013 } from "../index.js";
5
+ const eventEmitter = new NativeEventEmitter(IoReactNativeIso18013);
6
6
 
7
7
  /**
8
8
  * Events emitted by the native module:
@@ -44,9 +44,9 @@ export function start(config = {}) {
44
44
  certificates
45
45
  } = config;
46
46
  if (Platform.OS === 'ios') {
47
- return IoReactNativeProximity.start(certificates ? certificates : []);
47
+ return IoReactNativeIso18013.start(certificates ? certificates : []);
48
48
  } else {
49
- return IoReactNativeProximity.start(peripheralMode ? peripheralMode : true, centralClientMode ? centralClientMode : false, clearBleCache ? clearBleCache : true, certificates ? certificates : []);
49
+ return IoReactNativeIso18013.start(peripheralMode ? peripheralMode : true, centralClientMode ? centralClientMode : false, clearBleCache ? clearBleCache : true, certificates ? certificates : []);
50
50
  }
51
51
  }
52
52
 
@@ -54,14 +54,14 @@ export function start(config = {}) {
54
54
  * Gets the QR code string this method is responsible for initializing the connection and retrieving the QR code string
55
55
  */
56
56
  export function getQrCodeString() {
57
- return IoReactNativeProximity.getQrCodeString();
57
+ return IoReactNativeIso18013.getQrCodeString();
58
58
  }
59
59
 
60
60
  /**
61
61
  * Closes the QR engagement
62
62
  */
63
63
  export function close() {
64
- return IoReactNativeProximity.close();
64
+ return IoReactNativeIso18013.close();
65
65
  }
66
66
 
67
67
  /**
@@ -70,7 +70,7 @@ export function close() {
70
70
  * @param code - The error code to be sent to the verifier app.
71
71
  */
72
72
  export function sendErrorResponse(code) {
73
- return IoReactNativeProximity.sendErrorResponse(code);
73
+ return IoReactNativeIso18013.sendErrorResponse(code);
74
74
  }
75
75
 
76
76
  /**
@@ -80,7 +80,7 @@ export function sendErrorResponse(code) {
80
80
  * @returns A base64 encoded response to be sent to the verifier app via `sendResponse`
81
81
  */
82
82
  export function generateResponse(documents, acceptedFields) {
83
- return IoReactNativeProximity.generateResponse(documents, acceptedFields);
83
+ return IoReactNativeIso18013.generateResponse(documents, acceptedFields);
84
84
  }
85
85
 
86
86
  /**
@@ -89,7 +89,7 @@ export function generateResponse(documents, acceptedFields) {
89
89
  * @param response - The base64 encoded response to be sent to the verifier app.
90
90
  */
91
91
  export function sendResponse(response) {
92
- return IoReactNativeProximity.sendResponse(response);
92
+ return IoReactNativeIso18013.sendResponse(response);
93
93
  }
94
94
 
95
95
  /**
@@ -99,14 +99,6 @@ export function sendResponse(response) {
99
99
  * @param callback - The callback to be called when the event is emitted. The callback will receive the event payload as an argument.
100
100
  */
101
101
  export function addListener(event, callback) {
102
- eventEmitter.addListener(event, callback);
103
- }
104
-
105
- /**
106
- * Removes a listener for a `QrEngagementEvents` event.
107
- * @param event - The event to remove the listener for. The available events are defined in the `QrEngagementEvents` type.
108
- */
109
- export function removeListener(event) {
110
- eventEmitter.removeAllListeners(event);
102
+ return eventEmitter.addListener(event, callback);
111
103
  }
112
104
  //# sourceMappingURL=proximity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","Platform","IoReactNativeProximity","eventEmitter","ErrorCode","start","config","peripheralMode","centralClientMode","clearBleCache","certificates","OS","getQrCodeString","close","sendErrorResponse","code","generateResponse","documents","acceptedFields","sendResponse","response","addListener","event","callback","removeListener","removeAllListeners"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/proximity.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,SAASC,sBAAsB,QAAQ,aAAI;AAI3C,MAAMC,YAAY,GAAG,IAAIH,kBAAkB,CAACE,sBAAsB,CAAC;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,WAAYE,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAMrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CACnBC,MAKC,GAAG,CAAC,CAAC,EACY;EAClB,MAAM;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC,aAAa;IAAEC;EAAa,CAAC,GACtEJ,MAAM;EACR,IAAIL,QAAQ,CAACU,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOT,sBAAsB,CAACG,KAAK,CAACK,YAAY,GAAGA,YAAY,GAAG,EAAE,CAAC;EACvE,CAAC,MAAM;IACL,OAAOR,sBAAsB,CAACG,KAAK,CACjCE,cAAc,GAAGA,cAAc,GAAG,IAAI,EACtCC,iBAAiB,GAAGA,iBAAiB,GAAG,KAAK,EAC7CC,aAAa,GAAGA,aAAa,GAAG,IAAI,EACpCC,YAAY,GAAGA,YAAY,GAAG,EAChC,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAAA,EAAoB;EACjD,OAAOV,sBAAsB,CAACU,eAAe,CAAC,CAAC;AACjD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CAAA,EAAqB;EACxC,OAAOX,sBAAsB,CAACW,KAAK,CAAC,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,IAAe,EAAoB;EACnE,OAAOb,sBAAsB,CAACY,iBAAiB,CAACC,IAAI,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,SAAmC,EACnCC,cAA8B,EACb;EACjB,OAAOhB,sBAAsB,CAACc,gBAAgB,CAACC,SAAS,EAAEC,cAAc,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,QAAgB,EAAoB;EAC/D,OAAOlB,sBAAsB,CAACiB,YAAY,CAACC,QAAQ,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,KAAQ,EACRC,QAA0C,EAC1C;EACApB,YAAY,CAACkB,WAAW,CAACC,KAAK,EAAEC,QAAQ,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACF,KAAa,EAAE;EAC5CnB,YAAY,CAACsB,kBAAkB,CAACH,KAAK,CAAC;AACxC","ignoreList":[]}
1
+ {"version":3,"names":["NativeEventEmitter","Platform","IoReactNativeIso18013","eventEmitter","ErrorCode","start","config","peripheralMode","centralClientMode","clearBleCache","certificates","OS","getQrCodeString","close","sendErrorResponse","code","generateResponse","documents","acceptedFields","sendResponse","response","addListener","event","callback"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/proximity.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE3D,SAASC,qBAAqB,QAAQ,aAAI;AAG1C,MAAMC,YAAY,GAAG,IAAIH,kBAAkB,CAACE,qBAAqB,CAAC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,WAAYE,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAMrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CACnBC,MAKC,GAAG,CAAC,CAAC,EACY;EAClB,MAAM;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC,aAAa;IAAEC;EAAa,CAAC,GACtEJ,MAAM;EACR,IAAIL,QAAQ,CAACU,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOT,qBAAqB,CAACG,KAAK,CAACK,YAAY,GAAGA,YAAY,GAAG,EAAE,CAAC;EACtE,CAAC,MAAM;IACL,OAAOR,qBAAqB,CAACG,KAAK,CAChCE,cAAc,GAAGA,cAAc,GAAG,IAAI,EACtCC,iBAAiB,GAAGA,iBAAiB,GAAG,KAAK,EAC7CC,aAAa,GAAGA,aAAa,GAAG,IAAI,EACpCC,YAAY,GAAGA,YAAY,GAAG,EAChC,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAAA,EAAoB;EACjD,OAAOV,qBAAqB,CAACU,eAAe,CAAC,CAAC;AAChD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,KAAKA,CAAA,EAAqB;EACxC,OAAOX,qBAAqB,CAACW,KAAK,CAAC,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,IAAe,EAAoB;EACnE,OAAOb,qBAAqB,CAACY,iBAAiB,CAACC,IAAI,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,SAAmC,EACnCC,cAA8B,EACb;EACjB,OAAOhB,qBAAqB,CAACc,gBAAgB,CAACC,SAAS,EAAEC,cAAc,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,QAAgB,EAAoB;EAC/D,OAAOlB,qBAAqB,CAACiB,YAAY,CAACC,QAAQ,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,KAAQ,EACRC,QAA0C,EAC1C;EACA,OAAOpB,YAAY,CAACkB,WAAW,CAACC,KAAK,EAAEC,QAAQ,CAAC;AAClD","ignoreList":[]}
@@ -41,25 +41,6 @@ export const parseVerifierRequest = input => {
41
41
  return VerifierRequest.parse(input);
42
42
  };
43
43
 
44
- /**
45
- * Zod schema for the type returned by the `onError` event in Proximity `Events`.
46
- */
47
- const EventError = z.string().catch('Unknown error');
48
-
49
- /**
50
- * Error type returned by the `onError` event in Proximity `Events`.
51
- */
52
-
53
- /**
54
- * Parses the input to an Error object.
55
- * This function is used to parse the error received from the verifier app via the `onError` event.
56
- * @param input - The input to be parsed
57
- * @returns The parsed Error object or a default error message if parsing fails
58
- */
59
- export const parseEventError = input => {
60
- return EventError.parse(input);
61
- };
62
-
63
44
  /**
64
45
  * This is the type definition for the accepted fields that will be presented to the verifier app.
65
46
  * It contains of a nested object structure, where the outermost key represents the credential doctype.
@@ -76,4 +57,4 @@ export const parseEventError = input => {
76
57
  * }
77
58
  * }`
78
59
  **/
79
- //# sourceMappingURL=schema.js.map
60
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","booleanFieldGroup","record","boolean","credentialEntrySchema","object","isAuthenticated","catchall","VerifierRequest","request","parseVerifierRequest","input","parse"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/request.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA,MAAMC,iBAAiB,GAAGD,CAAC,CAACE,MAAM,CAACF,CAAC,CAACG,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAMC,qBAAqB,GAAGJ,CAAC,CAC5BK,MAAM,CAAC;EACNC,eAAe,EAAEN,CAAC,CAACG,OAAO,CAAC;AAC7B,CAAC,CAAC,CACDI,QAAQ,CAACN,iBAAiB,CAAC;AAE9B,MAAMO,eAAe,GAAGR,CAAC,CAACK,MAAM,CAAC;EAC/BI,OAAO,EAAET,CAAC,CAACE,MAAM,CAACE,qBAAqB;AACzC,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,oBAAoB,GAAIC,KAAc,IAAsB;EACvE,OAAOH,eAAe,CAACI,KAAK,CAACD,KAAK,CAAC;AACrC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -48,12 +48,41 @@ export const generateOID4VPDeviceResponse = async (
48
48
  ) : Promise<string> => {...};
49
49
  ```
50
50
 
51
- ### Error Codes
52
-
53
- | Type | Platform | Description |
54
- | --------------------------------- | ----------- | ------------------------------------------------------------------ |
55
- | UNABLE_TO_GENERATE_RESPONSE | Android/iOS | Failure during the generation of a response |
56
- | DOC_REQUESTED_PARSING_EXCEPTION | Android/iOS | The passed documents where in a bad format or contained wrong data |
57
- | REQUESTED_ITEMS_PARSING_EXCEPTION | iOS | The passed items where in a bad format |
58
- | UNABLE_TO_GENERATE_TRANSCRIPT | Android | There has been an error generating the session transcript |
59
- | UNKNOWN_EXCEPTION | Android/iOS | Unexpected failure |
51
+ ## Errors
52
+
53
+ This table contains the list of error codes that can be thrown by the `ISO18013_7` module which are mapped via the `ModuleErrorCodes` type:
54
+
55
+ | Type | Platform | Description |
56
+ | ------------------------------ | ----------- | ----------------------------------------------- |
57
+ | GENERATE_OID4VP_RESPONSE_ERROR | Android/iOS | An error occurred while generating the response |
58
+
59
+ An error can be parsed using the `ModuleErrorSchema` with type `ModuleErrorCodes` exposed by the `ISO18013_5` module. The error can be parsed as follows:
60
+
61
+ ```typescript
62
+ import { ISO18013_7 } from '@pagopa/io-react-native-iso18013';
63
+ try {
64
+ await ISO18013_7.func();
65
+ } catch (error) {
66
+ const parsedError = ISO18013_7.ModuleErrorSchema.parse(error); // Or ModuleErrorSchema.safeParse(error) for safe parsing
67
+ console.log(JSON.stringify(parsedError, null, 2));
68
+ }
69
+ ```
70
+
71
+ The parsed object will contain properties from both iOS and Android platforms:
72
+
73
+ ```typescript
74
+ {
75
+ code: string; // Defined in ModuleErrorCodes
76
+ message: string;
77
+ name: string;
78
+ userInfo?: Record<string, any> | null;
79
+ nativeStackAndroid?: Array<{
80
+ lineNumber: number;
81
+ file: string;
82
+ methodName: string;
83
+ class: string;
84
+ }>;
85
+ domain?: string;
86
+ nativeStackIOS?: Array<string>;
87
+ };
88
+ ```
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import z from 'zod';
4
+ import { GenericModuleErrorSchema } from "../../schema.js";
5
+
6
+ /**
7
+ * Error codes which the ISO18013_7 module uses to reject a promise.
8
+ */
9
+ const ModuleErrorCodesSchema = z.enum(['GENERATE_OID4VP_RESPONSE_ERROR', 'EUNSPECIFIED' // Android only default when no other error is specified
10
+ ]);
11
+ /**
12
+ * Schema which can be used to parse a rejected promise error by the ISO18013_7 module.
13
+ */
14
+ export const ModuleErrorSchema = GenericModuleErrorSchema(ModuleErrorCodesSchema);
15
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","GenericModuleErrorSchema","ModuleErrorCodesSchema","enum","ModuleErrorSchema"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-7/error.ts"],"mappings":";;AAAA,OAAOA,CAAC,MAAM,KAAK;AACnB,SAASC,wBAAwB,QAAQ,iBAAc;;AAEvD;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGF,CAAC,CAACG,IAAI,CAAC,CACpC,gCAAgC,EAChC,cAAc,CAAE;AAAA,CACjB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGH,wBAAwB,CACvDC,sBACF,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
3
  export { generateOID4VPDeviceResponse } from "./remote.js";
4
+ export { ModuleErrorSchema } from "./error.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["generateOID4VPDeviceResponse"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-7/index.ts"],"mappings":";;AAAA,SACEA,4BAA4B,QAGvB,aAAU","ignoreList":[]}
1
+ {"version":3,"names":["generateOID4VPDeviceResponse","ModuleErrorSchema"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-7/index.ts"],"mappings":";;AAAA,SAASA,4BAA4B,QAAQ,aAAU;AACvD,SACEC,iBAAiB,QAGZ,YAAS","ignoreList":[]}
@@ -1,18 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { IoReactNativeProximity } from "../index.js";
4
-
5
- /**
6
- * All error codes that the module could return.
7
- */
8
-
9
- /**
10
- * Error type returned by a rejected promise.
11
- *
12
- * If additional error information are available,
13
- * they are stored in the {@link OID4VPFailure["userInfo"]} field.
14
- */
15
-
3
+ import { IoReactNativeIso18013 } from "../index.js";
16
4
  /**
17
5
  *
18
6
  * @param clientId extracted from OID4VP session
@@ -26,6 +14,6 @@ import { IoReactNativeProximity } from "../index.js";
26
14
  * @returns the Device Response in CBOR format
27
15
  */
28
16
  export const generateOID4VPDeviceResponse = async (clientId, responseUri, authorizationRequestNonce, mdocGeneratedNonce, documents, fieldRequestedAndAccepted) => {
29
- return await IoReactNativeProximity.generateOID4VPDeviceResponse(clientId, responseUri, authorizationRequestNonce, mdocGeneratedNonce, documents, typeof fieldRequestedAndAccepted === 'string' ? fieldRequestedAndAccepted : JSON.stringify(fieldRequestedAndAccepted));
17
+ return await IoReactNativeIso18013.generateOID4VPDeviceResponse(clientId, responseUri, authorizationRequestNonce, mdocGeneratedNonce, documents, typeof fieldRequestedAndAccepted === 'string' ? fieldRequestedAndAccepted : JSON.stringify(fieldRequestedAndAccepted));
30
18
  };
31
19
  //# sourceMappingURL=remote.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["IoReactNativeProximity","generateOID4VPDeviceResponse","clientId","responseUri","authorizationRequestNonce","mdocGeneratedNonce","documents","fieldRequestedAndAccepted","JSON","stringify"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-7/remote.ts"],"mappings":";;AAAA,SAASA,sBAAsB,QAAQ,aAAI;;AAG3C;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GAAG,MAAAA,CAC1CC,QAAgB,EAChBC,WAAmB,EACnBC,yBAAiC,EACjCC,kBAA0B,EAC1BC,SAAmC,EACnCC,yBAAuD,KACnC;EACpB,OAAO,MAAMP,sBAAsB,CAACC,4BAA4B,CAC9DC,QAAQ,EACRC,WAAW,EACXC,yBAAyB,EACzBC,kBAAkB,EAClBC,SAAS,EACT,OAAOC,yBAAyB,KAAK,QAAQ,GACzCA,yBAAyB,GACzBC,IAAI,CAACC,SAAS,CAACF,yBAAyB,CAC9C,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["IoReactNativeIso18013","generateOID4VPDeviceResponse","clientId","responseUri","authorizationRequestNonce","mdocGeneratedNonce","documents","fieldRequestedAndAccepted","JSON","stringify"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-7/remote.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,aAAI;AAG1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,GAAG,MAAAA,CAC1CC,QAAgB,EAChBC,WAAmB,EACnBC,yBAAiC,EACjCC,kBAA0B,EAC1BC,SAAmC,EACnCC,yBAAuD,KACnC;EACpB,OAAO,MAAMP,qBAAqB,CAACC,4BAA4B,CAC7DC,QAAQ,EACRC,WAAW,EACXC,yBAAyB,EACzBC,kBAAkB,EAClBC,SAAS,EACT,OAAOC,yBAAyB,KAAK,QAAQ,GACzCA,yBAAyB,GACzBC,IAAI,CAACC,SAAS,CAACF,yBAAyB,CAC9C,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Schema for parsing a nativeStackAndroid object of a rejected promise error in an Android native module.
7
+ */
8
+ const StackTraceElementSchema = z.object({
9
+ lineNumber: z.number(),
10
+ file: z.string(),
11
+ methodName: z.string(),
12
+ class: z.string()
13
+ });
14
+
15
+ /**
16
+ * Schema for parsing specific parameters of a rejected promise error in an Android native module.
17
+ * It's defined as partial to allow merging with the common schema and it must be checked at runtime.
18
+ */
19
+ const ModuleErrorAndroidSchema = z.object({
20
+ nativeStackAndroid: z.array(StackTraceElementSchema)
21
+ }).partial();
22
+
23
+ /**
24
+ * Schema for parsing specific parameters of a rejected promise error in an iOS native module.
25
+ * It's defined as partial to allow merging with the common schema and it must be checked at runtime.
26
+ */
27
+ const ModuleErrorIosSchema = z.object({
28
+ domain: z.string(),
29
+ nativeStackIOS: z.array(z.string())
30
+ }).partial();
31
+
32
+ /**
33
+ * Schema for parsing common parameters of a rejected promise error in a native module.
34
+ * This schema contains the common parameters that are shared across both Android and iOS native modules.
35
+ * Parameters which are platform specific are defined as optional and must be checked at runtime.
36
+ * It accepts a generic code schema to allow for different error codes which can be defined in each module.
37
+ * @param codeSchema - The Zod schema for the error codes used by the module.
38
+ * @returns A schema for the common parameters of a rejected promise error in a native module.
39
+ */
40
+ export const GenericModuleErrorSchema = codeSchema => z.object({
41
+ code: codeSchema,
42
+ message: z.string(),
43
+ name: z.string(),
44
+ userInfo: z.record(z.string(), z.any()).optional().or(z.null())
45
+ }).and(ModuleErrorAndroidSchema).and(ModuleErrorIosSchema);
46
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["z","StackTraceElementSchema","object","lineNumber","number","file","string","methodName","class","ModuleErrorAndroidSchema","nativeStackAndroid","array","partial","ModuleErrorIosSchema","domain","nativeStackIOS","GenericModuleErrorSchema","codeSchema","code","message","name","userInfo","record","any","optional","or","null","and"],"sourceRoot":"../../src","sources":["schema.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;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,wBAAwB,GAGnCC,UAAoB,IAEpBjB,CAAC,CACEE,MAAM,CAAC;EACNgB,IAAI,EAAED,UAAU;EAChBE,OAAO,EAAEnB,CAAC,CAACM,MAAM,CAAC,CAAC;EACnBc,IAAI,EAAEpB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBe,QAAQ,EAAErB,CAAC,CAACsB,MAAM,CAACtB,CAAC,CAACM,MAAM,CAAC,CAAC,EAAEN,CAAC,CAACuB,GAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,EAAE,CAACzB,CAAC,CAAC0B,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC,CACDC,GAAG,CAAClB,wBAAwB,CAAC,CAC7BkB,GAAG,CAACd,oBAAoB,CAAC","ignoreList":[]}