@pagopa/io-react-native-wallet 0.24.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. package/lib/commonjs/client/generated/wallet-provider.js +39 -16
  2. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  3. package/lib/commonjs/client/index.js +25 -10
  4. package/lib/commonjs/client/index.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +1 -1
  6. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +21 -14
  7. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  8. package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -2
  9. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  10. package/lib/commonjs/credential/issuance/06-obtain-credential.js +26 -17
  11. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  12. package/lib/commonjs/credential/issuance/README.md +8 -14
  13. package/lib/commonjs/credential/issuance/errors.js +52 -0
  14. package/lib/commonjs/credential/issuance/errors.js.map +1 -0
  15. package/lib/commonjs/credential/issuance/index.js +7 -2
  16. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  17. package/lib/commonjs/credential/issuance/types.js +1 -5
  18. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  19. package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
  20. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  21. package/lib/commonjs/credential/presentation/03-get-request-object.js +2 -2
  22. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  23. package/lib/commonjs/credential/presentation/04-send-authorization-response.js +2 -2
  24. package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/errors.js +49 -0
  26. package/lib/commonjs/credential/presentation/errors.js.map +1 -0
  27. package/lib/commonjs/credential/presentation/index.js +5 -0
  28. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  29. package/lib/commonjs/credential/status/02-status-attestation.js +8 -6
  30. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
  31. package/lib/commonjs/credential/status/README.md +5 -2
  32. package/lib/commonjs/credential/status/types.js +1 -14
  33. package/lib/commonjs/credential/status/types.js.map +1 -1
  34. package/lib/commonjs/sd-jwt/errors.js +40 -0
  35. package/lib/commonjs/sd-jwt/errors.js.map +1 -0
  36. package/lib/commonjs/sd-jwt/index.js +8 -4
  37. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  38. package/lib/commonjs/sd-jwt/verifier.js +5 -1
  39. package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
  40. package/lib/commonjs/trust/index.js +2 -2
  41. package/lib/commonjs/trust/index.js.map +1 -1
  42. package/lib/commonjs/utils/decoder.js +3 -1
  43. package/lib/commonjs/utils/decoder.js.map +1 -1
  44. package/lib/commonjs/utils/error-codes.js +51 -0
  45. package/lib/commonjs/utils/error-codes.js.map +1 -0
  46. package/lib/commonjs/utils/errors.js +119 -463
  47. package/lib/commonjs/utils/errors.js.map +1 -1
  48. package/lib/commonjs/utils/misc.js +21 -14
  49. package/lib/commonjs/utils/misc.js.map +1 -1
  50. package/lib/commonjs/utils/par.js +2 -1
  51. package/lib/commonjs/utils/par.js.map +1 -1
  52. package/lib/commonjs/wallet-instance/README.md +26 -5
  53. package/lib/commonjs/wallet-instance/index.js +33 -7
  54. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  55. package/lib/commonjs/wallet-instance-attestation/README.md +8 -2
  56. package/lib/commonjs/wallet-instance-attestation/issuing.js +13 -10
  57. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  58. package/lib/module/client/generated/wallet-provider.js +31 -11
  59. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  60. package/lib/module/client/index.js +22 -8
  61. package/lib/module/client/index.js.map +1 -1
  62. package/lib/module/credential/issuance/03-start-user-authorization.js +1 -1
  63. package/lib/module/credential/issuance/04-complete-user-authorization.js +16 -9
  64. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  65. package/lib/module/credential/issuance/05-authorize-access.js +7 -4
  66. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  67. package/lib/module/credential/issuance/06-obtain-credential.js +29 -20
  68. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  69. package/lib/module/credential/issuance/README.md +8 -14
  70. package/lib/module/credential/issuance/errors.js +44 -0
  71. package/lib/module/credential/issuance/errors.js.map +1 -0
  72. package/lib/module/credential/issuance/index.js +3 -2
  73. package/lib/module/credential/issuance/index.js.map +1 -1
  74. package/lib/module/credential/issuance/types.js +0 -3
  75. package/lib/module/credential/issuance/types.js.map +1 -1
  76. package/lib/module/credential/presentation/01-start-flow.js +1 -1
  77. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  78. package/lib/module/credential/presentation/03-get-request-object.js +3 -3
  79. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  80. package/lib/module/credential/presentation/04-send-authorization-response.js +3 -3
  81. package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -1
  82. package/lib/module/credential/presentation/errors.js +42 -0
  83. package/lib/module/credential/presentation/errors.js.map +1 -0
  84. package/lib/module/credential/presentation/index.js +2 -1
  85. package/lib/module/credential/presentation/index.js.map +1 -1
  86. package/lib/module/credential/status/02-status-attestation.js +11 -9
  87. package/lib/module/credential/status/02-status-attestation.js.map +1 -1
  88. package/lib/module/credential/status/README.md +5 -2
  89. package/lib/module/credential/status/types.js +0 -12
  90. package/lib/module/credential/status/types.js.map +1 -1
  91. package/lib/module/sd-jwt/errors.js +32 -0
  92. package/lib/module/sd-jwt/errors.js.map +1 -0
  93. package/lib/module/sd-jwt/index.js +5 -5
  94. package/lib/module/sd-jwt/index.js.map +1 -1
  95. package/lib/module/sd-jwt/verifier.js +5 -1
  96. package/lib/module/sd-jwt/verifier.js.map +1 -1
  97. package/lib/module/trust/index.js +3 -3
  98. package/lib/module/trust/index.js.map +1 -1
  99. package/lib/module/utils/decoder.js +3 -1
  100. package/lib/module/utils/decoder.js.map +1 -1
  101. package/lib/module/utils/error-codes.js +43 -0
  102. package/lib/module/utils/error-codes.js.map +1 -0
  103. package/lib/module/utils/errors.js +98 -438
  104. package/lib/module/utils/errors.js.map +1 -1
  105. package/lib/module/utils/misc.js +18 -11
  106. package/lib/module/utils/misc.js.map +1 -1
  107. package/lib/module/utils/par.js +3 -2
  108. package/lib/module/utils/par.js.map +1 -1
  109. package/lib/module/wallet-instance/README.md +26 -5
  110. package/lib/module/wallet-instance/index.js +32 -7
  111. package/lib/module/wallet-instance/index.js.map +1 -1
  112. package/lib/module/wallet-instance-attestation/README.md +8 -2
  113. package/lib/module/wallet-instance-attestation/issuing.js +15 -12
  114. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  115. package/lib/typescript/client/generated/wallet-provider.d.ts +138 -27
  116. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  117. package/lib/typescript/client/index.d.ts +7 -1
  118. package/lib/typescript/client/index.d.ts.map +1 -1
  119. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +1 -1
  120. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +1 -1
  121. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  122. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  123. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  124. package/lib/typescript/credential/issuance/errors.d.ts +28 -0
  125. package/lib/typescript/credential/issuance/errors.d.ts.map +1 -0
  126. package/lib/typescript/credential/issuance/index.d.ts +3 -2
  127. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  128. package/lib/typescript/credential/issuance/types.d.ts +0 -8
  129. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  130. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  131. package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -1
  132. package/lib/typescript/credential/presentation/errors.d.ts +25 -0
  133. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -0
  134. package/lib/typescript/credential/presentation/index.d.ts +2 -1
  135. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  136. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
  137. package/lib/typescript/credential/status/types.d.ts +0 -15
  138. package/lib/typescript/credential/status/types.d.ts.map +1 -1
  139. package/lib/typescript/sd-jwt/errors.d.ts +20 -0
  140. package/lib/typescript/sd-jwt/errors.d.ts.map +1 -0
  141. package/lib/typescript/sd-jwt/index.d.ts +3 -2
  142. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  143. package/lib/typescript/utils/error-codes.d.ts +45 -0
  144. package/lib/typescript/utils/error-codes.d.ts.map +1 -0
  145. package/lib/typescript/utils/errors.d.ts +88 -225
  146. package/lib/typescript/utils/errors.d.ts.map +1 -1
  147. package/lib/typescript/utils/misc.d.ts +9 -4
  148. package/lib/typescript/utils/misc.d.ts.map +1 -1
  149. package/lib/typescript/utils/par.d.ts.map +1 -1
  150. package/lib/typescript/wallet-instance/index.d.ts +17 -1
  151. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  152. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  153. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  154. package/package.json +1 -1
  155. package/src/client/generated/wallet-provider.ts +43 -13
  156. package/src/client/index.ts +28 -15
  157. package/src/credential/issuance/03-start-user-authorization.ts +1 -1
  158. package/src/credential/issuance/04-complete-user-authorization.ts +21 -21
  159. package/src/credential/issuance/05-authorize-access.ts +7 -4
  160. package/src/credential/issuance/06-obtain-credential.ts +39 -39
  161. package/src/credential/issuance/README.md +8 -14
  162. package/src/credential/issuance/errors.ts +44 -0
  163. package/src/credential/issuance/index.ts +4 -2
  164. package/src/credential/issuance/types.ts +0 -8
  165. package/src/credential/presentation/01-start-flow.ts +1 -1
  166. package/src/credential/presentation/03-get-request-object.ts +3 -3
  167. package/src/credential/presentation/04-send-authorization-response.ts +3 -3
  168. package/src/credential/presentation/errors.ts +41 -0
  169. package/src/credential/presentation/index.ts +2 -0
  170. package/src/credential/status/02-status-attestation.ts +17 -25
  171. package/src/credential/status/README.md +5 -2
  172. package/src/credential/status/types.ts +0 -15
  173. package/src/sd-jwt/errors.ts +39 -0
  174. package/src/sd-jwt/index.ts +5 -8
  175. package/src/sd-jwt/verifier.ts +5 -5
  176. package/src/trust/index.ts +3 -3
  177. package/src/utils/decoder.ts +3 -3
  178. package/src/utils/error-codes.ts +50 -0
  179. package/src/utils/errors.ts +152 -476
  180. package/src/utils/misc.ts +20 -17
  181. package/src/utils/par.ts +3 -2
  182. package/src/wallet-instance/README.md +26 -5
  183. package/src/wallet-instance/index.ts +40 -18
  184. package/src/wallet-instance-attestation/README.md +8 -2
  185. package/src/wallet-instance-attestation/issuing.ts +28 -36
