@embarkai/ui-kit 0.4.106 → 0.4.108

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.
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>EmbarkAI Secure Wallet - iframe version 0.4.106</title>
18
+ <title>EmbarkAI Secure Wallet - iframe version 0.4.108</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -6342,7 +6342,7 @@ var SigningManager = class extends TokenRefreshApiClient {
6342
6342
  };
6343
6343
 
6344
6344
  // src/iframe/main.ts
6345
- var IFRAME_VERSION = "0.4.106";
6345
+ var IFRAME_VERSION = "0.4.108";
6346
6346
  var IframeWallet = class {
6347
6347
  // private finchpay: FinchPayRampAPI
6348
6348
  // private rampnow: RampnowOnrampAPI
package/dist/index.cjs CHANGED
@@ -15709,6 +15709,32 @@ var init_wallets = __esm({
15709
15709
  }
15710
15710
  });
15711
15711
 
15712
+ // src/internal/lib/connect-errors.ts
15713
+ function someInErrorChain(error, predicate) {
15714
+ let current = error;
15715
+ for (let depth = 0; current && depth < 10; depth++) {
15716
+ if (predicate(current)) return true;
15717
+ current = current.cause;
15718
+ }
15719
+ return false;
15720
+ }
15721
+ function dropFailedConnectorSession(error, connector, wagmiConfig3) {
15722
+ if (isRequestPendingError(error) || isUserRejectedError(error)) return;
15723
+ if (wagmiConfig3.state.connections.has(connector.uid)) return;
15724
+ connector.disconnect().catch(() => {
15725
+ });
15726
+ }
15727
+ var REQUEST_PENDING_ERROR_CODE, USER_REJECTED_ERROR_CODE, isRequestPendingError, isUserRejectedError, isUnsupportedChainError;
15728
+ var init_connect_errors = __esm({
15729
+ "src/internal/lib/connect-errors.ts"() {
15730
+ REQUEST_PENDING_ERROR_CODE = -32002;
15731
+ USER_REJECTED_ERROR_CODE = 4001;
15732
+ isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
15733
+ isUserRejectedError = (error) => someInErrorChain(error, (e) => e.code === USER_REJECTED_ERROR_CODE);
15734
+ isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
15735
+ }
15736
+ });
15737
+
15712
15738
  // src/internal/auth/providers/types.ts
15713
15739
  function getTssUrl3() {
15714
15740
  return getServiceUrls().tssUrl;
@@ -16816,9 +16842,12 @@ function ProviderCard(props) {
16816
16842
  isPending: isConnectingExternalWallet,
16817
16843
  variables: pendingConnectVariables,
16818
16844
  isAvailable: isConnectExternalWalletAvailable
16819
- } = useExternalWalletConnnect();
16820
- const setPage = useLayoutDataStore((st) => st.setPage);
16821
- const setConfirmUnlink = useManageWalletStore((st) => st.setConfirmUnlink);
16845
+ } = useExternalWalletConnnect({
16846
+ // onSuccess: undefined,
16847
+ onError: ({ connector, error }) => {
16848
+ console.warn("[useExternalWalletConnect]", connector, error);
16849
+ }
16850
+ });
16822
16851
  const { data: providers = [] } = useProvidersList();
16823
16852
  if (!provider) {
16824
16853
  console.warn("[ProviderCard] Received undefined provider");
@@ -16909,8 +16938,8 @@ function ProviderCard(props) {
16909
16938
  disabled: disabled || isConnectingExternalWallet,
16910
16939
  title: t("passport:common.delete"),
16911
16940
  onClick: () => {
16912
- setConfirmUnlink({ provider, providerName: info.name, externalId });
16913
- setPage("unlink-provider" /* UNLINK_PROVIDER */);
16941
+ useManageWalletStore.getState().setConfirmUnlink({ provider, providerName: info.name, externalId });
16942
+ useLayoutDataStore.getState().setPage("unlink-provider" /* UNLINK_PROVIDER */);
16914
16943
  },
16915
16944
  children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_lucide_react30.Trash2Icon, { className: "w-4 h-4 text-[var(--ui-kit-bg-error)]" })
16916
16945
  }
