@dynamic-labs/sdk-react-core 3.1.3 → 3.2.0
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 +25 -1
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +11 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +12 -2
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +15 -8
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +15 -8
- package/src/lib/locale/en/translation.cjs +43 -24
- package/src/lib/locale/en/translation.d.ts +43 -24
- package/src/lib/locale/en/translation.js +43 -24
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +5 -5
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +5 -5
- package/src/lib/shared/assets/connected-apps.cjs +64 -0
- package/src/lib/shared/assets/connected-apps.js +40 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs +24 -0
- package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js +20 -0
- package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +3 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +5 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +5 -3
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +9 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +10 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +9 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +10 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +0 -14
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +0 -14
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.cjs +4 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.js +4 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +8 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +9 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +19 -14
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.js +4 -1
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.cjs +180 -0
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.d.ts +12 -0
- package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.js +175 -0
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +7 -9
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +7 -9
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +17 -8
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +17 -8
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
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('../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var arrowLeft = require('../../../../shared/assets/arrow-left.cjs');
|
|
16
|
+
var check = require('../../../../shared/assets/check.cjs');
|
|
17
|
+
var externalLink = require('../../../../shared/assets/externalLink.cjs');
|
|
18
|
+
var unlink = require('../../../../shared/assets/unlink.cjs');
|
|
19
|
+
require('@dynamic-labs/wallet-book');
|
|
20
|
+
require('@dynamic-labs/utils');
|
|
21
|
+
require('../../../../utils/constants/colors.cjs');
|
|
22
|
+
require('../../../../utils/constants/values.cjs');
|
|
23
|
+
require('../../../../store/state/loadingAndLifecycle.cjs');
|
|
24
|
+
require('../../../../shared/consts/index.cjs');
|
|
25
|
+
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
26
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
27
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
28
|
+
var useDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
|
|
29
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
30
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
31
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
32
|
+
require('@dynamic-labs/multi-wallet');
|
|
33
|
+
require('react-international-phone');
|
|
34
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
35
|
+
require('../../../../store/state/user/user.cjs');
|
|
36
|
+
require('../../../../locale/locale.cjs');
|
|
37
|
+
require('../../../../store/state/projectSettings/projectSettings.cjs');
|
|
38
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
39
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
40
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
41
|
+
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
42
|
+
require('react-dom');
|
|
43
|
+
require('../../../../context/WalletContext/WalletContext.cjs');
|
|
44
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
45
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
46
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
47
|
+
require('@dynamic-labs/types');
|
|
48
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
49
|
+
require('yup');
|
|
50
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
51
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
52
|
+
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
53
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
54
|
+
require('@dynamic-labs/rpc-providers');
|
|
55
|
+
require('../../../../store/state/environmentId.cjs');
|
|
56
|
+
require('../../../../store/state/walletConnectorOptions.cjs');
|
|
57
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
58
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
59
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
60
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
61
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
62
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
63
|
+
require('../../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
64
|
+
require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
65
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
66
|
+
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
67
|
+
require('react-focus-lock');
|
|
68
|
+
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
69
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
70
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
71
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
72
|
+
require('formik');
|
|
73
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
74
|
+
require('../../../../components/Input/Input.cjs');
|
|
75
|
+
require('../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
76
|
+
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
77
|
+
require('../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
78
|
+
require('../../../../../polyfills.cjs');
|
|
79
|
+
require('../../../../context/ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
80
|
+
require('../../../../context/ErrorBoundary/ErrorBoundaryContext.cjs');
|
|
81
|
+
require('../../../DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
82
|
+
require('../../components/DynamicWidgetCard/DynamicWidgetCard.cjs');
|
|
83
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
84
|
+
require('../../../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
85
|
+
require('../../../../context/FundingContext/FundingContext.cjs');
|
|
86
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
87
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
88
|
+
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
89
|
+
require('@hcaptcha/react-hcaptcha');
|
|
90
|
+
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
91
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
92
|
+
require('../../../../context/SendBalanceContext/SendBalanceContext.cjs');
|
|
93
|
+
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
94
|
+
require('../../../../context/ConnectWithOtpContext/constants.cjs');
|
|
95
|
+
require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
96
|
+
require('../../../../store/state/tokenBalances.cjs');
|
|
97
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
98
|
+
require('qrcode');
|
|
99
|
+
|
|
100
|
+
const ConnectedAppsView = ({ name, }) => {
|
|
101
|
+
var _a;
|
|
102
|
+
const { t } = reactI18next.useTranslation();
|
|
103
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
104
|
+
const { primaryWallet } = useDynamicContext.useDynamicContext();
|
|
105
|
+
const [connectedApps, setConnectedApps] = React.useState([]);
|
|
106
|
+
const [refreshing, setRefreshing] = React.useState(false);
|
|
107
|
+
const [showSuccessMessage, setShowSuccessMessage] = React.useState(false);
|
|
108
|
+
const { globalWallet } = (_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
const fetchConnectedApps = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
+
try {
|
|
112
|
+
// poll for 3 seconds for the global wallet to load
|
|
113
|
+
const pollForSessions = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
const startTime = Date.now();
|
|
115
|
+
while (Date.now() - startTime < 3000) {
|
|
116
|
+
try {
|
|
117
|
+
const sessions = yield globalWallet.getConnectedWCSessions();
|
|
118
|
+
if (sessions !== undefined) {
|
|
119
|
+
return sessions;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
// ignore polling error waiting for global wallet to load
|
|
124
|
+
}
|
|
125
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
126
|
+
}
|
|
127
|
+
logger.logger.warn('Timeout waiting for sessions');
|
|
128
|
+
return undefined;
|
|
129
|
+
});
|
|
130
|
+
const sessions = yield pollForSessions();
|
|
131
|
+
// when a user logs out on dapp side, refresh the connected apps
|
|
132
|
+
globalWallet.getWeb3Wallet().on('session_delete', () => setRefreshing(!refreshing));
|
|
133
|
+
if (sessions) {
|
|
134
|
+
const apps = Object.values(sessions).map((session) => ({
|
|
135
|
+
icon: session.peer.metadata.icons[0] || '',
|
|
136
|
+
name: session.peer.metadata.name,
|
|
137
|
+
topic: session.topic,
|
|
138
|
+
url: session.peer.metadata.url,
|
|
139
|
+
}));
|
|
140
|
+
setConnectedApps(apps);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
logger.logger.warn('Error fetching connected apps', error);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
fetchConnectedApps();
|
|
148
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
149
|
+
}, [primaryWallet, refreshing]);
|
|
150
|
+
React.useEffect(() => {
|
|
151
|
+
if (name) {
|
|
152
|
+
setShowSuccessMessage(true);
|
|
153
|
+
const timer = setTimeout(() => {
|
|
154
|
+
setShowSuccessMessage(false);
|
|
155
|
+
}, 3000);
|
|
156
|
+
return () => clearTimeout(timer);
|
|
157
|
+
}
|
|
158
|
+
else
|
|
159
|
+
return;
|
|
160
|
+
}, [name]);
|
|
161
|
+
const handleDisconnect = (topic) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
+
try {
|
|
163
|
+
yield globalWallet.disconnectWCSession(topic);
|
|
164
|
+
setRefreshing(!refreshing);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
logger.logger.warn('Error disconnecting app', error);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
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', weight: 'medium', 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: () => window.open(app.url, '_blank'), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsxRuntime.jsx(externalLink.ReactComponent, {}), typographyProps: {
|
|
171
|
+
color: 'secondary',
|
|
172
|
+
variant: 'button_secondary',
|
|
173
|
+
} }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => handleDisconnect(app.topic), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsxRuntime.jsx(unlink.ReactComponent, {}), typographyProps: {
|
|
174
|
+
color: 'secondary',
|
|
175
|
+
variant: 'button_secondary',
|
|
176
|
+
} })] })] }, app.url))) })), showSuccessMessage && (jsxRuntime.jsxs("div", { className: 'success-message', children: [jsxRuntime.jsx(check.ReactComponent, {}), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'primary', children: t('global_wallet.connected_apps.success', { name }) })] }))] }));
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
exports.ConnectedAppsView = ConnectedAppsView;
|
|
180
|
+
exports["default"] = ConnectedAppsView;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ConnectedApp {
|
|
3
|
+
name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
topic: string;
|
|
7
|
+
}
|
|
8
|
+
export type ConnectedAppsViewProps = {
|
|
9
|
+
name?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ConnectedAppsView: React.FC<ConnectedAppsViewProps>;
|
|
12
|
+
export default ConnectedAppsView;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
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 '../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { ReactComponent as SvgArrowLeft } from '../../../../shared/assets/arrow-left.js';
|
|
12
|
+
import { ReactComponent as SvgCheck } from '../../../../shared/assets/check.js';
|
|
13
|
+
import { ReactComponent as SvgExternalLink } from '../../../../shared/assets/externalLink.js';
|
|
14
|
+
import { ReactComponent as SvgUnlink } from '../../../../shared/assets/unlink.js';
|
|
15
|
+
import '@dynamic-labs/wallet-book';
|
|
16
|
+
import '@dynamic-labs/utils';
|
|
17
|
+
import '../../../../utils/constants/colors.js';
|
|
18
|
+
import '../../../../utils/constants/values.js';
|
|
19
|
+
import '../../../../store/state/loadingAndLifecycle.js';
|
|
20
|
+
import '../../../../shared/consts/index.js';
|
|
21
|
+
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
22
|
+
import '../../../../components/Alert/Alert.js';
|
|
23
|
+
import '../../../../events/dynamicEvents.js';
|
|
24
|
+
import { useDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
|
|
25
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
26
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
27
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
28
|
+
import '@dynamic-labs/multi-wallet';
|
|
29
|
+
import 'react-international-phone';
|
|
30
|
+
import '../../../../config/ApiEndpoint.js';
|
|
31
|
+
import '../../../../store/state/user/user.js';
|
|
32
|
+
import '../../../../locale/locale.js';
|
|
33
|
+
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
34
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
36
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
37
|
+
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
38
|
+
import 'react-dom';
|
|
39
|
+
import '../../../../context/WalletContext/WalletContext.js';
|
|
40
|
+
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
41
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
42
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
43
|
+
import '@dynamic-labs/types';
|
|
44
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
45
|
+
import 'yup';
|
|
46
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
47
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
48
|
+
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
49
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
50
|
+
import '@dynamic-labs/rpc-providers';
|
|
51
|
+
import '../../../../store/state/environmentId.js';
|
|
52
|
+
import '../../../../store/state/walletConnectorOptions.js';
|
|
53
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
54
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
55
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
56
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
57
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
58
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
59
|
+
import '../../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
60
|
+
import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
61
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
62
|
+
import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
63
|
+
import 'react-focus-lock';
|
|
64
|
+
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
65
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
66
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
67
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
68
|
+
import 'formik';
|
|
69
|
+
import '../../../../store/state/sendBalances.js';
|
|
70
|
+
import '../../../../components/Input/Input.js';
|
|
71
|
+
import '../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
72
|
+
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
73
|
+
import '../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
74
|
+
import '../../../../../polyfills.js';
|
|
75
|
+
import '../../../../context/ErrorBoundary/ErrorBoundaryBase.js';
|
|
76
|
+
import '../../../../context/ErrorBoundary/ErrorBoundaryContext.js';
|
|
77
|
+
import '../../../DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
78
|
+
import '../../components/DynamicWidgetCard/DynamicWidgetCard.js';
|
|
79
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
80
|
+
import '../../../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
81
|
+
import '../../../../context/FundingContext/FundingContext.js';
|
|
82
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
83
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
84
|
+
import '../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
85
|
+
import '@hcaptcha/react-hcaptcha';
|
|
86
|
+
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
87
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
88
|
+
import '../../../../context/SendBalanceContext/SendBalanceContext.js';
|
|
89
|
+
import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
90
|
+
import '../../../../context/ConnectWithOtpContext/constants.js';
|
|
91
|
+
import '../../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
92
|
+
import '../../../../store/state/tokenBalances.js';
|
|
93
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
94
|
+
import 'qrcode';
|
|
95
|
+
|
|
96
|
+
const ConnectedAppsView = ({ name, }) => {
|
|
97
|
+
var _a;
|
|
98
|
+
const { t } = useTranslation();
|
|
99
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
100
|
+
const { primaryWallet } = useDynamicContext();
|
|
101
|
+
const [connectedApps, setConnectedApps] = useState([]);
|
|
102
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
103
|
+
const [showSuccessMessage, setShowSuccessMessage] = useState(false);
|
|
104
|
+
const { globalWallet } = (_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const fetchConnectedApps = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
+
try {
|
|
108
|
+
// poll for 3 seconds for the global wallet to load
|
|
109
|
+
const pollForSessions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const startTime = Date.now();
|
|
111
|
+
while (Date.now() - startTime < 3000) {
|
|
112
|
+
try {
|
|
113
|
+
const sessions = yield globalWallet.getConnectedWCSessions();
|
|
114
|
+
if (sessions !== undefined) {
|
|
115
|
+
return sessions;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
// ignore polling error waiting for global wallet to load
|
|
120
|
+
}
|
|
121
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
122
|
+
}
|
|
123
|
+
logger.warn('Timeout waiting for sessions');
|
|
124
|
+
return undefined;
|
|
125
|
+
});
|
|
126
|
+
const sessions = yield pollForSessions();
|
|
127
|
+
// when a user logs out on dapp side, refresh the connected apps
|
|
128
|
+
globalWallet.getWeb3Wallet().on('session_delete', () => setRefreshing(!refreshing));
|
|
129
|
+
if (sessions) {
|
|
130
|
+
const apps = Object.values(sessions).map((session) => ({
|
|
131
|
+
icon: session.peer.metadata.icons[0] || '',
|
|
132
|
+
name: session.peer.metadata.name,
|
|
133
|
+
topic: session.topic,
|
|
134
|
+
url: session.peer.metadata.url,
|
|
135
|
+
}));
|
|
136
|
+
setConnectedApps(apps);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
logger.warn('Error fetching connected apps', error);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
fetchConnectedApps();
|
|
144
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
145
|
+
}, [primaryWallet, refreshing]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (name) {
|
|
148
|
+
setShowSuccessMessage(true);
|
|
149
|
+
const timer = setTimeout(() => {
|
|
150
|
+
setShowSuccessMessage(false);
|
|
151
|
+
}, 3000);
|
|
152
|
+
return () => clearTimeout(timer);
|
|
153
|
+
}
|
|
154
|
+
else
|
|
155
|
+
return;
|
|
156
|
+
}, [name]);
|
|
157
|
+
const handleDisconnect = (topic) => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
+
try {
|
|
159
|
+
yield globalWallet.disconnectWCSession(topic);
|
|
160
|
+
setRefreshing(!refreshing);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
logger.warn('Error disconnecting app', error);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
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', weight: 'medium', 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: () => window.open(app.url, '_blank'), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsx(SvgExternalLink, {}), typographyProps: {
|
|
167
|
+
color: 'secondary',
|
|
168
|
+
variant: 'button_secondary',
|
|
169
|
+
} }), jsx(TypographyButton, { onClick: () => handleDisconnect(app.topic), buttonVariant: 'tertiary', buttonPadding: 'none', startSlot: jsx(SvgUnlink, {}), typographyProps: {
|
|
170
|
+
color: 'secondary',
|
|
171
|
+
variant: 'button_secondary',
|
|
172
|
+
} })] })] }, app.url))) })), showSuccessMessage && (jsxs("div", { className: 'success-message', children: [jsx(SvgCheck, {}), jsx(Typography, { variant: 'body_small', color: 'primary', children: t('global_wallet.connected_apps.success', { name }) })] }))] }));
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export { ConnectedAppsView, ConnectedAppsView as default };
|
|
@@ -118,13 +118,13 @@ const GlobalWalletView = () => {
|
|
|
118
118
|
throw new Error('Global Wallet not found');
|
|
119
119
|
const showBanner = React.useCallback((message, type) => {
|
|
120
120
|
setBannerMessage({ message, type });
|
|
121
|
-
const timeout = type === 'success' ?
|
|
121
|
+
const timeout = type === 'success' ? 0 : 3000;
|
|
122
122
|
setTimeout(() => {
|
|
123
123
|
setBannerMessage(null);
|
|
124
|
-
if (type === 'success')
|
|
125
|
-
goToInitialDynamicWidgetView();
|
|
126
124
|
}, timeout);
|
|
127
|
-
},
|
|
125
|
+
},
|
|
126
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
127
|
+
[]);
|
|
128
128
|
const handleConfirmView = (pairingInfo) => {
|
|
129
129
|
setView('global-wallet-confirm', {
|
|
130
130
|
onCancel: () => {
|
|
@@ -136,7 +136,7 @@ const GlobalWalletView = () => {
|
|
|
136
136
|
setWalletConnectUri('');
|
|
137
137
|
},
|
|
138
138
|
onConfirm: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
var _a
|
|
139
|
+
var _a;
|
|
140
140
|
try {
|
|
141
141
|
yield globalWallet.confirmPairing(true);
|
|
142
142
|
setDynamicWidgetView('global-wallet');
|
|
@@ -144,13 +144,11 @@ const GlobalWalletView = () => {
|
|
|
144
144
|
ignoreIfIsEmbeddedWidget: false,
|
|
145
145
|
performMultiWalletChecks: false,
|
|
146
146
|
});
|
|
147
|
-
|
|
148
|
-
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
149
|
-
}), 'success');
|
|
147
|
+
setDynamicWidgetView('connected-apps', { name: pairingInfo.name });
|
|
150
148
|
}
|
|
151
149
|
catch (error) {
|
|
152
150
|
showBanner(t('global_wallet.banner.warning', {
|
|
153
|
-
name: (
|
|
151
|
+
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
154
152
|
}), 'error');
|
|
155
153
|
}
|
|
156
154
|
}),
|
|
@@ -114,13 +114,13 @@ const GlobalWalletView = () => {
|
|
|
114
114
|
throw new Error('Global Wallet not found');
|
|
115
115
|
const showBanner = useCallback((message, type) => {
|
|
116
116
|
setBannerMessage({ message, type });
|
|
117
|
-
const timeout = type === 'success' ?
|
|
117
|
+
const timeout = type === 'success' ? 0 : 3000;
|
|
118
118
|
setTimeout(() => {
|
|
119
119
|
setBannerMessage(null);
|
|
120
|
-
if (type === 'success')
|
|
121
|
-
goToInitialDynamicWidgetView();
|
|
122
120
|
}, timeout);
|
|
123
|
-
},
|
|
121
|
+
},
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
[]);
|
|
124
124
|
const handleConfirmView = (pairingInfo) => {
|
|
125
125
|
setView('global-wallet-confirm', {
|
|
126
126
|
onCancel: () => {
|
|
@@ -132,7 +132,7 @@ const GlobalWalletView = () => {
|
|
|
132
132
|
setWalletConnectUri('');
|
|
133
133
|
},
|
|
134
134
|
onConfirm: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
var _a
|
|
135
|
+
var _a;
|
|
136
136
|
try {
|
|
137
137
|
yield globalWallet.confirmPairing(true);
|
|
138
138
|
setDynamicWidgetView('global-wallet');
|
|
@@ -140,13 +140,11 @@ const GlobalWalletView = () => {
|
|
|
140
140
|
ignoreIfIsEmbeddedWidget: false,
|
|
141
141
|
performMultiWalletChecks: false,
|
|
142
142
|
});
|
|
143
|
-
|
|
144
|
-
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
145
|
-
}), 'success');
|
|
143
|
+
setDynamicWidgetView('connected-apps', { name: pairingInfo.name });
|
|
146
144
|
}
|
|
147
145
|
catch (error) {
|
|
148
146
|
showBanner(t('global_wallet.banner.warning', {
|
|
149
|
-
name: (
|
|
147
|
+
name: (_a = pairingInfo.name) !== null && _a !== void 0 ? _a : t('global_wallet.the_dapp'),
|
|
150
148
|
}), 'error');
|
|
151
149
|
}
|
|
152
150
|
}),
|
|
@@ -21,6 +21,7 @@ require('../../../../context/ViewContext/ViewContext.cjs');
|
|
|
21
21
|
var add = require('../../../../shared/assets/add.cjs');
|
|
22
22
|
var altKey = require('../../../../shared/assets/alt-key.cjs');
|
|
23
23
|
var androidTouchId = require('../../../../shared/assets/android-touch-id.cjs');
|
|
24
|
+
var connectedApps = require('../../../../shared/assets/connected-apps.cjs');
|
|
24
25
|
var checkCircle = require('../../../../shared/assets/check-circle.cjs');
|
|
25
26
|
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
26
27
|
var exportPrivateKey = require('../../../../shared/assets/export-private-key.cjs');
|
|
@@ -117,8 +118,11 @@ require('../../../../store/state/tokenBalances.cjs');
|
|
|
117
118
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
118
119
|
|
|
119
120
|
const SettingsView = () => {
|
|
120
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
121
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
121
122
|
const { projectSettings, primaryWallet, user, handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
|
|
123
|
+
const { globalWallet } =
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
+
(_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
122
126
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
123
127
|
const { addEmbeddedWalletRecoveryEmail } = useEmbeddedWalletAuthenticator.useEmbeddedWalletAuthenticator();
|
|
124
128
|
const { createPassword } = useEmbeddedWallet.useEmbeddedWallet();
|
|
@@ -129,17 +133,20 @@ const SettingsView = () => {
|
|
|
129
133
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
130
134
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
131
135
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
132
|
-
const cbWalletProperties = (
|
|
136
|
+
const cbWalletProperties = (_c = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find(({ walletName }) => walletName === 'coinbasempc')) === null || _c === void 0 ? void 0 : _c.walletProperties;
|
|
133
137
|
const isCoinbaseWallet = walletConnectorCore.isCoinbaseMpcWalletConnector(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector);
|
|
134
138
|
const hasClaimedCoinbaseMPC = Boolean(cbWalletProperties === null || cbWalletProperties === void 0 ? void 0 : cbWalletProperties.claimed);
|
|
135
|
-
const turnkeyWalletProperties = (
|
|
139
|
+
const turnkeyWalletProperties = (_e = (_d = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _e === void 0 ? void 0 : _e.walletProperties;
|
|
136
140
|
const isTurnkeyHDWallet = turnkeyWalletProperties === null || turnkeyWalletProperties === void 0 ? void 0 : turnkeyWalletProperties.turnkeyHDWalletId;
|
|
137
|
-
const isPasskeyEnabled = Boolean((
|
|
141
|
+
const isPasskeyEnabled = Boolean((_j = (_h = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.supportedSecurityMethods) === null || _h === void 0 ? void 0 : _h.passkey) === null || _j === void 0 ? void 0 : _j.isEnabled);
|
|
138
142
|
const isTurnkeyWalletWithAuthenticator = isTurnkeyWallet && !isTurnkeyWalletWithoutAuthenticator;
|
|
139
143
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
140
144
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
141
145
|
const isSessionKeyCompatible = (primaryWallet && walletConnectorCore.isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
142
146
|
(eoaWallet && walletConnectorCore.isSessionKeyCompatibleWallet(eoaWallet));
|
|
147
|
+
const handleConnectedAppsClick = () => {
|
|
148
|
+
setDynamicWidgetView('connected-apps');
|
|
149
|
+
};
|
|
143
150
|
const handlePasskeyClick = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
144
151
|
if (isTurnkeyWalletWithAuthenticator) {
|
|
145
152
|
return setDynamicWidgetView('manage-passkeys');
|
|
@@ -175,14 +182,16 @@ const SettingsView = () => {
|
|
|
175
182
|
return jsxRuntime.jsx(add.ReactComponent, { "data-testid": 'email-add-icon' });
|
|
176
183
|
};
|
|
177
184
|
const isEmbeddedWallet = Boolean(wallet &&
|
|
178
|
-
(((
|
|
179
|
-
((
|
|
180
|
-
const isMfaEnabled = Boolean((
|
|
185
|
+
(((_l = (_k = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _k === void 0 ? void 0 : _k.key) === null || _l === void 0 ? void 0 : _l.startsWith('turnkey')) ||
|
|
186
|
+
((_o = (_m = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _m === void 0 ? void 0 : _m.key) === null || _o === void 0 ? void 0 : _o.startsWith('coinbasempc'))));
|
|
187
|
+
const isMfaEnabled = Boolean((_q = (_p = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security) === null || _p === void 0 ? void 0 : _p.mfa) === null || _q === void 0 ? void 0 : _q.enabled);
|
|
181
188
|
const shouldShowPasskeyMFA = isPasskeyEnabled && isTurnkeyWallet && !isSessionKeyCompatible;
|
|
182
189
|
const shouldShowSecuritySection = isMfaEnabled || isCoinbaseWallet || shouldShowPasskeyMFA;
|
|
183
190
|
return (jsxRuntime.jsxs("div", { className: 'settings-view', children: [jsxRuntime.jsxs("div", { className: 'settings-view__body', children: [jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_section.title') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'currency-button', buttonClassName: classNames.classNames('settings-view__body__section__button', 'settings-view__body__section__button__badge'), startSlot:
|
|
184
191
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
185
|
-
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(currency.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_section.currency.badge', children: t('dyn_settings.global_section.currency.title') }), jsxRuntime.jsx(Badge.Badge, { text: t('dyn_settings.global_section.currency.badge'), copykey: 'dyn_settings.global_section.currency.badge', variant: 'secondary' })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: true, showInternalLoading: false })] }),
|
|
192
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(currency.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_section.currency.badge', children: t('dyn_settings.global_section.currency.title') }), jsxRuntime.jsx(Badge.Badge, { text: t('dyn_settings.global_section.currency.badge'), copykey: 'dyn_settings.global_section.currency.badge', variant: 'secondary' })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: true, showInternalLoading: false })] }), globalWallet && (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_connectivity_section.title') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => handleConnectedAppsClick(), dataTestId: 'connected-apps-button', buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
193
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
194
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(connectedApps.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_connectivity_section.connected_apps_button', children: t('dyn_settings.global_connectivity_section.connected_apps_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })] })), shouldShowSecuritySection && (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: classNames.classNames('settings-view__body__section__title', {
|
|
186
195
|
'settings-view__body__section__title__info-icon': !isTurnkeyWalletWithAuthenticator,
|
|
187
196
|
}), children: t('dyn_settings.security_section.title') }), shouldShowPasskeyMFA && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-passkeys-button', onClick: () => handlePasskeyClick(), buttonClassName: classNames.classNames('settings-view__body__section__button', {
|
|
188
197
|
'settings-view__body__section__button__badge': !isTurnkeyWalletWithAuthenticator,
|
|
@@ -17,6 +17,7 @@ import '../../../../context/ViewContext/ViewContext.js';
|
|
|
17
17
|
import { ReactComponent as SvgAdd } from '../../../../shared/assets/add.js';
|
|
18
18
|
import { ReactComponent as SvgAltKey } from '../../../../shared/assets/alt-key.js';
|
|
19
19
|
import { ReactComponent as SvgAndroidTouchId } from '../../../../shared/assets/android-touch-id.js';
|
|
20
|
+
import { ReactComponent as SvgConnectedApps } from '../../../../shared/assets/connected-apps.js';
|
|
20
21
|
import { ReactComponent as SvgCheckCircle } from '../../../../shared/assets/check-circle.js';
|
|
21
22
|
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
22
23
|
import { ReactComponent as SvgExportPrivateKey } from '../../../../shared/assets/export-private-key.js';
|
|
@@ -113,8 +114,11 @@ import '../../../../store/state/tokenBalances.js';
|
|
|
113
114
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
114
115
|
|
|
115
116
|
const SettingsView = () => {
|
|
116
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
117
118
|
const { projectSettings, primaryWallet, user, handleLogOut } = useInternalDynamicContext();
|
|
119
|
+
const { globalWallet } =
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
(_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) !== null && _a !== void 0 ? _a : {};
|
|
118
122
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
119
123
|
const { addEmbeddedWalletRecoveryEmail } = useEmbeddedWalletAuthenticator();
|
|
120
124
|
const { createPassword } = useEmbeddedWallet();
|
|
@@ -125,17 +129,20 @@ const SettingsView = () => {
|
|
|
125
129
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
126
130
|
const [isLoading, setIsLoading] = useState(false);
|
|
127
131
|
const { getEOAWallet } = useSmartWallets();
|
|
128
|
-
const cbWalletProperties = (
|
|
132
|
+
const cbWalletProperties = (_c = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find(({ walletName }) => walletName === 'coinbasempc')) === null || _c === void 0 ? void 0 : _c.walletProperties;
|
|
129
133
|
const isCoinbaseWallet = isCoinbaseMpcWalletConnector(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector);
|
|
130
134
|
const hasClaimedCoinbaseMPC = Boolean(cbWalletProperties === null || cbWalletProperties === void 0 ? void 0 : cbWalletProperties.claimed);
|
|
131
|
-
const turnkeyWalletProperties = (
|
|
135
|
+
const turnkeyWalletProperties = (_e = (_d = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _e === void 0 ? void 0 : _e.walletProperties;
|
|
132
136
|
const isTurnkeyHDWallet = turnkeyWalletProperties === null || turnkeyWalletProperties === void 0 ? void 0 : turnkeyWalletProperties.turnkeyHDWalletId;
|
|
133
|
-
const isPasskeyEnabled = Boolean((
|
|
137
|
+
const isPasskeyEnabled = Boolean((_j = (_h = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.supportedSecurityMethods) === null || _h === void 0 ? void 0 : _h.passkey) === null || _j === void 0 ? void 0 : _j.isEnabled);
|
|
134
138
|
const isTurnkeyWalletWithAuthenticator = isTurnkeyWallet && !isTurnkeyWalletWithoutAuthenticator;
|
|
135
139
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
136
140
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
137
141
|
const isSessionKeyCompatible = (primaryWallet && isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
138
142
|
(eoaWallet && isSessionKeyCompatibleWallet(eoaWallet));
|
|
143
|
+
const handleConnectedAppsClick = () => {
|
|
144
|
+
setDynamicWidgetView('connected-apps');
|
|
145
|
+
};
|
|
139
146
|
const handlePasskeyClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
147
|
if (isTurnkeyWalletWithAuthenticator) {
|
|
141
148
|
return setDynamicWidgetView('manage-passkeys');
|
|
@@ -171,14 +178,16 @@ const SettingsView = () => {
|
|
|
171
178
|
return jsx(SvgAdd, { "data-testid": 'email-add-icon' });
|
|
172
179
|
};
|
|
173
180
|
const isEmbeddedWallet = Boolean(wallet &&
|
|
174
|
-
(((
|
|
175
|
-
((
|
|
176
|
-
const isMfaEnabled = Boolean((
|
|
181
|
+
(((_l = (_k = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _k === void 0 ? void 0 : _k.key) === null || _l === void 0 ? void 0 : _l.startsWith('turnkey')) ||
|
|
182
|
+
((_o = (_m = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _m === void 0 ? void 0 : _m.key) === null || _o === void 0 ? void 0 : _o.startsWith('coinbasempc'))));
|
|
183
|
+
const isMfaEnabled = Boolean((_q = (_p = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security) === null || _p === void 0 ? void 0 : _p.mfa) === null || _q === void 0 ? void 0 : _q.enabled);
|
|
177
184
|
const shouldShowPasskeyMFA = isPasskeyEnabled && isTurnkeyWallet && !isSessionKeyCompatible;
|
|
178
185
|
const shouldShowSecuritySection = isMfaEnabled || isCoinbaseWallet || shouldShowPasskeyMFA;
|
|
179
186
|
return (jsxs("div", { className: 'settings-view', children: [jsxs("div", { className: 'settings-view__body', children: [jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_section.title') }), jsx(TypographyButton, { dataTestId: 'currency-button', buttonClassName: classNames('settings-view__body__section__button', 'settings-view__body__section__button__badge'), startSlot:
|
|
180
187
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
181
|
-
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgCurrency, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_section.currency.badge', children: t('dyn_settings.global_section.currency.title') }), jsx(Badge, { text: t('dyn_settings.global_section.currency.badge'), copykey: 'dyn_settings.global_section.currency.badge', variant: 'secondary' })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: true, showInternalLoading: false })] }),
|
|
188
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgCurrency, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_section.currency.badge', children: t('dyn_settings.global_section.currency.title') }), jsx(Badge, { text: t('dyn_settings.global_section.currency.badge'), copykey: 'dyn_settings.global_section.currency.badge', variant: 'secondary' })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: true, showInternalLoading: false })] }), globalWallet && (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: t('dyn_settings.global_connectivity_section.title') }), jsx(TypographyButton, { onClick: () => handleConnectedAppsClick(), dataTestId: 'connected-apps-button', buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
189
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
190
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgConnectedApps, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.global_connectivity_section.connected_apps_button', children: t('dyn_settings.global_connectivity_section.connected_apps_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })] })), shouldShowSecuritySection && (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: classNames('settings-view__body__section__title', {
|
|
182
191
|
'settings-view__body__section__title__info-icon': !isTurnkeyWalletWithAuthenticator,
|
|
183
192
|
}), children: t('dyn_settings.security_section.title') }), shouldShowPasskeyMFA && (jsx(TypographyButton, { dataTestId: 'manage-passkeys-button', onClick: () => handlePasskeyClick(), buttonClassName: classNames('settings-view__body__section__button', {
|
|
184
193
|
'settings-view__body__section__button__badge': !isTurnkeyWalletWithAuthenticator,
|