@dynamic-labs/sdk-react-core 4.61.2 → 4.61.4
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 +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- 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/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasswordEncrypted/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs +132 -0
- package/src/lib/utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.d.ts +1 -0
- package/src/lib/utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js +128 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.cjs +2 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.js +3 -3
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +134 -0
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.d.ts +2 -0
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +130 -0
- package/src/lib/views/ResetPasswordForSettingsView/index.d.ts +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +19 -5
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +19 -5
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.cjs +16 -33
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.js +17 -34
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.cjs +50 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.d.ts +8 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.js +46 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +182 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.d.ts +5 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +178 -0
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +11 -4
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +3 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +11 -4
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.cjs +16 -9
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.d.ts +3 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.js +16 -9
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.js +2 -2
|
@@ -150,6 +150,7 @@ var UnlockWalletView = require('./UnlockWalletView/UnlockWalletView.cjs');
|
|
|
150
150
|
var ConfirmPasskeyView = require('./Passkey/ConfirmPasskeyView/ConfirmPasskeyView.cjs');
|
|
151
151
|
var SetupPasskeyView = require('./Passkey/SetupPasskeyView/SetupPasskeyView.cjs');
|
|
152
152
|
var PendingConnectView = require('./PendingConnectView/PendingConnectView.cjs');
|
|
153
|
+
var ResetPasswordForSettingsView = require('./ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs');
|
|
153
154
|
var SandboxMaximumThresholdReached = require('./SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.cjs');
|
|
154
155
|
var SelectHardwareWalletView = require('./SelectHardwareWalletView/SelectHardwareWalletView.cjs');
|
|
155
156
|
var SelectWalletInWalletGroupView = require('./SelectWalletInWalletGroupView/SelectWalletInWalletGroupView.cjs');
|
|
@@ -240,6 +241,7 @@ const viewToComponentMap = {
|
|
|
240
241
|
'pending-signature-without-back-button': PendingSignatureView.PendingSignatureView,
|
|
241
242
|
'qr-code': QrCodeView.QrCodeView,
|
|
242
243
|
'rename-passkey': RenamePasskeyView.RenamePasskeyView,
|
|
244
|
+
'reset-password-flow': ResetPasswordForSettingsView.ResetPasswordForSettingsView,
|
|
243
245
|
'sandbox-maximum-threshold-reached': SandboxMaximumThresholdReached.SandboxMaximumThresholdReached,
|
|
244
246
|
'select-hardware-wallet': SelectHardwareWalletView.SelectHardwareWalletView,
|
|
245
247
|
'select-wallet-in-wallet-group': SelectWalletInWalletGroupView.SelectWalletInWalletGroupView,
|
|
@@ -92,6 +92,7 @@ export declare const viewToComponentMap: {
|
|
|
92
92
|
'rename-passkey': import("react").FC<{
|
|
93
93
|
onUpdate?: (() => void) | undefined;
|
|
94
94
|
}>;
|
|
95
|
+
'reset-password-flow': import("react").FC;
|
|
95
96
|
'sandbox-maximum-threshold-reached': () => JSX.Element;
|
|
96
97
|
'select-hardware-wallet': import("react").FC<{
|
|
97
98
|
wallet: import("../shared").WalletOption;
|
|
@@ -146,6 +146,7 @@ import { UnlockWalletView } from './UnlockWalletView/UnlockWalletView.js';
|
|
|
146
146
|
import { ConfirmPasskeyView } from './Passkey/ConfirmPasskeyView/ConfirmPasskeyView.js';
|
|
147
147
|
import { SetupPasskeyView } from './Passkey/SetupPasskeyView/SetupPasskeyView.js';
|
|
148
148
|
import { PendingConnectView } from './PendingConnectView/PendingConnectView.js';
|
|
149
|
+
import { ResetPasswordForSettingsView } from './ResetPasswordForSettingsView/ResetPasswordForSettingsView.js';
|
|
149
150
|
import { SandboxMaximumThresholdReached } from './SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.js';
|
|
150
151
|
import { SelectHardwareWalletView } from './SelectHardwareWalletView/SelectHardwareWalletView.js';
|
|
151
152
|
import { SelectWalletInWalletGroupView } from './SelectWalletInWalletGroupView/SelectWalletInWalletGroupView.js';
|
|
@@ -236,6 +237,7 @@ const viewToComponentMap = {
|
|
|
236
237
|
'pending-signature-without-back-button': PendingSignatureView,
|
|
237
238
|
'qr-code': QrCodeView,
|
|
238
239
|
'rename-passkey': RenamePasskeyView,
|
|
240
|
+
'reset-password-flow': ResetPasswordForSettingsView,
|
|
239
241
|
'sandbox-maximum-threshold-reached': SandboxMaximumThresholdReached,
|
|
240
242
|
'select-hardware-wallet': SelectHardwareWalletView,
|
|
241
243
|
'select-wallet-in-wallet-group': SelectWalletInWalletGroupView,
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs
CHANGED
|
@@ -17,7 +17,7 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
17
17
|
var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
|
|
18
18
|
var faceId = require('../../../../../shared/assets/face-id.cjs');
|
|
19
19
|
var lock = require('../../../../../shared/assets/lock.cjs');
|
|
20
|
-
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
20
|
+
var ViewContext = require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
21
21
|
var logger = require('../../../../../shared/logger.cjs');
|
|
22
22
|
require('@dynamic-labs/wallet-book');
|
|
23
23
|
require('@dynamic-labs/utils');
|
|
@@ -98,6 +98,7 @@ require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs
|
|
|
98
98
|
require('../../../../../context/FooterAnimationContext/index.cjs');
|
|
99
99
|
require('../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
100
100
|
require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
101
|
+
var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
101
102
|
require('../../../../../context/OnrampContext/OnrampContext.cjs');
|
|
102
103
|
require('../../../../../store/state/sendBalances.cjs');
|
|
103
104
|
require('../../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
@@ -105,6 +106,7 @@ require('../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCard
|
|
|
105
106
|
require('../../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
106
107
|
require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
107
108
|
require('../../../components/PasskeyCard/PasskeyCard.cjs');
|
|
109
|
+
var useIsPasswordEncrypted = require('../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
|
|
108
110
|
require('../../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
109
111
|
require('../../../../../../index.cjs');
|
|
110
112
|
require('../../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
@@ -114,17 +116,18 @@ require('../../../../../store/state/tokenBalances.cjs');
|
|
|
114
116
|
require('../../../../../store/state/multichainBalances.cjs');
|
|
115
117
|
require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
116
118
|
var useIsPasskeysMfaEnabled = require('../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs');
|
|
117
|
-
var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
118
119
|
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
119
120
|
|
|
120
121
|
const MfaSection = ({ isLoading }) => {
|
|
121
122
|
var _a, _b, _c;
|
|
122
123
|
const { t } = reactI18next.useTranslation();
|
|
123
124
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
124
|
-
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
125
|
+
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
126
|
+
const { pushView } = ViewContext.useViewContext();
|
|
125
127
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
126
128
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
127
129
|
const { updatePassword } = useWalletPassword.useWalletPassword();
|
|
130
|
+
const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
|
|
128
131
|
const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
|
|
129
132
|
const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
|
|
130
133
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled.useIsPasskeysMfaEnabled();
|
|
@@ -151,14 +154,25 @@ const MfaSection = ({ isLoading }) => {
|
|
|
151
154
|
}),
|
|
152
155
|
});
|
|
153
156
|
}, [setDynamicWidgetView, wallet, updatePassword]);
|
|
157
|
+
const handleResetPasswordClick = React.useCallback(() => {
|
|
158
|
+
setShowAuthFlow(true, {
|
|
159
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
160
|
+
performMultiWalletChecks: false,
|
|
161
|
+
});
|
|
162
|
+
pushView('reset-password-flow');
|
|
163
|
+
}, [setShowAuthFlow, pushView]);
|
|
154
164
|
if (!isMfaEnabled && !isWaasWallet) {
|
|
155
165
|
return null;
|
|
156
166
|
}
|
|
157
167
|
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:
|
|
158
168
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
159
|
-
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 })), shouldShowPasswordSetup && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'password-setup-button', onClick: handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
169
|
+
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 })), shouldShowPasswordSetup && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
160
170
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
161
|
-
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:
|
|
171
|
+
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
|
|
172
|
+
? 'dyn_settings.account_security.password.reset_button'
|
|
173
|
+
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
174
|
+
? t('dyn_settings.account_security.password.reset_button')
|
|
175
|
+
: 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:
|
|
162
176
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
163
177
|
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 }))] }));
|
|
164
178
|
};
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js
CHANGED
|
@@ -13,7 +13,7 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
13
13
|
import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/chevron-left.js';
|
|
14
14
|
import { ReactComponent as SvgFaceId } from '../../../../../shared/assets/face-id.js';
|
|
15
15
|
import { ReactComponent as SvgLock } from '../../../../../shared/assets/lock.js';
|
|
16
|
-
import '../../../../../context/ViewContext/ViewContext.js';
|
|
16
|
+
import { useViewContext } from '../../../../../context/ViewContext/ViewContext.js';
|
|
17
17
|
import { logger } from '../../../../../shared/logger.js';
|
|
18
18
|
import '@dynamic-labs/wallet-book';
|
|
19
19
|
import '@dynamic-labs/utils';
|
|
@@ -94,6 +94,7 @@ import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
|
94
94
|
import '../../../../../context/FooterAnimationContext/index.js';
|
|
95
95
|
import '../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
96
96
|
import '../../../../../context/PasskeyContext/PasskeyContext.js';
|
|
97
|
+
import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
97
98
|
import '../../../../../context/OnrampContext/OnrampContext.js';
|
|
98
99
|
import '../../../../../store/state/sendBalances.js';
|
|
99
100
|
import '../../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
@@ -101,6 +102,7 @@ import '../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardT
|
|
|
101
102
|
import '../../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
102
103
|
import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
103
104
|
import '../../../components/PasskeyCard/PasskeyCard.js';
|
|
105
|
+
import { useIsPasswordEncrypted } from '../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js';
|
|
104
106
|
import '../../CryptoComOnramp/CryptoComOnramp.js';
|
|
105
107
|
import '../../../../../../index.js';
|
|
106
108
|
import '../../ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
@@ -110,17 +112,18 @@ import '../../../../../store/state/tokenBalances.js';
|
|
|
110
112
|
import '../../../../../store/state/multichainBalances.js';
|
|
111
113
|
import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
112
114
|
import { useIsPasskeysMfaEnabled } from '../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js';
|
|
113
|
-
import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
114
115
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
115
116
|
|
|
116
117
|
const MfaSection = ({ isLoading }) => {
|
|
117
118
|
var _a, _b, _c;
|
|
118
119
|
const { t } = useTranslation();
|
|
119
120
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
120
|
-
const { primaryWallet } = useInternalDynamicContext();
|
|
121
|
+
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
122
|
+
const { pushView } = useViewContext();
|
|
121
123
|
const { getEOAWallet } = useSmartWallets();
|
|
122
124
|
const projectSettings = useProjectSettings();
|
|
123
125
|
const { updatePassword } = useWalletPassword();
|
|
126
|
+
const isPasswordEncrypted = useIsPasswordEncrypted();
|
|
124
127
|
const isMfaEnabled = useIsMfaEnabled();
|
|
125
128
|
const isTotpMfaEnabled = useIsTotpMfaEnabled();
|
|
126
129
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled();
|
|
@@ -147,14 +150,25 @@ const MfaSection = ({ isLoading }) => {
|
|
|
147
150
|
}),
|
|
148
151
|
});
|
|
149
152
|
}, [setDynamicWidgetView, wallet, updatePassword]);
|
|
153
|
+
const handleResetPasswordClick = useCallback(() => {
|
|
154
|
+
setShowAuthFlow(true, {
|
|
155
|
+
ignoreIfIsEmbeddedWidget: false,
|
|
156
|
+
performMultiWalletChecks: false,
|
|
157
|
+
});
|
|
158
|
+
pushView('reset-password-flow');
|
|
159
|
+
}, [setShowAuthFlow, pushView]);
|
|
150
160
|
if (!isMfaEnabled && !isWaasWallet) {
|
|
151
161
|
return null;
|
|
152
162
|
}
|
|
153
163
|
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:
|
|
154
164
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
155
|
-
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 })), shouldShowPasswordSetup && (jsx(TypographyButton, { dataTestId: 'password-setup-button', onClick: handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
165
|
+
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 })), shouldShowPasswordSetup && (jsx(TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
156
166
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
157
|
-
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:
|
|
167
|
+
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
|
|
168
|
+
? 'dyn_settings.account_security.password.reset_button'
|
|
169
|
+
: 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
|
|
170
|
+
? t('dyn_settings.account_security.password.reset_button')
|
|
171
|
+
: 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:
|
|
158
172
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
159
173
|
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 }))] }));
|
|
160
174
|
};
|
|
@@ -8,11 +8,12 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('../../../../
|
|
14
|
-
require('
|
|
15
|
-
require('../../../../
|
|
11
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
12
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
13
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
14
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
15
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
16
|
+
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
16
17
|
require('@dynamic-labs/iconic');
|
|
17
18
|
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
18
19
|
var exportPrivateKey = require('../../../../shared/assets/export-private-key.cjs');
|
|
@@ -23,25 +24,23 @@ require('@dynamic-labs/wallet-book');
|
|
|
23
24
|
require('@dynamic-labs/utils');
|
|
24
25
|
require('../../../../utils/constants/colors.cjs');
|
|
25
26
|
require('../../../../utils/constants/values.cjs');
|
|
27
|
+
require('@dynamic-labs/sdk-api-core');
|
|
26
28
|
require('../../../../shared/consts/index.cjs');
|
|
29
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
30
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
31
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
27
32
|
require('@dynamic-labs/multi-wallet');
|
|
28
33
|
require('react-international-phone');
|
|
29
34
|
require('../../../../store/state/nonce/nonce.cjs');
|
|
35
|
+
require('@dynamic-labs-sdk/client/core');
|
|
36
|
+
require('../../../../client/client.cjs');
|
|
37
|
+
require('@dynamic-labs-sdk/client');
|
|
38
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
30
39
|
require('@dynamic-labs/locale');
|
|
31
40
|
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
41
|
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
42
|
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
34
43
|
require('../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
35
|
-
require('../../../../events/dynamicEvents.cjs');
|
|
36
|
-
var useUser = require('../../../../client/extension/user/useUser/useUser.cjs');
|
|
37
|
-
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
38
|
-
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
39
|
-
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
40
|
-
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
41
|
-
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
42
|
-
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
43
|
-
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
44
|
-
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
45
44
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
46
45
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
47
46
|
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -108,6 +107,7 @@ require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
|
108
107
|
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
109
108
|
require('../../components/PasskeyCard/PasskeyCard.cjs');
|
|
110
109
|
var useEmbeddedReveal = require('../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs');
|
|
110
|
+
var useIsPasswordEncrypted = require('../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
|
|
111
111
|
require('../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
112
112
|
require('../../../../../index.cjs');
|
|
113
113
|
require('../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
@@ -123,32 +123,15 @@ const ExportAndRecoveryView = () => {
|
|
|
123
123
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
124
124
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
125
125
|
const { pushView } = ViewContext.useViewContext();
|
|
126
|
-
const user = useUser.useUser();
|
|
127
126
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
128
127
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
129
128
|
const { initExportProcess } = useEmbeddedReveal.useEmbeddedReveal();
|
|
129
|
+
const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
|
|
130
130
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
131
131
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
132
132
|
const isSessionKeyCompatible = (primaryWallet && walletConnectorCore.isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
133
133
|
(eoaWallet && walletConnectorCore.isSessionKeyCompatibleWallet(eoaWallet));
|
|
134
134
|
const isV3WaasWallet = 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')));
|
|
135
|
-
const walletCredential = React.useMemo(() => {
|
|
136
|
-
var _a;
|
|
137
|
-
if (!user || !primaryWallet)
|
|
138
|
-
return undefined;
|
|
139
|
-
return (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((cred) => cred.walletName === 'dynamicwaas' &&
|
|
140
|
-
cred.address === primaryWallet.address);
|
|
141
|
-
}, [user, primaryWallet]);
|
|
142
|
-
const isPasswordEncrypted = React.useMemo(() => {
|
|
143
|
-
var _a;
|
|
144
|
-
const keyShares = (_a = walletCredential === null || walletCredential === void 0 ? void 0 : walletCredential.walletProperties) === null || _a === void 0 ? void 0 : _a.keyShares;
|
|
145
|
-
if (!keyShares || !Array.isArray(keyShares))
|
|
146
|
-
return false;
|
|
147
|
-
return keyShares.some((keyShare) => keyShare &&
|
|
148
|
-
typeof keyShare === 'object' &&
|
|
149
|
-
'passwordEncrypted' in keyShare &&
|
|
150
|
-
keyShare.passwordEncrypted === true);
|
|
151
|
-
}, [walletCredential]);
|
|
152
135
|
const handleBackClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
153
136
|
const handlePrivateKeyClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
154
137
|
if (!isSessionKeyCompatible) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-core';
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '../../../../
|
|
10
|
-
import '
|
|
11
|
-
import '../../../../
|
|
7
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
8
|
+
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
9
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
10
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
11
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
12
|
+
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
12
13
|
import '@dynamic-labs/iconic';
|
|
13
14
|
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
14
15
|
import { ReactComponent as SvgExportPrivateKey } from '../../../../shared/assets/export-private-key.js';
|
|
@@ -19,25 +20,23 @@ import '@dynamic-labs/wallet-book';
|
|
|
19
20
|
import '@dynamic-labs/utils';
|
|
20
21
|
import '../../../../utils/constants/colors.js';
|
|
21
22
|
import '../../../../utils/constants/values.js';
|
|
23
|
+
import '@dynamic-labs/sdk-api-core';
|
|
22
24
|
import '../../../../shared/consts/index.js';
|
|
25
|
+
import '../../../../events/dynamicEvents.js';
|
|
26
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
27
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
23
28
|
import '@dynamic-labs/multi-wallet';
|
|
24
29
|
import 'react-international-phone';
|
|
25
30
|
import '../../../../store/state/nonce/nonce.js';
|
|
31
|
+
import '@dynamic-labs-sdk/client/core';
|
|
32
|
+
import '../../../../client/client.js';
|
|
33
|
+
import '@dynamic-labs-sdk/client';
|
|
34
|
+
import '../../../../config/ApiEndpoint.js';
|
|
26
35
|
import '@dynamic-labs/locale';
|
|
27
36
|
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
37
|
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
38
|
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
30
39
|
import '../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
31
|
-
import '../../../../events/dynamicEvents.js';
|
|
32
|
-
import { useUser } from '../../../../client/extension/user/useUser/useUser.js';
|
|
33
|
-
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
34
|
-
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
35
|
-
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
36
|
-
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
37
|
-
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
38
|
-
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
39
|
-
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
40
|
-
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
41
40
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
42
41
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
43
42
|
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -104,6 +103,7 @@ import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
|
104
103
|
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
105
104
|
import '../../components/PasskeyCard/PasskeyCard.js';
|
|
106
105
|
import { useEmbeddedReveal } from '../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js';
|
|
106
|
+
import { useIsPasswordEncrypted } from '../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js';
|
|
107
107
|
import '../CryptoComOnramp/CryptoComOnramp.js';
|
|
108
108
|
import '../../../../../index.js';
|
|
109
109
|
import '../ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
@@ -119,32 +119,15 @@ const ExportAndRecoveryView = () => {
|
|
|
119
119
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
120
120
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
121
121
|
const { pushView } = useViewContext();
|
|
122
|
-
const user = useUser();
|
|
123
122
|
const { getEOAWallet } = useSmartWallets();
|
|
124
123
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
125
124
|
const { initExportProcess } = useEmbeddedReveal();
|
|
125
|
+
const isPasswordEncrypted = useIsPasswordEncrypted();
|
|
126
126
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
127
127
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
128
128
|
const isSessionKeyCompatible = (primaryWallet && isSessionKeyCompatibleWallet(primaryWallet)) ||
|
|
129
129
|
(eoaWallet && isSessionKeyCompatibleWallet(eoaWallet));
|
|
130
130
|
const isV3WaasWallet = 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')));
|
|
131
|
-
const walletCredential = useMemo(() => {
|
|
132
|
-
var _a;
|
|
133
|
-
if (!user || !primaryWallet)
|
|
134
|
-
return undefined;
|
|
135
|
-
return (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((cred) => cred.walletName === 'dynamicwaas' &&
|
|
136
|
-
cred.address === primaryWallet.address);
|
|
137
|
-
}, [user, primaryWallet]);
|
|
138
|
-
const isPasswordEncrypted = useMemo(() => {
|
|
139
|
-
var _a;
|
|
140
|
-
const keyShares = (_a = walletCredential === null || walletCredential === void 0 ? void 0 : walletCredential.walletProperties) === null || _a === void 0 ? void 0 : _a.keyShares;
|
|
141
|
-
if (!keyShares || !Array.isArray(keyShares))
|
|
142
|
-
return false;
|
|
143
|
-
return keyShares.some((keyShare) => keyShare &&
|
|
144
|
-
typeof keyShare === 'object' &&
|
|
145
|
-
'passwordEncrypted' in keyShare &&
|
|
146
|
-
keyShare.passwordEncrypted === true);
|
|
147
|
-
}, [walletCredential]);
|
|
148
131
|
const handleBackClick = useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
149
132
|
const handlePrivateKeyClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
133
|
if (!isSessionKeyCompatible) {
|
package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
10
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
11
|
+
var Input = require('../../../../components/Input/Input.cjs');
|
|
12
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
13
|
+
var ToggleVisibilityButton = require('../../../../components/ToggleVisibilityButton/ToggleVisibilityButton.cjs');
|
|
14
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
15
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
16
|
+
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
17
|
+
var errorCircleX = require('../../../../shared/assets/error-circle-x.cjs');
|
|
18
|
+
var passwordLockIcon = require('../../../../shared/assets/password-lock-icon.cjs');
|
|
19
|
+
require('@dynamic-labs/iconic');
|
|
20
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
|
|
22
|
+
const ResetPasswordCurrentView = ({ onContinue, onBack, isLoading = false, error: externalError = null, }) => {
|
|
23
|
+
const { t } = reactI18next.useTranslation();
|
|
24
|
+
const [password, setPassword] = React.useState('');
|
|
25
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
26
|
+
const [internalError, setInternalError] = React.useState(null);
|
|
27
|
+
const error = externalError !== null && externalError !== void 0 ? externalError : internalError;
|
|
28
|
+
const handlePasswordChange = React.useCallback((e) => {
|
|
29
|
+
setPassword(e.target.value);
|
|
30
|
+
setInternalError(null);
|
|
31
|
+
}, []);
|
|
32
|
+
const handleToggleVisibility = React.useCallback((hidden) => {
|
|
33
|
+
setShowPassword(!hidden);
|
|
34
|
+
}, []);
|
|
35
|
+
const handleContinue = React.useCallback(() => {
|
|
36
|
+
if (!password) {
|
|
37
|
+
setInternalError(t('dyn_reset_password.current.error.required'));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
onContinue(password);
|
|
41
|
+
}, [password, onContinue, t]);
|
|
42
|
+
const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onBack, "data-testid": 'reset-password-current-back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
43
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_reset_password.current.title', children: t('dyn_reset_password.current.title') }) }), jsxRuntime.jsx("div", { className: 'enter-password-view', children: jsxRuntime.jsxs("div", { className: 'enter-password-view__body', children: [jsxRuntime.jsx("div", { className: 'enter-password-view__icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(passwordLockIcon.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_reset_password.current.description', className: 'enter-password-view__description', children: t('dyn_reset_password.current.description') }), jsxRuntime.jsx(Input.Input, { id: 'reset-password-current-input', type: showPassword ? 'text' : 'password', label: t('dyn_reset_password.current.label'), placeholder: t('dyn_reset_password.current.placeholder'), value: password, onChange: handlePasswordChange, variant: 'regular', error: Boolean(error), message: error ? (jsxRuntime.jsxs("span", { className: 'enter-password-view__error-message', children: [jsxRuntime.jsx(errorCircleX.ReactComponent, { width: 14, height: 14 }), error] })) : undefined, suffix:
|
|
44
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
45
|
+
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), jsxRuntime.jsx("div", { className: 'enter-password-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'reset-password-current-continue-button', onClick: handleContinue, disabled: !password || isLoading, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
46
|
+
color: 'inherit',
|
|
47
|
+
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] }) })] }));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.ResetPasswordCurrentView = ResetPasswordCurrentView;
|
package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export type ResetPasswordCurrentViewProps = {
|
|
3
|
+
onContinue: (password: string) => void;
|
|
4
|
+
onBack: () => void;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
error?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare const ResetPasswordCurrentView: FC<ResetPasswordCurrentViewProps>;
|
package/src/lib/widgets/DynamicWidget/views/ResetPasswordCurrentView/ResetPasswordCurrentView.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
6
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
7
|
+
import { Input } from '../../../../components/Input/Input.js';
|
|
8
|
+
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
9
|
+
import { ToggleVisibilityButton } from '../../../../components/ToggleVisibilityButton/ToggleVisibilityButton.js';
|
|
10
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
11
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
12
|
+
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
13
|
+
import { ReactComponent as SvgErrorCircleX } from '../../../../shared/assets/error-circle-x.js';
|
|
14
|
+
import { ReactComponent as SvgPasswordLockIcon } from '../../../../shared/assets/password-lock-icon.js';
|
|
15
|
+
import '@dynamic-labs/iconic';
|
|
16
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
17
|
+
|
|
18
|
+
const ResetPasswordCurrentView = ({ onContinue, onBack, isLoading = false, error: externalError = null, }) => {
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
const [password, setPassword] = useState('');
|
|
21
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
22
|
+
const [internalError, setInternalError] = useState(null);
|
|
23
|
+
const error = externalError !== null && externalError !== void 0 ? externalError : internalError;
|
|
24
|
+
const handlePasswordChange = useCallback((e) => {
|
|
25
|
+
setPassword(e.target.value);
|
|
26
|
+
setInternalError(null);
|
|
27
|
+
}, []);
|
|
28
|
+
const handleToggleVisibility = useCallback((hidden) => {
|
|
29
|
+
setShowPassword(!hidden);
|
|
30
|
+
}, []);
|
|
31
|
+
const handleContinue = useCallback(() => {
|
|
32
|
+
if (!password) {
|
|
33
|
+
setInternalError(t('dyn_reset_password.current.error.required'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
onContinue(password);
|
|
37
|
+
}, [password, onContinue, t]);
|
|
38
|
+
const backButton = (jsx(IconButton, { type: 'button', onClick: onBack, "data-testid": 'reset-password-current-back-button', children: jsx(SvgChevronLeft, {}) }));
|
|
39
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_reset_password.current.title', children: t('dyn_reset_password.current.title') }) }), jsx("div", { className: 'enter-password-view', children: jsxs("div", { className: 'enter-password-view__body', children: [jsx("div", { className: 'enter-password-view__icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgPasswordLockIcon, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_reset_password.current.description', className: 'enter-password-view__description', children: t('dyn_reset_password.current.description') }), jsx(Input, { id: 'reset-password-current-input', type: showPassword ? 'text' : 'password', label: t('dyn_reset_password.current.label'), placeholder: t('dyn_reset_password.current.placeholder'), value: password, onChange: handlePasswordChange, variant: 'regular', error: Boolean(error), message: error ? (jsxs("span", { className: 'enter-password-view__error-message', children: [jsx(SvgErrorCircleX, { width: 14, height: 14 }), error] })) : undefined, suffix:
|
|
40
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
41
|
+
jsx(ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), jsx("div", { className: 'enter-password-view__actions', children: jsx(TypographyButton, { dataTestId: 'reset-password-current-continue-button', onClick: handleContinue, disabled: !password || isLoading, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
42
|
+
color: 'inherit',
|
|
43
|
+
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] }) })] }));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { ResetPasswordCurrentView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ResetPasswordCurrentView } from './ResetPasswordCurrentView';
|