@@ -17326,14 +17355,6 @@ function getConnectFlowType(params) {
17326
17355
  if (!isEmbarkAI) return "auth";
17327
17356
  return connectFlow;
17328
17357
  }
17329
- function someInErrorChain(error, predicate) {
17330
- let current = error;
17331
- for (let depth = 0; current && depth < 10; depth++) {
17332
- if (predicate(current)) return true;
17333
- current = current.cause;
17334
- }
17335
- return false;
17336
- }
17337
17358
  function ConnectExternalWalletMenu() {
17338
17359
  const { config, callbacksRef } = useProviderConfig();
17339
17360
  const allowedWallets = config.current?.wallet?.allowedWallets;
@@ -17403,7 +17424,7 @@ function ConnectExternalWalletMenu() {
17403
17424
  }
17404
17425
  };
17405
17426
  const completeExternalConnect = (connector, address, chainId) => {
17406
- useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17427
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
17407
17428
  keepOrReleaseExternalWallet(connector, address, chainId);
17408
17429
  };
17409
17430
  const { mutateAsync: loginOrLinkWallet, isPending: isLoginOrLinkWallet } = (0, import_react_query25.useMutation)({
@@ -17507,6 +17528,7 @@ function ConnectExternalWalletMenu() {
17507
17528
  if (!isRequestPending && connectFlowType !== "connect" && wagmiConfig3.state.connections.has(connector.uid)) {
17508
17529
  disconnect({ connector });
17509
17530
  }
17531
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17510
17532
  const errorMessage = isRequestPending ? (
17511
17533
  // @ts-expect-error i18n typing
17512
17534
  t("passport:connectMenu.requestPending", { wallet: connector.name })
@@ -17570,7 +17592,7 @@ function ConnectExternalWalletMenu() {
17570
17592
  size: "icon",
17571
17593
  title: t("passport:common.back"),
17572
17594
  disabled: isConnectingExternalWallet || isLoginOrLinkWallet,
17573
- onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "main-menu" /* MAIN_MENU */),
17595
+ onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "manage-wallet" /* MANAGE_WALLET */),
17574
17596
  children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_lucide_react33.ArrowLeft, { className: "h-4 w-4" })
17575
17597
  }
17576
17598
  ),
@@ -17663,7 +17685,7 @@ function ConnectExternalWalletMenu() {
17663
17685
  ] })
17664
17686
  ] });
17665
17687
  }
