@verdocs/web-sdk 1.4.7 → 1.5.2

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