@pagopa/io-react-native-wallet 1.5.0 → 1.6.0

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 (58) hide show
  1. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +33 -21
  2. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  3. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +192 -58
  4. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  5. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +32 -15
  6. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  7. package/lib/commonjs/credential/presentation/types.js +1 -1
  8. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  9. package/lib/commonjs/entity/trust/chain.js.map +1 -1
  10. package/lib/commonjs/mdoc/index.js +45 -13
  11. package/lib/commonjs/mdoc/index.js.map +1 -1
  12. package/lib/commonjs/utils/crypto.js +70 -4
  13. package/lib/commonjs/utils/crypto.js.map +1 -1
  14. package/lib/commonjs/utils/string.js +4 -4
  15. package/lib/commonjs/utils/string.js.map +1 -1
  16. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +33 -21
  17. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  18. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +186 -55
  19. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  20. package/lib/module/credential/presentation/08-send-authorization-response.js +32 -15
  21. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  22. package/lib/module/credential/presentation/types.js +1 -1
  23. package/lib/module/credential/presentation/types.js.map +1 -1
  24. package/lib/module/entity/trust/chain.js.map +1 -1
  25. package/lib/module/mdoc/index.js +43 -12
  26. package/lib/module/mdoc/index.js.map +1 -1
  27. package/lib/module/utils/crypto.js +67 -2
  28. package/lib/module/utils/crypto.js.map +1 -1
  29. package/lib/module/utils/string.js +4 -4
  30. package/lib/module/utils/string.js.map +1 -1
  31. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +1 -1
  32. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  33. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +49 -13
  34. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  35. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +3 -2
  36. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  37. package/lib/typescript/credential/presentation/types.d.ts +10 -7
  38. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  39. package/lib/typescript/entity/trust/chain.d.ts.map +1 -1
  40. package/lib/typescript/mdoc/index.d.ts +6 -2
  41. package/lib/typescript/mdoc/index.d.ts.map +1 -1
  42. package/lib/typescript/utils/crypto.d.ts +8 -0
  43. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  44. package/lib/typescript/utils/errors.d.ts.map +1 -1
  45. package/lib/typescript/utils/misc.d.ts.map +1 -1
  46. package/lib/typescript/utils/string.d.ts +3 -3
  47. package/lib/typescript/utils/string.d.ts.map +1 -1
  48. package/package.json +14 -12
  49. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -16
  50. package/src/credential/presentation/07-evaluate-input-descriptor.ts +278 -97
  51. package/src/credential/presentation/08-send-authorization-response.ts +35 -25
  52. package/src/credential/presentation/types.ts +9 -6
  53. package/src/entity/trust/chain.ts +14 -10
  54. package/src/mdoc/index.ts +72 -15
  55. package/src/utils/crypto.ts +61 -2
  56. package/src/utils/errors.ts +2 -2
  57. package/src/utils/misc.ts +2 -2
  58. package/src/utils/string.ts +4 -4
@@ -103,12 +103,12 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
103
103
  }
104
104
  return definedValues;
105
105
  };
106
- const parseCredentialMDoc = function (credentials_supported, _ref8) {
106
+ const parseCredentialMDoc = function (credentials_supported, credential_type, _ref8) {
107
107
  let {
108
- mDoc
108
+ issuerSigned
109
109
  } = _ref8;
110
- let includeUndefinedAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
111
- const credentialSubject = credentials_supported[mDoc.docType];
110
+ let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
111
+ const credentialSubject = credentials_supported[credential_type];
112
112
  if (!credentialSubject) {
113
113
  throw new _errors.IoWalletError("Credential type not supported by the issuer");
114
114
  }
@@ -126,10 +126,10 @@ const parseCredentialMDoc = function (credentials_supported, _ref8) {
126
126
  return [namespace, claimNameKey, definition];
127
127
  });
128
128
  });
