@getpara/core-sdk 2.0.0-alpha.64 → 2.0.0-alpha.66

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.
@@ -116,7 +116,7 @@ const _ParaCore = class _ParaCore {
116
116
  __privateAdd(this, _ParaCore_instances);
117
117
  this.popupWindow = null;
118
118
  __privateAdd(this, _authInfo);
119
- // Track expected wallet IDs during wallet switching
119
+ this.isSwitchingWallets = false;
120
120
  this.isNativePasskey = false;
121
121
  this.isReady = false;
122
122
  this.accountLinkInProgress = void 0;
@@ -776,7 +776,8 @@ const _ParaCore = class _ParaCore {
776
776
  isTelegramLogin,
777
777
  isFarcasterLogin,
778
778
  isAddNewCredential,
779
- isSwitchWallets
779
+ isSwitchWallets,
780
+ isExportPrivateKey
780
781
  ] = [
781
782
  ["createAuth", "createPassword", "createPIN"].includes(type),
782
783
  ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
@@ -786,7 +787,8 @@ const _ParaCore = class _ParaCore {
786
787
  ["telegramLogin", "telegramLoginVerify"].includes(type),
787
788
  type === "loginFarcaster",
788
789
  type === "addNewCredential",
789
- type === "switchWallets"
790
+ type === "switchWallets",
791
+ type === "exportPrivateKey"
790
792
  ];
791
793
  if (isOAuth && !opts.oAuthMethod) {
792
794
  throw new Error("oAuthMethod is required for oAuth portal URLs");
@@ -795,7 +797,7 @@ const _ParaCore = class _ParaCore {
795
797
  this.assertIsAuthSet();
796
798
  }
797
799
  let sessionId = opts.sessionId;
798
- if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin) && !sessionId) {
800
+ if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin || isExportPrivateKey) && !sessionId) {
799
801
  const session = yield this.touchSession(true);
800
802
  sessionId = session.sessionId;
801
803
  }
@@ -869,6 +871,10 @@ const _ParaCore = class _ParaCore {
869
871
  path = "/auth/add-new-credential";
870
872
  break;
871
873
  }
874
+ case "exportPrivateKey": {
875
+ path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
876
+ break;
877
+ }
872
878
  default: {
873
879
  throw new Error(`invalid URL type ${type}`);
874
880
  }
@@ -901,12 +907,12 @@ const _ParaCore = class _ParaCore {
901
907
  portalTextColor: this.portalTextColor,
902
908
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
903
909
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
904
- }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets) ? __spreadProps(__spreadValues({
910
+ }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
905
911
  authInfo: JSON.stringify(this.authInfo)
906
912
  }, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
907
913
  pfpUrl: this.authInfo.pfpUrl,
908
914
  displayName: this.authInfo.displayName
909
- }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
915
+ }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
910
916
  sessionId: thisDevice.sessionId,
911
917
  encryptionKey: thisDevice.encryptionKey
912
918
  }, opts.newDevice ? {
@@ -1837,10 +1843,27 @@ Need help? Visit: https://docs.getpara.com or contact support
1837
1843
  if (this.externalWalletConnectionType === "VERIFICATION") {
1838
1844
  return isSessionActive;
1839
1845
  }
1840
- if (this.walletSwitchIds) {
1846
+ if (this.isSwitchingWallets) {
1841
1847
  return isSessionActive;
1842
1848
  }
1843
- return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1849
+ if (!isSessionActive) {
1850
+ return false;
1851
+ }
1852
+ if (this.isNoWalletConfig) {
1853
+ return true;
1854
+ }
1855
+ const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1856
+ const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
1857
+ for (const { type } of requiredWalletTypes) {
1858
+ const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
1859
+ const wallet = this.wallets[walletId];
1860
+ return wallet && walletType === type;
1861
+ });
1862
+ if (!hasWalletForType) {
1863
+ return false;
1864
+ }
1865
+ }
1866
+ return true;
1844
1867
  });
1845
1868
  }
1846
1869
  get isGuestMode() {
@@ -3264,7 +3287,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3264
3287
  return { credentialId };
3265
3288
  }
3266
3289
  const { sessionId } = yield this.touchSession();
3267
- const url = yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
3290
+ const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
3268
3291
  isForNewDevice,
3269
3292
  pathId: credentialId,
3270
3293
  portalTheme,
@@ -3273,7 +3296,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3273
3296
  addNewCredentialType: optsAuthMethod,
3274
3297
  addNewCredentialPasskeyId: passkeyId,
3275
3298
  addNewCredentialPasswordId: passwordId
3276
- });
3299
+ }));
3277
3300
  return __spreadValues({ credentialId }, url ? { url } : {});
3278
3301
  });
3279
3302
  }
@@ -3513,6 +3536,40 @@ Need help? Visit: https://docs.getpara.com or contact support
3513
3536
  this.setUserId(userId);
3514
3537
  });
3515
3538
  }
