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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/README.md +0 -32
  2. package/lib/commonjs/client/generated/wallet-provider.js +39 -16
  3. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
  4. package/lib/commonjs/client/index.js +25 -10
  5. package/lib/commonjs/client/index.js.map +1 -1
  6. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +2 -2
  7. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +36 -67
  8. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -2
  10. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/06-obtain-credential.js +26 -17
  12. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/README.md +8 -14
  14. package/lib/commonjs/credential/issuance/errors.js +52 -0
  15. package/lib/commonjs/credential/issuance/errors.js.map +1 -0
  16. package/lib/commonjs/credential/issuance/index.js +13 -2
  17. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  18. package/lib/commonjs/credential/issuance/types.js +1 -5
  19. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  20. package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
  21. package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
  22. package/lib/commonjs/credential/presentation/03-get-request-object.js +2 -2
  23. package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
  24. package/lib/commonjs/credential/presentation/04-send-authorization-response.js +2 -2
  25. package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -1
  26. package/lib/commonjs/credential/presentation/errors.js +49 -0
  27. package/lib/commonjs/credential/presentation/errors.js.map +1 -0
  28. package/lib/commonjs/credential/presentation/index.js +5 -0
  29. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  30. package/lib/commonjs/credential/status/02-status-attestation.js +8 -6
  31. package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
  32. package/lib/commonjs/credential/status/README.md +5 -2
  33. package/lib/commonjs/credential/status/types.js +1 -14
  34. package/lib/commonjs/credential/status/types.js.map +1 -1
  35. package/lib/commonjs/sd-jwt/errors.js +40 -0
  36. package/lib/commonjs/sd-jwt/errors.js.map +1 -0
  37. package/lib/commonjs/sd-jwt/index.js +8 -4
  38. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  39. package/lib/commonjs/sd-jwt/verifier.js +5 -1
  40. package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
  41. package/lib/commonjs/trust/index.js +2 -2
  42. package/lib/commonjs/trust/index.js.map +1 -1
  43. package/lib/commonjs/utils/decoder.js +3 -1
  44. package/lib/commonjs/utils/decoder.js.map +1 -1
  45. package/lib/commonjs/utils/error-codes.js +51 -0
  46. package/lib/commonjs/utils/error-codes.js.map +1 -0
  47. package/lib/commonjs/utils/errors.js +119 -463
  48. package/lib/commonjs/utils/errors.js.map +1 -1
  49. package/lib/commonjs/utils/misc.js +23 -55
  50. package/lib/commonjs/utils/misc.js.map +1 -1
  51. package/lib/commonjs/utils/par.js +2 -1
  52. package/lib/commonjs/utils/par.js.map +1 -1
  53. package/lib/commonjs/wallet-instance/README.md +26 -5
  54. package/lib/commonjs/wallet-instance/index.js +33 -7
  55. package/lib/commonjs/wallet-instance/index.js.map +1 -1
  56. package/lib/commonjs/wallet-instance-attestation/README.md +8 -2
  57. package/lib/commonjs/wallet-instance-attestation/issuing.js +13 -10
  58. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  59. package/lib/module/client/generated/wallet-provider.js +31 -11
  60. package/lib/module/client/generated/wallet-provider.js.map +1 -1
  61. package/lib/module/client/index.js +22 -8
  62. package/lib/module/client/index.js.map +1 -1
  63. package/lib/module/credential/issuance/03-start-user-authorization.js +2 -2
  64. package/lib/module/credential/issuance/04-complete-user-authorization.js +33 -65
  65. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  66. package/lib/module/credential/issuance/05-authorize-access.js +7 -4
  67. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  68. package/lib/module/credential/issuance/06-obtain-credential.js +29 -20
  69. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  70. package/lib/module/credential/issuance/README.md +8 -14
  71. package/lib/module/credential/issuance/errors.js +44 -0
  72. package/lib/module/credential/issuance/errors.js.map +1 -0
  73. package/lib/module/credential/issuance/index.js +3 -2
  74. package/lib/module/credential/issuance/index.js.map +1 -1
  75. package/lib/module/credential/issuance/types.js +0 -3
  76. package/lib/module/credential/issuance/types.js.map +1 -1
  77. package/lib/module/credential/presentation/01-start-flow.js +1 -1
  78. package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
  79. package/lib/module/credential/presentation/03-get-request-object.js +3 -3
  80. package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
  81. package/lib/module/credential/presentation/04-send-authorization-response.js +3 -3
  82. package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -1
  83. package/lib/module/credential/presentation/errors.js +42 -0
  84. package/lib/module/credential/presentation/errors.js.map +1 -0
  85. package/lib/module/credential/presentation/index.js +2 -1
  86. package/lib/module/credential/presentation/index.js.map +1 -1
  87. package/lib/module/credential/status/02-status-attestation.js +11 -9
  88. package/lib/module/credential/status/02-status-attestation.js.map +1 -1
  89. package/lib/module/credential/status/README.md +5 -2
  90. package/lib/module/credential/status/types.js +0 -12
  91. package/lib/module/credential/status/types.js.map +1 -1
  92. package/lib/module/sd-jwt/errors.js +32 -0
  93. package/lib/module/sd-jwt/errors.js.map +1 -0
  94. package/lib/module/sd-jwt/index.js +5 -5
  95. package/lib/module/sd-jwt/index.js.map +1 -1
  96. package/lib/module/sd-jwt/verifier.js +5 -1
  97. package/lib/module/sd-jwt/verifier.js.map +1 -1
  98. package/lib/module/trust/index.js +3 -3
  99. package/lib/module/trust/index.js.map +1 -1
  100. package/lib/module/utils/decoder.js +3 -1
  101. package/lib/module/utils/decoder.js.map +1 -1
  102. package/lib/module/utils/error-codes.js +43 -0
  103. package/lib/module/utils/error-codes.js.map +1 -0
  104. package/lib/module/utils/errors.js +98 -438
  105. package/lib/module/utils/errors.js.map +1 -1
  106. package/lib/module/utils/misc.js +19 -49
  107. package/lib/module/utils/misc.js.map +1 -1
  108. package/lib/module/utils/par.js +3 -2
  109. package/lib/module/utils/par.js.map +1 -1
  110. package/lib/module/wallet-instance/README.md +26 -5
  111. package/lib/module/wallet-instance/index.js +32 -7
  112. package/lib/module/wallet-instance/index.js.map +1 -1
  113. package/lib/module/wallet-instance-attestation/README.md +8 -2
  114. package/lib/module/wallet-instance-attestation/issuing.js +15 -12
  115. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  116. package/lib/typescript/client/generated/wallet-provider.d.ts +138 -27
  117. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
  118. package/lib/typescript/client/index.d.ts +7 -1
  119. package/lib/typescript/client/index.d.ts.map +1 -1
  120. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +2 -2
  121. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +17 -16
  122. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  123. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  124. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  125. package/lib/typescript/credential/issuance/errors.d.ts +28 -0
  126. package/lib/typescript/credential/issuance/errors.d.ts.map +1 -0
  127. package/lib/typescript/credential/issuance/index.d.ts +4 -3
  128. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  129. package/lib/typescript/credential/issuance/types.d.ts +0 -8
  130. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  131. package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
  132. package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -1
  133. package/lib/typescript/credential/presentation/errors.d.ts +25 -0
  134. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -0
  135. package/lib/typescript/credential/presentation/index.d.ts +2 -1
  136. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  137. package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
  138. package/lib/typescript/credential/status/types.d.ts +0 -15
  139. package/lib/typescript/credential/status/types.d.ts.map +1 -1
  140. package/lib/typescript/sd-jwt/errors.d.ts +20 -0
  141. package/lib/typescript/sd-jwt/errors.d.ts.map +1 -0
  142. package/lib/typescript/sd-jwt/index.d.ts +3 -2
  143. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  144. package/lib/typescript/utils/error-codes.d.ts +45 -0
  145. package/lib/typescript/utils/error-codes.d.ts.map +1 -0
  146. package/lib/typescript/utils/errors.d.ts +88 -225
  147. package/lib/typescript/utils/errors.d.ts.map +1 -1
  148. package/lib/typescript/utils/misc.d.ts +9 -24
  149. package/lib/typescript/utils/misc.d.ts.map +1 -1
  150. package/lib/typescript/utils/par.d.ts.map +1 -1
  151. package/lib/typescript/wallet-instance/index.d.ts +17 -1
  152. package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
  153. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  154. package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
  155. package/package.json +1 -1
  156. package/src/client/generated/wallet-provider.ts +43 -13
  157. package/src/client/index.ts +28 -15
  158. package/src/credential/issuance/03-start-user-authorization.ts +2 -2
  159. package/src/credential/issuance/04-complete-user-authorization.ts +57 -118
  160. package/src/credential/issuance/05-authorize-access.ts +7 -4
  161. package/src/credential/issuance/06-obtain-credential.ts +39 -39
  162. package/src/credential/issuance/README.md +8 -14
  163. package/src/credential/issuance/errors.ts +44 -0
  164. package/src/credential/issuance/index.ts +8 -2
  165. package/src/credential/issuance/types.ts +0 -8
  166. package/src/credential/presentation/01-start-flow.ts +1 -1
  167. package/src/credential/presentation/03-get-request-object.ts +3 -3
  168. package/src/credential/presentation/04-send-authorization-response.ts +3 -3
  169. package/src/credential/presentation/errors.ts +41 -0
  170. package/src/credential/presentation/index.ts +2 -0
  171. package/src/credential/status/02-status-attestation.ts +17 -25
  172. package/src/credential/status/README.md +5 -2
  173. package/src/credential/status/types.ts +0 -15
  174. package/src/sd-jwt/errors.ts +39 -0
  175. package/src/sd-jwt/index.ts +5 -8
  176. package/src/sd-jwt/verifier.ts +5 -5
  177. package/src/trust/index.ts +3 -3
  178. package/src/utils/decoder.ts +3 -3
  179. package/src/utils/error-codes.ts +50 -0
  180. package/src/utils/errors.ts +152 -476
  181. package/src/utils/misc.ts +21 -65
  182. package/src/utils/par.ts +3 -2
  183. package/src/wallet-instance/README.md +26 -5
  184. package/src/wallet-instance/index.ts +40 -18
  185. package/src/wallet-instance-attestation/README.md +8 -2
  186. package/src/wallet-instance-attestation/issuing.ts +28 -36
