import type { ResponseBuilder } from './response.js'; export interface CookieOptions { /** Cookie `Domain` attribute. Validated against header-injection characters. */ domain?: string; /** Cookie `Path` attribute. Validated against header-injection characters. */ path?: string; /** Cookie `Expires` attribute (absolute date). */ expires?: Date; /** * Cookie `Max-Age` attribute, **in seconds**. Emitted whenever defined, so * `maxAge: 0` (expire immediately) is preserved. */ maxAge?: number; /** Cookie `HttpOnly` attribute - inaccessible to `document.cookie`. */ httpOnly?: boolean; /** * Cookie `Secure` attribute. Auto-enabled when `sameSite` is `'none'` and * `secure` is undefined; an explicit `secure: false` with `sameSite: 'none'` * throws a `TypeError`. */ secure?: boolean; /** Cookie `SameSite` attribute. */ sameSite?: 'strict' | 'lax' | 'none'; /** Cookie `Priority` attribute (Chromium extension). */ priority?: 'low' | 'medium' | 'high'; /** Cookie `Partitioned` attribute (CHIPS). */ partitioned?: boolean; } /** * Serialize a cookie name/value pair plus attributes into a `Set-Cookie` string. * * Low-level primitive: it does **not** default `path` - that default (`'/'`) * lives in `ResponseBuilder.cookie()`. The value is `encodeURIComponent`-encoded. * * @param name Cookie name, validated as an RFC 6265 token. * @param value Cookie value, URI-encoded automatically. * @param options Cookie attributes. `maxAge` is in **seconds**. * @throws {TypeError} If `name` is not a valid token, `path`/`domain` contains * CR/LF, `;`, or control characters, `maxAge` is not finite, `expires` is * an invalid `Date`, `sameSite` is `'none'` with an explicit `secure: false`, * or `partitioned` is set without a resolved `Secure`. */ export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string; /** * Parse a `Cookie` request header into a name -> value map. Values are * URI-decoded (falling back to the raw value on malformed input) and surrounding * double quotes are stripped. On duplicate names, the first occurrence wins. * * The returned object has a null prototype, so cookie names that collide with * `Object.prototype` members (`toString`, `constructor`, `__proto__`, ...) are * stored and read as honest own properties. */ export declare function parseCookieHeader(header: string): Record; /** * Ergonomic accessor for request cookies (read) and response cookies (write). * Exposed on `RequestContext` as the lazy `ctx.cookies` getter. Reads lazily * parse the request `Cookie` header and cache the result; writes delegate to the * `ResponseBuilder` so `Set-Cookie` headers survive the fast path. */ export declare class CookieJar { private readonly req; private readonly res; private _parsed; constructor(req: Request, res: ResponseBuilder); private parse; /** Return the value of an incoming cookie, or `undefined` if absent. */ get(name: string): string | undefined; /** * Return all incoming cookies as a name -> value map. This is a snapshot copy, * so mutating the result does not affect the jar's cached state. */ getAll(): Record; /** Whether an incoming cookie with the given name is present. */ has(name: string): boolean; /** Set a response cookie (delegates to `ResponseBuilder.cookie()`). */ set(name: string, value: string, options?: CookieOptions): this; /** Expire a response cookie (delegates to `ResponseBuilder.deleteCookie()`). */ delete(name: string, options?: { path?: string; domain?: string; }): this; } //# sourceMappingURL=cookies.d.ts.map