@pagopa/io-react-native-iso18013 0.1.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 (113) hide show
  1. package/IoReactNativeIso18013.podspec +29 -0
  2. package/LICENSE +20 -0
  3. package/README.md +30 -0
  4. package/android/build.gradle +83 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/ioreactnativeiso18013/Base64Utils.kt +56 -0
  9. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeCborModule.kt +209 -0
  10. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Module.kt +439 -0
  11. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Package.kt +17 -0
  12. package/ios/Base64Utils.swift +47 -0
  13. package/ios/IoReactNativeCbor.mm +32 -0
  14. package/ios/IoReactNativeCbor.swift +188 -0
  15. package/ios/IoReactNativeIso18013-Bridging-Header.h +2 -0
  16. package/ios/IoReactNativeIso18013.mm +43 -0
  17. package/ios/IoReactNativeIso18013.swift +491 -0
  18. package/lib/module/cbor/cbor/README.md +95 -0
  19. package/lib/module/cbor/cbor/decoder.js +51 -0
  20. package/lib/module/cbor/cbor/decoder.js.map +1 -0
  21. package/lib/module/cbor/cbor/failure.js +2 -0
  22. package/lib/module/cbor/cbor/failure.js.map +1 -0
  23. package/lib/module/cbor/cbor/index.js +5 -0
  24. package/lib/module/cbor/cbor/index.js.map +1 -0
  25. package/lib/module/cbor/cbor/schema.js +117 -0
  26. package/lib/module/cbor/cbor/schema.js.map +1 -0
  27. package/lib/module/cbor/cbor/schema.utils.js +16 -0
  28. package/lib/module/cbor/cbor/schema.utils.js.map +1 -0
  29. package/lib/module/cbor/cose/README.md +53 -0
  30. package/lib/module/cbor/cose/failure.js +2 -0
  31. package/lib/module/cbor/cose/failure.js.map +1 -0
  32. package/lib/module/cbor/cose/index.js +4 -0
  33. package/lib/module/cbor/cose/index.js.map +1 -0
  34. package/lib/module/cbor/cose/sign.js +23 -0
  35. package/lib/module/cbor/cose/sign.js.map +1 -0
  36. package/lib/module/cbor/index.js +13 -0
  37. package/lib/module/cbor/index.js.map +1 -0
  38. package/lib/module/index.js +8 -0
  39. package/lib/module/index.js.map +1 -0
  40. package/lib/module/iso18013/index.js +14 -0
  41. package/lib/module/iso18013/index.js.map +1 -0
  42. package/lib/module/iso18013/iso18013-5/README.md +234 -0
  43. package/lib/module/iso18013/iso18013-5/index.js +5 -0
  44. package/lib/module/iso18013/iso18013-5/index.js.map +1 -0
  45. package/lib/module/iso18013/iso18013-5/proximity.js +112 -0
  46. package/lib/module/iso18013/iso18013-5/proximity.js.map +1 -0
  47. package/lib/module/iso18013/iso18013-5/schema.js +79 -0
  48. package/lib/module/iso18013/iso18013-5/schema.js.map +1 -0
  49. package/lib/module/iso18013/iso18013-7/README.md +59 -0
  50. package/lib/module/iso18013/iso18013-7/index.js +4 -0
  51. package/lib/module/iso18013/iso18013-7/index.js.map +1 -0
  52. package/lib/module/iso18013/iso18013-7/remote.js +31 -0
  53. package/lib/module/iso18013/iso18013-7/remote.js.map +1 -0
  54. package/lib/module/iso18013/types.js +2 -0
  55. package/lib/module/iso18013/types.js.map +1 -0
  56. package/lib/module/package.json +1 -0
  57. package/lib/typescript/package.json +1 -0
  58. package/lib/typescript/src/cbor/cbor/decoder.d.ts +35 -0
  59. package/lib/typescript/src/cbor/cbor/decoder.d.ts.map +1 -0
  60. package/lib/typescript/src/cbor/cbor/failure.d.ts +15 -0
  61. package/lib/typescript/src/cbor/cbor/failure.d.ts.map +1 -0
  62. package/lib/typescript/src/cbor/cbor/index.d.ts +4 -0
  63. package/lib/typescript/src/cbor/cbor/index.d.ts.map +1 -0
  64. package/lib/typescript/src/cbor/cbor/schema.d.ts +2420 -0
  65. package/lib/typescript/src/cbor/cbor/schema.d.ts.map +1 -0
  66. package/lib/typescript/src/cbor/cbor/schema.utils.d.ts +8 -0
  67. package/lib/typescript/src/cbor/cbor/schema.utils.d.ts.map +1 -0
  68. package/lib/typescript/src/cbor/cose/failure.d.ts +15 -0
  69. package/lib/typescript/src/cbor/cose/failure.d.ts.map +1 -0
  70. package/lib/typescript/src/cbor/cose/index.d.ts +3 -0
  71. package/lib/typescript/src/cbor/cose/index.d.ts.map +1 -0
  72. package/lib/typescript/src/cbor/cose/sign.d.ts +19 -0
  73. package/lib/typescript/src/cbor/cose/sign.d.ts.map +1 -0
  74. package/lib/typescript/src/cbor/index.d.ts +2 -0
  75. package/lib/typescript/src/cbor/index.d.ts.map +1 -0
  76. package/lib/typescript/src/index.d.ts +6 -0
  77. package/lib/typescript/src/index.d.ts.map +1 -0
  78. package/lib/typescript/src/iso18013/index.d.ts +3 -0
  79. package/lib/typescript/src/iso18013/index.d.ts.map +1 -0
  80. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts +4 -0
  81. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts.map +1 -0
  82. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts +88 -0
  83. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts.map +1 -0
  84. package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts +85 -0
  85. package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts.map +1 -0
  86. package/lib/typescript/src/iso18013/iso18013-7/index.d.ts +3 -0
  87. package/lib/typescript/src/iso18013/iso18013-7/index.d.ts.map +1 -0
  88. package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts +29 -0
  89. package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts.map +1 -0
  90. package/lib/typescript/src/iso18013/types.d.ts +16 -0
  91. package/lib/typescript/src/iso18013/types.d.ts.map +1 -0
  92. package/package.json +163 -0
  93. package/src/cbor/cbor/README.md +95 -0
  94. package/src/cbor/cbor/decoder.ts +56 -0
  95. package/src/cbor/cbor/failure.ts +18 -0
  96. package/src/cbor/cbor/index.ts +9 -0
  97. package/src/cbor/cbor/schema.ts +150 -0
  98. package/src/cbor/cbor/schema.utils.ts +13 -0
  99. package/src/cbor/cose/README.md +53 -0
  100. package/src/cbor/cose/failure.ts +20 -0
  101. package/src/cbor/cose/index.ts +2 -0
  102. package/src/cbor/cose/sign.ts +25 -0
  103. package/src/cbor/index.ts +18 -0
  104. package/src/index.tsx +5 -0
  105. package/src/iso18013/index.ts +25 -0
  106. package/src/iso18013/iso18013-5/README.md +234 -0
  107. package/src/iso18013/iso18013-5/index.ts +23 -0
  108. package/src/iso18013/iso18013-5/proximity.ts +134 -0
  109. package/src/iso18013/iso18013-5/schema.ts +87 -0
  110. package/src/iso18013/iso18013-7/README.md +59 -0
  111. package/src/iso18013/iso18013-7/index.ts +7 -0
  112. package/src/iso18013/iso18013-7/remote.ts +54 -0
  113. package/src/iso18013/types.ts +16 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cbor/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,oBAAY,gBAAgB;IAC1B,GAAG,0BAA0B;IAC7B,MAAM,4BAA4B;CACnC;AAED,eAAO,MAAM,YAAY,0CAAiC,CAAC;AAC3D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAItC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,2BAA2B,CACnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;EAKxC,CAAC;AAE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CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * If the value is a string, parse it as JSON.
