@monerium/sdk-react-provider 0.0.2 → 0.0.4

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