3539
+ exportPrivateKey() {
3540
+ return __async(this, arguments, function* (args = {}) {
3541
+ let walletId = args == null ? void 0 : args.walletId;
3542
+ if (!(args == null ? void 0 : args.walletId)) {
3543
+ walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
3544
+ }
3545
+ const wallet = this.wallets[walletId];
3546
+ if (this.externalWallets[walletId]) {
3547
+ throw new Error("Cannot export private key for an external wallet");
3548
+ }
3549
+ if (!wallet || !wallet.signer) {
3550
+ throw new Error("Wallet not found with id: " + walletId);
3551
+ }
3552
+ if (wallet.scheme !== "DKLS") {
3553
+ throw new Error("Cannot export private key for a Solana wallet");
3554
+ }
3555
+ if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
3556
+ throw new Error("Cannot export private key for a pregenerated wallet");
3557
+ }
3558
+ if (args.shouldOpenPopup) {
3559
+ this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
3560
+ }
3561
+ const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
3562
+ pathId: walletId
3563
+ });
3564
+ if (args.shouldOpenPopup) {
3565
+ this.popupWindow.location.href = exportPrivateKeyUrl;
3566
+ }
3567
+ return {
3568
+ url: exportPrivateKeyUrl,
3569
+ popupWindow: this.popupWindow
3570
+ };
3571
+ });
3572
+ }
3516
3573
  };
3517
3574
  _authInfo = new WeakMap();
3518
3575
  _ParaCore_instances = new WeakSet();
