@openfort/react 0.0.4 → 0.0.6

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
@@ -1,13 +1,13 @@
1
- import { http, useConfig, useConnectors as useConnectors$1, useConnect as useConnect$1, useAccount, useDisconnect, useSwitchChain, createConfig, useEnsAddress, useEnsName, useEnsAvatar, useBalance, useChainId, WagmiContext, useBlockNumber } from 'wagmi';
1
+ import { Openfort as Openfort$1, EmbeddedState, AuthActionRequiredActions, OAuthProvider, RecoveryMethod, MissingRecoveryPasswordError, AccountTypeEnum, ChainTypeEnum } from '@openfort/openfort-js';
2
+ export { RecoveryMethod, ThirdPartyOAuthProvider } from '@openfort/openfort-js';
3
+ import { http, useConfig, useConnectors as useConnectors$1, useConnect as useConnect$1, useAccount, useDisconnect, useChainId, useSwitchChain, createConfig, useEnsAddress, useEnsName, useEnsAvatar, useBalance, WagmiContext, useBlockNumber } from 'wagmi';
2
4
  import { mainnet, polygon, optimism, arbitrum, sepolia } from 'wagmi/chains';
3
5
  import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
4
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import React, { createContext, useEffect, useState, useMemo, useRef, useCallback, createElement, useLayoutEffect } from 'react';
7
+ import React, { useEffect, createContext, useState, useMemo, useRef, useCallback, createElement, useLayoutEffect, useContext } from 'react';
6
8
  import { detect } from 'detect-browser';
7
9
  import { Buffer } from 'buffer';
8
- import { Openfort as Openfort$1, RecoveryMethod, EmbeddedState, AuthActionRequiredActions, OAuthProvider, ShieldAuthType, MissingRecoveryPasswordError, AccountTypeEnum, ChainTypeEnum } from '@openfort/openfort-js';
9
- export { RecoveryMethod } from '@openfort/openfort-js';
10
- import { polygonAmoy } from 'viem/chains';
10
+ import { useQueryClient, useQuery } from '@tanstack/react-query';
11
11
  import { motion, AnimatePresence, MotionConfig } from 'framer-motion';
12
12
  import styled$1, { css, keyframes } from 'styled-components';
13
13
  import { createPortal } from 'react-dom';
@@ -20,14 +20,15 @@ import { normalize } from 'viem/ens';
20
20
  import { AxiosError } from 'axios';
21
21
  import { createSiweMessage } from 'viem/siwe';
22
22
  import { signMessage } from '@wagmi/core';
23
- import { useQuery, useQueryClient } from '@tanstack/react-query';
23
+ import calculateEntropy from 'fast-password-entropy';
24
24
 
25
- const OPENFORT_VERSION = '0.0.4';
25
+ const OPENFORT_VERSION = '0.0.6';
26
26
 
27
27
  var OpenfortErrorType;
