import { McpCorsOptions, McpTransportArmorOptions } from "./types.js"; //#region src/transport.d.ts declare const DEFAULT_MCP_ALLOW_HEADERS: readonly string[]; declare const DEFAULT_MCP_EXPOSE_HEADERS: readonly string[]; interface SurfaceListRequest { readonly protocolVersion?: string; } interface InboundMcpEnvelope { readonly era: "modern" | "legacy"; readonly method?: string; readonly protocolVersion?: string; readonly rawClientInfo?: unknown; readonly rawCapabilities?: unknown; readonly surfaceList: SurfaceListRequest | null; readonly isSubscriptionsListen: boolean; readonly subscriptionsListenId: string | number | null; /** Defined only when the entire HTTP body fit in 64 KiB and parsed as valid JSON. */ readonly parsedBody?: unknown; } declare function boundedBodyText(body: Request | Response, maxBytes: number): Promise<{ readonly text: string; readonly complete: boolean; } | null>; /** * Single-pass bounded (64 KiB) HTTP request classifier shared across transport * armor, `ctx.client` extraction, `onSurface` `tools/list` inspection, and * 2025 `initialize` session issuance. Clones `request` at most once per `POST` * and cancels the clone reader immediately if a `tools/call` body exceeds 64 KiB. */ declare function inspectInboundMcpEnvelope(request: Request): Promise; declare function jsonRpcPayloadFromResponseText(text: string): unknown; declare function isSuccessfulJsonRpcResponse(response: Response): Promise; /** * Immediate, spec-compliant refusal of unsupported SSE/listen-stream requests * so stateless Edge Functions and Cloud Run containers never hold open idle * streams until platform request timeouts. */ declare function applyMcpTransportArmor(request: Request, envelope: InboundMcpEnvelope, options?: McpTransportArmorOptions): Response | undefined; /** Case-insensitive comma-token union for `Access-Control-Expose-Headers` and `Vary`. */ declare function mergeHeaderTokens(existing: string | null | undefined, additions: readonly string[]): string; declare function mergeExposedHeaders(existing: string | null | undefined, extra?: readonly string[]): string; interface EvaluatedCorsOrigin { readonly hasOriginHeader: boolean; readonly allowed: boolean; readonly allowOriginHeader?: string; readonly varyOrigin: boolean; } declare function evaluateMcpCorsOrigin(request: Request, options: McpCorsOptions): EvaluatedCorsOrigin; declare function forbiddenOriginResponse(): Response; /** * Evaluate `Origin` and answer `OPTIONS` CORS preflights before auth runs. * Returns a `403` `Response` for disallowed or `"null"` origins and a `204` * `Response` for valid `OPTIONS` preflights; returns `undefined` to continue. */ declare function applyMcpCorsPreflight(request: Request, options: McpCorsOptions): { readonly shortCircuit?: Response; readonly evaluated: EvaluatedCorsOrigin; }; /** Stamp CORS origin and merged `Access-Control-Expose-Headers` onto an outbound response. */ declare function decorateMcpCorsResponse(response: Response, evaluated: EvaluatedCorsOrigin, options?: McpCorsOptions): Response; //#endregion export { DEFAULT_MCP_ALLOW_HEADERS, DEFAULT_MCP_EXPOSE_HEADERS, EvaluatedCorsOrigin, InboundMcpEnvelope, SurfaceListRequest, applyMcpCorsPreflight, applyMcpTransportArmor, boundedBodyText, decorateMcpCorsResponse, evaluateMcpCorsOrigin, forbiddenOriginResponse, inspectInboundMcpEnvelope, isSuccessfulJsonRpcResponse, jsonRpcPayloadFromResponseText, mergeExposedHeaders, mergeHeaderTokens }; //# sourceMappingURL=transport.d.ts.map