@@ -144,10 +144,17 @@ export interface INonceEndpointOpts extends ISingleEndpointOpts {
144144 baseUrl : string | URL
145145}
146146
147+ export enum WellKnownHostLocation {
148+ AT_CONTEXT_PATH = 'AT_CONTEXT_PATH' ,
149+ AT_ROOT_PATH = 'AT_ROOT_PATH' ,
150+ AT_BOTH = 'AT_BOTH'
151+ }
152+
147153export interface IOID4VCIServerOpts extends HasEndpointOpts {
148154 asClientOpts ?: ClientMetadata
149155 endpointOpts ?: IOID4VCIEndpointOpts
150156 baseUrl ?: string
157+ wellKnownHostLocation ?: WellKnownHostLocation
151158}
152159
153160export class OID4VCIServer {
@@ -159,6 +166,7 @@ export class OID4VCIServer {
159166 // private readonly _server?: http.Server
160167 private readonly _router : express . Router
161168 private readonly _asClientOpts ?: ClientMetadata
169+ private readonly _wellknownHostLocation ?: WellKnownHostLocation
162170
163171 constructor (
164172 expressSupport : ExpressSupport ,
@@ -173,18 +181,22 @@ export class OID4VCIServer {
173181 this . _issuer = opts ?. issuer ? opts . issuer : buildVCIFromEnvironment ( )
174182 this . _asClientOpts =
175183 opts . asClientOpts || this . _issuer . asClientOpts ? ( { ...opts . asClientOpts , ...this . _issuer . asClientOpts } as ClientMetadata ) : undefined
176-
184+ this . _wellknownHostLocation = opts ?. wellKnownHostLocation ?? ( process . env . WELLKNOWN_HOST_LOCATION as WellKnownHostLocation )
177185 pushedAuthorizationEndpoint ( this . router , this . issuer , this . authRequestsData )
178186
179187 // Create root router for alternative .well-known endpoints if needed
180188 const basePath = getBasePath ( this . baseUrl )
181189 let rootRouter : express . Router | undefined
182- if ( basePath && basePath !== '/' ) {
190+ if ( basePath && basePath !== '/' && ( this . wellknownHostLocation == WellKnownHostLocation . AT_ROOT_PATH || this . wellknownHostLocation == WellKnownHostLocation . AT_BOTH ) ) {
183191 rootRouter = express . Router ( )
184192 this . _app . use ( '/' , rootRouter )
185193 }
186194
187- getMetadataEndpoints ( this . router , this . issuer , rootRouter , basePath )
195+ getMetadataEndpoints ( this . router , this . issuer , {
196+ rootRouter,
197+ basePath,
198+ wellKnownHostLocation : this . wellknownHostLocation
199+ } )
188200
189201 let issuerPayloadPath : string | undefined
190202 if ( this . isGetIssuePayloadEndpointEnabled ( opts ?. endpointOpts ?. getIssuePayloadOpts ) ) {
@@ -310,4 +322,8 @@ export class OID4VCIServer {
310322 get baseUrl ( ) : URL {
311323 return this . _baseUrl
312324 }
325+
326+ get wellknownHostLocation ( ) : WellKnownHostLocation | undefined {
327+ return this . _wellknownHostLocation
328+ }
313329}
0 commit comments