@arcblock/did-connect-react 3.4.14 → 3.5.0
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/Connect/components/login-item/connect-choose-list.js +111 -111
- package/lib/Connect/components/login-item/connect-provider-list.js +180 -180
- package/lib/Connect/components/login-item/mobile-login-item.js +56 -56
- package/lib/Connect/components/login-item/passkey-login-item.js +27 -29
- package/lib/Connect/components/login-item/web-login-item.js +31 -29
- package/lib/Connect/connect.js +202 -197
- package/lib/Connect/contexts/state.js +19 -17
- package/lib/Connect/hooks/provider-list.js +33 -33
- package/lib/Connect/plugins/email/list-item.js +14 -14
- package/lib/Connect/plugins/email/placeholder.js +77 -76
- package/lib/package.json.js +1 -1
- package/package.json +14 -9
- 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 -317
- package/src/Connect/components/login-item/connect-provider-list.jsx +0 -462
- package/src/Connect/components/login-item/login-method-item.jsx +0 -139
- package/src/Connect/components/login-item/mobile-login-item.jsx +0 -181
- package/src/Connect/components/login-item/passkey-login-item.jsx +0 -54
- package/src/Connect/components/login-item/wallet-login-options.jsx +0 -129
- package/src/Connect/components/login-item/web-login-item.jsx +0 -157
- 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 -617
- package/src/Connect/contexts/state.jsx +0 -234
- 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 -165
- 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 -34
- package/src/Connect/plugins/email/placeholder.jsx +0 -365
- 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,8 +1,8 @@
|
|
|
1
1
|
import { jsx as O } from "react/jsx-runtime";
|
|
2
2
|
import r from "prop-types";
|
|
3
|
-
import { useState as
|
|
3
|
+
import { useState as h, use as W, useRef as D, useEffect as V, createContext as X } from "react";
|
|
4
4
|
import Y from "@arcblock/react-hooks/lib/useBrowser";
|
|
5
|
-
import { useUpdate as Z, useCreation as n, useMemoizedFn as
|
|
5
|
+
import { useUpdate as Z, useCreation as n, useMemoizedFn as A, useLatest as $, useReactive as ee, useSize as te } from "ahooks";
|
|
6
6
|
import E from "lodash/isUndefined";
|
|
7
7
|
import oe from "lodash/noop";
|
|
8
8
|
import { Box as re } from "@mui/material";
|
|
@@ -10,7 +10,7 @@ import { translate as ne } from "@arcblock/ux/lib/Locale/util";
|
|
|
10
10
|
import { getMaster as T, getCurrentApp as se } from "@arcblock/ux/lib/Util/federated";
|
|
11
11
|
import { getDIDMotifInfo as ie } from "@arcblock/did-motif";
|
|
12
12
|
import { isEthereumDid as ce, getDIDColor as pe } from "@arcblock/ux/lib/Util";
|
|
13
|
-
import {
|
|
13
|
+
import { LAST_USED_LOGIN_METHOD as ue } from "@arcblock/ux/lib/Util/constant";
|
|
14
14
|
import ae from "../hooks/use-apps.js";
|
|
15
15
|
import { SessionContext as de } from "../../Session/context.js";
|
|
16
16
|
import le from "../assets/locale.js";
|
|
@@ -30,22 +30,24 @@ function me({
|
|
|
30
30
|
testOnlyBorderColor: l = void 0,
|
|
31
31
|
...L
|
|
32
32
|
}) {
|
|
33
|
-
const w = Z(), [f, j] =
|
|
33
|
+
const w = Z(), [f, j] = h([]), [N, U] = h(!1), [m, q] = h(""), z = n(() => new Map(f.map((e) => [e.name, e])), [f]), J = A((e) => z.get(e)), _ = $(m), k = A((e, i = {}) => ne(le, e, d, "en", i)), g = W(de), o = ee({
|
|
34
34
|
sourceAppPid: void 0,
|
|
35
35
|
status: "created",
|
|
36
36
|
autoActiveWebview: !0,
|
|
37
37
|
deeplink: void 0,
|
|
38
38
|
chooseMethod: "",
|
|
39
|
+
walletMethod: "",
|
|
40
|
+
// 细分的 wallet 登录方式,如 wallet-ext, wallet-web, wallet-scan 等
|
|
39
41
|
retryConnect: oe
|
|
40
|
-
}),
|
|
42
|
+
}), B = D({
|
|
41
43
|
cancelCount: 0
|
|
42
|
-
}), s = Y(), { appInfoList: b, autoGenerateSourceAppPid:
|
|
44
|
+
}), s = Y(), { appInfoList: b, autoGenerateSourceAppPid: S, canSwitchApp: v } = ae({
|
|
43
45
|
blocklet: c,
|
|
44
46
|
connectState: o,
|
|
45
47
|
action: a,
|
|
46
48
|
sourceAppPid: t?.sourceAppPid,
|
|
47
49
|
enableSwitchApp: t?.forceSwitch || t?.enableSwitchApp
|
|
48
|
-
}),
|
|
50
|
+
}), G = n(() => {
|
|
49
51
|
try {
|
|
50
52
|
return localStorage.getItem(ue);
|
|
51
53
|
} catch {
|
|
@@ -55,7 +57,7 @@ function me({
|
|
|
55
57
|
if (v)
|
|
56
58
|
return {
|
|
57
59
|
...t,
|
|
58
|
-
sourceAppPid: E(o.sourceAppPid) ?
|
|
60
|
+
sourceAppPid: E(o.sourceAppPid) ? S : o.sourceAppPid
|
|
59
61
|
};
|
|
60
62
|
const e = T(c)?.appPid, i = T(globalThis.blocklet)?.appPid;
|
|
61
63
|
return g?.session?.user && (e === i || !e) ? E(t?.sourceAppPid) ? {
|
|
@@ -63,14 +65,14 @@ function me({
|
|
|
63
65
|
sourceAppPid: g.session.user?.sourceAppPid
|
|
64
66
|
} : t : {
|
|
65
67
|
...t,
|
|
66
|
-
sourceAppPid:
|
|
68
|
+
sourceAppPid: S
|
|
67
69
|
};
|
|
68
70
|
}, [
|
|
69
71
|
v,
|
|
70
72
|
t,
|
|
71
73
|
o.sourceAppPid,
|
|
72
74
|
a,
|
|
73
|
-
|
|
75
|
+
S,
|
|
74
76
|
g?.session?.user
|
|
75
77
|
]), F = n(() => {
|
|
76
78
|
const e = window?.navigator?.userAgent;
|
|
@@ -79,7 +81,7 @@ function me({
|
|
|
79
81
|
V(() => {
|
|
80
82
|
o.sourceAppPid = p.sourceAppPid;
|
|
81
83
|
}, [p.sourceAppPid]);
|
|
82
|
-
const H =
|
|
84
|
+
const H = A((e) => {
|
|
83
85
|
o.status = e || "created";
|
|
84
86
|
}), u = globalThis.blocklet ? se(c) : globalThis.env, I = n(() => {
|
|
85
87
|
if (l)
|
|
@@ -91,7 +93,7 @@ function me({
|
|
|
91
93
|
isMobile: s.mobile.any,
|
|
92
94
|
matchSmallScreen: y,
|
|
93
95
|
connectState: o,
|
|
94
|
-
staticState:
|
|
96
|
+
staticState: B,
|
|
95
97
|
reactiveState: o,
|
|
96
98
|
appInfoList: b,
|
|
97
99
|
extraParams: p,
|
|
@@ -100,22 +102,22 @@ function me({
|
|
|
100
102
|
browserBrand: F,
|
|
101
103
|
currentAppInfo: u,
|
|
102
104
|
currentAppColor: I,
|
|
103
|
-
t:
|
|
105
|
+
t: k,
|
|
104
106
|
locale: d,
|
|
105
107
|
action: a,
|
|
106
108
|
changeStatus: H,
|
|
107
109
|
getPlugin: J,
|
|
108
|
-
latestActivePlugin:
|
|
110
|
+
latestActivePlugin: _,
|
|
109
111
|
plugins: f,
|
|
110
112
|
setPlugins: j,
|
|
111
113
|
selectedPlugin: m,
|
|
112
|
-
setSelectedPlugin:
|
|
114
|
+
setSelectedPlugin: q,
|
|
113
115
|
forceUpdate: w,
|
|
114
116
|
// 控制钱包登录的显示
|
|
115
117
|
showWalletOptions: N,
|
|
116
|
-
setShowWalletOptions:
|
|
118
|
+
setShowWalletOptions: U,
|
|
117
119
|
// 用于记录上一次登录方式
|
|
118
|
-
lastLoginMethod:
|
|
120
|
+
lastLoginMethod: G
|
|
119
121
|
}), [
|
|
120
122
|
s.wallet,
|
|
121
123
|
s.arcSphere,
|
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
import { useBrowser as C } from "@arcblock/react-hooks";
|
|
2
|
-
import { useRequest as
|
|
3
|
-
import
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { getFederatedEnabled as
|
|
6
|
-
import { useState as
|
|
7
|
-
const
|
|
2
|
+
import { useRequest as D, useCreation as L } from "ahooks";
|
|
3
|
+
import s from "lodash/isNil";
|
|
4
|
+
import { LOGIN_PROVIDER as i, WALLET_LOGIN_METHOD as I } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { getFederatedEnabled as O, getMaster as y, getBlockletData as W } from "@arcblock/ux/lib/Util/federated";
|
|
6
|
+
import { useState as N } from "react";
|
|
7
|
+
const R = async ({ sourceAppPid: d }) => {
|
|
8
8
|
const t = globalThis?.blocklet;
|
|
9
9
|
if (!t)
|
|
10
10
|
return {
|
|
11
|
-
[
|
|
11
|
+
[i.WALLET]: {
|
|
12
12
|
order: 0,
|
|
13
13
|
enabled: !0,
|
|
14
14
|
showQrcode: !0
|
|
15
15
|
},
|
|
16
|
-
[
|
|
16
|
+
[i.PASSKEY]: {
|
|
17
17
|
order: 1,
|
|
18
18
|
enabled: !0
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
const l =
|
|
22
|
-
return l && e?.appPid && d === e?.appPid ? (await
|
|
23
|
-
},
|
|
24
|
-
const t = await
|
|
25
|
-
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !
|
|
21
|
+
const l = O(t), e = y(t);
|
|
22
|
+
return l && e?.appPid && d === e?.appPid ? (await W(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
|
|
23
|
+
}, S = async ({ sourceAppPid: d } = {}) => {
|
|
24
|
+
const t = await R({ sourceAppPid: d });
|
|
25
|
+
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !s(e?.order) && !s(o?.order) ? e.order - o.order : s(e?.order) ? 1 : -1);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function q({
|
|
28
28
|
allowWallet: d = !0,
|
|
29
29
|
passkeyBehavior: t = "none",
|
|
30
30
|
action: l,
|
|
31
31
|
sourceAppPid: e,
|
|
32
32
|
mode: o = "dialog",
|
|
33
33
|
blocklet: P = globalThis.blocklet,
|
|
34
|
-
isSmallView:
|
|
34
|
+
isSmallView: p = !1,
|
|
35
35
|
lastLoginMethod: a = ""
|
|
36
36
|
}) {
|
|
37
|
-
const [m,
|
|
37
|
+
const [m, v] = N(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], A = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], u = C(), { data: h = [] } = D(
|
|
38
38
|
async () => {
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
return
|
|
39
|
+
v(!0);
|
|
40
|
+
const n = await S({ sourceAppPid: e });
|
|
41
|
+
return v(!1), n;
|
|
42
42
|
},
|
|
43
43
|
{ refreshDeps: [e] }
|
|
44
|
-
), f =
|
|
45
|
-
const
|
|
46
|
-
return
|
|
44
|
+
), f = L(() => {
|
|
45
|
+
const n = globalThis?.blocklet?.DID_CONNECT_ENABLED_PROVIDERS?.split(",") || [];
|
|
46
|
+
return h.filter((r) => n.length > 0 && !n.includes(r.provider) ? !1 : r.provider === i.WALLET ? d : r.provider === i.PASSKEY ? t !== "none" && !u.wallet && !u.arcSphere : r.provider === i.EMAIL ? A.includes(l) && (P?.settings?.notification?.email?.enabled ?? !1) : !(r.type === "oauth" && !w.includes(l))).sort((r, c) => {
|
|
47
47
|
if (a) {
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
48
|
+
const g = Object.values(I).includes(a), E = g ? r.provider === i.WALLET : r.provider === a, b = g ? c.provider === i.WALLET : c.provider === a;
|
|
49
|
+
if (E && !b)
|
|
50
50
|
return -1;
|
|
51
|
-
if (!
|
|
51
|
+
if (!E && b)
|
|
52
52
|
return 1;
|
|
53
53
|
}
|
|
54
|
-
return !
|
|
54
|
+
return !s(r?.order) && !s(c?.order) ? r.order - c.order : s(r?.order) ? s(c?.order) ? 0 : 1 : -1;
|
|
55
55
|
});
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
return globalThis?.blocklet ? !!(f.find((r) => r.provider ===
|
|
59
|
-
}, [o,
|
|
56
|
+
}, [h, a]), T = L(() => {
|
|
57
|
+
const n = o === "drawer" || p && u.mobile.any;
|
|
58
|
+
return globalThis?.blocklet ? !!(f.find((r) => r.provider === i.WALLET)?.showQrcode !== !0 || n) : !!n;
|
|
59
|
+
}, [o, p, f]);
|
|
60
60
|
return {
|
|
61
|
-
hideChooseList:
|
|
62
|
-
hideQRCode:
|
|
61
|
+
hideChooseList: L(() => !1),
|
|
62
|
+
hideQRCode: T,
|
|
63
63
|
providerList: f,
|
|
64
64
|
loadingProviderList: m
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
export {
|
|
68
|
-
|
|
68
|
+
q as default
|
|
69
69
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMemoizedFn as
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import a from "prop-types";
|
|
3
|
+
import { useMemoizedFn as c } from "ahooks";
|
|
4
4
|
import p from "@iconify-icons/tabler/mail-filled";
|
|
5
5
|
import { LOGIN_PROVIDER as t, LOGIN_PROVIDER_NAME as I } from "@arcblock/ux/lib/Util/constant";
|
|
6
6
|
import { GA_LAST_LOGIN_METHOD as L } from "@arcblock/ux/lib/withTracker/constant";
|
|
7
|
-
import
|
|
8
|
-
import { useStateContext as
|
|
9
|
-
function u({ ...
|
|
10
|
-
const { setSelectedPlugin:
|
|
7
|
+
import M from "../../components/login-item/login-method-item.js";
|
|
8
|
+
import { useStateContext as f } from "../../contexts/state.js";
|
|
9
|
+
function u({ ...n }) {
|
|
10
|
+
const { setSelectedPlugin: r, getPlugin: m, connectState: e, lastLoginMethod: i } = f(), s = c(() => {
|
|
11
11
|
localStorage.setItem(L, t.EMAIL);
|
|
12
|
-
const o =
|
|
13
|
-
o.state.reset(), o.state.status = "creating",
|
|
12
|
+
const o = m(t.EMAIL);
|
|
13
|
+
o.state.reset(), o.state.status = "creating", e.chooseMethod = t.EMAIL, e.walletMethod = "", r(o);
|
|
14
14
|
});
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
|
|
15
|
+
return /* @__PURE__ */ l(
|
|
16
|
+
M,
|
|
17
17
|
{
|
|
18
|
-
...
|
|
19
|
-
isLatest:
|
|
18
|
+
...n,
|
|
19
|
+
isLatest: i && i === t.EMAIL,
|
|
20
20
|
title: I[t.EMAIL],
|
|
21
21
|
icon: p,
|
|
22
22
|
onClick: s
|
|
@@ -24,7 +24,7 @@ function u({ ...i }) {
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
u.propTypes = {
|
|
27
|
-
onClick:
|
|
27
|
+
onClick: a.func
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
30
|
u as default
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as n, Fragment as s, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import j from "@arcblock/ux/lib/LoadingMask";
|
|
3
|
-
import { Typography as T, TextField as B, Box as p, CircularProgress as
|
|
4
|
-
import { useMemoizedFn as d, useCreation as F, useReactive as
|
|
3
|
+
import { Typography as T, TextField as B, Box as p, CircularProgress as A } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as d, useCreation as F, useReactive as H, useInterval as N } from "ahooks";
|
|
5
5
|
import c from "prop-types";
|
|
6
|
-
import { joinURL as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { useEffect as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
import { joinURL as G, withQuery as I } from "ufo";
|
|
7
|
+
import K from "@arcblock/ux/lib/Toast";
|
|
8
|
+
import U from "@arcblock/ux/lib/VerificationCode";
|
|
9
|
+
import { useEffect as q } from "react";
|
|
10
|
+
import E from "lodash/noop";
|
|
11
|
+
import W from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
12
|
+
import { LAST_USED_LOGIN_METHOD as k, LOGIN_PROVIDER as v } from "@arcblock/ux/lib/Util/constant";
|
|
13
|
+
import R from "../../components/back-button.js";
|
|
14
|
+
import V from "../../components/action-button.js";
|
|
15
|
+
import { useStateContext as Q } from "../../contexts/state.js";
|
|
16
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as X, VERIFY_CODE_LENGTH as Y, CHECK_STATUS_INTERVAL as $ } from "../../../constant.js";
|
|
17
|
+
import { createAxios as J, debug as y } from "../../../utils.js";
|
|
18
|
+
function Z({
|
|
19
|
+
fallback: _ = null,
|
|
19
20
|
state: o,
|
|
20
|
-
forceUpdate: t =
|
|
21
|
-
onSuccess: h =
|
|
22
|
-
t:
|
|
21
|
+
forceUpdate: t = E,
|
|
22
|
+
onSuccess: h = E,
|
|
23
|
+
t: w = E
|
|
23
24
|
}) {
|
|
24
|
-
const { setSelectedPlugin:
|
|
25
|
-
baseURL:
|
|
26
|
-
}), [o.baseUrl]), e =
|
|
25
|
+
const { setSelectedPlugin: D, locale: m, connectState: u, action: f, extraParams: M } = Q(), l = d((r, i = {}) => w(r, i, m)), g = F(() => J({
|
|
26
|
+
baseURL: G(o.baseUrl, X, "/api/user")
|
|
27
|
+
}), [o.baseUrl]), e = H({
|
|
27
28
|
email: "",
|
|
28
29
|
code: "",
|
|
29
30
|
codeId: "",
|
|
@@ -33,15 +34,15 @@ function $({
|
|
|
33
34
|
loadingSendCode: !1,
|
|
34
35
|
loadingVerifyCode: !1,
|
|
35
36
|
error: ""
|
|
36
|
-
}),
|
|
37
|
+
}), P = d(() => {
|
|
37
38
|
e.email = "", e.code = "", e.codeId = "", e.verifyMode = e.defaultVerifyMode, e.loadingSendCode = !1, e.loadingVerifyCode = !1, e.error = "";
|
|
38
|
-
}),
|
|
39
|
+
}), b = d(async () => {
|
|
39
40
|
if (!e.email || !e.email.trim()) {
|
|
40
|
-
e.error =
|
|
41
|
+
e.error = l("emailRequired");
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email)) {
|
|
44
|
-
e.error =
|
|
45
|
+
e.error = l("emailInvalid");
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
e.error = "";
|
|
@@ -49,7 +50,7 @@ function $({
|
|
|
49
50
|
e.loadingSendCode = !0;
|
|
50
51
|
let i = !1;
|
|
51
52
|
["login"].includes(f) && (u.sourceAppPid || (i = !0));
|
|
52
|
-
const { data: x } = await g.post(
|
|
53
|
+
const { data: x } = await g.post(I("/email/sendCode", { locale: m }), {
|
|
53
54
|
email: e.email,
|
|
54
55
|
sourceAppPid: u.sourceAppPid,
|
|
55
56
|
useMagicLink: i
|
|
@@ -61,17 +62,17 @@ function $({
|
|
|
61
62
|
} finally {
|
|
62
63
|
e.loadingSendCode = !1, t();
|
|
63
64
|
}
|
|
64
|
-
}),
|
|
65
|
-
if (e.code.length ===
|
|
65
|
+
}), S = d(async () => {
|
|
66
|
+
if (e.code.length === Y)
|
|
66
67
|
try {
|
|
67
68
|
e.loadingVerifyCode = !0;
|
|
68
|
-
const { data: r } = await g.post(
|
|
69
|
-
...
|
|
69
|
+
const { data: r } = await g.post(I("/email/login", { locale: m }), {
|
|
70
|
+
...M,
|
|
70
71
|
action: f,
|
|
71
72
|
code: e.code,
|
|
72
73
|
sourceAppPid: u.sourceAppPid
|
|
73
74
|
});
|
|
74
|
-
y("Email login succeed (use code)", { loginResult: r }), await h(
|
|
75
|
+
y("Email login succeed (use code)", { loginResult: r }), localStorage.setItem(k, v.EMAIL), await h(
|
|
75
76
|
{
|
|
76
77
|
...r,
|
|
77
78
|
encrypted: !1
|
|
@@ -80,19 +81,19 @@ function $({
|
|
|
80
81
|
), o.status = "succeed";
|
|
81
82
|
} catch (r) {
|
|
82
83
|
const i = r?.response?.data || r?.message;
|
|
83
|
-
|
|
84
|
+
K.error(i), y("Email login failed (use code)", { error: r });
|
|
84
85
|
} finally {
|
|
85
86
|
e.loadingVerifyCode = !1, t();
|
|
86
87
|
}
|
|
87
|
-
}),
|
|
88
|
+
}), O = d(async () => {
|
|
88
89
|
o.status = "verifying", t();
|
|
89
90
|
try {
|
|
90
|
-
const { data: r } = await g.post(
|
|
91
|
-
...
|
|
91
|
+
const { data: r } = await g.post(I("/email/login", { locale: m }), {
|
|
92
|
+
...M,
|
|
92
93
|
action: f,
|
|
93
94
|
magicToken: o.magicToken
|
|
94
95
|
});
|
|
95
|
-
y("Email login succeed (use magic link)", { loginResult: r }), await h(
|
|
96
|
+
y("Email login succeed (use magic link)", { loginResult: r }), localStorage.setItem(k, v.EMAIL), await h(
|
|
96
97
|
{
|
|
97
98
|
...r,
|
|
98
99
|
encrypted: !1
|
|
@@ -104,28 +105,28 @@ function $({
|
|
|
104
105
|
o.status = "error", o.error = i, y("Email login failed (use magic link)", { error: r });
|
|
105
106
|
}
|
|
106
107
|
t();
|
|
107
|
-
}),
|
|
108
|
+
}), L = e.verifyMode === "magicLink" && o.status === "sending" && // 如果正在校验验证码,则不轮询状态
|
|
108
109
|
!e.loadingVerifyCode && e.codeId, z = d(async () => {
|
|
109
|
-
if (
|
|
110
|
+
if (L) {
|
|
110
111
|
try {
|
|
111
112
|
const { data: r } = await g.get("/email/status", {
|
|
112
113
|
params: {
|
|
113
114
|
codeId: e.codeId
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
|
-
r.verified && (o.status = "succeed",
|
|
117
|
+
r.verified && (o.status = "succeed", P(), localStorage.setItem(k, v.EMAIL), await h({ encrypted: !1 }, (i) => i));
|
|
117
118
|
} catch (r) {
|
|
118
119
|
console.error("check status error", r);
|
|
119
120
|
}
|
|
120
121
|
t();
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
N(z, L ? $ : void 0), q(() => {
|
|
125
|
+
P(), (u.sourceAppPid || !["login"].includes(f)) && (e.defaultVerifyMode = "code"), o.magicToken && O();
|
|
125
126
|
}, [o]);
|
|
126
127
|
let C = null;
|
|
127
128
|
if (o.status === "creating")
|
|
128
|
-
C = /* @__PURE__ */
|
|
129
|
+
C = /* @__PURE__ */ n(s, { children: [
|
|
129
130
|
/* @__PURE__ */ a(
|
|
130
131
|
T,
|
|
131
132
|
{
|
|
@@ -134,7 +135,7 @@ function $({
|
|
|
134
135
|
textAlign: "center",
|
|
135
136
|
color: "text.secondary"
|
|
136
137
|
},
|
|
137
|
-
children:
|
|
138
|
+
children: l("emailPlaceholder")
|
|
138
139
|
}
|
|
139
140
|
),
|
|
140
141
|
/* @__PURE__ */ a(
|
|
@@ -144,15 +145,15 @@ function $({
|
|
|
144
145
|
fullWidth: !0,
|
|
145
146
|
type: "email",
|
|
146
147
|
variant: "outlined",
|
|
147
|
-
label:
|
|
148
|
-
placeholder:
|
|
148
|
+
label: l("email"),
|
|
149
|
+
placeholder: l("emailPlaceholder"),
|
|
149
150
|
size: "small",
|
|
150
151
|
value: e.email,
|
|
151
152
|
onChange: (r) => {
|
|
152
153
|
e.email = r.target.value;
|
|
153
154
|
},
|
|
154
155
|
onKeyDown: (r) => {
|
|
155
|
-
r.key === "Enter" &&
|
|
156
|
+
r.key === "Enter" && b(e.email);
|
|
156
157
|
},
|
|
157
158
|
sx: {
|
|
158
159
|
maxWidth: 320,
|
|
@@ -171,17 +172,17 @@ function $({
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
),
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ n(p, { sx: { display: "flex", gap: 1 }, children: [
|
|
175
176
|
/* @__PURE__ */ a(
|
|
176
|
-
|
|
177
|
+
R,
|
|
177
178
|
{
|
|
178
179
|
onClick: () => {
|
|
179
|
-
o.reset(),
|
|
180
|
+
o.reset(), D();
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
),
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
184
|
+
/* @__PURE__ */ n(
|
|
185
|
+
V,
|
|
185
186
|
{
|
|
186
187
|
sx: {
|
|
187
188
|
color: "primary.main",
|
|
@@ -189,50 +190,50 @@ function $({
|
|
|
189
190
|
},
|
|
190
191
|
disabled: e.loadingSendCode,
|
|
191
192
|
onClick: () => {
|
|
192
|
-
|
|
193
|
+
b(e.email);
|
|
193
194
|
},
|
|
194
195
|
children: [
|
|
195
|
-
e.loadingSendCode ? /* @__PURE__ */ a(
|
|
196
|
-
|
|
196
|
+
e.loadingSendCode ? /* @__PURE__ */ a(A, { color: "inherit", size: 14, sx: { mr: 1 } }) : null,
|
|
197
|
+
l("sendCode")
|
|
197
198
|
]
|
|
198
199
|
}
|
|
199
200
|
)
|
|
200
201
|
] })
|
|
201
202
|
] });
|
|
202
203
|
else if (o.status === "sending")
|
|
203
|
-
C = /* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */ a(T, { variant: "body2", sx: { textAlign: "center", color: "text.secondary" }, children: e.verifyMode === "magicLink" ? /* @__PURE__ */
|
|
206
|
-
|
|
204
|
+
C = /* @__PURE__ */ n(s, { children: [
|
|
205
|
+
/* @__PURE__ */ n(p, { sx: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
|
|
206
|
+
/* @__PURE__ */ a(T, { variant: "body2", sx: { textAlign: "center", color: "text.secondary" }, children: e.verifyMode === "magicLink" ? /* @__PURE__ */ n(s, { children: [
|
|
207
|
+
l("verifyEmail"),
|
|
207
208
|
/* @__PURE__ */ a("br", {}),
|
|
208
|
-
|
|
209
|
-
] }) :
|
|
209
|
+
l("orUseCodePlaceholder")
|
|
210
|
+
] }) : l("codePlaceholder") }),
|
|
210
211
|
/* @__PURE__ */ a(s, {})
|
|
211
212
|
] }),
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ n(s, { children: [
|
|
213
214
|
/* @__PURE__ */ a(
|
|
214
|
-
|
|
215
|
+
U,
|
|
215
216
|
{
|
|
216
217
|
code: e.code,
|
|
217
218
|
onChange: (r) => {
|
|
218
219
|
e.code = r;
|
|
219
220
|
},
|
|
220
221
|
onComplete: () => {
|
|
221
|
-
|
|
222
|
+
S();
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
225
|
),
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ n(p, { sx: { display: "flex", gap: 1 }, children: [
|
|
226
227
|
/* @__PURE__ */ a(
|
|
227
|
-
|
|
228
|
+
R,
|
|
228
229
|
{
|
|
229
230
|
onClick: () => {
|
|
230
231
|
e.code = "", o.status = "creating", t();
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
),
|
|
234
|
-
/* @__PURE__ */
|
|
235
|
-
|
|
235
|
+
/* @__PURE__ */ n(
|
|
236
|
+
V,
|
|
236
237
|
{
|
|
237
238
|
sx: {
|
|
238
239
|
color: "primary.main",
|
|
@@ -240,11 +241,11 @@ function $({
|
|
|
240
241
|
},
|
|
241
242
|
disabled: e.loadingVerifyCode,
|
|
242
243
|
onClick: () => {
|
|
243
|
-
|
|
244
|
+
S();
|
|
244
245
|
},
|
|
245
246
|
children: [
|
|
246
|
-
e.loadingVerifyCode ? /* @__PURE__ */ a(
|
|
247
|
-
|
|
247
|
+
e.loadingVerifyCode ? /* @__PURE__ */ a(A, { color: "inherit", size: 14, sx: { mr: 1 } }) : null,
|
|
248
|
+
l("confirm")
|
|
248
249
|
]
|
|
249
250
|
}
|
|
250
251
|
)
|
|
@@ -252,8 +253,8 @@ function $({
|
|
|
252
253
|
] })
|
|
253
254
|
] });
|
|
254
255
|
else
|
|
255
|
-
return
|
|
256
|
-
return /* @__PURE__ */
|
|
256
|
+
return _;
|
|
257
|
+
return /* @__PURE__ */ n(
|
|
257
258
|
p,
|
|
258
259
|
{
|
|
259
260
|
sx: {
|
|
@@ -265,13 +266,13 @@ function $({
|
|
|
265
266
|
pb: 1
|
|
266
267
|
},
|
|
267
268
|
children: [
|
|
268
|
-
/* @__PURE__ */ a(j, { size: 52, borderRadius: 12, children: /* @__PURE__ */ a(
|
|
269
|
+
/* @__PURE__ */ a(j, { size: 52, borderRadius: 12, children: /* @__PURE__ */ a(W, { provider: "email" }) }),
|
|
269
270
|
C
|
|
270
271
|
]
|
|
271
272
|
}
|
|
272
273
|
);
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
Z.propTypes = {
|
|
275
276
|
fallback: c.any,
|
|
276
277
|
state: c.object.isRequired,
|
|
277
278
|
forceUpdate: c.func,
|
|
@@ -279,5 +280,5 @@ $.propTypes = {
|
|
|
279
280
|
t: c.func
|
|
280
281
|
};
|
|
281
282
|
export {
|
|
282
|
-
|
|
283
|
+
Z as default
|
|
283
284
|
};
|
package/lib/package.json.js
CHANGED