@getpara/core-sdk 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,9 +1,41 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __typeError = (msg) => {
12
+ throw TypeError(msg);
13
+ };
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
7
39
  var __export = (target, all) => {
8
40
  for (var name in all)
9
41
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -25,6 +57,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
57
  mod
26
58
  ));
27
59
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
60
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
61
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
62
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
63
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
64
+ var __async = (__this, __arguments, generator) => {
65
+ return new Promise((resolve, reject) => {
66
+ var fulfilled = (value) => {
67
+ try {
68
+ step(generator.next(value));
69
+ } catch (e) {
70
+ reject(e);
71
+ }
72
+ };
73
+ var rejected = (value) => {
74
+ try {
75
+ step(generator.throw(value));
76
+ } catch (e) {
77
+ reject(e);
78
+ }
79
+ };
80
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
81
+ step((generator = generator.apply(__this, __arguments)).next());
82
+ });
83
+ };
28
84
 
29
85
  // src/index.ts
30
86
  var src_exports = {};
@@ -110,7 +166,7 @@ var import_node_forge = __toESM(require("node-forge"));
110
166
  // src/utils/events.ts
111
167
  function dispatchEvent(type, data, error) {
112
168
  typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
113
- new CustomEvent(type, { detail: { data, ...error && { error: new Error(error) } } })
169
+ new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
114
170
  );
115
171
  }
116
172
 
