puppeteer-tough-cookie-store
Version:
Puppeteer cookie store implementation for tough-cookie
78 lines (77 loc) • 2.54 kB
TypeScript
import type { Cookie, Store } from 'tough-cookie';
import type { CDPSession } from 'puppeteer';
/**
* Options for `PuppeteerToughCookieStore`
*/
export interface StoreOptions {
/**
* Changed getAllCookies behavior
*/
getAllCookiesUrls?: string[];
/**
* Fix `Cannot delete property 'creationIndex' of [object Object]` inside tough-cookie package
*
* [closed issue #1](https://github.com/salesforce/tough-cookie/issues/192) |
* [issue #2](https://github.com/salesforce/tough-cookie/issues/199)
*
* `getAllCookies` will call `.toJSON` before return cookies
*
* BE CAREFUL: TYPES WILL LIE TO YOU
*
* @deprecated
*/
_getAllCookies_returnPlainObject?: boolean;
}
/**
* @class PuppeteerToughCookieStore
*/
export declare class PuppeteerToughCookieStore implements Store {
/**
* Current store driver works async only
*/
synchronous: boolean;
constructor(
/** @internal */
client: CDPSession,
/** @internal */
options?: StoreOptions);
/**
* Returns cookie for the specific domain and path
*/
findCookie(domain: string, path: string, key: string): Promise<Cookie | undefined>;
/**
* Returns cookies for the specific domain and path
*/
findCookies(domain: string, path?: string, allowSpecialUseDomain?: boolean): Promise<Cookie[]>;
/**
* Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
*/
putCookie(cookie: Cookie): Promise<void>;
/**
* Sets a cookies with the given cookies; may overwrite equivalent cookies if they exist.
*/
putCookies(cookies: Cookie[]): Promise<void>;
/**
* Updates a cookie; in reality almost an alias for `.putCookies`
*/
updateCookie(oldCookie: Cookie, newCookie: Cookie): Promise<void>;
/**
* Deletes browser cookies with matching name, domain and path.
*/
removeCookie(domain: string, path: string, key: string): Promise<void>;
/**
* Deletes browser cookies with matching domain and path.
*/
removeCookies(domain: string, path: string): Promise<void>;
/**
* Returns all browser cookies. Depending on the backend support, will return detailed cookie
* information in the `cookies` field.
*
* If `options.getAllCookiesUrls` set will return cookies only for those specific urls
*/
getAllCookies(): Promise<Cookie[]>;
/**
* Clears browser cookies.
*/
removeAllCookies(): Promise<void>;
}