@arcblock/ux 2.11.16 → 2.11.18
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/Locale/context.js +1 -0
- package/lib/SessionBlocklet/index.js +2 -2
- package/lib/SessionUser/components/logged-in.js +12 -1
- package/lib/Util/constant.d.ts +2 -2
- package/lib/Util/constant.js +9 -8
- package/lib/Util/index.js +2 -2
- package/package.json +5 -5
- package/src/Locale/context.tsx +1 -0
- package/src/SessionBlocklet/index.tsx +2 -2
- package/src/SessionUser/components/logged-in.tsx +13 -1
- package/src/Util/constant.ts +7 -6
- package/src/Util/index.ts +2 -2
package/lib/Locale/context.js
CHANGED
@@ -7,7 +7,7 @@ import WidgetsOutlineRoundedIcon from '@iconify-icons/material-symbols/widgets-o
|
|
7
7
|
import { useMemoizedFn, useReactive } from 'ahooks';
|
8
8
|
import Button from '../Button';
|
9
9
|
import { temp as colors } from '../Colors';
|
10
|
-
import {
|
10
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX, NAVIGATION_URL } from '../Util/constant';
|
11
11
|
import SessionPermission from '../SessionPermission';
|
12
12
|
import { getTranslation } from '../Util';
|
13
13
|
export default function SessionBlocklet({
|
@@ -111,7 +111,7 @@ export default function SessionBlocklet({
|
|
111
111
|
},
|
112
112
|
children: [item?.component?.did ? /*#__PURE__*/_jsx(Box, {
|
113
113
|
component: "img",
|
114
|
-
src: `${
|
114
|
+
src: `${BLOCKLET_SERVICE_PATH_PREFIX}/blocklet/logo-bundle/${item.component.did}`,
|
115
115
|
sx: {
|
116
116
|
borderRadius: 2,
|
117
117
|
width: 50,
|
@@ -45,11 +45,22 @@ export default function LoggedIn({
|
|
45
45
|
const onTogglePopper = useMemoizedFn((value = !currentState.open) => {
|
46
46
|
currentState.open = value;
|
47
47
|
});
|
48
|
+
|
48
49
|
// base64 img maybe have some blank char, need encodeURIComponent to transform it
|
49
50
|
const avatar = getUserAvatar(session.user?.avatar?.replace(/\s/g, encodeURIComponent(' ')));
|
51
|
+
|
52
|
+
// FIXME: @zhanghan this should be refactored into SessionContext
|
53
|
+
const oauth = session.useOAuth();
|
54
|
+
const passkey = typeof session.usePasskey === 'function' ? session.usePasskey() : null;
|
50
55
|
const handleSwitchPassport = useMemoizedFn(() => {
|
51
56
|
onTogglePopper(false);
|
52
|
-
session
|
57
|
+
if (session?.user?.sourceProvider === 'passkey') {
|
58
|
+
passkey.switchPassport(session.user);
|
59
|
+
} else if (['google', 'apple', 'email', 'github'].includes(session?.user?.sourceProvider)) {
|
60
|
+
oauth.switchOAuthPassport(session.user);
|
61
|
+
} else {
|
62
|
+
session.switchPassport();
|
63
|
+
}
|
53
64
|
});
|
54
65
|
const handleSwitchAccount = useMemoizedFn(({
|
55
66
|
userSession
|
package/lib/Util/constant.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
export declare const DEFAULT_TIMEOUT: number;
|
2
2
|
export declare const DEFAULT_WINDOW_TIMEOUT: number;
|
3
|
-
export declare const
|
4
|
-
export declare const AUTH_SERVICE_PREFIX = "/.well-known/service";
|
3
|
+
export declare const BLOCKLET_SERVICE_PATH_PREFIX = "/.well-known/service";
|
5
4
|
export declare const SESSION_TOKEN_STORAGE_KEY = "login_token";
|
6
5
|
export declare const REFRESH_TOKEN_STORAGE_KEY = "refresh_token";
|
7
6
|
export declare const RELAY_SOCKET_PREFIX = "/.well-known/service";
|
@@ -22,6 +21,7 @@ export declare const LOGIN_PROVIDER: {
|
|
22
21
|
GOOGLE: string;
|
23
22
|
WALLET: string;
|
24
23
|
NFT: string;
|
24
|
+
PASSKEY: string;
|
25
25
|
};
|
26
26
|
export declare const LOGIN_PROVIDER_NAME: {
|
27
27
|
[x: string]: string;
|
package/lib/Util/constant.js
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
export const DEFAULT_TIMEOUT = 5 * 60;
|
2
2
|
export const DEFAULT_WINDOW_TIMEOUT = 30 * 60;
|
3
|
-
export const
|
4
|
-
export const AUTH_SERVICE_PREFIX = '/.well-known/service';
|
3
|
+
export const BLOCKLET_SERVICE_PATH_PREFIX = '/.well-known/service';
|
5
4
|
export const SESSION_TOKEN_STORAGE_KEY = 'login_token';
|
6
5
|
export const REFRESH_TOKEN_STORAGE_KEY = 'refresh_token';
|
7
6
|
export const RELAY_SOCKET_PREFIX = '/.well-known/service';
|
8
7
|
export const API_DID_PREFIX = '/api/did';
|
9
|
-
export const DASHBOARD_URL = `${
|
10
|
-
export const PROFILE_URL = `${
|
11
|
-
export const DID_SPACE_URL = `${
|
12
|
-
export const NAVIGATION_URL = `${
|
8
|
+
export const DASHBOARD_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin`;
|
9
|
+
export const PROFILE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user`;
|
10
|
+
export const DID_SPACE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user/settings#storage`;
|
11
|
+
export const NAVIGATION_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin/navigation`;
|
13
12
|
export const DID_PREFIX = 'did:abt:';
|
14
13
|
export const PASSPORT_STATUS = {
|
15
14
|
VALID: 'valid',
|
@@ -22,7 +21,8 @@ export const LOGIN_PROVIDER = {
|
|
22
21
|
GITHUB: 'github',
|
23
22
|
GOOGLE: 'google',
|
24
23
|
WALLET: 'wallet',
|
25
|
-
NFT: 'nft'
|
24
|
+
NFT: 'nft',
|
25
|
+
PASSKEY: 'passkey'
|
26
26
|
};
|
27
27
|
export const LOGIN_PROVIDER_NAME = {
|
28
28
|
// [LOGIN_PROVIDER.EMAIL]: 'Email',
|
@@ -31,7 +31,8 @@ export const LOGIN_PROVIDER_NAME = {
|
|
31
31
|
[LOGIN_PROVIDER.GITHUB]: 'Github',
|
32
32
|
[LOGIN_PROVIDER.GOOGLE]: 'Google',
|
33
33
|
[LOGIN_PROVIDER.WALLET]: 'DID Wallet',
|
34
|
-
[LOGIN_PROVIDER.NFT]: 'NFT'
|
34
|
+
[LOGIN_PROVIDER.NFT]: 'NFT',
|
35
|
+
[LOGIN_PROVIDER.PASSKEY]: 'Passkey'
|
35
36
|
};
|
36
37
|
|
37
38
|
// HACK: 目前这里的键值不能使用 [LOGIN_PROVIDER.AUTH0] 形式,否则会影响 ts 的 keyof typeof OAUTH_PROVIDER 来获取键值作为类型的判断
|
package/lib/Util/index.js
CHANGED
@@ -4,7 +4,7 @@ import padStart from 'lodash/padStart';
|
|
4
4
|
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
5
5
|
import isNil from 'lodash/isNil';
|
6
6
|
import pRetry from 'p-retry';
|
7
|
-
import { DID_PREFIX,
|
7
|
+
import { DID_PREFIX, BLOCKLET_SERVICE_PATH_PREFIX } from './constant';
|
8
8
|
let dateTool = null;
|
9
9
|
export function parseQuery(str) {
|
10
10
|
return str.replace(/^\?/, '').split('&').map(x => x.split('=')).filter(([key]) => !!key).reduce((memo, x) => {
|
@@ -293,7 +293,7 @@ export const getUserAvatar = (avatar, size = 48) => {
|
|
293
293
|
if (!avatar) {
|
294
294
|
return avatar;
|
295
295
|
}
|
296
|
-
if (avatar.indexOf(
|
296
|
+
if (avatar.indexOf(BLOCKLET_SERVICE_PATH_PREFIX) >= 0) {
|
297
297
|
return appendParams(avatar, {
|
298
298
|
imageFilter: 'resize',
|
299
299
|
w: size,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.11.
|
3
|
+
"version": "2.11.18",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -68,12 +68,12 @@
|
|
68
68
|
"react": ">=18.2.0",
|
69
69
|
"react-router-dom": ">=6.22.3"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "68ac427a17804a71e469f6fc61b28c87ecb9e40d",
|
72
72
|
"dependencies": {
|
73
73
|
"@arcblock/did-motif": "^1.1.13",
|
74
|
-
"@arcblock/icons": "^2.11.
|
75
|
-
"@arcblock/nft-display": "^2.11.
|
76
|
-
"@arcblock/react-hooks": "^2.11.
|
74
|
+
"@arcblock/icons": "^2.11.18",
|
75
|
+
"@arcblock/nft-display": "^2.11.18",
|
76
|
+
"@arcblock/react-hooks": "^2.11.18",
|
77
77
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
78
78
|
"@fontsource/inter": "^5.0.16",
|
79
79
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
package/src/Locale/context.tsx
CHANGED
@@ -78,6 +78,7 @@ export interface LocaleContextType {
|
|
78
78
|
languages: { code: string; name: string }[];
|
79
79
|
}
|
80
80
|
|
81
|
+
// FIXME: @wangshijun revert this before release
|
81
82
|
const LocaleContext = createContext<LocaleContextType>(null!);
|
82
83
|
const { Provider, Consumer } = LocaleContext;
|
83
84
|
|
@@ -18,7 +18,7 @@ import { useMemoizedFn, useReactive } from 'ahooks';
|
|
18
18
|
|
19
19
|
import Button from '../Button';
|
20
20
|
import { temp as colors } from '../Colors';
|
21
|
-
import {
|
21
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX, NAVIGATION_URL } from '../Util/constant';
|
22
22
|
import SessionPermission from '../SessionPermission';
|
23
23
|
import { getTranslation } from '../Util';
|
24
24
|
import type { Locale } from '../type';
|
@@ -119,7 +119,7 @@ export default function SessionBlocklet({ session, locale = 'zh', size = 24 }: S
|
|
119
119
|
{item?.component?.did ? (
|
120
120
|
<Box
|
121
121
|
component="img"
|
122
|
-
src={`${
|
122
|
+
src={`${BLOCKLET_SERVICE_PATH_PREFIX}/blocklet/logo-bundle/${item.component.did}`}
|
123
123
|
sx={{
|
124
124
|
borderRadius: 2,
|
125
125
|
width: 50,
|
@@ -68,12 +68,24 @@ export default function LoggedIn({
|
|
68
68
|
const onTogglePopper = useMemoizedFn((value = !currentState.open) => {
|
69
69
|
currentState.open = value;
|
70
70
|
});
|
71
|
+
|
71
72
|
// base64 img maybe have some blank char, need encodeURIComponent to transform it
|
72
73
|
const avatar = getUserAvatar(session.user?.avatar?.replace(/\s/g, encodeURIComponent(' ')));
|
74
|
+
|
75
|
+
// FIXME: @zhanghan this should be refactored into SessionContext
|
76
|
+
const oauth = session.useOAuth();
|
77
|
+
const passkey = typeof session.usePasskey === 'function' ? session.usePasskey() : null;
|
73
78
|
const handleSwitchPassport = useMemoizedFn(() => {
|
74
79
|
onTogglePopper(false);
|
75
|
-
session
|
80
|
+
if (session?.user?.sourceProvider === 'passkey') {
|
81
|
+
passkey.switchPassport(session.user);
|
82
|
+
} else if (['google', 'apple', 'email', 'github'].includes(session?.user?.sourceProvider)) {
|
83
|
+
oauth.switchOAuthPassport(session.user);
|
84
|
+
} else {
|
85
|
+
session.switchPassport();
|
86
|
+
}
|
76
87
|
});
|
88
|
+
|
77
89
|
const handleSwitchAccount = useMemoizedFn(({ userSession } = {}) => {
|
78
90
|
return new Promise<void>((resolve) => {
|
79
91
|
const options: Record<string, any> = {};
|
package/src/Util/constant.ts
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
export const DEFAULT_TIMEOUT = 5 * 60;
|
2
2
|
export const DEFAULT_WINDOW_TIMEOUT = 30 * 60;
|
3
|
-
export const
|
4
|
-
export const AUTH_SERVICE_PREFIX = '/.well-known/service';
|
3
|
+
export const BLOCKLET_SERVICE_PATH_PREFIX = '/.well-known/service';
|
5
4
|
export const SESSION_TOKEN_STORAGE_KEY = 'login_token';
|
6
5
|
export const REFRESH_TOKEN_STORAGE_KEY = 'refresh_token';
|
7
6
|
|
8
7
|
export const RELAY_SOCKET_PREFIX = '/.well-known/service';
|
9
8
|
export const API_DID_PREFIX = '/api/did';
|
10
9
|
|
11
|
-
export const DASHBOARD_URL = `${
|
12
|
-
export const PROFILE_URL = `${
|
13
|
-
export const DID_SPACE_URL = `${
|
14
|
-
export const NAVIGATION_URL = `${
|
10
|
+
export const DASHBOARD_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin`;
|
11
|
+
export const PROFILE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user`;
|
12
|
+
export const DID_SPACE_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/user/settings#storage`;
|
13
|
+
export const NAVIGATION_URL = `${BLOCKLET_SERVICE_PATH_PREFIX}/admin/navigation`;
|
15
14
|
|
16
15
|
export const DID_PREFIX = 'did:abt:';
|
17
16
|
|
@@ -28,6 +27,7 @@ export const LOGIN_PROVIDER = {
|
|
28
27
|
GOOGLE: 'google',
|
29
28
|
WALLET: 'wallet',
|
30
29
|
NFT: 'nft',
|
30
|
+
PASSKEY: 'passkey',
|
31
31
|
};
|
32
32
|
|
33
33
|
export const LOGIN_PROVIDER_NAME = {
|
@@ -38,6 +38,7 @@ export const LOGIN_PROVIDER_NAME = {
|
|
38
38
|
[LOGIN_PROVIDER.GOOGLE]: 'Google',
|
39
39
|
[LOGIN_PROVIDER.WALLET]: 'DID Wallet',
|
40
40
|
[LOGIN_PROVIDER.NFT]: 'NFT',
|
41
|
+
[LOGIN_PROVIDER.PASSKEY]: 'Passkey',
|
41
42
|
};
|
42
43
|
|
43
44
|
// HACK: 目前这里的键值不能使用 [LOGIN_PROVIDER.AUTH0] 形式,否则会影响 ts 的 keyof typeof OAUTH_PROVIDER 来获取键值作为类型的判断
|
package/src/Util/index.ts
CHANGED
@@ -4,7 +4,7 @@ import padStart from 'lodash/padStart';
|
|
4
4
|
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
5
5
|
import isNil from 'lodash/isNil';
|
6
6
|
import pRetry from 'p-retry';
|
7
|
-
import { DID_PREFIX,
|
7
|
+
import { DID_PREFIX, BLOCKLET_SERVICE_PATH_PREFIX } from './constant';
|
8
8
|
import type { $TSFixMe, Locale } from '../type';
|
9
9
|
|
10
10
|
let dateTool: $TSFixMe | null = null;
|
@@ -364,7 +364,7 @@ export const getUserAvatar = (avatar: string, size = 48) => {
|
|
364
364
|
return avatar;
|
365
365
|
}
|
366
366
|
|
367
|
-
if (avatar.indexOf(
|
367
|
+
if (avatar.indexOf(BLOCKLET_SERVICE_PATH_PREFIX) >= 0) {
|
368
368
|
return appendParams(avatar, {
|
369
369
|
imageFilter: 'resize',
|
370
370
|
w: size,
|