@getpara/core-sdk 1.4.4 → 1.5.0-dev.0

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