@arcblock/did-connect-react 3.1.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/LICENSE +13 -0
- package/README.md +134 -0
- package/lib/Address/index.js +4 -0
- package/lib/Avatar/index.js +4 -0
- package/lib/Button/index.js +17 -0
- package/lib/Connect/assets/locale.js +143 -0
- package/lib/Connect/assets/login-bg.png +0 -0
- package/lib/Connect/assets/login-slogan.js +9 -0
- package/lib/Connect/components/action-button.js +26 -0
- package/lib/Connect/components/app-tips.js +132 -0
- package/lib/Connect/components/auto-height.js +31 -0
- package/lib/Connect/components/back-button.js +24 -0
- package/lib/Connect/components/connect-status.js +263 -0
- package/lib/Connect/components/did-connect-title.js +126 -0
- package/lib/Connect/components/download-tips.js +52 -0
- package/lib/Connect/components/loading.js +26 -0
- package/lib/Connect/components/login-item/connect-choose-list.js +249 -0
- package/lib/Connect/components/login-item/login-method-item.js +129 -0
- package/lib/Connect/components/login-item/mobile-login-item.js +114 -0
- package/lib/Connect/components/login-item/passkey-login-item.js +44 -0
- package/lib/Connect/components/login-item/web-login-item.js +97 -0
- package/lib/Connect/components/mask-overlay.js +34 -0
- package/lib/Connect/components/refresh-overlay.js +57 -0
- package/lib/Connect/components/switch-app.js +70 -0
- package/lib/Connect/contexts/state.js +142 -0
- package/lib/Connect/fullpage.js +5 -0
- package/lib/Connect/hooks/auth-url.js +23 -0
- package/lib/Connect/hooks/method-list.js +46 -0
- package/lib/Connect/hooks/page-show.js +17 -0
- package/lib/Connect/hooks/security.js +27 -0
- package/lib/Connect/hooks/token.js +305 -0
- package/lib/Connect/hooks/use-apps.js +19 -0
- package/lib/Connect/hooks/use-quick-connect.js +97 -0
- package/lib/Connect/index.js +498 -0
- package/lib/Connect/landing-page.js +5 -0
- package/lib/Connect/plugins/email/index.js +62 -0
- package/lib/Connect/plugins/email/list-item.js +28 -0
- package/lib/Connect/plugins/email/placeholder.js +283 -0
- package/lib/Connect/plugins/index.js +4 -0
- package/lib/Connect/use-connect.js +164 -0
- package/lib/Connect/with-blocklet.js +15 -0
- package/lib/Connect/with-bridge-call.js +108 -0
- package/lib/Federated/context.js +61 -0
- package/lib/Federated/index.js +7 -0
- package/lib/Logo/index.js +4 -0
- package/lib/OAuth/context.js +234 -0
- package/lib/OAuth/guest.svg.js +5 -0
- package/lib/OAuth/index.js +7 -0
- package/lib/OAuth/passport-switcher.js +114 -0
- package/lib/Passkey/actions.js +165 -0
- package/lib/Passkey/constants.js +4 -0
- package/lib/Passkey/context.js +266 -0
- package/lib/Passkey/dialog.js +277 -0
- package/lib/Passkey/icon.js +13 -0
- package/lib/Passkey/index.js +9 -0
- package/lib/Service/index.js +62 -0
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +135 -0
- package/lib/Session/assets/did-spaces-guide-icon.svg.js +9 -0
- package/lib/Session/context.js +5 -0
- package/lib/Session/did-spaces-guide.js +136 -0
- package/lib/Session/hooks/use-federated.js +64 -0
- package/lib/Session/hooks/use-mobile.js +8 -0
- package/lib/Session/hooks/use-protected-routes.js +11 -0
- package/lib/Session/hooks/use-session-token.js +169 -0
- package/lib/Session/hooks/use-verify.js +45 -0
- package/lib/Session/index.js +896 -0
- package/lib/Session/libs/constants.js +15 -0
- package/lib/Session/libs/did-spaces.js +10 -0
- package/lib/Session/libs/federated.js +42 -0
- package/lib/Session/libs/index.js +15 -0
- package/lib/Session/libs/locales.js +161 -0
- package/lib/Session/libs/login-mobile.js +55 -0
- package/lib/Session/window-focus-aware.js +17 -0
- package/lib/SessionManager/index.js +4 -0
- package/lib/Storage/engine/cookie.js +21 -0
- package/lib/Storage/engine/local-storage.js +36 -0
- package/lib/Storage/index.js +23 -0
- package/lib/User/index.js +6 -0
- package/lib/User/use-did.js +59 -0
- package/lib/User/wrap-did.js +13 -0
- package/lib/WebWalletSWKeeper/index.js +5 -0
- package/lib/constant.js +22 -0
- package/lib/error.js +8 -0
- package/lib/hooks/use-locale.js +7 -0
- package/lib/index.js +33 -0
- package/lib/locales/en.js +17 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/zh.js +17 -0
- package/lib/package.json.js +7 -0
- package/lib/types.d.ts +355 -0
- package/lib/utils.js +214 -0
- package/package.json +84 -0
- package/src/Address/index.jsx +2 -0
- package/src/Avatar/index.jsx +2 -0
- package/src/Button/Button.stories.jsx +7 -0
- package/src/Button/index.jsx +21 -0
- package/src/Connect/Connect.stories.jsx +34 -0
- package/src/Connect/assets/locale.js +145 -0
- package/src/Connect/assets/login-bg.png +0 -0
- package/src/Connect/assets/login-slogan.js +7 -0
- package/src/Connect/components/action-button.jsx +22 -0
- package/src/Connect/components/app-tips.jsx +156 -0
- package/src/Connect/components/auto-height.jsx +38 -0
- package/src/Connect/components/back-button.jsx +23 -0
- package/src/Connect/components/connect-status.jsx +259 -0
- package/src/Connect/components/did-connect-title.jsx +106 -0
- package/src/Connect/components/download-tips.jsx +55 -0
- package/src/Connect/components/loading.jsx +25 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +304 -0
- package/src/Connect/components/login-item/login-method-item.jsx +118 -0
- package/src/Connect/components/login-item/mobile-login-item.jsx +179 -0
- package/src/Connect/components/login-item/passkey-login-item.jsx +52 -0
- package/src/Connect/components/login-item/web-login-item.jsx +149 -0
- package/src/Connect/components/mask-overlay.jsx +32 -0
- package/src/Connect/components/refresh-overlay.jsx +52 -0
- package/src/Connect/components/switch-app.jsx +69 -0
- package/src/Connect/contexts/state.jsx +219 -0
- package/src/Connect/fullpage.jsx +3 -0
- package/src/Connect/hooks/auth-url.js +31 -0
- package/src/Connect/hooks/method-list.js +121 -0
- package/src/Connect/hooks/page-show.js +24 -0
- package/src/Connect/hooks/security.js +40 -0
- package/src/Connect/hooks/token.js +639 -0
- package/src/Connect/hooks/use-apps.js +69 -0
- package/src/Connect/hooks/use-quick-connect.js +130 -0
- package/src/Connect/index.jsx +600 -0
- package/src/Connect/landing-page.jsx +3 -0
- package/src/Connect/plugins/email/index.jsx +82 -0
- package/src/Connect/plugins/email/list-item.jsx +31 -0
- package/src/Connect/plugins/email/placeholder.jsx +365 -0
- package/src/Connect/plugins/index.js +2 -0
- package/src/Connect/use-connect.jsx +321 -0
- package/src/Connect/with-blocklet.jsx +26 -0
- package/src/Connect/with-bridge-call.jsx +138 -0
- package/src/Federated/context.jsx +93 -0
- package/src/Federated/index.jsx +1 -0
- package/src/Logo/index.jsx +2 -0
- package/src/OAuth/context.jsx +346 -0
- package/src/OAuth/guest.svg +20 -0
- package/src/OAuth/index.jsx +1 -0
- package/src/OAuth/passport-switcher.jsx +133 -0
- package/src/Passkey/actions.jsx +212 -0
- package/src/Passkey/constants.js +2 -0
- package/src/Passkey/context.jsx +381 -0
- package/src/Passkey/dialog.jsx +391 -0
- package/src/Passkey/icon.jsx +10 -0
- package/src/Passkey/index.jsx +2 -0
- package/src/Service/index.jsx +96 -0
- package/src/Session/assets/did-spaces-guide-cover.svg +128 -0
- package/src/Session/assets/did-spaces-guide-icon.svg +7 -0
- package/src/Session/context.jsx +7 -0
- package/src/Session/did-spaces-guide.jsx +173 -0
- package/src/Session/hooks/use-federated.js +88 -0
- package/src/Session/hooks/use-mobile.jsx +6 -0
- package/src/Session/hooks/use-protected-routes.js +16 -0
- package/src/Session/hooks/use-session-token.js +365 -0
- package/src/Session/hooks/use-verify.jsx +76 -0
- package/src/Session/index.jsx +1687 -0
- package/src/Session/libs/constants.js +14 -0
- package/src/Session/libs/did-spaces.js +38 -0
- package/src/Session/libs/federated.js +79 -0
- package/src/Session/libs/index.js +5 -0
- package/src/Session/libs/locales.js +160 -0
- package/src/Session/libs/login-mobile.js +80 -0
- package/src/Session/window-focus-aware.jsx +28 -0
- package/src/SessionManager/index.jsx +2 -0
- package/src/Storage/engine/cookie.js +23 -0
- package/src/Storage/engine/local-storage.js +55 -0
- package/src/Storage/index.js +25 -0
- package/src/User/index.js +4 -0
- package/src/User/use-did.js +80 -0
- package/src/User/wrap-did.jsx +18 -0
- package/src/WebWalletSWKeeper/index.jsx +3 -0
- package/src/constant.js +26 -0
- package/src/error.js +6 -0
- package/src/hooks/use-locale.jsx +6 -0
- package/src/index.js +43 -0
- package/src/locales/en.jsx +15 -0
- package/src/locales/index.jsx +13 -0
- package/src/locales/zh.jsx +15 -0
- package/src/types.d.ts +355 -0
- package/src/utils.js +395 -0
- package/vite.config.mjs +29 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { jsx as t, jsxs as p, Fragment as He } from "react/jsx-runtime";
|
|
2
|
+
import { use as Ve, useRef as ie, useState as qe, useEffect as se } from "react";
|
|
3
|
+
import e from "prop-types";
|
|
4
|
+
import { Box as i, Skeleton as Ye, Divider as Ge } from "@mui/material";
|
|
5
|
+
import { useUpdate as Ke, useSize as Qe, useCreation as d, useMount as ae, useMemoizedFn as M, useDebounceFn as Xe, usePrevious as Je, useUpdateEffect as Ze } from "ahooks";
|
|
6
|
+
import x from "lodash/noop";
|
|
7
|
+
import $e from "lodash/isUndefined";
|
|
8
|
+
import et from "@arcblock/ux/lib/CloseButton";
|
|
9
|
+
import { LOGIN_PROVIDER as tt, OAUTH_PROVIDER as z, DID_CONNECT_MEDIUM_WIDTH as U, LOGIN_PROVIDER_NAME as ot, DID_CONNECT_SMALL_WIDTH as rt } from "@arcblock/ux/lib/Util/constant";
|
|
10
|
+
import nt from "@arcblock/ux/lib/QRCode";
|
|
11
|
+
import { withUxTheme as it, withContainer as st, DIDConnectFooter as at } from "@arcblock/ux/lib/DIDConnect";
|
|
12
|
+
import { useTheme as ct } from "@arcblock/ux/lib/Theme";
|
|
13
|
+
import lt from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
14
|
+
import "@fontsource/lexend/400.css";
|
|
15
|
+
import "@fontsource/lexend/600.css";
|
|
16
|
+
import ut from "./with-blocklet.js";
|
|
17
|
+
import dt from "./with-bridge-call.js";
|
|
18
|
+
import { default as mo } from "./hooks/security.js";
|
|
19
|
+
import { SessionContext as ft } from "../Session/context.js";
|
|
20
|
+
import { StateProvider as mt, useStateContext as pt } from "./contexts/state.js";
|
|
21
|
+
import ht from "./components/login-item/connect-choose-list.js";
|
|
22
|
+
import gt from "./components/auto-height.js";
|
|
23
|
+
import xt from "./hooks/token.js";
|
|
24
|
+
import { useOAuth as bt } from "../OAuth/context.js";
|
|
25
|
+
import Ct from "./components/connect-status.js";
|
|
26
|
+
import { usePasskey as wt } from "../Passkey/context.js";
|
|
27
|
+
import { CHECK_STATUS_INTERVAL as yt, API_DID_PREFIX as kt, BUSY_STATUS as y, DEFAULT_TIMEOUT as St } from "../constant.js";
|
|
28
|
+
import "../utils.js";
|
|
29
|
+
import It from "./components/did-connect-title.js";
|
|
30
|
+
import Dt from "./components/download-tips.js";
|
|
31
|
+
import Pt from "./hooks/method-list.js";
|
|
32
|
+
import Tt from "./hooks/auth-url.js";
|
|
33
|
+
import { getWalletDid as vt } from "../User/use-did.js";
|
|
34
|
+
import { getWebWalletUrl as _t } from "@arcblock/ux/lib/Util/wallet";
|
|
35
|
+
function ce({
|
|
36
|
+
hideCloseButton: b = !1,
|
|
37
|
+
mode: f = "dialog",
|
|
38
|
+
action: k,
|
|
39
|
+
baseUrl: h = "",
|
|
40
|
+
checkFn: S,
|
|
41
|
+
checkInterval: I = yt,
|
|
42
|
+
checkTimeout: D = St * 1e3,
|
|
43
|
+
prefix: P = kt,
|
|
44
|
+
tokenKey: B = "_t_",
|
|
45
|
+
locale: F = "en",
|
|
46
|
+
encKey: ue = "_ek_",
|
|
47
|
+
autoConnect: de = !0,
|
|
48
|
+
forceConnected: N = !0,
|
|
49
|
+
saveConnect: fe = !0,
|
|
50
|
+
useSocket: me = !0,
|
|
51
|
+
allowWallet: j = !0,
|
|
52
|
+
provider: pe = "",
|
|
53
|
+
messages: u = {},
|
|
54
|
+
passkeyBehavior: H = "none",
|
|
55
|
+
webWalletUrl: V = _t(),
|
|
56
|
+
enabledConnectTypes: q = ["web", "mobile", ...Object.keys(z)],
|
|
57
|
+
extraContent: Y = null,
|
|
58
|
+
disableSwitchApp: T = !1,
|
|
59
|
+
magicToken: G = void 0,
|
|
60
|
+
customItems: he = [],
|
|
61
|
+
onClose: v = x,
|
|
62
|
+
onError: K = x,
|
|
63
|
+
onSuccess: _ = x,
|
|
64
|
+
onRecreateSession: Q = x,
|
|
65
|
+
setColor: ge = x
|
|
66
|
+
}) {
|
|
67
|
+
const R = ct(), X = Ke(), xe = Ve(ft), be = vt(xe?.session?.user), {
|
|
68
|
+
t: J,
|
|
69
|
+
staticState: Ce,
|
|
70
|
+
connectState: s,
|
|
71
|
+
extraParams: we,
|
|
72
|
+
currentAppInfo: ye,
|
|
73
|
+
currentAppColor: O,
|
|
74
|
+
// 插件相关
|
|
75
|
+
selectedPlugin: a,
|
|
76
|
+
blocklet: Z,
|
|
77
|
+
masterBlocklet: ke
|
|
78
|
+
} = pt(), { state: o, generate: $, cancelWhenScanned: Se } = xt({
|
|
79
|
+
action: k,
|
|
80
|
+
baseUrl: h,
|
|
81
|
+
checkFn: S,
|
|
82
|
+
checkInterval: I,
|
|
83
|
+
checkTimeout: D,
|
|
84
|
+
extraParams: we,
|
|
85
|
+
prefix: P,
|
|
86
|
+
onError: K,
|
|
87
|
+
onSuccess: _,
|
|
88
|
+
locale: F,
|
|
89
|
+
tokenKey: B,
|
|
90
|
+
encKey: ue,
|
|
91
|
+
autoConnect: de,
|
|
92
|
+
forceConnected: N === !0 ? be || !0 : N,
|
|
93
|
+
saveConnect: fe,
|
|
94
|
+
useSocket: me,
|
|
95
|
+
provider: pe
|
|
96
|
+
}), A = ie(!1), ee = ie(null), g = Qe(ee), W = d(() => g ? g.width < U - 50 : !0, [g, g?.width]), [te, Ie] = qe(!1);
|
|
97
|
+
ae(() => {
|
|
98
|
+
Ie(g?.width < U - 50);
|
|
99
|
+
});
|
|
100
|
+
const { oauthState: c, setBaseUrl: De } = bt(), { passkeyState: l, setTargetAppPid: Pe } = wt();
|
|
101
|
+
ae(() => {
|
|
102
|
+
De(h), Pe(Z?.appPid), o.reset(), c.reset(), l.reset();
|
|
103
|
+
}), se(() => {
|
|
104
|
+
ge(O);
|
|
105
|
+
}, [O]);
|
|
106
|
+
const Te = d(() => ({
|
|
107
|
+
confirm: u.confirm,
|
|
108
|
+
success: u.success,
|
|
109
|
+
error: a?.state?.error || o.error || l.error || c.error || ""
|
|
110
|
+
}), [
|
|
111
|
+
u.confirm,
|
|
112
|
+
u.success,
|
|
113
|
+
o.error,
|
|
114
|
+
c.error,
|
|
115
|
+
l.error,
|
|
116
|
+
a?.state?.error
|
|
117
|
+
]), C = d(() => y.includes(l.status) || y.includes(c.status) || y.includes(o.status) || y.includes(a?.state?.computedStatus), [o.status, c.status, l.status, a?.state?.computedStatus]), oe = M(async () => {
|
|
118
|
+
Q(), c.reset(), l.reset(), await $(!1);
|
|
119
|
+
}), ve = M(() => {
|
|
120
|
+
s?.retryConnect();
|
|
121
|
+
}), _e = M(() => {
|
|
122
|
+
Q(), c.reset(), l.reset(), a?.state?.reset(), Ce.current.cancelCount++, Se();
|
|
123
|
+
}), { run: Re } = Xe(
|
|
124
|
+
() => {
|
|
125
|
+
A.current || o.status === "timeout" && (A.current = !0, o.reset(), oe(), A.current = !1);
|
|
126
|
+
},
|
|
127
|
+
{ leading: !0, trailing: !1 }
|
|
128
|
+
);
|
|
129
|
+
se(Re, [o.status]);
|
|
130
|
+
const Oe = d(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), {
|
|
131
|
+
showMobileLogin: Ae,
|
|
132
|
+
hideChooseList: r,
|
|
133
|
+
oauthProviderList: We,
|
|
134
|
+
showOAuthLogin: Le,
|
|
135
|
+
showPasskeyLogin: Ee,
|
|
136
|
+
showWebLogin: Me,
|
|
137
|
+
showEmailLogin: Ue,
|
|
138
|
+
hideQRCode: m
|
|
139
|
+
} = Pt({
|
|
140
|
+
action: o.action,
|
|
141
|
+
sourceAppPid: s?.sourceAppPid,
|
|
142
|
+
enabledConnectTypes: q,
|
|
143
|
+
allowWallet: j,
|
|
144
|
+
passkeyBehavior: H,
|
|
145
|
+
webWalletUrl: V,
|
|
146
|
+
mode: f,
|
|
147
|
+
blocklet: s?.sourceAppPid ? ke : Z,
|
|
148
|
+
isSmallView: W
|
|
149
|
+
}), ze = Je(s?.sourceAppPid);
|
|
150
|
+
Ze(() => {
|
|
151
|
+
$e(ze) || $();
|
|
152
|
+
}, [s?.sourceAppPid]);
|
|
153
|
+
const n = (w) => {
|
|
154
|
+
const je = R.spacing(w);
|
|
155
|
+
return parseInt(je, 10);
|
|
156
|
+
}, Be = d(() => b ? null : /* @__PURE__ */ t(
|
|
157
|
+
et,
|
|
158
|
+
{
|
|
159
|
+
onClose: v,
|
|
160
|
+
sx: {
|
|
161
|
+
position: "absolute",
|
|
162
|
+
right: 14,
|
|
163
|
+
top: 14
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
), [b, v]);
|
|
167
|
+
let re = null;
|
|
168
|
+
C && (re = /* @__PURE__ */ t(
|
|
169
|
+
i,
|
|
170
|
+
{
|
|
171
|
+
sx: {
|
|
172
|
+
flex: 1,
|
|
173
|
+
display: "flex",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
justifyContent: "center"
|
|
176
|
+
},
|
|
177
|
+
children: /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
|
|
178
|
+
Ct,
|
|
179
|
+
{
|
|
180
|
+
status: a?.state?.computedStatus || c.status || l.status || o.status,
|
|
181
|
+
nextWorkflow: o.nextWorkflow,
|
|
182
|
+
mfaCode: o.mfaCode,
|
|
183
|
+
onCancel: _e,
|
|
184
|
+
onRetry: ve,
|
|
185
|
+
onClose: v,
|
|
186
|
+
messages: Te,
|
|
187
|
+
locale: F,
|
|
188
|
+
className: "did-connect__auth-status auth-status",
|
|
189
|
+
loadingIcon: s.chooseMethod ? /* @__PURE__ */ t(lt, { provider: s.chooseMethod, sx: { color: "text.primary" } }) : null,
|
|
190
|
+
chooseMethod: Oe,
|
|
191
|
+
hideRetry: s.chooseMethod === "email",
|
|
192
|
+
hideBack: !!G
|
|
193
|
+
}
|
|
194
|
+
) })
|
|
195
|
+
}
|
|
196
|
+
));
|
|
197
|
+
const ne = Tt({ disableSwitchApp: T, tokenState: o }), Fe = d(() => {
|
|
198
|
+
const w = R.mode === "dark" ? R.palette.grey[500] : "white";
|
|
199
|
+
return /* @__PURE__ */ t(
|
|
200
|
+
i,
|
|
201
|
+
{
|
|
202
|
+
sx: {
|
|
203
|
+
p: r ? 3 : 2,
|
|
204
|
+
width: (r ? 240 : 196) + n(1) * 2,
|
|
205
|
+
height: (r ? 240 : 196) + n(1) * 2
|
|
206
|
+
},
|
|
207
|
+
children: o.url ? /* @__PURE__ */ t(
|
|
208
|
+
nt,
|
|
209
|
+
{
|
|
210
|
+
data: ne,
|
|
211
|
+
size: r ? 240 - n(3) * 2 : 196 - n(2) * 2,
|
|
212
|
+
sx: {
|
|
213
|
+
width: (r ? 240 - n(3) * 2 : 196 - n(2) * 2) + n(1) * 2,
|
|
214
|
+
height: (r ? 240 - n(3) * 2 : 196 - n(2) * 2) + n(1) * 2,
|
|
215
|
+
flex: 1,
|
|
216
|
+
backgroundColor: w,
|
|
217
|
+
p: 1,
|
|
218
|
+
fontSize: 0,
|
|
219
|
+
textAlign: "center",
|
|
220
|
+
boxSizing: "border-box",
|
|
221
|
+
borderRadius: 1,
|
|
222
|
+
border: "1px solid",
|
|
223
|
+
borderColor: "divider"
|
|
224
|
+
},
|
|
225
|
+
config: {
|
|
226
|
+
backgroundOptions: {
|
|
227
|
+
color: w
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
) : /* @__PURE__ */ t(
|
|
232
|
+
Ye,
|
|
233
|
+
{
|
|
234
|
+
animation: "wave",
|
|
235
|
+
variant: "rectangular",
|
|
236
|
+
sx: {
|
|
237
|
+
position: "absolute",
|
|
238
|
+
left: n(2) + 1,
|
|
239
|
+
right: n(2) + 1,
|
|
240
|
+
top: n(2) + 1,
|
|
241
|
+
bottom: n(2) + 1,
|
|
242
|
+
borderRadius: 1,
|
|
243
|
+
zIndex: 1,
|
|
244
|
+
width: "auto",
|
|
245
|
+
height: "auto"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}, [ne, r]), Ne = d(() => r ? "column-reverse" : !m && te ? "column" : "row", [r, te, m]), L = /* @__PURE__ */ p(
|
|
252
|
+
i,
|
|
253
|
+
{
|
|
254
|
+
className: "did-connect__body",
|
|
255
|
+
sx: {
|
|
256
|
+
display: "flex",
|
|
257
|
+
flexDirection: Ne,
|
|
258
|
+
justifyContent: "center",
|
|
259
|
+
alignItems: "stretch",
|
|
260
|
+
flex: 1,
|
|
261
|
+
gap: !m && W ? 0 : 1.5,
|
|
262
|
+
overflow: "visible",
|
|
263
|
+
px: r ? 2 : 0
|
|
264
|
+
},
|
|
265
|
+
children: [
|
|
266
|
+
!C && !m ? /* @__PURE__ */ p(He, { children: [
|
|
267
|
+
/* @__PURE__ */ t(
|
|
268
|
+
i,
|
|
269
|
+
{
|
|
270
|
+
sx: {
|
|
271
|
+
display: "flex",
|
|
272
|
+
alignItems: "center",
|
|
273
|
+
overflowX: "auto",
|
|
274
|
+
overflowY: "visible",
|
|
275
|
+
maxWidth: "100%",
|
|
276
|
+
margin: "auto"
|
|
277
|
+
},
|
|
278
|
+
children: /* @__PURE__ */ p(
|
|
279
|
+
i,
|
|
280
|
+
{
|
|
281
|
+
sx: {
|
|
282
|
+
fontSize: 0,
|
|
283
|
+
position: "relative",
|
|
284
|
+
mb: r ? 4 : 2.5
|
|
285
|
+
},
|
|
286
|
+
children: [
|
|
287
|
+
Fe,
|
|
288
|
+
/* @__PURE__ */ p(
|
|
289
|
+
i,
|
|
290
|
+
{
|
|
291
|
+
sx: {
|
|
292
|
+
position: "absolute",
|
|
293
|
+
color: "text.secondary",
|
|
294
|
+
fontSize: 12,
|
|
295
|
+
bottom: r ? 8 : 4,
|
|
296
|
+
transform: "translateY(100%)",
|
|
297
|
+
left: 0,
|
|
298
|
+
right: 0,
|
|
299
|
+
textAlign: "center"
|
|
300
|
+
},
|
|
301
|
+
children: [
|
|
302
|
+
J("scanWithWallet1"),
|
|
303
|
+
" ",
|
|
304
|
+
/* @__PURE__ */ t(Dt, {}),
|
|
305
|
+
" ",
|
|
306
|
+
J("scanWithWallet2")
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
),
|
|
315
|
+
r ? null : /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
|
|
316
|
+
Ge,
|
|
317
|
+
{
|
|
318
|
+
orientation: "vertical",
|
|
319
|
+
sx: {
|
|
320
|
+
fontSize: 12,
|
|
321
|
+
color: "text.hint",
|
|
322
|
+
"&::before, &::after": {
|
|
323
|
+
borderColor: "divider"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
children: "or"
|
|
327
|
+
}
|
|
328
|
+
) })
|
|
329
|
+
] }) : null,
|
|
330
|
+
/* @__PURE__ */ p(
|
|
331
|
+
i,
|
|
332
|
+
{
|
|
333
|
+
sx: {
|
|
334
|
+
display: "flex",
|
|
335
|
+
flex: 1
|
|
336
|
+
},
|
|
337
|
+
children: [
|
|
338
|
+
re,
|
|
339
|
+
/* @__PURE__ */ t(
|
|
340
|
+
ht,
|
|
341
|
+
{
|
|
342
|
+
slotProps: {
|
|
343
|
+
root: {
|
|
344
|
+
sx: [C ? { display: "none" } : {}]
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
allowWallet: j,
|
|
348
|
+
size: m && f !== "dialog" ? "normal" : "small",
|
|
349
|
+
tokenState: o,
|
|
350
|
+
messages: u,
|
|
351
|
+
tokenKey: B,
|
|
352
|
+
onSuccess: _,
|
|
353
|
+
passkeyBehavior: H,
|
|
354
|
+
webWalletUrl: V,
|
|
355
|
+
extraContent: Y,
|
|
356
|
+
enabledConnectTypes: q,
|
|
357
|
+
onRest: oe,
|
|
358
|
+
showMobileLogin: Ae,
|
|
359
|
+
showOAuthLogin: Le,
|
|
360
|
+
showPasskeyLogin: Ee,
|
|
361
|
+
showWebLogin: Me,
|
|
362
|
+
showEmailLogin: Ue,
|
|
363
|
+
oauthProviderList: We,
|
|
364
|
+
disableSwitchApp: T,
|
|
365
|
+
forceUpdate: X,
|
|
366
|
+
magicToken: G,
|
|
367
|
+
baseUrl: h,
|
|
368
|
+
customItems: he
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
let E = L;
|
|
378
|
+
return a ? E = a.renderPlaceholder({
|
|
379
|
+
fallback: L,
|
|
380
|
+
forceUpdate: X,
|
|
381
|
+
onSuccess: _,
|
|
382
|
+
onError: K
|
|
383
|
+
}) : E = L, /* @__PURE__ */ p(
|
|
384
|
+
i,
|
|
385
|
+
{
|
|
386
|
+
ref: ee,
|
|
387
|
+
className: "did-connect__root",
|
|
388
|
+
sx: {
|
|
389
|
+
backgroundColor: "background.default",
|
|
390
|
+
display: "flex",
|
|
391
|
+
flexDirection: "column",
|
|
392
|
+
height: "100%",
|
|
393
|
+
position: "relative",
|
|
394
|
+
maxWidth: "100%",
|
|
395
|
+
width: (
|
|
396
|
+
// eslint-disable-next-line no-nested-ternary
|
|
397
|
+
f === "drawer" ? "100%" : m || C || r ? rt : U
|
|
398
|
+
),
|
|
399
|
+
transition: "width 0.2s ease-in-out",
|
|
400
|
+
margin: "auto",
|
|
401
|
+
p: W ? 2 : 3,
|
|
402
|
+
pb: 0,
|
|
403
|
+
gap: 2
|
|
404
|
+
},
|
|
405
|
+
children: [
|
|
406
|
+
/* @__PURE__ */ t(i, { "data-did-auth-url": o.url, sx: { display: "none" } }),
|
|
407
|
+
/* @__PURE__ */ t(
|
|
408
|
+
It,
|
|
409
|
+
{
|
|
410
|
+
title: u.title,
|
|
411
|
+
description: u.scan,
|
|
412
|
+
extraContent: Y,
|
|
413
|
+
disableSwitchApp: T
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
/* @__PURE__ */ t(gt, { initHeight: 72, children: E }),
|
|
417
|
+
/* @__PURE__ */ t(at, { currentAppInfo: ye, currentAppColor: O }),
|
|
418
|
+
Be
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
ce.propTypes = {
|
|
424
|
+
mode: e.oneOf(["dialog", "drawer", "page"]),
|
|
425
|
+
action: e.string.isRequired,
|
|
426
|
+
baseUrl: e.string,
|
|
427
|
+
checkFn: e.func.isRequired,
|
|
428
|
+
checkInterval: e.number,
|
|
429
|
+
checkTimeout: e.number,
|
|
430
|
+
// extraParams: PropTypes.object, // 需要使用 useStateContext 中导出的
|
|
431
|
+
prefix: e.string,
|
|
432
|
+
messages: e.object,
|
|
433
|
+
tokenKey: e.string,
|
|
434
|
+
locale: e.oneOf(["en", "zh", ""]),
|
|
435
|
+
encKey: e.string,
|
|
436
|
+
autoConnect: e.bool,
|
|
437
|
+
forceConnected: e.oneOfType([e.bool, e.string]),
|
|
438
|
+
saveConnect: e.bool,
|
|
439
|
+
useSocket: e.bool,
|
|
440
|
+
extraContent: e.any,
|
|
441
|
+
passkeyBehavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
|
|
442
|
+
enabledConnectTypes: e.arrayOf(e.oneOf(["web", "mobile", ...Object.keys(z)])),
|
|
443
|
+
webWalletUrl: e.string,
|
|
444
|
+
allowWallet: e.bool,
|
|
445
|
+
provider: e.oneOf([tt.WALLET, ...Object.keys(z), ""]),
|
|
446
|
+
hideCloseButton: e.bool,
|
|
447
|
+
disableSwitchApp: e.bool,
|
|
448
|
+
onClose: e.func,
|
|
449
|
+
onError: e.func,
|
|
450
|
+
onSuccess: e.func,
|
|
451
|
+
onRecreateSession: e.func,
|
|
452
|
+
setColor: e.func,
|
|
453
|
+
magicToken: e.string,
|
|
454
|
+
customItems: e.arrayOf(e.node)
|
|
455
|
+
};
|
|
456
|
+
function le({ testOnlyBorderColor: b = void 0, ...f }) {
|
|
457
|
+
const { checkFn: k, extraParams: h = {}, blocklet: S, masterBlocklet: I, action: D, locale: P = "en" } = f;
|
|
458
|
+
if (typeof k != "function")
|
|
459
|
+
throw new Error("Cannot initialize did connect component without a fetchFn");
|
|
460
|
+
return /* @__PURE__ */ t(
|
|
461
|
+
mt,
|
|
462
|
+
{
|
|
463
|
+
blocklet: S,
|
|
464
|
+
masterBlocklet: I,
|
|
465
|
+
action: D,
|
|
466
|
+
locale: P,
|
|
467
|
+
extraParams: h,
|
|
468
|
+
testOnlyBorderColor: b,
|
|
469
|
+
sx: {
|
|
470
|
+
position: "relative",
|
|
471
|
+
width: "100%",
|
|
472
|
+
height: "100%",
|
|
473
|
+
lineHeight: 1.2,
|
|
474
|
+
color: "grey.700",
|
|
475
|
+
"&, & *, & *:before, & *:after": {
|
|
476
|
+
fontFamily: "Lexend",
|
|
477
|
+
// 保持跟 DID Wallet 一致
|
|
478
|
+
boxSizing: "border-box"
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
children: /* @__PURE__ */ t(ce, { ...f })
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
le.propTypes = {
|
|
486
|
+
checkFn: e.func.isRequired,
|
|
487
|
+
extraParams: e.object,
|
|
488
|
+
blocklet: e.object.isRequired,
|
|
489
|
+
masterBlocklet: e.object,
|
|
490
|
+
action: e.string.isRequired,
|
|
491
|
+
locale: e.string,
|
|
492
|
+
testOnlyBorderColor: e.string
|
|
493
|
+
};
|
|
494
|
+
const lo = it(dt(ut(st(le))));
|
|
495
|
+
export {
|
|
496
|
+
lo as default,
|
|
497
|
+
mo as useSecurity
|
|
498
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useReactive as c, useMemoizedFn as u } from "ahooks";
|
|
3
|
+
import f from "@iconify-icons/material-symbols/mail-outline-rounded";
|
|
4
|
+
import { LOGIN_PROVIDER as h } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { translate as E } from "@arcblock/ux/lib/Locale/util";
|
|
6
|
+
import P from "./list-item.js";
|
|
7
|
+
import g from "./placeholder.js";
|
|
8
|
+
function k({ baseUrl: s }) {
|
|
9
|
+
const i = c({
|
|
10
|
+
baseUrl: s,
|
|
11
|
+
status: "idle",
|
|
12
|
+
get computedStatus() {
|
|
13
|
+
return this.status === "idle" ? "creating" : this.status === "creating" || this.status === "sending" || this.status === "verifying" ? "scanned" : this.status;
|
|
14
|
+
},
|
|
15
|
+
error: "",
|
|
16
|
+
magicToken: "",
|
|
17
|
+
reset() {
|
|
18
|
+
this.status = "idle", this.error = "", this.magicToken = "";
|
|
19
|
+
}
|
|
20
|
+
}), r = h.EMAIL, t = "Email", o = f, l = {
|
|
21
|
+
zh: {
|
|
22
|
+
email: "邮箱地址",
|
|
23
|
+
emailPlaceholder: "请输入邮箱地址",
|
|
24
|
+
sendCode: "发送验证邮件",
|
|
25
|
+
confirm: "确认",
|
|
26
|
+
verifyEmail: "登录链接已发送至邮箱,请登录邮箱查看",
|
|
27
|
+
useCode: "使用验证码",
|
|
28
|
+
codePlaceholder: "请输入验证码",
|
|
29
|
+
orUseCodePlaceholder: "或使用验证码",
|
|
30
|
+
emailInvalid: "邮箱格式不正确",
|
|
31
|
+
emailRequired: "邮箱地址不能为空"
|
|
32
|
+
},
|
|
33
|
+
en: {
|
|
34
|
+
email: "Email",
|
|
35
|
+
emailPlaceholder: "Enter your email address",
|
|
36
|
+
sendCode: "Send Verification Email",
|
|
37
|
+
confirm: "Confirm",
|
|
38
|
+
verifyEmail: "Login link sent! Please check your email.",
|
|
39
|
+
useCode: "Use Verification Code",
|
|
40
|
+
codePlaceholder: "Enter your verification code.",
|
|
41
|
+
orUseCodePlaceholder: "Or use verification code.",
|
|
42
|
+
emailInvalid: "Email format is incorrect",
|
|
43
|
+
emailRequired: "Email is required"
|
|
44
|
+
}
|
|
45
|
+
}, n = u((e, m = {}, d = "en") => E(l, e, d, "en", m));
|
|
46
|
+
return {
|
|
47
|
+
name: r,
|
|
48
|
+
title: t,
|
|
49
|
+
icon: o,
|
|
50
|
+
renderListItem(e) {
|
|
51
|
+
return /* @__PURE__ */ a(P, { ...e, state: i, name: r, title: t, icon: o, t: n });
|
|
52
|
+
},
|
|
53
|
+
renderPlaceholder(e) {
|
|
54
|
+
return /* @__PURE__ */ a(g, { ...e, state: i, name: r, title: t, icon: o, t: n });
|
|
55
|
+
},
|
|
56
|
+
order: 100,
|
|
57
|
+
state: i
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
k as default
|
|
62
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import c from "prop-types";
|
|
3
|
+
import { useMemoizedFn as p } from "ahooks";
|
|
4
|
+
import l from "@iconify-icons/material-symbols/mail-outline-rounded";
|
|
5
|
+
import { LOGIN_PROVIDER as o, LOGIN_PROVIDER_NAME as u } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
+
import a from "../../components/login-item/login-method-item.js";
|
|
7
|
+
import { useStateContext as f } from "../../contexts/state.js";
|
|
8
|
+
function I({ ...e }) {
|
|
9
|
+
const { setSelectedPlugin: n, getPlugin: i, connectState: r } = f(), m = p(() => {
|
|
10
|
+
const t = i(o.EMAIL);
|
|
11
|
+
t.state.reset(), t.state.status = "creating", r.chooseMethod = o.EMAIL, n(t);
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ s(
|
|
14
|
+
a,
|
|
15
|
+
{
|
|
16
|
+
...e,
|
|
17
|
+
title: u[o.EMAIL],
|
|
18
|
+
icon: l,
|
|
19
|
+
onClick: m
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
I.propTypes = {
|
|
24
|
+
onClick: c.func
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
I as default
|
|
28
|
+
};
|