@arcblock/did-connect-react 3.3.10 → 3.4.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/lib/Connect/assets/locale.js +4 -2
- package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
- package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
- package/lib/Connect/components/login-item/login-method-item.js +63 -47
- package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
- package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
- package/lib/Connect/connect.js +503 -0
- package/lib/Connect/contexts/state.js +74 -65
- package/lib/Connect/fallback-connect.js +53 -0
- package/lib/Connect/hooks/provider-list.js +45 -29
- package/lib/Connect/index.js +13 -502
- package/lib/Connect/plugins/email/list-item.js +19 -18
- package/lib/Connect/use-connect.js +10 -10
- package/lib/OAuth/context.js +3 -3
- package/lib/Passkey/actions.js +80 -75
- package/lib/Passkey/context.js +3 -3
- package/lib/Passkey/dialog.js +7 -7
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
- package/lib/Session/index.js +189 -189
- package/lib/package.json.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +8 -8
- package/src/Connect/assets/locale.js +2 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
- package/src/Connect/components/login-item/login-method-item.jsx +24 -7
- package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
- package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
- package/src/Connect/connect.jsx +618 -0
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/fallback-connect.jsx +47 -0
- package/src/Connect/hooks/provider-list.js +48 -17
- package/src/Connect/index.jsx +8 -605
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Connect/use-connect.jsx +1 -1
- package/src/Passkey/actions.jsx +5 -0
- package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
- package/src/Session/index.jsx +3 -4
- package/src/utils.js +2 -2
|
@@ -1,57 +1,64 @@
|
|
|
1
1
|
import { jsx as O } from "react/jsx-runtime";
|
|
2
2
|
import r from "prop-types";
|
|
3
|
-
import {
|
|
3
|
+
import { useState as S, 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
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Box as
|
|
9
|
-
import { translate as
|
|
10
|
-
import { getMaster as
|
|
11
|
-
import { getDIDMotifInfo as
|
|
12
|
-
import { isEthereumDid as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import de from "
|
|
16
|
-
|
|
5
|
+
import { useUpdate as Z, useCreation as n, useMemoizedFn as h, useLatest as $, useReactive as ee, useSize as te } from "ahooks";
|
|
6
|
+
import E from "lodash/isUndefined";
|
|
7
|
+
import oe from "lodash/noop";
|
|
8
|
+
import { Box as re } from "@mui/material";
|
|
9
|
+
import { translate as ne } from "@arcblock/ux/lib/Locale/util";
|
|
10
|
+
import { getMaster as T, getCurrentApp as se } from "@arcblock/ux/lib/Util/federated";
|
|
11
|
+
import { getDIDMotifInfo as ie } from "@arcblock/did-motif";
|
|
12
|
+
import { isEthereumDid as ce, getDIDColor as pe } from "@arcblock/ux/lib/Util";
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as ue } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
+
import ae from "../hooks/use-apps.js";
|
|
15
|
+
import { SessionContext as de } from "../../Session/context.js";
|
|
16
|
+
import le from "../assets/locale.js";
|
|
17
|
+
const x = X({
|
|
17
18
|
isWalletWebview: !1,
|
|
18
19
|
isMobile: !1,
|
|
19
20
|
matchSmallScreen: !1,
|
|
20
21
|
blocklet: null
|
|
21
|
-
}), { Provider:
|
|
22
|
-
function
|
|
23
|
-
children:
|
|
24
|
-
blocklet:
|
|
22
|
+
}), { Provider: fe, Consumer: We } = x;
|
|
23
|
+
function me({
|
|
24
|
+
children: R,
|
|
25
|
+
blocklet: c,
|
|
25
26
|
masterBlocklet: P = void 0,
|
|
26
|
-
action:
|
|
27
|
+
action: a,
|
|
27
28
|
extraParams: t = {},
|
|
28
|
-
locale:
|
|
29
|
+
locale: d = "en",
|
|
29
30
|
testOnlyBorderColor: l = void 0,
|
|
30
|
-
...
|
|
31
|
+
...L
|
|
31
32
|
}) {
|
|
32
|
-
const w = Z(), [f,
|
|
33
|
+
const w = Z(), [f, j] = S([]), [N, q] = S(!1), [m, z] = S(""), G = n(() => new Map(f.map((e) => [e.name, e])), [f]), J = h((e) => G.get(e)), U = $(m), _ = h((e, i = {}) => ne(le, e, d, "en", i)), g = W(de), o = ee({
|
|
33
34
|
sourceAppPid: void 0,
|
|
34
35
|
status: "created",
|
|
35
36
|
autoActiveWebview: !0,
|
|
36
37
|
deeplink: void 0,
|
|
37
38
|
chooseMethod: "",
|
|
38
|
-
retryConnect:
|
|
39
|
-
}),
|
|
39
|
+
retryConnect: oe
|
|
40
|
+
}), k = D({
|
|
40
41
|
cancelCount: 0
|
|
41
|
-
}),
|
|
42
|
-
blocklet:
|
|
42
|
+
}), s = Y(), { appInfoList: b, autoGenerateSourceAppPid: A, canSwitchApp: v } = ae({
|
|
43
|
+
blocklet: c,
|
|
43
44
|
connectState: o,
|
|
44
|
-
action:
|
|
45
|
+
action: a,
|
|
45
46
|
sourceAppPid: t?.sourceAppPid,
|
|
46
47
|
enableSwitchApp: t?.forceSwitch || t?.enableSwitchApp
|
|
47
|
-
}),
|
|
48
|
+
}), B = n(() => {
|
|
49
|
+
try {
|
|
50
|
+
return localStorage.getItem(ue);
|
|
51
|
+
} catch {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
}, []), C = D(null), M = te(C), y = n(() => (M?.width || 0) < 500, [M?.width]), p = n(() => {
|
|
48
55
|
if (v)
|
|
49
56
|
return {
|
|
50
57
|
...t,
|
|
51
|
-
sourceAppPid:
|
|
58
|
+
sourceAppPid: E(o.sourceAppPid) ? A : o.sourceAppPid
|
|
52
59
|
};
|
|
53
|
-
const e =
|
|
54
|
-
return g?.session?.user && (e ===
|
|
60
|
+
const e = T(c)?.appPid, i = T(globalThis.blocklet)?.appPid;
|
|
61
|
+
return g?.session?.user && (e === i || !e) ? E(t?.sourceAppPid) ? {
|
|
55
62
|
...t,
|
|
56
63
|
sourceAppPid: g.session.user?.sourceAppPid
|
|
57
64
|
} : t : {
|
|
@@ -62,70 +69,72 @@ function le({
|
|
|
62
69
|
v,
|
|
63
70
|
t,
|
|
64
71
|
o.sourceAppPid,
|
|
65
|
-
|
|
72
|
+
a,
|
|
66
73
|
A,
|
|
67
74
|
g?.session?.user
|
|
68
|
-
]),
|
|
75
|
+
]), F = n(() => {
|
|
69
76
|
const e = window?.navigator?.userAgent;
|
|
70
77
|
return e.indexOf("Edge") > -1 || e.indexOf("Edg") > -1 ? "edge" : e.indexOf("Chrome") > -1 ? "chrome" : "unknown";
|
|
71
78
|
}, []);
|
|
72
|
-
|
|
73
|
-
o.sourceAppPid =
|
|
74
|
-
}, [
|
|
79
|
+
V(() => {
|
|
80
|
+
o.sourceAppPid = p.sourceAppPid;
|
|
81
|
+
}, [p.sourceAppPid]);
|
|
75
82
|
const H = h((e) => {
|
|
76
83
|
o.status = e || "created";
|
|
77
|
-
}), u = globalThis.blocklet ?
|
|
84
|
+
}), u = globalThis.blocklet ? se(c) : globalThis.env, I = n(() => {
|
|
78
85
|
if (l)
|
|
79
86
|
return l;
|
|
80
|
-
const e = u.appPid,
|
|
81
|
-
return
|
|
82
|
-
}, [u.appId, l]), K =
|
|
83
|
-
isWalletWebview:
|
|
84
|
-
isMobile:
|
|
87
|
+
const e = u.appPid, i = ce(e), Q = i ? void 0 : ie(e);
|
|
88
|
+
return i ? pe(e) : Q.color;
|
|
89
|
+
}, [u.appId, l]), K = n(() => ({
|
|
90
|
+
isWalletWebview: s.wallet || s.arcSphere,
|
|
91
|
+
isMobile: s.mobile.any,
|
|
85
92
|
matchSmallScreen: y,
|
|
86
93
|
connectState: o,
|
|
87
|
-
staticState:
|
|
94
|
+
staticState: k,
|
|
88
95
|
reactiveState: o,
|
|
89
96
|
appInfoList: b,
|
|
90
|
-
extraParams:
|
|
91
|
-
blocklet:
|
|
97
|
+
extraParams: p,
|
|
98
|
+
blocklet: c,
|
|
92
99
|
masterBlocklet: P,
|
|
93
|
-
browserBrand:
|
|
100
|
+
browserBrand: F,
|
|
94
101
|
currentAppInfo: u,
|
|
95
102
|
currentAppColor: I,
|
|
96
|
-
t:
|
|
97
|
-
locale:
|
|
98
|
-
action:
|
|
103
|
+
t: _,
|
|
104
|
+
locale: d,
|
|
105
|
+
action: a,
|
|
99
106
|
changeStatus: H,
|
|
100
|
-
getPlugin:
|
|
101
|
-
latestActivePlugin:
|
|
107
|
+
getPlugin: J,
|
|
108
|
+
latestActivePlugin: U,
|
|
102
109
|
plugins: f,
|
|
103
|
-
setPlugins:
|
|
110
|
+
setPlugins: j,
|
|
104
111
|
selectedPlugin: m,
|
|
105
|
-
setSelectedPlugin:
|
|
112
|
+
setSelectedPlugin: z,
|
|
106
113
|
forceUpdate: w,
|
|
107
114
|
// 控制钱包登录的显示
|
|
108
|
-
showWalletOptions:
|
|
109
|
-
setShowWalletOptions:
|
|
115
|
+
showWalletOptions: N,
|
|
116
|
+
setShowWalletOptions: q,
|
|
117
|
+
// 用于记录上一次登录方式
|
|
118
|
+
lastLoginMethod: B
|
|
110
119
|
}), [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
s.wallet,
|
|
121
|
+
s.arcSphere,
|
|
122
|
+
s.mobile.any,
|
|
114
123
|
y,
|
|
115
124
|
JSON.stringify(o),
|
|
116
125
|
JSON.stringify(b),
|
|
117
|
-
JSON.stringify(
|
|
118
|
-
|
|
126
|
+
JSON.stringify(p),
|
|
127
|
+
c,
|
|
119
128
|
P,
|
|
120
|
-
|
|
129
|
+
d,
|
|
121
130
|
m,
|
|
122
131
|
w,
|
|
123
132
|
u,
|
|
124
133
|
I
|
|
125
134
|
]);
|
|
126
|
-
return /* @__PURE__ */ O(
|
|
135
|
+
return /* @__PURE__ */ O(fe, { value: K, children: /* @__PURE__ */ O(re, { ...L, ref: C, children: R }) });
|
|
127
136
|
}
|
|
128
|
-
|
|
137
|
+
me.propTypes = {
|
|
129
138
|
children: r.any.isRequired,
|
|
130
139
|
blocklet: r.object.isRequired,
|
|
131
140
|
masterBlocklet: r.object,
|
|
@@ -135,11 +144,11 @@ le.propTypes = {
|
|
|
135
144
|
testOnlyBorderColor: r.string
|
|
136
145
|
};
|
|
137
146
|
function xe() {
|
|
138
|
-
return
|
|
147
|
+
return W(x);
|
|
139
148
|
}
|
|
140
149
|
export {
|
|
141
150
|
We as StateConsumer,
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
x as StateContext,
|
|
152
|
+
me as StateProvider,
|
|
144
153
|
xe as useStateContext
|
|
145
154
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { DIDConnectFooter as a } from "@arcblock/ux/lib/DIDConnect";
|
|
3
|
+
import { DID_CONNECT_SMALL_WIDTH as l } from "@arcblock/ux/lib/Util/constant";
|
|
4
|
+
import { getCurrentApp as x } from "@arcblock/ux/lib/Util/federated";
|
|
5
|
+
import { Box as o, Skeleton as i } from "@mui/material";
|
|
6
|
+
function f(r) {
|
|
7
|
+
const n = globalThis.blocklet ? x(globalThis.blocklet) : globalThis.env;
|
|
8
|
+
return /* @__PURE__ */ t(
|
|
9
|
+
o,
|
|
10
|
+
{
|
|
11
|
+
className: "did-connect__root",
|
|
12
|
+
sx: {
|
|
13
|
+
backgroundColor: "background.default",
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column",
|
|
16
|
+
height: "100%",
|
|
17
|
+
position: "relative",
|
|
18
|
+
maxWidth: "100%",
|
|
19
|
+
// eslint-disable-next-line react/prop-types
|
|
20
|
+
width: r.mode === "drawer" ? "100%" : l - 20,
|
|
21
|
+
transition: "width 0.2s ease-in-out",
|
|
22
|
+
margin: "auto",
|
|
23
|
+
p: 3,
|
|
24
|
+
pb: 0,
|
|
25
|
+
gap: 2.5
|
|
26
|
+
},
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
29
|
+
/* @__PURE__ */ e(i, { variant: "rounded", height: 28, sx: { width: "6rem" } }),
|
|
30
|
+
/* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
|
|
31
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { fontSize: "13px", height: "15px" } }),
|
|
32
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { fontSize: "13px", height: "15px", width: "3rem" } })
|
|
33
|
+
] })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
36
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
|
|
37
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
|
|
38
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
|
|
39
|
+
/* @__PURE__ */ t(o, { sx: { display: "flex", gap: 1.5, mt: 1 }, children: [
|
|
40
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
|
|
41
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
|
|
42
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
|
|
43
|
+
/* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } })
|
|
44
|
+
] })
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ e(a, { currentAppInfo: n })
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
f as default
|
|
53
|
+
};
|
|
@@ -1,50 +1,66 @@
|
|
|
1
|
-
import { useBrowser as
|
|
2
|
-
import { useRequest as
|
|
3
|
-
import
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { getFederatedEnabled as
|
|
6
|
-
|
|
1
|
+
import { useBrowser as k } from "@arcblock/react-hooks";
|
|
2
|
+
import { useRequest as y, useCreation as L } from "ahooks";
|
|
3
|
+
import n from "lodash/isNil";
|
|
4
|
+
import { LOGIN_PROVIDER as s } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { getFederatedEnabled as A, getMaster as C, getBlockletData as T } from "@arcblock/ux/lib/Util/federated";
|
|
6
|
+
import { useState as I } from "react";
|
|
7
|
+
const S = async ({ sourceAppPid: a }) => {
|
|
7
8
|
const t = globalThis?.blocklet;
|
|
8
9
|
if (!t)
|
|
9
10
|
return {
|
|
10
|
-
[
|
|
11
|
+
[s.WALLET]: {
|
|
11
12
|
order: 0,
|
|
12
13
|
enabled: !0,
|
|
13
14
|
showQrcode: !0
|
|
14
15
|
},
|
|
15
|
-
[
|
|
16
|
+
[s.PASSKEY]: {
|
|
16
17
|
order: 1,
|
|
17
18
|
enabled: !0
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
},
|
|
23
|
-
const t = await
|
|
24
|
-
return Object.entries(t).map(([e,
|
|
21
|
+
const l = A(t), e = C(t);
|
|
22
|
+
return l && e?.appPid && a === e?.appPid ? (await T(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
|
|
23
|
+
}, B = async ({ sourceAppPid: a } = {}) => {
|
|
24
|
+
const t = await S({ sourceAppPid: a });
|
|
25
|
+
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !n(e?.order) && !n(o?.order) ? e.order - o.order : n(e?.order) ? 1 : -1);
|
|
25
26
|
};
|
|
26
|
-
function
|
|
27
|
-
allowWallet:
|
|
27
|
+
function Y({
|
|
28
|
+
allowWallet: a = !0,
|
|
28
29
|
passkeyBehavior: t = "none",
|
|
29
|
-
action:
|
|
30
|
+
action: l,
|
|
30
31
|
sourceAppPid: e,
|
|
31
|
-
mode:
|
|
32
|
-
blocklet:
|
|
33
|
-
isSmallView:
|
|
32
|
+
mode: o = "dialog",
|
|
33
|
+
blocklet: b = globalThis.blocklet,
|
|
34
|
+
isSmallView: p = !1,
|
|
35
|
+
lastLoginMethod: u = ""
|
|
34
36
|
}) {
|
|
35
|
-
const
|
|
36
|
-
async () =>
|
|
37
|
+
const [P, g] = I(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], c = k(), { data: h = [] } = y(
|
|
38
|
+
async () => {
|
|
39
|
+
g(!0);
|
|
40
|
+
const d = await B({ sourceAppPid: e });
|
|
41
|
+
return g(!1), d;
|
|
42
|
+
},
|
|
37
43
|
{ refreshDeps: [e] }
|
|
38
|
-
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
), f = L(() => h.filter((r) => r.name === s.WALLET ? a : r.name === s.PASSKEY ? t !== "none" && !c.wallet && !c.arcSphere : r.name === s.EMAIL ? b?.settings?.notification?.email?.enabled ?? !1 : !(r.type === "oauth" && !w.includes(l))).sort((r, i) => {
|
|
45
|
+
if (u) {
|
|
46
|
+
const m = r.provider === u, v = i.provider === u;
|
|
47
|
+
if (m && !v)
|
|
48
|
+
return -1;
|
|
49
|
+
if (!m && v)
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
return !n(r?.order) && !n(i?.order) ? r.order - i.order : n(r?.order) ? n(i?.order) ? 0 : 1 : -1;
|
|
53
|
+
}), [h, u]), E = L(() => {
|
|
54
|
+
const d = o === "drawer" || p && c.mobile.any;
|
|
55
|
+
return globalThis?.blocklet ? !!(f.find((i) => i.provider === s.WALLET)?.showQrcode !== !0 || d) : !!d;
|
|
56
|
+
}, [o, p, f]);
|
|
42
57
|
return {
|
|
43
|
-
hideChooseList:
|
|
44
|
-
hideQRCode:
|
|
45
|
-
providerList:
|
|
58
|
+
hideChooseList: L(() => !1),
|
|
59
|
+
hideQRCode: E,
|
|
60
|
+
providerList: f,
|
|
61
|
+
loadingProviderList: P
|
|
46
62
|
};
|
|
47
63
|
}
|
|
48
64
|
export {
|
|
49
|
-
|
|
65
|
+
Y as default
|
|
50
66
|
};
|