@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
@@ -13,45 +13,39 @@ var _logging = require("../../utils/logging");
13
13
 
14
14
  // handy alias
15
15
 
16
- const parseCredentialSdJwt = function (credentials_supported, _ref) {
16
+ const parseCredentialSdJwt = function (credentialConfig, _ref) {
17
17
  let {
18
18
  sdJwt,
19
19
  disclosures
20
20
  } = _ref;
21
21
  let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
22
22
  let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
23
- const credentialSubject = credentials_supported[sdJwt.payload.vct];
24
- if (!credentialSubject) {
25
- _logging.Logger.log(_logging.LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
26
- throw new _errors.IoWalletError("Credential type not supported by the issuer");
27
- }
28
- if (credentialSubject.format !== sdJwt.header.typ) {
29
- _logging.Logger.log(_logging.LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
30
- throw new _errors.IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
23
+ if (credentialConfig.format !== sdJwt.header.typ) {
24
+ const message = `Received credential is of an unknwown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
25
+ _logging.Logger.log(_logging.LogLevel.ERROR, message);
26
+ throw new _errors.IoWalletError(message);
31
27
  }
32
-
33
- // transfrom a record { key: value } in an iterable of pairs [key, value]
34
- if (!credentialSubject.claims) {
28
+ if (!credentialConfig.claims) {
35
29
  _logging.Logger.log(_logging.LogLevel.ERROR, "Missing claims in the credential subject");
36
30
  throw new _errors.IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
37
31
  }
38
32
 
39
- const attrDefinitions = Object.entries(credentialSubject.claims);
33
+ const attrDefinitions = credentialConfig.claims;
40
34
 
41
35
  // the key of the attribute defintion must match the disclosure's name
42
- const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
43
- let [attrKey] = _ref2;
44
- return !disclosures.some(_ref3 => {
45
- let [, name] = _ref3;
46
- return name === attrKey;
47
- });
48
- });
36
+ const attrsNotInDisclosures = attrDefinitions.filter(definition => !disclosures.some(_ref2 => {
37
+ let [, name] = _ref2;
38
+ return name === definition.path[0];
39
+ }) // Ignore nested paths for now, see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#name-claims-path-pointer
40
+ );
41
+
49
42
  if (attrsNotInDisclosures.length > 0) {
50
- const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
43
+ const missing = attrsNotInDisclosures.map(_ => _.path[0]).join(", ");
51
44
  const received = disclosures.map(_ => _[1 /* name */]).join(", ");
52
45
  if (!ignoreMissingAttributes) {
53
- _logging.Logger.log(_logging.LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
54
- throw new _errors.IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
46
+ const message = `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`;
47
+ _logging.Logger.log(_logging.LogLevel.ERROR, message);
48
+ throw new _errors.IoWalletError(message);
55
49
  }
56
50
  }
57
51
 
@@ -59,28 +53,31 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
59
53
  // and are present in the disclosure set
60
54
  const definedValues = Object.fromEntries(attrDefinitions
61
55
  // retrieve the value from the disclosure set
62
- .map(_ref4 => {
56
+ .map(_ref3 => {
63
57
  var _disclosures$find;
64
- let [attrKey, definition] = _ref4;
65
- return [attrKey, {
58
+ let {
59
+ path,
60
+ ...definition
61
+ } = _ref3;
62
+ return [path[0], {
66
63
  ...definition,
67
- value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === attrKey)) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
64
+ value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === path[0])) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
68
65
  }];
69
66
  })
70
67
  // add a human readable attribute name, with i18n, in the form { locale: name }
71
68
  // example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
72
- .map(_ref5 => {
69
+ .map(_ref4 => {
73
70
  let [attrKey, {
74
71
  display,
75
72
  ...definition
76
- }] = _ref5;
73
+ }] = _ref4;
77
74
  return [attrKey, {
78
75
  ...definition,
79
- name: display.reduce((names, _ref6) => {
76
+ name: display.reduce((names, _ref5) => {
80
77
  let {
81
78
  locale,
82
79
  name
83
- } = _ref6;
80
+ } = _ref5;
84
81
  return {
85
82
  ...names,
86
83
  [locale]: name
@@ -91,8 +88,8 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
91
88
  if (includeUndefinedAttributes) {
92
89
  // attributes that are in the disclosure set
93
90
  // but are not defined in the issuer configuration
94
- const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref7 => {
95
- let [, key, value] = _ref7;
91
+ const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref6 => {
92
+ let [, key, value] = _ref6;
96
93
  return [key, {
97
94
  value,
98
95
  name: key
@@ -129,23 +126,26 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
129
126
  cnf
130
127
  } = decodedCredential.sdJwt.payload;
131
128
  if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
132
- _logging.Logger.log(_logging.LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
133
- throw new _errors.IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
129
+ const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
130
+ _logging.Logger.log(_logging.LogLevel.ERROR, message);
131
+ throw new _errors.IoWalletError(message);
134
132
  }
135
133
  return decodedCredential;
136
134
  }
137
-
138
- // utility type that specialize VerifyAndParseCredential for given format
139
-
140
- const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
135
+ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId, _ref7) => {
141
136
  let {
142
137
  credentialCryptoContext,
143
138
  ignoreMissingAttributes,
144
139
  includeUndefinedAttributes
145
- } = _ref8;
140
+ } = _ref7;
146
141
  const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
147
142
  _logging.Logger.log(_logging.LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
148
- const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
143
+ const credentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId];
144
+ if (!credentialConfig) {
145
+ _logging.Logger.log(_logging.LogLevel.ERROR, `Credential type not supported by the issuer: ${credentialConfigurationId}`);
146
+ throw new _errors.IoWalletError("Credential type not supported by the issuer");
147
+ }
148
+ const parsedCredential = parseCredentialSdJwt(credentialConfig, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
149
149
  const maybeIssuedAt = (0, _converters.getValueFromDisclosures)(decoded.disclosures, "iat");
150
150
  _logging.Logger.log(_logging.LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
151
151
  return {
@@ -159,7 +159,7 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
159
159
  * Verify and parse an encoded credential.
160
160
  * @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
161
161
  * @param credential The encoded credential returned by {@link obtainCredential}
162
- * @param format The format of the credentual returned by {@link obtainCredential}
162
+ * @param credentialConfigurationId The credential configuration ID that defines the provided credential
163
163
  * @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
164
164
  * @param context.ignoreMissingAttributes Skip error when attributes declared in the issuer configuration are not found within disclosures
165
165
  * @param context.includeUndefinedAttributes Include attributes not explicitly declared in the issuer configuration
@@ -168,13 +168,16 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
168
168
  * @throws {IoWalletError} If the credential is not bound to the provided user key
169
169
  * @throws {IoWalletError} If the credential data fail to parse
170
170
  */
171
- const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
172
- if (format === "vc+sd-jwt") {
173
- _logging.Logger.log(_logging.LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
174
- return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
171
+ const verifyAndParseCredential = async (issuerConf, credential, credentialConfigurationId, context) => {
172
+ var _issuerConf$openid_cr;
173
+ 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;
174
+ if (format === "dc+sd-jwt") {
175
+ _logging.Logger.log(_logging.LogLevel.DEBUG, "Parsing credential in dc+sd-jwt format");
176
+ return verifyAndParseCredentialSdJwt(issuerConf, credential, credentialConfigurationId, context);
175
177
  }
176
- _logging.Logger.log(_logging.LogLevel.ERROR, `Unsupported credential format: ${format}`);
177
- throw new _errors.IoWalletError(`Unsupported credential format: ${format}`);
178
+ const message = `Unsupported credential format: ${format}`;
179
+ _logging.Logger.log(_logging.LogLevel.ERROR, message);
180
+ throw new _errors.IoWalletError(message);
178
181
  };
179
182
  exports.verifyAndParseCredential = verifyAndParseCredential;
180
183
  //# sourceMappingURL=07-verify-and-parse-credential.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_types","_sdJwt","_converters","_logging","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","Logger","log","LogLevel","ERROR","IoWalletError","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","verifySdJwt","SdJwt4VC","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","parsedCredential","credential_configurations_supported","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAGA,IAAAI,QAAA,GAAAJ,OAAA;AAuBA;;AAkBA;;AAKA,MAAMK,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAgI,EAAAC,IAAA,EAI3G;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,MAAMI,iBAAiB,GAAGT,qBAAqB,CAACE,KAAK,CAACQ,OAAO,CAACC,GAAG,CAAC;EAElE,IAAI,CAACF,iBAAiB,EAAE;IACtBG,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,gDAA+Cb,KAAK,CAACQ,OAAO,CAACC,GAAI,EACpE,CAAC;IACD,MAAM,IAAIK,qBAAa,CAAC,6CAA6C,CAAC;EACxE;EAEA,IAAIP,iBAAiB,CAACQ,MAAM,KAAKf,KAAK,CAACgB,MAAM,CAACC,GAAG,EAAE;IACjDP,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,gEAA+DN,iBAAiB,CAACQ,MAAO,gBAAef,KAAK,CAACgB,MAAM,CAACC,GAAI,GAC3H,CAAC;IACD,MAAM,IAAIH,qBAAa,CACpB,gEAA+DP,iBAAiB,CAACQ,MAAO,gBAA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AAE,kCAAiCC,MAAO,EAAC,CAAC;AACrE,CAAC;AAACwE,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["_errors","require","_types","_sdJwt","_converters","_logging","parseCredentialSdJwt","credentialConfig","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","format","header","typ","message","Logger","log","LogLevel","ERROR","IoWalletError","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","verifySdJwt","SdJwt4VC","getPublicKey","cnf","payload","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","credentialConfigurationId","_ref7","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","credential_configurations_supported","parsedCredential","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","_issuerConf$openid_cr","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAGA,IAAAI,QAAA,GAAAJ,OAAA;AA2BA;;AAkBA;;AAKA,MAAMK,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,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;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM+E,wBAAkD,GAAG,MAAAA,CAChEnB,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBkB,OAAO,KACJ;EAAA,IAAAC,qBAAA;EACH,MAAM/E,MAAM,IAAA+E,qBAAA,GACVrB,UAAU,CAACM,wBAAwB,CAACK,mCAAmC,CACrET,yBAAyB,CAC1B,cAAAmB,qBAAA,uBAFDA,qBAAA,CAEG/E,MAAM;EAEX,IAAIA,MAAM,KAAK,WAAW,EAAE;IAC1BI,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAAC4D,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOT,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBkB,OACF,CAAC;EACH;EAEA,MAAM3E,OAAO,GAAI,kCAAiCH,MAAO,EAAC;EAC1DI,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAEJ,OAAO,CAAC;EACnC,MAAM,IAAIK,qBAAa,CAACL,OAAO,CAAC;AAClC,CAAC;AAAC6E,OAAA,CAAAH,wBAAA,GAAAA,wBAAA"}
@@ -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
 
@@ -96,17 +96,13 @@ const walletInstanceAttestation =
96
96
  appFetch,
97
97
  });
98
98
 
99
- const credentialType = "someCredential"; // Let's assume this is the credential type
100
-
101
- const eid = {
99
+ const pid = {
102
100
  credential: "example",
103
101
  parsedCredential: "example"
104
102
  keyTag: "example";
105
- credentialType: "eid";
103
+ credentialType: "PersonIdentificationData";
106
104
  };
107
105
 
108
- const eidCryptoContext = createCryptoContextFor(eid.keyTag);
109
-
110
106
  // Create credential crypto context
111
107
  const credentialKeyTag = uuidv4().toString();
112
108
  await generate(credentialKeyTag); // Let's assume this function generates a new hardware-backed key pair
@@ -115,22 +111,26 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
115
111
  // Start the issuance flow
116
112
  const startFlow: Credential.Issuance.StartFlow = () => ({
117
113
  issuerUrl: WALLET_EAA_PROVIDER_BASE_URL,
118
- credentialType,
114
+ credentialId: "someCredentialId",
119
115
  });
120
116
 
121
- const { issuerUrl } = startFlow();
117
+ const { issuerUrl, credentialId } = startFlow();
122
118
 
123
119
  // Evaluate issuer trust
124
120
  const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(issuerUrl);
125
121
 
126
122
  // Start user authorization
127
- const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
128
- await Credential.Issuance.startUserAuthorization(issuerConf, credentialType, {
129
- walletInstanceAttestation,
130
- redirectUri,
131
- wiaCryptoContext,
132
- appFetch,
133
- });
123
+ const { issuerRequestUri, clientId, codeVerifier } =
124
+ await Credential.Issuance.startUserAuthorization(
125
+ issuerConf,
126
+ [credentialId],
127
+ {
128
+ walletInstanceAttestation,
129
+ redirectUri: REDIRECT_URI,
130
+ wiaCryptoContext,
131
+ appFetch,
132
+ }
133
+ );
134
134
 
135
135
  const requestObject =
136
136
  await Credential.Issuance.getRequestedCredentialToBePresented(
@@ -140,13 +140,12 @@ const requestObject =
140
140
  appFetch
141
141
  );
142
142
 
143
- // The app here should ask the user to confirm the required data contained in the requestObject
144
-
145
143
  // Complete the user authorization via form_post.jwt mode
146
144
  const { code } =
147
145
  await Credential.Issuance.completeUserAuthorizationWithFormPostJwtMode(
148
146
  requestObject,
149
- { wiaCryptoContext, pidCryptoContext, pid, walletInstanceAttestation }
147
+ pid.credential,
148
+ { wiaCryptoContext, pidCryptoContext: createCryptoContextFor(pid.keyTag) }
150
149
  );
151
150
 
152
151
  // Generate the DPoP context which will be used for the whole issuance flow
@@ -157,7 +156,7 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
157
156
  issuerConf,
158
157
  code,
159
158
  clientId,
160
- redirectUri,
159
+ redirectUri: REDIRECT_URI,
161
160
  codeVerifier,
162
161
  {
163
162
  walletInstanceAttestation,
@@ -167,12 +166,19 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
167
166
  }
168
167
  );
169
168
 
170
- // Obtain the credential
171
- const { credential, format } = await Credential.Issuance.obtainCredential(
169
+ // For simplicity, in this example flow we work on a single credential.
170
+ const { credential_configuration_id, credential_identifiers } =
171
+ accessToken.authorization_details[0]!;
172
+
173
+ // Obtain the credential
174
+ const { credential } = await Credential.Issuance.obtainCredential(
172
175
  issuerConf,
173
176
  accessToken,
174
177
  clientId,
175
- credentialDefinition,
178
+ {
179
+ credential_configuration_id,
180
+ credential_identifier: credential_identifiers[0],
181
+ },
176
182
  {
177
183
  credentialCryptoContext,
178
184
  dPopCryptoContext,
@@ -184,22 +190,29 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
184
190
  * Parse and verify the credential. The ignoreMissingAttributes flag must be set to false or omitted in production.
185
191
  * WARNING: includeUndefinedAttributes should not be set to true in production in order to get only claims explicitly declared by the issuer.
186
192
  */
187
- const { parsedCredential } = await Credential.Issuance.verifyAndParseCredential(
188
- issuerConf,
189
- credential,
190
- format,
191
- {
192
- credentialCryptoContext,
193
- ignoreMissingAttributes: true,
194
- includeUndefinedAttributes: false
195
- }
196
- );
193
+ const { parsedCredential } =
194
+ await Credential.Issuance.verifyAndParseCredential(
195
+ issuerConf,
196
+ credential,
197
+ credential_configuration_id,
198
+ {
199
+ credentialCryptoContext,
200
+ ignoreMissingAttributes: true,
201
+ includeUndefinedAttributes: false
202
+ }
203
+ );
204
+
205
+ const credentialType =
206
+ issuerConf.openid_credential_issuer.credential_configurations_supported[
207
+ credential_configuration_id
208
+ ].scope;
197
209
 
198
210
  return {
199
211
  parsedCredential,
200
212
  credential,
201
213
  keyTag: credentialKeyTag,
202
214
  credentialType,
215
+ credentialConfigurationId: credential_configuration_id,
203
216
  };
204
217
  ```
205
218
 
@@ -251,11 +264,10 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
251
264
  // Start the issuance flow
252
265
  const startFlow: Credential.Issuance.StartFlow = () => ({
253
266
  issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
254
- credentialType: "PersonIdentificationData",
255
- appFetch,
267
+ credentialId: "dc_sd_jwt_PersonIdentificationData",
256
268
  });
257
269
 
258
- const { issuerUrl } = startFlow();
270
+ const { issuerUrl, credentialId } = startFlow();
259
271
 
260
272
  // Evaluate issuer trust
261
273
  const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
@@ -265,12 +277,16 @@ const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
265
277
 
266
278
  // Start user authorization
267
279
  const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
268
- await Credential.Issuance.startUserAuthorization(issuerConf, credentialType, {
269
- walletInstanceAttestation,
270
- redirectUri,
271
- wiaCryptoContext,
272
- appFetch,
273
- });
280
+ await Credential.Issuance.startUserAuthorization(
281
+ issuerConf,
282
+ [credentialId], // Request authorization for one or more credentials
283
+ {
284
+ walletInstanceAttestation,
285
+ redirectUri,
286
+ wiaCryptoContext,
287
+ appFetch,
288
+ }
289
+ );
274
290
 
275
291
  // Complete the authorization process with query mode with the authorizationContext which opens the browser
276
292
  const { code } =
@@ -301,12 +317,27 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
301
317
  }
302
318
  );
303
319
 
320
+
321
+ const [pidCredentialDefinition] = credentialDefinition;
322
+
323
+ // Extract the credential_identifier(s) from the access token
324
+ // For each one of them, a credential can be obtained by calling `obtainCredential`
325
+ const { credential_configuration_id, credential_identifiers } =
326
+ accessToken.authorization_details.find(
327
+ (authDetails) =>
328
+ authDetails.credential_configuration_id ===
329
+ pidCredentialDefinition.credential_configuration_id
330
+ );
331
+
304
332
  // Obtain che eID credential
305
333
  const { credential, format } = await Credential.Issuance.obtainCredential(
306
334
  issuerConf,
307
335
  accessToken,
308
336
  clientId,
309
- credentialDefinition,
337
+ {
338
+ credential_configuration_id,
339
+ credential_identifier: credential_identifiers.at(0),
340
+ },
310
341
  {
311
342
  credentialCryptoContext,
312
343
  dPopCryptoContext,
@@ -318,15 +349,16 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
318
349
  const { parsedCredential, issuedAt, expiration } = await Credential.Issuance.verifyAndParseCredential(
319
350
  issuerConf,
320
351
  credential,
321
- format,
352
+ credential_configuration_id,
322
353
  { credentialCryptoContext }
323
354
  );
324
355
 
325
356
  return {
326
357
  parsedCredential,
327
358
  credential,
359
+ credentialConfigurationId: credential_configuration_id
360
+ credentialType: "PersonIdentificationData",
328
361
  keyTag: credentialKeyTag,
329
- credentialType,
330
362
  issuedAt,
331
363
  expiration
332
364
  };
@@ -9,6 +9,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
9
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
10
  const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation";
11
11
  exports.ASSERTION_TYPE = ASSERTION_TYPE;
12
- const SupportedCredentialFormat = z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
12
+ const SupportedCredentialFormat = z.union([z.literal("dc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
13
13
  exports.SupportedCredentialFormat = SupportedCredentialFormat;
14
14
  //# sourceMappingURL=const.js.map
@@ -3,26 +3,29 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TokenResponse = exports.ResponseUriResultShape = exports.CredentialResponse = void 0;
7
- var _par = require("../../utils/par");
6
+ exports.TokenResponse = exports.ResponseUriResultShape = exports.NonceResponse = exports.CredentialResponse = exports.AuthorizationDetail = void 0;
8
7
  var z = _interopRequireWildcard(require("zod"));
9
- var _const = require("./const");
10
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
+ const AuthorizationDetail = z.object({
11
+ type: z.literal("openid_credential"),
12
+ credential_configuration_id: z.string(),
13
+ credential_identifiers: z.array(z.string())
14
+ });
15
+ exports.AuthorizationDetail = AuthorizationDetail;
12
16
  const TokenResponse = z.object({
13
17
  access_token: z.string(),
14
- authorization_details: z.array(_par.AuthorizationDetail),
15
- c_nonce: z.string(),
16
- c_nonce_expires_in: z.number(),
18
+ refresh_token: z.string().optional(),
19
+ authorization_details: z.array(AuthorizationDetail),
17
20
  expires_in: z.number(),
18
21
  token_type: z.string()
19
22
  });
20
23
  exports.TokenResponse = TokenResponse;
21
24
  const CredentialResponse = z.object({
22
- c_nonce: z.string(),
23
- c_nonce_expires_in: z.number(),
24
- credential: z.string(),
25
- format: _const.SupportedCredentialFormat
25
+ credentials: z.array(z.object({
26
+ credential: z.string()
27
+ })),
28
+ notification_id: z.string().optional()
26
29
  });
27
30
 
28
31
  /**
@@ -33,4 +36,8 @@ const ResponseUriResultShape = z.object({
33
36
  redirect_uri: z.string()
34
37
  });
35
38
  exports.ResponseUriResultShape = ResponseUriResultShape;
39
+ const NonceResponse = z.object({
40
+ c_nonce: z.string()
41
+ });
42
+ exports.NonceResponse = NonceResponse;
36
43
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_par","require","z","_interopRequireWildcard","_const","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TokenResponse","object","access_token","string","authorization_details","array","AuthorizationDetail","c_nonce","c_nonce_expires_in","number","expires_in","token_type","exports","CredentialResponse","credential","format","SupportedCredentialFormat","ResponseUriResultShape","redirect_uri"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,I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C,qBAAqB,EAAE7B,CAAC,CAAC8B,KAAK,CAACC,wBAAmB,CAAC;EACnDC,OAAO,EAAEhC,CAAC,CAAC4B,MAAM,CAAC,CAAC;EACnBK,kBAAkB,EAAEjC,CAAC,CAACkC,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEnC,CAAC,CAACkC,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEpC,CAAC,CAAC4B,MAAM,CAAC;AACvB,CAAC,CAAC;AAACS,OAAA,CAAAZ,aAAA,GAAAA,aAAA;AAII,MAAMa,kBAAkB,GAAGtC,CAAC,CAAC0B,MAAM,CAAC;EACzCM,OAAO,EAAEhC,CAAC,CAAC4B,MAAM,CAAC,CAAC;EACnBK,kBAAkB,EAAEjC,CAAC,CAACkC,MAAM,CAAC,CAAC;EAC9BK,UAAU,EAAEvC,CAAC,CAAC4B,MAAM,CAAC,CAAC;EACtBY,MAAM,EAAEC;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AAFAJ,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAGO,MAAMI,sBAAsB,GAAG1C,CAAC,CAAC0B,MAAM,CAAC;EAC7CiB,YAAY,EAAE3C,CAAC,CAAC4B,MAAM,CAAC;AACzB,CAAC,CAAC;AAACS,OAAA,CAAAK,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["z","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","type","literal","credential_configuration_id","string","credential_identifiers","array","exports","TokenResponse","access_token","refresh_token","optional","authorization_details","expires_in","number","token_type","CredentialResponse","credentials","credential","notification_id","ResponseUriResultShape","redirect_uri","NonceResponse","c_nonce"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC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C;AACpB,CAAC,CAAC;AAACG,OAAA,CAAAe,aAAA,GAAAA,aAAA"}
@@ -7,7 +7,6 @@ exports.prepareRemotePresentations = exports.evaluateDcqlQuery = void 0;
7
7
  var _dcql = require("dcql");
8
8
  var _valibot = require("valibot");
9
9
  var _sdJwt = require("../../sd-jwt");
10
- var _crypto = require("../../utils/crypto");
11
10
  var _errors = require("./errors");
12
11
  /**
13
12
  * The purpose for the credential request by the RP.
@@ -23,11 +22,6 @@ const mapCredentialToObject = jwt => {
23
22
  disclosures
24
23
  } = (0, _sdJwt.decode)(jwt);
25
24
  const credentialFormat = sdJwt.header.typ;
26
-
27
- // TODO [SIW-2082]: support MDOC credentials
28
- if (credentialFormat !== "vc+sd-jwt") {
29
- throw new Error(`Unsupported credential format: ${credentialFormat}`);
30
- }
31
25
  return {
32
26
  vct: sdJwt.payload.vct,
33
27
  credential_format: credentialFormat,
@@ -64,7 +58,7 @@ const extractMissingCredentials = (queryResult, originalQuery) => {
64
58
  var _credential$meta;
65
59
  let [id] = _ref3;
66
60
  const credential = originalQuery.credentials.find(c => c.id === id);
67
- if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
61
+ if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "dc+sd-jwt" && (credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
68
62
  throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
69
63
  }
70
64
 
@@ -96,7 +90,7 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
96
90
  return getDcqlQueryMatches(queryResult).map(_ref5 => {
97
91
  var _queryResult$credenti;
98
92
  let [id, match] = _ref5;
99
- if (match.output.credential_format !== "vc+sd-jwt") {
93
+ if (match.output.credential_format !== "dc+sd-jwt" && match.output.credential_format !== "vc+sd-jwt") {
100
94
  throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
101
95
  }
102
96
 
@@ -114,12 +108,12 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
114
108
  required: Boolean(credentialSet.required)
115
109
  };
116
110
  });
117
- const [keyTag, credential] = credentialsSdJwtByVct[vct];
111
+ const [cryptoContext, credential] = credentialsSdJwtByVct[vct];
118
112
  const requiredDisclosures = Object.values(claims);
119
113
  return {
120
114
  id,
121
115
  vct,
122
- keyTag,
116
+ cryptoContext,
123
117
  credential,
124
118
  requiredDisclosures,
125
119
  // When it is a match but no credential_sets are found, the credential is required by default
@@ -148,12 +142,11 @@ const prepareRemotePresentations = async (credentials, nonce, clientId) => {
148
142
  return Promise.all(credentials.map(async item => {
149
143
  const {
150
144
  vp_token
151
- } = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
145
+ } = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, item.cryptoContext]);
152
146
  return {
153
147
  credentialId: item.id,
154
148
  requestedClaims: item.requestedClaims,
155
- vpToken: vp_token,
156
- format: "vc+sd-jwt"
149
+ vpToken: vp_token
157
150
  };
158
151
  }));
159
152
  };