@arcblock/did-connect-react 3.4.15 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/did-connect-react.css +1 -0
- package/dist/standalone/index.js +133700 -0
- package/lib/package.json.js +1 -1
- package/package.json +11 -6
- package/.aigne/doc-smith/config.yaml +0 -85
- package/.aigne/doc-smith/history.yaml +0 -6
- package/.aigne/doc-smith/output/structure-plan.json +0 -204
- package/.aigne/doc-smith/translation-cache.yaml +0 -11
- package/.aigne/doc-smith/upload-cache.yaml +0 -213
- package/docs/_sidebar.md +0 -18
- package/docs/advanced-authentication-methods.ja.md +0 -261
- package/docs/advanced-authentication-methods.md +0 -261
- package/docs/advanced-authentication-methods.zh-TW.md +0 -261
- package/docs/advanced-authentication-methods.zh.md +0 -261
- package/docs/advanced-utilities.ja.md +0 -132
- package/docs/advanced-utilities.md +0 -132
- package/docs/advanced-utilities.zh-TW.md +0 -132
- package/docs/advanced-utilities.zh.md +0 -132
- package/docs/advanced.ja.md +0 -95
- package/docs/advanced.md +0 -95
- package/docs/advanced.zh-TW.md +0 -95
- package/docs/advanced.zh.md +0 -95
- package/docs/api-reference.ja.md +0 -178
- package/docs/api-reference.md +0 -178
- package/docs/api-reference.zh-TW.md +0 -178
- package/docs/api-reference.zh.md +0 -178
- package/docs/assets/diagram/core-components-session-provider-01.ja.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/overview-01.ja.jpg +0 -0
- package/docs/assets/diagram/overview-01.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh.jpg +0 -0
- package/docs/core-components-did-connect.ja.md +0 -166
- package/docs/core-components-did-connect.md +0 -166
- package/docs/core-components-did-connect.zh-TW.md +0 -166
- package/docs/core-components-did-connect.zh.md +0 -166
- package/docs/core-components-session-provider.ja.md +0 -197
- package/docs/core-components-session-provider.md +0 -197
- package/docs/core-components-session-provider.zh-TW.md +0 -197
- package/docs/core-components-session-provider.zh.md +0 -197
- package/docs/core-components.ja.md +0 -16
- package/docs/core-components.md +0 -16
- package/docs/core-components.zh-TW.md +0 -16
- package/docs/core-components.zh.md +0 -16
- package/docs/getting-started.ja.md +0 -138
- package/docs/getting-started.md +0 -138
- package/docs/getting-started.zh-TW.md +0 -138
- package/docs/getting-started.zh.md +0 -138
- package/docs/hooks-use-connect.ja.md +0 -178
- package/docs/hooks-use-connect.md +0 -178
- package/docs/hooks-use-connect.zh-TW.md +0 -178
- package/docs/hooks-use-connect.zh.md +0 -178
- package/docs/hooks-use-did.ja.md +0 -107
- package/docs/hooks-use-did.md +0 -107
- package/docs/hooks-use-did.zh-TW.md +0 -107
- package/docs/hooks-use-did.zh.md +0 -107
- package/docs/hooks-use-oauth-passkey.ja.md +0 -188
- package/docs/hooks-use-oauth-passkey.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh-TW.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh.md +0 -188
- package/docs/hooks.ja.md +0 -23
- package/docs/hooks.md +0 -23
- package/docs/hooks.zh-TW.md +0 -23
- package/docs/hooks.zh.md +0 -23
- package/docs/overview.ja.md +0 -119
- package/docs/overview.md +0 -119
- package/docs/overview.zh-TW.md +0 -119
- package/docs/overview.zh.md +0 -119
- package/docs/ui-components-address.ja.md +0 -121
- package/docs/ui-components-address.md +0 -121
- package/docs/ui-components-address.zh-TW.md +0 -121
- package/docs/ui-components-address.zh.md +0 -121
- package/docs/ui-components-avatar.ja.md +0 -65
- package/docs/ui-components-avatar.md +0 -65
- package/docs/ui-components-avatar.zh-TW.md +0 -65
- package/docs/ui-components-avatar.zh.md +0 -65
- package/docs/ui-components-button.ja.md +0 -99
- package/docs/ui-components-button.md +0 -99
- package/docs/ui-components-button.zh-TW.md +0 -99
- package/docs/ui-components-button.zh.md +0 -99
- package/docs/ui-components-logo.ja.md +0 -52
- package/docs/ui-components-logo.md +0 -52
- package/docs/ui-components-logo.zh-TW.md +0 -52
- package/docs/ui-components-logo.zh.md +0 -52
- package/docs/ui-components.ja.md +0 -57
- package/docs/ui-components.md +0 -57
- package/docs/ui-components.zh-TW.md +0 -57
- package/docs/ui-components.zh.md +0 -57
- package/glossary.md +0 -1
- package/src/Address/index.jsx +0 -2
- package/src/Avatar/index.jsx +0 -2
- package/src/Button/Button.stories.jsx +0 -7
- package/src/Button/index.jsx +0 -21
- package/src/Connect/Connect.stories.jsx +0 -34
- package/src/Connect/assets/locale.js +0 -149
- package/src/Connect/assets/login-bg.png +0 -0
- package/src/Connect/assets/login-slogan.js +0 -7
- package/src/Connect/components/action-button.jsx +0 -22
- package/src/Connect/components/app-tips.jsx +0 -156
- package/src/Connect/components/auto-height.jsx +0 -38
- package/src/Connect/components/back-button.jsx +0 -24
- package/src/Connect/components/connect-status.jsx +0 -259
- package/src/Connect/components/did-connect-title.jsx +0 -107
- package/src/Connect/components/download-tips.jsx +0 -55
- package/src/Connect/components/loading.jsx +0 -25
- package/src/Connect/components/login-item/connect-choose-list.jsx +0 -328
- package/src/Connect/components/login-item/connect-provider-list.jsx +0 -473
- package/src/Connect/components/login-item/login-method-item.jsx +0 -139
- package/src/Connect/components/login-item/mobile-login-item.jsx +0 -184
- package/src/Connect/components/login-item/passkey-login-item.jsx +0 -56
- package/src/Connect/components/login-item/wallet-login-options.jsx +0 -129
- package/src/Connect/components/login-item/web-login-item.jsx +0 -159
- package/src/Connect/components/mask-overlay.jsx +0 -32
- package/src/Connect/components/refresh-overlay.jsx +0 -52
- package/src/Connect/components/switch-app.jsx +0 -69
- package/src/Connect/connect.jsx +0 -635
- package/src/Connect/contexts/state.jsx +0 -235
- package/src/Connect/fallback-connect.jsx +0 -47
- package/src/Connect/fullpage.jsx +0 -3
- package/src/Connect/hooks/auth-url.js +0 -31
- package/src/Connect/hooks/method-list.js +0 -121
- package/src/Connect/hooks/page-show.js +0 -24
- package/src/Connect/hooks/provider-list.js +0 -168
- package/src/Connect/hooks/security.js +0 -40
- package/src/Connect/hooks/token.js +0 -627
- package/src/Connect/hooks/use-apps.js +0 -69
- package/src/Connect/hooks/use-quick-connect.js +0 -119
- package/src/Connect/index.jsx +0 -21
- package/src/Connect/landing-page.jsx +0 -3
- package/src/Connect/plugins/email/index.jsx +0 -85
- package/src/Connect/plugins/email/list-item.jsx +0 -35
- package/src/Connect/plugins/email/placeholder.jsx +0 -372
- package/src/Connect/plugins/index.js +0 -2
- package/src/Connect/use-connect.jsx +0 -321
- package/src/Connect/with-blocklet.jsx +0 -26
- package/src/Connect/with-bridge-call.jsx +0 -138
- package/src/Federated/context.jsx +0 -93
- package/src/Federated/index.jsx +0 -1
- package/src/Logo/index.jsx +0 -2
- package/src/OAuth/bind-conflict-alert.jsx +0 -37
- package/src/OAuth/context.jsx +0 -407
- package/src/OAuth/guest.svg +0 -20
- package/src/OAuth/index.jsx +0 -1
- package/src/OAuth/passport-switcher.jsx +0 -2
- package/src/Passkey/actions.jsx +0 -217
- package/src/Passkey/constants.js +0 -2
- package/src/Passkey/context.jsx +0 -395
- package/src/Passkey/dialog.jsx +0 -401
- package/src/Passkey/icon.jsx +0 -10
- package/src/Passkey/index.jsx +0 -2
- package/src/Service/index.jsx +0 -96
- package/src/Session/assets/did-spaces-guide-cover.svg +0 -1
- package/src/Session/assets/did-spaces-guide-icon.svg +0 -7
- package/src/Session/context.jsx +0 -7
- package/src/Session/did-spaces-guide.jsx +0 -173
- package/src/Session/handler.jsx +0 -98
- package/src/Session/hooks/use-federated.js +0 -91
- package/src/Session/hooks/use-mobile.jsx +0 -6
- package/src/Session/hooks/use-protected-routes.js +0 -16
- package/src/Session/hooks/use-session-token.js +0 -400
- package/src/Session/hooks/use-verify.jsx +0 -76
- package/src/Session/index.jsx +0 -1789
- package/src/Session/libs/constants.js +0 -17
- package/src/Session/libs/did-spaces.js +0 -38
- package/src/Session/libs/federated.js +0 -82
- package/src/Session/libs/index.js +0 -5
- package/src/Session/libs/locales.js +0 -160
- package/src/Session/libs/login-mobile.js +0 -80
- package/src/Session/window-focus-aware.jsx +0 -28
- package/src/SessionManager/index.jsx +0 -2
- package/src/Storage/engine/cookie.js +0 -25
- package/src/Storage/engine/local-storage.js +0 -57
- package/src/Storage/index.js +0 -25
- package/src/User/index.js +0 -4
- package/src/User/use-did.js +0 -80
- package/src/User/wrap-did.jsx +0 -18
- package/src/WebWalletSWKeeper/index.jsx +0 -3
- package/src/components/PassportSwitcher.jsx +0 -160
- package/src/constant.js +0 -27
- package/src/error.js +0 -6
- package/src/hooks/use-locale.jsx +0 -6
- package/src/index.js +0 -32
- package/src/locales/en.jsx +0 -15
- package/src/locales/index.jsx +0 -13
- package/src/locales/zh.jsx +0 -15
- package/src/types.d.ts +0 -355
- package/src/utils.js +0 -413
- package/vite.config.mjs +0 -29
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { Box } from '@mui/material';
|
|
3
|
-
import {
|
|
4
|
-
LOGIN_PROVIDER,
|
|
5
|
-
LOGIN_PROVIDER_ICON_SIZE,
|
|
6
|
-
LOGIN_PROVIDER_NAME,
|
|
7
|
-
LAST_USED_LOGIN_METHOD,
|
|
8
|
-
WALLET_LOGIN_METHOD,
|
|
9
|
-
} from '@arcblock/ux/lib/Util/constant';
|
|
10
|
-
import { getWebWalletUrl } from '@arcblock/ux/lib/Util/wallet';
|
|
11
|
-
import noop from 'lodash/noop';
|
|
12
|
-
import { useMemoizedFn } from 'ahooks';
|
|
13
|
-
import Cookie from 'js-cookie';
|
|
14
|
-
import { getCookieOptions } from '@arcblock/ux/lib/Util';
|
|
15
|
-
import { useEffect, useRef } from 'react';
|
|
16
|
-
import { mergeSx } from '@arcblock/ux/lib/Util/style';
|
|
17
|
-
import ProviderIcon from '@arcblock/ux/lib/DIDConnect/provider-icon';
|
|
18
|
-
import { GA_LAST_LOGIN_METHOD } from '@arcblock/ux/lib/withTracker/constant';
|
|
19
|
-
|
|
20
|
-
import MobileLoginItem from './mobile-login-item';
|
|
21
|
-
import WebLoginItem from './web-login-item';
|
|
22
|
-
import LoginMethodItem from './login-method-item';
|
|
23
|
-
import { useOAuth } from '../../../OAuth';
|
|
24
|
-
import { useStateContext } from '../../contexts/state';
|
|
25
|
-
import { getApiErrorMessage, getAppId, logger } from '../../../utils';
|
|
26
|
-
import PasskeyLoginItem from './passkey-login-item';
|
|
27
|
-
import { usePasskey } from '../../../Passkey';
|
|
28
|
-
import { useEmailPlugin } from '../../plugins';
|
|
29
|
-
|
|
30
|
-
export default function ConnectChooseList({
|
|
31
|
-
onSuccess = noop,
|
|
32
|
-
onError = noop,
|
|
33
|
-
size = 'small',
|
|
34
|
-
tokenState,
|
|
35
|
-
webWalletUrl = getWebWalletUrl(),
|
|
36
|
-
tokenKey,
|
|
37
|
-
passkeyBehavior = 'none',
|
|
38
|
-
onReset = noop,
|
|
39
|
-
showMobileLogin = true,
|
|
40
|
-
showOAuthLogin = true,
|
|
41
|
-
showPasskeyLogin = true,
|
|
42
|
-
showWebLogin = true,
|
|
43
|
-
showEmailLogin = true,
|
|
44
|
-
oauthProviderList = [],
|
|
45
|
-
slotProps = {},
|
|
46
|
-
disableSwitchApp = false,
|
|
47
|
-
forceUpdate = noop,
|
|
48
|
-
magicToken = undefined,
|
|
49
|
-
baseUrl = '/',
|
|
50
|
-
customItems = [],
|
|
51
|
-
}) {
|
|
52
|
-
const walletLoginRef = useRef(null);
|
|
53
|
-
const webLoginRef = useRef(null);
|
|
54
|
-
const passkeyLoginRef = useRef(null);
|
|
55
|
-
const { loginOAuth, logoutOAuth, t, oauthState } = useOAuth();
|
|
56
|
-
const { passkeyState } = usePasskey();
|
|
57
|
-
const { extraParams, locale, connectState, plugins, setPlugins, setSelectedPlugin, getPlugin, lastLoginMethod } =
|
|
58
|
-
useStateContext();
|
|
59
|
-
|
|
60
|
-
const handleLoginOAuth = useMemoizedFn(async (item) => {
|
|
61
|
-
localStorage.setItem(GA_LAST_LOGIN_METHOD, item.provider);
|
|
62
|
-
tokenState.reset();
|
|
63
|
-
oauthState.reset({
|
|
64
|
-
status: 'scanned',
|
|
65
|
-
});
|
|
66
|
-
passkeyState.reset();
|
|
67
|
-
connectState.chooseMethod = item.provider;
|
|
68
|
-
connectState.walletMethod = ''; // 清除 wallet 登录方式,防止状态污染
|
|
69
|
-
|
|
70
|
-
const sourceAppPid = extraParams?.sourceAppPid;
|
|
71
|
-
try {
|
|
72
|
-
oauthState.loading = true;
|
|
73
|
-
oauthState.status = 'scanned';
|
|
74
|
-
const loginResult = await loginOAuth(item, {
|
|
75
|
-
action: tokenState.action,
|
|
76
|
-
...extraParams,
|
|
77
|
-
});
|
|
78
|
-
const cookieOptions = getCookieOptions({ returnDomain: false });
|
|
79
|
-
Cookie.remove('connected_did', cookieOptions);
|
|
80
|
-
Cookie.remove('connected_pk', cookieOptions);
|
|
81
|
-
Cookie.remove('connected_wallet_os', cookieOptions);
|
|
82
|
-
|
|
83
|
-
if (loginResult?.sessionToken) {
|
|
84
|
-
// 登录成功后记录最后使用的登录方式(用于显示 Last Used 标签)
|
|
85
|
-
localStorage.setItem(LAST_USED_LOGIN_METHOD, item.provider);
|
|
86
|
-
await onSuccess(
|
|
87
|
-
{
|
|
88
|
-
...loginResult,
|
|
89
|
-
encrypted: false,
|
|
90
|
-
},
|
|
91
|
-
(val) => val,
|
|
92
|
-
{
|
|
93
|
-
sourceAppPid,
|
|
94
|
-
connected_app: getAppId(tokenState.appInfo, tokenState.memberAppInfo),
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
oauthState.loading = false;
|
|
98
|
-
oauthState.status = 'succeed';
|
|
99
|
-
}
|
|
100
|
-
} catch (e) {
|
|
101
|
-
logger.error(`Failed login OAuth: ${item.provider}`, e);
|
|
102
|
-
const errorMessage = getApiErrorMessage(e, t('loginOAuthFailed'));
|
|
103
|
-
oauthState.loading = false;
|
|
104
|
-
oauthState.error = errorMessage;
|
|
105
|
-
oauthState.status = 'error';
|
|
106
|
-
await logoutOAuth({ provider: item.provider });
|
|
107
|
-
onError(new Error(errorMessage));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const defaultRetryConnect = useMemoizedFn(async () => {
|
|
112
|
-
tokenState.reset();
|
|
113
|
-
await onReset();
|
|
114
|
-
tokenState.status = 'created';
|
|
115
|
-
connectState.chooseMethod = 'wallet';
|
|
116
|
-
connectState.walletMethod = ''; // 重置 wallet 登录方式,确保扫码登录能正确记录
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const emailPlugin = useEmailPlugin({ baseUrl });
|
|
120
|
-
|
|
121
|
-
const setupMagicToken = useMemoizedFn(() => {
|
|
122
|
-
if (magicToken && showEmailLogin && plugins.some((plugin) => plugin.name === LOGIN_PROVIDER.EMAIL)) {
|
|
123
|
-
const plugin = getPlugin(LOGIN_PROVIDER.EMAIL);
|
|
124
|
-
if (plugin.state.status === 'idle') {
|
|
125
|
-
localStorage.setItem(GA_LAST_LOGIN_METHOD, LOGIN_PROVIDER.EMAIL);
|
|
126
|
-
plugin.state.reset();
|
|
127
|
-
plugin.state.magicToken = magicToken;
|
|
128
|
-
connectState.chooseMethod = LOGIN_PROVIDER.EMAIL;
|
|
129
|
-
setSelectedPlugin(plugin);
|
|
130
|
-
forceUpdate();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// 考虑到切换账号的情况,此时 showEmailLogin 会根据当前上下文的 blocklet 发生变化,所以需要监听 showEmailLogin 的变化
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
const finalList = [];
|
|
138
|
-
if (showEmailLogin) {
|
|
139
|
-
// 尽可能确保在 baseUrl 不变的情况下,不更改 email 插件的数据,以确保页面的展示不会出现闪烁
|
|
140
|
-
const prevEmailPlugin = getPlugin(LOGIN_PROVIDER.EMAIL);
|
|
141
|
-
if (prevEmailPlugin && prevEmailPlugin.baseUrl === emailPlugin.baseUrl) {
|
|
142
|
-
finalList.push(prevEmailPlugin);
|
|
143
|
-
} else {
|
|
144
|
-
finalList.push(emailPlugin);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
setPlugins(finalList);
|
|
148
|
-
connectState.retryConnect = defaultRetryConnect;
|
|
149
|
-
// HACK: 必须要设置延迟,不然拿不到最新的 plugins 的值
|
|
150
|
-
setTimeout(() => {
|
|
151
|
-
setupMagicToken();
|
|
152
|
-
}, 100);
|
|
153
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
154
|
-
}, [showEmailLogin]);
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<Box className="did-connect__choose" sx={mergeSx({ flex: 1 }, slotProps?.root?.sx)}>
|
|
158
|
-
<Box
|
|
159
|
-
sx={{
|
|
160
|
-
display: 'flex',
|
|
161
|
-
flexDirection: 'column',
|
|
162
|
-
gap: 2,
|
|
163
|
-
}}>
|
|
164
|
-
<Box
|
|
165
|
-
sx={[
|
|
166
|
-
{
|
|
167
|
-
display: 'flex',
|
|
168
|
-
flexDirection: 'column',
|
|
169
|
-
gap: 1.5,
|
|
170
|
-
},
|
|
171
|
-
]}>
|
|
172
|
-
{showMobileLogin && (
|
|
173
|
-
<MobileLoginItem
|
|
174
|
-
t={t}
|
|
175
|
-
isLatest={lastLoginMethod && lastLoginMethod === WALLET_LOGIN_METHOD.MOBILE}
|
|
176
|
-
ref={walletLoginRef}
|
|
177
|
-
tokenState={tokenState}
|
|
178
|
-
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
179
|
-
locale={locale}
|
|
180
|
-
tokenKey={tokenKey}
|
|
181
|
-
disableSwitchApp={disableSwitchApp}
|
|
182
|
-
onClick={async () => {
|
|
183
|
-
localStorage.setItem(GA_LAST_LOGIN_METHOD, LOGIN_PROVIDER.WALLET);
|
|
184
|
-
tokenState.reset();
|
|
185
|
-
await onReset();
|
|
186
|
-
tokenState.status = 'created';
|
|
187
|
-
connectState.chooseMethod = 'wallet';
|
|
188
|
-
const connectFn = walletLoginRef.current?.connect;
|
|
189
|
-
connectState.retryConnect = () => {
|
|
190
|
-
connectFn(defaultRetryConnect);
|
|
191
|
-
};
|
|
192
|
-
}}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
{showWebLogin && (
|
|
196
|
-
<WebLoginItem
|
|
197
|
-
isLatest={lastLoginMethod && lastLoginMethod === WALLET_LOGIN_METHOD.WEB}
|
|
198
|
-
ref={webLoginRef}
|
|
199
|
-
tokenState={tokenState}
|
|
200
|
-
webWalletUrl={webWalletUrl}
|
|
201
|
-
t={t}
|
|
202
|
-
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
203
|
-
disableSwitchApp={disableSwitchApp}
|
|
204
|
-
onClick={() => {
|
|
205
|
-
localStorage.setItem(GA_LAST_LOGIN_METHOD, LOGIN_PROVIDER.WALLET);
|
|
206
|
-
// HACK: 在点击插件登录时,直接将状态置为扫码中,避免插件登录时的状态切换
|
|
207
|
-
tokenState.status = 'scanned';
|
|
208
|
-
connectState.chooseMethod = 'wallet-web';
|
|
209
|
-
const connectFn = webLoginRef.current.connect;
|
|
210
|
-
connectState.retryConnect = async () => {
|
|
211
|
-
await onReset();
|
|
212
|
-
tokenState.error = '';
|
|
213
|
-
tokenState.status = 'scanned';
|
|
214
|
-
connectFn();
|
|
215
|
-
};
|
|
216
|
-
}}
|
|
217
|
-
/>
|
|
218
|
-
)}
|
|
219
|
-
|
|
220
|
-
{showOAuthLogin || showPasskeyLogin || showEmailLogin ? (
|
|
221
|
-
<Box
|
|
222
|
-
sx={[
|
|
223
|
-
{
|
|
224
|
-
display: 'flex',
|
|
225
|
-
flexDirection: 'column',
|
|
226
|
-
gap: 1.5,
|
|
227
|
-
},
|
|
228
|
-
]}>
|
|
229
|
-
{/* TODO: @zhanghan 需要将所有 method 转换为 plugin 的形式注入 */}
|
|
230
|
-
{plugins.map((plugin) =>
|
|
231
|
-
plugin.renderListItem({
|
|
232
|
-
key: plugin.name,
|
|
233
|
-
sx: [size === 'small' ? { p: 1 } : { p: 2 }],
|
|
234
|
-
// forceUpdate,
|
|
235
|
-
})
|
|
236
|
-
)}
|
|
237
|
-
{showOAuthLogin
|
|
238
|
-
? oauthProviderList.map((item) => (
|
|
239
|
-
<LoginMethodItem
|
|
240
|
-
t={t}
|
|
241
|
-
isLatest={lastLoginMethod && lastLoginMethod === item.provider}
|
|
242
|
-
key={item.provider}
|
|
243
|
-
title={LOGIN_PROVIDER_NAME[item.provider]}
|
|
244
|
-
icon={
|
|
245
|
-
<ProviderIcon
|
|
246
|
-
provider={item.provider}
|
|
247
|
-
sx={{
|
|
248
|
-
transform: 'scale(0.95)',
|
|
249
|
-
width: LOGIN_PROVIDER_ICON_SIZE,
|
|
250
|
-
height: LOGIN_PROVIDER_ICON_SIZE,
|
|
251
|
-
color: 'text.primary',
|
|
252
|
-
}}
|
|
253
|
-
/>
|
|
254
|
-
}
|
|
255
|
-
onClick={() => {
|
|
256
|
-
handleLoginOAuth(item);
|
|
257
|
-
connectState.retryConnect = () => {
|
|
258
|
-
handleLoginOAuth(item);
|
|
259
|
-
};
|
|
260
|
-
}}
|
|
261
|
-
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
262
|
-
/>
|
|
263
|
-
))
|
|
264
|
-
: null}
|
|
265
|
-
{showPasskeyLogin ? (
|
|
266
|
-
<PasskeyLoginItem
|
|
267
|
-
ref={passkeyLoginRef}
|
|
268
|
-
onSuccess={onSuccess}
|
|
269
|
-
onError={onError}
|
|
270
|
-
tokenState={tokenState}
|
|
271
|
-
behavior={passkeyBehavior}
|
|
272
|
-
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
273
|
-
onClick={() => {
|
|
274
|
-
localStorage.setItem(GA_LAST_LOGIN_METHOD, LOGIN_PROVIDER.PASSKEY);
|
|
275
|
-
const connectFn = passkeyLoginRef.current.connect;
|
|
276
|
-
connectState.chooseMethod = 'passkey';
|
|
277
|
-
connectState.walletMethod = ''; // 清除 wallet 登录方式,防止状态污染
|
|
278
|
-
connectState.retryConnect = () => {
|
|
279
|
-
passkeyState.verifying = true;
|
|
280
|
-
connectState.chooseMethod = 'passkey';
|
|
281
|
-
connectFn();
|
|
282
|
-
};
|
|
283
|
-
}}
|
|
284
|
-
slotProps={{
|
|
285
|
-
icon: {
|
|
286
|
-
sx: {
|
|
287
|
-
fontSize: LOGIN_PROVIDER_ICON_SIZE,
|
|
288
|
-
'& svg': {
|
|
289
|
-
fontSize: LOGIN_PROVIDER_ICON_SIZE,
|
|
290
|
-
width: '1em',
|
|
291
|
-
height: '1em',
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
}}
|
|
296
|
-
/>
|
|
297
|
-
) : null}
|
|
298
|
-
</Box>
|
|
299
|
-
) : null}
|
|
300
|
-
{customItems.map((item) => (!item ? null : item))}
|
|
301
|
-
</Box>
|
|
302
|
-
</Box>
|
|
303
|
-
</Box>
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
ConnectChooseList.propTypes = {
|
|
308
|
-
onSuccess: PropTypes.func,
|
|
309
|
-
onError: PropTypes.func,
|
|
310
|
-
size: PropTypes.oneOf(['small', 'normal', 'large']),
|
|
311
|
-
tokenState: PropTypes.object.isRequired,
|
|
312
|
-
webWalletUrl: PropTypes.string,
|
|
313
|
-
tokenKey: PropTypes.string.isRequired,
|
|
314
|
-
passkeyBehavior: PropTypes.oneOf(['none', 'both', 'only-existing', 'only-new']),
|
|
315
|
-
onReset: PropTypes.func,
|
|
316
|
-
showMobileLogin: PropTypes.bool,
|
|
317
|
-
showOAuthLogin: PropTypes.bool,
|
|
318
|
-
showPasskeyLogin: PropTypes.bool,
|
|
319
|
-
showWebLogin: PropTypes.bool,
|
|
320
|
-
showEmailLogin: PropTypes.bool,
|
|
321
|
-
oauthProviderList: PropTypes.array,
|
|
322
|
-
slotProps: PropTypes.object,
|
|
323
|
-
disableSwitchApp: PropTypes.bool,
|
|
324
|
-
forceUpdate: PropTypes.func,
|
|
325
|
-
magicToken: PropTypes.string,
|
|
326
|
-
baseUrl: PropTypes.string,
|
|
327
|
-
customItems: PropTypes.arrayOf(PropTypes.node),
|
|
328
|
-
};
|