@arcblock/did-connect-react 3.4.8 → 3.4.10

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,34 +1,37 @@
1
- import { jsxs as d, Fragment as p, jsx as e } from "react/jsx-runtime";
1
+ import { jsxs as f, Fragment as p, jsx as e } from "react/jsx-runtime";
2
2
  import o from "prop-types";
3
- import { Box as t, Divider as C } from "@mui/material";
3
+ import { Box as i, Divider as q } from "@mui/material";
4
4
  import { LOGIN_PROVIDER as u } from "@arcblock/ux/lib/Util/constant";
5
- import { checkSameProtocol as k, getWebWalletUrl as W } from "@arcblock/ux/lib/Util/wallet";
6
- import { detectWalletExtension as q } from "@arcblock/ux/lib/Util";
7
- import { useCreation as j } from "ahooks";
8
- import { useBrowser as T } from "@arcblock/react-hooks";
9
- import P from "./mobile-login-item.js";
10
- import v from "./web-login-item.js";
11
- import B from "../back-button.js";
12
- import { useStateContext as E } from "../../contexts/state.js";
13
- function I({
14
- qrcode: b,
5
+ import { checkSameProtocol as T, getWebWalletUrl as j } from "@arcblock/ux/lib/Util/wallet";
6
+ import { detectWalletExtension as v } from "@arcblock/ux/lib/Util";
7
+ import { useCreation as I } from "ahooks";
8
+ import { useBrowser as P } from "@arcblock/react-hooks";
9
+ import A from "./mobile-login-item.js";
10
+ import B from "./web-login-item.js";
11
+ import E from "../back-button.js";
12
+ import { useStateContext as O } from "../../contexts/state.js";
13
+ function S({
14
+ qrcode: g,
15
15
  tokenState: r,
16
- webWalletUrl: n = W(),
16
+ webWalletUrl: n = j(),
17
17
  size: l = "small",
18
- disableSwitchApp: m = !1,
18
+ disableSwitchApp: s = !1,
19
19
  tokenKey: x,
20
- walletLoginRef: g = null,
20
+ walletLoginRef: b = null,
21
21
  webLoginRef: h = null,
22
22
  onMobileLoginClick: L,
23
- onWebLoginClick: w,
24
- onBack: s
23
+ onWebLoginClick: C,
24
+ onBack: a
25
25
  }) {
26
- const { t: a, locale: y } = E(), i = T(), R = k(n), c = q(), f = j(() => i.mobile.tablet || !i.mobile.any && window?.navigator?.maxTouchPoints > 0, [i.mobile.tablet, i.mobile.any]);
27
- return /* @__PURE__ */ d(p, { children: [
28
- b,
29
- /* @__PURE__ */ d(t, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
30
- /* @__PURE__ */ e(t, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
31
- C,
26
+ const { t: c, locale: R } = O(), w = P(), k = T(n), m = v(), d = I(() => {
27
+ const t = navigator.userAgent.toLowerCase(), y = /ipad/.test(t) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, W = /android/.test(t) && !/mobile/.test(t);
28
+ return !!(y || W);
29
+ }, []);
30
+ return /* @__PURE__ */ f(p, { children: [
31
+ g,
32
+ /* @__PURE__ */ f(i, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
33
+ /* @__PURE__ */ e(i, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
34
+ q,
32
35
  {
33
36
  orientation: "horizontal",
34
37
  sx: {
@@ -42,7 +45,7 @@ function I({
42
45
  }
43
46
  ) }),
44
47
  /* @__PURE__ */ e(
45
- t,
48
+ i,
46
49
  {
47
50
  sx: {
48
51
  width: "100%",
@@ -57,43 +60,43 @@ function I({
57
60
  }
58
61
  }
59
62
  },
60
- children: f ? /* @__PURE__ */ e(
61
- P,
63
+ children: d ? /* @__PURE__ */ e(
64
+ A,
62
65
  {
63
- t: a,
64
- ref: g,
66
+ t: c,
67
+ ref: b,
65
68
  tokenState: r,
66
- isTablet: f,
69
+ isTablet: d,
67
70
  sx: [l === "small" ? { p: 1 } : { p: 2 }],
68
- locale: y,
71
+ locale: R,
69
72
  tokenKey: x,
70
- disableSwitchApp: m,
73
+ disableSwitchApp: s,
71
74
  onClick: L
72
75
  },
73
76
  u.WALLET
74
77
  ) : (
75
78
  // eslint-disable-next-line react/jsx-no-useless-fragment
76
- /* @__PURE__ */ e(p, { children: (R || c) && (!i.mobile.any || c) ? /* @__PURE__ */ e(
77
- v,
79
+ /* @__PURE__ */ e(p, { children: (k || m) && (!w.mobile.any || m) ? /* @__PURE__ */ e(
80
+ B,
78
81
  {
79
- t: a,
82
+ t: c,
80
83
  ref: h,
81
84
  tokenState: r,
82
85
  webWalletUrl: n,
83
86
  sx: [l === "small" ? { p: 1 } : { p: 2 }],
84
- disableSwitchApp: m,
85
- onClick: w
87
+ disableSwitchApp: s,
88
+ onClick: C
86
89
  },
87
90
  u.WALLET
88
91
  ) : null })
89
92
  )
90
93
  }
91
94
  ),
92
- s && /* @__PURE__ */ e(B, { variant: "text", onClick: s })
95
+ a && /* @__PURE__ */ e(E, { variant: "text", onClick: a })
93
96
  ] })
94
97
  ] });
95
98
  }
96
- I.propTypes = {
99
+ S.propTypes = {
97
100
  qrcode: o.node.isRequired,
98
101
  tokenState: o.object.isRequired,
99
102
  webWalletUrl: o.string,
@@ -107,5 +110,5 @@ I.propTypes = {
107
110
  onBack: o.func.isRequired
108
111
  };
109
112
  export {
110
- I as default
113
+ S as default
111
114
  };
@@ -1,10 +1,10 @@
1
- import { useBrowser as k } from "@arcblock/react-hooks";
2
- import { useRequest as y, useCreation as p } from "ahooks";
3
- import i from "lodash/isNil";
1
+ import { useBrowser as C } from "@arcblock/react-hooks";
2
+ import { useRequest as T, useCreation as p } from "ahooks";
3
+ import n from "lodash/isNil";
4
4
  import { LOGIN_PROVIDER as s } from "@arcblock/ux/lib/Util/constant";
5
- import { getFederatedEnabled as C, getMaster as T, getBlockletData as I } from "@arcblock/ux/lib/Util/federated";
6
- import { useState as S } from "react";
7
- const B = async ({ sourceAppPid: d }) => {
5
+ import { getFederatedEnabled as y, getMaster as D, getBlockletData as I } from "@arcblock/ux/lib/Util/federated";
6
+ import { useState as R } from "react";
7
+ const S = async ({ sourceAppPid: d }) => {
8
8
  const t = globalThis?.blocklet;
9
9
  if (!t)
10
10
  return {
@@ -18,49 +18,52 @@ const B = async ({ sourceAppPid: d }) => {
18
18
  enabled: !0
19
19
  }
20
20
  };
21
- const a = C(t), e = T(t);
22
- return a && e?.appPid && d === e?.appPid ? (await I(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
23
- }, R = async ({ sourceAppPid: d } = {}) => {
24
- const t = await B({ sourceAppPid: d });
25
- return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !i(e?.order) && !i(o?.order) ? e.order - o.order : i(e?.order) ? 1 : -1);
21
+ const l = y(t), e = D(t);
22
+ return l && e?.appPid && d === e?.appPid ? (await I(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
23
+ }, B = async ({ sourceAppPid: d } = {}) => {
24
+ const t = await S({ sourceAppPid: d });
25
+ return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !n(e?.order) && !n(o?.order) ? e.order - o.order : n(e?.order) ? 1 : -1);
26
26
  };
27
- function j({
27
+ function Y({
28
28
  allowWallet: d = !0,
29
29
  passkeyBehavior: t = "none",
30
- action: a,
30
+ action: l,
31
31
  sourceAppPid: e,
32
32
  mode: o = "dialog",
33
- blocklet: b = globalThis.blocklet,
33
+ blocklet: P = globalThis.blocklet,
34
34
  isSmallView: L = !1,
35
- lastLoginMethod: u = ""
35
+ lastLoginMethod: a = ""
36
36
  }) {
37
- const [P, g] = S(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], E = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], c = k(), { data: v = [] } = y(
37
+ const [m, g] = R(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], E = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], c = C(), { data: v = [] } = T(
38
38
  async () => {
39
39
  g(!0);
40
- const l = await R({ sourceAppPid: e });
41
- return g(!1), l;
40
+ const i = await B({ sourceAppPid: e });
41
+ return g(!1), i;
42
42
  },
43
43
  { refreshDeps: [e] }
44
- ), f = p(() => v.filter((r) => r.provider === s.WALLET ? d : r.provider === s.PASSKEY ? t !== "none" && !c.wallet && !c.arcSphere : r.provider === s.EMAIL ? E.includes(a) && (b?.settings?.notification?.email?.enabled ?? !1) : !(r.type === "oauth" && !w.includes(a))).sort((r, n) => {
45
- if (u) {
46
- const h = r.provider === u, m = n.provider === u;
47
- if (h && !m)
48
- return -1;
49
- if (!h && m)
50
- return 1;
51
- }
52
- return !i(r?.order) && !i(n?.order) ? r.order - n.order : i(r?.order) ? i(n?.order) ? 0 : 1 : -1;
53
- }), [v, u]), A = p(() => {
54
- const l = o === "drawer" || L && c.mobile.any;
55
- return globalThis?.blocklet ? !!(f.find((n) => n.provider === s.WALLET)?.showQrcode !== !0 || l) : !!l;
44
+ ), f = p(() => {
45
+ const i = globalThis?.blocklet?.DID_CONNECT_ENABLED_PROVIDERS?.split(",") || [];
46
+ return v.filter((r) => i.length > 0 && !i.includes(r.provider) ? !1 : r.provider === s.WALLET ? d : r.provider === s.PASSKEY ? t !== "none" && !c.wallet && !c.arcSphere : r.provider === s.EMAIL ? E.includes(l) && (P?.settings?.notification?.email?.enabled ?? !1) : !(r.type === "oauth" && !w.includes(l))).sort((r, u) => {
47
+ if (a) {
48
+ const h = r.provider === a, b = u.provider === a;
49
+ if (h && !b)
50
+ return -1;
51
+ if (!h && b)
52
+ return 1;
53
+ }
54
+ return !n(r?.order) && !n(u?.order) ? r.order - u.order : n(r?.order) ? n(u?.order) ? 0 : 1 : -1;
55
+ });
56
+ }, [v, a]), A = p(() => {
57
+ const i = o === "drawer" || L && c.mobile.any;
58
+ return globalThis?.blocklet ? !!(f.find((r) => r.provider === s.WALLET)?.showQrcode !== !0 || i) : !!i;
56
59
  }, [o, L, f]);
57
60
  return {
58
61
  hideChooseList: p(() => !1),
59
62
  hideQRCode: A,
60
63
  providerList: f,
61
- loadingProviderList: P
64
+ loadingProviderList: m
62
65
  };
63
66
  }
64
67
  export {
65
- j as default
68
+ Y as default
66
69
  };
@@ -1,4 +1,4 @@
1
- const o = "3.4.8", s = {
1
+ const o = "3.4.10", 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.4.8",
3
+ "version": "3.4.10",
4
4
  "description": "Client side library to work with DID Connect by ArcBlock.",
5
5
  "keywords": [
6
6
  "react",
@@ -32,17 +32,17 @@
32
32
  "url": "https://github.com/ArcBlock/ux/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@arcblock/bridge": "3.4.8",
36
- "@arcblock/did": "^1.28.5",
37
- "@arcblock/icons": "3.4.8",
38
- "@arcblock/react-hooks": "3.4.8",
39
- "@arcblock/ws": "^1.28.5",
35
+ "@arcblock/bridge": "3.4.10",
36
+ "@arcblock/did": "^1.28.6",
37
+ "@arcblock/icons": "3.4.10",
38
+ "@arcblock/react-hooks": "3.4.10",
39
+ "@arcblock/ws": "^1.28.6",
40
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",
44
44
  "@iconify/react": "^5.2.1",
45
- "@ocap/util": "^1.28.5",
45
+ "@ocap/util": "^1.28.6",
46
46
  "@simplewebauthn/browser": "^13.1.0",
47
47
  "ahooks": "^3.8.5",
48
48
  "axios": "^1.10.0",
@@ -85,5 +85,5 @@
85
85
  "eslint-plugin-react-hooks": "^4.6.2",
86
86
  "jest": "^29.7.0"
87
87
  },
88
- "gitHead": "6bbdc63e6e0b7ddfd5e37f2ac6bb44ee49da7139"
88
+ "gitHead": "162768378bf0a1d1e0984d1f01235eafa5bd9bdb"
89
89
  }
@@ -30,8 +30,20 @@ export default function WalletLoginOptions({
30
30
  const extension = detectWalletExtension();
31
31
 
32
32
  const isTablet = useCreation(() => {
33
- return browser.mobile.tablet || (!browser.mobile.any && window?.navigator?.maxTouchPoints > 0);
34
- }, [browser.mobile.tablet, browser.mobile.any]);
33
+ const ua = navigator.userAgent.toLowerCase();
34
+
35
+ // 1. 判断是否是 iPad (iOS 13+ 可能会显示为 Macintosh,需要结合触控点判断)
36
+ const isIpad = /ipad/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
37
+
38
+ // 2. 判断是否是 Android 平板 (即 User Agent 包含 Android 但不包含 Mobile)
39
+ const isAndroidTablet = /android/.test(ua) && !/mobile/.test(ua);
40
+
41
+ // 3. 综合判断平板
42
+ if (isIpad || isAndroidTablet) {
43
+ return true;
44
+ }
45
+ return false;
46
+ }, []);
35
47
  return (
36
48
  <>
37
49
  {qrcode}
@@ -74,8 +74,14 @@ export default function useProviderList({
74
74
  );
75
75
 
76
76
  const showedLoginProviderList = useCreation(() => {
77
+ const allowedProviders = globalThis?.blocklet?.DID_CONNECT_ENABLED_PROVIDERS?.split(',') || [];
77
78
  const result = loginProviderList
78
79
  .filter((item) => {
80
+ if (allowedProviders.length > 0) {
81
+ if (!allowedProviders.includes(item.provider)) {
82
+ return false;
83
+ }
84
+ }
79
85
  if (item.provider === LOGIN_PROVIDER.WALLET) {
80
86
  return allowWallet;
81
87
  }