tough-cookie-file-store
Version:
A JSON file store for tough-cookie module
40 lines (39 loc) • 2.04 kB
TypeScript
import * as tough from 'tough-cookie';
import type { CookiesIndex } from '../cookies-index.js';
export type ParseNetscapeCookiesOptions = {
forceParse?: boolean;
httpOnlyExtension?: boolean;
filePath?: string;
onLineError?: (line: string, lineNumber: number) => void;
};
/**
* Parses the text of a netscape cookies.txt file line-by-line, yielding each cookie and its canonical domain.
* @param {string} data - The string content of the cookies file.
* @param {object} options - Options for loading the cookies file.
* @returns {Generator} a generator that yields each cookie
*/
export declare function parseNetscapeCookiesTxtLineByLine(data: string, options?: ParseNetscapeCookiesOptions): Generator<tough.Cookie>;
/**
* Parses the text of a netscape cookies.txt file into an array of cookies
* @param {string} data - The string content of the cookies file.
* @param {object} options - Options for loading the cookies file.
* @returns {Cookie[]} the parsed cookies
*/
export declare function parseNetscapeCookiesTxtToIndex(data: string, options: ParseNetscapeCookiesOptions): CookiesIndex;
export type StringifyNetscapeCookiesOptions = {
httpOnlyExtension?: boolean;
};
/**
* Serializes the text of a netscape cookies.txt file from a cookies index.
* @param {CookiesIndex} cookies - The object containing all the cookies.
* @param {object} options - Options for serializing the cookies file.
* @returns {string} the serialized netscape cookies file.
*/
export declare function stringifyNetscapeCookiesTxt(cookies: CookiesIndex, options?: StringifyNetscapeCookiesOptions): string;
/**
* Serializes a Cookie object into a line for a cookies.txt file. This does not include the trailing newline.
* @param {Cookie} cookie - The cookie to serialize
* @param {object} options - Options for serializing the cookie
* @returns {string} the serialized netscape cookies.txt line.
*/
export declare function stringifyNetscapeCookiesTxtLine(cookie: tough.Cookie, options?: StringifyNetscapeCookiesOptions): string;