@digitaldefiance/express-suite-react-components 5.0.0 → 5.0.2
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/LICENSE +21 -0
- package/README.md +4 -0
- package/package.json +3 -4
- package/src/auth/AdminRoute.tsx +54 -0
- package/src/auth/Private.tsx +17 -0
- package/src/auth/PrivateRoute.tsx +28 -0
- package/src/auth/UnAuth.tsx +16 -0
- package/src/auth/UnAuthRoute.tsx +30 -0
- package/src/auth/{index.d.ts → index.ts} +2 -3
- package/src/components/ApiAccess.tsx +175 -0
- package/src/components/BackupCodeLoginForm.tsx +489 -0
- package/src/components/BackupCodesForm.tsx +287 -0
- package/src/components/CategoryMenu.tsx +155 -0
- package/src/components/ChangePasswordForm.tsx +273 -0
- package/src/components/ConfirmationDialog.tsx +48 -0
- package/src/components/CurrencyCodeSelector.tsx +60 -0
- package/src/components/CurrencyInput.tsx +80 -0
- package/src/components/DashboardPage.tsx +24 -0
- package/src/components/DropdownMenu.tsx +105 -0
- package/src/components/ExpirationSecondsSelector.tsx +60 -0
- package/src/components/FakeEmailAdminPanel.tsx +374 -0
- package/src/components/Flag.tsx +52 -0
- package/src/components/ForgotPasswordForm.tsx +174 -0
- package/src/components/LoginForm.tsx +468 -0
- package/src/components/LogoutPage.tsx +21 -0
- package/src/components/RegisterForm.tsx +1169 -0
- package/src/components/ResetPasswordForm.tsx +247 -0
- package/src/components/SideMenu.tsx +46 -0
- package/src/components/SideMenuListItem.tsx +75 -0
- package/src/components/T.tsx +24 -0
- package/src/components/TDiv.tsx +26 -0
- package/src/components/TImgAlt.tsx +28 -0
- package/src/components/TopMenu.tsx +252 -0
- package/src/components/TotpSetupForm.tsx +188 -0
- package/src/components/TotpVerificationForm.tsx +148 -0
- package/src/components/TranslatedTitle.tsx +31 -0
- package/src/components/UserLanguageSelector.tsx +45 -0
- package/src/components/UserMenu.tsx +15 -0
- package/src/components/UserSettingsForm.tsx +904 -0
- package/src/components/VerifyEmailPage.tsx +222 -0
- package/src/components/__tests__/RegisterForm.totp.spec.tsx +377 -0
- package/src/components/__tests__/TotpSetupForm.spec.tsx +258 -0
- package/src/components/__tests__/TotpVerificationForm.spec.tsx +259 -0
- package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +396 -0
- package/src/components/{index.d.ts → index.ts} +1 -1
- package/src/contexts/AuthProvider.spec.tsx +1284 -0
- package/src/contexts/AuthProvider.tsx +977 -0
- package/src/contexts/I18nProvider.tsx +164 -0
- package/src/contexts/MenuContext.tsx +426 -0
- package/src/contexts/SuiteConfigProvider.tsx +93 -0
- package/src/contexts/ThemeProvider.tsx +67 -0
- package/src/contexts/{index.d.ts → index.ts} +0 -1
- package/src/hooks/{index.d.ts → index.ts} +0 -1
- package/src/hooks/useAuthenticatedApi.tsx +67 -0
- package/src/hooks/useBackupCodes.ts +105 -0
- package/src/hooks/useEmailVerification.ts +54 -0
- package/src/hooks/useExpiringValue.ts +78 -0
- package/src/hooks/useLocalStorage.ts +18 -0
- package/src/hooks/useUserSettings.ts +271 -0
- package/src/{index.d.ts → index.ts} +1 -1
- package/src/interfaces/IAppConfig.ts +7 -0
- package/src/interfaces/ICategoryConfig.ts +41 -0
- package/src/interfaces/IMenuConfig.ts +28 -0
- package/src/interfaces/IMenuOption.ts +79 -0
- package/src/interfaces/{index.d.ts → index.ts} +0 -1
- package/src/services/__mocks__/authService.ts +14 -0
- package/src/services/__tests__/authService.totp.property.spec.ts +360 -0
- package/src/services/__tests__/authService.totp.spec.ts +439 -0
- package/src/services/api.ts +13 -0
- package/src/services/authService.ts +692 -0
- package/src/services/authenticatedApi.ts +17 -0
- package/src/services/index.ts +3 -0
- package/src/types/MenuType.ts +15 -0
- package/src/types/expirationSeconds.ts +18 -0
- package/src/types/index.ts +1 -0
- package/src/types/translation.ts +20 -0
- package/src/wrappers/BackupCodeLoginWrapper.tsx +34 -0
- package/src/wrappers/BackupCodesWrapper.tsx +28 -0
- package/src/wrappers/ChangePasswordFormWrapper.tsx +34 -0
- package/src/wrappers/ForgotPasswordFormWrapper.tsx +45 -0
- package/src/wrappers/LoginFormWrapper.tsx +108 -0
- package/src/wrappers/LogoutPageWrapper.tsx +30 -0
- package/src/wrappers/RegisterFormWrapper.tsx +109 -0
- package/src/wrappers/ResetPasswordFormWrapper.tsx +57 -0
- package/src/wrappers/UserSettingsFormWrapper.tsx +140 -0
- package/src/wrappers/VerifyEmailPageWrapper.tsx +27 -0
- package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +339 -0
- package/src/wrappers/{index.d.ts → index.tsx} +10 -1
- package/src/auth/AdminRoute.d.ts +0 -8
- package/src/auth/AdminRoute.d.ts.map +0 -1
- package/src/auth/AdminRoute.js +0 -28
- package/src/auth/Private.d.ts +0 -6
- package/src/auth/Private.d.ts.map +0 -1
- package/src/auth/Private.js +0 -14
- package/src/auth/PrivateRoute.d.ts +0 -8
- package/src/auth/PrivateRoute.d.ts.map +0 -1
- package/src/auth/PrivateRoute.js +0 -23
- package/src/auth/UnAuth.d.ts +0 -6
- package/src/auth/UnAuth.d.ts.map +0 -1
- package/src/auth/UnAuth.js +0 -14
- package/src/auth/UnAuthRoute.d.ts +0 -8
- package/src/auth/UnAuthRoute.d.ts.map +0 -1
- package/src/auth/UnAuthRoute.js +0 -22
- package/src/auth/index.d.ts.map +0 -1
- package/src/auth/index.js +0 -12
- package/src/components/ApiAccess.d.ts +0 -16
- package/src/components/ApiAccess.d.ts.map +0 -1
- package/src/components/ApiAccess.js +0 -77
- package/src/components/BackupCodeLoginForm.d.ts +0 -43
- package/src/components/BackupCodeLoginForm.d.ts.map +0 -1
- package/src/components/BackupCodeLoginForm.js +0 -139
- package/src/components/BackupCodesForm.d.ts +0 -26
- package/src/components/BackupCodesForm.d.ts.map +0 -1
- package/src/components/BackupCodesForm.js +0 -120
- package/src/components/CategoryMenu.d.ts +0 -17
- package/src/components/CategoryMenu.d.ts.map +0 -1
- package/src/components/CategoryMenu.js +0 -65
- package/src/components/ChangePasswordForm.d.ts +0 -26
- package/src/components/ChangePasswordForm.d.ts.map +0 -1
- package/src/components/ChangePasswordForm.js +0 -78
- package/src/components/ConfirmationDialog.d.ts +0 -13
- package/src/components/ConfirmationDialog.d.ts.map +0 -1
- package/src/components/ConfirmationDialog.js +0 -10
- package/src/components/CurrencyCodeSelector.d.ts +0 -9
- package/src/components/CurrencyCodeSelector.d.ts.map +0 -1
- package/src/components/CurrencyCodeSelector.js +0 -31
- package/src/components/CurrencyInput.d.ts +0 -13
- package/src/components/CurrencyInput.d.ts.map +0 -1
- package/src/components/CurrencyInput.js +0 -22
- package/src/components/DashboardPage.d.ts +0 -8
- package/src/components/DashboardPage.d.ts.map +0 -1
- package/src/components/DashboardPage.js +0 -10
- package/src/components/DropdownMenu.d.ts +0 -13
- package/src/components/DropdownMenu.d.ts.map +0 -1
- package/src/components/DropdownMenu.js +0 -63
- package/src/components/ExpirationSecondsSelector.d.ts +0 -13
- package/src/components/ExpirationSecondsSelector.d.ts.map +0 -1
- package/src/components/ExpirationSecondsSelector.js +0 -32
- package/src/components/FakeEmailAdminPanel.d.ts +0 -23
- package/src/components/FakeEmailAdminPanel.d.ts.map +0 -1
- package/src/components/FakeEmailAdminPanel.js +0 -147
- package/src/components/Flag.d.ts +0 -20
- package/src/components/Flag.d.ts.map +0 -1
- package/src/components/Flag.js +0 -43
- package/src/components/ForgotPasswordForm.d.ts +0 -18
- package/src/components/ForgotPasswordForm.d.ts.map +0 -1
- package/src/components/ForgotPasswordForm.js +0 -61
- package/src/components/LoginForm.d.ts +0 -44
- package/src/components/LoginForm.d.ts.map +0 -1
- package/src/components/LoginForm.js +0 -123
- package/src/components/LogoutPage.d.ts +0 -8
- package/src/components/LogoutPage.d.ts.map +0 -1
- package/src/components/LogoutPage.js +0 -16
- package/src/components/RegisterForm.d.ts +0 -100
- package/src/components/RegisterForm.d.ts.map +0 -1
- package/src/components/RegisterForm.js +0 -306
- package/src/components/ResetPasswordForm.d.ts +0 -23
- package/src/components/ResetPasswordForm.d.ts.map +0 -1
- package/src/components/ResetPasswordForm.js +0 -78
- package/src/components/SideMenu.d.ts +0 -8
- package/src/components/SideMenu.d.ts.map +0 -1
- package/src/components/SideMenu.js +0 -25
- package/src/components/SideMenuListItem.d.ts +0 -13
- package/src/components/SideMenuListItem.d.ts.map +0 -1
- package/src/components/SideMenuListItem.js +0 -44
- package/src/components/T.d.ts +0 -7
- package/src/components/T.d.ts.map +0 -1
- package/src/components/T.js +0 -13
- package/src/components/TDiv.d.ts +0 -9
- package/src/components/TDiv.d.ts.map +0 -1
- package/src/components/TDiv.js +0 -14
- package/src/components/TImgAlt.d.ts +0 -10
- package/src/components/TImgAlt.d.ts.map +0 -1
- package/src/components/TImgAlt.js +0 -14
- package/src/components/TopMenu.d.ts +0 -50
- package/src/components/TopMenu.d.ts.map +0 -1
- package/src/components/TopMenu.js +0 -79
- package/src/components/TotpSetupForm.d.ts +0 -24
- package/src/components/TotpSetupForm.d.ts.map +0 -1
- package/src/components/TotpSetupForm.js +0 -82
- package/src/components/TotpVerificationForm.d.ts +0 -23
- package/src/components/TotpVerificationForm.d.ts.map +0 -1
- package/src/components/TotpVerificationForm.js +0 -66
- package/src/components/TranslatedTitle.d.ts +0 -8
- package/src/components/TranslatedTitle.d.ts.map +0 -1
- package/src/components/TranslatedTitle.js +0 -15
- package/src/components/UserLanguageSelector.d.ts +0 -4
- package/src/components/UserLanguageSelector.d.ts.map +0 -1
- package/src/components/UserLanguageSelector.js +0 -31
- package/src/components/UserMenu.d.ts +0 -4
- package/src/components/UserMenu.d.ts.map +0 -1
- package/src/components/UserMenu.js +0 -12
- package/src/components/UserSettingsForm.d.ts +0 -113
- package/src/components/UserSettingsForm.d.ts.map +0 -1
- package/src/components/UserSettingsForm.js +0 -269
- package/src/components/VerifyEmailPage.d.ts +0 -24
- package/src/components/VerifyEmailPage.d.ts.map +0 -1
- package/src/components/VerifyEmailPage.js +0 -81
- package/src/components/index.d.ts.map +0 -1
- package/src/components/index.js +0 -35
- package/src/contexts/AuthProvider.d.ts +0 -186
- package/src/contexts/AuthProvider.d.ts.map +0 -1
- package/src/contexts/AuthProvider.js +0 -515
- package/src/contexts/I18nProvider.d.ts +0 -27
- package/src/contexts/I18nProvider.d.ts.map +0 -1
- package/src/contexts/I18nProvider.js +0 -60
- package/src/contexts/MenuContext.d.ts +0 -20
- package/src/contexts/MenuContext.d.ts.map +0 -1
- package/src/contexts/MenuContext.js +0 -275
- package/src/contexts/SuiteConfigProvider.d.ts +0 -44
- package/src/contexts/SuiteConfigProvider.d.ts.map +0 -1
- package/src/contexts/SuiteConfigProvider.js +0 -43
- package/src/contexts/ThemeProvider.d.ts +0 -15
- package/src/contexts/ThemeProvider.d.ts.map +0 -1
- package/src/contexts/ThemeProvider.js +0 -36
- package/src/contexts/index.d.ts.map +0 -1
- package/src/contexts/index.js +0 -8
- package/src/hooks/index.d.ts.map +0 -1
- package/src/hooks/index.js +0 -9
- package/src/hooks/useAuthenticatedApi.d.ts +0 -34
- package/src/hooks/useAuthenticatedApi.d.ts.map +0 -1
- package/src/hooks/useAuthenticatedApi.js +0 -46
- package/src/hooks/useBackupCodes.d.ts +0 -15
- package/src/hooks/useBackupCodes.d.ts.map +0 -1
- package/src/hooks/useBackupCodes.js +0 -74
- package/src/hooks/useEmailVerification.d.ts +0 -10
- package/src/hooks/useEmailVerification.d.ts.map +0 -1
- package/src/hooks/useEmailVerification.js +0 -40
- package/src/hooks/useExpiringValue.d.ts +0 -14
- package/src/hooks/useExpiringValue.d.ts.map +0 -1
- package/src/hooks/useExpiringValue.js +0 -53
- package/src/hooks/useLocalStorage.d.ts +0 -2
- package/src/hooks/useLocalStorage.d.ts.map +0 -1
- package/src/hooks/useLocalStorage.js +0 -15
- package/src/hooks/useUserSettings.d.ts +0 -48
- package/src/hooks/useUserSettings.d.ts.map +0 -1
- package/src/hooks/useUserSettings.js +0 -171
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -12
- package/src/interfaces/IAppConfig.d.ts +0 -8
- package/src/interfaces/IAppConfig.d.ts.map +0 -1
- package/src/interfaces/IAppConfig.js +0 -2
- package/src/interfaces/ICategoryConfig.d.ts +0 -41
- package/src/interfaces/ICategoryConfig.d.ts.map +0 -1
- package/src/interfaces/ICategoryConfig.js +0 -2
- package/src/interfaces/IMenuConfig.d.ts +0 -28
- package/src/interfaces/IMenuConfig.d.ts.map +0 -1
- package/src/interfaces/IMenuConfig.js +0 -2
- package/src/interfaces/IMenuOption.d.ts +0 -82
- package/src/interfaces/IMenuOption.d.ts.map +0 -1
- package/src/interfaces/IMenuOption.js +0 -2
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -7
- package/src/services/__mocks__/authService.d.ts +0 -21
- package/src/services/__mocks__/authService.d.ts.map +0 -1
- package/src/services/__mocks__/authService.js +0 -15
- package/src/services/api.d.ts +0 -3
- package/src/services/api.d.ts.map +0 -1
- package/src/services/api.js +0 -14
- package/src/services/authService.d.ts +0 -126
- package/src/services/authService.d.ts.map +0 -1
- package/src/services/authService.js +0 -471
- package/src/services/authenticatedApi.d.ts +0 -3
- package/src/services/authenticatedApi.d.ts.map +0 -1
- package/src/services/authenticatedApi.js +0 -18
- package/src/services/index.d.ts +0 -4
- package/src/services/index.d.ts.map +0 -1
- package/src/services/index.js +0 -6
- package/src/types/MenuType.d.ts +0 -11
- package/src/types/MenuType.d.ts.map +0 -1
- package/src/types/MenuType.js +0 -12
- package/src/types/expirationSeconds.d.ts +0 -3
- package/src/types/expirationSeconds.d.ts.map +0 -1
- package/src/types/expirationSeconds.js +0 -17
- package/src/types/index.d.ts +0 -2
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -4
- package/src/types/translation.d.ts +0 -10
- package/src/types/translation.d.ts.map +0 -1
- package/src/types/translation.js +0 -9
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +0 -8
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +0 -1
- package/src/wrappers/BackupCodeLoginWrapper.js +0 -20
- package/src/wrappers/BackupCodesWrapper.d.ts +0 -7
- package/src/wrappers/BackupCodesWrapper.d.ts.map +0 -1
- package/src/wrappers/BackupCodesWrapper.js +0 -17
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +0 -8
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ChangePasswordFormWrapper.js +0 -21
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts +0 -8
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ForgotPasswordFormWrapper.js +0 -29
- package/src/wrappers/LoginFormWrapper.d.ts +0 -21
- package/src/wrappers/LoginFormWrapper.d.ts.map +0 -1
- package/src/wrappers/LoginFormWrapper.js +0 -72
- package/src/wrappers/LogoutPageWrapper.d.ts +0 -9
- package/src/wrappers/LogoutPageWrapper.d.ts.map +0 -1
- package/src/wrappers/LogoutPageWrapper.js +0 -21
- package/src/wrappers/RegisterFormWrapper.d.ts +0 -20
- package/src/wrappers/RegisterFormWrapper.d.ts.map +0 -1
- package/src/wrappers/RegisterFormWrapper.js +0 -51
- package/src/wrappers/ResetPasswordFormWrapper.d.ts +0 -9
- package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +0 -1
- package/src/wrappers/ResetPasswordFormWrapper.js +0 -34
- package/src/wrappers/UserSettingsFormWrapper.d.ts +0 -29
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +0 -1
- package/src/wrappers/UserSettingsFormWrapper.js +0 -95
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +0 -8
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +0 -1
- package/src/wrappers/VerifyEmailPageWrapper.js +0 -21
- package/src/wrappers/index.d.ts.map +0 -1
- package/src/wrappers/index.js +0 -24
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoginForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
-
const icons_material_1 = require("@mui/icons-material");
|
|
8
|
-
const material_1 = require("@mui/material");
|
|
9
|
-
const formik_1 = require("formik");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
12
|
-
const contexts_1 = require("../contexts");
|
|
13
|
-
const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType: initialAuthType = 'password', allowLoginTypeToggle = true, allowAuthTypeToggle = true, showForgotPassword = true, showSignUp = true, forgotPasswordLink = '/forgot-password', signUpLink = '/register', emailLabel, usernameLabel, passwordLabel, mnemonicLabel, signInButtonText, forgotPasswordText, signUpText, useUsernameText, useEmailText, useMnemonicText, usePasswordText, toggleVisibilityLabel, titleText, emailValidation, usernameValidation, passwordValidation, mnemonicValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, }) => {
|
|
14
|
-
const { tComponent } = (0, contexts_1.useI18n)();
|
|
15
|
-
const [loginType, setLoginType] = (0, react_1.useState)(initialLoginType);
|
|
16
|
-
const [authType, setAuthType] = (0, react_1.useState)(initialAuthType);
|
|
17
|
-
const [showSecret, setShowSecret] = (0, react_1.useState)(false);
|
|
18
|
-
// Use translations with fallbacks
|
|
19
|
-
const labels = {
|
|
20
|
-
title: titleText ||
|
|
21
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_Title),
|
|
22
|
-
email: emailLabel ||
|
|
23
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email),
|
|
24
|
-
username: usernameLabel ||
|
|
25
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username),
|
|
26
|
-
password: passwordLabel ||
|
|
27
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password),
|
|
28
|
-
mnemonic: mnemonicLabel ||
|
|
29
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic),
|
|
30
|
-
signIn: signInButtonText ||
|
|
31
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.SignInButton),
|
|
32
|
-
forgotPassword: forgotPasswordText ||
|
|
33
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_ForgotPassword),
|
|
34
|
-
signUp: signUpText ||
|
|
35
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_SignUp),
|
|
36
|
-
useUsername: useUsernameText ||
|
|
37
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseUsername),
|
|
38
|
-
useEmail: useEmailText ||
|
|
39
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmailAddress),
|
|
40
|
-
useMnemonic: useMnemonicText ||
|
|
41
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic),
|
|
42
|
-
usePassword: usePasswordText ||
|
|
43
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword),
|
|
44
|
-
toggleVisibility: toggleVisibilityLabel ||
|
|
45
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.TogglePasswordVisibility),
|
|
46
|
-
passwordAuthInfo: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_PasswordAuthInfo),
|
|
47
|
-
};
|
|
48
|
-
const validation = {
|
|
49
|
-
email: emailValidation ||
|
|
50
|
-
Yup.string()
|
|
51
|
-
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
52
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
53
|
-
username: usernameValidation ||
|
|
54
|
-
Yup.string()
|
|
55
|
-
.matches(suite_core_lib_1.Constants.UsernameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate))
|
|
56
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
57
|
-
password: passwordValidation ||
|
|
58
|
-
Yup.string()
|
|
59
|
-
.min(1, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
60
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
61
|
-
mnemonic: mnemonicValidation ||
|
|
62
|
-
Yup.string()
|
|
63
|
-
.matches(suite_core_lib_1.Constants.MnemonicRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidMnemonic))
|
|
64
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
65
|
-
};
|
|
66
|
-
const formik = (0, formik_1.useFormik)({
|
|
67
|
-
initialValues: {
|
|
68
|
-
email: '',
|
|
69
|
-
username: '',
|
|
70
|
-
mnemonic: '',
|
|
71
|
-
password: '',
|
|
72
|
-
...additionalInitialValues,
|
|
73
|
-
},
|
|
74
|
-
validationSchema: Yup.object({
|
|
75
|
-
[loginType]: loginType === 'email' ? validation.email : validation.username,
|
|
76
|
-
...(authType === 'mnemonic'
|
|
77
|
-
? { mnemonic: validation.mnemonic }
|
|
78
|
-
: { password: validation.password }),
|
|
79
|
-
...additionalValidation,
|
|
80
|
-
}),
|
|
81
|
-
enableReinitialize: true,
|
|
82
|
-
onSubmit: async (values, { setStatus }) => {
|
|
83
|
-
try {
|
|
84
|
-
setStatus(null);
|
|
85
|
-
await onSubmit(values);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const err = error;
|
|
89
|
-
setStatus(err.message ||
|
|
90
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError));
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
96
|
-
marginTop: 8,
|
|
97
|
-
display: 'flex',
|
|
98
|
-
flexDirection: 'column',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: labels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [formik.status && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 2 }, children: formik.status })), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, id: loginType, label: loginType === 'email' ? labels.email : labels.username, name: loginType, autoComplete: loginType === 'email' ? 'email' : 'username', autoFocus: true, value: loginType === 'email'
|
|
101
|
-
? formik.values.email
|
|
102
|
-
: formik.values.username, onChange: formik.handleChange, error: formik.touched[loginType] && Boolean(formik.errors[loginType]), helperText: formik.touched[loginType] && formik.errors[loginType] }), authType === 'password' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: labels.password, id: "password", type: showSecret ? 'text' : 'password', value: formik.values.password, onChange: formik.handleChange, error: formik.touched.password && Boolean(formik.errors.password), helperText: formik.touched.password && formik.errors.password, slotProps: {
|
|
103
|
-
input: {
|
|
104
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": labels.toggleVisibility, onClick: () => setShowSecret(!showSecret), edge: "end", children: showSecret ? (0, jsx_runtime_1.jsx)(icons_material_1.VisibilityOff, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.Visibility, {}) }) })),
|
|
105
|
-
},
|
|
106
|
-
} }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mt: 1 }, children: labels.passwordAuthInfo })] })) : ((0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "mnemonic", label: labels.mnemonic, id: "mnemonic", multiline: true, rows: 3, autoComplete: "section-mnemonic current-password", value: formik.values.mnemonic, onChange: formik.handleChange, error: formik.touched.mnemonic && Boolean(formik.errors.mnemonic), helperText: formik.touched.mnemonic && formik.errors.mnemonic, type: showSecret ? 'text' : 'password', slotProps: {
|
|
107
|
-
input: {
|
|
108
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": labels.toggleVisibility, onClick: () => setShowSecret(!showSecret), edge: "end", children: showSecret ? (0, jsx_runtime_1.jsx)(icons_material_1.VisibilityOff, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.Visibility, {}) }) })),
|
|
109
|
-
},
|
|
110
|
-
} })), additionalFields && additionalFields(formik), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: labels.signIn }), (showForgotPassword || showSignUp) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', justifyContent: 'space-between' }, children: [showForgotPassword && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: forgotPasswordLink, variant: "body2", children: labels.forgotPassword })), showSignUp && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: signUpLink, variant: "body2", children: labels.signUp }))] })), (allowLoginTypeToggle || allowAuthTypeToggle) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 1, mt: 2 }, children: [allowLoginTypeToggle && ((0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () => {
|
|
111
|
-
const newType = loginType === 'email' ? 'username' : 'email';
|
|
112
|
-
formik.setFieldValue(loginType, '');
|
|
113
|
-
setLoginType(newType);
|
|
114
|
-
}, children: loginType === 'email' ? labels.useUsername : labels.useEmail })), allowAuthTypeToggle && ((0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () => {
|
|
115
|
-
const newType = authType === 'password' ? 'mnemonic' : 'password';
|
|
116
|
-
formik.setFieldValue(authType, '');
|
|
117
|
-
setAuthType(newType);
|
|
118
|
-
}, children: authType === 'password'
|
|
119
|
-
? labels.useMnemonic
|
|
120
|
-
: labels.usePassword }))] }))] })] }) }));
|
|
121
|
-
};
|
|
122
|
-
exports.LoginForm = LoginForm;
|
|
123
|
-
exports.default = exports.LoginForm;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface LogoutPageProps {
|
|
2
|
-
onLogout: () => Promise<void> | void;
|
|
3
|
-
onNavigate?: (path: string) => void;
|
|
4
|
-
redirectTo?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const LogoutPage: ({ onLogout, onNavigate, redirectTo }: LogoutPageProps) => null;
|
|
7
|
-
export default LogoutPage;
|
|
8
|
-
//# sourceMappingURL=LogoutPage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/LogoutPage.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,GAAI,sCAAiD,eAAe,SAU1F,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogoutPage = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const LogoutPage = ({ onLogout, onNavigate, redirectTo = '/login' }) => {
|
|
6
|
-
(0, react_1.useEffect)(() => {
|
|
7
|
-
const performLogout = async () => {
|
|
8
|
-
await onLogout();
|
|
9
|
-
onNavigate?.(redirectTo);
|
|
10
|
-
};
|
|
11
|
-
performLogout();
|
|
12
|
-
}, [onLogout, onNavigate, redirectTo]);
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
exports.LogoutPage = LogoutPage;
|
|
16
|
-
exports.default = exports.LogoutPage;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { useFormik } from 'formik';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import * as Yup from 'yup';
|
|
4
|
-
export interface RegisterFormValues {
|
|
5
|
-
username: string;
|
|
6
|
-
email: string;
|
|
7
|
-
displayName?: string;
|
|
8
|
-
timezone: string;
|
|
9
|
-
password?: string;
|
|
10
|
-
confirmPassword?: string;
|
|
11
|
-
directChallenge?: boolean;
|
|
12
|
-
mnemonic?: string;
|
|
13
|
-
[key: string]: string | boolean | undefined;
|
|
14
|
-
}
|
|
15
|
-
export interface RegisterFormProps {
|
|
16
|
-
onSubmit: (values: RegisterFormValues, usePassword: boolean) => Promise<{
|
|
17
|
-
success: boolean;
|
|
18
|
-
message: string;
|
|
19
|
-
mnemonic?: string;
|
|
20
|
-
} | {
|
|
21
|
-
error: string;
|
|
22
|
-
errorType?: string;
|
|
23
|
-
field?: string;
|
|
24
|
-
errors?: Array<{
|
|
25
|
-
path: string;
|
|
26
|
-
msg: string;
|
|
27
|
-
}>;
|
|
28
|
-
}>;
|
|
29
|
-
timezones: string[];
|
|
30
|
-
getInitialTimezone: () => string;
|
|
31
|
-
usernameValidation?: Yup.StringSchema;
|
|
32
|
-
emailValidation?: Yup.StringSchema;
|
|
33
|
-
displayNameValidation?: Yup.StringSchema;
|
|
34
|
-
timezoneValidation?: Yup.StringSchema;
|
|
35
|
-
passwordValidation?: Yup.StringSchema;
|
|
36
|
-
confirmPasswordValidation?: Yup.StringSchema;
|
|
37
|
-
/**
|
|
38
|
-
* When true, display a TOTP setup step after successful registration.
|
|
39
|
-
* Defaults to false. When false or not provided, existing flow is unchanged.
|
|
40
|
-
*/
|
|
41
|
-
enableTotpSetup?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Called to initiate TOTP setup (e.g. AuthService.setupTotp()).
|
|
44
|
-
* Must return provisioning URI and secret on success, or an error.
|
|
45
|
-
*/
|
|
46
|
-
onTotpSetup?: () => Promise<{
|
|
47
|
-
provisioningUri: string;
|
|
48
|
-
secret: string;
|
|
49
|
-
} | {
|
|
50
|
-
error: string;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* Called to confirm TOTP setup with a 6-digit code (e.g. AuthService.confirmTotp()).
|
|
54
|
-
*/
|
|
55
|
-
onTotpConfirm?: (code: string) => Promise<{
|
|
56
|
-
success: boolean;
|
|
57
|
-
} | {
|
|
58
|
-
error: string;
|
|
59
|
-
}>;
|
|
60
|
-
/**
|
|
61
|
-
* Called after the user successfully confirms TOTP during the registration flow.
|
|
62
|
-
*/
|
|
63
|
-
onTotpSetupComplete?: () => void;
|
|
64
|
-
/**
|
|
65
|
-
* List of email domains that are not allowed during registration.
|
|
66
|
-
* For example, the home system's email domain should be disallowed
|
|
67
|
-
* so users cannot register with addresses managed by the platform.
|
|
68
|
-
*/
|
|
69
|
-
disallowedEmailDomains?: string[];
|
|
70
|
-
additionalFields?: (formik: ReturnType<typeof useFormik<RegisterFormValues>>, usePassword: boolean) => React.ReactNode;
|
|
71
|
-
additionalInitialValues?: Record<string, string | boolean>;
|
|
72
|
-
additionalValidation?: Record<string, Yup.Schema>;
|
|
73
|
-
labels?: {
|
|
74
|
-
title?: string;
|
|
75
|
-
username?: string;
|
|
76
|
-
email?: string;
|
|
77
|
-
displayName?: string;
|
|
78
|
-
timezone?: string;
|
|
79
|
-
password?: string;
|
|
80
|
-
confirmPassword?: string;
|
|
81
|
-
useMnemonic?: string;
|
|
82
|
-
usePassword?: string;
|
|
83
|
-
registering?: string;
|
|
84
|
-
register?: string;
|
|
85
|
-
successTitle?: string;
|
|
86
|
-
mnemonicSuccess?: string;
|
|
87
|
-
proceedToLogin?: string;
|
|
88
|
-
savedRecoveryPhrase?: string;
|
|
89
|
-
loginLink?: string;
|
|
90
|
-
mnemonic?: string;
|
|
91
|
-
totpSetupTitle?: string;
|
|
92
|
-
totpSkipButton?: string;
|
|
93
|
-
totpSetupError?: string;
|
|
94
|
-
totpSetupSuccess?: string;
|
|
95
|
-
passwordAuthInfo?: string;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
export declare const RegisterForm: FC<RegisterFormProps>;
|
|
99
|
-
export default RegisterForm;
|
|
100
|
-
//# sourceMappingURL=RegisterForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CACR,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,OAAO,KACjB,OAAO,CACR;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC/C,CACJ,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,qBAAqB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACzC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CACzB;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAChE,CAAC;IACF;;OAEG;IACH,aAAa,CAAC,EAAE,CACd,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,kBAAkB,CAAC,CAAC,EACxD,WAAW,EAAE,OAAO,KACjB,KAAK,CAAC,SAAS,CAAC;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC3D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAmhC9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegisterForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const formik_1 = require("formik");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
|
-
const bip39_1 = require("bip39");
|
|
12
|
-
const contexts_1 = require("../contexts");
|
|
13
|
-
const TotpSetupForm_1 = require("./TotpSetupForm");
|
|
14
|
-
const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidation, emailValidation, displayNameValidation, timezoneValidation, passwordValidation, confirmPasswordValidation, enableTotpSetup = false, onTotpSetup, onTotpConfirm, onTotpSetupComplete, disallowedEmailDomains, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
15
|
-
const { tComponent } = (0, contexts_1.useI18n)();
|
|
16
|
-
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
17
|
-
const [mnemonic, setMnemonic] = (0, react_1.useState)(null);
|
|
18
|
-
const [usePassword, setUsePassword] = (0, react_1.useState)(true);
|
|
19
|
-
const [registrationSuccess, setRegistrationSuccess] = (0, react_1.useState)(false);
|
|
20
|
-
const [registering, setRegistering] = (0, react_1.useState)(false);
|
|
21
|
-
const [showMnemonicInput, setShowMnemonicInput] = (0, react_1.useState)(false);
|
|
22
|
-
const [autoMnemonic, setAutoMnemonic] = (0, react_1.useState)(() => (0, bip39_1.generateMnemonic)(256));
|
|
23
|
-
const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
|
|
24
|
-
const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
|
|
25
|
-
const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
|
|
26
|
-
const [totpSetupError, setTotpSetupError] = (0, react_1.useState)(null);
|
|
27
|
-
const [totpSetupComplete, setTotpSetupComplete] = (0, react_1.useState)(false);
|
|
28
|
-
const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
|
|
29
|
-
const initiateTotpSetup = (0, react_1.useCallback)(async () => {
|
|
30
|
-
if (!onTotpSetup)
|
|
31
|
-
return;
|
|
32
|
-
setTotpSetupLoading(true);
|
|
33
|
-
setTotpSetupError(null);
|
|
34
|
-
try {
|
|
35
|
-
const result = await onTotpSetup();
|
|
36
|
-
if ('error' in result) {
|
|
37
|
-
setTotpSetupError(result.error);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
setTotpProvisioningUri(result.provisioningUri);
|
|
41
|
-
setTotpSecret(result.secret);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
setTotpSetupError(labels.totpSetupError || 'Failed to set up two-factor authentication');
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
setTotpSetupLoading(false);
|
|
49
|
-
}
|
|
50
|
-
}, [onTotpSetup, labels.totpSetupError]);
|
|
51
|
-
const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
|
|
52
|
-
if (!onTotpConfirm) {
|
|
53
|
-
return { error: 'TOTP confirmation is not available' };
|
|
54
|
-
}
|
|
55
|
-
const result = await onTotpConfirm(code);
|
|
56
|
-
if ('success' in result && result.success) {
|
|
57
|
-
setTotpSetupComplete(true);
|
|
58
|
-
setShowTotpSetup(false);
|
|
59
|
-
if (onTotpSetupComplete) {
|
|
60
|
-
onTotpSetupComplete();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
}, [onTotpConfirm, onTotpSetupComplete]);
|
|
65
|
-
const handleSkipTotp = (0, react_1.useCallback)(() => {
|
|
66
|
-
setShowTotpSetup(false);
|
|
67
|
-
}, []);
|
|
68
|
-
const validation = {
|
|
69
|
-
username: usernameValidation ||
|
|
70
|
-
Yup.string()
|
|
71
|
-
.min(suite_core_lib_1.Constants.UsernameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameMinLengthTemplate))
|
|
72
|
-
.max(suite_core_lib_1.Constants.UsernameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameMaxLengthTemplate))
|
|
73
|
-
.matches(suite_core_lib_1.Constants.UsernameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate))
|
|
74
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
75
|
-
email: emailValidation ||
|
|
76
|
-
Yup.string()
|
|
77
|
-
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
78
|
-
.test('disallowed-domain', '', function (value) {
|
|
79
|
-
if (!value || !disallowedEmailDomains?.length)
|
|
80
|
-
return true;
|
|
81
|
-
const atIndex = value.lastIndexOf('@');
|
|
82
|
-
if (atIndex <= 0)
|
|
83
|
-
return true;
|
|
84
|
-
const domain = value.slice(atIndex + 1).toLowerCase();
|
|
85
|
-
const blocked = disallowedEmailDomains.find((d) => d.toLowerCase() === domain);
|
|
86
|
-
if (!blocked)
|
|
87
|
-
return true;
|
|
88
|
-
return this.createError({
|
|
89
|
-
message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_EmailDomainNotAllowedTemplate, { domain: blocked }),
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
93
|
-
displayName: !suite_core_lib_1.Constants.EnableDisplayName
|
|
94
|
-
? Yup.string().strip()
|
|
95
|
-
: displayNameValidation ||
|
|
96
|
-
Yup.string()
|
|
97
|
-
.min(suite_core_lib_1.Constants.DisplayNameMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMinLengthTemplate))
|
|
98
|
-
.max(suite_core_lib_1.Constants.DisplayNameMaxLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameMaxLengthTemplate))
|
|
99
|
-
.matches(suite_core_lib_1.Constants.DisplayNameRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_DisplayNameRegexErrorTemplate))
|
|
100
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
101
|
-
directChallenge: Yup.boolean(),
|
|
102
|
-
timezone: timezoneValidation ||
|
|
103
|
-
Yup.string()
|
|
104
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
105
|
-
.oneOf(timezones, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid)),
|
|
106
|
-
password: passwordValidation ||
|
|
107
|
-
Yup.string()
|
|
108
|
-
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate))
|
|
109
|
-
.min(8, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate))
|
|
110
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
111
|
-
confirmPassword: confirmPasswordValidation ||
|
|
112
|
-
Yup.string()
|
|
113
|
-
.oneOf([Yup.ref('password')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch))
|
|
114
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
115
|
-
mnemonic: Yup.string()
|
|
116
|
-
.optional()
|
|
117
|
-
.test('mnemonic-format', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRegex), (value) => {
|
|
118
|
-
if (!value || value.trim() === '')
|
|
119
|
-
return true;
|
|
120
|
-
return suite_core_lib_1.Constants.MnemonicRegex.test(value.trim());
|
|
121
|
-
}),
|
|
122
|
-
};
|
|
123
|
-
const formik = (0, formik_1.useFormik)({
|
|
124
|
-
initialValues: {
|
|
125
|
-
username: '',
|
|
126
|
-
email: '',
|
|
127
|
-
...(suite_core_lib_1.Constants.EnableDisplayName ? { displayName: '' } : {}),
|
|
128
|
-
timezone: getInitialTimezone(),
|
|
129
|
-
password: '',
|
|
130
|
-
confirmPassword: '',
|
|
131
|
-
directChallenge: false,
|
|
132
|
-
mnemonic: '',
|
|
133
|
-
...additionalInitialValues,
|
|
134
|
-
},
|
|
135
|
-
enableReinitialize: true,
|
|
136
|
-
validationSchema: Yup.object({
|
|
137
|
-
username: validation.username,
|
|
138
|
-
email: validation.email,
|
|
139
|
-
...(suite_core_lib_1.Constants.EnableDisplayName
|
|
140
|
-
? { displayName: validation.displayName }
|
|
141
|
-
: {}),
|
|
142
|
-
timezone: validation.timezone,
|
|
143
|
-
...(usePassword
|
|
144
|
-
? {
|
|
145
|
-
password: validation.password,
|
|
146
|
-
confirmPassword: validation.confirmPassword,
|
|
147
|
-
}
|
|
148
|
-
: {}),
|
|
149
|
-
...(showMnemonicInput ? { mnemonic: validation.mnemonic } : {}),
|
|
150
|
-
...additionalValidation,
|
|
151
|
-
}),
|
|
152
|
-
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
153
|
-
setRegistering(true);
|
|
154
|
-
setApiErrors({});
|
|
155
|
-
try {
|
|
156
|
-
const effectiveMnemonic = !showMnemonicInput
|
|
157
|
-
? autoMnemonic
|
|
158
|
-
: (values.mnemonic?.trim() || autoMnemonic);
|
|
159
|
-
const registerResult = await onSubmit({ ...values, mnemonic: effectiveMnemonic }, usePassword);
|
|
160
|
-
if ('success' in registerResult && registerResult.success) {
|
|
161
|
-
setRegistrationSuccess(true);
|
|
162
|
-
if (registerResult.mnemonic) {
|
|
163
|
-
setMnemonic(registerResult.mnemonic);
|
|
164
|
-
}
|
|
165
|
-
if (enableTotpSetup && onTotpSetup) {
|
|
166
|
-
setShowTotpSetup(true);
|
|
167
|
-
// Fire-and-forget: initiate TOTP setup in background
|
|
168
|
-
// The setup state is managed by initiateTotpSetup
|
|
169
|
-
initiateTotpSetup();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
setRegistrationSuccess(false);
|
|
174
|
-
const newApiErrors = {};
|
|
175
|
-
const fieldsToTouch = {};
|
|
176
|
-
if ('field' in registerResult && registerResult.field) {
|
|
177
|
-
setFieldError(registerResult.field, registerResult.error);
|
|
178
|
-
fieldsToTouch[registerResult.field] = true;
|
|
179
|
-
}
|
|
180
|
-
if ('errors' in registerResult && registerResult.errors) {
|
|
181
|
-
registerResult.errors.forEach((err) => {
|
|
182
|
-
if (err.path && err.msg) {
|
|
183
|
-
setFieldError(err.path, err.msg);
|
|
184
|
-
fieldsToTouch[err.path] = true;
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
if ('error' in registerResult &&
|
|
189
|
-
registerResult.error &&
|
|
190
|
-
!Object.keys(newApiErrors).length) {
|
|
191
|
-
newApiErrors.general = registerResult.error;
|
|
192
|
-
}
|
|
193
|
-
setApiErrors(newApiErrors);
|
|
194
|
-
setTouched(fieldsToTouch, false);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (err) {
|
|
198
|
-
console.error('[RegisterForm] onSubmit error:', err);
|
|
199
|
-
setApiErrors({
|
|
200
|
-
general: err instanceof Error ? err.message : String(err),
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
setSubmitting(false);
|
|
204
|
-
setRegistering(false);
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
208
|
-
mt: 8,
|
|
209
|
-
display: 'flex',
|
|
210
|
-
flexDirection: 'column',
|
|
211
|
-
alignItems: 'center',
|
|
212
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
213
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), mnemonic || registrationSuccess ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, width: '100%' }, children: showTotpSetup && !totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", sx: { textAlign: 'center' }, children: labels.totpSetupTitle || 'Set Up Two-Factor Authentication' }), totpSetupLoading && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { textAlign: 'center', mt: 2 }, children: "Loading TOTP setup..." })), totpSetupError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: totpSetupError })), totpProvisioningUri && totpSecret && ((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: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleSkipTotp, "data-testid": "skip-totp-button", children: labels.totpSkipButton || 'Skip' }) })] })) : totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.totpSetupSuccess ||
|
|
214
|
-
'Two-factor authentication has been enabled successfully.' }), mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
215
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
216
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
217
|
-
display: 'grid',
|
|
218
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
219
|
-
gap: 1.5,
|
|
220
|
-
mb: 3,
|
|
221
|
-
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
222
|
-
display: 'flex',
|
|
223
|
-
alignItems: 'center',
|
|
224
|
-
justifyContent: 'center',
|
|
225
|
-
gap: 0.5,
|
|
226
|
-
py: 1,
|
|
227
|
-
px: 1.5,
|
|
228
|
-
borderRadius: 2,
|
|
229
|
-
border: '1px solid',
|
|
230
|
-
borderColor: 'divider',
|
|
231
|
-
bgcolor: 'action.hover',
|
|
232
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
233
|
-
labels.proceedToLogin ||
|
|
234
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
235
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
236
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] }))] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
237
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
238
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
239
|
-
display: 'grid',
|
|
240
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
241
|
-
gap: 1.5,
|
|
242
|
-
mb: 3,
|
|
243
|
-
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
244
|
-
display: 'flex',
|
|
245
|
-
alignItems: 'center',
|
|
246
|
-
justifyContent: 'center',
|
|
247
|
-
gap: 0.5,
|
|
248
|
-
py: 1,
|
|
249
|
-
px: 1.5,
|
|
250
|
-
borderRadius: 2,
|
|
251
|
-
border: '1px solid',
|
|
252
|
-
borderColor: 'divider',
|
|
253
|
-
bgcolor: 'action.hover',
|
|
254
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
255
|
-
labels.proceedToLogin ||
|
|
256
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
257
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
258
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })) })) })) : ((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: "username", name: "username", label: labels.username ||
|
|
259
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username), value: formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.username &&
|
|
260
|
-
(formik.errors.username || apiErrors.username)), helperText: formik.touched.username &&
|
|
261
|
-
(formik.errors.username || apiErrors.username), margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email ||
|
|
262
|
-
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 && (formik.errors.email || apiErrors.email), margin: "normal" }), suite_core_lib_1.Constants.EnableDisplayName && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "displayName", name: "displayName", label: labels.displayName ||
|
|
263
|
-
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 &&
|
|
264
|
-
(formik.errors.displayName || apiErrors.displayName)), helperText: formik.touched.displayName &&
|
|
265
|
-
(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 ||
|
|
266
|
-
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 ||
|
|
267
|
-
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 &&
|
|
268
|
-
(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.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: () => setUsePassword(!usePassword), children: usePassword
|
|
269
|
-
? labels.useMnemonic ||
|
|
270
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic)
|
|
271
|
-
: labels.usePassword ||
|
|
272
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password ||
|
|
273
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword ||
|
|
274
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword &&
|
|
275
|
-
formik.errors.confirmPassword), helperText: formik.touched.confirmPassword &&
|
|
276
|
-
formik.errors.confirmPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mt: 1 }, children: labels?.passwordAuthInfo ||
|
|
277
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_PasswordAuthInfo) })] })), (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.Checkbox, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge || false, onChange: formik.handleChange }), label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik, usePassword), !showMnemonicInput && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: labels.mnemonic || 'Your Recovery Phrase — save this before registering' }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
278
|
-
display: 'grid',
|
|
279
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
280
|
-
gap: 1,
|
|
281
|
-
mb: 1,
|
|
282
|
-
}, children: autoMnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
283
|
-
display: 'flex',
|
|
284
|
-
alignItems: 'center',
|
|
285
|
-
gap: 0.5,
|
|
286
|
-
py: 0.5,
|
|
287
|
-
px: 1,
|
|
288
|
-
borderRadius: 1,
|
|
289
|
-
border: '1px solid',
|
|
290
|
-
borderColor: 'divider',
|
|
291
|
-
bgcolor: 'action.hover',
|
|
292
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "warning", sx: { mb: 1 }, children: "Write down these words in order. You will need them to recover your account." }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", size: "small", onClick: () => setAutoMnemonic((0, bip39_1.generateMnemonic)(256)), children: "Regenerate" })] })), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", size: "small", onClick: () => setShowMnemonicInput(!showMnemonicInput), "aria-expanded": showMnemonicInput, "aria-controls": "mnemonic-input", children: showMnemonicInput
|
|
293
|
-
? tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ClearMnemonic)
|
|
294
|
-
: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic) }) }), showMnemonicInput && ((0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "mnemonic-input", name: "mnemonic", label: labels.mnemonic ||
|
|
295
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic), value: formik.values.mnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.mnemonic &&
|
|
296
|
-
(formik.errors.mnemonic || apiErrors.mnemonic)), helperText: formik.touched.mnemonic &&
|
|
297
|
-
(formik.errors.mnemonic || apiErrors.mnemonic), margin: "normal", multiline: true, minRows: 2 })), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (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: registering
|
|
298
|
-
? labels.registering ||
|
|
299
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering)
|
|
300
|
-
: labels.register ||
|
|
301
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisterButton) }), registering && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.registering ||
|
|
302
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisteringMessage) })] })), !registrationSuccess && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", variant: "body2", children: labels.loginLink ||
|
|
303
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_LoginLink) }) }))] }))] }) }));
|
|
304
|
-
};
|
|
305
|
-
exports.RegisterForm = RegisterForm;
|
|
306
|
-
exports.default = exports.RegisterForm;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import * as Yup from 'yup';
|
|
3
|
-
export interface ResetPasswordFormValues {
|
|
4
|
-
password: string;
|
|
5
|
-
confirmPassword: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ResetPasswordFormProps {
|
|
8
|
-
token: string | null;
|
|
9
|
-
onSubmit: (token: string, password: string) => Promise<void>;
|
|
10
|
-
passwordValidation?: Yup.StringSchema;
|
|
11
|
-
confirmPasswordValidation?: Yup.StringSchema;
|
|
12
|
-
labels?: {
|
|
13
|
-
title?: string;
|
|
14
|
-
password?: string;
|
|
15
|
-
confirmPassword?: string;
|
|
16
|
-
resetButton?: string;
|
|
17
|
-
successMessage?: string;
|
|
18
|
-
invalidToken?: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export declare const ResetPasswordForm: FC<ResetPasswordFormProps>;
|
|
22
|
-
export default ResetPasswordForm;
|
|
23
|
-
//# sourceMappingURL=ResetPasswordForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResetPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ResetPasswordForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA6MxD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|