From 4044c2175b4cbee16f44c8bb5499bba249ca4993 Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Wed, 27 Sep 2023 03:28:22 +0200 Subject: [PATCH] fix: Better match credential offer types and formats onto issuer metadata --- packages/callback-example/CHANGELOG.md | 7 +- packages/client/CHANGELOG.md | 10 +-- packages/client/lib/OpenID4VCIClient.ts | 80 ++++--------------- .../lib/__tests__/AccessTokenClient.spec.ts | 4 +- packages/client/lib/__tests__/IT.spec.ts | 5 +- .../lib/__tests__/MattrE2E.spec.test.ts | 49 ++++++------ .../lib/__tests__/OpenID4VCIClient.spec.ts | 2 +- .../lib/__tests__/OpenID4VCIClientPAR.spec.ts | 18 ++--- packages/common/CHANGELOG.md | 12 +-- .../lib/functions/IssuerMetadataUtils.ts | 72 +++++++++++------ packages/issuer-rest/CHANGELOG.md | 10 +-- .../lib/__tests__/ClientIssuerIT.spec.ts | 74 ++++++++--------- packages/issuer/CHANGELOG.md | 7 +- 13 files changed, 139 insertions(+), 211 deletions(-) diff --git a/packages/callback-example/CHANGELOG.md b/packages/callback-example/CHANGELOG.md index 0ebd14dc..c65fb009 100644 --- a/packages/callback-example/CHANGELOG.md +++ b/packages/callback-example/CHANGELOG.md @@ -5,14 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.7.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.6.0...v0.7.0) (2023-08-19) - ### Features -* Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) - - - - +- Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) # [0.6.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.4.0...v0.6.0) (2023-06-24) diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index 04416b84..4a1628ff 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -5,19 +5,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.7.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.6.0...v0.7.0) (2023-08-19) - ### Bug Fixes -* Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) - +- Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) ### Features -* Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) - - - - +- Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) # [0.6.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.4.0...v0.6.0) (2023-06-24) diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index fe21b600..fc42dc41 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -366,79 +366,29 @@ export class OpenID4VCIClient { return response.successBody; } - getCredentialsSupported(restrictToInitiationTypes: boolean, supportedType?: string): CredentialSupported[] { + getCredentialsSupported( + restrictToInitiationTypes: boolean, + format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[], + ): CredentialSupported[] { return getSupportedCredentials({ issuerMetadata: this.endpointMetadata.credentialIssuerMetadata, version: this.version(), - supportedType, - credentialTypes: restrictToInitiationTypes ? this.getCredentialTypes() : undefined, + format: format, + types: restrictToInitiationTypes ? this.getCredentialTypes() : undefined, }); - /*//FIXME: delegate to getCredentialsSupported from IssuerMetadataUtils - let credentialsSupported = this.endpointMetadata?.issuerMetadata?.credentials_supported - - if (this.version() === OpenId4VCIVersion.VER_1_0_08 || typeof credentialsSupported === 'object') { - const issuerMetadata = this.endpointMetadata.issuerMetadata as IssuerMetadataV1_0_08 - const v8CredentialsSupported = issuerMetadata.credentials_supported - credentialsSupported = [] - credentialsSupported = Object.entries(v8CredentialsSupported).map((key, value) => ) - - } - - - if (!credentialsSupported) { - return [] - } else if (!restrictToInitiationTypes) { - return credentialsSupported - } - - - - /!** - * the following (not array part is a legacy code from version 1_0-08 which jff implementors used) - *!/ - if (!Array.isArray(credentialsSupported)) { - const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08; - const initiationTypes = supportedType ? [supportedType] : this.getCredentialTypes(); - const supported: IssuerCredentialSubject = {}; - for (const [key, value] of Object.entries(credentialsSupportedV8)) { - if (initiationTypes.includes(key)) { - supported[key] = value; - } - } - // todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) - return supported as unknown as CredentialSupported[]; - } - const initiationTypes = supportedType ? [supportedType] : this.getCredentialTypes() - const credentialSupportedOverlap: CredentialSupported[] = [] - for (const supported of credentialsSupported) { - const supportedTypeOverlap: string[] = [] - for (const type of supported.types) { - initiationTypes.includes(type) - supportedTypeOverlap.push(type) - } - if (supportedTypeOverlap.length > 0) { - credentialSupportedOverlap.push({ - ...supported, - types: supportedTypeOverlap - }) - } - } - return credentialSupportedOverlap as CredentialSupported[]*/ - } - - getCredentialMetadata(type: string): CredentialSupported[] { - return this.getCredentialsSupported(false, type); } - // todo https://sphereon.atlassian.net/browse/VDX-184 - getCredentialTypes(): string[] { + getCredentialTypes(): string[][] { if (this.credentialOffer.version < OpenId4VCIVersion.VER_1_0_11) { - return typeof (this.credentialOffer.original_credential_offer as CredentialOfferPayloadV1_0_08).credential_type === 'string' - ? [(this.credentialOffer.original_credential_offer as CredentialOfferPayloadV1_0_08).credential_type as string] - : ((this.credentialOffer.original_credential_offer as CredentialOfferPayloadV1_0_08).credential_type as string[]); + 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; + const result: string[][] = []; + result[0] = types; + return result; } else { - // FIXME: this for sure isn't correct. It would also include VerifiableCredential. The whole call to this getCredentialsTypes should be changed to begin with - return this.credentialOffer.credential_offer.credentials.flatMap((c) => (typeof c === 'string' ? c : c.types)); + return this.credentialOffer.credential_offer.credentials.map((c, index) => { + return typeof c === 'string' ? [c] : c.types; + }); } } diff --git a/packages/client/lib/__tests__/AccessTokenClient.spec.ts b/packages/client/lib/__tests__/AccessTokenClient.spec.ts index cd1e53e5..52b7345a 100644 --- a/packages/client/lib/__tests__/AccessTokenClient.spec.ts +++ b/packages/client/lib/__tests__/AccessTokenClient.spec.ts @@ -4,8 +4,8 @@ import { AccessTokenResponse, GrantTypes, OpenIDResponse, - WellKnownEndpoints -} from '@sphereon/oid4vci-common' + WellKnownEndpoints, +} from '@sphereon/oid4vci-common'; import nock from 'nock'; import { AccessTokenClient } from '../AccessTokenClient'; diff --git a/packages/client/lib/__tests__/IT.spec.ts b/packages/client/lib/__tests__/IT.spec.ts index f104ae5a..74c3a741 100644 --- a/packages/client/lib/__tests__/IT.spec.ts +++ b/packages/client/lib/__tests__/IT.spec.ts @@ -5,8 +5,9 @@ import { CredentialOfferRequestWithBaseUrl, Jwt, OpenId4VCIVersion, - ProofOfPossession, WellKnownEndpoints -} from '@sphereon/oid4vci-common' + ProofOfPossession, + WellKnownEndpoints, +} from '@sphereon/oid4vci-common'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import nock from 'nock'; diff --git a/packages/client/lib/__tests__/MattrE2E.spec.test.ts b/packages/client/lib/__tests__/MattrE2E.spec.test.ts index 3f90c945..7c856e51 100644 --- a/packages/client/lib/__tests__/MattrE2E.spec.test.ts +++ b/packages/client/lib/__tests__/MattrE2E.spec.test.ts @@ -1,6 +1,6 @@ -import { CredentialMapper } from '@sphereon/ssi-types' -import { fetch } from 'cross-fetch'; import { Alg, AuthzFlowType, Jwt } from '@sphereon/oid4vci-common'; +import { CredentialMapper } from '@sphereon/ssi-types'; +import { fetch } from 'cross-fetch'; import { importJWK, JWK, SignJWT } from 'jose'; import { OpenID4VCIClient } from '..'; @@ -22,53 +22,50 @@ const did = `did:key:z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`; const kid = `${did}#z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`; describe('OID4VCI-Client using Mattr issuer should', () => { async function test(format: 'ldp_vc' | 'jwt_vc_json') { - const offer = await getCredentialOffer(format) + const offer = await getCredentialOffer(format); const client = await OpenID4VCIClient.fromURI({ uri: offer.offerUrl, flowType: AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW, kid, - alg: Alg.EdDSA - }) - expect(client.flowType).toEqual(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW) - expect(client.credentialOffer).toBeDefined() - expect(client.endpointMetadata).toBeDefined() - expect(client.getCredentialEndpoint()).toEqual(`${ISSUER_URL}/oidc/v1/auth/credential`) - expect(client.getAccessTokenEndpoint()).toEqual('https://launchpad.vii.electron.mattrlabs.io/oidc/v1/auth/token') - - const accessToken = await client.acquireAccessToken() - console.log(accessToken) + alg: Alg.EdDSA, + }); + expect(client.flowType).toEqual(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW); + expect(client.credentialOffer).toBeDefined(); + expect(client.endpointMetadata).toBeDefined(); + expect(client.getCredentialEndpoint()).toEqual(`${ISSUER_URL}/oidc/v1/auth/credential`); + expect(client.getAccessTokenEndpoint()).toEqual('https://launchpad.vii.electron.mattrlabs.io/oidc/v1/auth/token'); + + const accessToken = await client.acquireAccessToken(); + console.log(accessToken); expect(accessToken).toMatchObject({ expires_in: 3600, scope: 'OpenBadgeCredential', - token_type: 'Bearer' - }) + token_type: 'Bearer', + }); const credentialResponse = await client.acquireCredentials({ credentialTypes: 'OpenBadgeCredential', format, proofCallbacks: { - signCallback: proofOfPossessionCallbackFunction - } - }) - expect(credentialResponse.credential).toBeDefined() - const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credentialResponse.credential!) - expect(format.startsWith(wrappedVC.format)).toEqual(true) - + signCallback: proofOfPossessionCallbackFunction, + }, + }); + expect(credentialResponse.credential).toBeDefined(); + const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credentialResponse.credential!); + expect(format.startsWith(wrappedVC.format)).toEqual(true); } it( 'succeed in a full flow with the client using OpenID4VCI version 11 and ldp_vc', async () => { - - await test('ldp_vc') + await test('ldp_vc'); }, UNIT_TEST_TIMEOUT, ); it( 'succeed in a full flow with the client using OpenID4VCI version 11 and jwt_vc_json', async () => { - - await test('jwt_vc_json') + await test('jwt_vc_json'); }, UNIT_TEST_TIMEOUT, ); diff --git a/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts b/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts index ea8708d2..c3d9da59 100644 --- a/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts +++ b/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts @@ -1,4 +1,4 @@ -import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common' +import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import nock from 'nock'; diff --git a/packages/client/lib/__tests__/OpenID4VCIClientPAR.spec.ts b/packages/client/lib/__tests__/OpenID4VCIClientPAR.spec.ts index b319fd4e..8a7e8ee6 100644 --- a/packages/client/lib/__tests__/OpenID4VCIClientPAR.spec.ts +++ b/packages/client/lib/__tests__/OpenID4VCIClientPAR.spec.ts @@ -1,4 +1,4 @@ -import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common' +import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common'; import nock from 'nock'; import { OpenID4VCIClient } from '../OpenID4VCIClient'; @@ -23,9 +23,7 @@ describe('OpenID4VCIClient', () => { }); it('should successfully retrieve the authorization code using PAR', async () => { - ( - client.endpointMetadata.credentialIssuerMetadata! - ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; + client.endpointMetadata.credentialIssuerMetadata!.pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; const actual = await client.acquirePushedAuthorizationRequestURI({ clientId: 'test-client', codeChallengeMethod: CodeChallengeMethod.SHA256, @@ -60,9 +58,7 @@ describe('OpenID4VCIClient', () => { }); it('should not fail when only authorization_details is present', async () => { - ( - client.endpointMetadata.credentialIssuerMetadata! - ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; + client.endpointMetadata.credentialIssuerMetadata!.pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; const actual = await client.acquirePushedAuthorizationRequestURI({ clientId: 'test-client', codeChallengeMethod: CodeChallengeMethod.SHA256, @@ -83,9 +79,7 @@ describe('OpenID4VCIClient', () => { }); it('should not fail when only scope is present', async () => { - ( - client.endpointMetadata.credentialIssuerMetadata! - ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; + client.endpointMetadata.credentialIssuerMetadata!.pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; const actual = await client.acquirePushedAuthorizationRequestURI({ clientId: 'test-client', codeChallengeMethod: CodeChallengeMethod.SHA256, @@ -97,9 +91,7 @@ describe('OpenID4VCIClient', () => { }); it('should not fail when both authorization_details and scope are present', async () => { - ( - client.endpointMetadata.credentialIssuerMetadata! - ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; + client.endpointMetadata.credentialIssuerMetadata!.pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`; const actual = await client.acquirePushedAuthorizationRequestURI({ clientId: 'test-client', codeChallengeMethod: CodeChallengeMethod.SHA256, diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 7aca887e..1a83f8b9 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -5,20 +5,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.7.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.6.0...v0.7.0) (2023-08-19) - ### Bug Fixes -* fix credential request properties ([0037025](https://github.com/Sphereon-Opensource/OID4VCI/commit/0037025ef27d3a1fa7c68954b1f87e660ef0c82c)) -* Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) - +- fix credential request properties ([0037025](https://github.com/Sphereon-Opensource/OID4VCI/commit/0037025ef27d3a1fa7c68954b1f87e660ef0c82c)) +- Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) ### Features -* Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) - - - - +- Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) # [0.6.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.4.0...v0.6.0) (2023-06-24) diff --git a/packages/common/lib/functions/IssuerMetadataUtils.ts b/packages/common/lib/functions/IssuerMetadataUtils.ts index d89d142b..0e6a0cc3 100644 --- a/packages/common/lib/functions/IssuerMetadataUtils.ts +++ b/packages/common/lib/functions/IssuerMetadataUtils.ts @@ -6,59 +6,81 @@ import { CredentialSupportedV1_0_08, IssuerMetadataV1_0_08, MetadataDisplay, + OID4VCICredentialFormat, OpenId4VCIVersion, } from '../types'; export function getSupportedCredentials(opts?: { issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08; version: OpenId4VCIVersion; - credentialTypes?: (CredentialOfferFormat | string)[]; - supportedType?: CredentialOfferFormat | string; + types?: string[][]; + format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]; +}): CredentialSupported[] { + if (opts?.types && Array.isArray(opts?.types)) { + return opts.types.flatMap((types) => getSupportedCredential({ ...opts, types })); + } + return getSupportedCredential(opts ? { ...opts, types: undefined } : undefined); +} + +export function getSupportedCredential(opts?: { + issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08; + version: OpenId4VCIVersion; + types?: string[]; + format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]; }): CredentialSupported[] { const { issuerMetadata } = opts ?? {}; + let formats: (OID4VCICredentialFormat | string)[]; + if (opts?.format && Array.isArray(opts.format)) { + formats = opts.format; + } else if (opts?.format && !Array.isArray(opts.format)) { + formats = [opts.format]; + } else { + formats = []; + } let credentialsSupported: CredentialSupported[]; if (!issuerMetadata) { return []; } - const { version, credentialTypes, supportedType } = opts ?? { version: OpenId4VCIVersion.VER_1_0_11 }; + const { version, types } = opts ?? { version: OpenId4VCIVersion.VER_1_0_11 }; if (version === OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) { credentialsSupported = credentialsSupportedV8ToV11((issuerMetadata as IssuerMetadataV1_0_08).credentials_supported); - /* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08 - // const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types) - const supported: IssuerCredentialSubject = {} - for (const [key, value] of Object.entries(credentialsSupportedV8)) { - if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) { - supported[key] = value - } - } - // todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) - return supported as unknown as CredentialSupported[]*/ } else { credentialsSupported = (issuerMetadata as CredentialIssuerMetadata).credentials_supported; } if (credentialsSupported === undefined || credentialsSupported.length === 0) { return []; - } else if (!credentialTypes || credentialTypes.length === 0) { + } else if (!types || types.length === 0) { return credentialsSupported; } /** * the following (not array part is a legacy code from version 1_0-08 which JFF plugfest 2 implementors used) */ - const initiationTypes = supportedType ? [supportedType] : credentialTypes; + const initiationTypes = version === OpenId4VCIVersion.VER_1_0_08 && !types ? formats : types; + const supportedFormats: (CredentialOfferFormat | string)[] = formats ?? ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; const credentialSupportedOverlap: CredentialSupported[] = []; - for (const offerType of initiationTypes) { - if (typeof offerType === 'string') { - const supported = credentialsSupported.filter((sup) => sup.id === offerType || sup.types.includes(offerType)); - if (supported) { - credentialSupportedOverlap.push(...supported); - } - } else { - const supported = credentialsSupported.filter((sup) => arrayEqualsIgnoreOrder(sup.types, offerType.types) && sup.format === offerType.format); - if (supported) { - credentialSupportedOverlap.push(...supported); + if (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 { + // 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.includes('VerifiableCredential')) { + initiationTypes.push('VerifiableCredential'); + } + const supported = credentialsSupported.filter((sup) => { + const supTypes = sup.types; + if (!supTypes.includes('VerifiableCredential')) { + supTypes.push('VerifiableCredential'); } + return arrayEqualsIgnoreOrder(supTypes, initiationTypes) && supportedFormats.includes(sup.format); + }); + if (supported) { + credentialSupportedOverlap.push(...supported); } } return credentialSupportedOverlap; diff --git a/packages/issuer-rest/CHANGELOG.md b/packages/issuer-rest/CHANGELOG.md index 47e8b2ab..5c503e66 100644 --- a/packages/issuer-rest/CHANGELOG.md +++ b/packages/issuer-rest/CHANGELOG.md @@ -5,19 +5,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.7.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.6.0...v0.7.0) (2023-08-19) - ### Bug Fixes -* Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) - +- Revise well-known metadata retrieval for OID4VCI, OAuth 2.0 and OIDC. fixes [#62](https://github.com/Sphereon-Opensource/OID4VCI/issues/62) ([a750cc7](https://github.com/Sphereon-Opensource/OID4VCI/commit/a750cc76e084f12aeb58f2b1ac44b1bb5e69b5ae)) ### Features -* Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) - - - - +- Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) # [0.6.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.4.0...v0.6.0) (2023-06-24) diff --git a/packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts b/packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts index c48a3a5c..6364a7b6 100644 --- a/packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts +++ b/packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts @@ -252,54 +252,48 @@ describe('VcIssuer', () => { it('should retrieve server metadata', async () => { await expect(client.retrieveServerMetadata()).resolves.toEqual({ - "authorizationServerType": "OID4VCI", - "authorization_server": "http://localhost:3456/test", - "credentialIssuerMetadata": { - "credential_endpoint": "http://localhost:3456/test/credential-endpoint", - "credential_issuer": "http://localhost:3456/test", - "credentials_supported": [ + authorizationServerType: 'OID4VCI', + authorization_server: 'http://localhost:3456/test', + credentialIssuerMetadata: { + credential_endpoint: 'http://localhost:3456/test/credential-endpoint', + credential_issuer: 'http://localhost:3456/test', + credentials_supported: [ { - "credentialSubject": { - "given_name": { - "locale": "en-US", - "name": "given name" - } + credentialSubject: { + given_name: { + locale: 'en-US', + name: 'given name', + }, }, - "cryptographic_binding_methods_supported": [ - "did" - ], - "cryptographic_suites_supported": [ - "ES256K" - ], - "display": [ + cryptographic_binding_methods_supported: ['did'], + cryptographic_suites_supported: ['ES256K'], + display: [ { - "background_color": "#12107c", - "locale": "en-US", - "logo": { - "alt_text": "a square logo of a university", - "url": "https://exampleuniversity.com/public/logo.png" + background_color: '#12107c', + locale: 'en-US', + logo: { + alt_text: 'a square logo of a university', + url: 'https://exampleuniversity.com/public/logo.png', }, - "name": "University Credential", - "text_color": "#FFFFFF" - } + name: 'University Credential', + text_color: '#FFFFFF', + }, ], - "format": "jwt_vc_json", - "id": "UniversityDegree_JWT", - "types": [ - "VerifiableCredential" - ] - } + format: 'jwt_vc_json', + id: 'UniversityDegree_JWT', + types: ['VerifiableCredential'], + }, ], - "display": [ + display: [ { - "locale": "en-US", - "name": "example issuer" - } - ] + locale: 'en-US', + name: 'example issuer', + }, + ], }, - "credential_endpoint": "http://localhost:3456/test/credential-endpoint", - "issuer": "http://localhost:3456/test", - "token_endpoint": "http://localhost:3456/test/token" + credential_endpoint: 'http://localhost:3456/test/credential-endpoint', + issuer: 'http://localhost:3456/test', + token_endpoint: 'http://localhost:3456/test/token', }) }) it('should get state on server side', async () => { diff --git a/packages/issuer/CHANGELOG.md b/packages/issuer/CHANGELOG.md index bc790cb1..0d3fad98 100644 --- a/packages/issuer/CHANGELOG.md +++ b/packages/issuer/CHANGELOG.md @@ -5,14 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.7.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.6.0...v0.7.0) (2023-08-19) - ### Features -* Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) - - - - +- Integrate ssi-express-support to allow for future authn/authz. Also moved endpoints to functions, so solutions can include their own set of endpoints ([c749aba](https://github.com/Sphereon-Opensource/OID4VCI/commit/c749ababd4bec567d6aeeda49b76f195ec792201)) # [0.6.0](https://github.com/Sphereon-Opensource/OID4VCI/compare/v0.4.0...v0.6.0) (2023-06-24)