@@ -720,14 +720,41 @@ export function getMetadataEndpoints(router: Router, issuer: VcIssuer) {
720720 const credentialIssuerHandler = ( request : Request , response : Response ) => {
721721 return response . json ( issuer . issuerMetadata )
722722 }
723- router . get ( WellKnownEndpoints . OPENID4VCI_ISSUER , credentialIssuerHandler )
724723
725724 const authorizationServerHandler = ( request : Request , response : Response ) => {
726725 return response . json ( issuer . authorizationServerMetadata )
727726 }
727+
728+ // Original endpoints
729+ router . get ( WellKnownEndpoints . OPENID4VCI_ISSUER , credentialIssuerHandler )
728730 router . get ( WellKnownEndpoints . OAUTH_AS , authorizationServerHandler )
731+
732+ // Alternative endpoints with .well-known at root
733+ const alternativeCredentialIssuerEndpoint = getAlternativeWellKnownEndpoint ( WellKnownEndpoints . OPENID4VCI_ISSUER )
734+ const alternativeAuthServerEndpoint = getAlternativeWellKnownEndpoint ( WellKnownEndpoints . OAUTH_AS )
735+
736+ if ( alternativeCredentialIssuerEndpoint ) {
737+ router . get ( alternativeCredentialIssuerEndpoint , credentialIssuerHandler )
738+ }
739+
740+ if ( alternativeAuthServerEndpoint ) {
741+ router . get ( alternativeAuthServerEndpoint , authorizationServerHandler )
742+ }
729743}
730744
745+ function getAlternativeWellKnownEndpoint ( originalEndpoint : string ) : string | null {
746+ const wellKnownIndex = originalEndpoint . indexOf ( '/.well-known/' )
747+ if ( wellKnownIndex <= 0 ) {
748+ return null
749+ }
750+
751+ const contextPath = originalEndpoint . substring ( 0 , wellKnownIndex )
752+ const wellKnownResource = originalEndpoint . substring ( wellKnownIndex + '/.well-known/' . length )
753+
754+ return `/.well-known/${ wellKnownResource } ${ contextPath } `
755+ }
756+
757+
731758export function determinePath (
732759 baseUrl : URL | string | undefined ,
733760 endpoint : string ,
0 commit comments