@openfort/react 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/Common/TickList/index.d.ts +7 -0
- package/build/components/Common/TickList/styles.d.ts +3 -0
- package/build/components/FloatingGraphic/index.d.ts +15 -0
- package/build/components/Openfort/context.d.ts +1 -1
- package/build/components/Openfort/types.d.ts +19 -26
- package/build/components/Pages/Providers/index.d.ts +2 -2
- package/build/components/Pages/Recover/index.d.ts +2 -2
- package/build/components/Pages/Recover/styles.d.ts +1 -0
- package/build/components/PasswordStrength/PasswordStrengthIndicator.d.ts +4 -0
- package/build/components/PasswordStrength/password-utility.d.ts +52 -0
- package/build/components/contexts/web3/index.d.ts +1 -2
- package/build/hooks/openfort/auth/useAuthCallback.d.ts +3 -3
- package/build/hooks/openfort/auth/{useCreateWalletPostAuth.d.ts → useConnectToWalletPostAuth.d.ts} +5 -4
- package/build/hooks/openfort/auth/useEmailAuth.d.ts +1 -1
- package/build/hooks/openfort/auth/useGuestAuth.d.ts +1 -1
- package/build/hooks/openfort/auth/useOAuth.d.ts +1 -1
- package/build/hooks/openfort/auth/useSignOut.d.ts +1 -1
- package/build/hooks/openfort/useProviders.d.ts +4 -4
- package/build/hooks/openfort/useWallets.d.ts +2 -1
- package/build/index.d.ts +1 -1
- package/build/index.es.js +612 -201
- package/build/index.es.js.map +1 -1
- package/build/types.d.ts +1 -1
- package/build/version.d.ts +1 -1
- package/package.json +3 -2
package/build/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Openfort as Openfort$1,
|
|
2
|
-
export { RecoveryMethod, ThirdPartyOAuthProvider } from '@openfort/openfort-js';
|
|
3
|
-
import { http, useConfig, useConnectors as useConnectors$1, useConnect as useConnect$1, useAccount, useDisconnect, useSwitchChain, createConfig, useEnsAddress, useEnsName, useEnsAvatar, useBalance,
|
|
1
|
+
import { Openfort as Openfort$1, EmbeddedState, AuthActionRequiredActions, OAuthProvider, RecoveryMethod, MissingRecoveryPasswordError, AccountTypeEnum, ChainTypeEnum } from '@openfort/openfort-js';
|
|
2
|
+
export { OAuthProvider, RecoveryMethod, ThirdPartyOAuthProvider } from '@openfort/openfort-js';
|
|
3
|
+
import { http, useConfig, useConnectors as useConnectors$1, useConnect as useConnect$1, useAccount, useDisconnect, useChainId, useSwitchChain, createConfig, useEnsAddress, useEnsName, useEnsAvatar, useBalance, WagmiContext, useBlockNumber } from 'wagmi';
|
|
4
4
|
import { mainnet, polygon, optimism, arbitrum, sepolia } from 'wagmi/chains';
|
|
5
5
|
import { safe, injected, coinbaseWallet, walletConnect } from '@wagmi/connectors';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import React, { useEffect, createContext, useState, useMemo, useRef, useCallback, createElement, useLayoutEffect } from 'react';
|
|
7
|
+
import React, { useEffect, createContext, useState, useMemo, useRef, useCallback, createElement, useLayoutEffect, useContext } from 'react';
|
|
8
8
|
import { detect } from 'detect-browser';
|
|
9
9
|
import { Buffer } from 'buffer';
|
|
10
|
-
import {
|
|
10
|
+
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
11
11
|
import { motion, AnimatePresence, MotionConfig } from 'framer-motion';
|
|
12
12
|
import styled$1, { css, keyframes } from 'styled-components';
|
|
13
13
|
import { createPortal } from 'react-dom';
|
|
@@ -20,9 +20,9 @@ import { normalize } from 'viem/ens';
|
|
|
20
20
|
import { AxiosError } from 'axios';
|
|
21
21
|
import { createSiweMessage } from 'viem/siwe';
|
|
22
22
|
import { signMessage } from '@wagmi/core';
|
|
23
|
-
import
|
|
23
|
+
import calculateEntropy from 'fast-password-entropy';
|
|
24
24
|
|
|
25
|
-
const OPENFORT_VERSION = '0.0.
|
|
25
|
+
const OPENFORT_VERSION = '0.0.7';
|
|
26
26
|
|
|
27
27
|
var OpenfortErrorType;
|
|
28
28
|
(function (OpenfortErrorType) {
|
|
@@ -292,7 +292,6 @@ var Logos = {
|
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
|
|
295
|
-
const playerRegex = /^(pla_[a-zA-Z0-9]{4})[a-zA-Z0-9-]+([a-zA-Z0-9]{4})$/;
|
|
296
295
|
const truncateEthAddress = (address, separator = '••••') => {
|
|
297
296
|
if (!address)
|
|
298
297
|
return '';
|
|
@@ -301,14 +300,6 @@ const truncateEthAddress = (address, separator = '••••') => {
|
|
|
301
300
|
return address;
|
|
302
301
|
return `${match[1]}${separator}${match[2]}`;
|
|
303
302
|
};
|
|
304
|
-
const truncateUserId = (playerId, separator = '••••') => {
|
|
305
|
-
if (!playerId)
|
|
306
|
-
return '';
|
|
307
|
-
const match = playerId.match(playerRegex);
|
|
308
|
-
if (!match)
|
|
309
|
-
return playerId;
|
|
310
|
-
return `${match[1]}${separator}${match[2]}`;
|
|
311
|
-
};
|
|
312
303
|
const nFormatter = (num, digits = 2) => {
|
|
313
304
|
if (num < 10000)
|
|
314
305
|
return num.toFixed(2);
|
|
@@ -769,24 +760,24 @@ const routes = {
|
|
|
769
760
|
PROFILE: 'profile',
|
|
770
761
|
SWITCHNETWORKS: 'switchNetworks',
|
|
771
762
|
};
|
|
772
|
-
var
|
|
773
|
-
(function (
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
763
|
+
var UIAuthProvider;
|
|
764
|
+
(function (UIAuthProvider) {
|
|
765
|
+
UIAuthProvider["GOOGLE"] = "google";
|
|
766
|
+
UIAuthProvider["TWITTER"] = "twitter";
|
|
767
|
+
UIAuthProvider["FACEBOOK"] = "facebook";
|
|
777
768
|
// DISCORD = "discord",
|
|
778
769
|
// EPIC_GAMES = "epic_games",
|
|
779
770
|
// LINE = "line",
|
|
780
771
|
// TELEGRAM = "telegram", // Telegram is not working yet
|
|
781
772
|
// Extended Providers
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
})(
|
|
773
|
+
UIAuthProvider["EMAIL"] = "email";
|
|
774
|
+
UIAuthProvider["WALLET"] = "wallet";
|
|
775
|
+
UIAuthProvider["GUEST"] = "guest";
|
|
776
|
+
})(UIAuthProvider || (UIAuthProvider = {}));
|
|
786
777
|
const socialProviders = [
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
778
|
+
UIAuthProvider.GOOGLE,
|
|
779
|
+
UIAuthProvider.TWITTER,
|
|
780
|
+
UIAuthProvider.FACEBOOK,
|
|
790
781
|
];
|
|
791
782
|
|
|
792
783
|
function useChainIsSupported(chainId) {
|
|
@@ -991,9 +982,8 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
991
982
|
const { connectors, connect, reset } = useConnect();
|
|
992
983
|
const { address } = useAccount();
|
|
993
984
|
const [user, setUser] = useState(null);
|
|
994
|
-
const {
|
|
985
|
+
const { disconnectAsync } = useDisconnect();
|
|
995
986
|
const { walletConfig } = useOpenfort();
|
|
996
|
-
const automaticRecovery = walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC;
|
|
997
987
|
// ---- Openfort instance ----
|
|
998
988
|
const openfort = useMemo(() => {
|
|
999
989
|
log('Creating Openfort instance.', openfortProps);
|
|
@@ -1075,21 +1065,27 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
1075
1065
|
return null;
|
|
1076
1066
|
}
|
|
1077
1067
|
}, [openfort]);
|
|
1068
|
+
const chainId = useChainId();
|
|
1078
1069
|
useEffect(() => {
|
|
1079
|
-
if (!openfort)
|
|
1080
|
-
return;
|
|
1081
|
-
if (!walletConfig)
|
|
1070
|
+
if (!openfort || !walletConfig)
|
|
1082
1071
|
return;
|
|
1083
|
-
log("Getting ethereum provider");
|
|
1084
|
-
|
|
1085
|
-
{
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1072
|
+
log("Getting ethereum provider", chainId);
|
|
1073
|
+
const resolvePolicy = () => {
|
|
1074
|
+
const { ethereumProviderPolicyId } = walletConfig;
|
|
1075
|
+
if (!ethereumProviderPolicyId)
|
|
1076
|
+
return undefined;
|
|
1077
|
+
if (typeof ethereumProviderPolicyId === "string") {
|
|
1078
|
+
return { policy: ethereumProviderPolicyId };
|
|
1090
1079
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1080
|
+
const policy = ethereumProviderPolicyId[chainId];
|
|
1081
|
+
if (!policy) {
|
|
1082
|
+
log(`No policy found for chainId ${chainId}.`);
|
|
1083
|
+
return undefined;
|
|
1084
|
+
}
|
|
1085
|
+
return { policy };
|
|
1086
|
+
};
|
|
1087
|
+
openfort.embeddedWallet.getEthereumProvider(resolvePolicy());
|
|
1088
|
+
}, [openfort, walletConfig, chainId]);
|
|
1093
1089
|
const [isConnectedWithEmbeddedSigner, setIsConnectedWithEmbeddedSigner] = useState(false);
|
|
1094
1090
|
useEffect(() => {
|
|
1095
1091
|
if (!openfort)
|
|
@@ -1127,7 +1123,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
1127
1123
|
default:
|
|
1128
1124
|
throw new Error(`Unknown embedded state: ${embeddedState}`);
|
|
1129
1125
|
}
|
|
1130
|
-
}, [embeddedState, openfort
|
|
1126
|
+
}, [embeddedState, openfort]);
|
|
1131
1127
|
useEffect(() => {
|
|
1132
1128
|
// Connect to wagmi with Embedded signer
|
|
1133
1129
|
if (address || !user)
|
|
@@ -1144,13 +1140,15 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
1144
1140
|
connect({ connector });
|
|
1145
1141
|
}, [connectors, embeddedState, address, user]);
|
|
1146
1142
|
// ---- Auth functions ----
|
|
1147
|
-
const
|
|
1143
|
+
const queryClient = useQueryClient();
|
|
1144
|
+
const logout = useCallback(async () => {
|
|
1148
1145
|
if (!openfort)
|
|
1149
1146
|
return;
|
|
1150
|
-
log('Logging out...');
|
|
1151
|
-
openfort.auth.logout();
|
|
1152
1147
|
setUser(null);
|
|
1153
|
-
|
|
1148
|
+
log('Logging out...');
|
|
1149
|
+
await openfort.auth.logout();
|
|
1150
|
+
await disconnectAsync();
|
|
1151
|
+
queryClient.resetQueries({ queryKey: ['openfortEmbeddedWalletList'] });
|
|
1154
1152
|
reset();
|
|
1155
1153
|
startPollingEmbeddedState();
|
|
1156
1154
|
}, [openfort]);
|
|
@@ -1174,7 +1172,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
1174
1172
|
return true;
|
|
1175
1173
|
case EmbeddedState.UNAUTHENTICATED:
|
|
1176
1174
|
if (user)
|
|
1177
|
-
return true; // If user
|
|
1175
|
+
return true; // If user i<s set in unauthenticated state, it means that the embedded state is not up to date, so we should wait
|
|
1178
1176
|
return false;
|
|
1179
1177
|
case EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED:
|
|
1180
1178
|
if (!user)
|
|
@@ -1191,7 +1189,7 @@ const CoreOpenfortProvider = ({ children, debugMode, onConnect, onDisconnect, ..
|
|
|
1191
1189
|
return true;
|
|
1192
1190
|
}
|
|
1193
1191
|
}, [embeddedState, address, user]);
|
|
1194
|
-
const needsRecovery =
|
|
1192
|
+
const needsRecovery = (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) && (!address);
|
|
1195
1193
|
const value = {
|
|
1196
1194
|
signUpGuest,
|
|
1197
1195
|
embeddedState,
|
|
@@ -2853,7 +2851,7 @@ const InfoButton = styled(motion.button) `
|
|
|
2853
2851
|
}
|
|
2854
2852
|
}
|
|
2855
2853
|
`;
|
|
2856
|
-
const Container$
|
|
2854
|
+
const Container$8 = styled(motion.div) `
|
|
2857
2855
|
--ease: cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
2858
2856
|
--duration: 200ms;
|
|
2859
2857
|
--transition: height var(--duration) var(--ease),
|
|
@@ -4921,7 +4919,7 @@ const Modal = ({ open, pages, pageId, positionInside, inline, demo, onClose, onB
|
|
|
4921
4919
|
const Content = (jsx(ResetContainer, { "$useTheme": (_e = demo === null || demo === void 0 ? void 0 : demo.theme) !== null && _e !== void 0 ? _e : themeContext.theme, "$useMode": (_f = demo === null || demo === void 0 ? void 0 : demo.mode) !== null && _f !== void 0 ? _f : themeContext.mode, "$customTheme": (_g = demo === null || demo === void 0 ? void 0 : demo.customTheme) !== null && _g !== void 0 ? _g : themeContext.customTheme, children: jsxs(ModalContainer, { role: "dialog", style: {
|
|
4922
4920
|
pointerEvents: rendered ? 'auto' : 'none',
|
|
4923
4921
|
position: positionInside ? 'absolute' : undefined,
|
|
4924
|
-
}, children: [!inline && (jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur": (_h = context.uiConfig) === null || _h === void 0 ? void 0 : _h.overlayBlur })), jsxs(Container$
|
|
4922
|
+
}, children: [!inline && (jsx(BackgroundOverlay, { "$active": rendered, onClick: onClose, "$blur": (_h = context.uiConfig) === null || _h === void 0 ? void 0 : _h.overlayBlur })), jsxs(Container$8, { style: dimensionsCSS, initial: false, children: [jsx("div", { style: {
|
|
4925
4923
|
pointerEvents: inTransition ? 'all' : 'none', // Block interaction while transitioning
|
|
4926
4924
|
position: 'absolute',
|
|
4927
4925
|
top: 0,
|
|
@@ -6466,7 +6464,7 @@ function useWalletConnectUri({ enabled } = {
|
|
|
6466
6464
|
};
|
|
6467
6465
|
}
|
|
6468
6466
|
|
|
6469
|
-
const Web3Context =
|
|
6467
|
+
const Web3Context = createContext({
|
|
6470
6468
|
connect: {
|
|
6471
6469
|
getUri: () => '',
|
|
6472
6470
|
},
|
|
@@ -6501,7 +6499,7 @@ const Web3ContextProvider = ({ enabled, children, }) => {
|
|
|
6501
6499
|
};
|
|
6502
6500
|
return jsx(Web3Context.Provider, { value: value, children: children });
|
|
6503
6501
|
};
|
|
6504
|
-
const useWeb3 = () =>
|
|
6502
|
+
const useWeb3 = () => useContext(Web3Context);
|
|
6505
6503
|
|
|
6506
6504
|
const AlertContainer = styled(motion.div) `
|
|
6507
6505
|
display: flex;
|
|
@@ -7348,7 +7346,7 @@ const WalletList = styled.div `
|
|
|
7348
7346
|
}
|
|
7349
7347
|
`}
|
|
7350
7348
|
`;
|
|
7351
|
-
const Container$
|
|
7349
|
+
const Container$7 = styled.div ``;
|
|
7352
7350
|
|
|
7353
7351
|
function useWalletConnectModal() {
|
|
7354
7352
|
const { log } = useOpenfort();
|
|
@@ -7455,7 +7453,7 @@ const CopyToClipboardIcon = ({ copied, small, }) => (jsx(IconContainer$3, { "$cl
|
|
|
7455
7453
|
opacity: small || copied ? 1 : 0.3,
|
|
7456
7454
|
} }) }));
|
|
7457
7455
|
|
|
7458
|
-
const Container$
|
|
7456
|
+
const Container$6 = styled.div `
|
|
7459
7457
|
--color: var(--ck-copytoclipboard-stroke);
|
|
7460
7458
|
--bg: var(--ck-body-background);
|
|
7461
7459
|
transition: all 220ms cubic-bezier(0.175, 0.885, 0.32, 1.1);
|
|
@@ -7505,7 +7503,7 @@ const CopyToClipboard = ({ string, children, variant }) => {
|
|
|
7505
7503
|
};
|
|
7506
7504
|
if (variant === 'button')
|
|
7507
7505
|
return (jsx(Button, { disabled: !string, onClick: onCopy, icon: jsx(CopyToClipboardIcon, { copied: clipboard }), children: children }));
|
|
7508
|
-
return (jsx(Container$
|
|
7506
|
+
return (jsx(Container$6, { onClick: onCopy, "$disabled": !string, children: jsxs(OffsetContainer, { children: [children, jsx(CopyToClipboardIcon, { copied: clipboard, small: true })] }) }));
|
|
7509
7507
|
};
|
|
7510
7508
|
|
|
7511
7509
|
const MoreIcon = (jsx("svg", { width: "60", height: "60", viewBox: "0 0 60 60", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M30 42V19M19 30.5H42", stroke: "var(--ck-body-color-muted)", strokeWidth: "3", strokeLinecap: "round" }) }));
|
|
@@ -7533,7 +7531,7 @@ const MobileConnectors = () => {
|
|
|
7533
7531
|
window.location.href = uri;
|
|
7534
7532
|
//if (uri) window.open(uri, '_blank');
|
|
7535
7533
|
};
|
|
7536
|
-
return (jsx(PageContent, { style: { width: 312 }, children: jsxs(Container$
|
|
7534
|
+
return (jsx(PageContent, { style: { width: 312 }, children: jsxs(Container$7, { children: [jsx(ModalContent, { style: { paddingBottom: 0 }, children: jsx(ScrollArea, { height: 340, children: jsxs(WalletList, { "$disabled": !wcUri, children: [walletsIdsToDisplay
|
|
7537
7535
|
.sort(
|
|
7538
7536
|
// sort by name
|
|
7539
7537
|
(a, b) => {
|
|
@@ -7644,7 +7642,7 @@ const LogoPosition = styled(motion.div) `
|
|
|
7644
7642
|
const LogoInner = styled(motion.div) `
|
|
7645
7643
|
position: absolute;
|
|
7646
7644
|
`;
|
|
7647
|
-
const LogoGraphic = styled(motion.div) `
|
|
7645
|
+
const LogoGraphic$1 = styled(motion.div) `
|
|
7648
7646
|
position: relative;
|
|
7649
7647
|
overflow: hidden;
|
|
7650
7648
|
height: 58px;
|
|
@@ -7714,7 +7712,7 @@ const Logo$2 = styled(motion.div) `
|
|
|
7714
7712
|
|
|
7715
7713
|
&:nth-child(1) ${LogoPosition} {
|
|
7716
7714
|
transform: translate(50%, 50%);
|
|
7717
|
-
${LogoGraphic} {
|
|
7715
|
+
${LogoGraphic$1} {
|
|
7718
7716
|
border-radius: 17.2px;
|
|
7719
7717
|
width: 72px;
|
|
7720
7718
|
height: 72px;
|
|
@@ -7741,7 +7739,7 @@ const Introduction = () => {
|
|
|
7741
7739
|
const context = useOpenfort();
|
|
7742
7740
|
const locales = useLocales({});
|
|
7743
7741
|
const ctaUrl = (_b = (_a = context.uiConfig) === null || _a === void 0 ? void 0 : _a.walletOnboardingUrl) !== null && _b !== void 0 ? _b : locales.onboardingScreen_ctaUrl;
|
|
7744
|
-
return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic, { children: jsx(Logos.ImToken, {}) }) }) }) }) }) })] }), jsx(GraphicBackground, { children: wave })] }), jsxs(ModalContent, { style: { paddingBottom: 18 }, children: [jsx(ModalH1, { "$small": true, children: locales.onboardingScreen_h1 }), jsx(ModalBody, { children: locales.onboardingScreen_p })] }), jsx(Button, { href: ctaUrl, arrow: true, children: locales.onboardingScreen_ctaText })] }));
|
|
7742
|
+
return (jsxs(PageContent, { children: [jsxs(Graphic, { children: [jsxs(LogoGroup, { children: [jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Coinbase, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.MetaMask, { background: true }) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Trust, {}) }) }) }) }) }) }), jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { children: jsx(Logos.Argent, {}) }) }) }) }) }) }), jsx(Logo$2, { 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 })] }));
|
|
7745
7743
|
};
|
|
7746
7744
|
|
|
7747
7745
|
const AvatarContainer = styled(motion.div) `
|
|
@@ -8986,7 +8984,7 @@ const ChainSelectDropdown = ({ children, open, onClose, offsetX = 0, offsetY = 8
|
|
|
8986
8984
|
}, children: [jsx(DropdownHeading, { children: locales.switchNetworks }), jsx(ChainSelectList, {})] })] }) }) }) })) })] }));
|
|
8987
8985
|
};
|
|
8988
8986
|
|
|
8989
|
-
const Container$
|
|
8987
|
+
const Container$5 = styled(motion.div) ``;
|
|
8990
8988
|
const SwitchChainButton = styled(motion.button) `
|
|
8991
8989
|
--color: var(
|
|
8992
8990
|
--ck-dropdown-button-color,
|
|
@@ -9095,7 +9093,7 @@ const ChainSelector = () => {
|
|
|
9095
9093
|
setIsOpen(false);
|
|
9096
9094
|
}, [context.open]);
|
|
9097
9095
|
const disabled = chains.length <= 1;
|
|
9098
|
-
return (jsx(Fragment, { children: jsx(Container$
|
|
9096
|
+
return (jsx(Fragment, { children: jsx(Container$5, { children: jsx(ChainSelectDropdown, { offsetX: -12, open: !mobile && isOpen, onClose: () => setIsOpen(false), children: jsxs(SwitchChainButton, { "aria-label": flattenChildren(locales.switchNetworks).toString(), disabled: disabled, onClick: () => {
|
|
9099
9097
|
if (mobile) {
|
|
9100
9098
|
context.setRoute(routes.SWITCHNETWORKS);
|
|
9101
9099
|
}
|
|
@@ -9108,7 +9106,7 @@ const ChainSelector = () => {
|
|
|
9108
9106
|
const PoweredByFooter = ({ showDisclaimer }) => {
|
|
9109
9107
|
var _a, _b;
|
|
9110
9108
|
const { uiConfig: options } = useOpenfort();
|
|
9111
|
-
return (jsxs(Container$
|
|
9109
|
+
return (jsxs(Container$4, { children: [showDisclaimer && (jsx(Disclaimer, { children: (options === null || options === void 0 ? void 0 : options.disclaimer) ? (jsx(Fragment, { children: options.disclaimer })) : (jsxs("div", { children: ["By logging in, you agree to our ", jsx("a", { href: (_a = options === null || options === void 0 ? void 0 : options.termsOfServiceUrl) !== null && _a !== void 0 ? _a : "https://www.openfort.xyz/terms", target: "_blank", rel: "noopener noreferrer", children: "Terms of Service" }), " & ", jsx("a", { href: (_b = options === null || options === void 0 ? void 0 : options.privacyPolicyUrl) !== null && _b !== void 0 ? _b : "https://www.openfort.xyz/privacy", target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" }), "."] })) })), jsxs(TextButton, { onClick: () => {
|
|
9112
9110
|
window.open("https://www.openfort.xyz/", "_blank");
|
|
9113
9111
|
}, children: [jsx("span", { children: "Powered by" }), jsx(IconContainer$2, { children: jsx(Logos.Openfort, {}) }), jsx("span", { children: "Openfort" })] })] }));
|
|
9114
9112
|
};
|
|
@@ -9157,7 +9155,7 @@ const IconContainer$2 = styled.div `
|
|
|
9157
9155
|
border-radius: 0;
|
|
9158
9156
|
}
|
|
9159
9157
|
`;
|
|
9160
|
-
const Container$
|
|
9158
|
+
const Container$4 = styled(motion.div) `
|
|
9161
9159
|
text-align: center;
|
|
9162
9160
|
margin-top: 4px;
|
|
9163
9161
|
margin-bottom: -16px;
|
|
@@ -9208,12 +9206,12 @@ function useProviders() {
|
|
|
9208
9206
|
const { user } = useOpenfortCore();
|
|
9209
9207
|
const { uiConfig: options, thirdPartyAuth, setOpen } = useOpenfort();
|
|
9210
9208
|
const allProviders = (options === null || options === void 0 ? void 0 : options.authProviders) || [];
|
|
9211
|
-
const providers = allProviders.filter(p => p !==
|
|
9209
|
+
const providers = allProviders.filter(p => p !== UIAuthProvider.GUEST) || [];
|
|
9212
9210
|
const linkedProviders = user ? providers.filter(p => { var _a; return (_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find(a => a.provider === p); }) : [];
|
|
9213
9211
|
const availableProviders = user ?
|
|
9214
9212
|
providers.filter(provider => {
|
|
9215
9213
|
var _a;
|
|
9216
|
-
if (provider ===
|
|
9214
|
+
if (provider === UIAuthProvider.WALLET)
|
|
9217
9215
|
return true; // Wallet is always available
|
|
9218
9216
|
return !((_a = user.linkedAccounts) === null || _a === void 0 ? void 0 : _a.find(a => a.provider === provider));
|
|
9219
9217
|
})
|
|
@@ -9350,10 +9348,7 @@ const Profile = ({ closeModal }) => {
|
|
|
9350
9348
|
//watch: true,
|
|
9351
9349
|
});
|
|
9352
9350
|
const [shouldDisconnect, setShouldDisconnect] = useState(false);
|
|
9353
|
-
const { logout
|
|
9354
|
-
useEffect(() => {
|
|
9355
|
-
// if (!isConnected) context.setOpen(false);
|
|
9356
|
-
}, [isConnected]);
|
|
9351
|
+
const { logout } = useOpenfortCore();
|
|
9357
9352
|
useEffect(() => {
|
|
9358
9353
|
if (!shouldDisconnect)
|
|
9359
9354
|
return;
|
|
@@ -9411,7 +9406,7 @@ const outlineKeyframes = keyframes `
|
|
|
9411
9406
|
0%{ opacity:1; }
|
|
9412
9407
|
100%{ opacity:0; }
|
|
9413
9408
|
`;
|
|
9414
|
-
const Container$
|
|
9409
|
+
const Container$3 = styled(motion.div) `
|
|
9415
9410
|
/*
|
|
9416
9411
|
background: var(
|
|
9417
9412
|
--ck-body-background
|
|
@@ -10012,14 +10007,14 @@ const ConnectWithInjector = ({ switchConnectMethod, forceState }) => {
|
|
|
10012
10007
|
}, [status, expiryTimer]);
|
|
10013
10008
|
*/
|
|
10014
10009
|
if (!wallet) {
|
|
10015
|
-
return (jsx(PageContent, { children: jsxs(Container$
|
|
10010
|
+
return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "No connectors match the id given. This state should never happen." }) })] }) }));
|
|
10016
10011
|
}
|
|
10017
10012
|
// OLD_TODO: Make this more generic
|
|
10018
10013
|
if (isWalletConnectConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector.id)) {
|
|
10019
|
-
return (jsx(PageContent, { children: jsxs(Container$
|
|
10014
|
+
return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ModalHeading, { children: "Invalid State" }), jsx(ModalContent, { children: jsx(Alert, { children: "WalletConnect does not have an injection flow. This state should never happen." }) })] }) }));
|
|
10020
10015
|
}
|
|
10021
10016
|
const hasError = status === states$2.FAILED || status === states$2.REJECTED || status === states$2.DUPLICATED;
|
|
10022
|
-
return (jsx(PageContent, { children: jsxs(Container$
|
|
10017
|
+
return (jsx(PageContent, { children: jsxs(Container$3, { children: [jsx(ConnectingContainer$1, { children: jsxs(ConnectingAnimation$1, { "$shake": hasError, "$circle": walletInfo.iconShape === 'circle', children: [jsx(AnimatePresence, { children: (hasError) && (jsx(RetryButton, { "aria-label": "Retry", initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileTap: { scale: 0.9 }, transition: { duration: 0.1 }, onClick: runConnect, children: jsx(RetryIconContainer, { children: jsx(Tooltip, { open: showTryAgainTooltip &&
|
|
10023
10018
|
(hasError), message: locales.tryAgainQuestion, xOffset: -6, children: jsx(RetryIconCircle, {}) }) }) })) }), walletInfo.iconShape === 'circle' ? (jsx(CircleSpinner, { logo: status === states$2.UNAVAILABLE ? (jsx("div", { style: {
|
|
10024
10019
|
transform: 'scale(1.14)',
|
|
10025
10020
|
position: 'relative',
|
|
@@ -10566,6 +10561,13 @@ const EmailSignup = () => {
|
|
|
10566
10561
|
}, children: [jsx(Input, { style: { marginTop: 0 }, value: email, onChange: (e) => setEmail(e.target.value), type: "email", placeholder: "Enter your email", disabled: signupLoading, autoComplete: "off" }), jsx(Input, { value: password, onChange: (e) => setPassword(e.target.value), type: "password", placeholder: "Enter your password", disabled: signupLoading, autoComplete: "new-password" }), signupError && (jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: "Invalid email or password" }) })), jsx(Button, { onClick: handleSubmit, disabled: signupLoading, children: "Sign up" })] }), jsx("div", { style: { marginTop: 16 }, children: jsx(OrDivider, {}) }), jsx(Button, { onClick: () => { setRoute(routes.EMAIL_LOGIN); }, children: "Log in" })] }));
|
|
10567
10562
|
};
|
|
10568
10563
|
|
|
10564
|
+
const LogoGraphic = ({ size = "100%", logo }) => {
|
|
10565
|
+
return (jsx(Logo$2, { children: jsx(LogoPosition, { children: jsx(LogoInner, { children: jsx(FloatWrapper, { children: jsx(RotateWrapper, { children: jsx(LogoGraphic$1, { style: { transform: `scale(${size})` }, children: logo }) }) }) }) }) }));
|
|
10566
|
+
};
|
|
10567
|
+
const FloatingGraphic = ({ height = "130px", logoCenter, logoTopRight, logoTopLeft, logoBottomRight, logoBottomLeft }) => {
|
|
10568
|
+
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 })] }));
|
|
10569
|
+
};
|
|
10570
|
+
|
|
10569
10571
|
const EmailVerification = () => {
|
|
10570
10572
|
const { client } = useOpenfortCore();
|
|
10571
10573
|
const { setRoute, log } = useOpenfort();
|
|
@@ -10650,8 +10652,17 @@ const EmailVerification = () => {
|
|
|
10650
10652
|
if (loading) {
|
|
10651
10653
|
return (jsx(PageContent, { children: jsx(Loader, { reason: "Checking if account is verified" }) }));
|
|
10652
10654
|
}
|
|
10653
|
-
return (
|
|
10654
|
-
|
|
10655
|
+
return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "190px", logoCenter: {
|
|
10656
|
+
logo: jsx(EmailIcon, {}),
|
|
10657
|
+
}, logoTopLeft: {
|
|
10658
|
+
logo: jsx(EmailIcon, {}),
|
|
10659
|
+
}, logoBottomRight: {
|
|
10660
|
+
logo: jsx(EmailIcon, {}),
|
|
10661
|
+
}, logoTopRight: {
|
|
10662
|
+
logo: jsx(EmailIcon, {}),
|
|
10663
|
+
}, logoBottomLeft: {
|
|
10664
|
+
logo: jsx(EmailIcon, {}),
|
|
10665
|
+
} }), 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: () => {
|
|
10655
10666
|
setRoute(routes.EMAIL_LOGIN);
|
|
10656
10667
|
}, 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: () => { setRoute(routes.EMAIL_LOGIN); }, children: "Use another email" })] })) })] }));
|
|
10657
10668
|
};
|
|
@@ -10901,17 +10912,17 @@ const AuthProviderButton = ({ provider, title = provider + " login", icon }) =>
|
|
|
10901
10912
|
};
|
|
10902
10913
|
const ProviderButtonSwitch = ({ provider }) => {
|
|
10903
10914
|
switch (provider) {
|
|
10904
|
-
case
|
|
10915
|
+
case UIAuthProvider.GUEST:
|
|
10905
10916
|
return jsx(GuestButton, {});
|
|
10906
|
-
case
|
|
10917
|
+
case UIAuthProvider.WALLET:
|
|
10907
10918
|
return jsx(WalletButton, {});
|
|
10908
|
-
case
|
|
10919
|
+
case UIAuthProvider.EMAIL:
|
|
10909
10920
|
return jsx(EmailButton, {});
|
|
10910
|
-
case
|
|
10921
|
+
case UIAuthProvider.GOOGLE:
|
|
10911
10922
|
return (jsx(AuthProviderButton, { provider: OAuthProvider.GOOGLE, title: "Google", icon: providersLogos[provider] }));
|
|
10912
|
-
case
|
|
10923
|
+
case UIAuthProvider.TWITTER:
|
|
10913
10924
|
return (jsx(AuthProviderButton, { provider: OAuthProvider.TWITTER, title: "X", icon: providersLogos[provider] }));
|
|
10914
|
-
case
|
|
10925
|
+
case UIAuthProvider.FACEBOOK:
|
|
10915
10926
|
return (jsx(AuthProviderButton, { provider: OAuthProvider.FACEBOOK, title: "Facebook", icon: providersLogos[provider] }));
|
|
10916
10927
|
default:
|
|
10917
10928
|
throw new Error(`NOT IMPLEMENTED: ${provider}`);
|
|
@@ -11020,12 +11031,13 @@ function useUser() {
|
|
|
11020
11031
|
};
|
|
11021
11032
|
}
|
|
11022
11033
|
|
|
11023
|
-
const
|
|
11034
|
+
const parseOpenfortWallet = ({ address, recoveryMethod, }) => ({
|
|
11024
11035
|
connectorType: "embedded",
|
|
11025
11036
|
walletClientType: "openfort",
|
|
11026
11037
|
address,
|
|
11027
11038
|
id: embeddedWalletId,
|
|
11028
11039
|
isAvailable: true,
|
|
11040
|
+
recoveryMethod,
|
|
11029
11041
|
});
|
|
11030
11042
|
const mapWalletStatus = (status) => {
|
|
11031
11043
|
return {
|
|
@@ -11086,9 +11098,6 @@ function useWallets(hookOptions = {}) {
|
|
|
11086
11098
|
refetchOnMount: false,
|
|
11087
11099
|
refetchOnWindowFocus: false,
|
|
11088
11100
|
});
|
|
11089
|
-
// useEffect(() => {
|
|
11090
|
-
// queryClient.resetQueries({ queryKey: ['openfortEmbeddedWalletList'] })
|
|
11091
|
-
// }, [!!user, refetch]);
|
|
11092
11101
|
const getEncryptionSession = useCallback(async () => {
|
|
11093
11102
|
if (!walletConfig || !walletConfig.createEncryptedSessionEndpoint) {
|
|
11094
11103
|
throw new Error("No createEncryptedSessionEndpoint set in walletConfig");
|
|
@@ -11107,7 +11116,7 @@ function useWallets(hookOptions = {}) {
|
|
|
11107
11116
|
}, [walletConfig]);
|
|
11108
11117
|
const rawWallets = useMemo(() => {
|
|
11109
11118
|
const userWallets = user ? user.linkedAccounts
|
|
11110
|
-
.filter((a) => a.provider ===
|
|
11119
|
+
.filter((a) => a.provider === UIAuthProvider.WALLET)
|
|
11111
11120
|
.map((a) => {
|
|
11112
11121
|
const wallet = deviceWallets.find((c) => c.connector.id === a.walletClientType);
|
|
11113
11122
|
return {
|
|
@@ -11122,8 +11131,9 @@ function useWallets(hookOptions = {}) {
|
|
|
11122
11131
|
// Remove duplicates (different chain ids)
|
|
11123
11132
|
if (userWallets.find(w => w.address === (wallet.address)))
|
|
11124
11133
|
return;
|
|
11125
|
-
userWallets.push(
|
|
11134
|
+
userWallets.push(parseOpenfortWallet({
|
|
11126
11135
|
address: wallet.address,
|
|
11136
|
+
recoveryMethod: wallet.recoveryMethod,
|
|
11127
11137
|
}));
|
|
11128
11138
|
});
|
|
11129
11139
|
return userWallets;
|
|
@@ -11209,6 +11219,14 @@ function useWallets(hookOptions = {}) {
|
|
|
11209
11219
|
hookOptions
|
|
11210
11220
|
});
|
|
11211
11221
|
}
|
|
11222
|
+
const accessToken = await client.getAccessToken();
|
|
11223
|
+
if (!accessToken) {
|
|
11224
|
+
return onError({
|
|
11225
|
+
error: new OpenfortError("Openfort access token not found", OpenfortErrorType.WALLET_ERROR),
|
|
11226
|
+
hookOptions,
|
|
11227
|
+
options: optionsObject,
|
|
11228
|
+
});
|
|
11229
|
+
}
|
|
11212
11230
|
log(`Handling recovery with Openfort: ${password ? "with password" : "without password"}, chainId=${chainId}`);
|
|
11213
11231
|
try {
|
|
11214
11232
|
const recoveryParams = password ? {
|
|
@@ -11217,7 +11235,7 @@ function useWallets(hookOptions = {}) {
|
|
|
11217
11235
|
} : {
|
|
11218
11236
|
recoveryMethod: RecoveryMethod.AUTOMATIC,
|
|
11219
11237
|
encryptionSession: walletConfig.getEncryptionSession ?
|
|
11220
|
-
await walletConfig.getEncryptionSession() :
|
|
11238
|
+
await walletConfig.getEncryptionSession(accessToken) :
|
|
11221
11239
|
await getEncryptionSession()
|
|
11222
11240
|
};
|
|
11223
11241
|
// Ensure that the embedded wallet is listed
|
|
@@ -11250,13 +11268,12 @@ function useWallets(hookOptions = {}) {
|
|
|
11250
11268
|
walletAddress = walletToRecover.address;
|
|
11251
11269
|
}
|
|
11252
11270
|
else {
|
|
11253
|
-
|
|
11254
|
-
|
|
11271
|
+
// 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)
|
|
11272
|
+
return onError({
|
|
11273
|
+
error: new OpenfortError("No embedded wallet found for the current chain", OpenfortErrorType.WALLET_ERROR),
|
|
11274
|
+
options: optionsObject,
|
|
11275
|
+
hookOptions
|
|
11255
11276
|
});
|
|
11256
|
-
if (!wallet.wallet) {
|
|
11257
|
-
return { error: wallet.error || new OpenfortError("Failed to create embedded wallet", OpenfortErrorType.WALLET_ERROR) };
|
|
11258
|
-
}
|
|
11259
|
-
walletAddress = wallet.wallet.address;
|
|
11260
11277
|
}
|
|
11261
11278
|
}
|
|
11262
11279
|
setStatus({
|
|
@@ -11264,8 +11281,9 @@ function useWallets(hookOptions = {}) {
|
|
|
11264
11281
|
});
|
|
11265
11282
|
return onSuccess({
|
|
11266
11283
|
data: {
|
|
11267
|
-
wallet:
|
|
11284
|
+
wallet: parseOpenfortWallet({
|
|
11268
11285
|
address: walletAddress,
|
|
11286
|
+
recoveryMethod: recoveryParams.recoveryMethod,
|
|
11269
11287
|
}),
|
|
11270
11288
|
},
|
|
11271
11289
|
options: optionsObject,
|
|
@@ -11350,7 +11368,7 @@ function useWallets(hookOptions = {}) {
|
|
|
11350
11368
|
} : {
|
|
11351
11369
|
recoveryMethod: RecoveryMethod.AUTOMATIC,
|
|
11352
11370
|
encryptionSession: walletConfig.getEncryptionSession ?
|
|
11353
|
-
await walletConfig.getEncryptionSession() :
|
|
11371
|
+
await walletConfig.getEncryptionSession(accessToken) :
|
|
11354
11372
|
await getEncryptionSession()
|
|
11355
11373
|
};
|
|
11356
11374
|
const wallet = await client.embeddedWallet.create({
|
|
@@ -11365,8 +11383,9 @@ function useWallets(hookOptions = {}) {
|
|
|
11365
11383
|
refetch();
|
|
11366
11384
|
return onSuccess({
|
|
11367
11385
|
data: {
|
|
11368
|
-
wallet:
|
|
11386
|
+
wallet: parseOpenfortWallet({
|
|
11369
11387
|
address: wallet.address,
|
|
11388
|
+
recoveryMethod: wallet.recoveryMethod,
|
|
11370
11389
|
})
|
|
11371
11390
|
}
|
|
11372
11391
|
});
|
|
@@ -11399,8 +11418,9 @@ function useWallets(hookOptions = {}) {
|
|
|
11399
11418
|
hookOptions,
|
|
11400
11419
|
options: params,
|
|
11401
11420
|
data: {
|
|
11402
|
-
wallet:
|
|
11421
|
+
wallet: parseOpenfortWallet({
|
|
11403
11422
|
address: embeddedAccount.address,
|
|
11423
|
+
recoveryMethod: embeddedAccount.recoveryMethod,
|
|
11404
11424
|
}),
|
|
11405
11425
|
}
|
|
11406
11426
|
});
|
|
@@ -11429,19 +11449,202 @@ function useWallets(hookOptions = {}) {
|
|
|
11429
11449
|
};
|
|
11430
11450
|
}
|
|
11431
11451
|
|
|
11452
|
+
const TickListContainer = styled.ul `
|
|
11453
|
+
display: flex;
|
|
11454
|
+
flex-direction: column;
|
|
11455
|
+
gap: 8px;
|
|
11456
|
+
padding-top: 8px;
|
|
11457
|
+
padding-bottom: 8px;
|
|
11458
|
+
`;
|
|
11459
|
+
const TickItem = styled.li `
|
|
11460
|
+
display: flex;
|
|
11461
|
+
align-items: center;
|
|
11462
|
+
text-align: left;
|
|
11463
|
+
gap: 8px;
|
|
11464
|
+
font-size: 16px;
|
|
11465
|
+
line-height: 24px;
|
|
11466
|
+
`;
|
|
11467
|
+
const TickIconWrapper = styled.span `
|
|
11468
|
+
display: flex;
|
|
11469
|
+
align-items: center;
|
|
11470
|
+
justify-content: center;
|
|
11471
|
+
width: 16px;
|
|
11472
|
+
height: 16px;
|
|
11473
|
+
flex-shrink: 0;
|
|
11474
|
+
`;
|
|
11475
|
+
|
|
11476
|
+
const TickList = ({ items }) => {
|
|
11477
|
+
return (jsx(TickListContainer, { children: items.map((item, index) => (jsxs(TickItem, { children: [jsx(TickIconWrapper, { children: jsx(TickIcon, {}) }), jsx("span", { children: item })] }, index))) }));
|
|
11478
|
+
};
|
|
11479
|
+
TickList.displayName = 'TickList';
|
|
11480
|
+
|
|
11481
|
+
/**
|
|
11482
|
+
* Password Utilities Module
|
|
11483
|
+
* Provides functions for password strength calculation, passphrase generation,
|
|
11484
|
+
* and password validation.
|
|
11485
|
+
*/
|
|
11486
|
+
// ============================================================================
|
|
11487
|
+
// Constants and Regular Expressions
|
|
11488
|
+
// ============================================================================
|
|
11489
|
+
/** Regular expression to match lowercase letters */
|
|
11490
|
+
const LOWERCASE_REGEX = /[a-z]/;
|
|
11491
|
+
/** Regular expression to match uppercase letters */
|
|
11492
|
+
const UPPERCASE_REGEX = /[A-Z]/;
|
|
11493
|
+
/** Regular expression to match digits */
|
|
11494
|
+
const DIGIT_REGEX = /[0-9]/;
|
|
11495
|
+
/** Special characters allowed in passwords */
|
|
11496
|
+
const SPECIAL_CHARACTERS = '!@#$%^&()\\-*+.';
|
|
11497
|
+
/** Regular expression to match special characters */
|
|
11498
|
+
const SPECIAL_CHARACTER_REGEX = new RegExp(`[${SPECIAL_CHARACTERS}]`);
|
|
11499
|
+
/** Maximum entropy score for normalization */
|
|
11500
|
+
const MAX_ENTROPY_SCORE = 95;
|
|
11501
|
+
/** Minimum password length for security */
|
|
11502
|
+
const MIN_PASSWORD_LENGTH = 8;
|
|
11503
|
+
/** Weight for diversity score in overall strength calculation */
|
|
11504
|
+
const DIVERSITY_WEIGHT = 0.3;
|
|
11505
|
+
const ENTROPY_WEIGHT = 0.7;
|
|
11506
|
+
const MEDIUM_SCORE_THRESHOLD = 0.5;
|
|
11507
|
+
const STRONG_SCORE_THRESHOLD = 0.75;
|
|
11508
|
+
const VERY_STRONG_SCORE_THRESHOLD = 0.9;
|
|
11509
|
+
/**
|
|
11510
|
+
* Converts a numeric password strength score to a human-readable label.
|
|
11511
|
+
*
|
|
11512
|
+
* @param score - The strength score (0-1)
|
|
11513
|
+
* @returns The corresponding strength label
|
|
11514
|
+
*/
|
|
11515
|
+
function getPasswordStrengthLabel(score) {
|
|
11516
|
+
if (score > VERY_STRONG_SCORE_THRESHOLD) {
|
|
11517
|
+
return 'Very Strong';
|
|
11518
|
+
}
|
|
11519
|
+
else if (score > STRONG_SCORE_THRESHOLD) {
|
|
11520
|
+
return 'Strong';
|
|
11521
|
+
}
|
|
11522
|
+
else if (score > MEDIUM_SCORE_THRESHOLD) {
|
|
11523
|
+
return 'Medium';
|
|
11524
|
+
}
|
|
11525
|
+
else {
|
|
11526
|
+
return 'Weak';
|
|
11527
|
+
}
|
|
11528
|
+
}
|
|
11529
|
+
/**
|
|
11530
|
+
* Calculates the diversity score of a password based on character types used.
|
|
11531
|
+
* Considers lowercase, uppercase, digits, and special characters.
|
|
11532
|
+
*
|
|
11533
|
+
* @param password - The password to analyze
|
|
11534
|
+
* @returns A score between 0 and 1 representing character diversity
|
|
11535
|
+
*/
|
|
11536
|
+
function calculatePasswordDiversityScore(password) {
|
|
11537
|
+
// Passwords shorter than minimum length get a score of 0
|
|
11538
|
+
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
11539
|
+
return 0;
|
|
11540
|
+
}
|
|
11541
|
+
let characterTypesUsed = 0;
|
|
11542
|
+
if (LOWERCASE_REGEX.test(password)) {
|
|
11543
|
+
characterTypesUsed += 1;
|
|
11544
|
+
}
|
|
11545
|
+
if (UPPERCASE_REGEX.test(password)) {
|
|
11546
|
+
characterTypesUsed += 1;
|
|
11547
|
+
}
|
|
11548
|
+
if (DIGIT_REGEX.test(password)) {
|
|
11549
|
+
characterTypesUsed += 1;
|
|
11550
|
+
}
|
|
11551
|
+
if (SPECIAL_CHARACTER_REGEX.test(password)) {
|
|
11552
|
+
characterTypesUsed += 1;
|
|
11553
|
+
}
|
|
11554
|
+
return Math.max(0, Math.min(1, characterTypesUsed / 4));
|
|
11555
|
+
}
|
|
11556
|
+
/**
|
|
11557
|
+
* Calculates the overall password strength combining diversity and entropy.
|
|
11558
|
+
*
|
|
11559
|
+
* @param password - The password to analyze
|
|
11560
|
+
* @returns A strength score between 0 and 1
|
|
11561
|
+
*/
|
|
11562
|
+
function getPasswordStrength(password = '') {
|
|
11563
|
+
const diversityScore = calculatePasswordDiversityScore(password);
|
|
11564
|
+
const entropyScore = calculateEntropy(password) / MAX_ENTROPY_SCORE;
|
|
11565
|
+
return Math.min((diversityScore * DIVERSITY_WEIGHT +
|
|
11566
|
+
entropyScore * ENTROPY_WEIGHT), 1);
|
|
11567
|
+
}
|
|
11568
|
+
|
|
11569
|
+
const Container$2 = styled.div `
|
|
11570
|
+
display: flex;
|
|
11571
|
+
flex-direction: column;
|
|
11572
|
+
gap: 0.5rem;
|
|
11573
|
+
margin-top: 0.5rem;
|
|
11574
|
+
margin-bottom: 0.5rem;
|
|
11575
|
+
text-align: left;
|
|
11576
|
+
`;
|
|
11577
|
+
const BarWrapper = styled.div `
|
|
11578
|
+
width: 100%;
|
|
11579
|
+
height: 4px;
|
|
11580
|
+
background: var(--ck-secondary-button-background);
|
|
11581
|
+
border-radius: 4px;
|
|
11582
|
+
overflow: hidden;
|
|
11583
|
+
`;
|
|
11584
|
+
const Progress = styled(motion.div) `
|
|
11585
|
+
height: 100%;
|
|
11586
|
+
background: ${({ color }) => color};
|
|
11587
|
+
border-radius: 4px;
|
|
11588
|
+
`;
|
|
11589
|
+
const Label = styled.div `
|
|
11590
|
+
font-size: 0.875rem;
|
|
11591
|
+
font-weight: 500;
|
|
11592
|
+
color: var(--ck-body-color-muted);
|
|
11593
|
+
`;
|
|
11594
|
+
const LabelColor = styled.span `
|
|
11595
|
+
color: ${({ color }) => color};
|
|
11596
|
+
`;
|
|
11597
|
+
const PasswordStrengthIndicator = ({ password, showPasswordIsTooWeakError }) => {
|
|
11598
|
+
const passwordStrength = getPasswordStrength(password); // should return a number between 0 and 1
|
|
11599
|
+
const label = getPasswordStrengthLabel(passwordStrength);
|
|
11600
|
+
const color = useMemo(() => {
|
|
11601
|
+
switch (label) {
|
|
11602
|
+
case "Weak":
|
|
11603
|
+
return "#ef4444"; // red-500
|
|
11604
|
+
case "Medium":
|
|
11605
|
+
return "#f59e0b"; // amber-500
|
|
11606
|
+
case "Strong":
|
|
11607
|
+
return "#10b981"; // emerald-500
|
|
11608
|
+
case "Very Strong":
|
|
11609
|
+
return "#3b82f6"; // blue-500
|
|
11610
|
+
default:
|
|
11611
|
+
return "#d1d5db"; // gray-300
|
|
11612
|
+
}
|
|
11613
|
+
}, [label]);
|
|
11614
|
+
return (jsxs(Container$2, { children: [jsx(BarWrapper, { children: jsx(Progress, { color: color, initial: { width: 0 }, animate: { width: `${passwordStrength * 100}%` }, transition: { ease: "easeOut", duration: 0.5 } }) }), jsxs("div", { style: { position: 'relative' }, children: [jsx(motion.div, { initial: { opacity: 1 }, animate: {
|
|
11615
|
+
opacity: showPasswordIsTooWeakError ? 0 : 1,
|
|
11616
|
+
y: showPasswordIsTooWeakError ? 5 : 0
|
|
11617
|
+
}, transition: { duration: 0.3 }, children: jsxs(Label, { children: ["Password strength: ", jsx(LabelColor, { color: color, children: label })] }) }), jsx(motion.div, { initial: { opacity: 0 }, animate: {
|
|
11618
|
+
opacity: showPasswordIsTooWeakError ? 1 : 0,
|
|
11619
|
+
y: showPasswordIsTooWeakError ? 0 : -5
|
|
11620
|
+
}, transition: { duration: 0.3 }, style: { color: '#ef4444', fontSize: '0.875rem', fontWeight: 500, position: 'absolute', top: '0' }, children: "Password is too weak" })] })] }));
|
|
11621
|
+
};
|
|
11622
|
+
|
|
11623
|
+
const OtherMethodButton = styled.button `
|
|
11624
|
+
width: 100%;
|
|
11625
|
+
color: var(--ck-body-color-muted);
|
|
11626
|
+
transition: color 0.2s;
|
|
11627
|
+
font-size: 14px;
|
|
11628
|
+
margin-top: 10px;
|
|
11629
|
+
|
|
11630
|
+
&:hover {
|
|
11631
|
+
color: var(--ck-body-color);
|
|
11632
|
+
}
|
|
11633
|
+
`;
|
|
11634
|
+
|
|
11432
11635
|
// TODO: Localize
|
|
11433
|
-
const
|
|
11434
|
-
const [recoveryPhrase, setRecoveryPhrase] =
|
|
11435
|
-
const [recoveryError, setRecoveryError] =
|
|
11636
|
+
const RecoverPasswordWallet = ({ wallet }) => {
|
|
11637
|
+
const [recoveryPhrase, setRecoveryPhrase] = useState("");
|
|
11638
|
+
const [recoveryError, setRecoveryError] = useState(false);
|
|
11436
11639
|
const { triggerResize, uiConfig: options, log } = useOpenfort();
|
|
11437
|
-
|
|
11438
|
-
const [loading, setLoading] = React.useState(false);
|
|
11640
|
+
const [loading, setLoading] = useState(false);
|
|
11439
11641
|
const { setActiveWallet } = useWallets();
|
|
11440
11642
|
const handleSubmit = async () => {
|
|
11441
11643
|
setLoading(true);
|
|
11442
11644
|
const { error } = await setActiveWallet({
|
|
11443
11645
|
connector: embeddedWalletId,
|
|
11444
11646
|
password: recoveryPhrase,
|
|
11647
|
+
address: wallet.address,
|
|
11445
11648
|
});
|
|
11446
11649
|
setLoading(false);
|
|
11447
11650
|
if (error) {
|
|
@@ -11455,34 +11658,190 @@ const Recover = () => {
|
|
|
11455
11658
|
if (recoveryError)
|
|
11456
11659
|
triggerResize();
|
|
11457
11660
|
}, [recoveryError]);
|
|
11458
|
-
|
|
11661
|
+
const ensFallbackConfig = useEnsFallbackConfig();
|
|
11662
|
+
const { data: ensName } = useEnsName({
|
|
11663
|
+
chainId: 1,
|
|
11664
|
+
address: wallet.address,
|
|
11665
|
+
config: ensFallbackConfig,
|
|
11666
|
+
});
|
|
11667
|
+
const separator = '....';
|
|
11668
|
+
return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "130px", logoCenter: {
|
|
11669
|
+
logo: jsx(KeyIcon, {}),
|
|
11670
|
+
size: "1.2",
|
|
11671
|
+
}, logoTopLeft: {
|
|
11672
|
+
logo: jsx(ShieldIcon, {}),
|
|
11673
|
+
size: "0.75",
|
|
11674
|
+
}, logoBottomRight: {
|
|
11675
|
+
logo: jsx(LockIcon, {}),
|
|
11676
|
+
size: "0.5",
|
|
11677
|
+
} }), jsx(ModalHeading, { children: "Recover wallet" }), jsxs(ModalBody, { style: { textAlign: "center" }, children: ["Please enter the recovery password to recover wallet", " ", jsx(CopyToClipboard, { string: wallet.address, children: ensName !== null && ensName !== void 0 ? ensName : truncateEthAddress(wallet.address, separator) })] }), jsxs("form", { onSubmit: (e) => {
|
|
11459
11678
|
e.preventDefault();
|
|
11460
11679
|
handleSubmit();
|
|
11461
|
-
}, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => setRecoveryPhrase(e.target.value), type: "password", placeholder: "Enter your password", autoComplete: "off" }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "
|
|
11680
|
+
}, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => setRecoveryPhrase(e.target.value), type: "password", placeholder: "Enter your password", autoComplete: "off" }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "Recover wallet" })] })] }));
|
|
11462
11681
|
};
|
|
11463
|
-
const
|
|
11464
|
-
const {
|
|
11682
|
+
const RecoverAutomaticWallet = ({ walletAddress }) => {
|
|
11683
|
+
const { embeddedState } = useOpenfortCore();
|
|
11465
11684
|
const { setActiveWallet } = useWallets();
|
|
11466
11685
|
const { log } = useOpenfort();
|
|
11467
|
-
const [
|
|
11686
|
+
const [error, setError] = useState(false);
|
|
11468
11687
|
useEffect(() => {
|
|
11469
11688
|
(async () => {
|
|
11470
|
-
if (
|
|
11471
|
-
log("
|
|
11689
|
+
if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
|
|
11690
|
+
log("Automatically recovering wallet", walletAddress);
|
|
11472
11691
|
const response = await setActiveWallet({
|
|
11473
11692
|
connector: embeddedWalletId,
|
|
11474
11693
|
});
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11694
|
+
if (response.error) {
|
|
11695
|
+
setError(response.error.message || "There was an error recovering your account");
|
|
11696
|
+
log("Error recovering wallet", response.error);
|
|
11478
11697
|
}
|
|
11479
11698
|
}
|
|
11480
11699
|
})();
|
|
11481
|
-
}, [
|
|
11482
|
-
if (
|
|
11483
|
-
|
|
11700
|
+
}, [embeddedState]);
|
|
11701
|
+
if (error) {
|
|
11702
|
+
jsx(PageContent, { children: jsx(ModalBody, { style: { textAlign: "center" }, "$error": true, children: jsx(FitText, { children: error }) }) });
|
|
11703
|
+
}
|
|
11704
|
+
return (jsx(PageContent, { children: jsx(Loader, { reason: `Recovering wallet...` }) }));
|
|
11705
|
+
};
|
|
11706
|
+
const CreateWalletAutomaticRecovery = () => {
|
|
11707
|
+
const { embeddedState } = useOpenfortCore();
|
|
11708
|
+
const { createWallet } = useWallets();
|
|
11709
|
+
const [shouldCreateWallet, setShouldCreateWallet] = useState(false);
|
|
11710
|
+
const { log } = useOpenfort();
|
|
11711
|
+
useEffect(() => {
|
|
11712
|
+
// To ensure the wallet is created only once
|
|
11713
|
+
if (shouldCreateWallet) {
|
|
11714
|
+
(async () => {
|
|
11715
|
+
log("Creating wallet Automatic recover");
|
|
11716
|
+
const response = await createWallet();
|
|
11717
|
+
if (response.error) {
|
|
11718
|
+
log("Error creating wallet", response.error);
|
|
11719
|
+
}
|
|
11720
|
+
})();
|
|
11721
|
+
}
|
|
11722
|
+
}, [shouldCreateWallet]);
|
|
11723
|
+
useEffect(() => {
|
|
11724
|
+
if (embeddedState === EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED) {
|
|
11725
|
+
setShouldCreateWallet(true);
|
|
11726
|
+
}
|
|
11727
|
+
}, [embeddedState]);
|
|
11728
|
+
return (jsx(PageContent, { children: jsx(Loader, { reason: "Creating wallet..." }) }));
|
|
11729
|
+
};
|
|
11730
|
+
const OtherMethod = ({ currentMethod, onChangeMethod }) => {
|
|
11731
|
+
const { uiConfig } = useOpenfort();
|
|
11732
|
+
const otherMethods = useMemo(() => {
|
|
11733
|
+
const allowedMethods = uiConfig.walletRecovery.allowedMethods;
|
|
11734
|
+
const otherMethods = allowedMethods.filter((method) => method !== currentMethod);
|
|
11735
|
+
return otherMethods;
|
|
11736
|
+
}, [uiConfig, currentMethod]);
|
|
11737
|
+
if (otherMethods.length === 0)
|
|
11738
|
+
return null;
|
|
11739
|
+
if (otherMethods.length === 1) {
|
|
11740
|
+
const method = otherMethods[0];
|
|
11741
|
+
let text;
|
|
11742
|
+
switch (method) {
|
|
11743
|
+
case RecoveryMethod.PASSWORD:
|
|
11744
|
+
text = "Use password recovery";
|
|
11745
|
+
break;
|
|
11746
|
+
case RecoveryMethod.AUTOMATIC:
|
|
11747
|
+
text = "Skip for now";
|
|
11748
|
+
break;
|
|
11749
|
+
default:
|
|
11750
|
+
text = method;
|
|
11751
|
+
}
|
|
11752
|
+
return (jsx(OtherMethodButton, { onClick: () => {
|
|
11753
|
+
onChangeMethod(method);
|
|
11754
|
+
}, children: text }));
|
|
11755
|
+
}
|
|
11756
|
+
return (jsx(OtherMethodButton, { onClick: () => onChangeMethod("other"), children: "Choose another recovery method" }));
|
|
11757
|
+
};
|
|
11758
|
+
const CreateWalletPasswordRecovery = ({ onChangeMethod }) => {
|
|
11759
|
+
const [recoveryPhrase, setRecoveryPhrase] = useState("");
|
|
11760
|
+
const [recoveryError, setRecoveryError] = useState(false);
|
|
11761
|
+
const { triggerResize, uiConfig: options, log } = useOpenfort();
|
|
11762
|
+
const [showPasswordIsTooWeakError, setShowPasswordIsTooWeakError] = useState(false);
|
|
11763
|
+
const [loading, setLoading] = useState(false);
|
|
11764
|
+
const { createWallet } = useWallets();
|
|
11765
|
+
const handleSubmit = async () => {
|
|
11766
|
+
if (getPasswordStrength(recoveryPhrase) < MEDIUM_SCORE_THRESHOLD) {
|
|
11767
|
+
setShowPasswordIsTooWeakError(true);
|
|
11768
|
+
return;
|
|
11769
|
+
}
|
|
11770
|
+
setLoading(true);
|
|
11771
|
+
const { error } = await createWallet({
|
|
11772
|
+
password: recoveryPhrase,
|
|
11773
|
+
});
|
|
11774
|
+
setLoading(false);
|
|
11775
|
+
if (error) {
|
|
11776
|
+
setRecoveryError(error.message || "There was an error recovering your account");
|
|
11777
|
+
}
|
|
11778
|
+
else {
|
|
11779
|
+
log("Recovery success");
|
|
11780
|
+
}
|
|
11781
|
+
};
|
|
11782
|
+
useEffect(() => {
|
|
11783
|
+
if (recoveryError)
|
|
11784
|
+
triggerResize();
|
|
11785
|
+
}, [recoveryError]);
|
|
11786
|
+
return (jsxs(PageContent, { children: [jsx(FloatingGraphic, { height: "80px", logoCenter: {
|
|
11787
|
+
logo: jsx(KeyIcon, {}),
|
|
11788
|
+
size: "1.2",
|
|
11789
|
+
}, logoTopLeft: {
|
|
11790
|
+
logo: jsx(ShieldIcon, {}),
|
|
11791
|
+
size: "0.75",
|
|
11792
|
+
}, logoBottomRight: {
|
|
11793
|
+
logo: jsx(LockIcon, {}),
|
|
11794
|
+
size: "0.5",
|
|
11795
|
+
} }), jsx(ModalHeading, { children: "Secure your wallet" }), jsxs(ModalBody, { style: { textAlign: "center" }, children: [jsx(FitText, { children: "Set a password for your wallet." }), jsxs("form", { onSubmit: (e) => {
|
|
11796
|
+
e.preventDefault();
|
|
11797
|
+
handleSubmit();
|
|
11798
|
+
}, children: [jsx(Input, { value: recoveryPhrase, onChange: (e) => {
|
|
11799
|
+
if (showPasswordIsTooWeakError)
|
|
11800
|
+
setShowPasswordIsTooWeakError(false);
|
|
11801
|
+
setRecoveryPhrase(e.target.value);
|
|
11802
|
+
}, type: "password", placeholder: "Enter your password", autoComplete: "off" }), jsx(PasswordStrengthIndicator, { password: recoveryPhrase, showPasswordIsTooWeakError: showPasswordIsTooWeakError }), jsx(TickList, { items: [
|
|
11803
|
+
"You will use this password to access your wallet",
|
|
11804
|
+
"Make sure it's strong and memorable",
|
|
11805
|
+
] }), recoveryError && (jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: jsx(ModalBody, { style: { height: 24, marginTop: 12 }, "$error": true, children: jsx(FitText, { children: recoveryError }) }) }, recoveryError)), jsx(Button, { onClick: handleSubmit, waiting: loading, disabled: loading, children: "Create wallet" })] }), jsx(OtherMethod, { currentMethod: RecoveryMethod.PASSWORD, onChangeMethod: onChangeMethod })] })] }));
|
|
11806
|
+
};
|
|
11807
|
+
const ChooseRecoveryMethod = ({ onChangeMethod }) => {
|
|
11808
|
+
return (jsxs(PageContent, { children: [jsx(ModalHeading, { children: "Choose a recovery method" }), jsx(Button, { onClick: () => onChangeMethod(RecoveryMethod.PASSWORD), children: "Password" }), jsx(Button, { onClick: () => onChangeMethod(RecoveryMethod.AUTOMATIC), children: "Automatic" }), jsx(Button, { onClick: () => { }, children: "Passkey (coming soon)" })] }));
|
|
11809
|
+
};
|
|
11810
|
+
const RecoverWallet = ({ wallet }) => {
|
|
11811
|
+
switch (wallet.recoveryMethod) {
|
|
11812
|
+
case RecoveryMethod.PASSWORD:
|
|
11813
|
+
return jsx(RecoverPasswordWallet, { wallet: wallet });
|
|
11814
|
+
case RecoveryMethod.AUTOMATIC:
|
|
11815
|
+
return jsx(RecoverAutomaticWallet, { walletAddress: wallet.address });
|
|
11816
|
+
default:
|
|
11817
|
+
console.error("Unsupported recovery method: " + wallet.recoveryMethod + ", defaulting to automatic.");
|
|
11818
|
+
return jsx(RecoverAutomaticWallet, { walletAddress: wallet.address });
|
|
11819
|
+
}
|
|
11820
|
+
};
|
|
11821
|
+
const CreateWallet = () => {
|
|
11822
|
+
const { uiConfig } = useOpenfort();
|
|
11823
|
+
const [userSelectedMethod, setUserSelectedMethod] = useState(null);
|
|
11824
|
+
if (userSelectedMethod) {
|
|
11825
|
+
switch (userSelectedMethod) {
|
|
11826
|
+
case RecoveryMethod.PASSWORD:
|
|
11827
|
+
return jsx(CreateWalletPasswordRecovery, { onChangeMethod: setUserSelectedMethod });
|
|
11828
|
+
case RecoveryMethod.AUTOMATIC:
|
|
11829
|
+
return jsx(CreateWalletAutomaticRecovery, {});
|
|
11830
|
+
case "other":
|
|
11831
|
+
return jsx(ChooseRecoveryMethod, { onChangeMethod: setUserSelectedMethod });
|
|
11832
|
+
default:
|
|
11833
|
+
throw new Error("Unsupported recovery method: " + userSelectedMethod);
|
|
11834
|
+
}
|
|
11835
|
+
}
|
|
11836
|
+
// Default recovery method configured
|
|
11837
|
+
switch (uiConfig.walletRecovery.defaultMethod) {
|
|
11838
|
+
case RecoveryMethod.PASSWORD:
|
|
11839
|
+
return jsx(CreateWalletPasswordRecovery, { onChangeMethod: setUserSelectedMethod });
|
|
11840
|
+
case RecoveryMethod.AUTOMATIC:
|
|
11841
|
+
return jsx(CreateWalletAutomaticRecovery, {});
|
|
11842
|
+
default:
|
|
11843
|
+
throw new Error("Unsupported recovery method: " + uiConfig.walletRecovery.defaultMethod);
|
|
11484
11844
|
}
|
|
11485
|
-
return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up signer" }) }));
|
|
11486
11845
|
};
|
|
11487
11846
|
const Connected = () => {
|
|
11488
11847
|
const { setOpen } = useOpenfort();
|
|
@@ -11494,49 +11853,81 @@ const Connected = () => {
|
|
|
11494
11853
|
}, []);
|
|
11495
11854
|
return (jsx(PageContent, { children: jsx(Loader, { isLoading: false, reason: "Connected" }) }));
|
|
11496
11855
|
};
|
|
11497
|
-
const
|
|
11856
|
+
const RecoverPage = () => {
|
|
11498
11857
|
const { needsRecovery, user } = useOpenfortCore();
|
|
11499
11858
|
const { triggerResize, uiConfig, walletConfig, setRoute } = useOpenfort();
|
|
11500
|
-
const
|
|
11501
|
-
const [
|
|
11859
|
+
const { wallets, isLoadingWallets } = useWallets();
|
|
11860
|
+
// const [loading, setLoading] = useState(true);
|
|
11861
|
+
const [embeddedSignerLoading, setEmbeddedSignerLoading] = useState(true);
|
|
11502
11862
|
const { isConnected } = useAccount();
|
|
11503
11863
|
useEffect(() => {
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
if (!user)
|
|
11511
|
-
return;
|
|
11512
|
-
if ((uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.linkWalletOnSignUp) || !walletConfig) {
|
|
11513
|
-
if (!user.linkedAccounts.find((account) => account.provider === "wallet")) {
|
|
11514
|
-
setRoute(routes.CONNECTORS);
|
|
11515
|
-
return;
|
|
11516
|
-
}
|
|
11517
|
-
if (!walletConfig) {
|
|
11518
|
-
// Logged in without a wallet
|
|
11519
|
-
setRoute(routes.PROFILE);
|
|
11520
|
-
return;
|
|
11521
|
-
}
|
|
11864
|
+
let timeout;
|
|
11865
|
+
if (!isLoadingWallets) {
|
|
11866
|
+
timeout = setTimeout(() => {
|
|
11867
|
+
setEmbeddedSignerLoading(false);
|
|
11868
|
+
triggerResize();
|
|
11869
|
+
}, 500);
|
|
11522
11870
|
}
|
|
11523
|
-
|
|
11524
|
-
}, [
|
|
11525
|
-
|
|
11526
|
-
return (
|
|
11871
|
+
return () => { clearTimeout(timeout); };
|
|
11872
|
+
}, [isLoadingWallets]);
|
|
11873
|
+
const openfortWallets = useMemo(() => {
|
|
11874
|
+
return wallets.filter((wallet) => wallet.id === embeddedWalletId);
|
|
11875
|
+
}, [wallets]);
|
|
11876
|
+
// useEffect(() => {
|
|
11877
|
+
// if (!user) return;
|
|
11878
|
+
// if (uiConfig?.linkWalletOnSignUp || !walletConfig) {
|
|
11879
|
+
// if (!user.linkedAccounts.find((account) => account.provider === "wallet")) {
|
|
11880
|
+
// setRoute(routes.CONNECTORS);
|
|
11881
|
+
// return;
|
|
11882
|
+
// }
|
|
11883
|
+
// if (!walletConfig) {
|
|
11884
|
+
// // Logged in without a wallet
|
|
11885
|
+
// setRoute(routes.PROFILE);
|
|
11886
|
+
// return;
|
|
11887
|
+
// }
|
|
11888
|
+
// }
|
|
11889
|
+
// setLoading(false);
|
|
11890
|
+
// }, [user])
|
|
11891
|
+
if (embeddedSignerLoading) {
|
|
11892
|
+
return (jsx(PageContent, { children: jsx(Loader, { reason: "Setting up wallet" }) }));
|
|
11527
11893
|
}
|
|
11528
11894
|
if (isConnected && user) {
|
|
11529
11895
|
return jsx(Connected, {});
|
|
11530
11896
|
}
|
|
11531
|
-
if (
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
return jsx(Recover, {});
|
|
11897
|
+
if (!openfortWallets) {
|
|
11898
|
+
// Here wallets should be loaded, so if we don't have them something went wrong
|
|
11899
|
+
// TODO: add error logs
|
|
11900
|
+
return (jsx(PageContent, { children: "An unexpected error occurred. Please try again later." }));
|
|
11536
11901
|
}
|
|
11537
|
-
|
|
11538
|
-
return (jsx(
|
|
11902
|
+
if (openfortWallets.length === 0) {
|
|
11903
|
+
return (jsx(CreateWallet, {}));
|
|
11539
11904
|
}
|
|
11905
|
+
// if (wallets.length === 1) {
|
|
11906
|
+
return (jsx(RecoverWallet, { wallet: openfortWallets[0] }));
|
|
11907
|
+
// }
|
|
11908
|
+
// return (
|
|
11909
|
+
// <PageContent>
|
|
11910
|
+
// <div style={{ flexDirection: "column", display: "flex", gap: 8 }}>
|
|
11911
|
+
// {wallets.map((wallet) => (
|
|
11912
|
+
// <div key={wallet.address}>
|
|
11913
|
+
// {wallet.address} - {wallet.recoveryMethod} recover
|
|
11914
|
+
// </div>
|
|
11915
|
+
// ))}
|
|
11916
|
+
// </div>
|
|
11917
|
+
// </PageContent>
|
|
11918
|
+
// )
|
|
11919
|
+
// if (walletConfig && walletConfig.recoveryMethod === RecoveryMethod.AUTOMATIC) {
|
|
11920
|
+
// return <AutomaticRecovery />
|
|
11921
|
+
// }
|
|
11922
|
+
// if (needsRecovery) {
|
|
11923
|
+
// return <Recover />
|
|
11924
|
+
// } else {
|
|
11925
|
+
// return (
|
|
11926
|
+
// <PageContent>
|
|
11927
|
+
// <Loader reason="Setting up signer" />
|
|
11928
|
+
// </PageContent>
|
|
11929
|
+
// )
|
|
11930
|
+
// }
|
|
11540
11931
|
};
|
|
11541
11932
|
|
|
11542
11933
|
const SocialProviders = () => {
|
|
@@ -11608,7 +11999,7 @@ const ConnectModal = ({ mode = 'auto', theme = 'auto', customTheme = customTheme
|
|
|
11608
11999
|
connect: jsx(ConnectUsing, {}),
|
|
11609
12000
|
profile: jsx(Profile, {}),
|
|
11610
12001
|
switchNetworks: jsx(SwitchNetworks, {}),
|
|
11611
|
-
recover: jsx(
|
|
12002
|
+
recover: jsx(RecoverPage, {}),
|
|
11612
12003
|
};
|
|
11613
12004
|
function hide() {
|
|
11614
12005
|
context.setOpen(false);
|
|
@@ -11705,8 +12096,9 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11705
12096
|
}
|
|
11706
12097
|
const chains = useChains();
|
|
11707
12098
|
const injectedConnector = useConnector('injected');
|
|
12099
|
+
const allowAutomaticRecovery = !!((walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.createEncryptedSessionEndpoint) || (walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.getEncryptionSession));
|
|
11708
12100
|
// Default config options
|
|
11709
|
-
const
|
|
12101
|
+
const defaultUIOptions = {
|
|
11710
12102
|
theme: 'auto',
|
|
11711
12103
|
mode: 'auto',
|
|
11712
12104
|
language: 'en-US',
|
|
@@ -11729,20 +12121,33 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11729
12121
|
ethereumOnboardingUrl: undefined,
|
|
11730
12122
|
walletOnboardingUrl: undefined,
|
|
11731
12123
|
disableSiweRedirect: false,
|
|
11732
|
-
|
|
11733
|
-
|
|
12124
|
+
walletRecovery: {
|
|
12125
|
+
allowedMethods: [
|
|
12126
|
+
RecoveryMethod.PASSWORD,
|
|
12127
|
+
...(allowAutomaticRecovery ? [RecoveryMethod.AUTOMATIC] : [])
|
|
12128
|
+
],
|
|
12129
|
+
defaultMethod: allowAutomaticRecovery ? RecoveryMethod.AUTOMATIC : RecoveryMethod.PASSWORD,
|
|
12130
|
+
},
|
|
12131
|
+
authProviders: [
|
|
12132
|
+
UIAuthProvider.GUEST,
|
|
12133
|
+
UIAuthProvider.EMAIL,
|
|
12134
|
+
UIAuthProvider.WALLET,
|
|
12135
|
+
],
|
|
11734
12136
|
};
|
|
11735
|
-
const
|
|
11736
|
-
if (!
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
12137
|
+
const safeUiConfig = Object.assign({}, defaultUIOptions, uiConfig);
|
|
12138
|
+
if (!safeUiConfig.walletRecovery.allowedMethods) {
|
|
12139
|
+
safeUiConfig.walletRecovery.allowedMethods = defaultUIOptions.walletRecovery.allowedMethods;
|
|
12140
|
+
}
|
|
12141
|
+
if (!safeUiConfig.walletRecovery.defaultMethod) {
|
|
12142
|
+
safeUiConfig.walletRecovery.defaultMethod = defaultUIOptions.walletRecovery.defaultMethod;
|
|
12143
|
+
}
|
|
12144
|
+
if (safeUiConfig.walletRecovery.allowedMethods.includes(RecoveryMethod.AUTOMATIC) && !allowAutomaticRecovery) {
|
|
12145
|
+
safeUiConfig.walletRecovery.allowedMethods = safeUiConfig.walletRecovery.allowedMethods.filter(m => m !== RecoveryMethod.AUTOMATIC);
|
|
12146
|
+
console.warn("Automatic recovery method was removed from allowedMethods because no recovery options are configured in the walletConfig. Please provide either createEncryptedSessionEndpoint or getEncryptionSession to enable automatic recovery.");
|
|
11742
12147
|
}
|
|
11743
12148
|
if (typeof window !== 'undefined') {
|
|
11744
12149
|
// Buffer Polyfill, needed for bundlers that don't provide Node polyfills (e.g CRA, Vite, etc.)
|
|
11745
|
-
if (
|
|
12150
|
+
if (safeUiConfig.bufferPolyfill)
|
|
11746
12151
|
window.Buffer = (_b = window.Buffer) !== null && _b !== void 0 ? _b : Buffer;
|
|
11747
12152
|
// Some bundlers may need `global` and `process.env` polyfills as well
|
|
11748
12153
|
// Not implemented here to avoid unexpected behaviors, but leaving example here for future reference
|
|
@@ -11751,8 +12156,8 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11751
12156
|
* window.process = window.process ?? { env: {} };
|
|
11752
12157
|
*/
|
|
11753
12158
|
}
|
|
11754
|
-
const [ckTheme, setTheme] = useState((_d = (_c = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _c !== void 0 ? _c :
|
|
11755
|
-
const [ckMode, setMode] = useState((_f = (_e = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _e !== void 0 ? _e :
|
|
12159
|
+
const [ckTheme, setTheme] = useState((_d = (_c = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _c !== void 0 ? _c : defaultUIOptions.theme) !== null && _d !== void 0 ? _d : "auto");
|
|
12160
|
+
const [ckMode, setMode] = useState((_f = (_e = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _e !== void 0 ? _e : defaultUIOptions.mode) !== null && _f !== void 0 ? _f : 'auto');
|
|
11756
12161
|
const [ckCustomTheme, setCustomTheme] = useState((_g = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.customTheme) !== null && _g !== void 0 ? _g : {});
|
|
11757
12162
|
const [ckLang, setLang] = useState('en-US');
|
|
11758
12163
|
const [open, setOpen] = useState(false);
|
|
@@ -11763,17 +12168,17 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11763
12168
|
const [errorMessage, setErrorMessage] = useState('');
|
|
11764
12169
|
const [resize, onResize] = useState(0);
|
|
11765
12170
|
// Include Google Font that is needed for a themes
|
|
11766
|
-
if (
|
|
12171
|
+
if (safeUiConfig.embedGoogleFonts)
|
|
11767
12172
|
useThemeFont(ckTheme);
|
|
11768
12173
|
// Other Configuration
|
|
11769
12174
|
useEffect(() => { var _a; return setTheme((_a = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme) !== null && _a !== void 0 ? _a : 'auto'); }, [uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.theme]);
|
|
11770
|
-
useEffect(() => setLang(
|
|
12175
|
+
useEffect(() => setLang(safeUiConfig.language || 'en-US'), [safeUiConfig.language]);
|
|
11771
12176
|
useEffect(() => setErrorMessage(null), [route, open]);
|
|
11772
12177
|
// Check if chain is supported, elsewise redirect to switches page
|
|
11773
12178
|
const { chain, isConnected } = useAccount();
|
|
11774
12179
|
const isChainSupported = useChainIsSupported(chain === null || chain === void 0 ? void 0 : chain.id);
|
|
11775
12180
|
useEffect(() => {
|
|
11776
|
-
if (isConnected &&
|
|
12181
|
+
if (isConnected && safeUiConfig.enforceSupportedChains && !isChainSupported) {
|
|
11777
12182
|
setOpen(true);
|
|
11778
12183
|
setRoute(routes.SWITCHNETWORKS);
|
|
11779
12184
|
}
|
|
@@ -11804,7 +12209,7 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11804
12209
|
onConnect,
|
|
11805
12210
|
onDisconnect,
|
|
11806
12211
|
// Other configuration
|
|
11807
|
-
uiConfig:
|
|
12212
|
+
uiConfig: safeUiConfig,
|
|
11808
12213
|
errorMessage,
|
|
11809
12214
|
debugMode,
|
|
11810
12215
|
log,
|
|
@@ -11826,7 +12231,6 @@ const OpenfortProvider = ({ children, uiConfig, onConnect, onDisconnect, debugMo
|
|
|
11826
12231
|
publishableKey,
|
|
11827
12232
|
}, shieldConfiguration: walletConfig ? {
|
|
11828
12233
|
shieldPublishableKey: walletConfig.shieldPublishableKey,
|
|
11829
|
-
shieldEncryptionKey: walletConfig.recoveryMethod === RecoveryMethod.PASSWORD ? walletConfig.shieldEncryptionKey : undefined,
|
|
11830
12234
|
debug: debugMode,
|
|
11831
12235
|
} : undefined, overrides: overrides, thirdPartyAuth: thirdPartyAuth, debugMode: debugMode, onConnect: onConnect, onDisconnect: onDisconnect, children: [children, jsx(ConnectModal, { lang: ckLang, theme: ckTheme, mode: (_h = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.mode) !== null && _h !== void 0 ? _h : ckMode, customTheme: ckCustomTheme })] }) }) }));
|
|
11832
12236
|
};
|
|
@@ -12248,7 +12652,7 @@ const ConnectedLabel = ({ separator }) => {
|
|
|
12248
12652
|
if (!user)
|
|
12249
12653
|
return "Loading user...";
|
|
12250
12654
|
if (!address)
|
|
12251
|
-
return
|
|
12655
|
+
return "Not connected";
|
|
12252
12656
|
return "Loading...";
|
|
12253
12657
|
};
|
|
12254
12658
|
function OpenfortButtonInner({ label, showAvatar, separator, }) {
|
|
@@ -12369,21 +12773,16 @@ const mapStatus = (status) => {
|
|
|
12369
12773
|
};
|
|
12370
12774
|
|
|
12371
12775
|
function useSignOut(hookOptions = {}) {
|
|
12372
|
-
const {
|
|
12776
|
+
const { logout } = useOpenfortCore();
|
|
12373
12777
|
const [status, setStatus] = useState({
|
|
12374
12778
|
status: "idle",
|
|
12375
12779
|
});
|
|
12376
|
-
const { disconnect } = useDisconnect();
|
|
12377
|
-
const queryClient = useQueryClient();
|
|
12378
12780
|
const signOut = useCallback(async (options = {}) => {
|
|
12379
12781
|
setStatus({
|
|
12380
12782
|
status: 'loading',
|
|
12381
12783
|
});
|
|
12382
12784
|
try {
|
|
12383
|
-
|
|
12384
|
-
queryClient.resetQueries({ queryKey: ['openfortEmbeddedWalletList'] });
|
|
12385
|
-
disconnect();
|
|
12386
|
-
updateUser();
|
|
12785
|
+
logout();
|
|
12387
12786
|
setStatus({
|
|
12388
12787
|
status: 'success',
|
|
12389
12788
|
});
|
|
@@ -12405,7 +12804,7 @@ function useSignOut(hookOptions = {}) {
|
|
|
12405
12804
|
error,
|
|
12406
12805
|
});
|
|
12407
12806
|
}
|
|
12408
|
-
}, [
|
|
12807
|
+
}, [logout, setStatus, hookOptions]);
|
|
12409
12808
|
return {
|
|
12410
12809
|
...mapStatus(status),
|
|
12411
12810
|
signOut,
|
|
@@ -12413,22 +12812,43 @@ function useSignOut(hookOptions = {}) {
|
|
|
12413
12812
|
}
|
|
12414
12813
|
|
|
12415
12814
|
// this hook is used to create a wallet after the user has authenticated
|
|
12416
|
-
const
|
|
12417
|
-
const { setActiveWallet } = useWallets();
|
|
12815
|
+
const useConnectToWalletPostAuth = () => {
|
|
12816
|
+
const { createWallet, setActiveWallet } = useWallets();
|
|
12418
12817
|
const { walletConfig } = useOpenfort();
|
|
12419
12818
|
const { signOut } = useSignOut();
|
|
12819
|
+
const queryClient = useQueryClient();
|
|
12420
12820
|
const tryUseWallet = useCallback(async ({ logoutOnError: signOutOnError = true, automaticRecovery = true }) => {
|
|
12421
|
-
|
|
12821
|
+
console.log("tryUseWallet", { walletConfig, automaticRecovery });
|
|
12822
|
+
if ((!(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.createEncryptedSessionEndpoint) && !(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.getEncryptionSession)) || !automaticRecovery) {
|
|
12823
|
+
// If there is no encryption session, we cannot create a wallet
|
|
12422
12824
|
return {};
|
|
12423
12825
|
}
|
|
12424
|
-
const
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
if (
|
|
12428
|
-
|
|
12429
|
-
|
|
12826
|
+
const wallets = await queryClient.ensureQueryData({ queryKey: ['openfortEmbeddedWalletList'] });
|
|
12827
|
+
console.log("WALLETS", wallets);
|
|
12828
|
+
let wallet;
|
|
12829
|
+
if (wallets.length === 0) {
|
|
12830
|
+
const createWalletResult = await createWallet();
|
|
12831
|
+
if (createWalletResult.error && signOutOnError) {
|
|
12832
|
+
console.error("Error creating wallet:", createWalletResult.error);
|
|
12833
|
+
// If there was an error and we should log out, we can call the logout function
|
|
12834
|
+
await signOut();
|
|
12835
|
+
return {};
|
|
12836
|
+
}
|
|
12837
|
+
wallet = createWalletResult.wallet;
|
|
12430
12838
|
}
|
|
12431
|
-
|
|
12839
|
+
// Has a wallet with automatic recovery
|
|
12840
|
+
if (wallets.some(w => w.recoveryMethod === RecoveryMethod.AUTOMATIC)) {
|
|
12841
|
+
const setWalletResult = await setActiveWallet({
|
|
12842
|
+
connector: embeddedWalletId,
|
|
12843
|
+
});
|
|
12844
|
+
if (!setWalletResult.wallet || (setWalletResult.error && signOutOnError)) {
|
|
12845
|
+
console.error("Error recovering wallet:", setWalletResult.error);
|
|
12846
|
+
// If there was an error and we should log out, we can call the logout function
|
|
12847
|
+
await signOut();
|
|
12848
|
+
}
|
|
12849
|
+
wallet = setWalletResult.wallet;
|
|
12850
|
+
}
|
|
12851
|
+
return { wallet };
|
|
12432
12852
|
}, [walletConfig, setActiveWallet, signOut]);
|
|
12433
12853
|
return {
|
|
12434
12854
|
tryUseWallet,
|
|
@@ -12448,7 +12868,7 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
12448
12868
|
});
|
|
12449
12869
|
setRequiresEmailVerification(false);
|
|
12450
12870
|
}, []);
|
|
12451
|
-
const { tryUseWallet } =
|
|
12871
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
12452
12872
|
const signInEmail = useCallback(async (options) => {
|
|
12453
12873
|
var _a;
|
|
12454
12874
|
try {
|
|
@@ -12755,21 +13175,12 @@ const useEmailAuth = (hookOptions = {}) => {
|
|
|
12755
13175
|
};
|
|
12756
13176
|
};
|
|
12757
13177
|
|
|
12758
|
-
({
|
|
12759
|
-
// [OAuthProvider.APPLE]: AuthProvider.,
|
|
12760
|
-
// [OAuthProvider.DISCORD]: AuthProvider.,
|
|
12761
|
-
// [OAuthProvider.EPIC_GAMES]: AuthProvider.,
|
|
12762
|
-
[AuthProvider.FACEBOOK]: OAuthProvider.FACEBOOK,
|
|
12763
|
-
[AuthProvider.GOOGLE]: OAuthProvider.GOOGLE,
|
|
12764
|
-
// [OAuthProvider.LINE]: AuthProvider.,
|
|
12765
|
-
[AuthProvider.TWITTER]: OAuthProvider.TWITTER,
|
|
12766
|
-
});
|
|
12767
13178
|
const useOAuth = (hookOptions = {}) => {
|
|
12768
13179
|
const { client, updateUser } = useOpenfortCore();
|
|
12769
13180
|
const [status, setStatus] = useState({
|
|
12770
13181
|
status: "idle",
|
|
12771
13182
|
});
|
|
12772
|
-
const { tryUseWallet } =
|
|
13183
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
12773
13184
|
const storeCredentials = useCallback(async ({ player, accessToken, refreshToken, ...options }) => {
|
|
12774
13185
|
setStatus({
|
|
12775
13186
|
status: 'loading',
|
|
@@ -13017,7 +13428,7 @@ const useGuestAuth = (hookOptions = {}) => {
|
|
|
13017
13428
|
const [status, setStatus] = useState({
|
|
13018
13429
|
status: "idle",
|
|
13019
13430
|
});
|
|
13020
|
-
const { tryUseWallet } =
|
|
13431
|
+
const { tryUseWallet } = useConnectToWalletPostAuth();
|
|
13021
13432
|
const signUpGuest = useCallback(async (options = {}) => {
|
|
13022
13433
|
try {
|
|
13023
13434
|
setStatus({
|
|
@@ -13240,5 +13651,5 @@ const useWalletAuth = (hookOptions = {}) => {
|
|
|
13240
13651
|
};
|
|
13241
13652
|
};
|
|
13242
13653
|
|
|
13243
|
-
export { AuthProvider, Avatar, Chain as ChainIcon, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortErrorType, OpenfortProvider, OpenfortStatus, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useSignOut, useStatus, useUI, useUser, useWallet, useWalletAuth, useWallets, wallets };
|
|
13654
|
+
export { UIAuthProvider as AuthProvider, Avatar, Chain as ChainIcon, OPENFORT_VERSION, OpenfortButton, OpenfortError, OpenfortErrorType, OpenfortProvider, OpenfortStatus, embeddedWalletId, defaultConfig as getDefaultConfig, defaultConnectors as getDefaultConnectors, useAuthCallback, useChainIsSupported, useChains, useConnectWithSiwe, useEmailAuth, useGuestAuth, useOAuth, useOpenfortCore as useOpenfort, useSignOut, useStatus, useUI, useUser, useWallet, useWalletAuth, useWallets, wallets };
|
|
13244
13655
|
//# sourceMappingURL=index.es.js.map
|