@arcblock/did-connect-react 3.4.15 → 3.5.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/dist/standalone/did-connect-react.css +1 -0
- package/dist/standalone/index.js +133700 -0
- package/lib/package.json.js +1 -1
- package/package.json +11 -6
- package/.aigne/doc-smith/config.yaml +0 -85
- package/.aigne/doc-smith/history.yaml +0 -6
- package/.aigne/doc-smith/output/structure-plan.json +0 -204
- package/.aigne/doc-smith/translation-cache.yaml +0 -11
- package/.aigne/doc-smith/upload-cache.yaml +0 -213
- package/docs/_sidebar.md +0 -18
- package/docs/advanced-authentication-methods.ja.md +0 -261
- package/docs/advanced-authentication-methods.md +0 -261
- package/docs/advanced-authentication-methods.zh-TW.md +0 -261
- package/docs/advanced-authentication-methods.zh.md +0 -261
- package/docs/advanced-utilities.ja.md +0 -132
- package/docs/advanced-utilities.md +0 -132
- package/docs/advanced-utilities.zh-TW.md +0 -132
- package/docs/advanced-utilities.zh.md +0 -132
- package/docs/advanced.ja.md +0 -95
- package/docs/advanced.md +0 -95
- package/docs/advanced.zh-TW.md +0 -95
- package/docs/advanced.zh.md +0 -95
- package/docs/api-reference.ja.md +0 -178
- package/docs/api-reference.md +0 -178
- package/docs/api-reference.zh-TW.md +0 -178
- package/docs/api-reference.zh.md +0 -178
- package/docs/assets/diagram/core-components-session-provider-01.ja.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/overview-01.ja.jpg +0 -0
- package/docs/assets/diagram/overview-01.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh.jpg +0 -0
- package/docs/core-components-did-connect.ja.md +0 -166
- package/docs/core-components-did-connect.md +0 -166
- package/docs/core-components-did-connect.zh-TW.md +0 -166
- package/docs/core-components-did-connect.zh.md +0 -166
- package/docs/core-components-session-provider.ja.md +0 -197
- package/docs/core-components-session-provider.md +0 -197
- package/docs/core-components-session-provider.zh-TW.md +0 -197
- package/docs/core-components-session-provider.zh.md +0 -197
- package/docs/core-components.ja.md +0 -16
- package/docs/core-components.md +0 -16
- package/docs/core-components.zh-TW.md +0 -16
- package/docs/core-components.zh.md +0 -16
- package/docs/getting-started.ja.md +0 -138
- package/docs/getting-started.md +0 -138
- package/docs/getting-started.zh-TW.md +0 -138
- package/docs/getting-started.zh.md +0 -138
- package/docs/hooks-use-connect.ja.md +0 -178
- package/docs/hooks-use-connect.md +0 -178
- package/docs/hooks-use-connect.zh-TW.md +0 -178
- package/docs/hooks-use-connect.zh.md +0 -178
- package/docs/hooks-use-did.ja.md +0 -107
- package/docs/hooks-use-did.md +0 -107
- package/docs/hooks-use-did.zh-TW.md +0 -107
- package/docs/hooks-use-did.zh.md +0 -107
- package/docs/hooks-use-oauth-passkey.ja.md +0 -188
- package/docs/hooks-use-oauth-passkey.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh-TW.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh.md +0 -188
- package/docs/hooks.ja.md +0 -23
- package/docs/hooks.md +0 -23
- package/docs/hooks.zh-TW.md +0 -23
- package/docs/hooks.zh.md +0 -23
- package/docs/overview.ja.md +0 -119
- package/docs/overview.md +0 -119
- package/docs/overview.zh-TW.md +0 -119
- package/docs/overview.zh.md +0 -119
- package/docs/ui-components-address.ja.md +0 -121
- package/docs/ui-components-address.md +0 -121
- package/docs/ui-components-address.zh-TW.md +0 -121
- package/docs/ui-components-address.zh.md +0 -121
- package/docs/ui-components-avatar.ja.md +0 -65
- package/docs/ui-components-avatar.md +0 -65
- package/docs/ui-components-avatar.zh-TW.md +0 -65
- package/docs/ui-components-avatar.zh.md +0 -65
- package/docs/ui-components-button.ja.md +0 -99
- package/docs/ui-components-button.md +0 -99
- package/docs/ui-components-button.zh-TW.md +0 -99
- package/docs/ui-components-button.zh.md +0 -99
- package/docs/ui-components-logo.ja.md +0 -52
- package/docs/ui-components-logo.md +0 -52
- package/docs/ui-components-logo.zh-TW.md +0 -52
- package/docs/ui-components-logo.zh.md +0 -52
- package/docs/ui-components.ja.md +0 -57
- package/docs/ui-components.md +0 -57
- package/docs/ui-components.zh-TW.md +0 -57
- package/docs/ui-components.zh.md +0 -57
- package/glossary.md +0 -1
- package/src/Address/index.jsx +0 -2
- package/src/Avatar/index.jsx +0 -2
- package/src/Button/Button.stories.jsx +0 -7
- package/src/Button/index.jsx +0 -21
- package/src/Connect/Connect.stories.jsx +0 -34
- package/src/Connect/assets/locale.js +0 -149
- package/src/Connect/assets/login-bg.png +0 -0
- package/src/Connect/assets/login-slogan.js +0 -7
- package/src/Connect/components/action-button.jsx +0 -22
- package/src/Connect/components/app-tips.jsx +0 -156
- package/src/Connect/components/auto-height.jsx +0 -38
- package/src/Connect/components/back-button.jsx +0 -24
- package/src/Connect/components/connect-status.jsx +0 -259
- package/src/Connect/components/did-connect-title.jsx +0 -107
- package/src/Connect/components/download-tips.jsx +0 -55
- package/src/Connect/components/loading.jsx +0 -25
- package/src/Connect/components/login-item/connect-choose-list.jsx +0 -328
- package/src/Connect/components/login-item/connect-provider-list.jsx +0 -473
- package/src/Connect/components/login-item/login-method-item.jsx +0 -139
- package/src/Connect/components/login-item/mobile-login-item.jsx +0 -184
- package/src/Connect/components/login-item/passkey-login-item.jsx +0 -56
- package/src/Connect/components/login-item/wallet-login-options.jsx +0 -129
- package/src/Connect/components/login-item/web-login-item.jsx +0 -159
- package/src/Connect/components/mask-overlay.jsx +0 -32
- package/src/Connect/components/refresh-overlay.jsx +0 -52
- package/src/Connect/components/switch-app.jsx +0 -69
- package/src/Connect/connect.jsx +0 -635
- package/src/Connect/contexts/state.jsx +0 -235
- package/src/Connect/fallback-connect.jsx +0 -47
- package/src/Connect/fullpage.jsx +0 -3
- package/src/Connect/hooks/auth-url.js +0 -31
- package/src/Connect/hooks/method-list.js +0 -121
- package/src/Connect/hooks/page-show.js +0 -24
- package/src/Connect/hooks/provider-list.js +0 -168
- package/src/Connect/hooks/security.js +0 -40
- package/src/Connect/hooks/token.js +0 -627
- package/src/Connect/hooks/use-apps.js +0 -69
- package/src/Connect/hooks/use-quick-connect.js +0 -119
- package/src/Connect/index.jsx +0 -21
- package/src/Connect/landing-page.jsx +0 -3
- package/src/Connect/plugins/email/index.jsx +0 -85
- package/src/Connect/plugins/email/list-item.jsx +0 -35
- package/src/Connect/plugins/email/placeholder.jsx +0 -372
- package/src/Connect/plugins/index.js +0 -2
- package/src/Connect/use-connect.jsx +0 -321
- package/src/Connect/with-blocklet.jsx +0 -26
- package/src/Connect/with-bridge-call.jsx +0 -138
- package/src/Federated/context.jsx +0 -93
- package/src/Federated/index.jsx +0 -1
- package/src/Logo/index.jsx +0 -2
- package/src/OAuth/bind-conflict-alert.jsx +0 -37
- package/src/OAuth/context.jsx +0 -407
- package/src/OAuth/guest.svg +0 -20
- package/src/OAuth/index.jsx +0 -1
- package/src/OAuth/passport-switcher.jsx +0 -2
- package/src/Passkey/actions.jsx +0 -217
- package/src/Passkey/constants.js +0 -2
- package/src/Passkey/context.jsx +0 -395
- package/src/Passkey/dialog.jsx +0 -401
- package/src/Passkey/icon.jsx +0 -10
- package/src/Passkey/index.jsx +0 -2
- package/src/Service/index.jsx +0 -96
- package/src/Session/assets/did-spaces-guide-cover.svg +0 -1
- package/src/Session/assets/did-spaces-guide-icon.svg +0 -7
- package/src/Session/context.jsx +0 -7
- package/src/Session/did-spaces-guide.jsx +0 -173
- package/src/Session/handler.jsx +0 -98
- package/src/Session/hooks/use-federated.js +0 -91
- package/src/Session/hooks/use-mobile.jsx +0 -6
- package/src/Session/hooks/use-protected-routes.js +0 -16
- package/src/Session/hooks/use-session-token.js +0 -400
- package/src/Session/hooks/use-verify.jsx +0 -76
- package/src/Session/index.jsx +0 -1789
- package/src/Session/libs/constants.js +0 -17
- package/src/Session/libs/did-spaces.js +0 -38
- package/src/Session/libs/federated.js +0 -82
- package/src/Session/libs/index.js +0 -5
- package/src/Session/libs/locales.js +0 -160
- package/src/Session/libs/login-mobile.js +0 -80
- package/src/Session/window-focus-aware.jsx +0 -28
- package/src/SessionManager/index.jsx +0 -2
- package/src/Storage/engine/cookie.js +0 -25
- package/src/Storage/engine/local-storage.js +0 -57
- package/src/Storage/index.js +0 -25
- package/src/User/index.js +0 -4
- package/src/User/use-did.js +0 -80
- package/src/User/wrap-did.jsx +0 -18
- package/src/WebWalletSWKeeper/index.jsx +0 -3
- package/src/components/PassportSwitcher.jsx +0 -160
- package/src/constant.js +0 -27
- package/src/error.js +0 -6
- package/src/hooks/use-locale.jsx +0 -6
- package/src/index.js +0 -32
- package/src/locales/en.jsx +0 -15
- package/src/locales/index.jsx +0 -13
- package/src/locales/zh.jsx +0 -15
- package/src/types.d.ts +0 -355
- package/src/utils.js +0 -413
- package/vite.config.mjs +0 -29
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/prop-types */
|
|
2
|
-
import pick from 'lodash/pick';
|
|
3
|
-
import { Confirm } from '@arcblock/ux/lib/Dialog';
|
|
4
|
-
import { Box } from '@mui/material';
|
|
5
|
-
import Toast from '@arcblock/ux/lib/Toast';
|
|
6
|
-
import CardSelector from '@arcblock/ux/lib/CardSelector';
|
|
7
|
-
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
8
|
-
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
9
|
-
import { createPassportSvg } from '@arcblock/ux/lib/Util/passport';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line import/no-unresolved
|
|
12
|
-
import { ReactGA } from '@arcblock/ux/lib/withTracker';
|
|
13
|
-
// eslint-disable-next-line import/no-unresolved
|
|
14
|
-
import Guest from '../OAuth/guest.svg?react';
|
|
15
|
-
|
|
16
|
-
export const parseResponse = (data) => {
|
|
17
|
-
if (!data) {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// for backward compatibility
|
|
22
|
-
if (typeof data === 'string') {
|
|
23
|
-
return { sessionToken: data };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return pick(data, ['sessionToken', 'refreshToken', 'visitorId', 'destroySessionId', 'csrfToken']);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const translations = {
|
|
30
|
-
zh: {
|
|
31
|
-
switchPassport: '切换通行证',
|
|
32
|
-
switchPassportFailed: '切换通行证失败',
|
|
33
|
-
switchPassportSucceed: '切换通行证成功',
|
|
34
|
-
selectedPassport: '请选择一个通行证',
|
|
35
|
-
switch: '切换',
|
|
36
|
-
cancel: '取消',
|
|
37
|
-
currentRole: '当前角色:',
|
|
38
|
-
passport: '通行证',
|
|
39
|
-
getPassportFailed: '获取通行证失败',
|
|
40
|
-
},
|
|
41
|
-
en: {
|
|
42
|
-
switchPassport: 'Switch passport',
|
|
43
|
-
switchPassportFailed: 'Switch passport failed',
|
|
44
|
-
switchPassportSucceed: 'Switch passport succeed',
|
|
45
|
-
selectedPassport: 'Select a passport to switch',
|
|
46
|
-
switch: 'Switch',
|
|
47
|
-
cancel: 'Cancel',
|
|
48
|
-
currentRole: 'Current role: ',
|
|
49
|
-
passport: 'Passport',
|
|
50
|
-
getPassportFailed: 'Get passports failed',
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export function PassportSwitcher({ api, locale, switchState, onSwitchPassport, session }) {
|
|
55
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
56
|
-
return translate(translations, key, locale, 'en', data);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const visiblePassports = useCreation(() => {
|
|
60
|
-
return switchState.passports.filter((x) => x.role !== switchState.currentUser?.role);
|
|
61
|
-
}, [switchState.passports, switchState.currentUser?.role]);
|
|
62
|
-
|
|
63
|
-
const onSwitch = async () => {
|
|
64
|
-
const passportId = switchState.selectedPassport;
|
|
65
|
-
const fromRole = session?.user?.role;
|
|
66
|
-
const toRole = session?.user?.passports?.find((x) => x.id === passportId)?.role ?? 'guest';
|
|
67
|
-
const change = `${fromRole} -> ${toRole}`;
|
|
68
|
-
try {
|
|
69
|
-
const { data } = await api.post('/switch', { passportId });
|
|
70
|
-
const { sessionToken, refreshToken, csrfToken } = parseResponse(data);
|
|
71
|
-
onSwitchPassport({ sessionToken, refreshToken, csrfToken });
|
|
72
|
-
Toast.success(t('switchPassportSucceed'));
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @type {import('@arcblock/ux/lib/withTracker/action/switch-passport').SwitchPassportSuccessEvent}
|
|
76
|
-
*/
|
|
77
|
-
const switchPassportSuccessEvent = {
|
|
78
|
-
action: 'switchPassportSuccess',
|
|
79
|
-
change,
|
|
80
|
-
success: true,
|
|
81
|
-
};
|
|
82
|
-
ReactGA.event(switchPassportSuccessEvent.action, switchPassportSuccessEvent);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
const errorMessage = err.message || t('switchPassportFailed');
|
|
85
|
-
/**
|
|
86
|
-
* @type {import('@arcblock/ux/lib/withTracker/action/switch-passport').SwitchPassportFailedEvent}
|
|
87
|
-
*/
|
|
88
|
-
const switchPassportFailedEvent = {
|
|
89
|
-
action: 'switchPassportFailed',
|
|
90
|
-
success: false,
|
|
91
|
-
change,
|
|
92
|
-
errorMessage,
|
|
93
|
-
};
|
|
94
|
-
ReactGA.event(switchPassportFailedEvent.action, switchPassportFailedEvent);
|
|
95
|
-
Toast.error(errorMessage);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<Confirm
|
|
101
|
-
open={switchState.open}
|
|
102
|
-
title={t('switchPassport')}
|
|
103
|
-
onConfirm={onSwitch}
|
|
104
|
-
onCancel={switchState.reset}
|
|
105
|
-
confirmButton={{
|
|
106
|
-
text: t('switch'),
|
|
107
|
-
props: {
|
|
108
|
-
variant: 'contained',
|
|
109
|
-
color: 'primary',
|
|
110
|
-
},
|
|
111
|
-
}}
|
|
112
|
-
cancelButton={{
|
|
113
|
-
text: t('cancel'),
|
|
114
|
-
props: {
|
|
115
|
-
color: 'inherit',
|
|
116
|
-
},
|
|
117
|
-
}}
|
|
118
|
-
PaperProps={{ style: { width: 600 } }}>
|
|
119
|
-
<Box
|
|
120
|
-
sx={{
|
|
121
|
-
mb: 2,
|
|
122
|
-
}}>
|
|
123
|
-
{t('currentRole')}
|
|
124
|
-
{switchState.currentUser?.role}
|
|
125
|
-
</Box>
|
|
126
|
-
<CardSelector
|
|
127
|
-
width={160}
|
|
128
|
-
height={240}
|
|
129
|
-
cardSpace={24}
|
|
130
|
-
list={[
|
|
131
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
132
|
-
() => <Guest />,
|
|
133
|
-
...visiblePassports.map((x) => {
|
|
134
|
-
if (x.display) {
|
|
135
|
-
return {
|
|
136
|
-
src: x.display,
|
|
137
|
-
name: x.title,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line react/no-unstable-nested-components, react/function-component-definition
|
|
142
|
-
return () => (
|
|
143
|
-
<Box
|
|
144
|
-
key={x.id}
|
|
145
|
-
sx={{ width: '100%' }}
|
|
146
|
-
dangerouslySetInnerHTML={{
|
|
147
|
-
__html: createPassportSvg(x),
|
|
148
|
-
}}
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
}),
|
|
152
|
-
]}
|
|
153
|
-
onSelect={(index) => {
|
|
154
|
-
switchState.selectedPassport = index > 0 ? visiblePassports[index - 1].id : undefined;
|
|
155
|
-
}}
|
|
156
|
-
defaultIndex={0}
|
|
157
|
-
/>
|
|
158
|
-
</Confirm>
|
|
159
|
-
);
|
|
160
|
-
}
|
package/src/constant.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_TIMEOUT = 5 * 60;
|
|
2
|
-
export const DEFAULT_WINDOW_TIMEOUT = 30 * 60;
|
|
3
|
-
export const BLOCKLET_SERVICE_PATH_PREFIX = '/.well-known/service';
|
|
4
|
-
export const SESSION_TOKEN_STORAGE_KEY = 'login_token';
|
|
5
|
-
export const CSRF_TOKEN_STORAGE_KEY = 'x-csrf-token';
|
|
6
|
-
export const REFRESH_TOKEN_STORAGE_KEY = 'refresh_token';
|
|
7
|
-
|
|
8
|
-
export const RELAY_SOCKET_PREFIX = '/.well-known/service';
|
|
9
|
-
export const API_DID_PREFIX = '/api/did';
|
|
10
|
-
|
|
11
|
-
export const DEFAULT_NAME = 'DID Connect';
|
|
12
|
-
|
|
13
|
-
export const DID_CONNECT_URL_PARAMS_NAME = '__did-connect__';
|
|
14
|
-
|
|
15
|
-
export const BUSY_STATUS = ['scanned', 'succeed', 'error', 'busy'];
|
|
16
|
-
export const EXT_DOWNLOAD_URL = {
|
|
17
|
-
chrome: 'https://chromewebstore.google.com/detail/did-wallet/ibjflpbmadchofnbpppegdbnifdgincp',
|
|
18
|
-
edge: 'https://microsoftedge.microsoft.com/addons/detail/did-wallet/hjgoblidjnnnamdkinbichnfbmghmafd',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const CHECK_STATUS_INTERVAL = 2 * 1000;
|
|
22
|
-
export const VERIFY_CODE_LENGTH = 6;
|
|
23
|
-
|
|
24
|
-
export const LANG_COOKIE_NAME = 'nf_lang';
|
|
25
|
-
export const CHECK_INTERVAL_TIME = 1000;
|
|
26
|
-
|
|
27
|
-
export const DID_SPACES_BASE_URL = window?.blocklet?.DID_SPACES_BASE_URL || 'https://www.didspaces.com/app';
|
package/src/error.js
DELETED
package/src/hooks/use-locale.jsx
DELETED
package/src/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import DidConnect from './Connect';
|
|
2
|
-
import Button from './Button';
|
|
3
|
-
import Logo from './Logo';
|
|
4
|
-
import Session from './Session';
|
|
5
|
-
|
|
6
|
-
export * from './OAuth';
|
|
7
|
-
export * from './Passkey';
|
|
8
|
-
export * from './Session';
|
|
9
|
-
export * from './User';
|
|
10
|
-
export * from './Federated';
|
|
11
|
-
export * from './constant';
|
|
12
|
-
export * from './utils';
|
|
13
|
-
export * from './error';
|
|
14
|
-
|
|
15
|
-
export { default as SessionManager } from './SessionManager';
|
|
16
|
-
export { default as Address } from './Address';
|
|
17
|
-
export { default as Avatar } from './Avatar';
|
|
18
|
-
export { default as useConnect } from './Connect/use-connect';
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
// DID Connect
|
|
22
|
-
DidConnect,
|
|
23
|
-
DidConnect as Connect,
|
|
24
|
-
DidConnect as DIDConnect,
|
|
25
|
-
Logo,
|
|
26
|
-
Logo as DIDLogo,
|
|
27
|
-
Button,
|
|
28
|
-
Button as DIDButton,
|
|
29
|
-
|
|
30
|
-
// DEPRECATED
|
|
31
|
-
Session,
|
|
32
|
-
};
|
package/src/locales/en.jsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import flat from 'flat';
|
|
2
|
-
|
|
3
|
-
export default flat({
|
|
4
|
-
didSpacesGuide: {
|
|
5
|
-
title: 'Connect to DID Spaces',
|
|
6
|
-
description: 'Your secure, private, and reliable decentralized digital storage space.',
|
|
7
|
-
feature: {
|
|
8
|
-
dataSecurity: 'Data Security',
|
|
9
|
-
dataSharing: 'Data Sharing',
|
|
10
|
-
dataSync: 'Data Sync',
|
|
11
|
-
dataIntegration: 'Data Integration',
|
|
12
|
-
},
|
|
13
|
-
connectNow: 'Connect Now',
|
|
14
|
-
},
|
|
15
|
-
});
|
package/src/locales/index.jsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
import en from './en';
|
|
3
|
-
import zh from './zh';
|
|
4
|
-
|
|
5
|
-
const locales = { en, zh };
|
|
6
|
-
|
|
7
|
-
const replace = (template, data) =>
|
|
8
|
-
template.replace(/{(\w*)}/g, (_, key) => (Object.prototype.hasOwnProperty.call(data, key) ? data[key] : ''));
|
|
9
|
-
|
|
10
|
-
export function t(key, locale = 'en', params = {}) {
|
|
11
|
-
const _locale = locale in locales ? locale : 'en';
|
|
12
|
-
return replace(locales[_locale][key], params) || key;
|
|
13
|
-
}
|
package/src/locales/zh.jsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import flat from 'flat';
|
|
2
|
-
|
|
3
|
-
export default flat({
|
|
4
|
-
didSpacesGuide: {
|
|
5
|
-
title: '连接到 DID Spaces',
|
|
6
|
-
description: '您的安全、私密、可靠的分散式数字存储空间。',
|
|
7
|
-
feature: {
|
|
8
|
-
dataSecurity: '数据安全',
|
|
9
|
-
dataSharing: '数据共享',
|
|
10
|
-
dataSync: '数据同步',
|
|
11
|
-
dataIntegration: '数据集成',
|
|
12
|
-
},
|
|
13
|
-
connectNow: '立即连接',
|
|
14
|
-
},
|
|
15
|
-
});
|
package/src/types.d.ts
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios';
|
|
2
|
-
import type { EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { DEFAULT_TIMEOUT } from './constant';
|
|
4
|
-
import type { ReactNode } from 'react';
|
|
5
|
-
|
|
6
|
-
export type ConnectMessages = {
|
|
7
|
-
title: string;
|
|
8
|
-
scan: string;
|
|
9
|
-
success: ReactNode;
|
|
10
|
-
confirm?: string; // 貌似没有地方使用,先设置为非必填
|
|
11
|
-
error?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// FIXME: @zhanghan 将来需要改成 ts,直接从常量值 LOGIN_PROVIDER 中提取类型,目前只能写成这样
|
|
15
|
-
export type WalletProvider = 'wallet' | 'auth0' | 'apple' | 'github' | 'google' | 'passkey';
|
|
16
|
-
|
|
17
|
-
export type WalletOS = 'web' | 'android' | 'ios' | '';
|
|
18
|
-
export type UserRole = 'guest' | 'member' | 'admin' | 'owner' | string;
|
|
19
|
-
export type BaseLocale = 'en' | 'zh';
|
|
20
|
-
export type UserLocale = BaseLocale | string;
|
|
21
|
-
|
|
22
|
-
export type ConnectProps = {
|
|
23
|
-
/**
|
|
24
|
-
* @example login
|
|
25
|
-
*/
|
|
26
|
-
action: string;
|
|
27
|
-
containerEl?: Element;
|
|
28
|
-
/**
|
|
29
|
-
* @default "/api/did"
|
|
30
|
-
*/
|
|
31
|
-
prefix?: string;
|
|
32
|
-
/**
|
|
33
|
-
* @default "en"
|
|
34
|
-
*/
|
|
35
|
-
locale?: 'en' | 'zh';
|
|
36
|
-
/**
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
popup?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* @default 2*1000
|
|
42
|
-
*/
|
|
43
|
-
checkInterval?: number;
|
|
44
|
-
/**
|
|
45
|
-
* @default 5*60*1000
|
|
46
|
-
*/
|
|
47
|
-
checkTimeout?: number;
|
|
48
|
-
/**
|
|
49
|
-
* @default 2*1000
|
|
50
|
-
*/
|
|
51
|
-
closeTimeout?: number;
|
|
52
|
-
/**
|
|
53
|
-
* @default {}
|
|
54
|
-
*/
|
|
55
|
-
extraParams?: object;
|
|
56
|
-
/**
|
|
57
|
-
* @default "_t_"
|
|
58
|
-
*/
|
|
59
|
-
tokenKey?: string;
|
|
60
|
-
/**
|
|
61
|
-
* @default "_ek_"
|
|
62
|
-
*/
|
|
63
|
-
encKey?: string;
|
|
64
|
-
/**
|
|
65
|
-
* @default "''"
|
|
66
|
-
*/
|
|
67
|
-
baseUrl?: string;
|
|
68
|
-
/**
|
|
69
|
-
* @default {
|
|
70
|
-
title: 'DID Connect',
|
|
71
|
-
scan: 'Scan QR code to complete this action',
|
|
72
|
-
confirm: 'Confirm on your DID Wallet',
|
|
73
|
-
success: 'Success!'
|
|
74
|
-
}
|
|
75
|
-
*/
|
|
76
|
-
messages?: ConnectMessages;
|
|
77
|
-
/**
|
|
78
|
-
* @default true
|
|
79
|
-
*/
|
|
80
|
-
autoConnect?: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* @default true
|
|
83
|
-
*/
|
|
84
|
-
forceConnected?: boolean | string;
|
|
85
|
-
/**
|
|
86
|
-
* @default true
|
|
87
|
-
*/
|
|
88
|
-
saveConnect?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* @default true
|
|
91
|
-
*/
|
|
92
|
-
useSocket?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* @default true
|
|
95
|
-
*/
|
|
96
|
-
allowWallet?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* @default true
|
|
99
|
-
*/
|
|
100
|
-
passkeyBehavior?: 'none' | 'both' | 'only-existing' | 'only-new';
|
|
101
|
-
/**
|
|
102
|
-
* @default "wallet"
|
|
103
|
-
*/
|
|
104
|
-
provider?: 'wallet' | 'auth0' | '';
|
|
105
|
-
/**
|
|
106
|
-
* @default 160
|
|
107
|
-
*/
|
|
108
|
-
qrcodeSize?: number;
|
|
109
|
-
/**
|
|
110
|
-
* @default true
|
|
111
|
-
*/
|
|
112
|
-
showDownload?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* @default "https://web.abtwallet.io"
|
|
115
|
-
*/
|
|
116
|
-
webWalletUrl?: string;
|
|
117
|
-
/**
|
|
118
|
-
* @default ["web", "mobile", "github", "apple", "google", "auth0", "passkey"]
|
|
119
|
-
*/
|
|
120
|
-
enabledConnectTypes?: Array<'web' | 'mobile' | 'auth0', 'github' | 'apple' | 'google' | 'passkey'>;
|
|
121
|
-
extraContent?: any;
|
|
122
|
-
loadingEle?: any;
|
|
123
|
-
/**
|
|
124
|
-
* @default false
|
|
125
|
-
*/
|
|
126
|
-
disableSwitchApp?: boolean;
|
|
127
|
-
/**
|
|
128
|
-
* @default false
|
|
129
|
-
*/
|
|
130
|
-
hideCloseButton?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* @default {}
|
|
133
|
-
*/
|
|
134
|
-
options?: {
|
|
135
|
-
/**
|
|
136
|
-
* @default true
|
|
137
|
-
*/
|
|
138
|
-
showQuickConnect?: boolean;
|
|
139
|
-
};
|
|
140
|
-
onRecreateSession?: Function;
|
|
141
|
-
checkFn?: () => boolean;
|
|
142
|
-
onSuccess?: (result: object) => void;
|
|
143
|
-
onError?: (error: any) => void;
|
|
144
|
-
onClose?: Function;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export type OpenConnect = (params: ConnectProps) => void;
|
|
148
|
-
export type OpenConnectPopup = (
|
|
149
|
-
params: ConnectProps,
|
|
150
|
-
options?: {
|
|
151
|
-
baseUrl?: string;
|
|
152
|
-
locale?: BaseLocale;
|
|
153
|
-
}
|
|
154
|
-
) => void;
|
|
155
|
-
|
|
156
|
-
export type OpenDidConnect = (
|
|
157
|
-
params: ConnectProps,
|
|
158
|
-
options?: {
|
|
159
|
-
/**
|
|
160
|
-
* 打开 DID Connect 的模式
|
|
161
|
-
* @default 'popup'
|
|
162
|
-
*/
|
|
163
|
-
openMode?: 'redirect' | 'window' | 'popup';
|
|
164
|
-
requirements?: {
|
|
165
|
-
/**
|
|
166
|
-
* 是否要求登录
|
|
167
|
-
* @default true
|
|
168
|
-
*/
|
|
169
|
-
login?: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* 是否要求绑定 DID Wallet 账户
|
|
172
|
-
* @default true
|
|
173
|
-
*/
|
|
174
|
-
bindWallet?: boolean;
|
|
175
|
-
/**
|
|
176
|
-
* 是否要求绑定 DID Spaces
|
|
177
|
-
* @default false
|
|
178
|
-
*/
|
|
179
|
-
bindDidSpaces?: false | 'read' | 'full';
|
|
180
|
-
// bindOAuth?: boolea // 暂不支持,这里要配置的情况会稍微复杂一些
|
|
181
|
-
};
|
|
182
|
-
baseUrl?: string;
|
|
183
|
-
locale?: BaseLocale;
|
|
184
|
-
}
|
|
185
|
-
) => void;
|
|
186
|
-
|
|
187
|
-
export type CloseConnect = Function;
|
|
188
|
-
|
|
189
|
-
export type CommonSessionFn = (done?: Function, params?: object) => void;
|
|
190
|
-
|
|
191
|
-
export type LoginSessionFn = (
|
|
192
|
-
done?: Function,
|
|
193
|
-
params?: {
|
|
194
|
-
openMode: 'redirect' | 'window'; // iframe: 暂未启用
|
|
195
|
-
provider?: 'wallet';
|
|
196
|
-
redirect?: string;
|
|
197
|
-
forceConnected?: string;
|
|
198
|
-
sourceAppPid?: string;
|
|
199
|
-
passkeyBehavior?: string;
|
|
200
|
-
[key: string]: any;
|
|
201
|
-
},
|
|
202
|
-
origin?: string
|
|
203
|
-
) => any;
|
|
204
|
-
|
|
205
|
-
export type LogoutSessionFn = (done?: Function) => void;
|
|
206
|
-
|
|
207
|
-
export type Passport = {
|
|
208
|
-
id: string;
|
|
209
|
-
name: string;
|
|
210
|
-
title: string;
|
|
211
|
-
role: UserRole;
|
|
212
|
-
};
|
|
213
|
-
export type ConnectAccount = {
|
|
214
|
-
provider: WalletProvider;
|
|
215
|
-
did: string;
|
|
216
|
-
pk: string;
|
|
217
|
-
id?: string;
|
|
218
|
-
firstLoginAt?: string;
|
|
219
|
-
lastLoginAt?: string;
|
|
220
|
-
lastLoginIp?: string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export type SessionUser = {
|
|
224
|
-
avatar: string;
|
|
225
|
-
did: string;
|
|
226
|
-
email: string;
|
|
227
|
-
fullName: string;
|
|
228
|
-
remark?: string;
|
|
229
|
-
role?: UserRole;
|
|
230
|
-
sourceAppPid: null | string;
|
|
231
|
-
sourceProvider: WalletProvider;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
export type UserSession = {
|
|
235
|
-
id: string;
|
|
236
|
-
appName: string;
|
|
237
|
-
appPid: string;
|
|
238
|
-
updatedAt: string;
|
|
239
|
-
userDid: string;
|
|
240
|
-
visitorId: string;
|
|
241
|
-
extra: object;
|
|
242
|
-
user: SessionUser;
|
|
243
|
-
passportId?: string;
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export type User = {
|
|
247
|
-
approved: boolean;
|
|
248
|
-
avatar: string;
|
|
249
|
-
connectedAccounts: ConnectAccount[];
|
|
250
|
-
did: string;
|
|
251
|
-
pk: string;
|
|
252
|
-
email: string;
|
|
253
|
-
fullName: string;
|
|
254
|
-
role: UserRole;
|
|
255
|
-
locale: UserLocale;
|
|
256
|
-
passports: Passport[];
|
|
257
|
-
permissions: any[];
|
|
258
|
-
sourceAppPid?: string;
|
|
259
|
-
sourceProvider?: WalletProvider;
|
|
260
|
-
didSpace?: object;
|
|
261
|
-
remark?: string;
|
|
262
|
-
createdAt: string;
|
|
263
|
-
updatedAt: string;
|
|
264
|
-
firstLoginAt?: string;
|
|
265
|
-
lastLoginAt?: string;
|
|
266
|
-
lastLoginIp?: string;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
export type SessionProps = {
|
|
270
|
-
action: string;
|
|
271
|
-
error: string;
|
|
272
|
-
initialized: boolean;
|
|
273
|
-
loading: boolean;
|
|
274
|
-
open: boolean;
|
|
275
|
-
walletOS: WalletOS;
|
|
276
|
-
user?: User;
|
|
277
|
-
locale: UserLocale;
|
|
278
|
-
provider?: WalletProvider;
|
|
279
|
-
baseUrl?: string;
|
|
280
|
-
federatedMaster?: object;
|
|
281
|
-
login: LoginSessionFn;
|
|
282
|
-
logout: LogoutSessionFn;
|
|
283
|
-
switch: Function;
|
|
284
|
-
switchDid: CommonSessionFn;
|
|
285
|
-
autoSwitchDid: Function;
|
|
286
|
-
switchProfile: CommonSessionFn;
|
|
287
|
-
switchPassport: CommonSessionFn;
|
|
288
|
-
bindWallet: CommonSessionFn;
|
|
289
|
-
refresh: Function;
|
|
290
|
-
updateConnectedInfo: (data: object) => void;
|
|
291
|
-
openDidConnect: OpenDidConnect;
|
|
292
|
-
|
|
293
|
-
useOAuth: Function;
|
|
294
|
-
OAuthProvider: Function;
|
|
295
|
-
OAuthConsumer: Function;
|
|
296
|
-
OAuthContext: object;
|
|
297
|
-
|
|
298
|
-
usePasskey: Function;
|
|
299
|
-
PasskeyProvider: Function;
|
|
300
|
-
PasskeyConsumer: Function;
|
|
301
|
-
PasskeyContext: object;
|
|
302
|
-
|
|
303
|
-
useDid: (options: { session: Session }) => void;
|
|
304
|
-
WrapDid: Function;
|
|
305
|
-
getUserSessions: () => Promise<UserSession[]>;
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
export type SessionStorageProps = {
|
|
309
|
-
getToken: Function;
|
|
310
|
-
setToken: Function;
|
|
311
|
-
removeToken: Function;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
export type SessionContext = {
|
|
315
|
-
api: AxiosInstance; // api 实例(axios)
|
|
316
|
-
events: EventEmitter; // session 事件订阅器
|
|
317
|
-
storage: SessionStorageProps; // sessionToken 的存储实例
|
|
318
|
-
session: SessionProps; // session 实例
|
|
319
|
-
connectApi: {
|
|
320
|
-
open: OpenConnect;
|
|
321
|
-
close: CloseConnect;
|
|
322
|
-
}; // use-connect 的 connectApi
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
export interface TokenState {
|
|
326
|
-
checking: boolean;
|
|
327
|
-
loading: boolean;
|
|
328
|
-
token: string;
|
|
329
|
-
url: string;
|
|
330
|
-
store: object;
|
|
331
|
-
status: 'created' | 'scanned' | 'succeed' | 'error' | 'timeout' | 'busy' | 'forbidden';
|
|
332
|
-
error: string;
|
|
333
|
-
checkCount: number;
|
|
334
|
-
mfaCode?: number;
|
|
335
|
-
appInfo: object;
|
|
336
|
-
memberAppInfo: object;
|
|
337
|
-
connectedDid: string;
|
|
338
|
-
saveConnect: boolean;
|
|
339
|
-
inExistingSession: boolean;
|
|
340
|
-
nextWorkflow?: string;
|
|
341
|
-
baseUrl: string;
|
|
342
|
-
prefix: string;
|
|
343
|
-
extraParams: object;
|
|
344
|
-
checkFn: Function;
|
|
345
|
-
results: object;
|
|
346
|
-
action: string;
|
|
347
|
-
provider: 'wallet' | 'auth0' | 'apple' | 'github' | 'google';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
export type SwitchBehavior = 'auto' | 'disabled' | 'required';
|
|
351
|
-
export type DIDConnectUrlOptions = {
|
|
352
|
-
switchBehavior: SwitchBehavior;
|
|
353
|
-
sourceAppPid: string;
|
|
354
|
-
forceConnected: boolean | string;
|
|
355
|
-
};
|