import type { Cookie, CookieConfig } from './types.ts'; /** * Options accepted by CookieJar. * * `onChange` is fired after every mutation. The plugin uses this to * coalesce persistence via `queueMicrotask` — any burst of mutations * in a single tick produces exactly one adapter save. */ export interface CookieJarOptions extends Pick { onChange?: () => void; } /** * RFC 6265 §5.3 — In-memory cookie storage with eviction. * * Handles duplicate detection, expiry eviction, session cleanup, * and per-domain / total cookie limits. * * The jar is synchronous. Persistence (adapter.save) is fire-and-forget * and managed by the plugin layer via the `onChange` callback. */ export declare class CookieJar { constructor(config?: CookieJarOptions); /** * Seed the jar from a pre-existing cookie array (e.g., loaded from adapter). * Applies full set() semantics: eviction, dedup, size check. * * Fires `onChange` exactly once after the bulk import finishes so a * persistence backend does not see N redundant writes for one load. */ load(cookies: Cookie[]): void; /** * Retrieve cookies matching the given URL, per RFC 6265 §5.4. * * Updates `lastAccessTime` on every returned cookie (§5.4 step 3) and * fires `onChange` once if any match was retrieved. Non-retrieval calls * (no matches) do not mutate state and do not fire the callback. * * The `httpApi` flag from construction determines whether `httpOnly` * cookies are included: `true` for the HTTP request pipeline (default), * `false` for non-HTTP APIs such as `document.cookie`. */ get(url: URL): Cookie[]; /** * Store a cookie per RFC 6265 §5.3. * * - Cookies with expiryTime in the past are treated as deletion requests. * - Duplicate name+domain+path replaces old entry, preserving creationTime. * - Expired cookies are evicted before inserting. * - Per-domain and total limits are enforced after insert. * * Fires `onChange` after the mutation completes. */ set(cookie: Cookie): void; /** * Remove a specific cookie by domain + path + name. * * Fires `onChange` regardless of whether the cookie existed — callers * asking to delete a cookie is a meaningful event even when there is * nothing to remove. */ delete(domain: string, path: string, name: string): void; /** * Remove all cookies, or only those matching a specific domain. */ clear(domain?: string): void; /** * Remove all session cookies (persistentFlag = false). * Call this when a logical "session end" occurs. */ clearSession(): void; /** * Return all non-expired cookies without updating access times. * * Use this for inspection, serialization, or export. It does not fire * `onChange`. For request-time retrieval use `get(url)`. */ all(): Cookie[]; }