1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = void 0;
|
5 |
|
6 | var Cookies = _interopRequireWildcard(require("js-cookie"));
|
7 |
|
8 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
9 |
|
10 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11 |
|
12 |
|
13 | var CookieStorage = function () {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function CookieStorage(data) {
|
23 | if (data.domain) {
|
24 | this.domain = data.domain;
|
25 | } else {
|
26 | throw new Error('The domain of cookieStorage can not be undefined.');
|
27 | }
|
28 |
|
29 | if (data.path) {
|
30 | this.path = data.path;
|
31 | } else {
|
32 | this.path = '/';
|
33 | }
|
34 |
|
35 | if (Object.prototype.hasOwnProperty.call(data, 'expires')) {
|
36 | this.expires = data.expires;
|
37 | } else {
|
38 | this.expires = 365;
|
39 | }
|
40 |
|
41 | if (Object.prototype.hasOwnProperty.call(data, 'secure')) {
|
42 | this.secure = data.secure;
|
43 | } else {
|
44 | this.secure = true;
|
45 | }
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | var _proto = CookieStorage.prototype;
|
56 |
|
57 | _proto.setItem = function setItem(key, value) {
|
58 | Cookies.set(key, value, {
|
59 | path: this.path,
|
60 | expires: this.expires,
|
61 | domain: this.domain,
|
62 | secure: this.secure
|
63 | });
|
64 | return Cookies.get(key);
|
65 | }
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | ;
|
73 |
|
74 | _proto.getItem = function getItem(key) {
|
75 | return Cookies.get(key);
|
76 | }
|
77 | |
78 |
|
79 |
|
80 |
|
81 |
|
82 | ;
|
83 |
|
84 | _proto.removeItem = function removeItem(key) {
|
85 | return Cookies.remove(key, {
|
86 | path: this.path,
|
87 | domain: this.domain,
|
88 | secure: this.secure
|
89 | });
|
90 | }
|
91 | |
92 |
|
93 |
|
94 |
|
95 | ;
|
96 |
|
97 | _proto.clear = function clear() {
|
98 | var cookies = Cookies.get();
|
99 | var index;
|
100 |
|
101 | for (index = 0; index < cookies.length; ++index) {
|
102 | Cookies.remove(cookies[index]);
|
103 | }
|
104 |
|
105 | return {};
|
106 | };
|
107 |
|
108 | return CookieStorage;
|
109 | }();
|
110 |
|
111 | exports["default"] = CookieStorage; |
\ | No newline at end of file |