export type MaybePromise = T | Promise; import type { NodeResponseContext } from "@nifrajs/core/server"; import { parseCookies as parseCoreCookies } from "@nifrajs/core/server"; export declare const SAFE_METHODS: Set; export declare function jsonError(status: number, error: string, headers?: Record): Response; /** Shared with core so auth/CSRF middleware gets the allocation-light cookie scanner too. */ export declare const parseCookies: typeof parseCoreCookies; export declare function quotedHeaderValue(value: string): string; export declare function utf8Bytes(value: string): Uint8Array; export declare function secretBytes(secret: string | Uint8Array, label: string): Uint8Array; export declare function sha256(input: string | Uint8Array): Promise>; export declare function timingSafeEqualBytes(a: Uint8Array, b: Uint8Array): boolean; export declare function timingSafeEqualString(a: string, b: string): Promise; export declare function base64UrlEncode(bytes: ArrayBuffer | Uint8Array): string; export declare function base64UrlDecode(input: string): Uint8Array | null; export declare function decodeBase64(input: string): Uint8Array | null; export declare function importHmacKey(secret: string | Uint8Array, hash?: string): Promise; export declare function hmacSha256(input: string, secret: string | Uint8Array): Promise; export declare function verifyHmacSha256(input: string, signature: string, secret: string | Uint8Array): Promise; /** * Apply header mutations to a response, in place when possible. Framework-built responses * (`new Response`, `Response.json`) have mutable headers across every runtime - so the common path * mutates `res` directly and returns it, allocating nothing. Only an *immutable*-headers response * (`Response.redirect()`/`Response.error()`, or a proxied `fetch()` response on Node/Deno/workerd - * never on Bun) makes `.set`/`.append` throw; that path clones into a fresh `Headers` + `Response`, * exactly the old always-clone behavior. `apply` runs once either way (immutability is all-or-nothing * - the first mutation throws before any partial change), so a mutation chain is safe to pass. */ export declare function withHeaders(res: Response, apply: (headers: Headers) => void): Response; /** * Set one Node-direct response header without constructing a Web Response. `name` must already be * the lowercase wire spelling - the record documents that contract, and it is what `Headers` emits * on every other runtime. * * The outcome's own record is used AS-IS. Re-homing it into a null-prototype object - the obvious * way to make `__proto__` inert - demotes it to V8's dictionary mode for the rest of the request, * and everything downstream then pays dictionary lookups on the response hot path: the direct * writer's key walk, and Node's own `_storeHeader` walk over every name. Values here are strings and * string arrays, so assigning one through the inherited `__proto__` setter is a spec-level no-op * rather than pollution; the single name that setter would swallow is defined as an own data * property instead. Same trade core's portable header view makes over the same record. */ export declare function setNodeHeader(res: NodeResponseContext, name: string, value: string | readonly string[]): void; //# sourceMappingURL=_utils.d.ts.map