@monerium/sdk 2.7.0 → 2.7.2

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,15 +1,15 @@
1
- var G = (e, r, t) => {
1
+ var Z = (e, r, t) => {
2
2
  if (!r.has(e))
3
3
  throw TypeError("Cannot " + t);
4
4
  };
5
- var w = (e, r, t) => (G(e, r, "read from private field"), t ? t.call(e) : r.get(e)), z = (e, r, t) => {
5
+ var w = (e, r, t) => (Z(e, r, "read from private field"), t ? t.call(e) : r.get(e)), $ = (e, r, t) => {
6
6
  if (r.has(e))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  r instanceof WeakSet ? r.add(e) : r.set(e, t);
9
- }, A = (e, r, t, n) => (G(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
10
- var I = (e, r, t) => (G(e, r, "access private method"), t);
11
- var he = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(he || {}), de = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(de || {}), fe = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(fe || {}), le = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(ye || {});
12
- const me = (e) => {
9
+ }, I = (e, r, t, n) => (Z(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
10
+ var k = (e, r, t) => (Z(e, r, "access private method"), t);
11
+ var fe = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(fe || {}), le = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(_e || {});
12
+ const be = (e) => {
13
13
  if (e.toString() === "Invalid Date")
14
14
  throw e;
15
15
  const r = (n) => n < 10 ? "0" + n : n, t = (n) => {
@@ -19,12 +19,12 @@ const me = (e) => {
19
19
  return n = Math.abs(n), u + r(Math.floor(n / 60)) + ":" + r(n % 60);
20
20
  };
21
21
  return e.getFullYear() + "-" + r(e.getMonth() + 1) + "-" + r(e.getDate()) + "T" + r(e.getHours()) + ":" + r(e.getMinutes()) + ":" + r(e.getSeconds()) + t(e.getTimezoneOffset());
22
- }, qe = (e, r) => `Send EUR ${e} to ${r} at ${me(/* @__PURE__ */ new Date())}`, D = (e) => {
22
+ }, Fe = (e, r) => `Send EUR ${e} to ${r} at ${be(/* @__PURE__ */ new Date())}`, Q = (e) => {
23
23
  var r;
24
24
  return e && ((r = Object.entries(e)) == null ? void 0 : r.length) > 0 ? Object.entries(e).map(
25
25
  ([t, n]) => `${encodeURIComponent(t)}=${encodeURIComponent(n)}`
26
26
  ).join("&") : "";
27
- }, _e = (e) => {
27
+ }, Se = (e) => {
28
28
  switch (e) {
29
29
  case 1:
30
30
  case 5:
@@ -38,7 +38,7 @@ const me = (e) => {
38
38
  default:
39
39
  throw new Error(`Chain not supported: ${e}`);
40
40
  }
41
- }, be = (e) => {
41
+ }, Be = (e) => {
42
42
  switch (e) {
43
43
  case 1:
44
44
  case 100:
@@ -53,7 +53,7 @@ const me = (e) => {
53
53
  default:
54
54
  throw new Error(`Network not supported: ${e}`);
55
55
  }
56
- }, J = {
56
+ }, X = {
57
57
  environments: {
58
58
  production: {
59
59
  api: "https://api.monerium.app",
@@ -66,28 +66,22 @@ const me = (e) => {
66
66
  wss: "wss://api.monerium.dev"
67
67
  }
68
68
  }
69
- }, Be = "I hereby declare that I am the address owner.", P = "monerium.sdk.code_verifier", V = "monerium.sdk.refresh_token", Fe = {
70
- LINK_MESSAGE: Be,
71
- STORAGE_CODE_VERIFIER: P,
72
- STORAGE_REFRESH_TOKEN: V
69
+ }, ke = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", Ne = {
70
+ LINK_MESSAGE: ke,
71
+ STORAGE_CODE_VERIFIER: M,
72
+ STORAGE_REFRESH_TOKEN: W
73
73
  };
74
- var L = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
75
- function re(e) {
74
+ var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
75
+ function ne(e) {
76
76
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
77
77
  }
78
- function ke(e) {
78
+ function Ce(e) {
79
79
  if (e.__esModule)
80
80
  return e;
81
81
  var r = e.default;
82
82
  if (typeof r == "function") {
83
83
  var t = function n() {
84
- if (this instanceof n) {
85
- var u = [null];
86
- u.push.apply(u, arguments);
87
- var i = Function.bind.apply(r, u);
88
- return new i();
89
- }
90
- return r.apply(this, arguments);
84
+ return this instanceof n ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
91
85
  };
92
86
  t.prototype = r.prototype;
93
87
  } else
@@ -102,48 +96,48 @@ function ke(e) {
102
96
  });
103
97
  }), t;
104
98
  }
105
- var te = { exports: {} };
106
- function Se(e) {
99
+ var se = { exports: {} };
100
+ function xe(e) {
107
101
  throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
108
102
  }
109
- var Q = { exports: {} };
110
- const Ce = {}, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
103
+ var K = { exports: {} };
104
+ const Ae = {}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
111
105
  __proto__: null,
112
- default: Ce
113
- }, Symbol.toStringTag, { value: "Module" })), Ee = /* @__PURE__ */ ke(xe);
114
- var K;
115
- function ne() {
116
- return K || (K = 1, function(e, r) {
106
+ default: Ae
107
+ }, Symbol.toStringTag, { value: "Module" })), Ie = /* @__PURE__ */ Ce(Ee);
108
+ var ee;
109
+ function oe() {
110
+ return ee || (ee = 1, function(e, r) {
117
111
  (function(t, n) {
118
112
  e.exports = n();
119
- })(L, function() {
113
+ })(F, function() {
120
114
  var t = t || function(n, u) {
121
- var i;
122
- 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 L < "u" && L.crypto && (i = L.crypto), !i && typeof Se == "function")
115
+ var c;
116
+ 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 F < "u" && F.crypto && (c = F.crypto), !c && typeof xe == "function")
123
117
  try {
124
- i = Ee;
118
+ c = Ie;
125
119
  } catch {
126
120
  }
127
121
  var v = function() {
128
- if (i) {
129
- if (typeof i.getRandomValues == "function")
122
+ if (c) {
123
+ if (typeof c.getRandomValues == "function")
130
124
  try {
131
- return i.getRandomValues(new Uint32Array(1))[0];
125
+ return c.getRandomValues(new Uint32Array(1))[0];
132
126
  } catch {
133
127
  }
134
- if (typeof i.randomBytes == "function")
128
+ if (typeof c.randomBytes == "function")
135
129
  try {
136
- return i.randomBytes(4).readInt32LE();
130
+ return c.randomBytes(4).readInt32LE();
137
131
  } catch {
138
132
  }
139
133
  }
140
134
  throw new Error("Native crypto module could not be used to get secure random number.");
141
- }, k = Object.create || function() {
142
- function o() {
135
+ }, B = Object.create || function() {
136
+ function s() {
143
137
  }
144
- return function(s) {
145
- var c;
146
- return o.prototype = s, c = new o(), o.prototype = null, c;
138
+ return function(o) {
139
+ var a;
140
+ return s.prototype = o, a = new s(), s.prototype = null, a;
147
141
  };
148
142
  }(), p = {}, y = p.lib = {}, m = y.Base = function() {
149
143
  return {
@@ -165,11 +159,11 @@ function ne() {
165
159
  * }
166
160
  * });
167
161
  */
168
- extend: function(o) {
169
- var s = k(this);
170
- return o && s.mixIn(o), (!s.hasOwnProperty("init") || this.init === s.init) && (s.init = function() {
171
- s.$super.init.apply(this, arguments);
172
- }), s.init.prototype = s, s.$super = this, s;
162
+ extend: function(s) {
163
+ var o = B(this);
164
+ return s && o.mixIn(s), (!o.hasOwnProperty("init") || this.init === o.init) && (o.init = function() {
165
+ o.$super.init.apply(this, arguments);
166
+ }), o.init.prototype = o, o.$super = this, o;
173
167
  },
174
168
  /**
175
169
  * Extends this object and runs the init method.
@@ -184,8 +178,8 @@ function ne() {
184
178
  * var instance = MyType.create();
185
179
  */
186
180
  create: function() {
187
- var o = this.extend();
188
- return o.init.apply(o, arguments), o;
181
+ var s = this.extend();
182
+ return s.init.apply(s, arguments), s;
189
183
  },
190
184
  /**
191
185
  * Initializes a newly created object.
@@ -212,10 +206,10 @@ function ne() {
212
206
  * field: 'value'
213
207
  * });
214
208
  */
215
- mixIn: function(o) {
216
- for (var s in o)
217
- o.hasOwnProperty(s) && (this[s] = o[s]);
218
- o.hasOwnProperty("toString") && (this.toString = o.toString);
209
+ mixIn: function(s) {
210
+ for (var o in s)
211
+ s.hasOwnProperty(o) && (this[o] = s[o]);
212
+ s.hasOwnProperty("toString") && (this.toString = s.toString);
219
213
  },
220
214
  /**
221
215
  * Creates a copy of this object.
@@ -243,8 +237,8 @@ function ne() {
243
237
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
244
238
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
245
239
  */
246
- init: function(o, s) {
247
- o = this.words = o || [], s != u ? this.sigBytes = s : this.sigBytes = o.length * 4;
240
+ init: function(s, o) {
241
+ s = this.words = s || [], o != u ? this.sigBytes = o : this.sigBytes = s.length * 4;
248
242
  },
249
243
  /**
250
244
  * Converts this word array to a string.
@@ -259,8 +253,8 @@ function ne() {
259
253
  * var string = wordArray.toString();
260
254
  * var string = wordArray.toString(CryptoJS.enc.Utf8);
261
255
  */
262
- toString: function(o) {
263
- return (o || d).stringify(this);
256
+ toString: function(s) {
257
+ return (s || d).stringify(this);
264
258
  },
265
259
  /**
266
260
  * Concatenates a word array to this word array.
@@ -273,16 +267,16 @@ function ne() {
273
267
  *
274
268
  * wordArray1.concat(wordArray2);
275
269
  */
276
- concat: function(o) {
277
- var s = this.words, c = o.words, h = this.sigBytes, _ = o.sigBytes;
270
+ concat: function(s) {
271
+ var o = this.words, a = s.words, h = this.sigBytes, _ = s.sigBytes;
278
272
  if (this.clamp(), h % 4)
279
- for (var B = 0; B < _; B++) {
280
- var S = c[B >>> 2] >>> 24 - B % 4 * 8 & 255;
281
- s[h + B >>> 2] |= S << 24 - (h + B) % 4 * 8;
273
+ for (var S = 0; S < _; S++) {
274
+ var C = a[S >>> 2] >>> 24 - S % 4 * 8 & 255;
275
+ o[h + S >>> 2] |= C << 24 - (h + S) % 4 * 8;
282
276
  }
283
277
  else
284
- for (var C = 0; C < _; C += 4)
285
- s[h + C >>> 2] = c[C >>> 2];
278
+ for (var x = 0; x < _; x += 4)
279
+ o[h + x >>> 2] = a[x >>> 2];
286
280
  return this.sigBytes += _, this;
287
281
  },
288
282
  /**
@@ -293,8 +287,8 @@ function ne() {
293
287
  * wordArray.clamp();
294
288
  */
295
289
  clamp: function() {
296
- var o = this.words, s = this.sigBytes;
297
- o[s >>> 2] &= 4294967295 << 32 - s % 4 * 8, o.length = n.ceil(s / 4);
290
+ var s = this.words, o = this.sigBytes;
291
+ s[o >>> 2] &= 4294967295 << 32 - o % 4 * 8, s.length = n.ceil(o / 4);
298
292
  },
299
293
  /**
300
294
  * Creates a copy of this word array.
@@ -306,8 +300,8 @@ function ne() {
306
300
  * var clone = wordArray.clone();
307
301
  */
308
302
  clone: function() {
309
- var o = m.clone.call(this);
310
- return o.words = this.words.slice(0), o;
303
+ var s = m.clone.call(this);
304
+ return s.words = this.words.slice(0), s;
311
305
  },
312
306
  /**
313
307
  * Creates a word array filled with random bytes.
@@ -322,10 +316,10 @@ function ne() {
322
316
  *
323
317
  * var wordArray = CryptoJS.lib.WordArray.random(16);
324
318
  */
325
- random: function(o) {
326
- for (var s = [], c = 0; c < o; c += 4)
327
- s.push(v());
328
- return new g.init(s, o);
319
+ random: function(s) {
320
+ for (var o = [], a = 0; a < s; a += 4)
321
+ o.push(v());
322
+ return new g.init(o, s);
329
323
  }
330
324
  }), b = p.enc = {}, d = b.Hex = {
331
325
  /**
@@ -341,10 +335,10 @@ function ne() {
341
335
  *
342
336
  * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
343
337
  */
344
- stringify: function(o) {
345
- for (var s = o.words, c = o.sigBytes, h = [], _ = 0; _ < c; _++) {
346
- var B = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
347
- h.push((B >>> 4).toString(16)), h.push((B & 15).toString(16));
338
+ stringify: function(s) {
339
+ for (var o = s.words, a = s.sigBytes, h = [], _ = 0; _ < a; _++) {
340
+ var S = o[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
341
+ h.push((S >>> 4).toString(16)), h.push((S & 15).toString(16));
348
342
  }
349
343
  return h.join("");
350
344
  },
@@ -361,10 +355,10 @@ function ne() {
361
355
  *
362
356
  * var wordArray = CryptoJS.enc.Hex.parse(hexString);
363
357
  */
364
- parse: function(o) {
365
- for (var s = o.length, c = [], h = 0; h < s; h += 2)
366
- c[h >>> 3] |= parseInt(o.substr(h, 2), 16) << 24 - h % 8 * 4;
367
- return new g.init(c, s / 2);
358
+ parse: function(s) {
359
+ for (var o = s.length, a = [], h = 0; h < o; h += 2)
360
+ a[h >>> 3] |= parseInt(s.substr(h, 2), 16) << 24 - h % 8 * 4;
361
+ return new g.init(a, o / 2);
368
362
  }
369
363
  }, l = b.Latin1 = {
370
364
  /**
@@ -380,10 +374,10 @@ function ne() {
380
374
  *
381
375
  * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
382
376
  */
383
- stringify: function(o) {
384
- for (var s = o.words, c = o.sigBytes, h = [], _ = 0; _ < c; _++) {
385
- var B = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
386
- h.push(String.fromCharCode(B));
377
+ stringify: function(s) {
378
+ for (var o = s.words, a = s.sigBytes, h = [], _ = 0; _ < a; _++) {
379
+ var S = o[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
380
+ h.push(String.fromCharCode(S));
387
381
  }
388
382
  return h.join("");
389
383
  },
@@ -400,12 +394,12 @@ function ne() {
400
394
  *
401
395
  * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
402
396
  */
403
- parse: function(o) {
404
- for (var s = o.length, c = [], h = 0; h < s; h++)
405
- c[h >>> 2] |= (o.charCodeAt(h) & 255) << 24 - h % 4 * 8;
406
- return new g.init(c, s);
397
+ parse: function(s) {
398
+ for (var o = s.length, a = [], h = 0; h < o; h++)
399
+ a[h >>> 2] |= (s.charCodeAt(h) & 255) << 24 - h % 4 * 8;
400
+ return new g.init(a, o);
407
401
  }
408
- }, a = b.Utf8 = {
402
+ }, i = b.Utf8 = {
409
403
  /**
410
404
  * Converts a word array to a UTF-8 string.
411
405
  *
@@ -419,9 +413,9 @@ function ne() {
419
413
  *
420
414
  * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
421
415
  */
422
- stringify: function(o) {
416
+ stringify: function(s) {
423
417
  try {
424
- return decodeURIComponent(escape(l.stringify(o)));
418
+ return decodeURIComponent(escape(l.stringify(s)));
425
419
  } catch {
426
420
  throw new Error("Malformed UTF-8 data");
427
421
  }
@@ -439,8 +433,8 @@ function ne() {
439
433
  *
440
434
  * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
441
435
  */
442
- parse: function(o) {
443
- return l.parse(unescape(encodeURIComponent(o)));
436
+ parse: function(s) {
437
+ return l.parse(unescape(encodeURIComponent(s)));
444
438
  }
445
439
  }, f = y.BufferedBlockAlgorithm = m.extend({
446
440
  /**
@@ -463,8 +457,8 @@ function ne() {
463
457
  * bufferedBlockAlgorithm._append('data');
464
458
  * bufferedBlockAlgorithm._append(wordArray);
465
459
  */
466
- _append: function(o) {
467
- typeof o == "string" && (o = a.parse(o)), this._data.concat(o), this._nDataBytes += o.sigBytes;
460
+ _append: function(s) {
461
+ typeof s == "string" && (s = i.parse(s)), this._data.concat(s), this._nDataBytes += s.sigBytes;
468
462
  },
469
463
  /**
470
464
  * Processes available data blocks.
@@ -480,16 +474,16 @@ function ne() {
480
474
  * var processedData = bufferedBlockAlgorithm._process();
481
475
  * var processedData = bufferedBlockAlgorithm._process(!!'flush');
482
476
  */
483
- _process: function(o) {
484
- var s, c = this._data, h = c.words, _ = c.sigBytes, B = this.blockSize, S = B * 4, C = _ / S;
485
- o ? C = n.ceil(C) : C = n.max((C | 0) - this._minBufferSize, 0);
486
- var M = C * B, H = n.min(M * 4, _);
487
- if (M) {
488
- for (var q = 0; q < M; q += B)
489
- this._doProcessBlock(h, q);
490
- s = h.splice(0, M), c.sigBytes -= H;
477
+ _process: function(s) {
478
+ var o, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
479
+ s ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
480
+ var q = x * S, P = n.min(q * 4, _);
481
+ if (q) {
482
+ for (var N = 0; N < q; N += S)
483
+ this._doProcessBlock(h, N);
484
+ o = h.splice(0, q), a.sigBytes -= P;
491
485
  }
492
- return new g.init(s, H);
486
+ return new g.init(o, P);
493
487
  },
494
488
  /**
495
489
  * Creates a copy of this object.
@@ -501,8 +495,8 @@ function ne() {
501
495
  * var clone = bufferedBlockAlgorithm.clone();
502
496
  */
503
497
  clone: function() {
504
- var o = m.clone.call(this);
505
- return o._data = this._data.clone(), o;
498
+ var s = m.clone.call(this);
499
+ return s._data = this._data.clone(), s;
506
500
  },
507
501
  _minBufferSize: 0
508
502
  });
@@ -520,8 +514,8 @@ function ne() {
520
514
  *
521
515
  * var hasher = CryptoJS.algo.SHA256.create();
522
516
  */
523
- init: function(o) {
524
- this.cfg = this.cfg.extend(o), this.reset();
517
+ init: function(s) {
518
+ this.cfg = this.cfg.extend(s), this.reset();
525
519
  },
526
520
  /**
527
521
  * Resets this hasher to its initial state.
@@ -545,8 +539,8 @@ function ne() {
545
539
  * hasher.update('message');
546
540
  * hasher.update(wordArray);
547
541
  */
548
- update: function(o) {
549
- return this._append(o), this._process(), this;
542
+ update: function(s) {
543
+ return this._append(s), this._process(), this;
550
544
  },
551
545
  /**
552
546
  * Finalizes the hash computation.
@@ -562,10 +556,10 @@ function ne() {
562
556
  * var hash = hasher.finalize('message');
563
557
  * var hash = hasher.finalize(wordArray);
564
558
  */
565
- finalize: function(o) {
566
- o && this._append(o);
567
- var s = this._doFinalize();
568
- return s;
559
+ finalize: function(s) {
560
+ s && this._append(s);
561
+ var o = this._doFinalize();
562
+ return o;
569
563
  },
570
564
  blockSize: 16,
571
565
  /**
@@ -581,9 +575,9 @@ function ne() {
581
575
  *
582
576
  * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
583
577
  */
584
- _createHelper: function(o) {
585
- return function(s, c) {
586
- return new o.init(c).finalize(s);
578
+ _createHelper: function(s) {
579
+ return function(o, a) {
580
+ return new s.init(a).finalize(o);
587
581
  };
588
582
  },
589
583
  /**
@@ -599,25 +593,25 @@ function ne() {
599
593
  *
600
594
  * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
601
595
  */
602
- _createHmacHelper: function(o) {
603
- return function(s, c) {
604
- return new x.HMAC.init(o, c).finalize(s);
596
+ _createHmacHelper: function(s) {
597
+ return function(o, a) {
598
+ return new A.HMAC.init(s, a).finalize(o);
605
599
  };
606
600
  }
607
601
  });
608
- var x = p.algo = {};
602
+ var A = p.algo = {};
609
603
  return p;
610
604
  }(Math);
611
605
  return t;
612
606
  });
613
- }(Q)), Q.exports;
607
+ }(K)), K.exports;
614
608
  }
615
609
  (function(e, r) {
616
610
  (function(t, n) {
617
- e.exports = n(ne());
618
- })(L, function(t) {
611
+ e.exports = n(oe());
612
+ })(F, function(t) {
619
613
  return function() {
620
- var n = t, u = n.lib, i = u.WordArray, v = n.enc;
614
+ var n = t, u = n.lib, c = u.WordArray, v = n.enc;
621
615
  v.Base64url = {
622
616
  /**
623
617
  * Converts a word array to a Base64url string.
@@ -639,12 +633,12 @@ function ne() {
639
633
  var m = p.words, g = p.sigBytes, b = y ? this._safe_map : this._map;
640
634
  p.clamp();
641
635
  for (var d = [], l = 0; l < g; l += 3)
642
- for (var a = m[l >>> 2] >>> 24 - l % 4 * 8 & 255, f = m[l + 1 >>> 2] >>> 24 - (l + 1) % 4 * 8 & 255, x = m[l + 2 >>> 2] >>> 24 - (l + 2) % 4 * 8 & 255, o = a << 16 | f << 8 | x, s = 0; s < 4 && l + s * 0.75 < g; s++)
643
- d.push(b.charAt(o >>> 6 * (3 - s) & 63));
644
- var c = b.charAt(64);
645
- if (c)
636
+ for (var i = m[l >>> 2] >>> 24 - l % 4 * 8 & 255, f = m[l + 1 >>> 2] >>> 24 - (l + 1) % 4 * 8 & 255, A = m[l + 2 >>> 2] >>> 24 - (l + 2) % 4 * 8 & 255, s = i << 16 | f << 8 | A, o = 0; o < 4 && l + o * 0.75 < g; o++)
637
+ d.push(b.charAt(s >>> 6 * (3 - o) & 63));
638
+ var a = b.charAt(64);
639
+ if (a)
646
640
  for (; d.length % 4; )
647
- d.push(c);
641
+ d.push(a);
648
642
  return d.join("");
649
643
  },
650
644
  /**
@@ -672,202 +666,206 @@ function ne() {
672
666
  }
673
667
  var l = g.charAt(64);
674
668
  if (l) {
675
- var a = p.indexOf(l);
676
- a !== -1 && (m = a);
669
+ var i = p.indexOf(l);
670
+ i !== -1 && (m = i);
677
671
  }
678
- return k(p, m, b);
672
+ return B(p, m, b);
679
673
  },
680
674
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
681
675
  _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
682
676
  };
683
- function k(p, y, m) {
677
+ function B(p, y, m) {
684
678
  for (var g = [], b = 0, d = 0; d < y; d++)
685
679
  if (d % 4) {
686
- var l = m[p.charCodeAt(d - 1)] << d % 4 * 2, a = m[p.charCodeAt(d)] >>> 6 - d % 4 * 2, f = l | a;
680
+ var l = m[p.charCodeAt(d - 1)] << d % 4 * 2, i = m[p.charCodeAt(d)] >>> 6 - d % 4 * 2, f = l | i;
687
681
  g[b >>> 2] |= f << 24 - b % 4 * 8, b++;
688
682
  }
689
- return i.create(g, b);
683
+ return c.create(g, b);
690
684
  }
691
685
  }(), t.enc.Base64url;
692
686
  });
693
- })(te);
694
- var Ae = te.exports;
695
- const Ie = /* @__PURE__ */ re(Ae);
696
- var oe = { exports: {} };
687
+ })(se);
688
+ var Re = se.exports;
689
+ const $e = /* @__PURE__ */ ne(Re);
690
+ var ie = { exports: {} };
697
691
  (function(e, r) {
698
692
  (function(t, n) {
699
- e.exports = n(ne());
700
- })(L, function(t) {
693
+ e.exports = n(oe());
694
+ })(F, function(t) {
701
695
  return function(n) {
702
- var u = t, i = u.lib, v = i.WordArray, k = i.Hasher, p = u.algo, y = [], m = [];
696
+ var u = t, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
703
697
  (function() {
704
- function d(x) {
705
- for (var o = n.sqrt(x), s = 2; s <= o; s++)
706
- if (!(x % s))
698
+ function d(A) {
699
+ for (var s = n.sqrt(A), o = 2; o <= s; o++)
700
+ if (!(A % o))
707
701
  return !1;
708
702
  return !0;
709
703
  }
710
- function l(x) {
711
- return (x - (x | 0)) * 4294967296 | 0;
704
+ function l(A) {
705
+ return (A - (A | 0)) * 4294967296 | 0;
712
706
  }
713
- for (var a = 2, f = 0; f < 64; )
714
- d(a) && (f < 8 && (y[f] = l(n.pow(a, 1 / 2))), m[f] = l(n.pow(a, 1 / 3)), f++), a++;
707
+ for (var i = 2, f = 0; f < 64; )
708
+ d(i) && (f < 8 && (y[f] = l(n.pow(i, 1 / 2))), m[f] = l(n.pow(i, 1 / 3)), f++), i++;
715
709
  })();
716
- var g = [], b = p.SHA256 = k.extend({
710
+ var g = [], b = p.SHA256 = B.extend({
717
711
  _doReset: function() {
718
712
  this._hash = new v.init(y.slice(0));
719
713
  },
720
714
  _doProcessBlock: function(d, l) {
721
- for (var a = this._hash.words, f = a[0], x = a[1], o = a[2], s = a[3], c = a[4], h = a[5], _ = a[6], B = a[7], S = 0; S < 64; S++) {
722
- if (S < 16)
723
- g[S] = d[l + S] | 0;
715
+ for (var i = this._hash.words, f = i[0], A = i[1], s = i[2], o = i[3], a = i[4], h = i[5], _ = i[6], S = i[7], C = 0; C < 64; C++) {
716
+ if (C < 16)
717
+ g[C] = d[l + C] | 0;
724
718
  else {
725
- var C = g[S - 15], M = (C << 25 | C >>> 7) ^ (C << 14 | C >>> 18) ^ C >>> 3, H = g[S - 2], q = (H << 15 | H >>> 17) ^ (H << 13 | H >>> 19) ^ H >>> 10;
726
- g[S] = M + g[S - 7] + q + g[S - 16];
719
+ var x = g[C - 15], q = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, P = g[C - 2], N = (P << 15 | P >>> 17) ^ (P << 13 | P >>> 19) ^ P >>> 10;
720
+ g[C] = q + g[C - 7] + N + g[C - 16];
727
721
  }
728
- var se = c & h ^ ~c & _, ie = f & x ^ f & o ^ x & o, ae = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), ce = (c << 26 | c >>> 6) ^ (c << 21 | c >>> 11) ^ (c << 7 | c >>> 25), X = B + ce + se + m[S] + g[S], ue = ae + ie;
729
- B = _, _ = h, h = c, c = s + X | 0, s = o, o = x, x = f, f = X + ue | 0;
722
+ var ae = a & h ^ ~a & _, ce = f & A ^ f & s ^ A & s, ue = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), he = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + he + ae + m[C] + g[C], de = ue + ce;
723
+ S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + de | 0;
730
724
  }
731
- a[0] = a[0] + f | 0, a[1] = a[1] + x | 0, a[2] = a[2] + o | 0, a[3] = a[3] + s | 0, a[4] = a[4] + c | 0, a[5] = a[5] + h | 0, a[6] = a[6] + _ | 0, a[7] = a[7] + B | 0;
725
+ i[0] = i[0] + f | 0, i[1] = i[1] + A | 0, i[2] = i[2] + s | 0, i[3] = i[3] + o | 0, i[4] = i[4] + a | 0, i[5] = i[5] + h | 0, i[6] = i[6] + _ | 0, i[7] = i[7] + S | 0;
732
726
  },
733
727
  _doFinalize: function() {
734
- var d = this._data, l = d.words, a = this._nDataBytes * 8, f = d.sigBytes * 8;
735
- return l[f >>> 5] |= 128 << 24 - f % 32, l[(f + 64 >>> 9 << 4) + 14] = n.floor(a / 4294967296), l[(f + 64 >>> 9 << 4) + 15] = a, d.sigBytes = l.length * 4, this._process(), this._hash;
728
+ var d = this._data, l = d.words, i = this._nDataBytes * 8, f = d.sigBytes * 8;
729
+ return l[f >>> 5] |= 128 << 24 - f % 32, l[(f + 64 >>> 9 << 4) + 14] = n.floor(i / 4294967296), l[(f + 64 >>> 9 << 4) + 15] = i, d.sigBytes = l.length * 4, this._process(), this._hash;
736
730
  },
737
731
  clone: function() {
738
- var d = k.clone.call(this);
732
+ var d = B.clone.call(this);
739
733
  return d._hash = this._hash.clone(), d;
740
734
  }
741
735
  });
742
- u.SHA256 = k._createHelper(b), u.HmacSHA256 = k._createHmacHelper(b);
736
+ u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
743
737
  }(Math), t.SHA256;
744
738
  });
745
- })(oe);
746
- var Re = oe.exports;
747
- const $e = /* @__PURE__ */ re(Re), Te = (e, r) => {
739
+ })(ie);
740
+ var ze = ie.exports;
741
+ const Ue = /* @__PURE__ */ ne(ze), He = (e, r) => {
748
742
  const {
749
743
  client_id: t,
750
744
  redirect_uri: n,
751
745
  scope: u,
752
- state: i,
746
+ state: c,
753
747
  chainId: v,
754
- chain: k,
748
+ chain: B,
755
749
  network: p,
756
750
  address: y,
757
751
  signature: m
758
752
  } = e, g = y ? {
759
753
  address: y,
760
754
  ...m !== void 0 ? { signature: m } : {},
761
- ...v !== void 0 || k !== void 0 ? { chain: v ? _e(v) : k } : {},
762
- ...v !== void 0 || p !== void 0 ? { network: v ? be(v) : p } : {}
755
+ ...v !== void 0 || B !== void 0 ? { chain: v ? Se(v) : B } : {},
756
+ ...v !== void 0 || p !== void 0 ? { network: v ? Be(v) : p } : {}
763
757
  } : {};
764
- return D({
758
+ return Q({
765
759
  client_id: t,
766
760
  redirect_uri: n,
767
761
  ...u !== void 0 ? { scope: u } : {},
768
- ...i !== void 0 ? { state: i } : {},
762
+ ...c !== void 0 ? { state: c } : {},
769
763
  code_challenge: r,
770
764
  code_challenge_method: "S256",
771
765
  response_type: "code",
772
766
  ...g
773
767
  });
774
- }, ze = () => {
768
+ }, Pe = () => {
775
769
  let e = "";
776
770
  const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = r.length;
777
771
  let n = 0;
778
772
  for (; n < 128; )
779
773
  e += r.charAt(Math.floor(Math.random() * t)), n += 1;
780
774
  return e;
781
- }, Ue = (e) => Ie.stringify($e(e)), Y = (e, r) => {
782
- const t = ze(), n = Ue(t);
783
- return sessionStorage.setItem(P, t || ""), `${e}/auth?${Te(r, n)}`;
784
- }, He = () => {
775
+ }, Oe = (e) => $e.stringify(Ue(e)), re = (e, r) => {
776
+ const t = Pe(), n = Oe(t);
777
+ return sessionStorage.setItem(M, t || ""), `${e}/auth?${He(r, n)}`;
778
+ }, Te = () => {
785
779
  const e = window.location.href, [r, t] = e.split("?");
786
780
  t && window.history.replaceState(null, "", r);
787
- }, ee = (e) => e.code != null, Pe = (e) => e.refresh_token != null, Oe = (e) => e.client_secret != null, Me = async (e, r, t, n) => {
781
+ }, te = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, r, t, n) => {
788
782
  const u = await fetch(`${e}`, {
789
783
  method: r,
790
784
  headers: n,
791
785
  body: t
792
786
  });
793
- let i;
787
+ let c;
794
788
  const v = await u.text();
795
789
  try {
796
- i = JSON.parse(v);
790
+ c = JSON.parse(v);
797
791
  } catch {
798
792
  throw v;
799
793
  }
800
794
  if (!u.ok)
801
- throw i;
802
- return i;
803
- }, Z = typeof window > "u";
804
- var $, F, O, U, T, E, R, j, N, W;
805
- class je {
795
+ throw c;
796
+ return c;
797
+ }, T = typeof window > "u";
798
+ var z, D, L, H, U, O, j, E, R, V, G, J;
799
+ class We {
806
800
  constructor(r) {
801
+ /**
802
+ * {@link https://monerium.dev/api-docs#operation/auth-token}
803
+ */
804
+ $(this, O);
807
805
  // -- Helper Methods
808
- z(this, E);
809
- z(this, $, void 0);
810
- z(this, F, void 0);
806
+ $(this, E);
807
+ $(this, z, void 0);
808
+ $(this, D, void 0);
811
809
  /** The socket will be available after subscribing to an event */
812
- z(this, O, void 0);
813
- z(this, U, void 0);
814
- z(this, T, void 0);
815
- z(this, j, void 0);
816
- z(this, N, void 0);
817
- z(this, W, void 0);
818
- if (A(this, U, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, A(this, j, async (t, n, u) => {
819
- const i = sessionStorage.getItem(P) || "";
820
- if (!i)
810
+ $(this, L, void 0);
811
+ $(this, H, void 0);
812
+ $(this, U, void 0);
813
+ $(this, V, void 0);
814
+ $(this, G, void 0);
815
+ $(this, J, void 0);
816
+ if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (t, n, u) => {
817
+ const c = sessionStorage.getItem(M) || "";
818
+ if (!c)
821
819
  throw new Error("Code verifier not found");
822
- return this.codeVerifier = i, sessionStorage.removeItem(P), await this.getBearerToken({
820
+ return this.codeVerifier = c, sessionStorage.removeItem(M), await k(this, O, j).call(this, {
823
821
  code: u,
824
822
  redirect_uri: n,
825
823
  client_id: t,
826
- code_verifier: i
824
+ code_verifier: c
827
825
  });
828
- }), A(this, N, async ({
826
+ }), I(this, G, async ({
829
827
  clientId: t,
830
828
  clientSecret: n
831
- }) => await this.getBearerToken({
829
+ }) => await k(this, O, j).call(this, {
832
830
  client_id: t,
833
831
  client_secret: n
834
- })), A(this, W, async (t, n) => await this.getBearerToken({
832
+ })), I(this, J, async (t, n) => await k(this, O, j).call(this, {
835
833
  refresh_token: n,
836
834
  client_id: t
837
835
  })), this.subscribeToOrderNotifications = () => {
838
- var u, i;
839
- const t = `${w(this, $).wss}/profiles/${(u = this.bearerProfile) == null ? void 0 : u.profile}/orders?access_token=${(i = this.bearerProfile) == null ? void 0 : i.access_token}`, n = new WebSocket(t);
836
+ var u, c;
837
+ const t = `${w(this, z).wss}/profiles/${(u = this.bearerProfile) == null ? void 0 : u.profile}/orders?access_token=${(c = this.bearerProfile) == null ? void 0 : c.access_token}`, n = new WebSocket(t);
840
838
  return n.addEventListener("open", () => {
841
839
  console.info(`Socket connected: ${t}`);
842
840
  }), n.addEventListener("error", (v) => {
843
841
  throw console.error(v), new Error(`Socket error: ${t}`);
844
842
  }), n.addEventListener("message", (v) => {
845
843
  var p;
846
- const k = JSON.parse(v.data);
847
- (p = w(this, U).get(k.meta.state)) == null || p(
848
- k
844
+ const B = JSON.parse(v.data);
845
+ (p = w(this, H).get(B.meta.state)) == null || p(
846
+ B
849
847
  );
850
848
  }), n.addEventListener("close", () => {
851
849
  console.info(`Socket connection closed: ${t}`);
852
850
  }), n;
853
- }, this.auth = async (t) => await this.getBearerToken(t), this.getAuthFlowURI = (t) => {
854
- const n = Y(w(this, $).api, t);
855
- return this.codeVerifier = sessionStorage.getItem(P), n;
856
- }, this.pkceRequest = (t) => this.getAuthFlowURI(t), this.getEnvironment = () => w(this, $), !r) {
857
- A(this, $, J.environments.sandbox);
851
+ }, this.auth = async (t) => await k(this, O, j).call(this, t), this.connect = async (t) => await k(this, O, j).call(this, t), this.getAuthFlowURI = (t) => {
852
+ const n = re(w(this, z).api, t);
853
+ return this.codeVerifier = sessionStorage.getItem(M), n;
854
+ }, this.pkceRequest = (t) => this.getAuthFlowURI(t), this.getEnvironment = () => w(this, z), !r) {
855
+ I(this, z, X.environments.sandbox);
858
856
  return;
859
857
  }
860
858
  if (typeof r == "string")
861
- A(this, $, J.environments[r]);
862
- else if (A(this, $, J.environments[r.environment || "sandbox"]), Z) {
859
+ I(this, z, X.environments[r]);
860
+ else if (I(this, z, X.environments[r.environment || "sandbox"]), T) {
863
861
  const { clientId: t, clientSecret: n } = r;
864
- A(this, T, {
862
+ I(this, U, {
865
863
  clientId: t,
866
864
  clientSecret: n
867
865
  });
868
866
  } else {
869
867
  const { clientId: t, redirectUrl: n } = r;
870
- A(this, T, {
868
+ I(this, U, {
871
869
  clientId: t,
872
870
  redirectUrl: n
873
871
  });
@@ -881,13 +879,13 @@ class je {
881
879
  * {@link https://monerium.dev/api-docs#operation/auth}
882
880
  */
883
881
  async authorize(r) {
884
- var i, v;
885
- const t = (r == null ? void 0 : r.clientId) || ((i = w(this, T)) == null ? void 0 : i.clientId), n = (r == null ? void 0 : r.redirectUrl) || ((v = w(this, T)) == null ? void 0 : v.redirectUrl);
882
+ var c, v;
883
+ const t = (r == null ? void 0 : r.clientId) || ((c = w(this, U)) == null ? void 0 : c.clientId), n = (r == null ? void 0 : r.redirectUrl) || ((v = w(this, U)) == null ? void 0 : v.redirectUrl);
886
884
  if (!t)
887
885
  throw new Error("Missing ClientId");
888
886
  if (!n)
889
887
  throw new Error("Missing RedirectUrl");
890
- const u = Y(w(this, $).api, {
888
+ const u = re(w(this, z).api, {
891
889
  client_id: t,
892
890
  redirect_uri: n,
893
891
  address: r == null ? void 0 : r.address,
@@ -896,51 +894,33 @@ class je {
896
894
  });
897
895
  window.location.replace(u);
898
896
  }
899
- async connect(r) {
900
- var k, p, y;
901
- const t = (r == null ? void 0 : r.clientId) || ((k = w(this, T)) == null ? void 0 : k.clientId);
902
- if ((r == null ? void 0 : r.clientSecret) || ((p = w(this, T)) == null ? void 0 : p.clientSecret)) {
903
- if (!Z)
897
+ /**
898
+ * Get access to the API
899
+ * @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
900
+ * @returns boolean to indicate if access has been granted
901
+ */
902
+ async getAccess(r) {
903
+ var B, p, y;
904
+ const t = (r == null ? void 0 : r.clientId) || ((B = w(this, U)) == null ? void 0 : B.clientId);
905
+ if ((r == null ? void 0 : r.clientSecret) || ((p = w(this, U)) == null ? void 0 : p.clientSecret)) {
906
+ if (!T)
904
907
  throw new Error("Only use client credentials on server side");
905
- return await w(this, N).call(this, w(this, T)), !!this.bearerProfile;
908
+ return await w(this, G).call(this, w(this, U)), !!this.bearerProfile;
906
909
  }
907
- const u = (r == null ? void 0 : r.redirectUrl) || ((y = w(this, T)) == null ? void 0 : y.redirectUrl);
910
+ const u = (r == null ? void 0 : r.redirectUrl) || ((y = w(this, U)) == null ? void 0 : y.redirectUrl);
908
911
  if (!t)
909
912
  throw new Error("Missing ClientId");
910
- if (Z)
911
- throw new Error("This only works on client side");
912
- const i = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(V) || void 0;
913
- return i ? await w(this, j).call(this, t, u, i) : v && await w(this, W).call(this, t, v), !!this.bearerProfile;
914
- }
915
- /**
916
- * {@link https://monerium.dev/api-docs#operation/auth-token}
917
- */
918
- async getBearerToken(r) {
919
- let t;
920
- if (ee(r))
921
- t = { ...r, grant_type: "authorization_code" };
922
- else if (Pe(r))
923
- t = { ...r, grant_type: "refresh_token" };
924
- else if (Oe(r))
925
- t = { ...r, grant_type: "client_credentials" };
926
- else
927
- throw new Error("Authentication method could not be detected.");
928
- return await I(this, E, R).call(this, "post", "auth/token", t, !0).then((n) => {
929
- var u;
930
- this.bearerProfile = n, this.isAuthorized = !!n, A(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), window.sessionStorage.setItem(
931
- V,
932
- ((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
933
- );
934
- }).catch((n) => {
935
- throw sessionStorage.removeItem(P), sessionStorage.removeItem(V), new Error(n == null ? void 0 : n.message);
936
- }), ee(r) && He(), this.bearerProfile;
913
+ if (T)
914
+ throw new Error("This only works client side");
915
+ const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(W) || void 0;
916
+ return v ? await w(this, J).call(this, t, v) : c && await w(this, V).call(this, t, u, c), !!this.bearerProfile;
937
917
  }
938
918
  // -- Read Methods
939
919
  /**
940
920
  * {@link https://monerium.dev/api-docs#operation/auth-context}
941
921
  */
942
922
  getAuthContext() {
943
- return I(this, E, R).call(this, "get", "auth/context");
923
+ return k(this, E, R).call(this, "get", "auth/context");
944
924
  }
945
925
  /**
946
926
  * {@link https://monerium.dev/api-docs#operation/profile}
@@ -948,65 +928,74 @@ class je {
948
928
 
949
929
  */
950
930
  getProfile(r) {
951
- return I(this, E, R).call(this, "get", `profiles/${r}`);
931
+ return k(this, E, R).call(this, "get", `profiles/${r}`);
952
932
  }
953
933
  /**
954
934
  * {@link https://monerium.dev/api-docs#operation/profile-balances}
955
935
  * @param {string=} profileId - the id of the profile to fetch balances.
956
936
  */
957
937
  getBalances(r) {
958
- return r ? I(this, E, R).call(this, "get", `profiles/${r}/balances`) : I(this, E, R).call(this, "get", "balances");
938
+ return r ? k(this, E, R).call(this, "get", `profiles/${r}/balances`) : k(this, E, R).call(this, "get", "balances");
959
939
  }
960
940
  /**
961
941
  * {@link https://monerium.dev/api-docs#operation/orders}
962
942
  */
963
943
  getOrders(r) {
964
- const t = D(r);
965
- return I(this, E, R).call(this, "get", `orders?${t}`);
944
+ const t = Q(r);
945
+ return k(this, E, R).call(this, "get", `orders?${t}`);
966
946
  }
967
947
  /**
968
948
  * {@link https://monerium.dev/api-docs#operation/order}
969
949
  */
970
950
  getOrder(r) {
971
- return I(this, E, R).call(this, "get", `orders/${r}`);
951
+ return k(this, E, R).call(this, "get", `orders/${r}`);
972
952
  }
973
953
  /**
974
954
  * {@link https://monerium.dev/api-docs#operation/tokens}
975
955
  */
976
956
  getTokens() {
977
- return I(this, E, R).call(this, "get", "tokens");
957
+ return k(this, E, R).call(this, "get", "tokens");
978
958
  }
979
959
  // -- Write Methods
980
960
  /**
981
961
  * {@link https://monerium.dev/api-docs#operation/profile-addresses}
982
962
  */
983
963
  linkAddress(r, t) {
984
- return I(this, E, R).call(this, "post", `profiles/${r}/addresses`, JSON.stringify(t));
964
+ return k(this, E, R).call(this, "post", `profiles/${r}/addresses`, JSON.stringify(t));
985
965
  }
986
966
  /**
987
967
  * {@link https://monerium.dev/api-docs#operation/post-orders}
988
968
  */
989
969
  placeOrder(r, t) {
990
970
  const n = { ...r, kind: "redeem", currency: "eur" };
991
- return t ? I(this, E, R).call(this, "post", `profiles/${t}/orders`, JSON.stringify(n)) : I(this, E, R).call(this, "post", "orders", JSON.stringify(n));
971
+ return t ? k(this, E, R).call(this, "post", `profiles/${t}/orders`, JSON.stringify(n)) : k(this, E, R).call(this, "post", "orders", JSON.stringify(n));
992
972
  }
993
973
  /**
994
974
  * {@link https://monerium.dev/api-docs#operation/supporting-document}
995
975
  */
996
976
  uploadSupportingDocument(r) {
997
- const t = D(
977
+ const t = Q(
998
978
  r
999
979
  );
1000
- return I(this, E, R).call(this, "post", "files/supporting-document", t, !0);
980
+ return k(this, E, R).call(this, "post", "files/supporting-document", t, !0);
1001
981
  }
1002
982
  // -- Notifications
1003
983
  async connectOrderSocket() {
1004
984
  var r;
1005
- (r = this.bearerProfile) != null && r.access_token && w(this, U).size > 0 && A(this, O, this.subscribeToOrderNotifications());
985
+ (r = this.bearerProfile) != null && r.access_token && w(this, H).size > 0 && I(this, L, this.subscribeToOrderNotifications());
1006
986
  }
987
+ /**
988
+ * Cleanups the socket and the subscriptions
989
+ */
1007
990
  async disconnect() {
1008
991
  var r;
1009
- sessionStorage.removeItem(P), w(this, U).clear(), (r = w(this, O)) == null || r.close();
992
+ T || sessionStorage.removeItem(M), w(this, H).clear(), (r = w(this, L)) == null || r.close();
993
+ }
994
+ /**
995
+ * Revokes access
996
+ */
997
+ async revokeAccess() {
998
+ T || sessionStorage.removeItem(W), this.disconnect();
1010
999
  }
1011
1000
  /**
1012
1001
  * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
@@ -1016,7 +1005,7 @@ class je {
1016
1005
  * @param handler The handler to be called when the event is triggered
1017
1006
  */
1018
1007
  subscribeOrders(r, t) {
1019
- w(this, U).set(r, t);
1008
+ w(this, H).set(r, t);
1020
1009
  }
1021
1010
  /**
1022
1011
  * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
@@ -1024,32 +1013,53 @@ class je {
1024
1013
  */
1025
1014
  unsubscribeOrders(r) {
1026
1015
  var t;
1027
- w(this, U).delete(r), w(this, U).size === 0 && ((t = w(this, O)) == null || t.close(), A(this, O, void 0));
1016
+ w(this, H).delete(r), w(this, H).size === 0 && ((t = w(this, L)) == null || t.close(), I(this, L, void 0));
1028
1017
  }
1029
1018
  }
1030
- $ = new WeakMap(), F = new WeakMap(), O = new WeakMap(), U = new WeakMap(), T = new WeakMap(), E = new WeakSet(), R = async function(r, t, n, u) {
1031
- return Me(
1032
- `${w(this, $).api}/${t}`,
1019
+ z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(r) {
1020
+ let t;
1021
+ if (te(r))
1022
+ t = { ...r, grant_type: "authorization_code" };
1023
+ else if (Me(r))
1024
+ t = { ...r, grant_type: "refresh_token" };
1025
+ else if (Le(r))
1026
+ t = { ...r, grant_type: "client_credentials" };
1027
+ else
1028
+ throw new Error("Authorization grant type could not be detected.");
1029
+ return await k(this, E, R).call(this, "post", "auth/token", t, !0).then((n) => {
1030
+ var u;
1031
+ this.bearerProfile = n, this.isAuthorized = !!n, I(this, D, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
1032
+ W,
1033
+ ((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
1034
+ );
1035
+ }).catch((n) => {
1036
+ throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(W)), new Error(n == null ? void 0 : n.message);
1037
+ }), te(r) && Te(), this.bearerProfile;
1038
+ }, E = new WeakSet(), R = async function(r, t, n, u) {
1039
+ return qe(
1040
+ `${w(this, z).api}/${t}`,
1033
1041
  r,
1034
- u ? D(n) : n,
1042
+ u ? Q(n) : n,
1035
1043
  {
1036
- Authorization: w(this, F) || "",
1044
+ Authorization: w(this, D) || "",
1037
1045
  "Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
1038
1046
  }
1039
1047
  );
1040
- }, j = new WeakMap(), N = new WeakMap(), W = new WeakMap();
1048
+ }, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
1041
1049
  export {
1042
- ve as AccountState,
1043
- he as Currency,
1044
- pe as KYCOutcome,
1045
- le as KYCState,
1046
- je as MoneriumClient,
1047
- we as OrderKind,
1048
- ye as OrderState,
1049
- ge as PaymentStandard,
1050
- fe as Permission,
1051
- de as ProfileType,
1052
- Fe as constants,
1053
- qe as placeOrderMessage,
1054
- me as rfc3339
1050
+ we as AccountState,
1051
+ fe as Currency,
1052
+ ge as KYCOutcome,
1053
+ ve as KYCState,
1054
+ We as MoneriumClient,
1055
+ me as OrderKind,
1056
+ _e as OrderState,
1057
+ ye as PaymentStandard,
1058
+ pe as Permission,
1059
+ le as ProfileType,
1060
+ Ne as constants,
1061
+ Se as getChain,
1062
+ Be as getNetwork,
1063
+ Fe as placeOrderMessage,
1064
+ be as rfc3339
1055
1065
  };