koilib 2.5.1 → 2.6.0

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/koinos.js CHANGED
@@ -134,14 +134,14 @@ module.exports = base
134
134
 
135
135
  /***/ }),
136
136
 
137
- /***/ 6365:
137
+ /***/ 7505:
138
138
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
139
139
 
140
140
  "use strict";
141
141
 
142
142
  Object.defineProperty(exports, "__esModule", ({ value: true }));
143
143
  exports.SHA2 = void 0;
144
- const utils_1 = __webpack_require__(8359);
144
+ const utils_js_1 = __webpack_require__(8089);
145
145
  // Polyfill for Safari 14
146
146
  function setBigUint64(view, byteOffset, value, isLE) {
147
147
  if (typeof view.setBigUint64 === 'function')
@@ -156,7 +156,7 @@ function setBigUint64(view, byteOffset, value, isLE) {
156
156
  view.setUint32(byteOffset + l, wl, isLE);
157
157
  }
158
158
  // Base SHA2 class (RFC 6234)
159
- class SHA2 extends utils_1.Hash {
159
+ class SHA2 extends utils_js_1.Hash {
160
160
  constructor(blockLen, outputLen, padOffset, isLE) {
161
161
  super();
162
162
  this.blockLen = blockLen;
@@ -168,7 +168,7 @@ class SHA2 extends utils_1.Hash {
168
168
  this.pos = 0;
169
169
  this.destroyed = false;
170
170
  this.buffer = new Uint8Array(blockLen);
171
- this.view = (0, utils_1.createView)(this.buffer);
171
+ this.view = (0, utils_js_1.createView)(this.buffer);
172
172
  }
173
173
  update(data) {
174
174
  if (this.destroyed)
@@ -176,13 +176,13 @@ class SHA2 extends utils_1.Hash {
176
176
  const { view, buffer, blockLen, finished } = this;
177
177
  if (finished)
178
178
  throw new Error('digest() was already called');
179
- data = (0, utils_1.toBytes)(data);
179
+ data = (0, utils_js_1.toBytes)(data);
180
180
  const len = data.length;
181
181
  for (let pos = 0; pos < len;) {
182
182
  const take = Math.min(blockLen - this.pos, len - pos);
183
183
  // Fast path: we have at least one block in input, cast it to view and process
184
184
  if (take === blockLen) {
185
- const dataView = (0, utils_1.createView)(data);
185
+ const dataView = (0, utils_js_1.createView)(data);
186
186
  for (; blockLen <= len - pos; pos += blockLen)
187
187
  this.process(dataView, pos);
188
188
  continue;
@@ -228,7 +228,7 @@ class SHA2 extends utils_1.Hash {
228
228
  // So we just write lowest 64bit of that value.
229
229
  setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
230
230
  this.process(view, 0);
231
- const oview = (0, utils_1.createView)(out);
231
+ const oview = (0, utils_js_1.createView)(out);
232
232
  this.get().forEach((v, i) => oview.setUint32(4 * i, v, isLE));
233
233
  }
234
234
  digest() {
@@ -256,7 +256,7 @@ exports.SHA2 = SHA2;
256
256
 
257
257
  /***/ }),
258
258
 
259
- /***/ 901:
259
+ /***/ 4421:
260
260
  /***/ ((__unused_webpack_module, exports) => {
261
261
 
262
262
  "use strict";
@@ -271,15 +271,15 @@ exports.crypto = {
271
271
 
272
272
  /***/ }),
273
273
 
274
- /***/ 7050:
274
+ /***/ 830:
275
275
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
276
276
 
277
277
  "use strict";
278
278
 
279
279
  Object.defineProperty(exports, "__esModule", ({ value: true }));
280
280
  exports.ripemd160 = exports.RIPEMD160 = void 0;
281
- const _sha2_1 = __webpack_require__(6365);
282
- const utils_1 = __webpack_require__(8359);
281
+ const _sha2_js_1 = __webpack_require__(7505);
282
+ const utils_js_1 = __webpack_require__(8089);
283
283
  // https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
284
284
  // https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
285
285
  const Rho = new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
@@ -318,7 +318,7 @@ function f(group, x, y, z) {
318
318
  }
319
319
  // Temporary buffer, not used to store anything between runs
320
320
  const BUF = new Uint32Array(16);
321
- class RIPEMD160 extends _sha2_1.SHA2 {
321
+ class RIPEMD160 extends _sha2_js_1.SHA2 {
322
322
  constructor() {
323
323
  super(64, 20, 8, true);
324
324
  this.h0 = 0x67452301 | 0;
@@ -373,20 +373,24 @@ class RIPEMD160 extends _sha2_1.SHA2 {
373
373
  }
374
374
  }
375
375
  exports.RIPEMD160 = RIPEMD160;
376
- exports.ripemd160 = (0, utils_1.wrapConstructor)(() => new RIPEMD160());
376
+ /**
377
+ * RIPEMD-160 - a hash function from 1990s.
378
+ * @param message - msg that would be hashed
379
+ */
380
+ exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
377
381
 
378
382
 
379
383
  /***/ }),
380
384
 
381
- /***/ 5374:
385
+ /***/ 3061:
382
386
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
383
387
 
384
388
  "use strict";
385
389
 
386
390
  Object.defineProperty(exports, "__esModule", ({ value: true }));
387
391
  exports.sha256 = void 0;
388
- const _sha2_1 = __webpack_require__(6365);
389
- const utils_1 = __webpack_require__(8359);
392
+ const _sha2_js_1 = __webpack_require__(7505);
393
+ const utils_js_1 = __webpack_require__(8089);
390
394
  // Choice: a ? b : c
391
395
  const Chi = (a, b, c) => (a & b) ^ (~a & c);
392
396
  // Majority function, true if any two inpust is true
@@ -412,7 +416,7 @@ const IV = new Uint32Array([
412
416
  // Temporary buffer, not used to store anything between runs
413
417
  // Named this way because it matches specification.
414
418
  const SHA256_W = new Uint32Array(64);
415
- class SHA256 extends _sha2_1.SHA2 {
419
+ class SHA256 extends _sha2_js_1.SHA2 {
416
420
  constructor() {
417
421
  super(64, 32, 8, false);
418
422
  // We cannot use array here since array allows indexing by variable
@@ -448,16 +452,16 @@ class SHA256 extends _sha2_1.SHA2 {
448
452
  for (let i = 16; i < 64; i++) {
449
453
  const W15 = SHA256_W[i - 15];
450
454
  const W2 = SHA256_W[i - 2];
451
- const s0 = (0, utils_1.rotr)(W15, 7) ^ (0, utils_1.rotr)(W15, 18) ^ (W15 >>> 3);
452
- const s1 = (0, utils_1.rotr)(W2, 17) ^ (0, utils_1.rotr)(W2, 19) ^ (W2 >>> 10);
455
+ const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ (W15 >>> 3);
456
+ const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ (W2 >>> 10);
453
457
  SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
454
458
  }
455
459
  // Compression function main loop, 64 rounds
456
460
  let { A, B, C, D, E, F, G, H } = this;
457
461
  for (let i = 0; i < 64; i++) {
458
- const sigma1 = (0, utils_1.rotr)(E, 6) ^ (0, utils_1.rotr)(E, 11) ^ (0, utils_1.rotr)(E, 25);
462
+ const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25);
459
463
  const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
460
- const sigma0 = (0, utils_1.rotr)(A, 2) ^ (0, utils_1.rotr)(A, 13) ^ (0, utils_1.rotr)(A, 22);
464
+ const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22);
461
465
  const T2 = (sigma0 + Maj(A, B, C)) | 0;
462
466
  H = G;
463
467
  G = F;
@@ -487,23 +491,27 @@ class SHA256 extends _sha2_1.SHA2 {
487
491
  this.buffer.fill(0);
488
492
  }
489
493
  }
490
- exports.sha256 = (0, utils_1.wrapConstructor)(() => new SHA256());
494
+ /**
495
+ * SHA2-256 hash function
496
+ * @param message - data that would be hashed
497
+ */
498
+ exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());
491
499
 
492
500
 
493
501
  /***/ }),
494
502
 
495
- /***/ 8359:
503
+ /***/ 8089:
496
504
  /***/ ((module, exports, __webpack_require__) => {
497
505
 
498
506
  "use strict";
499
507
  /* module decorator */ module = __webpack_require__.nmd(module);
500
508
 
501
- /*! noble-hashes - MIT License (c) 2021 Paul Miller (paulmillr.com) */
509
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
502
510
  Object.defineProperty(exports, "__esModule", ({ value: true }));
503
- exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.assertHash = exports.assertBool = exports.assertNumber = exports.toBytes = exports.asyncLoop = exports.nextTick = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
511
+ exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.assertHash = exports.assertBytes = exports.assertBool = exports.assertNumber = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
504
512
  // The import here is via the package name. This is to ensure
505
513
  // that exports mapping/resolution does fall into place.
506
- const crypto_1 = __webpack_require__(901);
514
+ const crypto_1 = __webpack_require__(4421);
507
515
  // Cast array to different type
508
516
  const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
509
517
  exports.u8 = u8;
@@ -521,8 +529,11 @@ exports.isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
521
529
  if (!exports.isLE)
522
530
  throw new Error('Non little-endian hardware is not supported');
523
531
  const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
532
+ /**
533
+ * @example bytesToHex(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]))
534
+ */
524
535
  function bytesToHex(uint8a) {
525
- // pre-caching chars could speed this up 6x.
536
+ // pre-caching improves the speed 6x
526
537
  let hex = '';
527
538
  for (let i = 0; i < uint8a.length; i++) {
528
539
  hex += hexes[uint8a[i]];
@@ -530,6 +541,27 @@ function bytesToHex(uint8a) {
530
541
  return hex;
531
542
  }
532
543
  exports.bytesToHex = bytesToHex;
544
+ /**
545
+ * @example hexToBytes('deadbeef')
546
+ */
547
+ function hexToBytes(hex) {
548
+ if (typeof hex !== 'string') {
549
+ throw new TypeError('hexToBytes: expected string, got ' + typeof hex);
550
+ }
551
+ if (hex.length % 2)
552
+ throw new Error('hexToBytes: received invalid unpadded hex');
553
+ const array = new Uint8Array(hex.length / 2);
554
+ for (let i = 0; i < array.length; i++) {
555
+ const j = i * 2;
556
+ const hexByte = hex.slice(j, j + 2);
557
+ const byte = Number.parseInt(hexByte, 16);
558
+ if (Number.isNaN(byte))
559
+ throw new Error('Invalid byte sequence');
560
+ array[i] = byte;
561
+ }
562
+ return array;
563
+ }
564
+ exports.hexToBytes = hexToBytes;
533
565
  // Currently avoid insertion of polyfills with packers (browserify/webpack/etc)
534
566
  // But setTimeout is pretty slow, maybe worth to investigate howto do minimal polyfill here
535
567
  exports.nextTick = (() => {
@@ -559,17 +591,43 @@ async function asyncLoop(iters, tick, cb) {
559
591
  }
560
592
  }
561
593
  exports.asyncLoop = asyncLoop;
594
+ function utf8ToBytes(str) {
595
+ if (typeof str !== 'string') {
596
+ throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
597
+ }
598
+ return new TextEncoder().encode(str);
599
+ }
600
+ exports.utf8ToBytes = utf8ToBytes;
562
601
  function toBytes(data) {
563
602
  if (typeof data === 'string')
564
- data = new TextEncoder().encode(data);
603
+ data = utf8ToBytes(data);
565
604
  if (!(data instanceof Uint8Array))
566
605
  throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
567
606
  return data;
568
607
  }
569
608
  exports.toBytes = toBytes;
609
+ /**
610
+ * Concats Uint8Array-s into one; like `Buffer.concat([buf1, buf2])`
611
+ * @example concatBytes(buf1, buf2)
612
+ */
613
+ function concatBytes(...arrays) {
614
+ if (!arrays.every((a) => a instanceof Uint8Array))
615
+ throw new Error('Uint8Array list expected');
616
+ if (arrays.length === 1)
617
+ return arrays[0];
618
+ const length = arrays.reduce((a, arr) => a + arr.length, 0);
619
+ const result = new Uint8Array(length);
620
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
621
+ const arr = arrays[i];
622
+ result.set(arr, pad);
623
+ pad += arr.length;
624
+ }
625
+ return result;
626
+ }
627
+ exports.concatBytes = concatBytes;
570
628
  function assertNumber(n) {
571
- if (!Number.isSafeInteger(n))
572
- throw new Error(`Wrong integer: ${n}`);
629
+ if (!Number.isSafeInteger(n) || n < 0)
630
+ throw new Error(`Wrong positive integer: ${n}`);
573
631
  }
574
632
  exports.assertNumber = assertNumber;
575
633
  function assertBool(b) {
@@ -578,8 +636,15 @@ function assertBool(b) {
578
636
  }
579
637
  }
580
638
  exports.assertBool = assertBool;
639
+ function assertBytes(bytes, ...lengths) {
640
+ if (bytes instanceof Uint8Array && (!lengths.length || lengths.includes(bytes.length))) {
641
+ return;
642
+ }
643
+ throw new TypeError(`Expected ${lengths} bytes, not ${typeof bytes} with length=${bytes.length}`);
644
+ }
645
+ exports.assertBytes = assertBytes;
581
646
  function assertHash(hash) {
582
- if (typeof hash !== 'function' || typeof hash.init !== 'function')
647
+ if (typeof hash !== 'function' || typeof hash.create !== 'function')
583
648
  throw new Error('Hash should be wrapped by utils.wrapConstructor');
584
649
  assertNumber(hash.outputLen);
585
650
  assertNumber(hash.blockLen);
@@ -608,7 +673,6 @@ function wrapConstructor(hashConstructor) {
608
673
  hashC.outputLen = tmp.outputLen;
609
674
  hashC.blockLen = tmp.blockLen;
610
675
  hashC.create = () => hashConstructor();
611
- hashC.init = hashC.create;
612
676
  return hashC;
613
677
  }
614
678
  exports.wrapConstructor = wrapConstructor;
@@ -618,10 +682,12 @@ function wrapConstructorWithOpts(hashCons) {
618
682
  hashC.outputLen = tmp.outputLen;
619
683
  hashC.blockLen = tmp.blockLen;
620
684
  hashC.create = (opts) => hashCons(opts);
621
- hashC.init = hashC.create;
622
685
  return hashC;
623
686
  }
624
687
  exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
688
+ /**
689
+ * Secure PRNG
690
+ */
625
691
  function randomBytes(bytesLength = 32) {
626
692
  if (crypto_1.crypto.web) {
627
693
  return crypto_1.crypto.web.getRandomValues(new Uint8Array(bytesLength));
@@ -638,30 +704,42 @@ exports.randomBytes = randomBytes;
638
704
 
639
705
  /***/ }),
640
706
 
641
- /***/ 1337:
642
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
707
+ /***/ 9656:
708
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
643
709
 
644
710
  "use strict";
645
711
 
646
- /*! noble-secp256k1 - MIT License (c) Paul Miller (paulmillr.com) */
712
+ /*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
713
+ var __importDefault = (this && this.__importDefault) || function (mod) {
714
+ return (mod && mod.__esModule) ? mod : { "default": mod };
715
+ };
647
716
  Object.defineProperty(exports, "__esModule", ({ value: true }));
648
- exports.utils = exports.schnorr = exports.verify = exports.signSync = exports.sign = exports.getSharedSecret = exports.recoverPublicKey = exports.getPublicKey = exports.SignResult = exports.Signature = exports.Point = exports.CURVE = void 0;
717
+ exports.utils = exports.schnorr = exports.verify = exports.signSync = exports.sign = exports.getSharedSecret = exports.recoverPublicKey = exports.getPublicKey = exports.Signature = exports.Point = exports.CURVE = void 0;
718
+ const crypto_1 = __importDefault(__webpack_require__(9159));
719
+ const _0n = BigInt(0);
720
+ const _1n = BigInt(1);
721
+ const _2n = BigInt(2);
722
+ const _3n = BigInt(3);
723
+ const _8n = BigInt(8);
724
+ const POW_2_256 = _2n ** BigInt(256);
649
725
  const CURVE = {
650
- a: 0n,
651
- b: 7n,
652
- P: 2n ** 256n - 2n ** 32n - 977n,
653
- n: 2n ** 256n - 432420386565659656852420866394968145599n,
654
- h: 1n,
655
- Gx: 55066263022277343669578718895168534326250603453777594175500187360389116729240n,
656
- Gy: 32670510020758816978083085130507043184471273380659243275938904335757337482424n,
657
- beta: 0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501een,
726
+ a: _0n,
727
+ b: BigInt(7),
728
+ P: POW_2_256 - _2n ** BigInt(32) - BigInt(977),
729
+ n: POW_2_256 - BigInt('432420386565659656852420866394968145599'),
730
+ h: _1n,
731
+ Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),
732
+ Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),
733
+ beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
658
734
  };
659
735
  exports.CURVE = CURVE;
660
736
  function weistrass(x) {
661
737
  const { a, b } = CURVE;
662
- return mod(x ** 3n + a * x + b);
738
+ const x2 = mod(x * x);
739
+ const x3 = mod(x2 * x);
740
+ return mod(x3 + a * x + b);
663
741
  }
664
- const USE_ENDOMORPHISM = CURVE.a === 0n;
742
+ const USE_ENDOMORPHISM = CURVE.a === _0n;
665
743
  class JacobianPoint {
666
744
  constructor(x, y, z) {
667
745
  this.x = x;
@@ -672,7 +750,7 @@ class JacobianPoint {
672
750
  if (!(p instanceof Point)) {
673
751
  throw new TypeError('JacobianPoint#fromAffine: expected Point');
674
752
  }
675
- return new JacobianPoint(p.x, p.y, 1n);
753
+ return new JacobianPoint(p.x, p.y, _1n);
676
754
  }
677
755
  static toAffineBatch(points) {
678
756
  const toInv = invertBatch(points.map((p) => p.z));
@@ -697,15 +775,15 @@ class JacobianPoint {
697
775
  const X1 = this.x;
698
776
  const Y1 = this.y;
699
777
  const Z1 = this.z;
700
- const A = mod(X1 ** 2n);
701
- const B = mod(Y1 ** 2n);
702
- const C = mod(B ** 2n);
703
- const D = mod(2n * (mod(mod((X1 + B) ** 2n)) - A - C));
704
- const E = mod(3n * A);
705
- const F = mod(E ** 2n);
706
- const X3 = mod(F - 2n * D);
707
- const Y3 = mod(E * (D - X3) - 8n * C);
708
- const Z3 = mod(2n * Y1 * Z1);
778
+ const A = mod(X1 ** _2n);
779
+ const B = mod(Y1 ** _2n);
780
+ const C = mod(B ** _2n);
781
+ const D = mod(_2n * (mod(mod((X1 + B) ** _2n)) - A - C));
782
+ const E = mod(_3n * A);
783
+ const F = mod(E ** _2n);
784
+ const X3 = mod(F - _2n * D);
785
+ const Y3 = mod(E * (D - X3) - _8n * C);
786
+ const Z3 = mod(_2n * Y1 * Z1);
709
787
  return new JacobianPoint(X3, Y3, Z3);
710
788
  }
711
789
  add(other) {
@@ -718,30 +796,30 @@ class JacobianPoint {
718
796
  const X2 = other.x;
719
797
  const Y2 = other.y;
720
798
  const Z2 = other.z;
721
- if (X2 === 0n || Y2 === 0n)
799
+ if (X2 === _0n || Y2 === _0n)
722
800
  return this;
723
- if (X1 === 0n || Y1 === 0n)
801
+ if (X1 === _0n || Y1 === _0n)
724
802
  return other;
725
- const Z1Z1 = mod(Z1 ** 2n);
726
- const Z2Z2 = mod(Z2 ** 2n);
803
+ const Z1Z1 = mod(Z1 ** _2n);
804
+ const Z2Z2 = mod(Z2 ** _2n);
727
805
  const U1 = mod(X1 * Z2Z2);
728
806
  const U2 = mod(X2 * Z1Z1);
729
807
  const S1 = mod(Y1 * Z2 * Z2Z2);
730
808
  const S2 = mod(mod(Y2 * Z1) * Z1Z1);
731
809
  const H = mod(U2 - U1);
732
810
  const r = mod(S2 - S1);
733
- if (H === 0n) {
734
- if (r === 0n) {
811
+ if (H === _0n) {
812
+ if (r === _0n) {
735
813
  return this.double();
736
814
  }
737
815
  else {
738
816
  return JacobianPoint.ZERO;
739
817
  }
740
818
  }
741
- const HH = mod(H ** 2n);
819
+ const HH = mod(H ** _2n);
742
820
  const HHH = mod(H * HH);
743
821
  const V = mod(U1 * HH);
744
- const X3 = mod(r ** 2n - HHH - 2n * V);
822
+ const X3 = mod(r ** _2n - HHH - _2n * V);
745
823
  const Y3 = mod(r * (V - X3) - S1 * HHH);
746
824
  const Z3 = mod(Z1 * Z2 * H);
747
825
  return new JacobianPoint(X3, Y3, Z3);
@@ -750,32 +828,30 @@ class JacobianPoint {
750
828
  return this.add(other.negate());
751
829
  }
752
830
  multiplyUnsafe(scalar) {
753
- if (!isValidScalar(scalar))
754
- throw new TypeError('Point#multiply: expected valid scalar');
755
- let n = mod(BigInt(scalar), CURVE.n);
831
+ let n = normalizeScalar(scalar);
756
832
  if (!USE_ENDOMORPHISM) {
757
833
  let p = JacobianPoint.ZERO;
758
834
  let d = this;
759
- while (n > 0n) {
760
- if (n & 1n)
835
+ while (n > _0n) {
836
+ if (n & _1n)
761
837
  p = p.add(d);
762
838
  d = d.double();
763
- n >>= 1n;
839
+ n >>= _1n;
764
840
  }
765
841
  return p;
766
842
  }
767
- let [k1neg, k1, k2neg, k2] = splitScalarEndo(n);
843
+ let { k1neg, k1, k2neg, k2 } = splitScalarEndo(n);
768
844
  let k1p = JacobianPoint.ZERO;
769
845
  let k2p = JacobianPoint.ZERO;
770
846
  let d = this;
771
- while (k1 > 0n || k2 > 0n) {
772
- if (k1 & 1n)
847
+ while (k1 > _0n || k2 > _0n) {
848
+ if (k1 & _1n)
773
849
  k1p = k1p.add(d);
774
- if (k2 & 1n)
850
+ if (k2 & _1n)
775
851
  k2p = k2p.add(d);
776
852
  d = d.double();
777
- k1 >>= 1n;
778
- k2 >>= 1n;
853
+ k1 >>= _1n;
854
+ k2 >>= _1n;
779
855
  }
780
856
  if (k1neg)
781
857
  k1p = k1p.negate();
@@ -786,7 +862,7 @@ class JacobianPoint {
786
862
  }
787
863
  precomputeWindow(W) {
788
864
  const windows = USE_ENDOMORPHISM ? 128 / W + 1 : 256 / W + 1;
789
- let points = [];
865
+ const points = [];
790
866
  let p = this;
791
867
  let base = p;
792
868
  for (let window = 0; window < windows; window++) {
@@ -828,50 +904,55 @@ class JacobianPoint {
828
904
  n >>= shiftBy;
829
905
  if (wbits > windowSize) {
830
906
  wbits -= maxNumber;
831
- n += 1n;
907
+ n += _1n;
832
908
  }
833
909
  if (wbits === 0) {
834
- f = f.add(window % 2 ? precomputes[offset].negate() : precomputes[offset]);
910
+ let pr = precomputes[offset];
911
+ if (window % 2)
912
+ pr = pr.negate();
913
+ f = f.add(pr);
835
914
  }
836
915
  else {
837
- const cached = precomputes[offset + Math.abs(wbits) - 1];
838
- p = p.add(wbits < 0 ? cached.negate() : cached);
916
+ let cached = precomputes[offset + Math.abs(wbits) - 1];
917
+ if (wbits < 0)
918
+ cached = cached.negate();
919
+ p = p.add(cached);
839
920
  }
840
921
  }
841
- return [p, f];
922
+ return { p, f };
842
923
  }
843
924
  multiply(scalar, affinePoint) {
844
- if (!isValidScalar(scalar))
845
- throw new TypeError('Point#multiply: expected valid scalar');
846
- let n = mod(BigInt(scalar), CURVE.n);
925
+ let n = normalizeScalar(scalar);
847
926
  let point;
848
927
  let fake;
849
928
  if (USE_ENDOMORPHISM) {
850
- const [k1neg, k1, k2neg, k2] = splitScalarEndo(n);
851
- let k1p, k2p, f1p, f2p;
852
- [k1p, f1p] = this.wNAF(k1, affinePoint);
853
- [k2p, f2p] = this.wNAF(k2, affinePoint);
929
+ let { k1neg, k1, k2neg, k2 } = splitScalarEndo(n);
930
+ let { p: k1p, f: f1p } = this.wNAF(k1, affinePoint);
931
+ let { p: k2p, f: f2p } = this.wNAF(k2, affinePoint);
854
932
  if (k1neg)
855
933
  k1p = k1p.negate();
856
934
  if (k2neg)
857
935
  k2p = k2p.negate();
858
936
  k2p = new JacobianPoint(mod(k2p.x * CURVE.beta), k2p.y, k2p.z);
859
- [point, fake] = [k1p.add(k2p), f1p.add(f2p)];
937
+ point = k1p.add(k2p);
938
+ fake = f1p.add(f2p);
860
939
  }
861
940
  else {
862
- [point, fake] = this.wNAF(n, affinePoint);
941
+ let { p, f } = this.wNAF(n, affinePoint);
942
+ point = p;
943
+ fake = f;
863
944
  }
864
945
  return JacobianPoint.normalizeZ([point, fake])[0];
865
946
  }
866
947
  toAffine(invZ = invert(this.z)) {
867
- const invZ2 = invZ ** 2n;
948
+ const invZ2 = invZ ** _2n;
868
949
  const x = mod(this.x * invZ2);
869
950
  const y = mod(this.y * invZ2 * invZ);
870
951
  return new Point(x, y);
871
952
  }
872
953
  }
873
- JacobianPoint.BASE = new JacobianPoint(CURVE.Gx, CURVE.Gy, 1n);
874
- JacobianPoint.ZERO = new JacobianPoint(0n, 1n, 0n);
954
+ JacobianPoint.BASE = new JacobianPoint(CURVE.Gx, CURVE.Gy, _1n);
955
+ JacobianPoint.ZERO = new JacobianPoint(_0n, _1n, _0n);
875
956
  const pointPrecomputes = new WeakMap();
876
957
  class Point {
877
958
  constructor(x, y) {
@@ -887,7 +968,7 @@ class Point {
887
968
  const x = bytesToNumber(isShort ? bytes : bytes.slice(1));
888
969
  const y2 = weistrass(x);
889
970
  let y = sqrtMod(y2);
890
- const isYOdd = (y & 1n) === 1n;
971
+ const isYOdd = (y & _1n) === _1n;
891
972
  if (isShort) {
892
973
  if (isYOdd)
893
974
  y = mod(-y);
@@ -926,7 +1007,7 @@ class Point {
926
1007
  const sig = normalizeSignature(signature);
927
1008
  const { r, s } = sig;
928
1009
  if (recovery !== 0 && recovery !== 1) {
929
- throw new Error('Cannot recover signature: invalid yParity bit');
1010
+ throw new Error('Cannot recover signature: invalid recovery bit');
930
1011
  }
931
1012
  const prefix = 2 + (recovery & 1);
932
1013
  const P_ = Point.fromHex(`0${prefix}${pad64(r)}`);
@@ -944,7 +1025,7 @@ class Point {
944
1025
  toHex(isCompressed = false) {
945
1026
  const x = pad64(this.x);
946
1027
  if (isCompressed) {
947
- return `${this.y & 1n ? '03' : '02'}${x}`;
1028
+ return `${this.y & _1n ? '03' : '02'}${x}`;
948
1029
  }
949
1030
  else {
950
1031
  return `04${x}${pad64(this.y)}`;
@@ -958,13 +1039,12 @@ class Point {
958
1039
  }
959
1040
  assertValidity() {
960
1041
  const msg = 'Point is not on elliptic curve';
961
- const { P } = CURVE;
962
1042
  const { x, y } = this;
963
- if (x === 0n || y === 0n || x >= P || y >= P)
1043
+ if (!isWithinCurvePrime(x) || !isWithinCurvePrime(y))
964
1044
  throw new Error(msg);
965
1045
  const left = mod(y * y);
966
1046
  const right = weistrass(x);
967
- if ((left - right) % P !== 0n)
1047
+ if (mod(left - right) !== _0n)
968
1048
  throw new Error(msg);
969
1049
  }
970
1050
  equals(other) {
@@ -988,64 +1068,60 @@ class Point {
988
1068
  }
989
1069
  exports.Point = Point;
990
1070
  Point.BASE = new Point(CURVE.Gx, CURVE.Gy);
991
- Point.ZERO = new Point(0n, 0n);
992
- function sliceDer(s) {
1071
+ Point.ZERO = new Point(_0n, _0n);
1072
+ function sliceDER(s) {
993
1073
  return Number.parseInt(s[0], 16) >= 8 ? '00' + s : s;
994
1074
  }
1075
+ function parseDERInt(data) {
1076
+ if (data.length < 2 || data[0] !== 0x02) {
1077
+ throw new Error(`Invalid signature integer tag: ${bytesToHex(data)}`);
1078
+ }
1079
+ const len = data[1];
1080
+ const res = data.subarray(2, len + 2);
1081
+ if (!len || res.length !== len) {
1082
+ throw new Error(`Invalid signature integer: wrong length`);
1083
+ }
1084
+ if (res[0] === 0x00 && res[1] <= 0x7f) {
1085
+ throw new Error('Invalid signature integer: trailing length');
1086
+ }
1087
+ return { data: bytesToNumber(res), left: data.subarray(len + 2) };
1088
+ }
1089
+ function parseDERSignature(data) {
1090
+ if (data.length < 2 || data[0] != 0x30) {
1091
+ throw new Error(`Invalid signature tag: ${bytesToHex(data)}`);
1092
+ }
1093
+ if (data[1] !== data.length - 2) {
1094
+ throw new Error('Invalid signature: incorrect length');
1095
+ }
1096
+ const { data: r, left: sBytes } = parseDERInt(data.subarray(2));
1097
+ const { data: s, left: rBytesLeft } = parseDERInt(sBytes);
1098
+ if (rBytesLeft.length) {
1099
+ throw new Error(`Invalid signature: left bytes after parsing: ${bytesToHex(rBytesLeft)}`);
1100
+ }
1101
+ return { r, s };
1102
+ }
995
1103
  class Signature {
996
1104
  constructor(r, s) {
997
1105
  this.r = r;
998
1106
  this.s = s;
1107
+ this.assertValidity();
999
1108
  }
1000
1109
  static fromCompact(hex) {
1001
- if (typeof hex !== 'string' && !(hex instanceof Uint8Array)) {
1002
- throw new TypeError(`Signature.fromCompact: Expected string or Uint8Array`);
1003
- }
1004
- const str = hex instanceof Uint8Array ? bytesToHex(hex) : hex;
1110
+ const arr = hex instanceof Uint8Array;
1111
+ const name = 'Signature.fromCompact';
1112
+ if (typeof hex !== 'string' && !arr)
1113
+ throw new TypeError(`${name}: Expected string or Uint8Array`);
1114
+ const str = arr ? bytesToHex(hex) : hex;
1005
1115
  if (str.length !== 128)
1006
- throw new Error('Signature.fromCompact: Expected 64-byte hex');
1007
- const sig = new Signature(hexToNumber(str.slice(0, 64)), hexToNumber(str.slice(64, 128)));
1008
- sig.assertValidity();
1009
- return sig;
1116
+ throw new Error(`${name}: Expected 64-byte hex`);
1117
+ return new Signature(hexToNumber(str.slice(0, 64)), hexToNumber(str.slice(64, 128)));
1010
1118
  }
1011
1119
  static fromDER(hex) {
1012
- const fn = 'Signature.fromDER';
1013
- if (typeof hex !== 'string' && !(hex instanceof Uint8Array)) {
1014
- throw new TypeError(`${fn}: Expected string or Uint8Array`);
1015
- }
1016
- const str = hex instanceof Uint8Array ? bytesToHex(hex) : hex;
1017
- const length = parseByte(str.slice(2, 4));
1018
- if (str.slice(0, 2) !== '30' || length !== str.length - 4 || str.slice(4, 6) !== '02') {
1019
- throw new Error(`${fn}: Invalid signature ${str}`);
1020
- }
1021
- const rLen = parseByte(str.slice(6, 8));
1022
- const rEnd = 8 + rLen;
1023
- const rr = str.slice(8, rEnd);
1024
- if (rr.startsWith('00') && parseByte(rr.slice(2, 4)) <= 0x7f) {
1025
- throw new Error(`${fn}: Invalid r with trailing length`);
1026
- }
1027
- const r = hexToNumber(rr);
1028
- const separator = str.slice(rEnd, rEnd + 2);
1029
- if (separator !== '02') {
1030
- throw new Error(`${fn}: Invalid r-s separator`);
1031
- }
1032
- const sLen = parseByte(str.slice(rEnd + 2, rEnd + 4));
1033
- const diff = length - sLen - rLen - 10;
1034
- if (diff > 0 || diff === -4) {
1035
- throw new Error(`${fn}: Invalid total length`);
1036
- }
1037
- if (sLen > length - rLen - 4) {
1038
- throw new Error(`${fn}: Invalid s`);
1039
- }
1040
- const sStart = rEnd + 4;
1041
- const ss = str.slice(sStart, sStart + sLen);
1042
- if (ss.startsWith('00') && parseByte(ss.slice(2, 4)) <= 0x7f) {
1043
- throw new Error(`${fn}: Invalid s with trailing length`);
1044
- }
1045
- const s = hexToNumber(ss);
1046
- const sig = new Signature(r, s);
1047
- sig.assertValidity();
1048
- return sig;
1120
+ const arr = hex instanceof Uint8Array;
1121
+ if (typeof hex !== 'string' && !arr)
1122
+ throw new TypeError(`Signature.fromDER: Expected string or Uint8Array`);
1123
+ const { r, s } = parseDERSignature(arr ? hex : hexToBytes(hex));
1124
+ return new Signature(r, s);
1049
1125
  }
1050
1126
  static fromHex(hex) {
1051
1127
  return this.fromDER(hex);
@@ -1057,14 +1133,21 @@ class Signature {
1057
1133
  if (!isWithinCurveOrder(s))
1058
1134
  throw new Error('Invalid Signature: s must be 0 < s < n');
1059
1135
  }
1136
+ hasHighS() {
1137
+ const HALF = CURVE.n >> _1n;
1138
+ return this.s > HALF;
1139
+ }
1140
+ normalizeS() {
1141
+ return this.hasHighS() ? new Signature(this.r, CURVE.n - this.s) : this;
1142
+ }
1060
1143
  toDERRawBytes(isCompressed = false) {
1061
1144
  return hexToBytes(this.toDERHex(isCompressed));
1062
1145
  }
1063
1146
  toDERHex(isCompressed = false) {
1064
- const sHex = sliceDer(numberToHex(this.s));
1147
+ const sHex = sliceDER(numberToHex(this.s));
1065
1148
  if (isCompressed)
1066
1149
  return sHex;
1067
- const rHex = sliceDer(numberToHex(this.r));
1150
+ const rHex = sliceDER(numberToHex(this.r));
1068
1151
  const rLen = numberToHex(rHex.length / 2);
1069
1152
  const sLen = numberToHex(sHex.length / 2);
1070
1153
  const length = numberToHex(rHex.length / 2 + sHex.length / 2 + 4);
@@ -1084,8 +1167,9 @@ class Signature {
1084
1167
  }
1085
1168
  }
1086
1169
  exports.Signature = Signature;
1087
- exports.SignResult = Signature;
1088
1170
  function concatBytes(...arrays) {
1171
+ if (!arrays.every((a) => a instanceof Uint8Array))
1172
+ throw new Error('Uint8Array list expected');
1089
1173
  if (arrays.length === 1)
1090
1174
  return arrays[0];
1091
1175
  const length = arrays.reduce((a, arr) => a + arr.length, 0);
@@ -1097,14 +1181,17 @@ function concatBytes(...arrays) {
1097
1181
  }
1098
1182
  return result;
1099
1183
  }
1184
+ const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
1100
1185
  function bytesToHex(uint8a) {
1101
1186
  let hex = '';
1102
1187
  for (let i = 0; i < uint8a.length; i++) {
1103
- hex += uint8a[i].toString(16).padStart(2, '0');
1188
+ hex += hexes[uint8a[i]];
1104
1189
  }
1105
1190
  return hex;
1106
1191
  }
1107
1192
  function pad64(num) {
1193
+ if (num > POW_2_256)
1194
+ throw new Error('pad64: invalid number');
1108
1195
  return num.toString(16).padStart(64, '0');
1109
1196
  }
1110
1197
  function pad32b(num) {
@@ -1125,11 +1212,15 @@ function hexToBytes(hex) {
1125
1212
  throw new TypeError('hexToBytes: expected string, got ' + typeof hex);
1126
1213
  }
1127
1214
  if (hex.length % 2)
1128
- throw new Error('hexToBytes: received invalid unpadded hex');
1215
+ throw new Error('hexToBytes: received invalid unpadded hex' + hex.length);
1129
1216
  const array = new Uint8Array(hex.length / 2);
1130
1217
  for (let i = 0; i < array.length; i++) {
1131
1218
  const j = i * 2;
1132
- array[i] = Number.parseInt(hex.slice(j, j + 2), 16);
1219
+ const hexByte = hex.slice(j, j + 2);
1220
+ const byte = Number.parseInt(hexByte, 16);
1221
+ if (Number.isNaN(byte))
1222
+ throw new Error('Invalid byte sequence');
1223
+ array[i] = byte;
1133
1224
  }
1134
1225
  return array;
1135
1226
  }
@@ -1137,17 +1228,16 @@ function ensureBytes(hex) {
1137
1228
  return hex instanceof Uint8Array ? hex : hexToBytes(hex);
1138
1229
  }
1139
1230
  function bytesToNumber(bytes) {
1231
+ if (!(bytes instanceof Uint8Array))
1232
+ throw new Error('Expected Uint8Array');
1140
1233
  return hexToNumber(bytesToHex(bytes));
1141
1234
  }
1142
- function parseByte(str) {
1143
- return Number.parseInt(str, 16) * 2;
1144
- }
1145
- function isValidScalar(num) {
1146
- if (typeof num === 'bigint' && num > 0n)
1147
- return true;
1235
+ function normalizeScalar(num) {
1148
1236
  if (typeof num === 'number' && num > 0 && Number.isSafeInteger(num))
1149
- return true;
1150
- return false;
1237
+ return BigInt(num);
1238
+ if (typeof num === 'bigint' && isWithinCurveOrder(num))
1239
+ return num;
1240
+ throw new TypeError('Expected valid private scalar: 0 < scalar < curve.n');
1151
1241
  }
1152
1242
  function mod(a, b = CURVE.P) {
1153
1243
  const result = a % b;
@@ -1156,7 +1246,7 @@ function mod(a, b = CURVE.P) {
1156
1246
  function pow2(x, power) {
1157
1247
  const { P } = CURVE;
1158
1248
  let res = x;
1159
- while (power-- > 0n) {
1249
+ while (power-- > _0n) {
1160
1250
  res *= res;
1161
1251
  res %= P;
1162
1252
  }
@@ -1164,55 +1254,59 @@ function pow2(x, power) {
1164
1254
  }
1165
1255
  function sqrtMod(x) {
1166
1256
  const { P } = CURVE;
1257
+ const _6n = BigInt(6);
1258
+ const _11n = BigInt(11);
1259
+ const _22n = BigInt(22);
1260
+ const _23n = BigInt(23);
1261
+ const _44n = BigInt(44);
1262
+ const _88n = BigInt(88);
1167
1263
  const b2 = (x * x * x) % P;
1168
1264
  const b3 = (b2 * b2 * x) % P;
1169
- const b6 = (pow2(b3, 3n) * b3) % P;
1170
- const b9 = (pow2(b6, 3n) * b3) % P;
1171
- const b11 = (pow2(b9, 2n) * b2) % P;
1172
- const b22 = (pow2(b11, 11n) * b11) % P;
1173
- const b44 = (pow2(b22, 22n) * b22) % P;
1174
- const b88 = (pow2(b44, 44n) * b44) % P;
1175
- const b176 = (pow2(b88, 88n) * b88) % P;
1176
- const b220 = (pow2(b176, 44n) * b44) % P;
1177
- const b223 = (pow2(b220, 3n) * b3) % P;
1178
- const t1 = (pow2(b223, 23n) * b22) % P;
1179
- const t2 = (pow2(t1, 6n) * b2) % P;
1180
- return pow2(t2, 2n);
1265
+ const b6 = (pow2(b3, _3n) * b3) % P;
1266
+ const b9 = (pow2(b6, _3n) * b3) % P;
1267
+ const b11 = (pow2(b9, _2n) * b2) % P;
1268
+ const b22 = (pow2(b11, _11n) * b11) % P;
1269
+ const b44 = (pow2(b22, _22n) * b22) % P;
1270
+ const b88 = (pow2(b44, _44n) * b44) % P;
1271
+ const b176 = (pow2(b88, _88n) * b88) % P;
1272
+ const b220 = (pow2(b176, _44n) * b44) % P;
1273
+ const b223 = (pow2(b220, _3n) * b3) % P;
1274
+ const t1 = (pow2(b223, _23n) * b22) % P;
1275
+ const t2 = (pow2(t1, _6n) * b2) % P;
1276
+ return pow2(t2, _2n);
1181
1277
  }
1182
1278
  function invert(number, modulo = CURVE.P) {
1183
- if (number === 0n || modulo <= 0n) {
1279
+ if (number === _0n || modulo <= _0n) {
1184
1280
  throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);
1185
1281
  }
1186
1282
  let a = mod(number, modulo);
1187
1283
  let b = modulo;
1188
- let [x, y, u, v] = [0n, 1n, 1n, 0n];
1189
- while (a !== 0n) {
1284
+ let x = _0n, y = _1n, u = _1n, v = _0n;
1285
+ while (a !== _0n) {
1190
1286
  const q = b / a;
1191
1287
  const r = b % a;
1192
1288
  const m = x - u * q;
1193
1289
  const n = y - v * q;
1194
- [b, a] = [a, r];
1195
- [x, y] = [u, v];
1196
- [u, v] = [m, n];
1290
+ b = a, a = r, x = u, y = v, u = m, v = n;
1197
1291
  }
1198
1292
  const gcd = b;
1199
- if (gcd !== 1n)
1293
+ if (gcd !== _1n)
1200
1294
  throw new Error('invert: does not exist');
1201
1295
  return mod(x, modulo);
1202
1296
  }
1203
1297
  function invertBatch(nums, n = CURVE.P) {
1204
1298
  const len = nums.length;
1205
1299
  const scratch = new Array(len);
1206
- let acc = 1n;
1300
+ let acc = _1n;
1207
1301
  for (let i = 0; i < len; i++) {
1208
- if (nums[i] === 0n)
1302
+ if (nums[i] === _0n)
1209
1303
  continue;
1210
1304
  scratch[i] = acc;
1211
1305
  acc = mod(acc * nums[i], n);
1212
1306
  }
1213
1307
  acc = invert(acc, n);
1214
1308
  for (let i = len - 1; i >= 0; i--) {
1215
- if (nums[i] === 0n)
1309
+ if (nums[i] === _0n)
1216
1310
  continue;
1217
1311
  const tmp = mod(acc * nums[i], n);
1218
1312
  nums[i] = mod(acc * scratch[i], n);
@@ -1220,13 +1314,13 @@ function invertBatch(nums, n = CURVE.P) {
1220
1314
  }
1221
1315
  return nums;
1222
1316
  }
1223
- const divNearest = (a, b) => (a + b / 2n) / b;
1224
- const POW_2_128 = 2n ** 128n;
1317
+ const divNearest = (a, b) => (a + b / _2n) / b;
1318
+ const POW_2_128 = _2n ** BigInt(128);
1225
1319
  function splitScalarEndo(k) {
1226
1320
  const { n } = CURVE;
1227
- const a1 = 0x3086d221a7d46bcde86c90e49284eb15n;
1228
- const b1 = -0xe4437ed6010e88286f547fa90abfe4c3n;
1229
- const a2 = 0x114ca50f7a8e2f3f657c1108d9d44cfd8n;
1321
+ const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');
1322
+ const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
1323
+ const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
1230
1324
  const b2 = a1;
1231
1325
  const c1 = divNearest(b2 * k, n);
1232
1326
  const c2 = divNearest(-b1 * k, n);
@@ -1240,7 +1334,7 @@ function splitScalarEndo(k) {
1240
1334
  k2 = n - k2;
1241
1335
  if (k1 > POW_2_128 || k2 > POW_2_128)
1242
1336
  throw new Error('splitScalarEndo: Endomorphism failed');
1243
- return [k1neg, k1, k2neg, k2];
1337
+ return { k1neg, k1, k2neg, k2 };
1244
1338
  }
1245
1339
  function truncateHash(hash) {
1246
1340
  if (typeof hash !== 'string')
@@ -1256,73 +1350,77 @@ function truncateHash(hash) {
1256
1350
  }
1257
1351
  return msg;
1258
1352
  }
1259
- function _abc6979(msgHash, privateKey) {
1260
- if (msgHash == null)
1261
- throw new Error(`sign: expected valid msgHash, not "${msgHash}"`);
1262
- const num = typeof msgHash === 'string' ? hexToNumber(msgHash) : bytesToNumber(msgHash);
1263
- const h1 = pad32b(num);
1264
- const h1n = bytesToNumber(h1);
1265
- const x = pad32b(privateKey);
1266
- let v = new Uint8Array(32).fill(1);
1267
- let k = new Uint8Array(32).fill(0);
1268
- const b0 = Uint8Array.from([0x00]);
1269
- const b1 = Uint8Array.from([0x01]);
1270
- return [h1, h1n, x, v, k, b0, b1];
1271
- }
1272
- async function getQRSrfc6979(msgHash, privateKey) {
1273
- const privKey = normalizePrivateKey(privateKey);
1274
- let [h1, h1n, x, v, k, b0, b1] = _abc6979(msgHash, privKey);
1275
- const hmac = exports.utils.hmacSha256;
1276
- k = await hmac(k, v, b0, x, h1);
1277
- v = await hmac(k, v);
1278
- k = await hmac(k, v, b1, x, h1);
1279
- v = await hmac(k, v);
1280
- for (let i = 0; i < 1000; i++) {
1281
- v = await hmac(k, v);
1282
- let qrs = calcQRSFromK(v, h1n, privKey);
1283
- if (qrs)
1284
- return qrs;
1285
- k = await hmac(k, v, b0);
1286
- v = await hmac(k, v);
1287
- }
1288
- throw new TypeError('secp256k1: Tried 1,000 k values for sign(), all were invalid');
1289
- }
1290
- function getQRSrfc6979Sync(msgHash, privateKey) {
1291
- const privKey = normalizePrivateKey(privateKey);
1292
- let [h1, h1n, x, v, k, b0, b1] = _abc6979(msgHash, privKey);
1293
- const hmac = exports.utils.hmacSha256Sync;
1294
- if (!hmac)
1295
- throw new Error('utils.hmacSha256Sync is undefined, you need to set it');
1296
- k = hmac(k, v, b0, x, h1);
1297
- if (k instanceof Promise)
1298
- throw new Error('To use sync sign(), ensure utils.hmacSha256 is sync');
1299
- v = hmac(k, v);
1300
- k = hmac(k, v, b1, x, h1);
1301
- v = hmac(k, v);
1302
- for (let i = 0; i < 1000; i++) {
1303
- v = hmac(k, v);
1304
- let qrs = calcQRSFromK(v, h1n, privKey);
1305
- if (qrs)
1306
- return qrs;
1307
- k = hmac(k, v, b0);
1308
- v = hmac(k, v);
1309
- }
1310
- throw new TypeError('secp256k1: Tried 1,000 k values for sign(), all were invalid');
1353
+ class HmacDrbg {
1354
+ constructor() {
1355
+ this.v = new Uint8Array(32).fill(1);
1356
+ this.k = new Uint8Array(32).fill(0);
1357
+ this.counter = 0;
1358
+ }
1359
+ hmac(...values) {
1360
+ return exports.utils.hmacSha256(this.k, ...values);
1361
+ }
1362
+ hmacSync(...values) {
1363
+ if (typeof exports.utils.hmacSha256Sync !== 'function')
1364
+ throw new Error('utils.hmacSha256Sync is undefined, you need to set it');
1365
+ const res = exports.utils.hmacSha256Sync(this.k, ...values);
1366
+ if (res instanceof Promise)
1367
+ throw new Error('To use sync sign(), ensure utils.hmacSha256 is sync');
1368
+ return res;
1369
+ }
1370
+ incr() {
1371
+ if (this.counter >= 1000) {
1372
+ throw new Error('Tried 1,000 k values for sign(), all were invalid');
1373
+ }
1374
+ this.counter += 1;
1375
+ }
1376
+ async reseed(seed = new Uint8Array()) {
1377
+ this.k = await this.hmac(this.v, Uint8Array.from([0x00]), seed);
1378
+ this.v = await this.hmac(this.v);
1379
+ if (seed.length === 0)
1380
+ return;
1381
+ this.k = await this.hmac(this.v, Uint8Array.from([0x01]), seed);
1382
+ this.v = await this.hmac(this.v);
1383
+ }
1384
+ reseedSync(seed = new Uint8Array()) {
1385
+ this.k = this.hmacSync(this.v, Uint8Array.from([0x00]), seed);
1386
+ this.v = this.hmacSync(this.v);
1387
+ if (seed.length === 0)
1388
+ return;
1389
+ this.k = this.hmacSync(this.v, Uint8Array.from([0x01]), seed);
1390
+ this.v = this.hmacSync(this.v);
1391
+ }
1392
+ async generate() {
1393
+ this.incr();
1394
+ this.v = await this.hmac(this.v);
1395
+ return this.v;
1396
+ }
1397
+ generateSync() {
1398
+ this.incr();
1399
+ this.v = this.hmacSync(this.v);
1400
+ return this.v;
1401
+ }
1311
1402
  }
1312
1403
  function isWithinCurveOrder(num) {
1313
- return 0 < num && num < CURVE.n;
1404
+ return _0n < num && num < CURVE.n;
1314
1405
  }
1315
- function calcQRSFromK(v, msg, priv) {
1316
- const k = bytesToNumber(v);
1406
+ function isWithinCurvePrime(num) {
1407
+ return 0n < num && num < CURVE.P;
1408
+ }
1409
+ function kmdToSig(kBytes, m, d) {
1410
+ const k = bytesToNumber(kBytes);
1317
1411
  if (!isWithinCurveOrder(k))
1318
1412
  return;
1319
- const max = CURVE.n;
1413
+ const { n } = CURVE;
1320
1414
  const q = Point.BASE.multiply(k);
1321
- const r = mod(q.x, max);
1322
- const s = mod(invert(k, max) * (msg + r * priv), max);
1323
- if (r === 0n || s === 0n)
1415
+ const r = mod(q.x, n);
1416
+ if (r === _0n)
1324
1417
  return;
1325
- return [q, r, s];
1418
+ const s = mod(invert(k, n) * mod(m + d * r, n), n);
1419
+ if (s === _0n)
1420
+ return;
1421
+ const sig = new Signature(r, s);
1422
+ const recovery = (q.x === sig.r ? 0 : 2) | Number(q.y & _1n);
1423
+ return { sig, recovery };
1326
1424
  }
1327
1425
  function normalizePrivateKey(key) {
1328
1426
  let num;
@@ -1363,21 +1461,19 @@ function normalizeSignature(signature) {
1363
1461
  signature.assertValidity();
1364
1462
  return signature;
1365
1463
  }
1366
- else {
1464
+ try {
1367
1465
  return Signature.fromDER(signature);
1368
1466
  }
1467
+ catch (error) {
1468
+ return Signature.fromCompact(signature);
1469
+ }
1369
1470
  }
1370
1471
  function getPublicKey(privateKey, isCompressed = false) {
1371
- const point = Point.fromPrivateKey(privateKey);
1372
- if (typeof privateKey === 'string') {
1373
- return point.toHex(isCompressed);
1374
- }
1375
- return point.toRawBytes(isCompressed);
1472
+ return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
1376
1473
  }
1377
1474
  exports.getPublicKey = getPublicKey;
1378
1475
  function recoverPublicKey(msgHash, signature, recovery) {
1379
- const point = Point.fromSignature(msgHash, signature, recovery);
1380
- return typeof msgHash === 'string' ? point.toHex() : point.toRawBytes();
1476
+ return Point.fromSignature(msgHash, signature, recovery).toRawBytes();
1381
1477
  }
1382
1478
  exports.recoverPublicKey = recoverPublicKey;
1383
1479
  function isPub(item) {
@@ -1399,38 +1495,74 @@ function getSharedSecret(privateA, publicB, isCompressed = false) {
1399
1495
  throw new TypeError('getSharedSecret: second arg must be public key');
1400
1496
  const b = normalizePublicKey(publicB);
1401
1497
  b.assertValidity();
1402
- const shared = b.multiply(normalizePrivateKey(privateA));
1403
- return typeof privateA === 'string'
1404
- ? shared.toHex(isCompressed)
1405
- : shared.toRawBytes(isCompressed);
1498
+ return b.multiply(normalizePrivateKey(privateA)).toRawBytes(isCompressed);
1406
1499
  }
1407
1500
  exports.getSharedSecret = getSharedSecret;
1408
- function QRSToSig(qrs, opts, str = false) {
1409
- const [q, r, s] = qrs;
1410
- let { canonical, der, recovered } = opts;
1411
- let recovery = (q.x === r ? 0 : 2) | Number(q.y & 1n);
1412
- let adjustedS = s;
1413
- const HIGH_NUMBER = CURVE.n >> 1n;
1414
- if (s > HIGH_NUMBER && canonical) {
1415
- adjustedS = CURVE.n - s;
1501
+ function bits2int(bytes) {
1502
+ const slice = bytes.length > 32 ? bytes.slice(0, 32) : bytes;
1503
+ return bytesToNumber(slice);
1504
+ }
1505
+ function bits2octets(bytes) {
1506
+ const z1 = bits2int(bytes);
1507
+ const z2 = mod(z1, CURVE.n);
1508
+ return int2octets(z2 < _0n ? z1 : z2);
1509
+ }
1510
+ function int2octets(num) {
1511
+ if (typeof num !== 'bigint')
1512
+ throw new Error('Expected bigint');
1513
+ const hex = pad64(num);
1514
+ return hexToBytes(hex);
1515
+ }
1516
+ function initSigArgs(msgHash, privateKey, extraEntropy) {
1517
+ if (msgHash == null)
1518
+ throw new Error(`sign: expected valid msgHash, not "${msgHash}"`);
1519
+ const h1 = ensureBytes(msgHash);
1520
+ const d = normalizePrivateKey(privateKey);
1521
+ const seedArgs = [int2octets(d), bits2octets(h1)];
1522
+ if (extraEntropy != null) {
1523
+ if (extraEntropy === true)
1524
+ extraEntropy = exports.utils.randomBytes(32);
1525
+ const e = pad32b(bytesToNumber(ensureBytes(extraEntropy)));
1526
+ if (e.length !== 32)
1527
+ throw new Error('secp256k1: Expected 32 bytes of extra data');
1528
+ seedArgs.push(e);
1529
+ }
1530
+ const seed = concatBytes(...seedArgs);
1531
+ const m = bits2int(h1);
1532
+ return { seed, m, d };
1533
+ }
1534
+ function finalizeSig(recSig, opts) {
1535
+ let { sig, recovery } = recSig;
1536
+ const { canonical, der, recovered } = Object.assign({ canonical: true, der: true }, opts);
1537
+ if (canonical && sig.hasHighS()) {
1538
+ sig = sig.normalizeS();
1416
1539
  recovery ^= 1;
1417
1540
  }
1418
- const sig = new Signature(r, adjustedS);
1419
- sig.assertValidity();
1420
- const hex = der === false ? sig.toCompactHex() : sig.toDERHex();
1421
- const hashed = str ? hex : hexToBytes(hex);
1541
+ const hashed = der ? sig.toDERRawBytes() : sig.toCompactRawBytes();
1422
1542
  return recovered ? [hashed, recovery] : hashed;
1423
1543
  }
1424
1544
  async function sign(msgHash, privKey, opts = {}) {
1425
- return QRSToSig(await getQRSrfc6979(msgHash, privKey), opts, typeof msgHash === 'string');
1545
+ const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
1546
+ let sig;
1547
+ const drbg = new HmacDrbg();
1548
+ await drbg.reseed(seed);
1549
+ while (!(sig = kmdToSig(await drbg.generate(), m, d)))
1550
+ await drbg.reseed();
1551
+ return finalizeSig(sig, opts);
1426
1552
  }
1427
1553
  exports.sign = sign;
1428
1554
  function signSync(msgHash, privKey, opts = {}) {
1429
- return QRSToSig(getQRSrfc6979Sync(msgHash, privKey), opts, typeof msgHash === 'string');
1555
+ const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
1556
+ let sig;
1557
+ const drbg = new HmacDrbg();
1558
+ drbg.reseedSync(seed);
1559
+ while (!(sig = kmdToSig(drbg.generateSync(), m, d)))
1560
+ drbg.reseedSync();
1561
+ return finalizeSig(sig, opts);
1430
1562
  }
1431
1563
  exports.signSync = signSync;
1432
- function verify(signature, msgHash, publicKey) {
1433
- const { n } = CURVE;
1564
+ const vopts = { strict: true };
1565
+ function verify(signature, msgHash, publicKey, opts = vopts) {
1434
1566
  let sig;
1435
1567
  try {
1436
1568
  sig = normalizeSignature(signature);
@@ -1439,10 +1571,19 @@ function verify(signature, msgHash, publicKey) {
1439
1571
  return false;
1440
1572
  }
1441
1573
  const { r, s } = sig;
1574
+ if (opts.strict && sig.hasHighS())
1575
+ return false;
1442
1576
  const h = truncateHash(msgHash);
1443
- if (h === 0n)
1577
+ if (h === _0n)
1444
1578
  return false;
1445
- const pubKey = JacobianPoint.fromAffine(normalizePublicKey(publicKey));
1579
+ let pubKey;
1580
+ try {
1581
+ pubKey = JacobianPoint.fromAffine(normalizePublicKey(publicKey));
1582
+ }
1583
+ catch (error) {
1584
+ return false;
1585
+ }
1586
+ const { n } = CURVE;
1446
1587
  const s1 = invert(s, n);
1447
1588
  const u1 = mod(h * s1, n);
1448
1589
  const u2 = mod(r * s1, n);
@@ -1465,22 +1606,21 @@ async function createChallenge(x, P, message) {
1465
1606
  return mod(t, CURVE.n);
1466
1607
  }
1467
1608
  function hasEvenY(point) {
1468
- return mod(point.y, 2n) === 0n;
1609
+ return mod(point.y, _2n) === _0n;
1469
1610
  }
1470
1611
  class SchnorrSignature {
1471
1612
  constructor(r, s) {
1472
1613
  this.r = r;
1473
1614
  this.s = s;
1474
- if (r <= 0n || s <= 0n || r >= CURVE.P || s >= CURVE.n)
1615
+ if (!isWithinCurvePrime(r) || !isWithinCurveOrder(s))
1475
1616
  throw new Error('Invalid signature');
1476
1617
  }
1477
1618
  static fromHex(hex) {
1478
1619
  const bytes = ensureBytes(hex);
1479
- if (bytes.length !== 64) {
1620
+ if (bytes.length !== 64)
1480
1621
  throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${bytes.length}`);
1481
- }
1482
1622
  const r = bytesToNumber(bytes.slice(0, 32));
1483
- const s = bytesToNumber(bytes.slice(32));
1623
+ const s = bytesToNumber(bytes.slice(32, 64));
1484
1624
  return new SchnorrSignature(r, s);
1485
1625
  }
1486
1626
  toHex() {
@@ -1491,16 +1631,13 @@ class SchnorrSignature {
1491
1631
  }
1492
1632
  }
1493
1633
  function schnorrGetPublicKey(privateKey) {
1494
- const P = Point.fromPrivateKey(privateKey);
1495
- return typeof privateKey === 'string' ? P.toHexX() : P.toRawX();
1634
+ return Point.fromPrivateKey(privateKey).toRawX();
1496
1635
  }
1497
- async function schnorrSign(msgHash, privateKey, auxRand = exports.utils.randomBytes()) {
1498
- if (msgHash == null)
1499
- throw new TypeError(`sign: Expected valid message, not "${msgHash}"`);
1500
- if (!privateKey)
1501
- privateKey = 0n;
1636
+ async function schnorrSign(message, privateKey, auxRand = exports.utils.randomBytes()) {
1637
+ if (message == null)
1638
+ throw new TypeError(`sign: Expected valid message, not "${message}"`);
1502
1639
  const { n } = CURVE;
1503
- const m = ensureBytes(msgHash);
1640
+ const m = ensureBytes(message);
1504
1641
  const d0 = normalizePrivateKey(privateKey);
1505
1642
  const rand = ensureBytes(auxRand);
1506
1643
  if (rand.length !== 32)
@@ -1511,7 +1648,7 @@ async function schnorrSign(msgHash, privateKey, auxRand = exports.utils.randomBy
1511
1648
  const t = d ^ t0h;
1512
1649
  const k0h = await taggedHash('BIP0340/nonce', pad32b(t), P.toRawX(), m);
1513
1650
  const k0 = mod(k0h, n);
1514
- if (k0 === 0n)
1651
+ if (k0 === _0n)
1515
1652
  throw new Error('sign: Creation of signature failed. k is zero');
1516
1653
  const R = Point.fromPrivateKey(k0);
1517
1654
  const k = hasEvenY(R) ? k0 : n - k0;
@@ -1520,11 +1657,11 @@ async function schnorrSign(msgHash, privateKey, auxRand = exports.utils.randomBy
1520
1657
  const isValid = await schnorrVerify(sig.toRawBytes(), m, P.toRawX());
1521
1658
  if (!isValid)
1522
1659
  throw new Error('sign: Invalid signature produced');
1523
- return typeof msgHash === 'string' ? sig.toHex() : sig.toRawBytes();
1660
+ return sig.toRawBytes();
1524
1661
  }
1525
- async function schnorrVerify(signature, msgHash, publicKey) {
1662
+ async function schnorrVerify(signature, message, publicKey) {
1526
1663
  const sig = signature instanceof SchnorrSignature ? signature : SchnorrSignature.fromHex(signature);
1527
- const m = typeof msgHash === 'string' ? hexToBytes(msgHash) : msgHash;
1664
+ const m = ensureBytes(message);
1528
1665
  const P = normalizePublicKey(publicKey);
1529
1666
  const e = await createChallenge(sig.r, P, m);
1530
1667
  const sG = Point.fromPrivateKey(sig.s);
@@ -1541,14 +1678,10 @@ exports.schnorr = {
1541
1678
  verify: schnorrVerify,
1542
1679
  };
1543
1680
  Point.BASE._setWindowSize(8);
1544
- const crypto = (() => {
1545
- const webCrypto = typeof self === 'object' && 'crypto' in self ? self.crypto : undefined;
1546
- const nodeRequire = true && "function" === 'function';
1547
- return {
1548
- node: nodeRequire && !webCrypto ? __webpack_require__(5102) : undefined,
1549
- web: webCrypto,
1550
- };
1551
- })();
1681
+ const crypto = {
1682
+ node: crypto_1.default,
1683
+ web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,
1684
+ };
1552
1685
  exports.utils = {
1553
1686
  isValidPrivateKey(privateKey) {
1554
1687
  try {
@@ -1565,7 +1698,7 @@ exports.utils = {
1565
1698
  }
1566
1699
  else if (crypto.node) {
1567
1700
  const { randomBytes } = crypto.node;
1568
- return new Uint8Array(randomBytes(bytesLength).buffer);
1701
+ return Uint8Array.from(randomBytes(bytesLength));
1569
1702
  }
1570
1703
  else {
1571
1704
  throw new Error("The environment doesn't have randomBytes function");
@@ -1576,11 +1709,12 @@ exports.utils = {
1576
1709
  while (i--) {
1577
1710
  const b32 = exports.utils.randomBytes(32);
1578
1711
  const num = bytesToNumber(b32);
1579
- if (isWithinCurveOrder(num) && num !== 1n)
1712
+ if (isWithinCurveOrder(num) && num !== _1n)
1580
1713
  return b32;
1581
1714
  }
1582
1715
  throw new Error('Valid private key was not found in 8 iterations. PRNG is broken');
1583
1716
  },
1717
+ bytesToHex,
1584
1718
  sha256: async (message) => {
1585
1719
  if (crypto.web) {
1586
1720
  const buffer = await crypto.web.subtle.digest('SHA-256', message.buffer);
@@ -1604,9 +1738,7 @@ exports.utils = {
1604
1738
  else if (crypto.node) {
1605
1739
  const { createHmac } = crypto.node;
1606
1740
  const hash = createHmac('sha256', key);
1607
- for (let message of messages) {
1608
- hash.update(message);
1609
- }
1741
+ messages.forEach((m) => hash.update(m));
1610
1742
  return Uint8Array.from(hash.digest());
1611
1743
  }
1612
1744
  else {
@@ -1618,7 +1750,7 @@ exports.utils = {
1618
1750
  precompute(windowSize = 8, point = Point.BASE) {
1619
1751
  const cached = point === Point.BASE ? point : new Point(point.x, point.y);
1620
1752
  cached._setWindowSize(windowSize);
1621
- cached.multiply(3n);
1753
+ cached.multiply(_3n);
1622
1754
  return cached;
1623
1755
  },
1624
1756
  };
@@ -2757,1753 +2889,563 @@ utf8.write = function utf8_write(string, buffer, offset) {
2757
2889
 
2758
2890
  /***/ }),
2759
2891
 
2760
- /***/ 9669:
2761
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2762
-
2763
- module.exports = __webpack_require__(1609);
2764
-
2765
- /***/ }),
2766
-
2767
- /***/ 5448:
2768
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2769
-
2770
- "use strict";
2771
-
2772
-
2773
- var utils = __webpack_require__(4867);
2774
- var settle = __webpack_require__(6026);
2775
- var cookies = __webpack_require__(4372);
2776
- var buildURL = __webpack_require__(5327);
2777
- var buildFullPath = __webpack_require__(4097);
2778
- var parseHeaders = __webpack_require__(4109);
2779
- var isURLSameOrigin = __webpack_require__(7985);
2780
- var createError = __webpack_require__(5061);
2781
-
2782
- module.exports = function xhrAdapter(config) {
2783
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2784
- var requestData = config.data;
2785
- var requestHeaders = config.headers;
2786
-
2787
- if (utils.isFormData(requestData)) {
2788
- delete requestHeaders['Content-Type']; // Let the browser set it
2789
- }
2790
-
2791
- var request = new XMLHttpRequest();
2792
-
2793
- // HTTP basic authentication
2794
- if (config.auth) {
2795
- var username = config.auth.username || '';
2796
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2797
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
2798
- }
2799
-
2800
- var fullPath = buildFullPath(config.baseURL, config.url);
2801
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2802
-
2803
- // Set the request timeout in MS
2804
- request.timeout = config.timeout;
2805
-
2806
- // Listen for ready state
2807
- request.onreadystatechange = function handleLoad() {
2808
- if (!request || request.readyState !== 4) {
2809
- return;
2810
- }
2811
-
2812
- // The request errored out and we didn't get a response, this will be
2813
- // handled by onerror instead
2814
- // With one exception: request that using file: protocol, most browsers
2815
- // will return status as 0 even though it's a successful request
2816
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2817
- return;
2818
- }
2819
-
2820
- // Prepare the response
2821
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
2822
- var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
2823
- var response = {
2824
- data: responseData,
2825
- status: request.status,
2826
- statusText: request.statusText,
2827
- headers: responseHeaders,
2828
- config: config,
2829
- request: request
2830
- };
2831
-
2832
- settle(resolve, reject, response);
2833
-
2834
- // Clean up request
2835
- request = null;
2836
- };
2837
-
2838
- // Handle browser request cancellation (as opposed to a manual cancellation)
2839
- request.onabort = function handleAbort() {
2840
- if (!request) {
2841
- return;
2842
- }
2843
-
2844
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
2845
-
2846
- // Clean up request
2847
- request = null;
2848
- };
2849
-
2850
- // Handle low level network errors
2851
- request.onerror = function handleError() {
2852
- // Real errors are hidden from us by the browser
2853
- // onerror should only fire if it's a network error
2854
- reject(createError('Network Error', config, null, request));
2855
-
2856
- // Clean up request
2857
- request = null;
2858
- };
2859
-
2860
- // Handle timeout
2861
- request.ontimeout = function handleTimeout() {
2862
- var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
2863
- if (config.timeoutErrorMessage) {
2864
- timeoutErrorMessage = config.timeoutErrorMessage;
2865
- }
2866
- reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
2867
- request));
2868
-
2869
- // Clean up request
2870
- request = null;
2871
- };
2872
-
2873
- // Add xsrf header
2874
- // This is only done if running in a standard browser environment.
2875
- // Specifically not if we're in a web worker, or react-native.
2876
- if (utils.isStandardBrowserEnv()) {
2877
- // Add xsrf header
2878
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
2879
- cookies.read(config.xsrfCookieName) :
2880
- undefined;
2881
-
2882
- if (xsrfValue) {
2883
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
2884
- }
2885
- }
2886
-
2887
- // Add headers to the request
2888
- if ('setRequestHeader' in request) {
2889
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
2890
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
2891
- // Remove Content-Type if data is undefined
2892
- delete requestHeaders[key];
2893
- } else {
2894
- // Otherwise add header to the request
2895
- request.setRequestHeader(key, val);
2896
- }
2897
- });
2898
- }
2899
-
2900
- // Add withCredentials to request if needed
2901
- if (!utils.isUndefined(config.withCredentials)) {
2902
- request.withCredentials = !!config.withCredentials;
2903
- }
2904
-
2905
- // Add responseType to request if needed
2906
- if (config.responseType) {
2907
- try {
2908
- request.responseType = config.responseType;
2909
- } catch (e) {
2910
- // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
2911
- // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
2912
- if (config.responseType !== 'json') {
2913
- throw e;
2914
- }
2915
- }
2916
- }
2917
-
2918
- // Handle progress if needed
2919
- if (typeof config.onDownloadProgress === 'function') {
2920
- request.addEventListener('progress', config.onDownloadProgress);
2921
- }
2922
-
2923
- // Not all browsers support upload events
2924
- if (typeof config.onUploadProgress === 'function' && request.upload) {
2925
- request.upload.addEventListener('progress', config.onUploadProgress);
2926
- }
2927
-
2928
- if (config.cancelToken) {
2929
- // Handle cancellation
2930
- config.cancelToken.promise.then(function onCanceled(cancel) {
2931
- if (!request) {
2932
- return;
2933
- }
2934
-
2935
- request.abort();
2936
- reject(cancel);
2937
- // Clean up request
2938
- request = null;
2939
- });
2940
- }
2941
-
2942
- if (!requestData) {
2943
- requestData = null;
2944
- }
2945
-
2946
- // Send the request
2947
- request.send(requestData);
2948
- });
2949
- };
2950
-
2951
-
2952
- /***/ }),
2953
-
2954
- /***/ 1609:
2955
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2956
-
2957
- "use strict";
2958
-
2959
-
2960
- var utils = __webpack_require__(4867);
2961
- var bind = __webpack_require__(1849);
2962
- var Axios = __webpack_require__(321);
2963
- var mergeConfig = __webpack_require__(7185);
2964
- var defaults = __webpack_require__(5655);
2965
-
2966
- /**
2967
- * Create an instance of Axios
2968
- *
2969
- * @param {Object} defaultConfig The default config for the instance
2970
- * @return {Axios} A new instance of Axios
2971
- */
2972
- function createInstance(defaultConfig) {
2973
- var context = new Axios(defaultConfig);
2974
- var instance = bind(Axios.prototype.request, context);
2975
-
2976
- // Copy axios.prototype to instance
2977
- utils.extend(instance, Axios.prototype, context);
2978
-
2979
- // Copy context to instance
2980
- utils.extend(instance, context);
2981
-
2982
- return instance;
2983
- }
2984
-
2985
- // Create the default instance to be exported
2986
- var axios = createInstance(defaults);
2987
-
2988
- // Expose Axios class to allow class inheritance
2989
- axios.Axios = Axios;
2990
-
2991
- // Factory for creating new instances
2992
- axios.create = function create(instanceConfig) {
2993
- return createInstance(mergeConfig(axios.defaults, instanceConfig));
2994
- };
2995
-
2996
- // Expose Cancel & CancelToken
2997
- axios.Cancel = __webpack_require__(5263);
2998
- axios.CancelToken = __webpack_require__(4972);
2999
- axios.isCancel = __webpack_require__(6502);
3000
-
3001
- // Expose all/spread
3002
- axios.all = function all(promises) {
3003
- return Promise.all(promises);
3004
- };
3005
- axios.spread = __webpack_require__(8713);
3006
-
3007
- // Expose isAxiosError
3008
- axios.isAxiosError = __webpack_require__(6268);
3009
-
3010
- module.exports = axios;
3011
-
3012
- // Allow use of default import syntax in TypeScript
3013
- module.exports.default = axios;
3014
-
3015
-
3016
- /***/ }),
3017
-
3018
- /***/ 5263:
3019
- /***/ ((module) => {
3020
-
3021
- "use strict";
3022
-
3023
-
3024
- /**
3025
- * A `Cancel` is an object that is thrown when an operation is canceled.
3026
- *
3027
- * @class
3028
- * @param {string=} message The message.
3029
- */
3030
- function Cancel(message) {
3031
- this.message = message;
3032
- }
3033
-
3034
- Cancel.prototype.toString = function toString() {
3035
- return 'Cancel' + (this.message ? ': ' + this.message : '');
3036
- };
3037
-
3038
- Cancel.prototype.__CANCEL__ = true;
3039
-
3040
- module.exports = Cancel;
3041
-
3042
-
3043
- /***/ }),
3044
-
3045
- /***/ 4972:
3046
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3047
-
3048
- "use strict";
3049
-
3050
-
3051
- var Cancel = __webpack_require__(5263);
3052
-
3053
- /**
3054
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
3055
- *
3056
- * @class
3057
- * @param {Function} executor The executor function.
3058
- */
3059
- function CancelToken(executor) {
3060
- if (typeof executor !== 'function') {
3061
- throw new TypeError('executor must be a function.');
3062
- }
2892
+ /***/ 4098:
2893
+ /***/ (function(module, exports) {
3063
2894
 
3064
- var resolvePromise;
3065
- this.promise = new Promise(function promiseExecutor(resolve) {
3066
- resolvePromise = resolve;
3067
- });
3068
-
3069
- var token = this;
3070
- executor(function cancel(message) {
3071
- if (token.reason) {
3072
- // Cancellation has already been requested
3073
- return;
3074
- }
3075
-
3076
- token.reason = new Cancel(message);
3077
- resolvePromise(token.reason);
3078
- });
2895
+ var global = typeof self !== 'undefined' ? self : this;
2896
+ var __self__ = (function () {
2897
+ function F() {
2898
+ this.fetch = false;
2899
+ this.DOMException = global.DOMException
3079
2900
  }
2901
+ F.prototype = global;
2902
+ return new F();
2903
+ })();
2904
+ (function(self) {
3080
2905
 
3081
- /**
3082
- * Throws a `Cancel` if cancellation has been requested.
3083
- */
3084
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
3085
- if (this.reason) {
3086
- throw this.reason;
3087
- }
3088
- };
3089
-
3090
- /**
3091
- * Returns an object that contains a new `CancelToken` and a function that, when called,
3092
- * cancels the `CancelToken`.
3093
- */
3094
- CancelToken.source = function source() {
3095
- var cancel;
3096
- var token = new CancelToken(function executor(c) {
3097
- cancel = c;
3098
- });
3099
- return {
3100
- token: token,
3101
- cancel: cancel
3102
- };
3103
- };
3104
-
3105
- module.exports = CancelToken;
3106
-
3107
-
3108
- /***/ }),
3109
-
3110
- /***/ 6502:
3111
- /***/ ((module) => {
3112
-
3113
- "use strict";
3114
-
3115
-
3116
- module.exports = function isCancel(value) {
3117
- return !!(value && value.__CANCEL__);
3118
- };
3119
-
3120
-
3121
- /***/ }),
3122
-
3123
- /***/ 321:
3124
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3125
-
3126
- "use strict";
3127
-
3128
-
3129
- var utils = __webpack_require__(4867);
3130
- var buildURL = __webpack_require__(5327);
3131
- var InterceptorManager = __webpack_require__(782);
3132
- var dispatchRequest = __webpack_require__(3572);
3133
- var mergeConfig = __webpack_require__(7185);
3134
-
3135
- /**
3136
- * Create a new instance of Axios
3137
- *
3138
- * @param {Object} instanceConfig The default config for the instance
3139
- */
3140
- function Axios(instanceConfig) {
3141
- this.defaults = instanceConfig;
3142
- this.interceptors = {
3143
- request: new InterceptorManager(),
3144
- response: new InterceptorManager()
3145
- };
3146
- }
3147
-
3148
- /**
3149
- * Dispatch a request
3150
- *
3151
- * @param {Object} config The config specific for this request (merged with this.defaults)
3152
- */
3153
- Axios.prototype.request = function request(config) {
3154
- /*eslint no-param-reassign:0*/
3155
- // Allow for axios('example/url'[, config]) a la fetch API
3156
- if (typeof config === 'string') {
3157
- config = arguments[1] || {};
3158
- config.url = arguments[0];
3159
- } else {
3160
- config = config || {};
3161
- }
3162
-
3163
- config = mergeConfig(this.defaults, config);
3164
-
3165
- // Set config.method
3166
- if (config.method) {
3167
- config.method = config.method.toLowerCase();
3168
- } else if (this.defaults.method) {
3169
- config.method = this.defaults.method.toLowerCase();
3170
- } else {
3171
- config.method = 'get';
3172
- }
3173
-
3174
- // Hook up interceptors middleware
3175
- var chain = [dispatchRequest, undefined];
3176
- var promise = Promise.resolve(config);
3177
-
3178
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3179
- chain.unshift(interceptor.fulfilled, interceptor.rejected);
3180
- });
3181
-
3182
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3183
- chain.push(interceptor.fulfilled, interceptor.rejected);
3184
- });
3185
-
3186
- while (chain.length) {
3187
- promise = promise.then(chain.shift(), chain.shift());
3188
- }
3189
-
3190
- return promise;
3191
- };
3192
-
3193
- Axios.prototype.getUri = function getUri(config) {
3194
- config = mergeConfig(this.defaults, config);
3195
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
3196
- };
3197
-
3198
- // Provide aliases for supported request methods
3199
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3200
- /*eslint func-names:0*/
3201
- Axios.prototype[method] = function(url, config) {
3202
- return this.request(mergeConfig(config || {}, {
3203
- method: method,
3204
- url: url,
3205
- data: (config || {}).data
3206
- }));
3207
- };
3208
- });
3209
-
3210
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3211
- /*eslint func-names:0*/
3212
- Axios.prototype[method] = function(url, data, config) {
3213
- return this.request(mergeConfig(config || {}, {
3214
- method: method,
3215
- url: url,
3216
- data: data
3217
- }));
3218
- };
3219
- });
3220
-
3221
- module.exports = Axios;
3222
-
3223
-
3224
- /***/ }),
3225
-
3226
- /***/ 782:
3227
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3228
-
3229
- "use strict";
3230
-
3231
-
3232
- var utils = __webpack_require__(4867);
3233
-
3234
- function InterceptorManager() {
3235
- this.handlers = [];
3236
- }
3237
-
3238
- /**
3239
- * Add a new interceptor to the stack
3240
- *
3241
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
3242
- * @param {Function} rejected The function to handle `reject` for a `Promise`
3243
- *
3244
- * @return {Number} An ID used to remove interceptor later
3245
- */
3246
- InterceptorManager.prototype.use = function use(fulfilled, rejected) {
3247
- this.handlers.push({
3248
- fulfilled: fulfilled,
3249
- rejected: rejected
3250
- });
3251
- return this.handlers.length - 1;
3252
- };
3253
-
3254
- /**
3255
- * Remove an interceptor from the stack
3256
- *
3257
- * @param {Number} id The ID that was returned by `use`
3258
- */
3259
- InterceptorManager.prototype.eject = function eject(id) {
3260
- if (this.handlers[id]) {
3261
- this.handlers[id] = null;
3262
- }
3263
- };
3264
-
3265
- /**
3266
- * Iterate over all the registered interceptors
3267
- *
3268
- * This method is particularly useful for skipping over any
3269
- * interceptors that may have become `null` calling `eject`.
3270
- *
3271
- * @param {Function} fn The function to call for each interceptor
3272
- */
3273
- InterceptorManager.prototype.forEach = function forEach(fn) {
3274
- utils.forEach(this.handlers, function forEachHandler(h) {
3275
- if (h !== null) {
3276
- fn(h);
3277
- }
3278
- });
3279
- };
3280
-
3281
- module.exports = InterceptorManager;
3282
-
3283
-
3284
- /***/ }),
3285
-
3286
- /***/ 4097:
3287
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3288
-
3289
- "use strict";
3290
-
3291
-
3292
- var isAbsoluteURL = __webpack_require__(1793);
3293
- var combineURLs = __webpack_require__(7303);
3294
-
3295
- /**
3296
- * Creates a new URL by combining the baseURL with the requestedURL,
3297
- * only when the requestedURL is not already an absolute URL.
3298
- * If the requestURL is absolute, this function returns the requestedURL untouched.
3299
- *
3300
- * @param {string} baseURL The base URL
3301
- * @param {string} requestedURL Absolute or relative URL to combine
3302
- * @returns {string} The combined full path
3303
- */
3304
- module.exports = function buildFullPath(baseURL, requestedURL) {
3305
- if (baseURL && !isAbsoluteURL(requestedURL)) {
3306
- return combineURLs(baseURL, requestedURL);
3307
- }
3308
- return requestedURL;
3309
- };
3310
-
3311
-
3312
- /***/ }),
3313
-
3314
- /***/ 5061:
3315
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3316
-
3317
- "use strict";
3318
-
3319
-
3320
- var enhanceError = __webpack_require__(481);
3321
-
3322
- /**
3323
- * Create an Error with the specified message, config, error code, request and response.
3324
- *
3325
- * @param {string} message The error message.
3326
- * @param {Object} config The config.
3327
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
3328
- * @param {Object} [request] The request.
3329
- * @param {Object} [response] The response.
3330
- * @returns {Error} The created error.
3331
- */
3332
- module.exports = function createError(message, config, code, request, response) {
3333
- var error = new Error(message);
3334
- return enhanceError(error, config, code, request, response);
3335
- };
3336
-
3337
-
3338
- /***/ }),
3339
-
3340
- /***/ 3572:
3341
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3342
-
3343
- "use strict";
3344
-
3345
-
3346
- var utils = __webpack_require__(4867);
3347
- var transformData = __webpack_require__(8527);
3348
- var isCancel = __webpack_require__(6502);
3349
- var defaults = __webpack_require__(5655);
3350
-
3351
- /**
3352
- * Throws a `Cancel` if cancellation has been requested.
3353
- */
3354
- function throwIfCancellationRequested(config) {
3355
- if (config.cancelToken) {
3356
- config.cancelToken.throwIfRequested();
3357
- }
3358
- }
3359
-
3360
- /**
3361
- * Dispatch a request to the server using the configured adapter.
3362
- *
3363
- * @param {object} config The config that is to be used for the request
3364
- * @returns {Promise} The Promise to be fulfilled
3365
- */
3366
- module.exports = function dispatchRequest(config) {
3367
- throwIfCancellationRequested(config);
3368
-
3369
- // Ensure headers exist
3370
- config.headers = config.headers || {};
3371
-
3372
- // Transform request data
3373
- config.data = transformData(
3374
- config.data,
3375
- config.headers,
3376
- config.transformRequest
3377
- );
3378
-
3379
- // Flatten headers
3380
- config.headers = utils.merge(
3381
- config.headers.common || {},
3382
- config.headers[config.method] || {},
3383
- config.headers
3384
- );
3385
-
3386
- utils.forEach(
3387
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3388
- function cleanHeaderConfig(method) {
3389
- delete config.headers[method];
3390
- }
3391
- );
3392
-
3393
- var adapter = config.adapter || defaults.adapter;
3394
-
3395
- return adapter(config).then(function onAdapterResolution(response) {
3396
- throwIfCancellationRequested(config);
3397
-
3398
- // Transform response data
3399
- response.data = transformData(
3400
- response.data,
3401
- response.headers,
3402
- config.transformResponse
3403
- );
3404
-
3405
- return response;
3406
- }, function onAdapterRejection(reason) {
3407
- if (!isCancel(reason)) {
3408
- throwIfCancellationRequested(config);
3409
-
3410
- // Transform response data
3411
- if (reason && reason.response) {
3412
- reason.response.data = transformData(
3413
- reason.response.data,
3414
- reason.response.headers,
3415
- config.transformResponse
3416
- );
3417
- }
3418
- }
3419
-
3420
- return Promise.reject(reason);
3421
- });
3422
- };
3423
-
3424
-
3425
- /***/ }),
3426
-
3427
- /***/ 481:
3428
- /***/ ((module) => {
3429
-
3430
- "use strict";
3431
-
3432
-
3433
- /**
3434
- * Update an Error with the specified config, error code, and response.
3435
- *
3436
- * @param {Error} error The error to update.
3437
- * @param {Object} config The config.
3438
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
3439
- * @param {Object} [request] The request.
3440
- * @param {Object} [response] The response.
3441
- * @returns {Error} The error.
3442
- */
3443
- module.exports = function enhanceError(error, config, code, request, response) {
3444
- error.config = config;
3445
- if (code) {
3446
- error.code = code;
3447
- }
3448
-
3449
- error.request = request;
3450
- error.response = response;
3451
- error.isAxiosError = true;
3452
-
3453
- error.toJSON = function toJSON() {
3454
- return {
3455
- // Standard
3456
- message: this.message,
3457
- name: this.name,
3458
- // Microsoft
3459
- description: this.description,
3460
- number: this.number,
3461
- // Mozilla
3462
- fileName: this.fileName,
3463
- lineNumber: this.lineNumber,
3464
- columnNumber: this.columnNumber,
3465
- stack: this.stack,
3466
- // Axios
3467
- config: this.config,
3468
- code: this.code
3469
- };
3470
- };
3471
- return error;
3472
- };
3473
-
3474
-
3475
- /***/ }),
3476
-
3477
- /***/ 7185:
3478
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3479
-
3480
- "use strict";
3481
-
3482
-
3483
- var utils = __webpack_require__(4867);
3484
-
3485
- /**
3486
- * Config-specific merge-function which creates a new config-object
3487
- * by merging two configuration objects together.
3488
- *
3489
- * @param {Object} config1
3490
- * @param {Object} config2
3491
- * @returns {Object} New object resulting from merging config2 to config1
3492
- */
3493
- module.exports = function mergeConfig(config1, config2) {
3494
- // eslint-disable-next-line no-param-reassign
3495
- config2 = config2 || {};
3496
- var config = {};
3497
-
3498
- var valueFromConfig2Keys = ['url', 'method', 'data'];
3499
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
3500
- var defaultToConfig2Keys = [
3501
- 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
3502
- 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
3503
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
3504
- 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
3505
- 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
3506
- ];
3507
- var directMergeKeys = ['validateStatus'];
3508
-
3509
- function getMergedValue(target, source) {
3510
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
3511
- return utils.merge(target, source);
3512
- } else if (utils.isPlainObject(source)) {
3513
- return utils.merge({}, source);
3514
- } else if (utils.isArray(source)) {
3515
- return source.slice();
3516
- }
3517
- return source;
3518
- }
3519
-
3520
- function mergeDeepProperties(prop) {
3521
- if (!utils.isUndefined(config2[prop])) {
3522
- config[prop] = getMergedValue(config1[prop], config2[prop]);
3523
- } else if (!utils.isUndefined(config1[prop])) {
3524
- config[prop] = getMergedValue(undefined, config1[prop]);
3525
- }
3526
- }
3527
-
3528
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
3529
- if (!utils.isUndefined(config2[prop])) {
3530
- config[prop] = getMergedValue(undefined, config2[prop]);
3531
- }
3532
- });
3533
-
3534
- utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
3535
-
3536
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
3537
- if (!utils.isUndefined(config2[prop])) {
3538
- config[prop] = getMergedValue(undefined, config2[prop]);
3539
- } else if (!utils.isUndefined(config1[prop])) {
3540
- config[prop] = getMergedValue(undefined, config1[prop]);
3541
- }
3542
- });
3543
-
3544
- utils.forEach(directMergeKeys, function merge(prop) {
3545
- if (prop in config2) {
3546
- config[prop] = getMergedValue(config1[prop], config2[prop]);
3547
- } else if (prop in config1) {
3548
- config[prop] = getMergedValue(undefined, config1[prop]);
3549
- }
3550
- });
3551
-
3552
- var axiosKeys = valueFromConfig2Keys
3553
- .concat(mergeDeepPropertiesKeys)
3554
- .concat(defaultToConfig2Keys)
3555
- .concat(directMergeKeys);
3556
-
3557
- var otherKeys = Object
3558
- .keys(config1)
3559
- .concat(Object.keys(config2))
3560
- .filter(function filterAxiosKeys(key) {
3561
- return axiosKeys.indexOf(key) === -1;
3562
- });
3563
-
3564
- utils.forEach(otherKeys, mergeDeepProperties);
3565
-
3566
- return config;
3567
- };
3568
-
3569
-
3570
- /***/ }),
3571
-
3572
- /***/ 6026:
3573
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3574
-
3575
- "use strict";
3576
-
3577
-
3578
- var createError = __webpack_require__(5061);
3579
-
3580
- /**
3581
- * Resolve or reject a Promise based on response status.
3582
- *
3583
- * @param {Function} resolve A function that resolves the promise.
3584
- * @param {Function} reject A function that rejects the promise.
3585
- * @param {object} response The response.
3586
- */
3587
- module.exports = function settle(resolve, reject, response) {
3588
- var validateStatus = response.config.validateStatus;
3589
- if (!response.status || !validateStatus || validateStatus(response.status)) {
3590
- resolve(response);
3591
- } else {
3592
- reject(createError(
3593
- 'Request failed with status code ' + response.status,
3594
- response.config,
3595
- null,
3596
- response.request,
3597
- response
3598
- ));
3599
- }
3600
- };
3601
-
3602
-
3603
- /***/ }),
3604
-
3605
- /***/ 8527:
3606
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3607
-
3608
- "use strict";
3609
-
3610
-
3611
- var utils = __webpack_require__(4867);
3612
-
3613
- /**
3614
- * Transform the data for a request or a response
3615
- *
3616
- * @param {Object|String} data The data to be transformed
3617
- * @param {Array} headers The headers for the request or response
3618
- * @param {Array|Function} fns A single function or Array of functions
3619
- * @returns {*} The resulting transformed data
3620
- */
3621
- module.exports = function transformData(data, headers, fns) {
3622
- /*eslint no-param-reassign:0*/
3623
- utils.forEach(fns, function transform(fn) {
3624
- data = fn(data, headers);
3625
- });
3626
-
3627
- return data;
3628
- };
3629
-
3630
-
3631
- /***/ }),
3632
-
3633
- /***/ 5655:
3634
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3635
-
3636
- "use strict";
3637
-
3638
-
3639
- var utils = __webpack_require__(4867);
3640
- var normalizeHeaderName = __webpack_require__(6016);
3641
-
3642
- var DEFAULT_CONTENT_TYPE = {
3643
- 'Content-Type': 'application/x-www-form-urlencoded'
3644
- };
3645
-
3646
- function setContentTypeIfUnset(headers, value) {
3647
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
3648
- headers['Content-Type'] = value;
3649
- }
3650
- }
3651
-
3652
- function getDefaultAdapter() {
3653
- var adapter;
3654
- if (typeof XMLHttpRequest !== 'undefined') {
3655
- // For browsers use XHR adapter
3656
- adapter = __webpack_require__(5448);
3657
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
3658
- // For node use HTTP adapter
3659
- adapter = __webpack_require__(5448);
3660
- }
3661
- return adapter;
3662
- }
3663
-
3664
- var defaults = {
3665
- adapter: getDefaultAdapter(),
3666
-
3667
- transformRequest: [function transformRequest(data, headers) {
3668
- normalizeHeaderName(headers, 'Accept');
3669
- normalizeHeaderName(headers, 'Content-Type');
3670
- if (utils.isFormData(data) ||
3671
- utils.isArrayBuffer(data) ||
3672
- utils.isBuffer(data) ||
3673
- utils.isStream(data) ||
3674
- utils.isFile(data) ||
3675
- utils.isBlob(data)
3676
- ) {
3677
- return data;
3678
- }
3679
- if (utils.isArrayBufferView(data)) {
3680
- return data.buffer;
3681
- }
3682
- if (utils.isURLSearchParams(data)) {
3683
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
3684
- return data.toString();
3685
- }
3686
- if (utils.isObject(data)) {
3687
- setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
3688
- return JSON.stringify(data);
3689
- }
3690
- return data;
3691
- }],
3692
-
3693
- transformResponse: [function transformResponse(data) {
3694
- /*eslint no-param-reassign:0*/
3695
- if (typeof data === 'string') {
3696
- try {
3697
- data = JSON.parse(data);
3698
- } catch (e) { /* Ignore */ }
3699
- }
3700
- return data;
3701
- }],
3702
-
3703
- /**
3704
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
3705
- * timeout is not created.
3706
- */
3707
- timeout: 0,
3708
-
3709
- xsrfCookieName: 'XSRF-TOKEN',
3710
- xsrfHeaderName: 'X-XSRF-TOKEN',
3711
-
3712
- maxContentLength: -1,
3713
- maxBodyLength: -1,
3714
-
3715
- validateStatus: function validateStatus(status) {
3716
- return status >= 200 && status < 300;
3717
- }
3718
- };
3719
-
3720
- defaults.headers = {
3721
- common: {
3722
- 'Accept': 'application/json, text/plain, */*'
3723
- }
3724
- };
3725
-
3726
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3727
- defaults.headers[method] = {};
3728
- });
3729
-
3730
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3731
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
3732
- });
3733
-
3734
- module.exports = defaults;
3735
-
3736
-
3737
- /***/ }),
3738
-
3739
- /***/ 1849:
3740
- /***/ ((module) => {
3741
-
3742
- "use strict";
3743
-
3744
-
3745
- module.exports = function bind(fn, thisArg) {
3746
- return function wrap() {
3747
- var args = new Array(arguments.length);
3748
- for (var i = 0; i < args.length; i++) {
3749
- args[i] = arguments[i];
3750
- }
3751
- return fn.apply(thisArg, args);
3752
- };
3753
- };
3754
-
3755
-
3756
- /***/ }),
3757
-
3758
- /***/ 5327:
3759
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3760
-
3761
- "use strict";
3762
-
3763
-
3764
- var utils = __webpack_require__(4867);
3765
-
3766
- function encode(val) {
3767
- return encodeURIComponent(val).
3768
- replace(/%3A/gi, ':').
3769
- replace(/%24/g, '$').
3770
- replace(/%2C/gi, ',').
3771
- replace(/%20/g, '+').
3772
- replace(/%5B/gi, '[').
3773
- replace(/%5D/gi, ']');
3774
- }
3775
-
3776
- /**
3777
- * Build a URL by appending params to the end
3778
- *
3779
- * @param {string} url The base of the url (e.g., http://www.google.com)
3780
- * @param {object} [params] The params to be appended
3781
- * @returns {string} The formatted url
3782
- */
3783
- module.exports = function buildURL(url, params, paramsSerializer) {
3784
- /*eslint no-param-reassign:0*/
3785
- if (!params) {
3786
- return url;
3787
- }
3788
-
3789
- var serializedParams;
3790
- if (paramsSerializer) {
3791
- serializedParams = paramsSerializer(params);
3792
- } else if (utils.isURLSearchParams(params)) {
3793
- serializedParams = params.toString();
3794
- } else {
3795
- var parts = [];
3796
-
3797
- utils.forEach(params, function serialize(val, key) {
3798
- if (val === null || typeof val === 'undefined') {
3799
- return;
3800
- }
3801
-
3802
- if (utils.isArray(val)) {
3803
- key = key + '[]';
3804
- } else {
3805
- val = [val];
3806
- }
3807
-
3808
- utils.forEach(val, function parseValue(v) {
3809
- if (utils.isDate(v)) {
3810
- v = v.toISOString();
3811
- } else if (utils.isObject(v)) {
3812
- v = JSON.stringify(v);
3813
- }
3814
- parts.push(encode(key) + '=' + encode(v));
3815
- });
3816
- });
3817
-
3818
- serializedParams = parts.join('&');
3819
- }
3820
-
3821
- if (serializedParams) {
3822
- var hashmarkIndex = url.indexOf('#');
3823
- if (hashmarkIndex !== -1) {
3824
- url = url.slice(0, hashmarkIndex);
3825
- }
3826
-
3827
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
3828
- }
3829
-
3830
- return url;
3831
- };
3832
-
3833
-
3834
- /***/ }),
3835
-
3836
- /***/ 7303:
3837
- /***/ ((module) => {
3838
-
3839
- "use strict";
3840
-
3841
-
3842
- /**
3843
- * Creates a new URL by combining the specified URLs
3844
- *
3845
- * @param {string} baseURL The base URL
3846
- * @param {string} relativeURL The relative URL
3847
- * @returns {string} The combined URL
3848
- */
3849
- module.exports = function combineURLs(baseURL, relativeURL) {
3850
- return relativeURL
3851
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3852
- : baseURL;
3853
- };
3854
-
3855
-
3856
- /***/ }),
3857
-
3858
- /***/ 4372:
3859
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3860
-
3861
- "use strict";
3862
-
3863
-
3864
- var utils = __webpack_require__(4867);
3865
-
3866
- module.exports = (
3867
- utils.isStandardBrowserEnv() ?
3868
-
3869
- // Standard browser envs support document.cookie
3870
- (function standardBrowserEnv() {
3871
- return {
3872
- write: function write(name, value, expires, path, domain, secure) {
3873
- var cookie = [];
3874
- cookie.push(name + '=' + encodeURIComponent(value));
3875
-
3876
- if (utils.isNumber(expires)) {
3877
- cookie.push('expires=' + new Date(expires).toGMTString());
3878
- }
3879
-
3880
- if (utils.isString(path)) {
3881
- cookie.push('path=' + path);
3882
- }
3883
-
3884
- if (utils.isString(domain)) {
3885
- cookie.push('domain=' + domain);
3886
- }
3887
-
3888
- if (secure === true) {
3889
- cookie.push('secure');
3890
- }
3891
-
3892
- document.cookie = cookie.join('; ');
3893
- },
3894
-
3895
- read: function read(name) {
3896
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
3897
- return (match ? decodeURIComponent(match[3]) : null);
3898
- },
3899
-
3900
- remove: function remove(name) {
3901
- this.write(name, '', Date.now() - 86400000);
3902
- }
3903
- };
3904
- })() :
3905
-
3906
- // Non standard browser env (web workers, react-native) lack needed support.
3907
- (function nonStandardBrowserEnv() {
3908
- return {
3909
- write: function write() {},
3910
- read: function read() { return null; },
3911
- remove: function remove() {}
3912
- };
3913
- })()
3914
- );
3915
-
3916
-
3917
- /***/ }),
3918
-
3919
- /***/ 1793:
3920
- /***/ ((module) => {
3921
-
3922
- "use strict";
3923
-
3924
-
3925
- /**
3926
- * Determines whether the specified URL is absolute
3927
- *
3928
- * @param {string} url The URL to test
3929
- * @returns {boolean} True if the specified URL is absolute, otherwise false
3930
- */
3931
- module.exports = function isAbsoluteURL(url) {
3932
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
3933
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
3934
- // by any combination of letters, digits, plus, period, or hyphen.
3935
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
3936
- };
3937
-
3938
-
3939
- /***/ }),
3940
-
3941
- /***/ 6268:
3942
- /***/ ((module) => {
3943
-
3944
- "use strict";
3945
-
3946
-
3947
- /**
3948
- * Determines whether the payload is an error thrown by Axios
3949
- *
3950
- * @param {*} payload The value to test
3951
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3952
- */
3953
- module.exports = function isAxiosError(payload) {
3954
- return (typeof payload === 'object') && (payload.isAxiosError === true);
3955
- };
2906
+ var irrelevant = (function (exports) {
3956
2907
 
2908
+ var support = {
2909
+ searchParams: 'URLSearchParams' in self,
2910
+ iterable: 'Symbol' in self && 'iterator' in Symbol,
2911
+ blob:
2912
+ 'FileReader' in self &&
2913
+ 'Blob' in self &&
2914
+ (function() {
2915
+ try {
2916
+ new Blob();
2917
+ return true
2918
+ } catch (e) {
2919
+ return false
2920
+ }
2921
+ })(),
2922
+ formData: 'FormData' in self,
2923
+ arrayBuffer: 'ArrayBuffer' in self
2924
+ };
3957
2925
 
3958
- /***/ }),
2926
+ function isDataView(obj) {
2927
+ return obj && DataView.prototype.isPrototypeOf(obj)
2928
+ }
3959
2929
 
3960
- /***/ 7985:
3961
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2930
+ if (support.arrayBuffer) {
2931
+ var viewClasses = [
2932
+ '[object Int8Array]',
2933
+ '[object Uint8Array]',
2934
+ '[object Uint8ClampedArray]',
2935
+ '[object Int16Array]',
2936
+ '[object Uint16Array]',
2937
+ '[object Int32Array]',
2938
+ '[object Uint32Array]',
2939
+ '[object Float32Array]',
2940
+ '[object Float64Array]'
2941
+ ];
2942
+
2943
+ var isArrayBufferView =
2944
+ ArrayBuffer.isView ||
2945
+ function(obj) {
2946
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
2947
+ };
2948
+ }
3962
2949
 
3963
- "use strict";
2950
+ function normalizeName(name) {
2951
+ if (typeof name !== 'string') {
2952
+ name = String(name);
2953
+ }
2954
+ if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
2955
+ throw new TypeError('Invalid character in header field name')
2956
+ }
2957
+ return name.toLowerCase()
2958
+ }
3964
2959
 
2960
+ function normalizeValue(value) {
2961
+ if (typeof value !== 'string') {
2962
+ value = String(value);
2963
+ }
2964
+ return value
2965
+ }
3965
2966
 
3966
- var utils = __webpack_require__(4867);
2967
+ // Build a destructive iterator for the value list
2968
+ function iteratorFor(items) {
2969
+ var iterator = {
2970
+ next: function() {
2971
+ var value = items.shift();
2972
+ return {done: value === undefined, value: value}
2973
+ }
2974
+ };
3967
2975
 
3968
- module.exports = (
3969
- utils.isStandardBrowserEnv() ?
2976
+ if (support.iterable) {
2977
+ iterator[Symbol.iterator] = function() {
2978
+ return iterator
2979
+ };
2980
+ }
3970
2981
 
3971
- // Standard browser envs have full support of the APIs needed to test
3972
- // whether the request URL is of the same origin as current location.
3973
- (function standardBrowserEnv() {
3974
- var msie = /(msie|trident)/i.test(navigator.userAgent);
3975
- var urlParsingNode = document.createElement('a');
3976
- var originURL;
2982
+ return iterator
2983
+ }
3977
2984
 
3978
- /**
3979
- * Parse a URL to discover it's components
3980
- *
3981
- * @param {String} url The URL to be parsed
3982
- * @returns {Object}
3983
- */
3984
- function resolveURL(url) {
3985
- var href = url;
2985
+ function Headers(headers) {
2986
+ this.map = {};
2987
+
2988
+ if (headers instanceof Headers) {
2989
+ headers.forEach(function(value, name) {
2990
+ this.append(name, value);
2991
+ }, this);
2992
+ } else if (Array.isArray(headers)) {
2993
+ headers.forEach(function(header) {
2994
+ this.append(header[0], header[1]);
2995
+ }, this);
2996
+ } else if (headers) {
2997
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
2998
+ this.append(name, headers[name]);
2999
+ }, this);
3000
+ }
3001
+ }
3986
3002
 
3987
- if (msie) {
3988
- // IE needs attribute set twice to normalize properties
3989
- urlParsingNode.setAttribute('href', href);
3990
- href = urlParsingNode.href;
3991
- }
3003
+ Headers.prototype.append = function(name, value) {
3004
+ name = normalizeName(name);
3005
+ value = normalizeValue(value);
3006
+ var oldValue = this.map[name];
3007
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
3008
+ };
3992
3009
 
3993
- urlParsingNode.setAttribute('href', href);
3994
-
3995
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
3996
- return {
3997
- href: urlParsingNode.href,
3998
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
3999
- host: urlParsingNode.host,
4000
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
4001
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
4002
- hostname: urlParsingNode.hostname,
4003
- port: urlParsingNode.port,
4004
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
4005
- urlParsingNode.pathname :
4006
- '/' + urlParsingNode.pathname
4007
- };
4008
- }
3010
+ Headers.prototype['delete'] = function(name) {
3011
+ delete this.map[normalizeName(name)];
3012
+ };
4009
3013
 
4010
- originURL = resolveURL(window.location.href);
4011
-
4012
- /**
4013
- * Determine if a URL shares the same origin as the current location
4014
- *
4015
- * @param {String} requestURL The URL to test
4016
- * @returns {boolean} True if URL shares the same origin, otherwise false
4017
- */
4018
- return function isURLSameOrigin(requestURL) {
4019
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
4020
- return (parsed.protocol === originURL.protocol &&
4021
- parsed.host === originURL.host);
4022
- };
4023
- })() :
3014
+ Headers.prototype.get = function(name) {
3015
+ name = normalizeName(name);
3016
+ return this.has(name) ? this.map[name] : null
3017
+ };
4024
3018
 
