@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,13 +1,14 @@
1
1
  import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/auth";
2
- import { createAbortPromiseFromSignal, hasStatus, isDefined, until } from "../../utils/misc";
2
+ import { createAbortPromiseFromSignal, hasStatusOrThrow, isDefined, until } from "../../utils/misc";
3
3
  import parseUrl from "parse-url";
4
- import { AuthorizationError, AuthorizationIdpError, OperationAbortedError, ValidationFailed } from "../../utils/errors";
4
+ import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
5
5
  import { Linking } from "react-native";
6
6
  import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
7
7
  import { RequestObject } from "../presentation/types";
8
8
  import uuid from "react-native-uuid";
9
9
  import { ResponseUriResultShape } from "./types";
10
10
  import { getJwtFromFormPost } from "../../utils/decoder";
11
+ import { AuthorizationError, AuthorizationIdpError, OperationAbortedError } from "./errors";
11
12
 
12
13
  /**
13
14
  * 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.
@@ -82,7 +83,7 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
82
83
  }
83
84
  }
84
85
  const query = parseUrl(authRedirectUrl).query;
85
- return parseAuthroizationResponse(query);
86
+ return parseAuthorizationResponse(query);
86
87
  };
87
88
 
88
89
  /**
@@ -106,9 +107,12 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
106
107
  });
107
108
  const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
108
109
  method: "GET"
109
- }).then(hasStatus(200)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
110
+ }).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
110
111
  if (!requestObject.success) {
111
- throw new ValidationFailed("Request Object validation failed", requestObject.error.message);
112
+ throw new ValidationFailed({
113
+ message: "Request Object validation failed",
114
+ reason: requestObject.error.message
115
+ });
112
116
  }
113
117
  return requestObject.data;
114
118
  };
@@ -194,12 +198,15 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
194
198
  "Content-Type": "application/x-www-form-urlencoded"
195
199
  },
196
200
  body
197
- }).then(hasStatus(200)).then(reqUri => reqUri.json());
201
+ }).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
198
202
  const responseUri = ResponseUriResultShape.safeParse(resUriRes);
199
203
  if (!responseUri.success) {
200
- throw new ValidationFailed("Response Uri validation failed", responseUri.error.message);
204
+ throw new ValidationFailed({
205
+ message: "Response Uri validation failed",
206
+ reason: responseUri.error.message
207
+ });
201
208
  }
202
- return await appFetch(responseUri.data.redirect_uri).then(hasStatus(200)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthroizationResponse(cbRes.decodedJwt.payload));
209
+ return await appFetch(responseUri.data.redirect_uri).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthorizationResponse(cbRes.decodedJwt.payload));
203
210
  };
204
211
 
205
212
  /**
@@ -209,7 +216,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
209
216
  * @param authRes the authorization response to be parsed
210
217
  * @returns the authorization result which contains code, state and iss
211
218
  */