@@ -42,7 +42,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
42
42
 
43
43
  /**
44
44
  * WARNING: This function must be called after {@link evaluateIssuerTrust} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
45
- * Creates and sends a PAR request to the /as/par endpoint of the authroization server.
45
+ * Creates and sends a PAR request to the /as/par endpoint of the authorization server.
46
46
  * This starts the authentication flow to obtain an access token.
47
47
  * This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
48
48
  * This is an HTTP POST request containing the Wallet Instance identifier (client id), the code challenge and challenge method as specified by PKCE according to RFC 9126
@@ -51,7 +51,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
51
51
  * the application session identifier on the Wallet Instance side (state),
52
52
  * the method (query or form_post.jwt) by which the Authorization Server
53
53
  * should transmit the Authorization Response containing the authorization code issued upon the end user's authentication (response_mode)
54
- * to the Wallet Instance's Token Endpoint to obtain the Access Token, and the redirect_uri of the Wallet Instance where the Authorization Response
54
+ * to the Wallet Instance's Token Endpoint to obtain the Access Token, and the redirectUri of the Wallet Instance where the Authorization Response
55
55
  * should be delivered. The redirect is achived by using a custom URL scheme that the Wallet Instance is registered to handle.
56
56
  * @param issuerConf The issuer configuration
57
57
  * @param credentialType The type of the credential to be requested returned by {@link selectCredentialDefinition}
@@ -1,38 +1,28 @@
1
1
  import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/auth";
2
- import { createAbortPromiseFromSignal, hasStatus, isDefined, until } from "../../utils/misc";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
3
  import parseUrl from "parse-url";
4
- import { AuthorizationError, AuthorizationIdpError, OperationAbortedError, ValidationFailed } from "../../utils/errors";
5
- import { Linking } from "react-native";
4
+ import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
6
5
  import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
7
6
  import { RequestObject } from "../presentation/types";
8
7
  import uuid from "react-native-uuid";
9
8
  import { ResponseUriResultShape } from "./types";
10
9
  import { getJwtFromFormPost } from "../../utils/decoder";
10
+ import { AuthorizationError, AuthorizationIdpError } from "./errors";
11
11
 
12
12
  /**
13
13
  * The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
14
14
  */
15
15
 
