@embarkai/ui-kit 0.4.107 → 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.107</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.107";
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;
@@ -17329,14 +17355,6 @@ function getConnectFlowType(params) {
17329
17355
  if (!isEmbarkAI) return "auth";
17330
17356
  return connectFlow;
17331
17357
  }
17332
- function someInErrorChain(error, predicate) {
17333
- let current = error;
17334
- for (let depth = 0; current && depth < 10; depth++) {
17335
- if (predicate(current)) return true;
17336
- current = current.cause;
17337
- }
17338
- return false;
17339
- }
17340
17358
  function ConnectExternalWalletMenu() {
17341
17359
  const { config, callbacksRef } = useProviderConfig();
17342
17360
  const allowedWallets = config.current?.wallet?.allowedWallets;
@@ -17510,6 +17528,7 @@ function ConnectExternalWalletMenu() {
17510
17528
  if (!isRequestPending && connectFlowType !== "connect" && wagmiConfig3.state.connections.has(connector.uid)) {
17511
17529
  disconnect({ connector });
17512
17530
  }
17531
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17513
17532
  const errorMessage = isRequestPending ? (
17514
17533
  // @ts-expect-error i18n typing
17515
17534
  t("passport:connectMenu.requestPending", { wallet: connector.name })
@@ -17666,7 +17685,7 @@ function ConnectExternalWalletMenu() {
17666
17685
  ] })
17667
17686
  ] });
17668
17687
  }
