1 | /**
|
2 | * @description
|
3 | *
|
4 | * Object containing default options to pass when setting cookies.
|
5 | *
|
6 | * The object may have following properties:
|
7 | *
|
8 | * - **path** - {string} - The cookie will be available only for this path and its
|
9 | * sub-paths. By default, this is the URL that appears in your `<base>` tag.
|
10 | * - **domain** - {string} - The cookie will be available only for this domain and
|
11 | * its sub-domains. For security reasons the user agent will not accept the cookie
|
12 | * if the current domain is not a sub-domain of this domain or equal to it.
|
13 | * - **expires** - {string|Date} - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT"
|
14 | * or a Date object indicating the exact date/time this cookie will expire.
|
15 | * - **secure** - {boolean} - If `true`, then the cookie will only be available through a
|
16 | * secured connection.
|
17 | * - **httpOnly** - {boolean} - If `true`, then the cookie will be set with the `HttpOnly`
|
18 | * flag, and will only be accessible from the remote server. Helps to prevent against
|
19 | * XSS attacks.
|
20 | * - **sameSite** - {"Lax"|"Strict"|"None"} - Designates cookie for first party (Lax|Strict)
|
21 | * or third party contexts.
|
22 | * - **storeUnencoded** - {boolean} - If `true`, then the cookie value will not be encoded and
|
23 | * will be stored as provided.
|
24 | */
|
25 | export interface CookieOptions {
|
26 | path?: string;
|
27 | domain?: string;
|
28 | expires?: string | Date;
|
29 | secure?: boolean;
|
30 | httpOnly?: boolean;
|
31 | sameSite?: boolean | 'lax' | 'strict' | 'none';
|
32 | storeUnencoded?: boolean;
|
33 | }
|
34 | export interface CookieDict {
|
35 | [key: string]: string;
|
36 | }
|
37 | export interface ICookieWriterService {
|
38 | readAllAsString(): string;
|
39 | write(name: string, value: string | undefined, options?: CookieOptions): void;
|
40 | }
|
41 | export interface ICookieService {
|
42 | hasKey(key: string): boolean;
|
43 | get(key: string): string | undefined;
|
44 | getObject(key: string): object | undefined;
|
45 | getAll(): object;
|
46 | put(key: string, value: string, options?: CookieOptions): void;
|
47 | putObject(key: string, value: object, options?: CookieOptions): void;
|
48 | remove(key: string, options?: CookieOptions): void;
|
49 | removeAll(options?: CookieOptions): void;
|
50 | }
|