@pagopa/io-react-native-wallet 1.5.0 → 1.6.1
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.
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +5 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +33 -21
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +192 -58
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +45 -18
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +1 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/entity/trust/chain.js.map +1 -1
- package/lib/commonjs/mdoc/index.js +45 -13
- package/lib/commonjs/mdoc/index.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +70 -4
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/string.js +4 -4
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +5 -1
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +33 -21
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +186 -55
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +45 -18
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/types.js +1 -1
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/entity/trust/chain.js.map +1 -1
- package/lib/module/mdoc/index.js +43 -12
- package/lib/module/mdoc/index.js.map +1 -1
- package/lib/module/utils/crypto.js +67 -2
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/string.js +4 -4
- package/lib/module/utils/string.js.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +49 -13
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +6 -2
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +10 -7
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/entity/trust/chain.d.ts.map +1 -1
- package/lib/typescript/mdoc/index.d.ts +6 -2
- package/lib/typescript/mdoc/index.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +8 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +3 -3
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/credential/issuance/06-obtain-credential.ts +3 -1
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -16
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +278 -97
- package/src/credential/presentation/08-send-authorization-response.ts +50 -27
- package/src/credential/presentation/types.ts +9 -6
- package/src/entity/trust/chain.ts +14 -10
- package/src/mdoc/index.ts +72 -15
- package/src/utils/crypto.ts +61 -2
- package/src/utils/errors.ts +2 -2
- package/src/utils/misc.ts +2 -2
- package/src/utils/string.ts +4 -4
@@ -73,7 +73,11 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
73
73
|
|
74
74
|
/** The credential request body */
|
75
75
|
const credentialRequestFormBody = {
|
76
|
-
|
76
|
+
...(format === "mso_mdoc" ? {
|
77
|
+
doctype: credentialDefinition.credential_configuration_id
|
78
|
+
} : {
|
79
|
+
vct: credentialDefinition.credential_configuration_id
|
80
|
+
}),
|
77
81
|
format,
|
78
82
|
proof: {
|
79
83
|
jwt: signedNonceProof,
|
@@ -1 +1 @@
|
|
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,G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,IACzC,CAAC;EAED,IAAI,CAACL,4BAA4B,EAAE;IACjC,MAAM,IAAIM,wBAAgB,CAAC;MACzBC,OAAO,EACL;IACJ,CAAC,CAAC;EACJ;EAEA,MAAMC,UAAU,GACdrB,UAAU,CAACsB,mCAAmC,CAC5CnB,oBAAoB,CAACc,2BAA2B,CACjD;EAEH,IAAI,CAACI,UAAU,EAAE;IACf,MAAM,IAAIF,wBAAgB,CAAC;MACzBC,OAAO,EAAE;IACX,CAAC,CAAC;EACJ;EAEA,MAAMG,MAAM,GAAGF,UAAU,CAACE,MAAM;EAEhC,IAAI,CAACA,MAAM,EAAE;IACX,MAAM,IAAIJ,wBAAgB,CAAC;MACzBC,OAAO,EACL;IACJ,CAAC,CAAC;EACJ;;EAEA;EACA,MAAMI,yBAAyB,GAAG;
|
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","doctype","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":";;;;;;A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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
|
-
|
108
|
+
issuerSigned
|
109
109
|
} = _ref8;
|
110
|
-
let includeUndefinedAttributes = arguments.length >
|
111
|
-
const credentialSubject = credentials_supported[
|
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 (!
|
129
|
+
if (!issuerSigned.nameSpaces) {
|
130
130
|
throw new _errors.IoWalletError("Missing claims in the credential");
|
131
131
|
}
|
132
|
-
const flatNamespaces = Object.entries(
|
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
|
-
|
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
|
-
|
248
|
-
|
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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Ea,OAAO,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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A;AACO,MAAM8G,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,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
|
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
|
-
|
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
|
-
|
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
|
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$
|
108
|
-
if (!(inputDescriptor !== null && inputDescriptor !== void 0 && (_inputDescriptor$
|
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
|
117
|
-
const
|
219
|
+
const requiredDisclosures = [];
|
220
|
+
const optionalDisclosures = [];
|
118
221
|
|
119
|
-
// Transform disclosures
|
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 ?
|
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
|
-
|
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.
|
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(
|
224
|
-
let [keyTag, credential] =
|
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
|
380
|
+
if (!credentialsMdoc.length) {
|
240
381
|
throw new _errors.CredentialNotFoundError("mso_mdoc credential is not supported.");
|
241
382
|
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
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,
|
307
|
-
|
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:
|
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,
|
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
|