Cookies class extends the CookieJar class from the "tough-cookie" library. It provides methods to manage cookies for a specific URL.

Hierarchy

  • CookieJar
    • Cookies

Constructors

  • Constructor for the Cookies class. It calls the constructor of the parent class CookieJar.

    Returns Cookies

Methods

  • Parameters

    • Optional store: Store

    Returns Promise<CookieJar>

  • Parameters

    • store: Store
    • cb: ((err, newJar) => void)
        • (err, newJar): void
        • Parameters

          • err: null | Error
          • newJar: CookieJar

          Returns void

    Returns void

  • Parameters

    • cb: ((err, newJar) => void)
        • (err, newJar): void
        • Parameters

          • err: null | Error
          • newJar: CookieJar

          Returns void

    Returns void

  • Parameters

    • Optional store: Store

    Returns CookieJar

  • Fetches all cookies and organizes them by URL.

    This method serializes cookies and groups them by their domain and path, constructing a URL as the key and an object of cookies as key-value pairs.

    Returns Serialized

    An object where keys are URLs and values are objects containing cookies as key-value pairs.

    Example

    {
    * "https://example.com/": {
    * "cookie1": "value1",
    * "cookie2": "value2"
    * },
    * "https://anotherdomain.com/": {
    * "cookieA": "valueA",
    * "cookieB": "valueB"
    * }
    * }
  • Fetches the cookies for a given URL as an array of objects. Each object contains the name and value of a cookie.

    Parameters

    • url: string

      The URL from which cookies are to be fetched.

    Returns {
        name: string;
        value: string;
    }[]

    An array of objects, each containing the name and value of a cookie.

    Example

    fetchSequence('http://example.com')
    
  • Fetches the cookies for a given URL as an object.

    Parameters

    • url: string

      The URL from which cookies are to be fetched.

    Returns Record<string, string>

    An object containing cookies as key-value pairs.

    Example

    fetchJSON('http://example.com')
    
  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns Promise<string>

  • Parameters

    • currentUrl: string
    • options: GetCookiesOptions
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: string

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: string

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns string

  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns Promise<Cookie[]>

  • Parameters

    • currentUrl: string
    • options: GetCookiesOptions
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: Cookie[]

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: Cookie[]

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns Cookie[]

  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns Promise<string[]>

  • Parameters

    • currentUrl: string
    • options: GetCookiesOptions
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: string[]

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • cb: ((err, cookies) => void)
        • (err, cookies): void
        • Parameters

          • err: null | Error
          • cookies: string[]

          Returns void

    Returns void

  • Parameters

    • currentUrl: string
    • Optional options: GetCookiesOptions

    Returns string[]

  • Merges the provided cookies with the existing cookies for a given URL according to request payload.

    Parameters

    • cookies: Record<string, string>

      An object containing cookies as key-value pairs.

    • url: string

      The URL for which cookies are to be set.

    Returns {
        name: string;
        value: string;
    }[]

    An array of objects, each containing the name and value of a cookie.

    Example

    merge({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com')
    
  • Returns Promise<void>

  • Parameters

    • cb: ((err) => void)
        • (err): void
        • Parameters

          • err: null | Error

          Returns void

    Returns void

  • Returns void

  • Returns Promise<Serialized>

  • Parameters

    • cb: ((err, serializedObject) => void)
        • (err, serializedObject): void
        • Parameters

          • err: null | Error
          • serializedObject: Serialized

          Returns void

    Returns void

  • Returns Serialized

  • Parameters

    • cookieOrString: string | Cookie
    • currentUrl: string
    • Optional options: SetCookieOptions

    Returns Promise<Cookie>

  • Parameters

    • cookieOrString: string | Cookie
    • currentUrl: string
    • options: SetCookieOptions
    • cb: ((err, cookie) => void)
        • (err, cookie): void
        • Parameters

          • err: null | Error
          • cookie: Cookie

          Returns void

    Returns void

  • Parameters

    • cookieOrString: string | Cookie
    • currentUrl: string
    • cb: ((err, cookie) => void)
        • (err, cookie): void
        • Parameters

          • err: null | Error
          • cookie: Cookie

          Returns void

    Returns void

  • Parameters

    • cookieOrString: string | Cookie
    • currentUrl: string
    • Optional options: SetCookieOptions

    Returns Cookie

  • Checks and sets cookies for a given URL.

    Parameters

    • cookies: Record<string, string>

      An object containing cookies as key-value pairs.

    • url: string

      The URL for which cookies are to be set.

    Returns Record<string, string>

    An object containing cookies as key-value pairs.

    Example

    check({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com')
    
  • Returns Serialized

  • Parameters

    • serialized: string | Serialized
    • Optional store: Store

    Returns Promise<CookieJar>

  • Parameters

    • serialized: string | Serialized
    • store: Store
    • cb: ((err, object) => void)
        • (err, object): void
        • Parameters

          • err: null | Error
          • object: CookieJar

          Returns void

    Returns void

  • Parameters

    • serialized: string | Serialized
    • cb: ((err, object) => void)
        • (err, object): void
        • Parameters

          • err: null | Error
          • object: CookieJar

          Returns void

    Returns void

  • Parameters

    • serialized: string | Serialized
    • Optional store: Store

    Returns CookieJar

  • Parameters

    • string: string

    Returns CookieJar