4
+ * Otherwise, return the value as is.
5
+ * Useful for unescaping stringified JSON content
6
+ */
7
+ export declare const coerceToJSON: z.ZodEffects<z.ZodAny, any, any>;
8
+ //# sourceMappingURL=schema.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cbor/schema.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,YAAY,kCAKvB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * All error codes that the module could return.
3
+ */
4
+ export type CoseFailureCodes = 'PUBLIC_KEY_NOT_FOUND' | 'UNABLE_TO_SIGN' | 'INVALID_ENCODING' | 'THREADING_ERROR' | 'UNKNOWN_EXCEPTION';
5
+ /**
6
+ * Error type returned by a rejected promise.
7
+ *
8
+ * If additional error information are available,
9
+ * they are stored in the {@link CoseError["userInfo"]} field.
10
+ */
11
+ export type CoseFailure = {
12
+ message: CoseFailureCodes;
13
+ userInfo: Record<string, string>;
14
+ };
15
+ //# sourceMappingURL=failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cose/failure.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,CAAC;AAExB;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { sign, verify } from './sign';
2
+ export { type CoseFailure, type CoseFailureCodes } from './failure';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cose/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { PublicKey } from '@pagopa/io-react-native-crypto';
2
+ /**
3
+ * Sign base64 encoded data with COSE and return the COSE-Sign1 object in base64 encoding
4
+ *
5
+ * @param payload - The base64 or base64url encoded payload to sign
6
+ * @param keyTag - The alias of the key to use for signing.
7
+ * @throws {CoseFailure} If the key does not exist
8
+ * @returns The COSE-Sign1 object in base64 encoding
9
+ */
10
+ export declare const sign: (payload: string, keyTag: string) => Promise<string>;
11
+ /**
12
+ * Verifies a COSE-Sign1 object with the provided public key
13
+ *
14
+ * @param data - The COSE-Sign1 object in base64 or base64url encoding
15
+ * @param publicKey - The public key in JWK format
16
+ * @returns true if the signature is valid, false otherwise
17
+ */
18
+ export declare const verify: (data: string, publicKey: PublicKey) => Promise<boolean>;
19
+ //# sourceMappingURL=sign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cose/sign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAGhE;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAU,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,CAC5B,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GACjB,MAAM,MAAM,EACZ,WAAW,SAAS,KACnB,OAAO,CAAC,OAAO,CAAoD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const IoReactNativeCbor: any;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cbor/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,KASzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as CBOR from './cbor/cbor';
2
+ import * as COSE from './cbor/cose';
3
+ import * as ISO18013_5 from './iso18013/iso18013-5';
4
+ import * as ISO18013_7 from './iso18013/iso18013-7';
5
+ export { CBOR, COSE, ISO18013_5, ISO18013_7 };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { type AcceptedFields, type EventError, type VerifierRequest, parseEventError, parseVerifierRequest, } from './iso18013-5/schema';
2
+ export declare const IoReactNativeProximity: any;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/iso18013/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,eAAe,EACf,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAQ7B,eAAO,MAAM,sBAAsB,KAS9B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { type AcceptedFields, type EventError, type VerifierRequest, parseEventError, parseVerifierRequest, } from './schema';
2
+ export { ErrorCode, type Events, type EventsPayload, addListener, close, generateResponse, getQrCodeString, removeListener, sendErrorResponse, sendResponse, start, } from './proximity';
3
+ export { type RequestedDocument } from '../types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/iso18013/iso18013-5/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,eAAe,EACf,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,SAAS,EACT,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,KAAK,GACN,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,88 @@
1
+ import type { AcceptedFields } from './schema';
2
+ import type { RequestedDocument } from '../types';
3
+ /**
4
+ * Events emitted by the native module:
5
+ * - `onDeviceConnecting`: (iOS only) Emitted when the device is connecting to the verifier app.
6
+ * - `onDeviceConnected`: Emitted when the device is connected to the verifier app.
7
+ * - `onDocumentRequestReceived`: Emitted when a document request is received from the verifier app. Carries a payload containing the request data.
8
+ * - `onDeviceDisconnected`: Emitted when the device is disconnected from the verifier app.
9
+ * - `onError`: Emitted when an error occurs. Carries a payload containing the error data.
10
+ */
11
+ export type EventsPayload = {
12
+ onDeviceConnecting: undefined;
13
+ onDeviceConnected: undefined;
14
+ onDocumentRequestReceived: {
15
+ data?: string;
16
+ } | undefined;
17
+ onDeviceDisconnected: undefined;
18
+ onError: {
19
+ error?: string;
20
+ } | undefined;
21
+ };
22
+ /**
23
+ * Events emitted by the native module.
24
+ */
25
+ export type Events = keyof EventsPayload;
26
+ /**
27
+ * Error codes that can be used with the `sendErrorResponse` method.
28
+ * These are defined based on the SessionData status code defined in the table 20 of the ISO 18013-5 standard
29
+ * and mirror codes defined in the native module.
30
+ */
31
+ export declare enum ErrorCode {
32
+ SESSION_ENCRYPTION = 10,
33
+ CBOR_DECODING = 11,
34
+ SESSION_TERMINATED = 20
35
+ }
36
+ /**
37
+ * Starts the proximity flow by allocating the necessary resources and initializing the Bluetooth stack.
38
+ * @param config.peripheralMode (Android only) - Whether the device is in peripheral mode. Defaults to true
39
+ * @param config.centralClientMode (Android only) - Whether the device is in central client mode. Defaults to false
40
+ * @param config.clearBleCache (Android only) - Whether the BLE cache should be cleared. Defaults to true
41
+ * @param config.certificates - Array of base64 representing DER encoded X.509 certificate which are used to authenticate the verifier app
42
+ */
43
+ export declare function start(config?: {
44
+ peripheralMode?: boolean;
45
+ centralClientMode?: boolean;
46
+ clearBleCache?: boolean;
47
+ certificates?: string[];
48
+ }): Promise<boolean>;
49
+ /**
50
+ * Gets the QR code string this method is responsible for initializing the connection and retrieving the QR code string
51
+ */
52
+ export declare function getQrCodeString(): Promise<string>;
53
+ /**
54
+ * Closes the QR engagement
55
+ */
56
+ export declare function close(): Promise<boolean>;
57
+ /**
58
+ * Sends an error response to the verifier app.
59
+ * The error code must be one of the `ErrorCode` enum values.
60
+ * @param code - The error code to be sent to the verifier app.
61
+ */
62
+ export declare function sendErrorResponse(code: ErrorCode): Promise<boolean>;
63
+ /**
64
+ * Generates a response that will be sent to the verifier app containing the requested data
65
+ * @param documents - An array of `Document` which contains the requested data received from the `onDocumentRequestReceived` event
66
+ * @param acceptedFields - The accepted fields which will be presented to the verifier app. See the type definition for more details.
67
+ * @returns A base64 encoded response to be sent to the verifier app via `sendResponse`
68
+ */
69
+ export declare function generateResponse(documents: Array<RequestedDocument>, acceptedFields: AcceptedFields): Promise<string>;
70
+ /**
71
+ * Sends the response generated through the `generateResponse` method to the verifier app.
72
+ * Currently there's not evidence of the verifier app responding to this request, thus we don't handle the response.
73
+ * @param response - The base64 encoded response to be sent to the verifier app.
74
+ */
75
+ export declare function sendResponse(response: string): Promise<boolean>;
76
+ /**
77
+ * Adds a listener for a `QrEngagementEvents` event which will be emitted by the native module.
78
+ * The callback will be called with the event payload when the event is emitted.
79
+ * @param event - The event to listen for. The available events are defined in the `QrEngagementEvents` type.
80
+ * @param callback - The callback to be called when the event is emitted. The callback will receive the event payload as an argument.
81
+ */
82
+ export declare function addListener<E extends Events>(event: E, callback: (data: EventsPayload[E]) => void): void;
83
+ /**
84
+ * Removes a listener for a `QrEngagementEvents` event.
85
+ * @param event - The event to remove the listener for. The available events are defined in the `QrEngagementEvents` type.
86
+ */
87
+ export declare function removeListener(event: Events): void;
88
+ //# sourceMappingURL=proximity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proximity.d.ts","sourceRoot":"","sources":["../../../../../src/iso18013/iso18013-5/proximity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,kBAAkB,EAAE,SAAS,CAAC;IAC9B,iBAAiB,EAAE,SAAS,CAAC;IAE7B,yBAAyB,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACzD,oBAAoB,EAAE,SAAS,CAAC;IAChC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,oBAAY,SAAS;IACnB,kBAAkB,KAAK;IACvB,aAAa,KAAK;IAClB,kBAAkB,KAAK;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,MAAM,GAAE;IACN,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACL,OAAO,CAAC,OAAO,CAAC,CAalB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAEjD;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAExC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,EACnC,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC1C,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,QAG3C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,QAE3C"}
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ declare const VerifierRequest: z.ZodObject<{
3
+ request: z.ZodRecord<z.ZodString, z.ZodObject<{
4
+ isAuthenticated: z.ZodBoolean;
5
+ }, "strip", z.ZodRecord<z.ZodString, z.ZodBoolean>, z.objectOutputType<{
6
+ isAuthenticated: z.ZodBoolean;
7
+ }, z.ZodRecord<z.ZodString, z.ZodBoolean>, "strip">, z.objectInputType<{
8
+ isAuthenticated: z.ZodBoolean;
9
+ }, z.ZodRecord<z.ZodString, z.ZodBoolean>, "strip">>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ request: Record<string, z.objectOutputType<{
12
+ isAuthenticated: z.ZodBoolean;
13
+ }, z.ZodRecord<z.ZodString, z.ZodBoolean>, "strip">>;
14
+ }, {
15
+ request: Record<string, z.objectInputType<{
16
+ isAuthenticated: z.ZodBoolean;
17
+ }, z.ZodRecord<z.ZodString, z.ZodBoolean>, "strip">>;
18
+ }>;
19
+ /**
20
+ * VerifierRequest type returned by the `onDocumentRequestReceived` event in `Events`.
21
+ * The outermost key represents the credential doctype, the inner key represents the namespace and the innermost key represents the requested fields with a boolean value
22
+ * indicating whether the verifier app wants to retain the field or not. The isAuthenticated field is present for each requested credentials and indicates wether or not the verifier is authenticated.
23
+ * Example:
24
+ * `{
25
+ * "org.iso.18013.5.1.mDL": {
26
+ * "isAuthenticated": true,
27
+ * "org.iso.18013.5.1": {
28
+ * "hair_colour": true,
29
+ * "given_name_national_character": true,
30
+ * "family_name_national_character": true,
31
+ * "given_name": true,
32
+ * }
33
+ * }
34
+ * }`
35
+ * The request type can be also be used as input for the `generateResponse` method. The structure is the same, however the boolean value for each claim
36
+ * indicates the willing to present the claim.
37
+ */
38
+ export type VerifierRequest = z.infer<typeof VerifierRequest>;
39
+ /**
40
+ * Parses the input to a VerifierRequest object.
41
+ * This function is used to parse the request received from the verifier app.
42
+ * @param input - The input to be parsed
43
+ * @returns The parsed VerifierRequest object
44
+ */
45
+ export declare const parseVerifierRequest: (input: unknown) => VerifierRequest;
46
+ /**
47
+ * Zod schema for the type returned by the `onError` event in Proximity `Events`.
48
+ */
49
+ declare const EventError: z.ZodCatch<z.ZodString>;
50
+ /**
51
+ * Error type returned by the `onError` event in Proximity `Events`.
52
+ */
53
+ export type EventError = z.infer<typeof EventError>;
54
+ /**
55
+ * Parses the input to an Error object.
56
+ * This function is used to parse the error received from the verifier app via the `onError` event.
57
+ * @param input - The input to be parsed
58
+ * @returns The parsed Error object or a default error message if parsing fails
59
+ */
60
+ export declare const parseEventError: (input: unknown) => EventError;
61
+ /**
62
+ * This is the type definition for the accepted fields that will be presented to the verifier app.
63
+ * It contains of a nested object structure, where the outermost key represents the credential doctype.
64
+ * The inner dictionary contains namespaces, and for each namespace, there is another dictionary mapping requested claims to a boolean value,
65
+ * which indicates whether the user is willing to present the corresponding claim. Example:
66
+ * `{
67
+ * "org.iso.18013.5.1.mDL": {
68
+ * "org.iso.18013.5.1": {
69
+ * "hair_colour": true, // Indicates the user is willing to present this claim
70
+ * "given_name_national_character": true,
71
+ * "family_name_national_character": true,
72
+ * "given_name": true,
73
+ * }
74
+ * }
75
+ * }`
76
+ **/
77
+ export type AcceptedFields = {
78
+ [credential: string]: {
79
+ [namespace: string]: {
80
+ [field: string]: boolean;
81
+ };
82
+ };
83
+ };
84
+ export {};
85
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/iso18013/iso18013-5/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;EAEnB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,eAErD,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,UAAU,yBAAoC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,UAEhD,CAAC;AAEF;;;;;;;;;;;;;;;IAeI;AACJ,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,UAAU,EAAE,MAAM,GAAG;QACpB,CAAC,SAAS,EAAE,MAAM,GAAG;YAAE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;KACnD,CAAC;CACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { generateOID4VPDeviceResponse, type OID4VPFailure, type OID4VPFailureCodes, } from './remote';
2
+ export { type RequestedDocument } from '../types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/iso18013/iso18013-7/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { RequestedDocument } from '../types';
2
+ /**
3
+ * All error codes that the module could return.
4
+ */
5
+ export type OID4VPFailureCodes = 'UNABLE_TO_GENERATE_RESPONSE' | 'UNABLE_TO_GENERATE_TRANSCRIPT' | 'INVALID_DOC_REQUESTED' | 'GENERATE_OID4VP_DEVICE_RESPONSE_FAILED';
6
+ /**
7
+ * Error type returned by a rejected promise.
8
+ *
9
+ * If additional error information are available,
10
+ * they are stored in the {@link OID4VPFailure["userInfo"]} field.
11
+ */
12
+ export type OID4VPFailure = {
13
+ message: OID4VPFailureCodes;
14
+ userInfo: Record<string, string>;
15
+ };
16
+ /**
17
+ *
18
+ * @param clientId extracted from OID4VP session
19
+ * @param responseUri extracted from OID4VP session
20
+ * @param authorizationRequestNonce extracted from OID4VP session
21
+ * @param mdocGeneratedNonce To be generated
22
+ * @param documents An Array of {@link DocRequested}
23
+ * @param fieldRequestedAndAccepted extracted from OID4VP session, it's a record of claims
24
+ * accepted for disclosure or its stringification
25
+ * @throws {OID4VPFailure} in case of failure
26
+ * @returns the Device Response in CBOR format
27
+ */
28
+ export declare const generateOID4VPDeviceResponse: (clientId: string, responseUri: string, authorizationRequestNonce: string, mdocGeneratedNonce: string, documents: Array<RequestedDocument>, fieldRequestedAndAccepted: Record<string, any> | string) => Promise<string>;
29
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../../../src/iso18013/iso18013-7/remote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,6BAA6B,GAC7B,+BAA+B,GAC/B,uBAAuB,GACvB,wCAAwC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,MAAM,EAChB,aAAa,MAAM,EACnB,2BAA2B,MAAM,EACjC,oBAAoB,MAAM,EAC1B,WAAW,KAAK,CAAC,iBAAiB,CAAC,EACnC,2BAA2B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,KACtD,OAAO,CAAC,MAAM,CAWhB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Common types definition for ISO 18013-5 and ISO 18013-7 modules.
3
+ */
4
+ /**
5
+ * Documents type to be used in the {@link generateResponse} for ISO18013-5 and {@link generateOID4VPDeviceResponse} for ISO18013-7.
6
+ * It contains:
7
+ * - issuerSignedContent which is a base64 or base64url encoded string representing the credential;
8
+ * - alias which is the alias of the key used to sign the credential;
9
+ * - docType which is the document type.
10
+ */
11
+ export type RequestedDocument = {
12
+ issuerSignedContent: string;
13
+ alias: string;
14
+ docType: string;
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/iso18013/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,163 @@
1
+ {
2
+ "name": "@pagopa/io-react-native-iso18013",
3
+ "version": "0.1.0",
4
+ "description": "React Native bridge for iso18013 methods",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace @pagopa/io-react-native-iso18013-example",
36
+ "test": "jest",
37
+ "typecheck": "tsc",
38
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
39
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
+ "prepare": "bob build",
41
+ "release": "release-it"
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "ios",
46
+ "android"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/pagopa/io-react-native-iso18013.git"
51
+ },
52
+ "author": "LazyAfternoons <iowallettech@pagopa.it> (https://github.com/pagopa)",
53
+ "license": "MIT",
54
+ "bugs": {
55
+ "url": "https://github.com/pagopa/io-react-native-iso18013/issues"
56
+ },
57
+ "homepage": "https://github.com/pagopa/io-react-native-iso18013#readme",
58
+ "publishConfig": {
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "devDependencies": {
62
+ "@commitlint/config-conventional": "^19.6.0",
63
+ "@eslint/compat": "^1.2.7",
64
+ "@eslint/eslintrc": "^3.3.0",
65
+ "@eslint/js": "^9.22.0",
66
+ "@evilmartians/lefthook": "^1.5.0",
67
+ "@pagopa/io-react-native-crypto": "1.0.1",
68
+ "@react-native/eslint-config": "^0.78.0",
69
+ "@release-it/conventional-changelog": "^9.0.2",
70
+ "@types/jest": "^29.5.5",
71
+ "@types/react": "^19.0.0",
72
+ "commitlint": "^19.6.1",
73
+ "del-cli": "^5.1.0",
74
+ "eslint": "^9.22.0",
75
+ "eslint-config-prettier": "^10.1.1",
76
+ "eslint-plugin-prettier": "^5.2.3",
77
+ "jest": "^29.7.0",
78
+ "prettier": "^3.0.3",
79
+ "react": "19.0.0",
80
+ "react-native": "0.78.2",
81
+ "react-native-builder-bob": "^0.40.12",
82
+ "release-it": "^17.10.0",
83
+ "turbo": "^1.10.7",
84
+ "typescript": "^5.2.2"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "*",
88
+ "react-native": "*"
89
+ },
90
+ "workspaces": [
91
+ "example"
92
+ ],
93
+ "packageManager": "yarn@3.6.1",
94
+ "jest": {
95
+ "preset": "react-native",
96
+ "modulePathIgnorePatterns": [
97
+ "<rootDir>/example/node_modules",
98
+ "<rootDir>/lib/"
99
+ ]
100
+ },
101
+ "commitlint": {
102
+ "extends": [
103
+ "@commitlint/config-conventional"
104
+ ],
105
+ "rules": {
106
+ "subject-case": [
107
+ 0
108
+ ]
109
+ }
110
+ },
111
+ "release-it": {
112
+ "git": {
113
+ "commitMessage": "chore: release ${version}",
114
+ "tagName": "v${version}"
115
+ },
116
+ "npm": {
117
+ "publish": true
118
+ },
119
+ "github": {
120
+ "release": true
121
+ },
122
+ "plugins": {
123
+ "@release-it/conventional-changelog": {
124
+ "preset": {
125
+ "name": "angular"
126
+ }
127
+ }
128
+ }
129
+ },
130
+ "prettier": {
131
+ "quoteProps": "consistent",
132
+ "singleQuote": true,
133
+ "tabWidth": 2,
134
+ "trailingComma": "es5",
135
+ "useTabs": false
136
+ },
137
+ "react-native-builder-bob": {
138
+ "source": "src",
139
+ "output": "lib",
140
+ "targets": [
141
+ [
142
+ "module",
143
+ {
144
+ "esm": true
145
+ }
146
+ ],
147
+ [
148
+ "typescript",
149
+ {
150
+ "project": "tsconfig.build.json"
151
+ }
152
+ ]
153
+ ]
154
+ },
155
+ "create-react-native-library": {
156
+ "type": "legacy-module",
157
+ "languages": "kotlin-swift",
158
+ "version": "0.49.8"
159
+ },
160
+ "dependencies": {
161
+ "zod": "^3.25.67"
162
+ }
163
+ }
@@ -0,0 +1,95 @@
1
+ ## CBOR
2
+
3
+ This module provides methods to decode CBOR data into readable objects.
4
+
5
+ ```typescript
6
+ import { CBOR } from '@pagopa/io-react-native-cbor';
7
+ ```
8
+
9
+ ### Methods
10
+
11
+ #### `decode`
12
+
13
+ This method allows to decode CBOR data into readable JSON objects.
14
+ Returns a `Promise` which resolves to a JSON object, or rejects with an instance of `CborFailure` in case of failure.
15
+
16
+ **Note**: this method does not decode nested CBOR objects and therefore complex objects needs additional manual decoding
17
+
18
+ ```typescript
19
+ try {
20
+ const decoded = await CBOR.decode('...');
21
+ } catch (e) {
22
+ const { message, userInfo } = e as CborFailure;
23
+ }
24
+ ```
25
+
26
+ #### `decodeDocuments`
27
+
28
+ This metod allows the decoding of CBOR data which contains MDOC objects.
29
+ Returns a promise wich resolves to a [Documents](#documents) object, or rejects with an instance of `CborFailure` in case of failure.
30
+
31
+ ```typescript
32
+ try {
33
+ const decoded = await CBOR.decodeDocuments('...');
34
+ } catch (e) {
35
+ const { message, userInfo } = e as CborFailure;
36
+ }
37
+ ```
38
+
39
+ ### Types
40
+
41
+ #### `Documents`
42
+
43
+ ```typescript
44
+ type Documents = {
45
+ status?: number;
46
+ version?: string;
47
+ documents?: Array<MDOC>;
48
+ };
49
+ ```
50
+
51
+ #### `MDOC`
52
+
53
+ ```typescript
54
+ type MDOC = {
55
+ docType?: DocumentType;
56
+ issuerSigned?: IssuerSigned;
57
+ };
58
+ ```
59
+
60
+ #### `IssuerSigned`
61
+
62
+ ```typescript
63
+ type IssuerSigned = {
64
+ nameSpaces?: Record<string, Array<DocumentValue>>;
65
+ issuerAuth?: string;
66
+ };
67
+ ```
68
+
69
+ #### `DocumentValue`
70
+
71
+ ```typescript
72
+ type DocumentValue = {
73
+ digestID?: number;
74
+ random?: string;
75
+ elementIdentifier?: string;
76
+ elementValue?: string;
77
+ };
78
+ ```
79
+
80
+ #### `DocumentType`
81
+
82
+ ```typescript
83
+ enum DocumentTypeEnum {
84
+ MDL = 'org.iso.18013.5.1.mDL',
85
+ EU_PID = 'eu.europa.ec.eudi.pid.1',
86
+ }
87
+ ```
88
+
89
+ ### Error Codes
90
+
91
+ | Type | Platform | Description |
92
+ | ----------------- | ----------- | --------------------------------------------- |
93
+ | INVALID_ENCODING | Android/iOS | Provided payload has incorrect encoding |
94
+ | UNABLE_TO_DECODE | Android/iOS | The data does not contain a valid CBOR object |
95
+ | UNKNOWN_EXCEPTION | Android/iOS | Unexpected failure |