@openfort/react 0.1.14 → 0.2.1

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.
Files changed (42) hide show
  1. package/build/assets/icons.d.ts +3 -0
  2. package/build/components/Common/Button/types.d.ts +1 -0
  3. package/build/components/Common/Modal/styles.d.ts +1 -0
  4. package/build/components/Common/OTPInput/index.d.ts +8 -0
  5. package/build/components/Common/OTPInput/styles.d.ts +18 -0
  6. package/build/components/Common/Providers/ProviderHeader.d.ts +7 -0
  7. package/build/components/Common/Providers/ProviderIcon.d.ts +4 -0
  8. package/build/components/Common/Providers/getProviderName.d.ts +2 -0
  9. package/build/components/FloatingGraphic/index.d.ts +3 -1
  10. package/build/components/FloatingGraphic/styles.d.ts +2 -0
  11. package/build/components/Openfort/context.d.ts +2 -0
  12. package/build/components/Openfort/types.d.ts +86 -1
  13. package/build/components/Pages/EmailOTP/index.d.ts +3 -0
  14. package/build/components/Pages/EmailOTP/styles.d.ts +4 -0
  15. package/build/components/Pages/LinkedProvider/index.d.ts +2 -0
  16. package/build/components/Pages/LinkedProviders/styles.d.ts +2 -1
  17. package/build/components/Pages/PhoneOTP/index.d.ts +3 -0
  18. package/build/components/Pages/PhoneOTP/styles.d.ts +4 -0
  19. package/build/components/Pages/Providers/index.d.ts +1 -1
  20. package/build/components/Pages/Providers/styles.d.ts +1 -0
  21. package/build/components/Pages/RemoveLinkedProvider/index.d.ts +2 -0
  22. package/build/hooks/openfort/auth/status.d.ts +3 -1
  23. package/build/hooks/openfort/auth/useAuthCallback.d.ts +7 -10
  24. package/build/hooks/openfort/auth/useEmailAuth.d.ts +2 -3
  25. package/build/hooks/openfort/auth/useEmailOtpAuth.d.ts +29 -0
  26. package/build/hooks/openfort/auth/useGuestAuth.d.ts +2 -2
  27. package/build/hooks/openfort/auth/useOAuth.d.ts +5 -6
  28. package/build/hooks/openfort/auth/usePhoneOtpAuth.d.ts +30 -0
  29. package/build/hooks/openfort/useConnectWithSiwe.d.ts +4 -3
  30. package/build/hooks/openfort/useUser.d.ts +3 -2
  31. package/build/hooks/useConnectCallback.d.ts +3 -3
  32. package/build/hooks/useRouteProps.d.ts +10 -0
  33. package/build/index.d.ts +5 -3
  34. package/build/index.es.js +1735 -561
  35. package/build/index.es.js.map +1 -1
  36. package/build/openfort/CoreOpenfortProvider.d.ts +5 -3
  37. package/build/openfortCustomTypes.d.ts +10 -0
  38. package/build/siwe/create-siwe-message.d.ts +1 -1
  39. package/build/types.d.ts +4 -4
  40. package/build/utils/validation.d.ts +1 -0
  41. package/build/version.d.ts +1 -1
  42. package/package.json +4 -3
package/build/index.es.js CHANGED
@@ -1,16 +1,16 @@
1
- import { Openfort as Openfort$1, EmbeddedState, AccountTypeEnum, SDKConfiguration, RecoveryMethod, MissingRecoveryPasswordError, ChainTypeEnum, OAuthProvider, OpenfortError as OpenfortError$1, OpenfortErrorType as OpenfortErrorType$1 } from '@openfort/openfort-js';
1
+ import { Openfort as Openfort$1, EmbeddedState, AccountTypeEnum, SDKConfiguration, RecoveryMethod, MissingRecoveryPasswordError, ChainTypeEnum, OAuthProvider, OpenfortError as OpenfortError$1 } from '@openfort/openfort-js';
2
2
  export { AccountTypeEnum, OAuthProvider, OpenfortEvents, RecoveryMethod, ThirdPartyOAuthProvider, openfortEvents } from '@openfort/openfort-js';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import React, { useState, useEffect, createContext, useRef, useId, useMemo, useCallback, createElement, useLayoutEffect } from 'react';
5
5
  import { normalize } from 'viem/ens';
6
- import { useEnsAddress, useEnsName, useEnsAvatar, useConfig, useAccount, useBlockNumber, useBalance, useConnectors as useConnectors$1, useConnect as useConnect$1, useDisconnect, useChainId, http, useSwitchChain, useWalletClient, useEstimateGas, useEstimateFeesPerGas, useReadContract, useSendTransaction, useWriteContract, useWaitForTransactionReceipt, usePublicClient, WagmiContext } from 'wagmi';
6
+ import { useEnsAddress, useEnsName, useEnsAvatar, useConfig, useAccount, useBlockNumber, useBalance, useConnectors as useConnectors$1, useConnect as useConnect$1, useDisconnect, useChainId, http, useSwitchChain, useWalletClient, useEstimateGas, useEstimateFeesPerGas, useReadContract, useSendTransaction, useWriteContract, useWaitForTransactionReceipt, usePublicClient, useSignMessage, WagmiContext } from 'wagmi';
7
7
  import { motion, AnimatePresence, MotionConfig } from 'framer-motion';
8
- import styled$1, { css, keyframes } from 'styled-components';
8
+ import styled$1, { css, keyframes, createGlobalStyle } from 'styled-components';
9
9
  import { detect } from 'detect-browser';
10
10
  import { useQueryClient, useQuery } from '@tanstack/react-query';
11
11
  import useMeasure from 'react-use-measure';
12
12
  import { Buffer } from 'buffer';
13
- import { mainnet, polygon, optimism, arbitrum, sepolia } from 'wagmi/chains';
13
+ import { mainnet, polygon, optimism, arbitrum } from 'wagmi/chains';
14
14
  import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
15
15
  import { useTransition } from 'react-transition-state';
16
16
  import ResizeObserver from 'resize-observer-polyfill';