4025
- // Non standard browser envs (web workers, react-native) lack needed support.
4026
- (function nonStandardBrowserEnv() {
4027
- return function isURLSameOrigin() {
4028
- return true;
4029
- };
4030
- })()
4031
- );
3019
+ Headers.prototype.has = function(name) {
3020
+ return this.map.hasOwnProperty(normalizeName(name))
3021
+ };
4032
3022
 
3023
+ Headers.prototype.set = function(name, value) {
3024
+ this.map[normalizeName(name)] = normalizeValue(value);
3025
+ };
4033
3026
 
4034
- /***/ }),
3027
+ Headers.prototype.forEach = function(callback, thisArg) {
3028
+ for (var name in this.map) {
3029
+ if (this.map.hasOwnProperty(name)) {
3030
+ callback.call(thisArg, this.map[name], name, this);
3031
+ }
3032
+ }
3033
+ };
4035
3034
 
4036
- /***/ 6016:
4037
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3035
+ Headers.prototype.keys = function() {
3036
+ var items = [];
3037
+ this.forEach(function(value, name) {
3038
+ items.push(name);
3039
+ });
3040
+ return iteratorFor(items)
3041
+ };
4038
3042
 
4039
- "use strict";
3043
+ Headers.prototype.values = function() {
3044
+ var items = [];
3045
+ this.forEach(function(value) {
3046
+ items.push(value);
3047
+ });
3048
+ return iteratorFor(items)
3049
+ };
4040
3050
 
