@imtbl/sdk 0.4.0-alpha → 0.4.0-alpha.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.
- package/dist/blockchain-data.js +54 -3262
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +2 -16
- package/dist/checkout_sdk.js +26 -67
- package/dist/checkout_widgets.d.ts +2 -3
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.d.ts +2 -2
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +16 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +145 -4134
- package/dist/index.d.ts +45 -126
- package/dist/index.js +135 -4123
- package/dist/orderbook.d.ts +2 -2
- package/dist/orderbook.js +26 -24
- package/dist/passport.d.ts +13 -79
- package/dist/passport.js +15 -5248
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import globalAxios$1 from 'axios';
|
|
2
2
|
import { ImmutableX, Config, generateLegacyStarkPrivateKey, createStarkSigner, TransfersApi, OrdersApi as OrdersApi$1, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi as TokensApi$1 } from '@imtbl/core-sdk';
|
|
3
3
|
export { createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey } from '@imtbl/core-sdk';
|
|
4
4
|
import { UserManager } from 'oidc-client-ts';
|
|
@@ -8,11 +8,8 @@ import { OpenIdExtension } from '@magic-ext/oidc';
|
|
|
8
8
|
import BN$2 from 'bn.js';
|
|
9
9
|
import * as encUtils from 'enc-utils';
|
|
10
10
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
11
|
-
import { EventEmitter } from 'events';
|
|
12
|
-
import { ethers, BigNumber as BigNumber$1, providers, constants, utils as utils$2, Contract as Contract$1, ContractFactory } from 'ethers';
|
|
13
|
-
import { walletContracts } from '@0xsequence/abi';
|
|
14
|
-
import { encodeSignature } from '@0xsequence/config';
|
|
15
11
|
import FormData$2 from 'form-data';
|
|
12
|
+
import { providers, BigNumber as BigNumber$1, constants, utils as utils$1, Contract as Contract$1, ethers, ContractFactory } from 'ethers';
|
|
16
13
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
17
14
|
import { parseUnits } from '@ethersproject/units';
|
|
18
15
|
import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
|
|
@@ -40,3302 +37,6 @@ class ImmutableConfiguration {
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
function bind$1(fn, thisArg) {
|
|
44
|
-
return function wrap() {
|
|
45
|
-
return fn.apply(thisArg, arguments);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// utils is a library of generic helper functions non-specific to axios
|
|
50
|
-
|
|
51
|
-
const {toString: toString$1} = Object.prototype;
|
|
52
|
-
const {getPrototypeOf: getPrototypeOf$1} = Object;
|
|
53
|
-
|
|
54
|
-
const kindOf$1 = (cache => thing => {
|
|
55
|
-
const str = toString$1.call(thing);
|
|
56
|
-
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
57
|
-
})(Object.create(null));
|
|
58
|
-
|
|
59
|
-
const kindOfTest$1 = (type) => {
|
|
60
|
-
type = type.toLowerCase();
|
|
61
|
-
return (thing) => kindOf$1(thing) === type
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const typeOfTest$1 = type => thing => typeof thing === type;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Determine if a value is an Array
|
|
68
|
-
*
|
|
69
|
-
* @param {Object} val The value to test
|
|
70
|
-
*
|
|
71
|
-
* @returns {boolean} True if value is an Array, otherwise false
|
|
72
|
-
*/
|
|
73
|
-
const {isArray: isArray$1} = Array;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Determine if a value is undefined
|
|
77
|
-
*
|
|
78
|
-
* @param {*} val The value to test
|
|
79
|
-
*
|
|
80
|
-
* @returns {boolean} True if the value is undefined, otherwise false
|
|
81
|
-
*/
|
|
82
|
-
const isUndefined$1 = typeOfTest$1('undefined');
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Determine if a value is a Buffer
|
|
86
|
-
*
|
|
87
|
-
* @param {*} val The value to test
|
|
88
|
-
*
|
|
89
|
-
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
90
|
-
*/
|
|
91
|
-
function isBuffer$1(val) {
|
|
92
|
-
return val !== null && !isUndefined$1(val) && val.constructor !== null && !isUndefined$1(val.constructor)
|
|
93
|
-
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Determine if a value is an ArrayBuffer
|
|
98
|
-
*
|
|
99
|
-
* @param {*} val The value to test
|
|
100
|
-
*
|
|
101
|
-
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
102
|
-
*/
|
|
103
|
-
const isArrayBuffer$1 = kindOfTest$1('ArrayBuffer');
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Determine if a value is a view on an ArrayBuffer
|
|
108
|
-
*
|
|
109
|
-
* @param {*} val The value to test
|
|
110
|
-
*
|
|
111
|
-
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
|
112
|
-
*/
|
|
113
|
-
function isArrayBufferView$1(val) {
|
|
114
|
-
let result;
|
|
115
|
-
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
|
116
|
-
result = ArrayBuffer.isView(val);
|
|
117
|
-
} else {
|
|
118
|
-
result = (val) && (val.buffer) && (isArrayBuffer$1(val.buffer));
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Determine if a value is a String
|
|
125
|
-
*
|
|
126
|
-
* @param {*} val The value to test
|
|
127
|
-
*
|
|
128
|
-
* @returns {boolean} True if value is a String, otherwise false
|
|
129
|
-
*/
|
|
130
|
-
const isString$2 = typeOfTest$1('string');
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Determine if a value is a Function
|
|
134
|
-
*
|
|
135
|
-
* @param {*} val The value to test
|
|
136
|
-
* @returns {boolean} True if value is a Function, otherwise false
|
|
137
|
-
*/
|
|
138
|
-
const isFunction$1 = typeOfTest$1('function');
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Determine if a value is a Number
|
|
142
|
-
*
|
|
143
|
-
* @param {*} val The value to test
|
|
144
|
-
*
|
|
145
|
-
* @returns {boolean} True if value is a Number, otherwise false
|
|
146
|
-
*/
|
|
147
|
-
const isNumber$1 = typeOfTest$1('number');
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Determine if a value is an Object
|
|
151
|
-
*
|
|
152
|
-
* @param {*} thing The value to test
|
|
153
|
-
*
|
|
154
|
-
* @returns {boolean} True if value is an Object, otherwise false
|
|
155
|
-
*/
|
|
156
|
-
const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Determine if a value is a Boolean
|
|
160
|
-
*
|
|
161
|
-
* @param {*} thing The value to test
|
|
162
|
-
* @returns {boolean} True if value is a Boolean, otherwise false
|
|
163
|
-
*/
|
|
164
|
-
const isBoolean$1 = thing => thing === true || thing === false;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Determine if a value is a plain Object
|
|
168
|
-
*
|
|
169
|
-
* @param {*} val The value to test
|
|
170
|
-
*
|
|
171
|
-
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
172
|
-
*/
|
|
173
|
-
const isPlainObject$1 = (val) => {
|
|
174
|
-
if (kindOf$1(val) !== 'object') {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const prototype = getPrototypeOf$1(val);
|
|
179
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Determine if a value is a Date
|
|
184
|
-
*
|
|
185
|
-
* @param {*} val The value to test
|
|
186
|
-
*
|
|
187
|
-
* @returns {boolean} True if value is a Date, otherwise false
|
|
188
|
-
*/
|
|
189
|
-
const isDate$1 = kindOfTest$1('Date');
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Determine if a value is a File
|
|
193
|
-
*
|
|
194
|
-
* @param {*} val The value to test
|
|
195
|
-
*
|
|
196
|
-
* @returns {boolean} True if value is a File, otherwise false
|
|
197
|
-
*/
|
|
198
|
-
const isFile$1 = kindOfTest$1('File');
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Determine if a value is a Blob
|
|
202
|
-
*
|
|
203
|
-
* @param {*} val The value to test
|
|
204
|
-
*
|
|
205
|
-
* @returns {boolean} True if value is a Blob, otherwise false
|
|
206
|
-
*/
|
|
207
|
-
const isBlob$2 = kindOfTest$1('Blob');
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Determine if a value is a FileList
|
|
211
|
-
*
|
|
212
|
-
* @param {*} val The value to test
|
|
213
|
-
*
|
|
214
|
-
* @returns {boolean} True if value is a File, otherwise false
|
|
215
|
-
*/
|
|
216
|
-
const isFileList$1 = kindOfTest$1('FileList');
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Determine if a value is a Stream
|
|
220
|
-
*
|
|
221
|
-
* @param {*} val The value to test
|
|
222
|
-
*
|
|
223
|
-
* @returns {boolean} True if value is a Stream, otherwise false
|
|
224
|
-
*/
|
|
225
|
-
const isStream$1 = (val) => isObject$1(val) && isFunction$1(val.pipe);
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Determine if a value is a FormData
|
|
229
|
-
*
|
|
230
|
-
* @param {*} thing The value to test
|
|
231
|
-
*
|
|
232
|
-
* @returns {boolean} True if value is an FormData, otherwise false
|
|
233
|
-
*/
|
|
234
|
-
const isFormData$2 = (thing) => {
|
|
235
|
-
let kind;
|
|
236
|
-
return thing && (
|
|
237
|
-
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
238
|
-
isFunction$1(thing.append) && (
|
|
239
|
-
(kind = kindOf$1(thing)) === 'formdata' ||
|
|
240
|
-
// detect form-data instance
|
|
241
|
-
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
242
|
-
)
|
|
243
|
-
)
|
|
244
|
-
)
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Determine if a value is a URLSearchParams object
|
|
249
|
-
*
|
|
250
|
-
* @param {*} val The value to test
|
|
251
|
-
*
|
|
252
|
-
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
253
|
-
*/
|
|
254
|
-
const isURLSearchParams$1 = kindOfTest$1('URLSearchParams');
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Trim excess whitespace off the beginning and end of a string
|
|
258
|
-
*
|
|
259
|
-
* @param {String} str The String to trim
|
|
260
|
-
*
|
|
261
|
-
* @returns {String} The String freed of excess whitespace
|
|
262
|
-
*/
|
|
263
|
-
const trim$1 = (str) => str.trim ?
|
|
264
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Iterate over an Array or an Object invoking a function for each item.
|
|
268
|
-
*
|
|
269
|
-
* If `obj` is an Array callback will be called passing
|
|
270
|
-
* the value, index, and complete array for each item.
|
|
271
|
-
*
|
|
272
|
-
* If 'obj' is an Object callback will be called passing
|
|
273
|
-
* the value, key, and complete object for each property.
|
|
274
|
-
*
|
|
275
|
-
* @param {Object|Array} obj The object to iterate
|
|
276
|
-
* @param {Function} fn The callback to invoke for each item
|
|
277
|
-
*
|
|
278
|
-
* @param {Boolean} [allOwnKeys = false]
|
|
279
|
-
* @returns {any}
|
|
280
|
-
*/
|
|
281
|
-
function forEach$1(obj, fn, {allOwnKeys = false} = {}) {
|
|
282
|
-
// Don't bother if no value provided
|
|
283
|
-
if (obj === null || typeof obj === 'undefined') {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
let i;
|
|
288
|
-
let l;
|
|
289
|
-
|
|
290
|
-
// Force an array if not already something iterable
|
|
291
|
-
if (typeof obj !== 'object') {
|
|
292
|
-
/*eslint no-param-reassign:0*/
|
|
293
|
-
obj = [obj];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (isArray$1(obj)) {
|
|
297
|
-
// Iterate over array values
|
|
298
|
-
for (i = 0, l = obj.length; i < l; i++) {
|
|
299
|
-
fn.call(null, obj[i], i, obj);
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
// Iterate over object keys
|
|
303
|
-
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
304
|
-
const len = keys.length;
|
|
305
|
-
let key;
|
|
306
|
-
|
|
307
|
-
for (i = 0; i < len; i++) {
|
|
308
|
-
key = keys[i];
|
|
309
|
-
fn.call(null, obj[key], key, obj);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function findKey$1(obj, key) {
|
|
315
|
-
key = key.toLowerCase();
|
|
316
|
-
const keys = Object.keys(obj);
|
|
317
|
-
let i = keys.length;
|
|
318
|
-
let _key;
|
|
319
|
-
while (i-- > 0) {
|
|
320
|
-
_key = keys[i];
|
|
321
|
-
if (key === _key.toLowerCase()) {
|
|
322
|
-
return _key;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const _global$1 = (() => {
|
|
329
|
-
/*eslint no-undef:0*/
|
|
330
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
|
331
|
-
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
|
332
|
-
})();
|
|
333
|
-
|
|
334
|
-
const isContextDefined$1 = (context) => !isUndefined$1(context) && context !== _global$1;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Accepts varargs expecting each argument to be an object, then
|
|
338
|
-
* immutably merges the properties of each object and returns result.
|
|
339
|
-
*
|
|
340
|
-
* When multiple objects contain the same key the later object in
|
|
341
|
-
* the arguments list will take precedence.
|
|
342
|
-
*
|
|
343
|
-
* Example:
|
|
344
|
-
*
|
|
345
|
-
* ```js
|
|
346
|
-
* var result = merge({foo: 123}, {foo: 456});
|
|
347
|
-
* console.log(result.foo); // outputs 456
|
|
348
|
-
* ```
|
|
349
|
-
*
|
|
350
|
-
* @param {Object} obj1 Object to merge
|
|
351
|
-
*
|
|
352
|
-
* @returns {Object} Result of all merge properties
|
|
353
|
-
*/
|
|
354
|
-
function merge$1(/* obj1, obj2, obj3, ... */) {
|
|
355
|
-
const {caseless} = isContextDefined$1(this) && this || {};
|
|
356
|
-
const result = {};
|
|
357
|
-
const assignValue = (val, key) => {
|
|
358
|
-
const targetKey = caseless && findKey$1(result, key) || key;
|
|
359
|
-
if (isPlainObject$1(result[targetKey]) && isPlainObject$1(val)) {
|
|
360
|
-
result[targetKey] = merge$1(result[targetKey], val);
|
|
361
|
-
} else if (isPlainObject$1(val)) {
|
|
362
|
-
result[targetKey] = merge$1({}, val);
|
|
363
|
-
} else if (isArray$1(val)) {
|
|
364
|
-
result[targetKey] = val.slice();
|
|
365
|
-
} else {
|
|
366
|
-
result[targetKey] = val;
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
for (let i = 0, l = arguments.length; i < l; i++) {
|
|
371
|
-
arguments[i] && forEach$1(arguments[i], assignValue);
|
|
372
|
-
}
|
|
373
|
-
return result;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Extends object a by mutably adding to it the properties of object b.
|
|
378
|
-
*
|
|
379
|
-
* @param {Object} a The object to be extended
|
|
380
|
-
* @param {Object} b The object to copy properties from
|
|
381
|
-
* @param {Object} thisArg The object to bind function to
|
|
382
|
-
*
|
|
383
|
-
* @param {Boolean} [allOwnKeys]
|
|
384
|
-
* @returns {Object} The resulting value of object a
|
|
385
|
-
*/
|
|
386
|
-
const extend$1 = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
387
|
-
forEach$1(b, (val, key) => {
|
|
388
|
-
if (thisArg && isFunction$1(val)) {
|
|
389
|
-
a[key] = bind$1(val, thisArg);
|
|
390
|
-
} else {
|
|
391
|
-
a[key] = val;
|
|
392
|
-
}
|
|
393
|
-
}, {allOwnKeys});
|
|
394
|
-
return a;
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
|
399
|
-
*
|
|
400
|
-
* @param {string} content with BOM
|
|
401
|
-
*
|
|
402
|
-
* @returns {string} content value without BOM
|
|
403
|
-
*/
|
|
404
|
-
const stripBOM$1 = (content) => {
|
|
405
|
-
if (content.charCodeAt(0) === 0xFEFF) {
|
|
406
|
-
content = content.slice(1);
|
|
407
|
-
}
|
|
408
|
-
return content;
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Inherit the prototype methods from one constructor into another
|
|
413
|
-
* @param {function} constructor
|
|
414
|
-
* @param {function} superConstructor
|
|
415
|
-
* @param {object} [props]
|
|
416
|
-
* @param {object} [descriptors]
|
|
417
|
-
*
|
|
418
|
-
* @returns {void}
|
|
419
|
-
*/
|
|
420
|
-
const inherits$1 = (constructor, superConstructor, props, descriptors) => {
|
|
421
|
-
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
422
|
-
constructor.prototype.constructor = constructor;
|
|
423
|
-
Object.defineProperty(constructor, 'super', {
|
|
424
|
-
value: superConstructor.prototype
|
|
425
|
-
});
|
|
426
|
-
props && Object.assign(constructor.prototype, props);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Resolve object with deep prototype chain to a flat object
|
|
431
|
-
* @param {Object} sourceObj source object
|
|
432
|
-
* @param {Object} [destObj]
|
|
433
|
-
* @param {Function|Boolean} [filter]
|
|
434
|
-
* @param {Function} [propFilter]
|
|
435
|
-
*
|
|
436
|
-
* @returns {Object}
|
|
437
|
-
*/
|
|
438
|
-
const toFlatObject$1 = (sourceObj, destObj, filter, propFilter) => {
|
|
439
|
-
let props;
|
|
440
|
-
let i;
|
|
441
|
-
let prop;
|
|
442
|
-
const merged = {};
|
|
443
|
-
|
|
444
|
-
destObj = destObj || {};
|
|
445
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
446
|
-
if (sourceObj == null) return destObj;
|
|
447
|
-
|
|
448
|
-
do {
|
|
449
|
-
props = Object.getOwnPropertyNames(sourceObj);
|
|
450
|
-
i = props.length;
|
|
451
|
-
while (i-- > 0) {
|
|
452
|
-
prop = props[i];
|
|
453
|
-
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
454
|
-
destObj[prop] = sourceObj[prop];
|
|
455
|
-
merged[prop] = true;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
sourceObj = filter !== false && getPrototypeOf$1(sourceObj);
|
|
459
|
-
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
460
|
-
|
|
461
|
-
return destObj;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Determines whether a string ends with the characters of a specified string
|
|
466
|
-
*
|
|
467
|
-
* @param {String} str
|
|
468
|
-
* @param {String} searchString
|
|
469
|
-
* @param {Number} [position= 0]
|
|
470
|
-
*
|
|
471
|
-
* @returns {boolean}
|
|
472
|
-
*/
|
|
473
|
-
const endsWith$1 = (str, searchString, position) => {
|
|
474
|
-
str = String(str);
|
|
475
|
-
if (position === undefined || position > str.length) {
|
|
476
|
-
position = str.length;
|
|
477
|
-
}
|
|
478
|
-
position -= searchString.length;
|
|
479
|
-
const lastIndex = str.indexOf(searchString, position);
|
|
480
|
-
return lastIndex !== -1 && lastIndex === position;
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Returns new array from array like object or null if failed
|
|
486
|
-
*
|
|
487
|
-
* @param {*} [thing]
|
|
488
|
-
*
|
|
489
|
-
* @returns {?Array}
|
|
490
|
-
*/
|
|
491
|
-
const toArray$1 = (thing) => {
|
|
492
|
-
if (!thing) return null;
|
|
493
|
-
if (isArray$1(thing)) return thing;
|
|
494
|
-
let i = thing.length;
|
|
495
|
-
if (!isNumber$1(i)) return null;
|
|
496
|
-
const arr = new Array(i);
|
|
497
|
-
while (i-- > 0) {
|
|
498
|
-
arr[i] = thing[i];
|
|
499
|
-
}
|
|
500
|
-
return arr;
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
|
505
|
-
* thing passed in is an instance of Uint8Array
|
|
506
|
-
*
|
|
507
|
-
* @param {TypedArray}
|
|
508
|
-
*
|
|
509
|
-
* @returns {Array}
|
|
510
|
-
*/
|
|
511
|
-
// eslint-disable-next-line func-names
|
|
512
|
-
const isTypedArray$1 = (TypedArray => {
|
|
513
|
-
// eslint-disable-next-line func-names
|
|
514
|
-
return thing => {
|
|
515
|
-
return TypedArray && thing instanceof TypedArray;
|
|
516
|
-
};
|
|
517
|
-
})(typeof Uint8Array !== 'undefined' && getPrototypeOf$1(Uint8Array));
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* For each entry in the object, call the function with the key and value.
|
|
521
|
-
*
|
|
522
|
-
* @param {Object<any, any>} obj - The object to iterate over.
|
|
523
|
-
* @param {Function} fn - The function to call for each entry.
|
|
524
|
-
*
|
|
525
|
-
* @returns {void}
|
|
526
|
-
*/
|
|
527
|
-
const forEachEntry$1 = (obj, fn) => {
|
|
528
|
-
const generator = obj && obj[Symbol.iterator];
|
|
529
|
-
|
|
530
|
-
const iterator = generator.call(obj);
|
|
531
|
-
|
|
532
|
-
let result;
|
|
533
|
-
|
|
534
|
-
while ((result = iterator.next()) && !result.done) {
|
|
535
|
-
const pair = result.value;
|
|
536
|
-
fn.call(obj, pair[0], pair[1]);
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* It takes a regular expression and a string, and returns an array of all the matches
|
|
542
|
-
*
|
|
543
|
-
* @param {string} regExp - The regular expression to match against.
|
|
544
|
-
* @param {string} str - The string to search.
|
|
545
|
-
*
|
|
546
|
-
* @returns {Array<boolean>}
|
|
547
|
-
*/
|
|
548
|
-
const matchAll$1 = (regExp, str) => {
|
|
549
|
-
let matches;
|
|
550
|
-
const arr = [];
|
|
551
|
-
|
|
552
|
-
while ((matches = regExp.exec(str)) !== null) {
|
|
553
|
-
arr.push(matches);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
return arr;
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
560
|
-
const isHTMLForm$1 = kindOfTest$1('HTMLFormElement');
|
|
561
|
-
|
|
562
|
-
const toCamelCase$1 = str => {
|
|
563
|
-
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
|
564
|
-
function replacer(m, p1, p2) {
|
|
565
|
-
return p1.toUpperCase() + p2;
|
|
566
|
-
}
|
|
567
|
-
);
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
/* Creating a function that will check if an object has a property. */
|
|
571
|
-
const hasOwnProperty$1 = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* Determine if a value is a RegExp object
|
|
575
|
-
*
|
|
576
|
-
* @param {*} val The value to test
|
|
577
|
-
*
|
|
578
|
-
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
579
|
-
*/
|
|
580
|
-
const isRegExp$1 = kindOfTest$1('RegExp');
|
|
581
|
-
|
|
582
|
-
const reduceDescriptors$1 = (obj, reducer) => {
|
|
583
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
584
|
-
const reducedDescriptors = {};
|
|
585
|
-
|
|
586
|
-
forEach$1(descriptors, (descriptor, name) => {
|
|
587
|
-
if (reducer(descriptor, name, obj) !== false) {
|
|
588
|
-
reducedDescriptors[name] = descriptor;
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
Object.defineProperties(obj, reducedDescriptors);
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Makes all methods read-only
|
|
597
|
-
* @param {Object} obj
|
|
598
|
-
*/
|
|
599
|
-
|
|
600
|
-
const freezeMethods$1 = (obj) => {
|
|
601
|
-
reduceDescriptors$1(obj, (descriptor, name) => {
|
|
602
|
-
// skip restricted props in strict mode
|
|
603
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const value = obj[name];
|
|
608
|
-
|
|
609
|
-
if (!isFunction$1(value)) return;
|
|
610
|
-
|
|
611
|
-
descriptor.enumerable = false;
|
|
612
|
-
|
|
613
|
-
if ('writable' in descriptor) {
|
|
614
|
-
descriptor.writable = false;
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (!descriptor.set) {
|
|
619
|
-
descriptor.set = () => {
|
|
620
|
-
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
const toObjectSet$1 = (arrayOrString, delimiter) => {
|
|
627
|
-
const obj = {};
|
|
628
|
-
|
|
629
|
-
const define = (arr) => {
|
|
630
|
-
arr.forEach(value => {
|
|
631
|
-
obj[value] = true;
|
|
632
|
-
});
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
isArray$1(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
636
|
-
|
|
637
|
-
return obj;
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
const noop$1 = () => {};
|
|
641
|
-
|
|
642
|
-
const toFiniteNumber$1 = (value, defaultValue) => {
|
|
643
|
-
value = +value;
|
|
644
|
-
return Number.isFinite(value) ? value : defaultValue;
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
const ALPHA$1 = 'abcdefghijklmnopqrstuvwxyz';
|
|
648
|
-
|
|
649
|
-
const DIGIT$1 = '0123456789';
|
|
650
|
-
|
|
651
|
-
const ALPHABET$1 = {
|
|
652
|
-
DIGIT: DIGIT$1,
|
|
653
|
-
ALPHA: ALPHA$1,
|
|
654
|
-
ALPHA_DIGIT: ALPHA$1 + ALPHA$1.toUpperCase() + DIGIT$1
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
const generateString$1 = (size = 16, alphabet = ALPHABET$1.ALPHA_DIGIT) => {
|
|
658
|
-
let str = '';
|
|
659
|
-
const {length} = alphabet;
|
|
660
|
-
while (size--) {
|
|
661
|
-
str += alphabet[Math.random() * length|0];
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return str;
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
|
669
|
-
*
|
|
670
|
-
* @param {unknown} thing - The thing to check.
|
|
671
|
-
*
|
|
672
|
-
* @returns {boolean}
|
|
673
|
-
*/
|
|
674
|
-
function isSpecCompliantForm$1(thing) {
|
|
675
|
-
return !!(thing && isFunction$1(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
const toJSONObject$1 = (obj) => {
|
|
679
|
-
const stack = new Array(10);
|
|
680
|
-
|
|
681
|
-
const visit = (source, i) => {
|
|
682
|
-
|
|
683
|
-
if (isObject$1(source)) {
|
|
684
|
-
if (stack.indexOf(source) >= 0) {
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if(!('toJSON' in source)) {
|
|
689
|
-
stack[i] = source;
|
|
690
|
-
const target = isArray$1(source) ? [] : {};
|
|
691
|
-
|
|
692
|
-
forEach$1(source, (value, key) => {
|
|
693
|
-
const reducedValue = visit(value, i + 1);
|
|
694
|
-
!isUndefined$1(reducedValue) && (target[key] = reducedValue);
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
stack[i] = undefined;
|
|
698
|
-
|
|
699
|
-
return target;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
return source;
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
return visit(obj, 0);
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
const isAsyncFn$1 = kindOfTest$1('AsyncFunction');
|
|
710
|
-
|
|
711
|
-
const isThenable$1 = (thing) =>
|
|
712
|
-
thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
713
|
-
|
|
714
|
-
var utils$1 = {
|
|
715
|
-
isArray: isArray$1,
|
|
716
|
-
isArrayBuffer: isArrayBuffer$1,
|
|
717
|
-
isBuffer: isBuffer$1,
|
|
718
|
-
isFormData: isFormData$2,
|
|
719
|
-
isArrayBufferView: isArrayBufferView$1,
|
|
720
|
-
isString: isString$2,
|
|
721
|
-
isNumber: isNumber$1,
|
|
722
|
-
isBoolean: isBoolean$1,
|
|
723
|
-
isObject: isObject$1,
|
|
724
|
-
isPlainObject: isPlainObject$1,
|
|
725
|
-
isUndefined: isUndefined$1,
|
|
726
|
-
isDate: isDate$1,
|
|
727
|
-
isFile: isFile$1,
|
|
728
|
-
isBlob: isBlob$2,
|
|
729
|
-
isRegExp: isRegExp$1,
|
|
730
|
-
isFunction: isFunction$1,
|
|
731
|
-
isStream: isStream$1,
|
|
732
|
-
isURLSearchParams: isURLSearchParams$1,
|
|
733
|
-
isTypedArray: isTypedArray$1,
|
|
734
|
-
isFileList: isFileList$1,
|
|
735
|
-
forEach: forEach$1,
|
|
736
|
-
merge: merge$1,
|
|
737
|
-
extend: extend$1,
|
|
738
|
-
trim: trim$1,
|
|
739
|
-
stripBOM: stripBOM$1,
|
|
740
|
-
inherits: inherits$1,
|
|
741
|
-
toFlatObject: toFlatObject$1,
|
|
742
|
-
kindOf: kindOf$1,
|
|
743
|
-
kindOfTest: kindOfTest$1,
|
|
744
|
-
endsWith: endsWith$1,
|
|
745
|
-
toArray: toArray$1,
|
|
746
|
-
forEachEntry: forEachEntry$1,
|
|
747
|
-
matchAll: matchAll$1,
|
|
748
|
-
isHTMLForm: isHTMLForm$1,
|
|
749
|
-
hasOwnProperty: hasOwnProperty$1,
|
|
750
|
-
hasOwnProp: hasOwnProperty$1, // an alias to avoid ESLint no-prototype-builtins detection
|
|
751
|
-
reduceDescriptors: reduceDescriptors$1,
|
|
752
|
-
freezeMethods: freezeMethods$1,
|
|
753
|
-
toObjectSet: toObjectSet$1,
|
|
754
|
-
toCamelCase: toCamelCase$1,
|
|
755
|
-
noop: noop$1,
|
|
756
|
-
toFiniteNumber: toFiniteNumber$1,
|
|
757
|
-
findKey: findKey$1,
|
|
758
|
-
global: _global$1,
|
|
759
|
-
isContextDefined: isContextDefined$1,
|
|
760
|
-
ALPHABET: ALPHABET$1,
|
|
761
|
-
generateString: generateString$1,
|
|
762
|
-
isSpecCompliantForm: isSpecCompliantForm$1,
|
|
763
|
-
toJSONObject: toJSONObject$1,
|
|
764
|
-
isAsyncFn: isAsyncFn$1,
|
|
765
|
-
isThenable: isThenable$1
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* Create an Error with the specified message, config, error code, request and response.
|
|
770
|
-
*
|
|
771
|
-
* @param {string} message The error message.
|
|
772
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
773
|
-
* @param {Object} [config] The config.
|
|
774
|
-
* @param {Object} [request] The request.
|
|
775
|
-
* @param {Object} [response] The response.
|
|
776
|
-
*
|
|
777
|
-
* @returns {Error} The created error.
|
|
778
|
-
*/
|
|
779
|
-
function AxiosError$1(message, code, config, request, response) {
|
|
780
|
-
Error.call(this);
|
|
781
|
-
|
|
782
|
-
if (Error.captureStackTrace) {
|
|
783
|
-
Error.captureStackTrace(this, this.constructor);
|
|
784
|
-
} else {
|
|
785
|
-
this.stack = (new Error()).stack;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
this.message = message;
|
|
789
|
-
this.name = 'AxiosError';
|
|
790
|
-
code && (this.code = code);
|
|
791
|
-
config && (this.config = config);
|
|
792
|
-
request && (this.request = request);
|
|
793
|
-
response && (this.response = response);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
utils$1.inherits(AxiosError$1, Error, {
|
|
797
|
-
toJSON: function toJSON() {
|
|
798
|
-
return {
|
|
799
|
-
// Standard
|
|
800
|
-
message: this.message,
|
|
801
|
-
name: this.name,
|
|
802
|
-
// Microsoft
|
|
803
|
-
description: this.description,
|
|
804
|
-
number: this.number,
|
|
805
|
-
// Mozilla
|
|
806
|
-
fileName: this.fileName,
|
|
807
|
-
lineNumber: this.lineNumber,
|
|
808
|
-
columnNumber: this.columnNumber,
|
|
809
|
-
stack: this.stack,
|
|
810
|
-
// Axios
|
|
811
|
-
config: utils$1.toJSONObject(this.config),
|
|
812
|
-
code: this.code,
|
|
813
|
-
status: this.response && this.response.status ? this.response.status : null
|
|
814
|
-
};
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
const prototype$1$1 = AxiosError$1.prototype;
|
|
819
|
-
const descriptors$1 = {};
|
|
820
|
-
|
|
821
|
-
[
|
|
822
|
-
'ERR_BAD_OPTION_VALUE',
|
|
823
|
-
'ERR_BAD_OPTION',
|
|
824
|
-
'ECONNABORTED',
|
|
825
|
-
'ETIMEDOUT',
|
|
826
|
-
'ERR_NETWORK',
|
|
827
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
828
|
-
'ERR_DEPRECATED',
|
|
829
|
-
'ERR_BAD_RESPONSE',
|
|
830
|
-
'ERR_BAD_REQUEST',
|
|
831
|
-
'ERR_CANCELED',
|
|
832
|
-
'ERR_NOT_SUPPORT',
|
|
833
|
-
'ERR_INVALID_URL'
|
|
834
|
-
// eslint-disable-next-line func-names
|
|
835
|
-
].forEach(code => {
|
|
836
|
-
descriptors$1[code] = {value: code};
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
Object.defineProperties(AxiosError$1, descriptors$1);
|
|
840
|
-
Object.defineProperty(prototype$1$1, 'isAxiosError', {value: true});
|
|
841
|
-
|
|
842
|
-
// eslint-disable-next-line func-names
|
|
843
|
-
AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
844
|
-
const axiosError = Object.create(prototype$1$1);
|
|
845
|
-
|
|
846
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
847
|
-
return obj !== Error.prototype;
|
|
848
|
-
}, prop => {
|
|
849
|
-
return prop !== 'isAxiosError';
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
AxiosError$1.call(axiosError, error.message, code, config, request, response);
|
|
853
|
-
|
|
854
|
-
axiosError.cause = error;
|
|
855
|
-
|
|
856
|
-
axiosError.name = error.name;
|
|
857
|
-
|
|
858
|
-
customProps && Object.assign(axiosError, customProps);
|
|
859
|
-
|
|
860
|
-
return axiosError;
|
|
861
|
-
};
|
|
862
|
-
|
|
863
|
-
// eslint-disable-next-line strict
|
|
864
|
-
var httpAdapter$1 = null;
|
|
865
|
-
|
|
866
|
-
/**
|
|
867
|
-
* Determines if the given thing is a array or js object.
|
|
868
|
-
*
|
|
869
|
-
* @param {string} thing - The object or array to be visited.
|
|
870
|
-
*
|
|
871
|
-
* @returns {boolean}
|
|
872
|
-
*/
|
|
873
|
-
function isVisitable$1(thing) {
|
|
874
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* It removes the brackets from the end of a string
|
|
879
|
-
*
|
|
880
|
-
* @param {string} key - The key of the parameter.
|
|
881
|
-
*
|
|
882
|
-
* @returns {string} the key without the brackets.
|
|
883
|
-
*/
|
|
884
|
-
function removeBrackets$1(key) {
|
|
885
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
* It takes a path, a key, and a boolean, and returns a string
|
|
890
|
-
*
|
|
891
|
-
* @param {string} path - The path to the current key.
|
|
892
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
893
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
894
|
-
*
|
|
895
|
-
* @returns {string} The path to the current key.
|
|
896
|
-
*/
|
|
897
|
-
function renderKey$1(path, key, dots) {
|
|
898
|
-
if (!path) return key;
|
|
899
|
-
return path.concat(key).map(function each(token, i) {
|
|
900
|
-
// eslint-disable-next-line no-param-reassign
|
|
901
|
-
token = removeBrackets$1(token);
|
|
902
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
903
|
-
}).join(dots ? '.' : '');
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
908
|
-
*
|
|
909
|
-
* @param {Array<any>} arr - The array to check
|
|
910
|
-
*
|
|
911
|
-
* @returns {boolean}
|
|
912
|
-
*/
|
|
913
|
-
function isFlatArray$1(arr) {
|
|
914
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable$1);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
const predicates$1 = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
918
|
-
return /^is[A-Z]/.test(prop);
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* Convert a data object to FormData
|
|
923
|
-
*
|
|
924
|
-
* @param {Object} obj
|
|
925
|
-
* @param {?Object} [formData]
|
|
926
|
-
* @param {?Object} [options]
|
|
927
|
-
* @param {Function} [options.visitor]
|
|
928
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
929
|
-
* @param {Boolean} [options.dots = false]
|
|
930
|
-
* @param {?Boolean} [options.indexes = false]
|
|
931
|
-
*
|
|
932
|
-
* @returns {Object}
|
|
933
|
-
**/
|
|
934
|
-
|
|
935
|
-
/**
|
|
936
|
-
* It converts an object into a FormData object
|
|
937
|
-
*
|
|
938
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
939
|
-
* @param {string} formData - The FormData object to append to.
|
|
940
|
-
* @param {Object<string, any>} options
|
|
941
|
-
*
|
|
942
|
-
* @returns
|
|
943
|
-
*/
|
|
944
|
-
function toFormData$1(obj, formData, options) {
|
|
945
|
-
if (!utils$1.isObject(obj)) {
|
|
946
|
-
throw new TypeError('target must be an object');
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
// eslint-disable-next-line no-param-reassign
|
|
950
|
-
formData = formData || new (FormData)();
|
|
951
|
-
|
|
952
|
-
// eslint-disable-next-line no-param-reassign
|
|
953
|
-
options = utils$1.toFlatObject(options, {
|
|
954
|
-
metaTokens: true,
|
|
955
|
-
dots: false,
|
|
956
|
-
indexes: false
|
|
957
|
-
}, false, function defined(option, source) {
|
|
958
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
959
|
-
return !utils$1.isUndefined(source[option]);
|
|
960
|
-
});
|
|
961
|
-
|
|
962
|
-
const metaTokens = options.metaTokens;
|
|
963
|
-
// eslint-disable-next-line no-use-before-define
|
|
964
|
-
const visitor = options.visitor || defaultVisitor;
|
|
965
|
-
const dots = options.dots;
|
|
966
|
-
const indexes = options.indexes;
|
|
967
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
968
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
969
|
-
|
|
970
|
-
if (!utils$1.isFunction(visitor)) {
|
|
971
|
-
throw new TypeError('visitor must be a function');
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
function convertValue(value) {
|
|
975
|
-
if (value === null) return '';
|
|
976
|
-
|
|
977
|
-
if (utils$1.isDate(value)) {
|
|
978
|
-
return value.toISOString();
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
if (!useBlob && utils$1.isBlob(value)) {
|
|
982
|
-
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
986
|
-
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
return value;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Default visitor.
|
|
994
|
-
*
|
|
995
|
-
* @param {*} value
|
|
996
|
-
* @param {String|Number} key
|
|
997
|
-
* @param {Array<String|Number>} path
|
|
998
|
-
* @this {FormData}
|
|
999
|
-
*
|
|
1000
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1001
|
-
*/
|
|
1002
|
-
function defaultVisitor(value, key, path) {
|
|
1003
|
-
let arr = value;
|
|
1004
|
-
|
|
1005
|
-
if (value && !path && typeof value === 'object') {
|
|
1006
|
-
if (utils$1.endsWith(key, '{}')) {
|
|
1007
|
-
// eslint-disable-next-line no-param-reassign
|
|
1008
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
1009
|
-
// eslint-disable-next-line no-param-reassign
|
|
1010
|
-
value = JSON.stringify(value);
|
|
1011
|
-
} else if (
|
|
1012
|
-
(utils$1.isArray(value) && isFlatArray$1(value)) ||
|
|
1013
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1014
|
-
)) {
|
|
1015
|
-
// eslint-disable-next-line no-param-reassign
|
|
1016
|
-
key = removeBrackets$1(key);
|
|
1017
|
-
|
|
1018
|
-
arr.forEach(function each(el, index) {
|
|
1019
|
-
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
1020
|
-
// eslint-disable-next-line no-nested-ternary
|
|
1021
|
-
indexes === true ? renderKey$1([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1022
|
-
convertValue(el)
|
|
1023
|
-
);
|
|
1024
|
-
});
|
|
1025
|
-
return false;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
if (isVisitable$1(value)) {
|
|
1030
|
-
return true;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
formData.append(renderKey$1(path, key, dots), convertValue(value));
|
|
1034
|
-
|
|
1035
|
-
return false;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
const stack = [];
|
|
1039
|
-
|
|
1040
|
-
const exposedHelpers = Object.assign(predicates$1, {
|
|
1041
|
-
defaultVisitor,
|
|
1042
|
-
convertValue,
|
|
1043
|
-
isVisitable: isVisitable$1
|
|
1044
|
-
});
|
|
1045
|
-
|
|
1046
|
-
function build(value, path) {
|
|
1047
|
-
if (utils$1.isUndefined(value)) return;
|
|
1048
|
-
|
|
1049
|
-
if (stack.indexOf(value) !== -1) {
|
|
1050
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
stack.push(value);
|
|
1054
|
-
|
|
1055
|
-
utils$1.forEach(value, function each(el, key) {
|
|
1056
|
-
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
1057
|
-
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1058
|
-
);
|
|
1059
|
-
|
|
1060
|
-
if (result === true) {
|
|
1061
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1062
|
-
}
|
|
1063
|
-
});
|
|
1064
|
-
|
|
1065
|
-
stack.pop();
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
if (!utils$1.isObject(obj)) {
|
|
1069
|
-
throw new TypeError('data must be an object');
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
build(obj);
|
|
1073
|
-
|
|
1074
|
-
return formData;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
1079
|
-
* their percent-encoded equivalents
|
|
1080
|
-
*
|
|
1081
|
-
* @param {string} str - The string to encode.
|
|
1082
|
-
*
|
|
1083
|
-
* @returns {string} The encoded string.
|
|
1084
|
-
*/
|
|
1085
|
-
function encode$1$1(str) {
|
|
1086
|
-
const charMap = {
|
|
1087
|
-
'!': '%21',
|
|
1088
|
-
"'": '%27',
|
|
1089
|
-
'(': '%28',
|
|
1090
|
-
')': '%29',
|
|
1091
|
-
'~': '%7E',
|
|
1092
|
-
'%20': '+',
|
|
1093
|
-
'%00': '\x00'
|
|
1094
|
-
};
|
|
1095
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
1096
|
-
return charMap[match];
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
/**
|
|
1101
|
-
* It takes a params object and converts it to a FormData object
|
|
1102
|
-
*
|
|
1103
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1104
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1105
|
-
*
|
|
1106
|
-
* @returns {void}
|
|
1107
|
-
*/
|
|
1108
|
-
function AxiosURLSearchParams$1(params, options) {
|
|
1109
|
-
this._pairs = [];
|
|
1110
|
-
|
|
1111
|
-
params && toFormData$1(params, this, options);
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
const prototype$2 = AxiosURLSearchParams$1.prototype;
|
|
1115
|
-
|
|
1116
|
-
prototype$2.append = function append(name, value) {
|
|
1117
|
-
this._pairs.push([name, value]);
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
|
-
prototype$2.toString = function toString(encoder) {
|
|
1121
|
-
const _encode = encoder ? function(value) {
|
|
1122
|
-
return encoder.call(this, value, encode$1$1);
|
|
1123
|
-
} : encode$1$1;
|
|
1124
|
-
|
|
1125
|
-
return this._pairs.map(function each(pair) {
|
|
1126
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1127
|
-
}, '').join('&');
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
|
1132
|
-
* URI encoded counterparts
|
|
1133
|
-
*
|
|
1134
|
-
* @param {string} val The value to be encoded.
|
|
1135
|
-
*
|
|
1136
|
-
* @returns {string} The encoded value.
|
|
1137
|
-
*/
|
|
1138
|
-
function encode$3(val) {
|
|
1139
|
-
return encodeURIComponent(val).
|
|
1140
|
-
replace(/%3A/gi, ':').
|
|
1141
|
-
replace(/%24/g, '$').
|
|
1142
|
-
replace(/%2C/gi, ',').
|
|
1143
|
-
replace(/%20/g, '+').
|
|
1144
|
-
replace(/%5B/gi, '[').
|
|
1145
|
-
replace(/%5D/gi, ']');
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
/**
|
|
1149
|
-
* Build a URL by appending params to the end
|
|
1150
|
-
*
|
|
1151
|
-
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
1152
|
-
* @param {object} [params] The params to be appended
|
|
1153
|
-
* @param {?object} options
|
|
1154
|
-
*
|
|
1155
|
-
* @returns {string} The formatted url
|
|
1156
|
-
*/
|
|
1157
|
-
function buildURL$1(url, params, options) {
|
|
1158
|
-
/*eslint no-param-reassign:0*/
|
|
1159
|
-
if (!params) {
|
|
1160
|
-
return url;
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
const _encode = options && options.encode || encode$3;
|
|
1164
|
-
|
|
1165
|
-
const serializeFn = options && options.serialize;
|
|
1166
|
-
|
|
1167
|
-
let serializedParams;
|
|
1168
|
-
|
|
1169
|
-
if (serializeFn) {
|
|
1170
|
-
serializedParams = serializeFn(params, options);
|
|
1171
|
-
} else {
|
|
1172
|
-
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1173
|
-
params.toString() :
|
|
1174
|
-
new AxiosURLSearchParams$1(params, options).toString(_encode);
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (serializedParams) {
|
|
1178
|
-
const hashmarkIndex = url.indexOf("#");
|
|
1179
|
-
|
|
1180
|
-
if (hashmarkIndex !== -1) {
|
|
1181
|
-
url = url.slice(0, hashmarkIndex);
|
|
1182
|
-
}
|
|
1183
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
return url;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
let InterceptorManager$2 = class InterceptorManager {
|
|
1190
|
-
constructor() {
|
|
1191
|
-
this.handlers = [];
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Add a new interceptor to the stack
|
|
1196
|
-
*
|
|
1197
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1198
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1199
|
-
*
|
|
1200
|
-
* @return {Number} An ID used to remove interceptor later
|
|
1201
|
-
*/
|
|
1202
|
-
use(fulfilled, rejected, options) {
|
|
1203
|
-
this.handlers.push({
|
|
1204
|
-
fulfilled,
|
|
1205
|
-
rejected,
|
|
1206
|
-
synchronous: options ? options.synchronous : false,
|
|
1207
|
-
runWhen: options ? options.runWhen : null
|
|
1208
|
-
});
|
|
1209
|
-
return this.handlers.length - 1;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Remove an interceptor from the stack
|
|
1214
|
-
*
|
|
1215
|
-
* @param {Number} id The ID that was returned by `use`
|
|
1216
|
-
*
|
|
1217
|
-
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
1218
|
-
*/
|
|
1219
|
-
eject(id) {
|
|
1220
|
-
if (this.handlers[id]) {
|
|
1221
|
-
this.handlers[id] = null;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* Clear all interceptors from the stack
|
|
1227
|
-
*
|
|
1228
|
-
* @returns {void}
|
|
1229
|
-
*/
|
|
1230
|
-
clear() {
|
|
1231
|
-
if (this.handlers) {
|
|
1232
|
-
this.handlers = [];
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
/**
|
|
1237
|
-
* Iterate over all the registered interceptors
|
|
1238
|
-
*
|
|
1239
|
-
* This method is particularly useful for skipping over any
|
|
1240
|
-
* interceptors that may have become `null` calling `eject`.
|
|
1241
|
-
*
|
|
1242
|
-
* @param {Function} fn The function to call for each interceptor
|
|
1243
|
-
*
|
|
1244
|
-
* @returns {void}
|
|
1245
|
-
*/
|
|
1246
|
-
forEach(fn) {
|
|
1247
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1248
|
-
if (h !== null) {
|
|
1249
|
-
fn(h);
|
|
1250
|
-
}
|
|
1251
|
-
});
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
var InterceptorManager$1$1 = InterceptorManager$2;
|
|
1256
|
-
|
|
1257
|
-
var transitionalDefaults$1 = {
|
|
1258
|
-
silentJSONParsing: true,
|
|
1259
|
-
forcedJSONParsing: true,
|
|
1260
|
-
clarifyTimeoutError: false
|
|
1261
|
-
};
|
|
1262
|
-
|
|
1263
|
-
var URLSearchParams$1$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams$1;
|
|
1264
|
-
|
|
1265
|
-
var FormData$1$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
1266
|
-
|
|
1267
|
-
var Blob$1$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
1268
|
-
|
|
1269
|
-
/**
|
|
1270
|
-
* Determine if we're running in a standard browser environment
|
|
1271
|
-
*
|
|
1272
|
-
* This allows axios to run in a web worker, and react-native.
|
|
1273
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1274
|
-
*
|
|
1275
|
-
* web workers:
|
|
1276
|
-
* typeof window -> undefined
|
|
1277
|
-
* typeof document -> undefined
|
|
1278
|
-
*
|
|
1279
|
-
* react-native:
|
|
1280
|
-
* navigator.product -> 'ReactNative'
|
|
1281
|
-
* nativescript
|
|
1282
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1283
|
-
*
|
|
1284
|
-
* @returns {boolean}
|
|
1285
|
-
*/
|
|
1286
|
-
const isStandardBrowserEnv$1 = (() => {
|
|
1287
|
-
let product;
|
|
1288
|
-
if (typeof navigator !== 'undefined' && (
|
|
1289
|
-
(product = navigator.product) === 'ReactNative' ||
|
|
1290
|
-
product === 'NativeScript' ||
|
|
1291
|
-
product === 'NS')
|
|
1292
|
-
) {
|
|
1293
|
-
return false;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1297
|
-
})();
|
|
1298
|
-
|
|
1299
|
-
/**
|
|
1300
|
-
* Determine if we're running in a standard browser webWorker environment
|
|
1301
|
-
*
|
|
1302
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
|
1303
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
1304
|
-
* filtered out due to its judgment standard
|
|
1305
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1306
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1307
|
-
*/
|
|
1308
|
-
const isStandardBrowserWebWorkerEnv$1 = (() => {
|
|
1309
|
-
return (
|
|
1310
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1311
|
-
// eslint-disable-next-line no-undef
|
|
1312
|
-
self instanceof WorkerGlobalScope &&
|
|
1313
|
-
typeof self.importScripts === 'function'
|
|
1314
|
-
);
|
|
1315
|
-
})();
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
var platform$1 = {
|
|
1319
|
-
isBrowser: true,
|
|
1320
|
-
classes: {
|
|
1321
|
-
URLSearchParams: URLSearchParams$1$1,
|
|
1322
|
-
FormData: FormData$1$1,
|
|
1323
|
-
Blob: Blob$1$1
|
|
1324
|
-
},
|
|
1325
|
-
isStandardBrowserEnv: isStandardBrowserEnv$1,
|
|
1326
|
-
isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv$1,
|
|
1327
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
function toURLEncodedForm$1(data, options) {
|
|
1331
|
-
return toFormData$1(data, new platform$1.classes.URLSearchParams(), Object.assign({
|
|
1332
|
-
visitor: function(value, key, path, helpers) {
|
|
1333
|
-
if (platform$1.isNode && utils$1.isBuffer(value)) {
|
|
1334
|
-
this.append(key, value.toString('base64'));
|
|
1335
|
-
return false;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
|
1339
|
-
}
|
|
1340
|
-
}, options));
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
1345
|
-
*
|
|
1346
|
-
* @param {string} name - The name of the property to get.
|
|
1347
|
-
*
|
|
1348
|
-
* @returns An array of strings.
|
|
1349
|
-
*/
|
|
1350
|
-
function parsePropPath$1(name) {
|
|
1351
|
-
// foo[x][y][z]
|
|
1352
|
-
// foo.x.y.z
|
|
1353
|
-
// foo-x-y-z
|
|
1354
|
-
// foo x y z
|
|
1355
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1356
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
/**
|
|
1361
|
-
* Convert an array to an object.
|
|
1362
|
-
*
|
|
1363
|
-
* @param {Array<any>} arr - The array to convert to an object.
|
|
1364
|
-
*
|
|
1365
|
-
* @returns An object with the same keys and values as the array.
|
|
1366
|
-
*/
|
|
1367
|
-
function arrayToObject$1(arr) {
|
|
1368
|
-
const obj = {};
|
|
1369
|
-
const keys = Object.keys(arr);
|
|
1370
|
-
let i;
|
|
1371
|
-
const len = keys.length;
|
|
1372
|
-
let key;
|
|
1373
|
-
for (i = 0; i < len; i++) {
|
|
1374
|
-
key = keys[i];
|
|
1375
|
-
obj[key] = arr[key];
|
|
1376
|
-
}
|
|
1377
|
-
return obj;
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
/**
|
|
1381
|
-
* It takes a FormData object and returns a JavaScript object
|
|
1382
|
-
*
|
|
1383
|
-
* @param {string} formData The FormData object to convert to JSON.
|
|
1384
|
-
*
|
|
1385
|
-
* @returns {Object<string, any> | null} The converted object.
|
|
1386
|
-
*/
|
|
1387
|
-
function formDataToJSON$1(formData) {
|
|
1388
|
-
function buildPath(path, value, target, index) {
|
|
1389
|
-
let name = path[index++];
|
|
1390
|
-
const isNumericKey = Number.isFinite(+name);
|
|
1391
|
-
const isLast = index >= path.length;
|
|
1392
|
-
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
1393
|
-
|
|
1394
|
-
if (isLast) {
|
|
1395
|
-
if (utils$1.hasOwnProp(target, name)) {
|
|
1396
|
-
target[name] = [target[name], value];
|
|
1397
|
-
} else {
|
|
1398
|
-
target[name] = value;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
return !isNumericKey;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
1405
|
-
target[name] = [];
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
const result = buildPath(path, value, target[name], index);
|
|
1409
|
-
|
|
1410
|
-
if (result && utils$1.isArray(target[name])) {
|
|
1411
|
-
target[name] = arrayToObject$1(target[name]);
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
return !isNumericKey;
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
1418
|
-
const obj = {};
|
|
1419
|
-
|
|
1420
|
-
utils$1.forEachEntry(formData, (name, value) => {
|
|
1421
|
-
buildPath(parsePropPath$1(name), value, obj, 0);
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
return obj;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
return null;
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
const DEFAULT_CONTENT_TYPE$1 = {
|
|
1431
|
-
'Content-Type': undefined
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
|
-
/**
|
|
1435
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1436
|
-
* of the input
|
|
1437
|
-
*
|
|
1438
|
-
* @param {any} rawValue - The value to be stringified.
|
|
1439
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1440
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1441
|
-
*
|
|
1442
|
-
* @returns {string} A stringified version of the rawValue.
|
|
1443
|
-
*/
|
|
1444
|
-
function stringifySafely$1(rawValue, parser, encoder) {
|
|
1445
|
-
if (utils$1.isString(rawValue)) {
|
|
1446
|
-
try {
|
|
1447
|
-
(parser || JSON.parse)(rawValue);
|
|
1448
|
-
return utils$1.trim(rawValue);
|
|
1449
|
-
} catch (e) {
|
|
1450
|
-
if (e.name !== 'SyntaxError') {
|
|
1451
|
-
throw e;
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
const defaults$2 = {
|
|
1460
|
-
|
|
1461
|
-
transitional: transitionalDefaults$1,
|
|
1462
|
-
|
|
1463
|
-
adapter: ['xhr', 'http'],
|
|
1464
|
-
|
|
1465
|
-
transformRequest: [function transformRequest(data, headers) {
|
|
1466
|
-
const contentType = headers.getContentType() || '';
|
|
1467
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1468
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
1469
|
-
|
|
1470
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1471
|
-
data = new FormData(data);
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
const isFormData = utils$1.isFormData(data);
|
|
1475
|
-
|
|
1476
|
-
if (isFormData) {
|
|
1477
|
-
if (!hasJSONContentType) {
|
|
1478
|
-
return data;
|
|
1479
|
-
}
|
|
1480
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON$1(data)) : data;
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
if (utils$1.isArrayBuffer(data) ||
|
|
1484
|
-
utils$1.isBuffer(data) ||
|
|
1485
|
-
utils$1.isStream(data) ||
|
|
1486
|
-
utils$1.isFile(data) ||
|
|
1487
|
-
utils$1.isBlob(data)
|
|
1488
|
-
) {
|
|
1489
|
-
return data;
|
|
1490
|
-
}
|
|
1491
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1492
|
-
return data.buffer;
|
|
1493
|
-
}
|
|
1494
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1495
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1496
|
-
return data.toString();
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
let isFileList;
|
|
1500
|
-
|
|
1501
|
-
if (isObjectPayload) {
|
|
1502
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1503
|
-
return toURLEncodedForm$1(data, this.formSerializer).toString();
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1507
|
-
const _FormData = this.env && this.env.FormData;
|
|
1508
|
-
|
|
1509
|
-
return toFormData$1(
|
|
1510
|
-
isFileList ? {'files[]': data} : data,
|
|
1511
|
-
_FormData && new _FormData(),
|
|
1512
|
-
this.formSerializer
|
|
1513
|
-
);
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
if (isObjectPayload || hasJSONContentType ) {
|
|
1518
|
-
headers.setContentType('application/json', false);
|
|
1519
|
-
return stringifySafely$1(data);
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
return data;
|
|
1523
|
-
}],
|
|
1524
|
-
|
|
1525
|
-
transformResponse: [function transformResponse(data) {
|
|
1526
|
-
const transitional = this.transitional || defaults$2.transitional;
|
|
1527
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1528
|
-
const JSONRequested = this.responseType === 'json';
|
|
1529
|
-
|
|
1530
|
-
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1531
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1532
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1533
|
-
|
|
1534
|
-
try {
|
|
1535
|
-
return JSON.parse(data);
|
|
1536
|
-
} catch (e) {
|
|
1537
|
-
if (strictJSONParsing) {
|
|
1538
|
-
if (e.name === 'SyntaxError') {
|
|
1539
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1540
|
-
}
|
|
1541
|
-
throw e;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
return data;
|
|
1547
|
-
}],
|
|
1548
|
-
|
|
1549
|
-
/**
|
|
1550
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
1551
|
-
* timeout is not created.
|
|
1552
|
-
*/
|
|
1553
|
-
timeout: 0,
|
|
1554
|
-
|
|
1555
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
|
1556
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
1557
|
-
|
|
1558
|
-
maxContentLength: -1,
|
|
1559
|
-
maxBodyLength: -1,
|
|
1560
|
-
|
|
1561
|
-
env: {
|
|
1562
|
-
FormData: platform$1.classes.FormData,
|
|
1563
|
-
Blob: platform$1.classes.Blob
|
|
1564
|
-
},
|
|
1565
|
-
|
|
1566
|
-
validateStatus: function validateStatus(status) {
|
|
1567
|
-
return status >= 200 && status < 300;
|
|
1568
|
-
},
|
|
1569
|
-
|
|
1570
|
-
headers: {
|
|
1571
|
-
common: {
|
|
1572
|
-
'Accept': 'application/json, text/plain, */*'
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
|
|
1577
|
-
utils$1.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
1578
|
-
defaults$2.headers[method] = {};
|
|
1579
|
-
});
|
|
1580
|
-
|
|
1581
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
1582
|
-
defaults$2.headers[method] = utils$1.merge(DEFAULT_CONTENT_TYPE$1);
|
|
1583
|
-
});
|
|
1584
|
-
|
|
1585
|
-
var defaults$1$1 = defaults$2;
|
|
1586
|
-
|
|
1587
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1588
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1589
|
-
const ignoreDuplicateOf$1 = utils$1.toObjectSet([
|
|
1590
|
-
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1591
|
-
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1592
|
-
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
1593
|
-
'referer', 'retry-after', 'user-agent'
|
|
1594
|
-
]);
|
|
1595
|
-
|
|
1596
|
-
/**
|
|
1597
|
-
* Parse headers into an object
|
|
1598
|
-
*
|
|
1599
|
-
* ```
|
|
1600
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1601
|
-
* Content-Type: application/json
|
|
1602
|
-
* Connection: keep-alive
|
|
1603
|
-
* Transfer-Encoding: chunked
|
|
1604
|
-
* ```
|
|
1605
|
-
*
|
|
1606
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
1607
|
-
*
|
|
1608
|
-
* @returns {Object} Headers parsed into an object
|
|
1609
|
-
*/
|
|
1610
|
-
var parseHeaders$1 = rawHeaders => {
|
|
1611
|
-
const parsed = {};
|
|
1612
|
-
let key;
|
|
1613
|
-
let val;
|
|
1614
|
-
let i;
|
|
1615
|
-
|
|
1616
|
-
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|
1617
|
-
i = line.indexOf(':');
|
|
1618
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
1619
|
-
val = line.substring(i + 1).trim();
|
|
1620
|
-
|
|
1621
|
-
if (!key || (parsed[key] && ignoreDuplicateOf$1[key])) {
|
|
1622
|
-
return;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
if (key === 'set-cookie') {
|
|
1626
|
-
if (parsed[key]) {
|
|
1627
|
-
parsed[key].push(val);
|
|
1628
|
-
} else {
|
|
1629
|
-
parsed[key] = [val];
|
|
1630
|
-
}
|
|
1631
|
-
} else {
|
|
1632
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1633
|
-
}
|
|
1634
|
-
});
|
|
1635
|
-
|
|
1636
|
-
return parsed;
|
|
1637
|
-
};
|
|
1638
|
-
|
|
1639
|
-
const $internals$1 = Symbol('internals');
|
|
1640
|
-
|
|
1641
|
-
function normalizeHeader$1(header) {
|
|
1642
|
-
return header && String(header).trim().toLowerCase();
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
function normalizeValue$1(value) {
|
|
1646
|
-
if (value === false || value == null) {
|
|
1647
|
-
return value;
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
return utils$1.isArray(value) ? value.map(normalizeValue$1) : String(value);
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
function parseTokens$1(str) {
|
|
1654
|
-
const tokens = Object.create(null);
|
|
1655
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1656
|
-
let match;
|
|
1657
|
-
|
|
1658
|
-
while ((match = tokensRE.exec(str))) {
|
|
1659
|
-
tokens[match[1]] = match[2];
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
return tokens;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
const isValidHeaderName$1 = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1666
|
-
|
|
1667
|
-
function matchHeaderValue$1(context, value, header, filter, isHeaderNameFilter) {
|
|
1668
|
-
if (utils$1.isFunction(filter)) {
|
|
1669
|
-
return filter.call(this, value, header);
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
if (isHeaderNameFilter) {
|
|
1673
|
-
value = header;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
if (!utils$1.isString(value)) return;
|
|
1677
|
-
|
|
1678
|
-
if (utils$1.isString(filter)) {
|
|
1679
|
-
return value.indexOf(filter) !== -1;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
if (utils$1.isRegExp(filter)) {
|
|
1683
|
-
return filter.test(value);
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
function formatHeader$1(header) {
|
|
1688
|
-
return header.trim()
|
|
1689
|
-
.toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1690
|
-
return char.toUpperCase() + str;
|
|
1691
|
-
});
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
function buildAccessors$1(obj, header) {
|
|
1695
|
-
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1696
|
-
|
|
1697
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
1698
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
|
1699
|
-
value: function(arg1, arg2, arg3) {
|
|
1700
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1701
|
-
},
|
|
1702
|
-
configurable: true
|
|
1703
|
-
});
|
|
1704
|
-
});
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
|
-
let AxiosHeaders$2 = class AxiosHeaders {
|
|
1708
|
-
constructor(headers) {
|
|
1709
|
-
headers && this.set(headers);
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
set(header, valueOrRewrite, rewrite) {
|
|
1713
|
-
const self = this;
|
|
1714
|
-
|
|
1715
|
-
function setHeader(_value, _header, _rewrite) {
|
|
1716
|
-
const lHeader = normalizeHeader$1(_header);
|
|
1717
|
-
|
|
1718
|
-
if (!lHeader) {
|
|
1719
|
-
throw new Error('header name must be a non-empty string');
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
const key = utils$1.findKey(self, lHeader);
|
|
1723
|
-
|
|
1724
|
-
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1725
|
-
self[key || _header] = normalizeValue$1(_value);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
const setHeaders = (headers, _rewrite) =>
|
|
1730
|
-
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1731
|
-
|
|
1732
|
-
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1733
|
-
setHeaders(header, valueOrRewrite);
|
|
1734
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName$1(header)) {
|
|
1735
|
-
setHeaders(parseHeaders$1(header), valueOrRewrite);
|
|
1736
|
-
} else {
|
|
1737
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
return this;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
get(header, parser) {
|
|
1744
|
-
header = normalizeHeader$1(header);
|
|
1745
|
-
|
|
1746
|
-
if (header) {
|
|
1747
|
-
const key = utils$1.findKey(this, header);
|
|
1748
|
-
|
|
1749
|
-
if (key) {
|
|
1750
|
-
const value = this[key];
|
|
1751
|
-
|
|
1752
|
-
if (!parser) {
|
|
1753
|
-
return value;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
if (parser === true) {
|
|
1757
|
-
return parseTokens$1(value);
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
if (utils$1.isFunction(parser)) {
|
|
1761
|
-
return parser.call(this, value, key);
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
if (utils$1.isRegExp(parser)) {
|
|
1765
|
-
return parser.exec(value);
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
throw new TypeError('parser must be boolean|regexp|function');
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
has(header, matcher) {
|
|
1774
|
-
header = normalizeHeader$1(header);
|
|
1775
|
-
|
|
1776
|
-
if (header) {
|
|
1777
|
-
const key = utils$1.findKey(this, header);
|
|
1778
|
-
|
|
1779
|
-
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue$1(this, this[key], key, matcher)));
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
return false;
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
delete(header, matcher) {
|
|
1786
|
-
const self = this;
|
|
1787
|
-
let deleted = false;
|
|
1788
|
-
|
|
1789
|
-
function deleteHeader(_header) {
|
|
1790
|
-
_header = normalizeHeader$1(_header);
|
|
1791
|
-
|
|
1792
|
-
if (_header) {
|
|
1793
|
-
const key = utils$1.findKey(self, _header);
|
|
1794
|
-
|
|
1795
|
-
if (key && (!matcher || matchHeaderValue$1(self, self[key], key, matcher))) {
|
|
1796
|
-
delete self[key];
|
|
1797
|
-
|
|
1798
|
-
deleted = true;
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
if (utils$1.isArray(header)) {
|
|
1804
|
-
header.forEach(deleteHeader);
|
|
1805
|
-
} else {
|
|
1806
|
-
deleteHeader(header);
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
return deleted;
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
clear(matcher) {
|
|
1813
|
-
const keys = Object.keys(this);
|
|
1814
|
-
let i = keys.length;
|
|
1815
|
-
let deleted = false;
|
|
1816
|
-
|
|
1817
|
-
while (i--) {
|
|
1818
|
-
const key = keys[i];
|
|
1819
|
-
if(!matcher || matchHeaderValue$1(this, this[key], key, matcher, true)) {
|
|
1820
|
-
delete this[key];
|
|
1821
|
-
deleted = true;
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
return deleted;
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
normalize(format) {
|
|
1829
|
-
const self = this;
|
|
1830
|
-
const headers = {};
|
|
1831
|
-
|
|
1832
|
-
utils$1.forEach(this, (value, header) => {
|
|
1833
|
-
const key = utils$1.findKey(headers, header);
|
|
1834
|
-
|
|
1835
|
-
if (key) {
|
|
1836
|
-
self[key] = normalizeValue$1(value);
|
|
1837
|
-
delete self[header];
|
|
1838
|
-
return;
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1841
|
-
const normalized = format ? formatHeader$1(header) : String(header).trim();
|
|
1842
|
-
|
|
1843
|
-
if (normalized !== header) {
|
|
1844
|
-
delete self[header];
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
self[normalized] = normalizeValue$1(value);
|
|
1848
|
-
|
|
1849
|
-
headers[normalized] = true;
|
|
1850
|
-
});
|
|
1851
|
-
|
|
1852
|
-
return this;
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
concat(...targets) {
|
|
1856
|
-
return this.constructor.concat(this, ...targets);
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
toJSON(asStrings) {
|
|
1860
|
-
const obj = Object.create(null);
|
|
1861
|
-
|
|
1862
|
-
utils$1.forEach(this, (value, header) => {
|
|
1863
|
-
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1864
|
-
});
|
|
1865
|
-
|
|
1866
|
-
return obj;
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
[Symbol.iterator]() {
|
|
1870
|
-
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
toString() {
|
|
1874
|
-
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
get [Symbol.toStringTag]() {
|
|
1878
|
-
return 'AxiosHeaders';
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
static from(thing) {
|
|
1882
|
-
return thing instanceof this ? thing : new this(thing);
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
static concat(first, ...targets) {
|
|
1886
|
-
const computed = new this(first);
|
|
1887
|
-
|
|
1888
|
-
targets.forEach((target) => computed.set(target));
|
|
1889
|
-
|
|
1890
|
-
return computed;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
static accessor(header) {
|
|
1894
|
-
const internals = this[$internals$1] = (this[$internals$1] = {
|
|
1895
|
-
accessors: {}
|
|
1896
|
-
});
|
|
1897
|
-
|
|
1898
|
-
const accessors = internals.accessors;
|
|
1899
|
-
const prototype = this.prototype;
|
|
1900
|
-
|
|
1901
|
-
function defineAccessor(_header) {
|
|
1902
|
-
const lHeader = normalizeHeader$1(_header);
|
|
1903
|
-
|
|
1904
|
-
if (!accessors[lHeader]) {
|
|
1905
|
-
buildAccessors$1(prototype, _header);
|
|
1906
|
-
accessors[lHeader] = true;
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1911
|
-
|
|
1912
|
-
return this;
|
|
1913
|
-
}
|
|
1914
|
-
};
|
|
1915
|
-
|
|
1916
|
-
AxiosHeaders$2.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
1917
|
-
|
|
1918
|
-
utils$1.freezeMethods(AxiosHeaders$2.prototype);
|
|
1919
|
-
utils$1.freezeMethods(AxiosHeaders$2);
|
|
1920
|
-
|
|
1921
|
-
var AxiosHeaders$1$1 = AxiosHeaders$2;
|
|
1922
|
-
|
|
1923
|
-
/**
|
|
1924
|
-
* Transform the data for a request or a response
|
|
1925
|
-
*
|
|
1926
|
-
* @param {Array|Function} fns A single function or Array of functions
|
|
1927
|
-
* @param {?Object} response The response object
|
|
1928
|
-
*
|
|
1929
|
-
* @returns {*} The resulting transformed data
|
|
1930
|
-
*/
|
|
1931
|
-
function transformData$1(fns, response) {
|
|
1932
|
-
const config = this || defaults$1$1;
|
|
1933
|
-
const context = response || config;
|
|
1934
|
-
const headers = AxiosHeaders$1$1.from(context.headers);
|
|
1935
|
-
let data = context.data;
|
|
1936
|
-
|
|
1937
|
-
utils$1.forEach(fns, function transform(fn) {
|
|
1938
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
1939
|
-
});
|
|
1940
|
-
|
|
1941
|
-
headers.normalize();
|
|
1942
|
-
|
|
1943
|
-
return data;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
function isCancel$1(value) {
|
|
1947
|
-
return !!(value && value.__CANCEL__);
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
/**
|
|
1951
|
-
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
1952
|
-
*
|
|
1953
|
-
* @param {string=} message The message.
|
|
1954
|
-
* @param {Object=} config The config.
|
|
1955
|
-
* @param {Object=} request The request.
|
|
1956
|
-
*
|
|
1957
|
-
* @returns {CanceledError} The created error.
|
|
1958
|
-
*/
|
|
1959
|
-
function CanceledError$1(message, config, request) {
|
|
1960
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1961
|
-
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
1962
|
-
this.name = 'CanceledError';
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
|
1966
|
-
__CANCEL__: true
|
|
1967
|
-
});
|
|
1968
|
-
|
|
1969
|
-
/**
|
|
1970
|
-
* Resolve or reject a Promise based on response status.
|
|
1971
|
-
*
|
|
1972
|
-
* @param {Function} resolve A function that resolves the promise.
|
|
1973
|
-
* @param {Function} reject A function that rejects the promise.
|
|
1974
|
-
* @param {object} response The response.
|
|
1975
|
-
*
|
|
1976
|
-
* @returns {object} The response.
|
|
1977
|
-
*/
|
|
1978
|
-
function settle$1(resolve, reject, response) {
|
|
1979
|
-
const validateStatus = response.config.validateStatus;
|
|
1980
|
-
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
1981
|
-
resolve(response);
|
|
1982
|
-
} else {
|
|
1983
|
-
reject(new AxiosError$1(
|
|
1984
|
-
'Request failed with status code ' + response.status,
|
|
1985
|
-
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
1986
|
-
response.config,
|
|
1987
|
-
response.request,
|
|
1988
|
-
response
|
|
1989
|
-
));
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
var cookies$1 = platform$1.isStandardBrowserEnv ?
|
|
1994
|
-
|
|
1995
|
-
// Standard browser envs support document.cookie
|
|
1996
|
-
(function standardBrowserEnv() {
|
|
1997
|
-
return {
|
|
1998
|
-
write: function write(name, value, expires, path, domain, secure) {
|
|
1999
|
-
const cookie = [];
|
|
2000
|
-
cookie.push(name + '=' + encodeURIComponent(value));
|
|
2001
|
-
|
|
2002
|
-
if (utils$1.isNumber(expires)) {
|
|
2003
|
-
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
if (utils$1.isString(path)) {
|
|
2007
|
-
cookie.push('path=' + path);
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
if (utils$1.isString(domain)) {
|
|
2011
|
-
cookie.push('domain=' + domain);
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
if (secure === true) {
|
|
2015
|
-
cookie.push('secure');
|
|
2016
|
-
}
|
|
2017
|
-
|
|
2018
|
-
document.cookie = cookie.join('; ');
|
|
2019
|
-
},
|
|
2020
|
-
|
|
2021
|
-
read: function read(name) {
|
|
2022
|
-
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
2023
|
-
return (match ? decodeURIComponent(match[3]) : null);
|
|
2024
|
-
},
|
|
2025
|
-
|
|
2026
|
-
remove: function remove(name) {
|
|
2027
|
-
this.write(name, '', Date.now() - 86400000);
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
|
-
})() :
|
|
2031
|
-
|
|
2032
|
-
// Non standard browser env (web workers, react-native) lack needed support.
|
|
2033
|
-
(function nonStandardBrowserEnv() {
|
|
2034
|
-
return {
|
|
2035
|
-
write: function write() {},
|
|
2036
|
-
read: function read() { return null; },
|
|
2037
|
-
remove: function remove() {}
|
|
2038
|
-
};
|
|
2039
|
-
})();
|
|
2040
|
-
|
|
2041
|
-
/**
|
|
2042
|
-
* Determines whether the specified URL is absolute
|
|
2043
|
-
*
|
|
2044
|
-
* @param {string} url The URL to test
|
|
2045
|
-
*
|
|
2046
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
2047
|
-
*/
|
|
2048
|
-
function isAbsoluteURL$1(url) {
|
|
2049
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2050
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2051
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2052
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
/**
|
|
2056
|
-
* Creates a new URL by combining the specified URLs
|
|
2057
|
-
*
|
|
2058
|
-
* @param {string} baseURL The base URL
|
|
2059
|
-
* @param {string} relativeURL The relative URL
|
|
2060
|
-
*
|
|
2061
|
-
* @returns {string} The combined URL
|
|
2062
|
-
*/
|
|
2063
|
-
function combineURLs$1(baseURL, relativeURL) {
|
|
2064
|
-
return relativeURL
|
|
2065
|
-
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
2066
|
-
: baseURL;
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
/**
|
|
2070
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
2071
|
-
* only when the requestedURL is not already an absolute URL.
|
|
2072
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
2073
|
-
*
|
|
2074
|
-
* @param {string} baseURL The base URL
|
|
2075
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
2076
|
-
*
|
|
2077
|
-
* @returns {string} The combined full path
|
|
2078
|
-
*/
|
|
2079
|
-
function buildFullPath$1(baseURL, requestedURL) {
|
|
2080
|
-
if (baseURL && !isAbsoluteURL$1(requestedURL)) {
|
|
2081
|
-
return combineURLs$1(baseURL, requestedURL);
|
|
2082
|
-
}
|
|
2083
|
-
return requestedURL;
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
var isURLSameOrigin$1 = platform$1.isStandardBrowserEnv ?
|
|
2087
|
-
|
|
2088
|
-
// Standard browser envs have full support of the APIs needed to test
|
|
2089
|
-
// whether the request URL is of the same origin as current location.
|
|
2090
|
-
(function standardBrowserEnv() {
|
|
2091
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
2092
|
-
const urlParsingNode = document.createElement('a');
|
|
2093
|
-
let originURL;
|
|
2094
|
-
|
|
2095
|
-
/**
|
|
2096
|
-
* Parse a URL to discover it's components
|
|
2097
|
-
*
|
|
2098
|
-
* @param {String} url The URL to be parsed
|
|
2099
|
-
* @returns {Object}
|
|
2100
|
-
*/
|
|
2101
|
-
function resolveURL(url) {
|
|
2102
|
-
let href = url;
|
|
2103
|
-
|
|
2104
|
-
if (msie) {
|
|
2105
|
-
// IE needs attribute set twice to normalize properties
|
|
2106
|
-
urlParsingNode.setAttribute('href', href);
|
|
2107
|
-
href = urlParsingNode.href;
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
urlParsingNode.setAttribute('href', href);
|
|
2111
|
-
|
|
2112
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
2113
|
-
return {
|
|
2114
|
-
href: urlParsingNode.href,
|
|
2115
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
2116
|
-
host: urlParsingNode.host,
|
|
2117
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
2118
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
2119
|
-
hostname: urlParsingNode.hostname,
|
|
2120
|
-
port: urlParsingNode.port,
|
|
2121
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
2122
|
-
urlParsingNode.pathname :
|
|
2123
|
-
'/' + urlParsingNode.pathname
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
originURL = resolveURL(window.location.href);
|
|
2128
|
-
|
|
2129
|
-
/**
|
|
2130
|
-
* Determine if a URL shares the same origin as the current location
|
|
2131
|
-
*
|
|
2132
|
-
* @param {String} requestURL The URL to test
|
|
2133
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2134
|
-
*/
|
|
2135
|
-
return function isURLSameOrigin(requestURL) {
|
|
2136
|
-
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2137
|
-
return (parsed.protocol === originURL.protocol &&
|
|
2138
|
-
parsed.host === originURL.host);
|
|
2139
|
-
};
|
|
2140
|
-
})() :
|
|
2141
|
-
|
|
2142
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
2143
|
-
(function nonStandardBrowserEnv() {
|
|
2144
|
-
return function isURLSameOrigin() {
|
|
2145
|
-
return true;
|
|
2146
|
-
};
|
|
2147
|
-
})();
|
|
2148
|
-
|
|
2149
|
-
function parseProtocol$1(url) {
|
|
2150
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2151
|
-
return match && match[1] || '';
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
/**
|
|
2155
|
-
* Calculate data maxRate
|
|
2156
|
-
* @param {Number} [samplesCount= 10]
|
|
2157
|
-
* @param {Number} [min= 1000]
|
|
2158
|
-
* @returns {Function}
|
|
2159
|
-
*/
|
|
2160
|
-
function speedometer$1(samplesCount, min) {
|
|
2161
|
-
samplesCount = samplesCount || 10;
|
|
2162
|
-
const bytes = new Array(samplesCount);
|
|
2163
|
-
const timestamps = new Array(samplesCount);
|
|
2164
|
-
let head = 0;
|
|
2165
|
-
let tail = 0;
|
|
2166
|
-
let firstSampleTS;
|
|
2167
|
-
|
|
2168
|
-
min = min !== undefined ? min : 1000;
|
|
2169
|
-
|
|
2170
|
-
return function push(chunkLength) {
|
|
2171
|
-
const now = Date.now();
|
|
2172
|
-
|
|
2173
|
-
const startedAt = timestamps[tail];
|
|
2174
|
-
|
|
2175
|
-
if (!firstSampleTS) {
|
|
2176
|
-
firstSampleTS = now;
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
|
-
bytes[head] = chunkLength;
|
|
2180
|
-
timestamps[head] = now;
|
|
2181
|
-
|
|
2182
|
-
let i = tail;
|
|
2183
|
-
let bytesCount = 0;
|
|
2184
|
-
|
|
2185
|
-
while (i !== head) {
|
|
2186
|
-
bytesCount += bytes[i++];
|
|
2187
|
-
i = i % samplesCount;
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
head = (head + 1) % samplesCount;
|
|
2191
|
-
|
|
2192
|
-
if (head === tail) {
|
|
2193
|
-
tail = (tail + 1) % samplesCount;
|
|
2194
|
-
}
|
|
2195
|
-
|
|
2196
|
-
if (now - firstSampleTS < min) {
|
|
2197
|
-
return;
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
const passed = startedAt && now - startedAt;
|
|
2201
|
-
|
|
2202
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2203
|
-
};
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
function progressEventReducer$1(listener, isDownloadStream) {
|
|
2207
|
-
let bytesNotified = 0;
|
|
2208
|
-
const _speedometer = speedometer$1(50, 250);
|
|
2209
|
-
|
|
2210
|
-
return e => {
|
|
2211
|
-
const loaded = e.loaded;
|
|
2212
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
2213
|
-
const progressBytes = loaded - bytesNotified;
|
|
2214
|
-
const rate = _speedometer(progressBytes);
|
|
2215
|
-
const inRange = loaded <= total;
|
|
2216
|
-
|
|
2217
|
-
bytesNotified = loaded;
|
|
2218
|
-
|
|
2219
|
-
const data = {
|
|
2220
|
-
loaded,
|
|
2221
|
-
total,
|
|
2222
|
-
progress: total ? (loaded / total) : undefined,
|
|
2223
|
-
bytes: progressBytes,
|
|
2224
|
-
rate: rate ? rate : undefined,
|
|
2225
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
2226
|
-
event: e
|
|
2227
|
-
};
|
|
2228
|
-
|
|
2229
|
-
data[isDownloadStream ? 'download' : 'upload'] = true;
|
|
2230
|
-
|
|
2231
|
-
listener(data);
|
|
2232
|
-
};
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
const isXHRAdapterSupported$1 = typeof XMLHttpRequest !== 'undefined';
|
|
2236
|
-
|
|
2237
|
-
var xhrAdapter$1 = isXHRAdapterSupported$1 && function (config) {
|
|
2238
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2239
|
-
let requestData = config.data;
|
|
2240
|
-
const requestHeaders = AxiosHeaders$1$1.from(config.headers).normalize();
|
|
2241
|
-
const responseType = config.responseType;
|
|
2242
|
-
let onCanceled;
|
|
2243
|
-
function done() {
|
|
2244
|
-
if (config.cancelToken) {
|
|
2245
|
-
config.cancelToken.unsubscribe(onCanceled);
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
|
-
if (config.signal) {
|
|
2249
|
-
config.signal.removeEventListener('abort', onCanceled);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
if (utils$1.isFormData(requestData)) {
|
|
2254
|
-
if (platform$1.isStandardBrowserEnv || platform$1.isStandardBrowserWebWorkerEnv) {
|
|
2255
|
-
requestHeaders.setContentType(false); // Let the browser set it
|
|
2256
|
-
} else {
|
|
2257
|
-
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
let request = new XMLHttpRequest();
|
|
2262
|
-
|
|
2263
|
-
// HTTP basic authentication
|
|
2264
|
-
if (config.auth) {
|
|
2265
|
-
const username = config.auth.username || '';
|
|
2266
|
-
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
|
2267
|
-
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
const fullPath = buildFullPath$1(config.baseURL, config.url);
|
|
2271
|
-
|
|
2272
|
-
request.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
|
|
2273
|
-
|
|
2274
|
-
// Set the request timeout in MS
|
|
2275
|
-
request.timeout = config.timeout;
|
|
2276
|
-
|
|
2277
|
-
function onloadend() {
|
|
2278
|
-
if (!request) {
|
|
2279
|
-
return;
|
|
2280
|
-
}
|
|
2281
|
-
// Prepare the response
|
|
2282
|
-
const responseHeaders = AxiosHeaders$1$1.from(
|
|
2283
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2284
|
-
);
|
|
2285
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2286
|
-
request.responseText : request.response;
|
|
2287
|
-
const response = {
|
|
2288
|
-
data: responseData,
|
|
2289
|
-
status: request.status,
|
|
2290
|
-
statusText: request.statusText,
|
|
2291
|
-
headers: responseHeaders,
|
|
2292
|
-
config,
|
|
2293
|
-
request
|
|
2294
|
-
};
|
|
2295
|
-
|
|
2296
|
-
settle$1(function _resolve(value) {
|
|
2297
|
-
resolve(value);
|
|
2298
|
-
done();
|
|
2299
|
-
}, function _reject(err) {
|
|
2300
|
-
reject(err);
|
|
2301
|
-
done();
|
|
2302
|
-
}, response);
|
|
2303
|
-
|
|
2304
|
-
// Clean up request
|
|
2305
|
-
request = null;
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
|
-
if ('onloadend' in request) {
|
|
2309
|
-
// Use onloadend if available
|
|
2310
|
-
request.onloadend = onloadend;
|
|
2311
|
-
} else {
|
|
2312
|
-
// Listen for ready state to emulate onloadend
|
|
2313
|
-
request.onreadystatechange = function handleLoad() {
|
|
2314
|
-
if (!request || request.readyState !== 4) {
|
|
2315
|
-
return;
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
// The request errored out and we didn't get a response, this will be
|
|
2319
|
-
// handled by onerror instead
|
|
2320
|
-
// With one exception: request that using file: protocol, most browsers
|
|
2321
|
-
// will return status as 0 even though it's a successful request
|
|
2322
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2323
|
-
return;
|
|
2324
|
-
}
|
|
2325
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2326
|
-
// so we should call onloadend on the next 'tick'
|
|
2327
|
-
setTimeout(onloadend);
|
|
2328
|
-
};
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2332
|
-
request.onabort = function handleAbort() {
|
|
2333
|
-
if (!request) {
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
2338
|
-
|
|
2339
|
-
// Clean up request
|
|
2340
|
-
request = null;
|
|
2341
|
-
};
|
|
2342
|
-
|
|
2343
|
-
// Handle low level network errors
|
|
2344
|
-
request.onerror = function handleError() {
|
|
2345
|
-
// Real errors are hidden from us by the browser
|
|
2346
|
-
// onerror should only fire if it's a network error
|
|
2347
|
-
reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
|
|
2348
|
-
|
|
2349
|
-
// Clean up request
|
|
2350
|
-
request = null;
|
|
2351
|
-
};
|
|
2352
|
-
|
|
2353
|
-
// Handle timeout
|
|
2354
|
-
request.ontimeout = function handleTimeout() {
|
|
2355
|
-
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2356
|
-
const transitional = config.transitional || transitionalDefaults$1;
|
|
2357
|
-
if (config.timeoutErrorMessage) {
|
|
2358
|
-
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
2359
|
-
}
|
|
2360
|
-
reject(new AxiosError$1(
|
|
2361
|
-
timeoutErrorMessage,
|
|
2362
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2363
|
-
config,
|
|
2364
|
-
request));
|
|
2365
|
-
|
|
2366
|
-
// Clean up request
|
|
2367
|
-
request = null;
|
|
2368
|
-
};
|
|
2369
|
-
|
|
2370
|
-
// Add xsrf header
|
|
2371
|
-
// This is only done if running in a standard browser environment.
|
|
2372
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
2373
|
-
if (platform$1.isStandardBrowserEnv) {
|
|
2374
|
-
// Add xsrf header
|
|
2375
|
-
const xsrfValue = (config.withCredentials || isURLSameOrigin$1(fullPath))
|
|
2376
|
-
&& config.xsrfCookieName && cookies$1.read(config.xsrfCookieName);
|
|
2377
|
-
|
|
2378
|
-
if (xsrfValue) {
|
|
2379
|
-
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
|
-
// Remove Content-Type if data is undefined
|
|
2384
|
-
requestData === undefined && requestHeaders.setContentType(null);
|
|
2385
|
-
|
|
2386
|
-
// Add headers to the request
|
|
2387
|
-
if ('setRequestHeader' in request) {
|
|
2388
|
-
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2389
|
-
request.setRequestHeader(key, val);
|
|
2390
|
-
});
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
// Add withCredentials to request if needed
|
|
2394
|
-
if (!utils$1.isUndefined(config.withCredentials)) {
|
|
2395
|
-
request.withCredentials = !!config.withCredentials;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
// Add responseType to request if needed
|
|
2399
|
-
if (responseType && responseType !== 'json') {
|
|
2400
|
-
request.responseType = config.responseType;
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
// Handle progress if needed
|
|
2404
|
-
if (typeof config.onDownloadProgress === 'function') {
|
|
2405
|
-
request.addEventListener('progress', progressEventReducer$1(config.onDownloadProgress, true));
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
// Not all browsers support upload events
|
|
2409
|
-
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
|
2410
|
-
request.upload.addEventListener('progress', progressEventReducer$1(config.onUploadProgress));
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
if (config.cancelToken || config.signal) {
|
|
2414
|
-
// Handle cancellation
|
|
2415
|
-
// eslint-disable-next-line func-names
|
|
2416
|
-
onCanceled = cancel => {
|
|
2417
|
-
if (!request) {
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2421
|
-
request.abort();
|
|
2422
|
-
request = null;
|
|
2423
|
-
};
|
|
2424
|
-
|
|
2425
|
-
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
2426
|
-
if (config.signal) {
|
|
2427
|
-
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
const protocol = parseProtocol$1(fullPath);
|
|
2432
|
-
|
|
2433
|
-
if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
|
|
2434
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2435
|
-
return;
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
// Send the request
|
|
2440
|
-
request.send(requestData || null);
|
|
2441
|
-
});
|
|
2442
|
-
};
|
|
2443
|
-
|
|
2444
|
-
const knownAdapters$1 = {
|
|
2445
|
-
http: httpAdapter$1,
|
|
2446
|
-
xhr: xhrAdapter$1
|
|
2447
|
-
};
|
|
2448
|
-
|
|
2449
|
-
utils$1.forEach(knownAdapters$1, (fn, value) => {
|
|
2450
|
-
if(fn) {
|
|
2451
|
-
try {
|
|
2452
|
-
Object.defineProperty(fn, 'name', {value});
|
|
2453
|
-
} catch (e) {
|
|
2454
|
-
// eslint-disable-next-line no-empty
|
|
2455
|
-
}
|
|
2456
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
2457
|
-
}
|
|
2458
|
-
});
|
|
2459
|
-
|
|
2460
|
-
var adapters$1 = {
|
|
2461
|
-
getAdapter: (adapters) => {
|
|
2462
|
-
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
2463
|
-
|
|
2464
|
-
const {length} = adapters;
|
|
2465
|
-
let nameOrAdapter;
|
|
2466
|
-
let adapter;
|
|
2467
|
-
|
|
2468
|
-
for (let i = 0; i < length; i++) {
|
|
2469
|
-
nameOrAdapter = adapters[i];
|
|
2470
|
-
if((adapter = utils$1.isString(nameOrAdapter) ? knownAdapters$1[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
|
2471
|
-
break;
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
|
|
2475
|
-
if (!adapter) {
|
|
2476
|
-
if (adapter === false) {
|
|
2477
|
-
throw new AxiosError$1(
|
|
2478
|
-
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
|
2479
|
-
'ERR_NOT_SUPPORT'
|
|
2480
|
-
);
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
throw new Error(
|
|
2484
|
-
utils$1.hasOwnProp(knownAdapters$1, nameOrAdapter) ?
|
|
2485
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
|
2486
|
-
`Unknown adapter '${nameOrAdapter}'`
|
|
2487
|
-
);
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
if (!utils$1.isFunction(adapter)) {
|
|
2491
|
-
throw new TypeError('adapter is not a function');
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
return adapter;
|
|
2495
|
-
},
|
|
2496
|
-
adapters: knownAdapters$1
|
|
2497
|
-
};
|
|
2498
|
-
|
|
2499
|
-
/**
|
|
2500
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
2501
|
-
*
|
|
2502
|
-
* @param {Object} config The config that is to be used for the request
|
|
2503
|
-
*
|
|
2504
|
-
* @returns {void}
|
|
2505
|
-
*/
|
|
2506
|
-
function throwIfCancellationRequested$1(config) {
|
|
2507
|
-
if (config.cancelToken) {
|
|
2508
|
-
config.cancelToken.throwIfRequested();
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
if (config.signal && config.signal.aborted) {
|
|
2512
|
-
throw new CanceledError$1(null, config);
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
/**
|
|
2517
|
-
* Dispatch a request to the server using the configured adapter.
|
|
2518
|
-
*
|
|
2519
|
-
* @param {object} config The config that is to be used for the request
|
|
2520
|
-
*
|
|
2521
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
2522
|
-
*/
|
|
2523
|
-
function dispatchRequest$1(config) {
|
|
2524
|
-
throwIfCancellationRequested$1(config);
|
|
2525
|
-
|
|
2526
|
-
config.headers = AxiosHeaders$1$1.from(config.headers);
|
|
2527
|
-
|
|
2528
|
-
// Transform request data
|
|
2529
|
-
config.data = transformData$1.call(
|
|
2530
|
-
config,
|
|
2531
|
-
config.transformRequest
|
|
2532
|
-
);
|
|
2533
|
-
|
|
2534
|
-
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
2535
|
-
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
const adapter = adapters$1.getAdapter(config.adapter || defaults$1$1.adapter);
|
|
2539
|
-
|
|
2540
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
|
2541
|
-
throwIfCancellationRequested$1(config);
|
|
2542
|
-
|
|
2543
|
-
// Transform response data
|
|
2544
|
-
response.data = transformData$1.call(
|
|
2545
|
-
config,
|
|
2546
|
-
config.transformResponse,
|
|
2547
|
-
response
|
|
2548
|
-
);
|
|
2549
|
-
|
|
2550
|
-
response.headers = AxiosHeaders$1$1.from(response.headers);
|
|
2551
|
-
|
|
2552
|
-
return response;
|
|
2553
|
-
}, function onAdapterRejection(reason) {
|
|
2554
|
-
if (!isCancel$1(reason)) {
|
|
2555
|
-
throwIfCancellationRequested$1(config);
|
|
2556
|
-
|
|
2557
|
-
// Transform response data
|
|
2558
|
-
if (reason && reason.response) {
|
|
2559
|
-
reason.response.data = transformData$1.call(
|
|
2560
|
-
config,
|
|
2561
|
-
config.transformResponse,
|
|
2562
|
-
reason.response
|
|
2563
|
-
);
|
|
2564
|
-
reason.response.headers = AxiosHeaders$1$1.from(reason.response.headers);
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
return Promise.reject(reason);
|
|
2569
|
-
});
|
|
2570
|
-
}
|
|
2571
|
-
|
|
2572
|
-
const headersToObject$1 = (thing) => thing instanceof AxiosHeaders$1$1 ? thing.toJSON() : thing;
|
|
2573
|
-
|
|
2574
|
-
/**
|
|
2575
|
-
* Config-specific merge-function which creates a new config-object
|
|
2576
|
-
* by merging two configuration objects together.
|
|
2577
|
-
*
|
|
2578
|
-
* @param {Object} config1
|
|
2579
|
-
* @param {Object} config2
|
|
2580
|
-
*
|
|
2581
|
-
* @returns {Object} New object resulting from merging config2 to config1
|
|
2582
|
-
*/
|
|
2583
|
-
function mergeConfig$1(config1, config2) {
|
|
2584
|
-
// eslint-disable-next-line no-param-reassign
|
|
2585
|
-
config2 = config2 || {};
|
|
2586
|
-
const config = {};
|
|
2587
|
-
|
|
2588
|
-
function getMergedValue(target, source, caseless) {
|
|
2589
|
-
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2590
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
2591
|
-
} else if (utils$1.isPlainObject(source)) {
|
|
2592
|
-
return utils$1.merge({}, source);
|
|
2593
|
-
} else if (utils$1.isArray(source)) {
|
|
2594
|
-
return source.slice();
|
|
2595
|
-
}
|
|
2596
|
-
return source;
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
// eslint-disable-next-line consistent-return
|
|
2600
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
2601
|
-
if (!utils$1.isUndefined(b)) {
|
|
2602
|
-
return getMergedValue(a, b, caseless);
|
|
2603
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
2604
|
-
return getMergedValue(undefined, a, caseless);
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
|
|
2608
|
-
// eslint-disable-next-line consistent-return
|
|
2609
|
-
function valueFromConfig2(a, b) {
|
|
2610
|
-
if (!utils$1.isUndefined(b)) {
|
|
2611
|
-
return getMergedValue(undefined, b);
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
|
|
2615
|
-
// eslint-disable-next-line consistent-return
|
|
2616
|
-
function defaultToConfig2(a, b) {
|
|
2617
|
-
if (!utils$1.isUndefined(b)) {
|
|
2618
|
-
return getMergedValue(undefined, b);
|
|
2619
|
-
} else if (!utils$1.isUndefined(a)) {
|
|
2620
|
-
return getMergedValue(undefined, a);
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
// eslint-disable-next-line consistent-return
|
|
2625
|
-
function mergeDirectKeys(a, b, prop) {
|
|
2626
|
-
if (prop in config2) {
|
|
2627
|
-
return getMergedValue(a, b);
|
|
2628
|
-
} else if (prop in config1) {
|
|
2629
|
-
return getMergedValue(undefined, a);
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
|
|
2633
|
-
const mergeMap = {
|
|
2634
|
-
url: valueFromConfig2,
|
|
2635
|
-
method: valueFromConfig2,
|
|
2636
|
-
data: valueFromConfig2,
|
|
2637
|
-
baseURL: defaultToConfig2,
|
|
2638
|
-
transformRequest: defaultToConfig2,
|
|
2639
|
-
transformResponse: defaultToConfig2,
|
|
2640
|
-
paramsSerializer: defaultToConfig2,
|
|
2641
|
-
timeout: defaultToConfig2,
|
|
2642
|
-
timeoutMessage: defaultToConfig2,
|
|
2643
|
-
withCredentials: defaultToConfig2,
|
|
2644
|
-
adapter: defaultToConfig2,
|
|
2645
|
-
responseType: defaultToConfig2,
|
|
2646
|
-
xsrfCookieName: defaultToConfig2,
|
|
2647
|
-
xsrfHeaderName: defaultToConfig2,
|
|
2648
|
-
onUploadProgress: defaultToConfig2,
|
|
2649
|
-
onDownloadProgress: defaultToConfig2,
|
|
2650
|
-
decompress: defaultToConfig2,
|
|
2651
|
-
maxContentLength: defaultToConfig2,
|
|
2652
|
-
maxBodyLength: defaultToConfig2,
|
|
2653
|
-
beforeRedirect: defaultToConfig2,
|
|
2654
|
-
transport: defaultToConfig2,
|
|
2655
|
-
httpAgent: defaultToConfig2,
|
|
2656
|
-
httpsAgent: defaultToConfig2,
|
|
2657
|
-
cancelToken: defaultToConfig2,
|
|
2658
|
-
socketPath: defaultToConfig2,
|
|
2659
|
-
responseEncoding: defaultToConfig2,
|
|
2660
|
-
validateStatus: mergeDirectKeys,
|
|
2661
|
-
headers: (a, b) => mergeDeepProperties(headersToObject$1(a), headersToObject$1(b), true)
|
|
2662
|
-
};
|
|
2663
|
-
|
|
2664
|
-
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2665
|
-
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2666
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2667
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2668
|
-
});
|
|
2669
|
-
|
|
2670
|
-
return config;
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
const VERSION$1 = "1.4.0";
|
|
2674
|
-
|
|
2675
|
-
const validators$1$1 = {};
|
|
2676
|
-
|
|
2677
|
-
// eslint-disable-next-line func-names
|
|
2678
|
-
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
|
|
2679
|
-
validators$1$1[type] = function validator(thing) {
|
|
2680
|
-
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
2681
|
-
};
|
|
2682
|
-
});
|
|
2683
|
-
|
|
2684
|
-
const deprecatedWarnings$1 = {};
|
|
2685
|
-
|
|
2686
|
-
/**
|
|
2687
|
-
* Transitional option validator
|
|
2688
|
-
*
|
|
2689
|
-
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
2690
|
-
* @param {string?} version - deprecated version / removed since version
|
|
2691
|
-
* @param {string?} message - some message with additional info
|
|
2692
|
-
*
|
|
2693
|
-
* @returns {function}
|
|
2694
|
-
*/
|
|
2695
|
-
validators$1$1.transitional = function transitional(validator, version, message) {
|
|
2696
|
-
function formatMessage(opt, desc) {
|
|
2697
|
-
return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
// eslint-disable-next-line func-names
|
|
2701
|
-
return (value, opt, opts) => {
|
|
2702
|
-
if (validator === false) {
|
|
2703
|
-
throw new AxiosError$1(
|
|
2704
|
-
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
2705
|
-
AxiosError$1.ERR_DEPRECATED
|
|
2706
|
-
);
|
|
2707
|
-
}
|
|
2708
|
-
|
|
2709
|
-
if (version && !deprecatedWarnings$1[opt]) {
|
|
2710
|
-
deprecatedWarnings$1[opt] = true;
|
|
2711
|
-
// eslint-disable-next-line no-console
|
|
2712
|
-
console.warn(
|
|
2713
|
-
formatMessage(
|
|
2714
|
-
opt,
|
|
2715
|
-
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
2716
|
-
)
|
|
2717
|
-
);
|
|
2718
|
-
}
|
|
2719
|
-
|
|
2720
|
-
return validator ? validator(value, opt, opts) : true;
|
|
2721
|
-
};
|
|
2722
|
-
};
|
|
2723
|
-
|
|
2724
|
-
/**
|
|
2725
|
-
* Assert object's properties type
|
|
2726
|
-
*
|
|
2727
|
-
* @param {object} options
|
|
2728
|
-
* @param {object} schema
|
|
2729
|
-
* @param {boolean?} allowUnknown
|
|
2730
|
-
*
|
|
2731
|
-
* @returns {object}
|
|
2732
|
-
*/
|
|
2733
|
-
|
|
2734
|
-
function assertOptions$1(options, schema, allowUnknown) {
|
|
2735
|
-
if (typeof options !== 'object') {
|
|
2736
|
-
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2737
|
-
}
|
|
2738
|
-
const keys = Object.keys(options);
|
|
2739
|
-
let i = keys.length;
|
|
2740
|
-
while (i-- > 0) {
|
|
2741
|
-
const opt = keys[i];
|
|
2742
|
-
const validator = schema[opt];
|
|
2743
|
-
if (validator) {
|
|
2744
|
-
const value = options[opt];
|
|
2745
|
-
const result = value === undefined || validator(value, opt, options);
|
|
2746
|
-
if (result !== true) {
|
|
2747
|
-
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2748
|
-
}
|
|
2749
|
-
continue;
|
|
2750
|
-
}
|
|
2751
|
-
if (allowUnknown !== true) {
|
|
2752
|
-
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
var validator$1 = {
|
|
2758
|
-
assertOptions: assertOptions$1,
|
|
2759
|
-
validators: validators$1$1
|
|
2760
|
-
};
|
|
2761
|
-
|
|
2762
|
-
const validators$2 = validator$1.validators;
|
|
2763
|
-
|
|
2764
|
-
/**
|
|
2765
|
-
* Create a new instance of Axios
|
|
2766
|
-
*
|
|
2767
|
-
* @param {Object} instanceConfig The default config for the instance
|
|
2768
|
-
*
|
|
2769
|
-
* @return {Axios} A new instance of Axios
|
|
2770
|
-
*/
|
|
2771
|
-
let Axios$2 = class Axios {
|
|
2772
|
-
constructor(instanceConfig) {
|
|
2773
|
-
this.defaults = instanceConfig;
|
|
2774
|
-
this.interceptors = {
|
|
2775
|
-
request: new InterceptorManager$1$1(),
|
|
2776
|
-
response: new InterceptorManager$1$1()
|
|
2777
|
-
};
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
/**
|
|
2781
|
-
* Dispatch a request
|
|
2782
|
-
*
|
|
2783
|
-
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
2784
|
-
* @param {?Object} config
|
|
2785
|
-
*
|
|
2786
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
2787
|
-
*/
|
|
2788
|
-
request(configOrUrl, config) {
|
|
2789
|
-
/*eslint no-param-reassign:0*/
|
|
2790
|
-
// Allow for axios('example/url'[, config]) a la fetch API
|
|
2791
|
-
if (typeof configOrUrl === 'string') {
|
|
2792
|
-
config = config || {};
|
|
2793
|
-
config.url = configOrUrl;
|
|
2794
|
-
} else {
|
|
2795
|
-
config = configOrUrl || {};
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
config = mergeConfig$1(this.defaults, config);
|
|
2799
|
-
|
|
2800
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
2801
|
-
|
|
2802
|
-
if (transitional !== undefined) {
|
|
2803
|
-
validator$1.assertOptions(transitional, {
|
|
2804
|
-
silentJSONParsing: validators$2.transitional(validators$2.boolean),
|
|
2805
|
-
forcedJSONParsing: validators$2.transitional(validators$2.boolean),
|
|
2806
|
-
clarifyTimeoutError: validators$2.transitional(validators$2.boolean)
|
|
2807
|
-
}, false);
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
if (paramsSerializer != null) {
|
|
2811
|
-
if (utils$1.isFunction(paramsSerializer)) {
|
|
2812
|
-
config.paramsSerializer = {
|
|
2813
|
-
serialize: paramsSerializer
|
|
2814
|
-
};
|
|
2815
|
-
} else {
|
|
2816
|
-
validator$1.assertOptions(paramsSerializer, {
|
|
2817
|
-
encode: validators$2.function,
|
|
2818
|
-
serialize: validators$2.function
|
|
2819
|
-
}, true);
|
|
2820
|
-
}
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
// Set config.method
|
|
2824
|
-
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
2825
|
-
|
|
2826
|
-
let contextHeaders;
|
|
2827
|
-
|
|
2828
|
-
// Flatten headers
|
|
2829
|
-
contextHeaders = headers && utils$1.merge(
|
|
2830
|
-
headers.common,
|
|
2831
|
-
headers[config.method]
|
|
2832
|
-
);
|
|
2833
|
-
|
|
2834
|
-
contextHeaders && utils$1.forEach(
|
|
2835
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
2836
|
-
(method) => {
|
|
2837
|
-
delete headers[method];
|
|
2838
|
-
}
|
|
2839
|
-
);
|
|
2840
|
-
|
|
2841
|
-
config.headers = AxiosHeaders$1$1.concat(contextHeaders, headers);
|
|
2842
|
-
|
|
2843
|
-
// filter out skipped interceptors
|
|
2844
|
-
const requestInterceptorChain = [];
|
|
2845
|
-
let synchronousRequestInterceptors = true;
|
|
2846
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
2847
|
-
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
2848
|
-
return;
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2851
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
2852
|
-
|
|
2853
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
2854
|
-
});
|
|
2855
|
-
|
|
2856
|
-
const responseInterceptorChain = [];
|
|
2857
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
2858
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
2859
|
-
});
|
|
2860
|
-
|
|
2861
|
-
let promise;
|
|
2862
|
-
let i = 0;
|
|
2863
|
-
let len;
|
|
2864
|
-
|
|
2865
|
-
if (!synchronousRequestInterceptors) {
|
|
2866
|
-
const chain = [dispatchRequest$1.bind(this), undefined];
|
|
2867
|
-
chain.unshift.apply(chain, requestInterceptorChain);
|
|
2868
|
-
chain.push.apply(chain, responseInterceptorChain);
|
|
2869
|
-
len = chain.length;
|
|
2870
|
-
|
|
2871
|
-
promise = Promise.resolve(config);
|
|
2872
|
-
|
|
2873
|
-
while (i < len) {
|
|
2874
|
-
promise = promise.then(chain[i++], chain[i++]);
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
return promise;
|
|
2878
|
-
}
|
|
2879
|
-
|
|
2880
|
-
len = requestInterceptorChain.length;
|
|
2881
|
-
|
|
2882
|
-
let newConfig = config;
|
|
2883
|
-
|
|
2884
|
-
i = 0;
|
|
2885
|
-
|
|
2886
|
-
while (i < len) {
|
|
2887
|
-
const onFulfilled = requestInterceptorChain[i++];
|
|
2888
|
-
const onRejected = requestInterceptorChain[i++];
|
|
2889
|
-
try {
|
|
2890
|
-
newConfig = onFulfilled(newConfig);
|
|
2891
|
-
} catch (error) {
|
|
2892
|
-
onRejected.call(this, error);
|
|
2893
|
-
break;
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
try {
|
|
2898
|
-
promise = dispatchRequest$1.call(this, newConfig);
|
|
2899
|
-
} catch (error) {
|
|
2900
|
-
return Promise.reject(error);
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
i = 0;
|
|
2904
|
-
len = responseInterceptorChain.length;
|
|
2905
|
-
|
|
2906
|
-
while (i < len) {
|
|
2907
|
-
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
2908
|
-
}
|
|
2909
|
-
|
|
2910
|
-
return promise;
|
|
2911
|
-
}
|
|
2912
|
-
|
|
2913
|
-
getUri(config) {
|
|
2914
|
-
config = mergeConfig$1(this.defaults, config);
|
|
2915
|
-
const fullPath = buildFullPath$1(config.baseURL, config.url);
|
|
2916
|
-
return buildURL$1(fullPath, config.params, config.paramsSerializer);
|
|
2917
|
-
}
|
|
2918
|
-
};
|
|
2919
|
-
|
|
2920
|
-
// Provide aliases for supported request methods
|
|
2921
|
-
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
2922
|
-
/*eslint func-names:0*/
|
|
2923
|
-
Axios$2.prototype[method] = function(url, config) {
|
|
2924
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
2925
|
-
method,
|
|
2926
|
-
url,
|
|
2927
|
-
data: (config || {}).data
|
|
2928
|
-
}));
|
|
2929
|
-
};
|
|
2930
|
-
});
|
|
2931
|
-
|
|
2932
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2933
|
-
/*eslint func-names:0*/
|
|
2934
|
-
|
|
2935
|
-
function generateHTTPMethod(isForm) {
|
|
2936
|
-
return function httpMethod(url, data, config) {
|
|
2937
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
2938
|
-
method,
|
|
2939
|
-
headers: isForm ? {
|
|
2940
|
-
'Content-Type': 'multipart/form-data'
|
|
2941
|
-
} : {},
|
|
2942
|
-
url,
|
|
2943
|
-
data
|
|
2944
|
-
}));
|
|
2945
|
-
};
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
Axios$2.prototype[method] = generateHTTPMethod();
|
|
2949
|
-
|
|
2950
|
-
Axios$2.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
2951
|
-
});
|
|
2952
|
-
|
|
2953
|
-
var Axios$1$1 = Axios$2;
|
|
2954
|
-
|
|
2955
|
-
/**
|
|
2956
|
-
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
2957
|
-
*
|
|
2958
|
-
* @param {Function} executor The executor function.
|
|
2959
|
-
*
|
|
2960
|
-
* @returns {CancelToken}
|
|
2961
|
-
*/
|
|
2962
|
-
let CancelToken$2 = class CancelToken {
|
|
2963
|
-
constructor(executor) {
|
|
2964
|
-
if (typeof executor !== 'function') {
|
|
2965
|
-
throw new TypeError('executor must be a function.');
|
|
2966
|
-
}
|
|
2967
|
-
|
|
2968
|
-
let resolvePromise;
|
|
2969
|
-
|
|
2970
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
2971
|
-
resolvePromise = resolve;
|
|
2972
|
-
});
|
|
2973
|
-
|
|
2974
|
-
const token = this;
|
|
2975
|
-
|
|
2976
|
-
// eslint-disable-next-line func-names
|
|
2977
|
-
this.promise.then(cancel => {
|
|
2978
|
-
if (!token._listeners) return;
|
|
2979
|
-
|
|
2980
|
-
let i = token._listeners.length;
|
|
2981
|
-
|
|
2982
|
-
while (i-- > 0) {
|
|
2983
|
-
token._listeners[i](cancel);
|
|
2984
|
-
}
|
|
2985
|
-
token._listeners = null;
|
|
2986
|
-
});
|
|
2987
|
-
|
|
2988
|
-
// eslint-disable-next-line func-names
|
|
2989
|
-
this.promise.then = onfulfilled => {
|
|
2990
|
-
let _resolve;
|
|
2991
|
-
// eslint-disable-next-line func-names
|
|
2992
|
-
const promise = new Promise(resolve => {
|
|
2993
|
-
token.subscribe(resolve);
|
|
2994
|
-
_resolve = resolve;
|
|
2995
|
-
}).then(onfulfilled);
|
|
2996
|
-
|
|
2997
|
-
promise.cancel = function reject() {
|
|
2998
|
-
token.unsubscribe(_resolve);
|
|
2999
|
-
};
|
|
3000
|
-
|
|
3001
|
-
return promise;
|
|
3002
|
-
};
|
|
3003
|
-
|
|
3004
|
-
executor(function cancel(message, config, request) {
|
|
3005
|
-
if (token.reason) {
|
|
3006
|
-
// Cancellation has already been requested
|
|
3007
|
-
return;
|
|
3008
|
-
}
|
|
3009
|
-
|
|
3010
|
-
token.reason = new CanceledError$1(message, config, request);
|
|
3011
|
-
resolvePromise(token.reason);
|
|
3012
|
-
});
|
|
3013
|
-
}
|
|
3014
|
-
|
|
3015
|
-
/**
|
|
3016
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
3017
|
-
*/
|
|
3018
|
-
throwIfRequested() {
|
|
3019
|
-
if (this.reason) {
|
|
3020
|
-
throw this.reason;
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
|
|
3024
|
-
/**
|
|
3025
|
-
* Subscribe to the cancel signal
|
|
3026
|
-
*/
|
|
3027
|
-
|
|
3028
|
-
subscribe(listener) {
|
|
3029
|
-
if (this.reason) {
|
|
3030
|
-
listener(this.reason);
|
|
3031
|
-
return;
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
if (this._listeners) {
|
|
3035
|
-
this._listeners.push(listener);
|
|
3036
|
-
} else {
|
|
3037
|
-
this._listeners = [listener];
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
|
|
3041
|
-
/**
|
|
3042
|
-
* Unsubscribe from the cancel signal
|
|
3043
|
-
*/
|
|
3044
|
-
|
|
3045
|
-
unsubscribe(listener) {
|
|
3046
|
-
if (!this._listeners) {
|
|
3047
|
-
return;
|
|
3048
|
-
}
|
|
3049
|
-
const index = this._listeners.indexOf(listener);
|
|
3050
|
-
if (index !== -1) {
|
|
3051
|
-
this._listeners.splice(index, 1);
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3055
|
-
/**
|
|
3056
|
-
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
3057
|
-
* cancels the `CancelToken`.
|
|
3058
|
-
*/
|
|
3059
|
-
static source() {
|
|
3060
|
-
let cancel;
|
|
3061
|
-
const token = new CancelToken(function executor(c) {
|
|
3062
|
-
cancel = c;
|
|
3063
|
-
});
|
|
3064
|
-
return {
|
|
3065
|
-
token,
|
|
3066
|
-
cancel
|
|
3067
|
-
};
|
|
3068
|
-
}
|
|
3069
|
-
};
|
|
3070
|
-
|
|
3071
|
-
var CancelToken$1$1 = CancelToken$2;
|
|
3072
|
-
|
|
3073
|
-
/**
|
|
3074
|
-
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
3075
|
-
*
|
|
3076
|
-
* Common use case would be to use `Function.prototype.apply`.
|
|
3077
|
-
*
|
|
3078
|
-
* ```js
|
|
3079
|
-
* function f(x, y, z) {}
|
|
3080
|
-
* var args = [1, 2, 3];
|
|
3081
|
-
* f.apply(null, args);
|
|
3082
|
-
* ```
|
|
3083
|
-
*
|
|
3084
|
-
* With `spread` this example can be re-written.
|
|
3085
|
-
*
|
|
3086
|
-
* ```js
|
|
3087
|
-
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
3088
|
-
* ```
|
|
3089
|
-
*
|
|
3090
|
-
* @param {Function} callback
|
|
3091
|
-
*
|
|
3092
|
-
* @returns {Function}
|
|
3093
|
-
*/
|
|
3094
|
-
function spread$1(callback) {
|
|
3095
|
-
return function wrap(arr) {
|
|
3096
|
-
return callback.apply(null, arr);
|
|
3097
|
-
};
|
|
3098
|
-
}
|
|
3099
|
-
|
|
3100
|
-
/**
|
|
3101
|
-
* Determines whether the payload is an error thrown by Axios
|
|
3102
|
-
*
|
|
3103
|
-
* @param {*} payload The value to test
|
|
3104
|
-
*
|
|
3105
|
-
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3106
|
-
*/
|
|
3107
|
-
function isAxiosError$1(payload) {
|
|
3108
|
-
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
|
3109
|
-
}
|
|
3110
|
-
|
|
3111
|
-
const HttpStatusCode$2 = {
|
|
3112
|
-
Continue: 100,
|
|
3113
|
-
SwitchingProtocols: 101,
|
|
3114
|
-
Processing: 102,
|
|
3115
|
-
EarlyHints: 103,
|
|
3116
|
-
Ok: 200,
|
|
3117
|
-
Created: 201,
|
|
3118
|
-
Accepted: 202,
|
|
3119
|
-
NonAuthoritativeInformation: 203,
|
|
3120
|
-
NoContent: 204,
|
|
3121
|
-
ResetContent: 205,
|
|
3122
|
-
PartialContent: 206,
|
|
3123
|
-
MultiStatus: 207,
|
|
3124
|
-
AlreadyReported: 208,
|
|
3125
|
-
ImUsed: 226,
|
|
3126
|
-
MultipleChoices: 300,
|
|
3127
|
-
MovedPermanently: 301,
|
|
3128
|
-
Found: 302,
|
|
3129
|
-
SeeOther: 303,
|
|
3130
|
-
NotModified: 304,
|
|
3131
|
-
UseProxy: 305,
|
|
3132
|
-
Unused: 306,
|
|
3133
|
-
TemporaryRedirect: 307,
|
|
3134
|
-
PermanentRedirect: 308,
|
|
3135
|
-
BadRequest: 400,
|
|
3136
|
-
Unauthorized: 401,
|
|
3137
|
-
PaymentRequired: 402,
|
|
3138
|
-
Forbidden: 403,
|
|
3139
|
-
NotFound: 404,
|
|
3140
|
-
MethodNotAllowed: 405,
|
|
3141
|
-
NotAcceptable: 406,
|
|
3142
|
-
ProxyAuthenticationRequired: 407,
|
|
3143
|
-
RequestTimeout: 408,
|
|
3144
|
-
Conflict: 409,
|
|
3145
|
-
Gone: 410,
|
|
3146
|
-
LengthRequired: 411,
|
|
3147
|
-
PreconditionFailed: 412,
|
|
3148
|
-
PayloadTooLarge: 413,
|
|
3149
|
-
UriTooLong: 414,
|
|
3150
|
-
UnsupportedMediaType: 415,
|
|
3151
|
-
RangeNotSatisfiable: 416,
|
|
3152
|
-
ExpectationFailed: 417,
|
|
3153
|
-
ImATeapot: 418,
|
|
3154
|
-
MisdirectedRequest: 421,
|
|
3155
|
-
UnprocessableEntity: 422,
|
|
3156
|
-
Locked: 423,
|
|
3157
|
-
FailedDependency: 424,
|
|
3158
|
-
TooEarly: 425,
|
|
3159
|
-
UpgradeRequired: 426,
|
|
3160
|
-
PreconditionRequired: 428,
|
|
3161
|
-
TooManyRequests: 429,
|
|
3162
|
-
RequestHeaderFieldsTooLarge: 431,
|
|
3163
|
-
UnavailableForLegalReasons: 451,
|
|
3164
|
-
InternalServerError: 500,
|
|
3165
|
-
NotImplemented: 501,
|
|
3166
|
-
BadGateway: 502,
|
|
3167
|
-
ServiceUnavailable: 503,
|
|
3168
|
-
GatewayTimeout: 504,
|
|
3169
|
-
HttpVersionNotSupported: 505,
|
|
3170
|
-
VariantAlsoNegotiates: 506,
|
|
3171
|
-
InsufficientStorage: 507,
|
|
3172
|
-
LoopDetected: 508,
|
|
3173
|
-
NotExtended: 510,
|
|
3174
|
-
NetworkAuthenticationRequired: 511,
|
|
3175
|
-
};
|
|
3176
|
-
|
|
3177
|
-
Object.entries(HttpStatusCode$2).forEach(([key, value]) => {
|
|
3178
|
-
HttpStatusCode$2[value] = key;
|
|
3179
|
-
});
|
|
3180
|
-
|
|
3181
|
-
var HttpStatusCode$1$1 = HttpStatusCode$2;
|
|
3182
|
-
|
|
3183
|
-
/**
|
|
3184
|
-
* Create an instance of Axios
|
|
3185
|
-
*
|
|
3186
|
-
* @param {Object} defaultConfig The default config for the instance
|
|
3187
|
-
*
|
|
3188
|
-
* @returns {Axios} A new instance of Axios
|
|
3189
|
-
*/
|
|
3190
|
-
function createInstance$1(defaultConfig) {
|
|
3191
|
-
const context = new Axios$1$1(defaultConfig);
|
|
3192
|
-
const instance = bind$1(Axios$1$1.prototype.request, context);
|
|
3193
|
-
|
|
3194
|
-
// Copy axios.prototype to instance
|
|
3195
|
-
utils$1.extend(instance, Axios$1$1.prototype, context, {allOwnKeys: true});
|
|
3196
|
-
|
|
3197
|
-
// Copy context to instance
|
|
3198
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
3199
|
-
|
|
3200
|
-
// Factory for creating new instances
|
|
3201
|
-
instance.create = function create(instanceConfig) {
|
|
3202
|
-
return createInstance$1(mergeConfig$1(defaultConfig, instanceConfig));
|
|
3203
|
-
};
|
|
3204
|
-
|
|
3205
|
-
return instance;
|
|
3206
|
-
}
|
|
3207
|
-
|
|
3208
|
-
// Create the default instance to be exported
|
|
3209
|
-
const axios$1 = createInstance$1(defaults$1$1);
|
|
3210
|
-
|
|
3211
|
-
// Expose Axios class to allow class inheritance
|
|
3212
|
-
axios$1.Axios = Axios$1$1;
|
|
3213
|
-
|
|
3214
|
-
// Expose Cancel & CancelToken
|
|
3215
|
-
axios$1.CanceledError = CanceledError$1;
|
|
3216
|
-
axios$1.CancelToken = CancelToken$1$1;
|
|
3217
|
-
axios$1.isCancel = isCancel$1;
|
|
3218
|
-
axios$1.VERSION = VERSION$1;
|
|
3219
|
-
axios$1.toFormData = toFormData$1;
|
|
3220
|
-
|
|
3221
|
-
// Expose AxiosError class
|
|
3222
|
-
axios$1.AxiosError = AxiosError$1;
|
|
3223
|
-
|
|
3224
|
-
// alias for CanceledError for backward compatibility
|
|
3225
|
-
axios$1.Cancel = axios$1.CanceledError;
|
|
3226
|
-
|
|
3227
|
-
// Expose all/spread
|
|
3228
|
-
axios$1.all = function all(promises) {
|
|
3229
|
-
return Promise.all(promises);
|
|
3230
|
-
};
|
|
3231
|
-
|
|
3232
|
-
axios$1.spread = spread$1;
|
|
3233
|
-
|
|
3234
|
-
// Expose isAxiosError
|
|
3235
|
-
axios$1.isAxiosError = isAxiosError$1;
|
|
3236
|
-
|
|
3237
|
-
// Expose mergeConfig
|
|
3238
|
-
axios$1.mergeConfig = mergeConfig$1;
|
|
3239
|
-
|
|
3240
|
-
axios$1.AxiosHeaders = AxiosHeaders$1$1;
|
|
3241
|
-
|
|
3242
|
-
axios$1.formToJSON = thing => formDataToJSON$1(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3243
|
-
|
|
3244
|
-
axios$1.HttpStatusCode = HttpStatusCode$1$1;
|
|
3245
|
-
|
|
3246
|
-
axios$1.default = axios$1;
|
|
3247
|
-
|
|
3248
|
-
// this module should only have a default export
|
|
3249
|
-
var globalAxios$1 = axios$1;
|
|
3250
|
-
|
|
3251
|
-
/* tslint:disable */
|
|
3252
|
-
/* eslint-disable */
|
|
3253
|
-
/**
|
|
3254
|
-
* Immutable X API
|
|
3255
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
3256
|
-
*
|
|
3257
|
-
* The version of the OpenAPI document: 3.0
|
|
3258
|
-
* Contact: support@immutable.com
|
|
3259
|
-
*
|
|
3260
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
3261
|
-
* https://openapi-generator.tech
|
|
3262
|
-
* Do not edit the class manually.
|
|
3263
|
-
*/
|
|
3264
|
-
let Configuration$1 = class Configuration {
|
|
3265
|
-
/**
|
|
3266
|
-
* parameter for apiKey security
|
|
3267
|
-
* @param name security name
|
|
3268
|
-
* @memberof Configuration
|
|
3269
|
-
*/
|
|
3270
|
-
apiKey;
|
|
3271
|
-
/**
|
|
3272
|
-
* parameter for basic security
|
|
3273
|
-
*
|
|
3274
|
-
* @type {string}
|
|
3275
|
-
* @memberof Configuration
|
|
3276
|
-
*/
|
|
3277
|
-
username;
|
|
3278
|
-
/**
|
|
3279
|
-
* parameter for basic security
|
|
3280
|
-
*
|
|
3281
|
-
* @type {string}
|
|
3282
|
-
* @memberof Configuration
|
|
3283
|
-
*/
|
|
3284
|
-
password;
|
|
3285
|
-
/**
|
|
3286
|
-
* parameter for oauth2 security
|
|
3287
|
-
* @param name security name
|
|
3288
|
-
* @param scopes oauth2 scope
|
|
3289
|
-
* @memberof Configuration
|
|
3290
|
-
*/
|
|
3291
|
-
accessToken;
|
|
3292
|
-
/**
|
|
3293
|
-
* override base path
|
|
3294
|
-
*
|
|
3295
|
-
* @type {string}
|
|
3296
|
-
* @memberof Configuration
|
|
3297
|
-
*/
|
|
3298
|
-
basePath;
|
|
3299
|
-
/**
|
|
3300
|
-
* base options for axios calls
|
|
3301
|
-
*
|
|
3302
|
-
* @type {any}
|
|
3303
|
-
* @memberof Configuration
|
|
3304
|
-
*/
|
|
3305
|
-
baseOptions;
|
|
3306
|
-
/**
|
|
3307
|
-
* The FormData constructor that will be used to create multipart form data
|
|
3308
|
-
* requests. You can inject this here so that execution environments that
|
|
3309
|
-
* do not support the FormData class can still run the generated client.
|
|
3310
|
-
*
|
|
3311
|
-
* @type {new () => FormData}
|
|
3312
|
-
*/
|
|
3313
|
-
formDataCtor;
|
|
3314
|
-
constructor(param = {}) {
|
|
3315
|
-
this.apiKey = param.apiKey;
|
|
3316
|
-
this.username = param.username;
|
|
3317
|
-
this.password = param.password;
|
|
3318
|
-
this.accessToken = param.accessToken;
|
|
3319
|
-
this.basePath = param.basePath;
|
|
3320
|
-
this.baseOptions = param.baseOptions;
|
|
3321
|
-
this.formDataCtor = param.formDataCtor;
|
|
3322
|
-
}
|
|
3323
|
-
/**
|
|
3324
|
-
* Check if the given MIME is a JSON MIME.
|
|
3325
|
-
* JSON MIME examples:
|
|
3326
|
-
* application/json
|
|
3327
|
-
* application/json; charset=UTF8
|
|
3328
|
-
* APPLICATION/JSON
|
|
3329
|
-
* application/vnd.company+json
|
|
3330
|
-
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
3331
|
-
* @return True if the given MIME is JSON, false otherwise.
|
|
3332
|
-
*/
|
|
3333
|
-
isJsonMime(mime) {
|
|
3334
|
-
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
3335
|
-
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
3336
|
-
}
|
|
3337
|
-
};
|
|
3338
|
-
|
|
3339
40
|
/* tslint:disable */
|
|
3340
41
|
/* eslint-disable */
|
|
3341
42
|
/**
|
|
@@ -5044,7 +1745,7 @@ class TokensApi extends BaseAPI$1 {
|
|
|
5044
1745
|
* https://openapi-generator.tech
|
|
5045
1746
|
* Do not edit the class manually.
|
|
5046
1747
|
*/
|
|
5047
|
-
let Configuration$
|
|
1748
|
+
let Configuration$1 = class Configuration {
|
|
5048
1749
|
/**
|
|
5049
1750
|
* parameter for apiKey security
|
|
5050
1751
|
* @param name security name
|
|
@@ -5456,122 +2157,59 @@ const TokenContractType = {
|
|
|
5456
2157
|
*/
|
|
5457
2158
|
|
|
5458
2159
|
var index = /*#__PURE__*/Object.freeze({
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
2160
|
+
__proto__: null,
|
|
2161
|
+
APIError400AllOfCodeEnum: APIError400AllOfCodeEnum,
|
|
2162
|
+
APIError401AllOfCodeEnum: APIError401AllOfCodeEnum,
|
|
2163
|
+
APIError403AllOfCodeEnum: APIError403AllOfCodeEnum,
|
|
2164
|
+
APIError404AllOfCodeEnum: APIError404AllOfCodeEnum,
|
|
2165
|
+
APIError429AllOfCodeEnum: APIError429AllOfCodeEnum,
|
|
2166
|
+
APIError500AllOfCodeEnum: APIError500AllOfCodeEnum,
|
|
2167
|
+
ActivitiesApi: ActivitiesApi,
|
|
2168
|
+
ActivitiesApiAxiosParamCreator: ActivitiesApiAxiosParamCreator,
|
|
2169
|
+
ActivitiesApiFactory: ActivitiesApiFactory,
|
|
2170
|
+
ActivitiesApiFp: ActivitiesApiFp,
|
|
2171
|
+
ActivityType: ActivityType,
|
|
2172
|
+
ChainsApi: ChainsApi,
|
|
2173
|
+
ChainsApiAxiosParamCreator: ChainsApiAxiosParamCreator,
|
|
2174
|
+
ChainsApiFactory: ChainsApiFactory,
|
|
2175
|
+
ChainsApiFp: ChainsApiFp,
|
|
2176
|
+
CollectionContractType: CollectionContractType,
|
|
2177
|
+
CollectionsApi: CollectionsApi,
|
|
2178
|
+
CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
|
|
2179
|
+
CollectionsApiFactory: CollectionsApiFactory,
|
|
2180
|
+
CollectionsApiFp: CollectionsApiFp,
|
|
2181
|
+
Configuration: Configuration$1,
|
|
2182
|
+
CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
|
|
2183
|
+
ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
|
|
2184
|
+
ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
|
|
2185
|
+
FeeFeeTypeEnum: FeeFeeTypeEnum,
|
|
2186
|
+
NFTContractType: NFTContractType,
|
|
2187
|
+
NativeItemItemTypeEnum: NativeItemItemTypeEnum,
|
|
2188
|
+
NftOwnersApi: NftOwnersApi,
|
|
2189
|
+
NftOwnersApiAxiosParamCreator: NftOwnersApiAxiosParamCreator,
|
|
2190
|
+
NftOwnersApiFactory: NftOwnersApiFactory,
|
|
2191
|
+
NftOwnersApiFp: NftOwnersApiFp,
|
|
2192
|
+
NftsApi: NftsApi,
|
|
2193
|
+
NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
|
|
2194
|
+
NftsApiFactory: NftsApiFactory,
|
|
2195
|
+
NftsApiFp: NftsApiFp,
|
|
2196
|
+
OrderStatus: OrderStatus$1,
|
|
2197
|
+
OrdersApi: OrdersApi,
|
|
2198
|
+
OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
|
|
2199
|
+
OrdersApiFactory: OrdersApiFactory,
|
|
2200
|
+
OrdersApiFp: OrdersApiFp,
|
|
2201
|
+
PassportApi: PassportApi,
|
|
2202
|
+
PassportApiAxiosParamCreator: PassportApiAxiosParamCreator,
|
|
2203
|
+
PassportApiFactory: PassportApiFactory,
|
|
2204
|
+
PassportApiFp: PassportApiFp,
|
|
2205
|
+
SaleFeeTypeEnum: SaleFeeTypeEnum,
|
|
2206
|
+
TokenContractType: TokenContractType,
|
|
2207
|
+
TokensApi: TokensApi,
|
|
2208
|
+
TokensApiAxiosParamCreator: TokensApiAxiosParamCreator,
|
|
2209
|
+
TokensApiFactory: TokensApiFactory,
|
|
2210
|
+
TokensApiFp: TokensApiFp
|
|
5510
2211
|
});
|
|
5511
2212
|
|
|
5512
|
-
class MultiRollupApiClients {
|
|
5513
|
-
config;
|
|
5514
|
-
activitiesApi;
|
|
5515
|
-
chainsApi;
|
|
5516
|
-
collectionApi;
|
|
5517
|
-
nftOwnersApi;
|
|
5518
|
-
nftsApi;
|
|
5519
|
-
ordersApi;
|
|
5520
|
-
passportApi;
|
|
5521
|
-
constructor(config) {
|
|
5522
|
-
this.config = config;
|
|
5523
|
-
this.activitiesApi = new ActivitiesApi(config.indexer);
|
|
5524
|
-
this.chainsApi = new ChainsApi(config.indexer);
|
|
5525
|
-
this.collectionApi = new CollectionsApi(config.indexer);
|
|
5526
|
-
this.nftOwnersApi = new NftOwnersApi(config.indexer);
|
|
5527
|
-
this.nftsApi = new NftsApi(config.indexer);
|
|
5528
|
-
this.ordersApi = new OrdersApi(config.orderBook);
|
|
5529
|
-
this.passportApi = new PassportApi(config.passport);
|
|
5530
|
-
}
|
|
5531
|
-
}
|
|
5532
|
-
|
|
5533
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5534
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.0-alpha' };
|
|
5535
|
-
const createConfig = ({ basePath, headers, }) => {
|
|
5536
|
-
if (!basePath.trim()) {
|
|
5537
|
-
throw Error('basePath can not be empty');
|
|
5538
|
-
}
|
|
5539
|
-
const composedHeaders = { ...defaultHeaders$1, ...(headers || {}) };
|
|
5540
|
-
const apiConfigOptions = {
|
|
5541
|
-
basePath,
|
|
5542
|
-
baseOptions: { headers: composedHeaders },
|
|
5543
|
-
};
|
|
5544
|
-
return new Configuration$1(apiConfigOptions);
|
|
5545
|
-
};
|
|
5546
|
-
/**
|
|
5547
|
-
* Creates a Configuration for the specified environment
|
|
5548
|
-
* @returns an MultiRollupAPIConfiguration
|
|
5549
|
-
*/
|
|
5550
|
-
const multiRollupConfig = {
|
|
5551
|
-
getProduction: () => ({
|
|
5552
|
-
indexer: createConfig({
|
|
5553
|
-
basePath: 'https://indexer-mr.imtbl.com',
|
|
5554
|
-
}),
|
|
5555
|
-
orderBook: createConfig({
|
|
5556
|
-
basePath: 'https://order-book-mr.imtbl.com',
|
|
5557
|
-
}),
|
|
5558
|
-
passport: createConfig({
|
|
5559
|
-
basePath: 'https://api.immutable.com',
|
|
5560
|
-
}),
|
|
5561
|
-
}),
|
|
5562
|
-
getSandbox: () => ({
|
|
5563
|
-
indexer: createConfig({
|
|
5564
|
-
basePath: 'https://indexer-mr.sandbox.imtbl.com',
|
|
5565
|
-
}),
|
|
5566
|
-
orderBook: createConfig({
|
|
5567
|
-
basePath: 'https://order-book-mr.sandbox.imtbl.com',
|
|
5568
|
-
}),
|
|
5569
|
-
passport: createConfig({
|
|
5570
|
-
basePath: 'https://api.sandbox.immutable.com',
|
|
5571
|
-
}),
|
|
5572
|
-
}),
|
|
5573
|
-
};
|
|
5574
|
-
|
|
5575
2213
|
/**
|
|
5576
2214
|
* Custom Error class that is returned from the API when a request fails
|
|
5577
2215
|
*/
|
|
@@ -5591,7 +2229,7 @@ class APIError extends Error {
|
|
|
5591
2229
|
|
|
5592
2230
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5593
2231
|
const defaultHeaders = {
|
|
5594
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha',
|
|
2232
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha.2',
|
|
5595
2233
|
};
|
|
5596
2234
|
/**
|
|
5597
2235
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5647,7 +2285,7 @@ class BlockchainDataConfiguration {
|
|
|
5647
2285
|
* @returns APIError
|
|
5648
2286
|
*/
|
|
5649
2287
|
function formatError(error) {
|
|
5650
|
-
if (
|
|
2288
|
+
if (globalAxios$1.isAxiosError(error) && error.response) {
|
|
5651
2289
|
const apiError = error.response.data;
|
|
5652
2290
|
if (apiError.code && apiError.message) {
|
|
5653
2291
|
return new APIError({
|
|
@@ -5857,7 +2495,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5857
2495
|
chainID,
|
|
5858
2496
|
coreContractAddress,
|
|
5859
2497
|
registrationContractAddress,
|
|
5860
|
-
sdkVersion: 'ts-immutable-sdk-0.4.0-alpha',
|
|
2498
|
+
sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.2',
|
|
5861
2499
|
});
|
|
5862
2500
|
/**
|
|
5863
2501
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9581,8 +6219,6 @@ var globalAxios = axios;
|
|
|
9581
6219
|
* https://openapi-generator.tech
|
|
9582
6220
|
* Do not edit the class manually.
|
|
9583
6221
|
*/
|
|
9584
|
-
// Some imports not used depending on template conditions
|
|
9585
|
-
// @ts-ignore
|
|
9586
6222
|
const BASE_PATH = "https://guardian.sandbox.imtbl.com".replace(/\/+$/, "");
|
|
9587
6223
|
/**
|
|
9588
6224
|
*
|
|
@@ -9610,10 +6246,10 @@ class BaseAPI {
|
|
|
9610
6246
|
*/
|
|
9611
6247
|
class RequiredError extends Error {
|
|
9612
6248
|
field;
|
|
9613
|
-
name = "RequiredError";
|
|
9614
6249
|
constructor(field, msg) {
|
|
9615
6250
|
super(msg);
|
|
9616
6251
|
this.field = field;
|
|
6252
|
+
this.name = "RequiredError";
|
|
9617
6253
|
}
|
|
9618
6254
|
}
|
|
9619
6255
|
|
|
@@ -9658,6 +6294,8 @@ const setBearerAuthToObject = async function (object, configuration) {
|
|
|
9658
6294
|
}
|
|
9659
6295
|
};
|
|
9660
6296
|
function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
6297
|
+
if (parameter == null)
|
|
6298
|
+
return;
|
|
9661
6299
|
if (typeof parameter === "object") {
|
|
9662
6300
|
if (Array.isArray(parameter)) {
|
|
9663
6301
|
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
@@ -9813,7 +6451,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
|
|
|
9813
6451
|
* @summary Info for a specific transaction
|
|
9814
6452
|
* @param {string} transactionID The id of the starkex transaction to retrieve
|
|
9815
6453
|
* @param {'starkex' | 'evm'} chainType roll up type
|
|
9816
|
-
* @param {
|
|
6454
|
+
* @param {number} [chainID] ID of evm chain
|
|
9817
6455
|
* @param {*} [options] Override http request option.
|
|
9818
6456
|
* @throws {RequiredError}
|
|
9819
6457
|
*/
|
|
@@ -9888,7 +6526,7 @@ const TransactionsApiFp = function (configuration) {
|
|
|
9888
6526
|
* @summary Info for a specific transaction
|
|
9889
6527
|
* @param {string} transactionID The id of the starkex transaction to retrieve
|
|
9890
6528
|
* @param {'starkex' | 'evm'} chainType roll up type
|
|
9891
|
-
* @param {
|
|
6529
|
+
* @param {number} [chainID] ID of evm chain
|
|
9892
6530
|
* @param {*} [options] Override http request option.
|
|
9893
6531
|
* @throws {RequiredError}
|
|
9894
6532
|
*/
|
|
@@ -10205,12 +6843,10 @@ class AuthManager {
|
|
|
10205
6843
|
userManager;
|
|
10206
6844
|
config;
|
|
10207
6845
|
deviceCredentialsManager;
|
|
10208
|
-
logoutMode;
|
|
10209
6846
|
constructor(config) {
|
|
10210
6847
|
this.config = config;
|
|
10211
6848
|
this.userManager = new UserManager(getAuthConfiguration(config));
|
|
10212
6849
|
this.deviceCredentialsManager = new DeviceCredentialsManager();
|
|
10213
|
-
this.logoutMode = config.oidcConfiguration.logoutMode || 'redirect';
|
|
10214
6850
|
}
|
|
10215
6851
|
static mapOidcUserToDomainModel = (oidcUser) => {
|
|
10216
6852
|
const passport = oidcUser.profile?.passport;
|
|
@@ -10275,7 +6911,7 @@ class AuthManager {
|
|
|
10275
6911
|
}
|
|
10276
6912
|
async loginWithDeviceFlow() {
|
|
10277
6913
|
return withPassportError(async () => {
|
|
10278
|
-
const response = await
|
|
6914
|
+
const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/device/code`, {
|
|
10279
6915
|
client_id: this.config.oidcConfiguration.clientId,
|
|
10280
6916
|
scope: this.config.oidcConfiguration.scope,
|
|
10281
6917
|
audience: this.config.oidcConfiguration.audience,
|
|
@@ -10308,7 +6944,7 @@ class AuthManager {
|
|
|
10308
6944
|
return user;
|
|
10309
6945
|
}
|
|
10310
6946
|
catch (error) {
|
|
10311
|
-
if (
|
|
6947
|
+
if (globalAxios$1.isAxiosError(error)) {
|
|
10312
6948
|
const responseError = error.response?.data;
|
|
10313
6949
|
switch (responseError.error) {
|
|
10314
6950
|
case 'authorization_pending':
|
|
@@ -10333,7 +6969,7 @@ class AuthManager {
|
|
|
10333
6969
|
}
|
|
10334
6970
|
/* eslint-enable no-await-in-loop */
|
|
10335
6971
|
async getDeviceFlowToken(deviceCode) {
|
|
10336
|
-
const response = await
|
|
6972
|
+
const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
|
|
10337
6973
|
client_id: this.config.oidcConfiguration.clientId,
|
|
10338
6974
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
10339
6975
|
device_code: deviceCode,
|
|
@@ -10356,7 +6992,7 @@ class AuthManager {
|
|
|
10356
6992
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
10357
6993
|
}
|
|
10358
6994
|
async refreshToken(refreshToken) {
|
|
10359
|
-
const response = await
|
|
6995
|
+
const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
|
|
10360
6996
|
client_id: this.config.oidcConfiguration.clientId,
|
|
10361
6997
|
grant_type: 'refresh_token',
|
|
10362
6998
|
refresh_token: refreshToken,
|
|
@@ -10364,15 +7000,7 @@ class AuthManager {
|
|
|
10364
7000
|
return response.data;
|
|
10365
7001
|
}
|
|
10366
7002
|
async logout() {
|
|
10367
|
-
return withPassportError(async () =>
|
|
10368
|
-
if (this.logoutMode === 'silent') {
|
|
10369
|
-
return this.userManager.signoutSilent();
|
|
10370
|
-
}
|
|
10371
|
-
return this.userManager.signoutRedirect();
|
|
10372
|
-
}, PassportErrorType.LOGOUT_ERROR);
|
|
10373
|
-
}
|
|
10374
|
-
async logoutSilentCallback(url) {
|
|
10375
|
-
return this.userManager.signoutSilentCallback(url);
|
|
7003
|
+
return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
|
|
10376
7004
|
}
|
|
10377
7005
|
async logoutDeviceFlow() {
|
|
10378
7006
|
return withPassportError(async () => {
|
|
@@ -10575,7 +7203,6 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
|
|
|
10575
7203
|
amount_sell: amountSell,
|
|
10576
7204
|
token_sell: convertToSignableToken(request.sell),
|
|
10577
7205
|
fees: request.fees,
|
|
10578
|
-
split_fees: true,
|
|
10579
7206
|
expiration_timestamp: request.expiration_timestamp,
|
|
10580
7207
|
};
|
|
10581
7208
|
const getSignableOrderResponse = await ordersApi.getSignableOrder({
|
|
@@ -11030,10 +7657,6 @@ class PassportConfiguration {
|
|
|
11030
7657
|
magicProviderId;
|
|
11031
7658
|
oidcConfiguration;
|
|
11032
7659
|
baseConfig;
|
|
11033
|
-
zkEvmChainId;
|
|
11034
|
-
zkEvmRpcUrl;
|
|
11035
|
-
relayerUrl;
|
|
11036
|
-
multiRollupConfig;
|
|
11037
7660
|
constructor({ baseConfig, overrides, ...oidcConfiguration }) {
|
|
11038
7661
|
validateConfiguration(oidcConfiguration, [
|
|
11039
7662
|
'clientId',
|
|
@@ -11046,16 +7669,10 @@ class PassportConfiguration {
|
|
|
11046
7669
|
validateConfiguration(overrides, [
|
|
11047
7670
|
'network',
|
|
11048
7671
|
'authenticationDomain',
|
|
11049
|
-
'passportDomain',
|
|
11050
7672
|
'magicPublishableApiKey',
|
|
11051
7673
|
'magicProviderId',
|
|
11052
|
-
'
|
|
11053
|
-
'zkEvmChainId',
|
|
11054
|
-
'relayerUrl',
|
|
7674
|
+
'passportDomain',
|
|
11055
7675
|
'imxPublicApiDomain',
|
|
11056
|
-
'indexerMrBasePath',
|
|
11057
|
-
'orderBookMrBasePath',
|
|
11058
|
-
'passportMrBasePath',
|
|
11059
7676
|
], 'overrides');
|
|
11060
7677
|
this.network = overrides.network;
|
|
11061
7678
|
this.authenticationDomain = overrides.authenticationDomain;
|
|
@@ -11063,20 +7680,6 @@ class PassportConfiguration {
|
|
|
11063
7680
|
this.imxPublicApiDomain = overrides.imxPublicApiDomain;
|
|
11064
7681
|
this.magicPublishableApiKey = overrides.magicPublishableApiKey;
|
|
11065
7682
|
this.magicProviderId = overrides.magicProviderId;
|
|
11066
|
-
this.zkEvmRpcUrl = overrides.zkEvmRpcUrl;
|
|
11067
|
-
this.zkEvmChainId = overrides.zkEvmChainId;
|
|
11068
|
-
this.relayerUrl = overrides.relayerUrl;
|
|
11069
|
-
this.multiRollupConfig = {
|
|
11070
|
-
indexer: createConfig({
|
|
11071
|
-
basePath: overrides.indexerMrBasePath,
|
|
11072
|
-
}),
|
|
11073
|
-
orderBook: createConfig({
|
|
11074
|
-
basePath: overrides.orderBookMrBasePath,
|
|
11075
|
-
}),
|
|
11076
|
-
passport: createConfig({
|
|
11077
|
-
basePath: overrides.passportMrBasePath,
|
|
11078
|
-
}),
|
|
11079
|
-
};
|
|
11080
7683
|
}
|
|
11081
7684
|
else {
|
|
11082
7685
|
switch (baseConfig.environment) {
|
|
@@ -11087,10 +7690,6 @@ class PassportConfiguration {
|
|
|
11087
7690
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
11088
7691
|
this.passportDomain = 'https://passport.immutable.com';
|
|
11089
7692
|
this.imxPublicApiDomain = 'https://api.immutable.com';
|
|
11090
|
-
this.zkEvmRpcUrl = ''; // TODO: ID-785 Update once mainnet has been deployed
|
|
11091
|
-
this.zkEvmChainId = ''; // TODO: ID-785 Update once mainnet has been deployed
|
|
11092
|
-
this.relayerUrl = 'https://api.immutable.com/relayer-mr';
|
|
11093
|
-
this.multiRollupConfig = multiRollupConfig.getProduction();
|
|
11094
7693
|
break;
|
|
11095
7694
|
}
|
|
11096
7695
|
case Environment$1.SANDBOX:
|
|
@@ -11101,10 +7700,6 @@ class PassportConfiguration {
|
|
|
11101
7700
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
11102
7701
|
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
11103
7702
|
this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
|
|
11104
|
-
this.zkEvmRpcUrl = 'https://zkevm-rpc.sandbox.x.immutable.com';
|
|
11105
|
-
this.zkEvmChainId = 'eip155:13392';
|
|
11106
|
-
this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
|
|
11107
|
-
this.multiRollupConfig = multiRollupConfig.getSandbox();
|
|
11108
7703
|
break;
|
|
11109
7704
|
}
|
|
11110
7705
|
}
|
|
@@ -11265,537 +7860,6 @@ class ConfirmationScreen {
|
|
|
11265
7860
|
}
|
|
11266
7861
|
}
|
|
11267
7862
|
|
|
11268
|
-
var RelayerTransactionStatus;
|
|
11269
|
-
(function (RelayerTransactionStatus) {
|
|
11270
|
-
RelayerTransactionStatus["PENDING"] = "PENDING";
|
|
11271
|
-
RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
|
|
11272
|
-
RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
11273
|
-
RelayerTransactionStatus["REVERTED"] = "REVERTED";
|
|
11274
|
-
RelayerTransactionStatus["FAILED"] = "FAILED";
|
|
11275
|
-
})(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
|
|
11276
|
-
var ProviderEvent;
|
|
11277
|
-
(function (ProviderEvent) {
|
|
11278
|
-
ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
|
|
11279
|
-
})(ProviderEvent || (ProviderEvent = {}));
|
|
11280
|
-
|
|
11281
|
-
class TypedEventEmitter {
|
|
11282
|
-
emitter = new EventEmitter();
|
|
11283
|
-
emit(eventName, ...eventArg) {
|
|
11284
|
-
this.emitter.emit(eventName, ...eventArg);
|
|
11285
|
-
}
|
|
11286
|
-
on(eventName, handler) {
|
|
11287
|
-
this.emitter.on(eventName, handler);
|
|
11288
|
-
}
|
|
11289
|
-
removeListener(eventName, handler) {
|
|
11290
|
-
this.emitter.removeListener(eventName, handler);
|
|
11291
|
-
}
|
|
11292
|
-
}
|
|
11293
|
-
|
|
11294
|
-
class RelayerClient {
|
|
11295
|
-
config;
|
|
11296
|
-
constructor({ config }) {
|
|
11297
|
-
this.config = config;
|
|
11298
|
-
}
|
|
11299
|
-
async postToRelayer(request) {
|
|
11300
|
-
const body = {
|
|
11301
|
-
id: 1,
|
|
11302
|
-
jsonrpc: '2.0',
|
|
11303
|
-
...request,
|
|
11304
|
-
};
|
|
11305
|
-
const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
|
|
11306
|
-
method: 'POST',
|
|
11307
|
-
headers: {
|
|
11308
|
-
'Content-Type': 'application/json',
|
|
11309
|
-
},
|
|
11310
|
-
body: JSON.stringify(body),
|
|
11311
|
-
});
|
|
11312
|
-
const jsonResponse = await response.json();
|
|
11313
|
-
if (jsonResponse.error) {
|
|
11314
|
-
throw jsonResponse.error;
|
|
11315
|
-
}
|
|
11316
|
-
return jsonResponse;
|
|
11317
|
-
}
|
|
11318
|
-
async ethSendTransaction(to, data) {
|
|
11319
|
-
const payload = {
|
|
11320
|
-
method: 'eth_sendTransaction',
|
|
11321
|
-
params: [{
|
|
11322
|
-
to,
|
|
11323
|
-
data,
|
|
11324
|
-
chainId: this.config.zkEvmChainId.toString(),
|
|
11325
|
-
}],
|
|
11326
|
-
};
|
|
11327
|
-
const { result } = await this.postToRelayer(payload);
|
|
11328
|
-
return result;
|
|
11329
|
-
}
|
|
11330
|
-
async imGetTransactionByHash(hash) {
|
|
11331
|
-
const payload = {
|
|
11332
|
-
method: 'im_getTransactionByHash',
|
|
11333
|
-
params: [hash],
|
|
11334
|
-
};
|
|
11335
|
-
const { result } = await this.postToRelayer(payload);
|
|
11336
|
-
return result;
|
|
11337
|
-
}
|
|
11338
|
-
async imGetFeeOptions(userAddress, data) {
|
|
11339
|
-
const payload = {
|
|
11340
|
-
method: 'im_getFeeOptions',
|
|
11341
|
-
params: [{
|
|
11342
|
-
userAddress,
|
|
11343
|
-
data,
|
|
11344
|
-
chainId: this.config.zkEvmChainId.toString(),
|
|
11345
|
-
}],
|
|
11346
|
-
};
|
|
11347
|
-
const { result } = await this.postToRelayer(payload);
|
|
11348
|
-
return result;
|
|
11349
|
-
}
|
|
11350
|
-
}
|
|
11351
|
-
|
|
11352
|
-
/**
|
|
11353
|
-
* ProviderErrors should take priority over RpcErrorCodes
|
|
11354
|
-
*/
|
|
11355
|
-
var ProviderErrorCode;
|
|
11356
|
-
(function (ProviderErrorCode) {
|
|
11357
|
-
ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
11358
|
-
ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
|
|
11359
|
-
ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
|
|
11360
|
-
ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
|
|
11361
|
-
})(ProviderErrorCode || (ProviderErrorCode = {}));
|
|
11362
|
-
var RpcErrorCode;
|
|
11363
|
-
(function (RpcErrorCode) {
|
|
11364
|
-
RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
|
|
11365
|
-
RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
11366
|
-
RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
11367
|
-
RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
11368
|
-
RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
11369
|
-
RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
11370
|
-
})(RpcErrorCode || (RpcErrorCode = {}));
|
|
11371
|
-
class JsonRpcError extends Error {
|
|
11372
|
-
message;
|
|
11373
|
-
code;
|
|
11374
|
-
constructor(code, message) {
|
|
11375
|
-
super(message);
|
|
11376
|
-
this.message = message;
|
|
11377
|
-
this.code = code;
|
|
11378
|
-
}
|
|
11379
|
-
}
|
|
11380
|
-
|
|
11381
|
-
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
11382
|
-
async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
|
|
11383
|
-
const web3Provider = new Web3Provider(magicProvider);
|
|
11384
|
-
const ethSigner = web3Provider.getSigner();
|
|
11385
|
-
const ethereumAddress = await ethSigner.getAddress();
|
|
11386
|
-
const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
|
|
11387
|
-
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
11388
|
-
try {
|
|
11389
|
-
await multiRollupApiClients.passportApi.createCounterfactualAddress({
|
|
11390
|
-
createCounterfactualAddressRequest: {
|
|
11391
|
-
ethereumAddress,
|
|
11392
|
-
ethereumSignature,
|
|
11393
|
-
},
|
|
11394
|
-
}, { headers });
|
|
11395
|
-
}
|
|
11396
|
-
catch (error) {
|
|
11397
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
|
|
11398
|
-
}
|
|
11399
|
-
const user = await authManager.loginSilent();
|
|
11400
|
-
if (!user?.zkEvm) {
|
|
11401
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
|
|
11402
|
-
}
|
|
11403
|
-
return user;
|
|
11404
|
-
}
|
|
11405
|
-
|
|
11406
|
-
const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
|
|
11407
|
-
const user = await authManager.getUser() || await authManager.login();
|
|
11408
|
-
if (!user.idToken) {
|
|
11409
|
-
throw new Error('User is missing idToken');
|
|
11410
|
-
}
|
|
11411
|
-
const magicProvider = await magicAdapter.login(user.idToken, config.network);
|
|
11412
|
-
if (!user.zkEvm) {
|
|
11413
|
-
// Generate counterfactual address and retrieve updated Auth0 user
|
|
11414
|
-
const userZkevm = await registerZkEvmUser({
|
|
11415
|
-
authManager,
|
|
11416
|
-
magicProvider,
|
|
11417
|
-
multiRollupApiClients,
|
|
11418
|
-
accessToken: user.accessToken,
|
|
11419
|
-
});
|
|
11420
|
-
return {
|
|
11421
|
-
user: userZkevm,
|
|
11422
|
-
magicProvider,
|
|
11423
|
-
};
|
|
11424
|
-
}
|
|
11425
|
-
return {
|
|
11426
|
-
user: user,
|
|
11427
|
-
magicProvider,
|
|
11428
|
-
};
|
|
11429
|
-
};
|
|
11430
|
-
|
|
11431
|
-
// These are ignored by the Relayer but for consistency we set them to the
|
|
11432
|
-
// appropriate values for a 1/1 wallet.
|
|
11433
|
-
//
|
|
11434
|
-
// Weight of a single signature in the multisig
|
|
11435
|
-
const SIGNATURE_WEIGHT = 1;
|
|
11436
|
-
// Total required weight in the multisig
|
|
11437
|
-
const SIGNATURE_THRESHOLD = 1;
|
|
11438
|
-
const ETH_SIGN_FLAG = '02';
|
|
11439
|
-
const ETH_SIGN_PREFIX = '\x19\x01';
|
|
11440
|
-
const META_TRANSACTIONS_TYPE = `tuple(
|
|
11441
|
-
bool delegateCall,
|
|
11442
|
-
bool revertOnError,
|
|
11443
|
-
uint256 gasLimit,
|
|
11444
|
-
address target,
|
|
11445
|
-
uint256 value,
|
|
11446
|
-
bytes data
|
|
11447
|
-
)[]`;
|
|
11448
|
-
function getNormalisedTransactions(txs) {
|
|
11449
|
-
return txs.map((t) => ({
|
|
11450
|
-
delegateCall: t.delegateCall === true,
|
|
11451
|
-
revertOnError: t.revertOnError === true,
|
|
11452
|
-
gasLimit: t.gasLimit ?? ethers.constants.Zero,
|
|
11453
|
-
target: t.to ?? ethers.constants.AddressZero,
|
|
11454
|
-
value: t.value ?? ethers.constants.Zero,
|
|
11455
|
-
data: t.data ?? [],
|
|
11456
|
-
}));
|
|
11457
|
-
}
|
|
11458
|
-
function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
|
|
11459
|
-
const packMetaTransactionsNonceData = ethers.utils.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
|
|
11460
|
-
return ethers.utils.keccak256(packMetaTransactionsNonceData);
|
|
11461
|
-
}
|
|
11462
|
-
const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
|
|
11463
|
-
const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress, 'latest']);
|
|
11464
|
-
if (code && code !== '0x') {
|
|
11465
|
-
const contract = new ethers.Contract(smartContractWalletAddress, walletContracts.mainModule.abi, jsonRpcProvider);
|
|
11466
|
-
return contract.nonce();
|
|
11467
|
-
}
|
|
11468
|
-
return 0;
|
|
11469
|
-
};
|
|
11470
|
-
const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
|
|
11471
|
-
const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
|
|
11472
|
-
// Get the hash
|
|
11473
|
-
const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
|
|
11474
|
-
const completePayload = ethers.utils.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]);
|
|
11475
|
-
const hash = ethers.utils.keccak256(completePayload);
|
|
11476
|
-
// Sign the digest
|
|
11477
|
-
const hashArray = ethers.utils.arrayify(hash);
|
|
11478
|
-
const ethsigNoType = await signer.signMessage(hashArray);
|
|
11479
|
-
const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
|
|
11480
|
-
// Add metadata
|
|
11481
|
-
const encodedSignature = encodeSignature({
|
|
11482
|
-
threshold: SIGNATURE_THRESHOLD,
|
|
11483
|
-
signers: [
|
|
11484
|
-
{
|
|
11485
|
-
weight: SIGNATURE_WEIGHT,
|
|
11486
|
-
signature: signedDigest,
|
|
11487
|
-
},
|
|
11488
|
-
],
|
|
11489
|
-
});
|
|
11490
|
-
// Encode the transaction;
|
|
11491
|
-
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
11492
|
-
return walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
|
|
11493
|
-
normalisedMetaTransactions,
|
|
11494
|
-
nonce,
|
|
11495
|
-
encodedSignature,
|
|
11496
|
-
]);
|
|
11497
|
-
};
|
|
11498
|
-
const chainIdNumber = (chainId) => {
|
|
11499
|
-
const caip2Components = chainId.split(':');
|
|
11500
|
-
if (caip2Components.length !== 2) {
|
|
11501
|
-
throw new Error('Invalid configuration, chain ID is not in CAIP-2 format');
|
|
11502
|
-
}
|
|
11503
|
-
return BigNumber$1.from(caip2Components[1]);
|
|
11504
|
-
};
|
|
11505
|
-
|
|
11506
|
-
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
11507
|
-
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
11508
|
-
const converBigNumberishToNumber = (value) => BigNumber$1.from(value).toNumber();
|
|
11509
|
-
const transformGardianTransactions = (txs) => {
|
|
11510
|
-
try {
|
|
11511
|
-
return txs.map((t) => ({
|
|
11512
|
-
delegateCall: t.delegateCall === true,
|
|
11513
|
-
revertOnError: t.revertOnError === true,
|
|
11514
|
-
gasLimit: t.gasLimit ? converBigNumberishToNumber(t.gasLimit).toString() : '0',
|
|
11515
|
-
target: t.to ?? ethers.constants.AddressZero,
|
|
11516
|
-
value: t.value ? converBigNumberishToNumber(t.value).toString() : '0',
|
|
11517
|
-
data: t.data ? t.data.toString() : '0x00',
|
|
11518
|
-
}));
|
|
11519
|
-
}
|
|
11520
|
-
catch (error) {
|
|
11521
|
-
const errorMessage = (error instanceof Error) ? error.message : String(error);
|
|
11522
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
|
|
11523
|
-
}
|
|
11524
|
-
};
|
|
11525
|
-
const guardianValidation = async ({ transactionAPI, chainId, nonce, user, metaTransactions, }) => {
|
|
11526
|
-
const headers = { Authorization: `Bearer ${user.accessToken}` };
|
|
11527
|
-
const guardianTransactions = transformGardianTransactions(metaTransactions);
|
|
11528
|
-
try {
|
|
11529
|
-
await transactionAPI.evaluateTransaction({
|
|
11530
|
-
id: 'evm',
|
|
11531
|
-
transactionEvaluationRequest: {
|
|
11532
|
-
chainType: 'evm',
|
|
11533
|
-
chainId,
|
|
11534
|
-
transactionData: {
|
|
11535
|
-
nonce,
|
|
11536
|
-
userAddress: user.zkEvm.ethAddress,
|
|
11537
|
-
metaTransactions: guardianTransactions,
|
|
11538
|
-
},
|
|
11539
|
-
},
|
|
11540
|
-
}, { headers });
|
|
11541
|
-
}
|
|
11542
|
-
catch (error) {
|
|
11543
|
-
const errorMessage = (error instanceof Error) ? error.message : String(error);
|
|
11544
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
|
|
11545
|
-
}
|
|
11546
|
-
};
|
|
11547
|
-
const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, transactionAPI, config, user, }) => {
|
|
11548
|
-
const transactionRequest = params[0];
|
|
11549
|
-
if (!transactionRequest.to) {
|
|
11550
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
11551
|
-
}
|
|
11552
|
-
const chainId = chainIdNumber(config.zkEvmChainId);
|
|
11553
|
-
const magicWeb3Provider = new Web3Provider(magicProvider);
|
|
11554
|
-
const signer = magicWeb3Provider.getSigner();
|
|
11555
|
-
const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
|
|
11556
|
-
const metaTransaction = {
|
|
11557
|
-
to: transactionRequest.to,
|
|
11558
|
-
data: transactionRequest.data,
|
|
11559
|
-
nonce,
|
|
11560
|
-
value: transactionRequest.value,
|
|
11561
|
-
revertOnError: true,
|
|
11562
|
-
};
|
|
11563
|
-
// NOTE: We sign the transaction before getting the fee options because
|
|
11564
|
-
// accurate estimation of a transaction gas cost is only possible if the smart
|
|
11565
|
-
// wallet contract can actually execute it (in a simulated environment) - and
|
|
11566
|
-
// it can only execute signed transactions.
|
|
11567
|
-
const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
|
|
11568
|
-
// TODO: ID-698 Add support for non-native gas payments (e.g ERC20, feeTransaction initialisation must change)
|
|
11569
|
-
// NOTE: "Fee Options" represent the multiple ways we could pay for the gas
|
|
11570
|
-
// used in this transaction. Each fee option has a "recipientAddress" we
|
|
11571
|
-
// should transfer the payment to, an amount and a currency. We choose one
|
|
11572
|
-
// option and build a transaction that sends the expected currency amount for
|
|
11573
|
-
// that option to the specified address.
|
|
11574
|
-
const feeOptions = await relayerClient.imGetFeeOptions(user.zkEvm.ethAddress, signedTransaction);
|
|
11575
|
-
const imxFeeOption = feeOptions.find((feeOption) => feeOption.tokenSymbol === 'IMX');
|
|
11576
|
-
if (!imxFeeOption) {
|
|
11577
|
-
throw new Error('Failed to retrieve fees for IMX token');
|
|
11578
|
-
}
|
|
11579
|
-
const feeMetaTransaction = {
|
|
11580
|
-
nonce,
|
|
11581
|
-
to: imxFeeOption.recipientAddress,
|
|
11582
|
-
value: imxFeeOption.tokenPrice,
|
|
11583
|
-
revertOnError: true,
|
|
11584
|
-
};
|
|
11585
|
-
await guardianValidation({
|
|
11586
|
-
transactionAPI,
|
|
11587
|
-
chainId: config.zkEvmChainId,
|
|
11588
|
-
nonce: converBigNumberishToNumber(nonce),
|
|
11589
|
-
user,
|
|
11590
|
-
metaTransactions: [metaTransaction, feeMetaTransaction],
|
|
11591
|
-
});
|
|
11592
|
-
// NOTE: We sign again because we now are adding the fee transaction, so the
|
|
11593
|
-
// whole payload is different and needs a new signature.
|
|
11594
|
-
const signedTransactions = await getSignedMetaTransactions([metaTransaction, feeMetaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
|
|
11595
|
-
// TODO: ID-697 Evaluate transactions through Guardian
|
|
11596
|
-
const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
|
|
11597
|
-
const retrieveRelayerTransaction = async () => {
|
|
11598
|
-
const tx = await relayerClient.imGetTransactionByHash(relayerId);
|
|
11599
|
-
// NOTE: The transaction hash is only available from the Relayer once the
|
|
11600
|
-
// transaction is actually submitted onchain. Hence we need to poll the
|
|
11601
|
-
// Relayer get transaction endpoint until the status transitions to one that
|
|
11602
|
-
// has the hash available.
|
|
11603
|
-
if (tx.status === RelayerTransactionStatus.PENDING) {
|
|
11604
|
-
throw new Error();
|
|
11605
|
-
}
|
|
11606
|
-
return tx;
|
|
11607
|
-
};
|
|
11608
|
-
const relayerTransaction = await retryWithDelay(retrieveRelayerTransaction, {
|
|
11609
|
-
retries: MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES,
|
|
11610
|
-
interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
|
|
11611
|
-
finalErr: new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
|
|
11612
|
-
});
|
|
11613
|
-
if (![RelayerTransactionStatus.SUBMITTED, RelayerTransactionStatus.SUCCESSFUL].includes(relayerTransaction.status)) {
|
|
11614
|
-
throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
|
|
11615
|
-
}
|
|
11616
|
-
return relayerTransaction.hash;
|
|
11617
|
-
};
|
|
11618
|
-
|
|
11619
|
-
class ZkEvmProvider {
|
|
11620
|
-
authManager;
|
|
11621
|
-
config;
|
|
11622
|
-
confirmationScreen;
|
|
11623
|
-
magicAdapter;
|
|
11624
|
-
relayerClient;
|
|
11625
|
-
transactionAPI;
|
|
11626
|
-
multiRollupApiClients;
|
|
11627
|
-
jsonRpcProvider; // Used for read
|
|
11628
|
-
eventEmitter;
|
|
11629
|
-
magicProvider; // Used for signing
|
|
11630
|
-
user;
|
|
11631
|
-
constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
|
|
11632
|
-
this.authManager = authManager;
|
|
11633
|
-
this.magicAdapter = magicAdapter;
|
|
11634
|
-
this.config = config;
|
|
11635
|
-
this.confirmationScreen = confirmationScreen;
|
|
11636
|
-
this.relayerClient = new RelayerClient({ config });
|
|
11637
|
-
this.transactionAPI = new TransactionsApi(new Configuration({
|
|
11638
|
-
basePath: this.config.imxPublicApiDomain,
|
|
11639
|
-
}));
|
|
11640
|
-
this.jsonRpcProvider = new JsonRpcProvider(this.config.zkEvmRpcUrl);
|
|
11641
|
-
this.multiRollupApiClients = multiRollupApiClients;
|
|
11642
|
-
this.eventEmitter = new TypedEventEmitter();
|
|
11643
|
-
}
|
|
11644
|
-
isLoggedIn() {
|
|
11645
|
-
return this.magicProvider !== undefined && this.user !== undefined;
|
|
11646
|
-
}
|
|
11647
|
-
async performRequest(request) {
|
|
11648
|
-
switch (request.method) {
|
|
11649
|
-
case 'eth_requestAccounts': {
|
|
11650
|
-
if (this.isLoggedIn()) {
|
|
11651
|
-
return [this.user.zkEvm.ethAddress];
|
|
11652
|
-
}
|
|
11653
|
-
const { magicProvider, user } = await loginZkEvmUser({
|
|
11654
|
-
authManager: this.authManager,
|
|
11655
|
-
config: this.config,
|
|
11656
|
-
magicAdapter: this.magicAdapter,
|
|
11657
|
-
multiRollupApiClients: this.multiRollupApiClients,
|
|
11658
|
-
});
|
|
11659
|
-
this.user = user;
|
|
11660
|
-
this.magicProvider = magicProvider;
|
|
11661
|
-
this.eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
|
|
11662
|
-
return [this.user.zkEvm.ethAddress];
|
|
11663
|
-
}
|
|
11664
|
-
case 'eth_sendTransaction': {
|
|
11665
|
-
if (!this.isLoggedIn()) {
|
|
11666
|
-
throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
11667
|
-
}
|
|
11668
|
-
return sendTransaction({
|
|
11669
|
-
params: request.params || [],
|
|
11670
|
-
magicProvider: this.magicProvider,
|
|
11671
|
-
transactionAPI: this.transactionAPI,
|
|
11672
|
-
jsonRpcProvider: this.jsonRpcProvider,
|
|
11673
|
-
config: this.config,
|
|
11674
|
-
relayerClient: this.relayerClient,
|
|
11675
|
-
user: this.user,
|
|
11676
|
-
});
|
|
11677
|
-
}
|
|
11678
|
-
case 'eth_accounts': {
|
|
11679
|
-
return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
|
|
11680
|
-
}
|
|
11681
|
-
// Pass through methods
|
|
11682
|
-
case 'eth_gasPrice':
|
|
11683
|
-
case 'eth_getBalance':
|
|
11684
|
-
case 'eth_getStorageAt':
|
|
11685
|
-
case 'eth_estimateGas':
|
|
11686
|
-
case 'eth_call':
|
|
11687
|
-
case 'eth_blockNumber':
|
|
11688
|
-
case 'eth_chainId':
|
|
11689
|
-
case 'eth_getBlockByHash':
|
|
11690
|
-
case 'eth_getBlockByNumber':
|
|
11691
|
-
case 'eth_getTransactionByHash':
|
|
11692
|
-
case 'eth_getTransactionReceipt':
|
|
11693
|
-
case 'eth_getTransactionCount': {
|
|
11694
|
-
return this.jsonRpcProvider.send(request.method, request.params || []);
|
|
11695
|
-
}
|
|
11696
|
-
default: {
|
|
11697
|
-
throw new JsonRpcError(ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
|
|
11698
|
-
}
|
|
11699
|
-
}
|
|
11700
|
-
}
|
|
11701
|
-
async performJsonRpcRequest(request) {
|
|
11702
|
-
const { id, jsonrpc } = request;
|
|
11703
|
-
try {
|
|
11704
|
-
const result = await this.performRequest(request);
|
|
11705
|
-
return {
|
|
11706
|
-
id,
|
|
11707
|
-
jsonrpc,
|
|
11708
|
-
result,
|
|
11709
|
-
};
|
|
11710
|
-
}
|
|
11711
|
-
catch (error) {
|
|
11712
|
-
let jsonRpcError;
|
|
11713
|
-
if (error instanceof JsonRpcError) {
|
|
11714
|
-
jsonRpcError = error;
|
|
11715
|
-
}
|
|
11716
|
-
else if (error instanceof Error) {
|
|
11717
|
-
jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11718
|
-
}
|
|
11719
|
-
else {
|
|
11720
|
-
jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11721
|
-
}
|
|
11722
|
-
return {
|
|
11723
|
-
id,
|
|
11724
|
-
jsonrpc,
|
|
11725
|
-
error: jsonRpcError,
|
|
11726
|
-
};
|
|
11727
|
-
}
|
|
11728
|
-
}
|
|
11729
|
-
async request(request) {
|
|
11730
|
-
try {
|
|
11731
|
-
return this.performRequest(request);
|
|
11732
|
-
}
|
|
11733
|
-
catch (error) {
|
|
11734
|
-
if (error instanceof JsonRpcError) {
|
|
11735
|
-
throw error;
|
|
11736
|
-
}
|
|
11737
|
-
if (error instanceof Error) {
|
|
11738
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11739
|
-
}
|
|
11740
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11741
|
-
}
|
|
11742
|
-
}
|
|
11743
|
-
sendAsync(request, callback) {
|
|
11744
|
-
if (!callback) {
|
|
11745
|
-
throw new Error('No callback provided');
|
|
11746
|
-
}
|
|
11747
|
-
if (Array.isArray(request)) {
|
|
11748
|
-
Promise.all(request.map(this.performJsonRpcRequest)).then((result) => {
|
|
11749
|
-
callback(null, result);
|
|
11750
|
-
}).catch((error) => {
|
|
11751
|
-
callback(error, []);
|
|
11752
|
-
});
|
|
11753
|
-
}
|
|
11754
|
-
else {
|
|
11755
|
-
this.performJsonRpcRequest(request).then((result) => {
|
|
11756
|
-
callback(null, result);
|
|
11757
|
-
}).catch((error) => {
|
|
11758
|
-
callback(error, null);
|
|
11759
|
-
});
|
|
11760
|
-
}
|
|
11761
|
-
}
|
|
11762
|
-
async send(request, callbackOrParams, callback) {
|
|
11763
|
-
// Web3 >= 1.0.0-beta.38 calls `send` with method and parameters.
|
|
11764
|
-
if (typeof request === 'string') {
|
|
11765
|
-
if (typeof callbackOrParams === 'function') {
|
|
11766
|
-
return this.sendAsync({
|
|
11767
|
-
method: request,
|
|
11768
|
-
params: [],
|
|
11769
|
-
}, callbackOrParams);
|
|
11770
|
-
}
|
|
11771
|
-
if (callback) {
|
|
11772
|
-
return this.sendAsync({
|
|
11773
|
-
method: request,
|
|
11774
|
-
params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
|
|
11775
|
-
}, callback);
|
|
11776
|
-
}
|
|
11777
|
-
return this.request({
|
|
11778
|
-
method: request,
|
|
11779
|
-
params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
|
|
11780
|
-
});
|
|
11781
|
-
}
|
|
11782
|
-
// Web3 <= 1.0.0-beta.37 uses `send` with a callback for async queries.
|
|
11783
|
-
if (typeof callbackOrParams === 'function') {
|
|
11784
|
-
return this.sendAsync(request, callbackOrParams);
|
|
11785
|
-
}
|
|
11786
|
-
if (!Array.isArray(request) && typeof request === 'object') {
|
|
11787
|
-
return this.performJsonRpcRequest(request);
|
|
11788
|
-
}
|
|
11789
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_REQUEST, 'Invalid request');
|
|
11790
|
-
}
|
|
11791
|
-
on(event, listener) {
|
|
11792
|
-
this.eventEmitter.on(event, listener);
|
|
11793
|
-
}
|
|
11794
|
-
removeListener(event, listener) {
|
|
11795
|
-
this.eventEmitter.removeListener(event, listener);
|
|
11796
|
-
}
|
|
11797
|
-
}
|
|
11798
|
-
|
|
11799
7863
|
class Passport {
|
|
11800
7864
|
authManager;
|
|
11801
7865
|
config;
|
|
@@ -11803,7 +7867,6 @@ class Passport {
|
|
|
11803
7867
|
immutableXClient;
|
|
11804
7868
|
magicAdapter;
|
|
11805
7869
|
passportImxProviderFactory;
|
|
11806
|
-
multiRollupApiClients;
|
|
11807
7870
|
constructor(passportModuleConfiguration) {
|
|
11808
7871
|
this.config = new PassportConfiguration(passportModuleConfiguration);
|
|
11809
7872
|
this.authManager = new AuthManager(this.config);
|
|
@@ -11813,7 +7876,6 @@ class Passport {
|
|
|
11813
7876
|
|| new ImmutableXClient({
|
|
11814
7877
|
baseConfig: passportModuleConfiguration.baseConfig,
|
|
11815
7878
|
});
|
|
11816
|
-
this.multiRollupApiClients = new MultiRollupApiClients(this.config.multiRollupConfig);
|
|
11817
7879
|
this.passportImxProviderFactory = new PassportImxProviderFactory({
|
|
11818
7880
|
authManager: this.authManager,
|
|
11819
7881
|
config: this.config,
|
|
@@ -11843,29 +7905,12 @@ class Passport {
|
|
|
11843
7905
|
async connectImxWithCredentials(tokenResponse) {
|
|
11844
7906
|
return this.passportImxProviderFactory.getProviderWithCredentials(tokenResponse);
|
|
11845
7907
|
}
|
|
11846
|
-
// TODO ID-926 Make method public once development has been finalised
|
|
11847
|
-
connectEvm() {
|
|
11848
|
-
return new ZkEvmProvider({
|
|
11849
|
-
authManager: this.authManager,
|
|
11850
|
-
magicAdapter: this.magicAdapter,
|
|
11851
|
-
config: this.config,
|
|
11852
|
-
confirmationScreen: this.confirmationScreen,
|
|
11853
|
-
multiRollupApiClients: this.multiRollupApiClients,
|
|
11854
|
-
});
|
|
11855
|
-
}
|
|
11856
7908
|
async loginCallback() {
|
|
11857
7909
|
return this.authManager.loginCallback();
|
|
11858
7910
|
}
|
|
11859
7911
|
async logout() {
|
|
11860
7912
|
return this.authManager.logout();
|
|
11861
7913
|
}
|
|
11862
|
-
/**
|
|
11863
|
-
* This method should only be called from the logout redirect uri
|
|
11864
|
-
* when logout mode is 'silent'.
|
|
11865
|
-
*/
|
|
11866
|
-
async logoutSilentCallback(url) {
|
|
11867
|
-
return this.authManager.logoutSilentCallback(url);
|
|
11868
|
-
}
|
|
11869
7914
|
async logoutDeviceFlow() {
|
|
11870
7915
|
return this.authManager.logoutDeviceFlow();
|
|
11871
7916
|
}
|
|
@@ -12166,7 +8211,7 @@ const getRequestBody = (options) => {
|
|
|
12166
8211
|
return undefined;
|
|
12167
8212
|
};
|
|
12168
8213
|
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
12169
|
-
const source =
|
|
8214
|
+
const source = globalAxios$1.CancelToken.source();
|
|
12170
8215
|
const requestConfig = {
|
|
12171
8216
|
url,
|
|
12172
8217
|
headers,
|
|
@@ -12177,7 +8222,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
|
|
|
12177
8222
|
};
|
|
12178
8223
|
onCancel(() => source.cancel('The user aborted a request.'));
|
|
12179
8224
|
try {
|
|
12180
|
-
return await
|
|
8225
|
+
return await globalAxios$1.request(requestConfig);
|
|
12181
8226
|
}
|
|
12182
8227
|
catch (error) {
|
|
12183
8228
|
const axiosError = error;
|
|
@@ -12782,25 +8827,31 @@ class ImmutableApiClientFactory {
|
|
|
12782
8827
|
}
|
|
12783
8828
|
}
|
|
12784
8829
|
|
|
8830
|
+
const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
|
|
12785
8831
|
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
12786
8832
|
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
12787
|
-
function getOrderbookConfig(
|
|
12788
|
-
switch (
|
|
12789
|
-
case
|
|
8833
|
+
function getOrderbookConfig(chainName) {
|
|
8834
|
+
switch (chainName) {
|
|
8835
|
+
case DEVNET_CHAIN_NAME:
|
|
8836
|
+
return {
|
|
8837
|
+
seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
|
|
8838
|
+
zoneContractAddress: '0xCb5063b0c1dcF4f7fed8E7eaa79faf9859792767',
|
|
8839
|
+
apiEndpoint: 'https://order-book-mr.dev.imtbl.com',
|
|
8840
|
+
provider: new providers.JsonRpcProvider('https://zkevm-rpc.dev.x.immutable.com'),
|
|
8841
|
+
};
|
|
8842
|
+
case TESTNET_CHAIN_NAME:
|
|
12790
8843
|
return {
|
|
12791
8844
|
seaportContractAddress: '0x45E23dA18804F99Cf67408AeBE85F67c958381Ff',
|
|
12792
8845
|
zoneContractAddress: '0x25b00b7eb97eab6194798E9B8eF63Aa526D5bd7E',
|
|
12793
8846
|
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
12794
|
-
chainName: TESTNET_CHAIN_NAME,
|
|
12795
8847
|
provider: new providers.JsonRpcProvider('https://zkevm-rpc.sandbox.x.immutable.com'),
|
|
12796
8848
|
};
|
|
12797
|
-
|
|
12798
|
-
|
|
8849
|
+
case MAINNET_CHAIN_NAME:
|
|
8850
|
+
// not yet deployed
|
|
12799
8851
|
return {
|
|
12800
8852
|
seaportContractAddress: '',
|
|
12801
8853
|
zoneContractAddress: '',
|
|
12802
8854
|
apiEndpoint: 'https://order-book-mr.imtbl.com',
|
|
12803
|
-
chainName: MAINNET_CHAIN_NAME,
|
|
12804
8855
|
provider: new providers.JsonRpcProvider('https://zkevm-rpc.x.immutable.com'),
|
|
12805
8856
|
};
|
|
12806
8857
|
default:
|
|
@@ -13713,7 +9764,7 @@ const _abi$3 = [
|
|
|
13713
9764
|
class ImmutableERC721Base__factory {
|
|
13714
9765
|
static abi = _abi$3;
|
|
13715
9766
|
static createInterface() {
|
|
13716
|
-
return new utils$
|
|
9767
|
+
return new utils$1.Interface(_abi$3);
|
|
13717
9768
|
}
|
|
13718
9769
|
static connect(address, signerOrProvider) {
|
|
13719
9770
|
return new Contract$1(address, _abi$3, signerOrProvider);
|
|
@@ -13759,19 +9810,21 @@ class Orderbook {
|
|
|
13759
9810
|
apiClient;
|
|
13760
9811
|
seaport;
|
|
13761
9812
|
orderbookConfig;
|
|
13762
|
-
constructor(config) {
|
|
13763
|
-
|
|
13764
|
-
const
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
}
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
}
|
|
13771
|
-
this.orderbookConfig = finalConfig;
|
|
13772
|
-
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
9813
|
+
constructor(config, localConfig) {
|
|
9814
|
+
// either use preconfigured config or local config passed in
|
|
9815
|
+
const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
|
|
9816
|
+
if (!maybeConfig) {
|
|
9817
|
+
throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
|
|
9818
|
+
}
|
|
9819
|
+
this.orderbookConfig = maybeConfig;
|
|
9820
|
+
const { apiEndpoint } = this.orderbookConfig;
|
|
13773
9821
|
if (!apiEndpoint) {
|
|
13774
|
-
throw new Error('API endpoint must be provided');
|
|
9822
|
+
throw new Error('API endpoint must be provided as an override');
|
|
9823
|
+
}
|
|
9824
|
+
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
9825
|
+
const chainName = config.overrides?.chainName;
|
|
9826
|
+
if (!chainName) {
|
|
9827
|
+
throw new Error('chainName must be provided as an override');
|
|
13775
9828
|
}
|
|
13776
9829
|
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
13777
9830
|
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
@@ -25106,7 +21159,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
|
|
|
25106
21159
|
/**
|
|
25107
21160
|
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
25108
21161
|
*/
|
|
25109
|
-
const ZKEVM_DEVNET_CHAIN_ID = 'eip155:
|
|
21162
|
+
const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
|
|
25110
21163
|
/**
|
|
25111
21164
|
/**
|
|
25112
21165
|
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
@@ -25164,8 +21217,8 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
|
|
|
25164
21217
|
*/
|
|
25165
21218
|
const CONTRACTS_FOR_BRIDGE = new Map()
|
|
25166
21219
|
.set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
|
|
25167
|
-
rootChainERC20Predicate: '
|
|
25168
|
-
rootChainStateSender: '
|
|
21220
|
+
rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
|
|
21221
|
+
rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
|
|
25169
21222
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
25170
21223
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
25171
21224
|
})
|
|
@@ -25592,7 +21645,7 @@ const _abi$2 = [
|
|
|
25592
21645
|
let ERC20__factory$1 = class ERC20__factory {
|
|
25593
21646
|
static abi = _abi$2;
|
|
25594
21647
|
static createInterface() {
|
|
25595
|
-
return new utils$
|
|
21648
|
+
return new utils$1.Interface(_abi$2);
|
|
25596
21649
|
}
|
|
25597
21650
|
static connect(address, signerOrProvider) {
|
|
25598
21651
|
return new Contract$1(address, _abi$2, signerOrProvider);
|
|
@@ -25960,7 +22013,7 @@ class Multicall__factory extends ContractFactory {
|
|
|
25960
22013
|
static bytecode = _bytecode$1$1;
|
|
25961
22014
|
static abi = _abi$1$1;
|
|
25962
22015
|
static createInterface() {
|
|
25963
|
-
return new utils$
|
|
22016
|
+
return new utils$1.Interface(_abi$1$1);
|
|
25964
22017
|
}
|
|
25965
22018
|
static connect(address, signerOrProvider) {
|
|
25966
22019
|
return new Contract$1(address, _abi$1$1, signerOrProvider);
|
|
@@ -26984,7 +23037,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
26984
23037
|
static bytecode = _bytecode;
|
|
26985
23038
|
static abi = _abi;
|
|
26986
23039
|
static createInterface() {
|
|
26987
|
-
return new utils$
|
|
23040
|
+
return new utils$1.Interface(_abi);
|
|
26988
23041
|
}
|
|
26989
23042
|
static connect(address, signerOrProvider) {
|
|
26990
23043
|
return new Contract$1(address, _abi, signerOrProvider);
|
|
@@ -27402,28 +23455,16 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
|
|
|
27402
23455
|
[Environment$1.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
|
|
27403
23456
|
};
|
|
27404
23457
|
function validateOverrides(overrides) {
|
|
27405
|
-
|
|
27406
|
-
|
|
27407
|
-
if (!overrides[key]) {
|
|
23458
|
+
Object.entries(overrides).forEach(([key, value]) => {
|
|
23459
|
+
if (!value) {
|
|
27408
23460
|
throw new InvalidConfigurationError(`Missing override: ${key}`);
|
|
27409
23461
|
}
|
|
27410
|
-
}
|
|
23462
|
+
});
|
|
27411
23463
|
Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
|
|
27412
23464
|
if (!isValidNonZeroAddress(contract)) {
|
|
27413
23465
|
throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
|
|
27414
23466
|
}
|
|
27415
23467
|
});
|
|
27416
|
-
if (!overrides.secondaryFees) {
|
|
27417
|
-
return;
|
|
27418
|
-
}
|
|
27419
|
-
for (const secondaryFee of overrides.secondaryFees) {
|
|
27420
|
-
if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
|
|
27421
|
-
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
|
|
27422
|
-
}
|
|
27423
|
-
if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
|
|
27424
|
-
throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
|
|
27425
|
-
}
|
|
27426
|
-
}
|
|
27427
23468
|
}
|
|
27428
23469
|
/**
|
|
27429
23470
|
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
@@ -27433,7 +23474,6 @@ function validateOverrides(overrides) {
|
|
|
27433
23474
|
class ExchangeConfiguration {
|
|
27434
23475
|
baseConfig;
|
|
27435
23476
|
chain;
|
|
27436
|
-
secondaryFees;
|
|
27437
23477
|
constructor({ chainId, baseConfig, overrides }) {
|
|
27438
23478
|
this.baseConfig = baseConfig;
|
|
27439
23479
|
if (overrides) {
|
|
@@ -27445,10 +23485,8 @@ class ExchangeConfiguration {
|
|
|
27445
23485
|
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
27446
23486
|
nativeToken: overrides.nativeToken,
|
|
27447
23487
|
};
|
|
27448
|
-
this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
|
|
27449
23488
|
return;
|
|
27450
23489
|
}
|
|
27451
|
-
this.secondaryFees = [];
|
|
27452
23490
|
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
27453
23491
|
if (!chain) {
|
|
27454
23492
|
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
@@ -27462,13 +23500,11 @@ class Exchange {
|
|
|
27462
23500
|
router;
|
|
27463
23501
|
chainId;
|
|
27464
23502
|
nativeToken;
|
|
27465
|
-
secondaryFees;
|
|
27466
23503
|
constructor(configuration) {
|
|
27467
23504
|
const config = new ExchangeConfiguration(configuration);
|
|
27468
23505
|
this.chainId = config.chain.chainId;
|
|
27469
23506
|
this.nativeToken = config.chain.nativeToken;
|
|
27470
23507
|
this.provider = new ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
27471
|
-
this.secondaryFees = config.secondaryFees;
|
|
27472
23508
|
this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
|
|
27473
23509
|
multicallAddress: config.chain.contracts.multicall,
|
|
27474
23510
|
factoryAddress: config.chain.contracts.coreFactory,
|
|
@@ -27551,9 +23587,6 @@ class Exchange {
|
|
|
27551
23587
|
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
27552
23588
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, TradeType.EXACT_OUTPUT);
|
|
27553
23589
|
}
|
|
27554
|
-
thereAreSecondaryFees() {
|
|
27555
|
-
return this.secondaryFees.length > 0;
|
|
27556
|
-
}
|
|
27557
23590
|
}
|
|
27558
23591
|
|
|
27559
23592
|
/* eslint-disable class-methods-use-this */
|
|
@@ -27630,8 +23663,8 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
27630
23663
|
*/ var $0472f23319457bfb$export$c06e1e7429de6283;
|
|
27631
23664
|
(function(ChainId) {
|
|
27632
23665
|
ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
|
|
27633
|
-
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] =
|
|
27634
|
-
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] =
|
|
23666
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13392] = "IMTBL_ZKEVM_TESTNET";
|
|
23667
|
+
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13403] = "IMTBL_ZKEVM_DEVNET";
|
|
27635
23668
|
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
27636
23669
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
27637
23670
|
})($0472f23319457bfb$export$c06e1e7429de6283 || ($0472f23319457bfb$export$c06e1e7429de6283 = {}));
|
|
@@ -27716,10 +23749,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
27716
23749
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
27717
23750
|
[(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
|
|
27718
23751
|
};
|
|
27719
|
-
const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
|
|
27720
|
-
[(Environment$1).SANDBOX]: "https://zkevm-rpc.sandbox.x.immutable.com",
|
|
27721
|
-
[(Environment$1).PRODUCTION]: "https://zkevm-rpc.x.immutable.com"
|
|
27722
|
-
};
|
|
27723
23752
|
const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
27724
23753
|
[
|
|
27725
23754
|
($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
|
|
@@ -27745,7 +23774,7 @@ const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
|
27745
23774
|
chainIdHex: `0x${($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET.toString(16)}`,
|
|
27746
23775
|
chainName: ($0472f23319457bfb$export$b874c6b1dfe85e02).IMTBL_ZKEVM_MAINNET,
|
|
27747
23776
|
rpcUrls: [
|
|
27748
|
-
"https://rpc.immutable.com"
|
|
23777
|
+
"https://zkevm-rpc.x.immutable.com"
|
|
27749
23778
|
],
|
|
27750
23779
|
nativeCurrency: {
|
|
27751
23780
|
name: "IMX",
|
|
@@ -27780,7 +23809,7 @@ const $d85ad1457a3f1a83$export$3e81fc0987227f10 = new Map([
|
|
|
27780
23809
|
chainIdHex: `0x${($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET.toString(16)}`,
|
|
27781
23810
|
chainName: ($0472f23319457bfb$export$b874c6b1dfe85e02).IMTBL_ZKEVM_TESTNET,
|
|
27782
23811
|
rpcUrls: [
|
|
27783
|
-
"https://rpc.
|
|
23812
|
+
"https://zkevm-rpc.sandbox.x.immutable.com"
|
|
27784
23813
|
],
|
|
27785
23814
|
nativeCurrency: {
|
|
27786
23815
|
name: "IMX",
|
|
@@ -28056,7 +24085,7 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, w
|
|
|
28056
24085
|
const balance = await web3Provider.getBalance(walletAddress);
|
|
28057
24086
|
return {
|
|
28058
24087
|
balance: balance,
|
|
28059
|
-
formattedBalance: (utils$
|
|
24088
|
+
formattedBalance: (utils$1).formatUnits(balance, networkInfo.nativeCurrency.decimals),
|
|
28060
24089
|
token: networkInfo.nativeCurrency
|
|
28061
24090
|
};
|
|
28062
24091
|
}, {
|
|
@@ -28069,7 +24098,7 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
|
|
|
28069
24098
|
const symbol = await contract.symbol();
|
|
28070
24099
|
const balance = await contract.balanceOf(walletAddress);
|
|
28071
24100
|
const decimals = await contract.decimals();
|
|
28072
|
-
const formattedBalance = (utils$
|
|
24101
|
+
const formattedBalance = (utils$1).formatUnits(balance, decimals);
|
|
28073
24102
|
return {
|
|
28074
24103
|
balance: balance,
|
|
28075
24104
|
formattedBalance: formattedBalance,
|
|
@@ -28156,19 +24185,16 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
|
|
|
28156
24185
|
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
28157
24186
|
return new (Web3Provider)(provider);
|
|
28158
24187
|
}
|
|
28159
|
-
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(
|
|
28160
|
-
let
|
|
28161
|
-
switch(
|
|
24188
|
+
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
|
|
24189
|
+
let web3Provider = null;
|
|
24190
|
+
switch(defaultProvider){
|
|
28162
24191
|
case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
|
|
28163
|
-
|
|
24192
|
+
web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
|
|
28164
24193
|
break;
|
|
28165
24194
|
default:
|
|
28166
24195
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
|
|
28167
24196
|
}
|
|
28168
|
-
return
|
|
28169
|
-
provider: provider,
|
|
28170
|
-
walletProviderName: walletProviderName
|
|
28171
|
-
};
|
|
24197
|
+
return web3Provider;
|
|
28172
24198
|
}
|
|
28173
24199
|
|
|
28174
24200
|
|
|
@@ -28177,8 +24203,9 @@ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
|
|
|
28177
24203
|
|
|
28178
24204
|
|
|
28179
24205
|
|
|
24206
|
+
|
|
28180
24207
|
function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
|
|
28181
|
-
if (web3Provider && web3Provider
|
|
24208
|
+
if (web3Provider && web3Provider instanceof (Web3Provider) && web3Provider.provider?.request) return true;
|
|
28182
24209
|
return false;
|
|
28183
24210
|
}
|
|
28184
24211
|
async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
|
|
@@ -28343,7 +24370,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
|
|
|
28343
24370
|
static async makeHttpRequest(url) {
|
|
28344
24371
|
let response;
|
|
28345
24372
|
try {
|
|
28346
|
-
response = await (0,
|
|
24373
|
+
response = await (0, globalAxios$1).get(url);
|
|
28347
24374
|
} catch (error) {
|
|
28348
24375
|
throw new Error(`Error fetching from api: ${error.message}`);
|
|
28349
24376
|
}
|
|
@@ -28388,23 +24415,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
|
|
|
28388
24415
|
this.message = message;
|
|
28389
24416
|
}
|
|
28390
24417
|
}
|
|
28391
|
-
const $4013c5c91bb535f6$var$networkMap = (prod, dev
|
|
28392
|
-
|
|
28393
|
-
if (
|
|
28394
|
-
|
|
28395
|
-
networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
|
|
28396
|
-
if (local) {
|
|
28397
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
|
|
28398
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).PRODUCTION]);
|
|
28399
|
-
}
|
|
28400
|
-
} else {
|
|
28401
|
-
networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
|
|
28402
|
-
if (local) {
|
|
28403
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
|
|
28404
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).SANDBOX]);
|
|
28405
|
-
}
|
|
28406
|
-
}
|
|
28407
|
-
return networks;
|
|
24418
|
+
const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
|
|
24419
|
+
if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
|
|
24420
|
+
if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
|
|
24421
|
+
return $d85ad1457a3f1a83$export$3e81fc0987227f10;
|
|
28408
24422
|
};
|
|
28409
24423
|
const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
|
|
28410
24424
|
// DevMode and Sandbox will both use Sepolia.
|
|
@@ -28422,11 +24436,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28422
24436
|
// This will be used to get around the lack of
|
|
28423
24437
|
// Environment.DEVELOPMENT
|
|
28424
24438
|
isDevelopment = false;
|
|
28425
|
-
// This is a hidden feature that is only available
|
|
28426
|
-
// when building the project from source code.
|
|
28427
|
-
// This will be used to get around the lack of
|
|
28428
|
-
// Environment.LOCAL_DEVELOPMENT
|
|
28429
|
-
isLocal = false;
|
|
28430
24439
|
isProduction;
|
|
28431
24440
|
remote;
|
|
28432
24441
|
environment;
|
|
@@ -28436,7 +24445,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28436
24445
|
this.environment = config.baseConfig.environment;
|
|
28437
24446
|
// Developer mode will super set any environment configuration
|
|
28438
24447
|
this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
|
|
28439
|
-
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment
|
|
24448
|
+
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
|
|
28440
24449
|
this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
|
|
28441
24450
|
isDevelopment: this.isDevelopment,
|
|
28442
24451
|
isProduction: this.isProduction
|
|
@@ -28500,7 +24509,7 @@ async function $2e7bf45a7c9a9570$var$swapGasEstimator(config) {
|
|
|
28500
24509
|
try {
|
|
28501
24510
|
const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
|
|
28502
24511
|
// Create a fake transaction to get the gas from the quote
|
|
28503
|
-
const { swap: swap } = await exchange.getUnsignedSwapTxFromAmountIn($2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS, inAddress, outAddress, (0, BigNumber$1).from((0, utils$
|
|
24512
|
+
const { swap: swap } = await exchange.getUnsignedSwapTxFromAmountIn($2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS, inAddress, outAddress, (0, BigNumber$1).from((0, utils$1).parseUnits("1", $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS)));
|
|
28504
24513
|
if (swap.gasFeeEstimate === null) return {
|
|
28505
24514
|
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).SWAP,
|
|
28506
24515
|
gasFee: {}
|
|
@@ -28582,7 +24591,10 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28582
24591
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
28583
24592
|
* @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
|
|
28584
24593
|
*/ async createProvider(params) {
|
|
28585
|
-
|
|
24594
|
+
const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
|
|
24595
|
+
return {
|
|
24596
|
+
provider: web3Provider
|
|
24597
|
+
};
|
|
28586
24598
|
}
|
|
28587
24599
|
/**
|
|
28588
24600
|
* Checks if a wallet is connected to the specified provider.
|
|
@@ -28699,7 +24711,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28699
24711
|
function $parcel$export(e, n, v, s) {
|
|
28700
24712
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28701
24713
|
}
|
|
28702
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha";
|
|
24714
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.2";
|
|
28703
24715
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28704
24716
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28705
24717
|
|
|
@@ -29285,7 +25297,7 @@ class ERC20__factory extends ContractFactory {
|
|
|
29285
25297
|
static bytecode = _bytecode$2;
|
|
29286
25298
|
static abi = _abi$4;
|
|
29287
25299
|
static createInterface() {
|
|
29288
|
-
return new utils$
|
|
25300
|
+
return new utils$1.Interface(_abi$4);
|
|
29289
25301
|
}
|
|
29290
25302
|
static connect(address, signerOrProvider) {
|
|
29291
25303
|
return new Contract$1(address, _abi$4, signerOrProvider);
|
|
@@ -30209,7 +26221,7 @@ class ImmutableERC721PermissionedMintable__factory extends ContractFactory {
|
|
|
30209
26221
|
static bytecode = _bytecode$1;
|
|
30210
26222
|
static abi = _abi$1;
|
|
30211
26223
|
static createInterface() {
|
|
30212
|
-
return new utils$
|
|
26224
|
+
return new utils$1.Interface(_abi$1);
|
|
30213
26225
|
}
|
|
30214
26226
|
static connect(address, signerOrProvider) {
|
|
30215
26227
|
return new Contract$1(address, _abi$1, signerOrProvider);
|
|
@@ -30498,4 +26510,4 @@ class ERC721PermissionedMintable {
|
|
|
30498
26510
|
}
|
|
30499
26511
|
}
|
|
30500
26512
|
|
|
30501
|
-
export { APIError, BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, ERC20, ERC721PermissionedMintable, Environment$1 as Environment, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient,
|
|
26513
|
+
export { APIError, BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, ERC20, ERC721PermissionedMintable, Environment$1 as Environment, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, MetaMaskIMXProvider, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, Networks, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, Orderbook, Passport, PassportError, ProviderConfiguration, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme, module };
|