@digitaldefiance/express-suite-react-components 5.0.2 → 5.0.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/package.json +5 -4
- package/src/auth/AdminRoute.d.ts +8 -0
- package/src/auth/AdminRoute.d.ts.map +1 -0
- package/src/auth/AdminRoute.js +28 -0
- package/src/auth/Private.d.ts +6 -0
- package/src/auth/Private.d.ts.map +1 -0
- package/src/auth/Private.js +14 -0
- package/src/auth/PrivateRoute.d.ts +8 -0
- package/src/auth/PrivateRoute.d.ts.map +1 -0
- package/src/auth/PrivateRoute.js +23 -0
- package/src/auth/UnAuth.d.ts +6 -0
- package/src/auth/UnAuth.d.ts.map +1 -0
- package/src/auth/UnAuth.js +14 -0
- package/src/auth/UnAuthRoute.d.ts +8 -0
- package/src/auth/UnAuthRoute.d.ts.map +1 -0
- package/src/auth/UnAuthRoute.js +22 -0
- package/src/auth/{index.ts → index.d.ts} +3 -2
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +12 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +77 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +139 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +120 -0
- package/src/components/CategoryMenu.d.ts +17 -0
- package/src/components/CategoryMenu.d.ts.map +1 -0
- package/src/components/CategoryMenu.js +65 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +78 -0
- package/src/components/ConfirmationDialog.d.ts +13 -0
- package/src/components/ConfirmationDialog.d.ts.map +1 -0
- package/src/components/ConfirmationDialog.js +10 -0
- package/src/components/CurrencyCodeSelector.d.ts +9 -0
- package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
- package/src/components/CurrencyCodeSelector.js +31 -0
- package/src/components/CurrencyInput.d.ts +13 -0
- package/src/components/CurrencyInput.d.ts.map +1 -0
- package/src/components/CurrencyInput.js +22 -0
- package/src/components/DashboardPage.d.ts +8 -0
- package/src/components/DashboardPage.d.ts.map +1 -0
- package/src/components/DashboardPage.js +10 -0
- package/src/components/DropdownMenu.d.ts +13 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +63 -0
- package/src/components/ExpirationSecondsSelector.d.ts +13 -0
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
- package/src/components/ExpirationSecondsSelector.js +32 -0
- package/src/components/FakeEmailAdminPanel.d.ts +23 -0
- package/src/components/FakeEmailAdminPanel.d.ts.map +1 -0
- package/src/components/FakeEmailAdminPanel.js +147 -0
- package/src/components/Flag.d.ts +20 -0
- package/src/components/Flag.d.ts.map +1 -0
- package/src/components/Flag.js +43 -0
- package/src/components/ForgotPasswordForm.d.ts +18 -0
- package/src/components/ForgotPasswordForm.d.ts.map +1 -0
- package/src/components/ForgotPasswordForm.js +61 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +123 -0
- package/src/components/LogoutPage.d.ts +8 -0
- package/src/components/LogoutPage.d.ts.map +1 -0
- package/src/components/LogoutPage.js +16 -0
- package/src/components/RegisterForm.d.ts +100 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +306 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +78 -0
- package/src/components/SideMenu.d.ts +8 -0
- package/src/components/SideMenu.d.ts.map +1 -0
- package/src/components/SideMenu.js +25 -0
- package/src/components/SideMenuListItem.d.ts +13 -0
- package/src/components/SideMenuListItem.d.ts.map +1 -0
- package/src/components/SideMenuListItem.js +44 -0
- package/src/components/T.d.ts +7 -0
- package/src/components/T.d.ts.map +1 -0
- package/src/components/T.js +13 -0
- package/src/components/TDiv.d.ts +9 -0
- package/src/components/TDiv.d.ts.map +1 -0
- package/src/components/TDiv.js +14 -0
- package/src/components/TImgAlt.d.ts +10 -0
- package/src/components/TImgAlt.d.ts.map +1 -0
- package/src/components/TImgAlt.js +14 -0
- package/src/components/TopMenu.d.ts +50 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +79 -0
- package/src/components/TotpSetupForm.d.ts +24 -0
- package/src/components/TotpSetupForm.d.ts.map +1 -0
- package/src/components/TotpSetupForm.js +82 -0
- package/src/components/TotpVerificationForm.d.ts +23 -0
- package/src/components/TotpVerificationForm.d.ts.map +1 -0
- package/src/components/TotpVerificationForm.js +66 -0
- package/src/components/TranslatedTitle.d.ts +8 -0
- package/src/components/TranslatedTitle.d.ts.map +1 -0
- package/src/components/TranslatedTitle.js +15 -0
- package/src/components/UserLanguageSelector.d.ts +4 -0
- package/src/components/UserLanguageSelector.d.ts.map +1 -0
- package/src/components/UserLanguageSelector.js +31 -0
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/UserSettingsForm.d.ts +113 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +269 -0
- package/src/components/VerifyEmailPage.d.ts +24 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +81 -0
- package/src/components/{index.ts → index.d.ts} +1 -1
- package/src/components/index.d.ts.map +1 -0
- package/src/components/index.js +35 -0
- package/src/contexts/AuthProvider.d.ts +19 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +514 -0
- package/src/contexts/I18nProvider.d.ts +27 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +60 -0
- package/src/contexts/MenuContext.d.ts +28 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +307 -0
- package/src/contexts/SuiteConfigProvider.d.ts +44 -0
- package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
- package/src/contexts/SuiteConfigProvider.js +43 -0
- package/src/contexts/ThemeProvider.d.ts +15 -0
- package/src/contexts/ThemeProvider.d.ts.map +1 -0
- package/src/contexts/ThemeProvider.js +36 -0
- package/src/contexts/auth-context.d.ts +172 -0
- package/src/contexts/auth-context.d.ts.map +1 -0
- package/src/contexts/auth-context.js +13 -0
- package/src/contexts/{index.ts → index.d.ts} +1 -0
- package/src/contexts/index.d.ts.map +1 -0
- package/src/contexts/index.js +8 -0
- package/src/hooks/{index.ts → index.d.ts} +1 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +9 -0
- package/src/hooks/useAuthenticatedApi.d.ts +34 -0
- package/src/hooks/useAuthenticatedApi.d.ts.map +1 -0
- package/src/hooks/useAuthenticatedApi.js +46 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +74 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +40 -0
- package/src/hooks/useExpiringValue.d.ts +14 -0
- package/src/hooks/useExpiringValue.d.ts.map +1 -0
- package/src/hooks/useExpiringValue.js +53 -0
- package/src/hooks/useLocalStorage.d.ts +2 -0
- package/src/hooks/useLocalStorage.d.ts.map +1 -0
- package/src/hooks/useLocalStorage.js +15 -0
- package/src/hooks/useUserSettings.d.ts +48 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +171 -0
- package/src/{index.ts → index.d.ts} +1 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +12 -0
- package/src/interfaces/IAppConfig.d.ts +8 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/ICategoryConfig.d.ts +41 -0
- package/src/interfaces/ICategoryConfig.d.ts.map +1 -0
- package/src/interfaces/ICategoryConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +28 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +82 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +7 -0
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/api.d.ts +3 -0
- package/src/services/api.d.ts.map +1 -0
- package/src/services/api.js +14 -0
- package/src/services/authService.d.ts +126 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +471 -0
- package/src/services/authenticatedApi.d.ts +3 -0
- package/src/services/authenticatedApi.d.ts.map +1 -0
- package/src/services/authenticatedApi.js +18 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +6 -0
- package/src/types/MenuType.d.ts +11 -0
- package/src/types/MenuType.d.ts.map +1 -0
- package/src/types/MenuType.js +12 -0
- package/src/types/expirationSeconds.d.ts +3 -0
- package/src/types/expirationSeconds.d.ts.map +1 -0
- package/src/types/expirationSeconds.js +17 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +4 -0
- package/src/types/translation.d.ts +10 -0
- package/src/types/translation.d.ts.map +1 -0
- package/src/types/translation.js +9 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodeLoginWrapper.js +20 -0
- package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
- package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodesWrapper.js +17 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ForgotPasswordFormWrapper.js +29 -0
- package/src/wrappers/LoginFormWrapper.d.ts +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +72 -0
- package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
- package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
- package/src/wrappers/LogoutPageWrapper.js +21 -0
- package/src/wrappers/RegisterFormWrapper.d.ts +20 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +51 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts +9 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ResetPasswordFormWrapper.js +34 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +29 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +95 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +21 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -10
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +24 -0
- package/LICENSE +0 -21
- package/src/auth/AdminRoute.tsx +0 -54
- package/src/auth/Private.tsx +0 -17
- package/src/auth/PrivateRoute.tsx +0 -28
- package/src/auth/UnAuth.tsx +0 -16
- package/src/auth/UnAuthRoute.tsx +0 -30
- package/src/components/ApiAccess.tsx +0 -175
- package/src/components/BackupCodeLoginForm.tsx +0 -489
- package/src/components/BackupCodesForm.tsx +0 -287
- package/src/components/CategoryMenu.tsx +0 -155
- package/src/components/ChangePasswordForm.tsx +0 -273
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/CurrencyCodeSelector.tsx +0 -60
- package/src/components/CurrencyInput.tsx +0 -80
- package/src/components/DashboardPage.tsx +0 -24
- package/src/components/DropdownMenu.tsx +0 -105
- package/src/components/ExpirationSecondsSelector.tsx +0 -60
- package/src/components/FakeEmailAdminPanel.tsx +0 -374
- package/src/components/Flag.tsx +0 -52
- package/src/components/ForgotPasswordForm.tsx +0 -174
- package/src/components/LoginForm.tsx +0 -468
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -1169
- package/src/components/ResetPasswordForm.tsx +0 -247
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -75
- package/src/components/T.tsx +0 -24
- package/src/components/TDiv.tsx +0 -26
- package/src/components/TImgAlt.tsx +0 -28
- package/src/components/TopMenu.tsx +0 -252
- package/src/components/TotpSetupForm.tsx +0 -188
- package/src/components/TotpVerificationForm.tsx +0 -148
- package/src/components/TranslatedTitle.tsx +0 -31
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -904
- package/src/components/VerifyEmailPage.tsx +0 -222
- package/src/components/__tests__/RegisterForm.totp.spec.tsx +0 -377
- package/src/components/__tests__/TotpSetupForm.spec.tsx +0 -258
- package/src/components/__tests__/TotpVerificationForm.spec.tsx +0 -259
- package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +0 -396
- package/src/contexts/AuthProvider.spec.tsx +0 -1284
- package/src/contexts/AuthProvider.tsx +0 -977
- package/src/contexts/I18nProvider.tsx +0 -164
- package/src/contexts/MenuContext.tsx +0 -426
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useAuthenticatedApi.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -105
- package/src/hooks/useEmailVerification.ts +0 -54
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -271
- package/src/interfaces/IAppConfig.ts +0 -7
- package/src/interfaces/ICategoryConfig.ts +0 -41
- package/src/interfaces/IMenuConfig.ts +0 -28
- package/src/interfaces/IMenuOption.ts +0 -79
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/__tests__/authService.totp.property.spec.ts +0 -360
- package/src/services/__tests__/authService.totp.spec.ts +0 -439
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -692
- package/src/services/authenticatedApi.ts +0 -17
- package/src/services/index.ts +0 -3
- package/src/types/MenuType.ts +0 -15
- package/src/types/expirationSeconds.ts +0 -18
- package/src/types/index.ts +0 -1
- package/src/types/translation.ts +0 -20
- package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -34
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -34
- package/src/wrappers/ForgotPasswordFormWrapper.tsx +0 -45
- package/src/wrappers/LoginFormWrapper.tsx +0 -108
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -109
- package/src/wrappers/ResetPasswordFormWrapper.tsx +0 -57
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -140
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
- package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +0 -339
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserSettingsForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
7
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
8
|
+
const material_1 = require("@mui/material");
|
|
9
|
+
const formik_1 = require("formik");
|
|
10
|
+
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
13
|
+
const contexts_1 = require("../contexts");
|
|
14
|
+
const suite_core_lib_2 = require("@digitaldefiance/suite-core-lib");
|
|
15
|
+
const TotpSetupForm_1 = require("./TotpSetupForm");
|
|
16
|
+
const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, displayNameValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, totpEnabled, onTotpSetup, onTotpConfirm, onTotpDisable, onTotpReset, labels = {}, }) => {
|
|
17
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
18
|
+
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
19
|
+
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
20
|
+
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
21
|
+
// TOTP management state
|
|
22
|
+
const [totpStatus, setTotpStatus] = (0, react_1.useState)(totpEnabled);
|
|
23
|
+
// Sync totpStatus when the totpEnabled prop transitions from undefined to a
|
|
24
|
+
// concrete value (i.e. after the wrapper fetches it asynchronously).
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
if (totpEnabled !== undefined) {
|
|
27
|
+
setTotpStatus(totpEnabled);
|
|
28
|
+
}
|
|
29
|
+
}, [totpEnabled]);
|
|
30
|
+
const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
|
|
31
|
+
const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
|
|
32
|
+
const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
|
|
33
|
+
const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
|
|
34
|
+
const [totpError, setTotpError] = (0, react_1.useState)(null);
|
|
35
|
+
const [showDisablePrompt, setShowDisablePrompt] = (0, react_1.useState)(false);
|
|
36
|
+
const [disableCode, setDisableCode] = (0, react_1.useState)('');
|
|
37
|
+
const [disableSubmitting, setDisableSubmitting] = (0, react_1.useState)(false);
|
|
38
|
+
const [showResetPrompt, setShowResetPrompt] = (0, react_1.useState)(false);
|
|
39
|
+
const [resetCode, setResetCode] = (0, react_1.useState)('');
|
|
40
|
+
const [resetSubmitting, setResetSubmitting] = (0, react_1.useState)(false);
|
|
41
|
+
const handleEnableTotp = (0, react_1.useCallback)(async () => {
|
|
42
|
+
if (!onTotpSetup)
|
|
43
|
+
return;
|
|
44
|
+
setTotpSetupLoading(true);
|
|
45
|
+
setTotpError(null);
|
|
46
|
+
try {
|
|
47
|
+
const result = await onTotpSetup();
|
|
48
|
+
if ('error' in result) {
|
|
49
|
+
setTotpError(result.error);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setTotpProvisioningUri(result.provisioningUri);
|
|
53
|
+
setTotpSecret(result.secret);
|
|
54
|
+
setShowTotpSetup(true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
setTotpError(labels.totpError || 'Failed to set up two-factor authentication');
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
setTotpSetupLoading(false);
|
|
62
|
+
}
|
|
63
|
+
}, [onTotpSetup, labels.totpError]);
|
|
64
|
+
const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
|
|
65
|
+
if (!onTotpConfirm) {
|
|
66
|
+
return { error: 'TOTP confirmation is not available' };
|
|
67
|
+
}
|
|
68
|
+
const result = await onTotpConfirm(code);
|
|
69
|
+
if ('success' in result && result.success) {
|
|
70
|
+
setTotpStatus(true);
|
|
71
|
+
setShowTotpSetup(false);
|
|
72
|
+
setTotpProvisioningUri(null);
|
|
73
|
+
setTotpSecret(null);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}, [onTotpConfirm]);
|
|
77
|
+
const handleDisableTotp = (0, react_1.useCallback)(async () => {
|
|
78
|
+
if (!onTotpDisable || !disableCode)
|
|
79
|
+
return;
|
|
80
|
+
setDisableSubmitting(true);
|
|
81
|
+
setTotpError(null);
|
|
82
|
+
try {
|
|
83
|
+
const result = await onTotpDisable(disableCode);
|
|
84
|
+
if ('error' in result) {
|
|
85
|
+
setTotpError(result.error);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
setTotpStatus(false);
|
|
89
|
+
setShowDisablePrompt(false);
|
|
90
|
+
setDisableCode('');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
setTotpError(labels.totpError || 'Failed to disable two-factor authentication');
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
setDisableSubmitting(false);
|
|
98
|
+
}
|
|
99
|
+
}, [onTotpDisable, disableCode, labels.totpError]);
|
|
100
|
+
const handleResetTotp = (0, react_1.useCallback)(async () => {
|
|
101
|
+
if (!onTotpReset || !resetCode)
|
|
102
|
+
return;
|
|
103
|
+
setResetSubmitting(true);
|
|
104
|
+
setTotpError(null);
|
|
105
|
+
try {
|
|
106
|
+
const result = await onTotpReset(resetCode);
|
|
107
|
+
if ('error' in result) {
|
|
108
|
+
setTotpError(result.error);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
setTotpProvisioningUri(result.provisioningUri);
|
|
112
|
+
setTotpSecret(result.secret);
|
|
113
|
+
setShowResetPrompt(false);
|
|
114
|
+
setResetCode('');
|
|
115
|
+
setShowTotpSetup(true);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
setTotpError(labels.totpError || 'Failed to reset two-factor authentication');
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
setResetSubmitting(false);
|
|
123
|
+
}
|
|
124
|
+
}, [onTotpReset, resetCode, labels.totpError]);
|
|
125
|
+
const handleCancelTotpAction = (0, react_1.useCallback)(() => {
|
|
126
|
+
setShowTotpSetup(false);
|
|
127
|
+
setShowDisablePrompt(false);
|
|
128
|
+
setShowResetPrompt(false);
|
|
129
|
+
setTotpProvisioningUri(null);
|
|
130
|
+
setTotpSecret(null);
|
|
131
|
+
setDisableCode('');
|
|
132
|
+
setResetCode('');
|
|
133
|
+
setTotpError(null);
|
|
134
|
+
}, []);
|
|
135
|
+
const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
|
|
136
|
+
const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map((c) => ({
|
|
137
|
+
code: c.code,
|
|
138
|
+
label: `${c.code} - ${c.currency}`,
|
|
139
|
+
})), []);
|
|
140
|
+
const validation = {
|
|
141
|
+
email: emailValidation ||
|
|
142
|
+
Yup.string()
|
|
143
|
+
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
144
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
145
|
+
timezone: timezoneValidation ||
|
|
146
|
+
Yup.string()
|
|
147
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
148
|
+
.test('valid-timezone', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid), (value) => !value || moment_timezone_1.default.tz.zone(value) !== null),
|
|
149
|
+
siteLanguage: siteLanguageValidation ||
|
|
150
|
+
Yup.string().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
151
|
+
currency: currencyValidation ||
|
|
152
|
+
Yup.string()
|
|
153
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
154
|
+
.test('valid-currency', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required), (value) => !value || i18n_lib_1.CurrencyCode.isValid(value)),
|
|
155
|
+
darkMode: darkModeValidation ||
|
|
156
|
+
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
157
|
+
directChallenge: directChallengeValidation ||
|
|
158
|
+
Yup.boolean().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
159
|
+
...(suite_core_lib_2.Constants.EnableDisplayName ? {
|
|
160
|
+
displayName: displayNameValidation ||
|
|
161
|
+
Yup.string()
|
|
162
|
+
.min(suite_core_lib_2.Constants.DisplayNameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMinLengthTemplate))
|
|
163
|
+
.max(suite_core_lib_2.Constants.DisplayNameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMaxLengthTemplate))
|
|
164
|
+
.matches(suite_core_lib_2.Constants.DisplayNameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameRegexErrorTemplate)),
|
|
165
|
+
} : {}),
|
|
166
|
+
};
|
|
167
|
+
const formik = (0, formik_1.useFormik)({
|
|
168
|
+
initialValues: {
|
|
169
|
+
...initialValues,
|
|
170
|
+
...additionalInitialValues,
|
|
171
|
+
},
|
|
172
|
+
enableReinitialize: true,
|
|
173
|
+
validationSchema: Yup.object({
|
|
174
|
+
email: validation.email,
|
|
175
|
+
timezone: validation.timezone,
|
|
176
|
+
siteLanguage: validation.siteLanguage,
|
|
177
|
+
currency: validation.currency,
|
|
178
|
+
darkMode: validation.darkMode,
|
|
179
|
+
directChallenge: validation.directChallenge,
|
|
180
|
+
...(suite_core_lib_2.Constants.EnableDisplayName && validation.displayName ? { displayName: validation.displayName } : {}),
|
|
181
|
+
...additionalValidation,
|
|
182
|
+
}),
|
|
183
|
+
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
184
|
+
setSaving(true);
|
|
185
|
+
setSuccessMessage(null);
|
|
186
|
+
const result = await onSubmit(values);
|
|
187
|
+
if ('success' in result && result.success) {
|
|
188
|
+
setSuccessMessage(result.message ||
|
|
189
|
+
labels.successMessage ||
|
|
190
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess));
|
|
191
|
+
setApiErrors({});
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const newApiErrors = {};
|
|
195
|
+
const fieldsToTouch = {};
|
|
196
|
+
if ('field' in result && result.field) {
|
|
197
|
+
setFieldError(result.field, result.error);
|
|
198
|
+
fieldsToTouch[result.field] = true;
|
|
199
|
+
}
|
|
200
|
+
if ('errors' in result && result.errors) {
|
|
201
|
+
result.errors.forEach((err) => {
|
|
202
|
+
if (err.path && err.msg) {
|
|
203
|
+
setFieldError(err.path, err.msg);
|
|
204
|
+
fieldsToTouch[err.path] = true;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if ('error' in result &&
|
|
209
|
+
result.error &&
|
|
210
|
+
!Object.keys(newApiErrors).length) {
|
|
211
|
+
newApiErrors.general = result.error;
|
|
212
|
+
}
|
|
213
|
+
setApiErrors(newApiErrors);
|
|
214
|
+
setTouched(fieldsToTouch, false);
|
|
215
|
+
}
|
|
216
|
+
setSubmitting(false);
|
|
217
|
+
setSaving(false);
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
221
|
+
mt: 4,
|
|
222
|
+
display: 'flex',
|
|
223
|
+
flexDirection: 'column',
|
|
224
|
+
alignItems: 'center',
|
|
225
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
226
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Title) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email ||
|
|
227
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: (formik.touched.email &&
|
|
228
|
+
(formik.errors.email || apiErrors.email)) ||
|
|
229
|
+
labels.emailHelper ||
|
|
230
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), suite_core_lib_2.Constants.EnableDisplayName && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "displayName", name: "displayName", label: labels.displayName ||
|
|
231
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_DisplayName), value: formik.values.displayName ?? '', onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.displayName && (formik.errors.displayName || apiErrors.displayName)), helperText: formik.touched.displayName && (formik.errors.displayName || apiErrors.displayName), margin: "normal" })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone ||
|
|
232
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone ||
|
|
233
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone &&
|
|
234
|
+
(formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "language-label", children: labels.siteLanguage ||
|
|
235
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "language-label", id: "siteLanguage", name: "siteLanguage", value: formik.values.siteLanguage, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.siteLanguage &&
|
|
236
|
+
Boolean(formik.errors.siteLanguage), label: labels.siteLanguage ||
|
|
237
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage), children: languages.map((lang) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: lang.code, children: lang.label }, lang.code))) }), formik.touched.siteLanguage &&
|
|
238
|
+
(formik.errors.siteLanguage || apiErrors.siteLanguage) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.siteLanguage || apiErrors.siteLanguage }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "currency-label", children: labels.currency ||
|
|
239
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "currency-label", id: "currency", name: "currency", value: formik.values.currency, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.currency && Boolean(formik.errors.currency), label: labels.currency ||
|
|
240
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency), children: currencies.map((curr) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: curr.code, children: curr.label }, curr.code))) }), formik.touched.currency &&
|
|
241
|
+
(formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode ||
|
|
242
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge ||
|
|
243
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper ||
|
|
244
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
|
|
245
|
+
? labels.saving ||
|
|
246
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
|
|
247
|
+
: labels.save ||
|
|
248
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Save) })] }), totpStatus !== undefined && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mt: 3, mb: 2 } }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "h2", gutterBottom: true, children: labels.totpSectionTitle || 'Two-Factor Authentication' }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: totpStatus
|
|
249
|
+
? (labels.totpStatusEnabled || '2FA is currently enabled')
|
|
250
|
+
: (labels.totpStatusDisabled || '2FA is currently disabled') }), totpError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 2 }, role: "alert", children: totpError })), !totpStatus && !showTotpSetup && ((0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", onClick: handleEnableTotp, disabled: totpSetupLoading, "data-testid": "enable-totp-button", children: totpSetupLoading
|
|
251
|
+
? 'Setting up...'
|
|
252
|
+
: (labels.totpEnableButton || 'Enable 2FA') })), showTotpSetup && totpProvisioningUri && totpSecret && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(TotpSetupForm_1.TotpSetupForm, { provisioningUri: totpProvisioningUri, secret: totpSecret, onConfirm: handleTotpConfirm }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-totp-setup-button", children: labels.totpCancelButton || 'Cancel' }) })] })), totpStatus && !showTotpSetup && !showDisablePrompt && !showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", color: "error", onClick: () => { setShowDisablePrompt(true); setTotpError(null); }, "data-testid": "disable-totp-button", children: labels.totpDisableButton || 'Disable 2FA' }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "outlined", onClick: () => { setShowResetPrompt(true); setTotpError(null); }, "data-testid": "reset-totp-button", children: labels.totpResetButton || 'Reset 2FA' })] })), showDisablePrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to disable two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-disable-code", name: "totp-disable-code", label: labels.totpDisableCodeLabel || 'TOTP Code', value: disableCode, onChange: (e) => setDisableCode(e.target.value), inputProps: {
|
|
253
|
+
'aria-label': labels.totpDisableCodeLabel || 'TOTP Code',
|
|
254
|
+
inputMode: 'numeric',
|
|
255
|
+
maxLength: 6,
|
|
256
|
+
pattern: '\\d{6}',
|
|
257
|
+
}, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "contained", color: "error", onClick: handleDisableTotp, disabled: disableSubmitting || !/^\d{6}$/.test(disableCode), "data-testid": "disable-totp-submit-button", children: disableSubmitting
|
|
258
|
+
? 'Disabling...'
|
|
259
|
+
: (labels.totpDisableSubmitButton || 'Confirm Disable') }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-disable-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] })), showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to reset two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-reset-code", name: "totp-reset-code", label: labels.totpResetCodeLabel || 'TOTP Code', value: resetCode, onChange: (e) => setResetCode(e.target.value), inputProps: {
|
|
260
|
+
'aria-label': labels.totpResetCodeLabel || 'TOTP Code',
|
|
261
|
+
inputMode: 'numeric',
|
|
262
|
+
maxLength: 6,
|
|
263
|
+
pattern: '\\d{6}',
|
|
264
|
+
}, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "contained", onClick: handleResetTotp, disabled: resetSubmitting || !/^\d{6}$/.test(resetCode), "data-testid": "reset-totp-submit-button", children: resetSubmitting
|
|
265
|
+
? 'Resetting...'
|
|
266
|
+
: (labels.totpResetSubmitButton || 'Confirm Reset') }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "button", variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-reset-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] }))] }))] }) }));
|
|
267
|
+
};
|
|
268
|
+
exports.UserSettingsForm = UserSettingsForm;
|
|
269
|
+
exports.default = exports.UserSettingsForm;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface VerifyEmailPageProps {
|
|
3
|
+
token: string | null;
|
|
4
|
+
onVerify: (token: string) => Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
message?: string;
|
|
7
|
+
}>;
|
|
8
|
+
labels?: {
|
|
9
|
+
title?: string;
|
|
10
|
+
verifying?: string;
|
|
11
|
+
success?: string;
|
|
12
|
+
failed?: string;
|
|
13
|
+
noToken?: string;
|
|
14
|
+
checkYourEmail?: string;
|
|
15
|
+
proceedToLogin?: string;
|
|
16
|
+
contactSupport?: string;
|
|
17
|
+
requestNewEmail?: string;
|
|
18
|
+
};
|
|
19
|
+
loginLink?: string;
|
|
20
|
+
resendLink?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const VerifyEmailPage: FC<VerifyEmailPageProps>;
|
|
23
|
+
export default VerifyEmailPage;
|
|
24
|
+
//# sourceMappingURL=VerifyEmailPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AAGjE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAwLpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifyEmailPage = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const contexts_1 = require("../contexts");
|
|
9
|
+
const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', resendLink = '/resend-verification', }) => {
|
|
10
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
11
|
+
const [message, setMessage] = (0, react_1.useState)('');
|
|
12
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
13
|
+
const [verificationStatus, setVerificationStatus] = (0, react_1.useState)('pending');
|
|
14
|
+
const translatedLabels = (0, react_1.useMemo)(() => {
|
|
15
|
+
return {
|
|
16
|
+
title: labels.title ||
|
|
17
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_EmailVerification),
|
|
18
|
+
success: labels.success ||
|
|
19
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Success),
|
|
20
|
+
failed: labels.failed ||
|
|
21
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Failed),
|
|
22
|
+
noToken: labels.noToken ||
|
|
23
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.NoVerificationTokenProvided),
|
|
24
|
+
checkYourEmail: labels.checkYourEmail ||
|
|
25
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_CheckYourEmail),
|
|
26
|
+
proceedToLogin: labels.proceedToLogin ||
|
|
27
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin),
|
|
28
|
+
contactSupport: labels.contactSupport ||
|
|
29
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.HavingTroubleContactSupport),
|
|
30
|
+
requestNewEmail: labels.requestNewEmail ||
|
|
31
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RequestNewVerificationEmail),
|
|
32
|
+
};
|
|
33
|
+
}, [labels, tComponent]);
|
|
34
|
+
// Use a ref to track whether verification has already been attempted,
|
|
35
|
+
// preventing infinite re-render loops from unstable onVerify references.
|
|
36
|
+
const hasVerified = (0, react_1.useRef)(false);
|
|
37
|
+
// Stable reference to onVerify to avoid re-triggering the effect
|
|
38
|
+
const onVerifyRef = (0, react_1.useRef)(onVerify);
|
|
39
|
+
onVerifyRef.current = onVerify;
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
if (hasVerified.current)
|
|
42
|
+
return;
|
|
43
|
+
if (token) {
|
|
44
|
+
hasVerified.current = true;
|
|
45
|
+
const verifyEmail = async () => {
|
|
46
|
+
try {
|
|
47
|
+
const result = await onVerifyRef.current(token);
|
|
48
|
+
if (result.success) {
|
|
49
|
+
setMessage(result.message || translatedLabels.success);
|
|
50
|
+
setVerificationStatus('success');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setMessage(result.message || translatedLabels.failed);
|
|
54
|
+
setVerificationStatus('error');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
setMessage(translatedLabels.failed);
|
|
59
|
+
setVerificationStatus('error');
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
verifyEmail();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
hasVerified.current = true;
|
|
69
|
+
setLoading(false);
|
|
70
|
+
setVerificationStatus('info');
|
|
71
|
+
}
|
|
72
|
+
}, [token, translatedLabels]);
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
74
|
+
mt: 8,
|
|
75
|
+
display: 'flex',
|
|
76
|
+
flexDirection: 'column',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%', mt: 2 }, children: verificationStatus === 'info' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: translatedLabels.noToken }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: verificationStatus === 'success' ? 'success' : 'error', sx: { mb: 2 }, children: message }), verificationStatus === 'success' && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", component: material_1.Link, href: loginLink, fullWidth: true, children: translatedLabels.proceedToLogin })), verificationStatus === 'error' && ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] }))] })) }))] }) }));
|
|
79
|
+
};
|
|
80
|
+
exports.VerifyEmailPage = VerifyEmailPage;
|
|
81
|
+
exports.default = exports.VerifyEmailPage;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// Component exports
|
|
2
1
|
export * from './ApiAccess';
|
|
3
2
|
export * from './BackupCodeLoginForm';
|
|
4
3
|
export * from './BackupCodesForm';
|
|
@@ -30,3 +29,4 @@ export * from './TDiv';
|
|
|
30
29
|
export * from './TImgAlt';
|
|
31
30
|
export * from './TotpSetupForm';
|
|
32
31
|
export * from './TotpVerificationForm';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,KAAK,CAAC;AACpB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// Component exports
|
|
5
|
+
tslib_1.__exportStar(require("./ApiAccess"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./BackupCodeLoginForm"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./BackupCodesForm"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./CategoryMenu"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./ChangePasswordForm"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./ConfirmationDialog"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./CurrencyCodeSelector"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./CurrencyInput"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./DashboardPage"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./DropdownMenu"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./ExpirationSecondsSelector"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./FakeEmailAdminPanel"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./Flag"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./ForgotPasswordForm"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./LoginForm"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./LogoutPage"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./RegisterForm"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./ResetPasswordForm"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./UserSettingsForm"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./SideMenu"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./SideMenuListItem"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./TopMenu"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./TranslatedTitle"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./UserMenu"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./UserLanguageSelector"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./VerifyEmailPage"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./T"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./TDiv"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./TImgAlt"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./TotpSetupForm"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./TotpVerificationForm"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IECIESConfig } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { IConstants } from '@digitaldefiance/suite-core-lib';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export { AuthContext, useAuth } from './auth-context';
|
|
5
|
+
export type { AuthContextData } from './auth-context';
|
|
6
|
+
export type AuthProviderProps = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
constants: IConstants;
|
|
10
|
+
eciesConfig: IECIESConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Optional callback to handle navigation after logout
|
|
13
|
+
* If not provided, logout will only clear auth state without navigation
|
|
14
|
+
*/
|
|
15
|
+
onLogout?: () => void;
|
|
16
|
+
emailDomain: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const AuthProvider: ({ children, baseUrl, constants, eciesConfig, onLogout, emailDomain, }: AuthProviderProps) => import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=AuthProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EAIb,MAAM,4BAA4B,CAAC;AAMpC,OAAO,EACL,UAAU,EAOX,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEL,SAAS,EAMV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAUtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAitBF,eAAO,MAAM,YAAY,GAAI,uEAO1B,iBAAiB,gCAYnB,CAAC"}
|