@blocklet/did-space-react 0.5.57 → 0.5.59
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/.turbo/turbo-build.log +37 -18
- package/.turbo/turbo-lint$colon$fix.log +2 -2
- package/README.md +85 -39
- package/es/components/auth-connect-to/base-auth.d.ts +5 -0
- package/es/components/auth-connect-to/base-auth.js +60 -0
- package/es/components/auth-connect-to/gateway-auth.d.ts +5 -0
- package/es/components/auth-connect-to/gateway-auth.js +49 -0
- package/es/components/auth-connect-to/index.d.ts +18 -0
- package/es/components/auth-connect-to/index.js +61 -0
- package/es/components/base-connect-to/index.d.ts +10 -0
- package/es/components/{ConnectTo → base-connect-to}/index.js +32 -26
- package/{lib/components/PreviewNFT → es/components/preview-space-nft}/index.d.ts +1 -2
- package/es/components/{PreviewNFT → preview-space-nft}/index.js +7 -2
- package/es/components/session-connect-to/index.d.ts +16 -0
- package/es/components/session-connect-to/index.js +26 -0
- package/es/components/session-connect-to/re-connect.d.ts +13 -0
- package/es/components/session-connect-to/re-connect.js +51 -0
- package/es/components/{SpaceCard → space-card}/index.d.ts +1 -2
- package/es/components/{SpaceCard → space-card}/index.js +82 -33
- package/es/hooks/use-space-info.js +1 -1
- package/es/icons/index.d.ts +5 -4
- package/es/icons/index.js +11 -0
- package/es/index.d.ts +8 -5
- package/es/index.js +15 -4
- package/es/libs/constants.d.ts +4 -0
- package/es/libs/constants.js +6 -0
- package/es/libs/util.d.ts +1 -0
- package/es/libs/util.js +15 -1
- package/es/locales/en.js +27 -9
- package/es/locales/zh.js +27 -9
- package/es/types/index.d.ts +22 -7
- package/es/types/index.js +3 -1
- package/lib/components/auth-connect-to/base-auth.d.ts +5 -0
- package/lib/components/auth-connect-to/base-auth.js +62 -0
- package/lib/components/auth-connect-to/gateway-auth.d.ts +5 -0
- package/lib/components/auth-connect-to/gateway-auth.js +51 -0
- package/lib/components/auth-connect-to/index.d.ts +18 -0
- package/lib/components/auth-connect-to/index.js +65 -0
- package/lib/components/base-connect-to/index.d.ts +10 -0
- package/lib/components/{ConnectTo → base-connect-to}/index.js +31 -25
- package/{es/components/PreviewNFT → lib/components/preview-space-nft}/index.d.ts +1 -2
- package/lib/components/{PreviewNFT → preview-space-nft}/index.js +7 -2
- package/lib/components/session-connect-to/index.d.ts +16 -0
- package/lib/components/session-connect-to/index.js +29 -0
- package/lib/components/session-connect-to/re-connect.d.ts +13 -0
- package/lib/components/session-connect-to/re-connect.js +53 -0
- package/lib/components/{SpaceCard → space-card}/index.d.ts +1 -2
- package/lib/components/{SpaceCard → space-card}/index.js +82 -33
- package/lib/hooks/use-space-info.js +1 -1
- package/lib/icons/index.d.ts +5 -4
- package/lib/icons/index.js +16 -0
- package/lib/index.d.ts +8 -5
- package/lib/index.js +33 -10
- package/lib/libs/constants.d.ts +4 -0
- package/lib/libs/constants.js +9 -0
- package/lib/libs/util.d.ts +1 -0
- package/lib/libs/util.js +15 -0
- package/lib/locales/en.js +27 -9
- package/lib/locales/zh.js +27 -9
- package/lib/types/index.d.ts +22 -7
- package/lib/types/index.js +3 -1
- package/package.json +47 -36
- package/src/components/auth-connect-to/base-auth.tsx +64 -0
- package/src/components/auth-connect-to/gateway-auth.tsx +53 -0
- package/src/components/auth-connect-to/index.tsx +71 -0
- package/src/components/{ConnectTo/connect-to.stories.tsx → base-connect-to/base-connect-to.stories.tsx} +1 -1
- package/src/components/{ConnectTo → base-connect-to}/index.tsx +35 -22
- package/src/components/{PreviewNFT → preview-space-nft}/index.tsx +12 -6
- package/src/components/session-connect-to/index.tsx +39 -0
- package/src/components/session-connect-to/re-connect.tsx +57 -0
- package/src/components/{SpaceCard → space-card}/index.tsx +88 -30
- package/src/hooks/use-space-info.ts +1 -1
- package/src/icons/index.tsx +12 -4
- package/src/index.ts +11 -6
- package/src/libs/constants.ts +4 -0
- package/src/libs/util.ts +17 -0
- package/src/locales/en.tsx +26 -7
- package/src/locales/zh.tsx +25 -7
- package/src/types/index.ts +23 -6
- package/src/types/shims.d.ts +4 -4
- package/es/components/ConnectTo/index.d.ts +0 -10
- package/es/libs/theme.d.ts +0 -1
- package/lib/components/ConnectTo/index.d.ts +0 -10
- package/lib/libs/theme.d.ts +0 -1
- package/src/libs/theme.ts +0 -18
- /package/es/components/{ConnectTo/connect-to.stories.d.ts → base-connect-to/base-connect-to.stories.d.ts} +0 -0
- /package/es/components/{SpaceCard → space-card}/space-card.stories.d.ts +0 -0
- /package/lib/components/{ConnectTo/connect-to.stories.d.ts → base-connect-to/base-connect-to.stories.d.ts} +0 -0
- /package/lib/components/{SpaceCard → space-card}/space-card.stories.d.ts +0 -0
- /package/src/components/{SpaceCard → space-card}/space-card.stories.tsx +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import isUndefined from 'lodash/isUndefined';
|
|
2
2
|
import { joinURL, withQuery } from 'ufo';
|
|
3
|
-
import { Box, BoxProps, Link, Stack } from '@mui/material';
|
|
3
|
+
import { Box, BoxProps, Link, Skeleton, Stack, Tooltip } from '@mui/material';
|
|
4
|
+
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
|
4
5
|
import DidAddress from '@arcblock/ux/lib/DID';
|
|
5
6
|
import { styled } from '@arcblock/ux/lib/Theme';
|
|
6
7
|
|
|
7
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { AxiosError } from 'axios';
|
|
8
10
|
import useMobile from '../../hooks/use-mobile';
|
|
9
11
|
import useSpaceInfo from '../../hooks/use-space-info';
|
|
10
12
|
import useLocale from '../../hooks/use-locale';
|
|
@@ -16,51 +18,67 @@ import {
|
|
|
16
18
|
getSpaceNftDisplayUrlFromEndpoint,
|
|
17
19
|
} from '../../libs/util';
|
|
18
20
|
import { SpaceGateway, SpaceStatus } from '../../types';
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
+
import { SpacesConnectedIcon, SpaceDisconnectedIcon, SpaceConnectErrorIcon } from '../../icons';
|
|
22
|
+
import { PreviewSpaceNft } from '../preview-space-nft';
|
|
21
23
|
|
|
22
24
|
function Status({
|
|
23
25
|
spaceUrl,
|
|
24
26
|
status,
|
|
27
|
+
isError,
|
|
25
28
|
refresh,
|
|
26
29
|
sx,
|
|
27
30
|
...rest
|
|
28
|
-
}: { spaceUrl: string; status: SpaceStatus; refresh: () => void } & BoxProps) {
|
|
31
|
+
}: { spaceUrl: string; status: SpaceStatus; isError: boolean; refresh: () => void } & BoxProps) {
|
|
29
32
|
const { t } = useLocale();
|
|
30
|
-
const iconStyle = {
|
|
33
|
+
const iconStyle = { marginRight: '4px' };
|
|
31
34
|
|
|
32
|
-
// error
|
|
33
35
|
let icon: React.ReactNode = null;
|
|
34
36
|
let text: React.ReactNode = null;
|
|
35
37
|
|
|
36
38
|
if (status === SpaceStatus.CONNECTED) {
|
|
37
|
-
icon = <
|
|
39
|
+
icon = <SpacesConnectedIcon style={iconStyle} />;
|
|
38
40
|
text = <span style={{ color: '#047857' }}>{t('storage.spaces.connected.tag')}</span>;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
if (status === SpaceStatus.DISCONNECTED) {
|
|
42
|
-
icon = <
|
|
44
|
+
icon = <SpaceDisconnectedIcon style={iconStyle} />;
|
|
43
45
|
text = <span style={{ color: '#626a77' }}>{t('storage.spaces.disconnected.tag')}</span>;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
if (status === SpaceStatus.EXPIRED) {
|
|
47
|
-
icon = <
|
|
49
|
+
icon = <SpaceConnectErrorIcon style={iconStyle} />;
|
|
48
50
|
text = (
|
|
49
|
-
<
|
|
50
|
-
<span>{t('storage.spaces.expired.guide')}</span>
|
|
51
|
+
<Tooltip title={t('storage.spaces.error.expired')} placement="top">
|
|
51
52
|
<Link
|
|
52
53
|
href={withQuery(joinURL(spaceUrl, 'overview'), { guide: 1 })}
|
|
53
54
|
target="_blank"
|
|
54
|
-
underline="
|
|
55
|
+
underline="hover"
|
|
55
56
|
color="error"
|
|
56
|
-
sx={{
|
|
57
|
+
sx={{ display: 'flex', alignItems: 'center', color: 'error.main' }}
|
|
57
58
|
>
|
|
58
|
-
|
|
59
|
+
<span>{t('storage.spaces.error.tag')}</span>
|
|
60
|
+
<OpenInNewIcon sx={{ fontSize: '14px', marginLeft: '4px' }} />
|
|
59
61
|
</Link>
|
|
60
|
-
</
|
|
62
|
+
</Tooltip>
|
|
61
63
|
);
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
if (status === SpaceStatus.CORS_BLOCKED) {
|
|
67
|
+
icon = <SpaceConnectErrorIcon style={iconStyle} />;
|
|
68
|
+
text = (
|
|
69
|
+
<Tooltip title={t('storage.spaces.error.corsBlocked')} placement="top">
|
|
70
|
+
<Box sx={{ display: 'flex', alignItems: 'center', color: 'error.main' }}>
|
|
71
|
+
<span>{t('storage.spaces.error.tag')}</span>
|
|
72
|
+
</Box>
|
|
73
|
+
</Tooltip>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (status === SpaceStatus.UNKNOWN) {
|
|
78
|
+
icon = <SpaceConnectErrorIcon style={iconStyle} />;
|
|
79
|
+
text = <Box sx={{ color: 'error.main' }}>{t('storage.spaces.error.networkError')}</Box>;
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
// 如果 Space 为 Error 状态,则在页面重新可见时刷新 Space 状态(此时 error 可能已经在外部处理了)
|
|
65
83
|
useEffect(() => {
|
|
66
84
|
const handleVisibilityChange = () => {
|
|
@@ -68,14 +86,14 @@ function Status({
|
|
|
68
86
|
refresh();
|
|
69
87
|
}
|
|
70
88
|
};
|
|
71
|
-
if (
|
|
89
|
+
if (isError) {
|
|
72
90
|
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
73
91
|
} else {
|
|
74
92
|
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
75
93
|
}
|
|
76
94
|
|
|
77
95
|
return () => document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
78
|
-
}, [
|
|
96
|
+
}, [isError, refresh]);
|
|
79
97
|
|
|
80
98
|
return (
|
|
81
99
|
<Box
|
|
@@ -106,8 +124,10 @@ export interface SpaceCardProps extends BoxProps {
|
|
|
106
124
|
deps?: any[];
|
|
107
125
|
}
|
|
108
126
|
|
|
109
|
-
function SpaceCard({ endpoint, selected = false, compat, action, className, deps, ...rest }: SpaceCardProps) {
|
|
127
|
+
export function SpaceCard({ endpoint, selected = false, compat, action, className, deps, ...rest }: SpaceCardProps) {
|
|
110
128
|
const isMobile = useMobile();
|
|
129
|
+
const { t } = useLocale();
|
|
130
|
+
|
|
111
131
|
let isCompact = compat;
|
|
112
132
|
|
|
113
133
|
if (isUndefined(isCompact)) {
|
|
@@ -119,26 +139,51 @@ function SpaceCard({ endpoint, selected = false, compat, action, className, deps
|
|
|
119
139
|
const gatewayUrl = getSpaceGatewayUrlFromEndpoint(endpoint);
|
|
120
140
|
const [refreshSpaceInfo, setRefreshSpaceInfo] = useState(false);
|
|
121
141
|
const refresh = () => setRefreshSpaceInfo((p) => !p);
|
|
122
|
-
const {
|
|
142
|
+
const {
|
|
143
|
+
data: spaceInfo,
|
|
144
|
+
error,
|
|
145
|
+
loading,
|
|
146
|
+
} = useSpaceInfo({
|
|
123
147
|
endpoint,
|
|
124
148
|
deps: [refreshSpaceInfo].concat(deps ?? []),
|
|
125
149
|
});
|
|
126
|
-
|
|
150
|
+
let spaceName: React.ReactNode = '';
|
|
127
151
|
|
|
128
152
|
// 是否授权连接
|
|
129
153
|
const hasPermission = spaceInfo?.hasPermission ?? false;
|
|
130
154
|
// 是否在订阅期内
|
|
131
155
|
const isAvailable = spaceInfo?.isAvailable ?? false;
|
|
156
|
+
// 是否发生错误
|
|
157
|
+
let isError = false;
|
|
158
|
+
// space 状态
|
|
159
|
+
const spaceStatus = useRef(SpaceStatus.LOADING);
|
|
132
160
|
|
|
133
|
-
|
|
134
|
-
|
|
161
|
+
if (loading) {
|
|
162
|
+
spaceStatus.current = SpaceStatus.LOADING;
|
|
163
|
+
spaceName = <Skeleton variant="text" sx={{ width: '180px', fontSize: '1rem' }} />;
|
|
164
|
+
} else if (spaceInfo) {
|
|
165
|
+
spaceName = spaceInfo.spaceName;
|
|
135
166
|
if (!isAvailable) {
|
|
136
167
|
spaceStatus.current = SpaceStatus.EXPIRED;
|
|
168
|
+
isError = true;
|
|
137
169
|
} else if (hasPermission) {
|
|
138
170
|
spaceStatus.current = SpaceStatus.CONNECTED;
|
|
139
171
|
} else {
|
|
140
172
|
spaceStatus.current = SpaceStatus.DISCONNECTED;
|
|
141
173
|
}
|
|
174
|
+
} else if (error instanceof AxiosError) {
|
|
175
|
+
spaceName = t('common.unknown');
|
|
176
|
+
isError = true;
|
|
177
|
+
if (
|
|
178
|
+
!error.response && // 无响应
|
|
179
|
+
error.message === 'Network Error' && // 网络错误
|
|
180
|
+
error.code !== 'ECONNABORTED' && // 非超时引起
|
|
181
|
+
new URL(error.config!.url!).origin !== window.location.origin // 满足跨域
|
|
182
|
+
) {
|
|
183
|
+
spaceStatus.current = SpaceStatus.CORS_BLOCKED;
|
|
184
|
+
} else {
|
|
185
|
+
spaceStatus.current = SpaceStatus.UNKNOWN;
|
|
186
|
+
}
|
|
142
187
|
}
|
|
143
188
|
|
|
144
189
|
const renderAction = () => {
|
|
@@ -147,7 +192,7 @@ function SpaceCard({ endpoint, selected = false, compat, action, className, deps
|
|
|
147
192
|
return action({
|
|
148
193
|
spaceGateway: {
|
|
149
194
|
did: spaceDid!,
|
|
150
|
-
name: spaceName,
|
|
195
|
+
name: spaceInfo?.spaceName ?? '',
|
|
151
196
|
url: gatewayUrl,
|
|
152
197
|
endpoint,
|
|
153
198
|
},
|
|
@@ -165,17 +210,23 @@ function SpaceCard({ endpoint, selected = false, compat, action, className, deps
|
|
|
165
210
|
<BoxContainer
|
|
166
211
|
className={classNames(className, {
|
|
167
212
|
selected,
|
|
168
|
-
error:
|
|
213
|
+
error: isError,
|
|
169
214
|
})}
|
|
170
215
|
{...rest}
|
|
171
216
|
>
|
|
172
217
|
<Box display="flex" alignItems="center">
|
|
173
|
-
<
|
|
218
|
+
<PreviewSpaceNft src={getSpaceNftDisplayUrlFromEndpoint(endpoint)} width="72px" height="72px" />
|
|
174
219
|
<Stack ml={2} flex={1} spacing={1} minWidth={0}>
|
|
175
220
|
<Box display="flex" alignItems="center" sx={{ whiteSpace: 'nowrap' }}>
|
|
176
|
-
<Box className="space-name">{spaceName}</Box>
|
|
221
|
+
{spaceName && <Box className="space-name">{spaceName}</Box>}
|
|
177
222
|
{!isCompact && selected && (
|
|
178
|
-
<Status
|
|
223
|
+
<Status
|
|
224
|
+
spaceUrl={spaceUrl}
|
|
225
|
+
status={spaceStatus.current}
|
|
226
|
+
refresh={refresh}
|
|
227
|
+
isError={isError}
|
|
228
|
+
sx={{ mr: 1 }}
|
|
229
|
+
/>
|
|
179
230
|
)}
|
|
180
231
|
</Box>
|
|
181
232
|
<DidAddress
|
|
@@ -195,7 +246,15 @@ function SpaceCard({ endpoint, selected = false, compat, action, className, deps
|
|
|
195
246
|
</Box>
|
|
196
247
|
{isCompact && (
|
|
197
248
|
<Box display="flex" alignItems="center" marginTop={0.5}>
|
|
198
|
-
{selected &&
|
|
249
|
+
{selected && (
|
|
250
|
+
<Status
|
|
251
|
+
spaceUrl={spaceUrl}
|
|
252
|
+
status={spaceStatus.current}
|
|
253
|
+
refresh={refresh}
|
|
254
|
+
isError={isError}
|
|
255
|
+
flexShrink={0}
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
199
258
|
<Box flex={1} />
|
|
200
259
|
{renderAction()}
|
|
201
260
|
</Box>
|
|
@@ -224,7 +283,6 @@ const BoxContainer = styled(Box)`
|
|
|
224
283
|
white-space: nowrap;
|
|
225
284
|
overflow: hidden;
|
|
226
285
|
text-overflow: ellipsis;
|
|
286
|
+
margin-right: 8px;
|
|
227
287
|
}
|
|
228
288
|
`;
|
|
229
|
-
|
|
230
|
-
export default SpaceCard;
|
package/src/icons/index.tsx
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import EmptySpacesNFTIcon from './empty-space-nft.svg';
|
|
2
|
+
import SpacesConnectedIcon from './space-connected.svg';
|
|
3
|
+
import SpaceDisconnectedIcon from './space-disconnect.svg';
|
|
4
|
+
import SpaceConnectErrorIcon from './space-connect-error.svg';
|
|
5
|
+
|
|
6
|
+
// 为了输出 icons/index.js 文件,添加一点副作用
|
|
7
|
+
EmptySpacesNFTIcon.displayName = 'EmptySpacesNFTIcon';
|
|
8
|
+
SpacesConnectedIcon.displayName = 'SpacesConnectedIcon';
|
|
9
|
+
SpaceDisconnectedIcon.displayName = 'SpaceDisconnectedIcon';
|
|
10
|
+
SpaceConnectErrorIcon.displayName = 'SpaceConnectErrorIcon';
|
|
11
|
+
|
|
12
|
+
export { EmptySpacesNFTIcon, SpacesConnectedIcon, SpaceDisconnectedIcon, SpaceConnectErrorIcon };
|
package/src/index.ts
CHANGED
|
@@ -3,14 +3,19 @@ import useMobile from './hooks/use-mobile';
|
|
|
3
3
|
import useSpaceInfo from './hooks/use-space-info';
|
|
4
4
|
import useLocale from './hooks/use-locale';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
6
|
+
// components
|
|
7
|
+
export * from './components/space-card';
|
|
8
|
+
export * from './components/preview-space-nft';
|
|
9
|
+
export * from './components/base-connect-to';
|
|
10
|
+
export * from './components/auth-connect-to';
|
|
11
|
+
export * from './components/session-connect-to';
|
|
11
12
|
|
|
13
|
+
// utils
|
|
12
14
|
export * from './libs/util';
|
|
15
|
+
export * from './libs/gateway';
|
|
13
16
|
export * from './locales';
|
|
14
17
|
export * from './types';
|
|
18
|
+
export { api, useMobile, useSpaceInfo, useLocale };
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
// icons
|
|
21
|
+
export * from './icons';
|
package/src/libs/util.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { joinURL } from 'ufo';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
2
3
|
|
|
3
4
|
type ClassStr = string | undefined | null;
|
|
4
5
|
/** classObj -> className
|
|
@@ -84,3 +85,19 @@ const spaceDidRegex = /\/space\/([^/]+)/;
|
|
|
84
85
|
export function getSpaceDidFromGatewayUrl(url: string) {
|
|
85
86
|
return new URL(url).pathname.match(spaceDidRegex)?.[1];
|
|
86
87
|
}
|
|
88
|
+
|
|
89
|
+
export function decryptSpaceGateway(response: Record<string, string>, decrypt: Function) {
|
|
90
|
+
if (!isEmpty(response.spaceGateway)) {
|
|
91
|
+
return decrypt(response.spaceGateway);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const endpoint = decrypt(response.endpoint);
|
|
95
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
endpoint,
|
|
99
|
+
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
100
|
+
...{ name: 'DID Space' },
|
|
101
|
+
...space,
|
|
102
|
+
};
|
|
103
|
+
}
|
package/src/locales/en.tsx
CHANGED
|
@@ -2,34 +2,53 @@ import { flatten } from 'flat';
|
|
|
2
2
|
|
|
3
3
|
export default flatten({
|
|
4
4
|
common: {
|
|
5
|
-
open: 'Open',
|
|
6
|
-
delete: 'Delete',
|
|
7
|
-
confirm: 'Confirm',
|
|
8
5
|
cancel: 'Cancel',
|
|
6
|
+
confirm: 'Confirm',
|
|
7
|
+
delete: 'Delete',
|
|
9
8
|
error: 'Error',
|
|
9
|
+
open: 'Open',
|
|
10
|
+
unknown: 'Unknown',
|
|
10
11
|
},
|
|
11
12
|
storage: {
|
|
12
13
|
spaces: {
|
|
14
|
+
authorize: {
|
|
15
|
+
title: 'Connect {appName} to DID Spaces',
|
|
16
|
+
scan: 'Use your DID Wallet to scan the QR code below to allow the app {appName} to connect to DID Spaces',
|
|
17
|
+
success: 'Connected successfully',
|
|
18
|
+
},
|
|
13
19
|
connect: {
|
|
20
|
+
reconnect: 'Reconnect Now',
|
|
14
21
|
useSpaceGateway: 'Connect using the DID Spaces gateway',
|
|
15
22
|
useWallet: 'Connect with DID Wallet',
|
|
23
|
+
howToGetGatewayUrl: 'How to get the url of did spaces',
|
|
24
|
+
providerForStorage: 'Please connect your DID Spaces',
|
|
16
25
|
},
|
|
17
26
|
connected: {
|
|
27
|
+
title: 'Connected DID Spaces',
|
|
18
28
|
tag: 'Connected',
|
|
19
29
|
},
|
|
20
30
|
disconnected: {
|
|
21
31
|
tag: 'Disconnected',
|
|
22
32
|
},
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
error: {
|
|
34
|
+
tag: 'Need Attention',
|
|
35
|
+
expired: 'This DID spaces has expired, you can re-subscribe by opening this link',
|
|
36
|
+
corsBlocked:
|
|
37
|
+
'Connection requests may be blocked by CORS. Please check security settings in the DID Space dashboard.',
|
|
38
|
+
networkError: 'Network error',
|
|
25
39
|
},
|
|
26
40
|
gateway: {
|
|
27
41
|
add: {
|
|
28
|
-
title: 'Add DID Spaces',
|
|
29
|
-
label: 'Enter the url of the DID Spaces',
|
|
30
42
|
invalidUrl: 'Invalid DID Spaces gateway url',
|
|
43
|
+
label: 'Enter the url of the DID Spaces',
|
|
44
|
+
title: 'Add DID Spaces',
|
|
31
45
|
},
|
|
32
46
|
},
|
|
47
|
+
provideNFT: {
|
|
48
|
+
title: 'Please show the DID Spaces NFT for {appName}',
|
|
49
|
+
scan: 'Use your DID Wallet to scan the QR code below to allow the app {appName} show DID space NFT',
|
|
50
|
+
success: 'Connected successfully',
|
|
51
|
+
},
|
|
33
52
|
},
|
|
34
53
|
},
|
|
35
54
|
});
|
package/src/locales/zh.tsx
CHANGED
|
@@ -2,34 +2,52 @@ import { flatten } from 'flat';
|
|
|
2
2
|
|
|
3
3
|
export default flatten({
|
|
4
4
|
common: {
|
|
5
|
-
open: '打开',
|
|
6
|
-
delete: '删除',
|
|
7
|
-
confirm: '确认',
|
|
8
5
|
cancel: '取消',
|
|
6
|
+
confirm: '确认',
|
|
7
|
+
delete: '删除',
|
|
9
8
|
error: '错误',
|
|
9
|
+
open: '打开',
|
|
10
|
+
unknown: '未知',
|
|
10
11
|
},
|
|
11
12
|
storage: {
|
|
12
13
|
spaces: {
|
|
14
|
+
authorize: {
|
|
15
|
+
title: '连接 {appName} 至 DID Spaces',
|
|
16
|
+
scan: '使用你的 DID Wallet 扫描下面的二维码以允许应用 {appName} 连接至 DID Spaces',
|
|
17
|
+
success: '连接成功',
|
|
18
|
+
},
|
|
13
19
|
connect: {
|
|
20
|
+
reconnect: '立即重连',
|
|
14
21
|
useSpaceGateway: '使用 DID Spaces 网关连接',
|
|
15
22
|
useWallet: '使用 DID Wallet 连接',
|
|
23
|
+
howToGetGatewayUrl: '如何获取 DID Spaces 的网关地址',
|
|
24
|
+
providerForStorage: '请连接您的 DID Spaces',
|
|
16
25
|
},
|
|
17
26
|
connected: {
|
|
27
|
+
title: '已连接的 DID Spaces',
|
|
18
28
|
tag: '已连接',
|
|
19
29
|
},
|
|
20
30
|
disconnected: {
|
|
21
31
|
tag: '连接已断开',
|
|
22
32
|
},
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
error: {
|
|
34
|
+
tag: '需要关注',
|
|
35
|
+
expired: '此 DID Spaces 已过期,您可以打开此链接重新订阅',
|
|
36
|
+
corsBlocked: '连接请求可能被 CORS 阻止。请检查 DID Space 控制面板中的安全设置。',
|
|
37
|
+
networkError: '网络错误',
|
|
25
38
|
},
|
|
26
39
|
gateway: {
|
|
27
40
|
add: {
|
|
28
|
-
title: '添加 DID Spaces',
|
|
29
|
-
label: '输入 DID Spaces 的地址',
|
|
30
41
|
invalidUrl: '无效的 DID Spaces 网关地址',
|
|
42
|
+
label: '输入 DID Spaces 的地址',
|
|
43
|
+
title: '添加 DID Spaces',
|
|
31
44
|
},
|
|
32
45
|
},
|
|
46
|
+
provideNFT: {
|
|
47
|
+
title: '请为 {appName} 出示 DID Spaces NFT',
|
|
48
|
+
scan: '使用你的 DID Wallet 扫描下面的二维码为应用 {appName} 出示 DID Spaces NFT',
|
|
49
|
+
success: '连接成功',
|
|
50
|
+
},
|
|
33
51
|
},
|
|
34
52
|
},
|
|
35
53
|
});
|
package/src/types/index.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
export type $TSFixMe = any;
|
|
2
2
|
|
|
3
3
|
export interface AuthorizeConnect {
|
|
4
|
-
prefix?: string;
|
|
5
|
-
baseUrl?: string;
|
|
6
4
|
open: boolean;
|
|
7
5
|
action: string;
|
|
8
|
-
|
|
6
|
+
checkFn: Function;
|
|
9
7
|
messages: {
|
|
10
8
|
title: string;
|
|
11
9
|
scan: string;
|
|
12
10
|
confirm: string;
|
|
13
11
|
success: React.ReactNode;
|
|
14
12
|
};
|
|
13
|
+
prefix?: string;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
webWalletUrl?: string;
|
|
16
|
+
maxIdleTime?: number;
|
|
17
|
+
checkTimeout?: number;
|
|
15
18
|
extraParams?: Record<string, any>;
|
|
16
|
-
checkFn?: Function;
|
|
17
|
-
onClose?: Function;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export enum SpaceStatus {
|
|
21
|
-
|
|
22
|
+
LOADING = 'loading',
|
|
22
23
|
CONNECTED = 'connected',
|
|
23
24
|
DISCONNECTED = 'disconnected',
|
|
24
25
|
EXPIRED = 'expired',
|
|
26
|
+
CORS_BLOCKED = 'corsBlocked',
|
|
27
|
+
UNKNOWN = 'unknown',
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export interface SpaceGateway {
|
|
@@ -32,3 +35,17 @@ export interface SpaceGateway {
|
|
|
32
35
|
protected?: boolean;
|
|
33
36
|
loading?: boolean;
|
|
34
37
|
}
|
|
38
|
+
|
|
39
|
+
export interface BaseAuthOptions {
|
|
40
|
+
action?: string;
|
|
41
|
+
checkFn?: Function;
|
|
42
|
+
extraParams?: Record<string, string>;
|
|
43
|
+
checkTimeout?: number;
|
|
44
|
+
onSuccess?: (response: Record<string, string>, decrypt: Function) => Promise<void>;
|
|
45
|
+
onClose?: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface GatewayAuthOptions extends BaseAuthOptions {
|
|
49
|
+
spaceDid?: string;
|
|
50
|
+
spaceGatewayUrl?: string;
|
|
51
|
+
}
|
package/src/types/shims.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ declare module '@abtnode/ux/*';
|
|
|
4
4
|
declare module '@abtnode/util/*';
|
|
5
5
|
declare module '@blocklet/*';
|
|
6
6
|
|
|
7
|
-
declare module '*.png';
|
|
8
|
-
declare module 'google-libphonenumber';
|
|
9
|
-
declare module 'pretty-ms-i18n';
|
|
10
|
-
|
|
11
7
|
declare module '*.svg' {
|
|
12
8
|
import React from 'react';
|
|
13
9
|
const SVG: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
14
10
|
export default SVG;
|
|
15
11
|
}
|
|
12
|
+
|
|
13
|
+
declare interface Window {
|
|
14
|
+
blocklet: import('@blocklet/sdk').WindowBlocklet;
|
|
15
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SplitButtonProps } from '@arcblock/ux/lib/SplitButton';
|
|
2
|
-
export interface ConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onClick'> {
|
|
3
|
-
onWalletConnect?: () => void;
|
|
4
|
-
onGatewayConnect?: (params: {
|
|
5
|
-
spaceDid: string;
|
|
6
|
-
spaceGatewayUrl: string;
|
|
7
|
-
}) => void;
|
|
8
|
-
}
|
|
9
|
-
declare function ConnectTo({ style, onWalletConnect, onGatewayConnect, ...rest }: ConnectToProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export default ConnectTo;
|
package/es/libs/theme.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function create(settings?: any): import("@mui/material").Theme;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SplitButtonProps } from '@arcblock/ux/lib/SplitButton';
|
|
2
|
-
export interface ConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onClick'> {
|
|
3
|
-
onWalletConnect?: () => void;
|
|
4
|
-
onGatewayConnect?: (params: {
|
|
5
|
-
spaceDid: string;
|
|
6
|
-
spaceGatewayUrl: string;
|
|
7
|
-
}) => void;
|
|
8
|
-
}
|
|
9
|
-
declare function ConnectTo({ style, onWalletConnect, onGatewayConnect, ...rest }: ConnectToProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export default ConnectTo;
|
package/lib/libs/theme.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function create(settings?: any): import("@mui/material").Theme;
|
package/src/libs/theme.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createTheme } from '@arcblock/ux/lib/Theme';
|
|
2
|
-
import merge from 'lodash/merge';
|
|
3
|
-
|
|
4
|
-
export default function create(settings: any = {}) {
|
|
5
|
-
return createTheme(
|
|
6
|
-
merge(
|
|
7
|
-
{
|
|
8
|
-
typography: {
|
|
9
|
-
fontSize: 14,
|
|
10
|
-
allVariants: {
|
|
11
|
-
textTransform: 'none',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
settings
|
|
16
|
-
)
|
|
17
|
-
);
|
|
18
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|