import { AuthConfig } from "../../auth/types.js"; /** * Health endpoint configuration */ export interface HealthConfig { /** * Whether the health endpoint is enabled * @default true */ enabled?: boolean; /** * Path for the health endpoint * @default "/health" */ path?: string; /** * Custom response body. When set, this object is returned as JSON. * @default { ok: true } */ response?: Record; } /** * CORS configuration options for SSE transport */ export interface CORSConfig { /** * Access-Control-Allow-Origin header * @default "*" */ allowOrigin?: string; /** * Access-Control-Allow-Methods header * @default "GET, POST, OPTIONS" */ allowMethods?: string; /** * Access-Control-Allow-Headers header * @default "Content-Type, Authorization, x-api-key" */ allowHeaders?: string; /** * Access-Control-Expose-Headers header * @default "Content-Type, Authorization, x-api-key" */ exposeHeaders?: string; /** * Access-Control-Max-Age header for preflight requests * @default "86400" */ maxAge?: string; /** * List of allowed origins for Origin header validation. * If not set, all origins are allowed (backwards compatible). * When set, requests with non-matching Origin headers receive 403. * Requests without an Origin header (non-browser clients) are always allowed. */ allowedOrigins?: string[]; } /** * Configuration options for SSE transport */ export interface SSETransportConfig { /** * Port to listen on */ port?: number; /** * Host/address to bind to * @default "127.0.0.1" */ host?: string; /** * Endpoint for SSE events stream * @default "/sse" */ endpoint?: string; /** * Endpoint for receiving messages via POST * @default "/messages" */ messageEndpoint?: string; /** * Maximum allowed message size in bytes * @default "4mb" */ maxMessageSize?: string; /** * Custom headers to add to SSE responses */ headers?: Record; /** * CORS configuration */ cors?: CORSConfig; /** * Authentication configuration */ auth?: AuthConfig; /** * Health endpoint configuration. * Enabled by default at /health when using SSE transport. */ health?: HealthConfig; /** * OAuth configuration for authorization callbacks * This enables OAuth endpoints like /.well-known/oauth-protected-resource */ oauth?: { /** * Callback handler for successful OAuth authorization * @param accessToken The access token received * @param refreshToken The refresh token if available * @param expiresIn Token expiration time in seconds */ onCallback?: (params: { accessToken: string; refreshToken?: string; expiresIn?: number; state?: string; }) => Promise | void; /** * Error handler for OAuth failures */ onError?: (error: Error, state?: string) => Promise | void; }; } /** * Internal configuration type with required fields except headers */ export type SSETransportConfigInternal = Required> & { headers?: Record; auth?: AuthConfig; cors?: CORSConfig; oauth?: SSETransportConfig['oauth']; host?: string; health?: HealthConfig; }; /** * Default CORS configuration */ export declare const DEFAULT_CORS_CONFIG: CORSConfig; /** * Default configuration values */ export declare const DEFAULT_SSE_CONFIG: SSETransportConfigInternal;