@verdocs/web-sdk 1.4.6 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/cjs/VerdocsEndpoint-5e6dd8ef.js +4780 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/verdocs-auth.cjs.entry.js +32 -19
  4. package/dist/cjs/verdocs-dropdown_12.cjs.entry.js +15 -11
  5. package/dist/cjs/verdocs-kba-dialog.cjs.entry.js +1 -1
  6. package/dist/cjs/verdocs-ok-dialog.cjs.entry.js +1 -1
  7. package/dist/cjs/verdocs-quick-functions.cjs.entry.js +5 -0
  8. package/dist/cjs/verdocs-search-activity_2.cjs.entry.js +40 -35
  9. package/dist/cjs/verdocs-search.cjs.entry.js +6 -1
  10. package/dist/cjs/verdocs-sign.cjs.entry.js +26 -161
  11. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  12. package/dist/collection/components/dialogs/verdocs-kba-dialog/verdocs-kba-dialog.css +1 -1
  13. package/dist/collection/components/dialogs/verdocs-ok-dialog/verdocs-ok-dialog.css +1 -1
  14. package/dist/collection/components/elements/verdocs-quick-functions/verdocs-quick-functions.js +31 -1
  15. package/dist/collection/components/elements/verdocs-search-activity/verdocs-search-activity.js +30 -6
  16. package/dist/collection/components/elements/verdocs-search-box/verdocs-search-box.js +26 -0
  17. package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.css +1 -4
  18. package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +35 -17
  19. package/dist/collection/components/embeds/verdocs-search/verdocs-search.js +36 -6
  20. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.css +27 -26
  21. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +40 -23
  22. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.stories.js +2 -2
  23. package/dist/collection/components/embeds/verdocs-view/verdocs-view.js +26 -0
  24. package/dist/components/VerdocsEndpoint.js +4766 -0
  25. package/dist/components/verdocs-auth.js +33 -18
  26. package/dist/components/verdocs-kba-dialog.js +1 -1
  27. package/dist/components/verdocs-ok-dialog2.js +1 -1
  28. package/dist/components/verdocs-quick-functions.js +8 -1
  29. package/dist/components/verdocs-search-activity2.js +37 -34
  30. package/dist/components/verdocs-search-box2.js +6 -0
  31. package/dist/components/verdocs-search.js +9 -2
  32. package/dist/components/verdocs-sign.js +27 -162
  33. package/dist/components/verdocs-view2.js +6 -1
  34. package/dist/docs.json +117 -3
  35. package/dist/esm/VerdocsEndpoint-30e1b6ec.js +4766 -0
  36. package/dist/esm/loader.js +1 -1
  37. package/dist/esm/verdocs-auth.entry.js +32 -19
  38. package/dist/esm/verdocs-dropdown_12.entry.js +5 -1
  39. package/dist/esm/verdocs-kba-dialog.entry.js +1 -1
  40. package/dist/esm/verdocs-ok-dialog.entry.js +1 -1
  41. package/dist/esm/verdocs-quick-functions.entry.js +5 -0
  42. package/dist/esm/verdocs-search-activity_2.entry.js +40 -35
  43. package/dist/esm/verdocs-search.entry.js +6 -1
  44. package/dist/esm/verdocs-sign.entry.js +26 -161
  45. package/dist/esm/verdocs-web-sdk.js +1 -1
  46. package/dist/esm-es5/VerdocsEndpoint-30e1b6ec.js +7 -0
  47. package/dist/esm-es5/loader.js +1 -1
  48. package/dist/esm-es5/verdocs-auth.entry.js +1 -1
  49. package/dist/esm-es5/verdocs-dropdown_12.entry.js +2 -2
  50. package/dist/esm-es5/verdocs-kba-dialog.entry.js +1 -1
  51. package/dist/esm-es5/verdocs-ok-dialog.entry.js +1 -1
  52. package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -1
  53. package/dist/esm-es5/verdocs-search-activity_2.entry.js +1 -1
  54. package/dist/esm-es5/verdocs-search.entry.js +1 -1
  55. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  56. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  57. package/dist/types/components/elements/verdocs-quick-functions/verdocs-quick-functions.d.ts +5 -0
  58. package/dist/types/components/elements/verdocs-search-activity/verdocs-search-activity.d.ts +5 -0
  59. package/dist/types/components/elements/verdocs-search-box/verdocs-search-box.d.ts +5 -0
  60. package/dist/types/components/embeds/verdocs-auth/verdocs-auth.d.ts +7 -4
  61. package/dist/types/components/embeds/verdocs-search/verdocs-search.d.ts +5 -0
  62. package/dist/types/components/embeds/verdocs-sign/verdocs-sign.d.ts +6 -3
  63. package/dist/types/components/embeds/verdocs-view/verdocs-view.d.ts +5 -0
  64. package/dist/types/components.d.ts +57 -0
  65. package/dist/verdocs-web-sdk/{p-ed5baeb4.entry.js → p-064453c3.entry.js} +1 -1
  66. package/dist/verdocs-web-sdk/p-06f38046.js +1 -0
  67. package/dist/verdocs-web-sdk/p-16d62a51.system.entry.js +1 -0
  68. package/dist/verdocs-web-sdk/p-1b4e04b7.system.entry.js +1 -0
  69. package/dist/verdocs-web-sdk/p-1ea3b9d3.entry.js +1 -0
  70. package/dist/verdocs-web-sdk/p-30cc8818.entry.js +1 -0
  71. package/dist/verdocs-web-sdk/{p-0353c423.entry.js → p-32ad1014.entry.js} +1 -1
  72. package/dist/verdocs-web-sdk/p-4d80d044.system.js +7 -0
  73. package/dist/verdocs-web-sdk/{p-432c3151.system.entry.js → p-81fc0196.system.entry.js} +1 -1
  74. package/dist/verdocs-web-sdk/p-8276345a.entry.js +1 -0
  75. package/dist/verdocs-web-sdk/p-88a300c5.system.js +1 -1
  76. package/dist/verdocs-web-sdk/p-9139a76d.system.entry.js +1 -0
  77. package/dist/verdocs-web-sdk/p-a87069d5.system.entry.js +1 -0
  78. package/dist/verdocs-web-sdk/p-aa9fc574.entry.js +1 -0
  79. package/dist/verdocs-web-sdk/p-c29c2cf8.entry.js +1 -0
  80. package/dist/verdocs-web-sdk/{p-4368df79.system.entry.js → p-c4d03ff9.system.entry.js} +2 -2
  81. package/dist/verdocs-web-sdk/{p-a1143ddb.entry.js → p-d522de7d.entry.js} +2 -2
  82. package/dist/verdocs-web-sdk/{p-e2e643c5.system.entry.js → p-e4ba14dc.system.entry.js} +1 -1
  83. package/dist/verdocs-web-sdk/p-f6a53928.system.entry.js +1 -0
  84. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  85. package/package.json +2 -2
  86. package/dist/cjs/Auth-e68977a3.js +0 -90
  87. package/dist/cjs/Token-1ec62bd3.js +0 -2330
  88. package/dist/cjs/buffer-es6-bc8199b1.js +0 -2018
  89. package/dist/components/Auth.js +0 -85
  90. package/dist/components/Token.js +0 -2325
  91. package/dist/components/buffer-es6.js +0 -2010
  92. package/dist/esm/Auth-b330f209.js +0 -85
  93. package/dist/esm/Token-a587e3ad.js +0 -2325
  94. package/dist/esm/buffer-es6-136673c8.js +0 -2010
  95. package/dist/esm-es5/Auth-b330f209.js +0 -1
  96. package/dist/esm-es5/Token-a587e3ad.js +0 -1
  97. package/dist/esm-es5/buffer-es6-136673c8.js +0 -7
  98. package/dist/verdocs-web-sdk/p-0b1fb53f.entry.js +0 -1
  99. package/dist/verdocs-web-sdk/p-0c30002e.entry.js +0 -1
  100. package/dist/verdocs-web-sdk/p-203fd748.system.entry.js +0 -1
  101. package/dist/verdocs-web-sdk/p-216a4759.system.entry.js +0 -1
  102. package/dist/verdocs-web-sdk/p-2c161242.system.entry.js +0 -1
  103. package/dist/verdocs-web-sdk/p-3820c9a2.js +0 -1
  104. package/dist/verdocs-web-sdk/p-39633a02.entry.js +0 -1
  105. package/dist/verdocs-web-sdk/p-5dfd73f9.system.js +0 -7
  106. package/dist/verdocs-web-sdk/p-6348272c.js +0 -1
  107. package/dist/verdocs-web-sdk/p-9428614b.system.entry.js +0 -1
  108. package/dist/verdocs-web-sdk/p-da850d97.entry.js +0 -1
  109. package/dist/verdocs-web-sdk/p-e3659c64.system.js +0 -1
  110. package/dist/verdocs-web-sdk/p-e93ac86f.system.js +0 -1
  111. package/dist/verdocs-web-sdk/p-ef932a87.js +0 -1
  112. package/dist/verdocs-web-sdk/p-f0e6fde0.entry.js +0 -1
  113. package/dist/verdocs-web-sdk/p-fd853e54.system.entry.js +0 -1
