@monerium/sdk 2.7.1 → 2.7.3
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 +185 -1
- package/README.md +33 -2
- package/dist/client.d.ts +18 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +376 -363
- package/dist/package.json +1 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
if (!
|
|
3
|
-
throw TypeError("Cannot " +
|
|
1
|
+
var Z = (e, t, r) => {
|
|
2
|
+
if (!t.has(e))
|
|
3
|
+
throw TypeError("Cannot " + r);
|
|
4
4
|
};
|
|
5
|
-
var w = (e,
|
|
6
|
-
if (
|
|
5
|
+
var w = (e, t, r) => (Z(e, t, "read from private field"), r ? r.call(e) : t.get(e)), $ = (e, t, r) => {
|
|
6
|
+
if (t.has(e))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
const
|
|
8
|
+
t instanceof WeakSet ? t.add(e) : t.set(e, r);
|
|
9
|
+
}, I = (e, t, r, n) => (Z(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
|
|
10
|
+
var k = (e, t, r) => (Z(e, t, "access private method"), r);
|
|
11
|
+
var le = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(be || {});
|
|
12
|
+
const Se = (e) => {
|
|
13
13
|
if (e.toString() === "Invalid Date")
|
|
14
14
|
throw e;
|
|
15
|
-
const
|
|
15
|
+
const t = (n) => n < 10 ? "0" + n : n, r = (n) => {
|
|
16
16
|
if (n === 0)
|
|
17
17
|
return "Z";
|
|
18
18
|
const u = n > 0 ? "-" : "+";
|
|
19
|
-
return n = Math.abs(n), u +
|
|
19
|
+
return n = Math.abs(n), u + t(Math.floor(n / 60)) + ":" + t(n % 60);
|
|
20
20
|
};
|
|
21
|
-
return e.getFullYear() + "-" +
|
|
22
|
-
},
|
|
23
|
-
var
|
|
24
|
-
return e && ((
|
|
25
|
-
([
|
|
21
|
+
return e.getFullYear() + "-" + t(e.getMonth() + 1) + "-" + t(e.getDate()) + "T" + t(e.getHours()) + ":" + t(e.getMinutes()) + ":" + t(e.getSeconds()) + r(e.getTimezoneOffset());
|
|
22
|
+
}, Fe = (e, t) => `Send EUR ${e} to ${t} at ${Se(/* @__PURE__ */ new Date())}`, Q = (e) => {
|
|
23
|
+
var t;
|
|
24
|
+
return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
|
|
25
|
+
([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
|
|
26
26
|
).join("&") : "";
|
|
27
|
-
},
|
|
27
|
+
}, Be = (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
|
-
},
|
|
41
|
+
}, ke = (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
|
-
},
|
|
56
|
+
}, X = {
|
|
57
57
|
environments: {
|
|
58
58
|
production: {
|
|
59
59
|
api: "https://api.monerium.app",
|
|
@@ -66,84 +66,78 @@ const me = (e) => {
|
|
|
66
66
|
wss: "wss://api.monerium.dev"
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
},
|
|
70
|
-
LINK_MESSAGE:
|
|
71
|
-
STORAGE_CODE_VERIFIER:
|
|
72
|
-
STORAGE_REFRESH_TOKEN:
|
|
69
|
+
}, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", Ne = {
|
|
70
|
+
LINK_MESSAGE: Ce,
|
|
71
|
+
STORAGE_CODE_VERIFIER: M,
|
|
72
|
+
STORAGE_REFRESH_TOKEN: W
|
|
73
73
|
};
|
|
74
|
-
var
|
|
75
|
-
function
|
|
74
|
+
var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
75
|
+
function se(e) {
|
|
76
76
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function xe(e) {
|
|
79
79
|
if (e.__esModule)
|
|
80
80
|
return e;
|
|
81
|
-
var
|
|
82
|
-
if (typeof
|
|
83
|
-
var
|
|
84
|
-
|
|
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);
|
|
81
|
+
var t = e.default;
|
|
82
|
+
if (typeof t == "function") {
|
|
83
|
+
var r = function n() {
|
|
84
|
+
return this instanceof n ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
|
|
91
85
|
};
|
|
92
|
-
|
|
86
|
+
r.prototype = t.prototype;
|
|
93
87
|
} else
|
|
94
|
-
|
|
95
|
-
return Object.defineProperty(
|
|
88
|
+
r = {};
|
|
89
|
+
return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
|
|
96
90
|
var u = Object.getOwnPropertyDescriptor(e, n);
|
|
97
|
-
Object.defineProperty(
|
|
91
|
+
Object.defineProperty(r, n, u.get ? u : {
|
|
98
92
|
enumerable: !0,
|
|
99
93
|
get: function() {
|
|
100
94
|
return e[n];
|
|
101
95
|
}
|
|
102
96
|
});
|
|
103
|
-
}),
|
|
97
|
+
}), r;
|
|
104
98
|
}
|
|
105
|
-
var
|
|
106
|
-
function
|
|
99
|
+
var oe = { exports: {} };
|
|
100
|
+
function Ae(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
|
|
110
|
-
const
|
|
103
|
+
var K = { exports: {} };
|
|
104
|
+
const Ee = {}, Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
111
105
|
__proto__: null,
|
|
112
|
-
default:
|
|
113
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
114
|
-
var
|
|
115
|
-
function
|
|
116
|
-
return
|
|
117
|
-
(function(
|
|
106
|
+
default: Ee
|
|
107
|
+
}, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ xe(Ie);
|
|
108
|
+
var ee;
|
|
109
|
+
function ie() {
|
|
110
|
+
return ee || (ee = 1, function(e, t) {
|
|
111
|
+
(function(r, n) {
|
|
118
112
|
e.exports = n();
|
|
119
|
-
})(
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
if (typeof window < "u" && window.crypto && (
|
|
113
|
+
})(F, function() {
|
|
114
|
+
var r = r || function(n, u) {
|
|
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 Ae == "function")
|
|
123
117
|
try {
|
|
124
|
-
|
|
118
|
+
c = Re;
|
|
125
119
|
} catch {
|
|
126
120
|
}
|
|
127
121
|
var v = function() {
|
|
128
|
-
if (
|
|
129
|
-
if (typeof
|
|
122
|
+
if (c) {
|
|
123
|
+
if (typeof c.getRandomValues == "function")
|
|
130
124
|
try {
|
|
131
|
-
return
|
|
125
|
+
return c.getRandomValues(new Uint32Array(1))[0];
|
|
132
126
|
} catch {
|
|
133
127
|
}
|
|
134
|
-
if (typeof
|
|
128
|
+
if (typeof c.randomBytes == "function")
|
|
135
129
|
try {
|
|
136
|
-
return
|
|
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
|
-
},
|
|
142
|
-
function
|
|
135
|
+
}, B = Object.create || function() {
|
|
136
|
+
function s() {
|
|
143
137
|
}
|
|
144
|
-
return function(
|
|
145
|
-
var
|
|
146
|
-
return
|
|
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(
|
|
169
|
-
var
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
}),
|
|
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
|
|
188
|
-
return
|
|
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(
|
|
216
|
-
for (var
|
|
217
|
-
|
|
218
|
-
|
|
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(
|
|
247
|
-
|
|
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(
|
|
263
|
-
return (
|
|
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(
|
|
277
|
-
var
|
|
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
|
|
280
|
-
var
|
|
281
|
-
|
|
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
|
|
285
|
-
|
|
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
|
|
297
|
-
o
|
|
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
|
|
310
|
-
return
|
|
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(
|
|
326
|
-
for (var
|
|
327
|
-
|
|
328
|
-
return new g.init(
|
|
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(
|
|
345
|
-
for (var
|
|
346
|
-
var
|
|
347
|
-
h.push((
|
|
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(
|
|
365
|
-
for (var
|
|
366
|
-
|
|
367
|
-
return new g.init(
|
|
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(
|
|
384
|
-
for (var
|
|
385
|
-
var
|
|
386
|
-
h.push(String.fromCharCode(
|
|
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(
|
|
404
|
-
for (var
|
|
405
|
-
|
|
406
|
-
return new g.init(
|
|
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
|
-
},
|
|
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(
|
|
416
|
+
stringify: function(s) {
|
|
423
417
|
try {
|
|
424
|
-
return decodeURIComponent(escape(l.stringify(
|
|
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(
|
|
443
|
-
return l.parse(unescape(encodeURIComponent(
|
|
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(
|
|
467
|
-
typeof
|
|
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(
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
var
|
|
487
|
-
if (
|
|
488
|
-
for (var
|
|
489
|
-
this._doProcessBlock(h,
|
|
490
|
-
|
|
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(
|
|
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
|
|
505
|
-
return
|
|
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(
|
|
524
|
-
this.cfg = this.cfg.extend(
|
|
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(
|
|
549
|
-
return this._append(
|
|
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(
|
|
566
|
-
|
|
567
|
-
var
|
|
568
|
-
return
|
|
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(
|
|
585
|
-
return function(
|
|
586
|
-
return new
|
|
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(
|
|
603
|
-
return function(
|
|
604
|
-
return new
|
|
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
|
|
602
|
+
var A = p.algo = {};
|
|
609
603
|
return p;
|
|
610
604
|
}(Math);
|
|
611
|
-
return
|
|
605
|
+
return r;
|
|
612
606
|
});
|
|
613
|
-
}(
|
|
607
|
+
}(K)), K.exports;
|
|
614
608
|
}
|
|
615
|
-
(function(e,
|
|
616
|
-
(function(
|
|
617
|
-
e.exports = n(
|
|
618
|
-
})(
|
|
609
|
+
(function(e, t) {
|
|
610
|
+
(function(r, n) {
|
|
611
|
+
e.exports = n(ie());
|
|
612
|
+
})(F, function(r) {
|
|
619
613
|
return function() {
|
|
620
|
-
var n =
|
|
614
|
+
var n = r, 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
|
|
643
|
-
d.push(b.charAt(
|
|
644
|
-
var
|
|
645
|
-
if (
|
|
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(
|
|
641
|
+
d.push(a);
|
|
648
642
|
return d.join("");
|
|
649
643
|
},
|
|
650
644
|
/**
|
|
@@ -672,203 +666,210 @@ function ne() {
|
|
|
672
666
|
}
|
|
673
667
|
var l = g.charAt(64);
|
|
674
668
|
if (l) {
|
|
675
|
-
var
|
|
676
|
-
|
|
669
|
+
var i = p.indexOf(l);
|
|
670
|
+
i !== -1 && (m = i);
|
|
677
671
|
}
|
|
678
|
-
return
|
|
672
|
+
return B(p, m, b);
|
|
679
673
|
},
|
|
680
674
|
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
681
675
|
_safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
|
682
676
|
};
|
|
683
|
-
function
|
|
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,
|
|
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
|
|
683
|
+
return c.create(g, b);
|
|
690
684
|
}
|
|
691
|
-
}(),
|
|
685
|
+
}(), r.enc.Base64url;
|
|
692
686
|
});
|
|
693
|
-
})(
|
|
694
|
-
var
|
|
695
|
-
const
|
|
696
|
-
var
|
|
697
|
-
(function(e,
|
|
698
|
-
(function(
|
|
699
|
-
e.exports = n(
|
|
700
|
-
})(
|
|
687
|
+
})(oe);
|
|
688
|
+
var $e = oe.exports;
|
|
689
|
+
const ze = /* @__PURE__ */ se($e);
|
|
690
|
+
var ae = { exports: {} };
|
|
691
|
+
(function(e, t) {
|
|
692
|
+
(function(r, n) {
|
|
693
|
+
e.exports = n(ie());
|
|
694
|
+
})(F, function(r) {
|
|
701
695
|
return function(n) {
|
|
702
|
-
var u =
|
|
696
|
+
var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
|
|
703
697
|
(function() {
|
|
704
|
-
function d(
|
|
705
|
-
for (var
|
|
706
|
-
if (!(
|
|
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(
|
|
711
|
-
return (
|
|
704
|
+
function l(A) {
|
|
705
|
+
return (A - (A | 0)) * 4294967296 | 0;
|
|
712
706
|
}
|
|
713
|
-
for (var
|
|
714
|
-
d(
|
|
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 =
|
|
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
|
|
722
|
-
if (
|
|
723
|
-
g[
|
|
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
|
|
726
|
-
g[
|
|
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
|
|
729
|
-
|
|
722
|
+
var ce = a & h ^ ~a & _, ue = f & A ^ f & s ^ A & s, he = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), de = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + de + ce + m[C] + g[C], fe = he + ue;
|
|
723
|
+
S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + fe | 0;
|
|
730
724
|
}
|
|
731
|
-
|
|
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,
|
|
735
|
-
return l[f >>> 5] |= 128 << 24 - f % 32, l[(f + 64 >>> 9 << 4) + 14] = n.floor(
|
|
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 =
|
|
732
|
+
var d = B.clone.call(this);
|
|
739
733
|
return d._hash = this._hash.clone(), d;
|
|
740
734
|
}
|
|
741
735
|
});
|
|
742
|
-
u.SHA256 =
|
|
743
|
-
}(Math),
|
|
736
|
+
u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
|
|
737
|
+
}(Math), r.SHA256;
|
|
744
738
|
});
|
|
745
|
-
})(
|
|
746
|
-
var
|
|
747
|
-
const
|
|
739
|
+
})(ae);
|
|
740
|
+
var Ue = ae.exports;
|
|
741
|
+
const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
|
|
748
742
|
const {
|
|
749
|
-
client_id:
|
|
743
|
+
client_id: r,
|
|
750
744
|
redirect_uri: n,
|
|
751
745
|
scope: u,
|
|
752
|
-
state:
|
|
746
|
+
state: c,
|
|
753
747
|
chainId: v,
|
|
754
|
-
chain:
|
|
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 ||
|
|
762
|
-
...v !== void 0 || p !== void 0 ? { network: v ?
|
|
755
|
+
...v !== void 0 || B !== void 0 ? { chain: v ? Be(v) : B } : {},
|
|
756
|
+
...v !== void 0 || p !== void 0 ? { network: v ? ke(v) : p } : {}
|
|
763
757
|
} : {};
|
|
764
|
-
return
|
|
765
|
-
client_id:
|
|
758
|
+
return Q({
|
|
759
|
+
client_id: r,
|
|
766
760
|
redirect_uri: n,
|
|
767
761
|
...u !== void 0 ? { scope: u } : {},
|
|
768
|
-
...
|
|
769
|
-
code_challenge:
|
|
762
|
+
...c !== void 0 ? { state: c } : {},
|
|
763
|
+
code_challenge: t,
|
|
770
764
|
code_challenge_method: "S256",
|
|
771
765
|
response_type: "code",
|
|
772
766
|
...g
|
|
773
767
|
});
|
|
774
|
-
},
|
|
768
|
+
}, Oe = () => {
|
|
775
769
|
let e = "";
|
|
776
|
-
const
|
|
770
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length;
|
|
777
771
|
let n = 0;
|
|
778
772
|
for (; n < 128; )
|
|
779
|
-
e +=
|
|
773
|
+
e += t.charAt(Math.floor(Math.random() * r)), n += 1;
|
|
780
774
|
return e;
|
|
781
|
-
},
|
|
782
|
-
const
|
|
783
|
-
return sessionStorage.setItem(
|
|
784
|
-
},
|
|
785
|
-
const e = window.location.href
|
|
786
|
-
|
|
787
|
-
|
|
775
|
+
}, Te = (e) => ze.stringify(He(e)), te = (e, t) => {
|
|
776
|
+
const r = Oe(), n = Te(r);
|
|
777
|
+
return sessionStorage.setItem(M, r || ""), `${e}/auth?${Pe(t, n)}`;
|
|
778
|
+
}, re = () => {
|
|
779
|
+
const e = window.location.href;
|
|
780
|
+
if (!e || !(e != null && e.includes("?")))
|
|
781
|
+
return;
|
|
782
|
+
const [t, r] = e.split("?");
|
|
783
|
+
r && window.history.replaceState(null, "", t);
|
|
784
|
+
}, ne = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, t, r, n) => {
|
|
788
785
|
const u = await fetch(`${e}`, {
|
|
789
|
-
method:
|
|
786
|
+
method: t,
|
|
790
787
|
headers: n,
|
|
791
|
-
body:
|
|
788
|
+
body: r
|
|
792
789
|
});
|
|
793
|
-
let
|
|
790
|
+
let c;
|
|
794
791
|
const v = await u.text();
|
|
795
792
|
try {
|
|
796
|
-
|
|
793
|
+
c = JSON.parse(v);
|
|
797
794
|
} catch {
|
|
798
795
|
throw v;
|
|
799
796
|
}
|
|
800
797
|
if (!u.ok)
|
|
801
|
-
throw
|
|
802
|
-
return
|
|
803
|
-
},
|
|
804
|
-
var
|
|
805
|
-
class
|
|
806
|
-
constructor(
|
|
798
|
+
throw c;
|
|
799
|
+
return c;
|
|
800
|
+
}, T = typeof window > "u";
|
|
801
|
+
var z, D, L, H, U, O, j, E, R, V, G, J;
|
|
802
|
+
class We {
|
|
803
|
+
constructor(t) {
|
|
804
|
+
/**
|
|
805
|
+
* {@link https://monerium.dev/api-docs#operation/auth-token}
|
|
806
|
+
*/
|
|
807
|
+
$(this, O);
|
|
807
808
|
// -- Helper Methods
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
809
|
+
$(this, E);
|
|
810
|
+
$(this, z, void 0);
|
|
811
|
+
$(this, D, void 0);
|
|
811
812
|
/** The socket will be available after subscribing to an event */
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
if (
|
|
819
|
-
const
|
|
820
|
-
if (!
|
|
813
|
+
$(this, L, void 0);
|
|
814
|
+
$(this, H, void 0);
|
|
815
|
+
$(this, U, void 0);
|
|
816
|
+
$(this, V, void 0);
|
|
817
|
+
$(this, G, void 0);
|
|
818
|
+
$(this, J, void 0);
|
|
819
|
+
if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
|
|
820
|
+
const c = sessionStorage.getItem(M) || "";
|
|
821
|
+
if (!c)
|
|
821
822
|
throw new Error("Code verifier not found");
|
|
822
|
-
return this.codeVerifier =
|
|
823
|
+
return this.codeVerifier = c, sessionStorage.removeItem(M), await k(this, O, j).call(this, {
|
|
823
824
|
code: u,
|
|
824
825
|
redirect_uri: n,
|
|
825
|
-
client_id:
|
|
826
|
-
code_verifier:
|
|
826
|
+
client_id: r,
|
|
827
|
+
code_verifier: c
|
|
827
828
|
});
|
|
828
|
-
}),
|
|
829
|
-
clientId:
|
|
829
|
+
}), I(this, G, async ({
|
|
830
|
+
clientId: r,
|
|
830
831
|
clientSecret: n
|
|
831
|
-
}) => await this.
|
|
832
|
-
client_id:
|
|
832
|
+
}) => await k(this, O, j).call(this, {
|
|
833
|
+
client_id: r,
|
|
833
834
|
client_secret: n
|
|
834
|
-
})),
|
|
835
|
+
})), I(this, J, async (r, n) => await k(this, O, j).call(this, {
|
|
835
836
|
refresh_token: n,
|
|
836
|
-
client_id:
|
|
837
|
+
client_id: r
|
|
837
838
|
})), this.subscribeToOrderNotifications = () => {
|
|
838
|
-
var u,
|
|
839
|
-
const
|
|
839
|
+
var u, c;
|
|
840
|
+
const r = `${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(r);
|
|
840
841
|
return n.addEventListener("open", () => {
|
|
841
|
-
console.info(`Socket connected: ${
|
|
842
|
+
console.info(`Socket connected: ${r}`);
|
|
842
843
|
}), n.addEventListener("error", (v) => {
|
|
843
|
-
throw console.error(v), new Error(`Socket error: ${
|
|
844
|
+
throw console.error(v), new Error(`Socket error: ${r}`);
|
|
844
845
|
}), n.addEventListener("message", (v) => {
|
|
845
846
|
var p;
|
|
846
|
-
const
|
|
847
|
-
(p = w(this,
|
|
848
|
-
|
|
847
|
+
const B = JSON.parse(v.data);
|
|
848
|
+
(p = w(this, H).get(B.meta.state)) == null || p(
|
|
849
|
+
B
|
|
849
850
|
);
|
|
850
851
|
}), n.addEventListener("close", () => {
|
|
851
|
-
console.info(`Socket connection closed: ${
|
|
852
|
+
console.info(`Socket connection closed: ${r}`);
|
|
852
853
|
}), n;
|
|
853
|
-
}, this.auth = async (
|
|
854
|
-
const n =
|
|
855
|
-
return this.codeVerifier = sessionStorage.getItem(
|
|
856
|
-
}, this.pkceRequest = (
|
|
857
|
-
|
|
854
|
+
}, this.auth = async (r) => await k(this, O, j).call(this, r), this.connect = async (r) => await k(this, O, j).call(this, r), this.getAuthFlowURI = (r) => {
|
|
855
|
+
const n = te(w(this, z).api, r);
|
|
856
|
+
return this.codeVerifier = sessionStorage.getItem(M), n;
|
|
857
|
+
}, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
|
|
858
|
+
I(this, z, X.environments.sandbox);
|
|
858
859
|
return;
|
|
859
860
|
}
|
|
860
|
-
if (typeof
|
|
861
|
-
|
|
862
|
-
else if (
|
|
863
|
-
const { clientId:
|
|
864
|
-
|
|
865
|
-
clientId:
|
|
861
|
+
if (typeof t == "string")
|
|
862
|
+
I(this, z, X.environments[t]);
|
|
863
|
+
else if (I(this, z, X.environments[t.environment || "sandbox"]), T) {
|
|
864
|
+
const { clientId: r, clientSecret: n } = t;
|
|
865
|
+
I(this, U, {
|
|
866
|
+
clientId: r,
|
|
866
867
|
clientSecret: n
|
|
867
868
|
});
|
|
868
869
|
} else {
|
|
869
|
-
const { clientId:
|
|
870
|
-
|
|
871
|
-
clientId:
|
|
870
|
+
const { clientId: r, redirectUrl: n } = t;
|
|
871
|
+
I(this, U, {
|
|
872
|
+
clientId: r,
|
|
872
873
|
redirectUrl: n
|
|
873
874
|
});
|
|
874
875
|
}
|
|
@@ -880,133 +881,124 @@ class je {
|
|
|
880
881
|
* @returns string
|
|
881
882
|
* {@link https://monerium.dev/api-docs#operation/auth}
|
|
882
883
|
*/
|
|
883
|
-
async authorize(
|
|
884
|
-
var
|
|
885
|
-
const
|
|
886
|
-
if (!
|
|
884
|
+
async authorize(t) {
|
|
885
|
+
var c, v;
|
|
886
|
+
const r = (t == null ? void 0 : t.clientId) || ((c = w(this, U)) == null ? void 0 : c.clientId), n = (t == null ? void 0 : t.redirectUrl) || ((v = w(this, U)) == null ? void 0 : v.redirectUrl);
|
|
887
|
+
if (!r)
|
|
887
888
|
throw new Error("Missing ClientId");
|
|
888
889
|
if (!n)
|
|
889
890
|
throw new Error("Missing RedirectUrl");
|
|
890
|
-
const u =
|
|
891
|
-
client_id:
|
|
891
|
+
const u = te(w(this, z).api, {
|
|
892
|
+
client_id: r,
|
|
892
893
|
redirect_uri: n,
|
|
893
|
-
address:
|
|
894
|
-
signature:
|
|
895
|
-
chainId:
|
|
894
|
+
address: t == null ? void 0 : t.address,
|
|
895
|
+
signature: t == null ? void 0 : t.signature,
|
|
896
|
+
chainId: t == null ? void 0 : t.chainId
|
|
896
897
|
});
|
|
897
898
|
window.location.replace(u);
|
|
898
899
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
900
|
+
/**
|
|
901
|
+
* Get access to the API
|
|
902
|
+
* @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
|
|
903
|
+
* @returns boolean to indicate if access has been granted
|
|
904
|
+
*/
|
|
905
|
+
async getAccess(t) {
|
|
906
|
+
var B, p, y;
|
|
907
|
+
const r = (t == null ? void 0 : t.clientId) || ((B = w(this, U)) == null ? void 0 : B.clientId);
|
|
908
|
+
if ((t == null ? void 0 : t.clientSecret) || ((p = w(this, U)) == null ? void 0 : p.clientSecret)) {
|
|
909
|
+
if (!T)
|
|
904
910
|
throw new Error("Only use client credentials on server side");
|
|
905
|
-
return await w(this,
|
|
911
|
+
return await w(this, G).call(this, w(this, U)), !!this.bearerProfile;
|
|
906
912
|
}
|
|
907
|
-
const u = (
|
|
908
|
-
if (!
|
|
913
|
+
const u = (t == null ? void 0 : t.redirectUrl) || ((y = w(this, U)) == null ? void 0 : y.redirectUrl);
|
|
914
|
+
if (!r)
|
|
909
915
|
throw new Error("Missing ClientId");
|
|
910
|
-
if (
|
|
911
|
-
throw new Error("This only works
|
|
912
|
-
const
|
|
913
|
-
return
|
|
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;
|
|
916
|
+
if (T)
|
|
917
|
+
throw new Error("This only works client side");
|
|
918
|
+
const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(W) || void 0;
|
|
919
|
+
return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
|
|
937
920
|
}
|
|
938
921
|
// -- Read Methods
|
|
939
922
|
/**
|
|
940
923
|
* {@link https://monerium.dev/api-docs#operation/auth-context}
|
|
941
924
|
*/
|
|
942
925
|
getAuthContext() {
|
|
943
|
-
return
|
|
926
|
+
return k(this, E, R).call(this, "get", "auth/context");
|
|
944
927
|
}
|
|
945
928
|
/**
|
|
946
929
|
* {@link https://monerium.dev/api-docs#operation/profile}
|
|
947
930
|
* @param {string} profileId - the id of the profile to fetch.
|
|
948
931
|
|
|
949
932
|
*/
|
|
950
|
-
getProfile(
|
|
951
|
-
return
|
|
933
|
+
getProfile(t) {
|
|
934
|
+
return k(this, E, R).call(this, "get", `profiles/${t}`);
|
|
952
935
|
}
|
|
953
936
|
/**
|
|
954
937
|
* {@link https://monerium.dev/api-docs#operation/profile-balances}
|
|
955
938
|
* @param {string=} profileId - the id of the profile to fetch balances.
|
|
956
939
|
*/
|
|
957
|
-
getBalances(
|
|
958
|
-
return
|
|
940
|
+
getBalances(t) {
|
|
941
|
+
return t ? k(this, E, R).call(this, "get", `profiles/${t}/balances`) : k(this, E, R).call(this, "get", "balances");
|
|
959
942
|
}
|
|
960
943
|
/**
|
|
961
944
|
* {@link https://monerium.dev/api-docs#operation/orders}
|
|
962
945
|
*/
|
|
963
|
-
getOrders(
|
|
964
|
-
const
|
|
965
|
-
return
|
|
946
|
+
getOrders(t) {
|
|
947
|
+
const r = Q(t);
|
|
948
|
+
return k(this, E, R).call(this, "get", `orders?${r}`);
|
|
966
949
|
}
|
|
967
950
|
/**
|
|
968
951
|
* {@link https://monerium.dev/api-docs#operation/order}
|
|
969
952
|
*/
|
|
970
|
-
getOrder(
|
|
971
|
-
return
|
|
953
|
+
getOrder(t) {
|
|
954
|
+
return k(this, E, R).call(this, "get", `orders/${t}`);
|
|
972
955
|
}
|
|
973
956
|
/**
|
|
974
957
|
* {@link https://monerium.dev/api-docs#operation/tokens}
|
|
975
958
|
*/
|
|
976
959
|
getTokens() {
|
|
977
|
-
return
|
|
960
|
+
return k(this, E, R).call(this, "get", "tokens");
|
|
978
961
|
}
|
|
979
962
|
// -- Write Methods
|
|
980
963
|
/**
|
|
981
964
|
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
982
965
|
*/
|
|
983
|
-
linkAddress(
|
|
984
|
-
return
|
|
966
|
+
linkAddress(t, r) {
|
|
967
|
+
return k(this, E, R).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
|
|
985
968
|
}
|
|
986
969
|
/**
|
|
987
970
|
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
988
971
|
*/
|
|
989
|
-
placeOrder(
|
|
990
|
-
const n = { ...
|
|
991
|
-
return
|
|
972
|
+
placeOrder(t, r) {
|
|
973
|
+
const n = { ...t, kind: "redeem", currency: "eur" };
|
|
974
|
+
return r ? k(this, E, R).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, R).call(this, "post", "orders", JSON.stringify(n));
|
|
992
975
|
}
|
|
993
976
|
/**
|
|
994
977
|
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
995
978
|
*/
|
|
996
|
-
uploadSupportingDocument(
|
|
997
|
-
const
|
|
998
|
-
|
|
979
|
+
uploadSupportingDocument(t) {
|
|
980
|
+
const r = Q(
|
|
981
|
+
t
|
|
999
982
|
);
|
|
1000
|
-
return
|
|
983
|
+
return k(this, E, R).call(this, "post", "files/supporting-document", r, !0);
|
|
1001
984
|
}
|
|
1002
985
|
// -- Notifications
|
|
1003
986
|
async connectOrderSocket() {
|
|
1004
|
-
var
|
|
1005
|
-
(
|
|
987
|
+
var t;
|
|
988
|
+
(t = this.bearerProfile) != null && t.access_token && w(this, H).size > 0 && I(this, L, this.subscribeToOrderNotifications());
|
|
1006
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* Cleanups the socket and the subscriptions
|
|
992
|
+
*/
|
|
1007
993
|
async disconnect() {
|
|
1008
|
-
var
|
|
1009
|
-
sessionStorage.removeItem(
|
|
994
|
+
var t;
|
|
995
|
+
T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close();
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Revokes access
|
|
999
|
+
*/
|
|
1000
|
+
async revokeAccess() {
|
|
1001
|
+
T || sessionStorage.removeItem(W), this.disconnect();
|
|
1010
1002
|
}
|
|
1011
1003
|
/**
|
|
1012
1004
|
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
|
|
@@ -1015,41 +1007,62 @@ class je {
|
|
|
1015
1007
|
* @param event The event to subscribe to
|
|
1016
1008
|
* @param handler The handler to be called when the event is triggered
|
|
1017
1009
|
*/
|
|
1018
|
-
subscribeOrders(
|
|
1019
|
-
w(this,
|
|
1010
|
+
subscribeOrders(t, r) {
|
|
1011
|
+
w(this, H).set(t, r);
|
|
1020
1012
|
}
|
|
1021
1013
|
/**
|
|
1022
1014
|
* Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
|
|
1023
1015
|
* @param event The event to unsubscribe from
|
|
1024
1016
|
*/
|
|
1025
|
-
unsubscribeOrders(
|
|
1026
|
-
var
|
|
1027
|
-
w(this,
|
|
1017
|
+
unsubscribeOrders(t) {
|
|
1018
|
+
var r;
|
|
1019
|
+
w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
|
|
1028
1020
|
}
|
|
1029
1021
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
r,
|
|
1034
|
-
|
|
1022
|
+
z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
|
|
1023
|
+
let r;
|
|
1024
|
+
if (ne(t))
|
|
1025
|
+
r = { ...t, grant_type: "authorization_code" };
|
|
1026
|
+
else if (Me(t))
|
|
1027
|
+
r = { ...t, grant_type: "refresh_token" };
|
|
1028
|
+
else if (Le(t))
|
|
1029
|
+
r = { ...t, grant_type: "client_credentials" };
|
|
1030
|
+
else
|
|
1031
|
+
throw new Error("Authorization grant type could not be detected.");
|
|
1032
|
+
return await k(this, E, R).call(this, "post", "auth/token", r, !0).then((n) => {
|
|
1033
|
+
var u;
|
|
1034
|
+
this.bearerProfile = n, this.isAuthorized = !!n, I(this, D, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
|
|
1035
|
+
W,
|
|
1036
|
+
((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
|
|
1037
|
+
);
|
|
1038
|
+
}).catch((n) => {
|
|
1039
|
+
throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(W), re()), new Error(n == null ? void 0 : n.message);
|
|
1040
|
+
}), ne(t) && re(), this.bearerProfile;
|
|
1041
|
+
}, E = new WeakSet(), R = async function(t, r, n, u) {
|
|
1042
|
+
return qe(
|
|
1043
|
+
`${w(this, z).api}/${r}`,
|
|
1044
|
+
t,
|
|
1045
|
+
u ? Q(n) : n,
|
|
1035
1046
|
{
|
|
1036
|
-
Authorization: w(this,
|
|
1047
|
+
Authorization: w(this, D) || "",
|
|
1037
1048
|
"Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
|
|
1038
1049
|
}
|
|
1039
1050
|
);
|
|
1040
|
-
},
|
|
1051
|
+
}, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
|
|
1041
1052
|
export {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1053
|
+
ye as AccountState,
|
|
1054
|
+
le as Currency,
|
|
1055
|
+
we as KYCOutcome,
|
|
1056
|
+
ge as KYCState,
|
|
1057
|
+
We as MoneriumClient,
|
|
1058
|
+
_e as OrderKind,
|
|
1059
|
+
be as OrderState,
|
|
1060
|
+
me as PaymentStandard,
|
|
1061
|
+
ve as Permission,
|
|
1062
|
+
pe as ProfileType,
|
|
1063
|
+
Ne as constants,
|
|
1064
|
+
Be as getChain,
|
|
1065
|
+
ke as getNetwork,
|
|
1066
|
+
Fe as placeOrderMessage,
|
|
1067
|
+
Se as rfc3339
|
|
1055
1068
|
};
|