@arcblock/did-connect-react 3.3.10 → 3.4.1
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/assets/locale.js +4 -2
- package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
- package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
- package/lib/Connect/components/login-item/login-method-item.js +63 -47
- package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
- package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
- package/lib/Connect/connect.js +503 -0
- package/lib/Connect/contexts/state.js +74 -65
- package/lib/Connect/fallback-connect.js +53 -0
- package/lib/Connect/hooks/provider-list.js +45 -29
- package/lib/Connect/index.js +13 -502
- package/lib/Connect/plugins/email/list-item.js +19 -18
- package/lib/Connect/use-connect.js +10 -10
- package/lib/OAuth/context.js +3 -3
- package/lib/Passkey/actions.js +80 -75
- package/lib/Passkey/context.js +3 -3
- package/lib/Passkey/dialog.js +7 -7
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
- package/lib/Session/index.js +189 -189
- package/lib/package.json.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +8 -8
- package/src/Connect/assets/locale.js +2 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
- package/src/Connect/components/login-item/login-method-item.jsx +24 -7
- package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
- package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
- package/src/Connect/connect.jsx +618 -0
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/fallback-connect.jsx +47 -0
- package/src/Connect/hooks/provider-list.js +48 -17
- package/src/Connect/index.jsx +8 -605
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Connect/use-connect.jsx +1 -1
- package/src/Passkey/actions.jsx +5 -0
- package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
- package/src/Session/index.jsx +3 -4
- package/src/utils.js +2 -2
|
@@ -3,6 +3,7 @@ import { useCreation, useRequest } from 'ahooks';
|
|
|
3
3
|
import isNil from 'lodash/isNil';
|
|
4
4
|
import { LOGIN_PROVIDER } from '@arcblock/ux/lib/Util/constant';
|
|
5
5
|
import { getBlockletData, getFederatedEnabled, getMaster } from '@arcblock/ux/lib/Util/federated';
|
|
6
|
+
import { useState } from 'react';
|
|
6
7
|
|
|
7
8
|
const getAuthenticationConfig = async ({ sourceAppPid }) => {
|
|
8
9
|
const blocklet = globalThis?.blocklet;
|
|
@@ -55,39 +56,68 @@ export default function useProviderList({
|
|
|
55
56
|
mode = 'dialog',
|
|
56
57
|
blocklet = globalThis.blocklet,
|
|
57
58
|
isSmallView = false,
|
|
59
|
+
lastLoginMethod = '',
|
|
58
60
|
}) {
|
|
61
|
+
const [loadingProviderList, setLoadingProviderList] = useState(false);
|
|
59
62
|
const actionList = ['login', 'invite', 'connect-to-did-space', 'connect-to-did-domain', 'destroy-self'];
|
|
60
63
|
const browser = useBrowser();
|
|
61
64
|
|
|
62
65
|
const { data: loginProviderList = [] } = useRequest(
|
|
63
66
|
async () => {
|
|
67
|
+
setLoadingProviderList(true);
|
|
64
68
|
const data = await getLoginProviderList({ sourceAppPid });
|
|
69
|
+
setLoadingProviderList(false);
|
|
65
70
|
return data;
|
|
66
71
|
},
|
|
67
72
|
{ refreshDeps: [sourceAppPid] }
|
|
68
73
|
);
|
|
69
74
|
|
|
70
75
|
const showedLoginProviderList = useCreation(() => {
|
|
71
|
-
const result = loginProviderList
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
const result = loginProviderList
|
|
77
|
+
.filter((item) => {
|
|
78
|
+
if (item.name === LOGIN_PROVIDER.WALLET) {
|
|
79
|
+
return allowWallet;
|
|
80
|
+
}
|
|
81
|
+
if (item.name === LOGIN_PROVIDER.PASSKEY) {
|
|
82
|
+
return passkeyBehavior !== 'none' && !browser.wallet && !browser.arcSphere;
|
|
83
|
+
}
|
|
84
|
+
if (item.name === LOGIN_PROVIDER.EMAIL) {
|
|
85
|
+
return blocklet?.settings?.notification?.email?.enabled ?? false;
|
|
86
|
+
}
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
if (item.type === 'oauth') {
|
|
89
|
+
if (!actionList.includes(action)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
return true;
|
|
94
|
+
})
|
|
95
|
+
.sort((a, b) => {
|
|
96
|
+
// 优先处理 lastLoginMethod:匹配的项目排在最前面
|
|
97
|
+
if (lastLoginMethod) {
|
|
98
|
+
const aIsLastMethod = a.provider === lastLoginMethod;
|
|
99
|
+
const bIsLastMethod = b.provider === lastLoginMethod;
|
|
100
|
+
if (aIsLastMethod && !bIsLastMethod) {
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
if (!aIsLastMethod && bIsLastMethod) {
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// 然后按照 order 属性排序
|
|
108
|
+
if (!isNil(a?.order) && !isNil(b?.order)) {
|
|
109
|
+
return a.order - b.order;
|
|
110
|
+
}
|
|
111
|
+
if (!isNil(a?.order)) {
|
|
112
|
+
return -1;
|
|
113
|
+
}
|
|
114
|
+
if (!isNil(b?.order)) {
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
return 0;
|
|
118
|
+
});
|
|
89
119
|
return result;
|
|
90
|
-
}, [loginProviderList]);
|
|
120
|
+
}, [loginProviderList, lastLoginMethod]);
|
|
91
121
|
|
|
92
122
|
const hideQRCode = useCreation(() => {
|
|
93
123
|
const isMobileView = mode === 'drawer' || (isSmallView && browser.mobile.any);
|
|
@@ -121,6 +151,7 @@ export default function useProviderList({
|
|
|
121
151
|
hideChooseList,
|
|
122
152
|
hideQRCode,
|
|
123
153
|
providerList: showedLoginProviderList,
|
|
154
|
+
loadingProviderList,
|
|
124
155
|
};
|
|
125
156
|
|
|
126
157
|
return result;
|