@web3auth/modal 10.0.5 → 10.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +3 -25
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +52 -31
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +19 -8
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +5 -25
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +9 -13
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +18 -2
- package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +6 -1
- package/dist/lib.cjs/types/ui/components/Root/Root.type.d.ts +6 -1
- package/dist/lib.cjs/types/ui/components/Widget/Widget.type.d.ts +7 -2
- package/dist/lib.cjs/types/ui/loginModal.d.ts +6 -1
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +3 -27
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +54 -32
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +21 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +5 -25
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +9 -14
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +19 -3
- package/dist/modal.umd.min.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BUILD_ENV_TYPE, WEB3AUTH_NETWORK_TYPE } from "@web3auth/auth";
|
|
2
|
-
import type { ButtonRadiusType, ExternalButton, ExternalWalletEventType, LogoAlignmentType, SocialLoginEventType, SocialLoginsConfig } from "../../interfaces";
|
|
2
|
+
import type { browser, ButtonRadiusType, ExternalButton, ExternalWalletEventType, LogoAlignmentType, os, platform, SocialLoginEventType, SocialLoginsConfig } from "../../interfaces";
|
|
3
3
|
export interface LoginProps {
|
|
4
4
|
web3authClientId: string;
|
|
5
5
|
web3authNetwork: WEB3AUTH_NETWORK_TYPE;
|
|
@@ -22,6 +22,11 @@ export interface LoginProps {
|
|
|
22
22
|
totalExternalWallets: number;
|
|
23
23
|
logoAlignment?: LogoAlignmentType;
|
|
24
24
|
buttonRadius?: ButtonRadiusType;
|
|
25
|
+
deviceDetails: {
|
|
26
|
+
platform: platform;
|
|
27
|
+
browser: browser;
|
|
28
|
+
os: os;
|
|
29
|
+
};
|
|
25
30
|
handleExternalWalletBtnClick?: (flag: boolean) => void;
|
|
26
31
|
handleSocialLoginClick: (params: SocialLoginEventType) => void;
|
|
27
32
|
handleExternalWalletClick: (params: ExternalWalletEventType) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChainNamespaceType, WalletRegistry } from "@web3auth/no-modal";
|
|
2
|
-
import { ModalState, SocialLoginEventType, SocialLoginsConfig, UIConfig } from "../../interfaces";
|
|
2
|
+
import { browser, ModalState, os, platform, SocialLoginEventType, SocialLoginsConfig, UIConfig } from "../../interfaces";
|
|
3
3
|
export interface RootProps {
|
|
4
4
|
appLogo?: string;
|
|
5
5
|
appName?: string;
|
|
@@ -16,6 +16,11 @@ export interface RootProps {
|
|
|
16
16
|
isEmailPasswordLessLoginVisible: boolean;
|
|
17
17
|
isSmsPasswordLessLoginVisible: boolean;
|
|
18
18
|
uiConfig: UIConfig;
|
|
19
|
+
deviceDetails: {
|
|
20
|
+
platform: platform;
|
|
21
|
+
browser: browser;
|
|
22
|
+
os: os;
|
|
23
|
+
};
|
|
19
24
|
handleSocialLoginClick: (params: SocialLoginEventType) => void;
|
|
20
25
|
handleExternalWalletBtnClick?: (flag: boolean) => void;
|
|
21
26
|
preHandleExternalWalletClick: (params: {
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { SafeEventEmitter } from "@web3auth/auth";
|
|
2
2
|
import { ChainNamespaceType, WalletRegistry } from "@web3auth/no-modal";
|
|
3
|
-
import { ExternalWalletEventType, SocialLoginEventType, StateEmitterEvents, UIConfig } from "../../interfaces";
|
|
3
|
+
import { browser, ExternalWalletEventType, os, platform, SocialLoginEventType, StateEmitterEvents, UIConfig } from "../../interfaces";
|
|
4
4
|
export interface WidgetProps {
|
|
5
5
|
stateListener: SafeEventEmitter<StateEmitterEvents>;
|
|
6
6
|
appLogo?: string;
|
|
7
7
|
appName?: string;
|
|
8
8
|
chainNamespaces: ChainNamespaceType[];
|
|
9
9
|
walletRegistry?: WalletRegistry;
|
|
10
|
+
uiConfig: UIConfig;
|
|
11
|
+
deviceDetails: {
|
|
12
|
+
platform: platform;
|
|
13
|
+
browser: browser;
|
|
14
|
+
os: os;
|
|
15
|
+
};
|
|
10
16
|
handleSocialLoginClick: (params: SocialLoginEventType) => void;
|
|
11
17
|
handleExternalWalletClick: (params: ExternalWalletEventType) => void;
|
|
12
18
|
handleShowExternalWallets: (externalWalletsInitialized: boolean) => void;
|
|
13
19
|
closeModal: () => void;
|
|
14
|
-
uiConfig: UIConfig;
|
|
15
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./css/index.css";
|
|
2
2
|
import { type BaseConnectorConfig, type LoginMethodConfig, type WALLET_CONNECTOR_TYPE } from "@web3auth/no-modal";
|
|
3
|
-
import { LoginModalCallbacks, LoginModalProps, UIConfig } from "./interfaces";
|
|
3
|
+
import { browser, LoginModalCallbacks, LoginModalProps, os, platform, UIConfig } from "./interfaces";
|
|
4
4
|
export declare class LoginModal {
|
|
5
5
|
private uiConfig;
|
|
6
6
|
private stateEmitter;
|
|
@@ -11,6 +11,11 @@ export declare class LoginModal {
|
|
|
11
11
|
private analytics;
|
|
12
12
|
constructor(uiConfig: LoginModalProps, callbacks: LoginModalCallbacks);
|
|
13
13
|
get isDark(): boolean;
|
|
14
|
+
get deviceDetails(): {
|
|
15
|
+
platform: platform;
|
|
16
|
+
browser: browser;
|
|
17
|
+
os: os;
|
|
18
|
+
};
|
|
14
19
|
initModal: () => Promise<void>;
|
|
15
20
|
addSocialLogins: (connector: WALLET_CONNECTOR_TYPE, loginMethods: LoginMethodConfig, loginMethodsOrder: string[], uiConfig: Omit<UIConfig, "connectorListener">) => void;
|
|
16
21
|
addWalletLogins: (externalWalletsConfig: Record<string, BaseConnectorConfig>, options?: {
|
|
@@ -34,8 +34,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
34
34
|
try {
|
|
35
35
|
var _params$loginParams;
|
|
36
36
|
const connector = this.getConnector(params.connector, (_params$loginParams = params.loginParams) === null || _params$loginParams === void 0 ? void 0 : _params$loginParams.chainNamespace);
|
|
37
|
-
// auto-connect WalletConnect
|
|
38
|
-
const shouldStartConnectionInBackground = connector.name === WALLET_CONNECTORS.WALLET_CONNECT_V2
|
|
37
|
+
// auto-connect WalletConnect in background to generate QR code URI without interfering with user's selected connection
|
|
38
|
+
const shouldStartConnectionInBackground = connector.name === WALLET_CONNECTORS.WALLET_CONNECT_V2;
|
|
39
39
|
if (shouldStartConnectionInBackground) {
|
|
40
40
|
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
41
41
|
await connector.connect({
|
|
@@ -75,30 +75,6 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
75
75
|
wcConnector.status = CONNECTOR_STATUS.READY;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
// handle MM session refresh if MM is not injected
|
|
80
|
-
const metamaskConnector = this.getConnector(WALLET_CONNECTORS.METAMASK);
|
|
81
|
-
if (metamaskConnector && !metamaskConnector.isInjected) {
|
|
82
|
-
const status = metamaskConnector === null || metamaskConnector === void 0 ? void 0 : metamaskConnector.status;
|
|
83
|
-
log.debug("trying refreshing MM session", visibility, status);
|
|
84
|
-
if (visibility && (status === CONNECTOR_STATUS.READY || status === CONNECTOR_STATUS.CONNECTING)) {
|
|
85
|
-
log.debug("refreshing MM session");
|
|
86
|
-
|
|
87
|
-
// refreshing session for MM whenever modal is opened.
|
|
88
|
-
try {
|
|
89
|
-
const initialChain = this.getInitialChainIdForConnector(metamaskConnector);
|
|
90
|
-
metamaskConnector.connect({
|
|
91
|
-
chainId: initialChain.chainId
|
|
92
|
-
});
|
|
93
|
-
} catch (error) {
|
|
94
|
-
log.error(`Error while connecting to MM`, error);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (!visibility && this.status === CONNECTOR_STATUS.CONNECTED && (status === CONNECTOR_STATUS.READY || status === CONNECTOR_STATUS.CONNECTING)) {
|
|
98
|
-
log.debug("this stops MM connector from trying to reconnect once proposal expires");
|
|
99
|
-
metamaskConnector.status = CONNECTOR_STATUS.READY;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
78
|
});
|
|
103
79
|
_defineProperty(this, "getChainNamespaces", () => {
|
|
104
80
|
var _this$coreOptions$cha;
|
|
@@ -607,7 +583,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
607
583
|
}
|
|
608
584
|
|
|
609
585
|
// update connector config
|
|
610
|
-
if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING].includes(connector.status)) {
|
|
586
|
+
if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING, CONNECTOR_STATUS.CONNECTED].includes(connector.status)) {
|
|
611
587
|
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
612
588
|
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
613
589
|
isInjected: connector.isInjected,
|
|
@@ -11,12 +11,12 @@ import 'deepmerge';
|
|
|
11
11
|
import '../../config.js';
|
|
12
12
|
import '../../ui/config.js';
|
|
13
13
|
import '../../ui/css/index.css.js';
|
|
14
|
+
import 'bowser';
|
|
14
15
|
import 'react-dom/client';
|
|
15
16
|
import '@toruslabs/http-helpers';
|
|
16
17
|
import 'clsx';
|
|
17
18
|
import 'tailwind-merge';
|
|
18
19
|
import 'react/jsx-runtime';
|
|
19
|
-
import 'bowser';
|
|
20
20
|
import 'react-i18next';
|
|
21
21
|
import '../../ui/localeImport.js';
|
|
22
22
|
import 'classnames';
|
|
@@ -20,7 +20,7 @@ function ButtonWallet(props) {
|
|
|
20
20
|
buttonRadius
|
|
21
21
|
} = props;
|
|
22
22
|
const isDark = useContext(ThemedContext);
|
|
23
|
-
const isLink = useMemo(() => deviceDetails.platform !== "desktop" && button.href && button.hasWalletConnect && !button.
|
|
23
|
+
const isLink = useMemo(() => deviceDetails.platform !== "desktop" && button.href && button.hasWalletConnect && !button.isInstalled, [deviceDetails, button]);
|
|
24
24
|
const href = useMemo(() => button.href ? formatIOSMobile({
|
|
25
25
|
uri: walletConnectUri,
|
|
26
26
|
link: button.href
|
|
@@ -134,8 +134,18 @@ function ConnectWallet(props) {
|
|
|
134
134
|
if (isShowAllWallets) return totalExternalWalletsCount;
|
|
135
135
|
return walletDiscoverySupported ? defaultButtons.length : installedWalletButtons.length;
|
|
136
136
|
}, [walletDiscoverySupported, defaultButtons, installedWalletButtons, isShowAllWallets, totalExternalWalletsCount]);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Wallet click logic
|
|
140
|
+
* - For installed wallets
|
|
141
|
+
* - For MetaMask non-injected on desktop, show QR code for connection
|
|
142
|
+
* - Ask user to select a chain namespace if it has multiple namespaces
|
|
143
|
+
* - Otherwise, use their connectors to connect
|
|
144
|
+
* - For wallet-discovery wallets (not installed)
|
|
145
|
+
* - On desktop, show QR code for connection if wallet connect v2 is supported, otherwise show install links
|
|
146
|
+
* - On mobile, open deeplink with wallet connect uri (won't go into this function as it'll open the deeplink)
|
|
147
|
+
*/
|
|
137
148
|
const handleWalletClick = button => {
|
|
138
|
-
var _button$chainNamespac2, _button$chainNamespac3;
|
|
139
149
|
analytics === null || analytics === void 0 || analytics.track(ANALYTICS_EVENTS.EXTERNAL_WALLET_SELECTED, {
|
|
140
150
|
connector: button.isInstalled ? button.name : button.hasWalletConnect ? WALLET_CONNECTORS.WALLET_CONNECT_V2 : "",
|
|
141
151
|
wallet_name: button.displayName,
|
|
@@ -148,41 +158,53 @@ function ConnectWallet(props) {
|
|
|
148
158
|
total_external_wallets: allUniqueButtons.length
|
|
149
159
|
});
|
|
150
160
|
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
// for installed wallets
|
|
162
|
+
if (button.isInstalled) {
|
|
163
|
+
var _button$chainNamespac2;
|
|
164
|
+
// for MetaMask non-injected on desktop, show QR code for connection
|
|
165
|
+
if (button.name === WALLET_CONNECTORS.METAMASK && !button.hasInjectedWallet && deviceDetails.platform === "desktop") {
|
|
166
|
+
handleExternalWalletClick({
|
|
167
|
+
connector: button.name
|
|
168
|
+
});
|
|
169
|
+
setSelectedButton(button);
|
|
170
|
+
setSelectedWallet(true);
|
|
171
|
+
setCurrentPage(CONNECT_WALLET_PAGES.SELECTED_WALLET);
|
|
172
|
+
handleWalletDetailsHeight();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// show chain namespace selector if the button has multiple chain namespaces
|
|
177
|
+
if (((_button$chainNamespac2 = button.chainNamespaces) === null || _button$chainNamespac2 === void 0 ? void 0 : _button$chainNamespac2.length) > 1) {
|
|
178
|
+
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
179
|
+
multiChainSelector: {
|
|
180
|
+
show: true,
|
|
181
|
+
wallet: button
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
162
186
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const isCustomConnector = !button.hasInjectedWallet && button.isInstalled;
|
|
166
|
-
if (isInjectedConnectorAndSingleChainNamespace || isCustomConnector && button.name !== WALLET_CONNECTORS.METAMASK) {
|
|
167
|
-
return handleExternalWalletClick({
|
|
187
|
+
// otherwise, use their connectors to connect
|
|
188
|
+
handleExternalWalletClick({
|
|
168
189
|
connector: button.name
|
|
169
190
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// show QR code for wallet connect v2 and MM (non-injected)
|
|
173
|
-
if (button.hasWalletConnect) {
|
|
174
|
-
setSelectedButton(button);
|
|
175
|
-
setSelectedWallet(true);
|
|
176
|
-
setCurrentPage(CONNECT_WALLET_PAGES.SELECTED_WALLET);
|
|
177
|
-
handleWalletDetailsHeight();
|
|
191
|
+
return;
|
|
178
192
|
} else {
|
|
179
|
-
// show
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
193
|
+
// show QR code if wallet connect v2 is supported
|
|
194
|
+
if (button.hasWalletConnect) {
|
|
195
|
+
setSelectedButton(button);
|
|
196
|
+
setSelectedWallet(true);
|
|
197
|
+
setCurrentPage(CONNECT_WALLET_PAGES.SELECTED_WALLET);
|
|
198
|
+
handleWalletDetailsHeight();
|
|
199
|
+
} else {
|
|
200
|
+
// otherwise, show install links
|
|
201
|
+
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
202
|
+
installLinks: {
|
|
203
|
+
show: true,
|
|
204
|
+
wallet: button
|
|
205
|
+
}
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
186
208
|
}
|
|
187
209
|
};
|
|
188
210
|
const handleMoreWallets = () => {
|
|
@@ -13,7 +13,7 @@ const ConnectWalletChainNamespaceSelect = props => {
|
|
|
13
13
|
const [t] = useTranslation(undefined, {
|
|
14
14
|
i18n: i18nInstance
|
|
15
15
|
});
|
|
16
|
-
const chainNamespaces = wallet.chainNamespaces.map(chainNamespace => {
|
|
16
|
+
const chainNamespaces = wallet.chainNamespaces.sort().map(chainNamespace => {
|
|
17
17
|
const imageId = chainNamespace === "eip155" ? "evm" : chainNamespace;
|
|
18
18
|
const displayName = chainNamespace === "eip155" ? "EVM" : chainNamespace;
|
|
19
19
|
return {
|
|
@@ -10,7 +10,7 @@ import { AnalyticsContext } from '../../context/AnalyticsContext.js';
|
|
|
10
10
|
import { RootContext } from '../../context/RootContext.js';
|
|
11
11
|
import { createPasswordlessHandler } from '../../handlers/factory.js';
|
|
12
12
|
import i18nInstance from '../../localeImport.js';
|
|
13
|
-
import { cn,
|
|
13
|
+
import { cn, getUserCountry, getIcons, validatePhoneNumber } from '../../utils.js';
|
|
14
14
|
import Image from '../Image/Image.js';
|
|
15
15
|
import SocialLoginList from '../SocialLoginList/SocialLoginList.js';
|
|
16
16
|
import LoginOtp from './LoginOtp/LoginOtp.js';
|
|
@@ -42,7 +42,8 @@ function Login(props) {
|
|
|
42
42
|
showExternalWalletCount,
|
|
43
43
|
showInstalledExternalWallets,
|
|
44
44
|
logoAlignment = "center",
|
|
45
|
-
buttonRadius = "pill"
|
|
45
|
+
buttonRadius = "pill",
|
|
46
|
+
deviceDetails
|
|
46
47
|
} = props;
|
|
47
48
|
const [t] = useTranslation(undefined, {
|
|
48
49
|
i18n: i18nInstance
|
|
@@ -311,6 +312,13 @@ function Login(props) {
|
|
|
311
312
|
setOtpLoading(false);
|
|
312
313
|
}
|
|
313
314
|
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Installed wallet click logic:
|
|
318
|
+
* - For MetaMask: If not injected and on desktop, display QR code for connection.
|
|
319
|
+
* - If wallet supports multiple chain namespaces, prompt user to select a chain.
|
|
320
|
+
* - Otherwise, connect directly using the wallet connector.
|
|
321
|
+
*/
|
|
314
322
|
const handleInstalledWalletClick = wallet => {
|
|
315
323
|
var _wallet$chainNamespac;
|
|
316
324
|
analytics === null || analytics === void 0 || analytics.track(ANALYTICS_EVENTS.EXTERNAL_WALLET_SELECTED, {
|
|
@@ -324,8 +332,12 @@ function Login(props) {
|
|
|
324
332
|
has_wallet_registry_item: !!wallet.walletRegistryItem,
|
|
325
333
|
total_external_wallets: totalExternalWallets
|
|
326
334
|
});
|
|
327
|
-
// for non-injected Metamask, show QR code to connect
|
|
328
|
-
if (wallet.name === WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet) {
|
|
335
|
+
// for non-injected Metamask on desktop, show QR code to connect
|
|
336
|
+
if (wallet.name === WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet && deviceDetails.platform === "desktop") {
|
|
337
|
+
handleExternalWalletClick({
|
|
338
|
+
connector: wallet.name
|
|
339
|
+
});
|
|
340
|
+
// We should show QR code only if the wallet is not installed.
|
|
329
341
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
330
342
|
metamaskQrCode: {
|
|
331
343
|
show: true,
|
|
@@ -453,9 +465,10 @@ function Login(props) {
|
|
|
453
465
|
})]
|
|
454
466
|
}, "external-wallets-section");
|
|
455
467
|
};
|
|
468
|
+
const headerLogo = [DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT].includes(appLogo) ? "" : appLogo;
|
|
456
469
|
const delimiter = index => {
|
|
457
470
|
return /*#__PURE__*/jsxs("div", {
|
|
458
|
-
className: "w3a--flex w3a--w-full w3a--items-center w3a--gap-x-2",
|
|
471
|
+
className: cn("w3a--flex w3a--w-full w3a--items-center w3a--gap-x-2", headerLogo ? "w3a--my-2" : "w3a--my-4"),
|
|
459
472
|
children: [/*#__PURE__*/jsx("div", {
|
|
460
473
|
className: "w3a--h-px w3a--w-full w3a--bg-app-gray-200 dark:w3a--bg-app-gray-500"
|
|
461
474
|
}), /*#__PURE__*/jsx("p", {
|
|
@@ -511,20 +524,19 @@ function Login(props) {
|
|
|
511
524
|
return sections;
|
|
512
525
|
};
|
|
513
526
|
const expandedView = () => socialLoginSection(otherRow);
|
|
514
|
-
const headerLogo = [DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT].includes(appLogo) ? "" : appLogo;
|
|
515
527
|
return /*#__PURE__*/jsxs("div", {
|
|
516
528
|
className: "w3a--flex w3a--flex-col w3a--items-center w3a--gap-y-4 w3a--p-2",
|
|
517
529
|
children: [/*#__PURE__*/jsxs("div", {
|
|
518
530
|
className: cn("w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2 w3a--pt-6", logoAlignment === "center" ? "" : "w3a--w-full"),
|
|
519
|
-
children: [/*#__PURE__*/jsx("figure", {
|
|
531
|
+
children: [headerLogo && /*#__PURE__*/jsx("figure", {
|
|
520
532
|
className: cn("w3a--mx-auto w3a--h-12 w3a--w-[200px]", logoAlignment === "center" ? "w3a--flex w3a--justify-center w3a--items-center" : "w3a--ml-0 w3a--w-auto"),
|
|
521
533
|
children: /*#__PURE__*/jsx("img", {
|
|
522
|
-
src: headerLogo
|
|
534
|
+
src: headerLogo,
|
|
523
535
|
alt: "Logo",
|
|
524
536
|
className: "w3a--size-full w3a--object-contain"
|
|
525
537
|
})
|
|
526
538
|
}), /*#__PURE__*/jsx("p", {
|
|
527
|
-
className: cn("w3a--text-
|
|
539
|
+
className: cn("w3a--text-app-gray-900 dark:w3a--text-app-white", logoAlignment === "center" ? "w3a--text-center" : "w3a--text-left w3a--w-full w3a--ml-4", headerLogo ? "w3a--text-lg w3a--font-semibold" : "w3a--text-3xl w3a--font-medium"),
|
|
528
540
|
children: t("modal.social.sign-in")
|
|
529
541
|
})]
|
|
530
542
|
}), /*#__PURE__*/jsx(HCaptcha, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import { WALLET_CONNECTORS } from '@web3auth/no-modal';
|
|
3
|
-
import Bowser from 'bowser';
|
|
4
3
|
import { useContext, useState, useMemo, useCallback } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { DEFAULT_METAMASK_WALLET_REGISTRY_ITEM, PAGES, CONNECT_WALLET_PAGES } from '../../constants.js';
|
|
@@ -42,7 +41,8 @@ function Root(props) {
|
|
|
42
41
|
isEmailPasswordLessLoginVisible,
|
|
43
42
|
isSmsPasswordLessLoginVisible,
|
|
44
43
|
preHandleExternalWalletClick,
|
|
45
|
-
uiConfig
|
|
44
|
+
uiConfig,
|
|
45
|
+
deviceDetails
|
|
46
46
|
} = props;
|
|
47
47
|
const {
|
|
48
48
|
logoAlignment = "center",
|
|
@@ -92,19 +92,6 @@ function Root(props) {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// Wallet Details
|
|
95
|
-
const deviceDetails = useMemo(() => {
|
|
96
|
-
if (typeof window === "undefined") return {
|
|
97
|
-
platform: "mobile",
|
|
98
|
-
browser: "chrome",
|
|
99
|
-
os: "ios"
|
|
100
|
-
};
|
|
101
|
-
const browserData = Bowser.getParser(window.navigator.userAgent);
|
|
102
|
-
return {
|
|
103
|
-
platform: browserData.getPlatformType(),
|
|
104
|
-
browser: browserData.getBrowserName().toLowerCase(),
|
|
105
|
-
os: browserData.getOSName()
|
|
106
|
-
};
|
|
107
|
-
}, []);
|
|
108
95
|
const mobileInstallLinks = useMemo(() => {
|
|
109
96
|
var _bodyState$installLin;
|
|
110
97
|
if (deviceDetails.platform === "desktop") return [];
|
|
@@ -371,12 +358,8 @@ function Root(props) {
|
|
|
371
358
|
setToast
|
|
372
359
|
}), [bodyState, setBodyState, toast, setToast]);
|
|
373
360
|
const isShowLoader = useMemo(() => {
|
|
374
|
-
// don't show loader if metamask is connecting and there is a connect uri
|
|
375
|
-
if (modalState.detailedLoaderConnector === WALLET_CONNECTORS.METAMASK && modalState.metamaskConnectUri) {
|
|
376
|
-
return false;
|
|
377
|
-
}
|
|
378
361
|
return modalState.status !== MODAL_STATUS.INITIALIZED;
|
|
379
|
-
}, [modalState.
|
|
362
|
+
}, [modalState.status]);
|
|
380
363
|
return /*#__PURE__*/jsx(RootContext.Provider, {
|
|
381
364
|
value: contextValue,
|
|
382
365
|
children: /*#__PURE__*/jsxs("div", {
|
|
@@ -437,6 +420,7 @@ function Root(props) {
|
|
|
437
420
|
totalExternalWallets: totalExternalWallets,
|
|
438
421
|
logoAlignment: logoAlignment,
|
|
439
422
|
buttonRadius: buttonRadiusType,
|
|
423
|
+
deviceDetails: deviceDetails,
|
|
440
424
|
handleSocialLoginClick: handleSocialLoginClick,
|
|
441
425
|
handleExternalWalletBtnClick: onExternalWalletBtnClick,
|
|
442
426
|
handleSocialLoginHeight: handleSocialLoginHeight,
|
|
@@ -450,11 +434,7 @@ function Root(props) {
|
|
|
450
434
|
allExternalButtons: allButtons,
|
|
451
435
|
connectorVisibilityMap: connectorVisibilityMap,
|
|
452
436
|
customConnectorButtons: customConnectorButtons,
|
|
453
|
-
deviceDetails:
|
|
454
|
-
platform: deviceDetails.platform,
|
|
455
|
-
browser: deviceDetails.browser,
|
|
456
|
-
os: deviceDetails.os
|
|
457
|
-
},
|
|
437
|
+
deviceDetails: deviceDetails,
|
|
458
438
|
chainNamespace: chainNamespaces,
|
|
459
439
|
buttonRadius: buttonRadiusType,
|
|
460
440
|
handleWalletDetailsHeight: handleWalletDetailsHeight,
|
|
@@ -21,7 +21,8 @@ function Widget(props) {
|
|
|
21
21
|
appName,
|
|
22
22
|
chainNamespaces,
|
|
23
23
|
walletRegistry,
|
|
24
|
-
uiConfig
|
|
24
|
+
uiConfig,
|
|
25
|
+
deviceDetails
|
|
25
26
|
} = props;
|
|
26
27
|
const {
|
|
27
28
|
widgetType
|
|
@@ -123,8 +124,8 @@ function Widget(props) {
|
|
|
123
124
|
return ((_modalState$socialLog6 = modalState.socialLoginsConfig) === null || _modalState$socialLog6 === void 0 || (_modalState$socialLog6 = _modalState$socialLog6.uiConfig) === null || _modalState$socialLog6 === void 0 ? void 0 : _modalState$socialLog6.primaryButton) === "externalLogin";
|
|
124
125
|
}, [modalState.socialLoginsConfig]);
|
|
125
126
|
const showPasswordLessInput = useMemo(() => isEmailPasswordLessLoginVisible || isSmsPasswordLessLoginVisible, [isEmailPasswordLessLoginVisible, isSmsPasswordLessLoginVisible]);
|
|
126
|
-
const showExternalWalletButton = useMemo(() => modalState.hasExternalWallets, [modalState]);
|
|
127
|
-
const showExternalWalletPage = useMemo(() => (areSocialLoginsVisible || showPasswordLessInput) && !modalState.externalWalletsVisibility, [areSocialLoginsVisible, showPasswordLessInput, modalState
|
|
127
|
+
const showExternalWalletButton = useMemo(() => modalState.hasExternalWallets || !!modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK], [modalState]);
|
|
128
|
+
const showExternalWalletPage = useMemo(() => (areSocialLoginsVisible || showPasswordLessInput || !!modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK]) && !modalState.externalWalletsVisibility, [areSocialLoginsVisible, showPasswordLessInput, modalState]);
|
|
128
129
|
const handleExternalWalletBtnClick = flag => {
|
|
129
130
|
setModalState(prevState => {
|
|
130
131
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
@@ -162,7 +163,7 @@ function Widget(props) {
|
|
|
162
163
|
// TODO: maybe move this inside root
|
|
163
164
|
if (!modalState.modalVisibility) return;
|
|
164
165
|
if (typeof modalState.externalWalletsConfig === "object") {
|
|
165
|
-
var _modalState$externalW
|
|
166
|
+
var _modalState$externalW;
|
|
166
167
|
// auto connect to WC if not injected to generate QR code URI for mobile connection
|
|
167
168
|
const wcAvailable = (((_modalState$externalW = modalState.externalWalletsConfig[WALLET_CONNECTORS.WALLET_CONNECT_V2]) === null || _modalState$externalW === void 0 ? void 0 : _modalState$externalW.showOnModal) || false) !== false;
|
|
168
169
|
if (wcAvailable && !modalState.walletConnectUri && typeof handleExternalWalletClick === "function") {
|
|
@@ -170,14 +171,6 @@ function Widget(props) {
|
|
|
170
171
|
connector: WALLET_CONNECTORS.WALLET_CONNECT_V2
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
-
// auto connect to MetaMask if not injected to generate QR code URI for mobile connection
|
|
175
|
-
const mmAvailable = modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK] && !((_modalState$externalW2 = modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK]) !== null && _modalState$externalW2 !== void 0 && _modalState$externalW2.isInjected);
|
|
176
|
-
if (mmAvailable && !modalState.metamaskConnectUri && typeof handleExternalWalletClick === "function") {
|
|
177
|
-
handleExternalWalletClick({
|
|
178
|
-
connector: WALLET_CONNECTORS.METAMASK
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
174
|
}
|
|
182
175
|
}, [modalState, handleExternalWalletClick]);
|
|
183
176
|
if (widgetType === WIDGET_TYPE.MODAL) {
|
|
@@ -208,7 +201,8 @@ function Widget(props) {
|
|
|
208
201
|
onCloseLoader: onCloseLoader,
|
|
209
202
|
isEmailPasswordLessLoginVisible: isEmailPasswordLessLoginVisible,
|
|
210
203
|
isSmsPasswordLessLoginVisible: isSmsPasswordLessLoginVisible,
|
|
211
|
-
uiConfig: uiConfig
|
|
204
|
+
uiConfig: uiConfig,
|
|
205
|
+
deviceDetails: deviceDetails
|
|
212
206
|
})
|
|
213
207
|
});
|
|
214
208
|
}
|
|
@@ -237,7 +231,8 @@ function Widget(props) {
|
|
|
237
231
|
onCloseLoader: onCloseLoader,
|
|
238
232
|
isEmailPasswordLessLoginVisible: isEmailPasswordLessLoginVisible,
|
|
239
233
|
isSmsPasswordLessLoginVisible: isSmsPasswordLessLoginVisible,
|
|
240
|
-
uiConfig: uiConfig
|
|
234
|
+
uiConfig: uiConfig,
|
|
235
|
+
deviceDetails: deviceDetails
|
|
241
236
|
})
|
|
242
237
|
});
|
|
243
238
|
}
|