@monerium/sdk 2.0.7 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,35 +1,35 @@
1
1
  var Ce = Object.defineProperty;
2
- var Se = (s, f, _) =>
3
- f in s
4
- ? Ce(s, f, { enumerable: !0, configurable: !0, writable: !0, value: _ })
5
- : (s[f] = _);
6
- var G = (s, f, _) => (Se(s, typeof f != "symbol" ? f + "" : f, _), _),
7
- J = (s, f, _) => {
8
- if (!f.has(s)) throw TypeError("Cannot " + _);
2
+ var Se = (s, c, _) =>
3
+ c in s
4
+ ? Ce(s, c, { enumerable: !0, configurable: !0, writable: !0, value: _ })
5
+ : (s[c] = _);
6
+ var M = (s, c, _) => (Se(s, typeof c != "symbol" ? c + "" : c, _), _),
7
+ J = (s, c, _) => {
8
+ if (!c.has(s)) throw TypeError("Cannot " + _);
9
9
  };
10
- var M = (s, f, _) => (
11
- J(s, f, "read from private field"), _ ? _.call(s) : f.get(s)
10
+ var D = (s, c, _) => (
11
+ J(s, c, "read from private field"), _ ? _.call(s) : c.get(s)
12
12
  ),
13
- U = (s, f, _) => {
14
- if (f.has(s))
13
+ T = (s, c, _) => {
14
+ if (c.has(s))
15
15
  throw TypeError("Cannot add the same private member more than once");
16
- f instanceof WeakSet ? f.add(s) : f.set(s, _);
16
+ c instanceof WeakSet ? c.add(s) : c.set(s, _);
17
17
  },
18
- Q = (s, f, _, W) => (
19
- J(s, f, "write to private field"), W ? W.call(s, _) : f.set(s, _), _
18
+ Q = (s, c, _, W) => (
19
+ J(s, c, "write to private field"), W ? W.call(s, _) : c.set(s, _), _
20
20
  );
21
- var P = (s, f, _) => (J(s, f, "access private method"), _);
22
- (function (s, f) {
21
+ var A = (s, c, _) => (J(s, c, "access private method"), _);
22
+ (function (s, c) {
23
23
  typeof exports == "object" && typeof module < "u"
24
- ? f(exports)
24
+ ? c(exports)
25
25
  : typeof define == "function" && define.amd
26
- ? define(["exports"], f)
26
+ ? define(["exports"], c)
27
27
  : ((s = typeof globalThis < "u" ? globalThis : s || self),
28
- f((s["monerium-sdk"] = {})));
28
+ c((s["monerium-sdk"] = {})));
29
29
  })(this, function (s) {
30
- var $, z, k, R, q, ue, I, fe, F, ce;
30
+ var $, z, P, k, j, ue, q, ce, F, fe;
31
31
  ("use strict");
32
- var f =
32
+ var c =
33
33
  typeof globalThis < "u"
34
34
  ? globalThis
35
35
  : typeof window < "u"
@@ -43,8 +43,8 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
43
43
  if (r.__esModule) return r;
44
44
  var n = r.default;
45
45
  if (typeof n == "function") {
46
- var a = function c() {
47
- if (this instanceof c) {
46
+ var a = function f() {
47
+ if (this instanceof f) {
48
48
  var w = [null];
49
49
  w.push.apply(w, arguments);
50
50
  var v = Function.bind.apply(n, w);
@@ -56,17 +56,17 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
56
56
  } else a = {};
57
57
  return (
58
58
  Object.defineProperty(a, "__esModule", { value: !0 }),
59
- Object.keys(r).forEach(function (c) {
60
- var w = Object.getOwnPropertyDescriptor(r, c);
59
+ Object.keys(r).forEach(function (f) {
60
+ var w = Object.getOwnPropertyDescriptor(r, f);
61
61
  Object.defineProperty(
62
62
  a,
63
- c,
63
+ f,
64
64
  w.get
65
65
  ? w
66
66
  : {
67
67
  enumerable: !0,
68
68
  get: function () {
69
- return r[c];
69
+ return r[f];
70
70
  },
71
71
  }
72
72
  );
@@ -90,13 +90,13 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
90
90
  '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'
91
91
  );
92
92
  }
93
- var j = {},
93
+ var L = {},
94
94
  de = {
95
95
  get exports() {
96
- return j;
96
+ return L;
97
97
  },
98
98
  set exports(r) {
99
- j = r;
99
+ L = r;
100
100
  },
101
101
  };
102
102
  const pe = _(
@@ -109,17 +109,17 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
109
109
  )
110
110
  );
111
111
  var X;
112
- function D() {
112
+ function V() {
113
113
  return (
114
114
  X ||
115
115
  ((X = 1),
116
116
  (function (r, n) {
117
- (function (a, c) {
118
- r.exports = c();
119
- })(f, function () {
117
+ (function (a, f) {
118
+ r.exports = f();
119
+ })(c, function () {
120
120
  var a =
121
121
  a ||
122
- (function (c, w) {
122
+ (function (f, w) {
123
123
  var v;
124
124
  if (
125
125
  (typeof window < "u" && window.crypto && (v = window.crypto),
@@ -131,7 +131,7 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
131
131
  typeof window < "u" &&
132
132
  window.msCrypto &&
133
133
  (v = window.msCrypto),
134
- !v && typeof f < "u" && f.crypto && (v = f.crypto),
134
+ !v && typeof c < "u" && c.crypto && (v = c.crypto),
135
135
  !v && typeof he == "function")
136
136
  )
137
137
  try {
@@ -228,7 +228,7 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
228
228
  var e = this.words,
229
229
  t = this.sigBytes;
230
230
  (e[t >>> 2] &= 4294967295 << (32 - (t % 4) * 8)),
231
- (e.length = c.ceil(t / 4));
231
+ (e.length = f.ceil(t / 4));
232
232
  },
233
233
  clone: function () {
234
234
  var e = y.clone.call(this);
@@ -309,16 +309,16 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
309
309
  C = B * 4,
310
310
  S = m / C;
311
311
  e
312
- ? (S = c.ceil(S))
313
- : (S = c.max((S | 0) - this._minBufferSize, 0));
312
+ ? (S = f.ceil(S))
313
+ : (S = f.max((S | 0) - this._minBufferSize, 0));
314
314
  var E = S * B,
315
- T = c.min(E * 4, m);
315
+ U = f.min(E * 4, m);
316
316
  if (E) {
317
- for (var L = 0; L < E; L += B)
318
- this._doProcessBlock(l, L);
319
- (t = l.splice(0, E)), (o.sigBytes -= T);
317
+ for (var I = 0; I < E; I += B)
318
+ this._doProcessBlock(l, I);
319
+ (t = l.splice(0, E)), (o.sigBytes -= U);
320
320
  }
321
- return new d.init(t, T);
321
+ return new d.init(t, U);
322
322
  },
323
323
  clone: function () {
324
324
  var e = y.clone.call(this);
@@ -350,29 +350,29 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
350
350
  },
351
351
  _createHmacHelper: function (e) {
352
352
  return function (t, o) {
353
- return new A.HMAC.init(e, o).finalize(t);
353
+ return new R.HMAC.init(e, o).finalize(t);
354
354
  };
355
355
  },
356
356
  });
357
- var A = (u.algo = {});
357
+ var R = (u.algo = {});
358
358
  return u;
359
359
  })(Math);
360
360
  return a;
361
361
  });
362
362
  })(de)),
363
- j
363
+ L
364
364
  );
365
365
  }
366
366
  (function (r, n) {
367
- (function (a, c) {
368
- r.exports = c(D());
369
- })(f, function (a) {
367
+ (function (a, f) {
368
+ r.exports = f(V());
369
+ })(c, function (a) {
370
370
  return (
371
371
  (function () {
372
- var c = a,
373
- w = c.lib,
372
+ var f = a,
373
+ w = f.lib,
374
374
  v = w.WordArray,
375
- H = c.enc;
375
+ H = f.enc;
376
376
  H.Base64url = {
377
377
  stringify: function (u, x = !0) {
378
378
  var y = u.words,
@@ -383,8 +383,8 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
383
383
  for (
384
384
  var i = (y[g >>> 2] >>> (24 - (g % 4) * 8)) & 255,
385
385
  p = (y[(g + 1) >>> 2] >>> (24 - ((g + 1) % 4) * 8)) & 255,
386
- A = (y[(g + 2) >>> 2] >>> (24 - ((g + 2) % 4) * 8)) & 255,
387
- e = (i << 16) | (p << 8) | A,
386
+ R = (y[(g + 2) >>> 2] >>> (24 - ((g + 2) % 4) * 8)) & 255,
387
+ e = (i << 16) | (p << 8) | R,
388
388
  t = 0;
389
389
  t < 4 && g + t * 0.75 < d;
390
390
  t++
@@ -428,24 +428,24 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
428
428
  );
429
429
  });
430
430
  })(le);
431
- var V = {},
431
+ var N = {},
432
432
  ve = {
433
433
  get exports() {
434
- return V;
434
+ return N;
435
435
  },
436
436
  set exports(r) {
437
- V = r;
437
+ N = r;
438
438
  },
439
439
  };
440
440
  (function (r, n) {
441
- (function (a, c) {
442
- r.exports = c(D());
443
- })(f, function (a) {
441
+ (function (a, f) {
442
+ r.exports = f(V());
443
+ })(c, function (a) {
444
444
  return (
445
445
  (function () {
446
446
  if (typeof ArrayBuffer == "function") {
447
- var c = a,
448
- w = c.lib,
447
+ var f = a,
448
+ w = f.lib,
449
449
  v = w.WordArray,
450
450
  H = v.init,
451
451
  O = (v.init = function (u) {
@@ -475,21 +475,21 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
475
475
  );
476
476
  });
477
477
  })(ve);
478
- var N = {},
478
+ var G = {},
479
479
  ge = {
480
480
  get exports() {
481
- return N;
481
+ return G;
482
482
  },
483
483
  set exports(r) {
484
- N = r;
484
+ G = r;
485
485
  },
486
486
  };
487
487
  (function (r, n) {
488
- (function (a, c) {
489
- r.exports = c(D());
490
- })(f, function (a) {
488
+ (function (a, f) {
489
+ r.exports = f(V());
490
+ })(c, function (a) {
491
491
  return (
492
- (function (c) {
492
+ (function (f) {
493
493
  var w = a,
494
494
  v = w.lib,
495
495
  H = v.WordArray,
@@ -498,18 +498,18 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
498
498
  x = [],
499
499
  y = [];
500
500
  (function () {
501
- function h(A) {
502
- for (var e = c.sqrt(A), t = 2; t <= e; t++)
503
- if (!(A % t)) return !1;
501
+ function h(R) {
502
+ for (var e = f.sqrt(R), t = 2; t <= e; t++)
503
+ if (!(R % t)) return !1;
504
504
  return !0;
505
505
  }
506
- function g(A) {
507
- return ((A - (A | 0)) * 4294967296) | 0;
506
+ function g(R) {
507
+ return ((R - (R | 0)) * 4294967296) | 0;
508
508
  }
509
509
  for (var i = 2, p = 0; p < 64; )
510
510
  h(i) &&
511
- (p < 8 && (x[p] = g(c.pow(i, 1 / 2))),
512
- (y[p] = g(c.pow(i, 1 / 3))),
511
+ (p < 8 && (x[p] = g(f.pow(i, 1 / 2))),
512
+ (y[p] = g(f.pow(i, 1 / 3))),
513
513
  p++),
514
514
  i++;
515
515
  })();
@@ -522,7 +522,7 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
522
522
  for (
523
523
  var i = this._hash.words,
524
524
  p = i[0],
525
- A = i[1],
525
+ R = i[1],
526
526
  e = i[2],
527
527
  t = i[3],
528
528
  o = i[4],
@@ -540,15 +540,15 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
540
540
  ((S << 25) | (S >>> 7)) ^
541
541
  ((S << 14) | (S >>> 18)) ^
542
542
  (S >>> 3),
543
- T = d[C - 2],
544
- L =
545
- ((T << 15) | (T >>> 17)) ^
546
- ((T << 13) | (T >>> 19)) ^
547
- (T >>> 10);
548
- d[C] = E + d[C - 7] + L + d[C - 16];
543
+ U = d[C - 2],
544
+ I =
545
+ ((U << 15) | (U >>> 17)) ^
546
+ ((U << 13) | (U >>> 19)) ^
547
+ (U >>> 10);
548
+ d[C] = E + d[C - 7] + I + d[C - 16];
549
549
  }
550
550
  var _e = (o & l) ^ (~o & m),
551
- we = (p & A) ^ (p & e) ^ (A & e),
551
+ we = (p & R) ^ (p & e) ^ (R & e),
552
552
  be =
553
553
  ((p << 30) | (p >>> 2)) ^
554
554
  ((p << 19) | (p >>> 13)) ^
@@ -564,12 +564,12 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
564
564
  (l = o),
565
565
  (o = (t + se) | 0),
566
566
  (t = e),
567
- (e = A),
568
- (A = p),
567
+ (e = R),
568
+ (R = p),
569
569
  (p = (se + xe) | 0);
570
570
  }
571
571
  (i[0] = (i[0] + p) | 0),
572
- (i[1] = (i[1] + A) | 0),
572
+ (i[1] = (i[1] + R) | 0),
573
573
  (i[2] = (i[2] + e) | 0),
574
574
  (i[3] = (i[3] + t) | 0),
575
575
  (i[4] = (i[4] + o) | 0),
@@ -584,7 +584,7 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
584
584
  p = h.sigBytes * 8;
585
585
  return (
586
586
  (g[p >>> 5] |= 128 << (24 - (p % 32))),
587
- (g[(((p + 64) >>> 9) << 4) + 14] = c.floor(i / 4294967296)),
587
+ (g[(((p + 64) >>> 9) << 4) + 14] = f.floor(i / 4294967296)),
588
588
  (g[(((p + 64) >>> 9) << 4) + 15] = i),
589
589
  (h.sigBytes = g.length * 4),
590
590
  this._process(),
@@ -617,26 +617,27 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
617
617
  };
618
618
  class me {
619
619
  constructor(n = "sandbox") {
620
- U(this, k);
621
- U(this, q);
622
- U(this, I);
623
- U(this, F);
624
- U(this, $, void 0);
625
- U(this, z, void 0);
626
- G(this, "codeVerifier");
627
- G(this, "bearerProfile");
620
+ T(this, P);
621
+ T(this, j);
622
+ T(this, q);
623
+ T(this, F);
624
+ T(this, $, void 0);
625
+ T(this, z, void 0);
626
+ M(this, "codeVerifier");
627
+ M(this, "bearerProfile");
628
+ M(this, "pkceRequest", (n) => this.getAuthFlowURI(n));
628
629
  Q(this, $, ye.environments[n]);
629
630
  }
630
631
  async auth(n) {
631
632
  let a;
632
- if (P(this, q, ue).call(this, n))
633
+ if (A(this, j, ue).call(this, n))
633
634
  a = { ...n, grant_type: "authorization_code" };
634
- else if (P(this, I, fe).call(this, n))
635
+ else if (A(this, q, ce).call(this, n))
635
636
  a = { ...n, grant_type: "refresh_token" };
636
- else if (P(this, F, ce).call(this, n))
637
+ else if (A(this, F, fe).call(this, n))
637
638
  a = { ...n, grant_type: "client_credentials" };
638
639
  else throw new Error("Authentication method could not be detected.");
639
- (this.bearerProfile = await P(this, k, R).call(
640
+ (this.bearerProfile = await A(this, P, k).call(
640
641
  this,
641
642
  "post",
642
643
  "auth/token",
@@ -645,40 +646,41 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
645
646
  )),
646
647
  Q(this, z, `Bearer ${this.bearerProfile.access_token}`);
647
648
  }
648
- pkceRequest(n) {
649
- this.codeVerifier = V.random(64).toString();
650
- const a = W.stringify(N(this.codeVerifier)),
651
- c = {
649
+ getAuthFlowURI(n) {
650
+ this.codeVerifier = N.random(64).toString();
651
+ const a = W.stringify(G(this.codeVerifier)),
652
+ f = {
652
653
  ...n,
654
+ client_id: n == null ? void 0 : n.client_id,
653
655
  code_challenge: a,
654
656
  code_challenge_method: "S256",
655
657
  response_type: "code",
656
658
  };
657
- return `${M(this, $).api}/auth?${new URLSearchParams(c)}`;
659
+ return `${D(this, $).api}/auth?${new URLSearchParams(f)}`;
658
660
  }
659
661
  getAuthContext() {
660
- return P(this, k, R).call(this, "get", "auth/context");
662
+ return A(this, P, k).call(this, "get", "auth/context");
661
663
  }
662
664
  getProfile(n) {
663
- return P(this, k, R).call(this, "get", `profiles/${n}`);
665
+ return A(this, P, k).call(this, "get", `profiles/${n}`);
664
666
  }
665
667
  getBalances(n) {
666
668
  return n
667
- ? P(this, k, R).call(this, "get", `profiles/${n}/balances`)
668
- : P(this, k, R).call(this, "get", "balances");
669
+ ? A(this, P, k).call(this, "get", `profiles/${n}/balances`)
670
+ : A(this, P, k).call(this, "get", "balances");
669
671
  }
670
672
  getOrders(n) {
671
673
  const a = new URLSearchParams(n);
672
- return P(this, k, R).call(this, "get", `orders?${a}`);
674
+ return A(this, P, k).call(this, "get", `orders?${a}`);
673
675
  }
674
676
  getOrder(n) {
675
- return P(this, k, R).call(this, "get", `orders/${n}`);
677
+ return A(this, P, k).call(this, "get", `orders/${n}`);
676
678
  }
677
679
  getTokens() {
678
- return P(this, k, R).call(this, "get", "tokens");
680
+ return A(this, P, k).call(this, "get", "tokens");
679
681
  }
680
682
  linkAddress(n, a) {
681
- return P(this, k, R).call(
683
+ return A(this, P, k).call(
682
684
  this,
683
685
  "post",
684
686
  `profiles/${n}/addresses`,
@@ -687,17 +689,17 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
687
689
  }
688
690
  placeOrder(n, a) {
689
691
  return a
690
- ? P(this, k, R).call(
692
+ ? A(this, P, k).call(
691
693
  this,
692
694
  "post",
693
695
  `profiles/${a}/orders`,
694
696
  JSON.stringify(n)
695
697
  )
696
- : P(this, k, R).call(this, "post", "orders", JSON.stringify(n));
698
+ : A(this, P, k).call(this, "post", "orders", JSON.stringify(n));
697
699
  }
698
700
  uploadSupportingDocument(n) {
699
701
  const a = new URLSearchParams(n);
700
- return P(this, k, R).call(
702
+ return A(this, P, k).call(
701
703
  this,
702
704
  "post",
703
705
  "files/supporting-document",
@@ -708,32 +710,32 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
708
710
  }
709
711
  ($ = new WeakMap()),
710
712
  (z = new WeakMap()),
711
- (k = new WeakSet()),
712
- (R = async function (n, a, c, w) {
713
- const v = await fetch(`${M(this, $).api}/${a}`, {
713
+ (P = new WeakSet()),
714
+ (k = async function (n, a, f, w) {
715
+ const v = await fetch(`${D(this, $).api}/${a}`, {
714
716
  method: n,
715
717
  headers: {
716
718
  "Content-Type": `application/${
717
719
  w ? "x-www-form-urlencoded" : "json"
718
720
  }`,
719
- Authorization: M(this, z) || "",
721
+ Authorization: D(this, z) || "",
720
722
  },
721
- body: c,
723
+ body: f,
722
724
  }),
723
725
  H = await v.json();
724
726
  if (v.ok) return H;
725
727
  throw H;
726
728
  }),
727
- (q = new WeakSet()),
729
+ (j = new WeakSet()),
728
730
  (ue = function (n) {
729
731
  return n.code != null;
730
732
  }),
731
- (I = new WeakSet()),
732
- (fe = function (n) {
733
+ (q = new WeakSet()),
734
+ (ce = function (n) {
733
735
  return n.refresh_token != null;
734
736
  }),
735
737
  (F = new WeakSet()),
736
- (ce = function (n) {
738
+ (fe = function (n) {
737
739
  return n.client_secret != null;
738
740
  });
739
741
  var Z = ((r) => (