@@ -1,2325 +0,0 @@
1
- import { B as Buffer, p as process_1 } from './buffer-es6-136673c8.js';
2
-
3
- var bind = function bind(fn, thisArg) {
4
- return function wrap() {
5
- var args = new Array(arguments.length);
6
- for (var i = 0; i < args.length; i++) {
7
- args[i] = arguments[i];
8
- }
9
- return fn.apply(thisArg, args);
10
- };
11
- };
12
-
13
- // utils is a library of generic helper functions non-specific to axios
14
-
15
- var toString = Object.prototype.toString;
16
-
17
- // eslint-disable-next-line func-names
18
- var kindOf = (function(cache) {
19
- // eslint-disable-next-line func-names
20
- return function(thing) {
21
- var str = toString.call(thing);
22
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
23
- };
24
- })(Object.create(null));
25
-
26
- function kindOfTest(type) {
27
- type = type.toLowerCase();
28
- return function isKindOf(thing) {
29
- return kindOf(thing) === type;
30
- };
31
- }
32
-
33
- /**
34
- * Determine if a value is an Array
35
- *
36
- * @param {Object} val The value to test
37
- * @returns {boolean} True if value is an Array, otherwise false
38
- */
39
- function isArray(val) {
40
- return Array.isArray(val);
41
- }
42
-
43
- /**
44
- * Determine if a value is undefined
45
- *
46
- * @param {Object} val The value to test
47
- * @returns {boolean} True if the value is undefined, otherwise false
48
- */
49
- function isUndefined(val) {
50
- return typeof val === 'undefined';
51
- }
52
-
53
- /**
54
- * Determine if a value is a Buffer
55
- *
56
- * @param {Object} val The value to test
57
- * @returns {boolean} True if value is a Buffer, otherwise false
58
- */
59
- function isBuffer(val) {
60
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
61
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
62
- }
63
-
64
- /**
65
- * Determine if a value is an ArrayBuffer
66
- *
67
- * @function
68
- * @param {Object} val The value to test
69
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
70
- */
71
- var isArrayBuffer = kindOfTest('ArrayBuffer');
72
-
73
-
74
- /**
75
- * Determine if a value is a view on an ArrayBuffer
76
- *
77
- * @param {Object} val The value to test
78
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
79
- */
80
- function isArrayBufferView(val) {
81
- var result;
82
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
83
- result = ArrayBuffer.isView(val);
84
- } else {
85
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
86
- }
87
- return result;
88
- }
89
-
90
- /**
91
- * Determine if a value is a String
92
- *
93
- * @param {Object} val The value to test
94
- * @returns {boolean} True if value is a String, otherwise false
95
- */
96
- function isString(val) {
97
- return typeof val === 'string';
98
- }
99
-
100
- /**
101
- * Determine if a value is a Number
102
- *
103
- * @param {Object} val The value to test
104
- * @returns {boolean} True if value is a Number, otherwise false
105
- */
106
- function isNumber(val) {
107
- return typeof val === 'number';
108
- }
109
-
110
- /**
111
- * Determine if a value is an Object
112
- *
113
- * @param {Object} val The value to test
114
- * @returns {boolean} True if value is an Object, otherwise false
115
- */
116
- function isObject(val) {
117
- return val !== null && typeof val === 'object';
118
- }
119
-
120
- /**
121
- * Determine if a value is a plain Object
122
- *
123
- * @param {Object} val The value to test
124
- * @return {boolean} True if value is a plain Object, otherwise false
125
- */
126
- function isPlainObject(val) {
127
- if (kindOf(val) !== 'object') {
128
- return false;
129
- }
130
-
131
- var prototype = Object.getPrototypeOf(val);
132
- return prototype === null || prototype === Object.prototype;
133
- }
134
-
135
- /**
136
- * Determine if a value is a Date
137
- *
138
- * @function
139
- * @param {Object} val The value to test
140
- * @returns {boolean} True if value is a Date, otherwise false
141
- */
142
- var isDate = kindOfTest('Date');
143
-
144
- /**
145
- * Determine if a value is a File
146
- *
147
- * @function
148
- * @param {Object} val The value to test
149
- * @returns {boolean} True if value is a File, otherwise false
150
- */
151
- var isFile = kindOfTest('File');
152
-
153
- /**
154
- * Determine if a value is a Blob
155
- *
156
- * @function
157
- * @param {Object} val The value to test
158
- * @returns {boolean} True if value is a Blob, otherwise false
159
- */
160
- var isBlob = kindOfTest('Blob');
161
-
162
- /**
163
- * Determine if a value is a FileList
164
- *
165
- * @function
166
- * @param {Object} val The value to test
167
- * @returns {boolean} True if value is a File, otherwise false
168
- */
169
- var isFileList = kindOfTest('FileList');
170
-
171
- /**
172
- * Determine if a value is a Function
173
- *
174
- * @param {Object} val The value to test
175
- * @returns {boolean} True if value is a Function, otherwise false
176
- */
177
- function isFunction(val) {
178
- return toString.call(val) === '[object Function]';
179
- }
180
-
181
- /**
182
- * Determine if a value is a Stream
183
- *
184
- * @param {Object} val The value to test
185
- * @returns {boolean} True if value is a Stream, otherwise false
186
- */
187
- function isStream(val) {
188
- return isObject(val) && isFunction(val.pipe);
189
- }
190
-
191
- /**
192
- * Determine if a value is a FormData
193
- *
194
- * @param {Object} thing The value to test
195
- * @returns {boolean} True if value is an FormData, otherwise false
196
- */
197
- function isFormData(thing) {
198
- var pattern = '[object FormData]';
199
- return thing && (
200
- (typeof FormData === 'function' && thing instanceof FormData) ||
201
- toString.call(thing) === pattern ||
202
- (isFunction(thing.toString) && thing.toString() === pattern)
203
- );
204
- }
205
-
206
- /**
207
- * Determine if a value is a URLSearchParams object
208
- * @function
209
- * @param {Object} val The value to test
210
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
211
- */
212
- var isURLSearchParams = kindOfTest('URLSearchParams');
213
-
214
- /**
215
- * Trim excess whitespace off the beginning and end of a string
216
- *
217
- * @param {String} str The String to trim
218
- * @returns {String} The String freed of excess whitespace
219
- */
220
- function trim(str) {
221
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
222
- }
223
-
224
- /**
225
- * Determine if we're running in a standard browser environment
226
- *
227
- * This allows axios to run in a web worker, and react-native.
228
- * Both environments support XMLHttpRequest, but not fully standard globals.
229
- *
230
- * web workers:
231
- * typeof window -> undefined
232
- * typeof document -> undefined
233
- *
234
- * react-native:
235
- * navigator.product -> 'ReactNative'
236
- * nativescript
237
- * navigator.product -> 'NativeScript' or 'NS'
238
- */
239
- function isStandardBrowserEnv() {
240
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
241
- navigator.product === 'NativeScript' ||
242
- navigator.product === 'NS')) {
243
- return false;
244
- }
245
- return (
246
- typeof window !== 'undefined' &&
247
- typeof document !== 'undefined'
248
- );
249
- }
250
-
251
- /**
252
- * Iterate over an Array or an Object invoking a function for each item.
253
- *
254
- * If `obj` is an Array callback will be called passing
255
- * the value, index, and complete array for each item.
256
- *
257
- * If 'obj' is an Object callback will be called passing
258
- * the value, key, and complete object for each property.
259
- *
260
- * @param {Object|Array} obj The object to iterate
261
- * @param {Function} fn The callback to invoke for each item
262
- */
263
- function forEach(obj, fn) {
264
- // Don't bother if no value provided
265
- if (obj === null || typeof obj === 'undefined') {
266
- return;
267
- }
268
-
269
- // Force an array if not already something iterable
270
- if (typeof obj !== 'object') {
271
- /*eslint no-param-reassign:0*/
272
- obj = [obj];
273
- }
274
-
275
- if (isArray(obj)) {
276
- // Iterate over array values
277
- for (var i = 0, l = obj.length; i < l; i++) {
278
- fn.call(null, obj[i], i, obj);
279
- }
280
- } else {
281
- // Iterate over object keys
282
- for (var key in obj) {
283
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
284
- fn.call(null, obj[key], key, obj);
285
- }
286
- }
287
- }
288
- }
289
-
290
- /**
291
- * Accepts varargs expecting each argument to be an object, then
292
- * immutably merges the properties of each object and returns result.
293
- *
294
- * When multiple objects contain the same key the later object in
295
- * the arguments list will take precedence.
296
- *
297
- * Example:
298
- *
299
- * ```js
300
- * var result = merge({foo: 123}, {foo: 456});
301
- * console.log(result.foo); // outputs 456
302
- * ```
303
- *
304
- * @param {Object} obj1 Object to merge
305
- * @returns {Object} Result of all merge properties
306
- */
307
- function merge(/* obj1, obj2, obj3, ... */) {
308
- var result = {};
309
- function assignValue(val, key) {
310
- if (isPlainObject(result[key]) && isPlainObject(val)) {
311
- result[key] = merge(result[key], val);
312
- } else if (isPlainObject(val)) {
313
- result[key] = merge({}, val);
314
- } else if (isArray(val)) {
315
- result[key] = val.slice();
316
- } else {
317
- result[key] = val;
318
- }
319
- }
320
-
321
- for (var i = 0, l = arguments.length; i < l; i++) {
322
- forEach(arguments[i], assignValue);
323
- }
324
- return result;
325
- }
326
-
327
- /**
328
- * Extends object a by mutably adding to it the properties of object b.
329
- *
330
- * @param {Object} a The object to be extended
331
- * @param {Object} b The object to copy properties from
332
- * @param {Object} thisArg The object to bind function to
333
- * @return {Object} The resulting value of object a
334
- */
335
- function extend(a, b, thisArg) {
336
- forEach(b, function assignValue(val, key) {
337
- if (thisArg && typeof val === 'function') {
338
- a[key] = bind(val, thisArg);
339
- } else {
340
- a[key] = val;
341
- }
342
- });
343
- return a;
344
- }
345
-
346
- /**
347
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
348
- *
349
- * @param {string} content with BOM
350
- * @return {string} content value without BOM
351
- */
352
- function stripBOM(content) {
353
- if (content.charCodeAt(0) === 0xFEFF) {
354
- content = content.slice(1);
355
- }
356
- return content;
357
- }
358
-
359
- /**
360
- * Inherit the prototype methods from one constructor into another
361
- * @param {function} constructor
362
- * @param {function} superConstructor
363
- * @param {object} [props]
364
- * @param {object} [descriptors]
365
- */
366
-
367
- function inherits(constructor, superConstructor, props, descriptors) {
368
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
369
- constructor.prototype.constructor = constructor;
370
- props && Object.assign(constructor.prototype, props);
371
- }
372
-
373
- /**
374
- * Resolve object with deep prototype chain to a flat object
375
- * @param {Object} sourceObj source object
376
- * @param {Object} [destObj]
377
- * @param {Function} [filter]
378
- * @returns {Object}
379
- */
380
-
381
- function toFlatObject(sourceObj, destObj, filter) {
382
- var props;
383
- var i;
384
- var prop;
385
- var merged = {};
386
-
387
- destObj = destObj || {};
388
-
389
- do {
390
- props = Object.getOwnPropertyNames(sourceObj);
391
- i = props.length;
392
- while (i-- > 0) {
393
- prop = props[i];
394
- if (!merged[prop]) {
395
- destObj[prop] = sourceObj[prop];
396
- merged[prop] = true;
397
- }
398
- }
399
- sourceObj = Object.getPrototypeOf(sourceObj);
400
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
401
-
402
- return destObj;
403
- }
404
-
405
- /*
406
- * determines whether a string ends with the characters of a specified string
407
- * @param {String} str
408
- * @param {String} searchString
409
- * @param {Number} [position= 0]
410
- * @returns {boolean}
411
- */
412
- function endsWith(str, searchString, position) {
413
- str = String(str);
414
- if (position === undefined || position > str.length) {
415
- position = str.length;
416
- }
417
- position -= searchString.length;
418
- var lastIndex = str.indexOf(searchString, position);
419
- return lastIndex !== -1 && lastIndex === position;
420
- }
421
-
422
-
423
- /**
424
- * Returns new array from array like object
425
- * @param {*} [thing]
426
- * @returns {Array}
427
- */
428
- function toArray(thing) {
429
- if (!thing) return null;
430
- var i = thing.length;
431
- if (isUndefined(i)) return null;
432
- var arr = new Array(i);
433
- while (i-- > 0) {
434
- arr[i] = thing[i];
435
- }
436
- return arr;
437
- }
438
-
439
- // eslint-disable-next-line func-names
440
- var isTypedArray = (function(TypedArray) {
441
- // eslint-disable-next-line func-names
442
- return function(thing) {
443
- return TypedArray && thing instanceof TypedArray;
444
- };
445
- })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
446
-
447
- var utils = {
448
- isArray: isArray,
449
- isArrayBuffer: isArrayBuffer,
450
- isBuffer: isBuffer,
451
- isFormData: isFormData,
452
- isArrayBufferView: isArrayBufferView,
453
- isString: isString,
454
- isNumber: isNumber,
455
- isObject: isObject,
456
- isPlainObject: isPlainObject,
457
- isUndefined: isUndefined,
458
- isDate: isDate,
459
- isFile: isFile,
460
- isBlob: isBlob,
461
- isFunction: isFunction,
462
- isStream: isStream,
463
- isURLSearchParams: isURLSearchParams,
464
- isStandardBrowserEnv: isStandardBrowserEnv,
465
- forEach: forEach,
466
- merge: merge,
467
- extend: extend,
468
- trim: trim,
469
- stripBOM: stripBOM,
470
- inherits: inherits,
471
- toFlatObject: toFlatObject,
472
- kindOf: kindOf,
473
- kindOfTest: kindOfTest,
474
- endsWith: endsWith,
475
- toArray: toArray,
476
- isTypedArray: isTypedArray,
477
- isFileList: isFileList
478
- };
479
-
480
- function encode(val) {
481
- return encodeURIComponent(val).
482
- replace(/%3A/gi, ':').
483
- replace(/%24/g, '$').
484
- replace(/%2C/gi, ',').
485
- replace(/%20/g, '+').
486
- replace(/%5B/gi, '[').
487
- replace(/%5D/gi, ']');
488
- }
489
-
490
- /**
491
- * Build a URL by appending params to the end
492
- *
493
- * @param {string} url The base of the url (e.g., http://www.google.com)
494
- * @param {object} [params] The params to be appended
495
- * @returns {string} The formatted url
496
- */
497
- var buildURL = function buildURL(url, params, paramsSerializer) {
498
- /*eslint no-param-reassign:0*/
499
- if (!params) {
500
- return url;
501
- }
502
-
503
- var serializedParams;
504
- if (paramsSerializer) {
505
- serializedParams = paramsSerializer(params);
506
- } else if (utils.isURLSearchParams(params)) {
507
- serializedParams = params.toString();
508
- } else {
509
- var parts = [];
510
-
511
- utils.forEach(params, function serialize(val, key) {
512
- if (val === null || typeof val === 'undefined') {
513
- return;
514
- }
515
-
516
- if (utils.isArray(val)) {
517
- key = key + '[]';
518
- } else {
519
- val = [val];
520
- }
521
-
522
- utils.forEach(val, function parseValue(v) {
523
- if (utils.isDate(v)) {
524
- v = v.toISOString();
525
- } else if (utils.isObject(v)) {
526
- v = JSON.stringify(v);
527
- }
528
- parts.push(encode(key) + '=' + encode(v));
529
- });
530
- });
531
-
532
- serializedParams = parts.join('&');
533
- }
534
-
535
- if (serializedParams) {
536
- var hashmarkIndex = url.indexOf('#');
537
- if (hashmarkIndex !== -1) {
538
- url = url.slice(0, hashmarkIndex);
539
- }
540
-
541
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
542
- }
543
-
544
- return url;
545
- };
546
-
547
- function InterceptorManager() {
548
- this.handlers = [];
549
- }
550
-
551
- /**
552
- * Add a new interceptor to the stack
553
- *
554
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
555
- * @param {Function} rejected The function to handle `reject` for a `Promise`
556
- *
557
- * @return {Number} An ID used to remove interceptor later
558
- */
559
- InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
560
- this.handlers.push({
561
- fulfilled: fulfilled,
562
- rejected: rejected,
563
- synchronous: options ? options.synchronous : false,
564
- runWhen: options ? options.runWhen : null
565
- });
566
- return this.handlers.length - 1;
567
- };
568
-
569
- /**
570
- * Remove an interceptor from the stack
571
- *
572
- * @param {Number} id The ID that was returned by `use`
573
- */
574
- InterceptorManager.prototype.eject = function eject(id) {
575
- if (this.handlers[id]) {
576
- this.handlers[id] = null;
577
- }
578
- };
579
-
580
- /**
581
- * Iterate over all the registered interceptors
582
- *
583
- * This method is particularly useful for skipping over any
584
- * interceptors that may have become `null` calling `eject`.
585
- *
586
- * @param {Function} fn The function to call for each interceptor
587
- */
588
- InterceptorManager.prototype.forEach = function forEach(fn) {
589
- utils.forEach(this.handlers, function forEachHandler(h) {
590
- if (h !== null) {
591
- fn(h);
592
- }
593
- });
594
- };
595
-
596
- var InterceptorManager_1 = InterceptorManager;
597
-
598
- var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
599
- utils.forEach(headers, function processHeader(value, name) {
600
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
601
- headers[normalizedName] = value;
602
- delete headers[name];
603
- }
604
- });
605
- };
606
-
607
- /**
608
- * Create an Error with the specified message, config, error code, request and response.
609
- *
610
- * @param {string} message The error message.
611
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
612
- * @param {Object} [config] The config.
613
- * @param {Object} [request] The request.
614
- * @param {Object} [response] The response.
615
- * @returns {Error} The created error.
616
- */
617
- function AxiosError(message, code, config, request, response) {
618
- Error.call(this);
619
- this.message = message;
620
- this.name = 'AxiosError';
621
- code && (this.code = code);
622
- config && (this.config = config);
623
- request && (this.request = request);
624
- response && (this.response = response);
625
- }
626
-
627
- utils.inherits(AxiosError, Error, {
628
- toJSON: function toJSON() {
629
- return {
630
- // Standard
631
- message: this.message,
632
- name: this.name,
633
- // Microsoft
634
- description: this.description,
635
- number: this.number,
636
- // Mozilla
637
- fileName: this.fileName,
638
- lineNumber: this.lineNumber,
639
- columnNumber: this.columnNumber,
640
- stack: this.stack,
641
- // Axios
642
- config: this.config,
643
- code: this.code,
644
- status: this.response && this.response.status ? this.response.status : null
645
- };
646
- }
647
- });
648
-
649
- var prototype = AxiosError.prototype;
650
- var descriptors = {};
651
-
652
- [
653
- 'ERR_BAD_OPTION_VALUE',
654
- 'ERR_BAD_OPTION',
655
- 'ECONNABORTED',
656
- 'ETIMEDOUT',
657
- 'ERR_NETWORK',
658
- 'ERR_FR_TOO_MANY_REDIRECTS',
659
- 'ERR_DEPRECATED',
660
- 'ERR_BAD_RESPONSE',
661
- 'ERR_BAD_REQUEST',
662
- 'ERR_CANCELED'
663
- // eslint-disable-next-line func-names
664
- ].forEach(function(code) {
665
- descriptors[code] = {value: code};
666
- });
667
-
668
- Object.defineProperties(AxiosError, descriptors);
669
- Object.defineProperty(prototype, 'isAxiosError', {value: true});
670
-
671
- // eslint-disable-next-line func-names
672
- AxiosError.from = function(error, code, config, request, response, customProps) {
673
- var axiosError = Object.create(prototype);
674
-
675
- utils.toFlatObject(error, axiosError, function filter(obj) {
676
- return obj !== Error.prototype;
677
- });
678
-
679
- AxiosError.call(axiosError, error.message, code, config, request, response);
680
-
681
- axiosError.name = error.name;
682
-
683
- customProps && Object.assign(axiosError, customProps);
684
-
685
- return axiosError;
686
- };
687
-
688
- var AxiosError_1 = AxiosError;
689
-
690
- var transitional = {
691
- silentJSONParsing: true,
692
- forcedJSONParsing: true,
693
- clarifyTimeoutError: false
694
- };
695
-
696
- /**
697
- * Convert a data object to FormData
698
- * @param {Object} obj
699
- * @param {?Object} [formData]
700
- * @returns {Object}
701
- **/
702
-
703
- function toFormData(obj, formData) {
704
- // eslint-disable-next-line no-param-reassign
705
- formData = formData || new FormData();
706
-
707
- var stack = [];
708
-
709
- function convertValue(value) {
710
- if (value === null) return '';
711
-
712
- if (utils.isDate(value)) {
713
- return value.toISOString();
714
- }
715
-
716
- if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
717
- return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
718
- }
719
-
720
- return value;
721
- }
722
-
723
- function build(data, parentKey) {
724
- if (utils.isPlainObject(data) || utils.isArray(data)) {
725
- if (stack.indexOf(data) !== -1) {
726
- throw Error('Circular reference detected in ' + parentKey);
727
- }
728
-
729
- stack.push(data);
730
-
731
- utils.forEach(data, function each(value, key) {
732
- if (utils.isUndefined(value)) return;
733
- var fullKey = parentKey ? parentKey + '.' + key : key;
734
- var arr;
735
-
736
- if (value && !parentKey && typeof value === 'object') {
737
- if (utils.endsWith(key, '{}')) {
738
- // eslint-disable-next-line no-param-reassign
739
- value = JSON.stringify(value);
740
- } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
741
- // eslint-disable-next-line func-names
742
- arr.forEach(function(el) {
743
- !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
744
- });
745
- return;
746
- }
747
- }
748
-
749
- build(value, fullKey);
750
- });
751
-
752
- stack.pop();
753
- } else {
754
- formData.append(parentKey, convertValue(data));
755
- }
756
- }
757
-
758
- build(obj);
759
-
760
- return formData;
761
- }
762
-
763
- var toFormData_1 = toFormData;
764
-
765
- /**
766
- * Resolve or reject a Promise based on response status.
767
- *
768
- * @param {Function} resolve A function that resolves the promise.
769
- * @param {Function} reject A function that rejects the promise.
770
- * @param {object} response The response.
771
- */
772
- var settle = function settle(resolve, reject, response) {
773
- var validateStatus = response.config.validateStatus;
774
- if (!response.status || !validateStatus || validateStatus(response.status)) {
775
- resolve(response);
776
- } else {
777
- reject(new AxiosError_1(
778
- 'Request failed with status code ' + response.status,
779
- [AxiosError_1.ERR_BAD_REQUEST, AxiosError_1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
780
- response.config,
781
- response.request,
782
- response
783
- ));
784
- }
785
- };
786
-
787
- var cookies = (
788
- utils.isStandardBrowserEnv() ?
789
-
790
- // Standard browser envs support document.cookie
791
- (function standardBrowserEnv() {
792
- return {
793
- write: function write(name, value, expires, path, domain, secure) {
794
- var cookie = [];
795
- cookie.push(name + '=' + encodeURIComponent(value));
796
-
797
- if (utils.isNumber(expires)) {
798
- cookie.push('expires=' + new Date(expires).toGMTString());
799
- }
800
-
801
- if (utils.isString(path)) {
802
- cookie.push('path=' + path);
803
- }
804
-
805
- if (utils.isString(domain)) {
806
- cookie.push('domain=' + domain);
807
- }
808
-
809
- if (secure === true) {
810
- cookie.push('secure');
811
- }
812
-
813
- document.cookie = cookie.join('; ');
814
- },
815
-
816
- read: function read(name) {
817
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
818
- return (match ? decodeURIComponent(match[3]) : null);
819
- },
820
-
821
- remove: function remove(name) {
822
- this.write(name, '', Date.now() - 86400000);
823
- }
824
- };
825
- })() :
826
-
827
- // Non standard browser env (web workers, react-native) lack needed support.
828
- (function nonStandardBrowserEnv() {
829
- return {
830
- write: function write() {},
831
- read: function read() { return null; },
832
- remove: function remove() {}
833
- };
834
- })()
835
- );
836
-
837
- /**
838
- * Determines whether the specified URL is absolute
839
- *
840
- * @param {string} url The URL to test
841
- * @returns {boolean} True if the specified URL is absolute, otherwise false
842
- */
843
- var isAbsoluteURL = function isAbsoluteURL(url) {
844
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
845
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
846
- // by any combination of letters, digits, plus, period, or hyphen.
847
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
848
- };
849
-
850
- /**
851
- * Creates a new URL by combining the specified URLs
852
- *
853
- * @param {string} baseURL The base URL
854
- * @param {string} relativeURL The relative URL
855
- * @returns {string} The combined URL
856
- */
857
- var combineURLs = function combineURLs(baseURL, relativeURL) {
858
- return relativeURL
859
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
860
- : baseURL;
861
- };
862
-
863
- /**
864
- * Creates a new URL by combining the baseURL with the requestedURL,
865
- * only when the requestedURL is not already an absolute URL.
866
- * If the requestURL is absolute, this function returns the requestedURL untouched.
867
- *
868
- * @param {string} baseURL The base URL
869
- * @param {string} requestedURL Absolute or relative URL to combine
870
- * @returns {string} The combined full path
871
- */
872
- var buildFullPath = function buildFullPath(baseURL, requestedURL) {
873
- if (baseURL && !isAbsoluteURL(requestedURL)) {
874
- return combineURLs(baseURL, requestedURL);
875
- }
876
- return requestedURL;
877
- };
878
-
879
- // Headers whose duplicates are ignored by node
880
- // c.f. https://nodejs.org/api/http.html#http_message_headers
881
- var ignoreDuplicateOf = [
882
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
883
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
884
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
885
- 'referer', 'retry-after', 'user-agent'
886
- ];
887
-
888
- /**
889
- * Parse headers into an object
890
- *
891
- * ```
892
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
893
- * Content-Type: application/json
894
- * Connection: keep-alive
895
- * Transfer-Encoding: chunked
896
- * ```
897
- *
898
- * @param {String} headers Headers needing to be parsed
899
- * @returns {Object} Headers parsed into an object
900
- */
901
- var parseHeaders = function parseHeaders(headers) {
902
- var parsed = {};
903
- var key;
904
- var val;
905
- var i;
906
-
907
- if (!headers) { return parsed; }
908
-
909
- utils.forEach(headers.split('\n'), function parser(line) {
910
- i = line.indexOf(':');
911
- key = utils.trim(line.substr(0, i)).toLowerCase();
912
- val = utils.trim(line.substr(i + 1));
913
-
914
- if (key) {
915
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
916
- return;
917
- }
918
- if (key === 'set-cookie') {
919
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
920
- } else {
921
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
922
- }
923
- }
924
- });
925
-
926
- return parsed;
927
- };
928
-
929
- var isURLSameOrigin = (
930
- utils.isStandardBrowserEnv() ?
931
-
932
- // Standard browser envs have full support of the APIs needed to test
933
- // whether the request URL is of the same origin as current location.
934
- (function standardBrowserEnv() {
935
- var msie = /(msie|trident)/i.test(navigator.userAgent);
936
- var urlParsingNode = document.createElement('a');
937
- var originURL;
938
-
939
- /**
940
- * Parse a URL to discover it's components
941
- *
942
- * @param {String} url The URL to be parsed
943
- * @returns {Object}
944
- */
945
- function resolveURL(url) {
946
- var href = url;
947
-
948
- if (msie) {
949
- // IE needs attribute set twice to normalize properties
950
- urlParsingNode.setAttribute('href', href);
951
- href = urlParsingNode.href;
952
- }
953
-
954
- urlParsingNode.setAttribute('href', href);
955
-
956
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
957
- return {
958
- href: urlParsingNode.href,
959
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
960
- host: urlParsingNode.host,
961
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
962
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
963
- hostname: urlParsingNode.hostname,
964
- port: urlParsingNode.port,
965
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
966
- urlParsingNode.pathname :
967
- '/' + urlParsingNode.pathname
968
- };
969
- }
970
-
971
- originURL = resolveURL(window.location.href);
972
-
973
- /**
974
- * Determine if a URL shares the same origin as the current location
975
- *
976
- * @param {String} requestURL The URL to test
977
- * @returns {boolean} True if URL shares the same origin, otherwise false
978
- */
979
- return function isURLSameOrigin(requestURL) {
980
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
981
- return (parsed.protocol === originURL.protocol &&
982
- parsed.host === originURL.host);
983
- };
984
- })() :
985
-
986
- // Non standard browser envs (web workers, react-native) lack needed support.
987
- (function nonStandardBrowserEnv() {
988
- return function isURLSameOrigin() {
989
- return true;
990
- };
991
- })()
992
- );
993
-
994
- /**
995
- * A `CanceledError` is an object that is thrown when an operation is canceled.
996
- *
997
- * @class
998
- * @param {string=} message The message.
999
- */
1000
- function CanceledError(message) {
1001
- // eslint-disable-next-line no-eq-null,eqeqeq
1002
- AxiosError_1.call(this, message == null ? 'canceled' : message, AxiosError_1.ERR_CANCELED);
1003
- this.name = 'CanceledError';
1004
- }
1005
-
1006
- utils.inherits(CanceledError, AxiosError_1, {
1007
- __CANCEL__: true
1008
- });
1009
-
1010
- var CanceledError_1 = CanceledError;
1011
-
1012
- var parseProtocol = function parseProtocol(url) {
1013
- var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1014
- return match && match[1] || '';
1015
- };
1016
-
1017
- var xhr = function xhrAdapter(config) {
1018
- return new Promise(function dispatchXhrRequest(resolve, reject) {
1019
- var requestData = config.data;
1020
- var requestHeaders = config.headers;
1021
- var responseType = config.responseType;
1022
- var onCanceled;
1023
- function done() {
1024
- if (config.cancelToken) {
1025
- config.cancelToken.unsubscribe(onCanceled);
1026
- }
1027
-
1028
- if (config.signal) {
1029
- config.signal.removeEventListener('abort', onCanceled);
1030
- }
1031
- }
1032
-
1033
- if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
1034
- delete requestHeaders['Content-Type']; // Let the browser set it
1035
- }
1036
-
1037
- var request = new XMLHttpRequest();
1038
-
1039
- // HTTP basic authentication
1040
- if (config.auth) {
1041
- var username = config.auth.username || '';
1042
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1043
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1044
- }
1045
-
1046
- var fullPath = buildFullPath(config.baseURL, config.url);
1047
-
1048
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1049
-
1050
- // Set the request timeout in MS
1051
- request.timeout = config.timeout;
1052
-
1053
- function onloadend() {
1054
- if (!request) {
1055
- return;
1056
- }
1057
- // Prepare the response
1058
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1059
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1060
- request.responseText : request.response;
1061
- var response = {
1062
- data: responseData,
1063
- status: request.status,
1064
- statusText: request.statusText,
1065
- headers: responseHeaders,
1066
- config: config,
1067
- request: request
1068
- };
1069
-
1070
- settle(function _resolve(value) {
1071
- resolve(value);
1072
- done();
1073
- }, function _reject(err) {
1074
- reject(err);
1075
- done();
1076
- }, response);
1077
-
1078
- // Clean up request
1079
- request = null;
1080
- }
1081
-
1082
- if ('onloadend' in request) {
1083
- // Use onloadend if available
1084
- request.onloadend = onloadend;
1085
- } else {
1086
- // Listen for ready state to emulate onloadend
1087
- request.onreadystatechange = function handleLoad() {
1088
- if (!request || request.readyState !== 4) {
1089
- return;
1090
- }
1091
-
1092
- // The request errored out and we didn't get a response, this will be
1093
- // handled by onerror instead
1094
- // With one exception: request that using file: protocol, most browsers
1095
- // will return status as 0 even though it's a successful request
1096
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1097
- return;
1098
- }
1099
- // readystate handler is calling before onerror or ontimeout handlers,
1100
- // so we should call onloadend on the next 'tick'
1101
- setTimeout(onloadend);
1102
- };
1103
- }
1104
-
1105
- // Handle browser request cancellation (as opposed to a manual cancellation)
1106
- request.onabort = function handleAbort() {
1107
- if (!request) {
1108
- return;
1109
- }
1110
-
1111
- reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
1112
-
1113
- // Clean up request
1114
- request = null;
1115
- };
1116
-
1117
- // Handle low level network errors
1118
- request.onerror = function handleError() {
1119
- // Real errors are hidden from us by the browser
1120
- // onerror should only fire if it's a network error
1121
- reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request, request));
1122
-
1123
- // Clean up request
1124
- request = null;
1125
- };
1126
-
1127
- // Handle timeout
1128
- request.ontimeout = function handleTimeout() {
1129
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1130
- var transitional$1 = config.transitional || transitional;
1131
- if (config.timeoutErrorMessage) {
1132
- timeoutErrorMessage = config.timeoutErrorMessage;
1133
- }
1134
- reject(new AxiosError_1(
1135
- timeoutErrorMessage,
1136
- transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
1137
- config,
1138
- request));
1139
-
1140
- // Clean up request
1141
- request = null;
1142
- };
1143
-
1144
- // Add xsrf header
1145
- // This is only done if running in a standard browser environment.
1146
- // Specifically not if we're in a web worker, or react-native.
1147
- if (utils.isStandardBrowserEnv()) {
1148
- // Add xsrf header
1149
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
1150
- cookies.read(config.xsrfCookieName) :
1151
- undefined;
1152
-
1153
- if (xsrfValue) {
1154
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
1155
- }
1156
- }
1157
-
1158
- // Add headers to the request
1159
- if ('setRequestHeader' in request) {
1160
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1161
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1162
- // Remove Content-Type if data is undefined
1163
- delete requestHeaders[key];
1164
- } else {
1165
- // Otherwise add header to the request
1166
- request.setRequestHeader(key, val);
1167
- }
1168
- });
1169
- }
1170
-
1171
- // Add withCredentials to request if needed
1172
- if (!utils.isUndefined(config.withCredentials)) {
1173
- request.withCredentials = !!config.withCredentials;
1174
- }
1175
-
1176
- // Add responseType to request if needed
1177
- if (responseType && responseType !== 'json') {
1178
- request.responseType = config.responseType;
1179
- }
1180
-
1181
- // Handle progress if needed
1182
- if (typeof config.onDownloadProgress === 'function') {
1183
- request.addEventListener('progress', config.onDownloadProgress);
1184
- }
1185
-
1186
- // Not all browsers support upload events
1187
- if (typeof config.onUploadProgress === 'function' && request.upload) {
1188
- request.upload.addEventListener('progress', config.onUploadProgress);
1189
- }
1190
-
1191
- if (config.cancelToken || config.signal) {
1192
- // Handle cancellation
1193
- // eslint-disable-next-line func-names
1194
- onCanceled = function(cancel) {
1195
- if (!request) {
1196
- return;
1197
- }
1198
- reject(!cancel || (cancel && cancel.type) ? new CanceledError_1() : cancel);
1199
- request.abort();
1200
- request = null;
1201
- };
1202
-
1203
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
1204
- if (config.signal) {
1205
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1206
- }
1207
- }
1208
-
1209
- if (!requestData) {
1210
- requestData = null;
1211
- }
1212
-
1213
- var protocol = parseProtocol(fullPath);
1214
-
1215
- if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
1216
- reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
1217
- return;
1218
- }
1219
-
1220
-
1221
- // Send the request
1222
- request.send(requestData);
1223
- });
1224
- };
1225
-
1226
- // eslint-disable-next-line strict
1227
- var _null = null;
1228
-
1229
- var DEFAULT_CONTENT_TYPE = {
1230
- 'Content-Type': 'application/x-www-form-urlencoded'
1231
- };
1232
-
1233
- function setContentTypeIfUnset(headers, value) {
1234
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
1235
- headers['Content-Type'] = value;
1236
- }
1237
- }
1238
-
1239
- function getDefaultAdapter() {
1240
- var adapter;
1241
- if (typeof XMLHttpRequest !== 'undefined') {
1242
- // For browsers use XHR adapter
1243
- adapter = xhr;
1244
- } else if (typeof process_1 !== 'undefined' && Object.prototype.toString.call(process_1) === '[object process]') {
1245
- // For node use HTTP adapter
1246
- adapter = xhr;
1247
- }
1248
- return adapter;
1249
- }
1250
-
1251
- function stringifySafely(rawValue, parser, encoder) {
1252
- if (utils.isString(rawValue)) {
1253
- try {
1254
- (parser || JSON.parse)(rawValue);
1255
- return utils.trim(rawValue);
1256
- } catch (e) {
1257
- if (e.name !== 'SyntaxError') {
1258
- throw e;
1259
- }
1260
- }
1261
- }
1262
-
1263
- return (encoder || JSON.stringify)(rawValue);
1264
- }
1265
-
1266
- var defaults = {
1267
-
1268
- transitional: transitional,
1269
-
1270
- adapter: getDefaultAdapter(),
1271
-
1272
- transformRequest: [function transformRequest(data, headers) {
1273
- normalizeHeaderName(headers, 'Accept');
1274
- normalizeHeaderName(headers, 'Content-Type');
1275
-
1276
- if (utils.isFormData(data) ||
1277
- utils.isArrayBuffer(data) ||
1278
- utils.isBuffer(data) ||
1279
- utils.isStream(data) ||
1280
- utils.isFile(data) ||
1281
- utils.isBlob(data)
1282
- ) {
1283
- return data;
1284
- }
1285
- if (utils.isArrayBufferView(data)) {
1286
- return data.buffer;
1287
- }
1288
- if (utils.isURLSearchParams(data)) {
1289
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1290
- return data.toString();
1291
- }
1292
-
1293
- var isObjectPayload = utils.isObject(data);
1294
- var contentType = headers && headers['Content-Type'];
1295
-
1296
- var isFileList;
1297
-
1298
- if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
1299
- var _FormData = this.env && this.env.FormData;
1300
- return toFormData_1(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
1301
- } else if (isObjectPayload || contentType === 'application/json') {
1302
- setContentTypeIfUnset(headers, 'application/json');
1303
- return stringifySafely(data);
1304
- }
1305
-
1306
- return data;
1307
- }],
1308
-
1309
- transformResponse: [function transformResponse(data) {
1310
- var transitional = this.transitional || defaults.transitional;
1311
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
1312
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1313
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
1314
-
1315
- if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
1316
- try {
1317
- return JSON.parse(data);
1318
- } catch (e) {
1319
- if (strictJSONParsing) {
1320
- if (e.name === 'SyntaxError') {
1321
- throw AxiosError_1.from(e, AxiosError_1.ERR_BAD_RESPONSE, this, null, this.response);
1322
- }
1323
- throw e;
1324
- }
1325
- }
1326
- }
1327
-
1328
- return data;
1329
- }],
1330
-
1331
- /**
1332
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1333
- * timeout is not created.
1334
- */
1335
- timeout: 0,
1336
-
1337
- xsrfCookieName: 'XSRF-TOKEN',
1338
- xsrfHeaderName: 'X-XSRF-TOKEN',
1339
-
1340
- maxContentLength: -1,
1341
- maxBodyLength: -1,
1342
-
1343
- env: {
1344
- FormData: _null
1345
- },
1346
-
1347
- validateStatus: function validateStatus(status) {
1348
- return status >= 200 && status < 300;
1349
- },
1350
-
1351
- headers: {
1352
- common: {
1353
- 'Accept': 'application/json, text/plain, */*'
1354
- }
1355
- }
1356
- };
1357
-
1358
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1359
- defaults.headers[method] = {};
1360
- });
1361
-
1362
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1363
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1364
- });
1365
-
1366
- var defaults_1 = defaults;
1367
-
1368
- /**
1369
- * Transform the data for a request or a response
1370
- *
1371
- * @param {Object|String} data The data to be transformed
1372
- * @param {Array} headers The headers for the request or response
1373
- * @param {Array|Function} fns A single function or Array of functions
1374
- * @returns {*} The resulting transformed data
1375
- */
1376
- var transformData = function transformData(data, headers, fns) {
1377
- var context = this || defaults_1;
1378
- /*eslint no-param-reassign:0*/
1379
- utils.forEach(fns, function transform(fn) {
1380
- data = fn.call(context, data, headers);
1381
- });
1382
-
1383
- return data;
1384
- };
1385
-
1386
- var isCancel = function isCancel(value) {
1387
- return !!(value && value.__CANCEL__);
1388
- };
1389
-
1390
- /**
1391
- * Throws a `CanceledError` if cancellation has been requested.
1392
- */
1393
- function throwIfCancellationRequested(config) {
1394
- if (config.cancelToken) {
1395
- config.cancelToken.throwIfRequested();
1396
- }
1397
-
1398
- if (config.signal && config.signal.aborted) {
1399
- throw new CanceledError_1();
1400
- }
1401
- }
1402
-
1403
- /**
1404
- * Dispatch a request to the server using the configured adapter.
1405
- *
1406
- * @param {object} config The config that is to be used for the request
1407
- * @returns {Promise} The Promise to be fulfilled
1408
- */
1409
- var dispatchRequest = function dispatchRequest(config) {
1410
- throwIfCancellationRequested(config);
1411
-
1412
- // Ensure headers exist
1413
- config.headers = config.headers || {};
1414
-
1415
- // Transform request data
1416
- config.data = transformData.call(
1417
- config,
1418
- config.data,
1419
- config.headers,
1420
- config.transformRequest
1421
- );
1422
-
1423
- // Flatten headers
1424
- config.headers = utils.merge(
1425
- config.headers.common || {},
1426
- config.headers[config.method] || {},
1427
- config.headers
1428
- );
1429
-
1430
- utils.forEach(
1431
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
1432
- function cleanHeaderConfig(method) {
1433
- delete config.headers[method];
1434
- }
1435
- );
1436
-
1437
- var adapter = config.adapter || defaults_1.adapter;
1438
-
1439
- return adapter(config).then(function onAdapterResolution(response) {
1440
- throwIfCancellationRequested(config);
1441
-
1442
- // Transform response data
1443
- response.data = transformData.call(
1444
- config,
1445
- response.data,
1446
- response.headers,
1447
- config.transformResponse
1448
- );
1449
-
1450
- return response;
1451
- }, function onAdapterRejection(reason) {
1452
- if (!isCancel(reason)) {
1453
- throwIfCancellationRequested(config);
1454
-
1455
- // Transform response data
1456
- if (reason && reason.response) {
1457
- reason.response.data = transformData.call(
1458
- config,
1459
- reason.response.data,
1460
- reason.response.headers,
1461
- config.transformResponse
1462
- );
1463
- }
1464
- }
1465
-
1466
- return Promise.reject(reason);
1467
- });
1468
- };
1469
-
1470
- /**
1471
- * Config-specific merge-function which creates a new config-object
1472
- * by merging two configuration objects together.
1473
- *
1474
- * @param {Object} config1
1475
- * @param {Object} config2
1476
- * @returns {Object} New object resulting from merging config2 to config1
1477
- */
1478
- var mergeConfig = function mergeConfig(config1, config2) {
1479
- // eslint-disable-next-line no-param-reassign
1480
- config2 = config2 || {};
1481
- var config = {};
1482
-
1483
- function getMergedValue(target, source) {
1484
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
1485
- return utils.merge(target, source);
1486
- } else if (utils.isPlainObject(source)) {
1487
- return utils.merge({}, source);
1488
- } else if (utils.isArray(source)) {
1489
- return source.slice();
1490
- }
1491
- return source;
1492
- }
1493
-
1494
- // eslint-disable-next-line consistent-return
1495
- function mergeDeepProperties(prop) {
1496
- if (!utils.isUndefined(config2[prop])) {
1497
- return getMergedValue(config1[prop], config2[prop]);
1498
- } else if (!utils.isUndefined(config1[prop])) {
1499
- return getMergedValue(undefined, config1[prop]);
1500
- }
1501
- }
1502
-
1503
- // eslint-disable-next-line consistent-return
1504
- function valueFromConfig2(prop) {
1505
- if (!utils.isUndefined(config2[prop])) {
1506
- return getMergedValue(undefined, config2[prop]);
1507
- }
1508
- }
1509
-
1510
- // eslint-disable-next-line consistent-return
1511
- function defaultToConfig2(prop) {
1512
- if (!utils.isUndefined(config2[prop])) {
1513
- return getMergedValue(undefined, config2[prop]);
1514
- } else if (!utils.isUndefined(config1[prop])) {
1515
- return getMergedValue(undefined, config1[prop]);
1516
- }
1517
- }
1518
-
1519
- // eslint-disable-next-line consistent-return
1520
- function mergeDirectKeys(prop) {
1521
- if (prop in config2) {
1522
- return getMergedValue(config1[prop], config2[prop]);
1523
- } else if (prop in config1) {
1524
- return getMergedValue(undefined, config1[prop]);
1525
- }
1526
- }
1527
-
1528
- var mergeMap = {
1529
- 'url': valueFromConfig2,
1530
- 'method': valueFromConfig2,
1531
- 'data': valueFromConfig2,
1532
- 'baseURL': defaultToConfig2,
1533
- 'transformRequest': defaultToConfig2,
1534
- 'transformResponse': defaultToConfig2,
1535
- 'paramsSerializer': defaultToConfig2,
1536
- 'timeout': defaultToConfig2,
1537
- 'timeoutMessage': defaultToConfig2,
1538
- 'withCredentials': defaultToConfig2,
1539
- 'adapter': defaultToConfig2,
1540
- 'responseType': defaultToConfig2,
1541
- 'xsrfCookieName': defaultToConfig2,
1542
- 'xsrfHeaderName': defaultToConfig2,
1543
- 'onUploadProgress': defaultToConfig2,
1544
- 'onDownloadProgress': defaultToConfig2,
1545
- 'decompress': defaultToConfig2,
1546
- 'maxContentLength': defaultToConfig2,
1547
- 'maxBodyLength': defaultToConfig2,
1548
- 'beforeRedirect': defaultToConfig2,
1549
- 'transport': defaultToConfig2,
1550
- 'httpAgent': defaultToConfig2,
1551
- 'httpsAgent': defaultToConfig2,
1552
- 'cancelToken': defaultToConfig2,
1553
- 'socketPath': defaultToConfig2,
1554
- 'responseEncoding': defaultToConfig2,
1555
- 'validateStatus': mergeDirectKeys
1556
- };
1557
-
1558
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1559
- var merge = mergeMap[prop] || mergeDeepProperties;
1560
- var configValue = merge(prop);
1561
- (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1562
- });
1563
-
1564
- return config;
1565
- };
1566
-
1567
- var data = {
1568
- "version": "0.27.2"
1569
- };
1570
-
1571
- var VERSION = data.version;
1572
-
1573
-
1574
- var validators$1 = {};
1575
-
1576
- // eslint-disable-next-line func-names
1577
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
1578
- validators$1[type] = function validator(thing) {
1579
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1580
- };
1581
- });
1582
-
1583
- var deprecatedWarnings = {};
1584
-
1585
- /**
1586
- * Transitional option validator
1587
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
1588
- * @param {string?} version - deprecated version / removed since version
1589
- * @param {string?} message - some message with additional info
1590
- * @returns {function}
1591
- */
1592
- validators$1.transitional = function transitional(validator, version, message) {
1593
- function formatMessage(opt, desc) {
1594
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1595
- }
1596
-
1597
- // eslint-disable-next-line func-names
1598
- return function(value, opt, opts) {
1599
- if (validator === false) {
1600
- throw new AxiosError_1(
1601
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
1602
- AxiosError_1.ERR_DEPRECATED
1603
- );
1604
- }
1605
-
1606
- if (version && !deprecatedWarnings[opt]) {
1607
- deprecatedWarnings[opt] = true;
1608
- // eslint-disable-next-line no-console
1609
- console.warn(
1610
- formatMessage(
1611
- opt,
1612
- ' has been deprecated since v' + version + ' and will be removed in the near future'
1613
- )
1614
- );
1615
- }
1616
-
1617
- return validator ? validator(value, opt, opts) : true;
1618
- };
1619
- };
1620
-
1621
- /**
1622
- * Assert object's properties type
1623
- * @param {object} options
1624
- * @param {object} schema
1625
- * @param {boolean?} allowUnknown
1626
- */
1627
-
1628
- function assertOptions(options, schema, allowUnknown) {
1629
- if (typeof options !== 'object') {
1630
- throw new AxiosError_1('options must be an object', AxiosError_1.ERR_BAD_OPTION_VALUE);
1631
- }
1632
- var keys = Object.keys(options);
1633
- var i = keys.length;
1634
- while (i-- > 0) {
1635
- var opt = keys[i];
1636
- var validator = schema[opt];
1637
- if (validator) {
1638
- var value = options[opt];
1639
- var result = value === undefined || validator(value, opt, options);
1640
- if (result !== true) {
1641
- throw new AxiosError_1('option ' + opt + ' must be ' + result, AxiosError_1.ERR_BAD_OPTION_VALUE);
1642
- }
1643
- continue;
1644
- }
1645
- if (allowUnknown !== true) {
1646
- throw new AxiosError_1('Unknown option ' + opt, AxiosError_1.ERR_BAD_OPTION);
1647
- }
1648
- }
1649
- }
1650
-
1651
- var validator = {
1652
- assertOptions: assertOptions,
1653
- validators: validators$1
1654
- };
1655
-
1656
- var validators = validator.validators;
1657
- /**
1658
- * Create a new instance of Axios
1659
- *
1660
- * @param {Object} instanceConfig The default config for the instance
1661
- */
1662
- function Axios(instanceConfig) {
1663
- this.defaults = instanceConfig;
1664
- this.interceptors = {
1665
- request: new InterceptorManager_1(),
1666
- response: new InterceptorManager_1()
1667
- };
1668
- }
1669
-
1670
- /**
1671
- * Dispatch a request
1672
- *
1673
- * @param {Object} config The config specific for this request (merged with this.defaults)
1674
- */
1675
- Axios.prototype.request = function request(configOrUrl, config) {
1676
- /*eslint no-param-reassign:0*/
1677
- // Allow for axios('example/url'[, config]) a la fetch API
1678
- if (typeof configOrUrl === 'string') {
1679
- config = config || {};
1680
- config.url = configOrUrl;
1681
- } else {
1682
- config = configOrUrl || {};
1683
- }
1684
-
1685
- config = mergeConfig(this.defaults, config);
1686
-
1687
- // Set config.method
1688
- if (config.method) {
1689
- config.method = config.method.toLowerCase();
1690
- } else if (this.defaults.method) {
1691
- config.method = this.defaults.method.toLowerCase();
1692
- } else {
1693
- config.method = 'get';
1694
- }
1695
-
1696
- var transitional = config.transitional;
1697
-
1698
- if (transitional !== undefined) {
1699
- validator.assertOptions(transitional, {
1700
- silentJSONParsing: validators.transitional(validators.boolean),
1701
- forcedJSONParsing: validators.transitional(validators.boolean),
1702
- clarifyTimeoutError: validators.transitional(validators.boolean)
1703
- }, false);
1704
- }
1705
-
1706
- // filter out skipped interceptors
1707
- var requestInterceptorChain = [];
1708
- var synchronousRequestInterceptors = true;
1709
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
1710
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
1711
- return;
1712
- }
1713
-
1714
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
1715
-
1716
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
1717
- });
1718
-
1719
- var responseInterceptorChain = [];
1720
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
1721
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
1722
- });
1723
-
1724
- var promise;
1725
-
1726
- if (!synchronousRequestInterceptors) {
1727
- var chain = [dispatchRequest, undefined];
1728
-
1729
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
1730
- chain = chain.concat(responseInterceptorChain);
1731
-
1732
- promise = Promise.resolve(config);
1733
- while (chain.length) {
1734
- promise = promise.then(chain.shift(), chain.shift());
1735
- }
1736
-
1737
- return promise;
1738
- }
1739
-
1740
-
1741
- var newConfig = config;
1742
- while (requestInterceptorChain.length) {
1743
- var onFulfilled = requestInterceptorChain.shift();
1744
- var onRejected = requestInterceptorChain.shift();
1745
- try {
1746
- newConfig = onFulfilled(newConfig);
1747
- } catch (error) {
1748
- onRejected(error);
1749
- break;
1750
- }
1751
- }
1752
-
1753
- try {
1754
- promise = dispatchRequest(newConfig);
1755
- } catch (error) {
1756
- return Promise.reject(error);
1757
- }
1758
-
1759
- while (responseInterceptorChain.length) {
1760
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
1761
- }
1762
-
1763
- return promise;
1764
- };
1765
-
1766
- Axios.prototype.getUri = function getUri(config) {
1767
- config = mergeConfig(this.defaults, config);
1768
- var fullPath = buildFullPath(config.baseURL, config.url);
1769
- return buildURL(fullPath, config.params, config.paramsSerializer);
1770
- };
1771
-
1772
- // Provide aliases for supported request methods
1773
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
1774
- /*eslint func-names:0*/
1775
- Axios.prototype[method] = function(url, config) {
1776
- return this.request(mergeConfig(config || {}, {
1777
- method: method,
1778
- url: url,
1779
- data: (config || {}).data
1780
- }));
1781
- };
1782
- });
1783
-
1784
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1785
- /*eslint func-names:0*/
1786
-
1787
- function generateHTTPMethod(isForm) {
1788
- return function httpMethod(url, data, config) {
1789
- return this.request(mergeConfig(config || {}, {
1790
- method: method,
1791
- headers: isForm ? {
1792
- 'Content-Type': 'multipart/form-data'
1793
- } : {},
1794
- url: url,
1795
- data: data
1796
- }));
1797
- };
1798
- }
1799
-
1800
- Axios.prototype[method] = generateHTTPMethod();
1801
-
1802
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
1803
- });
1804
-
1805
- var Axios_1 = Axios;
1806
-
1807
- /**
1808
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
1809
- *
1810
- * @class
1811
- * @param {Function} executor The executor function.
1812
- */
1813
- function CancelToken(executor) {
1814
- if (typeof executor !== 'function') {
1815
- throw new TypeError('executor must be a function.');
1816
- }
1817
-
1818
- var resolvePromise;
1819
-
1820
- this.promise = new Promise(function promiseExecutor(resolve) {
1821
- resolvePromise = resolve;
1822
- });
1823
-
1824
- var token = this;
1825
-
1826
- // eslint-disable-next-line func-names
1827
- this.promise.then(function(cancel) {
1828
- if (!token._listeners) return;
1829
-
1830
- var i;
1831
- var l = token._listeners.length;
1832
-
1833
- for (i = 0; i < l; i++) {
1834
- token._listeners[i](cancel);
1835
- }
1836
- token._listeners = null;
1837
- });
1838
-
1839
- // eslint-disable-next-line func-names
1840
- this.promise.then = function(onfulfilled) {
1841
- var _resolve;
1842
- // eslint-disable-next-line func-names
1843
- var promise = new Promise(function(resolve) {
1844
- token.subscribe(resolve);
1845
- _resolve = resolve;
1846
- }).then(onfulfilled);
1847
-
1848
- promise.cancel = function reject() {
1849
- token.unsubscribe(_resolve);
1850
- };
1851
-
1852
- return promise;
1853
- };
1854
-
1855
- executor(function cancel(message) {
1856
- if (token.reason) {
1857
- // Cancellation has already been requested
1858
- return;
1859
- }
1860
-
1861
- token.reason = new CanceledError_1(message);
1862
- resolvePromise(token.reason);
1863
- });
1864
- }
1865
-
1866
- /**
1867
- * Throws a `CanceledError` if cancellation has been requested.
1868
- */
1869
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
1870
- if (this.reason) {
1871
- throw this.reason;
1872
- }
1873
- };
1874
-
1875
- /**
1876
- * Subscribe to the cancel signal
1877
- */
1878
-
1879
- CancelToken.prototype.subscribe = function subscribe(listener) {
1880
- if (this.reason) {
1881
- listener(this.reason);
1882
- return;
1883
- }
1884
-
1885
- if (this._listeners) {
1886
- this._listeners.push(listener);
1887
- } else {
1888
- this._listeners = [listener];
1889
- }
1890
- };
1891
-
1892
- /**
1893
- * Unsubscribe from the cancel signal
1894
- */
1895
-
1896
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
1897
- if (!this._listeners) {
1898
- return;
1899
- }
1900
- var index = this._listeners.indexOf(listener);
1901
- if (index !== -1) {
1902
- this._listeners.splice(index, 1);
1903
- }
1904
- };
1905
-
1906
- /**
1907
- * Returns an object that contains a new `CancelToken` and a function that, when called,
1908
- * cancels the `CancelToken`.
1909
- */
1910
- CancelToken.source = function source() {
1911
- var cancel;
1912
- var token = new CancelToken(function executor(c) {
1913
- cancel = c;
1914
- });
1915
- return {
1916
- token: token,
1917
- cancel: cancel
1918
- };
1919
- };
1920
-
1921
- var CancelToken_1 = CancelToken;
1922
-
1923
- /**
1924
- * Syntactic sugar for invoking a function and expanding an array for arguments.
1925
- *
1926
- * Common use case would be to use `Function.prototype.apply`.
1927
- *
1928
- * ```js
1929
- * function f(x, y, z) {}
1930
- * var args = [1, 2, 3];
1931
- * f.apply(null, args);
1932
- * ```
1933
- *
1934
- * With `spread` this example can be re-written.
1935
- *
1936
- * ```js
1937
- * spread(function(x, y, z) {})([1, 2, 3]);
1938
- * ```
1939
- *
1940
- * @param {Function} callback
1941
- * @returns {Function}
1942
- */
1943
- var spread = function spread(callback) {
1944
- return function wrap(arr) {
1945
- return callback.apply(null, arr);
1946
- };
1947
- };
1948
-
1949
- /**
1950
- * Determines whether the payload is an error thrown by Axios
1951
- *
1952
- * @param {*} payload The value to test
1953
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
1954
- */
1955
- var isAxiosError = function isAxiosError(payload) {
1956
- return utils.isObject(payload) && (payload.isAxiosError === true);
1957
- };
1958
-
1959
- /**
1960
- * Create an instance of Axios
1961
- *
1962
- * @param {Object} defaultConfig The default config for the instance
1963
- * @return {Axios} A new instance of Axios
1964
- */
1965
- function createInstance(defaultConfig) {
1966
- var context = new Axios_1(defaultConfig);
1967
- var instance = bind(Axios_1.prototype.request, context);
1968
-
1969
- // Copy axios.prototype to instance
1970
- utils.extend(instance, Axios_1.prototype, context);
1971
-
1972
- // Copy context to instance
1973
- utils.extend(instance, context);
1974
-
1975
- // Factory for creating new instances
1976
- instance.create = function create(instanceConfig) {
1977
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
1978
- };
1979
-
1980
- return instance;
1981
- }
1982
-
1983
- // Create the default instance to be exported
1984
- var axios$1 = createInstance(defaults_1);
1985
-
1986
- // Expose Axios class to allow class inheritance
1987
- axios$1.Axios = Axios_1;
1988
-
1989
- // Expose Cancel & CancelToken
1990
- axios$1.CanceledError = CanceledError_1;
1991
- axios$1.CancelToken = CancelToken_1;
1992
- axios$1.isCancel = isCancel;
1993
- axios$1.VERSION = data.version;
1994
- axios$1.toFormData = toFormData_1;
1995
-
1996
- // Expose AxiosError class
1997
- axios$1.AxiosError = AxiosError_1;
1998
-
1999
- // alias for CanceledError for backward compatibility
2000
- axios$1.Cancel = axios$1.CanceledError;
2001
-
2002
- // Expose all/spread
2003
- axios$1.all = function all(promises) {
2004
- return Promise.all(promises);
2005
- };
2006
- axios$1.spread = spread;
2007
-
2008
- // Expose isAxiosError
2009
- axios$1.isAxiosError = isAxiosError;
2010
-
2011
- var axios_1 = axios$1;
2012
-
2013
- // Allow use of default import syntax in TypeScript
2014
- var _default = axios$1;
2015
- axios_1.default = _default;
2016
-
2017
- var axios = axios_1;
2018
-
2019
- var requestLogger = function (r) {
2020
- // tslint:disable-next-line
2021
- console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
2022
- return r;
2023
- };
2024
- /**
2025
- * VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
2026
- * Endpoints can be used for isolated session tasks.
2027
- * For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
2028
- * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
2029
- * discarded once signing is complete.
2030
- *
2031
- * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
2032
- *
2033
- * ```typescript
2034
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2035
- *
2036
- * const endpoint = new VerdocsEndpoint();
2037
- * endpoint
2038
- * .logRequests(true)
2039
- * .setClientID('1234)
2040
- * .setTimeout(5000);
2041
- * ```
2042
- */
2043
- var VerdocsEndpoint = /** @class */ (function () {
2044
- /**
2045
- * Create a new VerdocsEndpoint to call Verdocs platform services.
2046
- *
2047
- * ```typescript
2048
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2049
- * const endpoint = new VerdocsEndpoint();
2050
- * ```
2051
- */
2052
- function VerdocsEndpoint() {
2053
- this.requestLoggerId = null;
2054
- this.api = axios.create({ baseURL: 'https://api.verdocs.com', timeout: 3000 });
2055
- }
2056
- /**
2057
- * Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
2058
- *
2059
- * ```typescript
2060
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2061
- *
2062
- * const endpoint = new VerdocsEndpoint();
2063
- * endpoint.setTimeout(3000);
2064
- * ```
2065
- */
2066
- VerdocsEndpoint.prototype.setTimeout = function (timeout) {
2067
- this.api.defaults.timeout = timeout;
2068
- return this;
2069
- };
2070
- /**
2071
- * Set the Client ID for Verdocs API calls.
2072
- *
2073
- * ```typescript
2074
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2075
- *
2076
- * const endpoint = new VerdocsEndpoint();
2077
- * endpoint.setClientID('1234);
2078
- * ```
2079
- */
2080
- VerdocsEndpoint.prototype.setClientID = function (clientID) {
2081
- this.api.defaults.headers.common['X-Client-ID'] = clientID;
2082
- return this;
2083
- };
2084
- /**
2085
- * Set the auth token that will be used for Verdocs API calls.
2086
- *
2087
- * ```typescript
2088
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2089
- *
2090
- * const endpoint = new VerdocsEndpoint();
2091
- * endpoint.setAuthorization(accessToken);
2092
- * ```
2093
- */
2094
- VerdocsEndpoint.prototype.setAuthorization = function (accessToken) {
2095
- if (accessToken) {
2096
- this.api.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
2097
- }
2098
- else {
2099
- delete this.api.defaults.headers.common.Authorization;
2100
- }
2101
- return this;
2102
- };
2103
- /**
2104
- * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
2105
- * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
2106
- *
2107
- * ```typescript
2108
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2109
- *
2110
- * const endpoint = new VerdocsEndpoint();
2111
- * endpoint.setSigningAuthorization(accessToken);
2112
- * ```
2113
- */
2114
- VerdocsEndpoint.prototype.setSigningAuthorization = function (accessToken) {
2115
- if (accessToken) {
2116
- this.api.defaults.headers.common.signer = "Bearer ".concat(accessToken);
2117
- }
2118
- else {
2119
- delete this.api.defaults.headers.common.signer;
2120
- }
2121
- return this;
2122
- };
2123
- /**
2124
- * Set the base URL for API calls. May also be set via the constructor.
2125
- *
2126
- * ```typescript
2127
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2128
- *
2129
- * const endpoint = new VerdocsEndpoint();
2130
- * endpoint.setBaseURL('https://api.verdocs.com');
2131
- * ```
2132
- */
2133
- VerdocsEndpoint.prototype.setBaseURL = function (url) {
2134
- this.api.defaults.baseURL = url;
2135
- return this;
2136
- };
2137
- /**
2138
- * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
2139
- *
2140
- * ```typescript
2141
- * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
2142
- *
2143
- * const endpoint = new VerdocsEndpoint();
2144
- * endpoint.logRequests(true);
2145
- * ```
2146
- */
2147
- VerdocsEndpoint.prototype.logRequests = function (enable) {
2148
- if (enable && this.requestLoggerId === null) {
2149
- this.requestLoggerId = this.api.interceptors.request.use(requestLogger);
2150
- }
2151
- else if (!enable && this.requestLoggerId !== null) {
2152
- this.api.interceptors.request.eject(this.requestLoggerId);
2153
- }
2154
- return this;
2155
- };
2156
- return VerdocsEndpoint;
2157
- }());
2158
-
2159
- // This file provides a polyfill for managing globals in both NodeJS and browser environments. This is
2160
- // an anti-pattern we'd hoped to avoid, but we have several projects dependending on one common library
2161
- // (this js-sdk) and we want that library to provide a common endpoint to all callers (so authentication
2162
- // tokens only need to be tracked in one place). The trouble is, one of those libraries is based on
2163
- // StencilJS and is compiling its modules into Web Components. Because of how module resolution works,
2164
- // when those Components load js-sdk they get a separate instance. Without messy options like having to
2165
- // pass raw data from the caller to each Component, or pass around references to a common Endpoint, they
2166
- // have no way to access authenticated sessions unless we make the Endpoint a true global.
2167
- //
2168
- // @credit https://github.com/medikoo/es5-ext/blob/master/global.js
2169
- // @credit https://mathiasbynens.be/notes/globalthis
2170
- var naiveFallback = function () {
2171
- if (typeof self === 'object' && self)
2172
- return self;
2173
- if (typeof window === 'object' && window)
2174
- return window;
2175
- throw new Error('Unable to resolve global `this`');
2176
- };
2177
- var globalThis_1 = (function () {
2178
- if (this)
2179
- return this;
2180
- // Unexpected strict mode (may happen if e.g. bundled into ESM module)
2181
- // Fallback to standard globalThis if available
2182
- if (typeof globalThis === 'object' && globalThis)
2183
- return globalThis;
2184
- // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
2185
- // In all ES5+ engines global object inherits from Object.prototype
2186
- // (if you approached one that doesn't please report)
2187
- try {
2188
- Object.defineProperty(Object.prototype, '__global__', {
2189
- get: function () {
2190
- return this;
2191
- },
2192
- configurable: true,
2193
- });
2194
- }
2195
- catch (error) {
2196
- // Unfortunate case of updates to Object.prototype being restricted
2197
- // via preventExtensions, seal or freeze
2198
- return naiveFallback();
2199
- }
2200
- try {
2201
- // Safari case (window.__global__ works, but __global__ does not)
2202
- if (!__global__)
2203
- return naiveFallback();
2204
- return __global__;
2205
- }
2206
- finally {
2207
- delete Object.prototype.__global__;
2208
- }
2209
- })();
2210
-
2211
- /**
2212
- * The Transport is a global singleton used to call Verdocs APIs. There can only be one Transport per application, and
2213
- * its configuration settings are shared for all callers. This is a simplified form of the Endpoint class where most
2214
- * tasks such as general session-token-management are handled automatically for the caller.
2215
- *
2216
- * @module
2217
- */
2218
- // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
2219
- // Also see globalThis for comments about why we're doing this in the first place.
2220
- var ENDPOINT_KEY = Symbol.for('verdocs-api-endpoint');
2221
- if (!globalThis_1[ENDPOINT_KEY]) {
2222
- globalThis_1[ENDPOINT_KEY] = new VerdocsEndpoint();
2223
- }
2224
- var globalEndpoint = globalThis_1[ENDPOINT_KEY];
2225
- var activeEndpoint = globalEndpoint;
2226
- /**
2227
- * Helper to get the endpoint for direct access to HTTP functions.
2228
- *
2229
- * ```typescript
2230
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2231
- *
2232
- * console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
2233
- * ```
2234
- */
2235
- var getEndpoint = function () {
2236
- return activeEndpoint;
2237
- };
2238
- /**
2239
- * Change the endpoint that will be used when making calls to Verdocs. Only one endpoint may be active at a time.
2240
- * Authorization and other configuration data is specific to each endpoint, and will not be carried over when the
2241
- * endpoint is changed. The typical use-case is to change to a sandboxed endpoint for signing sessions, then revert
2242
- * to the global endpoint when the signing session is complete. To revert, pass `null` as the endpoint to use.
2243
- *
2244
- * ```typescript
2245
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2246
- *
2247
- * const mySigningEndpoint = new VerdocsEndpoint();
2248
- * setActiveEndpoint(mySigningEndpoint);
2249
- * ... [Perform signing operations]
2250
- * setActiveEndpoint(null);
2251
- * ```
2252
- */
2253
- var setActiveEndpoint = function (e) {
2254
- activeEndpoint = e || globalEndpoint;
2255
- };
2256
-
2257
- /* tslint:disable:no-bitwise */
2258
- var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
2259
- // Regular expression to check formal correctness of base64 encoded strings
2260
- var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
2261
- /**
2262
- * Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
2263
- * Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
2264
- */
2265
- var AtoB = function (str) {
2266
- // atob can work with strings with whitespaces, even inside the encoded part,
2267
- // but only \t, \n, \f, \r and ' ', which can be stripped.
2268
- str = String(str).replace(/[\t\n\f\r ]+/g, '');
2269
- if (!b64re.test(str))
2270
- throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
2271
- // Adding the padding if missing, for semplicity
2272
- str += '=='.slice(2 - (str.length & 3));
2273
- var bitmap;
2274
- var result = '';
2275
- var r1;
2276
- var r2;
2277
- var i = 0;
2278
- for (; i < str.length;) {
2279
- bitmap =
2280
- (b64.indexOf(str.charAt(i++)) << 18) |
2281
- (b64.indexOf(str.charAt(i++)) << 12) |
2282
- ((r1 = b64.indexOf(str.charAt(i++))) << 6) |
2283
- (r2 = b64.indexOf(str.charAt(i++)));
2284
- result +=
2285
- r1 === 64
2286
- ? String.fromCharCode((bitmap >> 16) & 255)
2287
- : r2 === 64
2288
- ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
2289
- : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
2290
- }
2291
- return result;
2292
- };
2293
- /**
2294
- * Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
2295
- * many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
2296
- */
2297
- var decodeTokenBody = function (token) { return JSON.parse(AtoB((token || '').split('.')[1] || '')); };
2298
- /**
2299
- * Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
2300
- * `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
2301
- * will be removed. Note that user and signing sessions have different access token formats. The calling
2302
- * application should distinguish between the two based on the context of the authenticated session, or by
2303
- * the presence of the `document_id` field, which will only be present for signing sessions.
2304
- */
2305
- var decodeAccessTokenBody = function (token) {
2306
- var decoded;
2307
- try {
2308
- decoded = decodeTokenBody(token);
2309
- if (decoded === null) {
2310
- return null;
2311
- }
2312
- }
2313
- catch (e) {
2314
- return null;
2315
- }
2316
- Object.keys(decoded).forEach(function (key) {
2317
- if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
2318
- decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
2319
- delete decoded[key];
2320
- }
2321
- });
2322
- return decoded;
2323
- };
2324
-
2325
- export { VerdocsEndpoint as V, decodeAccessTokenBody as d, getEndpoint as g, setActiveEndpoint as s };