ngx-cookie-service 2.0.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +11 -2
  2. package/bundles/ngx-cookie-service.umd.js +158 -0
  3. package/bundles/ngx-cookie-service.umd.js.map +1 -0
  4. package/bundles/ngx-cookie-service.umd.min.js +2 -0
  5. package/bundles/ngx-cookie-service.umd.min.js.map +1 -0
  6. package/cookie-service/cookie.service.d.ts +47 -0
  7. package/{lib/index.ts → index.d.ts} +0 -0
  8. package/ngx-cookie-service.d.ts +4 -0
  9. package/ngx-cookie-service.es5.js +152 -0
  10. package/ngx-cookie-service.es5.js.map +1 -0
  11. package/ngx-cookie-service.js +153 -0
  12. package/ngx-cookie-service.js.map +1 -0
  13. package/ngx-cookie-service.metadata.json +1 -0
  14. package/package.json +1 -108
  15. package/.angular-cli.json +0 -57
  16. package/.editorconfig +0 -13
  17. package/.gitignore +0 -16
  18. package/CHANGELOG.md +0 -10
  19. package/README_NPM.md +0 -126
  20. package/demo-app/app/app.component.html +0 -1
  21. package/demo-app/app/app.component.scss +0 -0
  22. package/demo-app/app/app.component.spec.ts +0 -129
  23. package/demo-app/app/app.component.ts +0 -18
  24. package/demo-app/app/app.module.ts +0 -15
  25. package/demo-app/assets/.gitkeep +0 -0
  26. package/demo-app/environments/environment.prod.ts +0 -3
  27. package/demo-app/environments/environment.ts +0 -8
  28. package/demo-app/favicon.ico +0 -0
  29. package/demo-app/index.html +0 -14
  30. package/demo-app/main.ts +0 -11
  31. package/demo-app/polyfills.ts +0 -68
  32. package/demo-app/styles.scss +0 -1
  33. package/demo-app/test.ts +0 -33
  34. package/demo-app/tsconfig.app.json +0 -22
  35. package/demo-app/tsconfig.spec.json +0 -26
  36. package/e2e/app.e2e-spec.ts +0 -14
  37. package/e2e/app.po.ts +0 -11
  38. package/e2e/tsconfig.e2e.json +0 -19
  39. package/karma.conf.js +0 -44
  40. package/lib/cookie-service/cookie.service.ts +0 -170
  41. package/lib/tsconfig.json +0 -25
  42. package/protractor.conf.js +0 -30
  43. package/scripts/compile.js +0 -94
  44. package/tsconfig.json +0 -21
  45. package/tslint.json +0 -116
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  An (AOT ready) Angular (4.2+) service for cookies. Originally based on the [ng2-cookies](https://www.npmjs.com/package/ng2-cookies) library.
4
4
 
5
+ # :warning: Announcement: New maintainer needed.
6
+
7
+ We stopped working with Angular some time ago. At first we did not mind maintaining this package as a small side project, but we would finally like to move on to other projects.
8
+
9
+ However, we feel that this package is still useful. Therefore, we would really like to hand it over to a new maintainer instead of just deprecating it. If you would like to take care of `ngx-cookie-service` in the future, feel free to shoot us an email: technik@7leads.org
10
+
5
11
  # Installation
6
12
 
7
13
  ```bash
@@ -89,13 +95,13 @@ const allCookies: {} = cookieService.getAll();
89
95
 
90
96
  Returns a map of key-value pairs for cookies that can be accessed.
91
97
 
92
- ## set( name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean ): void;
98
+ ## set( name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'Strict' | 'None' ): void;
93
99
 
94
100
  ```typescript
95
101
  cookieService.set( 'test', 'Hello World' );
96
102
  ```
97
103
 
98
- Sets a cookie with the specified `name` and `value`. It is good practice to specify a path. If you are unsure about the path value, use `'/'`. If no path or domain is explicitly defined, the current location is assumed.
104
+ Sets a cookie with the specified `name` and `value`. It is good practice to specify a path. If you are unsure about the path value, use `'/'`. If no path or domain is explicitly defined, the current location is assumed. `sameSite` defaults to `None`.
99
105
 
100
106
  **Important:** For security reasons, it is not possible to define cookies for other domains. Browsers do not allow this. Read [this](https://stackoverflow.com/a/1063760) and [this](https://stackoverflow.com/a/17777005/1007003) StackOverflow answer for a more in-depth explanation.
101
107
 
@@ -180,6 +186,9 @@ Thanks to all contributors:
180
186
  * [JaredClemence](https://github.com/JaredClemence)
181
187
  * [flakolefluk](https://github.com/flakolefluk)
182
188
  * [mattbanks](https://github.com/mattbanks)
189
+ * [DBaker85](https://github.com/DBaker85)
190
+ * [mattlewis92](https://github.com/mattlewis92)
191
+ * [IceBreakerG](https://github.com/IceBreakerG)
183
192
 
184
193
  # License
185
194
 
@@ -0,0 +1,158 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common'], factory) :
4
+ (factory((global['ngx-cookie-service'] = {}),global.ng.core,global.ng.common));
5
+ }(this, (function (exports,core,common) { 'use strict';
6
+
7
+ // This service is based on the `ng2-cookies` package which sadly is not a service and does
8
+ // not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.
9
+ // Package: https://github.com/BCJTI/ng2-cookies
10
+ var CookieService = (function () {
11
+ /**
12
+ * @param {?} document
13
+ * @param {?} platformId
14
+ */
15
+ function CookieService(document, platformId) {
16
+ this.document = document;
17
+ this.platformId = platformId;
18
+ this.documentIsAccessible = common.isPlatformBrowser(this.platformId);
19
+ }
20
+ /**
21
+ * @param {?} name Cookie name
22
+ * @return {?}
23
+ */
24
+ CookieService.prototype.check = function (name) {
25
+ if (!this.documentIsAccessible) {
26
+ return false;
27
+ }
28
+ name = encodeURIComponent(name);
29
+ var /** @type {?} */ regExp = this.getCookieRegExp(name);
30
+ var /** @type {?} */ exists = regExp.test(this.document.cookie);
31
+ return exists;
32
+ };
33
+ /**
34
+ * @param {?} name Cookie name
35
+ * @return {?}
36
+ */
37
+ CookieService.prototype.get = function (name) {
38
+ if (this.documentIsAccessible && this.check(name)) {
39
+ name = encodeURIComponent(name);
40
+ var /** @type {?} */ regExp = this.getCookieRegExp(name);
41
+ var /** @type {?} */ result = regExp.exec(this.document.cookie);
42
+ return decodeURIComponent(result[1]);
43
+ }
44
+ else {
45
+ return '';
46
+ }
47
+ };
48
+ /**
49
+ * @return {?}
50
+ */
51
+ CookieService.prototype.getAll = function () {
52
+ if (!this.documentIsAccessible) {
53
+ return {};
54
+ }
55
+ var /** @type {?} */ cookies = {};
56
+ var /** @type {?} */ document = this.document;
57
+ if (document.cookie && document.cookie !== '') {
58
+ var /** @type {?} */ split = document.cookie.split(';');
59
+ for (var /** @type {?} */ i = 0; i < split.length; i += 1) {
60
+ var /** @type {?} */ currentCookie = split[i].split('=');
61
+ currentCookie[0] = currentCookie[0].replace(/^ /, '');
62
+ cookies[decodeURIComponent(currentCookie[0])] = decodeURIComponent(currentCookie[1]);
63
+ }
64
+ }
65
+ return cookies;
66
+ };
67
+ /**
68
+ * @param {?} name Cookie name
69
+ * @param {?} value Cookie value
70
+ * @param {?=} expires Number of days until the cookies expires or an actual `Date`
71
+ * @param {?=} path Cookie path
72
+ * @param {?=} domain Cookie domain
73
+ * @param {?=} secure Secure flag
74
+ * @param {?=} sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`
75
+ * @return {?}
76
+ */
77
+ CookieService.prototype.set = function (name, value, expires, path, domain, secure, sameSite) {
78
+ if (sameSite === void 0) { sameSite = 'None'; }
79
+ if (!this.documentIsAccessible) {
80
+ return;
81
+ }
82
+ var /** @type {?} */ cookieString = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';
83
+ if (expires) {
84
+ if (typeof expires === 'number') {
85
+ var /** @type {?} */ dateExpires = new Date(new Date().getTime() + expires * 1000 * 60 * 60 * 24);
86
+ cookieString += 'expires=' + dateExpires.toUTCString() + ';';
87
+ }
88
+ else {
89
+ cookieString += 'expires=' + expires.toUTCString() + ';';
90
+ }
91
+ }
92
+ if (path) {
93
+ cookieString += 'path=' + path + ';';
94
+ }
95
+ if (domain) {
96
+ cookieString += 'domain=' + domain + ';';
97
+ }
98
+ if (secure) {
99
+ cookieString += 'secure;';
100
+ }
101
+ cookieString += 'sameSite=' + sameSite + ';';
102
+ this.document.cookie = cookieString;
103
+ };
104
+ /**
105
+ * @param {?} name Cookie name
106
+ * @param {?=} path Cookie path
107
+ * @param {?=} domain Cookie domain
108
+ * @return {?}
109
+ */
110
+ CookieService.prototype.delete = function (name, path, domain) {
111
+ if (!this.documentIsAccessible) {
112
+ return;
113
+ }
114
+ this.set(name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain);
115
+ };
116
+ /**
117
+ * @param {?=} path Cookie path
118
+ * @param {?=} domain Cookie domain
119
+ * @return {?}
120
+ */
121
+ CookieService.prototype.deleteAll = function (path, domain) {
122
+ if (!this.documentIsAccessible) {
123
+ return;
124
+ }
125
+ var /** @type {?} */ cookies = this.getAll();
126
+ for (var /** @type {?} */ cookieName in cookies) {
127
+ if (cookies.hasOwnProperty(cookieName)) {
128
+ this.delete(cookieName, path, domain);
129
+ }
130
+ }
131
+ };
132
+ /**
133
+ * @param {?} name Cookie name
134
+ * @return {?}
135
+ */
136
+ CookieService.prototype.getCookieRegExp = function (name) {
137
+ var /** @type {?} */ escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/ig, '\\$1');
138
+ return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
139
+ };
140
+ return CookieService;
141
+ }());
142
+ CookieService.decorators = [
143
+ { type: core.Injectable },
144
+ ];
145
+ /**
146
+ * @nocollapse
147
+ */
148
+ CookieService.ctorParameters = function () { return [
149
+ { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] },] },
150
+ { type: core.InjectionToken, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] },] },
151
+ ]; };
152
+
153
+ exports.CookieService = CookieService;
154
+
155
+ Object.defineProperty(exports, '__esModule', { value: true });
156
+
157
+ })));
158
+ //# sourceMappingURL=ngx-cookie-service.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-cookie-service.umd.js","sources":["~/ngx-cookie-service/lib/cookie-service/cookie.service.ts"],"sourcesContent":["// This service is based on the `ng2-cookies` package which sadly is not a service and does\n// not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.\n// Package: https://github.com/BCJTI/ng2-cookies\n\n\nimport { Injectable, Inject, PLATFORM_ID, InjectionToken } from '@angular/core';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nexport class CookieService {\nprivate readonly documentIsAccessible: boolean;\n/**\n * @param {?} document\n * @param {?} platformId\n */\nconstructor(\nprivate document: any,\nprivate platformId: InjectionToken<Object>,\n ) {\n this.documentIsAccessible = isPlatformBrowser( this.platformId );\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\ncheck( name: string ): boolean {\n if ( !this.documentIsAccessible ) {\n return false;\n }\n\n name = encodeURIComponent( name );\n\n const /** @type {?} */ regExp: RegExp = this.getCookieRegExp( name );\n const /** @type {?} */ exists: boolean = regExp.test( this.document.cookie );\n\n return exists;\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\nget( name: string ): string {\n if ( this.documentIsAccessible && this.check( name ) ) {\n name = encodeURIComponent( name );\n\n const /** @type {?} */ regExp: RegExp = this.getCookieRegExp( name );\n const /** @type {?} */ result: RegExpExecArray = regExp.exec( this.document.cookie );\n\n return decodeURIComponent( result[ 1 ] );\n } else {\n return '';\n }\n }\n/**\n * @return {?}\n */\ngetAll(): {} {\n if ( !this.documentIsAccessible ) {\n return {};\n }\n\n const /** @type {?} */ cookies: {} = {};\n const /** @type {?} */ document: any = this.document;\n\n if ( document.cookie && document.cookie !== '' ) {\n const /** @type {?} */ split: Array<string> = document.cookie.split(';');\n\n for ( let /** @type {?} */ i = 0; i < split.length; i += 1 ) {\n const /** @type {?} */ currentCookie: Array<string> = split[ i ].split('=');\n\n currentCookie[ 0 ] = currentCookie[ 0 ].replace( /^ /, '' );\n cookies[ decodeURIComponent( currentCookie[ 0 ] ) ] = decodeURIComponent( currentCookie[ 1 ] );\n }\n }\n\n return cookies;\n }\n/**\n * @param {?} name Cookie name\n * @param {?} value Cookie value\n * @param {?=} expires Number of days until the cookies expires or an actual `Date`\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @param {?=} secure Secure flag\n * @param {?=} sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`\n * @return {?}\n */\nset(\n name: string,\n value: string,\n expires?: number | Date,\n path?: string,\n domain?: string,\n secure?: boolean,\n sameSite: 'Lax' | 'None' | 'Strict' = 'None'\n ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n let /** @type {?} */ cookieString: string = encodeURIComponent( name ) + '=' + encodeURIComponent( value ) + ';';\n\n if ( expires ) {\n if ( typeof expires === 'number' ) {\n const /** @type {?} */ dateExpires: Date = new Date( new Date().getTime() + expires * 1000 * 60 * 60 * 24 );\n\n cookieString += 'expires=' + dateExpires.toUTCString() + ';';\n } else {\n cookieString += 'expires=' + expires.toUTCString() + ';';\n }\n }\n\n if ( path ) {\n cookieString += 'path=' + path + ';';\n }\n\n if ( domain ) {\n cookieString += 'domain=' + domain + ';';\n }\n\n if ( secure ) {\n cookieString += 'secure;';\n }\n\n cookieString += 'sameSite=' + sameSite + ';';\n\n this.document.cookie = cookieString;\n }\n/**\n * @param {?} name Cookie name\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @return {?}\n */\ndelete( name: string, path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n this.set( name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain );\n }\n/**\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @return {?}\n */\ndeleteAll( path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n const /** @type {?} */ cookies: any = this.getAll();\n\n for ( const /** @type {?} */ cookieName in cookies ) {\n if ( cookies.hasOwnProperty( cookieName ) ) {\n this.delete( cookieName, path, domain );\n }\n }\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\nprivate getCookieRegExp( name: string ): RegExp {\n const /** @type {?} */ escapedName: string = name.replace( /([\\[\\]\\{\\}\\(\\)\\|\\=\\;\\+\\?\\,\\.\\*\\^\\$])/ig, '\\\\$1' );\n\n return new RegExp( '(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g' );\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: undefined, decorators: [{ type: Inject, args: [DOCUMENT, ] }, ]},\n{type: InjectionToken, decorators: [{ type: Inject, args: [PLATFORM_ID, ] }, ]},\n];\n}\n\nfunction CookieService_tsickle_Closure_declarations() {\n/** @type {?} */\nCookieService.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nCookieService.ctorParameters;\n/** @type {?} */\nCookieService.prototype.documentIsAccessible;\n/** @type {?} */\nCookieService.prototype.document;\n/** @type {?} */\nCookieService.prototype.platformId;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"],"names":["InjectionToken","Inject","PLATFORM_ID","DOCUMENT","Injectable","isPlatformBrowser"],"mappings":";;;;;;AAAA;;;AAKA,IAAA,aAAA,IAAA,YAAA;;;;;IAQA,SAAA,aAAA,CAGa,QAAU,EAEV,UAAkC,EAL/C;QAGa,IAAb,CAAA,QAAa,GAAA,QAAA,CAAU;QAEV,IAAb,CAAA,UAAa,GAAA,UAAA,CAAkC;QAD3C,IAAI,CAAC,oBAAoB,GAAGK,wBAAiB,CAAE,IAAI,CAAC,UAAU,CAAE,CAAC;KAClE;;;;;IAKH,aAAA,CAAA,SAAA,CAAA,KAIG,GAJH,UAIG,IAAA,EAJH;QACI,IAIK,CAAA,IAAE,CAAI,oBAAqB,EAAE;YAHhC,OAIO,KAAA,CAAM;SAHd;QAED,IAAI,GAIG,kBAAA,CAAoB,IAAA,CAAK,CAAE;QAFlC,qBAIM,MAAA,GAAiB,IAAA,CAAK,eAAC,CAAgB,IAAA,CAAK,CAAE;QAHpD,qBAIM,MAAA,GAAkB,MAAA,CAA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E,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAEH,WAAM,EAAE,IAAI,EAAE,CAACE,eAAQ,EAAG,EAAE,EAAG,EAAC;IACvE,EAAC,IAAI,EAAEH,mBAAc,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAEC,WAAM,EAAE,IAAI,EAAE,CAACC,gBAAW,EAAG,EAAE,EAAG,EAAC;CAC9E,CAAD,EAAC,CAAC;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common"],t):t(e["ngx-cookie-service"]={},e.ng.core,e.ng.common)}(this,function(e,t,o){"use strict";var n=(i.prototype.check=function(e){return!!this.documentIsAccessible&&(e=encodeURIComponent(e),this.getCookieRegExp(e).test(this.document.cookie))},i.prototype.get=function(e){if(this.documentIsAccessible&&this.check(e)){e=encodeURIComponent(e);var t=this.getCookieRegExp(e).exec(this.document.cookie);return decodeURIComponent(t[1])}return""},i.prototype.getAll=function(){if(!this.documentIsAccessible)return{};var e={},t=this.document;if(t.cookie&&""!==t.cookie)for(var o=t.cookie.split(";"),n=0;n<o.length;n+=1){var i=o[n].split("=");i[0]=i[0].replace(/^ /,""),e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e},i.prototype.set=function(e,t,o,n,i,c,r){if(void 0===r&&(r="None"),this.documentIsAccessible){var s=encodeURIComponent(e)+"="+encodeURIComponent(t)+";";o&&(s+="number"==typeof o?"expires="+new Date((new Date).getTime()+1e3*o*60*60*24).toUTCString()+";":"expires="+o.toUTCString()+";"),n&&(s+="path="+n+";"),i&&(s+="domain="+i+";"),c&&(s+="secure;"),s+="sameSite="+r+";",this.document.cookie=s}},i.prototype["delete"]=function(e,t,o){this.documentIsAccessible&&this.set(e,"",new Date("Thu, 01 Jan 1970 00:00:01 GMT"),t,o)},i.prototype.deleteAll=function(e,t){if(this.documentIsAccessible){var o=this.getAll();for(var n in o)o.hasOwnProperty(n)&&this["delete"](n,e,t)}},i.prototype.getCookieRegExp=function(e){var t=e.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi,"\\$1");return new RegExp("(?:^"+t+"|;\\s*"+t+")=(.*?)(?:;|$)","g")},i);function i(e,t){this.document=e,this.platformId=t,this.documentIsAccessible=o.isPlatformBrowser(this.platformId)}n.decorators=[{type:t.Injectable}],n.ctorParameters=function(){return[{type:undefined,decorators:[{type:t.Inject,args:[o.DOCUMENT]}]},{type:t.InjectionToken,decorators:[{type:t.Inject,args:[t.PLATFORM_ID]}]}]},e.CookieService=n,Object.defineProperty(e,"__esModule",{value:!0})});
2
+ //# sourceMappingURL=ngx-cookie-service.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-cookie-service.umd.min.js","sources":["~/ngx-cookie-service/lib/cookie-service/cookie.service.ts"],"sourcesContent":["// This service is based on the `ng2-cookies` package which sadly is not a service and does\n// not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.\n// Package: https://github.com/BCJTI/ng2-cookies\n\nimport { Injectable, Inject, PLATFORM_ID, InjectionToken } from '@angular/core';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\n\n@Injectable()\nexport class CookieService {\n private readonly documentIsAccessible: boolean;\n\n constructor(\n // The type `Document` may not be used here. Although a fix is on its way,\n // we will go with `any` for now to support Angular 2.4.x projects.\n // Issue: https://github.com/angular/angular/issues/12631\n // Fix: https://github.com/angular/angular/pull/14894\n @Inject( DOCUMENT ) private document: any,\n // Get the `PLATFORM_ID` so we can check if we're in a browser.\n @Inject( PLATFORM_ID ) private platformId: InjectionToken<Object>,\n ) {\n this.documentIsAccessible = isPlatformBrowser( this.platformId );\n }\n\n /**\n * @param name Cookie name\n * @returns {boolean}\n */\n check( name: string ): boolean {\n if ( !this.documentIsAccessible ) {\n return false;\n }\n\n name = encodeURIComponent( name );\n\n const regExp: RegExp = this.getCookieRegExp( name );\n const exists: boolean = regExp.test( this.document.cookie );\n\n return exists;\n }\n\n /**\n * @param name Cookie name\n * @returns {any}\n */\n get( name: string ): string {\n if ( this.documentIsAccessible && this.check( name ) ) {\n name = encodeURIComponent( name );\n\n const regExp: RegExp = this.getCookieRegExp( name );\n const result: RegExpExecArray = regExp.exec( this.document.cookie );\n\n return decodeURIComponent( result[ 1 ] );\n } else {\n return '';\n }\n }\n\n /**\n * @returns {}\n */\n getAll(): {} {\n if ( !this.documentIsAccessible ) {\n return {};\n }\n\n const cookies: {} = {};\n const document: any = this.document;\n\n if ( document.cookie && document.cookie !== '' ) {\n const split: Array<string> = document.cookie.split(';');\n\n for ( let i = 0; i < split.length; i += 1 ) {\n const currentCookie: Array<string> = split[ i ].split('=');\n\n currentCookie[ 0 ] = currentCookie[ 0 ].replace( /^ /, '' );\n cookies[ decodeURIComponent( currentCookie[ 0 ] ) ] = decodeURIComponent( currentCookie[ 1 ] );\n }\n }\n\n return cookies;\n }\n\n /**\n * @param name Cookie name\n * @param value Cookie value\n * @param expires Number of days until the cookies expires or an actual `Date`\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Secure flag\n * @param sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`\n */\n set(\n name: string,\n value: string,\n expires?: number | Date,\n path?: string,\n domain?: string,\n secure?: boolean,\n sameSite: 'Lax' | 'None' | 'Strict' = 'None'\n ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n let cookieString: string = encodeURIComponent( name ) + '=' + encodeURIComponent( value ) + ';';\n\n if ( expires ) {\n if ( typeof expires === 'number' ) {\n const dateExpires: Date = new Date( new Date().getTime() + expires * 1000 * 60 * 60 * 24 );\n\n cookieString += 'expires=' + dateExpires.toUTCString() + ';';\n } else {\n cookieString += 'expires=' + expires.toUTCString() + ';';\n }\n }\n\n if ( path ) {\n cookieString += 'path=' + path + ';';\n }\n\n if ( domain ) {\n cookieString += 'domain=' + domain + ';';\n }\n\n if ( secure ) {\n cookieString += 'secure;';\n }\n\n cookieString += 'sameSite=' + sameSite + ';';\n\n this.document.cookie = cookieString;\n }\n\n /**\n * @param name Cookie name\n * @param path Cookie path\n * @param domain Cookie domain\n */\n delete( name: string, path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n this.set( name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain );\n }\n\n /**\n * @param path Cookie path\n * @param domain Cookie domain\n */\n deleteAll( path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n const cookies: any = this.getAll();\n\n for ( const cookieName in cookies ) {\n if ( cookies.hasOwnProperty( cookieName ) ) {\n this.delete( cookieName, path, domain );\n }\n }\n }\n\n /**\n * @param name Cookie name\n * @returns {RegExp}\n */\n private getCookieRegExp( name: string ): RegExp {\n const escapedName: string = name.replace( /([\\[\\]\\{\\}\\(\\)\\|\\=\\;\\+\\?\\,\\.\\*\\^\\$])/ig, '\\\\$1' );\n\n return new RegExp( '(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g' );\n }\n}\n"],"names":["CookieService","prototype","check","name","this","documentIsAccessible","encodeURIComponent","getCookieRegExp","test","document","cookie","get","result","exec","decodeURIComponent","getAll","cookies","split","i","length","currentCookie","replace","set","value","expires","path","domain","secure","sameSite","cookieString","Date","getTime","toUTCString","delete","deleteAll","cookieName","hasOwnProperty","escapedName","RegExp","platformId","isPlatformBrowser","decorators","type","Injectable","ctorParameters","undefined","Inject","args","DOCUMENT","InjectionToken","PLATFORM_ID"],"mappings":"wTAKA,IAAAA,GAkBAA,EAAAC,UAAAC,MAAA,SAIGC,GAHC,QAIKC,KAAMC,uBAAXF,EAIOG,mBAAoBH,GAEJC,KAAKG,gBAAiBJ,GACdK,KAAMJ,KAAKK,SAASC,UAIvDV,EAAAC,UAAAU,IAAA,SAKGR,GAJC,GAKKC,KAAKC,sBAAwBD,KAAKF,MAAOC,GAAS,CAJ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qBANX,CAIA,IAMMW,EAAeZ,KAAKW,SAJ1B,IAMM,IAAMoB,KAAcnB,EACnBA,EAAQoB,eAAgBD,IAL3B/B,KAMK6B,UAAQE,EAAYV,EAAMC,KASpC1B,EAAHC,UAAAM,gBAAG,SAAAJ,GANC,IAOMkC,EAAsBlC,EAAKkB,QAAS,yCAA0C,QALpF,OAOO,IAAIiB,OAAQ,OAASD,EAAc,SAAWA,EAAc,iBAAkB,SA9JzF,SAAArC,EAGaS,EAEA8B,GAFAnC,KAAbK,SAAaA,EAEAL,KAAbmC,WAAaA,EADTnC,KAAKC,qBAAuBmC,EAAAA,kBAAmBpC,KAAKmC,YA4JjDvC,EAAPyC,WAA2C,CAN3C,CAOEC,KAAMC,EAAAA,aAGP3C,EAAD4C,eAAC,WAAA,MAAA,CAJD,CAACF,KAAMG,UAAWJ,WAAY,CAAC,CAAEC,KAAMI,EAAAA,OAAQC,KAAM,CAACC,EAAAA,aACtD,CAACN,KAAMO,EAAAA,eAAgBR,WAAY,CAAC,CAAEC,KAAMI,EAAAA,OAAQC,KAAM,CAACG,EAAAA"}
@@ -0,0 +1,47 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ export declare class CookieService {
3
+ private document;
4
+ private platformId;
5
+ private readonly documentIsAccessible;
6
+ constructor(document: any, platformId: InjectionToken<Object>);
7
+ /**
8
+ * @param name Cookie name
9
+ * @returns {boolean}
10
+ */
11
+ check(name: string): boolean;
12
+ /**
13
+ * @param name Cookie name
14
+ * @returns {any}
15
+ */
16
+ get(name: string): string;
17
+ /**
18
+ * @returns {}
19
+ */
20
+ getAll(): {};
21
+ /**
22
+ * @param name Cookie name
23
+ * @param value Cookie value
24
+ * @param expires Number of days until the cookies expires or an actual `Date`
25
+ * @param path Cookie path
26
+ * @param domain Cookie domain
27
+ * @param secure Secure flag
28
+ * @param sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`
29
+ */
30
+ set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
31
+ /**
32
+ * @param name Cookie name
33
+ * @param path Cookie path
34
+ * @param domain Cookie domain
35
+ */
36
+ delete(name: string, path?: string, domain?: string): void;
37
+ /**
38
+ * @param path Cookie path
39
+ * @param domain Cookie domain
40
+ */
41
+ deleteAll(path?: string, domain?: string): void;
42
+ /**
43
+ * @param name Cookie name
44
+ * @returns {RegExp}
45
+ */
46
+ private getCookieRegExp(name);
47
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
@@ -0,0 +1,152 @@
1
+ import { Inject, Injectable, InjectionToken, PLATFORM_ID } from '@angular/core';
2
+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
3
+ // This service is based on the `ng2-cookies` package which sadly is not a service and does
4
+ // not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.
5
+ // Package: https://github.com/BCJTI/ng2-cookies
6
+ var CookieService = (function () {
7
+ /**
8
+ * @param {?} document
9
+ * @param {?} platformId
10
+ */
11
+ function CookieService(document, platformId) {
12
+ this.document = document;
13
+ this.platformId = platformId;
14
+ this.documentIsAccessible = isPlatformBrowser(this.platformId);
15
+ }
16
+ /**
17
+ * @param {?} name Cookie name
18
+ * @return {?}
19
+ */
20
+ CookieService.prototype.check = function (name) {
21
+ if (!this.documentIsAccessible) {
22
+ return false;
23
+ }
24
+ name = encodeURIComponent(name);
25
+ var /** @type {?} */ regExp = this.getCookieRegExp(name);
26
+ var /** @type {?} */ exists = regExp.test(this.document.cookie);
27
+ return exists;
28
+ };
29
+ /**
30
+ * @param {?} name Cookie name
31
+ * @return {?}
32
+ */
33
+ CookieService.prototype.get = function (name) {
34
+ if (this.documentIsAccessible && this.check(name)) {
35
+ name = encodeURIComponent(name);
36
+ var /** @type {?} */ regExp = this.getCookieRegExp(name);
37
+ var /** @type {?} */ result = regExp.exec(this.document.cookie);
38
+ return decodeURIComponent(result[1]);
39
+ }
40
+ else {
41
+ return '';
42
+ }
43
+ };
44
+ /**
45
+ * @return {?}
46
+ */
47
+ CookieService.prototype.getAll = function () {
48
+ if (!this.documentIsAccessible) {
49
+ return {};
50
+ }
51
+ var /** @type {?} */ cookies = {};
52
+ var /** @type {?} */ document = this.document;
53
+ if (document.cookie && document.cookie !== '') {
54
+ var /** @type {?} */ split = document.cookie.split(';');
55
+ for (var /** @type {?} */ i = 0; i < split.length; i += 1) {
56
+ var /** @type {?} */ currentCookie = split[i].split('=');
57
+ currentCookie[0] = currentCookie[0].replace(/^ /, '');
58
+ cookies[decodeURIComponent(currentCookie[0])] = decodeURIComponent(currentCookie[1]);
59
+ }
60
+ }
61
+ return cookies;
62
+ };
63
+ /**
64
+ * @param {?} name Cookie name
65
+ * @param {?} value Cookie value
66
+ * @param {?=} expires Number of days until the cookies expires or an actual `Date`
67
+ * @param {?=} path Cookie path
68
+ * @param {?=} domain Cookie domain
69
+ * @param {?=} secure Secure flag
70
+ * @param {?=} sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`
71
+ * @return {?}
72
+ */
73
+ CookieService.prototype.set = function (name, value, expires, path, domain, secure, sameSite) {
74
+ if (sameSite === void 0) { sameSite = 'None'; }
75
+ if (!this.documentIsAccessible) {
76
+ return;
77
+ }
78
+ var /** @type {?} */ cookieString = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';
79
+ if (expires) {
80
+ if (typeof expires === 'number') {
81
+ var /** @type {?} */ dateExpires = new Date(new Date().getTime() + expires * 1000 * 60 * 60 * 24);
82
+ cookieString += 'expires=' + dateExpires.toUTCString() + ';';
83
+ }
84
+ else {
85
+ cookieString += 'expires=' + expires.toUTCString() + ';';
86
+ }
87
+ }
88
+ if (path) {
89
+ cookieString += 'path=' + path + ';';
90
+ }
91
+ if (domain) {
92
+ cookieString += 'domain=' + domain + ';';
93
+ }
94
+ if (secure) {
95
+ cookieString += 'secure;';
96
+ }
97
+ cookieString += 'sameSite=' + sameSite + ';';
98
+ this.document.cookie = cookieString;
99
+ };
100
+ /**
101
+ * @param {?} name Cookie name
102
+ * @param {?=} path Cookie path
103
+ * @param {?=} domain Cookie domain
104
+ * @return {?}
105
+ */
106
+ CookieService.prototype.delete = function (name, path, domain) {
107
+ if (!this.documentIsAccessible) {
108
+ return;
109
+ }
110
+ this.set(name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain);
111
+ };
112
+ /**
113
+ * @param {?=} path Cookie path
114
+ * @param {?=} domain Cookie domain
115
+ * @return {?}
116
+ */
117
+ CookieService.prototype.deleteAll = function (path, domain) {
118
+ if (!this.documentIsAccessible) {
119
+ return;
120
+ }
121
+ var /** @type {?} */ cookies = this.getAll();
122
+ for (var /** @type {?} */ cookieName in cookies) {
123
+ if (cookies.hasOwnProperty(cookieName)) {
124
+ this.delete(cookieName, path, domain);
125
+ }
126
+ }
127
+ };
128
+ /**
129
+ * @param {?} name Cookie name
130
+ * @return {?}
131
+ */
132
+ CookieService.prototype.getCookieRegExp = function (name) {
133
+ var /** @type {?} */ escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/ig, '\\$1');
134
+ return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
135
+ };
136
+ return CookieService;
137
+ }());
138
+ CookieService.decorators = [
139
+ { type: Injectable },
140
+ ];
141
+ /**
142
+ * @nocollapse
143
+ */
144
+ CookieService.ctorParameters = function () { return [
145
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
146
+ { type: InjectionToken, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
147
+ ]; };
148
+ /**
149
+ * Generated bundle index. Do not edit.
150
+ */
151
+ export { CookieService };
152
+ //# sourceMappingURL=ngx-cookie-service.es5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-cookie-service.es5.js","sources":["ts/lib/ngx-cookie-service.ts","ts/lib/cookie-service/cookie.service.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport {CookieService} from './index';\n","// This service is based on the `ng2-cookies` package which sadly is not a service and does\n// not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.\n// Package: https://github.com/BCJTI/ng2-cookies\n\n\nimport { Injectable, Inject, PLATFORM_ID, InjectionToken } from '@angular/core';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nexport class CookieService {\nprivate readonly documentIsAccessible: boolean;\n/**\n * @param {?} document\n * @param {?} platformId\n */\nconstructor(\nprivate document: any,\nprivate platformId: InjectionToken<Object>,\n ) {\n this.documentIsAccessible = isPlatformBrowser( this.platformId );\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\ncheck( name: string ): boolean {\n if ( !this.documentIsAccessible ) {\n return false;\n }\n\n name = encodeURIComponent( name );\n\n const /** @type {?} */ regExp: RegExp = this.getCookieRegExp( name );\n const /** @type {?} */ exists: boolean = regExp.test( this.document.cookie );\n\n return exists;\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\nget( name: string ): string {\n if ( this.documentIsAccessible && this.check( name ) ) {\n name = encodeURIComponent( name );\n\n const /** @type {?} */ regExp: RegExp = this.getCookieRegExp( name );\n const /** @type {?} */ result: RegExpExecArray = regExp.exec( this.document.cookie );\n\n return decodeURIComponent( result[ 1 ] );\n } else {\n return '';\n }\n }\n/**\n * @return {?}\n */\ngetAll(): {} {\n if ( !this.documentIsAccessible ) {\n return {};\n }\n\n const /** @type {?} */ cookies: {} = {};\n const /** @type {?} */ document: any = this.document;\n\n if ( document.cookie && document.cookie !== '' ) {\n const /** @type {?} */ split: Array<string> = document.cookie.split(';');\n\n for ( let /** @type {?} */ i = 0; i < split.length; i += 1 ) {\n const /** @type {?} */ currentCookie: Array<string> = split[ i ].split('=');\n\n currentCookie[ 0 ] = currentCookie[ 0 ].replace( /^ /, '' );\n cookies[ decodeURIComponent( currentCookie[ 0 ] ) ] = decodeURIComponent( currentCookie[ 1 ] );\n }\n }\n\n return cookies;\n }\n/**\n * @param {?} name Cookie name\n * @param {?} value Cookie value\n * @param {?=} expires Number of days until the cookies expires or an actual `Date`\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @param {?=} secure Secure flag\n * @param {?=} sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`\n * @return {?}\n */\nset(\n name: string,\n value: string,\n expires?: number | Date,\n path?: string,\n domain?: string,\n secure?: boolean,\n sameSite: 'Lax' | 'None' | 'Strict' = 'None'\n ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n let /** @type {?} */ cookieString: string = encodeURIComponent( name ) + '=' + encodeURIComponent( value ) + ';';\n\n if ( expires ) {\n if ( typeof expires === 'number' ) {\n const /** @type {?} */ dateExpires: Date = new Date( new Date().getTime() + expires * 1000 * 60 * 60 * 24 );\n\n cookieString += 'expires=' + dateExpires.toUTCString() + ';';\n } else {\n cookieString += 'expires=' + expires.toUTCString() + ';';\n }\n }\n\n if ( path ) {\n cookieString += 'path=' + path + ';';\n }\n\n if ( domain ) {\n cookieString += 'domain=' + domain + ';';\n }\n\n if ( secure ) {\n cookieString += 'secure;';\n }\n\n cookieString += 'sameSite=' + sameSite + ';';\n\n this.document.cookie = cookieString;\n }\n/**\n * @param {?} name Cookie name\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @return {?}\n */\ndelete( name: string, path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n this.set( name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain );\n }\n/**\n * @param {?=} path Cookie path\n * @param {?=} domain Cookie domain\n * @return {?}\n */\ndeleteAll( path?: string, domain?: string ): void {\n if ( !this.documentIsAccessible ) {\n return;\n }\n\n const /** @type {?} */ cookies: any = this.getAll();\n\n for ( const /** @type {?} */ cookieName in cookies ) {\n if ( cookies.hasOwnProperty( cookieName ) ) {\n this.delete( cookieName, path, domain );\n }\n }\n }\n/**\n * @param {?} name Cookie name\n * @return {?}\n */\nprivate getCookieRegExp( name: string ): RegExp {\n const /** @type {?} */ escapedName: string = name.replace( /([\\[\\]\\{\\}\\(\\)\\|\\=\\;\\+\\?\\,\\.\\*\\^\\$])/ig, '\\\\$1' );\n\n return new RegExp( '(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g' );\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: undefined, decorators: [{ type: Inject, args: [DOCUMENT, ] }, ]},\n{type: InjectionToken, decorators: [{ type: Inject, args: [PLATFORM_ID, ] }, ]},\n];\n}\n\nfunction CookieService_tsickle_Closure_declarations() {\n/** @type {?} */\nCookieService.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nCookieService.ctorParameters;\n/** @type {?} */\nCookieService.prototype.documentIsAccessible;\n/** @type {?} */\nCookieService.prototype.document;\n/** @type {?} */\nCookieService.prototype.platformId;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"],"names":[],"mappings":";;ACAA,2FAAA;;;AAKA;;;;;IAQA,uBAGa,QAAU,EAEV,UAAkC;QAFlC,IAAb,CAAA,QAAa,GAAA,QAAA,CAAU;QAEV,IAAb,CAAA,UAAa,GAAA,UAAA,CAAkC;QAD3C,IAAI,CAAC,oBAAoB,GAAG,iBAAiB,CAAE,IAAI,CAAC,UAAU,CAAE,CAAC;IACrE,CAAG;;;;;IAKH,6BAIG,GAJH,UAIG,IAAA;QAHC,EAAJ,CAAA,CAIS,CAAA,IAAE,CAAI,oBAAqB,CAJpC,CAIsC,CAJtC;YACM,MAAN,CAIa,KAAA,CAAM;QAHnB,CAAK;QAED,IAAI,GAIG,kBAAA,CAAoB,IAAA,CAAK,CAAE;QAFlC,IAAJ,gBAAA,CAIU,MAAA,GAAiB,IAAA,CAAK,eAAC,CAAgB,IAAA,CAAK,CAAE;QAHpD,IA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EAAM,MAAA,CAAO,CAAE;YALhD,CAAO;QACP,CAAK;IACL,CAAG;;;;;IAYA,uCAAA,GAAA,UAAA,IAAA;QANC,IAAJ,gBAAA,CAOU,WAAA,GAAsB,IAAA,CAAK,OAAC,CAAQ,wCAAA,EAA0C,MAAA,CAAO,CAAE;QAL7F,MAAJ,CAOW,IAAI,MAAA,CAAQ,MAAA,GAAS,WAAA,GAAc,QAAA,GAAW,WAAA,GAAc,gBAAA,EAAkB,GAAA,CAAI,CAAE;IAN/F,CAAG;;CAhKH;AAwKO,aAAP,CAAA,UAAO,GAAoC;IAN3C,EAOE,IAAA,EAAM,UAAA,EAAW;CANlB,CAOC;;;;AAED,aAAD,CAAA,cAAC,GAAA,cAAA,OAAA;IAJD,EAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAG,EAAE,EAAG,EAAC;IACvE,EAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EAAG,EAAE,EAAG,EAAC;CAC9E,EAEA,CAFA,CAAC;AD/KF;;GAEG;"}
@@ -0,0 +1,153 @@
1
+ import { Inject, Injectable, InjectionToken, PLATFORM_ID } from '@angular/core';
2
+ import { DOCUMENT, isPlatformBrowser } from '@angular/common';
3
+
4
+ // This service is based on the `ng2-cookies` package which sadly is not a service and does
5
+ // not use `DOCUMENT` injection and therefore doesn't work well with AoT production builds.
6
+ // Package: https://github.com/BCJTI/ng2-cookies
7
+ class CookieService {
8
+ /**
9
+ * @param {?} document
10
+ * @param {?} platformId
11
+ */
12
+ constructor(document, platformId) {
13
+ this.document = document;
14
+ this.platformId = platformId;
15
+ this.documentIsAccessible = isPlatformBrowser(this.platformId);
16
+ }
17
+ /**
18
+ * @param {?} name Cookie name
19
+ * @return {?}
20
+ */
21
+ check(name) {
22
+ if (!this.documentIsAccessible) {
23
+ return false;
24
+ }
25
+ name = encodeURIComponent(name);
26
+ const /** @type {?} */ regExp = this.getCookieRegExp(name);
27
+ const /** @type {?} */ exists = regExp.test(this.document.cookie);
28
+ return exists;
29
+ }
30
+ /**
31
+ * @param {?} name Cookie name
32
+ * @return {?}
33
+ */
34
+ get(name) {
35
+ if (this.documentIsAccessible && this.check(name)) {
36
+ name = encodeURIComponent(name);
37
+ const /** @type {?} */ regExp = this.getCookieRegExp(name);
38
+ const /** @type {?} */ result = regExp.exec(this.document.cookie);
39
+ return decodeURIComponent(result[1]);
40
+ }
41
+ else {
42
+ return '';
43
+ }
44
+ }
45
+ /**
46
+ * @return {?}
47
+ */
48
+ getAll() {
49
+ if (!this.documentIsAccessible) {
50
+ return {};
51
+ }
52
+ const /** @type {?} */ cookies = {};
53
+ const /** @type {?} */ document = this.document;
54
+ if (document.cookie && document.cookie !== '') {
55
+ const /** @type {?} */ split = document.cookie.split(';');
56
+ for (let /** @type {?} */ i = 0; i < split.length; i += 1) {
57
+ const /** @type {?} */ currentCookie = split[i].split('=');
58
+ currentCookie[0] = currentCookie[0].replace(/^ /, '');
59
+ cookies[decodeURIComponent(currentCookie[0])] = decodeURIComponent(currentCookie[1]);
60
+ }
61
+ }
62
+ return cookies;
63
+ }
64
+ /**
65
+ * @param {?} name Cookie name
66
+ * @param {?} value Cookie value
67
+ * @param {?=} expires Number of days until the cookies expires or an actual `Date`
68
+ * @param {?=} path Cookie path
69
+ * @param {?=} domain Cookie domain
70
+ * @param {?=} secure Secure flag
71
+ * @param {?=} sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `None`
72
+ * @return {?}
73
+ */
74
+ set(name, value, expires, path, domain, secure, sameSite = 'None') {
75
+ if (!this.documentIsAccessible) {
76
+ return;
77
+ }
78
+ let /** @type {?} */ cookieString = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';
79
+ if (expires) {
80
+ if (typeof expires === 'number') {
81
+ const /** @type {?} */ dateExpires = new Date(new Date().getTime() + expires * 1000 * 60 * 60 * 24);
82
+ cookieString += 'expires=' + dateExpires.toUTCString() + ';';
83
+ }
84
+ else {
85
+ cookieString += 'expires=' + expires.toUTCString() + ';';
86
+ }
87
+ }
88
+ if (path) {
89
+ cookieString += 'path=' + path + ';';
90
+ }
91
+ if (domain) {
92
+ cookieString += 'domain=' + domain + ';';
93
+ }
94
+ if (secure) {
95
+ cookieString += 'secure;';
96
+ }
97
+ cookieString += 'sameSite=' + sameSite + ';';
98
+ this.document.cookie = cookieString;
99
+ }
100
+ /**
101
+ * @param {?} name Cookie name
102
+ * @param {?=} path Cookie path
103
+ * @param {?=} domain Cookie domain
104
+ * @return {?}
105
+ */
106
+ delete(name, path, domain) {
107
+ if (!this.documentIsAccessible) {
108
+ return;
109
+ }
110
+ this.set(name, '', new Date('Thu, 01 Jan 1970 00:00:01 GMT'), path, domain);
111
+ }
112
+ /**
113
+ * @param {?=} path Cookie path
114
+ * @param {?=} domain Cookie domain
115
+ * @return {?}
116
+ */
117
+ deleteAll(path, domain) {
118
+ if (!this.documentIsAccessible) {
119
+ return;
120
+ }
121
+ const /** @type {?} */ cookies = this.getAll();
122
+ for (const /** @type {?} */ cookieName in cookies) {
123
+ if (cookies.hasOwnProperty(cookieName)) {
124
+ this.delete(cookieName, path, domain);
125
+ }
126
+ }
127
+ }
128
+ /**
129
+ * @param {?} name Cookie name
130
+ * @return {?}
131
+ */
132
+ getCookieRegExp(name) {
133
+ const /** @type {?} */ escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/ig, '\\$1');
134
+ return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
135
+ }
136
+ }
137
+ CookieService.decorators = [
138
+ { type: Injectable },
139
+ ];
140
+ /**
141
+ * @nocollapse
142
+ */
143
+ CookieService.ctorParameters = () => [
144
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
145
+ { type: InjectionToken, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] },
146
+ ];
147
+
148
+ /**
149
+ * Generated bundle index. Do not edit.
150
+ */
151
+
152
+ export { CookieService };
153
+ //# sourceMappingURL=ngx-cookie-service.js.map