@embarkai/ui-kit 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -877,6 +877,7 @@ var init_useLayoutDataStore = __esm({
877
877
  transitionPageHeight: DEFAULT_MAIN_MENU_HEIGHT,
878
878
  settingsNotifications: [],
879
879
  isWalletLinking: false,
880
+ pendingWalletLogin: null,
880
881
  setPageParams: (pageOptions) => set({ pageParams: pageOptions }),
881
882
  setPage: (page) => set((prev) => ({
882
883
  page,
@@ -898,7 +899,8 @@ var init_useLayoutDataStore = __esm({
898
899
  const filtered = prev.settingsNotifications.filter((n) => n.id !== notification.id);
899
900
  return { settingsNotifications: filtered };
900
901
  }),
901
- setIsWalletLinking: (isWalletLinking) => set({ isWalletLinking })
902
+ setIsWalletLinking: (isWalletLinking) => set({ isWalletLinking }),
903
+ setPendingWalletLogin: (pendingWalletLogin) => set({ pendingWalletLogin })
902
904
  }));
903
905
  }
904
906
  });
@@ -1552,7 +1554,7 @@ var init_deploy_account = __esm({
1552
1554
 
1553
1555
  // src/internal/clients/account/register-smart-account-address.ts
1554
1556
  async function registerSmartAccountAddress(chainId, smartAccountAddress, factoryAddress) {
1555
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
1557
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
1556
1558
  if (!accessToken) {
1557
1559
  console.warn("[Account] No access token available for Smart Account registration");
1558
1560
  return { success: true, chainId, smartAccountAddress, alreadySet: false };
@@ -1597,7 +1599,7 @@ async function registerSmartAccountAddress(chainId, smartAccountAddress, factory
1597
1599
  }
1598
1600
  }
1599
1601
  async function getAllSmartAccounts() {
1600
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
1602
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
1601
1603
  if (!accessToken) {
1602
1604
  console.warn("[Account] No access token available");
1603
1605
  return [];
@@ -1624,7 +1626,7 @@ async function getAllSmartAccounts() {
1624
1626
  }
1625
1627
  }
1626
1628
  async function getSmartAccountForChain(chainId) {
1627
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
1629
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
1628
1630
  if (!accessToken) {
1629
1631
  console.warn("[Account] No access token available");
1630
1632
  return null;
@@ -2174,7 +2176,7 @@ var init_httpClient = __esm({
2174
2176
  ...headers
2175
2177
  };
2176
2178
  if (requireAuth) {
2177
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
2179
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
2178
2180
  if (accessToken) {
2179
2181
  requestHeaders["Authorization"] = `Bearer ${accessToken}`;
2180
2182
  }
@@ -2191,9 +2193,9 @@ var init_httpClient = __esm({
2191
2193
  try {
2192
2194
  const response = await fetch(url, requestConfig);
2193
2195
  if (response.status === 401 && requireAuth) {
2194
- const refreshSuccess = await import_auth18.jwtTokenManager.refreshAccessToken();
2196
+ const refreshSuccess = await import_auth19.jwtTokenManager.refreshAccessToken();
2195
2197
  if (refreshSuccess) {
2196
- const newAccessToken = import_auth18.jwtTokenManager.getAccessToken();
2198
+ const newAccessToken = import_auth19.jwtTokenManager.getAccessToken();
2197
2199
  if (newAccessToken) {
2198
2200
  requestHeaders["Authorization"] = `Bearer ${newAccessToken}`;
2199
2201
  requestConfig.headers = requestHeaders;
@@ -2568,6 +2570,8 @@ function useAutoConnect() {
2568
2570
  }
2569
2571
  } catch (e) {
2570
2572
  if (e?.code === "KEYSHARE_RECOVERY_NEEDED") {
2573
+ setSession(null);
2574
+ setAddress(null);
2571
2575
  setRecoveryUserId(userId);
2572
2576
  setError(null);
2573
2577
  setStatus("recovery_needed");
@@ -3973,7 +3977,7 @@ function PassKeyStep(props) {
3973
3977
  setPasskeyStatus("checking available passkeys...");
3974
3978
  setIsLoading(true);
3975
3979
  try {
3976
- import_auth18.jwtTokenManager.clearTokens();
3980
+ import_auth19.jwtTokenManager.clearTokens();
3977
3981
  setPasskeyStatus("authenticating with passkey...");
3978
3982
  const result = await authenticateWithPasskey(
3979
3983
  void 0,
@@ -4463,8 +4467,8 @@ function Social(props) {
4463
4467
  const iframeManager = getIframeManager2();
4464
4468
  const finalizeSocialLogin = async (rawLoginResponse, providerKey, userData) => {
4465
4469
  let loginResponse2 = await normalizeSocialLoginResponse(rawLoginResponse, providerKey, userData);
4466
- const existingAccessToken = import_auth18.jwtTokenManager.getAccessToken();
4467
- const existingRefreshToken = import_auth18.jwtTokenManager.getRefreshToken();
4470
+ const existingAccessToken = import_auth19.jwtTokenManager.getAccessToken();
4471
+ const existingRefreshToken = import_auth19.jwtTokenManager.getRefreshToken();
4468
4472
  if (existingAccessToken && existingRefreshToken && !loginResponse2.accessToken) {
4469
4473
  console.log("[AuthModal] Using tokens already stored by iframe-manager");
4470
4474
  loginResponse2 = {
@@ -4493,7 +4497,7 @@ function Social(props) {
4493
4497
  setIsLoading(false);
4494
4498
  return;
4495
4499
  }
4496
- await import_auth18.jwtTokenManager.clearTokens();
4500
+ await import_auth19.jwtTokenManager.clearTokens();
4497
4501
  if (!loginResponse2.accessToken || !loginResponse2.refreshToken) {
4498
4502
  console.warn(
4499
4503
  "[AuthModal] Authentication tokens were not issued; continuing with cookie-based session only."
@@ -4502,7 +4506,7 @@ function Social(props) {
4502
4506
  let tokensPersisted = false;
4503
4507
  const persistTokensIfAvailable = async () => {
4504
4508
  if (!tokensPersisted && loginResponse2.accessToken && loginResponse2.refreshToken) {
4505
- await import_auth18.jwtTokenManager.setTokens(loginResponse2);
4509
+ await import_auth19.jwtTokenManager.setTokens(loginResponse2);
4506
4510
  tokensPersisted = true;
4507
4511
  }
4508
4512
  };
@@ -5015,7 +5019,7 @@ function useAuthMenuHandlers() {
5015
5019
  const iframeManager = getIframeManager2();
5016
5020
  await iframeManager.authenticate(userId, loginResponse.avatar, loginResponse.displayName);
5017
5021
  if (loginResponse.accessToken && loginResponse.refreshToken) {
5018
- await import_auth18.jwtTokenManager.setTokens(loginResponse);
5022
+ await import_auth19.jwtTokenManager.setTokens(loginResponse);
5019
5023
  } else {
5020
5024
  console.warn("[ConnectWalletButton] Login response missing tokens; skipping jwtTokenManager.setTokens");
5021
5025
  }
@@ -5073,6 +5077,8 @@ function useAuthMenuHandlers() {
5073
5077
  console.warn("[AuthMenu] Keyshare recovery needed for user:", userId);
5074
5078
  pendingLoginResponseRef.current = null;
5075
5079
  setError(null);
5080
+ setSession(null);
5081
+ setAddress(null);
5076
5082
  setRecoveryUserId(userId);
5077
5083
  setStatus("recovery_needed");
5078
5084
  setTimeout(() => {
@@ -5080,7 +5086,7 @@ function useAuthMenuHandlers() {
5080
5086
  }, 100);
5081
5087
  } else {
5082
5088
  pendingLoginResponseRef.current = null;
5083
- await import_auth18.jwtTokenManager.clearTokens();
5089
+ await import_auth19.jwtTokenManager.clearTokens();
5084
5090
  setStatus("error");
5085
5091
  setError(error?.message || String(error));
5086
5092
  setAlert({
@@ -5482,6 +5488,7 @@ var init_AuthMenu = __esm({
5482
5488
  init_SessionContext();
5483
5489
  import_lucide_react8 = require("lucide-react");
5484
5490
  import_react17 = require("react");
5491
+ init_auth();
5485
5492
  init_constants();
5486
5493
  init_useLayoutDataStore();
5487
5494
  init_useLayoutStore();
@@ -5499,8 +5506,20 @@ var init_AuthMenu = __esm({
5499
5506
  const isIframeReady = useSession((st) => st.isIframeReady);
5500
5507
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
5501
5508
  const setTransitionPageHeight = useLayoutDataStore((st) => st.setTransitionPageHeight);
5509
+ const pendingWalletLogin = useLayoutDataStore((st) => st.pendingWalletLogin);
5510
+ const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
5502
5511
  const { step, alert: alert2, setStep, setPasskeyStatus, setEmail, setAlert } = useAuthStore();
5503
5512
  const { pendingLoginResponseRef, onAuthSuccess, goBackToSignIn } = useAuthMenuHandlers();
5513
+ (0, import_react17.useEffect)(() => {
5514
+ if (!pendingWalletLogin) return;
5515
+ const loginResponse = pendingWalletLogin;
5516
+ setPendingWalletLogin(null);
5517
+ console.log("[AuthMenu] Processing wallet login response:", loginResponse);
5518
+ import_auth19.jwtTokenManager.clearTokens().then(() => {
5519
+ pendingLoginResponseRef.current = loginResponse;
5520
+ onAuthSuccess();
5521
+ });
5522
+ }, [pendingWalletLogin]);
5504
5523
  (0, import_react17.useEffect)(() => {
5505
5524
  setTransitionPageHeight(DEFAULT_AUTH_MENU_HEIGHT);
5506
5525
  return () => {
@@ -6048,7 +6067,7 @@ var init_queryKeys = __esm({
6048
6067
 
6049
6068
  // src/internal/components/BuyMenu/binance/api.ts
6050
6069
  async function getLumiaNetworkQuery() {
6051
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6070
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6052
6071
  if (!accessToken) {
6053
6072
  throw new Error("Access token is not available");
6054
6073
  }
@@ -6059,7 +6078,7 @@ async function getLumiaNetworkQuery() {
6059
6078
  return await iframeManager.sendMessage("BINANCE_GET_LUMIA_NETWORK_QUERY", { accessToken });
6060
6079
  }
6061
6080
  async function getPaymentMethodsQuery(payload) {
6062
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6081
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6063
6082
  if (!accessToken) {
6064
6083
  throw new Error("Access token is not available");
6065
6084
  }
@@ -6073,7 +6092,7 @@ async function getPaymentMethodsQuery(payload) {
6073
6092
  });
6074
6093
  }
6075
6094
  async function getQuoteQuery(payload) {
6076
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6095
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6077
6096
  if (!accessToken) {
6078
6097
  throw new Error("Access token is not available");
6079
6098
  }
@@ -6087,7 +6106,7 @@ async function getQuoteQuery(payload) {
6087
6106
  });
6088
6107
  }
6089
6108
  async function createPreorderMutation(payload) {
6090
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6109
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6091
6110
  if (!accessToken) {
6092
6111
  throw new Error("Access token is not available");
6093
6112
  }
@@ -6389,7 +6408,7 @@ var init_binance = __esm({
6389
6408
 
6390
6409
  // src/internal/components/BuyMenu/rampnow/api.ts
6391
6410
  async function getRampnowConfigQuery() {
6392
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6411
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6393
6412
  if (!accessToken) {
6394
6413
  throw new Error("Access token is not available");
6395
6414
  }
@@ -6400,7 +6419,7 @@ async function getRampnowConfigQuery() {
6400
6419
  return await iframeManager.sendMessage("RAMPNOW_GET_CONFIG", { accessToken });
6401
6420
  }
6402
6421
  async function getRampOrderQuoteQuery(payload) {
6403
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
6422
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
6404
6423
  if (!accessToken) {
6405
6424
  throw new Error("Access token is not available");
6406
6425
  }
@@ -7649,9 +7668,9 @@ __export(passkey_exports2, {
7649
7668
  linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn
7650
7669
  });
7651
7670
  async function completePasskeyLinking(payload) {
7652
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
7671
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
7653
7672
  if (!hasValidToken) throw new Error("No authentication token available");
7654
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/complete`, {
7673
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/complete`, {
7655
7674
  method: "POST",
7656
7675
  body: JSON.stringify(payload)
7657
7676
  });
@@ -7661,9 +7680,9 @@ async function completePasskeyLinking(payload) {
7661
7680
  }
7662
7681
  }
7663
7682
  async function beginPasskeyLinking() {
7664
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
7683
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
7665
7684
  if (!hasValidToken) throw new Error("No authentication token available");
7666
- let res = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/begin`, { method: "POST" });
7685
+ let res = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/begin`, { method: "POST" });
7667
7686
  if (res.ok) {
7668
7687
  const begin2 = await res.json();
7669
7688
  const options2 = {
@@ -7678,7 +7697,7 @@ async function beginPasskeyLinking() {
7678
7697
  };
7679
7698
  return { challengeId: begin2.challengeId, options: options2 };
7680
7699
  }
7681
- res = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/options`, { method: "GET" });
7700
+ res = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/options`, { method: "GET" });
7682
7701
  if (!res.ok) throw new Error("Failed to get passkey linking options");
7683
7702
  const begin = await res.json();
7684
7703
  const options = {
@@ -7697,7 +7716,7 @@ async function linkPasskeyWithWebAuthn(optionsOverride) {
7697
7716
  if (!("credentials" in navigator) || !("create" in navigator.credentials)) {
7698
7717
  throw new Error("WebAuthn not supported in this browser");
7699
7718
  }
7700
- const userId = import_auth18.jwtTokenManager.getUserId();
7719
+ const userId = import_auth19.jwtTokenManager.getUserId();
7701
7720
  if (!userId) throw new Error("No authenticated user");
7702
7721
  let challengeId = null;
7703
7722
  let publicKeyOptions = null;
@@ -7999,7 +8018,8 @@ function useCreateBackup() {
7999
8018
  setIsDialogForced(true);
8000
8019
  }
8001
8020
  }, [hasServerVault, setIsDialogForced, setMethod]);
8002
- const passportUserId = session?.mpcUserId || "";
8021
+ const recoveryUserId = useSession((st) => st.recoveryUserId);
8022
+ const passportUserId = session?.mpcUserId || recoveryUserId || "";
8003
8023
  const onBackupSuccess = () => console.log("[ConnectWalletButton] Backup created successfully");
8004
8024
  const { mutate: createPasswordBackup, isPending: isPasswordBackupCreating } = (0, import_react_query10.useMutation)({
8005
8025
  mutationFn: async () => {
@@ -9709,9 +9729,9 @@ var init_LanguagesMenu2 = __esm({
9709
9729
 
9710
9730
  // src/internal/auth/providers/common.ts
9711
9731
  async function getLinkedProviders() {
9712
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
9732
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
9713
9733
  if (!hasValidToken) throw new Error("No authentication token available");
9714
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/providers`, { method: "GET" });
9734
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/providers`, { method: "GET" });
9715
9735
  if (!response.ok) {
9716
9736
  const errorData = await response.json().catch(() => ({}));
9717
9737
  throw new Error(errorData.message || `Failed to fetch providers: ${response.statusText}`);
@@ -9720,11 +9740,11 @@ async function getLinkedProviders() {
9720
9740
  return data.providers;
9721
9741
  }
9722
9742
  async function unlinkProvider(providerType, externalId) {
9723
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
9743
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
9724
9744
  if (!hasValidToken) throw new Error("No authentication token available");
9725
9745
  let url = `${getTssUrl3()}/api/auth/unlink/${providerType}`;
9726
9746
  if (externalId) url += `?externalId=${encodeURIComponent(externalId)}`;
9727
- const response = await (0, import_auth18.authenticatedFetch)(url, { method: "DELETE" });
9747
+ const response = await (0, import_auth19.authenticatedFetch)(url, { method: "DELETE" });
9728
9748
  if (!response.ok) {
9729
9749
  const errorData = await response.json().catch(() => ({}));
9730
9750
  throw new Error(errorData.message || `Failed to unlink provider: ${response.statusText}`);
@@ -9732,12 +9752,12 @@ async function unlinkProvider(providerType, externalId) {
9732
9752
  try {
9733
9753
  const data = await response.json();
9734
9754
  if (data?.accessToken && data?.refreshToken && data?.expiresIn) {
9735
- import_auth18.jwtTokenManager.setTokens({
9755
+ import_auth19.jwtTokenManager.setTokens({
9736
9756
  accessToken: data.accessToken,
9737
9757
  refreshToken: data.refreshToken,
9738
- userId: import_auth18.jwtTokenManager.getUserId() || "",
9758
+ userId: import_auth19.jwtTokenManager.getUserId() || "",
9739
9759
  expiresIn: data.expiresIn,
9740
- hasKeyshare: import_auth18.jwtTokenManager.getHasKeyshare() ?? false
9760
+ hasKeyshare: import_auth19.jwtTokenManager.getHasKeyshare() ?? false
9741
9761
  });
9742
9762
  }
9743
9763
  } catch {
@@ -9834,7 +9854,7 @@ async function getLinkProfilesData() {
9834
9854
  });
9835
9855
  let avatar = null;
9836
9856
  try {
9837
- avatar = import_auth18.jwtTokenManager.getAvatar() || null;
9857
+ avatar = import_auth19.jwtTokenManager.getAvatar() || null;
9838
9858
  } catch {
9839
9859
  avatar = null;
9840
9860
  }
@@ -10011,9 +10031,9 @@ var init_EmailForm = __esm({
10011
10031
 
10012
10032
  // src/internal/auth/providers/email.ts
10013
10033
  async function sendEmailLinkCode(email) {
10014
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
10034
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
10015
10035
  if (!hasValidToken) throw new Error("No authentication token available");
10016
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/send-code`, {
10036
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/send-code`, {
10017
10037
  method: "POST",
10018
10038
  body: JSON.stringify({ email })
10019
10039
  });
@@ -10023,9 +10043,9 @@ async function sendEmailLinkCode(email) {
10023
10043
  }
10024
10044
  }
10025
10045
  async function verifyEmailLinkCode(email, code) {
10026
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
10046
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
10027
10047
  if (!hasValidToken) throw new Error("No authentication token available");
10028
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
10048
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
10029
10049
  method: "POST",
10030
10050
  credentials: "include",
10031
10051
  body: JSON.stringify({ email, code })
@@ -10297,7 +10317,7 @@ var init_AddProvider = __esm({
10297
10317
 
10298
10318
  // src/internal/components/ManageWalletMenu/EmailNotConnectedWarning.tsx
10299
10319
  function EmailNotConnectedWarning() {
10300
- const providers = import_auth18.jwtTokenManager.getProviders();
10320
+ const providers = import_auth19.jwtTokenManager.getProviders();
10301
10321
  const hasEmail = providers.includes("email");
10302
10322
  const { t } = useT();
10303
10323
  const config = useProviderConfig().config;
@@ -10358,11 +10378,11 @@ function useLinkSocial() {
10358
10378
  mode: "link"
10359
10379
  };
10360
10380
  try {
10361
- await (0, import_auth18.ensureValidToken)();
10381
+ await (0, import_auth19.ensureValidToken)();
10362
10382
  } catch (tokenError) {
10363
10383
  console.warn("[ManageWallet] ensureValidToken failed before linking", tokenError);
10364
10384
  }
10365
- const accessToken = import_auth18.jwtTokenManager.getAccessToken();
10385
+ const accessToken = import_auth19.jwtTokenManager.getAccessToken();
10366
10386
  if (accessToken) {
10367
10387
  authConfig.token = accessToken;
10368
10388
  }
@@ -10429,7 +10449,7 @@ var init_useLinkSocial = __esm({
10429
10449
 
10430
10450
  // src/internal/auth/providers/telegram.ts
10431
10451
  async function linkTelegram(telegramData) {
10432
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
10452
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
10433
10453
  if (!hasValidToken) throw new Error("No authentication token available");
10434
10454
  const formattedData = {
10435
10455
  id: telegramData.id,
@@ -10440,7 +10460,7 @@ async function linkTelegram(telegramData) {
10440
10460
  if (telegramData.last_name) formattedData.last_name = telegramData.last_name;
10441
10461
  if (telegramData.username) formattedData.username = telegramData.username;
10442
10462
  if (telegramData.photo_url) formattedData.photo_url = telegramData.photo_url;
10443
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/telegram`, {
10463
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/telegram`, {
10444
10464
  method: "POST",
10445
10465
  body: JSON.stringify(formattedData)
10446
10466
  });
@@ -12592,8 +12612,8 @@ function SecurityMenu() {
12592
12612
  const { t } = useT();
12593
12613
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
12594
12614
  const setPage = useLayoutDataStore((st) => st.setPage);
12595
- const userId = import_auth18.jwtTokenManager.getUserId();
12596
- const serverHasKeyshare = import_auth18.jwtTokenManager.getHasKeyshare() ?? false;
12615
+ const userId = import_auth19.jwtTokenManager.getUserId();
12616
+ const serverHasKeyshare = import_auth19.jwtTokenManager.getHasKeyshare() ?? false;
12597
12617
  const [isRemoving, setIsRemoving] = (0, import_react49.useState)(false);
12598
12618
  const [appToRemove, setAppToRemove] = (0, import_react49.useState)(null);
12599
12619
  const {
@@ -15503,7 +15523,7 @@ var init_usePageMapper = __esm({
15503
15523
  function useSettingsNotifications() {
15504
15524
  const address = useSession((st) => st.address);
15505
15525
  const setSettingsNotifications = useLayoutDataStore((st) => st.setSettingsNotifications);
15506
- const providers = import_auth18.jwtTokenManager.getProviders();
15526
+ const providers = import_auth19.jwtTokenManager.getProviders();
15507
15527
  const hasEmail = providers.includes("email");
15508
15528
  const { data: userProfile = null } = (0, import_react_query38.useQuery)({
15509
15529
  retry: false,
@@ -15553,7 +15573,7 @@ var init_package = __esm({
15553
15573
  "package.json"() {
15554
15574
  package_default = {
15555
15575
  name: "@embarkai/ui-kit",
15556
- version: "0.2.7",
15576
+ version: "0.3.0",
15557
15577
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
15558
15578
  type: "module",
15559
15579
  main: "./dist/index.cjs",
@@ -15591,51 +15611,52 @@ var init_package = __esm({
15591
15611
  },
15592
15612
  peerDependencies: {
15593
15613
  "@tanstack/react-query": ">=5.0.0",
15614
+ i18next: "^25.8.0",
15594
15615
  react: ">=18",
15595
15616
  "react-dom": ">=18",
15596
- "tailwind-merge": ">=2.2.0",
15597
- i18next: "^25.8.0",
15598
- "react-i18next": "^16.5.3"
15617
+ "react-i18next": "^16.5.3",
15618
+ "tailwind-merge": ">=2.2.0"
15599
15619
  },
15600
15620
  dependencies: {
15601
- "@radix-ui/react-slot": ">=1.2.4",
15621
+ "@embarkai/core": "workspace:*",
15602
15622
  "@radix-ui/react-checkbox": ">=1.3.3",
15603
- "@radix-ui/react-select": ">=2.2.6",
15604
15623
  "@radix-ui/react-dialog": ">=1.1.15",
15605
- "@embarkai/core": "workspace:*",
15624
+ "@radix-ui/react-select": ">=2.2.6",
15625
+ "@radix-ui/react-slot": ">=1.2.4",
15606
15626
  "@rainbow-me/rainbowkit": "^2.2.10",
15607
15627
  "@sentry/browser": "^10.22.0",
15608
15628
  "class-variance-authority": "^0.7.0",
15609
- "lodash-es": "^4.17.21",
15610
15629
  clsx: "^2.1.1",
15630
+ dayjs: "^1.11.9",
15611
15631
  "dkls23-wasm": "^0.1.0",
15632
+ "framer-motion": "^12.23.24",
15633
+ "lodash-es": "^4.17.21",
15612
15634
  "lucide-react": "^0.454.0",
15613
15635
  qrcode: "^1.5.0",
15614
- zustand: "^5.0.8",
15615
15636
  viem: "^2.38.0",
15616
15637
  wagmi: "^2.17.5",
15617
- dayjs: "^1.11.9",
15618
- "framer-motion": "^12.23.24"
15638
+ zustand: "^5.0.8"
15619
15639
  },
15620
15640
  devDependencies: {
15621
15641
  "@tailwindcss/typography": "^0.5.16",
15622
15642
  "@tanstack/react-query": "^5.90.2",
15643
+ "@types/lodash-es": "^4.17.12",
15623
15644
  "@types/qrcode": "^1.5.0",
15624
15645
  "@types/react": "^18.3.3",
15625
15646
  "@types/react-dom": "^18.3.0",
15626
15647
  autoprefixer: "^10.4.20",
15627
15648
  dotenv: "^17.2.3",
15649
+ i18next: "^25.8.0",
15628
15650
  postcss: "^8.4.47",
15629
15651
  react: "^18.3.1",
15630
15652
  "react-dom": "^18.3.1",
15653
+ "react-i18next": "^16.5.3",
15631
15654
  "tailwind-merge": "^2.2.0",
15632
- "@types/lodash-es": "^4.17.12",
15633
15655
  tailwindcss: "^3.4.10",
15634
15656
  tsup: "^8.5.0",
15635
15657
  typescript: "^5.4.5",
15636
15658
  vite: "^5.0.0",
15637
- i18next: "^25.8.0",
15638
- "react-i18next": "^16.5.3"
15659
+ vitest: "^4.0.18"
15639
15660
  },
15640
15661
  repository: {
15641
15662
  type: "git",
@@ -15665,7 +15686,7 @@ function Footer() {
15665
15686
  setError(null);
15666
15687
  setStatus("disconnecting");
15667
15688
  setIsLoading(true);
15668
- const userId = import_auth18.jwtTokenManager.getUserId() || null;
15689
+ const userId = import_auth19.jwtTokenManager.getUserId() || null;
15669
15690
  const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
15670
15691
  await logout2();
15671
15692
  return { disconnectedUserId: userId, disconnectAddress };
@@ -15802,8 +15823,8 @@ function Header() {
15802
15823
  queryKey: [QUERY_KEYS.userProfile, address],
15803
15824
  queryFn: getUserProfile
15804
15825
  });
15805
- const avatar = profile?.avatar || import_auth18.jwtTokenManager.getAvatar();
15806
- const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth18.jwtTokenManager.getDisplayName();
15826
+ const avatar = profile?.avatar || import_auth19.jwtTokenManager.getAvatar();
15827
+ const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth19.jwtTokenManager.getDisplayName();
15807
15828
  const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ (0, import_jsx_runtime89.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_runtime89.jsx)("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
15808
15829
  return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
15809
15830
  "div",
@@ -16237,10 +16258,23 @@ var init_TssManager = __esm({
16237
16258
  });
16238
16259
 
16239
16260
  // src/internal/auth/providers/wallet.ts
16261
+ async function walletLogin(walletData) {
16262
+ const response = await fetch(addProjectIdToUrl(`${getTssUrl3()}/api/auth/wallet/login`), {
16263
+ method: "POST",
16264
+ headers: { "Content-Type": "application/json" },
16265
+ credentials: "include",
16266
+ body: JSON.stringify(walletData)
16267
+ });
16268
+ if (!response.ok) {
16269
+ const errorData = await response.json().catch(() => ({}));
16270
+ throw new Error(errorData.message || `Wallet login failed: ${response.statusText}`);
16271
+ }
16272
+ return response.json();
16273
+ }
16240
16274
  async function linkWallet(walletData) {
16241
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
16275
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
16242
16276
  if (!hasValidToken) throw new Error("No authentication token available");
16243
- const response = await (0, import_auth18.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/wallet`, {
16277
+ const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/wallet`, {
16244
16278
  method: "POST",
16245
16279
  body: JSON.stringify(walletData)
16246
16280
  });
@@ -16250,9 +16284,9 @@ async function linkWallet(walletData) {
16250
16284
  }
16251
16285
  }
16252
16286
  async function unlinkWallet(address) {
16253
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
16287
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
16254
16288
  if (!hasValidToken) throw new Error("No authentication token available");
16255
- const response = await (0, import_auth18.authenticatedFetch)(
16289
+ const response = await (0, import_auth19.authenticatedFetch)(
16256
16290
  `${getTssUrl3()}/api/auth/unlink/wallet?address=${encodeURIComponent(address)}`,
16257
16291
  {
16258
16292
  method: "DELETE"
@@ -16289,9 +16323,23 @@ Timestamp: ${timestamp}
16289
16323
 
16290
16324
  Sign this message to link your wallet to ${projectName} Wallet`;
16291
16325
  }
16326
+ function createLoginMessage(address, projectName) {
16327
+ const nonce = crypto.randomUUID();
16328
+ const timestamp = Date.now();
16329
+ return [
16330
+ `${projectName} Wallet Login`,
16331
+ "",
16332
+ `Address: ${address}`,
16333
+ `Nonce: ${nonce}`,
16334
+ `Timestamp: ${timestamp}`,
16335
+ "",
16336
+ `Sign this message to login your wallet to ${projectName}`
16337
+ ].join("\n");
16338
+ }
16292
16339
  var METADATA_API_URL, METADATA_CACHE_TTL, metadataCache;
16293
16340
  var init_wallet = __esm({
16294
16341
  "src/internal/auth/providers/wallet.ts"() {
16342
+ init_projectId();
16295
16343
  init_auth();
16296
16344
  init_types();
16297
16345
  METADATA_API_URL = "https://dashboard.lumiapassport.com/api/public/project";
@@ -16351,6 +16399,7 @@ function WalletConnectHandler() {
16351
16399
  const walletMode = providerConfig?.wallet?.mode || "linked";
16352
16400
  const projectId = providerConfig?.projectId;
16353
16401
  const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
16402
+ const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
16354
16403
  const onLinkingComplete = (0, import_react63.useCallback)(
16355
16404
  async (success) => {
16356
16405
  setIsWalletLinking(false);
@@ -16439,12 +16488,14 @@ function WalletConnectHandler() {
16439
16488
  if (isWalletLinking) {
16440
16489
  const timeout = setTimeout(() => {
16441
16490
  console.warn("[WalletConnectHandler] Wallet linking timed out, resetting state");
16491
+ disconnect();
16442
16492
  setIsWalletLinking(false);
16443
16493
  setHasStartedLinking(false);
16444
16494
  }, 12e4);
16445
16495
  return () => clearTimeout(timeout);
16446
16496
  }
16447
- }, [isWalletLinking, setIsWalletLinking]);
16497
+ }, [isWalletLinking, setIsWalletLinking, disconnect]);
16498
+ const isAuthFlow = !passportWalletAddress;
16448
16499
  const { mutate: handleWalletSign, isPending: isWalletSigning } = (0, import_react_query41.useMutation)({
16449
16500
  mutationFn: async (payload) => {
16450
16501
  const { chainId, signingWalletAddress } = payload;
@@ -16463,24 +16514,45 @@ function WalletConnectHandler() {
16463
16514
  }
16464
16515
  setLinkIsLoading(true);
16465
16516
  const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
16466
- const message = createSignatureMessage(signingWalletAddress, projectName);
16467
- const signature = await signMessageAsync({ message, account: signingWalletAddress });
16517
+ const message = isAuthFlow ? createLoginMessage(signingWalletAddress, projectName) : createSignatureMessage(signingWalletAddress, projectName);
16518
+ const signature = await Promise.race([
16519
+ signMessageAsync({ message, account: signingWalletAddress }),
16520
+ new Promise(
16521
+ (_, reject) => setTimeout(() => reject(new Error("Signature request timed out. Please try again.")), 6e4)
16522
+ )
16523
+ ]);
16468
16524
  if (!signature) {
16469
16525
  throw new Error("Failed to get signature");
16470
16526
  }
16471
16527
  const walletName = connector?.name || "Unknown Wallet";
16472
16528
  const walletType = connector?.id || "unknown";
16473
- return await linkWallet({
16474
- // chainId: chain.id,
16529
+ const walletData = {
16475
16530
  chainId,
16476
16531
  address: signingWalletAddress,
16477
16532
  signature,
16478
16533
  message,
16479
16534
  walletName,
16480
16535
  walletType
16481
- });
16536
+ };
16537
+ if (isAuthFlow) {
16538
+ const loginResponse = await walletLogin(walletData);
16539
+ return loginResponse;
16540
+ } else {
16541
+ await linkWallet(walletData);
16542
+ return void 0;
16543
+ }
16482
16544
  },
16483
- onSuccess: () => {
16545
+ onSuccess: (data) => {
16546
+ if (isAuthFlow && data) {
16547
+ console.log("[WalletConnectHandler] Wallet login successful, passing to AuthMenu");
16548
+ disconnect();
16549
+ setPendingWalletLogin(data);
16550
+ setIsWalletLinking(false);
16551
+ setHasStartedLinking(false);
16552
+ setLinkIsLoading(false);
16553
+ setPage("auth" /* AUTH */);
16554
+ return;
16555
+ }
16484
16556
  const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
16485
16557
  if (shouldKeepConnected && walletAddress && chain?.id && connector) {
16486
16558
  setExternalWallet({
@@ -16501,7 +16573,7 @@ function WalletConnectHandler() {
16501
16573
  onLinkingComplete(false);
16502
16574
  setHasStartedLinking(false);
16503
16575
  setLinkIsLoading(false);
16504
- const errorMsg = err?.message || "Failed to link wallet";
16576
+ const errorMsg = err?.message || (isAuthFlow ? "Wallet login failed" : "Failed to link wallet");
16505
16577
  if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
16506
16578
  if (passportWalletAddress) {
16507
16579
  setManageWalletLinkError("Signature request was cancelled");
@@ -17548,7 +17620,7 @@ var init_vaultClient = __esm({
17548
17620
 
17549
17621
  // src/internal/auth/keyshare.ts
17550
17622
  async function checkKeyshareStatusWithSync(userId) {
17551
- const serverHasKeyshare = await (0, import_auth18.syncKeyshareStatus)();
17623
+ const serverHasKeyshare = await (0, import_auth19.syncKeyshareStatus)();
17552
17624
  return checkKeyshareStatus(userId, serverHasKeyshare);
17553
17625
  }
17554
17626
  async function checkKeyshareStatus(userId, serverHasKeyshare) {
@@ -17582,7 +17654,7 @@ async function ensureKeyshareForNewUser(userId, onProgress) {
17582
17654
  onProgress?.("Setting up secure key management...");
17583
17655
  const result = await ensureDkgAndGetOwner(userId);
17584
17656
  if (!result.ownerAddress) throw new Error("DKG completed but no owner address received");
17585
- await (0, import_auth18.syncKeyshareStatus)();
17657
+ await (0, import_auth19.syncKeyshareStatus)();
17586
17658
  onProgress?.("Key management setup complete");
17587
17659
  return { ownerAddress: result.ownerAddress };
17588
17660
  }
@@ -17667,7 +17739,7 @@ var init_keyshare = __esm({
17667
17739
 
17668
17740
  // src/internal/auth/providers/x.ts
17669
17741
  async function linkX() {
17670
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
17742
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
17671
17743
  if (!hasValidToken) throw new Error("No authentication token available");
17672
17744
  throw new Error('Use openSocialAuthPopup("x") to link X account');
17673
17745
  }
@@ -17675,10 +17747,10 @@ async function loginWithX() {
17675
17747
  throw new Error('Use openSocialAuthPopup("x") to login with X account');
17676
17748
  }
17677
17749
  async function unlinkX(externalId) {
17678
- const hasValidToken = await (0, import_auth18.ensureValidToken)();
17750
+ const hasValidToken = await (0, import_auth19.ensureValidToken)();
17679
17751
  if (!hasValidToken) throw new Error("No authentication token available");
17680
17752
  const url = externalId ? `${getTssUrl3()}/api/auth/unlink/x?externalId=${encodeURIComponent(externalId)}` : `${getTssUrl3()}/api/auth/unlink/x`;
17681
- const response = await (0, import_auth18.authenticatedFetch)(url, {
17753
+ const response = await (0, import_auth19.authenticatedFetch)(url, {
17682
17754
  method: "DELETE"
17683
17755
  });
17684
17756
  if (!response.ok) {
@@ -17709,9 +17781,9 @@ var init_providers = __esm({
17709
17781
  // src/internal/auth/index.ts
17710
17782
  var auth_exports = {};
17711
17783
  __export(auth_exports, {
17712
- JwtTokenManager: () => import_auth18.JwtTokenManager,
17784
+ JwtTokenManager: () => import_auth19.JwtTokenManager,
17713
17785
  authenticateWithPasskey: () => authenticateWithPasskey,
17714
- authenticatedFetch: () => import_auth18.authenticatedFetch,
17786
+ authenticatedFetch: () => import_auth19.authenticatedFetch,
17715
17787
  beginPasskeyAuthentication: () => beginPasskeyAuthentication,
17716
17788
  beginPasskeyLinking: () => beginPasskeyLinking,
17717
17789
  beginPasskeyRegistration: () => beginPasskeyRegistration,
@@ -17721,51 +17793,53 @@ __export(auth_exports, {
17721
17793
  completePasskeyAuthentication: () => completePasskeyAuthentication,
17722
17794
  completePasskeyLinking: () => completePasskeyLinking,
17723
17795
  completePasskeyRegistration: () => completePasskeyRegistration,
17724
- configureJwtModule: () => import_auth18.configureJwtModule,
17796
+ configureJwtModule: () => import_auth19.configureJwtModule,
17725
17797
  createInitialAuthState: () => createInitialAuthState,
17726
- createJwtTokenManager: () => import_auth18.createJwtTokenManager,
17798
+ createJwtTokenManager: () => import_auth19.createJwtTokenManager,
17799
+ createLoginMessage: () => createLoginMessage,
17727
17800
  createPasskeyHelpers: () => createPasskeyHelpers,
17728
17801
  createSignatureMessage: () => createSignatureMessage,
17729
17802
  deriveDemoPrivateKey: () => deriveDemoPrivateKey,
17730
17803
  ensureKeyshare: () => ensureKeyshare,
17731
- ensureValidToken: () => import_auth18.ensureValidToken,
17804
+ ensureValidToken: () => import_auth19.ensureValidToken,
17732
17805
  fetchProjectName: () => fetchProjectName,
17733
17806
  formatDate: () => formatDate,
17734
17807
  getKeyshareInfo: () => getKeyshareInfo,
17735
17808
  getLinkedProviders: () => getLinkedProviders,
17736
17809
  getProviderDisplayInfo: () => getProviderDisplayInfo,
17737
17810
  getTssUrl: () => getTssUrl3,
17738
- getValidTokens: () => import_auth18.getValidTokens,
17811
+ getValidTokens: () => import_auth19.getValidTokens,
17739
17812
  hasAvailablePasskeys: () => hasAvailablePasskeys,
17740
17813
  hideTelegramWidget: () => hideTelegramWidget,
17741
17814
  initTelegramWidget: () => initTelegramWidget,
17742
17815
  isWebAuthnSupported: () => isWebAuthnSupported,
17743
- jwtTokenManager: () => import_auth18.jwtTokenManager,
17816
+ jwtTokenManager: () => import_auth19.jwtTokenManager,
17744
17817
  linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn,
17745
17818
  linkTelegram: () => linkTelegram,
17746
17819
  linkWallet: () => linkWallet,
17747
17820
  linkX: () => linkX,
17748
- loginWithEmail: () => import_auth18.loginWithEmail,
17749
- loginWithTelegram: () => import_auth18.loginWithTelegram,
17750
- loginWithUserId: () => import_auth18.loginWithUserId,
17821
+ loginWithEmail: () => import_auth19.loginWithEmail,
17822
+ loginWithTelegram: () => import_auth19.loginWithTelegram,
17823
+ loginWithUserId: () => import_auth19.loginWithUserId,
17751
17824
  loginWithX: () => loginWithX,
17752
- logout: () => import_auth18.logout,
17825
+ logout: () => import_auth19.logout,
17753
17826
  mountTelegramLoginWidget: () => mountTelegramLoginWidget,
17754
17827
  registerPasskey: () => registerPasskey,
17755
17828
  resetWebAuthnFlags: () => resetWebAuthnFlags,
17756
17829
  sendEmailLinkCode: () => sendEmailLinkCode,
17757
17830
  showTelegramWidget: () => showTelegramWidget,
17758
- syncKeyshareStatus: () => import_auth18.syncKeyshareStatus,
17831
+ syncKeyshareStatus: () => import_auth19.syncKeyshareStatus,
17759
17832
  unlinkProvider: () => unlinkProvider,
17760
17833
  unlinkWallet: () => unlinkWallet,
17761
17834
  unlinkX: () => unlinkX,
17762
17835
  verifyEmailLinkCode: () => verifyEmailLinkCode,
17763
- verifyToken: () => import_auth18.verifyToken
17836
+ verifyToken: () => import_auth19.verifyToken,
17837
+ walletLogin: () => walletLogin
17764
17838
  });
17765
- var import_auth18, createInitialAuthState;
17839
+ var import_auth19, createInitialAuthState;
17766
17840
  var init_auth = __esm({
17767
17841
  "src/internal/auth/index.ts"() {
17768
- import_auth18 = require("@embarkai/core/auth");
17842
+ import_auth19 = require("@embarkai/core/auth");
17769
17843
  init_passkeyAuth();
17770
17844
  init_telegram();
17771
17845
  init_passkey();
@@ -17813,6 +17887,7 @@ var init_iframe_manager = __esm({
17813
17887
  this.iframe = null;
17814
17888
  this.channelToken = null;
17815
17889
  this.isReady = false;
17890
+ this.initPromise = null;
17816
17891
  // Message handling
17817
17892
  this.pendingRequests = /* @__PURE__ */ new Map();
17818
17893
  this.usedNonces = /* @__PURE__ */ new Set();
@@ -17850,9 +17925,13 @@ var init_iframe_manager = __esm({
17850
17925
  * Initialize iframe and wait for it to be ready
17851
17926
  */
17852
17927
  async initialize() {
17853
- if (this.iframe) {
17854
- return this.readyPromise;
17928
+ if (this.initPromise) {
17929
+ return this.initPromise;
17855
17930
  }
17931
+ this.initPromise = this.doInitialize();
17932
+ return this.initPromise;
17933
+ }
17934
+ async doInitialize() {
17856
17935
  this.iframe = document.createElement("iframe");
17857
17936
  let iframeUrl = this.iframeUrl;
17858
17937
  this.iframe.src = iframeUrl;
@@ -18122,9 +18201,15 @@ var init_iframe_manager = __esm({
18122
18201
  * Send secure message to iframe
18123
18202
  */
18124
18203
  async sendMessage(type, data) {
18204
+ if (this.initPromise && type !== "SDK_AUTH") {
18205
+ await this.initPromise;
18206
+ }
18125
18207
  if (!this.iframe || !this.iframe.contentWindow) {
18126
18208
  throw new Error("Iframe not initialized");
18127
18209
  }
18210
+ if (!this.channelToken && type !== "SDK_AUTH") {
18211
+ throw createAccountAbstractionError({ message: "SDK channel not established. Initialize iframe first." });
18212
+ }
18128
18213
  const messageId = this.generateMessageId();
18129
18214
  const nonce = this.generateNonce();
18130
18215
  const timestamp = Date.now();
@@ -18988,6 +19073,10 @@ var init_iframe_manager = __esm({
18988
19073
  this.iframe = null;
18989
19074
  this.isReady = false;
18990
19075
  this.channelToken = null;
19076
+ this.initPromise = null;
19077
+ this.readyPromise = new Promise((resolve) => {
19078
+ this.readyResolve = resolve;
19079
+ });
18991
19080
  this.log("[IframeManager] \u2705 Destroyed");
18992
19081
  }
18993
19082
  /**
@@ -19008,10 +19097,9 @@ var init_iframe_manager = __esm({
19008
19097
  });
19009
19098
 
19010
19099
  // src/config/rainbowkit.ts
19011
- var import_read13, import_rainbowkit2, import_wallets, import_chains, getProjectId, WALLET_MAP, createRainbowConfig, rainbowTheme;
19100
+ var import_rainbowkit2, import_wallets, import_chains, getProjectId, WALLET_MAP, createRainbowConfig, rainbowTheme;
19012
19101
  var init_rainbowkit = __esm({
19013
19102
  "src/config/rainbowkit.ts"() {
19014
- import_read13 = require("@embarkai/core/read");
19015
19103
  import_rainbowkit2 = require("@rainbow-me/rainbowkit");
19016
19104
  import_wallets = require("@rainbow-me/rainbowkit/wallets");
19017
19105
  import_chains = require("wagmi/chains");
@@ -19033,7 +19121,7 @@ var init_rainbowkit = __esm({
19033
19121
  const config = {
19034
19122
  appName: "EmbarkAI Wallet",
19035
19123
  projectId: getProjectId(opts.projectId),
19036
- chains: [import_read13.lumiaMainnetChain, import_read13.lumiaTestnetChain, import_chains.mainnet, import_chains.polygon, import_chains.bsc, import_chains.arbitrum, import_chains.optimism, import_chains.avalanche, import_chains.base, import_chains.zora],
19124
+ chains: [import_chains.mainnet, import_chains.polygon, import_chains.bsc, import_chains.arbitrum, import_chains.optimism, import_chains.avalanche, import_chains.base, import_chains.zora],
19037
19125
  ssr: false
19038
19126
  };
19039
19127
  if (opts.allowedWallets && opts.allowedWallets.length > 0) {
@@ -19312,17 +19400,17 @@ function buildTransport(urls) {
19312
19400
  retryCount: 0
19313
19401
  });
19314
19402
  }
19315
- var import_read14, import_viem17, import_wagmi5, wagmiConfig;
19403
+ var import_read13, import_viem17, import_wagmi5, wagmiConfig;
19316
19404
  var init_wagmi = __esm({
19317
19405
  "src/config/wagmi.ts"() {
19318
- import_read14 = require("@embarkai/core/read");
19406
+ import_read13 = require("@embarkai/core/read");
19319
19407
  import_viem17 = require("viem");
19320
19408
  import_wagmi5 = require("wagmi");
19321
19409
  wagmiConfig = (0, import_wagmi5.createConfig)({
19322
- chains: [import_read14.lumiaMainnetChain, import_read14.lumiaTestnetChain],
19410
+ chains: [import_read13.lumiaMainnetChain, import_read13.lumiaTestnetChain],
19323
19411
  transports: {
19324
- [import_read14.lumiaTestnetChain.id]: buildTransport(import_read14.lumiaTestnetChain.rpcUrls.default.http),
19325
- [import_read14.lumiaMainnetChain.id]: buildTransport(import_read14.lumiaMainnetChain.rpcUrls.default.http)
19412
+ [import_read13.lumiaTestnetChain.id]: buildTransport(import_read13.lumiaTestnetChain.rpcUrls.default.http),
19413
+ [import_read13.lumiaMainnetChain.id]: buildTransport(import_read13.lumiaMainnetChain.rpcUrls.default.http)
19326
19414
  }
19327
19415
  });
19328
19416
  }
@@ -19495,11 +19583,11 @@ function ConnectWalletButton(props) {
19495
19583
  queryKey: [QUERY_KEYS.userProfile, address],
19496
19584
  queryFn: getUserProfile
19497
19585
  });
19498
- const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth18.jwtTokenManager.getDisplayName();
19586
+ const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth19.jwtTokenManager.getDisplayName();
19499
19587
  const indicators = (0, import_react68.useMemo)(() => {
19500
19588
  const userId = session?.mpcUserId;
19501
19589
  if (!userId) return { server: false, local: false, backup: false };
19502
- const server = import_auth18.jwtTokenManager.getHasKeyshare() ?? false;
19590
+ const server = import_auth19.jwtTokenManager.getHasKeyshare() ?? false;
19503
19591
  const local = !!address;
19504
19592
  return { server, local, backup: hasServerVault };
19505
19593
  }, [session, address, hasServerVault]);
@@ -19796,7 +19884,7 @@ var init_LangToggle = __esm({
19796
19884
  // src/clients/bundler/getUserOperationByHash.ts
19797
19885
  async function getUserOperationByHash(userOpHash, chainId) {
19798
19886
  const targetChainId = chainId ?? requireActiveChainId();
19799
- const chainConfig = (0, import_read15.getChainConfig)(targetChainId);
19887
+ const chainConfig = (0, import_read14.getChainConfig)(targetChainId);
19800
19888
  if (!chainConfig) {
19801
19889
  throw new Error(`Chain ${targetChainId} is not supported`);
19802
19890
  }
@@ -19824,19 +19912,19 @@ async function getUserOperationByHash(userOpHash, chainId) {
19824
19912
  return null;
19825
19913
  }
19826
19914
  }
19827
- var import_core, import_read15;
19915
+ var import_core, import_read14;
19828
19916
  var init_getUserOperationByHash = __esm({
19829
19917
  "src/clients/bundler/getUserOperationByHash.ts"() {
19830
19918
  init_SessionContext();
19831
19919
  import_core = require("@embarkai/core");
19832
- import_read15 = require("@embarkai/core/read");
19920
+ import_read14 = require("@embarkai/core/read");
19833
19921
  }
19834
19922
  });
19835
19923
 
19836
19924
  // src/clients/bundler/getUserOperationReceipt.ts
19837
19925
  async function getUserOperationReceipt(userOpHash, chainId) {
19838
19926
  const targetChainId = chainId ?? requireActiveChainId();
19839
- const chainConfig = (0, import_read16.getChainConfig)(targetChainId);
19927
+ const chainConfig = (0, import_read15.getChainConfig)(targetChainId);
19840
19928
  if (!chainConfig) {
19841
19929
  throw new Error(`Chain ${targetChainId} is not supported`);
19842
19930
  }
@@ -19870,12 +19958,12 @@ async function getUserOperationReceipt(userOpHash, chainId) {
19870
19958
  return null;
19871
19959
  }
19872
19960
  }
19873
- var import_core2, import_read16;
19961
+ var import_core2, import_read15;
19874
19962
  var init_getUserOperationReceipt = __esm({
19875
19963
  "src/clients/bundler/getUserOperationReceipt.ts"() {
19876
19964
  init_SessionContext();
19877
19965
  import_core2 = require("@embarkai/core");
19878
- import_read16 = require("@embarkai/core/read");
19966
+ import_read15 = require("@embarkai/core/read");
19879
19967
  }
19880
19968
  });
19881
19969
 
@@ -20818,12 +20906,12 @@ function useLogout() {
20818
20906
  let userId = null;
20819
20907
  setIsLoading(true);
20820
20908
  try {
20821
- userId = import_auth20.jwtTokenManager.getUserId() || null;
20909
+ userId = import_auth21.jwtTokenManager.getUserId() || null;
20822
20910
  } catch (error) {
20823
20911
  console.warn("[useLogout] Could not get userId:", error);
20824
20912
  }
20825
20913
  try {
20826
- await (0, import_auth20.logout)();
20914
+ await (0, import_auth21.logout)();
20827
20915
  } catch (error) {
20828
20916
  console.warn("[useLogout] Core logout failed:", error);
20829
20917
  }
@@ -20843,10 +20931,10 @@ function useLogout() {
20843
20931
  }, [address, setAddress, setError, setSession, setStatus]);
20844
20932
  return { logout: logout2 };
20845
20933
  }
20846
- var import_auth20, import_react75;
20934
+ var import_auth21, import_react75;
20847
20935
  var init_useLogout = __esm({
20848
20936
  "src/hooks/useLogout.ts"() {
20849
- import_auth20 = require("@embarkai/core/auth");
20937
+ import_auth21 = require("@embarkai/core/auth");
20850
20938
  import_react75 = require("react");
20851
20939
  init_ProviderContext();
20852
20940
  init_SessionContext();
@@ -20907,7 +20995,7 @@ var init_clients2 = __esm({
20907
20995
  // src/modules/transactions.ts
20908
20996
  function useTransactions() {
20909
20997
  const chainId = requireActiveChainId();
20910
- const viemChain = (0, import_read17.getViemChain)(chainId);
20998
+ const viemChain = (0, import_read16.getViemChain)(chainId);
20911
20999
  const publicClient = (0, import_wagmi10.usePublicClient)({ chainId });
20912
21000
  const { data: walletClient } = (0, import_wagmi10.useWalletClient)();
20913
21001
  const { address } = (0, import_wagmi10.useAccount)();
@@ -20965,11 +21053,11 @@ function useTransactions() {
20965
21053
  isConnected: !!address && !!walletClient
20966
21054
  };
20967
21055
  }
20968
- var import_read17, import_viem20, import_wagmi10;
21056
+ var import_read16, import_viem20, import_wagmi10;
20969
21057
  var init_transactions = __esm({
20970
21058
  "src/modules/transactions.ts"() {
20971
21059
  init_SessionContext();
20972
- import_read17 = require("@embarkai/core/read");
21060
+ import_read16 = require("@embarkai/core/read");
20973
21061
  import_viem20 = require("viem");
20974
21062
  import_wagmi10 = require("wagmi");
20975
21063
  }
@@ -21236,9 +21324,9 @@ __export(index_exports, {
21236
21324
  getUserOperationByHash: () => getUserOperationByHash,
21237
21325
  getUserOperationReceipt: () => getUserOperationReceipt,
21238
21326
  getUserProfile: () => getUserProfile,
21239
- getValidTokens: () => import_auth18.getValidTokens,
21240
- jwtTokenManager: () => import_auth18.jwtTokenManager,
21241
- logout: () => import_auth18.logout,
21327
+ getValidTokens: () => import_auth19.getValidTokens,
21328
+ jwtTokenManager: () => import_auth19.jwtTokenManager,
21329
+ logout: () => import_auth19.logout,
21242
21330
  looksLikeNickname: () => looksLikeNickname,
21243
21331
  prepareUserOperation: () => prepareUserOperation,
21244
21332
  requireActiveChainId: () => requireActiveChainId,