@digitaldefiance/express-suite-react-components 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +186 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +515 -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 +292 -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/{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
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for a TopMenu category (mega-menu container).
|
|
5
|
-
*
|
|
6
|
-
* Categories let you group multiple icon dropdowns under a single AppBar
|
|
7
|
-
* button. Menus opt into a category by setting `IMenuConfig.category` (or
|
|
8
|
-
* `AdditionalDropdownMenu.category`) to this category's `id`. The TopMenu
|
|
9
|
-
* renders one icon button per category that has at least one matching menu;
|
|
10
|
-
* clicking it opens a popover containing the matching menus as icon tiles.
|
|
11
|
-
*
|
|
12
|
-
* Backwards compatibility: if `TopMenu` is not given a `categories` array,
|
|
13
|
-
* or if a menu does not declare a `category`, it renders inline in the AppBar
|
|
14
|
-
* exactly as before.
|
|
15
|
-
*/
|
|
16
|
-
export interface ICategoryConfig {
|
|
17
|
-
/** Unique identifier referenced by `IMenuConfig.category`. */
|
|
18
|
-
id: string;
|
|
19
|
-
/** Icon shown on the AppBar trigger button. */
|
|
20
|
-
icon: ReactElement;
|
|
21
|
-
/**
|
|
22
|
-
* Optional accessible label / tooltip / panel header. Plain string for
|
|
23
|
-
* tooltip; render-prop or node for the panel header if `showHeader` is true.
|
|
24
|
-
*/
|
|
25
|
-
label?: string;
|
|
26
|
-
/** Optional header content shown above the tile grid when `showHeader` is true. */
|
|
27
|
-
header?: ReactNode;
|
|
28
|
-
/** Show the `header` (or `label`) above the tile grid. Defaults to false. */
|
|
29
|
-
showHeader?: boolean;
|
|
30
|
-
/** Show the menu label under each tile inside the popover. Defaults to true. */
|
|
31
|
-
showLabels?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Sort order for placement in the AppBar. Higher numbers render first
|
|
34
|
-
* (same convention as `IMenuConfig.priority`). Defaults to 0.
|
|
35
|
-
*/
|
|
36
|
-
priority?: number;
|
|
37
|
-
/** Number of tile columns in the popover grid. Defaults to 3. */
|
|
38
|
-
columns?: number;
|
|
39
|
-
/** Hide the category trigger when it has no matching menus. Defaults to true. */
|
|
40
|
-
hideWhenEmpty?: boolean;
|
|
41
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { IMenuOption } from './IMenuOption';
|
|
3
|
-
import { createMenuType } from '../types';
|
|
4
|
-
|
|
5
|
-
export interface IMenuConfig {
|
|
6
|
-
menuType: ReturnType<typeof createMenuType>;
|
|
7
|
-
menuIcon: ReactElement;
|
|
8
|
-
priority?: number;
|
|
9
|
-
options: IMenuOption[];
|
|
10
|
-
isUserMenu?: boolean;
|
|
11
|
-
/** Optional callback invoked when the icon button is clicked. */
|
|
12
|
-
action?: () => void;
|
|
13
|
-
/** When true, the menu icon is hidden if there are no sub-options. Defaults to false. */
|
|
14
|
-
hideWhenEmpty?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Optional category identifier. When the TopMenu is configured with matching
|
|
17
|
-
* `categories`, this menu is rendered as a tile inside that category's
|
|
18
|
-
* mega-menu popover instead of inline in the AppBar. When omitted (or no
|
|
19
|
-
* matching category exists), the menu renders inline as a normal dropdown.
|
|
20
|
-
*/
|
|
21
|
-
category?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional human-readable label. When the menu is rendered as a tile inside
|
|
24
|
-
* a category popover with `showLabels` enabled, this is shown under the icon.
|
|
25
|
-
* Also used as the IconButton tooltip. Falls back to `menuType` when omitted.
|
|
26
|
-
*/
|
|
27
|
-
label?: string;
|
|
28
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { To } from 'react-router';
|
|
3
|
-
import { MenuType } from '../types/MenuType';
|
|
4
|
-
import { SxProps } from '@mui/system';
|
|
5
|
-
import { Theme } from '@mui/material';
|
|
6
|
-
|
|
7
|
-
export interface IMenuOption {
|
|
8
|
-
/**
|
|
9
|
-
* Unique identifier for the menu option
|
|
10
|
-
*/
|
|
11
|
-
id: string;
|
|
12
|
-
/**
|
|
13
|
-
* Text to display for the menu option
|
|
14
|
-
*/
|
|
15
|
-
label: string | ReactNode | Array<ReactNode>;
|
|
16
|
-
/**
|
|
17
|
-
* Where the menu option should be displayed
|
|
18
|
-
*/
|
|
19
|
-
includeOnMenus: MenuType[];
|
|
20
|
-
/**
|
|
21
|
-
* Display order for the menu option. Lower numbers are displayed first.
|
|
22
|
-
*/
|
|
23
|
-
index: number;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the menu option is a divider
|
|
26
|
-
*/
|
|
27
|
-
divider?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Icon to display for the menu option
|
|
30
|
-
*/
|
|
31
|
-
icon?: ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* Link to navigate to when the menu option is clicked
|
|
34
|
-
* Mutually exclusive with `action`
|
|
35
|
-
* Can be a string, a react-router To object, or an object with pathname and optional state
|
|
36
|
-
*/
|
|
37
|
-
link?: To | { pathname: string; state?: unknown };
|
|
38
|
-
/**
|
|
39
|
-
* Function to execute when the menu option is clicked
|
|
40
|
-
* Mutually exclusive with `link`
|
|
41
|
-
* @returns void
|
|
42
|
-
*/
|
|
43
|
-
action?: () => void;
|
|
44
|
-
/**
|
|
45
|
-
* Whether the menu option requires authentication
|
|
46
|
-
* true = requires authentication
|
|
47
|
-
* false = requires unauthenticated
|
|
48
|
-
* undefined = always show
|
|
49
|
-
*/
|
|
50
|
-
requiresAuth: boolean | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the menu option requires the user to be a global admin
|
|
53
|
-
* true = only show to global admins
|
|
54
|
-
* undefined/false = no admin requirement
|
|
55
|
-
*/
|
|
56
|
-
requiresAdmin?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Custom filter function to determine if the menu option should be displayed
|
|
59
|
-
* @param option - The menu option to filter
|
|
60
|
-
* @returns boolean
|
|
61
|
-
*/
|
|
62
|
-
filter?: (option: IMenuOption) => boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Additional CSS properties
|
|
65
|
-
*/
|
|
66
|
-
additionalSx?: SxProps<Theme>;
|
|
67
|
-
/**
|
|
68
|
-
* Additional CSS properties for the side menu variant
|
|
69
|
-
*/
|
|
70
|
-
sideSx?: SxProps<Theme>;
|
|
71
|
-
/**
|
|
72
|
-
* Additional CSS properties for the side menu variant Icon sub item
|
|
73
|
-
*/
|
|
74
|
-
sideIconSx?: SxProps<Theme>;
|
|
75
|
-
/**
|
|
76
|
-
* Additional CSS properties for the side menu variant Text sub item
|
|
77
|
-
*/
|
|
78
|
-
sideTextSx?: SxProps<Theme>;
|
|
79
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
export const mockAuthService = {
|
|
4
|
-
verifyToken: jest.fn(),
|
|
5
|
-
directLogin: jest.fn(),
|
|
6
|
-
emailChallengeLogin: jest.fn(),
|
|
7
|
-
refreshToken: jest.fn(),
|
|
8
|
-
register: jest.fn(),
|
|
9
|
-
requestEmailLogin: jest.fn(),
|
|
10
|
-
backupCodeLogin: jest.fn(),
|
|
11
|
-
changePassword: jest.fn(),
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const createAuthService = jest.fn(() => mockAuthService);
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Property-Based Tests for AuthService TOTP Error Extraction
|
|
3
|
-
*
|
|
4
|
-
* Feature: totp-2fa, Property 11: AuthService Error Extraction
|
|
5
|
-
*
|
|
6
|
-
* For any TOTP-related AuthService method, when the backend returns a
|
|
7
|
-
* non-2xx HTTP response, the method SHALL return an object with an `error`
|
|
8
|
-
* string extracted via `extractErrorMessage` and SHALL NOT throw an
|
|
9
|
-
* unhandled exception.
|
|
10
|
-
*
|
|
11
|
-
* **Validates: Requirements 11.5**
|
|
12
|
-
*
|
|
13
|
-
* Uses fast-check with ≥100 iterations.
|
|
14
|
-
*
|
|
15
|
-
* @module services/__tests__/authService.totp.property.spec
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { describe, it, expect, beforeEach, jest } from '@jest/globals';
|
|
19
|
-
import * as fc from 'fast-check';
|
|
20
|
-
import axios, { AxiosError, AxiosHeaders } from 'axios';
|
|
21
|
-
|
|
22
|
-
// ─── Mocks ──────────────────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
// Mock the API client factories so we can control what the axios instances return
|
|
25
|
-
const mockPost = jest.fn() as jest.MockedFunction<typeof axios.prototype.post>;
|
|
26
|
-
const mockGet = jest.fn() as jest.MockedFunction<typeof axios.prototype.get>;
|
|
27
|
-
|
|
28
|
-
const mockAxiosInstance = {
|
|
29
|
-
post: mockPost,
|
|
30
|
-
get: mockGet,
|
|
31
|
-
interceptors: {
|
|
32
|
-
request: { use: jest.fn() },
|
|
33
|
-
response: { use: jest.fn() },
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
jest.mock('../api', () => ({
|
|
38
|
-
createApiClient: jest.fn(() => mockAxiosInstance),
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
jest.mock('../authenticatedApi', () => ({
|
|
42
|
-
createAuthenticatedApiClient: jest.fn(() => mockAxiosInstance),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
jest.mock('@digitaldefiance/ecies-lib', () => ({
|
|
46
|
-
EciesCryptoCore: jest.fn().mockImplementation(() => ({})),
|
|
47
|
-
ECIESService: jest.fn().mockImplementation(() => ({})),
|
|
48
|
-
hexToUint8Array: jest.fn(),
|
|
49
|
-
uint8ArrayToHex: jest.fn(),
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
jest.mock('@digitaldefiance/suite-core-lib', () => ({
|
|
53
|
-
getSuiteCoreTranslation: jest.fn(
|
|
54
|
-
(key: string) => key,
|
|
55
|
-
),
|
|
56
|
-
SuiteCoreStringKey: {
|
|
57
|
-
Common_UnexpectedError: 'common_unexpectedError',
|
|
58
|
-
Registration_Error: 'registration_error',
|
|
59
|
-
Registration_Success: 'registration_success',
|
|
60
|
-
Validation_UsernameOrEmailRequired: 'validation_usernameOrEmailRequired',
|
|
61
|
-
Validation_InvalidToken: 'validation_invalidToken',
|
|
62
|
-
Error_Login_DirectChallengeNotEnabled:
|
|
63
|
-
'error_login_directChallengeNotEnabled',
|
|
64
|
-
Error_Login_PasswordLoginNotEnabled: 'error_login_passwordLoginNotEnabled',
|
|
65
|
-
},
|
|
66
|
-
Constants: {},
|
|
67
|
-
}));
|
|
68
|
-
|
|
69
|
-
// Import AuthService after mocks are set up
|
|
70
|
-
import { AuthService } from '../authService';
|
|
71
|
-
|
|
72
|
-
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Build a realistic AxiosError with the given status code and response data.
|
|
76
|
-
*/
|
|
77
|
-
function buildAxiosError(
|
|
78
|
-
status: number,
|
|
79
|
-
data: Record<string, unknown>,
|
|
80
|
-
): AxiosError {
|
|
81
|
-
const headers = new AxiosHeaders();
|
|
82
|
-
const config = { headers } as import('axios').InternalAxiosRequestConfig;
|
|
83
|
-
const response = {
|
|
84
|
-
data,
|
|
85
|
-
status,
|
|
86
|
-
statusText: 'Error',
|
|
87
|
-
headers: {},
|
|
88
|
-
config,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const error = new AxiosError(
|
|
92
|
-
`Request failed with status code ${status}`,
|
|
93
|
-
AxiosError.ERR_BAD_RESPONSE,
|
|
94
|
-
config,
|
|
95
|
-
undefined,
|
|
96
|
-
response,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
return error;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// ─── Arbitraries ────────────────────────────────────────────────────────────
|
|
103
|
-
|
|
104
|
-
/** Non-2xx HTTP status codes (client and server errors) */
|
|
105
|
-
const nonSuccessStatus = fc.oneof(
|
|
106
|
-
fc.integer({ min: 400, max: 499 }),
|
|
107
|
-
fc.integer({ min: 500, max: 599 }),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
/** Arbitrary non-empty error message strings */
|
|
111
|
-
const errorMessage = fc.string({ minLength: 1, maxLength: 200 }).filter(
|
|
112
|
-
(s) => s.trim().length > 0,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
/** 6-digit TOTP code string */
|
|
116
|
-
const totpCode = fc
|
|
117
|
-
.array(fc.constantFrom(...'0123456789'.split('')), {
|
|
118
|
-
minLength: 6,
|
|
119
|
-
maxLength: 6,
|
|
120
|
-
})
|
|
121
|
-
.map((chars) => chars.join(''));
|
|
122
|
-
|
|
123
|
-
/** Arbitrary non-empty token string */
|
|
124
|
-
const tokenString = fc.string({ minLength: 10, maxLength: 100 }).filter(
|
|
125
|
-
(s) => s.trim().length > 0,
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
// ─── Tests ──────────────────────────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
describe('AuthService TOTP - Property Tests', () => {
|
|
131
|
-
let authService: AuthService;
|
|
132
|
-
|
|
133
|
-
beforeEach(() => {
|
|
134
|
-
mockPost.mockReset();
|
|
135
|
-
mockGet.mockReset();
|
|
136
|
-
|
|
137
|
-
const mockConstants = {} as import('@digitaldefiance/suite-core-lib').IConstants;
|
|
138
|
-
const mockEciesConfig = {} as import('@digitaldefiance/ecies-lib').IECIESConfig;
|
|
139
|
-
|
|
140
|
-
authService = new AuthService(
|
|
141
|
-
mockConstants,
|
|
142
|
-
'http://localhost:3000',
|
|
143
|
-
mockEciesConfig,
|
|
144
|
-
'test.example.com',
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// ─── Property 11: AuthService Error Extraction ──────────────────────────
|
|
149
|
-
|
|
150
|
-
describe('Feature: totp-2fa, Property 11: AuthService Error Extraction', () => {
|
|
151
|
-
/**
|
|
152
|
-
* **Validates: Requirements 11.5**
|
|
153
|
-
*
|
|
154
|
-
* For any TOTP-related AuthService method, when the backend returns a
|
|
155
|
-
* non-2xx HTTP response, the method must return `{ error: string }` and
|
|
156
|
-
* must not throw.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
describe('setupTotp returns { error } on non-2xx and never throws', () => {
|
|
160
|
-
it('extracts error from response.data.message', async () => {
|
|
161
|
-
await fc.assert(
|
|
162
|
-
fc.asyncProperty(
|
|
163
|
-
nonSuccessStatus,
|
|
164
|
-
errorMessage,
|
|
165
|
-
async (status, msg) => {
|
|
166
|
-
mockPost.mockRejectedValueOnce(
|
|
167
|
-
buildAxiosError(status, { message: msg }),
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
const result = await authService.setupTotp();
|
|
171
|
-
|
|
172
|
-
expect(result).toHaveProperty('error');
|
|
173
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
174
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
175
|
-
},
|
|
176
|
-
),
|
|
177
|
-
{ numRuns: 100 },
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('extracts error from response.data.error (string)', async () => {
|
|
182
|
-
await fc.assert(
|
|
183
|
-
fc.asyncProperty(
|
|
184
|
-
nonSuccessStatus,
|
|
185
|
-
errorMessage,
|
|
186
|
-
async (status, msg) => {
|
|
187
|
-
mockPost.mockRejectedValueOnce(
|
|
188
|
-
buildAxiosError(status, { error: msg }),
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const result = await authService.setupTotp();
|
|
192
|
-
|
|
193
|
-
expect(result).toHaveProperty('error');
|
|
194
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
195
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
196
|
-
},
|
|
197
|
-
),
|
|
198
|
-
{ numRuns: 100 },
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
describe('confirmTotp returns { error } on non-2xx and never throws', () => {
|
|
204
|
-
it('extracts error for any status code and error message', async () => {
|
|
205
|
-
await fc.assert(
|
|
206
|
-
fc.asyncProperty(
|
|
207
|
-
nonSuccessStatus,
|
|
208
|
-
errorMessage,
|
|
209
|
-
totpCode,
|
|
210
|
-
async (status, msg, code) => {
|
|
211
|
-
mockPost.mockRejectedValueOnce(
|
|
212
|
-
buildAxiosError(status, { message: msg }),
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const result = await authService.confirmTotp(code);
|
|
216
|
-
|
|
217
|
-
expect(result).toHaveProperty('error');
|
|
218
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
219
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
220
|
-
},
|
|
221
|
-
),
|
|
222
|
-
{ numRuns: 100 },
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('disableTotp returns { error } on non-2xx and never throws', () => {
|
|
228
|
-
it('extracts error for any status code and error message', async () => {
|
|
229
|
-
await fc.assert(
|
|
230
|
-
fc.asyncProperty(
|
|
231
|
-
nonSuccessStatus,
|
|
232
|
-
errorMessage,
|
|
233
|
-
totpCode,
|
|
234
|
-
async (status, msg, code) => {
|
|
235
|
-
mockPost.mockRejectedValueOnce(
|
|
236
|
-
buildAxiosError(status, { message: msg }),
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
const result = await authService.disableTotp(code);
|
|
240
|
-
|
|
241
|
-
expect(result).toHaveProperty('error');
|
|
242
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
243
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
244
|
-
},
|
|
245
|
-
),
|
|
246
|
-
{ numRuns: 100 },
|
|
247
|
-
);
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
describe('resetTotp returns { error } on non-2xx and never throws', () => {
|
|
252
|
-
it('extracts error for any status code and error message', async () => {
|
|
253
|
-
await fc.assert(
|
|
254
|
-
fc.asyncProperty(
|
|
255
|
-
nonSuccessStatus,
|
|
256
|
-
errorMessage,
|
|
257
|
-
totpCode,
|
|
258
|
-
async (status, msg, code) => {
|
|
259
|
-
mockPost.mockRejectedValueOnce(
|
|
260
|
-
buildAxiosError(status, { message: msg }),
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
const result = await authService.resetTotp(code);
|
|
264
|
-
|
|
265
|
-
expect(result).toHaveProperty('error');
|
|
266
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
267
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
268
|
-
},
|
|
269
|
-
),
|
|
270
|
-
{ numRuns: 100 },
|
|
271
|
-
);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe('verifyTotpLogin returns { error } on non-2xx and never throws', () => {
|
|
276
|
-
it('extracts error for any status code, error message, and token', async () => {
|
|
277
|
-
await fc.assert(
|
|
278
|
-
fc.asyncProperty(
|
|
279
|
-
nonSuccessStatus,
|
|
280
|
-
errorMessage,
|
|
281
|
-
totpCode,
|
|
282
|
-
tokenString,
|
|
283
|
-
async (status, msg, code, token) => {
|
|
284
|
-
mockPost.mockRejectedValueOnce(
|
|
285
|
-
buildAxiosError(status, { message: msg }),
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
const result = await authService.verifyTotpLogin(token, code);
|
|
289
|
-
|
|
290
|
-
expect(result).toHaveProperty('error');
|
|
291
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
292
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
293
|
-
},
|
|
294
|
-
),
|
|
295
|
-
{ numRuns: 100 },
|
|
296
|
-
);
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
describe('error extraction handles object-shaped errors', () => {
|
|
301
|
-
it('extracts error.message from response.data.error object for all methods', async () => {
|
|
302
|
-
await fc.assert(
|
|
303
|
-
fc.asyncProperty(
|
|
304
|
-
nonSuccessStatus,
|
|
305
|
-
errorMessage,
|
|
306
|
-
totpCode,
|
|
307
|
-
tokenString,
|
|
308
|
-
async (status, msg, code, token) => {
|
|
309
|
-
const errorData = {
|
|
310
|
-
error: { message: msg, statusCode: status },
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
// Test all five methods with object-shaped error
|
|
314
|
-
const methods = [
|
|
315
|
-
() => {
|
|
316
|
-
mockPost.mockRejectedValueOnce(
|
|
317
|
-
buildAxiosError(status, errorData),
|
|
318
|
-
);
|
|
319
|
-
return authService.setupTotp();
|
|
320
|
-
},
|
|
321
|
-
() => {
|
|
322
|
-
mockPost.mockRejectedValueOnce(
|
|
323
|
-
buildAxiosError(status, errorData),
|
|
324
|
-
);
|
|
325
|
-
return authService.confirmTotp(code);
|
|
326
|
-
},
|
|
327
|
-
() => {
|
|
328
|
-
mockPost.mockRejectedValueOnce(
|
|
329
|
-
buildAxiosError(status, errorData),
|
|
330
|
-
);
|
|
331
|
-
return authService.disableTotp(code);
|
|
332
|
-
},
|
|
333
|
-
() => {
|
|
334
|
-
mockPost.mockRejectedValueOnce(
|
|
335
|
-
buildAxiosError(status, errorData),
|
|
336
|
-
);
|
|
337
|
-
return authService.resetTotp(code);
|
|
338
|
-
},
|
|
339
|
-
() => {
|
|
340
|
-
mockPost.mockRejectedValueOnce(
|
|
341
|
-
buildAxiosError(status, errorData),
|
|
342
|
-
);
|
|
343
|
-
return authService.verifyTotpLogin(token, code);
|
|
344
|
-
},
|
|
345
|
-
];
|
|
346
|
-
|
|
347
|
-
for (const method of methods) {
|
|
348
|
-
const result = await method();
|
|
349
|
-
expect(result).toHaveProperty('error');
|
|
350
|
-
expect(typeof (result as { error: string }).error).toBe('string');
|
|
351
|
-
expect((result as { error: string }).error.length).toBeGreaterThan(0);
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
),
|
|
355
|
-
{ numRuns: 100 },
|
|
356
|
-
);
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|