@arcblock/did-connect-react 3.3.7 → 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.
|
@@ -1,174 +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
|
|
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
|
|
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
13
|
import { GA_LAST_LOGIN_METHOD as g } from "@arcblock/ux/lib/withTracker/constant";
|
|
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
|
|
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:
|
|
34
|
+
webWalletUrl: x = ue(),
|
|
35
|
+
tokenKey: W,
|
|
36
36
|
passkeyBehavior: T = "none",
|
|
37
|
-
onReset: C =
|
|
37
|
+
onReset: C = b,
|
|
38
38
|
providerList: d = [],
|
|
39
|
-
slotProps:
|
|
39
|
+
slotProps: $ = {},
|
|
40
40
|
disableSwitchApp: A = !1,
|
|
41
|
-
forceUpdate:
|
|
42
|
-
magicToken:
|
|
43
|
-
baseUrl:
|
|
44
|
-
customItems:
|
|
45
|
-
qrcode:
|
|
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:
|
|
52
|
+
plugins: F,
|
|
53
|
+
setPlugins: re,
|
|
54
|
+
setSelectedPlugin: ie,
|
|
55
|
+
getPlugin: B,
|
|
55
56
|
showWalletOptions: h,
|
|
56
|
-
setShowWalletOptions:
|
|
57
|
-
} =
|
|
57
|
+
setShowWalletOptions: y
|
|
58
|
+
} = ve(), le = a((e, t = {}) => Ie(Re, e, D, "en", t)), G = a(async (e) => {
|
|
58
59
|
localStorage.setItem(g, e.provider), n.reset(), s.reset({
|
|
59
60
|
status: "scanned"
|
|
60
|
-
}),
|
|
61
|
-
const
|
|
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
|
-
sourceAppPid:
|
|
76
|
-
connected_app:
|
|
76
|
+
sourceAppPid: t,
|
|
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
|
+
}), U = a(async () => {
|
|
85
86
|
n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
|
|
86
|
-
}),
|
|
87
|
+
}), q = a(async () => {
|
|
87
88
|
localStorage.setItem(g, "wallet"), n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
|
|
88
|
-
const e =
|
|
89
|
+
const e = E.current?.connect;
|
|
89
90
|
i.retryConnect = () => {
|
|
90
|
-
e(
|
|
91
|
+
e(U);
|
|
91
92
|
};
|
|
92
|
-
}),
|
|
93
|
+
}), V = a(() => {
|
|
93
94
|
localStorage.setItem(g, "wallet"), n.status = "scanned", i.chooseMethod = "wallet-web";
|
|
94
|
-
const e =
|
|
95
|
+
const e = P.current.connect;
|
|
95
96
|
i.retryConnect = async () => {
|
|
96
97
|
await C(), n.error = "", n.status = "scanned", e();
|
|
97
98
|
};
|
|
98
|
-
}),
|
|
99
|
-
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}, [
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const e =
|
|
107
|
-
e.state.status === "idle" && (localStorage.setItem(g, "email"), e.state.reset(), e.state.magicToken =
|
|
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());
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
|
-
|
|
111
|
+
Z(() => {
|
|
111
112
|
const e = [];
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
|
|
113
|
+
if (K) {
|
|
114
|
+
const t = B(r.EMAIL);
|
|
115
|
+
t && t.baseUrl === Y.baseUrl ? e.push(t) : e.push(Y);
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
re(e), i.retryConnect = U, setTimeout(() => {
|
|
118
|
+
ce();
|
|
118
119
|
}, 100);
|
|
119
|
-
}, [
|
|
120
|
-
const
|
|
121
|
-
if (e.provider ===
|
|
122
|
-
return
|
|
123
|
-
|
|
120
|
+
}, [K]);
|
|
121
|
+
const H = d.map((e) => {
|
|
122
|
+
if (e.provider === r.WALLET)
|
|
123
|
+
return p.mobile.any && !h ? /* @__PURE__ */ l(
|
|
124
|
+
Ce,
|
|
124
125
|
{
|
|
125
|
-
ref:
|
|
126
|
+
ref: E,
|
|
126
127
|
tokenState: n,
|
|
127
128
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
128
|
-
locale:
|
|
129
|
-
tokenKey:
|
|
129
|
+
locale: D,
|
|
130
|
+
tokenKey: W,
|
|
130
131
|
disableSwitchApp: A,
|
|
131
|
-
onClick:
|
|
132
|
+
onClick: q
|
|
132
133
|
},
|
|
133
|
-
|
|
134
|
-
) : /* @__PURE__ */ l(
|
|
135
|
-
|
|
134
|
+
r.WALLET
|
|
135
|
+
) : f || !f && (ee || S) && (!p.mobile.any || S) ? /* @__PURE__ */ l(
|
|
136
|
+
Ae,
|
|
136
137
|
{
|
|
137
|
-
ref:
|
|
138
|
+
ref: P,
|
|
138
139
|
tokenState: n,
|
|
139
|
-
webWalletUrl:
|
|
140
|
+
webWalletUrl: x,
|
|
140
141
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
141
142
|
disableSwitchApp: A,
|
|
142
|
-
autoConnect: !
|
|
143
|
+
autoConnect: !f,
|
|
143
144
|
onClick: () => {
|
|
144
|
-
f(!0);
|
|
145
|
+
f ? y(!0) : V();
|
|
145
146
|
}
|
|
146
147
|
},
|
|
147
|
-
|
|
148
|
-
);
|
|
149
|
-
if (e.provider ===
|
|
148
|
+
r.WALLET
|
|
149
|
+
) : null;
|
|
150
|
+
if (e.provider === r.PASSKEY)
|
|
150
151
|
return T === "none" ? null : /* @__PURE__ */ l(
|
|
151
|
-
|
|
152
|
+
We,
|
|
152
153
|
{
|
|
153
154
|
ref: R,
|
|
154
|
-
onSuccess:
|
|
155
|
-
onError:
|
|
155
|
+
onSuccess: _,
|
|
156
|
+
onError: O,
|
|
156
157
|
tokenState: n,
|
|
157
158
|
behavior: T,
|
|
158
159
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
159
160
|
onClick: () => {
|
|
160
161
|
localStorage.setItem(g, "passkey");
|
|
161
|
-
const
|
|
162
|
+
const t = R.current.connect;
|
|
162
163
|
i.chooseMethod = "passkey", i.retryConnect = () => {
|
|
163
|
-
|
|
164
|
+
j.verifying = !0, i.chooseMethod = "passkey", t();
|
|
164
165
|
};
|
|
165
166
|
},
|
|
166
167
|
slotProps: {
|
|
167
168
|
icon: {
|
|
168
169
|
sx: {
|
|
169
|
-
fontSize:
|
|
170
|
+
fontSize: I,
|
|
170
171
|
"& svg": {
|
|
171
|
-
fontSize:
|
|
172
|
+
fontSize: I,
|
|
172
173
|
width: "1em",
|
|
173
174
|
height: "1em"
|
|
174
175
|
}
|
|
@@ -176,35 +177,35 @@ function Oe({
|
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
},
|
|
179
|
-
|
|
180
|
+
r.PASSKEY
|
|
180
181
|
);
|
|
181
|
-
if (e.provider ===
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
key:
|
|
182
|
+
if (e.provider === r.EMAIL) {
|
|
183
|
+
const t = F.find((c) => c.name === r.EMAIL);
|
|
184
|
+
return t ? t?.renderListItem({
|
|
185
|
+
key: t.name,
|
|
185
186
|
sx: [m === "small" ? { p: 1 } : { p: 2 }]
|
|
186
187
|
// forceUpdate,
|
|
187
188
|
}) : null;
|
|
188
189
|
}
|
|
189
190
|
return e.type === "oauth" ? /* @__PURE__ */ l(
|
|
190
|
-
|
|
191
|
+
Ee,
|
|
191
192
|
{
|
|
192
|
-
title:
|
|
193
|
+
title: de[e.provider],
|
|
193
194
|
icon: /* @__PURE__ */ l(
|
|
194
|
-
|
|
195
|
+
Le,
|
|
195
196
|
{
|
|
196
197
|
provider: e.provider,
|
|
197
198
|
sx: {
|
|
198
199
|
transform: "scale(0.95)",
|
|
199
|
-
width:
|
|
200
|
-
height:
|
|
200
|
+
width: I,
|
|
201
|
+
height: I,
|
|
201
202
|
color: "text.primary"
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
),
|
|
205
206
|
onClick: () => {
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
G(e), i.retryConnect = () => {
|
|
208
|
+
G(e);
|
|
208
209
|
};
|
|
209
210
|
},
|
|
210
211
|
sx: [m === "small" ? { p: 1.2 } : { p: 2 }]
|
|
@@ -212,42 +213,42 @@ function Oe({
|
|
|
212
213
|
e.provider
|
|
213
214
|
) : null;
|
|
214
215
|
}).filter(Boolean);
|
|
215
|
-
return /* @__PURE__ */ l(
|
|
216
|
-
|
|
216
|
+
return /* @__PURE__ */ l(L, { className: "did-connect__choose", sx: ye({ flex: 1 }, $?.root?.sx), children: /* @__PURE__ */ l(
|
|
217
|
+
L,
|
|
217
218
|
{
|
|
218
219
|
sx: {
|
|
219
220
|
display: "flex",
|
|
220
221
|
flexDirection: "column",
|
|
221
222
|
gap: 2
|
|
222
223
|
},
|
|
223
|
-
children: /* @__PURE__ */
|
|
224
|
-
|
|
224
|
+
children: /* @__PURE__ */ me(
|
|
225
|
+
L,
|
|
225
226
|
{
|
|
226
227
|
sx: [
|
|
227
228
|
{
|
|
228
229
|
display: "flex",
|
|
229
230
|
flexDirection: "column",
|
|
230
|
-
...h && !
|
|
231
|
+
...h && !p.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
|
|
231
232
|
}
|
|
232
233
|
],
|
|
233
234
|
children: [
|
|
234
|
-
h && !
|
|
235
|
-
|
|
235
|
+
h && !p.mobile.any ? /* @__PURE__ */ l(
|
|
236
|
+
Pe,
|
|
236
237
|
{
|
|
237
|
-
qrcode:
|
|
238
|
+
qrcode: Q,
|
|
238
239
|
tokenState: n,
|
|
239
|
-
webWalletUrl:
|
|
240
|
+
webWalletUrl: x,
|
|
240
241
|
size: m,
|
|
241
242
|
disableSwitchApp: A,
|
|
242
|
-
tokenKey:
|
|
243
|
-
walletLoginRef:
|
|
244
|
-
webLoginRef:
|
|
245
|
-
onMobileLoginClick:
|
|
246
|
-
onWebLoginClick:
|
|
247
|
-
onBack:
|
|
243
|
+
tokenKey: W,
|
|
244
|
+
walletLoginRef: E,
|
|
245
|
+
webLoginRef: P,
|
|
246
|
+
onMobileLoginClick: q,
|
|
247
|
+
onWebLoginClick: V,
|
|
248
|
+
onBack: M ? void 0 : se
|
|
248
249
|
}
|
|
249
250
|
) : /* @__PURE__ */ l(
|
|
250
|
-
|
|
251
|
+
L,
|
|
251
252
|
{
|
|
252
253
|
sx: {
|
|
253
254
|
display: "grid",
|
|
@@ -292,8 +293,8 @@ function Oe({
|
|
|
292
293
|
}
|
|
293
294
|
}
|
|
294
295
|
},
|
|
295
|
-
children:
|
|
296
|
-
|
|
296
|
+
children: H.length > 0 ? H : /* @__PURE__ */ l(
|
|
297
|
+
be,
|
|
297
298
|
{
|
|
298
299
|
className: "arc-login-item",
|
|
299
300
|
sx: {
|
|
@@ -301,19 +302,19 @@ function Oe({
|
|
|
301
302
|
textAlign: "center"
|
|
302
303
|
}
|
|
303
304
|
},
|
|
304
|
-
children:
|
|
305
|
+
children: le("noAuthenticationProvider")
|
|
305
306
|
}
|
|
306
307
|
)
|
|
307
308
|
}
|
|
308
309
|
),
|
|
309
|
-
|
|
310
|
+
z.map((e) => e || null)
|
|
310
311
|
]
|
|
311
312
|
}
|
|
312
313
|
)
|
|
313
314
|
}
|
|
314
315
|
) });
|
|
315
316
|
}
|
|
316
|
-
|
|
317
|
+
Se.propTypes = {
|
|
317
318
|
onSuccess: o.func,
|
|
318
319
|
onError: o.func,
|
|
319
320
|
size: o.oneOf(["small", "normal", "large"]),
|
|
@@ -329,8 +330,9 @@ Oe.propTypes = {
|
|
|
329
330
|
magicToken: o.string,
|
|
330
331
|
baseUrl: o.string,
|
|
331
332
|
customItems: o.arrayOf(o.node),
|
|
332
|
-
qrcode: o.node
|
|
333
|
+
qrcode: o.node,
|
|
334
|
+
hideQRCode: o.bool
|
|
333
335
|
};
|
|
334
336
|
export {
|
|
335
|
-
|
|
337
|
+
Se as default
|
|
336
338
|
};
|
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
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
|
|
|
@@ -223,7 +226,12 @@ export default function ConnectProviderList({
|
|
|
223
226
|
/>
|
|
224
227
|
);
|
|
225
228
|
}
|
|
226
|
-
|
|
229
|
+
// 是否显示 web 登录项
|
|
230
|
+
// 1. 如果隐藏了二维码,会在新页面显示 wallet 登录项
|
|
231
|
+
// 2. 如果显示了二维码,不需要在新页面显示 wallet 登录项,根据是否是同一协议、是否安装了钱包扩展、是否是移动端来判断是否显示
|
|
232
|
+
const shouldShowWebLoginItem =
|
|
233
|
+
hideQRCode || (!hideQRCode && (isSameProtocol || extension) && (!browser.mobile.any || extension));
|
|
234
|
+
return shouldShowWebLoginItem ? (
|
|
227
235
|
<WebLoginItem
|
|
228
236
|
key={LOGIN_PROVIDER.WALLET}
|
|
229
237
|
ref={webLoginRef}
|
|
@@ -231,12 +239,16 @@ export default function ConnectProviderList({
|
|
|
231
239
|
webWalletUrl={webWalletUrl}
|
|
232
240
|
sx={[size === 'small' ? { p: 1 } : { p: 2 }]}
|
|
233
241
|
disableSwitchApp={disableSwitchApp}
|
|
234
|
-
autoConnect={
|
|
242
|
+
autoConnect={!hideQRCode}
|
|
235
243
|
onClick={() => {
|
|
236
|
-
|
|
244
|
+
if (!hideQRCode) {
|
|
245
|
+
handleWebLoginClick();
|
|
246
|
+
} else {
|
|
247
|
+
setShowWalletOptions(true);
|
|
248
|
+
}
|
|
237
249
|
}}
|
|
238
250
|
/>
|
|
239
|
-
);
|
|
251
|
+
) : null;
|
|
240
252
|
}
|
|
241
253
|
|
|
242
254
|
if (item.provider === LOGIN_PROVIDER.PASSKEY) {
|
|
@@ -439,4 +451,5 @@ ConnectProviderList.propTypes = {
|
|
|
439
451
|
baseUrl: PropTypes.string,
|
|
440
452
|
customItems: PropTypes.arrayOf(PropTypes.node),
|
|
441
453
|
qrcode: PropTypes.node,
|
|
454
|
+
hideQRCode: PropTypes.bool,
|
|
442
455
|
};
|
package/src/Connect/index.jsx
CHANGED