16
16
  /**
17
- * WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link authorizeAccess}.
18
- * The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
19
- * It is used to complete the user authorization by catching the redirectSchema from the authorization server which then contains the authorization response.
20
- * This function utilizes the authorization context to open an in-app browser capable of catching the redirectSchema to perform a get request to the authorization endpoint.
21
- * If the 302 redirect happens and the redirectSchema is caught, the function will return the authorization response after parsing it from the query string.
17
+ * WARNING: This function must be called after {@link startUserAuthorization}. The generated authUrl must be used to open a browser or webview capable of catching the redirectSchema to perform a get request to the authorization endpoint.
18
+ * Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
22
19
  * @param issuerRequestUri the URI of the issuer where the request is sent
23
20
  * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
24
21
  * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
25
- * @param authorizationContext The context to identify the user which will be used to start the authorization. It's needed only when requesting a PersonalIdentificationData credential. The implementantion should open an in-app browser capable of catching the redirectSchema.
26
- * If not specified, the default browser is used
27
- * @param idphint Unique identifier of the SPID IDP selected by the user
28
- * @param redirectUri The url to reach to complete the user authorization which is the custom URL scheme that the Wallet Instance is registered to handle, usually a custom URL or deeplink
29
- * @param signal An optional {@link AbortSignal} to abort the operation when using the default browser
30
- * @throws {AuthorizationError} if an error occurs during the authorization process
31
- * @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
32
- * @throws {OperationAbortedError} if the caller aborts the operation via the provided signal
33
- * @returns the authorization response which contains code, state and iss
22
+ * @param idpHint Unique identifier of the IDP selected by the user
23
+ * @returns An object containing the authorization URL
34
24
  */
35
- export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext, signal) => {
25
+ export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idpHint) => {
36
26
  const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
37
27
  const params = new URLSearchParams({
38
28
  client_id: clientId,
@@ -40,49 +30,21 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
40
30
  idphint: idpHint
41
31
  });
42
32
  const authUrl = `${authzRequestEndpoint}?${params}`;
43
- var authRedirectUrl;
44
- if (authorizationContext) {
45
- const redirectSchema = new URL(redirectUri).protocol.replace(":", "");
46
- authRedirectUrl = await authorizationContext.authorize(authUrl, redirectSchema).catch(e => {
47
- throw new AuthorizationError(e.message);
48
- });
49
- } else {
50
- // handler for redirectUri
51
- const urlEventListener = Linking.addEventListener("url", _ref => {
52
- let {
53
- url
54
- } = _ref;
55
- if (url.includes(redirectUri)) {
56
- authRedirectUrl = url;
57
- }
58
- });
59
- const operationIsAborted = signal ? createAbortPromiseFromSignal(signal) : undefined;
60
- await Linking.openURL(authUrl);
61
-
62
- /*
63
- * Waits for 120 seconds for the identificationRedirectUrl variable to be set
64
- * by the custom url handler. If the timeout is exceeded, throw an exception
65
- */
66
- const unitAuthRedirectIsNotUndefined = until(() => authRedirectUrl !== undefined, 120);
33
+ return {
34
+ authUrl
35
+ };
36
+ };
67
37
 
68
- /**
69
- * Simultaneously listen for the abort signal (when provided) and the redirect url.
70
- * The first event that occurs will resolve the promise.
71
- * This is useful to properly cleanup when the caller aborts this operation.
72
- */
73
- const winner = await Promise.race([operationIsAborted === null || operationIsAborted === void 0 ? void 0 : operationIsAborted.listen(), unitAuthRedirectIsNotUndefined].filter(isDefined)).finally(() => {
74
- urlEventListener.remove();
75
- operationIsAborted === null || operationIsAborted === void 0 ? void 0 : operationIsAborted.remove();
76
- });
77
- if (winner === "OPERATION_ABORTED") {
78
- throw new OperationAbortedError("DefaultQueryModeAuthorization");
79
- }
80
- if (authRedirectUrl === undefined) {
81
- throw new AuthorizationError("Invalid authentication redirect url");
82
- }
83
- }
38
+ /**
39
+ * WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
40
+ * Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
41
+ * This function parses the authorization redirect URL to extract the authorization response.
42
+ * @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
43
+ * @returns the authorization response which contains code, state and iss
44
+ */
45
+ export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
84
46
  const query = parseUrl(authRedirectUrl).query;
85
- return parseAuthroizationResponse(query);
47
+ return parseAuthorizationResponse(query);
86
48
  };
87
49
 
88
50
  /**
@@ -106,9 +68,12 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
106
68
  });
107
69
  const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
108
70
  method: "GET"
109
- }).then(hasStatus(200)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
71
+ }).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
110
72
  if (!requestObject.success) {
111
- throw new ValidationFailed("Request Object validation failed", requestObject.error.message);
73
+ throw new ValidationFailed({
74
+ message: "Request Object validation failed",
75
+ reason: requestObject.error.message
76
+ });
112
77
  }
113
78
  return requestObject.data;
114
79
  };
@@ -194,12 +159,15 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
194
159
  "Content-Type": "application/x-www-form-urlencoded"
195
160
  },
196
161
  body
197
- }).then(hasStatus(200)).then(reqUri => reqUri.json());
162
+ }).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
198
163
  const responseUri = ResponseUriResultShape.safeParse(resUriRes);
199
164
  if (!responseUri.success) {
200
- throw new ValidationFailed("Response Uri validation failed", responseUri.error.message);
165
+ throw new ValidationFailed({
166
+ message: "Response Uri validation failed",
167
+ reason: responseUri.error.message
168
+ });
201
169
  }
202
- return await appFetch(responseUri.data.redirect_uri).then(hasStatus(200)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthroizationResponse(cbRes.decodedJwt.payload));
170
+ return await appFetch(responseUri.data.redirect_uri).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthorizationResponse(cbRes.decodedJwt.payload));
203
171
  };
204
172
 
205
173
  /**
@@ -209,7 +177,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
209
177
  * @param authRes the authorization response to be parsed
210
178
  * @returns the authorization result which contains code, state and iss
211
179
  */