3051
+ Headers.prototype.entries = function() {
3052
+ var items = [];
3053
+ this.forEach(function(value, name) {
3054
+ items.push([name, value]);
3055
+ });
3056
+ return iteratorFor(items)
3057
+ };
4041
3058
 
4042
- var utils = __webpack_require__(4867);
3059
+ if (support.iterable) {
3060
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
3061
+ }
4043
3062
 
4044
- module.exports = function normalizeHeaderName(headers, normalizedName) {
4045
- utils.forEach(headers, function processHeader(value, name) {
4046
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
4047
- headers[normalizedName] = value;
4048
- delete headers[name];
3063
+ function consumed(body) {
3064
+ if (body.bodyUsed) {
3065
+ return Promise.reject(new TypeError('Already read'))
4049
3066
  }
4050
- });
4051
- };
3067
+ body.bodyUsed = true;
3068
+ }
4052
3069
 
3070
+ function fileReaderReady(reader) {
3071
+ return new Promise(function(resolve, reject) {
3072
+ reader.onload = function() {
3073
+ resolve(reader.result);
3074
+ };
3075
+ reader.onerror = function() {
3076
+ reject(reader.error);
3077
+ };
3078
+ })
3079
+ }
4053
3080
 
4054
- /***/ }),
3081
+ function readBlobAsArrayBuffer(blob) {
3082
+ var reader = new FileReader();
3083
+ var promise = fileReaderReady(reader);
3084
+ reader.readAsArrayBuffer(blob);
3085
+ return promise
3086
+ }
4055
3087
 
