@arcblock/did-connect-react 3.4.2 → 3.4.4

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,4 +1,4 @@
1
- const o = "3.4.2", s = {
1
+ const o = "3.4.4", 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.2",
3
+ "version": "3.4.4",
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.2",
36
- "@arcblock/did": "^1.28.1",
37
- "@arcblock/icons": "3.4.2",
38
- "@arcblock/react-hooks": "3.4.2",
39
- "@arcblock/ws": "^1.28.1",
35
+ "@arcblock/bridge": "3.4.4",
36
+ "@arcblock/did": "^1.28.2",
37
+ "@arcblock/icons": "3.4.4",
38
+ "@arcblock/react-hooks": "3.4.4",
39
+ "@arcblock/ws": "^1.28.2",
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.1",
45
+ "@ocap/util": "^1.28.2",
46
46
  "@simplewebauthn/browser": "^13.1.0",
47
47
  "ahooks": "^3.8.5",
48
48
  "axios": "^1.10.0",
@@ -81,5 +81,5 @@
81
81
  "eslint-plugin-react-hooks": "^4.6.2",
82
82
  "jest": "^29.7.0"
83
83
  },
84
- "gitHead": "9ba657c3d15f93dc93e9029845631ececf385afc"
84
+ "gitHead": "89a650622cb03211e105d8d9ac7793ccf18aac4f"
85
85
  }
@@ -162,10 +162,10 @@ export default function ConnectProviderList({
162
162
  }, [providerList]);
163
163
 
164
164
  useEffect(() => {
165
- if (onlyWalletProvider && !browser.mobile.any && !showWalletOptions) {
165
+ if (hideQRCode && onlyWalletProvider && !browser.mobile.any && !showWalletOptions) {
166
166
  setShowWalletOptions(true);
167
167
  }
168
- }, [onlyWalletProvider, browser.mobile.any, setShowWalletOptions, showWalletOptions]);
168
+ }, [hideQRCode, onlyWalletProvider, browser.mobile.any, setShowWalletOptions, showWalletOptions]);
169
169
 
170
170
  const showEmailLogin = providerList.some((p) => p.provider === LOGIN_PROVIDER.EMAIL);
171
171
 
@@ -59,7 +59,8 @@ export default function useProviderList({
59
59
  lastLoginMethod = '',
60
60
  }) {
61
61
  const [loadingProviderList, setLoadingProviderList] = useState(false);
62
- const actionList = ['login', 'invite', 'connect-to-did-space', 'connect-to-did-domain', 'destroy-self'];
62
+ const oauthActionList = ['login', 'invite', 'connect-to-did-space', 'connect-to-did-domain', 'destroy-self'];
63
+ const emailActionList = ['login', 'invite', 'connect-to-did-space', 'connect-to-did-domain', 'destroy-self'];
63
64
  const browser = useBrowser();
64
65
 
65
66
  const { data: loginProviderList = [] } = useRequest(
@@ -75,18 +76,18 @@ export default function useProviderList({
75
76
  const showedLoginProviderList = useCreation(() => {
76
77
  const result = loginProviderList
77
78
  .filter((item) => {
78
- if (item.name === LOGIN_PROVIDER.WALLET) {
79
+ if (item.provider === LOGIN_PROVIDER.WALLET) {
79
80
  return allowWallet;
80
81
  }
81
- if (item.name === LOGIN_PROVIDER.PASSKEY) {
82
+ if (item.provider === LOGIN_PROVIDER.PASSKEY) {
82
83
  return passkeyBehavior !== 'none' && !browser.wallet && !browser.arcSphere;
83
84
  }
84
- if (item.name === LOGIN_PROVIDER.EMAIL) {
85
- return blocklet?.settings?.notification?.email?.enabled ?? false;
85
+ if (item.provider === LOGIN_PROVIDER.EMAIL) {
86
+ return emailActionList.includes(action) && (blocklet?.settings?.notification?.email?.enabled ?? false);
86
87
  }
87
88
 
88
89
  if (item.type === 'oauth') {
89
- if (!actionList.includes(action)) {
90
+ if (!oauthActionList.includes(action)) {
90
91
  return false;
91
92
  }
92
93
  }
@@ -12,12 +12,14 @@ import { startAuthentication, startRegistration } from '@simplewebauthn/browser'
12
12
 
13
13
  import { getApiErrorMessage, getWebAuthnErrorMessage, createAxios, logger } from '../utils';
14
14
  import { PassportSwitcher, parseResponse } from '../components/PassportSwitcher';
15
+ import defaultTranslations from '../Connect/assets/locale';
15
16
 
16
17
  const PasskeyContext = createContext({});
17
18
  const { Provider, Consumer: PasskeyConsumer } = PasskeyContext;
18
19
 
19
20
  const translations = {
20
21
  zh: {
22
+ ...defaultTranslations.zh,
21
23
  cancel: '取消',
22
24
  usePasskey: '使用 Passkey',
23
25
  createPasskey: '新建 Passkey',
@@ -49,6 +51,7 @@ const translations = {
49
51
  },
50
52
  },
51
53
  en: {
54
+ ...defaultTranslations.en,
52
55
  cancel: 'Cancel',
53
56
  usePasskey: 'Use Existing Passkey',
54
57
  createPasskey: 'Create New Passkey',
@@ -611,6 +611,16 @@ function createSessionContext(
611
611
  fetchAll: true,
612
612
  });
613
613
 
614
+ const getMessageByBlocklet = useMemoizedFn((action, locale) => {
615
+ if (!globalThis.blocklet) return null;
616
+
617
+ const messages = globalThis.blocklet?.settings?.actionConfig?.[action];
618
+ if (messages) {
619
+ return messages[locale] || messages.en;
620
+ }
621
+ return null;
622
+ });
623
+
614
624
  const ensureLogin = useMemoizedFn(async () => {
615
625
  if (!state?.user) {
616
626
  await new Promise((resolve) => {
@@ -994,9 +1004,12 @@ function createSessionContext(
994
1004
  if (pageState?.options?.origin === 'switch-did') {
995
1005
  localeAction = pageState?.options?.origin;
996
1006
  }
997
- const messages = translations[localeAction];
998
1007
 
999
- const connectMessage = messages[currentLocale] || messages.en;
1008
+ const defaultMessages = translations[localeAction];
1009
+
1010
+ const messages = getMessageByBlocklet(localeAction, currentLocale);
1011
+
1012
+ const connectMessage = messages || defaultMessages[currentLocale] || defaultMessages.en;
1000
1013
  const extraParams = {
1001
1014
  ...opts.extraParams,
1002
1015
  ...props.extraParams,