@imtbl/sdk 0.4.0-alpha.2 → 0.4.1-alpha

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/index.cjs CHANGED
@@ -1,16 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var globalAxios$1 = require('axios');
3
+ var axios$2 = require('axios');
4
4
  var coreSdk = require('@imtbl/core-sdk');
5
5
  var oidcClientTs = require('oidc-client-ts');
6
6
  var jwt_decode = require('jwt-decode');
7
+ var crypto = require('crypto');
7
8
  var magicSdk = require('magic-sdk');
8
9
  var oidc = require('@magic-ext/oidc');
10
+ var ethers = require('ethers');
9
11
  var BN$2 = require('bn.js');
10
12
  var encUtils = require('enc-utils');
11
13
  var providers = require('@ethersproject/providers');
14
+ var events = require('events');
15
+ var abi = require('@0xsequence/abi');
16
+ var config = require('@0xsequence/config');
12
17
  var FormData$2 = require('form-data');
13
- var ethers = require('ethers');
14
18
  var seaportJs = require('@opensea/seaport-js');
15
19
  var units = require('@ethersproject/units');
16
20
  var bignumber = require('@ethersproject/bignumber');
@@ -24,38 +28,3335 @@ var routerSdk = require('@uniswap/router-sdk');
24
28
  var jsxRuntime = require('react/jsx-runtime');
25
29
  var react = require('react');
26
30
 