4056
- /***/ 4109:
4057
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3088
+ function readBlobAsText(blob) {
3089
+ var reader = new FileReader();
3090
+ var promise = fileReaderReady(reader);
3091
+ reader.readAsText(blob);
3092
+ return promise
3093
+ }
4058
3094
 
4059
- "use strict";
3095
+ function readArrayBufferAsText(buf) {
3096
+ var view = new Uint8Array(buf);
3097
+ var chars = new Array(view.length);
4060
3098
 
3099
+ for (var i = 0; i < view.length; i++) {
3100
+ chars[i] = String.fromCharCode(view[i]);
3101
+ }
3102
+ return chars.join('')
3103
+ }
4061
3104
 
4062
- var utils = __webpack_require__(4867);
3105
+ function bufferClone(buf) {
3106
+ if (buf.slice) {
3107
+ return buf.slice(0)
3108
+ } else {
3109
+ var view = new Uint8Array(buf.byteLength);
3110
+ view.set(new Uint8Array(buf));
3111
+ return view.buffer
3112
+ }
3113
+ }
4063
3114
 
4064
- // Headers whose duplicates are ignored by node
4065
- // c.f. https://nodejs.org/api/http.html#http_message_headers
4066
- var ignoreDuplicateOf = [
4067
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
4068
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
4069
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
4070
- 'referer', 'retry-after', 'user-agent'
4071
- ];
3115
+ function Body() {
3116
+ this.bodyUsed = false;
3117
+
3118
+ this._initBody = function(body) {
3119
+ this._bodyInit = body;
3120
+ if (!body) {
3121
+ this._bodyText = '';
3122
+ } else if (typeof body === 'string') {
3123
+ this._bodyText = body;
3124
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
3125
+ this._bodyBlob = body;
3126
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
3127
+ this._bodyFormData = body;
3128
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
3129
+ this._bodyText = body.toString();
3130
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
3131
+ this._bodyArrayBuffer = bufferClone(body.buffer);
3132
+ // IE 10-11 can't handle a DataView body.
3133
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
3134
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
3135
+ this._bodyArrayBuffer = bufferClone(body);
3136
+ } else {
3137
+ this._bodyText = body = Object.prototype.toString.call(body);
3138
+ }
4072
3139
 
4073
- /**
4074
- * Parse headers into an object
4075
- *
4076
- * ```
4077
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
4078
- * Content-Type: application/json
4079
- * Connection: keep-alive
4080
- * Transfer-Encoding: chunked
4081
- * ```
4082
- *
4083
- * @param {String} headers Headers needing to be parsed
4084
- * @returns {Object} Headers parsed into an object
4085
- */
4086
- module.exports = function parseHeaders(headers) {
4087
- var parsed = {};
4088
- var key;
4089
- var val;
4090
- var i;
3140
+ if (!this.headers.get('content-type')) {
3141
+ if (typeof body === 'string') {
3142
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
3143
+ } else if (this._bodyBlob && this._bodyBlob.type) {
3144
+ this.headers.set('content-type', this._bodyBlob.type);
3145
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
3146
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
3147
+ }
3148
+ }
3149
+ };
4091
3150
 
4092
- if (!headers) { return parsed; }
3151
+ if (support.blob) {
3152
+ this.blob = function() {
3153
+ var rejected = consumed(this);
3154
+ if (rejected) {
3155
+ return rejected
3156
+ }
4093
3157
 
4094
- utils.forEach(headers.split('\n'), function parser(line) {
4095
- i = line.indexOf(':');
4096
- key = utils.trim(line.substr(0, i)).toLowerCase();
4097
- val = utils.trim(line.substr(i + 1));
3158
+ if (this._bodyBlob) {
3159
+ return Promise.resolve(this._bodyBlob)
3160
+ } else if (this._bodyArrayBuffer) {
3161
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
3162
+ } else if (this._bodyFormData) {
3163
+ throw new Error('could not read FormData body as blob')
3164
+ } else {
3165
+ return Promise.resolve(new Blob([this._bodyText]))
3166
+ }
3167
+ };
4098
3168
 
4099
- if (key) {
4100
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
4101
- return;
3169
+ this.arrayBuffer = function() {
3170
+ if (this._bodyArrayBuffer) {
3171
+ return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
3172
+ } else {
3173
+ return this.blob().then(readBlobAsArrayBuffer)
3174
+ }
3175
+ };
3176
+ }
3177
+
3178
+ this.text = function() {
3179
+ var rejected = consumed(this);
3180
+ if (rejected) {
3181
+ return rejected
4102
3182
  }
4103
- if (key === 'set-cookie') {
4104
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
3183
+
3184
+ if (this._bodyBlob) {
3185
+ return readBlobAsText(this._bodyBlob)
3186
+ } else if (this._bodyArrayBuffer) {
3187
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
3188
+ } else if (this._bodyFormData) {
3189
+ throw new Error('could not read FormData body as text')
4105
3190
  } else {
4106
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
3191
+ return Promise.resolve(this._bodyText)
4107
3192
  }
4108
- }
4109
- });
3193
+ };
4110
3194
 
4111
- return parsed;
4112
- };
3195
+ if (support.formData) {
3196
+ this.formData = function() {
3197
+ return this.text().then(decode)
3198
+ };
3199
+ }
4113
3200
 
3201
+ this.json = function() {
3202
+ return this.text().then(JSON.parse)
3203
+ };
4114
3204
 
4115
- /***/ }),
3205
+ return this
3206
+ }
4116
3207
 
