@pagopa/io-react-native-wallet 2.0.0-next.2 → 2.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/lib/commonjs/credential/issuance/03-start-user-authorization.js +38 -24
  2. package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +75 -57
  4. package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/05-authorize-access.js +6 -10
  6. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/06-obtain-credential.js +43 -11
  8. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +51 -48
  10. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/README.md +77 -45
  12. package/lib/commonjs/credential/issuance/const.js +1 -1
  13. package/lib/commonjs/credential/issuance/types.js +17 -10
  14. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  15. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +6 -13
  16. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  17. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +10 -11
  18. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  19. package/lib/commonjs/credential/presentation/types.js +1 -1
  20. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  21. package/lib/commonjs/credential/status/README.md +0 -1
  22. package/lib/commonjs/sd-jwt/__test__/index.test.js +11 -15
  23. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  24. package/lib/commonjs/sd-jwt/__test__/types.test.js +5 -2
  25. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  26. package/lib/commonjs/sd-jwt/__test__/utils.test.js +37 -0
  27. package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -0
  28. package/lib/commonjs/sd-jwt/index.js +26 -1
  29. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  30. package/lib/commonjs/sd-jwt/types.js +71 -8
  31. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  32. package/lib/commonjs/sd-jwt/utils.js +64 -0
  33. package/lib/commonjs/sd-jwt/utils.js.map +1 -0
  34. package/lib/commonjs/trust/types.js +18 -13
  35. package/lib/commonjs/trust/types.js.map +1 -1
  36. package/lib/commonjs/utils/par.js +32 -22
  37. package/lib/commonjs/utils/par.js.map +1 -1
  38. package/lib/commonjs/utils/pop.js +1 -1
  39. package/lib/commonjs/utils/pop.js.map +1 -1
  40. package/lib/commonjs/wallet-instance-attestation/types.js +4 -1
  41. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  42. package/lib/module/credential/issuance/03-start-user-authorization.js +38 -24
  43. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  44. package/lib/module/credential/issuance/04-complete-user-authorization.js +76 -58
  45. package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
  46. package/lib/module/credential/issuance/05-authorize-access.js +6 -10
  47. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  48. package/lib/module/credential/issuance/06-obtain-credential.js +44 -12
  49. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  50. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +51 -48
  51. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  52. package/lib/module/credential/issuance/README.md +77 -45
  53. package/lib/module/credential/issuance/const.js +1 -1
  54. package/lib/module/credential/issuance/types.js +13 -8
  55. package/lib/module/credential/issuance/types.js.map +1 -1
  56. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +6 -13
  57. package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
  58. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +10 -11
  59. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  60. package/lib/module/credential/presentation/types.js +1 -1
  61. package/lib/module/credential/presentation/types.js.map +1 -1
  62. package/lib/module/credential/status/README.md +0 -1
  63. package/lib/module/sd-jwt/__test__/index.test.js +11 -16
  64. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  65. package/lib/module/sd-jwt/__test__/types.test.js +5 -2
  66. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  67. package/lib/module/sd-jwt/__test__/utils.test.js +35 -0
  68. package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -0
  69. package/lib/module/sd-jwt/index.js +7 -1
  70. package/lib/module/sd-jwt/index.js.map +1 -1
  71. package/lib/module/sd-jwt/types.js +70 -7
  72. package/lib/module/sd-jwt/types.js.map +1 -1
  73. package/lib/module/sd-jwt/utils.js +57 -0
  74. package/lib/module/sd-jwt/utils.js.map +1 -0
  75. package/lib/module/trust/types.js +18 -13
  76. package/lib/module/trust/types.js.map +1 -1
  77. package/lib/module/utils/par.js +29 -20
  78. package/lib/module/utils/par.js.map +1 -1
  79. package/lib/module/utils/pop.js +1 -1
  80. package/lib/module/utils/pop.js.map +1 -1
  81. package/lib/module/wallet-instance-attestation/types.js +4 -1
  82. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  83. package/lib/typescript/client/generated/wallet-provider.d.ts +12 -12
  84. package/lib/typescript/credential/issuance/01-start-flow.d.ts +2 -2
  85. package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
  86. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +7 -6
  87. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  88. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +7 -14
  89. package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
  90. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  91. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +10 -5
  92. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  93. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -2
  94. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  95. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  96. package/lib/typescript/credential/issuance/types.d.ts +49 -26
  97. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  98. package/lib/typescript/credential/presentation/01-start-flow.d.ts +2 -2
  99. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +4 -3
  100. package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
  101. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +9 -5
  102. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  103. package/lib/typescript/credential/presentation/types.d.ts +3 -4
  104. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  105. package/lib/typescript/credential/status/types.d.ts +4 -4
  106. package/lib/typescript/pid/sd-jwt/types.d.ts +7 -7
  107. package/lib/typescript/sd-jwt/__test__/utils.test.d.ts +2 -0
  108. package/lib/typescript/sd-jwt/__test__/utils.test.d.ts.map +1 -0
  109. package/lib/typescript/sd-jwt/index.d.ts +69 -28
  110. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  111. package/lib/typescript/sd-jwt/types.d.ts +264 -31
  112. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  113. package/lib/typescript/sd-jwt/utils.d.ts +18 -0
  114. package/lib/typescript/sd-jwt/utils.d.ts.map +1 -0
  115. package/lib/typescript/trust/build-chain.d.ts +30 -14
  116. package/lib/typescript/trust/build-chain.d.ts.map +1 -1
  117. package/lib/typescript/trust/types.d.ts +322 -158
  118. package/lib/typescript/trust/types.d.ts.map +1 -1
  119. package/lib/typescript/utils/par.d.ts +29 -13
  120. package/lib/typescript/utils/par.d.ts.map +1 -1
  121. package/lib/typescript/wallet-instance-attestation/types.d.ts +9 -9
  122. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  123. package/package.json +1 -1
  124. package/src/credential/issuance/01-start-flow.ts +2 -2
  125. package/src/credential/issuance/03-start-user-authorization.ts +57 -38
  126. package/src/credential/issuance/04-complete-user-authorization.ts +79 -85
  127. package/src/credential/issuance/05-authorize-access.ts +5 -11
  128. package/src/credential/issuance/06-obtain-credential.ts +56 -23
  129. package/src/credential/issuance/07-verify-and-parse-credential.ts +54 -62
  130. package/src/credential/issuance/README.md +77 -45
  131. package/src/credential/issuance/const.ts +1 -1
  132. package/src/credential/issuance/types.ts +19 -8
  133. package/src/credential/presentation/07-evaluate-dcql-query.ts +16 -17
  134. package/src/credential/presentation/07-evaluate-input-descriptor.ts +19 -16
  135. package/src/credential/presentation/types.ts +1 -2
  136. package/src/credential/status/README.md +0 -1
  137. package/src/sd-jwt/__test__/index.test.ts +8 -29
  138. package/src/sd-jwt/__test__/types.test.ts +6 -2
  139. package/src/sd-jwt/__test__/utils.test.ts +37 -0
  140. package/src/sd-jwt/index.ts +7 -1
  141. package/src/sd-jwt/types.ts +68 -7
  142. package/src/sd-jwt/utils.ts +73 -0
  143. package/src/trust/types.ts +23 -17
  144. package/src/utils/par.ts +37 -21
  145. package/src/utils/pop.ts +1 -1
  146. package/src/wallet-instance-attestation/types.ts +3 -1
