@embarkai/ui-kit 0.4.58 → 0.4.59

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.js CHANGED
@@ -197,6 +197,9 @@ var init_initial = __esm({
197
197
  });
198
198
 
199
199
  // src/lib/errors.ts
200
+ function isSessionExpiredError(error) {
201
+ return typeof error === "object" && error !== null && error.code === ErrorCodes.SESSION_EXPIRED;
202
+ }
200
203
  function createAccountAbstractionError(params) {
201
204
  const { message, code } = params;
202
205
  if (!code) {
@@ -205,11 +208,13 @@ function createAccountAbstractionError(params) {
205
208
  switch (code) {
206
209
  case UserRejectedError.CODE:
207
210
  return new UserRejectedError(message);
211
+ case SessionExpiredError.CODE:
212
+ return new SessionExpiredError(message);
208
213
  default:
209
214
  return new AccountAbstractionError(message, code);
210
215
  }
211
216
  }
212
- var AccountAbstractionError, UserRejectedError, ErrorCodes;
217
+ var AccountAbstractionError, UserRejectedError, SessionExpiredError, ErrorCodes;
213
218
  var init_errors = __esm({
214
219
  "src/lib/errors.ts"() {
215
220
  AccountAbstractionError = class _AccountAbstractionError extends Error {
@@ -231,9 +236,19 @@ var init_errors = __esm({
231
236
  this.name = "UserRejectedError";
232
237
  }
233
238
  };
239
+ SessionExpiredError = class _SessionExpiredError extends AccountAbstractionError {
240
+ static {
241
+ this.CODE = "SESSION_EXPIRED";
242
+ }
243
+ constructor(message = "Session expired, please log in again") {
244
+ super(message, _SessionExpiredError.CODE);
245
+ this.name = "SessionExpiredError";
246
+ }
247
+ };
234
248
  ErrorCodes = {
235
249
  MPC_SIGNING_ERROR: "MPC_SIGNING_ERROR",
236
- USER_REJECTED: UserRejectedError.CODE
250
+ USER_REJECTED: UserRejectedError.CODE,
251
+ SESSION_EXPIRED: SessionExpiredError.CODE
237
252
  };
238
253
  }
239
254
  });
@@ -659,7 +674,10 @@ async function ensureDkgAndGetOwner(userId, _clientSeedHex) {
659
674
  };
660
675
  }
661
676
  await iframeManager.authenticate(userId);
662
- const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
677
+ const { jwtTokenManager: jwtTokenManager4, ensureFreshSession: ensureFreshSession2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
678
+ if (await ensureFreshSession2(jwtTokenManager4) === "session_dead") {
679
+ throw new SessionExpiredError();
680
+ }
663
681
  let accessToken = jwtTokenManager4.getAccessToken();
664
682
  if (!accessToken) {
665
683
  console.warn("[iframe-mpc-client] No access token available for DKG, attempting cookie-based session");
@@ -691,8 +709,12 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
691
709
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
692
710
  try {
693
711
  const iframeManager = getIframeManager();
694
- const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
712
+ const { jwtTokenManager: jwtTokenManager4, ensureFreshSession: ensureFreshSession2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
713
+ const session = await ensureFreshSession2(jwtTokenManager4);
695
714
  const accessToken = jwtTokenManager4.getAccessToken();
715
+ if (session === "session_dead") {
716
+ throw new SessionExpiredError();
717
+ }
696
718
  if (!accessToken) {
697
719
  throw new Error("No access token available for signing");
698
720
  }
@@ -751,8 +773,12 @@ async function signTypedDataWithMpc(userId, digest32, typedData) {
751
773
  digest32
752
774
  });
753
775
  const iframeManager = getIframeManager();
754
- const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
776
+ const { jwtTokenManager: jwtTokenManager4, ensureFreshSession: ensureFreshSession2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
777
+ const session = await ensureFreshSession2(jwtTokenManager4);
755
778
  const accessToken = jwtTokenManager4.getAccessToken();
779
+ if (session === "session_dead") {
780
+ throw new SessionExpiredError();
781
+ }
756
782
  if (!accessToken) {
757
783
  console.error("[signTypedDataWithMpc] No access token available");
758
784
  throw new Error("No access token available for signing");
@@ -15554,20 +15580,29 @@ var init_KycMenu = __esm({
15554
15580
  }
15555
15581
  });
15556
15582
 
15557
- // src/internal/components/KYC/KYCStatus.tsx
15583
+ // src/internal/hooks/useUserProfile.ts
15558
15584
  import { useQuery as useQuery9 } from "@tanstack/react-query";
15559
- import { Loader as Loader12 } from "lucide-react";
15560
- import { jsx as jsx70, jsxs as jsxs64 } from "react/jsx-runtime";
15561
- function KYCStatus() {
15585
+ function useUserProfile() {
15562
15586
  const address = useSession((st) => st.address);
15563
- const { data: userProfile = null, isLoading: isUserProfileLoading } = useQuery9({
15564
- retry: false,
15565
- enabled: !!address,
15587
+ return useQuery9({
15566
15588
  queryKey: [QUERY_KEYS.userProfile, address],
15567
- queryFn: getUserProfile
15589
+ queryFn: getUserProfile,
15590
+ enabled: !!address,
15591
+ retry: false
15568
15592
  });
15569
- const isKycVerified = !isUserProfileLoading && userProfile?.kycDetails?.kycStatus === "verified";
15570
- if (isUserProfileLoading) return /* @__PURE__ */ jsx70(Loader12, { className: "w-4 h-4 animate-spin" });
15593
+ }
15594
+ var init_useUserProfile = __esm({
15595
+ "src/internal/hooks/useUserProfile.ts"() {
15596
+ init_SessionContext();
15597
+ init_profile();
15598
+ }
15599
+ });
15600
+
15601
+ // src/internal/components/KYC/KYCStatus.tsx
15602
+ import { jsx as jsx70, jsxs as jsxs64 } from "react/jsx-runtime";
15603
+ function KYCStatus() {
15604
+ const { data: userProfile = null, isLoading: isUserProfileLoading } = useUserProfile();
15605
+ const isKycVerified = userProfile?.kycDetails?.kycStatus === "verified";
15571
15606
  if (!isKycVerified) return null;
15572
15607
  return /* @__PURE__ */ jsxs64("div", { className: "group relative flex flex-shrink-0", children: [
15573
15608
  /* @__PURE__ */ jsx70(PositiveIcon, {}),
@@ -15588,9 +15623,8 @@ function KYCStatus() {
15588
15623
  }
15589
15624
  var init_KYCStatus = __esm({
15590
15625
  "src/internal/components/KYC/KYCStatus.tsx"() {
15591
- init_SessionContext();
15592
15626
  init_icons();
15593
- init_profile();
15627
+ init_useUserProfile();
15594
15628
  init_utils2();
15595
15629
  }
15596
15630
  });
@@ -15855,7 +15889,7 @@ var init_useStore = __esm({
15855
15889
 
15856
15890
  // src/internal/components/ManageWalletMenu/EmailForm.tsx
15857
15891
  import { useMutation as useMutation12 } from "@tanstack/react-query";
15858
- import { ChevronRight as ChevronRight4, Loader as Loader13, Mail as Mail4 } from "lucide-react";
15892
+ import { ChevronRight as ChevronRight4, Loader as Loader12, Mail as Mail4 } from "lucide-react";
15859
15893
  import { jsx as jsx73, jsxs as jsxs67 } from "react/jsx-runtime";
15860
15894
  function EmailForm() {
15861
15895
  const { callbacksRef } = useProviderConfig();
@@ -15943,7 +15977,7 @@ function EmailForm() {
15943
15977
  size: "large",
15944
15978
  disabled: !email || isLoading,
15945
15979
  onClick: () => onSendVerificationCode(),
15946
- children: isLoading ? /* @__PURE__ */ jsx73(Loader13, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx73(ChevronRight4, { className: "w-4 h-4" })
15980
+ children: isLoading ? /* @__PURE__ */ jsx73(Loader12, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx73(ChevronRight4, { className: "w-4 h-4" })
15947
15981
  }
15948
15982
  )
15949
15983
  ] });
@@ -16625,7 +16659,7 @@ var init_ProviderCard = __esm({
16625
16659
 
16626
16660
  // src/internal/components/ManageWalletMenu/ManageWallet.tsx
16627
16661
  import { fromPairs } from "lodash-es";
16628
- import { AlertTriangle as AlertTriangle4, ArrowLeft as ArrowLeft14, Loader as Loader14 } from "lucide-react";
16662
+ import { AlertTriangle as AlertTriangle4, ArrowLeft as ArrowLeft14, Loader as Loader13 } from "lucide-react";
16629
16663
  import { useMemo as useMemo7 } from "react";
16630
16664
  import { Fragment as Fragment28, jsx as jsx77, jsxs as jsxs71 } from "react/jsx-runtime";
16631
16665
  function getProviderName(provider) {
@@ -16772,7 +16806,7 @@ function ManageWalletMenu() {
16772
16806
  ),
16773
16807
  /* @__PURE__ */ jsx77("span", { className: "text-xl font-semibold", children: t("passport:profilesMenu.title") })
16774
16808
  ] }),
16775
- isProvidersLoading && /* @__PURE__ */ jsx77("div", { className: "flex items-center justify-center p-4 text-[var(--ui-kit-fg-muted)]", children: /* @__PURE__ */ jsx77(Loader14, { className: "w-4 h-4 animate-spin" }) }),
16809
+ isProvidersLoading && /* @__PURE__ */ jsx77("div", { className: "flex items-center justify-center p-4 text-[var(--ui-kit-fg-muted)]", children: /* @__PURE__ */ jsx77(Loader13, { className: "w-4 h-4 animate-spin" }) }),
16776
16810
  /* @__PURE__ */ jsx77(EmailNotConnectedWarning, {}),
16777
16811
  showCurrentProviders && renderProviders.map((node) => node),
16778
16812
  showExtraProvidersUi && /* @__PURE__ */ jsx77(AddProvider, {}),
@@ -16824,7 +16858,7 @@ var init_ManageWallet = __esm({
16824
16858
 
16825
16859
  // src/internal/components/ManageWalletMenu/UnlinkProviderMenu.tsx
16826
16860
  import { useMutation as useMutation15, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
16827
- import { Key as Key6, Loader as Loader15 } from "lucide-react";
16861
+ import { Key as Key6, Loader as Loader14 } from "lucide-react";
16828
16862
  import { useState as useState19 } from "react";
16829
16863
  import { useDisconnect as useDisconnect2 } from "wagmi";
16830
16864
  import { jsx as jsx78, jsxs as jsxs72 } from "react/jsx-runtime";
@@ -16911,7 +16945,7 @@ function UnlinkProviderMenu() {
16911
16945
  disabled: !!isProviderUnlinking || !confirmUnlink || confirmInput !== confirmUnlink.externalId,
16912
16946
  className: "w-full flex-1",
16913
16947
  children: [
16914
- isProviderUnlinking && /* @__PURE__ */ jsx78(Loader15, { className: "animate-spin h-4 w-4" }),
16948
+ isProviderUnlinking && /* @__PURE__ */ jsx78(Loader14, { className: "animate-spin h-4 w-4" }),
16915
16949
  t("passport:common.delete")
16916
16950
  ]
16917
16951
  }
@@ -17261,7 +17295,7 @@ var init_NicknameEditForm = __esm({
17261
17295
  // src/internal/components/NicknameMenu/NicknameMenu.tsx
17262
17296
  import { useQuery as useQuery12 } from "@tanstack/react-query";
17263
17297
  import dayjs4 from "dayjs";
17264
- import { ArrowLeft as ArrowLeft15, Info as Info4, Loader as Loader16 } from "lucide-react";
17298
+ import { ArrowLeft as ArrowLeft15, Info as Info4, Loader as Loader15 } from "lucide-react";
17265
17299
  import { jsx as jsx80, jsxs as jsxs74 } from "react/jsx-runtime";
17266
17300
  function NicknameMenu() {
17267
17301
  const { isInitialUser } = usePageParams().current;
@@ -17300,7 +17334,7 @@ function NicknameMenu() {
17300
17334
  ),
17301
17335
  /* @__PURE__ */ jsxs74("div", { className: "flex gap-[var(--ui-kit-gap)] items-center w-fit", children: [
17302
17336
  /* @__PURE__ */ jsx80("span", { className: "text-xl font-semibold", children: t("passport:nicknameMenu.title") }),
17303
- isNicknameInfoLoading && /* @__PURE__ */ jsx80(Loader16, { className: "w-4 h-4 animate-spin" })
17337
+ isNicknameInfoLoading && /* @__PURE__ */ jsx80(Loader15, { className: "w-4 h-4 animate-spin" })
17304
17338
  ] })
17305
17339
  ] }),
17306
17340
  /* @__PURE__ */ jsx80("span", { className: "text-[10px] text-[var(--ui-kit-fg-muted)]", children: t("passport:nicknameMenu.yourNickname") }),
@@ -18166,7 +18200,7 @@ var init_PortfolioItem = __esm({
18166
18200
 
18167
18201
  // src/internal/components/PortfolioMenu/PortfolioMenu.tsx
18168
18202
  import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
18169
- import { ArrowLeft as ArrowLeft16, Gem, Loader as Loader17, RefreshCw as RefreshCw2 } from "lucide-react";
18203
+ import { ArrowLeft as ArrowLeft16, Gem, Loader as Loader16, RefreshCw as RefreshCw2 } from "lucide-react";
18170
18204
  import { useCallback as useCallback24 } from "react";
18171
18205
  import { jsx as jsx83, jsxs as jsxs77 } from "react/jsx-runtime";
18172
18206
  function PortfolioMenu() {
@@ -18221,11 +18255,11 @@ function PortfolioMenu() {
18221
18255
  size: "icon",
18222
18256
  onClick: refreshAllAssetsBalances,
18223
18257
  disabled: isBlockscoutLoading || isBlockscoutFetching,
18224
- children: isBlockscoutLoading || isBlockscoutFetching ? /* @__PURE__ */ jsx83(Loader17, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx83(RefreshCw2, { className: "h-4 w-4" })
18258
+ children: isBlockscoutLoading || isBlockscoutFetching ? /* @__PURE__ */ jsx83(Loader16, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx83(RefreshCw2, { className: "h-4 w-4" })
18225
18259
  }
18226
18260
  )
18227
18261
  ] }),
18228
- isBlockscoutLoading && /* @__PURE__ */ jsx83("div", { className: "w-full flex items-center justify-center gap-[var(--ui-kit-gap)] p-[var(--ui-kit-pd)]", children: /* @__PURE__ */ jsx83(Loader17, { className: "w-4 h-4 animate-spin" }) }),
18262
+ isBlockscoutLoading && /* @__PURE__ */ jsx83("div", { className: "w-full flex items-center justify-center gap-[var(--ui-kit-gap)] p-[var(--ui-kit-pd)]", children: /* @__PURE__ */ jsx83(Loader16, { className: "w-4 h-4 animate-spin" }) }),
18229
18263
  !isBlockscoutLoading && blockscoutAssets?.length === 0 && /* @__PURE__ */ jsxs77(Highlight, { type: "info", className: "flex flex-col items-center justify-center gap-[var(--ui-kit-gap)]", children: [
18230
18264
  /* @__PURE__ */ jsx83(Gem, { className: "w-8 h-8" }),
18231
18265
  /* @__PURE__ */ jsx83("span", { className: "block", children: t("passport:portfolioMenu.noAssets") })
@@ -18352,7 +18386,7 @@ var init_nickname_fingerprint = __esm({
18352
18386
  });
18353
18387
 
18354
18388
  // src/internal/components/ReceiveMenu/ReceiveMenu.tsx
18355
- import { ArrowLeft as ArrowLeft17, CheckCircle2 as CheckCircle23, Copy as Copy2, Info as Info5, Loader as Loader18, Shield } from "lucide-react";
18389
+ import { ArrowLeft as ArrowLeft17, CheckCircle2 as CheckCircle23, Copy as Copy2, Info as Info5, Loader as Loader17, Shield } from "lucide-react";
18356
18390
  import QRCode from "qrcode";
18357
18391
  import { useCallback as useCallback25, useEffect as useEffect33, useMemo as useMemo11, useState as useState21 } from "react";
18358
18392
  import { Fragment as Fragment31, jsx as jsx84, jsxs as jsxs78 } from "react/jsx-runtime";
@@ -18426,7 +18460,7 @@ function ReceiveMenu() {
18426
18460
  /* @__PURE__ */ jsx84("strong", { className: "block w-full", children: `${t("passport:common.network")}: ${chainConfig.name}` }),
18427
18461
  /* @__PURE__ */ jsx84("span", { className: "block w-full", children: t("passport:receiveMenu.warning") })
18428
18462
  ] }),
18429
- /* @__PURE__ */ jsx84("div", { className: "flex items-center justify-center p-[var(--ui-kit-pd)]", style: { minHeight: "216px" }, children: qrCodeUrl ? /* @__PURE__ */ jsx84("img", { src: qrCodeUrl, alt: "Wallet QR Code", className: "w-48 h-48" }) : /* @__PURE__ */ jsx84(Loader18, { className: "w-4 h-4 animate-spin" }) }),
18463
+ /* @__PURE__ */ jsx84("div", { className: "flex items-center justify-center p-[var(--ui-kit-pd)]", style: { minHeight: "216px" }, children: qrCodeUrl ? /* @__PURE__ */ jsx84("img", { src: qrCodeUrl, alt: "Wallet QR Code", className: "w-48 h-48" }) : /* @__PURE__ */ jsx84(Loader17, { className: "w-4 h-4 animate-spin" }) }),
18430
18464
  fingerprint && /* @__PURE__ */ jsxs78("div", { className: "flex items-center justify-center gap-2 p-3 rounded-[var(--ui-kit-el-bdrs)] bg-[var(--ui-kit-bg-secondary)]", children: [
18431
18465
  /* @__PURE__ */ jsx84(Shield, { className: "w-4 h-4 text-[var(--ui-kit-bg-success)]" }),
18432
18466
  /* @__PURE__ */ jsx84("span", { className: "text-sm text-[var(--ui-kit-fg-muted)]", children: t("passport:common.fingerprint") }),
@@ -18665,7 +18699,7 @@ var init_ConnectedApps = __esm({
18665
18699
 
18666
18700
  // src/internal/components/SecurityMenu/ConnectedApps/UntrustApplication.tsx
18667
18701
  import { useMutation as useMutation18, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
18668
- import { AppWindowMac as AppWindowMac2, Loader as Loader19 } from "lucide-react";
18702
+ import { AppWindowMac as AppWindowMac2, Loader as Loader18 } from "lucide-react";
18669
18703
  import { jsx as jsx86, jsxs as jsxs80 } from "react/jsx-runtime";
18670
18704
  function UntrustApplication() {
18671
18705
  const { t } = useT();
@@ -18742,7 +18776,7 @@ function UntrustApplication() {
18742
18776
  className: "flex-1",
18743
18777
  onClick: () => handleUntrustApp(),
18744
18778
  disabled: isUntrustingApp,
18745
- children: isUntrustingApp ? /* @__PURE__ */ jsx86(Loader19, { className: "h-4 w-4 animate-spin" }) : t("passport:common.delete")
18779
+ children: isUntrustingApp ? /* @__PURE__ */ jsx86(Loader18, { className: "h-4 w-4 animate-spin" }) : t("passport:common.delete")
18746
18780
  }
18747
18781
  )
18748
18782
  ] })
@@ -18770,11 +18804,11 @@ var init_ConnectedApps2 = __esm({
18770
18804
  });
18771
18805
 
18772
18806
  // src/internal/components/SecurityMenu/Keyshare/KeyshareStatus.tsx
18773
- import { Loader as Loader20 } from "lucide-react";
18807
+ import { Loader as Loader19 } from "lucide-react";
18774
18808
  import { jsx as jsx87, jsxs as jsxs81 } from "react/jsx-runtime";
18775
18809
  function KeyshareStatus(props) {
18776
18810
  const { isLoading, content, icon: Icon2, children } = props;
18777
- if (isLoading) return /* @__PURE__ */ jsx87(Loader20, { className: "w-4 h-4 animate-spin" });
18811
+ if (isLoading) return /* @__PURE__ */ jsx87(Loader19, { className: "w-4 h-4 animate-spin" });
18778
18812
  return /* @__PURE__ */ jsxs81("div", { className: "group relative w-full h-full", children: [
18779
18813
  children,
18780
18814
  /* @__PURE__ */ jsx87(
@@ -22231,7 +22265,7 @@ var init_useTokenBalance = __esm({
22231
22265
  });
22232
22266
 
22233
22267
  // src/internal/components/SendMenu/send/sendSteps/InputSendStep.tsx
22234
- import { AlertCircle as AlertCircle4, AtSign as AtSign2, CheckCircle2 as CheckCircle25, Loader as Loader21, Wallet2 as Wallet24 } from "lucide-react";
22268
+ import { AlertCircle as AlertCircle4, AtSign as AtSign2, CheckCircle2 as CheckCircle25, Loader as Loader20, Wallet2 as Wallet24 } from "lucide-react";
22235
22269
  import { formatUnits as formatUnits11, isAddress as isAddress2 } from "viem";
22236
22270
  import { Fragment as Fragment41, jsx as jsx107, jsxs as jsxs98 } from "react/jsx-runtime";
22237
22271
  function InputSendStep(props) {
@@ -22347,7 +22381,7 @@ function InputSendStep(props) {
22347
22381
  /* @__PURE__ */ jsx107(AssetInputIcon, { asset: selectedAsset }),
22348
22382
  /* @__PURE__ */ jsx107("span", { children: (isNft ? selectedAsset.nftMetadata?.name || selectedAsset.symbol : selectedAsset.name).toUpperCase() })
22349
22383
  ] }) : /* @__PURE__ */ jsx107("span", { className: "text-[var(--ui-kit-fg-muted)]", children: "No Asset Selected" }),
22350
- isAssetsLoading && /* @__PURE__ */ jsx107(Loader21, { className: "w-4 h-4 animate-spin" })
22384
+ isAssetsLoading && /* @__PURE__ */ jsx107(Loader20, { className: "w-4 h-4 animate-spin" })
22351
22385
  ]
22352
22386
  }
22353
22387
  ),
@@ -22361,7 +22395,7 @@ function InputSendStep(props) {
22361
22395
  disabled: isAssetsLoading,
22362
22396
  onChange: (e) => setRecipient(e.target.value),
22363
22397
  placeholder: "0x... or @nickname",
22364
- element: isNicknameInput && isResolving ? /* @__PURE__ */ jsx107(Loader21, { className: "w-4 h-4 animate-spin text-[var(--ui-kit-fg-muted)]" }) : null
22398
+ element: isNicknameInput && isResolving ? /* @__PURE__ */ jsx107(Loader20, { className: "w-4 h-4 animate-spin text-[var(--ui-kit-fg-muted)]" }) : null
22365
22399
  }
22366
22400
  ),
22367
22401
  /* @__PURE__ */ jsx107(NicknameData, { resolvedNicknameData, isNicknameInput }),
@@ -22370,7 +22404,7 @@ function InputSendStep(props) {
22370
22404
  !isNft && selectedAsset && /* @__PURE__ */ jsxs98("span", { className: "block text-[10px]", children: [
22371
22405
  t("passport:common.balance"),
22372
22406
  " ",
22373
- isBalanceLoading ? /* @__PURE__ */ jsx107(Loader21, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsxs98("span", { className: "text-[var(--ui-kit-fg)] font-semibold", children: [
22407
+ isBalanceLoading ? /* @__PURE__ */ jsx107(Loader20, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsxs98("span", { className: "text-[var(--ui-kit-fg)] font-semibold", children: [
22374
22408
  formatPrice(balanceData.formatted),
22375
22409
  " ",
22376
22410
  balanceData.symbol
@@ -22397,7 +22431,7 @@ function InputSendStep(props) {
22397
22431
  type: isComplianceLoading ? "info" : erc3643CanTransfer ? "success" : "error",
22398
22432
  className: "flex gap-[var(--ui-kit-gap)]",
22399
22433
  children: isComplianceLoading ? /* @__PURE__ */ jsxs98(Fragment41, { children: [
22400
- /* @__PURE__ */ jsx107(Loader21, { className: "h-4 w-4 animate-spin" }),
22434
+ /* @__PURE__ */ jsx107(Loader20, { className: "h-4 w-4 animate-spin" }),
22401
22435
  /* @__PURE__ */ jsx107("span", { children: "Checking compliance..." })
22402
22436
  ] }) : erc3643CanTransfer ? /* @__PURE__ */ jsxs98(Fragment41, { children: [
22403
22437
  /* @__PURE__ */ jsx107(CheckCircle25, { className: "h-4 w-4" }),
@@ -22441,7 +22475,7 @@ var init_InputSendStep = __esm({
22441
22475
 
22442
22476
  // src/internal/components/SendMenu/send/sendSteps/ConfirmSendStep.tsx
22443
22477
  import { useMutation as useMutation21 } from "@tanstack/react-query";
22444
- import { AlertTriangle as AlertTriangle5, AtSign as AtSign3, Loader as Loader27, Shield as Shield2, ShieldAlert as ShieldAlert2, ShieldCheck as ShieldCheck3 } from "lucide-react";
22478
+ import { AlertTriangle as AlertTriangle5, AtSign as AtSign3, Loader as Loader21, Shield as Shield2, ShieldAlert as ShieldAlert2, ShieldCheck as ShieldCheck3 } from "lucide-react";
22445
22479
  import { Fragment as Fragment42, jsx as jsx108, jsxs as jsxs99 } from "react/jsx-runtime";
22446
22480
  function ConfirmSendStep(props) {
22447
22481
  const { sendTransaction, erc3643Compliance, isNicknameInput, resolvedNicknameData } = props;
@@ -22601,7 +22635,7 @@ function ConfirmSendStep(props) {
22601
22635
  className: "w-full",
22602
22636
  size: "large",
22603
22637
  children: [
22604
- isTransactionPending && /* @__PURE__ */ jsx108(Loader27, { className: "h-4 w-4 animate-spin" }),
22638
+ isTransactionPending && /* @__PURE__ */ jsx108(Loader21, { className: "h-4 w-4 animate-spin" }),
22605
22639
  t("passport:common.confirm")
22606
22640
  ]
22607
22641
  }
@@ -22631,7 +22665,7 @@ var init_sendSteps = __esm({
22631
22665
  });
22632
22666
 
22633
22667
  // src/internal/components/SendMenu/send/SendMenu.tsx
22634
- import { CheckCircle2 as CheckCircle26, Loader as Loader28 } from "lucide-react";
22668
+ import { CheckCircle2 as CheckCircle26, Loader as Loader27 } from "lucide-react";
22635
22669
  import { useEffect as useEffect45, useMemo as useMemo15 } from "react";
22636
22670
  import { parseUnits as parseUnits2 } from "viem";
22637
22671
  import { Fragment as Fragment43, jsx as jsx109, jsxs as jsxs100 } from "react/jsx-runtime";
@@ -22753,7 +22787,7 @@ function SendMenu() {
22753
22787
  }
22754
22788
  ),
22755
22789
  txStep === "pending" && /* @__PURE__ */ jsxs100(Highlight, { type: "info", className: "flex gap-[var(--ui-kit-gap)]", children: [
22756
- /* @__PURE__ */ jsx109(Loader28, { className: "h-4 w-4 animate-spin" }),
22790
+ /* @__PURE__ */ jsx109(Loader27, { className: "h-4 w-4 animate-spin" }),
22757
22791
  /* @__PURE__ */ jsxs100("span", { className: "flex-1", children: [
22758
22792
  /* @__PURE__ */ jsx109("span", { className: "block leading-4 font-semibold", children: t("passport:sendMenu.pendingStep") }),
22759
22793
  /* @__PURE__ */ jsx109("span", { children: t("passport:sendMenu.pendingStepMsg") })
@@ -23994,7 +24028,7 @@ var init_TransactionsGroup = __esm({
23994
24028
 
23995
24029
  // src/internal/components/TransactionsMenu/TransactionsMenu.tsx
23996
24030
  import { useQuery as useQuery23, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
23997
- import { ArrowLeft as ArrowLeft22, Loader as Loader29, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
24031
+ import { ArrowLeft as ArrowLeft22, Loader as Loader28, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
23998
24032
  import { useCallback as useCallback30, useState as useState28 } from "react";
23999
24033
  import { jsx as jsx114, jsxs as jsxs105 } from "react/jsx-runtime";
24000
24034
  function TransactionsMenu() {
@@ -24042,12 +24076,12 @@ function TransactionsMenu() {
24042
24076
  onClick: refreshTxHistory,
24043
24077
  disabled: isTxHistoryFetching,
24044
24078
  title: "Refresh transactions",
24045
- children: isTxHistoryFetching ? /* @__PURE__ */ jsx114(Loader29, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx114(RefreshCw3, { className: "h-4 w-4" })
24079
+ children: isTxHistoryFetching ? /* @__PURE__ */ jsx114(Loader28, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx114(RefreshCw3, { className: "h-4 w-4" })
24046
24080
  }
24047
24081
  )
24048
24082
  ] }),
24049
24083
  !historySupported && /* @__PURE__ */ jsx114(Highlight, { type: "warning", children: /* @__PURE__ */ jsx114("span", { children: t("passport:transactionsMenu.comingSoon") }) }),
24050
- historySupported && isTxHistoryLoading && /* @__PURE__ */ jsx114("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ jsx114(Loader29, { className: "w-4 h-4 animate-spin" }) }),
24084
+ historySupported && isTxHistoryLoading && /* @__PURE__ */ jsx114("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ jsx114(Loader28, { className: "w-4 h-4 animate-spin" }) }),
24051
24085
  historySupported && !isTxHistoryLoading && txHistoryResolvedError && /* @__PURE__ */ jsxs105(Highlight, { type: "error", className: "flex gap-[var(--ui-kit-gap)]", children: [
24052
24086
  /* @__PURE__ */ jsx114(XCircle, { className: "w-4 h-4 flex-none" }),
24053
24087
  /* @__PURE__ */ jsx114("span", { className: "block w-full flex-1 text-center text-xs", children: txHistoryResolvedError })
@@ -24312,19 +24346,12 @@ var init_usePageMapper = __esm({
24312
24346
  });
24313
24347
 
24314
24348
  // src/internal/hooks/useSettingsNotifications.ts
24315
- import { useQuery as useQuery24 } from "@tanstack/react-query";
24316
24349
  import { useEffect as useEffect49 } from "react";
24317
24350
  function useSettingsNotifications() {
24318
- const address = useSession((st) => st.address);
24319
24351
  const setSettingsNotifications = useLayoutDataStore((st) => st.setSettingsNotifications);
24320
24352
  const providers = jwtTokenManager2.getProviders();
24321
24353
  const hasEmail = providers.includes("email");
24322
- const { data: userProfile = null } = useQuery24({
24323
- retry: false,
24324
- enabled: !!address,
24325
- queryKey: [QUERY_KEYS.userProfile, address],
24326
- queryFn: getUserProfile
24327
- });
24354
+ const { data: userProfile = null } = useUserProfile();
24328
24355
  useEffect49(() => {
24329
24356
  const isKYCVerified = userProfile?.kycDetails?.kycStatus === "verified";
24330
24357
  setSettingsNotifications({
@@ -24342,10 +24369,9 @@ function useSettingsNotifications() {
24342
24369
  var EMAIL_NOT_CONNECTED_NOTIFICATION, COMPLETE_KYC_PROGRESS;
24343
24370
  var init_useSettingsNotifications = __esm({
24344
24371
  "src/internal/hooks/useSettingsNotifications.ts"() {
24345
- init_SessionContext();
24346
24372
  init_auth();
24347
- init_profile();
24348
24373
  init_useLayoutDataStore();
24374
+ init_useUserProfile();
24349
24375
  EMAIL_NOT_CONNECTED_NOTIFICATION = {
24350
24376
  id: "email-not-connected",
24351
24377
  target: "manage-wallet" /* MANAGE_WALLET */,
@@ -24365,7 +24391,7 @@ var init_package = __esm({
24365
24391
  "package.json"() {
24366
24392
  package_default = {
24367
24393
  name: "@embarkai/ui-kit",
24368
- version: "0.4.58",
24394
+ version: "0.4.59",
24369
24395
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
24370
24396
  type: "module",
24371
24397
  main: "./dist/index.cjs",
@@ -24467,7 +24493,7 @@ var init_package = __esm({
24467
24493
 
24468
24494
  // src/internal/components/Footer/Footer.tsx
24469
24495
  import { useMutation as useMutation22, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
24470
- import { Loader as Loader30, LogOut } from "lucide-react";
24496
+ import { Loader as Loader29, LogOut } from "lucide-react";
24471
24497
  import { useDisconnect as useDisconnect3 } from "wagmi";
24472
24498
  import { jsx as jsx116, jsxs as jsxs106 } from "react/jsx-runtime";
24473
24499
  function Footer() {
@@ -24555,7 +24581,7 @@ function Footer() {
24555
24581
  disabled: isDisconnecting,
24556
24582
  children: [
24557
24583
  /* @__PURE__ */ jsx116("span", { children: t("passport:auth.logout") }),
24558
- isDisconnecting ? /* @__PURE__ */ jsx116(Loader30, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx116(LogOut, { className: "w-4 h-4" })
24584
+ isDisconnecting ? /* @__PURE__ */ jsx116(Loader29, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx116(LogOut, { className: "w-4 h-4" })
24559
24585
  ]
24560
24586
  }
24561
24587
  ) : null
@@ -24600,8 +24626,7 @@ var init_Footer2 = __esm({
24600
24626
  });
24601
24627
 
24602
24628
  // src/internal/components/Header/Header.tsx
24603
- import { useQuery as useQuery25 } from "@tanstack/react-query";
24604
- import { Copy as Copy4, Loader as Loader31 } from "lucide-react";
24629
+ import { Copy as Copy4, Loader as Loader30 } from "lucide-react";
24605
24630
  import { useCallback as useCallback32, useRef as useRef21, useState as useState29 } from "react";
24606
24631
  import { Fragment as Fragment45, jsx as jsx117, jsxs as jsxs107 } from "react/jsx-runtime";
24607
24632
  function formatAddress2(addr) {
@@ -24636,12 +24661,7 @@ function Header() {
24636
24661
  }, 1e3);
24637
24662
  }
24638
24663
  }, []);
24639
- const { data: profile, isLoading: isProfileLoading } = useQuery25({
24640
- retry: false,
24641
- enabled: !!address,
24642
- queryKey: [QUERY_KEYS.userProfile, address],
24643
- queryFn: getUserProfile
24644
- });
24664
+ const { data: profile, isLoading: isProfileLoading } = useUserProfile();
24645
24665
  const avatar = profile?.avatar || jwtTokenManager2.getAvatar();
24646
24666
  const displayName = profile?.nicknameDisplay || profile?.displayName || jwtTokenManager2.getDisplayName();
24647
24667
  const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ jsx117("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ jsx117("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
@@ -24669,7 +24689,7 @@ function Header() {
24669
24689
  style: { width: "calc(100% - 48px - var(--ui-kit-gap))" },
24670
24690
  className: "flex-1 flex flex-col justify-center gap-1",
24671
24691
  children: [
24672
- isProfileLoading && /* @__PURE__ */ jsx117(Loader31, { className: "w-4 h-4 animate-spin" }),
24692
+ isProfileLoading && /* @__PURE__ */ jsx117(Loader30, { className: "w-4 h-4 animate-spin" }),
24673
24693
  !!address && !isProfileLoading && !!profile && /* @__PURE__ */ jsxs107(Fragment45, { children: [
24674
24694
  /* @__PURE__ */ jsxs107("div", { className: "w-full flex items-center gap-[var(--ui-kit-gap)]", children: [
24675
24695
  /* @__PURE__ */ jsx117(
@@ -24727,7 +24747,7 @@ var init_Header = __esm({
24727
24747
  init_useT();
24728
24748
  init_icons();
24729
24749
  init_auth();
24730
- init_profile();
24750
+ init_useUserProfile();
24731
24751
  init_pro_mode();
24732
24752
  init_utils2();
24733
24753
  init_BalanceView2();
@@ -26500,6 +26520,7 @@ __export(auth_exports, {
26500
26520
  createPasskeyHelpers: () => createPasskeyHelpers,
26501
26521
  createSignatureMessage: () => createSignatureMessage,
26502
26522
  deriveDemoPrivateKey: () => deriveDemoPrivateKey,
26523
+ ensureFreshSession: () => ensureFreshSession,
26503
26524
  ensureKeyshare: () => ensureKeyshare,
26504
26525
  ensureValidToken: () => ensureValidToken,
26505
26526
  fetchProjectName: () => fetchProjectName,
@@ -26543,6 +26564,7 @@ import {
26543
26564
  configureJwtModule,
26544
26565
  logout,
26545
26566
  verifyToken,
26567
+ ensureFreshSession,
26546
26568
  ensureValidToken,
26547
26569
  getValidTokens,
26548
26570
  authenticatedFetch,
@@ -26881,8 +26903,8 @@ var init_iframe_manager = __esm({
26881
26903
  async handleTokenRefreshRequest(message) {
26882
26904
  try {
26883
26905
  const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
26884
- const refreshSuccess = await jwtTokenManager4.refreshAccessToken();
26885
- if (refreshSuccess) {
26906
+ const outcome = await jwtTokenManager4.refreshTokens();
26907
+ if (outcome === "refreshed") {
26886
26908
  const newAccessToken = jwtTokenManager4.getAccessToken();
26887
26909
  if (this.iframe && this.iframe.contentWindow) {
26888
26910
  const iframeOrigin = new URL(this.iframeUrl).origin;
@@ -26904,6 +26926,7 @@ var init_iframe_manager = __esm({
26904
26926
  type: "IFRAME_MSG_TOKEN_REFRESHED",
26905
26927
  messageId: message.messageId,
26906
26928
  error: "Token refresh failed",
26929
+ sessionDead: outcome === "session_dead",
26907
26930
  timestamp: Date.now()
26908
26931
  },
26909
26932
  iframeOrigin
@@ -28362,16 +28385,15 @@ init_lumia2();
28362
28385
  init_embarkAI2();
28363
28386
  init_SessionContext();
28364
28387
  init_auth();
28365
- init_profile();
28366
28388
  init_BalanceView2();
28367
28389
  init_KYC();
28368
28390
  init_button();
28369
28391
  init_useLayoutDataStore();
28392
+ init_useUserProfile();
28370
28393
  init_useLayoutStore();
28371
28394
  init_pro_mode();
28372
28395
  init_utils2();
28373
- import { useQuery as useQuery26 } from "@tanstack/react-query";
28374
- import { Cloud as Cloud4, Laptop as Laptop2, Loader as Loader32, Shield as Shield3 } from "lucide-react";
28396
+ import { Cloud as Cloud4, Laptop as Laptop2, Loader as Loader31, Shield as Shield3 } from "lucide-react";
28375
28397
  import { useEffect as useEffect54, useMemo as useMemo18 } from "react";
28376
28398
  import { Fragment as Fragment48, jsx as jsx125, jsxs as jsxs111 } from "react/jsx-runtime";
28377
28399
  function getFormattedStatus(label, status, showStatus) {
@@ -28393,12 +28415,7 @@ function ConnectWalletButton(props) {
28393
28415
  const { session, address, hasServerVault, isLoading, isIframeReady, status, setUsePaymaster } = useSession();
28394
28416
  const connectButtonLabel = getFormattedStatus(label || "Connect", status, isIframeReady);
28395
28417
  useEffect54(() => setUsePaymaster(usePaymaster), [setUsePaymaster, usePaymaster]);
28396
- const { data: profile, isLoading: isProfileLoading } = useQuery26({
28397
- retry: false,
28398
- enabled: !!address,
28399
- queryKey: [QUERY_KEYS.userProfile, address],
28400
- queryFn: getUserProfile
28401
- });
28418
+ const { data: profile, isLoading: isProfileLoading } = useUserProfile();
28402
28419
  const displayName = profile?.nicknameDisplay || profile?.displayName || jwtTokenManager2.getDisplayName();
28403
28420
  const indicators = useMemo18(() => {
28404
28421
  const userId = session?.mpcUserId;
@@ -28418,7 +28435,7 @@ function ConnectWalletButton(props) {
28418
28435
  disabled: isConnecting,
28419
28436
  onClick: () => setPage("auth" /* AUTH */),
28420
28437
  children: [
28421
- isConnecting ? /* @__PURE__ */ jsx125("span", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ jsx125(Loader32, { className: "w-4 h-4 animate-spin" }) }) : /* @__PURE__ */ jsx125(embarkAI_default2, { className: "w-6 h-6" }),
28438
+ isConnecting ? /* @__PURE__ */ jsx125("span", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ jsx125(Loader31, { className: "w-4 h-4 animate-spin" }) }) : /* @__PURE__ */ jsx125(embarkAI_default2, { className: "w-6 h-6" }),
28422
28439
  connectButtonLabel
28423
28440
  ]
28424
28441
  }
@@ -28439,7 +28456,7 @@ function ConnectWalletButton(props) {
28439
28456
  "disabled:hover:bg-[var(--ui-kit-bg)] disabled:active:bg-[var(--ui-kit-bg)]"
28440
28457
  ),
28441
28458
  children: [
28442
- isConnecting ? /* @__PURE__ */ jsx125("span", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ jsx125(Loader32, { className: "w-4 h-4 animate-spin" }) }) : /* @__PURE__ */ jsx125(embarkAI_default2, { className: "w-6 h-6" }),
28459
+ isConnecting ? /* @__PURE__ */ jsx125("span", { className: "w-6 h-6 flex items-center justify-center", children: /* @__PURE__ */ jsx125(Loader31, { className: "w-4 h-4 animate-spin" }) }) : /* @__PURE__ */ jsx125(embarkAI_default2, { className: "w-6 h-6" }),
28443
28460
  connectButtonLabel.toUpperCase()
28444
28461
  ]
28445
28462
  }
@@ -28463,8 +28480,8 @@ function ConnectWalletButton(props) {
28463
28480
  ] }),
28464
28481
  /* @__PURE__ */ jsxs111("div", { className: "text-left flex-1 min-w-0 text-[var(--ui-kit-fg)]", children: [
28465
28482
  /* @__PURE__ */ jsxs111("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
28466
- isProfileLoading ? /* @__PURE__ */ jsx125(Loader32, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx125("span", { className: "w-fit text-[14px] leading-4 truncate max-w-[144px] text-[var(--ui-kit-fg)]", children: displayName }),
28467
- !isProfileLoading && /* @__PURE__ */ jsx125(KYCStatus, {})
28483
+ isProfileLoading ? /* @__PURE__ */ jsx125(Loader31, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ jsx125("span", { className: "w-fit text-[14px] leading-4 truncate max-w-[144px] text-[var(--ui-kit-fg)]", children: displayName }),
28484
+ /* @__PURE__ */ jsx125(KYCStatus, {})
28468
28485
  ] }),
28469
28486
  /* @__PURE__ */ jsx125(BalanceView, {})
28470
28487
  ] }),
@@ -29954,6 +29971,7 @@ export {
29954
29971
  PASSPORT_TRANSLATIONS,
29955
29972
  PageKey,
29956
29973
  Provider,
29974
+ SessionExpiredError,
29957
29975
  TOKENS_ICONS,
29958
29976
  ThemeToggle,
29959
29977
  TransactionsList,
@@ -29980,6 +29998,7 @@ export {
29980
29998
  getUserOperationReceipt,
29981
29999
  getUserProfile,
29982
30000
  getValidTokens,
30001
+ isSessionExpiredError,
29983
30002
  jwtTokenManager2 as jwtTokenManager,
29984
30003
  logout,
29985
30004
  looksLikeNickname,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embarkai/ui-kit",
3
- "version": "0.4.58",
3
+ "version": "0.4.59",
4
4
  "description": "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -51,7 +51,7 @@
51
51
  "viem": "^2.52.2",
52
52
  "wagmi": "^2.19.5",
53
53
  "zustand": "^5.0.14",
54
- "@embarkai/core": "0.4.6"
54
+ "@embarkai/core": "0.4.7"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@svgr/core": "^8.1.0",