File size: 1,557 Bytes
9ada4bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Cookie } from 'set-cookie-parser';

interface RequestLike {
    credentials: Request['credentials'];
    url: string;
}
interface HeadersLike {
    get(name: string): string | null;
}
interface ResponseLike {
    headers: HeadersLike;
}
type Store = Map<string, StoreEntry>;
type StoreEntry = Map<string, Cookie>;
type CookieString = Omit<Cookie, 'expires'> & {
    expires?: string;
};
declare const PERSISTENCY_KEY = "MSW_COOKIE_STORE";
declare class CookieStore {
    private store;
    constructor();
    /**
     * Sets the given request cookies into the store.
     * Respects the `request.credentials` policy.
     */
    add(request: RequestLike, response: ResponseLike): void;
    /**
     * Returns cookies relevant to the given request
     * and its `request.credentials` policy.
     */
    get(request: RequestLike): StoreEntry;
    /**
     * Returns a collection of all stored cookies.
     */
    getAll(): Store;
    /**
     * Deletes all cookies associated with the given request.
     */
    deleteAll(request: RequestLike): void;
    /**
     * Clears the entire cookie store.
     */
    clear(): void;
    /**
     * Hydrates the virtual cookie store from the `localStorage` if defined.
     */
    hydrate(): void;
    /**
     * Persists the current virtual cookies into the `localStorage` if defined,
     * so they are available on the next page load.
     */
    persist(): void;
    private deleteExpiredCookies;
}
declare const store: CookieStore;

export { CookieString, PERSISTENCY_KEY, Store, StoreEntry, store };