1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export const version: string;
|
10 |
|
11 | export const PrefixSecurityEnum: Readonly<{
|
12 | DISABLED: string;
|
13 | SILENT: string;
|
14 | STRICT: string;
|
15 | }>;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export function parseDate(string: string): Date;
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export function formatDate(date: Date): string;
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export function canonicalDomain(str: string): string;
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export function domainMatch(str: string, domStr: string, canonicalize?: boolean): boolean;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export function defaultPath(path: string): string;
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | export function pathMatch(reqPath: string, cookiePath: string): boolean;
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export function parse(cookieString: string, options?: Cookie.ParseOptions): Cookie | undefined;
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | export function fromJSON(string: string): Cookie;
|
71 |
|
72 | export function getPublicSuffix(hostname: string): string | null;
|
73 |
|
74 | export function cookieCompare(a: Cookie, b: Cookie): number;
|
75 |
|
76 | export function permuteDomain(domain: string, allowSpecialUseDomain?: boolean): string[];
|
77 |
|
78 | export function permutePath(path: string): string[];
|
79 |
|
80 | export class Cookie {
|
81 | static parse(cookieString: string, options?: Cookie.ParseOptions): Cookie | undefined;
|
82 |
|
83 | static fromJSON(strOrObj: string | object): Cookie | null;
|
84 |
|
85 | constructor(properties?: Cookie.Properties);
|
86 |
|
87 | key: string;
|
88 | value: string;
|
89 | expires: Date | 'Infinity';
|
90 | maxAge: number | 'Infinity' | '-Infinity';
|
91 | domain: string | null;
|
92 | path: string | null;
|
93 | secure: boolean;
|
94 | httpOnly: boolean;
|
95 | extensions: string[] | null;
|
96 | creation: Date | null;
|
97 | creationIndex: number;
|
98 |
|
99 | hostOnly: boolean | null;
|
100 | pathIsDefault: boolean | null;
|
101 | lastAccessed: Date | null;
|
102 | sameSite: string;
|
103 |
|
104 | toString(): string;
|
105 |
|
106 | cookieString(): string;
|
107 |
|
108 | setExpires(exp: Date | string): void;
|
109 |
|
110 | setMaxAge(number: number): void;
|
111 |
|
112 | expiryTime(now?: number): number;
|
113 |
|
114 | expiryDate(now?: number): Date;
|
115 |
|
116 | TTL(now?: Date): number | typeof Infinity;
|
117 |
|
118 | isPersistent(): boolean;
|
119 |
|
120 | canonicalizedDomain(): string | null;
|
121 |
|
122 | cdomain(): string | null;
|
123 |
|
124 | inspect(): string;
|
125 |
|
126 | toJSON(): { [key: string]: any; };
|
127 |
|
128 | clone(): Cookie;
|
129 |
|
130 | validate(): boolean | string;
|
131 | }
|
132 |
|
133 | export namespace Cookie {
|
134 | interface ParseOptions {
|
135 | loose?: boolean | undefined;
|
136 | }
|
137 |
|
138 | interface Properties {
|
139 | key?: string | undefined;
|
140 | value?: string | undefined;
|
141 | expires?: Date | undefined;
|
142 | maxAge?: number | 'Infinity' | '-Infinity' | undefined;
|
143 | domain?: string | undefined;
|
144 | path?: string | undefined;
|
145 | secure?: boolean | undefined;
|
146 | httpOnly?: boolean | undefined;
|
147 | extensions?: string[] | undefined;
|
148 | creation?: Date | undefined;
|
149 | creationIndex?: number | undefined;
|
150 |
|
151 | hostOnly?: boolean | undefined;
|
152 | pathIsDefault?: boolean | undefined;
|
153 | lastAccessed?: Date | undefined;
|
154 | sameSite?: string | undefined;
|
155 | }
|
156 |
|
157 | interface Serialized {
|
158 | [key: string]: any;
|
159 | }
|
160 | }
|
161 |
|
162 | export class CookieJar {
|
163 | static deserialize(serialized: CookieJar.Serialized | string, store?: Store): Promise<CookieJar>;
|
164 | static deserialize(serialized: CookieJar.Serialized | string, store: Store, cb: (err: Error | null, object: CookieJar) => void): void;
|
165 | static deserialize(serialized: CookieJar.Serialized | string, cb: (err: Error | null, object: CookieJar) => void): void;
|
166 |
|
167 | static deserializeSync(serialized: CookieJar.Serialized | string, store?: Store): CookieJar;
|
168 |
|
169 | static fromJSON(string: string): CookieJar;
|
170 |
|
171 | constructor(store?: Store, options?: CookieJar.Options);
|
172 |
|
173 | setCookie(cookieOrString: Cookie | string, currentUrl: string, options?: CookieJar.SetCookieOptions): Promise<Cookie>;
|
174 | setCookie(cookieOrString: Cookie | string, currentUrl: string, options: CookieJar.SetCookieOptions, cb: (err: Error | null, cookie: Cookie) => void): void;
|
175 | setCookie(cookieOrString: Cookie | string, currentUrl: string, cb: (err: Error | null, cookie: Cookie) => void): void;
|
176 |
|
177 | setCookieSync(cookieOrString: Cookie | string, currentUrl: string, options?: CookieJar.SetCookieOptions): Cookie;
|
178 |
|
179 | getCookies(currentUrl: string, options?: CookieJar.GetCookiesOptions): Promise<Cookie[]>;
|
180 | getCookies(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: Cookie[]) => void): void;
|
181 | getCookies(currentUrl: string, cb: (err: Error | null, cookies: Cookie[]) => void): void;
|
182 |
|
183 | getCookiesSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): Cookie[];
|
184 |
|
185 | getCookieString(currentUrl: string, options?: CookieJar.GetCookiesOptions): Promise<string>;
|
186 | getCookieString(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: string) => void): void;
|
187 | getCookieString(currentUrl: string, cb: (err: Error | null, cookies: string) => void): void;
|
188 |
|
189 | getCookieStringSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): string;
|
190 |
|
191 | getSetCookieStrings(currentUrl: string, options?: CookieJar.GetCookiesOptions): Promise<string[]>;
|
192 | getSetCookieStrings(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: string[]) => void): void;
|
193 | getSetCookieStrings(currentUrl: string, cb: (err: Error | null, cookies: string[]) => void): void;
|
194 |
|
195 | getSetCookieStringsSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): string[];
|
196 |
|
197 | serialize(): Promise<CookieJar.Serialized>;
|
198 | serialize(cb: (err: Error | null, serializedObject: CookieJar.Serialized) => void): void;
|
199 |
|
200 | serializeSync(): CookieJar.Serialized;
|
201 |
|
202 | toJSON(): CookieJar.Serialized;
|
203 |
|
204 | clone(store?: Store): Promise<CookieJar>;
|
205 | clone(store: Store, cb: (err: Error | null, newJar: CookieJar) => void): void;
|
206 | clone(cb: (err: Error | null, newJar: CookieJar) => void): void;
|
207 |
|
208 | cloneSync(store?: Store): CookieJar;
|
209 |
|
210 | removeAllCookies(): Promise<void>;
|
211 | removeAllCookies(cb: (err: Error | null) => void): void;
|
212 |
|
213 | removeAllCookiesSync(): void;
|
214 | }
|
215 |
|
216 | export namespace CookieJar {
|
217 | interface Options {
|
218 | allowSpecialUseDomain?: boolean | undefined;
|
219 | looseMode?: boolean | undefined;
|
220 | rejectPublicSuffixes?: boolean | undefined;
|
221 | prefixSecurity?: string | undefined;
|
222 | }
|
223 |
|
224 | interface SetCookieOptions {
|
225 | http?: boolean | undefined;
|
226 | secure?: boolean | undefined;
|
227 | now?: Date | undefined;
|
228 | ignoreError?: boolean | undefined;
|
229 | }
|
230 |
|
231 | interface GetCookiesOptions {
|
232 | http?: boolean | undefined;
|
233 | secure?: boolean | undefined;
|
234 | now?: Date | undefined;
|
235 | expire?: boolean | undefined;
|
236 | allPaths?: boolean | undefined;
|
237 | }
|
238 |
|
239 | interface Serialized {
|
240 | version: string;
|
241 | storeType: string;
|
242 | rejectPublicSuffixes: boolean;
|
243 | cookies: Cookie.Serialized[];
|
244 | }
|
245 | }
|
246 |
|
247 | export abstract class Store {
|
248 | synchronous: boolean;
|
249 |
|
250 | findCookie(domain: string, path: string, key: string, cb: (err: Error | null, cookie: Cookie | null) => void): void;
|
251 |
|
252 | findCookies(domain: string, path: string, allowSpecialUseDomain: boolean, cb: (err: Error | null, cookie: Cookie[]) => void): void;
|
253 |
|
254 | putCookie(cookie: Cookie, cb: (err: Error | null) => void): void;
|
255 |
|
256 | updateCookie(oldCookie: Cookie, newCookie: Cookie, cb: (err: Error | null) => void): void;
|
257 |
|
258 | removeCookie(domain: string, path: string, key: string, cb: (err: Error | null) => void): void;
|
259 |
|
260 | removeCookies(domain: string, path: string, cb: (err: Error | null) => void): void;
|
261 |
|
262 | getAllCookies(cb: (err: Error | null, cookie: Cookie[]) => void): void;
|
263 | }
|
264 |
|
265 | export class MemoryCookieStore extends Store { }
|