This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
53 lines (53 loc) · 1.96 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
export interface BaseCookieOptions {
/** How many seconds that this cookie should last. */
maxAge?: number;
/** Keep alive to a specified date or time. */
expires?: string | number | Date;
/** Honor same-site principle. */
sameSite?: "Strict" | "Lax";
/** Set cookie for a specified domain name. */
domain?: string;
/** Set cookie for a specified pathname. */
path?: string;
/** Only HTTP(s), not JavaScript, can access this cookie. */
httpOnly?: boolean;
/** The cookie won't be sent if not using HTTPS protocol. */
secure?: boolean;
}
export interface CookieOptions extends BaseCookieOptions {
name?: string;
value?: string;
}
export declare class Cookie implements CookieOptions {
name: string;
value: string;
maxAge: number;
expires: string | number | Date;
sameSite: "Strict" | "Lax";
domain: string;
path: string;
httpOnly: boolean;
secure: boolean;
/**
* @example new Cookie("username=Luna")
* @example new Cookie("username=Luna; Max-Age=120; HttpOnly")
* @example new Cookie("username", "Luna")
* @example new Cookie("username", "Luna", { maxAge: 120, httpOnly: true })
* @example new Cookie({ name: "username", value: "Luna", maxAge: 120, httpOnly: true })
*/
constructor(options: CookieOptions);
constructor(cookieStr: string);
constructor(name: string, value: string, options?: BaseCookieOptions);
/** Gets the serialized cookie string of the current instance. */
toString(): string;
}
/** Serializes an object or Cookie instance to a valid cookie string. */
export declare function serialize(data: Cookie | CookieOptions): string;
/** Parses a cookie string to a Cookie instance. */
export declare function parse(cookieStr: string): Cookie;
/**
* Parses a string as multiple cookies, useful for parsing
* `document.cookie` and `req.headers.cookie`.
*/
export declare function parseMany(str: string): Cookie[];
export default Cookie;