UNPKG

28.6 kBTypeScriptView Raw
1import { Store } from '../store';
2import { Cookie } from './cookie';
3import { Callback, ErrorCallback, Nullable } from '../utils';
4import { SerializedCookieJar } from './constants';
5/**
6 * Configuration options used when calling `CookieJar.setCookie(...)`
7 * @public
8 */
9export interface SetCookieOptions {
10 /**
11 * Controls if a cookie string should be parsed using `loose` mode or not.
12 * See {@link Cookie.parse} and {@link ParseCookieOptions} for more details.
13 *
14 * Defaults to `false` if not provided.
15 */
16 loose?: boolean | undefined;
17 /**
18 * Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon storage.
19 *
20 * - `'strict'` - If the request is on the same "site for cookies" (see the RFC draft
21 * for more information), pass this option to add a layer of defense against CSRF.
22 *
23 * - `'lax'` - If the request is from another site, but is directly because of navigation
24 * by the user, such as, `<link type=prefetch>` or `<a href="...">`, then use `lax`.
25 *
26 * - `'none'` - This indicates a cross-origin request.
27 *
28 * - `undefined` - SameSite is not be enforced! This can be a valid use-case for when
29 * CSRF isn't in the threat model of the system being built.
30 *
31 * Defaults to `undefined` if not provided.
32 *
33 * @remarks
34 * - It is highly recommended that you read {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02##section-8.8 | RFC6265bis - Section 8.8}
35 * which discusses security considerations and defence on SameSite cookies in depth.
36 */
37 sameSiteContext?: 'strict' | 'lax' | 'none' | undefined;
38 /**
39 * Silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option.
40 *
41 * Defaults to `false` if not provided.
42 */
43 ignoreError?: boolean | undefined;
44 /**
45 * Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies.
46 *
47 * Defaults to `true` if not provided.
48 */
49 http?: boolean | undefined;
50 /**
51 * Forces the cookie creation and access time of cookies to this value when stored.
52 *
53 * Defaults to `Date.now()` if not provided.
54 */
55 now?: Date | undefined;
56}
57/**
58 * Configuration options used when calling `CookieJar.getCookies(...)`.
59 * @public
60 */
61export interface GetCookiesOptions {
62 /**
63 * Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies.
64 *
65 * Defaults to `true` if not provided.
66 */
67 http?: boolean | undefined;
68 /**
69 * Perform `expiry-time` checking of cookies and asynchronously remove expired
70 * cookies from the store.
71 *
72 * @remarks
73 * - Using `false` returns expired cookies and does not remove them from the
74 * store which is potentially useful for replaying `Set-Cookie` headers.
75 *
76 * Defaults to `true` if not provided.
77 */
78 expire?: boolean | undefined;
79 /**
80 * If `true`, do not scope cookies by path. If `false`, then RFC-compliant path scoping will be used.
81 *
82 * @remarks
83 * - May not be supported by the underlying store (the default {@link MemoryCookieStore} supports it).
84 *
85 * Defaults to `false` if not provided.
86 */
87 allPaths?: boolean | undefined;
88 /**
89 * Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon retrieval.
90 *
91 * - `'strict'` - If the request is on the same "site for cookies" (see the RFC draft
92 * for more information), pass this option to add a layer of defense against CSRF.
93 *
94 * - `'lax'` - If the request is from another site, but is directly because of navigation
95 * by the user, such as, `<link type=prefetch>` or `<a href="...">`, then use `lax`.
96 *
97 * - `'none'` - This indicates a cross-origin request.
98 *
99 * - `undefined` - SameSite is not be enforced! This can be a valid use-case for when
100 * CSRF isn't in the threat model of the system being built.
101 *
102 * Defaults to `undefined` if not provided.
103 *
104 * @remarks
105 * - It is highly recommended that you read {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02##section-8.8 | RFC6265bis - Section 8.8}
106 * which discusses security considerations and defence on SameSite cookies in depth.
107 */
108 sameSiteContext?: 'none' | 'lax' | 'strict' | undefined;
109 /**
110 * Flag to indicate if the returned cookies should be sorted or not.
111 *
112 * Defaults to `undefined` if not provided.
113 */
114 sort?: boolean | undefined;
115}
116/**
117 * Configuration settings to be used with a {@link CookieJar}.
118 * @public
119 */
120export interface CreateCookieJarOptions {
121 /**
122 * Reject cookies that match those defined in the {@link https://publicsuffix.org/ | Public Suffix List} (e.g.; domains like "com" and "co.uk").
123 *
124 * Defaults to `true` if not specified.
125 */
126 rejectPublicSuffixes?: boolean | undefined;
127 /**
128 * Accept malformed cookies like `bar` and `=bar`, which have an implied empty name but are not RFC-compliant.
129 *
130 * Defaults to `false` if not specified.
131 */
132 looseMode?: boolean | undefined;
133 /**
134 * Controls how cookie prefixes are handled. See {@link PrefixSecurityEnum}.
135 *
136 * Defaults to `silent` if not specified.
137 */
138 prefixSecurity?: 'strict' | 'silent' | 'unsafe-disabled' | undefined;
139 /**
140 * Accepts {@link https://datatracker.ietf.org/doc/html/rfc6761 | special-use domains } such as `local`.
141 * This is not in the standard, but is used sometimes on the web and is accepted by most browsers. It is
142 * also useful for testing purposes.
143 *
144 * Defaults to `true` if not specified.
145 */
146 allowSpecialUseDomain?: boolean | undefined;
147}
148/**
149 * A CookieJar is for storage and retrieval of {@link Cookie} objects as defined in
150 * {@link https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3 | RFC6265 - Section 5.3}.
151 *
152 * It also supports a pluggable persistence layer via {@link Store}.
153 * @public
154 */
155export declare class CookieJar {
156 private readonly rejectPublicSuffixes;
157 private readonly enableLooseMode;
158 private readonly allowSpecialUseDomain;
159 /**
160 * The configured {@link Store} for the {@link CookieJar}.
161 */
162 readonly store: Store;
163 /**
164 * The configured {@link PrefixSecurityEnum} value for the {@link CookieJar}.
165 */
166 readonly prefixSecurity: string;
167 /**
168 * Creates a new `CookieJar` instance.
169 *
170 * @remarks
171 * - If a custom store is not passed to the constructor, an in-memory store ({@link MemoryCookieStore} will be created and used.
172 * - If a boolean value is passed as the `options` parameter, this is equivalent to passing `{ rejectPublicSuffixes: <value> }`
173 *
174 * @param store - a custom {@link Store} implementation (defaults to {@link MemoryCookieStore})
175 * @param options - configures how cookies are processed by the cookie jar
176 */
177 constructor(store?: Nullable<Store>, options?: CreateCookieJarOptions | boolean);
178 private callSync;
179 /**
180 * Attempt to set the {@link Cookie} in the {@link CookieJar}.
181 *
182 * @remarks
183 * - If successfully persisted, the {@link Cookie} will have updated
184 * {@link Cookie.creation}, {@link Cookie.lastAccessed} and {@link Cookie.hostOnly}
185 * properties.
186 *
187 * - As per the RFC, the {@link Cookie.hostOnly} flag is set if there was no `Domain={value}`
188 * atttribute on the cookie string. The {@link Cookie.domain} property is set to the
189 * fully-qualified hostname of `currentUrl` in this case. Matching this cookie requires an
190 * exact hostname match (not a {@link domainMatch} as per usual)
191 *
192 * @param cookie - The cookie object or cookie string to store. A string value will be parsed into a cookie using {@link Cookie.parse}.
193 * @param url - The domain to store the cookie with.
194 * @param callback - A function to call after a cookie has been successfully stored.
195 * @public
196 */
197 setCookie(cookie: string | Cookie, url: string | URL, callback: Callback<Cookie | undefined>): void;
198 /**
199 * Attempt to set the {@link Cookie} in the {@link CookieJar}.
200 *
201 * @remarks
202 * - If successfully persisted, the {@link Cookie} will have updated
203 * {@link Cookie.creation}, {@link Cookie.lastAccessed} and {@link Cookie.hostOnly}
204 * properties.
205 *
206 * - As per the RFC, the {@link Cookie.hostOnly} flag is set if there was no `Domain={value}`
207 * atttribute on the cookie string. The {@link Cookie.domain} property is set to the
208 * fully-qualified hostname of `currentUrl` in this case. Matching this cookie requires an
209 * exact hostname match (not a {@link domainMatch} as per usual)
210 *
211 * @param cookie - The cookie object or cookie string to store. A string value will be parsed into a cookie using {@link Cookie.parse}.
212 * @param url - The domain to store the cookie with.
213 * @param options - Configuration settings to use when storing the cookie.
214 * @param callback - A function to call after a cookie has been successfully stored.
215 * @public
216 */
217 setCookie(cookie: string | Cookie, url: string | URL, options: SetCookieOptions, callback: Callback<Cookie | undefined>): void;
218 /**
219 * Attempt to set the {@link Cookie} in the {@link CookieJar}.
220 *
221 * @remarks
222 * - If successfully persisted, the {@link Cookie} will have updated
223 * {@link Cookie.creation}, {@link Cookie.lastAccessed} and {@link Cookie.hostOnly}
224 * properties.
225 *
226 * - As per the RFC, the {@link Cookie.hostOnly} flag is set if there was no `Domain={value}`
227 * atttribute on the cookie string. The {@link Cookie.domain} property is set to the
228 * fully-qualified hostname of `currentUrl` in this case. Matching this cookie requires an
229 * exact hostname match (not a {@link domainMatch} as per usual)
230 *
231 * @param cookie - The cookie object or cookie string to store. A string value will be parsed into a cookie using {@link Cookie.parse}.
232 * @param url - The domain to store the cookie with.
233 * @param options - Configuration settings to use when storing the cookie.
234 * @public
235 */
236 setCookie(cookie: string | Cookie, url: string | URL, options?: SetCookieOptions): Promise<Cookie | undefined>;
237 /**
238 * @internal No doc because this is an overload that supports the implementation
239 */
240 setCookie(cookie: string | Cookie, url: string | URL, options: SetCookieOptions | Callback<Cookie | undefined>, callback?: Callback<Cookie | undefined>): unknown;
241 /**
242 * Synchronously attempt to set the {@link Cookie} in the {@link CookieJar}.
243 *
244 * <strong>Note:</strong> Only works if the configured {@link Store} is also synchronous.
245 *
246 * @remarks
247 * - If successfully persisted, the {@link Cookie} will have updated
248 * {@link Cookie.creation}, {@link Cookie.lastAccessed} and {@link Cookie.hostOnly}
249 * properties.
250 *
251 * - As per the RFC, the {@link Cookie.hostOnly} flag is set if there was no `Domain={value}`
252 * atttribute on the cookie string. The {@link Cookie.domain} property is set to the
253 * fully-qualified hostname of `currentUrl` in this case. Matching this cookie requires an
254 * exact hostname match (not a {@link domainMatch} as per usual)
255 *
256 * @param cookie - The cookie object or cookie string to store. A string value will be parsed into a cookie using {@link Cookie.parse}.
257 * @param url - The domain to store the cookie with.
258 * @param options - Configuration settings to use when storing the cookie.
259 * @public
260 */
261 setCookieSync(cookie: string | Cookie, url: string, options?: SetCookieOptions): Cookie | undefined;
262 /**
263 * Retrieve the list of cookies that can be sent in a Cookie header for the
264 * current URL.
265 *
266 * @remarks
267 * - The array of cookies returned will be sorted according to {@link cookieCompare}.
268 *
269 * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
270 *
271 * @param url - The domain to store the cookie with.
272 */
273 getCookies(url: string): Promise<Cookie[]>;
274 /**
275 * Retrieve the list of cookies that can be sent in a Cookie header for the
276 * current URL.
277 *
278 * @remarks
279 * - The array of cookies returned will be sorted according to {@link cookieCompare}.
280 *
281 * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
282 *
283 * @param url - The domain to store the cookie with.
284 * @param callback - A function to call after a cookie has been successfully retrieved.
285 */
286 getCookies(url: string, callback: Callback<Cookie[]>): void;
287 /**
288 * Retrieve the list of cookies that can be sent in a Cookie header for the
289 * current URL.
290 *
291 * @remarks
292 * - The array of cookies returned will be sorted according to {@link cookieCompare}.
293 *
294 * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
295 *
296 * @param url - The domain to store the cookie with.
297 * @param options - Configuration settings to use when retrieving the cookies.
298 * @param callback - A function to call after a cookie has been successfully retrieved.
299 */
300 getCookies(url: string | URL, options: GetCookiesOptions | undefined, callback: Callback<Cookie[]>): void;
301 /**
302 * Retrieve the list of cookies that can be sent in a Cookie header for the
303 * current URL.
304 *
305 * @remarks
306 * - The array of cookies returned will be sorted according to {@link cookieCompare}.
307 *
308 * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
309 *
310 * @param url - The domain to store the cookie with.
311 * @param options - Configuration settings to use when retrieving the cookies.
312 */
313 getCookies(url: string | URL, options?: GetCookiesOptions): Promise<Cookie[]>;
314 /**
315 * @internal No doc because this is an overload that supports the implementation
316 */
317 getCookies(url: string | URL, options: GetCookiesOptions | undefined | Callback<Cookie[]>, callback?: Callback<Cookie[]>): unknown;
318 /**
319 * Synchronously retrieve the list of cookies that can be sent in a Cookie header for the
320 * current URL.
321 *
322 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
323 *
324 * @remarks
325 * - The array of cookies returned will be sorted according to {@link cookieCompare}.
326 *
327 * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
328 *
329 * @param url - The domain to store the cookie with.
330 * @param options - Configuration settings to use when retrieving the cookies.
331 */
332 getCookiesSync(url: string, options?: GetCookiesOptions): Cookie[];
333 /**
334 * Accepts the same options as `.getCookies()` but returns a string suitable for a
335 * `Cookie` header rather than an Array.
336 *
337 * @param url - The domain to store the cookie with.
338 * @param options - Configuration settings to use when retrieving the cookies.
339 * @param callback - A function to call after the `Cookie` header string has been created.
340 */
341 getCookieString(url: string, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
342 /**
343 * Accepts the same options as `.getCookies()` but returns a string suitable for a
344 * `Cookie` header rather than an Array.
345 *
346 * @param url - The domain to store the cookie with.
347 * @param callback - A function to call after the `Cookie` header string has been created.
348 */
349 getCookieString(url: string, callback: Callback<string | undefined>): void;
350 /**
351 * Accepts the same options as `.getCookies()` but returns a string suitable for a
352 * `Cookie` header rather than an Array.
353 *
354 * @param url - The domain to store the cookie with.
355 * @param options - Configuration settings to use when retrieving the cookies.
356 */
357 getCookieString(url: string, options?: GetCookiesOptions): Promise<string>;
358 /**
359 * @internal No doc because this is an overload that supports the implementation
360 */
361 getCookieString(url: string, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
362 /**
363 * Synchronous version of `.getCookieString()`. Accepts the same options as `.getCookies()` but returns a string suitable for a
364 * `Cookie` header rather than an Array.
365 *
366 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
367 *
368 * @param url - The domain to store the cookie with.
369 * @param options - Configuration settings to use when retrieving the cookies.
370 */
371 getCookieStringSync(url: string, options?: GetCookiesOptions): string;
372 /**
373 * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
374 * as `.getCookies()`.
375 *
376 * @param url - The domain to store the cookie with.
377 * @param callback - A function to call after the `Set-Cookie` header strings have been created.
378 */
379 getSetCookieStrings(url: string, callback: Callback<string[] | undefined>): void;
380 /**
381 * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
382 * as `.getCookies()`.
383 *
384 * @param url - The domain to store the cookie with.
385 * @param options - Configuration settings to use when retrieving the cookies.
386 * @param callback - A function to call after the `Set-Cookie` header strings have been created.
387 */
388 getSetCookieStrings(url: string, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
389 /**
390 * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
391 * as `.getCookies()`.
392 *
393 * @param url - The domain to store the cookie with.
394 * @param options - Configuration settings to use when retrieving the cookies.
395 */
396 getSetCookieStrings(url: string, options?: GetCookiesOptions): Promise<string[] | undefined>;
397 /**
398 * @internal No doc because this is an overload that supports the implementation
399 */
400 getSetCookieStrings(url: string, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
401 /**
402 * Synchronous version of `.getSetCookieStrings()`. Returns an array of strings suitable for `Set-Cookie` headers.
403 * Accepts the same options as `.getCookies()`.
404 *
405 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
406 *
407 * @param url - The domain to store the cookie with.
408 * @param options - Configuration settings to use when retrieving the cookies.
409 */
410 getSetCookieStringsSync(url: string, options?: GetCookiesOptions): string[];
411 /**
412 * Serialize the CookieJar if the underlying store supports `.getAllCookies`.
413 * @param callback - A function to call after the CookieJar has been serialized
414 */
415 serialize(callback: Callback<SerializedCookieJar>): void;
416 /**
417 * Serialize the CookieJar if the underlying store supports `.getAllCookies`.
418 */
419 serialize(): Promise<SerializedCookieJar>;
420 /**
421 * Serialize the CookieJar if the underlying store supports `.getAllCookies`.
422 *
423 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
424 */
425 serializeSync(): SerializedCookieJar | undefined;
426 /**
427 * Alias of {@link CookieJar.serializeSync}. Allows the cookie to be serialized
428 * with `JSON.stringify(cookieJar)`.
429 */
430 toJSON(): SerializedCookieJar | undefined;
431 /**
432 * Use the class method CookieJar.deserialize instead of calling this directly
433 * @internal
434 */
435 _importCookies(serialized: unknown, callback: Callback<CookieJar>): void;
436 /**
437 * @internal
438 */
439 _importCookiesSync(serialized: unknown): void;
440 /**
441 * Produces a deep clone of this CookieJar. Modifications to the original do
442 * not affect the clone, and vice versa.
443 *
444 * @remarks
445 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
446 *
447 * - Transferring between store types is supported so long as the source
448 * implements `.getAllCookies()` and the destination implements `.putCookie()`.
449 *
450 * @param callback - A function to call when the CookieJar is cloned.
451 */
452 clone(callback: Callback<CookieJar>): void;
453 /**
454 * Produces a deep clone of this CookieJar. Modifications to the original do
455 * not affect the clone, and vice versa.
456 *
457 * @remarks
458 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
459 *
460 * - Transferring between store types is supported so long as the source
461 * implements `.getAllCookies()` and the destination implements `.putCookie()`.
462 *
463 * @param newStore - The target {@link Store} to clone cookies into.
464 * @param callback - A function to call when the CookieJar is cloned.
465 */
466 clone(newStore: Store, callback: Callback<CookieJar>): void;
467 /**
468 * Produces a deep clone of this CookieJar. Modifications to the original do
469 * not affect the clone, and vice versa.
470 *
471 * @remarks
472 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
473 *
474 * - Transferring between store types is supported so long as the source
475 * implements `.getAllCookies()` and the destination implements `.putCookie()`.
476 *
477 * @param newStore - The target {@link Store} to clone cookies into.
478 */
479 clone(newStore?: Store): Promise<CookieJar>;
480 /**
481 * @internal
482 */
483 _cloneSync(newStore?: Store): CookieJar | undefined;
484 /**
485 * Produces a deep clone of this CookieJar. Modifications to the original do
486 * not affect the clone, and vice versa.
487 *
488 * <strong>Note</strong>: Only works if both the configured Store and destination
489 * Store are synchronous.
490 *
491 * @remarks
492 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
493 *
494 * - Transferring between store types is supported so long as the source
495 * implements `.getAllCookies()` and the destination implements `.putCookie()`.
496 *
497 * @param newStore - The target {@link Store} to clone cookies into.
498 */
499 cloneSync(newStore?: Store): CookieJar | undefined;
500 /**
501 * Removes all cookies from the CookieJar.
502 *
503 * @remarks
504 * - This is a new backwards-compatible feature of tough-cookie version 2.5,
505 * so not all Stores will implement it efficiently. For Stores that do not
506 * implement `removeAllCookies`, the fallback is to call `removeCookie` after
507 * `getAllCookies`.
508 *
509 * - If `getAllCookies` fails or isn't implemented in the Store, an error is returned.
510 *
511 * - If one or more of the `removeCookie` calls fail, only the first error is returned.
512 *
513 * @param callback - A function to call when all the cookies have been removed.
514 */
515 removeAllCookies(callback: ErrorCallback): void;
516 /**
517 * Removes all cookies from the CookieJar.
518 *
519 * @remarks
520 * - This is a new backwards-compatible feature of tough-cookie version 2.5,
521 * so not all Stores will implement it efficiently. For Stores that do not
522 * implement `removeAllCookies`, the fallback is to call `removeCookie` after
523 * `getAllCookies`.
524 *
525 * - If `getAllCookies` fails or isn't implemented in the Store, an error is returned.
526 *
527 * - If one or more of the `removeCookie` calls fail, only the first error is returned.
528 */
529 removeAllCookies(): Promise<void>;
530 /**
531 * Removes all cookies from the CookieJar.
532 *
533 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
534 *
535 * @remarks
536 * - This is a new backwards-compatible feature of tough-cookie version 2.5,
537 * so not all Stores will implement it efficiently. For Stores that do not
538 * implement `removeAllCookies`, the fallback is to call `removeCookie` after
539 * `getAllCookies`.
540 *
541 * - If `getAllCookies` fails or isn't implemented in the Store, an error is returned.
542 *
543 * - If one or more of the `removeCookie` calls fail, only the first error is returned.
544 */
545 removeAllCookiesSync(): void;
546 /**
547 * A new CookieJar is created and the serialized {@link Cookie} values are added to
548 * the underlying store. Each {@link Cookie} is added via `store.putCookie(...)` in
549 * the order in which they appear in the serialization.
550 *
551 * @remarks
552 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
553 *
554 * - As a convenience, if `strOrObj` is a string, it is passed through `JSON.parse` first.
555 *
556 * @param strOrObj - A JSON string or object representing the deserialized cookies.
557 * @param callback - A function to call after the {@link CookieJar} has been deserialized.
558 */
559 static deserialize(strOrObj: string | object, callback: Callback<CookieJar>): void;
560 /**
561 * A new CookieJar is created and the serialized {@link Cookie} values are added to
562 * the underlying store. Each {@link Cookie} is added via `store.putCookie(...)` in
563 * the order in which they appear in the serialization.
564 *
565 * @remarks
566 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
567 *
568 * - As a convenience, if `strOrObj` is a string, it is passed through `JSON.parse` first.
569 *
570 * @param strOrObj - A JSON string or object representing the deserialized cookies.
571 * @param store - The underlying store to persist the deserialized cookies into.
572 * @param callback - A function to call after the {@link CookieJar} has been deserialized.
573 */
574 static deserialize(strOrObj: string | object, store: Store, callback: Callback<CookieJar>): void;
575 /**
576 * A new CookieJar is created and the serialized {@link Cookie} values are added to
577 * the underlying store. Each {@link Cookie} is added via `store.putCookie(...)` in
578 * the order in which they appear in the serialization.
579 *
580 * @remarks
581 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
582 *
583 * - As a convenience, if `strOrObj` is a string, it is passed through `JSON.parse` first.
584 *
585 * @param strOrObj - A JSON string or object representing the deserialized cookies.
586 * @param store - The underlying store to persist the deserialized cookies into.
587 */
588 static deserialize(strOrObj: string | object, store?: Store): Promise<CookieJar>;
589 /**
590 * @internal No doc because this is an overload that supports the implementation
591 */
592 static deserialize(strOrObj: string | object, store?: Store | Callback<CookieJar>, callback?: Callback<CookieJar>): unknown;
593 /**
594 * A new CookieJar is created and the serialized {@link Cookie} values are added to
595 * the underlying store. Each {@link Cookie} is added via `store.putCookie(...)` in
596 * the order in which they appear in the serialization.
597 *
598 * <strong>Note</strong>: Only works if the configured Store is also synchronous.
599 *
600 * @remarks
601 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
602 *
603 * - As a convenience, if `strOrObj` is a string, it is passed through `JSON.parse` first.
604 *
605 * @param strOrObj - A JSON string or object representing the deserialized cookies.
606 * @param store - The underlying store to persist the deserialized cookies into.
607 */
608 static deserializeSync(strOrObj: string | SerializedCookieJar, store?: Store): CookieJar;
609 /**
610 * Alias of {@link CookieJar.deserializeSync}.
611 *
612 * @remarks
613 * - When no {@link Store} is provided, a new {@link MemoryCookieStore} will be used.
614 *
615 * - As a convenience, if `strOrObj` is a string, it is passed through `JSON.parse` first.
616 *
617 * @param jsonString - A JSON string or object representing the deserialized cookies.
618 * @param store - The underlying store to persist the deserialized cookies into.
619 */
620 static fromJSON(jsonString: string | SerializedCookieJar, store?: Store): CookieJar;
621}