@monerium/sdk 2.0.7 → 2.0.9

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 L = (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, _, I) => (
19
+ J(s, c, "write to private field"), I ? I.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 W, E, P, k, q, ue, F, ce, M, 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
  );
@@ -74,13 +74,13 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
74
74
  a
75
75
  );
76
76
  }
77
- var W = {},
77
+ var I = {},
78
78
  le = {
79
79
  get exports() {
80
- return W;
80
+ return I;
81
81
  },
82
82
  set exports(r) {
83
- W = r;
83
+ I = r;
84
84
  },
85
85
  };
86
86
  function he(r) {
@@ -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));
314
- var E = S * B,
315
- T = c.min(E * 4, m);
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);
312
+ ? (S = f.ceil(S))
313
+ : (S = f.max((S | 0) - this._minBufferSize, 0));
314
+ var $ = S * B,
315
+ U = f.min($ * 4, m);
316
+ if ($) {
317
+ for (var z = 0; z < $; z += B)
318
+ this._doProcessBlock(l, z);
319
+ (t = l.splice(0, $)), (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,11 +350,11 @@ 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;
@@ -364,15 +364,15 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
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],
@@ -536,19 +536,19 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
536
536
  if (C < 16) d[C] = h[g + C] | 0;
537
537
  else {
538
538
  var S = d[C - 15],
539
- E =
539
+ $ =
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
+ z =
545
+ ((U << 15) | (U >>> 17)) ^
546
+ ((U << 13) | (U >>> 19)) ^
547
+ (U >>> 10);
548
+ d[C] = $ + d[C - 7] + z + 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,68 +617,72 @@ 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");
628
- Q(this, $, ye.environments[n]);
620
+ T(this, P);
621
+ T(this, q);
622
+ T(this, F);
623
+ T(this, M);
624
+ T(this, W, void 0);
625
+ T(this, E, void 0);
626
+ L(this, "codeVerifier");
627
+ L(this, "bearerProfile");
628
+ L(this, "clientId");
629
+ L(this, "pkceRequest", this.getAuthFlowURI);
630
+ Q(this, W, ye.environments[n]);
629
631
  }
630
632
  async auth(n) {
631
633
  let a;
632
- if (P(this, q, ue).call(this, n))
634
+ if (A(this, q, ue).call(this, n))
633
635
  a = { ...n, grant_type: "authorization_code" };
634
- else if (P(this, I, fe).call(this, n))
636
+ else if (A(this, F, ce).call(this, n))
635
637
  a = { ...n, grant_type: "refresh_token" };
636
- else if (P(this, F, ce).call(this, n))
638
+ else if (A(this, M, fe).call(this, n))
637
639
  a = { ...n, grant_type: "client_credentials" };
638
640
  else throw new Error("Authentication method could not be detected.");
639
- (this.bearerProfile = await P(this, k, R).call(
640
- this,
641
- "post",
642
- "auth/token",
643
- new URLSearchParams(a),
644
- !0
645
- )),
646
- Q(this, z, `Bearer ${this.bearerProfile.access_token}`);
641
+ (this.clientId = n.client_id),
642
+ (this.bearerProfile = await A(this, P, k).call(
643
+ this,
644
+ "post",
645
+ "auth/token",
646
+ new URLSearchParams(a),
647
+ !0
648
+ )),
649
+ Q(this, E, `Bearer ${this.bearerProfile.access_token}`);
647
650
  }
648
- pkceRequest(n) {
649
- this.codeVerifier = V.random(64).toString();
650
- const a = W.stringify(N(this.codeVerifier)),
651
- c = {
651
+ getAuthFlowURI(n) {
652
+ this.codeVerifier = N.random(64).toString();
653
+ const a = I.stringify(G(this.codeVerifier)),
654
+ f = {
652
655
  ...n,
656
+ client_id: this.clientId || (n == null ? void 0 : n.client_id),
653
657
  code_challenge: a,
654
658
  code_challenge_method: "S256",
655
659
  response_type: "code",
656
660
  };
657
- return `${M(this, $).api}/auth?${new URLSearchParams(c)}`;
661
+ return `${D(this, W).api}/auth?${new URLSearchParams(f)}`;
658
662
  }
659
663
  getAuthContext() {
660
- return P(this, k, R).call(this, "get", "auth/context");
664
+ return A(this, P, k).call(this, "get", "auth/context");
661
665
  }
662
666
  getProfile(n) {
663
- return P(this, k, R).call(this, "get", `profiles/${n}`);
667
+ return A(this, P, k).call(this, "get", `profiles/${n}`);
664
668
  }
665
669
  getBalances(n) {
666
670
  return n
667
- ? P(this, k, R).call(this, "get", `profiles/${n}/balances`)
668
- : P(this, k, R).call(this, "get", "balances");
671
+ ? A(this, P, k).call(this, "get", `profiles/${n}/balances`)
672
+ : A(this, P, k).call(this, "get", "balances");
669
673
  }
670
674
  getOrders(n) {
671
675
  const a = new URLSearchParams(n);
672
- return P(this, k, R).call(this, "get", `orders?${a}`);
676
+ return A(this, P, k).call(this, "get", `orders?${a}`);
673
677
  }
674
678
  getOrder(n) {
675
- return P(this, k, R).call(this, "get", `orders/${n}`);
679
+ return A(this, P, k).call(this, "get", `orders/${n}`);
676
680
  }
677
681
  getTokens() {
678
- return P(this, k, R).call(this, "get", "tokens");
682
+ return A(this, P, k).call(this, "get", "tokens");
679
683
  }
680
684
  linkAddress(n, a) {
681
- return P(this, k, R).call(
685
+ return A(this, P, k).call(
682
686
  this,
683
687
  "post",
684
688
  `profiles/${n}/addresses`,
@@ -687,17 +691,17 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
687
691
  }
688
692
  placeOrder(n, a) {
689
693
  return a
690
- ? P(this, k, R).call(
694
+ ? A(this, P, k).call(
691
695
  this,
692
696
  "post",
693
697
  `profiles/${a}/orders`,
694
698
  JSON.stringify(n)
695
699
  )
696
- : P(this, k, R).call(this, "post", "orders", JSON.stringify(n));
700
+ : A(this, P, k).call(this, "post", "orders", JSON.stringify(n));
697
701
  }
698
702
  uploadSupportingDocument(n) {
699
703
  const a = new URLSearchParams(n);
700
- return P(this, k, R).call(
704
+ return A(this, P, k).call(
701
705
  this,
702
706
  "post",
703
707
  "files/supporting-document",
@@ -706,19 +710,19 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
706
710
  );
707
711
  }
708
712
  }
709
- ($ = new WeakMap()),
710
- (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
+ (W = new WeakMap()),
714
+ (E = new WeakMap()),
715
+ (P = new WeakSet()),
716
+ (k = async function (n, a, f, w) {
717
+ const v = await fetch(`${D(this, W).api}/${a}`, {
714
718
  method: n,
715
719
  headers: {
716
720
  "Content-Type": `application/${
717
721
  w ? "x-www-form-urlencoded" : "json"
718
722
  }`,
719
- Authorization: M(this, z) || "",
723
+ Authorization: D(this, E) || "",
720
724
  },
721
- body: c,
725
+ body: f,
722
726
  }),
723
727
  H = await v.json();
724
728
  if (v.ok) return H;
@@ -728,12 +732,12 @@ var P = (s, f, _) => (J(s, f, "access private method"), _);
728
732
  (ue = function (n) {
729
733
  return n.code != null;
730
734
  }),
731
- (I = new WeakSet()),
732
- (fe = function (n) {
733
- return n.refresh_token != null;
734
- }),
735
735
  (F = new WeakSet()),
736
736
  (ce = function (n) {
737
+ return n.refresh_token != null;
738
+ }),
739
+ (M = new WeakSet()),
740
+ (fe = function (n) {
737
741
  return n.client_secret != null;
738
742
  });
739
743
  var Z = ((r) => (