@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,3 +1,8 @@
1
+ import { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes } from "./error-codes";
2
+ export { IssuerResponseErrorCodes, WalletProviderResponseErrorCodes };
3
+
4
+ // An error reason that supports both a string and a generic JSON object
5
+
1
6
  /**
2
7
  * utility to format a set of attributes into an error message string
3
8
  *
@@ -8,9 +13,14 @@
8
13
  * @param attrs A key value record set
9
14
  * @returns a human-readable serialization of the set
10
15
  */
11
- export const serializeAttrs = attrs => Object.entries(attrs).map(_ref => {
12
- let [k, v] = _ref;
13
- return [k, Array.isArray(v) ? `(${v.join(", ")})` : v];
16
+ export const serializeAttrs = attrs => Object.entries(attrs).filter(_ref => {
17
+ let [, v] = _ref;
18
+ return v !== undefined;
19
+ }).map(_ref2 => {
20
+ let [k, v] = _ref2;
21
+ if (Array.isArray(v)) return [k, `(${v.join(", ")})`];
22
+ if (typeof v !== "string") return [k, JSON.stringify(v)];
23
+ return [k, v];
14
24
  }).map(_ => _.join("=")).join(" ");
15
25
 
16
26
  /**
@@ -25,115 +35,31 @@ export const serializeAttrs = attrs => Object.entries(attrs).map(_ref => {
25
35
  * ```
26
36
  */
27
37
  export class IoWalletError extends Error {
28
- /** A unique error code for the particular error subclass. */
29
- static get code() {
30
- return "ERR_IO_WALLET_GENERIC";
31
- }
32
-
33
38
  /** A unique error code for the particular error subclass. */
34
39
  code = "ERR_IO_WALLET_GENERIC";
35
40
  constructor(message) {
36
- var _Error$captureStackTr;
37
41
  super(message);
38
42
  this.name = this.constructor.name;
39
- // @ts-ignore
40
- (_Error$captureStackTr = Error.captureStackTrace) === null || _Error$captureStackTr === void 0 ? void 0 : _Error$captureStackTr.call(Error, this, this.constructor);
41
43
  }
42
44
  }
43
45
 
44
- /**
45
- * An error subclass thrown when a Wallet Provider http request has a status code different from the one expected.
46
- */
47
- export class UnexpectedStatusCodeError extends IoWalletError {
48
- static get code() {
49
- return "ERR_UNEXPECTED_STATUS_CODE";
50
- }
51
- code = "ERR_UNEXPECTED_STATUS_CODE";
52
-
53
- /** HTTP status code */
54
-
55
- /** The stringified response body, useful to process the error response */
56
-
57
- constructor(message, statusCode, responseBody) {
58
- super(serializeAttrs({
59
- message,
60
- statusCode: statusCode.toString()
61
- }));
62
- this.statusCode = statusCode;
63
- this.responseBody = responseBody;
64
- }
65
- }
66
46
  /**
67
47
  * An error subclass thrown when validation fail
68
48
  *
69
49
  */
70
50
  export class ValidationFailed extends IoWalletError {
71
- static get code() {
72
- return "ERR_IO_WALLET_VALIDATION_FAILED";
73
- }
74
51
  code = "ERR_IO_WALLET_VALIDATION_FAILED";
75
52
 
76
53
  /** The Claim for which the validation failed. */
77
54
 
78
55
  /** Reason code for the validation failure. */
79
56
 
80
- constructor(message) {
81
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
82
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
83
- super(serializeAttrs({
84
- message,
85
- claim,
86
- reason
87
- }));
88
- this.claim = claim;
89
- this.reason = reason;
90
- }
91
- }
92
-
93
- /**
94
- * An error subclass thrown when validation fail
95
- *
96
- */
97
- export class WalletInstanceAttestationIssuingError extends IoWalletError {
98
- static get code() {
99
- return "ERR_IO_WALLET_INSTANCE_ATTESTATION_ISSUING_FAILED";
100
- }
101
- code = "ERR_IO_WALLET_INSTANCE_ATTESTATION_ISSUING_FAILED";
102
-
103
- /** The Claim for which the validation failed. */
104
-
105
- /** Reason code for the validation failure. */
106
-
107
- constructor(message) {
108
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
109
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
110
- super(serializeAttrs({
57
+ constructor(_ref3) {
58
+ let {
111
59
  message,
112
- claim,
113
- reason
114
- }));
115
- this.claim = claim;
116
- this.reason = reason;
117
- }
118
- }
119
-
120
- /**
121
- * An error subclass thrown when auth request decode fail
122
- *
123
- */
124
- export class AuthRequestDecodeError extends IoWalletError {
125
- static get code() {
126
- return "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
127
- }
128
- code = "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
129
-
130
- /** The Claim for which the validation failed. */
131
-
132
- /** Reason code for the validation failure. */
133
-
134
- constructor(message) {
135
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
136
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
60
+ claim = "unspecified",
61
+ reason = "unspecified"
62
+ } = _ref3;
137
63
  super(serializeAttrs({
138
64
  message,
139
65
  claim,
@@ -145,380 +71,66 @@ export class AuthRequestDecodeError extends IoWalletError {
145
71
  }
146
72
 
147
73
  /**
148
- * An error subclass thrown when validation fail
149
- *
74
+ * An error subclass thrown when an HTTP request has a status code different from the one expected.
150
75
  */
151
- export class PidIssuingError extends IoWalletError {
152
- static get code() {
153
- return "ERR_IO_WALLET_PID_ISSUING_FAILED";
154
- }
155
- code = "ERR_IO_WALLET_PID_ISSUING_FAILED";
156
-
157
- /** The Claim for which the validation failed. */
158
-
159
- /** Reason code for the validation failure. */
160
-
161
- constructor(message) {
162
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
163
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
164
- super(serializeAttrs({
76
+ export class UnexpectedStatusCodeError extends IoWalletError {
77
+ code = "ERR_UNEXPECTED_STATUS_CODE";
78
+ constructor(_ref4) {
79
+ let {
165
80
  message,
166
- claim,
167
- reason
168
- }));
169
- this.claim = claim;
170
- this.reason = reason;
171
- }
172
- }
173
-
174
- /**
175
- * When claims are requested but not found in the credential
176
- *
177
- */
178
- export class ClaimsNotFoundBetweenDislosures extends Error {
179
- static get code() {
180
- return "ERR_CLAIMS_NOT_FOUND";
181
- }
182
- code = "ERR_CLAIMS_NOT_FOUND";
183
-
184
- /** The Claims not found */
185
-
186
- constructor(claims) {
187
- const c = Array.isArray(claims) ? claims : [claims];
188
- const message = `Some requested claims are not present in the disclosurable values, claims: ${c.join(", ")}`;
189
- super(message);
190
- this.claims = c;
191
- }
192
- }
193
-
194
- /**
195
- * When the SD-JWT does not contain an hashed reference to a given set of claims
196
- */
197
- export class ClaimsNotFoundInToken extends Error {
198
- static get code() {
199
- return "ERR_CLAIMS_NOT_FOUND_IN_TOKEN";
200
- }
201
- code = "ERR_CLAIMS_NOT_FOUND_IN_TOKEN";
202
-
203
- /** The Claims not found */
204
-
205
- constructor(claims) {
206
- const c = Array.isArray(claims) ? claims : [claims];
207
- const message = `Some claims are not found in the given token, claims: ${c.join(", ")}`;
208
- super(message);
209
- this.claims = c;
210
- }
211
- }
212
-
213
- /**
214
- * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
215
- *
216
- */
217
- export class NoSuitableKeysFoundInEntityConfiguration extends Error {
218
- static get code() {
219
- return "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
220
- }
221
- code = "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
222
-
223
- /**
224
- * @param scenario describe the scenario in which the error arise
225
- */
226
- constructor(scenario) {
227
- const message = `Entity configuration do not provide any suitable keys (${scenario}).`;
228
- super(message);
229
- }
230
- }
231
-
232
- /**
233
- * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
234
- *
235
- */
236
- export class PidMetadataError extends Error {
237
- static get code() {
238
- return "PID_METADATA_ERROR";
239
- }
240
- constructor(message) {
241
- super(message);
242
- }
243
- }
244
-
245
- /**
246
- * An error subclass thrown when a Wallet Provider http request fail
247
- *
248
- */
249
- export class WalletProviderResponseError extends IoWalletError {
250
- static get code() {
251
- return "ERR_IO_WALLET_PROVIDER_RESPONSE_FAILED";
252
- }
253
- code = "ERR_IO_WALLET_PROVIDER_RESPONSE_FAILED";
254
-
255
- /** The Claim for which the validation failed. */
256
-
257
- /** Reason code for the validation failure. */
258
-
259
- /** HTTP status code */
260
-
261
- constructor(message) {
262
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
263
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
264
- let statusCode = arguments.length > 3 ? arguments[3] : undefined;
81
+ reason,
82
+ statusCode
83
+ } = _ref4;
265
84
  super(serializeAttrs({
266
85
  message,
267
- claim,
268
86
  reason,
269
- statusCode: statusCode.toString()
87
+ statusCode
270
88
  }));
271
- this.claim = claim;
272
89
  this.reason = reason;
273
90
  this.statusCode = statusCode;
274
91
  }
275
92
  }
276
- export class WalletInstanceRevokedError extends IoWalletError {
277
- static get code() {
278
- return "ERR_IO_WALLET_INSTANCE_REVOKED";
279
- }
280
- code = "ERR_IO_WALLET_INSTANCE_REVOKED";
281
- constructor(message, claim) {
282
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
283
- super(serializeAttrs({
284
- message,
285
- claim,
286
- reason
287
- }));
288
- this.reason = reason;
289
- this.claim = claim;
290
- }
291
- }
292
- export class WalletInstanceNotFoundError extends IoWalletError {
293
- static get code() {
294
- return "ERR_IO_WALLET_INSTANCE_NOT_FOUND";
295
- }
296
- code = "ERR_IO_WALLET_INSTANCE_NOT_FOUND";
297
- constructor(message, claim) {
298
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
299
- super(serializeAttrs({
300
- message,
301
- claim,
302
- reason
303
- }));
304
- this.reason = reason;
305
- this.claim = claim;
306
- }
307
- }
308
-
309
- /**
310
- * An error subclass thrown when obtaining a wallet instance attestation which fails due to the integrity.
311
- */
312
- export class WalletInstanceIntegrityFailedError extends IoWalletError {
313
- static get code() {
314
- return "ERR_IO_WALLET_INSTANCE_INTEGRITY_FAILED";
315
- }
316
- code = "ERR_IO_WALLET_INSTANCE_INTEGRITY_FAILED";
317
- constructor(message, claim) {
318
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
319
- super(serializeAttrs({
320
- message,
321
- claim,
322
- reason
323
- }));
324
- this.reason = reason;
325
- this.claim = claim;
326
- }
327
- }
328
-
329
- /**
330
- * An error subclass thrown when an error occurs during the wallet instance creation process.
331
- */
332
- export class WalletInstanceCreationError extends IoWalletError {
333
- static get code() {
334
- return "ERR_IO_WALLET_INSTANCE_CREATION_ERROR";
335
- }
336
- code = "ERR_IO_WALLET_INSTANCE_CREATION_ERROR";
337
-
338
- /** The Claim for which the validation failed. */
339
-
340
- /** Reason code for the validation failure. */
341
-
342
- constructor(message) {
343
- let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
344
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
345
- super(serializeAttrs({
346
- message,
347
- claim,
348
- reason
349
- }));
350
- this.claim = claim;
351
- this.reason = reason;
352
- }
353
- }
354
-
355
- /**
356
- * An error subclass thrown when obtaining a wallet instance attestation which fails due to the integrity.
357
- */
358
- export class WalletInstanceCreationIntegrityError extends IoWalletError {
359
- static get code() {
360
- return "ERR_IO_WALLET_INSTANCE_CREATION_INTEGRITY_ERROR";
361
- }
362
- code = "ERR_IO_WALLET_INSTANCE_CREATION_INTEGRITY_ERROR";
363
- constructor(message, claim) {
364
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
365
- super(serializeAttrs({
366
- message,
367
- claim,
368
- reason
369
- }));
370
- this.reason = reason;
371
- this.claim = claim;
372
- }
373
- }
374
-
375
- /**
376
- * An error subclass thrown when an error occurs during the authorization process.
377
- */
378
- export class AuthorizationError extends IoWalletError {
379
- static get code() {
380
- return "ERR_IO_WALLET_AUTHORIZATION_ERROR";
381
- }
382
- code = "ERR_IO_WALLET_AUTHORIZATION_ERROR";
383
- constructor(message) {
384
- super(message);
385
- }
386
- }
387
-
388
- /**
389
- * An error subclass thrown when an error occurs during the authorization process with the IDP.
390
- * It contains the error and error description returned by the IDP.
391
- */
392
- export class AuthorizationIdpError extends IoWalletError {
393
- static get code() {
394
- return "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_ERROR";
395
- }
396
- code = "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_PARSING_FAILED";
397
- constructor(error, errorDescription) {
398
- super(serializeAttrs(errorDescription ? {
399
- error,
400
- errorDescription
401
- } : {
402
- error
403
- }));
404
- this.error = error;
405
- this.errorDescription = errorDescription;
406
- }
407
- }
408
-
409
- /**
410
- * Error subclass thrown when an operation has been aborted.
411
- */
412
- export class OperationAbortedError extends IoWalletError {
413
- static get code() {
414
- return "ERR_IO_WALLET_OPERATION_ABORTED";
415
- }
416
- code = "ERR_IO_WALLET_OPERATION_ABORTED";
417
-
418
- /** The aborted operation */
419
-
420
- constructor(operation) {
421
- super(serializeAttrs({
422
- operation
423
- }));
424
- this.operation = operation;
425
- }
426
- }
427
-
428
- /**
429
- * Error subclass thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
430
- */
431
- export class CredentialInvalidStatusError extends IoWalletError {
432
- static get code() {
433
- return "ERR_CREDENTIAL_INVALID_STATUS";
434
- }
435
- code = "ERR_CREDENTIAL_INVALID_STATUS";
436
-
437
- /**
438
- * The error code that should be mapped with one of the `issuance_errors_supported` in the EC.
439
- */
440
-
441
- constructor(message, errorCode) {
442
- let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
443
- super(serializeAttrs({
444
- message,
445
- errorCode,
446
- reason
447
- }));
448
- this.errorCode = errorCode;
449
- this.reason = reason;
450
- }
451
- }
452
-
453
- /**
454
- * Error subclass thrown when an error occurs while obtaining a status attestation for a credential.
455
- */
456
- export class StatusAttestationError extends IoWalletError {
457
- static get code() {
458
- return "ERR_STATUS_ATTESTATION_ERROR";
459
- }
460
- code = "ERR_STATUS_ATTESTATION_ERROR";
461
- constructor(message) {
462
- let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
463
- super(serializeAttrs({
464
- message,
465
- reason
466
- }));
467
- this.reason = reason;
468
- }
469
- }
470
93
 
471
94
  /**
472
- * Error subclass thrown when an error occurs while requesting a credential.
95
+ * An error subclass thrown when an Issuer HTTP request fails.
96
+ * The specific error can be found in the `code` property.
97
+ *
98
+ * The class is generic over the error code to narrow down the reason.
473
99
  */
474
- export class CredentialRequestError extends IoWalletError {
475
- static get code() {
476
- return "CREDENTIAL_REQUEST_ERROR";
477
- }
478
- code = "CREDENTIAL_REQUEST_ERROR";
479
- constructor(message) {
480
- let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
481
- super(serializeAttrs({
482
- message,
483
- reason
484
- }));
485
- this.reason = reason;
100
+ export class IssuerResponseError extends UnexpectedStatusCodeError {
101
+ constructor(params) {
102
+ super(params);
103
+ this.code = params.code ?? IssuerResponseErrorCodes.IssuerGenericError;
486
104
  }
487
105
  }
488
106
 
489
107
  /**
490
- * Error subclass thrown when a credential cannot be issued immediately because it follows the async flow.
108
+ * An error subclass thrown when a Wallet Provider HTTP request fails.
109
+ * The specific error can be found in the `code` property.
491
110
  */
492
- export class CredentialIssuingNotSynchronousError extends IoWalletError {
493
- static get code() {
494
- return "CREDENTIAL_ISSUING_NOT_SYNCHRONOUS_ERROR";
495
- }
496
- code = "CREDENTIAL_ISSUING_NOT_SYNCHRONOUS_ERROR";
497
- constructor(message) {
498
- let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
499
- super(serializeAttrs({
500
- message,
501
- reason
502
- }));
503
- this.reason = reason;
111
+ export class WalletProviderResponseError extends UnexpectedStatusCodeError {
112
+ constructor(params) {
113
+ super(params);
114
+ this.reason = params.reason;
115
+ this.code = params.code ?? WalletProviderResponseErrorCodes.WalletProviderGenericError;
504
116
  }
505
117
  }
506
118
  /**
507
119
  * Function to extract the error message from the Entity Configuration's supported error codes.
508
120
  * @param errorCode The error code to map to a meaningful message
509
- * @param params.issuerConf The entity configuration for credentials
510
- * @param params.credentialType The type of credential the error belongs to
121
+ * @param issuerConf The entity configuration for credentials
122
+ * @param credentialType The type of credential the error belongs to
511
123
  * @returns A localized error {@link LocalizedIssuanceError} or undefined
512
- * @throws {Error} When no credential config is found
124
+ * @throws {IoWalletError} When no credential config is found
513
125
  */
514
- export function extractErrorMessageFromIssuerConf(errorCode, _ref2) {
126
+ export function extractErrorMessageFromIssuerConf(errorCode, _ref5) {
515
127
  let {
516
128
  issuerConf,
517
129
  credentialType
518
- } = _ref2;
130
+ } = _ref5;
519
131
  const credentialConfiguration = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialType];
520
132
  if (!credentialConfiguration) {
521
- throw new Error(`No configuration found for ${credentialType} in the provided EC`);
133
+ throw new IoWalletError(`No configuration found for ${credentialType} in the provided EC`);
522
134
  }
523
135
  const {
524
136
  issuance_errors_supported
@@ -527,15 +139,63 @@ export function extractErrorMessageFromIssuerConf(errorCode, _ref2) {
527
139
  return undefined;
528
140
  }
529
141
  const localesList = issuance_errors_supported[errorCode].display;
530
- return localesList.reduce((acc, _ref3) => {
142
+ return localesList.reduce((acc, _ref6) => {
531
143
  let {
532
144
  locale,
533
145
  ...rest
534
- } = _ref3;
146
+ } = _ref6;
535
147
  return {
536
148
  ...acc,
537
149
  [locale]: rest
538
150
  };
539
151
  }, {});
540
152
  }
153
+
154
+ /**
155
+ * Type guard for issuer errors.
156
+ * @param error The error to check
157
+ * @param code Optional code to narrow down the issuer error
158
+ */
159
+ export const isIssuerResponseError = (error, code) => error instanceof IssuerResponseError && error.code === (code ?? error.code);
160
+
161
+ /**
162
+ * Type guard for wallet provider errors.
163
+ * @param error The error to check
164
+ * @param code Optional code to narrow down the wallet provider error
165
+ */
166
+ export const isWalletProviderResponseError = (error, code) => error instanceof WalletProviderResponseError && error.code === (code ?? error.code);
167
+ /**
168
+ * Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
169
+ *
170
+ * Chain multiple `handle` to add cases that depend on the status code, then call `buildFrom` when done.
171
+ *
172
+ * For example:
173
+ * ```
174
+ * new ResponseErrorBuilder(IssuerResponseError)
175
+ * .handle(403, { code: "ERROR_CODE_1", message: "Forbidden" })
176
+ * .handle(500, { code: "ERROR_CODE_2", message: "Unexpected error" })
177
+ * .handle("*", { code: "ERROR_CODE_3", message: "Fallback" })
178
+ * .buildFrom(baseError)
179
+ * ```
180
+ */
181
+ export class ResponseErrorBuilder {
182
+ errorCases = {};
183
+ constructor(ErrorClass) {
184
+ this.ErrorClass = ErrorClass;
185
+ }
186
+ handle(status, params) {
187
+ this.errorCases[status] = params;
188
+ return this;
189
+ }
190
+ buildFrom(originalError) {
191
+ const params = this.errorCases[originalError.statusCode] ?? this.errorCases["*"];
192
+ if (params) {
193
+ return new this.ErrorClass({
194
+ ...originalError,
195
+ ...params
196
+ });
197
+ }
198
+ return originalError;
199
+ }
200
+ }
541
201
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["serializeAttrs","attrs","Object","entries","map","_ref","k","v","Array","isArray","join","_","IoWalletError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","UnexpectedStatusCodeError","statusCode","responseBody","toString","ValidationFailed","claim","arguments","length","undefined","reason","WalletInstanceAttestationIssuingError","AuthRequestDecodeError","PidIssuingError","ClaimsNotFoundBetweenDislosures","claims","c","ClaimsNotFoundInToken","NoSuitableKeysFoundInEntityConfiguration","scenario","PidMetadataError","WalletProviderResponseError","WalletInstanceRevokedError","WalletInstanceNotFoundError","WalletInstanceIntegrityFailedError","WalletInstanceCreationError","WalletInstanceCreationIntegrityError","AuthorizationError","AuthorizationIdpError","error","errorDescription","OperationAbortedError","operation","CredentialInvalidStatusError","errorCode","StatusAttestationError","CredentialRequestError","CredentialIssuingNotSynchronousError","extractErrorMessageFromIssuerConf","_ref2","issuerConf","credentialType","credentialConfiguration","openid_credential_issuer","credential_configurations_supported","issuance_errors_supported","localesList","display","reduce","acc","_ref3","locale","rest"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,cAAc,GACzBC,KAAsC,IAEtCC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAClBG,GAAG,CAACC,IAAA;EAAA,IAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAAF,IAAA;EAAA,OAAK,CAACC,CAAC,EAAEE,KAAK,CAACC,OAAO,CAACF,CAAC,CAAC,GAAI,IAAGA,CAAC,CAACG,IAAI,CAAC,IAAI,CAAE,GAAE,GAAGH,CAAC,CAAC;AAAA,EAAC,CAChEH,GAAG,CAAEO,CAAC,IAAKA,CAAC,CAACD,IAAI,CAAC,GAAG,CAAC,CAAC,CACvBA,IAAI,CAAC,GAAG,CAAC;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,aAAa,SAASC,KAAK,CAAC;EACvC;EACA,WAAWC,IAAIA,CAAA,EAAW;IACxB,OAAO,uBAAuB;EAChC;;EAEA;EACAA,IAAI,GAAW,uBAAuB;EAEtCC,WAAWA,CAACC,OAAgB,EAAE;IAAA,IAAAC,qBAAA;IAC5B,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,IAAI,CAACH,WAA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ResponseErrorCodes","WalletProviderResponseErrorCodes","serializeAttrs","attrs","Object","entries","filter","_ref","v","undefined","map","_ref2","k","Array","isArray","join","JSON","stringify","_","IoWalletError","Error","code","constructor","message","name","ValidationFailed","_ref3","claim","reason","UnexpectedStatusCodeError","_ref4","statusCode","IssuerResponseError","params","IssuerGenericError","WalletProviderResponseError","WalletProviderGenericError","extractErrorMessageFromIssuerConf","errorCode","_ref5","issuerConf","credentialType","credentialConfiguration","openid_credential_issuer","credential_configurations_supported","issuance_errors_supported","localesList","display","reduce","acc","_ref6","locale","rest","isIssuerResponseError","error","isWalletProviderResponseError","ResponseErrorBuilder","errorCases","ErrorClass","handle","status","buildFrom","originalError"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":"AAEA,SACEA,wBAAwB,EACxBC,gCAAgC,QAG3B,eAAe;AAEtB,SAASD,wBAAwB,EAAEC,gCAAgC;;AAEnE;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GACzBC,KAA8E,IAE9EC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAClBG,MAAM,CAACC,IAAA;EAAA,IAAC,GAAGC,CAAC,CAAC,GAAAD,IAAA;EAAA,OAAKC,CAAC,KAAKC,SAAS;AAAA,EAAC,CAClCC,GAAG,CAACC,KAAA,IAAY;EAAA,IAAX,CAACC,CAAC,EAAEJ,CAAC,CAAC,GAAAG,KAAA;EACV,IAAIE,KAAK,CAACC,OAAO,CAACN,CAAC,CAAC,EAAE,OAAO,CAACI,CAAC,EAAG,IAAGJ,CAAC,CAACO,IAAI,CAAC,IAAI,CAAE,GAAE,CAAC;EACrD,IAAI,OAAOP,CAAC,KAAK,QAAQ,EAAE,OAAO,CAACI,CAAC,EAAEI,IAAI,CAACC,SAAS,CAACT,CAAC,CAAC,CAAC;EACxD,OAAO,CAACI,CAAC,EAAEJ,CAAC,CAAC;AACf,CAAC,CAAC,CACDE,GAAG,CAAEQ,CAA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