/** * Structured error payloads — and the sanitiser that makes them safe to send. * * An error body used to be `{ error: { code, message } }`, so any data the UI * needed had to be smuggled into the message: apps ended up parsing * `Checks failed: A, B` to find out which checks failed. `details` gives that * data a place of its own. * * It is written by the server and read by the client verbatim, which makes it a * channel — so it is bounded on every axis before it leaves: * * - **Plain data only.** Strings, finite numbers, booleans, `null`, arrays and * plain objects. A `Date` becomes its ISO string. Everything else is dropped: * functions, symbols, `undefined`, BigInt, `NaN`/`Infinity`, and every exotic * object — `Error` (a stack is an internal), `Map`/`Set`/`RegExp`, typed * arrays, and class instances (an ORM row would otherwise walk out through an * error body). Dropping rather than rejecting keeps a serialisation slip from * turning a handled 422 into a 500. * - **Acyclic and shallow.** A cycle is dropped where it closes; * nesting past {@link MAX_ERROR_DETAILS_DEPTH} is dropped. * - **Small.** Over {@link MAX_ERROR_DETAILS_BYTES} of serialised JSON the * whole payload is dropped, so an error can never become an exfiltration or * amplification channel. * - **Opt-in.** Only errors explicitly constructed with `details` have any. An * unexpected exception still becomes the neutral 500 with nothing attached. */ /** A structured error payload: plain JSON data, keyed by name. */ export type ErrorDetails = Record; /** Largest `details` payload sent to a client, in bytes of serialised JSON. */ export declare const MAX_ERROR_DETAILS_BYTES = 4096; /** Deepest array/object nesting kept; anything below it is dropped. */ export declare const MAX_ERROR_DETAILS_DEPTH = 8; /** * Makes a client-safe copy of a structured error payload, or returns * `undefined` when there is nothing safe to send (see the rules at the top of * this module). Never throws, and never returns the caller's own object. */ export declare function sanitizeErrorDetails(details: unknown): ErrorDetails | undefined;