Skip to content

Commit 71f97dc

Browse files
authored
Merge pull request #68 from Sphereon-Opensource/develop
New release
2 parents 6b555df + 49e290b commit 71f97dc

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

packages/client/lib/OpenID4VCIClient.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ export class OpenID4VCIClient {
365365
return response.successBody;
366366
}
367367

368+
// FIXME: We really should convert <v11 to v12 objects first. Right now the logic doesn't map nicely and is brittle.
369+
// We should resolve IDs to objects first in case of strings.
370+
// When < v11 convert into a v12 object. When v12 object retain it.
371+
// Then match the object array on server metadata
368372
getCredentialsSupported(
369373
restrictToInitiationTypes: boolean,
370374
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[],
@@ -373,11 +377,11 @@ export class OpenID4VCIClient {
373377
issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
374378
version: this.version(),
375379
format: format,
376-
types: restrictToInitiationTypes ? this.getCredentialTypes() : undefined,
380+
types: restrictToInitiationTypes ? this.getCredentialOfferTypes() : undefined,
377381
});
378382
}
379383

380-
getCredentialTypes(): string[][] {
384+
getCredentialOfferTypes(): string[][] {
381385
if (this.credentialOffer.version < OpenId4VCIVersion.VER_1_0_11) {
382386
const orig = this.credentialOffer.original_credential_offer as CredentialOfferPayloadV1_0_08;
383387
const types: string[] = typeof orig.credential_type === 'string' ? [orig.credential_type] : orig.credential_type;

packages/common/lib/functions/IssuerMetadataUtils.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,17 @@ export function getSupportedCredential(opts?: {
7070
const supportedFormats: (CredentialOfferFormat | string)[] = formats && formats.length > 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'];
7171

7272
const credentialSupportedOverlap: CredentialSupported[] = [];
73-
if (opts?.types && typeof opts?.types === 'string') {
73+
if ((opts?.types && typeof opts?.types === 'string') || opts?.types?.length === 1) {
74+
const types = Array.isArray(opts.types) ? opts.types[0] : opts.types;
7475
const supported = credentialsSupported.filter(
75-
(sup) => sup.id === opts.types || (initiationTypes && arrayEqualsIgnoreOrder(sup.types, initiationTypes)),
76+
(sup) => sup.id === types || (initiationTypes && arrayEqualsIgnoreOrder(sup.types, initiationTypes)),
7677
);
7778
if (supported) {
7879
credentialSupportedOverlap.push(...supported);
7980
}
80-
} /*else if (initiationTypes && Array.isArray(initiationTypes) && initiationTypes.length === 1) {
81+
}
8182

82-
const supported = credentialsSupported.filter(
83-
(sup) => sup.id === initiationTypes![0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes!) && sup.types.includes(initiationTypes![0])),
84-
);
85-
if (supported) {
86-
credentialSupportedOverlap.push(...supported);
87-
}
88-
}*/ else {
83+
if (credentialSupportedOverlap.length === 0) {
8984
// 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.
9085
if (initiationTypes && !initiationTypes.includes('VerifiableCredential')) {
9186
initiationTypes.push('VerifiableCredential');

0 commit comments

Comments
 (0)