@mjhls/mjh-framework 1.0.691-beta.6 → 1.0.691-beta.8

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 (43) hide show
  1. package/dist/cjs/ADGutter.js +3 -2
  2. package/dist/cjs/{ADInfeed-fd8c792f.js → ADInfeed-1b449a61.js} +3 -2
  3. package/dist/cjs/ADSkyscraper.js +3 -2
  4. package/dist/cjs/ADSponsoredResources.js +3 -2
  5. package/dist/cjs/ADWebcast.js +3 -2
  6. package/dist/cjs/{ADlgInfeed-40259fe0.js → ADlgInfeed-7dc86b35.js} +3 -2
  7. package/dist/cjs/AdSlot.js +1 -1
  8. package/dist/cjs/Auth.js +206 -6
  9. package/dist/cjs/DeckContent.js +2 -1
  10. package/dist/cjs/ExternalResources.js +1 -1
  11. package/dist/cjs/GridContent.js +4 -2
  12. package/dist/cjs/IssueLanding.js +2 -2
  13. package/dist/cjs/MasterDeck.js +4 -2
  14. package/dist/cjs/PartnerDetailListing.js +3 -3
  15. package/dist/cjs/QueueDeckExpanded.js +4 -2
  16. package/dist/cjs/View.js +3 -3
  17. package/dist/cjs/getRelatedArticle.js +5 -354
  18. package/dist/cjs/getSerializers.js +1 -1
  19. package/dist/cjs/index.js +6 -6
  20. package/dist/esm/ADGutter.js +3 -2
  21. package/dist/esm/{ADInfeed-af6b0616.js → ADInfeed-5a2f924b.js} +3 -2
  22. package/dist/esm/ADSkyscraper.js +3 -2
  23. package/dist/esm/ADSponsoredResources.js +3 -2
  24. package/dist/esm/ADWebcast.js +3 -2
  25. package/dist/esm/{ADlgInfeed-27ba8238.js → ADlgInfeed-c0a01f39.js} +3 -2
  26. package/dist/esm/AdSlot.js +1 -1
  27. package/dist/esm/Auth.js +201 -1
  28. package/dist/esm/DeckContent.js +2 -1
  29. package/dist/esm/ExternalResources.js +1 -1
  30. package/dist/esm/GridContent.js +4 -2
  31. package/dist/esm/IssueLanding.js +2 -2
  32. package/dist/esm/MasterDeck.js +4 -2
  33. package/dist/esm/PartnerDetailListing.js +3 -3
  34. package/dist/esm/QueueDeckExpanded.js +4 -2
  35. package/dist/esm/View.js +3 -3
  36. package/dist/esm/getRelatedArticle.js +5 -354
  37. package/dist/esm/getSerializers.js +1 -1
  38. package/dist/esm/index.js +5 -5
  39. package/package.json +1 -1
  40. package/dist/cjs/index-bd6c9f56.js +0 -211
  41. package/dist/esm/index-db3bb315.js +0 -207
  42. /package/dist/cjs/{index-1735f801.js → index-9ced0453.js} +0 -0
  43. /package/dist/esm/{index-273cc821.js → index-3be21153.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { c as createCommonjsModule, u as unwrapExports, a as commonjsGlobal } from './_commonjsHelpers-0c4b6f40.js';
1
+ import './_commonjsHelpers-0c4b6f40.js';
2
2
  import './_to-object-ded78eb9.js';
3
3
  import './es6.string.iterator-9b2af4a5.js';
4
4
  import './_library-528f1934.js';
@@ -7,358 +7,9 @@ import './core.get-iterator-method-54d2e411.js';
7
7
  import './web.dom.iterable-8956f9a5.js';
8
8
  import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-7c654f36.js';
9
9
  import './_set-species-cede29f8.js';
10
- import { c as cookie } from './index-db3bb315.js';
10
+ import { parseCookies, setCookie } from 'nookies';
11
11
  import getQuery from './getQuery.js';
12
12
 
13
- var defaultParseOptions = {
14
- decodeValues: true,
15
- map: false,
16
- silent: false,
17
- };
18
-
19
- function isNonEmptyString(str) {
20
- return typeof str === "string" && !!str.trim();
21
- }
22
-
23
- function parseString(setCookieValue, options) {
24
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
25
- var nameValue = parts.shift().split("=");
26
- var name = nameValue.shift();
27
- var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
28
-
29
- options = options
30
- ? Object.assign({}, defaultParseOptions, options)
31
- : defaultParseOptions;
32
-
33
- var cookie = {
34
- name: name, // grab everything before the first =
35
- value: options.decodeValues ? decodeURIComponent(value) : value, // decode cookie value
36
- };
37
-
38
- parts.forEach(function (part) {
39
- var sides = part.split("=");
40
- var key = sides.shift().trimLeft().toLowerCase();
41
- var value = sides.join("=");
42
- if (key === "expires") {
43
- cookie.expires = new Date(value);
44
- } else if (key === "max-age") {
45
- cookie.maxAge = parseInt(value, 10);
46
- } else if (key === "secure") {
47
- cookie.secure = true;
48
- } else if (key === "httponly") {
49
- cookie.httpOnly = true;
50
- } else if (key === "samesite") {
51
- cookie.sameSite = value;
52
- } else {
53
- cookie[key] = value;
54
- }
55
- });
56
-
57
- return cookie;
58
- }
59
-
60
- function parse(input, options) {
61
- options = options
62
- ? Object.assign({}, defaultParseOptions, options)
63
- : defaultParseOptions;
64
-
65
- if (!input) {
66
- if (!options.map) {
67
- return [];
68
- } else {
69
- return {};
70
- }
71
- }
72
-
73
- if (input.headers && input.headers["set-cookie"]) {
74
- // fast-path for node.js (which automatically normalizes header names to lower-case
75
- input = input.headers["set-cookie"];
76
- } else if (input.headers) {
77
- // slow-path for other environments - see #25
78
- var sch =
79
- input.headers[
80
- Object.keys(input.headers).find(function (key) {
81
- return key.toLowerCase() === "set-cookie";
82
- })
83
- ];
84
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
85
- if (!sch && input.headers.cookie && !options.silent) {
86
- console.warn(
87
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
88
- );
89
- }
90
- input = sch;
91
- }
92
- if (!Array.isArray(input)) {
93
- input = [input];
94
- }
95
-
96
- options = options
97
- ? Object.assign({}, defaultParseOptions, options)
98
- : defaultParseOptions;
99
-
100
- if (!options.map) {
101
- return input.filter(isNonEmptyString).map(function (str) {
102
- return parseString(str, options);
103
- });
104
- } else {
105
- var cookies = {};
106
- return input.filter(isNonEmptyString).reduce(function (cookies, str) {
107
- var cookie = parseString(str, options);
108
- cookies[cookie.name] = cookie;
109
- return cookies;
110
- }, cookies);
111
- }
112
- }
113
-
114
- /*
115
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
116
- that are within a single set-cookie field-value, such as in the Expires portion.
117
-
118
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
119
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
120
- React Native's fetch does this for *every* header, including set-cookie.
121
-
122
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
123
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
124
- */
125
- function splitCookiesString(cookiesString) {
126
- if (Array.isArray(cookiesString)) {
127
- return cookiesString;
128
- }
129
- if (typeof cookiesString !== "string") {
130
- return [];
131
- }
132
-
133
- var cookiesStrings = [];
134
- var pos = 0;
135
- var start;
136
- var ch;
137
- var lastComma;
138
- var nextStart;
139
- var cookiesSeparatorFound;
140
-
141
- function skipWhitespace() {
142
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
143
- pos += 1;
144
- }
145
- return pos < cookiesString.length;
146
- }
147
-
148
- function notSpecialChar() {
149
- ch = cookiesString.charAt(pos);
150
-
151
- return ch !== "=" && ch !== ";" && ch !== ",";
152
- }
153
-
154
- while (pos < cookiesString.length) {
155
- start = pos;
156
- cookiesSeparatorFound = false;
157
-
158
- while (skipWhitespace()) {
159
- ch = cookiesString.charAt(pos);
160
- if (ch === ",") {
161
- // ',' is a cookie separator if we have later first '=', not ';' or ','
162
- lastComma = pos;
163
- pos += 1;
164
-
165
- skipWhitespace();
166
- nextStart = pos;
167
-
168
- while (pos < cookiesString.length && notSpecialChar()) {
169
- pos += 1;
170
- }
171
-
172
- // currently special character
173
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
174
- // we found cookies separator
175
- cookiesSeparatorFound = true;
176
- // pos is inside the next cookie, so back up and return it.
177
- pos = nextStart;
178
- cookiesStrings.push(cookiesString.substring(start, lastComma));
179
- start = pos;
180
- } else {
181
- // in param ',' or param separator ';',
182
- // we continue from that comma
183
- pos = lastComma + 1;
184
- }
185
- } else {
186
- pos += 1;
187
- }
188
- }
189
-
190
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
191
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
192
- }
193
- }
194
-
195
- return cookiesStrings;
196
- }
197
-
198
- var setCookie = parse;
199
- var parse_1 = parse;
200
- var parseString_1 = parseString;
201
- var splitCookiesString_1 = splitCookiesString;
202
- setCookie.parse = parse_1;
203
- setCookie.parseString = parseString_1;
204
- setCookie.splitCookiesString = splitCookiesString_1;
205
-
206
- var dist = createCommonjsModule(function (module, exports) {
207
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
208
- __assign = Object.assign || function(t) {
209
- for (var s, i = 1, n = arguments.length; i < n; i++) {
210
- s = arguments[i];
211
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
212
- t[p] = s[p];
213
- }
214
- return t;
215
- };
216
- return __assign.apply(this, arguments);
217
- };
218
- Object.defineProperty(exports, "__esModule", { value: true });
219
- exports.destroyCookie = exports.setCookie = exports.parseCookies = void 0;
220
-
221
-
222
- var isBrowser = function () { return typeof window !== 'undefined'; };
223
- function hasSameProperties(a, b) {
224
- var aProps = Object.getOwnPropertyNames(a);
225
- var bProps = Object.getOwnPropertyNames(b);
226
- if (aProps.length !== bProps.length) {
227
- return false;
228
- }
229
- for (var i = 0; i < aProps.length; i++) {
230
- var propName = aProps[i];
231
- if (a[propName] !== b[propName]) {
232
- return false;
233
- }
234
- }
235
- return true;
236
- }
237
- /**
238
- * Compare the cookie and return true if the cookies has equivalent
239
- * options and the cookies would be overwritten in the browser storage.
240
- *
241
- * @param a first Cookie for comparison
242
- * @param b second Cookie for comparison
243
- */
244
- function areCookiesEqual(a, b) {
245
- var sameSiteSame = a.sameSite === b.sameSite;
246
- if (typeof a.sameSite === 'string' && typeof b.sameSite === 'string') {
247
- sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
248
- }
249
- return (hasSameProperties(__assign(__assign({}, a), { sameSite: undefined }), __assign(__assign({}, b), { sameSite: undefined })) && sameSiteSame);
250
- }
251
- /**
252
- * Create an instance of the Cookie interface
253
- *
254
- * @param name name of the Cookie
255
- * @param value value of the Cookie
256
- * @param options Cookie options
257
- */
258
- function createCookie(name, value, options) {
259
- var sameSite = options.sameSite;
260
- if (sameSite === true) {
261
- sameSite = 'strict';
262
- }
263
- if (sameSite === undefined || sameSite === false) {
264
- sameSite = 'lax';
265
- }
266
- var cookieToSet = __assign(__assign({}, options), { sameSite: sameSite });
267
- delete cookieToSet.encode;
268
- return __assign({ name: name, value: value }, cookieToSet);
269
- }
270
- /**
271
- *
272
- * Parses cookies.
273
- *
274
- * @param ctx
275
- * @param options
276
- */
277
- function parseCookies(ctx, options) {
278
- if (ctx && ctx.req && ctx.req.headers && ctx.req.headers.cookie) {
279
- return cookie.parse(ctx.req.headers.cookie, options);
280
- }
281
- if (isBrowser()) {
282
- return cookie.parse(document.cookie, options);
283
- }
284
- return {};
285
- }
286
- exports.parseCookies = parseCookies;
287
- /**
288
- *
289
- * Sets a cookie.
290
- *
291
- * @param ctx
292
- * @param name
293
- * @param value
294
- * @param options
295
- */
296
- function setCookie$1(ctx, name, value, options) {
297
- if (ctx && ctx.res && ctx.res.getHeader && ctx.res.setHeader) {
298
- var cookies = ctx.res.getHeader('Set-Cookie') || [];
299
- if (typeof cookies === 'string')
300
- cookies = [cookies];
301
- if (typeof cookies === 'number')
302
- cookies = [];
303
- var parsedCookies = setCookie.parse(cookies);
304
- var cookiesToSet_1 = [];
305
- parsedCookies.forEach(function (parsedCookie) {
306
- if (!areCookiesEqual(parsedCookie, createCookie(name, value, options))) {
307
- cookiesToSet_1.push(cookie.serialize(parsedCookie.name, parsedCookie.value, __assign({ encode: function (val) { return val; } }, parsedCookie)));
308
- }
309
- });
310
- cookiesToSet_1.push(cookie.serialize(name, value, options));
311
- if (!ctx.res.finished) {
312
- ctx.res.setHeader('Set-Cookie', cookiesToSet_1);
313
- }
314
- }
315
- if (isBrowser()) {
316
- if (options && options.httpOnly) {
317
- throw new Error('Can not set a httpOnly cookie in the browser.');
318
- }
319
- document.cookie = cookie.serialize(name, value, options);
320
- }
321
- return {};
322
- }
323
- exports.setCookie = setCookie$1;
324
- /**
325
- *
326
- * Destroys a cookie with a particular name.
327
- *
328
- * @param ctx
329
- * @param name
330
- * @param options
331
- */
332
- function destroyCookie(ctx, name, options) {
333
- var opts = __assign(__assign({}, (options || {})), { maxAge: -1 });
334
- if (ctx && ctx.res && ctx.res.setHeader && ctx.res.getHeader) {
335
- var cookies = ctx.res.getHeader('Set-Cookie') || [];
336
- if (typeof cookies === 'string')
337
- cookies = [cookies];
338
- if (typeof cookies === 'number')
339
- cookies = [];
340
- cookies.push(cookie.serialize(name, '', opts));
341
- ctx.res.setHeader('Set-Cookie', cookies);
342
- }
343
- if (isBrowser()) {
344
- document.cookie = cookie.serialize(name, '', opts);
345
- }
346
- return {};
347
- }
348
- exports.destroyCookie = destroyCookie;
349
- exports.default = {
350
- set: setCookie$1,
351
- get: parseCookies,
352
- destroy: destroyCookie,
353
- };
354
-
355
- });
356
-
357
- unwrapExports(dist);
358
- var dist_1 = dist.destroyCookie;
359
- var dist_2 = dist.setCookie;
360
- var dist_3 = dist.parseCookies;
361
-
362
13
  var _this = undefined;
