@pagopa/io-react-native-wallet 0.11.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. package/lib/commonjs/client/generated/wallet-provider.js +126 -0
  2. package/lib/commonjs/client/generated/wallet-provider.js.map +1 -0
  3. package/lib/commonjs/client/index.js +40 -0
  4. package/lib/commonjs/client/index.js.map +1 -0
  5. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +2 -1
  6. package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/03-start-credential-issuance.js +287 -0
  8. package/lib/commonjs/credential/issuance/03-start-credential-issuance.js.map +1 -0
  9. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +56 -83
  10. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +88 -0
  12. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/05-authorize-access.js +56 -33
  14. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  15. package/lib/commonjs/credential/issuance/06-obtain-credential.js +51 -78
  16. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  17. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +21 -44
  18. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  19. package/lib/commonjs/credential/issuance/index.js +7 -0
  20. package/lib/commonjs/credential/issuance/index.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/types.js +28 -0
  22. package/lib/commonjs/credential/issuance/types.js.map +1 -0
  23. package/lib/commonjs/index.js +10 -1
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/pid/sd-jwt/converters.js +5 -9
  26. package/lib/commonjs/pid/sd-jwt/converters.js.map +1 -1
  27. package/lib/commonjs/pid/sd-jwt/types.js +3 -3
  28. package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
  29. package/lib/commonjs/sd-jwt/__test__/converters.test.js +1 -1
  30. package/lib/commonjs/sd-jwt/__test__/converters.test.js.map +1 -1
  31. package/lib/commonjs/sd-jwt/__test__/index.test.js +30 -43
  32. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  33. package/lib/commonjs/sd-jwt/__test__/types.test.js +16 -24
  34. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  35. package/lib/commonjs/sd-jwt/index.js +3 -9
  36. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  37. package/lib/commonjs/sd-jwt/types.js +11 -16
  38. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  39. package/lib/commonjs/trust/types.js +70 -29
  40. package/lib/commonjs/trust/types.js.map +1 -1
  41. package/lib/commonjs/utils/auth.js +44 -0
  42. package/lib/commonjs/utils/auth.js.map +1 -0
  43. package/lib/commonjs/utils/errors.js +104 -1
  44. package/lib/commonjs/utils/errors.js.map +1 -1
  45. package/lib/commonjs/utils/integrity.js +2 -0
  46. package/lib/commonjs/utils/integrity.js.map +1 -0
  47. package/lib/commonjs/utils/misc.js +34 -1
  48. package/lib/commonjs/utils/misc.js.map +1 -1
  49. package/lib/commonjs/utils/par.js +23 -15
  50. package/lib/commonjs/utils/par.js.map +1 -1
  51. package/lib/commonjs/utils/pop.js +33 -0
  52. package/lib/commonjs/utils/pop.js.map +1 -0
  53. package/lib/commonjs/wallet-instance/index.js +29 -0
  54. package/lib/commonjs/wallet-instance/index.js.map +1 -0
  55. package/lib/commonjs/wallet-instance-attestation/issuing.js +62 -65
  56. package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
  57. package/lib/commonjs/wallet-instance-attestation/types.js +8 -8
  58. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  59. package/lib/module/client/generated/wallet-provider.js +102 -0
  60. package/lib/module/client/generated/wallet-provider.js.map +1 -0
  61. package/lib/module/client/index.js +33 -0
  62. package/lib/module/client/index.js.map +1 -0
  63. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +2 -1
  64. package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
  65. package/lib/module/credential/issuance/03-start-credential-issuance.js +276 -0
  66. package/lib/module/credential/issuance/03-start-credential-issuance.js.map +1 -0
  67. package/lib/module/credential/issuance/03-start-user-authorization.js +56 -80
  68. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  69. package/lib/module/credential/issuance/04-complete-user-authorization.js +85 -1
  70. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  71. package/lib/module/credential/issuance/05-authorize-access.js +54 -33
  72. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  73. package/lib/module/credential/issuance/06-obtain-credential.js +50 -75
  74. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  75. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +21 -44
  76. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  77. package/lib/module/credential/issuance/index.js +2 -1
  78. package/lib/module/credential/issuance/index.js.map +1 -1
  79. package/lib/module/credential/issuance/types.js +18 -0
  80. package/lib/module/credential/issuance/types.js.map +1 -0
  81. package/lib/module/index.js +3 -1
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/pid/sd-jwt/converters.js +5 -9
  84. package/lib/module/pid/sd-jwt/converters.js.map +1 -1
  85. package/lib/module/pid/sd-jwt/types.js +3 -3
  86. package/lib/module/pid/sd-jwt/types.js.map +1 -1
  87. package/lib/module/sd-jwt/__test__/converters.test.js +1 -1
  88. package/lib/module/sd-jwt/__test__/converters.test.js.map +1 -1
  89. package/lib/module/sd-jwt/__test__/index.test.js +30 -43
  90. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  91. package/lib/module/sd-jwt/__test__/types.test.js +16 -24
  92. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  93. package/lib/module/sd-jwt/index.js +3 -9
  94. package/lib/module/sd-jwt/index.js.map +1 -1
  95. package/lib/module/sd-jwt/types.js +11 -16
  96. package/lib/module/sd-jwt/types.js.map +1 -1
  97. package/lib/module/trust/types.js +70 -29
  98. package/lib/module/trust/types.js.map +1 -1
  99. package/lib/module/utils/auth.js +35 -0
  100. package/lib/module/utils/auth.js.map +1 -0
  101. package/lib/module/utils/errors.js +98 -0
  102. package/lib/module/utils/errors.js.map +1 -1
  103. package/lib/module/utils/integrity.js +2 -0
  104. package/lib/module/utils/integrity.js.map +1 -0
  105. package/lib/module/utils/misc.js +31 -0
  106. package/lib/module/utils/misc.js.map +1 -1
  107. package/lib/module/utils/par.js +24 -16
  108. package/lib/module/utils/par.js.map +1 -1
  109. package/lib/module/utils/pop.js +24 -0
  110. package/lib/module/utils/pop.js.map +1 -0
  111. package/lib/module/wallet-instance/index.js +23 -0
  112. package/lib/module/wallet-instance/index.js.map +1 -0
  113. package/lib/module/wallet-instance-attestation/issuing.js +63 -67
  114. package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
  115. package/lib/module/wallet-instance-attestation/types.js +8 -8
  116. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  117. package/lib/typescript/client/generated/wallet-provider.d.ts +264 -0
  118. package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -0
  119. package/lib/typescript/client/index.d.ts +7 -0
  120. package/lib/typescript/client/index.d.ts.map +1 -0
  121. package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -0
  122. package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
  123. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +2 -1
  124. package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -1
  125. package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts +41 -0
  126. package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts.map +1 -0
  127. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +23 -18
  128. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  129. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +24 -12
  130. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  131. package/lib/typescript/credential/issuance/05-authorize-access.d.ts +22 -16
  132. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  133. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +19 -26
  134. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  135. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +10 -15
  136. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  137. package/lib/typescript/credential/issuance/index.d.ts +3 -4
  138. package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
  139. package/lib/typescript/credential/issuance/types.d.ts +63 -0
  140. package/lib/typescript/credential/issuance/types.d.ts.map +1 -0
  141. package/lib/typescript/credential/presentation/types.d.ts +6 -6
  142. package/lib/typescript/index.d.ts +6 -1
  143. package/lib/typescript/index.d.ts.map +1 -1
  144. package/lib/typescript/pid/sd-jwt/converters.d.ts.map +1 -1
  145. package/lib/typescript/pid/sd-jwt/types.d.ts +36 -36
  146. package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
  147. package/lib/typescript/sd-jwt/index.d.ts +40 -68
  148. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  149. package/lib/typescript/sd-jwt/types.d.ts +64 -121
  150. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  151. package/lib/typescript/trust/index.d.ts +150 -48
  152. package/lib/typescript/trust/index.d.ts.map +1 -1
  153. package/lib/typescript/trust/types.d.ts +2838 -1740
  154. package/lib/typescript/trust/types.d.ts.map +1 -1
  155. package/lib/typescript/utils/auth.d.ts +52 -0
  156. package/lib/typescript/utils/auth.d.ts.map +1 -0
  157. package/lib/typescript/utils/errors.d.ts +48 -0
  158. package/lib/typescript/utils/errors.d.ts.map +1 -1
  159. package/lib/typescript/utils/integrity.d.ts +21 -0
  160. package/lib/typescript/utils/integrity.d.ts.map +1 -0
  161. package/lib/typescript/utils/misc.d.ts +18 -0
  162. package/lib/typescript/utils/misc.d.ts.map +1 -1
  163. package/lib/typescript/utils/par.d.ts +8 -31
  164. package/lib/typescript/utils/par.d.ts.map +1 -1
  165. package/lib/typescript/utils/pop.d.ts +26 -0
  166. package/lib/typescript/utils/pop.d.ts.map +1 -0
  167. package/lib/typescript/wallet-instance/index.d.ts +7 -0
  168. package/lib/typescript/wallet-instance/index.d.ts.map +1 -0
  169. package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -4
  170. package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
  171. package/lib/typescript/wallet-instance-attestation/types.d.ts +64 -64
  172. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  173. package/package.json +9 -5
  174. package/src/client/generated/wallet-provider.ts +173 -0
  175. package/src/client/index.ts +53 -0
  176. package/src/credential/issuance/01-start-flow.ts +1 -0
  177. package/src/credential/issuance/02-evaluate-issuer-trust.ts +2 -1
  178. package/src/credential/issuance/03-start-credential-issuance.ts +407 -0
  179. package/src/credential/issuance/03-start-user-authorization.ts +91 -92
  180. package/src/credential/issuance/04-complete-user-authorization.ts +114 -13
  181. package/src/credential/issuance/05-authorize-access.ts +74 -49
  182. package/src/credential/issuance/06-obtain-credential.ts +77 -111
  183. package/src/credential/issuance/07-verify-and-parse-credential.ts +30 -67
  184. package/src/credential/issuance/index.ts +6 -4
  185. package/src/credential/issuance/types.ts +25 -0
  186. package/src/index.ts +8 -0
  187. package/src/pid/sd-jwt/converters.ts +5 -11
  188. package/src/pid/sd-jwt/types.ts +8 -6
  189. package/src/sd-jwt/__test__/converters.test.ts +1 -1
  190. package/src/sd-jwt/__test__/index.test.ts +45 -74
  191. package/src/sd-jwt/__test__/types.test.ts +21 -33
  192. package/src/sd-jwt/index.ts +3 -12
  193. package/src/sd-jwt/types.ts +17 -22
  194. package/src/trust/types.ts +64 -32
  195. package/src/utils/auth.ts +37 -0
  196. package/src/utils/errors.ts +112 -0
  197. package/src/utils/integrity.ts +23 -0
  198. package/src/utils/misc.ts +43 -0
  199. package/src/utils/par.ts +29 -17
  200. package/src/utils/pop.ts +34 -0
  201. package/src/wallet-instance/index.ts +29 -0
  202. package/src/wallet-instance-attestation/issuing.ts +101 -97
  203. package/src/wallet-instance-attestation/types.ts +12 -8
  204. package/lib/commonjs/credential/issuance/07-confirm-credential.js +0 -6
  205. package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +0 -1
  206. package/lib/commonjs/credential/issuance/08-confirm-credential.js +0 -6
  207. package/lib/commonjs/credential/issuance/08-confirm-credential.js.map +0 -1
  208. package/lib/module/credential/issuance/07-confirm-credential.js +0 -2
  209. package/lib/module/credential/issuance/07-confirm-credential.js.map +0 -1
  210. package/lib/module/credential/issuance/08-confirm-credential.js +0 -2
  211. package/lib/module/credential/issuance/08-confirm-credential.js.map +0 -1
  212. package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +0 -11
  213. package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +0 -1
  214. package/lib/typescript/credential/issuance/08-confirm-credential.d.ts +0 -11
  215. package/lib/typescript/credential/issuance/08-confirm-credential.d.ts.map +0 -1
  216. package/src/credential/issuance/07-confirm-credential.ts +0 -14
  217. package/src/credential/issuance/08-confirm-credential.ts +0 -14
