UNPKG

@sigiljs/sigil

Version:

TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating

39 lines (38 loc) 1.48 kB
type SameSite = "strict" | "lax" | "none"; type Priority = "low" | "medium" | "high"; type NoSemicolon<T extends string> = T extends `${string};${string}` ? never : T; type NonEmpty<T extends string> = T extends "" ? never : T; /** RFC6265 */ export type CookieName<T extends string> = NonEmpty<T> extends never ? never : T extends `${string};${string}` | `${string}=${string}` ? never : T; export type CookieValue<T extends string | null> = T extends string ? (NonEmpty<T> extends never ? never : NoSemicolon<T>) : null; export interface CookieOptions { /** Absolute expiration date */ expires?: Date; /** Max-Age in seconds (integer) */ maxAge?: number; domain?: string; path?: string; secure?: boolean; httpOnly?: boolean; sameSite?: SameSite; priority?: Priority; /** Chromium Partitioned cookies */ partitioned?: boolean; } export default class Cookie<N extends string, V extends string | null> { private _precompiled?; constructor(name: CookieName<N>, value: CookieValue<V>, options?: Readonly<CookieOptions>); private _name; get name(): CookieName<N>; private _value; get value(): CookieValue<V>; private _options; get options(): Readonly<CookieOptions>; compile(): string; setOptions(options: Readonly<Partial<CookieOptions>>): void; setValue(value: CookieValue<V>): void; setName(name: CookieName<N>): void; private encodeCookieValue; private capitalize; } export {};