@@ -3669,17 +3726,42 @@ waitForLoginProcess_fn = function() {
3669
3726
  skipSessionRefresh = false,
3670
3727
  isSwitchingWallets = false
3671
3728
  } = {}) {
3729
+ this.devLog("[waitForLoginProcess] Starting", {
3730
+ isSwitchingWallets,
3731
+ skipSessionRefresh,
3732
+ isExternalWalletAuth: this.isExternalWalletAuth
3733
+ });
3672
3734
  const startedAt = Date.now();
3735
+ let originalCurrentWalletIdsHash;
3736
+ if (isSwitchingWallets) {
3737
+ this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
3738
+ this.isSwitchingWallets = true;
3739
+ const session = yield this.touchSession();
3740
+ originalCurrentWalletIdsHash = session.currentWalletIdsHash;
3741
+ this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
3742
+ }
3673
3743
  return new Promise((resolve, reject) => {
3674
3744
  (() => __async(this, null, function* () {
3675
3745
  var _a;
3676
3746
  if (!this.isExternalWalletAuth && !isSwitchingWallets) {
3747
+ this.devLog("[waitForLoginProcess] Clearing external wallets");
3677
3748
  this.externalWallets = {};
3678
3749
  }
3750
+ let pollCount = 0;
3679
3751
  while (true) {
3752
+ pollCount++;
3753
+ this.devLog("[waitForLoginProcess] Poll iteration", {
3754
+ pollCount,
3755
+ elapsedMs: Date.now() - startedAt
3756
+ });
3680
3757
  if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
3758
+ this.devLog("[waitForLoginProcess] Canceled or timed out", {
3759
+ wasCanceled: isCanceled(),
3760
+ timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
3761
+ elapsedMs: Date.now() - startedAt
3762
+ });
3681
3763
  if (isSwitchingWallets) {
3682
- this.walletSwitchIds = void 0;
3764
+ this.isSwitchingWallets = false;
3683
3765
  } else {
3684
3766
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
3685
3767
  }
@@ -3688,58 +3770,108 @@ waitForLoginProcess_fn = function() {
3688
3770
  }
3689
3771
  yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
3690
3772
  try {
3773
+ this.devLog("[waitForLoginProcess] Touching session");
3691
3774
  let session = yield this.touchSession();
3692
- const shouldContinuePolling = !isSwitchingWallets && !session.isAuthenticated || isSwitchingWallets && !this.walletSwitchIds;
3775
+ this.devLog("[waitForLoginProcess] Session state", {
3776
+ isAuthenticated: session.isAuthenticated,
3777
+ currentWalletIdsHash: session.currentWalletIdsHash,
3778
+ needsWallet: session.needsWallet
3779
+ });
3780
+ const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
3781
+ this.devLog("[waitForLoginProcess] Should continue polling", {
3782
+ shouldContinuePolling,
3783
+ isSwitchingWallets,
3784
+ originalCurrentWalletIdsHash,
3785
+ sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
3786
+ isAuthenticated: session.isAuthenticated
3787
+ });
3693
3788
  if (shouldContinuePolling) {
3694
3789
  onPoll == null ? void 0 : onPoll();
3695
3790
  continue;
3696
3791
  }
3792
+ this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
3697
3793
  session = yield this.userSetupAfterLogin();
3698
3794
  const needsWallet = (_a = session.needsWallet) != null ? _a : false;
3795
+ this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
3699
3796
  if (isSwitchingWallets) {
3700
- if (this.walletSwitchIds) {
3701
- const walletIdsMatch = (0, import_utils2.currentWalletIdsEq)(session.currentWalletIds, this.walletSwitchIds);
3702
- if (!walletIdsMatch) {
3703
- onPoll == null ? void 0 : onPoll();
3704
- continue;
3705
- }
3706
- } else {
3797
+ const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
3798
+ this.devLog("[waitForLoginProcess] Wallet switching check", {
3799
+ isWalletSwitchingComplete,
3800
+ originalHash: originalCurrentWalletIdsHash,
3801
+ sessionHash: session.currentWalletIdsHash
3802
+ });
3803
+ if (!isWalletSwitchingComplete) {
3707
3804
  onPoll == null ? void 0 : onPoll();
3708
3805
  continue;
3709
3806
  }
3710
3807
  } else if (!needsWallet) {
3808
+ this.devLog("[waitForLoginProcess] Checking wallet IDs", {
3809
+ currentWalletIdsArrayLength: this.currentWalletIdsArray.length
3810
+ });
3711
3811
  if (this.currentWalletIdsArray.length === 0) {
3812
+ this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
3712
3813
  onPoll == null ? void 0 : onPoll();
3713
3814
  continue;
3714
3815
  }
3715
3816
  }
3817
+ this.devLog("[waitForLoginProcess] Getting transmission key shares");
3716
3818
  const tempSharesRes = yield this.getTransmissionKeyShares();
3819
+ this.devLog("[waitForLoginProcess] Transmission shares received", {
3820
+ shareCount: tempSharesRes.data.temporaryShares.length,
3821
+ shares: tempSharesRes.data.temporaryShares.map((s) => ({
3822
+ walletId: s.walletId,
3823
+ walletScheme: s.walletScheme
3824
+ }))
3825
+ });
3717
3826
  let hasSharesForCurrentWallets;
3718
3827
  if (!isSwitchingWallets) {
3828
+ this.devLog("[waitForLoginProcess] Fetching wallets");
3719
3829
  const fetchedWallets = yield this.fetchWallets();
3830
+ this.devLog("[waitForLoginProcess] Wallets fetched", {
3831
+ walletCount: fetchedWallets.length,
3832
+ wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
3833
+ });
3720
3834
  hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
3721
3835
  } else {
3722
3836
  hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
3723
3837
  return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
3724
3838
  });
3725
3839
  }
3840
+ this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
3841
+ hasSharesForCurrentWallets,
3842
+ currentWalletIdsCount: this.currentWalletIdsArray.length,
3843
+ shareCount: tempSharesRes.data.temporaryShares.length
3844
+ });
3726
3845
  if (hasSharesForCurrentWallets) {
3846
+ this.devLog("[waitForLoginProcess] Setting up after login");
3727
3847
  yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
3848
+ this.devLog("[waitForLoginProcess] Setup after login complete");
3849
+ this.devLog("[waitForLoginProcess] Claiming pregen wallets");
3728
3850
  yield this.claimPregenWallets();
3851
+ this.devLog("[waitForLoginProcess] Pregen wallets claimed");
3729
3852
  const resp = {
3730
3853
  needsWallet: needsWallet || Object.values(this.wallets).length === 0,
3731
3854
  partnerId: session.partnerId
3732
3855
  };
3856
+ this.devLog("[waitForLoginProcess] Login process complete", {
3857
+ needsWallet: resp.needsWallet,
3858
+ partnerId: resp.partnerId,
3859
+ walletCount: Object.values(this.wallets).length,
3860
+ isSwitchingWallets
3861
+ });
3733
3862
  if (isSwitchingWallets) {
3734
- this.walletSwitchIds = void 0;
3863
+ this.devLog("[waitForLoginProcess] Clearing wallet switching state");
3864
+ this.isSwitchingWallets = false;
3735
3865
  } else {
3866
+ this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
3736
3867
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
3737
3868
  }
3738
3869
  return resolve(resp);
3739
3870
  }
3871
+ this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
3740
3872
  onPoll == null ? void 0 : onPoll();
3741
3873
  } catch (err) {
3742
- console.error(err);
3874
+ console.error("[waitForLoginProcess] Error during polling iteration", err);
3743
3875
  onPoll == null ? void 0 : onPoll();
3744
3876
  }
3745
3877
  }
@@ -20,7 +20,6 @@ __export(constants_exports, {
20
20
  ACCOUNT_LINK_CONFLICT: () => ACCOUNT_LINK_CONFLICT,
21
21
  EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID: () => EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
22
22
  LOCAL_STORAGE_AUTH_INFO: () => LOCAL_STORAGE_AUTH_INFO,
23
- LOCAL_STORAGE_AUTH_METHOD: () => LOCAL_STORAGE_AUTH_METHOD,
24
23
  LOCAL_STORAGE_COUNTRY_CODE: () => LOCAL_STORAGE_COUNTRY_CODE,
25
24
  LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
26
25
  LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
@@ -44,7 +43,7 @@ __export(constants_exports, {
44
43
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
45
44
  });
46
45
  module.exports = __toCommonJS(constants_exports);
47
- const PARA_CORE_VERSION = "2.0.0-alpha.64";
46
+ const PARA_CORE_VERSION = "2.0.0-alpha.66";
48
47
  const PREFIX = "@CAPSULE/";
49
48
  const PARA_PREFIX = "@PARA/";
50
49
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -62,7 +61,6 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
62
61
  const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
63
62
  const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
64
63
  const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
65
- const LOCAL_STORAGE_AUTH_METHOD = `${PREFIX}authMethod`;
66
64
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
67
65
  const POLLING_INTERVAL_MS = 2e3;
68
66
  const SHORT_POLLING_INTERVAL_MS = 1e3;
@@ -74,7 +72,6 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
74
72
  ACCOUNT_LINK_CONFLICT,
75
73
  EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
76
74
  LOCAL_STORAGE_AUTH_INFO,
77
- LOCAL_STORAGE_AUTH_METHOD,
78
75
  LOCAL_STORAGE_COUNTRY_CODE,
79
76
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
80
77
  LOCAL_STORAGE_ED25519_WALLETS,
@@ -54,15 +54,16 @@ module.exports = __toCommonJS(transmissionUtils_exports);
54
54
  var import_ecies = require("@celo/utils/lib/ecies.js");
55
55
  var import_buffer = require("buffer");
56
56
  var eutil = __toESM(require("@ethereumjs/util"));
57
- var import_crypto = require("crypto");
58
57
  function upload(message, userManagementClient) {
59
58
  return __async(this, null, function* () {
60
59
  let secret;
61
60
  let publicKeyUint8Array;
62
61
  while (true) {
63
62
  try {
64
- secret = (0, import_crypto.randomBytes)(32).toString("hex");
65
- publicKeyUint8Array = eutil.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
63
+ const privateKeyUint8Array = new Uint8Array(32);
64
+ crypto.getRandomValues(privateKeyUint8Array);
65
+ secret = import_buffer.Buffer.from(privateKeyUint8Array).toString("hex");
66
+ publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
66
67
  break;
67
68
  } catch (e) {
68
69
  continue;
@@ -71,7 +71,8 @@ const PARA_CORE_METHODS = [
71
71
  "issueJwt",
72
72
  "getLinkedAccounts",
73
73
  "accountLinkInProgress",
74
- "addCredential"
74
+ "addCredential",
75
+ "exportPrivateKey"
75
76
  ];
76
77
  const PARA_INTERNAL_METHODS = [
77
78
  "linkAccount",
@@ -27,6 +27,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
27
27
  PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
28
28
  PopupType2["OAUTH"] = "OAUTH";
29
29
  PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
30
+ PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
30
31
  return PopupType2;
31
32
  })(PopupType || {});
32
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -29,7 +29,7 @@ function isPortal(ctx, env) {
29
29
  if (!isOnPortalDomain) return false;
30
30
  const isInIframe = window.parent !== window && !window.opener;
31
31
  const isInPopup = window.opener && window.parent === window;
32
- const isDirectAccess = !window.opener && !window.parent;
32
+ const isDirectAccess = window.parent === window && !window.opener;
33
33
  return isInIframe || isInPopup || isDirectAccess;
34
34
  }
35
35
  // Annotate the CommonJS export names for ESM import in node:
@@ -82,7 +82,7 @@ const _ParaCore = class _ParaCore {
82
82
  __privateAdd(this, _ParaCore_instances);
83
83
  this.popupWindow = null;
84
84
  __privateAdd(this, _authInfo);
85
- // Track expected wallet IDs during wallet switching
85
+ this.isSwitchingWallets = false;
86
86
  this.isNativePasskey = false;
87
87
  this.isReady = false;
88
88
  this.accountLinkInProgress = void 0;
@@ -742,7 +742,8 @@ const _ParaCore = class _ParaCore {
742
742
  isTelegramLogin,
743
743
  isFarcasterLogin,
744
744
  isAddNewCredential,
745
- isSwitchWallets
745
+ isSwitchWallets,
746
+ isExportPrivateKey
746
747
  ] = [
747
748
  ["createAuth", "createPassword", "createPIN"].includes(type),
748
749
  ["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets"].includes(type),
@@ -752,7 +753,8 @@ const _ParaCore = class _ParaCore {
752
753
  ["telegramLogin", "telegramLoginVerify"].includes(type),
753
754
  type === "loginFarcaster",
754
755
  type === "addNewCredential",
755
- type === "switchWallets"
756
+ type === "switchWallets",
757
+ type === "exportPrivateKey"
756
758
  ];
757
759
  if (isOAuth && !opts.oAuthMethod) {
758
760
  throw new Error("oAuthMethod is required for oAuth portal URLs");
@@ -761,7 +763,7 @@ const _ParaCore = class _ParaCore {
761
763
  this.assertIsAuthSet();
762
764
  }
763
765
  let sessionId = opts.sessionId;
764
- if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin) && !sessionId) {
766
+ if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin || isExportPrivateKey) && !sessionId) {
765
767
  const session = yield this.touchSession(true);
766
768
  sessionId = session.sessionId;
767
769
  }
@@ -835,6 +837,10 @@ const _ParaCore = class _ParaCore {
835
837
  path = "/auth/add-new-credential";
836
838
  break;
837
839
  }
840
+ case "exportPrivateKey": {
841
+ path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
842
+ break;
843
+ }
838
844
  default: {
839
845
  throw new Error(`invalid URL type ${type}`);
840
846
  }
@@ -867,12 +873,12 @@ const _ParaCore = class _ParaCore {
867
873
  portalTextColor: this.portalTextColor,
868
874
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
869
875
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
870
- }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets) ? __spreadProps(__spreadValues({
876
+ }, this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
871
877
  authInfo: JSON.stringify(this.authInfo)
872
878
  }, isPhone(this.authInfo.auth) ? splitPhoneNumber(this.authInfo.auth.phone) : this.authInfo.auth), {
873
879
  pfpUrl: this.authInfo.pfpUrl,
874
880
  displayName: this.authInfo.displayName
875
- }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
881
+ }) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential || isExportPrivateKey ? __spreadProps(__spreadValues({
876
882
  sessionId: thisDevice.sessionId,
877
883
  encryptionKey: thisDevice.encryptionKey
878
884
  }, opts.newDevice ? {
@@ -1803,10 +1809,27 @@ Need help? Visit: https://docs.getpara.com or contact support
1803
1809
  if (this.externalWalletConnectionType === "VERIFICATION") {
1804
1810
  return isSessionActive;
1805
1811
  }
1806
- if (this.walletSwitchIds) {
1812
+ if (this.isSwitchingWallets) {
1807
1813
  return isSessionActive;
1808
1814
  }
1809
- return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1815
+ if (!isSessionActive) {
1816
+ return false;
1817
+ }
1818
+ if (this.isNoWalletConfig) {
1819
+ return true;
1820
+ }
1821
+ const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
1822
+ const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
1823
+ for (const { type } of requiredWalletTypes) {
1824
+ const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
1825
+ const wallet = this.wallets[walletId];
1826
+ return wallet && walletType === type;
1827
+ });
1828
+ if (!hasWalletForType) {
1829
+ return false;
1830
+ }
1831
+ }
1832
+ return true;
1810
1833
  });
1811
1834
  }
1812
1835
  get isGuestMode() {
@@ -3230,7 +3253,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3230
3253
  return { credentialId };
3231
3254
  }
3232
3255
  const { sessionId } = yield this.touchSession();
3233
- const url = yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
3256
+ const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
3234
3257
  isForNewDevice,
3235
3258
  pathId: credentialId,
3236
3259
  portalTheme,
@@ -3239,7 +3262,7 @@ Need help? Visit: https://docs.getpara.com or contact support
3239
3262
  addNewCredentialType: optsAuthMethod,
3240
3263
  addNewCredentialPasskeyId: passkeyId,
3241
3264
  addNewCredentialPasswordId: passwordId
3242
- });
3265
+ }));
3243
3266
  return __spreadValues({ credentialId }, url ? { url } : {});
