@dynamic-labs/sdk-react-core 4.61.2 → 4.61.3
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 +14 -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/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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
10
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
|
+
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
12
|
+
require('@dynamic-labs/iconic');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var logger = require('../../../../shared/logger.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../../../utils/constants/colors.cjs');
|
|
19
|
+
require('../../../../utils/constants/values.cjs');
|
|
20
|
+
require('@dynamic-labs/sdk-api-core');
|
|
21
|
+
require('../../../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
23
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
|
+
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
require('react-international-phone');
|
|
27
|
+
require('../../../../store/state/nonce/nonce.cjs');
|
|
28
|
+
require('@dynamic-labs-sdk/client/core');
|
|
29
|
+
require('../../../../client/client.cjs');
|
|
30
|
+
require('@dynamic-labs-sdk/client');
|
|
31
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
32
|
+
require('@dynamic-labs/locale');
|
|
33
|
+
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
34
|
+
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
35
|
+
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
36
|
+
require('../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
37
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
38
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
39
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
40
|
+
require('../../../../store/state/authMode/authMode.cjs');
|
|
41
|
+
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
42
|
+
require('react-dom');
|
|
43
|
+
require('../../../../utils/functions/compareChains/compareChains.cjs');
|
|
44
|
+
require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
45
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
46
|
+
var useSmartWallets = require('../../../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
47
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
48
|
+
require('bs58');
|
|
49
|
+
require('@dynamic-labs/types');
|
|
50
|
+
require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
51
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
52
|
+
require('../../../../context/WalletContext/WalletContext.cjs');
|
|
53
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
54
|
+
require('yup');
|
|
55
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
56
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
57
|
+
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
58
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
59
|
+
require('@dynamic-labs/rpc-providers');
|
|
60
|
+
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
61
|
+
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
62
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
63
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
64
|
+
require('../../../../components/IconButton/IconButton.cjs');
|
|
65
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
66
|
+
require('../../../../components/Input/Input.cjs');
|
|
67
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
68
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
69
|
+
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
70
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
71
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
72
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
73
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
74
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
75
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
76
|
+
require('react-focus-lock');
|
|
77
|
+
require('qrcode');
|
|
78
|
+
require('formik');
|
|
79
|
+
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
80
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
81
|
+
require('../../context/DynamicWidgetContext.cjs');
|
|
82
|
+
var SetupPasswordConfirmView = require('../SetupPasswordConfirmView/SetupPasswordConfirmView.cjs');
|
|
83
|
+
var SetupPasswordEnterView = require('../SetupPasswordEnterView/SetupPasswordEnterView.cjs');
|
|
84
|
+
var SetupPasswordSuccessView = require('../SetupPasswordSuccessView/SetupPasswordSuccessView.cjs');
|
|
85
|
+
require('../../../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
|
|
86
|
+
require('../../../../utils/hooks/useWalletBackup/types.cjs');
|
|
87
|
+
require('../../../../utils/hooks/useWalletBackup/cloudProviders.cjs');
|
|
88
|
+
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
89
|
+
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
90
|
+
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
91
|
+
require('@hcaptcha/react-hcaptcha');
|
|
92
|
+
require('../../helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
93
|
+
require('../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
94
|
+
require('../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
95
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
96
|
+
require('../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
97
|
+
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
98
|
+
var useWalletPassword = require('../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
99
|
+
var ResetPasswordCurrentView = require('../ResetPasswordCurrentView/ResetPasswordCurrentView.cjs');
|
|
100
|
+
require('../../../../context/OnrampContext/OnrampContext.cjs');
|
|
101
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
102
|
+
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
103
|
+
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
104
|
+
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
105
|
+
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
106
|
+
require('../../components/PasskeyCard/PasskeyCard.cjs');
|
|
107
|
+
require('../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
108
|
+
require('../../../../../index.cjs');
|
|
109
|
+
require('../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
110
|
+
require('../../../../store/state/tokenBalances.cjs');
|
|
111
|
+
require('../../../../store/state/multichainBalances.cjs');
|
|
112
|
+
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
113
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
114
|
+
|
|
115
|
+
const ResetPasswordView = ({ onComplete, }) => {
|
|
116
|
+
const { t } = reactI18next.useTranslation();
|
|
117
|
+
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
118
|
+
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
119
|
+
const { unlockWallet } = useWalletPassword.useWalletPassword();
|
|
120
|
+
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
121
|
+
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
122
|
+
const [currentStep, setCurrentStep] = React.useState('current');
|
|
123
|
+
const [currentPassword, setCurrentPassword] = React.useState('');
|
|
124
|
+
const [newPassword, setNewPassword] = React.useState('');
|
|
125
|
+
const [verifyError, setVerifyError] = React.useState(null);
|
|
126
|
+
const [isVerifying, setIsVerifying] = React.useState(false);
|
|
127
|
+
const handleCurrentPasswordContinue = React.useCallback((password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
129
|
+
logger.logger.error('No wallet address or chain available for password verification');
|
|
130
|
+
setVerifyError(t('dyn_reset_password.current.error.failed'));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
setIsVerifying(true);
|
|
134
|
+
setVerifyError(null);
|
|
135
|
+
const success = yield unlockWallet({
|
|
136
|
+
accountAddress: wallet.address,
|
|
137
|
+
chainName: wallet.chain,
|
|
138
|
+
password,
|
|
139
|
+
});
|
|
140
|
+
setIsVerifying(false);
|
|
141
|
+
if (success) {
|
|
142
|
+
setCurrentPassword(password);
|
|
143
|
+
setCurrentStep('enter');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
setVerifyError(t('dyn_reset_password.current.error.invalid_password'));
|
|
147
|
+
}
|
|
148
|
+
}), [wallet, unlockWallet, t]);
|
|
149
|
+
const handleCurrentPasswordBack = React.useCallback(() => {
|
|
150
|
+
setShowAuthFlow(false);
|
|
151
|
+
}, [setShowAuthFlow]);
|
|
152
|
+
const handleEnterContinue = React.useCallback((password) => {
|
|
153
|
+
setNewPassword(password);
|
|
154
|
+
setCurrentStep('confirm');
|
|
155
|
+
}, []);
|
|
156
|
+
const handleEnterBack = React.useCallback(() => {
|
|
157
|
+
setCurrentStep('current');
|
|
158
|
+
}, []);
|
|
159
|
+
const handleConfirmContinue = React.useCallback(() => {
|
|
160
|
+
setCurrentStep('success');
|
|
161
|
+
}, []);
|
|
162
|
+
const handleConfirmBack = React.useCallback(() => {
|
|
163
|
+
setCurrentStep('enter');
|
|
164
|
+
}, []);
|
|
165
|
+
const handleSuccess = React.useCallback(() => {
|
|
166
|
+
onComplete(currentPassword, newPassword);
|
|
167
|
+
}, [onComplete, currentPassword, newPassword]);
|
|
168
|
+
switch (currentStep) {
|
|
169
|
+
case 'current':
|
|
170
|
+
return (jsxRuntime.jsx(ResetPasswordCurrentView.ResetPasswordCurrentView, { onContinue: handleCurrentPasswordContinue, onBack: handleCurrentPasswordBack, isLoading: isVerifying, error: verifyError }));
|
|
171
|
+
case 'enter':
|
|
172
|
+
return (jsxRuntime.jsx(SetupPasswordEnterView.SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack, title: t('dyn_reset_password.enter.title'), description: t('dyn_reset_password.enter.description'), oldPassword: currentPassword }));
|
|
173
|
+
case 'confirm':
|
|
174
|
+
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true }));
|
|
175
|
+
case 'success':
|
|
176
|
+
return (jsxRuntime.jsx(SetupPasswordSuccessView.SetupPasswordSuccessView, { onDone: handleSuccess, title: t('dyn_reset_password.success.title'), description: t('dyn_reset_password.success.description') }));
|
|
177
|
+
default:
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
exports.ResetPasswordView = ResetPasswordView;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useCallback } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
+
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { logger } from '../../../../shared/logger.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../../../utils/constants/colors.js';
|
|
15
|
+
import '../../../../utils/constants/values.js';
|
|
16
|
+
import '@dynamic-labs/sdk-api-core';
|
|
17
|
+
import '../../../../shared/consts/index.js';
|
|
18
|
+
import '../../../../events/dynamicEvents.js';
|
|
19
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
21
|
+
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import 'react-international-phone';
|
|
23
|
+
import '../../../../store/state/nonce/nonce.js';
|
|
24
|
+
import '@dynamic-labs-sdk/client/core';
|
|
25
|
+
import '../../../../client/client.js';
|
|
26
|
+
import '@dynamic-labs-sdk/client';
|
|
27
|
+
import '../../../../config/ApiEndpoint.js';
|
|
28
|
+
import '@dynamic-labs/locale';
|
|
29
|
+
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
30
|
+
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
31
|
+
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
32
|
+
import '../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
33
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
34
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
35
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
36
|
+
import '../../../../store/state/authMode/authMode.js';
|
|
37
|
+
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
38
|
+
import 'react-dom';
|
|
39
|
+
import '../../../../utils/functions/compareChains/compareChains.js';
|
|
40
|
+
import '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
41
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
42
|
+
import { useSmartWallets } from '../../../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
43
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
44
|
+
import 'bs58';
|
|
45
|
+
import '@dynamic-labs/types';
|
|
46
|
+
import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
47
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
48
|
+
import '../../../../context/WalletContext/WalletContext.js';
|
|
49
|
+
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
50
|
+
import 'yup';
|
|
51
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
52
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
53
|
+
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
54
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
55
|
+
import '@dynamic-labs/rpc-providers';
|
|
56
|
+
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
57
|
+
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
58
|
+
import '../../../../components/Alert/Alert.js';
|
|
59
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
60
|
+
import '../../../../components/IconButton/IconButton.js';
|
|
61
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
62
|
+
import '../../../../components/Input/Input.js';
|
|
63
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
64
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
65
|
+
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
66
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
67
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
68
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
69
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
70
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
71
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
72
|
+
import 'react-focus-lock';
|
|
73
|
+
import 'qrcode';
|
|
74
|
+
import 'formik';
|
|
75
|
+
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
76
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
77
|
+
import '../../context/DynamicWidgetContext.js';
|
|
78
|
+
import { SetupPasswordConfirmView } from '../SetupPasswordConfirmView/SetupPasswordConfirmView.js';
|
|
79
|
+
import { SetupPasswordEnterView } from '../SetupPasswordEnterView/SetupPasswordEnterView.js';
|
|
80
|
+
import { SetupPasswordSuccessView } from '../SetupPasswordSuccessView/SetupPasswordSuccessView.js';
|
|
81
|
+
import '../../../../utils/hooks/useWalletBackup/useWalletBackup.js';
|
|
82
|
+
import '../../../../utils/hooks/useWalletBackup/types.js';
|
|
83
|
+
import '../../../../utils/hooks/useWalletBackup/cloudProviders.js';
|
|
84
|
+
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
85
|
+
import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
86
|
+
import '../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
87
|
+
import '@hcaptcha/react-hcaptcha';
|
|
88
|
+
import '../../helpers/convertExchangeKeyAndProviderEnum.js';
|
|
89
|
+
import '../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
90
|
+
import '../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
91
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
92
|
+
import '../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
93
|
+
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
94
|
+
import { useWalletPassword } from '../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
95
|
+
import { ResetPasswordCurrentView } from '../ResetPasswordCurrentView/ResetPasswordCurrentView.js';
|
|
96
|
+
import '../../../../context/OnrampContext/OnrampContext.js';
|
|
97
|
+
import '../../../../store/state/sendBalances.js';
|
|
98
|
+
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
99
|
+
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
100
|
+
import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
101
|
+
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
102
|
+
import '../../components/PasskeyCard/PasskeyCard.js';
|
|
103
|
+
import '../CryptoComOnramp/CryptoComOnramp.js';
|
|
104
|
+
import '../../../../../index.js';
|
|
105
|
+
import '../ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
106
|
+
import '../../../../store/state/tokenBalances.js';
|
|
107
|
+
import '../../../../store/state/multichainBalances.js';
|
|
108
|
+
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
109
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
110
|
+
|
|
111
|
+
const ResetPasswordView = ({ onComplete, }) => {
|
|
112
|
+
const { t } = useTranslation();
|
|
113
|
+
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
114
|
+
const { getEOAWallet } = useSmartWallets();
|
|
115
|
+
const { unlockWallet } = useWalletPassword();
|
|
116
|
+
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
117
|
+
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
118
|
+
const [currentStep, setCurrentStep] = useState('current');
|
|
119
|
+
const [currentPassword, setCurrentPassword] = useState('');
|
|
120
|
+
const [newPassword, setNewPassword] = useState('');
|
|
121
|
+
const [verifyError, setVerifyError] = useState(null);
|
|
122
|
+
const [isVerifying, setIsVerifying] = useState(false);
|
|
123
|
+
const handleCurrentPasswordContinue = useCallback((password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
125
|
+
logger.error('No wallet address or chain available for password verification');
|
|
126
|
+
setVerifyError(t('dyn_reset_password.current.error.failed'));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setIsVerifying(true);
|
|
130
|
+
setVerifyError(null);
|
|
131
|
+
const success = yield unlockWallet({
|
|
132
|
+
accountAddress: wallet.address,
|
|
133
|
+
chainName: wallet.chain,
|
|
134
|
+
password,
|
|
135
|
+
});
|
|
136
|
+
setIsVerifying(false);
|
|
137
|
+
if (success) {
|
|
138
|
+
setCurrentPassword(password);
|
|
139
|
+
setCurrentStep('enter');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
setVerifyError(t('dyn_reset_password.current.error.invalid_password'));
|
|
143
|
+
}
|
|
144
|
+
}), [wallet, unlockWallet, t]);
|
|
145
|
+
const handleCurrentPasswordBack = useCallback(() => {
|
|
146
|
+
setShowAuthFlow(false);
|
|
147
|
+
}, [setShowAuthFlow]);
|
|
148
|
+
const handleEnterContinue = useCallback((password) => {
|
|
149
|
+
setNewPassword(password);
|
|
150
|
+
setCurrentStep('confirm');
|
|
151
|
+
}, []);
|
|
152
|
+
const handleEnterBack = useCallback(() => {
|
|
153
|
+
setCurrentStep('current');
|
|
154
|
+
}, []);
|
|
155
|
+
const handleConfirmContinue = useCallback(() => {
|
|
156
|
+
setCurrentStep('success');
|
|
157
|
+
}, []);
|
|
158
|
+
const handleConfirmBack = useCallback(() => {
|
|
159
|
+
setCurrentStep('enter');
|
|
160
|
+
}, []);
|
|
161
|
+
const handleSuccess = useCallback(() => {
|
|
162
|
+
onComplete(currentPassword, newPassword);
|
|
163
|
+
}, [onComplete, currentPassword, newPassword]);
|
|
164
|
+
switch (currentStep) {
|
|
165
|
+
case 'current':
|
|
166
|
+
return (jsx(ResetPasswordCurrentView, { onContinue: handleCurrentPasswordContinue, onBack: handleCurrentPasswordBack, isLoading: isVerifying, error: verifyError }));
|
|
167
|
+
case 'enter':
|
|
168
|
+
return (jsx(SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack, title: t('dyn_reset_password.enter.title'), description: t('dyn_reset_password.enter.description'), oldPassword: currentPassword }));
|
|
169
|
+
case 'confirm':
|
|
170
|
+
return (jsx(SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true }));
|
|
171
|
+
case 'success':
|
|
172
|
+
return (jsx(SetupPasswordSuccessView, { onDone: handleSuccess, title: t('dyn_reset_password.success.title'), description: t('dyn_reset_password.success.description') }));
|
|
173
|
+
default:
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export { ResetPasswordView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ResetPasswordView } from './ResetPasswordView';
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactI18next = require('react-i18next');
|
|
9
|
+
var Checkbox = require('../../../../components/Checkbox/Checkbox.cjs');
|
|
9
10
|
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
10
11
|
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
11
12
|
var Input = require('../../../../components/Input/Input.cjs');
|
|
@@ -20,13 +21,16 @@ var secureAction = require('../../../../shared/assets/secure-action.cjs');
|
|
|
20
21
|
require('@dynamic-labs/iconic');
|
|
21
22
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
22
23
|
|
|
23
|
-
const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
24
|
+
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, }) => {
|
|
24
25
|
const { t } = reactI18next.useTranslation();
|
|
25
26
|
const [confirmPassword, setConfirmPassword] = React.useState('');
|
|
26
27
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
27
28
|
const [hasInteracted, setHasInteracted] = React.useState(false);
|
|
29
|
+
const [acknowledged, setAcknowledged] = React.useState(false);
|
|
28
30
|
const passwordsMatch = password === confirmPassword;
|
|
29
|
-
const isValid = passwordsMatch &&
|
|
31
|
+
const isValid = passwordsMatch &&
|
|
32
|
+
confirmPassword.length > 0 &&
|
|
33
|
+
(!showAcknowledgment || acknowledged);
|
|
30
34
|
const handlePasswordChange = React.useCallback((e) => {
|
|
31
35
|
setConfirmPassword(e.target.value);
|
|
32
36
|
setHasInteracted(true);
|
|
@@ -34,6 +38,9 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
|
34
38
|
const handleToggleVisibility = React.useCallback((hidden) => {
|
|
35
39
|
setShowPassword(!hidden);
|
|
36
40
|
}, []);
|
|
41
|
+
const handleAcknowledgmentChange = React.useCallback(() => {
|
|
42
|
+
setAcknowledged((prev) => !prev);
|
|
43
|
+
}, []);
|
|
37
44
|
const handleContinue = React.useCallback(() => {
|
|
38
45
|
if (isValid) {
|
|
39
46
|
onContinue();
|
|
@@ -44,9 +51,9 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
|
44
51
|
const matchMessage = passwordsMatch
|
|
45
52
|
? t('dyn_setup_password.confirm.match')
|
|
46
53
|
: t('dyn_setup_password.confirm.mismatch');
|
|
47
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: t('dyn_setup_password.confirm.title') }) }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view', children: [jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(secureAction.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: t('dyn_setup_password.confirm.description') }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsxRuntime.jsx(Input.Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
54
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: title !== null && title !== void 0 ? title : t('dyn_setup_password.confirm.title') }) }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view', children: [jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(secureAction.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: description !== null && description !== void 0 ? description : t('dyn_setup_password.confirm.description') }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsxRuntime.jsx(Input.Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
48
55
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
49
|
-
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsxRuntime.jsx(Icon.Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsxRuntime.jsx(checkCircle.ReactComponent, {})) : (jsxRuntime.jsx(exclamationCircle.ReactComponent, {})) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
56
|
+
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsxRuntime.jsx(Icon.Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsxRuntime.jsx(checkCircle.ReactComponent, {})) : (jsxRuntime.jsx(exclamationCircle.ReactComponent, {})) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxRuntime.jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
50
57
|
color: 'inherit',
|
|
51
58
|
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] })] }));
|
|
52
59
|
};
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ export type SetupPasswordConfirmViewProps = {
|
|
|
3
3
|
password: string;
|
|
4
4
|
onContinue: () => void;
|
|
5
5
|
onBack: () => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
showAcknowledgment?: boolean;
|
|
6
9
|
};
|
|
7
10
|
export declare const SetupPasswordConfirmView: FC<SetupPasswordConfirmViewProps>;
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useCallback } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Checkbox } from '../../../../components/Checkbox/Checkbox.js';
|
|
5
6
|
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
6
7
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
7
8
|
import { Input } from '../../../../components/Input/Input.js';
|
|
@@ -16,13 +17,16 @@ import { ReactComponent as SvgSecureAction } from '../../../../shared/assets/sec
|
|
|
16
17
|
import '@dynamic-labs/iconic';
|
|
17
18
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
18
19
|
|
|
19
|
-
const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
20
|
+
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, }) => {
|
|
20
21
|
const { t } = useTranslation();
|
|
21
22
|
const [confirmPassword, setConfirmPassword] = useState('');
|
|
22
23
|
const [showPassword, setShowPassword] = useState(false);
|
|
23
24
|
const [hasInteracted, setHasInteracted] = useState(false);
|
|
25
|
+
const [acknowledged, setAcknowledged] = useState(false);
|
|
24
26
|
const passwordsMatch = password === confirmPassword;
|
|
25
|
-
const isValid = passwordsMatch &&
|
|
27
|
+
const isValid = passwordsMatch &&
|
|
28
|
+
confirmPassword.length > 0 &&
|
|
29
|
+
(!showAcknowledgment || acknowledged);
|
|
26
30
|
const handlePasswordChange = useCallback((e) => {
|
|
27
31
|
setConfirmPassword(e.target.value);
|
|
28
32
|
setHasInteracted(true);
|
|
@@ -30,6 +34,9 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
|
30
34
|
const handleToggleVisibility = useCallback((hidden) => {
|
|
31
35
|
setShowPassword(!hidden);
|
|
32
36
|
}, []);
|
|
37
|
+
const handleAcknowledgmentChange = useCallback(() => {
|
|
38
|
+
setAcknowledged((prev) => !prev);
|
|
39
|
+
}, []);
|
|
33
40
|
const handleContinue = useCallback(() => {
|
|
34
41
|
if (isValid) {
|
|
35
42
|
onContinue();
|
|
@@ -40,9 +47,9 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, }) => {
|
|
|
40
47
|
const matchMessage = passwordsMatch
|
|
41
48
|
? t('dyn_setup_password.confirm.match')
|
|
42
49
|
: t('dyn_setup_password.confirm.mismatch');
|
|
43
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: t('dyn_setup_password.confirm.title') }) }), jsxs("div", { className: 'setup-password-confirm-view', children: [jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgSecureAction, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: t('dyn_setup_password.confirm.description') }), jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsx(Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
50
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: title !== null && title !== void 0 ? title : t('dyn_setup_password.confirm.title') }) }), jsxs("div", { className: 'setup-password-confirm-view', children: [jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgSecureAction, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: description !== null && description !== void 0 ? description : t('dyn_setup_password.confirm.description') }), jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsx(Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
44
51
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
45
|
-
jsx(ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsx(Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsx(SvgCheckCircle, {})) : (jsx(SvgExclamationCircle, {})) }), jsx(Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), jsx("div", { className: 'setup-password-confirm-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
52
|
+
jsx(ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsx(Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsx(SvgCheckCircle, {})) : (jsx(SvgExclamationCircle, {})) }), jsx(Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsx(Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsx(Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), jsx("div", { className: 'setup-password-confirm-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
46
53
|
color: 'inherit',
|
|
47
54
|
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] })] }));
|
|
48
55
|
};
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.cjs
CHANGED
|
@@ -14,6 +14,7 @@ var ToggleVisibilityButton = require('../../../../components/ToggleVisibilityBut
|
|
|
14
14
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
15
15
|
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
16
16
|
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
17
|
+
var errorCircleX = require('../../../../shared/assets/error-circle-x.cjs');
|
|
17
18
|
var passwordLockIcon = require('../../../../shared/assets/password-lock-icon.cjs');
|
|
18
19
|
require('@dynamic-labs/iconic');
|
|
19
20
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
@@ -29,29 +30,35 @@ const validatePassword = (password) => ({
|
|
|
29
30
|
symbol: /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password),
|
|
30
31
|
uppercase: /[A-Z]/.test(password),
|
|
31
32
|
});
|
|
32
|
-
const SetupPasswordEnterView = ({ onContinue, onBack, }) => {
|
|
33
|
+
const SetupPasswordEnterView = ({ onContinue, onBack, title, description, oldPassword, }) => {
|
|
33
34
|
const { t } = reactI18next.useTranslation();
|
|
34
35
|
const [password, setPassword] = React.useState('');
|
|
35
36
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
37
|
+
const [samePasswordError, setSamePasswordError] = React.useState(false);
|
|
36
38
|
const requirements = validatePassword(password);
|
|
37
39
|
const allValid = Object.values(requirements).every(Boolean);
|
|
38
40
|
const handlePasswordChange = React.useCallback((e) => {
|
|
39
41
|
setPassword(e.target.value);
|
|
42
|
+
setSamePasswordError(false);
|
|
40
43
|
}, []);
|
|
41
44
|
const handleToggleVisibility = React.useCallback((hidden) => {
|
|
42
45
|
setShowPassword(!hidden);
|
|
43
46
|
}, []);
|
|
44
47
|
const handleContinue = React.useCallback(() => {
|
|
45
|
-
if (allValid)
|
|
46
|
-
|
|
48
|
+
if (!allValid)
|
|
49
|
+
return;
|
|
50
|
+
if (oldPassword && password === oldPassword) {
|
|
51
|
+
setSamePasswordError(true);
|
|
52
|
+
return;
|
|
47
53
|
}
|
|
48
|
-
|
|
54
|
+
onContinue(password);
|
|
55
|
+
}, [allValid, onContinue, password, oldPassword]);
|
|
49
56
|
const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onBack, "data-testid": 'setup-password-enter-back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
50
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.enter.title', children: t('dyn_setup_password.enter.title') }) }), jsxRuntime.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.enter.title', children: title !== null && title !== void 0 ? title : t('dyn_setup_password.enter.title') }) }), jsxRuntime.jsxs("div", { className: 'setup-password-enter-view', children: [jsxRuntime.jsxs("div", { className: 'setup-password-enter-view__body', children: [jsxRuntime.jsx("div", { className: 'setup-password-enter-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: 'primary', copykey: 'dyn_setup_password.enter.description', className: 'setup-password-enter-view__description', children: description !== null && description !== void 0 ? description : t('dyn_setup_password.enter.description') }), jsxRuntime.jsx(Input.Input, { id: 'setup-password-enter-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.enter.label'), placeholder: t('dyn_setup_password.enter.placeholder'), value: password, onChange: handlePasswordChange, variant: 'regular', suffix:
|
|
58
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
59
|
+
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), jsxRuntime.jsxs("div", { className: 'setup-password-enter-view__requirements', children: [jsxRuntime.jsx(PasswordRequirement.PasswordRequirement, { met: requirements.length, text: t('dyn_setup_password.enter.requirement_length') }), jsxRuntime.jsx(PasswordRequirement.PasswordRequirement, { met: requirements.uppercase, text: t('dyn_setup_password.enter.requirement_uppercase') }), jsxRuntime.jsx(PasswordRequirement.PasswordRequirement, { met: requirements.lowercase, text: t('dyn_setup_password.enter.requirement_lowercase') }), jsxRuntime.jsx(PasswordRequirement.PasswordRequirement, { met: requirements.number, text: t('dyn_setup_password.enter.requirement_number') }), jsxRuntime.jsx(PasswordRequirement.PasswordRequirement, { met: requirements.symbol, text: t('dyn_setup_password.enter.requirement_symbol') })] }), samePasswordError && (jsxRuntime.jsxs("div", { className: 'setup-password-enter-view__same-password-error', children: [jsxRuntime.jsx(Icon.Icon, { color: 'text-error', size: 'medium', children: jsxRuntime.jsx(errorCircleX.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'error-1', children: t('dyn_reset_password.enter.same_password_error') })] }))] }), jsxRuntime.jsx("div", { className: 'setup-password-enter-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-enter-continue-button', onClick: handleContinue, disabled: !allValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
60
|
+
color: 'inherit',
|
|
61
|
+
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] })] }));
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
exports.SetupPasswordEnterView = SetupPasswordEnterView;
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.d.ts
CHANGED
|
@@ -2,5 +2,8 @@ import { FC } from 'react';
|
|
|
2
2
|
export type SetupPasswordEnterViewProps = {
|
|
3
3
|
onContinue: (password: string) => void;
|
|
4
4
|
onBack: () => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
oldPassword?: string;
|
|
5
8
|
};
|
|
6
9
|
export declare const SetupPasswordEnterView: FC<SetupPasswordEnterViewProps>;
|