diff --git a/packages/issuer-rest/lib/oid4vci-api-functions.ts b/packages/issuer-rest/lib/oid4vci-api-functions.ts index 896716d7..d44388bb 100644 --- a/packages/issuer-rest/lib/oid4vci-api-functions.ts +++ b/packages/issuer-rest/lib/oid4vci-api-functions.ts @@ -2,6 +2,7 @@ import { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, adjustUrl, AuthorizationRequest, + CredentialIssuerMetadataOpts, CredentialOfferRESTRequest, CredentialRequestV1_0_11, determineGrantTypes, @@ -379,9 +380,16 @@ 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) }) }