@arcblock/ux 2.11.15 → 2.11.17

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.
@@ -52,6 +52,7 @@ const getLanguages = arg => {
52
52
  name: '简体中文'
53
53
  }];
54
54
  };
55
+ // FIXME: @wangshijun revert this before release
55
56
  const LocaleContext = /*#__PURE__*/createContext(null);
56
57
  const {
57
58
  Provider,
@@ -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.switchPassport();
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
@@ -22,6 +22,7 @@ export declare const LOGIN_PROVIDER: {
22
22
  GOOGLE: string;
23
23
  WALLET: string;
24
24
  NFT: string;
25
+ PASSKEY: string;
25
26
  };
26
27
  export declare const LOGIN_PROVIDER_NAME: {
27
28
  [x: string]: string;
@@ -22,7 +22,8 @@ export const LOGIN_PROVIDER = {
22
22
  GITHUB: 'github',
23
23
  GOOGLE: 'google',
24
24
  WALLET: 'wallet',
25
- NFT: 'nft'
25
+ NFT: 'nft',
26
+ PASSKEY: 'passkey'
26
27
  };
27
28
  export const LOGIN_PROVIDER_NAME = {
28
29
  // [LOGIN_PROVIDER.EMAIL]: 'Email',
@@ -31,7 +32,8 @@ export const LOGIN_PROVIDER_NAME = {
31
32
  [LOGIN_PROVIDER.GITHUB]: 'Github',
32
33
  [LOGIN_PROVIDER.GOOGLE]: 'Google',
33
34
  [LOGIN_PROVIDER.WALLET]: 'DID Wallet',
34
- [LOGIN_PROVIDER.NFT]: 'NFT'
35
+ [LOGIN_PROVIDER.NFT]: 'NFT',
36
+ [LOGIN_PROVIDER.PASSKEY]: 'Passkey'
35
37
  };
36
38
 
37
39
  // HACK: 目前这里的键值不能使用 [LOGIN_PROVIDER.AUTH0] 形式,否则会影响 ts 的 keyof typeof OAUTH_PROVIDER 来获取键值作为类型的判断
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.11.15",
3
+ "version": "2.11.17",
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": "08b1daa5c17ade28952f1c44fb4e6f79f1c3b178",
71
+ "gitHead": "2fd2da7dc02086457df65f0c2e7a4a14c9be0f49",
72
72
  "dependencies": {
73
73
  "@arcblock/did-motif": "^1.1.13",
74
- "@arcblock/icons": "^2.11.15",
75
- "@arcblock/nft-display": "^2.11.15",
76
- "@arcblock/react-hooks": "^2.11.15",
74
+ "@arcblock/icons": "^2.11.17",
75
+ "@arcblock/nft-display": "^2.11.17",
76
+ "@arcblock/react-hooks": "^2.11.17",
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",
@@ -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
 
@@ -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.switchPassport();
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> = {};
@@ -28,6 +28,7 @@ export const LOGIN_PROVIDER = {
28
28
  GOOGLE: 'google',
29
29
  WALLET: 'wallet',
30
30
  NFT: 'nft',
31
+ PASSKEY: 'passkey',
31
32
  };
32
33
 
33
34
  export const LOGIN_PROVIDER_NAME = {
@@ -38,6 +39,7 @@ export const LOGIN_PROVIDER_NAME = {
38
39
  [LOGIN_PROVIDER.GOOGLE]: 'Google',
39
40
  [LOGIN_PROVIDER.WALLET]: 'DID Wallet',
40
41
  [LOGIN_PROVIDER.NFT]: 'NFT',
42
+ [LOGIN_PROVIDER.PASSKEY]: 'Passkey',
41
43
  };
42
44
 
43
45
  // HACK: 目前这里的键值不能使用 [LOGIN_PROVIDER.AUTH0] 形式,否则会影响 ts 的 keyof typeof OAUTH_PROVIDER 来获取键值作为类型的判断