@pagopa/io-react-native-wallet 1.4.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 (85) hide show
  1. package/lib/commonjs/credential/issuance/06-obtain-credential.js +1 -5
  2. package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
  3. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +33 -21
  4. package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  5. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +318 -24
  6. package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  7. package/lib/commonjs/credential/presentation/08-send-authorization-response.js +47 -83
  8. package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
  9. package/lib/commonjs/credential/presentation/errors.js +18 -1
  10. package/lib/commonjs/credential/presentation/errors.js.map +1 -1
  11. package/lib/commonjs/credential/presentation/index.js +8 -2
  12. package/lib/commonjs/credential/presentation/index.js.map +1 -1
  13. package/lib/commonjs/credential/presentation/types.js +6 -2
  14. package/lib/commonjs/credential/presentation/types.js.map +1 -1
  15. package/lib/commonjs/entity/trust/chain.js.map +1 -1
  16. package/lib/commonjs/mdoc/index.js +45 -13
  17. package/lib/commonjs/mdoc/index.js.map +1 -1
  18. package/lib/commonjs/sd-jwt/index.js +41 -1
  19. package/lib/commonjs/sd-jwt/index.js.map +1 -1
  20. package/lib/commonjs/utils/crypto.js +70 -4
  21. package/lib/commonjs/utils/crypto.js.map +1 -1
  22. package/lib/commonjs/utils/string.js +6 -7
  23. package/lib/commonjs/utils/string.js.map +1 -1
  24. package/lib/module/credential/issuance/06-obtain-credential.js +1 -5
  25. package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
  26. package/lib/module/credential/issuance/07-verify-and-parse-credential.js +33 -21
  27. package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
  28. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +311 -23
  29. package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
  30. package/lib/module/credential/presentation/08-send-authorization-response.js +46 -81
  31. package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
  32. package/lib/module/credential/presentation/errors.js +16 -0
  33. package/lib/module/credential/presentation/errors.js.map +1 -1
  34. package/lib/module/credential/presentation/index.js +2 -2
  35. package/lib/module/credential/presentation/index.js.map +1 -1
  36. package/lib/module/credential/presentation/types.js +6 -2
  37. package/lib/module/credential/presentation/types.js.map +1 -1
  38. package/lib/module/entity/trust/chain.js.map +1 -1
  39. package/lib/module/mdoc/index.js +43 -12
  40. package/lib/module/mdoc/index.js.map +1 -1
  41. package/lib/module/sd-jwt/index.js +40 -1
  42. package/lib/module/sd-jwt/index.js.map +1 -1
  43. package/lib/module/utils/crypto.js +67 -2
  44. package/lib/module/utils/crypto.js.map +1 -1
  45. package/lib/module/utils/string.js +4 -6
  46. package/lib/module/utils/string.js.map +1 -1
  47. package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
  48. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +1 -1
  49. package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
  50. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +106 -9
  51. package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
  52. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +4 -33
  53. package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
  54. package/lib/typescript/credential/presentation/errors.d.ts +11 -0
  55. package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
  56. package/lib/typescript/credential/presentation/index.d.ts +3 -3
  57. package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
  58. package/lib/typescript/credential/presentation/types.d.ts +18 -6
  59. package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
  60. package/lib/typescript/entity/trust/chain.d.ts.map +1 -1
  61. package/lib/typescript/mdoc/index.d.ts +6 -2
  62. package/lib/typescript/mdoc/index.d.ts.map +1 -1
  63. package/lib/typescript/sd-jwt/index.d.ts +19 -0
  64. package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
  65. package/lib/typescript/utils/crypto.d.ts +8 -0
  66. package/lib/typescript/utils/crypto.d.ts.map +1 -1
  67. package/lib/typescript/utils/errors.d.ts.map +1 -1
  68. package/lib/typescript/utils/misc.d.ts.map +1 -1
  69. package/lib/typescript/utils/string.d.ts +3 -3
  70. package/lib/typescript/utils/string.d.ts.map +1 -1
  71. package/package.json +16 -14
  72. package/src/credential/issuance/06-obtain-credential.ts +1 -7
  73. package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -16
  74. package/src/credential/presentation/07-evaluate-input-descriptor.ts +459 -49
  75. package/src/credential/presentation/08-send-authorization-response.ts +57 -101
  76. package/src/credential/presentation/errors.ts +16 -0
  77. package/src/credential/presentation/index.ts +8 -4
  78. package/src/credential/presentation/types.ts +16 -3
  79. package/src/entity/trust/chain.ts +14 -10
  80. package/src/mdoc/index.ts +72 -15
  81. package/src/sd-jwt/index.ts +49 -1
  82. package/src/utils/crypto.ts +61 -2
  83. package/src/utils/errors.ts +2 -2
  84. package/src/utils/misc.ts +2 -2
  85. package/src/utils/string.ts +4 -6
