Skip to content

Latest commit

 

History

History
351 lines (155 loc) · 7.23 KB

tough-cookie.store.md

File metadata and controls

351 lines (155 loc) · 7.23 KB

Home > tough-cookie > Store

Store class

Base class for CookieJar stores.

The storage model for each CookieJar instance can be replaced with a custom implementation. The default is MemoryCookieStore.

Signature:

export declare class Store 

Remarks

  • Stores should inherit from the base Store class, which is available as a top-level export.

  • Stores are asynchronous by default, but if Store.synchronous is set to true, then the *Sync methods of the containing CookieJar can be used.

Constructors

Constructor

Modifiers

Description

(constructor)()

Constructs a new instance of the Store class

Properties

Property

Modifiers

Type

Description

synchronous

boolean

Store implementations that support synchronous methods must return true.

Methods

Method

Modifiers

Description

findCookie(domain, path, key)

Retrieve a Cookie with the given domain, path, and key (name). The RFC maintains that exactly one of these cookies should exist in a store. If the store is using versioning, this means that the latest or newest such cookie should be returned.

Callback takes an error and the resulting Cookie object. If no cookie is found then null MUST be passed instead (that is, not an error).

findCookie(domain, path, key, callback)

Retrieve a Cookie with the given domain, path, and key (name). The RFC maintains that exactly one of these cookies should exist in a store. If the store is using versioning, this means that the latest or newest such cookie should be returned.

Callback takes an error and the resulting Cookie object. If no cookie is found then null MUST be passed instead (that is, not an error).

findCookies(domain, path, allowSpecialUseDomain)

Locates all Cookie values matching the given domain and path.

The resulting list is checked for applicability to the current request according to the RFC (domain-match, path-match, http-only-flag, secure-flag, expiry, and so on), so it's OK to use an optimistic search algorithm when implementing this method. However, the search algorithm used SHOULD try to find cookies that domainMatch() the domain and pathMatch() the path in order to limit the amount of checking that needs to be done.

findCookies(domain, path, allowSpecialUseDomain, callback)

Locates all Cookie values matching the given domain and path.

The resulting list is checked for applicability to the current request according to the RFC (domain-match, path-match, http-only-flag, secure-flag, expiry, and so on), so it's OK to use an optimistic search algorithm when implementing this method. However, the search algorithm used SHOULD try to find cookies that domainMatch() the domain and pathMatch() the path in order to limit the amount of checking that needs to be done.

getAllCookies()

Gets all the cookies in the store.

getAllCookies(callback)

Gets all the cookies in the store.

putCookie(cookie)

Adds a new Cookie to the store. The implementation SHOULD replace any existing cookie with the same domain, path, and key properties.

putCookie(cookie, callback)

Adds a new Cookie to the store. The implementation SHOULD replace any existing cookie with the same domain, path, and key properties.

removeAllCookies()

Removes all cookies from the store.

removeAllCookies(callback)

Removes all cookies from the store.

removeCookie(domain, path, key)

Remove a cookie from the store (see notes on findCookie about the uniqueness constraint).

removeCookie(domain, path, key, callback)

Remove a cookie from the store (see notes on findCookie about the uniqueness constraint).

removeCookies(domain, path)

Removes matching cookies from the store. The path parameter is optional and if missing, means all paths in a domain should be removed.

removeCookies(domain, path, callback)

Removes matching cookies from the store. The path parameter is optional and if missing, means all paths in a domain should be removed.

updateCookie(oldCookie, newCookie)

Update an existing Cookie. The implementation MUST update the value for a cookie with the same domain, path, and key. The implementation SHOULD check that the old value in the store is equivalent to oldCookie - how the conflict is resolved is up to the store.

updateCookie(oldCookie, newCookie, callback)

Update an existing Cookie. The implementation MUST update the value for a cookie with the same domain, path, and key. The implementation SHOULD check that the old value in the store is equivalent to oldCookie - how the conflict is resolved is up to the store.