/
index.d.ts
102 lines (94 loc) · 2.48 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* The namespace's name is the same as the exported EggCookies,
* so you can solely use CookieGetOptions and CookieSetOptions
* when you use
* `import {CookieGetOptions, CookieSetOptions} from 'egg-cookies'`.
*/
declare namespace EggCookies {
interface DefaultCookieOptions {
/**
* Auto get and set `__Host` prefix cookie to adaptation CHIPS mode (The default value is false).
*/
autoChips?: boolean;
}
interface CookieGetOptions {
/**
* Whether to sign or not (The default value is true).
*/
signed?: boolean;
/**
* Encrypt the cookie's value or not (The default value is false).
*/
encrypt?: boolean;
}
interface CookieSetOptions {
/**
* The path for the cookie to be set in
*/
path?: string;
/**
* The domain for the cookie
*/
domain?: string;
/**
* Is overridable
*/
overwrite?: boolean;
/**
* Is the same site
*/
sameSite?: boolean | string;
/**
* Encrypt the cookie's value or not
*/
encrypt?: boolean;
/**
* Max age for browsers
*/
maxAge?: number;
/**
* Expire time
*/
expires?: Date;
/**
* Is for http only
*/
httpOnly?: boolean;
/**
* Encrypt the cookie's value or not
*/
secure?: boolean;
/**
* Is it signed or not.
*/
signed?: boolean;
/**
* Is it partitioned or not.
*/
partitioned?: boolean;
/**
* Remove unpartitioned same name cookie or not.
*/
removeUnpartitioned?: boolean;
}
class CookieError extends Error { }
}
declare class EggCookies {
constructor(ctx?: any, keys?: any, opts?: EggCookies.DefaultCookieOptions);
/**
* Get the Egg's cookies by name with optional options.
* @param name The Egg's cookie's unique name.
* @param opts Optional. The options for cookie's getting.
* @returns The cookie's value according to the specific name.
*/
get(name: string, opts?: EggCookies.CookieGetOptions): string;
/**
* Set the Egg's cookies by name with optional options.
* @param name The Egg cookie's unique name.
* @param value Optional. The Egg cookie's real value.
* @param opts Optional. The options for cookie's setting.
* @returns The current 'EggCookie' instance.
*/
set(name: string, value?: string | null, opts?: EggCookies.CookieSetOptions): this;
}
export = EggCookies;