363
14
 
364
15
  var getRelatedArticle = function () {
@@ -418,13 +69,13 @@ var getRelatedArticle = function () {
418
69
  conditions = '';
419
70
 
420
71
  if (ctx && url) {
421
- cookies = dist_3(ctx);
72
+ cookies = parseCookies(ctx);
422
73
  prevSlugs = cookies['prevSlugs'];
423
74
 
424
75
  if (!!prevSlugs) {
425
- dist_2(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
76
+ setCookie(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
426
77
  conditions = '&& !(url.current in [' + prevSlugs + '])';
427
- } else dist_2(ctx, 'prevSlugs', '"' + url + '"', {});
78
+ } else setCookie(ctx, 'prevSlugs', '"' + url + '"', {});
428
79
  }
429
80
  relatedArticleQuery = getQuery('related', conditions, '', articleCount);
430
81
  _context.next = 12;
@@ -39,7 +39,7 @@ import './smoothscroll-4b699764.js';
39
39
  import './GroupDeck.js';
40
40
  import 'react-bootstrap';
41
41
  import 'react-bootstrap/Button';
42
- export { g as default } from './index-273cc821.js';
42
+ export { g as default } from './index-3be21153.js';
43
43
  import './util-7700fc59.js';
44
44
  import './brightcove-react-player-loader.es-83f53e4e.js';
45
45
  import 'react-bootstrap/Pagination';
package/dist/esm/index.js CHANGED
@@ -38,10 +38,10 @@ import './_set-species-cede29f8.js';
38
38
  export { default as Segment } from './Segment.js';
39
39
  export { default as Beam } from './Beam.js';
40
40
  export { default as AdSlot } from './AdSlot.js';
41
- import './ADInfeed-af6b0616.js';
41
+ import './ADInfeed-5a2f924b.js';
42
42
  export { default as DeckContent } from './DeckContent.js';
43
43
  import './lodash-ec8c6b48.js';
44
- import './ADlgInfeed-27ba8238.js';
44
+ import './ADlgInfeed-c0a01f39.js';
45
45
  import './getContentCategory-15dcc413.js';
46
46
  import './get-5ee14cda.js';
47
47
  export { default as AD } from './AD.js';
@@ -79,7 +79,7 @@ import 'react-bootstrap/Form';
79
79
  import './index-ef6d5dcf.js';
80
80
  import './js.cookie-6874175c.js';
81
81
  export { default as CMEDeck } from './CMEDeck.js';
82
- export { g as getSerializers } from './index-273cc821.js';
82
+ export { g as getSerializers } from './index-3be21153.js';
83
83
  import './util-7700fc59.js';
84
84
  import './brightcove-react-player-loader.es-83f53e4e.js';
85
85
  import 'react-bootstrap/Pagination';
@@ -157,9 +157,9 @@ export { default as ConferenceArticleCard } from './ConferenceArticleCard.js';
157
157
  export { default as KMTracker } from './KMTracker.js';
158
158
  export { default as getSeriesDetail } from './getSeriesDetail.js';
159
159
  export { default as SetCookie } from './SetCookie.js';
160
- import './index-db3bb315.js';
161
- export { default as getRelatedArticle } from './getRelatedArticle.js';
160
+ import 'nookies';
162
161
  export { default as getQuery } from './getQuery.js';
162
+ export { default as getRelatedArticle } from './getRelatedArticle.js';
163
163
  export { default as Auth } from './Auth.js';
164
164
  import 'swr';
165
165
  import 'passport-local';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.691-beta.6",
3
+ "version": "1.0.691-beta.8",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",
@@ -1,211 +0,0 @@
1
- 'use strict';
2
-
3
- /*!
4
- * cookie
5
- * Copyright(c) 2012-2014 Roman Shtylman
6
- * Copyright(c) 2015 Douglas Christopher Wilson
7
- * MIT Licensed
8
- */
9
-
10
- /**
11
- * Module exports.
12
- * @public
13
- */
14
-
15
- var parse_1 = parse;
16
- var serialize_1 = serialize;
17
-
18
- /**
19
- * Module variables.
20
- * @private
21
- */
22
-
23
- var decode = decodeURIComponent;
24
- var encode = encodeURIComponent;
25
- var pairSplitRegExp = /; */;
26
-
27
- /**
28
- * RegExp to match field-content in RFC 7230 sec 3.2
29
- *
30
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
31
- * field-vchar = VCHAR / obs-text
32
- * obs-text = %x80-FF
33
- */
34
-
35
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
36
-
37
- /**
38
- * Parse a cookie header.
39
- *
40
- * Parse the given cookie header string into an object
41
- * The object has the various cookies as keys(names) => values
42
- *
43
- * @param {string} str
44
- * @param {object} [options]
45
- * @return {object}
46
- * @public
47
- */
48
-
49
- function parse(str, options) {
50
- if (typeof str !== 'string') {
51
- throw new TypeError('argument str must be a string');
52
- }
53
-
54
- var obj = {};
55
- var opt = options || {};
56
- var pairs = str.split(pairSplitRegExp);
57
- var dec = opt.decode || decode;
58
-
59
- for (var i = 0; i < pairs.length; i++) {
60
- var pair = pairs[i];
61
- var eq_idx = pair.indexOf('=');
62
-
63
- // skip things that don't look like key=value
64
- if (eq_idx < 0) {
65
- continue;
66
- }
67
-
68
- var key = pair.substr(0, eq_idx).trim();
69
- var val = pair.substr(++eq_idx, pair.length).trim();
70
-
71
- // quoted values
72
- if ('"' == val[0]) {
73
- val = val.slice(1, -1);
74
- }
75
-
76
- // only assign once
77
- if (undefined == obj[key]) {
78
- obj[key] = tryDecode(val, dec);
79
- }
80
- }
81
-
82
- return obj;
83
- }
84
-
85
- /**
86
- * Serialize data into a cookie header.
87
- *
88
- * Serialize the a name value pair into a cookie string suitable for
89
- * http headers. An optional options object specified cookie parameters.
90
- *
91
- * serialize('foo', 'bar', { httpOnly: true })
92
- * => "foo=bar; httpOnly"
93
- *
94
- * @param {string} name
95
- * @param {string} val
96
- * @param {object} [options]
97
- * @return {string}
98
- * @public
99
- */
100
-
101
- function serialize(name, val, options) {
102
- var opt = options || {};
103
- var enc = opt.encode || encode;
104
-
105
- if (typeof enc !== 'function') {
106
- throw new TypeError('option encode is invalid');
107
- }
108
-
109
- if (!fieldContentRegExp.test(name)) {
110
- throw new TypeError('argument name is invalid');
111
- }
112
-
113
- var value = enc(val);
114
-
115
- if (value && !fieldContentRegExp.test(value)) {
116
- throw new TypeError('argument val is invalid');
117
- }
118
-
119
- var str = name + '=' + value;
120
-
121
- if (null != opt.maxAge) {
122
- var maxAge = opt.maxAge - 0;
123
-
124
- if (isNaN(maxAge) || !isFinite(maxAge)) {
125
- throw new TypeError('option maxAge is invalid')
126
- }
127
-
128
- str += '; Max-Age=' + Math.floor(maxAge);
129
- }
130
-
131
- if (opt.domain) {
132
- if (!fieldContentRegExp.test(opt.domain)) {
133
- throw new TypeError('option domain is invalid');
134
- }
135
-
136
- str += '; Domain=' + opt.domain;
137
- }
138
-
139
- if (opt.path) {
140
- if (!fieldContentRegExp.test(opt.path)) {
141
- throw new TypeError('option path is invalid');
142
- }
143
-
144
- str += '; Path=' + opt.path;
145
- }
146
-
147
- if (opt.expires) {
148
- if (typeof opt.expires.toUTCString !== 'function') {
149
- throw new TypeError('option expires is invalid');
150
- }
151
-
152
- str += '; Expires=' + opt.expires.toUTCString();
153
- }
154
-
155
- if (opt.httpOnly) {
156
- str += '; HttpOnly';
157
- }
158
-
159
- if (opt.secure) {
160
- str += '; Secure';
161
- }
162
-
163
- if (opt.sameSite) {
164
- var sameSite = typeof opt.sameSite === 'string'
165
- ? opt.sameSite.toLowerCase() : opt.sameSite;
166
-
167
- switch (sameSite) {
168
- case true:
169
- str += '; SameSite=Strict';
170
- break;
171
- case 'lax':
172
- str += '; SameSite=Lax';
173
- break;
174
- case 'strict':
175
- str += '; SameSite=Strict';
176
- break;
177
- case 'none':
178
- str += '; SameSite=None';
179
- break;
180
- default:
181
- throw new TypeError('option sameSite is invalid');
182
- }
183
- }
184
-
185
- return str;
186
- }
187
-
188
- /**
189
- * Try decoding a string using a decoding function.
190
- *
191
- * @param {string} str
192
- * @param {function} decode
193
- * @private
194
- */
195
-
196
- function tryDecode(str, decode) {
197
- try {
198
- return decode(str);
199
- } catch (e) {
200
- return str;
201
- }
202
- }
203
-
204
- var cookie = {
205
- parse: parse_1,
206
- serialize: serialize_1
207
- };
208
-
209
- exports.cookie = cookie;
210
- exports.parse_1 = parse_1;
211
- exports.serialize_1 = serialize_1;