@@ -10,7 +10,6 @@ var _errors = require("../../utils/errors");
10
10
  var _types = require("./types");
11
11
  var _dpop = require("../../utils/dpop");
12
12
  var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
13
- var _string = require("../../utils/string");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  const createNonceProof = async (nonce, issuer, audience, ctx) => {
16
15
  const jwk = await ctx.getPublicKey();
@@ -104,10 +103,7 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
104
103
  }
105
104
 
106
105
  /* temporary base64 parsing for the "mso_mdoc" format until the credential submission with this format is fixed. */
107
- return format === "mso_mdoc" ? {
108
- ...credentialRes.data,
109
- credential: (0, _string.byteStringToBase64Url)(credentialRes.data.credential)
110
- } : credentialRes.data;
106
+ return credentialRes.data;
111
107
  };
112
108
 
113
109
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_reactNativeUuid","_interopRequireDefault","_string","obj","__esModule","default","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","detail","credential_configuration_id","type","ValidationFailed","message","credential","credential_configurations_supported","format","credentialRequestFormBody","vct","proof","jwt","proof_type","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","hasStatusOrThrow","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","reason","error","data","byteStringToBase64Url","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAA2D,SAAAM,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA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,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAEH,IAAI,IAAKO,yBAAkB,CAACC,SAAS,CAACR,IAAI,CAAC,CAAC,CAClDS,KAAK,CAACC,2BAA2B,CAAC;EAErC,IAAI,CAAChB,aAAa,CAACiB,OAAO,EAAE;IAC1B,MAAM,IAAIrC,wBAAgB,CAAC;MACzBC,OAAO,EAAE,uCAAuC;MAChDqC,MAAM,EAAElB,aAAa,CAACmB,KAAK,CAACtC;IAC9B,CAAC,CAAC;EACJ;;EAEA;EACA,OAAOG,MAAM,KAAK,UAAU,GACxB;IACE,GAAGgB,aAAa,CAACoB,IAAI;IACrBtC,UAAU,EAAE,IAAAuC,6BAAqB,EAACrB,aAAa,CAACoB,IAAI,CAACtC,UAAU;EACjE,CAAC,GACDkB,aAAa,CAACoB,IAAI;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA7D,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAMA,MAAMwD,2BAA2B,GAAIM,CAAU,IAAK;EAClD,IAAI,EAAEA,CAAC,YAAYC,iCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;EAEA,MAAM,IAAIE,4BAAoB,CAACC,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACC,uBAAuB;IACtDhD,OAAO,EAAE;EACX,CAAC,CAAC,CACDiD,SAAS,CAACR,CAAC,CAAC;AACjB,CAAC"}
1
+ {"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_reactNativeUuid","_interopRequireDefault","obj","__esModule","default","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","detail","credential_configuration_id","type","ValidationFailed","message","credential","credential_configurations_supported","format","credentialRequestFormBody","vct","proof","jwt","proof_type","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuid","v4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","hasStatusOrThrow","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","reason","error","data","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAqC,SAAAM,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAc9B,MAAMG,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIC,yBAAO,CAACH,GAAG,CAAC,CACpBI,UAAU,CAAC;IACVP;EACF,CAAC,CAAC,CACDQ,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC3BL;EACF,CAAC,CAAC,CACDM,WAAW,CAACR,QAAQ,CAAC,CACrBS,SAAS,CAACV,MAAM,CAAC,CACjBW,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,MAAM,CAAC,CACzBC,IAAI,CAAC,CAAC;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AA;AAMA,MAAMwD,2BAA2B,GAAIK,CAAU,IAAK;EAClD,IAAI,EAAEA,CAAC,YAAYC,iCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;EAEA,MAAM,IAAIE,4BAAoB,CAACC,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACC,uBAAuB;IACtD/C,OAAO,EAAE;EACX,CAAC,CAAC,CACDgD,SAAS,CAACR,CAAC,CAAC;AACjB,CAAC"}
@@ -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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,CAACb,aAAa,CAACc,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EAEnD,OAAO;IACLhB,gBAAgB;IAChBI,UAAU,EAAEQ,cAAc,IAAI,IAAIP,IAAI,CAAC,CAAC;IACxCE,QAAQ,EAAEL,aAAa,IAAI7F;EAC7B,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM6G,wBAAkD,GAAG,MAAAA,CAChEvB,UAAU,EACVC,UAAU,EACVjF,MAAM,EACNwG,OAAO,KACJ;EACH,IAAIxG,MAAM,KAAK,WAAW,EAAE;IAC1B,OAAO+E,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVjF,MAAM,EACNwG,OACF,CAAC;EACH;EACA,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,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,IAAAK,YAAA,GAAAL,OAAA;AAwBA;;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,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G,wBAAkD,GAAG,MAAAA,CAChEzB,UAAU,EACVC,UAAU,EACVhF,MAAM,EACN8F,cAAc,EACdW,OAAO,KACJ;EACH,IAAIzG,MAAM,KAAK,WAAW,EAAE;IAC1B,OAAO8E,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVhF,MAAM,EACN8F,cAAc,EACdW,OACF,CAAC;EACH;EACA,IAAIzG,MAAM,KAAK,UAAU,EAAE;IACzB,OAAO6F,4BAA4B,CACjCd,UAAU,EACVC,UAAU,EACVhF,MAAM,EACN8F,cAAc,EACdW,OACF,CAAC;EACH;EAEA,MAAM,IAAI1G,qBAAa,CAAE,kCAAiCC,MAAO,EAAC,CAAC;AACrE,CAAC;AAAC0G,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
@@ -3,15 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.evaluateInputDescriptorForSdJwt4VC = void 0;
6
+ exports.prepareRemotePresentations = exports.findCredentialSdJwt = exports.findCredentialMDoc = exports.evaluateInputDescriptors = exports.evaluateInputDescriptorForSdJwt4VC = exports.evaluateInputDescriptorForMdoc = exports.disclosureWithEncodedToEvaluatedDisclosure = void 0;
7
+ var _sdJwt = require("../../sd-jwt");
8
+ var _crypto = require("../../utils/crypto");
7
9
  var _jsonpathPlus = require("jsonpath-plus");
