@pagopa/io-react-native-iso18013 0.3.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.
- package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeCborModule.kt +67 -164
- package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Module.kt +95 -140
- package/ios/Base64Utils.swift +10 -3
- package/ios/IoReactNativeCbor.swift +55 -125
- package/ios/IoReactNativeIso18013.swift +87 -116
- package/lib/module/cbor/cbor/README.md +37 -5
- package/lib/module/cbor/cbor/error.js +15 -0
- package/lib/module/cbor/cbor/error.js.map +1 -0
- package/lib/module/cbor/cbor/index.js +1 -0
- package/lib/module/cbor/cbor/index.js.map +1 -1
- package/lib/module/cbor/cose/README.md +39 -9
- package/lib/module/cbor/cose/error.js +17 -0
- package/lib/module/cbor/cose/error.js.map +1 -0
- package/lib/module/cbor/cose/index.js +1 -0
- package/lib/module/cbor/cose/index.js.map +1 -1
- package/lib/module/iso18013/index.js +0 -1
- package/lib/module/iso18013/index.js.map +1 -1
- package/lib/module/iso18013/iso18013-5/README.md +52 -16
- package/lib/module/iso18013/iso18013-5/error.js +25 -0
- package/lib/module/iso18013/iso18013-5/error.js.map +1 -0
- package/lib/module/iso18013/iso18013-5/index.js +3 -2
- package/lib/module/iso18013/iso18013-5/index.js.map +1 -1
- package/lib/module/iso18013/iso18013-5/proximity.js +1 -9
- package/lib/module/iso18013/iso18013-5/proximity.js.map +1 -1
- package/lib/module/iso18013/iso18013-5/{schema.js → request.js} +1 -20
- package/lib/module/iso18013/iso18013-5/request.js.map +1 -0
- package/lib/module/iso18013/iso18013-7/README.md +38 -9
- package/lib/module/iso18013/iso18013-7/error.js +15 -0
- package/lib/module/iso18013/iso18013-7/error.js.map +1 -0
- package/lib/module/iso18013/iso18013-7/index.js +1 -0
- package/lib/module/iso18013/iso18013-7/index.js.map +1 -1
- package/lib/module/iso18013/iso18013-7/remote.js +0 -12
- package/lib/module/iso18013/iso18013-7/remote.js.map +1 -1
- package/lib/module/schema.js +46 -0
- package/lib/module/schema.js.map +1 -0
- package/lib/typescript/src/cbor/cbor/error.d.ts +68 -0
- package/lib/typescript/src/cbor/cbor/error.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cbor/index.d.ts +1 -1
- package/lib/typescript/src/cbor/cbor/index.d.ts.map +1 -1
- package/lib/typescript/src/cbor/cose/error.d.ts +68 -0
- package/lib/typescript/src/cbor/cose/error.d.ts.map +1 -0
- package/lib/typescript/src/cbor/cose/index.d.ts +1 -1
- package/lib/typescript/src/cbor/cose/index.d.ts.map +1 -1
- package/lib/typescript/src/iso18013/index.d.ts +0 -1
- package/lib/typescript/src/iso18013/index.d.ts.map +1 -1
- package/lib/typescript/src/iso18013/iso18013-5/error.d.ts +73 -0
- package/lib/typescript/src/iso18013/iso18013-5/error.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-5/index.d.ts +3 -2
- package/lib/typescript/src/iso18013/iso18013-5/index.d.ts.map +1 -1
- package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts +2 -7
- package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts.map +1 -1
- package/lib/typescript/src/iso18013/iso18013-5/{schema.d.ts → request.d.ts} +1 -16
- package/lib/typescript/src/iso18013/iso18013-5/request.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-7/error.d.ts +68 -0
- package/lib/typescript/src/iso18013/iso18013-7/error.d.ts.map +1 -0
- package/lib/typescript/src/iso18013/iso18013-7/index.d.ts +2 -1
- package/lib/typescript/src/iso18013/iso18013-7/index.d.ts.map +1 -1
- package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts +0 -14
- package/lib/typescript/src/iso18013/iso18013-7/remote.d.ts.map +1 -1
- package/lib/typescript/src/schema.d.ts +76 -0
- package/lib/typescript/src/schema.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/cbor/cbor/README.md +37 -5
- package/src/cbor/cbor/error.ts +23 -0
- package/src/cbor/cbor/index.ts +5 -1
- package/src/cbor/cose/README.md +39 -9
- package/src/cbor/cose/error.ts +23 -0
- package/src/cbor/cose/index.ts +5 -1
- package/src/iso18013/index.ts +0 -7
- package/src/iso18013/iso18013-5/README.md +52 -16
- package/src/iso18013/iso18013-5/error.ts +35 -0
- package/src/iso18013/iso18013-5/index.ts +9 -4
- package/src/iso18013/iso18013-5/proximity.ts +2 -10
- package/src/iso18013/iso18013-5/{schema.ts → request.ts} +0 -20
- package/src/iso18013/iso18013-7/README.md +38 -9
- package/src/iso18013/iso18013-7/error.ts +21 -0
- package/src/iso18013/iso18013-7/index.ts +5 -4
- package/src/iso18013/iso18013-7/remote.ts +0 -20
- package/src/schema.ts +55 -0
- package/lib/module/cbor/cbor/failure.js +0 -2
- package/lib/module/cbor/cbor/failure.js.map +0 -1
- package/lib/module/cbor/cose/failure.js +0 -2
- package/lib/module/cbor/cose/failure.js.map +0 -1
- package/lib/module/iso18013/iso18013-5/schema.js.map +0 -1
- package/lib/typescript/src/cbor/cbor/failure.d.ts +0 -15
- package/lib/typescript/src/cbor/cbor/failure.d.ts.map +0 -1
- package/lib/typescript/src/cbor/cose/failure.d.ts +0 -15
- package/lib/typescript/src/cbor/cose/failure.d.ts.map +0 -1
- package/lib/typescript/src/iso18013/iso18013-5/schema.d.ts.map +0 -1
- package/src/cbor/cbor/failure.ts +0 -18
- package/src/cbor/cose/failure.ts +0 -20
|
@@ -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 `
|
|
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', () =>
|
|
26
|
+
const listener = ISO18013_5.addListener('event', () =>
|
|
27
|
+
console.log('event occurred')
|
|
28
|
+
);
|
|
27
29
|
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
233
|
-
|
|
|
234
|
-
|
|
|
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,35 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { GenericModuleErrorSchema } from '../../schema';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Schema for parsing the payload returned by the `onError` event in Proximity `Events`, along with its type definition.
|
|
6
|
+
*/
|
|
7
|
+
export const OnErrorPayloadSchema = z.string().catch('Unknown error');
|
|
8
|
+
|
|
9
|
+
export type OnErrorPayload = z.infer<typeof OnErrorPayloadSchema>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Error codes which the ISO18013_5 module uses to reject a promise.
|
|
13
|
+
*/
|
|
14
|
+
const ModuleErrorCodesSchema = z.enum([
|
|
15
|
+
'DRH_NOT_DEFINED', // Android only
|
|
16
|
+
'QR_ENGAGEMENT_NOT_DEFINED', // Android only
|
|
17
|
+
'START_ERROR',
|
|
18
|
+
'GET_QR_CODE_ERROR',
|
|
19
|
+
'SEND_RESPONSE_ERROR',
|
|
20
|
+
'SEND_ERROR_RESPONSE_ERROR',
|
|
21
|
+
'GENERATE_RESPONSE_ERROR',
|
|
22
|
+
'CLOSE_ERROR', // Android only
|
|
23
|
+
'EUNSPECIFIED', // Android only default when no other error is specified
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
export type ModuleErrorCodes = z.infer<typeof ModuleErrorCodesSchema>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Schema which can be used to parse a rejected promise error by the ISO18013_5 module.
|
|
30
|
+
*/
|
|
31
|
+
export const ModuleErrorSchema = GenericModuleErrorSchema(
|
|
32
|
+
ModuleErrorCodesSchema
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export type ModuleError = z.infer<typeof ModuleErrorSchema>;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export {
|
|
2
2
|
type AcceptedFields,
|
|
3
|
-
type EventError,
|
|
4
3
|
type VerifierRequest,
|
|
5
|
-
parseEventError,
|
|
6
4
|
parseVerifierRequest,
|
|
7
|
-
} from './
|
|
5
|
+
} from './request';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
type OnErrorPayload,
|
|
9
|
+
OnErrorPayloadSchema,
|
|
10
|
+
ModuleErrorSchema,
|
|
11
|
+
type ModuleErrorCodes,
|
|
12
|
+
type ModuleError,
|
|
13
|
+
} from './error';
|
|
8
14
|
|
|
9
15
|
export {
|
|
10
16
|
ErrorCode,
|
|
@@ -14,7 +20,6 @@ export {
|
|
|
14
20
|
close,
|
|
15
21
|
generateResponse,
|
|
16
22
|
getQrCodeString,
|
|
17
|
-
removeListener,
|
|
18
23
|
sendErrorResponse,
|
|
19
24
|
sendResponse,
|
|
20
25
|
start,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
+
import type { AcceptedFields } from './request';
|
|
2
3
|
import { IoReactNativeIso18013 } from '..';
|
|
3
|
-
import type { AcceptedFields } from './schema';
|
|
4
4
|
import type { RequestedDocument } from '../types';
|
|
5
5
|
|
|
6
6
|
const eventEmitter = new NativeEventEmitter(IoReactNativeIso18013);
|
|
@@ -122,13 +122,5 @@ export function addListener<E extends Events>(
|
|
|
122
122
|
event: E,
|
|
123
123
|
callback: (data: EventsPayload[E]) => void
|
|
124
124
|
) {
|
|
125
|
-
eventEmitter.addListener(event, callback);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Removes a listener for a `QrEngagementEvents` event.
|
|
130
|
-
* @param event - The event to remove the listener for. The available events are defined in the `QrEngagementEvents` type.
|
|
131
|
-
*/
|
|
132
|
-
export function removeListener(event: Events) {
|
|
133
|
-
eventEmitter.removeAllListeners(event);
|
|
125
|
+
return eventEmitter.addListener(event, callback);
|
|
134
126
|
}
|
|
@@ -44,26 +44,6 @@ export const parseVerifierRequest = (input: unknown): VerifierRequest => {
|
|
|
44
44
|
return VerifierRequest.parse(input);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* Zod schema for the type returned by the `onError` event in Proximity `Events`.
|
|
49
|
-
*/
|
|
50
|
-
const EventError = z.string().catch('Unknown error');
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Error type returned by the `onError` event in Proximity `Events`.
|
|
54
|
-
*/
|
|
55
|
-
export type EventError = z.infer<typeof EventError>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Parses the input to an Error object.
|
|
59
|
-
* This function is used to parse the error received from the verifier app via the `onError` event.
|
|
60
|
-
* @param input - The input to be parsed
|
|
61
|
-
* @returns The parsed Error object or a default error message if parsing fails
|
|
62
|
-
*/
|
|
63
|
-
export const parseEventError = (input: unknown): EventError => {
|
|
64
|
-
return EventError.parse(input);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
47
|
/**
|
|
68
48
|
* This is the type definition for the accepted fields that will be presented to the verifier app.
|
|
69
49
|
* It contains of a nested object structure, where the outermost key represents the credential doctype.
|
|
@@ -48,12 +48,41 @@ export const generateOID4VPDeviceResponse = async (
|
|
|
48
48
|
) : Promise<string> => {...};
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
59
|
-
|
|
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,21 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { GenericModuleErrorSchema } from '../../schema';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Error codes which the ISO18013_7 module uses to reject a promise.
|
|
6
|
+
*/
|
|
7
|
+
const ModuleErrorCodesSchema = z.enum([
|
|
8
|
+
'GENERATE_OID4VP_RESPONSE_ERROR',
|
|
9
|
+
'EUNSPECIFIED', // Android only default when no other error is specified
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
export type ModuleErrorCodes = z.infer<typeof ModuleErrorCodesSchema>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Schema which can be used to parse a rejected promise error by the ISO18013_7 module.
|
|
16
|
+
*/
|
|
17
|
+
export const ModuleErrorSchema = GenericModuleErrorSchema(
|
|
18
|
+
ModuleErrorCodesSchema
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export type ModuleError = z.infer<typeof ModuleErrorSchema>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { generateOID4VPDeviceResponse } from './remote';
|
|
1
2
|
export {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
} from './
|
|
3
|
+
ModuleErrorSchema,
|
|
4
|
+
type ModuleError,
|
|
5
|
+
type ModuleErrorCodes,
|
|
6
|
+
} from './error';
|
|
6
7
|
|
|
7
8
|
export { type RequestedDocument } from '../types';
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
import { IoReactNativeIso18013 } from '..';
|
|
2
2
|
import type { RequestedDocument } from '../types';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* All error codes that the module could return.
|
|
6
|
-
*/
|
|
7
|
-
export type OID4VPFailureCodes =
|
|
8
|
-
| 'UNABLE_TO_GENERATE_RESPONSE'
|
|
9
|
-
| 'UNABLE_TO_GENERATE_TRANSCRIPT'
|
|
10
|
-
| 'INVALID_DOC_REQUESTED'
|
|
11
|
-
| 'GENERATE_OID4VP_DEVICE_RESPONSE_FAILED';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Error type returned by a rejected promise.
|
|
15
|
-
*
|
|
16
|
-
* If additional error information are available,
|
|
17
|
-
* they are stored in the {@link OID4VPFailure["userInfo"]} field.
|
|
18
|
-
*/
|
|
19
|
-
export type OID4VPFailure = {
|
|
20
|
-
message: OID4VPFailureCodes;
|
|
21
|
-
userInfo: Record<string, string>;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
4
|
/**
|
|
25
5
|
*
|
|
26
6
|
* @param clientId extracted from OID4VP session
|
package/src/schema.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Schema for parsing a nativeStackAndroid object of a rejected promise error in an Android native module.
|
|
5
|
+
*/
|
|
6
|
+
const StackTraceElementSchema = z.object({
|
|
7
|
+
lineNumber: z.number(),
|
|
8
|
+
file: z.string(),
|
|
9
|
+
methodName: z.string(),
|
|
10
|
+
class: z.string(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Schema for parsing specific parameters of a rejected promise error in an Android native module.
|
|
15
|
+
* It's defined as partial to allow merging with the common schema and it must be checked at runtime.
|
|
16
|
+
*/
|
|
17
|
+
const ModuleErrorAndroidSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
nativeStackAndroid: z.array(StackTraceElementSchema),
|
|
20
|
+
})
|
|
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
|
|
28
|
+
.object({
|
|
29
|
+
domain: z.string(),
|
|
30
|
+
nativeStackIOS: z.array(z.string()),
|
|
31
|
+
})
|
|
32
|
+
.partial();
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Schema for parsing common parameters of a rejected promise error in a native module.
|
|
36
|
+
* This schema contains the common parameters that are shared across both Android and iOS native modules.
|
|
37
|
+
* Parameters which are platform specific are defined as optional and must be checked at runtime.
|
|
38
|
+
* It accepts a generic code schema to allow for different error codes which can be defined in each module.
|
|
39
|
+
* @param codeSchema - The Zod schema for the error codes used by the module.
|
|
40
|
+
* @returns A schema for the common parameters of a rejected promise error in a native module.
|
|
41
|
+
*/
|
|
42
|
+
export const GenericModuleErrorSchema = <
|
|
43
|
+
CodeType extends z.ZodEnum<[string, ...string[]]>,
|
|
44
|
+
>(
|
|
45
|
+
codeSchema: CodeType
|
|
46
|
+
) =>
|
|
47
|
+
z
|
|
48
|
+
.object({
|
|
49
|
+
code: codeSchema,
|
|
50
|
+
message: z.string(),
|
|
51
|
+
name: z.string(),
|
|
52
|
+
userInfo: z.record(z.string(), z.any()).optional().or(z.null()),
|
|
53
|
+
})
|
|
54
|
+
.and(ModuleErrorAndroidSchema)
|
|
55
|
+
.and(ModuleErrorIosSchema);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["cbor/cbor/failure.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["cbor/cose/failure.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["z","booleanFieldGroup","record","boolean","credentialEntrySchema","object","isAuthenticated","catchall","VerifierRequest","request","parseVerifierRequest","input","parse","EventError","string","catch","parseEventError"],"sourceRoot":"../../../../src","sources":["iso18013/iso18013-5/schema.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,MAAME,UAAU,GAAGb,CAAC,CAACc,MAAM,CAAC,CAAC,CAACC,KAAK,CAAC,eAAe,CAAC;;AAEpD;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAIL,KAAc,IAAiB;EAC7D,OAAOE,UAAU,CAACD,KAAK,CAACD,KAAK,CAAC;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All error codes that the module could return.
|
|
3
|
-
*/
|
|
4
|
-
export type CborFailureCodes = 'UNABLE_TO_DECODE' | 'INVALID_ENCODING' | '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 CborFailure["userInfo"]} field.
|
|
10
|
-
*/
|
|
11
|
-
export type CborFailure = {
|
|
12
|
-
message: CborFailureCodes;
|
|
13
|
-
userInfo: Record<string, string>;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=failure.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../../../../../src/cbor/cbor/failure.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/cbor/cbor/failure.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All error codes that the module could return.
|
|
3
|
-
*/
|
|
4
|
-
export type CborFailureCodes =
|
|
5
|
-
| 'UNABLE_TO_DECODE'
|
|
6
|
-
| 'INVALID_ENCODING'
|
|
7
|
-
| 'UNKNOWN_EXCEPTION';
|
|
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 CborFailure["userInfo"]} field.
|
|
14
|
-
*/
|
|
15
|
-
export type CborFailure = {
|
|
16
|
-
message: CborFailureCodes;
|
|
17
|
-
userInfo: Record<string, string>;
|
|
18
|
-
};
|
package/src/cbor/cose/failure.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All error codes that the module could return.
|
|
3
|
-
*/
|
|
4
|
-
export type CoseFailureCodes =
|
|
5
|
-
| 'PUBLIC_KEY_NOT_FOUND'
|
|
6
|
-
| 'UNABLE_TO_SIGN'
|
|
7
|
-
| 'INVALID_ENCODING'
|
|
8
|
-
| 'THREADING_ERROR'
|
|
9
|
-
| 'UNKNOWN_EXCEPTION';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Error type returned by a rejected promise.
|
|
13
|
-
*
|
|
14
|
-
* If additional error information are available,
|
|
15
|
-
* they are stored in the {@link CoseError["userInfo"]} field.
|
|
16
|
-
*/
|
|
17
|
-
export type CoseFailure = {
|
|
18
|
-
message: CoseFailureCodes;
|
|
19
|
-
userInfo: Record<string, string>;
|
|
20
|
-
};
|