@openfort/react 0.0.3 → 0.0.4

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/build/index.es.js CHANGED
@@ -22,7 +22,7 @@ import { createSiweMessage } from 'viem/siwe';
22
22
  import { signMessage } from '@wagmi/core';
23
23
  import { useQuery, useQueryClient } from '@tanstack/react-query';
24
24
 
25
- const OPENFORTKIT_VERSION = '0.0.3';
25
+ const OPENFORT_VERSION = '0.0.4';
26
26
 
27
27
  var OpenfortErrorType;
28
28
  (function (OpenfortErrorType) {
@@ -94,7 +94,7 @@ const defaultConnectors = ({ app, walletConnectProjectId, coinbaseWalletPreferen
94
94
  // OLD_TODO: Move these to a provider rather than global variable
95
95
  let globalAppName;
96
96
  const getAppName = () => globalAppName;
97
- const defaultConfig = ({ appName = 'OpenfortKit', appIcon, appDescription, appUrl, walletConnectProjectId, coinbaseWalletPreference, chains = [mainnet, polygon, optimism, arbitrum], client, ...props }) => {
97
+ const defaultConfig = ({ appName = 'Openfort', appIcon, appDescription, appUrl, walletConnectProjectId, coinbaseWalletPreference, chains = [mainnet, polygon, optimism, arbitrum], client, ...props }) => {
98
98
  var _a, _b;
99
99
  globalAppName = appName;
100
100
  // OLD_TODO: nice to have, automate transports based on chains, but for now just provide public if not provided
@@ -109,7 +109,7 @@ const defaultConfig = ({ appName = 'OpenfortKit', appIcon, appDescription, appUr
109
109
  walletConnectProjectId,
110
110
  coinbaseWalletPreference,
111
111
  });
112
- // console.log("OPENFORTKIT CHAINS", chains, transports);
112
+ // console.log("OPENFORT CHAINS", chains, transports);
113
113
  const config = {
114
114
  ...props,
115
115
  chains,
@@ -788,7 +788,7 @@ const socialProviders = [
788
788
  AuthProvider.FACEBOOK,
789
789
  ];
790
790
 
791
- const OpenfortKitContext = createContext(null);
791
+ const Openfortcontext = createContext(null);
792
792
 
793
793
  function useChainIsSupported(chainId) {
794
794
  const { chains } = useConfig();
@@ -868,10 +868,10 @@ function useThemeFont(theme) {
868
868
  useGoogleFont(font !== null && font !== void 0 ? font : '');
869
869
  }
870
870
 
871
- const useOpenfortKit = () => {
872
- const context = React.useContext(OpenfortKitContext);
871
+ const useOpenfort = () => {
872
+ const context = React.useContext(Openfortcontext);
873
873
  if (!context)
874
- throw Error('OpenfortKit Hook must be inside a Provider.');
874
+ throw Error('Openfort Hook must be inside a Provider.');
875
875
  return context;
876
876
  };
877
877
 
@@ -880,7 +880,7 @@ const useOpenfortKit = () => {
880
880
  * additional functionality.
881
881
  */
882
882
  function useConnect({ ...props } = {}) {
883
- const context = useOpenfortKit();
883
+ const context = useOpenfort();
884
884
  const { connect, connectAsync, connectors, ...rest } = useConnect$1({
885
885
  ...props,
886
886
  mutation: {
@@ -997,7 +997,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
997
997
  const { address } = useAccount();
998
998
  const [user, setUser] = useState(null);
999
999
  const { disconnect } = useDisconnect();
1000
- const { walletConfig } = useOpenfortKit();
1000
+ const { walletConfig } = useOpenfort();
1001
1001
  const automaticRecovery = walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC;
1002
1002
  // ---- Openfort instance ----
1003
1003
  const openfort = useMemo(() => {
@@ -1207,7 +1207,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1207
1207
  * When using rollup with styled-components to build into an ES module, styled components decides to move all of it’s DOM elements into "styled.default" rather than just within "styled"
1208
1208
  *
1209
1209
  * We're unsure as to why this issue occurs, if you have any ideas or a better solution please let us know by opening a discussion on our GitHub repo:
1210
- * https://github.com/openfort-xyz/openfort-kit/discussions/new
1210
+ * https://github.com/openfort-xyz/openfort-react/discussions/new
1211
1211
  *
1212
1212
  */
1213
1213
  var styled = typeof styled$1.div === 'function' ? styled$1 : styled$1['default'];
@@ -2343,7 +2343,7 @@ const ResetContainer = styled(motion.div) `
2343
2343
 
2344
2344
  const Portal = (props) => {
2345
2345
  props = {
2346
- selector: '__CONNECTKIT__',
2346
+ selector: '__OPENFORT__',
2347
2347
  ...props,
2348
2348
  };
2349
2349
  const { selector, children } = props;
@@ -2355,7 +2355,7 @@ const Portal = (props) => {
2355
2355
  if (!ref.current) {
2356
2356
  const div = document.createElement('div');
2357
2357
  div.setAttribute('id', selector);
2358
- div.setAttribute('data-openfortkit', `${OPENFORTKIT_VERSION}`);
2358
+ div.setAttribute('data-openfort-react', `${OPENFORT_VERSION}`);
2359
2359
  document.body.appendChild(div);
2360
2360
  ref.current = div;
2361
2361
  }
@@ -3026,7 +3026,7 @@ styled(motion.div) `
3026
3026
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3027
3027
  function useLockBodyScroll(initialLocked) {
3028
3028
  const [locked, setLocked] = useState(initialLocked);
3029
- const context = useOpenfortKit();
3029
+ const context = useOpenfort();
3030
3030
  useIsomorphicLayoutEffect(() => {
3031
3031
  var _a;
3032
3032
  if (!locked)
@@ -4410,7 +4410,7 @@ export const keys = {
4410
4410
 
4411
4411
  function useLocales(replacements) {
4412
4412
  var _a, _b;
4413
- const context = useOpenfortKit();
4413
+ const context = useOpenfort();
4414
4414
  const language = (_b = (_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.language) !== null && _b !== void 0 ? _b : 'en-US';
4415
4415
  const translations = useMemo(() => {
4416
4416
  return getLocale(language);
@@ -4487,7 +4487,7 @@ const useWallet$1 = (id) => {
4487
4487
  };
4488
4488
  const useWallets$1 = () => {
4489
4489
  const connectors = useConnectors();
4490
- const context = useOpenfortKit();
4490
+ const context = useOpenfort();
4491
4491
  const wallets = connectors.map((connector) => {
4492
4492
  var _a, _b;
4493
4493
  // use overrides
@@ -4772,7 +4772,7 @@ const contentVariants$2 = {
4772
4772
  };
4773
4773
  const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onBack, onInfo, }) => {
4774
4774
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4775
- const context = useOpenfortKit();
4775
+ const context = useOpenfort();
4776
4776
  const themeContext = useThemeContext();
4777
4777
  const mobile = isMobile();
4778
4778
  const wallet = useWallet$1((_a = context.connector) === null || _a === void 0 ? void 0 : _a.id);
@@ -5681,7 +5681,7 @@ const About = () => {
5681
5681
  const locales = useLocales({
5682
5682
  //CONNECTORNAME: connector.name,
5683
5683
  });
5684
- const context = useOpenfortKit();
5684
+ const context = useOpenfort();
5685
5685
  const ctaUrl = (_b = (_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.ethereumOnboardingUrl) !== null && _b !== void 0 ? _b : locales.aboutScreen_ctaUrl;
5686
5686
  const [ready, setReady] = useState(true);
5687
5687
  const [slider, setSlider] = useState(0);
@@ -6376,7 +6376,7 @@ const ConnectorsContainer = styled.div `
6376
6376
  function useWalletConnectUri({ enabled } = {
6377
6377
  enabled: true,
6378
6378
  }) {
6379
- const { log } = useOpenfortKit();
6379
+ const { log } = useOpenfort();
6380
6380
  const [uri, setUri] = useState(undefined);
6381
6381
  const connector = useWalletConnectConnector();
6382
6382
  const { isConnected } = useAccount();
@@ -6790,7 +6790,7 @@ const useLastConnector = () => {
6790
6790
 
6791
6791
  const ConnectorList = () => {
6792
6792
  var _a;
6793
- const context = useOpenfortKit();
6793
+ const context = useOpenfort();
6794
6794
  const isMobile = useIsMobile();
6795
6795
  const wallets = useWallets$1();
6796
6796
  const { lastConnectorId } = useLastConnector();
@@ -6802,14 +6802,14 @@ const ConnectorList = () => {
6802
6802
  ...wallets.filter((wallet) => lastConnectorId === wallet.connector.id && wallet.id !== embeddedWalletId),
6803
6803
  ...wallets.filter((wallet) => lastConnectorId !== wallet.connector.id && wallet.id !== embeddedWalletId),
6804
6804
  ];
6805
- return (jsxs(ScrollArea, { mobileDirection: 'horizontal', children: [walletsToDisplay.length === 0 && (jsx(Alert, { error: true, children: "No connectors found in OpenfortKit config." })), walletsToDisplay.length > 0 && (jsx(ConnectorsContainer, { "$mobile": isMobile, "$totalResults": walletsToDisplay.length, children: walletsToDisplay.map((wallet) => jsx(ConnectorItem, { wallet: wallet, isRecent: wallet.id === lastConnectorId }, wallet.id)) }))] }));
6805
+ return (jsxs(ScrollArea, { mobileDirection: 'horizontal', children: [walletsToDisplay.length === 0 && (jsx(Alert, { error: true, children: "No connectors found in Openfort config." })), walletsToDisplay.length > 0 && (jsx(ConnectorsContainer, { "$mobile": isMobile, "$totalResults": walletsToDisplay.length, children: walletsToDisplay.map((wallet) => jsx(ConnectorItem, { wallet: wallet, isRecent: wallet.id === lastConnectorId }, wallet.id)) }))] }));
6806
6806
  };
6807
6807
  const ConnectorItem = ({ wallet, isRecent, }) => {
6808
6808
  var _a, _b, _c, _d;
6809
6809
  const { connect: { getUri }, } = useWeb3();
6810
6810
  const uri = getUri();
6811
6811
  const isMobile = useIsMobile();
6812
- const context = useOpenfortKit();
6812
+ const context = useOpenfort();
6813
6813
  const { connect } = useConnect();
6814
6814
  /*
6815
6815
  const [ready, setReady] = useState(false);
@@ -6851,7 +6851,7 @@ const ConnectorItem = ({ wallet, isRecent, }) => {
6851
6851
 
6852
6852
  const Wallets = () => {
6853
6853
  var _a, _b;
6854
- const context = useOpenfortKit();
6854
+ const context = useOpenfort();
6855
6855
  const locales = useLocales({});
6856
6856
  const isMobile = useIsMobile();
6857
6857
  return (jsxs(PageContent, { style: { width: 312 }, children: [jsx(ConnectorList, {}), isMobile ? (jsx(Fragment, { children: jsxs(InfoBox, { children: [jsxs(ModalContent, { style: { padding: 0, textAlign: 'left' }, children: [jsx(ModalH1, { "$small": true, children: locales.connectorsScreen_h1 }), jsx(ModalBody, { children: locales.connectorsScreen_p })] }), jsxs(InfoBoxButtons, { children: [!((_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.hideQuestionMarkCTA) && (jsx(Button, { variant: 'tertiary', onClick: () => context.setRoute(routes.ABOUT), children: locales.learnMore })), !((_b = context.uiConfig) === null || _b === void 0 ? void 0 : _b.hideNoWalletCTA) && (jsx(Button, { variant: 'tertiary', onClick: () => context.setRoute(routes.ONBOARDING), children: locales.getWallet }))] })] }) })) : (jsx(Fragment, {}))] }));
@@ -7084,7 +7084,7 @@ const TooltipTail = styled(motion.div) `
7084
7084
 
7085
7085
  const Tooltip = ({ children, message, open, xOffset = 0, yOffset = 0, delay, }) => {
7086
7086
  var _a;
7087
- const context = useOpenfortKit();
7087
+ const context = useOpenfort();
7088
7088
  const themeContext = useThemeContext();
7089
7089
  if ((_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.hideTooltips)
7090
7090
  return jsx(Fragment, { children: children });
@@ -7265,7 +7265,7 @@ CustomQRCode.displayName = 'CustomQRCode';
7265
7265
 
7266
7266
  const DownloadApp = () => {
7267
7267
  var _a, _b, _c;
7268
- const context = useOpenfortKit();
7268
+ const context = useOpenfort();
7269
7269
  const wallet = useWallet$1(context.connector.id);
7270
7270
  const locales = useLocales({
7271
7271
  CONNECTORNAME: wallet === null || wallet === void 0 ? void 0 : wallet.name,
@@ -7346,7 +7346,7 @@ const WalletList = styled.div `
7346
7346
  const Container$6 = styled.div ``;
7347
7347
 
7348
7348
  function useWalletConnectModal() {
7349
- const { log } = useOpenfortKit();
7349
+ const { log } = useOpenfort();
7350
7350
  const { connectAsync, connectors } = useConnect();
7351
7351
  const [isOpen, setIsOpen] = useState(false);
7352
7352
  return {
@@ -7506,7 +7506,7 @@ const CopyToClipboard = ({ string, children, variant }) => {
7506
7506
  const MoreIcon = (jsx("svg", { width: "60", height: "60", viewBox: "0 0 60 60", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M30 42V19M19 30.5H42", stroke: "var(--ck-body-color-muted)", strokeWidth: "3", strokeLinecap: "round" }) }));
7507
7507
  const MobileConnectors = () => {
7508
7508
  var _a, _b;
7509
- const context = useOpenfortKit();
7509
+ const context = useOpenfort();
7510
7510
  const locales = useLocales();
7511
7511
  const { connect: { getUri }, } = useWeb3();
7512
7512
  const wcUri = getUri();
@@ -7733,7 +7733,7 @@ var wave = (jsxs("svg", { "aria-hidden": "true", width: "298", height: "188", vi
7733
7733
 
7734
7734
  const Introduction = () => {
7735
7735
  var _a, _b;
7736
- const context = useOpenfortKit();
7736
+ const context = useOpenfort();
7737
7737
  const locales = useLocales({});
7738
7738
  const ctaUrl = (_b = (_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.walletOnboardingUrl) !== null && _b !== void 0 ? _b : locales.onboardingScreen_ctaUrl;
7739
7739
  return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.ImToken, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsxs(ModalContent, { style: { paddingBottom: 18 }, children: [jsx(ModalH1, { "$small": true, children: locales.onboardingScreen_h1 }), jsx(ModalBody, { children: locales.onboardingScreen_p })] }), jsx(Button, { href: ctaUrl, arrow: true, children: locales.onboardingScreen_ctaText })] }));
@@ -7885,7 +7885,7 @@ function useEnsFallbackConfig() {
7885
7885
  const Avatar = ({ address, name, size = 96, radius = 96 }) => {
7886
7886
  var _a, _b, _c;
7887
7887
  const isMounted = useIsMounted();
7888
- const context = useOpenfortKit();
7888
+ const context = useOpenfort();
7889
7889
  const imageRef = useRef(null);
7890
7890
  const [loaded, setLoaded] = useState(true);
7891
7891
  const ensFallbackConfig = useEnsFallbackConfig();
@@ -8708,7 +8708,7 @@ const ChainSelectList = ({ variant, }) => {
8708
8708
  switchChain({ chainId });
8709
8709
  }
8710
8710
  };
8711
- const { triggerResize } = useOpenfortKit();
8711
+ const { triggerResize } = useOpenfort();
8712
8712
  return (jsxs(SwitchNetworksContainer, { style: { marginBottom: switchChain !== undefined ? -8 : 0 }, children: [jsx(ChainButtonContainer, { children: jsx(ChainButtons, { children: chains.map((x) => {
8713
8713
  var _a;
8714
8714
  const c = chainConfigs.find((ch) => ch.id === x.id);
@@ -8831,7 +8831,7 @@ const DropdownHeading = styled(motion.div) `
8831
8831
 
8832
8832
  const ChainSelectDropdown = ({ children, open, onClose, offsetX = 0, offsetY = 8 }) => {
8833
8833
  var _a, _b, _c, _d;
8834
- const context = useOpenfortKit();
8834
+ const context = useOpenfort();
8835
8835
  const themeContext = useThemeContext();
8836
8836
  const locales = useLocales();
8837
8837
  const [offset, setOffset] = useState({ x: 0, y: 0 });
@@ -9077,7 +9077,7 @@ const SwitchChainButton = styled(motion.button) `
9077
9077
  `;
9078
9078
  const ChevronDown = ({ ...props }) => (jsx("svg", { "aria-hidden": "true", width: "11", height: "6", viewBox: "0 0 11 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: jsx("path", { d: "M1.5 1L5.5 5L9.5 1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
9079
9079
  const ChainSelector = () => {
9080
- const context = useOpenfortKit();
9080
+ const context = useOpenfort();
9081
9081
  const [isOpen, setIsOpen] = useState(false);
9082
9082
  const { chain } = useAccount();
9083
9083
  const { chains } = useSwitchChain();
@@ -9102,7 +9102,7 @@ const ChainSelector = () => {
9102
9102
 
9103
9103
  const PoweredByFooter = ({ showDisclaimer }) => {
9104
9104
  var _a, _b;
9105
- const { uiConfig: options } = useOpenfortKit();
9105
+ const { uiConfig: options } = useOpenfort();
9106
9106
  return (jsxs(Container$3, { children: [showDisclaimer && (jsx(Disclaimer, { children: (options === null || options === void 0 ? void 0 : options.disclaimer) ? (jsx(Fragment, { children: options.disclaimer })) : (jsxs("div", { children: ["By logging in, you agree to our ", jsx("a", { href: (_a = options === null || options === void 0 ? void 0 : options.termsOfServiceUrl) !== null && _a !== void 0 ? _a : "https://www.openfort.xyz/terms", target: "_blank", rel: "noopener noreferrer", children: "Terms of Service" }), " & ", jsx("a", { href: (_b = options === null || options === void 0 ? void 0 : options.privacyPolicyUrl) !== null && _b !== void 0 ? _b : "https://www.openfort.xyz/privacy", target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }), "."] })) })), jsxs(TextButton, { onClick: () => {
9107
9107
  window.open("https://www.openfort.xyz/", "_blank");
9108
9108
  }, children: [jsx("span", { children: "Powered by" }), jsx(IconContainer$2, { children: jsx(Logos.Openfort, {}) }), jsx("span", { children: "Openfort" })] })] }));
@@ -9201,7 +9201,7 @@ var Wallet = ({ ...props }) => {
9201
9201
 
9202
9202
  function useProviders() {
9203
9203
  const { user } = useOpenfortCore();
9204
- const { uiConfig: options } = useOpenfortKit();
9204
+ const { uiConfig: options } = useOpenfort();
9205
9205
  const allProviders = (options === null || options === void 0 ? void 0 : options.authProviders) || [];
9206
9206
  const providers = allProviders.filter(p => p !== AuthProvider.GUEST) || [];
9207
9207
  const linkedProviders = user ? providers.filter(p => { var _a; return (_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find(a => a.provider === p); }) : [];
@@ -9310,7 +9310,7 @@ const LinkedProvider = ({ provider }) => {
9310
9310
  return (jsx(LinkedProviderButton, { disabled: true, children: jsx(ProviderIcon$1, { children: jsx(ProviderIcon, { provider: provider }) }) }));
9311
9311
  };
9312
9312
  const AddLinkedProviderButton = () => {
9313
- const { setRoute } = useOpenfortKit();
9313
+ const { setRoute } = useOpenfort();
9314
9314
  const { availableProviders: unlinkedProviders } = useProviders();
9315
9315
  return (jsx(LinkedProviderButton, { disabled: unlinkedProviders.length === 0, onClick: () => setRoute(routes.PROVIDERS), children: "+" }));
9316
9316
  };
@@ -9324,7 +9324,7 @@ const LinkedProviders = () => {
9324
9324
 
9325
9325
  const Profile = ({ closeModal }) => {
9326
9326
  var _a, _b, _c, _d;
9327
- const context = useOpenfortKit();
9327
+ const context = useOpenfort();
9328
9328
  const themeContext = useThemeContext();
9329
9329
  const locales = useLocales();
9330
9330
  const { address, isConnected, connector, chain } = useAccount();
@@ -9749,11 +9749,10 @@ const createSIWEMessage = (address, nonce, chainId) => createSiweMessage({
9749
9749
 
9750
9750
  function useConnectWithSiwe() {
9751
9751
  const { client, user, updateUser } = useOpenfortCore();
9752
- const { log } = useOpenfortKit();
9753
- const { address } = useAccount();
9752
+ const { log } = useOpenfort();
9753
+ const { address, connector } = useAccount();
9754
9754
  const chainId = useChainId();
9755
9755
  const config = useConfig();
9756
- const { connector } = useAccount();
9757
9756
  const connectWithSiwe = useCallback(async ({ onError, onConnect, }) => {
9758
9757
  const connectorType = connector === null || connector === void 0 ? void 0 : connector.type;
9759
9758
  const walletClientType = connector === null || connector === void 0 ? void 0 : connector.id;
@@ -9843,7 +9842,7 @@ const contentVariants$1 = {
9843
9842
  const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
9844
9843
  var _a, _b, _c, _d, _e, _f, _g, _h;
9845
9844
  const openfort = useOpenfortCore();
9846
- const { log, setOpen } = useOpenfortKit();
9845
+ const { log, setOpen } = useOpenfort();
9847
9846
  const { isConnected } = useAccount();
9848
9847
  const { disconnect } = useDisconnect();
9849
9848
  const connectWithSiwe = useConnectWithSiwe();
@@ -9926,7 +9925,7 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
9926
9925
  },
9927
9926
  },
9928
9927
  });
9929
- const { triggerResize, connector: c } = useOpenfortKit();
9928
+ const { triggerResize, connector: c } = useOpenfort();
9930
9929
  const id = c.id;
9931
9930
  const wallet = useWallet$1(id);
9932
9931
  const walletInfo = {
@@ -10054,7 +10053,7 @@ const ScanIconWithLogos = ({ logo }) => {
10054
10053
 
10055
10054
  const ConnectWithQRCode = ({ switchConnectMethod }) => {
10056
10055
  var _a, _b, _c, _d, _e, _f, _g, _h;
10057
- const context = useOpenfortKit();
10056
+ const context = useOpenfort();
10058
10057
  const id = context.connector.id;
10059
10058
  const wallet = useWallet$1(context.connector.id);
10060
10059
  const { open: openW3M, isOpen: isOpenW3M } = useWalletConnectModal();
@@ -10080,7 +10079,7 @@ const ConnectWithQRCode = ({ switchConnectMethod }) => {
10080
10079
  const hasApps = downloads && Object.keys(downloads).length !== 0;
10081
10080
  const connectWithSiwe = useConnectWithSiwe();
10082
10081
  const { isConnected } = useAccount();
10083
- const { log, setOpen } = useOpenfortKit();
10082
+ const { log, setOpen } = useOpenfort();
10084
10083
  const { disconnect } = useDisconnect();
10085
10084
  const [isFirstFrame, setIsFirstFrame] = React.useState(true);
10086
10085
  useEffect(() => {
@@ -10175,8 +10174,8 @@ const ConnectingAnimation = styled(motion.div) `
10175
10174
  `}
10176
10175
  `;
10177
10176
  const Loader = ({ reason, isLoading = true, icon }) => {
10178
- const { uiConfig: options } = useOpenfortKit();
10179
- const { triggerResize } = useOpenfortKit();
10177
+ const { uiConfig: options } = useOpenfort();
10178
+ const { triggerResize } = useOpenfort();
10180
10179
  useEffect(() => {
10181
10180
  return () => triggerResize();
10182
10181
  }, []);
@@ -10205,7 +10204,7 @@ const states$1 = {
10205
10204
  CONNECTING: "connecting",
10206
10205
  };
10207
10206
  const ConnectWithOAuth = ({}) => {
10208
- const { connector, setRoute, log } = useOpenfortKit();
10207
+ const { connector, setRoute, log } = useOpenfort();
10209
10208
  const { client, user } = useOpenfortCore();
10210
10209
  const [status, setStatus] = useState(states$1.INIT);
10211
10210
  useEffect(() => {
@@ -10302,7 +10301,7 @@ const states = {
10302
10301
  INJECTOR: 'injector',
10303
10302
  };
10304
10303
  const ConnectUsing = () => {
10305
- const context = useOpenfortKit();
10304
+ const context = useOpenfort();
10306
10305
  const wallet = useWallet$1(context.connector.id);
10307
10306
  // If cannot be scanned, display injector flow, which if extension is not installed will show CTA to install it
10308
10307
  const isQrCode = !(wallet === null || wallet === void 0 ? void 0 : wallet.isInstalled) && (wallet === null || wallet === void 0 ? void 0 : wallet.getWalletConnectDeeplink);
@@ -10467,7 +10466,7 @@ const textVariants$2 = {
10467
10466
  const EmailLogin = () => {
10468
10467
  const [email, setEmail] = React.useState("");
10469
10468
  const [password, setPassword] = React.useState("");
10470
- const { setRoute, log } = useOpenfortKit();
10469
+ const { setRoute, log } = useOpenfort();
10471
10470
  const { client } = useOpenfortCore();
10472
10471
  const [loginLoading, setLoginLoading] = React.useState(false);
10473
10472
  const [loginError, setLoginError] = React.useState(false);
@@ -10510,7 +10509,7 @@ const EmailSignup = () => {
10510
10509
  const [email, setEmail] = React.useState("");
10511
10510
  const [password, setPassword] = React.useState("");
10512
10511
  const [username, setUsername] = React.useState("");
10513
- const { setRoute, triggerResize, log, uiConfig: options } = useOpenfortKit();
10512
+ const { setRoute, triggerResize, log, uiConfig: options } = useOpenfort();
10514
10513
  const { client } = useOpenfortCore();
10515
10514
  const [signupLoading, setSignupLoading] = React.useState(false);
10516
10515
  const [signupError, setSignupError] = React.useState(false);
@@ -10558,7 +10557,7 @@ const EmailSignup = () => {
10558
10557
 
10559
10558
  const EmailVerification = () => {
10560
10559
  const { client } = useOpenfortCore();
10561
- const { setRoute, log } = useOpenfortKit();
10560
+ const { setRoute, log } = useOpenfort();
10562
10561
  const [loading, setLoading] = useState(true);
10563
10562
  const [shouldSendEmailVerification, setShouldSendEmailVerification] = useState(false);
10564
10563
  const emailInStorage = useMemo(() => localStorage.getItem(emailToVerifyLocalStorageKey), []);
@@ -10649,7 +10648,7 @@ const EmailVerification = () => {
10649
10648
  // TODO: Localize
10650
10649
  const RequestEmail = () => {
10651
10650
  const [email, setEmail] = React.useState("");
10652
- const { log, triggerResize } = useOpenfortKit();
10651
+ const { log, triggerResize } = useOpenfort();
10653
10652
  const { client } = useOpenfortCore();
10654
10653
  const [loading, setLoading] = React.useState(false);
10655
10654
  const [message, setMessage] = React.useState("");
@@ -10706,7 +10705,7 @@ const ResetPassword = () => {
10706
10705
  const fixedUrl = window.location.href.replace("?state=", "&state="); // redirectUrl is not working with query params
10707
10706
  const url = new URL(fixedUrl);
10708
10707
  const [password, setPassword] = React.useState("");
10709
- const { setRoute, triggerResize, log } = useOpenfortKit();
10708
+ const { setRoute, triggerResize, log } = useOpenfort();
10710
10709
  const { client, updateUser } = useOpenfortCore();
10711
10710
  const [loading, setLoading] = React.useState(false);
10712
10711
  const email = url.searchParams.get("email");
@@ -10781,7 +10780,7 @@ const textVariants$1 = {
10781
10780
  const LinkEmail = () => {
10782
10781
  const [email, setEmail] = React.useState("");
10783
10782
  const [password, setPassword] = React.useState("");
10784
- const { setRoute, triggerResize, log } = useOpenfortKit();
10783
+ const { setRoute, triggerResize, log } = useOpenfort();
10785
10784
  const { client, updateUser } = useOpenfortCore();
10786
10785
  const [loginLoading, setLoginLoading] = React.useState(false);
10787
10786
  const [loginError, setLoginError] = React.useState(false);
@@ -10819,7 +10818,7 @@ const LinkEmail = () => {
10819
10818
  };
10820
10819
 
10821
10820
  const Loading = () => {
10822
- const { setRoute, walletConfig } = useOpenfortKit();
10821
+ const { setRoute, walletConfig } = useOpenfort();
10823
10822
  const { isLoading, user, needsRecovery } = useOpenfortCore();
10824
10823
  const { address } = useAccount();
10825
10824
  const [isFirstFrame, setIsFirstFrame] = React.useState(true);
@@ -10865,7 +10864,7 @@ const ProviderButton = ({ children, icon, onClick }) => {
10865
10864
  };
10866
10865
  const GuestButton = () => {
10867
10866
  const { signUpGuest } = useOpenfortCore();
10868
- const { setRoute } = useOpenfortKit();
10867
+ const { setRoute } = useOpenfort();
10869
10868
  const handleClick = () => {
10870
10869
  signUpGuest();
10871
10870
  setRoute(routes.RECOVER);
@@ -10873,16 +10872,16 @@ const GuestButton = () => {
10873
10872
  return (jsx(ProviderButton, { onClick: handleClick, icon: jsx(GuestIcon, {}), children: "Guest" }));
10874
10873
  };
10875
10874
  const WalletButton = () => {
10876
- const { setRoute } = useOpenfortKit();
10875
+ const { setRoute } = useOpenfort();
10877
10876
  return jsx(ProviderButton, { onClick: () => setRoute(routes.CONNECTORS), icon: jsx(Logos.OtherWallets, {}), children: "Wallet" });
10878
10877
  };
10879
10878
  const EmailButton = () => {
10880
- const { setRoute } = useOpenfortKit();
10879
+ const { setRoute } = useOpenfort();
10881
10880
  const { user } = useOpenfortCore();
10882
10881
  return jsx(ProviderButton, { onClick: () => setRoute(user ? routes.LINK_EMAIL : routes.EMAIL_LOGIN), icon: jsx(EmailIcon, {}), children: "Email" });
10883
10882
  };
10884
10883
  const AuthProviderButton = ({ provider, title = provider + " login", icon }) => {
10885
- const { setRoute, setConnector } = useOpenfortKit();
10884
+ const { setRoute, setConnector } = useOpenfort();
10886
10885
  const handleClick = () => {
10887
10886
  setRoute(routes.CONNECT);
10888
10887
  setConnector({ id: provider, type: "oauth" });
@@ -10924,7 +10923,7 @@ const AddressButNoUserCase = () => {
10924
10923
  return (jsx(PageContent, { children: jsx(Loader, { reason: "Updating user" }) }));
10925
10924
  };
10926
10925
  const SocialProvidersButton = () => {
10927
- const { setRoute } = useOpenfortKit();
10926
+ const { setRoute } = useOpenfort();
10928
10927
  return (jsx(ProviderButton, { onClick: () => setRoute(routes.SOCIAL_PROVIDERS), icon: jsx(OtherSocials, {}), children: "Other socials" }));
10929
10928
  };
10930
10929
  const Providers = () => {
@@ -10967,7 +10966,7 @@ const createOpenfortWallet = ({ address, }) => ({
10967
10966
  id: embeddedWalletId,
10968
10967
  isAvailable: true,
10969
10968
  });
10970
- const mapStatus$1 = (status) => {
10969
+ const mapWalletStatus = (status) => {
10971
10970
  return {
10972
10971
  error: status.error,
10973
10972
  isError: status.status === 'error',
@@ -10978,11 +10977,11 @@ const mapStatus$1 = (status) => {
10978
10977
  };
10979
10978
  function useWallets(hookOptions = {}) {
10980
10979
  const { user, embeddedState, client } = useOpenfortCore();
10981
- const { walletConfig, log, setOpen, setRoute, setConnector, uiConfig } = useOpenfortKit();
10980
+ const { walletConfig, log, setOpen, setRoute, setConnector, uiConfig } = useOpenfort();
10982
10981
  const { connector, isConnected, address } = useAccount();
10983
10982
  const chainId = useChainId();
10984
10983
  const deviceWallets = useWallets$1(); // TODO: Map wallets object to be the same as wallets
10985
- const { disconnect } = useDisconnect();
10984
+ const { disconnect, disconnectAsync } = useDisconnect();
10986
10985
  const [status, setStatus] = useState({
10987
10986
  status: "idle",
10988
10987
  });
@@ -11018,8 +11017,6 @@ function useWallets(hookOptions = {}) {
11018
11017
  }
11019
11018
  }
11020
11019
  });
11021
- const usesEmbeddedWallet = user && walletConfig;
11022
- const isEmbedded = embeddedState === EmbeddedState.READY;
11023
11020
  const { data: embeddedWallets, refetch } = useQuery({
11024
11021
  queryKey: ['openfortEmbeddedWalletList'],
11025
11022
  queryFn: () => !!user ? client.embeddedWallet.list() : Promise.resolve([]),
@@ -11044,7 +11041,7 @@ function useWallets(hookOptions = {}) {
11044
11041
  const respJSON = await resp.json();
11045
11042
  return respJSON.session;
11046
11043
  }, [walletConfig]);
11047
- const wallets = useMemo(() => {
11044
+ const rawWallets = useMemo(() => {
11048
11045
  const userWallets = user ? user.linkedAccounts
11049
11046
  .filter((a) => a.provider === AuthProvider.WALLET)
11050
11047
  .map((a) => {
@@ -11067,6 +11064,16 @@ function useWallets(hookOptions = {}) {
11067
11064
  });
11068
11065
  return userWallets;
11069
11066
  }, [user === null || user === void 0 ? void 0 : user.linkedAccounts, embeddedWallets]);
11067
+ const wallets = useMemo(() => {
11068
+ if (!isConnected || !address)
11069
+ return rawWallets;
11070
+ console.log("Mapping wallets", { rawWallets, status, address, isConnected, connector });
11071
+ return rawWallets.map((w) => ({
11072
+ ...w,
11073
+ isConnecting: status.status === 'connecting' && status.address === w.address,
11074
+ isActive: w.address === address && isConnected && (connector === null || connector === void 0 ? void 0 : connector.id) === w.id,
11075
+ }));
11076
+ }, [rawWallets, status, address, isConnected, connector]);
11070
11077
  const activeWallet = isConnected && connector ? wallets.find((w) => w.isActive) : undefined;
11071
11078
  useEffect(() => {
11072
11079
  if (connectToConnector)
@@ -11087,7 +11094,7 @@ function useWallets(hookOptions = {}) {
11087
11094
  connector = wallet.connector;
11088
11095
  }
11089
11096
  else {
11090
- connector = connector;
11097
+ connector = optionsObject.connector;
11091
11098
  }
11092
11099
  if (!connector) {
11093
11100
  log("Connector not found", deviceWallets, optionsObject.connector);
@@ -11097,22 +11104,7 @@ function useWallets(hookOptions = {}) {
11097
11104
  log(`Already connected to ${connector.id} with address ${address}, skipping connection`);
11098
11105
  return { wallet: activeWallet };
11099
11106
  }
11100
- const hasDisconnected = new Promise((resolve) => {
11101
- disconnect(undefined, {
11102
- onSuccess: () => {
11103
- resolve();
11104
- },
11105
- onError: (error) => {
11106
- console.error("Error disconnecting", error);
11107
- // setStatus({
11108
- // status: 'error',
11109
- // error: new Error("Failed to disconnect: " + error),
11110
- // });
11111
- resolve();
11112
- },
11113
- });
11114
- });
11115
- await hasDisconnected;
11107
+ await disconnectAsync();
11116
11108
  if (showUI) {
11117
11109
  const walletToConnect = wallets.find((w) => w.id == connector.id);
11118
11110
  if (!walletToConnect) {
@@ -11178,7 +11170,10 @@ function useWallets(hookOptions = {}) {
11178
11170
  } : {
11179
11171
  recoveryMethod: RecoveryMethod.AUTOMATIC,
11180
11172
  };
11173
+ // Ensure that the embedded wallet is listed
11174
+ const embeddedWallets = await client.embeddedWallet.list();
11181
11175
  log("Recovery params", optionsObject.address);
11176
+ log("Embedded wallets", embeddedWallets, chainId);
11182
11177
  if (optionsObject.address) {
11183
11178
  const walletId = (_a = embeddedWallets === null || embeddedWallets === void 0 ? void 0 : embeddedWallets.find((w) => w.address === optionsObject.address && w.chainId === chainId)) === null || _a === void 0 ? void 0 : _a.id;
11184
11179
  if (!walletId) {
@@ -11195,18 +11190,19 @@ function useWallets(hookOptions = {}) {
11195
11190
  });
11196
11191
  }
11197
11192
  else {
11198
- if (!embeddedWallets || embeddedWallets.length === 0) {
11199
- await createWallet({
11200
- password,
11201
- });
11202
- }
11203
- else {
11193
+ // Check if the embedded wallet is already created in the current chain
11194
+ if (embeddedWallets.some((w) => w.chainId === chainId)) {
11204
11195
  await client.embeddedWallet.recover({
11205
11196
  account: embeddedWallets[0].id,
11206
11197
  shieldAuthentication,
11207
11198
  recoveryParams,
11208
11199
  });
11209
11200
  }
11201
+ else {
11202
+ await createWallet({
11203
+ password,
11204
+ });
11205
+ }
11210
11206
  }
11211
11207
  setStatus({
11212
11208
  status: 'success',
@@ -11259,7 +11255,7 @@ function useWallets(hookOptions = {}) {
11259
11255
  });
11260
11256
  }
11261
11257
  return {};
11262
- }, [wallets, setOpen, setRoute, setConnector, disconnect, log, isConnected, address, usesEmbeddedWallet, isEmbedded]);
11258
+ }, [wallets, setOpen, setRoute, setConnector, disconnectAsync, log, address, client, walletConfig, chainId, refetch, hookOptions]);
11263
11259
  const createWallet = useCallback(async ({ password, ...options } = {}) => {
11264
11260
  var _a;
11265
11261
  setStatus({
@@ -11313,17 +11309,53 @@ function useWallets(hookOptions = {}) {
11313
11309
  }
11314
11310
  });
11315
11311
  }, [refetch, client, uiConfig, chainId]);
11312
+ const setRecovery = useCallback(async (params) => {
11313
+ try {
11314
+ setStatus({
11315
+ status: 'loading',
11316
+ });
11317
+ // Set embedded wallet recovery method
11318
+ if (params.recoveryMethod === 'password') {
11319
+ await client.embeddedWallet.setEmbeddedRecovery({
11320
+ recoveryMethod: RecoveryMethod.PASSWORD,
11321
+ recoveryPassword: params.recoveryPassword
11322
+ });
11323
+ }
11324
+ else {
11325
+ await client.embeddedWallet.setEmbeddedRecovery({
11326
+ recoveryMethod: RecoveryMethod.AUTOMATIC
11327
+ });
11328
+ }
11329
+ // Get the updated embedded account
11330
+ const embeddedAccount = await client.embeddedWallet.get();
11331
+ setStatus({ status: 'success' });
11332
+ return onSuccess({
11333
+ hookOptions,
11334
+ options: params,
11335
+ data: {
11336
+ wallet: createOpenfortWallet({
11337
+ address: embeddedAccount.address,
11338
+ }),
11339
+ }
11340
+ });
11341
+ }
11342
+ catch (error) {
11343
+ const errorObj = error instanceof Error ? error : new Error('Failed to set wallet recovery');
11344
+ return onError({
11345
+ hookOptions,
11346
+ options: params,
11347
+ error: new OpenfortError('Failed to set wallet recovery', OpenfortErrorType.WALLET_ERROR, { error: errorObj }),
11348
+ });
11349
+ }
11350
+ }, [client, setStatus, hookOptions]);
11316
11351
  return {
11317
- wallets: wallets.map((w) => ({
11318
- ...w,
11319
- isConnecting: status.status === 'connecting' && status.address === w.address,
11320
- isActive: w.address === address && isConnected && (connector === null || connector === void 0 ? void 0 : connector.id) === w.id,
11321
- })),
11352
+ wallets,
11322
11353
  availableWallets: deviceWallets,
11323
11354
  activeWallet,
11324
- setActiveWallet,
11355
+ setRecovery,
11325
11356
  createWallet,
11326
- ...mapStatus$1(status),
11357
+ setActiveWallet,
11358
+ ...mapWalletStatus(status),
11327
11359
  exportPrivateKey: client.embeddedWallet.exportPrivateKey,
11328
11360
  };
11329
11361
  }
@@ -11332,7 +11364,7 @@ function useWallets(hookOptions = {}) {
11332
11364
  const Recover = () => {
11333
11365
  const [recoveryPhrase, setRecoveryPhrase] = React.useState("");
11334
11366
  const [recoveryError, setRecoveryError] = React.useState(false);
11335
- const { triggerResize, uiConfig: options, log } = useOpenfortKit();
11367
+ const { triggerResize, uiConfig: options, log } = useOpenfort();
11336
11368
  useChainId();
11337
11369
  const [loading, setLoading] = React.useState(false);
11338
11370
  const { setActiveWallet } = useWallets();
@@ -11362,7 +11394,7 @@ const Recover = () => {
11362
11394
  const AutomaticRecovery = () => {
11363
11395
  const { needsRecovery } = useOpenfortCore();
11364
11396
  const { setActiveWallet } = useWallets();
11365
- const { log } = useOpenfortKit();
11397
+ const { log } = useOpenfort();
11366
11398
  const [hasRecoveryMethod, setHasRecoveryMethod] = React.useState(false);
11367
11399
  useEffect(() => {
11368
11400
  (async () => {
@@ -11384,7 +11416,7 @@ const AutomaticRecovery = () => {
11384
11416
  return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up signer" }) }));
11385
11417
  };
11386
11418
  const Connected = () => {
11387
- const { setOpen } = useOpenfortKit();
11419
+ const { setOpen } = useOpenfort();
11388
11420
  // hide on connect
11389
11421
  useEffect(() => {
11390
11422
  setTimeout(() => {
@@ -11395,7 +11427,7 @@ const Connected = () => {
11395
11427
  };
11396
11428
  const CreateEmbeddedSigner = () => {
11397
11429
  const { needsRecovery, user } = useOpenfortCore();
11398
- const { triggerResize, uiConfig, walletConfig, setRoute } = useOpenfortKit();
11430
+ const { triggerResize, uiConfig, walletConfig, setRoute } = useOpenfort();
11399
11431
  const [loading, setLoading] = React.useState(true);
11400
11432
  const [embeddedSignerLoading, setEmbeddedSignerLoading] = React.useState(true);
11401
11433
  const { isConnected } = useAccount();
@@ -11447,7 +11479,7 @@ const SocialProviders = () => {
11447
11479
  const customThemeDefault = {};
11448
11480
  const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customThemeDefault, lang = 'en-US' }) => {
11449
11481
  var _a;
11450
- const context = useOpenfortKit();
11482
+ const context = useOpenfort();
11451
11483
  const { logout, user } = useOpenfortCore();
11452
11484
  const { isConnected, chain } = useAccount();
11453
11485
  const chainIsSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
@@ -11577,7 +11609,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
11577
11609
  };
11578
11610
 
11579
11611
  /**
11580
- * OpenfortProvider component provides context and configuration for OpenfortKit.
11612
+ * OpenfortProvider component provides context and configuration for Openfort.
11581
11613
  * It must be used within a WagmiProvider.
11582
11614
  *
11583
11615
  * @param {React.ReactNode} children - The child components to be wrapped by the provider.
@@ -11599,7 +11631,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11599
11631
  }
11600
11632
  // Only allow for mounting OpenfortProvider once, so we avoid weird global
11601
11633
  // state collisions.
11602
- if (React.useContext(OpenfortKitContext)) {
11634
+ if (React.useContext(Openfortcontext)) {
11603
11635
  throw new Error('Multiple, nested usages of OpenfortProvider detected. Please use only one.');
11604
11636
  }
11605
11637
  const chains = useChains();
@@ -11718,13 +11750,13 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11718
11750
  triggerResize: () => onResize((prev) => prev + 1),
11719
11751
  walletConfig,
11720
11752
  };
11721
- return createElement(OpenfortKitContext.Provider, { value }, jsx(Fragment, { children: jsx(Web3ContextProvider, { enabled: open, children: jsxs(CoreOpenfortProvider, { baseConfiguration: {
11753
+ return createElement(Openfortcontext.Provider, { value }, jsx(Fragment, { children: jsx(Web3ContextProvider, { enabled: open, children: jsxs(CoreOpenfortProvider, { baseConfiguration: {
11722
11754
  publishableKey,
11723
11755
  }, shieldConfiguration: walletConfig ? {
11724
11756
  shieldPublishableKey: walletConfig.shieldPublishableKey,
11725
11757
  shieldEncryptionKey: walletConfig.recoveryMethod === RecoveryMethod.PASSWORD ? walletConfig.shieldEncryptionKey : undefined,
11726
11758
  debug: debugMode,
11727
- } : undefined, overrides: opts.openfortUrlOverrides, debugMode: debugMode, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_j = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _j !== void 0 ? _j : ckMode, customTheme: ckCustomTheme })] }) }) }));
11759
+ } : undefined, overrides: opts.overrides, debugMode: debugMode, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_j = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _j !== void 0 ? _j : ckMode, customTheme: ckCustomTheme })] }) }) }));
11728
11760
  };
11729
11761
 
11730
11762
  const Container$1 = styled(motion.div) `
@@ -11977,7 +12009,7 @@ const allRoutes = [
11977
12009
  ...safeRoutes.disconnected,
11978
12010
  ];
11979
12011
  function useUI() {
11980
- const { open, setOpen, setRoute, log } = useOpenfortKit();
12012
+ const { open, setOpen, setRoute, log } = useOpenfort();
11981
12013
  const { isLoading, user, needsRecovery } = useOpenfortCore();
11982
12014
  const { isConnected } = useAccount();
11983
12015
  function defaultOpen() {
@@ -12102,7 +12134,7 @@ const textVariants = {
12102
12134
  };
12103
12135
  const ConnectButtonRenderer = ({ children, }) => {
12104
12136
  const isMounted = useIsMounted();
12105
- const context = useOpenfortKit();
12137
+ const context = useOpenfort();
12106
12138
  const { open, close, isOpen } = useUI();
12107
12139
  const { address, isConnected, chain } = useAccount();
12108
12140
  const isChainSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
@@ -12135,7 +12167,7 @@ const ConnectButtonRenderer = ({ children, }) => {
12135
12167
  ensName: ensName === null || ensName === void 0 ? void 0 : ensName.toString(),
12136
12168
  }) }));
12137
12169
  };
12138
- ConnectButtonRenderer.displayName = 'OpenfortKitButton.Custom';
12170
+ ConnectButtonRenderer.displayName = 'OpenfortButton.Custom';
12139
12171
  const ConnectedLabel = ({ separator }) => {
12140
12172
  const { user, isLoading } = useOpenfortCore();
12141
12173
  const { address } = useAccount();
@@ -12147,7 +12179,7 @@ const ConnectedLabel = ({ separator }) => {
12147
12179
  return truncateUserId(user.id, separator);
12148
12180
  return "Loading...";
12149
12181
  };
12150
- function OpenfortKitButtonInner({ label, showAvatar, separator, }) {
12182
+ function OpenfortButtonInner({ label, showAvatar, separator, }) {
12151
12183
  const locales = useLocales({});
12152
12184
  const { user } = useOpenfortCore();
12153
12185
  const { address, chain } = useAccount();
@@ -12172,7 +12204,7 @@ function OpenfortKitButtonInner({ label, showAvatar, separator, }) {
12172
12204
  //padding: '0 5px',
12173
12205
  }, children: label ? label : defaultLabel }, "connectWalletText")) }));
12174
12206
  }
12175
- function OpenfortKitButton({
12207
+ function OpenfortButton({
12176
12208
  // Options
12177
12209
  label, showBalance = false, showAvatar = true,
12178
12210
  // Theming
@@ -12181,7 +12213,7 @@ theme, mode, customTheme,
12181
12213
  onClick, }) {
12182
12214
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12183
12215
  const isMounted = useIsMounted();
12184
- const context = useOpenfortKit();
12216
+ const context = useOpenfort();
12185
12217
  const { address, chain } = useAccount();
12186
12218
  const chainIsSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
12187
12219
  const { open } = useUI();
@@ -12234,39 +12266,39 @@ onClick, }) {
12234
12266
  }
12235
12267
  : {
12236
12268
  overflow: 'hidden',
12237
- }, children: jsx(OpenfortKitButtonInner, { separator: separator, showAvatar: showAvatar, label: label }) })] }) }));
12269
+ }, children: jsx(OpenfortButtonInner, { separator: separator, showAvatar: showAvatar, label: label }) })] }) }));
12238
12270
  }
12239
- OpenfortKitButton.Custom = ConnectButtonRenderer;
12240
-
12241
- var OpenfortKitStatus;
12242
- (function (OpenfortKitStatus) {
12243
- OpenfortKitStatus[OpenfortKitStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
12244
- OpenfortKitStatus[OpenfortKitStatus["NEEDS_RECOVERY"] = 1] = "NEEDS_RECOVERY";
12245
- OpenfortKitStatus[OpenfortKitStatus["LOADING"] = 2] = "LOADING";
12246
- OpenfortKitStatus[OpenfortKitStatus["CONNECTED"] = 3] = "CONNECTED";
12247
- })(OpenfortKitStatus || (OpenfortKitStatus = {}));
12271
+ OpenfortButton.Custom = ConnectButtonRenderer;
12272
+
12273
+ var OpenfortStatus;
12274
+ (function (OpenfortStatus) {
12275
+ OpenfortStatus[OpenfortStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
12276
+ OpenfortStatus[OpenfortStatus["NEEDS_RECOVERY"] = 1] = "NEEDS_RECOVERY";
12277
+ OpenfortStatus[OpenfortStatus["LOADING"] = 2] = "LOADING";
12278
+ OpenfortStatus[OpenfortStatus["CONNECTED"] = 3] = "CONNECTED";
12279
+ })(OpenfortStatus || (OpenfortStatus = {}));
12248
12280
  function useStatus() {
12249
12281
  const { embeddedState } = useOpenfortCore();
12250
12282
  const { isConnected, isConnecting } = useAccount();
12251
12283
  const getStatus = () => {
12252
12284
  if (embeddedState === EmbeddedState.READY)
12253
- return OpenfortKitStatus.CONNECTED;
12285
+ return OpenfortStatus.CONNECTED;
12254
12286
  if (embeddedState === EmbeddedState.NONE)
12255
- return OpenfortKitStatus.LOADING;
12256
- // if (needsRecovery) return OpenfortKitStatus.NEEDS_RECOVERY;
12287
+ return OpenfortStatus.LOADING;
12288
+ // if (needsRecovery) return OpenfortStatus.NEEDS_RECOVERY;
12257
12289
  if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
12258
12290
  if (isConnected)
12259
- return OpenfortKitStatus.CONNECTED;
12291
+ return OpenfortStatus.CONNECTED;
12260
12292
  else
12261
- return OpenfortKitStatus.NEEDS_RECOVERY;
12293
+ return OpenfortStatus.NEEDS_RECOVERY;
12262
12294
  }
12263
- return OpenfortKitStatus.DISCONNECTED;
12295
+ return OpenfortStatus.DISCONNECTED;
12264
12296
  };
12265
12297
  const status = getStatus();
12266
12298
  return {
12267
- isLoading: status === OpenfortKitStatus.LOADING,
12268
- isConnected: status === OpenfortKitStatus.CONNECTED,
12269
- isDisconnected: status === OpenfortKitStatus.DISCONNECTED,
12299
+ isLoading: status === OpenfortStatus.LOADING,
12300
+ isConnected: status === OpenfortStatus.CONNECTED,
12301
+ isDisconnected: status === OpenfortStatus.DISCONNECTED,
12270
12302
  isConnecting: isConnecting || embeddedState === EmbeddedState.CREATING_ACCOUNT,
12271
12303
  isAuthenticated: embeddedState !== EmbeddedState.NONE && embeddedState !== EmbeddedState.UNAUTHENTICATED,
12272
12304
  };
@@ -12339,12 +12371,17 @@ function useSignOut(hookOptions = {}) {
12339
12371
  data: {},
12340
12372
  });
12341
12373
  }
12342
- catch (error) {
12374
+ catch (e) {
12375
+ const error = new OpenfortError('Failed to sign out', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
12343
12376
  setStatus({
12344
12377
  status: 'error',
12345
- error: new OpenfortError('Failed to sign out', OpenfortErrorType.AUTHENTICATION_ERROR, { error }),
12378
+ error,
12379
+ });
12380
+ return onError({
12381
+ hookOptions,
12382
+ options,
12383
+ error,
12346
12384
  });
12347
- throw error;
12348
12385
  }
12349
12386
  }, [client, user, disconnect, updateUser, setStatus, hookOptions]);
12350
12387
  return {
@@ -12356,7 +12393,7 @@ function useSignOut(hookOptions = {}) {
12356
12393
  // this hook is used to create a wallet after the user has authenticated
12357
12394
  const useCreateWalletPostAuth = () => {
12358
12395
  const { setActiveWallet } = useWallets();
12359
- const { walletConfig } = useOpenfortKit();
12396
+ const { walletConfig } = useOpenfort();
12360
12397
  const { signOut } = useSignOut();
12361
12398
  const tryUseWallet = useCallback(async ({ logoutOnError: signOutOnError = true, automaticRecovery = true }) => {
12362
12399
  if (!walletConfig || walletConfig.recoveryMethod !== RecoveryMethod.AUTOMATIC || !automaticRecovery) {
@@ -12377,7 +12414,7 @@ const useCreateWalletPostAuth = () => {
12377
12414
  };
12378
12415
 
12379
12416
  const useEmailAuth = (hookOptions = {}) => {
12380
- const { log } = useOpenfortKit();
12417
+ const { log } = useOpenfort();
12381
12418
  const { client, updateUser } = useOpenfortCore();
12382
12419
  const [requiresEmailVerification, setRequiresEmailVerification] = useState(false);
12383
12420
  const [status, setStatus] = useState({
@@ -12648,14 +12685,14 @@ const useEmailAuth = (hookOptions = {}) => {
12648
12685
  });
12649
12686
  }
12650
12687
  }, [client, setStatus, updateUser, log, hookOptions]);
12651
- const verifyEmail = useCallback(async ({ email, state, ...options }) => {
12688
+ const verifyEmail = useCallback(async (options) => {
12652
12689
  setStatus({
12653
12690
  status: 'loading',
12654
12691
  });
12655
12692
  try {
12656
12693
  await client.auth.verifyEmail({
12657
- email,
12658
- state,
12694
+ email: options.email,
12695
+ state: options.state,
12659
12696
  });
12660
12697
  setStatus({
12661
12698
  status: 'success',
@@ -12664,7 +12701,7 @@ const useEmailAuth = (hookOptions = {}) => {
12664
12701
  hookOptions,
12665
12702
  options,
12666
12703
  data: {
12667
- email,
12704
+ email: options.email,
12668
12705
  },
12669
12706
  });
12670
12707
  }
@@ -12696,7 +12733,7 @@ const useEmailAuth = (hookOptions = {}) => {
12696
12733
  };
12697
12734
  };
12698
12735
 
12699
- const providerToAuthProvider = {
12736
+ ({
12700
12737
  // [OAuthProvider.APPLE]: AuthProvider.,
12701
12738
  // [OAuthProvider.DISCORD]: AuthProvider.,
12702
12739
  // [OAuthProvider.EPIC_GAMES]: AuthProvider.,
@@ -12704,13 +12741,7 @@ const providerToAuthProvider = {
12704
12741
  [AuthProvider.GOOGLE]: OAuthProvider.GOOGLE,
12705
12742
  // [OAuthProvider.LINE]: AuthProvider.,
12706
12743
  [AuthProvider.TWITTER]: OAuthProvider.TWITTER,
12707
- };
12708
- function getOAuthProvider(provider) {
12709
- if (!providerToAuthProvider[provider]) {
12710
- throw new Error(`Unsupported OAuth provider: ${provider}`);
12711
- }
12712
- return providerToAuthProvider[provider];
12713
- }
12744
+ });
12714
12745
  const useOAuth = (hookOptions = {}) => {
12715
12746
  const { client, updateUser } = useOpenfortCore();
12716
12747
  const [status, setStatus] = useState({
@@ -12762,7 +12793,7 @@ const useOAuth = (hookOptions = {}) => {
12762
12793
  status: 'loading',
12763
12794
  });
12764
12795
  await client.auth.initOAuth({
12765
- provider: getOAuthProvider(authProvider),
12796
+ provider: authProvider,
12766
12797
  options: {
12767
12798
  redirectTo: buildCallbackUrl({
12768
12799
  provider: authProvider,
@@ -12802,7 +12833,7 @@ const useOAuth = (hookOptions = {}) => {
12802
12833
  }
12803
12834
  await client.auth.initLinkOAuth({
12804
12835
  authToken,
12805
- provider: getOAuthProvider(authProvider),
12836
+ provider: authProvider,
12806
12837
  options: {
12807
12838
  redirectTo: buildCallbackUrl({
12808
12839
  provider: authProvider,
@@ -12839,7 +12870,7 @@ const useOAuth = (hookOptions = {}) => {
12839
12870
 
12840
12871
  const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and email callback
12841
12872
  ...hookOptions } = {}) => {
12842
- const { log } = useOpenfortKit();
12873
+ const { log } = useOpenfort();
12843
12874
  const [provider, setProvider] = useState(null);
12844
12875
  const [email, setEmail] = useState(null);
12845
12876
  const { verifyEmail, isSuccess: isEmailSuccess, isLoading: isEmailLoading, isError: isEmailError, error: emailError, } = useEmailAuth();
@@ -12980,12 +13011,11 @@ const useGuestAuth = (hookOptions = {}) => {
12980
13011
  setStatus({
12981
13012
  status: 'success',
12982
13013
  });
12983
- onSuccess({
13014
+ return onSuccess({
12984
13015
  hookOptions,
12985
13016
  options,
12986
- data: user,
13017
+ data: { user, wallet },
12987
13018
  });
12988
- return { user, wallet };
12989
13019
  }
12990
13020
  catch (error) {
12991
13021
  const openfortError = new OpenfortError("Failed to signup guest", OpenfortErrorType.AUTHENTICATION_ERROR, { error });
@@ -13008,13 +13038,12 @@ const useGuestAuth = (hookOptions = {}) => {
13008
13038
 
13009
13039
  const useWalletAuth = (hookOptions = {}) => {
13010
13040
  const { updateUser } = useOpenfortCore();
13011
- const { log } = useOpenfortKit();
13041
+ const { log } = useOpenfort();
13012
13042
  const siwe = useConnectWithSiwe();
13013
13043
  const availableWallets = useWallets$1(); // TODO: Use this to get the wallet client type
13014
13044
  const { disconnect } = useDisconnect();
13015
13045
  const [walletConnectingTo, setWalletConnectingTo] = useState(null);
13016
13046
  const [shouldConnectWithSiwe, setShouldConnectWithSiwe] = useState(false);
13017
- useAccount();
13018
13047
  const [status, setStatus] = useState({
13019
13048
  status: "idle",
13020
13049
  });
@@ -13189,5 +13218,5 @@ const useWalletAuth = (hookOptions = {}) => {
13189
13218
  };
13190
13219
  };
13191
13220
 
13192
- export { AuthProvider, Avatar, Chain as ChainIcon, OPENFORTKIT_VERSION, OpenfortError, OpenfortErrorType, OpenfortKitButton, OpenfortKitContext, OpenfortKitStatus, OpenfortProvider, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useSignOut, useStatus, useUI, useUser, useWallet, useWalletAuth, useWallets, wallets };
13221
+ export { AuthProvider, Avatar, Chain as ChainIcon, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortErrorType, OpenfortProvider, OpenfortStatus, Openfortcontext, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useSignOut, useStatus, useUI, useUser, useWallet, useWalletAuth, useWallets, wallets };
13193
13222
  //# sourceMappingURL=index.es.js.map