/** * postgres-mcp - OAuth Middleware * * Authentication and authorization middleware for HTTP transport. * Transport-agnostic utilities (AuthenticatedContext, formatOAuthError, * createAuthenticatedContext, validateAuth) live in transport-agnostic.ts. * This file re-exports the shared type/formatter and provides * middleware-specific wrappers with config-object signatures. */ import type { TokenValidator } from "./token-validator.js"; export type { AuthenticatedContext } from "./transport-agnostic.js"; export { formatOAuthError } from "./transport-agnostic.js"; export { extractBearerToken } from "./helpers.js"; import type { AuthenticatedContext } from "./transport-agnostic.js"; /** * Auth middleware configuration */ export interface AuthMiddlewareConfig { /** Token validator instance */ tokenValidator: TokenValidator; /** Whether to require authentication (default: true) */ required?: boolean; /** Required scopes (any of these) */ requiredScopes?: string[]; } /** * Create authentication context from request */ export declare function createAuthContext(authHeader: string | undefined, tokenValidator: TokenValidator): Promise; /** * Validate authentication and authorization (middleware variant). * Uses config object for Express middleware chaining. * For transport-agnostic usage, see validateAuth in transport-agnostic.ts. */ export declare function validateAuth(authHeader: string | undefined, config: AuthMiddlewareConfig): Promise; /** * Check if context has required scope */ export declare function requireScope(context: AuthenticatedContext, scope: string): void; /** * Check if context has any of the required scopes */ export declare function requireAnyScope(context: AuthenticatedContext, scopes: string[]): void; /** * Check if context has scope for a tool operation */ export declare function requireToolScope(context: AuthenticatedContext, requiredScopes: string[]): void; //# sourceMappingURL=middleware.d.ts.map