export interface CompressionOptions { /** Don't compress bodies smaller than this many bytes. Default `1024`. Enforced by peeking the body * (see below) since runtimes rarely expose `Content-Length` on a constructed `Response`. */ readonly threshold?: number; /** Decide whether a `Content-Type` is worth compressing. Default: text, JSON/+json, JS, XML/+xml, * NDJSON, wasm, SVG. Already-compressed media (images, video, archives) is skipped. */ readonly compressible?: (contentType: string) => boolean; } /** * Transparently **gzip** responses when the client sends `Accept-Encoding: gzip` and the body is a * compressible type larger than `threshold`. Uses the Web-standard `CompressionStream`, so it runs * on every nifra runtime including the edge; gzip is the one encoding `CompressionStream` * guarantees everywhere, so brotli isn't offered. * * Built on the portable `onResponseBody` tier for framework-serialized bytes, with a stream-safe raw * fallback for handler-returned/proxied Responses. The common JSON path stays on Node's direct * writer; raw streams are compressed incrementally without being fully buffered. * * Skips: clients that don't accept gzip, already-encoded responses, bodyless responses, * `Range` responses (206 / `Content-Range`), `Cache-Control: no-transform`, non-compressible * types, and bodies below `threshold` (gzip's ~20-byte overhead would enlarge them). Adds * `Vary: Accept-Encoding`. * * **Security (BREACH).** Compression makes the response length depend on its content, so a response * that mixes a secret with attacker-reflected input leaks the secret through the compressed size * (the BREACH class of attacks). This applies to any HTTP compression, not this middleware * specifically. Nifra's own CSRF tokens are HMAC-signed per session and safe to compress, but if a * response body reflects request input **and** carries a per-request secret, exclude that route via * `compressible`/route scoping, or split the secret and the reflection into separate responses. * * ```ts * app.use(compression()) * ``` */ export declare function compression(options?: CompressionOptions): import("@nifrajs/core").IdentityPlugin; //# sourceMappingURL=compression.d.ts.map