8
10
  var _errors = require("./errors");
9
11
  var _ajv = _interopRequireDefault(require("ajv"));
12
+ var _ioReactNativeCbor = require("@pagopa/io-react-native-cbor");
13
+ var _mdoc = require("../../mdoc");
14
+ var _misc = require("../../utils/misc");
10
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
16
  const ajv = new _ajv.default({
12
17
  allErrors: true
13
18
  });
14
- 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;
15
27
  /**
16
28
  * Transforms an array of DisclosureWithEncoded objects into a key-value map.
17
29
  * @param disclosures - An array of DisclosureWithEncoded, each containing a decoded property with [?, claimName, claimValue].
@@ -28,6 +40,22 @@ const mapDisclosuresToObject = disclosures => {
28
40
  }, {});
29
41
  };
30
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
+
31
59
  /**
32
60
  * Finds a claim within the payload based on provided JSONPath expressions.
33
61
  * @param paths - An array of JSONPath expressions to search for in the payload.
@@ -75,10 +103,91 @@ const extractClaimName = path => {
75
103
  // match[2] corresponds to the second capture group (\w+) inside [""] or ['']
76
104
  return match[1] || match[2];
77
105
  }
106
+ throw new Error(`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`);
107
+ };
108
+
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 = [];
78
149
 
79
- // If the input doesn't match any of the expected formats, return null
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);
80
154
 
81
- throw new Error(`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`);
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
+ };
82
191
  };
83
192
 
84
193
  /**
@@ -89,30 +198,28 @@ const extractClaimName = path => {
89
198
  * - Validates whether required fields are present (unless marked optional)
90
199
  * and match any specified JSONPath.
91
200
  * - If a field includes a JSON Schema filter, validates the claim value against that schema.
92
- * - Enforces `limit_disclosure` rules by returning only disclosures, required and optional, matching the specified fields
93
- * if set to "required". Otherwise also return the array unrequestedDisclosures with disclosures which can be passed for a particular use case.
94
201
  * - Throws an error if a required field is invalid or missing.
95
202
  *
96
203
  * @param inputDescriptor - Describes constraints (fields, filters, etc.) that must be satisfied.
97
204
  * @param payloadCredential - The credential payload to check against.
98
205
  * @param disclosures - An array of DisclosureWithEncoded objects representing selective disclosures.
99
- * @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.
100
207
  * @throws Will throw an error if any required constraint fails or if JSONPath lookups are invalid.
101
208
  */
