superagent 7.1.6 → 8.0.0
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/README.md +35 -38
- package/dist/superagent.js +233 -325
- package/dist/superagent.min.js +1 -1
- package/lib/agent-base.js +8 -20
- package/lib/client.js +87 -100
- package/lib/node/agent.js +19 -23
- package/lib/node/http2wrapper.js +51 -61
- package/lib/node/index.js +171 -212
- package/lib/node/parsers/image.js +5 -5
- package/lib/node/parsers/index.js +2 -2
- package/lib/node/parsers/json.js +5 -5
- package/lib/node/parsers/text.js +3 -3
- package/lib/node/parsers/urlencoded.js +5 -5
- package/lib/node/response.js +16 -14
- package/lib/node/unzip.js +15 -15
- package/lib/request-base.js +35 -39
- package/lib/response-base.js +7 -7
- package/lib/utils.js +21 -27
- package/package.json +7 -7
- package/HISTORY.md +0 -692
package/dist/superagent.js
CHANGED
|
@@ -176,8 +176,6 @@ Emitter.prototype.hasListeners = function (event) {
|
|
|
176
176
|
},{}],5:[function(require,module,exports){
|
|
177
177
|
"use strict";
|
|
178
178
|
|
|
179
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
180
|
-
|
|
181
179
|
module.exports = stringify;
|
|
182
180
|
stringify.default = stringify;
|
|
183
181
|
stringify.stable = deterministicStringify;
|
|
@@ -247,7 +245,7 @@ function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
247
245
|
depth += 1;
|
|
248
246
|
var i;
|
|
249
247
|
|
|
250
|
-
if (
|
|
248
|
+
if (typeof val === 'object' && val !== null) {
|
|
251
249
|
for (i = 0; i < stack.length; i++) {
|
|
252
250
|
if (stack[i] === val) {
|
|
253
251
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -331,7 +329,7 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
331
329
|
depth += 1;
|
|
332
330
|
var i;
|
|
333
331
|
|
|
334
|
-
if (
|
|
332
|
+
if (typeof val === 'object' && val !== null) {
|
|
335
333
|
for (i = 0; i < stack.length; i++) {
|
|
336
334
|
if (stack[i] === val) {
|
|
337
335
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -424,7 +422,7 @@ module.exports = function bind(that) {
|
|
|
424
422
|
var args = slice.call(arguments, 1);
|
|
425
423
|
var bound;
|
|
426
424
|
|
|
427
|
-
var binder = function
|
|
425
|
+
var binder = function () {
|
|
428
426
|
if (this instanceof bound) {
|
|
429
427
|
var result = target.apply(this, args.concat(slice.call(arguments)));
|
|
430
428
|
|
|
@@ -468,14 +466,12 @@ module.exports = Function.prototype.bind || implementation;
|
|
|
468
466
|
},{"./implementation":6}],8:[function(require,module,exports){
|
|
469
467
|
'use strict';
|
|
470
468
|
|
|
471
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
472
|
-
|
|
473
469
|
var undefined;
|
|
474
470
|
var $SyntaxError = SyntaxError;
|
|
475
471
|
var $Function = Function;
|
|
476
472
|
var $TypeError = TypeError;
|
|
477
473
|
|
|
478
|
-
var getEvalledConstructor = function
|
|
474
|
+
var getEvalledConstructor = function (expressionSyntax) {
|
|
479
475
|
try {
|
|
480
476
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
481
477
|
} catch (e) {}
|
|
@@ -491,7 +487,7 @@ if ($gOPD) {
|
|
|
491
487
|
}
|
|
492
488
|
}
|
|
493
489
|
|
|
494
|
-
var throwTypeError = function
|
|
490
|
+
var throwTypeError = function () {
|
|
495
491
|
throw new $TypeError();
|
|
496
492
|
};
|
|
497
493
|
|
|
@@ -549,7 +545,7 @@ var INTRINSICS = {
|
|
|
549
545
|
'%isFinite%': isFinite,
|
|
550
546
|
'%isNaN%': isNaN,
|
|
551
547
|
'%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
552
|
-
'%JSON%':
|
|
548
|
+
'%JSON%': typeof JSON === 'object' ? JSON : undefined,
|
|
553
549
|
'%Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
554
550
|
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
555
551
|
'%Math%': Math,
|
|
@@ -672,6 +668,7 @@ var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
|
672
668
|
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
673
669
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
674
670
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
671
|
+
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
675
672
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
676
673
|
var reEscapeChar = /\\(\\)?/g;
|
|
677
674
|
|
|
@@ -731,6 +728,10 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
731
728
|
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
732
729
|
}
|
|
733
730
|
|
|
731
|
+
if ($exec(/^%?[^%]*%?$/g, name) === null) {
|
|
732
|
+
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
733
|
+
}
|
|
734
|
+
|
|
734
735
|
var parts = stringToPath(name);
|
|
735
736
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
736
737
|
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
@@ -797,8 +798,6 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
797
798
|
},{"function-bind":7,"has":11,"has-symbols":9}],9:[function(require,module,exports){
|
|
798
799
|
'use strict';
|
|
799
800
|
|
|
800
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
801
|
-
|
|
802
801
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
803
802
|
|
|
804
803
|
var hasSymbolSham = require('./shams');
|
|
@@ -812,11 +811,11 @@ module.exports = function hasNativeSymbols() {
|
|
|
812
811
|
return false;
|
|
813
812
|
}
|
|
814
813
|
|
|
815
|
-
if (
|
|
814
|
+
if (typeof origSymbol('foo') !== 'symbol') {
|
|
816
815
|
return false;
|
|
817
816
|
}
|
|
818
817
|
|
|
819
|
-
if (
|
|
818
|
+
if (typeof Symbol('bar') !== 'symbol') {
|
|
820
819
|
return false;
|
|
821
820
|
}
|
|
822
821
|
|
|
@@ -826,14 +825,12 @@ module.exports = function hasNativeSymbols() {
|
|
|
826
825
|
},{"./shams":10}],10:[function(require,module,exports){
|
|
827
826
|
'use strict';
|
|
828
827
|
|
|
829
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
830
|
-
|
|
831
828
|
module.exports = function hasSymbols() {
|
|
832
829
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
833
830
|
return false;
|
|
834
831
|
}
|
|
835
832
|
|
|
836
|
-
if (
|
|
833
|
+
if (typeof Symbol.iterator === 'symbol') {
|
|
837
834
|
return true;
|
|
838
835
|
}
|
|
839
836
|
|
|
@@ -899,8 +896,6 @@ module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
|
899
896
|
},{"function-bind":7}],12:[function(require,module,exports){
|
|
900
897
|
"use strict";
|
|
901
898
|
|
|
902
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
903
|
-
|
|
904
899
|
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
905
900
|
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
906
901
|
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
@@ -930,9 +925,9 @@ var $arrSlice = Array.prototype.slice;
|
|
|
930
925
|
var $floor = Math.floor;
|
|
931
926
|
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
932
927
|
var gOPS = Object.getOwnPropertySymbols;
|
|
933
|
-
var symToString = typeof Symbol === 'function' &&
|
|
934
|
-
var hasShammedSymbols = typeof Symbol === 'function' &&
|
|
935
|
-
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (
|
|
928
|
+
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
|
|
929
|
+
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
|
|
930
|
+
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
|
|
936
931
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
937
932
|
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
|
|
938
933
|
return O.__proto__;
|
|
@@ -1026,7 +1021,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1026
1021
|
depth = 0;
|
|
1027
1022
|
}
|
|
1028
1023
|
|
|
1029
|
-
if (depth >= maxDepth && maxDepth > 0 &&
|
|
1024
|
+
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
1030
1025
|
return isArray(obj) ? '[Array]' : '[Object]';
|
|
1031
1026
|
}
|
|
1032
1027
|
|
|
@@ -1067,7 +1062,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1067
1062
|
|
|
1068
1063
|
if (isSymbol(obj)) {
|
|
1069
1064
|
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
1070
|
-
return
|
|
1065
|
+
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
1071
1066
|
}
|
|
1072
1067
|
|
|
1073
1068
|
if (isElement(obj)) {
|
|
@@ -1116,7 +1111,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1116
1111
|
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
1117
1112
|
}
|
|
1118
1113
|
|
|
1119
|
-
if (
|
|
1114
|
+
if (typeof obj === 'object' && customInspect) {
|
|
1120
1115
|
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
|
|
1121
1116
|
return utilInspect(obj, {
|
|
1122
1117
|
depth: maxDepth - depth
|
|
@@ -1202,43 +1197,43 @@ function quote(s) {
|
|
|
1202
1197
|
}
|
|
1203
1198
|
|
|
1204
1199
|
function isArray(obj) {
|
|
1205
|
-
return toStr(obj) === '[object Array]' && (!toStringTag || !(
|
|
1200
|
+
return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1206
1201
|
}
|
|
1207
1202
|
|
|
1208
1203
|
function isDate(obj) {
|
|
1209
|
-
return toStr(obj) === '[object Date]' && (!toStringTag || !(
|
|
1204
|
+
return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1210
1205
|
}
|
|
1211
1206
|
|
|
1212
1207
|
function isRegExp(obj) {
|
|
1213
|
-
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(
|
|
1208
|
+
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1214
1209
|
}
|
|
1215
1210
|
|
|
1216
1211
|
function isError(obj) {
|
|
1217
|
-
return toStr(obj) === '[object Error]' && (!toStringTag || !(
|
|
1212
|
+
return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1218
1213
|
}
|
|
1219
1214
|
|
|
1220
1215
|
function isString(obj) {
|
|
1221
|
-
return toStr(obj) === '[object String]' && (!toStringTag || !(
|
|
1216
|
+
return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1222
1217
|
}
|
|
1223
1218
|
|
|
1224
1219
|
function isNumber(obj) {
|
|
1225
|
-
return toStr(obj) === '[object Number]' && (!toStringTag || !(
|
|
1220
|
+
return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1226
1221
|
}
|
|
1227
1222
|
|
|
1228
1223
|
function isBoolean(obj) {
|
|
1229
|
-
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(
|
|
1224
|
+
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1230
1225
|
}
|
|
1231
1226
|
|
|
1232
1227
|
function isSymbol(obj) {
|
|
1233
1228
|
if (hasShammedSymbols) {
|
|
1234
|
-
return obj &&
|
|
1229
|
+
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
1235
1230
|
}
|
|
1236
1231
|
|
|
1237
|
-
if (
|
|
1232
|
+
if (typeof obj === 'symbol') {
|
|
1238
1233
|
return true;
|
|
1239
1234
|
}
|
|
1240
1235
|
|
|
1241
|
-
if (!obj ||
|
|
1236
|
+
if (!obj || typeof obj !== 'object' || !symToString) {
|
|
1242
1237
|
return false;
|
|
1243
1238
|
}
|
|
1244
1239
|
|
|
@@ -1251,7 +1246,7 @@ function isSymbol(obj) {
|
|
|
1251
1246
|
}
|
|
1252
1247
|
|
|
1253
1248
|
function isBigInt(obj) {
|
|
1254
|
-
if (!obj ||
|
|
1249
|
+
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
|
|
1255
1250
|
return false;
|
|
1256
1251
|
}
|
|
1257
1252
|
|
|
@@ -1304,7 +1299,7 @@ function indexOf(xs, x) {
|
|
|
1304
1299
|
}
|
|
1305
1300
|
|
|
1306
1301
|
function isMap(x) {
|
|
1307
|
-
if (!mapSize || !x ||
|
|
1302
|
+
if (!mapSize || !x || typeof x !== 'object') {
|
|
1308
1303
|
return false;
|
|
1309
1304
|
}
|
|
1310
1305
|
|
|
@@ -1324,7 +1319,7 @@ function isMap(x) {
|
|
|
1324
1319
|
}
|
|
1325
1320
|
|
|
1326
1321
|
function isWeakMap(x) {
|
|
1327
|
-
if (!weakMapHas || !x ||
|
|
1322
|
+
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
1328
1323
|
return false;
|
|
1329
1324
|
}
|
|
1330
1325
|
|
|
@@ -1344,7 +1339,7 @@ function isWeakMap(x) {
|
|
|
1344
1339
|
}
|
|
1345
1340
|
|
|
1346
1341
|
function isWeakRef(x) {
|
|
1347
|
-
if (!weakRefDeref || !x ||
|
|
1342
|
+
if (!weakRefDeref || !x || typeof x !== 'object') {
|
|
1348
1343
|
return false;
|
|
1349
1344
|
}
|
|
1350
1345
|
|
|
@@ -1357,7 +1352,7 @@ function isWeakRef(x) {
|
|
|
1357
1352
|
}
|
|
1358
1353
|
|
|
1359
1354
|
function isSet(x) {
|
|
1360
|
-
if (!setSize || !x ||
|
|
1355
|
+
if (!setSize || !x || typeof x !== 'object') {
|
|
1361
1356
|
return false;
|
|
1362
1357
|
}
|
|
1363
1358
|
|
|
@@ -1377,7 +1372,7 @@ function isSet(x) {
|
|
|
1377
1372
|
}
|
|
1378
1373
|
|
|
1379
1374
|
function isWeakSet(x) {
|
|
1380
|
-
if (!weakSetHas || !x ||
|
|
1375
|
+
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
1381
1376
|
return false;
|
|
1382
1377
|
}
|
|
1383
1378
|
|
|
@@ -1397,7 +1392,7 @@ function isWeakSet(x) {
|
|
|
1397
1392
|
}
|
|
1398
1393
|
|
|
1399
1394
|
function isElement(x) {
|
|
1400
|
-
if (!x ||
|
|
1395
|
+
if (!x || typeof x !== 'object') {
|
|
1401
1396
|
return false;
|
|
1402
1397
|
}
|
|
1403
1398
|
|
|
@@ -1743,10 +1738,10 @@ var Format = {
|
|
|
1743
1738
|
module.exports = {
|
|
1744
1739
|
'default': Format.RFC3986,
|
|
1745
1740
|
formatters: {
|
|
1746
|
-
RFC1738: function
|
|
1741
|
+
RFC1738: function (value) {
|
|
1747
1742
|
return replace.call(value, percentTwenties, '+');
|
|
1748
1743
|
},
|
|
1749
|
-
RFC3986: function
|
|
1744
|
+
RFC3986: function (value) {
|
|
1750
1745
|
return String(value);
|
|
1751
1746
|
}
|
|
1752
1747
|
},
|
|
@@ -1795,13 +1790,13 @@ var defaults = {
|
|
|
1795
1790
|
strictNullHandling: false
|
|
1796
1791
|
};
|
|
1797
1792
|
|
|
1798
|
-
var interpretNumericEntities = function
|
|
1793
|
+
var interpretNumericEntities = function (str) {
|
|
1799
1794
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
1800
1795
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
1801
1796
|
});
|
|
1802
1797
|
};
|
|
1803
1798
|
|
|
1804
|
-
var parseArrayValue = function
|
|
1799
|
+
var parseArrayValue = function (val, options) {
|
|
1805
1800
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
1806
1801
|
return val.split(',');
|
|
1807
1802
|
}
|
|
@@ -1874,7 +1869,7 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1874
1869
|
return obj;
|
|
1875
1870
|
};
|
|
1876
1871
|
|
|
1877
|
-
var parseObject = function
|
|
1872
|
+
var parseObject = function (chain, val, options, valuesParsed) {
|
|
1878
1873
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
1879
1874
|
|
|
1880
1875
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
@@ -2010,8 +2005,6 @@ module.exports = function (str, opts) {
|
|
|
2010
2005
|
},{"./utils":18}],17:[function(require,module,exports){
|
|
2011
2006
|
'use strict';
|
|
2012
2007
|
|
|
2013
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2014
|
-
|
|
2015
2008
|
var getSideChannel = require('side-channel');
|
|
2016
2009
|
|
|
2017
2010
|
var utils = require('./utils');
|
|
@@ -2035,7 +2028,7 @@ var isArray = Array.isArray;
|
|
|
2035
2028
|
var split = String.prototype.split;
|
|
2036
2029
|
var push = Array.prototype.push;
|
|
2037
2030
|
|
|
2038
|
-
var pushToArray = function
|
|
2031
|
+
var pushToArray = function (arr, valueOrArray) {
|
|
2039
2032
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2040
2033
|
};
|
|
2041
2034
|
|
|
@@ -2061,7 +2054,7 @@ var defaults = {
|
|
|
2061
2054
|
};
|
|
2062
2055
|
|
|
2063
2056
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
2064
|
-
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' ||
|
|
2057
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
|
|
2065
2058
|
};
|
|
2066
2059
|
|
|
2067
2060
|
var sentinel = {};
|
|
@@ -2123,7 +2116,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2123
2116
|
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
|
|
2124
2117
|
}
|
|
2125
2118
|
|
|
2126
|
-
return [formatter(keyValue) + '=' + valuesJoined];
|
|
2119
|
+
return [formatter(keyValue) + (isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
|
|
2127
2120
|
}
|
|
2128
2121
|
|
|
2129
2122
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
@@ -2151,15 +2144,17 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2151
2144
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
2152
2145
|
}
|
|
2153
2146
|
|
|
2147
|
+
var adjustedPrefix = generateArrayPrefix === 'comma' && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
2148
|
+
|
|
2154
2149
|
for (var j = 0; j < objKeys.length; ++j) {
|
|
2155
2150
|
var key = objKeys[j];
|
|
2156
|
-
var value =
|
|
2151
|
+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
2157
2152
|
|
|
2158
2153
|
if (skipNulls && value === null) {
|
|
2159
2154
|
continue;
|
|
2160
2155
|
}
|
|
2161
2156
|
|
|
2162
|
-
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(
|
|
2157
|
+
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
2163
2158
|
sideChannel.set(object, step);
|
|
2164
2159
|
var valueSideChannel = getSideChannel();
|
|
2165
2160
|
valueSideChannel.set(sentinel, sideChannel);
|
|
@@ -2236,7 +2231,7 @@ module.exports = function (object, opts) {
|
|
|
2236
2231
|
|
|
2237
2232
|
var keys = [];
|
|
2238
2233
|
|
|
2239
|
-
if (
|
|
2234
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
2240
2235
|
return '';
|
|
2241
2236
|
}
|
|
2242
2237
|
|
|
@@ -2289,8 +2284,6 @@ module.exports = function (object, opts) {
|
|
|
2289
2284
|
},{"./formats":14,"./utils":18,"side-channel":19}],18:[function(require,module,exports){
|
|
2290
2285
|
'use strict';
|
|
2291
2286
|
|
|
2292
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2293
|
-
|
|
2294
2287
|
var formats = require('./formats');
|
|
2295
2288
|
|
|
2296
2289
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -2342,10 +2335,10 @@ var merge = function merge(target, source, options) {
|
|
|
2342
2335
|
return target;
|
|
2343
2336
|
}
|
|
2344
2337
|
|
|
2345
|
-
if (
|
|
2338
|
+
if (typeof source !== 'object') {
|
|
2346
2339
|
if (isArray(target)) {
|
|
2347
2340
|
target.push(source);
|
|
2348
|
-
} else if (target &&
|
|
2341
|
+
} else if (target && typeof target === 'object') {
|
|
2349
2342
|
if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
|
|
2350
2343
|
target[source] = true;
|
|
2351
2344
|
}
|
|
@@ -2356,7 +2349,7 @@ var merge = function merge(target, source, options) {
|
|
|
2356
2349
|
return target;
|
|
2357
2350
|
}
|
|
2358
2351
|
|
|
2359
|
-
if (!target ||
|
|
2352
|
+
if (!target || typeof target !== 'object') {
|
|
2360
2353
|
return [target].concat(source);
|
|
2361
2354
|
}
|
|
2362
2355
|
|
|
@@ -2371,7 +2364,7 @@ var merge = function merge(target, source, options) {
|
|
|
2371
2364
|
if (has.call(target, i)) {
|
|
2372
2365
|
var targetItem = target[i];
|
|
2373
2366
|
|
|
2374
|
-
if (targetItem &&
|
|
2367
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
2375
2368
|
target[i] = merge(targetItem, item, options);
|
|
2376
2369
|
} else {
|
|
2377
2370
|
target.push(item);
|
|
@@ -2403,7 +2396,7 @@ var assign = function assignSingleSource(target, source) {
|
|
|
2403
2396
|
}, target);
|
|
2404
2397
|
};
|
|
2405
2398
|
|
|
2406
|
-
var decode = function
|
|
2399
|
+
var decode = function (str, decoder, charset) {
|
|
2407
2400
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
2408
2401
|
|
|
2409
2402
|
if (charset === 'iso-8859-1') {
|
|
@@ -2424,7 +2417,7 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
|
2424
2417
|
|
|
2425
2418
|
var string = str;
|
|
2426
2419
|
|
|
2427
|
-
if (
|
|
2420
|
+
if (typeof str === 'symbol') {
|
|
2428
2421
|
string = Symbol.prototype.toString.call(str);
|
|
2429
2422
|
} else if (typeof str !== 'string') {
|
|
2430
2423
|
string = String(str);
|
|
@@ -2487,7 +2480,7 @@ var compact = function compact(value) {
|
|
|
2487
2480
|
var key = keys[j];
|
|
2488
2481
|
var val = obj[key];
|
|
2489
2482
|
|
|
2490
|
-
if (
|
|
2483
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
2491
2484
|
queue.push({
|
|
2492
2485
|
obj: obj,
|
|
2493
2486
|
prop: key
|
|
@@ -2506,7 +2499,7 @@ var isRegExp = function isRegExp(obj) {
|
|
|
2506
2499
|
};
|
|
2507
2500
|
|
|
2508
2501
|
var isBuffer = function isBuffer(obj) {
|
|
2509
|
-
if (!obj ||
|
|
2502
|
+
if (!obj || typeof obj !== 'object') {
|
|
2510
2503
|
return false;
|
|
2511
2504
|
}
|
|
2512
2505
|
|
|
@@ -2547,8 +2540,6 @@ module.exports = {
|
|
|
2547
2540
|
},{"./formats":14}],19:[function(require,module,exports){
|
|
2548
2541
|
'use strict';
|
|
2549
2542
|
|
|
2550
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2551
|
-
|
|
2552
2543
|
var GetIntrinsic = require('get-intrinsic');
|
|
2553
2544
|
|
|
2554
2545
|
var callBound = require('call-bind/callBound');
|
|
@@ -2565,7 +2556,7 @@ var $mapGet = callBound('Map.prototype.get', true);
|
|
|
2565
2556
|
var $mapSet = callBound('Map.prototype.set', true);
|
|
2566
2557
|
var $mapHas = callBound('Map.prototype.has', true);
|
|
2567
2558
|
|
|
2568
|
-
var listGetNode = function
|
|
2559
|
+
var listGetNode = function (list, key) {
|
|
2569
2560
|
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
2570
2561
|
if (curr.key === key) {
|
|
2571
2562
|
prev.next = curr.next;
|
|
@@ -2576,12 +2567,12 @@ var listGetNode = function listGetNode(list, key) {
|
|
|
2576
2567
|
}
|
|
2577
2568
|
};
|
|
2578
2569
|
|
|
2579
|
-
var listGet = function
|
|
2570
|
+
var listGet = function (objects, key) {
|
|
2580
2571
|
var node = listGetNode(objects, key);
|
|
2581
2572
|
return node && node.value;
|
|
2582
2573
|
};
|
|
2583
2574
|
|
|
2584
|
-
var listSet = function
|
|
2575
|
+
var listSet = function (objects, key, value) {
|
|
2585
2576
|
var node = listGetNode(objects, key);
|
|
2586
2577
|
|
|
2587
2578
|
if (node) {
|
|
@@ -2595,7 +2586,7 @@ var listSet = function listSet(objects, key, value) {
|
|
|
2595
2586
|
}
|
|
2596
2587
|
};
|
|
2597
2588
|
|
|
2598
|
-
var listHas = function
|
|
2589
|
+
var listHas = function (objects, key) {
|
|
2599
2590
|
return !!listGetNode(objects, key);
|
|
2600
2591
|
};
|
|
2601
2592
|
|
|
@@ -2604,13 +2595,13 @@ module.exports = function getSideChannel() {
|
|
|
2604
2595
|
var $m;
|
|
2605
2596
|
var $o;
|
|
2606
2597
|
var channel = {
|
|
2607
|
-
assert: function
|
|
2598
|
+
assert: function (key) {
|
|
2608
2599
|
if (!channel.has(key)) {
|
|
2609
2600
|
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
2610
2601
|
}
|
|
2611
2602
|
},
|
|
2612
|
-
get: function
|
|
2613
|
-
if ($WeakMap && key && (
|
|
2603
|
+
get: function (key) {
|
|
2604
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2614
2605
|
if ($wm) {
|
|
2615
2606
|
return $weakMapGet($wm, key);
|
|
2616
2607
|
}
|
|
@@ -2624,8 +2615,8 @@ module.exports = function getSideChannel() {
|
|
|
2624
2615
|
}
|
|
2625
2616
|
}
|
|
2626
2617
|
},
|
|
2627
|
-
has: function
|
|
2628
|
-
if ($WeakMap && key && (
|
|
2618
|
+
has: function (key) {
|
|
2619
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2629
2620
|
if ($wm) {
|
|
2630
2621
|
return $weakMapHas($wm, key);
|
|
2631
2622
|
}
|
|
@@ -2641,8 +2632,8 @@ module.exports = function getSideChannel() {
|
|
|
2641
2632
|
|
|
2642
2633
|
return false;
|
|
2643
2634
|
},
|
|
2644
|
-
set: function
|
|
2645
|
-
if ($WeakMap && key && (
|
|
2635
|
+
set: function (key, value) {
|
|
2636
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2646
2637
|
if (!$wm) {
|
|
2647
2638
|
$wm = new $WeakMap();
|
|
2648
2639
|
}
|
|
@@ -2672,58 +2663,28 @@ module.exports = function getSideChannel() {
|
|
|
2672
2663
|
},{"call-bind/callBound":2,"get-intrinsic":8,"object-inspect":12}],20:[function(require,module,exports){
|
|
2673
2664
|
"use strict";
|
|
2674
2665
|
|
|
2675
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2676
|
-
|
|
2677
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2678
|
-
|
|
2679
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
2680
|
-
|
|
2681
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
2682
|
-
|
|
2683
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2684
|
-
|
|
2685
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2686
|
-
|
|
2687
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2688
|
-
|
|
2689
2666
|
function Agent() {
|
|
2690
2667
|
this._defaults = [];
|
|
2691
2668
|
}
|
|
2692
2669
|
|
|
2693
|
-
|
|
2694
|
-
var fn = _arr[_i];
|
|
2695
|
-
|
|
2670
|
+
for (const fn of ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']) {
|
|
2696
2671
|
Agent.prototype[fn] = function () {
|
|
2697
2672
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2698
2673
|
args[_key] = arguments[_key];
|
|
2699
2674
|
}
|
|
2700
2675
|
|
|
2701
2676
|
this._defaults.push({
|
|
2702
|
-
fn
|
|
2703
|
-
args
|
|
2677
|
+
fn,
|
|
2678
|
+
args
|
|
2704
2679
|
});
|
|
2705
2680
|
|
|
2706
2681
|
return this;
|
|
2707
2682
|
};
|
|
2708
|
-
};
|
|
2709
|
-
|
|
2710
|
-
for (var _i = 0, _arr = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']; _i < _arr.length; _i++) {
|
|
2711
|
-
_loop();
|
|
2712
2683
|
}
|
|
2713
2684
|
|
|
2714
2685
|
Agent.prototype._setDefaults = function (request) {
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
try {
|
|
2719
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2720
|
-
var def = _step.value;
|
|
2721
|
-
request[def.fn].apply(request, _toConsumableArray(def.args));
|
|
2722
|
-
}
|
|
2723
|
-
} catch (err) {
|
|
2724
|
-
_iterator.e(err);
|
|
2725
|
-
} finally {
|
|
2726
|
-
_iterator.f();
|
|
2686
|
+
for (const def of this._defaults) {
|
|
2687
|
+
request[def.fn](...def.args);
|
|
2727
2688
|
}
|
|
2728
2689
|
};
|
|
2729
2690
|
|
|
@@ -2732,15 +2693,7 @@ module.exports = Agent;
|
|
|
2732
2693
|
},{}],21:[function(require,module,exports){
|
|
2733
2694
|
"use strict";
|
|
2734
2695
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2738
|
-
|
|
2739
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2740
|
-
|
|
2741
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2742
|
-
|
|
2743
|
-
var root;
|
|
2696
|
+
let root;
|
|
2744
2697
|
|
|
2745
2698
|
if (typeof window !== 'undefined') {
|
|
2746
2699
|
root = window;
|
|
@@ -2751,22 +2704,23 @@ if (typeof window !== 'undefined') {
|
|
|
2751
2704
|
root = self;
|
|
2752
2705
|
}
|
|
2753
2706
|
|
|
2754
|
-
|
|
2707
|
+
const Emitter = require('component-emitter');
|
|
2755
2708
|
|
|
2756
|
-
|
|
2709
|
+
const safeStringify = require('fast-safe-stringify');
|
|
2757
2710
|
|
|
2758
|
-
|
|
2711
|
+
const qs = require('qs');
|
|
2759
2712
|
|
|
2760
|
-
|
|
2713
|
+
const RequestBase = require('./request-base');
|
|
2761
2714
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2715
|
+
const {
|
|
2716
|
+
isObject,
|
|
2717
|
+
mixin,
|
|
2718
|
+
hasOwn
|
|
2719
|
+
} = require('./utils');
|
|
2766
2720
|
|
|
2767
|
-
|
|
2721
|
+
const ResponseBase = require('./response-base');
|
|
2768
2722
|
|
|
2769
|
-
|
|
2723
|
+
const Agent = require('./agent-base');
|
|
2770
2724
|
|
|
2771
2725
|
function noop() {}
|
|
2772
2726
|
|
|
@@ -2783,28 +2737,24 @@ module.exports = function (method, url) {
|
|
|
2783
2737
|
};
|
|
2784
2738
|
|
|
2785
2739
|
exports = module.exports;
|
|
2786
|
-
|
|
2740
|
+
const request = exports;
|
|
2787
2741
|
exports.Request = Request;
|
|
2788
2742
|
|
|
2789
|
-
request.getXHR =
|
|
2790
|
-
if (root.XMLHttpRequest
|
|
2791
|
-
return new XMLHttpRequest();
|
|
2743
|
+
request.getXHR = () => {
|
|
2744
|
+
if (root.XMLHttpRequest) {
|
|
2745
|
+
return new root.XMLHttpRequest();
|
|
2792
2746
|
}
|
|
2793
2747
|
|
|
2794
2748
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
2795
2749
|
};
|
|
2796
2750
|
|
|
2797
|
-
|
|
2798
|
-
return s.trim();
|
|
2799
|
-
} : function (s) {
|
|
2800
|
-
return s.replace(/(^\s*|\s*$)/g, '');
|
|
2801
|
-
};
|
|
2751
|
+
const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
|
|
2802
2752
|
|
|
2803
2753
|
function serialize(object) {
|
|
2804
2754
|
if (!isObject(object)) return object;
|
|
2805
|
-
|
|
2755
|
+
const pairs = [];
|
|
2806
2756
|
|
|
2807
|
-
for (
|
|
2757
|
+
for (const key in object) {
|
|
2808
2758
|
if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
|
|
2809
2759
|
}
|
|
2810
2760
|
|
|
@@ -2820,21 +2770,11 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2820
2770
|
}
|
|
2821
2771
|
|
|
2822
2772
|
if (Array.isArray(value)) {
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
try {
|
|
2827
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2828
|
-
var v = _step.value;
|
|
2829
|
-
pushEncodedKeyValuePair(pairs, key, v);
|
|
2830
|
-
}
|
|
2831
|
-
} catch (err) {
|
|
2832
|
-
_iterator.e(err);
|
|
2833
|
-
} finally {
|
|
2834
|
-
_iterator.f();
|
|
2773
|
+
for (const v of value) {
|
|
2774
|
+
pushEncodedKeyValuePair(pairs, key, v);
|
|
2835
2775
|
}
|
|
2836
2776
|
} else if (isObject(value)) {
|
|
2837
|
-
for (
|
|
2777
|
+
for (const subkey in value) {
|
|
2838
2778
|
if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), value[subkey]);
|
|
2839
2779
|
}
|
|
2840
2780
|
} else {
|
|
@@ -2845,12 +2785,12 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2845
2785
|
request.serializeObject = serialize;
|
|
2846
2786
|
|
|
2847
2787
|
function parseString(string_) {
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2788
|
+
const object = {};
|
|
2789
|
+
const pairs = string_.split('&');
|
|
2790
|
+
let pair;
|
|
2791
|
+
let pos;
|
|
2852
2792
|
|
|
2853
|
-
for (
|
|
2793
|
+
for (let i = 0, length_ = pairs.length; i < length_; ++i) {
|
|
2854
2794
|
pair = pairs[i];
|
|
2855
2795
|
pos = pair.indexOf('=');
|
|
2856
2796
|
|
|
@@ -2883,14 +2823,14 @@ request.parse = {
|
|
|
2883
2823
|
};
|
|
2884
2824
|
|
|
2885
2825
|
function parseHeader(string_) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
for (
|
|
2826
|
+
const lines = string_.split(/\r?\n/);
|
|
2827
|
+
const fields = {};
|
|
2828
|
+
let index;
|
|
2829
|
+
let line;
|
|
2830
|
+
let field;
|
|
2831
|
+
let value;
|
|
2832
|
+
|
|
2833
|
+
for (let i = 0, length_ = lines.length; i < length_; ++i) {
|
|
2894
2834
|
line = lines[i];
|
|
2895
2835
|
index = line.indexOf(':');
|
|
2896
2836
|
|
|
@@ -2915,7 +2855,9 @@ function Response(request_) {
|
|
|
2915
2855
|
this.xhr = this.req.xhr;
|
|
2916
2856
|
this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
|
|
2917
2857
|
this.statusText = this.req.xhr.statusText;
|
|
2918
|
-
|
|
2858
|
+
let {
|
|
2859
|
+
status
|
|
2860
|
+
} = this.xhr;
|
|
2919
2861
|
|
|
2920
2862
|
if (status === 1223) {
|
|
2921
2863
|
status = 204;
|
|
@@ -2939,7 +2881,7 @@ function Response(request_) {
|
|
|
2939
2881
|
mixin(Response.prototype, ResponseBase.prototype);
|
|
2940
2882
|
|
|
2941
2883
|
Response.prototype._parseBody = function (string_) {
|
|
2942
|
-
|
|
2884
|
+
let parse = request.parse[this.type];
|
|
2943
2885
|
|
|
2944
2886
|
if (this.req._parser) {
|
|
2945
2887
|
return this.req._parser(this, string_);
|
|
@@ -2953,11 +2895,17 @@ Response.prototype._parseBody = function (string_) {
|
|
|
2953
2895
|
};
|
|
2954
2896
|
|
|
2955
2897
|
Response.prototype.toError = function () {
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2898
|
+
const {
|
|
2899
|
+
req
|
|
2900
|
+
} = this;
|
|
2901
|
+
const {
|
|
2902
|
+
method
|
|
2903
|
+
} = req;
|
|
2904
|
+
const {
|
|
2905
|
+
url
|
|
2906
|
+
} = req;
|
|
2907
|
+
const message = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")");
|
|
2908
|
+
const error = new Error(message);
|
|
2961
2909
|
error.status = this.status;
|
|
2962
2910
|
error.method = method;
|
|
2963
2911
|
error.url = url;
|
|
@@ -2967,15 +2915,15 @@ Response.prototype.toError = function () {
|
|
|
2967
2915
|
request.Response = Response;
|
|
2968
2916
|
|
|
2969
2917
|
function Request(method, url) {
|
|
2970
|
-
|
|
2918
|
+
const self = this;
|
|
2971
2919
|
this._query = this._query || [];
|
|
2972
2920
|
this.method = method;
|
|
2973
2921
|
this.url = url;
|
|
2974
2922
|
this.header = {};
|
|
2975
2923
|
this._header = {};
|
|
2976
|
-
this.on('end',
|
|
2977
|
-
|
|
2978
|
-
|
|
2924
|
+
this.on('end', () => {
|
|
2925
|
+
let error = null;
|
|
2926
|
+
let res = null;
|
|
2979
2927
|
|
|
2980
2928
|
try {
|
|
2981
2929
|
res = new Response(self);
|
|
@@ -2997,7 +2945,7 @@ function Request(method, url) {
|
|
|
2997
2945
|
}
|
|
2998
2946
|
|
|
2999
2947
|
self.emit('response', res);
|
|
3000
|
-
|
|
2948
|
+
let new_error;
|
|
3001
2949
|
|
|
3002
2950
|
try {
|
|
3003
2951
|
if (!self._isResponseOK(res)) {
|
|
@@ -3034,7 +2982,7 @@ Request.prototype.accept = function (type) {
|
|
|
3034
2982
|
Request.prototype.auth = function (user, pass, options) {
|
|
3035
2983
|
if (arguments.length === 1) pass = '';
|
|
3036
2984
|
|
|
3037
|
-
if (
|
|
2985
|
+
if (typeof pass === 'object' && pass !== null) {
|
|
3038
2986
|
options = pass;
|
|
3039
2987
|
pass = '';
|
|
3040
2988
|
}
|
|
@@ -3045,7 +2993,7 @@ Request.prototype.auth = function (user, pass, options) {
|
|
|
3045
2993
|
};
|
|
3046
2994
|
}
|
|
3047
2995
|
|
|
3048
|
-
|
|
2996
|
+
const encoder = options.encoder ? options.encoder : string => {
|
|
3049
2997
|
if (typeof btoa === 'function') {
|
|
3050
2998
|
return btoa(string);
|
|
3051
2999
|
}
|
|
@@ -3086,7 +3034,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3086
3034
|
return this._retry();
|
|
3087
3035
|
}
|
|
3088
3036
|
|
|
3089
|
-
|
|
3037
|
+
const fn = this._callback;
|
|
3090
3038
|
this.clearTimeout();
|
|
3091
3039
|
|
|
3092
3040
|
if (error) {
|
|
@@ -3098,7 +3046,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3098
3046
|
};
|
|
3099
3047
|
|
|
3100
3048
|
Request.prototype.crossDomainError = function () {
|
|
3101
|
-
|
|
3049
|
+
const error = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
|
|
3102
3050
|
error.crossDomain = true;
|
|
3103
3051
|
error.status = this.status;
|
|
3104
3052
|
error.method = this.method;
|
|
@@ -3114,14 +3062,14 @@ Request.prototype.agent = function () {
|
|
|
3114
3062
|
Request.prototype.ca = Request.prototype.agent;
|
|
3115
3063
|
Request.prototype.buffer = Request.prototype.ca;
|
|
3116
3064
|
|
|
3117
|
-
Request.prototype.write =
|
|
3065
|
+
Request.prototype.write = () => {
|
|
3118
3066
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
3119
3067
|
};
|
|
3120
3068
|
|
|
3121
3069
|
Request.prototype.pipe = Request.prototype.write;
|
|
3122
3070
|
|
|
3123
3071
|
Request.prototype._isHost = function (object) {
|
|
3124
|
-
return object &&
|
|
3072
|
+
return object && typeof object === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
|
|
3125
3073
|
};
|
|
3126
3074
|
|
|
3127
3075
|
Request.prototype.end = function (fn) {
|
|
@@ -3138,10 +3086,10 @@ Request.prototype.end = function (fn) {
|
|
|
3138
3086
|
};
|
|
3139
3087
|
|
|
3140
3088
|
Request.prototype._setUploadTimeout = function () {
|
|
3141
|
-
|
|
3089
|
+
const self = this;
|
|
3142
3090
|
|
|
3143
3091
|
if (this._uploadTimeout && !this._uploadTimeoutTimer) {
|
|
3144
|
-
this._uploadTimeoutTimer = setTimeout(
|
|
3092
|
+
this._uploadTimeoutTimer = setTimeout(() => {
|
|
3145
3093
|
self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
|
|
3146
3094
|
}, this._uploadTimeout);
|
|
3147
3095
|
}
|
|
@@ -3149,15 +3097,19 @@ Request.prototype._setUploadTimeout = function () {
|
|
|
3149
3097
|
|
|
3150
3098
|
Request.prototype._end = function () {
|
|
3151
3099
|
if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
|
|
3152
|
-
|
|
3100
|
+
const self = this;
|
|
3153
3101
|
this.xhr = request.getXHR();
|
|
3154
|
-
|
|
3155
|
-
|
|
3102
|
+
const {
|
|
3103
|
+
xhr
|
|
3104
|
+
} = this;
|
|
3105
|
+
let data = this._formData || this._data;
|
|
3156
3106
|
|
|
3157
3107
|
this._setTimeouts();
|
|
3158
3108
|
|
|
3159
|
-
xhr.addEventListener('readystatechange',
|
|
3160
|
-
|
|
3109
|
+
xhr.addEventListener('readystatechange', () => {
|
|
3110
|
+
const {
|
|
3111
|
+
readyState
|
|
3112
|
+
} = xhr;
|
|
3161
3113
|
|
|
3162
3114
|
if (readyState >= 2 && self._responseTimeoutTimer) {
|
|
3163
3115
|
clearTimeout(self._responseTimeoutTimer);
|
|
@@ -3167,11 +3119,11 @@ Request.prototype._end = function () {
|
|
|
3167
3119
|
return;
|
|
3168
3120
|
}
|
|
3169
3121
|
|
|
3170
|
-
|
|
3122
|
+
let status;
|
|
3171
3123
|
|
|
3172
3124
|
try {
|
|
3173
3125
|
status = xhr.status;
|
|
3174
|
-
} catch (
|
|
3126
|
+
} catch (err) {
|
|
3175
3127
|
status = 0;
|
|
3176
3128
|
}
|
|
3177
3129
|
|
|
@@ -3183,7 +3135,7 @@ Request.prototype._end = function () {
|
|
|
3183
3135
|
self.emit('end');
|
|
3184
3136
|
});
|
|
3185
3137
|
|
|
3186
|
-
|
|
3138
|
+
const handleProgress = (direction, e) => {
|
|
3187
3139
|
if (e.total > 0) {
|
|
3188
3140
|
e.percent = e.loaded / e.total * 100;
|
|
3189
3141
|
|
|
@@ -3203,7 +3155,7 @@ Request.prototype._end = function () {
|
|
|
3203
3155
|
if (xhr.upload) {
|
|
3204
3156
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
3205
3157
|
}
|
|
3206
|
-
} catch (
|
|
3158
|
+
} catch (err) {}
|
|
3207
3159
|
}
|
|
3208
3160
|
|
|
3209
3161
|
if (xhr.upload) {
|
|
@@ -3223,18 +3175,17 @@ Request.prototype._end = function () {
|
|
|
3223
3175
|
if (this._withCredentials) xhr.withCredentials = true;
|
|
3224
3176
|
|
|
3225
3177
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
3226
|
-
|
|
3178
|
+
const contentType = this._header['content-type'];
|
|
3179
|
+
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3227
3180
|
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
if (!_serialize && isJSON(contentType)) {
|
|
3231
|
-
_serialize = request.serialize['application/json'];
|
|
3181
|
+
if (!serialize && isJSON(contentType)) {
|
|
3182
|
+
serialize = request.serialize['application/json'];
|
|
3232
3183
|
}
|
|
3233
3184
|
|
|
3234
|
-
if (
|
|
3185
|
+
if (serialize) data = serialize(data);
|
|
3235
3186
|
}
|
|
3236
3187
|
|
|
3237
|
-
for (
|
|
3188
|
+
for (const field in this.header) {
|
|
3238
3189
|
if (this.header[field] === null) continue;
|
|
3239
3190
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
3240
3191
|
}
|
|
@@ -3247,15 +3198,11 @@ Request.prototype._end = function () {
|
|
|
3247
3198
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
3248
3199
|
};
|
|
3249
3200
|
|
|
3250
|
-
request.agent =
|
|
3251
|
-
return new Agent();
|
|
3252
|
-
};
|
|
3253
|
-
|
|
3254
|
-
var _loop = function _loop() {
|
|
3255
|
-
var method = _arr[_i];
|
|
3201
|
+
request.agent = () => new Agent();
|
|
3256
3202
|
|
|
3203
|
+
for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
3257
3204
|
Agent.prototype[method.toLowerCase()] = function (url, fn) {
|
|
3258
|
-
|
|
3205
|
+
const request_ = new request.Request(method, url);
|
|
3259
3206
|
|
|
3260
3207
|
this._setDefaults(request_);
|
|
3261
3208
|
|
|
@@ -3265,16 +3212,12 @@ var _loop = function _loop() {
|
|
|
3265
3212
|
|
|
3266
3213
|
return request_;
|
|
3267
3214
|
};
|
|
3268
|
-
};
|
|
3269
|
-
|
|
3270
|
-
for (var _i = 0, _arr = ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']; _i < _arr.length; _i++) {
|
|
3271
|
-
_loop();
|
|
3272
3215
|
}
|
|
3273
3216
|
|
|
3274
3217
|
Agent.prototype.del = Agent.prototype.delete;
|
|
3275
3218
|
|
|
3276
|
-
request.get =
|
|
3277
|
-
|
|
3219
|
+
request.get = (url, data, fn) => {
|
|
3220
|
+
const request_ = request('GET', url);
|
|
3278
3221
|
|
|
3279
3222
|
if (typeof data === 'function') {
|
|
3280
3223
|
fn = data;
|
|
@@ -3286,8 +3229,8 @@ request.get = function (url, data, fn) {
|
|
|
3286
3229
|
return request_;
|
|
3287
3230
|
};
|
|
3288
3231
|
|
|
3289
|
-
request.head =
|
|
3290
|
-
|
|
3232
|
+
request.head = (url, data, fn) => {
|
|
3233
|
+
const request_ = request('HEAD', url);
|
|
3291
3234
|
|
|
3292
3235
|
if (typeof data === 'function') {
|
|
3293
3236
|
fn = data;
|
|
@@ -3299,8 +3242,8 @@ request.head = function (url, data, fn) {
|
|
|
3299
3242
|
return request_;
|
|
3300
3243
|
};
|
|
3301
3244
|
|
|
3302
|
-
request.options =
|
|
3303
|
-
|
|
3245
|
+
request.options = (url, data, fn) => {
|
|
3246
|
+
const request_ = request('OPTIONS', url);
|
|
3304
3247
|
|
|
3305
3248
|
if (typeof data === 'function') {
|
|
3306
3249
|
fn = data;
|
|
@@ -3313,7 +3256,7 @@ request.options = function (url, data, fn) {
|
|
|
3313
3256
|
};
|
|
3314
3257
|
|
|
3315
3258
|
function del(url, data, fn) {
|
|
3316
|
-
|
|
3259
|
+
const request_ = request('DELETE', url);
|
|
3317
3260
|
|
|
3318
3261
|
if (typeof data === 'function') {
|
|
3319
3262
|
fn = data;
|
|
@@ -3328,8 +3271,8 @@ function del(url, data, fn) {
|
|
|
3328
3271
|
request.del = del;
|
|
3329
3272
|
request.delete = del;
|
|
3330
3273
|
|
|
3331
|
-
request.patch =
|
|
3332
|
-
|
|
3274
|
+
request.patch = (url, data, fn) => {
|
|
3275
|
+
const request_ = request('PATCH', url);
|
|
3333
3276
|
|
|
3334
3277
|
if (typeof data === 'function') {
|
|
3335
3278
|
fn = data;
|
|
@@ -3341,8 +3284,8 @@ request.patch = function (url, data, fn) {
|
|
|
3341
3284
|
return request_;
|
|
3342
3285
|
};
|
|
3343
3286
|
|
|
3344
|
-
request.post =
|
|
3345
|
-
|
|
3287
|
+
request.post = (url, data, fn) => {
|
|
3288
|
+
const request_ = request('POST', url);
|
|
3346
3289
|
|
|
3347
3290
|
if (typeof data === 'function') {
|
|
3348
3291
|
fn = data;
|
|
@@ -3354,8 +3297,8 @@ request.post = function (url, data, fn) {
|
|
|
3354
3297
|
return request_;
|
|
3355
3298
|
};
|
|
3356
3299
|
|
|
3357
|
-
request.put =
|
|
3358
|
-
|
|
3300
|
+
request.put = (url, data, fn) => {
|
|
3301
|
+
const request_ = request('PUT', url);
|
|
3359
3302
|
|
|
3360
3303
|
if (typeof data === 'function') {
|
|
3361
3304
|
fn = data;
|
|
@@ -3371,13 +3314,12 @@ request.put = function (url, data, fn) {
|
|
|
3371
3314
|
(function (process){(function (){
|
|
3372
3315
|
"use strict";
|
|
3373
3316
|
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
var semver = require('semver');
|
|
3317
|
+
const semver = require('semver');
|
|
3377
3318
|
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3319
|
+
const {
|
|
3320
|
+
isObject,
|
|
3321
|
+
hasOwn
|
|
3322
|
+
} = require('./utils');
|
|
3381
3323
|
|
|
3382
3324
|
module.exports = RequestBase;
|
|
3383
3325
|
|
|
@@ -3409,14 +3351,14 @@ RequestBase.prototype.serialize = function (fn) {
|
|
|
3409
3351
|
};
|
|
3410
3352
|
|
|
3411
3353
|
RequestBase.prototype.timeout = function (options) {
|
|
3412
|
-
if (!options ||
|
|
3354
|
+
if (!options || typeof options !== 'object') {
|
|
3413
3355
|
this._timeout = options;
|
|
3414
3356
|
this._responseTimeout = 0;
|
|
3415
3357
|
this._uploadTimeout = 0;
|
|
3416
3358
|
return this;
|
|
3417
3359
|
}
|
|
3418
3360
|
|
|
3419
|
-
for (
|
|
3361
|
+
for (const option in options) {
|
|
3420
3362
|
if (hasOwn(options, option)) {
|
|
3421
3363
|
switch (option) {
|
|
3422
3364
|
case 'deadline':
|
|
@@ -3449,8 +3391,8 @@ RequestBase.prototype.retry = function (count, fn) {
|
|
|
3449
3391
|
return this;
|
|
3450
3392
|
};
|
|
3451
3393
|
|
|
3452
|
-
|
|
3453
|
-
|
|
3394
|
+
const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
3395
|
+
const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
3454
3396
|
|
|
3455
3397
|
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
3456
3398
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
@@ -3459,7 +3401,7 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
3459
3401
|
|
|
3460
3402
|
if (this._retryCallback) {
|
|
3461
3403
|
try {
|
|
3462
|
-
|
|
3404
|
+
const override = this._retryCallback(error, res);
|
|
3463
3405
|
|
|
3464
3406
|
if (override === true) return true;
|
|
3465
3407
|
if (override === false) return false;
|
|
@@ -3494,34 +3436,32 @@ RequestBase.prototype._retry = function () {
|
|
|
3494
3436
|
};
|
|
3495
3437
|
|
|
3496
3438
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
3497
|
-
var _this = this;
|
|
3498
|
-
|
|
3499
3439
|
if (!this._fullfilledPromise) {
|
|
3500
|
-
|
|
3440
|
+
const self = this;
|
|
3501
3441
|
|
|
3502
3442
|
if (this._endCalled) {
|
|
3503
3443
|
console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
|
|
3504
3444
|
}
|
|
3505
3445
|
|
|
3506
|
-
this._fullfilledPromise = new Promise(
|
|
3507
|
-
self.on('abort',
|
|
3508
|
-
if (
|
|
3446
|
+
this._fullfilledPromise = new Promise((resolve, reject) => {
|
|
3447
|
+
self.on('abort', () => {
|
|
3448
|
+
if (this._maxRetries && this._maxRetries > this._retries) {
|
|
3509
3449
|
return;
|
|
3510
3450
|
}
|
|
3511
3451
|
|
|
3512
|
-
if (
|
|
3513
|
-
reject(
|
|
3452
|
+
if (this.timedout && this.timedoutError) {
|
|
3453
|
+
reject(this.timedoutError);
|
|
3514
3454
|
return;
|
|
3515
3455
|
}
|
|
3516
3456
|
|
|
3517
|
-
|
|
3457
|
+
const error = new Error('Aborted');
|
|
3518
3458
|
error.code = 'ABORTED';
|
|
3519
|
-
error.status =
|
|
3520
|
-
error.method =
|
|
3521
|
-
error.url =
|
|
3459
|
+
error.status = this.status;
|
|
3460
|
+
error.method = this.method;
|
|
3461
|
+
error.url = this.url;
|
|
3522
3462
|
reject(error);
|
|
3523
3463
|
});
|
|
3524
|
-
self.end(
|
|
3464
|
+
self.end((error, res) => {
|
|
3525
3465
|
if (error) reject(error);else resolve(res);
|
|
3526
3466
|
});
|
|
3527
3467
|
});
|
|
@@ -3565,7 +3505,7 @@ RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
|
3565
3505
|
|
|
3566
3506
|
RequestBase.prototype.set = function (field, value) {
|
|
3567
3507
|
if (isObject(field)) {
|
|
3568
|
-
for (
|
|
3508
|
+
for (const key in field) {
|
|
3569
3509
|
if (hasOwn(field, key)) this.set(key, field[key]);
|
|
3570
3510
|
}
|
|
3571
3511
|
|
|
@@ -3593,7 +3533,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3593
3533
|
}
|
|
3594
3534
|
|
|
3595
3535
|
if (isObject(name)) {
|
|
3596
|
-
for (
|
|
3536
|
+
for (const key in name) {
|
|
3597
3537
|
if (hasOwn(name, key)) this.field(key, name[key]);
|
|
3598
3538
|
}
|
|
3599
3539
|
|
|
@@ -3601,7 +3541,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3601
3541
|
}
|
|
3602
3542
|
|
|
3603
3543
|
if (Array.isArray(value)) {
|
|
3604
|
-
for (
|
|
3544
|
+
for (const i in value) {
|
|
3605
3545
|
if (hasOwn(value, i)) this.field(name, value[i]);
|
|
3606
3546
|
}
|
|
3607
3547
|
|
|
@@ -3695,8 +3635,8 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3695
3635
|
};
|
|
3696
3636
|
|
|
3697
3637
|
RequestBase.prototype.send = function (data) {
|
|
3698
|
-
|
|
3699
|
-
|
|
3638
|
+
const isObject_ = isObject(data);
|
|
3639
|
+
let type = this._header['content-type'];
|
|
3700
3640
|
|
|
3701
3641
|
if (this._formData) {
|
|
3702
3642
|
throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
|
|
@@ -3713,7 +3653,7 @@ RequestBase.prototype.send = function (data) {
|
|
|
3713
3653
|
}
|
|
3714
3654
|
|
|
3715
3655
|
if (isObject_ && isObject(this._data)) {
|
|
3716
|
-
for (
|
|
3656
|
+
for (const key in data) {
|
|
3717
3657
|
if (hasOwn(data, key)) this._data[key] = data[key];
|
|
3718
3658
|
}
|
|
3719
3659
|
} else if (typeof data === 'string') {
|
|
@@ -3744,7 +3684,7 @@ RequestBase.prototype.sortQuery = function (sort) {
|
|
|
3744
3684
|
};
|
|
3745
3685
|
|
|
3746
3686
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3747
|
-
|
|
3687
|
+
const query = this._query.join('&');
|
|
3748
3688
|
|
|
3749
3689
|
if (query) {
|
|
3750
3690
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
@@ -3753,10 +3693,10 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3753
3693
|
this._query.length = 0;
|
|
3754
3694
|
|
|
3755
3695
|
if (this._sort) {
|
|
3756
|
-
|
|
3696
|
+
const index = this.url.indexOf('?');
|
|
3757
3697
|
|
|
3758
3698
|
if (index >= 0) {
|
|
3759
|
-
|
|
3699
|
+
const queryArray = this.url.slice(index + 1).split('&');
|
|
3760
3700
|
|
|
3761
3701
|
if (typeof this._sort === 'function') {
|
|
3762
3702
|
queryArray.sort(this._sort);
|
|
@@ -3769,7 +3709,7 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3769
3709
|
}
|
|
3770
3710
|
};
|
|
3771
3711
|
|
|
3772
|
-
RequestBase.prototype._appendQueryString =
|
|
3712
|
+
RequestBase.prototype._appendQueryString = () => {
|
|
3773
3713
|
console.warn('Unsupported');
|
|
3774
3714
|
};
|
|
3775
3715
|
|
|
@@ -3778,7 +3718,7 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3778
3718
|
return;
|
|
3779
3719
|
}
|
|
3780
3720
|
|
|
3781
|
-
|
|
3721
|
+
const error = new Error("".concat(reason + timeout, "ms exceeded"));
|
|
3782
3722
|
error.timeout = timeout;
|
|
3783
3723
|
error.code = 'ECONNABORTED';
|
|
3784
3724
|
error.errno = errno;
|
|
@@ -3789,16 +3729,16 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3789
3729
|
};
|
|
3790
3730
|
|
|
3791
3731
|
RequestBase.prototype._setTimeouts = function () {
|
|
3792
|
-
|
|
3732
|
+
const self = this;
|
|
3793
3733
|
|
|
3794
3734
|
if (this._timeout && !this._timer) {
|
|
3795
|
-
this._timer = setTimeout(
|
|
3735
|
+
this._timer = setTimeout(() => {
|
|
3796
3736
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
3797
3737
|
}, this._timeout);
|
|
3798
3738
|
}
|
|
3799
3739
|
|
|
3800
3740
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
3801
|
-
this._responseTimeoutTimer = setTimeout(
|
|
3741
|
+
this._responseTimeoutTimer = setTimeout(() => {
|
|
3802
3742
|
self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
|
|
3803
3743
|
}, this._responseTimeout);
|
|
3804
3744
|
}
|
|
@@ -3808,7 +3748,7 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3808
3748
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3809
3749
|
"use strict";
|
|
3810
3750
|
|
|
3811
|
-
|
|
3751
|
+
const utils = require('./utils');
|
|
3812
3752
|
|
|
3813
3753
|
module.exports = ResponseBase;
|
|
3814
3754
|
|
|
@@ -3819,11 +3759,11 @@ ResponseBase.prototype.get = function (field) {
|
|
|
3819
3759
|
};
|
|
3820
3760
|
|
|
3821
3761
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3822
|
-
|
|
3762
|
+
const ct = header['content-type'] || '';
|
|
3823
3763
|
this.type = utils.type(ct);
|
|
3824
|
-
|
|
3764
|
+
const parameters = utils.params(ct);
|
|
3825
3765
|
|
|
3826
|
-
for (
|
|
3766
|
+
for (const key in parameters) {
|
|
3827
3767
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3828
3768
|
}
|
|
3829
3769
|
|
|
@@ -3833,11 +3773,11 @@ ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
|
3833
3773
|
if (header.link) {
|
|
3834
3774
|
this.links = utils.parseLinks(header.link);
|
|
3835
3775
|
}
|
|
3836
|
-
} catch (
|
|
3776
|
+
} catch (err) {}
|
|
3837
3777
|
};
|
|
3838
3778
|
|
|
3839
3779
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3840
|
-
|
|
3780
|
+
const type = Math.trunc(status / 100);
|
|
3841
3781
|
this.statusCode = status;
|
|
3842
3782
|
this.status = this.statusCode;
|
|
3843
3783
|
this.statusType = type;
|
|
@@ -3861,67 +3801,35 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3861
3801
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3862
3802
|
"use strict";
|
|
3863
3803
|
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3867
|
-
|
|
3868
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3804
|
+
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3869
3805
|
|
|
3870
|
-
|
|
3806
|
+
exports.params = value => {
|
|
3807
|
+
const object = {};
|
|
3871
3808
|
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
var object = {};
|
|
3878
|
-
|
|
3879
|
-
var _iterator = _createForOfIteratorHelper(value.split(/ *; */)),
|
|
3880
|
-
_step;
|
|
3881
|
-
|
|
3882
|
-
try {
|
|
3883
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3884
|
-
var string_ = _step.value;
|
|
3885
|
-
var parts = string_.split(/ *= */);
|
|
3886
|
-
var key = parts.shift();
|
|
3887
|
-
|
|
3888
|
-
var _value = parts.shift();
|
|
3889
|
-
|
|
3890
|
-
if (key && _value) object[key] = _value;
|
|
3891
|
-
}
|
|
3892
|
-
} catch (err) {
|
|
3893
|
-
_iterator.e(err);
|
|
3894
|
-
} finally {
|
|
3895
|
-
_iterator.f();
|
|
3809
|
+
for (const string_ of value.split(/ *; */)) {
|
|
3810
|
+
const parts = string_.split(/ *= */);
|
|
3811
|
+
const key = parts.shift();
|
|
3812
|
+
const value = parts.shift();
|
|
3813
|
+
if (key && value) object[key] = value;
|
|
3896
3814
|
}
|
|
3897
3815
|
|
|
3898
3816
|
return object;
|
|
3899
3817
|
};
|
|
3900
3818
|
|
|
3901
|
-
exports.parseLinks =
|
|
3902
|
-
|
|
3819
|
+
exports.parseLinks = value => {
|
|
3820
|
+
const object = {};
|
|
3903
3821
|
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
var string_ = _step2.value;
|
|
3910
|
-
var parts = string_.split(/ *; */);
|
|
3911
|
-
var url = parts[0].slice(1, -1);
|
|
3912
|
-
var rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3913
|
-
object[rel] = url;
|
|
3914
|
-
}
|
|
3915
|
-
} catch (err) {
|
|
3916
|
-
_iterator2.e(err);
|
|
3917
|
-
} finally {
|
|
3918
|
-
_iterator2.f();
|
|
3822
|
+
for (const string_ of value.split(/ *, */)) {
|
|
3823
|
+
const parts = string_.split(/ *; */);
|
|
3824
|
+
const url = parts[0].slice(1, -1);
|
|
3825
|
+
const rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3826
|
+
object[rel] = url;
|
|
3919
3827
|
}
|
|
3920
3828
|
|
|
3921
3829
|
return object;
|
|
3922
3830
|
};
|
|
3923
3831
|
|
|
3924
|
-
exports.cleanHeader =
|
|
3832
|
+
exports.cleanHeader = (header, changesOrigin) => {
|
|
3925
3833
|
delete header['content-type'];
|
|
3926
3834
|
delete header['content-length'];
|
|
3927
3835
|
delete header['transfer-encoding'];
|
|
@@ -3935,8 +3843,8 @@ exports.cleanHeader = function (header, changesOrigin) {
|
|
|
3935
3843
|
return header;
|
|
3936
3844
|
};
|
|
3937
3845
|
|
|
3938
|
-
exports.isObject =
|
|
3939
|
-
return object !== null &&
|
|
3846
|
+
exports.isObject = object => {
|
|
3847
|
+
return object !== null && typeof object === 'object';
|
|
3940
3848
|
};
|
|
3941
3849
|
|
|
3942
3850
|
exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
@@ -3947,8 +3855,8 @@ exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
|
3947
3855
|
return Object.prototype.hasOwnProperty.call(new Object(object), property);
|
|
3948
3856
|
};
|
|
3949
3857
|
|
|
3950
|
-
exports.mixin =
|
|
3951
|
-
for (
|
|
3858
|
+
exports.mixin = (target, source) => {
|
|
3859
|
+
for (const key in source) {
|
|
3952
3860
|
if (exports.hasOwn(source, key)) {
|
|
3953
3861
|
target[key] = source[key];
|
|
3954
3862
|
}
|