17666
- var import_react_query25, import_lucide_react33, import_react46, import_wagmi3, import_chains, import_jsx_runtime74, SIGN_FALLBACK_CHAIN_ID, REQUEST_PENDING_ERROR_CODE, isRequestPendingError, isUnsupportedChainError;
17688
+ var import_react_query25, import_lucide_react33, import_react46, import_wagmi3, import_chains, import_jsx_runtime74, SIGN_FALLBACK_CHAIN_ID;
17667
17689
  var init_ConnectExternalWalletMenu = __esm({
17668
17690
  "src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx"() {
17669
17691
  init_ProviderContext();
@@ -17671,6 +17693,7 @@ var init_ConnectExternalWalletMenu = __esm({
17671
17693
  init_useOpenPage();
17672
17694
  init_i18n();
17673
17695
  init_wallets();
17696
+ init_connect_errors();
17674
17697
  init_linkedProfiles();
17675
17698
  import_react_query25 = require("@tanstack/react-query");
17676
17699
  import_lucide_react33 = require("lucide-react");
@@ -17690,16 +17713,15 @@ var init_ConnectExternalWalletMenu = __esm({
17690
17713
  init_useHasInjectedWallet();
17691
17714
  import_jsx_runtime74 = require("react/jsx-runtime");
17692
17715
  SIGN_FALLBACK_CHAIN_ID = import_chains.mainnet.id;
17693
- REQUEST_PENDING_ERROR_CODE = -32002;
17694
- isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
17695
- isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
17696
17716
  }
17697
17717
  });
17698
17718
 
17699
17719
  // src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
17700
- function useExternalWalletConnnect() {
17720
+ function useExternalWalletConnnect(options) {
17721
+ const { onSuccess, onError } = options || {};
17701
17722
  const { config } = useProviderConfig();
17702
17723
  const walletMode = config.current?.wallet?.mode;
17724
+ const wagmiConfig3 = (0, import_wagmi4.useConfig)();
17703
17725
  const connectors = (0, import_wagmi4.useConnectors)();
17704
17726
  const { mutate: disconnect } = (0, import_wagmi4.useDisconnect)();
17705
17727
  const { mutate: connect, ...restUseConnect } = (0, import_wagmi4.useConnect)({
@@ -17712,9 +17734,16 @@ function useExternalWalletConnnect() {
17712
17734
  chainId,
17713
17735
  connectorName: connector.name || "Unknown Wallet"
17714
17736
  });
17737
+ onSuccess?.({ connected: true, address: signingWalletAddress });
17715
17738
  useLayoutStore.getState().setIsDialogForced(false);
17716
17739
  },
17717
- onError: (error, variables) => {
17740
+ onError: (error, { connector }) => {
17741
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17742
+ onError?.({
17743
+ connected: false,
17744
+ connector: connector?.name || "Unknown Wallet",
17745
+ error
17746
+ });
17718
17747
  useLayoutStore.getState().setIsDialogForced(false);
17719
17748
  }
17720
17749
  }
@@ -17757,6 +17786,7 @@ var init_useExternalWalletConnect = __esm({
17757
17786
  import_react47 = require("react");
17758
17787
  import_wagmi4 = require("wagmi");
17759
17788
  init_useLayoutStore();
17789
+ init_connect_errors();
17760
17790
  init_useExternalWalletStore();
17761
17791
  }
17762
17792
  });
@@ -30011,7 +30041,7 @@ var init_package = __esm({
30011
30041
  "package.json"() {
30012
30042
  package_default = {
30013
30043
  name: "@embarkai/ui-kit",
30014
- version: "0.4.106",
30044
+ version: "0.4.108",
30015
30045
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
30016
30046
  type: "module",
30017
30047
  main: "./dist/index.cjs",
package/dist/index.js CHANGED
@@ -15667,6 +15667,32 @@ var init_wallets = __esm({
15667
15667
  }
15668
15668
  });
15669
15669
 
15670
+ // src/internal/lib/connect-errors.ts
15671
+ function someInErrorChain(error, predicate) {
15672
+ let current = error;
15673
+ for (let depth = 0; current && depth < 10; depth++) {
15674
+ if (predicate(current)) return true;
15675
+ current = current.cause;
15676
+ }
15677
+ return false;
15678
+ }
15679
+ function dropFailedConnectorSession(error, connector, wagmiConfig3) {
15680
+ if (isRequestPendingError(error) || isUserRejectedError(error)) return;
15681
+ if (wagmiConfig3.state.connections.has(connector.uid)) return;
15682
+ connector.disconnect().catch(() => {
15683
+ });
15684
+ }
15685
+ var REQUEST_PENDING_ERROR_CODE, USER_REJECTED_ERROR_CODE, isRequestPendingError, isUserRejectedError, isUnsupportedChainError;
15686
+ var init_connect_errors = __esm({
15687
+ "src/internal/lib/connect-errors.ts"() {
15688
+ REQUEST_PENDING_ERROR_CODE = -32002;
15689
+ USER_REJECTED_ERROR_CODE = 4001;
15690
+ isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
15691
+ isUserRejectedError = (error) => someInErrorChain(error, (e) => e.code === USER_REJECTED_ERROR_CODE);
15692
+ isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
15693
+ }
15694
+ });
15695
+
15670
15696
  // src/internal/auth/providers/types.ts
15671
15697
  import { Key as Key3, Mail as Mail3, Wallet2 as Wallet22 } from "lucide-react";
15672
15698
  function getTssUrl3() {
@@ -16770,9 +16796,12 @@ function ProviderCard(props) {
16770
16796
  isPending: isConnectingExternalWallet,
16771
16797
  variables: pendingConnectVariables,
16772
16798
  isAvailable: isConnectExternalWalletAvailable
16773
- } = useExternalWalletConnnect();
16774
- const setPage = useLayoutDataStore((st) => st.setPage);
16775
- const setConfirmUnlink = useManageWalletStore((st) => st.setConfirmUnlink);
16799
+ } = useExternalWalletConnnect({
16800
+ // onSuccess: undefined,
16801
+ onError: ({ connector, error }) => {
16802
+ console.warn("[useExternalWalletConnect]", connector, error);
16803
+ }
16804
+ });
16776
16805
  const { data: providers = [] } = useProvidersList();
16777
16806
  if (!provider) {
16778
16807
  console.warn("[ProviderCard] Received undefined provider");
@@ -16863,8 +16892,8 @@ function ProviderCard(props) {
16863
16892
  disabled: disabled || isConnectingExternalWallet,
16864
16893
  title: t("passport:common.delete"),
16865
16894
  onClick: () => {
16866
- setConfirmUnlink({ provider, providerName: info.name, externalId });
16867
- setPage("unlink-provider" /* UNLINK_PROVIDER */);
16895
+ useManageWalletStore.getState().setConfirmUnlink({ provider, providerName: info.name, externalId });
16896
+ useLayoutDataStore.getState().setPage("unlink-provider" /* UNLINK_PROVIDER */);
16868
16897
  },
16869
16898
  children: /* @__PURE__ */ jsx71(Trash2Icon, { className: "w-4 h-4 text-[var(--ui-kit-bg-error)]" })
16870
16899
  }
@@ -17289,14 +17318,6 @@ function getConnectFlowType(params) {
17289
17318
  if (!isEmbarkAI) return "auth";
17290
17319
  return connectFlow;
17291
17320
  }
17292
- function someInErrorChain(error, predicate) {
17293
- let current = error;
17294
- for (let depth = 0; current && depth < 10; depth++) {
17295
- if (predicate(current)) return true;
17296
- current = current.cause;
17297
- }
17298
- return false;
17299
- }
17300
17321
  function ConnectExternalWalletMenu() {
17301
17322
  const { config, callbacksRef } = useProviderConfig();
17302
17323
  const allowedWallets = config.current?.wallet?.allowedWallets;
@@ -17366,7 +17387,7 @@ function ConnectExternalWalletMenu() {
17366
17387
  }
17367
17388
  };
17368
17389
  const completeExternalConnect = (connector, address, chainId) => {
17369
- useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17390
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
17370
17391
  keepOrReleaseExternalWallet(connector, address, chainId);
17371
17392
  };
17372
17393
  const { mutateAsync: loginOrLinkWallet, isPending: isLoginOrLinkWallet } = useMutation10({
@@ -17470,6 +17491,7 @@ function ConnectExternalWalletMenu() {
17470
17491
  if (!isRequestPending && connectFlowType !== "connect" && wagmiConfig3.state.connections.has(connector.uid)) {
17471
17492
  disconnect({ connector });
17472
17493
  }
17494
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17473
17495
  const errorMessage = isRequestPending ? (
17474
17496
  // @ts-expect-error i18n typing
17475
17497
  t("passport:connectMenu.requestPending", { wallet: connector.name })
@@ -17533,7 +17555,7 @@ function ConnectExternalWalletMenu() {
17533
17555
  size: "icon",
17534
17556
  title: t("passport:common.back"),
17535
17557
  disabled: isConnectingExternalWallet || isLoginOrLinkWallet,
17536
- onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "main-menu" /* MAIN_MENU */),
17558
+ onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "manage-wallet" /* MANAGE_WALLET */),
17537
17559
  children: /* @__PURE__ */ jsx74(ArrowLeft8, { className: "h-4 w-4" })
17538
17560
  }
17539
17561
  ),
@@ -17626,7 +17648,7 @@ function ConnectExternalWalletMenu() {
17626
17648
  ] })
17627
17649
  ] });
17628
17650
  }
17629
- var SIGN_FALLBACK_CHAIN_ID, REQUEST_PENDING_ERROR_CODE, isRequestPendingError, isUnsupportedChainError;
17651
+ var SIGN_FALLBACK_CHAIN_ID;
17630
17652
  var init_ConnectExternalWalletMenu = __esm({
17631
17653
  "src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx"() {
17632
17654
  init_ProviderContext();
@@ -17634,6 +17656,7 @@ var init_ConnectExternalWalletMenu = __esm({
17634
17656
  init_useOpenPage();
17635
17657
  init_i18n();
17636
17658
  init_wallets();
17659
+ init_connect_errors();
17637
17660
  init_linkedProfiles();
17638
17661
  init_common();
17639
17662
  init_wallet();
@@ -17647,18 +17670,17 @@ var init_ConnectExternalWalletMenu = __esm({
17647
17670
  init_useConnectExternalWalletMenuParams();
17648
17671
  init_useHasInjectedWallet();
17649
17672
  SIGN_FALLBACK_CHAIN_ID = mainnet.id;
17650
- REQUEST_PENDING_ERROR_CODE = -32002;
17651
- isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
17652
- isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
17653
17673
  }
17654
17674
  });
17655
17675
 
17656
17676
  // src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
17657
17677
  import { useCallback as useCallback18 } from "react";
17658
- import { useConnect as useConnect2, useConnectors as useConnectors2, useDisconnect as useDisconnect3 } from "wagmi";
17659
- function useExternalWalletConnnect() {
17678
+ import { useConfig as useConfig2, useConnect as useConnect2, useConnectors as useConnectors2, useDisconnect as useDisconnect3 } from "wagmi";
17679
+ function useExternalWalletConnnect(options) {
17680
+ const { onSuccess, onError } = options || {};
17660
17681
  const { config } = useProviderConfig();
17661
17682
  const walletMode = config.current?.wallet?.mode;
17683
+ const wagmiConfig3 = useConfig2();
17662
17684
  const connectors = useConnectors2();
17663
17685
  const { mutate: disconnect } = useDisconnect3();
17664
17686
  const { mutate: connect, ...restUseConnect } = useConnect2({
@@ -17671,9 +17693,16 @@ function useExternalWalletConnnect() {
17671
17693
  chainId,
17672
17694
  connectorName: connector.name || "Unknown Wallet"
17673
17695
  });
17696
+ onSuccess?.({ connected: true, address: signingWalletAddress });
17674
17697
  useLayoutStore.getState().setIsDialogForced(false);
17675
17698
  },
17676
- onError: (error, variables) => {
17699
+ onError: (error, { connector }) => {
17700
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17701
+ onError?.({
17702
+ connected: false,
17703
+ connector: connector?.name || "Unknown Wallet",
17704
+ error
17705
+ });
17677
17706
  useLayoutStore.getState().setIsDialogForced(false);
17678
17707
  }
17679
17708
  }
@@ -17713,6 +17742,7 @@ var init_useExternalWalletConnect = __esm({
17713
17742
  "src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
17714
17743
  init_ProviderContext();
17715
17744
  init_useLayoutStore();
17745
+ init_connect_errors();
17716
17746
  init_useExternalWalletStore();
17717
17747
  }
17718
17748
  });
@@ -29912,7 +29942,7 @@ var init_package = __esm({
29912
29942
  "package.json"() {
29913
29943
  package_default = {
29914
29944
  name: "@embarkai/ui-kit",
29915
- version: "0.4.106",
29945
+ version: "0.4.108",
29916
29946
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
29917
29947
  type: "module",
29918
29948
  main: "./dist/index.cjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embarkai/ui-kit",
3
- "version": "0.4.106",
3
+ "version": "0.4.108",
4
4
  "description": "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",