129
- if (!mDoc.issuerSigned.nameSpaces) {
129
+ if (!issuerSigned.nameSpaces) {
130
130
  throw new _errors.IoWalletError("Missing claims in the credential");
131
131
  }
132
- const flatNamespaces = Object.entries(mDoc.issuerSigned.nameSpaces).flatMap(_ref11 => {
132
+ const flatNamespaces = Object.entries(issuerSigned.nameSpaces).flatMap(_ref11 => {
133
133
  let [namespace, values] = _ref11;
134
134
  return values.map(v => [namespace, v.elementIdentifier, v.elementValue]);
135
135
  });
@@ -233,25 +233,37 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
233
233
  *
234
234
  */
235
235
  async function verifyCredentialMDoc(rawCredential, issuerKeys, holderBindingContext) {
236
- const [decodedCredential] =
236
+ /**
237
+ * For the moment, being that issues in the crypto key generation
238
+ * have been found on Android, the check for the deviceKey inside
239
+ * of the mDoc is skipped, so we are not interested in the holderBindingKey
240
+ */
241
+ const [decodedCredential, _] =
237
242
  // parallel for optimization
238
243
  await Promise.all([(0, _mdoc.verify)(rawCredential, issuerKeys), holderBindingContext.getPublicKey()]);
239
-
240
- // TODO Implement the holder binding verification for MDOC
241
-
242
- // Get only the first decoded credential
243
-
244
244
  if (!decodedCredential) {
245
245
  throw new _errors.IoWalletError("No MDOC credentials found!");
246
246
  }
247
- return {
248
- mDoc: decodedCredential.mDoc
249
- };
247
+
248
+ /**
249
+ * For the moment, being that issues in the crypto key generation
250
+ * have been found on Android, the check for the deviceKey inside
251
+ * of the mDoc is skipped.
252
+ */
253
+ //const key = decodedCredential.mDoc.issuerSigned.issuerAuth.payload.deviceKeyInfo.deviceKey;
254
+ //
255
+ //if (!compareKeysByThumbprint(key, holderBindingKey as PublicKey)) {
256
+ // throw new IoWalletError(
257
+ // `Failed to verify holder binding, holder binding key and mDoc deviceKey don't match`
258
+ // );
259
+ //}
260
+
261
+ return decodedCredential;
250
262
  }
251
263
 
252
264
  // utility type that specialize VerifyAndParseCredential for given format
253
265
 
254
- const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref18) => {
266
+ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, __, _ref18) => {
255
267
  let {
256
268
  credentialCryptoContext,
257
269
  ignoreMissingAttributes,
@@ -266,14 +278,14 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref18)
266
278
  issuedAt: typeof maybeIssuedAt === "number" ? new Date(maybeIssuedAt * 1000) : undefined
267
279
  };
268
280
  };
269
- const verifyAndParseCredentialMDoc = async (issuerConf, credential, _, _ref19) => {
281
+ const verifyAndParseCredentialMDoc = async (issuerConf, credential, _, credentialType, _ref19) => {
270
282
  var _parsedCredential$exp, _parsedCredential$iss;
271
283
  let {
272
284
  credentialCryptoContext,
273
285
  ignoreMissingAttributes
274
286
  } = _ref19;
275
287
  const decoded = await verifyCredentialMDoc(credential, issuerConf.keys, credentialCryptoContext);
276
- const parsedCredential = parseCredentialMDoc(issuerConf.credential_configurations_supported, decoded, ignoreMissingAttributes);
288
+ const parsedCredential = parseCredentialMDoc(issuerConf.credential_configurations_supported, credentialType, decoded, ignoreMissingAttributes);
277
289
  const expirationDate = (0, _converters2.extractElementValueAsDate)(parsedCredential === null || parsedCredential === void 0 || (_parsedCredential$exp = parsedCredential.expiry_date) === null || _parsedCredential$exp === void 0 ? void 0 : _parsedCredential$exp.value);
278
290
  if (!expirationDate) {
279
291
  throw new _errors.IoWalletError(`expirationDate must be present!!`);
@@ -301,12 +313,12 @@ const verifyAndParseCredentialMDoc = async (issuerConf, credential, _, _ref19) =
301
313
  * @throws {IoWalletError} If the credential is not bound to the provided user key
302
314
  * @throws {IoWalletError} If the credential data fail to parse
303
315
  */
304
- const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
316
+ const verifyAndParseCredential = async (issuerConf, credential, format, credentialType, context) => {
305
317
  if (format === "vc+sd-jwt") {
306
- return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
318
+ return verifyAndParseCredentialSdJwt(issuerConf, credential, format, credentialType, context);
307
319
  }
308
320
  if (format === "mso_mdoc") {
309
- return verifyAndParseCredentialMDoc(issuerConf, credential, format, context);
321
+ return verifyAndParseCredentialMDoc(issuerConf, credential, format, credentialType, context);
310
322
  }
311
323
  throw new _errors.IoWalletError(`Unsupported credential format: ${format}`);
312
324
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_errors","require","_types","_sdJwt","_mdoc","_converters","_converters2","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","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","parseCredentialMDoc","_ref8","mDoc","docType","flatMap","_ref9","namespace","claimName","_ref10","claimNameKey","issuerSigned","nameSpaces","flatNamespaces","_ref11","values","v","elementIdentifier","elementValue","_ref12","_flatNamespaces$find","attrDefNamespace","_ref13","_ref14","_ref15","_ref16","_ref17","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","jwk","kid","verifyCredentialMDoc","verifyMdoc","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref18","credentialCryptoContext","decoded","parsedCredential","credential_configurations_supported","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredentialMDoc","_ref19","_parsedCredential$exp","_parsedCredential$iss","expirationDate","extractElementValueAsDate","expiry_date","setDate","getDate","issue_date","verifyAndParseCredential","context","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,IAAAK,YAAA,GAAAL,OAAA;AAuBA;;AAkBA;;AASA,MAAMM,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAgG,EAAAC,IAAA,EAI3E;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;IACtB,MAAM,IAAIG,qBAAa,CAAC,6CAA6C,CAAC;EACxE;EAEA,IAAIH,iBAAiB,CAACI,MAAM,KAAKX,KAAK,CAACY,MAAM,CAACC,GAAG,EAAE;IACjD,MAAM,IAAIH,qBAAa,CACpB,gEAA+DH,iBAAiB,CAACI,MAAO,gBAAeX,KAAK,CAACY,MAAM,CAACC,GAAI,KAC3H,CAAC;EACH;;EAEA;EACA,IAAI,CAACN,iBAAiB,CAACO,MAAM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A,IAAIxG,MAAM,KAAK,UAAU,EAAE;IACzB,OAAO6F,4BAA4B,CACjCb,UAAU,EACVC,UAAU,EACVjF,MAAM,EACNwG,OACF,CAAC;EACH;EAEA,MAAM,IAAIzG,qBAAa,CAAE,kCAAiCC,MAAO,EAAC,CAAC;AACrE,CAAC;AAACyG,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["_errors","require","_types","_sdJwt","_mdoc","_converters","_converters2","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","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","parseCredentialMDoc","credential_type","_ref8","issuerSigned","flatMap","_ref9","namespace","claimName","_ref10","claimNameKey","nameSpaces","flatNamespaces","_ref11","values","v","elementIdentifier","elementValue","_ref12","_flatNamespaces$find","attrDefNamespace","_ref13","_ref14","_ref15","_ref16","_ref17","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","jwk","kid","verifyCredentialMDoc","verifyMdoc","verifyAndParseCredentialSdJwt","issuerConf","credential","__","_ref18","credentialCryptoContext","decoded","parsedCredential","credential_configurations_supported","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredentialMDoc","credentialType","_ref19","_parsedCredential$exp","_parsedCredential$iss","expirationDate","extractElementValueAsDate","expiry_date","setDate","getDate","issue_date","verifyAndParseCredential","context","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,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-3,19 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.prepareRemotePresentations = exports.findCredentialSdJwt = exports.evaluateInputDescriptors = exports.evaluateInputDescriptorForSdJwt4VC = void 0;
6
+ exports.prepareRemotePresentations = exports.findCredentialSdJwt = exports.findCredentialMDoc = exports.evaluateInputDescriptors = exports.evaluateInputDescriptorForSdJwt4VC = exports.evaluateInputDescriptorForMdoc = exports.disclosureWithEncodedToEvaluatedDisclosure = void 0;
7
7
  var _sdJwt = require("../../sd-jwt");
8
8
  var _crypto = require("../../utils/crypto");
9
9
  var _jsonpathPlus = require("jsonpath-plus");
10
10
  var _errors = require("./errors");
11
11
  var _ajv = _interopRequireDefault(require("ajv"));
12
- var _string = require("../../utils/string");
13
12
  var _ioReactNativeCbor = require("@pagopa/io-react-native-cbor");
13
+ var _mdoc = require("../../mdoc");
14
+ var _misc = require("../../utils/misc");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  const ajv = new _ajv.default({
16
17
  allErrors: true
17
18
  });
18
- const INDEX_CLAIM_NAME = 1;
19
+ const disclosureWithEncodedToEvaluatedDisclosure = disclosure => {
20
+ const [, claimName, claimValue] = disclosure.decoded;
21
+ return {
22
+ name: claimName,
23
+ value: claimValue
24
+ };
25
+ };
26
+ exports.disclosureWithEncodedToEvaluatedDisclosure = disclosureWithEncodedToEvaluatedDisclosure;
19
27
  /**
20
28
  * Transforms an array of DisclosureWithEncoded objects into a key-value map.
21
29
  * @param disclosures - An array of DisclosureWithEncoded, each containing a decoded property with [?, claimName, claimValue].
@@ -32,6 +40,22 @@ const mapDisclosuresToObject = disclosures => {
32
40
  }, {});
33
41
  };
34
42
 
43
+ /**
44
+ * Transforms the issuer's namespaces from a CBOR structure into a plain JavaScript object.
45
+ *
46
+ * @param namespaces - The CBOR-based namespaces object where each key corresponds to a namespace,
47
+ * and each value is an array of elements containing identifiers and values.
48
+ * @returns A record (plain object) where each key is a namespace, and its value is another object
49
+ * mapping element identifiers to their corresponding element values.
50
+ */
51
+ const mapNamespacesToObject = namespaces => {
52
+ return Object.entries(namespaces).reduce((obj, _ref2) => {
53
+ let [namespace, elements] = _ref2;
54
+ obj[namespace] = Object.fromEntries(elements.map(element => [element.elementIdentifier, element.elementValue]));
55
+ return obj;
56
+ }, {});
57
+ };
58
+
35
59
  /**
36
60
  * Finds a claim within the payload based on provided JSONPath expressions.
37
61
  * @param paths - An array of JSONPath expressions to search for in the payload.
@@ -79,10 +103,91 @@ const extractClaimName = path => {
79
103
  // match[2] corresponds to the second capture group (\w+) inside [""] or ['']
80
104
  return match[1] || match[2];
81
105
  }
106
+ throw new Error(`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`);
107
+ };
82
108
 
83
- // If the input doesn't match any of the expected formats, return null
109
+ /**
110
+ * Extracts the namespace and claim name from a path in the following format:
111
+ * $['nameSpace']['propertyName']
112
+ *
113
+ * @param path - The path string containing the claim reference.
114
+ * @returns An object with the extracted namespace and claim name.
115
+ * @throws An error if the input format is invalid.
116
+ */
117
+ const extractNamespaceAndClaimName = path => {
118
+ const regex = /^\$\[(?:'|")([^'"\]]+)(?:'|")\]\[(?:'|")([^'"\]]+)(?:'|")\]$/;
119
+ const match = path.match(regex);
120
+ if (match) {
121
+ return {
122
+ nameSpace: match[1],
123
+ propertyName: match[2]
124
+ };
125
+ }
126
+ throw new Error(`Invalid input format: "${path}". Expected format is "$['nameSpace']['propertyName']".`);
127
+ };
128
+ /**
129
+ * Evaluates the input descriptor for an mDoc by verifying that the issuerSigned claims meet
130
+ * the constraints defined in the input descriptor. It categorizes disclosures as either required
131
+ * or optional based on the field definitions.
132
+ *
133
+ * @param inputDescriptor - Contains constraints and field definitions specifying required/optional claims.
134
+ * @param issuerSigned - Contains the issuerSigned with namespaces and their associated claims.
135
+ * @returns An object with two arrays: one for required disclosures and one for optional disclosures.
136
+ * @throws MissingDataError - If a required field is missing or if a claim fails JSON Schema validation.
137
+ */
138
+ const evaluateInputDescriptorForMdoc = (inputDescriptor, issuerSigned) => {
139
+ var _inputDescriptor$cons;
140
+ if (!(inputDescriptor !== null && inputDescriptor !== void 0 && (_inputDescriptor$cons = inputDescriptor.constraints) !== null && _inputDescriptor$cons !== void 0 && _inputDescriptor$cons.fields)) {
141
+ // No validation, no field are required
142
+ return {
143
+ requiredDisclosures: [],
144
+ optionalDisclosures: []
145
+ };
146
+ }
147
+ const requiredDisclosures = [];
148
+ const optionalDisclosures = [];
84
149
 
85
- throw new Error(`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`);
150
+ // Convert issuer's namespaces into an object for easier lookup of claim values.
151
+ const namespacesAsPayload = mapNamespacesToObject(issuerSigned.nameSpaces);
152
+ const allFieldsValid = inputDescriptor.constraints.fields.every(field => {
153
+ const [matchedPath, matchedValue] = findMatchedClaim(field.path, namespacesAsPayload);
154
+
155
+ // If no matching claim is found, the field is valid only if it's marked as optional.
156
+ if (matchedValue === undefined || !matchedPath) {
157
+ return field === null || field === void 0 ? void 0 : field.optional;
158
+ } else {
159
+ // Extract the namespace and property name from the matched path.
160
+ const {
161
+ nameSpace,
162
+ propertyName
163
+ } = extractNamespaceAndClaimName(matchedPath);
164
+ if (nameSpace && propertyName) {
165
+ (field !== null && field !== void 0 && field.optional ? optionalDisclosures : requiredDisclosures).push({
166
+ namespace: nameSpace,
167
+ name: propertyName,
168
+ value: matchedValue
169
+ });
170
+ }
171
+ }
172
+ if (field.filter) {
173
+ try {
174
+ const validateSchema = ajv.compile(field.filter);
175
+ if (!validateSchema(matchedValue)) {
176
+ throw new _errors.MissingDataError(`Claim value "${matchedValue}" for path "${matchedPath}" does not match the provided JSON Schema.`);
177
+ }
178
+ } catch (error) {
179
+ return false;
180
+ }
181
+ }
182
+ return true;
183
+ });
184
+ if (!allFieldsValid) {
185
+ throw new _errors.MissingDataError("Credential validation failed: Required fields are missing or do not match the input descriptor.");
186
+ }
187
+ return {
188
+ requiredDisclosures,
189
+ optionalDisclosures
190
+ };
86
191
  };
87
192
 
88
193
  /**
@@ -93,30 +198,28 @@ const extractClaimName = path => {
93
198
  * - Validates whether required fields are present (unless marked optional)
94
199
  * and match any specified JSONPath.
95
200
  * - If a field includes a JSON Schema filter, validates the claim value against that schema.
96
- * - Enforces `limit_disclosure` rules by returning only disclosures, required and optional, matching the specified fields
97
- * if set to "required". Otherwise also return the array unrequestedDisclosures with disclosures which can be passed for a particular use case.
98
201
  * - Throws an error if a required field is invalid or missing.
99
202
  *
100
203
  * @param inputDescriptor - Describes constraints (fields, filters, etc.) that must be satisfied.
101
204
  * @param payloadCredential - The credential payload to check against.
102
205
  * @param disclosures - An array of DisclosureWithEncoded objects representing selective disclosures.
103
- * @returns A filtered list of disclosures satisfying the descriptor constraints, or throws an error if not.
206
+ * @returns An object with two arrays: one for required disclosures and one for optional disclosures.
104
207
  * @throws Will throw an error if any required constraint fails or if JSONPath lookups are invalid.
105
208
  */
209
+ exports.evaluateInputDescriptorForMdoc = evaluateInputDescriptorForMdoc;
106
210
  const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential, disclosures) => {
107
- var _inputDescriptor$cons;
108
- if (!(inputDescriptor !== null && inputDescriptor !== void 0 && (_inputDescriptor$cons = inputDescriptor.constraints) !== null && _inputDescriptor$cons !== void 0 && _inputDescriptor$cons.fields)) {
211
+ var _inputDescriptor$cons2;
212
+ if (!(inputDescriptor !== null && inputDescriptor !== void 0 && (_inputDescriptor$cons2 = inputDescriptor.constraints) !== null && _inputDescriptor$cons2 !== void 0 && _inputDescriptor$cons2.fields)) {
109
213
  // No validation, all field are optional
110
214
  return {
111
215
  requiredDisclosures: [],
112
- optionalDisclosures: [],
113
- unrequestedDisclosures: disclosures
216
+ optionalDisclosures: []
114
217
  };
115
218
  }
116
- const requiredClaimNames = [];
117
- const optionalClaimNames = [];
219
+ const requiredDisclosures = [];
220
+ const optionalDisclosures = [];
118
221
 
119
- // Transform disclosures to find claim using JSONPath
222
+ // Transform disclosures into an object for easier lookup of claim values.
120
223
  const disclosuresAsPayload = mapDisclosuresToObject(disclosures);
121
224
 
122
225
  // For each field, we need at least one matching path
@@ -136,7 +239,10 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
136
239
  // if match a disclouse we save which is required or optional
137
240
  const claimName = extractClaimName(matchedPath);
138
241
  if (claimName) {
139
- (field !== null && field !== void 0 && field.optional ? optionalClaimNames : requiredClaimNames).push(claimName);
242
+ (field !== null && field !== void 0 && field.optional ? optionalDisclosures : requiredDisclosures).push({
243
+ value: matchedValue,
244
+ name: claimName
245
+ });
140
246
  }
141
247
  }
142
248
 
@@ -160,26 +266,19 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
160
266
  if (!allFieldsValid) {
161
267
  throw new _errors.MissingDataError("Credential validation failed: Required fields are missing or do not match the input descriptor.");
162
268
  }
163
-
164
- // Categorizes disclosures into required and optional based on claim names and disclosure constraints.
165
-
166
- const requiredDisclosures = disclosures.filter(disclosure => requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
167
- const optionalDisclosures = disclosures.filter(disclosure => optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
168
- const isNotLimitDisclosure = !(inputDescriptor.constraints.limit_disclosure === "required");
169
- const unrequestedDisclosures = isNotLimitDisclosure ? disclosures.filter(disclosure => !optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]) && !requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])) : [];
170
269
  return {
171
270
  requiredDisclosures,
172
- optionalDisclosures,
173
- unrequestedDisclosures
271
+ optionalDisclosures
174
272
  };
175
273
  };
176
- exports.evaluateInputDescriptorForSdJwt4VC = evaluateInputDescriptorForSdJwt4VC;
274
+
177
275
  /**
178
276
  * Finds the first credential that satisfies the input descriptor constraints.
179
277
  * @param inputDescriptor The input descriptor to evaluate.
180
278
  * @param decodedSdJwtCredentials An array of decoded SD-JWT credentials.
181
279
  * @returns An object containing the matched evaluation, keyTag, and credential.
182
280
  */
281
+ exports.evaluateInputDescriptorForSdJwt4VC = evaluateInputDescriptorForSdJwt4VC;
183
282
  const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) => {
184
283
  for (const {
185
284
  keyTag,
@@ -202,6 +301,34 @@ const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) => {
202
301
  throw new _errors.CredentialNotFoundError("None of the vc+sd-jwt credentials satisfy the requirements.");
203
302
  };
204
303
 
304
+ /**
305
+ * Finds the first credential that satisfies the input descriptor constraints.
306
+ * @param inputDescriptor The input descriptor to evaluate.
307
+ * @param decodedMdocCredentials An array of decoded MDOC credentials.
308
+ * @returns An object containing the matched evaluation, keyTag, and credential.
309
+ */
310
+ exports.findCredentialSdJwt = findCredentialSdJwt;
311
+ const findCredentialMDoc = (inputDescriptor, decodedMDocCredentials) => {
312
+ for (const {
313
+ keyTag,
314
+ credential,
315
+ issuerSigned
316
+ } of decodedMDocCredentials) {
317
+ try {
318
+ const evaluatedDisclosure = evaluateInputDescriptorForMdoc(inputDescriptor, issuerSigned);
319
+ return {
320
+ matchedEvaluation: evaluatedDisclosure,
321
+ matchedKeyTag: keyTag,
322
+ matchedCredential: credential
323
+ };
324
+ } catch {
325
+ // skip to next credential
326
+ continue;
327
+ }
328
+ }
329
+ throw new _errors.CredentialNotFoundError("None of the mso_mdoc credentials satisfy the requirements.");
330
+ };
331
+
205
332
  /**
206
333
  * Evaluates multiple input descriptors against provided SD-JWT and MDOC credentials.
207
334
  *
@@ -217,11 +344,11 @@ const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) => {
217
344
  * the input descriptor, the credential, and the keyTag.
218
345
  * @throws {CredentialNotFoundError} When the credential format is unsupported.
219
346
  */
220
- exports.findCredentialSdJwt = findCredentialSdJwt;
347
+ exports.findCredentialMDoc = findCredentialMDoc;
221
348
  const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt, credentialsMdoc) => {
222
349
  // We need decode SD-JWT credentials for evaluation
223
- const decodedSdJwtCredentials = (credentialsSdJwt === null || credentialsSdJwt === void 0 ? void 0 : credentialsSdJwt.map(_ref2 => {
224
- let [keyTag, credential] = _ref2;
350
+ const decodedSdJwtCredentials = (credentialsSdJwt === null || credentialsSdJwt === void 0 ? void 0 : credentialsSdJwt.map(_ref3 => {
351
+ let [keyTag, credential] = _ref3;
225
352
  const {
226
353
  sdJwt,
227
354
  disclosures
@@ -233,38 +360,36 @@ const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt, cred
233
360
  disclosures
234
361
  };
235
362
  })) || [];
363
+
364
+ // We need decode Mdoc credentials for evaluation
365
+ const decodedMdocCredentials = (await Promise.all(credentialsMdoc === null || credentialsMdoc === void 0 ? void 0 : credentialsMdoc.map(async _ref4 => {
366
+ let [keyTag, credential] = _ref4;
367
+ const issuerSigned = await _ioReactNativeCbor.CBOR.decodeIssuerSigned(credential);
368
+ if (!issuerSigned) {
369
+ throw new _errors.CredentialNotFoundError("mso_mdoc credential is not present.");
370
+ }
371
+ return {
372
+ keyTag,
373
+ credential,
374
+ issuerSigned
375
+ };
376
+ }))) || [];
236
377
  const results = Promise.all(inputDescriptors.map(async descriptor => {
237
378
  var _descriptor$format, _descriptor$format2;
238
379
  if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format.mso_mdoc) {
239
- if (!credentialsMdoc || !credentialsMdoc[0]) {
380
+ if (!credentialsMdoc.length) {
240
381
  throw new _errors.CredentialNotFoundError("mso_mdoc credential is not supported.");
241
382
  }
242
- /**
243
- * The current implementation for the "mso_mdoc" format is temporary and always returns the first credential (mDL).
244
- * [WLEO-266] This will be replaced with the real implementation once the evaluateInputDescriptorForMdoc function is available.
245
- **/
246
- const [keyTag, credential] = credentialsMdoc[0];
247
- const mdoc = await _ioReactNativeCbor.CBOR.decodeDocuments(credential);
248
- if (!mdoc || !mdoc.documents || !mdoc.documents[0]) {
249
- throw new _errors.CredentialNotFoundError("mso_mdoc credential is not present.");
250
- }
251
- const document = mdoc.documents[0];
252
- // We set requiredDisclosures to all the elements in the document, as we don't have a real implementation for this yet.
383
+ const {
384
+ matchedEvaluation,
385
+ matchedKeyTag,
386
+ matchedCredential
387
+ } = findCredentialMDoc(descriptor, decodedMdocCredentials);
253
388
  return {
254
- evaluatedDisclosure: {
255
- requiredDisclosures: Object.entries(document.issuerSigned.nameSpaces).flatMap(_ref3 => {
256
- let [, elements] = _ref3;
257
- return elements.map(element => ({
258
- encoded: "",
259
- decoded: ["", element.elementIdentifier, element.elementValue]
260
- }));
261
- }),
262
- optionalDisclosures: [],
263
- unrequestedDisclosures: []
264
- },
389
+ evaluatedDisclosure: matchedEvaluation,
265
390
  inputDescriptor: descriptor,
266
- credential,
267
- keyTag
391
+ credential: matchedCredential,
392
+ keyTag: matchedKeyTag
268
393
  };
269
394
  }
270
395
  if ((_descriptor$format2 = descriptor.format) !== null && _descriptor$format2 !== void 0 && _descriptor$format2["vc+sd-jwt"]) {
@@ -303,22 +428,27 @@ const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt, cred
303
428
  * @throws {CredentialNotFoundError} When the credential format is unsupported.
304
429
  */
305
430
  exports.evaluateInputDescriptors = evaluateInputDescriptors;
306
- const prepareRemotePresentations = async (credentialAndDescriptors, nonce, client_id) => {
307
- return Promise.all(credentialAndDescriptors.map(async item => {
431
+ const prepareRemotePresentations = async (credentialAndDescriptors, authRequestObject) => {
432
+ /* In case of ISO 18013-7 we need a nonce, it shall have a minimum entropy of 16 */
433
+ const generatedNonce = (0, _misc.generateRandomAlphaNumericString)(16);
434
+ const presentations = await Promise.all(credentialAndDescriptors.map(async item => {
308
435
  var _descriptor$format3, _descriptor$format4;
309
436
  const descriptor = item.inputDescriptor;
310
437
  if ((_descriptor$format3 = descriptor.format) !== null && _descriptor$format3 !== void 0 && _descriptor$format3.mso_mdoc) {
438
+ const {
439
+ vp_token
440
+ } = await (0, _mdoc.prepareVpTokenMdoc)(authRequestObject.nonce, generatedNonce, authRequestObject.clientId, authRequestObject.responseUri, descriptor.id, item.keyTag, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
311
441
  return {
312
442
  requestedClaims: item.requestedClaims,
313
443
  inputDescriptor: descriptor,
314
- vpToken: (0, _string.base64ToBase64Url)(item.credential),
444
+ vpToken: vp_token,
315
445
  format: "mso_mdoc"
316
446
  };
317
447
  }
318
448
  if ((_descriptor$format4 = descriptor.format) !== null && _descriptor$format4 !== void 0 && _descriptor$format4["vc+sd-jwt"]) {
319
449
  const {
320
450
  vp_token
321
- } = await (0, _sdJwt.prepareVpToken)(nonce, client_id, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
451
+ } = await (0, _sdJwt.prepareVpToken)(authRequestObject.nonce, authRequestObject.clientId, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
322
452
  return {
323
453
  requestedClaims: item.requestedClaims,
324
454
  inputDescriptor: descriptor,
@@ -328,6 +458,10 @@ const prepareRemotePresentations = async (credentialAndDescriptors, nonce, clien
328
458
  }
329
459
  throw new _errors.CredentialNotFoundError(`${descriptor.format} format is not supported.`);
330
460
  }));
461
+ return {
462
+ presentations,
463
+ generatedNonce
464
+ };
331
465
  };
332
466
  exports.prepareRemotePresentations = prepareRemotePresentations;
333
467
  //# sourceMappingURL=07-evaluate-input-descriptor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_sdJwt","require","_crypto","_jsonpathPlus","_errors","_ajv","_interopRequireDefault","_string","_ioReactNativeCbor","obj","__esModule","default","ajv","Ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","extractClaimName","regex","match","Error","evaluateInputDescriptorForSdJwt4VC","inputDescriptor","payloadCredential","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","unrequestedDisclosures","requiredClaimNames","optionalClaimNames","disclosuresAsPayload","allFieldsValid","every","field","optional","push","filter","validateSchema","compile","disclosure","includes","isNotLimitDisclosure","limit_disclosure","exports","findCredentialSdJwt","decodedSdJwtCredentials","keyTag","credential","sdJwt","evaluatedDisclosure","matchedEvaluation","matchedKeyTag","matchedCredential","CredentialNotFoundError","evaluateInputDescriptors","inputDescriptors","credentialsSdJwt","credentialsMdoc","map","_ref2","decode","results","Promise","all","descriptor","_descriptor$format","_descriptor$format2","format","mso_mdoc","mdoc","CBOR","decodeDocuments","documents","document","Object","entries","issuerSigned","nameSpaces","flatMap","_ref3","elements","element","encoded","elementIdentifier","elementValue","prepareRemotePresentations","credentialAndDescriptors","nonce","client_id","item","_descriptor$format3","_descriptor$format4","requestedClaims","vpToken","base64ToBase64Url","vp_token","prepareVpToken","createCryptoContextFor"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAAoD,SAAAK,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AACpD,MAAMG,GAAG,GAAG,IAAIC,YAAG,CAAC;EAAEC,SAAS,EAAE;AAAK,CAAC,CAAC;AACxC,MAAMC,gBAAgB,GAAG,CAAC;AAsC1B;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAC1BC,WAAoC,IACR;EAC5B,OAAOA,WAAW,CAACC,MAAM,CAAC,CAACT,GA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AAA,CAAoB,WAAW,CAAC,EAAE;MACpC,MAAM;QAAEI;MAAS,CAAC,GAAG,MAAM,IAAAC,qBAAc,EAACT,KAAK,EAAEC,SAAS,EAAE,CAC1DC,IAAI,CAAC1C,UAAU,EACf0C,IAAI,CAACG,eAAe,EACpB,IAAAK,8BAAsB,EAACR,IAAI,CAAC3C,MAAM,CAAC,CACpC,CAAC;MAEF,OAAO;QACL8C,eAAe,EAAEH,IAAI,CAACG,eAAe;QACrCxE,eAAe,EAAE4C,UAAU;QAC3B6B,OAAO,EAAEE,QAAQ;QACjB5B,MAAM,EAAE;MACV,CAAC;IACH;IAEA,MAAM,IAAId,+BAAuB,CAC9B,GAAEW,UAAU,CAACG,MAAO,2BACvB,CAAC;EACH,CAAC,CACH,CAAC;AACH,CAAC;AAACxB,OAAA,CAAA0C,0BAAA,GAAAA,0BAAA"}
1
+ {"version":3,"names":["_sdJwt","require","_crypto","_jsonpathPlus","_errors","_ajv","_interopRequireDefault","_ioReactNativeCbor","_mdoc","_misc","obj","__esModule","default","ajv","Ajv","allErrors","disclosureWithEncodedToEvaluatedDisclosure","disclosure","claimName","claimValue","decoded","name","value","exports","mapDisclosuresToObject","disclosures","reduce","_ref","mapNamespacesToObject","namespaces","Object","entries","_ref2","namespace","elements","fromEntries","map","element","elementIdentifier","elementValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","extractClaimName","regex","match","Error","extractNamespaceAndClaimName","nameSpace","propertyName","evaluateInputDescriptorForMdoc","inputDescriptor","issuerSigned","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","namespacesAsPayload","nameSpaces","allFieldsValid","every","field","undefined","optional","push","filter","validateSchema","compile","evaluateInputDescriptorForSdJwt4VC","payloadCredential","_inputDescriptor$cons2","disclosuresAsPayload","findCredentialSdJwt","decodedSdJwtCredentials","keyTag","credential","sdJwt","evaluatedDisclosure","matchedEvaluation","matchedKeyTag","matchedCredential","CredentialNotFoundError","findCredentialMDoc","decodedMDocCredentials","evaluateInputDescriptors","inputDescriptors","credentialsSdJwt","credentialsMdoc","_ref3","decode","decodedMdocCredentials","Promise","all","_ref4","CBOR","decodeIssuerSigned","results","descriptor","_descriptor$format","_descriptor$format2","format","mso_mdoc","prepareRemotePresentations","credentialAndDescriptors","authRequestObject","generatedNonce","generateRandomAlphaNumericString","presentations","item","_descriptor$format3","_descriptor$format4","vp_token","prepareVpTokenMdoc","nonce","clientId","responseUri","id","requestedClaims","createCryptoContextFor","vpToken","prepareVpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAAoE,SAAAK,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEpE,MAAMG,GAAG,GAAG,IAAIC,YAAG,CAAC;EAAEC,SAAS,EAAE;AAAK,CAAC,CAAC;AAmDjC,MAAMC,0CAA0C,GACrDC,UAAiC,IACT;EACxB,MAAM,GAAGC,SAAS,EAAEC,UAAU,CAAC,GAAGF,UAAU,CAACG,OAAO;EACpD,OAAO;IACLC,IAAI,EAAEH,SAAS;IACfI,KAAK,EAAEH;EACT,CAAC;AACH,CAAC;AAACI,OAAA,CAAAP,0CAAA,GAAAA,0CAAA;AAeF;AACA;AACA;AACA;AACA;AACA,MAAMQ,sBAAsB,GAC1BC,WAAoC,IACR;EAC5B,OAAOA,WAAW,CAACC,MAAM,CACvB,CAAChB,GAAG,EAAAiB,IAA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