@dynamic-labs/sdk-react-core 4.18.8 → 4.19.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/CHANGELOG.md +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/utils/functions/getSessionInformationName/getSessionInformationName.cjs +10 -0
- package/src/lib/utils/functions/getSessionInformationName/getSessionInformationName.d.ts +2 -0
- package/src/lib/utils/functions/getSessionInformationName/getSessionInformationName.js +6 -0
- package/src/lib/utils/functions/getSessionInformationName/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -3
- package/src/lib/utils/hooks/useSessionKeys/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSessionKeys/useSessionKeys.cjs +140 -0
- package/src/lib/utils/hooks/useSessionKeys/useSessionKeys.d.ts +5 -0
- package/src/lib/utils/hooks/useSessionKeys/useSessionKeys.js +136 -0
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +5 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +5 -1
- package/src/lib/utils/types/SessionInformation.d.ts +25 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.cjs +24 -10
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.d.ts +5 -1
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.js +24 -10
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.cjs +4 -3
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.d.ts +3 -5
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.js +4 -3
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.cjs +8 -18
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.js +9 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.19.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.0...v4.19.1) (2025-05-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **react-native:** reload webview when disconnected ([#8765](https://github.com/dynamic-labs/dynamic-auth/issues/8765)) ([addf90b](https://github.com/dynamic-labs/dynamic-auth/commit/addf90b6fccbe4b883e9778cf7a07e0471f85318))
|
|
8
|
+
|
|
9
|
+
## [4.19.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.8...v4.19.0) (2025-05-23)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* expose 7702 kernel and add viem controller ([#8786](https://github.com/dynamic-labs/dynamic-auth/issues/8786)) ([eea710e](https://github.com/dynamic-labs/dynamic-auth/commit/eea710e238ccbc36e6be37d8f7493954b99858ef))
|
|
15
|
+
* use browser wallet client & iframe for waas operations ([#8697](https://github.com/dynamic-labs/dynamic-auth/issues/8697)) ([13a47b1](https://github.com/dynamic-labs/dynamic-auth/commit/13a47b1c9a2984f08682e833ca8c87605a3a872f))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **global-wallet:** close popup when page unloads to prevent orphaned popup windows ([#8787](https://github.com/dynamic-labs/dynamic-auth/issues/8787)) ([441b04c](https://github.com/dynamic-labs/dynamic-auth/commit/441b04ca04a02feb37473e43bca0e66c5d772ce2))
|
|
21
|
+
* override network when requesting BTC networks in useTokenBalances ([#8773](https://github.com/dynamic-labs/dynamic-auth/issues/8773)) ([fd07d09](https://github.com/dynamic-labs/dynamic-auth/commit/fd07d09de970c7e6f85b251a88854e8eca57e249))
|
|
22
|
+
* remove libmpc executor dependency global wallet ([#8792](https://github.com/dynamic-labs/dynamic-auth/issues/8792)) ([7502585](https://github.com/dynamic-labs/dynamic-auth/commit/75025859d2f952915322cf65504117ec2506152b))
|
|
23
|
+
* standardize font on headers ([#8734](https://github.com/dynamic-labs/dynamic-auth/issues/8734)) ([9f0900c](https://github.com/dynamic-labs/dynamic-auth/commit/9f0900cb7c4294201cc952ae7538648bdea83ff5))
|
|
24
|
+
|
|
2
25
|
### [4.18.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.7...v4.18.8) (2025-05-22)
|
|
3
26
|
|
|
4
27
|
### Bug Fixes
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.672",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"yup": "0.32.11",
|
|
15
15
|
"react-international-phone": "4.2.5",
|
|
16
16
|
"bs58": "5.0.0",
|
|
17
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
18
|
-
"@dynamic-labs/iconic": "4.
|
|
19
|
-
"@dynamic-labs/logger": "4.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
22
|
-
"@dynamic-labs/store": "4.
|
|
23
|
-
"@dynamic-labs/types": "4.
|
|
24
|
-
"@dynamic-labs/utils": "4.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
17
|
+
"@dynamic-labs/assert-package-version": "4.19.1",
|
|
18
|
+
"@dynamic-labs/iconic": "4.19.1",
|
|
19
|
+
"@dynamic-labs/logger": "4.19.1",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "4.19.1",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "4.19.1",
|
|
22
|
+
"@dynamic-labs/store": "4.19.1",
|
|
23
|
+
"@dynamic-labs/types": "4.19.1",
|
|
24
|
+
"@dynamic-labs/utils": "4.19.1",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.19.1",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.19.1",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var shortenWalletAddress = require('../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
7
|
+
|
|
8
|
+
const getSessionInformationName = (session) => { var _a; return (_a = session.origin) !== null && _a !== void 0 ? _a : shortenWalletAddress.shortenWalletAddress(session.sessionId); };
|
|
9
|
+
|
|
10
|
+
exports.getSessionInformationName = getSessionInformationName;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { shortenWalletAddress } from '../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
3
|
+
|
|
4
|
+
const getSessionInformationName = (session) => { var _a; return (_a = session.origin) !== null && _a !== void 0 ? _a : shortenWalletAddress(session.sessionId); };
|
|
5
|
+
|
|
6
|
+
export { getSessionInformationName };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getSessionInformationName';
|
|
@@ -10,9 +10,8 @@ export declare const useDynamicWaas: () => {
|
|
|
10
10
|
createWalletAccount: () => Promise<({
|
|
11
11
|
chainName: string;
|
|
12
12
|
accountAddress: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
publicKeyHex?: string | undefined;
|
|
13
|
+
publicKeyHex: string;
|
|
14
|
+
rawPublicKey: string | Uint8Array | undefined;
|
|
16
15
|
} | undefined)[]>;
|
|
17
16
|
dynamicWaasIsEnabled: boolean;
|
|
18
17
|
getWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSessionKeys';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
|
+
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
10
|
+
require('@dynamic-labs/sdk-api-core');
|
|
11
|
+
var logger = require('../../../shared/logger.cjs');
|
|
12
|
+
require('@dynamic-labs/iconic');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
require('react/jsx-runtime');
|
|
15
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../constants/colors.cjs');
|
|
19
|
+
require('../../constants/values.cjs');
|
|
20
|
+
require('../../../shared/consts/index.cjs');
|
|
21
|
+
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
require('react-international-phone');
|
|
26
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
27
|
+
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
28
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
+
require('../../../store/state/user/user.cjs');
|
|
30
|
+
require('../../../locale/locale.cjs');
|
|
31
|
+
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
34
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
37
|
+
require('../../../store/state/authMode/authMode.cjs');
|
|
38
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
39
|
+
require('react-dom');
|
|
40
|
+
require('../../functions/compareChains/compareChains.cjs');
|
|
41
|
+
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
42
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
43
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
44
|
+
require('bs58');
|
|
45
|
+
require('@dynamic-labs/types');
|
|
46
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
47
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
48
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
49
|
+
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
50
|
+
require('yup');
|
|
51
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
52
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
53
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
54
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
55
|
+
require('@dynamic-labs/rpc-providers');
|
|
56
|
+
require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
57
|
+
require('react-i18next');
|
|
58
|
+
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
59
|
+
require('../../../components/Alert/Alert.cjs');
|
|
60
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
62
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
63
|
+
require('../../../components/Input/Input.cjs');
|
|
64
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
65
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
66
|
+
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
67
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
68
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
69
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
70
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
71
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
72
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
73
|
+
require('react-focus-lock');
|
|
74
|
+
require('qrcode');
|
|
75
|
+
require('formik');
|
|
76
|
+
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
77
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
78
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
79
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
80
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
81
|
+
require('@hcaptcha/react-hcaptcha');
|
|
82
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
83
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
84
|
+
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
85
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
86
|
+
require('../../../store/state/sendBalances.cjs');
|
|
87
|
+
require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
88
|
+
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
89
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
90
|
+
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
91
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
92
|
+
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
93
|
+
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
94
|
+
require('../../../../index.cjs');
|
|
95
|
+
require('../../../store/state/tokenBalances.cjs');
|
|
96
|
+
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
97
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
98
|
+
|
|
99
|
+
const useSessionKeys = () => {
|
|
100
|
+
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
101
|
+
const listSessions = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
104
|
+
if (!(connector === null || connector === void 0 ? void 0 : connector.listSessions)) {
|
|
105
|
+
logger.logger.error('Connector does not support session key management');
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
logger.logger.debug('[ZkSyncConnector] listSessions');
|
|
109
|
+
try {
|
|
110
|
+
const sessions = yield connector.listSessions();
|
|
111
|
+
return sessions;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
logger.logger.error('Error fetching session keys:', error);
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}), [primaryWallet]);
|
|
118
|
+
const revokeSession = React.useCallback((sessionId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
121
|
+
if (!(connector === null || connector === void 0 ? void 0 : connector.revokeSession)) {
|
|
122
|
+
logger.logger.error('Connector does not support session key management');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
logger.logger.debug('[ZkSyncConnector] revokeSession', sessionId);
|
|
126
|
+
try {
|
|
127
|
+
yield connector.revokeSession(sessionId);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
logger.logger.error('Error revoking session:', error);
|
|
131
|
+
}
|
|
132
|
+
}), [primaryWallet]);
|
|
133
|
+
const value = React.useMemo(() => ({
|
|
134
|
+
listSessions,
|
|
135
|
+
revokeSession,
|
|
136
|
+
}), [listSessions, revokeSession]);
|
|
137
|
+
return value;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.useSessionKeys = useSessionKeys;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
6
|
+
import '@dynamic-labs/sdk-api-core';
|
|
7
|
+
import { logger } from '../../../shared/logger.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../constants/colors.js';
|
|
15
|
+
import '../../constants/values.js';
|
|
16
|
+
import '../../../shared/consts/index.js';
|
|
17
|
+
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import 'react-international-phone';
|
|
22
|
+
import '../../../store/state/nonce/nonce.js';
|
|
23
|
+
import '../../../store/state/projectSettings/projectSettings.js';
|
|
24
|
+
import '../../../config/ApiEndpoint.js';
|
|
25
|
+
import '../../../store/state/user/user.js';
|
|
26
|
+
import '../../../locale/locale.js';
|
|
27
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
30
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
|
+
import '../../../store/state/authMode/authMode.js';
|
|
34
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
35
|
+
import 'react-dom';
|
|
36
|
+
import '../../functions/compareChains/compareChains.js';
|
|
37
|
+
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
38
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
39
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
40
|
+
import 'bs58';
|
|
41
|
+
import '@dynamic-labs/types';
|
|
42
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
43
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
44
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
45
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
46
|
+
import 'yup';
|
|
47
|
+
import '../../../context/MockContext/MockContext.js';
|
|
48
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
49
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
50
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
51
|
+
import '@dynamic-labs/rpc-providers';
|
|
52
|
+
import '../../../store/state/walletOptions/walletOptions.js';
|
|
53
|
+
import 'react-i18next';
|
|
54
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
55
|
+
import '../../../components/Alert/Alert.js';
|
|
56
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
57
|
+
import '../../../components/IconButton/IconButton.js';
|
|
58
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
59
|
+
import '../../../components/Input/Input.js';
|
|
60
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
61
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
62
|
+
import '../../../components/OverlayCard/OverlayCard.js';
|
|
63
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
64
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
65
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
66
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
67
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
68
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
69
|
+
import 'react-focus-lock';
|
|
70
|
+
import 'qrcode';
|
|
71
|
+
import 'formik';
|
|
72
|
+
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
73
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
74
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
75
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
76
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
77
|
+
import '@hcaptcha/react-hcaptcha';
|
|
78
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
79
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
80
|
+
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
81
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
82
|
+
import '../../../store/state/sendBalances.js';
|
|
83
|
+
import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
84
|
+
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
85
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
86
|
+
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
87
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
88
|
+
import '../../../context/OnrampContext/OnrampContext.js';
|
|
89
|
+
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
90
|
+
import '../../../../index.js';
|
|
91
|
+
import '../../../store/state/tokenBalances.js';
|
|
92
|
+
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
93
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
94
|
+
|
|
95
|
+
const useSessionKeys = () => {
|
|
96
|
+
const { primaryWallet } = useInternalDynamicContext();
|
|
97
|
+
const listSessions = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
100
|
+
if (!(connector === null || connector === void 0 ? void 0 : connector.listSessions)) {
|
|
101
|
+
logger.error('Connector does not support session key management');
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
logger.debug('[ZkSyncConnector] listSessions');
|
|
105
|
+
try {
|
|
106
|
+
const sessions = yield connector.listSessions();
|
|
107
|
+
return sessions;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
logger.error('Error fetching session keys:', error);
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
}), [primaryWallet]);
|
|
114
|
+
const revokeSession = useCallback((sessionId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
117
|
+
if (!(connector === null || connector === void 0 ? void 0 : connector.revokeSession)) {
|
|
118
|
+
logger.error('Connector does not support session key management');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
logger.debug('[ZkSyncConnector] revokeSession', sessionId);
|
|
122
|
+
try {
|
|
123
|
+
yield connector.revokeSession(sessionId);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
logger.error('Error revoking session:', error);
|
|
127
|
+
}
|
|
128
|
+
}), [primaryWallet]);
|
|
129
|
+
const value = useMemo(() => ({
|
|
130
|
+
listSessions,
|
|
131
|
+
revokeSession,
|
|
132
|
+
}), [listSessions, revokeSession]);
|
|
133
|
+
return value;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export { useSessionKeys };
|
|
@@ -124,7 +124,11 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
124
124
|
// the reason why we need to get the network here again insteaf of using the value
|
|
125
125
|
// from DynamicContext is because this function might run before the network state is
|
|
126
126
|
// properly set when switching wallets, so we want to make sure we have the latest network
|
|
127
|
-
|
|
127
|
+
let requestNetwork = networkId !== null && networkId !== void 0 ? networkId : (yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(true)));
|
|
128
|
+
if (requestChainName === sdkApiCore.ChainEnum.Btc) {
|
|
129
|
+
// Bitcoin does not need a network ID to fetch token balances but the request requires a network ID
|
|
130
|
+
requestNetwork = 1;
|
|
131
|
+
}
|
|
128
132
|
const isValidRequest = requestNetwork && !isNaN(Number(requestNetwork));
|
|
129
133
|
logger.logger.logVerboseTroubleshootingMessage('[useTokenBalances] will try to fetch token balances', {
|
|
130
134
|
isLoading,
|
|
@@ -120,7 +120,11 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm
|
|
|
120
120
|
// the reason why we need to get the network here again insteaf of using the value
|
|
121
121
|
// from DynamicContext is because this function might run before the network state is
|
|
122
122
|
// properly set when switching wallets, so we want to make sure we have the latest network
|
|
123
|
-
|
|
123
|
+
let requestNetwork = networkId !== null && networkId !== void 0 ? networkId : (yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(true)));
|
|
124
|
+
if (requestChainName === ChainEnum.Btc) {
|
|
125
|
+
// Bitcoin does not need a network ID to fetch token balances but the request requires a network ID
|
|
126
|
+
requestNetwork = 1;
|
|
127
|
+
}
|
|
124
128
|
const isValidRequest = requestNetwork && !isNaN(Number(requestNetwork));
|
|
125
129
|
logger.logVerboseTroubleshootingMessage('[useTokenBalances] will try to fetch token balances', {
|
|
126
130
|
isLoading,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SessionInformation = {
|
|
2
|
+
blockNumber: bigint;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
session: SessionConfig;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
transactionHash: string;
|
|
7
|
+
origin?: string;
|
|
8
|
+
};
|
|
9
|
+
export type SessionConfig = {
|
|
10
|
+
signer: string;
|
|
11
|
+
expiresAt: bigint;
|
|
12
|
+
feeLimit: Limit;
|
|
13
|
+
callPolicies: unknown[];
|
|
14
|
+
transferPolicies: unknown[];
|
|
15
|
+
};
|
|
16
|
+
export type Limit = {
|
|
17
|
+
limitType: LimitType;
|
|
18
|
+
limit: bigint;
|
|
19
|
+
period: bigint;
|
|
20
|
+
};
|
|
21
|
+
export declare enum LimitType {
|
|
22
|
+
Unlimited = 0,
|
|
23
|
+
Lifetime = 1,
|
|
24
|
+
Allowance = 2
|
|
25
|
+
}
|
|
@@ -20,7 +20,7 @@ export declare const mapViewToComponent: {
|
|
|
20
20
|
'send-balance': import("react").FC;
|
|
21
21
|
'session-management': import("react").FC<import("../../views/SessionManagementView").SessionManagementViewProps>;
|
|
22
22
|
'session-management-info': import("react").FC;
|
|
23
|
-
'session-management-revoke-access': import("react").FC
|
|
23
|
+
'session-management-revoke-access': import("react").FC<import("../../views/SessionManagementView/RevokeAccessView").RevokeAccessViewProps>;
|
|
24
24
|
settings: import("react").FC;
|
|
25
25
|
wallets: import("react").FC;
|
|
26
26
|
};
|
|
@@ -172,7 +172,7 @@ const ConnectedAppsView = ({ name }) => {
|
|
|
172
172
|
logger.logger.warn('Error disconnecting app', error);
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
return (jsxRuntime.jsxs("div", { className: 'connected-apps-view', children: [jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, { className: 'arrow-left-icon' }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title',
|
|
175
|
+
return (jsxRuntime.jsxs("div", { className: 'connected-apps-view', children: [jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, { className: 'arrow-left-icon' }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', className: 'title', children: t('global_wallet.connected_apps.title') })] }), jsxRuntime.jsx("div", { className: 'subheader', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'medium', color: 'primary', className: 'title', children: t('global_wallet.connected_apps.subtitle') }) }), connectedApps.length > 0 && (jsxRuntime.jsx("ul", { className: 'connected-apps-list', children: connectedApps.map((app) => (jsxRuntime.jsxs("li", { className: 'connected-app-item', children: [jsxRuntime.jsx("img", { src: app.icon, alt: app.name, className: 'app-icon' }), jsxRuntime.jsx("div", { className: 'app-info', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: app.url }) }), jsxRuntime.jsxs("div", { className: 'app-actions', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => utils.PlatformService.openURL(app.url, 'blank'), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsxRuntime.jsx(externalLink.ReactComponent, {}), typographyProps: {
|
|
176
176
|
color: 'secondary',
|
|
177
177
|
variant: 'button_secondary',
|
|
178
178
|
}, dataTestId: 'open-app-button' }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => handleDisconnect(app.topic), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsxRuntime.jsx(unlink.ReactComponent, {}), typographyProps: {
|
|
@@ -168,7 +168,7 @@ const ConnectedAppsView = ({ name }) => {
|
|
|
168
168
|
logger.warn('Error disconnecting app', error);
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
|
-
return (jsxs("div", { className: 'connected-apps-view', children: [jsxs("div", { className: 'header', children: [jsx(IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsx(SvgArrowLeft, { className: 'arrow-left-icon' }) }), jsx(Typography, { variant: 'title',
|
|
171
|
+
return (jsxs("div", { className: 'connected-apps-view', children: [jsxs("div", { className: 'header', children: [jsx(IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsx(SvgArrowLeft, { className: 'arrow-left-icon' }) }), jsx(Typography, { variant: 'title', color: 'primary', className: 'title', children: t('global_wallet.connected_apps.title') })] }), jsx("div", { className: 'subheader', children: jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'primary', className: 'title', children: t('global_wallet.connected_apps.subtitle') }) }), connectedApps.length > 0 && (jsx("ul", { className: 'connected-apps-list', children: connectedApps.map((app) => (jsxs("li", { className: 'connected-app-item', children: [jsx("img", { src: app.icon, alt: app.name, className: 'app-icon' }), jsx("div", { className: 'app-info', children: jsx(Typography, { variant: 'body_normal', color: 'primary', children: app.url }) }), jsxs("div", { className: 'app-actions', children: [jsx(TypographyButton, { onClick: () => PlatformService.openURL(app.url, 'blank'), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsx(SvgExternalLink, {}), typographyProps: {
|
|
172
172
|
color: 'secondary',
|
|
173
173
|
variant: 'button_secondary',
|
|
174
174
|
}, dataTestId: 'open-app-button' }), jsx(TypographyButton, { onClick: () => handleDisconnect(app.topic), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsx(SvgUnlink, {}), typographyProps: {
|
|
@@ -228,7 +228,7 @@ const GlobalWalletView = () => {
|
|
|
228
228
|
}
|
|
229
229
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
230
230
|
}, [walletConnectUri]);
|
|
231
|
-
const renderHeader = () => (jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: goToInitialDynamicWidgetView, "data-testid": 'back-button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title',
|
|
231
|
+
const renderHeader = () => (jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: goToInitialDynamicWidgetView, "data-testid": 'back-button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', as: 'h1', copykey: 'global_wallet.connect_to_apps', children: t('global_wallet.connect_to_apps') }), utils.isMobile() && (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: () => {
|
|
232
232
|
pushView('global-wallet-info');
|
|
233
233
|
setShowAuthFlow(true, {
|
|
234
234
|
ignoreIfIsEmbeddedWidget: false,
|
|
@@ -224,7 +224,7 @@ const GlobalWalletView = () => {
|
|
|
224
224
|
}
|
|
225
225
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
226
226
|
}, [walletConnectUri]);
|
|
227
|
-
const renderHeader = () => (jsxs("div", { className: 'header', children: [jsx(IconButton, { type: 'button', onClick: goToInitialDynamicWidgetView, "data-testid": 'back-button', children: jsx(SvgArrowLeft, {}) }), jsx(Typography, { variant: 'title',
|
|
227
|
+
const renderHeader = () => (jsxs("div", { className: 'header', children: [jsx(IconButton, { type: 'button', onClick: goToInitialDynamicWidgetView, "data-testid": 'back-button', children: jsx(SvgArrowLeft, {}) }), jsx(Typography, { variant: 'title', color: 'primary', as: 'h1', copykey: 'global_wallet.connect_to_apps', children: t('global_wallet.connect_to_apps') }), isMobile() && (jsx(IconButton, { type: 'button', onClick: () => {
|
|
228
228
|
pushView('global-wallet-info');
|
|
229
229
|
setShowAuthFlow(true, {
|
|
230
230
|
ignoreIfIsEmbeddedWidget: false,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../../../../../_virtual/_tslib.cjs');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var reactI18next = require('react-i18next');
|
|
8
9
|
var ModalHeader = require('../../../../../components/ModalHeader/ModalHeader.cjs');
|
|
@@ -14,22 +15,35 @@ var close = require('../../../../../shared/assets/close.cjs');
|
|
|
14
15
|
require('@dynamic-labs/iconic');
|
|
15
16
|
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
16
17
|
var TypographyButton = require('../../../../../components/TypographyButton/TypographyButton.cjs');
|
|
18
|
+
var useSessionKeys = require('../../../../../utils/hooks/useSessionKeys/useSessionKeys.cjs');
|
|
19
|
+
var getSessionInformationName = require('../../../../../utils/functions/getSessionInformationName/getSessionInformationName.cjs');
|
|
17
20
|
|
|
18
|
-
const RevokeAccessView = () => {
|
|
21
|
+
const RevokeAccessView = ({ session }) => {
|
|
19
22
|
const { t } = reactI18next.useTranslation();
|
|
20
23
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
24
|
+
const { revokeSession } = useSessionKeys.useSessionKeys();
|
|
21
25
|
const handleCancel = () => {
|
|
22
26
|
setDynamicWidgetView('session-management');
|
|
23
27
|
};
|
|
24
|
-
const handleRevoke = () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const handleRevoke = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
yield revokeSession(session.sessionId);
|
|
31
|
+
setDynamicWidgetView('session-management', {
|
|
32
|
+
bannerMessage: {
|
|
33
|
+
message: `Revoked ${getSessionInformationName.getSessionInformationName(session)}`,
|
|
34
|
+
type: 'success',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
setDynamicWidgetView('session-management', {
|
|
40
|
+
bannerMessage: {
|
|
41
|
+
message: `Failed to revoke ${getSessionInformationName.getSessionInformationName(session)}`,
|
|
42
|
+
type: 'error',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
33
47
|
const renderCloseButton = () => (jsxRuntime.jsx(IconButton.IconButton, { onClick: handleCancel, "aria-label": t('dyn_session_management.aria.close_button_label'), children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
34
48
|
return (jsxRuntime.jsxs("div", { className: 'revoke-access-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: renderCloseButton(), children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.title', children: t('dyn_session_management.revoke_access_view.title') }) }), jsxRuntime.jsx("div", { className: 'revoke-access-view__body', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.description', align: 'center', children: t('dyn_session_management.revoke_access_view.description') }) }), jsxRuntime.jsxs("div", { className: 'revoke-access-view__footer', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'danger', buttonPadding: 'small', onClick: handleRevoke, dataTestId: 'revoke-access-confirm-button', copykey: 'dyn_session_management.revoke_access_view.revoke_button', expanded: true, children: t('dyn_session_management.revoke_access_view.revoke_button') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'small', onClick: handleCancel, dataTestId: 'revoke-access-cancel-button', copykey: 'dyn_session_management.revoke_access_view.cancel_button', expanded: true, children: t('dyn_session_management.revoke_access_view.cancel_button') })] })] }));
|
|
35
49
|
};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
2
|
+
import { SessionInformation } from '../../../../../utils/types/SessionInformation';
|
|
3
|
+
export interface RevokeAccessViewProps {
|
|
4
|
+
session: SessionInformation;
|
|
5
|
+
}
|
|
6
|
+
export declare const RevokeAccessView: FC<RevokeAccessViewProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
2
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { ModalHeader } from '../../../../../components/ModalHeader/ModalHeader.js';
|
|
@@ -10,22 +11,35 @@ import { ReactComponent as SvgClose } from '../../../../../shared/assets/close.j
|
|
|
10
11
|
import '@dynamic-labs/iconic';
|
|
11
12
|
import '../../../../../context/ViewContext/ViewContext.js';
|
|
12
13
|
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
14
|
+
import { useSessionKeys } from '../../../../../utils/hooks/useSessionKeys/useSessionKeys.js';
|
|
15
|
+
import { getSessionInformationName } from '../../../../../utils/functions/getSessionInformationName/getSessionInformationName.js';
|
|
13
16
|
|
|
14
|
-
const RevokeAccessView = () => {
|
|
17
|
+
const RevokeAccessView = ({ session }) => {
|
|
15
18
|
const { t } = useTranslation();
|
|
16
19
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
20
|
+
const { revokeSession } = useSessionKeys();
|
|
17
21
|
const handleCancel = () => {
|
|
18
22
|
setDynamicWidgetView('session-management');
|
|
19
23
|
};
|
|
20
|
-
const handleRevoke = () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const handleRevoke = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
yield revokeSession(session.sessionId);
|
|
27
|
+
setDynamicWidgetView('session-management', {
|
|
28
|
+
bannerMessage: {
|
|
29
|
+
message: `Revoked ${getSessionInformationName(session)}`,
|
|
30
|
+
type: 'success',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
setDynamicWidgetView('session-management', {
|
|
36
|
+
bannerMessage: {
|
|
37
|
+
message: `Failed to revoke ${getSessionInformationName(session)}`,
|
|
38
|
+
type: 'error',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
29
43
|
const renderCloseButton = () => (jsx(IconButton, { onClick: handleCancel, "aria-label": t('dyn_session_management.aria.close_button_label'), children: jsx(SvgClose, {}) }));
|
|
30
44
|
return (jsxs("div", { className: 'revoke-access-view', children: [jsx(ModalHeader, { trailing: renderCloseButton(), children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.title', children: t('dyn_session_management.revoke_access_view.title') }) }), jsx("div", { className: 'revoke-access-view__body', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.description', align: 'center', children: t('dyn_session_management.revoke_access_view.description') }) }), jsxs("div", { className: 'revoke-access-view__footer', children: [jsx(TypographyButton, { buttonVariant: 'danger', buttonPadding: 'small', onClick: handleRevoke, dataTestId: 'revoke-access-confirm-button', copykey: 'dyn_session_management.revoke_access_view.revoke_button', expanded: true, children: t('dyn_session_management.revoke_access_view.revoke_button') }), jsx(TypographyButton, { buttonPadding: 'small', onClick: handleCancel, dataTestId: 'revoke-access-cancel-button', copykey: 'dyn_session_management.revoke_access_view.cancel_button', expanded: true, children: t('dyn_session_management.revoke_access_view.cancel_button') })] })] }));
|
|
31
45
|
};
|
|
@@ -12,17 +12,18 @@ var IconButton = require('../../../../../components/IconButton/IconButton.cjs');
|
|
|
12
12
|
var chevronDown = require('../../../../../shared/assets/chevron-down.cjs');
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var getSessionInformationName = require('../../../../../utils/functions/getSessionInformationName/getSessionInformationName.cjs');
|
|
15
16
|
|
|
16
17
|
const SessionListItem = ({ session, onRevokeAccessClick, }) => {
|
|
17
18
|
const { t } = reactI18next.useTranslation();
|
|
18
19
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
19
20
|
const handleRevokeAccess = React.useCallback(() => {
|
|
20
|
-
onRevokeAccessClick(session
|
|
21
|
-
}, [onRevokeAccessClick, session
|
|
21
|
+
onRevokeAccessClick(session);
|
|
22
|
+
}, [onRevokeAccessClick, session]);
|
|
22
23
|
const toggleExpanded = React.useCallback(() => {
|
|
23
24
|
setIsExpanded((prev) => !prev);
|
|
24
25
|
}, []);
|
|
25
|
-
return (jsxRuntime.jsxs("div", { className: 'session-management-session', children: [jsxRuntime.jsxs("div", { className: 'session-management-session__main', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', children: session
|
|
26
|
+
return (jsxRuntime.jsxs("div", { className: 'session-management-session', children: [jsxRuntime.jsxs("div", { className: 'session-management-session__main', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', children: getSessionInformationName.getSessionInformationName(session) }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: handleRevokeAccess, children: t('dyn_session_management.session_component.revoke_button') })] }), jsxRuntime.jsxs("div", { className: 'session-management-session__permissions-toggle', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', children: t('dyn_session_management.session_component.permission_details') }), jsxRuntime.jsx(IconButton.IconButton, { onClick: toggleExpanded, "aria-label": t(isExpanded
|
|
26
27
|
? 'dyn_session_management.session_component.aria.collapse_permissions'
|
|
27
28
|
: 'dyn_session_management.session_component.aria.expand_permissions'), className: 'session-management-session__icon-button', children: jsxRuntime.jsx(chevronDown.ReactComponent, {}) })] }), isExpanded && (jsxRuntime.jsx("div", { className: 'session-management-session__permissions', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', children: "TODO: Add permission details" }) }))] }));
|
|
28
29
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { SessionInformation } from '../../../../../utils/types/SessionInformation';
|
|
2
3
|
interface SessionListItemProps {
|
|
3
|
-
session:
|
|
4
|
-
|
|
5
|
-
site?: string;
|
|
6
|
-
};
|
|
7
|
-
onRevokeAccessClick: (sessionId: string) => void;
|
|
4
|
+
session: SessionInformation;
|
|
5
|
+
onRevokeAccessClick: (session: SessionInformation) => void;
|
|
8
6
|
}
|
|
9
7
|
export declare const SessionListItem: FC<SessionListItemProps>;
|
|
10
8
|
export {};
|
package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.js
CHANGED
|
@@ -8,17 +8,18 @@ import { IconButton } from '../../../../../components/IconButton/IconButton.js';
|
|
|
8
8
|
import { ReactComponent as SvgChevronDown } from '../../../../../shared/assets/chevron-down.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
10
10
|
import '../../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { getSessionInformationName } from '../../../../../utils/functions/getSessionInformationName/getSessionInformationName.js';
|
|
11
12
|
|
|
12
13
|
const SessionListItem = ({ session, onRevokeAccessClick, }) => {
|
|
13
14
|
const { t } = useTranslation();
|
|
14
15
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
15
16
|
const handleRevokeAccess = useCallback(() => {
|
|
16
|
-
onRevokeAccessClick(session
|
|
17
|
-
}, [onRevokeAccessClick, session
|
|
17
|
+
onRevokeAccessClick(session);
|
|
18
|
+
}, [onRevokeAccessClick, session]);
|
|
18
19
|
const toggleExpanded = useCallback(() => {
|
|
19
20
|
setIsExpanded((prev) => !prev);
|
|
20
21
|
}, []);
|
|
21
|
-
return (jsxs("div", { className: 'session-management-session', children: [jsxs("div", { className: 'session-management-session__main', children: [jsx(Typography, { variant: 'body_normal', children: session
|
|
22
|
+
return (jsxs("div", { className: 'session-management-session', children: [jsxs("div", { className: 'session-management-session__main', children: [jsx(Typography, { variant: 'body_normal', children: getSessionInformationName(session) }), jsx(TypographyButton, { onClick: handleRevokeAccess, children: t('dyn_session_management.session_component.revoke_button') })] }), jsxs("div", { className: 'session-management-session__permissions-toggle', children: [jsx(Typography, { variant: 'body_small', children: t('dyn_session_management.session_component.permission_details') }), jsx(IconButton, { onClick: toggleExpanded, "aria-label": t(isExpanded
|
|
22
23
|
? 'dyn_session_management.session_component.aria.collapse_permissions'
|
|
23
24
|
: 'dyn_session_management.session_component.aria.expand_permissions'), className: 'session-management-session__icon-button', children: jsx(SvgChevronDown, {}) })] }), isExpanded && (jsx("div", { className: 'session-management-session__permissions', children: jsx(Typography, { variant: 'body_small', weight: 'bold', children: "TODO: Add permission details" }) }))] }));
|
|
24
25
|
};
|
|
@@ -15,37 +15,27 @@ var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
|
15
15
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
16
16
|
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
17
17
|
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
18
|
+
var useSessionKeys = require('../../../../utils/hooks/useSessionKeys/useSessionKeys.cjs');
|
|
18
19
|
var EmptySessionsView = require('./EmptySessionsView/EmptySessionsView.cjs');
|
|
19
20
|
var SessionListItem = require('./SessionListItem/SessionListItem.cjs');
|
|
20
21
|
|
|
21
22
|
const SessionManagementView = ({ bannerMessage, }) => {
|
|
22
23
|
const { t } = reactI18next.useTranslation();
|
|
23
24
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
site: 'app.lumfi.xyz',
|
|
30
|
-
url: 'https://app.lumfi.xyz',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
34
|
-
permissions: [],
|
|
35
|
-
sessionId: '2',
|
|
36
|
-
site: 'app.sophon.xyz',
|
|
37
|
-
url: 'https://app.sophon.xyz',
|
|
38
|
-
},
|
|
39
|
-
], []);
|
|
25
|
+
const { listSessions } = useSessionKeys.useSessionKeys();
|
|
26
|
+
const [sessions, setSessions] = React.useState([]);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
listSessions().then(setSessions);
|
|
29
|
+
}, [listSessions]);
|
|
40
30
|
const handleBackButtonClick = React.useCallback(() => {
|
|
41
31
|
setDynamicWidgetView('account-and-security-settings');
|
|
42
32
|
}, [setDynamicWidgetView]);
|
|
43
33
|
const handleInfoButtonClick = React.useCallback(() => {
|
|
44
34
|
setDynamicWidgetView('session-management-info');
|
|
45
35
|
}, [setDynamicWidgetView]);
|
|
46
|
-
const handleRevokeAccessClick = React.useCallback((
|
|
36
|
+
const handleRevokeAccessClick = React.useCallback((session) => {
|
|
47
37
|
setDynamicWidgetView('session-management-revoke-access', {
|
|
48
|
-
|
|
38
|
+
session,
|
|
49
39
|
});
|
|
50
40
|
}, [setDynamicWidgetView]);
|
|
51
41
|
const renderBackButton = () => (jsxRuntime.jsx(IconButton.IconButton, { onClick: handleBackButtonClick, "aria-label": t('dyn_session_management.aria.back_button_label'), children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
6
6
|
import { ReactComponent as SvgFooterInfoIcon } from '../../../../shared/assets/footer-info-icon.js';
|
|
@@ -11,37 +11,27 @@ import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
|
11
11
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
12
12
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
13
13
|
import { ErrorContainer } from '../../../../components/ErrorContainer/ErrorContainer.js';
|
|
14
|
+
import { useSessionKeys } from '../../../../utils/hooks/useSessionKeys/useSessionKeys.js';
|
|
14
15
|
import { EmptySessionsView } from './EmptySessionsView/EmptySessionsView.js';
|
|
15
16
|
import { SessionListItem } from './SessionListItem/SessionListItem.js';
|
|
16
17
|
|
|
17
18
|
const SessionManagementView = ({ bannerMessage, }) => {
|
|
18
19
|
const { t } = useTranslation();
|
|
19
20
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
site: 'app.lumfi.xyz',
|
|
26
|
-
url: 'https://app.lumfi.xyz',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
30
|
-
permissions: [],
|
|
31
|
-
sessionId: '2',
|
|
32
|
-
site: 'app.sophon.xyz',
|
|
33
|
-
url: 'https://app.sophon.xyz',
|
|
34
|
-
},
|
|
35
|
-
], []);
|
|
21
|
+
const { listSessions } = useSessionKeys();
|
|
22
|
+
const [sessions, setSessions] = useState([]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
listSessions().then(setSessions);
|
|
25
|
+
}, [listSessions]);
|
|
36
26
|
const handleBackButtonClick = useCallback(() => {
|
|
37
27
|
setDynamicWidgetView('account-and-security-settings');
|
|
38
28
|
}, [setDynamicWidgetView]);
|
|
39
29
|
const handleInfoButtonClick = useCallback(() => {
|
|
40
30
|
setDynamicWidgetView('session-management-info');
|
|
41
31
|
}, [setDynamicWidgetView]);
|
|
42
|
-
const handleRevokeAccessClick = useCallback((
|
|
32
|
+
const handleRevokeAccessClick = useCallback((session) => {
|
|
43
33
|
setDynamicWidgetView('session-management-revoke-access', {
|
|
44
|
-
|
|
34
|
+
session,
|
|
45
35
|
});
|
|
46
36
|
}, [setDynamicWidgetView]);
|
|
47
37
|
const renderBackButton = () => (jsx(IconButton, { onClick: handleBackButtonClick, "aria-label": t('dyn_session_management.aria.back_button_label'), children: jsx(SvgChevronLeft, {}) }));
|