@monerium/sdk 2.6.4 → 2.7.0

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,101 +1,151 @@
1
- var oe = Object.defineProperty;
2
- var ie = (e, r, n) => r in e ? oe(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n;
3
- var I = (e, r, n) => (ie(e, typeof r != "symbol" ? r + "" : r, n), n), D = (e, r, n) => {
1
+ var G = (e, r, t) => {
4
2
  if (!r.has(e))
5
- throw TypeError("Cannot " + n);
3
+ throw TypeError("Cannot " + t);
6
4
  };
7
- var M = (e, r, n) => (D(e, r, "read from private field"), n ? n.call(e) : r.get(e)), O = (e, r, n) => {
5
+ var w = (e, r, t) => (G(e, r, "read from private field"), t ? t.call(e) : r.get(e)), z = (e, r, t) => {
8
6
  if (r.has(e))
9
7
  throw TypeError("Cannot add the same private member more than once");
10
- r instanceof WeakSet ? r.add(e) : r.set(e, n);
11
- }, F = (e, r, n, i) => (D(e, r, "write to private field"), i ? i.call(e, n) : r.set(e, n), n);
12
- var B = (e, r, n) => (D(e, r, "access private method"), n);
13
- var P = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
- function se(e) {
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) => {
13
+ if (e.toString() === "Invalid Date")
14
+ throw e;
15
+ const r = (n) => n < 10 ? "0" + n : n, t = (n) => {
16
+ if (n === 0)
17
+ return "Z";
18
+ const u = n > 0 ? "-" : "+";
19
+ return n = Math.abs(n), u + r(Math.floor(n / 60)) + ":" + r(n % 60);
20
+ };
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) => {
23
+ var r;
24
+ return e && ((r = Object.entries(e)) == null ? void 0 : r.length) > 0 ? Object.entries(e).map(
25
+ ([t, n]) => `${encodeURIComponent(t)}=${encodeURIComponent(n)}`
26
+ ).join("&") : "";
27
+ }, _e = (e) => {
28
+ switch (e) {
29
+ case 1:
30
+ case 5:
31
+ return "ethereum";
32
+ case 100:
33
+ case 10200:
34
+ return "gnosis";
35
+ case 137:
36
+ case 80001:
37
+ return "polygon";
38
+ default:
39
+ throw new Error(`Chain not supported: ${e}`);
40
+ }
41
+ }, be = (e) => {
42
+ switch (e) {
43
+ case 1:
44
+ case 100:
45
+ case 137:
46
+ return "mainnet";
47
+ case 5:
48
+ return "goerli";
49
+ case 10200:
50
+ return "chiado";
51
+ case 80001:
52
+ return "mumbai";
53
+ default:
54
+ throw new Error(`Network not supported: ${e}`);
55
+ }
56
+ }, J = {
57
+ environments: {
58
+ production: {
59
+ api: "https://api.monerium.app",
60
+ web: "https://monerium.app",
61
+ wss: "wss://api.monerium.app"
62
+ },
63
+ sandbox: {
64
+ api: "https://api.monerium.dev",
65
+ web: "https://sandbox.monerium.dev",
66
+ wss: "wss://api.monerium.dev"
67
+ }
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
73
+ };
74
+ var L = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
75
+ function re(e) {
76
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
77
+ }
78
+ function ke(e) {
15
79
  if (e.__esModule)
16
80
  return e;
17
81
  var r = e.default;
18
82
  if (typeof r == "function") {
19
- var n = function i() {
20
- if (this instanceof i) {
21
- var p = [null];
22
- p.push.apply(p, arguments);
23
- var l = Function.bind.apply(r, p);
24
- return new l();
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();
25
89
  }
26
90
  return r.apply(this, arguments);
27
91
  };
28
- n.prototype = r.prototype;
92
+ t.prototype = r.prototype;
29
93
  } else
30
- n = {};
31
- return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(i) {
32
- var p = Object.getOwnPropertyDescriptor(e, i);
33
- Object.defineProperty(n, i, p.get ? p : {
94
+ t = {};
95
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
96
+ var u = Object.getOwnPropertyDescriptor(e, n);
97
+ Object.defineProperty(t, n, u.get ? u : {
34
98
  enumerable: !0,
35
99
  get: function() {
36
- return e[i];
100
+ return e[n];
37
101
  }
38
102
  });
39
- }), n;
103
+ }), t;
40
104
  }
41
- var N = {}, ae = {
42
- get exports() {
43
- return N;
44
- },
45
- set exports(e) {
46
- N = e;
47
- }
48
- };
49
- function ce(e) {
105
+ var te = { exports: {} };
106
+ function Se(e) {
50
107
  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.');
51
108
  }
52
- var W = {}, ue = {
53
- get exports() {
54
- return W;
55
- },
56
- set exports(e) {
57
- W = e;
58
- }
59
- };
60
- const fe = {}, he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
109
+ var Q = { exports: {} };
110
+ const Ce = {}, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
61
111
  __proto__: null,
62
- default: fe
63
- }, Symbol.toStringTag, { value: "Module" })), le = /* @__PURE__ */ se(he);
64
- var J;
65
- function Z() {
66
- return J || (J = 1, function(e, r) {
67
- (function(n, i) {
68
- e.exports = i();
69
- })(P, function() {
70
- var n = n || function(i, p) {
71
- var l;
72
- if (typeof window < "u" && window.crypto && (l = window.crypto), typeof self < "u" && self.crypto && (l = self.crypto), typeof globalThis < "u" && globalThis.crypto && (l = globalThis.crypto), !l && typeof window < "u" && window.msCrypto && (l = window.msCrypto), !l && typeof P < "u" && P.crypto && (l = P.crypto), !l && typeof ce == "function")
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) {
117
+ (function(t, n) {
118
+ e.exports = n();
119
+ })(L, function() {
120
+ 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")
73
123
  try {
74
- l = le;
124
+ i = Ee;
75
125
  } catch {
76
126
  }
77
- var k = function() {
78
- if (l) {
79
- if (typeof l.getRandomValues == "function")
127
+ var v = function() {
128
+ if (i) {
129
+ if (typeof i.getRandomValues == "function")
80
130
  try {
81
- return l.getRandomValues(new Uint32Array(1))[0];
131
+ return i.getRandomValues(new Uint32Array(1))[0];
82
132
  } catch {
83
133
  }
84
- if (typeof l.randomBytes == "function")
134
+ if (typeof i.randomBytes == "function")
85
135
  try {
86
- return l.randomBytes(4).readInt32LE();
136
+ return i.randomBytes(4).readInt32LE();
87
137
  } catch {
88
138
  }
89
139
  }
90
140
  throw new Error("Native crypto module could not be used to get secure random number.");
91
- }, R = Object.create || function() {
92
- function t() {
141
+ }, k = Object.create || function() {
142
+ function o() {
93
143
  }
94
- return function(o) {
95
- var a;
96
- return t.prototype = o, a = new t(), t.prototype = null, a;
144
+ return function(s) {
145
+ var c;
146
+ return o.prototype = s, c = new o(), o.prototype = null, c;
97
147
  };
98
- }(), _ = {}, A = _.lib = {}, w = A.Base = function() {
148
+ }(), p = {}, y = p.lib = {}, m = y.Base = function() {
99
149
  return {
100
150
  /**
101
151
  * Creates a new object that inherits from this object.
@@ -115,11 +165,11 @@ function Z() {
115
165
  * }
116
166
  * });
117
167
  */
118
- extend: function(t) {
119
- var o = R(this);
120
- return t && o.mixIn(t), (!o.hasOwnProperty("init") || this.init === o.init) && (o.init = function() {
121
- o.$super.init.apply(this, arguments);
122
- }), o.init.prototype = o, o.$super = this, o;
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;
123
173
  },
124
174
  /**
125
175
  * Extends this object and runs the init method.
@@ -134,8 +184,8 @@ function Z() {
134
184
  * var instance = MyType.create();
135
185
  */
136
186
  create: function() {
137
- var t = this.extend();
138
- return t.init.apply(t, arguments), t;
187
+ var o = this.extend();
188
+ return o.init.apply(o, arguments), o;
139
189
  },
140
190
  /**
141
191
  * Initializes a newly created object.
@@ -162,10 +212,10 @@ function Z() {
162
212
  * field: 'value'
163
213
  * });
164
214
  */
165
- mixIn: function(t) {
166
- for (var o in t)
167
- t.hasOwnProperty(o) && (this[o] = t[o]);
168
- t.hasOwnProperty("toString") && (this.toString = t.toString);
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);
169
219
  },
170
220
  /**
171
221
  * Creates a copy of this object.
@@ -180,7 +230,7 @@ function Z() {
180
230
  return this.init.prototype.extend(this);
181
231
  }
182
232
  };
183
- }(), d = A.WordArray = w.extend({
233
+ }(), g = y.WordArray = m.extend({
184
234
  /**
185
235
  * Initializes a newly created word array.
186
236
  *
@@ -193,8 +243,8 @@ function Z() {
193
243
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
194
244
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
195
245
  */
196
- init: function(t, o) {
197
- t = this.words = t || [], o != p ? this.sigBytes = o : this.sigBytes = t.length * 4;
246
+ init: function(o, s) {
247
+ o = this.words = o || [], s != u ? this.sigBytes = s : this.sigBytes = o.length * 4;
198
248
  },
199
249
  /**
200
250
  * Converts this word array to a string.
@@ -209,8 +259,8 @@ function Z() {
209
259
  * var string = wordArray.toString();
210
260
  * var string = wordArray.toString(CryptoJS.enc.Utf8);
211
261
  */
212
- toString: function(t) {
213
- return (t || u).stringify(this);
262
+ toString: function(o) {
263
+ return (o || d).stringify(this);
214
264
  },
215
265
  /**
216
266
  * Concatenates a word array to this word array.
@@ -223,17 +273,17 @@ function Z() {
223
273
  *
224
274
  * wordArray1.concat(wordArray2);
225
275
  */
226
- concat: function(t) {
227
- var o = this.words, a = t.words, c = this.sigBytes, v = t.sigBytes;
228
- if (this.clamp(), c % 4)
229
- for (var y = 0; y < v; y++) {
230
- var m = a[y >>> 2] >>> 24 - y % 4 * 8 & 255;
231
- o[c + y >>> 2] |= m << 24 - (c + y) % 4 * 8;
276
+ concat: function(o) {
277
+ var s = this.words, c = o.words, h = this.sigBytes, _ = o.sigBytes;
278
+ 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;
232
282
  }
233
283
  else
234
- for (var b = 0; b < v; b += 4)
235
- o[c + b >>> 2] = a[b >>> 2];
236
- return this.sigBytes += v, this;
284
+ for (var C = 0; C < _; C += 4)
285
+ s[h + C >>> 2] = c[C >>> 2];
286
+ return this.sigBytes += _, this;
237
287
  },
238
288
  /**
239
289
  * Removes insignificant bits.
@@ -243,8 +293,8 @@ function Z() {
243
293
  * wordArray.clamp();
244
294
  */
245
295
  clamp: function() {
246
- var t = this.words, o = this.sigBytes;
247
- t[o >>> 2] &= 4294967295 << 32 - o % 4 * 8, t.length = i.ceil(o / 4);
296
+ var o = this.words, s = this.sigBytes;
297
+ o[s >>> 2] &= 4294967295 << 32 - s % 4 * 8, o.length = n.ceil(s / 4);
248
298
  },
249
299
  /**
250
300
  * Creates a copy of this word array.
@@ -256,8 +306,8 @@ function Z() {
256
306
  * var clone = wordArray.clone();
257
307
  */
258
308
  clone: function() {
259
- var t = w.clone.call(this);
260
- return t.words = this.words.slice(0), t;
309
+ var o = m.clone.call(this);
310
+ return o.words = this.words.slice(0), o;
261
311
  },
262
312
  /**
263
313
  * Creates a word array filled with random bytes.
@@ -272,12 +322,12 @@ function Z() {
272
322
  *
273
323
  * var wordArray = CryptoJS.lib.WordArray.random(16);
274
324
  */
275
- random: function(t) {
276
- for (var o = [], a = 0; a < t; a += 4)
277
- o.push(k());
278
- return new d.init(o, t);
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);
279
329
  }
280
- }), g = _.enc = {}, u = g.Hex = {
330
+ }), b = p.enc = {}, d = b.Hex = {
281
331
  /**
282
332
  * Converts a word array to a hex string.
283
333
  *
@@ -291,12 +341,12 @@ function Z() {
291
341
  *
292
342
  * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
293
343
  */
294
- stringify: function(t) {
295
- for (var o = t.words, a = t.sigBytes, c = [], v = 0; v < a; v++) {
296
- var y = o[v >>> 2] >>> 24 - v % 4 * 8 & 255;
297
- c.push((y >>> 4).toString(16)), c.push((y & 15).toString(16));
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));
298
348
  }
299
- return c.join("");
349
+ return h.join("");
300
350
  },
301
351
  /**
302
352
  * Converts a hex string to a word array.
@@ -311,12 +361,12 @@ function Z() {
311
361
  *
312
362
  * var wordArray = CryptoJS.enc.Hex.parse(hexString);
313
363
  */
314
- parse: function(t) {
315
- for (var o = t.length, a = [], c = 0; c < o; c += 2)
316
- a[c >>> 3] |= parseInt(t.substr(c, 2), 16) << 24 - c % 8 * 4;
317
- return new d.init(a, o / 2);
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);
318
368
  }
319
- }, h = g.Latin1 = {
369
+ }, l = b.Latin1 = {
320
370
  /**
321
371
  * Converts a word array to a Latin1 string.
322
372
  *
@@ -330,12 +380,12 @@ function Z() {
330
380
  *
331
381
  * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
332
382
  */
333
- stringify: function(t) {
334
- for (var o = t.words, a = t.sigBytes, c = [], v = 0; v < a; v++) {
335
- var y = o[v >>> 2] >>> 24 - v % 4 * 8 & 255;
336
- c.push(String.fromCharCode(y));
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));
337
387
  }
338
- return c.join("");
388
+ return h.join("");
339
389
  },
340
390
  /**
341
391
  * Converts a Latin1 string to a word array.
@@ -350,12 +400,12 @@ function Z() {
350
400
  *
351
401
  * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
352
402
  */
353
- parse: function(t) {
354
- for (var o = t.length, a = [], c = 0; c < o; c++)
355
- a[c >>> 2] |= (t.charCodeAt(c) & 255) << 24 - c % 4 * 8;
356
- return new d.init(a, o);
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);
357
407
  }
358
- }, s = g.Utf8 = {
408
+ }, a = b.Utf8 = {
359
409
  /**
360
410
  * Converts a word array to a UTF-8 string.
361
411
  *
@@ -369,9 +419,9 @@ function Z() {
369
419
  *
370
420
  * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
371
421
  */
372
- stringify: function(t) {
422
+ stringify: function(o) {
373
423
  try {
374
- return decodeURIComponent(escape(h.stringify(t)));
424
+ return decodeURIComponent(escape(l.stringify(o)));
375
425
  } catch {
376
426
  throw new Error("Malformed UTF-8 data");
377
427
  }
@@ -389,10 +439,10 @@ function Z() {
389
439
  *
390
440
  * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
391
441
  */
392
- parse: function(t) {
393
- return h.parse(unescape(encodeURIComponent(t)));
442
+ parse: function(o) {
443
+ return l.parse(unescape(encodeURIComponent(o)));
394
444
  }
395
- }, f = A.BufferedBlockAlgorithm = w.extend({
445
+ }, f = y.BufferedBlockAlgorithm = m.extend({
396
446
  /**
397
447
  * Resets this block algorithm's data buffer to its initial state.
398
448
  *
@@ -401,7 +451,7 @@ function Z() {
401
451
  * bufferedBlockAlgorithm.reset();
402
452
  */
403
453
  reset: function() {
404
- this._data = new d.init(), this._nDataBytes = 0;
454
+ this._data = new g.init(), this._nDataBytes = 0;
405
455
  },
406
456
  /**
407
457
  * Adds new data to this block algorithm's buffer.
@@ -413,8 +463,8 @@ function Z() {
413
463
  * bufferedBlockAlgorithm._append('data');
414
464
  * bufferedBlockAlgorithm._append(wordArray);
415
465
  */
416
- _append: function(t) {
417
- typeof t == "string" && (t = s.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes;
466
+ _append: function(o) {
467
+ typeof o == "string" && (o = a.parse(o)), this._data.concat(o), this._nDataBytes += o.sigBytes;
418
468
  },
419
469
  /**
420
470
  * Processes available data blocks.
@@ -430,16 +480,16 @@ function Z() {
430
480
  * var processedData = bufferedBlockAlgorithm._process();
431
481
  * var processedData = bufferedBlockAlgorithm._process(!!'flush');
432
482
  */
433
- _process: function(t) {
434
- var o, a = this._data, c = a.words, v = a.sigBytes, y = this.blockSize, m = y * 4, b = v / m;
435
- t ? b = i.ceil(b) : b = i.max((b | 0) - this._minBufferSize, 0);
436
- var $ = b * y, H = i.min($ * 4, v);
437
- if ($) {
438
- for (var E = 0; E < $; E += y)
439
- this._doProcessBlock(c, E);
440
- o = c.splice(0, $), a.sigBytes -= H;
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;
441
491
  }
442
- return new d.init(o, H);
492
+ return new g.init(s, H);
443
493
  },
444
494
  /**
445
495
  * Creates a copy of this object.
@@ -451,16 +501,16 @@ function Z() {
451
501
  * var clone = bufferedBlockAlgorithm.clone();
452
502
  */
453
503
  clone: function() {
454
- var t = w.clone.call(this);
455
- return t._data = this._data.clone(), t;
504
+ var o = m.clone.call(this);
505
+ return o._data = this._data.clone(), o;
456
506
  },
457
507
  _minBufferSize: 0
458
508
  });
459
- A.Hasher = f.extend({
509
+ y.Hasher = f.extend({
460
510
  /**
461
511
  * Configuration options.
462
512
  */
463
- cfg: w.extend(),
513
+ cfg: m.extend(),
464
514
  /**
465
515
  * Initializes a newly created hasher.
466
516
  *
@@ -470,8 +520,8 @@ function Z() {
470
520
  *
471
521
  * var hasher = CryptoJS.algo.SHA256.create();
472
522
  */
473
- init: function(t) {
474
- this.cfg = this.cfg.extend(t), this.reset();
523
+ init: function(o) {
524
+ this.cfg = this.cfg.extend(o), this.reset();
475
525
  },
476
526
  /**
477
527
  * Resets this hasher to its initial state.
@@ -495,8 +545,8 @@ function Z() {
495
545
  * hasher.update('message');
496
546
  * hasher.update(wordArray);
497
547
  */
498
- update: function(t) {
499
- return this._append(t), this._process(), this;
548
+ update: function(o) {
549
+ return this._append(o), this._process(), this;
500
550
  },
501
551
  /**
502
552
  * Finalizes the hash computation.
@@ -512,10 +562,10 @@ function Z() {
512
562
  * var hash = hasher.finalize('message');
513
563
  * var hash = hasher.finalize(wordArray);
514
564
  */
515
- finalize: function(t) {
516
- t && this._append(t);
517
- var o = this._doFinalize();
518
- return o;
565
+ finalize: function(o) {
566
+ o && this._append(o);
567
+ var s = this._doFinalize();
568
+ return s;
519
569
  },
520
570
  blockSize: 16,
521
571
  /**
@@ -531,9 +581,9 @@ function Z() {
531
581
  *
532
582
  * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
533
583
  */
534
- _createHelper: function(t) {
535
- return function(o, a) {
536
- return new t.init(a).finalize(o);
584
+ _createHelper: function(o) {
585
+ return function(s, c) {
586
+ return new o.init(c).finalize(s);
537
587
  };
538
588
  },
539
589
  /**
@@ -549,26 +599,26 @@ function Z() {
549
599
  *
550
600
  * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
551
601
  */
552
- _createHmacHelper: function(t) {
553
- return function(o, a) {
554
- return new x.HMAC.init(t, a).finalize(o);
602
+ _createHmacHelper: function(o) {
603
+ return function(s, c) {
604
+ return new x.HMAC.init(o, c).finalize(s);
555
605
  };
556
606
  }
557
607
  });
558
- var x = _.algo = {};
559
- return _;
608
+ var x = p.algo = {};
609
+ return p;
560
610
  }(Math);
561
- return n;
611
+ return t;
562
612
  });
563
- }(ue)), W;
613
+ }(Q)), Q.exports;
564
614
  }
565
615
  (function(e, r) {
566
- (function(n, i) {
567
- e.exports = i(Z());
568
- })(P, function(n) {
616
+ (function(t, n) {
617
+ e.exports = n(ne());
618
+ })(L, function(t) {
569
619
  return function() {
570
- var i = n, p = i.lib, l = p.WordArray, k = i.enc;
571
- k.Base64url = {
620
+ var n = t, u = n.lib, i = u.WordArray, v = n.enc;
621
+ v.Base64url = {
572
622
  /**
573
623
  * Converts a word array to a Base64url string.
574
624
  *
@@ -584,17 +634,18 @@ function Z() {
584
634
  *
585
635
  * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
586
636
  */
587
- stringify: function(_, A = !0) {
588
- var w = _.words, d = _.sigBytes, g = A ? this._safe_map : this._map;
589
- _.clamp();
590
- for (var u = [], h = 0; h < d; h += 3)
591
- for (var s = w[h >>> 2] >>> 24 - h % 4 * 8 & 255, f = w[h + 1 >>> 2] >>> 24 - (h + 1) % 4 * 8 & 255, x = w[h + 2 >>> 2] >>> 24 - (h + 2) % 4 * 8 & 255, t = s << 16 | f << 8 | x, o = 0; o < 4 && h + o * 0.75 < d; o++)
592
- u.push(g.charAt(t >>> 6 * (3 - o) & 63));
593
- var a = g.charAt(64);
594
- if (a)
595
- for (; u.length % 4; )
596
- u.push(a);
597
- return u.join("");
637
+ stringify: function(p, y) {
638
+ y === void 0 && (y = !0);
639
+ var m = p.words, g = p.sigBytes, b = y ? this._safe_map : this._map;
640
+ p.clamp();
641
+ 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)
646
+ for (; d.length % 4; )
647
+ d.push(c);
648
+ return d.join("");
598
649
  },
599
650
  /**
600
651
  * Converts a Base64url string to a word array.
@@ -611,267 +662,394 @@ function Z() {
611
662
  *
612
663
  * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
613
664
  */
614
- parse: function(_, A = !0) {
615
- var w = _.length, d = A ? this._safe_map : this._map, g = this._reverseMap;
616
- if (!g) {
617
- g = this._reverseMap = [];
618
- for (var u = 0; u < d.length; u++)
619
- g[d.charCodeAt(u)] = u;
665
+ parse: function(p, y) {
666
+ y === void 0 && (y = !0);
667
+ var m = p.length, g = y ? this._safe_map : this._map, b = this._reverseMap;
668
+ if (!b) {
669
+ b = this._reverseMap = [];
670
+ for (var d = 0; d < g.length; d++)
671
+ b[g.charCodeAt(d)] = d;
620
672
  }
621
- var h = d.charAt(64);
622
- if (h) {
623
- var s = _.indexOf(h);
624
- s !== -1 && (w = s);
673
+ var l = g.charAt(64);
674
+ if (l) {
675
+ var a = p.indexOf(l);
676
+ a !== -1 && (m = a);
625
677
  }
626
- return R(_, w, g);
678
+ return k(p, m, b);
627
679
  },
628
680
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
629
681
  _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
630
682
  };
631
- function R(_, A, w) {
632
- for (var d = [], g = 0, u = 0; u < A; u++)
633
- if (u % 4) {
634
- var h = w[_.charCodeAt(u - 1)] << u % 4 * 2, s = w[_.charCodeAt(u)] >>> 6 - u % 4 * 2, f = h | s;
635
- d[g >>> 2] |= f << 24 - g % 4 * 8, g++;
683
+ function k(p, y, m) {
684
+ for (var g = [], b = 0, d = 0; d < y; d++)
685
+ 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;
687
+ g[b >>> 2] |= f << 24 - b % 4 * 8, b++;
636
688
  }
637
- return l.create(d, g);
689
+ return i.create(g, b);
638
690
  }
639
- }(), n.enc.Base64url;
691
+ }(), t.enc.Base64url;
640
692
  });
641
- })(ae);
642
- var V = {}, pe = {
643
- get exports() {
644
- return V;
645
- },
646
- set exports(e) {
647
- V = e;
648
- }
649
- };
693
+ })(te);
694
+ var Ae = te.exports;
695
+ const Ie = /* @__PURE__ */ re(Ae);
696
+ var oe = { exports: {} };
650
697
  (function(e, r) {
651
- (function(n, i) {
652
- e.exports = i(Z());
653
- })(P, function(n) {
654
- return function(i) {
655
- var p = n, l = p.lib, k = l.WordArray, R = l.Hasher, _ = p.algo, A = [], w = [];
698
+ (function(t, n) {
699
+ e.exports = n(ne());
700
+ })(L, function(t) {
701
+ return function(n) {
702
+ var u = t, i = u.lib, v = i.WordArray, k = i.Hasher, p = u.algo, y = [], m = [];
656
703
  (function() {
657
- function u(x) {
658
- for (var t = i.sqrt(x), o = 2; o <= t; o++)
659
- if (!(x % o))
704
+ function d(x) {
705
+ for (var o = n.sqrt(x), s = 2; s <= o; s++)
706
+ if (!(x % s))
660
707
  return !1;
661
708
  return !0;
662
709
  }
663
- function h(x) {
710
+ function l(x) {
664
711
  return (x - (x | 0)) * 4294967296 | 0;
665
712
  }
666
- for (var s = 2, f = 0; f < 64; )
667
- u(s) && (f < 8 && (A[f] = h(i.pow(s, 1 / 2))), w[f] = h(i.pow(s, 1 / 3)), f++), s++;
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++;
668
715
  })();
669
- var d = [], g = _.SHA256 = R.extend({
716
+ var g = [], b = p.SHA256 = k.extend({
670
717
  _doReset: function() {
671
- this._hash = new k.init(A.slice(0));
718
+ this._hash = new v.init(y.slice(0));
672
719
  },
673
- _doProcessBlock: function(u, h) {
674
- for (var s = this._hash.words, f = s[0], x = s[1], t = s[2], o = s[3], a = s[4], c = s[5], v = s[6], y = s[7], m = 0; m < 64; m++) {
675
- if (m < 16)
676
- d[m] = u[h + m] | 0;
720
+ _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;
677
724
  else {
678
- var b = d[m - 15], $ = (b << 25 | b >>> 7) ^ (b << 14 | b >>> 18) ^ b >>> 3, H = d[m - 2], E = (H << 15 | H >>> 17) ^ (H << 13 | H >>> 19) ^ H >>> 10;
679
- d[m] = $ + d[m - 7] + E + d[m - 16];
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];
680
727
  }
681
- var Y = a & c ^ ~a & v, ee = f & x ^ f & t ^ x & t, re = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), te = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), G = y + te + Y + w[m] + d[m], ne = re + ee;
682
- y = v, v = c, c = a, a = o + G | 0, o = t, t = x, x = f, f = G + ne | 0;
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;
683
730
  }
684
- s[0] = s[0] + f | 0, s[1] = s[1] + x | 0, s[2] = s[2] + t | 0, s[3] = s[3] + o | 0, s[4] = s[4] + a | 0, s[5] = s[5] + c | 0, s[6] = s[6] + v | 0, s[7] = s[7] + y | 0;
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;
685
732
  },
686
733
  _doFinalize: function() {
687
- var u = this._data, h = u.words, s = this._nDataBytes * 8, f = u.sigBytes * 8;
688
- return h[f >>> 5] |= 128 << 24 - f % 32, h[(f + 64 >>> 9 << 4) + 14] = i.floor(s / 4294967296), h[(f + 64 >>> 9 << 4) + 15] = s, u.sigBytes = h.length * 4, this._process(), this._hash;
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;
689
736
  },
690
737
  clone: function() {
691
- var u = R.clone.call(this);
692
- return u._hash = this._hash.clone(), u;
738
+ var d = k.clone.call(this);
739
+ return d._hash = this._hash.clone(), d;
693
740
  }
694
741
  });
695
- p.SHA256 = R._createHelper(g), p.HmacSHA256 = R._createHmacHelper(g);
696
- }(Math), n.SHA256;
742
+ u.SHA256 = k._createHelper(b), u.HmacSHA256 = k._createHmacHelper(b);
743
+ }(Math), t.SHA256;
744
+ });
745
+ })(oe);
746
+ var Re = oe.exports;
747
+ const $e = /* @__PURE__ */ re(Re), Te = (e, r) => {
748
+ const {
749
+ client_id: t,
750
+ redirect_uri: n,
751
+ scope: u,
752
+ state: i,
753
+ chainId: v,
754
+ chain: k,
755
+ network: p,
756
+ address: y,
757
+ signature: m
758
+ } = e, g = y ? {
759
+ address: y,
760
+ ...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 } : {}
763
+ } : {};
764
+ return D({
765
+ client_id: t,
766
+ redirect_uri: n,
767
+ ...u !== void 0 ? { scope: u } : {},
768
+ ...i !== void 0 ? { state: i } : {},
769
+ code_challenge: r,
770
+ code_challenge_method: "S256",
771
+ response_type: "code",
772
+ ...g
697
773
  });
698
- })(pe);
699
- const de = () => {
774
+ }, ze = () => {
700
775
  let e = "";
701
- const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = r.length;
702
- let i = 0;
703
- for (; i < 128; )
704
- e += r.charAt(Math.floor(Math.random() * n)), i += 1;
776
+ const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = r.length;
777
+ let n = 0;
778
+ for (; n < 128; )
779
+ e += r.charAt(Math.floor(Math.random() * t)), n += 1;
705
780
  return e;
706
- }, ve = async (e, r, n, i) => {
707
- const p = await fetch(`${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 = () => {
785
+ const e = window.location.href, [r, t] = e.split("?");
786
+ 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) => {
788
+ const u = await fetch(`${e}`, {
708
789
  method: r,
709
- headers: i,
710
- body: n
790
+ headers: n,
791
+ body: t
711
792
  });
712
- let l;
713
- const k = await p.text();
793
+ let i;
794
+ const v = await u.text();
714
795
  try {
715
- l = JSON.parse(k);
796
+ i = JSON.parse(v);
716
797
  } catch {
717
- throw k;
718
- }
719
- if (!p.ok)
720
- throw l;
721
- return l;
722
- }, ge = (e) => {
723
- if (e.toString() === "Invalid Date")
724
- throw e;
725
- const r = (i) => i < 10 ? "0" + i : i, n = (i) => {
726
- if (i === 0)
727
- return "Z";
728
- const p = i > 0 ? "-" : "+";
729
- return i = Math.abs(i), p + r(Math.floor(i / 60)) + ":" + r(i % 60);
730
- };
731
- return e.getFullYear() + "-" + r(e.getMonth() + 1) + "-" + r(e.getDate()) + "T" + r(e.getHours()) + ":" + r(e.getMinutes()) + ":" + r(e.getSeconds()) + n(e.getTimezoneOffset());
732
- }, He = (e, r) => `Send EUR ${e} to ${r} at ${ge(/* @__PURE__ */ new Date())}`, T = (e) => {
733
- var r;
734
- return e && ((r = Object.entries(e)) == null ? void 0 : r.length) > 0 ? Object.entries(e).map(
735
- ([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(i)}`
736
- ).join("&") : "";
737
- }, ye = {
738
- environments: {
739
- production: {
740
- api: "https://api.monerium.app",
741
- web: "https://monerium.app"
742
- },
743
- sandbox: {
744
- api: "https://api.monerium.dev",
745
- web: "https://sandbox.monerium.dev"
746
- }
798
+ throw v;
747
799
  }
748
- };
749
- var z, q, C, S, j, Q, U, X, L, K;
750
- class Oe {
751
- constructor(r = "sandbox") {
800
+ 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 {
806
+ constructor(r) {
752
807
  // -- Helper Methods
753
- O(this, C);
754
- O(this, j);
755
- O(this, U);
756
- O(this, L);
757
- O(this, z, void 0);
758
- O(this, q, void 0);
759
- /** The PKCE code verifier */
760
- I(this, "codeVerifier");
761
- I(this, "bearerProfile");
762
- /**
763
- * @deprecated since v2.0.7, use {@link getAuthFlowURI} instead.
764
- */
765
- I(this, "pkceRequest", (r) => this.getAuthFlowURI(r));
766
- F(this, z, ye.environments[r]);
767
- }
768
- // -- Authentication
769
- async auth(r) {
770
- let n;
771
- if (B(this, j, Q).call(this, r))
772
- n = { ...r, grant_type: "authorization_code" };
773
- else if (B(this, U, X).call(this, r))
774
- n = { ...r, grant_type: "refresh_token" };
775
- else if (B(this, L, K).call(this, r))
776
- n = { ...r, grant_type: "client_credentials" };
777
- else
778
- throw new Error("Authentication method could not be detected.");
779
- return this.bearerProfile = await B(this, C, S).call(this, "post", "auth/token", n, !0), F(this, q, `Bearer ${this.bearerProfile.access_token}`), this.bearerProfile;
808
+ z(this, E);
809
+ z(this, $, void 0);
810
+ z(this, F, void 0);
811
+ /** 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)
821
+ throw new Error("Code verifier not found");
822
+ return this.codeVerifier = i, sessionStorage.removeItem(P), await this.getBearerToken({
823
+ code: u,
824
+ redirect_uri: n,
825
+ client_id: t,
826
+ code_verifier: i
827
+ });
828
+ }), A(this, N, async ({
829
+ clientId: t,
830
+ clientSecret: n
831
+ }) => await this.getBearerToken({
832
+ client_id: t,
833
+ client_secret: n
834
+ })), A(this, W, async (t, n) => await this.getBearerToken({
835
+ refresh_token: n,
836
+ client_id: t
837
+ })), 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);
840
+ return n.addEventListener("open", () => {
841
+ console.info(`Socket connected: ${t}`);
842
+ }), n.addEventListener("error", (v) => {
843
+ throw console.error(v), new Error(`Socket error: ${t}`);
844
+ }), n.addEventListener("message", (v) => {
845
+ var p;
846
+ const k = JSON.parse(v.data);
847
+ (p = w(this, U).get(k.meta.state)) == null || p(
848
+ k
849
+ );
850
+ }), n.addEventListener("close", () => {
851
+ console.info(`Socket connection closed: ${t}`);
852
+ }), 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);
858
+ return;
859
+ }
860
+ if (typeof r == "string")
861
+ A(this, $, J.environments[r]);
862
+ else if (A(this, $, J.environments[r.environment || "sandbox"]), Z) {
863
+ const { clientId: t, clientSecret: n } = r;
864
+ A(this, T, {
865
+ clientId: t,
866
+ clientSecret: n
867
+ });
868
+ } else {
869
+ const { clientId: t, redirectUrl: n } = r;
870
+ A(this, T, {
871
+ clientId: t,
872
+ redirectUrl: n
873
+ });
874
+ }
780
875
  }
781
876
  /**
782
877
  * Construct the url to the authorization code flow,
783
- * the code verifier is needed afterwards to obtain an access token and is therefore stored in `this.codeVerifier`
784
- * For automatic wallet link, add the following properties: `address`, `signature`, `chain` & `network`
878
+ * Code Verifier needed for the code challenge is stored in session storage
879
+ * For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
785
880
  * @returns string
881
+ * {@link https://monerium.dev/api-docs#operation/auth}
786
882
  */
787
- getAuthFlowURI(r) {
788
- this.codeVerifier = de();
789
- const n = N.stringify(
790
- V(this.codeVerifier)
791
- ), i = {
792
- ...r,
793
- client_id: r == null ? void 0 : r.client_id,
794
- code_challenge: n,
795
- code_challenge_method: "S256",
796
- response_type: "code"
797
- };
798
- return `${M(this, z).api}/auth?${T(i)}`;
883
+ 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);
886
+ if (!t)
887
+ throw new Error("Missing ClientId");
888
+ if (!n)
889
+ throw new Error("Missing RedirectUrl");
890
+ const u = Y(w(this, $).api, {
891
+ client_id: t,
892
+ redirect_uri: n,
893
+ address: r == null ? void 0 : r.address,
894
+ signature: r == null ? void 0 : r.signature,
895
+ chainId: r == null ? void 0 : r.chainId
896
+ });
897
+ window.location.replace(u);
898
+ }
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)
904
+ throw new Error("Only use client credentials on server side");
905
+ return await w(this, N).call(this, w(this, T)), !!this.bearerProfile;
906
+ }
907
+ const u = (r == null ? void 0 : r.redirectUrl) || ((y = w(this, T)) == null ? void 0 : y.redirectUrl);
908
+ if (!t)
909
+ 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;
799
937
  }
800
938
  // -- Read Methods
939
+ /**
940
+ * {@link https://monerium.dev/api-docs#operation/auth-context}
941
+ */
801
942
  getAuthContext() {
802
- return B(this, C, S).call(this, "get", "auth/context");
943
+ return I(this, E, R).call(this, "get", "auth/context");
803
944
  }
804
945
  /**
805
- * @param {string} profileId - the id of the profile to fetch.
806
- */
946
+ * {@link https://monerium.dev/api-docs#operation/profile}
947
+ * @param {string} profileId - the id of the profile to fetch.
948
+
949
+ */
807
950
  getProfile(r) {
808
- return B(this, C, S).call(this, "get", `profiles/${r}`);
951
+ return I(this, E, R).call(this, "get", `profiles/${r}`);
809
952
  }
810
953
  /**
954
+ * {@link https://monerium.dev/api-docs#operation/profile-balances}
811
955
  * @param {string=} profileId - the id of the profile to fetch balances.
812
956
  */
813
957
  getBalances(r) {
814
- return r ? B(this, C, S).call(this, "get", `profiles/${r}/balances`) : B(this, C, S).call(this, "get", "balances");
958
+ return r ? I(this, E, R).call(this, "get", `profiles/${r}/balances`) : I(this, E, R).call(this, "get", "balances");
815
959
  }
960
+ /**
961
+ * {@link https://monerium.dev/api-docs#operation/orders}
962
+ */
816
963
  getOrders(r) {
817
- const n = T(r);
818
- return B(this, C, S).call(this, "get", `orders?${n}`);
964
+ const t = D(r);
965
+ return I(this, E, R).call(this, "get", `orders?${t}`);
819
966
  }
967
+ /**
968
+ * {@link https://monerium.dev/api-docs#operation/order}
969
+ */
820
970
  getOrder(r) {
821
- return B(this, C, S).call(this, "get", `orders/${r}`);
971
+ return I(this, E, R).call(this, "get", `orders/${r}`);
822
972
  }
973
+ /**
974
+ * {@link https://monerium.dev/api-docs#operation/tokens}
975
+ */
823
976
  getTokens() {
824
- return B(this, C, S).call(this, "get", "tokens");
977
+ return I(this, E, R).call(this, "get", "tokens");
825
978
  }
826
979
  // -- Write Methods
827
- linkAddress(r, n) {
828
- return B(this, C, S).call(this, "post", `profiles/${r}/addresses`, JSON.stringify(n));
980
+ /**
981
+ * {@link https://monerium.dev/api-docs#operation/profile-addresses}
982
+ */
983
+ linkAddress(r, t) {
984
+ return I(this, E, R).call(this, "post", `profiles/${r}/addresses`, JSON.stringify(t));
829
985
  }
830
- placeOrder(r, n) {
831
- const i = { ...r, kind: "redeem", currency: "eur" };
832
- return n ? B(this, C, S).call(this, "post", `profiles/${n}/orders`, JSON.stringify(i)) : B(this, C, S).call(this, "post", "orders", JSON.stringify(i));
986
+ /**
987
+ * {@link https://monerium.dev/api-docs#operation/post-orders}
988
+ */
989
+ placeOrder(r, t) {
990
+ 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));
833
992
  }
993
+ /**
994
+ * {@link https://monerium.dev/api-docs#operation/supporting-document}
995
+ */
834
996
  uploadSupportingDocument(r) {
835
- const n = T(
997
+ const t = D(
836
998
  r
837
999
  );
838
- return B(this, C, S).call(this, "post", "files/supporting-document", n, !0);
1000
+ return I(this, E, R).call(this, "post", "files/supporting-document", t, !0);
1001
+ }
1002
+ // -- Notifications
1003
+ async connectOrderSocket() {
1004
+ var r;
1005
+ (r = this.bearerProfile) != null && r.access_token && w(this, U).size > 0 && A(this, O, this.subscribeToOrderNotifications());
1006
+ }
1007
+ async disconnect() {
1008
+ var r;
1009
+ sessionStorage.removeItem(P), w(this, U).clear(), (r = w(this, O)) == null || r.close();
1010
+ }
1011
+ /**
1012
+ * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
1013
+ * We are setting a subscription map because we need the user to have a token to start the WebSocket connection
1014
+ * {@link https://monerium.dev/api-docs#operation/profile-orders-notifications}
1015
+ * @param event The event to subscribe to
1016
+ * @param handler The handler to be called when the event is triggered
1017
+ */
1018
+ subscribeOrders(r, t) {
1019
+ w(this, U).set(r, t);
1020
+ }
1021
+ /**
1022
+ * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
1023
+ * @param event The event to unsubscribe from
1024
+ */
1025
+ unsubscribeOrders(r) {
1026
+ 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));
839
1028
  }
840
1029
  }
841
- z = new WeakMap(), q = new WeakMap(), C = new WeakSet(), S = async function(r, n, i, p) {
842
- return ve(
843
- `${M(this, z).api}/${n}`,
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}`,
844
1033
  r,
845
- p ? T(i) : i,
1034
+ u ? D(n) : n,
846
1035
  {
847
- Authorization: M(this, q) || "",
848
- "Content-Type": `application/${p ? "x-www-form-urlencoded" : "json"}`
1036
+ Authorization: w(this, F) || "",
1037
+ "Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
849
1038
  }
850
1039
  );
851
- }, j = new WeakSet(), Q = function(r) {
852
- return r.code != null;
853
- }, U = new WeakSet(), X = function(r) {
854
- return r.refresh_token != null;
855
- }, L = new WeakSet(), K = function(r) {
856
- return r.client_secret != null;
857
- };
858
- const we = "I hereby declare that I am the address owner.", $e = {
859
- LINK_MESSAGE: we
860
- };
861
- var _e = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(_e || {}), me = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(me || {}), be = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(be || {}), Be = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(Be || {}), xe = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(xe || {}), Ce = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(Ce || {}), Ae = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(Ae || {}), Se = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(Se || {}), Re = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(Re || {});
1040
+ }, j = new WeakMap(), N = new WeakMap(), W = new WeakMap();
862
1041
  export {
863
- Ce as AccountState,
864
- _e as Currency,
865
- xe as KYCOutcome,
866
- Be as KYCState,
867
- Oe as MoneriumClient,
868
- Se as OrderKind,
869
- Re as OrderState,
870
- Ae as PaymentStandard,
871
- be as Permission,
872
- me as ProfileType,
873
- $e as constants,
874
- He as placeOrderMessage,
875
- ge as rfc3339
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
876
1055
  };
877
- //# sourceMappingURL=index.mjs.map