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

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 (122) 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/05-authorize-access.js +6 -10
  4. package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/06-obtain-credential.js +43 -11
  6. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +51 -48
  8. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/README.md +34 -13
  10. package/lib/commonjs/credential/issuance/const.js +1 -1
  11. package/lib/commonjs/credential/issuance/types.js +16 -10
  12. package/lib/commonjs/credential/issuance/types.js.map +1 -1
  13. package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +4 -4
  14. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +3 -3
  15. package/lib/commonjs/credential/status/README.md +0 -1
  16. package/lib/commonjs/sd-jwt/__test__/index.test.js +11 -15
  17. package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
  18. package/lib/commonjs/sd-jwt/__test__/types.test.js +5 -2
  19. package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
  20. package/lib/commonjs/sd-jwt/__test__/utils.test.js +37 -0
  21. package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -0
  22. package/lib/commonjs/sd-jwt/index.js +20 -0
  23. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  24. package/lib/commonjs/sd-jwt/types.js +51 -4
  25. package/lib/commonjs/sd-jwt/types.js.map +1 -1
  26. package/lib/commonjs/sd-jwt/utils.js +64 -0
  27. package/lib/commonjs/sd-jwt/utils.js.map +1 -0
  28. package/lib/commonjs/trust/types.js +18 -13
  29. package/lib/commonjs/trust/types.js.map +1 -1
  30. package/lib/commonjs/utils/par.js +32 -22
  31. package/lib/commonjs/utils/par.js.map +1 -1
  32. package/lib/commonjs/utils/pop.js +1 -1
  33. package/lib/commonjs/utils/pop.js.map +1 -1
  34. package/lib/commonjs/wallet-instance-attestation/types.js +5 -1
  35. package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
  36. package/lib/module/credential/issuance/03-start-user-authorization.js +38 -24
  37. package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
  38. package/lib/module/credential/issuance/05-authorize-access.js +6 -10
  39. package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
  40. package/lib/module/credential/issuance/06-obtain-credential.js +44 -12
  41. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  42. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +51 -48
  43. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  44. package/lib/module/credential/issuance/README.md +34 -13
  45. package/lib/module/credential/issuance/const.js +1 -1
  46. package/lib/module/credential/issuance/types.js +12 -8
  47. package/lib/module/credential/issuance/types.js.map +1 -1
  48. package/lib/module/credential/presentation/07-evaluate-dcql-query.js +4 -4
  49. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +3 -3
  50. package/lib/module/credential/status/README.md +0 -1
  51. package/lib/module/sd-jwt/__test__/index.test.js +11 -16
  52. package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
  53. package/lib/module/sd-jwt/__test__/types.test.js +5 -2
  54. package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
  55. package/lib/module/sd-jwt/__test__/utils.test.js +35 -0
  56. package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -0
  57. package/lib/module/sd-jwt/index.js +1 -0
  58. package/lib/module/sd-jwt/index.js.map +1 -1
  59. package/lib/module/sd-jwt/types.js +50 -3
  60. package/lib/module/sd-jwt/types.js.map +1 -1
  61. package/lib/module/sd-jwt/utils.js +57 -0
  62. package/lib/module/sd-jwt/utils.js.map +1 -0
  63. package/lib/module/trust/types.js +18 -13
  64. package/lib/module/trust/types.js.map +1 -1
  65. package/lib/module/utils/par.js +29 -20
  66. package/lib/module/utils/par.js.map +1 -1
  67. package/lib/module/utils/pop.js +1 -1
  68. package/lib/module/utils/pop.js.map +1 -1
  69. package/lib/module/wallet-instance-attestation/types.js +5 -1
  70. package/lib/module/wallet-instance-attestation/types.js.map +1 -1
  71. package/lib/typescript/client/generated/wallet-provider.d.ts +12 -12
  72. package/lib/typescript/credential/issuance/01-start-flow.d.ts +2 -2
  73. package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
  74. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +7 -6
  75. package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
  76. package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
  77. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +10 -5
  78. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  79. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -2
  80. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  81. package/lib/typescript/credential/issuance/const.d.ts +1 -1
  82. package/lib/typescript/credential/issuance/types.d.ts +46 -26
  83. package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
  84. package/lib/typescript/pid/sd-jwt/types.d.ts +7 -7
  85. package/lib/typescript/sd-jwt/__test__/utils.test.d.ts +2 -0
  86. package/lib/typescript/sd-jwt/__test__/utils.test.d.ts.map +1 -0
  87. package/lib/typescript/sd-jwt/index.d.ts +21 -8
  88. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  89. package/lib/typescript/sd-jwt/types.d.ts +194 -12
  90. package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
  91. package/lib/typescript/sd-jwt/utils.d.ts +18 -0
  92. package/lib/typescript/sd-jwt/utils.d.ts.map +1 -0
  93. package/lib/typescript/trust/build-chain.d.ts +30 -14
  94. package/lib/typescript/trust/build-chain.d.ts.map +1 -1
  95. package/lib/typescript/trust/types.d.ts +322 -158
  96. package/lib/typescript/trust/types.d.ts.map +1 -1
  97. package/lib/typescript/utils/par.d.ts +29 -13
  98. package/lib/typescript/utils/par.d.ts.map +1 -1
  99. package/lib/typescript/wallet-instance-attestation/types.d.ts +9 -9
  100. package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/src/credential/issuance/01-start-flow.ts +2 -2
  103. package/src/credential/issuance/03-start-user-authorization.ts +57 -38
  104. package/src/credential/issuance/05-authorize-access.ts +5 -11
  105. package/src/credential/issuance/06-obtain-credential.ts +53 -23
  106. package/src/credential/issuance/07-verify-and-parse-credential.ts +54 -62
  107. package/src/credential/issuance/README.md +34 -13
  108. package/src/credential/issuance/const.ts +1 -1
  109. package/src/credential/issuance/types.ts +18 -8
  110. package/src/credential/presentation/07-evaluate-dcql-query.ts +4 -4
  111. package/src/credential/presentation/07-evaluate-input-descriptor.ts +3 -3
  112. package/src/credential/status/README.md +0 -1
  113. package/src/sd-jwt/__test__/index.test.ts +8 -29
  114. package/src/sd-jwt/__test__/types.test.ts +6 -2
  115. package/src/sd-jwt/__test__/utils.test.ts +37 -0
  116. package/src/sd-jwt/index.ts +2 -0
  117. package/src/sd-jwt/types.ts +49 -2
  118. package/src/sd-jwt/utils.ts +73 -0
  119. package/src/trust/types.ts +23 -17
  120. package/src/utils/par.ts +37 -21
  121. package/src/utils/pop.ts +1 -1
  122. package/src/wallet-instance-attestation/types.ts +3 -1
