superagent 7.1.6 → 8.0.1
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 -39
- package/dist/superagent.js +247 -352
- package/dist/superagent.min.js +1 -1
- package/lib/agent-base.js +8 -20
- package/lib/client.js +88 -101
- package/lib/node/agent.js +19 -23
- package/lib/node/http2wrapper.js +54 -67
- package/lib/node/index.js +176 -217
- 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 +38 -42
- package/lib/response-base.js +7 -7
- package/lib/utils.js +21 -27
- package/package.json +20 -22
- package/HISTORY.md +0 -692
package/dist/superagent.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
-
"use strict";
|
|
3
2
|
|
|
4
3
|
},{}],2:[function(require,module,exports){
|
|
5
4
|
'use strict';
|
|
@@ -73,8 +72,6 @@ if ($defineProperty) {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
},{"function-bind":7,"get-intrinsic":8}],4:[function(require,module,exports){
|
|
76
|
-
"use strict";
|
|
77
|
-
|
|
78
75
|
if (typeof module !== 'undefined') {
|
|
79
76
|
module.exports = Emitter;
|
|
80
77
|
}
|
|
@@ -174,10 +171,6 @@ Emitter.prototype.hasListeners = function (event) {
|
|
|
174
171
|
};
|
|
175
172
|
|
|
176
173
|
},{}],5:[function(require,module,exports){
|
|
177
|
-
"use strict";
|
|
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
174
|
module.exports = stringify;
|
|
182
175
|
stringify.default = stringify;
|
|
183
176
|
stringify.stable = deterministicStringify;
|
|
@@ -247,7 +240,7 @@ function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
247
240
|
depth += 1;
|
|
248
241
|
var i;
|
|
249
242
|
|
|
250
|
-
if (
|
|
243
|
+
if (typeof val === 'object' && val !== null) {
|
|
251
244
|
for (i = 0; i < stack.length; i++) {
|
|
252
245
|
if (stack[i] === val) {
|
|
253
246
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -331,7 +324,7 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
331
324
|
depth += 1;
|
|
332
325
|
var i;
|
|
333
326
|
|
|
334
|
-
if (
|
|
327
|
+
if (typeof val === 'object' && val !== null) {
|
|
335
328
|
for (i = 0; i < stack.length; i++) {
|
|
336
329
|
if (stack[i] === val) {
|
|
337
330
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -424,7 +417,7 @@ module.exports = function bind(that) {
|
|
|
424
417
|
var args = slice.call(arguments, 1);
|
|
425
418
|
var bound;
|
|
426
419
|
|
|
427
|
-
var binder = function
|
|
420
|
+
var binder = function () {
|
|
428
421
|
if (this instanceof bound) {
|
|
429
422
|
var result = target.apply(this, args.concat(slice.call(arguments)));
|
|
430
423
|
|
|
@@ -468,14 +461,12 @@ module.exports = Function.prototype.bind || implementation;
|
|
|
468
461
|
},{"./implementation":6}],8:[function(require,module,exports){
|
|
469
462
|
'use strict';
|
|
470
463
|
|
|
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
464
|
var undefined;
|
|
474
465
|
var $SyntaxError = SyntaxError;
|
|
475
466
|
var $Function = Function;
|
|
476
467
|
var $TypeError = TypeError;
|
|
477
468
|
|
|
478
|
-
var getEvalledConstructor = function
|
|
469
|
+
var getEvalledConstructor = function (expressionSyntax) {
|
|
479
470
|
try {
|
|
480
471
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
481
472
|
} catch (e) {}
|
|
@@ -491,7 +482,7 @@ if ($gOPD) {
|
|
|
491
482
|
}
|
|
492
483
|
}
|
|
493
484
|
|
|
494
|
-
var throwTypeError = function
|
|
485
|
+
var throwTypeError = function () {
|
|
495
486
|
throw new $TypeError();
|
|
496
487
|
};
|
|
497
488
|
|
|
@@ -549,7 +540,7 @@ var INTRINSICS = {
|
|
|
549
540
|
'%isFinite%': isFinite,
|
|
550
541
|
'%isNaN%': isNaN,
|
|
551
542
|
'%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
552
|
-
'%JSON%':
|
|
543
|
+
'%JSON%': typeof JSON === 'object' ? JSON : undefined,
|
|
553
544
|
'%Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
554
545
|
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
555
546
|
'%Math%': Math,
|
|
@@ -672,6 +663,7 @@ var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
|
672
663
|
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
673
664
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
674
665
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
666
|
+
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
675
667
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
676
668
|
var reEscapeChar = /\\(\\)?/g;
|
|
677
669
|
|
|
@@ -731,6 +723,10 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
731
723
|
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
732
724
|
}
|
|
733
725
|
|
|
726
|
+
if ($exec(/^%?[^%]*%?$/, name) === null) {
|
|
727
|
+
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
728
|
+
}
|
|
729
|
+
|
|
734
730
|
var parts = stringToPath(name);
|
|
735
731
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
736
732
|
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
@@ -797,8 +793,6 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
797
793
|
},{"function-bind":7,"has":11,"has-symbols":9}],9:[function(require,module,exports){
|
|
798
794
|
'use strict';
|
|
799
795
|
|
|
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
796
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
803
797
|
|
|
804
798
|
var hasSymbolSham = require('./shams');
|
|
@@ -812,11 +806,11 @@ module.exports = function hasNativeSymbols() {
|
|
|
812
806
|
return false;
|
|
813
807
|
}
|
|
814
808
|
|
|
815
|
-
if (
|
|
809
|
+
if (typeof origSymbol('foo') !== 'symbol') {
|
|
816
810
|
return false;
|
|
817
811
|
}
|
|
818
812
|
|
|
819
|
-
if (
|
|
813
|
+
if (typeof Symbol('bar') !== 'symbol') {
|
|
820
814
|
return false;
|
|
821
815
|
}
|
|
822
816
|
|
|
@@ -826,14 +820,12 @@ module.exports = function hasNativeSymbols() {
|
|
|
826
820
|
},{"./shams":10}],10:[function(require,module,exports){
|
|
827
821
|
'use strict';
|
|
828
822
|
|
|
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
823
|
module.exports = function hasSymbols() {
|
|
832
824
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
833
825
|
return false;
|
|
834
826
|
}
|
|
835
827
|
|
|
836
|
-
if (
|
|
828
|
+
if (typeof Symbol.iterator === 'symbol') {
|
|
837
829
|
return true;
|
|
838
830
|
}
|
|
839
831
|
|
|
@@ -897,10 +889,6 @@ var bind = require('function-bind');
|
|
|
897
889
|
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
898
890
|
|
|
899
891
|
},{"function-bind":7}],12:[function(require,module,exports){
|
|
900
|
-
"use strict";
|
|
901
|
-
|
|
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
892
|
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
905
893
|
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
906
894
|
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
@@ -930,9 +918,9 @@ var $arrSlice = Array.prototype.slice;
|
|
|
930
918
|
var $floor = Math.floor;
|
|
931
919
|
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
932
920
|
var gOPS = Object.getOwnPropertySymbols;
|
|
933
|
-
var symToString = typeof Symbol === 'function' &&
|
|
934
|
-
var hasShammedSymbols = typeof Symbol === 'function' &&
|
|
935
|
-
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (
|
|
921
|
+
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
|
|
922
|
+
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
|
|
923
|
+
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
|
|
936
924
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
937
925
|
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
|
|
938
926
|
return O.__proto__;
|
|
@@ -1026,7 +1014,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1026
1014
|
depth = 0;
|
|
1027
1015
|
}
|
|
1028
1016
|
|
|
1029
|
-
if (depth >= maxDepth && maxDepth > 0 &&
|
|
1017
|
+
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
1030
1018
|
return isArray(obj) ? '[Array]' : '[Object]';
|
|
1031
1019
|
}
|
|
1032
1020
|
|
|
@@ -1067,7 +1055,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1067
1055
|
|
|
1068
1056
|
if (isSymbol(obj)) {
|
|
1069
1057
|
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
1070
|
-
return
|
|
1058
|
+
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
1071
1059
|
}
|
|
1072
1060
|
|
|
1073
1061
|
if (isElement(obj)) {
|
|
@@ -1116,7 +1104,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1116
1104
|
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
1117
1105
|
}
|
|
1118
1106
|
|
|
1119
|
-
if (
|
|
1107
|
+
if (typeof obj === 'object' && customInspect) {
|
|
1120
1108
|
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
|
|
1121
1109
|
return utilInspect(obj, {
|
|
1122
1110
|
depth: maxDepth - depth
|
|
@@ -1202,43 +1190,43 @@ function quote(s) {
|
|
|
1202
1190
|
}
|
|
1203
1191
|
|
|
1204
1192
|
function isArray(obj) {
|
|
1205
|
-
return toStr(obj) === '[object Array]' && (!toStringTag || !(
|
|
1193
|
+
return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1206
1194
|
}
|
|
1207
1195
|
|
|
1208
1196
|
function isDate(obj) {
|
|
1209
|
-
return toStr(obj) === '[object Date]' && (!toStringTag || !(
|
|
1197
|
+
return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1210
1198
|
}
|
|
1211
1199
|
|
|
1212
1200
|
function isRegExp(obj) {
|
|
1213
|
-
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(
|
|
1201
|
+
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1214
1202
|
}
|
|
1215
1203
|
|
|
1216
1204
|
function isError(obj) {
|
|
1217
|
-
return toStr(obj) === '[object Error]' && (!toStringTag || !(
|
|
1205
|
+
return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1218
1206
|
}
|
|
1219
1207
|
|
|
1220
1208
|
function isString(obj) {
|
|
1221
|
-
return toStr(obj) === '[object String]' && (!toStringTag || !(
|
|
1209
|
+
return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1222
1210
|
}
|
|
1223
1211
|
|
|
1224
1212
|
function isNumber(obj) {
|
|
1225
|
-
return toStr(obj) === '[object Number]' && (!toStringTag || !(
|
|
1213
|
+
return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1226
1214
|
}
|
|
1227
1215
|
|
|
1228
1216
|
function isBoolean(obj) {
|
|
1229
|
-
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(
|
|
1217
|
+
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1230
1218
|
}
|
|
1231
1219
|
|
|
1232
1220
|
function isSymbol(obj) {
|
|
1233
1221
|
if (hasShammedSymbols) {
|
|
1234
|
-
return obj &&
|
|
1222
|
+
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
1235
1223
|
}
|
|
1236
1224
|
|
|
1237
|
-
if (
|
|
1225
|
+
if (typeof obj === 'symbol') {
|
|
1238
1226
|
return true;
|
|
1239
1227
|
}
|
|
1240
1228
|
|
|
1241
|
-
if (!obj ||
|
|
1229
|
+
if (!obj || typeof obj !== 'object' || !symToString) {
|
|
1242
1230
|
return false;
|
|
1243
1231
|
}
|
|
1244
1232
|
|
|
@@ -1251,7 +1239,7 @@ function isSymbol(obj) {
|
|
|
1251
1239
|
}
|
|
1252
1240
|
|
|
1253
1241
|
function isBigInt(obj) {
|
|
1254
|
-
if (!obj ||
|
|
1242
|
+
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
|
|
1255
1243
|
return false;
|
|
1256
1244
|
}
|
|
1257
1245
|
|
|
@@ -1304,7 +1292,7 @@ function indexOf(xs, x) {
|
|
|
1304
1292
|
}
|
|
1305
1293
|
|
|
1306
1294
|
function isMap(x) {
|
|
1307
|
-
if (!mapSize || !x ||
|
|
1295
|
+
if (!mapSize || !x || typeof x !== 'object') {
|
|
1308
1296
|
return false;
|
|
1309
1297
|
}
|
|
1310
1298
|
|
|
@@ -1324,7 +1312,7 @@ function isMap(x) {
|
|
|
1324
1312
|
}
|
|
1325
1313
|
|
|
1326
1314
|
function isWeakMap(x) {
|
|
1327
|
-
if (!weakMapHas || !x ||
|
|
1315
|
+
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
1328
1316
|
return false;
|
|
1329
1317
|
}
|
|
1330
1318
|
|
|
@@ -1344,7 +1332,7 @@ function isWeakMap(x) {
|
|
|
1344
1332
|
}
|
|
1345
1333
|
|
|
1346
1334
|
function isWeakRef(x) {
|
|
1347
|
-
if (!weakRefDeref || !x ||
|
|
1335
|
+
if (!weakRefDeref || !x || typeof x !== 'object') {
|
|
1348
1336
|
return false;
|
|
1349
1337
|
}
|
|
1350
1338
|
|
|
@@ -1357,7 +1345,7 @@ function isWeakRef(x) {
|
|
|
1357
1345
|
}
|
|
1358
1346
|
|
|
1359
1347
|
function isSet(x) {
|
|
1360
|
-
if (!setSize || !x ||
|
|
1348
|
+
if (!setSize || !x || typeof x !== 'object') {
|
|
1361
1349
|
return false;
|
|
1362
1350
|
}
|
|
1363
1351
|
|
|
@@ -1377,7 +1365,7 @@ function isSet(x) {
|
|
|
1377
1365
|
}
|
|
1378
1366
|
|
|
1379
1367
|
function isWeakSet(x) {
|
|
1380
|
-
if (!weakSetHas || !x ||
|
|
1368
|
+
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
1381
1369
|
return false;
|
|
1382
1370
|
}
|
|
1383
1371
|
|
|
@@ -1397,7 +1385,7 @@ function isWeakSet(x) {
|
|
|
1397
1385
|
}
|
|
1398
1386
|
|
|
1399
1387
|
function isElement(x) {
|
|
1400
|
-
if (!x ||
|
|
1388
|
+
if (!x || typeof x !== 'object') {
|
|
1401
1389
|
return false;
|
|
1402
1390
|
}
|
|
1403
1391
|
|
|
@@ -1538,8 +1526,6 @@ function arrObjKeys(obj, inspect) {
|
|
|
1538
1526
|
}
|
|
1539
1527
|
|
|
1540
1528
|
},{"./util.inspect":1}],13:[function(require,module,exports){
|
|
1541
|
-
"use strict";
|
|
1542
|
-
|
|
1543
1529
|
var process = module.exports = {};
|
|
1544
1530
|
var cachedSetTimeout;
|
|
1545
1531
|
var cachedClearTimeout;
|
|
@@ -1743,10 +1729,10 @@ var Format = {
|
|
|
1743
1729
|
module.exports = {
|
|
1744
1730
|
'default': Format.RFC3986,
|
|
1745
1731
|
formatters: {
|
|
1746
|
-
RFC1738: function
|
|
1732
|
+
RFC1738: function (value) {
|
|
1747
1733
|
return replace.call(value, percentTwenties, '+');
|
|
1748
1734
|
},
|
|
1749
|
-
RFC3986: function
|
|
1735
|
+
RFC3986: function (value) {
|
|
1750
1736
|
return String(value);
|
|
1751
1737
|
}
|
|
1752
1738
|
},
|
|
@@ -1795,13 +1781,13 @@ var defaults = {
|
|
|
1795
1781
|
strictNullHandling: false
|
|
1796
1782
|
};
|
|
1797
1783
|
|
|
1798
|
-
var interpretNumericEntities = function
|
|
1784
|
+
var interpretNumericEntities = function (str) {
|
|
1799
1785
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
1800
1786
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
1801
1787
|
});
|
|
1802
1788
|
};
|
|
1803
1789
|
|
|
1804
|
-
var parseArrayValue = function
|
|
1790
|
+
var parseArrayValue = function (val, options) {
|
|
1805
1791
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
1806
1792
|
return val.split(',');
|
|
1807
1793
|
}
|
|
@@ -1874,7 +1860,7 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1874
1860
|
return obj;
|
|
1875
1861
|
};
|
|
1876
1862
|
|
|
1877
|
-
var parseObject = function
|
|
1863
|
+
var parseObject = function (chain, val, options, valuesParsed) {
|
|
1878
1864
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
1879
1865
|
|
|
1880
1866
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
@@ -2010,8 +1996,6 @@ module.exports = function (str, opts) {
|
|
|
2010
1996
|
},{"./utils":18}],17:[function(require,module,exports){
|
|
2011
1997
|
'use strict';
|
|
2012
1998
|
|
|
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
1999
|
var getSideChannel = require('side-channel');
|
|
2016
2000
|
|
|
2017
2001
|
var utils = require('./utils');
|
|
@@ -2035,7 +2019,7 @@ var isArray = Array.isArray;
|
|
|
2035
2019
|
var split = String.prototype.split;
|
|
2036
2020
|
var push = Array.prototype.push;
|
|
2037
2021
|
|
|
2038
|
-
var pushToArray = function
|
|
2022
|
+
var pushToArray = function (arr, valueOrArray) {
|
|
2039
2023
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2040
2024
|
};
|
|
2041
2025
|
|
|
@@ -2061,12 +2045,12 @@ var defaults = {
|
|
|
2061
2045
|
};
|
|
2062
2046
|
|
|
2063
2047
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
2064
|
-
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' ||
|
|
2048
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
|
|
2065
2049
|
};
|
|
2066
2050
|
|
|
2067
2051
|
var sentinel = {};
|
|
2068
2052
|
|
|
2069
|
-
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
2053
|
+
var stringify = function stringify(object, prefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
2070
2054
|
var obj = object;
|
|
2071
2055
|
var tmpSc = sideChannel;
|
|
2072
2056
|
var step = 0;
|
|
@@ -2123,7 +2107,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2123
2107
|
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
|
|
2124
2108
|
}
|
|
2125
2109
|
|
|
2126
|
-
return [formatter(keyValue) + '=' + valuesJoined];
|
|
2110
|
+
return [formatter(keyValue) + (commaRoundTrip && isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
|
|
2127
2111
|
}
|
|
2128
2112
|
|
|
2129
2113
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
@@ -2151,19 +2135,21 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2151
2135
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
2152
2136
|
}
|
|
2153
2137
|
|
|
2138
|
+
var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
2139
|
+
|
|
2154
2140
|
for (var j = 0; j < objKeys.length; ++j) {
|
|
2155
2141
|
var key = objKeys[j];
|
|
2156
|
-
var value =
|
|
2142
|
+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
2157
2143
|
|
|
2158
2144
|
if (skipNulls && value === null) {
|
|
2159
2145
|
continue;
|
|
2160
2146
|
}
|
|
2161
2147
|
|
|
2162
|
-
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(
|
|
2148
|
+
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
2163
2149
|
sideChannel.set(object, step);
|
|
2164
2150
|
var valueSideChannel = getSideChannel();
|
|
2165
2151
|
valueSideChannel.set(sentinel, sideChannel);
|
|
2166
|
-
pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
2152
|
+
pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
2167
2153
|
}
|
|
2168
2154
|
|
|
2169
2155
|
return values;
|
|
@@ -2236,7 +2222,7 @@ module.exports = function (object, opts) {
|
|
|
2236
2222
|
|
|
2237
2223
|
var keys = [];
|
|
2238
2224
|
|
|
2239
|
-
if (
|
|
2225
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
2240
2226
|
return '';
|
|
2241
2227
|
}
|
|
2242
2228
|
|
|
@@ -2252,6 +2238,12 @@ module.exports = function (object, opts) {
|
|
|
2252
2238
|
|
|
2253
2239
|
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
2254
2240
|
|
|
2241
|
+
if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
|
|
2242
|
+
throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
|
|
2246
|
+
|
|
2255
2247
|
if (!objKeys) {
|
|
2256
2248
|
objKeys = Object.keys(obj);
|
|
2257
2249
|
}
|
|
@@ -2269,7 +2261,7 @@ module.exports = function (object, opts) {
|
|
|
2269
2261
|
continue;
|
|
2270
2262
|
}
|
|
2271
2263
|
|
|
2272
|
-
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
|
|
2264
|
+
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, commaRoundTrip, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
|
|
2273
2265
|
}
|
|
2274
2266
|
|
|
2275
2267
|
var joined = keys.join(options.delimiter);
|
|
@@ -2289,8 +2281,6 @@ module.exports = function (object, opts) {
|
|
|
2289
2281
|
},{"./formats":14,"./utils":18,"side-channel":19}],18:[function(require,module,exports){
|
|
2290
2282
|
'use strict';
|
|
2291
2283
|
|
|
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
2284
|
var formats = require('./formats');
|
|
2295
2285
|
|
|
2296
2286
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -2342,10 +2332,10 @@ var merge = function merge(target, source, options) {
|
|
|
2342
2332
|
return target;
|
|
2343
2333
|
}
|
|
2344
2334
|
|
|
2345
|
-
if (
|
|
2335
|
+
if (typeof source !== 'object') {
|
|
2346
2336
|
if (isArray(target)) {
|
|
2347
2337
|
target.push(source);
|
|
2348
|
-
} else if (target &&
|
|
2338
|
+
} else if (target && typeof target === 'object') {
|
|
2349
2339
|
if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
|
|
2350
2340
|
target[source] = true;
|
|
2351
2341
|
}
|
|
@@ -2356,7 +2346,7 @@ var merge = function merge(target, source, options) {
|
|
|
2356
2346
|
return target;
|
|
2357
2347
|
}
|
|
2358
2348
|
|
|
2359
|
-
if (!target ||
|
|
2349
|
+
if (!target || typeof target !== 'object') {
|
|
2360
2350
|
return [target].concat(source);
|
|
2361
2351
|
}
|
|
2362
2352
|
|
|
@@ -2371,7 +2361,7 @@ var merge = function merge(target, source, options) {
|
|
|
2371
2361
|
if (has.call(target, i)) {
|
|
2372
2362
|
var targetItem = target[i];
|
|
2373
2363
|
|
|
2374
|
-
if (targetItem &&
|
|
2364
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
2375
2365
|
target[i] = merge(targetItem, item, options);
|
|
2376
2366
|
} else {
|
|
2377
2367
|
target.push(item);
|
|
@@ -2403,7 +2393,7 @@ var assign = function assignSingleSource(target, source) {
|
|
|
2403
2393
|
}, target);
|
|
2404
2394
|
};
|
|
2405
2395
|
|
|
2406
|
-
var decode = function
|
|
2396
|
+
var decode = function (str, decoder, charset) {
|
|
2407
2397
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
2408
2398
|
|
|
2409
2399
|
if (charset === 'iso-8859-1') {
|
|
@@ -2424,7 +2414,7 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
|
2424
2414
|
|
|
2425
2415
|
var string = str;
|
|
2426
2416
|
|
|
2427
|
-
if (
|
|
2417
|
+
if (typeof str === 'symbol') {
|
|
2428
2418
|
string = Symbol.prototype.toString.call(str);
|
|
2429
2419
|
} else if (typeof str !== 'string') {
|
|
2430
2420
|
string = String(str);
|
|
@@ -2487,7 +2477,7 @@ var compact = function compact(value) {
|
|
|
2487
2477
|
var key = keys[j];
|
|
2488
2478
|
var val = obj[key];
|
|
2489
2479
|
|
|
2490
|
-
if (
|
|
2480
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
2491
2481
|
queue.push({
|
|
2492
2482
|
obj: obj,
|
|
2493
2483
|
prop: key
|
|
@@ -2506,7 +2496,7 @@ var isRegExp = function isRegExp(obj) {
|
|
|
2506
2496
|
};
|
|
2507
2497
|
|
|
2508
2498
|
var isBuffer = function isBuffer(obj) {
|
|
2509
|
-
if (!obj ||
|
|
2499
|
+
if (!obj || typeof obj !== 'object') {
|
|
2510
2500
|
return false;
|
|
2511
2501
|
}
|
|
2512
2502
|
|
|
@@ -2547,8 +2537,6 @@ module.exports = {
|
|
|
2547
2537
|
},{"./formats":14}],19:[function(require,module,exports){
|
|
2548
2538
|
'use strict';
|
|
2549
2539
|
|
|
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
2540
|
var GetIntrinsic = require('get-intrinsic');
|
|
2553
2541
|
|
|
2554
2542
|
var callBound = require('call-bind/callBound');
|
|
@@ -2565,7 +2553,7 @@ var $mapGet = callBound('Map.prototype.get', true);
|
|
|
2565
2553
|
var $mapSet = callBound('Map.prototype.set', true);
|
|
2566
2554
|
var $mapHas = callBound('Map.prototype.has', true);
|
|
2567
2555
|
|
|
2568
|
-
var listGetNode = function
|
|
2556
|
+
var listGetNode = function (list, key) {
|
|
2569
2557
|
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
2570
2558
|
if (curr.key === key) {
|
|
2571
2559
|
prev.next = curr.next;
|
|
@@ -2576,12 +2564,12 @@ var listGetNode = function listGetNode(list, key) {
|
|
|
2576
2564
|
}
|
|
2577
2565
|
};
|
|
2578
2566
|
|
|
2579
|
-
var listGet = function
|
|
2567
|
+
var listGet = function (objects, key) {
|
|
2580
2568
|
var node = listGetNode(objects, key);
|
|
2581
2569
|
return node && node.value;
|
|
2582
2570
|
};
|
|
2583
2571
|
|
|
2584
|
-
var listSet = function
|
|
2572
|
+
var listSet = function (objects, key, value) {
|
|
2585
2573
|
var node = listGetNode(objects, key);
|
|
2586
2574
|
|
|
2587
2575
|
if (node) {
|
|
@@ -2595,7 +2583,7 @@ var listSet = function listSet(objects, key, value) {
|
|
|
2595
2583
|
}
|
|
2596
2584
|
};
|
|
2597
2585
|
|
|
2598
|
-
var listHas = function
|
|
2586
|
+
var listHas = function (objects, key) {
|
|
2599
2587
|
return !!listGetNode(objects, key);
|
|
2600
2588
|
};
|
|
2601
2589
|
|
|
@@ -2604,13 +2592,13 @@ module.exports = function getSideChannel() {
|
|
|
2604
2592
|
var $m;
|
|
2605
2593
|
var $o;
|
|
2606
2594
|
var channel = {
|
|
2607
|
-
assert: function
|
|
2595
|
+
assert: function (key) {
|
|
2608
2596
|
if (!channel.has(key)) {
|
|
2609
2597
|
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
2610
2598
|
}
|
|
2611
2599
|
},
|
|
2612
|
-
get: function
|
|
2613
|
-
if ($WeakMap && key && (
|
|
2600
|
+
get: function (key) {
|
|
2601
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2614
2602
|
if ($wm) {
|
|
2615
2603
|
return $weakMapGet($wm, key);
|
|
2616
2604
|
}
|
|
@@ -2624,8 +2612,8 @@ module.exports = function getSideChannel() {
|
|
|
2624
2612
|
}
|
|
2625
2613
|
}
|
|
2626
2614
|
},
|
|
2627
|
-
has: function
|
|
2628
|
-
if ($WeakMap && key && (
|
|
2615
|
+
has: function (key) {
|
|
2616
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2629
2617
|
if ($wm) {
|
|
2630
2618
|
return $weakMapHas($wm, key);
|
|
2631
2619
|
}
|
|
@@ -2641,8 +2629,8 @@ module.exports = function getSideChannel() {
|
|
|
2641
2629
|
|
|
2642
2630
|
return false;
|
|
2643
2631
|
},
|
|
2644
|
-
set: function
|
|
2645
|
-
if ($WeakMap && key && (
|
|
2632
|
+
set: function (key, value) {
|
|
2633
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2646
2634
|
if (!$wm) {
|
|
2647
2635
|
$wm = new $WeakMap();
|
|
2648
2636
|
}
|
|
@@ -2670,103 +2658,62 @@ module.exports = function getSideChannel() {
|
|
|
2670
2658
|
};
|
|
2671
2659
|
|
|
2672
2660
|
},{"call-bind/callBound":2,"get-intrinsic":8,"object-inspect":12}],20:[function(require,module,exports){
|
|
2673
|
-
"use strict";
|
|
2674
|
-
|
|
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
2661
|
function Agent() {
|
|
2690
2662
|
this._defaults = [];
|
|
2691
2663
|
}
|
|
2692
2664
|
|
|
2693
|
-
|
|
2694
|
-
var fn = _arr[_i];
|
|
2695
|
-
|
|
2665
|
+
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
2666
|
Agent.prototype[fn] = function () {
|
|
2697
2667
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2698
2668
|
args[_key] = arguments[_key];
|
|
2699
2669
|
}
|
|
2700
2670
|
|
|
2701
2671
|
this._defaults.push({
|
|
2702
|
-
fn
|
|
2703
|
-
args
|
|
2672
|
+
fn,
|
|
2673
|
+
args
|
|
2704
2674
|
});
|
|
2705
2675
|
|
|
2706
2676
|
return this;
|
|
2707
2677
|
};
|
|
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
2678
|
}
|
|
2713
2679
|
|
|
2714
2680
|
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();
|
|
2681
|
+
for (const def of this._defaults) {
|
|
2682
|
+
request[def.fn](...def.args);
|
|
2727
2683
|
}
|
|
2728
2684
|
};
|
|
2729
2685
|
|
|
2730
2686
|
module.exports = Agent;
|
|
2731
2687
|
|
|
2732
2688
|
},{}],21:[function(require,module,exports){
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
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); }
|
|
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;
|
|
2689
|
+
let root;
|
|
2744
2690
|
|
|
2745
2691
|
if (typeof window !== 'undefined') {
|
|
2746
2692
|
root = window;
|
|
2747
2693
|
} else if (typeof self === 'undefined') {
|
|
2748
2694
|
console.warn('Using browser-only version of superagent in non-browser environment');
|
|
2749
|
-
root =
|
|
2695
|
+
root = this;
|
|
2750
2696
|
} else {
|
|
2751
2697
|
root = self;
|
|
2752
2698
|
}
|
|
2753
2699
|
|
|
2754
|
-
|
|
2700
|
+
const Emitter = require('component-emitter');
|
|
2755
2701
|
|
|
2756
|
-
|
|
2702
|
+
const safeStringify = require('fast-safe-stringify');
|
|
2757
2703
|
|
|
2758
|
-
|
|
2704
|
+
const qs = require('qs');
|
|
2759
2705
|
|
|
2760
|
-
|
|
2706
|
+
const RequestBase = require('./request-base');
|
|
2761
2707
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2708
|
+
const {
|
|
2709
|
+
isObject,
|
|
2710
|
+
mixin,
|
|
2711
|
+
hasOwn
|
|
2712
|
+
} = require('./utils');
|
|
2766
2713
|
|
|
2767
|
-
|
|
2714
|
+
const ResponseBase = require('./response-base');
|
|
2768
2715
|
|
|
2769
|
-
|
|
2716
|
+
const Agent = require('./agent-base');
|
|
2770
2717
|
|
|
2771
2718
|
function noop() {}
|
|
2772
2719
|
|
|
@@ -2783,28 +2730,24 @@ module.exports = function (method, url) {
|
|
|
2783
2730
|
};
|
|
2784
2731
|
|
|
2785
2732
|
exports = module.exports;
|
|
2786
|
-
|
|
2733
|
+
const request = exports;
|
|
2787
2734
|
exports.Request = Request;
|
|
2788
2735
|
|
|
2789
|
-
request.getXHR =
|
|
2790
|
-
if (root.XMLHttpRequest
|
|
2791
|
-
return new XMLHttpRequest();
|
|
2736
|
+
request.getXHR = () => {
|
|
2737
|
+
if (root.XMLHttpRequest) {
|
|
2738
|
+
return new root.XMLHttpRequest();
|
|
2792
2739
|
}
|
|
2793
2740
|
|
|
2794
2741
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
2795
2742
|
};
|
|
2796
2743
|
|
|
2797
|
-
|
|
2798
|
-
return s.trim();
|
|
2799
|
-
} : function (s) {
|
|
2800
|
-
return s.replace(/(^\s*|\s*$)/g, '');
|
|
2801
|
-
};
|
|
2744
|
+
const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
|
|
2802
2745
|
|
|
2803
2746
|
function serialize(object) {
|
|
2804
2747
|
if (!isObject(object)) return object;
|
|
2805
|
-
|
|
2748
|
+
const pairs = [];
|
|
2806
2749
|
|
|
2807
|
-
for (
|
|
2750
|
+
for (const key in object) {
|
|
2808
2751
|
if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
|
|
2809
2752
|
}
|
|
2810
2753
|
|
|
@@ -2820,22 +2763,12 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2820
2763
|
}
|
|
2821
2764
|
|
|
2822
2765
|
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();
|
|
2766
|
+
for (const v of value) {
|
|
2767
|
+
pushEncodedKeyValuePair(pairs, key, v);
|
|
2835
2768
|
}
|
|
2836
2769
|
} else if (isObject(value)) {
|
|
2837
|
-
for (
|
|
2838
|
-
if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs,
|
|
2770
|
+
for (const subkey in value) {
|
|
2771
|
+
if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs, `${key}[${subkey}]`, value[subkey]);
|
|
2839
2772
|
}
|
|
2840
2773
|
} else {
|
|
2841
2774
|
pairs.push(encodeURI(key) + '=' + encodeURIComponent(value));
|
|
@@ -2845,12 +2778,12 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2845
2778
|
request.serializeObject = serialize;
|
|
2846
2779
|
|
|
2847
2780
|
function parseString(string_) {
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2781
|
+
const object = {};
|
|
2782
|
+
const pairs = string_.split('&');
|
|
2783
|
+
let pair;
|
|
2784
|
+
let pos;
|
|
2852
2785
|
|
|
2853
|
-
for (
|
|
2786
|
+
for (let i = 0, length_ = pairs.length; i < length_; ++i) {
|
|
2854
2787
|
pair = pairs[i];
|
|
2855
2788
|
pos = pair.indexOf('=');
|
|
2856
2789
|
|
|
@@ -2883,14 +2816,14 @@ request.parse = {
|
|
|
2883
2816
|
};
|
|
2884
2817
|
|
|
2885
2818
|
function parseHeader(string_) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
for (
|
|
2819
|
+
const lines = string_.split(/\r?\n/);
|
|
2820
|
+
const fields = {};
|
|
2821
|
+
let index;
|
|
2822
|
+
let line;
|
|
2823
|
+
let field;
|
|
2824
|
+
let value;
|
|
2825
|
+
|
|
2826
|
+
for (let i = 0, length_ = lines.length; i < length_; ++i) {
|
|
2894
2827
|
line = lines[i];
|
|
2895
2828
|
index = line.indexOf(':');
|
|
2896
2829
|
|
|
@@ -2915,7 +2848,9 @@ function Response(request_) {
|
|
|
2915
2848
|
this.xhr = this.req.xhr;
|
|
2916
2849
|
this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
|
|
2917
2850
|
this.statusText = this.req.xhr.statusText;
|
|
2918
|
-
|
|
2851
|
+
let {
|
|
2852
|
+
status
|
|
2853
|
+
} = this.xhr;
|
|
2919
2854
|
|
|
2920
2855
|
if (status === 1223) {
|
|
2921
2856
|
status = 204;
|
|
@@ -2939,7 +2874,7 @@ function Response(request_) {
|
|
|
2939
2874
|
mixin(Response.prototype, ResponseBase.prototype);
|
|
2940
2875
|
|
|
2941
2876
|
Response.prototype._parseBody = function (string_) {
|
|
2942
|
-
|
|
2877
|
+
let parse = request.parse[this.type];
|
|
2943
2878
|
|
|
2944
2879
|
if (this.req._parser) {
|
|
2945
2880
|
return this.req._parser(this, string_);
|
|
@@ -2953,11 +2888,17 @@ Response.prototype._parseBody = function (string_) {
|
|
|
2953
2888
|
};
|
|
2954
2889
|
|
|
2955
2890
|
Response.prototype.toError = function () {
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2891
|
+
const {
|
|
2892
|
+
req
|
|
2893
|
+
} = this;
|
|
2894
|
+
const {
|
|
2895
|
+
method
|
|
2896
|
+
} = req;
|
|
2897
|
+
const {
|
|
2898
|
+
url
|
|
2899
|
+
} = req;
|
|
2900
|
+
const message = `cannot ${method} ${url} (${this.status})`;
|
|
2901
|
+
const error = new Error(message);
|
|
2961
2902
|
error.status = this.status;
|
|
2962
2903
|
error.method = method;
|
|
2963
2904
|
error.url = url;
|
|
@@ -2967,15 +2908,15 @@ Response.prototype.toError = function () {
|
|
|
2967
2908
|
request.Response = Response;
|
|
2968
2909
|
|
|
2969
2910
|
function Request(method, url) {
|
|
2970
|
-
|
|
2911
|
+
const self = this;
|
|
2971
2912
|
this._query = this._query || [];
|
|
2972
2913
|
this.method = method;
|
|
2973
2914
|
this.url = url;
|
|
2974
2915
|
this.header = {};
|
|
2975
2916
|
this._header = {};
|
|
2976
|
-
this.on('end',
|
|
2977
|
-
|
|
2978
|
-
|
|
2917
|
+
this.on('end', () => {
|
|
2918
|
+
let error = null;
|
|
2919
|
+
let res = null;
|
|
2979
2920
|
|
|
2980
2921
|
try {
|
|
2981
2922
|
res = new Response(self);
|
|
@@ -2997,7 +2938,7 @@ function Request(method, url) {
|
|
|
2997
2938
|
}
|
|
2998
2939
|
|
|
2999
2940
|
self.emit('response', res);
|
|
3000
|
-
|
|
2941
|
+
let new_error;
|
|
3001
2942
|
|
|
3002
2943
|
try {
|
|
3003
2944
|
if (!self._isResponseOK(res)) {
|
|
@@ -3034,7 +2975,7 @@ Request.prototype.accept = function (type) {
|
|
|
3034
2975
|
Request.prototype.auth = function (user, pass, options) {
|
|
3035
2976
|
if (arguments.length === 1) pass = '';
|
|
3036
2977
|
|
|
3037
|
-
if (
|
|
2978
|
+
if (typeof pass === 'object' && pass !== null) {
|
|
3038
2979
|
options = pass;
|
|
3039
2980
|
pass = '';
|
|
3040
2981
|
}
|
|
@@ -3045,7 +2986,7 @@ Request.prototype.auth = function (user, pass, options) {
|
|
|
3045
2986
|
};
|
|
3046
2987
|
}
|
|
3047
2988
|
|
|
3048
|
-
|
|
2989
|
+
const encoder = options.encoder ? options.encoder : string => {
|
|
3049
2990
|
if (typeof btoa === 'function') {
|
|
3050
2991
|
return btoa(string);
|
|
3051
2992
|
}
|
|
@@ -3086,7 +3027,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3086
3027
|
return this._retry();
|
|
3087
3028
|
}
|
|
3088
3029
|
|
|
3089
|
-
|
|
3030
|
+
const fn = this._callback;
|
|
3090
3031
|
this.clearTimeout();
|
|
3091
3032
|
|
|
3092
3033
|
if (error) {
|
|
@@ -3098,7 +3039,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3098
3039
|
};
|
|
3099
3040
|
|
|
3100
3041
|
Request.prototype.crossDomainError = function () {
|
|
3101
|
-
|
|
3042
|
+
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
3043
|
error.crossDomain = true;
|
|
3103
3044
|
error.status = this.status;
|
|
3104
3045
|
error.method = this.method;
|
|
@@ -3114,14 +3055,14 @@ Request.prototype.agent = function () {
|
|
|
3114
3055
|
Request.prototype.ca = Request.prototype.agent;
|
|
3115
3056
|
Request.prototype.buffer = Request.prototype.ca;
|
|
3116
3057
|
|
|
3117
|
-
Request.prototype.write =
|
|
3058
|
+
Request.prototype.write = () => {
|
|
3118
3059
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
3119
3060
|
};
|
|
3120
3061
|
|
|
3121
3062
|
Request.prototype.pipe = Request.prototype.write;
|
|
3122
3063
|
|
|
3123
3064
|
Request.prototype._isHost = function (object) {
|
|
3124
|
-
return object &&
|
|
3065
|
+
return object && typeof object === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
|
|
3125
3066
|
};
|
|
3126
3067
|
|
|
3127
3068
|
Request.prototype.end = function (fn) {
|
|
@@ -3138,10 +3079,10 @@ Request.prototype.end = function (fn) {
|
|
|
3138
3079
|
};
|
|
3139
3080
|
|
|
3140
3081
|
Request.prototype._setUploadTimeout = function () {
|
|
3141
|
-
|
|
3082
|
+
const self = this;
|
|
3142
3083
|
|
|
3143
3084
|
if (this._uploadTimeout && !this._uploadTimeoutTimer) {
|
|
3144
|
-
this._uploadTimeoutTimer = setTimeout(
|
|
3085
|
+
this._uploadTimeoutTimer = setTimeout(() => {
|
|
3145
3086
|
self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
|
|
3146
3087
|
}, this._uploadTimeout);
|
|
3147
3088
|
}
|
|
@@ -3149,15 +3090,19 @@ Request.prototype._setUploadTimeout = function () {
|
|
|
3149
3090
|
|
|
3150
3091
|
Request.prototype._end = function () {
|
|
3151
3092
|
if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
|
|
3152
|
-
|
|
3093
|
+
const self = this;
|
|
3153
3094
|
this.xhr = request.getXHR();
|
|
3154
|
-
|
|
3155
|
-
|
|
3095
|
+
const {
|
|
3096
|
+
xhr
|
|
3097
|
+
} = this;
|
|
3098
|
+
let data = this._formData || this._data;
|
|
3156
3099
|
|
|
3157
3100
|
this._setTimeouts();
|
|
3158
3101
|
|
|
3159
|
-
xhr.addEventListener('readystatechange',
|
|
3160
|
-
|
|
3102
|
+
xhr.addEventListener('readystatechange', () => {
|
|
3103
|
+
const {
|
|
3104
|
+
readyState
|
|
3105
|
+
} = xhr;
|
|
3161
3106
|
|
|
3162
3107
|
if (readyState >= 2 && self._responseTimeoutTimer) {
|
|
3163
3108
|
clearTimeout(self._responseTimeoutTimer);
|
|
@@ -3167,11 +3112,11 @@ Request.prototype._end = function () {
|
|
|
3167
3112
|
return;
|
|
3168
3113
|
}
|
|
3169
3114
|
|
|
3170
|
-
|
|
3115
|
+
let status;
|
|
3171
3116
|
|
|
3172
3117
|
try {
|
|
3173
3118
|
status = xhr.status;
|
|
3174
|
-
} catch (
|
|
3119
|
+
} catch (err) {
|
|
3175
3120
|
status = 0;
|
|
3176
3121
|
}
|
|
3177
3122
|
|
|
@@ -3183,7 +3128,7 @@ Request.prototype._end = function () {
|
|
|
3183
3128
|
self.emit('end');
|
|
3184
3129
|
});
|
|
3185
3130
|
|
|
3186
|
-
|
|
3131
|
+
const handleProgress = (direction, e) => {
|
|
3187
3132
|
if (e.total > 0) {
|
|
3188
3133
|
e.percent = e.loaded / e.total * 100;
|
|
3189
3134
|
|
|
@@ -3203,7 +3148,7 @@ Request.prototype._end = function () {
|
|
|
3203
3148
|
if (xhr.upload) {
|
|
3204
3149
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
3205
3150
|
}
|
|
3206
|
-
} catch (
|
|
3151
|
+
} catch (err) {}
|
|
3207
3152
|
}
|
|
3208
3153
|
|
|
3209
3154
|
if (xhr.upload) {
|
|
@@ -3223,18 +3168,17 @@ Request.prototype._end = function () {
|
|
|
3223
3168
|
if (this._withCredentials) xhr.withCredentials = true;
|
|
3224
3169
|
|
|
3225
3170
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3171
|
+
const contentType = this._header['content-type'];
|
|
3172
|
+
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3229
3173
|
|
|
3230
|
-
if (!
|
|
3231
|
-
|
|
3174
|
+
if (!serialize && isJSON(contentType)) {
|
|
3175
|
+
serialize = request.serialize['application/json'];
|
|
3232
3176
|
}
|
|
3233
3177
|
|
|
3234
|
-
if (
|
|
3178
|
+
if (serialize) data = serialize(data);
|
|
3235
3179
|
}
|
|
3236
3180
|
|
|
3237
|
-
for (
|
|
3181
|
+
for (const field in this.header) {
|
|
3238
3182
|
if (this.header[field] === null) continue;
|
|
3239
3183
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
3240
3184
|
}
|
|
@@ -3247,15 +3191,11 @@ Request.prototype._end = function () {
|
|
|
3247
3191
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
3248
3192
|
};
|
|
3249
3193
|
|
|
3250
|
-
request.agent =
|
|
3251
|
-
return new Agent();
|
|
3252
|
-
};
|
|
3253
|
-
|
|
3254
|
-
var _loop = function _loop() {
|
|
3255
|
-
var method = _arr[_i];
|
|
3194
|
+
request.agent = () => new Agent();
|
|
3256
3195
|
|
|
3196
|
+
for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
3257
3197
|
Agent.prototype[method.toLowerCase()] = function (url, fn) {
|
|
3258
|
-
|
|
3198
|
+
const request_ = new request.Request(method, url);
|
|
3259
3199
|
|
|
3260
3200
|
this._setDefaults(request_);
|
|
3261
3201
|
|
|
@@ -3265,16 +3205,12 @@ var _loop = function _loop() {
|
|
|
3265
3205
|
|
|
3266
3206
|
return request_;
|
|
3267
3207
|
};
|
|
3268
|
-
};
|
|
3269
|
-
|
|
3270
|
-
for (var _i = 0, _arr = ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']; _i < _arr.length; _i++) {
|
|
3271
|
-
_loop();
|
|
3272
3208
|
}
|
|
3273
3209
|
|
|
3274
3210
|
Agent.prototype.del = Agent.prototype.delete;
|
|
3275
3211
|
|
|
3276
|
-
request.get =
|
|
3277
|
-
|
|
3212
|
+
request.get = (url, data, fn) => {
|
|
3213
|
+
const request_ = request('GET', url);
|
|
3278
3214
|
|
|
3279
3215
|
if (typeof data === 'function') {
|
|
3280
3216
|
fn = data;
|
|
@@ -3286,8 +3222,8 @@ request.get = function (url, data, fn) {
|
|
|
3286
3222
|
return request_;
|
|
3287
3223
|
};
|
|
3288
3224
|
|
|
3289
|
-
request.head =
|
|
3290
|
-
|
|
3225
|
+
request.head = (url, data, fn) => {
|
|
3226
|
+
const request_ = request('HEAD', url);
|
|
3291
3227
|
|
|
3292
3228
|
if (typeof data === 'function') {
|
|
3293
3229
|
fn = data;
|
|
@@ -3299,8 +3235,8 @@ request.head = function (url, data, fn) {
|
|
|
3299
3235
|
return request_;
|
|
3300
3236
|
};
|
|
3301
3237
|
|
|
3302
|
-
request.options =
|
|
3303
|
-
|
|
3238
|
+
request.options = (url, data, fn) => {
|
|
3239
|
+
const request_ = request('OPTIONS', url);
|
|
3304
3240
|
|
|
3305
3241
|
if (typeof data === 'function') {
|
|
3306
3242
|
fn = data;
|
|
@@ -3313,7 +3249,7 @@ request.options = function (url, data, fn) {
|
|
|
3313
3249
|
};
|
|
3314
3250
|
|
|
3315
3251
|
function del(url, data, fn) {
|
|
3316
|
-
|
|
3252
|
+
const request_ = request('DELETE', url);
|
|
3317
3253
|
|
|
3318
3254
|
if (typeof data === 'function') {
|
|
3319
3255
|
fn = data;
|
|
@@ -3328,8 +3264,8 @@ function del(url, data, fn) {
|
|
|
3328
3264
|
request.del = del;
|
|
3329
3265
|
request.delete = del;
|
|
3330
3266
|
|
|
3331
|
-
request.patch =
|
|
3332
|
-
|
|
3267
|
+
request.patch = (url, data, fn) => {
|
|
3268
|
+
const request_ = request('PATCH', url);
|
|
3333
3269
|
|
|
3334
3270
|
if (typeof data === 'function') {
|
|
3335
3271
|
fn = data;
|
|
@@ -3341,8 +3277,8 @@ request.patch = function (url, data, fn) {
|
|
|
3341
3277
|
return request_;
|
|
3342
3278
|
};
|
|
3343
3279
|
|
|
3344
|
-
request.post =
|
|
3345
|
-
|
|
3280
|
+
request.post = (url, data, fn) => {
|
|
3281
|
+
const request_ = request('POST', url);
|
|
3346
3282
|
|
|
3347
3283
|
if (typeof data === 'function') {
|
|
3348
3284
|
fn = data;
|
|
@@ -3354,8 +3290,8 @@ request.post = function (url, data, fn) {
|
|
|
3354
3290
|
return request_;
|
|
3355
3291
|
};
|
|
3356
3292
|
|
|
3357
|
-
request.put =
|
|
3358
|
-
|
|
3293
|
+
request.put = (url, data, fn) => {
|
|
3294
|
+
const request_ = request('PUT', url);
|
|
3359
3295
|
|
|
3360
3296
|
if (typeof data === 'function') {
|
|
3361
3297
|
fn = data;
|
|
@@ -3369,15 +3305,12 @@ request.put = function (url, data, fn) {
|
|
|
3369
3305
|
|
|
3370
3306
|
},{"./agent-base":20,"./request-base":22,"./response-base":23,"./utils":24,"component-emitter":4,"fast-safe-stringify":5,"qs":15}],22:[function(require,module,exports){
|
|
3371
3307
|
(function (process){(function (){
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
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); }
|
|
3308
|
+
const semver = require('semver');
|
|
3375
3309
|
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
hasOwn = _require.hasOwn;
|
|
3310
|
+
const {
|
|
3311
|
+
isObject,
|
|
3312
|
+
hasOwn
|
|
3313
|
+
} = require('./utils');
|
|
3381
3314
|
|
|
3382
3315
|
module.exports = RequestBase;
|
|
3383
3316
|
|
|
@@ -3409,14 +3342,14 @@ RequestBase.prototype.serialize = function (fn) {
|
|
|
3409
3342
|
};
|
|
3410
3343
|
|
|
3411
3344
|
RequestBase.prototype.timeout = function (options) {
|
|
3412
|
-
if (!options ||
|
|
3345
|
+
if (!options || typeof options !== 'object') {
|
|
3413
3346
|
this._timeout = options;
|
|
3414
3347
|
this._responseTimeout = 0;
|
|
3415
3348
|
this._uploadTimeout = 0;
|
|
3416
3349
|
return this;
|
|
3417
3350
|
}
|
|
3418
3351
|
|
|
3419
|
-
for (
|
|
3352
|
+
for (const option in options) {
|
|
3420
3353
|
if (hasOwn(options, option)) {
|
|
3421
3354
|
switch (option) {
|
|
3422
3355
|
case 'deadline':
|
|
@@ -3449,8 +3382,8 @@ RequestBase.prototype.retry = function (count, fn) {
|
|
|
3449
3382
|
return this;
|
|
3450
3383
|
};
|
|
3451
3384
|
|
|
3452
|
-
|
|
3453
|
-
|
|
3385
|
+
const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
3386
|
+
const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
3454
3387
|
|
|
3455
3388
|
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
3456
3389
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
@@ -3459,7 +3392,7 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
3459
3392
|
|
|
3460
3393
|
if (this._retryCallback) {
|
|
3461
3394
|
try {
|
|
3462
|
-
|
|
3395
|
+
const override = this._retryCallback(error, res);
|
|
3463
3396
|
|
|
3464
3397
|
if (override === true) return true;
|
|
3465
3398
|
if (override === false) return false;
|
|
@@ -3494,34 +3427,32 @@ RequestBase.prototype._retry = function () {
|
|
|
3494
3427
|
};
|
|
3495
3428
|
|
|
3496
3429
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
3497
|
-
var _this = this;
|
|
3498
|
-
|
|
3499
3430
|
if (!this._fullfilledPromise) {
|
|
3500
|
-
|
|
3431
|
+
const self = this;
|
|
3501
3432
|
|
|
3502
3433
|
if (this._endCalled) {
|
|
3503
3434
|
console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
|
|
3504
3435
|
}
|
|
3505
3436
|
|
|
3506
|
-
this._fullfilledPromise = new Promise(
|
|
3507
|
-
self.on('abort',
|
|
3508
|
-
if (
|
|
3437
|
+
this._fullfilledPromise = new Promise((resolve, reject) => {
|
|
3438
|
+
self.on('abort', () => {
|
|
3439
|
+
if (this._maxRetries && this._maxRetries > this._retries) {
|
|
3509
3440
|
return;
|
|
3510
3441
|
}
|
|
3511
3442
|
|
|
3512
|
-
if (
|
|
3513
|
-
reject(
|
|
3443
|
+
if (this.timedout && this.timedoutError) {
|
|
3444
|
+
reject(this.timedoutError);
|
|
3514
3445
|
return;
|
|
3515
3446
|
}
|
|
3516
3447
|
|
|
3517
|
-
|
|
3448
|
+
const error = new Error('Aborted');
|
|
3518
3449
|
error.code = 'ABORTED';
|
|
3519
|
-
error.status =
|
|
3520
|
-
error.method =
|
|
3521
|
-
error.url =
|
|
3450
|
+
error.status = this.status;
|
|
3451
|
+
error.method = this.method;
|
|
3452
|
+
error.url = this.url;
|
|
3522
3453
|
reject(error);
|
|
3523
3454
|
});
|
|
3524
|
-
self.end(
|
|
3455
|
+
self.end((error, res) => {
|
|
3525
3456
|
if (error) reject(error);else resolve(res);
|
|
3526
3457
|
});
|
|
3527
3458
|
});
|
|
@@ -3565,7 +3496,7 @@ RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
|
3565
3496
|
|
|
3566
3497
|
RequestBase.prototype.set = function (field, value) {
|
|
3567
3498
|
if (isObject(field)) {
|
|
3568
|
-
for (
|
|
3499
|
+
for (const key in field) {
|
|
3569
3500
|
if (hasOwn(field, key)) this.set(key, field[key]);
|
|
3570
3501
|
}
|
|
3571
3502
|
|
|
@@ -3593,7 +3524,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3593
3524
|
}
|
|
3594
3525
|
|
|
3595
3526
|
if (isObject(name)) {
|
|
3596
|
-
for (
|
|
3527
|
+
for (const key in name) {
|
|
3597
3528
|
if (hasOwn(name, key)) this.field(key, name[key]);
|
|
3598
3529
|
}
|
|
3599
3530
|
|
|
@@ -3601,7 +3532,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3601
3532
|
}
|
|
3602
3533
|
|
|
3603
3534
|
if (Array.isArray(value)) {
|
|
3604
|
-
for (
|
|
3535
|
+
for (const i in value) {
|
|
3605
3536
|
if (hasOwn(value, i)) this.field(name, value[i]);
|
|
3606
3537
|
}
|
|
3607
3538
|
|
|
@@ -3646,7 +3577,7 @@ RequestBase.prototype.abort = function () {
|
|
|
3646
3577
|
RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
3647
3578
|
switch (options.type) {
|
|
3648
3579
|
case 'basic':
|
|
3649
|
-
this.set('Authorization',
|
|
3580
|
+
this.set('Authorization', `Basic ${base64Encoder(`${user}:${pass}`)}`);
|
|
3650
3581
|
break;
|
|
3651
3582
|
|
|
3652
3583
|
case 'auto':
|
|
@@ -3655,7 +3586,7 @@ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
|
3655
3586
|
break;
|
|
3656
3587
|
|
|
3657
3588
|
case 'bearer':
|
|
3658
|
-
this.set('Authorization',
|
|
3589
|
+
this.set('Authorization', `Bearer ${user}`);
|
|
3659
3590
|
break;
|
|
3660
3591
|
|
|
3661
3592
|
default:
|
|
@@ -3695,8 +3626,8 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3695
3626
|
};
|
|
3696
3627
|
|
|
3697
3628
|
RequestBase.prototype.send = function (data) {
|
|
3698
|
-
|
|
3699
|
-
|
|
3629
|
+
const isObject_ = isObject(data);
|
|
3630
|
+
let type = this._header['content-type'];
|
|
3700
3631
|
|
|
3701
3632
|
if (this._formData) {
|
|
3702
3633
|
throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
|
|
@@ -3713,7 +3644,7 @@ RequestBase.prototype.send = function (data) {
|
|
|
3713
3644
|
}
|
|
3714
3645
|
|
|
3715
3646
|
if (isObject_ && isObject(this._data)) {
|
|
3716
|
-
for (
|
|
3647
|
+
for (const key in data) {
|
|
3717
3648
|
if (hasOwn(data, key)) this._data[key] = data[key];
|
|
3718
3649
|
}
|
|
3719
3650
|
} else if (typeof data === 'string') {
|
|
@@ -3722,7 +3653,7 @@ RequestBase.prototype.send = function (data) {
|
|
|
3722
3653
|
if (type) type = type.toLowerCase().trim();
|
|
3723
3654
|
|
|
3724
3655
|
if (type === 'application/x-www-form-urlencoded') {
|
|
3725
|
-
this._data = this._data ?
|
|
3656
|
+
this._data = this._data ? `${this._data}&${data}` : data;
|
|
3726
3657
|
} else {
|
|
3727
3658
|
this._data = (this._data || '') + data;
|
|
3728
3659
|
}
|
|
@@ -3744,7 +3675,7 @@ RequestBase.prototype.sortQuery = function (sort) {
|
|
|
3744
3675
|
};
|
|
3745
3676
|
|
|
3746
3677
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3747
|
-
|
|
3678
|
+
const query = this._query.join('&');
|
|
3748
3679
|
|
|
3749
3680
|
if (query) {
|
|
3750
3681
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
@@ -3753,10 +3684,10 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3753
3684
|
this._query.length = 0;
|
|
3754
3685
|
|
|
3755
3686
|
if (this._sort) {
|
|
3756
|
-
|
|
3687
|
+
const index = this.url.indexOf('?');
|
|
3757
3688
|
|
|
3758
3689
|
if (index >= 0) {
|
|
3759
|
-
|
|
3690
|
+
const queryArray = this.url.slice(index + 1).split('&');
|
|
3760
3691
|
|
|
3761
3692
|
if (typeof this._sort === 'function') {
|
|
3762
3693
|
queryArray.sort(this._sort);
|
|
@@ -3769,7 +3700,7 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3769
3700
|
}
|
|
3770
3701
|
};
|
|
3771
3702
|
|
|
3772
|
-
RequestBase.prototype._appendQueryString =
|
|
3703
|
+
RequestBase.prototype._appendQueryString = () => {
|
|
3773
3704
|
console.warn('Unsupported');
|
|
3774
3705
|
};
|
|
3775
3706
|
|
|
@@ -3778,7 +3709,7 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3778
3709
|
return;
|
|
3779
3710
|
}
|
|
3780
3711
|
|
|
3781
|
-
|
|
3712
|
+
const error = new Error(`${reason + timeout}ms exceeded`);
|
|
3782
3713
|
error.timeout = timeout;
|
|
3783
3714
|
error.code = 'ECONNABORTED';
|
|
3784
3715
|
error.errno = errno;
|
|
@@ -3789,16 +3720,16 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3789
3720
|
};
|
|
3790
3721
|
|
|
3791
3722
|
RequestBase.prototype._setTimeouts = function () {
|
|
3792
|
-
|
|
3723
|
+
const self = this;
|
|
3793
3724
|
|
|
3794
3725
|
if (this._timeout && !this._timer) {
|
|
3795
|
-
this._timer = setTimeout(
|
|
3726
|
+
this._timer = setTimeout(() => {
|
|
3796
3727
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
3797
3728
|
}, this._timeout);
|
|
3798
3729
|
}
|
|
3799
3730
|
|
|
3800
3731
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
3801
|
-
this._responseTimeoutTimer = setTimeout(
|
|
3732
|
+
this._responseTimeoutTimer = setTimeout(() => {
|
|
3802
3733
|
self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
|
|
3803
3734
|
}, this._responseTimeout);
|
|
3804
3735
|
}
|
|
@@ -3806,9 +3737,7 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3806
3737
|
|
|
3807
3738
|
}).call(this)}).call(this,require('_process'))
|
|
3808
3739
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
var utils = require('./utils');
|
|
3740
|
+
const utils = require('./utils');
|
|
3812
3741
|
|
|
3813
3742
|
module.exports = ResponseBase;
|
|
3814
3743
|
|
|
@@ -3819,11 +3748,11 @@ ResponseBase.prototype.get = function (field) {
|
|
|
3819
3748
|
};
|
|
3820
3749
|
|
|
3821
3750
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3822
|
-
|
|
3751
|
+
const ct = header['content-type'] || '';
|
|
3823
3752
|
this.type = utils.type(ct);
|
|
3824
|
-
|
|
3753
|
+
const parameters = utils.params(ct);
|
|
3825
3754
|
|
|
3826
|
-
for (
|
|
3755
|
+
for (const key in parameters) {
|
|
3827
3756
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3828
3757
|
}
|
|
3829
3758
|
|
|
@@ -3833,11 +3762,11 @@ ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
|
3833
3762
|
if (header.link) {
|
|
3834
3763
|
this.links = utils.parseLinks(header.link);
|
|
3835
3764
|
}
|
|
3836
|
-
} catch (
|
|
3765
|
+
} catch (err) {}
|
|
3837
3766
|
};
|
|
3838
3767
|
|
|
3839
3768
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3840
|
-
|
|
3769
|
+
const type = Math.trunc(status / 100);
|
|
3841
3770
|
this.statusCode = status;
|
|
3842
3771
|
this.status = this.statusCode;
|
|
3843
3772
|
this.statusType = type;
|
|
@@ -3859,69 +3788,35 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3859
3788
|
};
|
|
3860
3789
|
|
|
3861
3790
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3862
|
-
|
|
3791
|
+
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3863
3792
|
|
|
3864
|
-
|
|
3793
|
+
exports.params = value => {
|
|
3794
|
+
const object = {};
|
|
3865
3795
|
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
exports.type = function (string_) {
|
|
3873
|
-
return string_.split(/ *; */).shift();
|
|
3874
|
-
};
|
|
3875
|
-
|
|
3876
|
-
exports.params = function (value) {
|
|
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();
|
|
3796
|
+
for (const string_ of value.split(/ *; */)) {
|
|
3797
|
+
const parts = string_.split(/ *= */);
|
|
3798
|
+
const key = parts.shift();
|
|
3799
|
+
const value = parts.shift();
|
|
3800
|
+
if (key && value) object[key] = value;
|
|
3896
3801
|
}
|
|
3897
3802
|
|
|
3898
3803
|
return object;
|
|
3899
3804
|
};
|
|
3900
3805
|
|
|
3901
|
-
exports.parseLinks =
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
var _iterator2 = _createForOfIteratorHelper(value.split(/ *, */)),
|
|
3905
|
-
_step2;
|
|
3806
|
+
exports.parseLinks = value => {
|
|
3807
|
+
const object = {};
|
|
3906
3808
|
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
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();
|
|
3809
|
+
for (const string_ of value.split(/ *, */)) {
|
|
3810
|
+
const parts = string_.split(/ *; */);
|
|
3811
|
+
const url = parts[0].slice(1, -1);
|
|
3812
|
+
const rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3813
|
+
object[rel] = url;
|
|
3919
3814
|
}
|
|
3920
3815
|
|
|
3921
3816
|
return object;
|
|
3922
3817
|
};
|
|
3923
3818
|
|
|
3924
|
-
exports.cleanHeader =
|
|
3819
|
+
exports.cleanHeader = (header, changesOrigin) => {
|
|
3925
3820
|
delete header['content-type'];
|
|
3926
3821
|
delete header['content-length'];
|
|
3927
3822
|
delete header['transfer-encoding'];
|
|
@@ -3935,8 +3830,8 @@ exports.cleanHeader = function (header, changesOrigin) {
|
|
|
3935
3830
|
return header;
|
|
3936
3831
|
};
|
|
3937
3832
|
|
|
3938
|
-
exports.isObject =
|
|
3939
|
-
return object !== null &&
|
|
3833
|
+
exports.isObject = object => {
|
|
3834
|
+
return object !== null && typeof object === 'object';
|
|
3940
3835
|
};
|
|
3941
3836
|
|
|
3942
3837
|
exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
@@ -3947,8 +3842,8 @@ exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
|
3947
3842
|
return Object.prototype.hasOwnProperty.call(new Object(object), property);
|
|
3948
3843
|
};
|
|
3949
3844
|
|
|
3950
|
-
exports.mixin =
|
|
3951
|
-
for (
|
|
3845
|
+
exports.mixin = (target, source) => {
|
|
3846
|
+
for (const key in source) {
|
|
3952
3847
|
if (exports.hasOwn(source, key)) {
|
|
3953
3848
|
target[key] = source[key];
|
|
3954
3849
|
}
|