CookieJarStore
Class: CookieJarStore
Defined in: storage/cookie-store.ts:36
DataStore-backed wrapper around a tough-cookie CookieJar.
Remarks
Construct via the static CookieJarStore.create factory — the ctor is private so a fully-rehydrated jar is guaranteed before first use.
Example
import { CookieJarStore, FileDataStore } from "@snapcap/native";
const store = new FileDataStore(".tmp/auth/auth.json");
const jarStore = await CookieJarStore.create(store);
// jarStore.jar is a tough-cookie CookieJar; pass to your fetch wrapper.
await jarStore.flush();Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
jar | readonly | CookieJar | The underlying tough-cookie CookieJar. | storage/cookie-store.ts:38 |
Methods
create()
static create(store: DataStore, key?: string): Promise<CookieJarStore>;Defined in: storage/cookie-store.ts:54
Build a new CookieJarStore, rehydrating the jar from the
DataStore if a prior serialization exists at key.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
store | DataStore | undefined | The DataStore backing the persisted cookie state. |
key | string | "cookie_jar" | Storage key under which the serialized jar lives. Defaults to "cookie_jar". |
Returns
Promise<CookieJarStore>
A ready-to-use CookieJarStore whose .jar is fully populated
from prior state (if any).
flush()
flush(): Promise<void>;Defined in: storage/cookie-store.ts:74
Persist the jar's current state back to the DataStore.
Returns
Promise<void>
Remarks
Called automatically by makeJarFetch after any response that yielded a
Set-Cookie. Call directly if you mutate the jar by other means
(jar.setCookie() from your own code).