@@ -1,4 +1,8 @@
1
- import type { CredentialIssuerEntityConfiguration } from "../trust/types";
1
+ import type { ProblemDetail } from "../client/generated/wallet-provider";
2
+ import type { CredentialIssuerEntityConfiguration } from "../trust";
3
+ import { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes, type IssuerResponseErrorCode, type WalletProviderResponseErrorCode } from "./error-codes";
4
+ export { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes };
5
+ type GenericErrorReason = string | Record<string, unknown>;
2
6
  /**
3
7
  * utility to format a set of attributes into an error message string
4
8
  *
@@ -9,7 +13,7 @@ import type { CredentialIssuerEntityConfiguration } from "../trust/types";
9
13
  * @param attrs A key value record set
10
14
  * @returns a human-readable serialization of the set
11
15
  */
12
- export declare const serializeAttrs: (attrs: Record<string, string | string>) => string;
16
+ export declare const serializeAttrs: (attrs: Record<string, GenericErrorReason | number | Array<string> | undefined>) => string;
13
17
  /**
14
18
  * A generic Error that all other io-wallet specific Error subclasses extend.
15
19
  *
@@ -22,246 +26,67 @@ export declare const serializeAttrs: (attrs: Record<string, string | string>) =>
22
26
  * ```
23
27
  */
