/** * HTTP helpers shared by the kernel and the opt-in request lanes (idempotency, effect-ledger). Kept * in a leaf module (runtime-core aside, itself a leaf) so a lane can reuse them without importing the * server, and so the server can reuse them without pulling a lane's feature code into the base bundle. */ import { type ResponseResult } from "./runtime-core.js"; /** * Is `value` a destination that stays on this origin? * * True only for an absolute path: one leading `/`, never `//` (protocol-relative → another origin), * and free of any character a URL parser turns into an origin escape. A leading `/` alone is not * enough: under a special scheme `\` parses as `/`, and tab/CR/LF are STRIPPED before parsing, so * `/\evil.example` and `//evil.example` both resolve to the external host `evil.example` while * passing a `//` test. Rejecting CR/LF here also keeps a validated destination out of the * response-splitting sink it usually flows into. * * One implementation, because every caller is the same open-redirect gate: `redirect()` in * `@nifrajs/web`, the `redirectTo` of the `@nifrajs/auth` and `@nifrajs/better-auth` guards. Three * copies of a security predicate is three chances for one of them to be hardened alone. * * It answers about a PATH, not a URL: an absolute `https://this.host/x` is false even for the * current origin, because the whole point is that the value never got to name a host. */ export declare function isSameOriginPath(value: string): boolean; /** A uniform JSON error envelope: `{ ok: false, error }` at the given status. */ export declare function jsonError(status: number, error: string, headers?: Record): Response; /** * The same envelope as {@link jsonError}, as plain data rather than a built `Response`. * * This is what the framework's own renders - 404, 405, 422, the body caps, the timeouts, 500 - answer * with wherever the value flows into a lane's response wrapper, so an error costs what a handler's * plain return costs. Building the `Response` was measured as the dominant cost of answering early * (see `PlainRender`), and on the Node lane an error `Response` is worse still: it is untagged, so * the adapter cannot recognize its body and drains it through a Web stream, which is also why an * error answered chunked while an ordinary return carries a `content-length`. * * `jsonError` stays for the callers that genuinely need a `Response` object (mount bridges, the * lanes' own typed returns). */ export declare function plainError(status: number, error: string, headers?: Record): ResponseResult; export interface UrlParts { readonly pathname: string; readonly search: string; } export declare function urlPartsOf(url: string): UrlParts; export declare function pathnameOf(url: string): string; //# sourceMappingURL=http.d.ts.map