@arcblock/did-connect-react 3.4.13 → 3.4.15
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/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 +8 -8
- package/src/Connect/components/login-item/connect-choose-list.jsx +14 -3
- package/src/Connect/components/login-item/connect-provider-list.jsx +14 -3
- package/src/Connect/components/login-item/mobile-login-item.jsx +5 -2
- package/src/Connect/components/login-item/passkey-login-item.jsx +7 -5
- package/src/Connect/components/login-item/web-login-item.jsx +4 -2
- package/src/Connect/connect.jsx +21 -3
- package/src/Connect/contexts/state.jsx +3 -2
- package/src/Connect/hooks/provider-list.js +6 -3
- package/src/Connect/plugins/email/list-item.jsx +1 -0
- package/src/Connect/plugins/email/placeholder.jsx +7 -0
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-connect-react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.15",
|
|
4
4
|
"description": "Client side library to work with DID Connect by ArcBlock.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "3.4.
|
|
36
|
-
"@arcblock/did": "^1.
|
|
37
|
-
"@arcblock/icons": "3.4.
|
|
38
|
-
"@arcblock/react-hooks": "3.4.
|
|
39
|
-
"@arcblock/ws": "^1.
|
|
35
|
+
"@arcblock/bridge": "3.4.15",
|
|
36
|
+
"@arcblock/did": "^1.29.4",
|
|
37
|
+
"@arcblock/icons": "3.4.15",
|
|
38
|
+
"@arcblock/react-hooks": "3.4.15",
|
|
39
|
+
"@arcblock/ws": "^1.29.4",
|
|
40
40
|
"@blocklet/constant": "^1.17.7",
|
|
41
41
|
"@fontsource/lexend": "^5.2.9",
|
|
42
42
|
"@iconify-icons/logos": "^1.2.36",
|
|
43
43
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
44
44
|
"@iconify/react": "^5.2.1",
|
|
45
|
-
"@ocap/util": "^1.
|
|
45
|
+
"@ocap/util": "^1.29.4",
|
|
46
46
|
"@simplewebauthn/browser": "^13.1.0",
|
|
47
47
|
"ahooks": "^3.8.5",
|
|
48
48
|
"axios": "^1.10.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
86
86
|
"jest": "^29.7.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "73039d82d507d9ec5408d8cfc67d9efeffae3e74"
|
|
89
89
|
}
|