@dynamic-labs/sdk-react-core 4.22.7 → 4.23.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 +21 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -1
- package/src/lib/client/client.cjs +2 -0
- package/src/lib/client/client.d.ts +1 -0
- package/src/lib/client/client.js +2 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/fetchOverride/fetchOverride.cjs +5 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/fetchOverride/fetchOverride.js +5 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +24 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.d.ts +1 -1
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +26 -8
- package/src/lib/components/MenuList/DropdownMenu/DropdownMenu.cjs +1 -1
- package/src/lib/components/MenuList/DropdownMenu/DropdownMenu.js +1 -1
- package/src/lib/components/Search/Search.cjs +5 -1
- package/src/lib/components/Search/Search.js +5 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +1 -1
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +9 -2
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -2
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/wallets.d.ts +2 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +1 -1
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +1 -1
- package/src/lib/locale/en/translation.cjs +28 -0
- package/src/lib/locale/en/translation.d.ts +28 -0
- package/src/lib/locale/en/translation.js +28 -0
- package/src/lib/shared/logger.cjs +1 -1
- package/src/lib/shared/logger.js +2 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +1 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +1 -0
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.cjs +1 -1
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.js +1 -1
- package/src/lib/utils/functions/getTimeSince/index.d.ts +1 -0
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs +1 -1
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/index.d.ts +3 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +1 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +1 -1
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.cjs +15 -0
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.d.ts +6 -0
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.js +11 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +13 -6
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +13 -6
- package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.js +1 -1
- package/src/lib/utils/hooks/useIsMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsMfaEnabled/useIsMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.cjs +15 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.js +11 -0
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -1
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +33 -18
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.d.ts +4 -0
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +33 -18
- package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.cjs +1 -1
- package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.js +1 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +1 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +1 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +1 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +43 -6
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +2 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +43 -6
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/ExchangeList/ExchangeList.cjs +5 -5
- package/src/lib/views/ExchangeList/ExchangeList.js +5 -5
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +2 -2
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +1 -1
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs +4 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.d.ts +2 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.js +4 -2
- package/src/lib/views/WalletList/WalletList.cjs +1 -1
- package/src/lib/views/WalletList/WalletList.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +4 -4
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +2 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.js +2 -2
- package/src/lib/widgets/DynamicWidget/helpers/helpers.cjs +0 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.d.ts +0 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.js +0 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +42 -106
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +43 -107
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +119 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.d.ts +6 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +115 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.cjs +170 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/WalletSecuritySection.js +166 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/WalletSecuritySection/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView/ManageMfaWidgetView.cjs → ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs} +8 -7
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView/ManageMfaWidgetView.js → ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js} +7 -6
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +5 -4
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +5 -4
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.d.ts +0 -2
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/index.d.ts +0 -1
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.cjs +0 -0
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.d.ts +0 -0
- /package/src/lib/{widgets/DynamicWidget/helpers → utils/functions/getTimeSince}/getTimeSince.js +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/UserDeviceTile.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/index.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/views/{ManageMfaWidgetView → ManageTotpMfaWidgetView}/components/utils/sort.js +0 -0
|
@@ -9,8 +9,8 @@ require('@dynamic-labs-sdk/client/core');
|
|
|
9
9
|
require('@dynamic-labs/sdk-api-core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
require('../../../shared/logger.cjs');
|
|
16
16
|
require('../../constants/colors.cjs');
|
|
@@ -23,7 +23,7 @@ require('@dynamic-labs/wallet-book');
|
|
|
23
23
|
require('../../../shared/consts/index.cjs');
|
|
24
24
|
require('../../../store/state/nonce/nonce.cjs');
|
|
25
25
|
require('../../../config/ApiEndpoint.cjs');
|
|
26
|
-
|
|
26
|
+
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
27
|
require('../../../locale/locale.cjs');
|
|
28
28
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
29
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
@@ -96,79 +96,94 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
96
96
|
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
97
97
|
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
98
98
|
require('../../../../index.cjs');
|
|
99
|
+
var useIsMfaEnabled = require('../useIsMfaEnabled/useIsMfaEnabled.cjs');
|
|
100
|
+
var useIsTotpMfaEnabled = require('../useIsTotpMfaEnabled/useIsTotpMfaEnabled.cjs');
|
|
99
101
|
require('../../../store/state/tokenBalances.cjs');
|
|
100
102
|
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
101
103
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
102
104
|
|
|
103
105
|
const useMfaModals = () => {
|
|
104
|
-
var _a;
|
|
105
106
|
const { setShowAuthFlow, setShowDynamicUserProfile } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
|
-
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
107
107
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
108
108
|
const { clearStackAndPush } = ViewContext.useViewContext();
|
|
109
|
-
const isMfaEnabled = (
|
|
110
|
-
const
|
|
109
|
+
const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
|
|
110
|
+
const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
|
|
111
|
+
const setShowTotpMfaManage = React.useCallback((value) => {
|
|
111
112
|
if (value) {
|
|
112
|
-
if (!
|
|
113
|
+
if (!isTotpMfaEnabled) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
setDynamicWidgetView('manage-mfa-no-footer');
|
|
116
|
+
setDynamicWidgetView('manage-totp-mfa-no-footer');
|
|
116
117
|
}
|
|
117
118
|
setShowDynamicUserProfile(value);
|
|
118
|
-
}, [
|
|
119
|
+
}, [isTotpMfaEnabled, setShowDynamicUserProfile, setDynamicWidgetView]);
|
|
119
120
|
const setShowMfaChooseType = React.useCallback((value) => {
|
|
120
121
|
if (value) {
|
|
121
|
-
if (!isMfaEnabled)
|
|
122
|
+
if (!isMfaEnabled) {
|
|
122
123
|
return;
|
|
124
|
+
}
|
|
123
125
|
clearStackAndPush('mfa-choose-device');
|
|
124
126
|
}
|
|
125
127
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
126
128
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
127
129
|
const setShowMfaQRCode = React.useCallback((value) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
128
130
|
if (value) {
|
|
129
|
-
if (!
|
|
131
|
+
if (!isTotpMfaEnabled) {
|
|
130
132
|
return;
|
|
133
|
+
}
|
|
131
134
|
const user = getUserProfile.getUserProfile();
|
|
132
135
|
// Already have MFA configured
|
|
133
136
|
if (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) {
|
|
134
|
-
|
|
137
|
+
setShowTotpMfaManage(true);
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
137
140
|
clearStackAndPush('mfa-secure-device', { isInitialSetup: true });
|
|
138
141
|
}
|
|
139
142
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
140
|
-
}), [
|
|
143
|
+
}), [
|
|
144
|
+
isTotpMfaEnabled,
|
|
145
|
+
setShowAuthFlow,
|
|
146
|
+
clearStackAndPush,
|
|
147
|
+
setShowTotpMfaManage,
|
|
148
|
+
]);
|
|
141
149
|
const setShowOTPVerification = React.useCallback((value) => {
|
|
142
150
|
if (value) {
|
|
143
|
-
if (!
|
|
151
|
+
if (!isTotpMfaEnabled) {
|
|
144
152
|
return;
|
|
153
|
+
}
|
|
145
154
|
clearStackAndPush('mfa-verification');
|
|
146
155
|
}
|
|
147
156
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
148
|
-
}, [
|
|
157
|
+
}, [isTotpMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
149
158
|
const setShowMfaViewBackupCodes = React.useCallback((value) => {
|
|
150
159
|
if (value) {
|
|
151
|
-
if (!isMfaEnabled)
|
|
160
|
+
if (!isMfaEnabled) {
|
|
152
161
|
return;
|
|
162
|
+
}
|
|
153
163
|
clearStackAndPush('mfa-display-backup-codes');
|
|
154
164
|
}
|
|
155
165
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
156
166
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
157
167
|
const setShowMfaEnterBackupCodes = React.useCallback((value) => {
|
|
158
168
|
if (value) {
|
|
159
|
-
if (!isMfaEnabled)
|
|
169
|
+
if (!isMfaEnabled) {
|
|
160
170
|
return;
|
|
171
|
+
}
|
|
161
172
|
clearStackAndPush('mfa-recovery');
|
|
162
173
|
}
|
|
163
174
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
164
175
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
165
176
|
return {
|
|
166
|
-
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
179
|
+
*/
|
|
180
|
+
setShowMFAManage: setShowTotpMfaManage,
|
|
167
181
|
setShowMfaChooseType,
|
|
168
182
|
setShowMfaEnterBackupCodes,
|
|
169
183
|
setShowMfaQRCode,
|
|
170
184
|
setShowMfaViewBackupCodes,
|
|
171
185
|
setShowOTPVerification,
|
|
186
|
+
setShowTotpMfaManage,
|
|
172
187
|
};
|
|
173
188
|
};
|
|
174
189
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
export declare const useMfaModals: () => {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
5
|
+
*/
|
|
3
6
|
setShowMFAManage: Dispatch<SetStateAction<boolean>>;
|
|
4
7
|
setShowMfaChooseType: Dispatch<SetStateAction<boolean>>;
|
|
5
8
|
setShowMfaEnterBackupCodes: Dispatch<SetStateAction<boolean>>;
|
|
6
9
|
setShowMfaQRCode: Dispatch<SetStateAction<boolean>>;
|
|
7
10
|
setShowMfaViewBackupCodes: Dispatch<SetStateAction<boolean>>;
|
|
8
11
|
setShowOTPVerification: Dispatch<SetStateAction<boolean>>;
|
|
12
|
+
setShowTotpMfaManage: Dispatch<SetStateAction<boolean>>;
|
|
9
13
|
};
|
|
@@ -5,8 +5,8 @@ import '@dynamic-labs-sdk/client/core';
|
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import '../../../shared/logger.js';
|
|
12
12
|
import '../../constants/colors.js';
|
|
@@ -19,7 +19,7 @@ import '@dynamic-labs/wallet-book';
|
|
|
19
19
|
import '../../../shared/consts/index.js';
|
|
20
20
|
import '../../../store/state/nonce/nonce.js';
|
|
21
21
|
import '../../../config/ApiEndpoint.js';
|
|
22
|
-
import
|
|
22
|
+
import '../../../store/state/projectSettings/projectSettings.js';
|
|
23
23
|
import '../../../locale/locale.js';
|
|
24
24
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
25
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
@@ -92,79 +92,94 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
92
92
|
import '../../../context/OnrampContext/OnrampContext.js';
|
|
93
93
|
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
94
94
|
import '../../../../index.js';
|
|
95
|
+
import { useIsMfaEnabled } from '../useIsMfaEnabled/useIsMfaEnabled.js';
|
|
96
|
+
import { useIsTotpMfaEnabled } from '../useIsTotpMfaEnabled/useIsTotpMfaEnabled.js';
|
|
95
97
|
import '../../../store/state/tokenBalances.js';
|
|
96
98
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
97
99
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
98
100
|
|
|
99
101
|
const useMfaModals = () => {
|
|
100
|
-
var _a;
|
|
101
102
|
const { setShowAuthFlow, setShowDynamicUserProfile } = useInternalDynamicContext();
|
|
102
|
-
const projectSettings = useProjectSettings();
|
|
103
103
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
104
104
|
const { clearStackAndPush } = useViewContext();
|
|
105
|
-
const isMfaEnabled = (
|
|
106
|
-
const
|
|
105
|
+
const isMfaEnabled = useIsMfaEnabled();
|
|
106
|
+
const isTotpMfaEnabled = useIsTotpMfaEnabled();
|
|
107
|
+
const setShowTotpMfaManage = useCallback((value) => {
|
|
107
108
|
if (value) {
|
|
108
|
-
if (!
|
|
109
|
+
if (!isTotpMfaEnabled) {
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
|
-
setDynamicWidgetView('manage-mfa-no-footer');
|
|
112
|
+
setDynamicWidgetView('manage-totp-mfa-no-footer');
|
|
112
113
|
}
|
|
113
114
|
setShowDynamicUserProfile(value);
|
|
114
|
-
}, [
|
|
115
|
+
}, [isTotpMfaEnabled, setShowDynamicUserProfile, setDynamicWidgetView]);
|
|
115
116
|
const setShowMfaChooseType = useCallback((value) => {
|
|
116
117
|
if (value) {
|
|
117
|
-
if (!isMfaEnabled)
|
|
118
|
+
if (!isMfaEnabled) {
|
|
118
119
|
return;
|
|
120
|
+
}
|
|
119
121
|
clearStackAndPush('mfa-choose-device');
|
|
120
122
|
}
|
|
121
123
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
122
124
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
123
125
|
const setShowMfaQRCode = useCallback((value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
126
|
if (value) {
|
|
125
|
-
if (!
|
|
127
|
+
if (!isTotpMfaEnabled) {
|
|
126
128
|
return;
|
|
129
|
+
}
|
|
127
130
|
const user = getUserProfile();
|
|
128
131
|
// Already have MFA configured
|
|
129
132
|
if (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) {
|
|
130
|
-
|
|
133
|
+
setShowTotpMfaManage(true);
|
|
131
134
|
return;
|
|
132
135
|
}
|
|
133
136
|
clearStackAndPush('mfa-secure-device', { isInitialSetup: true });
|
|
134
137
|
}
|
|
135
138
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
136
|
-
}), [
|
|
139
|
+
}), [
|
|
140
|
+
isTotpMfaEnabled,
|
|
141
|
+
setShowAuthFlow,
|
|
142
|
+
clearStackAndPush,
|
|
143
|
+
setShowTotpMfaManage,
|
|
144
|
+
]);
|
|
137
145
|
const setShowOTPVerification = useCallback((value) => {
|
|
138
146
|
if (value) {
|
|
139
|
-
if (!
|
|
147
|
+
if (!isTotpMfaEnabled) {
|
|
140
148
|
return;
|
|
149
|
+
}
|
|
141
150
|
clearStackAndPush('mfa-verification');
|
|
142
151
|
}
|
|
143
152
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
144
|
-
}, [
|
|
153
|
+
}, [isTotpMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
145
154
|
const setShowMfaViewBackupCodes = useCallback((value) => {
|
|
146
155
|
if (value) {
|
|
147
|
-
if (!isMfaEnabled)
|
|
156
|
+
if (!isMfaEnabled) {
|
|
148
157
|
return;
|
|
158
|
+
}
|
|
149
159
|
clearStackAndPush('mfa-display-backup-codes');
|
|
150
160
|
}
|
|
151
161
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
152
162
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
153
163
|
const setShowMfaEnterBackupCodes = useCallback((value) => {
|
|
154
164
|
if (value) {
|
|
155
|
-
if (!isMfaEnabled)
|
|
165
|
+
if (!isMfaEnabled) {
|
|
156
166
|
return;
|
|
167
|
+
}
|
|
157
168
|
clearStackAndPush('mfa-recovery');
|
|
158
169
|
}
|
|
159
170
|
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
160
171
|
}, [isMfaEnabled, setShowAuthFlow, clearStackAndPush]);
|
|
161
172
|
return {
|
|
162
|
-
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated use setShowTotpMfaManage instead
|
|
175
|
+
*/
|
|
176
|
+
setShowMFAManage: setShowTotpMfaManage,
|
|
163
177
|
setShowMfaChooseType,
|
|
164
178
|
setShowMfaEnterBackupCodes,
|
|
165
179
|
setShowMfaQRCode,
|
|
166
180
|
setShowMfaViewBackupCodes,
|
|
167
181
|
setShowOTPVerification,
|
|
182
|
+
setShowTotpMfaManage,
|
|
168
183
|
};
|
|
169
184
|
};
|
|
170
185
|
|
|
@@ -9,8 +9,8 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
16
16
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -5,8 +5,8 @@ import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
12
12
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -9,8 +9,8 @@ var client = require('../../../client/client.cjs');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs/sdk-api-core');
|
|
11
11
|
require('@dynamic-labs-sdk/client');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
var logger = require('../../../shared/logger.cjs');
|
|
16
16
|
require('../../constants/colors.cjs');
|
|
@@ -5,8 +5,8 @@ import { getDynamicClient } from '../../../client/client.js';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import '@dynamic-labs-sdk/client';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import { logger } from '../../../shared/logger.js';
|
|
12
12
|
import '../../constants/colors.js';
|
|
@@ -9,8 +9,8 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('@dynamic-labs-sdk/client/core');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../client/client.cjs');
|
|
12
|
-
require('../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../constants/values.cjs');
|
|
14
14
|
var errors = require('../../constants/errors.cjs');
|
|
15
15
|
require('@dynamic-labs/multi-wallet');
|
|
16
16
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -5,8 +5,8 @@ import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import '@dynamic-labs-sdk/client/core';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../client/client.js';
|
|
8
|
-
import '../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../constants/values.js';
|
|
10
10
|
import { USER_NOT_LOGGED_IN } from '../../constants/errors.js';
|
|
11
11
|
import '@dynamic-labs/multi-wallet';
|
|
12
12
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -9,8 +9,8 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
require('react');
|
|
10
10
|
require('@dynamic-labs-sdk/client');
|
|
11
11
|
require('../../../../client/client.cjs');
|
|
12
|
-
require('../../../constants/values.cjs');
|
|
13
12
|
require('@dynamic-labs/utils');
|
|
13
|
+
require('../../../constants/values.cjs');
|
|
14
14
|
require('@dynamic-labs/multi-wallet');
|
|
15
15
|
require('../../../../shared/logger.cjs');
|
|
16
16
|
require('../../../constants/colors.cjs');
|
|
@@ -5,8 +5,8 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@dynamic-labs-sdk/client';
|
|
7
7
|
import '../../../../client/client.js';
|
|
8
|
-
import '../../../constants/values.js';
|
|
9
8
|
import '@dynamic-labs/utils';
|
|
9
|
+
import '../../../constants/values.js';
|
|
10
10
|
import '@dynamic-labs/multi-wallet';
|
|
11
11
|
import '../../../../shared/logger.js';
|
|
12
12
|
import '../../../constants/colors.js';
|
|
@@ -13,8 +13,8 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
13
13
|
var useInitStatus = require('../../../client/extension/hooks/useClientInitStatus/useInitStatus.cjs');
|
|
14
14
|
require('@dynamic-labs-sdk/client');
|
|
15
15
|
require('../../../client/client.cjs');
|
|
16
|
-
require('../../constants/values.cjs');
|
|
17
16
|
require('@dynamic-labs/utils');
|
|
17
|
+
require('../../constants/values.cjs');
|
|
18
18
|
require('@dynamic-labs/multi-wallet');
|
|
19
19
|
require('../../constants/colors.cjs');
|
|
20
20
|
require('react-international-phone');
|
|
@@ -9,8 +9,8 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
9
9
|
import { useClientInitStatus } from '../../../client/extension/hooks/useClientInitStatus/useInitStatus.js';
|
|
10
10
|
import '@dynamic-labs-sdk/client';
|
|
11
11
|
import '../../../client/client.js';
|
|
12
|
-
import '../../constants/values.js';
|
|
13
12
|
import '@dynamic-labs/utils';
|
|
13
|
+
import '../../constants/values.js';
|
|
14
14
|
import '@dynamic-labs/multi-wallet';
|
|
15
15
|
import '../../constants/colors.js';
|
|
16
16
|
import 'react-international-phone';
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var React = require('react');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
9
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
10
|
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
12
11
|
require('@dynamic-labs/sdk-api-core');
|
|
@@ -19,7 +18,8 @@ require('../../constants/colors.cjs');
|
|
|
19
18
|
require('../../constants/values.cjs');
|
|
20
19
|
var isWalletGroup = require('../../functions/walletListBuilder/utils/isWalletGroup/isWalletGroup.cjs');
|
|
21
20
|
require('../../../shared/consts/index.cjs');
|
|
22
|
-
require('../../../events/dynamicEvents.cjs');
|
|
21
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
23
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -133,7 +133,7 @@ const useWalletOptions = () => {
|
|
|
133
133
|
});
|
|
134
134
|
}, [walletConnectorOptions, walletGroups]);
|
|
135
135
|
const allWalletOptions = React.useMemo(() => getFilteredWalletOptions((options) => options), [getFilteredWalletOptions]);
|
|
136
|
-
const selectWalletOption = React.useCallback((
|
|
136
|
+
const selectWalletOption = React.useCallback((walletKey, selectGroupIfAvailable = true) => new Promise((resolve, reject) => {
|
|
137
137
|
const group = groupWalletOptions.groupWalletOptions(walletGroups, walletConnectorOptions);
|
|
138
138
|
const walletGroup = group.find((wallet) => wallet.key === walletKey);
|
|
139
139
|
const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((wallet) => wallet.key === walletKey);
|
|
@@ -143,9 +143,12 @@ const useWalletOptions = () => {
|
|
|
143
143
|
walletOption: walletOption === null || walletOption === void 0 ? void 0 : walletOption.key,
|
|
144
144
|
});
|
|
145
145
|
if (!walletOption) {
|
|
146
|
-
|
|
146
|
+
reject(new utils.DynamicError('Invalid wallet option key provided.'));
|
|
147
|
+
return;
|
|
147
148
|
}
|
|
148
|
-
if (selectGroupIfAvailable &&
|
|
149
|
+
if (selectGroupIfAvailable &&
|
|
150
|
+
walletGroup &&
|
|
151
|
+
isWalletGroup.isWalletGroup(walletGroup)) {
|
|
149
152
|
navigateToWalletGroup(walletGroup);
|
|
150
153
|
}
|
|
151
154
|
else if (walletConnectorCore.isHardwareWalletConnector(walletOption.walletConnector) &&
|
|
@@ -159,6 +162,40 @@ const useWalletOptions = () => {
|
|
|
159
162
|
handleWalletItemClick(walletOption);
|
|
160
163
|
}
|
|
161
164
|
setShowAuthFlow(true);
|
|
165
|
+
const walletAdded = (wallet) => {
|
|
166
|
+
if (wallet.key !== walletKey) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
resolve(wallet);
|
|
170
|
+
setShowAuthFlow(false);
|
|
171
|
+
cleanup();
|
|
172
|
+
};
|
|
173
|
+
const walletConnectionFailed = (walletConnector, error) => {
|
|
174
|
+
if (walletConnector.key !== walletKey) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
reject(error);
|
|
178
|
+
setShowAuthFlow(false);
|
|
179
|
+
cleanup();
|
|
180
|
+
};
|
|
181
|
+
const authFailure = (method, reason) => {
|
|
182
|
+
if (method.type !== 'wallet' ||
|
|
183
|
+
method.connectorName !== walletOption.walletConnector.name) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const error = typeof reason === 'object' ? reason.error : reason;
|
|
187
|
+
reject(error);
|
|
188
|
+
setShowAuthFlow(false);
|
|
189
|
+
cleanup();
|
|
190
|
+
};
|
|
191
|
+
const cleanup = () => {
|
|
192
|
+
dynamicEvents.dynamicEvents.off('walletConnectionFailed', walletConnectionFailed);
|
|
193
|
+
dynamicEvents.dynamicEvents.off('authFailure', authFailure);
|
|
194
|
+
dynamicEvents.dynamicEvents.off('walletAdded', walletAdded);
|
|
195
|
+
};
|
|
196
|
+
dynamicEvents.dynamicEvents.on('walletAdded', walletAdded);
|
|
197
|
+
dynamicEvents.dynamicEvents.on('walletConnectionFailed', walletConnectionFailed);
|
|
198
|
+
dynamicEvents.dynamicEvents.on('authFailure', authFailure);
|
|
162
199
|
}), [
|
|
163
200
|
handleWalletItemClick,
|
|
164
201
|
navigateToWalletGroup,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
1
2
|
import { WalletOption } from '../../../shared';
|
|
2
3
|
export declare const useWalletOptions: () => {
|
|
3
4
|
getFilteredWalletOptions: (filter: (options: WalletOption[]) => WalletOption[]) => {
|
|
@@ -9,7 +10,7 @@ export declare const useWalletOptions: () => {
|
|
|
9
10
|
key: string;
|
|
10
11
|
name: string;
|
|
11
12
|
}[];
|
|
12
|
-
selectWalletOption: (walletKey: string, selectGroupIfAvailable?: boolean) => Promise<
|
|
13
|
+
selectWalletOption: (walletKey: string, selectGroupIfAvailable?: boolean) => Promise<Wallet<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>>;
|
|
13
14
|
walletOptions: {
|
|
14
15
|
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE" | "SUI";
|
|
15
16
|
group: string | undefined;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
2
|
import { useCallback, useMemo } from 'react';
|
|
4
|
-
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
3
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
+
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
5
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
6
|
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
8
7
|
import '@dynamic-labs/sdk-api-core';
|
|
@@ -15,7 +14,8 @@ import '../../constants/colors.js';
|
|
|
15
14
|
import '../../constants/values.js';
|
|
16
15
|
import { isWalletGroup } from '../../functions/walletListBuilder/utils/isWalletGroup/isWalletGroup.js';
|
|
17
16
|
import '../../../shared/consts/index.js';
|
|
18
|
-
import '../../../events/dynamicEvents.js';
|
|
17
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../../../_virtual/_tslib.js';
|
|
19
19
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -129,7 +129,7 @@ const useWalletOptions = () => {
|
|
|
129
129
|
});
|
|
130
130
|
}, [walletConnectorOptions, walletGroups]);
|
|
131
131
|
const allWalletOptions = useMemo(() => getFilteredWalletOptions((options) => options), [getFilteredWalletOptions]);
|
|
132
|
-
const selectWalletOption = useCallback((
|
|
132
|
+
const selectWalletOption = useCallback((walletKey, selectGroupIfAvailable = true) => new Promise((resolve, reject) => {
|
|
133
133
|
const group = groupWalletOptions(walletGroups, walletConnectorOptions);
|
|
134
134
|
const walletGroup = group.find((wallet) => wallet.key === walletKey);
|
|
135
135
|
const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((wallet) => wallet.key === walletKey);
|
|
@@ -139,9 +139,12 @@ const useWalletOptions = () => {
|
|
|
139
139
|
walletOption: walletOption === null || walletOption === void 0 ? void 0 : walletOption.key,
|
|
140
140
|
});
|
|
141
141
|
if (!walletOption) {
|
|
142
|
-
|
|
142
|
+
reject(new DynamicError('Invalid wallet option key provided.'));
|
|
143
|
+
return;
|
|
143
144
|
}
|
|
144
|
-
if (selectGroupIfAvailable &&
|
|
145
|
+
if (selectGroupIfAvailable &&
|
|
146
|
+
walletGroup &&
|
|
147
|
+
isWalletGroup(walletGroup)) {
|
|
145
148
|
navigateToWalletGroup(walletGroup);
|
|
146
149
|
}
|
|
147
150
|
else if (isHardwareWalletConnector(walletOption.walletConnector) &&
|
|
@@ -155,6 +158,40 @@ const useWalletOptions = () => {
|
|
|
155
158
|
handleWalletItemClick(walletOption);
|
|
156
159
|
}
|
|
157
160
|
setShowAuthFlow(true);
|
|
161
|
+
const walletAdded = (wallet) => {
|
|
162
|
+
if (wallet.key !== walletKey) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
resolve(wallet);
|
|
166
|
+
setShowAuthFlow(false);
|
|
167
|
+
cleanup();
|
|
168
|
+
};
|
|
169
|
+
const walletConnectionFailed = (walletConnector, error) => {
|
|
170
|
+
if (walletConnector.key !== walletKey) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
reject(error);
|
|
174
|
+
setShowAuthFlow(false);
|
|
175
|
+
cleanup();
|
|
176
|
+
};
|
|
177
|
+
const authFailure = (method, reason) => {
|
|
178
|
+
if (method.type !== 'wallet' ||
|
|
179
|
+
method.connectorName !== walletOption.walletConnector.name) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const error = typeof reason === 'object' ? reason.error : reason;
|
|
183
|
+
reject(error);
|
|
184
|
+
setShowAuthFlow(false);
|
|
185
|
+
cleanup();
|
|
186
|
+
};
|
|
187
|
+
const cleanup = () => {
|
|
188
|
+
dynamicEvents.off('walletConnectionFailed', walletConnectionFailed);
|
|
189
|
+
dynamicEvents.off('authFailure', authFailure);
|
|
190
|
+
dynamicEvents.off('walletAdded', walletAdded);
|
|
191
|
+
};
|
|
192
|
+
dynamicEvents.on('walletAdded', walletAdded);
|
|
193
|
+
dynamicEvents.on('walletConnectionFailed', walletConnectionFailed);
|
|
194
|
+
dynamicEvents.on('authFailure', authFailure);
|
|
158
195
|
}), [
|
|
159
196
|
handleWalletItemClick,
|
|
160
197
|
navigateToWalletGroup,
|
|
@@ -12,8 +12,8 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
12
12
|
require('@dynamic-labs-sdk/client/core');
|
|
13
13
|
require('@dynamic-labs-sdk/client');
|
|
14
14
|
require('../../client/client.cjs');
|
|
15
|
-
var findEmbeddedWalletFromVerifiedCredentials = require('../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
|
|
16
15
|
require('@dynamic-labs/utils');
|
|
16
|
+
var findEmbeddedWalletFromVerifiedCredentials = require('../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
|
|
17
17
|
require('../../utils/constants/values.cjs');
|
|
18
18
|
require('@dynamic-labs/multi-wallet');
|
|
19
19
|
var logger = require('../../shared/logger.cjs');
|
|
@@ -8,8 +8,8 @@ import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-cor
|
|
|
8
8
|
import '@dynamic-labs-sdk/client/core';
|
|
9
9
|
import '@dynamic-labs-sdk/client';
|
|
10
10
|
import '../../client/client.js';
|
|
11
|
-
import { findEmbeddedWalletFromVerifiedCredentials } from '../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
|
|
12
11
|
import '@dynamic-labs/utils';
|
|
12
|
+
import { findEmbeddedWalletFromVerifiedCredentials } from '../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
|
|
13
13
|
import '../../utils/constants/values.js';
|
|
14
14
|
import '@dynamic-labs/multi-wallet';
|
|
15
15
|
import { logger } from '../../shared/logger.js';
|
|
@@ -7,18 +7,18 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactI18next = require('react-i18next');
|
|
9
9
|
var utils = require('@dynamic-labs/utils');
|
|
10
|
+
var noWalletFound = require('../../assets/no-wallet-found.cjs');
|
|
10
11
|
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
11
12
|
var Search = require('../../components/Search/Search.cjs');
|
|
12
13
|
var Skeleton = require('../../components/Skeleton/Skeleton.cjs');
|
|
13
14
|
var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
|
|
14
15
|
var DefaultFooter = require('../../layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.cjs');
|
|
15
|
-
var useEffectOnce = require('../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
16
|
-
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
17
|
-
var localStorage = require('../../utils/constants/localStorage.cjs');
|
|
18
16
|
var projectSettings = require('../../store/state/projectSettings/projectSettings.cjs');
|
|
17
|
+
var localStorage = require('../../utils/constants/localStorage.cjs');
|
|
18
|
+
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
19
|
+
var useEffectOnce = require('../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
19
20
|
var convertExchangeKeyAndProviderEnum = require('../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
20
21
|
var SearchNotFoundMessage = require('../WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs');
|
|
21
|
-
var noWalletFound = require('../../assets/no-wallet-found.cjs');
|
|
22
22
|
var ExchangeListItem = require('./ExchangeListItem/ExchangeListItem.cjs');
|
|
23
23
|
|
|
24
24
|
const ExchangeList = ({ onSelectExchange, showDefaultFooter, scrollContainerClassName, }) => {
|
|
@@ -79,7 +79,7 @@ const ExchangeList = ({ onSelectExchange, showDefaultFooter, scrollContainerClas
|
|
|
79
79
|
'exchange-list__scroll-container--fixed-height': false,
|
|
80
80
|
}), "data-testid": 'exchange-list-scroll-container', ref: exchangeListScrollRef, onScroll: handleScroll, children: !projectSettings$1 ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: 10, className: 'exchange-list__tile-skeleton' })) : (
|
|
81
81
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
82
|
-
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [exchangeNames.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { copykey: 'dyn_exchange_list.no_exchange', children: t('dyn_exchange_list.no_exchanges') })), exchangeNames.length && filteredExchangeNames.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, {
|
|
82
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [exchangeNames.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { copykey: 'dyn_exchange_list.no_exchange', children: t('dyn_exchange_list.no_exchanges') })), exchangeNames.length && filteredExchangeNames.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, { titleKey: 'dyn_exchange_list.search.not_found.title', subtitleKey: 'dyn_exchange_list.search.not_found.description', image: jsxRuntime.jsx(noWalletFound.ReactComponent, {}) })) : (filteredExchangeNames.map((exchange, index) => (jsxRuntime.jsx(ExchangeListItem.ExchangeListItem, { exchange: convertExchangeKeyAndProviderEnum.convertProviderToExchangeKeyEnum(exchange), onResetSearchValue: () => handleFilterValueChange(''), onSelectExchange: onSelectExchange }, `${exchange}_${index}`))))] })) }), showDefaultFooter && (jsxRuntime.jsx(DefaultFooter.DefaultFooter, { hideBorder: !footerBorderIsVisible }))] }));
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
exports.ExchangeList = ExchangeList;
|