209
+ exports.evaluateInputDescriptorForMdoc = evaluateInputDescriptorForMdoc;
102
210
  const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential, disclosures) => {
103
- var _inputDescriptor$cons;
104
- 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)) {
105
213
  // No validation, all field are optional
106
214
  return {
107
215
  requiredDisclosures: [],
108
- optionalDisclosures: [],
109
- unrequestedDisclosures: disclosures
216
+ optionalDisclosures: []
110
217
  };
111
218
  }
112
- const requiredClaimNames = [];
113
- const optionalClaimNames = [];
219
+ const requiredDisclosures = [];
220
+ const optionalDisclosures = [];
114
221
 
115
- // Transform disclosures to find claim using JSONPath
222
+ // Transform disclosures into an object for easier lookup of claim values.
116
223
  const disclosuresAsPayload = mapDisclosuresToObject(disclosures);
117
224
 
118
225
  // For each field, we need at least one matching path
@@ -132,7 +239,10 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
132
239
  // if match a disclouse we save which is required or optional
133
240
  const claimName = extractClaimName(matchedPath);
134
241
  if (claimName) {
135
- (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
+ });
136
246
  }
137
247
  }
138
248
 
@@ -156,18 +266,202 @@ const evaluateInputDescriptorForSdJwt4VC = (inputDescriptor, payloadCredential,
156
266
  if (!allFieldsValid) {
157
267
  throw new _errors.MissingDataError("Credential validation failed: Required fields are missing or do not match the input descriptor.");
158
268
  }
159
-
160
- // Categorizes disclosures into required and optional based on claim names and disclosure constraints.
161
-
162
- const requiredDisclosures = disclosures.filter(disclosure => requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
163
- const optionalDisclosures = disclosures.filter(disclosure => optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]));
164
- const isNotLimitDisclosure = !(inputDescriptor.constraints.limit_disclosure === "required");
165
- const unrequestedDisclosures = isNotLimitDisclosure ? disclosures.filter(disclosure => !optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME]) && !requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])) : [];
166
269
  return {
167
270
  requiredDisclosures,
168
- optionalDisclosures,
169
- unrequestedDisclosures
271
+ optionalDisclosures
170
272
  };
171
273
  };
274
+
275
+ /**
276
+ * Finds the first credential that satisfies the input descriptor constraints.
277
+ * @param inputDescriptor The input descriptor to evaluate.
278
+ * @param decodedSdJwtCredentials An array of decoded SD-JWT credentials.
279
+ * @returns An object containing the matched evaluation, keyTag, and credential.
280
+ */
172
281
  exports.evaluateInputDescriptorForSdJwt4VC = evaluateInputDescriptorForSdJwt4VC;