17669
- 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;
17670
17689
  var init_ConnectExternalWalletMenu = __esm({
17671
17690
  "src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx"() {
17672
17691
  init_ProviderContext();
@@ -17674,6 +17693,7 @@ var init_ConnectExternalWalletMenu = __esm({
17674
17693
  init_useOpenPage();
17675
17694
  init_i18n();
17676
17695
  init_wallets();
17696
+ init_connect_errors();
17677
17697
  init_linkedProfiles();
17678
17698
  import_react_query25 = require("@tanstack/react-query");
17679
17699
  import_lucide_react33 = require("lucide-react");
@@ -17693,9 +17713,6 @@ var init_ConnectExternalWalletMenu = __esm({
17693
17713
  init_useHasInjectedWallet();
17694
17714
  import_jsx_runtime74 = require("react/jsx-runtime");
17695
17715
  SIGN_FALLBACK_CHAIN_ID = import_chains.mainnet.id;
17696
- REQUEST_PENDING_ERROR_CODE = -32002;
17697
- isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
17698
- isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
17699
17716
  }
17700
17717
  });
17701
17718
 
@@ -17704,6 +17721,7 @@ function useExternalWalletConnnect(options) {
17704
17721
  const { onSuccess, onError } = options || {};
17705
17722
  const { config } = useProviderConfig();
17706
17723
  const walletMode = config.current?.wallet?.mode;
17724
+ const wagmiConfig3 = (0, import_wagmi4.useConfig)();
17707
17725
  const connectors = (0, import_wagmi4.useConnectors)();
17708
17726
  const { mutate: disconnect } = (0, import_wagmi4.useDisconnect)();
17709
17727
  const { mutate: connect, ...restUseConnect } = (0, import_wagmi4.useConnect)({
@@ -17720,6 +17738,7 @@ function useExternalWalletConnnect(options) {
17720
17738
  useLayoutStore.getState().setIsDialogForced(false);
17721
17739
  },
17722
17740
  onError: (error, { connector }) => {
17741
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17723
17742
  onError?.({
17724
17743
  connected: false,
17725
17744
  connector: connector?.name || "Unknown Wallet",
@@ -17767,6 +17786,7 @@ var init_useExternalWalletConnect = __esm({
17767
17786
  import_react47 = require("react");
17768
17787
  import_wagmi4 = require("wagmi");
17769
17788
  init_useLayoutStore();
17789
+ init_connect_errors();
17770
17790
  init_useExternalWalletStore();
17771
17791
  }
17772
17792
  });
@@ -30021,7 +30041,7 @@ var init_package = __esm({
30021
30041
  "package.json"() {
30022
30042
  package_default = {
30023
30043
  name: "@embarkai/ui-kit",
30024
- version: "0.4.107",
30044
+ version: "0.4.108",
30025
30045
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
30026
30046
  type: "module",
30027
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() {
@@ -17292,14 +17318,6 @@ function getConnectFlowType(params) {
17292
17318
  if (!isEmbarkAI) return "auth";
17293
17319
  return connectFlow;
17294
17320
  }
17295
- function someInErrorChain(error, predicate) {
17296
- let current = error;
17297
- for (let depth = 0; current && depth < 10; depth++) {
17298
- if (predicate(current)) return true;
17299
- current = current.cause;
17300
- }
17301
- return false;
17302
- }
17303
17321
  function ConnectExternalWalletMenu() {
17304
17322
  const { config, callbacksRef } = useProviderConfig();
17305
17323
  const allowedWallets = config.current?.wallet?.allowedWallets;
@@ -17473,6 +17491,7 @@ function ConnectExternalWalletMenu() {
17473
17491
  if (!isRequestPending && connectFlowType !== "connect" && wagmiConfig3.state.connections.has(connector.uid)) {
17474
17492
  disconnect({ connector });
17475
17493
  }
17494
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17476
17495
  const errorMessage = isRequestPending ? (
17477
17496
  // @ts-expect-error i18n typing
17478
17497
  t("passport:connectMenu.requestPending", { wallet: connector.name })
@@ -17629,7 +17648,7 @@ function ConnectExternalWalletMenu() {
17629
17648
  ] })
17630
17649
  ] });
17631
17650
  }
17632
- var SIGN_FALLBACK_CHAIN_ID, REQUEST_PENDING_ERROR_CODE, isRequestPendingError, isUnsupportedChainError;
17651
+ var SIGN_FALLBACK_CHAIN_ID;
17633
17652
  var init_ConnectExternalWalletMenu = __esm({
17634
17653
  "src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx"() {
17635
17654
  init_ProviderContext();
@@ -17637,6 +17656,7 @@ var init_ConnectExternalWalletMenu = __esm({
17637
17656
  init_useOpenPage();
17638
17657
  init_i18n();
17639
17658
  init_wallets();
17659
+ init_connect_errors();
17640
17660
  init_linkedProfiles();
17641
17661
  init_common();
17642
17662
  init_wallet();
@@ -17650,19 +17670,17 @@ var init_ConnectExternalWalletMenu = __esm({
17650
17670
  init_useConnectExternalWalletMenuParams();
17651
17671
  init_useHasInjectedWallet();
17652
17672
  SIGN_FALLBACK_CHAIN_ID = mainnet.id;
17653
- REQUEST_PENDING_ERROR_CODE = -32002;
17654
- isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
17655
- isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
17656
17673
  }
17657
17674
  });
17658
17675
 
17659
17676
  // src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
17660
17677
  import { useCallback as useCallback18 } from "react";
17661
- import { useConnect as useConnect2, useConnectors as useConnectors2, useDisconnect as useDisconnect3 } from "wagmi";
17678
+ import { useConfig as useConfig2, useConnect as useConnect2, useConnectors as useConnectors2, useDisconnect as useDisconnect3 } from "wagmi";
17662
17679
  function useExternalWalletConnnect(options) {
17663
17680
  const { onSuccess, onError } = options || {};
17664
17681
  const { config } = useProviderConfig();
17665
17682
  const walletMode = config.current?.wallet?.mode;
17683
+ const wagmiConfig3 = useConfig2();
17666
17684
  const connectors = useConnectors2();
17667
17685
  const { mutate: disconnect } = useDisconnect3();
17668
17686
  const { mutate: connect, ...restUseConnect } = useConnect2({
@@ -17679,6 +17697,7 @@ function useExternalWalletConnnect(options) {
17679
17697
  useLayoutStore.getState().setIsDialogForced(false);
17680
17698
  },
17681
17699
  onError: (error, { connector }) => {
17700
+ dropFailedConnectorSession(error, connector, wagmiConfig3);
17682
17701
  onError?.({
17683
17702
  connected: false,
17684
17703
  connector: connector?.name || "Unknown Wallet",
@@ -17723,6 +17742,7 @@ var init_useExternalWalletConnect = __esm({
17723
17742
  "src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
17724
17743
  init_ProviderContext();
17725
17744
  init_useLayoutStore();
17745
+ init_connect_errors();
17726
17746
  init_useExternalWalletStore();
17727
17747
  }
17728
17748
  });
@@ -29922,7 +29942,7 @@ var init_package = __esm({
29922
29942
  "package.json"() {
29923
29943
  package_default = {
29924
29944
  name: "@embarkai/ui-kit",
29925
- version: "0.4.107",
29945
+ version: "0.4.108",
29926
29946
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
29927
29947
  type: "module",
29928
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.107",
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",