@frak-labs/core-sdk 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,833 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk665P7NO4_cjs = require('./chunk-665P7NO4.cjs');
4
- var jsSha256 = require('js-sha256');
5
- var viem = require('viem');
6
-
7
- // ../../node_modules/async-lz-string/libs/async-lz-string.js
8
- var require_async_lz_string = chunk665P7NO4_cjs.__commonJS({
9
- "../../node_modules/async-lz-string/libs/async-lz-string.js"(exports, module) {
10
- !function(t, e) {
11
- if ("object" == typeof exports && "object" == typeof module) module.exports = e();
12
- else if ("function" == typeof define && define.amd) define([], e);
13
- else {
14
- var n = e();
15
- for (var r in n) ("object" == typeof exports ? exports : t)[r] = n[r];
16
- }
17
- }(exports, () => (() => {
18
- var t = { 48: function(t2, e2, n) {
19
- var r = this && this.__awaiter || function(t3, e3, n2, r2) {
20
- return new (n2 || (n2 = Promise))(function(a2, o2) {
21
- function i2(t4) {
22
- try {
23
- u2(r2.next(t4));
24
- } catch (t5) {
25
- o2(t5);
26
- }
27
- }
28
- function s2(t4) {
29
- try {
30
- u2(r2.throw(t4));
31
- } catch (t5) {
32
- o2(t5);
33
- }
34
- }
35
- function u2(t4) {
36
- var e4;
37
- t4.done ? a2(t4.value) : (e4 = t4.value, e4 instanceof n2 ? e4 : new n2(function(t5) {
38
- t5(e4);
39
- })).then(i2, s2);
40
- }
41
- u2((r2 = r2.apply(t3, e3 || [])).next());
42
- });
43
- }, a = this && this.__generator || function(t3, e3) {
44
- var n2, r2, a2, o2, i2 = { label: 0, sent: function() {
45
- if (1 & a2[0]) throw a2[1];
46
- return a2[1];
47
- }, trys: [], ops: [] };
48
- return o2 = { next: s2(0), throw: s2(1), return: s2(2) }, "function" == typeof Symbol && (o2[Symbol.iterator] = function() {
49
- return this;
50
- }), o2;
51
- function s2(s3) {
52
- return function(u2) {
53
- return function(s4) {
54
- if (n2) throw new TypeError("Generator is already executing.");
55
- for (; o2 && (o2 = 0, s4[0] && (i2 = 0)), i2; ) try {
56
- if (n2 = 1, r2 && (a2 = 2 & s4[0] ? r2.return : s4[0] ? r2.throw || ((a2 = r2.return) && a2.call(r2), 0) : r2.next) && !(a2 = a2.call(r2, s4[1])).done) return a2;
57
- switch (r2 = 0, a2 && (s4 = [2 & s4[0], a2.value]), s4[0]) {
58
- case 0:
59
- case 1:
60
- a2 = s4;
61
- break;
62
- case 4:
63
- return i2.label++, { value: s4[1], done: false };
64
- case 5:
65
- i2.label++, r2 = s4[1], s4 = [0];
66
- continue;
67
- case 7:
68
- s4 = i2.ops.pop(), i2.trys.pop();
69
- continue;
70
- default:
71
- if (!((a2 = (a2 = i2.trys).length > 0 && a2[a2.length - 1]) || 6 !== s4[0] && 2 !== s4[0])) {
72
- i2 = 0;
73
- continue;
74
- }
75
- if (3 === s4[0] && (!a2 || s4[1] > a2[0] && s4[1] < a2[3])) {
76
- i2.label = s4[1];
77
- break;
78
- }
79
- if (6 === s4[0] && i2.label < a2[1]) {
80
- i2.label = a2[1], a2 = s4;
81
- break;
82
- }
83
- if (a2 && i2.label < a2[2]) {
84
- i2.label = a2[2], i2.ops.push(s4);
85
- break;
86
- }
87
- a2[2] && i2.ops.pop(), i2.trys.pop();
88
- continue;
89
- }
90
- s4 = e3.call(t3, i2);
91
- } catch (t4) {
92
- s4 = [6, t4], r2 = 0;
93
- } finally {
94
- n2 = a2 = 0;
95
- }
96
- if (5 & s4[0]) throw s4[1];
97
- return { value: s4[0] ? s4[1] : undefined, done: true };
98
- }([s3, u2]);
99
- };
100
- }
101
- };
102
- Object.defineProperty(e2, "__esModule", { value: true }), e2.decompressFromUTF16 = e2.compressToUTF16 = e2.decompressFromBase64 = e2.compressToBase64 = undefined;
103
- var o = n(304), i = n(134), s = new o.CompressorImpl(), u = new i.DecompressorImpl(), c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = {};
104
- e2.compressToBase64 = function(t3) {
105
- return r(this, undefined, undefined, function() {
106
- var e3;
107
- return a(this, function(n2) {
108
- switch (n2.label) {
109
- case 0:
110
- return null === t3 ? [2, ""] : [4, s.compress(t3, 6, function(t4) {
111
- return c.charAt(t4);
112
- })];
113
- case 1:
114
- switch ((e3 = n2.sent()).length % 4) {
115
- default:
116
- case 0:
117
- return [2, e3];
118
- case 1:
119
- return [2, e3 + "==="];
120
- case 2:
121
- return [2, e3 + "=="];
122
- case 3:
123
- return [2, e3 + "="];
124
- }
125
- return [2];
126
- }
127
- });
128
- });
129
- }, e2.decompressFromBase64 = function(t3) {
130
- return r(this, undefined, undefined, function() {
131
- return a(this, function(e3) {
132
- switch (e3.label) {
133
- case 0:
134
- return null === t3 ? [2, ""] : "" === t3 ? [2, null] : [4, u.decompress(t3.length, 32, function(e4) {
135
- return function(t4, e5) {
136
- if (!l[t4]) {
137
- l[t4] = {};
138
- for (var n2 = 0; n2 < t4.length; n2++) l[t4][t4.charAt(n2)] = n2;
139
- }
140
- return l[t4][e5];
141
- }(c, t3.charAt(e4));
142
- })];
143
- case 1:
144
- return [2, e3.sent()];
145
- }
146
- });
147
- });
148
- }, e2.compressToUTF16 = function(t3) {
149
- return r(this, undefined, undefined, function() {
150
- return a(this, function(e3) {
151
- switch (e3.label) {
152
- case 0:
153
- return null === t3 ? [2, ""] : [4, s.compress(t3, 15, function(t4) {
154
- return String.fromCharCode(t4 + 32);
155
- })];
156
- case 1:
157
- return [2, e3.sent() + " "];
158
- }
159
- });
160
- });
161
- }, e2.decompressFromUTF16 = function(t3) {
162
- return r(this, undefined, undefined, function() {
163
- return a(this, function(e3) {
164
- switch (e3.label) {
165
- case 0:
166
- return null === t3 ? [2, ""] : "" === t3 ? [2, null] : [4, u.decompress(t3.length, 16384, function(e4) {
167
- return t3.charCodeAt(e4) - 32;
168
- })];
169
- case 1:
170
- return [2, e3.sent()];
171
- }
172
- });
173
- });
174
- };
175
- }, 304: function(t2, e2, n) {
176
- var r = this && this.__awaiter || function(t3, e3, n2, r2) {
177
- return new (n2 || (n2 = Promise))(function(a2, o2) {
178
- function i2(t4) {
179
- try {
180
- u(r2.next(t4));
181
- } catch (t5) {
182
- o2(t5);
183
- }
184
- }
185
- function s2(t4) {
186
- try {
187
- u(r2.throw(t4));
188
- } catch (t5) {
189
- o2(t5);
190
- }
191
- }
192
- function u(t4) {
193
- var e4;
194
- t4.done ? a2(t4.value) : (e4 = t4.value, e4 instanceof n2 ? e4 : new n2(function(t5) {
195
- t5(e4);
196
- })).then(i2, s2);
197
- }
198
- u((r2 = r2.apply(t3, e3 || [])).next());
199
- });
200
- }, a = this && this.__generator || function(t3, e3) {
201
- var n2, r2, a2, o2, i2 = { label: 0, sent: function() {
202
- if (1 & a2[0]) throw a2[1];
203
- return a2[1];
204
- }, trys: [], ops: [] };
205
- return o2 = { next: s2(0), throw: s2(1), return: s2(2) }, "function" == typeof Symbol && (o2[Symbol.iterator] = function() {
206
- return this;
207
- }), o2;
208
- function s2(s3) {
209
- return function(u) {
210
- return function(s4) {
211
- if (n2) throw new TypeError("Generator is already executing.");
212
- for (; o2 && (o2 = 0, s4[0] && (i2 = 0)), i2; ) try {
213
- if (n2 = 1, r2 && (a2 = 2 & s4[0] ? r2.return : s4[0] ? r2.throw || ((a2 = r2.return) && a2.call(r2), 0) : r2.next) && !(a2 = a2.call(r2, s4[1])).done) return a2;
214
- switch (r2 = 0, a2 && (s4 = [2 & s4[0], a2.value]), s4[0]) {
215
- case 0:
216
- case 1:
217
- a2 = s4;
218
- break;
219
- case 4:
220
- return i2.label++, { value: s4[1], done: false };
221
- case 5:
222
- i2.label++, r2 = s4[1], s4 = [0];
223
- continue;
224
- case 7:
225
- s4 = i2.ops.pop(), i2.trys.pop();
226
- continue;
227
- default:
228
- if (!((a2 = (a2 = i2.trys).length > 0 && a2[a2.length - 1]) || 6 !== s4[0] && 2 !== s4[0])) {
229
- i2 = 0;
230
- continue;
231
- }
232
- if (3 === s4[0] && (!a2 || s4[1] > a2[0] && s4[1] < a2[3])) {
233
- i2.label = s4[1];
234
- break;
235
- }
236
- if (6 === s4[0] && i2.label < a2[1]) {
237
- i2.label = a2[1], a2 = s4;
238
- break;
239
- }
240
- if (a2 && i2.label < a2[2]) {
241
- i2.label = a2[2], i2.ops.push(s4);
242
- break;
243
- }
244
- a2[2] && i2.ops.pop(), i2.trys.pop();
245
- continue;
246
- }
247
- s4 = e3.call(t3, i2);
248
- } catch (t4) {
249
- s4 = [6, t4], r2 = 0;
250
- } finally {
251
- n2 = a2 = 0;
252
- }
253
- if (5 & s4[0]) throw s4[1];
254
- return { value: s4[0] ? s4[1] : undefined, done: true };
255
- }([s3, u]);
256
- };
257
- }
258
- };
259
- Object.defineProperty(e2, "__esModule", { value: true }), e2.CompressorImpl = undefined;
260
- var o = n(658), i = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], s = function() {
261
- function t3() {
262
- }
263
- return t3.writeValueToData = function(t4, e3, n2, r2, a2) {
264
- if (n2 % 4 != 0 || t4.dataPosition + n2 > r2 - 1) for (var o2 = 0; o2 < n2; o2++) t4.dataVal = t4.dataVal << 1 | 1 & e3, t4.dataPosition == r2 - 1 ? (t4.dataPosition = 0, t4.data.push(a2(t4.dataVal)), t4.dataVal = 0) : t4.dataPosition++, e3 >>= 1;
265
- else t4.dataVal <<= n2, t4.dataVal |= function(t5, e4) {
266
- for (var n3 = 0, r3 = 0; r3 < e4; ++r3) n3 <<= 4, n3 |= i[15 & t5], t5 >>= 4;
267
- return n3;
268
- }(e3, n2 / 4), t4.dataPosition += n2;
269
- }, t3.writeWToDataVal = function(e3, n2, r2) {
270
- e3.dictionaryToCreate.has(e3.w) ? (e3.w.charCodeAt(0) < 256 ? (t3.writeValueToData(e3, 0, e3.numBits, n2, r2), t3.writeValueToData(e3, e3.w.charCodeAt(0), 8, n2, r2)) : (t3.writeValueToData(e3, 1, e3.numBits, n2, r2), t3.writeValueToData(e3, e3.w.charCodeAt(0), 16, n2, r2)), e3.enlargeIn--, 0 == e3.enlargeIn && (e3.enlargeIn = Math.pow(2, e3.numBits), e3.numBits++), e3.dictionaryToCreate.delete(e3.w)) : t3.writeValueToData(e3, e3.dictionary.get(e3.w), e3.numBits, n2, r2), e3.enlargeIn--, 0 == e3.enlargeIn && (e3.enlargeIn = Math.pow(2, e3.numBits), e3.numBits++);
271
- }, t3.loopIteration = function(t4, e3, n2, r2, a2) {
272
- var o2 = t4.charAt(e3);
273
- a2.dictionary.has(o2) || (a2.dictionary.set(o2, a2.dictSize++), a2.dictionaryToCreate.set(o2, true));
274
- var i2 = a2.w + o2;
275
- a2.dictionary.has(i2) ? a2.w = i2 : (this.writeWToDataVal(a2, n2, r2), a2.dictionary.set(i2, a2.dictSize++), a2.w = String(o2));
276
- }, t3.prototype.compress = function(e3, n2, i2) {
277
- var s2 = this;
278
- return new Promise(function(u) {
279
- return r(s2, undefined, undefined, function() {
280
- var r2, s3;
281
- return a(this, function(a2) {
282
- switch (a2.label) {
283
- case 0:
284
- if (null == e3) return u(""), [2];
285
- r2 = { data: [], dataPosition: 0, dataVal: 0, dictionary: /* @__PURE__ */ new Map(), dictionaryToCreate: /* @__PURE__ */ new Map(), dictSize: 3, enlargeIn: 2, numBits: 2, w: "" }, s3 = 0, a2.label = 1;
286
- case 1:
287
- return s3 < e3.length ? (t3.loopIteration(e3, s3, n2, i2, r2), s3 % 1e4 != 0 ? [3, 3] : [4, (0, o.wait)()]) : [3, 4];
288
- case 2:
289
- a2.sent(), a2.label = 3;
290
- case 3:
291
- return s3 += 1, [3, 1];
292
- case 4:
293
- return "" !== r2.w && t3.writeWToDataVal(r2, n2, i2), t3.writeValueToData(r2, 2, r2.numBits, n2, i2), r2.dataVal <<= n2 - r2.dataPosition, r2.data.push(i2(r2.dataVal)), u(r2.data.join("")), [2];
294
- }
295
- });
296
- });
297
- });
298
- }, t3;
299
- }();
300
- e2.CompressorImpl = s;
301
- }, 134: function(t2, e2, n) {
302
- var r = this && this.__awaiter || function(t3, e3, n2, r2) {
303
- return new (n2 || (n2 = Promise))(function(a2, o2) {
304
- function i2(t4) {
305
- try {
306
- u(r2.next(t4));
307
- } catch (t5) {
308
- o2(t5);
309
- }
310
- }
311
- function s(t4) {
312
- try {
313
- u(r2.throw(t4));
314
- } catch (t5) {
315
- o2(t5);
316
- }
317
- }
318
- function u(t4) {
319
- var e4;
320
- t4.done ? a2(t4.value) : (e4 = t4.value, e4 instanceof n2 ? e4 : new n2(function(t5) {
321
- t5(e4);
322
- })).then(i2, s);
323
- }
324
- u((r2 = r2.apply(t3, e3 || [])).next());
325
- });
326
- }, a = this && this.__generator || function(t3, e3) {
327
- var n2, r2, a2, o2, i2 = { label: 0, sent: function() {
328
- if (1 & a2[0]) throw a2[1];
329
- return a2[1];
330
- }, trys: [], ops: [] };
331
- return o2 = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (o2[Symbol.iterator] = function() {
332
- return this;
333
- }), o2;
334
- function s(s2) {
335
- return function(u) {
336
- return function(s3) {
337
- if (n2) throw new TypeError("Generator is already executing.");
338
- for (; o2 && (o2 = 0, s3[0] && (i2 = 0)), i2; ) try {
339
- if (n2 = 1, r2 && (a2 = 2 & s3[0] ? r2.return : s3[0] ? r2.throw || ((a2 = r2.return) && a2.call(r2), 0) : r2.next) && !(a2 = a2.call(r2, s3[1])).done) return a2;
340
- switch (r2 = 0, a2 && (s3 = [2 & s3[0], a2.value]), s3[0]) {
341
- case 0:
342
- case 1:
343
- a2 = s3;
344
- break;
345
- case 4:
346
- return i2.label++, { value: s3[1], done: false };
347
- case 5:
348
- i2.label++, r2 = s3[1], s3 = [0];
349
- continue;
350
- case 7:
351
- s3 = i2.ops.pop(), i2.trys.pop();
352
- continue;
353
- default:
354
- if (!((a2 = (a2 = i2.trys).length > 0 && a2[a2.length - 1]) || 6 !== s3[0] && 2 !== s3[0])) {
355
- i2 = 0;
356
- continue;
357
- }
358
- if (3 === s3[0] && (!a2 || s3[1] > a2[0] && s3[1] < a2[3])) {
359
- i2.label = s3[1];
360
- break;
361
- }
362
- if (6 === s3[0] && i2.label < a2[1]) {
363
- i2.label = a2[1], a2 = s3;
364
- break;
365
- }
366
- if (a2 && i2.label < a2[2]) {
367
- i2.label = a2[2], i2.ops.push(s3);
368
- break;
369
- }
370
- a2[2] && i2.ops.pop(), i2.trys.pop();
371
- continue;
372
- }
373
- s3 = e3.call(t3, i2);
374
- } catch (t4) {
375
- s3 = [6, t4], r2 = 0;
376
- } finally {
377
- n2 = a2 = 0;
378
- }
379
- if (5 & s3[0]) throw s3[1];
380
- return { value: s3[0] ? s3[1] : undefined, done: true };
381
- }([s2, u]);
382
- };
383
- }
384
- };
385
- Object.defineProperty(e2, "__esModule", { value: true }), e2.DecompressorImpl = undefined;
386
- var o = n(658), i = function() {
387
- function t3() {
388
- }
389
- return t3.prototype.decompress = function(t4, e3, n2) {
390
- var i2 = this;
391
- return new Promise(function(s) {
392
- return r(i2, undefined, undefined, function() {
393
- var r2, i3, u;
394
- return a(this, function(a2) {
395
- switch (a2.label) {
396
- case 0:
397
- for (r2 = { bits: 0, c: null, dataIndex: 1, dataPosition: e3, dataVal: n2(0), dictionary: /* @__PURE__ */ new Map(), dictSize: 4, enlargeIn: 4, entry: "", maxPower: Math.pow(2, 2), numBits: 3, power: 1, resb: null, result: [], w: null }, i3 = 0; i3 < 3; i3 += 1) r2.dictionary.set(i3, i3);
398
- for (; r2.power != r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 == r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
399
- switch (r2.bits) {
400
- case 0:
401
- for (r2.bits = 0, r2.maxPower = Math.pow(2, 8), r2.power = 1; r2.power != r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 == r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
402
- r2.c = String.fromCharCode(r2.bits);
403
- break;
404
- case 1:
405
- for (r2.bits = 0, r2.maxPower = Math.pow(2, 16), r2.power = 1; r2.power !== r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 === r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
406
- r2.c = String.fromCharCode(r2.bits);
407
- break;
408
- case 2:
409
- return s(""), [2];
410
- }
411
- r2.dictionary[3] = r2.c, r2.w = r2.c, r2.result.push(r2.c), u = 1, a2.label = 1;
412
- case 1:
413
- return u % 2e4 != 0 ? [3, 3] : [4, (0, o.wait)()];
414
- case 2:
415
- a2.sent(), a2.label = 3;
416
- case 3:
417
- if (r2.dataIndex > t4) return s(""), [2];
418
- for (r2.bits = 0, r2.maxPower = Math.pow(2, r2.numBits), r2.power = 1; r2.power != r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 == r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
419
- switch (r2.c = r2.bits) {
420
- case 0:
421
- for (r2.bits = 0, r2.maxPower = Math.pow(2, 8), r2.power = 1; r2.power !== r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 == r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
422
- r2.dictionary[r2.dictSize++] = String.fromCharCode(r2.bits), r2.c = r2.dictSize - 1, r2.enlargeIn--;
423
- break;
424
- case 1:
425
- for (r2.bits = 0, r2.maxPower = Math.pow(2, 16), r2.power = 1; r2.power !== r2.maxPower; ) r2.resb = r2.dataVal & r2.dataPosition, r2.dataPosition >>= 1, 0 == r2.dataPosition && (r2.dataPosition = e3, r2.dataVal = n2(r2.dataIndex++)), r2.bits |= (r2.resb > 0 ? 1 : 0) * r2.power, r2.power <<= 1;
426
- r2.dictionary[r2.dictSize++] = String.fromCharCode(r2.bits), r2.c = r2.dictSize - 1, r2.enlargeIn--;
427
- break;
428
- case 2:
429
- return s(r2.result.join("")), [2];
430
- }
431
- if (0 == r2.enlargeIn && (r2.enlargeIn = Math.pow(2, r2.numBits), r2.numBits++), r2.dictionary[r2.c]) r2.entry = r2.dictionary[r2.c];
432
- else {
433
- if (r2.c !== r2.dictSize) return s(null), [2];
434
- r2.entry = r2.w + r2.w.charAt(0);
435
- }
436
- return r2.result.push(r2.entry), r2.dictionary[r2.dictSize++] = r2.w + r2.entry.charAt(0), r2.enlargeIn--, r2.w = r2.entry, 0 == r2.enlargeIn && (r2.enlargeIn = Math.pow(2, r2.numBits), r2.numBits++), u++, [3, 1];
437
- case 4:
438
- return [2];
439
- }
440
- });
441
- });
442
- });
443
- }, t3;
444
- }();
445
- e2.DecompressorImpl = i;
446
- }, 658: function(t2, e2) {
447
- var n = this && this.__awaiter || function(t3, e3, n2, r2) {
448
- return new (n2 || (n2 = Promise))(function(a, o) {
449
- function i(t4) {
450
- try {
451
- u(r2.next(t4));
452
- } catch (t5) {
453
- o(t5);
454
- }
455
- }
456
- function s(t4) {
457
- try {
458
- u(r2.throw(t4));
459
- } catch (t5) {
460
- o(t5);
461
- }
462
- }
463
- function u(t4) {
464
- var e4;
465
- t4.done ? a(t4.value) : (e4 = t4.value, e4 instanceof n2 ? e4 : new n2(function(t5) {
466
- t5(e4);
467
- })).then(i, s);
468
- }
469
- u((r2 = r2.apply(t3, e3 || [])).next());
470
- });
471
- }, r = this && this.__generator || function(t3, e3) {
472
- var n2, r2, a, o, i = { label: 0, sent: function() {
473
- if (1 & a[0]) throw a[1];
474
- return a[1];
475
- }, trys: [], ops: [] };
476
- return o = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (o[Symbol.iterator] = function() {
477
- return this;
478
- }), o;
479
- function s(s2) {
480
- return function(u) {
481
- return function(s3) {
482
- if (n2) throw new TypeError("Generator is already executing.");
483
- for (; o && (o = 0, s3[0] && (i = 0)), i; ) try {
484
- if (n2 = 1, r2 && (a = 2 & s3[0] ? r2.return : s3[0] ? r2.throw || ((a = r2.return) && a.call(r2), 0) : r2.next) && !(a = a.call(r2, s3[1])).done) return a;
485
- switch (r2 = 0, a && (s3 = [2 & s3[0], a.value]), s3[0]) {
486
- case 0:
487
- case 1:
488
- a = s3;
489
- break;
490
- case 4:
491
- return i.label++, { value: s3[1], done: false };
492
- case 5:
493
- i.label++, r2 = s3[1], s3 = [0];
494
- continue;
495
- case 7:
496
- s3 = i.ops.pop(), i.trys.pop();
497
- continue;
498
- default:
499
- if (!((a = (a = i.trys).length > 0 && a[a.length - 1]) || 6 !== s3[0] && 2 !== s3[0])) {
500
- i = 0;
501
- continue;
502
- }
503
- if (3 === s3[0] && (!a || s3[1] > a[0] && s3[1] < a[3])) {
504
- i.label = s3[1];
505
- break;
506
- }
507
- if (6 === s3[0] && i.label < a[1]) {
508
- i.label = a[1], a = s3;
509
- break;
510
- }
511
- if (a && i.label < a[2]) {
512
- i.label = a[2], i.ops.push(s3);
513
- break;
514
- }
515
- a[2] && i.ops.pop(), i.trys.pop();
516
- continue;
517
- }
518
- s3 = e3.call(t3, i);
519
- } catch (t4) {
520
- s3 = [6, t4], r2 = 0;
521
- } finally {
522
- n2 = a = 0;
523
- }
524
- if (5 & s3[0]) throw s3[1];
525
- return { value: s3[0] ? s3[1] : undefined, done: true };
526
- }([s2, u]);
527
- };
528
- }
529
- };
530
- Object.defineProperty(e2, "__esModule", { value: true }), e2.wait = undefined, e2.wait = function() {
531
- return n(this, undefined, undefined, function() {
532
- return r(this, function(t3) {
533
- return [2, new Promise(function(t4) {
534
- setTimeout(t4, 0);
535
- })];
536
- });
537
- });
538
- };
539
- } }, e = {};
540
- return function n(r) {
541
- var a = e[r];
542
- if (undefined !== a) return a.exports;
543
- var o = e[r] = { exports: {} };
544
- return t[r].call(o.exports, o, o.exports, n), o.exports;
545
- }(48);
546
- })());
547
- }
548
- });
549
-
550
- // src/types/rpc/error.ts
551
- var FrakRpcError = class extends Error {
552
- constructor(code, message, data) {
553
- super(message);
554
- this.code = code;
555
- this.data = data;
556
- }
557
- };
558
- var InternalError = class extends FrakRpcError {
559
- constructor(message) {
560
- super(RpcErrorCodes.internalError, message);
561
- }
562
- };
563
- var ClientNotFound = class extends FrakRpcError {
564
- constructor() {
565
- super(RpcErrorCodes.clientNotConnected, "Client not found");
566
- }
567
- };
568
- var RpcErrorCodes = {
569
- // Standard JSON-RPC 2.0 errors
570
- parseError: -32700,
571
- invalidRequest: -32600,
572
- methodNotFound: -32601,
573
- invalidParams: -32602,
574
- internalError: -32603,
575
- serverError: -32e3,
576
- // Frak specific errors (from -32001 to -32099)
577
- clientNotConnected: -32001,
578
- configError: -32002,
579
- corruptedResponse: -32003,
580
- clientAborted: -32004,
581
- walletNotConnected: -32005,
582
- serverErrorForInteractionDelegation: -32006
583
- };
584
-
585
- // src/utils/Deferred.ts
586
- var Deferred = class {
587
- _promise;
588
- _resolve;
589
- _reject;
590
- constructor() {
591
- this._promise = new Promise((resolve, reject) => {
592
- this._resolve = resolve;
593
- this._reject = reject;
594
- });
595
- }
596
- get promise() {
597
- return this._promise;
598
- }
599
- resolve = (value) => {
600
- this._resolve?.(value);
601
- };
602
- reject = (reason) => {
603
- this._reject?.(reason);
604
- };
605
- };
606
-
607
- // src/utils/compression/compress.ts
608
- var import_async_lz_string = chunk665P7NO4_cjs.__toESM(require_async_lz_string(), 1);
609
- async function hashAndCompressData(data) {
610
- const validationHash = jsSha256.sha256(JSON.stringify(data));
611
- const hashProtectedData = {
612
- ...data,
613
- validationHash
614
- };
615
- const compressed = await compressJson(hashProtectedData);
616
- const compressedHash = jsSha256.sha256(compressed);
617
- return {
618
- compressed,
619
- compressedHash
620
- };
621
- }
622
- async function compressJson(data) {
623
- return (0, import_async_lz_string.compressToBase64)(JSON.stringify(data));
624
- }
625
-
626
- // src/utils/compression/decompress.ts
627
- var import_async_lz_string2 = chunk665P7NO4_cjs.__toESM(require_async_lz_string(), 1);
628
- async function decompressDataAndCheckHash(compressedData) {
629
- if (!(compressedData?.compressed && compressedData?.compressedHash)) {
630
- throw new FrakRpcError(
631
- RpcErrorCodes.corruptedResponse,
632
- "Missing compressed data"
633
- );
634
- }
635
- const parsedData = await decompressJson(
636
- compressedData.compressed
637
- );
638
- if (!parsedData) {
639
- throw new FrakRpcError(
640
- RpcErrorCodes.corruptedResponse,
641
- "Invalid compressed data"
642
- );
643
- }
644
- if (!parsedData?.validationHash) {
645
- throw new FrakRpcError(
646
- RpcErrorCodes.corruptedResponse,
647
- "Missing validation hash"
648
- );
649
- }
650
- const expectedCompressedHash = jsSha256.sha256(compressedData.compressed);
651
- if (expectedCompressedHash !== compressedData.compressedHash) {
652
- throw new FrakRpcError(
653
- RpcErrorCodes.corruptedResponse,
654
- "Invalid compressed hash"
655
- );
656
- }
657
- const { validationHash: _, ...rawResultData } = parsedData;
658
- const expectedValidationHash = jsSha256.sha256(JSON.stringify(rawResultData));
659
- if (expectedValidationHash !== parsedData.validationHash) {
660
- throw new FrakRpcError(
661
- RpcErrorCodes.corruptedResponse,
662
- "Invalid data validation hash"
663
- );
664
- }
665
- return parsedData;
666
- }
667
- async function decompressJson(data) {
668
- const decompressed = await (0, import_async_lz_string2.decompressFromBase64)(data);
669
- try {
670
- return JSON.parse(decompressed);
671
- } catch (e) {
672
- console.error("Invalid compressed data", { e, decompressed });
673
- return null;
674
- }
675
- }
676
-
677
- // src/utils/iframeHelper.ts
678
- var baseIframeProps = {
679
- id: "nexus-wallet",
680
- name: "nexus-wallet",
681
- allow: "publickey-credentials-get *; clipboard-write; web-share *",
682
- style: {
683
- width: "0",
684
- height: "0",
685
- border: "0",
686
- position: "absolute",
687
- zIndex: 2000001,
688
- top: "-1000px",
689
- left: "-1000px"
690
- }
691
- };
692
- function createIframe({
693
- walletBaseUrl,
694
- config
695
- }) {
696
- const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
697
- if (alreadyCreatedIFrame) {
698
- alreadyCreatedIFrame.remove();
699
- }
700
- const iframe = document.createElement("iframe");
701
- iframe.id = baseIframeProps.id;
702
- iframe.name = baseIframeProps.name;
703
- iframe.allow = baseIframeProps.allow;
704
- iframe.style.zIndex = baseIframeProps.style.zIndex.toString();
705
- changeIframeVisibility({ iframe, isVisible: false });
706
- document.body.appendChild(iframe);
707
- return new Promise((resolve) => {
708
- iframe?.addEventListener("load", () => resolve(iframe));
709
- iframe.src = `${config?.walletUrl ?? walletBaseUrl ?? "https://wallet.frak.id"}/listener`;
710
- });
711
- }
712
- function changeIframeVisibility({
713
- iframe,
714
- isVisible
715
- }) {
716
- if (!isVisible) {
717
- iframe.style.width = "0";
718
- iframe.style.height = "0";
719
- iframe.style.border = "0";
720
- iframe.style.position = "fixed";
721
- iframe.style.top = "-1000px";
722
- iframe.style.left = "-1000px";
723
- return;
724
- }
725
- iframe.style.position = "fixed";
726
- iframe.style.top = "0";
727
- iframe.style.left = "0";
728
- iframe.style.width = "100%";
729
- iframe.style.height = "100%";
730
- iframe.style.pointerEvents = "auto";
731
- }
732
- var contextKey = "fCtx";
733
- function base64url_encode(buffer) {
734
- return btoa(Array.from(buffer, (b) => String.fromCharCode(b)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
735
- }
736
- function base64url_decode(value) {
737
- const m = value.length % 4;
738
- return Uint8Array.from(
739
- atob(
740
- value.replace(/-/g, "+").replace(/_/g, "/").padEnd(value.length + (m === 0 ? 0 : 4 - m), "=")
741
- ),
742
- (c) => c.charCodeAt(0)
743
- );
744
- }
745
- function compress(context) {
746
- if (!context?.r) return;
747
- try {
748
- const bytes = viem.hexToBytes(context.r);
749
- return base64url_encode(bytes);
750
- } catch (e) {
751
- console.error("Error compressing Frak context", { e, context });
752
- }
753
- return undefined;
754
- }
755
- function decompress(context) {
756
- if (!context || context.length === 0) return;
757
- try {
758
- const bytes = base64url_decode(context);
759
- return { r: viem.bytesToHex(bytes, { size: 20 }) };
760
- } catch (e) {
761
- console.error("Error decompressing Frak context", { e, context });
762
- }
763
- return undefined;
764
- }
765
- function parse({ url }) {
766
- if (!url) return null;
767
- const urlObj = new URL(url);
768
- const frakContext = urlObj.searchParams.get(contextKey);
769
- if (!frakContext) return null;
770
- return decompress(frakContext);
771
- }
772
- function update({
773
- url,
774
- context
775
- }) {
776
- if (!url) return null;
777
- const currentContext = parse({ url });
778
- const mergedContext = currentContext ? { ...currentContext, ...context } : context;
779
- if (!mergedContext.r) return null;
780
- const compressedContext = compress(mergedContext);
781
- if (!compressedContext) return null;
782
- const urlObj = new URL(url);
783
- urlObj.searchParams.set(contextKey, compressedContext);
784
- return urlObj.toString();
785
- }
786
- function remove(url) {
787
- const urlObj = new URL(url);
788
- urlObj.searchParams.delete(contextKey);
789
- return urlObj.toString();
790
- }
791
- function replaceUrl({
792
- url: baseUrl,
793
- context
794
- }) {
795
- if (!window.location?.href || typeof window === "undefined") {
796
- console.error("No window found, can't update context");
797
- return;
798
- }
799
- const url = baseUrl ?? window.location.href;
800
- let newUrl;
801
- if (context !== null) {
802
- newUrl = update({
803
- url,
804
- context
805
- });
806
- } else {
807
- newUrl = remove(url);
808
- }
809
- if (!newUrl) return;
810
- window.history.replaceState(null, "", newUrl.toString());
811
- }
812
- var FrakContextManager = {
813
- compress,
814
- decompress,
815
- parse,
816
- update,
817
- remove,
818
- replaceUrl
819
- };
820
-
821
- exports.ClientNotFound = ClientNotFound;
822
- exports.Deferred = Deferred;
823
- exports.FrakContextManager = FrakContextManager;
824
- exports.FrakRpcError = FrakRpcError;
825
- exports.InternalError = InternalError;
826
- exports.RpcErrorCodes = RpcErrorCodes;
827
- exports.baseIframeProps = baseIframeProps;
828
- exports.changeIframeVisibility = changeIframeVisibility;
829
- exports.compressJson = compressJson;
830
- exports.createIframe = createIframe;
831
- exports.decompressDataAndCheckHash = decompressDataAndCheckHash;
832
- exports.decompressJson = decompressJson;
833
- exports.hashAndCompressData = hashAndCompressData;