27
- function _interopNamespaceDefault(e) {
28
- var n = Object.create(null);
29
- if (e) {
30
- Object.keys(e).forEach(function (k) {
31
- if (k !== 'default') {
32
- var d = Object.getOwnPropertyDescriptor(e, k);
33
- Object.defineProperty(n, k, d.get ? d : {
34
- enumerable: true,
35
- get: function () { return e[k]; }
36
- });
37
- }
38
- });
39
- }
40
- n.default = e;
41
- return Object.freeze(n);
31
+ function _interopNamespaceDefault(e) {
32
+ var n = Object.create(null);
33
+ if (e) {
34
+ Object.keys(e).forEach(function (k) {
35
+ if (k !== 'default') {
36
+ var d = Object.getOwnPropertyDescriptor(e, k);
37
+ Object.defineProperty(n, k, d.get ? d : {
38
+ enumerable: true,
39
+ get: function () { return e[k]; }
40
+ });
41
+ }
42
+ });
43
+ }
44
+ n.default = e;
45
+ return Object.freeze(n);
46
+ }
47
+
48
+ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
49
+ var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
50
+
51
+ exports.Environment = void 0;
52
+ (function (Environment) {
53
+ Environment["PRODUCTION"] = "production";
54
+ Environment["SANDBOX"] = "sandbox";
55
+ })(exports.Environment || (exports.Environment = {}));
56
+ class ImmutableConfiguration {
57
+ environment;
58
+ apiKey;
59
+ constructor(options) {
60
+ this.environment = options.environment;
61
+ this.apiKey = options.apiKey;
62
+ }
63
+ }
64
+
65
+ function bind$1(fn, thisArg) {
66
+ return function wrap() {
67
+ return fn.apply(thisArg, arguments);
68
+ };
69
+ }
70
+
71
+ // utils is a library of generic helper functions non-specific to axios
72
+
73
+ const {toString: toString$1} = Object.prototype;
74
+ const {getPrototypeOf: getPrototypeOf$1} = Object;
75
+
76
+ const kindOf$1 = (cache => thing => {
77
+ const str = toString$1.call(thing);
78
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
79
+ })(Object.create(null));
80
+
81
+ const kindOfTest$1 = (type) => {
82
+ type = type.toLowerCase();
83
+ return (thing) => kindOf$1(thing) === type
84
+ };
85
+
86
+ const typeOfTest$1 = type => thing => typeof thing === type;
87
+
88
+ /**
89
+ * Determine if a value is an Array
90
+ *
91
+ * @param {Object} val The value to test
92
+ *
93
+ * @returns {boolean} True if value is an Array, otherwise false
94
+ */
95
+ const {isArray: isArray$1} = Array;
96
+
97
+ /**
98
+ * Determine if a value is undefined
99
+ *
100
+ * @param {*} val The value to test
101
+ *
102
+ * @returns {boolean} True if the value is undefined, otherwise false
103
+ */
104
+ const isUndefined$1 = typeOfTest$1('undefined');
105
+
106
+ /**
107
+ * Determine if a value is a Buffer
108
+ *
109
+ * @param {*} val The value to test
110
+ *
111
+ * @returns {boolean} True if value is a Buffer, otherwise false
112
+ */
113
+ function isBuffer$1(val) {
114
+ return val !== null && !isUndefined$1(val) && val.constructor !== null && !isUndefined$1(val.constructor)
115
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
116
+ }
117
+
118
+ /**
119
+ * Determine if a value is an ArrayBuffer
120
+ *
121
+ * @param {*} val The value to test
122
+ *
123
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
124
+ */
125
+ const isArrayBuffer$1 = kindOfTest$1('ArrayBuffer');
126
+
127
+
128
+ /**
129
+ * Determine if a value is a view on an ArrayBuffer
130
+ *
131
+ * @param {*} val The value to test
132
+ *
133
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
134
+ */
135
+ function isArrayBufferView$1(val) {
136
+ let result;
137
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
138
+ result = ArrayBuffer.isView(val);
139
+ } else {
140
+ result = (val) && (val.buffer) && (isArrayBuffer$1(val.buffer));
141
+ }
142
+ return result;
143
+ }
144
+
145
+ /**
146
+ * Determine if a value is a String
147
+ *
148
+ * @param {*} val The value to test
149
+ *
150
+ * @returns {boolean} True if value is a String, otherwise false
151
+ */
152
+ const isString$2 = typeOfTest$1('string');
153
+
154
+ /**
155
+ * Determine if a value is a Function
156
+ *
157
+ * @param {*} val The value to test
158
+ * @returns {boolean} True if value is a Function, otherwise false
159
+ */
160
+ const isFunction$1 = typeOfTest$1('function');
161
+
162
+ /**
163
+ * Determine if a value is a Number
164
+ *
165
+ * @param {*} val The value to test
166
+ *
167
+ * @returns {boolean} True if value is a Number, otherwise false
168
+ */
169
+ const isNumber$1 = typeOfTest$1('number');
170
+
171
+ /**
172
+ * Determine if a value is an Object
173
+ *
174
+ * @param {*} thing The value to test
175
+ *
176
+ * @returns {boolean} True if value is an Object, otherwise false
177
+ */
178
+ const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
179
+
180
+ /**
181
+ * Determine if a value is a Boolean
182
+ *
183
+ * @param {*} thing The value to test
184
+ * @returns {boolean} True if value is a Boolean, otherwise false
185
+ */
186
+ const isBoolean$1 = thing => thing === true || thing === false;
187
+
188
+ /**
189
+ * Determine if a value is a plain Object
190
+ *
191
+ * @param {*} val The value to test
192
+ *
193
+ * @returns {boolean} True if value is a plain Object, otherwise false
194
+ */
195
+ const isPlainObject$1 = (val) => {
196
+ if (kindOf$1(val) !== 'object') {
197
+ return false;
198
+ }
199
+
200
+ const prototype = getPrototypeOf$1(val);
201
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
202
+ };
203
+
204
+ /**
205
+ * Determine if a value is a Date
206
+ *
207
+ * @param {*} val The value to test
208
+ *
209
+ * @returns {boolean} True if value is a Date, otherwise false
210
+ */
211
+ const isDate$1 = kindOfTest$1('Date');
212
+
213
+ /**
214
+ * Determine if a value is a File
215
+ *
216
+ * @param {*} val The value to test
217
+ *
218
+ * @returns {boolean} True if value is a File, otherwise false
219
+ */
220
+ const isFile$1 = kindOfTest$1('File');
221
+
222
+ /**
223
+ * Determine if a value is a Blob
224
+ *
225
+ * @param {*} val The value to test
226
+ *
227
+ * @returns {boolean} True if value is a Blob, otherwise false
228
+ */
229
+ const isBlob$2 = kindOfTest$1('Blob');
230
+
231
+ /**
232
+ * Determine if a value is a FileList
233
+ *
234
+ * @param {*} val The value to test
235
+ *
236
+ * @returns {boolean} True if value is a File, otherwise false
237
+ */
238
+ const isFileList$1 = kindOfTest$1('FileList');
239
+
240
+ /**
241
+ * Determine if a value is a Stream
242
+ *
243
+ * @param {*} val The value to test
244
+ *
245
+ * @returns {boolean} True if value is a Stream, otherwise false
246
+ */
247
+ const isStream$1 = (val) => isObject$1(val) && isFunction$1(val.pipe);
248
+
249
+ /**
250
+ * Determine if a value is a FormData
251
+ *
252
+ * @param {*} thing The value to test
253
+ *
254
+ * @returns {boolean} True if value is an FormData, otherwise false
255
+ */
256
+ const isFormData$2 = (thing) => {
257
+ let kind;
258
+ return thing && (
259
+ (typeof FormData === 'function' && thing instanceof FormData) || (
260
+ isFunction$1(thing.append) && (
261
+ (kind = kindOf$1(thing)) === 'formdata' ||
262
+ // detect form-data instance
263
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
264
+ )
265
+ )
266
+ )
267
+ };
268
+
269
+ /**
270
+ * Determine if a value is a URLSearchParams object
271
+ *
272
+ * @param {*} val The value to test
273
+ *
274
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
275
+ */
276
+ const isURLSearchParams$1 = kindOfTest$1('URLSearchParams');
277
+
278
+ /**
279
+ * Trim excess whitespace off the beginning and end of a string
280
+ *
281
+ * @param {String} str The String to trim
282
+ *
283
+ * @returns {String} The String freed of excess whitespace
284
+ */
285
+ const trim$1 = (str) => str.trim ?
286
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
287
+
288
+ /**
289
+ * Iterate over an Array or an Object invoking a function for each item.
290
+ *
291
+ * If `obj` is an Array callback will be called passing
292
+ * the value, index, and complete array for each item.
293
+ *
294
+ * If 'obj' is an Object callback will be called passing
295
+ * the value, key, and complete object for each property.
296
+ *
297
+ * @param {Object|Array} obj The object to iterate
298
+ * @param {Function} fn The callback to invoke for each item
299
+ *
300
+ * @param {Boolean} [allOwnKeys = false]
301
+ * @returns {any}
302
+ */
303
+ function forEach$1(obj, fn, {allOwnKeys = false} = {}) {
304
+ // Don't bother if no value provided
305
+ if (obj === null || typeof obj === 'undefined') {
306
+ return;
307
+ }
308
+
309
+ let i;
310
+ let l;
311
+
312
+ // Force an array if not already something iterable
313
+ if (typeof obj !== 'object') {
314
+ /*eslint no-param-reassign:0*/
315
+ obj = [obj];
316
+ }
317
+
318
+ if (isArray$1(obj)) {
319
+ // Iterate over array values
320
+ for (i = 0, l = obj.length; i < l; i++) {
321
+ fn.call(null, obj[i], i, obj);
322
+ }
323
+ } else {
324
+ // Iterate over object keys
325
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
326
+ const len = keys.length;
327
+ let key;
328
+
329
+ for (i = 0; i < len; i++) {
330
+ key = keys[i];
331
+ fn.call(null, obj[key], key, obj);
332
+ }
333
+ }
334
+ }
335
+
336
+ function findKey$1(obj, key) {
337
+ key = key.toLowerCase();
338
+ const keys = Object.keys(obj);
339
+ let i = keys.length;
340
+ let _key;
341
+ while (i-- > 0) {
342
+ _key = keys[i];
343
+ if (key === _key.toLowerCase()) {
344
+ return _key;
345
+ }
346
+ }
347
+ return null;
348
+ }
349
+
350
+ const _global$1 = (() => {
351
+ /*eslint no-undef:0*/
352
+ if (typeof globalThis !== "undefined") return globalThis;
353
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
354
+ })();
355
+
356
+ const isContextDefined$1 = (context) => !isUndefined$1(context) && context !== _global$1;
357
+
358
+ /**
359
+ * Accepts varargs expecting each argument to be an object, then
360
+ * immutably merges the properties of each object and returns result.
361
+ *
362
+ * When multiple objects contain the same key the later object in
363
+ * the arguments list will take precedence.
364
+ *
365
+ * Example:
366
+ *
367
+ * ```js
368
+ * var result = merge({foo: 123}, {foo: 456});
369
+ * console.log(result.foo); // outputs 456
370
+ * ```
371
+ *
372
+ * @param {Object} obj1 Object to merge
373
+ *
374
+ * @returns {Object} Result of all merge properties
375
+ */
376
+ function merge$1(/* obj1, obj2, obj3, ... */) {
377
+ const {caseless} = isContextDefined$1(this) && this || {};
378
+ const result = {};
379
+ const assignValue = (val, key) => {
380
+ const targetKey = caseless && findKey$1(result, key) || key;
381
+ if (isPlainObject$1(result[targetKey]) && isPlainObject$1(val)) {
382
+ result[targetKey] = merge$1(result[targetKey], val);
383
+ } else if (isPlainObject$1(val)) {
384
+ result[targetKey] = merge$1({}, val);
385
+ } else if (isArray$1(val)) {
386
+ result[targetKey] = val.slice();
387
+ } else {
388
+ result[targetKey] = val;
389
+ }
390
+ };
391
+
392
+ for (let i = 0, l = arguments.length; i < l; i++) {
393
+ arguments[i] && forEach$1(arguments[i], assignValue);
394
+ }
395
+ return result;
396
+ }
397
+
398
+ /**
399
+ * Extends object a by mutably adding to it the properties of object b.
400
+ *
401
+ * @param {Object} a The object to be extended
402
+ * @param {Object} b The object to copy properties from
403
+ * @param {Object} thisArg The object to bind function to
404
+ *
405
+ * @param {Boolean} [allOwnKeys]
406
+ * @returns {Object} The resulting value of object a
407
+ */
408
+ const extend$1 = (a, b, thisArg, {allOwnKeys}= {}) => {
409
+ forEach$1(b, (val, key) => {
410
+ if (thisArg && isFunction$1(val)) {
411
+ a[key] = bind$1(val, thisArg);
412
+ } else {
413
+ a[key] = val;
414
+ }
415
+ }, {allOwnKeys});
416
+ return a;
417
+ };
418
+
419
+ /**
420
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
421
+ *
422
+ * @param {string} content with BOM
423
+ *
424
+ * @returns {string} content value without BOM
425
+ */
426
+ const stripBOM$1 = (content) => {
427
+ if (content.charCodeAt(0) === 0xFEFF) {
428
+ content = content.slice(1);
429
+ }
430
+ return content;
431
+ };
432
+
433
+ /**
434
+ * Inherit the prototype methods from one constructor into another
435
+ * @param {function} constructor
436
+ * @param {function} superConstructor
437
+ * @param {object} [props]
438
+ * @param {object} [descriptors]
439
+ *
440
+ * @returns {void}
441
+ */
442
+ const inherits$1 = (constructor, superConstructor, props, descriptors) => {
443
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
444
+ constructor.prototype.constructor = constructor;
445
+ Object.defineProperty(constructor, 'super', {
446
+ value: superConstructor.prototype
447
+ });
448
+ props && Object.assign(constructor.prototype, props);
449
+ };
450
+
451
+ /**
452
+ * Resolve object with deep prototype chain to a flat object
453
+ * @param {Object} sourceObj source object
454
+ * @param {Object} [destObj]
455
+ * @param {Function|Boolean} [filter]
456
+ * @param {Function} [propFilter]
457
+ *
458
+ * @returns {Object}
459
+ */
460
+ const toFlatObject$1 = (sourceObj, destObj, filter, propFilter) => {
461
+ let props;
462
+ let i;
463
+ let prop;
464
+ const merged = {};
465
+
466
+ destObj = destObj || {};
467
+ // eslint-disable-next-line no-eq-null,eqeqeq
468
+ if (sourceObj == null) return destObj;
469
+
470
+ do {
471
+ props = Object.getOwnPropertyNames(sourceObj);
472
+ i = props.length;
473
+ while (i-- > 0) {
474
+ prop = props[i];
475
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
476
+ destObj[prop] = sourceObj[prop];
477
+ merged[prop] = true;
478
+ }
479
+ }
480
+ sourceObj = filter !== false && getPrototypeOf$1(sourceObj);
481
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
482
+
483
+ return destObj;
484
+ };
485
+
486
+ /**
487
+ * Determines whether a string ends with the characters of a specified string
488
+ *
489
+ * @param {String} str
490
+ * @param {String} searchString
491
+ * @param {Number} [position= 0]
492
+ *
493
+ * @returns {boolean}
494
+ */
495
+ const endsWith$1 = (str, searchString, position) => {
496
+ str = String(str);
497
+ if (position === undefined || position > str.length) {
498
+ position = str.length;
499
+ }
500
+ position -= searchString.length;
501
+ const lastIndex = str.indexOf(searchString, position);
502
+ return lastIndex !== -1 && lastIndex === position;
503
+ };
504
+
505
+
506
+ /**
507
+ * Returns new array from array like object or null if failed
508
+ *
509
+ * @param {*} [thing]
510
+ *
511
+ * @returns {?Array}
512
+ */
513
+ const toArray$1 = (thing) => {
514
+ if (!thing) return null;
515
+ if (isArray$1(thing)) return thing;
516
+ let i = thing.length;
517
+ if (!isNumber$1(i)) return null;
518
+ const arr = new Array(i);
519
+ while (i-- > 0) {
520
+ arr[i] = thing[i];
521
+ }
522
+ return arr;
523
+ };
524
+
525
+ /**
526
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
527
+ * thing passed in is an instance of Uint8Array
528
+ *
529
+ * @param {TypedArray}
530
+ *
531
+ * @returns {Array}
532
+ */
533
+ // eslint-disable-next-line func-names
534
+ const isTypedArray$1 = (TypedArray => {
535
+ // eslint-disable-next-line func-names
536
+ return thing => {
537
+ return TypedArray && thing instanceof TypedArray;
538
+ };
539
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf$1(Uint8Array));
540
+
541
+ /**
542
+ * For each entry in the object, call the function with the key and value.
543
+ *
544
+ * @param {Object<any, any>} obj - The object to iterate over.
545
+ * @param {Function} fn - The function to call for each entry.
546
+ *
547
+ * @returns {void}
548
+ */
549
+ const forEachEntry$1 = (obj, fn) => {
550
+ const generator = obj && obj[Symbol.iterator];
551
+
552
+ const iterator = generator.call(obj);
553
+
554
+ let result;
555
+
556
+ while ((result = iterator.next()) && !result.done) {
557
+ const pair = result.value;
558
+ fn.call(obj, pair[0], pair[1]);
559
+ }
560
+ };
561
+
562
+ /**
563
+ * It takes a regular expression and a string, and returns an array of all the matches
564
+ *
565
+ * @param {string} regExp - The regular expression to match against.
566
+ * @param {string} str - The string to search.
567
+ *
568
+ * @returns {Array<boolean>}
569
+ */
570
+ const matchAll$1 = (regExp, str) => {
571
+ let matches;
572
+ const arr = [];
573
+
574
+ while ((matches = regExp.exec(str)) !== null) {
575
+ arr.push(matches);
576
+ }
577
+
578
+ return arr;
579
+ };
580
+
581
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
582
+ const isHTMLForm$1 = kindOfTest$1('HTMLFormElement');
583
+
584
+ const toCamelCase$1 = str => {
585
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
586
+ function replacer(m, p1, p2) {
587
+ return p1.toUpperCase() + p2;
588
+ }
589
+ );
590
+ };
591
+
592
+ /* Creating a function that will check if an object has a property. */
593
+ const hasOwnProperty$1 = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
594
+
595
+ /**
596
+ * Determine if a value is a RegExp object
597
+ *
598
+ * @param {*} val The value to test
599
+ *
600
+ * @returns {boolean} True if value is a RegExp object, otherwise false
601
+ */
602
+ const isRegExp$1 = kindOfTest$1('RegExp');
603
+
604
+ const reduceDescriptors$1 = (obj, reducer) => {
605
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
606
+ const reducedDescriptors = {};
607
+
608
+ forEach$1(descriptors, (descriptor, name) => {
609
+ if (reducer(descriptor, name, obj) !== false) {
610
+ reducedDescriptors[name] = descriptor;
611
+ }
612
+ });
613
+
614
+ Object.defineProperties(obj, reducedDescriptors);
615
+ };
616
+
617
+ /**
618
+ * Makes all methods read-only
619
+ * @param {Object} obj
620
+ */
621
+
622
+ const freezeMethods$1 = (obj) => {
623
+ reduceDescriptors$1(obj, (descriptor, name) => {
624
+ // skip restricted props in strict mode
625
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
626
+ return false;
627
+ }
628
+
629
+ const value = obj[name];
630
+
631
+ if (!isFunction$1(value)) return;
632
+
633
+ descriptor.enumerable = false;
634
+
635
+ if ('writable' in descriptor) {
636
+ descriptor.writable = false;
637
+ return;
638
+ }
639
+
640
+ if (!descriptor.set) {
641
+ descriptor.set = () => {
642
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
643
+ };
644
+ }
645
+ });
646
+ };
647
+
648
+ const toObjectSet$1 = (arrayOrString, delimiter) => {
649
+ const obj = {};
650
+
651
+ const define = (arr) => {
652
+ arr.forEach(value => {
653
+ obj[value] = true;
654
+ });
655
+ };
656
+
657
+ isArray$1(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
658
+
659
+ return obj;
660
+ };
661
+
662
+ const noop$1 = () => {};
663
+
664
+ const toFiniteNumber$1 = (value, defaultValue) => {
665
+ value = +value;
666
+ return Number.isFinite(value) ? value : defaultValue;
667
+ };
668
+
669
+ const ALPHA$1 = 'abcdefghijklmnopqrstuvwxyz';
670
+
671
+ const DIGIT$1 = '0123456789';
672
+
673
+ const ALPHABET$1 = {
674
+ DIGIT: DIGIT$1,
675
+ ALPHA: ALPHA$1,
676
+ ALPHA_DIGIT: ALPHA$1 + ALPHA$1.toUpperCase() + DIGIT$1
677
+ };
678
+
679
+ const generateString$1 = (size = 16, alphabet = ALPHABET$1.ALPHA_DIGIT) => {
680
+ let str = '';
681
+ const {length} = alphabet;
682
+ while (size--) {
683
+ str += alphabet[Math.random() * length|0];
684
+ }
685
+
686
+ return str;
687
+ };
688
+
689
+ /**
690
+ * If the thing is a FormData object, return true, otherwise return false.
691
+ *
692
+ * @param {unknown} thing - The thing to check.
693
+ *
694
+ * @returns {boolean}
695
+ */
696
+ function isSpecCompliantForm$1(thing) {
697
+ return !!(thing && isFunction$1(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
698
+ }
699
+
700
+ const toJSONObject$1 = (obj) => {
701
+ const stack = new Array(10);
702
+
703
+ const visit = (source, i) => {
704
+
705
+ if (isObject$1(source)) {
706
+ if (stack.indexOf(source) >= 0) {
707
+ return;
708
+ }
709
+
710
+ if(!('toJSON' in source)) {
711
+ stack[i] = source;
712
+ const target = isArray$1(source) ? [] : {};
713
+
714
+ forEach$1(source, (value, key) => {
715
+ const reducedValue = visit(value, i + 1);
716
+ !isUndefined$1(reducedValue) && (target[key] = reducedValue);
717
+ });
718
+
719
+ stack[i] = undefined;
720
+
721
+ return target;
722
+ }
723
+ }
724
+
725
+ return source;
726
+ };
727
+
728
+ return visit(obj, 0);
729
+ };
730
+
731
+ const isAsyncFn$1 = kindOfTest$1('AsyncFunction');
732
+
733
+ const isThenable$1 = (thing) =>
734
+ thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
735
+
736
+ var utils$1 = {
737
+ isArray: isArray$1,
738
+ isArrayBuffer: isArrayBuffer$1,
739
+ isBuffer: isBuffer$1,
740
+ isFormData: isFormData$2,
741
+ isArrayBufferView: isArrayBufferView$1,
742
+ isString: isString$2,
743
+ isNumber: isNumber$1,
744
+ isBoolean: isBoolean$1,
745
+ isObject: isObject$1,
746
+ isPlainObject: isPlainObject$1,
747
+ isUndefined: isUndefined$1,
748
+ isDate: isDate$1,
749
+ isFile: isFile$1,
750
+ isBlob: isBlob$2,
751
+ isRegExp: isRegExp$1,
752
+ isFunction: isFunction$1,
753
+ isStream: isStream$1,
754
+ isURLSearchParams: isURLSearchParams$1,
755
+ isTypedArray: isTypedArray$1,
756
+ isFileList: isFileList$1,
757
+ forEach: forEach$1,
758
+ merge: merge$1,
759
+ extend: extend$1,
760
+ trim: trim$1,
761
+ stripBOM: stripBOM$1,
762
+ inherits: inherits$1,
763
+ toFlatObject: toFlatObject$1,
764
+ kindOf: kindOf$1,
765
+ kindOfTest: kindOfTest$1,
766
+ endsWith: endsWith$1,
767
+ toArray: toArray$1,
768
+ forEachEntry: forEachEntry$1,
769
+ matchAll: matchAll$1,
770
+ isHTMLForm: isHTMLForm$1,
771
+ hasOwnProperty: hasOwnProperty$1,
772
+ hasOwnProp: hasOwnProperty$1, // an alias to avoid ESLint no-prototype-builtins detection
773
+ reduceDescriptors: reduceDescriptors$1,
774
+ freezeMethods: freezeMethods$1,
775
+ toObjectSet: toObjectSet$1,
776
+ toCamelCase: toCamelCase$1,
777
+ noop: noop$1,
778
+ toFiniteNumber: toFiniteNumber$1,
779
+ findKey: findKey$1,
780
+ global: _global$1,
781
+ isContextDefined: isContextDefined$1,
782
+ ALPHABET: ALPHABET$1,
783
+ generateString: generateString$1,
784
+ isSpecCompliantForm: isSpecCompliantForm$1,
785
+ toJSONObject: toJSONObject$1,
786
+ isAsyncFn: isAsyncFn$1,
787
+ isThenable: isThenable$1
788
+ };
789
+
790
+ /**
791
+ * Create an Error with the specified message, config, error code, request and response.
792
+ *
793
+ * @param {string} message The error message.
794
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
795
+ * @param {Object} [config] The config.
796
+ * @param {Object} [request] The request.
797
+ * @param {Object} [response] The response.
798
+ *
799
+ * @returns {Error} The created error.
800
+ */
801
+ function AxiosError$1(message, code, config, request, response) {
802
+ Error.call(this);
803
+
804
+ if (Error.captureStackTrace) {
805
+ Error.captureStackTrace(this, this.constructor);
806
+ } else {
807
+ this.stack = (new Error()).stack;
808
+ }
809
+
810
+ this.message = message;
811
+ this.name = 'AxiosError';
812
+ code && (this.code = code);
813
+ config && (this.config = config);
814
+ request && (this.request = request);
815
+ response && (this.response = response);
816
+ }
817
+
818
+ utils$1.inherits(AxiosError$1, Error, {
819
+ toJSON: function toJSON() {
820
+ return {
821
+ // Standard
822
+ message: this.message,
823
+ name: this.name,
824
+ // Microsoft
825
+ description: this.description,
826
+ number: this.number,
827
+ // Mozilla
828
+ fileName: this.fileName,
829
+ lineNumber: this.lineNumber,
830
+ columnNumber: this.columnNumber,
831
+ stack: this.stack,
832
+ // Axios
833
+ config: utils$1.toJSONObject(this.config),
834
+ code: this.code,
835
+ status: this.response && this.response.status ? this.response.status : null
836
+ };
837
+ }
838
+ });
839
+
840
+ const prototype$1$1 = AxiosError$1.prototype;
841
+ const descriptors$1 = {};
842
+
843
+ [
844
+ 'ERR_BAD_OPTION_VALUE',
845
+ 'ERR_BAD_OPTION',
846
+ 'ECONNABORTED',
847
+ 'ETIMEDOUT',
848
+ 'ERR_NETWORK',
849
+ 'ERR_FR_TOO_MANY_REDIRECTS',
850
+ 'ERR_DEPRECATED',
851
+ 'ERR_BAD_RESPONSE',
852
+ 'ERR_BAD_REQUEST',
853
+ 'ERR_CANCELED',
854
+ 'ERR_NOT_SUPPORT',
855
+ 'ERR_INVALID_URL'
856
+ // eslint-disable-next-line func-names
857
+ ].forEach(code => {
858
+ descriptors$1[code] = {value: code};
859
+ });
860
+
861
+ Object.defineProperties(AxiosError$1, descriptors$1);
862
+ Object.defineProperty(prototype$1$1, 'isAxiosError', {value: true});
863
+
864
+ // eslint-disable-next-line func-names
865
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
866
+ const axiosError = Object.create(prototype$1$1);
867
+
868
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
869
+ return obj !== Error.prototype;
870
+ }, prop => {
871
+ return prop !== 'isAxiosError';
872
+ });
873
+
874
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
875
+
876
+ axiosError.cause = error;
877
+
878
+ axiosError.name = error.name;
879
+
880
+ customProps && Object.assign(axiosError, customProps);
881
+
882
+ return axiosError;
883
+ };
884
+
885
+ // eslint-disable-next-line strict
886
+ var httpAdapter$1 = null;
887
+
888
+ /**
889
+ * Determines if the given thing is a array or js object.
890
+ *
891
+ * @param {string} thing - The object or array to be visited.
892
+ *
893
+ * @returns {boolean}
894
+ */
895
+ function isVisitable$1(thing) {
896
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
897
+ }
898
+
899
+ /**
900
+ * It removes the brackets from the end of a string
901
+ *
902
+ * @param {string} key - The key of the parameter.
903
+ *
904
+ * @returns {string} the key without the brackets.
905
+ */
906
+ function removeBrackets$1(key) {
907
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
908
+ }
909
+
910
+ /**
911
+ * It takes a path, a key, and a boolean, and returns a string
912
+ *
913
+ * @param {string} path - The path to the current key.
914
+ * @param {string} key - The key of the current object being iterated over.
915
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
916
+ *
917
+ * @returns {string} The path to the current key.
918
+ */
919
+ function renderKey$1(path, key, dots) {
920
+ if (!path) return key;
921
+ return path.concat(key).map(function each(token, i) {
922
+ // eslint-disable-next-line no-param-reassign
923
+ token = removeBrackets$1(token);
924
+ return !dots && i ? '[' + token + ']' : token;
925
+ }).join(dots ? '.' : '');
926
+ }
927
+
928
+ /**
929
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
930
+ *
931
+ * @param {Array<any>} arr - The array to check
932
+ *
933
+ * @returns {boolean}
934
+ */
935
+ function isFlatArray$1(arr) {
936
+ return utils$1.isArray(arr) && !arr.some(isVisitable$1);
937
+ }
938
+
939
+ const predicates$1 = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
940
+ return /^is[A-Z]/.test(prop);
941
+ });
942
+
943
+ /**
944
+ * Convert a data object to FormData
945
+ *
946
+ * @param {Object} obj
947
+ * @param {?Object} [formData]
948
+ * @param {?Object} [options]
949
+ * @param {Function} [options.visitor]
950
+ * @param {Boolean} [options.metaTokens = true]
951
+ * @param {Boolean} [options.dots = false]
952
+ * @param {?Boolean} [options.indexes = false]
953
+ *
954
+ * @returns {Object}
955
+ **/
956
+
957
+ /**
958
+ * It converts an object into a FormData object
959
+ *
960
+ * @param {Object<any, any>} obj - The object to convert to form data.
961
+ * @param {string} formData - The FormData object to append to.
962
+ * @param {Object<string, any>} options
963
+ *
964
+ * @returns
965
+ */
966
+ function toFormData$1(obj, formData, options) {
967
+ if (!utils$1.isObject(obj)) {
968
+ throw new TypeError('target must be an object');
969
+ }
970
+
971
+ // eslint-disable-next-line no-param-reassign
972
+ formData = formData || new (FormData)();
973
+
974
+ // eslint-disable-next-line no-param-reassign
975
+ options = utils$1.toFlatObject(options, {
976
+ metaTokens: true,
977
+ dots: false,
978
+ indexes: false
979
+ }, false, function defined(option, source) {
980
+ // eslint-disable-next-line no-eq-null,eqeqeq
981
+ return !utils$1.isUndefined(source[option]);
982
+ });
983
+
984
+ const metaTokens = options.metaTokens;
985
+ // eslint-disable-next-line no-use-before-define
986
+ const visitor = options.visitor || defaultVisitor;
987
+ const dots = options.dots;
988
+ const indexes = options.indexes;
989
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
990
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
991
+
992
+ if (!utils$1.isFunction(visitor)) {
993
+ throw new TypeError('visitor must be a function');
994
+ }
995
+
996
+ function convertValue(value) {
997
+ if (value === null) return '';
998
+
999
+ if (utils$1.isDate(value)) {
1000
+ return value.toISOString();
1001
+ }
1002
+
1003
+ if (!useBlob && utils$1.isBlob(value)) {
1004
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1005
+ }
1006
+
1007
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1008
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1009
+ }
1010
+
1011
+ return value;
1012
+ }
1013
+
1014
+ /**
1015
+ * Default visitor.
1016
+ *
1017
+ * @param {*} value
1018
+ * @param {String|Number} key
1019
+ * @param {Array<String|Number>} path
1020
+ * @this {FormData}
1021
+ *
1022
+ * @returns {boolean} return true to visit the each prop of the value recursively
1023
+ */
1024
+ function defaultVisitor(value, key, path) {
1025
+ let arr = value;
1026
+
1027
+ if (value && !path && typeof value === 'object') {
1028
+ if (utils$1.endsWith(key, '{}')) {
1029
+ // eslint-disable-next-line no-param-reassign
1030
+ key = metaTokens ? key : key.slice(0, -2);
1031
+ // eslint-disable-next-line no-param-reassign
1032
+ value = JSON.stringify(value);
1033
+ } else if (
1034
+ (utils$1.isArray(value) && isFlatArray$1(value)) ||
1035
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1036
+ )) {
1037
+ // eslint-disable-next-line no-param-reassign
1038
+ key = removeBrackets$1(key);
1039
+
1040
+ arr.forEach(function each(el, index) {
1041
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1042
+ // eslint-disable-next-line no-nested-ternary
1043
+ indexes === true ? renderKey$1([key], index, dots) : (indexes === null ? key : key + '[]'),
1044
+ convertValue(el)
1045
+ );
1046
+ });
1047
+ return false;
1048
+ }
1049
+ }
1050
+
1051
+ if (isVisitable$1(value)) {
1052
+ return true;
1053
+ }
1054
+
1055
+ formData.append(renderKey$1(path, key, dots), convertValue(value));
1056
+
1057
+ return false;
1058
+ }
1059
+
1060
+ const stack = [];
1061
+
1062
+ const exposedHelpers = Object.assign(predicates$1, {
1063
+ defaultVisitor,
1064
+ convertValue,
1065
+ isVisitable: isVisitable$1
1066
+ });
1067
+
1068
+ function build(value, path) {
1069
+ if (utils$1.isUndefined(value)) return;
1070
+
1071
+ if (stack.indexOf(value) !== -1) {
1072
+ throw Error('Circular reference detected in ' + path.join('.'));
1073
+ }
1074
+
1075
+ stack.push(value);
1076
+
1077
+ utils$1.forEach(value, function each(el, key) {
1078
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1079
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1080
+ );
1081
+
1082
+ if (result === true) {
1083
+ build(el, path ? path.concat(key) : [key]);
1084
+ }
1085
+ });
1086
+
1087
+ stack.pop();
1088
+ }
1089
+
1090
+ if (!utils$1.isObject(obj)) {
1091
+ throw new TypeError('data must be an object');
1092
+ }
1093
+
1094
+ build(obj);
1095
+
1096
+ return formData;
1097
+ }
1098
+
1099
+ /**
1100
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1101
+ * their percent-encoded equivalents
1102
+ *
1103
+ * @param {string} str - The string to encode.
1104
+ *
1105
+ * @returns {string} The encoded string.
1106
+ */
1107
+ function encode$1$1(str) {
1108
+ const charMap = {
1109
+ '!': '%21',
1110
+ "'": '%27',
1111
+ '(': '%28',
1112
+ ')': '%29',
1113
+ '~': '%7E',
1114
+ '%20': '+',
1115
+ '%00': '\x00'
1116
+ };
1117
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1118
+ return charMap[match];
1119
+ });
1120
+ }
1121
+
1122
+ /**
1123
+ * It takes a params object and converts it to a FormData object
1124
+ *
1125
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1126
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1127
+ *
1128
+ * @returns {void}
1129
+ */
1130
+ function AxiosURLSearchParams$1(params, options) {
1131
+ this._pairs = [];
1132
+
1133
+ params && toFormData$1(params, this, options);
1134
+ }
1135
+
1136
+ const prototype$2 = AxiosURLSearchParams$1.prototype;
1137
+
1138
+ prototype$2.append = function append(name, value) {
1139
+ this._pairs.push([name, value]);
1140
+ };
1141
+
1142
+ prototype$2.toString = function toString(encoder) {
1143
+ const _encode = encoder ? function(value) {
1144
+ return encoder.call(this, value, encode$1$1);
1145
+ } : encode$1$1;
1146
+
1147
+ return this._pairs.map(function each(pair) {
1148
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1149
+ }, '').join('&');
1150
+ };
1151
+
1152
+ /**
1153
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1154
+ * URI encoded counterparts
1155
+ *
1156
+ * @param {string} val The value to be encoded.
1157
+ *
1158
+ * @returns {string} The encoded value.
1159
+ */
1160
+ function encode$3(val) {
1161
+ return encodeURIComponent(val).
1162
+ replace(/%3A/gi, ':').
1163
+ replace(/%24/g, '$').
1164
+ replace(/%2C/gi, ',').
1165
+ replace(/%20/g, '+').
1166
+ replace(/%5B/gi, '[').
1167
+ replace(/%5D/gi, ']');
1168
+ }
1169
+
1170
+ /**
1171
+ * Build a URL by appending params to the end
1172
+ *
1173
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1174
+ * @param {object} [params] The params to be appended
1175
+ * @param {?object} options
1176
+ *
1177
+ * @returns {string} The formatted url
1178
+ */
1179
+ function buildURL$1(url, params, options) {
1180
+ /*eslint no-param-reassign:0*/
1181
+ if (!params) {
1182
+ return url;
1183
+ }
1184
+
1185
+ const _encode = options && options.encode || encode$3;
1186
+
1187
+ const serializeFn = options && options.serialize;
1188
+
1189
+ let serializedParams;
1190
+
1191
+ if (serializeFn) {
1192
+ serializedParams = serializeFn(params, options);
1193
+ } else {
1194
+ serializedParams = utils$1.isURLSearchParams(params) ?
1195
+ params.toString() :
1196
+ new AxiosURLSearchParams$1(params, options).toString(_encode);
1197
+ }
1198
+
1199
+ if (serializedParams) {
1200
+ const hashmarkIndex = url.indexOf("#");
1201
+
1202
+ if (hashmarkIndex !== -1) {
1203
+ url = url.slice(0, hashmarkIndex);
1204
+ }
1205
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1206
+ }
1207
+
1208
+ return url;
1209
+ }
1210
+
1211
+ let InterceptorManager$2 = class InterceptorManager {
1212
+ constructor() {
1213
+ this.handlers = [];
1214
+ }
1215
+
1216
+ /**
1217
+ * Add a new interceptor to the stack
1218
+ *
1219
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1220
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1221
+ *
1222
+ * @return {Number} An ID used to remove interceptor later
1223
+ */
1224
+ use(fulfilled, rejected, options) {
1225
+ this.handlers.push({
1226
+ fulfilled,
1227
+ rejected,
1228
+ synchronous: options ? options.synchronous : false,
1229
+ runWhen: options ? options.runWhen : null
1230
+ });
1231
+ return this.handlers.length - 1;
1232
+ }
1233
+
1234
+ /**
1235
+ * Remove an interceptor from the stack
1236
+ *
1237
+ * @param {Number} id The ID that was returned by `use`
1238
+ *
1239
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1240
+ */
1241
+ eject(id) {
1242
+ if (this.handlers[id]) {
1243
+ this.handlers[id] = null;
1244
+ }
1245
+ }
1246
+
1247
+ /**
1248
+ * Clear all interceptors from the stack
1249
+ *
1250
+ * @returns {void}
1251
+ */
1252
+ clear() {
1253
+ if (this.handlers) {
1254
+ this.handlers = [];
1255
+ }
1256
+ }
1257
+
1258
+ /**
1259
+ * Iterate over all the registered interceptors
1260
+ *
1261
+ * This method is particularly useful for skipping over any
1262
+ * interceptors that may have become `null` calling `eject`.
1263
+ *
1264
+ * @param {Function} fn The function to call for each interceptor
1265
+ *
1266
+ * @returns {void}
1267
+ */
1268
+ forEach(fn) {
1269
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1270
+ if (h !== null) {
1271
+ fn(h);
1272
+ }
1273
+ });
1274
+ }
1275
+ };
1276
+
1277
+ var InterceptorManager$1$1 = InterceptorManager$2;
1278
+
1279
+ var transitionalDefaults$1 = {
1280
+ silentJSONParsing: true,
1281
+ forcedJSONParsing: true,
1282
+ clarifyTimeoutError: false
1283
+ };
1284
+
1285
+ var URLSearchParams$1$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams$1;
1286
+
1287
+ var FormData$1$1 = typeof FormData !== 'undefined' ? FormData : null;
1288
+
1289
+ var Blob$1$1 = typeof Blob !== 'undefined' ? Blob : null;
1290
+
1291
+ /**
1292
+ * Determine if we're running in a standard browser environment
1293
+ *
1294
+ * This allows axios to run in a web worker, and react-native.
1295
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1296
+ *
1297
+ * web workers:
1298
+ * typeof window -> undefined
1299
+ * typeof document -> undefined
1300
+ *
1301
+ * react-native:
1302
+ * navigator.product -> 'ReactNative'
1303
+ * nativescript
1304
+ * navigator.product -> 'NativeScript' or 'NS'
1305
+ *
1306
+ * @returns {boolean}
1307
+ */
1308
+ const isStandardBrowserEnv$1 = (() => {
1309
+ let product;
1310
+ if (typeof navigator !== 'undefined' && (
1311
+ (product = navigator.product) === 'ReactNative' ||
1312
+ product === 'NativeScript' ||
1313
+ product === 'NS')
1314
+ ) {
1315
+ return false;
1316
+ }
1317
+
1318
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
1319
+ })();
1320
+
1321
+ /**
1322
+ * Determine if we're running in a standard browser webWorker environment
1323
+ *
1324
+ * Although the `isStandardBrowserEnv` method indicates that
1325
+ * `allows axios to run in a web worker`, the WebWorker will still be
1326
+ * filtered out due to its judgment standard
1327
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1328
+ * This leads to a problem when axios post `FormData` in webWorker
1329
+ */
1330
+ const isStandardBrowserWebWorkerEnv$1 = (() => {
1331
+ return (
1332
+ typeof WorkerGlobalScope !== 'undefined' &&
1333
+ // eslint-disable-next-line no-undef
1334
+ self instanceof WorkerGlobalScope &&
1335
+ typeof self.importScripts === 'function'
1336
+ );
1337
+ })();
1338
+
1339
+
1340
+ var platform$1 = {
1341
+ isBrowser: true,
1342
+ classes: {
1343
+ URLSearchParams: URLSearchParams$1$1,
1344
+ FormData: FormData$1$1,
1345
+ Blob: Blob$1$1
1346
+ },
1347
+ isStandardBrowserEnv: isStandardBrowserEnv$1,
1348
+ isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv$1,
1349
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1350
+ };
1351
+
1352
+ function toURLEncodedForm$1(data, options) {
1353
+ return toFormData$1(data, new platform$1.classes.URLSearchParams(), Object.assign({
1354
+ visitor: function(value, key, path, helpers) {
1355
+ if (platform$1.isNode && utils$1.isBuffer(value)) {
1356
+ this.append(key, value.toString('base64'));
1357
+ return false;
1358
+ }
1359
+
1360
+ return helpers.defaultVisitor.apply(this, arguments);
1361
+ }
1362
+ }, options));
1363
+ }
1364
+
1365
+ /**
1366
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1367
+ *
1368
+ * @param {string} name - The name of the property to get.
1369
+ *
1370
+ * @returns An array of strings.
1371
+ */
1372
+ function parsePropPath$1(name) {
1373
+ // foo[x][y][z]
1374
+ // foo.x.y.z
1375
+ // foo-x-y-z
1376
+ // foo x y z
1377
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1378
+ return match[0] === '[]' ? '' : match[1] || match[0];
1379
+ });
1380
+ }
1381
+
1382
+ /**
1383
+ * Convert an array to an object.
1384
+ *
1385
+ * @param {Array<any>} arr - The array to convert to an object.
1386
+ *
1387
+ * @returns An object with the same keys and values as the array.
1388
+ */
1389
+ function arrayToObject$1(arr) {
1390
+ const obj = {};
1391
+ const keys = Object.keys(arr);
1392
+ let i;
1393
+ const len = keys.length;
1394
+ let key;
1395
+ for (i = 0; i < len; i++) {
1396
+ key = keys[i];
1397
+ obj[key] = arr[key];
1398
+ }
1399
+ return obj;
1400
+ }
1401
+
1402
+ /**
1403
+ * It takes a FormData object and returns a JavaScript object
1404
+ *
1405
+ * @param {string} formData The FormData object to convert to JSON.
1406
+ *
1407
+ * @returns {Object<string, any> | null} The converted object.
1408
+ */
1409
+ function formDataToJSON$1(formData) {
1410
+ function buildPath(path, value, target, index) {
1411
+ let name = path[index++];
1412
+ const isNumericKey = Number.isFinite(+name);
1413
+ const isLast = index >= path.length;
1414
+ name = !name && utils$1.isArray(target) ? target.length : name;
1415
+
1416
+ if (isLast) {
1417
+ if (utils$1.hasOwnProp(target, name)) {
1418
+ target[name] = [target[name], value];
1419
+ } else {
1420
+ target[name] = value;
1421
+ }
1422
+
1423
+ return !isNumericKey;
1424
+ }
1425
+
1426
+ if (!target[name] || !utils$1.isObject(target[name])) {
1427
+ target[name] = [];
1428
+ }
1429
+
1430
+ const result = buildPath(path, value, target[name], index);
1431
+
1432
+ if (result && utils$1.isArray(target[name])) {
1433
+ target[name] = arrayToObject$1(target[name]);
1434
+ }
1435
+
1436
+ return !isNumericKey;
1437
+ }
1438
+
1439
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1440
+ const obj = {};
1441
+
1442
+ utils$1.forEachEntry(formData, (name, value) => {
1443
+ buildPath(parsePropPath$1(name), value, obj, 0);
1444
+ });
1445
+
1446
+ return obj;
1447
+ }
1448
+
1449
+ return null;
1450
+ }
1451
+
1452
+ const DEFAULT_CONTENT_TYPE$1 = {
1453
+ 'Content-Type': undefined
1454
+ };
1455
+
1456
+ /**
1457
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1458
+ * of the input
1459
+ *
1460
+ * @param {any} rawValue - The value to be stringified.
1461
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1462
+ * @param {Function} encoder - A function that takes a value and returns a string.
1463
+ *
1464
+ * @returns {string} A stringified version of the rawValue.
1465
+ */
1466
+ function stringifySafely$1(rawValue, parser, encoder) {
1467
+ if (utils$1.isString(rawValue)) {
1468
+ try {
1469
+ (parser || JSON.parse)(rawValue);
1470
+ return utils$1.trim(rawValue);
1471
+ } catch (e) {
1472
+ if (e.name !== 'SyntaxError') {
1473
+ throw e;
1474
+ }
1475
+ }
1476
+ }
1477
+
1478
+ return (encoder || JSON.stringify)(rawValue);
1479
+ }
1480
+
1481
+ const defaults$2 = {
1482
+
1483
+ transitional: transitionalDefaults$1,
1484
+
1485
+ adapter: ['xhr', 'http'],
1486
+
1487
+ transformRequest: [function transformRequest(data, headers) {
1488
+ const contentType = headers.getContentType() || '';
1489
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1490
+ const isObjectPayload = utils$1.isObject(data);
1491
+
1492
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1493
+ data = new FormData(data);
1494
+ }
1495
+
1496
+ const isFormData = utils$1.isFormData(data);
1497
+
1498
+ if (isFormData) {
1499
+ if (!hasJSONContentType) {
1500
+ return data;
1501
+ }
1502
+ return hasJSONContentType ? JSON.stringify(formDataToJSON$1(data)) : data;
1503
+ }
1504
+
1505
+ if (utils$1.isArrayBuffer(data) ||
1506
+ utils$1.isBuffer(data) ||
1507
+ utils$1.isStream(data) ||
1508
+ utils$1.isFile(data) ||
1509
+ utils$1.isBlob(data)
1510
+ ) {
1511
+ return data;
1512
+ }
1513
+ if (utils$1.isArrayBufferView(data)) {
1514
+ return data.buffer;
1515
+ }
1516
+ if (utils$1.isURLSearchParams(data)) {
1517
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1518
+ return data.toString();
1519
+ }
1520
+
1521
+ let isFileList;
1522
+
1523
+ if (isObjectPayload) {
1524
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1525
+ return toURLEncodedForm$1(data, this.formSerializer).toString();
1526
+ }
1527
+
1528
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1529
+ const _FormData = this.env && this.env.FormData;
1530
+
1531
+ return toFormData$1(
1532
+ isFileList ? {'files[]': data} : data,
1533
+ _FormData && new _FormData(),
1534
+ this.formSerializer
1535
+ );
1536
+ }
1537
+ }
1538
+
1539
+ if (isObjectPayload || hasJSONContentType ) {
1540
+ headers.setContentType('application/json', false);
1541
+ return stringifySafely$1(data);
1542
+ }
1543
+
1544
+ return data;
1545
+ }],
1546
+
1547
+ transformResponse: [function transformResponse(data) {
1548
+ const transitional = this.transitional || defaults$2.transitional;
1549
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1550
+ const JSONRequested = this.responseType === 'json';
1551
+
1552
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1553
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1554
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1555
+
1556
+ try {
1557
+ return JSON.parse(data);
1558
+ } catch (e) {
1559
+ if (strictJSONParsing) {
1560
+ if (e.name === 'SyntaxError') {
1561
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1562
+ }
1563
+ throw e;
1564
+ }
1565
+ }
1566
+ }
1567
+
1568
+ return data;
1569
+ }],
1570
+
1571
+ /**
1572
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1573
+ * timeout is not created.
1574
+ */
1575
+ timeout: 0,
1576
+
1577
+ xsrfCookieName: 'XSRF-TOKEN',
1578
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1579
+
1580
+ maxContentLength: -1,
1581
+ maxBodyLength: -1,
1582
+
1583
+ env: {
1584
+ FormData: platform$1.classes.FormData,
1585
+ Blob: platform$1.classes.Blob
1586
+ },
1587
+
1588
+ validateStatus: function validateStatus(status) {
1589
+ return status >= 200 && status < 300;
1590
+ },
1591
+
1592
+ headers: {
1593
+ common: {
1594
+ 'Accept': 'application/json, text/plain, */*'
1595
+ }
1596
+ }
1597
+ };
1598
+
1599
+ utils$1.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1600
+ defaults$2.headers[method] = {};
1601
+ });
1602
+
1603
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1604
+ defaults$2.headers[method] = utils$1.merge(DEFAULT_CONTENT_TYPE$1);
1605
+ });
1606
+
1607
+ var defaults$1$1 = defaults$2;
1608
+
1609
+ // RawAxiosHeaders whose duplicates are ignored by node
1610
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1611
+ const ignoreDuplicateOf$1 = utils$1.toObjectSet([
1612
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1613
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1614
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1615
+ 'referer', 'retry-after', 'user-agent'
1616
+ ]);
1617
+
1618
+ /**
1619
+ * Parse headers into an object
1620
+ *
1621
+ * ```
1622
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1623
+ * Content-Type: application/json
1624
+ * Connection: keep-alive
1625
+ * Transfer-Encoding: chunked
1626
+ * ```
1627
+ *
1628
+ * @param {String} rawHeaders Headers needing to be parsed
1629
+ *
1630
+ * @returns {Object} Headers parsed into an object
1631
+ */
1632
+ var parseHeaders$1 = rawHeaders => {
1633
+ const parsed = {};
1634
+ let key;
1635
+ let val;
1636
+ let i;
1637
+
1638
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1639
+ i = line.indexOf(':');
1640
+ key = line.substring(0, i).trim().toLowerCase();
1641
+ val = line.substring(i + 1).trim();
1642
+
1643
+ if (!key || (parsed[key] && ignoreDuplicateOf$1[key])) {
1644
+ return;
1645
+ }
1646
+
1647
+ if (key === 'set-cookie') {
1648
+ if (parsed[key]) {
1649
+ parsed[key].push(val);
1650
+ } else {
1651
+ parsed[key] = [val];
1652
+ }
1653
+ } else {
1654
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1655
+ }
1656
+ });
1657
+
1658
+ return parsed;
1659
+ };
1660
+
1661
+ const $internals$1 = Symbol('internals');
1662
+
1663
+ function normalizeHeader$1(header) {
1664
+ return header && String(header).trim().toLowerCase();
1665
+ }
1666
+
1667
+ function normalizeValue$1(value) {
1668
+ if (value === false || value == null) {
1669
+ return value;
1670
+ }
1671
+
1672
+ return utils$1.isArray(value) ? value.map(normalizeValue$1) : String(value);
1673
+ }
1674
+
1675
+ function parseTokens$1(str) {
1676
+ const tokens = Object.create(null);
1677
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1678
+ let match;
1679
+
1680
+ while ((match = tokensRE.exec(str))) {
1681
+ tokens[match[1]] = match[2];
1682
+ }
1683
+
1684
+ return tokens;
1685
+ }
1686
+
1687
+ const isValidHeaderName$1 = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1688
+
1689
+ function matchHeaderValue$1(context, value, header, filter, isHeaderNameFilter) {
1690
+ if (utils$1.isFunction(filter)) {
1691
+ return filter.call(this, value, header);
1692
+ }
1693
+
1694
+ if (isHeaderNameFilter) {
1695
+ value = header;
1696
+ }
1697
+
1698
+ if (!utils$1.isString(value)) return;
1699
+
1700
+ if (utils$1.isString(filter)) {
1701
+ return value.indexOf(filter) !== -1;
1702
+ }
1703
+
1704
+ if (utils$1.isRegExp(filter)) {
1705
+ return filter.test(value);
1706
+ }
1707
+ }
1708
+
1709
+ function formatHeader$1(header) {
1710
+ return header.trim()
1711
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1712
+ return char.toUpperCase() + str;
1713
+ });
1714
+ }
1715
+
1716
+ function buildAccessors$1(obj, header) {
1717
+ const accessorName = utils$1.toCamelCase(' ' + header);
1718
+
1719
+ ['get', 'set', 'has'].forEach(methodName => {
1720
+ Object.defineProperty(obj, methodName + accessorName, {
1721
+ value: function(arg1, arg2, arg3) {
1722
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1723
+ },
1724
+ configurable: true
1725
+ });
1726
+ });
1727
+ }
1728
+
1729
+ let AxiosHeaders$2 = class AxiosHeaders {
1730
+ constructor(headers) {
1731
+ headers && this.set(headers);
1732
+ }
1733
+
1734
+ set(header, valueOrRewrite, rewrite) {
1735
+ const self = this;
1736
+
1737
+ function setHeader(_value, _header, _rewrite) {
1738
+ const lHeader = normalizeHeader$1(_header);
1739
+
1740
+ if (!lHeader) {
1741
+ throw new Error('header name must be a non-empty string');
1742
+ }
1743
+
1744
+ const key = utils$1.findKey(self, lHeader);
1745
+
1746
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1747
+ self[key || _header] = normalizeValue$1(_value);
1748
+ }
1749
+ }
1750
+
1751
+ const setHeaders = (headers, _rewrite) =>
1752
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1753
+
1754
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1755
+ setHeaders(header, valueOrRewrite);
1756
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName$1(header)) {
1757
+ setHeaders(parseHeaders$1(header), valueOrRewrite);
1758
+ } else {
1759
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1760
+ }
1761
+
1762
+ return this;
1763
+ }
1764
+
1765
+ get(header, parser) {
1766
+ header = normalizeHeader$1(header);
1767
+
1768
+ if (header) {
1769
+ const key = utils$1.findKey(this, header);
1770
+
1771
+ if (key) {
1772
+ const value = this[key];
1773
+
1774
+ if (!parser) {
1775
+ return value;
1776
+ }
1777
+
1778
+ if (parser === true) {
1779
+ return parseTokens$1(value);
1780
+ }
1781
+
1782
+ if (utils$1.isFunction(parser)) {
1783
+ return parser.call(this, value, key);
1784
+ }
1785
+
1786
+ if (utils$1.isRegExp(parser)) {
1787
+ return parser.exec(value);
1788
+ }
1789
+
1790
+ throw new TypeError('parser must be boolean|regexp|function');
1791
+ }
1792
+ }
1793
+ }
1794
+
1795
+ has(header, matcher) {
1796
+ header = normalizeHeader$1(header);
1797
+
1798
+ if (header) {
1799
+ const key = utils$1.findKey(this, header);
1800
+
1801
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue$1(this, this[key], key, matcher)));
1802
+ }
1803
+
1804
+ return false;
1805
+ }
1806
+
1807
+ delete(header, matcher) {
1808
+ const self = this;
1809
+ let deleted = false;
1810
+
1811
+ function deleteHeader(_header) {
1812
+ _header = normalizeHeader$1(_header);
1813
+
1814
+ if (_header) {
1815
+ const key = utils$1.findKey(self, _header);
1816
+
1817
+ if (key && (!matcher || matchHeaderValue$1(self, self[key], key, matcher))) {
1818
+ delete self[key];
1819
+
1820
+ deleted = true;
1821
+ }
1822
+ }
1823
+ }
1824
+
1825
+ if (utils$1.isArray(header)) {
1826
+ header.forEach(deleteHeader);
1827
+ } else {
1828
+ deleteHeader(header);
1829
+ }
1830
+
1831
+ return deleted;
1832
+ }
1833
+
1834
+ clear(matcher) {
1835
+ const keys = Object.keys(this);
1836
+ let i = keys.length;
1837
+ let deleted = false;
1838
+
1839
+ while (i--) {
1840
+ const key = keys[i];
1841
+ if(!matcher || matchHeaderValue$1(this, this[key], key, matcher, true)) {
1842
+ delete this[key];
1843
+ deleted = true;
1844
+ }
1845
+ }
1846
+
1847
+ return deleted;
1848
+ }
1849
+
1850
+ normalize(format) {
1851
+ const self = this;
1852
+ const headers = {};
1853
+
1854
+ utils$1.forEach(this, (value, header) => {
1855
+ const key = utils$1.findKey(headers, header);
1856
+
1857
+ if (key) {
1858
+ self[key] = normalizeValue$1(value);
1859
+ delete self[header];
1860
+ return;
1861
+ }
1862
+
1863
+ const normalized = format ? formatHeader$1(header) : String(header).trim();
1864
+
1865
+ if (normalized !== header) {
1866
+ delete self[header];
1867
+ }
1868
+
1869
+ self[normalized] = normalizeValue$1(value);
1870
+
1871
+ headers[normalized] = true;
1872
+ });
1873
+
1874
+ return this;
1875
+ }
1876
+
1877
+ concat(...targets) {
1878
+ return this.constructor.concat(this, ...targets);
1879
+ }
1880
+
1881
+ toJSON(asStrings) {
1882
+ const obj = Object.create(null);
1883
+
1884
+ utils$1.forEach(this, (value, header) => {
1885
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1886
+ });
1887
+
1888
+ return obj;
1889
+ }
1890
+
1891
+ [Symbol.iterator]() {
1892
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1893
+ }
1894
+
1895
+ toString() {
1896
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1897
+ }
1898
+
1899
+ get [Symbol.toStringTag]() {
1900
+ return 'AxiosHeaders';
1901
+ }
1902
+
1903
+ static from(thing) {
1904
+ return thing instanceof this ? thing : new this(thing);
1905
+ }
1906
+
1907
+ static concat(first, ...targets) {
1908
+ const computed = new this(first);
1909
+
1910
+ targets.forEach((target) => computed.set(target));
1911
+
1912
+ return computed;
1913
+ }
1914
+
1915
+ static accessor(header) {
1916
+ const internals = this[$internals$1] = (this[$internals$1] = {
1917
+ accessors: {}
1918
+ });
1919
+
1920
+ const accessors = internals.accessors;
1921
+ const prototype = this.prototype;
1922
+
1923
+ function defineAccessor(_header) {
1924
+ const lHeader = normalizeHeader$1(_header);
1925
+
1926
+ if (!accessors[lHeader]) {
1927
+ buildAccessors$1(prototype, _header);
1928
+ accessors[lHeader] = true;
1929
+ }
1930
+ }
1931
+
1932
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1933
+
1934
+ return this;
1935
+ }
1936
+ };
1937
+
1938
+ AxiosHeaders$2.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1939
+
1940
+ utils$1.freezeMethods(AxiosHeaders$2.prototype);
1941
+ utils$1.freezeMethods(AxiosHeaders$2);
1942
+
1943
+ var AxiosHeaders$1$1 = AxiosHeaders$2;
1944
+
1945
+ /**
1946
+ * Transform the data for a request or a response
1947
+ *
1948
+ * @param {Array|Function} fns A single function or Array of functions
1949
+ * @param {?Object} response The response object
1950
+ *
1951
+ * @returns {*} The resulting transformed data
1952
+ */
1953
+ function transformData$1(fns, response) {
1954
+ const config = this || defaults$1$1;
1955
+ const context = response || config;
1956
+ const headers = AxiosHeaders$1$1.from(context.headers);
1957
+ let data = context.data;
1958
+
1959
+ utils$1.forEach(fns, function transform(fn) {
1960
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1961
+ });
1962
+
1963
+ headers.normalize();
1964
+
1965
+ return data;
1966
+ }
1967
+
1968
+ function isCancel$1(value) {
1969
+ return !!(value && value.__CANCEL__);
1970
+ }
1971
+
1972
+ /**
1973
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1974
+ *
1975
+ * @param {string=} message The message.
1976
+ * @param {Object=} config The config.
1977
+ * @param {Object=} request The request.
1978
+ *
1979
+ * @returns {CanceledError} The created error.
1980
+ */
1981
+ function CanceledError$1(message, config, request) {
1982
+ // eslint-disable-next-line no-eq-null,eqeqeq
1983
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1984
+ this.name = 'CanceledError';
1985
+ }
1986
+
1987
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1988
+ __CANCEL__: true
1989
+ });
1990
+
1991
+ /**
1992
+ * Resolve or reject a Promise based on response status.
1993
+ *
1994
+ * @param {Function} resolve A function that resolves the promise.
1995
+ * @param {Function} reject A function that rejects the promise.
1996
+ * @param {object} response The response.
1997
+ *
1998
+ * @returns {object} The response.
1999
+ */
2000
+ function settle$1(resolve, reject, response) {
2001
+ const validateStatus = response.config.validateStatus;
2002
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2003
+ resolve(response);
2004
+ } else {
2005
+ reject(new AxiosError$1(
2006
+ 'Request failed with status code ' + response.status,
2007
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2008
+ response.config,
2009
+ response.request,
2010
+ response
2011
+ ));
2012
+ }
2013
+ }
2014
+
2015
+ var cookies$1 = platform$1.isStandardBrowserEnv ?
2016
+
2017
+ // Standard browser envs support document.cookie
2018
+ (function standardBrowserEnv() {
2019
+ return {
2020
+ write: function write(name, value, expires, path, domain, secure) {
2021
+ const cookie = [];
2022
+ cookie.push(name + '=' + encodeURIComponent(value));
2023
+
2024
+ if (utils$1.isNumber(expires)) {
2025
+ cookie.push('expires=' + new Date(expires).toGMTString());
2026
+ }
2027
+
2028
+ if (utils$1.isString(path)) {
2029
+ cookie.push('path=' + path);
2030
+ }
2031
+
2032
+ if (utils$1.isString(domain)) {
2033
+ cookie.push('domain=' + domain);
2034
+ }
2035
+
2036
+ if (secure === true) {
2037
+ cookie.push('secure');
2038
+ }
2039
+
2040
+ document.cookie = cookie.join('; ');
2041
+ },
2042
+
2043
+ read: function read(name) {
2044
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2045
+ return (match ? decodeURIComponent(match[3]) : null);
2046
+ },
2047
+
2048
+ remove: function remove(name) {
2049
+ this.write(name, '', Date.now() - 86400000);
2050
+ }
2051
+ };
2052
+ })() :
2053
+
2054
+ // Non standard browser env (web workers, react-native) lack needed support.
2055
+ (function nonStandardBrowserEnv() {
2056
+ return {
2057
+ write: function write() {},
2058
+ read: function read() { return null; },
2059
+ remove: function remove() {}
2060
+ };
2061
+ })();
2062
+
2063
+ /**
2064
+ * Determines whether the specified URL is absolute
2065
+ *
2066
+ * @param {string} url The URL to test
2067
+ *
2068
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2069
+ */
2070
+ function isAbsoluteURL$1(url) {
2071
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2072
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2073
+ // by any combination of letters, digits, plus, period, or hyphen.
2074
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2075
+ }
2076
+
2077
+ /**
2078
+ * Creates a new URL by combining the specified URLs
2079
+ *
2080
+ * @param {string} baseURL The base URL
2081
+ * @param {string} relativeURL The relative URL
2082
+ *
2083
+ * @returns {string} The combined URL
2084
+ */
2085
+ function combineURLs$1(baseURL, relativeURL) {
2086
+ return relativeURL
2087
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2088
+ : baseURL;
2089
+ }
2090
+
2091
+ /**
2092
+ * Creates a new URL by combining the baseURL with the requestedURL,
2093
+ * only when the requestedURL is not already an absolute URL.
2094
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2095
+ *
2096
+ * @param {string} baseURL The base URL
2097
+ * @param {string} requestedURL Absolute or relative URL to combine
2098
+ *
2099
+ * @returns {string} The combined full path
2100
+ */
2101
+ function buildFullPath$1(baseURL, requestedURL) {
2102
+ if (baseURL && !isAbsoluteURL$1(requestedURL)) {
2103
+ return combineURLs$1(baseURL, requestedURL);
2104
+ }
2105
+ return requestedURL;
2106
+ }
2107
+
2108
+ var isURLSameOrigin$1 = platform$1.isStandardBrowserEnv ?
2109
+
2110
+ // Standard browser envs have full support of the APIs needed to test
2111
+ // whether the request URL is of the same origin as current location.
2112
+ (function standardBrowserEnv() {
2113
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
2114
+ const urlParsingNode = document.createElement('a');
2115
+ let originURL;
2116
+
2117
+ /**
2118
+ * Parse a URL to discover it's components
2119
+ *
2120
+ * @param {String} url The URL to be parsed
2121
+ * @returns {Object}
2122
+ */
2123
+ function resolveURL(url) {
2124
+ let href = url;
2125
+
2126
+ if (msie) {
2127
+ // IE needs attribute set twice to normalize properties
2128
+ urlParsingNode.setAttribute('href', href);
2129
+ href = urlParsingNode.href;
2130
+ }
2131
+
2132
+ urlParsingNode.setAttribute('href', href);
2133
+
2134
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2135
+ return {
2136
+ href: urlParsingNode.href,
2137
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2138
+ host: urlParsingNode.host,
2139
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2140
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2141
+ hostname: urlParsingNode.hostname,
2142
+ port: urlParsingNode.port,
2143
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2144
+ urlParsingNode.pathname :
2145
+ '/' + urlParsingNode.pathname
2146
+ };
2147
+ }
2148
+
2149
+ originURL = resolveURL(window.location.href);
2150
+
2151
+ /**
2152
+ * Determine if a URL shares the same origin as the current location
2153
+ *
2154
+ * @param {String} requestURL The URL to test
2155
+ * @returns {boolean} True if URL shares the same origin, otherwise false
2156
+ */
2157
+ return function isURLSameOrigin(requestURL) {
2158
+ const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2159
+ return (parsed.protocol === originURL.protocol &&
2160
+ parsed.host === originURL.host);
2161
+ };
2162
+ })() :
2163
+
2164
+ // Non standard browser envs (web workers, react-native) lack needed support.
2165
+ (function nonStandardBrowserEnv() {
2166
+ return function isURLSameOrigin() {
2167
+ return true;
2168
+ };
2169
+ })();
2170
+
2171
+ function parseProtocol$1(url) {
2172
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2173
+ return match && match[1] || '';
2174
+ }
2175
+
2176
+ /**
2177
+ * Calculate data maxRate
2178
+ * @param {Number} [samplesCount= 10]
2179
+ * @param {Number} [min= 1000]
2180
+ * @returns {Function}
2181
+ */
2182
+ function speedometer$1(samplesCount, min) {
2183
+ samplesCount = samplesCount || 10;
2184
+ const bytes = new Array(samplesCount);
2185
+ const timestamps = new Array(samplesCount);
2186
+ let head = 0;
2187
+ let tail = 0;
2188
+ let firstSampleTS;
2189
+
2190
+ min = min !== undefined ? min : 1000;
2191
+
2192
+ return function push(chunkLength) {
2193
+ const now = Date.now();
2194
+
2195
+ const startedAt = timestamps[tail];
2196
+
2197
+ if (!firstSampleTS) {
2198
+ firstSampleTS = now;
2199
+ }
2200
+
2201
+ bytes[head] = chunkLength;
2202
+ timestamps[head] = now;
2203
+
2204
+ let i = tail;
2205
+ let bytesCount = 0;
2206
+
2207
+ while (i !== head) {
2208
+ bytesCount += bytes[i++];
2209
+ i = i % samplesCount;
2210
+ }
2211
+
2212
+ head = (head + 1) % samplesCount;
2213
+
2214
+ if (head === tail) {
2215
+ tail = (tail + 1) % samplesCount;
2216
+ }
2217
+
2218
+ if (now - firstSampleTS < min) {
2219
+ return;
2220
+ }
2221
+
2222
+ const passed = startedAt && now - startedAt;
2223
+
2224
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2225
+ };
2226
+ }
2227
+
2228
+ function progressEventReducer$1(listener, isDownloadStream) {
2229
+ let bytesNotified = 0;
2230
+ const _speedometer = speedometer$1(50, 250);
2231
+
2232
+ return e => {
2233
+ const loaded = e.loaded;
2234
+ const total = e.lengthComputable ? e.total : undefined;
2235
+ const progressBytes = loaded - bytesNotified;
2236
+ const rate = _speedometer(progressBytes);
2237
+ const inRange = loaded <= total;
2238
+
2239
+ bytesNotified = loaded;
2240
+
2241
+ const data = {
2242
+ loaded,
2243
+ total,
2244
+ progress: total ? (loaded / total) : undefined,
2245
+ bytes: progressBytes,
2246
+ rate: rate ? rate : undefined,
2247
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2248
+ event: e
2249
+ };
2250
+
2251
+ data[isDownloadStream ? 'download' : 'upload'] = true;
2252
+
2253
+ listener(data);
2254
+ };
2255
+ }
2256
+
2257
+ const isXHRAdapterSupported$1 = typeof XMLHttpRequest !== 'undefined';
2258
+
2259
+ var xhrAdapter$1 = isXHRAdapterSupported$1 && function (config) {
2260
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2261
+ let requestData = config.data;
2262
+ const requestHeaders = AxiosHeaders$1$1.from(config.headers).normalize();
2263
+ const responseType = config.responseType;
2264
+ let onCanceled;
2265
+ function done() {
2266
+ if (config.cancelToken) {
2267
+ config.cancelToken.unsubscribe(onCanceled);
2268
+ }
2269
+
2270
+ if (config.signal) {
2271
+ config.signal.removeEventListener('abort', onCanceled);
2272
+ }
2273
+ }
2274
+
2275
+ if (utils$1.isFormData(requestData)) {
2276
+ if (platform$1.isStandardBrowserEnv || platform$1.isStandardBrowserWebWorkerEnv) {
2277
+ requestHeaders.setContentType(false); // Let the browser set it
2278
+ } else {
2279
+ requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2280
+ }
2281
+ }
2282
+
2283
+ let request = new XMLHttpRequest();
2284
+
2285
+ // HTTP basic authentication
2286
+ if (config.auth) {
2287
+ const username = config.auth.username || '';
2288
+ const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2289
+ requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2290
+ }
2291
+
2292
+ const fullPath = buildFullPath$1(config.baseURL, config.url);
2293
+
2294
+ request.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
2295
+
2296
+ // Set the request timeout in MS
2297
+ request.timeout = config.timeout;
2298
+
2299
+ function onloadend() {
2300
+ if (!request) {
2301
+ return;
2302
+ }
2303
+ // Prepare the response
2304
+ const responseHeaders = AxiosHeaders$1$1.from(
2305
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2306
+ );
2307
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2308
+ request.responseText : request.response;
2309
+ const response = {
2310
+ data: responseData,
2311
+ status: request.status,
2312
+ statusText: request.statusText,
2313
+ headers: responseHeaders,
2314
+ config,
2315
+ request
2316
+ };
2317
+
2318
+ settle$1(function _resolve(value) {
2319
+ resolve(value);
2320
+ done();
2321
+ }, function _reject(err) {
2322
+ reject(err);
2323
+ done();
2324
+ }, response);
2325
+
2326
+ // Clean up request
2327
+ request = null;
2328
+ }
2329
+
2330
+ if ('onloadend' in request) {
2331
+ // Use onloadend if available
2332
+ request.onloadend = onloadend;
2333
+ } else {
2334
+ // Listen for ready state to emulate onloadend
2335
+ request.onreadystatechange = function handleLoad() {
2336
+ if (!request || request.readyState !== 4) {
2337
+ return;
2338
+ }
2339
+
2340
+ // The request errored out and we didn't get a response, this will be
2341
+ // handled by onerror instead
2342
+ // With one exception: request that using file: protocol, most browsers
2343
+ // will return status as 0 even though it's a successful request
2344
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2345
+ return;
2346
+ }
2347
+ // readystate handler is calling before onerror or ontimeout handlers,
2348
+ // so we should call onloadend on the next 'tick'
2349
+ setTimeout(onloadend);
2350
+ };
2351
+ }
2352
+
2353
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2354
+ request.onabort = function handleAbort() {
2355
+ if (!request) {
2356
+ return;
2357
+ }
2358
+
2359
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2360
+
2361
+ // Clean up request
2362
+ request = null;
2363
+ };
2364
+
2365
+ // Handle low level network errors
2366
+ request.onerror = function handleError() {
2367
+ // Real errors are hidden from us by the browser
2368
+ // onerror should only fire if it's a network error
2369
+ reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
2370
+
2371
+ // Clean up request
2372
+ request = null;
2373
+ };
2374
+
2375
+ // Handle timeout
2376
+ request.ontimeout = function handleTimeout() {
2377
+ let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2378
+ const transitional = config.transitional || transitionalDefaults$1;
2379
+ if (config.timeoutErrorMessage) {
2380
+ timeoutErrorMessage = config.timeoutErrorMessage;
2381
+ }
2382
+ reject(new AxiosError$1(
2383
+ timeoutErrorMessage,
2384
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2385
+ config,
2386
+ request));
2387
+
2388
+ // Clean up request
2389
+ request = null;
2390
+ };
2391
+
2392
+ // Add xsrf header
2393
+ // This is only done if running in a standard browser environment.
2394
+ // Specifically not if we're in a web worker, or react-native.
2395
+ if (platform$1.isStandardBrowserEnv) {
2396
+ // Add xsrf header
2397
+ const xsrfValue = (config.withCredentials || isURLSameOrigin$1(fullPath))
2398
+ && config.xsrfCookieName && cookies$1.read(config.xsrfCookieName);
2399
+
2400
+ if (xsrfValue) {
2401
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2402
+ }
2403
+ }
2404
+
2405
+ // Remove Content-Type if data is undefined
2406
+ requestData === undefined && requestHeaders.setContentType(null);
2407
+
2408
+ // Add headers to the request
2409
+ if ('setRequestHeader' in request) {
2410
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2411
+ request.setRequestHeader(key, val);
2412
+ });
2413
+ }
2414
+
2415
+ // Add withCredentials to request if needed
2416
+ if (!utils$1.isUndefined(config.withCredentials)) {
2417
+ request.withCredentials = !!config.withCredentials;
2418
+ }
2419
+
2420
+ // Add responseType to request if needed
2421
+ if (responseType && responseType !== 'json') {
2422
+ request.responseType = config.responseType;
2423
+ }
2424
+
2425
+ // Handle progress if needed
2426
+ if (typeof config.onDownloadProgress === 'function') {
2427
+ request.addEventListener('progress', progressEventReducer$1(config.onDownloadProgress, true));
2428
+ }
2429
+
2430
+ // Not all browsers support upload events
2431
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
2432
+ request.upload.addEventListener('progress', progressEventReducer$1(config.onUploadProgress));
2433
+ }
2434
+
2435
+ if (config.cancelToken || config.signal) {
2436
+ // Handle cancellation
2437
+ // eslint-disable-next-line func-names
2438
+ onCanceled = cancel => {
2439
+ if (!request) {
2440
+ return;
2441
+ }
2442
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2443
+ request.abort();
2444
+ request = null;
2445
+ };
2446
+
2447
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
2448
+ if (config.signal) {
2449
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2450
+ }
2451
+ }
2452
+
2453
+ const protocol = parseProtocol$1(fullPath);
2454
+
2455
+ if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
2456
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2457
+ return;
2458
+ }
2459
+
2460
+
2461
+ // Send the request
2462
+ request.send(requestData || null);
2463
+ });
2464
+ };
2465
+
2466
+ const knownAdapters$1 = {
2467
+ http: httpAdapter$1,
2468
+ xhr: xhrAdapter$1
2469
+ };
2470
+
2471
+ utils$1.forEach(knownAdapters$1, (fn, value) => {
2472
+ if(fn) {
2473
+ try {
2474
+ Object.defineProperty(fn, 'name', {value});
2475
+ } catch (e) {
2476
+ // eslint-disable-next-line no-empty
2477
+ }
2478
+ Object.defineProperty(fn, 'adapterName', {value});
2479
+ }
2480
+ });
2481
+
2482
+ var adapters$1 = {
2483
+ getAdapter: (adapters) => {
2484
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
2485
+
2486
+ const {length} = adapters;
2487
+ let nameOrAdapter;
2488
+ let adapter;
2489
+
2490
+ for (let i = 0; i < length; i++) {
2491
+ nameOrAdapter = adapters[i];
2492
+ if((adapter = utils$1.isString(nameOrAdapter) ? knownAdapters$1[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2493
+ break;
2494
+ }
2495
+ }
2496
+
2497
+ if (!adapter) {
2498
+ if (adapter === false) {
2499
+ throw new AxiosError$1(
2500
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
2501
+ 'ERR_NOT_SUPPORT'
2502
+ );
2503
+ }
2504
+
2505
+ throw new Error(
2506
+ utils$1.hasOwnProp(knownAdapters$1, nameOrAdapter) ?
2507
+ `Adapter '${nameOrAdapter}' is not available in the build` :
2508
+ `Unknown adapter '${nameOrAdapter}'`
2509
+ );
2510
+ }
2511
+
2512
+ if (!utils$1.isFunction(adapter)) {
2513
+ throw new TypeError('adapter is not a function');
2514
+ }
2515
+
2516
+ return adapter;
2517
+ },
2518
+ adapters: knownAdapters$1
2519
+ };
2520
+
2521
+ /**
2522
+ * Throws a `CanceledError` if cancellation has been requested.
2523
+ *
2524
+ * @param {Object} config The config that is to be used for the request
2525
+ *
2526
+ * @returns {void}
2527
+ */
2528
+ function throwIfCancellationRequested$1(config) {
2529
+ if (config.cancelToken) {
2530
+ config.cancelToken.throwIfRequested();
2531
+ }
2532
+
2533
+ if (config.signal && config.signal.aborted) {
2534
+ throw new CanceledError$1(null, config);
2535
+ }
2536
+ }
2537
+
2538
+ /**
2539
+ * Dispatch a request to the server using the configured adapter.
2540
+ *
2541
+ * @param {object} config The config that is to be used for the request
2542
+ *
2543
+ * @returns {Promise} The Promise to be fulfilled
2544
+ */
2545
+ function dispatchRequest$1(config) {
2546
+ throwIfCancellationRequested$1(config);
2547
+
2548
+ config.headers = AxiosHeaders$1$1.from(config.headers);
2549
+
2550
+ // Transform request data
2551
+ config.data = transformData$1.call(
2552
+ config,
2553
+ config.transformRequest
2554
+ );
2555
+
2556
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2557
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2558
+ }
2559
+
2560
+ const adapter = adapters$1.getAdapter(config.adapter || defaults$1$1.adapter);
2561
+
2562
+ return adapter(config).then(function onAdapterResolution(response) {
2563
+ throwIfCancellationRequested$1(config);
2564
+
2565
+ // Transform response data
2566
+ response.data = transformData$1.call(
2567
+ config,
2568
+ config.transformResponse,
2569
+ response
2570
+ );
2571
+
2572
+ response.headers = AxiosHeaders$1$1.from(response.headers);
2573
+
2574
+ return response;
2575
+ }, function onAdapterRejection(reason) {
2576
+ if (!isCancel$1(reason)) {
2577
+ throwIfCancellationRequested$1(config);
2578
+
2579
+ // Transform response data
2580
+ if (reason && reason.response) {
2581
+ reason.response.data = transformData$1.call(
2582
+ config,
2583
+ config.transformResponse,
2584
+ reason.response
2585
+ );
2586
+ reason.response.headers = AxiosHeaders$1$1.from(reason.response.headers);
2587
+ }
2588
+ }
2589
+
2590
+ return Promise.reject(reason);
2591
+ });
2592
+ }
2593
+
2594
+ const headersToObject$1 = (thing) => thing instanceof AxiosHeaders$1$1 ? thing.toJSON() : thing;
2595
+
2596
+ /**
2597
+ * Config-specific merge-function which creates a new config-object
2598
+ * by merging two configuration objects together.
2599
+ *
2600
+ * @param {Object} config1
2601
+ * @param {Object} config2
2602
+ *
2603
+ * @returns {Object} New object resulting from merging config2 to config1
2604
+ */
2605
+ function mergeConfig$1(config1, config2) {
2606
+ // eslint-disable-next-line no-param-reassign
2607
+ config2 = config2 || {};
2608
+ const config = {};
2609
+
2610
+ function getMergedValue(target, source, caseless) {
2611
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2612
+ return utils$1.merge.call({caseless}, target, source);
2613
+ } else if (utils$1.isPlainObject(source)) {
2614
+ return utils$1.merge({}, source);
2615
+ } else if (utils$1.isArray(source)) {
2616
+ return source.slice();
2617
+ }
2618
+ return source;
2619
+ }
2620
+
2621
+ // eslint-disable-next-line consistent-return
2622
+ function mergeDeepProperties(a, b, caseless) {
2623
+ if (!utils$1.isUndefined(b)) {
2624
+ return getMergedValue(a, b, caseless);
2625
+ } else if (!utils$1.isUndefined(a)) {
2626
+ return getMergedValue(undefined, a, caseless);
2627
+ }
2628
+ }
2629
+
2630
+ // eslint-disable-next-line consistent-return
2631
+ function valueFromConfig2(a, b) {
2632
+ if (!utils$1.isUndefined(b)) {
2633
+ return getMergedValue(undefined, b);
2634
+ }
2635
+ }
2636
+
2637
+ // eslint-disable-next-line consistent-return
2638
+ function defaultToConfig2(a, b) {
2639
+ if (!utils$1.isUndefined(b)) {
2640
+ return getMergedValue(undefined, b);
2641
+ } else if (!utils$1.isUndefined(a)) {
2642
+ return getMergedValue(undefined, a);
2643
+ }
2644
+ }
2645
+
2646
+ // eslint-disable-next-line consistent-return
2647
+ function mergeDirectKeys(a, b, prop) {
2648
+ if (prop in config2) {
2649
+ return getMergedValue(a, b);
2650
+ } else if (prop in config1) {
2651
+ return getMergedValue(undefined, a);
2652
+ }
2653
+ }
2654
+
2655
+ const mergeMap = {
2656
+ url: valueFromConfig2,
2657
+ method: valueFromConfig2,
2658
+ data: valueFromConfig2,
2659
+ baseURL: defaultToConfig2,
2660
+ transformRequest: defaultToConfig2,
2661
+ transformResponse: defaultToConfig2,
2662
+ paramsSerializer: defaultToConfig2,
2663
+ timeout: defaultToConfig2,
2664
+ timeoutMessage: defaultToConfig2,
2665
+ withCredentials: defaultToConfig2,
2666
+ adapter: defaultToConfig2,
2667
+ responseType: defaultToConfig2,
2668
+ xsrfCookieName: defaultToConfig2,
2669
+ xsrfHeaderName: defaultToConfig2,
2670
+ onUploadProgress: defaultToConfig2,
2671
+ onDownloadProgress: defaultToConfig2,
2672
+ decompress: defaultToConfig2,
2673
+ maxContentLength: defaultToConfig2,
2674
+ maxBodyLength: defaultToConfig2,
2675
+ beforeRedirect: defaultToConfig2,
2676
+ transport: defaultToConfig2,
2677
+ httpAgent: defaultToConfig2,
2678
+ httpsAgent: defaultToConfig2,
2679
+ cancelToken: defaultToConfig2,
2680
+ socketPath: defaultToConfig2,
2681
+ responseEncoding: defaultToConfig2,
2682
+ validateStatus: mergeDirectKeys,
2683
+ headers: (a, b) => mergeDeepProperties(headersToObject$1(a), headersToObject$1(b), true)
2684
+ };
2685
+
2686
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2687
+ const merge = mergeMap[prop] || mergeDeepProperties;
2688
+ const configValue = merge(config1[prop], config2[prop], prop);
2689
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2690
+ });
2691
+
2692
+ return config;
2693
+ }
2694
+
2695
+ const VERSION$1 = "1.4.0";
2696
+
2697
+ const validators$1$1 = {};
2698
+
2699
+ // eslint-disable-next-line func-names
2700
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
2701
+ validators$1$1[type] = function validator(thing) {
2702
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2703
+ };
2704
+ });
2705
+
2706
+ const deprecatedWarnings$1 = {};
2707
+
2708
+ /**
2709
+ * Transitional option validator
2710
+ *
2711
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
2712
+ * @param {string?} version - deprecated version / removed since version
2713
+ * @param {string?} message - some message with additional info
2714
+ *
2715
+ * @returns {function}
2716
+ */
2717
+ validators$1$1.transitional = function transitional(validator, version, message) {
2718
+ function formatMessage(opt, desc) {
2719
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2720
+ }
2721
+
2722
+ // eslint-disable-next-line func-names
2723
+ return (value, opt, opts) => {
2724
+ if (validator === false) {
2725
+ throw new AxiosError$1(
2726
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2727
+ AxiosError$1.ERR_DEPRECATED
2728
+ );
2729
+ }
2730
+
2731
+ if (version && !deprecatedWarnings$1[opt]) {
2732
+ deprecatedWarnings$1[opt] = true;
2733
+ // eslint-disable-next-line no-console
2734
+ console.warn(
2735
+ formatMessage(
2736
+ opt,
2737
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
2738
+ )
2739
+ );
2740
+ }
2741
+
2742
+ return validator ? validator(value, opt, opts) : true;
2743
+ };
2744
+ };
2745
+
2746
+ /**
2747
+ * Assert object's properties type
2748
+ *
2749
+ * @param {object} options
2750
+ * @param {object} schema
2751
+ * @param {boolean?} allowUnknown
2752
+ *
2753
+ * @returns {object}
2754
+ */
2755
+
2756
+ function assertOptions$1(options, schema, allowUnknown) {
2757
+ if (typeof options !== 'object') {
2758
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2759
+ }
2760
+ const keys = Object.keys(options);
2761
+ let i = keys.length;
2762
+ while (i-- > 0) {
2763
+ const opt = keys[i];
2764
+ const validator = schema[opt];
2765
+ if (validator) {
2766
+ const value = options[opt];
2767
+ const result = value === undefined || validator(value, opt, options);
2768
+ if (result !== true) {
2769
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2770
+ }
2771
+ continue;
2772
+ }
2773
+ if (allowUnknown !== true) {
2774
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2775
+ }
2776
+ }
2777
+ }
2778
+
2779
+ var validator$1 = {
2780
+ assertOptions: assertOptions$1,
2781
+ validators: validators$1$1
2782
+ };
2783
+
2784
+ const validators$2 = validator$1.validators;
2785
+
2786
+ /**
2787
+ * Create a new instance of Axios
2788
+ *
2789
+ * @param {Object} instanceConfig The default config for the instance
2790
+ *
2791
+ * @return {Axios} A new instance of Axios
2792
+ */
2793
+ let Axios$2 = class Axios {
2794
+ constructor(instanceConfig) {
2795
+ this.defaults = instanceConfig;
2796
+ this.interceptors = {
2797
+ request: new InterceptorManager$1$1(),
2798
+ response: new InterceptorManager$1$1()
2799
+ };
2800
+ }
2801
+
2802
+ /**
2803
+ * Dispatch a request
2804
+ *
2805
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2806
+ * @param {?Object} config
2807
+ *
2808
+ * @returns {Promise} The Promise to be fulfilled
2809
+ */
2810
+ request(configOrUrl, config) {
2811
+ /*eslint no-param-reassign:0*/
2812
+ // Allow for axios('example/url'[, config]) a la fetch API
2813
+ if (typeof configOrUrl === 'string') {
2814
+ config = config || {};
2815
+ config.url = configOrUrl;
2816
+ } else {
2817
+ config = configOrUrl || {};
2818
+ }
2819
+
2820
+ config = mergeConfig$1(this.defaults, config);
2821
+
2822
+ const {transitional, paramsSerializer, headers} = config;
2823
+
2824
+ if (transitional !== undefined) {
2825
+ validator$1.assertOptions(transitional, {
2826
+ silentJSONParsing: validators$2.transitional(validators$2.boolean),
2827
+ forcedJSONParsing: validators$2.transitional(validators$2.boolean),
2828
+ clarifyTimeoutError: validators$2.transitional(validators$2.boolean)
2829
+ }, false);
2830
+ }
2831
+
2832
+ if (paramsSerializer != null) {
2833
+ if (utils$1.isFunction(paramsSerializer)) {
2834
+ config.paramsSerializer = {
2835
+ serialize: paramsSerializer
2836
+ };
2837
+ } else {
2838
+ validator$1.assertOptions(paramsSerializer, {
2839
+ encode: validators$2.function,
2840
+ serialize: validators$2.function
2841
+ }, true);
2842
+ }
2843
+ }
2844
+
2845
+ // Set config.method
2846
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2847
+
2848
+ let contextHeaders;
2849
+
2850
+ // Flatten headers
2851
+ contextHeaders = headers && utils$1.merge(
2852
+ headers.common,
2853
+ headers[config.method]
2854
+ );
2855
+
2856
+ contextHeaders && utils$1.forEach(
2857
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2858
+ (method) => {
2859
+ delete headers[method];
2860
+ }
2861
+ );
2862
+
2863
+ config.headers = AxiosHeaders$1$1.concat(contextHeaders, headers);
2864
+
2865
+ // filter out skipped interceptors
2866
+ const requestInterceptorChain = [];
2867
+ let synchronousRequestInterceptors = true;
2868
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2869
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2870
+ return;
2871
+ }
2872
+
2873
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2874
+
2875
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2876
+ });
2877
+
2878
+ const responseInterceptorChain = [];
2879
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2880
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2881
+ });
2882
+
2883
+ let promise;
2884
+ let i = 0;
2885
+ let len;
2886
+
2887
+ if (!synchronousRequestInterceptors) {
2888
+ const chain = [dispatchRequest$1.bind(this), undefined];
2889
+ chain.unshift.apply(chain, requestInterceptorChain);
2890
+ chain.push.apply(chain, responseInterceptorChain);
2891
+ len = chain.length;
2892
+
2893
+ promise = Promise.resolve(config);
2894
+
2895
+ while (i < len) {
2896
+ promise = promise.then(chain[i++], chain[i++]);
2897
+ }
2898
+
2899
+ return promise;
2900
+ }
2901
+
2902
+ len = requestInterceptorChain.length;
2903
+
2904
+ let newConfig = config;
2905
+
2906
+ i = 0;
2907
+
2908
+ while (i < len) {
2909
+ const onFulfilled = requestInterceptorChain[i++];
2910
+ const onRejected = requestInterceptorChain[i++];
2911
+ try {
2912
+ newConfig = onFulfilled(newConfig);
2913
+ } catch (error) {
2914
+ onRejected.call(this, error);
2915
+ break;
2916
+ }
2917
+ }
2918
+
2919
+ try {
2920
+ promise = dispatchRequest$1.call(this, newConfig);
2921
+ } catch (error) {
2922
+ return Promise.reject(error);
2923
+ }
2924
+
2925
+ i = 0;
2926
+ len = responseInterceptorChain.length;
2927
+
2928
+ while (i < len) {
2929
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2930
+ }
2931
+
2932
+ return promise;
2933
+ }
2934
+
2935
+ getUri(config) {
2936
+ config = mergeConfig$1(this.defaults, config);
2937
+ const fullPath = buildFullPath$1(config.baseURL, config.url);
2938
+ return buildURL$1(fullPath, config.params, config.paramsSerializer);
2939
+ }
2940
+ };
2941
+
2942
+ // Provide aliases for supported request methods
2943
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2944
+ /*eslint func-names:0*/
2945
+ Axios$2.prototype[method] = function(url, config) {
2946
+ return this.request(mergeConfig$1(config || {}, {
2947
+ method,
2948
+ url,
2949
+ data: (config || {}).data
2950
+ }));
2951
+ };
2952
+ });
2953
+
2954
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2955
+ /*eslint func-names:0*/
2956
+
2957
+ function generateHTTPMethod(isForm) {
2958
+ return function httpMethod(url, data, config) {
2959
+ return this.request(mergeConfig$1(config || {}, {
2960
+ method,
2961
+ headers: isForm ? {
2962
+ 'Content-Type': 'multipart/form-data'
2963
+ } : {},
2964
+ url,
2965
+ data
2966
+ }));
2967
+ };
2968
+ }
2969
+
2970
+ Axios$2.prototype[method] = generateHTTPMethod();
2971
+
2972
+ Axios$2.prototype[method + 'Form'] = generateHTTPMethod(true);
2973
+ });
2974
+
2975
+ var Axios$1$1 = Axios$2;
2976
+
2977
+ /**
2978
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
2979
+ *
2980
+ * @param {Function} executor The executor function.
2981
+ *
2982
+ * @returns {CancelToken}
2983
+ */
2984
+ let CancelToken$2 = class CancelToken {
2985
+ constructor(executor) {
2986
+ if (typeof executor !== 'function') {
2987
+ throw new TypeError('executor must be a function.');
2988
+ }
2989
+
2990
+ let resolvePromise;
2991
+
2992
+ this.promise = new Promise(function promiseExecutor(resolve) {
2993
+ resolvePromise = resolve;
2994
+ });
2995
+
2996
+ const token = this;
2997
+
2998
+ // eslint-disable-next-line func-names
2999
+ this.promise.then(cancel => {
3000
+ if (!token._listeners) return;
3001
+
3002
+ let i = token._listeners.length;
3003
+
3004
+ while (i-- > 0) {
3005
+ token._listeners[i](cancel);
3006
+ }
3007
+ token._listeners = null;
3008
+ });
3009
+
3010
+ // eslint-disable-next-line func-names
3011
+ this.promise.then = onfulfilled => {
3012
+ let _resolve;
3013
+ // eslint-disable-next-line func-names
3014
+ const promise = new Promise(resolve => {
3015
+ token.subscribe(resolve);
3016
+ _resolve = resolve;
3017
+ }).then(onfulfilled);
3018
+
3019
+ promise.cancel = function reject() {
3020
+ token.unsubscribe(_resolve);
3021
+ };
3022
+
3023
+ return promise;
3024
+ };
3025
+
3026
+ executor(function cancel(message, config, request) {
3027
+ if (token.reason) {
3028
+ // Cancellation has already been requested
3029
+ return;
3030
+ }
3031
+
3032
+ token.reason = new CanceledError$1(message, config, request);
3033
+ resolvePromise(token.reason);
3034
+ });
3035
+ }
3036
+
3037
+ /**
3038
+ * Throws a `CanceledError` if cancellation has been requested.
3039
+ */
3040
+ throwIfRequested() {
3041
+ if (this.reason) {
3042
+ throw this.reason;
3043
+ }
3044
+ }
3045
+
3046
+ /**
3047
+ * Subscribe to the cancel signal
3048
+ */
3049
+
3050
+ subscribe(listener) {
3051
+ if (this.reason) {
3052
+ listener(this.reason);
3053
+ return;
3054
+ }
3055
+
3056
+ if (this._listeners) {
3057
+ this._listeners.push(listener);
3058
+ } else {
3059
+ this._listeners = [listener];
3060
+ }
3061
+ }
3062
+
3063
+ /**
3064
+ * Unsubscribe from the cancel signal
3065
+ */
3066
+
3067
+ unsubscribe(listener) {
3068
+ if (!this._listeners) {
3069
+ return;
3070
+ }
3071
+ const index = this._listeners.indexOf(listener);
3072
+ if (index !== -1) {
3073
+ this._listeners.splice(index, 1);
3074
+ }
3075
+ }
3076
+
3077
+ /**
3078
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3079
+ * cancels the `CancelToken`.
3080
+ */
3081
+ static source() {
3082
+ let cancel;
3083
+ const token = new CancelToken(function executor(c) {
3084
+ cancel = c;
3085
+ });
3086
+ return {
3087
+ token,
3088
+ cancel
3089
+ };
3090
+ }
3091
+ };
3092
+
3093
+ var CancelToken$1$1 = CancelToken$2;
3094
+
3095
+ /**
3096
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3097
+ *
3098
+ * Common use case would be to use `Function.prototype.apply`.
3099
+ *
3100
+ * ```js
3101
+ * function f(x, y, z) {}
3102
+ * var args = [1, 2, 3];
3103
+ * f.apply(null, args);
3104
+ * ```
3105
+ *
3106
+ * With `spread` this example can be re-written.
3107
+ *
3108
+ * ```js
3109
+ * spread(function(x, y, z) {})([1, 2, 3]);
3110
+ * ```
3111
+ *
3112
+ * @param {Function} callback
3113
+ *
3114
+ * @returns {Function}
3115
+ */
3116
+ function spread$1(callback) {
3117
+ return function wrap(arr) {
3118
+ return callback.apply(null, arr);
3119
+ };
3120
+ }
3121
+
3122
+ /**
3123
+ * Determines whether the payload is an error thrown by Axios
3124
+ *
3125
+ * @param {*} payload The value to test
3126
+ *
3127
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3128
+ */
3129
+ function isAxiosError$1(payload) {
3130
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
42
3131
  }
