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