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