24
28
  export declare class IoWalletError extends Error {
25
- /** A unique error code for the particular error subclass. */
26
- static get code(): string;
27
29
  /** A unique error code for the particular error subclass. */
28
30
  code: string;
29
31
  constructor(message?: string);
30
32
  }
31
- /**
32
- * An error subclass thrown when a Wallet Provider http request has a status code different from the one expected.
33
- */
34
- export declare class UnexpectedStatusCodeError extends IoWalletError {
35
- static get code(): "ERR_UNEXPECTED_STATUS_CODE";
36
- code: string;
37
- /** HTTP status code */
38
- statusCode: number;
39
- /** The stringified response body, useful to process the error response */
40
- responseBody: string;
41
- constructor(message: string, statusCode: number, responseBody: string);
42
- }
43
33
  /**
44
34
  * An error subclass thrown when validation fail
45
35
  *
46
36
  */
47
37
  export declare class ValidationFailed extends IoWalletError {
48
- static get code(): "ERR_IO_WALLET_VALIDATION_FAILED";
49
- code: string;
50
- /** The Claim for which the validation failed. */
51
- claim: string;
52
- /** Reason code for the validation failure. */
53
- reason: string;
54
- constructor(message: string, claim?: string, reason?: string);
55
- }
56
- /**
57
- * An error subclass thrown when validation fail
58
- *
59
- */
60
- export declare class WalletInstanceAttestationIssuingError extends IoWalletError {
61
- static get code(): "ERR_IO_WALLET_INSTANCE_ATTESTATION_ISSUING_FAILED";
62
- code: string;
63
- /** The Claim for which the validation failed. */
64
- claim: string;
65
- /** Reason code for the validation failure. */
66
- reason: string;
67
- constructor(message: string, claim?: string, reason?: string);
68
- }
69
- /**
70
- * An error subclass thrown when auth request decode fail
71
- *
72
- */
73
- export declare class AuthRequestDecodeError extends IoWalletError {
74
- static get code(): "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
75
- code: string;
76
- /** The Claim for which the validation failed. */
77
- claim: string;
78
- /** Reason code for the validation failure. */
79
- reason: string;
80
- constructor(message: string, claim?: string, reason?: string);
81
- }
82
- /**
83
- * An error subclass thrown when validation fail
84
- *
85
- */
86
- export declare class PidIssuingError extends IoWalletError {
87
- static get code(): "ERR_IO_WALLET_PID_ISSUING_FAILED";
88
38
  code: string;
89
39
  /** The Claim for which the validation failed. */
90
40
  claim: string;
91
41
  /** Reason code for the validation failure. */
92
42
  reason: string;
93
- constructor(message: string, claim?: string, reason?: string);
43
+ constructor({ message, claim, reason, }: {
44
+ message: string;
45
+ claim?: string;
46
+ reason?: string;
47
+ });
94
48
  }