212
- export const parseAuthroizationResponse = authRes => {
180
+ export const parseAuthorizationResponse = authRes => {
213
181
  const authResParsed = AuthorizationResultShape.safeParse(authRes);
214
182
  if (!authResParsed.success) {
215
183
  const authErr = AuthorizationErrorShape.safeParse(authRes);
@@ -1 +1 @@
1
- {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","createAbortPromiseFromSignal","hasStatus","isDefined","until","parseUrl","AuthorizationError","AuthorizationIdpError","OperationAbortedError","ValidationFailed","Linking","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","signal","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","urlEventListener","addEventListener","_ref","url","includes","operationIsAborted","undefined","openURL","unitAuthRedirectIsNotUndefined","winner","Promise","race","listen","filter","finally","remove","query","parseAuthroizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAGnB,kBAAkB;AACzB,SACEC,4BAA4B,EAC5BC,SAAS,EACTC,SAAS,EACTC,KAAK,QAEA,kBAAkB;AAEzB,OAAOC,QAAQ,MAAM,WAAW;AAChC,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,qBAAqB,EACrBC,gBAAgB,QACX,oBAAoB;AAE3B,SAASC,OAAO,QAAQ,cAAc;AACtC,SACEC,MAAM,EACNC,YAAY,EACZC,OA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AAG5H,wBAAwB,CAAC2E,SAAS,CAACgD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAAC/C,OAAO,EAAE;IAC1B,MAAMgD,OAAO,GAAG9H,uBAAuB,CAAC4E,SAAS,CAACgD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAChD,OAAO,EAAE;MACpB,MAAM,IAAIvE,kBAAkB,CAACsH,aAAa,CAAC9C,KAAK,CAACnC,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIpC,qBAAqB,CAC7BsH,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
1
+ {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","message","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["cred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,CAAC,CAAC,CACzBF,IAAI,CAAC9B,kBAAkB,CAAC,CACxB8B,IAAI,CAAEqD,KAAK,IAAK/D,0BAA0B,CAAC+D,KAAK,CAACC,UAAU,CAAChD,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMhB,0BAA0B,GACrCiE,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAGjG,wBAAwB,CAAC8C,SAAS,CAACkD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAACjD,OAAO,EAAE;IAC1B,MAAMkD,OAAO,GAAGnG,uBAAuB,CAAC+C,SAAS,CAACkD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAClD,OAAO,EAAE;MACpB,MAAM,IAAIpC,kBAAkB,CAACqF,aAAa,CAAC9C,KAAK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIpC,qBAAqB,CAC7BqF,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
@@ -1,11 +1,11 @@
1
- import { hasStatus } from "../../utils/misc";
1
+ import { hasStatusOrThrow } from "../../utils/misc";
2
2
  import { createDPopToken } from "../../utils/dpop";
3
3
  import uuid from "react-native-uuid";
4
4
  import { createPopToken } from "../../utils/pop";
5
5
  import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
6
6
  import { ASSERTION_TYPE } from "./const";
7
7
  import { TokenResponse } from "./types";
8
- import { ValidationFailed } from "../../utils/errors";
8
+ import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
9
9
  /**
10
10
  * Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
11
11
  * for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
@@ -62,9 +62,12 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
62
62
  DPoP: tokenRequestSignedDPop
63
63
  },
64
64
  body: authorizationRequestFormBody.toString()
65
- }).then(hasStatus(200)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
65
+ }).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
66
66
  if (!tokenRes.success) {
67
- throw new ValidationFailed(tokenRes.error.message);
67
+ throw new ValidationFailed({
68
+ message: "Token Response validation failed",
69
+ reason: tokenRes.error.message
70
+ });
68
71
  }
69
72
  return {
70
73
  accessToken: tokenRes.data
@@ -1 +1 @@
1
- {"version":3,"names":["hasStatus","createDPopToken","uuid","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","ValidationFailed","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","v4","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","error","message","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,SAAS,QAAkB,kBAAkB;AAGtD,SAASC,eAAe,QAAQ,kBAAkB;AAClD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAiBrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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A4B,GAAG,IAAIC,eAAe,CAACR,WAAW,CAAC;EACrE,MAAMS,QAAQ,GAAG,MAAMpC,QAAQ,CAACmB,QAAQ,EAAE;IACxCkB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAElB;IACR,CAAC;IACDmB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAACzD,SAAS,CAAC,GAAG,CAAC,CAAC,CACpByD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,IAAKjD,aAAa,CAACsD,SAAS,CAACL,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrB,MAAM,IAAItD,gBAAgB,CAAC4C,QAAQ,CAACW,KAAK,CAACC,OAAO,CAAC;EACpD;EAEA,OAAO;IAAEC,WAAW,EAAEb,QAAQ,CAACc;EAAK,CAAC;AACvC,CAAC"}
1
+ {"version":3,"names":["hasStatusOrThrow","createDPopToken","uuid","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","v4","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","message","reason","error","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;A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CAAC,CAAE,EAAC;IACnBf,GAAG;IACHG;EACF,CAAC,EACDV,gBACF,CAAC;EAED,MAAMwB,WAAW,GAAG;IAClBC,UAAU,EAAE,oBAAoB;IAChCC,SAAS,EAAEjC,QAAQ;IACnBD,IAAI;IACJmC,YAAY,EAAEjC,WAAW;IACzBkC,aAAa,EAAEjC,YAAY;IAC3BkC,qBAAqB,EAAE3C,cAAc;IACrC4C,gBAAgB,EAAE/B,yBAAyB,GAAG,GAAG,GAAGwB;EACtD,CAAC;EAED,MAAMQ,4BAA4B,GAAG,IAAIC,eAAe,CAACR,WAAW,CAAC;EACrE,MAAMS,QAAQ,GAAG,MAAMpC,QAAQ,CAACmB,QAAQ,EAAE;IACxCkB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAElB;IACR,CAAC;IACDmB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC1D,gBAAgB,CAAC,GAAG,EAAEO,mBAAmB,CAAC,CAAC,CAChDmD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,IAAKlD,aAAa,CAACuD,SAAS,CAACL,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrB,MAAM,IAAItD,gBAAgB,CAAC;MACzBuD,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAEZ,QAAQ,CAACa,KAAK,CAACF;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEG,WAAW,EAAEd,QAAQ,CAACe;EAAK,CAAC;AACvC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { sha256ToBase64, SignJWT } from "@pagopa/io-react-native-jwt";
2
- import { hasStatus, safeJsonParse } from "../../utils/misc";
3
- import { CredentialInvalidStatusError, CredentialIssuingNotSynchronousError, CredentialRequestError, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
4
- import { CredentialIssuanceFailureResponse, CredentialResponse } from "./types";
2
+ import { hasStatusOrThrow } from "../../utils/misc";
3
+ import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
4
+ import { CredentialResponse } from "./types";
5
5
  import { createDPopToken } from "../../utils/dpop";
6
6
  import uuid from "react-native-uuid";
7
7
  export const createNonceProof = async (nonce, issuer, audience, ctx) => {
@@ -46,9 +46,11 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
46
46
  const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
47
47
 
48
48
  // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
49
- const constainsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
50
- if (!constainsCredentialDefinition) {
51
- throw new ValidationFailed("The access token response does not contain the requested credential");
49
+ const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
50
+ if (!containsCredentialDefinition) {
51
+ throw new ValidationFailed({
52
+ message: "The access token response does not contain the requested credential"
53
+ });
52
54
  }
53
55
 
54
56
  /** The credential request body */
@@ -62,7 +64,7 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
62
64
  proof_type: "jwt"
63
65
  }
64
66
  };
65
- const tokenRequestSignedDPop = await await createDPopToken({
67
+ const tokenRequestSignedDPop = await createDPopToken({
66
68
  htm: "POST",
67
69
  htu: credentialUrl,
68
70
  jti: `${uuid.v4()}`,
@@ -76,9 +78,12 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
76
78
  Authorization: `${accessToken.token_type} ${accessToken.access_token}`
77
79
  },
78
80
  body: JSON.stringify(credentialRequestFormBody)
79
- }).then(hasStatus(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
81
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
80
82
  if (!credentialRes.success) {
81
- throw new ValidationFailed(credentialRes.error.message);
83
+ throw new ValidationFailed({
84
+ message: "Credential Response validation failed",
85
+ reason: credentialRes.error.message
86
+ });
82
87
  }
83
88
  return credentialRes.data;
84
89
  };
@@ -94,16 +99,20 @@ const handleObtainCredentialError = e => {
94
99
  if (!(e instanceof UnexpectedStatusCodeError)) {
95
100
  throw e;
96
101
  }
97
-
98
- // Although it is technically not an error, we handle it as such to avoid
99
- // changing the return type of `obtainCredential` and introduce a breaking change.
100
- if (e.statusCode === 201) {
101
- throw new CredentialIssuingNotSynchronousError("This credential cannot be issued synchronously. It will be available at a later time.", e.message);
102
- }
103
- if ([403, 404].includes(e.statusCode)) {
104
- const maybeError = CredentialIssuanceFailureResponse.safeParse(safeJsonParse(e.responseBody));
105
- throw new CredentialInvalidStatusError("Invalid status found for the given credential", maybeError.success ? maybeError.data.error : "unknown", e.message);
106
- }
107
- throw new CredentialRequestError(`Unable to obtain the requested credential [response status code: ${e.statusCode}]`, e.message);
102
+ throw new ResponseErrorBuilder(IssuerResponseError).handle(201, {
103
+ // Although it is technically not an error, we handle it as such to avoid
104
+ // changing the return type of `obtainCredential` and introduce a breaking change.
105
+ code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
106
+ message: "This credential cannot be issued synchronously. It will be available at a later time."
107
+ }).handle(403, {
108
+ code: IssuerResponseErrorCodes.CredentialInvalidStatus,
109
+ message: "Invalid status found for the given credential"
110
+ }).handle(404, {
111
+ code: IssuerResponseErrorCodes.CredentialInvalidStatus,
112
+ message: "Invalid status found for the given credential"
113
+ }).handle("*", {
114
+ code: IssuerResponseErrorCodes.CredentialRequestFailed,
115
+ message: "Unable to obtain the requested credential"
116
+ }).buildFrom(e);
108
117
  };
109
118
  //# sourceMappingURL=06-obtain-credential.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sha256ToBase64","SignJWT","hasStatus","safeJsonParse","CredentialInvalidStatusError","CredentialIssuingNotSynchronousError","CredentialRequestError","UnexpectedStatusCodeError","ValidationFailed","CredentialIssuanceFailureResponse","CredentialResponse","createDPopToken","uuid","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","constainsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","htm","htu","jti","v4","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","res","json","safeParse","catch","handleObtainCredentialError","success","error","message","data","e","statusCode","includes","maybeError","responseBody"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SACEA,cAAc,EACdC,OAAO,QAEF,6BAA6B;AAGpC,SAASC,SAAS,EAAEC,aAAa,QAAkB,kBAAkB;AAErE,SACEC,4BAA4B,EAC5BC,oCAAoC,EACpCC,sBAAsB,EACtBC,yBAAyB,EACzBC,gBAAgB,QACX,oBAAoB;AAC3B,SAASC,iCAAiC,EAAEC,kBAAkB,QAAQ,SAAS;AAE/E,SAASC,eAAe,QAAQ,kBAAkB;AAClD,OAAOC,IAAI,MAAM,mBAAmB;AAcpC,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIlB,OAAO,CAACgB,GAAG,CAAC,CAC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0E,CAAC;EACT;;EAEA;EACA;EACA,IAAIA,CAAC,CAACC,UAAU,KAAK,GAAG,EAAE;IACxB,MAAM,IAAI7E,oCAAoC,CAC5C,uFAAuF,EACvF4E,CAAC,CAACF,OACJ,CAAC;EACH;EAEA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACI,QAAQ,CAACF,CAAC,CAACC,UAAU,CAAC,EAAE;IACrC,MAAME,UAAU,GAAG3E,iCAAiC,CAACiE,SAAS,CAC5DvE,aAAa,CAAC8E,CAAC,CAACI,YAAY,CAC9B,CAAC;IACD,MAAM,IAAIjF,4BAA4B,CACpC,+CAA+C,EAC/CgF,UAAU,CAACP,OAAO,GAAGO,UAAU,CAACJ,IAAI,CAACF,KAAK,GAAG,SAAS,EACtDG,CAAC,CAACF,OACJ,CAAC;EACH;EAEA,MAAM,IAAIzE,sBAAsB,CAC7B,oEAAmE2E,CAAC,CAACC,UAAW,GAAE,EACnFD,CAAC,CAACF,OACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","uuid","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","htm","htu","jti","v4","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","res","json","safeParse","catch","handleObtainCredentialError","success","reason","error","data","e","handle","code","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SAEEA,cAAc,EACdC,OAAO,QACF,6BAA6B;AAGpC,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,EACzBC,gBAAgB,QACX,oBAAoB;AAC3B,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,eAAe,QAAQ,kBAAkB;AAClD,OAAOC,IAAI,MAAM,mBAAmB;AAcpC,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIhB,OAAO,CAACc,GAAG,CAAC,CACpBG,UAAU,CAAC;IACVN;EACF,CAAC,CAAC,CACDO,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC3BJ;EACF,CAAC,CAAC,CACDK,WAAW,CAACP,QAAQ,CAAC,CACrBQ,SAAS,CAACT,MAAM,CAAC,CACjBU,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,MAAM,CAAC,CACzBC,IAAI,CAAC,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,WAAW,EACXC,QAAQ,EACRC,oBAAoB,EACpBC,OAAO,KACJ;EACH,MAAM;IACJC,uBAAuB;IACvBC,QAAQ,GAAGC,KAAK;IAChBC;EACF,CAAC,GAAGJ,OAAO;EAEX,MAAMK,aAAa,GAAGT,UAAU,CAACU,wBAAwB,CAACC,mBAAmB;;EAE7E;AACF;AACA;AACA;AACA;EACE,MAAMC,gBAAgB,GAAG,MAAM5B,gB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;
39
39
 
40
40
  ## Mapped results
41
41
 
42
- ### 201 Created (CredentialIssuingNotSynchronousError)
42
+ The following errors are mapped to a `IssuerResponseError` with specific codes.
43
43
 
44
- A `201 Created` response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time.
45
-
46
- Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous.
47
- This allows keeping the flow consistent and handle the case where the credential is not immediately available.
48
-
49
- ### 403 Forbidden (CredentialInvalidStatusError)
50
-
51
- A `403 Forbidden` response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `errorCode` property.
52
-
53
- ### 404 Not Found (CredentialInvalidStatusError)
54
-
55
- A `404 Not Found` response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `errorCode` property.
44
+ |HTTP Status|Error Code|Description|
45
+ |-----------|----------|-----------|
46
+ |`201 Created`|`ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS`| This response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time. Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous. This allows keeping the flow consistent and handle the case where the credential is not immediately available.|
47
+ |`403 Forbidden`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `reason` property.|
48
+ |`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`| This response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `reason` property.|
49
+ |`*`|`ERR_ISSUER_GENERIC_ERROR`|This is a generic error code to map unexpected errors that occurred when interacting with the Issuer.|
56
50
 
57
51
  ## Strong authentication for eID issuance (Query Mode)
58
52
 
@@ -278,7 +272,7 @@ const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
278
272
  appFetch,
279
273
  });
280
274
 
281
- // Complete the authroization process with query mode with the authorizationContext which opens the browser
275
+ // Complete the authorization process with query mode with the authorizationContext which opens the browser
282
276
  const { code } =
283
277
  await Credential.Issuance.completeUserAuthorizationWithQueryMode(
284
278
  issuerRequestUri,
@@ -0,0 +1,44 @@
1
+ import { IoWalletError, serializeAttrs } from "../../utils/errors";
2
+
3
+ /**
4
+ * An error subclass thrown when an error occurs during the authorization process.
5
+ */
6
+ export class AuthorizationError extends IoWalletError {
7
+ code = "ERR_IO_WALLET_AUTHORIZATION_ERROR";
8
+ constructor(message) {
9
+ super(message);
10
+ }
11
+ }
12
+
13
+ /**
14
+ * An error subclass thrown when an error occurs during the authorization process with the IDP.
15
+ * It contains the error and error description returned by the IDP.
16
+ */
17
+ export class AuthorizationIdpError extends IoWalletError {
18
+ code = "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_PARSING_FAILED";
19
+ constructor(error, errorDescription) {
20
+ super(serializeAttrs({
21
+ error,
22
+ errorDescription
23
+ }));
24
+ this.error = error;
25
+ this.errorDescription = errorDescription;
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Error subclass thrown when an operation has been aborted.
31
+ */
32
+ export class OperationAbortedError extends IoWalletError {
33
+ code = "ERR_IO_WALLET_OPERATION_ABORTED";
34
+
35
+ /** The aborted operation */
36
+
37
+ constructor(operation) {
38
+ super(serializeAttrs({
39
+ operation
40
+ }));
41
+ this.operation = operation;
42
+ }
43
+ }
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IoWalletError","serializeAttrs","AuthorizationError","code","constructor","message","AuthorizationIdpError","error","errorDescription","OperationAbortedError","operation"],"sourceRoot":"../../../../src","sources":["credential/issuance/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASF,aAAa,CAAC;EACpDG,IAAI,GAAG,mCAAmC;EAE1CC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASN,aAAa,CAAC;EACvDG,IAAI,GAAG,sDAAsD;EAK7DC,WAAWA,CAACG,KAAa,EAAEC,gBAAyB,EAAE;IACpD,KAAK,CAACP,cAAc,CAAC;MAAEM,KAAK;MAAEC;IAAiB,CAAC,CAAC,CAAC;IAClD,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EAC1C;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAAST,aAAa,CAAC;EACvDG,IAAI,GAAG,iCAAiC;;EAExC;;EAGAC,WAAWA,CAACM,SAAiB,EAAE;IAC7B,KAAK,CAACT,cAAc,CAAC;MAAES;IAAU,CAAC,CAAC,CAAC;IACpC,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;AACF"}
@@ -1,8 +1,9 @@
1
1
  import { evaluateIssuerTrust } from "./02-evaluate-issuer-trust";
2
2
  import { startUserAuthorization } from "./03-start-user-authorization";
3
- import { completeUserAuthorizationWithQueryMode, completeUserAuthorizationWithFormPostJwtMode, parseAuthroizationResponse, getRequestedCredentialToBePresented } from "./04-complete-user-authorization";
3
+ import { completeUserAuthorizationWithQueryMode, completeUserAuthorizationWithFormPostJwtMode, parseAuthorizationResponse, buildAuthorizationUrl, getRequestedCredentialToBePresented } from "./04-complete-user-authorization";
4
4
  import { authorizeAccess } from "./05-authorize-access";
5
5
  import { obtainCredential } from "./06-obtain-credential";
6
6
  import { verifyAndParseCredential } from "./07-verify-and-parse-credential";
7
- export { evaluateIssuerTrust, startUserAuthorization, completeUserAuthorizationWithQueryMode, getRequestedCredentialToBePresented, completeUserAuthorizationWithFormPostJwtMode, authorizeAccess, obtainCredential, verifyAndParseCredential, parseAuthroizationResponse };
7
+ import * as Errors from "./errors";
8
+ export { evaluateIssuerTrust, startUserAuthorization, buildAuthorizationUrl, completeUserAuthorizationWithQueryMode, getRequestedCredentialToBePresented, completeUserAuthorizationWithFormPostJwtMode, authorizeAccess, obtainCredential, verifyAndParseCredential, parseAuthorizationResponse, Errors };
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","completeUserAuthorizationWithFormPostJwtMode","parseAuthroizationResponse","getRequestedCredentialToBePresented","authorizeAccess","obtainCredential","verifyAndParseCredential"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AACtC,SACEC,sCAAsC,EACtCC,4CAA4C,EAC5CC,0BAA0B,EAI1BC,mCAAmC,QAC9B,kCAAkC;AACzC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SACEC,wBAAwB,QAEnB,kCAAkC;AAEzC,SACER,mBAAmB,EACnBC,sBAAsB,EACtBC,sCAAsC,EACtCG,mCAAmC,EACnCF,4CAA4C,EAC5CG,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBJ,0BAA0B"}
1
+ {"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","completeUserAuthorizationWithFormPostJwtMode","parseAuthorizationResponse","buildAuthorizationUrl","getRequestedCredentialToBePresented","authorizeAccess","obtainCredential","verifyAndParseCredential","Errors"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AACtC,SACEC,sCAAsC,EACtCC,4CAA4C,EAC5CC,0BAA0B,EAC1BC,qBAAqB,EAKrBC,mCAAmC,QAC9B,kCAAkC;AACzC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SACEC,wBAAwB,QAEnB,kCAAkC;AACzC,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,SACEV,mBAAmB,EACnBC,sBAAsB,EACtBI,qBAAqB,EACrBH,sCAAsC,EACtCI,mCAAmC,EACnCH,4CAA4C,EAC5CI,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBL,0BAA0B,EAC1BM,MAAM"}
@@ -22,7 +22,4 @@ export const CredentialResponse = z.object({
22
22
  export const ResponseUriResultShape = z.object({
23
23
  redirect_uri: z.string()
24
24
  });
25
- export const CredentialIssuanceFailureResponse = z.object({
26
- error: z.string()
27
- });
28
25
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri","CredentialIssuanceFailureResponse","error"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMe,sBAAsB,GAAGhB,CAAC,CAACG,MAAM,CAAC;EAC7Cc,YAAY,EAAEjB,CAAC,CAACK,MAAM,CAAC;AACzB,CAAC,CAAC;AAIF,OAAO,MAAMa,iCAAiC,GAAGlB,CAAC,CAACG,MAAM,CAAC;EACxDgB,KAAK,EAAEnB,CAAC,CAACK,MAAM,CAAC;AAClB,CAAC,CAAC"}
1
+ {"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMe,sBAAsB,GAAGhB,CAAC,CAACG,MAAM,CAAC;EAC7Cc,YAAY,EAAEjB,CAAC,CAACK,MAAM,CAAC;AACzB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod";
2
2
  import { decodeBase64 } from "@pagopa/io-react-native-jwt";
3
- import { AuthRequestDecodeError } from "../../utils/errors";
3
+ import { AuthRequestDecodeError } from "./errors";
4
4
  const QRCodePayload = z.object({
5
5
  protocol: z.string(),
6
6
  resource: z.string(),
@@ -1 +1 @@
1
- {"version":3,"names":["z","decodeBase64","AuthRequestDecodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decoded","decodedUrl","URL","hostname","searchParams","get","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,sBAAsB,QAAQ,oBAAoB;AAE3D,MAAMC,aAAa,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC7BC,QAAQ,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBC,QAAQ,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EAAE;EACtBE,QAAQ,EAAER,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBG,UAAU,EAAET,CAAC,CAACM,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAoC,GAAIC,MAAM,IAAK;EAC9D,MAAMC,OAAO,GAAGX,YAAY,CAACU,MAAM,CAAC;EACpC,MAAME,UAAU,GAAG,IAAIC,GAAG,CAACF,OAAO,CAAC;EACnC,MAAMP,QAAQ,GAAGQ,UAAU,CAACR,QAAQ;EACpC,MAAME,QAAQ,GAAGM,UAAU,CAACE,QAAQ;EACpC,MAAMN,UAAU,GAAGI,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;EAC7D,MAAMT,QAAQ,GAAGK,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,WAAW,CAAC;EAEzD,MAAMC,MAAM,GAAGf,aAAa,CAACgB,SAAS,CAAC;IACrCd,QAAQ;IACRE,QAAQ;IACRE,UAAU;IACVD;EACF,CAAC,CAAC;EAEF,IAAIU,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAInB,sBAAsB,CAACgB,MAAM,CAACI,KAAK,CAACC,OAAO,EAAG,GAAEV,UAAW,EAAC,CAAC;EACzE;AACF,CAAC"}
1
+ {"version":3,"names":["z","decodeBase64","AuthRequestDecodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decoded","decodedUrl","URL","hostname","searchParams","get","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,sBAAsB,QAAQ,UAAU;AAEjD,MAAMC,aAAa,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC7BC,QAAQ,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBC,QAAQ,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EAAE;EACtBE,QAAQ,EAAER,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBG,UAAU,EAAET,CAAC,CAACM,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAoC,GAAIC,MAAM,IAAK;EAC9D,MAAMC,OAAO,GAAGX,YAAY,CAACU,MAAM,CAAC;EACpC,MAAME,UAAU,GAAG,IAAIC,GAAG,CAACF,OAAO,CAAC;EACnC,MAAMP,QAAQ,GAAGQ,UAAU,CAACR,QAAQ;EACpC,MAAME,QAAQ,GAAGM,UAAU,CAACE,QAAQ;EACpC,MAAMN,UAAU,GAAGI,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;EAC7D,MAAMT,QAAQ,GAAGK,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,WAAW,CAAC;EAEzD,MAAMC,MAAM,GAAGf,aAAa,CAACgB,SAAS,CAAC;IACrCd,QAAQ;IACRE,QAAQ;IACRE,UAAU;IACVD;EACF,CAAC,CAAC;EAEF,IAAIU,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAInB,sBAAsB,CAACgB,MAAM,CAACI,KAAK,CAACC,OAAO,EAAG,GAAEV,UAAW,EAAC,CAAC;EACzE;AACF,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import uuid from "react-native-uuid";
2
2
  import { decode as decodeJwt, sha256ToBase64, verify } from "@pagopa/io-react-native-jwt";
3
3
  import { createDPopToken } from "../../utils/dpop";
4
- import { NoSuitableKeysFoundInEntityConfiguration } from "../../utils/errors";
5
- import { hasStatus } from "../../utils/misc";
4
+ import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
5
+ import { hasStatusOrThrow } from "../../utils/misc";
6
6
  import { RequestObject } from "./types";
7
7
  /**
8
8
  * Obtain the Request Object for RP authentication
@@ -33,7 +33,7 @@ export const getRequestObject = async (requestUri, rpConf, _ref) => {
33
33
  Authorization: `DPoP ${walletInstanceAttestation}`,
34
34
  DPoP: signedWalletInstanceDPoP
35
35
  }
36
- }).then(hasStatus(200)).then(res => res.json()).then(responseJson => responseJson.response);
36
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(responseJson => responseJson.response);
37
37
  const responseJwt = decodeJwt(responseEncodedJwt);
38
38
 
39
39
  // verify token signature according to RP's entity configuration
@@ -1 +1 @@
1
- {"version":3,"names":["uuid","decode","decodeJwt","sha256ToBase64","verify","createDPopToken","NoSuitableKeysFoundInEntityConfiguration","hasStatus","RequestObject","getRequestObject","requestUri","rpConf","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","signedWalletInstanceDPoP","jti","v4","htm","htu","ath","responseEncodedJwt","method","headers","Authorization","DPoP","then","res","json","responseJson","response","responseJwt","pubKey","wallet_relying_party","jwks","keys","find","_ref2","kid","protectedHeader","requestObject","parse","payload"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,mBAAmB;AACpC,SACEC,MAAM,IAAIC,SAAS,EACnBC,cAAc,EACdC,MAAM,QAED,6BAA6B;AAEpC,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,wCAAwC,QAAQ,oBAAoB;AAE7E,SAASC,SAAS,QAAkB,kBAAkB;AAEtD,SAASC,aAAa,QAAQ,SAAS;AAYvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,MAAM,EAAAC,IAAA,KAEH;EAAA,IADH;IAAEC,gBAAgB;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAA0B,CAAC,GAAAJ,IAAA;EAEjE,MAAMK,wBAAwB,GAAG,MAAMZ,eAAe,CACpD;IACEa,GAAG,EAAG,GAAElB,IAAI,CAACmB,EAAE,CAAC,CAAE,EAAC;IACnBC,GAAG,EAAE,KAAK;IACVC,GAAG,EAAEX,UAAU;IACfY,GAAG,EAAE,MAAMnB,cAAc,CAACa,yBAAyB;EACrD,CAAC,EACDH,gBACF,CAAC;EAED,MAAMU,kBAAkB,GAAG,MAAMT,QAAQ,CAACJ,UAAU,EAAE;IACpDc,MAAM,EAAE,KAAK;IACbC,OAAO,EAAE;MACPC,aAAa,EAAG,QAAOV,yBAA0B,EAAC;MAClDW,IAAI,EAAEV;IACR;EACF,CAAC,CAAC,CACCW,IAAI,CAACrB,SAAS,CAAC,GAAG,CAAC,CAAC,CACpBqB,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEG,YAAY,IAAKA,YAAY,CAACC,QAAQ,CAAC;EAEhD,MAAMC,WAAW,GAAG/B,SAAS,CAACqB,kBAAkB,CAAC;;EAEjD;EACA;EACA;IACE,MAAMW,MAAM,GAAGvB,MAAM,CAACwB,oBAAoB,CAACC,IAAI,CAACC,IAAI,CAACC,IAAI,CACvDC,KAAA;MAAA,IAAC;QAAEC;MAAI,CAAC,GAAAD,KAAA;MAAA,OAAKC,GAAG,KAAKP,WAAW,CAACQ,eAAe,CAACD,GAAG;IAAA,CACtD,CAAC;IACD,IAAI,CAACN,MAAM,EAAE;MACX,MAAM,IAAI5B,wCAAwC,CAChD,uCACF,CAAC;IACH;IACA,MAAMF,MAAM,CAACmB,kBAAkB,EAAEW,MAAM,CAAC;EAC1C;;EAEA;EACA,MAAMQ,aAAa,GAAGlC,aAAa,CAACmC,KAAK,CAACV,WAAW,CAACW,OAAO,CAAC;EAE9D,OAAO;IACLF;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["uuid","decode","decodeJwt","sha256ToBase64","verify","createDPopToken","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","RequestObject","getRequestObject","requestUri","rpConf","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","signedWalletInstanceDPoP","jti","v4","htm","htu","ath","responseEncodedJwt","method","headers","Authorization","DPoP","then","res","json","responseJson","response","responseJwt","pubKey","wallet_relying_party","jwks","keys","find","_ref2","kid","protectedHeader","requestObject","parse","payload"],"sourceRoot":"../../../../src","sources":["cred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ACC,IAAI,CAACC,IAAI,CAACC,IAAI,CACvDC,KAAA;MAAA,IAAC;QAAEC;MAAI,CAAC,GAAAD,KAAA;MAAA,OAAKC,GAAG,KAAKP,WAAW,CAACQ,eAAe,CAACD,GAAG;IAAA,CACtD,CAAC;IACD,IAAI,CAACN,MAAM,EAAE;MACX,MAAM,IAAI5B,wCAAwC,CAChD,uCACF,CAAC;IACH;IACA,MAAMF,MAAM,CAACmB,kBAAkB,EAAEW,MAAM,CAAC;EAC1C;;EAEA;EACA,MAAMQ,aAAa,GAAGlC,aAAa,CAACmC,KAAK,CAACV,WAAW,CAACW,OAAO,CAAC;EAE9D,OAAO;IACLF;EACF,CAAC;AACH,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { EncryptJwe, SignJWT } from "@pagopa/io-react-native-jwt";
2
2
  import uuid from "react-native-uuid";
3
3
  import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
4
- import { NoSuitableKeysFoundInEntityConfiguration } from "../../utils/errors";
5
- import { hasStatus } from "../../utils/misc";
4
+ import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
5
+ import { hasStatusOrThrow } from "../../utils/misc";
6
6
  import { disclose } from "../../sd-jwt";
7
7
  import * as z from "zod";
8
8
  export const AuthorizationResponse = z.object({
@@ -123,6 +123,6 @@ export const sendAuthorizationResponse = async (requestObject, rpConf, presentat
123
123
  "Content-Type": "application/x-www-form-urlencoded"
124
124
  },
125
125
  body
126
- }).then(hasStatus(200)).then(res => res.json()).then(AuthorizationResponse.parse);
126
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
127
127
  };
128
128
  //# sourceMappingURL=04-send-authorization-response.js.map