@getpara/core-sdk 1.4.5-dev.0 → 1.5.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,41 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  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
- };
39
7
  var __export = (target, all) => {
40
8
  for (var name in all)
41
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,30 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
57
25
  mod
58
26
  ));
59
27
  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
- };
84
28
 
85
29
  // src/index.ts
86
30
  var src_exports = {};
@@ -166,7 +110,7 @@ var import_node_forge = __toESM(require("node-forge"));
166
110
  // src/utils/events.ts
167
111
  function dispatchEvent(type, data, error) {
168
112
  typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
169
- new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
113
+ new CustomEvent(type, { detail: { data, ...error && { error: new Error(error) } } })
170
114
  );
171
115
  }
172
116
 
@@ -233,8 +177,7 @@ function truncateAddress(str, addressType, { prefix = addressType === "COSMOS" ?
233
177
  return `${str.slice(0, headLength)}...${str.slice(-4)}`;
234
178
  }
235
179
  function stringToPhoneNumber(str) {
236
- var _a;
237
- return (_a = (0, import_libphonenumber_js.default)(str)) == null ? void 0 : _a.formatInternational().replace(/[^\d+]/g, "");
180
+ return (0, import_libphonenumber_js.default)(str)?.formatInternational().replace(/[^\d+]/g, "");
238
181
  }
239
182
  function normalizePhoneNumber(countryCode, number) {
240
183
  return stringToPhoneNumber(`${countryCode[0] !== "+" ? "+" : ""}${countryCode}${number}`);
@@ -277,17 +220,15 @@ function getOnRampAssets(data, {
277
220
  }
278
221
 
279
222
  // src/utils/polling.ts
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));
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;
288
228
  }
289
- return false;
290
- });
229
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
230
+ }
231
+ return false;
291
232
  }
292
233
 
293
234
  // src/types/config.ts
@@ -461,10 +402,7 @@ function isPregenIdentifierMatch(a, b, type) {
461
402
  }
462
403
  }
463
404
  function isWalletSupported(types, wallet) {
464
- return types.some((walletType) => {
465
- var _a;
466
- return !!((_a = WalletSchemeTypeMap[wallet == null ? void 0 : wallet.scheme]) == null ? void 0 : _a[walletType]);
467
- });
405
+ return types.some((walletType) => !!WalletSchemeTypeMap[wallet?.scheme]?.[walletType]);
468
406
  }
469
407
  function getSchemes(types) {
470
408
  return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
@@ -487,11 +425,12 @@ function getEquivalentTypes(types) {
487
425
  return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map((t) => import_user_management_client.WalletType[t])));
488
426
  }
489
427
  function entityToWallet(w) {
490
- return __spreadProps(__spreadValues({}, w), {
428
+ return {
429
+ ...w,
491
430
  scheme: w.scheme,
492
431
  type: w.type,
493
432
  pregenIdentifierType: w.pregenIdentifierType
494
- });
433
+ };
495
434
  }
496
435
  function migrateWallet(obj) {
497
436
  if (["USER", "PREGEN"].includes(obj.type)) {
@@ -533,87 +472,79 @@ function decodePrivateKeyPemHex(privateKeyPemHex) {
533
472
  const pem = Buffer.from(privateKeyPemHex, "hex").toString("utf-8");
534
473
  return import_node_forge.default.pki.privateKeyFromPem(pem);
535
474
  }
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
- });
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");
557
494
  }
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
- });
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;
579
514
  }
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
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);
593
521
  };
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
- });
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
+ );
610
543
  }
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
- });
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);
617
548
  }
618
549
  function symmetricKeyEncryptMessage(message) {
619
550
  const key = import_node_forge.default.random.getBytesSync(16);
@@ -641,57 +572,49 @@ function decryptWithPrivateKey(privateKey, encryptedMessageHex, encryptedKeyHex)
641
572
  const key = privateKey.decrypt(encryptedKey, RSA_ENCRYPTION_SCHEME);
642
573
  return decipherEncryptedMessageHex(key, encryptedMessageHex);
643
574
  }
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
- });
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);
672
582
  }
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) => ({
583
+ async function getDerivedPrivateKeyAndDecrypt(ctx, seedValue, encryptedShares) {
584
+ return Promise.all(
585
+ encryptedShares.map(async (share) => ({
688
586
  walletId: share.walletId,
689
587
  walletScheme: share.walletScheme,
690
588
  partnerId: share.partnerId,
691
- signer: decryptWithPrivateKey(privateKey, share.encryptedShare, share.encryptedKey),
589
+ signer: await decryptWithDerivedPrivateKey(ctx, {
590
+ seedValue,
591
+ encryptedMessageHex: share.encryptedShare,
592
+ encryptedKeyHex: share.encryptedKey
593
+ }),
692
594
  protocolId: share.protocolId
693
- }));
694
- });
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
+ }));
695
618
  }
696
619
  function encryptWithDerivedPublicKey(publicKeyHex, message) {
697
620
  const { key, encryptedMessageHex } = symmetricKeyEncryptMessage(message);
@@ -710,55 +633,49 @@ function hashPasswordWithSalt(password) {
710
633
  function generateSalt(length = 16) {
711
634
  return import_node_forge.default.util.bytesToHex(import_node_forge.default.random.getBytesSync(length));
712
635
  }
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
- });
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
+ );
727
648
  }
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
- });
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");
740
659
  }
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
- });
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;
762
679
  }
763
680
 
764
681
  // src/external/userManagementClient.ts
@@ -920,126 +837,125 @@ var KeyContainer = class _KeyContainer {
920
837
  };
921
838
 
922
839
  // src/shares/recovery.ts
923
- function sendRecoveryForShare(_0) {
924
- return __async(this, arguments, function* ({
925
- ctx,
926
- userId,
927
- walletId,
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({
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(
981
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) => ({
982
893
  walletId,
983
- useDKLS: ctx.useDKLS
984
- }, emailProps));
985
- return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
894
+ ...share
895
+ })),
896
+ ...ignoreRedistributingBackupEncryptedShare ? [] : userBackupKeyShareOptsArr
897
+ ]);
898
+ await ctx.client.distributeParaShare({
899
+ userId,
900
+ walletId,
901
+ useDKLS: ctx.useDKLS,
902
+ ...emailProps
986
903
  });
904
+ return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
987
905
  }
988
906
 
989
907
  // src/shares/shareDistribution.ts
990
- function distributeNewShare(_0) {
991
- return __async(this, arguments, function* ({
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({
992
952
  ctx,
993
953
  userId,
994
954
  walletId,
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
- });
955
+ otherEncryptedShares: allEncryptedShares,
956
+ userSigner: userShare,
957
+ ignoreRedistributingBackupEncryptedShare,
958
+ emailProps
1043
959
  });
1044
960
  }
1045
961
 
@@ -1048,36 +964,32 @@ var import_ecies2 = require("@celo/utils/lib/ecies.js");
1048
964
  var import_buffer = require("buffer");
1049
965
  var eutil2 = __toESM(require("ethereumjs-util"));
1050
966
  var import_crypto = require("crypto");
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
- }
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;
1063
977
  }
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
- });
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);
1071
985
  }
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
- });
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;
1081
993
  }
1082
994
 
1083
995
  // src/errors.ts
@@ -1104,7 +1016,7 @@ var TransactionReviewTimeout = class extends Error {
1104
1016
  };
1105
1017
 
1106
1018
  // src/constants.ts
1107
- var PARA_CORE_VERSION = '1.4.4';
1019
+ var PARA_CORE_VERSION = '1.5.0';
1108
1020
  var PREFIX = "@CAPSULE/";
1109
1021
  var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
1110
1022
  var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
@@ -1116,7 +1028,6 @@ var LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
1116
1028
  var LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
1117
1029
  var LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
1118
1030
  var LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
1119
- var LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES = `${PREFIX}currentExternalWalletAddresses`;
1120
1031
  var LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
1121
1032
  var SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
1122
1033
  var POLLING_INTERVAL_MS = 2e3;
@@ -1127,9 +1038,6 @@ function storageListener(e) {
1127
1038
  if (!e.url.includes(window.location.origin)) {
1128
1039
  return;
1129
1040
  }
1130
- if (e.key === LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) {
1131
- this.updateCurrentExternalWalletAddressesFromStorage();
1132
- }
1133
1041
  if (e.key === LOCAL_STORAGE_EXTERNAL_WALLETS) {
1134
1042
  this.updateExternalWalletsFromStorage();
1135
1043
  }
@@ -1179,8 +1087,7 @@ if (typeof global !== "undefined") {
1179
1087
  self.global = self.global || self;
1180
1088
  }
1181
1089
  var { pki, jsbn } = import_node_forge2.default;
1182
- var _supportedWalletTypes, _supportedWalletTypesOpt;
1183
- var _ParaCore = class _ParaCore {
1090
+ var ParaCore = class _ParaCore {
1184
1091
  /**
1185
1092
  * Constructs a new `ParaCore` instance.
1186
1093
  * @param env - `Environment` to use.
@@ -1197,8 +1104,8 @@ var _ParaCore = class _ParaCore {
1197
1104
  * 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.
1198
1105
  */
1199
1106
  this.currentWalletIds = {};
1200
- __privateAdd(this, _supportedWalletTypes);
1201
- __privateAdd(this, _supportedWalletTypesOpt);
1107
+ this.#supportedWalletTypes = void 0;
1108
+ this.#supportedWalletTypesOpt = void 0;
1202
1109
  this.localStorageGetItem = (key) => {
1203
1110
  return this.platformUtils.localStorage.get(key);
1204
1111
  };
@@ -1221,14 +1128,14 @@ var _ParaCore = class _ParaCore {
1221
1128
  * Remove all local storage and prefixed session storage.
1222
1129
  * @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
1223
1130
  */
1224
- this.clearStorage = (type = "all") => __async(this, null, function* () {
1131
+ this.clearStorage = async (type = "all") => {
1225
1132
  const isAll = type === "all";
1226
1133
  (isAll || type === "local") && this.platformUtils.localStorage.clear(PREFIX);
1227
1134
  (isAll || type === "session") && this.platformUtils.sessionStorage.clear(PREFIX);
1228
1135
  if ((isAll || type === "secure") && this.platformUtils.secureStorage) {
1229
1136
  this.platformUtils.secureStorage.clear(PREFIX);
1230
1137
  }
1231
- });
1138
+ };
1232
1139
  this.initializeFromStorage = () => {
1233
1140
  this.updateEmailFromStorage();
1234
1141
  this.updateCountryCodeFromStorage();
@@ -1240,7 +1147,6 @@ var _ParaCore = class _ParaCore {
1240
1147
  this.updateSessionCookieFromStorage();
1241
1148
  this.updateLoginEncryptionKeyPairFromStorage();
1242
1149
  this.updateExternalWalletsFromStorage();
1243
- this.updateCurrentExternalWalletAddressesFromStorage();
1244
1150
  };
1245
1151
  this.updateTelegramUserIdFromStorage = () => {
1246
1152
  this.telegramUserId = this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID) || void 0;
@@ -1257,16 +1163,18 @@ var _ParaCore = class _ParaCore {
1257
1163
  this.updateEmailFromStorage = () => {
1258
1164
  this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || void 0;
1259
1165
  };
1260
- this.updateWalletsFromStorage = () => __async(this, null, function* () {
1261
- var _a;
1262
- const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1166
+ this.updateWalletsFromStorage = async () => {
1167
+ const _currentWalletIds = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS) ?? void 0;
1263
1168
  const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
1264
1169
  const fromJson = JSON.parse(_currentWalletIds);
1265
1170
  return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1266
1171
  const wallet = Object.values(this.wallets).find(
1267
1172
  (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1268
1173
  );
1269
- return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1174
+ return {
1175
+ ...acc,
1176
+ ...wallet && !acc[type] ? { [type]: [wallet.id] } : {}
1177
+ };
1270
1178
  }, {}) : fromJson;
1271
1179
  })();
1272
1180
  this.setCurrentWalletIds(currentWalletIds);
@@ -1274,25 +1182,34 @@ var _ParaCore = class _ParaCore {
1274
1182
  const _wallets = JSON.parse(stringWallets || "{}");
1275
1183
  const stringEd25519Wallets = this.platformUtils.secureStorage ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS) : this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
1276
1184
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || "{}");
1277
- const wallets = __spreadValues(__spreadValues({}, Object.keys(_wallets).reduce((res, key) => {
1278
- return __spreadProps(__spreadValues({}, res), {
1279
- [key]: migrateWallet(_wallets[key])
1280
- });
1281
- }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
1282
- return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {});
1283
- }, {}));
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
+ };
1284
1199
  this.setWallets(wallets);
1285
- });
1200
+ };
1286
1201
  this.updateWalletIdsFromStorage = () => {
1287
- var _a;
1288
- const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1202
+ const _currentWalletIds = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS) ?? void 0;
1289
1203
  const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
1290
1204
  const fromJson = JSON.parse(_currentWalletIds);
1291
1205
  return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1292
1206
  const wallet = Object.values(this.wallets).find(
1293
1207
  (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1294
1208
  );
1295
- return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1209
+ return {
1210
+ ...acc,
1211
+ ...wallet && !acc[type] ? { [type]: [wallet.id] } : {}
1212
+ };
1296
1213
  }, {}) : fromJson;
1297
1214
  })();
1298
1215
  this.setCurrentWalletIds(currentWalletIds);
@@ -1314,10 +1231,6 @@ var _ParaCore = class _ParaCore {
1314
1231
  const _externalWallets = JSON.parse(stringExternalWallets || "{}");
1315
1232
  this.setExternalWallets(_externalWallets);
1316
1233
  };
