@getpara/web-sdk 2.0.0-dev.1 → 2.0.0-dev.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/dist/index.js CHANGED
@@ -1,1829 +1,24 @@
1
1
  "use client";
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
- step((generator = generator.apply(__this, __arguments)).next());
20
- });
21
- };
22
-
23
- // src/index.ts
2
+ import "./chunk-WLGKV3EF.js";
24
3
  export * from "@getpara/core-sdk";
25
-
26
- // src/ParaWeb.ts
27
- import * as Sentry from "@sentry/browser";
28
- import ParaCore, { Environment as Environment2 } from "@getpara/core-sdk";
29
-
30
- // src/WebUtils.ts
31
- import { PopupType } from "@getpara/core-sdk";
32
-
33
- // src/LocalStorage.ts
34
- var LocalStorage = class {
35
- constructor() {
36
- this.get = (key) => {
37
- if (typeof window !== "undefined") {
38
- return localStorage.getItem(key) || null;
39
- }
40
- return null;
41
- };
42
- this.set = (key, value) => {
43
- if (typeof window !== "undefined") {
44
- localStorage.setItem(key, value);
45
- }
46
- };
47
- this.removeItem = (key) => {
48
- if (typeof window !== "undefined") {
49
- localStorage.removeItem(key);
50
- }
51
- };
52
- this.clear = (prefix) => {
53
- if (typeof window !== "undefined") {
54
- for (let i = 0; i < localStorage.length; i++) {
55
- const key = localStorage.key(i);
56
- if (key && key.startsWith(prefix)) {
57
- localStorage.removeItem(key);
58
- i--;
59
- }
60
- }
61
- }
62
- };
63
- }
64
- };
65
-
66
- // src/SessionStorage.ts
67
- var SessionStorage = class {
68
- constructor() {
69
- this.get = (key) => {
70
- if (typeof window !== "undefined") {
71
- return sessionStorage.getItem(key) || null;
72
- }
73
- return null;
74
- };
75
- this.set = (key, value) => {
76
- if (typeof window !== "undefined") {
77
- sessionStorage.setItem(key, value);
78
- }
79
- };
80
- this.removeItem = (key) => {
81
- if (typeof window !== "undefined") {
82
- sessionStorage.removeItem(key);
83
- }
84
- };
85
- this.clear = (prefix) => {
86
- if (typeof window !== "undefined") {
87
- for (let i = 0; i < sessionStorage.length; i++) {
88
- const key = sessionStorage.key(i);
89
- if (key && key.startsWith(prefix)) {
90
- sessionStorage.removeItem(key);
91
- i--;
92
- }
93
- }
94
- }
95
- };
96
- }
97
- };
98
-
99
- // src/workers/workerWrapper.ts
100
- import { getPortalBaseURL as getPortalBaseURL2 } from "@getpara/core-sdk";
101
-
102
- // src/wasm/wasm_exec.js
103
- (() => {
104
- const enosys = () => {
105
- const err = new Error("not implemented");
106
- err.code = "ENOSYS";
107
- return err;
108
- };
109
- if (!globalThis.fs) {
110
- let outputBuf = "";
111
- globalThis.fs = {
112
- constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },
113
- // unused
114
- writeSync(fd, buf) {
115
- outputBuf += decoder.decode(buf);
116
- const nl = outputBuf.lastIndexOf("\n");
117
- if (nl != -1) {
118
- console.log(outputBuf.substring(0, nl));
119
- outputBuf = outputBuf.substring(nl + 1);
120
- }
121
- return buf.length;
122
- },
123
- write(fd, buf, offset, length, position, callback) {
124
- if (offset !== 0 || length !== buf.length || position !== null) {
125
- callback(enosys());
126
- return;
127
- }
128
- const n = this.writeSync(fd, buf);
129
- callback(null, n);
130
- },
131
- chmod(path, mode, callback) {
132
- callback(enosys());
133
- },
134
- chown(path, uid, gid, callback) {
135
- callback(enosys());
136
- },
137
- close(fd, callback) {
138
- callback(enosys());
139
- },
140
- fchmod(fd, mode, callback) {
141
- callback(enosys());
142
- },
143
- fchown(fd, uid, gid, callback) {
144
- callback(enosys());
145
- },
146
- fstat(fd, callback) {
147
- callback(enosys());
148
- },
149
- fsync(fd, callback) {
150
- callback(null);
151
- },
152
- ftruncate(fd, length, callback) {
153
- callback(enosys());
154
- },
155
- lchown(path, uid, gid, callback) {
156
- callback(enosys());
157
- },
158
- link(path, link, callback) {
159
- callback(enosys());
160
- },
161
- lstat(path, callback) {
162
- callback(enosys());
163
- },
164
- mkdir(path, perm, callback) {
165
- callback(enosys());
166
- },
167
- open(path, flags, mode, callback) {
168
- callback(enosys());
169
- },
170
- read(fd, buffer, offset, length, position, callback) {
171
- callback(enosys());
172
- },
173
- readdir(path, callback) {
174
- callback(enosys());
175
- },
176
- readlink(path, callback) {
177
- callback(enosys());
178
- },
179
- rename(from, to, callback) {
180
- callback(enosys());
181
- },
182
- rmdir(path, callback) {
183
- callback(enosys());
184
- },
185
- stat(path, callback) {
186
- callback(enosys());
187
- },
188
- symlink(path, link, callback) {
189
- callback(enosys());
190
- },
191
- truncate(path, length, callback) {
192
- callback(enosys());
193
- },
194
- unlink(path, callback) {
195
- callback(enosys());
196
- },
197
- utimes(path, atime, mtime, callback) {
198
- callback(enosys());
199
- }
200
- };
201
- }
202
- if (!globalThis.process) {
203
- globalThis.process = {
204
- getuid() {
205
- return -1;
206
- },
207
- getgid() {
208
- return -1;
209
- },
210
- geteuid() {
211
- return -1;
212
- },
213
- getegid() {
214
- return -1;
215
- },
216
- getgroups() {
217
- throw enosys();
218
- },
219
- pid: -1,
220
- ppid: -1,
221
- umask() {
222
- throw enosys();
223
- },
224
- cwd() {
225
- throw enosys();
226
- },
227
- chdir() {
228
- throw enosys();
229
- }
230
- };
231
- }
232
- if (!globalThis.crypto) {
233
- throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
234
- }
235
- if (!globalThis.performance) {
236
- globalThis.performance = Date;
237
- }
238
- if (!globalThis.TextEncoder) {
239
- throw new Error("globalThis.TextEncoder is not available, polyfill required");
240
- }
241
- if (!globalThis.TextDecoder) {
242
- throw new Error("globalThis.TextDecoder is not available, polyfill required");
243
- }
244
- const encoder = new TextEncoder("utf-8");
245
- const decoder = new TextDecoder("utf-8");
246
- globalThis.Go = class {
247
- constructor() {
248
- this.argv = ["js"];
249
- this.env = {};
250
- this.exit = (code) => {
251
- if (code !== 0) {
252
- console.warn("exit code:", code);
253
- }
254
- };
255
- this._exitPromise = new Promise((resolve) => {
256
- this._resolveExitPromise = resolve;
257
- });
258
- this._pendingEvent = null;
259
- this._scheduledTimeouts = /* @__PURE__ */ new Map();
260
- this._nextCallbackTimeoutID = 1;
261
- const setInt64 = (addr, v) => {
262
- this.mem.setUint32(addr + 0, v, true);
263
- this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
264
- };
265
- const setInt32 = (addr, v) => {
266
- this.mem.setUint32(addr + 0, v, true);
267
- };
268
- const getInt64 = (addr) => {
269
- const low = this.mem.getUint32(addr + 0, true);
270
- const high = this.mem.getInt32(addr + 4, true);
271
- return low + high * 4294967296;
272
- };
273
- const loadValue = (addr) => {
274
- const f = this.mem.getFloat64(addr, true);
275
- if (f === 0) {
276
- return void 0;
277
- }
278
- if (!isNaN(f)) {
279
- return f;
280
- }
281
- const id = this.mem.getUint32(addr, true);
282
- return this._values[id];
283
- };
284
- const storeValue = (addr, v) => {
285
- const nanHead = 2146959360;
286
- if (typeof v === "number" && v !== 0) {
287
- if (isNaN(v)) {
288
- this.mem.setUint32(addr + 4, nanHead, true);
289
- this.mem.setUint32(addr, 0, true);
290
- return;
291
- }
292
- this.mem.setFloat64(addr, v, true);
293
- return;
294
- }
295
- if (v === void 0) {
296
- this.mem.setFloat64(addr, 0, true);
297
- return;
298
- }
299
- let id = this._ids.get(v);
300
- if (id === void 0) {
301
- id = this._idPool.pop();
302
- if (id === void 0) {
303
- id = this._values.length;
304
- }
305
- this._values[id] = v;
306
- this._goRefCounts[id] = 0;
307
- this._ids.set(v, id);
308
- }
309
- this._goRefCounts[id]++;
310
- let typeFlag = 0;
311
- switch (typeof v) {
312
- case "object":
313
- if (v !== null) {
314
- typeFlag = 1;
315
- }
316
- break;
317
- case "string":
318
- typeFlag = 2;
319
- break;
320
- case "symbol":
321
- typeFlag = 3;
322
- break;
323
- case "function":
324
- typeFlag = 4;
325
- break;
326
- }
327
- this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
328
- this.mem.setUint32(addr, id, true);
329
- };
330
- const loadSlice = (addr) => {
331
- const array = getInt64(addr + 0);
332
- const len = getInt64(addr + 8);
333
- return new Uint8Array(this._inst.exports.mem.buffer, array, len);
334
- };
335
- const loadSliceOfValues = (addr) => {
336
- const array = getInt64(addr + 0);
337
- const len = getInt64(addr + 8);
338
- const a = new Array(len);
339
- for (let i = 0; i < len; i++) {
340
- a[i] = loadValue(array + i * 8);
341
- }
342
- return a;
343
- };
344
- const loadString = (addr) => {
345
- const saddr = getInt64(addr + 0);
346
- const len = getInt64(addr + 8);
347
- return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
348
- };
349
- const timeOrigin = Date.now() - performance.now();
350
- this.importObject = {
351
- _gotest: {
352
- add: (a, b) => a + b
353
- },
354
- gojs: {
355
- // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
356
- // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
357
- // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
358
- // This changes the SP, thus we have to update the SP used by the imported function.
359
- // func wasmExit(code int32)
360
- "runtime.wasmExit": (sp) => {
361
- sp >>>= 0;
362
- const code = this.mem.getInt32(sp + 8, true);
363
- this.exited = true;
364
- delete this._inst;
365
- delete this._values;
366
- delete this._goRefCounts;
367
- delete this._ids;
368
- delete this._idPool;
369
- this.exit(code);
370
- },
371
- // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
372
- "runtime.wasmWrite": (sp) => {
373
- sp >>>= 0;
374
- const fd = getInt64(sp + 8);
375
- const p = getInt64(sp + 16);
376
- const n = this.mem.getInt32(sp + 24, true);
377
- fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
378
- },
379
- // func resetMemoryDataView()
380
- "runtime.resetMemoryDataView": (sp) => {
381
- sp >>>= 0;
382
- this.mem = new DataView(this._inst.exports.mem.buffer);
383
- },
384
- // func nanotime1() int64
385
- "runtime.nanotime1": (sp) => {
386
- sp >>>= 0;
387
- setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);
388
- },
389
- // func walltime() (sec int64, nsec int32)
390
- "runtime.walltime": (sp) => {
391
- sp >>>= 0;
392
- const msec = (/* @__PURE__ */ new Date()).getTime();
393
- setInt64(sp + 8, msec / 1e3);
394
- this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);
395
- },
396
- // func scheduleTimeoutEvent(delay int64) int32
397
- "runtime.scheduleTimeoutEvent": (sp) => {
398
- sp >>>= 0;
399
- const id = this._nextCallbackTimeoutID;
400
- this._nextCallbackTimeoutID++;
401
- this._scheduledTimeouts.set(id, setTimeout(
402
- () => {
403
- this._resume();
404
- while (this._scheduledTimeouts.has(id)) {
405
- console.warn("scheduleTimeoutEvent: missed timeout event");
406
- this._resume();
407
- }
408
- },
409
- getInt64(sp + 8)
410
- ));
411
- this.mem.setInt32(sp + 16, id, true);
412
- },
413
- // func clearTimeoutEvent(id int32)
414
- "runtime.clearTimeoutEvent": (sp) => {
415
- sp >>>= 0;
416
- const id = this.mem.getInt32(sp + 8, true);
417
- clearTimeout(this._scheduledTimeouts.get(id));
418
- this._scheduledTimeouts.delete(id);
419
- },
420
- // func getRandomData(r []byte)
421
- "runtime.getRandomData": (sp) => {
422
- sp >>>= 0;
423
- crypto.getRandomValues(loadSlice(sp + 8));
424
- },
425
- // func finalizeRef(v ref)
426
- "syscall/js.finalizeRef": (sp) => {
427
- sp >>>= 0;
428
- const id = this.mem.getUint32(sp + 8, true);
429
- this._goRefCounts[id]--;
430
- if (this._goRefCounts[id] === 0) {
431
- const v = this._values[id];
432
- this._values[id] = null;
433
- this._ids.delete(v);
434
- this._idPool.push(id);
435
- }
436
- },
437
- // func stringVal(value string) ref
438
- "syscall/js.stringVal": (sp) => {
439
- sp >>>= 0;
440
- storeValue(sp + 24, loadString(sp + 8));
441
- },
442
- // func valueGet(v ref, p string) ref
443
- "syscall/js.valueGet": (sp) => {
444
- sp >>>= 0;
445
- const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
446
- sp = this._inst.exports.getsp() >>> 0;
447
- storeValue(sp + 32, result);
448
- },
449
- // func valueSet(v ref, p string, x ref)
450
- "syscall/js.valueSet": (sp) => {
451
- sp >>>= 0;
452
- Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
453
- },
454
- // func valueDelete(v ref, p string)
455
- "syscall/js.valueDelete": (sp) => {
456
- sp >>>= 0;
457
- Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
458
- },
459
- // func valueIndex(v ref, i int) ref
460
- "syscall/js.valueIndex": (sp) => {
461
- sp >>>= 0;
462
- storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
463
- },
464
- // valueSetIndex(v ref, i int, x ref)
465
- "syscall/js.valueSetIndex": (sp) => {
466
- sp >>>= 0;
467
- Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
468
- },
469
- // func valueCall(v ref, m string, args []ref) (ref, bool)
470
- "syscall/js.valueCall": (sp) => {
471
- sp >>>= 0;
472
- try {
473
- const v = loadValue(sp + 8);
474
- const m = Reflect.get(v, loadString(sp + 16));
475
- const args = loadSliceOfValues(sp + 32);
476
- const result = Reflect.apply(m, v, args);
477
- sp = this._inst.exports.getsp() >>> 0;
478
- storeValue(sp + 56, result);
479
- this.mem.setUint8(sp + 64, 1);
480
- } catch (err) {
481
- sp = this._inst.exports.getsp() >>> 0;
482
- storeValue(sp + 56, err);
483
- this.mem.setUint8(sp + 64, 0);
484
- }
485
- },
486
- // func valueInvoke(v ref, args []ref) (ref, bool)
487
- "syscall/js.valueInvoke": (sp) => {
488
- sp >>>= 0;
489
- try {
490
- const v = loadValue(sp + 8);
491
- const args = loadSliceOfValues(sp + 16);
492
- const result = Reflect.apply(v, void 0, args);
493
- sp = this._inst.exports.getsp() >>> 0;
494
- storeValue(sp + 40, result);
495
- this.mem.setUint8(sp + 48, 1);
496
- } catch (err) {
497
- sp = this._inst.exports.getsp() >>> 0;
498
- storeValue(sp + 40, err);
499
- this.mem.setUint8(sp + 48, 0);
500
- }
501
- },
502
- // func valueNew(v ref, args []ref) (ref, bool)
503
- "syscall/js.valueNew": (sp) => {
504
- sp >>>= 0;
505
- try {
506
- const v = loadValue(sp + 8);
507
- const args = loadSliceOfValues(sp + 16);
508
- const result = Reflect.construct(v, args);
509
- sp = this._inst.exports.getsp() >>> 0;
510
- storeValue(sp + 40, result);
511
- this.mem.setUint8(sp + 48, 1);
512
- } catch (err) {
513
- sp = this._inst.exports.getsp() >>> 0;
514
- storeValue(sp + 40, err);
515
- this.mem.setUint8(sp + 48, 0);
516
- }
517
- },
518
- // func valueLength(v ref) int
519
- "syscall/js.valueLength": (sp) => {
520
- sp >>>= 0;
521
- setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
522
- },
523
- // valuePrepareString(v ref) (ref, int)
524
- "syscall/js.valuePrepareString": (sp) => {
525
- sp >>>= 0;
526
- const str = encoder.encode(String(loadValue(sp + 8)));
527
- storeValue(sp + 16, str);
528
- setInt64(sp + 24, str.length);
529
- },
530
- // valueLoadString(v ref, b []byte)
531
- "syscall/js.valueLoadString": (sp) => {
532
- sp >>>= 0;
533
- const str = loadValue(sp + 8);
534
- loadSlice(sp + 16).set(str);
535
- },
536
- // func valueInstanceOf(v ref, t ref) bool
537
- "syscall/js.valueInstanceOf": (sp) => {
538
- sp >>>= 0;
539
- this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);
540
- },
541
- // func copyBytesToGo(dst []byte, src ref) (int, bool)
542
- "syscall/js.copyBytesToGo": (sp) => {
543
- sp >>>= 0;
544
- const dst = loadSlice(sp + 8);
545
- const src = loadValue(sp + 32);
546
- if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
547
- this.mem.setUint8(sp + 48, 0);
548
- return;
549
- }
550
- const toCopy = src.subarray(0, dst.length);
551
- dst.set(toCopy);
552
- setInt64(sp + 40, toCopy.length);
553
- this.mem.setUint8(sp + 48, 1);
554
- },
555
- // func copyBytesToJS(dst ref, src []byte) (int, bool)
556
- "syscall/js.copyBytesToJS": (sp) => {
557
- sp >>>= 0;
558
- const dst = loadValue(sp + 8);
559
- const src = loadSlice(sp + 16);
560
- if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
561
- this.mem.setUint8(sp + 48, 0);
562
- return;
563
- }
564
- const toCopy = src.subarray(0, dst.length);
565
- dst.set(toCopy);
566
- setInt64(sp + 40, toCopy.length);
567
- this.mem.setUint8(sp + 48, 1);
568
- },
569
- "debug": (value) => {
570
- console.log(value);
571
- }
572
- }
573
- };
574
- }
575
- run(instance) {
576
- return __async(this, null, function* () {
577
- if (!(instance instanceof WebAssembly.Instance)) {
578
- throw new Error("Go.run: WebAssembly.Instance expected");
579
- }
580
- this._inst = instance;
581
- this.mem = new DataView(this._inst.exports.mem.buffer);
582
- this._values = [
583
- // JS values that Go currently has references to, indexed by reference id
584
- NaN,
585
- 0,
586
- null,
587
- true,
588
- false,
589
- globalThis,
590
- this
591
- ];
592
- this._goRefCounts = new Array(this._values.length).fill(Infinity);
593
- this._ids = /* @__PURE__ */ new Map([
594
- // mapping from JS values to reference ids
595
- [0, 1],
596
- [null, 2],
597
- [true, 3],
598
- [false, 4],
599
- [globalThis, 5],
600
- [this, 6]
601
- ]);
602
- this._idPool = [];
603
- this.exited = false;
604
- let offset = 4096;
605
- const strPtr = (str) => {
606
- const ptr = offset;
607
- const bytes = encoder.encode(str + "\0");
608
- new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
609
- offset += bytes.length;
610
- if (offset % 8 !== 0) {
611
- offset += 8 - offset % 8;
612
- }
613
- return ptr;
614
- };
615
- const argc = this.argv.length;
616
- const argvPtrs = [];
617
- this.argv.forEach((arg) => {
618
- argvPtrs.push(strPtr(arg));
619
- });
620
- argvPtrs.push(0);
621
- const keys = Object.keys(this.env).sort();
622
- keys.forEach((key) => {
623
- argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
624
- });
625
- argvPtrs.push(0);
626
- const argv = offset;
627
- argvPtrs.forEach((ptr) => {
628
- this.mem.setUint32(offset, ptr, true);
629
- this.mem.setUint32(offset + 4, 0, true);
630
- offset += 8;
631
- });
632
- const wasmMinDataAddr = 4096 + 8192;
633
- if (offset >= wasmMinDataAddr) {
634
- throw new Error("total length of command line and environment variables exceeds limit");
635
- }
636
- this._inst.exports.run(argc, argv);
637
- if (this.exited) {
638
- this._resolveExitPromise();
639
- }
640
- yield this._exitPromise;
641
- });
642
- }
643
- _resume() {
644
- if (this.exited) {
645
- throw new Error("Go program has already exited");
646
- }
647
- this._inst.exports.resume();
648
- if (this.exited) {
649
- this._resolveExitPromise();
650
- }
651
- }
652
- _makeFuncWrapper(id) {
653
- const go = this;
654
- return function() {
655
- const event = { id, this: this, args: arguments };
656
- go._pendingEvent = event;
657
- go._resume();
658
- return event.result;
659
- };
660
- }
661
- };
662
- })();
663
-
664
- // src/workers/walletUtils.ts
665
- import { getBaseMPCNetworkUrl, WalletScheme, WalletType } from "@getpara/core-sdk";
666
- var configCGGMPBase = (serverUrl, walletId, id) => `{"ServerUrl":"${serverUrl}", "WalletId": "${walletId}", "Id":"${id}", "Ids":["USER","CAPSULE"], "Threshold":1}`;
667
- var configDKLSBase = (walletId, id, disableWebSockets) => `{"walletId": "${walletId}", "id":"${id}", "otherId":"CAPSULE", "isReceiver": false, "disableWebSockets": ${disableWebSockets}}`;
668
- function keygenRequest(ctx, userId, walletId, protocolId) {
669
- return __async(this, null, function* () {
670
- const { data } = yield ctx.mpcComputationClient.post("/wallets", {
671
- userId,
672
- walletId,
673
- protocolId
674
- });
675
- return data;
676
- });
677
- }
678
- function signMessageRequest(ctx, userId, walletId, protocolId, message, signer) {
679
- return __async(this, null, function* () {
680
- const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/messages/sign`, {
681
- userId,
682
- protocolId,
683
- message,
684
- signer
685
- });
686
- return data;
687
- });
688
- }
689
- function sendTransactionRequest(ctx, userId, walletId, protocolId, transaction, signer, chainId) {
690
- return __async(this, null, function* () {
691
- const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/transactions/send`, {
692
- userId,
693
- protocolId,
694
- transaction,
695
- signer,
696
- chainId
697
- });
698
- return data;
699
- });
700
- }
701
- function ed25519Keygen(ctx, userId) {
702
- return __async(this, null, function* () {
703
- const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
704
- scheme: WalletScheme.ED25519,
705
- type: WalletType.SOLANA
706
- });
707
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
708
- try {
709
- const newSigner = yield new Promise(
710
- (resolve, reject) => globalThis.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
711
- if (err) {
712
- reject(err);
713
- }
714
- resolve(result);
715
- })
716
- );
717
- return { signer: newSigner, walletId };
718
- } catch (e) {
719
- throw new Error(`error creating account of type SOLANA with userId ${userId} and walletId ${walletId}`);
720
- }
721
- });
722
- }
723
- function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType) {
724
- return __async(this, null, function* () {
725
- const { walletId, protocolId } = yield ctx.client.createPregenWallet({
726
- pregenIdentifier,
727
- pregenIdentifierType,
728
- scheme: WalletScheme.ED25519,
729
- type: WalletType.SOLANA
730
- });
731
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
732
- try {
733
- const newSigner = yield new Promise(
734
- (resolve, reject) => globalThis.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
735
- if (err) {
736
- reject(err);
737
- }
738
- resolve(result);
739
- })
740
- );
741
- return { signer: newSigner, walletId };
742
- } catch (e) {
743
- throw new Error(`error creating account of type SOLANA with walletId ${walletId}`);
744
- }
745
- });
746
- }
747
- function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
748
- return __async(this, null, function* () {
749
- const { protocolId } = yield ctx.client.preSignMessage(userId, walletId, base64Bytes, WalletScheme.ED25519);
750
- try {
751
- const base64Sig = yield new Promise(
752
- (resolve, reject) => globalThis.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
753
- if (err) {
754
- reject(err);
755
- }
756
- resolve(result);
757
- })
758
- );
759
- return { signature: base64Sig };
760
- } catch (e) {
761
- throw new Error(`error signing for account of type SOLANA with userId ${userId} and walletId ${walletId}`);
762
- }
763
- });
764
- }
765
- function keygen(ctx, userId, type, secretKey) {
766
- return __async(this, null, function* () {
767
- const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
768
- useTwoSigners: true,
769
- scheme: ctx.useDKLS ? WalletScheme.DKLS : WalletScheme.CGGMP,
770
- type,
771
- cosmosPrefix: type === WalletType.COSMOS ? ctx.cosmosPrefix : void 0
772
- });
773
- if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
774
- return {
775
- signer: (yield keygenRequest(ctx, userId, walletId, protocolId)).signer,
776
- walletId
777
- };
778
- }
779
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
780
- const signerConfigUser = ctx.useDKLS ? configDKLSBase(walletId, "USER", ctx.disableWebSockets) : configCGGMPBase(serverUrl, walletId, "USER");
781
- const createAccountFn = ctx.useDKLS ? globalThis.dklsCreateAccount : globalThis.createAccountV2;
782
- try {
783
- const newSigner = yield new Promise(
784
- (resolve, reject) => createAccountFn(
785
- signerConfigUser,
786
- serverUrl,
787
- protocolId,
788
- secretKey,
789
- () => {
790
- },
791
- // no-op for deprecated callback to update progress percentage
792
- (err, result) => {
793
- if (err) {
794
- reject(err);
795
- }
796
- resolve(result);
797
- }
798
- )
799
- );
800
- return { signer: newSigner, walletId };
801
- } catch (e) {
802
- throw new Error(`error creating account of type ${type} with userId ${userId} and walletId ${walletId}`);
803
- }
804
- });
805
- }
806
- function preKeygen(ctx, _partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey) {
807
- return __async(this, null, function* () {
808
- const { walletId, protocolId } = yield ctx.client.createPregenWallet({
809
- pregenIdentifier,
810
- pregenIdentifierType,
811
- type,
812
- cosmosPrefix: type === WalletType.COSMOS ? ctx.cosmosPrefix : void 0
813
- });
814
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
815
- const signerConfigUser = configDKLSBase(walletId, "USER", ctx.disableWebSockets);
816
- try {
817
- const newSigner = yield new Promise(
818
- (resolve, reject) => globalThis.dklsCreateAccount(
819
- signerConfigUser,
820
- serverUrl,
821
- protocolId,
822
- secretKey,
823
- () => {
824
- },
825
- // no-op for deprecated callback to update progress percentage
826
- (err, result) => {
827
- if (err) {
828
- reject(err);
829
- }
830
- resolve(result);
831
- }
832
- )
833
- );
834
- return { signer: newSigner, walletId };
835
- } catch (e) {
836
- throw new Error(`error creating account of type ${type} with walletId ${walletId}`);
837
- }
838
- });
839
- }
840
- function signMessage(ctx, share, walletId, userId, message, cosmosSignDoc) {
841
- return __async(this, null, function* () {
842
- const { protocolId, pendingTransactionId } = yield ctx.client.preSignMessage(
843
- userId,
844
- walletId,
845
- message,
846
- null,
847
- cosmosSignDoc
848
- );
849
- if (pendingTransactionId) {
850
- return { pendingTransactionId };
851
- }
852
- if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
853
- return signMessageRequest(ctx, userId, walletId, protocolId, message, share);
854
- }
855
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
856
- const signMessageFn = ctx.useDKLS ? globalThis.dklsSignMessage : globalThis.signMessage;
857
- const parsedShare = JSON.parse(share);
858
- if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
859
- parsedShare.disableWebSockets = ctx.disableWebSockets;
860
- }
861
- share = JSON.stringify(parsedShare);
862
- try {
863
- return yield new Promise(
864
- (resolve, reject) => signMessageFn(share, serverUrl, message, protocolId, (err, result) => {
865
- if (err) {
866
- reject(err);
867
- }
868
- resolve({ signature: result });
869
- })
870
- );
871
- } catch (e) {
872
- throw new Error(`error signing for account with userId ${userId} and walletId ${walletId}`);
873
- }
874
- });
875
- }
876
- function signTransaction(ctx, share, walletId, userId, tx, chainId) {
877
- return __async(this, null, function* () {
878
- const {
879
- data: { protocolId, pendingTransactionId }
880
- } = yield ctx.client.signTransaction(userId, walletId, { transaction: tx, chainId });
881
- if (pendingTransactionId) {
882
- return { pendingTransactionId };
883
- }
884
- if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
885
- return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
886
- }
887
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
888
- const signTransactionFn = ctx.useDKLS ? globalThis.dklsSendTransaction : globalThis.sendTransaction;
889
- const parsedShare = JSON.parse(share);
890
- if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
891
- parsedShare.disableWebSockets = ctx.disableWebSockets;
892
- }
893
- share = JSON.stringify(parsedShare);
894
- try {
895
- return yield new Promise(
896
- (resolve, reject) => signTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
897
- if (err) {
898
- reject(err);
899
- }
900
- resolve({ signature: result });
901
- })
902
- );
903
- } catch (e) {
904
- throw new Error(`error signing transaction for account with userId ${userId} and walletId ${walletId}`);
905
- }
906
- });
907
- }
908
- function sendTransaction(ctx, share, walletId, userId, tx, chainId) {
909
- return __async(this, null, function* () {
910
- const {
911
- data: { protocolId, pendingTransactionId }
912
- } = yield ctx.client.sendTransaction(userId, walletId, { transaction: tx, chainId });
913
- if (pendingTransactionId) {
914
- return { pendingTransactionId };
915
- }
916
- if (ctx.offloadMPCComputationURL && !ctx.useDKLS) {
917
- return sendTransactionRequest(ctx, userId, walletId, protocolId, tx, share, chainId);
918
- }
919
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
920
- const sendTransactionFn = ctx.useDKLS ? globalThis.dklsSendTransaction : globalThis.sendTransaction;
921
- const parsedShare = JSON.parse(share);
922
- if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
923
- parsedShare.disableWebSockets = ctx.disableWebSockets;
924
- }
925
- share = JSON.stringify(parsedShare);
926
- try {
927
- return yield new Promise(
928
- (resolve, reject) => sendTransactionFn(share, serverUrl, tx, chainId, protocolId, (err, result) => {
929
- if (err) {
930
- reject(err);
931
- }
932
- resolve({ signature: result });
933
- })
934
- );
935
- } catch (e) {
936
- throw new Error(`error signing transaction to send for account with userId ${userId} and walletId ${walletId}`);
937
- }
938
- });
939
- }
940
- function refresh(ctx, share, walletId, userId, oldPartnerId, newPartnerId, keyShareProtocolId) {
941
- return __async(this, null, function* () {
942
- const {
943
- data: { protocolId }
944
- } = yield ctx.client.refreshKeys(userId, walletId, oldPartnerId, newPartnerId, keyShareProtocolId);
945
- const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
946
- const refreshFn = ctx.useDKLS ? globalThis.dklsRefresh : globalThis.refresh;
947
- const parsedShare = JSON.parse(share);
948
- if (!parsedShare.disableWebSockets !== !ctx.disableWebSockets) {
949
- parsedShare.disableWebSockets = ctx.disableWebSockets;
950
- }
951
- share = JSON.stringify(parsedShare);
952
- try {
953
- return yield new Promise(
954
- (resolve, reject) => refreshFn(share, serverUrl, protocolId, (err, result) => {
955
- if (err) {
956
- reject(err);
957
- }
958
- resolve({ protocolId, signer: result });
959
- })
960
- );
961
- } catch (e) {
962
- throw new Error(`error refreshing keys for account with userId ${userId} and walletId ${walletId}`);
963
- }
964
- });
965
- }
966
- function getPrivateKey(ctx, share, walletId, userId) {
967
- return __async(this, null, function* () {
968
- const paraShare = yield ctx.client.getParaShare(userId, walletId);
969
- if (!paraShare) {
970
- return "";
971
- }
972
- try {
973
- return yield new Promise(
974
- (resolve, reject) => globalThis.getPrivateKey(share, paraShare, (err, result) => {
975
- if (err) {
976
- reject(err);
977
- }
978
- resolve(result);
979
- })
980
- );
981
- } catch (e) {
982
- throw new Error(`error getting private key for account with userId ${userId} and walletId ${walletId}`);
983
- }
984
- });
985
- }
986
-
987
- // src/workers/worker.ts
988
- import {
989
- getPortalBaseURL,
990
- initClient,
991
- mpcComputationClient,
992
- paraVersion,
993
- WalletType as WalletType2
994
- } from "@getpara/core-sdk";
995
- function loadWasm(ctx, wasmOverride) {
996
- return __async(this, null, function* () {
997
- if (typeof self === "undefined") {
998
- return;
999
- }
1000
- const goWasm = new self.Go();
1001
- let wasmArrayBuffer = wasmOverride;
1002
- if (!wasmArrayBuffer) {
1003
- if (process.env.DISABLE_WASM_FETCH === "true") {
1004
- throw new Error("fetching wasm file is disabled");
1005
- }
1006
- const fetchedWasm = yield fetch(`${getPortalBaseURL(ctx)}/static/js/main.wasm`, { mode: "cors" });
1007
- wasmArrayBuffer = yield fetchedWasm.arrayBuffer();
1008
- }
1009
- const newRes = yield WebAssembly.instantiate(wasmArrayBuffer, goWasm.importObject);
1010
- goWasm.run(newRes.instance);
1011
- });
1012
- }
1013
- function executeMessage(ctx, message) {
1014
- return __async(this, null, function* () {
1015
- const { functionType, params, returnObject } = message;
1016
- switch (functionType) {
1017
- case "KEYGEN": {
1018
- const { userId, secretKey, type = WalletType2.EVM } = params;
1019
- const keygenRes = yield keygen(ctx, userId, type, secretKey);
1020
- return keygenRes;
1021
- }
1022
- case "SIGN_TRANSACTION": {
1023
- const { share, walletId, userId, tx, chainId } = params;
1024
- return signTransaction(ctx, share, walletId, userId, tx, chainId);
1025
- }
1026
- case "SEND_TRANSACTION": {
1027
- const { share, walletId, userId, tx, chainId } = params;
1028
- return sendTransaction(ctx, share, walletId, userId, tx, chainId);
1029
- }
1030
- case "SIGN_MESSAGE": {
1031
- const { share, walletId, userId, message: message2, cosmosSignDoc } = params;
1032
- return signMessage(ctx, share, walletId, userId, message2, cosmosSignDoc);
1033
- }
1034
- case "REFRESH": {
1035
- const { share, walletId, userId, oldPartnerId, newPartnerId, keyShareProtocolId } = params;
1036
- const { protocolId, signer } = yield refresh(
1037
- ctx,
1038
- share,
1039
- walletId,
1040
- userId,
1041
- oldPartnerId,
1042
- newPartnerId,
1043
- keyShareProtocolId
1044
- );
1045
- return returnObject ? { protocolId, signer } : signer;
1046
- }
1047
- case "PREKEYGEN": {
1048
- const { email, partnerId, secretKey, type = WalletType2.EVM } = params;
1049
- let { pregenIdentifier, pregenIdentifierType } = params;
1050
- if (email !== "null" && email !== "undefined" && email !== "" && email != null) {
1051
- pregenIdentifier = email;
1052
- pregenIdentifierType = "EMAIL";
1053
- }
1054
- const keygenRes = yield preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey);
1055
- return keygenRes;
1056
- }
1057
- case "GET_PRIVATE_KEY": {
1058
- const { share, walletId, userId } = params;
1059
- return yield getPrivateKey(ctx, share, walletId, userId);
1060
- }
1061
- case "ED25519_KEYGEN": {
1062
- const { userId } = params;
1063
- return ed25519Keygen(ctx, userId);
1064
- }
1065
- case "ED25519_SIGN": {
1066
- const { share, walletId, userId, base64Bytes } = params;
1067
- return ed25519Sign(ctx, share, userId, walletId, base64Bytes);
1068
- }
1069
- case "ED25519_PREKEYGEN": {
1070
- const { email } = params;
1071
- let { pregenIdentifier, pregenIdentifierType } = params;
1072
- if (email !== "null" && email !== "undefined" && email !== "" && email != null) {
1073
- pregenIdentifier = email;
1074
- pregenIdentifierType = "EMAIL";
1075
- }
1076
- return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType);
1077
- }
1078
- default: {
1079
- throw new Error(`functionType: ${functionType} not supported`);
1080
- }
1081
- }
1082
- });
1083
- }
1084
- function handleMessage(e, postMessage, useFetchAdapter) {
1085
- return __async(this, null, function* () {
1086
- const {
1087
- env,
1088
- apiKey,
1089
- cosmosPrefix = "cosmos",
1090
- offloadMPCComputationURL,
1091
- disableWorkers,
1092
- sessionCookie,
1093
- useDKLS,
1094
- disableWebSockets,
1095
- wasmOverride
1096
- } = e.data;
1097
- if (!env) {
1098
- return true;
1099
- }
1100
- const ctx = {
1101
- env,
1102
- apiKey,
1103
- cosmosPrefix,
1104
- client: initClient({
1105
- env,
1106
- version: paraVersion,
1107
- apiKey,
1108
- useFetchAdapter,
1109
- retrieveSessionCookie: () => sessionCookie
1110
- }),
1111
- offloadMPCComputationURL,
1112
- mpcComputationClient: offloadMPCComputationURL ? mpcComputationClient.initClient(offloadMPCComputationURL, !!disableWorkers) : void 0,
1113
- useDKLS,
1114
- disableWebSockets: !!disableWebSockets,
1115
- wasmOverride
1116
- };
1117
- if (!ctx.offloadMPCComputationURL || ctx.useDKLS) {
1118
- yield loadWasm(ctx, wasmOverride);
1119
- }
1120
- const result = yield executeMessage(ctx, e.data);
1121
- postMessage(result);
1122
- return false;
1123
- });
1124
- }
1125
-
1126
- // src/workers/workerWrapper.ts
1127
- function setupWorker(ctx, resFunction) {
1128
- return __async(this, null, function* () {
1129
- const onmessage = (event) => {
1130
- if (event.data.functionType === "CUSTOM") {
1131
- return;
1132
- }
1133
- resFunction(event.data);
1134
- };
1135
- if (ctx.disableWorkers) {
1136
- const syncWorker = {
1137
- postMessage: function(message) {
1138
- (function() {
1139
- return __async(this, null, function* () {
1140
- yield handleMessage({ data: message }, (data) => onmessage({ data }), ctx.disableWorkers);
1141
- });
1142
- })();
1143
- },
1144
- terminate: () => {
1145
- return;
1146
- }
1147
- };
1148
- return syncWorker;
1149
- }
1150
- let worker;
1151
- if (ctx.useLocalFiles) {
1152
- throw new Error("useLocalFiles only supported locally");
1153
- } else {
1154
- const workerRes = yield fetch(`${getPortalBaseURL2(ctx)}/static/js/mpcWorker-bundle.js`);
1155
- const workerBlob = new Blob([yield workerRes.text()], { type: "application/javascript" });
1156
- const workerScriptURL = URL.createObjectURL(workerBlob);
1157
- worker = new Worker(workerScriptURL);
1158
- }
1159
- worker.onmessage = onmessage;
1160
- return worker;
1161
- });
1162
- }
1163
-
1164
- // src/wallet/keygen.ts
1165
- import { distributeNewShare, waitUntilTrue } from "@getpara/core-sdk";
1166
- function isKeygenComplete(ctx, userId, walletId) {
1167
- return __async(this, null, function* () {
1168
- const wallets = yield ctx.client.getWallets(userId);
1169
- const wallet = wallets.data.wallets.find((w) => w.id === walletId);
1170
- return !!wallet.address;
1171
- });
1172
- }
1173
- function isRefreshComplete(ctx, userId, walletId, partnerId, protocolId) {
1174
- return __async(this, null, function* () {
1175
- const { isDone } = yield ctx.client.isRefreshDone(userId, walletId, partnerId, protocolId);
1176
- return isDone;
1177
- });
1178
- }
1179
- function isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, walletId) {
1180
- return __async(this, null, function* () {
1181
- const wallets = yield ctx.client.getPregenWallets({ [pregenIdentifierType]: [pregenIdentifier] });
1182
- const wallet = wallets.wallets.find((w) => w.id === walletId);
1183
- return !!wallet.address;
1184
- });
1185
- }
1186
- function keygen2(ctx, userId, type, secretKey, skipDistribute = false, sessionCookie, emailProps = {}) {
1187
- return new Promise((resolve) => __async(this, null, function* () {
1188
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1189
- yield waitUntilTrue(() => __async(this, null, function* () {
1190
- return isKeygenComplete(ctx, userId, res.walletId);
1191
- }), 15e3, 1e3);
1192
- if (skipDistribute) {
1193
- resolve({
1194
- signer: res.signer,
1195
- walletId: res.walletId,
1196
- recoveryShare: null
1197
- });
1198
- worker.terminate();
1199
- return;
1200
- }
1201
- const recoveryShare = yield distributeNewShare({
1202
- ctx,
1203
- userId,
1204
- walletId: res.walletId,
1205
- userShare: res.signer,
1206
- emailProps
1207
- });
1208
- resolve({
1209
- signer: res.signer,
1210
- walletId: res.walletId,
1211
- recoveryShare
1212
- });
1213
- worker.terminate();
1214
- }));
1215
- worker.postMessage({
1216
- env: ctx.env,
1217
- apiKey: ctx.apiKey,
1218
- cosmosPrefix: ctx.cosmosPrefix,
1219
- params: { userId, secretKey, type },
1220
- functionType: "KEYGEN",
1221
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1222
- disableWorkers: ctx.disableWorkers,
1223
- sessionCookie,
1224
- useDKLS: ctx.useDKLS,
1225
- disableWebSockets: ctx.disableWebSockets,
1226
- wasmOverride: ctx.wasmOverride
1227
- });
1228
- }));
1229
- }
1230
- function preKeygen2(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, _skipDistribute = false, partnerId, sessionCookie) {
1231
- return new Promise((resolve) => __async(this, null, function* () {
1232
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1233
- yield waitUntilTrue(
1234
- () => __async(this, null, function* () {
1235
- return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
1236
- }),
1237
- 15e3,
1238
- 1e3
1239
- );
1240
- resolve({
1241
- signer: res.signer,
1242
- walletId: res.walletId,
1243
- recoveryShare: null
1244
- });
1245
- worker.terminate();
1246
- }));
1247
- const email = void 0;
1248
- const params = { pregenIdentifier, pregenIdentifierType, type, secretKey, partnerId, email };
1249
- if (pregenIdentifierType === "EMAIL") {
1250
- params.email = pregenIdentifier;
1251
- }
1252
- worker.postMessage({
1253
- env: ctx.env,
1254
- apiKey: ctx.apiKey,
1255
- cosmosPrefix: ctx.cosmosPrefix,
1256
- params,
1257
- functionType: "PREKEYGEN",
1258
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1259
- disableWorkers: ctx.disableWorkers,
1260
- sessionCookie,
1261
- useDKLS: ctx.useDKLS,
1262
- disableWebSockets: ctx.disableWebSockets,
1263
- wasmOverride: ctx.wasmOverride
1264
- });
1265
- }));
1266
- }
1267
- function refresh2(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
1268
- return new Promise((resolve) => __async(this, null, function* () {
1269
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1270
- if (!(yield waitUntilTrue(() => __async(this, null, function* () {
1271
- return isRefreshComplete(ctx, userId, walletId, newPartnerId);
1272
- }), 15e3, 1e3))) {
1273
- throw new Error("refresh failed");
1274
- }
1275
- const { protocolId, signer } = res;
1276
- resolve({
1277
- signer,
1278
- protocolId
1279
- });
1280
- worker.terminate();
1281
- }));
1282
- worker.postMessage({
1283
- env: ctx.env,
1284
- apiKey: ctx.apiKey,
1285
- params: { userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId },
1286
- functionType: "REFRESH",
1287
- disableWorkers: ctx.disableWorkers,
1288
- sessionCookie,
1289
- useDKLS: ctx.useDKLS,
1290
- disableWebSockets: ctx.disableWebSockets,
1291
- wasmOverride: ctx.wasmOverride,
1292
- returnObject: true
1293
- });
1294
- }));
1295
- }
1296
- function ed25519Keygen2(ctx, userId, sessionCookie, _emailProps = {}) {
1297
- return new Promise((resolve) => __async(this, null, function* () {
1298
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1299
- yield waitUntilTrue(() => __async(this, null, function* () {
1300
- return isKeygenComplete(ctx, userId, res.walletId);
1301
- }), 15e3, 1e3);
1302
- resolve({
1303
- signer: res.signer,
1304
- walletId: res.walletId,
1305
- recoveryShare: null
1306
- });
1307
- worker.terminate();
1308
- }));
1309
- worker.postMessage({
1310
- env: ctx.env,
1311
- apiKey: ctx.apiKey,
1312
- cosmosPrefix: ctx.cosmosPrefix,
1313
- params: { userId },
1314
- functionType: "ED25519_KEYGEN",
1315
- disableWorkers: ctx.disableWorkers,
1316
- sessionCookie,
1317
- disableWebSockets: ctx.disableWebSockets,
1318
- wasmOverride: ctx.wasmOverride
1319
- });
1320
- }));
1321
- }
1322
- function ed25519PreKeygen2(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
1323
- return new Promise((resolve) => __async(this, null, function* () {
1324
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1325
- yield waitUntilTrue(
1326
- () => __async(this, null, function* () {
1327
- return isPreKeygenComplete(ctx, pregenIdentifier, pregenIdentifierType, res.walletId);
1328
- }),
1329
- 15e3,
1330
- 1e3
1331
- );
1332
- resolve({
1333
- signer: res.signer,
1334
- walletId: res.walletId,
1335
- recoveryShare: null
1336
- });
1337
- worker.terminate();
1338
- }));
1339
- const email = void 0;
1340
- const params = { pregenIdentifier, pregenIdentifierType, email };
1341
- if (pregenIdentifierType === "EMAIL") {
1342
- params.email = pregenIdentifier;
1343
- }
1344
- worker.postMessage({
1345
- env: ctx.env,
1346
- apiKey: ctx.apiKey,
1347
- cosmosPrefix: ctx.cosmosPrefix,
1348
- params,
1349
- functionType: "ED25519_PREKEYGEN",
1350
- disableWorkers: ctx.disableWorkers,
1351
- sessionCookie,
1352
- disableWebSockets: ctx.disableWebSockets,
1353
- wasmOverride: ctx.wasmOverride
1354
- });
1355
- }));
1356
- }
1357
-
1358
- // src/wallet/signing.ts
1359
- function signTransaction2(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
1360
- return __async(this, null, function* () {
1361
- return yield new Promise((resolve) => __async(this, null, function* () {
1362
- const worker = yield setupWorker(ctx, (sendTransactionRes) => __async(this, null, function* () {
1363
- resolve(sendTransactionRes);
1364
- worker.terminate();
1365
- }));
1366
- worker.postMessage({
1367
- env: ctx.env,
1368
- apiKey: ctx.apiKey,
1369
- cosmosPrefix: ctx.cosmosPrefix,
1370
- params: { share, walletId, userId, tx, chainId },
1371
- functionType: "SIGN_TRANSACTION",
1372
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1373
- disableWorkers: ctx.disableWorkers,
1374
- sessionCookie,
1375
- useDKLS: isDKLS,
1376
- disableWebSockets: ctx.disableWebSockets,
1377
- wasmOverride: ctx.wasmOverride
1378
- });
1379
- }));
1380
- });
1381
- }
1382
- function sendTransaction2(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
1383
- return __async(this, null, function* () {
1384
- return yield new Promise((resolve) => __async(this, null, function* () {
1385
- const worker = yield setupWorker(ctx, (sendTransactionRes) => __async(this, null, function* () {
1386
- resolve(sendTransactionRes);
1387
- worker.terminate();
1388
- }));
1389
- worker.postMessage({
1390
- env: ctx.env,
1391
- apiKey: ctx.apiKey,
1392
- cosmosPrefix: ctx.cosmosPrefix,
1393
- params: { share, walletId, userId, tx, chainId },
1394
- functionType: "SEND_TRANSACTION",
1395
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1396
- disableWorkers: ctx.disableWorkers,
1397
- sessionCookie,
1398
- useDKLS: isDKLS,
1399
- disableWebSockets: ctx.disableWebSockets,
1400
- wasmOverride: ctx.wasmOverride
1401
- });
1402
- }));
1403
- });
1404
- }
1405
- function signMessage2(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
1406
- return __async(this, null, function* () {
1407
- return yield new Promise((resolve) => __async(this, null, function* () {
1408
- const worker = yield setupWorker(ctx, (signMessageRes) => __async(this, null, function* () {
1409
- resolve(signMessageRes);
1410
- worker.terminate();
1411
- }));
1412
- worker.postMessage({
1413
- env: ctx.env,
1414
- apiKey: ctx.apiKey,
1415
- cosmosPrefix: ctx.cosmosPrefix,
1416
- params: { share, walletId, userId, message, cosmosSignDoc },
1417
- functionType: "SIGN_MESSAGE",
1418
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1419
- disableWorkers: ctx.disableWorkers,
1420
- sessionCookie,
1421
- useDKLS: isDKLS,
1422
- disableWebSockets: ctx.disableWebSockets,
1423
- wasmOverride: ctx.wasmOverride
1424
- });
1425
- }));
1426
- });
1427
- }
1428
- function ed25519Sign2(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
1429
- return __async(this, null, function* () {
1430
- return yield new Promise((resolve) => __async(this, null, function* () {
1431
- const worker = yield setupWorker(ctx, (signMessageRes) => __async(this, null, function* () {
1432
- resolve(signMessageRes);
1433
- worker.terminate();
1434
- }));
1435
- worker.postMessage({
1436
- env: ctx.env,
1437
- apiKey: ctx.apiKey,
1438
- cosmosPrefix: ctx.cosmosPrefix,
1439
- params: { share, walletId, userId, base64Bytes },
1440
- functionType: "ED25519_SIGN",
1441
- disableWorkers: ctx.disableWorkers,
1442
- sessionCookie,
1443
- disableWebSockets: ctx.disableWebSockets,
1444
- wasmOverride: ctx.wasmOverride
1445
- });
1446
- }));
1447
- });
1448
- }
1449
-
1450
- // src/wallet/privateKey.ts
1451
- function getPrivateKey2(ctx, userId, walletId, share, sessionCookie) {
1452
- return __async(this, null, function* () {
1453
- return yield new Promise((resolve) => __async(this, null, function* () {
1454
- const worker = yield setupWorker(ctx, (res) => __async(this, null, function* () {
1455
- resolve(res);
1456
- worker.terminate();
1457
- }));
1458
- worker.postMessage({
1459
- env: ctx.env,
1460
- apiKey: ctx.apiKey,
1461
- cosmosPrefix: ctx.cosmosPrefix,
1462
- params: { share, walletId, userId },
1463
- functionType: "GET_PRIVATE_KEY",
1464
- offloadMPCComputationURL: ctx.offloadMPCComputationURL,
1465
- disableWorkers: ctx.disableWorkers,
1466
- sessionCookie,
1467
- useDKLS: ctx.useDKLS,
1468
- disableWebSockets: ctx.disableWebSockets,
1469
- wasmOverride: ctx.wasmOverride
1470
- });
1471
- }));
1472
- });
1473
- }
1474
-
1475
- // src/WebUtils.ts
1476
- var WebUtils = class {
1477
- constructor() {
1478
- this.localStorage = new LocalStorage();
1479
- this.sessionStorage = new SessionStorage();
1480
- this.secureStorage = null;
1481
- this.isSyncStorage = true;
1482
- this.disableProviderModal = false;
1483
- }
1484
- getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
1485
- return getPrivateKey2(ctx, userId, walletId, share, sessionCookie);
1486
- }
1487
- keygen(ctx, userId, type, secretKey, sessionCookie, emailProps = {}) {
1488
- return keygen2(ctx, userId, type, secretKey, true, sessionCookie, emailProps);
1489
- }
1490
- refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
1491
- return refresh2(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId);
1492
- }
1493
- preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
1494
- return preKeygen2(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
1495
- }
1496
- signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
1497
- return signMessage2(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc);
1498
- }
1499
- signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
1500
- return signTransaction2(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
1501
- }
1502
- sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
1503
- return sendTransaction2(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
1504
- }
1505
- signHash(_address, _hash) {
1506
- throw new Error("not implemented");
1507
- }
1508
- ed25519Keygen(ctx, userId, sessionCookie, emailProps) {
1509
- return ed25519Keygen2(ctx, userId, sessionCookie, emailProps);
1510
- }
1511
- ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
1512
- return ed25519PreKeygen2(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie);
1513
- }
1514
- ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
1515
- return ed25519Sign2(ctx, userId, walletId, share, base64Bytes, sessionCookie);
1516
- }
1517
- openPopup(popupUrl, opts) {
1518
- if (typeof window === "undefined") {
1519
- return;
1520
- }
1521
- if (opts) {
1522
- const { type } = opts;
1523
- const popUpWidth = 550;
1524
- let popUpHeight;
1525
- switch (type) {
1526
- case PopupType.LOGIN_PASSKEY: {
1527
- popUpHeight = 798;
1528
- break;
1529
- }
1530
- case PopupType.CREATE_PASSKEY: {
1531
- popUpHeight = 464;
1532
- break;
1533
- }
1534
- case PopupType.SIGN_MESSAGE_REVIEW: {
1535
- popUpHeight = 585;
1536
- break;
1537
- }
1538
- case PopupType.SIGN_TRANSACTION_REVIEW: {
1539
- popUpHeight = 750;
1540
- break;
1541
- }
1542
- case PopupType.OAUTH:
1543
- default: {
1544
- popUpHeight = 768;
1545
- break;
1546
- }
1547
- }
1548
- const dualScreenLeft = window.screenLeft !== void 0 ? window.screenLeft : window.screenX;
1549
- const dualScreenTop = window.screenTop !== void 0 ? window.screenTop : window.screenY;
1550
- const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
1551
- const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
1552
- const left = (width - popUpWidth) / 2 + dualScreenLeft;
1553
- const top = (height - popUpHeight) / 2 + dualScreenTop;
1554
- const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
1555
- height=${popUpHeight}, top=${top}, left=${left}`;
1556
- let popupWindow = window.open(popupUrl, type.toString(), windowFeatures);
1557
- if (!popupWindow) {
1558
- setTimeout(() => {
1559
- popupWindow = window.open(popupUrl, "_blank");
1560
- }, 0);
1561
- }
1562
- return popupWindow;
1563
- } else {
1564
- const popupWindow = window.open(popupUrl, "popup", "popup=true,width=400,height=500");
1565
- if (!popupWindow) {
1566
- setTimeout(() => {
1567
- window.open(popupUrl, "_blank");
1568
- }, 0);
1569
- }
1570
- return popupWindow;
1571
- }
1572
- }
1573
- };
1574
-
1575
- // src/ParaWeb.ts
1576
- var Para = class extends ParaCore {
1577
- constructor(env, apiKey, opts) {
1578
- super(env, apiKey, opts);
1579
- if (env !== Environment2.PROD && env !== Environment2.DEV) {
1580
- Sentry.init({
1581
- environment: env.toLowerCase(),
1582
- dsn: "https://38f27d4836da617ab9e95cf66b9611d9@o4504568036720640.ingest.us.sentry.io/4508850812944384"
1583
- });
1584
- }
1585
- }
1586
- getPlatformUtils() {
1587
- return new WebUtils();
1588
- }
1589
- };
1590
-
1591
- // src/index.ts
1592
- import ParaCore2 from "@getpara/core-sdk";
4
+ import { Para as ParaWeb } from "./ParaWeb.js";
5
+ import ParaCore from "@getpara/core-sdk";
1593
6
  import {
1594
- Environment as Environment4
7
+ Environment
1595
8
  } from "@getpara/core-sdk";
1596
-
1597
- // src/cryptography/webAuth.ts
1598
- import base64url from "base64url";
1599
- import * as cbor from "cbor-web";
1600
- import forge from "node-forge";
1601
- import { getPortalDomain } from "@getpara/core-sdk";
1602
- var ES256_ALGORITHM = -7;
1603
- var RS256_ALGORITHM = -257;
1604
- function publicKeyCredentialToJSON(pubKeyCred) {
1605
- if (pubKeyCred instanceof ArrayBuffer || ArrayBuffer.isView(pubKeyCred)) {
1606
- return base64url.encode(pubKeyCred);
1607
- } else if (pubKeyCred instanceof Array) {
1608
- return pubKeyCred.map(publicKeyCredentialToJSON);
1609
- } else if (pubKeyCred instanceof Object) {
1610
- const obj = {};
1611
- for (const key in pubKeyCred) {
1612
- obj[key] = publicKeyCredentialToJSON(pubKeyCred[key]);
1613
- }
1614
- return obj;
1615
- } else return pubKeyCred;
1616
- }
1617
- function parseMakeCredAuthData(buffer) {
1618
- const rpIdHash = buffer.slice(0, 32);
1619
- buffer = buffer.slice(32);
1620
- const flagsBuf = buffer.slice(0, 1);
1621
- buffer = buffer.slice(1);
1622
- const flags = flagsBuf[0];
1623
- const counterBuf = buffer.slice(0, 4);
1624
- buffer = buffer.slice(4);
1625
- const counter = counterBuf.readUInt32BE(0);
1626
- const aaguid = buffer.slice(0, 16);
1627
- buffer = buffer.slice(16);
1628
- const credIDLenBuf = buffer.slice(0, 2);
1629
- buffer = buffer.slice(2);
1630
- const credIDLen = credIDLenBuf.readUInt16BE(0);
1631
- const credID = buffer.slice(0, credIDLen);
1632
- buffer = buffer.slice(credIDLen);
1633
- const COSEPublicKey = buffer;
1634
- return {
1635
- rpIdHash,
1636
- flagsBuf,
1637
- flags,
1638
- counter,
1639
- counterBuf,
1640
- aaguid,
1641
- credID,
1642
- COSEPublicKey
1643
- };
1644
- }
1645
- function parseAttestationObject(attestationObject) {
1646
- const attestationObjectBuffer = base64url.toBuffer(attestationObject);
1647
- return cbor.decodeAllSync(attestationObjectBuffer)[0];
1648
- }
1649
- function COSEECDSAtoPKCS(COSEPublicKey) {
1650
- const coseStruct = cbor.decodeAllSync(COSEPublicKey)[0];
1651
- const tag = Buffer.from([4]);
1652
- const x = coseStruct.get(-2);
1653
- const y = coseStruct.get(-3);
1654
- return Buffer.concat([tag, x, y]);
1655
- }
1656
- function COSERSAtoPKCS(COSEPublicKey) {
1657
- const coseStruct = cbor.decodeAllSync(COSEPublicKey)[0];
1658
- const n = coseStruct.get(-1);
1659
- const e = coseStruct.get(-2);
1660
- const nForge = forge.util.createBuffer(n.toString("binary"));
1661
- const eForge = forge.util.createBuffer(e.toString("binary"));
1662
- const publicKey = forge.pki.setRsaPublicKey(
1663
- new forge.jsbn.BigInteger(nForge.toHex(), 16),
1664
- new forge.jsbn.BigInteger(eForge.toHex(), 16)
1665
- );
1666
- return Buffer.from(forge.pki.publicKeyToPem(publicKey), "utf-8");
1667
- }
1668
- function parseCredentialCreationRes(creds, algorithm) {
1669
- const parsedAttestation = parseAttestationObject(creds.response.attestationObject);
1670
- const { COSEPublicKey, aaguid } = parseMakeCredAuthData(parsedAttestation.authData);
1671
- if (algorithm === RS256_ALGORITHM) {
1672
- return {
1673
- cosePublicKey: base64url.encode(COSERSAtoPKCS(COSEPublicKey)),
1674
- clientDataJSON: creds.response.clientDataJSON,
1675
- aaguid: aaguid.toString("hex")
1676
- };
1677
- }
1678
- return {
1679
- cosePublicKey: base64url.encode(COSEECDSAtoPKCS(COSEPublicKey)),
1680
- clientDataJSON: creds.response.clientDataJSON,
1681
- aaguid: aaguid.toString("hex")
1682
- };
1683
- }
1684
- function generateUserHandle() {
1685
- const userHandle = new Uint8Array(32);
1686
- window.crypto.getRandomValues(userHandle);
1687
- return userHandle;
1688
- }
1689
- function createCredential(env, userId, identifier, isE2E) {
1690
- return __async(this, null, function* () {
1691
- if (typeof navigator === "undefined") {
1692
- return;
1693
- }
1694
- const userHandle = generateUserHandle();
1695
- const createCredentialDefaultArgs = {
1696
- publicKey: {
1697
- authenticatorSelection: {
1698
- authenticatorAttachment: "platform",
1699
- requireResidentKey: true,
1700
- residentKey: "required",
1701
- userVerification: "required"
1702
- },
1703
- rp: {
1704
- id: getPortalDomain(env, isE2E),
1705
- name: "Para"
1706
- },
1707
- user: {
1708
- id: userHandle,
1709
- name: identifier,
1710
- displayName: identifier
1711
- },
1712
- pubKeyCredParams: [
1713
- { type: "public-key", alg: ES256_ALGORITHM },
1714
- // RS256_ALGORITHM should only be needed for windows hello
1715
- { type: "public-key", alg: RS256_ALGORITHM }
1716
- ],
1717
- attestation: "direct",
1718
- timeout: 6e4,
1719
- // TODO: don't think we really get value from verifying this, but should revisit
1720
- challenge: Buffer.from(userId, "utf-8")
1721
- }
1722
- };
1723
- const credential = yield navigator.credentials.create(createCredentialDefaultArgs);
1724
- const algorithm = credential.response.getPublicKeyAlgorithm ? credential.response.getPublicKeyAlgorithm() : ES256_ALGORITHM;
1725
- const userHandleEncoded = base64url.encode(Buffer.from(userHandle));
1726
- return {
1727
- creds: publicKeyCredentialToJSON(credential),
1728
- userHandle: userHandleEncoded,
1729
- algorithm
1730
- };
1731
- });
1732
- }
1733
- function generateSignature(env, challenge, allowedPublicKeys, isE2E) {
1734
- return __async(this, null, function* () {
1735
- const getCredentialDefaultArgs = {
1736
- publicKey: {
1737
- timeout: 6e4,
1738
- challenge: Buffer.from(challenge, "base64"),
1739
- allowCredentials: allowedPublicKeys.map((key) => ({
1740
- id: base64url.toBuffer(key),
1741
- type: "public-key"
1742
- })),
1743
- userVerification: "required",
1744
- rpId: getPortalDomain(env, isE2E)
1745
- }
1746
- };
1747
- const assertation = yield navigator.credentials.get(getCredentialDefaultArgs);
1748
- return publicKeyCredentialToJSON(assertation);
1749
- });
1750
- }
1751
-
1752
- // src/utils/truncateEthAddress.ts
1753
- var truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
1754
- var truncateEthAddress = (address) => {
1755
- const match = address.match(truncateRegex);
1756
- if (!match) return address;
1757
- return `${match[1]}\u2026${match[2]}`;
1758
- };
1759
-
1760
- // src/utils/isPasskeySupported.ts
1761
- import { UAParser } from "ua-parser-js";
1762
- var isPasskeySupported = (userAgent) => __async(void 0, null, function* () {
1763
- var _a, _b, _c;
1764
- const directPasskeyCheck = yield (_b = (_a = window == null ? void 0 : window.PublicKeyCredential) == null ? void 0 : _a.isUserVerifyingPlatformAuthenticatorAvailable) == null ? void 0 : _b.call(_a);
1765
- if (directPasskeyCheck === true || directPasskeyCheck === false) {
1766
- return directPasskeyCheck;
1767
- }
1768
- const osName = (_c = new UAParser(userAgent).getOS().name) == null ? void 0 : _c.toLowerCase();
1769
- return !!osName && !["linux", "chrome os"].includes(osName);
1770
- });
1771
-
1772
- // src/utils/isMobile.ts
1773
- function isAndroid() {
1774
- return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
1775
- }
1776
- function isSmallIOS() {
1777
- return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
1778
- }
1779
- function isLargeIOS() {
1780
- return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
1781
- }
1782
- function isTablet() {
1783
- return typeof navigator !== "undefined" && /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
1784
- navigator.userAgent
1785
- );
1786
- }
1787
- function isIOS() {
1788
- return isSmallIOS() || isLargeIOS();
1789
- }
1790
- function isMobile() {
1791
- return isAndroid() || isIOS();
1792
- }
1793
- function isSafari() {
1794
- return typeof navigator !== "undefined" && /AppleWebKit/i.test(navigator.userAgent) && !/CriOS/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent);
1795
- }
1796
- function isIOSWebview() {
1797
- const isStandalone = typeof navigator !== "undefined" && !navigator.standalone;
1798
- return typeof navigator !== "undefined" && isIOS() && !isStandalone && !/safari/i.test(navigator.userAgent.toLowerCase());
1799
- }
1800
- function isMobileSafari() {
1801
- return isMobile() && isSafari();
1802
- }
1803
- function isTelegram() {
1804
- return typeof window !== "undefined" && (Boolean(window.TelegramWebviewProxy) || Boolean(window.Telegram) || Boolean(window.TelegramWebviewProxyProto));
1805
- }
1806
-
1807
- // src/index.ts
1808
- var src_default = Para;
9
+ import { createCredential, generateSignature, parseCredentialCreationRes } from "./cryptography/webAuth.js";
10
+ import { truncateEthAddress } from "./utils/truncateEthAddress.js";
11
+ import { isPasskeySupported } from "./utils/isPasskeySupported.js";
12
+ export * from "./utils/isMobile.js";
13
+ var src_default = ParaWeb;
1809
14
  export {
1810
- Environment4 as Environment,
1811
- ParaCore2 as ParaCore,
1812
- Para as ParaWeb,
15
+ Environment,
16
+ ParaCore,
17
+ ParaWeb,
1813
18
  createCredential,
1814
19
  src_default as default,
1815
20
  generateSignature,
1816
- isAndroid,
1817
- isIOS,
1818
- isIOSWebview,
1819
- isLargeIOS,
1820
- isMobile,
1821
- isMobileSafari,
1822
21
  isPasskeySupported,
1823
- isSafari,
1824
- isSmallIOS,
1825
- isTablet,
1826
- isTelegram,
1827
22
  parseCredentialCreationRes,
1828
23
  truncateEthAddress
1829
24
  };