4117
- /***/ 8713:
4118
- /***/ ((module) => {
3208
+ // HTTP methods whose capitalization should be normalized
3209
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
4119
3210
 
4120
- "use strict";
3211
+ function normalizeMethod(method) {
3212
+ var upcased = method.toUpperCase();
3213
+ return methods.indexOf(upcased) > -1 ? upcased : method
3214
+ }
4121
3215
 
3216
+ function Request(input, options) {
3217
+ options = options || {};
3218
+ var body = options.body;
4122
3219
 
4123
- /**
4124
- * Syntactic sugar for invoking a function and expanding an array for arguments.
4125
- *
4126
- * Common use case would be to use `Function.prototype.apply`.
4127
- *
4128
- * ```js
4129
- * function f(x, y, z) {}
4130
- * var args = [1, 2, 3];
4131
- * f.apply(null, args);
4132
- * ```
4133
- *
4134
- * With `spread` this example can be re-written.
4135
- *
4136
- * ```js
4137
- * spread(function(x, y, z) {})([1, 2, 3]);
4138
- * ```
4139
- *
4140
- * @param {Function} callback
4141
- * @returns {Function}
4142
- */
4143
- module.exports = function spread(callback) {
4144
- return function wrap(arr) {
4145
- return callback.apply(null, arr);
4146
- };
4147
- };
3220
+ if (input instanceof Request) {
3221
+ if (input.bodyUsed) {
3222
+ throw new TypeError('Already read')
3223
+ }
3224
+ this.url = input.url;
3225
+ this.credentials = input.credentials;
3226
+ if (!options.headers) {
3227
+ this.headers = new Headers(input.headers);
3228
+ }
3229
+ this.method = input.method;
3230
+ this.mode = input.mode;
3231
+ this.signal = input.signal;
3232
+ if (!body && input._bodyInit != null) {
3233
+ body = input._bodyInit;
3234
+ input.bodyUsed = true;
3235
+ }
3236
+ } else {
3237
+ this.url = String(input);
3238
+ }
4148
3239
 
3240
+ this.credentials = options.credentials || this.credentials || 'same-origin';
3241
+ if (options.headers || !this.headers) {
3242
+ this.headers = new Headers(options.headers);
3243
+ }
3244
+ this.method = normalizeMethod(options.method || this.method || 'GET');
3245
+ this.mode = options.mode || this.mode || null;
3246
+ this.signal = options.signal || this.signal;
3247
+ this.referrer = null;
4149
3248
 
4150
- /***/ }),
3249
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
3250
+ throw new TypeError('Body not allowed for GET or HEAD requests')
3251
+ }
3252
+ this._initBody(body);
3253
+ }
4151
3254
 