3244
3267
  });
3245
3268
  }
@@ -3479,6 +3502,40 @@ Need help? Visit: https://docs.getpara.com or contact support
3479
3502
  this.setUserId(userId);
3480
3503
  });
3481
3504
  }
3505
+ exportPrivateKey() {
3506
+ return __async(this, arguments, function* (args = {}) {
3507
+ let walletId = args == null ? void 0 : args.walletId;
3508
+ if (!(args == null ? void 0 : args.walletId)) {
3509
+ walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
3510
+ }
3511
+ const wallet = this.wallets[walletId];
3512
+ if (this.externalWallets[walletId]) {
3513
+ throw new Error("Cannot export private key for an external wallet");
3514
+ }
3515
+ if (!wallet || !wallet.signer) {
3516
+ throw new Error("Wallet not found with id: " + walletId);
3517
+ }
3518
+ if (wallet.scheme !== "DKLS") {
3519
+ throw new Error("Cannot export private key for a Solana wallet");
3520
+ }
3521
+ if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
3522
+ throw new Error("Cannot export private key for a pregenerated wallet");
3523
+ }
3524
+ if (args.shouldOpenPopup) {
3525
+ this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: PopupType.EXPORT_PRIVATE_KEY });
3526
+ }
3527
+ const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
3528
+ pathId: walletId
3529
+ });
3530
+ if (args.shouldOpenPopup) {
3531
+ this.popupWindow.location.href = exportPrivateKeyUrl;
3532
+ }
3533
+ return {
3534
+ url: exportPrivateKeyUrl,
3535
+ popupWindow: this.popupWindow
3536
+ };
3537
+ });
3538
+ }
3482
3539
  };
