@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,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TImgAlt = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// src/app/components/TImgAlt.tsx
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const contexts_1 = require("../contexts");
|
|
8
|
+
const TImgAlt = ({ src, stringKey, vars, imgOptions, }) => {
|
|
9
|
+
const { currentLanguage, tBranded } = (0, contexts_1.useI18n)();
|
|
10
|
+
const translated = (0, react_1.useMemo)(() => tBranded(stringKey, vars, currentLanguage), [tBranded, stringKey, vars, currentLanguage]);
|
|
11
|
+
return (0, jsx_runtime_1.jsx)("img", { src: src, ...imgOptions, alt: translated });
|
|
12
|
+
};
|
|
13
|
+
exports.TImgAlt = TImgAlt;
|
|
14
|
+
exports.default = exports.TImgAlt;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IConstants } from '@digitaldefiance/suite-core-lib';
|
|
2
|
+
import React, { FC, ReactElement } from 'react';
|
|
3
|
+
import { ICategoryConfig } from '../interfaces/ICategoryConfig';
|
|
4
|
+
import { MenuType } from '../types/MenuType';
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
APP_CONFIG?: {
|
|
8
|
+
hostname: string;
|
|
9
|
+
siteTitle: string;
|
|
10
|
+
server: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export interface AdditionalDropdownMenu {
|
|
16
|
+
menuType: MenuType;
|
|
17
|
+
menuIcon: ReactElement;
|
|
18
|
+
priority?: number;
|
|
19
|
+
/** Optional callback invoked when the icon button is clicked. */
|
|
20
|
+
action?: () => void;
|
|
21
|
+
/** When true, the menu icon is hidden if there are no sub-options. Defaults to false. */
|
|
22
|
+
hideWhenEmpty?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optional category id. When the TopMenu is given matching `categories`,
|
|
25
|
+
* this menu is rendered inside that category's popover instead of inline.
|
|
26
|
+
*/
|
|
27
|
+
category?: string;
|
|
28
|
+
/** Optional label used for tile captions and tooltips. */
|
|
29
|
+
label?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TopMenuProps {
|
|
32
|
+
Logo: React.ReactNode;
|
|
33
|
+
additionalMenus?: Array<AdditionalDropdownMenu>;
|
|
34
|
+
/**
|
|
35
|
+
* Optional category configurations. When provided, any menu (whether
|
|
36
|
+
* registered via `MenuContext` or passed in `additionalMenus`) whose
|
|
37
|
+
* `category` matches a category `id` is rendered as a tile inside that
|
|
38
|
+
* category's mega-menu popover. Menus without a matching category render
|
|
39
|
+
* inline in the AppBar exactly as before, so this is backwards compatible:
|
|
40
|
+
* omit `categories` (or use empty array) for the original layout.
|
|
41
|
+
*/
|
|
42
|
+
categories?: ICategoryConfig[];
|
|
43
|
+
/** Custom action elements rendered in the toolbar after menu dropdowns (e.g. notification bell). Only shown when authenticated. */
|
|
44
|
+
actions?: React.ReactNode;
|
|
45
|
+
constants?: IConstants;
|
|
46
|
+
showTitle?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare const TopMenu: FC<TopMenuProps>;
|
|
49
|
+
export default TopMenu;
|
|
50
|
+
//# sourceMappingURL=TopMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TopMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIX,MAAM,iCAAiC,CAAC;AAUzC,OAAO,KAAK,EAAE,EAEZ,EAAE,EACF,YAAY,EAIb,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAQ7C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,CAAC,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,MAAM,EAAE,MAAM,CAAC;YACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,eAAe,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,mIAAmI;IACnI,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAsKpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TopMenu = 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 Menu_1 = tslib_1.__importDefault(require("@mui/icons-material/Menu"));
|
|
8
|
+
const material_1 = require("@mui/material");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_router_1 = require("react-router");
|
|
11
|
+
const AuthProvider_1 = require("../contexts/AuthProvider");
|
|
12
|
+
const I18nProvider_1 = require("../contexts/I18nProvider");
|
|
13
|
+
const MenuContext_1 = require("../contexts/MenuContext");
|
|
14
|
+
const CategoryMenu_1 = require("./CategoryMenu");
|
|
15
|
+
const DropdownMenu_1 = require("./DropdownMenu");
|
|
16
|
+
const SideMenu_1 = require("./SideMenu");
|
|
17
|
+
const UserLanguageSelector_1 = require("./UserLanguageSelector");
|
|
18
|
+
const UserMenu_1 = require("./UserMenu");
|
|
19
|
+
const TopMenu = ({ Logo, additionalMenus, categories, actions, constants, showTitle, }) => {
|
|
20
|
+
const { isAuthenticated } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
|
|
21
|
+
const { getTopMenus } = (0, MenuContext_1.useMenu)();
|
|
22
|
+
const [isSideMenuOpen, setIsSideMenuOpen] = (0, react_1.useState)(false);
|
|
23
|
+
const handleOpenSideMenu = () => setIsSideMenuOpen(true);
|
|
24
|
+
const handleCloseSideMenu = () => setIsSideMenuOpen(false);
|
|
25
|
+
const { tComponent } = (0, I18nProvider_1.useI18n)();
|
|
26
|
+
// When constants are explicitly provided, pass Site as a template variable
|
|
27
|
+
// override. Otherwise let the i18n engine resolve {Site} from its registered
|
|
28
|
+
// constants (which the consuming app sets up via createI18nSetup).
|
|
29
|
+
const siteTitle = tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_SiteTemplate, constants ? { Site: constants.Site } : undefined);
|
|
30
|
+
const allMenus = (0, react_1.useMemo)(() => {
|
|
31
|
+
const contextMenus = getTopMenus();
|
|
32
|
+
if (!additionalMenus || additionalMenus.length === 0) {
|
|
33
|
+
return contextMenus;
|
|
34
|
+
}
|
|
35
|
+
const additional = additionalMenus.map((m) => ({
|
|
36
|
+
...m,
|
|
37
|
+
options: [],
|
|
38
|
+
isUserMenu: false,
|
|
39
|
+
}));
|
|
40
|
+
return [...contextMenus, ...additional].sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
41
|
+
}, [getTopMenus, additionalMenus]);
|
|
42
|
+
// Split menus into those that belong to a configured category vs. those
|
|
43
|
+
// that should render inline in the AppBar (default, backwards-compatible
|
|
44
|
+
// behaviour). The user menu is always inline.
|
|
45
|
+
const { inlineMenus, menusByCategory, orderedCategories } = (0, react_1.useMemo)(() => {
|
|
46
|
+
const hasCategories = !!categories && categories.length > 0;
|
|
47
|
+
const categoryIds = new Set(hasCategories ? categories.map((c) => c.id) : []);
|
|
48
|
+
const byCategory = new Map();
|
|
49
|
+
const inline = [];
|
|
50
|
+
for (const menu of allMenus) {
|
|
51
|
+
const cat = menu.category;
|
|
52
|
+
if (!menu.isUserMenu && hasCategories && cat && categoryIds.has(cat)) {
|
|
53
|
+
const list = byCategory.get(cat) ?? [];
|
|
54
|
+
list.push(menu);
|
|
55
|
+
byCategory.set(cat, list);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
inline.push(menu);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const ordered = hasCategories
|
|
62
|
+
? [...categories].sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
|
|
63
|
+
: [];
|
|
64
|
+
return {
|
|
65
|
+
inlineMenus: inline,
|
|
66
|
+
menusByCategory: byCategory,
|
|
67
|
+
orderedCategories: ordered,
|
|
68
|
+
};
|
|
69
|
+
}, [allMenus, categories]);
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.AppBar, { position: "fixed", sx: { top: 10 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "large", edge: "start", color: "inherit", "aria-label": "menu", sx: { mr: 2 }, onClick: handleOpenSideMenu, children: (0, jsx_runtime_1.jsx)(Menu_1.default, {}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
71
|
+
height: 40,
|
|
72
|
+
width: 'auto',
|
|
73
|
+
marginRight: 2,
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
}, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: showTitle !== false ? siteTitle : '\u00A0' }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: [isAuthenticated ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_1.Link, to: "/dashboard", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard) }), inlineMenus.map((menu, index) => menu.isUserMenu ? ((0, jsx_runtime_1.jsx)(UserMenu_1.UserMenu, {}, `user-menu`)) : ((0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: menu.menuType, menuIcon: menu.menuIcon, action: menu.action, hideWhenEmpty: menu.hideWhenEmpty }, `menu-${index}`))), orderedCategories.map((category) => ((0, jsx_runtime_1.jsx)(CategoryMenu_1.CategoryMenu, { category: category, menus: menusByCategory.get(category.id) ?? [] }, `category-${category.id}`)))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_1.Link, to: "/login", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_LoginButton) }), (0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_1.Link, to: "/register", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton) })] })), isAuthenticated && actions, (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
|
|
77
|
+
};
|
|
78
|
+
exports.TopMenu = TopMenu;
|
|
79
|
+
exports.default = exports.TopMenu;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface TotpSetupFormValues {
|
|
3
|
+
code: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TotpSetupFormProps {
|
|
6
|
+
provisioningUri: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
onConfirm: (code: string) => Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
error: string;
|
|
12
|
+
}>;
|
|
13
|
+
labels?: {
|
|
14
|
+
title?: string;
|
|
15
|
+
qrCodeAlt?: string;
|
|
16
|
+
secretLabel?: string;
|
|
17
|
+
codeLabel?: string;
|
|
18
|
+
confirmButton?: string;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const TotpSetupForm: FC<TotpSetupFormProps>;
|
|
23
|
+
export default TotpSetupForm;
|
|
24
|
+
//# sourceMappingURL=TotpSetupForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotpSetupForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TotpSetupForm.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAGrC,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CACT,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAiBD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAgJhD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TotpSetupForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const qrcode_react_1 = require("qrcode.react");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
|
+
const defaultLabels = {
|
|
12
|
+
title: 'Set Up Two-Factor Authentication',
|
|
13
|
+
qrCodeAlt: 'QR code for TOTP authenticator app setup',
|
|
14
|
+
secretLabel: 'Manual entry key',
|
|
15
|
+
codeLabel: 'Confirmation code',
|
|
16
|
+
confirmButton: 'Confirm',
|
|
17
|
+
errorMessage: 'An unexpected error occurred',
|
|
18
|
+
};
|
|
19
|
+
const totpCodeSchema = Yup.object({
|
|
20
|
+
code: Yup.string()
|
|
21
|
+
.required('Confirmation code is required')
|
|
22
|
+
.matches(/^\d{6}$/, 'Code must be exactly 6 digits'),
|
|
23
|
+
});
|
|
24
|
+
const TotpSetupForm = ({ provisioningUri, secret, onConfirm, labels = {}, }) => {
|
|
25
|
+
const [confirmError, setConfirmError] = (0, react_1.useState)(null);
|
|
26
|
+
const resolvedLabels = {
|
|
27
|
+
title: labels.title ?? defaultLabels.title,
|
|
28
|
+
qrCodeAlt: labels.qrCodeAlt ?? defaultLabels.qrCodeAlt,
|
|
29
|
+
secretLabel: labels.secretLabel ?? defaultLabels.secretLabel,
|
|
30
|
+
codeLabel: labels.codeLabel ?? defaultLabels.codeLabel,
|
|
31
|
+
confirmButton: labels.confirmButton ?? defaultLabels.confirmButton,
|
|
32
|
+
errorMessage: labels.errorMessage ?? defaultLabels.errorMessage,
|
|
33
|
+
};
|
|
34
|
+
const formik = (0, formik_1.useFormik)({
|
|
35
|
+
initialValues: {
|
|
36
|
+
code: '',
|
|
37
|
+
},
|
|
38
|
+
validationSchema: totpCodeSchema,
|
|
39
|
+
onSubmit: async (values, { setSubmitting }) => {
|
|
40
|
+
try {
|
|
41
|
+
setConfirmError(null);
|
|
42
|
+
const result = await onConfirm(values.code);
|
|
43
|
+
if ('error' in result) {
|
|
44
|
+
setConfirmError(result.error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
setConfirmError(resolvedLabels.errorMessage);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
setSubmitting(false);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const errorId = 'totp-setup-error';
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
57
|
+
marginTop: 8,
|
|
58
|
+
display: 'flex',
|
|
59
|
+
flexDirection: 'column',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: resolvedLabels.title }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 3, display: 'flex', justifyContent: 'center' }, children: (0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: provisioningUri, size: 200, role: "img", "aria-label": resolvedLabels.qrCodeAlt, "data-testid": "qr-code-svg" }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
62
|
+
mt: 2,
|
|
63
|
+
p: 2,
|
|
64
|
+
bgcolor: 'grey.100',
|
|
65
|
+
borderRadius: 1,
|
|
66
|
+
width: '100%',
|
|
67
|
+
textAlign: 'center',
|
|
68
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: resolvedLabels.secretLabel }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: {
|
|
69
|
+
fontFamily: 'monospace',
|
|
70
|
+
wordBreak: 'break-all',
|
|
71
|
+
userSelect: 'all',
|
|
72
|
+
}, children: secret })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 2, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "code", name: "code", label: resolvedLabels.codeLabel, inputProps: {
|
|
73
|
+
'aria-label': resolvedLabels.codeLabel,
|
|
74
|
+
inputMode: 'numeric',
|
|
75
|
+
maxLength: 6,
|
|
76
|
+
pattern: '\\d{6}',
|
|
77
|
+
...(confirmError ? { 'aria-describedby': errorId } : {}),
|
|
78
|
+
}, autoComplete: "one-time-code", autoFocus: true, value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.code && Boolean(formik.errors.code)) ||
|
|
79
|
+
Boolean(confirmError), helperText: formik.touched.code && formik.errors.code }), confirmError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { id: errorId, color: "error", variant: "body2", sx: { mt: 1 }, role: "alert", children: confirmError })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: resolvedLabels.confirmButton })] })] }) }));
|
|
80
|
+
};
|
|
81
|
+
exports.TotpSetupForm = TotpSetupForm;
|
|
82
|
+
exports.default = exports.TotpSetupForm;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IRequestUserDTO } from '@digitaldefiance/suite-core-lib';
|
|
3
|
+
export interface TotpVerificationFormValues {
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TotpVerificationFormProps {
|
|
7
|
+
pendingTotpToken: string;
|
|
8
|
+
onSubmit: (code: string, pendingTotpToken: string) => Promise<{
|
|
9
|
+
token: string;
|
|
10
|
+
user: IRequestUserDTO;
|
|
11
|
+
} | {
|
|
12
|
+
error: string;
|
|
13
|
+
}>;
|
|
14
|
+
labels?: {
|
|
15
|
+
title?: string;
|
|
16
|
+
codeLabel?: string;
|
|
17
|
+
submitButton?: string;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare const TotpVerificationForm: FC<TotpVerificationFormProps>;
|
|
22
|
+
export default TotpVerificationForm;
|
|
23
|
+
//# sourceMappingURL=TotpVerificationForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotpVerificationForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TotpVerificationForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,KACrB,OAAO,CACV;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAC7D,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAeD,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA0G9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TotpVerificationForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
+
const defaultLabels = {
|
|
11
|
+
title: 'Two-Factor Authentication',
|
|
12
|
+
codeLabel: 'Authentication code',
|
|
13
|
+
submitButton: 'Verify',
|
|
14
|
+
errorMessage: 'An unexpected error occurred',
|
|
15
|
+
};
|
|
16
|
+
const totpCodeSchema = Yup.object({
|
|
17
|
+
code: Yup.string()
|
|
18
|
+
.required('Authentication code is required')
|
|
19
|
+
.matches(/^\d{6}$/, 'Code must be exactly 6 digits'),
|
|
20
|
+
});
|
|
21
|
+
const TotpVerificationForm = ({ pendingTotpToken, onSubmit, labels = {}, }) => {
|
|
22
|
+
const [submitError, setSubmitError] = (0, react_1.useState)(null);
|
|
23
|
+
const resolvedLabels = {
|
|
24
|
+
title: labels.title ?? defaultLabels.title,
|
|
25
|
+
codeLabel: labels.codeLabel ?? defaultLabels.codeLabel,
|
|
26
|
+
submitButton: labels.submitButton ?? defaultLabels.submitButton,
|
|
27
|
+
errorMessage: labels.errorMessage ?? defaultLabels.errorMessage,
|
|
28
|
+
};
|
|
29
|
+
const formik = (0, formik_1.useFormik)({
|
|
30
|
+
initialValues: {
|
|
31
|
+
code: '',
|
|
32
|
+
},
|
|
33
|
+
validationSchema: totpCodeSchema,
|
|
34
|
+
onSubmit: async (values, { setSubmitting }) => {
|
|
35
|
+
try {
|
|
36
|
+
setSubmitError(null);
|
|
37
|
+
const result = await onSubmit(values.code, pendingTotpToken);
|
|
38
|
+
if ('error' in result) {
|
|
39
|
+
setSubmitError(result.error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
setSubmitError(resolvedLabels.errorMessage);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setSubmitting(false);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const errorId = 'totp-verification-error';
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
52
|
+
marginTop: 8,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: resolvedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 2, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "code", name: "code", label: resolvedLabels.codeLabel, inputProps: {
|
|
57
|
+
'aria-label': resolvedLabels.codeLabel,
|
|
58
|
+
inputMode: 'numeric',
|
|
59
|
+
maxLength: 6,
|
|
60
|
+
pattern: '\\d{6}',
|
|
61
|
+
...(submitError ? { 'aria-describedby': errorId } : {}),
|
|
62
|
+
}, autoComplete: "one-time-code", autoFocus: true, value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.code && Boolean(formik.errors.code)) ||
|
|
63
|
+
Boolean(submitError), helperText: formik.touched.code && formik.errors.code }), submitError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { id: errorId, color: "error", variant: "body2", sx: { mt: 1 }, role: "alert", children: submitError })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: resolvedLabels.submitButton })] })] }) }));
|
|
64
|
+
};
|
|
65
|
+
exports.TotpVerificationForm = TotpVerificationForm;
|
|
66
|
+
exports.default = exports.TotpVerificationForm;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface FCParams<TEnum extends string> {
|
|
2
|
+
componentId: string;
|
|
3
|
+
stringKey: TEnum;
|
|
4
|
+
vars?: Record<string, string | number>;
|
|
5
|
+
}
|
|
6
|
+
export declare const TranslatedTitle: <TEnum extends string>({ componentId, stringKey, vars, }: FCParams<TEnum>) => null;
|
|
7
|
+
export default TranslatedTitle;
|
|
8
|
+
//# sourceMappingURL=TranslatedTitle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslatedTitle.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TranslatedTitle.tsx"],"names":[],"mappings":"AAKA,UAAU,QAAQ,CAAC,KAAK,SAAS,MAAM;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,SAAS,MAAM,EAAE,mCAInD,QAAQ,CAAC,KAAK,CAAC,KAAG,IAapB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/app/components/TranslatedTitle.tsx
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TranslatedTitle = void 0;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const contexts_1 = require("../contexts");
|
|
7
|
+
const TranslatedTitle = ({ componentId, stringKey, vars, }) => {
|
|
8
|
+
const { tComponent, currentLanguage } = (0, contexts_1.useI18n)();
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
document.title = tComponent(componentId, stringKey, vars, currentLanguage);
|
|
11
|
+
}, [tComponent, componentId, stringKey, vars, currentLanguage]);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
exports.TranslatedTitle = TranslatedTitle;
|
|
15
|
+
exports.default = exports.TranslatedTitle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserLanguageSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserLanguageSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAiC,MAAM,OAAO,CAAC;AAM1D,eAAO,MAAM,oBAAoB,EAAE,EAkClC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserLanguageSelector = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const Flag_1 = require("./Flag");
|
|
9
|
+
const hooks_1 = require("../hooks");
|
|
10
|
+
const services_1 = require("../services");
|
|
11
|
+
const contexts_1 = require("../contexts");
|
|
12
|
+
const UserLanguageSelector = () => {
|
|
13
|
+
const { baseUrl } = (0, contexts_1.useSuiteConfig)();
|
|
14
|
+
const authenticatedApi = (0, react_1.useMemo)(() => (0, services_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
15
|
+
const { isAuthenticated } = (0, contexts_1.useAuth)();
|
|
16
|
+
const { currentLanguage, changeLanguage } = (0, hooks_1.useUserSettings)({ authenticatedApi, isAuthenticated });
|
|
17
|
+
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
18
|
+
const handleClick = (event) => {
|
|
19
|
+
setAnchorEl(event.currentTarget);
|
|
20
|
+
};
|
|
21
|
+
const handleClose = () => {
|
|
22
|
+
setAnchorEl(null);
|
|
23
|
+
};
|
|
24
|
+
const handleLanguageChange = (newLanguage) => {
|
|
25
|
+
changeLanguage(newLanguage);
|
|
26
|
+
handleClose();
|
|
27
|
+
};
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleClick, children: (0, jsx_runtime_1.jsx)(Flag_1.Flag, { language: currentLanguage }) }), (0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, children: Object.values(i18n_lib_1.LanguageRegistry.getAllLanguages()).map((lang) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => handleLanguageChange(lang.code), children: [(0, jsx_runtime_1.jsx)(Flag_1.Flag, { language: lang.code, sx: { mr: 1 } }), " ", lang.name] }, lang.code))) })] }));
|
|
29
|
+
};
|
|
30
|
+
exports.UserLanguageSelector = UserLanguageSelector;
|
|
31
|
+
exports.default = exports.UserLanguageSelector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAK3B,eAAO,MAAM,QAAQ,EAAE,EAOtB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserMenu = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const MenuType_1 = require("../types/MenuType");
|
|
7
|
+
const DropdownMenu_1 = require("./DropdownMenu");
|
|
8
|
+
const UserMenu = () => {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: MenuType_1.MenuTypes.UserMenu, menuIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AccountCircle, {}) }));
|
|
10
|
+
};
|
|
11
|
+
exports.UserMenu = UserMenu;
|
|
12
|
+
exports.default = exports.UserMenu;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useFormik } from 'formik';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import * as Yup from 'yup';
|
|
4
|
+
export interface UserSettingsFormValues {
|
|
5
|
+
email: string;
|
|
6
|
+
timezone: string;
|
|
7
|
+
siteLanguage: string;
|
|
8
|
+
currency: string;
|
|
9
|
+
darkMode: boolean;
|
|
10
|
+
directChallenge: boolean;
|
|
11
|
+
displayName?: string;
|
|
12
|
+
[key: string]: string | boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface UserSettingsFormProps {
|
|
15
|
+
initialValues: UserSettingsFormValues;
|
|
16
|
+
onSubmit: (values: UserSettingsFormValues) => Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
message: string;
|
|
19
|
+
} | {
|
|
20
|
+
error: string;
|
|
21
|
+
errorType?: string;
|
|
22
|
+
field?: string;
|
|
23
|
+
errors?: Array<{
|
|
24
|
+
path: string;
|
|
25
|
+
msg: string;
|
|
26
|
+
}>;
|
|
27
|
+
}>;
|
|
28
|
+
languages: Array<{
|
|
29
|
+
code: string;
|
|
30
|
+
label: string;
|
|
31
|
+
}>;
|
|
32
|
+
emailValidation?: Yup.StringSchema;
|
|
33
|
+
timezoneValidation?: Yup.StringSchema;
|
|
34
|
+
siteLanguageValidation?: Yup.StringSchema;
|
|
35
|
+
currencyValidation?: Yup.StringSchema;
|
|
36
|
+
darkModeValidation?: Yup.BooleanSchema;
|
|
37
|
+
directChallengeValidation?: Yup.BooleanSchema;
|
|
38
|
+
displayNameValidation?: Yup.StringSchema;
|
|
39
|
+
additionalFields?: (formik: ReturnType<typeof useFormik<UserSettingsFormValues>>) => React.ReactNode;
|
|
40
|
+
additionalInitialValues?: Record<string, string | boolean>;
|
|
41
|
+
additionalValidation?: Record<string, Yup.Schema>;
|
|
42
|
+
/**
|
|
43
|
+
* Current TOTP 2FA status. When undefined (not passed), no TOTP controls are rendered.
|
|
44
|
+
* When false, an "Enable 2FA" button is shown. When true, "Disable 2FA" and "Reset 2FA" buttons are shown.
|
|
45
|
+
*/
|
|
46
|
+
totpEnabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Called to initiate TOTP setup (e.g. AuthService.setupTotp()).
|
|
49
|
+
* Must return provisioning URI and secret on success, or an error.
|
|
50
|
+
*/
|
|
51
|
+
onTotpSetup?: () => Promise<{
|
|
52
|
+
provisioningUri: string;
|
|
53
|
+
secret: string;
|
|
54
|
+
} | {
|
|
55
|
+
error: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Called to confirm TOTP setup with a 6-digit code (e.g. AuthService.confirmTotp()).
|
|
59
|
+
*/
|
|
60
|
+
onTotpConfirm?: (code: string) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
} | {
|
|
63
|
+
error: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Called to disable TOTP with a 6-digit code (e.g. AuthService.disableTotp()).
|
|
67
|
+
*/
|
|
68
|
+
onTotpDisable?: (code: string) => Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
error: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Called to reset TOTP with a 6-digit code (e.g. AuthService.resetTotp()).
|
|
75
|
+
* Returns new provisioning URI and secret on success.
|
|
76
|
+
*/
|
|
77
|
+
onTotpReset?: (code: string) => Promise<{
|
|
78
|
+
provisioningUri: string;
|
|
79
|
+
secret: string;
|
|
80
|
+
} | {
|
|
81
|
+
error: string;
|
|
82
|
+
}>;
|
|
83
|
+
labels?: {
|
|
84
|
+
title?: string;
|
|
85
|
+
email?: string;
|
|
86
|
+
emailHelper?: string;
|
|
87
|
+
timezone?: string;
|
|
88
|
+
siteLanguage?: string;
|
|
89
|
+
currency?: string;
|
|
90
|
+
darkMode?: string;
|
|
91
|
+
directChallenge?: string;
|
|
92
|
+
directChallengeHelper?: string;
|
|
93
|
+
displayName?: string;
|
|
94
|
+
saving?: string;
|
|
95
|
+
save?: string;
|
|
96
|
+
successMessage?: string;
|
|
97
|
+
totpSectionTitle?: string;
|
|
98
|
+
totpStatusEnabled?: string;
|
|
99
|
+
totpStatusDisabled?: string;
|
|
100
|
+
totpEnableButton?: string;
|
|
101
|
+
totpDisableButton?: string;
|
|
102
|
+
totpResetButton?: string;
|
|
103
|
+
totpDisableCodeLabel?: string;
|
|
104
|
+
totpDisableSubmitButton?: string;
|
|
105
|
+
totpResetCodeLabel?: string;
|
|
106
|
+
totpResetSubmitButton?: string;
|
|
107
|
+
totpCancelButton?: string;
|
|
108
|
+
totpError?: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export declare const UserSettingsForm: FC<UserSettingsFormProps>;
|
|
112
|
+
export default UserSettingsForm;
|
|
113
|
+
//# sourceMappingURL=UserSettingsForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"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"}
|