@arcblock/did-connect-react 3.3.7 → 3.3.9

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 se } from "react/jsx-runtime";
1
+ import { jsx as l, jsxs as me } from "react/jsx-runtime";
2
2
  import o from "prop-types";
3
- import { Box as y } from "@mui/material";
4
- import { LOGIN_PROVIDER as t, LOGIN_PROVIDER_ICON_SIZE as L, LOGIN_PROVIDER_NAME as ae } from "@arcblock/ux/lib/Util/constant";
5
- import { getWebWalletUrl as ce } from "@arcblock/ux/lib/Util/wallet";
6
- import I from "lodash/noop";
7
- import { useMemoizedFn as c, useCreation as me } from "ahooks";
8
- import M from "js-cookie";
9
- import { getCookieOptions as de } from "@arcblock/ux/lib/Util";
10
- import { useRef as P, useEffect as K } from "react";
11
- import { mergeSx as pe } from "@arcblock/ux/lib/Util/style";
12
- import ue from "@arcblock/ux/lib/DIDConnect/provider-icon";
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 he } from "@arcblock/ux/lib/Locale/util";
15
- import ge from "@arcblock/ux/lib/Empty";
16
- import { useBrowser as fe } from "@arcblock/react-hooks";
17
- import ye from "./mobile-login-item.js";
18
- import Le from "./web-login-item.js";
19
- import Ie from "./login-method-item.js";
20
- import Ce from "./wallet-login-options.js";
21
- import { useOAuth as Ae } from "../../../OAuth/context.js";
22
- import { useStateContext as be } from "../../contexts/state.js";
23
- import { getAppId as xe, logger as Ee, getApiErrorMessage as Me } from "../../../utils.js";
24
- import Pe from "./passkey-login-item.js";
25
- import { usePasskey as ve } from "../../../Passkey/context.js";
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 _e from "../../plugins/email/index.js";
28
- import we from "../../assets/locale.js";
29
- function Oe({
30
- onSuccess: v = I,
31
- onError: _ = I,
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: w = ce(),
35
- tokenKey: O,
34
+ webWalletUrl: x = ue(),
35
+ tokenKey: W,
36
36
  passkeyBehavior: T = "none",
37
- onReset: C = I,
37
+ onReset: C = b,
38
38
  providerList: d = [],
39
- slotProps: Y = {},
39
+ slotProps: $ = {},
40
40
  disableSwitchApp: A = !1,
41
- forceUpdate: H = I,
42
- magicToken: W = void 0,
43
- baseUrl: Z = "/",
44
- customItems: $ = [],
45
- qrcode: J = null
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 b = P(null), x = P(null), R = P(null), u = fe(), { loginOAuth: Q, logoutOAuth: X, t: z, oauthState: s } = Ae(), { passkeyState: k } = ve(), {
48
- extraParams: j,
49
- locale: N,
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: D,
52
- setPlugins: ee,
53
- setSelectedPlugin: oe,
54
- getPlugin: F,
52
+ plugins: F,
53
+ setPlugins: re,
54
+ setSelectedPlugin: ie,
55
+ getPlugin: B,
55
56
  showWalletOptions: h,
56
- setShowWalletOptions: f
57
- } = be(), ne = c((e, r = {}) => he(we, e, N, "en", r)), S = c(async (e) => {
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
- }), k.reset(), i.chooseMethod = e.provider;
61
- const r = j?.sourceAppPid;
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 a = await Q(e, {
65
+ const c = await oe(e, {
65
66
  action: n.action,
66
- ...j
67
- }), p = de({ returnDomain: !1 });
68
- M.remove("connected_did", p), M.remove("connected_pk", p), M.remove("connected_wallet_os", p), a?.sessionToken && (await v(
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
- ...a,
71
+ ...c,
71
72
  encrypted: !1
72
73
  },
73
- (le) => le,
74
+ (ae) => ae,
74
75
  {
75
- sourceAppPid: r,
76
- connected_app: xe(n.appInfo, n.memberAppInfo)
76
+ sourceAppPid: t,
77
+ connected_app: we(n.appInfo, n.memberAppInfo)
77
78
  }
78
79
  ), s.loading = !1, s.status = "succeed");
79
- } catch (a) {
80
- Ee.error(`Failed login OAuth: ${e.provider}`, a);
81
- const p = Me(a, z("loginOAuthFailed"));
82
- s.loading = !1, s.error = p, s.status = "error", await X({ provider: e.provider }), _(new Error(p));
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
- }), B = c(async () => {
85
+ }), U = a(async () => {
85
86
  n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
86
- }), G = c(async () => {
87
+ }), q = a(async () => {
87
88
  localStorage.setItem(g, "wallet"), n.reset(), await C(), n.status = "created", i.chooseMethod = "wallet";
88
- const e = b.current?.connect;
89
+ const e = E.current?.connect;
89
90
  i.retryConnect = () => {
90
- e(B);
91
+ e(U);
91
92
  };
92
- }), te = c(() => {
93
+ }), V = a(() => {
93
94
  localStorage.setItem(g, "wallet"), n.status = "scanned", i.chooseMethod = "wallet-web";
94
- const e = x.current.connect;
95
+ const e = P.current.connect;
95
96
  i.retryConnect = async () => {
96
97
  await C(), n.error = "", n.status = "scanned", e();
97
98
  };
98
- }), re = c(() => {
99
- f(!1);
100
- }), E = me(() => d.length === 1 && d[0].provider === t.WALLET, [d]);
101
- K(() => {
102
- E && !u.mobile.any && !h && f(!0);
103
- }, [E, u.mobile.any, f, h]);
104
- const U = d.some((e) => e.provider === t.EMAIL), q = _e({ baseUrl: Z }), ie = c(() => {
105
- if (W && d.some((e) => e.name === t.EMAIL) && D.some((e) => e.name === t.EMAIL)) {
106
- const e = F(t.EMAIL);
107
- e.state.status === "idle" && (localStorage.setItem(g, "email"), e.state.reset(), e.state.magicToken = W, i.chooseMethod = t.EMAIL, oe(e), H());
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
- K(() => {
111
+ Z(() => {
111
112
  const e = [];
112
- if (U) {
113
- const r = F(t.EMAIL);
114
- r && r.baseUrl === q.baseUrl ? e.push(r) : e.push(q);
113
+ if (K) {
114
+ const t = B(r.EMAIL);
115
+ t && t.baseUrl === Y.baseUrl ? e.push(t) : e.push(Y);
115
116
  }
116
- ee(e), i.retryConnect = B, setTimeout(() => {
117
- ie();
117
+ re(e), i.retryConnect = U, setTimeout(() => {
118
+ ce();
118
119
  }, 100);
119
- }, [U]);
120
- const V = d.map((e) => {
121
- if (e.provider === t.WALLET)
122
- return u.mobile.any && !h ? /* @__PURE__ */ l(
123
- ye,
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: b,
126
+ ref: E,
126
127
  tokenState: n,
127
128
  sx: [m === "small" ? { p: 1 } : { p: 2 }],
128
- locale: N,
129
- tokenKey: O,
129
+ locale: D,
130
+ tokenKey: W,
130
131
  disableSwitchApp: A,
131
- onClick: G
132
+ onClick: q
132
133
  },
133
- t.WALLET
134
- ) : /* @__PURE__ */ l(
135
- Le,
134
+ r.WALLET
135
+ ) : f || !f && (ee || S) && (!p.mobile.any || S) ? /* @__PURE__ */ l(
136
+ Ae,
136
137
  {
137
- ref: x,
138
+ ref: P,
138
139
  tokenState: n,
139
- webWalletUrl: w,
140
+ webWalletUrl: x,
140
141
  sx: [m === "small" ? { p: 1 } : { p: 2 }],
141
142
  disableSwitchApp: A,
142
- autoConnect: !1,
143
+ autoConnect: !f,
143
144
  onClick: () => {
144
- f(!0);
145
+ f ? y(!0) : V();
145
146
  }
146
147
  },
147
- t.WALLET
148
- );
149
- if (e.provider === t.PASSKEY)
148
+ r.WALLET
149
+ ) : null;
150
+ if (e.provider === r.PASSKEY)
150
151
  return T === "none" ? null : /* @__PURE__ */ l(
151
- Pe,
152
+ We,
152
153
  {
153
154
  ref: R,
154
- onSuccess: v,
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 r = R.current.connect;
162
+ const t = R.current.connect;
162
163
  i.chooseMethod = "passkey", i.retryConnect = () => {
163
- k.verifying = !0, i.chooseMethod = "passkey", r();
164
+ j.verifying = !0, i.chooseMethod = "passkey", t();
164
165
  };
165
166
  },
166
167
  slotProps: {
167
168
  icon: {
168
169
  sx: {
169
- fontSize: L,
170
+ fontSize: I,
170
171
  "& svg": {
171
- fontSize: L,
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
- t.PASSKEY
180
+ r.PASSKEY
180
181
  );
181
- if (e.provider === t.EMAIL) {
182
- const r = D.find((a) => a.name === t.EMAIL);
183
- return r ? r?.renderListItem({
184
- key: r.name,
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
- Ie,
191
+ Ee,
191
192
  {
192
- title: ae[e.provider],
193
+ title: de[e.provider],
193
194
  icon: /* @__PURE__ */ l(
194
- ue,
195
+ Le,
195
196
  {
196
197
  provider: e.provider,
197
198
  sx: {
198
199
  transform: "scale(0.95)",
199
- width: L,
200
- height: L,
200
+ width: I,
201
+ height: I,
201
202
  color: "text.primary"
202
203
  }
203
204
  }
204
205
  ),
205
206
  onClick: () => {
206
- S(e), i.retryConnect = () => {
207
- S(e);
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(y, { className: "did-connect__choose", sx: pe({ flex: 1 }, Y?.root?.sx), children: /* @__PURE__ */ l(
216
- y,
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__ */ se(
224
- y,
224
+ children: /* @__PURE__ */ me(
225
+ L,
225
226
  {
226
227
  sx: [
227
228
  {
228
229
  display: "flex",
229
230
  flexDirection: "column",
230
- ...h && !u.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
231
+ ...h && !p.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
231
232
  }
232
233
  ],
233
234
  children: [
234
- h && !u.mobile.any ? /* @__PURE__ */ l(
235
- Ce,
235
+ h && !p.mobile.any ? /* @__PURE__ */ l(
236
+ Pe,
236
237
  {
237
- qrcode: J,
238
+ qrcode: Q,
238
239
  tokenState: n,
239
- webWalletUrl: w,
240
+ webWalletUrl: x,
240
241
  size: m,
241
242
  disableSwitchApp: A,
242
- tokenKey: O,
243
- walletLoginRef: b,
244
- webLoginRef: x,
245
- onMobileLoginClick: G,
246
- onWebLoginClick: te,
247
- onBack: E ? void 0 : re
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
- y,
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: V.length > 0 ? V : /* @__PURE__ */ l(
296
- ge,
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: ne("noAuthenticationProvider")
305
+ children: le("noAuthenticationProvider")
305
306
  }
306
307
  )
307
308
  }
308
309
  ),
309
- $.map((e) => e || null)
310
+ z.map((e) => e || null)
310
311
  ]
311
312
  }
312
313
  )
313
314
  }
314
315
  ) });
315
316
  }
316
- Oe.propTypes = {
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
- Oe as default
337
+ Se as default
336
338
  };
@@ -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: m = "dialog",
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: p, hideChooseList: r } = Dt({
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: m,
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" : !p && re ? "column" : "row", [r, re, p]), ce = u(() => E ? /* @__PURE__ */ t(
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: !p && oe ? 0 : 1.5,
314
+ gap: !m && oe ? 0 : 1.5,
315
315
  overflow: "visible",
316
316
  px: r ? 2 : 0
317
317
  },
318
318
  children: [
319
- !y && !p ? /* @__PURE__ */ x(qe, { children: [
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: p && m !== "dialog" ? "normal" : "small",
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 = p || y ? rt : N;
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
- m === "drawer" ? "100%" : f ? ae - 20 : ae
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, ...m }) {
463
- const { checkFn: I, extraParams: b = {}, blocklet: v, masterBlocklet: D, action: T, locale: _ = "en" } = m;
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, { ...m })
488
+ children: /* @__PURE__ */ t(fe, { ...p })
488
489
  }
489
490
  );
490
491
  }
@@ -1,4 +1,4 @@
1
- const o = "3.3.7", s = {
1
+ const o = "3.3.9", s = {
2
2
  version: o
3
3
  };
4
4
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/did-connect-react",
3
- "version": "3.3.7",
3
+ "version": "3.3.9",
4
4
  "description": "Client side library to work with DID Connect by ArcBlock.",
5
5
  "keywords": [
6
6
  "react",
@@ -32,12 +32,12 @@
32
32
  "url": "https://github.com/ArcBlock/ux/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@arcblock/bridge": "3.3.7",
35
+ "@arcblock/bridge": "3.3.9",
36
36
  "@arcblock/did": "^1.27.16",
37
- "@arcblock/icons": "3.3.7",
38
- "@arcblock/react-hooks": "3.3.7",
37
+ "@arcblock/icons": "3.3.9",
38
+ "@arcblock/react-hooks": "3.3.9",
39
39
  "@arcblock/ws": "^1.27.16",
40
- "@blocklet/constant": "^1.17.6",
40
+ "@blocklet/constant": "^1.17.7",
41
41
  "@fontsource/lexend": "^5.2.9",
42
42
  "@iconify-icons/logos": "^1.2.36",
43
43
  "@iconify-icons/material-symbols": "^1.2.58",
@@ -81,5 +81,5 @@
81
81
  "eslint-plugin-react-hooks": "^4.6.2",
82
82
  "jest": "^29.7.0"
83
83
  },
84
- "gitHead": "cd0e3b812192ce054be488bcb60ed3f44e81fdff"
84
+ "gitHead": "c7a122040ee66c92cb979d185ad4a30cb80ef3fa"
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
- return (
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={false}
242
+ autoConnect={!hideQRCode}
235
243
  onClick={() => {
236
- setShowWalletOptions(true);
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
  };
@@ -467,6 +467,7 @@ function Connect({
467
467
  allowWallet={allowWallet}
468
468
  size={hideQRCode && mode !== 'dialog' ? 'normal' : 'small'}
469
469
  tokenState={state}
470
+ hideQRCode={hideQRCode}
470
471
  messages={messages}
471
472
  tokenKey={tokenKey}
472
473
  onSuccess={onSuccess}