@embarkai/ui-kit 0.4.46 → 0.4.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1301,7 +1301,7 @@ var init_ChainSync2 = __esm({
1301
1301
 
1302
1302
  // src/internal/clients/account/register-smart-account-address.ts
1303
1303
  async function registerSmartAccountAddress(chainId, smartAccountAddress, factoryAddress) {
1304
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
1304
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
1305
1305
  if (!accessToken) {
1306
1306
  console.warn("[Account] No access token available for Smart Account registration");
1307
1307
  return { success: true, chainId, smartAccountAddress, alreadySet: false };
@@ -1346,7 +1346,7 @@ async function registerSmartAccountAddress(chainId, smartAccountAddress, factory
1346
1346
  }
1347
1347
  }
1348
1348
  async function getAllSmartAccounts() {
1349
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
1349
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
1350
1350
  if (!accessToken) {
1351
1351
  console.warn("[Account] No access token available");
1352
1352
  return [];
@@ -1373,7 +1373,7 @@ async function getAllSmartAccounts() {
1373
1373
  }
1374
1374
  }
1375
1375
  async function getSmartAccountForChain(chainId) {
1376
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
1376
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
1377
1377
  if (!accessToken) {
1378
1378
  console.warn("[Account] No access token available");
1379
1379
  return null;
@@ -1989,7 +1989,7 @@ var init_httpClient = __esm({
1989
1989
  ...headers
1990
1990
  };
1991
1991
  if (requireAuth) {
1992
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
1992
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
1993
1993
  if (accessToken) {
1994
1994
  requestHeaders["Authorization"] = `Bearer ${accessToken}`;
1995
1995
  }
@@ -2006,9 +2006,9 @@ var init_httpClient = __esm({
2006
2006
  try {
2007
2007
  const response = await fetch(url, requestConfig);
2008
2008
  if (response.status === 401 && requireAuth) {
2009
- const refreshSuccess = await import_auth20.jwtTokenManager.refreshAccessToken();
2009
+ const refreshSuccess = await import_auth21.jwtTokenManager.refreshAccessToken();
2010
2010
  if (refreshSuccess) {
2011
- const newAccessToken = import_auth20.jwtTokenManager.getAccessToken();
2011
+ const newAccessToken = import_auth21.jwtTokenManager.getAccessToken();
2012
2012
  if (newAccessToken) {
2013
2013
  requestHeaders["Authorization"] = `Bearer ${newAccessToken}`;
2014
2014
  requestConfig.headers = requestHeaders;
@@ -2441,15 +2441,11 @@ function useBackupStatusChanges() {
2441
2441
  onSuccess: ({ stats, detail }) => {
2442
2442
  const hasRecoveryData = stats && (!!stats.created || !!stats?.devices?.length);
2443
2443
  if (!!hasRecoveryData) {
2444
- console.log(
2445
- "[BACKUP STATUS] Recovery data found after backup status change.\n Redirect to main menu:",
2446
- detail?.navigateToMainMenu
2447
- );
2448
2444
  setHasServerVault(true);
2449
- if (!!detail?.navigateToMainMenu) {
2450
- setTimeout(() => setPage(null), 1e3);
2445
+ if (!!detail?.navigateToNicknameMenu) {
2446
+ console.log("[BACKUP STATUS] New user backup created, navigating to nickname settings");
2447
+ setTimeout(() => setPage("nickname-settings" /* NICKNAME_SETTINGS */), 1e3);
2451
2448
  }
2452
- console.info("[BACKUP STATUS] Recovery data found in vault, marking as has-server-vault");
2453
2449
  } else {
2454
2450
  setHasServerVault(false);
2455
2451
  setPage("keysare-backup" /* KEYSARE_BACKUP */);
@@ -6640,7 +6636,7 @@ function PassKeyStep(props) {
6640
6636
  setPasskeyStatus("checking available passkeys...");
6641
6637
  setIsLoading(true);
6642
6638
  try {
6643
- import_auth20.jwtTokenManager.clearTokens();
6639
+ import_auth21.jwtTokenManager.clearTokens();
6644
6640
  setPasskeyStatus("authenticating with passkey...");
6645
6641
  const result = await authenticateWithPasskey(
6646
6642
  void 0,
@@ -7131,8 +7127,8 @@ function Social(props) {
7131
7127
  const iframeManager = getIframeManager2();
7132
7128
  const finalizeSocialLogin = async (rawLoginResponse, providerKey, userData) => {
7133
7129
  let loginResponse2 = await normalizeSocialLoginResponse(rawLoginResponse, providerKey, userData);
7134
- const existingAccessToken = import_auth20.jwtTokenManager.getAccessToken();
7135
- const existingRefreshToken = import_auth20.jwtTokenManager.getRefreshToken();
7130
+ const existingAccessToken = import_auth21.jwtTokenManager.getAccessToken();
7131
+ const existingRefreshToken = import_auth21.jwtTokenManager.getRefreshToken();
7136
7132
  if (existingAccessToken && existingRefreshToken && !loginResponse2.accessToken) {
7137
7133
  console.log("[AuthModal] Using tokens already stored by iframe-manager");
7138
7134
  loginResponse2 = {
@@ -7161,7 +7157,7 @@ function Social(props) {
7161
7157
  setIsLoading(false);
7162
7158
  return;
7163
7159
  }
7164
- await import_auth20.jwtTokenManager.clearTokens();
7160
+ await import_auth21.jwtTokenManager.clearTokens();
7165
7161
  if (!loginResponse2.accessToken || !loginResponse2.refreshToken) {
7166
7162
  console.warn(
7167
7163
  "[AuthModal] Authentication tokens were not issued; continuing with cookie-based session only."
@@ -7170,7 +7166,7 @@ function Social(props) {
7170
7166
  let tokensPersisted = false;
7171
7167
  const persistTokensIfAvailable = async () => {
7172
7168
  if (!tokensPersisted && loginResponse2.accessToken && loginResponse2.refreshToken) {
7173
- await import_auth20.jwtTokenManager.setTokens(loginResponse2);
7169
+ await import_auth21.jwtTokenManager.setTokens(loginResponse2);
7174
7170
  tokensPersisted = true;
7175
7171
  }
7176
7172
  };
@@ -7607,25 +7603,15 @@ function useAuthMenuHandlers() {
7607
7603
  const { config, callbacksRef } = useProviderConfig();
7608
7604
  const qc = (0, import_react_query5.useQueryClient)();
7609
7605
  const pendingLoginResponseRef = (0, import_react15.useRef)(null);
7610
- const setPage = useLayoutDataStore((st) => st.setPage);
7611
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
7612
7606
  const [telegramCleanup, setTelegramCleanup] = (0, import_react15.useState)(null);
7613
- const {
7614
- usePaymaster,
7615
- publicClient,
7616
- activeChainId,
7617
- setError,
7618
- setStatus,
7619
- setSession,
7620
- setAddress,
7621
- setRecoveryUserId,
7622
- setHasServerVault,
7623
- setIsLoading
7624
- } = useSession();
7607
+ const usePaymaster = useSession((st) => st.usePaymaster);
7608
+ const publicClient = useSession((st) => st.publicClient);
7609
+ const activeChainId = useSession((st) => st.activeChainId);
7625
7610
  const setStep = useAuthStore((st) => st.setStep);
7626
7611
  const setAlert = useAuthStore((st) => st.setAlert);
7627
7612
  const createSessionWithKeyshare = (0, import_react15.useCallback)(
7628
7613
  async (userId, hasServerKeyshare, isNewUser) => {
7614
+ const { setStatus } = useSession.getState();
7629
7615
  try {
7630
7616
  try {
7631
7617
  callbacksRef.current?.onConnecting?.({ method: "wallet" });
@@ -7663,9 +7649,19 @@ function useAuthMenuHandlers() {
7663
7649
  throw error;
7664
7650
  }
7665
7651
  },
7666
- [setStatus, usePaymaster, activeChainId]
7652
+ [usePaymaster, activeChainId]
7667
7653
  );
7668
7654
  const onAuthSuccess = (0, import_react15.useCallback)(async () => {
7655
+ const {
7656
+ //
7657
+ setSession,
7658
+ setAddress,
7659
+ setStatus,
7660
+ setIsLoading,
7661
+ setError,
7662
+ setHasServerVault,
7663
+ setRecoveryUserId
7664
+ } = useSession.getState();
7669
7665
  setIsLoading(true);
7670
7666
  setStep("loading");
7671
7667
  const loginResponse = pendingLoginResponseRef.current;
@@ -7683,7 +7679,7 @@ function useAuthMenuHandlers() {
7683
7679
  const iframeManager = getIframeManager2();
7684
7680
  await iframeManager.authenticate(userId, loginResponse.avatar, loginResponse.displayName);
7685
7681
  if (loginResponse.accessToken && loginResponse.refreshToken) {
7686
- await import_auth20.jwtTokenManager.setTokens(loginResponse);
7682
+ await import_auth21.jwtTokenManager.setTokens(loginResponse);
7687
7683
  } else {
7688
7684
  console.warn("[ConnectWalletButton] Login response missing tokens; skipping jwtTokenManager.setTokens");
7689
7685
  }
@@ -7729,11 +7725,11 @@ function useAuthMenuHandlers() {
7729
7725
  if (!!jwt?.isNewUser || !hasKeyshareVaultBackup) {
7730
7726
  if (!!jwt?.isNewUser) console.log("[AuthMenu] New user detected - forcing backup flow");
7731
7727
  if (!hasKeyshareVaultBackup) console.log("[AuthMenu] No recovery data found - forcing backup flow");
7732
- setIsDialogForced(true);
7733
- setPage("keysare-backup" /* KEYSARE_BACKUP */);
7728
+ useLayoutStore.getState().setIsDialogForced(true);
7729
+ useLayoutDataStore.getState().setPage("keysare-backup" /* KEYSARE_BACKUP */);
7734
7730
  } else {
7735
- setIsDialogForced(false);
7736
- setPage(null);
7731
+ useLayoutStore.getState().setIsDialogForced(false);
7732
+ useLayoutDataStore.getState().setPage(null);
7737
7733
  }
7738
7734
  }, 100);
7739
7735
  } catch (error) {
@@ -7745,12 +7741,10 @@ function useAuthMenuHandlers() {
7745
7741
  setAddress(null);
7746
7742
  setRecoveryUserId(userId);
7747
7743
  setStatus("recovery_needed");
7748
- setTimeout(() => {
7749
- setPage("keyshare-restore" /* KEYSHARE_RESTORE */);
7750
- }, 100);
7744
+ setTimeout(() => useLayoutDataStore.getState().setPage("keyshare-restore" /* KEYSHARE_RESTORE */), 100);
7751
7745
  } else {
7752
7746
  pendingLoginResponseRef.current = null;
7753
- await import_auth20.jwtTokenManager.clearTokens();
7747
+ await import_auth21.jwtTokenManager.clearTokens();
7754
7748
  setStatus("error");
7755
7749
  setError(error?.message || String(error));
7756
7750
  setAlert({
@@ -7763,20 +7757,7 @@ function useAuthMenuHandlers() {
7763
7757
  setIsLoading(false);
7764
7758
  setStep("signin");
7765
7759
  }
7766
- }, [
7767
- qc,
7768
- setStep,
7769
- setPage,
7770
- setError,
7771
- setStatus,
7772
- setSession,
7773
- setAlert,
7774
- setAddress,
7775
- setRecoveryUserId,
7776
- setHasServerVault,
7777
- setIsDialogForced,
7778
- createSessionWithKeyshare
7779
- ]);
7760
+ }, [qc, setStep, setAlert, createSessionWithKeyshare]);
7780
7761
  const goBackToSignIn = (0, import_react15.useCallback)(() => {
7781
7762
  setStep("signin");
7782
7763
  setAlert(null);
@@ -8209,7 +8190,7 @@ var init_AuthMenu = __esm({
8209
8190
  const loginResponse = pendingWalletLogin;
8210
8191
  setPendingWalletLogin(null);
8211
8192
  console.log("[AuthMenu] Processing wallet login response:", loginResponse);
8212
- import_auth20.jwtTokenManager.clearTokens().then(() => {
8193
+ import_auth21.jwtTokenManager.clearTokens().then(() => {
8213
8194
  pendingLoginResponseRef.current = loginResponse;
8214
8195
  onAuthSuccess();
8215
8196
  });
@@ -9479,7 +9460,7 @@ var init_queryKeys = __esm({
9479
9460
 
9480
9461
  // src/internal/components/BuyMenu/binance/api.ts
9481
9462
  function iframe() {
9482
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
9463
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
9483
9464
  if (!accessToken) {
9484
9465
  throw new Error("Access token is not available");
9485
9466
  }
@@ -10391,7 +10372,7 @@ var init_binance = __esm({
10391
10372
 
10392
10373
  // src/internal/components/BuyMenu/finchpay/api.ts
10393
10374
  function iframe2() {
10394
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
10375
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
10395
10376
  if (!accessToken) {
10396
10377
  throw new Error("Access token is not available");
10397
10378
  }
@@ -11633,67 +11614,43 @@ var init_LumiaIcon2 = __esm({
11633
11614
  }
11634
11615
  });
11635
11616
 
11636
- // src/config/networks.ts
11637
- var import_read11, NETWORK_OPTIONS;
11617
+ // src/internal/assets/networks/index.ts
11618
+ var import_read11, NETWORKS_ICONS;
11638
11619
  var init_networks3 = __esm({
11639
- "src/config/networks.ts"() {
11620
+ "src/internal/assets/networks/index.ts"() {
11621
+ import_read11 = require("@embarkai/core/read");
11640
11622
  init_ArbitrumIcon();
11641
11623
  init_BaseIcon();
11642
11624
  init_BscIcon();
11643
11625
  init_EthereumIcon();
11644
11626
  init_LumiaIcon2();
11645
- import_read11 = require("@embarkai/core/read");
11646
- NETWORK_OPTIONS = [
11647
- {
11648
- chainId: import_read11.LUMIA_TESTNET_CHAIN_ID,
11649
- name: "Lumia Beam",
11650
- badge: "TESTNET",
11651
- Icon: LumiaIcon2,
11652
- isActive: true
11653
- },
11654
- {
11655
- chainId: import_read11.LUMIA_MAINNET_CHAIN_ID,
11656
- name: "Lumia Prism",
11657
- badge: "MAINNET",
11658
- Icon: LumiaIcon2,
11659
- isActive: true
11660
- },
11661
- {
11662
- chainId: import_read11.SEPOLIA_CHAIN_ID,
11663
- name: "Sepolia",
11664
- badge: "TESTNET",
11665
- Icon: EthereumIcon,
11666
- isActive: true
11667
- },
11668
- {
11669
- chainId: import_read11.BSC_TESTNET_CHAIN_ID,
11670
- name: "BSC Testnet",
11671
- badge: "TESTNET",
11672
- Icon: BSCIcon,
11673
- isActive: true
11674
- },
11675
- {
11676
- chainId: import_read11.ARBITRUM_SEPOLIA_CHAIN_ID,
11677
- name: "Arbitrum Sepolia",
11678
- badge: "TESTNET",
11679
- Icon: ArbitrumIcon,
11680
- isActive: true
11681
- },
11682
- {
11683
- chainId: import_read11.BASE_SEPOLIA_CHAIN_ID,
11684
- name: "Base Sepolia",
11685
- badge: "TESTNET",
11686
- Icon: BaseIcon,
11687
- isActive: true
11688
- },
11689
- {
11690
- chainId: import_read11.LUMIA_PULSAR_TESTNET_CHAIN_ID,
11691
- name: "Lumia Pulsar Testnet",
11692
- badge: "TESTNET",
11693
- Icon: LumiaIcon2,
11694
- isActive: true
11695
- }
11696
- ];
11627
+ NETWORKS_ICONS = {
11628
+ [import_read11.LUMIA_MAINNET_CHAIN_ID]: LumiaIcon2,
11629
+ [import_read11.LUMIA_TESTNET_CHAIN_ID]: LumiaIcon2,
11630
+ [import_read11.LUMIA_PULSAR_TESTNET_CHAIN_ID]: LumiaIcon2,
11631
+ [import_read11.BASE_SEPOLIA_CHAIN_ID]: BaseIcon,
11632
+ [import_read11.BSC_MAINNET_CHAIN_ID]: BSCIcon,
11633
+ [import_read11.BSC_TESTNET_CHAIN_ID]: BSCIcon,
11634
+ 1: EthereumIcon,
11635
+ [import_read11.ARBITRUM_SEPOLIA_CHAIN_ID]: ArbitrumIcon
11636
+ };
11637
+ }
11638
+ });
11639
+
11640
+ // src/config/networks.ts
11641
+ var import_read12, NETWORK_OPTIONS;
11642
+ var init_networks4 = __esm({
11643
+ "src/config/networks.ts"() {
11644
+ init_networks3();
11645
+ init_EmbarkIcon();
11646
+ import_read12 = require("@embarkai/core/read");
11647
+ NETWORK_OPTIONS = [...import_read12.SUPPORTED_CHAINS].map(([chainId, chain]) => ({
11648
+ chainId,
11649
+ name: chain.name,
11650
+ badge: import_read12.SUPPORTED_MAINNETS.includes(chainId) ? "MAINNET" : "TESTNET",
11651
+ Icon: NETWORKS_ICONS[chainId] || EmbarkIcon,
11652
+ isActive: true
11653
+ }));
11697
11654
  }
11698
11655
  });
11699
11656
 
@@ -11725,7 +11682,7 @@ var init_truncateMiddle = __esm({
11725
11682
 
11726
11683
  // src/internal/components/ChainsMenu/ChainsMenu.tsx
11727
11684
  function getPaymasterExplorerUrl(chainId, paymasterAddress) {
11728
- const chainConfig = (0, import_read12.getChainConfig)(chainId);
11685
+ const chainConfig = (0, import_read13.getChainConfig)(chainId);
11729
11686
  const explorerUrl = chainConfig?.blockExplorerUrl;
11730
11687
  if (!explorerUrl) return paymasterAddress;
11731
11688
  return `${explorerUrl.replace(/\/$/, "")}/address/${paymasterAddress}`;
@@ -11742,7 +11699,7 @@ function ChainsMenu() {
11742
11699
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
11743
11700
  const setPage = useLayoutDataStore((st) => st.setPage);
11744
11701
  const visibleNetworks = NETWORK_OPTIONS.filter((option) => option.isActive);
11745
- const activeChainConfig = activeChainId ? (0, import_read12.getChainConfig)(activeChainId) : null;
11702
+ const activeChainConfig = activeChainId ? (0, import_read13.getChainConfig)(activeChainId) : null;
11746
11703
  const activeDefaultPaymasterAddress = activeChainConfig?.paymasterAddress;
11747
11704
  const activePaymasterQuery = (0, import_react_query15.useQuery)({
11748
11705
  queryKey: ["chain-paymaster", config.current.projectId, activeChainId],
@@ -11883,15 +11840,15 @@ function ChainsMenu() {
11883
11840
  }
11884
11841
  );
11885
11842
  }
11886
- var import_core2, import_read12, import_react_query15, import_lucide_react19, import_react29, import_jsx_runtime48;
11843
+ var import_core2, import_read13, import_react_query15, import_lucide_react19, import_react29, import_jsx_runtime48;
11887
11844
  var init_ChainsMenu = __esm({
11888
11845
  "src/internal/components/ChainsMenu/ChainsMenu.tsx"() {
11889
- init_networks3();
11846
+ init_networks4();
11890
11847
  init_ProviderContext();
11891
11848
  init_SessionContext();
11892
11849
  init_useT();
11893
11850
  import_core2 = require("@embarkai/core");
11894
- import_read12 = require("@embarkai/core/read");
11851
+ import_read13 = require("@embarkai/core/read");
11895
11852
  import_react_query15 = require("@tanstack/react-query");
11896
11853
  import_lucide_react19 = require("lucide-react");
11897
11854
  import_react29 = require("react");
@@ -11993,7 +11950,7 @@ function ChainSwitchRequest() {
11993
11950
  var import_lucide_react20, import_react30, import_react_i18next2, import_jsx_runtime49;
11994
11951
  var init_ChainSwitchRequest = __esm({
11995
11952
  "src/internal/components/ChainsMenu/ChainSwitchRequest.tsx"() {
11996
- init_networks3();
11953
+ init_networks4();
11997
11954
  init_ProviderContext();
11998
11955
  init_SessionContext();
11999
11956
  init_useT();
@@ -13441,9 +13398,9 @@ __export(passkey_exports2, {
13441
13398
  linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn
13442
13399
  });
13443
13400
  async function completePasskeyLinking(payload) {
13444
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
13401
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
13445
13402
  if (!hasValidToken) throw new Error("No authentication token available");
13446
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/complete`, {
13403
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/complete`, {
13447
13404
  method: "POST",
13448
13405
  body: JSON.stringify(payload)
13449
13406
  });
@@ -13453,9 +13410,9 @@ async function completePasskeyLinking(payload) {
13453
13410
  }
13454
13411
  }
13455
13412
  async function beginPasskeyLinking() {
13456
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
13413
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
13457
13414
  if (!hasValidToken) throw new Error("No authentication token available");
13458
- let res = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/begin`, { method: "POST" });
13415
+ let res = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/begin`, { method: "POST" });
13459
13416
  if (res.ok) {
13460
13417
  const begin2 = await res.json();
13461
13418
  const options2 = {
@@ -13483,7 +13440,7 @@ async function beginPasskeyLinking() {
13483
13440
  };
13484
13441
  return { challengeId: begin2.challengeId, options: options2 };
13485
13442
  }
13486
- res = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/options`, { method: "GET" });
13443
+ res = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/options`, { method: "GET" });
13487
13444
  if (!res.ok) throw new Error("Failed to get passkey linking options");
13488
13445
  const begin = await res.json();
13489
13446
  const options = {
@@ -13515,7 +13472,7 @@ async function linkPasskeyWithWebAuthn(optionsOverride) {
13515
13472
  if (!("credentials" in navigator) || !("create" in navigator.credentials)) {
13516
13473
  throw new Error("WebAuthn not supported in this browser");
13517
13474
  }
13518
- const userId = import_auth20.jwtTokenManager.getUserId();
13475
+ const userId = import_auth21.jwtTokenManager.getUserId();
13519
13476
  if (!userId) throw new Error("No authenticated user");
13520
13477
  let challengeId = null;
13521
13478
  let publicKeyOptions = null;
@@ -13811,36 +13768,39 @@ function useCreateBackup() {
13811
13768
  const session = useSession((st) => st.session);
13812
13769
  const address = useSession((st) => st.address);
13813
13770
  const hasServerVault = useSession((st) => st.hasServerVault);
13814
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
13815
- const { usePasskey, restorePassword, selectedCloudProvider, setSuccess, setError, setMethod, setIsCreatingPasskey } = useRestoreStore();
13771
+ const usePasskey = useRestoreStore((st) => st.usePasskey);
13772
+ const restorePassword = useRestoreStore((st) => st.restorePassword);
13773
+ const selectedCloudProvider = useRestoreStore((st) => st.selectedCloudProvider);
13816
13774
  (0, import_react36.useEffect)(() => {
13817
13775
  if (!hasServerVault) {
13818
- setMethod("server");
13819
- setIsDialogForced(true);
13776
+ useRestoreStore.getState().setMethod("server");
13777
+ useLayoutStore.getState().setIsDialogForced(true);
13820
13778
  }
13821
- }, [hasServerVault, setIsDialogForced, setMethod]);
13779
+ }, [hasServerVault]);
13822
13780
  const recoveryUserId = useSession((st) => st.recoveryUserId);
13823
13781
  const passportUserId = session?.mpcUserId || recoveryUserId || "";
13824
- const onBackupSuccess = () => console.log("[ConnectWalletButton] Backup created successfully");
13782
+ const onBackupSuccess = (0, import_react36.useCallback)(() => {
13783
+ console.log("[EMBARKAI BACKUP] Backup created successfully");
13784
+ }, [hasServerVault]);
13825
13785
  const { mutate: createPasswordBackup, isPending: isPasswordBackupCreating } = (0, import_react_query17.useMutation)({
13826
13786
  mutationFn: async () => {
13827
13787
  const iframeManager = getIframeManager();
13828
13788
  if (!iframeManager) {
13829
13789
  throw new Error("Iframe manager not initialized");
13830
13790
  }
13831
- const jwt = await Promise.resolve().then(() => (init_auth(), auth_exports)).then((m) => m.jwtTokenManager.getTokens());
13791
+ const jwt = import_auth21.jwtTokenManager.getTokens();
13832
13792
  if (!usePasskey && !restorePassword) {
13833
13793
  throw new Error("Please provide a password for the backup");
13834
13794
  }
13835
13795
  const password = !usePasskey ? restorePassword : void 0;
13836
- const navigateToMainMenu = jwt.isNewUser || !hasServerVault;
13837
- console.log("[BACKUP STATUS] is new user:", jwt.isNewUser, !hasServerVault, "usePasskey:", usePasskey);
13796
+ console.log("[BACKUP STATUS] is new user:", jwt.isNewUser);
13838
13797
  return {
13839
13798
  response: await iframeManager.createBackup(passportUserId, { method: "server", password }, jwt.accessToken),
13840
- navigateToMainMenu
13799
+ isNewUser: jwt.isNewUser
13841
13800
  };
13842
13801
  },
13843
- onSuccess: async ({ response, navigateToMainMenu }) => {
13802
+ onSuccess: async ({ response, isNewUser }) => {
13803
+ const { setError, setSuccess } = useRestoreStore.getState();
13844
13804
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13845
13805
  if (response.success) {
13846
13806
  setError("");
@@ -13848,7 +13808,11 @@ function useCreateBackup() {
13848
13808
  if (typeof window !== "undefined") {
13849
13809
  window.dispatchEvent(
13850
13810
  new CustomEvent("lumia-passport-backup-status-changed", {
13851
- detail: { method: "server", success: true, navigateToMainMenu }
13811
+ detail: {
13812
+ method: "server",
13813
+ success: true,
13814
+ navigateToNicknameMenu: !!isNewUser
13815
+ }
13852
13816
  })
13853
13817
  );
13854
13818
  }
@@ -13856,9 +13820,10 @@ function useCreateBackup() {
13856
13820
  } else {
13857
13821
  setError(response.error || "Server backup failed");
13858
13822
  }
13859
- setIsDialogForced(false);
13823
+ useLayoutStore.getState().setIsDialogForced(false);
13860
13824
  },
13861
13825
  onError: async (error) => {
13826
+ const { setError, setSuccess } = useRestoreStore.getState();
13862
13827
  setSuccess("");
13863
13828
  if (error?.name === "NotAllowedError" || error?.message?.includes("timed out or was not allowed")) {
13864
13829
  setError("Passkey selection was cancelled. Please try again or create a new passkey.");
@@ -13887,7 +13852,7 @@ function useCreateBackup() {
13887
13852
  },
13888
13853
  onSuccess: async () => {
13889
13854
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13890
- setSuccess("Backup file downloaded successfully");
13855
+ useRestoreStore.getState().setSuccess("Backup file downloaded successfully");
13891
13856
  if (typeof window !== "undefined") {
13892
13857
  window.dispatchEvent(
13893
13858
  new CustomEvent("lumia-passport-backup-status-changed", {
@@ -13898,13 +13863,13 @@ function useCreateBackup() {
13898
13863
  onBackupSuccess();
13899
13864
  },
13900
13865
  onError: async (error) => {
13901
- setError(error?.message || "Backup creation failed");
13866
+ useRestoreStore.getState().setError(error?.message || "Backup creation failed");
13902
13867
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13903
13868
  }
13904
13869
  });
13905
13870
  const { mutate: createPasskey, isPending: isPasskeyCreating } = (0, import_react_query17.useMutation)({
13906
13871
  mutationFn: async () => {
13907
- setIsCreatingPasskey(true);
13872
+ useRestoreStore.getState().setIsCreatingPasskey(true);
13908
13873
  const { linkPasskeyWithWebAuthn: linkPasskeyWithWebAuthn2 } = await Promise.resolve().then(() => (init_passkey2(), passkey_exports2));
13909
13874
  const { createPasskeyHelpers: createPasskeyHelpers2 } = await Promise.resolve().then(() => (init_passkey(), passkey_exports));
13910
13875
  const { credentialId, rawId } = await linkPasskeyWithWebAuthn2();
@@ -13914,11 +13879,13 @@ function useCreateBackup() {
13914
13879
  return { credentialId, rawId };
13915
13880
  },
13916
13881
  onSuccess: async () => {
13882
+ const { setError, setSuccess, setIsCreatingPasskey } = useRestoreStore.getState();
13917
13883
  setIsCreatingPasskey(false);
13918
13884
  setError(null);
13919
13885
  setSuccess("Passkey created successfully. You can now create a backup.");
13920
13886
  },
13921
13887
  onError: async (error) => {
13888
+ const { setError, setIsCreatingPasskey } = useRestoreStore.getState();
13922
13889
  setIsCreatingPasskey(false);
13923
13890
  if (error.name === "NotAllowedError") {
13924
13891
  setError("Passkey creation cancelled. Please try again.");
@@ -13951,7 +13918,7 @@ function useCreateBackup() {
13951
13918
  },
13952
13919
  onSuccess: async ({ provider, uploadResult }) => {
13953
13920
  console.log("[KeyshareBackup] Cloud backup upload result:", uploadResult);
13954
- setSuccess(`Successfully created cloud backup on ${provider.name}`);
13921
+ useRestoreStore.getState().setSuccess(`Successfully created cloud backup on ${provider.name}`);
13955
13922
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13956
13923
  if (typeof window !== "undefined") {
13957
13924
  window.dispatchEvent(
@@ -13963,7 +13930,7 @@ function useCreateBackup() {
13963
13930
  onBackupSuccess();
13964
13931
  },
13965
13932
  onError: async (error) => {
13966
- setError(error?.message || "Backup creation failed");
13933
+ useRestoreStore.getState().setError(error?.message || "Backup creation failed");
13967
13934
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13968
13935
  }
13969
13936
  });
@@ -13984,6 +13951,7 @@ var init_useCreateBackup = __esm({
13984
13951
  init_SessionContext();
13985
13952
  import_react_query17 = require("@tanstack/react-query");
13986
13953
  import_react36 = require("react");
13954
+ init_auth();
13987
13955
  init_useLayoutStore();
13988
13956
  init_iframe_manager();
13989
13957
  init_constants4();
@@ -15093,23 +15061,14 @@ var init_KeyshareRestoreMenu = __esm({
15093
15061
  const qc = (0, import_react_query21.useQueryClient)();
15094
15062
  const { callbacksRef } = useProviderConfig();
15095
15063
  const { t } = useT();
15096
- const { address, setSession, setAddress, setStatus, setIsLoading } = useSession();
15064
+ const address = useSession((st) => st.address);
15097
15065
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
15098
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
15099
- const setPage = useLayoutDataStore((st) => st.setPage);
15100
- const {
15101
- method: currentRestoreMethod,
15102
- error,
15103
- success,
15104
- setError,
15105
- setShowPassword,
15106
- setUsePasskey,
15107
- setRestoreFile,
15108
- setRestorePassword,
15109
- setSuccess,
15110
- setMethod
15111
- } = useRestoreStore();
15066
+ const error = useRestoreStore((st) => st.error);
15067
+ const success = useRestoreStore((st) => st.success);
15068
+ const currentRestoreMethod = useRestoreStore((st) => st.method);
15112
15069
  (0, import_react43.useEffect)(() => {
15070
+ const { setIsDialogForced } = useLayoutStore.getState();
15071
+ const { setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
15113
15072
  setIsDialogForced(true);
15114
15073
  return () => {
15115
15074
  setRestorePassword("");
@@ -15136,14 +15095,17 @@ var init_KeyshareRestoreMenu = __esm({
15136
15095
  });
15137
15096
  const hasServerBackup = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
15138
15097
  (0, import_react43.useEffect)(() => {
15139
- if (!!hasServerBackup) setMethod("server");
15098
+ if (!!hasServerBackup) useRestoreStore.getState().setMethod("server");
15140
15099
  }, [hasServerBackup]);
15141
15100
  const { mutate: disconnect, isPending: isDisconnecting } = (0, import_react_query21.useMutation)({
15142
15101
  mutationFn: async () => {
15102
+ const { setStatus, setIsLoading } = useSession.getState();
15103
+ const { setError, setMethod } = useRestoreStore.getState();
15143
15104
  setError(null);
15144
15105
  setMethod(null);
15145
15106
  setStatus("disconnecting");
15146
15107
  setIsLoading(true);
15108
+ useLayoutStore.getState().setIsDialogForced(true);
15147
15109
  const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
15148
15110
  const userId = jwtTokenManager4.getUserId() || null;
15149
15111
  const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
@@ -15152,20 +15114,22 @@ var init_KeyshareRestoreMenu = __esm({
15152
15114
  },
15153
15115
  onSuccess: async ({ disconnectedUserId }) => {
15154
15116
  await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
15117
+ const { setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
15155
15118
  setSession(null);
15156
15119
  setAddress(null);
15157
- setError(null);
15158
15120
  setStatus("idle");
15159
15121
  setIsLoading(false);
15160
- setIsDialogForced(false);
15122
+ useRestoreStore.getState().setError(null);
15123
+ useLayoutStore.getState().setIsDialogForced(false);
15161
15124
  callbacksRef.current?.onDisconnect?.({ address: "0x", userId: disconnectedUserId });
15162
- setTimeout(() => setPage("auth" /* AUTH */), 50);
15125
+ setTimeout(() => useLayoutDataStore.getState().setPage("auth" /* AUTH */), 50);
15163
15126
  },
15164
15127
  onError: (err) => {
15165
- setError(err.message || "An unknown error occurred during sign out");
15128
+ const { setStatus, setIsLoading } = useSession.getState();
15166
15129
  setStatus("idle");
15167
15130
  setIsLoading(false);
15168
- setIsDialogForced(false);
15131
+ useRestoreStore.getState().setError(err.message || "An unknown error occurred during sign out");
15132
+ useLayoutStore.getState().setIsDialogForced(false);
15169
15133
  }
15170
15134
  });
15171
15135
  const RestoreComponent = currentRestoreMethod ? RESTORE_COMPONENTS[currentRestoreMethod] : null;
@@ -15199,6 +15163,7 @@ var init_KeyshareRestoreMenu = __esm({
15199
15163
  labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
15200
15164
  checked: currentRestoreMethod !== "server",
15201
15165
  onChange: () => {
15166
+ const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
15202
15167
  if (!!error) setError(null);
15203
15168
  if (currentRestoreMethod === "server") {
15204
15169
  setRestorePassword("");
@@ -15228,6 +15193,15 @@ var init_KeyshareRestoreMenu = __esm({
15228
15193
  size: "large",
15229
15194
  variant: "ghost",
15230
15195
  onClick: () => {
15196
+ const {
15197
+ setError,
15198
+ setShowPassword,
15199
+ setUsePasskey,
15200
+ setRestoreFile,
15201
+ setRestorePassword,
15202
+ setSuccess,
15203
+ setMethod
15204
+ } = useRestoreStore.getState();
15231
15205
  setError(null);
15232
15206
  setShowPassword(false);
15233
15207
  setUsePasskey(false);
@@ -15270,20 +15244,11 @@ function KeyshareBackupMenu() {
15270
15244
  const { t } = useT();
15271
15245
  const setPage = useLayoutDataStore((st) => st.setPage);
15272
15246
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
15273
- const {
15274
- method: currentBackupMethod,
15275
- error,
15276
- success,
15277
- setSelectedCloudProvider,
15278
- setSuccess,
15279
- setError,
15280
- setRestorePassword,
15281
- setRestoreFile,
15282
- setShowPassword,
15283
- setUsePasskey,
15284
- setMethod
15285
- } = useRestoreStore();
15247
+ const currentBackupMethod = useRestoreStore((st) => st.method);
15248
+ const error = useRestoreStore((st) => st.error);
15249
+ const success = useRestoreStore((st) => st.success);
15286
15250
  (0, import_react44.useEffect)(() => {
15251
+ const { setSuccess, setError, setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
15287
15252
  return () => {
15288
15253
  setSuccess(null);
15289
15254
  setError(null);
@@ -15297,13 +15262,12 @@ function KeyshareBackupMenu() {
15297
15262
  const { data: serverRecoveryStatus, isLoading: isRecoveryLoading } = (0, import_react_query22.useQuery)({
15298
15263
  retry: false,
15299
15264
  enabled: !!address,
15300
- // Prevent query from running with undefined address
15301
15265
  queryKey: [CHECK_BACKUP_QUERY_KEY, address],
15302
15266
  queryFn: async () => await getShareRecoveryStats()
15303
15267
  });
15304
15268
  const hasRecoveryData = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
15305
15269
  (0, import_react44.useEffect)(() => {
15306
- if (!!hasRecoveryData) setMethod("server");
15270
+ if (!!hasRecoveryData) useRestoreStore.getState().setMethod("server");
15307
15271
  }, [hasRecoveryData]);
15308
15272
  const {
15309
15273
  isPasswordBackupCreating,
@@ -15336,6 +15300,16 @@ function KeyshareBackupMenu() {
15336
15300
  size: "icon",
15337
15301
  title: "Back",
15338
15302
  onClick: () => {
15303
+ const {
15304
+ setSuccess,
15305
+ setError,
15306
+ setRestorePassword,
15307
+ setRestoreFile,
15308
+ setShowPassword,
15309
+ setUsePasskey,
15310
+ setMethod,
15311
+ setSelectedCloudProvider
15312
+ } = useRestoreStore.getState();
15339
15313
  setRestorePassword("");
15340
15314
  setRestoreFile(null);
15341
15315
  setShowPassword(false);
@@ -15358,6 +15332,7 @@ function KeyshareBackupMenu() {
15358
15332
  labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
15359
15333
  checked: currentBackupMethod !== "server",
15360
15334
  onChange: () => {
15335
+ const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
15361
15336
  if (!!error) setError(null);
15362
15337
  if (currentBackupMethod === "server") {
15363
15338
  setRestorePassword("");
@@ -15390,21 +15365,12 @@ function KeyshareBackupMenu() {
15390
15365
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.AlertCircle, { className: "h-4 w-4 flex-shrink-0" }),
15391
15366
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block w-full flex-1", children: error })
15392
15367
  ] }),
15393
- success && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
15394
- /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Highlight, { type: "success", className: "flex gap-[var(--ui-kit-gap)]", children: [
15368
+ success && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Highlight, { type: "success", className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
15369
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "w-full flex gap-[var(--ui-kit-gap)]", children: [
15395
15370
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react35.CheckCircle2, { className: "h-4 w-4 flex-shrink-0" }),
15396
15371
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "block w-full flex-1", children: success })
15397
15372
  ] }),
15398
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
15399
- Button,
15400
- {
15401
- variant: "default",
15402
- size: "large",
15403
- className: "w-full",
15404
- onClick: () => setPage("settings" /* SETTINGS */),
15405
- children: "Done"
15406
- }
15407
- )
15373
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Button, { variant: "default", size: "large", className: "w-full", onClick: () => setPage("settings" /* SETTINGS */), children: t("passport:common.continue") })
15408
15374
  ] })
15409
15375
  ] })
15410
15376
  }
@@ -15839,9 +15805,9 @@ var init_LanguagesMenu2 = __esm({
15839
15805
 
15840
15806
  // src/internal/auth/providers/common.ts
15841
15807
  async function getLinkedProviders() {
15842
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
15808
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
15843
15809
  if (!hasValidToken) throw new Error("No authentication token available");
15844
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/providers`, { method: "GET" });
15810
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/providers`, { method: "GET" });
15845
15811
  if (!response.ok) {
15846
15812
  const errorData = await response.json().catch(() => ({}));
15847
15813
  throw new Error(errorData.message || `Failed to fetch providers: ${response.statusText}`);
@@ -15850,11 +15816,11 @@ async function getLinkedProviders() {
15850
15816
  return data.providers;
15851
15817
  }
15852
15818
  async function unlinkProvider(providerType, externalId) {
15853
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
15819
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
15854
15820
  if (!hasValidToken) throw new Error("No authentication token available");
15855
15821
  let url = `${getTssUrl3()}/api/auth/unlink/${providerType}`;
15856
15822
  if (externalId) url += `?externalId=${encodeURIComponent(externalId)}`;
15857
- const response = await (0, import_auth20.authenticatedFetch)(url, { method: "DELETE" });
15823
+ const response = await (0, import_auth21.authenticatedFetch)(url, { method: "DELETE" });
15858
15824
  if (!response.ok) {
15859
15825
  const errorData = await response.json().catch(() => ({}));
15860
15826
  throw new Error(errorData.message || `Failed to unlink provider: ${response.statusText}`);
@@ -15862,12 +15828,12 @@ async function unlinkProvider(providerType, externalId) {
15862
15828
  try {
15863
15829
  const data = await response.json();
15864
15830
  if (data?.accessToken && data?.refreshToken && data?.expiresIn) {
15865
- import_auth20.jwtTokenManager.setTokens({
15831
+ import_auth21.jwtTokenManager.setTokens({
15866
15832
  accessToken: data.accessToken,
15867
15833
  refreshToken: data.refreshToken,
15868
- userId: import_auth20.jwtTokenManager.getUserId() || "",
15834
+ userId: import_auth21.jwtTokenManager.getUserId() || "",
15869
15835
  expiresIn: data.expiresIn,
15870
- hasKeyshare: import_auth20.jwtTokenManager.getHasKeyshare() ?? false
15836
+ hasKeyshare: import_auth21.jwtTokenManager.getHasKeyshare() ?? false
15871
15837
  });
15872
15838
  }
15873
15839
  } catch {
@@ -15970,7 +15936,7 @@ function useLinkedProfiles() {
15970
15936
  });
15971
15937
  let avatar2 = null;
15972
15938
  try {
15973
- avatar2 = import_auth20.jwtTokenManager.getAvatar() || null;
15939
+ avatar2 = import_auth21.jwtTokenManager.getAvatar() || null;
15974
15940
  } catch {
15975
15941
  avatar2 = null;
15976
15942
  }
@@ -16135,9 +16101,9 @@ var init_EmailForm = __esm({
16135
16101
 
16136
16102
  // src/internal/auth/providers/email.ts
16137
16103
  async function sendEmailLinkCode(email) {
16138
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
16104
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
16139
16105
  if (!hasValidToken) throw new Error("No authentication token available");
16140
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/send-code`, {
16106
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/send-code`, {
16141
16107
  method: "POST",
16142
16108
  body: JSON.stringify({ email })
16143
16109
  });
@@ -16147,9 +16113,9 @@ async function sendEmailLinkCode(email) {
16147
16113
  }
16148
16114
  }
16149
16115
  async function verifyEmailLinkCode(email, code) {
16150
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
16116
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
16151
16117
  if (!hasValidToken) throw new Error("No authentication token available");
16152
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
16118
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
16153
16119
  method: "POST",
16154
16120
  credentials: "include",
16155
16121
  body: JSON.stringify({ email, code })
@@ -16435,7 +16401,7 @@ var init_AddProvider = __esm({
16435
16401
 
16436
16402
  // src/internal/components/ManageWalletMenu/EmailNotConnectedWarning.tsx
16437
16403
  function EmailNotConnectedWarning() {
16438
- const providers = import_auth20.jwtTokenManager.getProviders();
16404
+ const providers = import_auth21.jwtTokenManager.getProviders();
16439
16405
  const hasEmail = providers.includes("email");
16440
16406
  const { t } = useT();
16441
16407
  const config = useProviderConfig().config;
@@ -16502,11 +16468,11 @@ function useLinkSocial() {
16502
16468
  mode: "link"
16503
16469
  };
16504
16470
  try {
16505
- await (0, import_auth20.ensureValidToken)();
16471
+ await (0, import_auth21.ensureValidToken)();
16506
16472
  } catch (tokenError) {
16507
16473
  console.warn("[ManageWallet] ensureValidToken failed before linking", tokenError);
16508
16474
  }
16509
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
16475
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
16510
16476
  if (accessToken) {
16511
16477
  authConfig.token = accessToken;
16512
16478
  }
@@ -16573,7 +16539,7 @@ var init_useLinkSocial = __esm({
16573
16539
 
16574
16540
  // src/internal/auth/providers/telegram.ts
16575
16541
  async function linkTelegram(telegramData) {
16576
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
16542
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
16577
16543
  if (!hasValidToken) throw new Error("No authentication token available");
16578
16544
  const formattedData = {
16579
16545
  id: telegramData.id,
@@ -16584,7 +16550,7 @@ async function linkTelegram(telegramData) {
16584
16550
  if (telegramData.last_name) formattedData.last_name = telegramData.last_name;
16585
16551
  if (telegramData.username) formattedData.username = telegramData.username;
16586
16552
  if (telegramData.photo_url) formattedData.photo_url = telegramData.photo_url;
16587
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/telegram`, {
16553
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/telegram`, {
16588
16554
  method: "POST",
16589
16555
  body: JSON.stringify(formattedData)
16590
16556
  });
@@ -17604,7 +17570,7 @@ var init_NicknameMenu2 = __esm({
17604
17570
  function getCachedPublicClient(chainId) {
17605
17571
  const cachedClient = publicClientByChainId.get(chainId);
17606
17572
  if (cachedClient) return cachedClient;
17607
- const publicClient = (0, import_read13.createPublicClientForChain)(chainId);
17573
+ const publicClient = (0, import_read14.createPublicClientForChain)(chainId);
17608
17574
  publicClientByChainId.set(chainId, publicClient);
17609
17575
  return publicClient;
17610
17576
  }
@@ -17616,7 +17582,7 @@ function useResolvedPublicClient(chainId, logScope = "useResolvedPublicClient")
17616
17582
  const shouldUseActiveClient = !chainId || chainId === activeChainId;
17617
17583
  const chainConfig = (0, import_react56.useMemo)(() => {
17618
17584
  if (shouldUseActiveClient) return activeChainConfig;
17619
- return (0, import_read13.getChainConfig)(chainId);
17585
+ return (0, import_read14.getChainConfig)(chainId);
17620
17586
  }, [activeChainConfig, chainId, shouldUseActiveClient]);
17621
17587
  const publicClient = (0, import_react56.useMemo)(() => {
17622
17588
  if (shouldUseActiveClient) return activePublicClient;
@@ -17635,11 +17601,11 @@ function useResolvedPublicClient(chainId, logScope = "useResolvedPublicClient")
17635
17601
  resolvedChainId
17636
17602
  };
17637
17603
  }
17638
- var import_read13, import_react56, publicClientByChainId;
17604
+ var import_read14, import_react56, publicClientByChainId;
17639
17605
  var init_useResolvedPublicClient = __esm({
17640
17606
  "src/internal/hooks/useResolvedPublicClient.ts"() {
17641
17607
  init_SessionContext();
17642
- import_read13 = require("@embarkai/core/read");
17608
+ import_read14 = require("@embarkai/core/read");
17643
17609
  import_react56 = require("react");
17644
17610
  publicClientByChainId = /* @__PURE__ */ new Map();
17645
17611
  }
@@ -19095,8 +19061,8 @@ function SecurityMenu() {
19095
19061
  const { t } = useT();
19096
19062
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
19097
19063
  const setPage = useLayoutDataStore((st) => st.setPage);
19098
- const userId = import_auth20.jwtTokenManager.getUserId();
19099
- const serverHasKeyshare = import_auth20.jwtTokenManager.getHasKeyshare() ?? false;
19064
+ const userId = import_auth21.jwtTokenManager.getUserId();
19065
+ const serverHasKeyshare = import_auth21.jwtTokenManager.getHasKeyshare() ?? false;
19100
19066
  const [appToUntrust, untrustApp] = (0, import_react62.useState)(null);
19101
19067
  const { data: recoveryData, isLoading: isRecoveryLoading } = useKeyshareRecoveryStats();
19102
19068
  const localInfo = recoveryData?.keyshareInfo || {};
@@ -19217,9 +19183,9 @@ async function walletLogin(walletData) {
19217
19183
  return response.json();
19218
19184
  }
19219
19185
  async function linkWallet(walletData) {
19220
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
19186
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
19221
19187
  if (!hasValidToken) throw new Error("No authentication token available");
19222
- const response = await (0, import_auth20.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/wallet`, {
19188
+ const response = await (0, import_auth21.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/wallet`, {
19223
19189
  method: "POST",
19224
19190
  body: JSON.stringify(walletData)
19225
19191
  });
@@ -19229,9 +19195,9 @@ async function linkWallet(walletData) {
19229
19195
  }
19230
19196
  }
19231
19197
  async function unlinkWallet(address) {
19232
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
19198
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
19233
19199
  if (!hasValidToken) throw new Error("No authentication token available");
19234
- const response = await (0, import_auth20.authenticatedFetch)(
19200
+ const response = await (0, import_auth21.authenticatedFetch)(
19235
19201
  `${getTssUrl3()}/api/auth/unlink/wallet?address=${encodeURIComponent(address)}`,
19236
19202
  {
19237
19203
  method: "DELETE"
@@ -19325,23 +19291,23 @@ var init_useFlowSelector = __esm({
19325
19291
  });
19326
19292
 
19327
19293
  // src/internal/components/SendMenu/hyperbridge/lib/chains.ts
19328
- var import_read14, import_chains, CHAINS_UI_META;
19294
+ var import_read15, import_chains, CHAINS_UI_META;
19329
19295
  var init_chains = __esm({
19330
19296
  "src/internal/components/SendMenu/hyperbridge/lib/chains.ts"() {
19331
19297
  init_EthereumIcon();
19332
19298
  init_LumiaIcon2();
19333
19299
  init_BscIcon();
19334
- import_read14 = require("@embarkai/core/read");
19300
+ import_read15 = require("@embarkai/core/read");
19335
19301
  import_chains = require("wagmi/chains");
19336
19302
  CHAINS_UI_META = {
19337
19303
  lumiaprism: {
19338
- chainID: import_read14.lumiaMainnetChain.id,
19339
- chainLabel: import_read14.lumiaMainnetChain.name,
19304
+ chainID: import_read15.lumiaMainnetChain.id,
19305
+ chainLabel: import_read15.lumiaMainnetChain.name,
19340
19306
  chainName: "lumiaprism",
19341
19307
  // exact hyperlane registry chain name
19342
19308
  Icon: LumiaIcon2,
19343
- explorerUrl: import_read14.lumiaMainnetChain.blockExplorers.default.url,
19344
- chain: import_read14.lumiaMainnetChain
19309
+ explorerUrl: import_read15.lumiaMainnetChain.blockExplorers.default.url,
19310
+ chain: import_read15.lumiaMainnetChain
19345
19311
  },
19346
19312
  bsc: {
19347
19313
  chainID: import_chains.bsc.id,
@@ -19750,7 +19716,7 @@ var init_useAvailableSenders = __esm({
19750
19716
 
19751
19717
  // src/internal/components/SendMenu/hyperbridge/api.ts
19752
19718
  function iframe3() {
19753
- const accessToken = import_auth20.jwtTokenManager.getAccessToken();
19719
+ const accessToken = import_auth21.jwtTokenManager.getAccessToken();
19754
19720
  if (!accessToken) {
19755
19721
  throw new Error("Access token is not available");
19756
19722
  }
@@ -19815,7 +19781,7 @@ var init_api3 = __esm({
19815
19781
  // src/clients/bundler/getUserOperationByHash.ts
19816
19782
  async function getUserOperationByHash(userOpHash, chainId) {
19817
19783
  const targetChainId = chainId ?? requireActiveChainId();
19818
- const chainConfig = (0, import_read15.getChainConfig)(targetChainId);
19784
+ const chainConfig = (0, import_read16.getChainConfig)(targetChainId);
19819
19785
  if (!chainConfig) {
19820
19786
  throw new Error(`Chain ${targetChainId} is not supported`);
19821
19787
  }
@@ -19843,19 +19809,19 @@ async function getUserOperationByHash(userOpHash, chainId) {
19843
19809
  return null;
19844
19810
  }
19845
19811
  }
19846
- var import_core3, import_read15;
19812
+ var import_core3, import_read16;
19847
19813
  var init_getUserOperationByHash = __esm({
19848
19814
  "src/clients/bundler/getUserOperationByHash.ts"() {
19849
19815
  init_SessionContext();
19850
19816
  import_core3 = require("@embarkai/core");
19851
- import_read15 = require("@embarkai/core/read");
19817
+ import_read16 = require("@embarkai/core/read");
19852
19818
  }
19853
19819
  });
19854
19820
 
19855
19821
  // src/clients/bundler/getUserOperationReceipt.ts
19856
19822
  async function getUserOperationReceipt(userOpHash, chainId) {
19857
19823
  const targetChainId = chainId ?? requireActiveChainId();
19858
- const chainConfig = (0, import_read16.getChainConfig)(targetChainId);
19824
+ const chainConfig = (0, import_read17.getChainConfig)(targetChainId);
19859
19825
  if (!chainConfig) {
19860
19826
  throw new Error(`Chain ${targetChainId} is not supported`);
19861
19827
  }
@@ -19889,12 +19855,12 @@ async function getUserOperationReceipt(userOpHash, chainId) {
19889
19855
  return null;
19890
19856
  }
19891
19857
  }
19892
- var import_core4, import_read16;
19858
+ var import_core4, import_read17;
19893
19859
  var init_getUserOperationReceipt = __esm({
19894
19860
  "src/clients/bundler/getUserOperationReceipt.ts"() {
19895
19861
  init_SessionContext();
19896
19862
  import_core4 = require("@embarkai/core");
19897
- import_read16 = require("@embarkai/core/read");
19863
+ import_read17 = require("@embarkai/core/read");
19898
19864
  }
19899
19865
  });
19900
19866
 
@@ -20062,7 +20028,7 @@ function isOririnChainEmbarkSupported(originChain) {
20062
20028
  var import_viem12;
20063
20029
  var init_utils8 = __esm({
20064
20030
  "src/internal/components/SendMenu/hyperbridge/utils.ts"() {
20065
- init_networks3();
20031
+ init_networks4();
20066
20032
  import_viem12 = require("viem");
20067
20033
  init_chains();
20068
20034
  }
@@ -23313,27 +23279,27 @@ function getHistoryUrls(params) {
23313
23279
  }
23314
23280
  return getBlockscoutHistoryUrls(params);
23315
23281
  }
23316
- var import_read17, ETHERSCAN_V2_API_URL, BLOCKSCOUT_API_URLS, CHAIN_SPECIFIC_API_URLS, ETHERSCAN_CHAINS, UNSUPPORTED_HISTORY_CHAINS, TX_HISTORY_URLS;
23282
+ var import_read18, ETHERSCAN_V2_API_URL, BLOCKSCOUT_API_URLS, CHAIN_SPECIFIC_API_URLS, ETHERSCAN_CHAINS, UNSUPPORTED_HISTORY_CHAINS, TX_HISTORY_URLS;
23317
23283
  var init_txUrls = __esm({
23318
23284
  "src/internal/components/TransactionsMenu/txUrls.ts"() {
23319
- import_read17 = require("@embarkai/core/read");
23285
+ import_read18 = require("@embarkai/core/read");
23320
23286
  init_base();
23321
23287
  ETHERSCAN_V2_API_URL = "https://api.etherscan.io/v2/api";
23322
23288
  BLOCKSCOUT_API_URLS = {
23323
- [import_read17.ARBITRUM_SEPOLIA_CHAIN_ID]: "https://arbitrum-sepolia.blockscout.com/api",
23324
- [import_read17.BASE_SEPOLIA_CHAIN_ID]: "https://base-sepolia.blockscout.com/api"
23289
+ [import_read18.ARBITRUM_SEPOLIA_CHAIN_ID]: "https://arbitrum-sepolia.blockscout.com/api",
23290
+ [import_read18.BASE_SEPOLIA_CHAIN_ID]: "https://base-sepolia.blockscout.com/api"
23325
23291
  };
23326
23292
  CHAIN_SPECIFIC_API_URLS = {};
23327
23293
  ETHERSCAN_CHAINS = /* @__PURE__ */ new Set([
23328
- import_read17.SEPOLIA_CHAIN_ID,
23329
- import_read17.ARBITRUM_SEPOLIA_CHAIN_ID,
23330
- import_read17.BASE_SEPOLIA_CHAIN_ID
23294
+ import_read18.SEPOLIA_CHAIN_ID,
23295
+ import_read18.ARBITRUM_SEPOLIA_CHAIN_ID,
23296
+ import_read18.BASE_SEPOLIA_CHAIN_ID
23331
23297
  ]);
23332
23298
  UNSUPPORTED_HISTORY_CHAINS = /* @__PURE__ */ new Set([
23333
- import_read17.BSC_TESTNET_CHAIN_ID
23299
+ import_read18.BSC_TESTNET_CHAIN_ID
23334
23300
  ]);
23335
23301
  TX_HISTORY_URLS = {
23336
- [import_read17.LUMIA_TESTNET_CHAIN_ID]: (p) => {
23302
+ [import_read18.LUMIA_TESTNET_CHAIN_ID]: (p) => {
23337
23303
  const result = getBlockscoutHistoryUrls(p);
23338
23304
  return {
23339
23305
  transactionsUrl: result.transactionsUrl,
@@ -23341,7 +23307,7 @@ var init_txUrls = __esm({
23341
23307
  tokenTransfersUrl: result.tokenTransfersUrl
23342
23308
  };
23343
23309
  },
23344
- [import_read17.LUMIA_MAINNET_CHAIN_ID]: (p) => {
23310
+ [import_read18.LUMIA_MAINNET_CHAIN_ID]: (p) => {
23345
23311
  const result = getBlockscoutHistoryUrls(p);
23346
23312
  return {
23347
23313
  transactionsUrl: result.transactionsUrl,
@@ -24456,7 +24422,7 @@ var init_usePageMapper = __esm({
24456
24422
  function useSettingsNotifications() {
24457
24423
  const address = useSession((st) => st.address);
24458
24424
  const setSettingsNotifications = useLayoutDataStore((st) => st.setSettingsNotifications);
24459
- const providers = import_auth20.jwtTokenManager.getProviders();
24425
+ const providers = import_auth21.jwtTokenManager.getProviders();
24460
24426
  const hasEmail = providers.includes("email");
24461
24427
  const { data: userProfile = null } = (0, import_react_query51.useQuery)({
24462
24428
  retry: false,
@@ -24506,7 +24472,7 @@ var init_package = __esm({
24506
24472
  "package.json"() {
24507
24473
  package_default = {
24508
24474
  name: "@embarkai/ui-kit",
24509
- version: "0.4.46",
24475
+ version: "0.4.47",
24510
24476
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
24511
24477
  type: "module",
24512
24478
  main: "./dist/index.cjs",
@@ -24607,25 +24573,39 @@ var init_package = __esm({
24607
24573
  function Footer() {
24608
24574
  const qc = (0, import_react_query52.useQueryClient)();
24609
24575
  const { callbacksRef } = useProviderConfig();
24610
- const { address, setSession, setAddress, setStatus, setError, setIsLoading } = useSession();
24611
- const chainConfig = useSession((st) => st.chainConfig);
24612
24576
  const { t } = useT();
24613
- const setPage = useLayoutDataStore((st) => st.setPage);
24614
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
24577
+ const address = useSession((st) => st.address);
24578
+ const chainConfig = useSession((st) => st.chainConfig);
24579
+ const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
24580
+ const { disconnect: wagmiDisconnect } = (0, import_wagmi6.useDisconnect)({
24581
+ mutation: {
24582
+ onSuccess: () => {
24583
+ useExternalWalletStore.getState().clearExternalWallet();
24584
+ useExternalWalletStore.getState().setExternalChainId(null);
24585
+ console.log("[ExternalWalletStore] Disconnected from external wallet");
24586
+ },
24587
+ onError: (err) => {
24588
+ console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
24589
+ }
24590
+ }
24591
+ });
24615
24592
  const { mutate: disconnect, isPending: isDisconnecting } = (0, import_react_query52.useMutation)({
24616
24593
  mutationFn: async (disconnectAddress) => {
24617
24594
  if (!disconnectAddress) throw new Error("No address to disconnect");
24618
- setIsDialogForced(true);
24595
+ const { setError, setStatus, setIsLoading } = useSession.getState();
24596
+ useLayoutStore.getState().setIsDialogForced(true);
24619
24597
  setError(null);
24620
24598
  setStatus("disconnecting");
24621
24599
  setIsLoading(true);
24622
- const userId = import_auth20.jwtTokenManager.getUserId() || null;
24600
+ const userId = import_auth21.jwtTokenManager.getUserId() || null;
24623
24601
  const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
24624
24602
  await logout2();
24625
24603
  return { disconnectedUserId: userId, disconnectAddress };
24626
24604
  },
24627
24605
  onSuccess: async ({ disconnectAddress, disconnectedUserId }) => {
24628
24606
  await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
24607
+ if (!!directWalletAddress) wagmiDisconnect();
24608
+ const { setError, setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
24629
24609
  setSession(null);
24630
24610
  setAddress(null);
24631
24611
  setError(null);
@@ -24633,15 +24613,16 @@ function Footer() {
24633
24613
  setIsLoading(false);
24634
24614
  callbacksRef.current?.onDisconnect?.({ address: disconnectAddress, userId: disconnectedUserId });
24635
24615
  setTimeout(() => {
24636
- setPage("auth" /* AUTH */);
24637
- setIsDialogForced(false);
24616
+ useLayoutDataStore.getState().setPage("auth" /* AUTH */);
24617
+ useLayoutStore.getState().setIsDialogForced(false);
24638
24618
  }, 200);
24639
24619
  },
24640
24620
  onError: (err) => {
24621
+ const { setError, setStatus, setIsLoading } = useSession.getState();
24641
24622
  setError(err.message || "An unknown error occurred during sign out");
24642
24623
  setStatus("idle");
24643
24624
  setIsLoading(false);
24644
- setIsDialogForced(false);
24625
+ useLayoutStore.getState().setIsDialogForced(false);
24645
24626
  }
24646
24627
  });
24647
24628
  const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
@@ -24694,21 +24675,23 @@ function Footer() {
24694
24675
  }
24695
24676
  );
24696
24677
  }
24697
- var import_react_query52, import_lucide_react76, import_jsx_runtime116;
24678
+ var import_react_query52, import_lucide_react76, import_wagmi6, import_jsx_runtime116;
24698
24679
  var init_Footer = __esm({
24699
24680
  "src/internal/components/Footer/Footer.tsx"() {
24700
24681
  init_package();
24701
- init_networks3();
24682
+ init_networks4();
24702
24683
  init_ProviderContext();
24703
24684
  init_SessionContext();
24704
24685
  init_i18n();
24705
24686
  import_react_query52 = require("@tanstack/react-query");
24706
24687
  import_lucide_react76 = require("lucide-react");
24688
+ import_wagmi6 = require("wagmi");
24707
24689
  init_auth();
24708
24690
  init_base();
24709
24691
  init_useLayoutDataStore();
24710
24692
  init_useLayoutStore();
24711
24693
  init_utils2();
24694
+ init_useExternalWalletStore();
24712
24695
  init_constants4();
24713
24696
  init_button();
24714
24697
  import_jsx_runtime116 = require("react/jsx-runtime");
@@ -24761,8 +24744,8 @@ function Header() {
24761
24744
  queryKey: [QUERY_KEYS.userProfile, address],
24762
24745
  queryFn: getUserProfile
24763
24746
  });
24764
- const avatar = profile?.avatar || import_auth20.jwtTokenManager.getAvatar();
24765
- const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth20.jwtTokenManager.getDisplayName();
24747
+ const avatar = profile?.avatar || import_auth21.jwtTokenManager.getAvatar();
24748
+ const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth21.jwtTokenManager.getDisplayName();
24766
24749
  const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
24767
24750
  return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
24768
24751
  "div",
@@ -24841,7 +24824,7 @@ var import_react_query53, import_lucide_react77, import_react85, import_jsx_runt
24841
24824
  var init_Header = __esm({
24842
24825
  "src/internal/components/Header/Header.tsx"() {
24843
24826
  init_LumiaIcon3();
24844
- init_networks3();
24827
+ init_networks4();
24845
24828
  init_ProviderContext();
24846
24829
  init_SessionContext();
24847
24830
  init_useT();
@@ -25181,10 +25164,10 @@ function WalletConnectHandler() {
25181
25164
  const qc = (0, import_react_query54.useQueryClient)();
25182
25165
  const { callbacksRef } = useProviderConfig();
25183
25166
  const passportWalletAddress = useSession((st) => st.address);
25184
- const { address: walletAddress, isConnected, chain, connector } = (0, import_wagmi6.useAccount)();
25167
+ const { address: walletAddress, isConnected, chain, connector } = (0, import_wagmi7.useAccount)();
25185
25168
  const { openConnectModal, connectModalOpen } = (0, import_rainbowkit2.useConnectModal)();
25186
- const { disconnect } = (0, import_wagmi6.useDisconnect)();
25187
- const { signMessageAsync } = (0, import_wagmi6.useSignMessage)();
25169
+ const { disconnect } = (0, import_wagmi7.useDisconnect)();
25170
+ const { signMessageAsync } = (0, import_wagmi7.useSignMessage)();
25188
25171
  const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
25189
25172
  const setPage = useLayoutDataStore((st) => st.setPage);
25190
25173
  const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
@@ -25439,7 +25422,7 @@ function WalletConnectHandler() {
25439
25422
  ]);
25440
25423
  return null;
25441
25424
  }
25442
- var import_rainbowkit2, import_react_query54, import_react89, import_wagmi6;
25425
+ var import_rainbowkit2, import_react_query54, import_react89, import_wagmi7;
25443
25426
  var init_WalletConnectHandler = __esm({
25444
25427
  "src/internal/components/WalletConnectHandler.tsx"() {
25445
25428
  init_ProviderContext();
@@ -25448,7 +25431,7 @@ var init_WalletConnectHandler = __esm({
25448
25431
  import_rainbowkit2 = require("@rainbow-me/rainbowkit");
25449
25432
  import_react_query54 = require("@tanstack/react-query");
25450
25433
  import_react89 = __toESM(require("react"), 1);
25451
- import_wagmi6 = require("wagmi");
25434
+ import_wagmi7 = require("wagmi");
25452
25435
  init_wallet();
25453
25436
  init_AuthMenu2();
25454
25437
  init_useLayoutDataStore();
@@ -25460,7 +25443,7 @@ var init_WalletConnectHandler = __esm({
25460
25443
  // src/internal/components/DirectWalletHandler.tsx
25461
25444
  function DirectWalletHandler() {
25462
25445
  const walletMode = useProviderConfig().config.current?.wallet?.mode || "linked";
25463
- const { address, isConnected, chain, connector } = (0, import_wagmi7.useAccount)();
25446
+ const { address, isConnected, chain, connector } = (0, import_wagmi8.useAccount)();
25464
25447
  const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
25465
25448
  const externalAddress = useExternalWalletStore((st) => st.externalAddress);
25466
25449
  const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
@@ -25504,11 +25487,11 @@ function DirectWalletHandler() {
25504
25487
  }, [address, isConnected, isExternalConnected, externalAddress, chain?.id, connector, setExternalWallet]);
25505
25488
  return null;
25506
25489
  }
25507
- var import_react90, import_wagmi7;
25490
+ var import_react90, import_wagmi8;
25508
25491
  var init_DirectWalletHandler = __esm({
25509
25492
  "src/internal/components/DirectWalletHandler.tsx"() {
25510
25493
  import_react90 = require("react");
25511
- import_wagmi7 = require("wagmi");
25494
+ import_wagmi8 = require("wagmi");
25512
25495
  init_ProviderContext();
25513
25496
  init_useExternalWalletStore();
25514
25497
  }
@@ -25519,9 +25502,9 @@ function getChainParams(chainCfg) {
25519
25502
  return {
25520
25503
  activeChainId: chainCfg.id,
25521
25504
  chainConfig: chainCfg,
25522
- publicClient: (0, import_read18.createPublicClientForChain)(chainCfg.id),
25523
- bundlerClient: (0, import_read18.createBundlerClientForChain)(chainCfg.id),
25524
- viemChain: (0, import_read18.getViemChain)(chainCfg.id)
25505
+ publicClient: (0, import_read19.createPublicClientForChain)(chainCfg.id),
25506
+ bundlerClient: (0, import_read19.createBundlerClientForChain)(chainCfg.id),
25507
+ viemChain: (0, import_read19.getViemChain)(chainCfg.id)
25525
25508
  };
25526
25509
  }
25527
25510
  function waitForStoreHydration() {
@@ -25547,10 +25530,10 @@ function SessionProvider({ children }) {
25547
25530
  /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(Dialog2, {})
25548
25531
  ] });
25549
25532
  }
25550
- var import_read18, import_react91, import_zustand13, import_middleware4, import_jsx_runtime121, useSession, requireActiveChainId;
25533
+ var import_read19, import_react91, import_zustand13, import_middleware4, import_jsx_runtime121, useSession, requireActiveChainId;
25551
25534
  var init_SessionContext = __esm({
25552
25535
  "src/context/SessionContext.tsx"() {
25553
- import_read18 = require("@embarkai/core/read");
25536
+ import_read19 = require("@embarkai/core/read");
25554
25537
  import_react91 = require("react");
25555
25538
  import_zustand13 = require("zustand");
25556
25539
  import_middleware4 = require("zustand/middleware");
@@ -25622,7 +25605,7 @@ var init_SessionContext = __esm({
25622
25605
  // Set default chainId after hydration if not persisted
25623
25606
  onRehydrateStorage: () => (state) => {
25624
25607
  if (!state) return;
25625
- const hydartedChain = getChainParams((0, import_read18.getChainConfig)(state.activeChainId || import_read18.DEFAULT_CHAIN_ID));
25608
+ const hydartedChain = getChainParams((0, import_read19.getChainConfig)(state.activeChainId || import_read19.DEFAULT_CHAIN_ID));
25626
25609
  state.activeChainId = hydartedChain.activeChainId;
25627
25610
  state.publicClient = hydartedChain.publicClient;
25628
25611
  state.bundlerClient = hydartedChain.bundlerClient;
@@ -25697,31 +25680,31 @@ function getExplorerUrl() {
25697
25680
  const paramUrl = typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("explorerUrl") || void 0 : void 0;
25698
25681
  const net = getSelectedNetwork();
25699
25682
  const chainId = requireActiveChainId();
25700
- const chainConfig = (0, import_read19.getChainConfig)(chainId);
25683
+ const chainConfig = (0, import_read20.getChainConfig)(chainId);
25701
25684
  console.log("[getExplorerUrl] ", paramUrl, chainConfig.blockExplorerUrl);
25702
25685
  return paramUrl || chainConfig.blockExplorerUrl;
25703
25686
  }
25704
25687
  function getBundlerClient() {
25705
25688
  const chainId = requireActiveChainId();
25706
- const chainConfig = (0, import_read19.getChainConfig)(chainId);
25707
- const viemChain = (0, import_read19.getViemChain)(chainId);
25689
+ const chainConfig = (0, import_read20.getChainConfig)(chainId);
25690
+ const viemChain = (0, import_read20.getViemChain)(chainId);
25708
25691
  return (0, import_account_abstraction2.createBundlerClient)({
25709
25692
  chain: viemChain,
25710
25693
  transport: (0, import_viem19.http)(chainConfig.bundlerUrl, { timeout: 1e4, retryCount: 0, fetchOptions: { mode: "cors" } })
25711
25694
  });
25712
25695
  }
25713
- var import_read19, import_viem19, import_account_abstraction2, BUILD_NETWORK, lumiaBeamTestnet, lumiaPrisma, FUNDER_PK;
25696
+ var import_read20, import_viem19, import_account_abstraction2, BUILD_NETWORK, lumiaBeamTestnet, lumiaPrisma, FUNDER_PK;
25714
25697
  var init_base = __esm({
25715
25698
  "src/internal/clients/base.ts"() {
25716
25699
  init_initial();
25717
25700
  init_SessionContext();
25718
- import_read19 = require("@embarkai/core/read");
25701
+ import_read20 = require("@embarkai/core/read");
25719
25702
  import_viem19 = require("viem");
25720
25703
  import_account_abstraction2 = require("viem/account-abstraction");
25721
25704
  init_env();
25722
25705
  BUILD_NETWORK = true ? "" : "";
25723
- lumiaBeamTestnet = import_read19.lumiaTestnetChain;
25724
- lumiaPrisma = import_read19.lumiaMainnetChain;
25706
+ lumiaBeamTestnet = import_read20.lumiaTestnetChain;
25707
+ lumiaPrisma = import_read20.lumiaMainnetChain;
25725
25708
  FUNDER_PK = getEnvVar("VITE_FUNDER_PK") || "";
25726
25709
  }
25727
25710
  });
@@ -26441,7 +26424,7 @@ var init_vaultClient = __esm({
26441
26424
 
26442
26425
  // src/internal/auth/keyshare.ts
26443
26426
  async function checkKeyshareStatusWithSync(userId) {
26444
- const serverHasKeyshare = await (0, import_auth20.syncKeyshareStatus)();
26427
+ const serverHasKeyshare = await (0, import_auth21.syncKeyshareStatus)();
26445
26428
  return checkKeyshareStatus(userId, serverHasKeyshare);
26446
26429
  }
26447
26430
  async function checkKeyshareStatus(userId, serverHasKeyshare) {
@@ -26475,7 +26458,7 @@ async function ensureKeyshareForNewUser(userId, onProgress) {
26475
26458
  onProgress?.("Setting up secure key management...");
26476
26459
  const result = await ensureDkgAndGetOwner(userId);
26477
26460
  if (!result.ownerAddress) throw new Error("DKG completed but no owner address received");
26478
- await (0, import_auth20.syncKeyshareStatus)();
26461
+ await (0, import_auth21.syncKeyshareStatus)();
26479
26462
  onProgress?.("Key management setup complete");
26480
26463
  return { ownerAddress: result.ownerAddress };
26481
26464
  }
@@ -26560,7 +26543,7 @@ var init_keyshare = __esm({
26560
26543
 
26561
26544
  // src/internal/auth/providers/x.ts
26562
26545
  async function linkX() {
26563
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
26546
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
26564
26547
  if (!hasValidToken) throw new Error("No authentication token available");
26565
26548
  throw new Error('Use openSocialAuthPopup("x") to link X account');
26566
26549
  }
@@ -26568,10 +26551,10 @@ async function loginWithX() {
26568
26551
  throw new Error('Use openSocialAuthPopup("x") to login with X account');
26569
26552
  }
26570
26553
  async function unlinkX(externalId) {
26571
- const hasValidToken = await (0, import_auth20.ensureValidToken)();
26554
+ const hasValidToken = await (0, import_auth21.ensureValidToken)();
26572
26555
  if (!hasValidToken) throw new Error("No authentication token available");
26573
26556
  const url = externalId ? `${getTssUrl3()}/api/auth/unlink/x?externalId=${encodeURIComponent(externalId)}` : `${getTssUrl3()}/api/auth/unlink/x`;
26574
- const response = await (0, import_auth20.authenticatedFetch)(url, {
26557
+ const response = await (0, import_auth21.authenticatedFetch)(url, {
26575
26558
  method: "DELETE"
26576
26559
  });
26577
26560
  if (!response.ok) {
@@ -26602,9 +26585,9 @@ var init_providers = __esm({
26602
26585
  // src/internal/auth/index.ts
26603
26586
  var auth_exports = {};
26604
26587
  __export(auth_exports, {
26605
- JwtTokenManager: () => import_auth20.JwtTokenManager,
26588
+ JwtTokenManager: () => import_auth21.JwtTokenManager,
26606
26589
  authenticateWithPasskey: () => authenticateWithPasskey,
26607
- authenticatedFetch: () => import_auth20.authenticatedFetch,
26590
+ authenticatedFetch: () => import_auth21.authenticatedFetch,
26608
26591
  beginPasskeyAuthentication: () => beginPasskeyAuthentication,
26609
26592
  beginPasskeyLinking: () => beginPasskeyLinking,
26610
26593
  beginPasskeyRegistration: () => beginPasskeyRegistration,
@@ -26614,53 +26597,53 @@ __export(auth_exports, {
26614
26597
  completePasskeyAuthentication: () => completePasskeyAuthentication,
26615
26598
  completePasskeyLinking: () => completePasskeyLinking,
26616
26599
  completePasskeyRegistration: () => completePasskeyRegistration,
26617
- configureJwtModule: () => import_auth20.configureJwtModule,
26600
+ configureJwtModule: () => import_auth21.configureJwtModule,
26618
26601
  createInitialAuthState: () => createInitialAuthState,
26619
- createJwtTokenManager: () => import_auth20.createJwtTokenManager,
26602
+ createJwtTokenManager: () => import_auth21.createJwtTokenManager,
26620
26603
  createLoginMessage: () => createLoginMessage,
26621
26604
  createPasskeyHelpers: () => createPasskeyHelpers,
26622
26605
  createSignatureMessage: () => createSignatureMessage,
26623
26606
  deriveDemoPrivateKey: () => deriveDemoPrivateKey,
26624
26607
  ensureKeyshare: () => ensureKeyshare,
26625
- ensureValidToken: () => import_auth20.ensureValidToken,
26608
+ ensureValidToken: () => import_auth21.ensureValidToken,
26626
26609
  fetchProjectName: () => fetchProjectName,
26627
26610
  formatDate: () => formatDate,
26628
26611
  getKeyshareInfo: () => getKeyshareInfo,
26629
26612
  getLinkedProviders: () => getLinkedProviders,
26630
26613
  getProviderDisplayInfo: () => getProviderDisplayInfo,
26631
26614
  getTssUrl: () => getTssUrl3,
26632
- getValidTokens: () => import_auth20.getValidTokens,
26615
+ getValidTokens: () => import_auth21.getValidTokens,
26633
26616
  hasAvailablePasskeys: () => hasAvailablePasskeys,
26634
26617
  hideTelegramWidget: () => hideTelegramWidget,
26635
26618
  initTelegramWidget: () => initTelegramWidget,
26636
26619
  isWebAuthnSupported: () => isWebAuthnSupported,
26637
- jwtTokenManager: () => import_auth20.jwtTokenManager,
26620
+ jwtTokenManager: () => import_auth21.jwtTokenManager,
26638
26621
  linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn,
26639
26622
  linkTelegram: () => linkTelegram,
26640
26623
  linkWallet: () => linkWallet,
26641
26624
  linkX: () => linkX,
26642
- loginWithEmail: () => import_auth20.loginWithEmail,
26643
- loginWithTelegram: () => import_auth20.loginWithTelegram,
26644
- loginWithUserId: () => import_auth20.loginWithUserId,
26625
+ loginWithEmail: () => import_auth21.loginWithEmail,
26626
+ loginWithTelegram: () => import_auth21.loginWithTelegram,
26627
+ loginWithUserId: () => import_auth21.loginWithUserId,
26645
26628
  loginWithX: () => loginWithX,
26646
- logout: () => import_auth20.logout,
26629
+ logout: () => import_auth21.logout,
26647
26630
  mountTelegramLoginWidget: () => mountTelegramLoginWidget,
26648
26631
  registerPasskey: () => registerPasskey,
26649
26632
  resetWebAuthnFlags: () => resetWebAuthnFlags,
26650
26633
  sendEmailLinkCode: () => sendEmailLinkCode,
26651
26634
  showTelegramWidget: () => showTelegramWidget,
26652
- syncKeyshareStatus: () => import_auth20.syncKeyshareStatus,
26635
+ syncKeyshareStatus: () => import_auth21.syncKeyshareStatus,
26653
26636
  unlinkProvider: () => unlinkProvider,
26654
26637
  unlinkWallet: () => unlinkWallet,
26655
26638
  unlinkX: () => unlinkX,
26656
26639
  verifyEmailLinkCode: () => verifyEmailLinkCode,
26657
- verifyToken: () => import_auth20.verifyToken,
26640
+ verifyToken: () => import_auth21.verifyToken,
26658
26641
  walletLogin: () => walletLogin
26659
26642
  });
26660
- var import_auth20, createInitialAuthState;
26643
+ var import_auth21, createInitialAuthState;
26661
26644
  var init_auth = __esm({
26662
26645
  "src/internal/auth/index.ts"() {
26663
- import_auth20 = require("@embarkai/core/auth");
26646
+ import_auth21 = require("@embarkai/core/auth");
26664
26647
  init_passkeyAuth();
26665
26648
  init_telegram();
26666
26649
  init_passkey();
@@ -27962,13 +27945,13 @@ var init_iframe_manager = __esm({
27962
27945
  });
27963
27946
 
27964
27947
  // src/config/rainbowkit.ts
27965
- var import_read20, import_rainbowkit3, import_wallets2, import_wagmi8, import_chains12, getProjectId2, WALLET_MAP, getWagmiStorageKey, buildRainbowChains, createRainbowConfig, rainbowTheme;
27948
+ var import_read21, import_rainbowkit3, import_wallets2, import_wagmi9, import_chains12, getProjectId2, WALLET_MAP, getWagmiStorageKey, buildRainbowChains, createRainbowConfig, rainbowTheme;
27966
27949
  var init_rainbowkit = __esm({
27967
27950
  "src/config/rainbowkit.ts"() {
27968
- import_read20 = require("@embarkai/core/read");
27951
+ import_read21 = require("@embarkai/core/read");
27969
27952
  import_rainbowkit3 = require("@rainbow-me/rainbowkit");
27970
27953
  import_wallets2 = require("@rainbow-me/rainbowkit/wallets");
27971
- import_wagmi8 = require("wagmi");
27954
+ import_wagmi9 = require("wagmi");
27972
27955
  import_chains12 = require("wagmi/chains");
27973
27956
  getProjectId2 = (configProjectId) => {
27974
27957
  if (configProjectId) return configProjectId;
@@ -27992,8 +27975,8 @@ var init_rainbowkit = __esm({
27992
27975
  };
27993
27976
  buildRainbowChains = (supportedChains, preferredChainId) => {
27994
27977
  const availableChains = [
27995
- import_read20.lumiaMainnetChain,
27996
- import_read20.lumiaTestnetChain,
27978
+ import_read21.lumiaMainnetChain,
27979
+ import_read21.lumiaTestnetChain,
27997
27980
  import_chains12.mainnet,
27998
27981
  import_chains12.polygon,
27999
27982
  import_chains12.bsc,
@@ -28019,7 +28002,7 @@ var init_rainbowkit = __esm({
28019
28002
  appName: "EmbarkAI Wallet",
28020
28003
  projectId: getProjectId2(opts.projectId),
28021
28004
  chains: buildRainbowChains(opts.supportedChains, opts.preferredChainId),
28022
- storage: (0, import_wagmi8.createStorage)({ key: getWagmiStorageKey(opts) }),
28005
+ storage: (0, import_wagmi9.createStorage)({ key: getWagmiStorageKey(opts) }),
28023
28006
  ssr: false
28024
28007
  };
28025
28008
  if (opts.allowedWallets && opts.allowedWallets.length > 0) {
@@ -28249,14 +28232,14 @@ function RainbowKitProvider({ children }) {
28249
28232
  };
28250
28233
  }, [colorMode]);
28251
28234
  if (!config.current?.wallet?.enabled) return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children });
28252
- return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_wagmi9.WagmiProvider, { config: rainbowConfig, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_rainbowkit4.RainbowKitProvider, { theme: customTheme, modalSize: "compact", showRecentTransactions: true, children }) });
28235
+ return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_wagmi10.WagmiProvider, { config: rainbowConfig, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_rainbowkit4.RainbowKitProvider, { theme: customTheme, modalSize: "compact", showRecentTransactions: true, children }) });
28253
28236
  }
28254
- var import_rainbowkit4, import_react92, import_wagmi9, import_styles, import_jsx_runtime122;
28237
+ var import_rainbowkit4, import_react92, import_wagmi10, import_styles, import_jsx_runtime122;
28255
28238
  var init_RainbowKitContext = __esm({
28256
28239
  "src/context/RainbowKitContext.tsx"() {
28257
28240
  import_rainbowkit4 = require("@rainbow-me/rainbowkit");
28258
28241
  import_react92 = require("react");
28259
- import_wagmi9 = require("wagmi");
28242
+ import_wagmi10 = require("wagmi");
28260
28243
  init_rainbowkit();
28261
28244
  init_useLayoutStore();
28262
28245
  init_ProviderContext();
@@ -28281,14 +28264,14 @@ var init_utils11 = __esm({
28281
28264
  });
28282
28265
 
28283
28266
  // src/context/WagmiContext.tsx
28284
- var import_core7, import_wagmi10, import_jsx_runtime123, WagmiProvider2;
28267
+ var import_core7, import_wagmi11, import_jsx_runtime123, WagmiProvider2;
28285
28268
  var init_WagmiContext = __esm({
28286
28269
  "src/context/WagmiContext.tsx"() {
28287
28270
  import_core7 = require("@embarkai/core");
28288
- import_wagmi10 = require("wagmi");
28271
+ import_wagmi11 = require("wagmi");
28289
28272
  import_jsx_runtime123 = require("react/jsx-runtime");
28290
28273
  WagmiProvider2 = ({ children }) => {
28291
- return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_wagmi10.WagmiProvider, { config: import_core7.wagmiConfig, children });
28274
+ return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_wagmi11.WagmiProvider, { config: import_core7.wagmiConfig, children });
28292
28275
  };
28293
28276
  }
28294
28277
  });
@@ -28480,9 +28463,9 @@ __export(index_exports, {
28480
28463
  getUserOperationByHash: () => getUserOperationByHash,
28481
28464
  getUserOperationReceipt: () => getUserOperationReceipt,
28482
28465
  getUserProfile: () => getUserProfile,
28483
- getValidTokens: () => import_auth20.getValidTokens,
28484
- jwtTokenManager: () => import_auth20.jwtTokenManager,
28485
- logout: () => import_auth20.logout,
28466
+ getValidTokens: () => import_auth21.getValidTokens,
28467
+ jwtTokenManager: () => import_auth21.jwtTokenManager,
28468
+ logout: () => import_auth21.logout,
28486
28469
  looksLikeNickname: () => looksLikeNickname,
28487
28470
  prepareBatchUserOperation: () => prepareBatchUserOperation,
28488
28471
  prepareUserOperation: () => prepareUserOperation,
@@ -28677,11 +28660,11 @@ function ConnectWalletButton(props) {
28677
28660
  queryKey: [QUERY_KEYS.userProfile, address],
28678
28661
  queryFn: getUserProfile
28679
28662
  });
28680
- const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth20.jwtTokenManager.getDisplayName();
28663
+ const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth21.jwtTokenManager.getDisplayName();
28681
28664
  const indicators = (0, import_react94.useMemo)(() => {
28682
28665
  const userId = session?.mpcUserId;
28683
28666
  if (!userId) return { server: false, local: false, backup: false };
28684
- const server = import_auth20.jwtTokenManager.getHasKeyshare() ?? false;
28667
+ const server = import_auth21.jwtTokenManager.getHasKeyshare() ?? false;
28685
28668
  const local = !!address;
28686
28669
  return { server, local, backup: hasServerVault };
28687
28670
  }, [session, address, hasServerVault]);
@@ -29660,7 +29643,7 @@ function useWalletMode() {
29660
29643
  // src/hooks/useDirectWallet.ts
29661
29644
  var import_react98 = require("react");
29662
29645
  var import_rainbowkit6 = require("@rainbow-me/rainbowkit");
29663
- var import_wagmi11 = require("wagmi");
29646
+ var import_wagmi12 = require("wagmi");
29664
29647
  init_useExternalWalletStore();
29665
29648
  init_useLayoutDataStore();
29666
29649
  function useDirectWallet() {
@@ -29669,7 +29652,7 @@ function useDirectWallet() {
29669
29652
  const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
29670
29653
  const connectorName = useExternalWalletStore((st) => st.connectorName);
29671
29654
  const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
29672
- const { disconnect: wagmiDisconnect } = (0, import_wagmi11.useDisconnect)();
29655
+ const { disconnect: wagmiDisconnect } = (0, import_wagmi12.useDisconnect)();
29673
29656
  const { openConnectModal } = (0, import_rainbowkit6.useConnectModal)();
29674
29657
  const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
29675
29658
  const connect = (0, import_react98.useCallback)(() => {
@@ -29696,13 +29679,13 @@ function useDirectWallet() {
29696
29679
  // src/hooks/useSendDirectTransaction.ts
29697
29680
  var import_react99 = require("react");
29698
29681
  var import_viem20 = require("viem");
29699
- var import_wagmi12 = require("wagmi");
29682
+ var import_wagmi13 = require("wagmi");
29700
29683
  init_useExternalWalletStore();
29701
29684
  function useSendDirectTransaction() {
29702
29685
  const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
29703
29686
  const externalChainId = useExternalWalletStore((st) => st.externalChainId);
29704
- const { sendTransactionAsync } = (0, import_wagmi12.useSendTransaction)();
29705
- const { switchChainAsync } = (0, import_wagmi12.useSwitchChain)();
29687
+ const { sendTransactionAsync } = (0, import_wagmi13.useSendTransaction)();
29688
+ const { switchChainAsync } = (0, import_wagmi13.useSwitchChain)();
29706
29689
  const [isPending, setIsPending] = (0, import_react99.useState)(false);
29707
29690
  const [error, setError] = (0, import_react99.useState)(null);
29708
29691
  const [txHash, setTxHash] = (0, import_react99.useState)(null);
@@ -29835,11 +29818,11 @@ function useTransferToLinkedWallet() {
29835
29818
  }
29836
29819
 
29837
29820
  // src/hooks/useNativeWalletSignature.ts
29838
- var import_wagmi13 = require("wagmi");
29821
+ var import_wagmi14 = require("wagmi");
29839
29822
  init_providers();
29840
29823
  function useNativeWalletSignature() {
29841
- const signMessage = (0, import_wagmi13.useSignMessage)();
29842
- const signTypedMessage = (0, import_wagmi13.useSignTypedData)();
29824
+ const signMessage = (0, import_wagmi14.useSignMessage)();
29825
+ const signTypedMessage = (0, import_wagmi14.useSignTypedData)();
29843
29826
  return {
29844
29827
  signMessage,
29845
29828
  /** EIP-712 signature */
@@ -29849,27 +29832,43 @@ function useNativeWalletSignature() {
29849
29832
  }
29850
29833
 
29851
29834
  // src/hooks/useLogout.ts
29852
- var import_auth22 = require("@embarkai/core/auth");
29835
+ var import_auth23 = require("@embarkai/core/auth");
29853
29836
  var import_react101 = require("react");
29837
+ var import_wagmi15 = require("wagmi");
29854
29838
  init_ProviderContext();
29855
29839
  init_SessionContext();
29840
+ init_useExternalWalletStore();
29856
29841
  function useLogout() {
29857
- const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
29858
29842
  const { callbacksRef } = useProviderConfig();
29843
+ const address = useSession((st) => st.address);
29844
+ const { disconnect: wagmiDisconnect } = (0, import_wagmi15.useDisconnect)({
29845
+ mutation: {
29846
+ onSuccess: () => {
29847
+ useExternalWalletStore.getState().clearExternalWallet();
29848
+ useExternalWalletStore.getState().setExternalChainId(null);
29849
+ console.log("[ExternalWalletStore] Disconnected from external wallet");
29850
+ },
29851
+ onError: (err) => {
29852
+ console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
29853
+ }
29854
+ }
29855
+ });
29859
29856
  const logout2 = (0, import_react101.useCallback)(async () => {
29857
+ const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
29860
29858
  const prevAddress = address;
29861
29859
  let userId = null;
29862
29860
  setIsLoading(true);
29863
29861
  try {
29864
- userId = import_auth22.jwtTokenManager.getUserId() || null;
29862
+ userId = import_auth23.jwtTokenManager.getUserId() || null;
29865
29863
  } catch (error) {
29866
29864
  console.warn("[useLogout] Could not get userId:", error);
29867
29865
  }
29868
29866
  try {
29869
- await (0, import_auth22.logout)();
29867
+ await (0, import_auth23.logout)();
29870
29868
  } catch (error) {
29871
29869
  console.warn("[useLogout] Core logout failed:", error);
29872
29870
  }
29871
+ if (!!useExternalWalletStore.getState().externalAddress) wagmiDisconnect();
29873
29872
  setSession(null);
29874
29873
  setAddress(null);
29875
29874
  setStatus("idle");
@@ -29883,7 +29882,7 @@ function useLogout() {
29883
29882
  } catch (error) {
29884
29883
  console.warn("[useLogout] Callback error:", error);
29885
29884
  }
29886
- }, [address, setAddress, setError, setSession, setStatus]);
29885
+ }, [address]);
29887
29886
  return { logout: logout2 };
29888
29887
  }
29889
29888
 
@@ -29906,15 +29905,15 @@ init_useBlockscoutAssets();
29906
29905
 
29907
29906
  // src/modules/transactions.ts
29908
29907
  init_SessionContext();
29909
- var import_read21 = require("@embarkai/core/read");
29908
+ var import_read22 = require("@embarkai/core/read");
29910
29909
  var import_viem22 = require("viem");
29911
- var import_wagmi14 = require("wagmi");
29910
+ var import_wagmi16 = require("wagmi");
29912
29911
  function useTransactions() {
29913
29912
  const chainId = requireActiveChainId();
29914
- const viemChain = (0, import_read21.getViemChain)(chainId);
29915
- const publicClient = (0, import_wagmi14.usePublicClient)({ chainId });
29916
- const { data: walletClient } = (0, import_wagmi14.useWalletClient)();
29917
- const { address } = (0, import_wagmi14.useAccount)();
29913
+ const viemChain = (0, import_read22.getViemChain)(chainId);
29914
+ const publicClient = (0, import_wagmi16.usePublicClient)({ chainId });
29915
+ const { data: walletClient } = (0, import_wagmi16.useWalletClient)();
29916
+ const { address } = (0, import_wagmi16.useAccount)();
29918
29917
  const sendTransaction = async (params) => {
29919
29918
  if (!walletClient) {
29920
29919
  throw new Error("Wallet not connected");
@@ -29974,7 +29973,7 @@ function useTransactions() {
29974
29973
  init_SessionContext();
29975
29974
  var import_react102 = __toESM(require("react"), 1);
29976
29975
  var import_viem23 = require("viem");
29977
- var import_wagmi15 = require("wagmi");
29976
+ var import_wagmi17 = require("wagmi");
29978
29977
  var COMMON_TOKENS = [
29979
29978
  // Add real token addresses here when available
29980
29979
  // {
@@ -29991,7 +29990,7 @@ function useAssets(address) {
29991
29990
  data: nativeBalance,
29992
29991
  isLoading: nativeBalanceLoading,
29993
29992
  refetch: refetchNativeBalance
29994
- } = (0, import_wagmi15.useBalance)({
29993
+ } = (0, import_wagmi17.useBalance)({
29995
29994
  address,
29996
29995
  chainId,
29997
29996
  query: {
@@ -30005,7 +30004,7 @@ function useAssets(address) {
30005
30004
  args: [address],
30006
30005
  chainId
30007
30006
  }));
30008
- const readContractsResult = (0, import_wagmi15.useReadContracts)({
30007
+ const readContractsResult = (0, import_wagmi17.useReadContracts)({
30009
30008
  contracts: tokenContracts,
30010
30009
  query: {
30011
30010
  enabled: !!address && COMMON_TOKENS.length > 0
@@ -30086,7 +30085,7 @@ function useAssets(address) {
30086
30085
  }
30087
30086
  function useTokenInfo(tokenAddress) {
30088
30087
  const chainId = requireActiveChainId();
30089
- const readContractsResult = (0, import_wagmi15.useReadContracts)({
30088
+ const readContractsResult = (0, import_wagmi17.useReadContracts)({
30090
30089
  contracts: [
30091
30090
  { address: tokenAddress, abi: import_viem23.erc20Abi, functionName: "name", chainId },
30092
30091
  { address: tokenAddress, abi: import_viem23.erc20Abi, functionName: "symbol", chainId },
@@ -30117,7 +30116,7 @@ function useTokenBalance(tokenAddress, userAddress) {
30117
30116
  data: balance,
30118
30117
  isLoading,
30119
30118
  refetch
30120
- } = (0, import_wagmi15.useReadContract)({
30119
+ } = (0, import_wagmi17.useReadContract)({
30121
30120
  address: tokenAddress,
30122
30121
  abi: import_viem23.erc20Abi,
30123
30122
  functionName: "balanceOf",