@@ -19,7 +19,8 @@ import { numberToHex, formatUnits, parseUnits, isAddress, parseAbi, encodeFuncti
19
19
  import { erc7811Actions, erc7715Actions } from 'viem/experimental';
20
20
  import calculateEntropy from 'fast-password-entropy';
21
21
  import QRCodeUtil from 'qrcode';
22
- import { switchChain, signMessage } from '@wagmi/core';
22
+ import { PhoneInput } from 'react-international-phone';
23
+ import { switchChain } from '@wagmi/core';
23
24
  import { AxiosError } from 'axios';
24
25
  import { createSiweMessage } from 'viem/siwe';
25
26
  import { hashAuthorization } from 'viem/utils';
@@ -1912,6 +1913,8 @@ const routes = {
1912
1913
  CONNECTED_SUCCESS: 'connectedSuccess',
1913
1914
  CREATE_GUEST_USER: 'createGuestUser',
1914
1915
  EMAIL_LOGIN: 'emailLogin',
1916
+ EMAIL_OTP: 'emailOtp',
1917
+ PHONE_OTP: 'phoneOtp',
1915
1918
  FORGOT_PASSWORD: 'forgotPassword',
1916
1919
  EMAIL_VERIFICATION: 'emailVerification',
1917
1920
  LINK_EMAIL: 'linkEmail',
@@ -1925,7 +1928,9 @@ const routes = {
1925
1928
  CONNECTED: 'connected',
1926
1929
  PROFILE: 'profile',
1927
1930
  SWITCHNETWORKS: 'switchNetworks',
1931
+ LINKED_PROVIDER: 'linkedProvider',
1928
1932
  LINKED_PROVIDERS: 'linkedProviders',
1933
+ REMOVE_LINKED_PROVIDER: 'removeLinkedProvider',
1929
1934
  EXPORT_KEY: 'exportKey',
1930
1935
  NO_ASSETS_AVAILABLE: 'noAssetsAvailable',
1931
1936
  ASSET_INVENTORY: 'assetInventory',
@@ -1952,6 +1957,7 @@ var UIAuthProvider;
1952
1957
  (function (UIAuthProvider) {
1953
1958
  UIAuthProvider["GOOGLE"] = "google";
1954
1959
  UIAuthProvider["TWITTER"] = "twitter";
1960
+ UIAuthProvider["X"] = "twitter";
1955
1961
  UIAuthProvider["FACEBOOK"] = "facebook";
1956
1962
  UIAuthProvider["DISCORD"] = "discord";
1957
1963
  // EPIC_GAMES = "epic_games",
@@ -1959,7 +1965,13 @@ var UIAuthProvider;
1959
1965
  // TELEGRAM = "telegram", // Telegram is not working yet
1960
1966
  UIAuthProvider["APPLE"] = "apple";
1961
1967
  // Extended Providers
1962
- UIAuthProvider["EMAIL"] = "email";
1968
+ /**
1969
+ * @deprecated Use `UIAuthProvider.EMAIL_PASSWORD` or `UIAuthProvider.EMAIL_OTP` instead.
1970
+ */
1971
+ UIAuthProvider["EMAIL"] = "emailPassword";
1972
+ UIAuthProvider["EMAIL_PASSWORD"] = "emailPassword";
1973
+ UIAuthProvider["EMAIL_OTP"] = "emailOtp";
1974
+ UIAuthProvider["PHONE"] = "phone";
1963
1975
  UIAuthProvider["WALLET"] = "wallet";
1964
1976
  UIAuthProvider["GUEST"] = "guest";
1965
1977
  })(UIAuthProvider || (UIAuthProvider = {}));
@@ -4544,6 +4556,7 @@ const CoreOpenfortProvider = ({ children, onConnect, onDisconnect, openfortConfi
4544
4556
  const { connectors, connect, reset } = useConnect();
4545
4557
  const { address } = useAccount();
4546
4558
  const [user, setUser] = useState(null);
4559
+ const [linkedAccounts, setLinkedAccounts] = useState([]);
4547
4560
  const [walletStatus, setWalletStatus] = useState({ status: 'idle' });
4548
4561
  const { disconnectAsync } = useDisconnect();
4549
4562
  const { walletConfig } = useOpenfort();
@@ -4619,7 +4632,9 @@ const CoreOpenfortProvider = ({ children, onConnect, onDisconnect, openfortConfi
4619
4632
  }
4620
4633
  try {
4621
4634
  const user = await openfort.user.get();
4635
+ const linkedAccounts = await openfort.user.list();
4622
4636
  logger.log('Getting user');
4637
+ setLinkedAccounts(linkedAccounts);
4623
4638
  setUser(user);
4624
4639
  return user;
4625
4640
  }
@@ -4803,6 +4818,7 @@ const CoreOpenfortProvider = ({ children, onConnect, onDisconnect, openfortConfi
4803
4818
  isLoading: isLoading(),
4804
4819
  needsRecovery,
4805
4820
  user,
4821
+ linkedAccounts,
4806
4822
  updateUser,
4807
4823
  updateEmbeddedAccounts: fetchEmbeddedAccounts,
4808
4824
  embeddedAccounts,
@@ -4878,7 +4894,7 @@ const SendIcon = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width:
4878
4894
  const ReceiveIcon = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("path", { d: "M19 5L5 19", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M15 19H5V9", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" })] }));
4879
4895
  const BuyIcon = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("rect", { x: "3", y: "6", width: "18", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M3 10H21", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M7 14H9", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" })] }));
4880
4896
  const DollarIcon = (props) => (jsxs("svg", { width: "800px", height: "800px", viewBox: "0 0 24 24", role: "img", xmlns: "http://www.w3.org/2000/svg", "aria-labelledby": "dolarIconTitle", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", fill: "none", color: "currentColor", ...props, children: [jsx("title", { id: "dolarIconTitle", children: "Dolar" }), jsx("path", { d: "M12 4L12 6M12 18L12 20M15.5 8C15.1666667 6.66666667 14 6 12 6 9 6 8.5 7.95652174 8.5 9 8.5 13.140327 15.5 10.9649412 15.5 15 15.5 16.0434783 15 18 12 18 10 18 8.83333333 17.3333333 8.5 16" })] }));
4881
- const WalletIcon$2 = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("rect", { x: "3", y: "6", width: "18", height: "14", rx: "2.5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M21 10H17C15.8954 10 15 10.8954 15 12C15 13.1046 15.8954 14 17 14H21V10Z", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("circle", { cx: "17", cy: "12", r: "1", fill: "currentColor" })] }));
4897
+ const WalletIcon$1 = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("rect", { x: "3", y: "6", width: "18", height: "14", rx: "2.5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M21 10H17C15.8954 10 15 10.8954 15 12C15 13.1046 15.8954 14 17 14H21V10Z", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("circle", { cx: "17", cy: "12", r: "1", fill: "currentColor" })] }));
4882
4898
  const ExternalLinkIcon = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: {
4883
4899
  left: 0,
4884
4900
  top: 0,
@@ -4933,6 +4949,7 @@ const RetryIconCircle = ({ ...props }) => {
4933
4949
  };
4934
4950
  const CopyToClipboardIcon = ({ ...props }) => (jsxs("svg", { "aria-hidden": "true", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("path", { d: "M14 9.5V7C14 5.89543 13.1046 5 12 5H7C5.89543 5 5 5.89543 5 7V12C5 13.1046 5.89543 14 7 14H9.5", stroke: "var(--ck-body-color-muted)", strokeWidth: "2" }), jsx("rect", { x: "10", y: "10", width: "9", height: "9", rx: "2", stroke: "var(--ck-body-color-muted)", strokeWidth: "2" }), jsx("path", { d: "M1 3L3 5L7 1", stroke: "var(--ck-body-color)", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" })] }));
4935
4951
  const EmailIcon = ({ ...props }) => (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", width: "256", height: "256", children: [jsx("rect", { width: "256", height: "256", fill: "none" }), jsx("path", { d: "M32,96V200a8,8,0,0,0,8,8H216a8,8,0,0,0,8-8V96L128,32Z", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" }), jsx("polyline", { points: "224 96 145.46 152 110.55 152 32 96", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" })] }));
4952
+ const PhoneIcon = ({ ...props }) => (jsx("svg", { id: "Layer_1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", viewBox: "0 0 32 32", enableBackground: "new 0 0 32 32", xmlSpace: "preserve", ...props, children: jsx("path", { fill: "none", stroke: "currentColor", strokeWidth: 2, strokeMiterlimit: 10, d: "M13.6,8.5L9.5,4.3C9,3.9,8.3,3.9,7.8,4.3L4.7,7.5 C4,8.1,3.8,9.1,4.1,9.9c0.8,2.3,2.9,6.9,7,11s8.7,6.1,11,7c0.9,0.3,1.8,0.1,2.5-0.5l3.1-3.1c0.5-0.5,0.5-1.2,0-1.7l-4.1-4.1 c-0.5-0.5-1.2-0.5-1.7,0l-2.5,2.5c0,0-2.8-1.2-5-3.3s-3.3-5-3.3-5l2.5-2.5C14.1,9.7,14.1,8.9,13.6,8.5z" }) }));
4936
4953
  const GuestIcon = ({ ...props }) => (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", width: "256", height: "256", children: [jsx("rect", { width: "256", height: "256", fill: "none" }), jsx("circle", { cx: "128", cy: "96", r: "64", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" }), jsx("path", { d: "M32,216c19.37-33.47,54.55-56,96-56s76.63,22.53,96,56", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" })] }));
4937
4954
  const EyeIcon = ({ ...props }) => (jsxs("svg", { width: "800", height: "800", fill: "none", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: [jsx("path", { d: "m15.001 12c0 1.6569-1.3431 3-3 3-1.6568 0-3-1.3431-3-3s1.3432-3 3-3c1.6569 0 3 1.3431 3 3z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2 }), jsx("path", { d: "m12.001 5c-4.4777 0-8.2679 2.9429-9.5422 7 1.2743 4.0571 5.0646 7 9.5422 7 4.4776 0 8.2679-2.9429 9.5422-7-1.2743-4.0571-5.0646-7-9.5422-7z", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2 })] }));
4938
4955
  const EyeOffIcon = ({ ...props }) => (jsx("svg", { width: "800", height: "800", fill: "none", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: jsx("path", { d: "m2.999 3 18 18m-11.156-11.086c-0.52264 0.53996-0.84428 1.2756-0.84428 2.0864 0 1.6569 1.3432 3 3 3 0.8225 0 1.5677-0.331 2.1096-0.867m-7.6096-7.4858c-1.8993 1.2532-3.346 3.1368-4.042 5.3528 1.2742 4.0571 5.0646 7 9.5422 7 1.9889 0 3.8422-0.5806 5.3996-1.5816m-6.3998-12.369c0.329-0.03266 0.6627-0.04939 1.0002-0.04939 4.4777 0 8.268 2.9429 9.5422 7-0.2807 0.894-0.6837 1.7338-1.1892 2.5", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2 }) }));
@@ -5631,7 +5648,7 @@ const FitText = ({ children, maxFontSize = 100, minFontSize = 70, justifyContent
5631
5648
  };
5632
5649
  FitText.displayName = 'FitText';
5633
5650
 
5634
- const OPENFORT_VERSION = '0.1.14';
5651
+ const OPENFORT_VERSION = '0.2.1';
5635
5652
 
5636
5653
  const Portal = (props) => {
5637
5654
  props = {
@@ -5668,7 +5685,7 @@ const PageContentStyle = styled(motion.div) `
5668
5685
  padding-top: 48px;
5669
5686
  `;
5670
5687
 
5671
- const ErrorMessage$1 = styled(motion.div) `
5688
+ const ErrorMessage$2 = styled(motion.div) `
5672
5689
  z-index: -1;
5673
5690
  pointer-events: auto;
5674
5691
  position: absolute;
@@ -5829,6 +5846,8 @@ const ModalBody = styled.div `
5829
5846
  color: ${(props) => {
5830
5847
  if (props.$error)
5831
5848
  return 'var(--ck-body-color-danger)';
5849
+ if (props.$valid)
5850
+ return 'var(--ck-body-color-valid)';
5832
5851
  return 'var(--ck-body-color-muted)';
5833
5852
  }};
5834
5853
  strong {
@@ -6461,8 +6480,6 @@ onInfo, }) => {
6461
6480
  return 'Reset your password'; // TODO: Localize
6462
6481
  case routes.EMAIL_VERIFICATION:
6463
6482
  return 'Email Verification'; // TODO: Localize
6464
- case routes.SOCIAL_PROVIDERS:
6465
- return 'Other socials'; // TODO: Localize
6466
6483
  case routes.CONNECT:
6467
6484
  if (shouldUseQrcode()) {
6468
6485
  return isWalletConnectConnector((_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.id)
@@ -6501,7 +6518,7 @@ onInfo, }) => {
6501
6518
  width: 'var(--width)',
6502
6519
  zIndex: 9,
6503
6520
  transition: 'width 200ms ease',
6504
- } }), jsxs(BoxContainer, { className: `${rendered && 'active'}`, children: [jsx(AnimatePresence, { initial: false, children: context.errorMessage && (jsxs(ErrorMessage$1, { initial: { y: '10%', x: '-50%' }, animate: { y: '-100%' }, exit: { y: '100%' }, transition: { duration: 0.2, ease: 'easeInOut' }, children: [jsx("span", { children: context.errorMessage }), jsx("button", { type: "button", "aria-label": flattenChildren(locales.close).toString(), style: {
6521
+ } }), jsxs(BoxContainer, { className: `${rendered && 'active'}`, children: [jsx(AnimatePresence, { initial: false, children: context.errorMessage && (jsxs(ErrorMessage$2, { initial: { y: '10%', x: '-50%' }, animate: { y: '-100%' }, exit: { y: '100%' }, transition: { duration: 0.2, ease: 'easeInOut' }, children: [jsx("span", { children: context.errorMessage }), jsx("button", { type: "button", "aria-label": flattenChildren(locales.close).toString(), style: {
6505
6522
  position: 'absolute',
6506
6523
  right: 24,
6507
6524
  top: 24,
@@ -6909,7 +6926,7 @@ const transition = {
6909
6926
  ease: [0.175, 0.885, 0.32, 0.98],
6910
6927
  };
6911
6928
  const Button = ({ className, children, variant = 'secondary', // unique aspect to how we're handling buttons
6912
- disabled, icon, iconPosition = 'left', roundedIcon, waiting, arrow, download, href, style, onClick, textAlign, title, }) => {
6929
+ disabled, icon, iconPosition = 'left', roundedIcon, waiting, arrow, download, href, style, onClick, textAlign, title, fitText = true, }) => {
6913
6930
  const key = typeof children === 'string' ? children : flattenChildren(children).join(''); // Need to generate a string for the key so we can automatically animate between content
6914
6931
  const hrefUrl = href && (typeof href === 'string' ? href : flattenChildren(href).join('')); // Need to have a flat string for the href
6915
6932
  return (jsx(ButtonContainer, { className: className, as: href ? 'a' : undefined, onClick: (event) => {
@@ -6928,17 +6945,17 @@ disabled, icon, iconPosition = 'left', roundedIcon, waiting, arrow, download, hr
6928
6945
  }, transition: {
6929
6946
  ...transition,
6930
6947
  delay: 0.2,
6931
- }, children: [icon && iconPosition === 'left' && jsx(IconContainer$2, { "$rounded": roundedIcon, children: icon }), download && (jsx(DownloadArrow, { children: jsx(DownloadArrowInner, { children: jsxs(Arrow, { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx(ArrowLine, { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "var(--stroke-width)", strokeLinecap: "round" }), jsx(ArrowChevron, { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "var(--stroke-width)", strokeLinecap: "round" })] }) }) })), jsx(InnerContainer, { style: { paddingLeft: arrow ? 6 : 0 }, children: jsx(FitText, { justifyContent: textAlign, children: children }) }), icon && iconPosition === 'right' && jsx(IconContainer$2, { "$rounded": roundedIcon, children: icon }), arrow && (jsxs(Arrow, { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx(ArrowLine, { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "2", strokeLinecap: "round" }), jsx(ArrowChevron, { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "2", strokeLinecap: "round" })] }))] }, key), waiting && (jsx(SpinnerContainer$2, { children: jsx(Spinner$3, {}) }))] }) }));
6948
+ }, children: [icon && iconPosition === 'left' && jsx(IconContainer$2, { "$rounded": roundedIcon, children: icon }), download && (jsx(DownloadArrow, { children: jsx(DownloadArrowInner, { children: jsxs(Arrow, { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx(ArrowLine, { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "var(--stroke-width)", strokeLinecap: "round" }), jsx(ArrowChevron, { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "var(--stroke-width)", strokeLinecap: "round" })] }) }) })), jsx(InnerContainer, { style: { paddingLeft: arrow ? 6 : 0 }, children: fitText ? jsx(FitText, { justifyContent: textAlign, children: children }) : children }), icon && iconPosition === 'right' && jsx(IconContainer$2, { "$rounded": roundedIcon, children: icon }), arrow && (jsxs(Arrow, { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx(ArrowLine, { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "2", strokeLinecap: "round" }), jsx(ArrowChevron, { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "2", strokeLinecap: "round" })] }))] }, key), waiting && (jsx(SpinnerContainer$2, { children: jsx(Spinner$3, {}) }))] }) }));
6932
6949
  };
6933
6950
 
6934
- var OpenfortErrorType;
6935
- (function (OpenfortErrorType) {
6936
- OpenfortErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
6937
- OpenfortErrorType["WALLET_ERROR"] = "WALLET_ERROR";
6938
- OpenfortErrorType["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
6939
- OpenfortErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
6940
- OpenfortErrorType["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
6941
- })(OpenfortErrorType || (OpenfortErrorType = {}));
6951
+ var OpenfortReactErrorType;
6952
+ (function (OpenfortReactErrorType) {
6953
+ OpenfortReactErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
6954
+ OpenfortReactErrorType["WALLET_ERROR"] = "WALLET_ERROR";
6955
+ OpenfortReactErrorType["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
6956
+ OpenfortReactErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
6957
+ OpenfortReactErrorType["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
6958
+ })(OpenfortReactErrorType || (OpenfortReactErrorType = {}));
6942
6959
  class OpenfortError extends Error {
6943
6960
  constructor(message, type, data) {
6944
6961
  if ((data === null || data === void 0 ? void 0 : data.error) instanceof OpenfortError) {
@@ -6984,7 +7001,7 @@ const mapStatus = (status) => {
6984
7001
  isLoading: status.status === 'loading',
6985
7002
  isError: status.status === 'error',
6986
7003
  isSuccess: status.status === 'success',
6987
- error: status.error,
7004
+ error: 'error' in status ? status.error : undefined,
6988
7005
  };
6989
7006
  };
6990
7007
 
@@ -7066,7 +7083,7 @@ function useSignOut(hookOptions = {}) {
7066
7083
  });
7067
7084
  }
7068
7085
  catch (e) {
7069
- const error = new OpenfortError('Failed to sign out', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
7086
+ const error = new OpenfortError('Failed to sign out', OpenfortReactErrorType.AUTHENTICATION_ERROR, { error: e });
7070
7087
  setStatus({
7071
7088
  status: 'error',
7072
7089
  error,
@@ -7592,7 +7609,7 @@ const useWalletAssets = ({ assets: hookCustomAssets, staleTime = 30000 } = {}) =
7592
7609
  queryKey: ['wallet-assets', chainId, customAssetsToFetch, address],
7593
7610
  queryFn: async () => {
7594
7611
  if (!walletClient) {
7595
- throw new OpenfortError('No wallet client available', OpenfortErrorType.UNEXPECTED_ERROR, {
7612
+ throw new OpenfortError('No wallet client available', OpenfortReactErrorType.UNEXPECTED_ERROR, {
7596
7613
  error: new Error('Wallet client not initialized'),
7597
7614
  });
7598
7615
  }
@@ -7649,7 +7666,7 @@ const useWalletAssets = ({ assets: hookCustomAssets, staleTime = 30000 } = {}) =
7649
7666
  };
7650
7667
  }
7651
7668
  else {
7652
- throw new OpenfortError('Unsupported asset type', OpenfortErrorType.UNEXPECTED_ERROR, { asset: a });
7669
+ throw new OpenfortError('Unsupported asset type', OpenfortReactErrorType.UNEXPECTED_ERROR, { asset: a });
7653
7670
  }
7654
7671
  return asset;
7655
7672
  });
@@ -7692,7 +7709,7 @@ const useWalletAssets = ({ assets: hookCustomAssets, staleTime = 30000 } = {}) =
7692
7709
  if (error instanceof OpenfortError) {
7693
7710
  return error;
7694
7711
  }
7695
- return new OpenfortError('Failed to fetch wallet assets', OpenfortErrorType.UNEXPECTED_ERROR, { error });
7712
+ return new OpenfortError('Failed to fetch wallet assets', OpenfortReactErrorType.UNEXPECTED_ERROR, { error });
7696
7713
  }, [error]);
7697
7714
  return {
7698
7715
  data: data !== null && data !== void 0 ? data : null,
@@ -10363,12 +10380,12 @@ const Content = styled(motion.div) `
10363
10380
  gap: 12px;
10364
10381
  }
10365
10382
  `;
10366
- const dist$1 = 2;
10367
- const shakeKeyframes$1 = keyframes `
10383
+ const dist$2 = 2;
10384
+ const shakeKeyframes$2 = keyframes `
10368
10385
  0%{ transform:none; }
10369
- 25%{ transform:translateX(${dist$1}px); }
10370
- 50%{ transform:translateX(-${dist$1}px); }
10371
- 75%{ transform:translateX(${dist$1}px); }
10386
+ 25%{ transform:translateX(${dist$2}px); }
10387
+ 50%{ transform:translateX(-${dist$2}px); }
10388
+ 75%{ transform:translateX(${dist$2}px); }
10372
10389
  100%{ transform:none; }
10373
10390
  `;
10374
10391
  const outlineKeyframes$1 = keyframes `
@@ -10410,7 +10427,7 @@ const ConnectingAnimation$1 = styled(motion.div) `
10410
10427
  }
10411
10428
  ${(props) => props.$shake &&
10412
10429
  css `
10413
- animation: ${shakeKeyframes$1} 220ms ease-out both;
10430
+ animation: ${shakeKeyframes$2} 220ms ease-out both;
10414
10431
  &:before {
10415
10432
  animation: ${outlineKeyframes$1} 220ms ease-out 750ms both;
10416
10433
  }
@@ -10493,12 +10510,12 @@ justify-content: center;
10493
10510
  margin: 10px auto 16px;
10494
10511
  height: 120px;
10495
10512
  `;
10496
- const dist = 2;
10497
- const shakeKeyframes = keyframes `
10513
+ const dist$1 = 2;
10514
+ const shakeKeyframes$1 = keyframes `
10498
10515
  0%{ transform:none; }
10499
- 25%{ transform:translateX(${dist}px); }
10500
- 50%{ transform:translateX(-${dist}px); }
10501
- 75%{ transform:translateX(${dist}px); }
10516
+ 25%{ transform:translateX(${dist$1}px); }
10517
+ 50%{ transform:translateX(-${dist$1}px); }
10518
+ 75%{ transform:translateX(${dist$1}px); }
10502
10519
  100%{ transform:none; }
10503
10520
  `;
10504
10521
  const outlineKeyframes = keyframes `
@@ -10525,7 +10542,7 @@ const ConnectingAnimation = styled(motion.div) `
10525
10542
  `}
10526
10543
  ${(props) => props.$shake &&
10527
10544
  css `
10528
- animation: ${shakeKeyframes} 220ms ease-out both;
10545
+ animation: ${shakeKeyframes$1} 220ms ease-out both;
10529
10546
  &:before {
10530
10547
  animation: ${outlineKeyframes} 220ms ease-out both;
10531
10548
  }
@@ -11278,7 +11295,7 @@ const Connectors = ({ logoutOnBack }) => {
11278
11295
  * console.log('User is authenticated:', userHook.user);
11279
11296
  * console.log('User ID:', userHook.user.id);
11280
11297
  * console.log('User email:', userHook.user.email);
11281
- * console.log('Linked accounts:', userHook.user.linkedAccounts);
11298
+ * console.log('Linked accounts:', userHook.linkedAccounts);
11282
11299
  * } else {
11283
11300
  * console.log('User is not authenticated');
11284
11301
  * }
@@ -11305,7 +11322,7 @@ const Connectors = ({ logoutOnBack }) => {
11305
11322
  * ```
11306
11323
  */
11307
11324
  function useUser() {
11308
- const { user, client, embeddedState } = useOpenfortCore();
11325
+ const { user, client, embeddedState, linkedAccounts } = useOpenfortCore();
11309
11326
  const getAccessTokenAndUpdate = useCallback(async () => {
11310
11327
  try {
11311
11328
  await client.validateAndRefreshToken();
@@ -11328,6 +11345,7 @@ function useUser() {
11328
11345
  }, [client]);
11329
11346
  return {
11330
11347
  user,
11348
+ linkedAccounts,
11331
11349
  isAuthenticated: embeddedState !== EmbeddedState.NONE && embeddedState !== EmbeddedState.UNAUTHENTICATED,
11332
11350
  getAccessToken: getAccessTokenAndUpdate,
11333
11351
  validateAndRefreshToken: validateAndRefresh,
@@ -11423,7 +11441,7 @@ const mapWalletStatus = (status) => {
11423
11441
  */
11424
11442
  function useWallets(hookOptions = {}) {
11425
11443
  const { client, embeddedAccounts, isLoadingAccounts: isLoadingWallets, updateEmbeddedAccounts } = useOpenfortCore();
11426
- const { user } = useUser();
11444
+ const { linkedAccounts } = useUser();
11427
11445
  const { walletConfig, setOpen, setRoute, setConnector, uiConfig } = useOpenfort();
11428
11446
  const { connector, isConnected, address } = useAccount();
11429
11447
  const chainId = useChainId();
@@ -11435,7 +11453,7 @@ function useWallets(hookOptions = {}) {
11435
11453
  const { connect } = useConnect({
11436
11454
  mutation: {
11437
11455
  onError: (e) => {
11438
- const error = new OpenfortError('Failed to connect with wallet: ', OpenfortErrorType.AUTHENTICATION_ERROR, e);
11456
+ const error = new OpenfortError('Failed to connect with wallet: ', OpenfortReactErrorType.AUTHENTICATION_ERROR, e);
11439
11457
  setStatus({
11440
11458
  status: 'error',
11441
11459
  error,
@@ -11452,7 +11470,7 @@ function useWallets(hookOptions = {}) {
11452
11470
  !data.accounts.some((a) => { var _a; return a.toLowerCase() === ((_a = connectToConnector.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); })) {
11453
11471
  setStatus({
11454
11472
  status: 'error',
11455
- error: new OpenfortError('Failed to connect with wallet: Address mismatch', OpenfortErrorType.AUTHENTICATION_ERROR),
11473
+ error: new OpenfortError('Failed to connect with wallet: Address mismatch', OpenfortReactErrorType.AUTHENTICATION_ERROR),
11456
11474
  });
11457
11475
  disconnect();
11458
11476
  return;
@@ -11487,7 +11505,7 @@ function useWallets(hookOptions = {}) {
11487
11505
  case RecoveryMethod.AUTOMATIC: {
11488
11506
  const accessToken = await client.getAccessToken();
11489
11507
  if (!accessToken) {
11490
- throw new OpenfortError('Openfort access token not found', OpenfortErrorType.AUTHENTICATION_ERROR);
11508
+ throw new OpenfortError('Openfort access token not found', OpenfortReactErrorType.AUTHENTICATION_ERROR);
11491
11509
  }
11492
11510
  return {
11493
11511
  recoveryMethod: RecoveryMethod.AUTOMATIC,
@@ -11498,7 +11516,7 @@ function useWallets(hookOptions = {}) {
11498
11516
  }
11499
11517
  case RecoveryMethod.PASSWORD:
11500
11518
  if (!recovery.password) {
11501
- throw new OpenfortError('Please enter your password', OpenfortErrorType.VALIDATION_ERROR);
11519
+ throw new OpenfortError('Please enter your password', OpenfortReactErrorType.VALIDATION_ERROR);
11502
11520
  }
11503
11521
  return {
11504
11522
  recoveryMethod: RecoveryMethod.PASSWORD,
@@ -11513,13 +11531,13 @@ function useWallets(hookOptions = {}) {
11513
11531
  if (!walletAddress) {
11514
11532
  walletAddress = (_a = embeddedAccounts.find((w) => w.recoveryMethod === RecoveryMethod.PASSKEY)) === null || _a === void 0 ? void 0 : _a.address;
11515
11533
  if (!walletAddress) {
11516
- throw new OpenfortError('No wallet address provided and no embedded wallet with passkey recovery found', OpenfortErrorType.VALIDATION_ERROR);
11534
+ throw new OpenfortError('No wallet address provided and no embedded wallet with passkey recovery found', OpenfortReactErrorType.VALIDATION_ERROR);
11517
11535
  }
11518
11536
  }
11519
11537
  const details = (_b = embeddedAccounts.find((w) => w.address.toLowerCase() === (walletAddress === null || walletAddress === void 0 ? void 0 : walletAddress.toLowerCase()) && w.recoveryMethod === RecoveryMethod.PASSKEY)) === null || _b === void 0 ? void 0 : _b.recoveryMethodDetails;
11520
11538
  const passkeyId = details === null || details === void 0 ? void 0 : details.passkeyId;
11521
11539
  if (!passkeyId) {
11522
- throw new OpenfortError('No passkey details found for the wallet', OpenfortErrorType.VALIDATION_ERROR);
11540
+ throw new OpenfortError('No passkey details found for the wallet', OpenfortReactErrorType.VALIDATION_ERROR);
11523
11541
  }
11524
11542
  return {
11525
11543
  recoveryMethod: RecoveryMethod.PASSKEY,
@@ -11529,19 +11547,19 @@ function useWallets(hookOptions = {}) {
11529
11547
  };
11530
11548
  }
11531
11549
  default:
11532
- throw new OpenfortError('Invalid recovery method', OpenfortErrorType.VALIDATION_ERROR);
11550
+ throw new OpenfortError('Invalid recovery method', OpenfortReactErrorType.VALIDATION_ERROR);
11533
11551
  }
11534
11552
  }, [walletConfig, getEncryptionSession]);
11535
11553
  const userLinkedWalletConnectors = useMemo(() => {
11536
- const userWallets = user
11537
- ? user.linkedAccounts
11554
+ const userWallets = linkedAccounts
11555
+ ? linkedAccounts
11538
11556
  .filter((linkedAccount) => linkedAccount.provider === UIAuthProvider.WALLET)
11539
11557
  .map((linkedAccount) => {
11540
11558
  // For connector wallets (e.g. Metamask, Rabby, etc.)
11541
11559
  const wallet = availableWallets.find((c) => c.connector.id === linkedAccount.walletClientType);
11542
11560
  return {
11543
11561
  accounts: [],
11544
- address: linkedAccount.address,
11562
+ address: linkedAccount.accountId,
11545
11563
  connectorType: linkedAccount.connectorType,
11546
11564
  walletClientType: linkedAccount.walletClientType,
11547
11565
  id: (wallet === null || wallet === void 0 ? void 0 : wallet.id) || linkedAccount.walletClientType || 'unknown',
@@ -11551,7 +11569,7 @@ function useWallets(hookOptions = {}) {
11551
11569
  })
11552
11570
  : [];
11553
11571
  return userWallets;
11554
- }, [user === null || user === void 0 ? void 0 : user.linkedAccounts, embeddedAccounts]);
11572
+ }, [linkedAccounts, embeddedAccounts]);
11555
11573
  const userEmbeddedWallets = useMemo(() => {
11556
11574
  const newRawWallets = [];
11557
11575
  embeddedAccounts === null || embeddedAccounts === void 0 ? void 0 : embeddedAccounts.forEach((embeddedAccount) => {
@@ -11599,7 +11617,7 @@ function useWallets(hookOptions = {}) {
11599
11617
  const wallet = availableWallets.find((c) => c.id === optionsObject.walletId);
11600
11618
  if (!wallet) {
11601
11619
  logger.log('Connector not found', connector);
11602
- return { error: new OpenfortError('Connector not found', OpenfortErrorType.WALLET_ERROR) };
11620
+ return { error: new OpenfortError('Connector not found', OpenfortReactErrorType.WALLET_ERROR) };
11603
11621
  }
11604
11622
  logger.log('Connecting to', wallet.connector);
11605
11623
  connector = wallet.connector;
@@ -11609,7 +11627,7 @@ function useWallets(hookOptions = {}) {
11609
11627
  }
11610
11628
  if (!connector) {
11611
11629
  logger.log('Connector not found', availableWallets, optionsObject.walletId);
11612
- return { error: new OpenfortError('Connector not found', OpenfortErrorType.WALLET_ERROR) };
11630
+ return { error: new OpenfortError('Connector not found', OpenfortReactErrorType.WALLET_ERROR) };
11613
11631
  }
11614
11632
  if ((activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id) === connector.id && (address === null || address === void 0 ? void 0 : address.toLowerCase()) === ((_a = optionsObject.address) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
11615
11633
  logger.log(`Already connected to ${connector.id} with address ${address}, skipping connection`);
@@ -11621,7 +11639,7 @@ function useWallets(hookOptions = {}) {
11621
11639
  if (!walletToConnect) {
11622
11640
  logger.log('Wallet not found', connector);
11623
11641
  return onError({
11624
- error: new OpenfortError('Wallet not found', OpenfortErrorType.AUTHENTICATION_ERROR),
11642
+ error: new OpenfortError('Wallet not found', OpenfortReactErrorType.AUTHENTICATION_ERROR),
11625
11643
  options: optionsObject,
11626
11644
  hookOptions,
11627
11645
  });
@@ -11651,7 +11669,7 @@ function useWallets(hookOptions = {}) {
11651
11669
  });
11652
11670
  if (!walletConfig) {
11653
11671
  return onError({
11654
- error: new OpenfortError('Embedded signer not enabled', OpenfortErrorType.WALLET_ERROR),
11672
+ error: new OpenfortError('Embedded signer not enabled', OpenfortReactErrorType.WALLET_ERROR),
11655
11673
  options: optionsObject,
11656
11674
  hookOptions,
11657
11675
  });
@@ -11686,7 +11704,7 @@ function useWallets(hookOptions = {}) {
11686
11704
  return w.address.toLowerCase() === addressToMatch && !!w.chainId;
11687
11705
  });
11688
11706
  if (!accountToRecoverInDifferentChain || !accountToRecoverInDifferentChain.chainId) {
11689
- throw new OpenfortError(`Embedded wallet not found for address ${walletAddress}`, OpenfortErrorType.WALLET_ERROR);
11707
+ throw new OpenfortError(`Embedded wallet not found for address ${walletAddress}`, OpenfortReactErrorType.WALLET_ERROR);
11690
11708
  }
11691
11709
  logger.log(`Found embedded wallet for address ${walletAddress} in different chain ${accountToRecoverInDifferentChain.chainId}.`);
11692
11710
  hasToSwitchChain = true;
@@ -11697,7 +11715,7 @@ function useWallets(hookOptions = {}) {
11697
11715
  accountToRecover.recoveryMethod &&
11698
11716
  optionsObject.recovery.recoveryMethod !== accountToRecover.recoveryMethod) {
11699
11717
  logger.log('Recovery method does not match', optionsObject.recovery.recoveryMethod, accountToRecover.recoveryMethod);
11700
- throw new OpenfortError("The recovery method you entered is incorrect and does not match the wallet's recovery method", OpenfortErrorType.WALLET_ERROR);
11718
+ throw new OpenfortError("The recovery method you entered is incorrect and does not match the wallet's recovery method", OpenfortReactErrorType.WALLET_ERROR);
11701
11719
  }
11702
11720
  const recovery = {
11703
11721
  recoveryMethod: (_c = accountToRecover.recoveryMethod) !== null && _c !== void 0 ? _c : RecoveryMethod.AUTOMATIC,
@@ -11715,7 +11733,7 @@ function useWallets(hookOptions = {}) {
11715
11733
  if ((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.accountType) === AccountTypeEnum.EOA) {
11716
11734
  accountToRecover = embeddedAccounts.find((w) => w.accountType === AccountTypeEnum.EOA);
11717
11735
  if (!accountToRecover) {
11718
- throw new OpenfortError('No embedded wallet found with type EOA', OpenfortErrorType.WALLET_ERROR);
11736
+ throw new OpenfortError('No embedded wallet found with type EOA', OpenfortReactErrorType.WALLET_ERROR);
11719
11737
  }
11720
11738
  }
11721
11739
  else {
@@ -11723,7 +11741,7 @@ function useWallets(hookOptions = {}) {
11723
11741
  if (!accountToRecover) {
11724
11742
  // 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)
11725
11743
  // TODO: Connect to wallet in the other chain and then switch chain
11726
- throw new OpenfortError('No embedded wallet found for the current chain', OpenfortErrorType.WALLET_ERROR);
11744
+ throw new OpenfortError('No embedded wallet found for the current chain', OpenfortReactErrorType.WALLET_ERROR);
11727
11745
  }
11728
11746
  }
11729
11747
  logger.log('Found embedded wallet to recover (without walletAddress)', accountToRecover);
@@ -11739,7 +11757,7 @@ function useWallets(hookOptions = {}) {
11739
11757
  walletAddress = accountToRecover.address;
11740
11758
  }
11741
11759
  if (!embeddedAccount) {
11742
- throw new OpenfortError('Failed to recover embedded wallet', OpenfortErrorType.WALLET_ERROR);
11760
+ throw new OpenfortError('Failed to recover embedded wallet', OpenfortReactErrorType.WALLET_ERROR);
11743
11761
  }
11744
11762
  setStatus({
11745
11763
  status: 'success',
@@ -11763,16 +11781,16 @@ function useWallets(hookOptions = {}) {
11763
11781
  catch (err) {
11764
11782
  let error;
11765
11783
  if (err instanceof MissingRecoveryPasswordError) {
11766
- error = new OpenfortError('Missing recovery password', OpenfortErrorType.WALLET_ERROR);
11784
+ error = new OpenfortError('Missing recovery password', OpenfortReactErrorType.WALLET_ERROR);
11767
11785
  }
11768
11786
  else if (err instanceof OpenfortError) {
11769
11787
  error = err;
11770
11788
  }
11771
11789
  else if (typeof err === 'string') {
11772
- error = new OpenfortError(err, OpenfortErrorType.WALLET_ERROR);
11790
+ error = new OpenfortError(err, OpenfortReactErrorType.WALLET_ERROR);
11773
11791
  }
11774
11792
  else {
11775
- error = new OpenfortError('Failed to recover embedded wallet', OpenfortErrorType.WALLET_ERROR, {
11793
+ error = new OpenfortError('Failed to recover embedded wallet', OpenfortReactErrorType.WALLET_ERROR, {
11776
11794
  error: err,
11777
11795
  });
11778
11796
  if (error.message === 'Wrong recovery password for this embedded signer') {
@@ -11830,10 +11848,10 @@ function useWallets(hookOptions = {}) {
11830
11848
  try {
11831
11849
  const accessToken = await client.getAccessToken();
11832
11850
  if (!accessToken) {
11833
- throw new OpenfortError('Openfort access token not found', OpenfortErrorType.WALLET_ERROR);
11851
+ throw new OpenfortError('Openfort access token not found', OpenfortReactErrorType.WALLET_ERROR);
11834
11852
  }
11835
11853
  if (!walletConfig) {
11836
- throw new OpenfortError('Embedded signer not enabled', OpenfortErrorType.WALLET_ERROR);
11854
+ throw new OpenfortError('Embedded signer not enabled', OpenfortReactErrorType.WALLET_ERROR);
11837
11855
  }
11838
11856
  const recoveryParams = await parseWalletRecovery(recovery);
11839
11857
  const accountType = (options === null || options === void 0 ? void 0 : options.accountType) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.accountType) || AccountTypeEnum.SMART_ACCOUNT;
@@ -11867,7 +11885,7 @@ function useWallets(hookOptions = {}) {
11867
11885
  const errorObj = e instanceof Error ? e : new Error('Failed to create wallet');
11868
11886
  const error = e instanceof OpenfortError
11869
11887
  ? e
11870
- : new OpenfortError('Failed to create wallet', OpenfortErrorType.WALLET_ERROR, { error: errorObj });
11888
+ : new OpenfortError('Failed to create wallet', OpenfortReactErrorType.WALLET_ERROR, { error: errorObj });
11871
11889
  setStatus({
11872
11890
  status: 'error',
11873
11891
  error,
@@ -11910,7 +11928,7 @@ function useWallets(hookOptions = {}) {
11910
11928
  return onError({
11911
11929
  hookOptions,
11912
11930
  options: params,
11913
- error: new OpenfortError('Failed to set wallet recovery', OpenfortErrorType.WALLET_ERROR, {
11931
+ error: new OpenfortError('Failed to set wallet recovery', OpenfortReactErrorType.WALLET_ERROR, {
11914
11932
  error: errorObj,
11915
11933
  }),
11916
11934
  });
@@ -12067,7 +12085,7 @@ const useGuestAuth = (hookOptions = {}) => {
12067
12085
  status: 'loading',
12068
12086
  });
12069
12087
  const result = await client.auth.signUpGuest();
12070
- const user = result.player;
12088
+ const user = result.user;
12071
12089
  await updateUser(user);
12072
12090
  const { wallet } = await tryUseWallet({
12073
12091
  logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
@@ -12083,7 +12101,7 @@ const useGuestAuth = (hookOptions = {}) => {
12083
12101
  });
12084
12102
  }
12085
12103
  catch (error) {
12086
- const openfortError = new OpenfortError('Failed to signup guest', OpenfortErrorType.AUTHENTICATION_ERROR, {
12104
+ const openfortError = new OpenfortError('Failed to signup guest', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
12087
12105
  error,
12088
12106
  });
12089
12107
  setStatus({
@@ -12212,7 +12230,10 @@ var wave = (jsxs("svg", { "aria-hidden": "true", width: "298", height: "188", vi
12212
12230
 
12213
12231
  const Graphic = styled(motion.div) `
12214
12232
  position: relative;
12215
- margin: 16px auto 20px;
12233
+ margin-top: ${({ $marginTop }) => $marginTop !== null && $marginTop !== void 0 ? $marginTop : '16px'};
12234
+ margin-bottom: ${({ $marginBottom }) => $marginBottom !== null && $marginBottom !== void 0 ? $marginBottom : '20px'};
12235
+ margin-left: auto;
12236
+ margin-right: auto;
12216
12237
  height: ${({ $height }) => $height !== null && $height !== void 0 ? $height : '190px'};
12217
12238
  max-width: 295px;
12218
12239
  pointer-events: none;
@@ -12378,8 +12399,8 @@ const Logo$1 = styled(motion.div) `
12378
12399
  const LogoGraphic = ({ size = '100%', logo }) => {
12379
12400
  return (jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { style: { transform: `scale(${size})` }, children: logo }) }) }) }) }) }));
12380
12401
  };
12381
- const FloatingGraphic = ({ height = '130px', logoCenter, logoTopRight, logoTopLeft, logoBottomRight, logoBottomLeft, }) => {
12382
- return (jsxs(Graphic, { "$height": height, children: [jsxs(LogoGroup, { children: [jsx(LogoGraphic, { ...logoCenter }), logoTopLeft ? jsx(LogoGraphic, { ...logoTopLeft }) : jsx("div", {}), logoTopRight ? jsx(LogoGraphic, { ...logoTopRight }) : jsx("div", {}), logoBottomLeft ? jsx(LogoGraphic, { ...logoBottomLeft }) : jsx("div", {}), logoBottomRight ? jsx(LogoGraphic, { ...logoBottomRight }) : jsx("div", {})] }), jsx(GraphicBackground, { children: wave })] }));
12402
+ const FloatingGraphic = ({ height = '130px', marginBottom, marginTop, logoCenter, logoTopRight, logoTopLeft, logoBottomRight, logoBottomLeft, }) => {
12403
+ return (jsxs(Graphic, { "$height": height, "$marginBottom": marginBottom, "$marginTop": marginTop, children: [jsxs(LogoGroup, { children: [jsx(LogoGraphic, { ...logoCenter }), logoTopLeft ? jsx(LogoGraphic, { ...logoTopLeft }) : jsx("div", {}), logoTopRight ? jsx(LogoGraphic, { ...logoTopRight }) : jsx("div", {}), logoBottomLeft ? jsx(LogoGraphic, { ...logoBottomLeft }) : jsx("div", {}), logoBottomRight ? jsx(LogoGraphic, { ...logoBottomRight }) : jsx("div", {})] }), jsx(GraphicBackground, { children: wave })] }));
12383
12404
  };
12384
12405
 
12385
12406
  /**
@@ -12563,6 +12584,10 @@ const PasswordStrengthIndicator = ({ password, showPasswordIsTooWeakError, }) =>
12563
12584
  }, transition: { duration: 0.3 }, style: { color: '#ef4444', fontSize: '0.875rem', fontWeight: 500, position: 'absolute', top: '0' }, children: "Password is too weak" })] })] }));
12564
12585
  };
12565
12586
 
12587
+ const PhoneGlobalStyles = createGlobalStyle `
12588
+ // Styles from react-international-phone (imported here to avoid importing the whole CSS file for nextjs compatibility)
12589
+ .react-international-phone-country-selector{position:relative}.react-international-phone-country-selector-button{display:flex;height:var(--react-international-phone-height, 36px);box-sizing:border-box;align-items:center;justify-content:center;padding:0;border:1px solid var(--react-international-phone-country-selector-border-color, var(--react-international-phone-border-color, gainsboro));margin:0;appearance:button;-webkit-appearance:button;background-color:var(--react-international-phone-country-selector-background-color, var(--react-international-phone-background-color, white));cursor:pointer;text-transform:none;user-select:none}.react-international-phone-country-selector-button:hover{background-color:var(--react-international-phone-country-selector-background-color-hover, whitesmoke)}.react-international-phone-country-selector-button--hide-dropdown{cursor:auto}.react-international-phone-country-selector-button--hide-dropdown:hover{background-color:transparent}.react-international-phone-country-selector-button__button-content{display:flex;align-items:center;justify-content:center}.react-international-phone-country-selector-button__flag-emoji{margin:0 4px}.react-international-phone-country-selector-button__flag-emoji--disabled{opacity:.75}.react-international-phone-country-selector-button__dropdown-arrow{border-top:var(--react-international-phone-country-selector-arrow-size, 4px) solid var(--react-international-phone-country-selector-arrow-color, #777);border-right:var(--react-international-phone-country-selector-arrow-size, 4px) solid transparent;border-left:var(--react-international-phone-country-selector-arrow-size, 4px) solid transparent;margin-right:4px;transition:all .1s ease-out}.react-international-phone-country-selector-button__dropdown-arrow--active{transform:rotateX(180deg)}.react-international-phone-country-selector-button__dropdown-arrow--disabled{border-top-color:var(--react-international-phone-disabled-country-selector-arrow-color, #999)}.react-international-phone-country-selector-button--disabled,.react-international-phone-country-selector-button--disabled:hover{background-color:var(--react-international-phone-disabled-country-selector-background-color, var(--react-international-phone-disabled-background-color, whitesmoke))}.react-international-phone-country-selector-button--disabled{cursor:auto}.react-international-phone-flag-emoji{width:var(--react-international-phone-flag-width, 24px);height:var(--react-international-phone-flag-height, 24px);box-sizing:border-box}.react-international-phone-country-selector-dropdown{position:absolute;z-index:1;top:var(--react-international-phone-dropdown-top, 44px);left:var(--react-international-phone-dropdown-left, 0);display:flex;width:300px;max-height:200px;flex-direction:column;padding:4px 0;margin:0;background-color:var(--react-international-phone-dropdown-item-background-color, var(--react-international-phone-background-color, white));box-shadow:var(--react-international-phone-dropdown-shadow, 2px 2px 16px rgba(0, 0, 0, .25));color:var(--react-international-phone-dropdown-item-text-color, var(--react-international-phone-text-color, #222));list-style:none;overflow-y:scroll}.react-international-phone-country-selector-dropdown__preferred-list-divider{height:1px;border:none;margin:var(--react-international-phone-dropdown-preferred-list-divider-margin, 0);background:var(--react-international-phone-dropdown-preferred-list-divider-color, var(--react-international-phone-border-color, gainsboro))}.react-international-phone-country-selector-dropdown__list-item{display:flex;min-height:var(--react-international-phone-dropdown-item-height, 28px);box-sizing:border-box;align-items:center;padding:2px 8px}.react-international-phone-country-selector-dropdown__list-item-flag-emoji{margin-right:8px}.react-international-phone-country-selector-dropdown__list-item-country-name{overflow:hidden;margin-right:8px;font-size:var(--react-international-phone-dropdown-item-font-size, 14px);text-overflow:ellipsis;white-space:nowrap}.react-international-phone-country-selector-dropdown__list-item-dial-code{color:var(--react-international-phone-dropdown-item-dial-code-color, gray);font-size:var(--react-international-phone-dropdown-item-font-size, 14px)}.react-international-phone-country-selector-dropdown__list-item:hover{background-color:var(--react-international-phone-selected-dropdown-item-background-color, var(--react-international-phone-selected-dropdown-item-background-color, whitesmoke));cursor:pointer}.react-international-phone-country-selector-dropdown__list-item--selected,.react-international-phone-country-selector-dropdown__list-item--focused{background-color:var(--react-international-phone-selected-dropdown-item-background-color, whitesmoke);color:var(--react-international-phone-selected-dropdown-item-text-color, var(--react-international-phone-text-color, #222))}.react-international-phone-country-selector-dropdown__list-item--selected .react-international-phone-country-selector-dropdown__list-item-dial-code,.react-international-phone-country-selector-dropdown__list-item--focused .react-international-phone-country-selector-dropdown__list-item-dial-code{color:var(--react-international-phone-selected-dropdown-item-dial-code-color, var(--react-international-phone-dropdown-item-dial-code-color, gray))}.react-international-phone-country-selector-dropdown__list-item--focused{background-color:var(--react-international-phone-selected-dropdown-item-background-color, var(--react-international-phone-selected-dropdown-item-background-color, whitesmoke))}.react-international-phone-dial-code-preview{display:flex;align-items:center;justify-content:center;padding:0 8px;border:1px solid var(--react-international-phone-dial-code-preview-border-color, var(--react-international-phone-border-color, gainsboro));margin-right:-1px;background-color:var(--react-international-phone-dial-code-preview-background-color, var(--react-international-phone-background-color, white));color:var(--react-international-phone-dial-code-preview-text-color, var(--react-international-phone-text-color, #222));font-size:var(--react-international-phone-dial-code-preview-font-size, var(--react-international-phone-font-size, 13px))}.react-international-phone-dial-code-preview--disabled{background-color:var(--react-international-phone-dial-code-preview-disabled-background-color, var(--react-international-phone-disabled-background-color, whitesmoke));color:var(--react-international-phone-dial-code-preview-disabled-text-color, var(--react-international-phone-disabled-text-color, #666))}.react-international-phone-input-container{display:flex}.react-international-phone-input-container .react-international-phone-country-selector-button{border-radius:var(--react-international-phone-border-radius, 4px);margin-right:-1px;border-bottom-right-radius:0;border-top-right-radius:0}.react-international-phone-input-container .react-international-phone-input{overflow:visible;height:var(--react-international-phone-height, 36px);box-sizing:border-box;padding:0 8px;border:1px solid var(--react-international-phone-border-color, gainsboro);border-radius:var(--react-international-phone-border-radius, 4px);margin:0;background-color:var(--react-international-phone-background-color, white);border-bottom-left-radius:0;border-top-left-radius:0;color:var(--react-international-phone-text-color, #222);font-family:inherit;font-size:var(--react-international-phone-font-size, 13px)}.react-international-phone-input-container .react-international-phone-input:focus{outline:none}.react-international-phone-input-container .react-international-phone-input--disabled{background-color:var(--react-international-phone-disabled-background-color, whitesmoke);color:var(--react-international-phone-disabled-text-color, #666)}
12590
+ `;
12566
12591
  const ProviderInputInner = styled.div `
12567
12592
  border-radius: var(--ck-secondary-button-border-radius);
12568
12593
  font-size: 1rem;
@@ -12600,10 +12625,33 @@ const ProviderInputInner = styled.div `
12600
12625
  width: 100%;
12601
12626
  height: 100%;
12602
12627
  }
12628
+
12629
+ .react-international-phone-country-selector-button {
12630
+ padding-left: 20px;
12631
+ padding-right: 10px;
12632
+ --react-international-phone-border-color: none;
12633
+ --react-international-phone-border-radius: var(--ck-secondary-button-border-radius);
12634
+ --react-international-phone-background-color: var(--ck-secondary-button-background);
12635
+ --react-international-phone-text-color: var(--ck-body-color);
12636
+ border-radius: var(--ck-secondary-button-border-radius) 0px 0px var(--ck-secondary-button-border-radius);
12637
+ transition: all .2s ease-out;
12638
+ }
12639
+
12640
+ .react-international-phone-country-selector-dropdown {
12641
+ box-shadow: var(--ck-secondary-button-hover-box-shadow);
12642
+ }
12643
+
12644
+ .react-international-phone-country-selector-button__dropdown-arrow {
12645
+ border-top: var(--react-international-phone-country-selector-arrow-size, 4px) solid var(--react-international-phone-country-selector-arrow-color, #777) !important;
12646
+ border-right: var(--react-international-phone-country-selector-arrow-size, 4px) solid transparent !important;
12647
+ border-left: var(--react-international-phone-country-selector-arrow-size, 4px) solid transparent !important;
12648
+ margin-right: 4px;
12649
+ transition: all .1s ease-out;
12650
+ }
12603
12651
  `;
12604
12652
  const EmailInnerButton = styled(motion.button) `
12605
12653
  color: var(--ck-body-action-color);
12606
- transition: background-color 200ms ease, transform 100ms ease, color 200ms ease, transition 200ms ease;
12654
+ transition: background-color 200ms ease, transform 100ms ease, color 200ms ease, transition 200ms ease, opacity 200ms ease;
12607
12655
  border-radius: 16px;
12608
12656
 
12609
12657
  svg {
@@ -13146,6 +13194,11 @@ const DownloadApp = () => {
13146
13194
  return (jsx(PageContent, { children: jsxs(ModalContent, { style: { paddingBottom: 4, gap: 14 }, children: [downloads.redirect && jsx(CustomQRCode, { value: downloads.redirect }), !downloads.redirect && jsx(Fragment, { children: "No download link available" }), jsx(ModalBody, { style: { fontSize: 15, lineHeight: '20px', padding: '0 12px' }, children: bodycopy })] }) }));
13147
13195
  };
13148
13196
 
13197
+ const isValidEmail = (email) => {
13198
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
13199
+ return emailRegex.test(email);
13200
+ };
13201
+
13149
13202
  const buildCallbackUrl = ({ email, callbackUrl, provider, isOpen, }) => {
13150
13203
  if (callbackUrl && !callbackUrl.startsWith('http')) {
13151
13204
  callbackUrl = `${window.location.origin}${callbackUrl.startsWith('/') ? '' : '/'}${callbackUrl}`;
@@ -13161,10 +13214,6 @@ const buildCallbackUrl = ({ email, callbackUrl, provider, isOpen, }) => {
13161
13214
  return redirectUrl.toString();
13162
13215
  };
13163
13216
 
13164
- const isValidEmail = (email) => {
13165
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
13166
- return emailRegex.test(email);
13167
- };
13168
13217
  /**
13169
13218
  * Hook for email-based authentication operations
13170
13219
  *
@@ -13258,7 +13307,7 @@ const useEmailAuth = (hookOptions = {}) => {
13258
13307
  });
13259
13308
  setRequiresEmailVerification(false);
13260
13309
  if (!options.email || !options.password) {
13261
- const error = new OpenfortError('Email and password are required', OpenfortErrorType.VALIDATION_ERROR);
13310
+ const error = new OpenfortError('Email and password are required', OpenfortReactErrorType.VALIDATION_ERROR);
13262
13311
  setStatus({
13263
13312
  status: 'error',
13264
13313
  error,
@@ -13270,7 +13319,7 @@ const useEmailAuth = (hookOptions = {}) => {
13270
13319
  });
13271
13320
  }
13272
13321
  if (!isValidEmail(options.email)) {
13273
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13322
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13274
13323
  setStatus({
13275
13324
  status: 'error',
13276
13325
  error,
@@ -13313,7 +13362,7 @@ const useEmailAuth = (hookOptions = {}) => {
13313
13362
  setStatus({
13314
13363
  status: 'success',
13315
13364
  });
13316
- const user = result.player;
13365
+ const user = result.user;
13317
13366
  await updateUser();
13318
13367
  return onSuccess({
13319
13368
  data: { user, wallet },
@@ -13323,7 +13372,7 @@ const useEmailAuth = (hookOptions = {}) => {
13323
13372
  }
13324
13373
  }
13325
13374
  catch (e) {
13326
- const error = new OpenfortError('Failed to login with email and password', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
13375
+ const error = new OpenfortError('Failed to login with email and password', OpenfortReactErrorType.AUTHENTICATION_ERROR, { error: e });
13327
13376
  setStatus({
13328
13377
  status: 'error',
13329
13378
  error: error,
@@ -13339,7 +13388,7 @@ const useEmailAuth = (hookOptions = {}) => {
13339
13388
  var _a;
13340
13389
  try {
13341
13390
  if (!isValidEmail(options.email)) {
13342
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13391
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13343
13392
  setStatus({
13344
13393
  status: 'error',
13345
13394
  error,
@@ -13374,7 +13423,7 @@ const useEmailAuth = (hookOptions = {}) => {
13374
13423
  });
13375
13424
  }
13376
13425
  catch (e) {
13377
- const error = new OpenfortError('Failed to reset password', OpenfortErrorType.AUTHENTICATION_ERROR, {
13426
+ const error = new OpenfortError('Failed to reset password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13378
13427
  error: e,
13379
13428
  });
13380
13429
  setStatus({
@@ -13391,7 +13440,7 @@ const useEmailAuth = (hookOptions = {}) => {
13391
13440
  const resetPassword = useCallback(async (options) => {
13392
13441
  try {
13393
13442
  if (!isValidEmail(options.email)) {
13394
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13443
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13395
13444
  setStatus({
13396
13445
  status: 'error',
13397
13446
  error,
@@ -13407,9 +13456,8 @@ const useEmailAuth = (hookOptions = {}) => {
13407
13456
  });
13408
13457
  setRequiresEmailVerification(false);
13409
13458
  await client.auth.resetPassword({
13410
- email: options.email,
13411
13459
  password: options.password,
13412
- state: options.state,
13460
+ token: options.state,
13413
13461
  });
13414
13462
  setStatus({
13415
13463
  status: 'success',
@@ -13422,7 +13470,7 @@ const useEmailAuth = (hookOptions = {}) => {
13422
13470
  });
13423
13471
  }
13424
13472
  catch (e) {
13425
- const error = new OpenfortError('Failed to reset password', OpenfortErrorType.AUTHENTICATION_ERROR, {
13473
+ const error = new OpenfortError('Failed to reset password', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13426
13474
  error: e,
13427
13475
  });
13428
13476
  setStatus({
@@ -13440,7 +13488,7 @@ const useEmailAuth = (hookOptions = {}) => {
13440
13488
  var _a, _b, _c;
13441
13489
  try {
13442
13490
  if (!options.email || !options.password) {
13443
- const error = new OpenfortError('Email and password are required', OpenfortErrorType.VALIDATION_ERROR);
13491
+ const error = new OpenfortError('Email and password are required', OpenfortReactErrorType.VALIDATION_ERROR);
13444
13492
  setStatus({
13445
13493
  status: 'error',
13446
13494
  error,
@@ -13452,7 +13500,7 @@ const useEmailAuth = (hookOptions = {}) => {
13452
13500
  });
13453
13501
  }
13454
13502
  if (!isValidEmail(options.email)) {
13455
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13503
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13456
13504
  setStatus({
13457
13505
  status: 'error',
13458
13506
  error,
@@ -13470,47 +13518,45 @@ const useEmailAuth = (hookOptions = {}) => {
13470
13518
  const result = await client.auth.signUpWithEmailPassword({
13471
13519
  email: options.email,
13472
13520
  password: options.password,
13521
+ callbackURL: buildCallbackUrl({
13522
+ email: options.email,
13523
+ callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
13524
+ provider: 'email',
13525
+ isOpen,
13526
+ }),
13473
13527
  ...(options.name && { name: options.name }),
13474
13528
  });
13475
- if ('action' in result) {
13476
- setStatus({
13477
- status: 'awaiting-input',
13529
+ // TODO: TMP FIX
13530
+ if ('token' in result && result.token !== null) {
13531
+ const { wallet } = await tryUseWallet({
13532
+ logoutOnError: (_b = options.logoutOnError) !== null && _b !== void 0 ? _b : hookOptions.logoutOnError,
13533
+ recoverWalletAutomatically: (_c = options.recoverWalletAutomatically) !== null && _c !== void 0 ? _c : hookOptions.recoverWalletAutomatically,
13478
13534
  });
13479
- client.auth.requestEmailVerification({
13480
- email: options.email,
13481
- redirectUrl: buildCallbackUrl({
13482
- email: options.email,
13483
- callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
13484
- provider: 'email',
13485
- isOpen,
13486
- }),
13535
+ setStatus({
13536
+ status: 'success',
13487
13537
  });
13488
- setRequiresEmailVerification(true);
13538
+ const user = result.user;
13539
+ await updateUser(user);
13489
13540
  return onSuccess({
13490
- data: { requiresEmailVerification: true },
13541
+ data: { user, wallet },
13491
13542
  hookOptions,
13492
13543
  options,
13493
13544
  });
13494
13545
  }
13495
13546
  else {
13496
- const { wallet } = await tryUseWallet({
13497
- logoutOnError: (_b = options.logoutOnError) !== null && _b !== void 0 ? _b : hookOptions.logoutOnError,
13498
- recoverWalletAutomatically: (_c = options.recoverWalletAutomatically) !== null && _c !== void 0 ? _c : hookOptions.recoverWalletAutomatically,
13499
- });
13500
13547
  setStatus({
13501
- status: 'success',
13548
+ status: 'awaiting-input',
13502
13549
  });
13503
- const user = result.player;
13504
- await updateUser(user);
13550
+ setRequiresEmailVerification(true);
13505
13551
  return onSuccess({
13506
- data: { user, wallet },
13552
+ data: { requiresEmailVerification: true },
13507
13553
  hookOptions,
13508
13554
  options,
13509
13555
  });
13510
13556
  }
13511
13557
  }
13512
13558
  catch (e) {
13513
- const error = new OpenfortError('Failed to login with email and password', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
13559
+ const error = new OpenfortError('Failed to login with email and password', OpenfortReactErrorType.AUTHENTICATION_ERROR, { error: e });
13514
13560
  setStatus({
13515
13561
  status: 'error',
13516
13562
  error,
@@ -13526,7 +13572,7 @@ const useEmailAuth = (hookOptions = {}) => {
13526
13572
  var _a;
13527
13573
  try {
13528
13574
  if (!isValidEmail(options.email)) {
13529
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13575
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13530
13576
  setStatus({
13531
13577
  status: 'error',
13532
13578
  error,
@@ -13541,7 +13587,7 @@ const useEmailAuth = (hookOptions = {}) => {
13541
13587
  const authToken = await client.getAccessToken();
13542
13588
  if (!authToken) {
13543
13589
  logger.log('No token found');
13544
- const error = new OpenfortError('No token found', OpenfortErrorType.AUTHENTICATION_ERROR);
13590
+ const error = new OpenfortError('No token found', OpenfortReactErrorType.AUTHENTICATION_ERROR);
13545
13591
  setStatus({
13546
13592
  status: 'error',
13547
13593
  error,
@@ -13552,43 +13598,29 @@ const useEmailAuth = (hookOptions = {}) => {
13552
13598
  error,
13553
13599
  });
13554
13600
  }
13555
- const result = await client.auth.linkEmailPassword({
13601
+ await client.auth.addEmail({
13602
+ // name: options.name || '',
13556
13603
  email: options.email,
13557
- password: options.password,
13558
- authToken,
13604
+ // password: options.password,
13605
+ // method: 'password',
13606
+ callbackURL: buildCallbackUrl({
13607
+ callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
13608
+ email: options.email,
13609
+ provider: 'email',
13610
+ isOpen,
13611
+ }),
13559
13612
  });
13560
13613
  logger.log('Email linked successfully');
13561
- if ('action' in result) {
13562
- setStatus({
13563
- status: 'awaiting-input',
13564
- });
13565
- client.auth.requestEmailVerification({
13566
- email: options.email,
13567
- redirectUrl: buildCallbackUrl({
13568
- email: options.email,
13569
- callbackUrl: (_a = options.emailVerificationRedirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.emailVerificationRedirectTo,
13570
- provider: 'email',
13571
- isOpen,
13572
- }),
13573
- });
13574
- updateUser();
13575
- setRequiresEmailVerification(true);
13576
- return onSuccess({
13577
- data: { requiresEmailVerification: true },
13578
- hookOptions,
13579
- options,
13580
- });
13581
- }
13582
- else {
13583
- return onSuccess({
13584
- data: {},
13585
- hookOptions,
13586
- options,
13587
- });
13588
- }
13614
+ return onSuccess({
13615
+ data: {},
13616
+ hookOptions,
13617
+ options,
13618
+ });
13589
13619
  }
13590
13620
  catch (e) {
13591
- const error = new OpenfortError('Failed to link email', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
13621
+ const error = new OpenfortError('Failed to link email', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13622
+ error: e,
13623
+ });
13592
13624
  setStatus({
13593
13625
  status: 'error',
13594
13626
  error: error,
@@ -13606,7 +13638,7 @@ const useEmailAuth = (hookOptions = {}) => {
13606
13638
  });
13607
13639
  try {
13608
13640
  if (!isValidEmail(options.email)) {
13609
- const error = new OpenfortError('Invalid email', OpenfortErrorType.VALIDATION_ERROR);
13641
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13610
13642
  setStatus({
13611
13643
  status: 'error',
13612
13644
  error,
@@ -13618,8 +13650,7 @@ const useEmailAuth = (hookOptions = {}) => {
13618
13650
  });
13619
13651
  }
13620
13652
  await client.auth.verifyEmail({
13621
- email: options.email,
13622
- state: options.state,
13653
+ token: options.state,
13623
13654
  });
13624
13655
  setStatus({
13625
13656
  status: 'success',
@@ -13633,7 +13664,9 @@ const useEmailAuth = (hookOptions = {}) => {
13633
13664
  });
13634
13665
  }
13635
13666
  catch (e) {
13636
- const error = new OpenfortError('Failed to verify email', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
13667
+ const error = new OpenfortError('Failed to verify email', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13668
+ error: e,
13669
+ });
13637
13670
  setStatus({
13638
13671
  status: 'error',
13639
13672
  error,
@@ -13749,6 +13782,7 @@ const EmailLogin = () => {
13749
13782
  setRoute(routes.EMAIL_VERIFICATION);
13750
13783
  }
13751
13784
  else {
13785
+ setEmail('');
13752
13786
  setRoute(routes.LOAD_WALLETS);
13753
13787
  }
13754
13788
  }
@@ -13779,91 +13813,603 @@ const EmailLogin = () => {
13779
13813
  }, children: "Forgot password?" }) })] }, loginError ? 'error' : 'no-error') }) }), jsx(Button, { onClick: handleSubmit, disabled: loginLoading, waiting: loginLoading, children: jsx(AnimatePresence, { initial: false, children: loginLoading ? (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants$1, children: isRegister ? 'Signing up...' : 'Logging in...' }, "connectedText")) : isRegister ? (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants$1, children: "Sign up" }, "connectedText")) : (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants$1, children: "Sign in" }, "connectedText")) }) })] }), jsxs(FooterContainer, { children: ["or", jsx("button", { type: "button", onClick: handleToggle, disabled: loginLoading, children: isRegister ? 'Sign in' : 'Sign up' })] })] }));
13780
13814
  };
13781
13815
 
13782
- const EmailVerification = () => {
13783
- const { client } = useOpenfortCore();
13784
- const { setRoute, emailInput: emailInStorage } = useOpenfort();
13785
- const [loading, setLoading] = useState(true);
13786
- const [verificationResponse, setVerificationResponse] = useState(null);
13787
- useEffect(() => {
13788
- const fixedUrl = window.location.href.replace('?state=', '&state='); // redirectUrl is not working with query params
13789
- const url = new URL(fixedUrl);
13790
- const openfortEmailVerificationUI = url.searchParams.get('openfortEmailVerificationUI');
13791
- if (!openfortEmailVerificationUI) {
13792
- // Send email verification flow
13793
- if (!emailInStorage) {
13794
- setRoute(routes.EMAIL_LOGIN);
13795
- return;
13816
+ const useEmailOtpAuth = (hookOptions = {}) => {
13817
+ const { client, updateUser } = useOpenfortCore();
13818
+ const [status, setStatus] = useState({
13819
+ status: 'idle',
13820
+ });
13821
+ const reset = useCallback(() => {
13822
+ setStatus({
13823
+ status: 'idle',
13824
+ });
13825
+ }, []);
13826
+ const { tryUseWallet } = useConnectToWalletPostAuth();
13827
+ const signInEmailOtp = useCallback(async (options) => {
13828
+ var _a, _b;
13829
+ try {
13830
+ setStatus({
13831
+ status: 'loading',
13832
+ });
13833
+ if (!options.email || !options.otp) {
13834
+ const error = new OpenfortError('Email and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
13835
+ setStatus({
13836
+ status: 'error',
13837
+ error,
13838
+ });
13839
+ return onError({
13840
+ hookOptions,
13841
+ options,
13842
+ error,
13843
+ });
13796
13844
  }
13797
- setLoading(false);
13798
- return;
13799
- }
13800
- // Verify email flow
13801
- const state = url.searchParams.get('state');
13802
- const email = url.searchParams.get('email');
13803
- if (!state) {
13804
- logger.error('No state found in URL');
13805
- return;
13845
+ if (!isValidEmail(options.email)) {
13846
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13847
+ setStatus({
13848
+ status: 'error',
13849
+ error,
13850
+ });
13851
+ return onError({
13852
+ hookOptions,
13853
+ options,
13854
+ error,
13855
+ });
13856
+ }
13857
+ const result = await client.auth.logInWithEmailOtp({
13858
+ email: options.email,
13859
+ otp: options.otp,
13860
+ });
13861
+ const { wallet } = await tryUseWallet({
13862
+ logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
13863
+ recoverWalletAutomatically: (_b = options.recoverWalletAutomatically) !== null && _b !== void 0 ? _b : hookOptions.recoverWalletAutomatically,
13864
+ });
13865
+ setStatus({
13866
+ status: 'success',
13867
+ });
13868
+ const user = result.user;
13869
+ await updateUser();
13870
+ return onSuccess({
13871
+ data: { user, wallet },
13872
+ hookOptions,
13873
+ options,
13874
+ });
13806
13875
  }
13807
- const removeParams = () => {
13808
- ['state', 'openfortEmailVerificationUI', 'email', 'openfortAuthProvider'].forEach((key) => {
13809
- url.searchParams.delete(key);
13876
+ catch (e) {
13877
+ const error = new OpenfortError('Failed to login with email OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13878
+ error: e,
13879
+ });
13880
+ setStatus({
13881
+ status: 'error',
13882
+ error: error,
13883
+ });
13884
+ return onError({
13885
+ hookOptions,
13886
+ options,
13887
+ error: error,
13810
13888
  });
13811
- window.history.replaceState({}, document.title, url.toString());
13812
- };
13813
- if (!email) {
13814
- setRoute(routes.EMAIL_LOGIN);
13815
- return;
13816
13889
  }
13817
- logger.log('EmailVerification', state, email);
13818
- (async () => {
13819
- try {
13820
- await client.auth.verifyEmail({
13821
- email,
13822
- state,
13890
+ }, [client, setStatus, updateUser, hookOptions]);
13891
+ const requestEmailOtp = useCallback(async (options) => {
13892
+ try {
13893
+ setStatus({
13894
+ status: 'requesting',
13895
+ });
13896
+ if (!options.email) {
13897
+ const error = new OpenfortError('Email is required', OpenfortReactErrorType.VALIDATION_ERROR);
13898
+ setStatus({
13899
+ status: 'error',
13900
+ error,
13823
13901
  });
13824
- setVerificationResponse({
13825
- success: true,
13902
+ return onError({
13903
+ hookOptions,
13904
+ options,
13905
+ error,
13826
13906
  });
13827
13907
  }
13828
- catch (e) {
13829
- setVerificationResponse({
13830
- success: false,
13831
- error: 'There was an error verifying your email. Please try again.',
13908
+ if (!isValidEmail(options.email)) {
13909
+ const error = new OpenfortError('Invalid email', OpenfortReactErrorType.VALIDATION_ERROR);
13910
+ setStatus({
13911
+ status: 'error',
13912
+ error,
13913
+ });
13914
+ return onError({
13915
+ hookOptions,
13916
+ options,
13917
+ error,
13832
13918
  });
13833
- logger.log('Error verifying email', e);
13834
- }
13835
- finally {
13836
- removeParams();
13837
- setLoading(false);
13838
13919
  }
13839
- })();
13840
- }, []);
13841
- if (loading) {
13842
- return (jsx(PageContent, { children: jsx(Loader, { header: "Checking if account is verified" }) }));
13843
- }
13844
- return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "190px", logoCenter: {
13845
- logo: jsx(EmailIcon, {}),
13846
- }, logoTopLeft: {
13847
- logo: jsx(EmailIcon, {}),
13848
- }, logoBottomRight: {
13849
- logo: jsx(EmailIcon, {}),
13850
- }, logoTopRight: {
13851
- logo: jsx(EmailIcon, {}),
13852
- }, logoBottomLeft: {
13853
- logo: jsx(EmailIcon, {}),
13854
- } }), jsx(ModalContent, { children: verificationResponse ? (jsxs(Fragment, { children: [jsx(ModalH1, { "$small": true, children: verificationResponse.success ? 'Email verified' : 'Email verification failed' }), jsxs(ModalBody, { children: [verificationResponse.error ? verificationResponse.error : 'Your email has been verified.', jsx(Button, { onClick: () => {
13855
- setRoute(routes.EMAIL_LOGIN);
13856
- }, style: { marginTop: 12 }, children: "Continue" })] })] })) : (jsxs(Fragment, { children: [jsx(ModalH1, { "$small": true, children: "Email sent" }), jsxs(ModalBody, { style: { height: 40 }, children: ["Please check your email.", jsx("br", {}), emailInStorage] }), jsx(TextLinkButton, { style: { textDecoration: 'underline' }, onClick: () => {
13857
- setRoute(routes.EMAIL_LOGIN);
13858
- }, children: "Go back to login" })] })) })] }));
13859
- };
13860
-
13861
- // TODO: Localize
13862
- const ExportKey = () => {
13863
- const { exportPrivateKey } = useWallets();
13864
- const [exportedKey, setExportedKey] = useState(null);
13865
- const [exportError, setExportError] = useState(null);
13866
- const [showExportedKey, setShowExportedKey] = useState(false);
13920
+ await client.auth.requestEmailOtp({
13921
+ email: options.email,
13922
+ });
13923
+ setStatus({
13924
+ status: 'success',
13925
+ });
13926
+ return onSuccess({
13927
+ data: {},
13928
+ hookOptions,
13929
+ options,
13930
+ });
13931
+ }
13932
+ catch (e) {
13933
+ const error = new OpenfortError('Failed to request email OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
13934
+ error: e,
13935
+ });
13936
+ setStatus({
13937
+ status: 'error',
13938
+ error: error,
13939
+ });
13940
+ return onError({
13941
+ hookOptions,
13942
+ options,
13943
+ error: error,
13944
+ });
13945
+ }
13946
+ }, [client, setStatus, updateUser, hookOptions]);
13947
+ return {
13948
+ signInEmailOtp,
13949
+ requestEmailOtp,
13950
+ reset,
13951
+ isRequesting: status.status === 'requesting',
13952
+ ...mapStatus(status),
13953
+ isAwaitingInput: status.status === 'awaiting-input',
13954
+ };
13955
+ };
13956
+
13957
+ const caretBlink = keyframes `
13958
+ 0%, 70%, 100% { opacity: 1; }
13959
+ 20%, 50% { opacity: 0; }
13960
+ `;
13961
+ const OtpContainer = styled$1.div `
13962
+ display: flex;
13963
+ align-items: center;
13964
+ justify-content: center;
13965
+
13966
+ --border: ${({ showBorder }) => (showBorder ? 'var(--ck-body-color-muted)' : 'transparent')};
13967
+ `;
13968
+ const pulse = keyframes `
13969
+ 0% {
13970
+ opacity: 100%;
13971
+ }
13972
+ 50% {
13973
+ opacity: 40%;
13974
+ }
13975
+ 100% {
13976
+ opacity: 100%;
13977
+ }
13978
+ `;
13979
+ const dist = 2;
13980
+ const shakeKeyframes = keyframes `
13981
+ 0%{ transform:none; }
13982
+ 25%{ transform:translateX(${dist}px); }
13983
+ 50%{ transform:translateX(-${dist}px); }
13984
+ 75%{ transform:translateX(${dist}px); }
13985
+ 100%{ transform:none; }
13986
+ `;
13987
+ const keyframeSuccess = keyframes `
13988
+ 0% { transform: scale(1); }
13989
+ 50% { transform: scale(1.1); }
13990
+ 100% { transform: scale(1); }
13991
+ `;
13992
+ const OTPGroup = styled$1.div `
13993
+ display: flex;
13994
+
13995
+ outline-width: 3px;
13996
+ outline-style: solid;
13997
+ border-radius: 0.375rem;
13998
+ transition: outline-color 0.3s, border-radius .5s;
13999
+
14000
+ outline-color: ${({ isError, isSuccess }) => {
14001
+ if (isError)
14002
+ return 'var(--ck-body-color-danger)';
14003
+ if (isSuccess)
14004
+ return 'var(--ck-body-color-valid)';
14005
+ return 'transparent';
14006
+ }};
14007
+
14008
+ ${({ isLoading }) => isLoading &&
14009
+ css `
14010
+ animation: ${pulse} 1s ease-in-out infinite;
14011
+ `}
14012
+
14013
+ ${({ isError }) => isError &&
14014
+ css `
14015
+ animation: ${shakeKeyframes} 220ms ease-out both;
14016
+ `}
14017
+
14018
+ ${({ isSuccess }) => isSuccess &&
14019
+ css `
14020
+ border-radius: 3rem;
14021
+ min-width: 3.5rem;
14022
+ ${OTPSlotWrapper} {
14023
+ width: 0;
14024
+ border: 0;
14025
+ transition: width .5s, border .5s;
14026
+ }
14027
+ animation: ${keyframeSuccess} 220ms ease-out both;
14028
+ animation-delay: 250ms;
14029
+ `}
14030
+ `;
14031
+ const OTPSlotWrapper = styled$1.div `
14032
+ position: relative;
14033
+ width: 2.5rem;
14034
+ height: 3.5rem;
14035
+ font-size: 2rem;
14036
+
14037
+ display: flex;
14038
+ align-items: center;
14039
+ justify-content: center;
14040
+
14041
+ transition: all 0.3s;
14042
+
14043
+ border-top: 1px solid var(--border);
14044
+ border-bottom: 1px solid var(--border);
14045
+ border-right: 0.5px solid var(--border);
14046
+ border-left: 0.5px solid var(--border);
14047
+
14048
+ &:first-child {
14049
+ border-left: 1px solid var(--border);
14050
+ border-radius: 0.375rem 0 0 0.375rem;
14051
+ }
14052
+
14053
+ &:last-child {
14054
+ border-radius: 0 0.375rem 0.375rem 0;
14055
+ }
14056
+
14057
+ outline: ${({ isActive }) => (isActive ? '2px solid var(--ck-connectbutton-color)' : '0')};
14058
+ z-index: ${({ isActive }) => (isActive ? 1 : 0)};
14059
+ outline-offset: 0;
14060
+
14061
+ cursor: text;
14062
+ color: var(--ck-body-color);
14063
+ `;
14064
+ const OTPNumberValue = styled$1.div `
14065
+ opacity: ${({ $hide }) => ($hide ? 0 : 1)};
14066
+ transition: opacity 0.3s;
14067
+ `;
14068
+ const OTPHiddenInput = styled$1.input `
14069
+ position: absolute;
14070
+ inset: 0;
14071
+ opacity: 0;
14072
+ cursor: text;
14073
+ caret-color: transparent; /* Hide native caret */
14074
+ `;
14075
+ const FakeCaretWrapper = styled$1.div `
14076
+ position: absolute;
14077
+ inset: 0;
14078
+ pointer-events: none;
14079
+
14080
+ display: flex;
14081
+ align-items: center;
14082
+ justify-content: center;
14083
+
14084
+ animation: ${caretBlink} 1.2s ease-out infinite;
14085
+ `;
14086
+ const CaretBar = styled$1.div `
14087
+ width: 1px;
14088
+ height: 2rem;
14089
+ background: var(--ck-body-color);
14090
+ `;
14091
+ const keyframeWrapper = keyframes `
14092
+ 0% { transform: scale(0); }
14093
+ 100% { transform: scale(1); }
14094
+ `;
14095
+ const SuccessTickWrapper = styled$1.div `
14096
+ position: absolute;
14097
+ inset: 5px;
14098
+ display: flex;
14099
+ animation: ${keyframeWrapper} 200ms ease-out both;
14100
+ animation-delay: 200ms;
14101
+ color: var(--ck-body-color-valid);
14102
+ `;
14103
+
14104
+ function FakeCaret() {
14105
+ return (jsx(FakeCaretWrapper, { children: jsx(CaretBar, {}) }));
14106
+ }
14107
+ function OtpInputStandalone({ length = 6, onChange, onComplete, isLoading, isError, isSuccess, }) {
14108
+ const [values, setValues] = useState(Array(length).fill(''));
14109
+ const [activeIndex, setActiveIndex] = useState(0);
14110
+ const canEdit = !isLoading && !isError && !isSuccess;
14111
+ const inputsRef = useRef([]);
14112
+ const handleInput = (index, char) => {
14113
+ var _a;
14114
+ if (!char.match(/^[0-9]$/))
14115
+ return;
14116
+ if (!canEdit)
14117
+ return;
14118
+ const newValues = [...values];
14119
+ newValues[index] = char;
14120
+ setValues(newValues);
14121
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValues.join(''));
14122
+ // Move cursor to next box
14123
+ if (index < length - 1) {
14124
+ setActiveIndex(index + 1);
14125
+ (_a = inputsRef.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
14126
+ }
14127
+ };
14128
+ useEffect(() => {
14129
+ if (values.every((v) => v !== '')) {
14130
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(values.join(''));
14131
+ }
14132
+ }, [values]);
14133
+ const handleBackspace = (index) => {
14134
+ var _a;
14135
+ const newValues = [...values];
14136
+ if (newValues[index] === '') {
14137
+ if (index > 0) {
14138
+ // Move back
14139
+ setActiveIndex(index - 1);
14140
+ (_a = inputsRef.current[index - 1]) === null || _a === void 0 ? void 0 : _a.focus();
14141
+ }
14142
+ newValues[index - 1] = '';
14143
+ }
14144
+ else {
14145
+ newValues[index] = '';
14146
+ }
14147
+ setValues(newValues);
14148
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValues.join(''));
14149
+ };
14150
+ const handlePaste = (e) => {
14151
+ var _a;
14152
+ const pasted = e.clipboardData.getData('text').replace(/\D/g, '');
14153
+ if (!pasted)
14154
+ return;
14155
+ const arr = pasted.substring(0, length).split('');
14156
+ const newValues = [...values];
14157
+ arr.forEach((char, i) => {
14158
+ newValues[i] = char;
14159
+ });
14160
+ setValues(newValues);
14161
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValues.join(''));
14162
+ const finalIndex = Math.min(arr.length - 1, length - 1);
14163
+ setActiveIndex(finalIndex);
14164
+ (_a = inputsRef.current[finalIndex]) === null || _a === void 0 ? void 0 : _a.focus();
14165
+ };
14166
+ const handleFocus = (i) => {
14167
+ var _a, _b;
14168
+ if (activeIndex !== -1) {
14169
+ setActiveIndex(i);
14170
+ return;
14171
+ }
14172
+ const firstEmptyIndex = values.indexOf('');
14173
+ if (firstEmptyIndex !== -1) {
14174
+ setActiveIndex(firstEmptyIndex);
14175
+ (_a = inputsRef.current[firstEmptyIndex]) === null || _a === void 0 ? void 0 : _a.focus();
14176
+ }
14177
+ else {
14178
+ setActiveIndex(length - 1);
14179
+ (_b = inputsRef.current[length - 1]) === null || _b === void 0 ? void 0 : _b.focus();
14180
+ }
14181
+ };
14182
+ useEffect(() => {
14183
+ var _a;
14184
+ if (!isError) {
14185
+ setValues(Array(length).fill(''));
14186
+ setActiveIndex(0);
14187
+ (_a = inputsRef.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
14188
+ }
14189
+ }, [isError]);
14190
+ return (jsx(OtpContainer, { showBorder: !isSuccess, children: jsxs(OTPGroup, { isError: isError, isSuccess: isSuccess, isLoading: isLoading, children: [values.slice(0, 6).map((value, idx) => {
14191
+ const index = idx;
14192
+ return (jsxs(OTPSlotWrapper, { isActive: canEdit && activeIndex === index, children: [jsx(OTPHiddenInput, { ref: (el) => {
14193
+ inputsRef.current[index] = el;
14194
+ }, value: "", inputMode: "numeric", onBlur: () => setActiveIndex(-1), autoComplete: "one-time-code", autoFocus: index === 0, onFocus: () => handleFocus(index), onPaste: handlePaste, onKeyDown: (e) => {
14195
+ if (!canEdit)
14196
+ return;
14197
+ if (e.key === 'Backspace') {
14198
+ e.preventDefault();
14199
+ handleBackspace(index);
14200
+ }
14201
+ }, onChange: (e) => handleInput(index, e.target.value) }), value && jsx(OTPNumberValue, { "$hide": isSuccess, children: value }), !value && activeIndex === index && jsx(FakeCaret, {})] }, index));
14202
+ }), isSuccess && (jsx(SuccessTickWrapper, { children: jsx(TickIcon, { width: '100%', height: '100%' }) }))] }) }));
14203
+ }
14204
+
14205
+ const Body$1 = styled.p `
14206
+ color: var(--ck-body-color);
14207
+ text-align: center;
14208
+ margin-bottom: 16px;
14209
+ `;
14210
+ const ResultContainer$1 = styled.div `
14211
+ margin-top: 16px;
14212
+ height: 24px;
14213
+ text-align: center;
14214
+ `;
14215
+ const FooterButtonText$1 = styled.button `
14216
+ background: none;
14217
+ border: none;
14218
+ cursor: pointer;
14219
+ padding: 0;
14220
+ color: var(--ck-body-color-muted);
14221
+ transition: color 0.3s;
14222
+
14223
+ &:disabled {
14224
+ color: var(--ck-body-color-muted) !important;
14225
+ cursor: not-allowed;
14226
+ }
14227
+ `;
14228
+ const FooterTextButton$1 = styled.p `
14229
+ color: var(--ck-body-color-muted);
14230
+ text-align: center;
14231
+ margin-top: 16px;
14232
+ &:hover {
14233
+ ${FooterButtonText$1} {
14234
+ color: var(--ck-body-color);
14235
+ }
14236
+ }
14237
+ `;
14238
+
14239
+ const RESEND_COOLDOWN_MS$1 = 10000;
14240
+ const SUCCESS_REDIRECT_DELAY_MS$1 = 2000;
14241
+ const ERROR_DISPLAY_DURATION_MS$1 = 2000;
14242
+ const EmailOTP = () => {
14243
+ const { emailInput: email, previousRoute, setRoute, setEmailInput } = useOpenfort();
14244
+ const { isLoading, requestEmailOtp, signInEmailOtp } = useEmailOtpAuth({
14245
+ recoverWalletAutomatically: false,
14246
+ });
14247
+ const onBack = useMemo(() => {
14248
+ if ((previousRoute === null || previousRoute === void 0 ? void 0 : previousRoute.route) === routes.EMAIL_VERIFICATION)
14249
+ return routes.PROVIDERS;
14250
+ return 'back';
14251
+ }, [previousRoute]);
14252
+ const [canSendOtp, setCanSendOtp] = useState(true);
14253
+ const [status, setStatus] = useState('idle');
14254
+ // Single ref to track if initial OTP request has been made
14255
+ const hasRequestedInitialOtpRef = useRef(false);
14256
+ // Memoize the OTP request function to prevent unnecessary recreations
14257
+ const sendOtpRequest = useCallback(async () => {
14258
+ const { error } = await requestEmailOtp({ email });
14259
+ if (error) {
14260
+ logger.error('Error requesting email OTP:', error);
14261
+ setStatus('error');
14262
+ }
14263
+ else {
14264
+ setStatus('idle');
14265
+ }
14266
+ }, [email, requestEmailOtp]);
14267
+ // Initial OTP request on mount
14268
+ useEffect(() => {
14269
+ if (hasRequestedInitialOtpRef.current)
14270
+ return;
14271
+ hasRequestedInitialOtpRef.current = true;
14272
+ sendOtpRequest();
14273
+ }, [sendOtpRequest]);
14274
+ // Handle OTP completion
14275
+ const handleComplete = useCallback(async (otp) => {
14276
+ logger.log('OTP entered:', otp);
14277
+ setStatus('loading');
14278
+ const { error } = await signInEmailOtp({ email, otp });
14279
+ if (error) {
14280
+ logger.error('Error logging in with email OTP:', error);
14281
+ setStatus('error');
14282
+ }
14283
+ else {
14284
+ setStatus('success');
14285
+ }
14286
+ }, [email, signInEmailOtp]);
14287
+ // Handle status changes and side effects
14288
+ useEffect(() => {
14289
+ let timeoutId;
14290
+ switch (status) {
14291
+ case 'send-otp':
14292
+ setStatus('sending-otp');
14293
+ sendOtpRequest();
14294
+ break;
14295
+ case 'success':
14296
+ timeoutId = setTimeout(() => {
14297
+ setEmailInput('');
14298
+ setRoute(routes.LOAD_WALLETS);
14299
+ }, SUCCESS_REDIRECT_DELAY_MS$1);
14300
+ break;
14301
+ case 'error':
14302
+ timeoutId = setTimeout(() => {
14303
+ setStatus('idle');
14304
+ }, ERROR_DISPLAY_DURATION_MS$1);
14305
+ break;
14306
+ }
14307
+ return () => {
14308
+ if (timeoutId)
14309
+ clearTimeout(timeoutId);
14310
+ };
14311
+ }, [status, sendOtpRequest, setEmailInput, setRoute]);
14312
+ // Handle resend cooldown
14313
+ useEffect(() => {
14314
+ if (canSendOtp)
14315
+ return;
14316
+ const timerId = setTimeout(() => {
14317
+ setCanSendOtp(true);
14318
+ }, RESEND_COOLDOWN_MS$1);
14319
+ return () => clearTimeout(timerId);
14320
+ }, [canSendOtp]);
14321
+ // Memoize button text to avoid recalculation
14322
+ const sendButtonText = useMemo(() => {
14323
+ if (!canSendOtp)
14324
+ return 'Code Sent!';
14325
+ if (status === 'sending-otp')
14326
+ return 'Sending...';
14327
+ return 'Resend Code';
14328
+ }, [canSendOtp, status]);
14329
+ const handleResendClick = useCallback(() => {
14330
+ setStatus('send-otp');
14331
+ setCanSendOtp(false);
14332
+ }, []);
14333
+ const isResendDisabled = !canSendOtp || status === 'sending-otp' || status === 'send-otp';
14334
+ return (jsxs(PageContent, { onBack: onBack, children: [jsx(ModalHeading, { children: "Enter your code" }), jsx(FloatingGraphic, { height: "100px", marginTop: "8px", marginBottom: "10px", logoCenter: {
14335
+ logo: jsx(EmailIcon, {}),
14336
+ } }), jsxs(ModalBody, { children: [jsxs(Body$1, { children: ["Please check ", jsx("b", { children: email }), " for an email from openfort.io and enter your code below."] }), jsx(OtpInputStandalone, { onComplete: handleComplete, isLoading: status === 'loading' || isLoading, isError: status === 'error', isSuccess: status === 'success' }), jsxs(ResultContainer$1, { children: [status === 'success' && jsx(ModalBody, { "$valid": true, children: "Code verified successfully!" }), status === 'error' && jsx(ModalBody, { "$error": true, children: "Invalid code. Please try again." })] }), jsxs(FooterTextButton$1, { children: ["Didn't receive the code?", ' ', jsx(FooterButtonText$1, { type: "button", onClick: handleResendClick, disabled: isResendDisabled, children: sendButtonText })] })] }), jsx(PoweredByFooter, {})] }));
14337
+ };
14338
+
14339
+ const EmailVerification = () => {
14340
+ const { setRoute, emailInput, setEmailInput } = useOpenfort();
14341
+ const [loading, setLoading] = useState(true);
14342
+ const [verificationResponse, setVerificationResponse] = useState(null);
14343
+ const isVerifying = useRef(false);
14344
+ useEffect(() => {
14345
+ if (isVerifying.current)
14346
+ return;
14347
+ isVerifying.current = true;
14348
+ const url = new URL(window.location.href);
14349
+ if (emailInput) {
14350
+ // Not callback flow
14351
+ setLoading(false);
14352
+ return;
14353
+ }
14354
+ // Verify email flow
14355
+ const email = url.searchParams.get('email');
14356
+ const removeParams = () => {
14357
+ ['state', 'openfortEmailVerificationUI', 'email', 'openfortAuthProvider'].forEach((key) => {
14358
+ url.searchParams.delete(key);
14359
+ });
14360
+ window.history.replaceState({}, document.title, url.toString());
14361
+ };
14362
+ logger.log('Email verification', email);
14363
+ if (!email) {
14364
+ setRoute(routes.EMAIL_LOGIN);
14365
+ return;
14366
+ }
14367
+ try {
14368
+ // ASSUMING IT WORKS
14369
+ // TODO: TMP FIX
14370
+ setEmailInput(email);
14371
+ setVerificationResponse({
14372
+ success: true,
14373
+ });
14374
+ }
14375
+ catch (e) {
14376
+ setVerificationResponse({
14377
+ success: false,
14378
+ error: 'There was an error verifying your email. Please try again.',
14379
+ });
14380
+ logger.log('Error verifying email', e);
14381
+ }
14382
+ finally {
14383
+ removeParams();
14384
+ setLoading(false);
14385
+ }
14386
+ }, []);
14387
+ if (loading) {
14388
+ return (jsx(PageContent, { children: jsx(Loader, { header: "Checking if account is verified" }) }));
14389
+ }
14390
+ return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "190px", logoCenter: {
14391
+ logo: jsx(EmailIcon, {}),
14392
+ }, logoTopLeft: {
14393
+ logo: jsx(EmailIcon, {}),
14394
+ }, logoBottomRight: {
14395
+ logo: jsx(EmailIcon, {}),
14396
+ }, logoTopRight: {
14397
+ logo: jsx(EmailIcon, {}),
14398
+ }, logoBottomLeft: {
14399
+ logo: jsx(EmailIcon, {}),
14400
+ } }), jsx(ModalContent, { children: verificationResponse ? (jsxs(Fragment, { children: [jsx(ModalH1, { "$small": true, children: verificationResponse.success ? 'Email verified' : 'Email verification failed' }), jsxs(ModalBody, { children: [verificationResponse.error ? verificationResponse.error : 'Your email has been verified.', jsx(Button, { onClick: () => {
14401
+ setRoute(routes.EMAIL_LOGIN);
14402
+ }, style: { marginTop: 12 }, children: "Continue" })] })] })) : (jsxs(Fragment, { children: [jsx(ModalH1, { "$small": true, children: "Email sent" }), jsxs(ModalBody, { style: { height: 40 }, children: ["Please check your email.", jsx("br", {}), emailInput] }), jsx(TextLinkButton, { style: { textDecoration: 'underline' }, onClick: () => {
14403
+ setRoute(routes.EMAIL_LOGIN);
14404
+ }, children: "Go back to login" })] })) })] }));
14405
+ };
14406
+
14407
+ // TODO: Localize
14408
+ const ExportKey = () => {
14409
+ const { exportPrivateKey } = useWallets();
14410
+ const [exportedKey, setExportedKey] = useState(null);
14411
+ const [exportError, setExportError] = useState(null);
14412
+ const [showExportedKey, setShowExportedKey] = useState(false);
13867
14413
  useEffect(() => {
13868
14414
  const asyncExportKey = async () => {
13869
14415
  try {
@@ -13955,42 +14501,41 @@ const ResetPassword = () => {
13955
14501
  const fixedUrl = window.location.href.replace('?state=', '&state='); // redirectUrl is not working with query params
13956
14502
  const url = new URL(fixedUrl);
13957
14503
  const [password, setPassword] = React.useState('');
13958
- const { setRoute, triggerResize } = useOpenfort();
13959
- const { client, updateUser } = useOpenfortCore();
13960
- const [loading, setLoading] = React.useState(false);
14504
+ // const { setRoute, triggerResize } = useOpenfort()
14505
+ // const { client, updateUser } = useOpenfortCore()
14506
+ const [loading, _setLoading] = React.useState(false);
13961
14507
  const email = url.searchParams.get('email');
14508
+ // OTP_TODO: Reset password
13962
14509
  const handleSubmit = async () => {
13963
- setLoading(true);
13964
- const state = url.searchParams.get('state');
13965
- if (!email || !state) {
13966
- logger.log('No email or state found');
13967
- setLoading(false);
13968
- return;
13969
- }
13970
- try {
13971
- await client.auth.resetPassword({
13972
- password: password,
13973
- email,
13974
- state,
13975
- });
13976
- await client.auth.logInWithEmailPassword({
13977
- email,
13978
- password,
13979
- });
13980
- const user = await updateUser();
13981
- if (!user)
13982
- throw new Error('No user found');
13983
- ['openfortForgotPasswordUI', 'state', 'email'].forEach((param) => {
13984
- url.searchParams.delete(param);
13985
- });
13986
- window.history.replaceState({}, document.title, url.toString());
13987
- setRoute(routes.LOAD_WALLETS);
13988
- }
13989
- catch (e) {
13990
- logger.log('Reset password error', e);
13991
- setLoading(false);
13992
- triggerResize();
13993
- }
14510
+ // setLoading(true)
14511
+ // const state = url.searchParams.get('state')
14512
+ // if (!email || !state) {
14513
+ // logger.log('No email or state found')
14514
+ // setLoading(false)
14515
+ // return
14516
+ // }
14517
+ // try {
14518
+ // await client.auth.resetPassword({
14519
+ // password: password,
14520
+ // email,
14521
+ // state,
14522
+ // })
14523
+ // await client.auth.logInWithEmailPassword({
14524
+ // email,
14525
+ // password,
14526
+ // })
14527
+ // const user = await updateUser()
14528
+ // if (!user) throw new Error('No user found')
14529
+ // ;['openfortForgotPasswordUI', 'state', 'email'].forEach((param) => {
14530
+ // url.searchParams.delete(param)
14531
+ // })
14532
+ // window.history.replaceState({}, document.title, url.toString())
14533
+ // setRoute(routes.LOAD_WALLETS)
14534
+ // } catch (e) {
14535
+ // logger.log('Reset password error', e)
14536
+ // setLoading(false)
14537
+ // triggerResize()
14538
+ // }
13994
14539
  };
13995
14540
  return (jsx(PageContent, { children: jsxs("form", { onSubmit: (e) => {
13996
14541
  e.preventDefault();
@@ -14028,27 +14573,19 @@ const textVariants = {
14028
14573
  },
14029
14574
  };
14030
14575
  const LinkEmail = () => {
14031
- const [password, setPassword] = React.useState('');
14576
+ // const [password, setPassword] = React.useState('')
14032
14577
  const { setRoute, triggerResize, emailInput: email, setEmailInput: setEmail } = useOpenfort();
14033
14578
  const { client, updateUser } = useOpenfortCore();
14034
14579
  const [loginLoading, setLoginLoading] = React.useState(false);
14035
14580
  const [loginError, setLoginError] = React.useState(false);
14581
+ const { linkEmail } = useEmailAuth();
14036
14582
  const handleSubmit = async () => {
14037
14583
  setLoginLoading(true);
14038
14584
  await client.validateAndRefreshToken();
14039
- const authToken = await client.getAccessToken();
14040
- if (!authToken) {
14041
- logger.log('No token found');
14042
- setLoginLoading(false);
14043
- setLoginError('No token found.');
14044
- triggerResize();
14045
- return;
14046
- }
14047
14585
  try {
14048
- await client.auth.linkEmailPassword({
14586
+ await linkEmail({
14049
14587
  email,
14050
- password,
14051
- authToken,
14588
+ // emailVerificationRedirectTo: window.location.origin,
14052
14589
  });
14053
14590
  await updateUser();
14054
14591
  setEmail('');
@@ -14069,27 +14606,221 @@ const LinkEmail = () => {
14069
14606
  return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Link your email" }), jsxs("form", { onSubmit: (e) => {
14070
14607
  e.preventDefault();
14071
14608
  handleSubmit();
14072
- }, children: [jsx(Input, { style: { marginTop: 0 }, value: email, onChange: (e) => setEmail(e.target.value), type: "email", placeholder: "Enter your email", disabled: loginLoading }), jsx(Input, { value: password, onChange: (e) => setPassword(e.target.value), type: "password", placeholder: "Enter your password", disabled: loginLoading }), loginError && (jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: loginError }) })), jsx(Button, { onClick: handleSubmit, disabled: loginLoading, waiting: loginLoading, children: jsx(AnimatePresence, { initial: false, children: loginLoading ? (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants, children: "Linking email..." }, "connectedText")) : (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants, children: "Link email" }, "connectedText")) }) })] })] }));
14609
+ }, children: [jsx(Input, { style: { marginTop: 0 }, value: email, onChange: (e) => setEmail(e.target.value), type: "email", placeholder: "Enter your email", disabled: loginLoading }), loginError && (jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: loginError }) })), jsx(Button, { onClick: handleSubmit, disabled: loginLoading, waiting: loginLoading, children: jsx(AnimatePresence, { initial: false, children: loginLoading ? (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants, children: "Linking email..." }, "connectedText")) : (jsx(TextContainer, { initial: 'initial', animate: 'animate', exit: 'exit', variants: textVariants, children: "Link email" }, "connectedText")) }) })] })] }));
14610
+ };
14611
+
14612
+ const getProviderName = (provider) => {
14613
+ switch (provider) {
14614
+ case 'wallet':
14615
+ case 'siwe':
14616
+ return 'Wallet';
14617
+ case 'email':
14618
+ case 'credential':
14619
+ return 'Email';
14620
+ default:
14621
+ return provider.charAt(0).toUpperCase() + provider.slice(1);
14622
+ }
14623
+ };
14624
+
14625
+ const ProviderIconWrapper$2 = styled.div `
14626
+ width: 24px;
14627
+ height: 24px;
14628
+ flex-shrink: 0;
14629
+ display: flex;
14630
+ align-items: center;
14631
+ justify-content: center;
14632
+ `;
14633
+ const LinkedProviderButtonContainer = styled.div `
14634
+ ${ButtonContainer} {
14635
+ font-weight: var(--ck-primary-button-font-weight, 500);
14636
+ }
14637
+
14638
+ &:first-of-type {
14639
+ ${ButtonContainer}, ${ProviderInputInner} {
14640
+ margin-top: 0;
14641
+ }
14642
+ }
14643
+
14644
+ ${ButtonContainerInner} {
14645
+ padding: 0 20px;
14646
+ }
14647
+
14648
+ ${InnerContainer} {
14649
+ width: 100%;
14650
+ max-width: 100%;
14651
+ }
14652
+ `;
14653
+ const LinkedProviderButtonWrapper = styled.div `
14654
+ display: flex;
14655
+ align-items: center;
14656
+ gap: 12px;
14657
+ `;
14658
+ const LinkedProvidersGroupWrapper = styled.div `
14659
+ `;
14660
+ const LinkedProviderText = styled.div `
14661
+ flex: 1;
14662
+ overflow: hidden;
14663
+ text-overflow: ellipsis;
14664
+ white-space: nowrap;
14665
+ color: var(--ck-body-color-muted);
14666
+ text-align: start;
14667
+ max-width: 210px;
14668
+ `;
14669
+
14670
+ const WalletDisplay = ({ walletAddress }) => {
14671
+ var _a, _b;
14672
+ const ensFallbackConfig = useEnsFallbackConfig();
14673
+ const { data: ensName } = useEnsName({
14674
+ chainId: 1,
14675
+ address: walletAddress,
14676
+ config: ensFallbackConfig,
14677
+ });
14678
+ const context = useOpenfort();
14679
+ const themeContext = useThemeContext();
14680
+ const separator = ['web95', 'rounded', 'minimal'].includes((_b = (_a = themeContext.theme) !== null && _a !== void 0 ? _a : context.uiConfig.theme) !== null && _b !== void 0 ? _b : '')
14681
+ ? '....'
14682
+ : undefined;
14683
+ return ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(walletAddress, separator);
14684
+ };
14685
+ const ProviderHeader = ({ provider }) => {
14686
+ var _a;
14687
+ const { user } = useUser();
14688
+ switch (provider.provider) {
14689
+ case 'wallet':
14690
+ case 'siwe':
14691
+ return (jsx(LinkedProviderText, { children: jsx(WalletDisplay, { walletAddress: provider.accountId }) }));
14692
+ case 'phone':
14693
+ return jsx(LinkedProviderText, { children: provider.accountId });
14694
+ default:
14695
+ return (jsx(LinkedProviderText, { style: { textTransform: (user === null || user === void 0 ? void 0 : user.email) ? 'none' : 'capitalize' }, children: (_a = user === null || user === void 0 ? void 0 : user.email) !== null && _a !== void 0 ? _a : provider.provider }));
14696
+ }
14697
+ };
14698
+
14699
+ const WalletIconWrapper = ({ provider }) => {
14700
+ var _a;
14701
+ const wallets = useWagmiWallets();
14702
+ const wallet = useMemo(() => {
14703
+ return wallets.find((w) => { var _a; return ((_a = w.id) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === provider.walletClientType; });
14704
+ }, [provider]);
14705
+ if (provider.walletClientType === 'walletconnect')
14706
+ return jsx(Logos.WalletConnect, {});
14707
+ if (wallet)
14708
+ return jsx(Fragment, { children: (_a = wallet.iconConnector) !== null && _a !== void 0 ? _a : wallet.icon });
14709
+ return jsx(WalletIcon$1, {});
14710
+ };
14711
+ const ProviderIcon = ({ provider }) => {
14712
+ switch (provider.provider) {
14713
+ case 'email':
14714
+ case 'credential':
14715
+ return jsx(EmailIcon, {});
14716
+ // OTP_TODO: Wallet icon
14717
+ case 'wallet':
14718
+ case 'siwe':
14719
+ return jsx(WalletIconWrapper, { provider: provider });
14720
+ case 'phone':
14721
+ return jsx(PhoneIcon, {});
14722
+ case 'google':
14723
+ case 'twitter':
14724
+ case 'facebook':
14725
+ return providersLogos[provider.provider];
14726
+ default:
14727
+ return jsx(FitText, { children: provider.provider.substring(0, 4).toUpperCase() });
14728
+ }
14729
+ };
14730
+
14731
+ const ProviderIconContainer$1 = styled.div `
14732
+ width: 100%;
14733
+ display: flex;
14734
+ align-items: center;
14735
+ justify-content: center;
14736
+ `;
14737
+ const ProviderIconWrapper$1 = styled.div `
14738
+ width: 54px;
14739
+ height: 54px;
14740
+ flex-shrink: 0;
14741
+ display: flex;
14742
+ align-items: center;
14743
+ justify-content: center;
14744
+ background-color: var(--ck-body-background-secondary);
14745
+ border-radius: 28px;
14746
+ `;
14747
+ const ProviderIconInner$1 = styled.div `
14748
+ width: 32px;
14749
+ height: 32px;
14750
+ flex-shrink: 0;
14751
+ display: flex;
14752
+ align-items: center;
14753
+ justify-content: center;
14754
+ `;
14755
+ const SiweContent = ({ provider }) => {
14756
+ var _a, _b;
14757
+ const address = provider.accountId;
14758
+ const ensFallbackConfig = useEnsFallbackConfig();
14759
+ const { data: ensName } = useEnsName({
14760
+ chainId: 1,
14761
+ address,
14762
+ config: ensFallbackConfig,
14763
+ });
14764
+ const context = useOpenfort();
14765
+ const themeContext = useThemeContext();
14766
+ const separator = ['web95', 'rounded', 'minimal'].includes((_b = (_a = themeContext.theme) !== null && _a !== void 0 ? _a : context.uiConfig.theme) !== null && _b !== void 0 ? _b : '')
14767
+ ? '....'
14768
+ : undefined;
14769
+ return (jsxs(Fragment, { children: [jsx(ModalH1, { children: jsx(CopyText, { value: address, children: ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(address, separator) }) }), jsxs("div", { style: { marginTop: '16px' }, children: ["Linked via Sign-In with Ethereum (SIWE)", jsx(Button, { onClick: () => context.setRoute({ route: 'removeLinkedProvider', provider }), children: "Remove this wallet" })] })] }));
14770
+ };
14771
+ const OAuthContent = ({ provider }) => {
14772
+ const { user } = useUser();
14773
+ const { setRoute } = useOpenfort();
14774
+ return (jsxs(Fragment, { children: [jsx(ModalH1, { children: provider.provider.charAt(0).toUpperCase() + provider.provider.slice(1) }), jsxs("div", { style: { marginTop: '16px' }, children: [user === null || user === void 0 ? void 0 : user.email, jsxs(Button, { onClick: () => setRoute({ route: 'removeLinkedProvider', provider }), children: ["Remove ", provider.provider] })] })] }));
14775
+ };
14776
+ const LinkedProvider$1 = () => {
14777
+ const { route } = useOpenfort();
14778
+ const provider = useMemo(() => {
14779
+ if (route.route === 'linkedProvider') {
14780
+ return route.provider;
14781
+ }
14782
+ throw new Error('No provider found in route');
14783
+ }, []);
14784
+ const getProviderDetails = (provider) => {
14785
+ switch (provider.provider) {
14786
+ case 'siwe':
14787
+ return jsx(SiweContent, { provider: provider });
14788
+ case 'google':
14789
+ case 'facebook':
14790
+ case 'twitter':
14791
+ return jsx(OAuthContent, { provider: provider });
14792
+ default:
14793
+ return (jsxs("div", { style: { marginTop: '16px', display: 'flex', alignItems: 'center', gap: '8px', flexDirection: 'column' }, children: [jsxs("div", { children: ["Authentication method: ", jsx("b", { children: getProviderName(provider.provider) })] }), jsx(FitText, { children: jsx(ProviderHeader, { provider: provider }) })] }));
14794
+ }
14795
+ };
14796
+ return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: getProviderName(provider.provider) }), jsxs(ModalContent, { style: { paddingBottom: 0 }, children: [jsx(ProviderIconContainer$1, { children: jsx(ProviderIconWrapper$1, { children: jsx(ProviderIconInner$1, { children: jsx(ProviderIcon, { provider: provider }) }) }) }), jsx(ModalBody, { children: getProviderDetails(provider) })] })] }));
14073
14797
  };
14074
14798
 
14075
14799
  function useProviders() {
14076
- const { user } = useOpenfortCore();
14800
+ const { user, linkedAccounts } = useOpenfortCore();
14077
14801
  const { uiConfig: options, thirdPartyAuth, setOpen } = useOpenfort();
14078
14802
  const allProviders = (options === null || options === void 0 ? void 0 : options.authProviders) || [];
14079
14803
  const providers = allProviders.filter((p) => p !== UIAuthProvider.GUEST) || [];
14080
- const linkedProviders = user ? providers.filter((p) => { var _a; return (_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find((a) => a.provider === p); }) : [];
14804
+ const linkedProviders = user ? providers.filter((p) => linkedAccounts === null || linkedAccounts === void 0 ? void 0 : linkedAccounts.find((a) => a.provider === p)) : [];
14081
14805
  const availableProviders = user
14082
14806
  ? providers.filter((provider) => {
14083
- var _a;
14084
14807
  if (provider === UIAuthProvider.WALLET)
14085
14808
  return true; // Wallet is always available
14086
- return !((_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find((a) => a.provider === provider));
14809
+ if (user.email && (provider === UIAuthProvider.EMAIL_PASSWORD || provider === UIAuthProvider.EMAIL_OTP)) {
14810
+ return false; // If user has email, don't show email password or otp
14811
+ }
14812
+ if (provider === UIAuthProvider.EMAIL_PASSWORD)
14813
+ return false; // Disable email password linking for now
14814
+ if (user.phoneNumber && provider === UIAuthProvider.PHONE) {
14815
+ return false; // If user has phone number, don't show phone otp
14816
+ }
14817
+ return !(linkedAccounts === null || linkedAccounts === void 0 ? void 0 : linkedAccounts.find((a) => a.provider === provider));
14087
14818
  })
14088
14819
  : providers;
14089
14820
  useEffect(() => {
14090
14821
  if (thirdPartyAuth) {
14091
14822
  setOpen(false);
14092
- logger.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));
14823
+ logger.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.', OpenfortReactErrorType.CONFIGURATION_ERROR));
14093
14824
  }
14094
14825
  }, [thirdPartyAuth, setOpen]);
14095
14826
  const maxProviders = (options === null || options === void 0 ? void 0 : options.authProvidersLength) || 4;
@@ -14099,10 +14830,17 @@ function useProviders() {
14099
14830
  return { mainProviders: activeProviders, hasExcessProviders: false, remainingSocialProviders: [] };
14100
14831
  }
14101
14832
  // Separate social and non-social providers
14102
- const nonSocial = activeProviders.filter((p) => !socialProviders.includes(p));
14833
+ const nonSocial = activeProviders.filter((p, _, array) => {
14834
+ if (p === UIAuthProvider.EMAIL_OTP && array.includes(UIAuthProvider.EMAIL_PASSWORD)) {
14835
+ // If both email otp and email password are present, treat email otp as social to avoid showing both
14836
+ return false;
14837
+ }
14838
+ return !socialProviders.includes(p);
14839
+ });
14103
14840
  const social = activeProviders.filter((p) => socialProviders.includes(p));
14104
14841
  // Allow as many non-socials as possible, then fill the rest with socials
14105
14842
  const remainingSlots = maxProviders - nonSocial.length;
14843
+ const remainingSocialProviders = social.slice(Math.max(0, remainingSlots - 1));
14106
14844
  return {
14107
14845
  mainProviders: [...nonSocial, ...social.slice(0, Math.max(0, remainingSlots - 1))].sort((a, b) => {
14108
14846
  // sort them in the original order
@@ -14111,7 +14849,7 @@ function useProviders() {
14111
14849
  return indexA - indexB;
14112
14850
  }),
14113
14851
  hasExcessProviders: social.length > remainingSlots - 1,
14114
- remainingSocialProviders: social.slice(remainingSlots - 1),
14852
+ remainingSocialProviders,
14115
14853
  };
14116
14854
  }, [user, availableProviders, allProviders, maxProviders]);
14117
14855
  return {
@@ -14124,66 +14862,9 @@ function useProviders() {
14124
14862
  };
14125
14863
  }
14126
14864
 
14127
- const ProviderIconWrapper = styled.div `
14128
- width: 24px;
14129
- height: 24px;
14130
- flex-shrink: 0;
14131
- display: flex;
14132
- align-items: center;
14133
- justify-content: center;
14134
- `;
14135
- const LinkedProviderContainer = styled.div `
14136
- background-color: var(--ck-body-background-secondary);
14137
- border: var(--ck-body-divider) 1px solid;
14138
- display: flex;
14139
- align-items: center;
14140
- gap: 12px;
14141
- padding: 12px 16px;
14142
- border-radius: var(--ck-primary-button-border-radius);
14143
- overflow: hidden;
14144
- text-overflow: ellipsis;
14145
- `;
14146
- const LinkedProvidersGroupWrapper = styled.div `
14147
- display: flex;
14148
- flex-direction: column;
14149
- gap: 12px;
14150
- `;
14151
- const LinkedProviderText = styled.div `
14152
- flex: 1;
14153
- overflow: hidden;
14154
- text-overflow: ellipsis;
14155
- white-space: nowrap;
14156
- color: var(--ck-body-color-muted);
14157
- `;
14158
-
14159
- const WalletIcon$1 = ({ provider }) => {
14160
- var _a;
14161
- const wallets = useWagmiWallets();
14162
- const wallet = useMemo(() => {
14163
- return wallets.find((w) => { var _a; return ((_a = w.id) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === provider.walletClientType; });
14164
- }, [provider]);
14165
- if (provider.walletClientType === 'walletconnect')
14166
- return jsx(Logos.WalletConnect, {});
14167
- if (wallet)
14168
- return jsx(Fragment, { children: (_a = wallet.iconConnector) !== null && _a !== void 0 ? _a : wallet.icon });
14169
- return jsx(WalletIcon$2, {});
14170
- };
14171
- const ProviderIcon = ({ provider }) => {
14172
- switch (provider.provider) {
14173
- case 'email':
14174
- return jsx(EmailIcon, {});
14175
- case 'wallet':
14176
- return jsx(WalletIcon$1, { provider: provider });
14177
- case 'google':
14178
- case 'twitter':
14179
- case 'facebook':
14180
- return providersLogos[provider.provider];
14181
- default:
14182
- return jsx(FitText, { children: provider.provider.substring(0, 4).toUpperCase() });
14183
- }
14184
- };
14185
14865
  const LinkedProvider = ({ provider }) => {
14186
- return (jsxs(LinkedProviderContainer, { children: [jsx(ProviderIconWrapper, { children: jsx(ProviderIcon, { provider: provider }) }), jsx(LinkedProviderText, { children: provider.address || provider.email || 'unknown' })] }));
14866
+ const { setRoute } = useOpenfort();
14867
+ return (jsx(LinkedProviderButtonContainer, { children: jsx(Button, { onClick: () => setRoute({ route: routes.LINKED_PROVIDER, provider }), fitText: false, children: jsxs(LinkedProviderButtonWrapper, { children: [jsx(ProviderIconWrapper$2, { children: jsx(ProviderIcon, { provider: provider }) }), jsx(ProviderHeader, { provider: provider })] }) }) }));
14187
14868
  };
14188
14869
  const AddLinkedProviderButton = () => {
14189
14870
  const { setRoute } = useOpenfort();
@@ -14191,7 +14872,12 @@ const AddLinkedProviderButton = () => {
14191
14872
  return (jsx(Button, { disabled: unlinkedProviders.length === 0, onClick: () => setRoute(routes.PROVIDERS), children: "+" }));
14192
14873
  };
14193
14874
  const LinkedProvidersGroup = () => {
14194
- const { user, isLoading } = useOpenfortCore();
14875
+ const { linkedAccounts, user, isLoading } = useOpenfortCore();
14876
+ const { triggerResize } = useOpenfort();
14877
+ useEffect(() => {
14878
+ if (!isLoading)
14879
+ triggerResize();
14880
+ }, [isLoading]);
14195
14881
  // TODO: Show loading
14196
14882
  if (isLoading) {
14197
14883
  return (jsx("div", { children: jsx(AddLinkedProviderButton, {}) }));
@@ -14200,13 +14886,13 @@ const LinkedProvidersGroup = () => {
14200
14886
  if (!user) {
14201
14887
  return (jsx("div", { children: jsx(AddLinkedProviderButton, {}) }));
14202
14888
  }
14203
- if (user.linkedAccounts.length === 0) {
14204
- return (jsx("div", { children: jsx(AddLinkedProviderButton, {}) }));
14205
- }
14206
- return (jsxs(Fragment, { children: [jsx(LinkedProvidersGroupWrapper, { children: user.linkedAccounts.map((provider) => (jsx(LinkedProvider, { provider: provider }, `${provider.provider}-${provider.address || provider.email || 'unknown'}`))) }), jsx(AddLinkedProviderButton, {})] }));
14889
+ return (jsxs(Fragment, { children: [jsxs(LinkedProvidersGroupWrapper, { children: [linkedAccounts.length === 0 && !user.email && !user.phoneNumber && (jsxs(ModalContent, { children: ["You are logged in as a guest.", jsx(ModalBody, { children: "Add authentication methods to avoid losing access to your account." })] })), !linkedAccounts.find((a) => a.provider === 'credential') && user.email && (jsx(LinkedProvider, { provider: { provider: 'credential', accountId: user.email } }, `credential-${user.email}`)), linkedAccounts.map((provider) => (jsx(LinkedProvider, { provider: provider }, `${provider.provider}-${provider.accountId}`))), user.phoneNumber && (jsx(LinkedProvider, { provider: {
14890
+ provider: 'phone',
14891
+ accountId: user.phoneNumber,
14892
+ } }, `phone-${user.phoneNumber}`))] }), jsx(AddLinkedProviderButton, {})] }));
14207
14893
  };
14208
14894
  const LinkedProviders = () => {
14209
- return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Linked accounts" }), jsx(ModalContent, { children: jsx(ModalBody, { children: "Configure the linked accounts of your profile." }) }), jsx(LinkedProvidersGroup, {})] }));
14895
+ return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Authentication methods" }), jsx(LinkedProvidersGroup, {})] }));
14210
14896
  };
14211
14897
 
14212
14898
  const Loading = () => {
@@ -14382,76 +15068,386 @@ const MobileConnectors = () => {
14382
15068
  context.setRoute(routes.CONNECT_WITH_MOBILE);
14383
15069
  context.setConnector({ id: walletId });
14384
15070
  };
14385
- return (jsx(PageContent, { width: 312, onBack: routes.PROVIDERS, children: jsxs(Container, { children: [jsx(ModalContent, { style: { paddingBottom: 0 }, children: jsx(ScrollArea, { height: 340, children: jsxs(WalletList, { children: [walletsIdsToDisplay
14386
- .sort(
14387
- // sort by name
14388
- (a, b) => {
14389
- var _a, _b, _c, _d;
14390
- const walletA = walletConfigs[a];
14391
- const walletB = walletConfigs[b];
14392
- const nameA = (_b = (_a = walletA.name) !== null && _a !== void 0 ? _a : walletA.shortName) !== null && _b !== void 0 ? _b : a;
14393
- const nameB = (_d = (_c = walletB.name) !== null && _c !== void 0 ? _c : walletB.shortName) !== null && _d !== void 0 ? _d : b;
14394
- return nameA.localeCompare(nameB);
14395
- })
14396
- .filter((walletId) => !(walletId === 'coinbaseWallet' || walletId === 'com.coinbase.wallet'))
14397
- .map((walletId, i) => {
14398
- const wallet = walletConfigs[walletId];
14399
- const { name, shortName, iconConnector, icon } = wallet;
14400
- return (jsxs(WalletItem, { onClick: () => connectWallet(walletId), style: {
14401
- animationDelay: `${i * 50}ms`,
14402
- }, children: [jsx(WalletIcon, { "$outline": true, children: iconConnector !== null && iconConnector !== void 0 ? iconConnector : icon }), jsx(WalletLabel, { children: shortName !== null && shortName !== void 0 ? shortName : name })] }, walletId));
14403
- }), jsxs(WalletItem, { onClick: openW3M, "$waiting": isOpenW3M, children: [jsx(WalletIcon, { style: { background: 'var(--ck-body-background-secondary)' }, children: isOpenW3M ? (jsx("div", { style: {
14404
- position: 'absolute',
14405
- inset: 0,
14406
- display: 'flex',
14407
- alignItems: 'center',
14408
- justifyContent: 'center',
14409
- }, children: jsx("div", { style: {
14410
- width: '50%',
14411
- }, children: jsx(Spinner$3, {}) }) })) : (MoreIcon) }), jsx(WalletLabel, { children: locales.more })] })] }) }) }), context.uiConfig.walletConnectCTA !== 'modal' && (jsx("div", { style: {
14412
- display: 'flex',
14413
- alignItems: 'center',
14414
- justifyContent: 'center',
14415
- gap: 14,
14416
- paddingTop: 8,
14417
- }, children: jsx(CopyButton, { value: "", children: locales.copyToClipboard }) }))] }) }));
15071
+ return (jsx(PageContent, { width: 312, onBack: routes.PROVIDERS, children: jsxs(Container, { children: [jsx(ModalContent, { style: { paddingBottom: 0 }, children: jsx(ScrollArea, { height: 340, children: jsxs(WalletList, { children: [walletsIdsToDisplay
15072
+ .sort(
15073
+ // sort by name
15074
+ (a, b) => {
15075
+ var _a, _b, _c, _d;
15076
+ const walletA = walletConfigs[a];
15077
+ const walletB = walletConfigs[b];
15078
+ const nameA = (_b = (_a = walletA.name) !== null && _a !== void 0 ? _a : walletA.shortName) !== null && _b !== void 0 ? _b : a;
15079
+ const nameB = (_d = (_c = walletB.name) !== null && _c !== void 0 ? _c : walletB.shortName) !== null && _d !== void 0 ? _d : b;
15080
+ return nameA.localeCompare(nameB);
15081
+ })
15082
+ .filter((walletId) => !(walletId === 'coinbaseWallet' || walletId === 'com.coinbase.wallet'))
15083
+ .map((walletId, i) => {
15084
+ const wallet = walletConfigs[walletId];
15085
+ const { name, shortName, iconConnector, icon } = wallet;
15086
+ return (jsxs(WalletItem, { onClick: () => connectWallet(walletId), style: {
15087
+ animationDelay: `${i * 50}ms`,
15088
+ }, children: [jsx(WalletIcon, { "$outline": true, children: iconConnector !== null && iconConnector !== void 0 ? iconConnector : icon }), jsx(WalletLabel, { children: shortName !== null && shortName !== void 0 ? shortName : name })] }, walletId));
15089
+ }), jsxs(WalletItem, { onClick: openW3M, "$waiting": isOpenW3M, children: [jsx(WalletIcon, { style: { background: 'var(--ck-body-background-secondary)' }, children: isOpenW3M ? (jsx("div", { style: {
15090
+ position: 'absolute',
15091
+ inset: 0,
15092
+ display: 'flex',
15093
+ alignItems: 'center',
15094
+ justifyContent: 'center',
15095
+ }, children: jsx("div", { style: {
15096
+ width: '50%',
15097
+ }, children: jsx(Spinner$3, {}) }) })) : (MoreIcon) }), jsx(WalletLabel, { children: locales.more })] })] }) }) }), context.uiConfig.walletConnectCTA !== 'modal' && (jsx("div", { style: {
15098
+ display: 'flex',
15099
+ alignItems: 'center',
15100
+ justifyContent: 'center',
15101
+ gap: 14,
15102
+ paddingTop: 8,
15103
+ }, children: jsx(CopyButton, { value: "", children: locales.copyToClipboard }) }))] }) }));
15104
+ };
15105
+
15106
+ const ButtonsContainer = styled.div `
15107
+ display: flex;
15108
+ gap: 12px;
15109
+ margin-top: 12px;
15110
+ `;
15111
+
15112
+ const NoAssetsAvailable = () => {
15113
+ const { setRoute } = useOpenfort();
15114
+ const chainId = useChainId();
15115
+ const chains = useChains();
15116
+ const chain = chains.find((c) => c.id === chainId);
15117
+ const showBuyOption = chain && !chain.testnet;
15118
+ return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "190px", logoCenter: {
15119
+ logo: jsx(BuyIcon, {}),
15120
+ }, logoTopLeft: {
15121
+ logo: jsx(BuyIcon, {}),
15122
+ }, logoBottomRight: {
15123
+ logo: jsx(BuyIcon, {}),
15124
+ }, logoTopRight: {
15125
+ logo: jsx(DollarIcon, {}),
15126
+ }, logoBottomLeft: {
15127
+ logo: jsx(DollarIcon, {}),
15128
+ } }), jsxs(ModalContent, { style: { paddingBottom: 0 }, children: [jsx(ModalH1, { "$small": true, children: "No assets available" }), jsxs(ModalBody, { children: [jsx("div", { style: { paddingRight: 12, paddingLeft: 12 }, children: "You currently have no assets available in your wallet." }), jsxs(ButtonsContainer, { children: [jsx(Button, { onClick: () => {
15129
+ setRoute(routes.RECEIVE);
15130
+ }, icon: jsx(ReceiveIcon, {}), children: "Get assets" }), showBuyOption && (jsx(Button, { onClick: () => {
15131
+ setRoute(routes.BUY);
15132
+ }, icon: jsx(BuyIcon, {}), children: "Buy assets" }))] })] })] })] }));
15133
+ };
15134
+
15135
+ const Introduction = () => {
15136
+ var _a;
15137
+ const context = useOpenfort();
15138
+ const locales = useLocales({});
15139
+ const ctaUrl = (_a = context.uiConfig.walletOnboardingUrl) !== null && _a !== void 0 ? _a : locales.onboardingScreen_ctaUrl;
15140
+ return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { 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 })] }));
15141
+ };
15142
+
15143
+ const usePhoneOtpAuth = (hookOptions = {}) => {
15144
+ const { client, updateUser } = useOpenfortCore();
15145
+ const [status, setStatus] = useState({
15146
+ status: 'idle',
15147
+ });
15148
+ const reset = useCallback(() => {
15149
+ setStatus({
15150
+ status: 'idle',
15151
+ });
15152
+ }, []);
15153
+ const { tryUseWallet } = useConnectToWalletPostAuth();
15154
+ const logInWithPhoneOtp = useCallback(async (options) => {
15155
+ var _a, _b;
15156
+ try {
15157
+ setStatus({
15158
+ status: 'loading',
15159
+ });
15160
+ if (!options.phoneNumber || !options.otp) {
15161
+ const error = new OpenfortError('Phone and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
15162
+ setStatus({
15163
+ status: 'error',
15164
+ error,
15165
+ });
15166
+ return onError({
15167
+ hookOptions,
15168
+ options,
15169
+ error,
15170
+ });
15171
+ }
15172
+ const result = await client.auth.logInWithPhoneOtp({
15173
+ phoneNumber: options.phoneNumber,
15174
+ otp: options.otp,
15175
+ });
15176
+ const { wallet } = await tryUseWallet({
15177
+ logoutOnError: (_a = options.logoutOnError) !== null && _a !== void 0 ? _a : hookOptions.logoutOnError,
15178
+ recoverWalletAutomatically: (_b = options.recoverWalletAutomatically) !== null && _b !== void 0 ? _b : hookOptions.recoverWalletAutomatically,
15179
+ });
15180
+ setStatus({
15181
+ status: 'success',
15182
+ });
15183
+ const user = result.user;
15184
+ await updateUser();
15185
+ return onSuccess({
15186
+ data: { user, wallet },
15187
+ hookOptions,
15188
+ options,
15189
+ });
15190
+ }
15191
+ catch (e) {
15192
+ const error = new OpenfortError('Failed to login with phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
15193
+ error: e,
15194
+ });
15195
+ setStatus({
15196
+ status: 'error',
15197
+ error: error,
15198
+ });
15199
+ return onError({
15200
+ hookOptions,
15201
+ options,
15202
+ error: error,
15203
+ });
15204
+ }
15205
+ }, [client, setStatus, updateUser, hookOptions]);
15206
+ const requestPhoneOtp = useCallback(async (options) => {
15207
+ try {
15208
+ setStatus({
15209
+ status: 'requesting',
15210
+ });
15211
+ if (!options.phoneNumber) {
15212
+ const error = new OpenfortError('Phone number is required', OpenfortReactErrorType.VALIDATION_ERROR);
15213
+ setStatus({
15214
+ status: 'error',
15215
+ error,
15216
+ });
15217
+ return onError({
15218
+ hookOptions,
15219
+ options,
15220
+ error,
15221
+ });
15222
+ }
15223
+ await client.auth.requestPhoneOtp({
15224
+ phoneNumber: options.phoneNumber,
15225
+ });
15226
+ setStatus({
15227
+ status: 'idle',
15228
+ });
15229
+ return onSuccess({
15230
+ data: {},
15231
+ hookOptions,
15232
+ options,
15233
+ });
15234
+ }
15235
+ catch (e) {
15236
+ const error = new OpenfortError('Failed to request phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
15237
+ error: e,
15238
+ });
15239
+ setStatus({
15240
+ status: 'error',
15241
+ error: error,
15242
+ });
15243
+ return onError({
15244
+ hookOptions,
15245
+ options,
15246
+ error: error,
15247
+ });
15248
+ }
15249
+ }, [client, setStatus, updateUser, hookOptions]);
15250
+ const linkPhoneOtp = useCallback(async (options) => {
15251
+ try {
15252
+ setStatus({
15253
+ status: 'loading',
15254
+ });
15255
+ if (!options.phoneNumber || !options.otp) {
15256
+ const error = new OpenfortError('Phone and OTP are required', OpenfortReactErrorType.VALIDATION_ERROR);
15257
+ setStatus({
15258
+ status: 'error',
15259
+ error,
15260
+ });
15261
+ return onError({
15262
+ hookOptions,
15263
+ options,
15264
+ error,
15265
+ });
15266
+ }
15267
+ const result = await client.auth.linkPhoneOtp({
15268
+ phoneNumber: options.phoneNumber,
15269
+ otp: options.otp,
15270
+ });
15271
+ setStatus({
15272
+ status: 'success',
15273
+ });
15274
+ const user = result.user;
15275
+ await updateUser();
15276
+ return onSuccess({
15277
+ data: { user },
15278
+ hookOptions,
15279
+ options,
15280
+ });
15281
+ }
15282
+ catch (e) {
15283
+ const error = new OpenfortError('Failed to link phone OTP', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
15284
+ error: e,
15285
+ });
15286
+ setStatus({
15287
+ status: 'error',
15288
+ error: error,
15289
+ });
15290
+ return onError({
15291
+ hookOptions,
15292
+ options,
15293
+ error: error,
15294
+ });
15295
+ }
15296
+ }, [client, setStatus, updateUser, hookOptions]);
15297
+ return {
15298
+ logInWithPhoneOtp,
15299
+ requestPhoneOtp,
15300
+ linkPhoneOtp,
15301
+ reset,
15302
+ isRequesting: status.status === 'requesting',
15303
+ ...mapStatus(status),
15304
+ isAwaitingInput: status.status === 'awaiting-input',
15305
+ };
14418
15306
  };
14419
15307
 
14420
- const ButtonsContainer = styled.div `
14421
- display: flex;
14422
- gap: 12px;
14423
- margin-top: 12px;
15308
+ const Body = styled.p `
15309
+ color: var(--ck-body-color);
15310
+ text-align: center;
15311
+ margin-bottom: 16px;
14424
15312
  `;
15313
+ const ResultContainer = styled.div `
15314
+ margin-top: 16px;
15315
+ height: 24px;
15316
+ text-align: center;
15317
+ `;
15318
+ const FooterButtonText = styled.button `
15319
+ background: none;
15320
+ border: none;
15321
+ cursor: pointer;
15322
+ padding: 0;
15323
+ color: var(--ck-body-color-muted);
15324
+ transition: color 0.3s;
14425
15325
 
14426
- const NoAssetsAvailable = () => {
14427
- const { setRoute } = useOpenfort();
14428
- const chainId = useChainId();
14429
- const chains = useChains();
14430
- const chain = chains.find((c) => c.id === chainId);
14431
- const showBuyOption = chain && !chain.testnet;
14432
- return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "190px", logoCenter: {
14433
- logo: jsx(BuyIcon, {}),
14434
- }, logoTopLeft: {
14435
- logo: jsx(BuyIcon, {}),
14436
- }, logoBottomRight: {
14437
- logo: jsx(BuyIcon, {}),
14438
- }, logoTopRight: {
14439
- logo: jsx(DollarIcon, {}),
14440
- }, logoBottomLeft: {
14441
- logo: jsx(DollarIcon, {}),
14442
- } }), jsxs(ModalContent, { style: { paddingBottom: 0 }, children: [jsx(ModalH1, { "$small": true, children: "No assets available" }), jsxs(ModalBody, { children: [jsx("div", { style: { paddingRight: 12, paddingLeft: 12 }, children: "You currently have no assets available in your wallet." }), jsxs(ButtonsContainer, { children: [jsx(Button, { onClick: () => {
14443
- setRoute(routes.RECEIVE);
14444
- }, icon: jsx(ReceiveIcon, {}), children: "Get assets" }), showBuyOption && (jsx(Button, { onClick: () => {
14445
- setRoute(routes.BUY);
14446
- }, icon: jsx(BuyIcon, {}), children: "Buy assets" }))] })] })] })] }));
14447
- };
15326
+ &:disabled {
15327
+ color: var(--ck-body-color-muted) !important;
15328
+ cursor: not-allowed;
15329
+ }
15330
+ `;
15331
+ const FooterTextButton = styled.p `
15332
+ color: var(--ck-body-color-muted);
15333
+ text-align: center;
15334
+ margin-top: 16px;
15335
+ &:hover {
15336
+ ${FooterButtonText} {
15337
+ color: var(--ck-body-color);
15338
+ }
15339
+ }
15340
+ `;
14448
15341
 
14449
- const Introduction = () => {
14450
- var _a;
14451
- const context = useOpenfort();
14452
- const locales = useLocales({});
14453
- const ctaUrl = (_a = context.uiConfig.walletOnboardingUrl) !== null && _a !== void 0 ? _a : locales.onboardingScreen_ctaUrl;
14454
- return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$1, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { 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 })] }));
15342
+ const RESEND_COOLDOWN_MS = 10000;
15343
+ const SUCCESS_REDIRECT_DELAY_MS = 2000;
15344
+ const ERROR_DISPLAY_DURATION_MS = 2000;
15345
+ const PhoneOTP = () => {
15346
+ const { phoneInput: phone, setPhoneInput, setRoute } = useOpenfort();
15347
+ const { isLoading, requestPhoneOtp, logInWithPhoneOtp, linkPhoneOtp } = usePhoneOtpAuth({
15348
+ recoverWalletAutomatically: false,
15349
+ });
15350
+ const { user } = useUser();
15351
+ const [canSendOtp, setCanSendOtp] = useState(true);
15352
+ const [status, setStatus] = useState('idle');
15353
+ const [errorMessage, setErrorMessage] = useState(null);
15354
+ // Single ref to track if initial OTP request has been made
15355
+ const hasRequestedInitialOtpRef = useRef(false);
15356
+ // Memoize the OTP request function to prevent unnecessary recreations
15357
+ const sendOtpRequest = useCallback(async () => {
15358
+ const { error } = await requestPhoneOtp({ phoneNumber: phone });
15359
+ if (error) {
15360
+ logger.error('Error requesting phone OTP:', error);
15361
+ setStatus('error');
15362
+ }
15363
+ else {
15364
+ setStatus('idle');
15365
+ }
15366
+ }, [phone, requestPhoneOtp]);
15367
+ // Initial OTP request on mount
15368
+ useEffect(() => {
15369
+ if (hasRequestedInitialOtpRef.current)
15370
+ return;
15371
+ hasRequestedInitialOtpRef.current = true;
15372
+ sendOtpRequest();
15373
+ }, [sendOtpRequest]);
15374
+ // Handle OTP completion
15375
+ const handleComplete = useCallback(async (otp) => {
15376
+ logger.log('OTP entered:', otp);
15377
+ setStatus('loading');
15378
+ let error = null;
15379
+ if (user) {
15380
+ const { error: linkError } = await linkPhoneOtp({ phoneNumber: phone, otp });
15381
+ error = linkError;
15382
+ }
15383
+ else {
15384
+ const { error: loginError } = await logInWithPhoneOtp({ phoneNumber: phone, otp });
15385
+ error = loginError;
15386
+ }
15387
+ if (error) {
15388
+ logger.error('Error verifying phone OTP:', error);
15389
+ setStatus('error');
15390
+ if (error.message === 'Invalid OTP') {
15391
+ setErrorMessage('Invalid code. Please try again.');
15392
+ }
15393
+ else {
15394
+ setErrorMessage(error.message);
15395
+ }
15396
+ }
15397
+ else {
15398
+ setStatus('success');
15399
+ }
15400
+ }, [phone, logInWithPhoneOtp]);
15401
+ // Handle status changes and side effects
15402
+ useEffect(() => {
15403
+ let timeoutId;
15404
+ switch (status) {
15405
+ case 'send-otp':
15406
+ setStatus('sending-otp');
15407
+ sendOtpRequest();
15408
+ break;
15409
+ case 'success':
15410
+ timeoutId = setTimeout(() => {
15411
+ setPhoneInput('');
15412
+ setRoute(routes.LOAD_WALLETS);
15413
+ }, SUCCESS_REDIRECT_DELAY_MS);
15414
+ break;
15415
+ case 'error':
15416
+ timeoutId = setTimeout(() => {
15417
+ setStatus('idle');
15418
+ }, ERROR_DISPLAY_DURATION_MS);
15419
+ break;
15420
+ }
15421
+ return () => {
15422
+ if (timeoutId)
15423
+ clearTimeout(timeoutId);
15424
+ };
15425
+ }, [status, sendOtpRequest, setPhoneInput, setRoute]);
15426
+ // Handle resend cooldown
15427
+ useEffect(() => {
15428
+ if (canSendOtp)
15429
+ return;
15430
+ const timerId = setTimeout(() => {
15431
+ setCanSendOtp(true);
15432
+ }, RESEND_COOLDOWN_MS);
15433
+ return () => clearTimeout(timerId);
15434
+ }, [canSendOtp]);
15435
+ // Memoize button text to avoid recalculation
15436
+ const sendButtonText = useMemo(() => {
15437
+ if (!canSendOtp)
15438
+ return 'Code Sent!';
15439
+ if (status === 'sending-otp')
15440
+ return 'Sending...';
15441
+ return 'Resend Code';
15442
+ }, [canSendOtp, status]);
15443
+ const handleResendClick = useCallback(() => {
15444
+ setStatus('send-otp');
15445
+ setCanSendOtp(false);
15446
+ }, []);
15447
+ const isResendDisabled = !canSendOtp || status === 'sending-otp' || status === 'send-otp';
15448
+ return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Enter your code" }), jsx(FloatingGraphic, { height: "100px", marginTop: "8px", marginBottom: "10px", logoCenter: {
15449
+ logo: jsx(PhoneIcon, {}),
15450
+ } }), jsxs(ModalBody, { children: [jsxs(Body, { children: ["Please check ", jsx("b", { children: phone }), " for an SMS and enter your code below."] }), jsx(OtpInputStandalone, { onComplete: handleComplete, isLoading: status === 'loading' || isLoading, isError: status === 'error', isSuccess: status === 'success' }), jsxs(ResultContainer, { children: [status === 'success' && jsx(ModalBody, { "$valid": true, children: "Code verified successfully!" }), status === 'error' && jsx(ModalBody, { "$error": true, children: errorMessage || 'Invalid code. Please try again.' })] }), jsxs(FooterTextButton, { children: ["Didn't receive the code?", ' ', jsx(FooterButtonText, { type: "button", onClick: handleResendClick, disabled: isResendDisabled, children: sendButtonText })] })] }), jsx(PoweredByFooter, {})] }));
14455
15451
  };
14456
15452
 
14457
15453
  const LargeButtonStyle = styled.div `
@@ -14538,12 +15534,12 @@ const Profile = () => {
14538
15534
  }, [shouldDisconnect]);
14539
15535
  return (jsxs(PageContent, { onBack: routes.CONNECTED, children: [jsxs(ModalContent, { children: [jsx(ModalHeading, { children: "Profile" }), jsxs("div", { children: [jsx(LargeButton, { onClick: () => {
14540
15536
  setRoute(routes.LINKED_PROVIDERS);
14541
- }, icon: jsx(GuestIcon, {}), children: "Linked accounts" }), jsx(LargeButton, { onClick: () => {
15537
+ }, icon: jsx(GuestIcon, {}), children: "Authentication methods" }), jsx(LargeButton, { onClick: () => {
14542
15538
  setRoute(routes.EXPORT_KEY);
14543
15539
  }, icon: jsx(KeyIcon, {}), children: "Export key" })] })] }), !isSafeConnector(connector === null || connector === void 0 ? void 0 : connector.id) && (jsx(DisconnectButton, { onClick: () => setShouldDisconnect(true), icon: jsx(DisconnectIcon, {}), children: locales.disconnect }))] }));
14544
15540
  };
14545
15541
 
14546
- const ProviderButton = ({ children, icon, onClick }) => {
15542
+ const ProviderButtonBase = ({ children, icon, onClick }) => {
14547
15543
  return (jsx(ProvidersButton, { children: jsxs(Button, { onClick: onClick, children: [jsx(ProviderLabel, { children: children }), jsx(ProviderIcon$1, { children: icon })] }) }));
14548
15544
  };
14549
15545
  const GuestButton = () => {
@@ -14551,22 +15547,57 @@ const GuestButton = () => {
14551
15547
  const handleClick = () => {
14552
15548
  setRoute(routes.CREATE_GUEST_USER);
14553
15549
  };
14554
- return (jsx(ProviderButton, { onClick: handleClick, icon: jsx(GuestIcon, {}), children: "Guest" }));
15550
+ return (jsx(ProviderButtonBase, { onClick: handleClick, icon: jsx(GuestIcon, {}), children: "Guest" }));
14555
15551
  };
14556
15552
  const WalletButton = () => {
14557
15553
  const { setRoute } = useOpenfort();
14558
15554
  const { user } = useOpenfortCore();
14559
- return (jsx(ProviderButton, { onClick: () => setRoute({ route: routes.CONNECTORS, connectType: user ? 'link' : 'connect' }), icon: jsx(Logos.OtherWallets, {}), children: "Wallet" }));
15555
+ return (jsx(ProviderButtonBase, { onClick: () => setRoute({ route: routes.CONNECTORS, connectType: user ? 'link' : 'connect' }), icon: jsx(Logos.OtherWallets, {}), children: "Wallet" }));
15556
+ };
15557
+ const EmailButton = ({ handleSubmit }) => {
15558
+ const { emailInput, setEmailInput } = useOpenfort();
15559
+ const isValidEmail$1 = useMemo(() => {
15560
+ return isValidEmail(emailInput);
15561
+ }, [emailInput]);
15562
+ return (jsx(ProvidersButton, { children: jsx("form", { onSubmit: (e) => {
15563
+ e.preventDefault();
15564
+ if (isValidEmail$1)
15565
+ handleSubmit();
15566
+ }, noValidate: true, children: jsxs(ProviderInputInner, { children: [jsx("input", { value: emailInput, onChange: (e) => setEmailInput(e.target.value), type: "email", placeholder: "Enter your email", formNoValidate: true }), jsx("div", { style: { position: 'relative' }, children: jsx(AnimatePresence, { initial: false, children: isValidEmail$1 ? (jsx(motion.div, { initial: { x: -5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: -5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, children: jsx(EmailInnerButton, { type: "submit", "aria-label": "Submit email", children: jsx(ProviderIcon$1, { children: jsxs("svg", { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("title", { children: "Submit email" }), jsx("line", { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "1", strokeLinecap: "round" }), jsx("path", { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "1", strokeLinecap: "round" })] }) }) }) }, emailInput ? 'enabled' : 'disabled')) : (jsx(motion.div, { initial: { x: 5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: 5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, children: jsx(ProviderIcon$1, { children: jsx(EmailIcon, {}) }) })) }) })] }) }) }));
14560
15567
  };
14561
- const EmailButton = () => {
15568
+ const EmailPasswordButton = () => {
14562
15569
  const { setRoute } = useOpenfort();
14563
15570
  const { user } = useOpenfortCore();
14564
- const { emailInput, setEmailInput } = useOpenfort();
15571
+ const handleSubmit = () => {
15572
+ setRoute(user ? routes.LINK_EMAIL : routes.EMAIL_LOGIN);
15573
+ };
15574
+ return jsx(EmailButton, { handleSubmit: handleSubmit });
15575
+ };
15576
+ const EmailOTPButton = () => {
15577
+ const { setRoute } = useOpenfort();
15578
+ const handleSubmit = () => {
15579
+ setRoute(routes.EMAIL_OTP);
15580
+ };
15581
+ return jsx(EmailButton, { handleSubmit: handleSubmit });
15582
+ };
15583
+ const PhoneButton = () => {
15584
+ const { uiConfig, phoneInput, setPhoneInput, setRoute } = useOpenfort();
14565
15585
  const handleSubmit = (e) => {
14566
15586
  e.preventDefault();
14567
- setRoute(user ? routes.LINK_EMAIL : routes.EMAIL_LOGIN);
15587
+ setRoute(routes.PHONE_OTP);
14568
15588
  };
14569
- return (jsx(ProvidersButton, { children: jsx("form", { onSubmit: handleSubmit, noValidate: true, children: jsxs(ProviderInputInner, { children: [jsx("input", { value: emailInput, onChange: (e) => setEmailInput(e.target.value), type: "email", placeholder: "Enter your email", formNoValidate: true }), jsx("div", { style: { position: 'relative' }, children: jsx(AnimatePresence, { initial: false, children: emailInput ? (jsx(EmailInnerButton, { initial: { x: -5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: -5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, type: "submit", "aria-label": "Submit email", children: jsx(ProviderIcon$1, { children: jsxs("svg", { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("title", { children: "Submit email" }), jsx("line", { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "1", strokeLinecap: "round" }), jsx("path", { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "1", strokeLinecap: "round" })] }) }) }, emailInput ? 'enabled' : 'disabled')) : (jsx(motion.div, { initial: { x: 5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: 5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, children: jsx(ProviderIcon$1, { children: jsx(EmailIcon, {}) }) })) }) })] }) }) }));
15589
+ const hasValue = phoneInput.length > 5;
15590
+ // && !defaultCountries.some((country: CountryData) => phoneInput.replace('+', '') === country[2])
15591
+ return (jsx(ProvidersButton, { children: jsx("form", { onSubmit: handleSubmit, noValidate: true, children: jsxs(ProviderInputInner, { children: [jsx("div", { style: { width: '100%' }, children: jsx(PhoneInput, { value: phoneInput, onChange: (phone) => setPhoneInput(phone), hideDropdown: false, placeholder: "Enter your phone", style: {
15592
+ '--react-international-phone-height': '56px',
15593
+ '--react-international-phone-text-color': 'var(--ck-body-color)',
15594
+ '--react-international-phone-background-color': 'var(--ck-secondary-button-background)',
15595
+ '--react-international-phone-country-selector-background-color': 'var(--ck-secondary-button-background)',
15596
+ '--react-international-phone-selected-dropdown-item-background-color': 'var(--ck-secondary-button-hover-background)',
15597
+ '--react-international-phone-country-selector-background-color-hover': 'var(--ck-secondary-button-hover-background)',
15598
+ '--react-international-phone-font-size': '16px',
15599
+ paddingLeft: '4px',
15600
+ }, ...uiConfig.phoneConfig }) }), jsx("div", { style: { position: 'relative' }, children: jsx(AnimatePresence, { initial: false, children: hasValue ? (jsx(EmailInnerButton, { initial: { x: -5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: -5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, type: "submit", "aria-label": "Submit email", children: jsx(ProviderIcon$1, { children: jsxs("svg", { width: "13", height: "12", viewBox: "0 0 13 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("title", { children: "Submit email" }), jsx("line", { stroke: "currentColor", x1: "1", y1: "6", x2: "12", y2: "6", strokeWidth: "1", strokeLinecap: "round" }), jsx("path", { stroke: "currentColor", d: "M7.51431 1.5L11.757 5.74264M7.5 10.4858L11.7426 6.24314", strokeWidth: "1", strokeLinecap: "round" })] }) }) }, phoneInput ? 'enabled' : 'disabled')) : (jsx(motion.div, { initial: { x: 5, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: 5, opacity: 0, position: 'absolute' }, transition: { duration: 0.2, ease: [0.25, 1, 0.5, 1] }, children: jsx(ProviderIcon$1, { children: jsx(PhoneIcon, {}) }) })) }) })] }) }) }));
14570
15601
  };
14571
15602
  const AuthProviderButton = ({ provider, title = `${provider} login`, icon, }) => {
14572
15603
  const { setRoute, setConnector } = useOpenfort();
@@ -14574,29 +15605,26 @@ const AuthProviderButton = ({ provider, title = `${provider} login`, icon, }) =>
14574
15605
  setRoute({ route: routes.CONNECT, connectType: 'linkIfUserConnectIfNoUser' });
14575
15606
  setConnector({ id: provider, type: 'oauth' });
14576
15607
  };
14577
- return (jsx(ProviderButton, { onClick: handleClick, icon: icon, children: title }));
15608
+ return (jsx(ProviderButtonBase, { onClick: handleClick, icon: icon, children: title }));
14578
15609
  };
14579
- const ProviderButtonSwitch = ({ provider }) => {
14580
- switch (provider) {
14581
- case UIAuthProvider.GUEST:
14582
- return jsx(GuestButton, {});
14583
- case UIAuthProvider.WALLET:
14584
- return jsx(WalletButton, {});
14585
- case UIAuthProvider.EMAIL:
14586
- return jsx(EmailButton, {});
14587
- case UIAuthProvider.GOOGLE:
14588
- return jsx(AuthProviderButton, { provider: OAuthProvider.GOOGLE, title: "Google", icon: providersLogos[provider] });
14589
- case UIAuthProvider.TWITTER:
14590
- return jsx(AuthProviderButton, { provider: OAuthProvider.TWITTER, title: "X", icon: providersLogos[provider] });
14591
- case UIAuthProvider.FACEBOOK:
14592
- return jsx(AuthProviderButton, { provider: OAuthProvider.FACEBOOK, title: "Facebook", icon: providersLogos[provider] });
14593
- case UIAuthProvider.DISCORD:
14594
- return jsx(AuthProviderButton, { provider: OAuthProvider.DISCORD, title: "Discord", icon: providersLogos[provider] });
14595
- case UIAuthProvider.APPLE:
14596
- return jsx(AuthProviderButton, { provider: OAuthProvider.APPLE, title: "Apple", icon: providersLogos[provider] });
14597
- default:
14598
- throw new Error(`NOT IMPLEMENTED: ${provider}`);
15610
+ const authProviderToOAuthProviderMap = {
15611
+ guest: jsx(GuestButton, {}),
15612
+ wallet: jsx(WalletButton, {}),
15613
+ emailPassword: jsx(EmailPasswordButton, {}),
15614
+ emailOtp: jsx(EmailOTPButton, {}),
15615
+ phone: jsx(PhoneButton, {}),
15616
+ google: (jsx(AuthProviderButton, { provider: OAuthProvider.GOOGLE, title: "Google", icon: providersLogos[UIAuthProvider.GOOGLE] })),
15617
+ twitter: (jsx(AuthProviderButton, { provider: OAuthProvider.TWITTER, title: "X", icon: providersLogos[UIAuthProvider.TWITTER] })),
15618
+ facebook: (jsx(AuthProviderButton, { provider: OAuthProvider.FACEBOOK, title: "Facebook", icon: providersLogos[UIAuthProvider.FACEBOOK] })),
15619
+ discord: (jsx(AuthProviderButton, { provider: OAuthProvider.DISCORD, title: "Discord", icon: providersLogos[UIAuthProvider.DISCORD] })),
15620
+ apple: (jsx(AuthProviderButton, { provider: OAuthProvider.APPLE, title: "Apple", icon: providersLogos[UIAuthProvider.APPLE] })),
15621
+ };
15622
+ const ProviderButton = ({ provider }) => {
15623
+ const { user } = useOpenfortCore();
15624
+ if (user && (provider === UIAuthProvider.EMAIL_OTP || provider === UIAuthProvider.EMAIL_PASSWORD)) {
15625
+ return jsx(EmailPasswordButton, {});
14599
15626
  }
15627
+ return authProviderToOAuthProviderMap[provider] || null;
14600
15628
  };
14601
15629
  // This accounts for the case where the user has an address but no user, which can happen if the user has not signed up yet, but logged in with a wallet
14602
15630
  const AddressButNoUserCase = () => {
@@ -14616,7 +15644,7 @@ const AddressButNoUserCase = () => {
14616
15644
  };
14617
15645
  const SocialProvidersButton = ({ thereAreSocialsAlready }) => {
14618
15646
  const { setRoute } = useOpenfort();
14619
- return (jsx(ProviderButton, { onClick: () => setRoute(routes.SOCIAL_PROVIDERS), icon: jsx(OtherSocials, {}), children: thereAreSocialsAlready ? 'Other socials' : 'Social providers' }));
15647
+ return (jsx(ProviderButtonBase, { onClick: () => setRoute(routes.SOCIAL_PROVIDERS), icon: jsx(OtherSocials, {}), children: thereAreSocialsAlready ? 'Other socials' : 'Social providers' }));
14620
15648
  };
14621
15649
  const Providers = () => {
14622
15650
  const { user } = useOpenfortCore();
@@ -14632,7 +15660,7 @@ const Providers = () => {
14632
15660
  if (address && !user) {
14633
15661
  return jsx(AddressButNoUserCase, {});
14634
15662
  }
14635
- return (jsxs(PageContent, { onBack: onBack, children: [jsx(ModalHeading, { children: user ? 'Link auth' : 'Connect' }), mainProviders.map((auth) => (jsx(ProviderButtonSwitch, { provider: auth }, auth))), hasExcessProviders && (jsx(SocialProvidersButton, { thereAreSocialsAlready: !!mainProviders.find((p) => socialProviders.includes(p)) })), jsx(PoweredByFooter, { showDisclaimer: true })] }));
15663
+ return (jsxs(PageContent, { onBack: onBack, children: [jsx(ModalHeading, { children: user ? 'Link auth' : 'Connect' }), mainProviders.map((auth) => (jsx(ProviderButton, { provider: auth }, auth))), hasExcessProviders && (jsx(SocialProvidersButton, { thereAreSocialsAlready: !!mainProviders.find((p) => socialProviders.includes(p)) })), jsx(PoweredByFooter, { showDisclaimer: true })] }));
14636
15664
  };
14637
15665
 
14638
15666
  const StyledButton = styled.button `
@@ -14897,6 +15925,125 @@ const RecoverPage = () => {
14897
15925
  return jsx(RecoverWallet, { wallet: wallet, onBack: onBack, logoutOnBack: logoutOnBack });
14898
15926
  };
14899
15927
 
15928
+ const ProviderIconContainer = styled.div `
15929
+ width: 100%;
15930
+ display: flex;
15931
+ align-items: center;
15932
+ justify-content: center;
15933
+ `;
15934
+ const ProviderIconWrapper = styled.div `
15935
+ width: 54px;
15936
+ height: 54px;
15937
+ flex-shrink: 0;
15938
+ display: flex;
15939
+ align-items: center;
15940
+ justify-content: center;
15941
+ background-color: var(--ck-body-background-secondary);
15942
+ border-radius: 28px;
15943
+ `;
15944
+ const ProviderIconInner = styled.div `
15945
+ width: 32px;
15946
+ height: 32px;
15947
+ flex-shrink: 0;
15948
+ display: flex;
15949
+ align-items: center;
15950
+ justify-content: center;
15951
+ `;
15952
+ const ButtonWrapper = styled.div `
15953
+ display: flex;
15954
+ gap: 12px;
15955
+ margin-top: 24px;
15956
+ `;
15957
+ const ErrorMessage$1 = styled.div `
15958
+ color: var(--ck-body-color-danger, #ff4d4f);
15959
+ margin-top: 16px;
15960
+ `;
15961
+ const RemoveLinkedProvider = () => {
15962
+ const { route, triggerResize, onBack, setOnBack, setRouteHistory, setRoute } = useOpenfort();
15963
+ const { client, updateUser } = useOpenfortCore();
15964
+ const [error, setError] = useState(null);
15965
+ const [isSuccess, setIsSuccess] = useState(false);
15966
+ const provider = useMemo(() => {
15967
+ if (route.route === 'removeLinkedProvider') {
15968
+ return route.provider;
15969
+ }
15970
+ throw new Error('No provider found in route');
15971
+ }, []);
15972
+ useEffect(() => {
15973
+ if (error)
15974
+ triggerResize();
15975
+ }, [error]);
15976
+ useEffect(() => {
15977
+ if (isSuccess) {
15978
+ updateUser();
15979
+ triggerResize();
15980
+ setOnBack(() => () => {
15981
+ setRouteHistory((prev) => {
15982
+ const newHistory = [...prev];
15983
+ newHistory.pop();
15984
+ newHistory.pop();
15985
+ if (newHistory.length > 0) {
15986
+ setRoute(newHistory[newHistory.length - 1]);
15987
+ }
15988
+ else {
15989
+ setRoute({ route: routes.CONNECTED });
15990
+ }
15991
+ return newHistory;
15992
+ });
15993
+ });
15994
+ }
15995
+ }, [isSuccess]);
15996
+ const handleRemove = async () => {
15997
+ if (provider.provider === 'siwe' || provider.provider === 'wallet')
15998
+ try {
15999
+ const result = await client.auth.unlinkWallet({
16000
+ address: provider.accountId,
16001
+ chainId: provider.chainId,
16002
+ });
16003
+ if (!result.success) {
16004
+ setError('Failed to remove linked provider. Please try again.');
16005
+ return;
16006
+ }
16007
+ else {
16008
+ setIsSuccess(true);
16009
+ }
16010
+ }
16011
+ catch (e) {
16012
+ if (e instanceof Error)
16013
+ setError(e.message);
16014
+ else {
16015
+ logger.error('Unexpected error removing linked provider:', e);
16016
+ setError('Failed to remove linked provider. Please try again.');
16017
+ }
16018
+ return;
16019
+ }
16020
+ else {
16021
+ try {
16022
+ const result = await client.auth.unlinkOAuth({
16023
+ provider: provider.provider,
16024
+ });
16025
+ if (!result.status) {
16026
+ setError('Failed to remove linked provider. Please try again.');
16027
+ return;
16028
+ }
16029
+ else {
16030
+ setIsSuccess(true);
16031
+ }
16032
+ }
16033
+ catch (e) {
16034
+ if (e instanceof Error)
16035
+ setError(e.message);
16036
+ else {
16037
+ logger.error('Unexpected error removing linked provider:', e);
16038
+ setError('Failed to remove linked provider. Please try again.');
16039
+ }
16040
+ return;
16041
+ }
16042
+ }
16043
+ };
16044
+ return (jsxs(PageContent, { children: [jsxs(ModalHeading, { children: ["Remove ", getProviderName(provider.provider)] }), jsxs(ModalContent, { style: { paddingBottom: 0 }, children: [jsx(ProviderIconContainer, { style: { marginBottom: '16px' }, children: jsx(ProviderIconWrapper, { children: jsx(ProviderIconInner, { children: jsx(ProviderIcon, { provider: provider }) }) }) }), isSuccess ? (jsxs(Fragment, { children: [jsx(ModalH1, { "$valid": true, children: "Success" }), jsxs(ModalBody, { children: ["Successfully removed", ' ', provider.provider === 'siwe' ? (jsxs("span", { children: [jsx("b", { children: jsx(WalletDisplay, { walletAddress: provider.accountId }) }), "."] })) : (jsxs(Fragment, { children: [jsx("b", { children: getProviderName(provider.provider) }), " as an authentication method."] }))] }), jsx(ButtonWrapper, { style: { marginTop: 0 }, children: jsx(Button, { onClick: () => onBack === null || onBack === void 0 ? void 0 : onBack(), children: "Back" }) })] })) : (jsxs(Fragment, { children: [jsxs("p", { children: ["Are you sure you want to remove", ' ', provider.provider === 'siwe' ? (jsxs(CopyText, { value: provider.accountId, children: [jsx("b", { children: jsx(WalletDisplay, { walletAddress: provider.accountId }) }), "?"] })) : (jsxs(Fragment, { children: [jsx("b", { children: getProviderName(provider.provider) }), "as an authentication method?"] }))] }), error && jsx(ErrorMessage$1, { children: error }), jsxs(ButtonWrapper, { style: { marginTop: 0 }, children: [jsx(Button, { onClick: () => onBack === null || onBack === void 0 ? void 0 : onBack(), children: "Cancel" }), jsx(Button, { onClick: handleRemove, children: "Remove" })] })] }))] })] }));
16045
+ };
16046
+
14900
16047
  const ZERO = BigInt(0);
14901
16048
  const usdFormatter$1 = new Intl.NumberFormat('en-US', {
14902
16049
  style: 'currency',
@@ -15942,7 +17089,7 @@ const SendConfirmation = () => {
15942
17089
 
15943
17090
  const SocialProviders = () => {
15944
17091
  const { remainingSocialProviders } = useProviders();
15945
- return (jsxs(PageContent, { children: [jsx(ScrollArea, { mobileDirection: 'horizontal', children: remainingSocialProviders.map((auth) => (jsx(ProviderButtonSwitch, { provider: auth }, auth))) }), jsx(PoweredByFooter, { showDisclaimer: true })] }));
17092
+ return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Other socials" }), jsx(ScrollArea, { mobileDirection: 'horizontal', children: remainingSocialProviders.map((auth) => (jsx(ProviderButton, { provider: auth }, auth))) }), jsx(PoweredByFooter, { showDisclaimer: true })] }));
15946
17093
  };
15947
17094
 
15948
17095
  const SwitchNetworks = () => {
@@ -15964,7 +17111,7 @@ const createSIWEMessage = (address, nonce, chainId) => createSiweMessage({
15964
17111
  statement: 'By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.',
15965
17112
  uri: window.location.origin,
15966
17113
  version: '1',
15967
- chainId: chainId !== null && chainId !== void 0 ? chainId : sepolia.id,
17114
+ chainId: chainId,
15968
17115
  nonce,
15969
17116
  });
15970
17117
 
@@ -15977,7 +17124,8 @@ function useConnectWithSiwe() {
15977
17124
  const chainId = useChainId();
15978
17125
  const config = useConfig();
15979
17126
  const publicClient = usePublicClient();
15980
- const connectWithSiwe = useCallback(async ({ onError, onConnect, connectorType: propsConnectorType, walletClientType: propsWalletClientType, } = {}) => {
17127
+ const { signMessageAsync } = useSignMessage();
17128
+ const connectWithSiwe = useCallback(async ({ onError, onConnect, connectorType: propsConnectorType, walletClientType: propsWalletClientType, link = !!user, } = {}) => {
15981
17129
  var _a, _b;
15982
17130
  const connectorType = propsConnectorType !== null && propsConnectorType !== void 0 ? propsConnectorType : connector === null || connector === void 0 ? void 0 : connector.type;
15983
17131
  const walletClientType = propsWalletClientType !== null && propsWalletClientType !== void 0 ? propsWalletClientType : connector === null || connector === void 0 ? void 0 : connector.id;
@@ -15992,30 +17140,36 @@ function useConnectWithSiwe() {
15992
17140
  chainId,
15993
17141
  });
15994
17142
  }
15995
- const { nonce } = await client.auth.initSIWE({ address });
17143
+ let nonce;
17144
+ if (link) {
17145
+ const resp = await client.auth.linkSIWE({ address });
17146
+ nonce = resp.nonce;
17147
+ }
17148
+ else {
17149
+ const resp = await client.auth.initSIWE({ address });
17150
+ nonce = resp.nonce;
17151
+ }
15996
17152
  const SIWEMessage = createSIWEMessage(address, nonce, chainId);
15997
- const signature = await signMessage(config, { message: SIWEMessage });
15998
- // if has user, we link the wallet
15999
- if (user) {
16000
- logger.log('User found, trying to lint wallet to user');
16001
- const authToken = await client.getAccessToken();
16002
- if (!authToken)
16003
- throw new Error('No access token found');
16004
- logger.log('Linking wallet', { signature, message: SIWEMessage, connectorType, walletClientType, authToken });
17153
+ const signature = await signMessageAsync({ message: SIWEMessage });
17154
+ if (link) {
17155
+ logger.log('Linking wallet to user');
16005
17156
  await client.auth.linkWallet({
16006
17157
  signature,
16007
17158
  message: SIWEMessage,
16008
17159
  connectorType,
16009
17160
  walletClientType,
16010
- authToken,
17161
+ address,
17162
+ chainId,
16011
17163
  });
16012
17164
  }
16013
17165
  else {
17166
+ logger.log('Authenticating with SIWE');
16014
17167
  await client.auth.authenticateWithSIWE({
16015
17168
  signature,
16016
17169
  message: SIWEMessage,
16017
17170
  connectorType,
16018
17171
  walletClientType,
17172
+ address,
16019
17173
  });
16020
17174
  }
16021
17175
  await updateUser();
@@ -16041,7 +17195,7 @@ function useConnectWithSiwe() {
16041
17195
  else {
16042
17196
  message = 'Failed to connect with SIWE.';
16043
17197
  }
16044
- onError(message, err instanceof OpenfortError$1 ? err.type : undefined);
17198
+ onError(message, err instanceof OpenfortError$1 ? err : undefined);
16045
17199
  }
16046
17200
  }, [client, user, updateUser, address, chainId, config, connector, accountChainId, publicClient]);
16047
17201
  return connectWithSiwe;
@@ -16260,7 +17414,7 @@ const ConnectWithInjector = ({ forceState }) => {
16260
17414
  const { disconnect } = useDisconnect();
16261
17415
  const connectWithSiwe = useConnectWithSiwe();
16262
17416
  const props = useRouteProps(routes.CONNECT);
16263
- const { user } = useUser();
17417
+ const { linkedAccounts } = useUser();
16264
17418
  const onConnect = useCallback(() => {
16265
17419
  setStatus(states$3.CONNECTED);
16266
17420
  setTimeout(() => {
@@ -16335,7 +17489,7 @@ const ConnectWithInjector = ({ forceState }) => {
16335
17489
  });
16336
17490
  return;
16337
17491
  }
16338
- const userWallets = user === null || user === void 0 ? void 0 : user.linkedAccounts.filter((acc) => {
17492
+ const userWallets = linkedAccounts === null || linkedAccounts === void 0 ? void 0 : linkedAccounts.filter((acc) => {
16339
17493
  var _a, _b;
16340
17494
  return acc.walletClientType === ((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) ||
16341
17495
  acc.walletClientType === ((_b = wallet.connector) === null || _b === void 0 ? void 0 : _b.id);
@@ -16343,7 +17497,7 @@ const ConnectWithInjector = ({ forceState }) => {
16343
17497
  // If already has linked account, don't link again
16344
17498
  if (userWallets && userWallets.length > 0) {
16345
17499
  wallet.connector.getAccounts().then((acc) => {
16346
- if (acc.some((v) => userWallets.some((w) => w.address === v))) {
17500
+ if (acc.some((v) => userWallets.some((w) => w.accountId === v))) {
16347
17501
  onConnect();
16348
17502
  return;
16349
17503
  }
@@ -16353,15 +17507,15 @@ const ConnectWithInjector = ({ forceState }) => {
16353
17507
  connectWithSiwe({
16354
17508
  // connectorType: wallet.connector.id,
16355
17509
  // walletClientType: wallet.connector.name.toLowerCase(),
16356
- onError: (error, errorType) => {
17510
+ onError: (error, _errorType) => {
16357
17511
  logger.error(error);
16358
17512
  disconnect();
16359
- if (errorType === OpenfortErrorType$1.AUTHENTICATION_ERROR) {
16360
- setStatus(states$3.DUPLICATED);
16361
- }
16362
- else {
16363
- setStatus(states$3.FAILED);
16364
- }
17513
+ // TODO: TMP FIX: Handle siwe error properly
17514
+ // if (errorType) {
17515
+ // setStatus(states.DUPLICATED)
17516
+ // } else {
17517
+ setStatus(states$3.FAILED);
17518
+ // }
16365
17519
  },
16366
17520
  onConnect: () => {
16367
17521
  onConnect();
@@ -16492,7 +17646,7 @@ const ConnectWithOAuth = () => {
16492
17646
  (async () => {
16493
17647
  if (connector.type !== 'oauth')
16494
17648
  throw new Error('Invalid connector type');
16495
- const url = new URL(window.location.href);
17649
+ const url = new URL(window.location.href.replace('?access_token=', '&access_token=')); // handle both ? and & cases
16496
17650
  const hasProvider = !!url.searchParams.get('openfortAuthProviderUI');
16497
17651
  const provider = connector.id;
16498
17652
  switch (status) {
@@ -16503,21 +17657,34 @@ const ConnectWithOAuth = () => {
16503
17657
  setTimeout(() => setStatus(states$2.REDIRECT), 150); // UX: wait a bit before redirecting
16504
17658
  break;
16505
17659
  case states$2.CONNECTING: {
16506
- const player = url.searchParams.get('player_id');
16507
- const accessToken = url.searchParams.get('access_token');
16508
- const refreshToken = url.searchParams.get('refresh_token');
16509
- ['openfortAuthProviderUI', 'refresh_token', 'access_token', 'player_id'].forEach((key) => {
17660
+ const userId = url.searchParams.get('user_id');
17661
+ const token = url.searchParams.get('access_token');
17662
+ const error = url.searchParams.get('error');
17663
+ ['openfortAuthProviderUI', 'access_token', 'user_id', 'error'].forEach((key) => {
16510
17664
  url.searchParams.delete(key);
16511
17665
  });
16512
17666
  window.history.replaceState({}, document.title, url.toString());
16513
- if (!player || !accessToken || !refreshToken) {
16514
- logger.error(`Missing player id or access token or refresh token: player=${player}, accessToken=${accessToken ? `${accessToken.substring(0, 10)}...` : accessToken}, refreshToken=${refreshToken}`);
17667
+ if (!userId || !token || error) {
17668
+ logger.error(`Missing user id or access token: userId=${userId}, accessToken=${token ? `${token.substring(0, 10)}...` : token}`);
17669
+ setStatus(states$2.ERROR);
17670
+ if (error) {
17671
+ switch (error) {
17672
+ case "email_doesn't_match":
17673
+ setDescription('The email associated with this OAuth provider does not match your account email.');
17674
+ break;
17675
+ default:
17676
+ setDescription('There was an error during authentication. Please try again.');
17677
+ }
17678
+ }
17679
+ else {
17680
+ setDescription('There was an error during authentication. Please try again.');
17681
+ }
17682
+ triggerResize();
16515
17683
  return;
16516
17684
  }
16517
17685
  client.auth.storeCredentials({
16518
- player,
16519
- accessToken,
16520
- refreshToken,
17686
+ token,
17687
+ userId,
16521
17688
  });
16522
17689
  setRoute(routes.LOADING);
16523
17690
  break;
@@ -16537,26 +17704,19 @@ const ConnectWithOAuth = () => {
16537
17704
  return;
16538
17705
  }
16539
17706
  const linkResponse = await client.auth.initLinkOAuth({
16540
- authToken,
16541
17707
  provider,
16542
- options: {
16543
- redirectTo: cleanURL,
16544
- queryParams,
16545
- },
17708
+ redirectTo: `${cleanURL}?${new URLSearchParams(queryParams).toString()}`,
16546
17709
  });
16547
17710
  logger.log(linkResponse);
16548
- window.location.href = linkResponse.url;
17711
+ window.location.href = linkResponse;
16549
17712
  }
16550
17713
  else {
16551
17714
  const r = await client.auth.initOAuth({
16552
17715
  provider,
16553
- options: {
16554
- redirectTo: cleanURL,
16555
- queryParams,
16556
- },
17716
+ redirectTo: `${cleanURL}?${new URLSearchParams(queryParams).toString()}`,
16557
17717
  });
16558
17718
  logger.log(r);
16559
- window.location.href = r.url;
17719
+ window.location.href = r;
16560
17720
  }
16561
17721
  }
16562
17722
  catch (e) {
@@ -16835,6 +17995,8 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
16835
17995
  createGuestUser: jsx(CreateGuestUserPage, {}),
16836
17996
  socialProviders: jsx(SocialProviders, {}),
16837
17997
  emailLogin: jsx(EmailLogin, {}),
17998
+ emailOtp: jsx(EmailOTP, {}),
17999
+ phoneOtp: jsx(PhoneOTP, {}),
16838
18000
  forgotPassword: jsx(ForgotPassword, {}),
16839
18001
  emailVerification: jsx(EmailVerification, {}),
16840
18002
  linkEmail: jsx(LinkEmail, {}),
@@ -16850,6 +18012,8 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
16850
18012
  profile: jsx(Profile, {}),
16851
18013
  switchNetworks: jsx(SwitchNetworks, {}),
16852
18014
  linkedProviders: jsx(LinkedProviders, {}),
18015
+ linkedProvider: jsx(LinkedProvider$1, {}),
18016
+ removeLinkedProvider: jsx(RemoveLinkedProvider, {}),
16853
18017
  connectWithMobile: jsx(ConnectWithMobile, {}),
16854
18018
  noAssetsAvailable: jsx(NoAssetsAvailable, {}),
16855
18019
  assetInventory: jsx(AssetInventory, {}),
@@ -16870,11 +18034,11 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
16870
18034
  }
16871
18035
  // if auth redirect
16872
18036
  useEffect(() => {
16873
- const url = new URL(window.location.href);
18037
+ const url = new URL(window.location.href.replace('?access_token=', '&access_token=')); // handle both ? and & cases
16874
18038
  const provider = url.searchParams.get('openfortAuthProviderUI');
16875
18039
  const emailVerification = url.searchParams.get('openfortEmailVerificationUI');
16876
18040
  const forgotPassword = url.searchParams.get('openfortForgotPasswordUI');
16877
- logger.log('Checking for search parameters', url);
18041
+ logger.log('Checking for search parameters', { url, provider, emailVerification, forgotPassword });
16878
18042
  if (emailVerification) {
16879
18043
  context.setOpen(true);
16880
18044
  context.setRoute(routes.EMAIL_VERIFICATION);
@@ -16996,12 +18160,13 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
16996
18160
  }
16997
18161
  const debugModeOptions = useMemo(() => {
16998
18162
  const getDebugMode = () => {
16999
- var _a, _b, _c;
18163
+ var _a, _b, _c, _d;
17000
18164
  if (typeof debugMode === 'undefined') {
17001
18165
  return {
17002
18166
  shieldDebugMode: false,
17003
18167
  openfortCoreDebugMode: false,
17004
18168
  openfortReactDebugMode: false,
18169
+ debugRoutes: false,
17005
18170
  };
17006
18171
  }
17007
18172
  else if (typeof debugMode === 'boolean') {
@@ -17009,6 +18174,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
17009
18174
  shieldDebugMode: debugMode,
17010
18175
  openfortCoreDebugMode: debugMode,
17011
18176
  openfortReactDebugMode: debugMode,
18177
+ debugRoutes: false,
17012
18178
  };
17013
18179
  }
17014
18180
  else {
@@ -17016,6 +18182,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
17016
18182
  shieldDebugMode: (_a = debugMode.shieldDebugMode) !== null && _a !== void 0 ? _a : false,
17017
18183
  openfortCoreDebugMode: (_b = debugMode.openfortCoreDebugMode) !== null && _b !== void 0 ? _b : false,
17018
18184
  openfortReactDebugMode: (_c = debugMode.openfortReactDebugMode) !== null && _c !== void 0 ? _c : false,
18185
+ debugRoutes: (_d = debugMode.debugRoutes) !== null && _d !== void 0 ? _d : false,
17019
18186
  };
17020
18187
  }
17021
18188
  };
@@ -17092,6 +18259,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
17092
18259
  const [errorMessage, setErrorMessage] = useState('');
17093
18260
  const [resize, onResize] = useState(0);
17094
18261
  const [emailInput, setEmailInput] = useState('');
18262
+ const [phoneInput, setPhoneInput] = useState('');
17095
18263
  const [sendForm, setSendForm] = useState(defaultSendFormState);
17096
18264
  const [buyForm, setBuyForm] = useState(defaultBuyFormState);
17097
18265
  const [headerLeftSlot, setHeaderLeftSlot] = useState(null);
@@ -17185,6 +18353,8 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
17185
18353
  debugMode: debugModeOptions,
17186
18354
  emailInput,
17187
18355
  setEmailInput,
18356
+ phoneInput,
18357
+ setPhoneInput,
17188
18358
  resize,
17189
18359
  triggerResize,
17190
18360
  publishableKey,
@@ -17198,20 +18368,32 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
17198
18368
  headerLeftSlot,
17199
18369
  setHeaderLeftSlot,
17200
18370
  };
17201
- return createElement(Openfortcontext.Provider, { value }, jsx(Web3ContextProvider, { children: jsxs(CoreOpenfortProvider, { openfortConfig: {
17202
- baseConfiguration: {
17203
- publishableKey,
17204
- },
17205
- shieldConfiguration: walletConfig
17206
- ? {
17207
- shieldPublishableKey: walletConfig.shieldPublishableKey,
17208
- debug: debugModeOptions.shieldDebugMode,
17209
- }
17210
- : undefined,
17211
- debug: debugModeOptions.openfortCoreDebugMode,
17212
- overrides,
17213
- thirdPartyAuth,
17214
- }, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_e = safeUiConfig.mode) !== null && _e !== void 0 ? _e : ckMode, customTheme: ckCustomTheme })] }) }));
18371
+ return createElement(Openfortcontext.Provider, { value }, jsxs(Web3ContextProvider, { children: [jsx(PhoneGlobalStyles, {}), jsxs(CoreOpenfortProvider, { openfortConfig: {
18372
+ baseConfiguration: {
18373
+ publishableKey,
18374
+ },
18375
+ shieldConfiguration: walletConfig
18376
+ ? {
18377
+ shieldPublishableKey: walletConfig.shieldPublishableKey,
18378
+ debug: debugModeOptions.shieldDebugMode,
18379
+ }
18380
+ : undefined,
18381
+ debug: debugModeOptions.openfortCoreDebugMode,
18382
+ overrides,
18383
+ thirdPartyAuth,
18384
+ }, onConnect: onConnect, onDisconnect: onDisconnect, children: [debugModeOptions.debugRoutes && (jsx("pre", { style: {
18385
+ position: 'absolute',
18386
+ top: 0,
18387
+ left: 0,
18388
+ fontSize: '14px',
18389
+ color: 'gray',
18390
+ background: 'white',
18391
+ zIndex: 9999,
18392
+ }, children: JSON.stringify(routeHistory.map((item) => Object.fromEntries(Object.entries(item).map(([key, value]) => [
18393
+ key,
18394
+ typeof value === 'object' && value !== null ? '[object]' : value,
18395
+ ]))), null, 2) // For debugging purposes
18396
+ })), children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_e = safeUiConfig.mode) !== null && _e !== void 0 ? _e : ckMode, customTheme: ckCustomTheme })] })] }));
17215
18397
  };
17216
18398
 
17217
18399
  /**
@@ -17295,16 +18477,15 @@ const useOAuth = (hookOptions = {}) => {
17295
18477
  });
17296
18478
  const { isOpen } = useUI();
17297
18479
  const { tryUseWallet } = useConnectToWalletPostAuth();
17298
- const storeCredentials = useCallback(async ({ player, accessToken, refreshToken, ...options }) => {
18480
+ const storeCredentials = useCallback(async ({ userId, token, ...options }) => {
17299
18481
  var _a, _b;
17300
18482
  setStatus({
17301
18483
  status: 'loading',
17302
18484
  });
17303
18485
  try {
17304
18486
  await client.auth.storeCredentials({
17305
- player,
17306
- accessToken,
17307
- refreshToken,
18487
+ userId,
18488
+ token,
17308
18489
  });
17309
18490
  setStatus({
17310
18491
  status: 'success',
@@ -17321,7 +18502,7 @@ const useOAuth = (hookOptions = {}) => {
17321
18502
  });
17322
18503
  }
17323
18504
  catch (e) {
17324
- const error = new OpenfortError('Failed to store credentials', OpenfortErrorType.AUTHENTICATION_ERROR, {
18505
+ const error = new OpenfortError('Failed to store credentials', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
17325
18506
  error: e,
17326
18507
  });
17327
18508
  setStatus({
@@ -17344,13 +18525,11 @@ const useOAuth = (hookOptions = {}) => {
17344
18525
  });
17345
18526
  await client.auth.initOAuth({
17346
18527
  provider: authProvider,
17347
- options: {
17348
- redirectTo: buildCallbackUrl({
17349
- provider: authProvider,
17350
- callbackUrl: (_a = hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.redirectTo,
17351
- isOpen,
17352
- }),
17353
- },
18528
+ redirectTo: buildCallbackUrl({
18529
+ provider: authProvider,
18530
+ callbackUrl: (_a = hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.redirectTo,
18531
+ isOpen,
18532
+ }),
17354
18533
  });
17355
18534
  return onSuccess({
17356
18535
  data: {},
@@ -17359,7 +18538,7 @@ const useOAuth = (hookOptions = {}) => {
17359
18538
  });
17360
18539
  }
17361
18540
  catch (e) {
17362
- const error = new OpenfortError('Failed to login with OAuth', OpenfortErrorType.AUTHENTICATION_ERROR, {
18541
+ const error = new OpenfortError('Failed to login with OAuth', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
17363
18542
  error: e,
17364
18543
  });
17365
18544
  setStatus({
@@ -17382,18 +18561,15 @@ const useOAuth = (hookOptions = {}) => {
17382
18561
  });
17383
18562
  const authToken = await client.getAccessToken();
17384
18563
  if (!authToken) {
17385
- throw new OpenfortError('No auth token found', OpenfortErrorType.AUTHENTICATION_ERROR);
18564
+ throw new OpenfortError('No auth token found', OpenfortReactErrorType.AUTHENTICATION_ERROR);
17386
18565
  }
17387
18566
  await client.auth.initLinkOAuth({
17388
- authToken,
17389
18567
  provider: authProvider,
17390
- options: {
17391
- redirectTo: buildCallbackUrl({
17392
- provider: authProvider,
17393
- callbackUrl: (_a = options === null || options === void 0 ? void 0 : options.redirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo,
17394
- isOpen,
17395
- }),
17396
- },
18568
+ redirectTo: buildCallbackUrl({
18569
+ provider: authProvider,
18570
+ callbackUrl: (_a = options === null || options === void 0 ? void 0 : options.redirectTo) !== null && _a !== void 0 ? _a : hookOptions === null || hookOptions === void 0 ? void 0 : hookOptions.redirectTo,
18571
+ isOpen,
18572
+ }),
17397
18573
  });
17398
18574
  return onSuccess({
17399
18575
  data: {},
@@ -17402,7 +18578,9 @@ const useOAuth = (hookOptions = {}) => {
17402
18578
  });
17403
18579
  }
17404
18580
  catch (e) {
17405
- const error = new OpenfortError('Failed to link OAuth', OpenfortErrorType.AUTHENTICATION_ERROR, { error: e });
18581
+ const error = new OpenfortError('Failed to link OAuth', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
18582
+ error: e,
18583
+ });
17406
18584
  setStatus({
17407
18585
  status: 'error',
17408
18586
  error,
@@ -17474,13 +18652,11 @@ const useOAuth = (hookOptions = {}) => {
17474
18652
  * state: 'verification-token',
17475
18653
  * });
17476
18654
  * };
17477
- *
17478
- * // Manually store credentials (if needed)
17479
- * const handleManualStore = async () => {
18655
+ * // Manually trigger storing credentials (if needed)
18656
+ * const handleManualStoreCredentials = async () => {
17480
18657
  * await authCallback.storeCredentials({
17481
- * player: 'player-id',
17482
- * accessToken: 'access-token',
17483
- * refreshToken: 'refresh-token',
18658
+ * userId: 'player-id',
18659
+ * token: 'access-token',
17484
18660
  * });
17485
18661
  * };
17486
18662
  * ```
@@ -17513,7 +18689,7 @@ const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and ema
17513
18689
  onError({
17514
18690
  hookOptions,
17515
18691
  options: {},
17516
- error: new OpenfortError('No state or email found in URL', OpenfortErrorType.AUTHENTICATION_ERROR),
18692
+ error: new OpenfortError('No state or email found in URL', OpenfortReactErrorType.AUTHENTICATION_ERROR),
17517
18693
  });
17518
18694
  return;
17519
18695
  }
@@ -17547,30 +18723,28 @@ const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and ema
17547
18723
  removeParams();
17548
18724
  }
17549
18725
  else {
17550
- const player = url.searchParams.get('player_id');
17551
- const accessToken = url.searchParams.get('access_token');
17552
- const refreshToken = url.searchParams.get('refresh_token');
17553
- if (!player || !accessToken || !refreshToken) {
17554
- logger.error(`Missing player id or access token or refresh token`, {
17555
- player,
17556
- accessToken: accessToken ? `${accessToken.substring(0, 10)}...` : accessToken,
17557
- refreshToken,
18726
+ const userId = url.searchParams.get('user_id');
18727
+ const token = url.searchParams.get('access_token');
18728
+ if (!userId || !token) {
18729
+ logger.error(`Missing user id or access token`, {
18730
+ userId,
18731
+ token: token ? `${token.substring(0, 10)}...` : token,
17558
18732
  fixedUrl,
17559
18733
  });
17560
18734
  onError({
17561
18735
  hookOptions,
17562
18736
  options: {},
17563
- error: new OpenfortError('Missing player id or access token or refresh token', OpenfortErrorType.AUTHENTICATION_ERROR),
18737
+ error: new OpenfortError('Missing player id or access token or refresh token', OpenfortReactErrorType.AUTHENTICATION_ERROR),
17564
18738
  });
17565
18739
  return;
17566
18740
  }
17567
18741
  const removeParams = () => {
17568
- ['openfortAuthProvider', 'refresh_token', 'access_token', 'player_id'].forEach((key) => {
18742
+ ['openfortAuthProvider', 'access_token', 'user_id'].forEach((key) => {
17569
18743
  url.searchParams.delete(key);
17570
18744
  });
17571
18745
  window.history.replaceState({}, document.title, url.toString());
17572
18746
  };
17573
- logger.log('callback', { player, accessToken, refreshToken });
18747
+ logger.log('callback', { userId });
17574
18748
  const options = {
17575
18749
  onSuccess: (data) => {
17576
18750
  var _a;
@@ -17589,7 +18763,7 @@ const useAuthCallback = ({ enabled = true, // Automatically handle OAuth and ema
17589
18763
  onError: hookOptions.onError,
17590
18764
  throwOnError: hookOptions.throwOnError,
17591
18765
  };
17592
- await storeCredentials({ player, accessToken, refreshToken, ...options });
18766
+ await storeCredentials({ userId, token, ...options });
17593
18767
  removeParams();
17594
18768
  }
17595
18769
  })();
@@ -17630,7 +18804,7 @@ const useWalletAuth = (hookOptions = {}) => {
17630
18804
  const { connectAsync } = useConnect({
17631
18805
  mutation: {
17632
18806
  onError: (e) => {
17633
- const error = new OpenfortError('Failed to connect with wallet', OpenfortErrorType.AUTHENTICATION_ERROR, {
18807
+ const error = new OpenfortError('Failed to connect with wallet', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
17634
18808
  error: e,
17635
18809
  });
17636
18810
  handleError(error);
@@ -17649,7 +18823,7 @@ const useWalletAuth = (hookOptions = {}) => {
17649
18823
  onError: (e) => {
17650
18824
  logger.log('Error connecting with SIWE', e);
17651
18825
  disconnect();
17652
- const error = new OpenfortError('Failed to connect with siwe', OpenfortErrorType.AUTHENTICATION_ERROR, {
18826
+ const error = new OpenfortError('Failed to connect with siwe', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
17653
18827
  error: e,
17654
18828
  });
17655
18829
  handleError(error);
@@ -17752,7 +18926,7 @@ const useWalletAuth = (hookOptions = {}) => {
17752
18926
  }
17753
18927
  if (!connector) {
17754
18928
  logger.log('Connector not found', connector);
17755
- return handleError(new OpenfortError('Connector not found', OpenfortErrorType.AUTHENTICATION_ERROR));
18929
+ return handleError(new OpenfortError('Connector not found', OpenfortReactErrorType.AUTHENTICATION_ERROR));
17756
18930
  }
17757
18931
  setWalletConnectingTo(connector.id);
17758
18932
  const hasDisconnected = new Promise((resolve) => {
@@ -17762,7 +18936,7 @@ const useWalletAuth = (hookOptions = {}) => {
17762
18936
  },
17763
18937
  onError: (e) => {
17764
18938
  logger.error('Error disconnecting', e);
17765
- const error = new OpenfortError('Failed to disconnect', OpenfortErrorType.AUTHENTICATION_ERROR, {
18939
+ const error = new OpenfortError('Failed to disconnect', OpenfortReactErrorType.AUTHENTICATION_ERROR, {
17766
18940
  error: e,
17767
18941
  });
17768
18942
  handleError(error);
@@ -17779,7 +18953,7 @@ const useWalletAuth = (hookOptions = {}) => {
17779
18953
  }
17780
18954
  catch (error) {
17781
18955
  logger.error('Error connecting', error);
17782
- handleError(new OpenfortError('Failed to connect', OpenfortErrorType.AUTHENTICATION_ERROR, { error }));
18956
+ handleError(new OpenfortError('Failed to connect', OpenfortReactErrorType.AUTHENTICATION_ERROR, { error }));
17783
18957
  }
17784
18958
  }, [siwe, disconnect, updateUser, availableWallets, setStatus, hookOptions]);
17785
18959
  return {
@@ -17826,11 +19000,11 @@ function use7702Authorization() {
17826
19000
  arrayifyMessage: false,
17827
19001
  }) => {
17828
19002
  if (!client) {
17829
- throw new OpenfortError('Openfort client is not initialized.', OpenfortErrorType.CONFIGURATION_ERROR);
19003
+ throw new OpenfortError('Openfort client is not initialized.', OpenfortReactErrorType.CONFIGURATION_ERROR);
17830
19004
  }
17831
19005
  const authorization = parameters;
17832
19006
  if (!authorization.contractAddress) {
17833
- throw new OpenfortError('Authorization is missing the contract address to sign.', OpenfortErrorType.VALIDATION_ERROR);
19007
+ throw new OpenfortError('Authorization is missing the contract address to sign.', OpenfortReactErrorType.VALIDATION_ERROR);
17834
19008
  }
17835
19009
  const hash = hashAuthorization(authorization);
17836
19010
  try {
@@ -17850,7 +19024,7 @@ function use7702Authorization() {
17850
19024
  };
17851
19025
  }
17852
19026
  catch (error) {
17853
- throw new OpenfortError('Failed to sign authorization.', OpenfortErrorType.WALLET_ERROR, { error });
19027
+ throw new OpenfortError('Failed to sign authorization.', OpenfortReactErrorType.WALLET_ERROR, { error });
17854
19028
  }
17855
19029
  }, [client]);
17856
19030
  return { signAuthorization };
@@ -17950,7 +19124,7 @@ const useGrantPermissions = (hookOptions = {}) => {
17950
19124
  try {
17951
19125
  logger.log('Granting permissions with request:', request);
17952
19126
  if (!walletClient) {
17953
- throw new OpenfortError('Wallet client not available', OpenfortErrorType.WALLET_ERROR);
19127
+ throw new OpenfortError('Wallet client not available', OpenfortReactErrorType.WALLET_ERROR);
17954
19128
  }
17955
19129
  setStatus({
17956
19130
  status: 'loading',
@@ -17958,7 +19132,7 @@ const useGrantPermissions = (hookOptions = {}) => {
17958
19132
  // Get the current chain configuration
17959
19133
  const chain = chains.find((c) => c.id === chainId);
17960
19134
  if (!chain) {
17961
- throw new OpenfortError('No chain configured', OpenfortErrorType.CONFIGURATION_ERROR);
19135
+ throw new OpenfortError('No chain configured', OpenfortReactErrorType.CONFIGURATION_ERROR);
17962
19136
  }
17963
19137
  // Get the account address
17964
19138
  const [account] = await walletClient.getAddresses();
@@ -17980,7 +19154,7 @@ const useGrantPermissions = (hookOptions = {}) => {
17980
19154
  });
17981
19155
  }
17982
19156
  catch (error) {
17983
- const openfortError = new OpenfortError('Failed to grant permissions', OpenfortErrorType.WALLET_ERROR, {
19157
+ const openfortError = new OpenfortError('Failed to grant permissions', OpenfortReactErrorType.WALLET_ERROR, {
17984
19158
  error,
17985
19159
  });
17986
19160
  setStatus({
@@ -18053,7 +19227,7 @@ const useRevokePermissions = (hookOptions = {}) => {
18053
19227
  const revokePermissions = useCallback(async ({ sessionKey }, options = {}) => {
18054
19228
  try {
18055
19229
  if (!walletClient) {
18056
- throw new OpenfortError('Wallet client not available', OpenfortErrorType.WALLET_ERROR);
19230
+ throw new OpenfortError('Wallet client not available', OpenfortReactErrorType.WALLET_ERROR);
18057
19231
  }
18058
19232
  logger.log('Revoking permissions for session key:', sessionKey);
18059
19233
  setStatus({
@@ -18062,7 +19236,7 @@ const useRevokePermissions = (hookOptions = {}) => {
18062
19236
  // Get the current chain configuration
18063
19237
  const chain = chains.find((c) => c.id === chainId);
18064
19238
  if (!chain) {
18065
- throw new OpenfortError('No chain configured', OpenfortErrorType.CONFIGURATION_ERROR);
19239
+ throw new OpenfortError('No chain configured', OpenfortReactErrorType.CONFIGURATION_ERROR);
18066
19240
  }
18067
19241
  // Get the account address
18068
19242
  const revokePermissionsResult = await walletClient.request({
@@ -18086,7 +19260,7 @@ const useRevokePermissions = (hookOptions = {}) => {
18086
19260
  });
18087
19261
  }
18088
19262
  catch (error) {
18089
- const openfortError = new OpenfortError('Failed to revoke permissions', OpenfortErrorType.WALLET_ERROR, {
19263
+ const openfortError = new OpenfortError('Failed to revoke permissions', OpenfortReactErrorType.WALLET_ERROR, {
18090
19264
  error,
18091
19265
  });
18092
19266
  setStatus({
@@ -18137,5 +19311,5 @@ const wallets = Object.keys(walletConfigs).reduce((acc, key) => {
18137
19311
  return acc;
18138
19312
  }, {});
18139
19313
 
18140
- export { UIAuthProvider as AuthProvider, Avatar, Chain as ChainIcon, LinkWalletOnSignUpOption, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortErrorType, OpenfortProvider, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, use7702Authorization, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGrantPermissions, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useRevokePermissions, useSignOut, useUI, useUser, useWalletAssets, useWalletAuth, useWallets, wallets };
19314
+ export { UIAuthProvider as AuthProvider, Avatar, Chain as ChainIcon, LinkWalletOnSignUpOption, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortReactErrorType as OpenfortErrorType, OpenfortProvider, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, use7702Authorization, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGrantPermissions, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useRevokePermissions, useSignOut, useUI, useUser, useWalletAssets, useWalletAuth, useWallets, wallets };
18141
19315
  //# sourceMappingURL=index.es.js.map