@@ -2,13 +2,13 @@ import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/a
2
2
  import { hasStatusOrThrow } from "../../utils/misc";
3
3
  import parseUrl from "parse-url";
4
4
  import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
5
- import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
5
+ import { decode, SignJWT } from "@pagopa/io-react-native-jwt";
6
6
  import { RequestObject } from "../presentation/types";
7
- import { v4 as uuidv4 } from "uuid";
8
7
  import { ResponseUriResultShape } from "./types";
9
8
  import { getJwtFromFormPost } from "../../utils/decoder";
10
9
  import { AuthorizationError, AuthorizationIdpError } from "./errors";
11
10
  import { LogLevel, Logger } from "../../utils/logging";
11
+ import { Presentation } from "..";
12
12
 
13
13
  /**
14
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.
@@ -86,70 +86,46 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
86
86
  };
87
87
 
88
88
  /**
89
- * WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link completeUserAuthorizationWithFormPostJwtMode}.
89
+ * WARNING: This function must be called after {@link getRequestedCredentialToBePresented}. The next function to be called is {@link authorizeAccess}.
90
90
  * The interface of the phase to complete User authorization via presentation of existing credentials when the response mode is "form_post.jwt".
91
- * It is used as a first step to complete the user authorization by obtaining the requested credential to be presented from the authorization server.
92
- * The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
93
- * @param issuerRequestUri the URI of the issuer where the request is sent
94
- * @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
95
- * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
96
- * @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
97
- * @param context.pid the PID to be presented
98
- * @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
99
- * @param context.pidCryptoContext The PID crypto context associated with the pid parameter
100
- * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
91
+ * The information is obtained by performing a POST request to the endpoint received in the response_uri field of the requestObject, where the Authorization Response payload is posted.
92
+ * Following this,the redirect_uri from the response is used to obtain the final authorization response.
93
+ * @param requestObject - The request object containing the necessary parameters for authorization.
94
+ * @param pid The `PID` that must be presented for the issuance of credentials.
95
+ * @param appFetch (optional) fetch api implementation. Default: built-in fetch
101
96
  * @throws {ValidationFailed} if an error while validating the response
102
97
  * @returns the authorization response which contains code, state and iss
103
98
  */
