@monerium/sdk 2.2.1 → 2.2.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 +31 -11
- package/dist/index.d.ts +234 -240
- package/dist/index.mjs +727 -994
- package/dist/index.umd.js +1 -764
- package/package.json +11 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,765 +1,2 @@
|
|
|
1
|
-
(function (a, c) {
|
|
2
|
-
typeof exports == 'object' && typeof module < 'u'
|
|
3
|
-
? c(exports)
|
|
4
|
-
: typeof define == 'function' && define.amd
|
|
5
|
-
? define(['exports'], c)
|
|
6
|
-
: ((a = typeof globalThis < 'u' ? globalThis : a || self),
|
|
7
|
-
c((a['monerium-sdk'] = {})));
|
|
8
|
-
})(this, function (a) {
|
|
9
|
-
var E, W, A, k, q, se, M, ce, F, ue;
|
|
10
|
-
('use strict');
|
|
11
|
-
var xe = Object.defineProperty;
|
|
12
|
-
var Ce = (a, c, g) =>
|
|
13
|
-
c in a
|
|
14
|
-
? xe(a, c, { enumerable: !0, configurable: !0, writable: !0, value: g })
|
|
15
|
-
: (a[c] = g);
|
|
16
|
-
var I = (a, c, g) => (Ce(a, typeof c != 'symbol' ? c + '' : c, g), g),
|
|
17
|
-
N = (a, c, g) => {
|
|
18
|
-
if (!c.has(a)) throw TypeError('Cannot ' + g);
|
|
19
|
-
};
|
|
20
|
-
var D = (a, c, g) => (
|
|
21
|
-
N(a, c, 'read from private field'), g ? g.call(a) : c.get(a)
|
|
22
|
-
),
|
|
23
|
-
$ = (a, c, g) => {
|
|
24
|
-
if (c.has(a))
|
|
25
|
-
throw TypeError('Cannot add the same private member more than once');
|
|
26
|
-
c instanceof WeakSet ? c.add(a) : c.set(a, g);
|
|
27
|
-
},
|
|
28
|
-
G = (a, c, g, z) => (
|
|
29
|
-
N(a, c, 'write to private field'), z ? z.call(a, g) : c.set(a, g), g
|
|
30
|
-
);
|
|
31
|
-
var S = (a, c, g) => (N(a, c, 'access private method'), g);
|
|
32
|
-
var c =
|
|
33
|
-
typeof globalThis < 'u'
|
|
34
|
-
? globalThis
|
|
35
|
-
: typeof window < 'u'
|
|
36
|
-
? window
|
|
37
|
-
: typeof global < 'u'
|
|
38
|
-
? global
|
|
39
|
-
: typeof self < 'u'
|
|
40
|
-
? self
|
|
41
|
-
: {};
|
|
42
|
-
function g(r) {
|
|
43
|
-
if (r.__esModule) return r;
|
|
44
|
-
var n = r.default;
|
|
45
|
-
if (typeof n == 'function') {
|
|
46
|
-
var s = function u() {
|
|
47
|
-
if (this instanceof u) {
|
|
48
|
-
var b = [null];
|
|
49
|
-
b.push.apply(b, arguments);
|
|
50
|
-
var p = Function.bind.apply(n, b);
|
|
51
|
-
return new p();
|
|
52
|
-
}
|
|
53
|
-
return n.apply(this, arguments);
|
|
54
|
-
};
|
|
55
|
-
s.prototype = n.prototype;
|
|
56
|
-
} else s = {};
|
|
57
|
-
return (
|
|
58
|
-
Object.defineProperty(s, '__esModule', { value: !0 }),
|
|
59
|
-
Object.keys(r).forEach(function (u) {
|
|
60
|
-
var b = Object.getOwnPropertyDescriptor(r, u);
|
|
61
|
-
Object.defineProperty(
|
|
62
|
-
s,
|
|
63
|
-
u,
|
|
64
|
-
b.get
|
|
65
|
-
? b
|
|
66
|
-
: {
|
|
67
|
-
enumerable: !0,
|
|
68
|
-
get: function () {
|
|
69
|
-
return r[u];
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
);
|
|
73
|
-
}),
|
|
74
|
-
s
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
var z = {},
|
|
78
|
-
fe = {
|
|
79
|
-
get exports() {
|
|
80
|
-
return z;
|
|
81
|
-
},
|
|
82
|
-
set exports(r) {
|
|
83
|
-
z = r;
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
function he(r) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
'Could not dynamically require "' +
|
|
89
|
-
r +
|
|
90
|
-
'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.',
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
var U = {},
|
|
94
|
-
le = {
|
|
95
|
-
get exports() {
|
|
96
|
-
return U;
|
|
97
|
-
},
|
|
98
|
-
set exports(r) {
|
|
99
|
-
U = r;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
const de = g(
|
|
103
|
-
Object.freeze(
|
|
104
|
-
Object.defineProperty(
|
|
105
|
-
{ __proto__: null, default: {} },
|
|
106
|
-
Symbol.toStringTag,
|
|
107
|
-
{ value: 'Module' },
|
|
108
|
-
),
|
|
109
|
-
),
|
|
110
|
-
);
|
|
111
|
-
var J;
|
|
112
|
-
function Q() {
|
|
113
|
-
return (
|
|
114
|
-
J ||
|
|
115
|
-
((J = 1),
|
|
116
|
-
(function (r, n) {
|
|
117
|
-
(function (s, u) {
|
|
118
|
-
r.exports = u();
|
|
119
|
-
})(c, function () {
|
|
120
|
-
var s =
|
|
121
|
-
s ||
|
|
122
|
-
(function (u, b) {
|
|
123
|
-
var p;
|
|
124
|
-
if (
|
|
125
|
-
(typeof window < 'u' && window.crypto && (p = window.crypto),
|
|
126
|
-
typeof self < 'u' && self.crypto && (p = self.crypto),
|
|
127
|
-
typeof globalThis < 'u' &&
|
|
128
|
-
globalThis.crypto &&
|
|
129
|
-
(p = globalThis.crypto),
|
|
130
|
-
!p &&
|
|
131
|
-
typeof window < 'u' &&
|
|
132
|
-
window.msCrypto &&
|
|
133
|
-
(p = window.msCrypto),
|
|
134
|
-
!p && typeof c < 'u' && c.crypto && (p = c.crypto),
|
|
135
|
-
!p && typeof he == 'function')
|
|
136
|
-
)
|
|
137
|
-
try {
|
|
138
|
-
p = de;
|
|
139
|
-
} catch {}
|
|
140
|
-
var H = function () {
|
|
141
|
-
if (p) {
|
|
142
|
-
if (typeof p.getRandomValues == 'function')
|
|
143
|
-
try {
|
|
144
|
-
return p.getRandomValues(new Uint32Array(1))[0];
|
|
145
|
-
} catch {}
|
|
146
|
-
if (typeof p.randomBytes == 'function')
|
|
147
|
-
try {
|
|
148
|
-
return p.randomBytes(4).readInt32LE();
|
|
149
|
-
} catch {}
|
|
150
|
-
}
|
|
151
|
-
throw new Error(
|
|
152
|
-
'Native crypto module could not be used to get secure random number.',
|
|
153
|
-
);
|
|
154
|
-
},
|
|
155
|
-
O =
|
|
156
|
-
Object.create ||
|
|
157
|
-
(function () {
|
|
158
|
-
function e() {}
|
|
159
|
-
return function (t) {
|
|
160
|
-
var o;
|
|
161
|
-
return (
|
|
162
|
-
(e.prototype = t),
|
|
163
|
-
(o = new e()),
|
|
164
|
-
(e.prototype = null),
|
|
165
|
-
o
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
})(),
|
|
169
|
-
B = {},
|
|
170
|
-
R = (B.lib = {}),
|
|
171
|
-
_ = (R.Base = (function () {
|
|
172
|
-
return {
|
|
173
|
-
extend: function (e) {
|
|
174
|
-
var t = O(this);
|
|
175
|
-
return (
|
|
176
|
-
e && t.mixIn(e),
|
|
177
|
-
(!t.hasOwnProperty('init') || this.init === t.init) &&
|
|
178
|
-
(t.init = function () {
|
|
179
|
-
t.$super.init.apply(this, arguments);
|
|
180
|
-
}),
|
|
181
|
-
(t.init.prototype = t),
|
|
182
|
-
(t.$super = this),
|
|
183
|
-
t
|
|
184
|
-
);
|
|
185
|
-
},
|
|
186
|
-
create: function () {
|
|
187
|
-
var e = this.extend();
|
|
188
|
-
return e.init.apply(e, arguments), e;
|
|
189
|
-
},
|
|
190
|
-
init: function () {},
|
|
191
|
-
mixIn: function (e) {
|
|
192
|
-
for (var t in e)
|
|
193
|
-
e.hasOwnProperty(t) && (this[t] = e[t]);
|
|
194
|
-
e.hasOwnProperty('toString') &&
|
|
195
|
-
(this.toString = e.toString);
|
|
196
|
-
},
|
|
197
|
-
clone: function () {
|
|
198
|
-
return this.init.prototype.extend(this);
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
})()),
|
|
202
|
-
v = (R.WordArray = _.extend({
|
|
203
|
-
init: function (e, t) {
|
|
204
|
-
(e = this.words = e || []),
|
|
205
|
-
t != b
|
|
206
|
-
? (this.sigBytes = t)
|
|
207
|
-
: (this.sigBytes = e.length * 4);
|
|
208
|
-
},
|
|
209
|
-
toString: function (e) {
|
|
210
|
-
return (e || h).stringify(this);
|
|
211
|
-
},
|
|
212
|
-
concat: function (e) {
|
|
213
|
-
var t = this.words,
|
|
214
|
-
o = e.words,
|
|
215
|
-
f = this.sigBytes,
|
|
216
|
-
y = e.sigBytes;
|
|
217
|
-
if ((this.clamp(), f % 4))
|
|
218
|
-
for (var w = 0; w < y; w++) {
|
|
219
|
-
var x = (o[w >>> 2] >>> (24 - (w % 4) * 8)) & 255;
|
|
220
|
-
t[(f + w) >>> 2] |= x << (24 - ((f + w) % 4) * 8);
|
|
221
|
-
}
|
|
222
|
-
else
|
|
223
|
-
for (var C = 0; C < y; C += 4)
|
|
224
|
-
t[(f + C) >>> 2] = o[C >>> 2];
|
|
225
|
-
return (this.sigBytes += y), this;
|
|
226
|
-
},
|
|
227
|
-
clamp: function () {
|
|
228
|
-
var e = this.words,
|
|
229
|
-
t = this.sigBytes;
|
|
230
|
-
(e[t >>> 2] &= 4294967295 << (32 - (t % 4) * 8)),
|
|
231
|
-
(e.length = u.ceil(t / 4));
|
|
232
|
-
},
|
|
233
|
-
clone: function () {
|
|
234
|
-
var e = _.clone.call(this);
|
|
235
|
-
return (e.words = this.words.slice(0)), e;
|
|
236
|
-
},
|
|
237
|
-
random: function (e) {
|
|
238
|
-
for (var t = [], o = 0; o < e; o += 4) t.push(H());
|
|
239
|
-
return new v.init(t, e);
|
|
240
|
-
},
|
|
241
|
-
})),
|
|
242
|
-
m = (B.enc = {}),
|
|
243
|
-
h = (m.Hex = {
|
|
244
|
-
stringify: function (e) {
|
|
245
|
-
for (
|
|
246
|
-
var t = e.words, o = e.sigBytes, f = [], y = 0;
|
|
247
|
-
y < o;
|
|
248
|
-
y++
|
|
249
|
-
) {
|
|
250
|
-
var w = (t[y >>> 2] >>> (24 - (y % 4) * 8)) & 255;
|
|
251
|
-
f.push((w >>> 4).toString(16)),
|
|
252
|
-
f.push((w & 15).toString(16));
|
|
253
|
-
}
|
|
254
|
-
return f.join('');
|
|
255
|
-
},
|
|
256
|
-
parse: function (e) {
|
|
257
|
-
for (var t = e.length, o = [], f = 0; f < t; f += 2)
|
|
258
|
-
o[f >>> 3] |=
|
|
259
|
-
parseInt(e.substr(f, 2), 16) << (24 - (f % 8) * 4);
|
|
260
|
-
return new v.init(o, t / 2);
|
|
261
|
-
},
|
|
262
|
-
}),
|
|
263
|
-
d = (m.Latin1 = {
|
|
264
|
-
stringify: function (e) {
|
|
265
|
-
for (
|
|
266
|
-
var t = e.words, o = e.sigBytes, f = [], y = 0;
|
|
267
|
-
y < o;
|
|
268
|
-
y++
|
|
269
|
-
) {
|
|
270
|
-
var w = (t[y >>> 2] >>> (24 - (y % 4) * 8)) & 255;
|
|
271
|
-
f.push(String.fromCharCode(w));
|
|
272
|
-
}
|
|
273
|
-
return f.join('');
|
|
274
|
-
},
|
|
275
|
-
parse: function (e) {
|
|
276
|
-
for (var t = e.length, o = [], f = 0; f < t; f++)
|
|
277
|
-
o[f >>> 2] |=
|
|
278
|
-
(e.charCodeAt(f) & 255) << (24 - (f % 4) * 8);
|
|
279
|
-
return new v.init(o, t);
|
|
280
|
-
},
|
|
281
|
-
}),
|
|
282
|
-
i = (m.Utf8 = {
|
|
283
|
-
stringify: function (e) {
|
|
284
|
-
try {
|
|
285
|
-
return decodeURIComponent(escape(d.stringify(e)));
|
|
286
|
-
} catch {
|
|
287
|
-
throw new Error('Malformed UTF-8 data');
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
parse: function (e) {
|
|
291
|
-
return d.parse(unescape(encodeURIComponent(e)));
|
|
292
|
-
},
|
|
293
|
-
}),
|
|
294
|
-
l = (R.BufferedBlockAlgorithm = _.extend({
|
|
295
|
-
reset: function () {
|
|
296
|
-
(this._data = new v.init()), (this._nDataBytes = 0);
|
|
297
|
-
},
|
|
298
|
-
_append: function (e) {
|
|
299
|
-
typeof e == 'string' && (e = i.parse(e)),
|
|
300
|
-
this._data.concat(e),
|
|
301
|
-
(this._nDataBytes += e.sigBytes);
|
|
302
|
-
},
|
|
303
|
-
_process: function (e) {
|
|
304
|
-
var t,
|
|
305
|
-
o = this._data,
|
|
306
|
-
f = o.words,
|
|
307
|
-
y = o.sigBytes,
|
|
308
|
-
w = this.blockSize,
|
|
309
|
-
x = w * 4,
|
|
310
|
-
C = y / x;
|
|
311
|
-
e
|
|
312
|
-
? (C = u.ceil(C))
|
|
313
|
-
: (C = u.max((C | 0) - this._minBufferSize, 0));
|
|
314
|
-
var L = C * w,
|
|
315
|
-
T = u.min(L * 4, y);
|
|
316
|
-
if (L) {
|
|
317
|
-
for (var j = 0; j < L; j += w)
|
|
318
|
-
this._doProcessBlock(f, j);
|
|
319
|
-
(t = f.splice(0, L)), (o.sigBytes -= T);
|
|
320
|
-
}
|
|
321
|
-
return new v.init(t, T);
|
|
322
|
-
},
|
|
323
|
-
clone: function () {
|
|
324
|
-
var e = _.clone.call(this);
|
|
325
|
-
return (e._data = this._data.clone()), e;
|
|
326
|
-
},
|
|
327
|
-
_minBufferSize: 0,
|
|
328
|
-
}));
|
|
329
|
-
R.Hasher = l.extend({
|
|
330
|
-
cfg: _.extend(),
|
|
331
|
-
init: function (e) {
|
|
332
|
-
(this.cfg = this.cfg.extend(e)), this.reset();
|
|
333
|
-
},
|
|
334
|
-
reset: function () {
|
|
335
|
-
l.reset.call(this), this._doReset();
|
|
336
|
-
},
|
|
337
|
-
update: function (e) {
|
|
338
|
-
return this._append(e), this._process(), this;
|
|
339
|
-
},
|
|
340
|
-
finalize: function (e) {
|
|
341
|
-
e && this._append(e);
|
|
342
|
-
var t = this._doFinalize();
|
|
343
|
-
return t;
|
|
344
|
-
},
|
|
345
|
-
blockSize: 16,
|
|
346
|
-
_createHelper: function (e) {
|
|
347
|
-
return function (t, o) {
|
|
348
|
-
return new e.init(o).finalize(t);
|
|
349
|
-
};
|
|
350
|
-
},
|
|
351
|
-
_createHmacHelper: function (e) {
|
|
352
|
-
return function (t, o) {
|
|
353
|
-
return new P.HMAC.init(e, o).finalize(t);
|
|
354
|
-
};
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
var P = (B.algo = {});
|
|
358
|
-
return B;
|
|
359
|
-
})(Math);
|
|
360
|
-
return s;
|
|
361
|
-
});
|
|
362
|
-
})(le)),
|
|
363
|
-
U
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
(function (r, n) {
|
|
367
|
-
(function (s, u) {
|
|
368
|
-
r.exports = u(Q());
|
|
369
|
-
})(c, function (s) {
|
|
370
|
-
return (
|
|
371
|
-
(function () {
|
|
372
|
-
var u = s,
|
|
373
|
-
b = u.lib,
|
|
374
|
-
p = b.WordArray,
|
|
375
|
-
H = u.enc;
|
|
376
|
-
H.Base64url = {
|
|
377
|
-
stringify: function (B, R = !0) {
|
|
378
|
-
var _ = B.words,
|
|
379
|
-
v = B.sigBytes,
|
|
380
|
-
m = R ? this._safe_map : this._map;
|
|
381
|
-
B.clamp();
|
|
382
|
-
for (var h = [], d = 0; d < v; d += 3)
|
|
383
|
-
for (
|
|
384
|
-
var i = (_[d >>> 2] >>> (24 - (d % 4) * 8)) & 255,
|
|
385
|
-
l = (_[(d + 1) >>> 2] >>> (24 - ((d + 1) % 4) * 8)) & 255,
|
|
386
|
-
P = (_[(d + 2) >>> 2] >>> (24 - ((d + 2) % 4) * 8)) & 255,
|
|
387
|
-
e = (i << 16) | (l << 8) | P,
|
|
388
|
-
t = 0;
|
|
389
|
-
t < 4 && d + t * 0.75 < v;
|
|
390
|
-
t++
|
|
391
|
-
)
|
|
392
|
-
h.push(m.charAt((e >>> (6 * (3 - t))) & 63));
|
|
393
|
-
var o = m.charAt(64);
|
|
394
|
-
if (o) for (; h.length % 4; ) h.push(o);
|
|
395
|
-
return h.join('');
|
|
396
|
-
},
|
|
397
|
-
parse: function (B, R = !0) {
|
|
398
|
-
var _ = B.length,
|
|
399
|
-
v = R ? this._safe_map : this._map,
|
|
400
|
-
m = this._reverseMap;
|
|
401
|
-
if (!m) {
|
|
402
|
-
m = this._reverseMap = [];
|
|
403
|
-
for (var h = 0; h < v.length; h++) m[v.charCodeAt(h)] = h;
|
|
404
|
-
}
|
|
405
|
-
var d = v.charAt(64);
|
|
406
|
-
if (d) {
|
|
407
|
-
var i = B.indexOf(d);
|
|
408
|
-
i !== -1 && (_ = i);
|
|
409
|
-
}
|
|
410
|
-
return O(B, _, m);
|
|
411
|
-
},
|
|
412
|
-
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
413
|
-
_safe_map:
|
|
414
|
-
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
|
415
|
-
};
|
|
416
|
-
function O(B, R, _) {
|
|
417
|
-
for (var v = [], m = 0, h = 0; h < R; h++)
|
|
418
|
-
if (h % 4) {
|
|
419
|
-
var d = _[B.charCodeAt(h - 1)] << ((h % 4) * 2),
|
|
420
|
-
i = _[B.charCodeAt(h)] >>> (6 - (h % 4) * 2),
|
|
421
|
-
l = d | i;
|
|
422
|
-
(v[m >>> 2] |= l << (24 - (m % 4) * 8)), m++;
|
|
423
|
-
}
|
|
424
|
-
return p.create(v, m);
|
|
425
|
-
}
|
|
426
|
-
})(),
|
|
427
|
-
s.enc.Base64url
|
|
428
|
-
);
|
|
429
|
-
});
|
|
430
|
-
})(fe);
|
|
431
|
-
var V = {},
|
|
432
|
-
pe = {
|
|
433
|
-
get exports() {
|
|
434
|
-
return V;
|
|
435
|
-
},
|
|
436
|
-
set exports(r) {
|
|
437
|
-
V = r;
|
|
438
|
-
},
|
|
439
|
-
};
|
|
440
|
-
(function (r, n) {
|
|
441
|
-
(function (s, u) {
|
|
442
|
-
r.exports = u(Q());
|
|
443
|
-
})(c, function (s) {
|
|
444
|
-
return (
|
|
445
|
-
(function (u) {
|
|
446
|
-
var b = s,
|
|
447
|
-
p = b.lib,
|
|
448
|
-
H = p.WordArray,
|
|
449
|
-
O = p.Hasher,
|
|
450
|
-
B = b.algo,
|
|
451
|
-
R = [],
|
|
452
|
-
_ = [];
|
|
453
|
-
(function () {
|
|
454
|
-
function h(P) {
|
|
455
|
-
for (var e = u.sqrt(P), t = 2; t <= e; t++)
|
|
456
|
-
if (!(P % t)) return !1;
|
|
457
|
-
return !0;
|
|
458
|
-
}
|
|
459
|
-
function d(P) {
|
|
460
|
-
return ((P - (P | 0)) * 4294967296) | 0;
|
|
461
|
-
}
|
|
462
|
-
for (var i = 2, l = 0; l < 64; )
|
|
463
|
-
h(i) &&
|
|
464
|
-
(l < 8 && (R[l] = d(u.pow(i, 1 / 2))),
|
|
465
|
-
(_[l] = d(u.pow(i, 1 / 3))),
|
|
466
|
-
l++),
|
|
467
|
-
i++;
|
|
468
|
-
})();
|
|
469
|
-
var v = [],
|
|
470
|
-
m = (B.SHA256 = O.extend({
|
|
471
|
-
_doReset: function () {
|
|
472
|
-
this._hash = new H.init(R.slice(0));
|
|
473
|
-
},
|
|
474
|
-
_doProcessBlock: function (h, d) {
|
|
475
|
-
for (
|
|
476
|
-
var i = this._hash.words,
|
|
477
|
-
l = i[0],
|
|
478
|
-
P = i[1],
|
|
479
|
-
e = i[2],
|
|
480
|
-
t = i[3],
|
|
481
|
-
o = i[4],
|
|
482
|
-
f = i[5],
|
|
483
|
-
y = i[6],
|
|
484
|
-
w = i[7],
|
|
485
|
-
x = 0;
|
|
486
|
-
x < 64;
|
|
487
|
-
x++
|
|
488
|
-
) {
|
|
489
|
-
if (x < 16) v[x] = h[d + x] | 0;
|
|
490
|
-
else {
|
|
491
|
-
var C = v[x - 15],
|
|
492
|
-
L =
|
|
493
|
-
((C << 25) | (C >>> 7)) ^
|
|
494
|
-
((C << 14) | (C >>> 18)) ^
|
|
495
|
-
(C >>> 3),
|
|
496
|
-
T = v[x - 2],
|
|
497
|
-
j =
|
|
498
|
-
((T << 15) | (T >>> 17)) ^
|
|
499
|
-
((T << 13) | (T >>> 19)) ^
|
|
500
|
-
(T >>> 10);
|
|
501
|
-
v[x] = L + v[x - 7] + j + v[x - 16];
|
|
502
|
-
}
|
|
503
|
-
var me = (o & f) ^ (~o & y),
|
|
504
|
-
we = (l & P) ^ (l & e) ^ (P & e),
|
|
505
|
-
_e =
|
|
506
|
-
((l << 30) | (l >>> 2)) ^
|
|
507
|
-
((l << 19) | (l >>> 13)) ^
|
|
508
|
-
((l << 10) | (l >>> 22)),
|
|
509
|
-
be =
|
|
510
|
-
((o << 26) | (o >>> 6)) ^
|
|
511
|
-
((o << 21) | (o >>> 11)) ^
|
|
512
|
-
((o << 7) | (o >>> 25)),
|
|
513
|
-
ae = w + be + me + _[x] + v[x],
|
|
514
|
-
Be = _e + we;
|
|
515
|
-
(w = y),
|
|
516
|
-
(y = f),
|
|
517
|
-
(f = o),
|
|
518
|
-
(o = (t + ae) | 0),
|
|
519
|
-
(t = e),
|
|
520
|
-
(e = P),
|
|
521
|
-
(P = l),
|
|
522
|
-
(l = (ae + Be) | 0);
|
|
523
|
-
}
|
|
524
|
-
(i[0] = (i[0] + l) | 0),
|
|
525
|
-
(i[1] = (i[1] + P) | 0),
|
|
526
|
-
(i[2] = (i[2] + e) | 0),
|
|
527
|
-
(i[3] = (i[3] + t) | 0),
|
|
528
|
-
(i[4] = (i[4] + o) | 0),
|
|
529
|
-
(i[5] = (i[5] + f) | 0),
|
|
530
|
-
(i[6] = (i[6] + y) | 0),
|
|
531
|
-
(i[7] = (i[7] + w) | 0);
|
|
532
|
-
},
|
|
533
|
-
_doFinalize: function () {
|
|
534
|
-
var h = this._data,
|
|
535
|
-
d = h.words,
|
|
536
|
-
i = this._nDataBytes * 8,
|
|
537
|
-
l = h.sigBytes * 8;
|
|
538
|
-
return (
|
|
539
|
-
(d[l >>> 5] |= 128 << (24 - (l % 32))),
|
|
540
|
-
(d[(((l + 64) >>> 9) << 4) + 14] = u.floor(i / 4294967296)),
|
|
541
|
-
(d[(((l + 64) >>> 9) << 4) + 15] = i),
|
|
542
|
-
(h.sigBytes = d.length * 4),
|
|
543
|
-
this._process(),
|
|
544
|
-
this._hash
|
|
545
|
-
);
|
|
546
|
-
},
|
|
547
|
-
clone: function () {
|
|
548
|
-
var h = O.clone.call(this);
|
|
549
|
-
return (h._hash = this._hash.clone()), h;
|
|
550
|
-
},
|
|
551
|
-
}));
|
|
552
|
-
(b.SHA256 = O._createHelper(m)),
|
|
553
|
-
(b.HmacSHA256 = O._createHmacHelper(m));
|
|
554
|
-
})(Math),
|
|
555
|
-
s.SHA256
|
|
556
|
-
);
|
|
557
|
-
});
|
|
558
|
-
})(pe);
|
|
559
|
-
const ve = () => {
|
|
560
|
-
let r = '';
|
|
561
|
-
const n =
|
|
562
|
-
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
|
|
563
|
-
s = n.length;
|
|
564
|
-
let u = 0;
|
|
565
|
-
for (; u < 128; )
|
|
566
|
-
(r += n.charAt(Math.floor(Math.random() * s))), (u += 1);
|
|
567
|
-
return r;
|
|
568
|
-
},
|
|
569
|
-
ye = {
|
|
570
|
-
environments: {
|
|
571
|
-
production: {
|
|
572
|
-
api: 'https://api.monerium.app',
|
|
573
|
-
web: 'https://monerium.app',
|
|
574
|
-
},
|
|
575
|
-
sandbox: {
|
|
576
|
-
api: 'https://api.monerium.dev',
|
|
577
|
-
web: 'https://sandbox.monerium.dev',
|
|
578
|
-
},
|
|
579
|
-
},
|
|
580
|
-
};
|
|
581
|
-
class ge {
|
|
582
|
-
constructor(n = 'sandbox') {
|
|
583
|
-
$(this, A);
|
|
584
|
-
$(this, q);
|
|
585
|
-
$(this, M);
|
|
586
|
-
$(this, F);
|
|
587
|
-
$(this, E, void 0);
|
|
588
|
-
$(this, W, void 0);
|
|
589
|
-
I(this, 'codeVerifier');
|
|
590
|
-
I(this, 'bearerProfile');
|
|
591
|
-
I(this, 'pkceRequest', (n) => this.getAuthFlowURI(n));
|
|
592
|
-
G(this, E, ye.environments[n]);
|
|
593
|
-
}
|
|
594
|
-
async auth(n) {
|
|
595
|
-
let s;
|
|
596
|
-
if (S(this, q, se).call(this, n))
|
|
597
|
-
s = { ...n, grant_type: 'authorization_code' };
|
|
598
|
-
else if (S(this, M, ce).call(this, n))
|
|
599
|
-
s = { ...n, grant_type: 'refresh_token' };
|
|
600
|
-
else if (S(this, F, ue).call(this, n))
|
|
601
|
-
s = { ...n, grant_type: 'client_credentials' };
|
|
602
|
-
else throw new Error('Authentication method could not be detected.');
|
|
603
|
-
return (
|
|
604
|
-
(this.bearerProfile = await S(this, A, k).call(
|
|
605
|
-
this,
|
|
606
|
-
'post',
|
|
607
|
-
'auth/token',
|
|
608
|
-
new URLSearchParams(s),
|
|
609
|
-
!0,
|
|
610
|
-
)),
|
|
611
|
-
G(this, W, `Bearer ${this.bearerProfile.access_token}`),
|
|
612
|
-
this.bearerProfile
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
getAuthFlowURI(n) {
|
|
616
|
-
this.codeVerifier = ve();
|
|
617
|
-
const s = z.stringify(V(this.codeVerifier)),
|
|
618
|
-
u = {
|
|
619
|
-
...n,
|
|
620
|
-
client_id: n == null ? void 0 : n.client_id,
|
|
621
|
-
code_challenge: s,
|
|
622
|
-
code_challenge_method: 'S256',
|
|
623
|
-
response_type: 'code',
|
|
624
|
-
};
|
|
625
|
-
return `${D(this, E).api}/auth?${new URLSearchParams(u)}`;
|
|
626
|
-
}
|
|
627
|
-
getAuthContext() {
|
|
628
|
-
return S(this, A, k).call(this, 'get', 'auth/context');
|
|
629
|
-
}
|
|
630
|
-
getProfile(n) {
|
|
631
|
-
return S(this, A, k).call(this, 'get', `profiles/${n}`);
|
|
632
|
-
}
|
|
633
|
-
getBalances(n) {
|
|
634
|
-
return n
|
|
635
|
-
? S(this, A, k).call(this, 'get', `profiles/${n}/balances`)
|
|
636
|
-
: S(this, A, k).call(this, 'get', 'balances');
|
|
637
|
-
}
|
|
638
|
-
getOrders(n) {
|
|
639
|
-
const s = new URLSearchParams(n);
|
|
640
|
-
return S(this, A, k).call(this, 'get', `orders?${s}`);
|
|
641
|
-
}
|
|
642
|
-
getOrder(n) {
|
|
643
|
-
return S(this, A, k).call(this, 'get', `orders/${n}`);
|
|
644
|
-
}
|
|
645
|
-
getTokens() {
|
|
646
|
-
return S(this, A, k).call(this, 'get', 'tokens');
|
|
647
|
-
}
|
|
648
|
-
linkAddress(n, s) {
|
|
649
|
-
return S(this, A, k).call(
|
|
650
|
-
this,
|
|
651
|
-
'post',
|
|
652
|
-
`profiles/${n}/addresses`,
|
|
653
|
-
JSON.stringify(s),
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
placeOrder(n, s) {
|
|
657
|
-
return s
|
|
658
|
-
? S(this, A, k).call(
|
|
659
|
-
this,
|
|
660
|
-
'post',
|
|
661
|
-
`profiles/${s}/orders`,
|
|
662
|
-
JSON.stringify(n),
|
|
663
|
-
)
|
|
664
|
-
: S(this, A, k).call(this, 'post', 'orders', JSON.stringify(n));
|
|
665
|
-
}
|
|
666
|
-
uploadSupportingDocument(n) {
|
|
667
|
-
const s = new URLSearchParams(n);
|
|
668
|
-
return S(this, A, k).call(
|
|
669
|
-
this,
|
|
670
|
-
'post',
|
|
671
|
-
'files/supporting-document',
|
|
672
|
-
s,
|
|
673
|
-
!0,
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
(E = new WeakMap()),
|
|
678
|
-
(W = new WeakMap()),
|
|
679
|
-
(A = new WeakSet()),
|
|
680
|
-
(k = async function (n, s, u, b) {
|
|
681
|
-
const p = await fetch(`${D(this, E).api}/${s}`, {
|
|
682
|
-
method: n,
|
|
683
|
-
headers: {
|
|
684
|
-
'Content-Type': `application/${b ? 'x-www-form-urlencoded' : 'json'}`,
|
|
685
|
-
Authorization: D(this, W) || '',
|
|
686
|
-
},
|
|
687
|
-
body: u,
|
|
688
|
-
});
|
|
689
|
-
let H;
|
|
690
|
-
try {
|
|
691
|
-
H = await p.json();
|
|
692
|
-
} catch {
|
|
693
|
-
throw await p.text();
|
|
694
|
-
}
|
|
695
|
-
if (p.ok) return H;
|
|
696
|
-
throw H;
|
|
697
|
-
}),
|
|
698
|
-
(q = new WeakSet()),
|
|
699
|
-
(se = function (n) {
|
|
700
|
-
return n.code != null;
|
|
701
|
-
}),
|
|
702
|
-
(M = new WeakSet()),
|
|
703
|
-
(ce = function (n) {
|
|
704
|
-
return n.refresh_token != null;
|
|
705
|
-
}),
|
|
706
|
-
(F = new WeakSet()),
|
|
707
|
-
(ue = function (n) {
|
|
708
|
-
return n.client_secret != null;
|
|
709
|
-
});
|
|
710
|
-
var X = ((r) => (
|
|
711
|
-
(r.eur = 'eur'), (r.usd = 'usd'), (r.gbp = 'gbp'), (r.isk = 'isk'), r
|
|
712
|
-
))(X || {}),
|
|
713
|
-
Z = ((r) => ((r.corporate = 'corporate'), (r.personal = 'personal'), r))(
|
|
714
|
-
Z || {},
|
|
715
|
-
),
|
|
716
|
-
K = ((r) => ((r.read = 'read'), (r.write = 'write'), r))(K || {}),
|
|
717
|
-
Y = ((r) => (
|
|
718
|
-
(r.absent = 'absent'),
|
|
719
|
-
(r.submitted = 'submitted'),
|
|
720
|
-
(r.pending = 'pending'),
|
|
721
|
-
(r.confirmed = 'confirmed'),
|
|
722
|
-
r
|
|
723
|
-
))(Y || {}),
|
|
724
|
-
ee = ((r) => (
|
|
725
|
-
(r.approved = 'approved'),
|
|
726
|
-
(r.rejected = 'rejected'),
|
|
727
|
-
(r.unknown = 'unknown'),
|
|
728
|
-
r
|
|
729
|
-
))(ee || {}),
|
|
730
|
-
re = ((r) => ((r.iban = 'iban'), (r.scan = 'scan'), r))(re || {}),
|
|
731
|
-
te = ((r) => (
|
|
732
|
-
(r.polygon = 'polygon'),
|
|
733
|
-
(r.ethereum = 'ethereum'),
|
|
734
|
-
(r.gnosis = 'gnosis'),
|
|
735
|
-
r
|
|
736
|
-
))(te || {}),
|
|
737
|
-
ne = ((r) => (
|
|
738
|
-
(r.mainnet = 'mainnet'),
|
|
739
|
-
(r.chiado = 'chiado'),
|
|
740
|
-
(r.goerli = 'goerli'),
|
|
741
|
-
(r.mumbai = 'mumbai'),
|
|
742
|
-
r
|
|
743
|
-
))(ne || {}),
|
|
744
|
-
ie = ((r) => ((r.redeem = 'redeem'), (r.issue = 'issue'), r))(ie || {}),
|
|
745
|
-
oe = ((r) => (
|
|
746
|
-
(r.placed = 'placed'),
|
|
747
|
-
(r.pending = 'pending'),
|
|
748
|
-
(r.processed = 'processed'),
|
|
749
|
-
(r.rejected = 'rejected'),
|
|
750
|
-
r
|
|
751
|
-
))(oe || {});
|
|
752
|
-
(a.Chain = te),
|
|
753
|
-
(a.Currency = X),
|
|
754
|
-
(a.KYCOutcome = ee),
|
|
755
|
-
(a.KYCState = Y),
|
|
756
|
-
(a.MoneriumClient = ge),
|
|
757
|
-
(a.Network = ne),
|
|
758
|
-
(a.OrderKind = ie),
|
|
759
|
-
(a.OrderState = oe),
|
|
760
|
-
(a.PaymentStandard = re),
|
|
761
|
-
(a.Permission = K),
|
|
762
|
-
(a.ProfileType = Z),
|
|
763
|
-
Object.defineProperty(a, Symbol.toStringTag, { value: 'Module' });
|
|
764
|
-
});
|
|
1
|
+
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a["monerium-sdk"]={}))})(this,function(a){var E,W,A,k,q,se,M,ce,F,ue;"use strict";var xe=Object.defineProperty;var Ce=(a,c,g)=>c in a?xe(a,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):a[c]=g;var I=(a,c,g)=>(Ce(a,typeof c!="symbol"?c+"":c,g),g),N=(a,c,g)=>{if(!c.has(a))throw TypeError("Cannot "+g)};var D=(a,c,g)=>(N(a,c,"read from private field"),g?g.call(a):c.get(a)),$=(a,c,g)=>{if(c.has(a))throw TypeError("Cannot add the same private member more than once");c instanceof WeakSet?c.add(a):c.set(a,g)},G=(a,c,g,z)=>(N(a,c,"write to private field"),z?z.call(a,g):c.set(a,g),g);var S=(a,c,g)=>(N(a,c,"access private method"),g);var c=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function g(r){if(r.__esModule)return r;var n=r.default;if(typeof n=="function"){var s=function u(){if(this instanceof u){var b=[null];b.push.apply(b,arguments);var p=Function.bind.apply(n,b);return new p}return n.apply(this,arguments)};s.prototype=n.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(r).forEach(function(u){var b=Object.getOwnPropertyDescriptor(r,u);Object.defineProperty(s,u,b.get?b:{enumerable:!0,get:function(){return r[u]}})}),s}var z={},fe={get exports(){return z},set exports(r){z=r}};function he(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var U={},le={get exports(){return U},set exports(r){U=r}};const de=g(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var J;function Q(){return J||(J=1,function(r,n){(function(s,u){r.exports=u()})(c,function(){var s=s||function(u,b){var p;if(typeof window<"u"&&window.crypto&&(p=window.crypto),typeof self<"u"&&self.crypto&&(p=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(p=globalThis.crypto),!p&&typeof window<"u"&&window.msCrypto&&(p=window.msCrypto),!p&&typeof c<"u"&&c.crypto&&(p=c.crypto),!p&&typeof he=="function")try{p=de}catch{}var H=function(){if(p){if(typeof p.getRandomValues=="function")try{return p.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof p.randomBytes=="function")try{return p.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},O=Object.create||function(){function e(){}return function(t){var o;return e.prototype=t,o=new e,e.prototype=null,o}}(),B={},R=B.lib={},_=R.Base=function(){return{extend:function(e){var t=O(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),v=R.WordArray=_.extend({init:function(e,t){e=this.words=e||[],t!=b?this.sigBytes=t:this.sigBytes=e.length*4},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,o=e.words,f=this.sigBytes,y=e.sigBytes;if(this.clamp(),f%4)for(var w=0;w<y;w++){var x=o[w>>>2]>>>24-w%4*8&255;t[f+w>>>2]|=x<<24-(f+w)%4*8}else for(var C=0;C<y;C+=4)t[f+C>>>2]=o[C>>>2];return this.sigBytes+=y,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=u.ceil(t/4)},clone:function(){var e=_.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],o=0;o<e;o+=4)t.push(H());return new v.init(t,e)}}),m=B.enc={},h=m.Hex={stringify:function(e){for(var t=e.words,o=e.sigBytes,f=[],y=0;y<o;y++){var w=t[y>>>2]>>>24-y%4*8&255;f.push((w>>>4).toString(16)),f.push((w&15).toString(16))}return f.join("")},parse:function(e){for(var t=e.length,o=[],f=0;f<t;f+=2)o[f>>>3]|=parseInt(e.substr(f,2),16)<<24-f%8*4;return new v.init(o,t/2)}},d=m.Latin1={stringify:function(e){for(var t=e.words,o=e.sigBytes,f=[],y=0;y<o;y++){var w=t[y>>>2]>>>24-y%4*8&255;f.push(String.fromCharCode(w))}return f.join("")},parse:function(e){for(var t=e.length,o=[],f=0;f<t;f++)o[f>>>2]|=(e.charCodeAt(f)&255)<<24-f%4*8;return new v.init(o,t)}},i=m.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},l=R.BufferedBlockAlgorithm=_.extend({reset:function(){this._data=new v.init,this._nDataBytes=0},_append:function(e){typeof e=="string"&&(e=i.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t,o=this._data,f=o.words,y=o.sigBytes,w=this.blockSize,x=w*4,C=y/x;e?C=u.ceil(C):C=u.max((C|0)-this._minBufferSize,0);var L=C*w,T=u.min(L*4,y);if(L){for(var j=0;j<L;j+=w)this._doProcessBlock(f,j);t=f.splice(0,L),o.sigBytes-=T}return new v.init(t,T)},clone:function(){var e=_.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});R.Hasher=l.extend({cfg:_.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},blockSize:16,_createHelper:function(e){return function(t,o){return new e.init(o).finalize(t)}},_createHmacHelper:function(e){return function(t,o){return new P.HMAC.init(e,o).finalize(t)}}});var P=B.algo={};return B}(Math);return s})}(le)),U}(function(r,n){(function(s,u){r.exports=u(Q())})(c,function(s){return function(){var u=s,b=u.lib,p=b.WordArray,H=u.enc;H.Base64url={stringify:function(B,R=!0){var _=B.words,v=B.sigBytes,m=R?this._safe_map:this._map;B.clamp();for(var h=[],d=0;d<v;d+=3)for(var i=_[d>>>2]>>>24-d%4*8&255,l=_[d+1>>>2]>>>24-(d+1)%4*8&255,P=_[d+2>>>2]>>>24-(d+2)%4*8&255,e=i<<16|l<<8|P,t=0;t<4&&d+t*.75<v;t++)h.push(m.charAt(e>>>6*(3-t)&63));var o=m.charAt(64);if(o)for(;h.length%4;)h.push(o);return h.join("")},parse:function(B,R=!0){var _=B.length,v=R?this._safe_map:this._map,m=this._reverseMap;if(!m){m=this._reverseMap=[];for(var h=0;h<v.length;h++)m[v.charCodeAt(h)]=h}var d=v.charAt(64);if(d){var i=B.indexOf(d);i!==-1&&(_=i)}return O(B,_,m)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function O(B,R,_){for(var v=[],m=0,h=0;h<R;h++)if(h%4){var d=_[B.charCodeAt(h-1)]<<h%4*2,i=_[B.charCodeAt(h)]>>>6-h%4*2,l=d|i;v[m>>>2]|=l<<24-m%4*8,m++}return p.create(v,m)}}(),s.enc.Base64url})})(fe);var V={},pe={get exports(){return V},set exports(r){V=r}};(function(r,n){(function(s,u){r.exports=u(Q())})(c,function(s){return function(u){var b=s,p=b.lib,H=p.WordArray,O=p.Hasher,B=b.algo,R=[],_=[];(function(){function h(P){for(var e=u.sqrt(P),t=2;t<=e;t++)if(!(P%t))return!1;return!0}function d(P){return(P-(P|0))*4294967296|0}for(var i=2,l=0;l<64;)h(i)&&(l<8&&(R[l]=d(u.pow(i,1/2))),_[l]=d(u.pow(i,1/3)),l++),i++})();var v=[],m=B.SHA256=O.extend({_doReset:function(){this._hash=new H.init(R.slice(0))},_doProcessBlock:function(h,d){for(var i=this._hash.words,l=i[0],P=i[1],e=i[2],t=i[3],o=i[4],f=i[5],y=i[6],w=i[7],x=0;x<64;x++){if(x<16)v[x]=h[d+x]|0;else{var C=v[x-15],L=(C<<25|C>>>7)^(C<<14|C>>>18)^C>>>3,T=v[x-2],j=(T<<15|T>>>17)^(T<<13|T>>>19)^T>>>10;v[x]=L+v[x-7]+j+v[x-16]}var me=o&f^~o&y,we=l&P^l&e^P&e,_e=(l<<30|l>>>2)^(l<<19|l>>>13)^(l<<10|l>>>22),be=(o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25),ae=w+be+me+_[x]+v[x],Be=_e+we;w=y,y=f,f=o,o=t+ae|0,t=e,e=P,P=l,l=ae+Be|0}i[0]=i[0]+l|0,i[1]=i[1]+P|0,i[2]=i[2]+e|0,i[3]=i[3]+t|0,i[4]=i[4]+o|0,i[5]=i[5]+f|0,i[6]=i[6]+y|0,i[7]=i[7]+w|0},_doFinalize:function(){var h=this._data,d=h.words,i=this._nDataBytes*8,l=h.sigBytes*8;return d[l>>>5]|=128<<24-l%32,d[(l+64>>>9<<4)+14]=u.floor(i/4294967296),d[(l+64>>>9<<4)+15]=i,h.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var h=O.clone.call(this);return h._hash=this._hash.clone(),h}});b.SHA256=O._createHelper(m),b.HmacSHA256=O._createHmacHelper(m)}(Math),s.SHA256})})(pe);const ve=()=>{let r="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=n.length;let u=0;for(;u<128;)r+=n.charAt(Math.floor(Math.random()*s)),u+=1;return r},ye={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev"}}};class ge{constructor(n="sandbox"){$(this,A);$(this,q);$(this,M);$(this,F);$(this,E,void 0);$(this,W,void 0);I(this,"codeVerifier");I(this,"bearerProfile");I(this,"pkceRequest",n=>this.getAuthFlowURI(n));G(this,E,ye.environments[n])}async auth(n){let s;if(S(this,q,se).call(this,n))s={...n,grant_type:"authorization_code"};else if(S(this,M,ce).call(this,n))s={...n,grant_type:"refresh_token"};else if(S(this,F,ue).call(this,n))s={...n,grant_type:"client_credentials"};else throw new Error("Authentication method could not be detected.");return this.bearerProfile=await S(this,A,k).call(this,"post","auth/token",new URLSearchParams(s),!0),G(this,W,`Bearer ${this.bearerProfile.access_token}`),this.bearerProfile}getAuthFlowURI(n){this.codeVerifier=ve();const s=z.stringify(V(this.codeVerifier)),u={...n,client_id:n==null?void 0:n.client_id,code_challenge:s,code_challenge_method:"S256",response_type:"code"};return`${D(this,E).api}/auth?${new URLSearchParams(u)}`}getAuthContext(){return S(this,A,k).call(this,"get","auth/context")}getProfile(n){return S(this,A,k).call(this,"get",`profiles/${n}`)}getBalances(n){return n?S(this,A,k).call(this,"get",`profiles/${n}/balances`):S(this,A,k).call(this,"get","balances")}getOrders(n){const s=new URLSearchParams(n);return S(this,A,k).call(this,"get",`orders?${s}`)}getOrder(n){return S(this,A,k).call(this,"get",`orders/${n}`)}getTokens(){return S(this,A,k).call(this,"get","tokens")}linkAddress(n,s){return S(this,A,k).call(this,"post",`profiles/${n}/addresses`,JSON.stringify(s))}placeOrder(n,s){return s?S(this,A,k).call(this,"post",`profiles/${s}/orders`,JSON.stringify(n)):S(this,A,k).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(n){const s=new URLSearchParams(n);return S(this,A,k).call(this,"post","files/supporting-document",s,!0)}}E=new WeakMap,W=new WeakMap,A=new WeakSet,k=async function(n,s,u,b){const p=await fetch(`${D(this,E).api}/${s}`,{method:n,headers:{"Content-Type":`application/${b?"x-www-form-urlencoded":"json"}`,Authorization:D(this,W)||""},body:u});let H;try{H=await p.json()}catch{throw await p.text()}if(p.ok)return H;throw H},q=new WeakSet,se=function(n){return n.code!=null},M=new WeakSet,ce=function(n){return n.refresh_token!=null},F=new WeakSet,ue=function(n){return n.client_secret!=null};var X=(r=>(r.eur="eur",r.usd="usd",r.gbp="gbp",r.isk="isk",r))(X||{}),Z=(r=>(r.corporate="corporate",r.personal="personal",r))(Z||{}),K=(r=>(r.read="read",r.write="write",r))(K||{}),Y=(r=>(r.absent="absent",r.submitted="submitted",r.pending="pending",r.confirmed="confirmed",r))(Y||{}),ee=(r=>(r.approved="approved",r.rejected="rejected",r.unknown="unknown",r))(ee||{}),re=(r=>(r.iban="iban",r.scan="scan",r))(re||{}),te=(r=>(r.polygon="polygon",r.ethereum="ethereum",r.gnosis="gnosis",r))(te||{}),ne=(r=>(r.mainnet="mainnet",r.chiado="chiado",r.goerli="goerli",r.mumbai="mumbai",r))(ne||{}),ie=(r=>(r.redeem="redeem",r.issue="issue",r))(ie||{}),oe=(r=>(r.placed="placed",r.pending="pending",r.processed="processed",r.rejected="rejected",r))(oe||{});a.Chain=te,a.Currency=X,a.KYCOutcome=ee,a.KYCState=Y,a.MoneriumClient=ge,a.Network=ne,a.OrderKind=ie,a.OrderState=oe,a.PaymentStandard=re,a.Permission=K,a.ProfileType=Z,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
765
2
|
//# sourceMappingURL=index.umd.js.map
|