UNPKG

@aptos-labs/aptos-client

Version:

Client package for accessing the Aptos network API.

55 lines 2.03 kB
/** A parsed cookie with optional attributes. */ export interface Cookie { name: string; value: string; expires?: Date; sameSite?: "Lax" | "None" | "Strict"; secure?: boolean; httpOnly?: boolean; } /** * Minimal, origin-scoped cookie jar used by the Node and fetch entry points. * * @remarks * Cookies are keyed by origin (scheme + host + port). Expired cookies are * filtered out lazily when {@link getCookies} is called. The browser entry * point delegates cookie handling to the browser engine and does not use * this class. * * **Note:** A single module-level `CookieJar` instance is shared across all * requests in the same process. In multi-tenant server-side environments, * create a separate instance and pass it via {@link AptosClientRequest.cookieJar} * to avoid cross-request cookie leakage. */ export declare class CookieJar { private jar; static readonly MAX_COOKIES_PER_ORIGIN = 50; /** RFC 6265 §6.1 recommends at least 4096 bytes per cookie. */ static readonly MAX_COOKIE_SIZE = 8192; constructor(jar?: Map<string, Cookie[]>); /** * Store a `Set-Cookie` header value for the given URL's origin. * * @param url - The URL the response was received from. * @param cookieStr - Raw `Set-Cookie` header string. */ setCookie(url: URL, cookieStr: string): void; /** * Return all non-expired cookies for the given URL's origin. * * @param url - The URL to match cookies against. * @returns An array of {@link Cookie} objects (may be empty). */ getCookies(url: URL): Cookie[]; /** Remove all stored cookies. Useful for test isolation. */ clear(): void; /** * Parse a raw `Set-Cookie` header string into a {@link Cookie} object. * * @param str - Raw `Set-Cookie` header value. * @returns Parsed cookie. * @throws If the cookie is malformed or contains control characters. */ static parse(str: string): Cookie; } //# sourceMappingURL=cookieJar.d.ts.map