UNPKG

2.01 kBTypeScriptView Raw
1import type { CookieInit, CookieList, CookieListItem, CookieStore, CookieStoreDeleteOptions, CookieStoreGetOptions } from 'cookie-store-interface';
2export * from 'cookie-store-interface';
3export interface EncryptedCookieStoreOptions {
4 /**
5 * One or more crypto keys that were previously used to encrypt cookies.
6 * `EncryptedCookieStore` will try to decrypt cookies using these, but they are not used for encrypting new cookies.
7 */
8 keyring?: readonly CryptoKey[];
9}
10export interface DeriveOptions {
11 secret: string | BufferSource | JsonWebKey;
12 salt?: BufferSource;
13 iterations?: number;
14 format?: KeyFormat;
15 hash?: HashAlgorithmIdentifier;
16 hmacHash?: HashAlgorithmIdentifier;
17 length?: number;
18}
19/**
20 * # Encrypted Cookie Store
21 * A partial implementation of the [Cookie Store API](https://wicg.github.io/cookie-store)
22 * that transparently encrypts and decrypts cookies via AES-GCM.
23 *
24 * This is likely only useful in server-side implementations,
25 * but written in a platform-agnostic way.
26 */
27export declare class EncryptedCookieStore implements CookieStore {
28 #private;
29 /** A helper function to derive a crypto key from a passphrase */
30 static deriveCryptoKey(opts: DeriveOptions): Promise<CryptoKey>;
31 constructor(store: CookieStore, key: CryptoKey, opts?: EncryptedCookieStoreOptions);
32 get(name?: string): Promise<CookieListItem | null>;
33 get(options?: CookieStoreGetOptions): Promise<CookieListItem | null>;
34 getAll(name?: string): Promise<CookieList>;
35 getAll(options?: CookieStoreGetOptions): Promise<CookieList>;
36 set(name: string, value: string): Promise<void>;
37 set(options: CookieInit): Promise<void>;
38 delete(name: string): Promise<void>;
39 delete(options: CookieStoreDeleteOptions): Promise<void>;
40 addEventListener(...args: Parameters<CookieStore['addEventListener']>): void;
41 dispatchEvent(event: Event): boolean;
42 removeEventListener(...args: Parameters<CookieStore['removeEventListener']>): void;
43}