@arcblock/did-connect-react 3.5.2 → 4.0.0-beta.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/ConnectContext.d.ts +13 -0
- package/dist/ConnectContext.d.ts.map +1 -0
- package/dist/ConnectContext.js +14 -0
- package/dist/ConnectContext.js.map +1 -0
- package/dist/ConnectProvider.d.ts +11 -0
- package/dist/ConnectProvider.d.ts.map +1 -0
- package/dist/ConnectProvider.js +23 -0
- package/dist/ConnectProvider.js.map +1 -0
- package/dist/compat/SessionProvider.d.ts +22 -0
- package/dist/compat/SessionProvider.d.ts.map +1 -0
- package/dist/compat/SessionProvider.js +17 -0
- package/dist/compat/SessionProvider.js.map +1 -0
- package/dist/compat/index.d.ts +4 -0
- package/dist/compat/index.d.ts.map +1 -0
- package/dist/compat/index.js +3 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/useSessionContext.d.ts +14 -0
- package/dist/compat/useSessionContext.d.ts.map +1 -0
- package/dist/compat/useSessionContext.js +20 -0
- package/dist/compat/useSessionContext.js.map +1 -0
- package/dist/components/LoginPage.d.ts +15 -0
- package/dist/components/LoginPage.d.ts.map +1 -0
- package/dist/components/LoginPage.js +33 -0
- package/dist/components/LoginPage.js.map +1 -0
- package/dist/components/UserAvatar.d.ts +19 -0
- package/dist/components/UserAvatar.d.ts.map +1 -0
- package/dist/components/UserAvatar.js +45 -0
- package/dist/components/UserAvatar.js.map +1 -0
- package/dist/hooks/index.d.ts +11 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useConnect.d.ts +15 -0
- package/dist/hooks/useConnect.d.ts.map +1 -0
- package/dist/hooks/useConnect.js +19 -0
- package/dist/hooks/useConnect.js.map +1 -0
- package/dist/hooks/useEmail.d.ts +11 -0
- package/dist/hooks/useEmail.d.ts.map +1 -0
- package/dist/hooks/useEmail.js +47 -0
- package/dist/hooks/useEmail.js.map +1 -0
- package/dist/hooks/useOAuth.d.ts +12 -0
- package/dist/hooks/useOAuth.d.ts.map +1 -0
- package/dist/hooks/useOAuth.js +75 -0
- package/dist/hooks/useOAuth.js.map +1 -0
- package/dist/hooks/usePasskey.d.ts +14 -0
- package/dist/hooks/usePasskey.d.ts.map +1 -0
- package/dist/hooks/usePasskey.js +35 -0
- package/dist/hooks/usePasskey.js.map +1 -0
- package/dist/hooks/useSession.d.ts +12 -0
- package/dist/hooks/useSession.d.ts.map +1 -0
- package/dist/hooks/useSession.js +30 -0
- package/dist/hooks/useSession.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/internals/blocklet-config.d.ts +22 -0
- package/dist/internals/blocklet-config.d.ts.map +1 -0
- package/dist/internals/blocklet-config.js +26 -0
- package/dist/internals/blocklet-config.js.map +1 -0
- package/dist/internals/local-storage-adapter.d.ts +12 -0
- package/dist/internals/local-storage-adapter.d.ts.map +1 -0
- package/dist/internals/local-storage-adapter.js +32 -0
- package/dist/internals/local-storage-adapter.js.map +1 -0
- package/dist/internals/use-sync-state.d.ts +18 -0
- package/dist/internals/use-sync-state.d.ts.map +1 -0
- package/dist/internals/use-sync-state.js +38 -0
- package/dist/internals/use-sync-state.js.map +1 -0
- package/package.json +33 -79
- package/LICENSE +0 -13
- package/README.md +0 -134
- package/dist/standalone/did-connect-react.css +0 -1
- package/dist/standalone/index.js +0 -136774
- package/lib/Address/index.js +0 -4
- package/lib/Avatar/index.js +0 -4
- package/lib/Button/index.js +0 -17
- package/lib/Connect/assets/locale.js +0 -147
- package/lib/Connect/assets/login-bg.png +0 -0
- package/lib/Connect/assets/login-slogan.js +0 -9
- package/lib/Connect/components/action-button.js +0 -26
- package/lib/Connect/components/app-tips.js +0 -132
- package/lib/Connect/components/auto-height.js +0 -31
- package/lib/Connect/components/back-button.js +0 -25
- package/lib/Connect/components/connect-status.js +0 -263
- package/lib/Connect/components/did-connect-title.js +0 -127
- package/lib/Connect/components/download-tips.js +0 -52
- package/lib/Connect/components/loading.js +0 -26
- package/lib/Connect/components/login-item/connect-choose-list.js +0 -257
- package/lib/Connect/components/login-item/connect-provider-list.js +0 -345
- package/lib/Connect/components/login-item/login-method-item.js +0 -147
- package/lib/Connect/components/login-item/mobile-login-item.js +0 -116
- package/lib/Connect/components/login-item/passkey-login-item.js +0 -44
- package/lib/Connect/components/login-item/wallet-login-options.js +0 -114
- package/lib/Connect/components/login-item/web-login-item.js +0 -104
- package/lib/Connect/components/mask-overlay.js +0 -34
- package/lib/Connect/components/refresh-overlay.js +0 -57
- package/lib/Connect/components/switch-app.js +0 -70
- package/lib/Connect/connect.js +0 -505
- package/lib/Connect/contexts/state.js +0 -156
- package/lib/Connect/fallback-connect.js +0 -53
- package/lib/Connect/fullpage.js +0 -5
- package/lib/Connect/hooks/auth-url.js +0 -23
- package/lib/Connect/hooks/method-list.js +0 -46
- package/lib/Connect/hooks/page-show.js +0 -17
- package/lib/Connect/hooks/provider-list.js +0 -69
- package/lib/Connect/hooks/security.js +0 -27
- package/lib/Connect/hooks/token.js +0 -296
- package/lib/Connect/hooks/use-apps.js +0 -19
- package/lib/Connect/hooks/use-quick-connect.js +0 -86
- package/lib/Connect/index.js +0 -16
- package/lib/Connect/landing-page.js +0 -5
- package/lib/Connect/plugins/email/index.js +0 -65
- package/lib/Connect/plugins/email/list-item.js +0 -31
- package/lib/Connect/plugins/email/placeholder.js +0 -284
- package/lib/Connect/plugins/index.js +0 -4
- package/lib/Connect/use-connect.js +0 -164
- package/lib/Connect/with-blocklet.js +0 -15
- package/lib/Connect/with-bridge-call.js +0 -108
- package/lib/Federated/context.js +0 -61
- package/lib/Federated/index.js +0 -7
- package/lib/Logo/index.js +0 -4
- package/lib/OAuth/bind-conflict-alert.js +0 -29
- package/lib/OAuth/context.js +0 -277
- package/lib/OAuth/guest.svg.js +0 -5
- package/lib/OAuth/index.js +0 -7
- package/lib/OAuth/passport-switcher.js +0 -5
- package/lib/Passkey/actions.js +0 -170
- package/lib/Passkey/constants.js +0 -4
- package/lib/Passkey/context.js +0 -281
- package/lib/Passkey/dialog.js +0 -280
- package/lib/Passkey/icon.js +0 -13
- package/lib/Passkey/index.js +0 -9
- package/lib/Service/index.js +0 -62
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +0 -111
- package/lib/Session/assets/did-spaces-guide-icon.svg.js +0 -9
- package/lib/Session/context.js +0 -5
- package/lib/Session/did-spaces-guide.js +0 -136
- package/lib/Session/handler.js +0 -55
- package/lib/Session/hooks/use-federated.js +0 -64
- package/lib/Session/hooks/use-mobile.js +0 -8
- package/lib/Session/hooks/use-protected-routes.js +0 -11
- package/lib/Session/hooks/use-session-token.js +0 -181
- package/lib/Session/hooks/use-verify.js +0 -45
- package/lib/Session/index.js +0 -941
- package/lib/Session/libs/constants.js +0 -18
- package/lib/Session/libs/did-spaces.js +0 -10
- package/lib/Session/libs/federated.js +0 -42
- package/lib/Session/libs/index.js +0 -15
- package/lib/Session/libs/locales.js +0 -161
- package/lib/Session/libs/login-mobile.js +0 -55
- package/lib/Session/window-focus-aware.js +0 -17
- package/lib/SessionManager/index.js +0 -4
- package/lib/Storage/engine/cookie.js +0 -22
- package/lib/Storage/engine/local-storage.js +0 -37
- package/lib/Storage/index.js +0 -23
- package/lib/User/index.js +0 -6
- package/lib/User/use-did.js +0 -59
- package/lib/User/wrap-did.js +0 -13
- package/lib/WebWalletSWKeeper/index.js +0 -5
- package/lib/components/PassportSwitcher.js +0 -128
- package/lib/constant.js +0 -23
- package/lib/error.js +0 -8
- package/lib/hooks/use-locale.js +0 -7
- package/lib/index.js +0 -111
- package/lib/locales/en.js +0 -17
- package/lib/locales/index.js +0 -10
- package/lib/locales/zh.js +0 -17
- package/lib/node_modules/@blocklet/js-sdk/dist/index.js +0 -512
- package/lib/packages/did-connect/package.json.js +0 -7
- package/lib/types.d.ts +0 -355
- package/lib/utils.js +0 -225
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useReactive as u, useMemoizedFn as f } from "ahooks";
|
|
3
|
-
import h from "@iconify-icons/material-symbols/mail-outline-rounded";
|
|
4
|
-
import { LOGIN_PROVIDER as E } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
-
import { translate as P } from "@arcblock/ux/lib/Locale/util";
|
|
6
|
-
import p from "./list-item.js";
|
|
7
|
-
import g from "./placeholder.js";
|
|
8
|
-
import s from "../../assets/locale.js";
|
|
9
|
-
function q({ baseUrl: l }) {
|
|
10
|
-
const i = u({
|
|
11
|
-
baseUrl: l,
|
|
12
|
-
status: "idle",
|
|
13
|
-
get computedStatus() {
|
|
14
|
-
return this.status === "idle" ? "creating" : this.status === "creating" || this.status === "sending" || this.status === "verifying" ? "scanned" : this.status;
|
|
15
|
-
},
|
|
16
|
-
error: "",
|
|
17
|
-
magicToken: "",
|
|
18
|
-
reset() {
|
|
19
|
-
this.status = "idle", this.error = "", this.magicToken = "";
|
|
20
|
-
}
|
|
21
|
-
}), r = E.EMAIL, t = "Email", o = h, m = {
|
|
22
|
-
zh: {
|
|
23
|
-
...s.zh,
|
|
24
|
-
email: "邮箱地址",
|
|
25
|
-
emailPlaceholder: "请输入邮箱地址",
|
|
26
|
-
sendCode: "发送验证邮件",
|
|
27
|
-
confirm: "确认",
|
|
28
|
-
verifyEmail: "登录链接已发送至邮箱,请登录邮箱查看",
|
|
29
|
-
useCode: "使用验证码",
|
|
30
|
-
codePlaceholder: "请输入验证码",
|
|
31
|
-
orUseCodePlaceholder: "或使用验证码",
|
|
32
|
-
emailInvalid: "邮箱格式不正确",
|
|
33
|
-
emailRequired: "邮箱地址不能为空"
|
|
34
|
-
},
|
|
35
|
-
en: {
|
|
36
|
-
...s.en,
|
|
37
|
-
email: "Email",
|
|
38
|
-
emailPlaceholder: "Enter your email address",
|
|
39
|
-
sendCode: "Send Verification Email",
|
|
40
|
-
confirm: "Confirm",
|
|
41
|
-
verifyEmail: "Login link sent! Please check your email.",
|
|
42
|
-
useCode: "Use Verification Code",
|
|
43
|
-
codePlaceholder: "Enter your verification code.",
|
|
44
|
-
orUseCodePlaceholder: "Or use verification code.",
|
|
45
|
-
emailInvalid: "Email format is incorrect",
|
|
46
|
-
emailRequired: "Email is required"
|
|
47
|
-
}
|
|
48
|
-
}, n = f((e, d = {}, c = "en") => P(m, e, c, "en", d));
|
|
49
|
-
return {
|
|
50
|
-
name: r,
|
|
51
|
-
title: t,
|
|
52
|
-
icon: o,
|
|
53
|
-
renderListItem(e) {
|
|
54
|
-
return /* @__PURE__ */ a(p, { ...e, state: i, name: r, title: t, icon: o, t: n });
|
|
55
|
-
},
|
|
56
|
-
renderPlaceholder(e) {
|
|
57
|
-
return /* @__PURE__ */ a(g, { ...e, state: i, name: r, title: t, icon: o, t: n });
|
|
58
|
-
},
|
|
59
|
-
order: 100,
|
|
60
|
-
state: i
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
q as default
|
|
65
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import a from "prop-types";
|
|
3
|
-
import { useMemoizedFn as c } from "ahooks";
|
|
4
|
-
import p from "@iconify-icons/tabler/mail-filled";
|
|
5
|
-
import { LOGIN_PROVIDER as t, LOGIN_PROVIDER_NAME as I } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
-
import { GA_LAST_LOGIN_METHOD as L } from "@arcblock/ux/lib/withTracker/constant";
|
|
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
|
-
localStorage.setItem(L, t.EMAIL);
|
|
12
|
-
const o = m(t.EMAIL);
|
|
13
|
-
o.state.reset(), o.state.status = "creating", e.chooseMethod = t.EMAIL, e.walletMethod = "", r(o);
|
|
14
|
-
});
|
|
15
|
-
return /* @__PURE__ */ l(
|
|
16
|
-
M,
|
|
17
|
-
{
|
|
18
|
-
...n,
|
|
19
|
-
isLatest: i && i === t.EMAIL,
|
|
20
|
-
title: I[t.EMAIL],
|
|
21
|
-
icon: p,
|
|
22
|
-
onClick: s
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
u.propTypes = {
|
|
27
|
-
onClick: a.func
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
u as default
|
|
31
|
-
};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { jsxs as n, Fragment as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import j from "@arcblock/ux/lib/LoadingMask";
|
|
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
|
-
import c from "prop-types";
|
|
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,
|
|
20
|
-
state: o,
|
|
21
|
-
forceUpdate: t = E,
|
|
22
|
-
onSuccess: h = E,
|
|
23
|
-
t: w = E
|
|
24
|
-
}) {
|
|
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({
|
|
28
|
-
email: "",
|
|
29
|
-
code: "",
|
|
30
|
-
codeId: "",
|
|
31
|
-
defaultVerifyMode: "magicLink",
|
|
32
|
-
verifyMode: "magicLink",
|
|
33
|
-
// magicLink, code
|
|
34
|
-
loadingSendCode: !1,
|
|
35
|
-
loadingVerifyCode: !1,
|
|
36
|
-
error: ""
|
|
37
|
-
}), P = d(() => {
|
|
38
|
-
e.email = "", e.code = "", e.codeId = "", e.verifyMode = e.defaultVerifyMode, e.loadingSendCode = !1, e.loadingVerifyCode = !1, e.error = "";
|
|
39
|
-
}), b = d(async () => {
|
|
40
|
-
if (!e.email || !e.email.trim()) {
|
|
41
|
-
e.error = l("emailRequired");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email)) {
|
|
45
|
-
e.error = l("emailInvalid");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
e.error = "";
|
|
49
|
-
try {
|
|
50
|
-
e.loadingSendCode = !0;
|
|
51
|
-
let i = !1;
|
|
52
|
-
["login"].includes(f) && (u.sourceAppPid || (i = !0));
|
|
53
|
-
const { data: x } = await g.post(I("/email/sendCode", { locale: m }), {
|
|
54
|
-
email: e.email,
|
|
55
|
-
sourceAppPid: u.sourceAppPid,
|
|
56
|
-
useMagicLink: i
|
|
57
|
-
});
|
|
58
|
-
e.verifyMode = e.defaultVerifyMode, e.codeId = x.id, o.status = "sending";
|
|
59
|
-
} catch (i) {
|
|
60
|
-
const x = i?.response?.data?.error || i?.message;
|
|
61
|
-
o.status = "error", o.error = x;
|
|
62
|
-
} finally {
|
|
63
|
-
e.loadingSendCode = !1, t();
|
|
64
|
-
}
|
|
65
|
-
}), S = d(async () => {
|
|
66
|
-
if (e.code.length === Y)
|
|
67
|
-
try {
|
|
68
|
-
e.loadingVerifyCode = !0;
|
|
69
|
-
const { data: r } = await g.post(I("/email/login", { locale: m }), {
|
|
70
|
-
...M,
|
|
71
|
-
action: f,
|
|
72
|
-
code: e.code,
|
|
73
|
-
sourceAppPid: u.sourceAppPid
|
|
74
|
-
});
|
|
75
|
-
y("Email login succeed (use code)", { loginResult: r }), localStorage.setItem(k, v.EMAIL), await h(
|
|
76
|
-
{
|
|
77
|
-
...r,
|
|
78
|
-
encrypted: !1
|
|
79
|
-
},
|
|
80
|
-
(i) => i
|
|
81
|
-
), o.status = "succeed";
|
|
82
|
-
} catch (r) {
|
|
83
|
-
const i = r?.response?.data || r?.message;
|
|
84
|
-
K.error(i), y("Email login failed (use code)", { error: r });
|
|
85
|
-
} finally {
|
|
86
|
-
e.loadingVerifyCode = !1, t();
|
|
87
|
-
}
|
|
88
|
-
}), O = d(async () => {
|
|
89
|
-
o.status = "verifying", t();
|
|
90
|
-
try {
|
|
91
|
-
const { data: r } = await g.post(I("/email/login", { locale: m }), {
|
|
92
|
-
...M,
|
|
93
|
-
action: f,
|
|
94
|
-
magicToken: o.magicToken
|
|
95
|
-
});
|
|
96
|
-
y("Email login succeed (use magic link)", { loginResult: r }), localStorage.setItem(k, v.EMAIL), await h(
|
|
97
|
-
{
|
|
98
|
-
...r,
|
|
99
|
-
encrypted: !1
|
|
100
|
-
},
|
|
101
|
-
(i) => i
|
|
102
|
-
), o.status = "succeed";
|
|
103
|
-
} catch (r) {
|
|
104
|
-
const i = r?.response?.data || r?.message;
|
|
105
|
-
o.status = "error", o.error = i, y("Email login failed (use magic link)", { error: r });
|
|
106
|
-
}
|
|
107
|
-
t();
|
|
108
|
-
}), L = e.verifyMode === "magicLink" && o.status === "sending" && // 如果正在校验验证码,则不轮询状态
|
|
109
|
-
!e.loadingVerifyCode && e.codeId, z = d(async () => {
|
|
110
|
-
if (L) {
|
|
111
|
-
try {
|
|
112
|
-
const { data: r } = await g.get("/email/status", {
|
|
113
|
-
params: {
|
|
114
|
-
codeId: e.codeId
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
r.verified && (o.status = "succeed", P(), localStorage.setItem(k, v.EMAIL), await h({ encrypted: !1 }, (i) => i));
|
|
118
|
-
} catch (r) {
|
|
119
|
-
console.error("check status error", r);
|
|
120
|
-
}
|
|
121
|
-
t();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
N(z, L ? $ : void 0), q(() => {
|
|
125
|
-
P(), (u.sourceAppPid || !["login"].includes(f)) && (e.defaultVerifyMode = "code"), o.magicToken && O();
|
|
126
|
-
}, [o]);
|
|
127
|
-
let C = null;
|
|
128
|
-
if (o.status === "creating")
|
|
129
|
-
C = /* @__PURE__ */ n(s, { children: [
|
|
130
|
-
/* @__PURE__ */ a(
|
|
131
|
-
T,
|
|
132
|
-
{
|
|
133
|
-
variant: "body2",
|
|
134
|
-
sx: {
|
|
135
|
-
textAlign: "center",
|
|
136
|
-
color: "text.secondary"
|
|
137
|
-
},
|
|
138
|
-
children: l("emailPlaceholder")
|
|
139
|
-
}
|
|
140
|
-
),
|
|
141
|
-
/* @__PURE__ */ a(
|
|
142
|
-
B,
|
|
143
|
-
{
|
|
144
|
-
name: "email",
|
|
145
|
-
fullWidth: !0,
|
|
146
|
-
type: "email",
|
|
147
|
-
variant: "outlined",
|
|
148
|
-
label: l("email"),
|
|
149
|
-
placeholder: l("emailPlaceholder"),
|
|
150
|
-
size: "small",
|
|
151
|
-
value: e.email,
|
|
152
|
-
onChange: (r) => {
|
|
153
|
-
e.email = r.target.value;
|
|
154
|
-
},
|
|
155
|
-
onKeyDown: (r) => {
|
|
156
|
-
r.key === "Enter" && b(e.email);
|
|
157
|
-
},
|
|
158
|
-
sx: {
|
|
159
|
-
maxWidth: 320,
|
|
160
|
-
"& .MuiOutlinedInput-root": {
|
|
161
|
-
borderRadius: 1
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
error: !!e.error,
|
|
165
|
-
helperText: e.error,
|
|
166
|
-
slotProps: {
|
|
167
|
-
htmlInput: {
|
|
168
|
-
sx: {
|
|
169
|
-
boxSizing: "content-box !important"
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
),
|
|
175
|
-
/* @__PURE__ */ n(p, { sx: { display: "flex", gap: 1 }, children: [
|
|
176
|
-
/* @__PURE__ */ a(
|
|
177
|
-
R,
|
|
178
|
-
{
|
|
179
|
-
onClick: () => {
|
|
180
|
-
o.reset(), D();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
),
|
|
184
|
-
/* @__PURE__ */ n(
|
|
185
|
-
V,
|
|
186
|
-
{
|
|
187
|
-
sx: {
|
|
188
|
-
color: "primary.main",
|
|
189
|
-
borderColor: "primary.light"
|
|
190
|
-
},
|
|
191
|
-
disabled: e.loadingSendCode,
|
|
192
|
-
onClick: () => {
|
|
193
|
-
b(e.email);
|
|
194
|
-
},
|
|
195
|
-
children: [
|
|
196
|
-
e.loadingSendCode ? /* @__PURE__ */ a(A, { color: "inherit", size: 14, sx: { mr: 1 } }) : null,
|
|
197
|
-
l("sendCode")
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
)
|
|
201
|
-
] })
|
|
202
|
-
] });
|
|
203
|
-
else if (o.status === "sending")
|
|
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"),
|
|
208
|
-
/* @__PURE__ */ a("br", {}),
|
|
209
|
-
l("orUseCodePlaceholder")
|
|
210
|
-
] }) : l("codePlaceholder") }),
|
|
211
|
-
/* @__PURE__ */ a(s, {})
|
|
212
|
-
] }),
|
|
213
|
-
/* @__PURE__ */ n(s, { children: [
|
|
214
|
-
/* @__PURE__ */ a(
|
|
215
|
-
U,
|
|
216
|
-
{
|
|
217
|
-
code: e.code,
|
|
218
|
-
onChange: (r) => {
|
|
219
|
-
e.code = r;
|
|
220
|
-
},
|
|
221
|
-
onComplete: () => {
|
|
222
|
-
S();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
),
|
|
226
|
-
/* @__PURE__ */ n(p, { sx: { display: "flex", gap: 1 }, children: [
|
|
227
|
-
/* @__PURE__ */ a(
|
|
228
|
-
R,
|
|
229
|
-
{
|
|
230
|
-
onClick: () => {
|
|
231
|
-
e.code = "", o.status = "creating", t();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
),
|
|
235
|
-
/* @__PURE__ */ n(
|
|
236
|
-
V,
|
|
237
|
-
{
|
|
238
|
-
sx: {
|
|
239
|
-
color: "primary.main",
|
|
240
|
-
borderColor: "primary.light"
|
|
241
|
-
},
|
|
242
|
-
disabled: e.loadingVerifyCode,
|
|
243
|
-
onClick: () => {
|
|
244
|
-
S();
|
|
245
|
-
},
|
|
246
|
-
children: [
|
|
247
|
-
e.loadingVerifyCode ? /* @__PURE__ */ a(A, { color: "inherit", size: 14, sx: { mr: 1 } }) : null,
|
|
248
|
-
l("confirm")
|
|
249
|
-
]
|
|
250
|
-
}
|
|
251
|
-
)
|
|
252
|
-
] })
|
|
253
|
-
] })
|
|
254
|
-
] });
|
|
255
|
-
else
|
|
256
|
-
return _;
|
|
257
|
-
return /* @__PURE__ */ n(
|
|
258
|
-
p,
|
|
259
|
-
{
|
|
260
|
-
sx: {
|
|
261
|
-
display: "flex",
|
|
262
|
-
flexDirection: "column",
|
|
263
|
-
alignItems: "center",
|
|
264
|
-
justifyContent: "center",
|
|
265
|
-
gap: 2,
|
|
266
|
-
pb: 1
|
|
267
|
-
},
|
|
268
|
-
children: [
|
|
269
|
-
/* @__PURE__ */ a(j, { size: 52, borderRadius: 12, children: /* @__PURE__ */ a(W, { provider: "email" }) }),
|
|
270
|
-
C
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
Z.propTypes = {
|
|
276
|
-
fallback: c.any,
|
|
277
|
-
state: c.object.isRequired,
|
|
278
|
-
forceUpdate: c.func,
|
|
279
|
-
onSuccess: c.func,
|
|
280
|
-
t: c.func
|
|
281
|
-
};
|
|
282
|
-
export {
|
|
283
|
-
Z as default
|
|
284
|
-
};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { jsx as H } from "react/jsx-runtime";
|
|
2
|
-
import { createPortal as j } from "react-dom";
|
|
3
|
-
import { useCreation as R, useMemoizedFn as g, useReactive as V, useDebounce as q } from "ahooks";
|
|
4
|
-
import { useRef as B, use as Q, useState as v, useImperativeHandle as X } from "react";
|
|
5
|
-
import z from "lodash/noop";
|
|
6
|
-
import T from "lodash/cloneDeep";
|
|
7
|
-
import S from "lodash/isFunction";
|
|
8
|
-
import J from "lodash/isUndefined";
|
|
9
|
-
import { joinURL as k, withQuery as M } from "ufo";
|
|
10
|
-
import K from "p-queue";
|
|
11
|
-
import { useTheme as N } from "@arcblock/ux/lib/Theme";
|
|
12
|
-
import { getCookieOptions as G } from "@arcblock/ux/lib/Util";
|
|
13
|
-
import A from "js-cookie";
|
|
14
|
-
import { useBrowser as W } from "@arcblock/react-hooks";
|
|
15
|
-
import { getFederatedEnabled as Y, getMaster as Z } from "@arcblock/ux/lib/Util/federated";
|
|
16
|
-
import { SessionContext as $ } from "../Session/context.js";
|
|
17
|
-
import { openPopup as ee, runPopup as oe, updateConnectedInfo as ne, getAppId as te } from "../utils.js";
|
|
18
|
-
import { API_DID_PREFIX as re, BLOCKLET_SERVICE_PATH_PREFIX as se } from "../constant.js";
|
|
19
|
-
import ce from "./index.js";
|
|
20
|
-
const b = 2e3;
|
|
21
|
-
function ie({ ref: P }) {
|
|
22
|
-
const { api: _, session: s } = Q($), [c, I] = v({
|
|
23
|
-
title: "DID Connect",
|
|
24
|
-
scan: "Use follwing methods to complete this action",
|
|
25
|
-
confirm: "Confirm in your account",
|
|
26
|
-
success: "Success!"
|
|
27
|
-
}), x = N(), F = {
|
|
28
|
-
containerEl: null,
|
|
29
|
-
popup: !0,
|
|
30
|
-
checkFn: _?.get || z
|
|
31
|
-
}, C = x?.transitions?.duration?.leavingScreen || 500, e = V({
|
|
32
|
-
show: !1,
|
|
33
|
-
...T(F)
|
|
34
|
-
}), o = q(e.show, {
|
|
35
|
-
wait: C
|
|
36
|
-
}), [i, O] = v({}), l = g(() => {
|
|
37
|
-
const n = T(F);
|
|
38
|
-
Object.keys(n).forEach((m) => {
|
|
39
|
-
e[m] = n[m];
|
|
40
|
-
});
|
|
41
|
-
}), t = g(() => {
|
|
42
|
-
e.show = !1, setTimeout(() => {
|
|
43
|
-
l();
|
|
44
|
-
}, C);
|
|
45
|
-
}), E = g((n) => {
|
|
46
|
-
const { containerEl: m, checkFn: a, popup: d, messages: f, ...h } = T(n);
|
|
47
|
-
typeof a == "function" && (e.checkFn = a), d !== void 0 && (e.popup = d), f !== void 0 && I(f), m !== void 0 && (e.containerEl = m), O(h), e.show = !0;
|
|
48
|
-
}), y = s.useOAuth(), p = g(async ({ provider: n, action: m, extraParams: a, onLogin: d }) => {
|
|
49
|
-
const f = await y.loginOAuth(
|
|
50
|
-
{ provider: n },
|
|
51
|
-
{
|
|
52
|
-
action: m,
|
|
53
|
-
...a
|
|
54
|
-
}
|
|
55
|
-
), h = G({ returnDomain: !1 });
|
|
56
|
-
A.remove("connected_did", h), A.remove("connected_pk", h), A.remove("connected_wallet_os", h), d(
|
|
57
|
-
{
|
|
58
|
-
...f,
|
|
59
|
-
encrypted: !1
|
|
60
|
-
},
|
|
61
|
-
(w) => w
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
X(P, () => ({
|
|
65
|
-
open: E,
|
|
66
|
-
loginOAuth: p,
|
|
67
|
-
close: t
|
|
68
|
-
}), [E, t, p]);
|
|
69
|
-
const u = /* @__PURE__ */ H(
|
|
70
|
-
ce,
|
|
71
|
-
{
|
|
72
|
-
open: e.show,
|
|
73
|
-
popup: e.popup,
|
|
74
|
-
messages: c,
|
|
75
|
-
checkFn: e.checkFn,
|
|
76
|
-
...i
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
return e.containerEl ? j(u, e.containerEl) : e.show || o ? u : null;
|
|
80
|
-
}
|
|
81
|
-
function xe() {
|
|
82
|
-
const P = B(null), _ = W(), s = R(() => {
|
|
83
|
-
const o = { concurrency: 1 };
|
|
84
|
-
return _.arcSphere && delete o.concurrency, new K(o);
|
|
85
|
-
}), c = g((...o) => {
|
|
86
|
-
P.current?.close(...o);
|
|
87
|
-
}), I = g(
|
|
88
|
-
({ onSuccess: o, onClose: i, onEnd: O, closeTimeout: l = b, ...t }, ...E) => {
|
|
89
|
-
const y = () => new Promise((p) => {
|
|
90
|
-
typeof o == "function" ? t.onSuccess = (...u) => {
|
|
91
|
-
o(...u), setTimeout(() => {
|
|
92
|
-
c(), p();
|
|
93
|
-
}, l);
|
|
94
|
-
} : t.onSuccess = () => {
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
c(), p();
|
|
97
|
-
}, l);
|
|
98
|
-
}, typeof i == "function" ? t.onClose = (...u) => {
|
|
99
|
-
i(...u), c(), p(), s.clear();
|
|
100
|
-
} : t.onClose = () => {
|
|
101
|
-
c(), p(), s.clear();
|
|
102
|
-
}, setTimeout(() => {
|
|
103
|
-
P.current?.open(t, ...E);
|
|
104
|
-
}, 300);
|
|
105
|
-
});
|
|
106
|
-
s.add(y);
|
|
107
|
-
}
|
|
108
|
-
), x = g(
|
|
109
|
-
(o = {}, { baseUrl: i, locale: O = "en", blocklet: l = globalThis?.blocklet, closeTimeout: t = b, popupOptions: E } = {}) => new Promise((y, p) => {
|
|
110
|
-
const u = () => new Promise((n) => {
|
|
111
|
-
(async () => {
|
|
112
|
-
if (J(i)) {
|
|
113
|
-
const r = Y(), U = Z();
|
|
114
|
-
i = r ? U.appUrl : window.location.origin;
|
|
115
|
-
}
|
|
116
|
-
const { onSuccess: a, onClose: d, onError: f, custom: h = !1, ...w } = o;
|
|
117
|
-
if (!w?.extraParams?.provider)
|
|
118
|
-
throw S(f) && f("Must have extraParams.provider"), new Error("Must have extraParams.provider");
|
|
119
|
-
w?.prefix || (w.prefix = window.location.origin + k(l?.prefix, re));
|
|
120
|
-
const D = {
|
|
121
|
-
params: btoa(encodeURIComponent(JSON.stringify(w))),
|
|
122
|
-
appPid: l?.appPid,
|
|
123
|
-
locale: O,
|
|
124
|
-
disableClose: !0
|
|
125
|
-
// 弹窗模式默认不允许关闭 DID Connect
|
|
126
|
-
}, L = ee(
|
|
127
|
-
h ? M(k(i, w.prefix), D) : M(k(i || "/", se, "/connect"), D),
|
|
128
|
-
E
|
|
129
|
-
);
|
|
130
|
-
try {
|
|
131
|
-
const r = await oe({ popup: L, closeTimeout: t });
|
|
132
|
-
ne(
|
|
133
|
-
{
|
|
134
|
-
connected_app: te(),
|
|
135
|
-
...r?.options
|
|
136
|
-
},
|
|
137
|
-
!0
|
|
138
|
-
), S(a) ? (a({ ...r.response, encrypted: !1 }), c(), n()) : (c(), n()), y({ ...r.response, encrypted: !1 });
|
|
139
|
-
} catch (r) {
|
|
140
|
-
throw console.error(r), r.message === "Popup closed" ? S(d) ? (d(), n(), s.clear()) : (n(), s.clear()) : S(f) && f(r), r;
|
|
141
|
-
}
|
|
142
|
-
})().catch((a) => {
|
|
143
|
-
n(), p(a);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
s.add(u);
|
|
147
|
-
})
|
|
148
|
-
), F = (o) => {
|
|
149
|
-
P.current.loginOAuth(o);
|
|
150
|
-
}, C = R(() => /* @__PURE__ */ H(ie, { ref: P })), e = R(() => ({
|
|
151
|
-
open: I,
|
|
152
|
-
close: c,
|
|
153
|
-
loginOAuth: F,
|
|
154
|
-
openPopup: x,
|
|
155
|
-
queue: s
|
|
156
|
-
}));
|
|
157
|
-
return {
|
|
158
|
-
connectHolder: C,
|
|
159
|
-
connectApi: e
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
export {
|
|
163
|
-
xe as default
|
|
164
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { BlockletProvider as i, useBlockletContext as u } from "@arcblock/ux/lib/BlockletContext";
|
|
3
|
-
function p(r) {
|
|
4
|
-
function n({ ...t }) {
|
|
5
|
-
const { blocklet: o, masterBlocklet: c } = u();
|
|
6
|
-
return /* @__PURE__ */ e(r, { ...t, blocklet: o, masterBlocklet: c });
|
|
7
|
-
}
|
|
8
|
-
function l({ baseUrl: t, ...o }) {
|
|
9
|
-
return /* @__PURE__ */ e(i, { baseUrl: t, children: /* @__PURE__ */ e(n, { baseUrl: t, ...o }) });
|
|
10
|
-
}
|
|
11
|
-
return l;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
p as default
|
|
15
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
-
import { use as h, useEffect as y } from "react";
|
|
3
|
-
import g from "prop-types";
|
|
4
|
-
import w from "@arcblock/bridge";
|
|
5
|
-
import { useDebounceFn as x, useMemoizedFn as T } from "ahooks";
|
|
6
|
-
import D from "lodash/pick";
|
|
7
|
-
import P from "@arcblock/react-hooks/lib/useBrowser";
|
|
8
|
-
import { isUrl as _ } from "@arcblock/ux/lib/Util";
|
|
9
|
-
import { joinURL as k } from "ufo";
|
|
10
|
-
import { debug as n } from "../utils.js";
|
|
11
|
-
import { API_DID_PREFIX as A, BLOCKLET_SERVICE_PATH_PREFIX as E, DEFAULT_TIMEOUT as I } from "../constant.js";
|
|
12
|
-
import S from "./hooks/security.js";
|
|
13
|
-
import { SessionContext as K } from "../Session/context.js";
|
|
14
|
-
import { getWalletDid as U } from "../User/use-did.js";
|
|
15
|
-
function G(a) {
|
|
16
|
-
const l = {
|
|
17
|
-
prefix: A,
|
|
18
|
-
checkInterval: 2e3,
|
|
19
|
-
checkTimeout: I * 1e3,
|
|
20
|
-
locale: "en",
|
|
21
|
-
tokenKey: "_t_",
|
|
22
|
-
encKey: "_ek_",
|
|
23
|
-
baseUrl: "",
|
|
24
|
-
messages: {},
|
|
25
|
-
extraParams: {},
|
|
26
|
-
forceConnected: !0,
|
|
27
|
-
enabledConnectTypes: [],
|
|
28
|
-
// 所有的
|
|
29
|
-
disableSwitchApp: !1,
|
|
30
|
-
hideCloseButton: !1,
|
|
31
|
-
qrcodeSize: 160,
|
|
32
|
-
options: {}
|
|
33
|
-
};
|
|
34
|
-
function c(r) {
|
|
35
|
-
const { encryptKey: d, decrypt: f } = S(), m = P(), p = h(K), u = U(p?.session?.user), i = D(r, [
|
|
36
|
-
//
|
|
37
|
-
"action",
|
|
38
|
-
"checkTimeout",
|
|
39
|
-
"locale",
|
|
40
|
-
"messages",
|
|
41
|
-
// 'webWalletUrl', arcSphere 中不需要通过 web 登录,不需要此参数
|
|
42
|
-
//
|
|
43
|
-
"baseUrl",
|
|
44
|
-
// 要写清楚 baseUrl 和 prefix 的处理逻辑
|
|
45
|
-
"prefix",
|
|
46
|
-
"checkInterval",
|
|
47
|
-
"closeTimeout",
|
|
48
|
-
"extraParams",
|
|
49
|
-
"tokenKey",
|
|
50
|
-
"encKey",
|
|
51
|
-
"forceConnected",
|
|
52
|
-
"provider",
|
|
53
|
-
"enabledConnectTypes",
|
|
54
|
-
"disableSwitchApp",
|
|
55
|
-
"hideCloseButton",
|
|
56
|
-
// 不允许用户关闭这个 connect
|
|
57
|
-
// 'qrcodeSize', // 不应该允许配置?
|
|
58
|
-
"options"
|
|
59
|
-
// FIXME: @zhanghan 弄清楚参数的字段
|
|
60
|
-
//
|
|
61
|
-
// 'autoConnect',
|
|
62
|
-
// 'saveConnect',
|
|
63
|
-
// 'useSocket', // 后期再考虑实现
|
|
64
|
-
// 'allowWallet',
|
|
65
|
-
// 'showDownload',
|
|
66
|
-
// 函数,需要在这一层进行处理
|
|
67
|
-
// 'onError',
|
|
68
|
-
// 'onSuccess',
|
|
69
|
-
// 'onRecreateSession', // 貌似没有地方用,直接去掉?
|
|
70
|
-
// 'onClose',
|
|
71
|
-
]), e = Object.assign({}, l, i);
|
|
72
|
-
e.forceConnected === !0 && (e.forceConnected = u || !0);
|
|
73
|
-
const C = r.serviceHost || window?.env?.apiPrefix || window?.blocklet?.prefix || "/";
|
|
74
|
-
!_(e.prefix) && !e.prefix?.startsWith(E) && (e.prefix = k(C, e.prefix));
|
|
75
|
-
const t = m.arcSphere && r.open && !window.forceOpenConnect, { run: s } = x(
|
|
76
|
-
T(async () => {
|
|
77
|
-
n("bridge call arcDidConnect", r, i, e);
|
|
78
|
-
try {
|
|
79
|
-
const o = await w.callArc("didConnect", { ...e, [e.encKey]: d });
|
|
80
|
-
if (n("bridge callArc didConnect: result", o), o.action === "error") {
|
|
81
|
-
r.onError(o.data);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (o.action === "success") {
|
|
85
|
-
r.onSuccess(o.data, f);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
r.onClose(o.data);
|
|
89
|
-
} catch (o) {
|
|
90
|
-
logger.error("Failed to callArc didConnect", o);
|
|
91
|
-
}
|
|
92
|
-
}),
|
|
93
|
-
{
|
|
94
|
-
leading: !0,
|
|
95
|
-
wait: 300
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
return y(() => {
|
|
99
|
-
t && (n("WrapConnect call"), s());
|
|
100
|
-
}, [s, t]), t ? null : /* @__PURE__ */ b(a, { ...r });
|
|
101
|
-
}
|
|
102
|
-
return c.propTypes = {
|
|
103
|
-
open: g.bool
|
|
104
|
-
}, c;
|
|
105
|
-
}
|
|
106
|
-
export {
|
|
107
|
-
G as default
|
|
108
|
-
};
|