@@ -23429,63 +23429,18 @@ exports.serialize = serialize;
23429
23429
* @private
23430
23430
*/
23431
23431
23432
- var __toString = Object.prototype.toString
23432
+ var decode = decodeURIComponent;
23433
+ var encode = encodeURIComponent;
23433
23434
23434
23435
/**
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.
23436
+ * RegExp to match field-content in RFC 7230 sec 3.2
23438
23437
*
23439
- * cookie-name = token
23440
- * token = 1*tchar
23441
- * tchar = "!" / "#" / "$" / "%" / "&" / "'" /
23442
- * "*" / "+" / "-" / "." / "^" / "_" /
23443
- * "`" / "|" / "~" / DIGIT / ALPHA
23438
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
23439
+ * field-vchar = VCHAR / obs-text
23440
+ * obs-text = %x80-FF
23444
23441
*/
23445
23442
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]*$/;
23443
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
23489
23444
23490
23445
/**
23491
23446
* Parse a cookie header.
@@ -23504,80 +23459,43 @@ function parse(str, options) {
23504
23459
throw new TypeError('argument str must be a string');
23505
23460
}
23506
23461
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;
23512
-
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
- }
23462
+ var obj = {}
23463
+ var opt = options || {};
23464
+ var pairs = str.split(';')
23465
+ var dec = opt.decode || decode;
23525
23466
23526
- endIdx = str.indexOf(';', index);
23467
+ for (var i = 0; i < pairs.length; i++) {
23468
+ var pair = pairs[i];
23469
+ var index = pair.indexOf('=')
23527
23470
23528
- if (endIdx === -1) {
23529
- endIdx = len;
23530
- } else if (eqIdx > endIdx) {
23531
- // backtrack on prior semicolon
23532
- index = str.lastIndexOf(';', eqIdx - 1) + 1;
23471
+ // skip things that don't look like key=value
23472
+ if (index < 0) {
23533
23473
continue;
23534
23474
}
23535
23475
23536
- var keyStartIdx = startIndex(str, index, eqIdx);
23537
- var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
23538
- var key = str.slice(keyStartIdx, keyEndIdx);
23476
+ var key = pair.substring(0, index).trim()
23539
23477
23540
23478
// only assign once
23541
- if (undefined === obj[key]) {
23542
- var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
23543
- var valEndIdx = endIndex(str, endIdx, valStartIdx);
23479
+ if (undefined == obj[key]) {
23480
+ var val = pair.substring(index + 1, pair.length).trim()
23544
23481
23545
- if (str.charCodeAt(valStartIdx) === 0x22 /* " */ && str.charCodeAt(valEndIdx - 1) === 0x22 /* " */) {
23546
- valStartIdx++;
23547
- valEndIdx--;
23482
+ // quoted values
23483
+ if (val[0] === '"') {
23484
+ val = val.slice(1, -1)
23548
23485
}
23549
23486
23550
- var val = str.slice(valStartIdx, valEndIdx);
23551
23487
obj[key] = tryDecode(val, dec);
23552
23488
}
23553
-
23554
- index = endIdx + 1
23555
- } while (index < max);
23489
+ }
23556
23490
23557
23491
return obj;
23558
23492
}
23559
23493
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
-
23576
23494
/**
23577
23495
* Serialize data into a cookie header.
23578
23496
*
23579
- * Serialize a name value pair into a cookie string suitable for
23580
- * http headers. An optional options object specifies cookie parameters.
23497
+ * Serialize the a name value pair into a cookie string suitable for
23498
+ * http headers. An optional options object specified cookie parameters.
23581
23499
*
23582
23500
* serialize('foo', 'bar', { httpOnly: true })
23583
23501
* => "foo=bar; httpOnly"
@@ -23597,13 +23515,13 @@ function serialize(name, val, options) {
23597
23515
throw new TypeError('option encode is invalid');
23598
23516
}
23599
23517
23600
- if (!cookieNameRegExp .test(name)) {
23518
+ if (!fieldContentRegExp .test(name)) {
23601
23519
throw new TypeError('argument name is invalid');
23602
23520
}
23603
23521
23604
23522
var value = enc(val);
23605
23523
23606
- if (value && !cookieValueRegExp .test(value)) {
23524
+ if (value && !fieldContentRegExp .test(value)) {
23607
23525
throw new TypeError('argument val is invalid');
23608
23526
}
23609
23527
@@ -23612,37 +23530,35 @@ function serialize(name, val, options) {
23612
23530
if (null != opt.maxAge) {
23613
23531
var maxAge = opt.maxAge - 0;
23614
23532
23615
- if (!isFinite(maxAge)) {
23533
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
23616
23534
throw new TypeError('option maxAge is invalid')
23617
23535
}
23618
23536
23619
23537
str += '; Max-Age=' + Math.floor(maxAge);
23620
23538
}
23621
23539
23622
23540
if (opt.domain) {
23623
- if (!domainValueRegExp .test(opt.domain)) {
23541
+ if (!fieldContentRegExp .test(opt.domain)) {
23624
23542
throw new TypeError('option domain is invalid');
23625
23543
}
23626
23544
23627
23545
str += '; Domain=' + opt.domain;
23628
23546
}
23629
23547
23630
23548
if (opt.path) {
23631
- if (!pathValueRegExp .test(opt.path)) {
23549
+ if (!fieldContentRegExp .test(opt.path)) {
23632
23550
throw new TypeError('option path is invalid');
23633
23551
}
23634
23552
23635
23553
str += '; Path=' + opt.path;
23636
23554
}
23637
23555
23638
23556
if (opt.expires) {
23639
- var expires = opt.expires
23640
-
23641
- if (!isDate(expires) || isNaN(expires.valueOf())) {
23557
+ if (typeof opt.expires.toUTCString !== 'function') {
23642
23558
throw new TypeError('option expires is invalid');
23643
23559
}
23644
23560
23645
- str += '; Expires=' + expires.toUTCString()
23561
+ str += '; Expires=' + opt. expires.toUTCString();
23646
23562
}
23647
23563
23648
23564
if (opt.httpOnly) {
@@ -23653,30 +23569,6 @@ function serialize(name, val, options) {
23653
23569
str += '; Secure';
23654
23570
}
23655
23571
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
-
23680
23572
if (opt.sameSite) {
23681
23573
var sameSite = typeof opt.sameSite === 'string'
23682
23574
? opt.sameSite.toLowerCase() : opt.sameSite;
@@ -23702,42 +23594,6 @@ function serialize(name, val, options) {
23702
23594
return str;
23703
23595
}
23704
23596
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
-
23741
23597
/**
23742
23598
* Try decoding a string using a decoding function.
23743
23599
*
@@ -29185,7 +29041,7 @@ module.exports={
29185
29041
"_args": [
29186
29042
[
29187
29043
29188
- "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript"
29044
+ "/Users/abhis/Documents/GitHub /splunk-sdk-javascript"
29189
29045
]
29190
29046
],
29191
29047
"_development": true,
@@ -29211,7 +29067,7 @@ module.exports={
29211
29067
],
29212
29068
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
29213
29069
"_spec": "6.5.4",
29214
- "_where": "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript",
29070
+ "_where": "/Users/abhis/Documents/GitHub /splunk-sdk-javascript",
29215
29071
"author": {
29216
29072
"name": "Fedor Indutny",
29217
29073
@@ -39678,7 +39534,7 @@ module.exports={
39678
39534
"_args": [
39679
39535
[
39680
39536
39681
- "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript"
39537
+ "/Users/abhis/Documents/GitHub /splunk-sdk-javascript"
39682
39538
]
39683
39539
],
39684
39540
@@ -39704,13 +39560,13 @@ module.exports={
39704
39560
],
39705
39561
"_resolved": "https://registry.npmjs.org/needle/-/needle-3.0.0.tgz",
39706
39562
"_spec": "3.0.0",
39707
- "_where": "/Users/sjaskowski/PycharmProjects /splunk-sdk-javascript",
39563
+ "_where": "/Users/abhis/Documents/GitHub /splunk-sdk-javascript",
39708
39564
"author": {
39709
39565
"name": "Tomás Pollak",
39710
39566
39711
39567
},
39712
39568
"bin": {
39713
- "needle": "bin/needle"
39569
+ "needle": "./ bin/needle"
39714
39570
},
39715
39571
"bugs": {
39716
39572
"url": "https://github.com/tomas/needle/issues"
@@ -55541,7 +55397,7 @@ module.exports={
55541
55397
"test": "nyc mocha tests/tests.js -t 50000 --allow-uncaught --exit --reporter mochawesome"
55542
55398
},
55543
55399
"dependencies": {
55544
- "cookie": "0.7.0 ",
55400
+ "cookie": "0.4.2 ",
55545
55401
"dotenv": "16.0.0",
55546
55402
"elementtree": "0.1.7",
55547
55403
"needle": "3.0.0"
0 commit comments