@dynamic-labs/sdk-react-core 0.19.0-alpha.4 → 0.19.0-alpha.5
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/CHANGELOG.md +7 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -14
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -14
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/helpers.cjs +5 -6
- package/src/lib/context/DynamicContext/helpers.d.ts +2 -2
- package/src/lib/context/DynamicContext/helpers.js +5 -6
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.cjs +2 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.js +2 -1
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -0
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +7 -5
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +7 -5
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +2 -2
- package/src/lib/views/AccountExistsView/AccountExistsView.js +2 -2
- package/src/lib/views/LoginView/LoginView.cjs +70 -0
- package/src/lib/views/LoginView/LoginView.d.ts +2 -0
- package/src/lib/views/LoginView/LoginView.js +66 -0
- package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs → LoginView/components/EmailSignIn/LoginEmailForm.cjs} +6 -11
- package/src/lib/views/LoginView/components/EmailSignIn/LoginEmailForm.d.ts +8 -0
- package/src/lib/views/{LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js → LoginView/components/EmailSignIn/LoginEmailForm.js} +6 -11
- package/src/lib/views/LoginView/components/EmailSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/LoginWidget.d.ts +5 -0
- package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.cjs +65 -0
- package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/ListItemButton.d.ts +2 -1
- package/src/lib/views/LoginView/components/WalletSignIn/ListItemButton/ListItemButton.js +61 -0
- package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.cjs → LoginView/components/WalletSignIn/WalletSignIn.cjs} +7 -19
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSignIn.d.ts +7 -0
- package/src/lib/views/{LoginWithEmailView/components/ListItemButton/ListItemButton.js → LoginView/components/WalletSignIn/WalletSignIn.js} +8 -20
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.cjs +47 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.d.ts +8 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/WalletSimpleSignIn.js +43 -0
- package/src/lib/views/LoginView/components/WalletSignIn/WalletSimpleSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/WalletSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/components/index.d.ts +3 -0
- package/src/lib/views/LoginView/index.d.ts +1 -0
- package/src/lib/views/LoginView/useLoginView.cjs +137 -0
- package/src/lib/views/LoginView/useLoginView.d.ts +6 -0
- package/src/lib/views/LoginView/useLoginView.js +132 -0
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.types.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +4 -3
- package/src/lib/views/viewToComponentMap.js +4 -3
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.cjs +0 -63
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.d.ts +0 -2
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.js +0 -59
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.d.ts +0 -7
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/index.d.ts +0 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +0 -36
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.d.ts +0 -9
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +0 -31
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/index.d.ts +0 -1
- package/src/lib/views/LoginWithEmailView/index.d.ts +0 -1
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.cjs +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.d.ts +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/SocialSignIn.js +0 -0
- /package/src/lib/views/{LoginWithEmailView → LoginView}/components/SocialSignIn/index.d.ts +0 -0
- /package/src/lib/views/{LoginWithEmailView/components → LoginView/components/WalletSignIn}/ListItemButton/index.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.4...v0.19.0-alpha.5) (2023-08-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* send wagmi settings only once when DynamicWagmiConnector loads ([#3103](https://github.com/dynamic-labs/DynamicAuth/issues/3103)) ([8bba505](https://github.com/dynamic-labs/DynamicAuth/commit/8bba505f84f6f3567743397a3f1274a3840a7700))
|
|
8
|
+
|
|
2
9
|
## [0.19.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.3...v0.19.0-alpha.4) (2023-08-23)
|
|
3
10
|
|
|
4
11
|
|
package/package.cjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = "0.19.0-alpha.
|
|
5
|
+
var version = "0.19.0-alpha.5";
|
|
6
6
|
var dependencies = {
|
|
7
7
|
"react-focus-lock": "2.9.2",
|
|
8
8
|
"@dynamic-labs/iconic": "0.1.27",
|
|
9
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
9
|
+
"@dynamic-labs/sdk-api": "0.0.267",
|
|
10
10
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
11
11
|
"country-list": "2.3.0",
|
|
12
12
|
yup: "0.32.11",
|
package/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var version = "0.19.0-alpha.
|
|
1
|
+
var version = "0.19.0-alpha.5";
|
|
2
2
|
var dependencies = {
|
|
3
3
|
"react-focus-lock": "2.9.2",
|
|
4
4
|
"@dynamic-labs/iconic": "0.1.27",
|
|
5
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
5
|
+
"@dynamic-labs/sdk-api": "0.0.267",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
7
7
|
"country-list": "2.3.0",
|
|
8
8
|
yup: "0.32.11",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react-focus-lock": "2.9.2",
|
|
11
11
|
"@dynamic-labs/iconic": "0.1.27",
|
|
12
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
12
|
+
"@dynamic-labs/sdk-api": "0.0.267",
|
|
13
13
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
14
14
|
"country-list": "2.3.0",
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
18
|
"ethers": "5.7.2",
|
|
19
|
-
"@dynamic-labs/logger": "0.19.0-alpha.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.19.0-alpha.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.19.0-alpha.
|
|
22
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
23
|
-
"@dynamic-labs/utils": "0.19.0-alpha.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.19.0-alpha.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.
|
|
19
|
+
"@dynamic-labs/logger": "0.19.0-alpha.5",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.19.0-alpha.5",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.5",
|
|
22
|
+
"@dynamic-labs/types": "0.19.0-alpha.5",
|
|
23
|
+
"@dynamic-labs/utils": "0.19.0-alpha.5",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.5",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.5",
|
|
26
26
|
"eventemitter3": "5.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -10,28 +10,16 @@ var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
|
10
10
|
var ConnectButton = require('./components/ConnectButton.cjs');
|
|
11
11
|
|
|
12
12
|
const DynamicConnectButton = ({ buttonContainerClassName = '', buttonClassName = '', children, }) => {
|
|
13
|
-
const { isProjectSettingsLoading, setShowAuthFlow, setSelectedWalletConnector,
|
|
13
|
+
const { isProjectSettingsLoading, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
14
14
|
const { setView } = ViewContext.useViewContext();
|
|
15
15
|
const [didUserClick, setUserClicked] = React.useState(false);
|
|
16
16
|
const handleOnClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
if (!didUserClick) {
|
|
18
18
|
setUserClicked(true);
|
|
19
19
|
}
|
|
20
|
-
if (loginWithEmail) {
|
|
21
|
-
setView('login-with-email-or-wallet');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
setView('wallet-list');
|
|
25
|
-
}
|
|
26
20
|
setSelectedWalletConnector(null);
|
|
27
21
|
setShowAuthFlow(true);
|
|
28
|
-
}), [
|
|
29
|
-
didUserClick,
|
|
30
|
-
loginWithEmail,
|
|
31
|
-
setSelectedWalletConnector,
|
|
32
|
-
setShowAuthFlow,
|
|
33
|
-
setView,
|
|
34
|
-
]);
|
|
22
|
+
}), [didUserClick, setSelectedWalletConnector, setShowAuthFlow, setView]);
|
|
35
23
|
return (jsxRuntime.jsx(ConnectButton.ConnectButton, Object.assign({ isLoading: isProjectSettingsLoading, isActive: didUserClick, onClick: handleOnClick, buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName }, { children: children })));
|
|
36
24
|
};
|
|
37
25
|
|
|
@@ -6,28 +6,16 @@ import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
|
6
6
|
import { ConnectButton } from './components/ConnectButton.js';
|
|
7
7
|
|
|
8
8
|
const DynamicConnectButton = ({ buttonContainerClassName = '', buttonClassName = '', children, }) => {
|
|
9
|
-
const { isProjectSettingsLoading, setShowAuthFlow, setSelectedWalletConnector,
|
|
9
|
+
const { isProjectSettingsLoading, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext();
|
|
10
10
|
const { setView } = useViewContext();
|
|
11
11
|
const [didUserClick, setUserClicked] = useState(false);
|
|
12
12
|
const handleOnClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
13
|
if (!didUserClick) {
|
|
14
14
|
setUserClicked(true);
|
|
15
15
|
}
|
|
16
|
-
if (loginWithEmail) {
|
|
17
|
-
setView('login-with-email-or-wallet');
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
setView('wallet-list');
|
|
21
|
-
}
|
|
22
16
|
setSelectedWalletConnector(null);
|
|
23
17
|
setShowAuthFlow(true);
|
|
24
|
-
}), [
|
|
25
|
-
didUserClick,
|
|
26
|
-
loginWithEmail,
|
|
27
|
-
setSelectedWalletConnector,
|
|
28
|
-
setShowAuthFlow,
|
|
29
|
-
setView,
|
|
30
|
-
]);
|
|
18
|
+
}), [didUserClick, setSelectedWalletConnector, setShowAuthFlow, setView]);
|
|
31
19
|
return (jsx(ConnectButton, Object.assign({ isLoading: isProjectSettingsLoading, isActive: didUserClick, onClick: handleOnClick, buttonContainerClassName: buttonContainerClassName, buttonClassName: buttonClassName }, { children: children })));
|
|
32
20
|
};
|
|
33
21
|
|
|
@@ -691,9 +691,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
691
691
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
692
692
|
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(walletBook.WalletBookContextProvider, Object.assign({ walletBook: walletBook$1 }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _h === void 0 ? void 0 : _h.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsxRuntime.jsx(LoadingContext.LoadingContextProvider, { children: jsxRuntime.jsx(ViewContext.ViewContextProvider, Object.assign({ initialView: helpers.getInitialView({
|
|
693
693
|
connectedWallets,
|
|
694
|
+
isAuthenticated,
|
|
694
695
|
isBridgeFlow,
|
|
695
696
|
isFullyConnected,
|
|
696
|
-
loginWithEmail,
|
|
697
697
|
}) }, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, Object.assign({ canSync: didConnectedStateLoad }, { children: jsxRuntime.jsx(QrCodeContext.QrCodeContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsxs(UserFieldEditorContext.UserFieldEditorContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(OAuthIFrameContainer.OAuthIFrameContainer, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) })) }) })) }) })) })) })));
|
|
698
698
|
};
|
|
699
699
|
|
|
@@ -687,9 +687,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
687
687
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
688
688
|
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(WalletBookContextProvider, Object.assign({ walletBook: walletBook }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _h === void 0 ? void 0 : _h.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsx(LoadingContextProvider, { children: jsx(ViewContextProvider, Object.assign({ initialView: getInitialView({
|
|
689
689
|
connectedWallets,
|
|
690
|
+
isAuthenticated,
|
|
690
691
|
isBridgeFlow,
|
|
691
692
|
isFullyConnected,
|
|
692
|
-
loginWithEmail,
|
|
693
693
|
}) }, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, Object.assign({ canSync: didConnectedStateLoad }, { children: jsx(QrCodeContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(ErrorContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(CaptchaContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsxs(UserFieldEditorContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(OAuthIFrameContainer, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) })) }) })) }) })) })) })));
|
|
694
694
|
};
|
|
695
695
|
|
|
@@ -54,17 +54,16 @@ const initExpirationTime = (logout) => {
|
|
|
54
54
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
55
55
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
56
56
|
};
|
|
57
|
-
const getInitialView = ({ connectedWallets,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (isFullyConnected) {
|
|
57
|
+
const getInitialView = ({ connectedWallets, isBridgeFlow, isFullyConnected, isAuthenticated, }) => {
|
|
58
|
+
// when multiwallet enabled, and user wants to link wallet
|
|
59
|
+
// show wallet-list view
|
|
60
|
+
if (isFullyConnected || isAuthenticated) {
|
|
62
61
|
return 'wallet-list';
|
|
63
62
|
}
|
|
64
63
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
65
64
|
return 'bridge-welcome';
|
|
66
65
|
}
|
|
67
|
-
return 'wallet
|
|
66
|
+
return 'login-with-email-or-wallet';
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
exports.getInitialView = getInitialView;
|
|
@@ -2,9 +2,9 @@ import { Wallet } from '../../shared';
|
|
|
2
2
|
import { ViewType } from '../ViewContext';
|
|
3
3
|
export declare const isAuthTokenExpired: (token: string) => boolean;
|
|
4
4
|
export declare const initExpirationTime: (logout: VoidFunction) => void;
|
|
5
|
-
export declare const getInitialView: ({ connectedWallets,
|
|
5
|
+
export declare const getInitialView: ({ connectedWallets, isBridgeFlow, isFullyConnected, isAuthenticated, }: {
|
|
6
6
|
connectedWallets: Wallet[];
|
|
7
|
-
loginWithEmail: boolean;
|
|
8
7
|
isBridgeFlow: boolean;
|
|
8
|
+
isAuthenticated: boolean;
|
|
9
9
|
isFullyConnected: boolean;
|
|
10
10
|
}) => ViewType;
|
|
@@ -50,17 +50,16 @@ const initExpirationTime = (logout) => {
|
|
|
50
50
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
51
51
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
52
52
|
};
|
|
53
|
-
const getInitialView = ({ connectedWallets,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (isFullyConnected) {
|
|
53
|
+
const getInitialView = ({ connectedWallets, isBridgeFlow, isFullyConnected, isAuthenticated, }) => {
|
|
54
|
+
// when multiwallet enabled, and user wants to link wallet
|
|
55
|
+
// show wallet-list view
|
|
56
|
+
if (isFullyConnected || isAuthenticated) {
|
|
58
57
|
return 'wallet-list';
|
|
59
58
|
}
|
|
60
59
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
61
60
|
return 'bridge-welcome';
|
|
62
61
|
}
|
|
63
|
-
return 'wallet
|
|
62
|
+
return 'login-with-email-or-wallet';
|
|
64
63
|
};
|
|
65
64
|
|
|
66
65
|
export { getInitialView, initExpirationTime, isAuthTokenExpired };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SetStateAction, Dispatch, PropsWithChildren, FC } from 'react';
|
|
2
|
-
export type ViewType = 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-with-email' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-email-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'update-email' | 'verify-email' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts' | 'wallet-cannot-be-transferred';
|
|
2
|
+
export type ViewType = 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-with-email' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-wallet-only' | 'login-with-email-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'update-email' | 'verify-email' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts' | 'wallet-cannot-be-transferred';
|
|
3
3
|
export type ViewContextProps = {
|
|
4
4
|
setView: Dispatch<SetStateAction<ViewType>>;
|
|
5
5
|
view: ViewType;
|
|
@@ -17,7 +17,8 @@ const HelpContentSwitch = () => {
|
|
|
17
17
|
const { projectSettings, newToWeb3WalletChainMap, selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
18
18
|
const isWalletListTypeView = React.useMemo(() => view === 'wallet-connect-mobile-wallets-list' ||
|
|
19
19
|
view === 'wallet-list' ||
|
|
20
|
-
view === 'login-with-email-or-wallet-full-wallet-list'
|
|
20
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
21
|
+
view === 'login-with-wallet-only', [view]);
|
|
21
22
|
const isPendingSignatureTypeView = React.useMemo(() => view === 'pending-signature-without-back-button' ||
|
|
22
23
|
view === 'pending-signature', [view]);
|
|
23
24
|
const isPendingConnectTypeView = React.useMemo(() => view === 'pending-connect' || view === 'qr-code', [view]);
|
|
@@ -13,7 +13,8 @@ const HelpContentSwitch = () => {
|
|
|
13
13
|
const { projectSettings, newToWeb3WalletChainMap, selectedWalletConnector } = useInternalDynamicContext();
|
|
14
14
|
const isWalletListTypeView = useMemo(() => view === 'wallet-connect-mobile-wallets-list' ||
|
|
15
15
|
view === 'wallet-list' ||
|
|
16
|
-
view === 'login-with-email-or-wallet-full-wallet-list'
|
|
16
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
17
|
+
view === 'login-with-wallet-only', [view]);
|
|
17
18
|
const isPendingSignatureTypeView = useMemo(() => view === 'pending-signature-without-back-button' ||
|
|
18
19
|
view === 'pending-signature', [view]);
|
|
19
20
|
const isPendingConnectTypeView = useMemo(() => view === 'pending-connect' || view === 'qr-code', [view]);
|
|
@@ -16,6 +16,9 @@ const getDynamicLayoutData = ({ view }) => {
|
|
|
16
16
|
'login-with-email-or-wallet-full-wallet-list': {
|
|
17
17
|
heading: 'Get your first wallet',
|
|
18
18
|
},
|
|
19
|
+
'login-with-wallet-only': {
|
|
20
|
+
heading: 'Get your first wallet',
|
|
21
|
+
},
|
|
19
22
|
'pending-connect': {
|
|
20
23
|
heading: 'Connecting a wallet',
|
|
21
24
|
},
|
|
@@ -44,6 +47,9 @@ const getDynamicLayoutData = ({ view }) => {
|
|
|
44
47
|
'login-with-email-or-wallet-full-wallet-list': {
|
|
45
48
|
heading: 'Select your wallet',
|
|
46
49
|
},
|
|
50
|
+
'login-with-wallet-only': {
|
|
51
|
+
heading: 'Select your wallet',
|
|
52
|
+
},
|
|
47
53
|
'wallet-connect-mobile-wallets-list': {
|
|
48
54
|
heading: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(iconic.WalletConnectIcon, { style: { height: '1.5rem', width: '1.5rem' } }), ' ', "WalletConnect wallets"] })),
|
|
49
55
|
},
|
|
@@ -12,6 +12,9 @@ const getDynamicLayoutData = ({ view }) => {
|
|
|
12
12
|
'login-with-email-or-wallet-full-wallet-list': {
|
|
13
13
|
heading: 'Get your first wallet',
|
|
14
14
|
},
|
|
15
|
+
'login-with-wallet-only': {
|
|
16
|
+
heading: 'Get your first wallet',
|
|
17
|
+
},
|
|
15
18
|
'pending-connect': {
|
|
16
19
|
heading: 'Connecting a wallet',
|
|
17
20
|
},
|
|
@@ -40,6 +43,9 @@ const getDynamicLayoutData = ({ view }) => {
|
|
|
40
43
|
'login-with-email-or-wallet-full-wallet-list': {
|
|
41
44
|
heading: 'Select your wallet',
|
|
42
45
|
},
|
|
46
|
+
'login-with-wallet-only': {
|
|
47
|
+
heading: 'Select your wallet',
|
|
48
|
+
},
|
|
43
49
|
'wallet-connect-mobile-wallets-list': {
|
|
44
50
|
heading: (jsxs(Fragment, { children: [jsx(WalletConnectIcon, { style: { height: '1.5rem', width: '1.5rem' } }), ' ', "WalletConnect wallets"] })),
|
|
45
51
|
},
|
|
@@ -17,7 +17,8 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
17
17
|
const { helpHeaderData } = getDynamicLayoutData.getDynamicLayoutData({ view });
|
|
18
18
|
const isWalletListTypeView = view === 'wallet-connect-mobile-wallets-list' ||
|
|
19
19
|
view === 'wallet-list' ||
|
|
20
|
-
view === 'login-with-email-or-wallet-full-wallet-list'
|
|
20
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
21
|
+
view === 'login-with-wallet-only';
|
|
21
22
|
const showHelpContent = Boolean(helpHeaderData &&
|
|
22
23
|
// Notice the negation here
|
|
23
24
|
!((view === 'qr-code' && !(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.canConnectViaQrCode)) ||
|
|
@@ -51,13 +52,14 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
51
52
|
const showToSFooter = Boolean(!isUserLinkingWallet.isUserLinkingWallet(user, view, mockedSDK) &&
|
|
52
53
|
(view === 'wallet-list' ||
|
|
53
54
|
view === 'wallet-connect-mobile-wallets-list' ||
|
|
54
|
-
// Don't show empty footer
|
|
55
|
-
(view === 'login-with-email-or-wallet'
|
|
55
|
+
// Don't show empty footer during the login
|
|
56
|
+
((view === 'login-with-email-or-wallet' ||
|
|
57
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
58
|
+
view === 'login-with-wallet-only') &&
|
|
56
59
|
(termsOfServiceUrl ||
|
|
57
60
|
privacyPolicyUrl ||
|
|
58
61
|
customPrivacyPolicy ||
|
|
59
|
-
customTermsOfServices))
|
|
60
|
-
view === 'login-with-email-or-wallet-full-wallet-list'));
|
|
62
|
+
customTermsOfServices))));
|
|
61
63
|
const showCloseButton = view !== 'login-with-email-or-wallet-full-wallet-list' &&
|
|
62
64
|
view !== 'login-with-email-verification';
|
|
63
65
|
const showBackButton = view === 'qr-code' ||
|
|
@@ -13,7 +13,8 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
13
13
|
const { helpHeaderData } = getDynamicLayoutData({ view });
|
|
14
14
|
const isWalletListTypeView = view === 'wallet-connect-mobile-wallets-list' ||
|
|
15
15
|
view === 'wallet-list' ||
|
|
16
|
-
view === 'login-with-email-or-wallet-full-wallet-list'
|
|
16
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
17
|
+
view === 'login-with-wallet-only';
|
|
17
18
|
const showHelpContent = Boolean(helpHeaderData &&
|
|
18
19
|
// Notice the negation here
|
|
19
20
|
!((view === 'qr-code' && !(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.canConnectViaQrCode)) ||
|
|
@@ -47,13 +48,14 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
47
48
|
const showToSFooter = Boolean(!isUserLinkingWallet(user, view, mockedSDK) &&
|
|
48
49
|
(view === 'wallet-list' ||
|
|
49
50
|
view === 'wallet-connect-mobile-wallets-list' ||
|
|
50
|
-
// Don't show empty footer
|
|
51
|
-
(view === 'login-with-email-or-wallet'
|
|
51
|
+
// Don't show empty footer during the login
|
|
52
|
+
((view === 'login-with-email-or-wallet' ||
|
|
53
|
+
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
54
|
+
view === 'login-with-wallet-only') &&
|
|
52
55
|
(termsOfServiceUrl ||
|
|
53
56
|
privacyPolicyUrl ||
|
|
54
57
|
customPrivacyPolicy ||
|
|
55
|
-
customTermsOfServices))
|
|
56
|
-
view === 'login-with-email-or-wallet-full-wallet-list'));
|
|
58
|
+
customTermsOfServices))));
|
|
57
59
|
const showCloseButton = view !== 'login-with-email-or-wallet-full-wallet-list' &&
|
|
58
60
|
view !== 'login-with-email-verification';
|
|
59
61
|
const showBackButton = view === 'qr-code' ||
|
|
@@ -53,7 +53,7 @@ require('../../components/InlineWidget/InlineWidget.cjs');
|
|
|
53
53
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
54
54
|
var capitalize = require('../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
55
55
|
var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
56
|
-
var
|
|
56
|
+
var LoginEmailForm = require('../LoginView/components/EmailSignIn/LoginEmailForm.cjs');
|
|
57
57
|
|
|
58
58
|
const AccountExistsView = () => {
|
|
59
59
|
const { existentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
@@ -71,7 +71,7 @@ const AccountExistsView = () => {
|
|
|
71
71
|
: '. Please log in with your email.';
|
|
72
72
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["It looks like an account already exists using ", jsxRuntime.jsx("strong", { children: email }), '', messageTrail] }));
|
|
73
73
|
};
|
|
74
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize.capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsxRuntime.jsx(
|
|
74
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize.capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { isLoading: false, currentEmail: email }))] }))] })));
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
exports.AccountExistsView = AccountExistsView;
|
|
@@ -49,7 +49,7 @@ import '../../components/InlineWidget/InlineWidget.js';
|
|
|
49
49
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
50
|
import { capitalize } from '../../shared/utils/functions/capitalize/capitalize.js';
|
|
51
51
|
import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
52
|
-
import {
|
|
52
|
+
import { LoginEmailForm } from '../LoginView/components/EmailSignIn/LoginEmailForm.js';
|
|
53
53
|
|
|
54
54
|
const AccountExistsView = () => {
|
|
55
55
|
const { existentAccountData } = useAccountExistsContext();
|
|
@@ -67,7 +67,7 @@ const AccountExistsView = () => {
|
|
|
67
67
|
: '. Please log in with your email.';
|
|
68
68
|
return (jsxs(Fragment, { children: ["It looks like an account already exists using ", jsx("strong", { children: email }), '', messageTrail] }));
|
|
69
69
|
};
|
|
70
|
-
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsx(
|
|
70
|
+
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsx(LoginEmailForm, { isLoading: false, currentEmail: email }))] }))] })));
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
export { AccountExistsView };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var Divider = require('../../components/Divider/Divider.cjs');
|
|
8
|
+
var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
|
|
9
|
+
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
10
|
+
var LoadingContext = require('../../context/LoadingContext/LoadingContext.cjs');
|
|
11
|
+
var useAuthLayoutChecks = require('../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs');
|
|
12
|
+
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
13
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
var WalletList = require('../WalletList/WalletList.cjs');
|
|
15
|
+
var SocialSignIn = require('./components/SocialSignIn/SocialSignIn.cjs');
|
|
16
|
+
var WalletSignIn = require('./components/WalletSignIn/WalletSignIn.cjs');
|
|
17
|
+
var LoginEmailForm = require('./components/EmailSignIn/LoginEmailForm.cjs');
|
|
18
|
+
var useLoginView = require('./useLoginView.cjs');
|
|
19
|
+
|
|
20
|
+
const LoginView = () => {
|
|
21
|
+
const { error } = ErrorContext.useErrorContext();
|
|
22
|
+
const { loading } = LoadingContext.useLoadingContext();
|
|
23
|
+
const { showToSFooter } = useAuthLayoutChecks.useAuthLayoutChecks();
|
|
24
|
+
const { view, setView } = ViewContext.useViewContext();
|
|
25
|
+
const { isWalletOnly, logingViewSections } = useLoginView.useLoginView();
|
|
26
|
+
const [showWalletList, setShowWalletList] = React.useState(isWalletOnly);
|
|
27
|
+
const [isLoading, setIsLoading] = React.useState(loading);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
// toolkit log in with email was set to false
|
|
30
|
+
if (isWalletOnly) {
|
|
31
|
+
setView('login-with-wallet-only');
|
|
32
|
+
setShowWalletList(true);
|
|
33
|
+
}
|
|
34
|
+
// returning from 'View all wallets' button
|
|
35
|
+
if (!isWalletOnly && view === 'login-with-email-or-wallet') {
|
|
36
|
+
setShowWalletList(false);
|
|
37
|
+
}
|
|
38
|
+
// toolkit log in with email was set back to true
|
|
39
|
+
if (!isWalletOnly &&
|
|
40
|
+
(!showWalletList || view === 'login-with-wallet-only')) {
|
|
41
|
+
setView('login-with-email-or-wallet');
|
|
42
|
+
setShowWalletList(false);
|
|
43
|
+
}
|
|
44
|
+
}, [isWalletOnly, view]);
|
|
45
|
+
const renderViewSections = React.useMemo(() => logingViewSections.map((viewSection, index) => {
|
|
46
|
+
switch (viewSection.type) {
|
|
47
|
+
case 'separator':
|
|
48
|
+
return (jsxRuntime.jsx(Divider.Divider, { text: viewSection.label }, `${viewSection.type}_${index}`));
|
|
49
|
+
case 'email':
|
|
50
|
+
return (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
51
|
+
case 'wallet':
|
|
52
|
+
return (jsxRuntime.jsx(WalletSignIn.WalletSignIn, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
53
|
+
setView('login-with-email-or-wallet-full-wallet-list'); // this view is just to show the back button
|
|
54
|
+
setShowWalletList(true);
|
|
55
|
+
}, isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
56
|
+
case 'social':
|
|
57
|
+
return jsxRuntime.jsx(SocialSignIn.SocialSignIn, {}, `${viewSection.type}_${index}`);
|
|
58
|
+
default:
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}), [logingViewSections, isLoading, setView]);
|
|
62
|
+
if (showWalletList) {
|
|
63
|
+
return jsxRuntime.jsx(WalletList.WalletList, {});
|
|
64
|
+
}
|
|
65
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), jsxRuntime.jsx("div", Object.assign({ className: classNames.classNames('login-with-email__scroll', {
|
|
66
|
+
'login-with-email__scroll--with-footer': showToSFooter,
|
|
67
|
+
}), "data-testid": 'login-with-email-scroll' }, { children: renderViewSections }))] })));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.LoginView = LoginView;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { Divider } from '../../components/Divider/Divider.js';
|
|
4
|
+
import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
|
|
5
|
+
import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
|
|
6
|
+
import { useLoadingContext } from '../../context/LoadingContext/LoadingContext.js';
|
|
7
|
+
import { useAuthLayoutChecks } from '../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js';
|
|
8
|
+
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
9
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import { WalletList } from '../WalletList/WalletList.js';
|
|
11
|
+
import { SocialSignIn } from './components/SocialSignIn/SocialSignIn.js';
|
|
12
|
+
import { WalletSignIn } from './components/WalletSignIn/WalletSignIn.js';
|
|
13
|
+
import { LoginEmailForm } from './components/EmailSignIn/LoginEmailForm.js';
|
|
14
|
+
import { useLoginView } from './useLoginView.js';
|
|
15
|
+
|
|
16
|
+
const LoginView = () => {
|
|
17
|
+
const { error } = useErrorContext();
|
|
18
|
+
const { loading } = useLoadingContext();
|
|
19
|
+
const { showToSFooter } = useAuthLayoutChecks();
|
|
20
|
+
const { view, setView } = useViewContext();
|
|
21
|
+
const { isWalletOnly, logingViewSections } = useLoginView();
|
|
22
|
+
const [showWalletList, setShowWalletList] = useState(isWalletOnly);
|
|
23
|
+
const [isLoading, setIsLoading] = useState(loading);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
// toolkit log in with email was set to false
|
|
26
|
+
if (isWalletOnly) {
|
|
27
|
+
setView('login-with-wallet-only');
|
|
28
|
+
setShowWalletList(true);
|
|
29
|
+
}
|
|
30
|
+
// returning from 'View all wallets' button
|
|
31
|
+
if (!isWalletOnly && view === 'login-with-email-or-wallet') {
|
|
32
|
+
setShowWalletList(false);
|
|
33
|
+
}
|
|
34
|
+
// toolkit log in with email was set back to true
|
|
35
|
+
if (!isWalletOnly &&
|
|
36
|
+
(!showWalletList || view === 'login-with-wallet-only')) {
|
|
37
|
+
setView('login-with-email-or-wallet');
|
|
38
|
+
setShowWalletList(false);
|
|
39
|
+
}
|
|
40
|
+
}, [isWalletOnly, view]);
|
|
41
|
+
const renderViewSections = useMemo(() => logingViewSections.map((viewSection, index) => {
|
|
42
|
+
switch (viewSection.type) {
|
|
43
|
+
case 'separator':
|
|
44
|
+
return (jsx(Divider, { text: viewSection.label }, `${viewSection.type}_${index}`));
|
|
45
|
+
case 'email':
|
|
46
|
+
return (jsx(LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
47
|
+
case 'wallet':
|
|
48
|
+
return (jsx(WalletSignIn, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
49
|
+
setView('login-with-email-or-wallet-full-wallet-list'); // this view is just to show the back button
|
|
50
|
+
setShowWalletList(true);
|
|
51
|
+
}, isLoading: isLoading }, `${viewSection.type}_${index}`));
|
|
52
|
+
case 'social':
|
|
53
|
+
return jsx(SocialSignIn, {}, `${viewSection.type}_${index}`);
|
|
54
|
+
default:
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}), [logingViewSections, isLoading, setView]);
|
|
58
|
+
if (showWalletList) {
|
|
59
|
+
return jsx(WalletList, {});
|
|
60
|
+
}
|
|
61
|
+
return (jsxs("div", Object.assign({ className: 'login-with-email__container' }, { children: [error && jsx(ErrorContainer, { children: error }), jsx("div", Object.assign({ className: classNames('login-with-email__scroll', {
|
|
62
|
+
'login-with-email__scroll--with-footer': showToSFooter,
|
|
63
|
+
}), "data-testid": 'login-with-email-scroll' }, { children: renderViewSections }))] })));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { LoginView };
|
|
@@ -48,14 +48,12 @@ require('../../../../components/Popper/Popper/Popper.cjs');
|
|
|
48
48
|
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
49
49
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
50
50
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
51
|
-
var LoadingContext = require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
52
51
|
var useEmailProvider = require('../../../../utils/hooks/useEmailProvider/useEmailProvider.cjs');
|
|
53
52
|
|
|
54
53
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
55
|
-
const
|
|
54
|
+
const LoginEmailForm = ({ isLoading: isExternalLoading, onSubmit, onSubmitError, currentEmail, }) => {
|
|
56
55
|
var _a;
|
|
57
56
|
const { environmentId, wallets, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
-
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
59
57
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
60
58
|
const [emailInput, setEmailInput] = React.useState(currentEmail !== null && currentEmail !== void 0 ? currentEmail : '');
|
|
61
59
|
const [emailError, setEmailError] = React.useState(false);
|
|
@@ -65,13 +63,12 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
65
63
|
const { handleEmailOnlyLoginSubmit, submitEmail, isEmailProviderLoading } = useEmailProvider.useEmailProvider({
|
|
66
64
|
emailWalletConnector,
|
|
67
65
|
});
|
|
68
|
-
const isLoading = React.useMemo(() => isEmailProviderLoading ||
|
|
66
|
+
const isLoading = React.useMemo(() => isEmailProviderLoading || isExternalLoading, [isEmailProviderLoading, isExternalLoading]);
|
|
69
67
|
const handleEmailOnChangeEvent = (event) => {
|
|
70
68
|
const { value } = event.currentTarget;
|
|
71
69
|
setEmailInput(value);
|
|
72
70
|
};
|
|
73
71
|
const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
|
|
74
|
-
const onChangeHandler = handleEmailOnChangeEvent;
|
|
75
72
|
const emailInputSuffixIcon = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ "data-testid": 'email_submit_button', type: 'submit', className: `icon-button${((_a = emailInput === null || emailInput === void 0 ? void 0 : emailInput.trim()) === null || _a === void 0 ? void 0 : _a.length) ? '--visible' : ''}`, disabled: isLoading }, { children: jsxRuntime.jsx(arrowRight.ReactComponent, {}) })));
|
|
76
73
|
const handleSubmit = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
74
|
e.preventDefault();
|
|
@@ -80,7 +77,7 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
try {
|
|
83
|
-
|
|
80
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
|
|
84
81
|
if (isInjectedWalletProviderEnabled &&
|
|
85
82
|
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
|
|
86
83
|
// see: https://linear.app/dynamic-labs/issue/DYN-2517
|
|
@@ -103,14 +100,12 @@ const LoginWithEmailForm = ({ currentEmail }) => {
|
|
|
103
100
|
catch (error) {
|
|
104
101
|
logger.logger.debug(error);
|
|
105
102
|
setErrorMessage(error.code);
|
|
106
|
-
|
|
107
|
-
finally {
|
|
108
|
-
setLoading(false);
|
|
103
|
+
onSubmitError === null || onSubmitError === void 0 ? void 0 : onSubmitError();
|
|
109
104
|
}
|
|
110
105
|
});
|
|
111
106
|
// social sign in currently coupled to email... might be better to decouple
|
|
112
|
-
return (jsxRuntime.jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange:
|
|
107
|
+
return (jsxRuntime.jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange: handleEmailOnChangeEvent, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon, disabled: isLoading }) })));
|
|
113
108
|
};
|
|
114
109
|
|
|
115
110
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
116
|
-
exports.
|
|
111
|
+
exports.LoginEmailForm = LoginEmailForm;
|