212
- export const parseAuthroizationResponse = authRes => {
219
+ export const parseAuthorizationResponse = authRes => {
213
220
  const authResParsed = AuthorizationResultShape.safeParse(authRes);
214
221
  if (!authResParsed.success) {
215
222
  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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AAC,CAAC,CAAC,CACzBF,IAAI,CAACrD,kBAAkB,CAAC,CACxBqD,IAAI,CAAEmD,KAAK,IAAK5D,0BAA0B,CAAC4D,KAAK,CAACC,UAAU,CAAC9C,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMf,0BAA0B,GACrC8D,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAG5H,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","createAbortPromiseFromSignal","hasStatusOrThrow","isDefined","until","parseUrl","IssuerResponseError","ValidationFailed","Linking","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","OperationAbortedError","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","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","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":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAGnB,kBAAkB;AACzB,SACEC,4BAA4B,EAC5BC,gBAAgB,EAChBC,SAAS,EACTC,KAAK,QAEA,kBAAkB;AAEzB,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SAASC,OAAO,QAAQ,cAAc;AACtC,SACEC,MAAM,EACNC,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,qBAAqB,QAChB,UAAU;;AAEjB;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sCAA8E,GACzF,MAAAA,CACEC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,WAAW,EACXC,oBAAoB,EACpBC,MAAM,KACH;EACH,MAAMC,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O,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAI3B,qBAAqB,CAC7B8G,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;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAgC,GAAG,MAAAA,CAC9CC,UAAU,EACVC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,OAAO,KACJ;EACH,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC,gBAAgB;IAChBC;EACF,CAAC,GAAGL,OAAO;EAEX,MAAMM,WAAW,GACfX,UAAU,CAACY,0BAA0B,CAACC,qCAAqC;EAC7E,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAACJ,WAAW,CAAC;EACnC,MAAMK,GAAG,GAAI,GAAEF,MAAM,CAACG,QAAS,KAAIH,MAAM,CAACI,QAAS,EAAC;EACpD,MAAMC,GAAG,GAAGxB,yBAAyB,CAACyB,MAAM,CAACZ,yBAAyB,CAAC,CACpEa,OAAO,CAACC,GAAG,CAACC,GAA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B,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;AAG7D,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,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAiB1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAgC,GAAG,MAAAA,CAC9CC,UAAU,EACVC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,OAAO,KACJ;EACH,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC,gBAAgB;IAChBC;E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DmB,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,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,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B,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,CAAC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AA2B,GAAIK,CAAU,IAAK;EAClD,IAAI,EAAEA,CAAC,YAAY1E,yBAAyB,CAAC,EAAE;IAC7C,MAAM0E,CAAC;EACT;EAEA,MAAM,IAAI3E,oBAAoB,CAACF,mBAAmB,CAAC,CAChD8E,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAE9E,wBAAwB,CAAC+E,+BAA+B;IAC9DnC,OAAO,EACL;EACJ,CAAC,CAAC,CACDiC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE9E,wBAAwB,CAACgF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDiC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE9E,wBAAwB,CAACgF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDiC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE9E,wBAAwB,CAACiF,uBAAuB;IACtDrC,OAAO,EAAE;EACX,CAAC,CAAC,CACDsC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
@@ -39,20 +39,14 @@ graph TD;
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, 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, 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","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,EAI1BC,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,SACET,mBAAmB,EACnBC,sBAAsB,EACtBC,sCAAsC,EACtCG,mCAAmC,EACnCF,4CAA4C,EAC5CG,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBJ,0BAA0B,EAC1BK,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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equestDecodeError","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,Q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ACtD,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":["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,UAAU;AAEnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,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,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BqB,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,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
@@ -1 +1 @@
1
- {"version":3,"names":["EncryptJwe","SignJWT","uuid","WalletInstanceAttestation","NoSuitableKeysFoundInEntityConfiguration","hasStatus","disclose","z","AuthorizationResponse","object","status","string","response_code","optional","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","wallet_relying_party","jwks","keys","filter","jwk","use","kty","prepareVpToken","requestObject","walletInstanceAttestation","_ref","vc","claims","cryptoCtx","token","vp","paths","payload","iss","decode","pidKid","getPublicKey","then","_","kid","vp_token","setProtectedHeader","typ","setPayload","jti","v4","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","rpConf","presentation","_ref2","appFetch","fetch","rsaPublicJwk","authzResponsePayload","JSON","stringify","state","encrypted","alg","enc","encrypt","formBody","URLSearchParams","response","body","toString","method","headers","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,6BAA6B;AACjE,OAAOC,IAAI,MAAM,mBAAmB;AACpC,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,wCAAwC,QAAQ,oBAAoB;AAC7E,SAASC,SAAS,QAAkB,kBAAkB;AAE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Q;IAAEc;EAAwB,CAAC,GAAG,MAAMhC,cAAc,CAChEC,aAAa,EACbC,yBAAyB,EACzBwC,YACF,CAAC;EAED,MAAMK,oBAAoB,GAAGC,IAAI,CAACC,SAAS,CAAC;IAC1CC,KAAK,EAAEjD,aAAa,CAACiD,KAAK;IAC1BlB,uBAAuB;IACvBR,KAAK,EAAEvB,aAAa,CAACuB,KAAK;IAC1BN;EACF,CAAC,CAAC;EAEF,MAAMiC,SAAS,GAAG,MAAM,IAAI3E,UAAU,CAACuE,oBAAoB,EAAE;IAC3DK,GAAG,EAAE,cAAc;IACnBC,GAAG,EAAE,eAAe;IACpBpC,GAAG,EAAE6B,YAAY,CAAC7B;EACpB,CAAC,CAAC,CAACqC,OAAO,CAACR,YAAY,CAAC;EAExB,MAAMS,QAAQ,GAAG,IAAIC,eAAe,CAAC;IAAEC,QAAQ,EAAEN;EAAU,CAAC,CAAC;EAC7D,MAAMO,IAAI,GAAGH,QAAQ,CAACI,QAAQ,CAAC,CAAC;EAEhC,OAAOf,QAAQ,CAAC3C,aAAa,CAACyB,YAAY,EAAE;IAC1CkC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IACDH;EACF,CAAC,CAAC,CACC3C,IAAI,CAAClC,SAAS,CAAC,GAAG,CAAC,CAAC,CACpBkC,IAAI,CAAE+C,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBhD,IAAI,CAAC/B,qBAAqB,CAACgF,KAAK,CAAC;AACtC,CAAC"}
1
+ {"version":3,"names":["EncryptJwe","SignJWT","uuid","WalletInstanceAttestation","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","disclose","z","AuthorizationResponse","object","status","string","response_code","optional","chooseRSAPublicKeyToEncrypt","entity","usingRsa256","wallet_relying_party","jwks","keys","filter","jwk","use","kty","prepareVpToken","requestObject","walletInstanceAttestation","_ref","vc","claims","cryptoCtx","token","vp","paths","payload","iss","decode","pidKid","getPublicKey","then","_","kid","vp_token","setProtectedHeader","typ","setPayload","jti","v4","nonce","setAudience","response_uri","setIssuedAt","setExpirationTime","sign","vc_scope","scope","presentation_submission","definition_id","id","descriptor_map","map","p","path","format","sendAuthorizationResponse","rpConf","presentation","_ref2","appFetch","fetch","rsaPublicJwk","authzResponsePayload","JSON","stringify","state","encrypted","alg","enc","encrypt","formBody","URLSearchParams","response","body","toString","method","headers","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/presentation/04-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,6BAA6B;AACjE,OAAOC,IAAI,MAAM,mBAAmB;AACpC,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,wCAAwC,QAAQ,UAAU;AACnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SAASC,QAAQ,QAAQ,cAAc;AAGvC,OAAO,KAAKC,CAAC,MAAM,KAAK;AAGxB,OAAO,MAAMC,qBAAqB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC5CC,MAAM,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EAClBC,aAAa,EAAEL,CAAC,CACbI,MAAM,CAAC,CAAC,CAAC;AACd;AACA;AACA;AACA,8BAJc,CAKTE,QAAQ,CAAC;AACd,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,2BAA2B,GAC/BC,MAAgD,IACxC;EACR,MAAM,CAACC,WAAW,CAAC,GAAGD,MAAM,CAACE,oBAAoB,CAACC,IAAI,CAACC,IAAI,CAACC,MAAM,CAC/DC,GAAG,IAAKA,GAAG,CAACC,GAAG,KAAK,KAAK,IAAID,GAAG,CAACE,GAAG,KAAK,KAC5C,CAAC;EAED,IAAIP,WAAW,EAAE;IACf,OAAOA,WAAW;EACpB;;EAEA;EACA,MAAM,IAAIZ,wCAAwC,CAChD,4BACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;A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IACdC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IACDH;EACF,CAAC,CAAC,CACC3C,IAAI,CAAClC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BkC,IAAI,CAAE+C,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBhD,IAAI,CAAC/B,qBAAqB,CAACgF,KAAK,CAAC;AACtC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { IoWalletError, serializeAttrs } from "../../utils/errors";
2
+
3
+ /**
4
+ * An error subclass thrown when auth request decode fail
5
+ *
6
+ */
7
+ export class AuthRequestDecodeError extends IoWalletError {
8
+ code = "ERR_IO_WALLET_AUTHENTICATION_REQUEST_DECODE_FAILED";
9
+
10
+ /** The Claim for which the validation failed. */
11
+
12
+ /** Reason code for the validation failure. */
13
+
14
+ constructor(message) {
15
+ let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "unspecified";
16
+ let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unspecified";
17
+ super(serializeAttrs({
18
+ message,
19
+ claim,
20
+ reason
21
+ }));
22
+ this.claim = claim;
23
+ this.reason = reason;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * When selecting a public key from an entity configuration, and no one meets the requirements for the scenario
29
+ *
30
+ */
31
+ export class NoSuitableKeysFoundInEntityConfiguration extends IoWalletError {
32
+ code = "ERR_NO_SUITABLE_KEYS_NOT_FOUND";
33
+
34
+ /**
35
+ * @param scenario describe the scenario in which the error arise
36
+ */
37
+ constructor(scenario) {
38
+ const message = `Entity configuration do not provide any suitable keys (${scenario}).`;
39
+ super(message);
40
+ }
41
+ }
42
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IoWalletError","serializeAttrs","AuthRequestDecodeError","code","constructor","message","claim","arguments","length","undefined","reason","NoSuitableKeysFoundInEntityConfiguration","scenario"],"sourceRoot":"../../../../src","sources":["credential/presentation/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,SAASF,aAAa,CAAC;EACxDG,IAAI,GAAG,oDAAoD;;EAE3D;;EAGA;;EAGAC,WAAWA,CACTC,OAAe,EAGf;IAAA,IAFAC,KAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAAA,IAC7BG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAE9B,KAAK,CAACN,cAAc,CAAC;MAAEI,OAAO;MAAEC,KAAK;MAAEI;IAAO,CAAC,CAAC,CAAC;IACjD,IAAI,CAACJ,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wCAAwC,SAASX,aAAa,CAAC;EAC1EG,IAAI,GAAG,gCAAgC;;EAEvC;AACF;AACA;EACEC,WAAWA,CAACQ,QAAgB,EAAE;IAC5B,MAAMP,OAAO,GAAI,0DAAyDO,QAAS,IAAG;IACtF,KAAK,CAACP,OAAO,CAAC;EAChB;AACF"}
@@ -2,5 +2,6 @@ import { startFlowFromQR } from "./01-start-flow";
2
2
  import { evaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
3
3
  import { getRequestObject } from "./03-get-request-object";
4
4
  import { sendAuthorizationResponse } from "./04-send-authorization-response";
5
- export { startFlowFromQR, evaluateRelyingPartyTrust, getRequestObject, sendAuthorizationResponse };
5
+ import * as Errors from "./errors";
6
+ export { startFlowFromQR, evaluateRelyingPartyTrust, getRequestObject, sendAuthorizationResponse, Errors };
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["startFlowFromQR","evaluateRelyingPartyTrust","getRequestObject","sendAuthorizationResponse"],"sourceRoot":"../../../../src","sources":["credential/presentation/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAwB,iBAAiB;AACjE,SACEC,yBAAyB,QAEpB,wBAAwB;AAC/B,SACEC,gBAAgB,QAEX,yBAAyB;AAChC,SACEC,yBAAyB,QAEpB,kCAAkC;AAEzC,SACEH,eAAe,EACfC,yBAAyB,EACzBC,gBAAgB,EAChBC,yBAAyB"}
1
+ {"version":3,"names":["startFlowFromQR","evaluateRelyingPartyTrust","getRequestObject","sendAuthorizationResponse","Errors"],"sourceRoot":"../../../../src","sources":["credential/presentation/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAwB,iBAAiB;AACjE,SACEC,yBAAyB,QAEpB,wBAAwB;AAC/B,SACEC,gBAAgB,QAEX,yBAAyB;AAChC,SACEC,yBAAyB,QAEpB,kCAAkC;AACzC,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,SACEJ,eAAe,EACfC,yBAAyB,EACzBC,gBAAgB,EAChBC,yBAAyB,EACzBC,MAAM"}