Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release #68

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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