Skip to content

Commit 20f6bc7

Browse files
committed
Merge branch 'feature/SSISDK-73_well-known-draftv1' into feature/SSISDK-73_auth_detail_fix
2 parents be377c9 + 7af1d01 commit 20f6bc7

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

packages/issuer-rest/lib/OID4VCIServer.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,17 @@ export class OID4VCIServer {
175175
opts.asClientOpts || this._issuer.asClientOpts ? ({ ...opts.asClientOpts, ...this._issuer.asClientOpts } as ClientMetadata) : undefined
176176

177177
pushedAuthorizationEndpoint(this.router, this.issuer, this.authRequestsData)
178-
getMetadataEndpoints(this.router, this.issuer)
178+
179+
// Create root router for alternative .well-known endpoints if needed
180+
const basePath = getBasePath(this.baseUrl)
181+
let rootRouter: express.Router | undefined
182+
if (basePath && basePath !== '/') {
183+
rootRouter = express.Router()
184+
this._app.use('/', rootRouter)
185+
}
186+
187+
getMetadataEndpoints(this.router, this.issuer, rootRouter, this.baseUrl)
188+
179189
let issuerPayloadPath: string | undefined
180190
if (this.isGetIssuePayloadEndpointEnabled(opts?.endpointOpts?.getIssuePayloadOpts)) {
181191
issuerPayloadPath = getCredentialOfferReferenceEndpoint(this.router, this.issuer, {
@@ -231,7 +241,7 @@ export class OID4VCIServer {
231241
baseUrl: this.baseUrl,
232242
})
233243
}
234-
this._app.use(getBasePath(this.baseUrl), this._router)
244+
this._app.use(basePath, this._router)
235245
}
236246

237247
public get app(): Express {

packages/issuer-rest/lib/oid4vci-api-functions.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,27 @@ export function pushedAuthorizationEndpoint(
774774
})
775775
}
776776

777-
export function getMetadataEndpoints(router: Router, issuer: VcIssuer) {
777+
export function getMetadataEndpoints(router: Router, issuer: VcIssuer, rootRouter?: Router, baseUrl?: URL | string) {
778778
const credentialIssuerHandler = (request: Request, response: Response) => {
779779
return response.json(issuer.issuerMetadata)
780780
}
781-
router.get(WellKnownEndpoints.OPENID4VCI_ISSUER, credentialIssuerHandler)
782781

783782
const authorizationServerHandler = (request: Request, response: Response) => {
784783
return response.json(issuer.authorizationServerMetadata)
785784
}
785+
786+
// Original endpoints on the context router
787+
router.get(WellKnownEndpoints.OPENID4VCI_ISSUER, credentialIssuerHandler)
786788
router.get(WellKnownEndpoints.OAUTH_AS, authorizationServerHandler)
789+
790+
// Alternative root-level endpoints if rootRouter provided
791+
if (rootRouter && baseUrl) {
792+
const basePath = getBasePath(baseUrl)
793+
if (basePath && basePath !== '/') {
794+
rootRouter.get(`/.well-known/openid-credential-issuer${basePath}`, credentialIssuerHandler)
795+
rootRouter.get(`/.well-known/oauth-authorization-server${basePath}`, authorizationServerHandler)
796+
}
797+
}
787798
}
788799

789800
export function determinePath(

0 commit comments

Comments
 (0)