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