@monerium/sdk-react-provider 0.0.7 → 0.0.8

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.mjs CHANGED
@@ -1,22 +1,21 @@
1
- var te = (o, e, t) => {
2
- if (!e.has(o))
1
+ import { jsx as ge } from "react/jsx-runtime";
2
+ import { createContext as ve, useState as T, useEffect as te, useCallback as G, useContext as we } from "react";
3
+ const ue = ve(null);
4
+ var oe = (i, e, t) => {
5
+ if (!e.has(i))
3
6
  throw TypeError("Cannot " + t);
4
- };
5
- var y = (o, e, t) => (te(o, e, "read from private field"), t ? t.call(o) : e.get(o)), H = (o, e, t) => {
6
- if (e.has(o))
7
+ }, m = (i, e, t) => (oe(i, e, "read from private field"), t ? t.call(i) : e.get(i)), R = (i, e, t) => {
8
+ if (e.has(i))
7
9
  throw TypeError("Cannot add the same private member more than once");
8
- e instanceof WeakSet ? e.add(o) : e.set(o, t);
9
- }, I = (o, e, t, n) => (te(o, e, "write to private field"), n ? n.call(o, t) : e.set(o, t), t);
10
- var P = (o, e, t) => (te(o, e, "access private method"), t);
11
- import { jsx as ve } from "react/jsx-runtime";
12
- import { createContext as ge, useState as z, useEffect as re, useCallback as Y, useContext as we } from "react";
13
- const de = ge(null), Z = (o) => {
10
+ e instanceof WeakSet ? e.add(i) : e.set(i, t);
11
+ }, P = (i, e, t, n) => (oe(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), z = (i, e, t) => (oe(i, e, "access private method"), t);
12
+ const Z = (i) => {
14
13
  var e;
15
- return o && ((e = Object.entries(o)) == null ? void 0 : e.length) > 0 ? Object.entries(o).map(
14
+ return i && ((e = Object.entries(i)) == null ? void 0 : e.length) > 0 ? Object.entries(i).map(
16
15
  ([t, n]) => `${encodeURIComponent(t)}=${encodeURIComponent(n)}`
17
16
  ).join("&") : "";
18
- }, ye = (o) => {
19
- switch (o) {
17
+ }, ye = (i) => {
18
+ switch (i) {
20
19
  case 1:
21
20
  case 5:
22
21
  return "ethereum";
@@ -27,10 +26,10 @@ const de = ge(null), Z = (o) => {
27
26
  case 80001:
28
27
  return "polygon";
29
28
  default:
30
- throw new Error(`Chain not supported: ${o}`);
29
+ throw new Error(`Chain not supported: ${i}`);
31
30
  }
32
- }, me = (o) => {
33
- switch (o) {
31
+ }, me = (i) => {
32
+ switch (i) {
34
33
  case 1:
35
34
  case 100:
36
35
  case 137:
@@ -42,9 +41,9 @@ const de = ge(null), Z = (o) => {
42
41
  case 80001:
43
42
  return "mumbai";
44
43
  default:
45
- throw new Error(`Network not supported: ${o}`);
44
+ throw new Error(`Network not supported: ${i}`);
46
45
  }
47
- }, ne = {
46
+ }, re = {
48
47
  environments: {
49
48
  production: {
50
49
  api: "https://api.monerium.app",
@@ -57,82 +56,82 @@ const de = ge(null), Z = (o) => {
57
56
  wss: "wss://api.monerium.dev"
58
57
  }
59
58
  }
60
- }, N = "monerium.sdk.code_verifier", oe = "monerium.sdk.refresh_token";
61
- var j = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
62
- function fe(o) {
63
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
59
+ }, N = "monerium.sdk.code_verifier", ne = "monerium.sdk.refresh_token";
60
+ var J = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
61
+ function de(i) {
62
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
64
63
  }
65
- function _e(o) {
66
- if (o.__esModule)
67
- return o;
68
- var e = o.default;
64
+ function _e(i) {
65
+ if (i.__esModule)
66
+ return i;
67
+ var e = i.default;
69
68
  if (typeof e == "function") {
70
69
  var t = function n() {
71
70
  if (this instanceof n) {
72
- var i = [null];
73
- i.push.apply(i, arguments);
74
- var c = Function.bind.apply(e, i);
75
- return new c();
71
+ var o = [null];
72
+ o.push.apply(o, arguments);
73
+ var a = Function.bind.apply(e, o);
74
+ return new a();
76
75
  }
77
76
  return e.apply(this, arguments);
78
77
  };
79
78
  t.prototype = e.prototype;
80
79
  } else
81
80
  t = {};
82
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(o).forEach(function(n) {
83
- var i = Object.getOwnPropertyDescriptor(o, n);
84
- Object.defineProperty(t, n, i.get ? i : {
81
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(i).forEach(function(n) {
82
+ var o = Object.getOwnPropertyDescriptor(i, n);
83
+ Object.defineProperty(t, n, o.get ? o : {
85
84
  enumerable: !0,
86
85
  get: function() {
87
- return o[n];
86
+ return i[n];
88
87
  }
89
88
  });
90
89
  }), t;
91
90
  }
92
91
  var he = { exports: {} };
93
- function be(o) {
94
- throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
92
+ function be(i) {
93
+ throw new Error('Could not dynamically require "' + i + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
95
94
  }
96
95
  var se = { exports: {} };
97
- const Be = {}, ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
96
+ const ke = {}, Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
98
97
  __proto__: null,
99
- default: Be
100
- }, Symbol.toStringTag, { value: "Module" })), Ce = /* @__PURE__ */ _e(ke);
98
+ default: ke
99
+ }, Symbol.toStringTag, { value: "Module" })), Se = /* @__PURE__ */ _e(Oe);
101
100
  var ae;
102
- function le() {
103
- return ae || (ae = 1, function(o, e) {
101
+ function fe() {
102
+ return ae || (ae = 1, function(i, e) {
104
103
  (function(t, n) {
105
- o.exports = n();
106
- })(j, function() {
107
- var t = t || function(n, i) {
108
- var c;
109
- if (typeof window < "u" && window.crypto && (c = window.crypto), typeof self < "u" && self.crypto && (c = self.crypto), typeof globalThis < "u" && globalThis.crypto && (c = globalThis.crypto), !c && typeof window < "u" && window.msCrypto && (c = window.msCrypto), !c && typeof j < "u" && j.crypto && (c = j.crypto), !c && typeof be == "function")
104
+ i.exports = n();
105
+ })(J, function() {
106
+ var t = t || function(n, o) {
107
+ var a;
108
+ if (typeof window < "u" && window.crypto && (a = window.crypto), typeof self < "u" && self.crypto && (a = self.crypto), typeof globalThis < "u" && globalThis.crypto && (a = globalThis.crypto), !a && typeof window < "u" && window.msCrypto && (a = window.msCrypto), !a && typeof J < "u" && J.crypto && (a = J.crypto), !a && typeof be == "function")
110
109
  try {
111
- c = Ce;
110
+ a = Se;
112
111
  } catch {
113
112
  }
114
- var f = function() {
115
- if (c) {
116
- if (typeof c.getRandomValues == "function")
113
+ var d = function() {
114
+ if (a) {
115
+ if (typeof a.getRandomValues == "function")
117
116
  try {
118
- return c.getRandomValues(new Uint32Array(1))[0];
117
+ return a.getRandomValues(new Uint32Array(1))[0];
119
118
  } catch {
120
119
  }
121
- if (typeof c.randomBytes == "function")
120
+ if (typeof a.randomBytes == "function")
122
121
  try {
123
- return c.randomBytes(4).readInt32LE();
122
+ return a.randomBytes(4).readInt32LE();
124
123
  } catch {
125
124
  }
126
125
  }
127
126
  throw new Error("Native crypto module could not be used to get secure random number.");
128
- }, k = Object.create || function() {
127
+ }, O = Object.create || function() {
129
128
  function r() {
130
129
  }
131
130
  return function(s) {
132
- var u;
133
- return r.prototype = s, u = new r(), r.prototype = null, u;
131
+ var l;
132
+ return r.prototype = s, l = new r(), r.prototype = null, l;
134
133
  };
135
- }(), l = {}, w = l.lib = {}, m = w.Base = function() {
134
+ }(), f = {}, _ = f.lib = {}, w = _.Base = function() {
136
135
  return {
137
136
  /**
138
137
  * Creates a new object that inherits from this object.
@@ -153,7 +152,7 @@ function le() {
153
152
  * });
154
153
  */
155
154
  extend: function(r) {
156
- var s = k(this);
155
+ var s = O(this);
157
156
  return r && s.mixIn(r), (!s.hasOwnProperty("init") || this.init === s.init) && (s.init = function() {
158
157
  s.$super.init.apply(this, arguments);
159
158
  }), s.init.prototype = s, s.$super = this, s;
@@ -217,7 +216,7 @@ function le() {
217
216
  return this.init.prototype.extend(this);
218
217
  }
219
218
  };
220
- }(), g = w.WordArray = m.extend({
219
+ }(), v = _.WordArray = w.extend({
221
220
  /**
222
221
  * Initializes a newly created word array.
223
222
  *
@@ -231,7 +230,7 @@ function le() {
231
230
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
232
231
  */
233
232
  init: function(r, s) {
234
- r = this.words = r || [], s != i ? this.sigBytes = s : this.sigBytes = r.length * 4;
233
+ r = this.words = r || [], s != o ? this.sigBytes = s : this.sigBytes = r.length * 4;
235
234
  },
236
235
  /**
237
236
  * Converts this word array to a string.
@@ -261,16 +260,16 @@ function le() {
261
260
  * wordArray1.concat(wordArray2);
262
261
  */
263
262
  concat: function(r) {
264
- var s = this.words, u = r.words, d = this.sigBytes, _ = r.sigBytes;
265
- if (this.clamp(), d % 4)
266
- for (var b = 0; b < _; b++) {
267
- var S = u[b >>> 2] >>> 24 - b % 4 * 8 & 255;
268
- s[d + b >>> 2] |= S << 24 - (d + b) % 4 * 8;
263
+ var s = this.words, l = r.words, u = this.sigBytes, y = r.sigBytes;
264
+ if (this.clamp(), u % 4)
265
+ for (var b = 0; b < y; b++) {
266
+ var I = l[b >>> 2] >>> 24 - b % 4 * 8 & 255;
267
+ s[u + b >>> 2] |= I << 24 - (u + b) % 4 * 8;
269
268
  }
270
269
  else
271
- for (var x = 0; x < _; x += 4)
272
- s[d + x >>> 2] = u[x >>> 2];
273
- return this.sigBytes += _, this;
270
+ for (var x = 0; x < y; x += 4)
271
+ s[u + x >>> 2] = l[x >>> 2];
272
+ return this.sigBytes += y, this;
274
273
  },
275
274
  /**
276
275
  * Removes insignificant bits.
@@ -293,7 +292,7 @@ function le() {
293
292
  * var clone = wordArray.clone();
294
293
  */
295
294
  clone: function() {
296
- var r = m.clone.call(this);
295
+ var r = w.clone.call(this);
297
296
  return r.words = this.words.slice(0), r;
298
297
  },
299
298
  /**
@@ -310,11 +309,11 @@ function le() {
310
309
  * var wordArray = CryptoJS.lib.WordArray.random(16);
311
310
  */
312
311
  random: function(r) {
313
- for (var s = [], u = 0; u < r; u += 4)
314
- s.push(f());
315
- return new g.init(s, r);
312
+ for (var s = [], l = 0; l < r; l += 4)
313
+ s.push(d());
314
+ return new v.init(s, r);
316
315
  }
317
- }), B = l.enc = {}, h = B.Hex = {
316
+ }), k = f.enc = {}, h = k.Hex = {
318
317
  /**
319
318
  * Converts a word array to a hex string.
320
319
  *
@@ -329,11 +328,11 @@ function le() {
329
328
  * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
330
329
  */
331
330
  stringify: function(r) {
332
- for (var s = r.words, u = r.sigBytes, d = [], _ = 0; _ < u; _++) {
333
- var b = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
334
- d.push((b >>> 4).toString(16)), d.push((b & 15).toString(16));
331
+ for (var s = r.words, l = r.sigBytes, u = [], y = 0; y < l; y++) {
332
+ var b = s[y >>> 2] >>> 24 - y % 4 * 8 & 255;
333
+ u.push((b >>> 4).toString(16)), u.push((b & 15).toString(16));
335
334
  }
336
- return d.join("");
335
+ return u.join("");
337
336
  },
338
337
  /**
339
338
  * Converts a hex string to a word array.
@@ -349,11 +348,11 @@ function le() {
349
348
  * var wordArray = CryptoJS.enc.Hex.parse(hexString);
350
349
  */
351
350
  parse: function(r) {
352
- for (var s = r.length, u = [], d = 0; d < s; d += 2)
353
- u[d >>> 3] |= parseInt(r.substr(d, 2), 16) << 24 - d % 8 * 4;
354
- return new g.init(u, s / 2);
351
+ for (var s = r.length, l = [], u = 0; u < s; u += 2)
352
+ l[u >>> 3] |= parseInt(r.substr(u, 2), 16) << 24 - u % 8 * 4;
353
+ return new v.init(l, s / 2);
355
354
  }
356
- }, v = B.Latin1 = {
355
+ }, g = k.Latin1 = {
357
356
  /**
358
357
  * Converts a word array to a Latin1 string.
359
358
  *
@@ -368,11 +367,11 @@ function le() {
368
367
  * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
369
368
  */
370
369
  stringify: function(r) {
371
- for (var s = r.words, u = r.sigBytes, d = [], _ = 0; _ < u; _++) {
372
- var b = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
373
- d.push(String.fromCharCode(b));
370
+ for (var s = r.words, l = r.sigBytes, u = [], y = 0; y < l; y++) {
371
+ var b = s[y >>> 2] >>> 24 - y % 4 * 8 & 255;
372
+ u.push(String.fromCharCode(b));
374
373
  }
375
- return d.join("");
374
+ return u.join("");
376
375
  },
377
376
  /**
378
377
  * Converts a Latin1 string to a word array.
@@ -388,11 +387,11 @@ function le() {
388
387
  * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
389
388
  */
390
389
  parse: function(r) {
391
- for (var s = r.length, u = [], d = 0; d < s; d++)
392
- u[d >>> 2] |= (r.charCodeAt(d) & 255) << 24 - d % 4 * 8;
393
- return new g.init(u, s);
390
+ for (var s = r.length, l = [], u = 0; u < s; u++)
391
+ l[u >>> 2] |= (r.charCodeAt(u) & 255) << 24 - u % 4 * 8;
392
+ return new v.init(l, s);
394
393
  }
395
- }, a = B.Utf8 = {
394
+ }, c = k.Utf8 = {
396
395
  /**
397
396
  * Converts a word array to a UTF-8 string.
398
397
  *
@@ -408,7 +407,7 @@ function le() {
408
407
  */
409
408
  stringify: function(r) {
410
409
  try {
411
- return decodeURIComponent(escape(v.stringify(r)));
410
+ return decodeURIComponent(escape(g.stringify(r)));
412
411
  } catch {
413
412
  throw new Error("Malformed UTF-8 data");
414
413
  }
@@ -427,9 +426,9 @@ function le() {
427
426
  * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
428
427
  */
429
428
  parse: function(r) {
430
- return v.parse(unescape(encodeURIComponent(r)));
429
+ return g.parse(unescape(encodeURIComponent(r)));
431
430
  }
432
- }, p = w.BufferedBlockAlgorithm = m.extend({
431
+ }, p = _.BufferedBlockAlgorithm = w.extend({
433
432
  /**
434
433
  * Resets this block algorithm's data buffer to its initial state.
435
434
  *
@@ -438,7 +437,7 @@ function le() {
438
437
  * bufferedBlockAlgorithm.reset();
439
438
  */
440
439
  reset: function() {
441
- this._data = new g.init(), this._nDataBytes = 0;
440
+ this._data = new v.init(), this._nDataBytes = 0;
442
441
  },
443
442
  /**
444
443
  * Adds new data to this block algorithm's buffer.
@@ -451,7 +450,7 @@ function le() {
451
450
  * bufferedBlockAlgorithm._append(wordArray);
452
451
  */
453
452
  _append: function(r) {
454
- typeof r == "string" && (r = a.parse(r)), this._data.concat(r), this._nDataBytes += r.sigBytes;
453
+ typeof r == "string" && (r = c.parse(r)), this._data.concat(r), this._nDataBytes += r.sigBytes;
455
454
  },
456
455
  /**
457
456
  * Processes available data blocks.
@@ -468,15 +467,15 @@ function le() {
468
467
  * var processedData = bufferedBlockAlgorithm._process(!!'flush');
469
468
  */
470
469
  _process: function(r) {
471
- var s, u = this._data, d = u.words, _ = u.sigBytes, b = this.blockSize, S = b * 4, x = _ / S;
470
+ var s, l = this._data, u = l.words, y = l.sigBytes, b = this.blockSize, I = b * 4, x = y / I;
472
471
  r ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
473
- var D = x * b, U = n.min(D * 4, _);
474
- if (D) {
475
- for (var F = 0; F < D; F += b)
476
- this._doProcessBlock(d, F);
477
- s = d.splice(0, D), u.sigBytes -= U;
472
+ var W = x * b, $ = n.min(W * 4, y);
473
+ if (W) {
474
+ for (var L = 0; L < W; L += b)
475
+ this._doProcessBlock(u, L);
476
+ s = u.splice(0, W), l.sigBytes -= $;
478
477
  }
479
- return new g.init(s, U);
478
+ return new v.init(s, $);
480
479
  },
481
480
  /**
482
481
  * Creates a copy of this object.
@@ -488,16 +487,16 @@ function le() {
488
487
  * var clone = bufferedBlockAlgorithm.clone();
489
488
  */
490
489
  clone: function() {
491
- var r = m.clone.call(this);
490
+ var r = w.clone.call(this);
492
491
  return r._data = this._data.clone(), r;
493
492
  },
494
493
  _minBufferSize: 0
495
494
  });
496
- w.Hasher = p.extend({
495
+ _.Hasher = p.extend({
497
496
  /**
498
497
  * Configuration options.
499
498
  */
500
- cfg: m.extend(),
499
+ cfg: w.extend(),
501
500
  /**
502
501
  * Initializes a newly created hasher.
503
502
  *
@@ -569,8 +568,8 @@ function le() {
569
568
  * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
570
569
  */
571
570
  _createHelper: function(r) {
572
- return function(s, u) {
573
- return new r.init(u).finalize(s);
571
+ return function(s, l) {
572
+ return new r.init(l).finalize(s);
574
573
  };
575
574
  },
576
575
  /**
@@ -587,25 +586,25 @@ function le() {
587
586
  * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
588
587
  */
589
588
  _createHmacHelper: function(r) {
590
- return function(s, u) {
591
- return new C.HMAC.init(r, u).finalize(s);
589
+ return function(s, l) {
590
+ return new S.HMAC.init(r, l).finalize(s);
592
591
  };
593
592
  }
594
593
  });
595
- var C = l.algo = {};
596
- return l;
594
+ var S = f.algo = {};
595
+ return f;
597
596
  }(Math);
598
597
  return t;
599
598
  });
600
599
  }(se)), se.exports;
601
600
  }
602
- (function(o, e) {
601
+ (function(i, e) {
603
602
  (function(t, n) {
604
- o.exports = n(le());
605
- })(j, function(t) {
603
+ i.exports = n(fe());
604
+ })(J, function(t) {
606
605
  return function() {
607
- var n = t, i = n.lib, c = i.WordArray, f = n.enc;
608
- f.Base64url = {
606
+ var n = t, o = n.lib, a = o.WordArray, d = n.enc;
607
+ d.Base64url = {
609
608
  /**
610
609
  * Converts a word array to a Base64url string.
611
610
  *
@@ -621,17 +620,17 @@ function le() {
621
620
  *
622
621
  * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
623
622
  */
624
- stringify: function(l, w) {
625
- w === void 0 && (w = !0);
626
- var m = l.words, g = l.sigBytes, B = w ? this._safe_map : this._map;
627
- l.clamp();
628
- for (var h = [], v = 0; v < g; v += 3)
629
- for (var a = m[v >>> 2] >>> 24 - v % 4 * 8 & 255, p = m[v + 1 >>> 2] >>> 24 - (v + 1) % 4 * 8 & 255, C = m[v + 2 >>> 2] >>> 24 - (v + 2) % 4 * 8 & 255, r = a << 16 | p << 8 | C, s = 0; s < 4 && v + s * 0.75 < g; s++)
630
- h.push(B.charAt(r >>> 6 * (3 - s) & 63));
631
- var u = B.charAt(64);
632
- if (u)
623
+ stringify: function(f, _) {
624
+ _ === void 0 && (_ = !0);
625
+ var w = f.words, v = f.sigBytes, k = _ ? this._safe_map : this._map;
626
+ f.clamp();
627
+ for (var h = [], g = 0; g < v; g += 3)
628
+ for (var c = w[g >>> 2] >>> 24 - g % 4 * 8 & 255, p = w[g + 1 >>> 2] >>> 24 - (g + 1) % 4 * 8 & 255, S = w[g + 2 >>> 2] >>> 24 - (g + 2) % 4 * 8 & 255, r = c << 16 | p << 8 | S, s = 0; s < 4 && g + s * 0.75 < v; s++)
629
+ h.push(k.charAt(r >>> 6 * (3 - s) & 63));
630
+ var l = k.charAt(64);
631
+ if (l)
633
632
  for (; h.length % 4; )
634
- h.push(u);
633
+ h.push(l);
635
634
  return h.join("");
636
635
  },
637
636
  /**
@@ -649,212 +648,201 @@ function le() {
649
648
  *
650
649
  * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
651
650
  */
652
- parse: function(l, w) {
653
- w === void 0 && (w = !0);
654
- var m = l.length, g = w ? this._safe_map : this._map, B = this._reverseMap;
655
- if (!B) {
656
- B = this._reverseMap = [];
657
- for (var h = 0; h < g.length; h++)
658
- B[g.charCodeAt(h)] = h;
651
+ parse: function(f, _) {
652
+ _ === void 0 && (_ = !0);
653
+ var w = f.length, v = _ ? this._safe_map : this._map, k = this._reverseMap;
654
+ if (!k) {
655
+ k = this._reverseMap = [];
656
+ for (var h = 0; h < v.length; h++)
657
+ k[v.charCodeAt(h)] = h;
659
658
  }
660
- var v = g.charAt(64);
661
- if (v) {
662
- var a = l.indexOf(v);
663
- a !== -1 && (m = a);
659
+ var g = v.charAt(64);
660
+ if (g) {
661
+ var c = f.indexOf(g);
662
+ c !== -1 && (w = c);
664
663
  }
665
- return k(l, m, B);
664
+ return O(f, w, k);
666
665
  },
667
666
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
668
667
  _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
669
668
  };
670
- function k(l, w, m) {
671
- for (var g = [], B = 0, h = 0; h < w; h++)
669
+ function O(f, _, w) {
670
+ for (var v = [], k = 0, h = 0; h < _; h++)
672
671
  if (h % 4) {
673
- var v = m[l.charCodeAt(h - 1)] << h % 4 * 2, a = m[l.charCodeAt(h)] >>> 6 - h % 4 * 2, p = v | a;
674
- g[B >>> 2] |= p << 24 - B % 4 * 8, B++;
672
+ var g = w[f.charCodeAt(h - 1)] << h % 4 * 2, c = w[f.charCodeAt(h)] >>> 6 - h % 4 * 2, p = g | c;
673
+ v[k >>> 2] |= p << 24 - k % 4 * 8, k++;
675
674
  }
676
- return c.create(g, B);
675
+ return a.create(v, k);
677
676
  }
678
677
  }(), t.enc.Base64url;
679
678
  });
680
679
  })(he);
681
- var Se = he.exports;
682
- const xe = /* @__PURE__ */ fe(Se);
680
+ var Ie = he.exports;
681
+ const xe = /* @__PURE__ */ de(Ie);
683
682
  var pe = { exports: {} };
684
- (function(o, e) {
683
+ (function(i, e) {
685
684
  (function(t, n) {
686
- o.exports = n(le());
687
- })(j, function(t) {
685
+ i.exports = n(fe());
686
+ })(J, function(t) {
688
687
  return function(n) {
689
- var i = t, c = i.lib, f = c.WordArray, k = c.Hasher, l = i.algo, w = [], m = [];
688
+ var o = t, a = o.lib, d = a.WordArray, O = a.Hasher, f = o.algo, _ = [], w = [];
690
689
  (function() {
691
- function h(C) {
692
- for (var r = n.sqrt(C), s = 2; s <= r; s++)
693
- if (!(C % s))
690
+ function h(S) {
691
+ for (var r = n.sqrt(S), s = 2; s <= r; s++)
692
+ if (!(S % s))
694
693
  return !1;
695
694
  return !0;
696
695
  }
697
- function v(C) {
698
- return (C - (C | 0)) * 4294967296 | 0;
696
+ function g(S) {
697
+ return (S - (S | 0)) * 4294967296 | 0;
699
698
  }
700
- for (var a = 2, p = 0; p < 64; )
701
- h(a) && (p < 8 && (w[p] = v(n.pow(a, 1 / 2))), m[p] = v(n.pow(a, 1 / 3)), p++), a++;
699
+ for (var c = 2, p = 0; p < 64; )
700
+ h(c) && (p < 8 && (_[p] = g(n.pow(c, 1 / 2))), w[p] = g(n.pow(c, 1 / 3)), p++), c++;
702
701
  })();
703
- var g = [], B = l.SHA256 = k.extend({
702
+ var v = [], k = f.SHA256 = O.extend({
704
703
  _doReset: function() {
705
- this._hash = new f.init(w.slice(0));
704
+ this._hash = new d.init(_.slice(0));
706
705
  },
707
- _doProcessBlock: function(h, v) {
708
- for (var a = this._hash.words, p = a[0], C = a[1], r = a[2], s = a[3], u = a[4], d = a[5], _ = a[6], b = a[7], S = 0; S < 64; S++) {
709
- if (S < 16)
710
- g[S] = h[v + S] | 0;
706
+ _doProcessBlock: function(h, g) {
707
+ for (var c = this._hash.words, p = c[0], S = c[1], r = c[2], s = c[3], l = c[4], u = c[5], y = c[6], b = c[7], I = 0; I < 64; I++) {
708
+ if (I < 16)
709
+ v[I] = h[g + I] | 0;
711
710
  else {
712
- var x = g[S - 15], D = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, U = g[S - 2], F = (U << 15 | U >>> 17) ^ (U << 13 | U >>> 19) ^ U >>> 10;
713
- g[S] = D + g[S - 7] + F + g[S - 16];
711
+ var x = v[I - 15], W = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, $ = v[I - 2], L = ($ << 15 | $ >>> 17) ^ ($ << 13 | $ >>> 19) ^ $ >>> 10;
712
+ v[I] = W + v[I - 7] + L + v[I - 16];
714
713
  }
715
- var ee = u & d ^ ~u & _, A = p & C ^ p & r ^ C & r, R = (p << 30 | p >>> 2) ^ (p << 19 | p >>> 13) ^ (p << 10 | p >>> 22), M = (u << 26 | u >>> 6) ^ (u << 21 | u >>> 11) ^ (u << 7 | u >>> 25), q = b + M + ee + m[S] + g[S], V = R + A;
716
- b = _, _ = d, d = u, u = s + q | 0, s = r, r = C, C = p, p = q + V | 0;
714
+ var ee = l & u ^ ~l & y, A = p & S ^ p & r ^ S & r, M = (p << 30 | p >>> 2) ^ (p << 19 | p >>> 13) ^ (p << 10 | p >>> 22), U = (l << 26 | l >>> 6) ^ (l << 21 | l >>> 11) ^ (l << 7 | l >>> 25), H = b + U + ee + w[I] + v[I], V = M + A;
715
+ b = y, y = u, u = l, l = s + H | 0, s = r, r = S, S = p, p = H + V | 0;
717
716
  }
718
- a[0] = a[0] + p | 0, a[1] = a[1] + C | 0, a[2] = a[2] + r | 0, a[3] = a[3] + s | 0, a[4] = a[4] + u | 0, a[5] = a[5] + d | 0, a[6] = a[6] + _ | 0, a[7] = a[7] + b | 0;
717
+ c[0] = c[0] + p | 0, c[1] = c[1] + S | 0, c[2] = c[2] + r | 0, c[3] = c[3] + s | 0, c[4] = c[4] + l | 0, c[5] = c[5] + u | 0, c[6] = c[6] + y | 0, c[7] = c[7] + b | 0;
719
718
  },
720
719
  _doFinalize: function() {
721
- var h = this._data, v = h.words, a = this._nDataBytes * 8, p = h.sigBytes * 8;
722
- return v[p >>> 5] |= 128 << 24 - p % 32, v[(p + 64 >>> 9 << 4) + 14] = n.floor(a / 4294967296), v[(p + 64 >>> 9 << 4) + 15] = a, h.sigBytes = v.length * 4, this._process(), this._hash;
720
+ var h = this._data, g = h.words, c = this._nDataBytes * 8, p = h.sigBytes * 8;
721
+ return g[p >>> 5] |= 128 << 24 - p % 32, g[(p + 64 >>> 9 << 4) + 14] = n.floor(c / 4294967296), g[(p + 64 >>> 9 << 4) + 15] = c, h.sigBytes = g.length * 4, this._process(), this._hash;
723
722
  },
724
723
  clone: function() {
725
- var h = k.clone.call(this);
724
+ var h = O.clone.call(this);
726
725
  return h._hash = this._hash.clone(), h;
727
726
  }
728
727
  });
729
- i.SHA256 = k._createHelper(B), i.HmacSHA256 = k._createHmacHelper(B);
728
+ o.SHA256 = O._createHelper(k), o.HmacSHA256 = O._createHmacHelper(k);
730
729
  }(Math), t.SHA256;
731
730
  });
732
731
  })(pe);
733
732
  var Ae = pe.exports;
734
- const Ee = /* @__PURE__ */ fe(Ae), Ie = (o, e) => {
733
+ const Be = /* @__PURE__ */ de(Ae), Ee = (i, e) => {
735
734
  const {
736
735
  client_id: t,
737
736
  redirect_uri: n,
738
- scope: i,
739
- state: c,
740
- chainId: f,
741
- chain: k,
742
- network: l,
743
- address: w,
744
- signature: m
745
- } = o, g = w ? {
746
- address: w,
747
- ...m !== void 0 ? { signature: m } : {},
748
- ...f !== void 0 || k !== void 0 ? { chain: f ? ye(f) : k } : {},
749
- ...f !== void 0 || l !== void 0 ? { network: f ? me(f) : l } : {}
737
+ scope: o,
738
+ state: a,
739
+ chainId: d,
740
+ chain: O,
741
+ network: f,
742
+ address: _,
743
+ signature: w
744
+ } = i, v = _ ? {
745
+ address: _,
746
+ ...w !== void 0 ? { signature: w } : {},
747
+ ...d !== void 0 || O !== void 0 ? { chain: d ? ye(d) : O } : {},
748
+ ...d !== void 0 || f !== void 0 ? { network: d ? me(d) : f } : {}
750
749
  } : {};
751
750
  return Z({
752
751
  client_id: t,
753
752
  redirect_uri: n,
754
- ...i !== void 0 ? { scope: i } : {},
755
- ...c !== void 0 ? { state: c } : {},
753
+ ...o !== void 0 ? { scope: o } : {},
754
+ ...a !== void 0 ? { state: a } : {},
756
755
  code_challenge: e,
757
756
  code_challenge_method: "S256",
758
757
  response_type: "code",
759
- ...g
758
+ ...v
760
759
  });
761
- }, Pe = () => {
762
- let o = "";
760
+ }, Me = () => {
761
+ let i = "";
763
762
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = e.length;
764
763
  let n = 0;
765
764
  for (; n < 128; )
766
- o += e.charAt(Math.floor(Math.random() * t)), n += 1;
767
- return o;
768
- }, Oe = (o) => xe.stringify(Ee(o)), ce = (o, e) => {
769
- const t = Pe(), n = Oe(t);
770
- return sessionStorage.setItem(N, t || ""), `${o}/auth?${Ie(e, n)}`;
771
- }, Re = () => {
772
- const o = window.location.href, [e, t] = o.split("?");
765
+ i += e.charAt(Math.floor(Math.random() * t)), n += 1;
766
+ return i;
767
+ }, Pe = (i) => xe.stringify(Be(i)), ce = (i, e) => {
768
+ const t = Me(), n = Pe(t);
769
+ return sessionStorage.setItem(N, t || ""), `${i}/auth?${Ee(e, n)}`;
770
+ }, ze = () => {
771
+ const i = window.location.href, [e, t] = i.split("?");
773
772
  t && window.history.replaceState(null, "", e);
774
- }, ue = (o) => o.code != null, ze = (o) => o.refresh_token != null, Te = (o) => o.client_secret != null, $e = async (o, e, t, n) => {
775
- const i = await fetch(`${o}`, {
773
+ }, le = (i) => i.code != null, Te = (i) => i.refresh_token != null, $e = (i) => i.client_secret != null, Ce = async (i, e, t, n) => {
774
+ const o = await fetch(`${i}`, {
776
775
  method: e,
777
776
  headers: n,
778
777
  body: t
779
778
  });
780
- let c;
781
- const f = await i.text();
779
+ let a;
780
+ const d = await o.text();
782
781
  try {
783
- c = JSON.parse(f);
782
+ a = JSON.parse(d);
784
783
  } catch {
785
- throw f;
784
+ throw d;
786
785
  }
787
- if (!i.ok)
788
- throw c;
789
- return c;
786
+ if (!o.ok)
787
+ throw a;
788
+ return a;
790
789
  }, ie = typeof window > "u";
791
- var T, G, W, L, $, E, O, J, K, Q;
792
- class Ue {
790
+ var j, X, F, D, C, B, E, K, Q, Y;
791
+ class je {
793
792
  constructor(e) {
794
- // -- Helper Methods
795
- H(this, E);
796
- H(this, T, void 0);
797
- H(this, G, void 0);
798
- /** The socket will be available after subscribing to an event */
799
- H(this, W, void 0);
800
- H(this, L, void 0);
801
- H(this, $, void 0);
802
- H(this, J, void 0);
803
- H(this, K, void 0);
804
- H(this, Q, void 0);
805
- if (I(this, L, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, J, async (t, n, i) => {
806
- const c = sessionStorage.getItem(N) || "";
807
- if (!c)
793
+ if (R(this, B), R(this, j, void 0), R(this, X, void 0), R(this, F, void 0), R(this, D, void 0), R(this, C, void 0), R(this, K, void 0), R(this, Q, void 0), R(this, Y, void 0), P(this, D, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, P(this, K, async (t, n, o) => {
794
+ const a = sessionStorage.getItem(N) || "";
795
+ if (!a)
808
796
  throw new Error("Code verifier not found");
809
- return this.codeVerifier = c, sessionStorage.removeItem(N), await this.getBearerToken({
810
- code: i,
797
+ return this.codeVerifier = a, sessionStorage.removeItem(N), await this.getBearerToken({
798
+ code: o,
811
799
  redirect_uri: n,
812
800
  client_id: t,
813
- code_verifier: c
801
+ code_verifier: a
814
802
  });
815
- }), I(this, K, async ({
803
+ }), P(this, Q, async ({
816
804
  clientId: t,
817
805
  clientSecret: n
818
806
  }) => await this.getBearerToken({
819
807
  client_id: t,
820
808
  client_secret: n
821
- })), I(this, Q, async (t, n) => await this.getBearerToken({
809
+ })), P(this, Y, async (t, n) => await this.getBearerToken({
822
810
  refresh_token: n,
823
811
  client_id: t
824
812
  })), this.subscribeToOrderNotifications = () => {
825
- var i, c;
826
- const t = `${y(this, T).wss}/profiles/${(i = this.bearerProfile) == null ? void 0 : i.profile}/orders?access_token=${(c = this.bearerProfile) == null ? void 0 : c.access_token}`, n = new WebSocket(t);
827
- return n.addEventListener("open", () => {
828
- console.info(`Socket connected: ${t}`);
829
- }), n.addEventListener("error", (f) => {
830
- throw console.error(f), new Error(`Socket error: ${t}`);
831
- }), n.addEventListener("message", (f) => {
832
- var l;
833
- const k = JSON.parse(f.data);
834
- (l = y(this, L).get(k.meta.state)) == null || l(
835
- k
813
+ var t, n;
814
+ const o = `${m(this, j).wss}/profiles/${(t = this.bearerProfile) == null ? void 0 : t.profile}/orders?access_token=${(n = this.bearerProfile) == null ? void 0 : n.access_token}`, a = new WebSocket(o);
815
+ return a.addEventListener("open", () => {
816
+ console.info(`Socket connected: ${o}`);
817
+ }), a.addEventListener("error", (d) => {
818
+ throw console.error(d), new Error(`Socket error: ${o}`);
819
+ }), a.addEventListener("message", (d) => {
820
+ var O;
821
+ const f = JSON.parse(d.data);
822
+ (O = m(this, D).get(f.meta.state)) == null || O(
823
+ f
836
824
  );
837
- }), n.addEventListener("close", () => {
838
- console.info(`Socket connection closed: ${t}`);
839
- }), n;
825
+ }), a.addEventListener("close", () => {
826
+ console.info(`Socket connection closed: ${o}`);
827
+ }), a;
840
828
  }, this.auth = async (t) => await this.getBearerToken(t), this.getAuthFlowURI = (t) => {
841
- const n = ce(y(this, T).api, t);
829
+ const n = ce(m(this, j).api, t);
842
830
  return this.codeVerifier = sessionStorage.getItem(N), n;
843
- }, this.pkceRequest = (t) => this.getAuthFlowURI(t), this.getEnvironment = () => y(this, T), !e) {
844
- I(this, T, ne.environments.sandbox);
831
+ }, this.pkceRequest = (t) => this.getAuthFlowURI(t), this.getEnvironment = () => m(this, j), !e) {
832
+ P(this, j, re.environments.sandbox);
845
833
  return;
846
834
  }
847
835
  if (typeof e == "string")
848
- I(this, T, ne.environments[e]);
849
- else if (I(this, T, ne.environments[e.environment || "sandbox"]), ie) {
836
+ P(this, j, re.environments[e]);
837
+ else if (P(this, j, re.environments[e.environment || "sandbox"]), ie) {
850
838
  const { clientId: t, clientSecret: n } = e;
851
- I(this, $, {
839
+ P(this, C, {
852
840
  clientId: t,
853
841
  clientSecret: n
854
842
  });
855
843
  } else {
856
844
  const { clientId: t, redirectUrl: n } = e;
857
- I(this, $, {
845
+ P(this, C, {
858
846
  clientId: t,
859
847
  redirectUrl: n
860
848
  });
@@ -868,66 +856,66 @@ class Ue {
868
856
  * {@link https://monerium.dev/api-docs#operation/auth}
869
857
  */
870
858
  async authorize(e) {
871
- var c, f;
872
- const t = (e == null ? void 0 : e.clientId) || ((c = y(this, $)) == null ? void 0 : c.clientId), n = (e == null ? void 0 : e.redirectUrl) || ((f = y(this, $)) == null ? void 0 : f.redirectUrl);
873
- if (!t)
859
+ var t, n;
860
+ const o = (e == null ? void 0 : e.clientId) || ((t = m(this, C)) == null ? void 0 : t.clientId), a = (e == null ? void 0 : e.redirectUrl) || ((n = m(this, C)) == null ? void 0 : n.redirectUrl);
861
+ if (!o)
874
862
  throw new Error("Missing ClientId");
875
- if (!n)
863
+ if (!a)
876
864
  throw new Error("Missing RedirectUrl");
877
- const i = ce(y(this, T).api, {
878
- client_id: t,
879
- redirect_uri: n,
865
+ const d = ce(m(this, j).api, {
866
+ client_id: o,
867
+ redirect_uri: a,
880
868
  address: e == null ? void 0 : e.address,
881
869
  signature: e == null ? void 0 : e.signature,
882
870
  chainId: e == null ? void 0 : e.chainId
883
871
  });
884
- window.location.replace(i);
872
+ window.location.replace(d);
885
873
  }
886
874
  async connect(e) {
887
- var k, l, w;
888
- const t = (e == null ? void 0 : e.clientId) || ((k = y(this, $)) == null ? void 0 : k.clientId);
889
- if ((e == null ? void 0 : e.clientSecret) || ((l = y(this, $)) == null ? void 0 : l.clientSecret)) {
875
+ var t, n, o;
876
+ const a = (e == null ? void 0 : e.clientId) || ((t = m(this, C)) == null ? void 0 : t.clientId);
877
+ if (e != null && e.clientSecret || (n = m(this, C)) != null && n.clientSecret) {
890
878
  if (!ie)
891
879
  throw new Error("Only use client credentials on server side");
892
- return await y(this, K).call(this, y(this, $)), !!this.bearerProfile;
880
+ return await m(this, Q).call(this, m(this, C)), !!this.bearerProfile;
893
881
  }
894
- const i = (e == null ? void 0 : e.redirectUrl) || ((w = y(this, $)) == null ? void 0 : w.redirectUrl);
895
- if (!t)
882
+ const d = (e == null ? void 0 : e.redirectUrl) || ((o = m(this, C)) == null ? void 0 : o.redirectUrl);
883
+ if (!a)
896
884
  throw new Error("Missing ClientId");
897
885
  if (ie)
898
886
  throw new Error("This only works on client side");
899
- const c = new URLSearchParams(window.location.search).get("code") || void 0, f = sessionStorage.getItem(oe) || void 0;
900
- return c ? await y(this, J).call(this, t, i, c) : f && await y(this, Q).call(this, t, f), !!this.bearerProfile;
887
+ const O = new URLSearchParams(window.location.search).get("code") || void 0, f = sessionStorage.getItem(ne) || void 0;
888
+ return O ? await m(this, K).call(this, a, d, O) : f && await m(this, Y).call(this, a, f), !!this.bearerProfile;
901
889
  }
902
890
  /**
903
891
  * {@link https://monerium.dev/api-docs#operation/auth-token}
904
892
  */
905
893
  async getBearerToken(e) {
906
894
  let t;
907
- if (ue(e))
895
+ if (le(e))
908
896
  t = { ...e, grant_type: "authorization_code" };
909
- else if (ze(e))
910
- t = { ...e, grant_type: "refresh_token" };
911
897
  else if (Te(e))
898
+ t = { ...e, grant_type: "refresh_token" };
899
+ else if ($e(e))
912
900
  t = { ...e, grant_type: "client_credentials" };
913
901
  else
914
902
  throw new Error("Authentication method could not be detected.");
915
- return await P(this, E, O).call(this, "post", "auth/token", t, !0).then((n) => {
916
- var i;
917
- this.bearerProfile = n, this.isAuthorized = !!n, I(this, G, `Bearer ${n == null ? void 0 : n.access_token}`), window.sessionStorage.setItem(
918
- oe,
919
- ((i = this.bearerProfile) == null ? void 0 : i.refresh_token) || ""
903
+ return await z(this, B, E).call(this, "post", "auth/token", t, !0).then((n) => {
904
+ var o;
905
+ this.bearerProfile = n, this.isAuthorized = !!n, P(this, X, `Bearer ${n == null ? void 0 : n.access_token}`), window.sessionStorage.setItem(
906
+ ne,
907
+ ((o = this.bearerProfile) == null ? void 0 : o.refresh_token) || ""
920
908
  );
921
909
  }).catch((n) => {
922
- throw sessionStorage.removeItem(N), sessionStorage.removeItem(oe), new Error(n == null ? void 0 : n.message);
923
- }), ue(e) && Re(), this.bearerProfile;
910
+ throw sessionStorage.removeItem(N), sessionStorage.removeItem(ne), new Error(n == null ? void 0 : n.message);
911
+ }), le(e) && ze(), this.bearerProfile;
924
912
  }
925
913
  // -- Read Methods
926
914
  /**
927
915
  * {@link https://monerium.dev/api-docs#operation/auth-context}
928
916
  */
929
917
  getAuthContext() {
930
- return P(this, E, O).call(this, "get", "auth/context");
918
+ return z(this, B, E).call(this, "get", "auth/context");
931
919
  }
932
920
  /**
933
921
  * {@link https://monerium.dev/api-docs#operation/profile}
@@ -935,47 +923,47 @@ class Ue {
935
923
 
936
924
  */
937
925
  getProfile(e) {
938
- return P(this, E, O).call(this, "get", `profiles/${e}`);
926
+ return z(this, B, E).call(this, "get", `profiles/${e}`);
939
927
  }
940
928
  /**
941
929
  * {@link https://monerium.dev/api-docs#operation/profile-balances}
942
930
  * @param {string=} profileId - the id of the profile to fetch balances.
943
931
  */
944
932
  getBalances(e) {
945
- return e ? P(this, E, O).call(this, "get", `profiles/${e}/balances`) : P(this, E, O).call(this, "get", "balances");
933
+ return e ? z(this, B, E).call(this, "get", `profiles/${e}/balances`) : z(this, B, E).call(this, "get", "balances");
946
934
  }
947
935
  /**
948
936
  * {@link https://monerium.dev/api-docs#operation/orders}
949
937
  */
950
938
  getOrders(e) {
951
939
  const t = Z(e);
952
- return P(this, E, O).call(this, "get", `orders?${t}`);
940
+ return z(this, B, E).call(this, "get", `orders?${t}`);
953
941
  }
954
942
  /**
955
943
  * {@link https://monerium.dev/api-docs#operation/order}
956
944
  */
957
945
  getOrder(e) {
958
- return P(this, E, O).call(this, "get", `orders/${e}`);
946
+ return z(this, B, E).call(this, "get", `orders/${e}`);
959
947
  }
960
948
  /**
961
949
  * {@link https://monerium.dev/api-docs#operation/tokens}
962
950
  */
963
951
  getTokens() {
964
- return P(this, E, O).call(this, "get", "tokens");
952
+ return z(this, B, E).call(this, "get", "tokens");
965
953
  }
966
954
  // -- Write Methods
967
955
  /**
968
956
  * {@link https://monerium.dev/api-docs#operation/profile-addresses}
969
957
  */
970
958
  linkAddress(e, t) {
971
- return P(this, E, O).call(this, "post", `profiles/${e}/addresses`, JSON.stringify(t));
959
+ return z(this, B, E).call(this, "post", `profiles/${e}/addresses`, JSON.stringify(t));
972
960
  }
973
961
  /**
974
962
  * {@link https://monerium.dev/api-docs#operation/post-orders}
975
963
  */
976
964
  placeOrder(e, t) {
977
965
  const n = { ...e, kind: "redeem", currency: "eur" };
978
- return t ? P(this, E, O).call(this, "post", `profiles/${t}/orders`, JSON.stringify(n)) : P(this, E, O).call(this, "post", "orders", JSON.stringify(n));
966
+ return t ? z(this, B, E).call(this, "post", `profiles/${t}/orders`, JSON.stringify(n)) : z(this, B, E).call(this, "post", "orders", JSON.stringify(n));
979
967
  }
980
968
  /**
981
969
  * {@link https://monerium.dev/api-docs#operation/supporting-document}
@@ -984,16 +972,16 @@ class Ue {
984
972
  const t = Z(
985
973
  e
986
974
  );
987
- return P(this, E, O).call(this, "post", "files/supporting-document", t, !0);
975
+ return z(this, B, E).call(this, "post", "files/supporting-document", t, !0);
988
976
  }
989
977
  // -- Notifications
990
978
  async connectOrderSocket() {
991
979
  var e;
992
- (e = this.bearerProfile) != null && e.access_token && y(this, L).size > 0 && I(this, W, this.subscribeToOrderNotifications());
980
+ (e = this.bearerProfile) != null && e.access_token && m(this, D).size > 0 && P(this, F, this.subscribeToOrderNotifications());
993
981
  }
994
982
  async disconnect() {
995
983
  var e;
996
- sessionStorage.removeItem(N), y(this, L).clear(), (e = y(this, W)) == null || e.close();
984
+ sessionStorage.removeItem(N), m(this, D).clear(), (e = m(this, F)) == null || e.close();
997
985
  }
998
986
  /**
999
987
  * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
@@ -1003,7 +991,7 @@ class Ue {
1003
991
  * @param handler The handler to be called when the event is triggered
1004
992
  */
1005
993
  subscribeOrders(e, t) {
1006
- y(this, L).set(e, t);
994
+ m(this, D).set(e, t);
1007
995
  }
1008
996
  /**
1009
997
  * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
@@ -1011,134 +999,134 @@ class Ue {
1011
999
  */
1012
1000
  unsubscribeOrders(e) {
1013
1001
  var t;
1014
- y(this, L).delete(e), y(this, L).size === 0 && ((t = y(this, W)) == null || t.close(), I(this, W, void 0));
1002
+ m(this, D).delete(e), m(this, D).size === 0 && ((t = m(this, F)) == null || t.close(), P(this, F, void 0));
1015
1003
  }
1016
1004
  }
1017
- T = new WeakMap(), G = new WeakMap(), W = new WeakMap(), L = new WeakMap(), $ = new WeakMap(), E = new WeakSet(), O = async function(e, t, n, i) {
1018
- return $e(
1019
- `${y(this, T).api}/${t}`,
1020
- e,
1021
- i ? Z(n) : n,
1005
+ j = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakSet(), E = async function(i, e, t, n) {
1006
+ return Ce(
1007
+ `${m(this, j).api}/${e}`,
1008
+ i,
1009
+ n ? Z(t) : t,
1022
1010
  {
1023
- Authorization: y(this, G) || "",
1024
- "Content-Type": `application/${i ? "x-www-form-urlencoded" : "json"}`
1011
+ Authorization: m(this, X) || "",
1012
+ "Content-Type": `application/${n ? "x-www-form-urlencoded" : "json"}`
1025
1013
  }
1026
1014
  );
1027
- }, J = new WeakMap(), K = new WeakMap(), Q = new WeakMap();
1015
+ }, K = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap();
1028
1016
  const De = ({
1029
- children: o,
1017
+ children: i,
1030
1018
  clientId: e = "f99e629b-6dca-11ee-8aa6-5273f65ed05b",
1031
1019
  redirectUrl: t = "http://localhost:5173",
1032
1020
  environment: n = "sandbox"
1033
1021
  }) => {
1034
- const [i, c] = z(), [f, k] = z(!1), [l, w] = z(null), [m, g] = z(null), [B, h] = z(!1), [v, a] = z(!1), [p, C] = z(!1), [r, s] = z(!1), [u, d] = z(null), [_, b] = z([]), [S, x] = z([]);
1035
- re(() => {
1036
- const A = new Ue({
1022
+ const [o, a] = T(), [d, O] = T(!1), [f, _] = T(null), [w, v] = T(null), [k, h] = T(!1), [g, c] = T(!1), [p, S] = T(!1), [r, s] = T(!1), [l, u] = T(null), [y, b] = T([]), [I, x] = T([]);
1023
+ te(() => {
1024
+ const A = new je({
1037
1025
  environment: n,
1038
1026
  clientId: e,
1039
1027
  redirectUrl: t
1040
1028
  });
1041
- c(A);
1042
- }, []), re(() => ((async () => {
1043
- i && k(await i.connect());
1029
+ a(A);
1030
+ }, []), te(() => ((async () => {
1031
+ o && O(await o.getAccess());
1044
1032
  })(), () => {
1045
- i && i.disconnect();
1046
- }), [i]), re(() => {
1033
+ o && o.disconnect();
1034
+ }), [o]), te(() => {
1047
1035
  (async () => {
1048
- if (i && f)
1036
+ if (o && d)
1049
1037
  try {
1050
1038
  h(!0);
1051
- const R = await i.getAuthContext(), M = await i.getProfile(R.defaultProfile), q = await i.getBalances(), V = await i.getOrders(), X = await i.getTokens();
1052
- w(M), g(q), b(V), x(X);
1053
- } catch (R) {
1054
- console.error("Error fetching data:", R), d(R);
1039
+ const M = await o.getAuthContext(), U = await o.getProfile(M.defaultProfile), H = await o.getBalances(), V = await o.getOrders(), q = await o.getTokens();
1040
+ _(U), v(H), b(V), x(q);
1041
+ } catch (M) {
1042
+ console.error("Error fetching data:", M), u(M);
1055
1043
  } finally {
1056
1044
  h(!1);
1057
1045
  }
1058
1046
  })();
1059
- }, [i, f]);
1060
- const D = Y(async () => {
1047
+ }, [o, d]);
1048
+ const W = G(async () => {
1061
1049
  try {
1062
- i && await i.authorize();
1050
+ o && await o.authorize();
1063
1051
  } catch (A) {
1064
- console.error("Error during authorization:", A), d(A);
1052
+ console.error("Error during authorization:", A), u(A);
1065
1053
  }
1066
- }, [i]), U = Y(async () => {
1067
- if (i && f)
1054
+ }, [o]), $ = G(async () => {
1055
+ if (o && d)
1068
1056
  try {
1069
1057
  s(!0);
1070
- const A = await i.getBalances();
1071
- g(A);
1058
+ const A = await o.getBalances();
1059
+ v(A);
1072
1060
  } catch (A) {
1073
- console.error("Error getting balances:", A), d(A);
1061
+ console.error("Error getting balances:", A), u(A);
1074
1062
  } finally {
1075
1063
  s(!1);
1076
1064
  }
1077
- }, [i, f]), F = Y(
1078
- async (A, R) => {
1079
- if (i && f)
1065
+ }, [o, d]), L = G(
1066
+ async (A, M) => {
1067
+ if (o && d)
1080
1068
  try {
1081
- a(!0);
1082
- let M;
1083
- parseInt(A.amount) > 15e3 && R && (M = (await i.uploadSupportingDocument(
1084
- R
1069
+ c(!0);
1070
+ let U;
1071
+ parseInt(A.amount) > 15e3 && M && (U = (await o.uploadSupportingDocument(
1072
+ M
1085
1073
  )).id);
1086
- const q = {
1074
+ const H = {
1087
1075
  ...A,
1088
- documentId: M
1089
- }, V = await i.placeOrder(q);
1090
- b((X) => [...X, V]);
1091
- } catch (M) {
1092
- console.error("Error placing order:", M), d(M);
1076
+ documentId: U
1077
+ }, V = await o.placeOrder(H);
1078
+ b((q) => [...q, V]);
1079
+ } catch (U) {
1080
+ console.error("Error placing order:", U), u(U);
1093
1081
  } finally {
1094
- a(!1);
1082
+ c(!1);
1095
1083
  }
1096
1084
  },
1097
- [i, f]
1098
- ), ee = Y(
1085
+ [o, d]
1086
+ ), ee = G(
1099
1087
  async (A) => {
1100
- if (i && f && l)
1088
+ if (o && d && f)
1101
1089
  try {
1102
- return C(!0), await i.linkAddress(l.id, A);
1103
- } catch (R) {
1104
- console.error("Error linking address:", R), d(R);
1090
+ return S(!0), await o.linkAddress(f.id, A);
1091
+ } catch (M) {
1092
+ console.error("Error linking address:", M), u(M);
1105
1093
  } finally {
1106
- C(!1);
1094
+ S(!1);
1107
1095
  }
1108
1096
  },
1109
- [i, f, l]
1097
+ [o, d, f]
1110
1098
  );
1111
- return /* @__PURE__ */ ve(
1112
- de.Provider,
1099
+ return /* @__PURE__ */ ge(
1100
+ ue.Provider,
1113
1101
  {
1114
1102
  value: {
1115
- authorize: D,
1116
- isAuthorized: f,
1117
- profile: l,
1118
- balances: m,
1119
- loading: B,
1120
- loadingPlaceOrder: v,
1103
+ authorize: W,
1104
+ isAuthorized: d,
1105
+ profile: f,
1106
+ balances: w,
1107
+ loading: k,
1108
+ loadingPlaceOrder: g,
1121
1109
  loadingLinkAddress: p,
1122
1110
  loadingBalances: r,
1123
- getBalances: U,
1111
+ getBalances: $,
1124
1112
  linkAddress: ee,
1125
- placeOrder: F,
1126
- orders: _,
1127
- tokens: S,
1128
- error: u
1113
+ placeOrder: L,
1114
+ orders: y,
1115
+ tokens: I,
1116
+ error: l
1129
1117
  },
1130
- children: o
1118
+ children: i
1131
1119
  }
1132
1120
  );
1133
1121
  };
1134
- function Fe() {
1135
- const o = we(de);
1136
- if (o === null)
1122
+ function We() {
1123
+ const i = we(ue);
1124
+ if (i === null)
1137
1125
  throw new Error("useMonerium must be used within a MoneriumProvider");
1138
- return o;
1126
+ return i;
1139
1127
  }
1140
1128
  export {
1141
- de as MoneriumContext,
1129
+ ue as MoneriumContext,
1142
1130
  De as MoneriumProvider,
1143
- Fe as useMonerium
1131
+ We as useMonerium
1144
1132
  };