@@ -177,7 +233,8 @@ function truncateAddress(str, addressType, { prefix = addressType === "COSMOS" ?
177
233
  return `${str.slice(0, headLength)}...${str.slice(-4)}`;
178
234
  }
179
235
  function stringToPhoneNumber(str) {
180
- return (0, import_libphonenumber_js.default)(str)?.formatInternational().replace(/[^\d+]/g, "");
236
+ var _a;
237
+ return (_a = (0, import_libphonenumber_js.default)(str)) == null ? void 0 : _a.formatInternational().replace(/[^\d+]/g, "");
181
238
  }
182
239
  function normalizePhoneNumber(countryCode, number) {
183
240
  return stringToPhoneNumber(`${countryCode[0] !== "+" ? "+" : ""}${countryCode}${number}`);
@@ -220,26 +277,28 @@ function getOnRampAssets(data, {
220
277
  }
221
278
 
222
279
  // src/utils/polling.ts
223
- async function waitUntilTrue(condition, timeoutMs, intervalMs) {
224
- const start = Date.now();
225
- while (Date.now() - start < timeoutMs) {
226
- if (await condition()) {
227
- return true;
280
+ function waitUntilTrue(condition, timeoutMs, intervalMs) {
281
+ return __async(this, null, function* () {
282
+ const start = Date.now();
283
+ while (Date.now() - start < timeoutMs) {
284
+ if (yield condition()) {
285
+ return true;
286
+ }
287
+ yield new Promise((resolve) => setTimeout(resolve, intervalMs));
228
288
  }
229
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
230
- }
231
- return false;
289
+ return false;
290
+ });
232
291
  }
233
292
 
234
293
  // src/types/config.ts
235
- var Environment = /* @__PURE__ */ ((Environment3) => {
236
- Environment3["DEV"] = "DEV";
237
- Environment3["SANDBOX"] = "SANDBOX";
238
- Environment3["BETA"] = "BETA";
239
- Environment3["PROD"] = "PROD";
240
- Environment3["DEVELOPMENT"] = "BETA";
241
- Environment3["PRODUCTION"] = "PROD";
242
- return Environment3;
294
+ var Environment = /* @__PURE__ */ ((Environment2) => {
295
+ Environment2["DEV"] = "DEV";
296
+ Environment2["SANDBOX"] = "SANDBOX";
297
+ Environment2["BETA"] = "BETA";
298
+ Environment2["PROD"] = "PROD";
299
+ Environment2["DEVELOPMENT"] = "BETA";
300
+ Environment2["PRODUCTION"] = "PROD";
301
+ return Environment2;
243
302
  })(Environment || {});
244
303
  var EnabledFlow = /* @__PURE__ */ ((EnabledFlow2) => {
245
304
  EnabledFlow2["BUY"] = "BUY";
@@ -402,7 +461,10 @@ function isPregenIdentifierMatch(a, b, type) {
402
461
  }
403
462
  }
404
463
  function isWalletSupported(types, wallet) {
405
- return types.some((walletType) => !!WalletSchemeTypeMap[wallet?.scheme]?.[walletType]);
464
+ return types.some((walletType) => {
465
+ var _a;
466
+ return !!((_a = WalletSchemeTypeMap[wallet == null ? void 0 : wallet.scheme]) == null ? void 0 : _a[walletType]);
467
+ });
406
468
  }
407
469
  function getSchemes(types) {
408
470
  return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
@@ -425,12 +487,11 @@ function getEquivalentTypes(types) {
425
487
  return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map((t) => import_user_management_client.WalletType[t])));
426
488
  }
427
489
  function entityToWallet(w) {
428
- return {
429
- ...w,
490
+ return __spreadProps(__spreadValues({}, w), {
430
491
  scheme: w.scheme,
431
492
  type: w.type,
432
493
  pregenIdentifierType: w.pregenIdentifierType
433
- };
494
+ });
434
495
  }
435
496
  function migrateWallet(obj) {
436
497
  if (["USER", "PREGEN"].includes(obj.type)) {
@@ -472,79 +533,87 @@ function decodePrivateKeyPemHex(privateKeyPemHex) {
472
533
  const pem = Buffer.from(privateKeyPemHex, "hex").toString("utf-8");
473
534
  return import_node_forge.default.pki.privateKeyFromPem(pem);
474
535
  }
475
- async function encryptPrivateKey(keyPair, key) {
476
- const privateKeyPemHex = encodePrivateKeyToPemHex(keyPair);
477
- const cryptoKey = await window.crypto.subtle.importKey(
478
- "raw",
479
- Buffer.from(key, "base64"),
480
- {
481
- name: "AES-GCM",
482
- length: 256
483
- },
484
- true,
485
- ["encrypt", "decrypt"]
486
- );
487
- const encodedPlaintext = new TextEncoder().encode(privateKeyPemHex);
488
- const ciphertext = await window.crypto.subtle.encrypt(
489
- { name: "AES-GCM", iv: CONSTANT_IV_AES },
490
- cryptoKey,
491
- encodedPlaintext
492
- );
493
- return Buffer.from(ciphertext).toString("base64");
536
+ function encryptPrivateKey(keyPair, key) {
537
+ return __async(this, null, function* () {
538
+ const privateKeyPemHex = encodePrivateKeyToPemHex(keyPair);
539
+ const cryptoKey = yield window.crypto.subtle.importKey(
540
+ "raw",
541
+ Buffer.from(key, "base64"),
542
+ {
543
+ name: "AES-GCM",
544
+ length: 256
545
+ },
546
+ true,
547
+ ["encrypt", "decrypt"]
548
+ );
549
+ const encodedPlaintext = new TextEncoder().encode(privateKeyPemHex);
550
+ const ciphertext = yield window.crypto.subtle.encrypt(
551
+ { name: "AES-GCM", iv: CONSTANT_IV_AES },
552
+ cryptoKey,
553
+ encodedPlaintext
554
+ );
555
+ return Buffer.from(ciphertext).toString("base64");
556
+ });
494
557
  }
495
- async function decryptPrivateKey(encryptedPrivateKeyPemHex, key) {
496
- const secretKey = await crypto.subtle.importKey(
497
- "raw",
498
- Buffer.from(key, "base64"),
499
- {
500
- name: "AES-GCM",
501
- length: 256
502
- },
503
- true,
504
- ["encrypt", "decrypt"]
505
- );
506
- const cleartext = await crypto.subtle.decrypt(
507
- { name: "AES-GCM", iv: CONSTANT_IV_AES },
508
- secretKey,
509
- Buffer.from(encryptedPrivateKeyPemHex, "base64")
510
- );
511
- const privateKeyPemHex = new TextDecoder().decode(cleartext);
512
- const privateKey = decodePrivateKeyPemHex(privateKeyPemHex);
513
- return privateKey;
558
+ function decryptPrivateKey(encryptedPrivateKeyPemHex, key) {
559
+ return __async(this, null, function* () {
560
+ const secretKey = yield crypto.subtle.importKey(
561
+ "raw",
562
+ Buffer.from(key, "base64"),
563
+ {
564
+ name: "AES-GCM",
565
+ length: 256
566
+ },
567
+ true,
568
+ ["encrypt", "decrypt"]
569
+ );
570
+ const cleartext = yield crypto.subtle.decrypt(
571
+ { name: "AES-GCM", iv: CONSTANT_IV_AES },
572
+ secretKey,
573
+ Buffer.from(encryptedPrivateKeyPemHex, "base64")
574
+ );
575
+ const privateKeyPemHex = new TextDecoder().decode(cleartext);
576
+ const privateKey = decodePrivateKeyPemHex(privateKeyPemHex);
577
+ return privateKey;
578
+ });
514
579
  }
515
- async function getAsymmetricKeyPair(ctx, seedValue) {
516
- const prng = import_node_forge.default.random.createInstance();
517
- if (seedValue) {
518
- prng.seedFileSync = (_n) => seedValue;
519
- prng.seedFile = (_n, cb) => {
520
- cb(null, seedValue);
580
+ function getAsymmetricKeyPair(ctx, seedValue) {
581
+ return __async(this, null, function* () {
582
+ const prng = import_node_forge.default.random.createInstance();
583
+ if (seedValue) {
584
+ prng.seedFileSync = (_n) => seedValue;
585
+ prng.seedFile = (_n, cb) => {
586
+ cb(null, seedValue);
587
+ };
588
+ }
589
+ const options = {
590
+ bits: 2048,
591
+ e: 65537,
592
+ prng
521
593
  };
522
- }
523
- const options = {
524
- bits: 2048,
525
- e: 65537,
526
- prng
527
- };
528
- if (!ctx.disableWorkers) {
529
- options.workLoad = 100;
530
- options.workers = seedValue ? 1 : -1;
531
- const workerRes = await fetch(`${getPortalBaseURL(ctx)}/static/js/prime.worker.min.js`);
532
- const workerBlob = new Blob([await workerRes.text()], { type: "application/javascript" });
533
- options.workerScript = URL.createObjectURL(workerBlob);
534
- }
535
- return new Promise(
536
- (resolve, reject) => rsa.generateKeyPair(options, (err, keypair) => {
537
- if (err) {
538
- reject(err);
539
- }
540
- resolve(keypair);
541
- })
542
- );
594
+ if (!ctx.disableWorkers) {
595
+ options.workLoad = 100;
596
+ options.workers = seedValue ? 1 : -1;
597
+ const workerRes = yield fetch(`${getPortalBaseURL(ctx)}/static/js/prime.worker.min.js`);
598
+ const workerBlob = new Blob([yield workerRes.text()], { type: "application/javascript" });
599
+ options.workerScript = URL.createObjectURL(workerBlob);
600
+ }
601
+ return new Promise(
602
+ (resolve, reject) => rsa.generateKeyPair(options, (err, keypair) => {
603
+ if (err) {
604
+ reject(err);
605
+ }
606
+ resolve(keypair);
607
+ })
608
+ );
609
+ });
543
610
  }
544
- async function getPublicKeyFromSignature(ctx, userHandle) {
545
- const encodedUserHandle = import_base64url.default.encode(userHandle);
546
- const keyPair = await getAsymmetricKeyPair(ctx, encodedUserHandle);
547
- return getPublicKeyHex(keyPair);
611
+ function getPublicKeyFromSignature(ctx, userHandle) {
612
+ return __async(this, null, function* () {
613
+ const encodedUserHandle = import_base64url.default.encode(userHandle);
614
+ const keyPair = yield getAsymmetricKeyPair(ctx, encodedUserHandle);
615
+ return getPublicKeyHex(keyPair);
616
+ });
548
617
  }
549
618
  function symmetricKeyEncryptMessage(message) {
550
619
  const key = import_node_forge.default.random.getBytesSync(16);
@@ -572,49 +641,57 @@ function decryptWithPrivateKey(privateKey, encryptedMessageHex, encryptedKeyHex)
572
641
  const key = privateKey.decrypt(encryptedKey, RSA_ENCRYPTION_SCHEME);
573
642
  return decipherEncryptedMessageHex(key, encryptedMessageHex);
574
643
  }
575
- async function decryptWithDerivedPrivateKey(ctx, {
576
- seedValue,
577
- encryptedMessageHex,
578
- encryptedKeyHex
579
- }) {
580
- const keyPair = await getAsymmetricKeyPair(ctx, seedValue);
581
- return decryptWithPrivateKey(keyPair.privateKey, encryptedMessageHex, encryptedKeyHex);
644
+ function decryptWithDerivedPrivateKey(_0, _1) {
645
+ return __async(this, arguments, function* (ctx, {
646
+ seedValue,
647
+ encryptedMessageHex,
648
+ encryptedKeyHex
649
+ }) {
650
+ const keyPair = yield getAsymmetricKeyPair(ctx, seedValue);
651
+ return decryptWithPrivateKey(keyPair.privateKey, encryptedMessageHex, encryptedKeyHex);
652
+ });
653
+ }
654
+ function getDerivedPrivateKeyAndDecrypt(ctx, seedValue, encryptedShares) {
655
+ return __async(this, null, function* () {
656
+ return Promise.all(
657
+ encryptedShares.map((share) => __async(this, null, function* () {
658
+ return {
659
+ walletId: share.walletId,
660
+ walletScheme: share.walletScheme,
661
+ partnerId: share.partnerId,
662
+ signer: yield decryptWithDerivedPrivateKey(ctx, {
663
+ seedValue,
664
+ encryptedMessageHex: share.encryptedShare,
665
+ encryptedKeyHex: share.encryptedKey
666
+ }),
667
+ protocolId: share.protocolId
668
+ };
669
+ }))
670
+ );
671
+ });
582
672
  }
583
- async function getDerivedPrivateKeyAndDecrypt(ctx, seedValue, encryptedShares) {
584
- return Promise.all(
585
- encryptedShares.map(async (share) => ({
673
+ function decryptPrivateKeyAndDecryptShare(encryptionKey, encryptedShares, encryptedPrivateKey) {
674
+ return __async(this, null, function* () {
675
+ let privateKey;
676
+ try {
677
+ privateKey = yield decryptPrivateKey(encryptedPrivateKey, encryptionKey);
678
+ } catch (e) {
679
+ }
680
+ try {
681
+ privateKey = yield decryptPrivateKeyWithPassword(encryptedPrivateKey, encryptionKey);
682
+ } catch (e) {
683
+ }
684
+ if (!privateKey) {
685
+ throw new Error("Could not decrypt private key");
686
+ }
687
+ return encryptedShares.map((share) => ({
586
688
  walletId: share.walletId,
587
689
  walletScheme: share.walletScheme,
588
690
  partnerId: share.partnerId,
589
- signer: await decryptWithDerivedPrivateKey(ctx, {
590
- seedValue,
591
- encryptedMessageHex: share.encryptedShare,
592
- encryptedKeyHex: share.encryptedKey
593
- }),
691
+ signer: decryptWithPrivateKey(privateKey, share.encryptedShare, share.encryptedKey),
594
692
  protocolId: share.protocolId
595
- }))
596
- );
597
- }
598
- async function decryptPrivateKeyAndDecryptShare(encryptionKey, encryptedShares, encryptedPrivateKey) {
599
- let privateKey;
600
- try {
601
- privateKey = await decryptPrivateKey(encryptedPrivateKey, encryptionKey);
602
- } catch (e) {
603
- }
604
- try {
605
- privateKey = await decryptPrivateKeyWithPassword(encryptedPrivateKey, encryptionKey);
606
- } catch (e) {
607
- }
608
- if (!privateKey) {
609
- throw new Error("Could not decrypt private key");
610
- }
611
- return encryptedShares.map((share) => ({
612
- walletId: share.walletId,
613
- walletScheme: share.walletScheme,
614
- partnerId: share.partnerId,
615
- signer: decryptWithPrivateKey(privateKey, share.encryptedShare, share.encryptedKey),
616
- protocolId: share.protocolId
617
- }));
693
+ }));
694
+ });
618
695
  }
619
696
  function encryptWithDerivedPublicKey(publicKeyHex, message) {
620
697
  const { key, encryptedMessageHex } = symmetricKeyEncryptMessage(message);
@@ -633,49 +710,55 @@ function hashPasswordWithSalt(password) {
633
710
  function generateSalt(length = 16) {
634
711
  return import_node_forge.default.util.bytesToHex(import_node_forge.default.random.getBytesSync(length));
635
712
  }
636
- async function deriveCryptoKeyFromPassword(hashedPassword) {
637
- const keyBuffer = Buffer.from(hashedPassword, "hex");
638
- return await window.crypto.subtle.importKey(
639
- "raw",
640
- keyBuffer,
641
- {
642
- name: "AES-GCM",
643
- length: 256
644
- },
645
- true,
646
- ["encrypt", "decrypt"]
647
- );
713
+ function deriveCryptoKeyFromPassword(hashedPassword) {
714
+ return __async(this, null, function* () {
715
+ const keyBuffer = Buffer.from(hashedPassword, "hex");
716
+ return yield window.crypto.subtle.importKey(
717
+ "raw",
718
+ keyBuffer,
719
+ {
720
+ name: "AES-GCM",
721
+ length: 256
722
+ },
723
+ true,
724
+ ["encrypt", "decrypt"]
725
+ );
726
+ });
648
727
  }
649
- async function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
650
- const cryptoKey = await deriveCryptoKeyFromPassword(hashedPassword);
651
- const privateKeyPemHex = encodePrivateKeyToPemHex(keyPair);
652
- const encodedPlaintext = new TextEncoder().encode(privateKeyPemHex);
653
- const ciphertext = await window.crypto.subtle.encrypt(
654
- { name: "AES-GCM", iv: CONSTANT_IV_AES },
655
- cryptoKey,
656
- encodedPlaintext
657
- );
658
- return Buffer.from(ciphertext).toString("base64");
728
+ function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
729
+ return __async(this, null, function* () {
730
+ const cryptoKey = yield deriveCryptoKeyFromPassword(hashedPassword);
731
+ const privateKeyPemHex = encodePrivateKeyToPemHex(keyPair);
732
+ const encodedPlaintext = new TextEncoder().encode(privateKeyPemHex);
733
+ const ciphertext = yield window.crypto.subtle.encrypt(
734
+ { name: "AES-GCM", iv: CONSTANT_IV_AES },
735
+ cryptoKey,
736
+ encodedPlaintext
737
+ );
738
+ return Buffer.from(ciphertext).toString("base64");
739
+ });
659
740
  }
660
- async function decryptPrivateKeyWithPassword(encryptedPrivateKeyPemHex, hashedPassword) {
661
- const secretKey = await crypto.subtle.importKey(
662
- "raw",
663
- Buffer.from(hashedPassword, "hex"),
664
- {
665
- name: "AES-GCM",
666
- length: 256
667
- },
668
- true,
669
- ["encrypt", "decrypt"]
670
- );
671
- const cleartext = await crypto.subtle.decrypt(
672
- { name: "AES-GCM", iv: CONSTANT_IV_AES },
673
- secretKey,
674
- Buffer.from(encryptedPrivateKeyPemHex, "base64")
675
- );
676
- const privateKeyPemHex = new TextDecoder().decode(cleartext);
677
- const privateKey = decodePrivateKeyPemHex(privateKeyPemHex);
678
- return privateKey;
741
+ function decryptPrivateKeyWithPassword(encryptedPrivateKeyPemHex, hashedPassword) {
742
+ return __async(this, null, function* () {
743
+ const secretKey = yield crypto.subtle.importKey(
744
+ "raw",
745
+ Buffer.from(hashedPassword, "hex"),
746
+ {
747
+ name: "AES-GCM",
748
+ length: 256
749
+ },
750
+ true,
751
+ ["encrypt", "decrypt"]
752
+ );
753
+ const cleartext = yield crypto.subtle.decrypt(
754
+ { name: "AES-GCM", iv: CONSTANT_IV_AES },
755
+ secretKey,
756
+ Buffer.from(encryptedPrivateKeyPemHex, "base64")
757
+ );
758
+ const privateKeyPemHex = new TextDecoder().decode(cleartext);
759
+ const privateKey = decodePrivateKeyPemHex(privateKeyPemHex);
760
+ return privateKey;
761
+ });
679
762
  }
680
763
 
681
764
  // src/external/userManagementClient.ts
@@ -837,125 +920,126 @@ var KeyContainer = class _KeyContainer {
837
920
  };
838
921
 
839
922
  // src/shares/recovery.ts
840
- async function sendRecoveryForShare({
841
- ctx,
842
- userId,
843
- walletId,
844
- otherEncryptedShares = [],
845
- userSigner,
846
- ignoreRedistributingBackupEncryptedShare = false,
847
- emailProps = {},
848
- forceRefresh = false
849
- }) {
850
- if (ignoreRedistributingBackupEncryptedShare) {
851
- await ctx.client.uploadUserKeyShares(
852
- userId,
853
- otherEncryptedShares.map((share) => ({
854
- walletId,
855
- ...share
856
- }))
857
- );
858
- return "";
859
- }
860
- let userBackupKeyShareOptsArr;
861
- let recoveryPrivateKeyContainer;
862
- const { recoveryPublicKeys } = await ctx.client.getRecoveryPublicKeys(userId);
863
- if (forceRefresh || !recoveryPublicKeys?.length) {
864
- recoveryPrivateKeyContainer = new KeyContainer(walletId, "", "");
865
- const { recoveryPublicKeys: recoveryPublicKeys2 } = await ctx.client.persistRecoveryPublicKeys(userId, [
866
- recoveryPrivateKeyContainer.getPublicEncryptionKeyHex()
867
- ]);
868
- const encryptedUserBackup = recoveryPrivateKeyContainer.encryptForSelf(userSigner);
869
- userBackupKeyShareOptsArr = [
870
- {
871
- walletId,
872
- encryptedShare: encryptedUserBackup,
873
- type: import_user_management_client3.KeyShareType.USER,
874
- encryptor: import_user_management_client3.EncryptorType.RECOVERY,
875
- recoveryPublicKeyId: recoveryPublicKeys2[0].id
876
- }
877
- ];
878
- } else {
879
- userBackupKeyShareOptsArr = recoveryPublicKeys.map((recoveryPublicKey) => {
880
- const { id: recoveryPublicKeyId, publicKey } = recoveryPublicKey;
881
- const encryptedUserBackup = KeyContainer.encryptWithPublicKey(Buffer.from(publicKey, "hex"), userSigner);
882
- return {
883
- walletId,
884
- encryptedShare: encryptedUserBackup,
885
- type: import_user_management_client3.KeyShareType.USER,
886
- encryptor: import_user_management_client3.EncryptorType.RECOVERY,
887
- recoveryPublicKeyId
888
- };
889
- });
890
- }
891
- await ctx.client.uploadUserKeyShares(userId, [
892
- ...otherEncryptedShares.map((share) => ({
893
- walletId,
894
- ...share
895
- })),
896
- ...ignoreRedistributingBackupEncryptedShare ? [] : userBackupKeyShareOptsArr
897
- ]);
898
- await ctx.client.distributeParaShare({
923
+ function sendRecoveryForShare(_0) {
924
+ return __async(this, arguments, function* ({
925
+ ctx,
899
926
  userId,
900
927
  walletId,
901
- useDKLS: ctx.useDKLS,
902
- ...emailProps
928
+ otherEncryptedShares = [],
929
+ userSigner,
930
+ ignoreRedistributingBackupEncryptedShare = false,
931
+ emailProps = {},
932
+ forceRefresh = false
933
+ }) {
934
+ if (ignoreRedistributingBackupEncryptedShare) {
935
+ yield ctx.client.uploadUserKeyShares(
936
+ userId,
937
+ otherEncryptedShares.map((share) => __spreadValues({
938
+ walletId
939
+ }, share))
940
+ );
941
+ return "";
942
+ }
943
+ let userBackupKeyShareOptsArr;
944
+ let recoveryPrivateKeyContainer;
945
+ const { recoveryPublicKeys } = yield ctx.client.getRecoveryPublicKeys(userId);
946
+ if (forceRefresh || !(recoveryPublicKeys == null ? void 0 : recoveryPublicKeys.length)) {
947
+ recoveryPrivateKeyContainer = new KeyContainer(walletId, "", "");
948
+ const { recoveryPublicKeys: recoveryPublicKeys2 } = yield ctx.client.persistRecoveryPublicKeys(userId, [
949
+ recoveryPrivateKeyContainer.getPublicEncryptionKeyHex()
950
+ ]);
951
+ const encryptedUserBackup = recoveryPrivateKeyContainer.encryptForSelf(userSigner);
952
+ userBackupKeyShareOptsArr = [
953
+ {
954
+ walletId,
955
+ encryptedShare: encryptedUserBackup,
956
+ type: import_user_management_client3.KeyShareType.USER,
957
+ encryptor: import_user_management_client3.EncryptorType.RECOVERY,
958
+ recoveryPublicKeyId: recoveryPublicKeys2[0].id
959
+ }
960
+ ];
961
+ } else {
962
+ userBackupKeyShareOptsArr = recoveryPublicKeys.map((recoveryPublicKey) => {
963
+ const { id: recoveryPublicKeyId, publicKey } = recoveryPublicKey;
964
+ const encryptedUserBackup = KeyContainer.encryptWithPublicKey(Buffer.from(publicKey, "hex"), userSigner);
965
+ return {
966
+ walletId,
967
+ encryptedShare: encryptedUserBackup,
968
+ type: import_user_management_client3.KeyShareType.USER,
969
+ encryptor: import_user_management_client3.EncryptorType.RECOVERY,
970
+ recoveryPublicKeyId
971
+ };
972
+ });
973
+ }
974
+ yield ctx.client.uploadUserKeyShares(userId, [
975
+ ...otherEncryptedShares.map((share) => __spreadValues({
976
+ walletId
977
+ }, share)),
978
+ ...ignoreRedistributingBackupEncryptedShare ? [] : userBackupKeyShareOptsArr
979
+ ]);
980
+ yield ctx.client.distributeParaShare(__spreadValues({
981
+ userId,
982
+ walletId,
983
+ useDKLS: ctx.useDKLS
984
+ }, emailProps));
985
+ return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
903
986
  });
904
- return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
905
987
  }
906
988
 
907
989
  // src/shares/shareDistribution.ts
908
- async function distributeNewShare({
909
- ctx,
910
- userId,
911
- walletId,
912
- userShare,
913
- ignoreRedistributingBackupEncryptedShare = false,
914
- emailProps = {},
915
- partnerId,
916
- protocolId
917
- }) {
918
- const publicKeysRes = await ctx.client.getSessionPublicKeys(userId);
919
- const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
920
- if (!key.publicKey) {
921
- return;
922
- }
923
- const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(key.sigDerivedPublicKey, userShare);
924
- return {
925
- encryptedShare: encryptedMessageHex,
926
- encryptedKey: encryptedKeyHex,
927
- type: import_user_management_client4.KeyShareType.USER,
928
- encryptor: import_user_management_client4.EncryptorType.BIOMETRICS,
929
- biometricPublicKey: key.sigDerivedPublicKey,
930
- partnerId,
931
- protocolId
932
- };
933
- }).filter(Boolean);
934
- const passwords = await ctx.client.getPasswords({ userId });
935
- const passwordEncryptedShares = passwords.map((password) => {
936
- if (password.status === "PENDING") {
937
- return;
938
- }
939
- const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(password.sigDerivedPublicKey, userShare);
940
- return {
941
- encryptedShare: encryptedMessageHex,
942
- encryptedKey: encryptedKeyHex,
943
- type: import_user_management_client4.KeyShareType.USER,
944
- encryptor: import_user_management_client4.EncryptorType.PASSWORD,
945
- passwordId: password.id,
946
- partnerId,
947
- protocolId
948
- };
949
- }).filter(Boolean);
950
- const allEncryptedShares = [...biometricEncryptedShares, ...passwordEncryptedShares];
951
- return await sendRecoveryForShare({
990
+ function distributeNewShare(_0) {
991
+ return __async(this, arguments, function* ({
952
992
  ctx,
953
993
  userId,
954
994
  walletId,
955
- otherEncryptedShares: allEncryptedShares,
956
- userSigner: userShare,
957
- ignoreRedistributingBackupEncryptedShare,
958
- emailProps
995
+ userShare,
996
+ ignoreRedistributingBackupEncryptedShare = false,
997
+ emailProps = {},
998
+ partnerId,
999
+ protocolId
1000
+ }) {
1001
+ const publicKeysRes = yield ctx.client.getSessionPublicKeys(userId);
1002
+ const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
1003
+ if (!key.publicKey) {
1004
+ return;
1005
+ }
1006
+ const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(key.sigDerivedPublicKey, userShare);
1007
+ return {
1008
+ encryptedShare: encryptedMessageHex,
1009
+ encryptedKey: encryptedKeyHex,
1010
+ type: import_user_management_client4.KeyShareType.USER,
1011
+ encryptor: import_user_management_client4.EncryptorType.BIOMETRICS,
1012
+ biometricPublicKey: key.sigDerivedPublicKey,
1013
+ partnerId,
1014
+ protocolId
1015
+ };
1016
+ }).filter(Boolean);
1017
+ const passwords = yield ctx.client.getPasswords({ userId });
1018
+ const passwordEncryptedShares = passwords.map((password) => {
1019
+ if (password.status === "PENDING") {
1020
+ return;
1021
+ }
1022
+ const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(password.sigDerivedPublicKey, userShare);
1023
+ return {
1024
+ encryptedShare: encryptedMessageHex,
1025
+ encryptedKey: encryptedKeyHex,
1026
+ type: import_user_management_client4.KeyShareType.USER,
1027
+ encryptor: import_user_management_client4.EncryptorType.PASSWORD,
1028
+ passwordId: password.id,
1029
+ partnerId,
1030
+ protocolId
1031
+ };
1032
+ }).filter(Boolean);
1033
+ const allEncryptedShares = [...biometricEncryptedShares, ...passwordEncryptedShares];
1034
+ return yield sendRecoveryForShare({
1035
+ ctx,
1036
+ userId,
1037
+ walletId,
1038
+ otherEncryptedShares: allEncryptedShares,
1039
+ userSigner: userShare,
1040
+ ignoreRedistributingBackupEncryptedShare,
1041
+ emailProps
1042
+ });
959
1043
  });
960
1044
  }
961
1045
 
@@ -964,32 +1048,36 @@ var import_ecies2 = require("@celo/utils/lib/ecies.js");
964
1048
  var import_buffer = require("buffer");
965
1049
  var eutil2 = __toESM(require("ethereumjs-util"));
966
1050
  var import_crypto = require("crypto");
967
- async function upload(message, userManagementClient) {
968
- let secret;
969
- let publicKeyUint8Array;
970
- while (true) {
971
- try {
972
- secret = (0, import_crypto.randomBytes)(32).toString("hex");
973
- publicKeyUint8Array = eutil2.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
974
- break;
975
- } catch (e) {
976
- continue;
1051
+ function upload(message, userManagementClient) {
1052
+ return __async(this, null, function* () {
1053
+ let secret;
1054
+ let publicKeyUint8Array;
1055
+ while (true) {
1056
+ try {
1057
+ secret = (0, import_crypto.randomBytes)(32).toString("hex");
1058
+ publicKeyUint8Array = eutil2.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
1059
+ break;
1060
+ } catch (e) {
1061
+ continue;
1062
+ }
977
1063
  }
978
- }
979
- const pubkey = import_buffer.Buffer.from(publicKeyUint8Array);
980
- const data = (0, import_ecies2.Encrypt)(pubkey, import_buffer.Buffer.from(message, "ucs2")).toString("base64");
981
- const {
982
- data: { id }
983
- } = await userManagementClient.tempTrasmissionInit(data);
984
- return encodeURIComponent(id + "|" + secret);
1064
+ const pubkey = import_buffer.Buffer.from(publicKeyUint8Array);
1065
+ const data = (0, import_ecies2.Encrypt)(pubkey, import_buffer.Buffer.from(message, "ucs2")).toString("base64");
1066
+ const {
1067
+ data: { id }
1068
+ } = yield userManagementClient.tempTrasmissionInit(data);
1069
+ return encodeURIComponent(id + "|" + secret);
1070
+ });
985
1071
  }
986
- async function retrieve(uriEncodedMessage, userManagementClient) {
987
- const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
988
- const response = await userManagementClient.tempTrasmission(id);
989
- const data = response.data.message;
990
- const buf = import_buffer.Buffer.from(data, "base64");
991
- const res = import_buffer.Buffer.from((0, import_ecies2.Decrypt)(import_buffer.Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
992
- return res;
1072
+ function retrieve(uriEncodedMessage, userManagementClient) {
1073
+ return __async(this, null, function* () {
1074
+ const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
1075
+ const response = yield userManagementClient.tempTrasmission(id);
1076
+ const data = response.data.message;
1077
+ const buf = import_buffer.Buffer.from(data, "base64");
1078
+ const res = import_buffer.Buffer.from((0, import_ecies2.Decrypt)(import_buffer.Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
1079
+ return res;
1080
+ });
993
1081
  }
994
1082
 
995
1083
  // src/errors.ts
@@ -1016,7 +1104,7 @@ var TransactionReviewTimeout = class extends Error {
1016
1104
  };
1017
1105
 
1018
1106
  // src/constants.ts
1019
- var PARA_CORE_VERSION = '1.5.0';
1107
+ var PARA_CORE_VERSION = '1.6.0';
1020
1108
  var PREFIX = "@CAPSULE/";
1021
1109
  var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
1022
1110
  var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
@@ -1087,7 +1175,8 @@ if (typeof global !== "undefined") {
1087
1175
  self.global = self.global || self;
1088
1176
  }
1089
1177
  var { pki, jsbn } = import_node_forge2.default;
1090
- var ParaCore = class _ParaCore {
1178
+ var _supportedWalletTypes, _supportedWalletTypesOpt;
1179
+ var _ParaCore = class _ParaCore {
1091
1180
  /**
1092
1181
  * Constructs a new `ParaCore` instance.
1093
1182
  * @param env - `Environment` to use.
@@ -1104,8 +1193,8 @@ var ParaCore = class _ParaCore {
1104
1193
  * The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
1105
1194
  */
1106
1195
  this.currentWalletIds = {};
1107
- this.#supportedWalletTypes = void 0;
1108
- this.#supportedWalletTypesOpt = void 0;
1196
+ __privateAdd(this, _supportedWalletTypes);
1197
+ __privateAdd(this, _supportedWalletTypesOpt);
1109
1198
  this.localStorageGetItem = (key) => {
1110
1199
  return this.platformUtils.localStorage.get(key);
1111
1200
  };
@@ -1128,14 +1217,14 @@ var ParaCore = class _ParaCore {
1128
1217
  * Remove all local storage and prefixed session storage.
1129
1218
  * @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
1130
1219
  */
1131
- this.clearStorage = async (type = "all") => {
1220
+ this.clearStorage = (type = "all") => __async(this, null, function* () {
1132
1221
  const isAll = type === "all";
1133
1222
  (isAll || type === "local") && this.platformUtils.localStorage.clear(PREFIX);
1134
1223
  (isAll || type === "session") && this.platformUtils.sessionStorage.clear(PREFIX);
1135
1224
  if ((isAll || type === "secure") && this.platformUtils.secureStorage) {
1136
1225
  this.platformUtils.secureStorage.clear(PREFIX);
1137
1226
  }
1138
- };
1227
+ });
1139
1228
  this.initializeFromStorage = () => {
1140
1229
  this.updateEmailFromStorage();
1141
1230
  this.updateCountryCodeFromStorage();
@@ -1163,18 +1252,16 @@ var ParaCore = class _ParaCore {
1163
1252
  this.updateEmailFromStorage = () => {
1164
1253
  this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || void 0;
1165
1254
  };
1166
- this.updateWalletsFromStorage = async () => {
1167
- const _currentWalletIds = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS) ?? void 0;
1255
+ this.updateWalletsFromStorage = () => __async(this, null, function* () {
1256
+ var _a;
1257
+ const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1168
1258
  const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
1169
1259
  const fromJson = JSON.parse(_currentWalletIds);
1170
1260
  return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1171
1261
  const wallet = Object.values(this.wallets).find(
1172
1262
  (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1173
1263
  );
1174
- return {
1175
- ...acc,
1176
- ...wallet && !acc[type] ? { [type]: [wallet.id] } : {}
1177
- };
1264
+ return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1178
1265
  }, {}) : fromJson;
1179
1266
  })();
1180
1267
  this.setCurrentWalletIds(currentWalletIds);
@@ -1182,34 +1269,25 @@ var ParaCore = class _ParaCore {
1182
1269
  const _wallets = JSON.parse(stringWallets || "{}");
1183
1270
  const stringEd25519Wallets = this.platformUtils.secureStorage ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS) : this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
1184
1271
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || "{}");
1185
- const wallets = {
1186
- ...Object.keys(_wallets).reduce((res, key) => {
1187
- return {
1188
- ...res,
1189
- [key]: migrateWallet(_wallets[key])
1190
- };
1191
- }, {}),
1192
- ...Object.keys(_ed25519Wallets).reduce((res, key) => {
1193
- return {
1194
- ...res,
1195
- ...!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}
1196
- };
1197
- }, {})
1198
- };
1272
+ const wallets = __spreadValues(__spreadValues({}, Object.keys(_wallets).reduce((res, key) => {
1273
+ return __spreadProps(__spreadValues({}, res), {
1274
+ [key]: migrateWallet(_wallets[key])
1275
+ });
1276
+ }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
1277
+ return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {});
1278
+ }, {}));
1199
1279
  this.setWallets(wallets);
1200
- };
1280
+ });
1201
1281
  this.updateWalletIdsFromStorage = () => {
1202
- const _currentWalletIds = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS) ?? void 0;
1282
+ var _a;
1283
+ const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1203
1284
  const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
1204
1285
  const fromJson = JSON.parse(_currentWalletIds);
1205
1286
  return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1206
1287
  const wallet = Object.values(this.wallets).find(
1207
1288
  (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1208
1289
  );
1209
- return {
1210
- ...acc,
1211
- ...wallet && !acc[type] ? { [type]: [wallet.id] } : {}
1212
- };
1290
+ return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1213
1291
  }, {}) : fromJson;
1214
1292
  })();
1215
1293
  this.setCurrentWalletIds(currentWalletIds);
@@ -1241,6 +1319,11 @@ var ParaCore = class _ParaCore {
1241
1319
  **/
1242
1320
  this.createWalletPerMissingType = this.createWalletPerType;
1243
1321
  if (!opts) opts = {};
1322
+ let isE2E = false;
1323
+ if (env === "E2E") {
1324
+ isE2E = true;
1325
+ env = "SANDBOX" /* SANDBOX */;
1326
+ }
1244
1327
  this.emailPrimaryColor = opts.emailPrimaryColor;
1245
1328
  this.emailTheme = opts.emailTheme;
1246
1329
  this.homepageUrl = opts.homepageUrl;
@@ -1292,13 +1375,14 @@ var ParaCore = class _ParaCore {
1292
1375
  useDKLS: opts.useDKLSForCreation || !opts.offloadMPCComputationURL,
1293
1376
  disableWebSockets: !!opts.disableWebSockets,
1294
1377
  wasmOverride: opts.wasmOverride,
1295
- cosmosPrefix: this.cosmosPrefix
1378
+ cosmosPrefix: this.cosmosPrefix,
1379
+ isE2E
1296
1380
  };
1297
1381
  if (opts.offloadMPCComputationURL) {
1298
1382
  this.ctx.mpcComputationClient = initClient2(opts.offloadMPCComputationURL, opts.disableWorkers);
1299
1383
  }
1300
1384
  try {
1301
- this.#supportedWalletTypes = opts.supportedWalletTypes ? (() => {
1385
+ __privateSet(this, _supportedWalletTypes, opts.supportedWalletTypes ? (() => {
1302
1386
  if (Object.values(opts.supportedWalletTypes).every(
1303
1387
  (config) => !!config && typeof config === "object" && config.optional
1304
1388
  )) {
@@ -1307,19 +1391,20 @@ var ParaCore = class _ParaCore {
1307
1391
  if (!Object.keys(opts.supportedWalletTypes).every((type) => Object.values(import_user_management_client5.WalletType).includes(type))) {
1308
1392
  throw new Error("unsupported wallet type");
1309
1393
  }
1310
- this.#supportedWalletTypesOpt = opts.supportedWalletTypes;
1394
+ __privateSet(this, _supportedWalletTypesOpt, opts.supportedWalletTypes);
1311
1395
  return Object.entries(opts.supportedWalletTypes).reduce((acc, [key, value]) => {
1396
+ var _a;
1312
1397
  if (!value) {
1313
1398
  return acc;
1314
1399
  }
1315
1400
  if (key === import_user_management_client5.WalletType.COSMOS && typeof value === "object" && !!value.prefix) {
1316
1401
  this.cosmosPrefix = value.prefix;
1317
1402
  }
1318
- return [...acc, { type: key, optional: value === true ? false : value.optional ?? false }];
1403
+ return [...acc, { type: key, optional: value === true ? false : (_a = value.optional) != null ? _a : false }];
1319
1404
  }, []);
1320
- })() : void 0;
1405
+ })() : void 0);
1321
1406
  } catch (e) {
1322
- this.#supportedWalletTypes = void 0;
1407
+ __privateSet(this, _supportedWalletTypes, void 0);
1323
1408
  }
1324
1409
  if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
1325
1410
  return;
@@ -1327,9 +1412,6 @@ var ParaCore = class _ParaCore {
1327
1412
  this.initializeFromStorage();
1328
1413
  setupListeners.bind(this)();
1329
1414
  }
1330
- static {
1331
- this.version = PARA_CORE_VERSION;
1332
- }
1333
1415
  get isEmail() {
1334
1416
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1335
1417
  }
@@ -1344,9 +1426,10 @@ var ParaCore = class _ParaCore {
1344
1426
  }
1345
1427
  get currentWalletIdsArray() {
1346
1428
  return this.supportedWalletTypes.reduce((acc, { type }) => {
1429
+ var _a;
1347
1430
  return [
1348
1431
  ...acc,
1349
- ...(this.currentWalletIds[type] ?? []).map((id) => {
1432
+ ...((_a = this.currentWalletIds[type]) != null ? _a : []).map((id) => {
1350
1433
  return [id, type];
1351
1434
  })
1352
1435
  ];
@@ -1359,19 +1442,17 @@ var ParaCore = class _ParaCore {
1359
1442
  * A map of pre-generated wallet identifiers that can be claimed in the current instance.
1360
1443
  */
1361
1444
  get pregenIds() {
1362
- return {
1363
- ...Object.values(this.wallets).filter((wallet) => !this.userId || this.isPregenWalletClaimable(wallet)).reduce((acc, wallet) => {
1364
- if ((acc[wallet.pregenIdentifierType] ?? []).includes(wallet.pregenIdentifier)) {
1365
- return acc;
1366
- }
1367
- return {
1368
- ...acc,
1369
- [wallet.pregenIdentifierType]: [
1370
- .../* @__PURE__ */ new Set([...acc[wallet.pregenIdentifierType] ?? [], wallet.pregenIdentifier])
1371
- ]
1372
- };
1373
- }, {})
1374
- };
1445
+ return __spreadValues({}, Object.values(this.wallets).filter((wallet) => !this.userId || this.isPregenWalletClaimable(wallet)).reduce((acc, wallet) => {
1446
+ var _a, _b;
1447
+ if (((_a = acc[wallet.pregenIdentifierType]) != null ? _a : []).includes(wallet.pregenIdentifier)) {
1448
+ return acc;
1449
+ }
1450
+ return __spreadProps(__spreadValues({}, acc), {
1451
+ [wallet.pregenIdentifierType]: [
1452
+ .../* @__PURE__ */ new Set([...(_b = acc[wallet.pregenIdentifierType]) != null ? _b : [], wallet.pregenIdentifier])
1453
+ ]
1454
+ });
1455
+ }, {}));
1375
1456
  }
1376
1457
  /**
1377
1458
  * Whether the instance has multiple wallets connected.
@@ -1379,14 +1460,13 @@ var ParaCore = class _ParaCore {
1379
1460
  get isMultiWallet() {
1380
1461
  return this.currentWalletIdsArray.length > 1;
1381
1462
  }
1382
- #supportedWalletTypes;
1383
- #supportedWalletTypesOpt;
1384
1463
  get supportedWalletTypes() {
1385
- return this.#supportedWalletTypes ?? [];
1464
+ var _a;
1465
+ return (_a = __privateGet(this, _supportedWalletTypes)) != null ? _a : [];
1386
1466
  }
1387
1467
  get isWalletTypeEnabled() {
1388
1468
  return this.supportedWalletTypes.reduce((acc, { type }) => {
1389
- return { ...acc, [type]: true };
1469
+ return __spreadProps(__spreadValues({}, acc), { [type]: true });
1390
1470
  }, {});
1391
1471
  }
1392
1472
  convertBigInt(bigInt) {
@@ -1415,12 +1495,14 @@ var ParaCore = class _ParaCore {
1415
1495
  };
1416
1496
  }
1417
1497
  isPortal(envOverride) {
1498
+ var _a;
1418
1499
  if (typeof window === "undefined") return false;
1419
- return !!window.location?.host && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
1500
+ return !!((_a = window.location) == null ? void 0 : _a.host) && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
1420
1501
  }
1421
1502
  isParaConnect() {
1503
+ var _a;
1422
1504
  if (typeof window === "undefined") return false;
1423
- return !!window.location?.host && getParaConnectBaseUrl(this.ctx).includes(window.location.host);
1505
+ return !!((_a = window.location) == null ? void 0 : _a.host) && getParaConnectBaseUrl(this.ctx).includes(window.location.host);
1424
1506
  }
1425
1507
  requireApiKey() {
1426
1508
  if (!this.ctx.apiKey) {
@@ -1431,19 +1513,20 @@ var ParaCore = class _ParaCore {
1431
1513
  }
1432
1514
  }
1433
1515
  isWalletSupported(wallet) {
1434
- return !this.#supportedWalletTypes || isWalletSupported(this.supportedWalletTypes?.map(({ type }) => type) ?? [], wallet);
1516
+ var _a, _b;
1517
+ return !__privateGet(this, _supportedWalletTypes) || isWalletSupported((_b = (_a = this.supportedWalletTypes) == null ? void 0 : _a.map(({ type }) => type)) != null ? _b : [], wallet);
1435
1518
  }
1436
1519
  isWalletOwned(wallet) {
1437
- return this.isWalletSupported(wallet) && !wallet?.pregenIdentifier && !wallet?.pregenIdentifierType && !!this.userId && wallet?.userId === this.userId;
1520
+ return this.isWalletSupported(wallet) && !(wallet == null ? void 0 : wallet.pregenIdentifier) && !(wallet == null ? void 0 : wallet.pregenIdentifierType) && !!this.userId && (wallet == null ? void 0 : wallet.userId) === this.userId;
1438
1521
  }
1439
1522
  isPregenWalletUnclaimed(wallet) {
1440
- return this.isWalletSupported(wallet) && (!wallet?.userId || wallet?.isPregen && !!wallet?.pregenIdentifier && !!wallet?.pregenIdentifierType);
1523
+ return this.isWalletSupported(wallet) && (!(wallet == null ? void 0 : wallet.userId) || (wallet == null ? void 0 : wallet.isPregen) && !!(wallet == null ? void 0 : wallet.pregenIdentifier) && !!(wallet == null ? void 0 : wallet.pregenIdentifierType));
1441
1524
  }
1442
1525
  isPregenWalletClaimable(wallet) {
1443
- return this.isWalletSupported(wallet) && this.isPregenWalletUnclaimed(wallet) && (!["EMAIL", "PHONE", "TELEGRAM"].includes(wallet?.pregenIdentifierType) || isPregenIdentifierMatch(
1444
- wallet?.pregenIdentifierType === "EMAIL" ? this.email : wallet?.pregenIdentifierType === "TELEGRAM" ? this.telegramUserId : this.getPhoneNumber(),
1445
- wallet?.pregenIdentifier,
1446
- wallet?.pregenIdentifierType
1526
+ return this.isWalletSupported(wallet) && this.isPregenWalletUnclaimed(wallet) && (!["EMAIL", "PHONE", "TELEGRAM"].includes(wallet == null ? void 0 : wallet.pregenIdentifierType) || isPregenIdentifierMatch(
1527
+ (wallet == null ? void 0 : wallet.pregenIdentifierType) === "EMAIL" ? this.email : (wallet == null ? void 0 : wallet.pregenIdentifierType) === "TELEGRAM" ? this.telegramUserId : this.getPhoneNumber(),
1528
+ wallet == null ? void 0 : wallet.pregenIdentifier,
1529
+ wallet == null ? void 0 : wallet.pregenIdentifierType
1447
1530
  ));
1448
1531
  }
1449
1532
  isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
@@ -1454,15 +1537,18 @@ var ParaCore = class _ParaCore {
1454
1537
  const wallet = this.wallets[walletId];
1455
1538
  const [isUnclaimed, isOwned] = [this.isPregenWalletUnclaimed(wallet), this.isWalletOwned(wallet)];
1456
1539
  if (forbidPregen && isUnclaimed) {
1457
- error = `pre-generated wallet with id ${wallet?.id} cannot be selected`;
1540
+ error = `pre-generated wallet with id ${wallet == null ? void 0 : wallet.id} cannot be selected`;
1458
1541
  } else if (!isOwned && !isUnclaimed) {
1459
- error = `wallet with id ${wallet?.id} is not owned by the current user`;
1542
+ error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
1460
1543
  } else if (!this.isWalletSupported(wallet)) {
1461
- error = `wallet with id ${wallet?.id} and type ${wallet?.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
1462
- } else if (types && (!getEquivalentTypes(types).includes(wallet?.type) || isOwned && !types.some((type) => this.currentWalletIds?.[type]?.includes(walletId)))) {
1463
- error = `wallet with id ${wallet?.id} and type ${wallet?.type} cannot be selected`;
1464
- } else if (schemes && !schemes.includes(wallet?.scheme)) {
1465
- error = `wallet with id ${wallet?.id} and scheme ${wallet?.scheme} cannot be selected`;
1544
+ error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
1545
+ } else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
1546
+ var _a, _b;
1547
+ return (_b = (_a = this.currentWalletIds) == null ? void 0 : _a[type]) == null ? void 0 : _b.includes(walletId);
1548
+ }))) {
1549
+ error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
1550
+ } else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
1551
+ error = `wallet with id ${wallet == null ? void 0 : wallet.id} and scheme ${wallet == null ? void 0 : wallet.scheme} cannot be selected`;
1466
1552
  }
1467
1553
  }
1468
1554
  if (error) {
@@ -1482,6 +1568,7 @@ var ParaCore = class _ParaCore {
1482
1568
  * @returns the formatted address
1483
1569
  */
1484
1570
  getDisplayAddress(walletId, options = {}) {
1571
+ var _a;
1485
1572
  if (this.externalWallets[walletId]) {
1486
1573
  const wallet2 = this.externalWallets[walletId];
1487
1574
  return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
@@ -1493,7 +1580,7 @@ var ParaCore = class _ParaCore {
1493
1580
  let str;
1494
1581
  switch (wallet.type) {
1495
1582
  case import_user_management_client5.WalletType.COSMOS:
1496
- str = getCosmosAddress(wallet.publicKey, this.cosmosPrefix ?? "cosmos");
1583
+ str = getCosmosAddress(wallet.publicKey, (_a = this.cosmosPrefix) != null ? _a : "cosmos");
1497
1584
  break;
1498
1585
  default:
1499
1586
  str = wallet.address;
@@ -1519,89 +1606,87 @@ var ParaCore = class _ParaCore {
1519
1606
  return this.wallets;
1520
1607
  }
1521
1608
  getAddress(walletId) {
1522
- return walletId ? this.wallets[walletId]?.address : Object.values(this.wallets)?.[0]?.address;
1523
- }
1524
- async constructPortalUrl(type, opts = {}) {
1525
- const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : await this.getPortalURL(opts.partnerId);
1526
- let path;
1527
- switch (type) {
1528
- case "createPassword": {
1529
- path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
1530
- break;
1531
- }
1532
- case "createAuth": {
1533
- path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
1534
- break;
1535
- }
1536
- case "loginPassword": {
1537
- path = "/web/passwords/login";
1538
- break;
1539
- }
1540
- case "loginAuth": {
1541
- path = "/web/biometrics/login";
1542
- break;
1543
- }
1544
- case "txReview": {
1545
- path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
1546
- break;
1547
- }
1548
- case "onRamp": {
1549
- path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
1550
- break;
1551
- }
1552
- default: {
1553
- throw new Error(`invalid URL type ${type}`);
1609
+ var _a, _b, _c;
1610
+ return walletId ? (_a = this.wallets[walletId]) == null ? void 0 : _a.address : (_c = (_b = Object.values(this.wallets)) == null ? void 0 : _b[0]) == null ? void 0 : _c.address;
1611
+ }
1612
+ constructPortalUrl(_0) {
1613
+ return __async(this, arguments, function* (type, opts = {}) {
1614
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1615
+ const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
1616
+ let path;
1617
+ switch (type) {
1618
+ case "createPassword": {
1619
+ path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
1620
+ break;
1621
+ }
1622
+ case "createAuth": {
1623
+ path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
1624
+ break;
1625
+ }
1626
+ case "loginPassword": {
1627
+ path = "/web/passwords/login";
1628
+ break;
1629
+ }
1630
+ case "loginAuth": {
1631
+ path = "/web/biometrics/login";
1632
+ break;
1633
+ }
1634
+ case "txReview": {
1635
+ path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
1636
+ break;
1637
+ }
1638
+ case "onRamp": {
1639
+ path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
1640
+ break;
1641
+ }
1642
+ default: {
1643
+ throw new Error(`invalid URL type ${type}`);
1644
+ }
1554
1645
  }
1555
- }
1556
- const [isCreate, isLogin, isOnRamp] = [
1557
- ["createAuth", "createPassword"].includes(type),
1558
- ["loginAuth", "loginPassword"].includes(type),
1559
- type === "onRamp"
1560
- ];
1561
- const partner = opts.partnerId ? (await this.ctx.client.getPartner(opts.partnerId)).data?.partner : void 0;
1562
- const params = {
1563
- apiKey: this.ctx.apiKey,
1564
- partnerId: opts.partnerId,
1565
- portalFont: opts.theme?.font || partner?.font || this.portalTheme?.font,
1566
- portalBorderRadius: opts.theme?.borderRadius || this.portalTheme?.borderRadius,
1567
- portalThemeMode: opts.theme?.mode || partner?.themeMode || this.portalTheme?.mode,
1568
- portalAccentColor: opts.theme?.accentColor || partner?.accentColor || this.portalTheme?.accentColor,
1569
- portalForegroundColor: opts.theme?.foregroundColor || partner?.foregroundColor || this.portalTheme?.foregroundColor,
1570
- portalBackgroundColor: opts.theme?.backgroundColor || partner?.backgroundColor || this.portalBackgroundColor || this.portalTheme?.backgroundColor,
1571
- portalPrimaryButtonColor: this.portalPrimaryButtonColor,
1572
- portalTextColor: this.portalTextColor,
1573
- portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
1574
- isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
1575
- supportedWalletTypes: this.#supportedWalletTypesOpt ? JSON.stringify(this.#supportedWalletTypesOpt) : void 0,
1576
- ...isCreate || isLogin ? {
1577
- ...opts.authType === "email" ? { email: this.email } : {},
1578
- ...opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {},
1579
- ...opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {},
1580
- ...opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}
1581
- } : {},
1582
- ...isLogin || isOnRamp ? { sessionId: opts.sessionId } : {},
1583
- ...isLogin ? {
1646
+ const [isCreate, isLogin, isOnRamp] = [
1647
+ ["createAuth", "createPassword"].includes(type),
1648
+ ["loginAuth", "loginPassword"].includes(type),
1649
+ type === "onRamp"
1650
+ ];
1651
+ const partner = opts.partnerId ? (_a = (yield this.ctx.client.getPartner(opts.partnerId)).data) == null ? void 0 : _a.partner : void 0;
1652
+ const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
1653
+ apiKey: this.ctx.apiKey,
1654
+ partnerId: opts.partnerId,
1655
+ portalFont: ((_b = opts.theme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
1656
+ portalBorderRadius: ((_d = opts.theme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
1657
+ portalThemeMode: ((_f = opts.theme) == null ? void 0 : _f.mode) || (partner == null ? void 0 : partner.themeMode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode),
1658
+ portalAccentColor: ((_h = opts.theme) == null ? void 0 : _h.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor),
1659
+ portalForegroundColor: ((_j = opts.theme) == null ? void 0 : _j.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor),
1660
+ portalBackgroundColor: ((_l = opts.theme) == null ? void 0 : _l.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor || ((_m = this.portalTheme) == null ? void 0 : _m.backgroundColor),
1661
+ portalPrimaryButtonColor: this.portalPrimaryButtonColor,
1662
+ portalTextColor: this.portalTextColor,
1663
+ portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
1664
+ isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
1665
+ supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
1666
+ }, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
1584
1667
  encryptionKey: opts.loginEncryptionPublicKey,
1585
1668
  newDeviceSessionLookupId: opts.newDeviceSessionId,
1586
1669
  newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
1587
1670
  pregenIds: JSON.stringify(this.pregenIds),
1588
1671
  displayName: opts.displayName,
1589
1672
  pfpUrl: opts.pfpUrl
1590
- } : {},
1591
- ...opts.params || {}
1592
- };
1593
- return constructUrl({ base, path, params });
1673
+ } : {}), opts.params || {});
1674
+ return constructUrl({ base, path, params });
1675
+ });
1594
1676
  }
1595
- async touchSession(regenerate = false) {
1596
- const res = await this.ctx.client.touchSession(regenerate);
1597
- this.setSupportedWalletTypes(res.data.supportedWalletTypes, res.data.cosmosPrefix);
1598
- return res;
1677
+ touchSession(regenerate = false) {
1678
+ return __async(this, null, function* () {
1679
+ const res = yield this.ctx.client.touchSession(regenerate);
1680
+ this.setSupportedWalletTypes(res.data.supportedWalletTypes, res.data.cosmosPrefix);
1681
+ return res;
1682
+ });
1599
1683
  }
1600
1684
  setSupportedWalletTypes(supportedWalletTypes, cosmosPrefix) {
1601
- if (supportedWalletTypes && !this.#supportedWalletTypes) {
1602
- this.#supportedWalletTypes = supportedWalletTypes;
1685
+ if (supportedWalletTypes && !__privateGet(this, _supportedWalletTypes)) {
1686
+ __privateSet(this, _supportedWalletTypes, supportedWalletTypes);
1603
1687
  Object.keys(this.currentWalletIds).forEach((type) => {
1604
- if (!this.#supportedWalletTypes?.some(({ type: supportedType }) => supportedType === type)) {
1688
+ var _a;
1689
+ if (!((_a = __privateGet(this, _supportedWalletTypes)) == null ? void 0 : _a.some(({ type: supportedType }) => supportedType === type))) {
1605
1690
  delete this.currentWalletIds[type];
1606
1691
  }
1607
1692
  });
@@ -1637,155 +1722,168 @@ var ParaCore = class _ParaCore {
1637
1722
  *
1638
1723
  * Init only needs to be called for storage that is async.
1639
1724
  */
1640
- async init() {
1641
- this.email = await this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || void 0;
1642
- this.countryCode = await this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || void 0;
1643
- this.phone = await this.localStorageGetItem(LOCAL_STORAGE_PHONE) || void 0;
1644
- this.userId = await this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || void 0;
1645
- this.telegramUserId = await this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID) || void 0;
1646
- const stringWallets = this.platformUtils.secureStorage ? await this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS) : await this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
1647
- const _wallets = JSON.parse(stringWallets || "{}");
1648
- const stringEd25519Wallets = this.platformUtils.secureStorage ? await this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS) : await this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
1649
- const _ed25519Wallets = JSON.parse(stringEd25519Wallets || "{}");
1650
- const wallets = {
1651
- ...Object.keys(_wallets).reduce((res, key) => {
1652
- return {
1653
- ...res,
1725
+ init() {
1726
+ return __async(this, null, function* () {
1727
+ var _a;
1728
+ this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || void 0;
1729
+ this.countryCode = (yield this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE)) || void 0;
1730
+ this.phone = (yield this.localStorageGetItem(LOCAL_STORAGE_PHONE)) || void 0;
1731
+ this.userId = (yield this.localStorageGetItem(LOCAL_STORAGE_USER_ID)) || void 0;
1732
+ this.telegramUserId = (yield this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID)) || void 0;
1733
+ const stringWallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS) : yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
1734
+ const _wallets = JSON.parse(stringWallets || "{}");
1735
+ const stringEd25519Wallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS) : yield this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
1736
+ const _ed25519Wallets = JSON.parse(stringEd25519Wallets || "{}");
1737
+ const wallets = __spreadValues(__spreadValues({}, Object.keys(_wallets).reduce((res, key) => {
1738
+ return __spreadProps(__spreadValues({}, res), {
1654
1739
  [key]: migrateWallet(_wallets[key])
1655
- };
1656
- }, {}),
1657
- ...Object.keys(_ed25519Wallets).reduce((res, key) => {
1658
- return {
1659
- ...res,
1660
- ...!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}
1661
- };
1662
- }, {})
1663
- };
1664
- await this.setWallets(wallets);
1665
- const _currentWalletIds = await this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS) ?? void 0;
1666
- const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
1667
- const fromJson = JSON.parse(_currentWalletIds);
1668
- return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1669
- const wallet = Object.values(this.wallets).find(
1670
- (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1671
- );
1672
- return {
1673
- ...acc,
1674
- ...wallet && !acc[type] ? { [type]: [wallet.id] } : {}
1675
- };
1676
- }, {}) : fromJson;
1677
- })();
1678
- await this.setCurrentWalletIds(currentWalletIds);
1679
- this.sessionCookie = await this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) || await this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) || void 0;
1680
- if (Object.values(this.wallets).filter((w) => this.isWalletOwned(w)).length > 0 && this.currentWalletIdsArray.length === 0) {
1681
- this.findWalletId(void 0, { forbidPregen: true });
1682
- }
1683
- const loginEncryptionKey = await this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1684
- if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
1685
- this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
1686
- }
1687
- const stringExternalWallets = await this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
1688
- const _externalWallets = JSON.parse(stringExternalWallets || "{}");
1689
- await this.setExternalWallets(_externalWallets);
1690
- setupListeners.bind(this)();
1691
- await this.touchSession();
1740
+ });
1741
+ }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
1742
+ return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {});
1743
+ }, {}));
1744
+ yield this.setWallets(wallets);
1745
+ const _currentWalletIds = (_a = yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1746
+ const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
1747
+ const fromJson = JSON.parse(_currentWalletIds);
1748
+ return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1749
+ const wallet = Object.values(this.wallets).find(
1750
+ (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1751
+ );
1752
+ return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1753
+ }, {}) : fromJson;
1754
+ })();
1755
+ yield this.setCurrentWalletIds(currentWalletIds);
1756
+ this.sessionCookie = (yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) || (yield this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) || void 0;
1757
+ if (Object.values(this.wallets).filter((w) => this.isWalletOwned(w)).length > 0 && this.currentWalletIdsArray.length === 0) {
1758
+ this.findWalletId(void 0, { forbidPregen: true });
1759
+ }
1760
+ const loginEncryptionKey = yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1761
+ if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
1762
+ this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
1763
+ }
1764
+ const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
1765
+ const _externalWallets = JSON.parse(stringExternalWallets || "{}");
1766
+ yield this.setExternalWallets(_externalWallets);
1767
+ setupListeners.bind(this)();
1768
+ yield this.touchSession();
1769
+ });
1692
1770
  }
1693
1771
  /**
1694
1772
  * Sets the email associated with the `ParaCore` instance.
1695
1773
  * @param email - Email to set.
1696
1774
  */
1697
- async setEmail(email) {
1698
- this.email = email;
1699
- await this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
1775
+ setEmail(email) {
1776
+ return __async(this, null, function* () {
1777
+ this.email = email;
1778
+ yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
1779
+ });
1700
1780
  }
1701
1781
  /**
1702
1782
  * Sets the Telegram user ID associated with the `ParaCore` instance.
1703
1783
  * @param telegramUserId - Telegram user ID to set.
1704
1784
  */
1705
- async setTelegramUserId(telegramUserId) {
1706
- this.telegramUserId = telegramUserId;
1707
- await this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
1785
+ setTelegramUserId(telegramUserId) {
1786
+ return __async(this, null, function* () {
1787
+ this.telegramUserId = telegramUserId;
1788
+ yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
1789
+ });
1708
1790
  }
1709
1791
  /**
1710
1792
  * Sets the phone number associated with the `ParaCore` instance.
1711
1793
  * @param phone - Phone number to set.
1712
1794
  * @param countryCode - Country Code to set.
1713
1795
  */
1714
- async setPhoneNumber(phone, countryCode) {
1715
- this.phone = phone;
1716
- this.countryCode = countryCode;
1717
- await this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
1718
- await this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
1796
+ setPhoneNumber(phone, countryCode) {
1797
+ return __async(this, null, function* () {
1798
+ this.phone = phone;
1799
+ this.countryCode = countryCode;
1800
+ yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
1801
+ yield this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
1802
+ });
1719
1803
  }
1720
1804
  /**
1721
1805
  * Sets the farcaster username associated with the `ParaCore` instance.
1722
1806
  * @param farcasterUsername - Farcaster Username to set.
1723
1807
  */
1724
- async setFarcasterUsername(farcasterUsername) {
1725
- this.farcasterUsername = farcasterUsername;
1726
- await this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
1808
+ setFarcasterUsername(farcasterUsername) {
1809
+ return __async(this, null, function* () {
1810
+ this.farcasterUsername = farcasterUsername;
1811
+ yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
1812
+ });
1727
1813
  }
1728
1814
  /**
1729
1815
  * Sets the external wallet address and type associated with the `ParaCore` instance.
1730
1816
  * @param externalAddress - External wallet address to set.
1731
1817
  * @param externalType - Type of external wallet to set.
1732
1818
  */
1733
- async setExternalWallet({ address, type, provider, addressBech32 }) {
1734
- this.externalWallets = {
1735
- [address]: {
1736
- id: address,
1737
- address: addressBech32 ?? address,
1738
- type,
1739
- name: provider,
1740
- isExternal: true,
1741
- signer: ""
1742
- }
1743
- };
1744
- this.setExternalWallets(this.externalWallets);
1745
- dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
1819
+ setExternalWallet(_0) {
1820
+ return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
1821
+ this.externalWallets = {
1822
+ [address]: {
1823
+ id: address,
1824
+ address: addressBech32 != null ? addressBech32 : address,
1825
+ type,
1826
+ name: provider,
1827
+ isExternal: true,
1828
+ signer: ""
1829
+ }
1830
+ };
1831
+ this.setExternalWallets(this.externalWallets);
1832
+ dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
1833
+ });
1746
1834
  }
1747
1835
  /**
1748
1836
  * Sets the user id associated with the `ParaCore` instance.
1749
1837
  * @param userId - User id to set.
1750
1838
  */
1751
- async setUserId(userId) {
1752
- this.userId = userId;
1753
- await this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
1839
+ setUserId(userId) {
1840
+ return __async(this, null, function* () {
1841
+ this.userId = userId;
1842
+ yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
1843
+ });
1754
1844
  }
1755
1845
  /**
1756
1846
  * Sets the wallets associated with the `ParaCore` instance.
1757
1847
  * @param wallets - Wallets to set.
1758
1848
  */
1759
- async setWallets(wallets) {
1760
- this.wallets = wallets;
1761
- if (this.platformUtils.secureStorage) {
1762
- await this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1763
- return;
1764
- }
1765
- await this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1849
+ setWallets(wallets) {
1850
+ return __async(this, null, function* () {
1851
+ this.wallets = wallets;
1852
+ if (this.platformUtils.secureStorage) {
1853
+ yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1854
+ return;
1855
+ }
1856
+ yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1857
+ });
1766
1858
  }
1767
1859
  /**
1768
1860
  * Sets the external wallets associated with the `ParaCore` instance.
1769
1861
  * @param externalWallets - External wallets to set.
1770
1862
  */
1771
- async setExternalWallets(externalWallets) {
1772
- this.externalWallets = externalWallets;
1773
- await this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
1863
+ setExternalWallets(externalWallets) {
1864
+ return __async(this, null, function* () {
1865
+ this.externalWallets = externalWallets;
1866
+ yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
1867
+ });
1774
1868
  }
1775
1869
  /**
1776
1870
  * Sets the login encryption key pair associated with the `ParaCore` instance.
1777
1871
  * @param keyPair - Encryption key pair generated from loginEncryptionKey.
1778
1872
  */
1779
- async setLoginEncryptionKeyPair(keyPair) {
1780
- if (!keyPair) {
1781
- keyPair = await getAsymmetricKeyPair(this.ctx);
1782
- }
1783
- this.loginEncryptionKeyPair = keyPair;
1784
- await this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
1873
+ setLoginEncryptionKeyPair(keyPair) {
1874
+ return __async(this, null, function* () {
1875
+ if (!keyPair) {
1876
+ keyPair = yield getAsymmetricKeyPair(this.ctx);
1877
+ }
1878
+ this.loginEncryptionKeyPair = keyPair;
1879
+ yield this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
1880
+ });
1785
1881
  }
1786
- async deleteLoginEncryptionKeyPair() {
1787
- this.loginEncryptionKeyPair = void 0;
1788
- await this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1882
+ deleteLoginEncryptionKeyPair() {
1883
+ return __async(this, null, function* () {
1884
+ this.loginEncryptionKeyPair = void 0;
1885
+ yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1886
+ });
1789
1887
  }
1790
1888
  /**
1791
1889
  * Gets the userId associated with the `ParaCore` instance.
@@ -1825,23 +1923,42 @@ var ParaCore = class _ParaCore {
1825
1923
  getFarcasterUsername() {
1826
1924
  return this.farcasterUsername;
1827
1925
  }
1828
- async setCurrentWalletIds(currentWalletIds, {
1829
- needsWallet = false,
1830
- sessionLookupId,
1831
- newDeviceSessionLookupId
1832
- } = {}) {
1833
- this.currentWalletIds = currentWalletIds;
1834
- await this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
1835
- if (sessionLookupId) {
1836
- await this.ctx.client.setCurrentWalletIds(
1837
- this.getUserId(),
1838
- this.currentWalletIds,
1839
- needsWallet,
1840
- sessionLookupId,
1841
- newDeviceSessionLookupId
1842
- );
1843
- }
1844
- dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
1926
+ setCurrentWalletIds(_0) {
1927
+ return __async(this, arguments, function* (currentWalletIds, {
1928
+ needsWallet = false,
1929
+ sessionLookupId,
1930
+ newDeviceSessionLookupId
1931
+ } = {}) {
1932
+ this.currentWalletIds = currentWalletIds;
1933
+ yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
1934
+ if (sessionLookupId) {
1935
+ yield this.ctx.client.setCurrentWalletIds(
1936
+ this.getUserId(),
1937
+ this.currentWalletIds,
1938
+ needsWallet,
1939
+ sessionLookupId,
1940
+ newDeviceSessionLookupId
1941
+ );
1942
+ }
1943
+ dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
1944
+ });
1945
+ }
1946
+ /**
1947
+ * Fetches the most recent OAuth account metadata for the signed-in user.
1948
+ * If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
1949
+ * @returns {Promise<AccountMetadata>} the user's account metadata.
1950
+ */
1951
+ getAccountMetadata() {
1952
+ return __async(this, null, function* () {
1953
+ if (!(yield this.isSessionActive()) || !this.userId) {
1954
+ throw new Error("no signed-in user");
1955
+ }
1956
+ const {
1957
+ data: { partnerId }
1958
+ } = yield this.touchSession();
1959
+ const { accountMetadata } = yield this.ctx.client.getAccountMetadata(this.userId, partnerId);
1960
+ return accountMetadata;
1961
+ });
1845
1962
  }
1846
1963
  /**
1847
1964
  * Validates that a wallet ID is present on the instance, usable, and matches the desired filters.
@@ -1895,6 +2012,7 @@ var ParaCore = class _ParaCore {
1895
2012
  return wallet;
1896
2013
  }
1897
2014
  findWallet(idOrAddress, overrideType, filter = {}) {
2015
+ var _b, _c;
1898
2016
  if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
1899
2017
  return Object.values(this.externalWallets)[0];
1900
2018
  }
@@ -1904,18 +2022,18 @@ var ParaCore = class _ParaCore {
1904
2022
  try {
1905
2023
  const walletId = this.findWalletId(idOrAddress, filter);
1906
2024
  if (walletId && !!this.wallets[walletId]) {
1907
- const { signer: _signer, ...wallet } = this.wallets[walletId];
1908
- const type = overrideType ?? this.currentWalletIdsArray.find(([id]) => id === walletId)?.[1] ?? wallet.type;
1909
- return {
1910
- ...wallet,
2025
+ const _a = this.wallets[walletId], { signer: _signer } = _a, wallet = __objRest(_a, ["signer"]);
2026
+ const type = (_c = overrideType != null ? overrideType : (_b = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _b[1]) != null ? _c : wallet.type;
2027
+ return __spreadProps(__spreadValues({}, wallet), {
1911
2028
  type: import_user_management_client5.WalletType[type]
1912
- };
2029
+ });
1913
2030
  }
1914
2031
  } catch (e) {
1915
2032
  return void 0;
1916
2033
  }
1917
2034
  }
1918
2035
  get availableWallets() {
2036
+ var _a;
1919
2037
  return [
1920
2038
  ...this.currentWalletIdsArray.map(([address, type]) => [address, type, false]).map(([id, type]) => {
1921
2039
  const wallet = this.findWallet(id, type);
@@ -1927,7 +2045,7 @@ var ParaCore = class _ParaCore {
1927
2045
  name: wallet.name
1928
2046
  };
1929
2047
  }).filter((obj) => obj !== null),
1930
- ...Object.values(this.externalWallets ?? {})
2048
+ ...Object.values((_a = this.externalWallets) != null ? _a : {})
1931
2049
  ];
1932
2050
  }
1933
2051
  /**
@@ -1941,61 +2059,78 @@ var ParaCore = class _ParaCore {
1941
2059
  assertIsValidWalletId(walletId, condition = {}) {
1942
2060
  this.isWalletUsable(walletId, condition, true);
1943
2061
  }
1944
- async assertIsValidWalletType(type, walletTypes) {
1945
- if (!this.#supportedWalletTypes) {
1946
- await this.touchSession();
1947
- }
1948
- if (!type || !Object.values(import_user_management_client5.WalletType).includes(type) || !(walletTypes ?? this.supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
1949
- throw new Error(`wallet type ${type} is not supported`);
1950
- }
1951
- return type;
2062
+ assertIsValidWalletType(type, walletTypes) {
2063
+ return __async(this, null, function* () {
2064
+ if (!__privateGet(this, _supportedWalletTypes)) {
2065
+ yield this.touchSession();
2066
+ }
2067
+ if (!type || !Object.values(import_user_management_client5.WalletType).includes(type) || !(walletTypes != null ? walletTypes : this.supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
2068
+ throw new Error(`wallet type ${type} is not supported`);
2069
+ }
2070
+ return type;
2071
+ });
1952
2072
  }
1953
- async getMissingTypes() {
1954
- if (!this.#supportedWalletTypes) {
1955
- await this.touchSession();
1956
- }
1957
- return this.supportedWalletTypes.filter(
1958
- ({ type: t, optional }) => !optional && Object.values(this.wallets).every((w) => !this.isWalletOwned(w) || !WalletSchemeTypeMap[w.scheme][t])
1959
- ).map(({ type }) => type);
2073
+ getMissingTypes() {
2074
+ return __async(this, null, function* () {
2075
+ if (!__privateGet(this, _supportedWalletTypes)) {
2076
+ yield this.touchSession();
2077
+ }
2078
+ return this.supportedWalletTypes.filter(
2079
+ ({ type: t, optional }) => !optional && Object.values(this.wallets).every((w) => !this.isWalletOwned(w) || !WalletSchemeTypeMap[w.scheme][t])
2080
+ ).map(({ type }) => type);
2081
+ });
1960
2082
  }
1961
- async getTypesToCreate(types) {
1962
- if (!this.#supportedWalletTypes) {
1963
- await this.touchSession();
1964
- }
1965
- return getSchemes(types ?? await this.getMissingTypes()).map((scheme) => {
1966
- switch (scheme) {
1967
- case import_user_management_client5.WalletScheme.ED25519:
1968
- return import_user_management_client5.WalletType.SOLANA;
1969
- default:
1970
- return this.supportedWalletTypes.some(({ type, optional }) => type === import_user_management_client5.WalletType.COSMOS && !optional) ? import_user_management_client5.WalletType.COSMOS : import_user_management_client5.WalletType.EVM;
2083
+ getTypesToCreate(types) {
2084
+ return __async(this, null, function* () {
2085
+ if (!__privateGet(this, _supportedWalletTypes)) {
2086
+ yield this.touchSession();
1971
2087
  }
2088
+ return getSchemes(types != null ? types : yield this.getMissingTypes()).map((scheme) => {
2089
+ switch (scheme) {
2090
+ case import_user_management_client5.WalletScheme.ED25519:
2091
+ return import_user_management_client5.WalletType.SOLANA;
2092
+ default:
2093
+ return this.supportedWalletTypes.some(({ type, optional }) => type === import_user_management_client5.WalletType.COSMOS && !optional) ? import_user_management_client5.WalletType.COSMOS : import_user_management_client5.WalletType.EVM;
2094
+ }
2095
+ });
1972
2096
  });
1973
2097
  }
1974
- async getPartnerURL(partnerId) {
1975
- const res = await this.ctx.client.getPartner(partnerId);
1976
- return res.data.partner.portalUrl;
2098
+ getPartnerURL(partnerId) {
2099
+ return __async(this, null, function* () {
2100
+ const res = yield this.ctx.client.getPartner(partnerId);
2101
+ return res.data.partner.portalUrl;
2102
+ });
1977
2103
  }
1978
2104
  /**
1979
2105
  * URL of the portal, which can be associated with a partner id
1980
2106
  * @param partnerId: string - id of the partner to get the portal URL for
1981
2107
  * @returns - portal URL
1982
2108
  */
1983
- async getPortalURL(partnerId) {
1984
- return partnerId && await this.getPartnerURL(partnerId) || getPortalBaseURL(this.ctx);
2109
+ getPortalURL(partnerId) {
2110
+ return __async(this, null, function* () {
2111
+ return partnerId && (yield this.getPartnerURL(partnerId)) || getPortalBaseURL(this.ctx);
2112
+ });
1985
2113
  }
1986
- async getWebAuthURLForCreate({
1987
- webAuthId,
1988
- ...options
1989
- }) {
1990
- return this.constructPortalUrl("createAuth", { ...options, pathId: webAuthId });
2114
+ getWebAuthURLForCreate(_a) {
2115
+ return __async(this, null, function* () {
2116
+ var _b = _a, {
2117
+ webAuthId
2118
+ } = _b, options = __objRest(_b, [
2119
+ "webAuthId"
2120
+ ]);
2121
+ return this.constructPortalUrl("createAuth", __spreadProps(__spreadValues({}, options), { pathId: webAuthId }));
2122
+ });
1991
2123
  }
1992
- async getPasswordURLForCreate({
1993
- passwordId,
1994
- ...options
1995
- }) {
1996
- return this.constructPortalUrl("createPassword", {
1997
- ...options,
1998
- pathId: passwordId
2124
+ getPasswordURLForCreate(_c) {
2125
+ return __async(this, null, function* () {
2126
+ var _d = _c, {
2127
+ passwordId
2128
+ } = _d, options = __objRest(_d, [
2129
+ "passwordId"
2130
+ ]);
2131
+ return this.constructPortalUrl("createPassword", __spreadProps(__spreadValues({}, options), {
2132
+ pathId: passwordId
2133
+ }));
1999
2134
  });
2000
2135
  }
2001
2136
  getShortUrl(compressedUrl) {
@@ -2004,35 +2139,42 @@ var ParaCore = class _ParaCore {
2004
2139
  path: `/short/${compressedUrl}`
2005
2140
  });
2006
2141
  }
2007
- async shortenLoginLink(link) {
2008
- const url = await upload(link, this.ctx.client);
2009
- return this.getShortUrl(url);
2142
+ shortenLoginLink(link) {
2143
+ return __async(this, null, function* () {
2144
+ const url = yield upload(link, this.ctx.client);
2145
+ return this.getShortUrl(url);
2146
+ });
2010
2147
  }
2011
2148
  /**
2012
2149
  * Generates a URL for registering a new WebAuth passkey.
2013
2150
  * @param {GetWebAuthUrlForLoginParams} opts the options object
2014
2151
  * @returns - the URL for creating a new passkey
2015
2152
  */
2016
- async getWebAuthURLForLogin(opts) {
2017
- return this.constructPortalUrl("loginAuth", opts);
2153
+ getWebAuthURLForLogin(opts) {
2154
+ return __async(this, null, function* () {
2155
+ return this.constructPortalUrl("loginAuth", opts);
2156
+ });
2018
2157
  }
2019
2158
  /**
2020
2159
  * Generates a URL for registering a new user password.
2021
2160
  * @param {GetWebAuthUrlForLoginParams} opts the options object
2022
2161
  * @returns - the URL for creating a new password
2023
2162
  */
2024
- async getPasswordURLForLogin(opts) {
2025
- return this.constructPortalUrl("loginPassword", opts);
2163
+ getPasswordURLForLogin(opts) {
2164
+ return __async(this, null, function* () {
2165
+ return this.constructPortalUrl("loginPassword", opts);
2166
+ });
2026
2167
  }
2027
2168
  /**
2028
2169
  * Generates a URL for registering a new WebAuth passkey for a phone number.
2029
2170
  * @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
2030
2171
  * @returns - web auth url
2031
2172
  */
2032
- async getWebAuthURLForLoginForPhone(opts) {
2033
- return this.constructPortalUrl("loginAuth", {
2034
- authType: "phone",
2035
- ...opts
2173
+ getWebAuthURLForLoginForPhone(opts) {
2174
+ return __async(this, null, function* () {
2175
+ return this.constructPortalUrl("loginAuth", __spreadValues({
2176
+ authType: "phone"
2177
+ }, opts));
2036
2178
  });
2037
2179
  }
2038
2180
  /**
@@ -2040,57 +2182,59 @@ var ParaCore = class _ParaCore {
2040
2182
  * @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
2041
2183
  * @returns - the private key string.
2042
2184
  */
2043
- async getPrivateKey(walletId) {
2044
- const wallets = Object.values(this.wallets);
2045
- const wallet = walletId ? this.wallets[walletId] : wallets?.[0];
2046
- if (!wallet) {
2047
- throw new Error("wallet not found");
2048
- }
2049
- if (wallet.scheme !== import_user_management_client5.WalletScheme.DKLS) {
2050
- throw new Error("invalid wallet scheme");
2051
- }
2052
- return await this.platformUtils.getPrivateKey(
2053
- this.ctx,
2054
- this.userId,
2055
- wallet.id,
2056
- wallet.signer,
2057
- this.retrieveSessionCookie()
2058
- );
2185
+ getPrivateKey(walletId) {
2186
+ return __async(this, null, function* () {
2187
+ const wallets = Object.values(this.wallets);
2188
+ const wallet = walletId ? this.wallets[walletId] : wallets == null ? void 0 : wallets[0];
2189
+ if (!wallet) {
2190
+ throw new Error("wallet not found");
2191
+ }
2192
+ if (wallet.scheme !== import_user_management_client5.WalletScheme.DKLS) {
2193
+ throw new Error("invalid wallet scheme");
2194
+ }
2195
+ return yield this.platformUtils.getPrivateKey(
2196
+ this.ctx,
2197
+ this.userId,
2198
+ wallet.id,
2199
+ wallet.signer,
2200
+ this.retrieveSessionCookie()
2201
+ );
2202
+ });
2059
2203
  }
2060
2204
  /**
2061
2205
  * Fetches the wallets associated with the user.
2062
2206
  * @returns {WalletEntity[]} wallets that were fetched.
2063
2207
  */
2064
- async fetchWallets() {
2065
- const res = await (this.isPortal() || this.isParaConnect() ? this.ctx.client.getAllWallets(this.userId) : this.ctx.client.getWallets(this.userId, true));
2066
- return res.data.wallets.filter(
2067
- (wallet) => !!wallet.address && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))
2068
- );
2208
+ fetchWallets() {
2209
+ return __async(this, null, function* () {
2210
+ const res = yield this.isPortal() || this.isParaConnect() ? this.ctx.client.getAllWallets(this.userId) : this.ctx.client.getWallets(this.userId, true);
2211
+ return res.data.wallets.filter(
2212
+ (wallet) => !!wallet.address && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))
2213
+ );
2214
+ });
2069
2215
  }
2070
- async populateWalletAddresses() {
2071
- const res = await this.ctx.client.getWallets(this.userId, true);
2072
- const wallets = res.data.wallets;
2073
- wallets.forEach((entity) => {
2074
- if (this.wallets[entity.id]) {
2075
- this.wallets[entity.id] = {
2076
- ...entityToWallet(entity),
2077
- ...this.wallets[entity.id]
2078
- };
2079
- }
2216
+ populateWalletAddresses() {
2217
+ return __async(this, null, function* () {
2218
+ const res = yield this.ctx.client.getWallets(this.userId, true);
2219
+ const wallets = res.data.wallets;
2220
+ wallets.forEach((entity) => {
2221
+ if (this.wallets[entity.id]) {
2222
+ this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
2223
+ }
2224
+ });
2225
+ yield this.setWallets(this.wallets);
2080
2226
  });
2081
- await this.setWallets(this.wallets);
2082
2227
  }
2083
- async populatePregenWalletAddresses() {
2084
- const res = await this.getPregenWallets();
2085
- res.forEach((entity) => {
2086
- if (this.wallets[entity.id]) {
2087
- this.wallets[entity.id] = {
2088
- ...entityToWallet(entity),
2089
- ...this.wallets[entity.id]
2090
- };
2091
- }
2228
+ populatePregenWalletAddresses() {
2229
+ return __async(this, null, function* () {
2230
+ const res = yield this.getPregenWallets();
2231
+ res.forEach((entity) => {
2232
+ if (this.wallets[entity.id]) {
2233
+ this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
2234
+ }
2235
+ });
2236
+ yield this.setWallets(this.wallets);
2092
2237
  });
2093
- await this.setWallets(this.wallets);
2094
2238
  }
2095
2239
  /**
2096
2240
  * Checks if a user exists for an email address.
@@ -2098,9 +2242,11 @@ var ParaCore = class _ParaCore {
2098
2242
  * @param {string} opts.email the email to check.
2099
2243
  * @returns true if user exists, false otherwise.
2100
2244
  */
2101
- async checkIfUserExists({ email }) {
2102
- const res = await this.ctx.client.checkUserExists({ email });
2103
- return res.data.exists;
2245
+ checkIfUserExists(_0) {
2246
+ return __async(this, arguments, function* ({ email }) {
2247
+ const res = yield this.ctx.client.checkUserExists({ email });
2248
+ return res.data.exists;
2249
+ });
2104
2250
  }
2105
2251
  /**
2106
2252
  * Checks if a user exists for a phone number.
@@ -2109,23 +2255,26 @@ var ParaCore = class _ParaCore {
2109
2255
  * @param {string} opts.countryCode - the country code.
2110
2256
  * @returns true if user exists, false otherwise.
2111
2257
  */
2112
- async checkIfUserExistsByPhone({ phone, countryCode }) {
2113
- const res = await this.ctx.client.checkUserExists({ phone, countryCode });
2114
- return res.data.exists;
2258
+ checkIfUserExistsByPhone(_0) {
2259
+ return __async(this, arguments, function* ({ phone, countryCode }) {
2260
+ const res = yield this.ctx.client.checkUserExists({ phone, countryCode });
2261
+ return res.data.exists;
2262
+ });
2115
2263
  }
2116
2264
  /**
2117
2265
  * Creates a new user.
2118
2266
  * @param {Object} opts the options object
2119
2267
  * @param {string} opts.email the email to use.
2120
2268
  */
2121
- async createUser({ email }) {
2122
- this.requireApiKey();
2123
- await this.setEmail(email);
2124
- const { userId } = await this.ctx.client.createUser({
2125
- email: this.email,
2126
- ...this.getVerificationEmailProps()
2269
+ createUser(_0) {
2270
+ return __async(this, arguments, function* ({ email }) {
2271
+ this.requireApiKey();
2272
+ yield this.setEmail(email);
2273
+ const { userId } = yield this.ctx.client.createUser(__spreadValues({
2274
+ email: this.email
2275
+ }, this.getVerificationEmailProps()));
2276
+ yield this.setUserId(userId);
2127
2277
  });
2128
- await this.setUserId(userId);
2129
2278
  }
2130
2279
  /**
2131
2280
  * Creates a new user with a phone number.
@@ -2133,14 +2282,16 @@ var ParaCore = class _ParaCore {
2133
2282
  * @param {string} opts.phone - the phone number to use for creating the user.
2134
2283
  * @param {string} opts.countryCode - the country code to use for creating the user.
2135
2284
  */
2136
- async createUserByPhone({ phone, countryCode }) {
2137
- this.requireApiKey();
2138
- await this.setPhoneNumber(phone, countryCode);
2139
- const { userId } = await this.ctx.client.createUser({
2140
- phone: this.phone,
2141
- countryCode: this.countryCode
2285
+ createUserByPhone(_0) {
2286
+ return __async(this, arguments, function* ({ phone, countryCode }) {
2287
+ this.requireApiKey();
2288
+ yield this.setPhoneNumber(phone, countryCode);
2289
+ const { userId } = yield this.ctx.client.createUser({
2290
+ phone: this.phone,
2291
+ countryCode: this.countryCode
2292
+ });
2293
+ yield this.setUserId(userId);
2142
2294
  });
2143
- await this.setUserId(userId);
2144
2295
  }
2145
2296
  /**
2146
2297
  * Logs in or creates a new user using an external wallet address.
@@ -2149,17 +2300,19 @@ var ParaCore = class _ParaCore {
2149
2300
  * @param {WalletType} opts.type type of external wallet to use for identification.
2150
2301
  * @param {string} opts.provider the name of the provider for the external wallet.
2151
2302
  */
2152
- async externalWalletLogin(wallet) {
2153
- this.requireApiKey();
2154
- const res = await this.ctx.client.externalWalletLogin({
2155
- externalAddress: wallet.address,
2156
- type: wallet.type,
2157
- externalWalletProvider: wallet.provider,
2158
- shouldTrackUser: wallet.shouldTrackUser
2159
- });
2160
- await this.setExternalWallet(wallet);
2161
- await this.setUserId(res.userId);
2162
- return res;
2303
+ externalWalletLogin(wallet) {
2304
+ return __async(this, null, function* () {
2305
+ this.requireApiKey();
2306
+ const res = yield this.ctx.client.externalWalletLogin({
2307
+ externalAddress: wallet.address,
2308
+ type: wallet.type,
2309
+ externalWalletProvider: wallet.provider,
2310
+ shouldTrackUser: wallet.shouldTrackUser
2311
+ });
2312
+ yield this.setExternalWallet(wallet);
2313
+ yield this.setUserId(res.userId);
2314
+ return res;
2315
+ });
2163
2316
  }
2164
2317
  /**
2165
2318
  * Returns whether or not the user is connected with an external wallet.
@@ -2173,18 +2326,22 @@ var ParaCore = class _ParaCore {
2173
2326
  * @param {string} verificationCode the six-digit code to check
2174
2327
  * @returns {string} the web auth url for creating a new credential
2175
2328
  */
2176
- async verifyEmail({ verificationCode }) {
2177
- await this.ctx.client.verifyEmail(this.userId, { verificationCode });
2178
- return this.getSetUpBiometricsURL();
2179
- }
2180
- async verifyExternalWallet({
2181
- address,
2182
- signedMessage,
2183
- cosmosPublicKeyHex,
2184
- cosmosSigner
2185
- }) {
2186
- await this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
2187
- return this.getSetUpBiometricsURL();
2329
+ verifyEmail(_0) {
2330
+ return __async(this, arguments, function* ({ verificationCode }) {
2331
+ yield this.ctx.client.verifyEmail(this.userId, { verificationCode });
2332
+ return this.getSetUpBiometricsURL();
2333
+ });
2334
+ }
2335
+ verifyExternalWallet(_0) {
2336
+ return __async(this, arguments, function* ({
2337
+ address,
2338
+ signedMessage,
2339
+ cosmosPublicKeyHex,
2340
+ cosmosSigner
2341
+ }) {
2342
+ yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
2343
+ return this.getSetUpBiometricsURL();
2344
+ });
2188
2345
  }
2189
2346
  /**
2190
2347
  * Passes the phone code obtained from the user for verification.
@@ -2192,9 +2349,11 @@ var ParaCore = class _ParaCore {
2192
2349
  * @param {string} verificationCode the six-digit code to check
2193
2350
  * @returns {string} the web auth url for creating a new credential
2194
2351
  */
2195
- async verifyPhone({ verificationCode }) {
2196
- await this.ctx.client.verifyPhone(this.userId, { verificationCode });
2197
- return this.getSetUpBiometricsURLForPhone();
2352
+ verifyPhone(_0) {
2353
+ return __async(this, arguments, function* ({ verificationCode }) {
2354
+ yield this.ctx.client.verifyPhone(this.userId, { verificationCode });
2355
+ return this.getSetUpBiometricsURLForPhone();
2356
+ });
2198
2357
  }
2199
2358
  /**
2200
2359
  * Validates the response received from an attempted Telegram login for authenticity, then
@@ -2202,17 +2361,19 @@ var ParaCore = class _ParaCore {
2202
2361
  * @param authResponse - the response JSON object received from the Telegram widget.
2203
2362
  * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
2204
2363
  */
2205
- async verifyTelegram(authObject) {
2206
- const res = await this.ctx.client.verifyTelegram(authObject);
2207
- if (res.isValid) {
2208
- await this.setUserId(res.userId);
2209
- await this.setTelegramUserId(res.telegramUserId);
2210
- await this.touchSession(true);
2211
- if (!this.loginEncryptionKeyPair) {
2212
- await this.setLoginEncryptionKeyPair();
2364
+ verifyTelegram(authObject) {
2365
+ return __async(this, null, function* () {
2366
+ const res = yield this.ctx.client.verifyTelegram(authObject);
2367
+ if (res.isValid) {
2368
+ yield this.setUserId(res.userId);
2369
+ yield this.setTelegramUserId(res.telegramUserId);
2370
+ yield this.touchSession(true);
2371
+ if (!this.loginEncryptionKeyPair) {
2372
+ yield this.setLoginEncryptionKeyPair();
2373
+ }
2213
2374
  }
2214
- }
2215
- return res;
2375
+ return res;
2376
+ });
2216
2377
  }
2217
2378
  /**
2218
2379
  * Performs 2FA verification.
@@ -2221,14 +2382,16 @@ var ParaCore = class _ParaCore {
2221
2382
  * @param {string} opts.verificationCode the verification code to received via 2FA.
2222
2383
  * @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
2223
2384
  */
2224
- async verify2FA({ email, verificationCode }) {
2225
- const res = await this.ctx.client.verify2FA(email, verificationCode);
2226
- return {
2227
- initiatedAt: res.data.initiatedAt,
2228
- status: res.data.status,
2229
- userId: res.data.userId,
2230
- wallets: res.data.wallets
2231
- };
2385
+ verify2FA(_0) {
2386
+ return __async(this, arguments, function* ({ email, verificationCode }) {
2387
+ const res = yield this.ctx.client.verify2FA(email, verificationCode);
2388
+ return {
2389
+ initiatedAt: res.data.initiatedAt,
2390
+ status: res.data.status,
2391
+ userId: res.data.userId,
2392
+ wallets: res.data.wallets
2393
+ };
2394
+ });
2232
2395
  }
2233
2396
  /**
2234
2397
  * Performs 2FA verification.
@@ -2238,65 +2401,76 @@ var ParaCore = class _ParaCore {
2238
2401
  * @param {string} opts.verificationCode - verification code to received via 2FA.
2239
2402
  * @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
2240
2403
  */
2241
- async verify2FAForPhone({
2242
- phone,
2243
- countryCode,
2244
- verificationCode
2245
- }) {
2246
- const res = await this.ctx.client.verify2FAForPhone(phone, countryCode, verificationCode);
2247
- return {
2248
- initiatedAt: res.data.initiatedAt,
2249
- status: res.data.status,
2250
- userId: res.data.userId,
2251
- wallets: res.data.wallets
2252
- };
2404
+ verify2FAForPhone(_0) {
2405
+ return __async(this, arguments, function* ({
2406
+ phone,
2407
+ countryCode,
2408
+ verificationCode
2409
+ }) {
2410
+ const res = yield this.ctx.client.verify2FAForPhone(phone, countryCode, verificationCode);
2411
+ return {
2412
+ initiatedAt: res.data.initiatedAt,
2413
+ status: res.data.status,
2414
+ userId: res.data.userId,
2415
+ wallets: res.data.wallets
2416
+ };
2417
+ });
2253
2418
  }
2254
2419
  /**
2255
2420
  * Sets up two-factor authentication for the current user.
2256
2421
  * @returns {string} uri - uri to use for setting up 2FA
2257
2422
  * */
2258
- async setup2FA() {
2259
- const res = await this.ctx.client.setup2FA(this.userId);
2260
- return {
2261
- uri: res.data.uri
2262
- };
2423
+ setup2FA() {
2424
+ return __async(this, null, function* () {
2425
+ const res = yield this.ctx.client.setup2FA(this.userId);
2426
+ return {
2427
+ uri: res.data.uri
2428
+ };
2429
+ });
2263
2430
  }
2264
2431
  /**
2265
2432
  * Enables 2FA.
2266
2433
  * @param {Object} opts the options object
2267
2434
  * @param {string} opts.verificationCode - the verification code received via 2FA.
2268
2435
  */
2269
- async enable2FA({ verificationCode }) {
2270
- await this.ctx.client.enable2FA(this.userId, verificationCode);
2436
+ enable2FA(_0) {
2437
+ return __async(this, arguments, function* ({ verificationCode }) {
2438
+ yield this.ctx.client.enable2FA(this.userId, verificationCode);
2439
+ });
2271
2440
  }
2272
2441
  /**
2273
2442
  * Determines if 2FA has been set up.
2274
2443
  * @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
2275
2444
  */
2276
- async check2FAStatus() {
2277
- if (!this.userId) {
2278
- return { isSetup: false };
2279
- }
2280
- const res = await this.ctx.client.check2FAStatus(this.userId);
2281
- return {
2282
- isSetup: res.data.isSetup
2283
- };
2445
+ check2FAStatus() {
2446
+ return __async(this, null, function* () {
2447
+ if (!this.userId) {
2448
+ return { isSetup: false };
2449
+ }
2450
+ const res = yield this.ctx.client.check2FAStatus(this.userId);
2451
+ return {
2452
+ isSetup: res.data.isSetup
2453
+ };
2454
+ });
2284
2455
  }
2285
2456
  /**
2286
2457
  * Resend a verification email for the current user.
2287
2458
  */
2288
- async resendVerificationCode() {
2289
- await this.ctx.client.resendVerificationCode({
2290
- userId: this.userId,
2291
- ...this.getVerificationEmailProps()
2459
+ resendVerificationCode() {
2460
+ return __async(this, null, function* () {
2461
+ yield this.ctx.client.resendVerificationCode(__spreadValues({
2462
+ userId: this.userId
2463
+ }, this.getVerificationEmailProps()));
2292
2464
  });
2293
2465
  }
2294
2466
  /**
2295
2467
  * Resend a verification SMS for the current user.
2296
2468
  */
2297
- async resendVerificationCodeByPhone() {
2298
- await this.ctx.client.resendVerificationCodeByPhone({
2299
- userId: this.userId
2469
+ resendVerificationCodeByPhone() {
2470
+ return __async(this, null, function* () {
2471
+ yield this.ctx.client.resendVerificationCodeByPhone({
2472
+ userId: this.userId
2473
+ });
2300
2474
  });
2301
2475
  }
2302
2476
  /**
@@ -2306,19 +2480,21 @@ var ParaCore = class _ParaCore {
2306
2480
  * @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
2307
2481
  * @returns {string} the URL
2308
2482
  */
2309
- async getSetUpBiometricsURL({
2310
- authType = "email",
2311
- isForNewDevice = false
2312
- } = {}) {
2313
- const res = await this.ctx.client.addSessionPublicKey(this.userId, {
2314
- status: import_user_management_client5.PublicKeyStatus.PENDING,
2315
- type: import_user_management_client5.PublicKeyType.WEB
2316
- });
2317
- return this.getWebAuthURLForCreate({
2318
- authType,
2319
- isForNewDevice,
2320
- webAuthId: res.data.id,
2321
- partnerId: res.data.partnerId
2483
+ getSetUpBiometricsURL() {
2484
+ return __async(this, arguments, function* ({
2485
+ authType = "email",
2486
+ isForNewDevice = false
2487
+ } = {}) {
2488
+ const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
2489
+ status: import_user_management_client5.PublicKeyStatus.PENDING,
2490
+ type: import_user_management_client5.PublicKeyType.WEB
2491
+ });
2492
+ return this.getWebAuthURLForCreate({
2493
+ authType,
2494
+ isForNewDevice,
2495
+ webAuthId: res.data.id,
2496
+ partnerId: res.data.partnerId
2497
+ });
2322
2498
  });
2323
2499
  }
2324
2500
  /**
@@ -2327,18 +2503,20 @@ var ParaCore = class _ParaCore {
2327
2503
  * @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
2328
2504
  * @returns {string} the URL
2329
2505
  */
2330
- async getSetUpBiometricsURLForPhone({
2331
- isForNewDevice = false
2332
- } = {}) {
2333
- const res = await this.ctx.client.addSessionPublicKey(this.userId, {
2334
- status: import_user_management_client5.PublicKeyStatus.PENDING,
2335
- type: import_user_management_client5.PublicKeyType.WEB
2336
- });
2337
- return this.getWebAuthURLForCreate({
2338
- authType: "phone",
2339
- isForNewDevice,
2340
- webAuthId: res.data.id,
2341
- partnerId: res.data.partnerId
2506
+ getSetUpBiometricsURLForPhone() {
2507
+ return __async(this, arguments, function* ({
2508
+ isForNewDevice = false
2509
+ } = {}) {
2510
+ const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
2511
+ status: import_user_management_client5.PublicKeyStatus.PENDING,
2512
+ type: import_user_management_client5.PublicKeyType.WEB
2513
+ });
2514
+ return this.getWebAuthURLForCreate({
2515
+ authType: "phone",
2516
+ isForNewDevice,
2517
+ webAuthId: res.data.id,
2518
+ partnerId: res.data.partnerId
2519
+ });
2342
2520
  });
2343
2521
  }
2344
2522
  /**
@@ -2349,95 +2527,107 @@ var ParaCore = class _ParaCore {
2349
2527
  * @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
2350
2528
  * @returns {string} the URL
2351
2529
  */
2352
- async getSetupPasswordURL({
2353
- authType = "email",
2354
- isForNewDevice = false,
2355
- theme
2356
- } = {}) {
2357
- const res = await this.ctx.client.addSessionPasswordPublicKey(this.userId, {
2358
- status: import_user_management_client5.PasswordStatus.PENDING
2359
- });
2360
- return this.getPasswordURLForCreate({
2361
- authType,
2362
- isForNewDevice,
2363
- passwordId: res.data.id,
2364
- partnerId: res.data.partnerId,
2530
+ getSetupPasswordURL() {
2531
+ return __async(this, arguments, function* ({
2532
+ authType = "email",
2533
+ isForNewDevice = false,
2365
2534
  theme
2535
+ } = {}) {
2536
+ const res = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
2537
+ status: import_user_management_client5.PasswordStatus.PENDING
2538
+ });
2539
+ return this.getPasswordURLForCreate({
2540
+ authType,
2541
+ isForNewDevice,
2542
+ passwordId: res.data.id,
2543
+ partnerId: res.data.partnerId,
2544
+ theme
2545
+ });
2366
2546
  });
2367
2547
  }
2368
2548
  /**
2369
2549
  * Checks if the current session is active.
2370
2550
  * @returns `true` if active, `false` otherwise
2371
2551
  */
2372
- async isSessionActive() {
2373
- if (this.isUsingExternalWallet()) {
2374
- return true;
2375
- }
2376
- const res = await this.touchSession();
2377
- return !!res.data.isAuthenticated;
2552
+ isSessionActive() {
2553
+ return __async(this, null, function* () {
2554
+ if (this.isUsingExternalWallet()) {
2555
+ return true;
2556
+ }
2557
+ const res = yield this.touchSession();
2558
+ return !!res.data.isAuthenticated;
2559
+ });
2378
2560
  }
2379
2561
  /**
2380
2562
  * Checks if a session is active and a wallet exists.
2381
2563
  * @returns `true` if active, `false` otherwise
2382
2564
  **/
2383
- async isFullyLoggedIn() {
2384
- if (this.isUsingExternalWallet()) {
2385
- return true;
2386
- }
2387
- const isSessionActive = await this.isSessionActive();
2388
- return isSessionActive && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true);
2565
+ isFullyLoggedIn() {
2566
+ return __async(this, null, function* () {
2567
+ if (this.isUsingExternalWallet()) {
2568
+ return true;
2569
+ }
2570
+ const isSessionActive = yield this.isSessionActive();
2571
+ return isSessionActive && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true);
2572
+ });
2389
2573
  }
2390
- async supportedAuthMethods(auth) {
2391
- const { supportedAuthMethods } = await this.ctx.client.getSupportedAuthMethods(auth);
2392
- const authMethods = /* @__PURE__ */ new Set();
2393
- for (const type of supportedAuthMethods) {
2394
- switch (type) {
2395
- case "PASSWORD":
2396
- authMethods.add(import_user_management_client5.AuthMethod.PASSWORD);
2397
- break;
2398
- case "BIOMETRIC":
2399
- authMethods.add(import_user_management_client5.AuthMethod.PASSKEY);
2400
- break;
2574
+ supportedAuthMethods(auth) {
2575
+ return __async(this, null, function* () {
2576
+ const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
2577
+ const authMethods = /* @__PURE__ */ new Set();
2578
+ for (const type of supportedAuthMethods) {
2579
+ switch (type) {
2580
+ case "PASSWORD":
2581
+ authMethods.add(import_user_management_client5.AuthMethod.PASSWORD);
2582
+ break;
2583
+ case "BIOMETRIC":
2584
+ authMethods.add(import_user_management_client5.AuthMethod.PASSKEY);
2585
+ break;
2586
+ }
2401
2587
  }
2402
- }
2403
- return authMethods;
2588
+ return authMethods;
2589
+ });
2404
2590
  }
2405
2591
  /**
2406
2592
  * Get hints associated with the users stored biometrics.
2407
2593
  * @returns Array containing useragents and AAGuids for stored biometrics
2408
2594
  */
2409
- async getUserBiometricLocationHints() {
2410
- if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId) {
2411
- throw new Error("one of email, phone or farcaster username are required to get biometric location hints");
2412
- }
2413
- return await this.ctx.client.getBiometricLocationHints({
2414
- email: this.email,
2415
- phone: this.phone,
2416
- countryCode: this.countryCode,
2417
- farcasterUsername: this.farcasterUsername,
2418
- telegramUserId: this.telegramUserId
2595
+ getUserBiometricLocationHints() {
2596
+ return __async(this, null, function* () {
2597
+ if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId) {
2598
+ throw new Error("one of email, phone or farcaster username are required to get biometric location hints");
2599
+ }
2600
+ return yield this.ctx.client.getBiometricLocationHints({
2601
+ email: this.email,
2602
+ phone: this.phone,
2603
+ countryCode: this.countryCode,
2604
+ farcasterUsername: this.farcasterUsername,
2605
+ telegramUserId: this.telegramUserId
2606
+ });
2419
2607
  });
2420
2608
  }
2421
- async setAuth(auth) {
2422
- const authInfo = (0, import_user_management_client5.extractAuthInfo)(auth);
2423
- if (!authInfo) {
2424
- return void 0;
2425
- }
2426
- switch (authInfo.authType) {
2427
- case "email":
2428
- await this.setEmail(authInfo.identifier);
2429
- break;
2430
- case "phone":
2431
- await this.setPhoneNumber(authInfo.auth.phone, authInfo.auth.countryCode);
2432
- break;
2433
- case "farcaster":
2434
- await this.setFarcasterUsername(authInfo.identifier);
2435
- break;
2436
- case "telegram":
2437
- await this.setTelegramUserId(authInfo.identifier);
2438
- break;
2439
- }
2440
- return authInfo;
2609
+ setAuth(auth) {
2610
+ return __async(this, null, function* () {
2611
+ const authInfo = (0, import_user_management_client5.extractAuthInfo)(auth);
2612
+ if (!authInfo) {
2613
+ return void 0;
2614
+ }
2615
+ switch (authInfo.authType) {
2616
+ case "email":
2617
+ yield this.setEmail(authInfo.identifier);
2618
+ break;
2619
+ case "phone":
2620
+ yield this.setPhoneNumber(authInfo.auth.phone, authInfo.auth.countryCode);
2621
+ break;
2622
+ case "farcaster":
2623
+ yield this.setFarcasterUsername(authInfo.identifier);
2624
+ break;
2625
+ case "telegram":
2626
+ yield this.setTelegramUserId(authInfo.identifier);
2627
+ break;
2628
+ }
2629
+ return authInfo;
2630
+ });
2441
2631
  }
2442
2632
  /**
2443
2633
  * Initiates a login.
@@ -2446,41 +2636,46 @@ var ParaCore = class _ParaCore {
2446
2636
  * @param {boolean} opts.useShortURL - whether to shorten the link
2447
2637
  * @returns - the WebAuth URL for logging in
2448
2638
  **/
2449
- async initiateUserLogin({ useShortUrl = false, ...auth }) {
2450
- const authInfo = await this.setAuth(auth);
2451
- if (!authInfo) {
2452
- return;
2453
- }
2454
- const res = await this.touchSession(true);
2455
- if (!this.loginEncryptionKeyPair) {
2456
- await this.setLoginEncryptionKeyPair();
2457
- }
2458
- const webAuthLoginURL = await this.getWebAuthURLForLogin({
2459
- authType: authInfo.authType,
2460
- sessionId: res.data.sessionId,
2461
- partnerId: res.data.partnerId,
2462
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2463
- });
2464
- if (!useShortUrl) {
2465
- return webAuthLoginURL;
2466
- }
2467
- return this.shortenLoginLink(webAuthLoginURL);
2639
+ initiateUserLogin(_e) {
2640
+ return __async(this, null, function* () {
2641
+ var _f = _e, { useShortUrl = false } = _f, auth = __objRest(_f, ["useShortUrl"]);
2642
+ const authInfo = yield this.setAuth(auth);
2643
+ if (!authInfo) {
2644
+ return;
2645
+ }
2646
+ const res = yield this.touchSession(true);
2647
+ if (!this.loginEncryptionKeyPair) {
2648
+ yield this.setLoginEncryptionKeyPair();
2649
+ }
2650
+ const webAuthLoginURL = yield this.getWebAuthURLForLogin({
2651
+ authType: authInfo.authType,
2652
+ sessionId: res.data.sessionId,
2653
+ partnerId: res.data.partnerId,
2654
+ loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2655
+ });
2656
+ if (!useShortUrl) {
2657
+ return webAuthLoginURL;
2658
+ }
2659
+ return this.shortenLoginLink(webAuthLoginURL);
2660
+ });
2468
2661
  }
2469
2662
  /**
2470
2663
  * Initiates a login.
2471
2664
  * @param email - the email to login with
2472
2665
  * @returns - a set of supported auth methods for the user
2473
2666
  **/
2474
- async initiateUserLoginV2(auth) {
2475
- const authInfo = await this.setAuth(auth);
2476
- if (!authInfo) {
2477
- return;
2478
- }
2479
- await this.touchSession(true);
2480
- if (!this.loginEncryptionKeyPair) {
2481
- await this.setLoginEncryptionKeyPair();
2482
- }
2483
- return await this.supportedAuthMethods(authInfo.auth);
2667
+ initiateUserLoginV2(auth) {
2668
+ return __async(this, null, function* () {
2669
+ const authInfo = yield this.setAuth(auth);
2670
+ if (!authInfo) {
2671
+ return;
2672
+ }
2673
+ yield this.touchSession(true);
2674
+ if (!this.loginEncryptionKeyPair) {
2675
+ yield this.setLoginEncryptionKeyPair();
2676
+ }
2677
+ return yield this.supportedAuthMethods(authInfo.auth);
2678
+ });
2484
2679
  }
2485
2680
  /**
2486
2681
  * Initiates a login.
@@ -2490,112 +2685,124 @@ var ParaCore = class _ParaCore {
2490
2685
  * @param opts.useShortURL - whether to shorten the link
2491
2686
  * @returns - the WebAuth URL for logging in
2492
2687
  **/
2493
- async initiateUserLoginForPhone({
2494
- useShortUrl = false,
2495
- ...auth
2496
- }) {
2497
- await this.setAuth(auth);
2498
- const res = await this.touchSession(true);
2499
- if (!this.loginEncryptionKeyPair) {
2500
- await this.setLoginEncryptionKeyPair();
2501
- }
2502
- const webAuthLoginURL = await this.getWebAuthURLForLoginForPhone({
2503
- sessionId: res.data.sessionId,
2504
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair),
2505
- partnerId: res.data.partnerId
2688
+ initiateUserLoginForPhone(_g) {
2689
+ return __async(this, null, function* () {
2690
+ var _h = _g, {
2691
+ useShortUrl = false
2692
+ } = _h, auth = __objRest(_h, [
2693
+ "useShortUrl"
2694
+ ]);
2695
+ yield this.setAuth(auth);
2696
+ const res = yield this.touchSession(true);
2697
+ if (!this.loginEncryptionKeyPair) {
2698
+ yield this.setLoginEncryptionKeyPair();
2699
+ }
2700
+ const webAuthLoginURL = yield this.getWebAuthURLForLoginForPhone({
2701
+ sessionId: res.data.sessionId,
2702
+ loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair),
2703
+ partnerId: res.data.partnerId
2704
+ });
2705
+ if (!useShortUrl) {
2706
+ return webAuthLoginURL;
2707
+ }
2708
+ return this.shortenLoginLink(webAuthLoginURL);
2506
2709
  });
2507
- if (!useShortUrl) {
2508
- return webAuthLoginURL;
2509
- }
2510
- return this.shortenLoginLink(webAuthLoginURL);
2511
2710
  }
2512
2711
  /**
2513
2712
  * Waits for the session to be active.
2514
2713
  **/
2515
- async waitForAccountCreation({ popupWindow } = {}) {
2516
- await this.touchSession();
2517
- this.externalWallets = {};
2518
- this.isAwaitingAccountCreation = true;
2519
- while (this.isAwaitingAccountCreation) {
2520
- try {
2521
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2522
- if (await this.isSessionActive()) {
2523
- this.isAwaitingAccountCreation = false;
2524
- dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
2525
- return true;
2526
- } else {
2527
- if (popupWindow?.closed) {
2714
+ waitForAccountCreation() {
2715
+ return __async(this, arguments, function* ({ popupWindow } = {}) {
2716
+ yield this.touchSession();
2717
+ this.externalWallets = {};
2718
+ this.isAwaitingAccountCreation = true;
2719
+ while (this.isAwaitingAccountCreation) {
2720
+ try {
2721
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2722
+ if (yield this.isSessionActive()) {
2528
2723
  this.isAwaitingAccountCreation = false;
2529
- return false;
2724
+ dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
2725
+ return true;
2726
+ } else {
2727
+ if (popupWindow == null ? void 0 : popupWindow.closed) {
2728
+ this.isAwaitingAccountCreation = false;
2729
+ return false;
2730
+ }
2530
2731
  }
2732
+ } catch (err) {
2733
+ console.error(err);
2531
2734
  }
2532
- } catch (err) {
2533
- console.error(err);
2534
2735
  }
2535
- }
2536
- return false;
2736
+ return false;
2737
+ });
2537
2738
  }
2538
- async waitForPasskeyAndCreateWallet({
2539
- popupWindow
2540
- } = {}) {
2541
- await this.waitForAccountCreation({ popupWindow });
2542
- const pregenWallets = await this.getPregenWallets();
2543
- let recoverySecret, walletIds = {};
2544
- if (pregenWallets.length > 0) {
2545
- recoverySecret = await this.claimPregenWallets();
2546
- walletIds = this.supportedWalletTypes.reduce((acc, { type }) => {
2547
- return {
2548
- ...acc,
2549
- [type]: [pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])?.id]
2550
- };
2551
- }, {});
2552
- }
2553
- const created = await this.createWalletPerType();
2554
- recoverySecret = recoverySecret ?? created.recoverySecret;
2555
- walletIds = { ...walletIds, ...created.walletIds };
2556
- const resp = { walletIds, recoverySecret };
2557
- dispatchEvent(ParaEvent.ACCOUNT_SETUP_EVENT, resp);
2558
- return resp;
2739
+ waitForPasskeyAndCreateWallet() {
2740
+ return __async(this, arguments, function* ({
2741
+ popupWindow
2742
+ } = {}) {
2743
+ yield this.waitForAccountCreation({ popupWindow });
2744
+ const pregenWallets = yield this.getPregenWallets();
2745
+ let recoverySecret, walletIds = {};
2746
+ if (pregenWallets.length > 0) {
2747
+ recoverySecret = yield this.claimPregenWallets();
2748
+ walletIds = this.supportedWalletTypes.reduce((acc, { type }) => {
2749
+ var _a;
2750
+ return __spreadProps(__spreadValues({}, acc), {
2751
+ [type]: [(_a = pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
2752
+ });
2753
+ }, {});
2754
+ }
2755
+ const created = yield this.createWalletPerType();
2756
+ recoverySecret = recoverySecret != null ? recoverySecret : created.recoverySecret;
2757
+ walletIds = __spreadValues(__spreadValues({}, walletIds), created.walletIds);
2758
+ const resp = { walletIds, recoverySecret };
2759
+ dispatchEvent(ParaEvent.ACCOUNT_SETUP_EVENT, resp);
2760
+ return resp;
2761
+ });
2559
2762
  }
2560
2763
  /**
2561
2764
  * Initiates a Farcaster login attempt and return the URI for the user to connect.
2562
2765
  * You can create a QR code with this URI that works with Farcaster's mobile app.
2563
2766
  * @return {string} the Farcaster connect URI
2564
2767
  */
2565
- async getFarcasterConnectURL() {
2566
- await this.logout();
2567
- await this.touchSession(true);
2568
- const {
2569
- data: { connect_uri }
2570
- } = await this.ctx.client.initializeFarcasterLogin();
2571
- return connect_uri;
2768
+ getFarcasterConnectURL() {
2769
+ return __async(this, null, function* () {
2770
+ yield this.logout();
2771
+ yield this.touchSession(true);
2772
+ const {
2773
+ data: { connect_uri }
2774
+ } = yield this.ctx.client.initializeFarcasterLogin();
2775
+ return connect_uri;
2776
+ });
2572
2777
  }
2573
2778
  /**
2574
2779
  * Awaits the response from a user's attempt to log in with Farcaster.
2575
2780
  * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
2576
2781
  * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
2577
2782
  */
2578
- async waitForFarcasterStatus() {
2579
- this.isAwaitingFarcaster = true;
2580
- while (this.isAwaitingFarcaster) {
2581
- try {
2582
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2583
- const res = await this.ctx.client.getFarcasterAuthStatus();
2584
- if (res.data.state === "completed") {
2585
- const { userId, userExists, username, pfpUrl } = res.data;
2586
- await this.setUserId(userId);
2587
- await this.setFarcasterUsername(username);
2588
- return {
2589
- userExists,
2590
- username,
2591
- pfpUrl
2592
- };
2783
+ waitForFarcasterStatus() {
2784
+ return __async(this, null, function* () {
2785
+ this.isAwaitingFarcaster = true;
2786
+ while (this.isAwaitingFarcaster) {
2787
+ try {
2788
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2789
+ const res = yield this.ctx.client.getFarcasterAuthStatus();
2790
+ if (res.data.state === "completed") {
2791
+ const { userId, userExists, username, pfpUrl } = res.data;
2792
+ yield this.setUserId(userId);
2793
+ yield this.setFarcasterUsername(username);
2794
+ return {
2795
+ userExists,
2796
+ username,
2797
+ pfpUrl
2798
+ };
2799
+ }
2800
+ } catch (err) {
2801
+ console.error(err);
2802
+ this.isAwaitingFarcaster = false;
2593
2803
  }
2594
- } catch (err) {
2595
- console.error(err);
2596
- this.isAwaitingFarcaster = false;
2597
2804
  }
2598
- }
2805
+ });
2599
2806
  }
2600
2807
  /**
2601
2808
  * Generates a URL for the user to log in with OAuth using a desire method.
@@ -2605,17 +2812,19 @@ var ParaCore = class _ParaCore {
2605
2812
  * @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
2606
2813
  * @returns {string} the URL for the user to log in with OAuth.
2607
2814
  */
2608
- async getOAuthURL({ method, deeplinkUrl }) {
2609
- await this.logout();
2610
- const res = await this.touchSession(true);
2611
- return constructUrl({
2612
- base: method === import_user_management_client5.OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseOAuthUrl(this.ctx.env),
2613
- path: `/auth/${method.toLowerCase()}`,
2614
- params: {
2615
- apiKey: this.ctx.apiKey,
2616
- sessionLookupId: res.data.sessionLookupId,
2617
- deeplinkUrl
2618
- }
2815
+ getOAuthURL(_0) {
2816
+ return __async(this, arguments, function* ({ method, deeplinkUrl }) {
2817
+ yield this.logout();
2818
+ const res = yield this.touchSession(true);
2819
+ return constructUrl({
2820
+ base: method === import_user_management_client5.OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseOAuthUrl(this.ctx.env),
2821
+ path: `/auth/${method.toLowerCase()}`,
2822
+ params: {
2823
+ apiKey: this.ctx.apiKey,
2824
+ sessionLookupId: res.data.sessionLookupId,
2825
+ deeplinkUrl
2826
+ }
2827
+ });
2619
2828
  });
2620
2829
  }
2621
2830
  /**
@@ -2626,36 +2835,38 @@ var ParaCore = class _ParaCore {
2626
2835
  * @param {Window} [opts.popupWindow] the popup window being used for login.
2627
2836
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
2628
2837
  */
2629
- async waitForOAuth({ popupWindow } = {}) {
2630
- this.isAwaitingOAuth = true;
2631
- while (this.isAwaitingOAuth) {
2632
- try {
2633
- if (popupWindow?.closed) {
2634
- return { isError: true, userExists: false };
2635
- }
2636
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2637
- if (this.isAwaitingOAuth) {
2638
- const res = await this.touchSession();
2639
- if (res.data.userId) {
2640
- const { userId, email } = res.data;
2641
- if (!this.loginEncryptionKeyPair) {
2642
- await this.setLoginEncryptionKeyPair();
2838
+ waitForOAuth() {
2839
+ return __async(this, arguments, function* ({ popupWindow } = {}) {
2840
+ this.isAwaitingOAuth = true;
2841
+ while (this.isAwaitingOAuth) {
2842
+ try {
2843
+ if (popupWindow == null ? void 0 : popupWindow.closed) {
2844
+ return { isError: true, userExists: false };
2845
+ }
2846
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2847
+ if (this.isAwaitingOAuth) {
2848
+ const res = yield this.touchSession();
2849
+ if (res.data.userId) {
2850
+ const { userId, email } = res.data;
2851
+ if (!this.loginEncryptionKeyPair) {
2852
+ yield this.setLoginEncryptionKeyPair();
2853
+ }
2854
+ yield this.setUserId(userId);
2855
+ yield this.setEmail(email);
2856
+ const userExists = yield this.checkIfUserExists({ email });
2857
+ this.isAwaitingOAuth = false;
2858
+ return {
2859
+ userExists,
2860
+ email
2861
+ };
2643
2862
  }
2644
- await this.setUserId(userId);
2645
- await this.setEmail(email);
2646
- const userExists = await this.checkIfUserExists({ email });
2647
- this.isAwaitingOAuth = false;
2648
- return {
2649
- userExists,
2650
- email
2651
- };
2652
2863
  }
2864
+ } catch (err) {
2865
+ console.error(err);
2653
2866
  }
2654
- } catch (err) {
2655
- console.error(err);
2656
2867
  }
2657
- }
2658
- return { userExists: false };
2868
+ return { userExists: false };
2869
+ });
2659
2870
  }
2660
2871
  /**
2661
2872
  * Waits for the session to be active and sets up the user.
@@ -2665,56 +2876,59 @@ var ParaCore = class _ParaCore {
2665
2876
  * @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
2666
2877
  * @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
2667
2878
  **/
2668
- async waitForLoginAndSetup({
2669
- popupWindow,
2670
- skipSessionRefresh = false
2671
- } = {}) {
2672
- this.externalWallets = {};
2673
- this.isAwaitingLogin = true;
2674
- while (this.isAwaitingLogin) {
2675
- try {
2676
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2677
- if (!await this.isSessionActive()) {
2678
- if (popupWindow?.closed) {
2679
- const resp2 = { isComplete: false, isError: true };
2680
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
2681
- return resp2;
2682
- }
2683
- continue;
2684
- }
2685
- const postLoginData = await this.userSetupAfterLogin();
2686
- const needsWallet = postLoginData.data.needsWallet ?? false;
2687
- if (!needsWallet) {
2688
- if (this.currentWalletIdsArray.length === 0) {
2689
- if (popupWindow?.closed) {
2879
+ waitForLoginAndSetup() {
2880
+ return __async(this, arguments, function* ({
2881
+ popupWindow,
2882
+ skipSessionRefresh = false
2883
+ } = {}) {
2884
+ var _a;
2885
+ this.externalWallets = {};
2886
+ this.isAwaitingLogin = true;
2887
+ while (this.isAwaitingLogin) {
2888
+ try {
2889
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2890
+ if (!(yield this.isSessionActive())) {
2891
+ if (popupWindow == null ? void 0 : popupWindow.closed) {
2690
2892
  const resp2 = { isComplete: false, isError: true };
2691
2893
  dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
2692
2894
  return resp2;
2693
- } else {
2694
- continue;
2695
2895
  }
2896
+ continue;
2696
2897
  }
2898
+ const postLoginData = yield this.userSetupAfterLogin();
2899
+ const needsWallet = (_a = postLoginData.data.needsWallet) != null ? _a : false;
2900
+ if (!needsWallet) {
2901
+ if (this.currentWalletIdsArray.length === 0) {
2902
+ if (popupWindow == null ? void 0 : popupWindow.closed) {
2903
+ const resp2 = { isComplete: false, isError: true };
2904
+ dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
2905
+ return resp2;
2906
+ } else {
2907
+ continue;
2908
+ }
2909
+ }
2910
+ }
2911
+ const fetchedWallets = yield this.fetchWallets();
2912
+ const tempSharesRes = yield this.getTransmissionKeyShares();
2913
+ if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
2914
+ yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
2915
+ yield this.claimPregenWallets();
2916
+ const resp2 = {
2917
+ isComplete: true,
2918
+ needsWallet: needsWallet || Object.values(this.wallets).length === 0,
2919
+ partnerId: postLoginData.data.partnerId
2920
+ };
2921
+ dispatchEvent(ParaEvent.LOGIN_EVENT, resp2);
2922
+ return resp2;
2923
+ }
2924
+ } catch (err) {
2925
+ console.error(err);
2697
2926
  }
2698
- const fetchedWallets = await this.fetchWallets();
2699
- const tempSharesRes = await this.getTransmissionKeyShares();
2700
- if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
2701
- await this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
2702
- await this.claimPregenWallets();
2703
- const resp2 = {
2704
- isComplete: true,
2705
- needsWallet: needsWallet || Object.values(this.wallets).length === 0,
2706
- partnerId: postLoginData.data.partnerId
2707
- };
2708
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp2);
2709
- return resp2;
2710
- }
2711
- } catch (err) {
2712
- console.error(err);
2713
2927
  }
2714
- }
2715
- const resp = { isComplete: false };
2716
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
2717
- return resp;
2928
+ const resp = { isComplete: false };
2929
+ dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
2930
+ return resp;
2931
+ });
2718
2932
  }
2719
2933
  /**
2720
2934
  * Updates the session with the user management server, possibly
@@ -2724,32 +2938,36 @@ var ParaCore = class _ParaCore {
2724
2938
  * @param {boolean} [shouldOpenPopup] - if `true`, the running device will open a popup to reauthenticate the user.
2725
2939
  * @returns a URL for the user to reauthenticate.
2726
2940
  **/
2727
- async refreshSession({ shouldOpenPopup = false } = {}) {
2728
- const res = await this.touchSession(true);
2729
- if (!this.loginEncryptionKeyPair) {
2730
- await this.setLoginEncryptionKeyPair();
2731
- }
2732
- const link = await this.getWebAuthURLForLogin({
2733
- sessionId: res.data.sessionId,
2734
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2941
+ refreshSession() {
2942
+ return __async(this, arguments, function* ({ shouldOpenPopup = false } = {}) {
2943
+ const res = yield this.touchSession(true);
2944
+ if (!this.loginEncryptionKeyPair) {
2945
+ yield this.setLoginEncryptionKeyPair();
2946
+ }
2947
+ const link = yield this.getWebAuthURLForLogin({
2948
+ sessionId: res.data.sessionId,
2949
+ loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2950
+ });
2951
+ if (shouldOpenPopup) {
2952
+ this.platformUtils.openPopup(link);
2953
+ }
2954
+ return link;
2735
2955
  });
2736
- if (shouldOpenPopup) {
2737
- this.platformUtils.openPopup(link);
2738
- }
2739
- return link;
2740
2956
  }
2741
2957
  /**
2742
2958
  * Call this method after login to ensure that the user ID is set
2743
2959
  * internally.
2744
2960
  **/
2745
- async userSetupAfterLogin() {
2746
- const res = await this.touchSession();
2747
- await this.setUserId(res.data.userId);
2748
- if (res.data.currentWalletIds && res.data.currentWalletIds !== this.currentWalletIds)
2749
- await this.setCurrentWalletIds(res.data.currentWalletIds, {
2750
- sessionLookupId: this.isPortal() ? res.data.sessionLookupId : void 0
2751
- });
2752
- return res;
2961
+ userSetupAfterLogin() {
2962
+ return __async(this, null, function* () {
2963
+ const res = yield this.touchSession();
2964
+ yield this.setUserId(res.data.userId);
2965
+ if (res.data.currentWalletIds && res.data.currentWalletIds !== this.currentWalletIds)
2966
+ yield this.setCurrentWalletIds(res.data.currentWalletIds, {
2967
+ sessionLookupId: this.isPortal() ? res.data.sessionLookupId : void 0
2968
+ });
2969
+ return res;
2970
+ });
2753
2971
  }
2754
2972
  /**
2755
2973
  * Get transmission shares associated with session.
@@ -2757,10 +2975,12 @@ var ParaCore = class _ParaCore {
2757
2975
  * @param {boolean} opts.isForNewDevice - true if this device is registering.
2758
2976
  * @returns - transmission keyshares.
2759
2977
  **/
2760
- async getTransmissionKeyShares({ isForNewDevice = false } = {}) {
2761
- const res = await this.touchSession();
2762
- const sessionLookupId = isForNewDevice ? `${res.data.sessionLookupId}-new-device` : res.data.sessionLookupId;
2763
- return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
2978
+ getTransmissionKeyShares() {
2979
+ return __async(this, arguments, function* ({ isForNewDevice = false } = {}) {
2980
+ const res = yield this.touchSession();
2981
+ const sessionLookupId = isForNewDevice ? `${res.data.sessionLookupId}-new-device` : res.data.sessionLookupId;
2982
+ return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
2983
+ });
2764
2984
  }
2765
2985
  /**
2766
2986
  * Call this method after login to perform setup.
@@ -2768,23 +2988,25 @@ var ParaCore = class _ParaCore {
2768
2988
  * @param {any[]} opts.temporaryShares optional temporary shares to use for decryption.
2769
2989
  * @param {boolean} [opts.skipSessionRefresh] - whether or not to skip refreshing the session.
2770
2990
  **/
2771
- async setupAfterLogin({
2772
- temporaryShares,
2773
- skipSessionRefresh = false
2774
- } = {}) {
2775
- if (!temporaryShares) {
2776
- temporaryShares = (await this.getTransmissionKeyShares()).data.temporaryShares;
2777
- }
2778
- temporaryShares.forEach((share) => {
2779
- const signer = decryptWithPrivateKey(this.loginEncryptionKeyPair.privateKey, share.encryptedShare, share.encryptedKey);
2780
- this.wallets[share.walletId] = {
2781
- id: share.walletId,
2782
- signer
2783
- };
2991
+ setupAfterLogin() {
2992
+ return __async(this, arguments, function* ({
2993
+ temporaryShares,
2994
+ skipSessionRefresh = false
2995
+ } = {}) {
2996
+ if (!temporaryShares) {
2997
+ temporaryShares = (yield this.getTransmissionKeyShares()).data.temporaryShares;
2998
+ }
2999
+ temporaryShares.forEach((share) => {
3000
+ const signer = decryptWithPrivateKey(this.loginEncryptionKeyPair.privateKey, share.encryptedShare, share.encryptedKey);
3001
+ this.wallets[share.walletId] = {
3002
+ id: share.walletId,
3003
+ signer
3004
+ };
3005
+ });
3006
+ yield this.deleteLoginEncryptionKeyPair();
3007
+ yield this.populateWalletAddresses();
3008
+ yield this.touchSession(!skipSessionRefresh);
2784
3009
  });
2785
- await this.deleteLoginEncryptionKeyPair();
2786
- await this.populateWalletAddresses();
2787
- await this.touchSession(!skipSessionRefresh);
2788
3010
  }
2789
3011
  /**
2790
3012
  * Distributes a new wallet recovery share.
@@ -2795,51 +3017,55 @@ var ParaCore = class _ParaCore {
2795
3017
  * @param {boolean} opts.forceRefreshRecovery whether or not to force recovery secret regeneration. Used when regenerating recovery shares.
2796
3018
  * @returns {string} the recovery share.
2797
3019
  **/
2798
- async distributeNewWalletShare({
2799
- walletId,
2800
- userShare,
2801
- skipBiometricShareCreation = false,
2802
- forceRefresh = false
2803
- }) {
2804
- let userSigner = userShare;
2805
- if (!userSigner) {
2806
- userSigner = this.wallets[walletId].signer;
2807
- }
2808
- const recoveryShare = skipBiometricShareCreation ? await sendRecoveryForShare({
2809
- ctx: this.ctx,
2810
- userId: this.userId,
3020
+ distributeNewWalletShare(_0) {
3021
+ return __async(this, arguments, function* ({
2811
3022
  walletId,
2812
- userSigner,
2813
- emailProps: this.getBackupKitEmailProps(),
2814
- forceRefresh
2815
- }) : await distributeNewShare({
2816
- ctx: this.ctx,
2817
- userId: this.userId,
2818
- walletId,
2819
- userShare: userSigner,
2820
- emailProps: this.getBackupKitEmailProps()
3023
+ userShare,
3024
+ skipBiometricShareCreation = false,
3025
+ forceRefresh = false
3026
+ }) {
3027
+ let userSigner = userShare;
3028
+ if (!userSigner) {
3029
+ userSigner = this.wallets[walletId].signer;
3030
+ }
3031
+ const recoveryShare = skipBiometricShareCreation ? yield sendRecoveryForShare({
3032
+ ctx: this.ctx,
3033
+ userId: this.userId,
3034
+ walletId,
3035
+ userSigner,
3036
+ emailProps: this.getBackupKitEmailProps(),
3037
+ forceRefresh
3038
+ }) : yield distributeNewShare({
3039
+ ctx: this.ctx,
3040
+ userId: this.userId,
3041
+ walletId,
3042
+ userShare: userSigner,
3043
+ emailProps: this.getBackupKitEmailProps()
3044
+ });
3045
+ return recoveryShare;
2821
3046
  });
2822
- return recoveryShare;
2823
3047
  }
2824
- async waitForWalletAddress(walletId) {
2825
- let maxPolls = 0;
2826
- while (true) {
2827
- try {
2828
- if (maxPolls === 10) {
2829
- break;
2830
- }
2831
- ++maxPolls;
2832
- const res = await this.ctx.client.getWallets(this.userId);
2833
- const wallet = res.data.wallets.find((w) => w.id === walletId);
2834
- if (wallet && wallet.address) {
2835
- return;
3048
+ waitForWalletAddress(walletId) {
3049
+ return __async(this, null, function* () {
3050
+ let maxPolls = 0;
3051
+ while (true) {
3052
+ try {
3053
+ if (maxPolls === 10) {
3054
+ break;
3055
+ }
3056
+ ++maxPolls;
3057
+ const res = yield this.ctx.client.getWallets(this.userId);
3058
+ const wallet = res.data.wallets.find((w) => w.id === walletId);
3059
+ if (wallet && wallet.address) {
3060
+ return;
3061
+ }
3062
+ yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
3063
+ } catch (err) {
3064
+ console.error(err);
2836
3065
  }
2837
- await new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
2838
- } catch (err) {
2839
- console.error(err);
2840
3066
  }
2841
- }
2842
- throw new Error("timed out waiting for wallet address");
3067
+ throw new Error("timed out waiting for wallet address");
3068
+ });
2843
3069
  }
2844
3070
  /**
2845
3071
  * Waits for a pregen wallet address to be created.
@@ -2849,25 +3075,27 @@ var ParaCore = class _ParaCore {
2849
3075
  * @param pregenIdentifierType - the identifier type of the user the pregen wallet is associated with.
2850
3076
  * @returns - recovery share.
2851
3077
  **/
2852
- async waitForPregenWalletAddress(walletId) {
2853
- let maxPolls = 0;
2854
- while (true) {
2855
- try {
2856
- if (maxPolls === 10) {
2857
- break;
2858
- }
2859
- ++maxPolls;
2860
- const res = await this.getPregenWallets();
2861
- const wallet = res.find((w) => w.id === walletId);
2862
- if (wallet && wallet.address) {
2863
- return;
3078
+ waitForPregenWalletAddress(walletId) {
3079
+ return __async(this, null, function* () {
3080
+ let maxPolls = 0;
3081
+ while (true) {
3082
+ try {
3083
+ if (maxPolls === 10) {
3084
+ break;
3085
+ }
3086
+ ++maxPolls;
3087
+ const res = yield this.getPregenWallets();
3088
+ const wallet = res.find((w) => w.id === walletId);
3089
+ if (wallet && wallet.address) {
3090
+ return;
3091
+ }
3092
+ yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
3093
+ } catch (err) {
3094
+ console.error(err);
2864
3095
  }
2865
- await new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
2866
- } catch (err) {
2867
- console.error(err);
2868
3096
  }
2869
- }
2870
- throw new Error("timed out waiting for wallet address");
3097
+ throw new Error("timed out waiting for wallet address");
3098
+ });
2871
3099
  }
2872
3100
  /**
2873
3101
  * Creates several new wallets with the desired types. If no types are provided, this method
@@ -2880,24 +3108,26 @@ var ParaCore = class _ParaCore {
2880
3108
  * @param {WalletType[]} [opts.types] the types of wallets to create.
2881
3109
  * @returns {Object} the wallets created, their ids, and the recovery secret.
2882
3110
  **/
2883
- async createWalletPerType({
2884
- skipDistribute = false,
2885
- types
2886
- } = {}) {
2887
- const wallets = [];
2888
- const walletIds = {};
2889
- let recoverySecret;
2890
- for (const type of await this.getTypesToCreate(types)) {
2891
- const [wallet, recoveryShare] = await this.createWallet({ type, skipDistribute });
2892
- wallets.push(wallet);
2893
- getEquivalentTypes(type).filter((t) => !!this.isWalletTypeEnabled[t]).forEach((t) => {
2894
- walletIds[t] = [wallet.id];
2895
- });
2896
- if (recoveryShare) {
2897
- recoverySecret = recoveryShare;
3111
+ createWalletPerType() {
3112
+ return __async(this, arguments, function* ({
3113
+ skipDistribute = false,
3114
+ types
3115
+ } = {}) {
3116
+ const wallets = [];
3117
+ const walletIds = {};
3118
+ let recoverySecret;
3119
+ for (const type of yield this.getTypesToCreate(types)) {
3120
+ const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
3121
+ wallets.push(wallet);
3122
+ getEquivalentTypes(type).filter((t) => !!this.isWalletTypeEnabled[t]).forEach((t) => {
3123
+ walletIds[t] = [wallet.id];
3124
+ });
3125
+ if (recoveryShare) {
3126
+ recoverySecret = recoveryShare;
3127
+ }
2898
3128
  }
2899
- }
2900
- return { wallets, walletIds, recoverySecret };
3129
+ return { wallets, walletIds, recoverySecret };
3130
+ });
2901
3131
  }
2902
3132
  /**
2903
3133
  * Refresh the current user share for a wallet.
@@ -2911,35 +3141,37 @@ var ParaCore = class _ParaCore {
2911
3141
  * @param {boolean} [opts.redistributeBackupEncryptedShares] whether or not to redistribute backup encrypted shares.
2912
3142
  * @returns {Object} the new user share and recovery secret.
2913
3143
  **/
2914
- async refreshShare({
2915
- walletId,
2916
- share,
2917
- oldPartnerId,
2918
- newPartnerId,
2919
- keyShareProtocolId,
2920
- redistributeBackupEncryptedShares
2921
- }) {
2922
- const { signer, protocolId } = await this.platformUtils.refresh(
2923
- this.ctx,
2924
- this.retrieveSessionCookie(),
2925
- this.userId,
3144
+ refreshShare(_0) {
3145
+ return __async(this, arguments, function* ({
2926
3146
  walletId,
2927
3147
  share,
2928
3148
  oldPartnerId,
2929
3149
  newPartnerId,
2930
- keyShareProtocolId
2931
- );
2932
- const recoverySecret = await distributeNewShare({
2933
- ctx: this.ctx,
2934
- userId: this.userId,
2935
- walletId,
2936
- userShare: signer,
2937
- ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
2938
- emailProps: this.getBackupKitEmailProps(),
2939
- partnerId: newPartnerId,
2940
- protocolId
3150
+ keyShareProtocolId,
3151
+ redistributeBackupEncryptedShares
3152
+ }) {
3153
+ const { signer, protocolId } = yield this.platformUtils.refresh(
3154
+ this.ctx,
3155
+ this.retrieveSessionCookie(),
3156
+ this.userId,
3157
+ walletId,
3158
+ share,
3159
+ oldPartnerId,
3160
+ newPartnerId,
3161
+ keyShareProtocolId
3162
+ );
3163
+ const recoverySecret = yield distributeNewShare({
3164
+ ctx: this.ctx,
3165
+ userId: this.userId,
3166
+ walletId,
3167
+ userShare: signer,
3168
+ ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
3169
+ emailProps: this.getBackupKitEmailProps(),
3170
+ partnerId: newPartnerId,
3171
+ protocolId
3172
+ });
3173
+ return { signer, recoverySecret, protocolId };
2941
3174
  });
2942
- return { signer, recoverySecret, protocolId };
2943
3175
  }
2944
3176
  /**
2945
3177
  * Creates a new wallet.
@@ -2948,71 +3180,73 @@ var ParaCore = class _ParaCore {
2948
3180
  * @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
2949
3181
  * @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
2950
3182
  **/
2951
- async createWallet({
2952
- type: _type,
2953
- skipDistribute = false
2954
- } = {}) {
2955
- this.requireApiKey();
2956
- const walletType = await this.assertIsValidWalletType(
2957
- _type ?? this.supportedWalletTypes.find(({ optional }) => !optional)?.type
2958
- );
2959
- let signer;
2960
- let wallet;
2961
- let keygenRes;
2962
- switch (walletType) {
2963
- case import_user_management_client5.WalletType.SOLANA: {
2964
- keygenRes = await this.platformUtils.ed25519Keygen(
2965
- this.ctx,
2966
- this.userId,
2967
- this.retrieveSessionCookie(),
2968
- this.getBackupKitEmailProps()
2969
- );
2970
- break;
3183
+ createWallet() {
3184
+ return __async(this, arguments, function* ({
3185
+ type: _type,
3186
+ skipDistribute = false
3187
+ } = {}) {
3188
+ var _a, _b;
3189
+ this.requireApiKey();
3190
+ const walletType = yield this.assertIsValidWalletType(
3191
+ _type != null ? _type : (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type
3192
+ );
3193
+ let signer;
3194
+ let wallet;
3195
+ let keygenRes;
3196
+ switch (walletType) {
3197
+ case import_user_management_client5.WalletType.SOLANA: {
3198
+ keygenRes = yield this.platformUtils.ed25519Keygen(
3199
+ this.ctx,
3200
+ this.userId,
3201
+ this.retrieveSessionCookie(),
3202
+ this.getBackupKitEmailProps()
3203
+ );
3204
+ break;
3205
+ }
3206
+ default: {
3207
+ keygenRes = yield this.platformUtils.keygen(
3208
+ this.ctx,
3209
+ this.userId,
3210
+ walletType,
3211
+ null,
3212
+ this.retrieveSessionCookie(),
3213
+ this.getBackupKitEmailProps()
3214
+ );
3215
+ break;
3216
+ }
2971
3217
  }
2972
- default: {
2973
- keygenRes = await this.platformUtils.keygen(
2974
- this.ctx,
2975
- this.userId,
2976
- walletType,
2977
- null,
2978
- this.retrieveSessionCookie(),
2979
- this.getBackupKitEmailProps()
2980
- );
2981
- break;
3218
+ const walletId = keygenRes.walletId;
3219
+ signer = keygenRes.signer;
3220
+ this.wallets[walletId] = {
3221
+ id: walletId,
3222
+ signer,
3223
+ scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
3224
+ type: walletType
3225
+ };
3226
+ wallet = this.wallets[walletId];
3227
+ yield this.waitForWalletAddress(wallet.id);
3228
+ yield this.populateWalletAddresses();
3229
+ let recoveryShare = null;
3230
+ if (!skipDistribute) {
3231
+ recoveryShare = yield distributeNewShare({
3232
+ ctx: this.ctx,
3233
+ userId: this.userId,
3234
+ walletId: wallet.id,
3235
+ userShare: signer,
3236
+ emailProps: this.getBackupKitEmailProps()
3237
+ });
2982
3238
  }
2983
- }
2984
- const walletId = keygenRes.walletId;
2985
- signer = keygenRes.signer;
2986
- this.wallets[walletId] = {
2987
- id: walletId,
2988
- signer,
2989
- scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
2990
- type: walletType
2991
- };
2992
- wallet = this.wallets[walletId];
2993
- await this.waitForWalletAddress(wallet.id);
2994
- await this.populateWalletAddresses();
2995
- let recoveryShare = null;
2996
- if (!skipDistribute) {
2997
- recoveryShare = await distributeNewShare({
2998
- ctx: this.ctx,
2999
- userId: this.userId,
3000
- walletId: wallet.id,
3001
- userShare: signer,
3002
- emailProps: this.getBackupKitEmailProps()
3239
+ yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
3240
+ [walletType]: [...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId]
3241
+ }));
3242
+ const walletNoSigner = __spreadValues({}, wallet);
3243
+ delete walletNoSigner.signer;
3244
+ dispatchEvent(ParaEvent.WALLET_CREATED, {
3245
+ wallet: walletNoSigner,
3246
+ recoverySecret: recoveryShare
3003
3247
  });
3004
- }
3005
- await this.setCurrentWalletIds({
3006
- ...this.currentWalletIds,
3007
- [walletType]: [...this.currentWalletIds[walletType] ?? [], walletId]
3008
- });
3009
- const walletNoSigner = { ...wallet };
3010
- delete walletNoSigner.signer;
3011
- dispatchEvent(ParaEvent.WALLET_CREATED, {
3012
- wallet: walletNoSigner,
3013
- recoverySecret: recoveryShare
3248
+ return [wallet, recoveryShare];
3014
3249
  });
3015
- return [wallet, recoveryShare];
3016
3250
  }
3017
3251
  /**
3018
3252
  * Creates a new pregenerated wallet.
@@ -3023,51 +3257,54 @@ var ParaCore = class _ParaCore {
3023
3257
  * @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
3024
3258
  * @returns {Wallet} the created wallet.
3025
3259
  **/
3026
- async createPregenWallet(opts) {
3027
- const {
3028
- type: _type = this.supportedWalletTypes.find(({ optional }) => !optional)?.type,
3029
- pregenIdentifier,
3030
- pregenIdentifierType = "EMAIL"
3031
- } = opts;
3032
- this.requireApiKey();
3033
- const walletType = await this.assertIsValidWalletType(
3034
- _type ?? this.supportedWalletTypes.find(({ optional }) => !optional)?.type
3035
- );
3036
- let keygenRes;
3037
- switch (walletType) {
3038
- case import_user_management_client5.WalletType.SOLANA:
3039
- keygenRes = await this.platformUtils.ed25519PreKeygen(
3040
- this.ctx,
3041
- pregenIdentifier,
3042
- pregenIdentifierType,
3043
- this.retrieveSessionCookie()
3044
- );
3045
- break;
3046
- default:
3047
- keygenRes = await this.platformUtils.preKeygen(
3048
- this.ctx,
3049
- void 0,
3050
- pregenIdentifier,
3051
- pregenIdentifierType,
3052
- walletType,
3053
- null,
3054
- this.retrieveSessionCookie()
3055
- );
3056
- break;
3057
- }
3058
- const { signer, walletId } = keygenRes;
3059
- this.wallets[walletId] = {
3060
- id: walletId,
3061
- signer,
3062
- scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
3063
- type: walletType,
3064
- isPregen: true,
3065
- pregenIdentifier,
3066
- pregenIdentifierType
3067
- };
3068
- await this.waitForPregenWalletAddress(walletId);
3069
- await this.populatePregenWalletAddresses();
3070
- return this.wallets[walletId];
3260
+ createPregenWallet(opts) {
3261
+ return __async(this, null, function* () {
3262
+ var _a, _b;
3263
+ const {
3264
+ type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
3265
+ pregenIdentifier,
3266
+ pregenIdentifierType = "EMAIL"
3267
+ } = opts;
3268
+ this.requireApiKey();
3269
+ const walletType = yield this.assertIsValidWalletType(
3270
+ _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
3271
+ );
3272
+ let keygenRes;
3273
+ switch (walletType) {
3274
+ case import_user_management_client5.WalletType.SOLANA:
3275
+ keygenRes = yield this.platformUtils.ed25519PreKeygen(
3276
+ this.ctx,
3277
+ pregenIdentifier,
3278
+ pregenIdentifierType,
3279
+ this.retrieveSessionCookie()
3280
+ );
3281
+ break;
3282
+ default:
3283
+ keygenRes = yield this.platformUtils.preKeygen(
3284
+ this.ctx,
3285
+ void 0,
3286
+ pregenIdentifier,
3287
+ pregenIdentifierType,
3288
+ walletType,
3289
+ null,
3290
+ this.retrieveSessionCookie()
3291
+ );
3292
+ break;
3293
+ }
3294
+ const { signer, walletId } = keygenRes;
3295
+ this.wallets[walletId] = {
3296
+ id: walletId,
3297
+ signer,
3298
+ scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
3299
+ type: walletType,
3300
+ isPregen: true,
3301
+ pregenIdentifier,
3302
+ pregenIdentifierType
3303
+ };
3304
+ yield this.waitForPregenWalletAddress(walletId);
3305
+ yield this.populatePregenWalletAddresses();
3306
+ return this.wallets[walletId];
3307
+ });
3071
3308
  }
3072
3309
  /**
3073
3310
  * Creates new pregenerated wallets for each desired type.
@@ -3079,17 +3316,19 @@ var ParaCore = class _ParaCore {
3079
3316
  * @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
3080
3317
  * @returns {Wallet[]} an array containing the created wallets.
3081
3318
  **/
3082
- async createPregenWalletPerType({
3083
- types,
3084
- pregenIdentifier,
3085
- pregenIdentifierType = "EMAIL"
3086
- }) {
3087
- const wallets = [];
3088
- for (const type of await this.getTypesToCreate(types)) {
3089
- const wallet = await this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
3090
- wallets.push(wallet);
3091
- }
3092
- return wallets;
3319
+ createPregenWalletPerType(_0) {
3320
+ return __async(this, arguments, function* ({
3321
+ types,
3322
+ pregenIdentifier,
3323
+ pregenIdentifierType = "EMAIL"
3324
+ }) {
3325
+ const wallets = [];
3326
+ for (const type of yield this.getTypesToCreate(types)) {
3327
+ const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
3328
+ wallets.push(wallet);
3329
+ }
3330
+ return wallets;
3331
+ });
3093
3332
  }
3094
3333
  /**
3095
3334
  * Claims a pregenerated wallet.
@@ -3099,63 +3338,71 @@ var ParaCore = class _ParaCore {
3099
3338
  * @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
3100
3339
  * @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
3101
3340
  **/
3102
- async claimPregenWallets({
3103
- pregenIdentifier,
3104
- pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3105
- } = {}) {
3106
- this.requireApiKey();
3107
- const pregenWallets = pregenIdentifier && pregenIdentifierType ? await this.getPregenWallets({ pregenIdentifier, pregenIdentifierType }) : await this.getPregenWallets();
3108
- if (pregenWallets.length === 0) {
3109
- return void 0;
3110
- }
3111
- let newRecoverySecret;
3112
- const { walletIds } = await this.ctx.client.claimPregenWallets({
3113
- userId: this.userId,
3114
- walletIds: pregenWallets.map((w) => w.id)
3115
- });
3116
- for (const walletId of walletIds) {
3117
- const wallet = this.wallets[walletId];
3118
- let refreshedShare;
3119
- if (wallet.scheme === import_user_management_client5.WalletScheme.ED25519) {
3120
- const distributeRes = await distributeNewShare({
3121
- ctx: this.ctx,
3341
+ claimPregenWallets() {
3342
+ return __async(this, arguments, function* ({
3343
+ pregenIdentifier,
3344
+ pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3345
+ } = {}) {
3346
+ var _a;
3347
+ this.requireApiKey();
3348
+ const pregenWallets = pregenIdentifier && pregenIdentifierType ? yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType }) : yield this.getPregenWallets();
3349
+ if (pregenWallets.length === 0) {
3350
+ return void 0;
3351
+ }
3352
+ const missingWallets = pregenWallets.filter((wallet) => !this.wallets[wallet.id]);
3353
+ if (missingWallets.length > 0) {
3354
+ throw new Error(
3355
+ `Cannot claim pregen wallets because wallet data is missing. Please call setUserShare first to load the wallet data for the following wallet IDs: ${missingWallets.map((w) => w.id).join(", ")}`
3356
+ );
3357
+ }
3358
+ let newRecoverySecret;
3359
+ const { walletIds } = yield this.ctx.client.claimPregenWallets({
3360
+ userId: this.userId,
3361
+ walletIds: pregenWallets.map((w) => w.id)
3362
+ });
3363
+ for (const walletId of walletIds) {
3364
+ const wallet = this.wallets[walletId];
3365
+ let refreshedShare;
3366
+ if (wallet.scheme === import_user_management_client5.WalletScheme.ED25519) {
3367
+ const distributeRes = yield distributeNewShare({
3368
+ ctx: this.ctx,
3369
+ userId: this.userId,
3370
+ walletId: wallet.id,
3371
+ userShare: this.wallets[wallet.id].signer,
3372
+ emailProps: this.getBackupKitEmailProps(),
3373
+ partnerId: wallet.partnerId
3374
+ });
3375
+ if (distributeRes.length > 0) {
3376
+ newRecoverySecret = distributeRes;
3377
+ }
3378
+ } else {
3379
+ refreshedShare = yield this.refreshShare({
3380
+ walletId: wallet.id,
3381
+ share: this.wallets[wallet.id].signer,
3382
+ oldPartnerId: wallet.partnerId,
3383
+ newPartnerId: wallet.partnerId,
3384
+ redistributeBackupEncryptedShares: true
3385
+ });
3386
+ if (refreshedShare.recoverySecret) {
3387
+ newRecoverySecret = refreshedShare.recoverySecret;
3388
+ }
3389
+ }
3390
+ this.wallets[wallet.id] = __spreadProps(__spreadValues({}, this.wallets[wallet.id]), {
3391
+ signer: (_a = refreshedShare == null ? void 0 : refreshedShare.signer) != null ? _a : wallet.signer,
3122
3392
  userId: this.userId,
3123
- walletId: wallet.id,
3124
- userShare: this.wallets[wallet.id].signer,
3125
- emailProps: this.getBackupKitEmailProps(),
3126
- partnerId: wallet.partnerId
3393
+ pregenIdentifier: void 0,
3394
+ pregenIdentifierType: void 0
3127
3395
  });
3128
- if (distributeRes.length > 0) {
3129
- newRecoverySecret = distributeRes;
3130
- }
3131
- } else {
3132
- refreshedShare = await this.refreshShare({
3133
- walletId: wallet.id,
3134
- share: this.wallets[wallet.id].signer,
3135
- oldPartnerId: wallet.partnerId,
3136
- newPartnerId: wallet.partnerId,
3137
- redistributeBackupEncryptedShares: true
3396
+ const walletNoSigner = __spreadValues({}, this.wallets[wallet.id]);
3397
+ delete walletNoSigner.signer;
3398
+ dispatchEvent(ParaEvent.PREGEN_WALLET_CLAIMED, {
3399
+ wallet: walletNoSigner,
3400
+ recoverySecret: newRecoverySecret
3138
3401
  });
3139
- if (refreshedShare.recoverySecret) {
3140
- newRecoverySecret = refreshedShare.recoverySecret;
3141
- }
3142
3402
  }
3143
- this.wallets[wallet.id] = {
3144
- ...this.wallets[wallet.id],
3145
- signer: refreshedShare?.signer ?? wallet.signer,
3146
- userId: this.userId,
3147
- pregenIdentifier: void 0,
3148
- pregenIdentifierType: void 0
3149
- };
3150
- const walletNoSigner = { ...this.wallets[wallet.id] };
3151
- delete walletNoSigner.signer;
3152
- dispatchEvent(ParaEvent.PREGEN_WALLET_CLAIMED, {
3153
- wallet: walletNoSigner,
3154
- recoverySecret: newRecoverySecret
3155
- });
3156
- }
3157
- await this.setWallets(this.wallets);
3158
- return newRecoverySecret;
3403
+ yield this.setWallets(this.wallets);
3404
+ return newRecoverySecret;
3405
+ });
3159
3406
  }
3160
3407
  /**
3161
3408
  * Updates the identifier for a pregen wallet.
@@ -3164,24 +3411,25 @@ var ParaCore = class _ParaCore {
3164
3411
  * @param {string} opts.newPregenIdentifier the new identtifier
3165
3412
  * @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
3166
3413
  **/
3167
- async updatePregenWalletIdentifier({
3168
- walletId,
3169
- newPregenIdentifier,
3170
- newPregenIdentifierType
3171
- }) {
3172
- this.requireApiKey();
3173
- await this.ctx.client.updatePregenWallet(walletId, {
3174
- pregenIdentifier: newPregenIdentifier,
3175
- pregenIdentifierType: newPregenIdentifierType
3176
- });
3177
- if (!!this.wallets[walletId]) {
3178
- this.wallets[walletId] = {
3179
- ...this.wallets[walletId],
3414
+ updatePregenWalletIdentifier(_0) {
3415
+ return __async(this, arguments, function* ({
3416
+ walletId,
3417
+ newPregenIdentifier,
3418
+ newPregenIdentifierType
3419
+ }) {
3420
+ this.requireApiKey();
3421
+ yield this.ctx.client.updatePregenWallet(walletId, {
3180
3422
  pregenIdentifier: newPregenIdentifier,
3181
3423
  pregenIdentifierType: newPregenIdentifierType
3182
- };
3183
- await this.setWallets(this.wallets);
3184
- }
3424
+ });
3425
+ if (!!this.wallets[walletId]) {
3426
+ this.wallets[walletId] = __spreadProps(__spreadValues({}, this.wallets[walletId]), {
3427
+ pregenIdentifier: newPregenIdentifier,
3428
+ pregenIdentifierType: newPregenIdentifierType
3429
+ });
3430
+ yield this.setWallets(this.wallets);
3431
+ }
3432
+ });
3185
3433
  }
3186
3434
  /**
3187
3435
  * Checks if a pregen Wallet exists for the given identifier with the current partner.
@@ -3190,17 +3438,19 @@ var ParaCore = class _ParaCore {
3190
3438
  * @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
3191
3439
  * @returns {boolean} whether the pregen wallet exists
3192
3440
  **/
3193
- async hasPregenWallet({
3194
- pregenIdentifier,
3195
- pregenIdentifierType
3196
- }) {
3197
- this.requireApiKey();
3198
- const res = await this.getPregenWallets({ pregenIdentifier, pregenIdentifierType });
3199
- const wallet = res.find((w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType);
3200
- if (!wallet) {
3201
- return false;
3202
- }
3203
- return true;
3441
+ hasPregenWallet(_0) {
3442
+ return __async(this, arguments, function* ({
3443
+ pregenIdentifier,
3444
+ pregenIdentifierType
3445
+ }) {
3446
+ this.requireApiKey();
3447
+ const res = yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType });
3448
+ const wallet = res.find((w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType);
3449
+ if (!wallet) {
3450
+ return false;
3451
+ }
3452
+ return true;
3453
+ });
3204
3454
  }
3205
3455
  /**
3206
3456
  * Get pregen wallets for the given identifier.
@@ -3209,17 +3459,19 @@ var ParaCore = class _ParaCore {
3209
3459
  * @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
3210
3460
  * @returns {Promise<WalletEntity[]>} the array of found wallets
3211
3461
  **/
3212
- async getPregenWallets({
3213
- pregenIdentifier,
3214
- pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3215
- } = {}) {
3216
- this.requireApiKey();
3217
- const res = await this.ctx.client.getPregenWallets(
3218
- pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds,
3219
- this.isPortal(),
3220
- this.userId
3221
- );
3222
- return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
3462
+ getPregenWallets() {
3463
+ return __async(this, arguments, function* ({
3464
+ pregenIdentifier,
3465
+ pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3466
+ } = {}) {
3467
+ this.requireApiKey();
3468
+ const res = yield this.ctx.client.getPregenWallets(
3469
+ pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds,
3470
+ this.isPortal(),
3471
+ this.userId
3472
+ );
3473
+ return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
3474
+ });
3223
3475
  }
3224
3476
  encodeWalletBase64(wallet) {
3225
3477
  const walletJson = JSON.stringify(wallet);
@@ -3240,45 +3492,54 @@ var ParaCore = class _ParaCore {
3240
3492
  * Sets the current wallets from a Base 64 string.
3241
3493
  * @param {string} base64Wallet the encoded wallet string
3242
3494
  **/
3243
- async setUserShare(base64Wallets) {
3244
- if (!base64Wallets) {
3245
- return;
3246
- }
3247
- const base64WalletsSplit = base64Wallets.split("-");
3248
- for (const base64Wallet of base64WalletsSplit) {
3249
- const walletJson = Buffer.from(base64Wallet, "base64").toString();
3250
- const wallet = migrateWallet(JSON.parse(walletJson));
3251
- this.wallets[wallet.id] = wallet;
3252
- await this.setWallets(this.wallets);
3253
- }
3254
- }
3255
- async getTransactionReviewUrl(transactionId, timeoutMs) {
3256
- const res = await this.touchSession();
3257
- return this.constructPortalUrl("txReview", {
3258
- partnerId: res.data.partnerId,
3259
- pathId: transactionId,
3260
- params: {
3261
- email: this.email,
3262
- timeoutMs: timeoutMs?.toString()
3495
+ setUserShare(base64Wallets) {
3496
+ return __async(this, null, function* () {
3497
+ if (!base64Wallets) {
3498
+ return;
3499
+ }
3500
+ const base64WalletsSplit = base64Wallets.split("-");
3501
+ for (const base64Wallet of base64WalletsSplit) {
3502
+ const walletJson = Buffer.from(base64Wallet, "base64").toString();
3503
+ const wallet = migrateWallet(JSON.parse(walletJson));
3504
+ this.wallets[wallet.id] = wallet;
3505
+ yield this.setWallets(this.wallets);
3263
3506
  }
3264
3507
  });
3265
3508
  }
3266
- async getOnRampTransactionUrl({
3267
- purchaseId,
3268
- providerKey,
3269
- ...walletParams
3270
- }) {
3271
- const res = await this.touchSession();
3272
- const [key, identifier] = (0, import_user_management_client5.extractWalletRef)(walletParams);
3273
- return this.constructPortalUrl("onRamp", {
3274
- partnerId: res.data.partnerId,
3275
- pathId: purchaseId,
3276
- sessionId: res.data.sessionId,
3277
- params: {
3278
- [key]: identifier,
3279
- providerKey,
3280
- currentWalletIds: JSON.stringify(this.currentWalletIds)
3281
- }
3509
+ getTransactionReviewUrl(transactionId, timeoutMs) {
3510
+ return __async(this, null, function* () {
3511
+ const res = yield this.touchSession();
3512
+ return this.constructPortalUrl("txReview", {
3513
+ partnerId: res.data.partnerId,
3514
+ pathId: transactionId,
3515
+ params: {
3516
+ email: this.email,
3517
+ timeoutMs: timeoutMs == null ? void 0 : timeoutMs.toString()
3518
+ }
3519
+ });
3520
+ });
3521
+ }
3522
+ getOnRampTransactionUrl(_i) {
3523
+ return __async(this, null, function* () {
3524
+ var _j = _i, {
3525
+ purchaseId,
3526
+ providerKey
3527
+ } = _j, walletParams = __objRest(_j, [
3528
+ "purchaseId",
3529
+ "providerKey"
3530
+ ]);
3531
+ const res = yield this.touchSession();
3532
+ const [key, identifier] = (0, import_user_management_client5.extractWalletRef)(walletParams);
3533
+ return this.constructPortalUrl("onRamp", {
3534
+ partnerId: res.data.partnerId,
3535
+ pathId: purchaseId,
3536
+ sessionId: res.data.sessionId,
3537
+ params: {
3538
+ [key]: identifier,
3539
+ providerKey,
3540
+ currentWalletIds: JSON.stringify(this.currentWalletIds)
3541
+ }
3542
+ });
3282
3543
  });
3283
3544
  }
3284
3545
  /**
@@ -3292,91 +3553,95 @@ var ParaCore = class _ParaCore {
3292
3553
  * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
3293
3554
  * @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
3294
3555
  **/
3295
- async signMessage({
3296
- walletId,
3297
- messageBase64,
3298
- timeoutMs = 3e4,
3299
- cosmosSignDocBase64
3300
- }) {
3301
- this.assertIsValidWalletId(walletId);
3302
- const wallet = this.wallets[walletId];
3303
- let signerId = this.userId;
3304
- if (wallet.partnerId && !wallet.userId) {
3305
- signerId = wallet.partnerId;
3306
- }
3307
- let signRes = await this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3308
- let timeStart = Date.now();
3309
- if (signRes.pendingTransactionId) {
3310
- this.platformUtils.openPopup(
3311
- await this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3312
- { type: cosmosSignDocBase64 ? "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ : "SIGN_MESSAGE_REVIEW" /* SIGN_MESSAGE_REVIEW */ }
3313
- );
3314
- } else {
3315
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3316
- return signRes;
3317
- }
3318
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3319
- while (true) {
3320
- if (Date.now() - timeStart > timeoutMs) {
3321
- break;
3322
- }
3323
- try {
3324
- await this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3325
- } catch (err) {
3326
- const error = new TransactionReviewDenied();
3327
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3328
- throw error;
3556
+ signMessage(_0) {
3557
+ return __async(this, arguments, function* ({
3558
+ walletId,
3559
+ messageBase64,
3560
+ timeoutMs = 3e4,
3561
+ cosmosSignDocBase64
3562
+ }) {
3563
+ this.assertIsValidWalletId(walletId);
3564
+ const wallet = this.wallets[walletId];
3565
+ let signerId = this.userId;
3566
+ if (wallet.partnerId && !wallet.userId) {
3567
+ signerId = wallet.partnerId;
3329
3568
  }
3330
- signRes = await this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3569
+ let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3570
+ let timeStart = Date.now();
3331
3571
  if (signRes.pendingTransactionId) {
3332
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3572
+ this.platformUtils.openPopup(
3573
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3574
+ { type: cosmosSignDocBase64 ? "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ : "SIGN_MESSAGE_REVIEW" /* SIGN_MESSAGE_REVIEW */ }
3575
+ );
3333
3576
  } else {
3334
- break;
3577
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3578
+ return signRes;
3335
3579
  }
3336
- }
3337
- if (signRes.pendingTransactionId) {
3338
- const error = new TransactionReviewTimeout(
3339
- await this.getTransactionReviewUrl(signRes.pendingTransactionId),
3340
- signRes.pendingTransactionId
3341
- );
3342
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3343
- throw error;
3344
- }
3345
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3346
- return signRes;
3347
- }
3348
- async signMessageInner({
3349
- wallet,
3350
- signerId,
3351
- messageBase64,
3352
- cosmosSignDocBase64
3353
- }) {
3354
- let signRes;
3355
- switch (wallet.scheme) {
3356
- case import_user_management_client5.WalletScheme.ED25519:
3357
- signRes = await this.platformUtils.ed25519Sign(
3358
- this.ctx,
3359
- signerId,
3360
- wallet.id,
3361
- wallet.signer,
3362
- messageBase64,
3363
- this.retrieveSessionCookie()
3364
- );
3365
- break;
3366
- default:
3367
- signRes = await this.platformUtils.signMessage(
3368
- this.ctx,
3369
- signerId,
3370
- wallet.id,
3371
- wallet.signer,
3372
- messageBase64,
3373
- this.retrieveSessionCookie(),
3374
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS,
3375
- cosmosSignDocBase64
3580
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3581
+ while (true) {
3582
+ if (Date.now() - timeStart > timeoutMs) {
3583
+ break;
3584
+ }
3585
+ try {
3586
+ yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3587
+ } catch (err) {
3588
+ const error = new TransactionReviewDenied();
3589
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3590
+ throw error;
3591
+ }
3592
+ signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3593
+ if (signRes.pendingTransactionId) {
3594
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3595
+ } else {
3596
+ break;
3597
+ }
3598
+ }
3599
+ if (signRes.pendingTransactionId) {
3600
+ const error = new TransactionReviewTimeout(
3601
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3602
+ signRes.pendingTransactionId
3376
3603
  );
3377
- break;
3378
- }
3379
- return signRes;
3604
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3605
+ throw error;
3606
+ }
3607
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3608
+ return signRes;
3609
+ });
3610
+ }
3611
+ signMessageInner(_0) {
3612
+ return __async(this, arguments, function* ({
3613
+ wallet,
3614
+ signerId,
3615
+ messageBase64,
3616
+ cosmosSignDocBase64
3617
+ }) {
3618
+ let signRes;
3619
+ switch (wallet.scheme) {
3620
+ case import_user_management_client5.WalletScheme.ED25519:
3621
+ signRes = yield this.platformUtils.ed25519Sign(
3622
+ this.ctx,
3623
+ signerId,
3624
+ wallet.id,
3625
+ wallet.signer,
3626
+ messageBase64,
3627
+ this.retrieveSessionCookie()
3628
+ );
3629
+ break;
3630
+ default:
3631
+ signRes = yield this.platformUtils.signMessage(
3632
+ this.ctx,
3633
+ signerId,
3634
+ wallet.id,
3635
+ wallet.signer,
3636
+ messageBase64,
3637
+ this.retrieveSessionCookie(),
3638
+ wallet.scheme === import_user_management_client5.WalletScheme.DKLS,
3639
+ cosmosSignDocBase64
3640
+ );
3641
+ break;
3642
+ }
3643
+ return signRes;
3644
+ });
3380
3645
  }
3381
3646
  /**
3382
3647
  * Signs a transaction.
@@ -3386,51 +3651,20 @@ var ParaCore = class _ParaCore {
3386
3651
  * @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
3387
3652
  * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
3388
3653
  **/
3389
- async signTransaction({
3390
- walletId,
3391
- rlpEncodedTxBase64,
3392
- chainId,
3393
- timeoutMs = 3e4
3394
- }) {
3395
- this.assertIsValidWalletId(walletId);
3396
- const wallet = this.wallets[walletId];
3397
- let signerId = this.userId;
3398
- if (wallet.partnerId && !wallet.userId) {
3399
- signerId = wallet.partnerId;
3400
- }
3401
- let signRes = await this.platformUtils.signTransaction(
3402
- this.ctx,
3403
- signerId,
3654
+ signTransaction(_0) {
3655
+ return __async(this, arguments, function* ({
3404
3656
  walletId,
3405
- this.wallets[walletId].signer,
3406
3657
  rlpEncodedTxBase64,
3407
3658
  chainId,
3408
- this.retrieveSessionCookie(),
3409
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3410
- );
3411
- let timeStart = Date.now();
3412
- if (signRes.pendingTransactionId) {
3413
- this.platformUtils.openPopup(
3414
- await this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3415
- { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3416
- );
3417
- } else {
3418
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3419
- return signRes;
3420
- }
3421
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3422
- while (true) {
3423
- if (Date.now() - timeStart > timeoutMs) {
3424
- break;
3425
- }
3426
- try {
3427
- await this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3428
- } catch (err) {
3429
- const error = new TransactionReviewDenied();
3430
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3431
- throw error;
3659
+ timeoutMs = 3e4
3660
+ }) {
3661
+ this.assertIsValidWalletId(walletId);
3662
+ const wallet = this.wallets[walletId];
3663
+ let signerId = this.userId;
3664
+ if (wallet.partnerId && !wallet.userId) {
3665
+ signerId = wallet.partnerId;
3432
3666
  }
3433
- signRes = await this.platformUtils.signTransaction(
3667
+ let signRes = yield this.platformUtils.signTransaction(
3434
3668
  this.ctx,
3435
3669
  signerId,
3436
3670
  walletId,
@@ -3440,22 +3674,55 @@ var ParaCore = class _ParaCore {
3440
3674
  this.retrieveSessionCookie(),
3441
3675
  wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3442
3676
  );
3677
+ let timeStart = Date.now();
3443
3678
  if (signRes.pendingTransactionId) {
3444
- await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3679
+ this.platformUtils.openPopup(
3680
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3681
+ { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3682
+ );
3445
3683
  } else {
3446
- break;
3684
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3685
+ return signRes;
3447
3686
  }
3448
- }
3449
- if (signRes.pendingTransactionId) {
3450
- const error = new TransactionReviewTimeout(
3451
- await this.getTransactionReviewUrl(signRes.pendingTransactionId),
3452
- signRes.pendingTransactionId
3453
- );
3454
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3455
- throw error;
3456
- }
3457
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3458
- return signRes;
3687
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3688
+ while (true) {
3689
+ if (Date.now() - timeStart > timeoutMs) {
3690
+ break;
3691
+ }
3692
+ try {
3693
+ yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3694
+ } catch (err) {
3695
+ const error = new TransactionReviewDenied();
3696
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3697
+ throw error;
3698
+ }
3699
+ signRes = yield this.platformUtils.signTransaction(
3700
+ this.ctx,
3701
+ signerId,
3702
+ walletId,
3703
+ this.wallets[walletId].signer,
3704
+ rlpEncodedTxBase64,
3705
+ chainId,
3706
+ this.retrieveSessionCookie(),
3707
+ wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3708
+ );
3709
+ if (signRes.pendingTransactionId) {
3710
+ yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3711
+ } else {
3712
+ break;
3713
+ }
3714
+ }
3715
+ if (signRes.pendingTransactionId) {
3716
+ const error = new TransactionReviewTimeout(
3717
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3718
+ signRes.pendingTransactionId
3719
+ );
3720
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3721
+ throw error;
3722
+ }
3723
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3724
+ return signRes;
3725
+ });
3459
3726
  }
3460
3727
  /**
3461
3728
  * @deprecated
@@ -3464,34 +3731,36 @@ var ParaCore = class _ParaCore {
3464
3731
  * @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
3465
3732
  * @param chainId - chain id of the chain the transaction is being sent on.
3466
3733
  **/
3467
- async sendTransaction({
3468
- walletId,
3469
- rlpEncodedTxBase64,
3470
- chainId
3471
- }) {
3472
- this.assertIsValidWalletId(walletId);
3473
- const wallet = this.wallets[walletId];
3474
- const signRes = await this.platformUtils.sendTransaction(
3475
- this.ctx,
3476
- this.userId,
3734
+ sendTransaction(_0) {
3735
+ return __async(this, arguments, function* ({
3477
3736
  walletId,
3478
- this.wallets[walletId].signer,
3479
3737
  rlpEncodedTxBase64,
3480
- chainId,
3481
- this.retrieveSessionCookie(),
3482
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3483
- );
3484
- if (signRes.pendingTransactionId) {
3485
- this.platformUtils.openPopup(
3486
- await this.getTransactionReviewUrl(signRes.pendingTransactionId),
3487
- { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3488
- );
3489
- const error = new TransactionReviewError(
3490
- await this.getTransactionReviewUrl(signRes.pendingTransactionId)
3738
+ chainId
3739
+ }) {
3740
+ this.assertIsValidWalletId(walletId);
3741
+ const wallet = this.wallets[walletId];
3742
+ const signRes = yield this.platformUtils.sendTransaction(
3743
+ this.ctx,
3744
+ this.userId,
3745
+ walletId,
3746
+ this.wallets[walletId].signer,
3747
+ rlpEncodedTxBase64,
3748
+ chainId,
3749
+ this.retrieveSessionCookie(),
3750
+ wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3491
3751
  );
3492
- throw error;
3493
- }
3494
- return signRes;
3752
+ if (signRes.pendingTransactionId) {
3753
+ this.platformUtils.openPopup(
3754
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3755
+ { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3756
+ );
3757
+ const error = new TransactionReviewError(
3758
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId)
3759
+ );
3760
+ throw error;
3761
+ }
3762
+ return signRes;
3763
+ });
3495
3764
  }
3496
3765
  isProviderModalDisabled() {
3497
3766
  return !!this.disableProviderModal;
@@ -3504,36 +3773,38 @@ var ParaCore = class _ParaCore {
3504
3773
  * @param {string} opts.walletId the wallet ID to use for the transaction, where funds will be sent or withdrawn.
3505
3774
  * @param {string} opts.externalWalletAddress the external wallet address to send funds to or withdraw funds from, if using an external wallet.
3506
3775
  **/
3507
- async initiateOnRampTransaction(options) {
3508
- const { params, shouldOpenPopup, ...walletParams } = options;
3509
- const onRampPurchase = await this.ctx.client.createOnRampPurchase({
3510
- userId: this.userId,
3511
- params: {
3512
- ...params,
3513
- address: walletParams.externalWalletAddress ?? this.getDisplayAddress(walletParams.walletId, { addressType: params.walletType })
3514
- },
3515
- ...walletParams
3516
- });
3517
- const portalUrl = await this.getOnRampTransactionUrl({
3518
- purchaseId: onRampPurchase.id,
3519
- providerKey: onRampPurchase.providerKey,
3520
- ...walletParams
3776
+ initiateOnRampTransaction(options) {
3777
+ return __async(this, null, function* () {
3778
+ var _b;
3779
+ const _a = options, { params, shouldOpenPopup } = _a, walletParams = __objRest(_a, ["params", "shouldOpenPopup"]);
3780
+ const onRampPurchase = yield this.ctx.client.createOnRampPurchase(__spreadValues({
3781
+ userId: this.userId,
3782
+ params: __spreadProps(__spreadValues({}, params), {
3783
+ address: (_b = walletParams.externalWalletAddress) != null ? _b : this.getDisplayAddress(walletParams.walletId, { addressType: params.walletType })
3784
+ })
3785
+ }, walletParams));
3786
+ const portalUrl = yield this.getOnRampTransactionUrl(__spreadValues({
3787
+ purchaseId: onRampPurchase.id,
3788
+ providerKey: onRampPurchase.providerKey
3789
+ }, walletParams));
3790
+ if (shouldOpenPopup) {
3791
+ this.platformUtils.openPopup(portalUrl, { type: "ON_RAMP_TRANSACTION" /* ON_RAMP_TRANSACTION */ });
3792
+ }
3793
+ return { onRampPurchase, portalUrl };
3521
3794
  });
3522
- if (shouldOpenPopup) {
3523
- this.platformUtils.openPopup(portalUrl, { type: "ON_RAMP_TRANSACTION" /* ON_RAMP_TRANSACTION */ });
3524
- }
3525
- return { onRampPurchase, portalUrl };
3526
3795
  }
3527
3796
  /**
3528
3797
  * Returns `true` if session was successfully kept alive, `false` otherwise.
3529
3798
  **/
3530
- async keepSessionAlive() {
3531
- try {
3532
- await this.ctx.client.keepSessionAlive(this.userId);
3533
- return true;
3534
- } catch (err) {
3535
- return false;
3536
- }
3799
+ keepSessionAlive() {
3800
+ return __async(this, null, function* () {
3801
+ try {
3802
+ yield this.ctx.client.keepSessionAlive(this.userId);
3803
+ return true;
3804
+ } catch (err) {
3805
+ return false;
3806
+ }
3807
+ });
3537
3808
  }
3538
3809
  /**
3539
3810
  * Serialize the current session for import by another Para instance.
@@ -3558,34 +3829,37 @@ var ParaCore = class _ParaCore {
3558
3829
  * Imports a session serialized by another Para instance.
3559
3830
  * @param {string} serializedInstanceBase64 the serialized session
3560
3831
  */
3561
- async importSession(serializedInstanceBase64) {
3562
- const serializedInstance = Buffer.from(serializedInstanceBase64, "base64").toString("utf8");
3563
- const sessionInfo = JSON.parse(serializedInstance);
3564
- await this.setEmail(sessionInfo.email);
3565
- await this.setTelegramUserId(sessionInfo.telegramUserId);
3566
- await this.setFarcasterUsername(sessionInfo.farcasterUsername);
3567
- await this.setUserId(sessionInfo.userId);
3568
- await this.setWallets(sessionInfo.wallets);
3569
- await this.setExternalWallets(sessionInfo.externalWallets || {});
3570
- for (const walletId of Object.keys(this.wallets)) {
3571
- if (!this.wallets[walletId].userId) {
3572
- this.wallets[walletId].userId = this.userId;
3832
+ importSession(serializedInstanceBase64) {
3833
+ return __async(this, null, function* () {
3834
+ var _a;
3835
+ const serializedInstance = Buffer.from(serializedInstanceBase64, "base64").toString("utf8");
3836
+ const sessionInfo = JSON.parse(serializedInstance);
3837
+ yield this.setEmail(sessionInfo.email);
3838
+ yield this.setTelegramUserId(sessionInfo.telegramUserId);
3839
+ yield this.setFarcasterUsername(sessionInfo.farcasterUsername);
3840
+ yield this.setUserId(sessionInfo.userId);
3841
+ yield this.setWallets(sessionInfo.wallets);
3842
+ yield this.setExternalWallets(sessionInfo.externalWallets || {});
3843
+ for (const walletId of Object.keys(this.wallets)) {
3844
+ if (!this.wallets[walletId].userId) {
3845
+ this.wallets[walletId].userId = this.userId;
3846
+ }
3573
3847
  }
3574
- }
3575
- if (Object.keys(sessionInfo.currentWalletIds).length !== 0) {
3576
- await this.setCurrentWalletIds(sessionInfo.currentWalletIds);
3577
- } else {
3578
- const currentWalletIds = {};
3579
- for (const walletId of Object.keys(sessionInfo.wallets)) {
3580
- currentWalletIds[sessionInfo.wallets[walletId].type] = [
3581
- ...currentWalletIds[sessionInfo.wallets[walletId].type] ?? [],
3582
- walletId
3583
- ];
3848
+ if (Object.keys(sessionInfo.currentWalletIds).length !== 0) {
3849
+ yield this.setCurrentWalletIds(sessionInfo.currentWalletIds);
3850
+ } else {
3851
+ const currentWalletIds = {};
3852
+ for (const walletId of Object.keys(sessionInfo.wallets)) {
3853
+ currentWalletIds[sessionInfo.wallets[walletId].type] = [
3854
+ ...(_a = currentWalletIds[sessionInfo.wallets[walletId].type]) != null ? _a : [],
3855
+ walletId
3856
+ ];
3857
+ }
3858
+ yield this.setCurrentWalletIds(currentWalletIds);
3584
3859
  }
3585
- await this.setCurrentWalletIds(currentWalletIds);
3586
- }
3587
- this.persistSessionCookie(sessionInfo.sessionCookie);
3588
- await this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
3860
+ this.persistSessionCookie(sessionInfo.sessionCookie);
3861
+ yield this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
3862
+ });
3589
3863
  }
3590
3864
  exitAccountCreation() {
3591
3865
  this.isAwaitingAccountCreation = false;
@@ -3609,48 +3883,54 @@ var ParaCore = class _ParaCore {
3609
3883
  * Retrieves a token to verify the current session.
3610
3884
  * @returns {Promise<string>} the ID
3611
3885
  **/
3612
- async getVerificationToken() {
3613
- const { data } = await this.touchSession();
3614
- return data.sessionLookupId;
3886
+ getVerificationToken() {
3887
+ return __async(this, null, function* () {
3888
+ const { data } = yield this.touchSession();
3889
+ return data.sessionLookupId;
3890
+ });
3615
3891
  }
3616
3892
  /**
3617
3893
  * Logs the user out.
3618
3894
  * @param {Object} opts the options object.
3619
3895
  * @param {boolean} opts.clearPregenWallets if `true`, will remove all pregen wallets from storage
3620
3896
  **/
3621
- async logout({ clearPregenWallets = false } = {}) {
3622
- await this.ctx.client.logout();
3623
- await this.clearStorage();
3624
- if (!clearPregenWallets) {
3625
- Object.entries(this.wallets).forEach(([id, wallet]) => {
3626
- if (!wallet.pregenIdentifier) {
3627
- delete this.wallets[id];
3628
- }
3629
- });
3630
- await this.setWallets(this.wallets);
3631
- } else {
3632
- this.wallets = {};
3633
- }
3634
- this.currentWalletIds = {};
3635
- this.externalWallets = {};
3636
- this.loginEncryptionKeyPair = void 0;
3637
- this.email = void 0;
3638
- this.telegramUserId = void 0;
3639
- this.phone = void 0;
3640
- this.countryCode = void 0;
3641
- this.userId = void 0;
3642
- this.sessionCookie = void 0;
3643
- dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
3644
- }
3645
- async getSupportedCreateAuthMethods() {
3646
- const res = await this.touchSession();
3647
- const partnerId = res.data.partnerId;
3648
- const partnerRes = await this.ctx.client.getPartner(partnerId);
3649
- let supportedAuthMethods = /* @__PURE__ */ new Set();
3650
- for (const authMethod of partnerRes.data.partner.supportedAuthMethods) {
3651
- supportedAuthMethods.add(import_user_management_client5.AuthMethod[authMethod]);
3652
- }
3653
- return supportedAuthMethods;
3897
+ logout() {
3898
+ return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
3899
+ yield this.ctx.client.logout();
3900
+ yield this.clearStorage();
3901
+ if (!clearPregenWallets) {
3902
+ Object.entries(this.wallets).forEach(([id, wallet]) => {
3903
+ if (!wallet.pregenIdentifier) {
3904
+ delete this.wallets[id];
3905
+ }
3906
+ });
3907
+ yield this.setWallets(this.wallets);
3908
+ } else {
3909
+ this.wallets = {};
3910
+ }
3911
+ this.currentWalletIds = {};
3912
+ this.externalWallets = {};
3913
+ this.loginEncryptionKeyPair = void 0;
3914
+ this.email = void 0;
3915
+ this.telegramUserId = void 0;
3916
+ this.phone = void 0;
3917
+ this.countryCode = void 0;
3918
+ this.userId = void 0;
3919
+ this.sessionCookie = void 0;
3920
+ dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
3921
+ });
3922
+ }
3923
+ getSupportedCreateAuthMethods() {
3924
+ return __async(this, null, function* () {
3925
+ const res = yield this.touchSession();
3926
+ const partnerId = res.data.partnerId;
3927
+ const partnerRes = yield this.ctx.client.getPartner(partnerId);
3928
+ let supportedAuthMethods = /* @__PURE__ */ new Set();
3929
+ for (const authMethod of partnerRes.data.partner.supportedAuthMethods) {
3930
+ supportedAuthMethods.add(import_user_management_client5.AuthMethod[authMethod]);
3931
+ }
3932
+ return supportedAuthMethods;
3933
+ });
3654
3934
  }
3655
3935
  /**
3656
3936
  * Converts to a string, removing sensitive data when logging this class.
@@ -3659,12 +3939,10 @@ var ParaCore = class _ParaCore {
3659
3939
  **/
3660
3940
  toString() {
3661
3941
  const redactedWallets = Object.keys(this.wallets).reduce(
3662
- (acc, walletId) => ({
3663
- ...acc,
3664
- [walletId]: {
3665
- ...this.wallets[walletId],
3942
+ (acc, walletId) => __spreadProps(__spreadValues({}, acc), {
3943
+ [walletId]: __spreadProps(__spreadValues({}, this.wallets[walletId]), {
3666
3944
  signer: this.wallets[walletId].signer ? "[REDACTED]" : void 0
3667
- }
3945
+ })
3668
3946
  }),
3669
3947
  {}
3670
3948
  );
@@ -3695,6 +3973,10 @@ var ParaCore = class _ParaCore {
3695
3973
  return `Para ${JSON.stringify(obj, null, 2)}`;
3696
3974
  }
3697
3975
  };
3976
+ _supportedWalletTypes = new WeakMap();
3977
+ _supportedWalletTypesOpt = new WeakMap();
3978
+ _ParaCore.version = PARA_CORE_VERSION;
3979
+ var ParaCore = _ParaCore;
3698
3980
 
3699
3981
  // src/index.ts
3700
3982
  var import_user_management_client6 = require("@getpara/user-management-client");