@mjhls/mjh-framework 1.0.626-iOS-chrome-fix → 1.0.626-iOS-chrome-fix-v2
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.
- package/dist/cjs/Auth.js +206 -6
- package/dist/cjs/View.js +2 -2
- package/dist/cjs/getRelatedArticle.js +5 -354
- package/dist/cjs/index.js +3 -3
- package/dist/esm/Auth.js +201 -1
- package/dist/esm/View.js +2 -2
- package/dist/esm/getRelatedArticle.js +5 -354
- package/dist/esm/index.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/index-bd6c9f56.js +0 -211
- package/dist/esm/index-db3bb315.js +0 -207
package/dist/cjs/Auth.js
CHANGED
|
@@ -22,7 +22,6 @@ var asyncToGenerator = require('./asyncToGenerator-8e707718.js');
|
|
|
22
22
|
require('./_set-species-4458e975.js');
|
|
23
23
|
var reactBootstrap = require('react-bootstrap');
|
|
24
24
|
var util = require('./util-f2c1b65b.js');
|
|
25
|
-
var index$4 = require('./index-bd6c9f56.js');
|
|
26
25
|
var useSWR = _interopDefault(require('swr'));
|
|
27
26
|
var Local = _interopDefault(require('passport-local'));
|
|
28
27
|
var mysql = _interopDefault(require('mysql'));
|
|
@@ -1210,12 +1209,213 @@ var SignupForm$1 = function SignupForm(props) {
|
|
|
1210
1209
|
);
|
|
1211
1210
|
};
|
|
1212
1211
|
|
|
1212
|
+
/*!
|
|
1213
|
+
* cookie
|
|
1214
|
+
* Copyright(c) 2012-2014 Roman Shtylman
|
|
1215
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
1216
|
+
* MIT Licensed
|
|
1217
|
+
*/
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Module exports.
|
|
1221
|
+
* @public
|
|
1222
|
+
*/
|
|
1223
|
+
|
|
1224
|
+
var parse_1 = parse;
|
|
1225
|
+
var serialize_1 = serialize;
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* Module variables.
|
|
1229
|
+
* @private
|
|
1230
|
+
*/
|
|
1231
|
+
|
|
1232
|
+
var decode = decodeURIComponent;
|
|
1233
|
+
var encode = encodeURIComponent;
|
|
1234
|
+
var pairSplitRegExp = /; */;
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
1238
|
+
*
|
|
1239
|
+
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
1240
|
+
* field-vchar = VCHAR / obs-text
|
|
1241
|
+
* obs-text = %x80-FF
|
|
1242
|
+
*/
|
|
1243
|
+
|
|
1244
|
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Parse a cookie header.
|
|
1248
|
+
*
|
|
1249
|
+
* Parse the given cookie header string into an object
|
|
1250
|
+
* The object has the various cookies as keys(names) => values
|
|
1251
|
+
*
|
|
1252
|
+
* @param {string} str
|
|
1253
|
+
* @param {object} [options]
|
|
1254
|
+
* @return {object}
|
|
1255
|
+
* @public
|
|
1256
|
+
*/
|
|
1257
|
+
|
|
1258
|
+
function parse(str, options) {
|
|
1259
|
+
if (typeof str !== 'string') {
|
|
1260
|
+
throw new TypeError('argument str must be a string');
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
var obj = {};
|
|
1264
|
+
var opt = options || {};
|
|
1265
|
+
var pairs = str.split(pairSplitRegExp);
|
|
1266
|
+
var dec = opt.decode || decode;
|
|
1267
|
+
|
|
1268
|
+
for (var i = 0; i < pairs.length; i++) {
|
|
1269
|
+
var pair = pairs[i];
|
|
1270
|
+
var eq_idx = pair.indexOf('=');
|
|
1271
|
+
|
|
1272
|
+
// skip things that don't look like key=value
|
|
1273
|
+
if (eq_idx < 0) {
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
var key = pair.substr(0, eq_idx).trim();
|
|
1278
|
+
var val = pair.substr(++eq_idx, pair.length).trim();
|
|
1279
|
+
|
|
1280
|
+
// quoted values
|
|
1281
|
+
if ('"' == val[0]) {
|
|
1282
|
+
val = val.slice(1, -1);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// only assign once
|
|
1286
|
+
if (undefined == obj[key]) {
|
|
1287
|
+
obj[key] = tryDecode(val, dec);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
return obj;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Serialize data into a cookie header.
|
|
1296
|
+
*
|
|
1297
|
+
* Serialize the a name value pair into a cookie string suitable for
|
|
1298
|
+
* http headers. An optional options object specified cookie parameters.
|
|
1299
|
+
*
|
|
1300
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
1301
|
+
* => "foo=bar; httpOnly"
|
|
1302
|
+
*
|
|
1303
|
+
* @param {string} name
|
|
1304
|
+
* @param {string} val
|
|
1305
|
+
* @param {object} [options]
|
|
1306
|
+
* @return {string}
|
|
1307
|
+
* @public
|
|
1308
|
+
*/
|
|
1309
|
+
|
|
1310
|
+
function serialize(name, val, options) {
|
|
1311
|
+
var opt = options || {};
|
|
1312
|
+
var enc = opt.encode || encode;
|
|
1313
|
+
|
|
1314
|
+
if (typeof enc !== 'function') {
|
|
1315
|
+
throw new TypeError('option encode is invalid');
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
if (!fieldContentRegExp.test(name)) {
|
|
1319
|
+
throw new TypeError('argument name is invalid');
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
var value = enc(val);
|
|
1323
|
+
|
|
1324
|
+
if (value && !fieldContentRegExp.test(value)) {
|
|
1325
|
+
throw new TypeError('argument val is invalid');
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
var str = name + '=' + value;
|
|
1329
|
+
|
|
1330
|
+
if (null != opt.maxAge) {
|
|
1331
|
+
var maxAge = opt.maxAge - 0;
|
|
1332
|
+
|
|
1333
|
+
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
1334
|
+
throw new TypeError('option maxAge is invalid')
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
str += '; Max-Age=' + Math.floor(maxAge);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
if (opt.domain) {
|
|
1341
|
+
if (!fieldContentRegExp.test(opt.domain)) {
|
|
1342
|
+
throw new TypeError('option domain is invalid');
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
str += '; Domain=' + opt.domain;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
if (opt.path) {
|
|
1349
|
+
if (!fieldContentRegExp.test(opt.path)) {
|
|
1350
|
+
throw new TypeError('option path is invalid');
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
str += '; Path=' + opt.path;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
if (opt.expires) {
|
|
1357
|
+
if (typeof opt.expires.toUTCString !== 'function') {
|
|
1358
|
+
throw new TypeError('option expires is invalid');
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
str += '; Expires=' + opt.expires.toUTCString();
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
if (opt.httpOnly) {
|
|
1365
|
+
str += '; HttpOnly';
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
if (opt.secure) {
|
|
1369
|
+
str += '; Secure';
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
if (opt.sameSite) {
|
|
1373
|
+
var sameSite = typeof opt.sameSite === 'string'
|
|
1374
|
+
? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
1375
|
+
|
|
1376
|
+
switch (sameSite) {
|
|
1377
|
+
case true:
|
|
1378
|
+
str += '; SameSite=Strict';
|
|
1379
|
+
break;
|
|
1380
|
+
case 'lax':
|
|
1381
|
+
str += '; SameSite=Lax';
|
|
1382
|
+
break;
|
|
1383
|
+
case 'strict':
|
|
1384
|
+
str += '; SameSite=Strict';
|
|
1385
|
+
break;
|
|
1386
|
+
case 'none':
|
|
1387
|
+
str += '; SameSite=None';
|
|
1388
|
+
break;
|
|
1389
|
+
default:
|
|
1390
|
+
throw new TypeError('option sameSite is invalid');
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
return str;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Try decoding a string using a decoding function.
|
|
1399
|
+
*
|
|
1400
|
+
* @param {string} str
|
|
1401
|
+
* @param {function} decode
|
|
1402
|
+
* @private
|
|
1403
|
+
*/
|
|
1404
|
+
|
|
1405
|
+
function tryDecode(str, decode) {
|
|
1406
|
+
try {
|
|
1407
|
+
return decode(str);
|
|
1408
|
+
} catch (e) {
|
|
1409
|
+
return str;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1213
1413
|
var TOKEN_NAME = 'token';
|
|
1214
1414
|
var MAX_AGE = 60 * 60 * 8; // 8 hours
|
|
1215
1415
|
|
|
1216
1416
|
function setTokenCookie(res, token, eKey) {
|
|
1217
1417
|
var cookies_serailized = [];
|
|
1218
|
-
cookies_serailized.push(
|
|
1418
|
+
cookies_serailized.push(serialize_1(TOKEN_NAME, token, {
|
|
1219
1419
|
//maxAge: MAX_AGE, // we want login cookie to expire when browser
|
|
1220
1420
|
//expires: new Date(Date.now() + MAX_AGE * 1000),
|
|
1221
1421
|
//httpOnly: true,
|
|
@@ -1224,7 +1424,7 @@ function setTokenCookie(res, token, eKey) {
|
|
|
1224
1424
|
//sameSite: 'lax',
|
|
1225
1425
|
}));
|
|
1226
1426
|
|
|
1227
|
-
cookies_serailized.push(
|
|
1427
|
+
cookies_serailized.push(serialize_1('eKey', eKey, {
|
|
1228
1428
|
//maxAge: MAX_AGE, // we want login cookie to expire when browser
|
|
1229
1429
|
//expires: new Date(Date.now() + MAX_AGE * 1000),
|
|
1230
1430
|
//httpOnly: true,
|
|
@@ -1238,12 +1438,12 @@ function setTokenCookie(res, token, eKey) {
|
|
|
1238
1438
|
|
|
1239
1439
|
function removeTokenCookie(res) {
|
|
1240
1440
|
var cookies_serailized = [];
|
|
1241
|
-
cookies_serailized.push(
|
|
1441
|
+
cookies_serailized.push(serialize_1(TOKEN_NAME, '', {
|
|
1242
1442
|
maxAge: -1,
|
|
1243
1443
|
expires: new Date(Date.now() - MAX_AGE * 1000),
|
|
1244
1444
|
path: '/'
|
|
1245
1445
|
}));
|
|
1246
|
-
cookies_serailized.push(
|
|
1446
|
+
cookies_serailized.push(serialize_1('eKey', '', {
|
|
1247
1447
|
maxAge: -1,
|
|
1248
1448
|
expires: new Date(Date.now() - MAX_AGE * 1000),
|
|
1249
1449
|
path: '/'
|
|
@@ -1258,7 +1458,7 @@ function parseCookies(req) {
|
|
|
1258
1458
|
|
|
1259
1459
|
// For pages we do need to parse the cookies.
|
|
1260
1460
|
var cookie = req.headers ? req.headers.cookie : null;
|
|
1261
|
-
return
|
|
1461
|
+
return parse_1(cookie || '');
|
|
1262
1462
|
}
|
|
1263
1463
|
|
|
1264
1464
|
function getTokenCookie(req) {
|
package/dist/cjs/View.js
CHANGED
|
@@ -58,9 +58,9 @@ var keys$1 = require('./keys-a586b7a0.js');
|
|
|
58
58
|
require('react-bootstrap/Dropdown');
|
|
59
59
|
var getKeywords = require('./getKeywords.js');
|
|
60
60
|
var getSeriesDetail = require('./getSeriesDetail.js');
|
|
61
|
-
require('
|
|
62
|
-
var getRelatedArticle = require('./getRelatedArticle.js');
|
|
61
|
+
require('nookies');
|
|
63
62
|
var getQuery = require('./getQuery.js');
|
|
63
|
+
var getRelatedArticle = require('./getRelatedArticle.js');
|
|
64
64
|
var getTargeting = require('./getTargeting-5a0b8ee4.js');
|
|
65
65
|
var urlFor = require('./urlFor.js');
|
|
66
66
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require('./_commonjsHelpers-06173234.js');
|
|
4
4
|
require('./_to-object-329a650b.js');
|
|
5
5
|
require('./core.get-iterator-method-41e87ec1.js');
|
|
6
6
|
require('./_library-dd23b178.js');
|
|
@@ -8,358 +8,9 @@ require('./_iter-detect-4d0352f8.js');
|
|
|
8
8
|
require('./web.dom.iterable-43c3e277.js');
|
|
9
9
|
var asyncToGenerator = require('./asyncToGenerator-8e707718.js');
|
|
10
10
|
require('./_set-species-4458e975.js');
|
|
11
|
-
var
|
|
11
|
+
var nookies = require('nookies');
|
|
12
12
|
var getQuery = require('./getQuery.js');
|
|
13
13
|
|
|
14
|
-
var defaultParseOptions = {
|
|
15
|
-
decodeValues: true,
|
|
16
|
-
map: false,
|
|
17
|
-
silent: false,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function isNonEmptyString(str) {
|
|
21
|
-
return typeof str === "string" && !!str.trim();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function parseString(setCookieValue, options) {
|
|
25
|
-
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
26
|
-
var nameValue = parts.shift().split("=");
|
|
27
|
-
var name = nameValue.shift();
|
|
28
|
-
var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
|
29
|
-
|
|
30
|
-
options = options
|
|
31
|
-
? Object.assign({}, defaultParseOptions, options)
|
|
32
|
-
: defaultParseOptions;
|
|
33
|
-
|
|
34
|
-
var cookie = {
|
|
35
|
-
name: name, // grab everything before the first =
|
|
36
|
-
value: options.decodeValues ? decodeURIComponent(value) : value, // decode cookie value
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
parts.forEach(function (part) {
|
|
40
|
-
var sides = part.split("=");
|
|
41
|
-
var key = sides.shift().trimLeft().toLowerCase();
|
|
42
|
-
var value = sides.join("=");
|
|
43
|
-
if (key === "expires") {
|
|
44
|
-
cookie.expires = new Date(value);
|
|
45
|
-
} else if (key === "max-age") {
|
|
46
|
-
cookie.maxAge = parseInt(value, 10);
|
|
47
|
-
} else if (key === "secure") {
|
|
48
|
-
cookie.secure = true;
|
|
49
|
-
} else if (key === "httponly") {
|
|
50
|
-
cookie.httpOnly = true;
|
|
51
|
-
} else if (key === "samesite") {
|
|
52
|
-
cookie.sameSite = value;
|
|
53
|
-
} else {
|
|
54
|
-
cookie[key] = value;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return cookie;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function parse(input, options) {
|
|
62
|
-
options = options
|
|
63
|
-
? Object.assign({}, defaultParseOptions, options)
|
|
64
|
-
: defaultParseOptions;
|
|
65
|
-
|
|
66
|
-
if (!input) {
|
|
67
|
-
if (!options.map) {
|
|
68
|
-
return [];
|
|
69
|
-
} else {
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (input.headers && input.headers["set-cookie"]) {
|
|
75
|
-
// fast-path for node.js (which automatically normalizes header names to lower-case
|
|
76
|
-
input = input.headers["set-cookie"];
|
|
77
|
-
} else if (input.headers) {
|
|
78
|
-
// slow-path for other environments - see #25
|
|
79
|
-
var sch =
|
|
80
|
-
input.headers[
|
|
81
|
-
Object.keys(input.headers).find(function (key) {
|
|
82
|
-
return key.toLowerCase() === "set-cookie";
|
|
83
|
-
})
|
|
84
|
-
];
|
|
85
|
-
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
|
86
|
-
if (!sch && input.headers.cookie && !options.silent) {
|
|
87
|
-
console.warn(
|
|
88
|
-
"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."
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
input = sch;
|
|
92
|
-
}
|
|
93
|
-
if (!Array.isArray(input)) {
|
|
94
|
-
input = [input];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
options = options
|
|
98
|
-
? Object.assign({}, defaultParseOptions, options)
|
|
99
|
-
: defaultParseOptions;
|
|
100
|
-
|
|
101
|
-
if (!options.map) {
|
|
102
|
-
return input.filter(isNonEmptyString).map(function (str) {
|
|
103
|
-
return parseString(str, options);
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
var cookies = {};
|
|
107
|
-
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
|
108
|
-
var cookie = parseString(str, options);
|
|
109
|
-
cookies[cookie.name] = cookie;
|
|
110
|
-
return cookies;
|
|
111
|
-
}, cookies);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
|
117
|
-
that are within a single set-cookie field-value, such as in the Expires portion.
|
|
118
|
-
|
|
119
|
-
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
|
120
|
-
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
|
121
|
-
React Native's fetch does this for *every* header, including set-cookie.
|
|
122
|
-
|
|
123
|
-
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
|
124
|
-
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
|
125
|
-
*/
|
|
126
|
-
function splitCookiesString(cookiesString) {
|
|
127
|
-
if (Array.isArray(cookiesString)) {
|
|
128
|
-
return cookiesString;
|
|
129
|
-
}
|
|
130
|
-
if (typeof cookiesString !== "string") {
|
|
131
|
-
return [];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var cookiesStrings = [];
|
|
135
|
-
var pos = 0;
|
|
136
|
-
var start;
|
|
137
|
-
var ch;
|
|
138
|
-
var lastComma;
|
|
139
|
-
var nextStart;
|
|
140
|
-
var cookiesSeparatorFound;
|
|
141
|
-
|
|
142
|
-
function skipWhitespace() {
|
|
143
|
-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
144
|
-
pos += 1;
|
|
145
|
-
}
|
|
146
|
-
return pos < cookiesString.length;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function notSpecialChar() {
|
|
150
|
-
ch = cookiesString.charAt(pos);
|
|
151
|
-
|
|
152
|
-
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
while (pos < cookiesString.length) {
|
|
156
|
-
start = pos;
|
|
157
|
-
cookiesSeparatorFound = false;
|
|
158
|
-
|
|
159
|
-
while (skipWhitespace()) {
|
|
160
|
-
ch = cookiesString.charAt(pos);
|
|
161
|
-
if (ch === ",") {
|
|
162
|
-
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
|
163
|
-
lastComma = pos;
|
|
164
|
-
pos += 1;
|
|
165
|
-
|
|
166
|
-
skipWhitespace();
|
|
167
|
-
nextStart = pos;
|
|
168
|
-
|
|
169
|
-
while (pos < cookiesString.length && notSpecialChar()) {
|
|
170
|
-
pos += 1;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// currently special character
|
|
174
|
-
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
175
|
-
// we found cookies separator
|
|
176
|
-
cookiesSeparatorFound = true;
|
|
177
|
-
// pos is inside the next cookie, so back up and return it.
|
|
178
|
-
pos = nextStart;
|
|
179
|
-
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
180
|
-
start = pos;
|
|
181
|
-
} else {
|
|
182
|
-
// in param ',' or param separator ';',
|
|
183
|
-
// we continue from that comma
|
|
184
|
-
pos = lastComma + 1;
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
pos += 1;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
192
|
-
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return cookiesStrings;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
var setCookie = parse;
|
|
200
|
-
var parse_1 = parse;
|
|
201
|
-
var parseString_1 = parseString;
|
|
202
|
-
var splitCookiesString_1 = splitCookiesString;
|
|
203
|
-
setCookie.parse = parse_1;
|
|
204
|
-
setCookie.parseString = parseString_1;
|
|
205
|
-
setCookie.splitCookiesString = splitCookiesString_1;
|
|
206
|
-
|
|
207
|
-
var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
|
|
208
|
-
var __assign = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__assign) || function () {
|
|
209
|
-
__assign = Object.assign || function(t) {
|
|
210
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
211
|
-
s = arguments[i];
|
|
212
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
213
|
-
t[p] = s[p];
|
|
214
|
-
}
|
|
215
|
-
return t;
|
|
216
|
-
};
|
|
217
|
-
return __assign.apply(this, arguments);
|
|
218
|
-
};
|
|
219
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
220
|
-
exports.destroyCookie = exports.setCookie = exports.parseCookies = void 0;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
var isBrowser = function () { return typeof window !== 'undefined'; };
|
|
224
|
-
function hasSameProperties(a, b) {
|
|
225
|
-
var aProps = Object.getOwnPropertyNames(a);
|
|
226
|
-
var bProps = Object.getOwnPropertyNames(b);
|
|
227
|
-
if (aProps.length !== bProps.length) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
for (var i = 0; i < aProps.length; i++) {
|
|
231
|
-
var propName = aProps[i];
|
|
232
|
-
if (a[propName] !== b[propName]) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Compare the cookie and return true if the cookies has equivalent
|
|
240
|
-
* options and the cookies would be overwritten in the browser storage.
|
|
241
|
-
*
|
|
242
|
-
* @param a first Cookie for comparison
|
|
243
|
-
* @param b second Cookie for comparison
|
|
244
|
-
*/
|
|
245
|
-
function areCookiesEqual(a, b) {
|
|
246
|
-
var sameSiteSame = a.sameSite === b.sameSite;
|
|
247
|
-
if (typeof a.sameSite === 'string' && typeof b.sameSite === 'string') {
|
|
248
|
-
sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
|
|
249
|
-
}
|
|
250
|
-
return (hasSameProperties(__assign(__assign({}, a), { sameSite: undefined }), __assign(__assign({}, b), { sameSite: undefined })) && sameSiteSame);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Create an instance of the Cookie interface
|
|
254
|
-
*
|
|
255
|
-
* @param name name of the Cookie
|
|
256
|
-
* @param value value of the Cookie
|
|
257
|
-
* @param options Cookie options
|
|
258
|
-
*/
|
|
259
|
-
function createCookie(name, value, options) {
|
|
260
|
-
var sameSite = options.sameSite;
|
|
261
|
-
if (sameSite === true) {
|
|
262
|
-
sameSite = 'strict';
|
|
263
|
-
}
|
|
264
|
-
if (sameSite === undefined || sameSite === false) {
|
|
265
|
-
sameSite = 'lax';
|
|
266
|
-
}
|
|
267
|
-
var cookieToSet = __assign(__assign({}, options), { sameSite: sameSite });
|
|
268
|
-
delete cookieToSet.encode;
|
|
269
|
-
return __assign({ name: name, value: value }, cookieToSet);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
*
|
|
273
|
-
* Parses cookies.
|
|
274
|
-
*
|
|
275
|
-
* @param ctx
|
|
276
|
-
* @param options
|
|
277
|
-
*/
|
|
278
|
-
function parseCookies(ctx, options) {
|
|
279
|
-
if (ctx && ctx.req && ctx.req.headers && ctx.req.headers.cookie) {
|
|
280
|
-
return index$4.cookie.parse(ctx.req.headers.cookie, options);
|
|
281
|
-
}
|
|
282
|
-
if (isBrowser()) {
|
|
283
|
-
return index$4.cookie.parse(document.cookie, options);
|
|
284
|
-
}
|
|
285
|
-
return {};
|
|
286
|
-
}
|
|
287
|
-
exports.parseCookies = parseCookies;
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
* Sets a cookie.
|
|
291
|
-
*
|
|
292
|
-
* @param ctx
|
|
293
|
-
* @param name
|
|
294
|
-
* @param value
|
|
295
|
-
* @param options
|
|
296
|
-
*/
|
|
297
|
-
function setCookie$1(ctx, name, value, options) {
|
|
298
|
-
if (ctx && ctx.res && ctx.res.getHeader && ctx.res.setHeader) {
|
|
299
|
-
var cookies = ctx.res.getHeader('Set-Cookie') || [];
|
|
300
|
-
if (typeof cookies === 'string')
|
|
301
|
-
cookies = [cookies];
|
|
302
|
-
if (typeof cookies === 'number')
|
|
303
|
-
cookies = [];
|
|
304
|
-
var parsedCookies = setCookie.parse(cookies);
|
|
305
|
-
var cookiesToSet_1 = [];
|
|
306
|
-
parsedCookies.forEach(function (parsedCookie) {
|
|
307
|
-
if (!areCookiesEqual(parsedCookie, createCookie(name, value, options))) {
|
|
308
|
-
cookiesToSet_1.push(index$4.cookie.serialize(parsedCookie.name, parsedCookie.value, __assign({ encode: function (val) { return val; } }, parsedCookie)));
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
cookiesToSet_1.push(index$4.cookie.serialize(name, value, options));
|
|
312
|
-
if (!ctx.res.finished) {
|
|
313
|
-
ctx.res.setHeader('Set-Cookie', cookiesToSet_1);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (isBrowser()) {
|
|
317
|
-
if (options && options.httpOnly) {
|
|
318
|
-
throw new Error('Can not set a httpOnly cookie in the browser.');
|
|
319
|
-
}
|
|
320
|
-
document.cookie = index$4.cookie.serialize(name, value, options);
|
|
321
|
-
}
|
|
322
|
-
return {};
|
|
323
|
-
}
|
|
324
|
-
exports.setCookie = setCookie$1;
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
* Destroys a cookie with a particular name.
|
|
328
|
-
*
|
|
329
|
-
* @param ctx
|
|
330
|
-
* @param name
|
|
331
|
-
* @param options
|
|
332
|
-
*/
|
|
333
|
-
function destroyCookie(ctx, name, options) {
|
|
334
|
-
var opts = __assign(__assign({}, (options || {})), { maxAge: -1 });
|
|
335
|
-
if (ctx && ctx.res && ctx.res.setHeader && ctx.res.getHeader) {
|
|
336
|
-
var cookies = ctx.res.getHeader('Set-Cookie') || [];
|
|
337
|
-
if (typeof cookies === 'string')
|
|
338
|
-
cookies = [cookies];
|
|
339
|
-
if (typeof cookies === 'number')
|
|
340
|
-
cookies = [];
|
|
341
|
-
cookies.push(index$4.cookie.serialize(name, '', opts));
|
|
342
|
-
ctx.res.setHeader('Set-Cookie', cookies);
|
|
343
|
-
}
|
|
344
|
-
if (isBrowser()) {
|
|
345
|
-
document.cookie = index$4.cookie.serialize(name, '', opts);
|
|
346
|
-
}
|
|
347
|
-
return {};
|
|
348
|
-
}
|
|
349
|
-
exports.destroyCookie = destroyCookie;
|
|
350
|
-
exports.default = {
|
|
351
|
-
set: setCookie$1,
|
|
352
|
-
get: parseCookies,
|
|
353
|
-
destroy: destroyCookie,
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
_commonjsHelpers.unwrapExports(dist);
|
|
359
|
-
var dist_1 = dist.destroyCookie;
|
|
360
|
-
var dist_2 = dist.setCookie;
|
|
361
|
-
var dist_3 = dist.parseCookies;
|
|
362
|
-
|
|
363
14
|
var _this = undefined;
|
|
364
15
|
|
|
365
16
|
var getRelatedArticle = function () {
|
|
@@ -412,13 +63,13 @@ var getRelatedArticle = function () {
|
|
|
412
63
|
conditions = '';
|
|
413
64
|
|
|
414
65
|
if (ctx && url) {
|
|
415
|
-
cookies =
|
|
66
|
+
cookies = nookies.parseCookies(ctx);
|
|
416
67
|
prevSlugs = cookies['prevSlugs'];
|
|
417
68
|
|
|
418
69
|
if (!!prevSlugs) {
|
|
419
|
-
|
|
70
|
+
nookies.setCookie(ctx, 'prevSlugs', prevSlugs + ',"' + url + '"', {});
|
|
420
71
|
conditions = '&& !(url.current in [' + prevSlugs + '])';
|
|
421
|
-
} else
|
|
72
|
+
} else nookies.setCookie(ctx, 'prevSlugs', '"' + url + '"', {});
|
|
422
73
|
}
|
|
423
74
|
relatedArticleQuery = getQuery('related', conditions, '', articleCount);
|
|
424
75
|
_context.next = 12;
|
package/dist/cjs/index.js
CHANGED
|
@@ -158,9 +158,9 @@ var ConferenceArticleCard = require('./ConferenceArticleCard.js');
|
|
|
158
158
|
var KMTracker = require('./KMTracker.js');
|
|
159
159
|
var getSeriesDetail = require('./getSeriesDetail.js');
|
|
160
160
|
var SetCookie = require('./SetCookie.js');
|
|
161
|
-
require('
|
|
162
|
-
var getRelatedArticle = require('./getRelatedArticle.js');
|
|
161
|
+
require('nookies');
|
|
163
162
|
var getQuery = require('./getQuery.js');
|
|
163
|
+
var getRelatedArticle = require('./getRelatedArticle.js');
|
|
164
164
|
var Auth = require('./Auth.js');
|
|
165
165
|
require('swr');
|
|
166
166
|
require('passport-local');
|
|
@@ -249,8 +249,8 @@ exports.ConferenceArticleCard = ConferenceArticleCard;
|
|
|
249
249
|
exports.KMTracker = KMTracker;
|
|
250
250
|
exports.getSeriesDetail = getSeriesDetail;
|
|
251
251
|
exports.SetCookie = SetCookie;
|
|
252
|
-
exports.getRelatedArticle = getRelatedArticle;
|
|
253
252
|
exports.getQuery = getQuery;
|
|
253
|
+
exports.getRelatedArticle = getRelatedArticle;
|
|
254
254
|
exports.Auth = Auth.default;
|
|
255
255
|
exports.getTargeting = getTargeting.getTargeting;
|
|
256
256
|
exports.View = View;
|