28
28
  (function (OpenfortErrorType) {
29
29
  OpenfortErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
30
30
  OpenfortErrorType["WALLET_ERROR"] = "WALLET_ERROR";
31
+ OpenfortErrorType["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
31
32
  })(OpenfortErrorType || (OpenfortErrorType = {}));
32
33
  class OpenfortError extends Error {
33
34
  constructor(message, type, data) {
@@ -291,7 +292,6 @@ var Logos = {
291
292
  };
292
293
 
293
294
  const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
294
- const playerRegex = /^(pla_[a-zA-Z0-9]{4})[a-zA-Z0-9-]+([a-zA-Z0-9]{4})$/;
295
295
  const truncateEthAddress = (address, separator = '••••') => {
296
296
  if (!address)
297
297
  return '';
@@ -300,14 +300,6 @@ const truncateEthAddress = (address, separator = '••••') => {
300
300
  return address;
301
301
  return `${match[1]}${separator}${match[2]}`;
302
302
  };
303
- const truncateUserId = (playerId, separator = '••••') => {
304
- if (!playerId)
305
- return '';
306
- const match = playerId.match(playerRegex);
307
- if (!match)
308
- return playerId;
309
- return `${match[1]}${separator}${match[2]}`;
310
- };
311
303
  const nFormatter = (num, digits = 2) => {
312
304
  if (num < 10000)
313
305
  return num.toFixed(2);
@@ -788,8 +780,6 @@ const socialProviders = [
788
780
  AuthProvider.FACEBOOK,
789
781
  ];
790
782
 
791
- const Openfortcontext = createContext(null);
792
-
793
783
  function useChainIsSupported(chainId) {
794
784
  const { chains } = useConfig();
795
785
  if (!chainId)
@@ -868,6 +858,8 @@ function useThemeFont(theme) {
868
858
  useGoogleFont(font !== null && font !== void 0 ? font : '');
869
859
  }
870
860
 
861
+ const Openfortcontext = createContext(null);
862
+
871
863
  const useOpenfort = () => {
872
864
  const context = React.useContext(Openfortcontext);
873
865
  if (!context)
@@ -974,14 +966,8 @@ const useConnectCallback = ({ onConnect, onDisconnect, }) => {
974
966
  *
975
967
  * const token = await client.getAccessToken();
976
968
  */
977
- function createOpenfortClient({ baseConfiguration, overrides, shieldConfiguration, }) {
978
- return new Openfort$1({
979
- baseConfiguration,
980
- overrides: {
981
- ...overrides,
982
- },
983
- shieldConfiguration
984
- });
969
+ function createOpenfortClient(config) {
970
+ return new Openfort$1(config);
985
971
  }
986
972
 
987
973
  const ConnectCallback = ({ onConnect, onDisconnect }) => {
@@ -996,12 +982,11 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
996
982
  const { connectors, connect, reset } = useConnect();
997
983
  const { address } = useAccount();
998
984
  const [user, setUser] = useState(null);
999
- const { disconnect } = useDisconnect();
985
+ const { disconnectAsync } = useDisconnect();
1000
986
  const { walletConfig } = useOpenfort();
1001
- const automaticRecovery = walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC;
1002
987
  // ---- Openfort instance ----
1003
988
  const openfort = useMemo(() => {
1004
- log('Creating Openfort instance.');
989
+ log('Creating Openfort instance.', openfortProps);
1005
990
  if (!openfortProps.baseConfiguration.publishableKey)
1006
991
  throw Error('CoreOpenfortProvider requires a publishableKey to be set in the baseConfiguration.');
1007
992
  const newClient = createOpenfortClient(openfortProps);
@@ -1054,6 +1039,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1054
1039
  var _a, _b;
1055
1040
  if (!openfort)
1056
1041
  return null;
1042
+ log("Updating user", { user, logoutOnError });
1057
1043
  if (user) {
1058
1044
  setUser(user);
1059
1045
  return user;
@@ -1079,21 +1065,27 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1079
1065
  return null;
1080
1066
  }
1081
1067
  }, [openfort]);
1068
+ const chainId = useChainId();
1082
1069
  useEffect(() => {
1083
- if (!openfort)
1084
- return;
1085
- if (!walletConfig)
1070
+ if (!openfort || !walletConfig)
1086
1071
  return;
1087
- log("Getting ethereum provider");
1088
- openfort.embeddedWallet.getEthereumProvider(walletConfig.ethereumProviderPolicyId ?
1089
- {
1090
- policy: walletConfig.ethereumProviderPolicyId,
1091
- chains: {
1092
- [polygonAmoy.id]: "https://rpc-amoy.polygon.technology",
1093
- }
1072
+ log("Getting ethereum provider", chainId);
1073
+ const resolvePolicy = () => {
1074
+ const { ethereumProviderPolicyId } = walletConfig;
1075
+ if (!ethereumProviderPolicyId)
1076
+ return undefined;
1077
+ if (typeof ethereumProviderPolicyId === "string") {
1078
+ return { policy: ethereumProviderPolicyId };
1094
1079
  }
1095
- : undefined);
1096
- }, [openfort]);
1080
+ const policy = ethereumProviderPolicyId[chainId];
1081
+ if (!policy) {
1082
+ log(`No policy found for chainId ${chainId}.`);
1083
+ return undefined;
1084
+ }
1085
+ return { policy };
1086
+ };
1087
+ openfort.embeddedWallet.getEthereumProvider(resolvePolicy());
1088
+ }, [openfort, walletConfig, chainId]);
1097
1089
  const [isConnectedWithEmbeddedSigner, setIsConnectedWithEmbeddedSigner] = useState(false);
1098
1090
  useEffect(() => {
1099
1091
  if (!openfort)
@@ -1113,16 +1105,25 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1113
1105
  setIsConnectedWithEmbeddedSigner(false);
1114
1106
  break;
1115
1107
  case EmbeddedState.READY:
1116
- if (!user)
1117
- updateUser(undefined, true);
1118
- // We cannot stop polling here because there is a bug on openfort-js
1119
- // that makes the embedded state to be stuck on CREATING_ACCOUNT
1120
- // stopPollingEmbeddedState();
1108
+ (async () => {
1109
+ for (let i = 0; i < 5; i++) {
1110
+ log("Trying to update user...", i);
1111
+ try {
1112
+ const user = await updateUser(undefined, true);
1113
+ if (user)
1114
+ break;
1115
+ }
1116
+ catch (err) {
1117
+ console.error("Error updating user, retrying...", err);
1118
+ }
1119
+ await new Promise((resolve) => setTimeout(resolve, 250));
1120
+ }
1121
+ })();
1121
1122
  break;
1122
1123
  default:
1123
1124
  throw new Error(`Unknown embedded state: ${embeddedState}`);
1124
1125
  }
1125
- }, [embeddedState, openfort, automaticRecovery]);
1126
+ }, [embeddedState, openfort]);
1126
1127
  useEffect(() => {
1127
1128
  // Connect to wagmi with Embedded signer
1128
1129
  if (address || !user)
@@ -1139,13 +1140,15 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1139
1140
  connect({ connector });
1140
1141
  }, [connectors, embeddedState, address, user]);
1141
1142
  // ---- Auth functions ----
1142
- const logout = useCallback(() => {
1143
+ const queryClient = useQueryClient();
1144
+ const logout = useCallback(async () => {
1143
1145
  if (!openfort)
1144
1146
  return;
1145
- log('Logging out...');
1146
- openfort.auth.logout();
1147
1147
  setUser(null);
1148
- disconnect();
1148
+ log('Logging out...');
1149
+ await openfort.auth.logout();
1150
+ await disconnectAsync();
1151
+ queryClient.resetQueries({ queryKey: ['openfortEmbeddedWalletList'] });
1149
1152
  reset();
1150
1153
  startPollingEmbeddedState();
1151
1154
  }, [openfort]);
@@ -1169,7 +1172,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1169
1172
  return true;
1170
1173
  case EmbeddedState.UNAUTHENTICATED:
1171
1174
  if (user)
1172
- return true; // If user is set in unauthenticated state, it means that the embedded state is not up to date, so we should wait
1175
+ return true; // If user i<s set in unauthenticated state, it means that the embedded state is not up to date, so we should wait
1173
1176
  return false;
1174
1177
  case EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED:
1175
1178
  if (!user)
@@ -1186,7 +1189,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
1186
1189
  return true;
1187
1190
  }
1188
1191
  }, [embeddedState, address, user]);
1189
- const needsRecovery = !automaticRecovery && (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) && (!address);
1192
+ const needsRecovery = (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) && (!address);
1190
1193
  const value = {
1191
1194
  signUpGuest,
1192
1195
  embeddedState,
@@ -2848,7 +2851,7 @@ const InfoButton = styled(motion.button) `
2848
2851
  }
2849
2852
  }
2850
2853
  `;
2851
- const Container$7 = styled(motion.div) `
2854
+ const Container$8 = styled(motion.div) `
2852
2855
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
2853
2856
  --duration: 200ms;
2854
2857
  --transition: height var(--duration) var(--ease),
@@ -4916,7 +4919,7 @@ const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onB
4916
4919
  const Content = (jsx(ResetContainer, { "$useTheme": (_e = demo === null || demo === void 0 ? void 0 : demo.theme) !== null && _e !== void 0 ? _e : themeContext.theme, "$useMode": (_f = demo === null || demo === void 0 ? void 0 : demo.mode) !== null && _f !== void 0 ? _f : themeContext.mode, "$customTheme": (_g = demo === null || demo === void 0 ? void 0 : demo.customTheme) !== null && _g !== void 0 ? _g : themeContext.customTheme, children: jsxs(ModalContainer, { role: "dialog", style: {
4917
4920
  pointerEvents: rendered ? 'auto' : 'none',
4918
4921
  position: positionInside ? 'absolute' : undefined,
4919
- }, children: [!inline && (jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur": (_h = context.uiConfig) === null || _h === void 0 ? void 0 : _h.overlayBlur })), jsxs(Container$7, { style: dimensionsCSS, initial: false, children: [jsx("div", { style: {
4922
+ }, children: [!inline && (jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur": (_h = context.uiConfig) === null || _h === void 0 ? void 0 : _h.overlayBlur })), jsxs(Container$8, { style: dimensionsCSS, initial: false, children: [jsx("div", { style: {
4920
4923
  pointerEvents: inTransition ? 'all' : 'none', // Block interaction while transitioning
4921
4924
  position: 'absolute',
4922
4925
  top: 0,
@@ -6461,7 +6464,7 @@ function useWalletConnectUri({ enabled } = {
6461
6464
  };
6462
6465
  }
6463
6466
 
6464
- const Web3Context = React.createContext({
6467
+ const Web3Context = createContext({
6465
6468
  connect: {
6466
6469
  getUri: () => '',
6467
6470
  },
@@ -6496,7 +6499,7 @@ const Web3ContextProvider = ({ enabled, children, }) => {
6496
6499
  };
6497
6500
  return jsx(Web3Context.Provider, { value: value, children: children });
6498
6501
  };
6499
- const useWeb3 = () => React.useContext(Web3Context);
6502
+ const useWeb3 = () => useContext(Web3Context);
6500
6503
 
6501
6504
  const AlertContainer = styled(motion.div) `
6502
6505
  display: flex;
@@ -7343,7 +7346,7 @@ const WalletList = styled.div `
7343
7346
  }
7344
7347
  `}
7345
7348
  `;
7346
- const Container$6 = styled.div ``;
7349
+ const Container$7 = styled.div ``;
7347
7350
 
7348
7351
  function useWalletConnectModal() {
7349
7352
  const { log } = useOpenfort();
@@ -7450,7 +7453,7 @@ const CopyToClipboardIcon = ({ copied, small, }) => (jsx(IconContainer$3, { "$cl
7450
7453
  opacity: small || copied ? 1 : 0.3,
7451
7454
  } }) }));
7452
7455
 
7453
- const Container$5 = styled.div `
7456
+ const Container$6 = styled.div `
7454
7457
  --color: var(--ck-copytoclipboard-stroke);
7455
7458
  --bg: var(--ck-body-background);
7456
7459
  transition: all 220ms cubic-bezier(0.175, 0.885, 0.32, 1.1);
@@ -7500,7 +7503,7 @@ const CopyToClipboard = ({ string, children, variant }) => {
7500
7503
  };
7501
7504
  if (variant === 'button')
7502
7505
  return (jsx(Button, { disabled: !string, onClick: onCopy, icon: jsx(CopyToClipboardIcon, { copied: clipboard }), children: children }));
7503
- return (jsx(Container$5, { onClick: onCopy, "$disabled": !string, children: jsxs(OffsetContainer, { children: [children, jsx(CopyToClipboardIcon, { copied: clipboard, small: true })] }) }));
7506
+ return (jsx(Container$6, { onClick: onCopy, "$disabled": !string, children: jsxs(OffsetContainer, { children: [children, jsx(CopyToClipboardIcon, { copied: clipboard, small: true })] }) }));
7504
7507
  };
7505
7508
 
7506
7509
  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" }) }));
@@ -7528,7 +7531,7 @@ const MobileConnectors = () => {
7528
7531
  window.location.href = uri;
7529
7532
  //if (uri) window.open(uri, '_blank');
7530
7533
  };
7531
- return (jsx(PageContent, { style: { width: 312 }, children: jsxs(Container$6, { children: [jsx(ModalContent, { style: { paddingBottom: 0 }, children: jsx(ScrollArea, { height: 340, children: jsxs(WalletList, { "$disabled": !wcUri, children: [walletsIdsToDisplay
7534
+ return (jsx(PageContent, { style: { width: 312 }, children: jsxs(Container$7, { children: [jsx(ModalContent, { style: { paddingBottom: 0 }, children: jsx(ScrollArea, { height: 340, children: jsxs(WalletList, { "$disabled": !wcUri, children: [walletsIdsToDisplay
7532
7535
  .sort(
7533
7536
  // sort by name
7534
7537
  (a, b) => {
@@ -8981,7 +8984,7 @@ const ChainSelectDropdown = ({ children, open, onClose, offsetX = 0, offsetY = 8
8981
8984
  }, children: [jsx(DropdownHeading, { children: locales.switchNetworks }), jsx(ChainSelectList, {})] })] }) }) }) })) })] }));
8982
8985
  };
8983
8986
 
8984
- const Container$4 = styled(motion.div) ``;
8987
+ const Container$5 = styled(motion.div) ``;
8985
8988
  const SwitchChainButton = styled(motion.button) `
8986
8989
  --color: var(
8987
8990
  --ck-dropdown-button-color,
@@ -9090,7 +9093,7 @@ const ChainSelector = () => {
9090
9093
  setIsOpen(false);
9091
9094
  }, [context.open]);
9092
9095
  const disabled = chains.length <= 1;
9093
- return (jsx(Fragment, { children: jsx(Container$4, { children: jsx(ChainSelectDropdown, { offsetX: -12, open: !mobile && isOpen, onClose: () => setIsOpen(false), children: jsxs(SwitchChainButton, { "aria-label": flattenChildren(locales.switchNetworks).toString(), disabled: disabled, onClick: () => {
9096
+ return (jsx(Fragment, { children: jsx(Container$5, { children: jsx(ChainSelectDropdown, { offsetX: -12, open: !mobile && isOpen, onClose: () => setIsOpen(false), children: jsxs(SwitchChainButton, { "aria-label": flattenChildren(locales.switchNetworks).toString(), disabled: disabled, onClick: () => {
9094
9097
  if (mobile) {
9095
9098
  context.setRoute(routes.SWITCHNETWORKS);
9096
9099
  }
@@ -9103,7 +9106,7 @@ const ChainSelector = () => {
9103
9106
  const PoweredByFooter = ({ showDisclaimer }) => {
9104
9107
  var _a, _b;
9105
9108
  const { uiConfig: options } = useOpenfort();
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: () => {
9109
+ return (jsxs(Container$4, { 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
9110
  window.open("https://www.openfort.xyz/", "_blank");
9108
9111
  }, children: [jsx("span", { children: "Powered by" }), jsx(IconContainer$2, { children: jsx(Logos.Openfort, {}) }), jsx("span", { children: "Openfort" })] })] }));
9109
9112
  };
@@ -9152,7 +9155,7 @@ const IconContainer$2 = styled.div `
9152
9155
  border-radius: 0;
9153
9156
  }
9154
9157
  `;
9155
- const Container$3 = styled(motion.div) `
9158
+ const Container$4 = styled(motion.div) `
9156
9159
  text-align: center;
9157
9160
  margin-top: 4px;
9158
9161
  margin-bottom: -16px;
@@ -9201,7 +9204,7 @@ var Wallet = ({ ...props }) => {
9201
9204
 
9202
9205
  function useProviders() {
9203
9206
  const { user } = useOpenfortCore();
9204
- const { uiConfig: options } = useOpenfort();
9207
+ const { uiConfig: options, thirdPartyAuth, setOpen } = useOpenfort();
9205
9208
  const allProviders = (options === null || options === void 0 ? void 0 : options.authProviders) || [];
9206
9209
  const providers = allProviders.filter(p => p !== AuthProvider.GUEST) || [];
9207
9210
  const linkedProviders = user ? providers.filter(p => { var _a; return (_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find(a => a.provider === p); }) : [];
@@ -9213,6 +9216,12 @@ function useProviders() {
9213
9216
  return !((_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find(a => a.provider === provider));
9214
9217
  })
9215
9218
  : providers;
9219
+ useEffect(() => {
9220
+ if (thirdPartyAuth) {
9221
+ setOpen(false);
9222
+ console.error(new OpenfortError('When using external third party auth providers, openfort Auth providers are not available. Either remove the `thirdPartyAuth` or authenticate your users using Auth hooks.', OpenfortErrorType.CONFIGURATION_ERROR));
9223
+ }
9224
+ }, []);
9216
9225
  return {
9217
9226
  availableProviders,
9218
9227
  linkedProviders,
@@ -9339,10 +9348,7 @@ const Profile = ({ closeModal }) => {
9339
9348
  //watch: true,
9340
9349
  });
9341
9350
  const [shouldDisconnect, setShouldDisconnect] = useState(false);
9342
- const { logout, user } = useOpenfortCore();
9343
- useEffect(() => {
9344
- // if (!isConnected) context.setOpen(false);
9345
- }, [isConnected]);
9351
+ const { logout } = useOpenfortCore();
9346
9352
  useEffect(() => {
9347
9353
  if (!shouldDisconnect)
9348
9354
  return;
@@ -9400,7 +9406,7 @@ const outlineKeyframes = keyframes `
9400
9406
  0%{ opacity:1; }
9401
9407
  100%{ opacity:0; }
9402
9408
  `;
9403
- const Container$2 = styled(motion.div) `
9409
+ const Container$3 = styled(motion.div) `
9404
9410
  /*
9405
9411
  background: var(
9406
9412
  --ck-body-background
@@ -10001,14 +10007,14 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
10001
10007
  }, [status, expiryTimer]);
10002
10008
  */
10003
10009
  if (!wallet) {
10004
- return (jsx(PageContent, { children: jsxs(Container$2, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "No connectors match the id given. This state should never happen." }) })] }) }));
10010
+ return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "No connectors match the id given. This state should never happen." }) })] }) }));
10005
10011
  }
10006
10012
  // OLD_TODO: Make this more generic
10007
10013
  if (isWalletConnectConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector.id)) {
10008
- return (jsx(PageContent, { children: jsxs(Container$2, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." }) })] }) }));
10014
+ return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." }) })] }) }));
10009
10015
  }
10010
10016
  const hasError = status === states$2.FAILED || status === states$2.REJECTED || status === states$2.DUPLICATED;
10011
- return (jsx(PageContent, { children: jsxs(Container$2, { children: [jsx(ConnectingContainer$1, { children: jsxs(ConnectingAnimation$1, { "$shake": hasError, "$circle": walletInfo.iconShape === 'circle', children: [jsx(AnimatePresence, { children: (hasError) && (jsx(RetryButton, { "aria-label": "Retry", initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileTap: { scale: 0.9 }, transition: { duration: 0.1 }, onClick: runConnect, children: jsx(RetryIconContainer, { children: jsx(Tooltip, { open: showTryAgainTooltip &&
10017
+ return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ConnectingContainer$1, { children: jsxs(ConnectingAnimation$1, { "$shake": hasError, "$circle": walletInfo.iconShape === 'circle', children: [jsx(AnimatePresence, { children: (hasError) && (jsx(RetryButton, { "aria-label": "Retry", initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileTap: { scale: 0.9 }, transition: { duration: 0.1 }, onClick: runConnect, children: jsx(RetryIconContainer, { children: jsx(Tooltip, { open: showTryAgainTooltip &&
10012
10018
  (hasError), message: locales.tryAgainQuestion, xOffset: -6, children: jsx(RetryIconCircle, {}) }) }) })) }), walletInfo.iconShape === 'circle' ? (jsx(CircleSpinner, { logo: status === states$2.UNAVAILABLE ? (jsx("div", { style: {
10013
10019
  transform: 'scale(1.14)',
10014
10020
  position: 'relative',
@@ -10480,14 +10486,14 @@ const EmailLogin = () => {
10480
10486
  setLoginLoading(false);
10481
10487
  setLoginError("Invalid email or password.");
10482
10488
  }).then((user) => {
10483
- // console.log("User", user);
10489
+ // log("User", user);
10484
10490
  if (!user) {
10485
10491
  setLoginLoading(false);
10486
10492
  setLoginError("Invalid email or password.");
10487
10493
  return;
10488
10494
  }
10489
10495
  if ("action" in user && user.action === AuthActionRequiredActions.ACTION_VERIFY_EMAIL) {
10490
- console.log("User needs to verify email");
10496
+ log("User needs to verify email");
10491
10497
  localStorage.setItem(emailToVerifyLocalStorageKey, email);
10492
10498
  setRoute(routes.EMAIL_VERIFICATION);
10493
10499
  }
@@ -10959,12 +10965,63 @@ const onError = ({ hookOptions, options, error, }) => {
10959
10965
  return { error };
10960
10966
  };
10961
10967
 
10962
- const createOpenfortWallet = ({ address, }) => ({
10968
+ var OpenfortStatus;
10969
+ (function (OpenfortStatus) {
10970
+ OpenfortStatus[OpenfortStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
10971
+ OpenfortStatus[OpenfortStatus["NEEDS_RECOVERY"] = 1] = "NEEDS_RECOVERY";
10972
+ OpenfortStatus[OpenfortStatus["LOADING"] = 2] = "LOADING";
10973
+ OpenfortStatus[OpenfortStatus["CONNECTED"] = 3] = "CONNECTED";
10974
+ })(OpenfortStatus || (OpenfortStatus = {}));
10975
+ function useStatus() {
10976
+ const { embeddedState } = useOpenfortCore();
10977
+ const { isConnected, isConnecting } = useAccount();
10978
+ const getStatus = () => {
10979
+ if (embeddedState === EmbeddedState.READY)
10980
+ return OpenfortStatus.CONNECTED;
10981
+ if (embeddedState === EmbeddedState.NONE)
10982
+ return OpenfortStatus.LOADING;
10983
+ // if (needsRecovery) return OpenfortStatus.NEEDS_RECOVERY;
10984
+ if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
10985
+ if (isConnected)
10986
+ return OpenfortStatus.CONNECTED;
10987
+ else
10988
+ return OpenfortStatus.NEEDS_RECOVERY;
10989
+ }
10990
+ return OpenfortStatus.DISCONNECTED;
10991
+ };
10992
+ const status = getStatus();
10993
+ return {
10994
+ isLoading: status === OpenfortStatus.LOADING,
10995
+ isConnected: status === OpenfortStatus.CONNECTED,
10996
+ isDisconnected: status === OpenfortStatus.DISCONNECTED,
10997
+ isConnecting: isConnecting || embeddedState === EmbeddedState.CREATING_ACCOUNT,
10998
+ isAuthenticated: embeddedState !== EmbeddedState.NONE && embeddedState !== EmbeddedState.UNAUTHENTICATED,
10999
+ };
11000
+ }
11001
+
11002
+ function useUser() {
11003
+ const { user, client } = useOpenfortCore();
11004
+ const { isAuthenticated } = useStatus();
11005
+ const getAccessTokenAndUpdate = useCallback(async () => {
11006
+ await client.validateAndRefreshToken();
11007
+ const token = await client.getAccessToken();
11008
+ return token;
11009
+ }, [client]);
11010
+ return {
11011
+ user,
11012
+ isAuthenticated,
11013
+ getAccessToken: getAccessTokenAndUpdate,
11014
+ validateAndRefreshToken: async () => await client.validateAndRefreshToken(),
11015
+ };
11016
+ }
11017
+
11018
+ const parseOpenfortWallet = ({ address, recoveryMethod, }) => ({
10963
11019
  connectorType: "embedded",
10964
11020
  walletClientType: "openfort",
10965
11021
  address,
10966
11022
  id: embeddedWalletId,
10967
11023
  isAvailable: true,
11024
+ recoveryMethod,
10968
11025
  });
10969
11026
  const mapWalletStatus = (status) => {
10970
11027
  return {
@@ -10976,7 +11033,8 @@ const mapWalletStatus = (status) => {
10976
11033
  };
10977
11034
  };
10978
11035
  function useWallets(hookOptions = {}) {
10979
- const { user, embeddedState, client } = useOpenfortCore();
11036
+ const { client } = useOpenfortCore();
11037
+ const { user } = useUser();
10980
11038
  const { walletConfig, log, setOpen, setRoute, setConnector, uiConfig } = useOpenfort();
10981
11039
  const { connector, isConnected, address } = useAccount();
10982
11040
  const chainId = useChainId();
@@ -11017,14 +11075,13 @@ function useWallets(hookOptions = {}) {
11017
11075
  }
11018
11076
  }
11019
11077
  });
11020
- const { data: embeddedWallets, refetch } = useQuery({
11078
+ // will reset on logout
11079
+ const { data: embeddedWallets, refetch, isPending: isLoadingWallets } = useQuery({
11021
11080
  queryKey: ['openfortEmbeddedWalletList'],
11022
- queryFn: () => !!user ? client.embeddedWallet.list() : Promise.resolve([]),
11081
+ queryFn: () => client.embeddedWallet.list(),
11082
+ refetchOnMount: false,
11083
+ refetchOnWindowFocus: false,
11023
11084
  });
11024
- useEffect(() => {
11025
- log("Refetching embedded wallets");
11026
- refetch();
11027
- }, [!!user, refetch]);
11028
11085
  const getEncryptionSession = useCallback(async () => {
11029
11086
  if (!walletConfig || !walletConfig.createEncryptedSessionEndpoint) {
11030
11087
  throw new Error("No createEncryptedSessionEndpoint set in walletConfig");
@@ -11058,16 +11115,16 @@ function useWallets(hookOptions = {}) {
11058
11115
  // Remove duplicates (different chain ids)
11059
11116
  if (userWallets.find(w => w.address === (wallet.address)))
11060
11117
  return;
11061
- userWallets.push(createOpenfortWallet({
11118
+ userWallets.push(parseOpenfortWallet({
11062
11119
  address: wallet.address,
11120
+ recoveryMethod: wallet.recoveryMethod,
11063
11121
  }));
11064
11122
  });
11065
11123
  return userWallets;
11066
11124
  }, [user === null || user === void 0 ? void 0 : user.linkedAccounts, embeddedWallets]);
11067
11125
  const wallets = useMemo(() => {
11068
- if (!isConnected || !address)
11069
- return rawWallets;
11070
- console.log("Mapping wallets", { rawWallets, status, address, isConnected, connector });
11126
+ // if (!isConnected || !address) return rawWallets;
11127
+ log("Mapping wallets", { rawWallets, status, address, isConnected, connector });
11071
11128
  return rawWallets.map((w) => ({
11072
11129
  ...w,
11073
11130
  isConnecting: status.status === 'connecting' && status.address === w.address,
@@ -11148,34 +11205,22 @@ function useWallets(hookOptions = {}) {
11148
11205
  }
11149
11206
  log(`Handling recovery with Openfort: ${password ? "with password" : "without password"}, chainId=${chainId}`);
11150
11207
  try {
11151
- const accessToken = await client.getAccessToken();
11152
- if (!accessToken) {
11153
- throw new Error("Openfort access token not found");
11154
- }
11155
- log("Access token");
11156
- const shieldAuthentication = password ? {
11157
- auth: ShieldAuthType.OPENFORT,
11158
- token: accessToken,
11159
- } : {
11160
- auth: ShieldAuthType.OPENFORT,
11161
- token: accessToken,
11162
- encryptionSession: walletConfig.getEncryptionSession ?
11163
- await walletConfig.getEncryptionSession() :
11164
- await getEncryptionSession(),
11165
- };
11166
- log("Shield authentication");
11167
11208
  const recoveryParams = password ? {
11168
11209
  recoveryMethod: RecoveryMethod.PASSWORD,
11169
11210
  password,
11170
11211
  } : {
11171
11212
  recoveryMethod: RecoveryMethod.AUTOMATIC,
11213
+ encryptionSession: walletConfig.getEncryptionSession ?
11214
+ await walletConfig.getEncryptionSession() :
11215
+ await getEncryptionSession()
11172
11216
  };
11173
11217
  // Ensure that the embedded wallet is listed
11174
11218
  const embeddedWallets = await client.embeddedWallet.list();
11175
11219
  log("Recovery params", optionsObject.address);
11176
11220
  log("Embedded wallets", embeddedWallets, chainId);
11177
- if (optionsObject.address) {
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;
11221
+ let walletAddress = optionsObject.address;
11222
+ if (walletAddress) {
11223
+ const walletId = (_a = embeddedWallets === null || embeddedWallets === void 0 ? void 0 : embeddedWallets.find((w) => w.address === walletAddress && w.chainId === chainId)) === null || _a === void 0 ? void 0 : _a.id;
11179
11224
  if (!walletId) {
11180
11225
  return onError({
11181
11226
  error: new OpenfortError("Embedded wallet not found for address", OpenfortErrorType.WALLET_ERROR),
@@ -11185,22 +11230,25 @@ function useWallets(hookOptions = {}) {
11185
11230
  }
11186
11231
  await client.embeddedWallet.recover({
11187
11232
  account: walletId,
11188
- shieldAuthentication,
11189
11233
  recoveryParams,
11190
11234
  });
11191
11235
  }
11192
11236
  else {
11193
11237
  // Check if the embedded wallet is already created in the current chain
11194
11238
  if (embeddedWallets.some((w) => w.chainId === chainId)) {
11239
+ const walletToRecover = embeddedWallets.find((w) => w.chainId === chainId);
11195
11240
  await client.embeddedWallet.recover({
11196
- account: embeddedWallets[0].id,
11197
- shieldAuthentication,
11241
+ account: walletToRecover.id,
11198
11242
  recoveryParams,
11199
11243
  });
11244
+ walletAddress = walletToRecover.address;
11200
11245
  }
11201
11246
  else {
11202
- await createWallet({
11203
- password,
11247
+ // Here it should check if there is a wallet that can recover in another chain and recover it in the current chain (its a different account so its not supported yet)
11248
+ return onError({
11249
+ error: new OpenfortError("No embedded wallet found for the current chain", OpenfortErrorType.WALLET_ERROR),
11250
+ options: optionsObject,
11251
+ hookOptions
11204
11252
  });
11205
11253
  }
11206
11254
  }
@@ -11209,8 +11257,9 @@ function useWallets(hookOptions = {}) {
11209
11257
  });
11210
11258
  return onSuccess({
11211
11259
  data: {
11212
- wallet: createOpenfortWallet({
11213
- address: optionsObject.address,
11260
+ wallet: parseOpenfortWallet({
11261
+ address: walletAddress,
11262
+ recoveryMethod: recoveryParams.recoveryMethod,
11214
11263
  }),
11215
11264
  },
11216
11265
  options: optionsObject,
@@ -11220,25 +11269,36 @@ function useWallets(hookOptions = {}) {
11220
11269
  catch (err) {
11221
11270
  log('Error handling recovery with Openfort:', err);
11222
11271
  if (err instanceof MissingRecoveryPasswordError) {
11272
+ const error = new OpenfortError("Missing recovery password", OpenfortErrorType.WALLET_ERROR);
11273
+ setStatus({
11274
+ status: 'error',
11275
+ error,
11276
+ });
11223
11277
  return onError({
11224
- error: new OpenfortError("Missing recovery password", OpenfortErrorType.WALLET_ERROR),
11278
+ error,
11225
11279
  options: optionsObject,
11226
11280
  hookOptions
11227
11281
  });
11228
11282
  }
11229
11283
  if (typeof err === 'string') {
11284
+ const error = new OpenfortError(err, OpenfortErrorType.WALLET_ERROR);
11285
+ setStatus({
11286
+ status: 'error',
11287
+ error,
11288
+ });
11230
11289
  return onError({
11231
- error: new OpenfortError(err, OpenfortErrorType.WALLET_ERROR),
11290
+ error,
11232
11291
  options: optionsObject,
11233
11292
  hookOptions
11234
11293
  });
11235
11294
  }
11236
- // setStatus({
11237
- // status: 'error',
11238
- // error: new Error("Failed to connect with embedded wallet: " + err),
11239
- // });
11295
+ const error = new OpenfortError("The recovery phrase you entered is incorrect.", OpenfortErrorType.WALLET_ERROR);
11296
+ setStatus({
11297
+ status: 'error',
11298
+ error,
11299
+ });
11240
11300
  return onError({
11241
- error: new OpenfortError("The recovery phrase you entered is incorrect.", OpenfortErrorType.WALLET_ERROR),
11301
+ error,
11242
11302
  options: optionsObject,
11243
11303
  hookOptions
11244
11304
  });
@@ -11262,52 +11322,63 @@ function useWallets(hookOptions = {}) {
11262
11322
  status: 'creating',
11263
11323
  });
11264
11324
  log("Creating wallet", { password: !!password, options });
11265
- const accessToken = await client.getAccessToken();
11266
- if (!accessToken) {
11267
- return onError({
11268
- error: new OpenfortError("Openfort access token not found", OpenfortErrorType.WALLET_ERROR),
11269
- hookOptions,
11270
- options,
11325
+ try {
11326
+ const accessToken = await client.getAccessToken();
11327
+ if (!accessToken) {
11328
+ return onError({
11329
+ error: new OpenfortError("Openfort access token not found", OpenfortErrorType.WALLET_ERROR),
11330
+ hookOptions,
11331
+ options,
11332
+ });
11333
+ }
11334
+ if (!walletConfig) {
11335
+ return onError({
11336
+ error: new OpenfortError("Embedded signer not enabled", OpenfortErrorType.WALLET_ERROR),
11337
+ hookOptions,
11338
+ options,
11339
+ });
11340
+ }
11341
+ const recoveryParams = password ? {
11342
+ recoveryMethod: RecoveryMethod.PASSWORD,
11343
+ password,
11344
+ } : {
11345
+ recoveryMethod: RecoveryMethod.AUTOMATIC,
11346
+ encryptionSession: walletConfig.getEncryptionSession ?
11347
+ await walletConfig.getEncryptionSession() :
11348
+ await getEncryptionSession()
11349
+ };
11350
+ const wallet = await client.embeddedWallet.create({
11351
+ chainId: (_a = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.initialChainId) !== null && _a !== void 0 ? _a : chainId,
11352
+ accountType: (options === null || options === void 0 ? void 0 : options.accountType) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.accountType) || AccountTypeEnum.SMART_ACCOUNT,
11353
+ chainType: ChainTypeEnum.EVM,
11354
+ recoveryParams,
11355
+ });
11356
+ setStatus({
11357
+ status: 'success',
11358
+ });
11359
+ refetch();
11360
+ return onSuccess({
11361
+ data: {
11362
+ wallet: parseOpenfortWallet({
11363
+ address: wallet.address,
11364
+ recoveryMethod: wallet.recoveryMethod,
11365
+ })
11366
+ }
11271
11367
  });
11272
11368
  }
11273
- if (!walletConfig) {
11369
+ catch (e) {
11370
+ const errorObj = e instanceof Error ? e : new Error('Failed to create wallet');
11371
+ const error = new OpenfortError('Failed to create wallet', OpenfortErrorType.WALLET_ERROR, { error: errorObj });
11372
+ setStatus({
11373
+ status: 'error',
11374
+ error,
11375
+ });
11274
11376
  return onError({
11275
- error: new OpenfortError("Embedded signer not enabled", OpenfortErrorType.WALLET_ERROR),
11377
+ error,
11276
11378
  hookOptions,
11277
11379
  options,
11278
11380
  });
11279
11381
  }
11280
- const shieldAuthentication = {
11281
- auth: ShieldAuthType.OPENFORT,
11282
- token: accessToken,
11283
- encryptionSession: walletConfig.getEncryptionSession ?
11284
- await walletConfig.getEncryptionSession() :
11285
- await getEncryptionSession(),
11286
- };
11287
- const recoveryParams = password ? {
11288
- recoveryMethod: RecoveryMethod.PASSWORD,
11289
- password,
11290
- } : {
11291
- recoveryMethod: RecoveryMethod.AUTOMATIC,
11292
- };
11293
- const wallet = await client.embeddedWallet.create({
11294
- chainId: (_a = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.initialChainId) !== null && _a !== void 0 ? _a : chainId,
11295
- accountType: AccountTypeEnum.SMART_ACCOUNT,
11296
- chainType: ChainTypeEnum.EVM,
11297
- recoveryParams,
11298
- shieldAuthentication
11299
- });
11300
- setStatus({
11301
- status: 'success',
11302
- });
11303
- refetch();
11304
- return onSuccess({
11305
- data: {
11306
- wallet: createOpenfortWallet({
11307
- address: wallet.address,
11308
- })
11309
- }
11310
- });
11311
11382
  }, [refetch, client, uiConfig, chainId]);
11312
11383
  const setRecovery = useCallback(async (params) => {
11313
11384
  try {
@@ -11315,17 +11386,7 @@ function useWallets(hookOptions = {}) {
11315
11386
  status: 'loading',
11316
11387
  });
11317
11388
  // 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
- }
11389
+ await client.embeddedWallet.setRecoveryMethod(params.previousRecovery, params.newRecovery);
11329
11390
  // Get the updated embedded account
11330
11391
  const embeddedAccount = await client.embeddedWallet.get();
11331
11392
  setStatus({ status: 'success' });
@@ -11333,8 +11394,9 @@ function useWallets(hookOptions = {}) {
11333
11394
  hookOptions,
11334
11395
  options: params,
11335
11396
  data: {
11336
- wallet: createOpenfortWallet({
11397
+ wallet: parseOpenfortWallet({
11337
11398
  address: embeddedAccount.address,
11399
+ recoveryMethod: embeddedAccount.recoveryMethod,
11338
11400
  }),
11339
11401
  }
11340
11402
  });
@@ -11349,10 +11411,13 @@ function useWallets(hookOptions = {}) {
11349
11411
  }
11350
11412
  }, [client, setStatus, hookOptions]);
11351
11413
  return {
11414
+ hasWallet: wallets.length > 0,
11415
+ isLoadingWallets,
11352
11416
  wallets,
11353
11417
  availableWallets: deviceWallets,
11354
11418
  activeWallet,
11355
11419
  setRecovery,
11420
+ reset: () => setStatus({ status: 'idle' }),
11356
11421
  createWallet,
11357
11422
  setActiveWallet,
11358
11423
  ...mapWalletStatus(status),
@@ -11360,19 +11425,202 @@ function useWallets(hookOptions = {}) {
11360
11425
  };
11361
11426
  }
11362
11427
 
11428
+ /**
11429
+ * Password Utilities Module
11430
+ * Provides functions for password strength calculation, passphrase generation,
11431
+ * and password validation.
11432
+ */
11433
+ // ============================================================================
11434
+ // Constants and Regular Expressions
11435
+ // ============================================================================
11436
+ /** Regular expression to match lowercase letters */
11437
+ const LOWERCASE_REGEX = /[a-z]/;
11438
+ /** Regular expression to match uppercase letters */
11439
+ const UPPERCASE_REGEX = /[A-Z]/;
11440
+ /** Regular expression to match digits */
11441
+ const DIGIT_REGEX = /[0-9]/;
11442
+ /** Special characters allowed in passwords */
11443
+ const SPECIAL_CHARACTERS = '!@#$%^&()\\-*+.';
11444
+ /** Regular expression to match special characters */
11445
+ const SPECIAL_CHARACTER_REGEX = new RegExp(`[${SPECIAL_CHARACTERS}]`);
11446
+ /** Maximum entropy score for normalization */
11447
+ const MAX_ENTROPY_SCORE = 95;
11448
+ /** Minimum password length for security */
11449
+ const MIN_PASSWORD_LENGTH = 8;
11450
+ /** Weight for diversity score in overall strength calculation */
11451
+ const DIVERSITY_WEIGHT = 0.3;
11452
+ const ENTROPY_WEIGHT = 0.7;
11453
+ const MEDIUM_SCORE_THRESHOLD = 0.5;
11454
+ const STRONG_SCORE_THRESHOLD = 0.75;
11455
+ const VERY_STRONG_SCORE_THRESHOLD = 0.9;
11456
+ /**
11457
+ * Converts a numeric password strength score to a human-readable label.
11458
+ *
11459
+ * @param score - The strength score (0-1)
11460
+ * @returns The corresponding strength label
11461
+ */
11462
+ function getPasswordStrengthLabel(score) {
11463
+ if (score > VERY_STRONG_SCORE_THRESHOLD) {
11464
+ return 'Very Strong';
11465
+ }
11466
+ else if (score > STRONG_SCORE_THRESHOLD) {
11467
+ return 'Strong';
11468
+ }
11469
+ else if (score > MEDIUM_SCORE_THRESHOLD) {
11470
+ return 'Medium';
11471
+ }
11472
+ else {
11473
+ return 'Weak';
11474
+ }
11475
+ }
11476
+ /**
11477
+ * Calculates the diversity score of a password based on character types used.
11478
+ * Considers lowercase, uppercase, digits, and special characters.
11479
+ *
11480
+ * @param password - The password to analyze
11481
+ * @returns A score between 0 and 1 representing character diversity
11482
+ */
11483
+ function calculatePasswordDiversityScore(password) {
11484
+ // Passwords shorter than minimum length get a score of 0
11485
+ if (password.length < MIN_PASSWORD_LENGTH) {
11486
+ return 0;
11487
+ }
11488
+ let characterTypesUsed = 0;
11489
+ if (LOWERCASE_REGEX.test(password)) {
11490
+ characterTypesUsed += 1;
11491
+ }
11492
+ if (UPPERCASE_REGEX.test(password)) {
11493
+ characterTypesUsed += 1;
11494
+ }
11495
+ if (DIGIT_REGEX.test(password)) {
11496
+ characterTypesUsed += 1;
11497
+ }
11498
+ if (SPECIAL_CHARACTER_REGEX.test(password)) {
11499
+ characterTypesUsed += 1;
11500
+ }
11501
+ return Math.max(0, Math.min(1, characterTypesUsed / 4));
11502
+ }
11503
+ /**
11504
+ * Calculates the overall password strength combining diversity and entropy.
11505
+ *
11506
+ * @param password - The password to analyze
11507
+ * @returns A strength score between 0 and 1
11508
+ */
11509
+ function getPasswordStrength(password = '') {
11510
+ const diversityScore = calculatePasswordDiversityScore(password);
11511
+ const entropyScore = calculateEntropy(password) / MAX_ENTROPY_SCORE;
11512
+ return Math.min((diversityScore * DIVERSITY_WEIGHT +
11513
+ entropyScore * ENTROPY_WEIGHT), 1);
11514
+ }
11515
+
11516
+ const Container$2 = styled.div `
11517
+ display: flex;
11518
+ flex-direction: column;
11519
+ gap: 0.5rem;
11520
+ margin-top: 0.5rem;
11521
+ margin-bottom: 0.5rem;
11522
+ text-align: left;
11523
+ `;
11524
+ const BarWrapper = styled.div `
11525
+ width: 100%;
11526
+ height: 4px;
11527
+ background: var(--ck-secondary-button-background);
11528
+ border-radius: 4px;
11529
+ overflow: hidden;
11530
+ `;
11531
+ const Progress = styled(motion.div) `
11532
+ height: 100%;
11533
+ background: ${({ color }) => color};
11534
+ border-radius: 4px;
11535
+ `;
11536
+ const Label = styled.div `
11537
+ font-size: 0.875rem;
11538
+ font-weight: 500;
11539
+ color: var(--ck-body-color-muted);
11540
+ `;
11541
+ const LabelColor = styled.span `
11542
+ color: ${({ color }) => color};
11543
+ `;
11544
+ const PasswordStrengthIndicator = ({ password, showPasswordIsTooWeakError }) => {
11545
+ const passwordStrength = getPasswordStrength(password); // should return a number between 0 and 1
11546
+ const label = getPasswordStrengthLabel(passwordStrength);
11547
+ const color = useMemo(() => {
11548
+ switch (label) {
11549
+ case "Weak":
11550
+ return "#ef4444"; // red-500
11551
+ case "Medium":
11552
+ return "#f59e0b"; // amber-500
11553
+ case "Strong":
11554
+ return "#10b981"; // emerald-500
11555
+ case "Very Strong":
11556
+ return "#3b82f6"; // blue-500
11557
+ default:
11558
+ return "#d1d5db"; // gray-300
11559
+ }
11560
+ }, [label]);
11561
+ return (jsxs(Container$2, { children: [jsx(BarWrapper, { children: jsx(Progress, { color: color, initial: { width: 0 }, animate: { width: `${passwordStrength * 100}%` }, transition: { ease: "easeOut", duration: 0.5 } }) }), jsxs("div", { style: { position: 'relative' }, children: [jsx(motion.div, { initial: { opacity: 1 }, animate: {
11562
+ opacity: showPasswordIsTooWeakError ? 0 : 1,
11563
+ y: showPasswordIsTooWeakError ? 5 : 0
11564
+ }, transition: { duration: 0.3 }, children: jsxs(Label, { children: ["Password strength: ", jsx(LabelColor, { color: color, children: label })] }) }), jsx(motion.div, { initial: { opacity: 0 }, animate: {
11565
+ opacity: showPasswordIsTooWeakError ? 1 : 0,
11566
+ y: showPasswordIsTooWeakError ? 0 : -5
11567
+ }, transition: { duration: 0.3 }, style: { color: '#ef4444', fontSize: '0.875rem', fontWeight: 500, position: 'absolute', top: '0' }, children: "Password is too weak" })] })] }));
11568
+ };
11569
+
11570
+ const TickListContainer = styled.ul `
11571
+ display: flex;
11572
+ flex-direction: column;
11573
+ gap: 8px;
11574
+ padding-top: 8px;
11575
+ padding-bottom: 8px;
11576
+ `;
11577
+ const TickItem = styled.li `
11578
+ display: flex;
11579
+ align-items: center;
11580
+ text-align: left;
11581
+ gap: 8px;
11582
+ font-size: 16px;
11583
+ line-height: 24px;
11584
+ `;
11585
+ const TickIconWrapper = styled.span `
11586
+ display: flex;
11587
+ align-items: center;
11588
+ justify-content: center;
11589
+ width: 16px;
11590
+ height: 16px;
11591
+ flex-shrink: 0;
11592
+ `;
11593
+
11594
+ const TickList = ({ items }) => {
11595
+ return (jsx(TickListContainer, { children: items.map((item, index) => (jsxs(TickItem, { children: [jsx(TickIconWrapper, { children: jsx(TickIcon, {}) }), jsx("span", { children: item })] }, index))) }));
11596
+ };
11597
+ TickList.displayName = 'TickList';
11598
+
11599
+ const OtherMethodButton = styled.button `
11600
+ width: 100%;
11601
+ color: var(--ck-body-color-muted);
11602
+ transition: color 0.2s;
11603
+ font-size: 14px;
11604
+ margin-top: 10px;
11605
+
11606
+ &:hover {
11607
+ color: var(--ck-body-color);
11608
+ }
11609
+ `;
11610
+
11363
11611
  // TODO: Localize
11364
- const Recover = () => {
11365
- const [recoveryPhrase, setRecoveryPhrase] = React.useState("");
11366
- const [recoveryError, setRecoveryError] = React.useState(false);
11612
+ const RecoverPasswordWallet = ({ wallet }) => {
11613
+ const [recoveryPhrase, setRecoveryPhrase] = useState("");
11614
+ const [recoveryError, setRecoveryError] = useState(false);
11367
11615
  const { triggerResize, uiConfig: options, log } = useOpenfort();
11368
- useChainId();
11369
- const [loading, setLoading] = React.useState(false);
11616
+ const [loading, setLoading] = useState(false);
11370
11617
  const { setActiveWallet } = useWallets();
11371
11618
  const handleSubmit = async () => {
11372
11619
  setLoading(true);
11373
11620
  const { error } = await setActiveWallet({
11374
11621
  connector: embeddedWalletId,
11375
11622
  password: recoveryPhrase,
11623
+ address: wallet.address,
11376
11624
  });
11377
11625
  setLoading(false);
11378
11626
  if (error) {
@@ -11386,34 +11634,172 @@ const Recover = () => {
11386
11634
  if (recoveryError)
11387
11635
  triggerResize();
11388
11636
  }, [recoveryError]);
11389
- return (jsxs(PageContent, { children: [jsxs(Graphic, { "$height": "110px", children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(1.2)" }, children: jsx(KeyIcon, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.75)" }, children: jsx(ShieldIcon, {}) }) }) }) }) }) }), jsx(Logo$2, {}), jsx(Logo$2, {}), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.5)" }, children: jsx(LockIcon, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsx(ModalHeading, { children: "Secure your account" }), jsx(ModalBody, { style: { textAlign: "center" }, children: jsx(FitText, { children: "Set or enter your password to secure your account." }) }), jsxs("form", { onSubmit: (e) => {
11637
+ const ensFallbackConfig = useEnsFallbackConfig();
11638
+ const { data: ensName } = useEnsName({
11639
+ chainId: 1,
11640
+ address: wallet.address,
11641
+ config: ensFallbackConfig,
11642
+ });
11643
+ const separator = '....';
11644
+ return (jsxs(PageContent, { children: [jsxs(Graphic, { "$height": "130px", children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(1.2)" }, children: jsx(KeyIcon, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.75)" }, children: jsx(ShieldIcon, {}) }) }) }) }) }) }), jsx(Logo$2, {}), jsx(Logo$2, {}), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.5)" }, children: jsx(LockIcon, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsx(ModalHeading, { children: "Recover wallet" }), jsxs(ModalBody, { style: { textAlign: "center" }, children: ["Please enter the recovery password to recover wallet", " ", jsx(CopyToClipboard, { string: wallet.address, children: ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(wallet.address, separator) })] }), jsxs("form", { onSubmit: (e) => {
11390
11645
  e.preventDefault();
11391
11646
  handleSubmit();
11392
- }, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => setRecoveryPhrase(e.target.value), type: "password", placeholder: "Enter your password", autoComplete: "off" }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "Enter" })] })] }));
11647
+ }, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => setRecoveryPhrase(e.target.value), type: "password", placeholder: "Enter your password", autoComplete: "off" }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "Recover wallet" })] })] }));
11393
11648
  };
11394
- const AutomaticRecovery = () => {
11395
- const { needsRecovery } = useOpenfortCore();
11649
+ const RecoverAutomaticWallet = ({ walletAddress }) => {
11650
+ const { embeddedState } = useOpenfortCore();
11396
11651
  const { setActiveWallet } = useWallets();
11397
11652
  const { log } = useOpenfort();
11398
- const [hasRecoveryMethod, setHasRecoveryMethod] = React.useState(false);
11653
+ const [error, setError] = useState(false);
11399
11654
  useEffect(() => {
11400
11655
  (async () => {
11401
- if (!needsRecovery) {
11402
- log("Automatic recovery enabled, configuring embedded signer");
11656
+ if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
11657
+ log("Automatically recovering wallet", walletAddress);
11403
11658
  const response = await setActiveWallet({
11404
11659
  connector: embeddedWalletId,
11405
11660
  });
11406
- // TODO: Handle error properly
11407
- if (response.error && response.error.message === "Missing recovery password") {
11408
- setHasRecoveryMethod(true);
11661
+ if (response.error) {
11662
+ setError(response.error.message || "There was an error recovering your account");
11663
+ log("Error recovering wallet", response.error);
11409
11664
  }
11410
11665
  }
11411
11666
  })();
11412
- }, [needsRecovery]);
11413
- if (hasRecoveryMethod) {
11414
- return jsx(Recover, {});
11667
+ }, [embeddedState]);
11668
+ if (error) {
11669
+ jsx(PageContent, { children: jsx(ModalBody, { style: { textAlign: "center" }, "$error": true, children: jsx(FitText, { children: error }) }) });
11670
+ }
11671
+ return (jsx(PageContent, { children: jsx(Loader, { reason: `Recovering wallet...` }) }));
11672
+ };
11673
+ const CreateWalletAutomaticRecovery = () => {
11674
+ const { embeddedState } = useOpenfortCore();
11675
+ const { createWallet } = useWallets();
11676
+ const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
11677
+ const { log } = useOpenfort();
11678
+ useEffect(() => {
11679
+ // To ensure the wallet is created only once
11680
+ if (shouldCreateWallet) {
11681
+ (async () => {
11682
+ log("Creating wallet Automatic recover");
11683
+ const response = await createWallet();
11684
+ if (response.error) {
11685
+ log("Error creating wallet", response.error);
11686
+ }
11687
+ })();
11688
+ }
11689
+ }, [shouldCreateWallet]);
11690
+ useEffect(() => {
11691
+ if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
11692
+ setShouldCreateWallet(true);
11693
+ }
11694
+ }, [embeddedState]);
11695
+ return (jsx(PageContent, { children: jsx(Loader, { reason: "Creating wallet..." }) }));
11696
+ };
11697
+ const OtherMethod = ({ currentMethod, onChangeMethod }) => {
11698
+ const { uiConfig } = useOpenfort();
11699
+ const otherMethods = useMemo(() => {
11700
+ const allowedMethods = uiConfig.walletRecovery.allowedMethods;
11701
+ const otherMethods = allowedMethods.filter((method) => method !== currentMethod);
11702
+ return otherMethods;
11703
+ }, [uiConfig, currentMethod]);
11704
+ if (otherMethods.length === 0)
11705
+ return null;
11706
+ if (otherMethods.length === 1) {
11707
+ const method = otherMethods[0];
11708
+ let text;
11709
+ switch (method) {
11710
+ case RecoveryMethod.PASSWORD:
11711
+ text = "Use password recovery";
11712
+ break;
11713
+ case RecoveryMethod.AUTOMATIC:
11714
+ text = "Skip for now";
11715
+ break;
11716
+ default:
11717
+ text = method;
11718
+ }
11719
+ return (jsx(OtherMethodButton, { onClick: () => {
11720
+ onChangeMethod(method);
11721
+ }, children: text }));
11722
+ }
11723
+ return (jsx(OtherMethodButton, { onClick: () => onChangeMethod("other"), children: "Choose another recovery method" }));
11724
+ };
11725
+ const CreateWalletPasswordRecovery = ({ onChangeMethod }) => {
11726
+ const [recoveryPhrase, setRecoveryPhrase] = useState("");
11727
+ const [recoveryError, setRecoveryError] = useState(false);
11728
+ const { triggerResize, uiConfig: options, log } = useOpenfort();
11729
+ const [showPasswordIsTooWeakError, setShowPasswordIsTooWeakError] = useState(false);
11730
+ const [loading, setLoading] = useState(false);
11731
+ const { createWallet } = useWallets();
11732
+ const handleSubmit = async () => {
11733
+ if (getPasswordStrength(recoveryPhrase) < MEDIUM_SCORE_THRESHOLD) {
11734
+ setShowPasswordIsTooWeakError(true);
11735
+ return;
11736
+ }
11737
+ setLoading(true);
11738
+ const { error } = await createWallet({
11739
+ password: recoveryPhrase,
11740
+ });
11741
+ setLoading(false);
11742
+ if (error) {
11743
+ setRecoveryError(error.message || "There was an error recovering your account");
11744
+ }
11745
+ else {
11746
+ log("Recovery success");
11747
+ }
11748
+ };
11749
+ useEffect(() => {
11750
+ if (recoveryError)
11751
+ triggerResize();
11752
+ }, [recoveryError]);
11753
+ return (jsxs(PageContent, { children: [jsxs(Graphic, { "$height": "80px", children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(1.2)" }, children: jsx(KeyIcon, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.75)" }, children: jsx(ShieldIcon, {}) }) }) }) }) }) }), jsx("div", {}), jsx("div", {}), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { style: { transform: "scale(0.5)" }, children: jsx(LockIcon, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsx(ModalHeading, { children: "Secure your wallet" }), jsxs(ModalBody, { style: { textAlign: "center" }, children: [jsx(FitText, { children: "Set a password for your wallet." }), jsxs("form", { onSubmit: (e) => {
11754
+ e.preventDefault();
11755
+ handleSubmit();
11756
+ }, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => {
11757
+ if (showPasswordIsTooWeakError)
11758
+ setShowPasswordIsTooWeakError(false);
11759
+ setRecoveryPhrase(e.target.value);
11760
+ }, type: "password", placeholder: "Enter your password", autoComplete: "off" }), jsx(PasswordStrengthIndicator, { password: recoveryPhrase, showPasswordIsTooWeakError: showPasswordIsTooWeakError }), jsx(TickList, { items: [
11761
+ "You will use this password to access your wallet",
11762
+ "Make sure it's strong and memorable",
11763
+ ] }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "Create wallet" })] }), jsx(OtherMethod, { currentMethod: RecoveryMethod.PASSWORD, onChangeMethod: onChangeMethod })] })] }));
11764
+ };
11765
+ const ChooseRecoveryMethod = ({ onChangeMethod }) => {
11766
+ return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Choose a recovery method" }), jsx(Button, { onClick: () => onChangeMethod(RecoveryMethod.PASSWORD), children: "Password" }), jsx(Button, { onClick: () => onChangeMethod(RecoveryMethod.AUTOMATIC), children: "Automatic" }), jsx(Button, { onClick: () => { }, children: "Passkey (coming soon)" })] }));
11767
+ };
11768
+ const RecoverWallet = ({ wallet }) => {
11769
+ switch (wallet.recoveryMethod) {
11770
+ case RecoveryMethod.PASSWORD:
11771
+ return jsx(RecoverPasswordWallet, { wallet: wallet });
11772
+ case RecoveryMethod.AUTOMATIC:
11773
+ return jsx(RecoverAutomaticWallet, { walletAddress: wallet.address });
11774
+ default:
11775
+ console.error("Unsupported recovery method: " + wallet.recoveryMethod + ", defaulting to automatic.");
11776
+ return jsx(RecoverAutomaticWallet, { walletAddress: wallet.address });
11777
+ }
11778
+ };
11779
+ const CreateWallet = () => {
11780
+ const { uiConfig } = useOpenfort();
11781
+ const [userSelectedMethod, setUserSelectedMethod] = useState(null);
11782
+ if (userSelectedMethod) {
11783
+ switch (userSelectedMethod) {
11784
+ case RecoveryMethod.PASSWORD:
11785
+ return jsx(CreateWalletPasswordRecovery, { onChangeMethod: setUserSelectedMethod });
11786
+ case RecoveryMethod.AUTOMATIC:
11787
+ return jsx(CreateWalletAutomaticRecovery, {});
11788
+ case "other":
11789
+ return jsx(ChooseRecoveryMethod, { onChangeMethod: setUserSelectedMethod });
11790
+ default:
11791
+ throw new Error("Unsupported recovery method: " + userSelectedMethod);
11792
+ }
11793
+ }
11794
+ // Default recovery method configured
11795
+ switch (uiConfig.walletRecovery.defaultMethod) {
11796
+ case RecoveryMethod.PASSWORD:
11797
+ return jsx(CreateWalletPasswordRecovery, { onChangeMethod: setUserSelectedMethod });
11798
+ case RecoveryMethod.AUTOMATIC:
11799
+ return jsx(CreateWalletAutomaticRecovery, {});
11800
+ default:
11801
+ throw new Error("Unsupported recovery method: " + uiConfig.walletRecovery.defaultMethod);
11415
11802
  }
11416
- return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up signer" }) }));
11417
11803
  };
11418
11804
  const Connected = () => {
11419
11805
  const { setOpen } = useOpenfort();
@@ -11425,49 +11811,81 @@ const Connected = () => {
11425
11811
  }, []);
11426
11812
  return (jsx(PageContent, { children: jsx(Loader, { isLoading: false, reason: "Connected" }) }));
11427
11813
  };
11428
- const CreateEmbeddedSigner = () => {
11814
+ const RecoverPage = () => {
11429
11815
  const { needsRecovery, user } = useOpenfortCore();
11430
11816
  const { triggerResize, uiConfig, walletConfig, setRoute } = useOpenfort();
11431
- const [loading, setLoading] = React.useState(true);
11432
- const [embeddedSignerLoading, setEmbeddedSignerLoading] = React.useState(true);
11817
+ const { wallets, isLoadingWallets } = useWallets();
11818
+ // const [loading, setLoading] = useState(true);
11819
+ const [embeddedSignerLoading, setEmbeddedSignerLoading] = useState(true);
11433
11820
  const { isConnected } = useAccount();
11434
11821
  useEffect(() => {
11435
- setTimeout(() => {
11436
- setEmbeddedSignerLoading(false);
11437
- triggerResize();
11438
- }, 500);
11439
- }, []);
11440
- useEffect(() => {
11441
- if (!user)
11442
- return;
11443
- if ((uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.linkWalletOnSignUp) || !walletConfig) {
11444
- if (!user.linkedAccounts.find((account) => account.provider === "wallet")) {
11445
- setRoute(routes.CONNECTORS);
11446
- return;
11447
- }
11448
- if (!walletConfig) {
11449
- // Logged in without a wallet
11450
- setRoute(routes.PROFILE);
11451
- return;
11452
- }
11822
+ let timeout;
11823
+ if (!isLoadingWallets) {
11824
+ timeout = setTimeout(() => {
11825
+ setEmbeddedSignerLoading(false);
11826
+ triggerResize();
11827
+ }, 500);
11453
11828
  }
11454
- setLoading(false);
11455
- }, [user]);
11456
- if (embeddedSignerLoading || loading) {
11457
- return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up signer" }) }));
11829
+ return () => { clearTimeout(timeout); };
11830
+ }, [isLoadingWallets]);
11831
+ const openfortWallets = useMemo(() => {
11832
+ return wallets.filter((wallet) => wallet.id === embeddedWalletId);
11833
+ }, [wallets]);
11834
+ // useEffect(() => {
11835
+ // if (!user) return;
11836
+ // if (uiConfig?.linkWalletOnSignUp || !walletConfig) {
11837
+ // if (!user.linkedAccounts.find((account) => account.provider === "wallet")) {
11838
+ // setRoute(routes.CONNECTORS);
11839
+ // return;
11840
+ // }
11841
+ // if (!walletConfig) {
11842
+ // // Logged in without a wallet
11843
+ // setRoute(routes.PROFILE);
11844
+ // return;
11845
+ // }
11846
+ // }
11847
+ // setLoading(false);
11848
+ // }, [user])
11849
+ if (embeddedSignerLoading) {
11850
+ return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up wallet" }) }));
11458
11851
  }
11459
11852
  if (isConnected && user) {
11460
11853
  return jsx(Connected, {});
11461
11854
  }
11462
- if (walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC) {
11463
- return jsx(AutomaticRecovery, {});
11855
+ if (!openfortWallets) {
11856
+ // Here wallets should be loaded, so if we don't have them something went wrong
11857
+ // TODO: add error logs
11858
+ return (jsx(PageContent, { children: "An unexpected error occurred. Please try again later." }));
11464
11859
  }
11465
- if (needsRecovery) {
11466
- return jsx(Recover, {});
11467
- }
11468
- else {
11469
- return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up signer" }) }));
11860
+ if (openfortWallets.length === 0) {
11861
+ return (jsx(CreateWallet, {}));
11470
11862
  }
11863
+ // if (wallets.length === 1) {
11864
+ return (jsx(RecoverWallet, { wallet: openfortWallets[0] }));
11865
+ // }
11866
+ // return (
11867
+ // <PageContent>
11868
+ // <div style={{ flexDirection: "column", display: "flex", gap: 8 }}>
11869
+ // {wallets.map((wallet) => (
11870
+ // <div key={wallet.address}>
11871
+ // {wallet.address} - {wallet.recoveryMethod} recover
11872
+ // </div>
11873
+ // ))}
11874
+ // </div>
11875
+ // </PageContent>
11876
+ // )
11877
+ // if (walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC) {
11878
+ // return <AutomaticRecovery />
11879
+ // }
11880
+ // if (needsRecovery) {
11881
+ // return <Recover />
11882
+ // } else {
11883
+ // return (
11884
+ // <PageContent>
11885
+ // <Loader reason="Setting up signer" />
11886
+ // </PageContent>
11887
+ // )
11888
+ // }
11471
11889
  };
11472
11890
 
11473
11891
  const SocialProviders = () => {
@@ -11539,7 +11957,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
11539
11957
  connect: jsx(ConnectUsing, {}),
11540
11958
  profile: jsx(Profile, {}),
11541
11959
  switchNetworks: jsx(SwitchNetworks, {}),
11542
- recover: jsx(CreateEmbeddedSigner, {}),
11960
+ recover: jsx(RecoverPage, {}),
11543
11961
  };
11544
11962
  function hide() {
11545
11963
  context.setOpen(false);
@@ -11623,8 +12041,8 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
11623
12041
  * @param {OpenfortOptions} [openfortOptions] - Options for Openfort integration.
11624
12042
  * @throws Will throw an error if used outside of a WagmiProvider or if nested usages are detected.
11625
12043
  */
11626
- const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMode = false, publishableKey, walletConfig, }) => {
11627
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12044
+ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMode = false, publishableKey, walletConfig, overrides, thirdPartyAuth, }) => {
12045
+ var _a, _b, _c, _d, _e, _f, _g, _h;
11628
12046
  // OpenfortProvider must be within a WagmiProvider
11629
12047
  if (!React.useContext(WagmiContext)) {
11630
12048
  throw Error('OpenfortProvider must be within a WagmiProvider');
@@ -11636,8 +12054,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11636
12054
  }
11637
12055
  const chains = useChains();
11638
12056
  const injectedConnector = useConnector('injected');
12057
+ const allowAutomaticRecovery = !!((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.createEncryptedSessionEndpoint) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.getEncryptionSession));
11639
12058
  // Default config options
11640
- const defaultOptions = {
12059
+ const defaultUIOptions = {
11641
12060
  theme: 'auto',
11642
12061
  mode: 'auto',
11643
12062
  language: 'en-US',
@@ -11660,21 +12079,34 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11660
12079
  ethereumOnboardingUrl: undefined,
11661
12080
  walletOnboardingUrl: undefined,
11662
12081
  disableSiweRedirect: false,
11663
- // Openfort options
11664
- authProviders: [],
11665
- };
11666
- const opts = Object.assign({}, defaultOptions, uiConfig);
11667
- if (((_b = opts.authProviders) === null || _b === void 0 ? void 0 : _b.length) === 0) {
11668
- opts.authProviders = [
12082
+ walletRecovery: {
12083
+ allowedMethods: [
12084
+ RecoveryMethod.PASSWORD,
12085
+ ...(allowAutomaticRecovery ? [RecoveryMethod.AUTOMATIC] : [])
12086
+ ],
12087
+ defaultMethod: allowAutomaticRecovery ? RecoveryMethod.AUTOMATIC : RecoveryMethod.PASSWORD,
12088
+ },
12089
+ authProviders: [
11669
12090
  AuthProvider.GUEST,
11670
12091
  AuthProvider.EMAIL,
11671
12092
  AuthProvider.WALLET,
11672
- ];
12093
+ ],
12094
+ };
12095
+ const safeUiConfig = Object.assign({}, defaultUIOptions, uiConfig);
12096
+ if (!safeUiConfig.walletRecovery.allowedMethods) {
12097
+ safeUiConfig.walletRecovery.allowedMethods = defaultUIOptions.walletRecovery.allowedMethods;
12098
+ }
12099
+ if (!safeUiConfig.walletRecovery.defaultMethod) {
12100
+ safeUiConfig.walletRecovery.defaultMethod = defaultUIOptions.walletRecovery.defaultMethod;
12101
+ }
12102
+ if (safeUiConfig.walletRecovery.allowedMethods.includes(RecoveryMethod.AUTOMATIC) && !allowAutomaticRecovery) {
12103
+ safeUiConfig.walletRecovery.allowedMethods = safeUiConfig.walletRecovery.allowedMethods.filter(m => m !== RecoveryMethod.AUTOMATIC);
12104
+ console.warn("Automatic recovery method was removed from allowedMethods because no recovery options are configured in the walletConfig. Please provide either createEncryptedSessionEndpoint or getEncryptionSession to enable automatic recovery.");
11673
12105
  }
11674
12106
  if (typeof window !== 'undefined') {
11675
12107
  // Buffer Polyfill, needed for bundlers that don't provide Node polyfills (e.g CRA, Vite, etc.)
11676
- if (opts.bufferPolyfill)
11677
- window.Buffer = (_c = window.Buffer) !== null && _c !== void 0 ? _c : Buffer;
12108
+ if (safeUiConfig.bufferPolyfill)
12109
+ window.Buffer = (_b = window.Buffer) !== null && _b !== void 0 ? _b : Buffer;
11678
12110
  // Some bundlers may need `global` and `process.env` polyfills as well
11679
12111
  // Not implemented here to avoid unexpected behaviors, but leaving example here for future reference
11680
12112
  /*
@@ -11682,9 +12114,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11682
12114
  * window.process = window.process ?? { env: {} };
11683
12115
  */
11684
12116
  }
11685
- const [ckTheme, setTheme] = useState((_e = (_d = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _d !== void 0 ? _d : defaultOptions.theme) !== null && _e !== void 0 ? _e : "auto");
11686
- const [ckMode, setMode] = useState((_g = (_f = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _f !== void 0 ? _f : defaultOptions.mode) !== null && _g !== void 0 ? _g : 'auto');
11687
- const [ckCustomTheme, setCustomTheme] = useState((_h = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.customTheme) !== null && _h !== void 0 ? _h : {});
12117
+ const [ckTheme, setTheme] = useState((_d = (_c = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _c !== void 0 ? _c : defaultUIOptions.theme) !== null && _d !== void 0 ? _d : "auto");
12118
+ const [ckMode, setMode] = useState((_f = (_e = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _e !== void 0 ? _e : defaultUIOptions.mode) !== null && _f !== void 0 ? _f : 'auto');
12119
+ const [ckCustomTheme, setCustomTheme] = useState((_g = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.customTheme) !== null && _g !== void 0 ? _g : {});
11688
12120
  const [ckLang, setLang] = useState('en-US');
11689
12121
  const [open, setOpen] = useState(false);
11690
12122
  const [connector, setConnector] = useState({
@@ -11694,17 +12126,17 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11694
12126
  const [errorMessage, setErrorMessage] = useState('');
11695
12127
  const [resize, onResize] = useState(0);
11696
12128
  // Include Google Font that is needed for a themes
11697
- if (opts.embedGoogleFonts)
12129
+ if (safeUiConfig.embedGoogleFonts)
11698
12130
  useThemeFont(ckTheme);
11699
12131
  // Other Configuration
11700
12132
  useEffect(() => { var _a; return setTheme((_a = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _a !== void 0 ? _a : 'auto'); }, [uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme]);
11701
- useEffect(() => setLang(opts.language || 'en-US'), [opts.language]);
12133
+ useEffect(() => setLang(safeUiConfig.language || 'en-US'), [safeUiConfig.language]);
11702
12134
  useEffect(() => setErrorMessage(null), [route, open]);
11703
12135
  // Check if chain is supported, elsewise redirect to switches page
11704
12136
  const { chain, isConnected } = useAccount();
11705
12137
  const isChainSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
11706
12138
  useEffect(() => {
11707
- if (isConnected && opts.enforceSupportedChains && !isChainSupported) {
12139
+ if (isConnected && safeUiConfig.enforceSupportedChains && !isChainSupported) {
11708
12140
  setOpen(true);
11709
12141
  setRoute(routes.SWITCHNETWORKS);
11710
12142
  }
@@ -11733,8 +12165,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11733
12165
  connector,
11734
12166
  setConnector,
11735
12167
  onConnect,
12168
+ onDisconnect,
11736
12169
  // Other configuration
11737
- uiConfig: opts,
12170
+ uiConfig: safeUiConfig,
11738
12171
  errorMessage,
11739
12172
  debugMode,
11740
12173
  log,
@@ -11749,14 +12182,15 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
11749
12182
  resize,
11750
12183
  triggerResize: () => onResize((prev) => prev + 1),
11751
12184
  walletConfig,
12185
+ overrides,
12186
+ thirdPartyAuth,
11752
12187
  };
11753
12188
  return createElement(Openfortcontext.Provider, { value }, jsx(Fragment, { children: jsx(Web3ContextProvider, { enabled: open, children: jsxs(CoreOpenfortProvider, { baseConfiguration: {
11754
12189
  publishableKey,
11755
12190
  }, shieldConfiguration: walletConfig ? {
11756
12191
  shieldPublishableKey: walletConfig.shieldPublishableKey,
11757
- shieldEncryptionKey: walletConfig.recoveryMethod === RecoveryMethod.PASSWORD ? walletConfig.shieldEncryptionKey : undefined,
11758
12192
  debug: debugMode,
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 })] }) }) }));
12193
+ } : undefined, overrides: overrides, thirdPartyAuth: thirdPartyAuth, debugMode: debugMode, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_h = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _h !== void 0 ? _h : ckMode, customTheme: ckCustomTheme })] }) }) }));
11760
12194
  };
11761
12195
 
11762
12196
  const Container$1 = styled(motion.div) `
@@ -12176,7 +12610,7 @@ const ConnectedLabel = ({ separator }) => {
12176
12610
  if (!user)
12177
12611
  return "Loading user...";
12178
12612
  if (!address)
12179
- return truncateUserId(user.id, separator);
12613
+ return "Not connected";
12180
12614
  return "Loading...";
12181
12615
  };
12182
12616
  function OpenfortButtonInner({ label, showAvatar, separator, }) {
@@ -12270,56 +12704,6 @@ onClick, }) {
12270
12704
  }
12271
12705
  OpenfortButton.Custom = ConnectButtonRenderer;
12272
12706
 
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 = {}));
12280
- function useStatus() {
12281
- const { embeddedState } = useOpenfortCore();
12282
- const { isConnected, isConnecting } = useAccount();
12283
- const getStatus = () => {
12284
- if (embeddedState === EmbeddedState.READY)
12285
- return OpenfortStatus.CONNECTED;
12286
- if (embeddedState === EmbeddedState.NONE)
12287
- return OpenfortStatus.LOADING;
12288
- // if (needsRecovery) return OpenfortStatus.NEEDS_RECOVERY;
12289
- if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
12290
- if (isConnected)
12291
- return OpenfortStatus.CONNECTED;
12292
- else
12293
- return OpenfortStatus.NEEDS_RECOVERY;
12294
- }
12295
- return OpenfortStatus.DISCONNECTED;
12296
- };
12297
- const status = getStatus();
12298
- return {
12299
- isLoading: status === OpenfortStatus.LOADING,
12300
- isConnected: status === OpenfortStatus.CONNECTED,
12301
- isDisconnected: status === OpenfortStatus.DISCONNECTED,
12302
- isConnecting: isConnecting || embeddedState === EmbeddedState.CREATING_ACCOUNT,
12303
- isAuthenticated: embeddedState !== EmbeddedState.NONE && embeddedState !== EmbeddedState.UNAUTHENTICATED,
12304
- };
12305
- }
12306
-
12307
- function useUser() {
12308
- const { user, client } = useOpenfortCore();
12309
- const { isAuthenticated } = useStatus();
12310
- const getAccessTokenAndUpdate = useCallback(async () => {
12311
- await client.validateAndRefreshToken();
12312
- const token = await client.getAccessToken();
12313
- return token;
12314
- }, [client]);
12315
- return {
12316
- user,
12317
- isAuthenticated,
12318
- getAccessToken: getAccessTokenAndUpdate,
12319
- validateAndRefreshToken: async () => await client.validateAndRefreshToken(),
12320
- };
12321
- }
12322
-
12323
12707
  function useWallet() {
12324
12708
  const { activeWallet } = useWallets();
12325
12709
  return activeWallet;
@@ -12347,21 +12731,16 @@ const mapStatus = (status) => {
12347
12731
  };
12348
12732
 
12349
12733
  function useSignOut(hookOptions = {}) {
12350
- const { client, updateUser, user } = useOpenfortCore();
12734
+ const { logout } = useOpenfortCore();
12351
12735
  const [status, setStatus] = useState({
12352
12736
  status: "idle",
12353
12737
  });
12354
- const { disconnect } = useDisconnect();
12355
12738
  const signOut = useCallback(async (options = {}) => {
12356
- if (!user)
12357
- return;
12358
12739
  setStatus({
12359
12740
  status: 'loading',
12360
12741
  });
12361
12742
  try {
12362
- await client.auth.logout();
12363
- disconnect();
12364
- updateUser();
12743
+ logout();
12365
12744
  setStatus({
12366
12745
  status: 'success',
12367
12746
  });
@@ -12383,7 +12762,7 @@ function useSignOut(hookOptions = {}) {
12383
12762
  error,
12384
12763
  });
12385
12764
  }
12386
- }, [client, user, disconnect, updateUser, setStatus, hookOptions]);
12765
+ }, [logout, setStatus, hookOptions]);
12387
12766
  return {
12388
12767
  ...mapStatus(status),
12389
12768
  signOut,
@@ -12391,22 +12770,43 @@ function useSignOut(hookOptions = {}) {
12391
12770
  }
12392
12771
 
12393
12772
  // this hook is used to create a wallet after the user has authenticated
12394
- const useCreateWalletPostAuth = () => {
12395
- const { setActiveWallet } = useWallets();
12773
+ const useConnectToWalletPostAuth = () => {
12774
+ const { createWallet, setActiveWallet } = useWallets();
12396
12775
  const { walletConfig } = useOpenfort();
12397
12776
  const { signOut } = useSignOut();
12777
+ const queryClient = useQueryClient();
12398
12778
  const tryUseWallet = useCallback(async ({ logoutOnError: signOutOnError = true, automaticRecovery = true }) => {
12399
- if (!walletConfig || walletConfig.recoveryMethod !== RecoveryMethod.AUTOMATIC || !automaticRecovery) {
12779
+ console.log("tryUseWallet", { walletConfig, automaticRecovery });
12780
+ if ((!(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.createEncryptedSessionEndpoint) && !(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.getEncryptionSession)) || !automaticRecovery) {
12781
+ // If there is no encryption session, we cannot create a wallet
12400
12782
  return {};
12401
12783
  }
12402
- const wallet = await setActiveWallet({
12403
- connector: embeddedWalletId,
12404
- });
12405
- if (wallet.error && signOutOnError) {
12406
- // If there was an error and we should log out, we can call the logout function
12407
- await signOut();
12784
+ const wallets = await queryClient.ensureQueryData({ queryKey: ['openfortEmbeddedWalletList'] });
12785
+ console.log("WALLETS", wallets);
12786
+ let wallet;
12787
+ if (wallets.length === 0) {
12788
+ const createWalletResult = await createWallet();
12789
+ if (createWalletResult.error && signOutOnError) {
12790
+ console.error("Error creating wallet:", createWalletResult.error);
12791
+ // If there was an error and we should log out, we can call the logout function
12792
+ await signOut();
12793
+ return {};
12794
+ }
12795
+ wallet = createWalletResult.wallet;
12408
12796
  }
12409
- return wallet;
12797
+ // Has a wallet with automatic recovery
12798
+ if (wallets.some(w => w.recoveryMethod === RecoveryMethod.AUTOMATIC)) {
12799
+ const setWalletResult = await setActiveWallet({
12800
+ connector: embeddedWalletId,
12801
+ });
12802
+ if (!setWalletResult.wallet || (setWalletResult.error && signOutOnError)) {
12803
+ console.error("Error recovering wallet:", setWalletResult.error);
12804
+ // If there was an error and we should log out, we can call the logout function
12805
+ await signOut();
12806
+ }
12807
+ wallet = setWalletResult.wallet;
12808
+ }
12809
+ return { wallet };
12410
12810
  }, [walletConfig, setActiveWallet, signOut]);
12411
12811
  return {
12412
12812
  tryUseWallet,
@@ -12426,7 +12826,7 @@ const useEmailAuth = (hookOptions = {}) => {
12426
12826
  });
12427
12827
  setRequiresEmailVerification(false);
12428
12828
  }, []);
12429
- const { tryUseWallet } = useCreateWalletPostAuth();
12829
+ const { tryUseWallet } = useConnectToWalletPostAuth();
12430
12830
  const signInEmail = useCallback(async (options) => {
12431
12831
  var _a;
12432
12832
  try {
@@ -12747,7 +13147,7 @@ const useOAuth = (hookOptions = {}) => {
12747
13147
  const [status, setStatus] = useState({
12748
13148
  status: "idle",
12749
13149
  });
12750
- const { tryUseWallet } = useCreateWalletPostAuth();
13150
+ const { tryUseWallet } = useConnectToWalletPostAuth();
12751
13151
  const storeCredentials = useCallback(async ({ player, accessToken, refreshToken, ...options }) => {
12752
13152
  setStatus({
12753
13153
  status: 'loading',
@@ -12995,7 +13395,7 @@ const useGuestAuth = (hookOptions = {}) => {
12995
13395
  const [status, setStatus] = useState({
12996
13396
  status: "idle",
12997
13397
  });
12998
- const { tryUseWallet } = useCreateWalletPostAuth();
13398
+ const { tryUseWallet } = useConnectToWalletPostAuth();
12999
13399
  const signUpGuest = useCallback(async (options = {}) => {
13000
13400
  try {
13001
13401
  setStatus({
@@ -13218,5 +13618,5 @@ const useWalletAuth = (hookOptions = {}) => {
13218
13618
  };
13219
13619
  };
13220
13620
 
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 };
13621
+ export { AuthProvider, Avatar, Chain as ChainIcon, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortErrorType, OpenfortProvider, OpenfortStatus, 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 };
13222
13622
  //# sourceMappingURL=index.es.js.map