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