@vonage/client-sdk 1.5.0-alpha.2 → 1.5.0-alpha.4

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.
@@ -30603,6 +30603,15 @@ function requireClientsdkClientcore () {
30603
30603
  setMetadataFor(Companion_130, 'Companion', objectMeta);
30604
30604
  setMetadataFor($serializer_149, '$serializer', objectMeta, VOID, [GeneratedSerializer]);
30605
30605
  setMetadataFor(SessionTerminatedEvent, 'SessionTerminatedEvent', classMeta, VOID, [SocketEvent], VOID, VOID, {0: $serializer_getInstance_149});
30606
+ function onAudioSay() {
30607
+ }
30608
+ function onAudioMuteUpdate(conversationId, legId, isMuted) {
30609
+ }
30610
+ function onAudioEarmuffUpdate(conversationId, legId, earmuffStatus) {
30611
+ }
30612
+ function onAudioDTMFUpdate(conversationId, legId, digits) {
30613
+ }
30614
+ setMetadataFor(AudioEventListener, 'AudioEventListener', interfaceMeta);
30606
30615
  function onRTCHangup(conversationId, legId, hangup) {
30607
30616
  }
30608
30617
  function onRTCTransfer(conversationId, legId) {
@@ -30613,16 +30622,7 @@ function requireClientsdkClientcore () {
30613
30622
  function onConversationEvent(event) {
30614
30623
  }
30615
30624
  setMetadataFor(ConversationEventListener, 'ConversationEventListener', interfaceMeta);
30616
- function onAudioSay() {
30617
- }
30618
- function onAudioMuteUpdate(conversationId, legId, isMuted) {
30619
- }
30620
- function onAudioEarmuffUpdate(conversationId, legId, earmuffStatus) {
30621
- }
30622
- function onAudioDTMFUpdate(conversationId, legId, digits) {
30623
- }
30624
- setMetadataFor(AudioEventListener, 'AudioEventListener', interfaceMeta);
30625
- setMetadataFor(ChatAPIImpl$1, VOID, classMeta, VOID, [RTCEventListener, ConversationEventListener, AudioEventListener]);
30625
+ setMetadataFor(ChatAPIImpl$1, VOID, classMeta, VOID, [AudioEventListener, RTCEventListener, ConversationEventListener]);
30626
30626
  setMetadataFor(ChatAPIImpl, 'ChatAPIImpl', classMeta, VOID, [ChatAPI]);
30627
30627
  setMetadataFor(LoggingLevel, 'LoggingLevel', classMeta, Enum);
30628
30628
  setMetadataFor(ClientConfigRegion, 'ClientConfigRegion', classMeta, Enum);
@@ -30747,7 +30747,7 @@ function requireClientsdkClientcore () {
30747
30747
  setMetadataFor(HangupReason, 'HangupReason', classMeta, Enum);
30748
30748
  setMetadataFor(LegStatus, 'LegStatus', classMeta, Enum);
30749
30749
  setMetadataFor(CallDisconnectReason, 'CallDisconnectReason', classMeta, Enum);
30750
- setMetadataFor(VoiceAPIImpl$1, VOID, classMeta, VOID, [RTCEventListener, ConversationEventListener, AudioEventListener]);
30750
+ setMetadataFor(VoiceAPIImpl$1, VOID, classMeta, VOID, [AudioEventListener, RTCEventListener, ConversationEventListener]);
30751
30751
  setMetadataFor(VoiceAPIImpl, 'VoiceAPIImpl', classMeta);
30752
30752
  setMetadataFor(CallEvent, 'CallEvent', interfaceMeta);
30753
30753
  setMetadataFor(SetupOutboundCall, 'SetupOutboundCall', classMeta, VOID, [CallEvent]);
@@ -30962,7 +30962,7 @@ function requireClientsdkClientcore () {
30962
30962
  setMetadataFor(Failed, 'Failed', classMeta, StateTransition);
30963
30963
  //endregion
30964
30964
  function BuildKonfig() {
30965
- this.b19_1 = '1.5.0-alpha.2';
30965
+ this.b19_1 = '1.5.0-alpha.4';
30966
30966
  }
30967
30967
  var BuildKonfig_instance;
30968
30968
  function CoreClientWithMedia() {
@@ -77293,3277 +77293,30 @@ function requireClientsdkClientcore () {
77293
77293
 
77294
77294
  } (clientsdkClientcore_js));
77295
77295
 
77296
- function bind(fn, thisArg) {
77297
- return function wrap() {
77298
- return fn.apply(thisArg, arguments);
77299
- };
77300
- }
77301
-
77302
- // utils is a library of generic helper functions non-specific to axios
77303
-
77304
- const {toString: toString$1} = Object.prototype;
77305
- const {getPrototypeOf} = Object;
77306
-
77307
- const kindOf = (cache => thing => {
77308
- const str = toString$1.call(thing);
77309
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
77310
- })(Object.create(null));
77311
-
77312
- const kindOfTest = (type) => {
77313
- type = type.toLowerCase();
77314
- return (thing) => kindOf(thing) === type
77315
- };
77316
-
77317
- const typeOfTest = type => thing => typeof thing === type;
77318
-
77319
- /**
77320
- * Determine if a value is an Array
77321
- *
77322
- * @param {Object} val The value to test
77323
- *
77324
- * @returns {boolean} True if value is an Array, otherwise false
77325
- */
77326
- const {isArray} = Array;
77327
-
77328
- /**
77329
- * Determine if a value is undefined
77330
- *
77331
- * @param {*} val The value to test
77332
- *
77333
- * @returns {boolean} True if the value is undefined, otherwise false
77334
- */
77335
- const isUndefined = typeOfTest('undefined');
77336
-
77337
- /**
77338
- * Determine if a value is a Buffer
77339
- *
77340
- * @param {*} val The value to test
77341
- *
77342
- * @returns {boolean} True if value is a Buffer, otherwise false
77343
- */
77344
- function isBuffer(val) {
77345
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
77346
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
77347
- }
77348
-
77349
- /**
77350
- * Determine if a value is an ArrayBuffer
77351
- *
77352
- * @param {*} val The value to test
77353
- *
77354
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
77355
- */
77356
- const isArrayBuffer = kindOfTest('ArrayBuffer');
77357
-
77358
-
77359
- /**
77360
- * Determine if a value is a view on an ArrayBuffer
77361
- *
77362
- * @param {*} val The value to test
77363
- *
77364
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
77365
- */
77366
- function isArrayBufferView(val) {
77367
- let result;
77368
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
77369
- result = ArrayBuffer.isView(val);
77370
- } else {
77371
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
77372
- }
77373
- return result;
77374
- }
77375
-
77376
- /**
77377
- * Determine if a value is a String
77378
- *
77379
- * @param {*} val The value to test
77380
- *
77381
- * @returns {boolean} True if value is a String, otherwise false
77382
- */
77383
- const isString = typeOfTest('string');
77384
-
77385
- /**
77386
- * Determine if a value is a Function
77387
- *
77388
- * @param {*} val The value to test
77389
- * @returns {boolean} True if value is a Function, otherwise false
77390
- */
77391
- const isFunction = typeOfTest('function');
77392
-
77393
- /**
77394
- * Determine if a value is a Number
77395
- *
77396
- * @param {*} val The value to test
77397
- *
77398
- * @returns {boolean} True if value is a Number, otherwise false
77399
- */
77400
- const isNumber = typeOfTest('number');
77401
-
77402
- /**
77403
- * Determine if a value is an Object
77404
- *
77405
- * @param {*} thing The value to test
77406
- *
77407
- * @returns {boolean} True if value is an Object, otherwise false
77408
- */
77409
- const isObject$2 = (thing) => thing !== null && typeof thing === 'object';
77410
-
77411
- /**
77412
- * Determine if a value is a Boolean
77413
- *
77414
- * @param {*} thing The value to test
77415
- * @returns {boolean} True if value is a Boolean, otherwise false
77416
- */
77417
- const isBoolean = thing => thing === true || thing === false;
77418
-
77419
- /**
77420
- * Determine if a value is a plain Object
77421
- *
77422
- * @param {*} val The value to test
77423
- *
77424
- * @returns {boolean} True if value is a plain Object, otherwise false
77425
- */
77426
- const isPlainObject = (val) => {
77427
- if (kindOf(val) !== 'object') {
77428
- return false;
77429
- }
77430
-
77431
- const prototype = getPrototypeOf(val);
77432
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
77433
- };
77434
-
77435
- /**
77436
- * Determine if a value is a Date
77437
- *
77438
- * @param {*} val The value to test
77439
- *
77440
- * @returns {boolean} True if value is a Date, otherwise false
77441
- */
77442
- const isDate = kindOfTest('Date');
77443
-
77444
- /**
77445
- * Determine if a value is a File
77446
- *
77447
- * @param {*} val The value to test
77448
- *
77449
- * @returns {boolean} True if value is a File, otherwise false
77450
- */
77451
- const isFile = kindOfTest('File');
77452
-
77453
- /**
77454
- * Determine if a value is a Blob
77455
- *
77456
- * @param {*} val The value to test
77457
- *
77458
- * @returns {boolean} True if value is a Blob, otherwise false
77459
- */
77460
- const isBlob = kindOfTest('Blob');
77461
-
77462
- /**
77463
- * Determine if a value is a FileList
77464
- *
77465
- * @param {*} val The value to test
77466
- *
77467
- * @returns {boolean} True if value is a File, otherwise false
77468
- */
77469
- const isFileList = kindOfTest('FileList');
77470
-
77471
- /**
77472
- * Determine if a value is a Stream
77473
- *
77474
- * @param {*} val The value to test
77475
- *
77476
- * @returns {boolean} True if value is a Stream, otherwise false
77477
- */
77478
- const isStream = (val) => isObject$2(val) && isFunction(val.pipe);
77479
-
77480
- /**
77481
- * Determine if a value is a FormData
77482
- *
77483
- * @param {*} thing The value to test
77484
- *
77485
- * @returns {boolean} True if value is an FormData, otherwise false
77486
- */
77487
- const isFormData = (thing) => {
77488
- let kind;
77489
- return thing && (
77490
- (typeof FormData === 'function' && thing instanceof FormData) || (
77491
- isFunction(thing.append) && (
77492
- (kind = kindOf(thing)) === 'formdata' ||
77493
- // detect form-data instance
77494
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
77495
- )
77496
- )
77497
- )
77498
- };
77499
-
77500
- /**
77501
- * Determine if a value is a URLSearchParams object
77502
- *
77503
- * @param {*} val The value to test
77504
- *
77505
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
77506
- */
77507
- const isURLSearchParams = kindOfTest('URLSearchParams');
77508
-
77509
- /**
77510
- * Trim excess whitespace off the beginning and end of a string
77511
- *
77512
- * @param {String} str The String to trim
77513
- *
77514
- * @returns {String} The String freed of excess whitespace
77515
- */
77516
- const trim = (str) => str.trim ?
77517
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
77518
-
77519
- /**
77520
- * Iterate over an Array or an Object invoking a function for each item.
77521
- *
77522
- * If `obj` is an Array callback will be called passing
77523
- * the value, index, and complete array for each item.
77524
- *
77525
- * If 'obj' is an Object callback will be called passing
77526
- * the value, key, and complete object for each property.
77527
- *
77528
- * @param {Object|Array} obj The object to iterate
77529
- * @param {Function} fn The callback to invoke for each item
77530
- *
77531
- * @param {Boolean} [allOwnKeys = false]
77532
- * @returns {any}
77533
- */
77534
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
77535
- // Don't bother if no value provided
77536
- if (obj === null || typeof obj === 'undefined') {
77537
- return;
77538
- }
77539
-
77540
- let i;
77541
- let l;
77542
-
77543
- // Force an array if not already something iterable
77544
- if (typeof obj !== 'object') {
77545
- /*eslint no-param-reassign:0*/
77546
- obj = [obj];
77547
- }
77548
-
77549
- if (isArray(obj)) {
77550
- // Iterate over array values
77551
- for (i = 0, l = obj.length; i < l; i++) {
77552
- fn.call(null, obj[i], i, obj);
77553
- }
77554
- } else {
77555
- // Iterate over object keys
77556
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
77557
- const len = keys.length;
77558
- let key;
77559
-
77560
- for (i = 0; i < len; i++) {
77561
- key = keys[i];
77562
- fn.call(null, obj[key], key, obj);
77563
- }
77564
- }
77565
- }
77566
-
77567
- function findKey(obj, key) {
77568
- key = key.toLowerCase();
77569
- const keys = Object.keys(obj);
77570
- let i = keys.length;
77571
- let _key;
77572
- while (i-- > 0) {
77573
- _key = keys[i];
77574
- if (key === _key.toLowerCase()) {
77575
- return _key;
77576
- }
77577
- }
77578
- return null;
77579
- }
77580
-
77581
- const _global = (() => {
77582
- /*eslint no-undef:0*/
77583
- if (typeof globalThis !== "undefined") return globalThis;
77584
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
77585
- })();
77586
-
77587
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
77588
-
77589
- /**
77590
- * Accepts varargs expecting each argument to be an object, then
77591
- * immutably merges the properties of each object and returns result.
77592
- *
77593
- * When multiple objects contain the same key the later object in
77594
- * the arguments list will take precedence.
77595
- *
77596
- * Example:
77597
- *
77598
- * ```js
77599
- * var result = merge({foo: 123}, {foo: 456});
77600
- * console.log(result.foo); // outputs 456
77601
- * ```
77602
- *
77603
- * @param {Object} obj1 Object to merge
77604
- *
77605
- * @returns {Object} Result of all merge properties
77606
- */
77607
- function merge(/* obj1, obj2, obj3, ... */) {
77608
- const {caseless} = isContextDefined(this) && this || {};
77609
- const result = {};
77610
- const assignValue = (val, key) => {
77611
- const targetKey = caseless && findKey(result, key) || key;
77612
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
77613
- result[targetKey] = merge(result[targetKey], val);
77614
- } else if (isPlainObject(val)) {
77615
- result[targetKey] = merge({}, val);
77616
- } else if (isArray(val)) {
77617
- result[targetKey] = val.slice();
77618
- } else {
77619
- result[targetKey] = val;
77620
- }
77621
- };
77622
-
77623
- for (let i = 0, l = arguments.length; i < l; i++) {
77624
- arguments[i] && forEach(arguments[i], assignValue);
77625
- }
77626
- return result;
77627
- }
77628
-
77629
- /**
77630
- * Extends object a by mutably adding to it the properties of object b.
77631
- *
77632
- * @param {Object} a The object to be extended
77633
- * @param {Object} b The object to copy properties from
77634
- * @param {Object} thisArg The object to bind function to
77635
- *
77636
- * @param {Boolean} [allOwnKeys]
77637
- * @returns {Object} The resulting value of object a
77638
- */
77639
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
77640
- forEach(b, (val, key) => {
77641
- if (thisArg && isFunction(val)) {
77642
- a[key] = bind(val, thisArg);
77643
- } else {
77644
- a[key] = val;
77645
- }
77646
- }, {allOwnKeys});
77647
- return a;
77648
- };
77649
-
77650
- /**
77651
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
77652
- *
77653
- * @param {string} content with BOM
77654
- *
77655
- * @returns {string} content value without BOM
77656
- */
77657
- const stripBOM = (content) => {
77658
- if (content.charCodeAt(0) === 0xFEFF) {
77659
- content = content.slice(1);
77660
- }
77661
- return content;
77662
- };
77663
-
77664
- /**
77665
- * Inherit the prototype methods from one constructor into another
77666
- * @param {function} constructor
77667
- * @param {function} superConstructor
77668
- * @param {object} [props]
77669
- * @param {object} [descriptors]
77670
- *
77671
- * @returns {void}
77672
- */
77673
- const inherits = (constructor, superConstructor, props, descriptors) => {
77674
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
77675
- constructor.prototype.constructor = constructor;
77676
- Object.defineProperty(constructor, 'super', {
77677
- value: superConstructor.prototype
77678
- });
77679
- props && Object.assign(constructor.prototype, props);
77680
- };
77681
-
77682
- /**
77683
- * Resolve object with deep prototype chain to a flat object
77684
- * @param {Object} sourceObj source object
77685
- * @param {Object} [destObj]
77686
- * @param {Function|Boolean} [filter]
77687
- * @param {Function} [propFilter]
77688
- *
77689
- * @returns {Object}
77690
- */
77691
- const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
77692
- let props;
77693
- let i;
77694
- let prop;
77695
- const merged = {};
77696
-
77697
- destObj = destObj || {};
77698
- // eslint-disable-next-line no-eq-null,eqeqeq
77699
- if (sourceObj == null) return destObj;
77700
-
77701
- do {
77702
- props = Object.getOwnPropertyNames(sourceObj);
77703
- i = props.length;
77704
- while (i-- > 0) {
77705
- prop = props[i];
77706
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
77707
- destObj[prop] = sourceObj[prop];
77708
- merged[prop] = true;
77709
- }
77710
- }
77711
- sourceObj = filter !== false && getPrototypeOf(sourceObj);
77712
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
77713
-
77714
- return destObj;
77715
- };
77716
-
77717
- /**
77718
- * Determines whether a string ends with the characters of a specified string
77719
- *
77720
- * @param {String} str
77721
- * @param {String} searchString
77722
- * @param {Number} [position= 0]
77723
- *
77724
- * @returns {boolean}
77725
- */
77726
- const endsWith = (str, searchString, position) => {
77727
- str = String(str);
77728
- if (position === undefined || position > str.length) {
77729
- position = str.length;
77730
- }
77731
- position -= searchString.length;
77732
- const lastIndex = str.indexOf(searchString, position);
77733
- return lastIndex !== -1 && lastIndex === position;
77734
- };
77735
-
77736
-
77737
- /**
77738
- * Returns new array from array like object or null if failed
77739
- *
77740
- * @param {*} [thing]
77741
- *
77742
- * @returns {?Array}
77743
- */
77744
- const toArray$1 = (thing) => {
77745
- if (!thing) return null;
77746
- if (isArray(thing)) return thing;
77747
- let i = thing.length;
77748
- if (!isNumber(i)) return null;
77749
- const arr = new Array(i);
77750
- while (i-- > 0) {
77751
- arr[i] = thing[i];
77752
- }
77753
- return arr;
77754
- };
77755
-
77756
- /**
77757
- * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
77758
- * thing passed in is an instance of Uint8Array
77759
- *
77760
- * @param {TypedArray}
77761
- *
77762
- * @returns {Array}
77763
- */
77764
- // eslint-disable-next-line func-names
77765
- const isTypedArray = (TypedArray => {
77766
- // eslint-disable-next-line func-names
77767
- return thing => {
77768
- return TypedArray && thing instanceof TypedArray;
77769
- };
77770
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
77771
-
77772
- /**
77773
- * For each entry in the object, call the function with the key and value.
77774
- *
77775
- * @param {Object<any, any>} obj - The object to iterate over.
77776
- * @param {Function} fn - The function to call for each entry.
77777
- *
77778
- * @returns {void}
77779
- */
77780
- const forEachEntry = (obj, fn) => {
77781
- const generator = obj && obj[Symbol.iterator];
77782
-
77783
- const iterator = generator.call(obj);
77784
-
77785
- let result;
77786
-
77787
- while ((result = iterator.next()) && !result.done) {
77788
- const pair = result.value;
77789
- fn.call(obj, pair[0], pair[1]);
77790
- }
77791
- };
77792
-
77793
- /**
77794
- * It takes a regular expression and a string, and returns an array of all the matches
77795
- *
77796
- * @param {string} regExp - The regular expression to match against.
77797
- * @param {string} str - The string to search.
77798
- *
77799
- * @returns {Array<boolean>}
77800
- */
77801
- const matchAll = (regExp, str) => {
77802
- let matches;
77803
- const arr = [];
77804
-
77805
- while ((matches = regExp.exec(str)) !== null) {
77806
- arr.push(matches);
77807
- }
77808
-
77809
- return arr;
77810
- };
77811
-
77812
- /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
77813
- const isHTMLForm = kindOfTest('HTMLFormElement');
77814
-
77815
- const toCamelCase = str => {
77816
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
77817
- function replacer(m, p1, p2) {
77818
- return p1.toUpperCase() + p2;
77819
- }
77820
- );
77821
- };
77822
-
77823
- /* Creating a function that will check if an object has a property. */
77824
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
77825
-
77826
- /**
77827
- * Determine if a value is a RegExp object
77828
- *
77829
- * @param {*} val The value to test
77830
- *
77831
- * @returns {boolean} True if value is a RegExp object, otherwise false
77832
- */
77833
- const isRegExp = kindOfTest('RegExp');
77834
-
77835
- const reduceDescriptors = (obj, reducer) => {
77836
- const descriptors = Object.getOwnPropertyDescriptors(obj);
77837
- const reducedDescriptors = {};
77838
-
77839
- forEach(descriptors, (descriptor, name) => {
77840
- let ret;
77841
- if ((ret = reducer(descriptor, name, obj)) !== false) {
77842
- reducedDescriptors[name] = ret || descriptor;
77843
- }
77844
- });
77845
-
77846
- Object.defineProperties(obj, reducedDescriptors);
77847
- };
77848
-
77849
- /**
77850
- * Makes all methods read-only
77851
- * @param {Object} obj
77852
- */
77853
-
77854
- const freezeMethods = (obj) => {
77855
- reduceDescriptors(obj, (descriptor, name) => {
77856
- // skip restricted props in strict mode
77857
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
77858
- return false;
77859
- }
77860
-
77861
- const value = obj[name];
77862
-
77863
- if (!isFunction(value)) return;
77864
-
77865
- descriptor.enumerable = false;
77866
-
77867
- if ('writable' in descriptor) {
77868
- descriptor.writable = false;
77869
- return;
77870
- }
77871
-
77872
- if (!descriptor.set) {
77873
- descriptor.set = () => {
77874
- throw Error('Can not rewrite read-only method \'' + name + '\'');
77875
- };
77876
- }
77877
- });
77878
- };
77879
-
77880
- const toObjectSet = (arrayOrString, delimiter) => {
77881
- const obj = {};
77882
-
77883
- const define = (arr) => {
77884
- arr.forEach(value => {
77885
- obj[value] = true;
77886
- });
77887
- };
77888
-
77889
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
77890
-
77891
- return obj;
77892
- };
77893
-
77894
- const noop = () => {};
77895
-
77896
- const toFiniteNumber = (value, defaultValue) => {
77897
- value = +value;
77898
- return Number.isFinite(value) ? value : defaultValue;
77899
- };
77900
-
77901
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
77902
-
77903
- const DIGIT = '0123456789';
77904
-
77905
- const ALPHABET = {
77906
- DIGIT,
77907
- ALPHA,
77908
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
77909
- };
77910
-
77911
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
77912
- let str = '';
77913
- const {length} = alphabet;
77914
- while (size--) {
77915
- str += alphabet[Math.random() * length|0];
77916
- }
77917
-
77918
- return str;
77919
- };
77920
-
77921
- /**
77922
- * If the thing is a FormData object, return true, otherwise return false.
77923
- *
77924
- * @param {unknown} thing - The thing to check.
77925
- *
77926
- * @returns {boolean}
77927
- */
77928
- function isSpecCompliantForm(thing) {
77929
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
77930
- }
77931
-
77932
- const toJSONObject = (obj) => {
77933
- const stack = new Array(10);
77934
-
77935
- const visit = (source, i) => {
77936
-
77937
- if (isObject$2(source)) {
77938
- if (stack.indexOf(source) >= 0) {
77939
- return;
77940
- }
77941
-
77942
- if(!('toJSON' in source)) {
77943
- stack[i] = source;
77944
- const target = isArray(source) ? [] : {};
77945
-
77946
- forEach(source, (value, key) => {
77947
- const reducedValue = visit(value, i + 1);
77948
- !isUndefined(reducedValue) && (target[key] = reducedValue);
77949
- });
77950
-
77951
- stack[i] = undefined;
77952
-
77953
- return target;
77954
- }
77955
- }
77956
-
77957
- return source;
77958
- };
77959
-
77960
- return visit(obj, 0);
77961
- };
77962
-
77963
- const isAsyncFn = kindOfTest('AsyncFunction');
77964
-
77965
- const isThenable = (thing) =>
77966
- thing && (isObject$2(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
77967
-
77968
- var utils$2 = {
77969
- isArray,
77970
- isArrayBuffer,
77971
- isBuffer,
77972
- isFormData,
77973
- isArrayBufferView,
77974
- isString,
77975
- isNumber,
77976
- isBoolean,
77977
- isObject: isObject$2,
77978
- isPlainObject,
77979
- isUndefined,
77980
- isDate,
77981
- isFile,
77982
- isBlob,
77983
- isRegExp,
77984
- isFunction,
77985
- isStream,
77986
- isURLSearchParams,
77987
- isTypedArray,
77988
- isFileList,
77989
- forEach,
77990
- merge,
77991
- extend,
77992
- trim,
77993
- stripBOM,
77994
- inherits,
77995
- toFlatObject,
77996
- kindOf,
77997
- kindOfTest,
77998
- endsWith,
77999
- toArray: toArray$1,
78000
- forEachEntry,
78001
- matchAll,
78002
- isHTMLForm,
78003
- hasOwnProperty,
78004
- hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
78005
- reduceDescriptors,
78006
- freezeMethods,
78007
- toObjectSet,
78008
- toCamelCase,
78009
- noop,
78010
- toFiniteNumber,
78011
- findKey,
78012
- global: _global,
78013
- isContextDefined,
78014
- ALPHABET,
78015
- generateString,
78016
- isSpecCompliantForm,
78017
- toJSONObject,
78018
- isAsyncFn,
78019
- isThenable
78020
- };
78021
-
78022
- /**
78023
- * Create an Error with the specified message, config, error code, request and response.
78024
- *
78025
- * @param {string} message The error message.
78026
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
78027
- * @param {Object} [config] The config.
78028
- * @param {Object} [request] The request.
78029
- * @param {Object} [response] The response.
78030
- *
78031
- * @returns {Error} The created error.
78032
- */
78033
- function AxiosError(message, code, config, request, response) {
78034
- Error.call(this);
78035
-
78036
- if (Error.captureStackTrace) {
78037
- Error.captureStackTrace(this, this.constructor);
78038
- } else {
78039
- this.stack = (new Error()).stack;
78040
- }
78041
-
78042
- this.message = message;
78043
- this.name = 'AxiosError';
78044
- code && (this.code = code);
78045
- config && (this.config = config);
78046
- request && (this.request = request);
78047
- response && (this.response = response);
78048
- }
78049
-
78050
- utils$2.inherits(AxiosError, Error, {
78051
- toJSON: function toJSON() {
78052
- return {
78053
- // Standard
78054
- message: this.message,
78055
- name: this.name,
78056
- // Microsoft
78057
- description: this.description,
78058
- number: this.number,
78059
- // Mozilla
78060
- fileName: this.fileName,
78061
- lineNumber: this.lineNumber,
78062
- columnNumber: this.columnNumber,
78063
- stack: this.stack,
78064
- // Axios
78065
- config: utils$2.toJSONObject(this.config),
78066
- code: this.code,
78067
- status: this.response && this.response.status ? this.response.status : null
78068
- };
78069
- }
78070
- });
78071
-
78072
- const prototype$1 = AxiosError.prototype;
78073
- const descriptors = {};
78074
-
78075
- [
78076
- 'ERR_BAD_OPTION_VALUE',
78077
- 'ERR_BAD_OPTION',
78078
- 'ECONNABORTED',
78079
- 'ETIMEDOUT',
78080
- 'ERR_NETWORK',
78081
- 'ERR_FR_TOO_MANY_REDIRECTS',
78082
- 'ERR_DEPRECATED',
78083
- 'ERR_BAD_RESPONSE',
78084
- 'ERR_BAD_REQUEST',
78085
- 'ERR_CANCELED',
78086
- 'ERR_NOT_SUPPORT',
78087
- 'ERR_INVALID_URL'
78088
- // eslint-disable-next-line func-names
78089
- ].forEach(code => {
78090
- descriptors[code] = {value: code};
78091
- });
78092
-
78093
- Object.defineProperties(AxiosError, descriptors);
78094
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
78095
-
78096
- // eslint-disable-next-line func-names
78097
- AxiosError.from = (error, code, config, request, response, customProps) => {
78098
- const axiosError = Object.create(prototype$1);
78099
-
78100
- utils$2.toFlatObject(error, axiosError, function filter(obj) {
78101
- return obj !== Error.prototype;
78102
- }, prop => {
78103
- return prop !== 'isAxiosError';
78104
- });
78105
-
78106
- AxiosError.call(axiosError, error.message, code, config, request, response);
78107
-
78108
- axiosError.cause = error;
78109
-
78110
- axiosError.name = error.name;
78111
-
78112
- customProps && Object.assign(axiosError, customProps);
78113
-
78114
- return axiosError;
78115
- };
78116
-
78117
- // eslint-disable-next-line strict
78118
- var httpAdapter = null;
78119
-
78120
- /**
78121
- * Determines if the given thing is a array or js object.
78122
- *
78123
- * @param {string} thing - The object or array to be visited.
78124
- *
78125
- * @returns {boolean}
78126
- */
78127
- function isVisitable(thing) {
78128
- return utils$2.isPlainObject(thing) || utils$2.isArray(thing);
78129
- }
78130
-
78131
- /**
78132
- * It removes the brackets from the end of a string
78133
- *
78134
- * @param {string} key - The key of the parameter.
78135
- *
78136
- * @returns {string} the key without the brackets.
78137
- */
78138
- function removeBrackets(key) {
78139
- return utils$2.endsWith(key, '[]') ? key.slice(0, -2) : key;
78140
- }
78141
-
78142
- /**
78143
- * It takes a path, a key, and a boolean, and returns a string
78144
- *
78145
- * @param {string} path - The path to the current key.
78146
- * @param {string} key - The key of the current object being iterated over.
78147
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
78148
- *
78149
- * @returns {string} The path to the current key.
78150
- */
78151
- function renderKey(path, key, dots) {
78152
- if (!path) return key;
78153
- return path.concat(key).map(function each(token, i) {
78154
- // eslint-disable-next-line no-param-reassign
78155
- token = removeBrackets(token);
78156
- return !dots && i ? '[' + token + ']' : token;
78157
- }).join(dots ? '.' : '');
78158
- }
78159
-
78160
- /**
78161
- * If the array is an array and none of its elements are visitable, then it's a flat array.
78162
- *
78163
- * @param {Array<any>} arr - The array to check
78164
- *
78165
- * @returns {boolean}
78166
- */
78167
- function isFlatArray(arr) {
78168
- return utils$2.isArray(arr) && !arr.some(isVisitable);
78169
- }
78170
-
78171
- const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop) {
78172
- return /^is[A-Z]/.test(prop);
78173
- });
78174
-
78175
- /**
78176
- * Convert a data object to FormData
78177
- *
78178
- * @param {Object} obj
78179
- * @param {?Object} [formData]
78180
- * @param {?Object} [options]
78181
- * @param {Function} [options.visitor]
78182
- * @param {Boolean} [options.metaTokens = true]
78183
- * @param {Boolean} [options.dots = false]
78184
- * @param {?Boolean} [options.indexes = false]
78185
- *
78186
- * @returns {Object}
78187
- **/
78188
-
78189
- /**
78190
- * It converts an object into a FormData object
78191
- *
78192
- * @param {Object<any, any>} obj - The object to convert to form data.
78193
- * @param {string} formData - The FormData object to append to.
78194
- * @param {Object<string, any>} options
78195
- *
78196
- * @returns
78197
- */
78198
- function toFormData(obj, formData, options) {
78199
- if (!utils$2.isObject(obj)) {
78200
- throw new TypeError('target must be an object');
78201
- }
78202
-
78203
- // eslint-disable-next-line no-param-reassign
78204
- formData = formData || new (FormData)();
78205
-
78206
- // eslint-disable-next-line no-param-reassign
78207
- options = utils$2.toFlatObject(options, {
78208
- metaTokens: true,
78209
- dots: false,
78210
- indexes: false
78211
- }, false, function defined(option, source) {
78212
- // eslint-disable-next-line no-eq-null,eqeqeq
78213
- return !utils$2.isUndefined(source[option]);
78214
- });
78215
-
78216
- const metaTokens = options.metaTokens;
78217
- // eslint-disable-next-line no-use-before-define
78218
- const visitor = options.visitor || defaultVisitor;
78219
- const dots = options.dots;
78220
- const indexes = options.indexes;
78221
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
78222
- const useBlob = _Blob && utils$2.isSpecCompliantForm(formData);
78223
-
78224
- if (!utils$2.isFunction(visitor)) {
78225
- throw new TypeError('visitor must be a function');
78226
- }
78227
-
78228
- function convertValue(value) {
78229
- if (value === null) return '';
78230
-
78231
- if (utils$2.isDate(value)) {
78232
- return value.toISOString();
78233
- }
78234
-
78235
- if (!useBlob && utils$2.isBlob(value)) {
78236
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
78237
- }
78238
-
78239
- if (utils$2.isArrayBuffer(value) || utils$2.isTypedArray(value)) {
78240
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
78241
- }
78242
-
78243
- return value;
78244
- }
78245
-
78246
- /**
78247
- * Default visitor.
78248
- *
78249
- * @param {*} value
78250
- * @param {String|Number} key
78251
- * @param {Array<String|Number>} path
78252
- * @this {FormData}
78253
- *
78254
- * @returns {boolean} return true to visit the each prop of the value recursively
78255
- */
78256
- function defaultVisitor(value, key, path) {
78257
- let arr = value;
78258
-
78259
- if (value && !path && typeof value === 'object') {
78260
- if (utils$2.endsWith(key, '{}')) {
78261
- // eslint-disable-next-line no-param-reassign
78262
- key = metaTokens ? key : key.slice(0, -2);
78263
- // eslint-disable-next-line no-param-reassign
78264
- value = JSON.stringify(value);
78265
- } else if (
78266
- (utils$2.isArray(value) && isFlatArray(value)) ||
78267
- ((utils$2.isFileList(value) || utils$2.endsWith(key, '[]')) && (arr = utils$2.toArray(value))
78268
- )) {
78269
- // eslint-disable-next-line no-param-reassign
78270
- key = removeBrackets(key);
78271
-
78272
- arr.forEach(function each(el, index) {
78273
- !(utils$2.isUndefined(el) || el === null) && formData.append(
78274
- // eslint-disable-next-line no-nested-ternary
78275
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
78276
- convertValue(el)
78277
- );
78278
- });
78279
- return false;
78280
- }
78281
- }
78282
-
78283
- if (isVisitable(value)) {
78284
- return true;
78285
- }
78286
-
78287
- formData.append(renderKey(path, key, dots), convertValue(value));
78288
-
78289
- return false;
78290
- }
78291
-
78292
- const stack = [];
78293
-
78294
- const exposedHelpers = Object.assign(predicates, {
78295
- defaultVisitor,
78296
- convertValue,
78297
- isVisitable
78298
- });
78299
-
78300
- function build(value, path) {
78301
- if (utils$2.isUndefined(value)) return;
78302
-
78303
- if (stack.indexOf(value) !== -1) {
78304
- throw Error('Circular reference detected in ' + path.join('.'));
78305
- }
78306
-
78307
- stack.push(value);
78308
-
78309
- utils$2.forEach(value, function each(el, key) {
78310
- const result = !(utils$2.isUndefined(el) || el === null) && visitor.call(
78311
- formData, el, utils$2.isString(key) ? key.trim() : key, path, exposedHelpers
78312
- );
78313
-
78314
- if (result === true) {
78315
- build(el, path ? path.concat(key) : [key]);
78316
- }
78317
- });
78318
-
78319
- stack.pop();
78320
- }
78321
-
78322
- if (!utils$2.isObject(obj)) {
78323
- throw new TypeError('data must be an object');
78324
- }
78325
-
78326
- build(obj);
78327
-
78328
- return formData;
78329
- }
78330
-
78331
- /**
78332
- * It encodes a string by replacing all characters that are not in the unreserved set with
78333
- * their percent-encoded equivalents
78334
- *
78335
- * @param {string} str - The string to encode.
78336
- *
78337
- * @returns {string} The encoded string.
78338
- */
78339
- function encode$3(str) {
78340
- const charMap = {
78341
- '!': '%21',
78342
- "'": '%27',
78343
- '(': '%28',
78344
- ')': '%29',
78345
- '~': '%7E',
78346
- '%20': '+',
78347
- '%00': '\x00'
78348
- };
78349
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
78350
- return charMap[match];
78351
- });
78352
- }
78353
-
78354
- /**
78355
- * It takes a params object and converts it to a FormData object
78356
- *
78357
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
78358
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
78359
- *
78360
- * @returns {void}
78361
- */
78362
- function AxiosURLSearchParams(params, options) {
78363
- this._pairs = [];
78364
-
78365
- params && toFormData(params, this, options);
78366
- }
78367
-
78368
- const prototype = AxiosURLSearchParams.prototype;
78369
-
78370
- prototype.append = function append(name, value) {
78371
- this._pairs.push([name, value]);
78372
- };
78373
-
78374
- prototype.toString = function toString(encoder) {
78375
- const _encode = encoder ? function(value) {
78376
- return encoder.call(this, value, encode$3);
78377
- } : encode$3;
78378
-
78379
- return this._pairs.map(function each(pair) {
78380
- return _encode(pair[0]) + '=' + _encode(pair[1]);
78381
- }, '').join('&');
78382
- };
78383
-
78384
- /**
78385
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
78386
- * URI encoded counterparts
78387
- *
78388
- * @param {string} val The value to be encoded.
78389
- *
78390
- * @returns {string} The encoded value.
78391
- */
78392
- function encode$2(val) {
78393
- return encodeURIComponent(val).
78394
- replace(/%3A/gi, ':').
78395
- replace(/%24/g, '$').
78396
- replace(/%2C/gi, ',').
78397
- replace(/%20/g, '+').
78398
- replace(/%5B/gi, '[').
78399
- replace(/%5D/gi, ']');
78400
- }
78401
-
78402
- /**
78403
- * Build a URL by appending params to the end
78404
- *
78405
- * @param {string} url The base of the url (e.g., http://www.google.com)
78406
- * @param {object} [params] The params to be appended
78407
- * @param {?object} options
78408
- *
78409
- * @returns {string} The formatted url
78410
- */
78411
- function buildURL(url, params, options) {
78412
- /*eslint no-param-reassign:0*/
78413
- if (!params) {
78414
- return url;
78415
- }
78416
-
78417
- const _encode = options && options.encode || encode$2;
78418
-
78419
- const serializeFn = options && options.serialize;
78420
-
78421
- let serializedParams;
78422
-
78423
- if (serializeFn) {
78424
- serializedParams = serializeFn(params, options);
78425
- } else {
78426
- serializedParams = utils$2.isURLSearchParams(params) ?
78427
- params.toString() :
78428
- new AxiosURLSearchParams(params, options).toString(_encode);
78429
- }
78430
-
78431
- if (serializedParams) {
78432
- const hashmarkIndex = url.indexOf("#");
78433
-
78434
- if (hashmarkIndex !== -1) {
78435
- url = url.slice(0, hashmarkIndex);
78436
- }
78437
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
78438
- }
78439
-
78440
- return url;
78441
- }
78442
-
78443
- class InterceptorManager {
78444
- constructor() {
78445
- this.handlers = [];
78446
- }
78447
-
78448
- /**
78449
- * Add a new interceptor to the stack
78450
- *
78451
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
78452
- * @param {Function} rejected The function to handle `reject` for a `Promise`
78453
- *
78454
- * @return {Number} An ID used to remove interceptor later
78455
- */
78456
- use(fulfilled, rejected, options) {
78457
- this.handlers.push({
78458
- fulfilled,
78459
- rejected,
78460
- synchronous: options ? options.synchronous : false,
78461
- runWhen: options ? options.runWhen : null
78462
- });
78463
- return this.handlers.length - 1;
78464
- }
78465
-
78466
- /**
78467
- * Remove an interceptor from the stack
78468
- *
78469
- * @param {Number} id The ID that was returned by `use`
78470
- *
78471
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
78472
- */
78473
- eject(id) {
78474
- if (this.handlers[id]) {
78475
- this.handlers[id] = null;
78476
- }
78477
- }
78478
-
78479
- /**
78480
- * Clear all interceptors from the stack
78481
- *
78482
- * @returns {void}
78483
- */
78484
- clear() {
78485
- if (this.handlers) {
78486
- this.handlers = [];
78487
- }
78488
- }
78489
-
78490
- /**
78491
- * Iterate over all the registered interceptors
78492
- *
78493
- * This method is particularly useful for skipping over any
78494
- * interceptors that may have become `null` calling `eject`.
78495
- *
78496
- * @param {Function} fn The function to call for each interceptor
78497
- *
78498
- * @returns {void}
78499
- */
78500
- forEach(fn) {
78501
- utils$2.forEach(this.handlers, function forEachHandler(h) {
78502
- if (h !== null) {
78503
- fn(h);
78504
- }
78505
- });
78506
- }
78507
- }
78508
-
78509
- var InterceptorManager$1 = InterceptorManager;
78510
-
78511
- var transitionalDefaults = {
78512
- silentJSONParsing: true,
78513
- forcedJSONParsing: true,
78514
- clarifyTimeoutError: false
78515
- };
78516
-
78517
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
78518
-
78519
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
78520
-
78521
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
78522
-
78523
- var platform$1 = {
78524
- isBrowser: true,
78525
- classes: {
78526
- URLSearchParams: URLSearchParams$1,
78527
- FormData: FormData$1,
78528
- Blob: Blob$1
78529
- },
78530
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
78531
- };
78532
-
78533
- const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
78534
-
78535
- /**
78536
- * Determine if we're running in a standard browser environment
78537
- *
78538
- * This allows axios to run in a web worker, and react-native.
78539
- * Both environments support XMLHttpRequest, but not fully standard globals.
78540
- *
78541
- * web workers:
78542
- * typeof window -> undefined
78543
- * typeof document -> undefined
78544
- *
78545
- * react-native:
78546
- * navigator.product -> 'ReactNative'
78547
- * nativescript
78548
- * navigator.product -> 'NativeScript' or 'NS'
78549
- *
78550
- * @returns {boolean}
78551
- */
78552
- const hasStandardBrowserEnv = (
78553
- (product) => {
78554
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
78555
- })(typeof navigator !== 'undefined' && navigator.product);
78556
-
78557
- /**
78558
- * Determine if we're running in a standard browser webWorker environment
78559
- *
78560
- * Although the `isStandardBrowserEnv` method indicates that
78561
- * `allows axios to run in a web worker`, the WebWorker will still be
78562
- * filtered out due to its judgment standard
78563
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
78564
- * This leads to a problem when axios post `FormData` in webWorker
78565
- */
78566
- const hasStandardBrowserWebWorkerEnv = (() => {
78567
- return (
78568
- typeof WorkerGlobalScope !== 'undefined' &&
78569
- // eslint-disable-next-line no-undef
78570
- self instanceof WorkerGlobalScope &&
78571
- typeof self.importScripts === 'function'
78572
- );
78573
- })();
78574
-
78575
- var utils$1 = /*#__PURE__*/Object.freeze({
78576
- __proto__: null,
78577
- hasBrowserEnv: hasBrowserEnv,
78578
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
78579
- hasStandardBrowserEnv: hasStandardBrowserEnv
78580
- });
78581
-
78582
- var platform = {
78583
- ...utils$1,
78584
- ...platform$1
78585
- };
78586
-
78587
- function toURLEncodedForm(data, options) {
78588
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
78589
- visitor: function(value, key, path, helpers) {
78590
- if (platform.isNode && utils$2.isBuffer(value)) {
78591
- this.append(key, value.toString('base64'));
78592
- return false;
78593
- }
78594
-
78595
- return helpers.defaultVisitor.apply(this, arguments);
78596
- }
78597
- }, options));
78598
- }
78599
-
78600
- /**
78601
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
78602
- *
78603
- * @param {string} name - The name of the property to get.
78604
- *
78605
- * @returns An array of strings.
78606
- */
78607
- function parsePropPath(name) {
78608
- // foo[x][y][z]
78609
- // foo.x.y.z
78610
- // foo-x-y-z
78611
- // foo x y z
78612
- return utils$2.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
78613
- return match[0] === '[]' ? '' : match[1] || match[0];
78614
- });
78615
- }
78616
-
78617
- /**
78618
- * Convert an array to an object.
78619
- *
78620
- * @param {Array<any>} arr - The array to convert to an object.
78621
- *
78622
- * @returns An object with the same keys and values as the array.
78623
- */
78624
- function arrayToObject(arr) {
78625
- const obj = {};
78626
- const keys = Object.keys(arr);
78627
- let i;
78628
- const len = keys.length;
78629
- let key;
78630
- for (i = 0; i < len; i++) {
78631
- key = keys[i];
78632
- obj[key] = arr[key];
78633
- }
78634
- return obj;
78635
- }
78636
-
78637
- /**
78638
- * It takes a FormData object and returns a JavaScript object
78639
- *
78640
- * @param {string} formData The FormData object to convert to JSON.
78641
- *
78642
- * @returns {Object<string, any> | null} The converted object.
78643
- */
78644
- function formDataToJSON(formData) {
78645
- function buildPath(path, value, target, index) {
78646
- let name = path[index++];
78647
-
78648
- if (name === '__proto__') return true;
78649
-
78650
- const isNumericKey = Number.isFinite(+name);
78651
- const isLast = index >= path.length;
78652
- name = !name && utils$2.isArray(target) ? target.length : name;
78653
-
78654
- if (isLast) {
78655
- if (utils$2.hasOwnProp(target, name)) {
78656
- target[name] = [target[name], value];
78657
- } else {
78658
- target[name] = value;
78659
- }
78660
-
78661
- return !isNumericKey;
78662
- }
78663
-
78664
- if (!target[name] || !utils$2.isObject(target[name])) {
78665
- target[name] = [];
78666
- }
78667
-
78668
- const result = buildPath(path, value, target[name], index);
78669
-
78670
- if (result && utils$2.isArray(target[name])) {
78671
- target[name] = arrayToObject(target[name]);
78672
- }
78673
-
78674
- return !isNumericKey;
78675
- }
78676
-
78677
- if (utils$2.isFormData(formData) && utils$2.isFunction(formData.entries)) {
78678
- const obj = {};
78679
-
78680
- utils$2.forEachEntry(formData, (name, value) => {
78681
- buildPath(parsePropPath(name), value, obj, 0);
78682
- });
78683
-
78684
- return obj;
78685
- }
78686
-
78687
- return null;
78688
- }
78689
-
78690
- /**
78691
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
78692
- * of the input
78693
- *
78694
- * @param {any} rawValue - The value to be stringified.
78695
- * @param {Function} parser - A function that parses a string into a JavaScript object.
78696
- * @param {Function} encoder - A function that takes a value and returns a string.
78697
- *
78698
- * @returns {string} A stringified version of the rawValue.
78699
- */
78700
- function stringifySafely(rawValue, parser, encoder) {
78701
- if (utils$2.isString(rawValue)) {
78702
- try {
78703
- (parser || JSON.parse)(rawValue);
78704
- return utils$2.trim(rawValue);
78705
- } catch (e) {
78706
- if (e.name !== 'SyntaxError') {
78707
- throw e;
78708
- }
78709
- }
78710
- }
78711
-
78712
- return (encoder || JSON.stringify)(rawValue);
78713
- }
78714
-
78715
- const defaults = {
78716
-
78717
- transitional: transitionalDefaults,
78718
-
78719
- adapter: ['xhr', 'http'],
78720
-
78721
- transformRequest: [function transformRequest(data, headers) {
78722
- const contentType = headers.getContentType() || '';
78723
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
78724
- const isObjectPayload = utils$2.isObject(data);
78725
-
78726
- if (isObjectPayload && utils$2.isHTMLForm(data)) {
78727
- data = new FormData(data);
78728
- }
78729
-
78730
- const isFormData = utils$2.isFormData(data);
78731
-
78732
- if (isFormData) {
78733
- if (!hasJSONContentType) {
78734
- return data;
78735
- }
78736
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
78737
- }
78738
-
78739
- if (utils$2.isArrayBuffer(data) ||
78740
- utils$2.isBuffer(data) ||
78741
- utils$2.isStream(data) ||
78742
- utils$2.isFile(data) ||
78743
- utils$2.isBlob(data)
78744
- ) {
78745
- return data;
78746
- }
78747
- if (utils$2.isArrayBufferView(data)) {
78748
- return data.buffer;
78749
- }
78750
- if (utils$2.isURLSearchParams(data)) {
78751
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
78752
- return data.toString();
78753
- }
78754
-
78755
- let isFileList;
78756
-
78757
- if (isObjectPayload) {
78758
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
78759
- return toURLEncodedForm(data, this.formSerializer).toString();
78760
- }
78761
-
78762
- if ((isFileList = utils$2.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
78763
- const _FormData = this.env && this.env.FormData;
78764
-
78765
- return toFormData(
78766
- isFileList ? {'files[]': data} : data,
78767
- _FormData && new _FormData(),
78768
- this.formSerializer
78769
- );
78770
- }
78771
- }
78772
-
78773
- if (isObjectPayload || hasJSONContentType ) {
78774
- headers.setContentType('application/json', false);
78775
- return stringifySafely(data);
78776
- }
78777
-
78778
- return data;
78779
- }],
78780
-
78781
- transformResponse: [function transformResponse(data) {
78782
- const transitional = this.transitional || defaults.transitional;
78783
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
78784
- const JSONRequested = this.responseType === 'json';
78785
-
78786
- if (data && utils$2.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
78787
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
78788
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
78789
-
78790
- try {
78791
- return JSON.parse(data);
78792
- } catch (e) {
78793
- if (strictJSONParsing) {
78794
- if (e.name === 'SyntaxError') {
78795
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
78796
- }
78797
- throw e;
78798
- }
78799
- }
78800
- }
78801
-
78802
- return data;
78803
- }],
78804
-
78805
- /**
78806
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
78807
- * timeout is not created.
78808
- */
78809
- timeout: 0,
78810
-
78811
- xsrfCookieName: 'XSRF-TOKEN',
78812
- xsrfHeaderName: 'X-XSRF-TOKEN',
78813
-
78814
- maxContentLength: -1,
78815
- maxBodyLength: -1,
78816
-
78817
- env: {
78818
- FormData: platform.classes.FormData,
78819
- Blob: platform.classes.Blob
78820
- },
78821
-
78822
- validateStatus: function validateStatus(status) {
78823
- return status >= 200 && status < 300;
78824
- },
78825
-
78826
- headers: {
78827
- common: {
78828
- 'Accept': 'application/json, text/plain, */*',
78829
- 'Content-Type': undefined
78830
- }
78831
- }
78832
- };
78833
-
78834
- utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
78835
- defaults.headers[method] = {};
78836
- });
78837
-
78838
- var defaults$1 = defaults;
78839
-
78840
- // RawAxiosHeaders whose duplicates are ignored by node
78841
- // c.f. https://nodejs.org/api/http.html#http_message_headers
78842
- const ignoreDuplicateOf = utils$2.toObjectSet([
78843
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
78844
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
78845
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
78846
- 'referer', 'retry-after', 'user-agent'
78847
- ]);
78848
-
78849
- /**
78850
- * Parse headers into an object
78851
- *
78852
- * ```
78853
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
78854
- * Content-Type: application/json
78855
- * Connection: keep-alive
78856
- * Transfer-Encoding: chunked
78857
- * ```
78858
- *
78859
- * @param {String} rawHeaders Headers needing to be parsed
78860
- *
78861
- * @returns {Object} Headers parsed into an object
78862
- */
78863
- var parseHeaders = rawHeaders => {
78864
- const parsed = {};
78865
- let key;
78866
- let val;
78867
- let i;
78868
-
78869
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
78870
- i = line.indexOf(':');
78871
- key = line.substring(0, i).trim().toLowerCase();
78872
- val = line.substring(i + 1).trim();
78873
-
78874
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
78875
- return;
78876
- }
78877
-
78878
- if (key === 'set-cookie') {
78879
- if (parsed[key]) {
78880
- parsed[key].push(val);
78881
- } else {
78882
- parsed[key] = [val];
78883
- }
78884
- } else {
78885
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
78886
- }
78887
- });
78888
-
78889
- return parsed;
78890
- };
78891
-
78892
- const $internals = Symbol('internals');
78893
-
78894
- function normalizeHeader(header) {
78895
- return header && String(header).trim().toLowerCase();
78896
- }
78897
-
78898
- function normalizeValue(value) {
78899
- if (value === false || value == null) {
78900
- return value;
78901
- }
78902
-
78903
- return utils$2.isArray(value) ? value.map(normalizeValue) : String(value);
78904
- }
78905
-
78906
- function parseTokens(str) {
78907
- const tokens = Object.create(null);
78908
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
78909
- let match;
78910
-
78911
- while ((match = tokensRE.exec(str))) {
78912
- tokens[match[1]] = match[2];
78913
- }
78914
-
78915
- return tokens;
78916
- }
78917
-
78918
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
78919
-
78920
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
78921
- if (utils$2.isFunction(filter)) {
78922
- return filter.call(this, value, header);
78923
- }
78924
-
78925
- if (isHeaderNameFilter) {
78926
- value = header;
78927
- }
78928
-
78929
- if (!utils$2.isString(value)) return;
78930
-
78931
- if (utils$2.isString(filter)) {
78932
- return value.indexOf(filter) !== -1;
78933
- }
78934
-
78935
- if (utils$2.isRegExp(filter)) {
78936
- return filter.test(value);
78937
- }
78938
- }
78939
-
78940
- function formatHeader(header) {
78941
- return header.trim()
78942
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
78943
- return char.toUpperCase() + str;
78944
- });
78945
- }
78946
-
78947
- function buildAccessors(obj, header) {
78948
- const accessorName = utils$2.toCamelCase(' ' + header);
78949
-
78950
- ['get', 'set', 'has'].forEach(methodName => {
78951
- Object.defineProperty(obj, methodName + accessorName, {
78952
- value: function(arg1, arg2, arg3) {
78953
- return this[methodName].call(this, header, arg1, arg2, arg3);
78954
- },
78955
- configurable: true
78956
- });
78957
- });
78958
- }
78959
-
78960
- class AxiosHeaders {
78961
- constructor(headers) {
78962
- headers && this.set(headers);
78963
- }
78964
-
78965
- set(header, valueOrRewrite, rewrite) {
78966
- const self = this;
78967
-
78968
- function setHeader(_value, _header, _rewrite) {
78969
- const lHeader = normalizeHeader(_header);
78970
-
78971
- if (!lHeader) {
78972
- throw new Error('header name must be a non-empty string');
78973
- }
78974
-
78975
- const key = utils$2.findKey(self, lHeader);
78976
-
78977
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
78978
- self[key || _header] = normalizeValue(_value);
78979
- }
78980
- }
78981
-
78982
- const setHeaders = (headers, _rewrite) =>
78983
- utils$2.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
78984
-
78985
- if (utils$2.isPlainObject(header) || header instanceof this.constructor) {
78986
- setHeaders(header, valueOrRewrite);
78987
- } else if(utils$2.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
78988
- setHeaders(parseHeaders(header), valueOrRewrite);
78989
- } else {
78990
- header != null && setHeader(valueOrRewrite, header, rewrite);
78991
- }
78992
-
78993
- return this;
78994
- }
78995
-
78996
- get(header, parser) {
78997
- header = normalizeHeader(header);
78998
-
78999
- if (header) {
79000
- const key = utils$2.findKey(this, header);
79001
-
79002
- if (key) {
79003
- const value = this[key];
79004
-
79005
- if (!parser) {
79006
- return value;
79007
- }
79008
-
79009
- if (parser === true) {
79010
- return parseTokens(value);
79011
- }
79012
-
79013
- if (utils$2.isFunction(parser)) {
79014
- return parser.call(this, value, key);
79015
- }
79016
-
79017
- if (utils$2.isRegExp(parser)) {
79018
- return parser.exec(value);
79019
- }
79020
-
79021
- throw new TypeError('parser must be boolean|regexp|function');
79022
- }
79023
- }
79024
- }
79025
-
79026
- has(header, matcher) {
79027
- header = normalizeHeader(header);
79028
-
79029
- if (header) {
79030
- const key = utils$2.findKey(this, header);
79031
-
79032
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
79033
- }
79034
-
79035
- return false;
79036
- }
79037
-
79038
- delete(header, matcher) {
79039
- const self = this;
79040
- let deleted = false;
79041
-
79042
- function deleteHeader(_header) {
79043
- _header = normalizeHeader(_header);
79044
-
79045
- if (_header) {
79046
- const key = utils$2.findKey(self, _header);
79047
-
79048
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
79049
- delete self[key];
79050
-
79051
- deleted = true;
79052
- }
79053
- }
79054
- }
79055
-
79056
- if (utils$2.isArray(header)) {
79057
- header.forEach(deleteHeader);
79058
- } else {
79059
- deleteHeader(header);
79060
- }
79061
-
79062
- return deleted;
79063
- }
79064
-
79065
- clear(matcher) {
79066
- const keys = Object.keys(this);
79067
- let i = keys.length;
79068
- let deleted = false;
79069
-
79070
- while (i--) {
79071
- const key = keys[i];
79072
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
79073
- delete this[key];
79074
- deleted = true;
79075
- }
79076
- }
79077
-
79078
- return deleted;
79079
- }
79080
-
79081
- normalize(format) {
79082
- const self = this;
79083
- const headers = {};
79084
-
79085
- utils$2.forEach(this, (value, header) => {
79086
- const key = utils$2.findKey(headers, header);
79087
-
79088
- if (key) {
79089
- self[key] = normalizeValue(value);
79090
- delete self[header];
79091
- return;
79092
- }
79093
-
79094
- const normalized = format ? formatHeader(header) : String(header).trim();
79095
-
79096
- if (normalized !== header) {
79097
- delete self[header];
79098
- }
79099
-
79100
- self[normalized] = normalizeValue(value);
79101
-
79102
- headers[normalized] = true;
79103
- });
79104
-
79105
- return this;
79106
- }
79107
-
79108
- concat(...targets) {
79109
- return this.constructor.concat(this, ...targets);
79110
- }
79111
-
79112
- toJSON(asStrings) {
79113
- const obj = Object.create(null);
79114
-
79115
- utils$2.forEach(this, (value, header) => {
79116
- value != null && value !== false && (obj[header] = asStrings && utils$2.isArray(value) ? value.join(', ') : value);
79117
- });
79118
-
79119
- return obj;
79120
- }
79121
-
79122
- [Symbol.iterator]() {
79123
- return Object.entries(this.toJSON())[Symbol.iterator]();
79124
- }
79125
-
79126
- toString() {
79127
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
79128
- }
79129
-
79130
- get [Symbol.toStringTag]() {
79131
- return 'AxiosHeaders';
79132
- }
79133
-
79134
- static from(thing) {
79135
- return thing instanceof this ? thing : new this(thing);
79136
- }
79137
-
79138
- static concat(first, ...targets) {
79139
- const computed = new this(first);
79140
-
79141
- targets.forEach((target) => computed.set(target));
79142
-
79143
- return computed;
79144
- }
79145
-
79146
- static accessor(header) {
79147
- const internals = this[$internals] = (this[$internals] = {
79148
- accessors: {}
79149
- });
79150
-
79151
- const accessors = internals.accessors;
79152
- const prototype = this.prototype;
79153
-
79154
- function defineAccessor(_header) {
79155
- const lHeader = normalizeHeader(_header);
79156
-
79157
- if (!accessors[lHeader]) {
79158
- buildAccessors(prototype, _header);
79159
- accessors[lHeader] = true;
79160
- }
79161
- }
79162
-
79163
- utils$2.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
79164
-
79165
- return this;
79166
- }
79167
- }
79168
-
79169
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
79170
-
79171
- // reserved names hotfix
79172
- utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
79173
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
79174
- return {
79175
- get: () => value,
79176
- set(headerValue) {
79177
- this[mapped] = headerValue;
79178
- }
79179
- }
79180
- });
79181
-
79182
- utils$2.freezeMethods(AxiosHeaders);
79183
-
79184
- var AxiosHeaders$1 = AxiosHeaders;
79185
-
79186
- /**
79187
- * Transform the data for a request or a response
79188
- *
79189
- * @param {Array|Function} fns A single function or Array of functions
79190
- * @param {?Object} response The response object
79191
- *
79192
- * @returns {*} The resulting transformed data
79193
- */
79194
- function transformData(fns, response) {
79195
- const config = this || defaults$1;
79196
- const context = response || config;
79197
- const headers = AxiosHeaders$1.from(context.headers);
79198
- let data = context.data;
79199
-
79200
- utils$2.forEach(fns, function transform(fn) {
79201
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
79202
- });
79203
-
79204
- headers.normalize();
79205
-
79206
- return data;
79207
- }
79208
-
79209
- function isCancel(value) {
79210
- return !!(value && value.__CANCEL__);
79211
- }
79212
-
79213
- /**
79214
- * A `CanceledError` is an object that is thrown when an operation is canceled.
79215
- *
79216
- * @param {string=} message The message.
79217
- * @param {Object=} config The config.
79218
- * @param {Object=} request The request.
79219
- *
79220
- * @returns {CanceledError} The created error.
79221
- */
79222
- function CanceledError(message, config, request) {
79223
- // eslint-disable-next-line no-eq-null,eqeqeq
79224
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
79225
- this.name = 'CanceledError';
79226
- }
79227
-
79228
- utils$2.inherits(CanceledError, AxiosError, {
79229
- __CANCEL__: true
79230
- });
79231
-
79232
- /**
79233
- * Resolve or reject a Promise based on response status.
79234
- *
79235
- * @param {Function} resolve A function that resolves the promise.
79236
- * @param {Function} reject A function that rejects the promise.
79237
- * @param {object} response The response.
79238
- *
79239
- * @returns {object} The response.
79240
- */
79241
- function settle(resolve, reject, response) {
79242
- const validateStatus = response.config.validateStatus;
79243
- if (!response.status || !validateStatus || validateStatus(response.status)) {
79244
- resolve(response);
79245
- } else {
79246
- reject(new AxiosError(
79247
- 'Request failed with status code ' + response.status,
79248
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
79249
- response.config,
79250
- response.request,
79251
- response
79252
- ));
79253
- }
79254
- }
79255
-
79256
- var cookies = platform.hasStandardBrowserEnv ?
79257
-
79258
- // Standard browser envs support document.cookie
79259
- {
79260
- write(name, value, expires, path, domain, secure) {
79261
- const cookie = [name + '=' + encodeURIComponent(value)];
79262
-
79263
- utils$2.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
79264
-
79265
- utils$2.isString(path) && cookie.push('path=' + path);
79266
-
79267
- utils$2.isString(domain) && cookie.push('domain=' + domain);
79268
-
79269
- secure === true && cookie.push('secure');
79270
-
79271
- document.cookie = cookie.join('; ');
79272
- },
79273
-
79274
- read(name) {
79275
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
79276
- return (match ? decodeURIComponent(match[3]) : null);
79277
- },
79278
-
79279
- remove(name) {
79280
- this.write(name, '', Date.now() - 86400000);
79281
- }
79282
- }
79283
-
79284
- :
79285
-
79286
- // Non-standard browser env (web workers, react-native) lack needed support.
79287
- {
79288
- write() {},
79289
- read() {
79290
- return null;
79291
- },
79292
- remove() {}
79293
- };
79294
-
79295
- /**
79296
- * Determines whether the specified URL is absolute
79297
- *
79298
- * @param {string} url The URL to test
79299
- *
79300
- * @returns {boolean} True if the specified URL is absolute, otherwise false
79301
- */
79302
- function isAbsoluteURL(url) {
79303
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
79304
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
79305
- // by any combination of letters, digits, plus, period, or hyphen.
79306
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
79307
- }
79308
-
79309
- /**
79310
- * Creates a new URL by combining the specified URLs
79311
- *
79312
- * @param {string} baseURL The base URL
79313
- * @param {string} relativeURL The relative URL
79314
- *
79315
- * @returns {string} The combined URL
79316
- */
79317
- function combineURLs(baseURL, relativeURL) {
79318
- return relativeURL
79319
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
79320
- : baseURL;
79321
- }
79322
-
79323
- /**
79324
- * Creates a new URL by combining the baseURL with the requestedURL,
79325
- * only when the requestedURL is not already an absolute URL.
79326
- * If the requestURL is absolute, this function returns the requestedURL untouched.
79327
- *
79328
- * @param {string} baseURL The base URL
79329
- * @param {string} requestedURL Absolute or relative URL to combine
79330
- *
79331
- * @returns {string} The combined full path
79332
- */
79333
- function buildFullPath(baseURL, requestedURL) {
79334
- if (baseURL && !isAbsoluteURL(requestedURL)) {
79335
- return combineURLs(baseURL, requestedURL);
79336
- }
79337
- return requestedURL;
79338
- }
79339
-
79340
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
79341
-
79342
- // Standard browser envs have full support of the APIs needed to test
79343
- // whether the request URL is of the same origin as current location.
79344
- (function standardBrowserEnv() {
79345
- const msie = /(msie|trident)/i.test(navigator.userAgent);
79346
- const urlParsingNode = document.createElement('a');
79347
- let originURL;
79348
-
79349
- /**
79350
- * Parse a URL to discover its components
79351
- *
79352
- * @param {String} url The URL to be parsed
79353
- * @returns {Object}
79354
- */
79355
- function resolveURL(url) {
79356
- let href = url;
79357
-
79358
- if (msie) {
79359
- // IE needs attribute set twice to normalize properties
79360
- urlParsingNode.setAttribute('href', href);
79361
- href = urlParsingNode.href;
79362
- }
79363
-
79364
- urlParsingNode.setAttribute('href', href);
79365
-
79366
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
79367
- return {
79368
- href: urlParsingNode.href,
79369
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
79370
- host: urlParsingNode.host,
79371
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
79372
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
79373
- hostname: urlParsingNode.hostname,
79374
- port: urlParsingNode.port,
79375
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
79376
- urlParsingNode.pathname :
79377
- '/' + urlParsingNode.pathname
79378
- };
79379
- }
79380
-
79381
- originURL = resolveURL(window.location.href);
79382
-
79383
- /**
79384
- * Determine if a URL shares the same origin as the current location
79385
- *
79386
- * @param {String} requestURL The URL to test
79387
- * @returns {boolean} True if URL shares the same origin, otherwise false
79388
- */
79389
- return function isURLSameOrigin(requestURL) {
79390
- const parsed = (utils$2.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
79391
- return (parsed.protocol === originURL.protocol &&
79392
- parsed.host === originURL.host);
79393
- };
79394
- })() :
79395
-
79396
- // Non standard browser envs (web workers, react-native) lack needed support.
79397
- (function nonStandardBrowserEnv() {
79398
- return function isURLSameOrigin() {
79399
- return true;
79400
- };
79401
- })();
79402
-
79403
- function parseProtocol(url) {
79404
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
79405
- return match && match[1] || '';
79406
- }
79407
-
79408
- /**
79409
- * Calculate data maxRate
79410
- * @param {Number} [samplesCount= 10]
79411
- * @param {Number} [min= 1000]
79412
- * @returns {Function}
79413
- */
79414
- function speedometer(samplesCount, min) {
79415
- samplesCount = samplesCount || 10;
79416
- const bytes = new Array(samplesCount);
79417
- const timestamps = new Array(samplesCount);
79418
- let head = 0;
79419
- let tail = 0;
79420
- let firstSampleTS;
79421
-
79422
- min = min !== undefined ? min : 1000;
79423
-
79424
- return function push(chunkLength) {
79425
- const now = Date.now();
79426
-
79427
- const startedAt = timestamps[tail];
79428
-
79429
- if (!firstSampleTS) {
79430
- firstSampleTS = now;
79431
- }
79432
-
79433
- bytes[head] = chunkLength;
79434
- timestamps[head] = now;
79435
-
79436
- let i = tail;
79437
- let bytesCount = 0;
79438
-
79439
- while (i !== head) {
79440
- bytesCount += bytes[i++];
79441
- i = i % samplesCount;
79442
- }
79443
-
79444
- head = (head + 1) % samplesCount;
79445
-
79446
- if (head === tail) {
79447
- tail = (tail + 1) % samplesCount;
79448
- }
79449
-
79450
- if (now - firstSampleTS < min) {
79451
- return;
79452
- }
79453
-
79454
- const passed = startedAt && now - startedAt;
79455
-
79456
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
79457
- };
79458
- }
79459
-
79460
- function progressEventReducer(listener, isDownloadStream) {
79461
- let bytesNotified = 0;
79462
- const _speedometer = speedometer(50, 250);
79463
-
79464
- return e => {
79465
- const loaded = e.loaded;
79466
- const total = e.lengthComputable ? e.total : undefined;
79467
- const progressBytes = loaded - bytesNotified;
79468
- const rate = _speedometer(progressBytes);
79469
- const inRange = loaded <= total;
79470
-
79471
- bytesNotified = loaded;
79472
-
79473
- const data = {
79474
- loaded,
79475
- total,
79476
- progress: total ? (loaded / total) : undefined,
79477
- bytes: progressBytes,
79478
- rate: rate ? rate : undefined,
79479
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
79480
- event: e
79481
- };
79482
-
79483
- data[isDownloadStream ? 'download' : 'upload'] = true;
79484
-
79485
- listener(data);
79486
- };
79487
- }
79488
-
79489
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
79490
-
79491
- var xhrAdapter = isXHRAdapterSupported && function (config) {
79492
- return new Promise(function dispatchXhrRequest(resolve, reject) {
79493
- let requestData = config.data;
79494
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
79495
- let {responseType, withXSRFToken} = config;
79496
- let onCanceled;
79497
- function done() {
79498
- if (config.cancelToken) {
79499
- config.cancelToken.unsubscribe(onCanceled);
79500
- }
79501
-
79502
- if (config.signal) {
79503
- config.signal.removeEventListener('abort', onCanceled);
79504
- }
79505
- }
79506
-
79507
- let contentType;
79508
-
79509
- if (utils$2.isFormData(requestData)) {
79510
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
79511
- requestHeaders.setContentType(false); // Let the browser set it
79512
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
79513
- // fix semicolon duplication issue for ReactNative FormData implementation
79514
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
79515
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
79516
- }
79517
- }
79518
-
79519
- let request = new XMLHttpRequest();
79520
-
79521
- // HTTP basic authentication
79522
- if (config.auth) {
79523
- const username = config.auth.username || '';
79524
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
79525
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
79526
- }
79527
-
79528
- const fullPath = buildFullPath(config.baseURL, config.url);
79529
-
79530
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
79531
-
79532
- // Set the request timeout in MS
79533
- request.timeout = config.timeout;
79534
-
79535
- function onloadend() {
79536
- if (!request) {
79537
- return;
79538
- }
79539
- // Prepare the response
79540
- const responseHeaders = AxiosHeaders$1.from(
79541
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
79542
- );
79543
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
79544
- request.responseText : request.response;
79545
- const response = {
79546
- data: responseData,
79547
- status: request.status,
79548
- statusText: request.statusText,
79549
- headers: responseHeaders,
79550
- config,
79551
- request
79552
- };
79553
-
79554
- settle(function _resolve(value) {
79555
- resolve(value);
79556
- done();
79557
- }, function _reject(err) {
79558
- reject(err);
79559
- done();
79560
- }, response);
79561
-
79562
- // Clean up request
79563
- request = null;
79564
- }
79565
-
79566
- if ('onloadend' in request) {
79567
- // Use onloadend if available
79568
- request.onloadend = onloadend;
79569
- } else {
79570
- // Listen for ready state to emulate onloadend
79571
- request.onreadystatechange = function handleLoad() {
79572
- if (!request || request.readyState !== 4) {
79573
- return;
79574
- }
79575
-
79576
- // The request errored out and we didn't get a response, this will be
79577
- // handled by onerror instead
79578
- // With one exception: request that using file: protocol, most browsers
79579
- // will return status as 0 even though it's a successful request
79580
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
79581
- return;
79582
- }
79583
- // readystate handler is calling before onerror or ontimeout handlers,
79584
- // so we should call onloadend on the next 'tick'
79585
- setTimeout(onloadend);
79586
- };
79587
- }
79588
-
79589
- // Handle browser request cancellation (as opposed to a manual cancellation)
79590
- request.onabort = function handleAbort() {
79591
- if (!request) {
79592
- return;
79593
- }
79594
-
79595
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
79596
-
79597
- // Clean up request
79598
- request = null;
79599
- };
79600
-
79601
- // Handle low level network errors
79602
- request.onerror = function handleError() {
79603
- // Real errors are hidden from us by the browser
79604
- // onerror should only fire if it's a network error
79605
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
79606
-
79607
- // Clean up request
79608
- request = null;
79609
- };
79610
-
79611
- // Handle timeout
79612
- request.ontimeout = function handleTimeout() {
79613
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
79614
- const transitional = config.transitional || transitionalDefaults;
79615
- if (config.timeoutErrorMessage) {
79616
- timeoutErrorMessage = config.timeoutErrorMessage;
79617
- }
79618
- reject(new AxiosError(
79619
- timeoutErrorMessage,
79620
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
79621
- config,
79622
- request));
79623
-
79624
- // Clean up request
79625
- request = null;
79626
- };
79627
-
79628
- // Add xsrf header
79629
- // This is only done if running in a standard browser environment.
79630
- // Specifically not if we're in a web worker, or react-native.
79631
- if(platform.hasStandardBrowserEnv) {
79632
- withXSRFToken && utils$2.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
79633
-
79634
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
79635
- // Add xsrf header
79636
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
79637
-
79638
- if (xsrfValue) {
79639
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
79640
- }
79641
- }
79642
- }
79643
-
79644
- // Remove Content-Type if data is undefined
79645
- requestData === undefined && requestHeaders.setContentType(null);
79646
-
79647
- // Add headers to the request
79648
- if ('setRequestHeader' in request) {
79649
- utils$2.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
79650
- request.setRequestHeader(key, val);
79651
- });
79652
- }
79653
-
79654
- // Add withCredentials to request if needed
79655
- if (!utils$2.isUndefined(config.withCredentials)) {
79656
- request.withCredentials = !!config.withCredentials;
79657
- }
79658
-
79659
- // Add responseType to request if needed
79660
- if (responseType && responseType !== 'json') {
79661
- request.responseType = config.responseType;
79662
- }
79663
-
79664
- // Handle progress if needed
79665
- if (typeof config.onDownloadProgress === 'function') {
79666
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
79667
- }
79668
-
79669
- // Not all browsers support upload events
79670
- if (typeof config.onUploadProgress === 'function' && request.upload) {
79671
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
79672
- }
79673
-
79674
- if (config.cancelToken || config.signal) {
79675
- // Handle cancellation
79676
- // eslint-disable-next-line func-names
79677
- onCanceled = cancel => {
79678
- if (!request) {
79679
- return;
79680
- }
79681
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
79682
- request.abort();
79683
- request = null;
79684
- };
79685
-
79686
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
79687
- if (config.signal) {
79688
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
79689
- }
79690
- }
79691
-
79692
- const protocol = parseProtocol(fullPath);
79693
-
79694
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
79695
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
79696
- return;
79697
- }
79698
-
79699
-
79700
- // Send the request
79701
- request.send(requestData || null);
79702
- });
79703
- };
79704
-
79705
- const knownAdapters = {
79706
- http: httpAdapter,
79707
- xhr: xhrAdapter
79708
- };
79709
-
79710
- utils$2.forEach(knownAdapters, (fn, value) => {
79711
- if (fn) {
79712
- try {
79713
- Object.defineProperty(fn, 'name', {value});
79714
- } catch (e) {
79715
- // eslint-disable-next-line no-empty
79716
- }
79717
- Object.defineProperty(fn, 'adapterName', {value});
79718
- }
79719
- });
79720
-
79721
- const renderReason = (reason) => `- ${reason}`;
79722
-
79723
- const isResolvedHandle = (adapter) => utils$2.isFunction(adapter) || adapter === null || adapter === false;
79724
-
79725
- var adapters = {
79726
- getAdapter: (adapters) => {
79727
- adapters = utils$2.isArray(adapters) ? adapters : [adapters];
79728
-
79729
- const {length} = adapters;
79730
- let nameOrAdapter;
79731
- let adapter;
79732
-
79733
- const rejectedReasons = {};
79734
-
79735
- for (let i = 0; i < length; i++) {
79736
- nameOrAdapter = adapters[i];
79737
- let id;
79738
-
79739
- adapter = nameOrAdapter;
79740
-
79741
- if (!isResolvedHandle(nameOrAdapter)) {
79742
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
79743
-
79744
- if (adapter === undefined) {
79745
- throw new AxiosError(`Unknown adapter '${id}'`);
79746
- }
79747
- }
79748
-
79749
- if (adapter) {
79750
- break;
79751
- }
79752
-
79753
- rejectedReasons[id || '#' + i] = adapter;
79754
- }
79755
-
79756
- if (!adapter) {
79757
-
79758
- const reasons = Object.entries(rejectedReasons)
79759
- .map(([id, state]) => `adapter ${id} ` +
79760
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
79761
- );
79762
-
79763
- let s = length ?
79764
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
79765
- 'as no adapter specified';
79766
-
79767
- throw new AxiosError(
79768
- `There is no suitable adapter to dispatch the request ` + s,
79769
- 'ERR_NOT_SUPPORT'
79770
- );
79771
- }
79772
-
79773
- return adapter;
79774
- },
79775
- adapters: knownAdapters
79776
- };
79777
-
79778
- /**
79779
- * Throws a `CanceledError` if cancellation has been requested.
79780
- *
79781
- * @param {Object} config The config that is to be used for the request
79782
- *
79783
- * @returns {void}
79784
- */
79785
- function throwIfCancellationRequested(config) {
79786
- if (config.cancelToken) {
79787
- config.cancelToken.throwIfRequested();
79788
- }
79789
-
79790
- if (config.signal && config.signal.aborted) {
79791
- throw new CanceledError(null, config);
79792
- }
79793
- }
79794
-
79795
- /**
79796
- * Dispatch a request to the server using the configured adapter.
79797
- *
79798
- * @param {object} config The config that is to be used for the request
79799
- *
79800
- * @returns {Promise} The Promise to be fulfilled
79801
- */
79802
- function dispatchRequest(config) {
79803
- throwIfCancellationRequested(config);
79804
-
79805
- config.headers = AxiosHeaders$1.from(config.headers);
79806
-
79807
- // Transform request data
79808
- config.data = transformData.call(
79809
- config,
79810
- config.transformRequest
79811
- );
79812
-
79813
- if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
79814
- config.headers.setContentType('application/x-www-form-urlencoded', false);
79815
- }
79816
-
79817
- const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
79818
-
79819
- return adapter(config).then(function onAdapterResolution(response) {
79820
- throwIfCancellationRequested(config);
79821
-
79822
- // Transform response data
79823
- response.data = transformData.call(
79824
- config,
79825
- config.transformResponse,
79826
- response
79827
- );
79828
-
79829
- response.headers = AxiosHeaders$1.from(response.headers);
79830
-
79831
- return response;
79832
- }, function onAdapterRejection(reason) {
79833
- if (!isCancel(reason)) {
79834
- throwIfCancellationRequested(config);
79835
-
79836
- // Transform response data
79837
- if (reason && reason.response) {
79838
- reason.response.data = transformData.call(
79839
- config,
79840
- config.transformResponse,
79841
- reason.response
79842
- );
79843
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
79844
- }
79845
- }
79846
-
79847
- return Promise.reject(reason);
79848
- });
79849
- }
79850
-
79851
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
79852
-
79853
- /**
79854
- * Config-specific merge-function which creates a new config-object
79855
- * by merging two configuration objects together.
79856
- *
79857
- * @param {Object} config1
79858
- * @param {Object} config2
79859
- *
79860
- * @returns {Object} New object resulting from merging config2 to config1
79861
- */
79862
- function mergeConfig(config1, config2) {
79863
- // eslint-disable-next-line no-param-reassign
79864
- config2 = config2 || {};
79865
- const config = {};
79866
-
79867
- function getMergedValue(target, source, caseless) {
79868
- if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
79869
- return utils$2.merge.call({caseless}, target, source);
79870
- } else if (utils$2.isPlainObject(source)) {
79871
- return utils$2.merge({}, source);
79872
- } else if (utils$2.isArray(source)) {
79873
- return source.slice();
79874
- }
79875
- return source;
79876
- }
79877
-
79878
- // eslint-disable-next-line consistent-return
79879
- function mergeDeepProperties(a, b, caseless) {
79880
- if (!utils$2.isUndefined(b)) {
79881
- return getMergedValue(a, b, caseless);
79882
- } else if (!utils$2.isUndefined(a)) {
79883
- return getMergedValue(undefined, a, caseless);
79884
- }
79885
- }
79886
-
79887
- // eslint-disable-next-line consistent-return
79888
- function valueFromConfig2(a, b) {
79889
- if (!utils$2.isUndefined(b)) {
79890
- return getMergedValue(undefined, b);
79891
- }
79892
- }
79893
-
79894
- // eslint-disable-next-line consistent-return
79895
- function defaultToConfig2(a, b) {
79896
- if (!utils$2.isUndefined(b)) {
79897
- return getMergedValue(undefined, b);
79898
- } else if (!utils$2.isUndefined(a)) {
79899
- return getMergedValue(undefined, a);
79900
- }
79901
- }
79902
-
79903
- // eslint-disable-next-line consistent-return
79904
- function mergeDirectKeys(a, b, prop) {
79905
- if (prop in config2) {
79906
- return getMergedValue(a, b);
79907
- } else if (prop in config1) {
79908
- return getMergedValue(undefined, a);
79909
- }
79910
- }
79911
-
79912
- const mergeMap = {
79913
- url: valueFromConfig2,
79914
- method: valueFromConfig2,
79915
- data: valueFromConfig2,
79916
- baseURL: defaultToConfig2,
79917
- transformRequest: defaultToConfig2,
79918
- transformResponse: defaultToConfig2,
79919
- paramsSerializer: defaultToConfig2,
79920
- timeout: defaultToConfig2,
79921
- timeoutMessage: defaultToConfig2,
79922
- withCredentials: defaultToConfig2,
79923
- withXSRFToken: defaultToConfig2,
79924
- adapter: defaultToConfig2,
79925
- responseType: defaultToConfig2,
79926
- xsrfCookieName: defaultToConfig2,
79927
- xsrfHeaderName: defaultToConfig2,
79928
- onUploadProgress: defaultToConfig2,
79929
- onDownloadProgress: defaultToConfig2,
79930
- decompress: defaultToConfig2,
79931
- maxContentLength: defaultToConfig2,
79932
- maxBodyLength: defaultToConfig2,
79933
- beforeRedirect: defaultToConfig2,
79934
- transport: defaultToConfig2,
79935
- httpAgent: defaultToConfig2,
79936
- httpsAgent: defaultToConfig2,
79937
- cancelToken: defaultToConfig2,
79938
- socketPath: defaultToConfig2,
79939
- responseEncoding: defaultToConfig2,
79940
- validateStatus: mergeDirectKeys,
79941
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
79942
- };
79943
-
79944
- utils$2.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
79945
- const merge = mergeMap[prop] || mergeDeepProperties;
79946
- const configValue = merge(config1[prop], config2[prop], prop);
79947
- (utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
79948
- });
79949
-
79950
- return config;
79951
- }
79952
-
79953
- const VERSION = "1.6.5";
79954
-
79955
- const validators$1 = {};
79956
-
79957
- // eslint-disable-next-line func-names
79958
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
79959
- validators$1[type] = function validator(thing) {
79960
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
79961
- };
79962
- });
79963
-
79964
- const deprecatedWarnings = {};
79965
-
79966
- /**
79967
- * Transitional option validator
79968
- *
79969
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
79970
- * @param {string?} version - deprecated version / removed since version
79971
- * @param {string?} message - some message with additional info
79972
- *
79973
- * @returns {function}
79974
- */
79975
- validators$1.transitional = function transitional(validator, version, message) {
79976
- function formatMessage(opt, desc) {
79977
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
79978
- }
79979
-
79980
- // eslint-disable-next-line func-names
79981
- return (value, opt, opts) => {
79982
- if (validator === false) {
79983
- throw new AxiosError(
79984
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
79985
- AxiosError.ERR_DEPRECATED
79986
- );
79987
- }
79988
-
79989
- if (version && !deprecatedWarnings[opt]) {
79990
- deprecatedWarnings[opt] = true;
79991
- // eslint-disable-next-line no-console
79992
- console.warn(
79993
- formatMessage(
79994
- opt,
79995
- ' has been deprecated since v' + version + ' and will be removed in the near future'
79996
- )
79997
- );
79998
- }
79999
-
80000
- return validator ? validator(value, opt, opts) : true;
80001
- };
80002
- };
80003
-
80004
- /**
80005
- * Assert object's properties type
80006
- *
80007
- * @param {object} options
80008
- * @param {object} schema
80009
- * @param {boolean?} allowUnknown
80010
- *
80011
- * @returns {object}
80012
- */
80013
-
80014
- function assertOptions(options, schema, allowUnknown) {
80015
- if (typeof options !== 'object') {
80016
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
80017
- }
80018
- const keys = Object.keys(options);
80019
- let i = keys.length;
80020
- while (i-- > 0) {
80021
- const opt = keys[i];
80022
- const validator = schema[opt];
80023
- if (validator) {
80024
- const value = options[opt];
80025
- const result = value === undefined || validator(value, opt, options);
80026
- if (result !== true) {
80027
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
80028
- }
80029
- continue;
80030
- }
80031
- if (allowUnknown !== true) {
80032
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
80033
- }
80034
- }
80035
- }
80036
-
80037
- var validator = {
80038
- assertOptions,
80039
- validators: validators$1
80040
- };
80041
-
80042
- const validators = validator.validators;
80043
-
80044
- /**
80045
- * Create a new instance of Axios
80046
- *
80047
- * @param {Object} instanceConfig The default config for the instance
80048
- *
80049
- * @return {Axios} A new instance of Axios
80050
- */
80051
- class Axios {
80052
- constructor(instanceConfig) {
80053
- this.defaults = instanceConfig;
80054
- this.interceptors = {
80055
- request: new InterceptorManager$1(),
80056
- response: new InterceptorManager$1()
80057
- };
80058
- }
80059
-
80060
- /**
80061
- * Dispatch a request
80062
- *
80063
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
80064
- * @param {?Object} config
80065
- *
80066
- * @returns {Promise} The Promise to be fulfilled
80067
- */
80068
- request(configOrUrl, config) {
80069
- /*eslint no-param-reassign:0*/
80070
- // Allow for axios('example/url'[, config]) a la fetch API
80071
- if (typeof configOrUrl === 'string') {
80072
- config = config || {};
80073
- config.url = configOrUrl;
80074
- } else {
80075
- config = configOrUrl || {};
80076
- }
80077
-
80078
- config = mergeConfig(this.defaults, config);
80079
-
80080
- const {transitional, paramsSerializer, headers} = config;
80081
-
80082
- if (transitional !== undefined) {
80083
- validator.assertOptions(transitional, {
80084
- silentJSONParsing: validators.transitional(validators.boolean),
80085
- forcedJSONParsing: validators.transitional(validators.boolean),
80086
- clarifyTimeoutError: validators.transitional(validators.boolean)
80087
- }, false);
80088
- }
80089
-
80090
- if (paramsSerializer != null) {
80091
- if (utils$2.isFunction(paramsSerializer)) {
80092
- config.paramsSerializer = {
80093
- serialize: paramsSerializer
80094
- };
80095
- } else {
80096
- validator.assertOptions(paramsSerializer, {
80097
- encode: validators.function,
80098
- serialize: validators.function
80099
- }, true);
80100
- }
80101
- }
80102
-
80103
- // Set config.method
80104
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
80105
-
80106
- // Flatten headers
80107
- let contextHeaders = headers && utils$2.merge(
80108
- headers.common,
80109
- headers[config.method]
80110
- );
80111
-
80112
- headers && utils$2.forEach(
80113
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
80114
- (method) => {
80115
- delete headers[method];
80116
- }
80117
- );
80118
-
80119
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
80120
-
80121
- // filter out skipped interceptors
80122
- const requestInterceptorChain = [];
80123
- let synchronousRequestInterceptors = true;
80124
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
80125
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
80126
- return;
80127
- }
80128
-
80129
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
80130
-
80131
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
80132
- });
80133
-
80134
- const responseInterceptorChain = [];
80135
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
80136
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
80137
- });
80138
-
80139
- let promise;
80140
- let i = 0;
80141
- let len;
80142
-
80143
- if (!synchronousRequestInterceptors) {
80144
- const chain = [dispatchRequest.bind(this), undefined];
80145
- chain.unshift.apply(chain, requestInterceptorChain);
80146
- chain.push.apply(chain, responseInterceptorChain);
80147
- len = chain.length;
80148
-
80149
- promise = Promise.resolve(config);
80150
-
80151
- while (i < len) {
80152
- promise = promise.then(chain[i++], chain[i++]);
80153
- }
80154
-
80155
- return promise;
80156
- }
80157
-
80158
- len = requestInterceptorChain.length;
80159
-
80160
- let newConfig = config;
80161
-
80162
- i = 0;
80163
-
80164
- while (i < len) {
80165
- const onFulfilled = requestInterceptorChain[i++];
80166
- const onRejected = requestInterceptorChain[i++];
80167
- try {
80168
- newConfig = onFulfilled(newConfig);
80169
- } catch (error) {
80170
- onRejected.call(this, error);
80171
- break;
80172
- }
80173
- }
80174
-
80175
- try {
80176
- promise = dispatchRequest.call(this, newConfig);
80177
- } catch (error) {
80178
- return Promise.reject(error);
80179
- }
80180
-
80181
- i = 0;
80182
- len = responseInterceptorChain.length;
80183
-
80184
- while (i < len) {
80185
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
80186
- }
80187
-
80188
- return promise;
80189
- }
80190
-
80191
- getUri(config) {
80192
- config = mergeConfig(this.defaults, config);
80193
- const fullPath = buildFullPath(config.baseURL, config.url);
80194
- return buildURL(fullPath, config.params, config.paramsSerializer);
80195
- }
80196
- }
80197
-
80198
- // Provide aliases for supported request methods
80199
- utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
80200
- /*eslint func-names:0*/
80201
- Axios.prototype[method] = function(url, config) {
80202
- return this.request(mergeConfig(config || {}, {
80203
- method,
80204
- url,
80205
- data: (config || {}).data
80206
- }));
80207
- };
80208
- });
80209
-
80210
- utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
80211
- /*eslint func-names:0*/
80212
-
80213
- function generateHTTPMethod(isForm) {
80214
- return function httpMethod(url, data, config) {
80215
- return this.request(mergeConfig(config || {}, {
80216
- method,
80217
- headers: isForm ? {
80218
- 'Content-Type': 'multipart/form-data'
80219
- } : {},
80220
- url,
80221
- data
80222
- }));
80223
- };
80224
- }
80225
-
80226
- Axios.prototype[method] = generateHTTPMethod();
80227
-
80228
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
80229
- });
80230
-
80231
- var Axios$1 = Axios;
80232
-
80233
- /**
80234
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
80235
- *
80236
- * @param {Function} executor The executor function.
80237
- *
80238
- * @returns {CancelToken}
80239
- */
80240
- class CancelToken {
80241
- constructor(executor) {
80242
- if (typeof executor !== 'function') {
80243
- throw new TypeError('executor must be a function.');
80244
- }
80245
-
80246
- let resolvePromise;
80247
-
80248
- this.promise = new Promise(function promiseExecutor(resolve) {
80249
- resolvePromise = resolve;
80250
- });
80251
-
80252
- const token = this;
80253
-
80254
- // eslint-disable-next-line func-names
80255
- this.promise.then(cancel => {
80256
- if (!token._listeners) return;
80257
-
80258
- let i = token._listeners.length;
80259
-
80260
- while (i-- > 0) {
80261
- token._listeners[i](cancel);
80262
- }
80263
- token._listeners = null;
80264
- });
80265
-
80266
- // eslint-disable-next-line func-names
80267
- this.promise.then = onfulfilled => {
80268
- let _resolve;
80269
- // eslint-disable-next-line func-names
80270
- const promise = new Promise(resolve => {
80271
- token.subscribe(resolve);
80272
- _resolve = resolve;
80273
- }).then(onfulfilled);
80274
-
80275
- promise.cancel = function reject() {
80276
- token.unsubscribe(_resolve);
80277
- };
80278
-
80279
- return promise;
80280
- };
80281
-
80282
- executor(function cancel(message, config, request) {
80283
- if (token.reason) {
80284
- // Cancellation has already been requested
80285
- return;
80286
- }
80287
-
80288
- token.reason = new CanceledError(message, config, request);
80289
- resolvePromise(token.reason);
80290
- });
80291
- }
80292
-
80293
- /**
80294
- * Throws a `CanceledError` if cancellation has been requested.
80295
- */
80296
- throwIfRequested() {
80297
- if (this.reason) {
80298
- throw this.reason;
80299
- }
80300
- }
80301
-
80302
- /**
80303
- * Subscribe to the cancel signal
80304
- */
80305
-
80306
- subscribe(listener) {
80307
- if (this.reason) {
80308
- listener(this.reason);
80309
- return;
80310
- }
80311
-
80312
- if (this._listeners) {
80313
- this._listeners.push(listener);
80314
- } else {
80315
- this._listeners = [listener];
80316
- }
80317
- }
80318
-
80319
- /**
80320
- * Unsubscribe from the cancel signal
80321
- */
80322
-
80323
- unsubscribe(listener) {
80324
- if (!this._listeners) {
80325
- return;
80326
- }
80327
- const index = this._listeners.indexOf(listener);
80328
- if (index !== -1) {
80329
- this._listeners.splice(index, 1);
80330
- }
80331
- }
80332
-
80333
- /**
80334
- * Returns an object that contains a new `CancelToken` and a function that, when called,
80335
- * cancels the `CancelToken`.
80336
- */
80337
- static source() {
80338
- let cancel;
80339
- const token = new CancelToken(function executor(c) {
80340
- cancel = c;
80341
- });
80342
- return {
80343
- token,
80344
- cancel
80345
- };
80346
- }
80347
- }
80348
-
80349
- var CancelToken$1 = CancelToken;
80350
-
80351
- /**
80352
- * Syntactic sugar for invoking a function and expanding an array for arguments.
80353
- *
80354
- * Common use case would be to use `Function.prototype.apply`.
80355
- *
80356
- * ```js
80357
- * function f(x, y, z) {}
80358
- * var args = [1, 2, 3];
80359
- * f.apply(null, args);
80360
- * ```
80361
- *
80362
- * With `spread` this example can be re-written.
80363
- *
80364
- * ```js
80365
- * spread(function(x, y, z) {})([1, 2, 3]);
80366
- * ```
80367
- *
80368
- * @param {Function} callback
80369
- *
80370
- * @returns {Function}
80371
- */
80372
- function spread(callback) {
80373
- return function wrap(arr) {
80374
- return callback.apply(null, arr);
80375
- };
80376
- }
80377
-
80378
- /**
80379
- * Determines whether the payload is an error thrown by Axios
80380
- *
80381
- * @param {*} payload The value to test
80382
- *
80383
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
80384
- */
80385
- function isAxiosError(payload) {
80386
- return utils$2.isObject(payload) && (payload.isAxiosError === true);
80387
- }
80388
-
80389
- const HttpStatusCode = {
80390
- Continue: 100,
80391
- SwitchingProtocols: 101,
80392
- Processing: 102,
80393
- EarlyHints: 103,
80394
- Ok: 200,
80395
- Created: 201,
80396
- Accepted: 202,
80397
- NonAuthoritativeInformation: 203,
80398
- NoContent: 204,
80399
- ResetContent: 205,
80400
- PartialContent: 206,
80401
- MultiStatus: 207,
80402
- AlreadyReported: 208,
80403
- ImUsed: 226,
80404
- MultipleChoices: 300,
80405
- MovedPermanently: 301,
80406
- Found: 302,
80407
- SeeOther: 303,
80408
- NotModified: 304,
80409
- UseProxy: 305,
80410
- Unused: 306,
80411
- TemporaryRedirect: 307,
80412
- PermanentRedirect: 308,
80413
- BadRequest: 400,
80414
- Unauthorized: 401,
80415
- PaymentRequired: 402,
80416
- Forbidden: 403,
80417
- NotFound: 404,
80418
- MethodNotAllowed: 405,
80419
- NotAcceptable: 406,
80420
- ProxyAuthenticationRequired: 407,
80421
- RequestTimeout: 408,
80422
- Conflict: 409,
80423
- Gone: 410,
80424
- LengthRequired: 411,
80425
- PreconditionFailed: 412,
80426
- PayloadTooLarge: 413,
80427
- UriTooLong: 414,
80428
- UnsupportedMediaType: 415,
80429
- RangeNotSatisfiable: 416,
80430
- ExpectationFailed: 417,
80431
- ImATeapot: 418,
80432
- MisdirectedRequest: 421,
80433
- UnprocessableEntity: 422,
80434
- Locked: 423,
80435
- FailedDependency: 424,
80436
- TooEarly: 425,
80437
- UpgradeRequired: 426,
80438
- PreconditionRequired: 428,
80439
- TooManyRequests: 429,
80440
- RequestHeaderFieldsTooLarge: 431,
80441
- UnavailableForLegalReasons: 451,
80442
- InternalServerError: 500,
80443
- NotImplemented: 501,
80444
- BadGateway: 502,
80445
- ServiceUnavailable: 503,
80446
- GatewayTimeout: 504,
80447
- HttpVersionNotSupported: 505,
80448
- VariantAlsoNegotiates: 506,
80449
- InsufficientStorage: 507,
80450
- LoopDetected: 508,
80451
- NotExtended: 510,
80452
- NetworkAuthenticationRequired: 511,
80453
- };
80454
-
80455
- Object.entries(HttpStatusCode).forEach(([key, value]) => {
80456
- HttpStatusCode[value] = key;
80457
- });
80458
-
80459
- var HttpStatusCode$1 = HttpStatusCode;
80460
-
80461
- /**
80462
- * Create an instance of Axios
80463
- *
80464
- * @param {Object} defaultConfig The default config for the instance
80465
- *
80466
- * @returns {Axios} A new instance of Axios
80467
- */
80468
- function createInstance(defaultConfig) {
80469
- const context = new Axios$1(defaultConfig);
80470
- const instance = bind(Axios$1.prototype.request, context);
80471
-
80472
- // Copy axios.prototype to instance
80473
- utils$2.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
80474
-
80475
- // Copy context to instance
80476
- utils$2.extend(instance, context, null, {allOwnKeys: true});
80477
-
80478
- // Factory for creating new instances
80479
- instance.create = function create(instanceConfig) {
80480
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
80481
- };
80482
-
80483
- return instance;
80484
- }
80485
-
80486
- // Create the default instance to be exported
80487
- const axios = createInstance(defaults$1);
80488
-
80489
- // Expose Axios class to allow class inheritance
80490
- axios.Axios = Axios$1;
80491
-
80492
- // Expose Cancel & CancelToken
80493
- axios.CanceledError = CanceledError;
80494
- axios.CancelToken = CancelToken$1;
80495
- axios.isCancel = isCancel;
80496
- axios.VERSION = VERSION;
80497
- axios.toFormData = toFormData;
80498
-
80499
- // Expose AxiosError class
80500
- axios.AxiosError = AxiosError;
80501
-
80502
- // alias for CanceledError for backward compatibility
80503
- axios.Cancel = axios.CanceledError;
80504
-
80505
- // Expose all/spread
80506
- axios.all = function all(promises) {
80507
- return Promise.all(promises);
80508
- };
80509
-
80510
- axios.spread = spread;
80511
-
80512
- // Expose isAxiosError
80513
- axios.isAxiosError = isAxiosError;
80514
-
80515
- // Expose mergeConfig
80516
- axios.mergeConfig = mergeConfig;
80517
-
80518
- axios.AxiosHeaders = AxiosHeaders$1;
80519
-
80520
- axios.formToJSON = thing => formDataToJSON(utils$2.isHTMLForm(thing) ? new FormData(thing) : thing);
80521
-
80522
- axios.getAdapter = adapters.getAdapter;
80523
-
80524
- axios.HttpStatusCode = HttpStatusCode$1;
80525
-
80526
- axios.default = axios;
80527
-
80528
- // this module should only have a default export
80529
- var axios$1 = axios;
80530
-
80531
77296
  class HttpClient {
80532
- stringToVerb(m) {
80533
- if (m.toLowerCase() === 'get')
80534
- return 'GET';
80535
- else if (m.toLowerCase() === 'post')
80536
- return 'POST';
80537
- else if (m.toLowerCase() === 'patch')
80538
- return 'PATCH';
80539
- else if (m.toLowerCase() === 'put')
80540
- return 'PUT';
80541
- else if (m.toLowerCase() === 'options')
80542
- return 'OPTIONS';
80543
- else if (m.toLowerCase() === 'delete')
80544
- return 'DELETE';
80545
- else
80546
- return 'GET';
80547
- }
80548
77297
  request(verb, url, headers, body, callback) {
80549
77298
  return __awaiter(this, void 0, void 0, function* () {
80550
- const method = this.stringToVerb(verb);
80551
- const data = body !== null && body.length > 0 ? JSON.parse(body) : '';
80552
- const axiosReq = {
80553
- url,
80554
- method,
80555
- headers,
80556
- data,
80557
- // Pipe all successful HTTP response through to core
80558
- validateStatus: () => true
77299
+ const options = {
77300
+ method: verb.toUpperCase(),
77301
+ headers: Object.entries(headers).reduce((acc, [key, value]) => {
77302
+ acc.append(key, value.toString());
77303
+ return acc;
77304
+ }, new Headers()),
77305
+ body: body == '' || body == null ? undefined : body
80559
77306
  };
80560
77307
  try {
80561
- const response = yield axios$1(axiosReq);
80562
- const coreResponse = new clientsdkClientcore_jsExports.vonage.HttpClientResponseJS(response.status, JSON.stringify(response.data));
77308
+ const response = yield fetch(url, options);
77309
+ const coreResponse = new clientsdkClientcore_jsExports.vonage.HttpClientResponseJS(response.status, yield response.text());
77310
+ // no need to check for status ok, as we pipe all responses through to core
80563
77311
  callback(null, coreResponse);
80564
77312
  }
80565
77313
  catch (error) {
80566
- const httpClientError = new clientsdkClientcore_jsExports.vonage.HttpClientErrorJS(error instanceof Error ? error.message : 'Unknown Error', error instanceof Error ? error : null);
77314
+ if (error instanceof Error) {
77315
+ const httpClientError = new clientsdkClientcore_jsExports.vonage.HttpClientErrorJS(error.message, error);
77316
+ callback(httpClientError, null);
77317
+ return;
77318
+ }
77319
+ const httpClientError = new clientsdkClientcore_jsExports.vonage.HttpClientErrorJS('Unknown Error', null);
80567
77320
  callback(httpClientError, null);
80568
77321
  }
80569
77322
  });