@arcblock/did-connect-react 3.3.6 → 3.3.8
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/components/login-item/connect-provider-list.js +151 -145
- package/lib/Connect/components/login-item/wallet-login-options.js +30 -30
- package/lib/Connect/index.js +13 -12
- package/lib/package.json.js +1 -1
- package/package.json +5 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +31 -8
- package/src/Connect/components/login-item/wallet-login-options.jsx +1 -1
- package/src/Connect/index.jsx +1 -0
|
@@ -1,170 +1,175 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
1
|
+
import { jsx as l, jsxs as me } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
|
-
import { Box as
|
|
4
|
-
import { LOGIN_PROVIDER as r, LOGIN_PROVIDER_ICON_SIZE as
|
|
5
|
-
import { getWebWalletUrl as
|
|
6
|
-
import
|
|
7
|
-
import { useMemoizedFn as
|
|
8
|
-
import
|
|
9
|
-
import { getCookieOptions as
|
|
10
|
-
import { useRef as
|
|
11
|
-
import { mergeSx as
|
|
12
|
-
import
|
|
13
|
-
import { GA_LAST_LOGIN_METHOD as
|
|
14
|
-
import { translate as
|
|
15
|
-
import
|
|
16
|
-
import { useBrowser as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { useOAuth as
|
|
22
|
-
import { useStateContext as
|
|
23
|
-
import { getAppId as
|
|
24
|
-
import
|
|
25
|
-
import { usePasskey as
|
|
3
|
+
import { Box as L } from "@mui/material";
|
|
4
|
+
import { LOGIN_PROVIDER as r, LOGIN_PROVIDER_ICON_SIZE as I, LOGIN_PROVIDER_NAME as de } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { checkSameProtocol as pe, getWebWalletUrl as ue } from "@arcblock/ux/lib/Util/wallet";
|
|
6
|
+
import b from "lodash/noop";
|
|
7
|
+
import { useMemoizedFn as a, useCreation as he } from "ahooks";
|
|
8
|
+
import v from "js-cookie";
|
|
9
|
+
import { detectWalletExtension as ge, getCookieOptions as fe } from "@arcblock/ux/lib/Util";
|
|
10
|
+
import { useRef as w, useEffect as Z } from "react";
|
|
11
|
+
import { mergeSx as ye } from "@arcblock/ux/lib/Util/style";
|
|
12
|
+
import Le from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as g } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
+
import { translate as Ie } from "@arcblock/ux/lib/Locale/util";
|
|
15
|
+
import be from "@arcblock/ux/lib/Empty";
|
|
16
|
+
import { useBrowser as xe } from "@arcblock/react-hooks";
|
|
17
|
+
import Ce from "./mobile-login-item.js";
|
|
18
|
+
import Ae from "./web-login-item.js";
|
|
19
|
+
import Ee from "./login-method-item.js";
|
|
20
|
+
import Pe from "./wallet-login-options.js";
|
|
21
|
+
import { useOAuth as Me } from "../../../OAuth/context.js";
|
|
22
|
+
import { useStateContext as ve } from "../../contexts/state.js";
|
|
23
|
+
import { getAppId as we, logger as _e, getApiErrorMessage as Oe } from "../../../utils.js";
|
|
24
|
+
import We from "./passkey-login-item.js";
|
|
25
|
+
import { usePasskey as Te } from "../../../Passkey/context.js";
|
|
26
26
|
import "../../../Passkey/actions.js";
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
function
|
|
30
|
-
onSuccess:
|
|
31
|
-
onError:
|
|
27
|
+
import ke from "../../plugins/email/index.js";
|
|
28
|
+
import Re from "../../assets/locale.js";
|
|
29
|
+
function Se({
|
|
30
|
+
onSuccess: _ = b,
|
|
31
|
+
onError: O = b,
|
|
32
32
|
size: m = "small",
|
|
33
33
|
tokenState: n,
|
|
34
|
-
webWalletUrl:
|
|
35
|
-
tokenKey:
|
|
36
|
-
passkeyBehavior:
|
|
37
|
-
onReset:
|
|
38
|
-
providerList:
|
|
39
|
-
slotProps:
|
|
40
|
-
disableSwitchApp:
|
|
41
|
-
forceUpdate:
|
|
42
|
-
magicToken:
|
|
43
|
-
baseUrl:
|
|
44
|
-
customItems:
|
|
45
|
-
qrcode:
|
|
34
|
+
webWalletUrl: x = ue(),
|
|
35
|
+
tokenKey: W,
|
|
36
|
+
passkeyBehavior: T = "none",
|
|
37
|
+
onReset: C = b,
|
|
38
|
+
providerList: d = [],
|
|
39
|
+
slotProps: $ = {},
|
|
40
|
+
disableSwitchApp: A = !1,
|
|
41
|
+
forceUpdate: J = b,
|
|
42
|
+
magicToken: k = void 0,
|
|
43
|
+
baseUrl: X = "/",
|
|
44
|
+
customItems: z = [],
|
|
45
|
+
qrcode: Q = null,
|
|
46
|
+
hideQRCode: f = !1
|
|
46
47
|
}) {
|
|
47
|
-
const
|
|
48
|
-
extraParams:
|
|
49
|
-
locale:
|
|
48
|
+
const E = w(null), P = w(null), R = w(null), ee = pe(x), S = ge(), p = xe(), { loginOAuth: oe, logoutOAuth: ne, t: te, oauthState: s } = Me(), { passkeyState: j } = Te(), {
|
|
49
|
+
extraParams: N,
|
|
50
|
+
locale: D,
|
|
50
51
|
connectState: i,
|
|
51
|
-
plugins:
|
|
52
|
-
setPlugins:
|
|
53
|
-
setSelectedPlugin:
|
|
54
|
-
getPlugin:
|
|
55
|
-
showWalletOptions:
|
|
56
|
-
setShowWalletOptions:
|
|
57
|
-
} =
|
|
58
|
-
localStorage.setItem(
|
|
52
|
+
plugins: F,
|
|
53
|
+
setPlugins: re,
|
|
54
|
+
setSelectedPlugin: ie,
|
|
55
|
+
getPlugin: B,
|
|
56
|
+
showWalletOptions: h,
|
|
57
|
+
setShowWalletOptions: y
|
|
58
|
+
} = ve(), le = a((e, t = {}) => Ie(Re, e, D, "en", t)), G = a(async (e) => {
|
|
59
|
+
localStorage.setItem(g, e.provider), n.reset(), s.reset({
|
|
59
60
|
status: "scanned"
|
|
60
|
-
}),
|
|
61
|
-
const t =
|
|
61
|
+
}), j.reset(), i.chooseMethod = e.provider;
|
|
62
|
+
const t = N?.sourceAppPid;
|
|
62
63
|
try {
|
|
63
64
|
s.loading = !0, s.status = "scanned";
|
|
64
|
-
const
|
|
65
|
+
const c = await oe(e, {
|
|
65
66
|
action: n.action,
|
|
66
|
-
...
|
|
67
|
-
}),
|
|
68
|
-
|
|
67
|
+
...N
|
|
68
|
+
}), u = fe({ returnDomain: !1 });
|
|
69
|
+
v.remove("connected_did", u), v.remove("connected_pk", u), v.remove("connected_wallet_os", u), c?.sessionToken && (await _(
|
|
69
70
|
{
|
|
70
|
-
...
|
|
71
|
+
...c,
|
|
71
72
|
encrypted: !1
|
|
72
73
|
},
|
|
73
|
-
(
|
|
74
|
+
(ae) => ae,
|
|
74
75
|
{
|
|
75
76
|
sourceAppPid: t,
|
|
76
|
-
connected_app:
|
|
77
|
+
connected_app: we(n.appInfo, n.memberAppInfo)
|
|
77
78
|
}
|
|
78
79
|
), s.loading = !1, s.status = "succeed");
|
|
79
|
-
} catch (
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
s.loading = !1, s.error =
|
|
80
|
+
} catch (c) {
|
|
81
|
+
_e.error(`Failed login OAuth: ${e.provider}`, c);
|
|
82
|
+
const u = Oe(c, te("loginOAuthFailed"));
|
|
83
|
+
s.loading = !1, s.error = u, s.status = "error", await ne({ provider: e.provider }), O(new Error(u));
|
|
83
84
|
}
|
|
84
|
-
}),
|
|
85
|
-
n.reset(), await
|
|
86
|
-
}),
|
|
87
|
-
localStorage.setItem(
|
|
88
|
-
const e =
|
|
85
|
+
}), U = a(async () => {
|
|
86
|
+
n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
|
|
87
|
+
}), q = a(async () => {
|
|
88
|
+
localStorage.setItem(g, "wallet"), n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
|
|
89
|
+
const e = E.current?.connect;
|
|
89
90
|
i.retryConnect = () => {
|
|
90
|
-
e(
|
|
91
|
+
e(U);
|
|
91
92
|
};
|
|
92
|
-
}),
|
|
93
|
-
localStorage.setItem(
|
|
94
|
-
const e =
|
|
93
|
+
}), V = a(() => {
|
|
94
|
+
localStorage.setItem(g, "wallet"), n.status = "scanned", i.chooseMethod = "wallet-web";
|
|
95
|
+
const e = P.current.connect;
|
|
95
96
|
i.retryConnect = async () => {
|
|
96
|
-
await
|
|
97
|
+
await C(), n.error = "", n.status = "scanned", e();
|
|
97
98
|
};
|
|
98
|
-
}),
|
|
99
|
-
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
}), se = a(() => {
|
|
100
|
+
y(!1);
|
|
101
|
+
}), M = he(() => d.length === 1 && d[0].provider === r.WALLET, [d]);
|
|
102
|
+
Z(() => {
|
|
103
|
+
M && !p.mobile.any && !h && y(!0);
|
|
104
|
+
}, [M, p.mobile.any, y, h]);
|
|
105
|
+
const K = d.some((e) => e.provider === r.EMAIL), Y = ke({ baseUrl: X }), ce = a(() => {
|
|
106
|
+
if (k && d.some((e) => e.name === r.EMAIL) && F.some((e) => e.name === r.EMAIL)) {
|
|
107
|
+
const e = B(r.EMAIL);
|
|
108
|
+
e.state.status === "idle" && (localStorage.setItem(g, "email"), e.state.reset(), e.state.magicToken = k, i.chooseMethod = r.EMAIL, ie(e), J());
|
|
104
109
|
}
|
|
105
110
|
});
|
|
106
|
-
|
|
111
|
+
Z(() => {
|
|
107
112
|
const e = [];
|
|
108
|
-
if (
|
|
109
|
-
const t =
|
|
110
|
-
t && t.baseUrl ===
|
|
113
|
+
if (K) {
|
|
114
|
+
const t = B(r.EMAIL);
|
|
115
|
+
t && t.baseUrl === Y.baseUrl ? e.push(t) : e.push(Y);
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
re(e), i.retryConnect = U, setTimeout(() => {
|
|
118
|
+
ce();
|
|
114
119
|
}, 100);
|
|
115
|
-
}, [
|
|
116
|
-
const
|
|
120
|
+
}, [K]);
|
|
121
|
+
const H = d.map((e) => {
|
|
117
122
|
if (e.provider === r.WALLET)
|
|
118
|
-
return
|
|
119
|
-
|
|
123
|
+
return p.mobile.any && !h ? /* @__PURE__ */ l(
|
|
124
|
+
Ce,
|
|
120
125
|
{
|
|
121
|
-
ref:
|
|
126
|
+
ref: E,
|
|
122
127
|
tokenState: n,
|
|
123
128
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
124
|
-
locale:
|
|
125
|
-
tokenKey:
|
|
126
|
-
disableSwitchApp:
|
|
127
|
-
onClick:
|
|
129
|
+
locale: D,
|
|
130
|
+
tokenKey: W,
|
|
131
|
+
disableSwitchApp: A,
|
|
132
|
+
onClick: q
|
|
128
133
|
},
|
|
129
134
|
r.WALLET
|
|
130
|
-
) : /* @__PURE__ */ l(
|
|
131
|
-
|
|
135
|
+
) : f || !f && (ee || S) && (!p.mobile.any || S) ? /* @__PURE__ */ l(
|
|
136
|
+
Ae,
|
|
132
137
|
{
|
|
133
|
-
ref:
|
|
138
|
+
ref: P,
|
|
134
139
|
tokenState: n,
|
|
135
|
-
webWalletUrl:
|
|
140
|
+
webWalletUrl: x,
|
|
136
141
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
137
|
-
disableSwitchApp:
|
|
138
|
-
autoConnect: !
|
|
142
|
+
disableSwitchApp: A,
|
|
143
|
+
autoConnect: !f,
|
|
139
144
|
onClick: () => {
|
|
140
|
-
|
|
145
|
+
f ? y(!0) : V();
|
|
141
146
|
}
|
|
142
147
|
},
|
|
143
148
|
r.WALLET
|
|
144
|
-
);
|
|
149
|
+
) : null;
|
|
145
150
|
if (e.provider === r.PASSKEY)
|
|
146
|
-
return
|
|
147
|
-
|
|
151
|
+
return T === "none" ? null : /* @__PURE__ */ l(
|
|
152
|
+
We,
|
|
148
153
|
{
|
|
149
154
|
ref: R,
|
|
150
|
-
onSuccess:
|
|
151
|
-
onError:
|
|
155
|
+
onSuccess: _,
|
|
156
|
+
onError: O,
|
|
152
157
|
tokenState: n,
|
|
153
|
-
behavior:
|
|
158
|
+
behavior: T,
|
|
154
159
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
155
160
|
onClick: () => {
|
|
156
|
-
localStorage.setItem(
|
|
161
|
+
localStorage.setItem(g, "passkey");
|
|
157
162
|
const t = R.current.connect;
|
|
158
163
|
i.chooseMethod = "passkey", i.retryConnect = () => {
|
|
159
|
-
|
|
164
|
+
j.verifying = !0, i.chooseMethod = "passkey", t();
|
|
160
165
|
};
|
|
161
166
|
},
|
|
162
167
|
slotProps: {
|
|
163
168
|
icon: {
|
|
164
169
|
sx: {
|
|
165
|
-
fontSize:
|
|
170
|
+
fontSize: I,
|
|
166
171
|
"& svg": {
|
|
167
|
-
fontSize:
|
|
172
|
+
fontSize: I,
|
|
168
173
|
width: "1em",
|
|
169
174
|
height: "1em"
|
|
170
175
|
}
|
|
@@ -175,7 +180,7 @@ function _e({
|
|
|
175
180
|
r.PASSKEY
|
|
176
181
|
);
|
|
177
182
|
if (e.provider === r.EMAIL) {
|
|
178
|
-
const t =
|
|
183
|
+
const t = F.find((c) => c.name === r.EMAIL);
|
|
179
184
|
return t ? t?.renderListItem({
|
|
180
185
|
key: t.name,
|
|
181
186
|
sx: [m === "small" ? { p: 1 } : { p: 2 }]
|
|
@@ -183,24 +188,24 @@ function _e({
|
|
|
183
188
|
}) : null;
|
|
184
189
|
}
|
|
185
190
|
return e.type === "oauth" ? /* @__PURE__ */ l(
|
|
186
|
-
|
|
191
|
+
Ee,
|
|
187
192
|
{
|
|
188
|
-
title:
|
|
193
|
+
title: de[e.provider],
|
|
189
194
|
icon: /* @__PURE__ */ l(
|
|
190
|
-
|
|
195
|
+
Le,
|
|
191
196
|
{
|
|
192
197
|
provider: e.provider,
|
|
193
198
|
sx: {
|
|
194
199
|
transform: "scale(0.95)",
|
|
195
|
-
width:
|
|
196
|
-
height:
|
|
200
|
+
width: I,
|
|
201
|
+
height: I,
|
|
197
202
|
color: "text.primary"
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
),
|
|
201
206
|
onClick: () => {
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
G(e), i.retryConnect = () => {
|
|
208
|
+
G(e);
|
|
204
209
|
};
|
|
205
210
|
},
|
|
206
211
|
sx: [m === "small" ? { p: 1.2 } : { p: 2 }]
|
|
@@ -208,42 +213,42 @@ function _e({
|
|
|
208
213
|
e.provider
|
|
209
214
|
) : null;
|
|
210
215
|
}).filter(Boolean);
|
|
211
|
-
return /* @__PURE__ */ l(
|
|
212
|
-
|
|
216
|
+
return /* @__PURE__ */ l(L, { className: "did-connect__choose", sx: ye({ flex: 1 }, $?.root?.sx), children: /* @__PURE__ */ l(
|
|
217
|
+
L,
|
|
213
218
|
{
|
|
214
219
|
sx: {
|
|
215
220
|
display: "flex",
|
|
216
221
|
flexDirection: "column",
|
|
217
222
|
gap: 2
|
|
218
223
|
},
|
|
219
|
-
children: /* @__PURE__ */
|
|
220
|
-
|
|
224
|
+
children: /* @__PURE__ */ me(
|
|
225
|
+
L,
|
|
221
226
|
{
|
|
222
227
|
sx: [
|
|
223
228
|
{
|
|
224
229
|
display: "flex",
|
|
225
230
|
flexDirection: "column",
|
|
226
|
-
...
|
|
231
|
+
...h && !p.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
|
|
227
232
|
}
|
|
228
233
|
],
|
|
229
234
|
children: [
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
h && !p.mobile.any ? /* @__PURE__ */ l(
|
|
236
|
+
Pe,
|
|
232
237
|
{
|
|
233
|
-
qrcode:
|
|
238
|
+
qrcode: Q,
|
|
234
239
|
tokenState: n,
|
|
235
|
-
webWalletUrl:
|
|
240
|
+
webWalletUrl: x,
|
|
236
241
|
size: m,
|
|
237
|
-
disableSwitchApp:
|
|
238
|
-
tokenKey:
|
|
239
|
-
walletLoginRef:
|
|
240
|
-
webLoginRef:
|
|
241
|
-
onMobileLoginClick:
|
|
242
|
-
onWebLoginClick:
|
|
243
|
-
onBack:
|
|
242
|
+
disableSwitchApp: A,
|
|
243
|
+
tokenKey: W,
|
|
244
|
+
walletLoginRef: E,
|
|
245
|
+
webLoginRef: P,
|
|
246
|
+
onMobileLoginClick: q,
|
|
247
|
+
onWebLoginClick: V,
|
|
248
|
+
onBack: M ? void 0 : se
|
|
244
249
|
}
|
|
245
250
|
) : /* @__PURE__ */ l(
|
|
246
|
-
|
|
251
|
+
L,
|
|
247
252
|
{
|
|
248
253
|
sx: {
|
|
249
254
|
display: "grid",
|
|
@@ -288,8 +293,8 @@ function _e({
|
|
|
288
293
|
}
|
|
289
294
|
}
|
|
290
295
|
},
|
|
291
|
-
children:
|
|
292
|
-
|
|
296
|
+
children: H.length > 0 ? H : /* @__PURE__ */ l(
|
|
297
|
+
be,
|
|
293
298
|
{
|
|
294
299
|
className: "arc-login-item",
|
|
295
300
|
sx: {
|
|
@@ -297,19 +302,19 @@ function _e({
|
|
|
297
302
|
textAlign: "center"
|
|
298
303
|
}
|
|
299
304
|
},
|
|
300
|
-
children:
|
|
305
|
+
children: le("noAuthenticationProvider")
|
|
301
306
|
}
|
|
302
307
|
)
|
|
303
308
|
}
|
|
304
309
|
),
|
|
305
|
-
|
|
310
|
+
z.map((e) => e || null)
|
|
306
311
|
]
|
|
307
312
|
}
|
|
308
313
|
)
|
|
309
314
|
}
|
|
310
315
|
) });
|
|
311
316
|
}
|
|
312
|
-
|
|
317
|
+
Se.propTypes = {
|
|
313
318
|
onSuccess: o.func,
|
|
314
319
|
onError: o.func,
|
|
315
320
|
size: o.oneOf(["small", "normal", "large"]),
|
|
@@ -325,8 +330,9 @@ _e.propTypes = {
|
|
|
325
330
|
magicToken: o.string,
|
|
326
331
|
baseUrl: o.string,
|
|
327
332
|
customItems: o.arrayOf(o.node),
|
|
328
|
-
qrcode: o.node
|
|
333
|
+
qrcode: o.node,
|
|
334
|
+
hideQRCode: o.bool
|
|
329
335
|
};
|
|
330
336
|
export {
|
|
331
|
-
|
|
337
|
+
Se as default
|
|
332
338
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as f, Fragment as d, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
3
|
import { Box as t, Divider as R } from "@mui/material";
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { checkSameProtocol as
|
|
4
|
+
import { LOGIN_PROVIDER as p } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { checkSameProtocol as C, getWebWalletUrl as k } from "@arcblock/ux/lib/Util/wallet";
|
|
6
6
|
import { detectWalletExtension as W } from "@arcblock/ux/lib/Util";
|
|
7
7
|
import { useCreation as q } from "ahooks";
|
|
8
8
|
import { useBrowser as j } from "@arcblock/react-hooks";
|
|
9
9
|
import T from "./mobile-login-item.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { useStateContext as
|
|
10
|
+
import P from "./web-login-item.js";
|
|
11
|
+
import v from "../back-button.js";
|
|
12
|
+
import { useStateContext as B } from "../../contexts/state.js";
|
|
13
13
|
function E({
|
|
14
|
-
qrcode:
|
|
14
|
+
qrcode: u,
|
|
15
15
|
tokenState: r,
|
|
16
|
-
webWalletUrl: n =
|
|
16
|
+
webWalletUrl: n = k(),
|
|
17
17
|
size: l = "small",
|
|
18
18
|
disableSwitchApp: m = !1,
|
|
19
|
-
tokenKey:
|
|
20
|
-
walletLoginRef:
|
|
21
|
-
webLoginRef:
|
|
22
|
-
onMobileLoginClick:
|
|
23
|
-
onWebLoginClick:
|
|
24
|
-
onBack:
|
|
19
|
+
tokenKey: b,
|
|
20
|
+
walletLoginRef: x = null,
|
|
21
|
+
webLoginRef: g = null,
|
|
22
|
+
onMobileLoginClick: h,
|
|
23
|
+
onWebLoginClick: L,
|
|
24
|
+
onBack: s
|
|
25
25
|
}) {
|
|
26
|
-
const { locale: w } =
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
|
|
29
|
-
/* @__PURE__ */
|
|
26
|
+
const { locale: w } = B(), i = j(), y = C(n), a = W(), c = q(() => i.mobile.tablet || !i.mobile.any && window?.navigator?.maxTouchPoints > 0, [i.mobile.tablet, i.mobile.any]);
|
|
27
|
+
return /* @__PURE__ */ f(d, { children: [
|
|
28
|
+
u,
|
|
29
|
+
/* @__PURE__ */ f(t, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
30
30
|
/* @__PURE__ */ e(t, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
|
|
31
31
|
R,
|
|
32
32
|
{
|
|
@@ -57,37 +57,37 @@ function E({
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
children:
|
|
60
|
+
children: c ? /* @__PURE__ */ e(
|
|
61
61
|
T,
|
|
62
62
|
{
|
|
63
|
-
ref:
|
|
63
|
+
ref: x,
|
|
64
64
|
tokenState: r,
|
|
65
|
-
isTablet:
|
|
65
|
+
isTablet: c,
|
|
66
66
|
sx: [l === "small" ? { p: 1 } : { p: 2 }],
|
|
67
67
|
locale: w,
|
|
68
|
-
tokenKey:
|
|
68
|
+
tokenKey: b,
|
|
69
69
|
disableSwitchApp: m,
|
|
70
|
-
onClick:
|
|
70
|
+
onClick: h
|
|
71
71
|
},
|
|
72
|
-
|
|
72
|
+
p.WALLET
|
|
73
73
|
) : (
|
|
74
74
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
75
|
-
/* @__PURE__ */ e(
|
|
76
|
-
|
|
75
|
+
/* @__PURE__ */ e(d, { children: (y || a) && (!i.mobile.any || a) ? /* @__PURE__ */ e(
|
|
76
|
+
P,
|
|
77
77
|
{
|
|
78
|
-
ref:
|
|
78
|
+
ref: g,
|
|
79
79
|
tokenState: r,
|
|
80
80
|
webWalletUrl: n,
|
|
81
81
|
sx: [l === "small" ? { p: 1 } : { p: 2 }],
|
|
82
82
|
disableSwitchApp: m,
|
|
83
|
-
onClick:
|
|
83
|
+
onClick: L
|
|
84
84
|
},
|
|
85
|
-
|
|
85
|
+
p.WALLET
|
|
86
86
|
) : null })
|
|
87
87
|
)
|
|
88
88
|
}
|
|
89
89
|
),
|
|
90
|
-
/* @__PURE__ */ e(
|
|
90
|
+
s && /* @__PURE__ */ e(v, { variant: "text", onClick: s })
|
|
91
91
|
] })
|
|
92
92
|
] });
|
|
93
93
|
}
|
package/lib/Connect/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import { getWalletDid as _t } from "../User/use-did.js";
|
|
|
34
34
|
import { getWebWalletUrl as Pt } from "@arcblock/ux/lib/Util/wallet";
|
|
35
35
|
function fe({
|
|
36
36
|
hideCloseButton: w = !1,
|
|
37
|
-
mode:
|
|
37
|
+
mode: p = "dialog",
|
|
38
38
|
action: I,
|
|
39
39
|
baseUrl: b = "",
|
|
40
40
|
checkFn: v,
|
|
@@ -129,12 +129,12 @@ function fe({
|
|
|
129
129
|
{ leading: !0, trailing: !1 }
|
|
130
130
|
);
|
|
131
131
|
ue(Me, [o.status]);
|
|
132
|
-
const Be = u(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), { providerList: Le, hideQRCode:
|
|
132
|
+
const Be = u(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), { providerList: Le, hideQRCode: m, hideChooseList: r } = Dt({
|
|
133
133
|
action: o.action,
|
|
134
134
|
sourceAppPid: s?.sourceAppPid,
|
|
135
135
|
allowWallet: V,
|
|
136
136
|
passkeyBehavior: Y,
|
|
137
|
-
mode:
|
|
137
|
+
mode: p,
|
|
138
138
|
blocklet: s?.sourceAppPid ? _e : $,
|
|
139
139
|
isSmallView: oe
|
|
140
140
|
}), Ne = Je(s?.sourceAppPid);
|
|
@@ -241,7 +241,7 @@ function fe({
|
|
|
241
241
|
)
|
|
242
242
|
}
|
|
243
243
|
);
|
|
244
|
-
}, [se, r, f]), je = u(() => r ? "column-reverse" : !
|
|
244
|
+
}, [se, r, f]), je = u(() => r ? "column-reverse" : !m && re ? "column" : "row", [r, re, m]), ce = u(() => E ? /* @__PURE__ */ t(
|
|
245
245
|
i,
|
|
246
246
|
{
|
|
247
247
|
sx: {
|
|
@@ -311,12 +311,12 @@ function fe({
|
|
|
311
311
|
justifyContent: "center",
|
|
312
312
|
alignItems: "stretch",
|
|
313
313
|
flex: 1,
|
|
314
|
-
gap: !
|
|
314
|
+
gap: !m && oe ? 0 : 1.5,
|
|
315
315
|
overflow: "visible",
|
|
316
316
|
px: r ? 2 : 0
|
|
317
317
|
},
|
|
318
318
|
children: [
|
|
319
|
-
!y && !
|
|
319
|
+
!y && !m ? /* @__PURE__ */ x(qe, { children: [
|
|
320
320
|
ce,
|
|
321
321
|
r ? null : /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
|
|
322
322
|
Ge,
|
|
@@ -351,8 +351,9 @@ function fe({
|
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
allowWallet: V,
|
|
354
|
-
size:
|
|
354
|
+
size: m && p !== "dialog" ? "normal" : "small",
|
|
355
355
|
tokenState: o,
|
|
356
|
+
hideQRCode: m,
|
|
356
357
|
messages: d,
|
|
357
358
|
tokenKey: j,
|
|
358
359
|
onSuccess: R,
|
|
@@ -383,7 +384,7 @@ function fe({
|
|
|
383
384
|
onSuccess: R,
|
|
384
385
|
onError: Q
|
|
385
386
|
}) : M = U;
|
|
386
|
-
const ae =
|
|
387
|
+
const ae = m || y ? rt : N;
|
|
387
388
|
return /* @__PURE__ */ x(
|
|
388
389
|
i,
|
|
389
390
|
{
|
|
@@ -398,7 +399,7 @@ function fe({
|
|
|
398
399
|
maxWidth: "100%",
|
|
399
400
|
width: (
|
|
400
401
|
// eslint-disable-next-line no-nested-ternary
|
|
401
|
-
|
|
402
|
+
p === "drawer" ? "100%" : f ? ae - 20 : ae
|
|
402
403
|
),
|
|
403
404
|
transition: "width 0.2s ease-in-out",
|
|
404
405
|
margin: "auto",
|
|
@@ -459,8 +460,8 @@ fe.propTypes = {
|
|
|
459
460
|
magicToken: e.string,
|
|
460
461
|
customItems: e.arrayOf(e.node)
|
|
461
462
|
};
|
|
462
|
-
function me({ testOnlyBorderColor: w = void 0, ...
|
|
463
|
-
const { checkFn: I, extraParams: b = {}, blocklet: v, masterBlocklet: D, action: T, locale: _ = "en" } =
|
|
463
|
+
function me({ testOnlyBorderColor: w = void 0, ...p }) {
|
|
464
|
+
const { checkFn: I, extraParams: b = {}, blocklet: v, masterBlocklet: D, action: T, locale: _ = "en" } = p;
|
|
464
465
|
if (typeof I != "function")
|
|
465
466
|
throw new Error("Cannot initialize did connect component without a fetchFn");
|
|
466
467
|
return /* @__PURE__ */ t(
|
|
@@ -484,7 +485,7 @@ function me({ testOnlyBorderColor: w = void 0, ...m }) {
|
|
|
484
485
|
boxSizing: "border-box"
|
|
485
486
|
}
|
|
486
487
|
},
|
|
487
|
-
children: /* @__PURE__ */ t(fe, { ...
|
|
488
|
+
children: /* @__PURE__ */ t(fe, { ...p })
|
|
488
489
|
}
|
|
489
490
|
);
|
|
490
491
|
}
|
package/lib/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-connect-react",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.8",
|
|
4
4
|
"description": "Client side library to work with DID Connect by ArcBlock.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "3.3.
|
|
35
|
+
"@arcblock/bridge": "3.3.8",
|
|
36
36
|
"@arcblock/did": "^1.27.16",
|
|
37
|
-
"@arcblock/icons": "3.3.
|
|
38
|
-
"@arcblock/react-hooks": "3.3.
|
|
37
|
+
"@arcblock/icons": "3.3.8",
|
|
38
|
+
"@arcblock/react-hooks": "3.3.8",
|
|
39
39
|
"@arcblock/ws": "^1.27.16",
|
|
40
40
|
"@blocklet/constant": "^1.17.6",
|
|
41
41
|
"@fontsource/lexend": "^5.2.9",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
82
82
|
"jest": "^29.7.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "b4c40eaa794d708a6d21b721306b8e1cf6fb00ce"
|
|
85
85
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { LOGIN_PROVIDER, LOGIN_PROVIDER_NAME, LOGIN_PROVIDER_ICON_SIZE } from '@arcblock/ux/lib/Util/constant';
|
|
4
|
-
import { getWebWalletUrl } from '@arcblock/ux/lib/Util/wallet';
|
|
4
|
+
import { checkSameProtocol, getWebWalletUrl } from '@arcblock/ux/lib/Util/wallet';
|
|
5
5
|
import noop from 'lodash/noop';
|
|
6
|
-
import { useMemoizedFn } from 'ahooks';
|
|
6
|
+
import { useMemoizedFn, useCreation } from 'ahooks';
|
|
7
7
|
import Cookie from 'js-cookie';
|
|
8
|
-
import { getCookieOptions } from '@arcblock/ux/lib/Util';
|
|
8
|
+
import { detectWalletExtension, getCookieOptions } from '@arcblock/ux/lib/Util';
|
|
9
9
|
import { useEffect, useRef } from 'react';
|
|
10
10
|
import { mergeSx } from '@arcblock/ux/lib/Util/style';
|
|
11
11
|
import ProviderIcon from '@arcblock/ux/lib/DIDConnect/provider-icon';
|
|
@@ -43,10 +43,13 @@ export default function ConnectProviderList({
|
|
|
43
43
|
baseUrl = '/',
|
|
44
44
|
customItems = [],
|
|
45
45
|
qrcode = null,
|
|
46
|
+
hideQRCode = false,
|
|
46
47
|
}) {
|
|
47
48
|
const walletLoginRef = useRef(null);
|
|
48
49
|
const webLoginRef = useRef(null);
|
|
49
50
|
const passkeyLoginRef = useRef(null);
|
|
51
|
+
const isSameProtocol = checkSameProtocol(webWalletUrl);
|
|
52
|
+
const extension = detectWalletExtension();
|
|
50
53
|
|
|
51
54
|
const browser = useBrowser();
|
|
52
55
|
|
|
@@ -153,6 +156,16 @@ export default function ConnectProviderList({
|
|
|
153
156
|
setShowWalletOptions(false);
|
|
154
157
|
});
|
|
155
158
|
|
|
159
|
+
const onlyWalletProvider = useCreation(() => {
|
|
160
|
+
return providerList.length === 1 && providerList[0].provider === LOGIN_PROVIDER.WALLET;
|
|
161
|
+
}, [providerList]);
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (onlyWalletProvider && !browser.mobile.any && !showWalletOptions) {
|
|
165
|
+
setShowWalletOptions(true);
|
|
166
|
+
}
|
|
167
|
+
}, [onlyWalletProvider, browser.mobile.any, setShowWalletOptions, showWalletOptions]);
|
|
168
|
+
|
|
156
169
|
const showEmailLogin = providerList.some((p) => p.provider === LOGIN_PROVIDER.EMAIL);
|
|
157
170
|
|
|
158
171
|
const emailPlugin = useEmailPlugin({ baseUrl });
|
|
@@ -213,7 +226,12 @@ export default function ConnectProviderList({
|
|
|
213
226
|
/>
|
|
214
227
|
);
|
|
215
228
|
}
|
|
216
|
-
|
|
229
|
+
// 是否显示 web 登录项
|
|
230
|
+
// 1. 如果隐藏了二维码,会在新页面显示 wallet 登录项
|
|
231
|
+
// 2. 如果显示了二维码,不需要在新页面显示 wallet 登录项,根据是否是同一协议、是否安装了钱包扩展、是否是移动端来判断是否显示
|
|
232
|
+
const shouldShowWebLoginItem =
|
|
233
|
+
hideQRCode || (!hideQRCode && (isSameProtocol || extension) && (!browser.mobile.any || extension));
|
|
234
|
+
return shouldShowWebLoginItem ? (
|
|
217
235
|
<WebLoginItem
|
|
218
236
|
key={LOGIN_PROVIDER.WALLET}
|
|
219
237
|
ref={webLoginRef}
|
|
@@ -221,12 +239,16 @@ export default function ConnectProviderList({
|
|
|
221
239
|
webWalletUrl={webWalletUrl}
|
|
222
240
|
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
223
241
|
disableSwitchApp={disableSwitchApp}
|
|
224
|
-
autoConnect={
|
|
242
|
+
autoConnect={!hideQRCode}
|
|
225
243
|
onClick={() => {
|
|
226
|
-
|
|
244
|
+
if (!hideQRCode) {
|
|
245
|
+
handleWebLoginClick();
|
|
246
|
+
} else {
|
|
247
|
+
setShowWalletOptions(true);
|
|
248
|
+
}
|
|
227
249
|
}}
|
|
228
250
|
/>
|
|
229
|
-
);
|
|
251
|
+
) : null;
|
|
230
252
|
}
|
|
231
253
|
|
|
232
254
|
if (item.provider === LOGIN_PROVIDER.PASSKEY) {
|
|
@@ -339,7 +361,7 @@ export default function ConnectProviderList({
|
|
|
339
361
|
webLoginRef={webLoginRef}
|
|
340
362
|
onMobileLoginClick={handleMobileLoginClick}
|
|
341
363
|
onWebLoginClick={handleWebLoginClick}
|
|
342
|
-
onBack={handleWalletLoginBack}
|
|
364
|
+
onBack={onlyWalletProvider ? undefined : handleWalletLoginBack}
|
|
343
365
|
/>
|
|
344
366
|
) : (
|
|
345
367
|
<Box
|
|
@@ -429,4 +451,5 @@ ConnectProviderList.propTypes = {
|
|
|
429
451
|
baseUrl: PropTypes.string,
|
|
430
452
|
customItems: PropTypes.arrayOf(PropTypes.node),
|
|
431
453
|
qrcode: PropTypes.node,
|
|
454
|
+
hideQRCode: PropTypes.bool,
|
|
432
455
|
};
|
package/src/Connect/index.jsx
CHANGED