Skip to content

Commit

Permalink
Merge pull request #68 from Sphereon-Opensource/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
nklomp authored Sep 28, 2023
2 parents 6b555df + 49e290b commit 71f97dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 6 additions & 2 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ export class OpenID4VCIClient {
return response.successBody;
}

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

getCredentialTypes(): string[][] {
getCredentialOfferTypes(): string[][] {
if (this.credentialOffer.version < OpenId4VCIVersion.VER_1_0_11) {
const orig = this.credentialOffer.original_credential_offer as CredentialOfferPayloadV1_0_08;
const types: string[] = typeof orig.credential_type === 'string' ? [orig.credential_type] : orig.credential_type;
Expand Down
15 changes: 5 additions & 10 deletions packages/common/lib/functions/IssuerMetadataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,17 @@ export function getSupportedCredential(opts?: {
const supportedFormats: (CredentialOfferFormat | string)[] = formats && formats.length > 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');
Expand Down

0 comments on commit 71f97dc

Please sign in to comment.