43
3132
 
44
- var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
3133
+ const HttpStatusCode$2 = {
3134
+ Continue: 100,
3135
+ SwitchingProtocols: 101,
3136
+ Processing: 102,
3137
+ EarlyHints: 103,
3138
+ Ok: 200,
3139
+ Created: 201,
3140
+ Accepted: 202,
3141
+ NonAuthoritativeInformation: 203,
3142
+ NoContent: 204,
3143
+ ResetContent: 205,
3144
+ PartialContent: 206,
3145
+ MultiStatus: 207,
3146
+ AlreadyReported: 208,
3147
+ ImUsed: 226,
3148
+ MultipleChoices: 300,
3149
+ MovedPermanently: 301,
3150
+ Found: 302,
3151
+ SeeOther: 303,
3152
+ NotModified: 304,
3153
+ UseProxy: 305,
3154
+ Unused: 306,
3155
+ TemporaryRedirect: 307,
3156
+ PermanentRedirect: 308,
3157
+ BadRequest: 400,
3158
+ Unauthorized: 401,
3159
+ PaymentRequired: 402,
3160
+ Forbidden: 403,
3161
+ NotFound: 404,
3162
+ MethodNotAllowed: 405,
3163
+ NotAcceptable: 406,
3164
+ ProxyAuthenticationRequired: 407,
3165
+ RequestTimeout: 408,
3166
+ Conflict: 409,
3167
+ Gone: 410,
3168
+ LengthRequired: 411,
3169
+ PreconditionFailed: 412,
3170
+ PayloadTooLarge: 413,
3171
+ UriTooLong: 414,
3172
+ UnsupportedMediaType: 415,
3173
+ RangeNotSatisfiable: 416,
3174
+ ExpectationFailed: 417,
3175
+ ImATeapot: 418,
3176
+ MisdirectedRequest: 421,
3177
+ UnprocessableEntity: 422,
3178
+ Locked: 423,
3179
+ FailedDependency: 424,
3180
+ TooEarly: 425,
3181
+ UpgradeRequired: 426,
3182
+ PreconditionRequired: 428,
3183
+ TooManyRequests: 429,
3184
+ RequestHeaderFieldsTooLarge: 431,
3185
+ UnavailableForLegalReasons: 451,
3186
+ InternalServerError: 500,
3187
+ NotImplemented: 501,
3188
+ BadGateway: 502,
3189
+ ServiceUnavailable: 503,
3190
+ GatewayTimeout: 504,
3191
+ HttpVersionNotSupported: 505,
3192
+ VariantAlsoNegotiates: 506,
3193
+ InsufficientStorage: 507,
3194
+ LoopDetected: 508,
3195
+ NotExtended: 510,
3196
+ NetworkAuthenticationRequired: 511,
3197
+ };
45
3198
 