4152
- /***/ 4867:
4153
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3255
+ Request.prototype.clone = function() {
3256
+ return new Request(this, {body: this._bodyInit})
3257
+ };
4154
3258
 
4155
- "use strict";
3259
+ function decode(body) {
3260
+ var form = new FormData();
3261
+ body
3262
+ .trim()
3263
+ .split('&')
3264
+ .forEach(function(bytes) {
3265
+ if (bytes) {
3266
+ var split = bytes.split('=');
3267
+ var name = split.shift().replace(/\+/g, ' ');
3268
+ var value = split.join('=').replace(/\+/g, ' ');
3269
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
3270
+ }
3271
+ });
3272
+ return form
3273
+ }
4156
3274
 
3275
+ function parseHeaders(rawHeaders) {
3276
+ var headers = new Headers();
3277
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
3278
+ // https://tools.ietf.org/html/rfc7230#section-3.2
3279
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
3280
+ preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
3281
+ var parts = line.split(':');
3282
+ var key = parts.shift().trim();
3283
+ if (key) {
3284
+ var value = parts.join(':').trim();
3285
+ headers.append(key, value);
3286
+ }
3287
+ });
3288
+ return headers
3289
+ }
4157
3290
 
4158
- var bind = __webpack_require__(1849);
3291
+ Body.call(Request.prototype);
4159
3292
 
