UNPKG

2.96 kBTypeScriptView Raw
1export declare class CookieService {
2 private document;
3 private platformId;
4 private readonly documentIsAccessible;
5 constructor(document: any, platformId: any);
6 /**
7 * Get cookie Regular Expression
8 *
9 * @param name Cookie name
10 * @returns property RegExp
11 */
12 private static getCookieRegExp;
13 private static safeDecodeURIComponent;
14 /**
15 * Return `true` if {@link Document} is accessible, otherwise return `false`
16 *
17 * @param name Cookie name
18 * @returns boolean - whether cookie with specified name exists
19 */
20 check(name: string): boolean;
21 /**
22 * Get cookies by name
23 *
24 * @param name Cookie name
25 * @returns property value
26 */
27 get(name: string): string;
28 /**
29 * Get all cookies in JSON format
30 *
31 * @returns all the cookies in json
32 */
33 getAll(): {
34 [key: string]: string;
35 };
36 /**
37 * Set cookie based on provided information
38 *
39 * @param name Cookie name
40 * @param value Cookie value
41 * @param expires Number of days until the cookies expires or an actual `Date`
42 * @param path Cookie path
43 * @param domain Cookie domain
44 * @param secure Secure flag
45 * @param sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`
46 */
47 set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
48 /**
49 * Set cookie based on provided information
50 *
51 * Cookie's parameters:
52 * <pre>
53 * expires Number of days until the cookies expires or an actual `Date`
54 * path Cookie path
55 * domain Cookie domain
56 * secure Secure flag
57 * sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`
58 * </pre>
59 *
60 * @param name Cookie name
61 * @param value Cookie value
62 * @param options Body with cookie's params
63 */
64 set(name: string, value: string, options?: {
65 expires?: number | Date;
66 path?: string;
67 domain?: string;
68 secure?: boolean;
69 sameSite?: 'Lax' | 'None' | 'Strict';
70 }): void;
71 /**
72 * Delete cookie by name
73 *
74 * @param name Cookie name
75 * @param path Cookie path
76 * @param domain Cookie domain
77 * @param secure Cookie secure flag
78 * @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
79 */
80 delete(name: string, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
81 /**
82 * Delete all cookies
83 *
84 * @param path Cookie path
85 * @param domain Cookie domain
86 * @param secure Is the Cookie secure
87 * @param sameSite Is the cookie same site
88 */
89 deleteAll(path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
90}