104
- export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
105
- Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
106
- const {
99
+ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, pid, _ref) => {
100
+ let {
107
101
  wiaCryptoContext,
108
102
  pidCryptoContext,
109
- pid,
110
- walletInstanceAttestation,
111
103
  appFetch = fetch
112
- } = ctx;
113
- const wiaWpToken = await new SignJWT(wiaCryptoContext).setProtectedHeader({
114
- alg: "ES256",
115
- typ: "JWT"
116
- }).setPayload({
117
- vp: walletInstanceAttestation,
118
- jti: uuidv4().toString(),
119
- nonce: requestObject.nonce
120
- }).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
121
- const pidWpToken = await new SignJWT(pidCryptoContext).setProtectedHeader({
122
- alg: "ES256",
123
- typ: "JWT"
124
- }).setPayload({
125
- vp: pid,
126
- jti: uuidv4().toString(),
127
- nonce: requestObject.nonce
128
- }).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
129
- Logger.log(LogLevel.DEBUG, `Wallet instance attestation JWT token: ${wiaWpToken}`);
130
-
131
- /* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
132
- * is cointaned in the `vp` property of the signed jwt token payload
133
- */
134
- const presentationSubmission = {
135
- definition_id: `${uuidv4()}`,
136
- id: `${uuidv4()}`,
137
- descriptor_map: [{
138
- id: "PersonIdentificationData",
139
- path: "$.vp_token[0].vp",
140
- format: "vc+sd-jwt"
141
- }, {
142
- id: "WalletAttestation",
143
- path: "$.vp_token[1].vp",
144
- format: "jwt"
145
- }]
146
- };
147
- Logger.log(LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
148
- const authzResponsePayload = encodeBase64(JSON.stringify({
104
+ } = _ref;
105
+ Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
106
+ if (!requestObject.dcql_query) {
107
+ throw new Error("Invalid request object");
108
+ }
109
+ const dcqlQueryResult = Presentation.evaluateDcqlQuery([[pidCryptoContext, pid]], requestObject.dcql_query);
110
+ const credentialsToPresent = dcqlQueryResult.map(_ref2 => {
111
+ let {
112
+ requiredDisclosures,
113
+ ...rest
114
+ } = _ref2;
115
+ return {
116
+ ...rest,
117
+ requestedClaims: requiredDisclosures.map(_ref3 => {
118
+ let [, claimName] = _ref3;
119
+ return claimName;
120
+ })
121
+ };
122
+ });
123
+ const remotePresentations = await Presentation.prepareRemotePresentations(credentialsToPresent, requestObject.nonce, requestObject.client_id);
124
+ const authzResponsePayload = await createAuthzResponsePayload({
149
125
  state: requestObject.state,
150
- presentation_submission: presentationSubmission,
151
- vp_token: [pidWpToken, wiaWpToken]
152
- }));
126
+ remotePresentations,
127
+ wiaCryptoContext
128
+ });
153
129
  Logger.log(LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
154
130
 
155
131
  // Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
@@ -203,4 +179,46 @@ export const parseAuthorizationResponse = authRes => {
203
179
  }
204
180
  return authResParsed.data;
205
181
  };
182
+
183
+ /**
184
+ * Creates the authorization response payload to be sent.
185
+ * This payload includes the state and the VP tokens for the presented credentials.
186
+ * The payload is encoded in Base64.
187
+ * @param state - The state parameter from the request object (optional).
188
+ * @param remotePresentations - An array of remote presentations containing credential IDs and their corresponding VP tokens.
189
+ * @returns The Base64 encoded authorization response payload.
190
+ */
191
+ const createAuthzResponsePayload = async _ref4 => {
192
+ let {
193
+ state,
194
+ remotePresentations,
195
+ wiaCryptoContext
196
+ } = _ref4;
197
+ const {
198
+ kid
199
+ } = await wiaCryptoContext.getPublicKey();
200
+ return new SignJWT(wiaCryptoContext).setProtectedHeader({
201
+ typ: "jwt",
202
+ kid
203
+ }).setPayload({
204
+ /**
205
+ * TODO [SIW-2264]: `state` coming from `requestObject` is marked as `optional`
206
+ * At the moment, it is not entirely clear whether this value can indeed be omitted
207
+ * and, if so, what the consequences of its absence might be.
208
+ */
209
+ ...(state ? {
210
+ state
211
+ } : {}),
212
+ vp_token: remotePresentations.reduce((vp_token, _ref5) => {
213
+ let {
214
+ credentialId,
215
+ vpToken
216
+ } = _ref5;
217
+ return {
218
+ ...vp_token,
219
+ [credentialId]: vpToken
220
+ };
221
+ }, {})
222
+ }).setIssuedAt().setExpirationTime("1h").sign();
223
+ };
206
224
  //# sourceMappingURL=04-complete-user-authorization.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","log","DEBUG","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","res","text","jws","reqObj","safeParse","payload","success","ERROR","error","message","reason","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","JSON","stringify","authzResponsePayload","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,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBA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O,EAAE;MACpBrC,MAAM,CAACiB,GAAG,CACRlB,QAAQ,CAACuC,KAAK,EACb,mDAAkDgD,aAAa,CAAC/C,KAAK,CAACC,OAAQ,EACjF,CAAC;MACD,MAAM,IAAI3C,kBAAkB,CAACyF,aAAa,CAAC/C,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACAxC,MAAM,CAACiB,GAAG,CACRlB,QAAQ,CAACuC,KAAK,EACb,2CAA0C+B,IAAI,CAACC,SAAS,CAACiB,OAAO,CAAE,EACrE,CAAC;IACD,MAAM,IAAIzF,qBAAqB,CAC7ByF,OAAO,CAAC7C,IAAI,CAACH,KAAK,EAClBgD,OAAO,CAAC7C,IAAI,CAAC8C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC5C,IAAI;AAC3B,CAAC"}
1
+ {"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","SignJWT","RequestObject","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","Presentation","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","log","DEBUG","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","res","text","jws","reqObj","safeParse","payload","success","ERROR","error","message","reason","data","completeUserAuthorizationWithFormPostJwtMode","pid","_ref","wiaCryptoContext","pidCryptoContext","dcql_query","Error","dcqlQueryResult","evaluateDcqlQuery","credentialsToPresent","map","_ref2","requiredDisclosures","rest","requestedClaims","_ref3","claimName","remotePresentations","prepareRemotePresentations","nonce","authzResponsePayload","createAuthzResponsePayload","state","body","response","resUriRes","response_uri","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","JSON","stringify","error_description","_ref4","kid","getPublicKey","setProtectedHeader","typ","setPayload","vp_token","reduce","_ref5","credentialId","vpToken","setIssuedAt","setExpirationTime","sign"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,OAAO,QAEF,6BAA6B;AACpC,SAAkCC,aAAa,QAAQ,uBAAuB;AAC9E,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;AACpE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AACtD,SAASC,YAAY,QAAQ,IAAI;;AAGjC;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAA4C,GAAG,MAAAA,CAC1DC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,KACJ;EACH,MAAMC,oBAAoB,GACxBF,UAAU,CAACG,0BAA0B,CAACC,sBAAsB;EAE9D,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC;IACjCC,SAAS,EAAER,QAAQ;IACnBS,WAAW,EAAEV;EACf,CAAC,CAAC;EAEF,IAAIG,OAAO,EAAE;IACXI,MAAM,CAACI,MAAM,CAAC,SAAS,EAAER,OAAO,CAAC;EACnC;EAEA,MAAMS,OAAO,GAAI,GAAER,oBAAqB,IAAGG,MAAO,EAAC;EAEnD,OAAO;IAAEK;EAAQ,CAAC;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sCAA8E,GACzF,MAAOC,eAAe,IAAK;EACzB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mBAAmB;IACnBd;EAKF,CAAC,GAAAqC,KAAA;EACC,MAAM;IAAEC;EAAI,CAAC,GAAG,MAAMtC,gBAAgB,CAACuC,YAAY,CAAC,CAAC;EAErD,OAAO,IAAI7F,OAAO,CAACsD,gBAAgB,CAAC,CACjCwC,kBAAkB,CAAC;IAClBC,GAAG,EAAE,KAAK;IACVH;EACF,CAAC,CAAC,CACDI,UAAU,CAAC;IACV;AACN;AACA;AACA;AACA;IACM,IAAIvB,KAAK,GAAG;MAAEA;IAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3BwB,QAAQ,EAAE7B,mBAAmB,CAAC8B,MAAM,CAClC,CAACD,QAAQ,EAAAE,KAAA;MAAA,IAAE;QAAEC,YAAY;QAAEC;MAAQ,CAAC,GAAAF,KAAA;MAAA,OAAM;QACxC,GAAGF,QAAQ;QACX,CAACG,YAAY,GAAGC;MAClB,CAAC;IAAA,CAAC,EACF,CAAC,CACH;EACF,CAAC,CAAC,CACDC,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,IAAI,CAAC,CACvBC,IAAI,CAAC,CAAC;AACX,CAAC"}
@@ -3,7 +3,6 @@ import { createDPopToken } from "../../utils/dpop";
3
3
  import { v4 as uuidv4 } from "uuid";
4
4
  import { createPopToken } from "../../utils/pop";
5
5
  import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
6
- import { ASSERTION_TYPE } from "./const";
7
6
  import { TokenResponse } from "./types";
8
7
  import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
9
8
  import { LogLevel, Logger } from "../../utils/logging";
@@ -25,16 +24,14 @@ import { LogLevel, Logger } from "../../utils/logging";
25
24
  * @throws {IssuerResponseError} with a specific code for more context
26
25
  * @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.
27
26
  */
28
- export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVerifier, context) => {
27
+ export const authorizeAccess = async (issuerConf, code, _, redirectUri, codeVerifier, context) => {
29
28
  const {
30
29
  appFetch = fetch,
31
30
  walletInstanceAttestation,
32
31
  wiaCryptoContext,
33
32
  dPopCryptoContext
34
33
  } = context;
35
- const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
36
- const parUrl = new URL(parEndpoint);
37
- const aud = `${parUrl.protocol}//${parUrl.hostname}`;
34
+ const aud = issuerConf.openid_credential_issuer.credential_issuer;
38
35
  const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
39
36
  const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
40
37
  const tokenRequestSignedDPop = await createDPopToken({
@@ -51,12 +48,9 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
51
48
  Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
52
49
  const requestBody = {
53
50
  grant_type: "authorization_code",
54
- client_id: clientId,
55
51
  code,
56
- redirect_uri: redirectUri,
57
52
  code_verifier: codeVerifier,
58
- client_assertion_type: ASSERTION_TYPE,
59
- client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
53
+ redirect_uri: redirectUri
60
54
  };
61
55
  const authorizationRequestFormBody = new URLSearchParams(requestBody);
62
56
  Logger.log(LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
@@ -64,7 +58,9 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
64
58
  method: "POST",
65
59
  headers: {
66
60
  "Content-Type": "application/x-www-form-urlencoded",
67
- DPoP: tokenRequestSignedDPop
61
+ DPoP: tokenRequestSignedDPop,
62
+ "OAuth-Client-Attestation": walletInstanceAttestation,
63
+ "OAuth-Client-Attestation-PoP": signedWiaPoP
68
64
  },
69
65
  body: authorizationRequestFormBody.toString()
70
66
  }).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
@@ -1 +1 @@
1
- {"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","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","log","DEBUG","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","error","message","reason","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,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;AAE1E,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAgBtD;AACA;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,MAA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AAMrC,QAAQ,CAACmB,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,CAAC9D,gBAAgB,CAAC,GAAG,EAAEQ,mBAAmB,CAAC,CAAC,CAChDsD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,IAAKrD,aAAa,CAAC0D,SAAS,CAACL,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrBvD,MAAM,CAACiC,GAAG,CACRlC,QAAQ,CAACyD,KAAK,EACb,qCAAoCX,QAAQ,CAACY,KAAK,CAACC,OAAQ,EAC9D,CAAC;IAED,MAAM,IAAI5D,gBAAgB,CAAC;MACzB4D,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAEd,QAAQ,CAACY,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEE,WAAW,EAAEf,QAAQ,CAACgB;EAAK,CAAC;AACvC,CAAC"}
1
+ {"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","authorizeAccess","issuerConf","code","_","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","aud","openid_credential_issuer","credential_issuer","iss","decode","payload","cnf","jwk","kid","tokenUrl","oauth_authorization_server","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","log","DEBUG","signedWiaPoP","requestBody","grant_type","code_verifier","redirect_uri","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","ERROR","error","message","reason","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAgBtD;AACA;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,CAAC,EACDC,WAAW,EACXC,YAAY,EACZC,OAAO,KACJ;EACH,MAAM;IACJC,QAAQ,GAAGC,KAAK;IAChBC,yBAAyB;IACzBC,gBAAgB;IAChBC;EACF,CAAC,GAAGL,OAAO;EACX,MAAMM,GAAG,GAAGX,UAAU,CAACY,wBAAwB,CAACC,iBAAiB;EACjE,MAAMC,GAAG,GAAGrB,yBAAyB,CAACsB,MAAM,CAACP,yBAAyB,CAAC,CACpEQ,OAAO,CAACC,GAAG,CAACC,GAAG,CAACC,GAAG;EAEtB,MAAMC,QAAQ,GAAGpB,UAAU,CAACqB,0BAA0B,CAACC,cAAc;EAErE,MAAMC,sBAAsB,GAAG,MAAMlC,eAAe,CAClD;IACEmC,GAAG,EAAE,MAAM;IACXC,GAAG,EAAEL,QAAQ;IACbM,GAAG,EAAG,GAAEnC,MAAM,CAAC,CAAE;EACnB,CAAC,EACDmB,iBACF,CAAC;EAEDZ,MAAM,CAAC6B,GAAG,CAAC9B,QAAQ,CAAC+B,KAAK,EAAG,uBAAsBL,sBAAuB,EAAC,CAAC;EAE3E,MAAMM,YAAY,GAAG,MA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C3CC,MAAM,EAAEd,QAAQ,CAACY,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEE,WAAW,EAAEf,QAAQ,CAACgB;EAAK,CAAC;AACvC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { sha256ToBase64, SignJWT } from "@pagopa/io-react-native-jwt";
2
2
  import { hasStatusOrThrow } from "../../utils/misc";
3
3
  import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
4
- import { CredentialResponse } from "./types";
4
+ import { CredentialResponse, NonceResponse } from "./types";
5
5
  import { createDPopToken } from "../../utils/dpop";
6
6
  import { v4 as uuidv4 } from "uuid";
7
7
  import { LogLevel, Logger } from "../../utils/logging";
@@ -24,11 +24,11 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
24
24
  * @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
25
25
  * @param accessToken The access token response returned by {@link authorizeAccess}
26
26
  * @param clientId The client id returned by {@link startUserAuthorization}
27
- * @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
28
- * @param tokenRequestSignedDPop The DPoP signed token request returned by {@link authorizeAccess}
27
+ * @param credentialDefinition The credential definition of the credential to be obtained returned by {@link authorizeAccess}
29
28
  * @param context.credentialCryptoContext The crypto context used to obtain the credential
30
29
  * @param context.dPopCryptoContext The DPoP crypto context
31
30
  * @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
31
+ * @param operationType Specify the type of credential issuance (used for reissuing)
32
32
  * @returns The credential response containing the credential
33
33
  */
34
34
  export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
@@ -37,18 +37,34 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
37
37
  appFetch = fetch,
38
38
  dPopCryptoContext
39
39
  } = context;
40
+ const {
41
+ credential_configuration_id,
42
+ credential_identifier
43
+ } = credentialDefinition;
40
44
  const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
45
+ const issuerUrl = issuerConf.oauth_authorization_server.issuer;
46
+ const nonceUrl = issuerConf.openid_credential_issuer.nonce_endpoint;
47
+
48
+ // Fetch the nonce from the Credential Issuer
49
+ const {
50
+ c_nonce
51
+ } = await appFetch(nonceUrl, {
52
+ method: "POST",
53
+ headers: {
54
+ "Content-Type": "application/json"
55
+ }
56
+ }).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => NonceResponse.parse(body));
41
57
 
42
58
  /**
43
59
  * JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
44
60
  * 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.
45
61
  * @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
46
62
  */
47
- const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
63
+ const signedNonceProof = await createNonceProof(c_nonce, clientId, issuerUrl, credentialCryptoContext);
48
64
  Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
49
65
 
50
66
  // Validation of accessTokenResponse.authorization_details if contain credentialDefinition
51
- const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
67
+ const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credential_configuration_id && (credential_identifier ? c.credential_identifiers.includes(credential_identifier) : true));
52
68
  if (!containsCredentialDefinition) {
53
69
  Logger.log(LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
54
70
  throw new ValidationFailed({
@@ -56,12 +72,20 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
56
72
  });
57
73
  }
58
74
 
59
- /** The credential request body */
60
- const credentialRequestFormBody = {
61
- credential_definition: {
62
- type: [credentialDefinition.credential_configuration_id]
63
- },
64
- format: credentialDefinition.format,
75
+ /**
76
+ * The credential request body.
77
+ * We accept both `credential_identifier` (recommended) and `credential_configuration_id`
78
+ * when the Authorization Server does not support `credential_identifier`.
79
+ * @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#section-3.3.4
80
+ */
81
+ const credentialRequestFormBody = credential_identifier ? {
82
+ credential_identifier: credential_identifier,
83
+ proof: {
84
+ jwt: signedNonceProof,
85
+ proof_type: "jwt"
86
+ }
87
+ } : {
88
+ credential_configuration_id: credential_configuration_id,
65
89
  proof: {
66
90
  jwt: signedNonceProof,
67
91
  proof_type: "jwt"
@@ -95,7 +119,15 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
95
119
  });
96
120
  }
97
121
  Logger.log(LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
98
- return credentialRes.data;
122
+
123
+ // Extract the format corresponding to the credential_configuration_id used
124
+ const issuerCredentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credential_configuration_id];
125
+
126
+ // TODO: [SIW-2264] Handle multiple credentials
127
+ return {
128
+ credential: credentialRes.data.credentials.at(0).credential,
129
+ format: issuerCredentialConfig.format
130
+ };
99
131
  };
100
132
 
101
133
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","res","json","safeParse","catch","handleObtainCredentialError","success","error","reason","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,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAetD,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,IAAInB,OAAO,CAACiB,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,EACPC,aAAa,KACV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C,CAAC;EACJ;EAEA1C,MAAM,CAACgC,GAAG,CACRjC,QAAQ,CAACkC,KAAK,EACb,wBAAuBe,IAAI,CAACC,SAAS,CAACO,aAAa,CAACgB,IAAI,CAAE,EAC7D,CAAC;EAED,OAAOhB,aAAa,CAACgB,IAAI;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMJ,2BAA2B,GAAIK,CAAU,IAAK;EAClDzE,MAAM,CAACgC,GAAG,CAACjC,QAAQ,CAAC0C,KAAK,EAAG,8CAA6CgC,CAAE,EAAC,CAAC;EAE7E,IAAI,EAAEA,CAAC,YAAYhF,yBAAyB,CAAC,EAAE;IAC7C,MAAMgF,CAAC;EACT;EAEA,MAAM,IAAIjF,oBAAoB,CAACF,mBAAmB,CAAC,CAChDoF,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEpF,wBAAwB,CAACqF,+BAA+B;IAC9DlC,OAAO,EACL;EACJ,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACsF,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACsF,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACuF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDqC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
1
+ {"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","NonceResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credential_configuration_id","credential_identifier","credentialUrl","openid_credential_issuer","credential_endpoint","issuerUrl","oauth_authorization_server","nonceUrl","nonce_endpoint","c_nonce","method","headers","then","res","json","body","parse","signedNonceProof","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_identifiers","includes","ERROR","message","credentialRequestFormBody","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","DPoP","Authorization","token_type","safeParse","catch","handleObtainCredentialError","success","error","reason","data","issuerCredentialConfig","credential_configurations_supported","credential","credentials","at","format","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,EAAEC,aAAa,QAAQ,SAAS;AAC3D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAqBtD,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,IAAIpB,OAAO,CAACkB,GAAG,CAAC,CACpBG,UAAU,CAAC;IACVN;EACF,CAAC,CAAC,CACDO,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC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EH;EACA,OAAO;IACLqD,UAAU,EAAEb,aAAa,CAACU,IAAI,CAACI,WAAW,CAACC,EAAE,CAAC,CAAC,CAAC,CAAEF,UAAU;IAC5DG,MAAM,EAAEL,sBAAsB,CAAEK;EAClC,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMV,2BAA2B,GAAIW,CAAU,IAAK;EAClDpF,MAAM,CAAC6C,GAAG,CAAC9C,QAAQ,CAACsD,KAAK,EAAG,8CAA6C+B,CAAE,EAAC,CAAC;EAE7E,IAAI,EAAEA,CAAC,YAAY5F,yBAAyB,CAAC,EAAE;IAC7C,MAAM4F,CAAC;EACT;EAEA,MAAM,IAAI7F,oBAAoB,CAACF,mBAAmB,CAAC,CAChDgG,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEhG,wBAAwB,CAACiG,+BAA+B;IAC9DjC,OAAO,EACL;EACJ,CAAC,CAAC,CACD+B,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEhG,wBAAwB,CAACkG,uBAAuB;IACtDlC,OAAO,EAAE;EACX,CAAC,CAAC,CACD+B,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEhG,wBAAwB,CAACkG,uBAAuB;IACtDlC,OAAO,EAAE;EACX,CAAC,CAAC,CACD+B,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEhG,wBAAwB,CAACmG,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDoC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
@@ -8,45 +8,39 @@ import { LogLevel, Logger } from "../../utils/logging";
8
8
 
9
9
  // handy alias
10
10
 
11
- const parseCredentialSdJwt = function (credentials_supported, _ref) {
11
+ const parseCredentialSdJwt = function (credentialConfig, _ref) {
12
12
  let {
13
13
  sdJwt,
14
14
  disclosures
15
15
  } = _ref;
16
16
  let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
17
17
  let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
18
- const credentialSubject = credentials_supported[sdJwt.payload.vct];
19
- if (!credentialSubject) {
20
- Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
21
- throw new IoWalletError("Credential type not supported by the issuer");
22
- }
23
- if (credentialSubject.format !== sdJwt.header.typ) {
24
- Logger.log(LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
25
- throw new IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
18
+ if (credentialConfig.format !== sdJwt.header.typ) {
19
+ const message = `Received credential is of an unknwown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
20
+ Logger.log(LogLevel.ERROR, message);
21
+ throw new IoWalletError(message);
26
22
  }
27
-
28
- // transfrom a record { key: value } in an iterable of pairs [key, value]
29
- if (!credentialSubject.claims) {
23
+ if (!credentialConfig.claims) {
30
24
  Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
31
25
  throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
32
26
  }
33
27
 
34
- const attrDefinitions = Object.entries(credentialSubject.claims);
28
+ const attrDefinitions = credentialConfig.claims;
35
29
 
36
30
  // the key of the attribute defintion must match the disclosure's name
37
- const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
38
- let [attrKey] = _ref2;
39
- return !disclosures.some(_ref3 => {
40
- let [, name] = _ref3;
41
- return name === attrKey;
42
- });
43
- });
31
+ const attrsNotInDisclosures = attrDefinitions.filter(definition => !disclosures.some(_ref2 => {
32
+ let [, name] = _ref2;
33
+ return name === definition.path[0];
34
+ }) // Ignore nested paths for now, see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#name-claims-path-pointer
35
+ );
36
+
44
37
  if (attrsNotInDisclosures.length > 0) {
45
- const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
38
+ const missing = attrsNotInDisclosures.map(_ => _.path[0]).join(", ");
46
39
  const received = disclosures.map(_ => _[1 /* name */]).join(", ");
47
40
  if (!ignoreMissingAttributes) {
48
- Logger.log(LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
49
- throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
41
+ const message = `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`;
42
+ Logger.log(LogLevel.ERROR, message);
43
+ throw new IoWalletError(message);
50
44
  }
51
45
  }
52
46
 
@@ -54,28 +48,31 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
54
48
  // and are present in the disclosure set
55
49
  const definedValues = Object.fromEntries(attrDefinitions
56
50
  // retrieve the value from the disclosure set
57
- .map(_ref4 => {
51
+ .map(_ref3 => {
58
52
  var _disclosures$find;
59
- let [attrKey, definition] = _ref4;
60
- return [attrKey, {
53
+ let {
54
+ path,
55
+ ...definition
56
+ } = _ref3;
57
+ return [path[0], {
61
58
  ...definition,
62
- value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === attrKey)) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
59
+ value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === path[0])) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
63
60
  }];
64
61
  })
65
62
  // add a human readable attribute name, with i18n, in the form { locale: name }
66
63
  // example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
67
- .map(_ref5 => {
64
+ .map(_ref4 => {
68
65
  let [attrKey, {
69
66
  display,
70
67
  ...definition
71
- }] = _ref5;
68
+ }] = _ref4;
72
69
  return [attrKey, {
73
70
  ...definition,
74
- name: display.reduce((names, _ref6) => {
71
+ name: display.reduce((names, _ref5) => {
75
72
  let {
76
73
  locale,
77
74
  name
78
- } = _ref6;
75
+ } = _ref5;
79
76
  return {
80
77
  ...names,
81
78
  [locale]: name
@@ -86,8 +83,8 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
86
83
  if (includeUndefinedAttributes) {
87
84
  // attributes that are in the disclosure set
88
85
  // but are not defined in the issuer configuration
89
- const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref7 => {
90
- let [, key, value] = _ref7;
86
+ const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref6 => {
87
+ let [, key, value] = _ref6;
91
88
  return [key, {
92
89
  value,
93
90
  name: key
@@ -124,23 +121,26 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
124
121
  cnf
125
122
  } = decodedCredential.sdJwt.payload;
126
123
  if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
127
- Logger.log(LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
128
- throw new IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
124
+ const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
125
+ Logger.log(LogLevel.ERROR, message);
126
+ throw new IoWalletError(message);
129
127
  }
130
128
  return decodedCredential;
131
129
  }
132
-
133
- // utility type that specialize VerifyAndParseCredential for given format
134
-
135
- const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
130
+ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId, _ref7) => {
136
131
  let {
137
132
  credentialCryptoContext,
138
133
  ignoreMissingAttributes,
139
134
  includeUndefinedAttributes
140
- } = _ref8;
135
+ } = _ref7;
141
136
  const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
142
137
  Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
143
- const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
138
+ const credentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId];
139
+ if (!credentialConfig) {
140
+ Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${credentialConfigurationId}`);
141
+ throw new IoWalletError("Credential type not supported by the issuer");
142
+ }
143
+ const parsedCredential = parseCredentialSdJwt(credentialConfig, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
144
144
  const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
145
145
  Logger.log(LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
146
146
  return {
@@ -154,7 +154,7 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
154
154
  * Verify and parse an encoded credential.
155
155
  * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
156
156
  * @param credential The encoded credential returned by {@link obtainCredential}
157
- * @param format The format of the credentual returned by {@link obtainCredential}
157
+ * @param credentialConfigurationId The credential configuration ID that defines the provided credential
158
158
  * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
159
159
  * @param context.ignoreMissingAttributes Skip error when attributes declared in the issuer configuration are not found within disclosures
160
160
  * @param context.includeUndefinedAttributes Include attributes not explicitly declared in the issuer configuration
@@ -163,12 +163,15 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
163
163
  * @throws {IoWalletError} If the credential is not bound to the provided user key
164
164
  * @throws {IoWalletError} If the credential data fail to parse
165
165
  */
166
- export const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
167
- if (format === "vc+sd-jwt") {
168
- Logger.log(LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
169
- return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
166
+ export const verifyAndParseCredential = async (issuerConf, credential, credentialConfigurationId, context) => {
167
+ var _issuerConf$openid_cr;
168
+ const format = (_issuerConf$openid_cr = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId]) === null || _issuerConf$openid_cr === void 0 ? void 0 : _issuerConf$openid_cr.format;
169
+ if (format === "dc+sd-jwt") {
170
+ Logger.log(LogLevel.DEBUG, "Parsing credential in dc+sd-jwt format");
171
+ return verifyAndParseCredentialSdJwt(issuerConf, credential, credentialConfigurationId, context);
170
172
  }
171
- Logger.log(LogLevel.ERROR, `Unsupported credential format: ${format}`);
172
- throw new IoWalletError(`Unsupported credential format: ${format}`);
173
+ const message = `Unsupported credential format: ${format}`;
174
+ Logger.log(LogLevel.ERROR, message);
175
+ throw new IoWalletError(message);
173
176
  };
174
177
  //# sourceMappingURL=07-verify-and-parse-credential.js.map