4160
- /*global toString:true*/
3293
+ function Response(bodyInit, options) {
3294
+ if (!options) {
3295
+ options = {};
3296
+ }
4161
3297
 
4162
- // utils is a library of generic helper functions non-specific to axios
3298
+ this.type = 'default';
3299
+ this.status = options.status === undefined ? 200 : options.status;
3300
+ this.ok = this.status >= 200 && this.status < 300;
3301
+ this.statusText = 'statusText' in options ? options.statusText : 'OK';
3302
+ this.headers = new Headers(options.headers);
3303
+ this.url = options.url || '';
3304
+ this._initBody(bodyInit);
3305
+ }
4163
3306
 
4164
- var toString = Object.prototype.toString;
3307
+ Body.call(Response.prototype);
4165
3308
 
4166
- /**
4167
- * Determine if a value is an Array
4168
- *
4169
- * @param {Object} val The value to test
4170
- * @returns {boolean} True if value is an Array, otherwise false
4171
- */
4172
- function isArray(val) {
4173
- return toString.call(val) === '[object Array]';
4174
- }
3309
+ Response.prototype.clone = function() {
3310
+ return new Response(this._bodyInit, {
3311
+ status: this.status,
3312
+ statusText: this.statusText,
3313
+ headers: new Headers(this.headers),
3314
+ url: this.url
3315
+ })
3316
+ };
4175
3317
 
4176
- /**
4177
- * Determine if a value is undefined
4178
- *
4179
- * @param {Object} val The value to test
4180
- * @returns {boolean} True if the value is undefined, otherwise false
4181
- */
4182
- function isUndefined(val) {
4183
- return typeof val === 'undefined';
4184
- }
3318
+ Response.error = function() {
3319
+ var response = new Response(null, {status: 0, statusText: ''});
3320
+ response.type = 'error';
3321
+ return response
3322
+ };
4185
3323
 
4186
- /**
4187
- * Determine if a value is a Buffer
4188
- *
4189
- * @param {Object} val The value to test
4190
- * @returns {boolean} True if value is a Buffer, otherwise false
4191
- */
4192
- function isBuffer(val) {
4193
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
4194
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
4195
- }
3324
+ var redirectStatuses = [301, 302, 303, 307, 308];
4196
3325
 
4197
- /**
4198
- * Determine if a value is an ArrayBuffer
4199
- *
4200
- * @param {Object} val The value to test
4201
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
4202
- */
4203
- function isArrayBuffer(val) {
4204
- return toString.call(val) === '[object ArrayBuffer]';
4205
- }
3326
+ Response.redirect = function(url, status) {
3327
+ if (redirectStatuses.indexOf(status) === -1) {
3328
+ throw new RangeError('Invalid status code')
3329
+ }
4206
3330
 
4207
- /**
4208
- * Determine if a value is a FormData
4209
- *
4210
- * @param {Object} val The value to test
4211
- * @returns {boolean} True if value is an FormData, otherwise false
4212
- */
4213
- function isFormData(val) {
4214
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
4215
- }
3331
+ return new Response(null, {status: status, headers: {location: url}})
3332
+ };
4216
3333
 
4217
- /**
4218
- * Determine if a value is a view on an ArrayBuffer
4219
- *
4220
- * @param {Object} val The value to test
4221
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
4222
- */
4223
- function isArrayBufferView(val) {
4224
- var result;
4225
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
4226
- result = ArrayBuffer.isView(val);
4227
- } else {
4228
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
3334
+ exports.DOMException = self.DOMException;
3335
+ try {
3336
+ new exports.DOMException();
3337
+ } catch (err) {
3338
+ exports.DOMException = function(message, name) {
3339
+ this.message = message;
3340
+ this.name = name;
3341
+ var error = Error(message);
3342
+ this.stack = error.stack;
3343
+ };
3344
+ exports.DOMException.prototype = Object.create(Error.prototype);
3345
+ exports.DOMException.prototype.constructor = exports.DOMException;
4229
3346
  }
4230
- return result;
4231
- }
4232
3347
 
4233
- /**
4234
- * Determine if a value is a String
4235
- *
4236
- * @param {Object} val The value to test
4237
- * @returns {boolean} True if value is a String, otherwise false
4238
- */
4239
- function isString(val) {
4240
- return typeof val === 'string';
4241
- }
3348
+ function fetch(input, init) {
3349
+ return new Promise(function(resolve, reject) {
3350
+ var request = new Request(input, init);
4242
3351
 
4243
- /**
4244
- * Determine if a value is a Number
4245
- *
4246
- * @param {Object} val The value to test
4247
- * @returns {boolean} True if value is a Number, otherwise false
4248
- */
4249
- function isNumber(val) {
4250
- return typeof val === 'number';
4251
- }
3352
+ if (request.signal && request.signal.aborted) {
3353
+ return reject(new exports.DOMException('Aborted', 'AbortError'))
3354
+ }
4252
3355
 
4253
- /**
4254
- * Determine if a value is an Object
4255
- *
4256
- * @param {Object} val The value to test
4257
- * @returns {boolean} True if value is an Object, otherwise false
4258
- */
4259
- function isObject(val) {
4260
- return val !== null && typeof val === 'object';
4261
- }
3356
+ var xhr = new XMLHttpRequest();
4262
3357
 
4263
- /**
4264
- * Determine if a value is a plain Object
4265
- *
4266
- * @param {Object} val The value to test
4267
- * @return {boolean} True if value is a plain Object, otherwise false
4268
- */
4269
- function isPlainObject(val) {
4270
- if (toString.call(val) !== '[object Object]') {
4271
- return false;
4272
- }
3358
+ function abortXhr() {
3359
+ xhr.abort();
3360
+ }
4273
3361
 
4274
- var prototype = Object.getPrototypeOf(val);
4275
- return prototype === null || prototype === Object.prototype;
4276
- }
3362
+ xhr.onload = function() {
3363
+ var options = {
3364
+ status: xhr.status,
3365
+ statusText: xhr.statusText,
3366
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
3367
+ };
3368
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
3369
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
3370
+ resolve(new Response(body, options));
3371
+ };
4277
3372
 
4278
- /**
4279
- * Determine if a value is a Date
4280
- *
4281
- * @param {Object} val The value to test
4282
- * @returns {boolean} True if value is a Date, otherwise false
4283
- */
4284
- function isDate(val) {
4285
- return toString.call(val) === '[object Date]';
4286
- }
3373
+ xhr.onerror = function() {
3374
+ reject(new TypeError('Network request failed'));
3375
+ };
4287
3376
 
4288
- /**
4289
- * Determine if a value is a File
4290
- *
4291
- * @param {Object} val The value to test
4292
- * @returns {boolean} True if value is a File, otherwise false
4293
- */
4294
- function isFile(val) {
4295
- return toString.call(val) === '[object File]';
4296
- }
3377
+ xhr.ontimeout = function() {
3378
+ reject(new TypeError('Network request failed'));
3379
+ };
4297
3380
 
4298
- /**
4299
- * Determine if a value is a Blob
4300
- *
4301
- * @param {Object} val The value to test
4302
- * @returns {boolean} True if value is a Blob, otherwise false
4303
- */
4304
- function isBlob(val) {
4305
- return toString.call(val) === '[object Blob]';
4306
- }
3381
+ xhr.onabort = function() {
3382
+ reject(new exports.DOMException('Aborted', 'AbortError'));
3383
+ };
4307
3384
 
4308
- /**
4309
- * Determine if a value is a Function
4310
- *
4311
- * @param {Object} val The value to test
4312
- * @returns {boolean} True if value is a Function, otherwise false
4313
- */
4314
- function isFunction(val) {
4315
- return toString.call(val) === '[object Function]';
4316
- }
3385
+ xhr.open(request.method, request.url, true);
4317
3386
 
4318
- /**
4319
- * Determine if a value is a Stream
4320
- *
4321
- * @param {Object} val The value to test
4322
- * @returns {boolean} True if value is a Stream, otherwise false
4323
- */
4324
- function isStream(val) {
4325
- return isObject(val) && isFunction(val.pipe);
4326
- }
3387
+ if (request.credentials === 'include') {
3388
+ xhr.withCredentials = true;
3389
+ } else if (request.credentials === 'omit') {
3390
+ xhr.withCredentials = false;
3391
+ }
4327
3392
 
4328
- /**
4329
- * Determine if a value is a URLSearchParams object
4330
- *
4331
- * @param {Object} val The value to test
4332
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
4333
- */
4334
- function isURLSearchParams(val) {
4335
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
4336
- }
3393
+ if ('responseType' in xhr && support.blob) {
3394
+ xhr.responseType = 'blob';
3395
+ }
4337
3396
 
4338
- /**
4339
- * Trim excess whitespace off the beginning and end of a string
4340
- *
4341
- * @param {String} str The String to trim
4342
- * @returns {String} The String freed of excess whitespace
4343
- */
4344
- function trim(str) {
4345
- return str.replace(/^\s*/, '').replace(/\s*$/, '');
4346
- }
3397
+ request.headers.forEach(function(value, name) {
3398
+ xhr.setRequestHeader(name, value);
3399
+ });
4347
3400
 
4348
- /**
4349
- * Determine if we're running in a standard browser environment
4350
- *
4351
- * This allows axios to run in a web worker, and react-native.
4352
- * Both environments support XMLHttpRequest, but not fully standard globals.
4353
- *
4354
- * web workers:
4355
- * typeof window -> undefined
4356
- * typeof document -> undefined
4357
- *
4358
- * react-native:
4359
- * navigator.product -> 'ReactNative'
4360
- * nativescript
4361
- * navigator.product -> 'NativeScript' or 'NS'
4362
- */
4363
- function isStandardBrowserEnv() {
4364
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
4365
- navigator.product === 'NativeScript' ||
4366
- navigator.product === 'NS')) {
4367
- return false;
4368
- }
4369
- return (
4370
- typeof window !== 'undefined' &&
4371
- typeof document !== 'undefined'
4372
- );
4373
- }
3401
+ if (request.signal) {
3402
+ request.signal.addEventListener('abort', abortXhr);
4374
3403
 
4375
- /**
4376
- * Iterate over an Array or an Object invoking a function for each item.
4377
- *
4378
- * If `obj` is an Array callback will be called passing
4379
- * the value, index, and complete array for each item.
4380
- *
4381
- * If 'obj' is an Object callback will be called passing
4382
- * the value, key, and complete object for each property.
4383
- *
4384
- * @param {Object|Array} obj The object to iterate
4385
- * @param {Function} fn The callback to invoke for each item
4386
- */
4387
- function forEach(obj, fn) {
4388
- // Don't bother if no value provided
4389
- if (obj === null || typeof obj === 'undefined') {
4390
- return;
4391
- }
3404
+ xhr.onreadystatechange = function() {
3405
+ // DONE (success or failure)
3406
+ if (xhr.readyState === 4) {
3407
+ request.signal.removeEventListener('abort', abortXhr);
3408
+ }
3409
+ };
3410
+ }
4392
3411
 
4393
- // Force an array if not already something iterable
4394
- if (typeof obj !== 'object') {
4395
- /*eslint no-param-reassign:0*/
4396
- obj = [obj];
3412
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
3413
+ })
4397
3414
  }
4398
3415
 
4399
- if (isArray(obj)) {
4400
- // Iterate over array values
4401
- for (var i = 0, l = obj.length; i < l; i++) {
4402
- fn.call(null, obj[i], i, obj);
4403
- }
4404
- } else {
4405
- // Iterate over object keys
4406
- for (var key in obj) {
4407
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
4408
- fn.call(null, obj[key], key, obj);
4409
- }
4410
- }
4411
- }
4412
- }
3416
+ fetch.polyfill = true;
4413
3417
 
4414
- /**
4415
- * Accepts varargs expecting each argument to be an object, then
4416
- * immutably merges the properties of each object and returns result.
4417
- *
4418
- * When multiple objects contain the same key the later object in
4419
- * the arguments list will take precedence.
4420
- *
4421
- * Example:
4422
- *
4423
- * ```js
4424
- * var result = merge({foo: 123}, {foo: 456});
4425
- * console.log(result.foo); // outputs 456
4426
- * ```
4427
- *
4428
- * @param {Object} obj1 Object to merge
4429
- * @returns {Object} Result of all merge properties
4430
- */
4431
- function merge(/* obj1, obj2, obj3, ... */) {
4432
- var result = {};
4433
- function assignValue(val, key) {
4434
- if (isPlainObject(result[key]) && isPlainObject(val)) {
4435
- result[key] = merge(result[key], val);
4436
- } else if (isPlainObject(val)) {
4437
- result[key] = merge({}, val);
4438
- } else if (isArray(val)) {
4439
- result[key] = val.slice();
4440
- } else {
4441
- result[key] = val;
4442
- }
3418
+ if (!self.fetch) {
3419
+ self.fetch = fetch;
3420
+ self.Headers = Headers;
3421
+ self.Request = Request;
3422
+ self.Response = Response;
4443
3423
  }
4444
3424
 
4445
- for (var i = 0, l = arguments.length; i < l; i++) {
4446
- forEach(arguments[i], assignValue);
4447
- }
4448
- return result;
4449
- }
3425
+ exports.Headers = Headers;
3426
+ exports.Request = Request;
3427
+ exports.Response = Response;
3428
+ exports.fetch = fetch;
4450
3429
 
4451
- /**
4452
- * Extends object a by mutably adding to it the properties of object b.
4453
- *
4454
- * @param {Object} a The object to be extended
4455
- * @param {Object} b The object to copy properties from
4456
- * @param {Object} thisArg The object to bind function to
4457
- * @return {Object} The resulting value of object a
4458
- */
4459
- function extend(a, b, thisArg) {
4460
- forEach(b, function assignValue(val, key) {
4461
- if (thisArg && typeof val === 'function') {
4462
- a[key] = bind(val, thisArg);
4463
- } else {
4464
- a[key] = val;
4465
- }
4466
- });
4467
- return a;
4468
- }
3430
+ Object.defineProperty(exports, '__esModule', { value: true });
4469
3431
 
4470
- /**
4471
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
4472
- *
4473
- * @param {string} content with BOM
4474
- * @return {string} content value without BOM
4475
- */
4476
- function stripBOM(content) {
4477
- if (content.charCodeAt(0) === 0xFEFF) {
4478
- content = content.slice(1);
4479
- }
4480
- return content;
4481
- }
3432
+ return exports;
4482
3433
 
4483
- module.exports = {
4484
- isArray: isArray,
4485
- isArrayBuffer: isArrayBuffer,
4486
- isBuffer: isBuffer,
4487
- isFormData: isFormData,
4488
- isArrayBufferView: isArrayBufferView,
4489
- isString: isString,
4490
- isNumber: isNumber,
4491
- isObject: isObject,
4492
- isPlainObject: isPlainObject,
4493
- isUndefined: isUndefined,
4494
- isDate: isDate,
4495
- isFile: isFile,
4496
- isBlob: isBlob,
4497
- isFunction: isFunction,
4498
- isStream: isStream,
4499
- isURLSearchParams: isURLSearchParams,
4500
- isStandardBrowserEnv: isStandardBrowserEnv,
4501
- forEach: forEach,
4502
- merge: merge,
4503
- extend: extend,
4504
- trim: trim,
4505
- stripBOM: stripBOM
4506
- };
3434
+ }({}));
3435
+ })(__self__);
3436
+ __self__.fetch.ponyfill = true;
3437
+ // Remove "polyfill" property added by whatwg-fetch
3438
+ delete __self__.fetch.polyfill;
3439
+ // Choose between native implementation (global) or custom implementation (__self__)
3440
+ // var ctx = global.fetch ? global : __self__;
3441
+ var ctx = __self__; // this line disable service worker support temporarily
3442
+ exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
3443
+ exports["default"] = ctx.fetch // For TypeScript consumers without esModuleInterop.
3444
+ exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
3445
+ exports.Headers = ctx.Headers
3446
+ exports.Request = ctx.Request
3447
+ exports.Response = ctx.Response
3448
+ module.exports = exports
4507
3449
 
4508
3450
 
4509
3451
  /***/ }),