3483
3540
  _authInfo = new WeakMap();
3484
3541
  _ParaCore_instances = new WeakSet();
@@ -3635,17 +3692,42 @@ waitForLoginProcess_fn = function() {
3635
3692
  skipSessionRefresh = false,
3636
3693
  isSwitchingWallets = false
3637
3694
  } = {}) {
3695
+ this.devLog("[waitForLoginProcess] Starting", {
3696
+ isSwitchingWallets,
3697
+ skipSessionRefresh,
3698
+ isExternalWalletAuth: this.isExternalWalletAuth
3699
+ });
3638
3700
  const startedAt = Date.now();
3701
+ let originalCurrentWalletIdsHash;
3702
+ if (isSwitchingWallets) {
3703
+ this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
3704
+ this.isSwitchingWallets = true;
3705
+ const session = yield this.touchSession();
3706
+ originalCurrentWalletIdsHash = session.currentWalletIdsHash;
3707
+ this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
3708
+ }
3639
3709
  return new Promise((resolve, reject) => {
3640
3710
  (() => __async(this, null, function* () {
3641
3711
  var _a;
3642
3712
  if (!this.isExternalWalletAuth && !isSwitchingWallets) {
3713
+ this.devLog("[waitForLoginProcess] Clearing external wallets");
3643
3714
  this.externalWallets = {};
3644
3715
  }
3716
+ let pollCount = 0;
3645
3717
  while (true) {
3718
+ pollCount++;
3719
+ this.devLog("[waitForLoginProcess] Poll iteration", {
3720
+ pollCount,
3721
+ elapsedMs: Date.now() - startedAt
3722
+ });
3646
3723
  if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
3724
+ this.devLog("[waitForLoginProcess] Canceled or timed out", {
3725
+ wasCanceled: isCanceled(),
3726
+ timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
3727
+ elapsedMs: Date.now() - startedAt
3728
+ });
3647
3729
  if (isSwitchingWallets) {
3648
- this.walletSwitchIds = void 0;
3730
+ this.isSwitchingWallets = false;
3649
3731
  } else {
3650
3732
  dispatchEvent(ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
3651
3733
  }
@@ -3654,58 +3736,108 @@ waitForLoginProcess_fn = function() {
3654
3736
  }
3655
3737
  yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
3656
3738
  try {
3739
+ this.devLog("[waitForLoginProcess] Touching session");
3657
3740
  let session = yield this.touchSession();
3658
- const shouldContinuePolling = !isSwitchingWallets && !session.isAuthenticated || isSwitchingWallets && !this.walletSwitchIds;
3741
+ this.devLog("[waitForLoginProcess] Session state", {
3742
+ isAuthenticated: session.isAuthenticated,
3743
+ currentWalletIdsHash: session.currentWalletIdsHash,
3744
+ needsWallet: session.needsWallet
3745
+ });
3746
+ const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
3747
+ this.devLog("[waitForLoginProcess] Should continue polling", {
3748
+ shouldContinuePolling,
3749
+ isSwitchingWallets,
3750
+ originalCurrentWalletIdsHash,
3751
+ sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
3752
+ isAuthenticated: session.isAuthenticated
3753
+ });
3659
3754
  if (shouldContinuePolling) {
3660
3755
  onPoll == null ? void 0 : onPoll();
3661
3756
  continue;
3662
3757
  }
3758
+ this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
3663
3759
  session = yield this.userSetupAfterLogin();
3664
3760
  const needsWallet = (_a = session.needsWallet) != null ? _a : false;
3761
+ this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
3665
3762
  if (isSwitchingWallets) {
3666
- if (this.walletSwitchIds) {
3667
- const walletIdsMatch = currentWalletIdsEq(session.currentWalletIds, this.walletSwitchIds);
3668
- if (!walletIdsMatch) {
3669
- onPoll == null ? void 0 : onPoll();
3670
- continue;
3671
- }
3672
- } else {
3763
+ const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
3764
+ this.devLog("[waitForLoginProcess] Wallet switching check", {
3765
+ isWalletSwitchingComplete,
3766
+ originalHash: originalCurrentWalletIdsHash,
3767
+ sessionHash: session.currentWalletIdsHash
3768
+ });
3769
+ if (!isWalletSwitchingComplete) {
3673
3770
  onPoll == null ? void 0 : onPoll();
3674
3771
  continue;
3675
3772
  }
3676
3773
  } else if (!needsWallet) {
3774
+ this.devLog("[waitForLoginProcess] Checking wallet IDs", {
3775
+ currentWalletIdsArrayLength: this.currentWalletIdsArray.length
3776
+ });
3677
3777
  if (this.currentWalletIdsArray.length === 0) {
3778
+ this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
3678
3779
  onPoll == null ? void 0 : onPoll();
3679
3780
  continue;
3680
3781
  }
3681
3782
  }
3783
+ this.devLog("[waitForLoginProcess] Getting transmission key shares");
3682
3784
  const tempSharesRes = yield this.getTransmissionKeyShares();
3785
+ this.devLog("[waitForLoginProcess] Transmission shares received", {
3786
+ shareCount: tempSharesRes.data.temporaryShares.length,
3787
+ shares: tempSharesRes.data.temporaryShares.map((s) => ({
3788
+ walletId: s.walletId,
3789
+ walletScheme: s.walletScheme
3790
+ }))
3791
+ });
3683
3792
  let hasSharesForCurrentWallets;
3684
3793
  if (!isSwitchingWallets) {
3794
+ this.devLog("[waitForLoginProcess] Fetching wallets");
3685
3795
  const fetchedWallets = yield this.fetchWallets();
3796
+ this.devLog("[waitForLoginProcess] Wallets fetched", {
3797
+ walletCount: fetchedWallets.length,
3798
+ wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
3799
+ });
3686
3800
  hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
3687
3801
  } else {
3688
3802
  hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
3689
3803
  return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
3690
3804
  });
3691
3805
  }
3806
+ this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
3807
+ hasSharesForCurrentWallets,
3808
+ currentWalletIdsCount: this.currentWalletIdsArray.length,
3809
+ shareCount: tempSharesRes.data.temporaryShares.length
3810
+ });
3692
3811
  if (hasSharesForCurrentWallets) {
3812
+ this.devLog("[waitForLoginProcess] Setting up after login");
3693
3813
  yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
3814
+ this.devLog("[waitForLoginProcess] Setup after login complete");
3815
+ this.devLog("[waitForLoginProcess] Claiming pregen wallets");
3694
3816
  yield this.claimPregenWallets();
3817
+ this.devLog("[waitForLoginProcess] Pregen wallets claimed");
3695
3818
  const resp = {
3696
3819
  needsWallet: needsWallet || Object.values(this.wallets).length === 0,
3697
3820
  partnerId: session.partnerId
3698
3821
  };
3822
+ this.devLog("[waitForLoginProcess] Login process complete", {
3823
+ needsWallet: resp.needsWallet,
3824
+ partnerId: resp.partnerId,
3825
+ walletCount: Object.values(this.wallets).length,
3826
+ isSwitchingWallets
3827
+ });
3699
3828
  if (isSwitchingWallets) {
3700
- this.walletSwitchIds = void 0;
3829
+ this.devLog("[waitForLoginProcess] Clearing wallet switching state");
3830
+ this.isSwitchingWallets = false;
3701
3831
  } else {
3832
+ this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
3702
3833
  dispatchEvent(ParaEvent.LOGIN_EVENT, resp);
3703
3834
  }
3704
3835
  return resolve(resp);
3705
3836
  }
3837
+ this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
3706
3838
  onPoll == null ? void 0 : onPoll();
3707
3839
  } catch (err) {
3708
- console.error(err);
3840
+ console.error("[waitForLoginProcess] Error during polling iteration", err);
3709
3841
  onPoll == null ? void 0 : onPoll();
3710
3842
  }
3711
3843
  }
@@ -1,5 +1,5 @@
1
1
  import "./chunk-W5CT3TVS.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.64";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.66";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -17,7 +17,6 @@ const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
17
17
  const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
18
18
  const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
19
19
  const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
20
- const LOCAL_STORAGE_AUTH_METHOD = `${PREFIX}authMethod`;
21
20
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
22
21
  const POLLING_INTERVAL_MS = 2e3;
23
22
  const SHORT_POLLING_INTERVAL_MS = 1e3;
@@ -28,7 +27,6 @@ export {
28
27
  ACCOUNT_LINK_CONFLICT,
29
28
  EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
30
29
  LOCAL_STORAGE_AUTH_INFO,
31
- LOCAL_STORAGE_AUTH_METHOD,
32
30
  LOCAL_STORAGE_COUNTRY_CODE,
33
31
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
34
32
  LOCAL_STORAGE_ED25519_WALLETS,
@@ -4,15 +4,16 @@ import {
4
4
  import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
5
5
  import { Buffer } from "buffer";
6
6
  import * as eutil from "@ethereumjs/util";
7
- import { randomBytes } from "crypto";
8
7
  function upload(message, userManagementClient) {
9
8
  return __async(this, null, function* () {
10
9
  let secret;
11
10
  let publicKeyUint8Array;
12
11
  while (true) {
13
12
  try {
14
- secret = randomBytes(32).toString("hex");
15
- publicKeyUint8Array = eutil.privateToPublic(Buffer.from(secret, "hex"));
13
+ const privateKeyUint8Array = new Uint8Array(32);
14
+ crypto.getRandomValues(privateKeyUint8Array);
15
+ secret = Buffer.from(privateKeyUint8Array).toString("hex");
16
+ publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
16
17
  break;
17
18
  } catch (e) {
18
19
  continue;
@@ -49,7 +49,8 @@ const PARA_CORE_METHODS = [
49
49
  "issueJwt",
50
50
  "getLinkedAccounts",
51
51
  "accountLinkInProgress",
52
- "addCredential"
52
+ "addCredential",
53
+ "exportPrivateKey"
53
54
  ];
54
55
  const PARA_INTERNAL_METHODS = [
55
56
  "linkAccount",
@@ -6,6 +6,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
6
6
  PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
7
7
  PopupType2["OAUTH"] = "OAUTH";
8
8
  PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
9
+ PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
9
10
  return PopupType2;
10
11
  })(PopupType || {});
11
12
  export {
@@ -8,7 +8,7 @@ function isPortal(ctx, env) {
8
8
  if (!isOnPortalDomain) return false;
9
9
  const isInIframe = window.parent !== window && !window.opener;
10
10
  const isInPopup = window.opener && window.parent === window;
11
- const isDirectAccess = !window.opener && !window.parent;
11
+ const isDirectAccess = window.parent === window && !window.opener;
12
12
  return isInIframe || isInPopup || isDirectAccess;
13
13
  }
14
14
  export {
@@ -1,13 +1,13 @@
1
1
  import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme } from '@getpara/user-management-client';
2
2
  import type { pki as pkiType } from 'node-forge';
3
- import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } from './types/index.js';
3
+ import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, AvailableWallet } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
5
5
  export declare abstract class ParaCore implements CoreInterface {
6
6
  #private;
7
7
  popupWindow: Window | null;
8
8
  static version?: string;
9
9
  ctx: Ctx;
10
- protected walletSwitchIds?: CurrentWalletIds;
10
+ protected isSwitchingWallets: boolean;
11
11
  protected isNativePasskey: boolean;
12
12
  protected isPartnerOptional?: boolean;
13
13
  protected setModalError(_error?: string): void;
@@ -352,7 +352,7 @@ export declare abstract class ParaCore implements CoreInterface {
352
352
  */
353
353
  findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
354
354
  findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
355
- get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>[];
355
+ get availableWallets(): AvailableWallet[];
356
356
  /**
357
357
  * Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
358
358
  * @param {string} type the wallet type to filter by.
@@ -719,7 +719,7 @@ export declare abstract class ParaCore implements CoreInterface {
719
719
  * Doesn't work for all types of logging.
720
720
  **/
721
721
  toString(): string;
722
- protected devLog(...s: string[]): void;
722
+ protected devLog(...s: any[]): void;
723
723
  protected getNewCredentialAndUrl({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
724
724
  credentialId: string;
725
725
  url?: string;
@@ -749,4 +749,5 @@ export declare abstract class ParaCore implements CoreInterface {
749
749
  refetch?: boolean;
750
750
  }): Promise<import("@getpara/user-management-client").ProfileBalance>;
751
751
  protected sendLoginCode(): Promise<void>;
752
+ exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
752
753
  }
@@ -16,7 +16,6 @@ export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletI
16
16
  export declare const LOCAL_STORAGE_SESSION_COOKIE = "@CAPSULE/sessionCookie";
17
17
  export declare const LOCAL_STORAGE_ENCLAVE_JWT = "@CAPSULE/enclaveJwt";
18
18
  export declare const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = "@CAPSULE/enclaveRefreshJwt";
19
- export declare const LOCAL_STORAGE_AUTH_METHOD = "@CAPSULE/authMethod";
20
19
  export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
21
20
  export declare const POLLING_INTERVAL_MS = 2000;
22
21
  export declare const SHORT_POLLING_INTERVAL_MS = 1000;
@@ -1,6 +1,6 @@
1
1
  import { ParaCore } from './ParaCore.js';
2
2
  export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type TAuthMethod, AuthMethodStatus, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TNetwork, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, type TOnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAssets, type OnRampPurchase, type OnRampAssetInfo, type ProviderAssetInfo, OnRampMethod, type Theme, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, type AssetMetadata, type AssetMetadataIndexed, type AssetValue, type BalancesConfig, type WalletBalance, type ProfileBalance, type OfframpDepositRequest, RecoveryStatus, ThemeMode, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, } from '@getpara/user-management-client';
3
- export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
3
+ export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type AvailableWallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
4
4
  export * from './types/coreApi.js';
5
5
  export * from './types/events.js';
6
6
  export * from './types/config.js';
@@ -3,7 +3,7 @@ import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, Wi
3
3
  import { ParaCore } from '../ParaCore.js';
4
4
  import { FullSignatureRes, Wallet } from './wallet.js';
5
5
  import { AccountLinkInProgress } from './auth.js';
6
- export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential"];
6
+ export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential", "exportPrivateKey"];
7
7
  export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
8
8
  export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
9
9
  export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
@@ -488,6 +488,16 @@ export type CoreMethods = Record<CoreMethodName, {
488
488
  params: Pick<NewCredentialUrlParams, 'authMethod'>;
489
489
  response: Promise<string>;
490
490
  };
491
+ exportPrivateKey: {
492
+ params: {
493
+ walletId?: string;
494
+ shouldOpenPopup?: boolean;
495
+ } | undefined;
496
+ response: {
497
+ popupWindow?: Window;
498
+ url: string;
499
+ };
500
+ };
491
501
  };
492
502
  export type InternalMethods = {
493
503
  linkAccount: {
@@ -12,7 +12,7 @@ export type VerifyExternalWalletV1 = {
12
12
  cosmosPublicKeyHex?: string;
13
13
  cosmosSigner?: string;
14
14
  };
15
- export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential';
15
+ export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey';
16
16
  export type PortalUrlOptions = {
17
17
  params?: Record<string, string | undefined | null>;
18
18
  isForNewDevice?: boolean;
@@ -4,5 +4,6 @@ export declare enum PopupType {
4
4
  LOGIN_PASSKEY = "LOGIN_PASSKEY",
5
5
  CREATE_PASSKEY = "CREATE_PASSKEY",
6
6
  OAUTH = "OAUTH",
7
- ON_RAMP_TRANSACTION = "ON_RAMP_TRANSACTION"
7
+ ON_RAMP_TRANSACTION = "ON_RAMP_TRANSACTION",
8
+ EXPORT_PRIVATE_KEY = "EXPORT_PRIVATE_KEY"
8
9
  }
@@ -26,6 +26,7 @@ export interface Wallet extends Omit<IWalletEntity, 'createdAt' | 'updatedAt' |
26
26
  ensName?: string | null;
27
27
  ensAvatar?: string | null;
28
28
  }
29
+ export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>;
29
30
  /** @deprecated */
30
31
  export declare enum PregenIdentifierType {
31
32
  EMAIL = "EMAIL",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.64",
3
+ "version": "2.0.0-alpha.66",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "2.0.0-alpha.64",
8
+ "@getpara/user-management-client": "2.0.0-alpha.66",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "base64url": "^3.0.1",
11
11
  "libphonenumber-js": "^1.11.7",
@@ -27,7 +27,7 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
- "gitHead": "c55ecfbbd200053ddb78d88c93c597c0f781a6bb",
30
+ "gitHead": "07c8b7b68aa36dec6071e3b3b3a66de2870312c8",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {