diff --git a/packages/issuer-rest/lib/oid4vci-api-functions.ts b/packages/issuer-rest/lib/oid4vci-api-functions.ts index d44388bb..896716d7 100644 --- a/packages/issuer-rest/lib/oid4vci-api-functions.ts +++ b/packages/issuer-rest/lib/oid4vci-api-functions.ts @@ -2,7 +2,6 @@ import { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, adjustUrl, AuthorizationRequest, - CredentialIssuerMetadataOpts, CredentialOfferRESTRequest, CredentialRequestV1_0_11, determineGrantTypes, @@ -380,16 +379,9 @@ export function pushedAuthorizationEndpoint( }) } -function addTokenEndpoint(issuerMetadata: CredentialIssuerMetadataOpts) { - if (!issuerMetadata.token_endpoint) { - issuerMetadata.token_endpoint = `${issuerMetadata.credential_issuer}/token` - } -} - export function getMetadataEndpoint(router: Router, issuer: VcIssuer) { const path = `/.well-known/openid-credential-issuer` router.get(path, (request: Request, response: Response) => { - addTokenEndpoint(issuer.issuerMetadata) return response.send(issuer.issuerMetadata) }) } diff --git a/packages/issuer/lib/builder/VcIssuerBuilder.ts b/packages/issuer/lib/builder/VcIssuerBuilder.ts index 7b30f874..7b6b7a61 100644 --- a/packages/issuer/lib/builder/VcIssuerBuilder.ts +++ b/packages/issuer/lib/builder/VcIssuerBuilder.ts @@ -145,6 +145,12 @@ export class VcIssuerBuilder { return this } + private setDefaultTokenEndpoint(issuerMetadata: Partial) { + if (!issuerMetadata.token_endpoint) { + issuerMetadata.token_endpoint = `${issuerMetadata.credential_issuer}/token` + } + } + public build(): VcIssuer { if (!this.credentialOfferStateManager) { throw new Error(TokenErrorResponse.invalid_request) @@ -155,6 +161,7 @@ export class VcIssuerBuilder { const builder = this.issuerMetadataBuilder?.build() const metadata: Partial = { ...this.issuerMetadata, ...builder } + this.setDefaultTokenEndpoint(metadata) // Let's make sure these get merged correctly: metadata.credentials_supported = [...(this.issuerMetadata.credentials_supported ?? []), ...(builder?.credentials_supported ?? [])] metadata.display = [...(this.issuerMetadata.display ?? []), ...(builder?.display ?? [])]