@@ -11433,7 +10375,7 @@ class Contract {
11433
10375
  constructor(c) {
11434
10376
  var _a;
11435
10377
  if (c.id)
11436
- this.id = utils_1.decodeBase58(c.id);
10378
+ this.id = (0, utils_1.decodeBase58)(c.id);
11437
10379
  this.signer = c.signer;
11438
10380
  this.provider = c.provider || ((_a = c.signer) === null || _a === void 0 ? void 0 : _a.provider);
11439
10381
  this.abi = c.abi;
@@ -11482,9 +10424,9 @@ class Contract {
11482
10424
  throw new Error(`No output defined for ${name}`);
11483
10425
  // read contract
11484
10426
  const { result: resultEncoded } = await this.provider.readContract({
11485
- contract_id: utils_1.encodeBase58(operation.call_contract.contract_id),
10427
+ contract_id: (0, utils_1.encodeBase58)(operation.call_contract.contract_id),
11486
10428
  entry_point: operation.call_contract.entry_point,
11487
- args: utils_1.encodeBase64(operation.call_contract.args),
10429
+ args: (0, utils_1.encodeBase64)(operation.call_contract.args),
11488
10430
  });
11489
10431
  let result = defaultOutput;
11490
10432
  if (resultEncoded) {
@@ -11507,7 +10449,7 @@ class Contract {
11507
10449
  });
11508
10450
  const abis = {};
11509
10451
  if (opts === null || opts === void 0 ? void 0 : opts.sendAbis) {
11510
- const contractId = utils_1.encodeBase58(this.id);
10452
+ const contractId = (0, utils_1.encodeBase58)(this.id);
11511
10453
  abis[contractId] = this.abi;
11512
10454
  }
11513
10455
  const transactionResponse = await this.signer.sendTransaction(transaction, abis);
@@ -11520,7 +10462,7 @@ class Contract {
11520
10462
  * Compute contract Id
11521
10463
  */
11522
10464
  static computeContractId(address) {
11523
- return utils_1.decodeBase58(address);
10465
+ return (0, utils_1.decodeBase58)(address);
11524
10466
  }
11525
10467
  /**
11526
10468
  * Get contract Id
@@ -11528,7 +10470,7 @@ class Contract {
11528
10470
  getId() {
11529
10471
  if (!this.id)
11530
10472
  throw new Error("id is not defined");
11531
- return utils_1.encodeBase58(this.id);
10473
+ return (0, utils_1.encodeBase58)(this.id);
11532
10474
  }
11533
10475
  /**
11534
10476
  * Function to deploy a new smart contract.
@@ -11650,8 +10592,8 @@ class Contract {
11650
10592
  throw new Error("Serializer is not defined");
11651
10593
  if (!op.call_contract)
11652
10594
  throw new Error("Operation is not CallContractOperation");
11653
- if (utils_1.encodeBase58(op.call_contract.contract_id) !== utils_1.encodeBase58(this.id))
11654
- throw new Error(`Invalid contract id. Expected: ${utils_1.encodeBase58(this.id)}. Received: ${utils_1.encodeBase58(op.call_contract.contract_id)}`);
10595
+ if ((0, utils_1.encodeBase58)(op.call_contract.contract_id) !== (0, utils_1.encodeBase58)(this.id))
10596
+ throw new Error(`Invalid contract id. Expected: ${(0, utils_1.encodeBase58)(this.id)}. Received: ${(0, utils_1.encodeBase58)(op.call_contract.contract_id)}`);
11655
10597
  for (let i = 0; i < Object.keys(this.abi.methods).length; i += 1) {
11656
10598
  const opName = Object.keys(this.abi.methods)[i];
11657
10599
  const method = this.abi.methods[opName];
@@ -11668,7 +10610,7 @@ class Contract {
11668
10610
  }
11669
10611
  }
11670
10612
  exports.Contract = Contract;
11671
- exports.default = Contract;
10613
+ exports["default"] = Contract;
11672
10614
 
11673
10615
 
11674
10616
  /***/ }),
@@ -11683,7 +10625,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11683
10625
  };
11684
10626
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11685
10627
  exports.Provider = void 0;
11686
- const axios_1 = __importDefault(__webpack_require__(9669));
10628
+ const cross_fetch_1 = __importDefault(__webpack_require__(4098));
11687
10629
  async function sleep(ms) {
11688
10630
  return new Promise((r) => setTimeout(r, ms));
11689
10631
  }
@@ -11718,16 +10660,9 @@ class Provider {
11718
10660
  * @returns Result of jsonrpc response
11719
10661
  */
11720
10662
  async call(method, params) {
11721
- let response = {
11722
- data: {},
11723
- status: 0,
11724
- statusText: "",
11725
- headers: {},
11726
- config: {},
11727
- };
11728
- let success = false;
11729
10663
  /* eslint-disable no-await-in-loop */
11730
- while (!success) {
10664
+ // eslint-disable-next-line no-constant-condition
10665
+ while (true) {
11731
10666
  try {
11732
10667
  const data = {
11733
10668
  id: Math.round(Math.random() * 1000),
@@ -11736,16 +10671,20 @@ class Provider {
11736
10671
  params,
11737
10672
  };
11738
10673
  const url = this.rpcNodes[this.currentNodeId];
11739
- // TODO: search conditional to enable fetch for Browser
11740
- /* const response = await fetch(url, {
11741
- method: "POST",
11742
- body: JSON.stringify(data),
10674
+ const response = await (0, cross_fetch_1.default)(url, {
10675
+ method: "POST",
10676
+ body: JSON.stringify(data),
11743
10677
  });
11744
- const json = await response.json();
11745
- if (json.error && json.error.message) throw new Error(json.error.message);
11746
- return json.result; */
11747
- response = await axios_1.default.post(url, data, { validateStatus: (s) => s < 400 });
11748
- success = true;
10678
+ const json = (await response.json());
10679
+ if (json.error && json.error.message) {
10680
+ const error = new Error(json.error.message);
10681
+ error.request = {
10682
+ method,
10683
+ params,
10684
+ };
10685
+ throw error;
10686
+ }
10687
+ return json.result;
11749
10688
  }
11750
10689
  catch (e) {
11751
10690
  const currentNode = this.rpcNodes[this.currentNodeId];
@@ -11756,12 +10695,6 @@ class Provider {
11756
10695
  throw e;
11757
10696
  }
11758
10697
  }
11759
- if (response.data.error)
11760
- throw new Error(JSON.stringify({
11761
- error: response.data.error,
11762
- request: { method, params },
11763
- }));
11764
- return response.data.result;
11765
10698
  }
11766
10699
  /**
11767
10700
  * Function to call "chain.get_account_nonce" to return the number of
@@ -11886,7 +10819,7 @@ class Provider {
11886
10819
  if (tx)
11887
10820
  bNum = Number(block.block_height);
11888
10821
  });
11889
- let lastId = blocks[blocks.length - 1].block_id;
10822
+ const lastId = blocks[blocks.length - 1].block_id;
11890
10823
  return [bNum, lastId];
11891
10824
  };
11892
10825
  let blockNumber = 0;
@@ -11908,6 +10841,7 @@ class Provider {
11908
10841
  previousId = lastId;
11909
10842
  blockNumber = Number(headTopology.height) + 1;
11910
10843
  }
10844
+ // eslint-disable-next-line no-continue
11911
10845
  if (blockNumber > Number(headTopology.height))
11912
10846
  continue;
11913
10847
  const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
@@ -11931,7 +10865,7 @@ class Provider {
11931
10865
  }
11932
10866
  }
11933
10867
  exports.Provider = Provider;
11934
- exports.default = Provider;
10868
+ exports["default"] = Provider;
11935
10869
 
11936
10870
 
11937
10871
  /***/ }),
@@ -12029,7 +10963,7 @@ class Serializer {
12029
10963
  }
12030
10964
  // Default byte conversion
12031
10965
  if (!options || !options[OP_BYTES]) {
12032
- object[name] = utils_1.decodeBase64(valueDecoded[name]);
10966
+ object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
12033
10967
  return;
12034
10968
  }
12035
10969
  // Specific byte conversion
@@ -12037,15 +10971,15 @@ class Serializer {
12037
10971
  case "BASE58":
12038
10972
  case "CONTRACT_ID":
12039
10973
  case "ADDRESS":
12040
- object[name] = utils_1.decodeBase58(valueDecoded[name]);
10974
+ object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
12041
10975
  break;
12042
10976
  case "BASE64":
12043
- object[name] = utils_1.decodeBase64(valueDecoded[name]);
10977
+ object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
12044
10978
  break;
12045
10979
  case "HEX":
12046
10980
  case "BLOCK_ID":
12047
10981
  case "TRANSACTION_ID":
12048
- object[name] = utils_1.toUint8Array(valueDecoded[name].replace("0x", ""));
10982
+ object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
12049
10983
  break;
12050
10984
  default:
12051
10985
  throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
@@ -12066,7 +11000,7 @@ class Serializer {
12066
11000
  */
12067
11001
  async deserialize(valueEncoded, typeName) {
12068
11002
  const valueBuffer = typeof valueEncoded === "string"
12069
- ? utils_1.decodeBase64(valueEncoded)
11003
+ ? (0, utils_1.decodeBase64)(valueEncoded)
12070
11004
  : valueEncoded;
12071
11005
  const protobufType = this.defaultType || this.root.lookupType(typeName);
12072
11006
  const message = protobufType.decode(valueBuffer);
@@ -12081,7 +11015,7 @@ class Serializer {
12081
11015
  return;
12082
11016
  // Default byte conversion
12083
11017
  if (!options || !options[OP_BYTES]) {
12084
- object[name] = utils_1.encodeBase64(object[name]);
11018
+ object[name] = (0, utils_1.encodeBase64)(object[name]);
12085
11019
  return;
12086
11020
  }
12087
11021
  // Specific byte conversion
@@ -12089,15 +11023,15 @@ class Serializer {
12089
11023
  case "BASE58":
12090
11024
  case "CONTRACT_ID":
12091
11025
  case "ADDRESS":
12092
- object[name] = utils_1.encodeBase58(object[name]);
11026
+ object[name] = (0, utils_1.encodeBase58)(object[name]);
12093
11027
  break;
12094
11028
  case "BASE64":
12095
- object[name] = utils_1.encodeBase64(object[name]);
11029
+ object[name] = (0, utils_1.encodeBase64)(object[name]);
12096
11030
  break;
12097
11031
  case "HEX":
12098
11032
  case "BLOCK_ID":
12099
11033
  case "TRANSACTION_ID":
12100
- object[name] = `0x${utils_1.toHexString(object[name])}`;
11034
+ object[name] = `0x${(0, utils_1.toHexString)(object[name])}`;
12101
11035
  break;
12102
11036
  default:
12103
11037
  throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
@@ -12107,7 +11041,7 @@ class Serializer {
12107
11041
  }
12108
11042
  }
12109
11043
  exports.Serializer = Serializer;
12110
- exports.default = Serializer;
11044
+ exports["default"] = Serializer;
12111
11045
 
12112
11046
 
12113
11047
  /***/ }),
@@ -12142,8 +11076,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12142
11076
  Object.defineProperty(exports, "__esModule", ({ value: true }));
12143
11077
  exports.Signer = void 0;
12144
11078
  /* eslint-disable no-param-reassign */
12145
- const sha256_1 = __webpack_require__(5374);
12146
- const secp = __importStar(__webpack_require__(1337));
11079
+ const sha256_1 = __webpack_require__(3061);
11080
+ const secp = __importStar(__webpack_require__(9656));
12147
11081
  const protocol_proto_json_1 = __importDefault(__webpack_require__(6139));
12148
11082
  const utils_1 = __webpack_require__(8593);
12149
11083
  const Serializer_1 = __webpack_require__(7187);
@@ -12233,11 +11167,11 @@ class Signer {
12233
11167
  }
12234
11168
  if (typeof c.privateKey === "string") {
12235
11169
  this.publicKey = secp.getPublicKey(c.privateKey, this.compressed);
12236
- this.address = utils_1.bitcoinAddress(utils_1.toUint8Array(this.publicKey));
11170
+ this.address = (0, utils_1.bitcoinAddress)(this.publicKey);
12237
11171
  }
12238
11172
  else {
12239
11173
  this.publicKey = secp.getPublicKey(c.privateKey, this.compressed);
12240
- this.address = utils_1.bitcoinAddress(this.publicKey);
11174
+ this.address = (0, utils_1.bitcoinAddress)(this.publicKey);
12241
11175
  }
12242
11176
  }
12243
11177
  /**
@@ -12253,9 +11187,9 @@ class Signer {
12253
11187
  */
12254
11188
  static fromWif(wif) {
12255
11189
  const compressed = wif[0] !== "5";
12256
- const privateKey = utils_1.bitcoinDecode(wif);
11190
+ const privateKey = (0, utils_1.bitcoinDecode)(wif);
12257
11191
  return new Signer({
12258
- privateKey: utils_1.toHexString(privateKey),
11192
+ privateKey: (0, utils_1.toHexString)(privateKey),
12259
11193
  compressed,
12260
11194
  });
12261
11195
  }
@@ -12272,7 +11206,7 @@ class Signer {
12272
11206
  * @returns Signer object
12273
11207
  */
12274
11208
  static fromSeed(seed, compressed) {
12275
- const privateKey = sha256_1.sha256(seed);
11209
+ const privateKey = (0, sha256_1.sha256)(seed);
12276
11210
  return new Signer({ privateKey, compressed });
12277
11211
  }
12278
11212
  /**
@@ -12283,10 +11217,10 @@ class Signer {
12283
11217
  getAddress(compressed = true) {
12284
11218
  if (typeof this.privateKey === "string") {
12285
11219
  const publicKey = secp.getPublicKey(this.privateKey, compressed);
12286
- return utils_1.bitcoinAddress(utils_1.toUint8Array(publicKey));
11220
+ return (0, utils_1.bitcoinAddress)(publicKey);
12287
11221
  }
12288
11222
  const publicKey = secp.getPublicKey(this.privateKey, compressed);
12289
- return utils_1.bitcoinAddress(publicKey);
11223
+ return (0, utils_1.bitcoinAddress)(publicKey);
12290
11224
  }
12291
11225
  /**
12292
11226
  * Function to get the private key in hex format or wif format
@@ -12309,7 +11243,7 @@ class Signer {
12309
11243
  getPrivateKey(format = "hex", compressed) {
12310
11244
  let stringPrivateKey;
12311
11245
  if (this.privateKey instanceof Uint8Array) {
12312
- stringPrivateKey = utils_1.toHexString(this.privateKey);
11246
+ stringPrivateKey = (0, utils_1.toHexString)(this.privateKey);
12313
11247
  }
12314
11248
  else if (typeof this.privateKey === "string") {
12315
11249
  stringPrivateKey = this.privateKey;
@@ -12322,7 +11256,7 @@ class Signer {
12322
11256
  case "hex":
12323
11257
  return stringPrivateKey;
12324
11258
  case "wif":
12325
- return utils_1.bitcoinEncode(utils_1.toUint8Array(stringPrivateKey), "private", comp);
11259
+ return (0, utils_1.bitcoinEncode)((0, utils_1.toUint8Array)(stringPrivateKey), "private", comp);
12326
11260
  default:
12327
11261
  /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
12328
11262
  throw new Error(`Invalid format ${format}`);
@@ -12337,7 +11271,7 @@ class Signer {
12337
11271
  async signTransaction(tx) {
12338
11272
  if (!tx.active)
12339
11273
  throw new Error("Active data is not defined");
12340
- const hash = sha256_1.sha256(utils_1.decodeBase64(tx.active));
11274
+ const hash = (0, sha256_1.sha256)((0, utils_1.decodeBase64)(tx.active));
12341
11275
  const [compSignature, recovery] = await secp.sign(hash, this.privateKey, {
12342
11276
  recovered: true,
12343
11277
  canonical: true,
@@ -12346,8 +11280,8 @@ class Signer {
12346
11280
  const compactSignature = new Uint8Array(65);
12347
11281
  compactSignature.set([recovery + 31], 0);
12348
11282
  compactSignature.set(compSignature, 1);
12349
- tx.signature_data = utils_1.encodeBase64(compactSignature);
12350
- const multihash = `0x1220${utils_1.toHexString(hash)}`; // 12: code sha2-256. 20: length (32 bytes)
11283
+ tx.signature_data = (0, utils_1.encodeBase64)(compactSignature);
11284
+ const multihash = `0x1220${(0, utils_1.toHexString)(hash)}`; // 12: code sha2-256. 20: length (32 bytes)
12351
11285
  tx.id = multihash;
12352
11286
  return tx;
12353
11287
  }
@@ -12429,19 +11363,19 @@ class Signer {
12429
11363
  if (opts && typeof opts.compressed !== "undefined") {
12430
11364
  compressed = opts.compressed;
12431
11365
  }
12432
- const hash = sha256_1.sha256(utils_1.decodeBase64(txOrBlock.active));
12433
- const compactSignatureHex = utils_1.toHexString(utils_1.decodeBase64(signatureData));
11366
+ const hash = (0, sha256_1.sha256)((0, utils_1.decodeBase64)(txOrBlock.active));
11367
+ const compactSignatureHex = (0, utils_1.toHexString)((0, utils_1.decodeBase64)(signatureData));
12434
11368
  const recovery = Number(`0x${compactSignatureHex.slice(0, 2)}`) - 31;
12435
11369
  const rHex = compactSignatureHex.slice(2, 66);
12436
11370
  const sHex = compactSignatureHex.slice(66);
12437
11371
  const r = BigInt(`0x${rHex}`);
12438
11372
  const s = BigInt(`0x${sHex}`);
12439
11373
  const sig = new secp.Signature(r, s);
12440
- const publicKey = secp.recoverPublicKey(utils_1.toHexString(hash), sig.toHex(), recovery);
11374
+ const publicKey = secp.recoverPublicKey((0, utils_1.toHexString)(hash), sig.toHex(), recovery);
12441
11375
  if (!publicKey)
12442
11376
  throw new Error("Public key cannot be recovered");
12443
11377
  if (!compressed)
12444
- return publicKey;
11378
+ return (0, utils_1.toHexString)(publicKey);
12445
11379
  return secp.Point.fromHex(publicKey).toHex(true);
12446
11380
  }
12447
11381
  /**
@@ -12494,7 +11428,7 @@ class Signer {
12494
11428
  */
12495
11429
  static async recoverAddress(txOrBlock, opts) {
12496
11430
  const publicKey = await Signer.recoverPublicKey(txOrBlock, opts);
12497
- return utils_1.bitcoinAddress(utils_1.toUint8Array(publicKey));
11431
+ return (0, utils_1.bitcoinAddress)((0, utils_1.toUint8Array)(publicKey));
12498
11432
  }
12499
11433
  /**
12500
11434
  * Function to encode a transaction
@@ -12522,7 +11456,7 @@ class Signer {
12522
11456
  };
12523
11457
  const buffer = await this.serializer.serialize(activeData2);
12524
11458
  return {
12525
- active: utils_1.encodeBase64(buffer),
11459
+ active: (0, utils_1.encodeBase64)(buffer),
12526
11460
  };
12527
11461
  }
12528
11462
  /**
@@ -12535,7 +11469,7 @@ class Signer {
12535
11469
  }
12536
11470
  }
12537
11471
  exports.Signer = Signer;
12538
- exports.default = Signer;
11472
+ exports["default"] = Signer;
12539
11473
 
12540
11474
 
12541
11475
  /***/ }),
@@ -12610,8 +11544,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12610
11544
  Object.defineProperty(exports, "__esModule", ({ value: true }));
12611
11545
  exports.ProtocolTypes = exports.Krc20Abi = exports.parseUnits = exports.formatUnits = exports.bitcoinAddress = exports.bitcoinDecode = exports.bitcoinEncode = exports.decodeBase64 = exports.encodeBase64 = exports.decodeBase58 = exports.encodeBase58 = exports.toHexString = exports.toUint8Array = void 0;
12612
11546
  const multibase = __importStar(__webpack_require__(6957));
12613
- const sha256_1 = __webpack_require__(5374);
12614
- const ripemd160_1 = __webpack_require__(7050);
11547
+ const sha256_1 = __webpack_require__(3061);
11548
+ const ripemd160_1 = __webpack_require__(830);
12615
11549
  const krc20_proto_json_1 = __importDefault(__webpack_require__(7177));
12616
11550
  const protocol_proto_json_1 = __importDefault(__webpack_require__(6139));
12617
11551
  /**
@@ -12698,8 +11632,8 @@ function bitcoinEncode(buffer, type, compressed = false) {
12698
11632
  prefixBuffer[0] = 128;
12699
11633
  }
12700
11634
  prefixBuffer.set(buffer, 1);
12701
- const firstHash = sha256_1.sha256(prefixBuffer);
12702
- const doubleHash = sha256_1.sha256(firstHash);
11635
+ const firstHash = (0, sha256_1.sha256)(prefixBuffer);
11636
+ const doubleHash = (0, sha256_1.sha256)(firstHash);
12703
11637
  const checksum = new Uint8Array(4);
12704
11638
  checksum.set(doubleHash.slice(0, 4));
12705
11639
  bufferCheck.set(buffer, 1);
@@ -12738,8 +11672,8 @@ exports.bitcoinDecode = bitcoinDecode;
12738
11672
  * address = bitcoinEncode( ripemd160 ( sha256 ( publicKey ) ) )
12739
11673
  */
12740
11674
  function bitcoinAddress(publicKey) {
12741
- const hash = sha256_1.sha256(publicKey);
12742
- const hash160 = ripemd160_1.ripemd160(hash);
11675
+ const hash = (0, sha256_1.sha256)(publicKey);
11676
+ const hash160 = (0, ripemd160_1.ripemd160)(hash);
12743
11677
  return bitcoinEncode(hash160, "public");
12744
11678
  }
12745
11679
  exports.bitcoinAddress = bitcoinAddress;
@@ -12839,7 +11773,7 @@ exports.ProtocolTypes = protocol_proto_json_1.default;
12839
11773
 
12840
11774
  /***/ }),
12841
11775
 
12842
- /***/ 5102:
11776
+ /***/ 9159:
12843
11777
  /***/ (() => {
12844
11778
 
12845
11779
  /* (ignored) */