46
- exports.Environment = void 0;
47
- (function (Environment) {
48
- Environment["PRODUCTION"] = "production";
49
- Environment["SANDBOX"] = "sandbox";
50
- })(exports.Environment || (exports.Environment = {}));
51
- class ImmutableConfiguration {
52
- environment;
3199
+ Object.entries(HttpStatusCode$2).forEach(([key, value]) => {
3200
+ HttpStatusCode$2[value] = key;
3201
+ });
3202
+
3203
+ var HttpStatusCode$1$1 = HttpStatusCode$2;
3204
+
3205
+ /**
3206
+ * Create an instance of Axios
3207
+ *
3208
+ * @param {Object} defaultConfig The default config for the instance
3209
+ *
3210
+ * @returns {Axios} A new instance of Axios
3211
+ */
3212
+ function createInstance$1(defaultConfig) {
3213
+ const context = new Axios$1$1(defaultConfig);
3214
+ const instance = bind$1(Axios$1$1.prototype.request, context);
3215
+
3216
+ // Copy axios.prototype to instance
3217
+ utils$1.extend(instance, Axios$1$1.prototype, context, {allOwnKeys: true});
3218
+
3219
+ // Copy context to instance
3220
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
3221
+
3222
+ // Factory for creating new instances
3223
+ instance.create = function create(instanceConfig) {
3224
+ return createInstance$1(mergeConfig$1(defaultConfig, instanceConfig));
3225
+ };
3226
+
3227
+ return instance;
3228
+ }
3229
+
3230
+ // Create the default instance to be exported
3231
+ const axios$1 = createInstance$1(defaults$1$1);
3232
+
3233
+ // Expose Axios class to allow class inheritance
3234
+ axios$1.Axios = Axios$1$1;
3235
+
3236
+ // Expose Cancel & CancelToken
3237
+ axios$1.CanceledError = CanceledError$1;
3238
+ axios$1.CancelToken = CancelToken$1$1;
3239
+ axios$1.isCancel = isCancel$1;
3240
+ axios$1.VERSION = VERSION$1;
3241
+ axios$1.toFormData = toFormData$1;
3242
+
3243
+ // Expose AxiosError class
3244
+ axios$1.AxiosError = AxiosError$1;
3245
+
3246
+ // alias for CanceledError for backward compatibility
3247
+ axios$1.Cancel = axios$1.CanceledError;
3248
+
3249
+ // Expose all/spread
3250
+ axios$1.all = function all(promises) {
3251
+ return Promise.all(promises);
3252
+ };
3253
+
3254
+ axios$1.spread = spread$1;
3255
+
3256
+ // Expose isAxiosError
3257
+ axios$1.isAxiosError = isAxiosError$1;
3258
+
3259
+ // Expose mergeConfig
3260
+ axios$1.mergeConfig = mergeConfig$1;
3261
+
3262
+ axios$1.AxiosHeaders = AxiosHeaders$1$1;
3263
+
3264
+ axios$1.formToJSON = thing => formDataToJSON$1(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3265
+
3266
+ axios$1.HttpStatusCode = HttpStatusCode$1$1;
3267
+
3268
+ axios$1.default = axios$1;
3269
+
3270
+ // this module should only have a default export
3271
+ var globalAxios$1 = axios$1;
3272
+
3273
+ /* tslint:disable */
3274
+ /* eslint-disable */
3275
+ /**
3276
+ * Immutable X API
3277
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3278
+ *
3279
+ * The version of the OpenAPI document: 3.0
3280
+ * Contact: support@immutable.com
3281
+ *
3282
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3283
+ * https://openapi-generator.tech
3284
+ * Do not edit the class manually.
3285
+ */
3286
+ let Configuration$1 = class Configuration {
3287
+ /**
3288
+ * parameter for apiKey security
3289
+ * @param name security name
3290
+ * @memberof Configuration
3291
+ */
53
3292
  apiKey;
54
- constructor(options) {
55
- this.environment = options.environment;
56
- this.apiKey = options.apiKey;
3293
+ /**
3294
+ * parameter for basic security
3295
+ *
3296
+ * @type {string}
3297
+ * @memberof Configuration
3298
+ */
3299
+ username;
3300
+ /**
3301
+ * parameter for basic security
3302
+ *
3303
+ * @type {string}
3304
+ * @memberof Configuration
3305
+ */
3306
+ password;
3307
+ /**
3308
+ * parameter for oauth2 security
3309
+ * @param name security name
3310
+ * @param scopes oauth2 scope
3311
+ * @memberof Configuration
3312
+ */
3313
+ accessToken;
3314
+ /**
3315
+ * override base path
3316
+ *
3317
+ * @type {string}
3318
+ * @memberof Configuration
3319
+ */
3320
+ basePath;
3321
+ /**
3322
+ * base options for axios calls
3323
+ *
3324
+ * @type {any}
3325
+ * @memberof Configuration
3326
+ */
3327
+ baseOptions;
3328
+ /**
3329
+ * The FormData constructor that will be used to create multipart form data
3330
+ * requests. You can inject this here so that execution environments that
3331
+ * do not support the FormData class can still run the generated client.
3332
+ *
3333
+ * @type {new () => FormData}
3334
+ */
3335
+ formDataCtor;
3336
+ constructor(param = {}) {
3337
+ this.apiKey = param.apiKey;
3338
+ this.username = param.username;
3339
+ this.password = param.password;
3340
+ this.accessToken = param.accessToken;
3341
+ this.basePath = param.basePath;
3342
+ this.baseOptions = param.baseOptions;
3343
+ this.formDataCtor = param.formDataCtor;
57
3344
  }
58
- }
3345
+ /**
3346
+ * Check if the given MIME is a JSON MIME.
3347
+ * JSON MIME examples:
3348
+ * application/json
3349
+ * application/json; charset=UTF8
3350
+ * APPLICATION/JSON
3351
+ * application/vnd.company+json
3352
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
3353
+ * @return True if the given MIME is JSON, false otherwise.
3354
+ */
3355
+ isJsonMime(mime) {
3356
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
3357
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
3358
+ }
3359
+ };
59
3360
 
60
3361
  /* tslint:disable */
61
3362
  /* eslint-disable */
@@ -1765,7 +5066,7 @@ class TokensApi extends BaseAPI$1 {
1765
5066
  * https://openapi-generator.tech
1766
5067
  * Do not edit the class manually.
1767
5068
  */
1768
- let Configuration$1 = class Configuration {
5069
+ let Configuration$2 = class Configuration {
1769
5070
  /**
1770
5071
  * parameter for apiKey security
1771
5072
  * @param name security name
@@ -2177,59 +5478,122 @@ const TokenContractType = {
2177
5478
  */
2178
5479
 
2179
5480
  var index = /*#__PURE__*/Object.freeze({
2180
- __proto__: null,
2181
- APIError400AllOfCodeEnum: APIError400AllOfCodeEnum,
2182
- APIError401AllOfCodeEnum: APIError401AllOfCodeEnum,
2183
- APIError403AllOfCodeEnum: APIError403AllOfCodeEnum,
2184
- APIError404AllOfCodeEnum: APIError404AllOfCodeEnum,
2185
- APIError429AllOfCodeEnum: APIError429AllOfCodeEnum,
2186
- APIError500AllOfCodeEnum: APIError500AllOfCodeEnum,
2187
- ActivitiesApi: ActivitiesApi,
2188
- ActivitiesApiAxiosParamCreator: ActivitiesApiAxiosParamCreator,
2189
- ActivitiesApiFactory: ActivitiesApiFactory,
2190
- ActivitiesApiFp: ActivitiesApiFp,
2191
- ActivityType: ActivityType,
2192
- ChainsApi: ChainsApi,
2193
- ChainsApiAxiosParamCreator: ChainsApiAxiosParamCreator,
2194
- ChainsApiFactory: ChainsApiFactory,
2195
- ChainsApiFp: ChainsApiFp,
2196
- CollectionContractType: CollectionContractType,
2197
- CollectionsApi: CollectionsApi,
2198
- CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
2199
- CollectionsApiFactory: CollectionsApiFactory,
2200
- CollectionsApiFp: CollectionsApiFp,
2201
- Configuration: Configuration$1,
2202
- CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
2203
- ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
2204
- ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
2205
- FeeFeeTypeEnum: FeeFeeTypeEnum,
2206
- NFTContractType: NFTContractType,
2207
- NativeItemItemTypeEnum: NativeItemItemTypeEnum,
2208
- NftOwnersApi: NftOwnersApi,
2209
- NftOwnersApiAxiosParamCreator: NftOwnersApiAxiosParamCreator,
2210
- NftOwnersApiFactory: NftOwnersApiFactory,
2211
- NftOwnersApiFp: NftOwnersApiFp,
2212
- NftsApi: NftsApi,
2213
- NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
2214
- NftsApiFactory: NftsApiFactory,
2215
- NftsApiFp: NftsApiFp,
2216
- OrderStatus: OrderStatus$1,
2217
- OrdersApi: OrdersApi,
2218
- OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
2219
- OrdersApiFactory: OrdersApiFactory,
2220
- OrdersApiFp: OrdersApiFp,
2221
- PassportApi: PassportApi,
2222
- PassportApiAxiosParamCreator: PassportApiAxiosParamCreator,
2223
- PassportApiFactory: PassportApiFactory,
2224
- PassportApiFp: PassportApiFp,
2225
- SaleFeeTypeEnum: SaleFeeTypeEnum,
2226
- TokenContractType: TokenContractType,
2227
- TokensApi: TokensApi,
2228
- TokensApiAxiosParamCreator: TokensApiAxiosParamCreator,
2229
- TokensApiFactory: TokensApiFactory,
2230
- TokensApiFp: TokensApiFp
5481
+ __proto__: null,
5482
+ APIError400AllOfCodeEnum: APIError400AllOfCodeEnum,
5483
+ APIError401AllOfCodeEnum: APIError401AllOfCodeEnum,
5484
+ APIError403AllOfCodeEnum: APIError403AllOfCodeEnum,
5485
+ APIError404AllOfCodeEnum: APIError404AllOfCodeEnum,
5486
+ APIError429AllOfCodeEnum: APIError429AllOfCodeEnum,
5487
+ APIError500AllOfCodeEnum: APIError500AllOfCodeEnum,
5488
+ ActivitiesApi: ActivitiesApi,
5489
+ ActivitiesApiAxiosParamCreator: ActivitiesApiAxiosParamCreator,
5490
+ ActivitiesApiFactory: ActivitiesApiFactory,
5491
+ ActivitiesApiFp: ActivitiesApiFp,
5492
+ ActivityType: ActivityType,
5493
+ ChainsApi: ChainsApi,
5494
+ ChainsApiAxiosParamCreator: ChainsApiAxiosParamCreator,
5495
+ ChainsApiFactory: ChainsApiFactory,
5496
+ ChainsApiFp: ChainsApiFp,
5497
+ CollectionContractType: CollectionContractType,
5498
+ CollectionsApi: CollectionsApi,
5499
+ CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
5500
+ CollectionsApiFactory: CollectionsApiFactory,
5501
+ CollectionsApiFp: CollectionsApiFp,
5502
+ Configuration: Configuration$2,
5503
+ CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
5504
+ ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
5505
+ ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
5506
+ FeeFeeTypeEnum: FeeFeeTypeEnum,
5507
+ NFTContractType: NFTContractType,
5508
+ NativeItemItemTypeEnum: NativeItemItemTypeEnum,
5509
+ NftOwnersApi: NftOwnersApi,
5510
+ NftOwnersApiAxiosParamCreator: NftOwnersApiAxiosParamCreator,
5511
+ NftOwnersApiFactory: NftOwnersApiFactory,
5512
+ NftOwnersApiFp: NftOwnersApiFp,
5513
+ NftsApi: NftsApi,
5514
+ NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
5515
+ NftsApiFactory: NftsApiFactory,
5516
+ NftsApiFp: NftsApiFp,
5517
+ OrderStatus: OrderStatus$1,
5518
+ OrdersApi: OrdersApi,
5519
+ OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
5520
+ OrdersApiFactory: OrdersApiFactory,
5521
+ OrdersApiFp: OrdersApiFp,
5522
+ PassportApi: PassportApi,
5523
+ PassportApiAxiosParamCreator: PassportApiAxiosParamCreator,
5524
+ PassportApiFactory: PassportApiFactory,
5525
+ PassportApiFp: PassportApiFp,
5526
+ SaleFeeTypeEnum: SaleFeeTypeEnum,
5527
+ TokenContractType: TokenContractType,
5528
+ TokensApi: TokensApi,
5529
+ TokensApiAxiosParamCreator: TokensApiAxiosParamCreator,
5530
+ TokensApiFactory: TokensApiFactory,
5531
+ TokensApiFp: TokensApiFp
2231
5532
  });
2232
5533
 
5534
+ class MultiRollupApiClients {
5535
+ config;
5536
+ activitiesApi;
5537
+ chainsApi;
5538
+ collectionApi;
5539
+ nftOwnersApi;
5540
+ nftsApi;
5541
+ ordersApi;
5542
+ passportApi;
5543
+ constructor(config) {
5544
+ this.config = config;
5545
+ this.activitiesApi = new ActivitiesApi(config.indexer);
5546
+ this.chainsApi = new ChainsApi(config.indexer);
5547
+ this.collectionApi = new CollectionsApi(config.indexer);
5548
+ this.nftOwnersApi = new NftOwnersApi(config.indexer);
5549
+ this.nftsApi = new NftsApi(config.indexer);
5550
+ this.ordersApi = new OrdersApi(config.orderBook);
5551
+ this.passportApi = new PassportApi(config.passport);
5552
+ }
5553
+ }
5554
+
5555
+ // eslint-disable-next-line @typescript-eslint/naming-convention
5556
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.1-alpha' };
5557
+ const createConfig = ({ basePath, headers, }) => {
5558
+ if (!basePath.trim()) {
5559
+ throw Error('basePath can not be empty');
5560
+ }
5561
+ const composedHeaders = { ...defaultHeaders$1, ...(headers || {}) };
5562
+ const apiConfigOptions = {
5563
+ basePath,
5564
+ baseOptions: { headers: composedHeaders },
5565
+ };
5566
+ return new Configuration$1(apiConfigOptions);
5567
+ };
5568
+ /**
5569
+ * Creates a Configuration for the specified environment
5570
+ * @returns an MultiRollupAPIConfiguration
5571
+ */
5572
+ const multiRollupConfig = {
5573
+ getProduction: () => ({
5574
+ indexer: createConfig({
5575
+ basePath: 'https://indexer-mr.imtbl.com',
5576
+ }),
5577
+ orderBook: createConfig({
5578
+ basePath: 'https://order-book-mr.imtbl.com',
5579
+ }),
5580
+ passport: createConfig({
5581
+ basePath: 'https://api.immutable.com',
5582
+ }),
5583
+ }),
5584
+ getSandbox: () => ({
5585
+ indexer: createConfig({
5586
+ basePath: 'https://indexer-mr.sandbox.imtbl.com',
5587
+ }),
5588
+ orderBook: createConfig({
5589
+ basePath: 'https://order-book-mr.sandbox.imtbl.com',
5590
+ }),
5591
+ passport: createConfig({
5592
+ basePath: 'https://api.sandbox.immutable.com',
5593
+ }),
5594
+ }),
5595
+ };
5596
+
2233
5597
  /**
2234
5598
  * Custom Error class that is returned from the API when a request fails
2235
5599
  */
@@ -2249,7 +5613,7 @@ class APIError extends Error {
2249
5613
 
2250
5614
  /* eslint-disable implicit-arrow-linebreak */
2251
5615
  const defaultHeaders = {
2252
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha.2',
5616
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.1-alpha',
2253
5617
  };
2254
5618
  /**
2255
5619
  * createAPIConfiguration to create a custom Configuration
@@ -2305,7 +5669,7 @@ class BlockchainDataConfiguration {
2305
5669
  * @returns APIError
2306
5670
  */
2307
5671
  function formatError(error) {
2308
- if (globalAxios$1.isAxiosError(error) && error.response) {
5672
+ if (axios$2.isAxiosError(error) && error.response) {
2309
5673
  const apiError = error.response.data;
2310
5674
  if (apiError.code && apiError.message) {
2311
5675
  return new APIError({
@@ -2515,7 +5879,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2515
5879
  chainID,
2516
5880
  coreContractAddress,
2517
5881
  registrationContractAddress,
2518
- sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.2',
5882
+ sdkVersion: 'ts-immutable-sdk-0.4.1-alpha',
2519
5883
  });
2520
5884
  /**
2521
5885
  * Sets `sdkVersion` at the time of build
@@ -6471,7 +9835,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
6471
9835
  * @summary Info for a specific transaction
6472
9836
  * @param {string} transactionID The id of the starkex transaction to retrieve
6473
9837
  * @param {'starkex' | 'evm'} chainType roll up type
6474
- * @param {number} [chainID] ID of evm chain
9838
+ * @param {string} [chainID] ID of evm chain
6475
9839
  * @param {*} [options] Override http request option.
6476
9840
  * @throws {RequiredError}
6477
9841
  */
@@ -6546,7 +9910,7 @@ const TransactionsApiFp = function (configuration) {
6546
9910
  * @summary Info for a specific transaction
6547
9911
  * @param {string} transactionID The id of the starkex transaction to retrieve
6548
9912
  * @param {'starkex' | 'evm'} chainType roll up type
6549
- * @param {number} [chainID] ID of evm chain
9913
+ * @param {string} [chainID] ID of evm chain
6550
9914
  * @param {*} [options] Override http request option.
6551
9915
  * @throws {RequiredError}
6552
9916
  */
@@ -6686,6 +10050,24 @@ class Configuration {
6686
10050
  }
6687
10051
  }
6688
10052
 
10053
+ /* tslint:disable */
10054
+ /* eslint-disable */
10055
+ /**
10056
+ * Guardian
10057
+ * Guardian API
10058
+ *
10059
+ * The version of the OpenAPI document: 1.0.0
10060
+ * Contact: support@immutable.com
10061
+ *
10062
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10063
+ * https://openapi-generator.tech
10064
+ * Do not edit the class manually.
10065
+ */
10066
+ const TransactionApprovalRequestChainTypeEnum = {
10067
+ Starkex: 'starkex',
10068
+ Evm: 'evm'
10069
+ };
10070
+
6689
10071
  // used to sign message with L1 keys. Used for registration
6690
10072
  function serializeEthSignature(sig) {
6691
10073
  // This is because golang appends a recovery param
@@ -6793,10 +10175,17 @@ const withPassportError = async (fn, customErrorType) => {
6793
10175
  };
6794
10176
 
6795
10177
  const keyCrendentials = 'passport_credentials';
10178
+ const KEY_PKCE_STATE = 'pkce_state';
10179
+ const KEY_PKCE_VERIFIER = 'pkce_verifier';
6796
10180
  const validCredentialsMinTtlSec = 3600; // 1 hour
6797
10181
  class DeviceCredentialsManager {
6798
10182
  saveCredentials(tokenResponse) {
6799
- localStorage.setItem(keyCrendentials, JSON.stringify(tokenResponse));
10183
+ if (this.areValid(tokenResponse)) {
10184
+ localStorage.setItem(keyCrendentials, JSON.stringify(tokenResponse));
10185
+ }
10186
+ else {
10187
+ throw Error('Invalid credentials.');
10188
+ }
6800
10189
  }
6801
10190
  getCredentials() {
6802
10191
  const credentialsJson = localStorage.getItem(keyCrendentials);
@@ -6814,14 +10203,31 @@ class DeviceCredentialsManager {
6814
10203
  return false;
6815
10204
  }
6816
10205
  isTokenValid(jwt) {
6817
- const tokenPayload = jwt_decode(jwt);
6818
- const expiresAt = tokenPayload.exp ?? 0;
6819
- const now = (Date.now() / 1000) + validCredentialsMinTtlSec;
6820
- return expiresAt > now;
10206
+ try {
10207
+ const tokenPayload = jwt_decode(jwt);
10208
+ const expiresAt = tokenPayload.exp ?? 0;
10209
+ const now = (Date.now() / 1000) + validCredentialsMinTtlSec;
10210
+ return expiresAt > now;
10211
+ }
10212
+ catch (error) {
10213
+ return false;
10214
+ }
6821
10215
  }
6822
10216
  clearCredentials() {
6823
10217
  localStorage.removeItem(keyCrendentials);
6824
10218
  }
10219
+ savePKCEData(data) {
10220
+ localStorage.setItem(KEY_PKCE_STATE, data.state);
10221
+ localStorage.setItem(KEY_PKCE_VERIFIER, data.verifier);
10222
+ }
10223
+ getPKCEData() {
10224
+ const state = localStorage.getItem(KEY_PKCE_STATE);
10225
+ const verifier = localStorage.getItem(KEY_PKCE_VERIFIER);
10226
+ if (state && verifier) {
10227
+ return { state, verifier };
10228
+ }
10229
+ return null;
10230
+ }
6825
10231
  }
6826
10232
 
6827
10233
  const formUrlEncodedHeader = {
@@ -6863,10 +10269,12 @@ class AuthManager {
6863
10269
  userManager;
6864
10270
  config;
6865
10271
  deviceCredentialsManager;
10272
+ logoutMode;
6866
10273
  constructor(config) {
6867
10274
  this.config = config;
6868
10275
  this.userManager = new oidcClientTs.UserManager(getAuthConfiguration(config));
6869
10276
  this.deviceCredentialsManager = new DeviceCredentialsManager();
10277
+ this.logoutMode = config.oidcConfiguration.logoutMode || 'redirect';
6870
10278
  }
6871
10279
  static mapOidcUserToDomainModel = (oidcUser) => {
6872
10280
  const passport = oidcUser.profile?.passport;
@@ -6931,7 +10339,7 @@ class AuthManager {
6931
10339
  }
6932
10340
  async loginWithDeviceFlow() {
6933
10341
  return withPassportError(async () => {
6934
- const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/device/code`, {
10342
+ const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/device/code`, {
6935
10343
  client_id: this.config.oidcConfiguration.clientId,
6936
10344
  scope: this.config.oidcConfiguration.scope,
6937
10345
  audience: this.config.oidcConfiguration.audience,
@@ -6964,7 +10372,7 @@ class AuthManager {
6964
10372
  return user;
6965
10373
  }
6966
10374
  catch (error) {
6967
- if (globalAxios$1.isAxiosError(error)) {
10375
+ if (axios$2.isAxiosError(error)) {
6968
10376
  const responseError = error.response?.data;
6969
10377
  switch (responseError.error) {
6970
10378
  case 'authorization_pending':
@@ -6989,13 +10397,66 @@ class AuthManager {
6989
10397
  }
6990
10398
  /* eslint-enable no-await-in-loop */
6991
10399
  async getDeviceFlowToken(deviceCode) {
6992
- const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
10400
+ const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
6993
10401
  client_id: this.config.oidcConfiguration.clientId,
6994
10402
  grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
6995
10403
  device_code: deviceCode,
6996
10404
  }, formUrlEncodedHeader);
6997
10405
  return response.data;
6998
10406
  }
10407
+ static base64URLEncode(str) {
10408
+ return str.toString('base64')
10409
+ .replace(/\+/g, '-')
10410
+ .replace(/\//g, '_')
10411
+ .replace(/=/g, '');
10412
+ }
10413
+ static sha256(buffer) {
10414
+ return crypto__namespace.createHash('sha256').update(buffer).digest();
10415
+ }
10416
+ getPKCEAuthorizationUrl() {
10417
+ const verifier = AuthManager.base64URLEncode(crypto__namespace.randomBytes(32));
10418
+ const challenge = AuthManager.base64URLEncode(AuthManager.sha256(verifier));
10419
+ // https://auth0.com/docs/secure/attack-protection/state-parameters
10420
+ const state = AuthManager.base64URLEncode(crypto__namespace.randomBytes(32));
10421
+ this.deviceCredentialsManager.savePKCEData({ state, verifier });
10422
+ return `${this.config.authenticationDomain}/authorize?`
10423
+ + 'response_type=code'
10424
+ + `&code_challenge=${challenge}`
10425
+ + '&code_challenge_method=S256'
10426
+ + `&client_id=${this.config.oidcConfiguration.clientId}`
10427
+ + `&redirect_uri=${this.config.oidcConfiguration.redirectUri}`
10428
+ + `&scope=${this.config.oidcConfiguration.scope}`
10429
+ + `&state=${state}`
10430
+ + `&audience=${this.config.oidcConfiguration.audience}`;
10431
+ }
10432
+ async connectImxPKCEFlow(authorizationCode, state) {
10433
+ return withPassportError(async () => {
10434
+ const pkceData = this.deviceCredentialsManager.getPKCEData();
10435
+ if (!pkceData) {
10436
+ throw new Error('No code verifier or state for PKCE');
10437
+ }
10438
+ if (state !== pkceData.state) {
10439
+ throw new Error('Provided state does not match stored state');
10440
+ }
10441
+ const tokenResponse = await this.getPKCEToken(authorizationCode, pkceData.verifier);
10442
+ const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
10443
+ // Only persist credentials that contain the necessary data
10444
+ if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
10445
+ this.deviceCredentialsManager.saveCredentials(tokenResponse);
10446
+ }
10447
+ return user;
10448
+ }, PassportErrorType.AUTHENTICATION_ERROR);
10449
+ }
10450
+ async getPKCEToken(authorizationCode, codeVerifier) {
10451
+ const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
10452
+ client_id: this.config.oidcConfiguration.clientId,
10453
+ grant_type: 'authorization_code',
10454
+ code_verifier: codeVerifier,
10455
+ code: authorizationCode,
10456
+ redirect_uri: this.config.oidcConfiguration.redirectUri,
10457
+ }, formUrlEncodedHeader);
10458
+ return response.data;
10459
+ }
6999
10460
  async connectImxWithCredentials(tokenResponse) {
7000
10461
  return withPassportError(async () => {
7001
10462
  if (this.deviceCredentialsManager.areValid(tokenResponse)) {
@@ -7012,7 +10473,7 @@ class AuthManager {
7012
10473
  }, PassportErrorType.AUTHENTICATION_ERROR);
7013
10474
  }
7014
10475
  async refreshToken(refreshToken) {
7015
- const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
10476
+ const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
7016
10477
  client_id: this.config.oidcConfiguration.clientId,
7017
10478
  grant_type: 'refresh_token',
7018
10479
  refresh_token: refreshToken,
@@ -7020,7 +10481,15 @@ class AuthManager {
7020
10481
  return response.data;
7021
10482
  }
7022
10483
  async logout() {
7023
- return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
10484
+ return withPassportError(async () => {
10485
+ if (this.logoutMode === 'silent') {
10486
+ return this.userManager.signoutSilent();
10487
+ }
10488
+ return this.userManager.signoutRedirect();
10489
+ }, PassportErrorType.LOGOUT_ERROR);
10490
+ }
10491
+ async logoutSilentCallback(url) {
10492
+ return this.userManager.signoutSilentCallback(url);
7024
10493
  }
7025
10494
  async logoutDeviceFlow() {
7026
10495
  return withPassportError(async () => {
@@ -7116,6 +10585,53 @@ const retryWithDelay = async (fn, options) => {
7116
10585
  }
7117
10586
  };
7118
10587
 
10588
+ /**
10589
+ * ProviderErrors should take priority over RpcErrorCodes
10590
+ */
10591
+ exports.ProviderErrorCode = void 0;
10592
+ (function (ProviderErrorCode) {
10593
+ ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
10594
+ ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
10595
+ ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
10596
+ ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
10597
+ })(exports.ProviderErrorCode || (exports.ProviderErrorCode = {}));
10598
+ exports.RpcErrorCode = void 0;
10599
+ (function (RpcErrorCode) {
10600
+ RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
10601
+ RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
10602
+ RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
10603
+ RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
10604
+ RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
10605
+ RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
10606
+ RpcErrorCode[RpcErrorCode["USER_REJECTED_REQUEST"] = -32003] = "USER_REJECTED_REQUEST";
10607
+ })(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
10608
+ class JsonRpcError extends Error {
10609
+ message;
10610
+ code;
10611
+ constructor(code, message) {
10612
+ super(message);
10613
+ this.message = message;
10614
+ this.code = code;
10615
+ }
10616
+ }
10617
+
10618
+ const convertBigNumberishToString = (value) => ethers.BigNumber.from(value).toString();
10619
+ const transformGuardianTransactions = (txs) => {
10620
+ try {
10621
+ return txs.map((t) => ({
10622
+ delegateCall: t.delegateCall === true,
10623
+ revertOnError: t.revertOnError === true,
10624
+ gasLimit: t.gasLimit ? convertBigNumberishToString(t.gasLimit) : '0',
10625
+ target: t.to ?? ethers.ethers.constants.AddressZero,
10626
+ value: t.value ? convertBigNumberishToString(t.value) : '0',
10627
+ data: t.data ? t.data.toString() : '0x00',
10628
+ }));
10629
+ }
10630
+ catch (error) {
10631
+ const errorMessage = (error instanceof Error) ? error.message : String(error);
10632
+ throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
10633
+ }
10634
+ };
7119
10635
  class GuardianClient {
7120
10636
  transactionAPI;
7121
10637
  confirmationScreen;
@@ -7150,7 +10666,7 @@ class GuardianClient {
7150
10666
  });
7151
10667
  const { confirmationRequired } = evaluateStarkexRes.data;
7152
10668
  if (confirmationRequired) {
7153
- const confirmationResult = await this.confirmationScreen.startGuardianTransaction(payloadHash, this.imxEtherAddress);
10669
+ const confirmationResult = await this.confirmationScreen.startGuardianTransaction(payloadHash, this.imxEtherAddress, TransactionApprovalRequestChainTypeEnum.Starkex);
7154
10670
  if (!confirmationResult.confirmed) {
7155
10671
  throw new Error('Transaction rejected by user');
7156
10672
  }
@@ -7159,6 +10675,47 @@ class GuardianClient {
7159
10675
  this.confirmationScreen.closeWindow();
7160
10676
  }
7161
10677
  }
10678
+ async evaluateEVMTransaction({ chainId, nonce, user, metaTransactions, }) {
10679
+ const headers = { Authorization: `Bearer ${user.accessToken}` };
10680
+ const guardianTransactions = transformGuardianTransactions(metaTransactions);
10681
+ try {
10682
+ const transactionEvaluationResponseAxiosResponse = await this.transactionAPI.evaluateTransaction({
10683
+ id: 'evm',
10684
+ transactionEvaluationRequest: {
10685
+ chainType: 'evm',
10686
+ chainId,
10687
+ transactionData: {
10688
+ nonce,
10689
+ userAddress: user.zkEvm.ethAddress,
10690
+ metaTransactions: guardianTransactions,
10691
+ },
10692
+ },
10693
+ }, { headers });
10694
+ return transactionEvaluationResponseAxiosResponse.data;
10695
+ }
10696
+ catch (error) {
10697
+ const errorMessage = (error instanceof Error) ? error.message : String(error);
10698
+ throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
10699
+ }
10700
+ }
10701
+ async validateEVMTransaction({ chainId, nonce, user, metaTransactions, }) {
10702
+ const transactionEvaluationResponse = await this.evaluateEVMTransaction({
10703
+ chainId,
10704
+ nonce,
10705
+ user,
10706
+ metaTransactions,
10707
+ });
10708
+ const { confirmationRequired, transactionId } = transactionEvaluationResponse;
10709
+ if (confirmationRequired && !!transactionId) {
10710
+ const confirmationResult = await this.confirmationScreen.startGuardianTransaction(transactionId, this.imxEtherAddress, TransactionApprovalRequestChainTypeEnum.Evm, chainId);
10711
+ if (!confirmationResult.confirmed) {
10712
+ throw new JsonRpcError(exports.RpcErrorCode.USER_REJECTED_REQUEST, 'Transaction rejected by user ');
10713
+ }
10714
+ }
10715
+ else {
10716
+ this.confirmationScreen.closeWindow();
10717
+ }
10718
+ }
7162
10719
  }
7163
10720
 
7164
10721
  async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, }) {
@@ -7223,6 +10780,7 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
7223
10780
  amount_sell: amountSell,
7224
10781
  token_sell: convertToSignableToken(request.sell),
7225
10782
  fees: request.fees,
10783
+ split_fees: true,
7226
10784
  expiration_timestamp: request.expiration_timestamp,
7227
10785
  };
7228
10786
  const getSignableOrderResponse = await ordersApi.getSignableOrder({
@@ -7596,6 +11154,10 @@ class PassportImxProviderFactory {
7596
11154
  const user = await this.authManager.connectImxDeviceFlow(deviceCode, interval, timeoutMs);
7597
11155
  return this.createProviderInstance(user);
7598
11156
  }
11157
+ async getProviderWithPKCEFlow(authorizationCode, state) {
11158
+ const user = await this.authManager.connectImxPKCEFlow(authorizationCode, state);
11159
+ return this.createProviderInstance(user);
11160
+ }
7599
11161
  async getProviderWithCredentials(tokenResponse) {
7600
11162
  const user = await this.authManager.connectImxWithCredentials(tokenResponse);
7601
11163
  if (!user) {
@@ -7677,6 +11239,10 @@ class PassportConfiguration {
7677
11239
  magicProviderId;
7678
11240
  oidcConfiguration;
7679
11241
  baseConfig;
11242
+ zkEvmChainId;
11243
+ zkEvmRpcUrl;
11244
+ relayerUrl;
11245
+ multiRollupConfig;
7680
11246
  constructor({ baseConfig, overrides, ...oidcConfiguration }) {
7681
11247
  validateConfiguration(oidcConfiguration, [
7682
11248
  'clientId',
@@ -7689,10 +11255,16 @@ class PassportConfiguration {
7689
11255
  validateConfiguration(overrides, [
7690
11256
  'network',
7691
11257
  'authenticationDomain',
11258
+ 'passportDomain',
7692
11259
  'magicPublishableApiKey',
7693
11260
  'magicProviderId',
7694
- 'passportDomain',
11261
+ 'zkEvmRpcUrl',
11262
+ 'zkEvmChainId',
11263
+ 'relayerUrl',
7695
11264
  'imxPublicApiDomain',
11265
+ 'indexerMrBasePath',
11266
+ 'orderBookMrBasePath',
11267
+ 'passportMrBasePath',
7696
11268
  ], 'overrides');
7697
11269
  this.network = overrides.network;
7698
11270
  this.authenticationDomain = overrides.authenticationDomain;
@@ -7700,6 +11272,20 @@ class PassportConfiguration {
7700
11272
  this.imxPublicApiDomain = overrides.imxPublicApiDomain;
7701
11273
  this.magicPublishableApiKey = overrides.magicPublishableApiKey;
7702
11274
  this.magicProviderId = overrides.magicProviderId;
11275
+ this.zkEvmRpcUrl = overrides.zkEvmRpcUrl;
11276
+ this.zkEvmChainId = overrides.zkEvmChainId;
11277
+ this.relayerUrl = overrides.relayerUrl;
11278
+ this.multiRollupConfig = {
11279
+ indexer: createConfig({
11280
+ basePath: overrides.indexerMrBasePath,
11281
+ }),
11282
+ orderBook: createConfig({
11283
+ basePath: overrides.orderBookMrBasePath,
11284
+ }),
11285
+ passport: createConfig({
11286
+ basePath: overrides.passportMrBasePath,
11287
+ }),
11288
+ };
7703
11289
  }
7704
11290
  else {
7705
11291
  switch (baseConfig.environment) {
@@ -7710,6 +11296,10 @@ class PassportConfiguration {
7710
11296
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
7711
11297
  this.passportDomain = 'https://passport.immutable.com';
7712
11298
  this.imxPublicApiDomain = 'https://api.immutable.com';
11299
+ this.zkEvmRpcUrl = ''; // TODO: ID-785 Update once mainnet has been deployed
11300
+ this.zkEvmChainId = ''; // TODO: ID-785 Update once mainnet has been deployed
11301
+ this.relayerUrl = 'https://api.immutable.com/relayer-mr';
11302
+ this.multiRollupConfig = multiRollupConfig.getProduction();
7713
11303
  break;
7714
11304
  }
7715
11305
  case exports.Environment.SANDBOX:
@@ -7720,6 +11310,10 @@ class PassportConfiguration {
7720
11310
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
7721
11311
  this.passportDomain = 'https://passport.sandbox.immutable.com';
7722
11312
  this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
11313
+ this.zkEvmRpcUrl = 'https://zkevm-rpc.sandbox.x.immutable.com';
11314
+ this.zkEvmChainId = 'eip155:13392';
11315
+ this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
11316
+ this.multiRollupConfig = multiRollupConfig.getSandbox();
7723
11317
  break;
7724
11318
  }
7725
11319
  }
@@ -7827,7 +11421,7 @@ class ConfirmationScreen {
7827
11421
  }, CONFIRMATION_WINDOW_CLOSED_POLLING_DURATION);
7828
11422
  });
7829
11423
  }
7830
- startGuardianTransaction(transactionId, imxEtherAddress) {
11424
+ startGuardianTransaction(transactionId, imxEtherAddress, chainType, chainId) {
7831
11425
  return new Promise((resolve, reject) => {
7832
11426
  const messageHandler = ({ data, origin }) => {
7833
11427
  if (origin !== this.config.passportDomain
@@ -7856,7 +11450,16 @@ class ConfirmationScreen {
7856
11450
  return;
7857
11451
  }
7858
11452
  // eslint-disable-next-line max-len
7859
- this.confirmationWindow.location.href = `${this.config.passportDomain}/transaction-confirmation/transaction.html?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
11453
+ let href = '';
11454
+ if (chainType === TransactionApprovalRequestChainTypeEnum.Starkex) {
11455
+ // eslint-disable-next-line max-len
11456
+ href = `${this.config.passportDomain}/transaction-confirmation/transaction.html?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
11457
+ }
11458
+ else {
11459
+ // eslint-disable-next-line max-len
11460
+ href = `${this.config.passportDomain}/transaction-confirmation/zkevm?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=evm&chainId=${chainId}`;
11461
+ }
11462
+ this.confirmationWindow.location.href = href;
7860
11463
  // https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
7861
11464
  const timer = setInterval(() => {
7862
11465
  if (this.confirmationWindow?.closed) {
@@ -7880,6 +11483,476 @@ class ConfirmationScreen {
7880
11483
  }
7881
11484
  }
7882
11485
 
11486
+ var RelayerTransactionStatus;
11487
+ (function (RelayerTransactionStatus) {
11488
+ RelayerTransactionStatus["PENDING"] = "PENDING";
11489
+ RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
11490
+ RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
11491
+ RelayerTransactionStatus["REVERTED"] = "REVERTED";
11492
+ RelayerTransactionStatus["FAILED"] = "FAILED";
11493
+ })(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
11494
+ exports.ProviderEvent = void 0;
11495
+ (function (ProviderEvent) {
11496
+ ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
11497
+ })(exports.ProviderEvent || (exports.ProviderEvent = {}));
11498
+
11499
+ class TypedEventEmitter {
11500
+ emitter = new events.EventEmitter();
11501
+ emit(eventName, ...eventArg) {
11502
+ this.emitter.emit(eventName, ...eventArg);
11503
+ }
11504
+ on(eventName, handler) {
11505
+ this.emitter.on(eventName, handler);
11506
+ }
11507
+ removeListener(eventName, handler) {
11508
+ this.emitter.removeListener(eventName, handler);
11509
+ }
11510
+ }
11511
+
11512
+ class RelayerClient {
11513
+ config;
11514
+ constructor({ config }) {
11515
+ this.config = config;
11516
+ }
11517
+ async postToRelayer(request) {
11518
+ const body = {
11519
+ id: 1,
11520
+ jsonrpc: '2.0',
11521
+ ...request,
11522
+ };
11523
+ const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
11524
+ method: 'POST',
11525
+ headers: {
11526
+ 'Content-Type': 'application/json',
11527
+ },
11528
+ body: JSON.stringify(body),
11529
+ });
11530
+ const jsonResponse = await response.json();
11531
+ if (jsonResponse.error) {
11532
+ throw jsonResponse.error;
11533
+ }
11534
+ return jsonResponse;
11535
+ }
11536
+ async ethSendTransaction(to, data) {
11537
+ const payload = {
11538
+ method: 'eth_sendTransaction',
11539
+ params: [{
11540
+ to,
11541
+ data,
11542
+ chainId: this.config.zkEvmChainId.toString(),
11543
+ }],
11544
+ };
11545
+ const { result } = await this.postToRelayer(payload);
11546
+ return result;
11547
+ }
11548
+ async imGetTransactionByHash(hash) {
11549
+ const payload = {
11550
+ method: 'im_getTransactionByHash',
11551
+ params: [hash],
11552
+ };
11553
+ const { result } = await this.postToRelayer(payload);
11554
+ return result;
11555
+ }
11556
+ async imGetFeeOptions(userAddress, data) {
11557
+ const payload = {
11558
+ method: 'im_getFeeOptions',
11559
+ params: [{
11560
+ userAddress,
11561
+ data,
11562
+ chainId: this.config.zkEvmChainId.toString(),
11563
+ }],
11564
+ };
11565
+ const { result } = await this.postToRelayer(payload);
11566
+ return result;
11567
+ }
11568
+ }
11569
+
11570
+ const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
11571
+ async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
11572
+ const web3Provider = new providers.Web3Provider(magicProvider);
11573
+ const ethSigner = web3Provider.getSigner();
11574
+ const ethereumAddress = await ethSigner.getAddress();
11575
+ const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
11576
+ const headers = { Authorization: `Bearer ${accessToken}` };
11577
+ try {
11578
+ await multiRollupApiClients.passportApi.createCounterfactualAddress({
11579
+ createCounterfactualAddressRequest: {
11580
+ ethereumAddress,
11581
+ ethereumSignature,
11582
+ },
11583
+ }, { headers });
11584
+ }
11585
+ catch (error) {
11586
+ throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
11587
+ }
11588
+ const user = await authManager.loginSilent();
11589
+ if (!user?.zkEvm) {
11590
+ throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
11591
+ }
11592
+ return user;
11593
+ }
11594
+
11595
+ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
11596
+ const user = await authManager.getUser() || await authManager.login();
11597
+ if (!user.idToken) {
11598
+ throw new Error('User is missing idToken');
11599
+ }
11600
+ const magicProvider = await magicAdapter.login(user.idToken, config.network);
11601
+ if (!user.zkEvm) {
11602
+ // Generate counterfactual address and retrieve updated Auth0 user
11603
+ const userZkevm = await registerZkEvmUser({
11604
+ authManager,
11605
+ magicProvider,
11606
+ multiRollupApiClients,
11607
+ accessToken: user.accessToken,
11608
+ });
11609
+ return {
11610
+ user: userZkevm,
11611
+ magicProvider,
11612
+ };
11613
+ }
11614
+ return {
11615
+ user: user,
11616
+ magicProvider,
11617
+ };
11618
+ };
11619
+
11620
+ // These are ignored by the Relayer but for consistency we set them to the
11621
+ // appropriate values for a 1/1 wallet.
11622
+ //
11623
+ // Weight of a single signature in the multisig
11624
+ const SIGNATURE_WEIGHT = 1;
11625
+ // Total required weight in the multisig
11626
+ const SIGNATURE_THRESHOLD = 1;
11627
+ const ETH_SIGN_FLAG = '02';
11628
+ const ETH_SIGN_PREFIX = '\x19\x01';
11629
+ const META_TRANSACTIONS_TYPE = `tuple(
11630
+ bool delegateCall,
11631
+ bool revertOnError,
11632
+ uint256 gasLimit,
11633
+ address target,
11634
+ uint256 value,
11635
+ bytes data
11636
+ )[]`;
11637
+ function getNormalisedTransactions(txs) {
11638
+ return txs.map((t) => ({
11639
+ delegateCall: t.delegateCall === true,
11640
+ revertOnError: t.revertOnError === true,
11641
+ gasLimit: t.gasLimit ?? ethers.ethers.constants.Zero,
11642
+ target: t.to ?? ethers.ethers.constants.AddressZero,
11643
+ value: t.value ?? ethers.ethers.constants.Zero,
11644
+ data: t.data ?? [],
11645
+ }));
11646
+ }
11647
+ function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
11648
+ const packMetaTransactionsNonceData = ethers.ethers.utils.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
11649
+ return ethers.ethers.utils.keccak256(packMetaTransactionsNonceData);
11650
+ }
11651
+ const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
11652
+ const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress, 'latest']);
11653
+ if (code && code !== '0x') {
11654
+ const contract = new ethers.ethers.Contract(smartContractWalletAddress, abi.walletContracts.mainModule.abi, jsonRpcProvider);
11655
+ return contract.nonce();
11656
+ }
11657
+ return 0;
11658
+ };
11659
+ const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
11660
+ const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
11661
+ // Get the hash
11662
+ const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
11663
+ const completePayload = ethers.ethers.utils.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]);
11664
+ const hash = ethers.ethers.utils.keccak256(completePayload);
11665
+ // Sign the digest
11666
+ const hashArray = ethers.ethers.utils.arrayify(hash);
11667
+ const ethsigNoType = await signer.signMessage(hashArray);
11668
+ const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
11669
+ // Add metadata
11670
+ const encodedSignature = config.encodeSignature({
11671
+ threshold: SIGNATURE_THRESHOLD,
11672
+ signers: [
11673
+ {
11674
+ weight: SIGNATURE_WEIGHT,
11675
+ signature: signedDigest,
11676
+ },
11677
+ ],
11678
+ });
11679
+ // Encode the transaction;
11680
+ const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
11681
+ return walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
11682
+ normalisedMetaTransactions,
11683
+ nonce,
11684
+ encodedSignature,
11685
+ ]);
11686
+ };
11687
+ const chainIdNumber = (chainId) => {
11688
+ const caip2Components = chainId.split(':');
11689
+ if (caip2Components.length !== 2) {
11690
+ throw new Error('Invalid configuration, chain ID is not in CAIP-2 format');
11691
+ }
11692
+ return ethers.BigNumber.from(caip2Components[1]);
11693
+ };
11694
+
11695
+ const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
11696
+ const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
11697
+ const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, config, user, }) => {
11698
+ const popupWindowSize = { width: 480, height: 580 };
11699
+ guardianClient.loading(popupWindowSize);
11700
+ const transactionRequest = params[0];
11701
+ if (!transactionRequest.to) {
11702
+ throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
11703
+ }
11704
+ const chainId = chainIdNumber(config.zkEvmChainId);
11705
+ const magicWeb3Provider = new providers.Web3Provider(magicProvider);
11706
+ const signer = magicWeb3Provider.getSigner();
11707
+ const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
11708
+ const metaTransaction = {
11709
+ to: transactionRequest.to,
11710
+ data: transactionRequest.data,
11711
+ nonce,
11712
+ value: transactionRequest.value,
11713
+ revertOnError: true,
11714
+ };
11715
+ // NOTE: We sign the transaction before getting the fee options because
11716
+ // accurate estimation of a transaction gas cost is only possible if the smart
11717
+ // wallet contract can actually execute it (in a simulated environment) - and
11718
+ // it can only execute signed transactions.
11719
+ const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
11720
+ // TODO: ID-698 Add support for non-native gas payments (e.g ERC20, feeTransaction initialisation must change)
11721
+ // NOTE: "Fee Options" represent the multiple ways we could pay for the gas
11722
+ // used in this transaction. Each fee option has a "recipientAddress" we
11723
+ // should transfer the payment to, an amount and a currency. We choose one
11724
+ // option and build a transaction that sends the expected currency amount for
11725
+ // that option to the specified address.
11726
+ const feeOptions = await relayerClient.imGetFeeOptions(user.zkEvm.ethAddress, signedTransaction);
11727
+ const imxFeeOption = feeOptions.find((feeOption) => feeOption.tokenSymbol === 'IMX');
11728
+ if (!imxFeeOption) {
11729
+ throw new Error('Failed to retrieve fees for IMX token');
11730
+ }
11731
+ const feeMetaTransaction = {
11732
+ nonce,
11733
+ to: imxFeeOption.recipientAddress,
11734
+ value: imxFeeOption.tokenPrice,
11735
+ revertOnError: true,
11736
+ };
11737
+ await guardianClient.validateEVMTransaction({
11738
+ chainId: config.zkEvmChainId,
11739
+ nonce: convertBigNumberishToString(nonce),
11740
+ user,
11741
+ metaTransactions: [metaTransaction, feeMetaTransaction],
11742
+ });
11743
+ // NOTE: We sign again because we now are adding the fee transaction, so the
11744
+ // whole payload is different and needs a new signature.
11745
+ const signedTransactions = await getSignedMetaTransactions([metaTransaction, feeMetaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
11746
+ // TODO: ID-697 Evaluate transactions through Guardian
11747
+ const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
11748
+ const retrieveRelayerTransaction = async () => {
11749
+ const tx = await relayerClient.imGetTransactionByHash(relayerId);
11750
+ // NOTE: The transaction hash is only available from the Relayer once the
11751
+ // transaction is actually submitted onchain. Hence we need to poll the
11752
+ // Relayer get transaction endpoint until the status transitions to one that
11753
+ // has the hash available.
11754
+ if (tx.status === RelayerTransactionStatus.PENDING) {
11755
+ throw new Error();
11756
+ }
11757
+ return tx;
11758
+ };
11759
+ const relayerTransaction = await retryWithDelay(retrieveRelayerTransaction, {
11760
+ retries: MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES,
11761
+ interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
11762
+ finalErr: new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
11763
+ });
11764
+ if (![RelayerTransactionStatus.SUBMITTED, RelayerTransactionStatus.SUCCESSFUL].includes(relayerTransaction.status)) {
11765
+ throw new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
11766
+ }
11767
+ return relayerTransaction.hash;
11768
+ };
11769
+
11770
+ class ZkEvmProvider {
11771
+ authManager;
11772
+ config;
11773
+ confirmationScreen;
11774
+ magicAdapter;
11775
+ relayerClient;
11776
+ transactionAPI;
11777
+ multiRollupApiClients;
11778
+ jsonRpcProvider; // Used for read
11779
+ eventEmitter;
11780
+ magicProvider; // Used for signing
11781
+ user;
11782
+ constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
11783
+ this.authManager = authManager;
11784
+ this.magicAdapter = magicAdapter;
11785
+ this.config = config;
11786
+ this.confirmationScreen = confirmationScreen;
11787
+ this.relayerClient = new RelayerClient({ config });
11788
+ this.transactionAPI = new TransactionsApi(new Configuration({
11789
+ basePath: this.config.imxPublicApiDomain,
11790
+ }));
11791
+ this.jsonRpcProvider = new providers.JsonRpcProvider(this.config.zkEvmRpcUrl);
11792
+ this.multiRollupApiClients = multiRollupApiClients;
11793
+ this.eventEmitter = new TypedEventEmitter();
11794
+ }
11795
+ isLoggedIn() {
11796
+ return this.magicProvider !== undefined && this.user !== undefined;
11797
+ }
11798
+ async performRequest(request) {
11799
+ switch (request.method) {
11800
+ case 'eth_requestAccounts': {
11801
+ if (this.isLoggedIn()) {
11802
+ return [this.user.zkEvm.ethAddress];
11803
+ }
11804
+ const { magicProvider, user } = await loginZkEvmUser({
11805
+ authManager: this.authManager,
11806
+ config: this.config,
11807
+ magicAdapter: this.magicAdapter,
11808
+ multiRollupApiClients: this.multiRollupApiClients,
11809
+ });
11810
+ this.user = user;
11811
+ this.magicProvider = magicProvider;
11812
+ this.eventEmitter.emit(exports.ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
11813
+ return [this.user.zkEvm.ethAddress];
11814
+ }
11815
+ case 'eth_sendTransaction': {
11816
+ if (!this.isLoggedIn()) {
11817
+ throw new JsonRpcError(exports.ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
11818
+ }
11819
+ const guardianClient = new GuardianClient({
11820
+ imxPublicApiDomain: this.config.imxPublicApiDomain,
11821
+ accessToken: this.user.accessToken,
11822
+ confirmationScreen: this.confirmationScreen,
11823
+ imxEtherAddress: this.user?.imx?.ethAddress || '',
11824
+ });
11825
+ return sendTransaction({
11826
+ params: request.params || [],
11827
+ magicProvider: this.magicProvider,
11828
+ guardianClient,
11829
+ jsonRpcProvider: this.jsonRpcProvider,
11830
+ config: this.config,
11831
+ relayerClient: this.relayerClient,
11832
+ user: this.user,
11833
+ });
11834
+ }
11835
+ case 'eth_accounts': {
11836
+ return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
11837
+ }
11838
+ // Pass through methods
11839
+ case 'eth_gasPrice':
11840
+ case 'eth_getBalance':
11841
+ case 'eth_getStorageAt':
11842
+ case 'eth_estimateGas':
11843
+ case 'eth_call':
11844
+ case 'eth_blockNumber':
11845
+ case 'eth_chainId':
11846
+ case 'eth_getBlockByHash':
11847
+ case 'eth_getBlockByNumber':
11848
+ case 'eth_getTransactionByHash':
11849
+ case 'eth_getTransactionReceipt':
11850
+ case 'eth_getTransactionCount': {
11851
+ return this.jsonRpcProvider.send(request.method, request.params || []);
11852
+ }
11853
+ default: {
11854
+ throw new JsonRpcError(exports.ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
11855
+ }
11856
+ }
11857
+ }
11858
+ async performJsonRpcRequest(request) {
11859
+ const { id, jsonrpc } = request;
11860
+ try {
11861
+ const result = await this.performRequest(request);
11862
+ return {
11863
+ id,
11864
+ jsonrpc,
11865
+ result,
11866
+ };
11867
+ }
11868
+ catch (error) {
11869
+ let jsonRpcError;
11870
+ if (error instanceof JsonRpcError) {
11871
+ jsonRpcError = error;
11872
+ }
11873
+ else if (error instanceof Error) {
11874
+ jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
11875
+ }
11876
+ else {
11877
+ jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
11878
+ }
11879
+ return {
11880
+ id,
11881
+ jsonrpc,
11882
+ error: jsonRpcError,
11883
+ };
11884
+ }
11885
+ }
11886
+ async request(request) {
11887
+ try {
11888
+ return this.performRequest(request);
11889
+ }
11890
+ catch (error) {
11891
+ if (error instanceof JsonRpcError) {
11892
+ throw error;
11893
+ }
11894
+ if (error instanceof Error) {
11895
+ throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
11896
+ }
11897
+ throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
11898
+ }
11899
+ }
11900
+ sendAsync(request, callback) {
11901
+ if (!callback) {
11902
+ throw new Error('No callback provided');
11903
+ }
11904
+ if (Array.isArray(request)) {
11905
+ Promise.all(request.map(this.performJsonRpcRequest)).then((result) => {
11906
+ callback(null, result);
11907
+ }).catch((error) => {
11908
+ callback(error, []);
11909
+ });
11910
+ }
11911
+ else {
11912
+ this.performJsonRpcRequest(request).then((result) => {
11913
+ callback(null, result);
11914
+ }).catch((error) => {
11915
+ callback(error, null);
11916
+ });
11917
+ }
11918
+ }
11919
+ async send(request, callbackOrParams, callback) {
11920
+ // Web3 >= 1.0.0-beta.38 calls `send` with method and parameters.
11921
+ if (typeof request === 'string') {
11922
+ if (typeof callbackOrParams === 'function') {
11923
+ return this.sendAsync({
11924
+ method: request,
11925
+ params: [],
11926
+ }, callbackOrParams);
11927
+ }
11928
+ if (callback) {
11929
+ return this.sendAsync({
11930
+ method: request,
11931
+ params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
11932
+ }, callback);
11933
+ }
11934
+ return this.request({
11935
+ method: request,
11936
+ params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
11937
+ });
11938
+ }
11939
+ // Web3 <= 1.0.0-beta.37 uses `send` with a callback for async queries.
11940
+ if (typeof callbackOrParams === 'function') {
11941
+ return this.sendAsync(request, callbackOrParams);
11942
+ }
11943
+ if (!Array.isArray(request) && typeof request === 'object') {
11944
+ return this.performJsonRpcRequest(request);
11945
+ }
11946
+ throw new JsonRpcError(exports.RpcErrorCode.INVALID_REQUEST, 'Invalid request');
11947
+ }
11948
+ on(event, listener) {
11949
+ this.eventEmitter.on(event, listener);
11950
+ }
11951
+ removeListener(event, listener) {
11952
+ this.eventEmitter.removeListener(event, listener);
11953
+ }
11954
+ }
11955
+
7883
11956
  class Passport {
7884
11957
  authManager;
7885
11958
  config;
@@ -7887,6 +11960,7 @@ class Passport {
7887
11960
  immutableXClient;
7888
11961
  magicAdapter;
7889
11962
  passportImxProviderFactory;
11963
+ multiRollupApiClients;
7890
11964
  constructor(passportModuleConfiguration) {
7891
11965
  this.config = new PassportConfiguration(passportModuleConfiguration);
7892
11966
  this.authManager = new AuthManager(this.config);
@@ -7896,6 +11970,7 @@ class Passport {
7896
11970
  || new ImmutableXClient({
7897
11971
  baseConfig: passportModuleConfiguration.baseConfig,
7898
11972
  });
11973
+ this.multiRollupApiClients = new MultiRollupApiClients(this.config.multiRollupConfig);
7899
11974
  this.passportImxProviderFactory = new PassportImxProviderFactory({
7900
11975
  authManager: this.authManager,
7901
11976
  config: this.config,
@@ -7916,6 +11991,12 @@ class Passport {
7916
11991
  async connectImxDeviceFlow(deviceCode, interval, timeoutMs) {
7917
11992
  return this.passportImxProviderFactory.getProviderWithDeviceFlow(deviceCode, interval, timeoutMs);
7918
11993
  }
11994
+ getPKCEAuthorizationUrl() {
11995
+ return this.authManager.getPKCEAuthorizationUrl();
11996
+ }
11997
+ async connectImxPKCEFlow(authorizationCode, state) {
11998
+ return this.passportImxProviderFactory.getProviderWithPKCEFlow(authorizationCode, state);
11999
+ }
7919
12000
  /**
7920
12001
  * @returns {boolean} the stored device flow credentials if they exist
7921
12002
  */
@@ -7925,12 +12006,29 @@ class Passport {
7925
12006
  async connectImxWithCredentials(tokenResponse) {
7926
12007
  return this.passportImxProviderFactory.getProviderWithCredentials(tokenResponse);
7927
12008
  }
12009
+ // TODO ID-926 Make method public once development has been finalised
12010
+ connectEvm() {
12011
+ return new ZkEvmProvider({
12012
+ authManager: this.authManager,
12013
+ magicAdapter: this.magicAdapter,
12014
+ config: this.config,
12015
+ confirmationScreen: this.confirmationScreen,
12016
+ multiRollupApiClients: this.multiRollupApiClients,
12017
+ });
12018
+ }
7928
12019
  async loginCallback() {
7929
12020
  return this.authManager.loginCallback();
7930
12021
  }
7931
12022
  async logout() {
7932
12023
  return this.authManager.logout();
7933
12024
  }
12025
+ /**
12026
+ * This method should only be called from the logout redirect uri
12027
+ * when logout mode is 'silent'.
12028
+ */
12029
+ async logoutSilentCallback(url) {
12030
+ return this.authManager.logoutSilentCallback(url);
12031
+ }
7934
12032
  async logoutDeviceFlow() {
7935
12033
  return this.authManager.logoutDeviceFlow();
7936
12034
  }
@@ -8231,7 +12329,7 @@ const getRequestBody = (options) => {
8231
12329
  return undefined;
8232
12330
  };
8233
12331
  const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
8234
- const source = globalAxios$1.CancelToken.source();
12332
+ const source = axios$2.CancelToken.source();
8235
12333
  const requestConfig = {
8236
12334
  url,
8237
12335
  headers,
@@ -8242,7 +12340,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
8242
12340
  };
8243
12341
  onCancel(() => source.cancel('The user aborted a request.'));
8244
12342
  try {
8245
- return await globalAxios$1.request(requestConfig);
12343
+ return await axios$2.request(requestConfig);
8246
12344
  }
8247
12345
  catch (error) {
8248
12346
  const axiosError = error;
@@ -8847,31 +12945,25 @@ class ImmutableApiClientFactory {
8847
12945
  }
8848
12946
  }
8849
12947
 
8850
- const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
8851
12948
  const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
8852
12949
  const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
8853
- function getOrderbookConfig(chainName) {
8854
- switch (chainName) {
8855
- case DEVNET_CHAIN_NAME:
12950
+ function getOrderbookConfig(environment) {
12951
+ switch (environment) {
12952
+ case exports.Environment.SANDBOX:
8856
12953
  return {
8857
- seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
8858
- zoneContractAddress: '0xCb5063b0c1dcF4f7fed8E7eaa79faf9859792767',
8859
- apiEndpoint: 'https://order-book-mr.dev.imtbl.com',
8860
- provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.dev.x.immutable.com'),
8861
- };
8862
- case TESTNET_CHAIN_NAME:
8863
- return {
8864
- seaportContractAddress: '0x45E23dA18804F99Cf67408AeBE85F67c958381Ff',
8865
- zoneContractAddress: '0x25b00b7eb97eab6194798E9B8eF63Aa526D5bd7E',
12954
+ seaportContractAddress: '0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19',
12955
+ zoneContractAddress: '0x6FeDb4949E5b452700A8a8956999a7E05B6770F3',
8866
12956
  apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
12957
+ chainName: TESTNET_CHAIN_NAME,
8867
12958
  provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.sandbox.x.immutable.com'),
8868
12959
  };
8869
- case MAINNET_CHAIN_NAME:
8870
- // not yet deployed
12960
+ // not yet deployed
12961
+ case exports.Environment.PRODUCTION:
8871
12962
  return {
8872
12963
  seaportContractAddress: '',
8873
12964
  zoneContractAddress: '',
8874
12965
  apiEndpoint: 'https://order-book-mr.imtbl.com',
12966
+ chainName: MAINNET_CHAIN_NAME,
8875
12967
  provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.x.immutable.com'),
8876
12968
  };
8877
12969
  default:
@@ -9830,21 +13922,19 @@ class Orderbook {
9830
13922
  apiClient;
9831
13923
  seaport;
9832
13924
  orderbookConfig;
9833
- constructor(config, localConfig) {
9834
- // either use preconfigured config or local config passed in
9835
- const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
9836
- if (!maybeConfig) {
9837
- throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
9838
- }
9839
- this.orderbookConfig = maybeConfig;
9840
- const { apiEndpoint } = this.orderbookConfig;
9841
- if (!apiEndpoint) {
9842
- throw new Error('API endpoint must be provided as an override');
13925
+ constructor(config) {
13926
+ const obConfig = getOrderbookConfig(config.baseConfig.environment);
13927
+ const finalConfig = {
13928
+ ...obConfig,
13929
+ ...config.overrides,
13930
+ };
13931
+ if (!finalConfig) {
13932
+ throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
9843
13933
  }
9844
- // TODO: Move chainId lookup to a map based on env. Just using override to get dev started
9845
- const chainName = config.overrides?.chainName;
9846
- if (!chainName) {
9847
- throw new Error('chainName must be provided as an override');
13934
+ this.orderbookConfig = finalConfig;
13935
+ const { apiEndpoint, chainName } = this.orderbookConfig;
13936
+ if (!apiEndpoint) {
13937
+ throw new Error('API endpoint must be provided');
9848
13938
  }
9849
13939
  this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
9850
13940
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
@@ -21179,7 +25269,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
21179
25269
  /**
21180
25270
  * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
21181
25271
  */
21182
- const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
25272
+ const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13423';
21183
25273
  /**
21184
25274
  /**
21185
25275
  * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
@@ -21237,14 +25327,14 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
21237
25327
  */
21238
25328
  const CONTRACTS_FOR_BRIDGE = new Map()
21239
25329
  .set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
21240
- rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
21241
- rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
25330
+ rootChainERC20Predicate: '0xf0b3435411A74F1aeCBD0fd6D53a90D5227fEeba',
25331
+ rootChainStateSender: '0x868097dbAcfD431F441d09D0e4D3B5eD3182E597',
21242
25332
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
21243
25333
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
21244
25334
  })
21245
25335
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
21246
- rootChainERC20Predicate: '0x9A7E4C4337a70C6754a9672F5ba69084463794B8',
21247
- rootChainStateSender: '0xfBfF6FD165adFA113bE39eE85ef030A996153253',
25336
+ rootChainERC20Predicate: '0x0C15a8359865867CdCC44f98b2F3fd5DF098C7E0',
25337
+ rootChainStateSender: '0x4C80001188db53dbc2eaAb32d5ef825feEedECA5',
21248
25338
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
21249
25339
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
21250
25340
  })
@@ -21836,7 +25926,7 @@ function getQuote(otherCurrency, tradeType, tradeInfo, slippage) {
21836
25926
  }
21837
25927
 
21838
25928
  const IMMUTABLE_TESTNET_RPC_URL = 'https://zkevm-rpc.sandbox.x.immutable.com';
21839
- const IMMUTABLE_TESTNET_CHAIN_ID = 13392;
25929
+ const IMMUTABLE_TESTNET_CHAIN_ID = 13372;
21840
25930
 
21841
25931
  const TIMX_IMMUTABLE_TESTNET = {
21842
25932
  chainId: IMMUTABLE_TESTNET_CHAIN_ID,
@@ -23475,16 +27565,28 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
23475
27565
  [exports.Environment.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
23476
27566
  };
23477
27567
  function validateOverrides(overrides) {
23478
- Object.entries(overrides).forEach(([key, value]) => {
23479
- if (!value) {
27568
+ const keysToCheck = ['rpcURL', 'exchangeContracts', 'commonRoutingTokens', 'nativeToken'];
27569
+ for (const key of keysToCheck) {
27570
+ if (!overrides[key]) {
23480
27571
  throw new InvalidConfigurationError(`Missing override: ${key}`);
23481
27572
  }
23482
- });
27573
+ }
23483
27574
  Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
23484
27575
  if (!isValidNonZeroAddress(contract)) {
23485
27576
  throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
23486
27577
  }
23487
27578
  });
27579
+ if (!overrides.secondaryFees) {
27580
+ return;
27581
+ }
27582
+ for (const secondaryFee of overrides.secondaryFees) {
27583
+ if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
27584
+ throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
27585
+ }
27586
+ if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
27587
+ throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
27588
+ }
27589
+ }
23488
27590
  }
23489
27591
  /**
23490
27592
  * {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
@@ -23494,6 +27596,7 @@ function validateOverrides(overrides) {
23494
27596
  class ExchangeConfiguration {
23495
27597
  baseConfig;
23496
27598
  chain;
27599
+ secondaryFees;
23497
27600
  constructor({ chainId, baseConfig, overrides }) {
23498
27601
  this.baseConfig = baseConfig;
23499
27602
  if (overrides) {
@@ -23505,8 +27608,10 @@ class ExchangeConfiguration {
23505
27608
  commonRoutingTokens: overrides.commonRoutingTokens,
23506
27609
  nativeToken: overrides.nativeToken,
23507
27610
  };
27611
+ this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
23508
27612
  return;
23509
27613
  }
27614
+ this.secondaryFees = [];
23510
27615
  const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
23511
27616
  if (!chain) {
23512
27617
  throw new ChainNotSupportedError(chainId, baseConfig.environment);
@@ -23520,11 +27625,13 @@ class Exchange {
23520
27625
  router;
23521
27626
  chainId;
23522
27627
  nativeToken;
27628
+ secondaryFees;
23523
27629
  constructor(configuration) {
23524
27630
  const config = new ExchangeConfiguration(configuration);
23525
27631
  this.chainId = config.chain.chainId;
23526
27632
  this.nativeToken = config.chain.nativeToken;
23527
27633
  this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
27634
+ this.secondaryFees = config.secondaryFees;
23528
27635
  this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
23529
27636
  multicallAddress: config.chain.contracts.multicall,
23530
27637
  factoryAddress: config.chain.contracts.coreFactory,
@@ -23607,6 +27714,9 @@ class Exchange {
23607
27714
  async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
23608
27715
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, sdkCore.TradeType.EXACT_OUTPUT);
23609
27716
  }
27717
+ thereAreSecondaryFees() {
27718
+ return this.secondaryFees.length > 0;
27719
+ }
23610
27720
  }
23611
27721
 
23612
27722
  /* eslint-disable class-methods-use-this */
@@ -23683,8 +27793,8 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
23683
27793
  */ exports.ChainId = void 0;
23684
27794
  (function(ChainId) {
23685
27795
  ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
23686
- ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13392] = "IMTBL_ZKEVM_TESTNET";
23687
- ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13403] = "IMTBL_ZKEVM_DEVNET";
27796
+ ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13372] = "IMTBL_ZKEVM_TESTNET";
27797
+ ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13423] = "IMTBL_ZKEVM_DEVNET";
23688
27798
  ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
23689
27799
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
23690
27800
  })(exports.ChainId || (exports.ChainId = {}));
@@ -23769,6 +27879,10 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
23769
27879
  [(exports.Environment).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
23770
27880
  [(exports.Environment).PRODUCTION]: "https://checkout-api.immutable.com"
23771
27881
  };
27882
+ const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
27883
+ [(exports.Environment).SANDBOX]: "https://zkevm-rpc.sandbox.x.immutable.com",
27884
+ [(exports.Environment).PRODUCTION]: "https://zkevm-rpc.x.immutable.com"
27885
+ };
23772
27886
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
23773
27887
  [
23774
27888
  (exports.ChainId).ETHEREUM,
@@ -23794,7 +27908,7 @@ const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
23794
27908
  chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_MAINNET.toString(16)}`,
23795
27909
  chainName: (exports.ChainName).IMTBL_ZKEVM_MAINNET,
23796
27910
  rpcUrls: [
23797
- "https://zkevm-rpc.x.immutable.com"
27911
+ "https://rpc.immutable.com"
23798
27912
  ],
23799
27913
  nativeCurrency: {
23800
27914
  name: "IMX",
@@ -23829,7 +27943,7 @@ const $d85ad1457a3f1a83$export$3e81fc0987227f10 = new Map([
23829
27943
  chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_TESTNET.toString(16)}`,
23830
27944
  chainName: (exports.ChainName).IMTBL_ZKEVM_TESTNET,
23831
27945
  rpcUrls: [
23832
- "https://zkevm-rpc.sandbox.x.immutable.com"
27946
+ "https://rpc.testnet.immutable.com"
23833
27947
  ],
23834
27948
  nativeCurrency: {
23835
27949
  name: "IMX",
@@ -24205,16 +28319,19 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
24205
28319
  if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", (exports.CheckoutErrorType).METAMASK_PROVIDER_ERROR);
24206
28320
  return new (providers.Web3Provider)(provider);
24207
28321
  }
24208
- async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
24209
- let web3Provider = null;
24210
- switch(defaultProvider){
28322
+ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
28323
+ let provider = null;
28324
+ switch(walletProviderName){
24211
28325
  case (exports.WalletProviderName).METAMASK:
24212
- web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
28326
+ provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
24213
28327
  break;
24214
28328
  default:
24215
28329
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", (exports.CheckoutErrorType).DEFAULT_PROVIDER_ERROR);
24216
28330
  }
24217
- return web3Provider;
28331
+ return {
28332
+ provider: provider,
28333
+ walletProviderName: walletProviderName
28334
+ };
24218
28335
  }
24219
28336
 
24220
28337
 
@@ -24223,9 +28340,8 @@ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
24223
28340
 
24224
28341
 
24225
28342
 
24226
-
24227
28343
  function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
24228
- if (web3Provider && web3Provider instanceof (providers.Web3Provider) && web3Provider.provider?.request) return true;
28344
+ if (web3Provider && web3Provider.provider?.request && typeof web3Provider.provider.request === "function") return true;
24229
28345
  return false;
24230
28346
  }
24231
28347
  async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
@@ -24390,7 +28506,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
24390
28506
  static async makeHttpRequest(url) {
24391
28507
  let response;
24392
28508
  try {
24393
- response = await (0, globalAxios$1).get(url);
28509
+ response = await (0, axios$2).get(url);
24394
28510
  } catch (error) {
24395
28511
  throw new Error(`Error fetching from api: ${error.message}`);
24396
28512
  }
@@ -24435,10 +28551,23 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
24435
28551
  this.message = message;
24436
28552
  }
24437
28553
  }
24438
- const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
24439
- if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
24440
- if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
24441
- return $d85ad1457a3f1a83$export$3e81fc0987227f10;
28554
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev, local)=>{
28555
+ let networks;
28556
+ if (dev) networks = ($d85ad1457a3f1a83$export$3a9ebede6a150274);
28557
+ else if (prod) {
28558
+ networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
28559
+ if (local) {
28560
+ const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
28561
+ rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).PRODUCTION]);
28562
+ }
28563
+ } else {
28564
+ networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
28565
+ if (local) {
28566
+ const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
28567
+ rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).SANDBOX]);
28568
+ }
28569
+ }
28570
+ return networks;
24442
28571
  };
24443
28572
  const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
24444
28573
  // DevMode and Sandbox will both use Sepolia.
@@ -24456,6 +28585,11 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
24456
28585
  // This will be used to get around the lack of
24457
28586
  // Environment.DEVELOPMENT
24458
28587
  isDevelopment = false;
28588
+ // This is a hidden feature that is only available
28589
+ // when building the project from source code.
28590
+ // This will be used to get around the lack of
28591
+ // Environment.LOCAL_DEVELOPMENT
28592
+ isLocal = false;
24459
28593
  isProduction;
24460
28594
  remote;
24461
28595
  environment;
@@ -24465,7 +28599,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
24465
28599
  this.environment = config.baseConfig.environment;
24466
28600
  // Developer mode will super set any environment configuration
24467
28601
  this.isProduction = !this.isDevelopment && this.environment === (exports.Environment).PRODUCTION;
24468
- this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
28602
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment, this.isLocal);
24469
28603
  this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
24470
28604
  isDevelopment: this.isDevelopment,
24471
28605
  isProduction: this.isProduction
@@ -24611,10 +28745,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
24611
28745
  * @param {CreateProviderParams} params - The parameters for creating the provider.
24612
28746
  * @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
24613
28747
  */ async createProvider(params) {
24614
- const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
24615
- return {
24616
- provider: web3Provider
24617
- };
28748
+ return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
24618
28749
  }
24619
28750
  /**
24620
28751
  * Checks if a wallet is connected to the specified provider.
@@ -24731,7 +28862,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
24731
28862
  function $parcel$export(e, n, v, s) {
24732
28863
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24733
28864
  }
24734
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.2";
28865
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.1-alpha";
24735
28866
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
24736
28867
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
24737
28868
 
@@ -26550,6 +30681,7 @@ exports.ERC721PermissionedMintable = ERC721PermissionedMintable;
26550
30681
  exports.GenericIMXProvider = GenericIMXProvider;
26551
30682
  exports.ImmutableConfiguration = ImmutableConfiguration;
26552
30683
  exports.ImmutableXClient = ImmutableXClient;
30684
+ exports.JsonRpcError = JsonRpcError;
26553
30685
  exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
26554
30686
  exports.Orderbook = Orderbook;
26555
30687
  exports.Passport = Passport;