@@ -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,MAAM,GAAG,IAAIC,GAAG,CAACJ,WAAW,CAAC;EACnC,MAAMK,GAAG,GAAI,GAAEF,MAAM,CAACG,QAAS,K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AE,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;AA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,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;EACH,MAAM;IACJC,uBAAuB;IACvBC,QAAQ,GAAGC,KAAK;IAChBC;EACF,CAAC,GAAGL,OAAO;EAEX,M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ACC,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;AAkBtD,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;IAC3BJ;EACF,CAAC,CAAC,CACDK,WAAW,CAACP,QAAQ,CAAC,CACrBQ,SAAS,CAACT,MAAM,CAAC,CACjBU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C,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
@@ -1 +1 @@
1
- {"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","LogLevel","Logger","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","log","ERROR","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","parsedCredential","credential_configurations_supported","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,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K,wBAAwB,CAACM,mCAAmC,EACvEP,OAAO,EACPhE,uBAAuB,EACvBI,0BACF,CAAC;EACD,MAAMoE,aAAa,GAAGhF,uBAAuB,CAACwE,OAAO,CAACjE,WAAW,EAAE,KAAK,CAAC;EAEzEL,MAAM,CAACc,GAAG,CACRf,QAAQ,CAAC0E,KAAK,EACb,sBAAqBC,IAAI,CAACC,SAAS,CAACC,gBAAgB,CAAE,gBAAeE,aAAc,EACtF,CAAC;EAED,OAAO;IACLF,gBAAgB;IAChBG,UAAU,EAAE,IAAIC,IAAI,CAACV,OAAO,CAAClE,KAAK,CAACQ,OAAO,CAACqE,GAAG,GAAG,IAAI,CAAC;IACtDC,QAAQ,EACN,OAAOJ,aAAa,KAAK,QAAQ,GAC7B,IAAIE,IAAI,CAACF,aAAa,GAAG,IAAI,CAAC,GAC9BrE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM0E,wBAAkD,GAAG,MAAAA,CAChEjB,UAAU,EACVC,UAAU,EACVnD,MAAM,EACNoE,OAAO,KACJ;EACH,IAAIpE,MAAM,KAAK,WAAW,EAAE;IAC1BhB,MAAM,CAACc,GAAG,CAACf,QAAQ,CAAC0E,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOR,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVnD,MAAM,EACNoE,OACF,CAAC;EACH;EAEApF,MAAM,CAACc,GAAG,CAACf,QAAQ,CAACgB,KAAK,EAAG,kCAAiCC,MAAO,EAAC,CAAC;EACtE,MAAM,IAAItB,aAAa,CAAE,kCAAiCsB,MAAO,EAAC,CAAC;AACrE,CAAC"}
1
+ {"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","LogLevel","Logger","parseCredentialSdJwt","credentialConfig","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","format","header","typ","message","log","ERROR","claims","attrDefinitions","attrsNotInDisclosures","filter","definition","some","_ref2","name","path","missing","map","_","join","received","definedValues","Object","fromEntries","_ref3","_disclosures$find","value","find","_ref4","attrKey","display","reduce","names","_ref5","locale","undefinedValues","keys","includes","_ref6","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","payload","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","credentialConfigurationId","_ref7","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","credential_configurations_supported","parsedCredential","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","_issuerConf$openid_cr"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AACpD,SAASC,uBAAuB,QAAQ,yBAAyB;AAGjE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;;AA2BtD;;AAkBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,gBAAgC,EAAAC,IAAA,EAIX;EAAA,IAHrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,GAAAF,IAAA;EAAA,IAC9CG,uBAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACxCG,0BAAmC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE3C,IAAIL,gBAAgB,CAACS,MAAM,KAAKP,KAAK,CAACQ,MAAM,CAACC,GAAG,EAAE;IAChD,MAAMC,OAAO,GAAI,gEAA+DZ,gBAAgB,CAACS,MAAO,gBAAeP,KAAK,CAACQ,MAAM,CAACC,GAAI,GAAE;IAC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,CAACK,mCAAmC,CACrET,yBAAyB,CAC1B,cAAAkB,qBAAA,uBAFDA,qBAAA,CAEGzE,MAAM;EAEX,IAAIA,MAAM,KAAK,WAAW,EAAE;IAC1BX,MAAM,CAACe,GAAG,CAAChB,QAAQ,CAACyE,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOT,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBiB,OACF,CAAC;EACH;EAEA,MAAMrE,OAAO,GAAI,kCAAiCH,MAAO,EAAC;EAC1DX,MAAM,CAACe,GAAG,CAAChB,QAAQ,CAACiB,KAAK,EAAEF,OAAO,CAAC;EACnC,MAAM,IAAIpB,aAAa,CAACoB,OAAO,CAAC;AAClC,CAAC"}
@@ -6,7 +6,7 @@ There's a fork in the flow which is based on the type of the credential that is
6
6
  This is due to the fact that eID credentials require a different authorization flow than other credentials, which is accomplished by a strong authentication method like SPID or CIE.
7
7
  Credentials instead require a simpler authorization flow and they require other credentials to be presented in order to be issued.
8
8
 
9
- The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step.
9
+ The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step. Available credentials are identified with a unique `credential_configuration_id`, that must be used when requesting authorization. The Authorization Server returns an array of **credential identifiers** that map to the `credential_configuration_id` provided: to obtain the credential, one of the credential identifiers (or all of them) must be requested to the credential endpoint.
10
10
 
11
11
  ## Sequence Diagram
12
12
 
@@ -72,6 +72,8 @@ The expected result from the authentication process is in `form_post.jwt` format
72
72
  <summary>Credential issuance flow</summary>
73
73
 
74
74
  ```ts
75
+ // TODO: [SIW-2209] update documentation in PR #219
76
+
75
77
  // Retrieve the integrity key tag from the store and create its context
76
78
  const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
77
79
  const integrityContext = getIntegrityContext(integrityKeyTag);
@@ -251,11 +253,10 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
251
253
  // Start the issuance flow
252
254
  const startFlow: Credential.Issuance.StartFlow = () => ({
253
255
  issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
254
- credentialType: "PersonIdentificationData",
255
- appFetch,
256
+ credentialId: "dc_sd_jwt_PersonIdentificationData",
256
257
  });
257
258
 
258
- const { issuerUrl } = startFlow();
259
+ const { issuerUrl, credentialId } = startFlow();
259
260
 
260
261
  // Evaluate issuer trust
261
262
  const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
@@ -265,12 +266,16 @@ const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
265
266
 
266
267
  // Start user authorization
267
268
  const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
268
- await Credential.Issuance.startUserAuthorization(issuerConf, credentialType, {
269
- walletInstanceAttestation,
270
- redirectUri,
271
- wiaCryptoContext,
272
- appFetch,
273
- });
269
+ await Credential.Issuance.startUserAuthorization(
270
+ issuerConf,
271
+ [credentialId], // Request authorization for one or more credentials
272
+ {
273
+ walletInstanceAttestation,
274
+ redirectUri,
275
+ wiaCryptoContext,
276
+ appFetch,
277
+ }
278
+ );
274
279
 
275
280
  // Complete the authorization process with query mode with the authorizationContext which opens the browser
276
281
  const { code } =
@@ -301,12 +306,27 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
301
306
  }
302
307
  );
303
308
 
309
+
310
+ const [pidCredentialDefinition] = credentialDefinition;
311
+
312
+ // Extract the credential_identifier(s) from the access token
313
+ // For each one of them, a credential can be obtained by calling `obtainCredential`
314
+ const { credential_configuration_id, credential_identifiers } =
315
+ accessToken.authorization_details.find(
316
+ (authDetails) =>
317
+ authDetails.credential_configuration_id ===
318
+ pidCredentialDefinition.credential_configuration_id
319
+ );
320
+
304
321
  // Obtain che eID credential
305
322
  const { credential, format } = await Credential.Issuance.obtainCredential(
306
323
  issuerConf,
307
324
  accessToken,
308
325
  clientId,
309
- credentialDefinition,
326
+ {
327
+ credential_configuration_id,
328
+ credential_identifier: credential_identifiers.at(0),
329
+ },
310
330
  {
311
331
  credentialCryptoContext,
312
332
  dPopCryptoContext,
@@ -318,15 +338,16 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
318
338
  const { parsedCredential, issuedAt, expiration } = await Credential.Issuance.verifyAndParseCredential(
319
339
  issuerConf,
320
340
  credential,
321
- format,
341
+ credential_configuration_id,
322
342
  { credentialCryptoContext }
323
343
  );
324
344
 
325
345
  return {
326
346
  parsedCredential,
327
347
  credential,
348
+ credentialConfigurationId: credential_configuration_id
349
+ credentialType: "PersonIdentificationData",
328
350
  keyTag: credentialKeyTag,
329
- credentialType,
330
351
  issuedAt,
331
352
  expiration
332
353
  };
@@ -1,4 +1,4 @@
1
1
  import * as z from "zod";
2
2
  export const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation";
3
- export const SupportedCredentialFormat = z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
3
+ export const SupportedCredentialFormat = z.union([z.literal("dc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
4
4
  //# sourceMappingURL=const.js.map
@@ -1,19 +1,20 @@
1
- import { AuthorizationDetail } from "../../utils/par";
2
1
  import * as z from "zod";
3
- import { SupportedCredentialFormat } from "./const";
2
+ export const AuthorizationDetail = z.object({
3
+ type: z.literal("openid_credential"),
4
+ credential_configuration_id: z.string(),
5
+ credential_identifiers: z.array(z.string())
6
+ });
4
7
  export const TokenResponse = z.object({
5
8
  access_token: z.string(),
6
9
  authorization_details: z.array(AuthorizationDetail),
7
- c_nonce: z.string(),
8
- c_nonce_expires_in: z.number(),
9
10
  expires_in: z.number(),
10
11
  token_type: z.string()
11
12
  });
12
13
  export const CredentialResponse = z.object({
13
- c_nonce: z.string(),
14
- c_nonce_expires_in: z.number(),
15
- credential: z.string(),
16
- format: SupportedCredentialFormat
14
+ credentials: z.array(z.object({
15
+ credential: z.string()
16
+ })),
17
+ notification_id: z.string().optional()
17
18
  });
18
19
 
19
20
  /**
@@ -22,4 +23,7 @@ export const CredentialResponse = z.object({
22
23
  export const ResponseUriResultShape = z.object({
23
24
  redirect_uri: z.string()
24
25
  });
26
+ export const NonceResponse = z.object({
27
+ c_nonce: z.string()
28
+ });
25
29
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMe,sBAAsB,GAAGhB,CAAC,CAACG,MAAM,CAAC;EAC7Cc,YAAY,EAAEjB,CAAC,CAACK,MAAM,CAAC;AACzB,CAAC,CAAC"}
1
+ {"version":3,"names":["z","AuthorizationDetail","object","type","literal","credential_configuration_id","string","credential_identifiers","array","TokenResponse","access_token","authorization_details","expires_in","number","token_type","CredentialResponse","credentials","credential","notification_id","optional","ResponseUriResultShape","redirect_uri","NonceResponse","c_nonce"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AAGxB,OAAO,MAAMC,mBAAmB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC1CC,IAAI,EAAEH,CAAC,CAACI,OAAO,CAAC,mBAAmB,CAAC;EACpCC,2BAA2B,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EACvCC,sBAAsB,EAAEP,CAAC,CAACQ,KAAK,CAACR,CAAC,CAACM,MAAM,CAAC,CAAC;AAC5C,CAAC,CAAC;AAIF,OAAO,MAAMG,aAAa,GAAGT,CAAC,CAACE,MAAM,CAAC;EACpCQ,YAAY,EAAEV,CAAC,CAACM,MAAM,CAAC,CAAC;EACxBK,qBAAqB,EAAEX,CAAC,CAACQ,KAAK,CAACP,mBAAmB,CAAC;EACnDW,UAAU,EAAEZ,CAAC,CAACa,MAAM,CAAC,CAAC;EACtBC,UAAU,EAAEd,CAAC,CAACM,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMS,kBAAkB,GAAGf,CAAC,CAACE,MAAM,CAAC;EACzCc,WAAW,EAAEhB,CAAC,CAACQ,KAAK,CAClBR,CAAC,CAACE,MAAM,CAAC;IACPe,UAAU,EAAEjB,CAAC,CAACM,MAAM,CAAC;EACvB,CAAC,CACH,CAAC;EACDY,eAAe,EAAElB,CAAC,CAACM,MAAM,CAAC,CAAC,CAACa,QAAQ,CAAC;AACvC,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGpB,CAAC,CAACE,MAAM,CAAC;EAC7CmB,YAAY,EAAErB,CAAC,CAACM,MAAM,CAAC;AACzB,CAAC,CAAC;AAKF,OAAO,MAAMgB,aAAa,GAAGtB,CAAC,CAACE,MAAM,CAAC;EACpCqB,OAAO,EAAEvB,CAAC,CAACM,MAAM,CAAC;AACpB,CAAC,CAAC"}
@@ -20,7 +20,7 @@ const mapCredentialToObject = jwt => {
20
20
  const credentialFormat = sdJwt.header.typ;
21
21
 
22
22
  // TODO [SIW-2082]: support MDOC credentials
23
- if (credentialFormat !== "vc+sd-jwt") {
23
+ if (credentialFormat !== "dc+sd-jwt") {
24
24
  throw new Error(`Unsupported credential format: ${credentialFormat}`);
25
25
  }
26
26
  return {
@@ -59,7 +59,7 @@ const extractMissingCredentials = (queryResult, originalQuery) => {
59
59
  var _credential$meta;
60
60
  let [id] = _ref3;
61
61
  const credential = originalQuery.credentials.find(c => c.id === id);
62
- if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
62
+ if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "dc+sd-jwt") {
63
63
  throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
64
64
  }
65
65
 
@@ -91,7 +91,7 @@ export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
91
91
  return getDcqlQueryMatches(queryResult).map(_ref5 => {
92
92
  var _queryResult$credenti;
93
93
  let [id, match] = _ref5;
94
- if (match.output.credential_format !== "vc+sd-jwt") {
94
+ if (match.output.credential_format !== "dc+sd-jwt") {
95
95
  throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
96
96
  }
97
97
 
@@ -147,7 +147,7 @@ export const prepareRemotePresentations = async (credentials, nonce, clientId) =
147
147
  credentialId: item.id,
148
148
  requestedClaims: item.requestedClaims,
149
149
  vpToken: vp_token,
150
- format: "vc+sd-jwt"
150
+ format: "dc+sd-jwt"
151
151
  };
152
152
  }));
153
153
  };
@@ -231,7 +231,7 @@ export const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJw
231
231
  })) || [];
232
232
  return Promise.all(inputDescriptors.map(async descriptor => {
233
233
  var _descriptor$format;
234
- if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format["vc+sd-jwt"]) {
234
+ if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format["dc+sd-jwt"]) {
235
235
  if (!decodedSdJwtCredentials.length) {
236
236
  throw new CredentialsNotFoundError([{
237
237
  id: descriptor.id,
@@ -277,7 +277,7 @@ export const prepareLegacyRemotePresentations = async (credentialAndDescriptors,
277
277
  return Promise.all(credentialAndDescriptors.map(async item => {
278
278
  var _descriptor$format2;
279
279
  const descriptor = item.inputDescriptor;
280
- if ((_descriptor$format2 = descriptor.format) !== null && _descriptor$format2 !== void 0 && _descriptor$format2["vc+sd-jwt"]) {
280
+ if ((_descriptor$format2 = descriptor.format) !== null && _descriptor$format2 !== void 0 && _descriptor$format2["dc+sd-jwt"]) {
281
281
  const {
282
282
  vp_token
283
283
  } = await prepareVpToken(nonce, client_id, [item.credential, item.requestedClaims, createCryptoContextFor(item.keyTag)]);
@@ -285,7 +285,7 @@ export const prepareLegacyRemotePresentations = async (credentialAndDescriptors,
285
285
  requestedClaims: item.requestedClaims,
286
286
  inputDescriptor: descriptor,
287
287
  vpToken: vp_token,
288
- format: "vc+sd-jwt"
288
+ format: "dc+sd-jwt"
289
289
  };
290
290
  }
291
291
  throw new CredentialsNotFoundError([{