UNPKG

2.21 kBTypeScriptView Raw
1import { CookieOptionsProvider } from './cookie-options.provider';
2import { CookieDict, CookieOptions, ICookieService, ICookieWriterService } from './cookie.model';
3export declare class CookieService implements ICookieService {
4 private document;
5 private optionsProvider;
6 private cookieWriterService;
7 protected options: CookieOptions;
8 constructor(document: any, optionsProvider: CookieOptionsProvider, cookieWriterService: ICookieWriterService);
9 /**
10 * @description
11 * Returns if the given cookie key exists or not.
12 *
13 * @param key Id to use for lookup.
14 * @returns true if key exists, otherwise false.
15 */
16 hasKey(key: string): boolean;
17 /**
18 * @description
19 * Returns the value of given cookie key.
20 *
21 * @param key Id to use for lookup.
22 * @returns Raw cookie value.
23 */
24 get(key: string): string;
25 /**
26 * @description
27 * Returns the deserialized value of given cookie key.
28 *
29 * @param key Id to use for lookup.
30 * @returns Deserialized cookie value.
31 */
32 getObject(key: string): object | undefined;
33 /**
34 * @description
35 * Returns a key value object with all the cookies.
36 *
37 * @returns All cookies
38 */
39 getAll(): CookieDict;
40 /**
41 * @description
42 * Sets a value for given cookie key.
43 *
44 * @param key Id for the `value`.
45 * @param value Raw value to be stored.
46 * @param options (Optional) Options object.
47 */
48 put(key: string, value: string | undefined, options?: CookieOptions): void;
49 /**
50 * @description
51 * Serializes and sets a value for given cookie key.
52 *
53 * @param key Id for the `value`.
54 * @param value Value to be stored.
55 * @param options (Optional) Options object.
56 */
57 putObject(key: string, value: object, options?: CookieOptions): void;
58 /**
59 * @description
60 * Remove given cookie.
61 *
62 * @param key Id of the key-value pair to delete.
63 * @param options (Optional) Options object.
64 */
65 remove(key: string, options?: CookieOptions): void;
66 /**
67 * @description
68 * Remove all cookies.
69 */
70 removeAll(options?: CookieOptions): void;
71}