@@ -1,18 +1,22 @@
1
- import * as z from "zod";
2
- import uuid from "react-native-uuid";
3
- import { makeParRequest } from "../../utils/par";
4
- import { getJwtFromFormPost } from "../../utils/decoder";
5
- import { hasStatus } from "../../utils/misc";
1
+ import { generateRandomAlphaNumericString } from "../../../src/utils/misc";
2
+ import { makeParRequest } from "../../../src/utils/par";
6
3
  import { ASSERTION_TYPE } from "./const";
4
+ /**
5
+ * Ensures that the credential type requested is supported by the issuer and contained in the
6
+ * issuer configuration.
7
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
8
+ * @param credentialType The type of the credential to be requested returned by {@link startFlow}
9
+ * @param context.wiaCryptoContext The Wallet Instance's crypto context
10
+ * @param context.walletInstanceAttestation The Wallet Instance's attestation
11
+ * @param context.redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
12
+ * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
13
+ * @returns The credential definition to be used in the request which includes the format and the type and its type
14
+ */
7
15
  const selectCredentialDefinition = (issuerConf, credentialType) => {
8
- const {
9
- credentials_supported
10
- } = issuerConf.openid_credential_issuer;
11
- const [result] = credentials_supported.filter(e => e.credential_definition.type.includes(credentialType)).map(e => ({
12
- credential_definition: {
13
- type: credentialType
14
- },
15
- format: e.format,
16
+ const credential_configurations_supported = issuerConf.openid_credential_issuer.credential_configurations_supported;
17
+ const [result] = Object.keys(credential_configurations_supported).filter(e => e.includes(credentialType)).map(e => ({
18
+ credential_configuration_id: credentialType,
19
+ format: credential_configurations_supported[e].format,
16
20
  type: "openid_credential"
17
21
  }));
18
22
  if (!result) {
@@ -20,90 +24,62 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
20
24
  }
21
25
  return result;
22
26
  };
23
- const decodeAuthorizationResponse = async raw => {
24
- const {
25
- decodedJwt: {
26
- payload
27
- }
28
- } = await getJwtFromFormPost(raw);
29
27
 
30
- /**
31
- * FIXME: [SIW-628] This step must not make any difference on the credential
32
- * we are authorizing for, being a PID or any other (Q)EAA.
33
- *
34
- * Currently, PID issuer is implemented to skip the CompleteUserAuthorization step
35
- * thus returning a stubbed (code, state) pair.
36
- *
37
- * This is a workaround to proceeed the flow anyway.
38
- * If the response does not map what expected (CorrectShape),
39
- * we try parse into (code, state) to check if we are in the PID scenario.
40
- * In that case, a stub value is returned (will not be evaluated anyway).
41
- *
42
- * This workaround will be obsolete once the PID issuer fixes its implementation
43
- */
44
- const CorrectShape = z.object({
45
- request_uri: z.string()
46
- });
47
- const WrongShapeForPID = z.object({
48
- code: z.string(),
49
- state: z.string()
50
- });
51
- const [correct, wrong] = [CorrectShape.safeParse(payload), WrongShapeForPID.safeParse(payload)];
52
- if (correct.success) {
53
- return correct.data;
54
- } else if (wrong.success) {
55
- return {
56
- request_uri: "https://fake-request-uri"
57
- };
28
+ /**
29
+ * Ensures that the response mode requested is supported by the issuer and contained in the issuer configuration.
30
+ * @param issuerConf The issuer configuration
31
+ * @param credentialType The type of the credential to be requested
32
+ * @returns The response mode to be used in the request, "query" for PersonIdentificationData and "form_post.jwt" for all other types.
33
+ */
34
+ const selectResponseMode = (issuerConf, credentialType) => {
35
+ const responseModeSupported = issuerConf.oauth_authorization_server.response_modes_supported;
36
+ const responseMode = credentialType === "PersonIdentificationData" ? "query" : "form_post.jwt";
37
+ if (!responseModeSupported.includes(responseMode)) {
38
+ throw new Error(`No response mode support the type '${credentialType}'`);
58
39
  }
59
- throw correct.error;
40
+ return responseMode;
60
41
  };
42
+
61
43
  /**
62
- * Start the User authorization phase.
63
- * Perform the Pushed Authorization Request as defined in OAuth 2.0 protocol.
64
- *
65
- * @param issuerConf The Issuer configuration
66
- * @param credentialType The type of the credential to be requested
67
- * @param context.wiaCryptoContext The context to access the key associated with the Wallet Instance Attestation
68
- * @param context.walletInstanceAttestation The Wallet Instance Attestation token
69
- * @param context.walletProviderBaseUrl The base url of the Wallet Provider
70
- * @param context.additionalParams Hash set of parameters to be passed to the authorization endpoint
71
- * (used as a temporary fix until we have a proper User identity in the PID token provider)
72
- * TODO: [SIW-630]
73
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
74
- * @returns The request uri to continue the authorization to
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.
46
+ * This starts the authentication flow to obtain an access token.
47
+ * This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
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
49
+ * along with the WTE and its proof of possession (WTE-PoP).
50
+ * Additionally, it includes a request object, which is a signed JWT encapsulating the type of digital credential requested (authorization_details),
51
+ * the application session identifier on the Wallet Instance side (state),
52
+ * the method (query or form_post.jwt) by which the Authorization Server
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
55
+ * should be delivered. The redirect is achived by using a custom URL scheme that the Wallet Instance is registered to handle.
56
+ * @param issuerConf The issuer configuration
57
+ * @param credentialType The type of the credential to be requested returned by {@link selectCredentialDefinition}
58
+ * @param ctx The context object containing the Wallet Instance's cryptographic context, the Wallet Instance's attestation, the redirect URI and the fetch implementation
59
+ * @returns The URI to which the end user should be redirected to start the authentication flow, along with the client id, the code verifier and the credential definition
75
60
  */
76
61
  export const startUserAuthorization = async (issuerConf, credentialType, ctx) => {
77
62
  const {
78
63
  wiaCryptoContext,
79
64
  walletInstanceAttestation,
80
- walletProviderBaseUrl,
81
- additionalParams = {},
65
+ redirectUri,
82
66
  appFetch = fetch
83
67
  } = ctx;
84
68
  const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
85
- const codeVerifier = `${uuid.v4()}`;
86
- // Make a PAR request to the credential issuer and return the response url
87
- const parUrl = issuerConf.openid_credential_issuer.pushed_authorization_request_endpoint;
69
+ const codeVerifier = generateRandomAlphaNumericString(64);
70
+ const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
71
+ const credentialDefinition = selectCredentialDefinition(issuerConf, credentialType);
72
+ const responseMode = selectResponseMode(issuerConf, credentialType);
88
73
  const getPar = makeParRequest({
89
74
  wiaCryptoContext,
90
75
  appFetch
91
76
  });
92
- const issuerRequestUri = await getPar(clientId, codeVerifier, walletProviderBaseUrl, parUrl, walletInstanceAttestation, [selectCredentialDefinition(issuerConf, credentialType)], ASSERTION_TYPE);
93
-
94
- // Initialize authorization by requesting the authz request uri
95
- const authzRequestEndpoint = issuerConf.openid_credential_issuer.authorization_endpoint;
96
- const params = new URLSearchParams({
97
- client_id: clientId,
98
- request_uri: issuerRequestUri,
99
- ...additionalParams
100
- });
101
- const {
102
- request_uri
103
- } = await appFetch(`${authzRequestEndpoint}?${params}`).then(hasStatus(200)).then(res => res.text()).then(decodeAuthorizationResponse);
77
+ const issuerRequestUri = await getPar(clientId, codeVerifier, redirectUri, responseMode, parEndpoint, walletInstanceAttestation, [credentialDefinition], ASSERTION_TYPE);
104
78
  return {
105
- requestUri: request_uri,
106
- clientId
79
+ issuerRequestUri,
80
+ clientId,
81
+ codeVerifier,
82
+ credentialDefinition
107
83
  };
108
84
  };
109
85
  //# sourceMappingURL=03-start-user-authorization.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["z","uuid","makeParRequest","getJwtFromFormPost","hasStatus","ASSERTION_TYPE","selectCredentialDefinition","issuerConf","credentialType","credentials_supported","openid_credential_issuer","result","filter","e","credential_definition","type","includes","map","format","Error","decodeAuthorizationResponse","raw","decodedJwt","payload","CorrectShape","object","request_uri","string","WrongShapeForPID","code","state","correct","wrong","safeParse","success","data","error","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","walletProviderBaseUrl","additionalParams","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","v4","parUrl","pushed_authorization_request_endpoint","getPar","issuerRequestUri","authzRequestEndpoint","authorization_endpoint","params","URLSearchParams","client_id","res","text","requestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAA8BC,cAAc,QAAQ,iBAAiB;AAErE,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,SAAS,QAAkB,kBAAkB;AAGtD,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,0BAA0B,GAAGA,CACjCC,UAAkD,EAClDC,cAAgD,KACxB;E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,GAAEa,oBAAqB,IAAGE,MAAO,EAAC,CAAC,CACxEX,IAAI,CAAC3C,SAAS,CAAC,GAAG,CAAC,CAAC,CACpB2C,IAAI,CAAEc,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBf,IAAI,CAAC3B,2BAA2B,CAAC;EAEpC,OAAO;IAAE2C,UAAU,EAAErC,WAAW;IAAEmB;EAAS,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"names":["generateRandomAlphaNumericString","makeParRequest","ASSERTION_TYPE","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","issuerRequestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAEA,SACEA,gCAAgC,QAE3B,yBAAyB;AAIhC,SAA8BC,cAAc,QAAQ,wBAAwB;AAC5E,SAASC,cAAc,QAAQ,SAAS;AAkBxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGA,CACjCC,UAAkD,EAClDC,cAAgD,KACxB;EACxB,MAAMC,mCAAmC,GACvCF,UAAU,CAACG,wBAAwB,CAACD,mCAAmC;EAEzE,MAAM,CAACE,MAAM,CAAC,GAAGC,MAAM,CAACC,IAAI,CAACJ,mCAAmC,CAAC,CAC9DK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,QAAQ,CAACR,cAAc,CAAC,CAAC,CACzCS,GAAG,CAAEF,CAAC,KAAM;IACXG,2BAA2B,EAAEV,cAAc;IAC3CW,MAAM,EAAEV,mCAAmC,CAACM,CAAC,CAAC,CAAEI,M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MAAM,GAAGvC,cAAc,CAAC;IAAEyB,gBAAgB;IAAEG;EAAS,CAAC,CAAC;EAC7D,MAAMY,gBAAgB,GAAG,MAAMD,MAAM,CACnCT,QAAQ,EACRK,YAAY,EACZR,WAAW,EACXL,YAAY,EACZc,WAAW,EACXV,yBAAyB,EACzB,CAACY,oBAAoB,CAAC,EACtBrC,cACF,CAAC;EAED,OAAO;IAAEuC,gBAAgB;IAAEV,QAAQ;IAAEK,YAAY;IAAEG;EAAqB,CAAC;AAC3E,CAAC"}
@@ -1,2 +1,86 @@
1
- export {};
1
+ import { AuthorizationErrorShape, AuthorizationResultShape } from "../../../src/utils/auth";
2
+ import { until } from "../../utils/misc";
3
+ import parseUrl from "parse-url";
4
+ import { AuthorizationError, AuthorizationIdpError } from "../../utils/errors";
5
+ import { Linking } from "react-native";
6
+
7
+ /**
8
+ * 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.
9
+ */
10
+
11
+ /**
12
+ * WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link authorizeAccess}.
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
+ * It is used to complete the user authorization by catching the redirectSchema from the authorization server which then contains the authorization response.
15
+ * 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.
16
+ * 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
+ * @param issuerRequestUri the URI of the issuer where the request is sent
18
+ * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
19
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
20
+ * @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.
21
+ * If not specified, the default browser is used
22
+ * @param idphint Unique identifier of the SPID IDP selected by the user
23
+ * @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
24
+ * @throws {AuthorizationError} if an error occurs during the authorization process
25
+ * @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
26
+ * @returns the authorization response which contains code, state and iss
27
+ */
28
+ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext) => {
29
+ /**
30
+ * Starts the authorization flow which dependes on the response mode and the request credential.
31
+ * If the response mode is "query" the authorization flow is handled differently via the authorization context which opens an in-app browser capable of catching the redirectSchema.
32
+ * The form_post.jwt mode is not currently supported.
33
+ */
34
+ const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
35
+ const params = new URLSearchParams({
36
+ client_id: clientId,
37
+ request_uri: issuerRequestUri,
38
+ idphint: idpHint
39
+ });
40
+ const authUrl = `${authzRequestEndpoint}?${params}`;
41
+ var authRedirectUrl;
42
+ if (authorizationContext) {
43
+ const redirectSchema = new URL(redirectUri).protocol.replace(":", "");
44
+ authRedirectUrl = await authorizationContext.authorize(authUrl, redirectSchema).catch(e => {
45
+ throw new AuthorizationError(e.message);
46
+ });
47
+ } else {
48
+ // handler for redirectUri
49
+ Linking.addEventListener("url", _ref => {
50
+ let {
51
+ url
52
+ } = _ref;
53
+ if (url.includes(redirectUri)) {
54
+ authRedirectUrl = url;
55
+ }
56
+ });
57
+ const openAuthUrlInBrowser = Linking.openURL(authUrl);
58
+
59
+ /*
60
+ * Waits for 120 seconds for the identificationRedirectUrl variable to be set
61
+ * by the custom url handler. If the timeout is exceeded, throw an exception
62
+ */
63
+ const unitAuthRedirectIsNotUndefined = until(() => authRedirectUrl !== undefined, 120);
64
+ await Promise.all([openAuthUrlInBrowser, unitAuthRedirectIsNotUndefined]);
65
+ if (authRedirectUrl === undefined) {
66
+ throw new AuthorizationError("Invalid authentication redirect url");
67
+ }
68
+ }
69
+ const urlParse = parseUrl(authRedirectUrl);
70
+ const authRes = AuthorizationResultShape.safeParse(urlParse.query);
71
+ if (!authRes.success) {
72
+ const authErr = AuthorizationErrorShape.safeParse(urlParse.query);
73
+ if (!authErr.success) {
74
+ throw new AuthorizationError(authRes.error.message); // an error occured while parsing the result and the error
75
+ }
76
+
77
+ throw new AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
78
+ }
79
+ return authRes.data;
80
+ };
81
+
82
+ // TODO: SIW-1120 implement generic credential issuance flow
83
+ export const completeUserAuthorizationWithFormPostJwtMode = () => {
84
+ throw new Error("Not implemented");
85
+ };
2
86
  //# sourceMappingURL=04-complete-user-authorization.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":""}
1
+ {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","until","parseUrl","AuthorizationError","AuthorizationIdpError","Linking","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","addEventListener","_ref","url","includes","openAuthUrlInBrowser","openURL","unitAuthRedirectIsNotUndefined","undefined","Promise","all","urlParse","authRes","safeParse","query","success","authErr","error","data","error_description","completeUserAuthorizationWithFormPostJwtMode","Error"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAGnB,yBAAyB;AAChC,SAASC,KAAK,QAAkB,kBAAkB;AAElD,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,oBAAoB;AAE9E,SAASC,OAAO,QAAQ,cAAc;;AAEtC;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sCAA8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CAAC;IAEzE,IAAIf,eAAe,KAAKgB,SAAS,EAAE;MACjC,MAAM,IAAInC,kBAAkB,CAAC,qCAAqC,CAAC;IACrE;EACF;EAEA,MAAMsC,QAAQ,GAAGvC,QAAQ,CAACoB,eAAe,CAAC;EAC1C,MAAMoB,OAAO,GAAG1C,wBAAwB,CAAC2C,SAAS,CAACF,QAAQ,CAACG,KAAK,CAAC;EAClE,IAAI,CAACF,OAAO,CAACG,OAAO,EAAE;IACpB,MAAMC,OAAO,GAAG/C,uBAAuB,CAAC4C,SAAS,CAACF,QAAQ,CAACG,KAAK,CAAC;IACjE,IAAI,CAACE,OAAO,CAACD,OAAO,EAAE;MACpB,MAAM,IAAI1C,kBAAkB,CAACuC,OAAO,CAACK,KAAK,CAACjB,OAAO,CAAC,CAAC,CAAC;IACvD;;IACA,MAAM,IAAI1B,qBAAqB,CAC7B0C,OAAO,CAACE,IAAI,CAACD,KAAK,EAClBD,OAAO,CAACE,IAAI,CAACC,iBACf,CAAC;EACH;EACA,OAAOP,OAAO,CAACM,IAAI;AACrB,CAAC;;AAEH;AACA,OAAO,MAAME,4CAA4C,GAAGA,CAAA,KAAM;EAChE,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AACpC,CAAC"}
@@ -1,55 +1,76 @@
1
+ import { hasStatus } from "../../../src/utils/misc";
2
+ import { withEphemeralKey } from "../../../src/utils/crypto";
3
+ import { createDPopToken } from "../../../src/utils/dpop";
1
4
  import uuid from "react-native-uuid";
2
- import { withEphemeralKey } from "../../utils/crypto";
3
- import { createDPopToken } from "../../utils/dpop";
4
- import { hasStatus } from "../../utils/misc";
5
+ import { createPopToken } from "../../../src/utils/pop";
6
+ import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
5
7
  import { ASSERTION_TYPE } from "./const";
8
+ import { TokenResponse } from "./types";
9
+ import { ValidationFailed } from "../../../src/utils/errors";
6
10
  /**
7
- * Obtain the access token to finally request the credential
8
- *
9
- * @param issuerConf The Issuer configuration
10
- * @param code The access code from the User authorization phase
11
- * @param clientId Identifies the current client across all the requests of the issuing flow
12
- * @param context.walletInstanceAttestation The Wallet Instance Attestation token
13
- * @param context.walletProviderBaseUrl The base url of the Wallet Provider
11
+ * Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
12
+ * for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
13
+ * This enables the Wallet Instance to request a digital credential.
14
+ * The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
15
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
16
+ * @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
17
+ * @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
18
+ * @param clientId The client id returned by {@link startUserAuthorization}
19
+ * @param codeVerifier The code verifier returned by {@link startUserAuthorization}
20
+ * @param context.walletInstanceAttestation The Wallet Instance's attestation
21
+ * @param context.wiaCryptoContext The Wallet Instance's crypto context
14
22
  * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
15
- * @returns
23
+ * @throws {ValidationFailed} if an error occurs while parsing the token response
24
+ * @return The token response containing the access token along with the token request signed with DPoP which has to be used in the {@link obtainCredential} step.
16
25
  */
17
- export const authorizeAccess = async (issuerConf, code, clientId, context) => {
26
+ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVerifier, context) => {
18
27
  const {
19
28
  appFetch = fetch,
20
29
  walletInstanceAttestation,
21
- walletProviderBaseUrl
30
+ wiaCryptoContext
22
31
  } = context;
23
- const tokenUrl = issuerConf.openid_credential_issuer.token_endpoint;
24
-
32
+ const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
33
+ const parUrl = new URL(parEndpoint);
34
+ const aud = `${parUrl.protocol}//${parUrl.hostname}`;
35
+ const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
36
+ const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
25
37
  // Use an ephemeral key to be destroyed after use
26
- const signedDPop = await withEphemeralKey(ephemeralContext => createDPopToken({
27
- htm: "POST",
28
- htu: tokenUrl,
29
- jti: `${uuid.v4()}`
30
- }, ephemeralContext));
31
- const codeVerifier = `${uuid.v4()}`;
38
+ const tokenRequestSignedDPop = await withEphemeralKey(async ephimeralContext => {
39
+ return await createDPopToken({
40
+ htm: "POST",
41
+ htu: tokenUrl,
42
+ jti: `${uuid.v4()}`
43
+ }, ephimeralContext);
44
+ });
45
+ const signedWiaPoP = await createPopToken({
46
+ jti: `${uuid.v4()}`,
47
+ aud,
48
+ iss
49
+ }, wiaCryptoContext);
32
50
  const requestBody = {
33
- grant_type: "authorization code",
51
+ grant_type: "authorization_code",
34
52
  client_id: clientId,
35
53
  code,
54
+ redirect_uri: redirectUri,
36
55
  code_verifier: codeVerifier,
37
56
  client_assertion_type: ASSERTION_TYPE,
38
- client_assertion: walletInstanceAttestation,
39
- redirect_uri: walletProviderBaseUrl
57
+ client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
40
58
  };
41
- var formBody = new URLSearchParams(requestBody);
42
- return appFetch(tokenUrl, {
59
+ const authorizationRequestFormBody = new URLSearchParams(requestBody);
60
+ const tokenRes = await appFetch(tokenUrl, {
43
61
  method: "POST",
44
62
  headers: {
45
63
  "Content-Type": "application/x-www-form-urlencoded",
46
- DPoP: signedDPop
64
+ DPoP: tokenRequestSignedDPop
47
65
  },
48
- body: formBody.toString()
49
- }).then(hasStatus(200)).then(res => res.json()).then(body => ({
50
- accessToken: body.access_token,
51
- nonce: body.c_nonce,
52
- clientId
53
- }));
66
+ body: authorizationRequestFormBody.toString()
67
+ }).then(hasStatus(200)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
68
+ if (!tokenRes.success) {
69
+ throw new ValidationFailed(tokenRes.error.message);
70
+ }
71
+ return {
72
+ accessToken: tokenRes.data,
73
+ tokenRequestSignedDPop
74
+ };
54
75
  };
55
76
  //# sourceMappingURL=05-authorize-access.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["uuid","withEphemeralKey","createDPopToken","hasStatus","ASSERTION_TYPE","authorizeAccess","issuerConf","code","clientId","context","appFetch","fetch","walletInstanceAttestation","walletProviderBaseUrl","tokenUrl","openid_credential_issuer","token_endpoint","signedDPop","ephemeralContext","htm","htu","jti","v4","codeVerifier","requestBody","grant_type","client_id","code_verifier","client_assertion_type","client_assertion","redirect_uri","formBody","URLSearchParams","method","headers","DPoP","body","toString","then","res","json","accessToken","access_token","nonce","c_nonce"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,mBAAmB;AACpC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,kBAAkB;AAElD,SAASC,SAAS,QAAkB,kBAAkB;AAEtD,SAASC,cAAc,QAAQ,SAAS;AAqBxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAgC,GAAG,MAAAA,CAC9CC,UAAU,EACVC,IAAI,EACJC,QAAQ,EACRC,OAAO,KAC+D;EACtE,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC;EACF,CAAC,GAAGJ,OAAO;EAEX,MAAMK,QAAQ,GAAGR,UAAU,CAACS,wBAAwB,CAACC,cAAc;;EAEnE;EACA,MAAMC,UAAU,GAAG,MAAMhB,gBAAgB,CAAEiB,gBAAgB,IACzDhB,eAAe,CACb;IACEiB,GAAG,EAAE,MAAM;IACXC,GAAG,EAAEN,QAAQ;IACbO,GAAG,EAAG,GAAErB,IAAI,CAACsB,EAAE,CAAC,CAAE;EACpB,CAAC,EACDJ,gBACF,CACF,CAAC;EAED,MAAMK,YAAY,GAAI,GAAEvB,IAAI,CAACsB,EAAE,CAAC,CAAE,EAAC;EACnC,MAAME,WAAW,GAAG;IAClBC,UAAU,EAAE,oBAAoB;IAChCC,SAAS,EAAElB,QAAQ;IACnBD,IAAI;IACJoB,aAAa,EAAEJ,YAAY;IAC3BK,qBAAqB,EAAExB,cAAc;IACrCyB,gBAAgB,EAAEjB,yBAAyB;IAC3CkB,YAAY,EAAEjB;EAChB,CAAC;EACD,IAAIkB,QAAQ,GAAG,IAAIC,eAAe,CAACR,WAAW,CAAC;EAE/C,OAAOd,QAAQ,CAACI,QAAQ,EAAE;IACxBmB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAElB;IACR,CAAC;IACDmB,IAAI,EAAEL,QAAQ,CAACM,QAAQ,CAAC;EAC1B,CAAC,CAAC,CACCC,IAAI,CAACnC,SAAS,CAAC,GAAG,CAAC,CAAC,CACpBmC,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,KAAM;IACfK,WAAW,EAAEL,IAAI,CAACM,YAAY;IAC9BC,KAAK,EAAEP,IAAI,CAACQ,OAAO;IACnBpC;EACF,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"names":["hasStatus","withEphemeralKey","createDPopToken","uuid","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","ValidationFailed","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","ephimeralContext","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,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F,CAAC;EAED,MAAMK,YAAY,GAAG,MAAMtC,cAAc,CACvC;IACEoC,GAAG,EAAG,GAAErC,IAAI,CAACsC,EAAE,CAAC,CAAE,EAAC;IACnBhB,GAAG;IACHG;EACF,CAAC,EACDT,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,EAAE1C,cAAc;IACrC2C,gBAAgB,EAAE/B,yBAAyB,GAAG,GAAG,GAAGwB;EACtD,CAAC;EAED,MAAMQ,4BAA4B,GAAG,IAAIC,eAAe,CAACR,WAAW,CAAC;EACrE,MAAMS,QAAQ,GAAG,MAAMpC,QAAQ,CAACkB,QAAQ,EAAE;IACxCmB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAEnB;IACR,CAAC;IACDoB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC1D,SAAS,CAAC,GAAG,CAAC,CAAC,CACpB0D,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,IAAI;IAAE9B;EAAuB,CAAC;AAC/D,CAAC"}
@@ -1,100 +1,75 @@
1
- import * as z from "zod";
2
- import uuid from "react-native-uuid";
3
1
  import { SignJWT } from "@pagopa/io-react-native-jwt";
4
- import { createDPopToken } from "../../utils/dpop";
5
- import { hasStatus } from "../../utils/misc";
6
- import { SupportedCredentialFormat } from "./const";
7
-
8
- /**
9
- * Return the signed jwt for nonce proof of possession
10
- */
2
+ import { hasStatus } from "../../../src/utils/misc";
3
+ import { ValidationFailed } from "../../../src/utils/errors";
4
+ import { CredentialResponse } from "./types";
11
5
  export const createNonceProof = async (nonce, issuer, audience, ctx) => {
6
+ const jwk = await ctx.getPublicKey();
12
7
  return new SignJWT(ctx).setPayload({
13
- nonce,
14
- jwk: await ctx.getPublicKey()
8
+ nonce
15
9
  }).setProtectedHeader({
16
- type: "openid4vci-proof+jwt"
17
- }).setAudience(audience).setIssuer(issuer).setIssuedAt().setExpirationTime("1h").sign();
10
+ typ: "openid4vci-proof+jwt",
11
+ jwk
12
+ }).setAudience(audience).setIssuer(issuer).setIssuedAt().setExpirationTime("5min").sign();
18
13
  };
19
- const CredentialEndpointResponse = z.object({
20
- credential: z.string(),
21
- format: SupportedCredentialFormat,
22
- // nonce used to perform multiple credential requests
23
- // re-using the same authorization profile
24
- c_nonce: z.string(),
25
- c_nonce_expires_in: z.number()
26
- });
27
- // Checks whether in the Entity confoguration at least one credential
28
- // is defined for the given type and format
29
- const isCredentialAvailable = (issuerConf, credentialType, credentialFormat) => issuerConf.openid_credential_issuer.credentials_supported.some(c => c.format === credentialFormat && c.credential_definition.type.includes(credentialType));
30
14
 
31
15
  /**
32
- * Fetch a credential from the issuer
33
- *
34
- * @param issuerConf The Issuer configuration
35
- * @param accessToken The access token to grant access to the credential, obtained with the access authorization step
36
- * @param nonce The nonce value to prevent reply attacks, obtained with the access authorization step
37
- * @param clientId Identifies the current client across all the requests of the issuing flow
38
- * @param credentialType The type of the credential to be requested
39
- * @param credentialFormat The format of the requested credential. @see {SupportedCredentialFormat}
40
- * @param context.credentialCryptoContext The context to access the key the Credential will be bound to
41
- * @param context.walletProviderBaseUrl The base url of the Wallet Provider
16
+ * Obtains the credential from the issuer.
17
+ * The key pair of the credentialCryptoContext is used for Openid4vci proof JWT to be presented with the Access Token and the DPoP Proof JWT at the Credential Endpoint
18
+ * of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
19
+ * The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
20
+ * The credential request is sent to the Credential Endpoint of the Credential Issuer via HTTP POST with the type of the credential, its format, the access token and the JWT proof.
21
+ * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
22
+ * @param accessToken The access token response returned by {@link authorizeAccess}
23
+ * @param clientId The client id returned by {@link startUserAuthorization}
24
+ * @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
25
+ * @param tokenRequestSignedDPop The DPoP signed token request returned by {@link authorizeAccess}
26
+ * @param context.credentialCryptoContext The crypto context used to obtain the credential
42
27
  * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
43
- * @returns The signed credential token
28
+ * @returns The credential response containing the credential
44
29
  */
45
- export const obtainCredential = async (issuerConf, accessToken, nonce, clientId, credentialType, credentialFormat, context) => {
30
+ export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, tokenRequestSignedDPop, context) => {
46
31
  const {
47
32
  credentialCryptoContext,
48
- walletProviderBaseUrl,
49
33
  appFetch = fetch
50
34
  } = context;
51
- if (!isCredentialAvailable(issuerConf, credentialType, credentialFormat)) {
52
- throw new Error(`The Issuer provides no credential for type ${credentialType} and format ${credentialFormat}`);
53
- }
54
35
  const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
55
36
 
56
- /** DPoP token for demonstating the possession
57
- of the key that will bind the holder User with the Credential
58
- @see https://datatracker.ietf.org/doc/html/rfc9449 */
59
- const signedDPopForPid = await createDPopToken({
60
- htm: "POST",
61
- htu: credentialUrl,
62
- jti: `${uuid.v4()}`
63
- }, credentialCryptoContext);
37
+ /**
38
+ * JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
39
+ * This is presented along with the access token to the Credential Endpoint as proof of possession of the private key used to sign the Access Token.
40
+ * @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
41
+ */
42
+ const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
64
43
 
65
- /** JWT proof token to bind the request nonce
66
- to the key that will bind the holder User with the Credential
67
- @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types */
68
- const signedNonceProof = await createNonceProof(nonce, clientId, walletProviderBaseUrl, credentialCryptoContext);
44
+ // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
45
+ const constainsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
46
+ if (!constainsCredentialDefinition) {
47
+ throw new ValidationFailed("The access token response does not contain the requested credential");
48
+ }
69
49
 
70
50
  /** The credential request body */
71
- const formBody = new URLSearchParams({
72
- credential_definition: JSON.stringify({
73
- type: [credentialType]
74
- }),
75
- format: credentialFormat,
76
- proof: JSON.stringify({
51
+ const credentialRequestFormBody = {
52
+ credential_definition: {
53
+ type: [credentialDefinition.credential_configuration_id]
54
+ },
55
+ format: credentialDefinition.format,
56
+ proof: {
77
57
  jwt: signedNonceProof,
78
58
  proof_type: "jwt"
79
- })
80
- });
81
- const {
82
- credential,
83
- format,
84
- c_nonce
85
- } = await appFetch(credentialUrl, {
59
+ }
60
+ };
61
+ const credentialRes = await appFetch(credentialUrl, {
86
62
  method: "POST",
87
63
  headers: {
88
- "Content-Type": "application/x-www-form-urlencoded",
89
- DPoP: signedDPopForPid,
90
- Authorization: accessToken
64
+ "Content-Type": "application/json",
65
+ DPoP: tokenRequestSignedDPop,
66
+ Authorization: `${accessToken.token_type} ${accessToken.access_token}`
91
67
  },
92
- body: formBody.toString()
93
- }).then(hasStatus(200)).then(res => res.json()).then(CredentialEndpointResponse.parse);
94
- return {
95
- credential,
96
- format,
97
- nonce: c_nonce
98
- };
68
+ body: JSON.stringify(credentialRequestFormBody)
69
+ }).then(hasStatus(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body));
70
+ if (!credentialRes.success) {
71
+ throw new ValidationFailed(credentialRes.error.message);
72
+ }
73
+ return credentialRes.data;
99
74
  };
100
75
  //# sourceMappingURL=06-obtain-credential.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["z","uuid","SignJWT","createDPopToken","hasStatus","SupportedCredentialFormat","createNonceProof","nonce","issuer","audience","ctx","setPayload","jwk","getPublicKey","setProtectedHeader","type","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","CredentialEndpointResponse","object","credential","string","format","c_nonce","c_nonce_expires_in","number","isCredentialAvailable","issuerConf","credentialType","credentialFormat","openid_credential_issuer","credentials_supported","some","c","credential_definition","includes","obtainCredential","accessToken","clientId","context","credentialCryptoContext","walletProviderBaseUrl","appFetch","fetch","Error","credentialUrl","credential_endpoint","signedDPopForPid","htm","htu","jti","v4","signedNonceProof","formBody","URLSearchParams","JSON","stringify","proof","jwt","proof_type","method","headers","DPoP","Authorization","body","toString","then","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,OAAO,QAA4B,6BAA6B;AACzE,SAASC,eAAe,QAAQ,kBAAkB;AAGlD,SAASC,SAAS,QAAkB,kBAAkB;AAGtD,SAASC,yBAAyB,QAAQ,SAAS;;AAEnD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,OAAO,IAAIR,OAAO,CAACQ,GAAG,CAAC,CACpBC,UAAU,CAAC;IACVJ,KAAK;IACLK,GAAG,EAAE,MAAMF,GAAG,CAACG,YAAY,CAAC;EAC9B,CAAC,CAAC,CACDC,kBAAkB,CAAC;IAClBC,IAAI,EAAE;EACR,CAAC,CAAC,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se","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","tokenRequestSignedDPop","context","credentialCryptoContext","appFetch","fetch","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","credentialRes","method","headers","DPoP","Authorization","token_type","access_token","body","JSON","stringify","then","res","json","safeParse","success","error","message","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SAASA,OAAO,QAA4B,6BAA6B;AAGzE,SAASC,SAAS,QAAkB,yBAAyB;AAE7D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,kBAAkB,QAAQ,SAAS;AAc5C,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,IAAIV,OAAO,CAACQ,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,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,WAAW,EACXC,QAAQ,EACRC,oBAAoB,EACpBC,sBAAsB,EAC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