@@ -23429,18 +23429,63 @@ exports.serialize = serialize;
23429
23429
* @private
23430
23430
*/
23431
23431
23432
- var decode = decodeURIComponent;
23433
- var encode = encodeURIComponent;
23432
+ var __toString = Object.prototype.toString
23434
23433
23435
23434
/**
23436
- * RegExp to match field-content in RFC 7230 sec 3.2
23435
+ * RegExp to match cookie-name in RFC 6265 sec 4.1.1
23436
+ * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
23437
+ * which has been replaced by the token definition in RFC 7230 appendix B.
23437
23438
*
23438
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
23439
- * field-vchar = VCHAR / obs-text
23440
- * obs-text = %x80-FF
23439
+ * cookie-name = token
23440
+ * token = 1*tchar
23441
+ * tchar = "!" / "#" / "$" / "%" / "&" / "'" /
23442
+ * "*" / "+" / "-" / "." / "^" / "_" /
23443
+ * "`" / "|" / "~" / DIGIT / ALPHA
23441
23444
*/
23442
23445
23443
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
23446
+ var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
23447
+
23448
+ /**
23449
+ * RegExp to match cookie-value in RFC 6265 sec 4.1.1
23450
+ *
23451
+ * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
23452
+ * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
23453
+ * ; US-ASCII characters excluding CTLs,
23454
+ * ; whitespace DQUOTE, comma, semicolon,
23455
+ * ; and backslash
23456
+ */
23457
+
23458
+ var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
23459
+
23460
+ /**
23461
+ * RegExp to match domain-value in RFC 6265 sec 4.1.1
23462
+ *
23463
+ * domain-value = <subdomain>
23464
+ * ; defined in [RFC1034], Section 3.5, as
23465
+ * ; enhanced by [RFC1123], Section 2.1
23466
+ * <subdomain> = <label> | <subdomain> "." <label>
23467
+ * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
23468
+ * Labels must be 63 characters or less.
23469
+ * 'let-dig' not 'letter' in the first char, per RFC1123
23470
+ * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
23471
+ * <let-dig-hyp> = <let-dig> | "-"
23472
+ * <let-dig> = <letter> | <digit>
23473
+ * <letter> = any one of the 52 alphabetic characters A through Z in
23474
+ * upper case and a through z in lower case
23475
+ * <digit> = any one of the ten digits 0 through 9
23476
+ */
23477
+
23478
+ var domainValueRegExp = /^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
23479
+
23480
+ /**
23481
+ * RegExp to match path-value in RFC 6265 sec 4.1.1
23482
+ *
23483
+ * path-value = <any CHAR except CTLs or ";">
23484
+ * CHAR = %x01-7F
23485
+ * ; defined in RFC 5234 appendix B.1
23486
+ */
23487
+
23488
+ var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
23444
23489
23445
23490
/**
23446
23491
* Parse a cookie header.
@@ -23459,43 +23504,80 @@ function parse(str, options) {
23459
23504
throw new TypeError('argument str must be a string');
23460
23505
}
23461
23506
23462
- var obj = {}
23463
- var opt = options || {};
23464
- var pairs = str.split(';')
23465
- var dec = opt.decode || decode;
23507
+ var obj = {};
23508
+ var len = str.length;
23509
+ // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
23510
+ var max = len - 2;
23511
+ if (max < 0) return obj;
23466
23512
23467
- for (var i = 0; i < pairs.length; i++) {
23468
- var pair = pairs[i];
23469
- var index = pair.indexOf('=')
23513
+ var dec = (options && options.decode) || decode;
23514
+ var index = 0;
23515
+ var eqIdx = 0;
23516
+ var endIdx = 0;
23517
+
23518
+ do {
23519
+ eqIdx = str.indexOf('=', index);
23520
+
23521
+ // no more cookie pairs
23522
+ if (eqIdx === -1) {
23523
+ break;
23524
+ }
23470
23525
23471
- // skip things that don't look like key=value
23472
- if (index < 0) {
23526
+ endIdx = str.indexOf(';', index);
23527
+
23528
+ if (endIdx === -1) {
23529
+ endIdx = len;
23530
+ } else if (eqIdx > endIdx) {
23531
+ // backtrack on prior semicolon
23532
+ index = str.lastIndexOf(';', eqIdx - 1) + 1;
23473
23533
continue;
23474
23534
}
23475
23535
23476
- var key = pair.substring(0, index).trim()
23536
+ var keyStartIdx = startIndex(str, index, eqIdx);
23537
+ var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
23538
+ var key = str.slice(keyStartIdx, keyEndIdx);
23477
23539
23478
23540
// only assign once
23479
- if (undefined == obj[key]) {
23480
- var val = pair.substring(index + 1, pair.length).trim()
23541
+ if (undefined === obj[key]) {
23542
+ var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
23543
+ var valEndIdx = endIndex(str, endIdx, valStartIdx);
23481
23544
23482
- // quoted values
23483
- if (val[0] === '"') {
23484
- val = val.slice(1, -1)
23545
+ if (str.charCodeAt(valStartIdx) === 0x22 /* " */ && str.charCodeAt(valEndIdx - 1) === 0x22 /* " */) {
23546
+ valStartIdx++;
23547
+ valEndIdx--;
23485
23548
}
23486
23549
23550
+ var val = str.slice(valStartIdx, valEndIdx);
23487
23551
obj[key] = tryDecode(val, dec);
23488
23552
}
23489
- }
23553
+
23554
+ index = endIdx + 1
23555
+ } while (index < max);
23490
23556
23491
23557
return obj;
23492
23558
}
23493
23559
23560
+ function startIndex(str, index, max) {
23561
+ do {
23562
+ var code = str.charCodeAt(index);
23563
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index;
23564
+ } while (++index < max);
23565
+ return max;
23566
+ }
23567
+
23568
+ function endIndex(str, index, min) {
23569
+ while (index > min) {
23570
+ var code = str.charCodeAt(--index);
23571
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index + 1;
23572
+ }
23573
+ return min;
23574
+ }
23575
+
23494
23576
/**
23495
23577
* Serialize data into a cookie header.
23496
23578
*
23497
- * Serialize the a name value pair into a cookie string suitable for
23498
- * http headers. An optional options object specified cookie parameters.
23579
+ * Serialize a name value pair into a cookie string suitable for
23580
+ * http headers. An optional options object specifies cookie parameters.
23499
23581
*
23500
23582
* serialize('foo', 'bar', { httpOnly: true })
23501
23583
* => "foo=bar; httpOnly"
@@ -23515,13 +23597,13 @@ function serialize(name, val, options) {
23515
23597
throw new TypeError('option encode is invalid');
23516
23598
}
23517
23599
23518
- if (!fieldContentRegExp .test(name)) {
23600
+ if (!cookieNameRegExp .test(name)) {
23519
23601
throw new TypeError('argument name is invalid');
23520
23602
}
23521
23603
23522
23604
var value = enc(val);
23523
23605
23524
- if (value && !fieldContentRegExp .test(value)) {
23606
+ if (value && !cookieValueRegExp .test(value)) {
23525
23607
throw new TypeError('argument val is invalid');
23526
23608
}
23527
23609
@@ -23530,35 +23612,37 @@ function serialize(name, val, options) {
23530
23612
if (null != opt.maxAge) {
23531
23613
var maxAge = opt.maxAge - 0;
23532
23614
23533
- if (isNaN(maxAge) || !isFinite(maxAge)) {
23615
+ if (!isFinite(maxAge)) {
23534
23616
throw new TypeError('option maxAge is invalid')
23535
23617
}
23536
23618
23537
23619
str += '; Max-Age=' + Math.floor(maxAge);
23538
23620
}
23539
23621
23540
23622
if (opt.domain) {
23541
- if (!fieldContentRegExp .test(opt.domain)) {
23623
+ if (!domainValueRegExp .test(opt.domain)) {
23542
23624
throw new TypeError('option domain is invalid');
23543
23625
}
23544
23626
23545
23627
str += '; Domain=' + opt.domain;
23546
23628
}
23547
23629
23548
23630
if (opt.path) {
23549
- if (!fieldContentRegExp .test(opt.path)) {
23631
+ if (!pathValueRegExp .test(opt.path)) {
23550
23632
throw new TypeError('option path is invalid');
23551
23633
}
23552
23634
23553
23635
str += '; Path=' + opt.path;
23554
23636
}
23555
23637
23556
23638
if (opt.expires) {
23557
- if (typeof opt.expires.toUTCString !== 'function') {
23639
+ var expires = opt.expires
23640
+
23641
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
23558
23642
throw new TypeError('option expires is invalid');
23559
23643
}
23560
23644
23561
- str += '; Expires=' + opt. expires.toUTCString();
23645
+ str += '; Expires=' + expires.toUTCString()
23562
23646
}
23563
23647
23564
23648
if (opt.httpOnly) {
@@ -23569,6 +23653,30 @@ function serialize(name, val, options) {
23569
23653
str += '; Secure';
23570
23654
}
23571
23655
23656
+ if (opt.partitioned) {
23657
+ str += '; Partitioned'
23658
+ }
23659
+
23660
+ if (opt.priority) {
23661
+ var priority = typeof opt.priority === 'string'
23662
+ ? opt.priority.toLowerCase()
23663
+ : opt.priority
23664
+
23665
+ switch (priority) {
23666
+ case 'low':
23667
+ str += '; Priority=Low'
23668
+ break
23669
+ case 'medium':
23670
+ str += '; Priority=Medium'
23671
+ break
23672
+ case 'high':
23673
+ str += '; Priority=High'
23674
+ break
23675
+ default:
23676
+ throw new TypeError('option priority is invalid')
23677
+ }
23678
+ }
23679
+
23572
23680
if (opt.sameSite) {
23573
23681
var sameSite = typeof opt.sameSite === 'string'
23574
23682
? opt.sameSite.toLowerCase() : opt.sameSite;
@@ -23594,6 +23702,42 @@ function serialize(name, val, options) {
23594
23702
return str;
23595
23703
}
23596
23704
23705
+ /**
23706
+ * URL-decode string value. Optimized to skip native call when no %.
23707
+ *
23708
+ * @param {string} str
23709
+ * @returns {string}
23710
+ */
23711
+
23712
+ function decode (str) {
23713
+ return str.indexOf('%') !== -1
23714
+ ? decodeURIComponent(str)
23715
+ : str
23716
+ }
23717
+
23718
+ /**
23719
+ * URL-encode value.
23720
+ *
23721
+ * @param {string} val
23722
+ * @returns {string}
23723
+ */
23724
+
23725
+ function encode (val) {
23726
+ return encodeURIComponent(val)
23727
+ }
23728
+
23729
+ /**
23730
+ * Determine if value is a Date.
23731
+ *
23732
+ * @param {*} val
23733
+ * @private
23734
+ */
23735
+
23736
+ function isDate (val) {
23737
+ return __toString.call(val) === '[object Date]' ||
23738
+ val instanceof Date
23739
+ }
23740
+
23597
23741
/**
23598
23742
* Try decoding a string using a decoding function.
23599
23743
*
@@ -29041,7 +29185,7 @@ module.exports={
29041
29185
"_args": [
29042
29186
[
29043
29187
"elliptic@6.5.4",
29044
- "/Users/abhis/Documents/GitHub /splunk-sdk-javascript"
29188
+ "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript"
29045
29189
]
29046
29190
],
29047
29191
"_development": true,
@@ -29067,7 +29211,7 @@ module.exports={
29067
29211
],
29068
29212
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
29069
29213
"_spec": "6.5.4",
29070
- "_where": "/Users/abhis/Documents/GitHub /splunk-sdk-javascript",
29214
+ "_where": "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript",
29071
29215
"author": {
29072
29216
"name": "Fedor Indutny",
29073
29217
"email": "fedor@indutny.com"
@@ -39534,7 +39678,7 @@ module.exports={
39534
39678
"_args": [
39535
39679
[
39536
39680
"needle@3.0.0",
39537
- "/Users/abhis/Documents/GitHub /splunk-sdk-javascript"
39681
+ "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript"
39538
39682
]
39539
39683
],
39540
39684
"_from": "needle@3.0.0",
@@ -39560,13 +39704,13 @@ module.exports={
39560
39704
],
39561
39705
"_resolved": "https://registry.npmjs.org/needle/-/needle-3.0.0.tgz",
39562
39706
"_spec": "3.0.0",
39563
- "_where": "/Users/abhis/Documents/GitHub /splunk-sdk-javascript",
39707
+ "_where": "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript",
39564
39708
"author": {
39565
39709
"name": "Tomás Pollak",
39566
39710
"email": "tomas@forkhq.com"
39567
39711
},
39568
39712
"bin": {
39569
- "needle": "./ bin/needle"
39713
+ "needle": "bin/needle"
39570
39714
},
39571
39715
"bugs": {
39572
39716
"url": "https://github.com/tomas/needle/issues"
@@ -55397,7 +55541,7 @@ module.exports={
55397
55541
"test": "nyc mocha tests/tests.js -t 50000 --allow-uncaught --exit --reporter mochawesome"
55398
55542
},
55399
55543
"dependencies": {
55400
- "cookie": "0.4.2 ",
55544
+ "cookie": "0.7.0 ",
55401
55545
"dotenv": "16.0.0",
55402
55546
"elementtree": "0.1.7",
55403
55547
"needle": "3.0.0"
0 commit comments