From 592ec4b837898eb3022d19479d79b6065e7a0d9e Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Fri, 29 Sep 2023 00:30:27 +0200 Subject: [PATCH] fix: id lookup against server metadata not working --- packages/client/lib/OpenID4VCIClient.ts | 8 ++++++-- .../common/lib/functions/IssuerMetadataUtils.ts | 15 +++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index 83dc0681..592d2dfd 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -365,6 +365,10 @@ export class OpenID4VCIClient { return response.successBody; } + // FIXME: We really should convert 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; const credentialSupportedOverlap: CredentialSupported[] = []; - if (opts?.types && typeof opts?.types === 'string') { + if ((opts?.types && typeof opts?.types === 'string') || opts?.types?.length === 1) { + const types = Array.isArray(opts.types) ? opts.types[0] : opts.types; const supported = credentialsSupported.filter( - (sup) => sup.id === opts.types || (initiationTypes && arrayEqualsIgnoreOrder(sup.types, initiationTypes)), + (sup) => sup.id === types || (initiationTypes && arrayEqualsIgnoreOrder(sup.types, initiationTypes)), ); if (supported) { credentialSupportedOverlap.push(...supported); } - } /*else if (initiationTypes && Array.isArray(initiationTypes) && initiationTypes.length === 1) { + } - const supported = credentialsSupported.filter( - (sup) => sup.id === initiationTypes![0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes!) && sup.types.includes(initiationTypes![0])), - ); - if (supported) { - credentialSupportedOverlap.push(...supported); - } - }*/ else { + if (credentialSupportedOverlap.length === 0) { // Make sure we include Verifiable Credential both on the offer side as well as in the metadata side, to ensure consistency of the issuer does not. if (initiationTypes && !initiationTypes.includes('VerifiableCredential')) { initiationTypes.push('VerifiableCredential');