@dynamic-labs/sdk-react-core 4.71.0 → 4.72.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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.cjs +15 -0
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.d.ts +1 -0
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.js +11 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.cjs +11 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.d.ts +1 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.js +7 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.cjs +33 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.d.ts +16 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.js +29 -0
- package/src/lib/client/extension/functions/getSessionKeys/getSessionKeys.d.ts +1 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.cjs +5 -9
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.d.ts +4 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js +6 -10
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.cjs +51 -0
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.d.ts +1 -0
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.js +47 -0
- package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs +5 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js +5 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +2 -0
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +2 -0
- package/src/lib/client/extension/index.d.ts +4 -0
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +2 -2
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +0 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +0 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +3 -4
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +3 -4
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +10 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +0 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +0 -2
- package/src/lib/data/api/api.cjs +1 -1
- package/src/lib/data/api/api.js +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +2 -4
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -4
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.cjs +2 -0
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.d.ts +3 -3
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.js +2 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +0 -88
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +0 -25
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +2 -83
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +0 -2
- package/src/lib/utils/hooks/index.d.ts +0 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -12
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -12
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -1
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +2 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -3
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -3
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +14 -14
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +14 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +14 -38
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +14 -38
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.types.d.ts +3 -2
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.cjs +4 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.js +4 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.cjs +22 -6
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.js +22 -6
- package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.cjs +5 -1
- package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.js +5 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +0 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +0 -2
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
- package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.cjs +1 -109
- package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.js +1 -109
- package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.cjs +1 -2
- package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.js +1 -2
- package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.cjs +2 -96
- package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.js +2 -96
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +60 -5
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +61 -6
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +12 -54
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +12 -54
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js +2 -2
- package/src/lib/utils/functions/clientSessionKeys/constants.cjs +0 -8
- package/src/lib/utils/functions/clientSessionKeys/constants.js +0 -4
- package/src/lib/utils/hooks/useClientSessionKeys/index.d.ts +0 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +0 -101
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.d.ts +0 -4
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +0 -97
|
@@ -19,8 +19,9 @@ var backupArrow = require('../../../../../shared/assets/backupArrow.cjs');
|
|
|
19
19
|
var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
|
|
20
20
|
var exportPrivateKey = require('../../../../../shared/assets/export-private-key.cjs');
|
|
21
21
|
var exportRecoveryPhrase = require('../../../../../shared/assets/export-recovery-phrase.cjs');
|
|
22
|
+
var lock = require('../../../../../shared/assets/lock.cjs');
|
|
22
23
|
var ViewContext = require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
23
|
-
require('../../../../../shared/logger.cjs');
|
|
24
|
+
var logger = require('../../../../../shared/logger.cjs');
|
|
24
25
|
require('@dynamic-labs/wallet-book');
|
|
25
26
|
require('@dynamic-labs/utils');
|
|
26
27
|
require('../../../../../utils/constants/colors.cjs');
|
|
@@ -86,7 +87,7 @@ require('qrcode');
|
|
|
86
87
|
require('formik');
|
|
87
88
|
require('../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
88
89
|
require('../../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
89
|
-
require('../../../context/DynamicWidgetContext.cjs');
|
|
90
|
+
var DynamicWidgetContext = require('../../../context/DynamicWidgetContext.cjs');
|
|
90
91
|
require('../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
|
|
91
92
|
var useWalletBackup = require('../../../../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
|
|
92
93
|
require('../../../../../utils/hooks/useWalletBackup/types.cjs');
|
|
@@ -102,6 +103,7 @@ require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs
|
|
|
102
103
|
require('../../../../../context/FooterAnimationContext/index.cjs');
|
|
103
104
|
require('../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
104
105
|
require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
106
|
+
var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
105
107
|
require('../../../../../context/OnrampContext/OnrampContext.cjs');
|
|
106
108
|
require('../../../../../store/state/sendBalances.cjs');
|
|
107
109
|
require('../../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
@@ -110,6 +112,7 @@ require('../../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
|
110
112
|
require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
111
113
|
require('../../../components/PasskeyCard/PasskeyCard.cjs');
|
|
112
114
|
var useEmbeddedReveal = require('../../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs');
|
|
115
|
+
var useIsPasswordEncrypted = require('../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
|
|
113
116
|
require('../../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
114
117
|
require('../../../../../../index.cjs');
|
|
115
118
|
require('../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs');
|
|
@@ -118,18 +121,23 @@ require('../../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
|
118
121
|
require('../../../../../store/state/tokenBalances.cjs');
|
|
119
122
|
require('../../../../../store/state/multichainBalances.cjs');
|
|
120
123
|
require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
124
|
+
var useIsMfaRequiredForAction = require('../../../../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs');
|
|
121
125
|
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
122
126
|
|
|
123
127
|
const EmbeddedWalletExportSection = () => {
|
|
124
128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
125
129
|
const { t } = reactI18next.useTranslation();
|
|
126
130
|
const { theme } = ThemeContext.useThemeContext();
|
|
131
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
127
132
|
const { primaryWallet, user, projectSettings, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
128
133
|
const { pushView } = ViewContext.useViewContext();
|
|
129
134
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
135
|
+
const { setPassword } = useWalletPassword.useWalletPassword();
|
|
136
|
+
const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
|
|
130
137
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
131
138
|
const { initExportProcess } = useEmbeddedReveal.useEmbeddedReveal();
|
|
132
|
-
const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
|
|
139
|
+
const { isStepUpRequired, promptMfa, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
|
|
140
|
+
const isMfaRequiredForAction = useIsMfaRequiredForAction.useIsMfaRequiredForAction();
|
|
133
141
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
134
142
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
135
143
|
const isEmbeddedWallet = Boolean(wallet &&
|
|
@@ -141,8 +149,34 @@ const EmbeddedWalletExportSection = () => {
|
|
|
141
149
|
const isSessionKeyCompatible = (primaryWallet && walletConnectorCore.isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
142
150
|
(eoaWallet && walletConnectorCore.isSessionKeyCompatibleWallet(eoaWallet));
|
|
143
151
|
const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
|
|
152
|
+
const shouldShowPasswordSetup = isV3WaasWallet;
|
|
153
|
+
const handlePasscodeClick = React.useCallback(() => {
|
|
154
|
+
setDynamicWidgetView('setup-password', {
|
|
155
|
+
onComplete: (password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
157
|
+
logger.logger.error('No wallet address or chain available for password setup');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
yield setPassword({
|
|
161
|
+
accountAddress: wallet.address,
|
|
162
|
+
chainName: wallet.chain,
|
|
163
|
+
newPassword: password,
|
|
164
|
+
});
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
}, [setDynamicWidgetView, wallet, setPassword]);
|
|
168
|
+
const handleResetPasswordClick = React.useCallback(() => {
|
|
169
|
+
setShowAuthFlow(true, {
|
|
170
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
171
|
+
performMultiWalletChecks: false,
|
|
172
|
+
});
|
|
173
|
+
pushView('reset-password-flow');
|
|
174
|
+
}, [setShowAuthFlow, pushView]);
|
|
144
175
|
const handleExportClick = React.useCallback((recoveryPhrase) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
-
|
|
176
|
+
const stepUpRequired = yield isStepUpRequired({
|
|
177
|
+
scope: sdkApiCore.TokenScope.Walletexport,
|
|
178
|
+
});
|
|
179
|
+
if (stepUpRequired) {
|
|
146
180
|
try {
|
|
147
181
|
yield promptStepUpAuth({
|
|
148
182
|
requestedScopes: [sdkApiCore.TokenScope.Walletexport],
|
|
@@ -152,6 +186,19 @@ const EmbeddedWalletExportSection = () => {
|
|
|
152
186
|
return;
|
|
153
187
|
}
|
|
154
188
|
}
|
|
189
|
+
else {
|
|
190
|
+
const isMfaRequired = yield isMfaRequiredForAction({
|
|
191
|
+
mfaAction: sdkApiCore.MFAAction.WalletWaasExport,
|
|
192
|
+
});
|
|
193
|
+
if (isMfaRequired) {
|
|
194
|
+
try {
|
|
195
|
+
yield promptMfa({ createMfaToken: true });
|
|
196
|
+
}
|
|
197
|
+
catch (_m) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
155
202
|
if (!isSessionKeyCompatible) {
|
|
156
203
|
if (yield shouldInitRecovery()) {
|
|
157
204
|
yield initPasskeyRecoveryProcess(undefined, {
|
|
@@ -163,6 +210,8 @@ const EmbeddedWalletExportSection = () => {
|
|
|
163
210
|
}), [
|
|
164
211
|
isStepUpRequired,
|
|
165
212
|
promptStepUpAuth,
|
|
213
|
+
isMfaRequiredForAction,
|
|
214
|
+
promptMfa,
|
|
166
215
|
shouldInitRecovery,
|
|
167
216
|
initPasskeyRecoveryProcess,
|
|
168
217
|
initExportProcess,
|
|
@@ -194,7 +243,13 @@ const EmbeddedWalletExportSection = () => {
|
|
|
194
243
|
if (!isEmbeddedWallet) {
|
|
195
244
|
return null;
|
|
196
245
|
}
|
|
197
|
-
return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.
|
|
246
|
+
return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.wallet_security_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.wallet_security_section.title') }) }), shouldShowPasswordSetup && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
247
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
248
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
|
|
249
|
+
? 'dyn_settings.account_security.password.reset_button'
|
|
250
|
+
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
251
|
+
? t('dyn_settings.account_security.password.reset_button')
|
|
252
|
+
: t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
198
253
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
199
254
|
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(backupArrow.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: areAllWalletsBackedUp ? (jsxRuntime.jsx(Badge.Badge, { variant: 'primary', text: t('dyn_waas.backup.backed_up'), copykey: 'dyn_waas.backup.backed_up' })) : (jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' })), showInternalLoading: false }))] }));
|
|
200
255
|
};
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { TokenScope, WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { TokenScope, MFAAction, WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-core';
|
|
8
8
|
import { Badge } from '../../../../../components/Badge/Badge.js';
|
|
9
9
|
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
@@ -15,8 +15,9 @@ import { ReactComponent as SvgBackupArrow } from '../../../../../shared/assets/b
|
|
|
15
15
|
import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/chevron-left.js';
|
|
16
16
|
import { ReactComponent as SvgExportPrivateKey } from '../../../../../shared/assets/export-private-key.js';
|
|
17
17
|
import { ReactComponent as SvgExportRecoveryPhrase } from '../../../../../shared/assets/export-recovery-phrase.js';
|
|
18
|
+
import { ReactComponent as SvgLock } from '../../../../../shared/assets/lock.js';
|
|
18
19
|
import { useViewContext } from '../../../../../context/ViewContext/ViewContext.js';
|
|
19
|
-
import '../../../../../shared/logger.js';
|
|
20
|
+
import { logger } from '../../../../../shared/logger.js';
|
|
20
21
|
import '@dynamic-labs/wallet-book';
|
|
21
22
|
import '@dynamic-labs/utils';
|
|
22
23
|
import '../../../../../utils/constants/colors.js';
|
|
@@ -82,7 +83,7 @@ import 'qrcode';
|
|
|
82
83
|
import 'formik';
|
|
83
84
|
import '../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
84
85
|
import '../../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
85
|
-
import '../../../context/DynamicWidgetContext.js';
|
|
86
|
+
import { useWidgetContext } from '../../../context/DynamicWidgetContext.js';
|
|
86
87
|
import '../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
|
|
87
88
|
import { useWalletBackup } from '../../../../../utils/hooks/useWalletBackup/useWalletBackup.js';
|
|
88
89
|
import '../../../../../utils/hooks/useWalletBackup/types.js';
|
|
@@ -98,6 +99,7 @@ import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
|
98
99
|
import '../../../../../context/FooterAnimationContext/index.js';
|
|
99
100
|
import '../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
100
101
|
import '../../../../../context/PasskeyContext/PasskeyContext.js';
|
|
102
|
+
import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
101
103
|
import '../../../../../context/OnrampContext/OnrampContext.js';
|
|
102
104
|
import '../../../../../store/state/sendBalances.js';
|
|
103
105
|
import '../../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
@@ -106,6 +108,7 @@ import '../../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
|
106
108
|
import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
107
109
|
import '../../../components/PasskeyCard/PasskeyCard.js';
|
|
108
110
|
import { useEmbeddedReveal } from '../../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js';
|
|
111
|
+
import { useIsPasswordEncrypted } from '../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js';
|
|
109
112
|
import '../../CryptoComOnramp/CryptoComOnramp.js';
|
|
110
113
|
import '../../../../../../index.js';
|
|
111
114
|
import '../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js';
|
|
@@ -114,18 +117,23 @@ import '../../ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
|
114
117
|
import '../../../../../store/state/tokenBalances.js';
|
|
115
118
|
import '../../../../../store/state/multichainBalances.js';
|
|
116
119
|
import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
120
|
+
import { useIsMfaRequiredForAction } from '../../../../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js';
|
|
117
121
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
118
122
|
|
|
119
123
|
const EmbeddedWalletExportSection = () => {
|
|
120
124
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
121
125
|
const { t } = useTranslation();
|
|
122
126
|
const { theme } = useThemeContext();
|
|
127
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
123
128
|
const { primaryWallet, user, projectSettings, setShowAuthFlow } = useInternalDynamicContext();
|
|
124
129
|
const { pushView } = useViewContext();
|
|
125
130
|
const { getEOAWallet } = useSmartWallets();
|
|
131
|
+
const { setPassword } = useWalletPassword();
|
|
132
|
+
const isPasswordEncrypted = useIsPasswordEncrypted();
|
|
126
133
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
127
134
|
const { initExportProcess } = useEmbeddedReveal();
|
|
128
|
-
const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication();
|
|
135
|
+
const { isStepUpRequired, promptMfa, promptStepUpAuth } = useStepUpAuthentication();
|
|
136
|
+
const isMfaRequiredForAction = useIsMfaRequiredForAction();
|
|
129
137
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
130
138
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
131
139
|
const isEmbeddedWallet = Boolean(wallet &&
|
|
@@ -137,8 +145,34 @@ const EmbeddedWalletExportSection = () => {
|
|
|
137
145
|
const isSessionKeyCompatible = (primaryWallet && isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
138
146
|
(eoaWallet && isSessionKeyCompatibleWallet(eoaWallet));
|
|
139
147
|
const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
|
|
148
|
+
const shouldShowPasswordSetup = isV3WaasWallet;
|
|
149
|
+
const handlePasscodeClick = useCallback(() => {
|
|
150
|
+
setDynamicWidgetView('setup-password', {
|
|
151
|
+
onComplete: (password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
153
|
+
logger.error('No wallet address or chain available for password setup');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
yield setPassword({
|
|
157
|
+
accountAddress: wallet.address,
|
|
158
|
+
chainName: wallet.chain,
|
|
159
|
+
newPassword: password,
|
|
160
|
+
});
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
}, [setDynamicWidgetView, wallet, setPassword]);
|
|
164
|
+
const handleResetPasswordClick = useCallback(() => {
|
|
165
|
+
setShowAuthFlow(true, {
|
|
166
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
167
|
+
performMultiWalletChecks: false,
|
|
168
|
+
});
|
|
169
|
+
pushView('reset-password-flow');
|
|
170
|
+
}, [setShowAuthFlow, pushView]);
|
|
140
171
|
const handleExportClick = useCallback((recoveryPhrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
|
|
172
|
+
const stepUpRequired = yield isStepUpRequired({
|
|
173
|
+
scope: TokenScope.Walletexport,
|
|
174
|
+
});
|
|
175
|
+
if (stepUpRequired) {
|
|
142
176
|
try {
|
|
143
177
|
yield promptStepUpAuth({
|
|
144
178
|
requestedScopes: [TokenScope.Walletexport],
|
|
@@ -148,6 +182,19 @@ const EmbeddedWalletExportSection = () => {
|
|
|
148
182
|
return;
|
|
149
183
|
}
|
|
150
184
|
}
|
|
185
|
+
else {
|
|
186
|
+
const isMfaRequired = yield isMfaRequiredForAction({
|
|
187
|
+
mfaAction: MFAAction.WalletWaasExport,
|
|
188
|
+
});
|
|
189
|
+
if (isMfaRequired) {
|
|
190
|
+
try {
|
|
191
|
+
yield promptMfa({ createMfaToken: true });
|
|
192
|
+
}
|
|
193
|
+
catch (_m) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
151
198
|
if (!isSessionKeyCompatible) {
|
|
152
199
|
if (yield shouldInitRecovery()) {
|
|
153
200
|
yield initPasskeyRecoveryProcess(undefined, {
|
|
@@ -159,6 +206,8 @@ const EmbeddedWalletExportSection = () => {
|
|
|
159
206
|
}), [
|
|
160
207
|
isStepUpRequired,
|
|
161
208
|
promptStepUpAuth,
|
|
209
|
+
isMfaRequiredForAction,
|
|
210
|
+
promptMfa,
|
|
162
211
|
shouldInitRecovery,
|
|
163
212
|
initPasskeyRecoveryProcess,
|
|
164
213
|
initExportProcess,
|
|
@@ -190,7 +239,13 @@ const EmbeddedWalletExportSection = () => {
|
|
|
190
239
|
if (!isEmbeddedWallet) {
|
|
191
240
|
return null;
|
|
192
241
|
}
|
|
193
|
-
return (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: jsx(Typography, { copykey: 'dyn_settings.
|
|
242
|
+
return (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: jsx(Typography, { copykey: 'dyn_settings.wallet_security_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.wallet_security_section.title') }) }), shouldShowPasswordSetup && (jsx(TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
243
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
244
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgLock, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
|
|
245
|
+
? 'dyn_settings.account_security.password.reset_button'
|
|
246
|
+
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
247
|
+
? t('dyn_settings.account_security.password.reset_button')
|
|
248
|
+
: t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), jsx(TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsx(TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsx(TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
194
249
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
195
250
|
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgBackupArrow, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: areAllWalletsBackedUp ? (jsx(Badge, { variant: 'primary', text: t('dyn_waas.backup.backed_up'), copykey: 'dyn_waas.backup.backed_up' })) : (jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' })), showInternalLoading: false }))] }));
|
|
196
251
|
};
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs
CHANGED
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var React = require('react');
|
|
9
8
|
var reactI18next = require('react-i18next');
|
|
10
9
|
var Typography = require('../../../../../components/Typography/Typography.cjs');
|
|
11
10
|
var TypographyButton = require('../../../../../components/TypographyButton/TypographyButton.cjs');
|
|
12
|
-
require('../../../../../context/DynamicContext/DynamicContext.cjs');
|
|
13
|
-
require('../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
14
|
-
require('@dynamic-labs/iconic');
|
|
15
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
16
11
|
var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
|
|
17
12
|
var faceId = require('../../../../../shared/assets/face-id.cjs');
|
|
18
13
|
var lock = require('../../../../../shared/assets/lock.cjs');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
require('
|
|
14
|
+
require('@dynamic-labs/iconic');
|
|
15
|
+
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
+
require('../../../../../events/dynamicEvents.cjs');
|
|
17
|
+
require('../../../../../../../_virtual/_tslib.cjs');
|
|
22
18
|
require('@dynamic-labs/utils');
|
|
19
|
+
require('../../../../../context/DynamicContext/DynamicContext.cjs');
|
|
20
|
+
require('../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
21
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
22
|
+
require('../../../../../shared/logger.cjs');
|
|
23
|
+
require('@dynamic-labs/wallet-book');
|
|
23
24
|
require('../../../../../utils/constants/colors.cjs');
|
|
24
25
|
require('../../../../../utils/constants/values.cjs');
|
|
25
26
|
require('@dynamic-labs/sdk-api-core');
|
|
26
27
|
require('../../../../../shared/consts/index.cjs');
|
|
27
|
-
require('../../../../../
|
|
28
|
+
require('../../../../../store/state/authMode/authMode.cjs');
|
|
28
29
|
require('../../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
29
30
|
require('../../../../../context/ErrorContext/ErrorContext.cjs');
|
|
30
31
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -42,13 +43,11 @@ require('../../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTy
|
|
|
42
43
|
require('../../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
43
44
|
require('../../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
44
45
|
require('../../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
45
|
-
require('../../../../../store/state/authMode/authMode.cjs');
|
|
46
46
|
require('../../../../../context/VerificationContext/VerificationContext.cjs');
|
|
47
47
|
require('react-dom');
|
|
48
48
|
require('../../../../../utils/functions/compareChains/compareChains.cjs');
|
|
49
49
|
require('../../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
50
50
|
require('../../../../../context/ThemeContext/ThemeContext.cjs');
|
|
51
|
-
var useSmartWallets = require('../../../../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
52
51
|
require('../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
53
52
|
require('bs58');
|
|
54
53
|
require('@dynamic-labs/types');
|
|
@@ -98,7 +97,6 @@ require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs
|
|
|
98
97
|
require('../../../../../context/FooterAnimationContext/index.cjs');
|
|
99
98
|
require('../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
100
99
|
require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
101
|
-
var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
102
100
|
require('../../../../../context/OnrampContext/OnrampContext.cjs');
|
|
103
101
|
require('../../../../../store/state/sendBalances.cjs');
|
|
104
102
|
require('../../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
@@ -106,7 +104,6 @@ require('../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCard
|
|
|
106
104
|
require('../../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
107
105
|
require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
108
106
|
require('../../../components/PasskeyCard/PasskeyCard.cjs');
|
|
109
|
-
var useIsPasswordEncrypted = require('../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
|
|
110
107
|
require('../../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
111
108
|
require('../../../../../../index.cjs');
|
|
112
109
|
require('../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs');
|
|
@@ -118,60 +115,21 @@ require('../../../../../store/state/tokenBalances.cjs');
|
|
|
118
115
|
require('../../../../../store/state/multichainBalances.cjs');
|
|
119
116
|
require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
120
117
|
var useIsPasskeysMfaEnabled = require('../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs');
|
|
121
|
-
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
122
118
|
|
|
123
119
|
const MfaSection = ({ isLoading }) => {
|
|
124
|
-
var _a, _b;
|
|
125
120
|
const { t } = reactI18next.useTranslation();
|
|
126
121
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
127
|
-
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
128
|
-
const { pushView } = ViewContext.useViewContext();
|
|
129
|
-
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
130
|
-
const { setPassword } = useWalletPassword.useWalletPassword();
|
|
131
|
-
const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
|
|
132
122
|
const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
|
|
133
123
|
const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
|
|
134
124
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled.useIsPasskeysMfaEnabled();
|
|
135
|
-
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
136
|
-
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
137
|
-
const isWaasWallet = Boolean(wallet && ((_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.startsWith('dynamicwaas')));
|
|
138
|
-
const shouldShowPasswordSetup = isWaasWallet;
|
|
139
125
|
const handleTotpMfaClick = React.useCallback(() => setDynamicWidgetView('manage-totp-mfa'), [setDynamicWidgetView]);
|
|
140
126
|
const handlePasskeyMfaClick = React.useCallback(() => setDynamicWidgetView('manage-passkeys-mfa'), [setDynamicWidgetView]);
|
|
141
|
-
|
|
142
|
-
setDynamicWidgetView('setup-password', {
|
|
143
|
-
onComplete: (password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
145
|
-
logger.logger.error('No wallet address or chain available for password setup');
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
yield setPassword({
|
|
149
|
-
accountAddress: wallet.address,
|
|
150
|
-
chainName: wallet.chain,
|
|
151
|
-
newPassword: password,
|
|
152
|
-
});
|
|
153
|
-
}),
|
|
154
|
-
});
|
|
155
|
-
}, [setDynamicWidgetView, wallet, setPassword]);
|
|
156
|
-
const handleResetPasswordClick = React.useCallback(() => {
|
|
157
|
-
setShowAuthFlow(true, {
|
|
158
|
-
ignoreIfIsEmbeddedWidget: false,
|
|
159
|
-
performMultiWalletChecks: false,
|
|
160
|
-
});
|
|
161
|
-
pushView('reset-password-flow');
|
|
162
|
-
}, [setShowAuthFlow, pushView]);
|
|
163
|
-
if (!isMfaEnabled && !isWaasWallet) {
|
|
127
|
+
if (!isMfaEnabled) {
|
|
164
128
|
return null;
|
|
165
129
|
}
|
|
166
130
|
return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.mfa_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.mfa_section.title') }) }), isPasskeyMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-passkeys-mfa-button', onClick: handlePasskeyMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
167
131
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
168
|
-
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(faceId.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })),
|
|
169
|
-
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
170
|
-
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
|
|
171
|
-
? 'dyn_settings.account_security.password.reset_button'
|
|
172
|
-
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
173
|
-
? t('dyn_settings.account_security.password.reset_button')
|
|
174
|
-
: t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
132
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(faceId.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
175
133
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
176
134
|
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.totp_button', children: t('dyn_settings.mfa_section.totp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false }))] }));
|
|
177
135
|
};
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
3
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
3
|
import { useCallback } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
7
6
|
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
8
|
-
import '../../../../../context/DynamicContext/DynamicContext.js';
|
|
9
|
-
import '../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
10
|
-
import '@dynamic-labs/iconic';
|
|
11
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
12
7
|
import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/chevron-left.js';
|
|
13
8
|
import { ReactComponent as SvgFaceId } from '../../../../../shared/assets/face-id.js';
|
|
14
9
|
import { ReactComponent as SvgLock } from '../../../../../shared/assets/lock.js';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import '
|
|
10
|
+
import '@dynamic-labs/iconic';
|
|
11
|
+
import '../../../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import '../../../../../events/dynamicEvents.js';
|
|
13
|
+
import '../../../../../../../_virtual/_tslib.js';
|
|
18
14
|
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../../../../context/DynamicContext/DynamicContext.js';
|
|
16
|
+
import '../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
17
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
18
|
+
import '../../../../../shared/logger.js';
|
|
19
|
+
import '@dynamic-labs/wallet-book';
|
|
19
20
|
import '../../../../../utils/constants/colors.js';
|
|
20
21
|
import '../../../../../utils/constants/values.js';
|
|
21
22
|
import '@dynamic-labs/sdk-api-core';
|
|
22
23
|
import '../../../../../shared/consts/index.js';
|
|
23
|
-
import '../../../../../
|
|
24
|
+
import '../../../../../store/state/authMode/authMode.js';
|
|
24
25
|
import '../../../../../context/CaptchaContext/CaptchaContext.js';
|
|
25
26
|
import '../../../../../context/ErrorContext/ErrorContext.js';
|
|
26
27
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -38,13 +39,11 @@ import '../../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTyp
|
|
|
38
39
|
import '../../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
39
40
|
import '../../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
40
41
|
import '../../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
41
|
-
import '../../../../../store/state/authMode/authMode.js';
|
|
42
42
|
import '../../../../../context/VerificationContext/VerificationContext.js';
|
|
43
43
|
import 'react-dom';
|
|
44
44
|
import '../../../../../utils/functions/compareChains/compareChains.js';
|
|
45
45
|
import '../../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
46
46
|
import '../../../../../context/ThemeContext/ThemeContext.js';
|
|
47
|
-
import { useSmartWallets } from '../../../../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
48
47
|
import '../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
49
48
|
import 'bs58';
|
|
50
49
|
import '@dynamic-labs/types';
|
|
@@ -94,7 +93,6 @@ import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
|
94
93
|
import '../../../../../context/FooterAnimationContext/index.js';
|
|
95
94
|
import '../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
96
95
|
import '../../../../../context/PasskeyContext/PasskeyContext.js';
|
|
97
|
-
import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
98
96
|
import '../../../../../context/OnrampContext/OnrampContext.js';
|
|
99
97
|
import '../../../../../store/state/sendBalances.js';
|
|
100
98
|
import '../../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
@@ -102,7 +100,6 @@ import '../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardT
|
|
|
102
100
|
import '../../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
103
101
|
import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
104
102
|
import '../../../components/PasskeyCard/PasskeyCard.js';
|
|
105
|
-
import { useIsPasswordEncrypted } from '../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js';
|
|
106
103
|
import '../../CryptoComOnramp/CryptoComOnramp.js';
|
|
107
104
|
import '../../../../../../index.js';
|
|
108
105
|
import '../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js';
|
|
@@ -114,60 +111,21 @@ import '../../../../../store/state/tokenBalances.js';
|
|
|
114
111
|
import '../../../../../store/state/multichainBalances.js';
|
|
115
112
|
import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
116
113
|
import { useIsPasskeysMfaEnabled } from '../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js';
|
|
117
|
-
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
118
114
|
|
|
119
115
|
const MfaSection = ({ isLoading }) => {
|
|
120
|
-
var _a, _b;
|
|
121
116
|
const { t } = useTranslation();
|
|
122
117
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
123
|
-
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
124
|
-
const { pushView } = useViewContext();
|
|
125
|
-
const { getEOAWallet } = useSmartWallets();
|
|
126
|
-
const { setPassword } = useWalletPassword();
|
|
127
|
-
const isPasswordEncrypted = useIsPasswordEncrypted();
|
|
128
118
|
const isMfaEnabled = useIsMfaEnabled();
|
|
129
119
|
const isTotpMfaEnabled = useIsTotpMfaEnabled();
|
|
130
120
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled();
|
|
131
|
-
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
132
|
-
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
133
|
-
const isWaasWallet = Boolean(wallet && ((_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.startsWith('dynamicwaas')));
|
|
134
|
-
const shouldShowPasswordSetup = isWaasWallet;
|
|
135
121
|
const handleTotpMfaClick = useCallback(() => setDynamicWidgetView('manage-totp-mfa'), [setDynamicWidgetView]);
|
|
136
122
|
const handlePasskeyMfaClick = useCallback(() => setDynamicWidgetView('manage-passkeys-mfa'), [setDynamicWidgetView]);
|
|
137
|
-
|
|
138
|
-
setDynamicWidgetView('setup-password', {
|
|
139
|
-
onComplete: (password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
141
|
-
logger.error('No wallet address or chain available for password setup');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
yield setPassword({
|
|
145
|
-
accountAddress: wallet.address,
|
|
146
|
-
chainName: wallet.chain,
|
|
147
|
-
newPassword: password,
|
|
148
|
-
});
|
|
149
|
-
}),
|
|
150
|
-
});
|
|
151
|
-
}, [setDynamicWidgetView, wallet, setPassword]);
|
|
152
|
-
const handleResetPasswordClick = useCallback(() => {
|
|
153
|
-
setShowAuthFlow(true, {
|
|
154
|
-
ignoreIfIsEmbeddedWidget: false,
|
|
155
|
-
performMultiWalletChecks: false,
|
|
156
|
-
});
|
|
157
|
-
pushView('reset-password-flow');
|
|
158
|
-
}, [setShowAuthFlow, pushView]);
|
|
159
|
-
if (!isMfaEnabled && !isWaasWallet) {
|
|
123
|
+
if (!isMfaEnabled) {
|
|
160
124
|
return null;
|
|
161
125
|
}
|
|
162
126
|
return (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: jsx(Typography, { copykey: 'dyn_settings.mfa_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.mfa_section.title') }) }), isPasskeyMfaEnabled && (jsx(TypographyButton, { dataTestId: 'manage-passkeys-mfa-button', onClick: handlePasskeyMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
163
127
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
164
|
-
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgFaceId, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })),
|
|
165
|
-
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
166
|
-
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgLock, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
|
|
167
|
-
? 'dyn_settings.account_security.password.reset_button'
|
|
168
|
-
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
169
|
-
? t('dyn_settings.account_security.password.reset_button')
|
|
170
|
-
: t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsx(TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
128
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgFaceId, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsx(TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
171
129
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
172
130
|
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgLock, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.totp_button', children: t('dyn_settings.mfa_section.totp_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false }))] }));
|
|
173
131
|
};
|
|
@@ -127,7 +127,7 @@ const EditProfileView = ({ rootClassName, }) => {
|
|
|
127
127
|
const hasPhoneChange = formValues.phoneNumber !== undefined &&
|
|
128
128
|
formValues.phoneNumber !== (user === null || user === void 0 ? void 0 : user.phoneNumber);
|
|
129
129
|
if ((hasEmailChange || hasPhoneChange) &&
|
|
130
|
-
isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentiallink })) {
|
|
130
|
+
(yield isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentiallink }))) {
|
|
131
131
|
try {
|
|
132
132
|
yield promptStepUpAuth({
|
|
133
133
|
requestedScopes: [sdkApiCore.TokenScope.Credentiallink],
|
|
@@ -123,7 +123,7 @@ const EditProfileView = ({ rootClassName, }) => {
|
|
|
123
123
|
const hasPhoneChange = formValues.phoneNumber !== undefined &&
|
|
124
124
|
formValues.phoneNumber !== (user === null || user === void 0 ? void 0 : user.phoneNumber);
|
|
125
125
|
if ((hasEmailChange || hasPhoneChange) &&
|
|
126
|
-
isStepUpRequired({ scope: TokenScope.Credentiallink })) {
|
|
126
|
+
(yield isStepUpRequired({ scope: TokenScope.Credentiallink }))) {
|
|
127
127
|
try {
|
|
128
128
|
yield promptStepUpAuth({
|
|
129
129
|
requestedScopes: [TokenScope.Credentiallink],
|
|
@@ -150,7 +150,7 @@ const ManagePasskeysMfaWidgetView = () => {
|
|
|
150
150
|
return passkeys.map((passkey) => (jsxRuntime.jsx(PasskeyCard.PasskeyCard, { passkey: passkey, onUpdate: retrigger }, passkey.id)));
|
|
151
151
|
};
|
|
152
152
|
return (jsxRuntime.jsxs("div", { className: 'manage-totp-mfa-widget-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_manage_passkeys_mfa.title', children: t('dyn_manage_passkeys_mfa.title') }) }) }), jsxRuntime.jsx(ModalHeaderBanner.ModalHeaderBanner, { type: 'error', messageKey: registerPasskeyError ? errorMessage : undefined, className: 'manage-totp-mfa-widget-view__header-banner' }), jsxRuntime.jsx("div", { className: 'manage-totp-mfa-widget-view__scroll-container', children: getPasskeysContent() }), jsxRuntime.jsx("div", { className: 'manage-totp-mfa-widget-view__add-mfa-button-container', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'manage-totp-mfa-widget-view__add-mfa-button-container__button', onClick: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
if (isStepUpRequired({ scope: CREDENTIAL_LINK_SCOPE })) {
|
|
153
|
+
if (yield isStepUpRequired({ scope: CREDENTIAL_LINK_SCOPE })) {
|
|
154
154
|
try {
|
|
155
155
|
yield promptStepUpAuth({
|
|
156
156
|
requestedScopes: [CREDENTIAL_LINK_SCOPE],
|