95
49
  /**
96
- * When claims are requested but not found in the credential
97
- *
50
+ * An error subclass thrown when an HTTP request has a status code different from the one expected.
98
51
  */
99
- export declare class ClaimsNotFoundBetweenDislosures extends Error {
100
- static get code(): "ERR_CLAIMS_NOT_FOUND";
101
- code: string;
102
- /** The Claims not found */
103
- claims: string[];
104
- constructor(claims: string | string[]);
105
- }
106
- /**
107
- * When the SD-JWT does not contain an hashed reference to a given set of claims
108
- */
109
- export declare class ClaimsNotFoundInToken extends Error {
110
- static get code(): "ERR_CLAIMS_NOT_FOUND_IN_TOKEN";
111
- code: string;
112
- /** The Claims not found */
113
- claims: string[];
114
- constructor(claims: string | string[]);
115
- }
116
- /**
117
- * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
118
- *
119
- */
120
- export declare class NoSuitableKeysFoundInEntityConfiguration extends Error {
121
- static get code(): "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
122
- code: string;
123
- /**
124
- * @param scenario describe the scenario in which the error arise
125
- */
126
- constructor(scenario: string);
127
- }
128
- /**
129
- * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
130
- *
131
- */
132
- export declare class PidMetadataError extends Error {
133
- static get code(): "PID_METADATA_ERROR";
134
- constructor(message: string);
135
- }
136
- /**
137
- * An error subclass thrown when a Wallet Provider http request fail
138
- *
139
- */
140
- export declare class WalletProviderResponseError extends IoWalletError {
141
- static get code(): "ERR_IO_WALLET_PROVIDER_RESPONSE_FAILED";
52
+ export declare class UnexpectedStatusCodeError extends IoWalletError {
142
53
  code: string;
143
- /** The Claim for which the validation failed. */
144
- claim: string;
145
- /** Reason code for the validation failure. */
146
- reason: string;
147
- /** HTTP status code */
148
54
  statusCode: number;
149
- constructor(message: string, claim: string | undefined, reason: string | undefined, statusCode: number);
150
- }
151
- export declare class WalletInstanceRevokedError extends IoWalletError {
152
- static get code(): "ERR_IO_WALLET_INSTANCE_REVOKED";
153
- code: string;
154
- claim: string;
155
- reason: string;
156
- constructor(message: string, claim: string, reason?: string);
157
- }
158
- export declare class WalletInstanceNotFoundError extends IoWalletError {
159
- static get code(): "ERR_IO_WALLET_INSTANCE_NOT_FOUND";
160
- code: string;
161
- claim: string;
162
- reason: string;
163
- constructor(message: string, claim: string, reason?: string);
164
- }
165
- /**
166
- * An error subclass thrown when obtaining a wallet instance attestation which fails due to the integrity.
167
- */
168
- export declare class WalletInstanceIntegrityFailedError extends IoWalletError {
169
- static get code(): "ERR_IO_WALLET_INSTANCE_INTEGRITY_FAILED";
170
- code: string;
171
- reason: string;
172
- claim: string;
173
- constructor(message: string, claim: string, reason?: string);
174
- }
175
- /**
176
- * An error subclass thrown when an error occurs during the wallet instance creation process.
177
- */
178
- export declare class WalletInstanceCreationError extends IoWalletError {
179
- static get code(): "ERR_IO_WALLET_INSTANCE_CREATION_ERROR";
180
- code: string;
181
- /** The Claim for which the validation failed. */
182
- claim: string;
183
- /** Reason code for the validation failure. */
184
- reason: string;
185
- constructor(message: string, claim?: string, reason?: string);
186
- }
187
- /**
188
- * An error subclass thrown when obtaining a wallet instance attestation which fails due to the integrity.
189
- */
190
- export declare class WalletInstanceCreationIntegrityError extends IoWalletError {
191
- static get code(): "ERR_IO_WALLET_INSTANCE_CREATION_INTEGRITY_ERROR";
192
- code: string;
193
- reason: string;
194
- claim: string;
195
- constructor(message: string, claim: string, reason?: string);
196
- }
197
- /**
198
- * An error subclass thrown when an error occurs during the authorization process.
199
- */
200
- export declare class AuthorizationError extends IoWalletError {
201
- static get code(): "ERR_IO_WALLET_AUTHORIZATION_ERROR";
202
- code: string;
203
- constructor(message?: string);
204
- }
205
- /**
206
- * An error subclass thrown when an error occurs during the authorization process with the IDP.
207
- * It contains the error and error description returned by the IDP.
208
- */
209
- export declare class AuthorizationIdpError extends IoWalletError {
210
- static get code(): "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_ERROR";
211
- code: string;
212
- error: string;
213
- errorDescription?: string;
214
- constructor(error: string, errorDescription?: string);
215
- }
216
- /**
217
- * Error subclass thrown when an operation has been aborted.
218
- */
219
- export declare class OperationAbortedError extends IoWalletError {
220
- static get code(): "ERR_IO_WALLET_OPERATION_ABORTED";
221
- code: string;
222
- /** The aborted operation */
223
- operation: string;
224
- constructor(operation: string);
225
- }
226
- /**
227
- * Error subclass thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
228
- */
229
- export declare class CredentialInvalidStatusError extends IoWalletError {
230
- static get code(): "ERR_CREDENTIAL_INVALID_STATUS";
231
- code: string;
232
- /**
233
- * The error code that should be mapped with one of the `issuance_errors_supported` in the EC.
234
- */
235
- errorCode: string;
236
- reason: string;
237
- constructor(message: string, errorCode: string, reason?: string);
238
- }
239
- /**
240
- * Error subclass thrown when an error occurs while obtaining a status attestation for a credential.
241
- */
242
- export declare class StatusAttestationError extends IoWalletError {
243
- static get code(): "ERR_STATUS_ATTESTATION_ERROR";
244
- code: string;
245
- reason: string;
246
- constructor(message: string, reason?: string);
247
- }
248
- /**
249
- * Error subclass thrown when an error occurs while requesting a credential.
250
- */
251
- export declare class CredentialRequestError extends IoWalletError {
252
- static get code(): "CREDENTIAL_REQUEST_ERROR";
253
- code: string;
254
- reason: string;
255
- constructor(message: string, reason?: string);
55
+ reason: GenericErrorReason;
56
+ constructor({ message, reason, statusCode, }: {
57
+ message: string;
58
+ reason: GenericErrorReason;
59
+ statusCode: number;
60
+ });
256
61
  }
257
62
  /**
258
- * Error subclass thrown when a credential cannot be issued immediately because it follows the async flow.
259
- */
260
- export declare class CredentialIssuingNotSynchronousError extends IoWalletError {
261
- static get code(): "CREDENTIAL_ISSUING_NOT_SYNCHRONOUS_ERROR";
262
- code: string;
263
- reason: string;
264
- constructor(message: string, reason?: string);
63
+ * An error subclass thrown when an Issuer HTTP request fails.
64
+ * The specific error can be found in the `code` property.
65
+ *
66
+ * The class is generic over the error code to narrow down the reason.
67
+ */
68
+ export declare class IssuerResponseError extends UnexpectedStatusCodeError {
69
+ code: IssuerResponseErrorCode;
70
+ constructor(params: {
71
+ code?: IssuerResponseErrorCode;
72
+ message: string;
73
+ reason: GenericErrorReason;
74
+ statusCode: number;
75
+ });
76
+ }
77
+ /**
78
+ * An error subclass thrown when a Wallet Provider HTTP request fails.
79
+ * The specific error can be found in the `code` property.
80
+ */
81
+ export declare class WalletProviderResponseError extends UnexpectedStatusCodeError {
82
+ code: WalletProviderResponseErrorCode;
83
+ reason: ProblemDetail;
84
+ constructor(params: {
85
+ code?: WalletProviderResponseErrorCode;
86
+ message: string;
87
+ reason: ProblemDetail;
88
+ statusCode: number;
89
+ });
265
90
  }
266
91
  type LocalizedIssuanceError = {
267
92
  [locale: string]: {
@@ -272,14 +97,52 @@ type LocalizedIssuanceError = {
272
97
  /**
273
98
  * Function to extract the error message from the Entity Configuration's supported error codes.
274
99
  * @param errorCode The error code to map to a meaningful message
275
- * @param params.issuerConf The entity configuration for credentials
276
- * @param params.credentialType The type of credential the error belongs to
100
+ * @param issuerConf The entity configuration for credentials
101
+ * @param credentialType The type of credential the error belongs to
277
102
  * @returns A localized error {@link LocalizedIssuanceError} or undefined
278
- * @throws {Error} When no credential config is found
103
+ * @throws {IoWalletError} When no credential config is found
279
104
  */
280
105
  export declare function extractErrorMessageFromIssuerConf(errorCode: string, { issuerConf, credentialType, }: {
281
106
  issuerConf: CredentialIssuerEntityConfiguration["payload"]["metadata"];
282
107
  credentialType: string;
283
108
  }): LocalizedIssuanceError | undefined;
284
- export {};
109
+ /**
110
+ * Type guard for issuer errors.
111
+ * @param error The error to check
112
+ * @param code Optional code to narrow down the issuer error
113
+ */
114
+ export declare const isIssuerResponseError: (error: unknown, code?: IssuerResponseErrorCode) => error is IssuerResponseError;
115
+ /**
116
+ * Type guard for wallet provider errors.
117
+ * @param error The error to check
118
+ * @param code Optional code to narrow down the wallet provider error
119
+ */
120
+ export declare const isWalletProviderResponseError: (error: unknown, code?: WalletProviderResponseErrorCode) => error is WalletProviderResponseError;
121
+ type ErrorCodeMap<T> = T extends typeof IssuerResponseError ? IssuerResponseErrorCode : T extends typeof WalletProviderResponseError ? WalletProviderResponseErrorCode : never;
122
+ type ErrorCase<T> = {
123
+ code: ErrorCodeMap<T>;
124
+ message: string;
125
+ reason?: GenericErrorReason;
126
+ };
127
+ /**
128
+ * Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
129
+ *
130
+ * Chain multiple `handle` to add cases that depend on the status code, then call `buildFrom` when done.
131
+ *
132
+ * For example:
133
+ * ```
134
+ * new ResponseErrorBuilder(IssuerResponseError)
135
+ * .handle(403, { code: "ERROR_CODE_1", message: "Forbidden" })
136
+ * .handle(500, { code: "ERROR_CODE_2", message: "Unexpected error" })
137
+ * .handle("*", { code: "ERROR_CODE_3", message: "Fallback" })
138
+ * .buildFrom(baseError)
139
+ * ```
140
+ */
141
+ export declare class ResponseErrorBuilder<T extends typeof UnexpectedStatusCodeError> {
142
+ private ErrorClass;
143
+ private errorCases;
144
+ constructor(ErrorClass: T);
145
+ handle(status: number | "*", params: ErrorCase<T>): this;
146
+ buildFrom(originalError: UnexpectedStatusCodeError): UnexpectedStatusCodeError;
147
+ }
285
148
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,UAClB,OAAO,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACrC,MAIW,CAAC;AAEf;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,6DAA6D;IAC7D,MAAM,KAAK,IAAI,IAAI,MAAM,CAExB;IAED,6DAA6D;IAC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S,CAAC,aAAa,EAAE,yBAAyB;CAUnD"}
@@ -1,10 +1,12 @@
1
+ import { UnexpectedStatusCodeError } from "./errors";
1
2
  /**
2
- * Check if a response is in the expected status, other
3
+ * Check if a response is in the expected status, otherwise throw an error
3
4
  * @param status - The expected status
4
- * @throws {@link UnexpectedStatusCodeError} if the status is different from the one expected
5
+ * @param customError - A custom error compatible with {@link UnexpectedStatusCodeError}
6
+ * @throws UnexpectedStatusCodeError if the status is different from the one expected
5
7
  * @returns The given response object
6
8
  */
7
- export declare const hasStatus: (status: number) => (res: Response) => Promise<Response>;
9
+ export declare const hasStatusOrThrow: (status: number, customError?: typeof UnexpectedStatusCodeError) => (res: Response) => Promise<Response>;
8
10
  export type Out<FN> = FN extends (...args: any[]) => Promise<any> ? Awaited<ReturnType<FN>> : FN extends (...args: any[]) => any ? ReturnType<FN> : never;
9
11
  /**
10
12
  * TODO [SIW-1310]: replace this function with a cryptographically secure one.
@@ -40,5 +42,8 @@ export declare const createAbortPromiseFromSignal: (signal: AbortSignal) => {
40
42
  remove: () => void;
41
43
  };
42
44
  export declare const isDefined: <T>(x: "" | T | null | undefined) => x is T;
43
- export declare const safeJsonParse: <T>(text: string, withDefault?: T | undefined) => T | null;
45
+ /**
46
+ * Utility function to parse a raw HTTP response as JSON if supported, otherwise as text.
47
+ */
48
+ export declare const parseRawHttpResponse: <T extends Record<string, unknown>>(response: Response) => Promise<string> | Promise<T>;
44
49
  //# sourceMappingURL=misc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/utils/misc.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,WACX,MAAM,WACH,QAAQ,KAAG,QAAQ,QAAQ,CAUtC,CAAC;AAIJ,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAC7D,OAAO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,MAAM,KACtB,QAAQ,IAAI,CAiBX,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,eAChC,MAAM,KACjB,QAAQ,MAAM,CAMhB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,WAAY,WAAW;;;CAa/D,CAAC;AAEF,eAAO,MAAM,SAAS,6CACV,CAAC;AAEb;;GAEG;AACH,eAAO,MAAM,oBAAoB,gDACrB,QAAQ,iCAIC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"par.d.ts","sourceRoot":"","sources":["../../../src/utils/par.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;WAA+B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc;sBAKL,aAAa;cACrB,WAAW,CAAC,OAAO,CAAC;iBAGpB,MAAM,gBACF,MAAM,eACP,MAAM,gBACL,MAAM,eACP,MAAM,6BACQ,MAAM;;;;oBAElB,MAAM,KACpB,QAAQ,MAAM,CAyEhB,CAAC"}
1
+ {"version":3,"file":"par.d.ts","sourceRoot":"","sources":["../../../src/utils/par.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAMzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;WAA+B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc;sBAKL,aAAa;cACrB,WAAW,CAAC,OAAO,CAAC;iBAGpB,MAAM,gBACF,MAAM,eACP,MAAM,gBACL,MAAM,eACP,MAAM,6BACQ,MAAM;;;;oBAElB,MAAM,KACpB,QAAQ,MAAM,CAyEhB,CAAC"}
@@ -1,11 +1,27 @@
1
+ import type { WalletInstanceData } from "../client/generated/wallet-provider";
1
2
  import type { IntegrityContext } from "..";
2
3
  export declare function createWalletInstance(context: {
3
4
  integrityContext: IntegrityContext;
4
5
  walletProviderBaseUrl: string;
5
6
  appFetch?: GlobalFetch["fetch"];
6
7
  }): Promise<string>;
7
- export declare function revokeCurrentWalletInstance(context: {
8
+ /**
9
+ * Revoke a Wallet Instance by ID.
10
+ * @param context.id The Wallet Instance ID. It matches the hardware key tag used for creation.
11
+ */
12
+ export declare function revokeWalletInstance(context: {
13
+ id: string;
8
14
  walletProviderBaseUrl: string;
9
15
  appFetch?: GlobalFetch["fetch"];
10
16
  }): Promise<void>;
17
+ /**
18
+ * Get the status of a Wallet Instance by ID.
19
+ * @param context.id The Wallet Instance ID. It matches the hardware key tag used for creation.
20
+ * @returns Details on the status of the Wallet Instance
21
+ */
22
+ export declare function getWalletInstanceStatus(context: {
23
+ id: string;
24
+ walletProviderBaseUrl: string;
25
+ appFetch?: GlobalFetch["fetch"];
26
+ }): Promise<WalletInstanceData>;
11
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAO3C,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,mBAuBA;AAsBD,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAE3C,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,mBAuBA;AAoBD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhB;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAM9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance-attestation/issuing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAU3C;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,aAAa,EAC/B,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,CAAC,CAoCjB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;sBAMP,aAAa;sBACb,gBAAgB;2BACX,MAAM;;;;;MAE3B,QAAQ,MAAM,CA6BjB,CAAC"}
1
+ {"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/wallet-instance-attestation/issuing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAQ3C;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,aAAa,EAC/B,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,CAAC,CAoCjB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc;sBAMP,aAAa;sBACb,gBAAgB;2BACX,MAAM;;;;;MAE3B,QAAQ,MAAM,CA6BjB,CAAC"}
@@ -231,13 +231,13 @@ export declare const WalletInstanceAttestationRequestJwt: z.ZodObject<{
231
231
  jti: z.ZodString;
232
232
  nonce: z.ZodString;
233
233
  }, "strip", z.ZodTypeAny, {
234
+ nonce: string;
234
235
  aud: string;
235
236
  jti: string;
236
- nonce: string;
237
237
  }, {
238
+ nonce: string;
238
239
  aud: string;
239
240
  jti: string;
240
- nonce: string;
241
241
  }>>;
242
242
  }, "strip", z.ZodTypeAny, {
243
243
  header: {
@@ -282,9 +282,9 @@ export declare const WalletInstanceAttestationRequestJwt: z.ZodObject<{
282
282
  };
283
283
  };
284
284
  } & {
285
+ nonce: string;
285
286
  aud: string;
286
287
  jti: string;
287
- nonce: string;
288
288
  };
289
289
  }, {
290
290
  header: {
@@ -329,9 +329,9 @@ export declare const WalletInstanceAttestationRequestJwt: z.ZodObject<{
329
329
  };
330
330
  };
331
331
  } & {
332
+ nonce: string;
332
333
  aud: string;
333
334
  jti: string;
334
- nonce: string;
335
335
  };
336
336
  }>;
337
337
  export type WalletInstanceAttestationJwt = z.infer<typeof WalletInstanceAttestationJwt>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-wallet",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Provide data structures, helpers and API for IO Wallet",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -32,11 +32,25 @@ export const ProblemDetail = z.object({
32
32
  instance: z.string().optional(),
33
33
  });
34
34
 
35
- export type SetCurrentWalletInstanceStatusBody = z.infer<typeof SetCurrentWalletInstanceStatusBody>;
36
- export const SetCurrentWalletInstanceStatusBody = z.object({
35
+ export type SetWalletInstanceStatusBody = z.infer<typeof SetWalletInstanceStatusBody>;
36
+ export const SetWalletInstanceStatusBody = z.object({
37
37
  status: z.literal("REVOKED"),
38
38
  });
39
39
 
40
+ export type RevocationReason = z.infer<typeof RevocationReason>;
41
+ export const RevocationReason = z.union([
42
+ z.literal("CERTIFICATE_REVOKED_BY_ISSUER"),
43
+ z.literal("NEW_WALLET_INSTANCE_CREATED"),
44
+ z.literal("REVOKED_BY_USER"),
45
+ ]);
46
+
47
+ export type WalletInstanceData = z.infer<typeof WalletInstanceData>;
48
+ export const WalletInstanceData = z.object({
49
+ id: z.string(),
50
+ is_revoked: z.boolean(),
51
+ revocation_reason: z.union([RevocationReason, z.undefined()]).optional(),
52
+ });
53
+
40
54
  export type get_GetNonce = typeof get_GetNonce;
41
55
  export const get_GetNonce = {
42
56
  method: z.literal("GET"),
@@ -55,37 +69,53 @@ export const post_CreateWalletInstance = {
55
69
  response: z.unknown(),
56
70
  };
57
71
 
58
- export type post_CreateWalletAttestation = typeof post_CreateWalletAttestation;
59
- export const post_CreateWalletAttestation = {
60
- method: z.literal("POST"),
61
- path: z.literal("/token"),
72
+ export type get_GetWalletInstanceStatus = typeof get_GetWalletInstanceStatus;
73
+ export const get_GetWalletInstanceStatus = {
74
+ method: z.literal("GET"),
75
+ path: z.literal("/wallet-instances/{id}/status"),
62
76
  parameters: z.object({
63
- body: CreateWalletAttestationBody,
77
+ path: z.object({
78
+ id: z.string(),
79
+ }),
64
80
  }),
65
- response: WalletAttestationView,
81
+ response: WalletInstanceData,
66
82
  };
67
83
 
68
- export type put_SetCurrentWalletInstanceStatus = typeof put_SetCurrentWalletInstanceStatus;
69
- export const put_SetCurrentWalletInstanceStatus = {
84
+ export type put_SetWalletInstanceStatus = typeof put_SetWalletInstanceStatus;
85
+ export const put_SetWalletInstanceStatus = {
70
86
  method: z.literal("PUT"),
71
- path: z.literal("/wallet-instances/current/status"),
87
+ path: z.literal("/wallet-instances/{id}/status"),
72
88
  parameters: z.object({
73
- body: SetCurrentWalletInstanceStatusBody,
89
+ path: z.object({
90
+ id: z.string(),
91
+ }),
92
+ body: SetWalletInstanceStatusBody,
74
93
  }),
75
94
  response: z.unknown(),
76
95
  };
77
96
 
97
+ export type post_CreateWalletAttestation = typeof post_CreateWalletAttestation;
98
+ export const post_CreateWalletAttestation = {
99
+ method: z.literal("POST"),
100
+ path: z.literal("/token"),
101
+ parameters: z.object({
102
+ body: CreateWalletAttestationBody,
103
+ }),
104
+ response: WalletAttestationView,
105
+ };
106
+
78
107
  // <EndpointByMethod>
79
108
  export const EndpointByMethod = {
80
109
  get: {
81
110
  "/nonce": get_GetNonce,
111
+ "/wallet-instances/{id}/status": get_GetWalletInstanceStatus,
82
112
  },
83
113
  post: {
84
114
  "/wallet-instances": post_CreateWalletInstance,
85
115
  "/token": post_CreateWalletAttestation,
86
116
  },
87
117
  put: {
88
- "/wallet-instances/current/status": put_SetCurrentWalletInstanceStatus,
118
+ "/wallet-instances/{id}/status": put_SetWalletInstanceStatus,
89
119
  },
90
120
  };
91
121
  export type EndpointByMethod = typeof EndpointByMethod;