diff --git a/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts b/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts index 480948c06d..ae26c6853d 100644 --- a/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts +++ b/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts @@ -300,15 +300,21 @@ export class OpenId4VcIssuerService { keyType: KeyType.Ed25519, }) - const credentialsSupported = Array.isArray(options.credentialsSupported) - ? options.credentialsSupported - : credentialsSupportedV13ToV11(options.credentialsSupported) - const openId4VcIssuer = new OpenId4VcIssuerRecord({ + const openId4VcIssuerBase = { issuerId: options.issuerId ?? utils.uuid(), display: options.display, accessTokenPublicKeyFingerprint: accessTokenSignerKey.fingerprint, - credentialsSupported, - }) + } as const + + const openId4VcIssuer = options.credentialsSupported + ? new OpenId4VcIssuerRecord({ + ...openId4VcIssuerBase, + credentialsSupported: options.credentialsSupported, + }) + : new OpenId4VcIssuerRecord({ + ...openId4VcIssuerBase, + credentialConfigurationsSupported: options.credentialConfigurationsSupported, + }) await this.openId4VcIssuerRepository.save(agentContext, openId4VcIssuer) await storeActorIdForContextCorrelationId(agentContext, openId4VcIssuer.issuerId) @@ -334,6 +340,9 @@ export class OpenId4VcIssuerService { tokenEndpoint: joinUriParts(issuerUrl, [config.accessTokenEndpoint.endpointPath]), credentialEndpoint: joinUriParts(issuerUrl, [config.credentialEndpoint.endpointPath]), credentialsSupported: issuerRecord.credentialsSupported, + credentialConfigurationsSupported: + issuerRecord.credentialConfigurationsSupported ?? + credentialsSupportedV11ToV13(agentContext, issuerRecord.credentialsSupported), issuerDisplay: issuerRecord.display, } satisfies OpenId4VcIssuerMetadata @@ -426,7 +435,7 @@ export class OpenId4VcIssuerService { agentContext: AgentContext, credentialOffer: OpenId4VciCredentialOfferPayload, credentialRequest: OpenId4VciCredentialRequest, - credentialsSupported: OpenId4VciCredentialSupportedWithId[], + credentialsSupported: OpenId4VciCredentialSupportedWithId[] | OpenId4VciCredentialConfigurationsSupported, issuanceSession: OpenId4VcIssuanceSessionRecord ): OpenId4VciCredentialConfigurationsSupported { const offeredCredentialsData = isCredentialOfferV1Draft13(credentialOffer) @@ -616,7 +625,7 @@ export class OpenId4VcIssuerService { agentContext, options.issuanceSession.credentialOfferPayload, credentialRequest, - issuerMetadata.credentialsSupported, + issuerMetadata.credentialConfigurationsSupported, issuanceSession ) diff --git a/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerServiceOptions.ts b/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerServiceOptions.ts index 384dec5a2c..8914af5b5d 100644 --- a/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerServiceOptions.ts +++ b/packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerServiceOptions.ts @@ -1,4 +1,8 @@ -import type { OpenId4VcIssuanceSessionRecord } from './repository' +import type { + OpenId4VcIssuanceSessionRecord, + OpenId4VcIssuerRecordCredentialConfigurationsSupportedProps, + OpenId4VcIssuerRecordCredentialSupportedProps, +} from './repository' import type { OpenId4VcCredentialHolderBinding, OpenId4VciCredentialConfigurationsSupported, @@ -34,6 +38,7 @@ export type OpenId4VcIssuerMetadata = { issuerDisplay?: OpenId4VciIssuerMetadataDisplay[] credentialsSupported: OpenId4VciCredentialSupportedWithId[] + credentialConfigurationsSupported: OpenId4VciCredentialConfigurationsSupported } export interface OpenId4VciCreateCredentialOfferOptions { @@ -140,12 +145,11 @@ export interface OpenId4VciSignW3cCredential { credential: W3cCredential } -export interface OpenId4VciCreateIssuerOptions { +export type OpenId4VciCreateIssuerOptions = { /** * Id of the issuer, not the id of the issuer record. Will be exposed publicly */ issuerId?: string - credentialsSupported: OpenId4VciCredentialSupportedWithId[] | OpenId4VciCredentialConfigurationsSupported display?: OpenId4VciIssuerMetadataDisplay[] -} +} & (OpenId4VcIssuerRecordCredentialSupportedProps | OpenId4VcIssuerRecordCredentialConfigurationsSupportedProps) diff --git a/packages/openid4vc/src/openid4vc-issuer/router/metadataEndpoint.ts b/packages/openid4vc/src/openid4vc-issuer/router/metadataEndpoint.ts index 6aca9a0758..58a2b280c6 100644 --- a/packages/openid4vc/src/openid4vc-issuer/router/metadataEndpoint.ts +++ b/packages/openid4vc/src/openid4vc-issuer/router/metadataEndpoint.ts @@ -2,7 +2,6 @@ import type { OpenId4VcIssuanceRequest } from './requestContext' import type { CredentialIssuerMetadata } from '@sphereon/oid4vci-common' import type { Router, Response } from 'express' -import { credentialsSupportedV11ToV13 } from '../../shared/issuerMetadataUtils' import { getRequestContext, sendErrorResponse } from '../../shared/router' import { OpenId4VcIssuerService } from '../OpenId4VcIssuerService' @@ -21,9 +20,7 @@ export function configureIssuerMetadataEndpoint(router: Router) { authorization_server: issuerMetadata.authorizationServer, authorization_servers: issuerMetadata.authorizationServer ? [issuerMetadata.authorizationServer] : undefined, credentials_supported: issuerMetadata.credentialsSupported, - credential_configurations_supported: - issuer.credentialConfigurationsSupported ?? - credentialsSupportedV11ToV13(agentContext, issuerMetadata.credentialsSupported), + credential_configurations_supported: issuerMetadata.credentialConfigurationsSupported, display: issuerMetadata.issuerDisplay, } satisfies CredentialIssuerMetadata