282
+ const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) => {
283
+ for (const {
284
+ keyTag,
285
+ credential,
286
+ sdJwt,
287
+ disclosures
288
+ } of decodedSdJwtCredentials) {
289
+ try {
290
+ const evaluatedDisclosure = evaluateInputDescriptorForSdJwt4VC(inputDescriptor, sdJwt.payload, disclosures);
291
+ return {
292
+ matchedEvaluation: evaluatedDisclosure,
293
+ matchedKeyTag: keyTag,
294
+ matchedCredential: credential
295
+ };
296
+ } catch {
297
+ // skip to next credential
298
+ continue;
299
+ }
300
+ }
301
+ throw new _errors.CredentialNotFoundError("None of the vc+sd-jwt credentials satisfy the requirements.");
302
+ };
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
+
332
+ /**
333
+ * Evaluates multiple input descriptors against provided SD-JWT and MDOC credentials.
334
+ *
335
+ * For each input descriptor, this function:
336
+ * - Checks the credential format.
337
+ * - Decodes the credential.
338
+ * - Evaluates the descriptor using the associated disclosures.
339
+ *
340
+ * @param inputDescriptors - An array of input descriptors.
341
+ * @param credentialsSdJwt - An array of tuples containing keyTag and SD-JWT credential.
342
+ * @param credentialsMdoc - An array of tuples containing keyTag and MDOC credential.
343
+ * @returns An array of objects, each containing the evaluated disclosures,
344
+ * the input descriptor, the credential, and the keyTag.
345
+ * @throws {CredentialNotFoundError} When the credential format is unsupported.
346
+ */
347
+ exports.findCredentialMDoc = findCredentialMDoc;
348
+ const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt, credentialsMdoc) => {
349
+ // We need decode SD-JWT credentials for evaluation
350
+ const decodedSdJwtCredentials = (credentialsSdJwt === null || credentialsSdJwt === void 0 ? void 0 : credentialsSdJwt.map(_ref3 => {
351
+ let [keyTag, credential] = _ref3;
352
+ const {
353
+ sdJwt,
354
+ disclosures
355
+ } = (0, _sdJwt.decode)(credential);
356
+ return {
357
+ keyTag,
358
+ credential,
359
+ sdJwt,
360
+ disclosures
361
+ };
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
+ }))) || [];
377
+ const results = Promise.all(inputDescriptors.map(async descriptor => {
378
+ var _descriptor$format, _descriptor$format2;
379
+ if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format.mso_mdoc) {
380
+ if (!credentialsMdoc.length) {
381
+ throw new _errors.CredentialNotFoundError("mso_mdoc credential is not supported.");
382
+ }
383
+ const {
384
+ matchedEvaluation,
385
+ matchedKeyTag,
386
+ matchedCredential
387
+ } = findCredentialMDoc(descriptor, decodedMdocCredentials);
388
+ return {
389
+ evaluatedDisclosure: matchedEvaluation,
390
+ inputDescriptor: descriptor,
391
+ credential: matchedCredential,
392
+ keyTag: matchedKeyTag
393
+ };
394
+ }
395
+ if ((_descriptor$format2 = descriptor.format) !== null && _descriptor$format2 !== void 0 && _descriptor$format2["vc+sd-jwt"]) {
396
+ if (!decodedSdJwtCredentials.length) {
397
+ throw new _errors.CredentialNotFoundError("vc+sd-jwt credential is not supported.");
398
+ }
399
+ const {
400
+ matchedEvaluation,
401
+ matchedKeyTag,
402
+ matchedCredential
403
+ } = findCredentialSdJwt(descriptor, decodedSdJwtCredentials);
404
+ return {
405
+ evaluatedDisclosure: matchedEvaluation,
406
+ inputDescriptor: descriptor,
407
+ credential: matchedCredential,
408
+ keyTag: matchedKeyTag
409
+ };
410
+ }
411
+ throw new _errors.CredentialNotFoundError(`${descriptor.format} format is not supported.`);
412
+ }));
413
+ return results;
414
+ };
415
+
416
+ /**
417
+ * Prepares remote presentations for a set of credentials based on input descriptors.
418
+ *
419
+ * For each credential and its corresponding input descriptor, this function:
420
+ * - Validates the credential format.
421
+ * - Generates a verifiable presentation token (vpToken) using the provided nonce and client identifier.
422
+ *
423
+ * @param credentialAndDescriptors - An array containing objects with requested claims,
424
+ * input descriptor, credential, and keyTag.
425
+ * @param nonce - A unique nonce for the verifiable presentation token.
426
+ * @param client_id - The client identifier.
427
+ * @returns A promise that resolves to an array of RemotePresentation objects.
428
+ * @throws {CredentialNotFoundError} When the credential format is unsupported.
429
+ */
430
+ exports.evaluateInputDescriptors = evaluateInputDescriptors;
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 => {
435
+ var _descriptor$format3, _descriptor$format4;
436
+ const descriptor = item.inputDescriptor;
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)]);
441
+ return {
442
+ requestedClaims: item.requestedClaims,
443
+ inputDescriptor: descriptor,
444
+ vpToken: vp_token,
445
+ format: "mso_mdoc"
446
+ };
447
+ }
448
+ if ((_descriptor$format4 = descriptor.format) !== null && _descriptor$format4 !== void 0 && _descriptor$format4["vc+sd-jwt"]) {
449
+ const {
450
+ vp_token
451
+ } = await (0, _sdJwt.prepareVpToken)(authRequestObject.nonce, authRequestObject.clientId, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
452
+ return {
453
+ requestedClaims: item.requestedClaims,
454
+ inputDescriptor: descriptor,
455
+ vpToken: vp_token,
456
+ format: "vc+sd-jwt"
457
+ };
458
+ }
459
+ throw new _errors.CredentialNotFoundError(`${descriptor.format} format is not supported.`);
460
+ }));
461
+ return {
462
+ presentations,
463
+ generatedNonce
464
+ };
465
+ };
466
+ exports.prepareRemotePresentations = prepareRemotePresentations;
173
467
  //# sourceMappingURL=07-evaluate-input-descriptor.js.map