@@ -17,17 +17,15 @@ export interface McpAuthOptions {
1717 requiredScopes ?: string [ ] ;
1818
1919 /**
20- * Optional, resource metadata path to include in WWW-Authenticate header.
20+ * Optional, resource metadata URL to include in WWW-Authenticate header.
2121 */
22- resourceMetadataPath ?: string ;
22+ resourceMetadataUrl ?: string ;
2323}
2424
2525export function withMcpAuth (
2626 handler : ( req : Request ) => Promise < Response > ,
2727 verifyToken : ( req : Request , token : string ) => Promise < AuthInfo > ,
28- options : McpAuthOptions = {
29- resourceMetadataPath : "/.well-known/oauth-protected-resource"
30- }
28+ options ?: McpAuthOptions
3129) {
3230 return async ( req : Request ) => {
3331 try {
@@ -53,7 +51,7 @@ export function withMcpAuth(
5351 }
5452
5553 // Check if token has the required scopes (if any)
56- if ( options . requiredScopes ?. length ) {
54+ if ( options ? .requiredScopes ?. length ) {
5755 const hasAllScopes = options . requiredScopes . every ( scope =>
5856 authInfo . scopes . includes ( scope )
5957 ) ;
@@ -74,7 +72,7 @@ export function withMcpAuth(
7472 return handler ( req ) ;
7573 } catch ( error ) {
7674 const origin = new URL ( req . url ) . origin ;
77- const resourceMetadataUrl = options . resourceMetadataPath || `${ origin } /.well-known/oauth-protected-resource` ;
75+ const resourceMetadataUrl = options ?. resourceMetadataUrl || `${ origin } /.well-known/oauth-protected-resource` ;
7876
7977 if ( error instanceof InvalidTokenError ) {
8078 return new Response ( JSON . stringify ( error . toResponseObject ( ) ) , {
0 commit comments