1317
- this.updateCurrentExternalWalletAddressesFromStorage = () => {
1318
- const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || void 0;
1319
- this.currentExternalWalletAddresses = _currentExternalWalletAddresses ? JSON.parse(_currentExternalWalletAddresses) : void 0;
1320
- };
1321
1234
  /**
1322
1235
  * Creates several new wallets with the desired types. If no types are provided, this method
1323
1236
  * will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
@@ -1385,7 +1298,7 @@ var _ParaCore = class _ParaCore {
1385
1298
  this.ctx.mpcComputationClient = initClient2(opts.offloadMPCComputationURL, opts.disableWorkers);
1386
1299
  }
1387
1300
  try {
1388
- __privateSet(this, _supportedWalletTypes, opts.supportedWalletTypes ? (() => {
1301
+ this.#supportedWalletTypes = opts.supportedWalletTypes ? (() => {
1389
1302
  if (Object.values(opts.supportedWalletTypes).every(
1390
1303
  (config) => !!config && typeof config === "object" && config.optional
1391
1304
  )) {
@@ -1394,20 +1307,19 @@ var _ParaCore = class _ParaCore {
1394
1307
  if (!Object.keys(opts.supportedWalletTypes).every((type) => Object.values(import_user_management_client5.WalletType).includes(type))) {
1395
1308
  throw new Error("unsupported wallet type");
1396
1309
  }
1397
- __privateSet(this, _supportedWalletTypesOpt, opts.supportedWalletTypes);
1310
+ this.#supportedWalletTypesOpt = opts.supportedWalletTypes;
1398
1311
  return Object.entries(opts.supportedWalletTypes).reduce((acc, [key, value]) => {
1399
- var _a;
1400
1312
  if (!value) {
1401
1313
  return acc;
1402
1314
  }
1403
1315
  if (key === import_user_management_client5.WalletType.COSMOS && typeof value === "object" && !!value.prefix) {
1404
1316
  this.cosmosPrefix = value.prefix;
1405
1317
  }
1406
- return [...acc, { type: key, optional: value === true ? false : (_a = value.optional) != null ? _a : false }];
1318
+ return [...acc, { type: key, optional: value === true ? false : value.optional ?? false }];
1407
1319
  }, []);
1408
- })() : void 0);
1320
+ })() : void 0;
1409
1321
  } catch (e) {
1410
- __privateSet(this, _supportedWalletTypes, void 0);
1322
+ this.#supportedWalletTypes = void 0;
1411
1323
  }
1412
1324
  if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
1413
1325
  return;
@@ -1415,6 +1327,9 @@ var _ParaCore = class _ParaCore {
1415
1327
  this.initializeFromStorage();
1416
1328
  setupListeners.bind(this)();
1417
1329
  }
1330
+ static {
1331
+ this.version = PARA_CORE_VERSION;
1332
+ }
1418
1333
  get isEmail() {
1419
1334
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1420
1335
  }
@@ -1429,10 +1344,9 @@ var _ParaCore = class _ParaCore {
1429
1344
  }
1430
1345
  get currentWalletIdsArray() {
1431
1346
  return this.supportedWalletTypes.reduce((acc, { type }) => {
1432
- var _a;
1433
1347
  return [
1434
1348
  ...acc,
1435
- ...((_a = this.currentWalletIds[type]) != null ? _a : []).map((id) => {
1349
+ ...(this.currentWalletIds[type] ?? []).map((id) => {
1436
1350
  return [id, type];
1437
1351
  })
1438
1352
  ];
@@ -1445,17 +1359,19 @@ var _ParaCore = class _ParaCore {
1445
1359
  * A map of pre-generated wallet identifiers that can be claimed in the current instance.
1446
1360
  */
1447
1361
  get pregenIds() {
1448
- return __spreadValues({}, Object.values(this.wallets).filter((wallet) => !this.userId || this.isPregenWalletClaimable(wallet)).reduce((acc, wallet) => {
1449
- var _a, _b;
1450
- if (((_a = acc[wallet.pregenIdentifierType]) != null ? _a : []).includes(wallet.pregenIdentifier)) {
1451
- return acc;
1452
- }
1453
- return __spreadProps(__spreadValues({}, acc), {
1454
- [wallet.pregenIdentifierType]: [
1455
- .../* @__PURE__ */ new Set([...(_b = acc[wallet.pregenIdentifierType]) != null ? _b : [], wallet.pregenIdentifier])
1456
- ]
1457
- });
1458
- }, {}));
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
+ };
1459
1375
  }
1460
1376
  /**
1461
1377
  * Whether the instance has multiple wallets connected.
@@ -1463,13 +1379,14 @@ var _ParaCore = class _ParaCore {
1463
1379
  get isMultiWallet() {
1464
1380
  return this.currentWalletIdsArray.length > 1;
1465
1381
  }
1382
+ #supportedWalletTypes;
1383
+ #supportedWalletTypesOpt;
1466
1384
  get supportedWalletTypes() {
1467
- var _a;
1468
- return (_a = __privateGet(this, _supportedWalletTypes)) != null ? _a : [];
1385
+ return this.#supportedWalletTypes ?? [];
1469
1386
  }
1470
1387
  get isWalletTypeEnabled() {
1471
1388
  return this.supportedWalletTypes.reduce((acc, { type }) => {
1472
- return __spreadProps(__spreadValues({}, acc), { [type]: true });
1389
+ return { ...acc, [type]: true };
1473
1390
  }, {});
1474
1391
  }
1475
1392
  convertBigInt(bigInt) {
@@ -1498,14 +1415,12 @@ var _ParaCore = class _ParaCore {
1498
1415
  };
1499
1416
  }
1500
1417
  isPortal(envOverride) {
1501
- var _a;
1502
1418
  if (typeof window === "undefined") return false;
1503
- return !!((_a = window.location) == null ? void 0 : _a.host) && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
1419
+ return !!window.location?.host && getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
1504
1420
  }
1505
1421
  isParaConnect() {
1506
- var _a;
1507
1422
  if (typeof window === "undefined") return false;
1508
- return !!((_a = window.location) == null ? void 0 : _a.host) && getParaConnectBaseUrl(this.ctx).includes(window.location.host);
1423
+ return !!window.location?.host && getParaConnectBaseUrl(this.ctx).includes(window.location.host);
1509
1424
  }
1510
1425
  requireApiKey() {
1511
1426
  if (!this.ctx.apiKey) {
@@ -1516,20 +1431,19 @@ var _ParaCore = class _ParaCore {
1516
1431
  }
1517
1432
  }
1518
1433
  isWalletSupported(wallet) {
1519
- var _a, _b;
1520
- return !__privateGet(this, _supportedWalletTypes) || isWalletSupported((_b = (_a = this.supportedWalletTypes) == null ? void 0 : _a.map(({ type }) => type)) != null ? _b : [], wallet);
1434
+ return !this.#supportedWalletTypes || isWalletSupported(this.supportedWalletTypes?.map(({ type }) => type) ?? [], wallet);
1521
1435
  }
1522
1436
  isWalletOwned(wallet) {
1523
- 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;
1437
+ return this.isWalletSupported(wallet) && !wallet?.pregenIdentifier && !wallet?.pregenIdentifierType && !!this.userId && wallet?.userId === this.userId;
1524
1438
  }
1525
1439
  isPregenWalletUnclaimed(wallet) {
1526
- 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));
1440
+ return this.isWalletSupported(wallet) && (!wallet?.userId || wallet?.isPregen && !!wallet?.pregenIdentifier && !!wallet?.pregenIdentifierType);
1527
1441
  }
1528
1442
  isPregenWalletClaimable(wallet) {
1529
- return this.isWalletSupported(wallet) && this.isPregenWalletUnclaimed(wallet) && (!["EMAIL", "PHONE", "TELEGRAM"].includes(wallet == null ? void 0 : wallet.pregenIdentifierType) || isPregenIdentifierMatch(
1530
- (wallet == null ? void 0 : wallet.pregenIdentifierType) === "EMAIL" ? this.email : (wallet == null ? void 0 : wallet.pregenIdentifierType) === "TELEGRAM" ? this.telegramUserId : this.getPhoneNumber(),
1531
- wallet == null ? void 0 : wallet.pregenIdentifier,
1532
- wallet == null ? void 0 : wallet.pregenIdentifierType
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
1533
1447
  ));
1534
1448
  }
1535
1449
  isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
@@ -1540,18 +1454,15 @@ var _ParaCore = class _ParaCore {
1540
1454
  const wallet = this.wallets[walletId];
1541
1455
  const [isUnclaimed, isOwned] = [this.isPregenWalletUnclaimed(wallet), this.isWalletOwned(wallet)];
1542
1456
  if (forbidPregen && isUnclaimed) {
1543
- error = `pre-generated wallet with id ${wallet == null ? void 0 : wallet.id} cannot be selected`;
1457
+ error = `pre-generated wallet with id ${wallet?.id} cannot be selected`;
1544
1458
  } else if (!isOwned && !isUnclaimed) {
1545
- error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
1459
+ error = `wallet with id ${wallet?.id} is not owned by the current user`;
1546
1460
  } else if (!this.isWalletSupported(wallet)) {
1547
- 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(", ")}`;
1548
- } else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
1549
- var _a, _b;
1550
- return (_b = (_a = this.currentWalletIds) == null ? void 0 : _a[type]) == null ? void 0 : _b.includes(walletId);
1551
- }))) {
1552
- error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
1553
- } else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
1554
- error = `wallet with id ${wallet == null ? void 0 : wallet.id} and scheme ${wallet == null ? void 0 : wallet.scheme} cannot be selected`;
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`;
1555
1466
  }
1556
1467
  }
1557
1468
  if (error) {
@@ -1571,7 +1482,6 @@ var _ParaCore = class _ParaCore {
1571
1482
  * @returns the formatted address
1572
1483
  */
1573
1484
  getDisplayAddress(walletId, options = {}) {
1574
- var _a;
1575
1485
  if (this.externalWallets[walletId]) {
1576
1486
  const wallet2 = this.externalWallets[walletId];
1577
1487
  return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
@@ -1583,7 +1493,7 @@ var _ParaCore = class _ParaCore {
1583
1493
  let str;
1584
1494
  switch (wallet.type) {
1585
1495
  case import_user_management_client5.WalletType.COSMOS:
1586
- str = getCosmosAddress(wallet.publicKey, (_a = this.cosmosPrefix) != null ? _a : "cosmos");
1496
+ str = getCosmosAddress(wallet.publicKey, this.cosmosPrefix ?? "cosmos");
1587
1497
  break;
1588
1498
  default:
1589
1499
  str = wallet.address;
@@ -1609,87 +1519,89 @@ var _ParaCore = class _ParaCore {
1609
1519
  return this.wallets;
1610
1520
  }
1611
1521
  getAddress(walletId) {
1612
- var _a, _b, _c;
1613
- 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;
1614
- }
1615
- constructPortalUrl(_0) {
1616
- return __async(this, arguments, function* (type, opts = {}) {
1617
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1618
- const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
1619
- let path;
1620
- switch (type) {
1621
- case "createPassword": {
1622
- path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
1623
- break;
1624
- }
1625
- case "createAuth": {
1626
- path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
1627
- break;
1628
- }
1629
- case "loginPassword": {
1630
- path = "/web/passwords/login";
1631
- break;
1632
- }
1633
- case "loginAuth": {
1634
- path = "/web/biometrics/login";
1635
- break;
1636
- }
1637
- case "txReview": {
1638
- path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
1639
- break;
1640
- }
1641
- case "onRamp": {
1642
- path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
1643
- break;
1644
- }
1645
- default: {
1646
- throw new Error(`invalid URL type ${type}`);
1647
- }
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;
1648
1531
  }
1649
- const [isCreate, isLogin, isOnRamp] = [
1650
- ["createAuth", "createPassword"].includes(type),
1651
- ["loginAuth", "loginPassword"].includes(type),
1652
- type === "onRamp"
1653
- ];
1654
- const partner = opts.partnerId ? (_a = (yield this.ctx.client.getPartner(opts.partnerId)).data) == null ? void 0 : _a.partner : void 0;
1655
- const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
1656
- apiKey: this.ctx.apiKey,
1657
- partnerId: opts.partnerId,
1658
- portalFont: ((_b = opts.theme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
1659
- portalBorderRadius: ((_d = opts.theme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
1660
- portalThemeMode: ((_f = opts.theme) == null ? void 0 : _f.mode) || (partner == null ? void 0 : partner.themeMode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode),
1661
- portalAccentColor: ((_h = opts.theme) == null ? void 0 : _h.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor),
1662
- portalForegroundColor: ((_j = opts.theme) == null ? void 0 : _j.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor),
1663
- 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),
1664
- portalPrimaryButtonColor: this.portalPrimaryButtonColor,
1665
- portalTextColor: this.portalTextColor,
1666
- portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
1667
- isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
1668
- supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
1669
- }, 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 ? {
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}`);
1554
+ }
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 ? {
1670
1584
  encryptionKey: opts.loginEncryptionPublicKey,
1671
1585
  newDeviceSessionLookupId: opts.newDeviceSessionId,
1672
1586
  newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
1673
1587
  pregenIds: JSON.stringify(this.pregenIds),
1674
1588
  displayName: opts.displayName,
1675
1589
  pfpUrl: opts.pfpUrl
1676
- } : {}), opts.params || {});
1677
- return constructUrl({ base, path, params });
1678
- });
1590
+ } : {},
1591
+ ...opts.params || {}
1592
+ };
1593
+ return constructUrl({ base, path, params });
1679
1594
  }
1680
- touchSession(regenerate = false) {
1681
- return __async(this, null, function* () {
1682
- const res = yield this.ctx.client.touchSession(regenerate);
1683
- this.setSupportedWalletTypes(res.data.supportedWalletTypes, res.data.cosmosPrefix);
1684
- return res;
1685
- });
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;
1686
1599
  }
1687
1600
  setSupportedWalletTypes(supportedWalletTypes, cosmosPrefix) {
1688
- if (supportedWalletTypes && !__privateGet(this, _supportedWalletTypes)) {
1689
- __privateSet(this, _supportedWalletTypes, supportedWalletTypes);
1601
+ if (supportedWalletTypes && !this.#supportedWalletTypes) {
1602
+ this.#supportedWalletTypes = supportedWalletTypes;
1690
1603
  Object.keys(this.currentWalletIds).forEach((type) => {
1691
- var _a;
1692
- if (!((_a = __privateGet(this, _supportedWalletTypes)) == null ? void 0 : _a.some(({ type: supportedType }) => supportedType === type))) {
1604
+ if (!this.#supportedWalletTypes?.some(({ type: supportedType }) => supportedType === type)) {
1693
1605
  delete this.currentWalletIds[type];
1694
1606
  }
1695
1607
  });
@@ -1725,181 +1637,155 @@ var _ParaCore = class _ParaCore {
1725
1637
  *
1726
1638
  * Init only needs to be called for storage that is async.
1727
1639
  */
1728
- init() {
1729
- return __async(this, null, function* () {
1730
- var _a;
1731
- this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || void 0;
1732
- this.countryCode = (yield this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE)) || void 0;
1733
- this.phone = (yield this.localStorageGetItem(LOCAL_STORAGE_PHONE)) || void 0;
1734
- this.userId = (yield this.localStorageGetItem(LOCAL_STORAGE_USER_ID)) || void 0;
1735
- this.telegramUserId = (yield this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID)) || void 0;
1736
- const stringWallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS) : yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
1737
- const _wallets = JSON.parse(stringWallets || "{}");
1738
- const stringEd25519Wallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS) : yield this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
1739
- const _ed25519Wallets = JSON.parse(stringEd25519Wallets || "{}");
1740
- const wallets = __spreadValues(__spreadValues({}, Object.keys(_wallets).reduce((res, key) => {
1741
- return __spreadProps(__spreadValues({}, res), {
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,
1742
1654
  [key]: migrateWallet(_wallets[key])
1743
- });
1744
- }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
1745
- return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {});
1746
- }, {}));
1747
- yield this.setWallets(wallets);
1748
- const _currentWalletIds = (_a = yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
1749
- const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
1750
- const fromJson = JSON.parse(_currentWalletIds);
1751
- return Array.isArray(fromJson) ? Object.keys(import_user_management_client5.WalletType).reduce((acc, type) => {
1752
- const wallet = Object.values(this.wallets).find(
1753
- (w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
1754
- );
1755
- return __spreadValues(__spreadValues({}, acc), wallet && !acc[type] ? { [type]: [wallet.id] } : {});
1756
- }, {}) : fromJson;
1757
- })();
1758
- yield this.setCurrentWalletIds(currentWalletIds);
1759
- this.sessionCookie = (yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) || (yield this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) || void 0;
1760
- if (Object.values(this.wallets).filter((w) => this.isWalletOwned(w)).length > 0 && this.currentWalletIdsArray.length === 0) {
1761
- this.findWalletId(void 0, { forbidPregen: true });
1762
- }
1763
- const loginEncryptionKey = yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1764
- if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
1765
- this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
1766
- }
1767
- const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
1768
- const _externalWallets = JSON.parse(stringExternalWallets || "{}");
1769
- yield this.setExternalWallets(_externalWallets);
1770
- const _currentExternalWalletAddresses = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || void 0;
1771
- this.currentExternalWalletAddresses = _currentExternalWalletAddresses ? JSON.parse(_currentExternalWalletAddresses) : void 0;
1772
- setupListeners.bind(this)();
1773
- yield this.touchSession();
1774
- });
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();
1775
1692
  }
1776
1693
  /**
1777
1694
  * Sets the email associated with the `ParaCore` instance.
1778
1695
  * @param email - Email to set.
1779
1696
  */
1780
- setEmail(email) {
1781
- return __async(this, null, function* () {
1782
- this.email = email;
1783
- yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
1784
- });
1697
+ async setEmail(email) {
1698
+ this.email = email;
1699
+ await this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
1785
1700
  }
1786
1701
  /**
1787
1702
  * Sets the Telegram user ID associated with the `ParaCore` instance.
1788
1703
  * @param telegramUserId - Telegram user ID to set.
1789
1704
  */
1790
- setTelegramUserId(telegramUserId) {
1791
- return __async(this, null, function* () {
1792
- this.telegramUserId = telegramUserId;
1793
- yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
1794
- });
1705
+ async setTelegramUserId(telegramUserId) {
1706
+ this.telegramUserId = telegramUserId;
1707
+ await this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
1795
1708
  }
1796
1709
  /**
1797
1710
  * Sets the phone number associated with the `ParaCore` instance.
1798
1711
  * @param phone - Phone number to set.
1799
1712
  * @param countryCode - Country Code to set.
1800
1713
  */
1801
- setPhoneNumber(phone, countryCode) {
1802
- return __async(this, null, function* () {
1803
- this.phone = phone;
1804
- this.countryCode = countryCode;
1805
- yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
1806
- yield this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
1807
- });
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);
1808
1719
  }
1809
1720
  /**
1810
1721
  * Sets the farcaster username associated with the `ParaCore` instance.
1811
1722
  * @param farcasterUsername - Farcaster Username to set.
1812
1723
  */
1813
- setFarcasterUsername(farcasterUsername) {
1814
- return __async(this, null, function* () {
1815
- this.farcasterUsername = farcasterUsername;
1816
- yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
1817
- });
1724
+ async setFarcasterUsername(farcasterUsername) {
1725
+ this.farcasterUsername = farcasterUsername;
1726
+ await this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
1818
1727
  }
1819
1728
  /**
1820
1729
  * Sets the external wallet address and type associated with the `ParaCore` instance.
1821
1730
  * @param externalAddress - External wallet address to set.
1822
1731
  * @param externalType - Type of external wallet to set.
1823
1732
  */
1824
- setExternalWallet(_0) {
1825
- return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
1826
- this.externalWallets = {
1827
- [address]: {
1828
- id: address,
1829
- address: addressBech32 != null ? addressBech32 : address,
1830
- type,
1831
- name: provider,
1832
- isExternal: true,
1833
- signer: ""
1834
- }
1835
- };
1836
- this.currentExternalWalletAddresses = [address];
1837
- this.setCurrentExternalWalletAddresses(this.currentExternalWalletAddresses);
1838
- this.setExternalWallets(this.externalWallets);
1839
- dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
1840
- });
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);
1841
1746
  }
1842
1747
  /**
1843
1748
  * Sets the user id associated with the `ParaCore` instance.
1844
1749
  * @param userId - User id to set.
1845
1750
  */
1846
- setUserId(userId) {
1847
- return __async(this, null, function* () {
1848
- this.userId = userId;
1849
- yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
1850
- });
1751
+ async setUserId(userId) {
1752
+ this.userId = userId;
1753
+ await this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
1851
1754
  }
1852
1755
  /**
1853
1756
  * Sets the wallets associated with the `ParaCore` instance.
1854
1757
  * @param wallets - Wallets to set.
1855
1758
  */
1856
- setWallets(wallets) {
1857
- return __async(this, null, function* () {
1858
- this.wallets = wallets;
1859
- if (this.platformUtils.secureStorage) {
1860
- yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1861
- return;
1862
- }
1863
- yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
1864
- });
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));
1865
1766
  }
1866
1767
  /**
1867
1768
  * Sets the external wallets associated with the `ParaCore` instance.
1868
1769
  * @param externalWallets - External wallets to set.
1869
1770
  */
1870
- setExternalWallets(externalWallets) {
1871
- return __async(this, null, function* () {
1872
- this.externalWallets = externalWallets;
1873
- yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
1874
- });
1875
- }
1876
- setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
1877
- return __async(this, null, function* () {
1878
- this.currentExternalWalletAddresses = currentExternalWalletAddresses;
1879
- yield this.localStorageSetItem(
1880
- LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES,
1881
- JSON.stringify(currentExternalWalletAddresses)
1882
- );
1883
- });
1771
+ async setExternalWallets(externalWallets) {
1772
+ this.externalWallets = externalWallets;
1773
+ await this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
1884
1774
  }
1885
1775
  /**
1886
1776
  * Sets the login encryption key pair associated with the `ParaCore` instance.
1887
1777
  * @param keyPair - Encryption key pair generated from loginEncryptionKey.
1888
1778
  */
1889
- setLoginEncryptionKeyPair(keyPair) {
1890
- return __async(this, null, function* () {
1891
- if (!keyPair) {
1892
- keyPair = yield getAsymmetricKeyPair(this.ctx);
1893
- }
1894
- this.loginEncryptionKeyPair = keyPair;
1895
- yield this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
1896
- });
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));
1897
1785
  }
1898
- deleteLoginEncryptionKeyPair() {
1899
- return __async(this, null, function* () {
1900
- this.loginEncryptionKeyPair = void 0;
1901
- yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1902
- });
1786
+ async deleteLoginEncryptionKeyPair() {
1787
+ this.loginEncryptionKeyPair = void 0;
1788
+ await this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
1903
1789
  }
1904
1790
  /**
1905
1791
  * Gets the userId associated with the `ParaCore` instance.
@@ -1939,25 +1825,23 @@ var _ParaCore = class _ParaCore {
1939
1825
  getFarcasterUsername() {
1940
1826
  return this.farcasterUsername;
1941
1827
  }
1942
- setCurrentWalletIds(_0) {
1943
- return __async(this, arguments, function* (currentWalletIds, {
1944
- needsWallet = false,
1945
- sessionLookupId,
1946
- newDeviceSessionLookupId
1947
- } = {}) {
1948
- this.currentWalletIds = currentWalletIds;
1949
- yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
1950
- if (sessionLookupId) {
1951
- yield this.ctx.client.setCurrentWalletIds(
1952
- this.getUserId(),
1953
- this.currentWalletIds,
1954
- needsWallet,
1955
- sessionLookupId,
1956
- newDeviceSessionLookupId
1957
- );
1958
- }
1959
- dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
1960
- });
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);
1961
1845
  }
1962
1846
  /**
1963
1847
  * Validates that a wallet ID is present on the instance, usable, and matches the desired filters.
@@ -2011,7 +1895,6 @@ var _ParaCore = class _ParaCore {
2011
1895
  return wallet;
2012
1896
  }
2013
1897
  findWallet(idOrAddress, overrideType, filter = {}) {
2014
- var _b, _c;
2015
1898
  if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
2016
1899
  return Object.values(this.externalWallets)[0];
2017
1900
  }
@@ -2021,18 +1904,18 @@ var _ParaCore = class _ParaCore {
2021
1904
  try {
2022
1905
  const walletId = this.findWalletId(idOrAddress, filter);
2023
1906
  if (walletId && !!this.wallets[walletId]) {
2024
- const _a = this.wallets[walletId], { signer: _signer } = _a, wallet = __objRest(_a, ["signer"]);
2025
- const type = (_c = overrideType != null ? overrideType : (_b = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _b[1]) != null ? _c : wallet.type;
2026
- return __spreadProps(__spreadValues({}, wallet), {
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,
2027
1911
  type: import_user_management_client5.WalletType[type]
2028
- });
1912
+ };
2029
1913
  }
2030
1914
  } catch (e) {
2031
1915
  return void 0;
2032
1916
  }
2033
1917
  }
2034
1918
  get availableWallets() {
2035
- var _a;
2036
1919
  return [
2037
1920
  ...this.currentWalletIdsArray.map(([address, type]) => [address, type, false]).map(([id, type]) => {
2038
1921
  const wallet = this.findWallet(id, type);
@@ -2044,7 +1927,7 @@ var _ParaCore = class _ParaCore {
2044
1927
  name: wallet.name
2045
1928
  };
2046
1929
  }).filter((obj) => obj !== null),
2047
- ...Object.values((_a = this.externalWallets) != null ? _a : {})
1930
+ ...Object.values(this.externalWallets ?? {})
2048
1931
  ];
2049
1932
  }
2050
1933
  /**
@@ -2058,78 +1941,61 @@ var _ParaCore = class _ParaCore {
2058
1941
  assertIsValidWalletId(walletId, condition = {}) {
2059
1942
  this.isWalletUsable(walletId, condition, true);
2060
1943
  }
2061
- assertIsValidWalletType(type, walletTypes) {
2062
- return __async(this, null, function* () {
2063
- if (!__privateGet(this, _supportedWalletTypes)) {
2064
- yield this.touchSession();
2065
- }
2066
- if (!type || !Object.values(import_user_management_client5.WalletType).includes(type) || !(walletTypes != null ? walletTypes : this.supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
2067
- throw new Error(`wallet type ${type} is not supported`);
2068
- }
2069
- return type;
2070
- });
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;
2071
1952
  }
2072
- getMissingTypes() {
2073
- return __async(this, null, function* () {
2074
- if (!__privateGet(this, _supportedWalletTypes)) {
2075
- yield this.touchSession();
2076
- }
2077
- return this.supportedWalletTypes.filter(
2078
- ({ type: t, optional }) => !optional && Object.values(this.wallets).every((w) => !this.isWalletOwned(w) || !WalletSchemeTypeMap[w.scheme][t])
2079
- ).map(({ type }) => type);
2080
- });
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);
2081
1960
  }
2082
- getTypesToCreate(types) {
2083
- return __async(this, null, function* () {
2084
- if (!__privateGet(this, _supportedWalletTypes)) {
2085
- yield this.touchSession();
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;
2086
1971
  }
2087
- return getSchemes(types != null ? types : yield this.getMissingTypes()).map((scheme) => {
2088
- switch (scheme) {
2089
- case import_user_management_client5.WalletScheme.ED25519:
2090
- return import_user_management_client5.WalletType.SOLANA;
2091
- default:
2092
- 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;
2093
- }
2094
- });
2095
1972
  });
2096
1973
  }
2097
- getPartnerURL(partnerId) {
2098
- return __async(this, null, function* () {
2099
- const res = yield this.ctx.client.getPartner(partnerId);
2100
- return res.data.partner.portalUrl;
2101
- });
1974
+ async getPartnerURL(partnerId) {
1975
+ const res = await this.ctx.client.getPartner(partnerId);
1976
+ return res.data.partner.portalUrl;
2102
1977
  }
2103
1978
  /**
2104
1979
  * URL of the portal, which can be associated with a partner id
2105
1980
  * @param partnerId: string - id of the partner to get the portal URL for
2106
1981
  * @returns - portal URL
2107
1982
  */
2108
- getPortalURL(partnerId) {
2109
- return __async(this, null, function* () {
2110
- return partnerId && (yield this.getPartnerURL(partnerId)) || getPortalBaseURL(this.ctx);
2111
- });
1983
+ async getPortalURL(partnerId) {
1984
+ return partnerId && await this.getPartnerURL(partnerId) || getPortalBaseURL(this.ctx);
2112
1985
  }
2113
- getWebAuthURLForCreate(_a) {
2114
- return __async(this, null, function* () {
2115
- var _b = _a, {
2116
- webAuthId
2117
- } = _b, options = __objRest(_b, [
2118
- "webAuthId"
2119
- ]);
2120
- return this.constructPortalUrl("createAuth", __spreadProps(__spreadValues({}, options), { pathId: webAuthId }));
2121
- });
1986
+ async getWebAuthURLForCreate({
1987
+ webAuthId,
1988
+ ...options
1989
+ }) {
1990
+ return this.constructPortalUrl("createAuth", { ...options, pathId: webAuthId });
2122
1991
  }
2123
- getPasswordURLForCreate(_c) {
2124
- return __async(this, null, function* () {
2125
- var _d = _c, {
2126
- passwordId
2127
- } = _d, options = __objRest(_d, [
2128
- "passwordId"
2129
- ]);
2130
- return this.constructPortalUrl("createPassword", __spreadProps(__spreadValues({}, options), {
2131
- pathId: passwordId
2132
- }));
1992
+ async getPasswordURLForCreate({
1993
+ passwordId,
1994
+ ...options
1995
+ }) {
1996
+ return this.constructPortalUrl("createPassword", {
1997
+ ...options,
1998
+ pathId: passwordId
2133
1999
  });
2134
2000
  }
2135
2001
  getShortUrl(compressedUrl) {
@@ -2138,42 +2004,35 @@ var _ParaCore = class _ParaCore {
2138
2004
  path: `/short/${compressedUrl}`
2139
2005
  });
2140
2006
  }
2141
- shortenLoginLink(link) {
2142
- return __async(this, null, function* () {
2143
- const url = yield upload(link, this.ctx.client);
2144
- return this.getShortUrl(url);
2145
- });
2007
+ async shortenLoginLink(link) {
2008
+ const url = await upload(link, this.ctx.client);
2009
+ return this.getShortUrl(url);
2146
2010
  }
2147
2011
  /**
2148
2012
  * Generates a URL for registering a new WebAuth passkey.
2149
2013
  * @param {GetWebAuthUrlForLoginParams} opts the options object
2150
2014
  * @returns - the URL for creating a new passkey
2151
2015
  */
2152
- getWebAuthURLForLogin(opts) {
2153
- return __async(this, null, function* () {
2154
- return this.constructPortalUrl("loginAuth", opts);
2155
- });
2016
+ async getWebAuthURLForLogin(opts) {
2017
+ return this.constructPortalUrl("loginAuth", opts);
2156
2018
  }
2157
2019
  /**
2158
2020
  * Generates a URL for registering a new user password.
2159
2021
  * @param {GetWebAuthUrlForLoginParams} opts the options object
2160
2022
  * @returns - the URL for creating a new password
2161
2023
  */
2162
- getPasswordURLForLogin(opts) {
2163
- return __async(this, null, function* () {
2164
- return this.constructPortalUrl("loginPassword", opts);
2165
- });
2024
+ async getPasswordURLForLogin(opts) {
2025
+ return this.constructPortalUrl("loginPassword", opts);
2166
2026
  }
2167
2027
  /**
2168
2028
  * Generates a URL for registering a new WebAuth passkey for a phone number.
2169
2029
  * @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
2170
2030
  * @returns - web auth url
2171
2031
  */
2172
- getWebAuthURLForLoginForPhone(opts) {
2173
- return __async(this, null, function* () {
2174
- return this.constructPortalUrl("loginAuth", __spreadValues({
2175
- authType: "phone"
2176
- }, opts));
2032
+ async getWebAuthURLForLoginForPhone(opts) {
2033
+ return this.constructPortalUrl("loginAuth", {
2034
+ authType: "phone",
2035
+ ...opts
2177
2036
  });
2178
2037
  }
2179
2038
  /**
@@ -2181,59 +2040,57 @@ var _ParaCore = class _ParaCore {
2181
2040
  * @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
2182
2041
  * @returns - the private key string.
2183
2042
  */
2184
- getPrivateKey(walletId) {
2185
- return __async(this, null, function* () {
2186
- const wallets = Object.values(this.wallets);
2187
- const wallet = walletId ? this.wallets[walletId] : wallets == null ? void 0 : wallets[0];
2188
- if (!wallet) {
2189
- throw new Error("wallet not found");
2190
- }
2191
- if (wallet.scheme !== import_user_management_client5.WalletScheme.DKLS) {
2192
- throw new Error("invalid wallet scheme");
2193
- }
2194
- return yield this.platformUtils.getPrivateKey(
2195
- this.ctx,
2196
- this.userId,
2197
- wallet.id,
2198
- wallet.signer,
2199
- this.retrieveSessionCookie()
2200
- );
2201
- });
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
+ );
2202
2059
  }
2203
2060
  /**
2204
2061
  * Fetches the wallets associated with the user.
2205
2062
  * @returns {WalletEntity[]} wallets that were fetched.
2206
2063
  */
2207
- fetchWallets() {
2208
- return __async(this, null, function* () {
2209
- const res = yield this.isPortal() || this.isParaConnect() ? this.ctx.client.getAllWallets(this.userId) : this.ctx.client.getWallets(this.userId, true);
2210
- return res.data.wallets.filter(
2211
- (wallet) => !!wallet.address && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))
2212
- );
2213
- });
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
+ );
2214
2069
  }
2215
- populateWalletAddresses() {
2216
- return __async(this, null, function* () {
2217
- const res = yield this.ctx.client.getWallets(this.userId, true);
2218
- const wallets = res.data.wallets;
2219
- wallets.forEach((entity) => {
2220
- if (this.wallets[entity.id]) {
2221
- this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
2222
- }
2223
- });
2224
- yield this.setWallets(this.wallets);
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
+ }
2225
2080
  });
2081
+ await this.setWallets(this.wallets);
2226
2082
  }
2227
- populatePregenWalletAddresses() {
2228
- return __async(this, null, function* () {
2229
- const res = yield this.getPregenWallets();
2230
- res.forEach((entity) => {
2231
- if (this.wallets[entity.id]) {
2232
- this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
2233
- }
2234
- });
2235
- yield this.setWallets(this.wallets);
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
+ }
2236
2092
  });
2093
+ await this.setWallets(this.wallets);
2237
2094
  }
2238
2095
  /**
2239
2096
  * Checks if a user exists for an email address.
@@ -2241,11 +2098,9 @@ var _ParaCore = class _ParaCore {
2241
2098
  * @param {string} opts.email the email to check.
2242
2099
  * @returns true if user exists, false otherwise.
2243
2100
  */
2244
- checkIfUserExists(_0) {
2245
- return __async(this, arguments, function* ({ email }) {
2246
- const res = yield this.ctx.client.checkUserExists({ email });
2247
- return res.data.exists;
2248
- });
2101
+ async checkIfUserExists({ email }) {
2102
+ const res = await this.ctx.client.checkUserExists({ email });
2103
+ return res.data.exists;
2249
2104
  }
2250
2105
  /**
2251
2106
  * Checks if a user exists for a phone number.
@@ -2254,26 +2109,23 @@ var _ParaCore = class _ParaCore {
2254
2109
  * @param {string} opts.countryCode - the country code.
2255
2110
  * @returns true if user exists, false otherwise.
2256
2111
  */
2257
- checkIfUserExistsByPhone(_0) {
2258
- return __async(this, arguments, function* ({ phone, countryCode }) {
2259
- const res = yield this.ctx.client.checkUserExists({ phone, countryCode });
2260
- return res.data.exists;
2261
- });
2112
+ async checkIfUserExistsByPhone({ phone, countryCode }) {
2113
+ const res = await this.ctx.client.checkUserExists({ phone, countryCode });
2114
+ return res.data.exists;
2262
2115
  }
2263
2116
  /**
2264
2117
  * Creates a new user.
2265
2118
  * @param {Object} opts the options object
2266
2119
  * @param {string} opts.email the email to use.
2267
2120
  */
2268
- createUser(_0) {
2269
- return __async(this, arguments, function* ({ email }) {
2270
- this.requireApiKey();
2271
- yield this.setEmail(email);
2272
- const { userId } = yield this.ctx.client.createUser(__spreadValues({
2273
- email: this.email
2274
- }, this.getVerificationEmailProps()));
2275
- yield this.setUserId(userId);
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()
2276
2127
  });
2128
+ await this.setUserId(userId);
2277
2129
  }
2278
2130
  /**
2279
2131
  * Creates a new user with a phone number.
@@ -2281,16 +2133,14 @@ var _ParaCore = class _ParaCore {
2281
2133
  * @param {string} opts.phone - the phone number to use for creating the user.
2282
2134
  * @param {string} opts.countryCode - the country code to use for creating the user.
2283
2135
  */
2284
- createUserByPhone(_0) {
2285
- return __async(this, arguments, function* ({ phone, countryCode }) {
2286
- this.requireApiKey();
2287
- yield this.setPhoneNumber(phone, countryCode);
2288
- const { userId } = yield this.ctx.client.createUser({
2289
- phone: this.phone,
2290
- countryCode: this.countryCode
2291
- });
2292
- yield this.setUserId(userId);
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
2293
2142
  });
2143
+ await this.setUserId(userId);
2294
2144
  }
2295
2145
  /**
2296
2146
  * Logs in or creates a new user using an external wallet address.
@@ -2299,19 +2149,17 @@ var _ParaCore = class _ParaCore {
2299
2149
  * @param {WalletType} opts.type type of external wallet to use for identification.
2300
2150
  * @param {string} opts.provider the name of the provider for the external wallet.
2301
2151
  */
2302
- externalWalletLogin(wallet) {
2303
- return __async(this, null, function* () {
2304
- this.requireApiKey();
2305
- const res = yield this.ctx.client.externalWalletLogin({
2306
- externalAddress: wallet.address,
2307
- type: wallet.type,
2308
- externalWalletProvider: wallet.provider,
2309
- shouldTrackUser: wallet.shouldTrackUser
2310
- });
2311
- yield this.setExternalWallet(wallet);
2312
- yield this.setUserId(res.userId);
2313
- return res;
2314
- });
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;
2315
2163
  }
2316
2164
  /**
2317
2165
  * Returns whether or not the user is connected with an external wallet.
@@ -2325,22 +2173,18 @@ var _ParaCore = class _ParaCore {
2325
2173
  * @param {string} verificationCode the six-digit code to check
2326
2174
  * @returns {string} the web auth url for creating a new credential
2327
2175
  */
2328
- verifyEmail(_0) {
2329
- return __async(this, arguments, function* ({ verificationCode }) {
2330
- yield this.ctx.client.verifyEmail(this.userId, { verificationCode });
2331
- return this.getSetUpBiometricsURL();
2332
- });
2333
- }
2334
- verifyExternalWallet(_0) {
2335
- return __async(this, arguments, function* ({
2336
- address,
2337
- signedMessage,
2338
- cosmosPublicKeyHex,
2339
- cosmosSigner
2340
- }) {
2341
- yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
2342
- return this.getSetUpBiometricsURL();
2343
- });
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();
2344
2188
  }
2345
2189
  /**
2346
2190
  * Passes the phone code obtained from the user for verification.
@@ -2348,11 +2192,9 @@ var _ParaCore = class _ParaCore {
2348
2192
  * @param {string} verificationCode the six-digit code to check
2349
2193
  * @returns {string} the web auth url for creating a new credential
2350
2194
  */
2351
- verifyPhone(_0) {
2352
- return __async(this, arguments, function* ({ verificationCode }) {
2353
- yield this.ctx.client.verifyPhone(this.userId, { verificationCode });
2354
- return this.getSetUpBiometricsURLForPhone();
2355
- });
2195
+ async verifyPhone({ verificationCode }) {
2196
+ await this.ctx.client.verifyPhone(this.userId, { verificationCode });
2197
+ return this.getSetUpBiometricsURLForPhone();
2356
2198
  }
2357
2199
  /**
2358
2200
  * Validates the response received from an attempted Telegram login for authenticity, then
@@ -2360,19 +2202,17 @@ var _ParaCore = class _ParaCore {
2360
2202
  * @param authResponse - the response JSON object received from the Telegram widget.
2361
2203
  * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
2362
2204
  */
2363
- verifyTelegram(authObject) {
2364
- return __async(this, null, function* () {
2365
- const res = yield this.ctx.client.verifyTelegram(authObject);
2366
- if (res.isValid) {
2367
- yield this.setUserId(res.userId);
2368
- yield this.setTelegramUserId(res.telegramUserId);
2369
- yield this.touchSession(true);
2370
- if (!this.loginEncryptionKeyPair) {
2371
- yield this.setLoginEncryptionKeyPair();
2372
- }
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();
2373
2213
  }
2374
- return res;
2375
- });
2214
+ }
2215
+ return res;
2376
2216
  }
2377
2217
  /**
2378
2218
  * Performs 2FA verification.
@@ -2381,16 +2221,14 @@ var _ParaCore = class _ParaCore {
2381
2221
  * @param {string} opts.verificationCode the verification code to received via 2FA.
2382
2222
  * @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
2383
2223
  */
2384
- verify2FA(_0) {
2385
- return __async(this, arguments, function* ({ email, verificationCode }) {
2386
- const res = yield this.ctx.client.verify2FA(email, verificationCode);
2387
- return {
2388
- initiatedAt: res.data.initiatedAt,
2389
- status: res.data.status,
2390
- userId: res.data.userId,
2391
- wallets: res.data.wallets
2392
- };
2393
- });
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
+ };
2394
2232
  }
2395
2233
  /**
2396
2234
  * Performs 2FA verification.
@@ -2400,76 +2238,65 @@ var _ParaCore = class _ParaCore {
2400
2238
  * @param {string} opts.verificationCode - verification code to received via 2FA.
2401
2239
  * @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
2402
2240
  */
2403
- verify2FAForPhone(_0) {
2404
- return __async(this, arguments, function* ({
2405
- phone,
2406
- countryCode,
2407
- verificationCode
2408
- }) {
2409
- const res = yield this.ctx.client.verify2FAForPhone(phone, countryCode, verificationCode);
2410
- return {
2411
- initiatedAt: res.data.initiatedAt,
2412
- status: res.data.status,
2413
- userId: res.data.userId,
2414
- wallets: res.data.wallets
2415
- };
2416
- });
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
+ };
2417
2253
  }
2418
2254
  /**
2419
2255
  * Sets up two-factor authentication for the current user.
2420
2256
  * @returns {string} uri - uri to use for setting up 2FA
2421
2257
  * */
2422
- setup2FA() {
2423
- return __async(this, null, function* () {
2424
- const res = yield this.ctx.client.setup2FA(this.userId);
2425
- return {
2426
- uri: res.data.uri
2427
- };
2428
- });
2258
+ async setup2FA() {
2259
+ const res = await this.ctx.client.setup2FA(this.userId);
2260
+ return {
2261
+ uri: res.data.uri
2262
+ };
2429
2263
  }
2430
2264
  /**
2431
2265
  * Enables 2FA.
2432
2266
  * @param {Object} opts the options object
2433
2267
  * @param {string} opts.verificationCode - the verification code received via 2FA.
2434
2268
  */
2435
- enable2FA(_0) {
2436
- return __async(this, arguments, function* ({ verificationCode }) {
2437
- yield this.ctx.client.enable2FA(this.userId, verificationCode);
2438
- });
2269
+ async enable2FA({ verificationCode }) {
2270
+ await this.ctx.client.enable2FA(this.userId, verificationCode);
2439
2271
  }
2440
2272
  /**
2441
2273
  * Determines if 2FA has been set up.
2442
2274
  * @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
2443
2275
  */
2444
- check2FAStatus() {
2445
- return __async(this, null, function* () {
2446
- if (!this.userId) {
2447
- return { isSetup: false };
2448
- }
2449
- const res = yield this.ctx.client.check2FAStatus(this.userId);
2450
- return {
2451
- isSetup: res.data.isSetup
2452
- };
2453
- });
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
+ };
2454
2284
  }
2455
2285
  /**
2456
2286
  * Resend a verification email for the current user.
2457
2287
  */
2458
- resendVerificationCode() {
2459
- return __async(this, null, function* () {
2460
- yield this.ctx.client.resendVerificationCode(__spreadValues({
2461
- userId: this.userId
2462
- }, this.getVerificationEmailProps()));
2288
+ async resendVerificationCode() {
2289
+ await this.ctx.client.resendVerificationCode({
2290
+ userId: this.userId,
2291
+ ...this.getVerificationEmailProps()
2463
2292
  });
2464
2293
  }
2465
2294
  /**
2466
2295
  * Resend a verification SMS for the current user.
2467
2296
  */
2468
- resendVerificationCodeByPhone() {
2469
- return __async(this, null, function* () {
2470
- yield this.ctx.client.resendVerificationCodeByPhone({
2471
- userId: this.userId
2472
- });
2297
+ async resendVerificationCodeByPhone() {
2298
+ await this.ctx.client.resendVerificationCodeByPhone({
2299
+ userId: this.userId
2473
2300
  });
2474
2301
  }
2475
2302
  /**
@@ -2479,21 +2306,19 @@ var _ParaCore = class _ParaCore {
2479
2306
  * @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
2480
2307
  * @returns {string} the URL
2481
2308
  */
2482
- getSetUpBiometricsURL() {
2483
- return __async(this, arguments, function* ({
2484
- authType = "email",
2485
- isForNewDevice = false
2486
- } = {}) {
2487
- const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
2488
- status: import_user_management_client5.PublicKeyStatus.PENDING,
2489
- type: import_user_management_client5.PublicKeyType.WEB
2490
- });
2491
- return this.getWebAuthURLForCreate({
2492
- authType,
2493
- isForNewDevice,
2494
- webAuthId: res.data.id,
2495
- partnerId: res.data.partnerId
2496
- });
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
2497
2322
  });
2498
2323
  }
2499
2324
  /**
@@ -2502,20 +2327,18 @@ var _ParaCore = class _ParaCore {
2502
2327
  * @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
2503
2328
  * @returns {string} the URL
2504
2329
  */
2505
- getSetUpBiometricsURLForPhone() {
2506
- return __async(this, arguments, function* ({
2507
- isForNewDevice = false
2508
- } = {}) {
2509
- const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
2510
- status: import_user_management_client5.PublicKeyStatus.PENDING,
2511
- type: import_user_management_client5.PublicKeyType.WEB
2512
- });
2513
- return this.getWebAuthURLForCreate({
2514
- authType: "phone",
2515
- isForNewDevice,
2516
- webAuthId: res.data.id,
2517
- partnerId: res.data.partnerId
2518
- });
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
2519
2342
  });
2520
2343
  }
2521
2344
  /**
@@ -2526,107 +2349,95 @@ var _ParaCore = class _ParaCore {
2526
2349
  * @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
2527
2350
  * @returns {string} the URL
2528
2351
  */
2529
- getSetupPasswordURL() {
2530
- return __async(this, arguments, function* ({
2531
- authType = "email",
2532
- isForNewDevice = false,
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,
2533
2365
  theme
2534
- } = {}) {
2535
- const res = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
2536
- status: import_user_management_client5.PasswordStatus.PENDING
2537
- });
2538
- return this.getPasswordURLForCreate({
2539
- authType,
2540
- isForNewDevice,
2541
- passwordId: res.data.id,
2542
- partnerId: res.data.partnerId,
2543
- theme
2544
- });
2545
2366
  });
2546
2367
  }
2547
2368
  /**
2548
2369
  * Checks if the current session is active.
2549
2370
  * @returns `true` if active, `false` otherwise
2550
2371
  */
2551
- isSessionActive() {
2552
- return __async(this, null, function* () {
2553
- if (this.isUsingExternalWallet()) {
2554
- return true;
2555
- }
2556
- const res = yield this.touchSession();
2557
- return !!res.data.isAuthenticated;
2558
- });
2372
+ async isSessionActive() {
2373
+ if (this.isUsingExternalWallet()) {
2374
+ return true;
2375
+ }
2376
+ const res = await this.touchSession();
2377
+ return !!res.data.isAuthenticated;
2559
2378
  }
2560
2379
  /**
2561
2380
  * Checks if a session is active and a wallet exists.
2562
2381
  * @returns `true` if active, `false` otherwise
2563
2382
  **/
2564
- isFullyLoggedIn() {
2565
- return __async(this, null, function* () {
2566
- if (this.isUsingExternalWallet()) {
2567
- return true;
2568
- }
2569
- const isSessionActive = yield this.isSessionActive();
2570
- return isSessionActive && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true);
2571
- });
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);
2572
2389
  }
2573
- supportedAuthMethods(auth) {
2574
- return __async(this, null, function* () {
2575
- const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
2576
- const authMethods = /* @__PURE__ */ new Set();
2577
- for (const type of supportedAuthMethods) {
2578
- switch (type) {
2579
- case "PASSWORD":
2580
- authMethods.add(import_user_management_client5.AuthMethod.PASSWORD);
2581
- break;
2582
- case "BIOMETRIC":
2583
- authMethods.add(import_user_management_client5.AuthMethod.PASSKEY);
2584
- break;
2585
- }
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;
2586
2401
  }
2587
- return authMethods;
2588
- });
2402
+ }
2403
+ return authMethods;
2589
2404
  }
2590
2405
  /**
2591
2406
  * Get hints associated with the users stored biometrics.
2592
2407
  * @returns Array containing useragents and AAGuids for stored biometrics
2593
2408
  */
2594
- getUserBiometricLocationHints() {
2595
- return __async(this, null, function* () {
2596
- if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId) {
2597
- throw new Error("one of email, phone or farcaster username are required to get biometric location hints");
2598
- }
2599
- return yield this.ctx.client.getBiometricLocationHints({
2600
- email: this.email,
2601
- phone: this.phone,
2602
- countryCode: this.countryCode,
2603
- farcasterUsername: this.farcasterUsername,
2604
- telegramUserId: this.telegramUserId
2605
- });
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
2606
2419
  });
2607
2420
  }
2608
- setAuth(auth) {
2609
- return __async(this, null, function* () {
2610
- const authInfo = (0, import_user_management_client5.extractAuthInfo)(auth);
2611
- if (!authInfo) {
2612
- return void 0;
2613
- }
2614
- switch (authInfo.authType) {
2615
- case "email":
2616
- yield this.setEmail(authInfo.identifier);
2617
- break;
2618
- case "phone":
2619
- yield this.setPhoneNumber(authInfo.auth.phone, authInfo.auth.countryCode);
2620
- break;
2621
- case "farcaster":
2622
- yield this.setFarcasterUsername(authInfo.identifier);
2623
- break;
2624
- case "telegram":
2625
- yield this.setTelegramUserId(authInfo.identifier);
2626
- break;
2627
- }
2628
- return authInfo;
2629
- });
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;
2630
2441
  }
2631
2442
  /**
2632
2443
  * Initiates a login.
@@ -2635,46 +2446,41 @@ var _ParaCore = class _ParaCore {
2635
2446
  * @param {boolean} opts.useShortURL - whether to shorten the link
2636
2447
  * @returns - the WebAuth URL for logging in
2637
2448
  **/
2638
- initiateUserLogin(_e) {
2639
- return __async(this, null, function* () {
2640
- var _f = _e, { useShortUrl = false } = _f, auth = __objRest(_f, ["useShortUrl"]);
2641
- const authInfo = yield this.setAuth(auth);
2642
- if (!authInfo) {
2643
- return;
2644
- }
2645
- const res = yield this.touchSession(true);
2646
- if (!this.loginEncryptionKeyPair) {
2647
- yield this.setLoginEncryptionKeyPair();
2648
- }
2649
- const webAuthLoginURL = yield this.getWebAuthURLForLogin({
2650
- authType: authInfo.authType,
2651
- sessionId: res.data.sessionId,
2652
- partnerId: res.data.partnerId,
2653
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2654
- });
2655
- if (!useShortUrl) {
2656
- return webAuthLoginURL;
2657
- }
2658
- return this.shortenLoginLink(webAuthLoginURL);
2659
- });
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);
2660
2468
  }
2661
2469
  /**
2662
2470
  * Initiates a login.
2663
2471
  * @param email - the email to login with
2664
2472
  * @returns - a set of supported auth methods for the user
2665
2473
  **/
2666
- initiateUserLoginV2(auth) {
2667
- return __async(this, null, function* () {
2668
- const authInfo = yield this.setAuth(auth);
2669
- if (!authInfo) {
2670
- return;
2671
- }
2672
- yield this.touchSession(true);
2673
- if (!this.loginEncryptionKeyPair) {
2674
- yield this.setLoginEncryptionKeyPair();
2675
- }
2676
- return yield this.supportedAuthMethods(authInfo.auth);
2677
- });
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);
2678
2484
  }
2679
2485
  /**
2680
2486
  * Initiates a login.
@@ -2684,125 +2490,112 @@ var _ParaCore = class _ParaCore {
2684
2490
  * @param opts.useShortURL - whether to shorten the link
2685
2491
  * @returns - the WebAuth URL for logging in
2686
2492
  **/
2687
- initiateUserLoginForPhone(_g) {
2688
- return __async(this, null, function* () {
2689
- var _h = _g, {
2690
- useShortUrl = false
2691
- } = _h, auth = __objRest(_h, [
2692
- "useShortUrl"
2693
- ]);
2694
- yield this.setAuth(auth);
2695
- const res = yield this.touchSession(true);
2696
- if (!this.loginEncryptionKeyPair) {
2697
- yield this.setLoginEncryptionKeyPair();
2698
- }
2699
- const webAuthLoginURL = yield this.getWebAuthURLForLoginForPhone({
2700
- sessionId: res.data.sessionId,
2701
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair),
2702
- partnerId: res.data.partnerId
2703
- });
2704
- if (!useShortUrl) {
2705
- return webAuthLoginURL;
2706
- }
2707
- return this.shortenLoginLink(webAuthLoginURL);
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
2708
2506
  });
2507
+ if (!useShortUrl) {
2508
+ return webAuthLoginURL;
2509
+ }
2510
+ return this.shortenLoginLink(webAuthLoginURL);
2709
2511
  }
2710
2512
  /**
2711
2513
  * Waits for the session to be active.
2712
2514
  **/
2713
- waitForAccountCreation() {
2714
- return __async(this, arguments, function* ({ popupWindow } = {}) {
2715
- yield this.touchSession();
2716
- this.currentExternalWalletAddresses = void 0;
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()) {
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) {
2723
2528
  this.isAwaitingAccountCreation = 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
- }
2529
+ return false;
2731
2530
  }
2732
- } catch (err) {
2733
- console.error(err);
2734
2531
  }
2532
+ } catch (err) {
2533
+ console.error(err);
2735
2534
  }
2736
- return false;
2737
- });
2535
+ }
2536
+ return false;
2738
2537
  }
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
- });
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;
2762
2559
  }
2763
2560
  /**
2764
2561
  * Initiates a Farcaster login attempt and return the URI for the user to connect.
2765
2562
  * You can create a QR code with this URI that works with Farcaster's mobile app.
2766
2563
  * @return {string} the Farcaster connect URI
2767
2564
  */
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
- });
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;
2777
2572
  }
2778
2573
  /**
2779
2574
  * Awaits the response from a user's attempt to log in with Farcaster.
2780
2575
  * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
2781
2576
  * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
2782
2577
  */
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;
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
+ };
2803
2593
  }
2594
+ } catch (err) {
2595
+ console.error(err);
2596
+ this.isAwaitingFarcaster = false;
2804
2597
  }
2805
- });
2598
+ }
2806
2599
  }
2807
2600
  /**
2808
2601
  * Generates a URL for the user to log in with OAuth using a desire method.
@@ -2812,19 +2605,17 @@ var _ParaCore = class _ParaCore {
2812
2605
  * @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
2813
2606
  * @returns {string} the URL for the user to log in with OAuth.
2814
2607
  */
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
- });
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
+ }
2828
2619
  });
2829
2620
  }
2830
2621
  /**
@@ -2835,38 +2626,36 @@ var _ParaCore = class _ParaCore {
2835
2626
  * @param {Window} [opts.popupWindow] the popup window being used for login.
2836
2627
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
2837
2628
  */
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
- };
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();
2862
2643
  }
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
+ };
2863
2652
  }
2864
- } catch (err) {
2865
- console.error(err);
2866
2653
  }
2654
+ } catch (err) {
2655
+ console.error(err);
2867
2656
  }
2868
- return { userExists: false };
2869
- });
2657
+ }
2658
+ return { userExists: false };
2870
2659
  }
2871
2660
  /**
2872
2661
  * Waits for the session to be active and sets up the user.
@@ -2876,60 +2665,56 @@ var _ParaCore = class _ParaCore {
2876
2665
  * @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
2877
2666
  * @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
2878
2667
  **/
2879
- waitForLoginAndSetup() {
2880
- return __async(this, arguments, function* ({
2881
- popupWindow,
2882
- skipSessionRefresh = false
2883
- } = {}) {
2884
- var _a;
2885
- this.currentExternalWalletAddresses = void 0;
2886
- this.externalWallets = {};
2887
- this.isAwaitingLogin = true;
2888
- while (this.isAwaitingLogin) {
2889
- try {
2890
- yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
2891
- if (!(yield this.isSessionActive())) {
2892
- if (popupWindow == null ? void 0 : popupWindow.closed) {
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) {
2893
2690
  const resp2 = { isComplete: false, isError: true };
2894
2691
  dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
2895
2692
  return resp2;
2693
+ } else {
2694
+ continue;
2896
2695
  }
2897
- continue;
2898
- }
2899
- const postLoginData = yield this.userSetupAfterLogin();
2900
- const needsWallet = (_a = postLoginData.data.needsWallet) != null ? _a : false;
2901
- if (!needsWallet) {
2902
- if (this.currentWalletIdsArray.length === 0) {
2903
- if (popupWindow == null ? void 0 : popupWindow.closed) {
2904
- const resp2 = { isComplete: false, isError: true };
2905
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
2906
- return resp2;
2907
- } else {
2908
- continue;
2909
- }
2910
- }
2911
- }
2912
- const fetchedWallets = yield this.fetchWallets();
2913
- const tempSharesRes = yield this.getTransmissionKeyShares();
2914
- if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
2915
- yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
2916
- yield this.claimPregenWallets();
2917
- const resp2 = {
2918
- isComplete: true,
2919
- needsWallet: needsWallet || Object.values(this.wallets).length === 0,
2920
- partnerId: postLoginData.data.partnerId
2921
- };
2922
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp2);
2923
- return resp2;
2924
2696
  }
2925
- } catch (err) {
2926
- console.error(err);
2927
2697
  }
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);
2928
2713
  }
2929
- const resp = { isComplete: false };
2930
- dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
2931
- return resp;
2932
- });
2714
+ }
2715
+ const resp = { isComplete: false };
2716
+ dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
2717
+ return resp;
2933
2718
  }
2934
2719
  /**
2935
2720
  * Updates the session with the user management server, possibly
@@ -2939,36 +2724,32 @@ var _ParaCore = class _ParaCore {
2939
2724
  * @param {boolean} [shouldOpenPopup] - if `true`, the running device will open a popup to reauthenticate the user.
2940
2725
  * @returns a URL for the user to reauthenticate.
2941
2726
  **/
2942
- refreshSession() {
2943
- return __async(this, arguments, function* ({ shouldOpenPopup = false } = {}) {
2944
- const res = yield this.touchSession(true);
2945
- if (!this.loginEncryptionKeyPair) {
2946
- yield this.setLoginEncryptionKeyPair();
2947
- }
2948
- const link = yield this.getWebAuthURLForLogin({
2949
- sessionId: res.data.sessionId,
2950
- loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
2951
- });
2952
- if (shouldOpenPopup) {
2953
- this.platformUtils.openPopup(link);
2954
- }
2955
- return link;
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)
2956
2735
  });
2736
+ if (shouldOpenPopup) {
2737
+ this.platformUtils.openPopup(link);
2738
+ }
2739
+ return link;
2957
2740
  }
2958
2741
  /**
2959
2742
  * Call this method after login to ensure that the user ID is set
2960
2743
  * internally.
2961
2744
  **/
2962
- userSetupAfterLogin() {
2963
- return __async(this, null, function* () {
2964
- const res = yield this.touchSession();
2965
- yield this.setUserId(res.data.userId);
2966
- if (res.data.currentWalletIds && res.data.currentWalletIds !== this.currentWalletIds)
2967
- yield this.setCurrentWalletIds(res.data.currentWalletIds, {
2968
- sessionLookupId: this.isPortal() ? res.data.sessionLookupId : void 0
2969
- });
2970
- return res;
2971
- });
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;
2972
2753
  }
2973
2754
  /**
2974
2755
  * Get transmission shares associated with session.
@@ -2976,12 +2757,10 @@ var _ParaCore = class _ParaCore {
2976
2757
  * @param {boolean} opts.isForNewDevice - true if this device is registering.
2977
2758
  * @returns - transmission keyshares.
2978
2759
  **/
2979
- getTransmissionKeyShares() {
2980
- return __async(this, arguments, function* ({ isForNewDevice = false } = {}) {
2981
- const res = yield this.touchSession();
2982
- const sessionLookupId = isForNewDevice ? `${res.data.sessionLookupId}-new-device` : res.data.sessionLookupId;
2983
- return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
2984
- });
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);
2985
2764
  }
2986
2765
  /**
2987
2766
  * Call this method after login to perform setup.
@@ -2989,25 +2768,23 @@ var _ParaCore = class _ParaCore {
2989
2768
  * @param {any[]} opts.temporaryShares optional temporary shares to use for decryption.
2990
2769
  * @param {boolean} [opts.skipSessionRefresh] - whether or not to skip refreshing the session.
2991
2770
  **/
2992
- setupAfterLogin() {
2993
- return __async(this, arguments, function* ({
2994
- temporaryShares,
2995
- skipSessionRefresh = false
2996
- } = {}) {
2997
- if (!temporaryShares) {
2998
- temporaryShares = (yield this.getTransmissionKeyShares()).data.temporaryShares;
2999
- }
3000
- temporaryShares.forEach((share) => {
3001
- const signer = decryptWithPrivateKey(this.loginEncryptionKeyPair.privateKey, share.encryptedShare, share.encryptedKey);
3002
- this.wallets[share.walletId] = {
3003
- id: share.walletId,
3004
- signer
3005
- };
3006
- });
3007
- yield this.deleteLoginEncryptionKeyPair();
3008
- yield this.populateWalletAddresses();
3009
- yield this.touchSession(!skipSessionRefresh);
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
+ };
3010
2784
  });
2785
+ await this.deleteLoginEncryptionKeyPair();
2786
+ await this.populateWalletAddresses();
2787
+ await this.touchSession(!skipSessionRefresh);
3011
2788
  }
3012
2789
  /**
3013
2790
  * Distributes a new wallet recovery share.
@@ -3018,55 +2795,51 @@ var _ParaCore = class _ParaCore {
3018
2795
  * @param {boolean} opts.forceRefreshRecovery whether or not to force recovery secret regeneration. Used when regenerating recovery shares.
3019
2796
  * @returns {string} the recovery share.
3020
2797
  **/
3021
- distributeNewWalletShare(_0) {
3022
- return __async(this, arguments, function* ({
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,
3023
2811
  walletId,
3024
- userShare,
3025
- skipBiometricShareCreation = false,
3026
- forceRefresh = false
3027
- }) {
3028
- let userSigner = userShare;
3029
- if (!userSigner) {
3030
- userSigner = this.wallets[walletId].signer;
3031
- }
3032
- const recoveryShare = skipBiometricShareCreation ? yield sendRecoveryForShare({
3033
- ctx: this.ctx,
3034
- userId: this.userId,
3035
- walletId,
3036
- userSigner,
3037
- emailProps: this.getBackupKitEmailProps(),
3038
- forceRefresh
3039
- }) : yield distributeNewShare({
3040
- ctx: this.ctx,
3041
- userId: this.userId,
3042
- walletId,
3043
- userShare: userSigner,
3044
- emailProps: this.getBackupKitEmailProps()
3045
- });
3046
- return recoveryShare;
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()
3047
2821
  });
2822
+ return recoveryShare;
3048
2823
  }
3049
- waitForWalletAddress(walletId) {
3050
- return __async(this, null, function* () {
3051
- let maxPolls = 0;
3052
- while (true) {
3053
- try {
3054
- if (maxPolls === 10) {
3055
- break;
3056
- }
3057
- ++maxPolls;
3058
- const res = yield this.ctx.client.getWallets(this.userId);
3059
- const wallet = res.data.wallets.find((w) => w.id === walletId);
3060
- if (wallet && wallet.address) {
3061
- return;
3062
- }
3063
- yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
3064
- } catch (err) {
3065
- console.error(err);
2824
+ async waitForWalletAddress(walletId) {
2825
+ let maxPolls = 0;
2826
+ while (true) {
2827
+ try {
2828
+ if (maxPolls === 10) {
2829
+ break;
3066
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;
2836
+ }
2837
+ await new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
2838
+ } catch (err) {
2839
+ console.error(err);
3067
2840
  }
3068
- throw new Error("timed out waiting for wallet address");
3069
- });
2841
+ }
2842
+ throw new Error("timed out waiting for wallet address");
3070
2843
  }
3071
2844
  /**
3072
2845
  * Waits for a pregen wallet address to be created.
@@ -3076,27 +2849,25 @@ var _ParaCore = class _ParaCore {
3076
2849
  * @param pregenIdentifierType - the identifier type of the user the pregen wallet is associated with.
3077
2850
  * @returns - recovery share.
3078
2851
  **/
3079
- waitForPregenWalletAddress(walletId) {
3080
- return __async(this, null, function* () {
3081
- let maxPolls = 0;
3082
- while (true) {
3083
- try {
3084
- if (maxPolls === 10) {
3085
- break;
3086
- }
3087
- ++maxPolls;
3088
- const res = yield this.getPregenWallets();
3089
- const wallet = res.find((w) => w.id === walletId);
3090
- if (wallet && wallet.address) {
3091
- return;
3092
- }
3093
- yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
3094
- } catch (err) {
3095
- console.error(err);
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;
3096
2864
  }
2865
+ await new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
2866
+ } catch (err) {
2867
+ console.error(err);
3097
2868
  }
3098
- throw new Error("timed out waiting for wallet address");
3099
- });
2869
+ }
2870
+ throw new Error("timed out waiting for wallet address");
3100
2871
  }
3101
2872
  /**
3102
2873
  * Creates several new wallets with the desired types. If no types are provided, this method
@@ -3109,26 +2880,24 @@ var _ParaCore = class _ParaCore {
3109
2880
  * @param {WalletType[]} [opts.types] the types of wallets to create.
3110
2881
  * @returns {Object} the wallets created, their ids, and the recovery secret.
3111
2882
  **/
3112
- createWalletPerType() {
3113
- return __async(this, arguments, function* ({
3114
- skipDistribute = false,
3115
- types
3116
- } = {}) {
3117
- const wallets = [];
3118
- const walletIds = {};
3119
- let recoverySecret;
3120
- for (const type of yield this.getTypesToCreate(types)) {
3121
- const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
3122
- wallets.push(wallet);
3123
- getEquivalentTypes(type).filter((t) => !!this.isWalletTypeEnabled[t]).forEach((t) => {
3124
- walletIds[t] = [wallet.id];
3125
- });
3126
- if (recoveryShare) {
3127
- recoverySecret = recoveryShare;
3128
- }
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;
3129
2898
  }
3130
- return { wallets, walletIds, recoverySecret };
3131
- });
2899
+ }
2900
+ return { wallets, walletIds, recoverySecret };
3132
2901
  }
3133
2902
  /**
3134
2903
  * Refresh the current user share for a wallet.
@@ -3142,37 +2911,35 @@ var _ParaCore = class _ParaCore {
3142
2911
  * @param {boolean} [opts.redistributeBackupEncryptedShares] whether or not to redistribute backup encrypted shares.
3143
2912
  * @returns {Object} the new user share and recovery secret.
3144
2913
  **/
3145
- refreshShare(_0) {
3146
- return __async(this, arguments, function* ({
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,
3147
2926
  walletId,
3148
2927
  share,
3149
2928
  oldPartnerId,
3150
2929
  newPartnerId,
3151
- keyShareProtocolId,
3152
- redistributeBackupEncryptedShares
3153
- }) {
3154
- const { signer, protocolId } = yield this.platformUtils.refresh(
3155
- this.ctx,
3156
- this.retrieveSessionCookie(),
3157
- this.userId,
3158
- walletId,
3159
- share,
3160
- oldPartnerId,
3161
- newPartnerId,
3162
- keyShareProtocolId
3163
- );
3164
- const recoverySecret = yield distributeNewShare({
3165
- ctx: this.ctx,
3166
- userId: this.userId,
3167
- walletId,
3168
- userShare: signer,
3169
- ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
3170
- emailProps: this.getBackupKitEmailProps(),
3171
- partnerId: newPartnerId,
3172
- protocolId
3173
- });
3174
- return { signer, recoverySecret, protocolId };
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
3175
2941
  });
2942
+ return { signer, recoverySecret, protocolId };
3176
2943
  }
3177
2944
  /**
3178
2945
  * Creates a new wallet.
@@ -3181,73 +2948,71 @@ var _ParaCore = class _ParaCore {
3181
2948
  * @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
3182
2949
  * @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
3183
2950
  **/
3184
- createWallet() {
3185
- return __async(this, arguments, function* ({
3186
- type: _type,
3187
- skipDistribute = false
3188
- } = {}) {
3189
- var _a, _b;
3190
- this.requireApiKey();
3191
- const walletType = yield this.assertIsValidWalletType(
3192
- _type != null ? _type : (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type
3193
- );
3194
- let signer;
3195
- let wallet;
3196
- let keygenRes;
3197
- switch (walletType) {
3198
- case import_user_management_client5.WalletType.SOLANA: {
3199
- keygenRes = yield this.platformUtils.ed25519Keygen(
3200
- this.ctx,
3201
- this.userId,
3202
- this.retrieveSessionCookie(),
3203
- this.getBackupKitEmailProps()
3204
- );
3205
- break;
3206
- }
3207
- default: {
3208
- keygenRes = yield this.platformUtils.keygen(
3209
- this.ctx,
3210
- this.userId,
3211
- walletType,
3212
- null,
3213
- this.retrieveSessionCookie(),
3214
- this.getBackupKitEmailProps()
3215
- );
3216
- break;
3217
- }
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;
3218
2971
  }
3219
- const walletId = keygenRes.walletId;
3220
- signer = keygenRes.signer;
3221
- this.wallets[walletId] = {
3222
- id: walletId,
3223
- signer,
3224
- scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
3225
- type: walletType
3226
- };
3227
- wallet = this.wallets[walletId];
3228
- yield this.waitForWalletAddress(wallet.id);
3229
- yield this.populateWalletAddresses();
3230
- let recoveryShare = null;
3231
- if (!skipDistribute) {
3232
- recoveryShare = yield distributeNewShare({
3233
- ctx: this.ctx,
3234
- userId: this.userId,
3235
- walletId: wallet.id,
3236
- userShare: signer,
3237
- emailProps: this.getBackupKitEmailProps()
3238
- });
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;
3239
2982
  }
3240
- yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
3241
- [walletType]: [...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId]
3242
- }));
3243
- const walletNoSigner = __spreadValues({}, wallet);
3244
- delete walletNoSigner.signer;
3245
- dispatchEvent(ParaEvent.WALLET_CREATED, {
3246
- wallet: walletNoSigner,
3247
- recoverySecret: recoveryShare
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()
3248
3003
  });
3249
- return [wallet, recoveryShare];
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
3250
3014
  });
3015
+ return [wallet, recoveryShare];
3251
3016
  }
3252
3017
  /**
3253
3018
  * Creates a new pregenerated wallet.
@@ -3258,54 +3023,51 @@ var _ParaCore = class _ParaCore {
3258
3023
  * @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
3259
3024
  * @returns {Wallet} the created wallet.
3260
3025
  **/
3261
- createPregenWallet(opts) {
3262
- return __async(this, null, function* () {
3263
- var _a, _b;
3264
- const {
3265
- type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
3266
- pregenIdentifier,
3267
- pregenIdentifierType = "EMAIL"
3268
- } = opts;
3269
- this.requireApiKey();
3270
- const walletType = yield this.assertIsValidWalletType(
3271
- _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
3272
- );
3273
- let keygenRes;
3274
- switch (walletType) {
3275
- case import_user_management_client5.WalletType.SOLANA:
3276
- keygenRes = yield this.platformUtils.ed25519PreKeygen(
3277
- this.ctx,
3278
- pregenIdentifier,
3279
- pregenIdentifierType,
3280
- this.retrieveSessionCookie()
3281
- );
3282
- break;
3283
- default:
3284
- keygenRes = yield this.platformUtils.preKeygen(
3285
- this.ctx,
3286
- void 0,
3287
- pregenIdentifier,
3288
- pregenIdentifierType,
3289
- walletType,
3290
- null,
3291
- this.retrieveSessionCookie()
3292
- );
3293
- break;
3294
- }
3295
- const { signer, walletId } = keygenRes;
3296
- this.wallets[walletId] = {
3297
- id: walletId,
3298
- signer,
3299
- scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
3300
- type: walletType,
3301
- isPregen: true,
3302
- pregenIdentifier,
3303
- pregenIdentifierType
3304
- };
3305
- yield this.waitForPregenWalletAddress(walletId);
3306
- yield this.populatePregenWalletAddresses();
3307
- return this.wallets[walletId];
3308
- });
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];
3309
3071
  }
3310
3072
  /**
3311
3073
  * Creates new pregenerated wallets for each desired type.
@@ -3317,19 +3079,17 @@ var _ParaCore = class _ParaCore {
3317
3079
  * @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
3318
3080
  * @returns {Wallet[]} an array containing the created wallets.
3319
3081
  **/
3320
- createPregenWalletPerType(_0) {
3321
- return __async(this, arguments, function* ({
3322
- types,
3323
- pregenIdentifier,
3324
- pregenIdentifierType = "EMAIL"
3325
- }) {
3326
- const wallets = [];
3327
- for (const type of yield this.getTypesToCreate(types)) {
3328
- const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
3329
- wallets.push(wallet);
3330
- }
3331
- return wallets;
3332
- });
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;
3333
3093
  }
3334
3094
  /**
3335
3095
  * Claims a pregenerated wallet.
@@ -3339,65 +3099,63 @@ var _ParaCore = class _ParaCore {
3339
3099
  * @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
3340
3100
  * @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
3341
3101
  **/
3342
- claimPregenWallets() {
3343
- return __async(this, arguments, function* ({
3344
- pregenIdentifier,
3345
- pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3346
- } = {}) {
3347
- var _a;
3348
- this.requireApiKey();
3349
- const pregenWallets = pregenIdentifier && pregenIdentifierType ? yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType }) : yield this.getPregenWallets();
3350
- if (pregenWallets.length === 0) {
3351
- return void 0;
3352
- }
3353
- let newRecoverySecret;
3354
- const { walletIds } = yield this.ctx.client.claimPregenWallets({
3355
- userId: this.userId,
3356
- walletIds: pregenWallets.map((w) => w.id)
3357
- });
3358
- for (const walletId of walletIds) {
3359
- const wallet = this.wallets[walletId];
3360
- let refreshedShare;
3361
- if (wallet.scheme === import_user_management_client5.WalletScheme.ED25519) {
3362
- const distributeRes = yield distributeNewShare({
3363
- ctx: this.ctx,
3364
- userId: this.userId,
3365
- walletId: wallet.id,
3366
- userShare: this.wallets[wallet.id].signer,
3367
- emailProps: this.getBackupKitEmailProps(),
3368
- partnerId: wallet.partnerId
3369
- });
3370
- if (distributeRes.length > 0) {
3371
- newRecoverySecret = distributeRes;
3372
- }
3373
- } else {
3374
- refreshedShare = yield this.refreshShare({
3375
- walletId: wallet.id,
3376
- share: this.wallets[wallet.id].signer,
3377
- oldPartnerId: wallet.partnerId,
3378
- newPartnerId: wallet.partnerId,
3379
- redistributeBackupEncryptedShares: true
3380
- });
3381
- if (refreshedShare.recoverySecret) {
3382
- newRecoverySecret = refreshedShare.recoverySecret;
3383
- }
3384
- }
3385
- this.wallets[wallet.id] = __spreadProps(__spreadValues({}, this.wallets[wallet.id]), {
3386
- signer: (_a = refreshedShare == null ? void 0 : refreshedShare.signer) != null ? _a : wallet.signer,
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,
3387
3122
  userId: this.userId,
3388
- pregenIdentifier: void 0,
3389
- pregenIdentifierType: void 0
3123
+ walletId: wallet.id,
3124
+ userShare: this.wallets[wallet.id].signer,
3125
+ emailProps: this.getBackupKitEmailProps(),
3126
+ partnerId: wallet.partnerId
3390
3127
  });
3391
- const walletNoSigner = __spreadValues({}, this.wallets[wallet.id]);
3392
- delete walletNoSigner.signer;
3393
- dispatchEvent(ParaEvent.PREGEN_WALLET_CLAIMED, {
3394
- wallet: walletNoSigner,
3395
- recoverySecret: newRecoverySecret
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
3138
  });
3139
+ if (refreshedShare.recoverySecret) {
3140
+ newRecoverySecret = refreshedShare.recoverySecret;
3141
+ }
3397
3142
  }
3398
- yield this.setWallets(this.wallets);
3399
- return newRecoverySecret;
3400
- });
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;
3401
3159
  }
3402
3160
  /**
3403
3161
  * Updates the identifier for a pregen wallet.
@@ -3406,25 +3164,24 @@ var _ParaCore = class _ParaCore {
3406
3164
  * @param {string} opts.newPregenIdentifier the new identtifier
3407
3165
  * @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
3408
3166
  **/
3409
- updatePregenWalletIdentifier(_0) {
3410
- return __async(this, arguments, function* ({
3411
- walletId,
3412
- newPregenIdentifier,
3413
- newPregenIdentifierType
3414
- }) {
3415
- this.requireApiKey();
3416
- yield this.ctx.client.updatePregenWallet(walletId, {
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],
3417
3180
  pregenIdentifier: newPregenIdentifier,
3418
3181
  pregenIdentifierType: newPregenIdentifierType
3419
- });
3420
- if (!!this.wallets[walletId]) {
3421
- this.wallets[walletId] = __spreadProps(__spreadValues({}, this.wallets[walletId]), {
3422
- pregenIdentifier: newPregenIdentifier,
3423
- pregenIdentifierType: newPregenIdentifierType
3424
- });
3425
- yield this.setWallets(this.wallets);
3426
- }
3427
- });
3182
+ };
3183
+ await this.setWallets(this.wallets);
3184
+ }
3428
3185
  }
3429
3186
  /**
3430
3187
  * Checks if a pregen Wallet exists for the given identifier with the current partner.
@@ -3433,19 +3190,17 @@ var _ParaCore = class _ParaCore {
3433
3190
  * @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
3434
3191
  * @returns {boolean} whether the pregen wallet exists
3435
3192
  **/
3436
- hasPregenWallet(_0) {
3437
- return __async(this, arguments, function* ({
3438
- pregenIdentifier,
3439
- pregenIdentifierType
3440
- }) {
3441
- this.requireApiKey();
3442
- const res = yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType });
3443
- const wallet = res.find((w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType);
3444
- if (!wallet) {
3445
- return false;
3446
- }
3447
- return true;
3448
- });
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;
3449
3204
  }
3450
3205
  /**
3451
3206
  * Get pregen wallets for the given identifier.
@@ -3454,19 +3209,17 @@ var _ParaCore = class _ParaCore {
3454
3209
  * @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
3455
3210
  * @returns {Promise<WalletEntity[]>} the array of found wallets
3456
3211
  **/
3457
- getPregenWallets() {
3458
- return __async(this, arguments, function* ({
3459
- pregenIdentifier,
3460
- pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
3461
- } = {}) {
3462
- this.requireApiKey();
3463
- const res = yield this.ctx.client.getPregenWallets(
3464
- pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds,
3465
- this.isPortal(),
3466
- this.userId
3467
- );
3468
- return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
3469
- });
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)));
3470
3223
  }
3471
3224
  encodeWalletBase64(wallet) {
3472
3225
  const walletJson = JSON.stringify(wallet);
@@ -3487,54 +3240,45 @@ var _ParaCore = class _ParaCore {
3487
3240
  * Sets the current wallets from a Base 64 string.
3488
3241
  * @param {string} base64Wallet the encoded wallet string
3489
3242
  **/
3490
- setUserShare(base64Wallets) {
3491
- return __async(this, null, function* () {
3492
- if (!base64Wallets) {
3493
- return;
3494
- }
3495
- const base64WalletsSplit = base64Wallets.split("-");
3496
- for (const base64Wallet of base64WalletsSplit) {
3497
- const walletJson = Buffer.from(base64Wallet, "base64").toString();
3498
- const wallet = migrateWallet(JSON.parse(walletJson));
3499
- this.wallets[wallet.id] = wallet;
3500
- yield this.setWallets(this.wallets);
3501
- }
3502
- });
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
+ }
3503
3254
  }
3504
- getTransactionReviewUrl(transactionId, timeoutMs) {
3505
- return __async(this, null, function* () {
3506
- const res = yield this.touchSession();
3507
- return this.constructPortalUrl("txReview", {
3508
- partnerId: res.data.partnerId,
3509
- pathId: transactionId,
3510
- params: {
3511
- email: this.email,
3512
- timeoutMs: timeoutMs == null ? void 0 : timeoutMs.toString()
3513
- }
3514
- });
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()
3263
+ }
3515
3264
  });
3516
3265
  }
3517
- getOnRampTransactionUrl(_i) {
3518
- return __async(this, null, function* () {
3519
- var _j = _i, {
3520
- purchaseId,
3521
- providerKey
3522
- } = _j, walletParams = __objRest(_j, [
3523
- "purchaseId",
3524
- "providerKey"
3525
- ]);
3526
- const res = yield this.touchSession();
3527
- const [key, identifier] = (0, import_user_management_client5.extractWalletRef)(walletParams);
3528
- return this.constructPortalUrl("onRamp", {
3529
- partnerId: res.data.partnerId,
3530
- pathId: purchaseId,
3531
- sessionId: res.data.sessionId,
3532
- params: {
3533
- [key]: identifier,
3534
- providerKey,
3535
- currentWalletIds: JSON.stringify(this.currentWalletIds)
3536
- }
3537
- });
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
+ }
3538
3282
  });
3539
3283
  }
3540
3284
  /**
@@ -3548,95 +3292,91 @@ var _ParaCore = class _ParaCore {
3548
3292
  * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
3549
3293
  * @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
3550
3294
  **/
3551
- signMessage(_0) {
3552
- return __async(this, arguments, function* ({
3553
- walletId,
3554
- messageBase64,
3555
- timeoutMs = 3e4,
3556
- cosmosSignDocBase64
3557
- }) {
3558
- this.assertIsValidWalletId(walletId);
3559
- const wallet = this.wallets[walletId];
3560
- let signerId = this.userId;
3561
- if (wallet.partnerId && !wallet.userId) {
3562
- signerId = wallet.partnerId;
3563
- }
3564
- let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3565
- let timeStart = Date.now();
3566
- if (signRes.pendingTransactionId) {
3567
- this.platformUtils.openPopup(
3568
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3569
- { type: cosmosSignDocBase64 ? "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ : "SIGN_MESSAGE_REVIEW" /* SIGN_MESSAGE_REVIEW */ }
3570
- );
3571
- } else {
3572
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3573
- return signRes;
3574
- }
3575
- yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3576
- while (true) {
3577
- if (Date.now() - timeStart > timeoutMs) {
3578
- break;
3579
- }
3580
- try {
3581
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3582
- } catch (err) {
3583
- const error = new TransactionReviewDenied();
3584
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3585
- throw error;
3586
- }
3587
- signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3588
- if (signRes.pendingTransactionId) {
3589
- yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3590
- } else {
3591
- break;
3592
- }
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;
3593
3322
  }
3594
- if (signRes.pendingTransactionId) {
3595
- const error = new TransactionReviewTimeout(
3596
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3597
- signRes.pendingTransactionId
3598
- );
3323
+ try {
3324
+ await this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3325
+ } catch (err) {
3326
+ const error = new TransactionReviewDenied();
3599
3327
  dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
3600
3328
  throw error;
3601
3329
  }
3602
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
3603
- return signRes;
3604
- });
3605
- }
3606
- signMessageInner(_0) {
3607
- return __async(this, arguments, function* ({
3608
- wallet,
3609
- signerId,
3610
- messageBase64,
3611
- cosmosSignDocBase64
3612
- }) {
3613
- let signRes;
3614
- switch (wallet.scheme) {
3615
- case import_user_management_client5.WalletScheme.ED25519:
3616
- signRes = yield this.platformUtils.ed25519Sign(
3617
- this.ctx,
3618
- signerId,
3619
- wallet.id,
3620
- wallet.signer,
3621
- messageBase64,
3622
- this.retrieveSessionCookie()
3623
- );
3624
- break;
3625
- default:
3626
- signRes = yield this.platformUtils.signMessage(
3627
- this.ctx,
3628
- signerId,
3629
- wallet.id,
3630
- wallet.signer,
3631
- messageBase64,
3632
- this.retrieveSessionCookie(),
3633
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS,
3634
- cosmosSignDocBase64
3635
- );
3636
- break;
3330
+ signRes = await this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
3331
+ if (signRes.pendingTransactionId) {
3332
+ await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3333
+ } else {
3334
+ break;
3637
3335
  }
3638
- return signRes;
3639
- });
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
3376
+ );
3377
+ break;
3378
+ }
3379
+ return signRes;
3640
3380
  }
3641
3381
  /**
3642
3382
  * Signs a transaction.
@@ -3646,20 +3386,51 @@ var _ParaCore = class _ParaCore {
3646
3386
  * @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
3647
3387
  * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
3648
3388
  **/
3649
- signTransaction(_0) {
3650
- return __async(this, arguments, function* ({
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,
3651
3404
  walletId,
3405
+ this.wallets[walletId].signer,
3652
3406
  rlpEncodedTxBase64,
3653
3407
  chainId,
3654
- timeoutMs = 3e4
3655
- }) {
3656
- this.assertIsValidWalletId(walletId);
3657
- const wallet = this.wallets[walletId];
3658
- let signerId = this.userId;
3659
- if (wallet.partnerId && !wallet.userId) {
3660
- signerId = wallet.partnerId;
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;
3661
3432
  }
3662
- let signRes = yield this.platformUtils.signTransaction(
3433
+ signRes = await this.platformUtils.signTransaction(
3663
3434
  this.ctx,
3664
3435
  signerId,
3665
3436
  walletId,
@@ -3669,55 +3440,22 @@ var _ParaCore = class _ParaCore {
3669
3440
  this.retrieveSessionCookie(),
3670
3441
  wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3671
3442
  );
3672
- let timeStart = Date.now();
3673
3443
  if (signRes.pendingTransactionId) {
3674
- this.platformUtils.openPopup(
3675
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
3676
- { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3677
- );
3444
+ await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3678
3445
  } else {
3679
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3680
- return signRes;
3681
- }
3682
- yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3683
- while (true) {
3684
- if (Date.now() - timeStart > timeoutMs) {
3685
- break;
3686
- }
3687
- try {
3688
- yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
3689
- } catch (err) {
3690
- const error = new TransactionReviewDenied();
3691
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3692
- throw error;
3693
- }
3694
- signRes = yield this.platformUtils.signTransaction(
3695
- this.ctx,
3696
- signerId,
3697
- walletId,
3698
- this.wallets[walletId].signer,
3699
- rlpEncodedTxBase64,
3700
- chainId,
3701
- this.retrieveSessionCookie(),
3702
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS
3703
- );
3704
- if (signRes.pendingTransactionId) {
3705
- yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
3706
- } else {
3707
- break;
3708
- }
3709
- }
3710
- if (signRes.pendingTransactionId) {
3711
- const error = new TransactionReviewTimeout(
3712
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3713
- signRes.pendingTransactionId
3714
- );
3715
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
3716
- throw error;
3446
+ break;
3717
3447
  }
3718
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
3719
- return signRes;
3720
- });
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;
3721
3459
  }
3722
3460
  /**
3723
3461
  * @deprecated
@@ -3726,36 +3464,34 @@ var _ParaCore = class _ParaCore {
3726
3464
  * @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
3727
3465
  * @param chainId - chain id of the chain the transaction is being sent on.
3728
3466
  **/
3729
- sendTransaction(_0) {
3730
- return __async(this, arguments, function* ({
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,
3731
3477
  walletId,
3478
+ this.wallets[walletId].signer,
3732
3479
  rlpEncodedTxBase64,
3733
- chainId
3734
- }) {
3735
- this.assertIsValidWalletId(walletId);
3736
- const wallet = this.wallets[walletId];
3737
- const signRes = yield this.platformUtils.sendTransaction(
3738
- this.ctx,
3739
- this.userId,
3740
- walletId,
3741
- this.wallets[walletId].signer,
3742
- rlpEncodedTxBase64,
3743
- chainId,
3744
- this.retrieveSessionCookie(),
3745
- wallet.scheme === import_user_management_client5.WalletScheme.DKLS
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 */ }
3746
3488
  );
3747
- if (signRes.pendingTransactionId) {
3748
- this.platformUtils.openPopup(
3749
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
3750
- { type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
3751
- );
3752
- const error = new TransactionReviewError(
3753
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId)
3754
- );
3755
- throw error;
3756
- }
3757
- return signRes;
3758
- });
3489
+ const error = new TransactionReviewError(
3490
+ await this.getTransactionReviewUrl(signRes.pendingTransactionId)
3491
+ );
3492
+ throw error;
3493
+ }
3494
+ return signRes;
3759
3495
  }
3760
3496
  isProviderModalDisabled() {
3761
3497
  return !!this.disableProviderModal;
@@ -3768,38 +3504,36 @@ var _ParaCore = class _ParaCore {
3768
3504
  * @param {string} opts.walletId the wallet ID to use for the transaction, where funds will be sent or withdrawn.
3769
3505
  * @param {string} opts.externalWalletAddress the external wallet address to send funds to or withdraw funds from, if using an external wallet.
3770
3506
  **/
3771
- initiateOnRampTransaction(options) {
3772
- return __async(this, null, function* () {
3773
- var _b;
3774
- const _a = options, { params, shouldOpenPopup } = _a, walletParams = __objRest(_a, ["params", "shouldOpenPopup"]);
3775
- const onRampPurchase = yield this.ctx.client.createOnRampPurchase(__spreadValues({
3776
- userId: this.userId,
3777
- params: __spreadProps(__spreadValues({}, params), {
3778
- address: (_b = walletParams.externalWalletAddress) != null ? _b : this.getDisplayAddress(walletParams.walletId, { addressType: params.walletType })
3779
- })
3780
- }, walletParams));
3781
- const portalUrl = yield this.getOnRampTransactionUrl(__spreadValues({
3782
- purchaseId: onRampPurchase.id,
3783
- providerKey: onRampPurchase.providerKey
3784
- }, walletParams));
3785
- if (shouldOpenPopup) {
3786
- this.platformUtils.openPopup(portalUrl, { type: "ON_RAMP_TRANSACTION" /* ON_RAMP_TRANSACTION */ });
3787
- }
3788
- return { onRampPurchase, portalUrl };
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
3789
3521
  });
3522
+ if (shouldOpenPopup) {
3523
+ this.platformUtils.openPopup(portalUrl, { type: "ON_RAMP_TRANSACTION" /* ON_RAMP_TRANSACTION */ });
3524
+ }
3525
+ return { onRampPurchase, portalUrl };
3790
3526
  }
3791
3527
  /**
3792
3528
  * Returns `true` if session was successfully kept alive, `false` otherwise.
3793
3529
  **/
3794
- keepSessionAlive() {
3795
- return __async(this, null, function* () {
3796
- try {
3797
- yield this.ctx.client.keepSessionAlive(this.userId);
3798
- return true;
3799
- } catch (err) {
3800
- return false;
3801
- }
3802
- });
3530
+ async keepSessionAlive() {
3531
+ try {
3532
+ await this.ctx.client.keepSessionAlive(this.userId);
3533
+ return true;
3534
+ } catch (err) {
3535
+ return false;
3536
+ }
3803
3537
  }
3804
3538
  /**
3805
3539
  * Serialize the current session for import by another Para instance.
@@ -3824,37 +3558,34 @@ var _ParaCore = class _ParaCore {
3824
3558
  * Imports a session serialized by another Para instance.
3825
3559
  * @param {string} serializedInstanceBase64 the serialized session
3826
3560
  */
3827
- importSession(serializedInstanceBase64) {
3828
- return __async(this, null, function* () {
3829
- var _a;
3830
- const serializedInstance = Buffer.from(serializedInstanceBase64, "base64").toString("utf8");
3831
- const sessionInfo = JSON.parse(serializedInstance);
3832
- yield this.setEmail(sessionInfo.email);
3833
- yield this.setTelegramUserId(sessionInfo.telegramUserId);
3834
- yield this.setFarcasterUsername(sessionInfo.farcasterUsername);
3835
- yield this.setUserId(sessionInfo.userId);
3836
- yield this.setWallets(sessionInfo.wallets);
3837
- yield this.setExternalWallets(sessionInfo.externalWallets || {});
3838
- for (const walletId of Object.keys(this.wallets)) {
3839
- if (!this.wallets[walletId].userId) {
3840
- this.wallets[walletId].userId = this.userId;
3841
- }
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;
3842
3573
  }
3843
- if (Object.keys(sessionInfo.currentWalletIds).length !== 0) {
3844
- yield this.setCurrentWalletIds(sessionInfo.currentWalletIds);
3845
- } else {
3846
- const currentWalletIds = {};
3847
- for (const walletId of Object.keys(sessionInfo.wallets)) {
3848
- currentWalletIds[sessionInfo.wallets[walletId].type] = [
3849
- ...(_a = currentWalletIds[sessionInfo.wallets[walletId].type]) != null ? _a : [],
3850
- walletId
3851
- ];
3852
- }
3853
- yield this.setCurrentWalletIds(currentWalletIds);
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
+ ];
3854
3584
  }
3855
- this.persistSessionCookie(sessionInfo.sessionCookie);
3856
- yield this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
3857
- });
3585
+ await this.setCurrentWalletIds(currentWalletIds);
3586
+ }
3587
+ this.persistSessionCookie(sessionInfo.sessionCookie);
3588
+ await this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
3858
3589
  }
3859
3590
  exitAccountCreation() {
3860
3591
  this.isAwaitingAccountCreation = false;
@@ -3878,55 +3609,48 @@ var _ParaCore = class _ParaCore {
3878
3609
  * Retrieves a token to verify the current session.
3879
3610
  * @returns {Promise<string>} the ID
3880
3611
  **/
3881
- getVerificationToken() {
3882
- return __async(this, null, function* () {
3883
- const { data } = yield this.touchSession();
3884
- return data.sessionLookupId;
3885
- });
3612
+ async getVerificationToken() {
3613
+ const { data } = await this.touchSession();
3614
+ return data.sessionLookupId;
3886
3615
  }
3887
3616
  /**
3888
3617
  * Logs the user out.
3889
3618
  * @param {Object} opts the options object.
3890
3619
  * @param {boolean} opts.clearPregenWallets if `true`, will remove all pregen wallets from storage
3891
3620
  **/
3892
- logout() {
3893
- return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
3894
- yield this.ctx.client.logout();
3895
- yield this.clearStorage();
3896
- if (!clearPregenWallets) {
3897
- Object.entries(this.wallets).forEach(([id, wallet]) => {
3898
- if (!wallet.pregenIdentifier) {
3899
- delete this.wallets[id];
3900
- }
3901
- });
3902
- yield this.setWallets(this.wallets);
3903
- } else {
3904
- this.wallets = {};
3905
- }
3906
- this.currentWalletIds = {};
3907
- this.currentExternalWalletAddresses = void 0;
3908
- this.externalWallets = {};
3909
- this.loginEncryptionKeyPair = void 0;
3910
- this.email = void 0;
3911
- this.telegramUserId = void 0;
3912
- this.phone = void 0;
3913
- this.countryCode = void 0;
3914
- this.userId = void 0;
3915
- this.sessionCookie = void 0;
3916
- dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
3917
- });
3918
- }
3919
- getSupportedCreateAuthMethods() {
3920
- return __async(this, null, function* () {
3921
- const res = yield this.touchSession();
3922
- const partnerId = res.data.partnerId;
3923
- const partnerRes = yield this.ctx.client.getPartner(partnerId);
3924
- let supportedAuthMethods = /* @__PURE__ */ new Set();
3925
- for (const authMethod of partnerRes.data.partner.supportedAuthMethods) {
3926
- supportedAuthMethods.add(import_user_management_client5.AuthMethod[authMethod]);
3927
- }
3928
- return supportedAuthMethods;
3929
- });
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;
3930
3654
  }
3931
3655
  /**
3932
3656
  * Converts to a string, removing sensitive data when logging this class.
@@ -3935,10 +3659,12 @@ var _ParaCore = class _ParaCore {
3935
3659
  **/
3936
3660
  toString() {
3937
3661
  const redactedWallets = Object.keys(this.wallets).reduce(
3938
- (acc, walletId) => __spreadProps(__spreadValues({}, acc), {
3939
- [walletId]: __spreadProps(__spreadValues({}, this.wallets[walletId]), {
3662
+ (acc, walletId) => ({
3663
+ ...acc,
3664
+ [walletId]: {
3665
+ ...this.wallets[walletId],
3940
3666
  signer: this.wallets[walletId].signer ? "[REDACTED]" : void 0
3941
- })
3667
+ }
3942
3668
  }),
3943
3669
  {}
3944
3670
  );
@@ -3969,10 +3695,6 @@ var _ParaCore = class _ParaCore {
3969
3695
  return `Para ${JSON.stringify(obj, null, 2)}`;
3970
3696
  }
3971
3697
  };
3972
- _supportedWalletTypes = new WeakMap();
3973
- _supportedWalletTypesOpt = new WeakMap();
3974
- _ParaCore.version = PARA_CORE_VERSION;
3975
- var ParaCore = _ParaCore;
3976
3698
 
3977
3699
  // src/index.ts
3978
3700
  var import_user_management_client6 = require("@getpara/user-management-client");