@digitaldefiance/express-suite-react-components 2.3.5 → 2.4.0

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/README.md CHANGED
@@ -297,6 +297,30 @@ MIT © Digital Defiance
297
297
 
298
298
  ## ChangeLog
299
299
 
300
+ ### Version 2.4.0
301
+
302
+ #### Changed
303
+ - **Version Bump**: Updated from 2.3.5 to 2.4.0
304
+ - **Dependency Update**: Upgraded `@digitaldefiance/suite-core-lib` from ^2.2.5 to ^2.2.10
305
+ - **Translation Keys**: Replaced `Login_UseEmail` with `Login_UseEmailAddress` in BackupCodeLoginForm and LoginForm
306
+ - **Error Messages**: Updated password login error to use `Error_Login_PasswordLoginNotSetup` instead of `PasswordLogin_Setup_NotAvailable` in AuthProvider
307
+
308
+ #### Added
309
+ - **Error Handling**: LoginForm now displays error messages via Alert component with Formik status
310
+ - **Error Recovery**: LoginForm onSubmit wrapped with try-catch to capture and display errors
311
+ - **Menu Context Integration**: TopMenu now uses `useMenu()` hook and `getTopMenus()` method
312
+ - **Menu Types**: Added `AccountCircle` icon import and `IMenuConfig` interface import
313
+
314
+ #### Fixed
315
+ - **Import Path**: Corrected `IAppConfig` import path from `../interfaces/AppConfig` to `../interfaces/IAppConfig`
316
+ - **Menu Rendering**: Simplified TopMenu additional menus logic to use centralized menu context
317
+ - **Error Type**: Added `errorType: 'PasswordLoginNotSetup'` to password login error responses
318
+
319
+ #### Technical
320
+ - Enhanced error propagation in authentication flows
321
+ - Improved menu configuration architecture with context-based management
322
+ - Better alignment with suite-core-lib translation key naming conventions
323
+
300
324
  ### v2.3.5
301
325
 
302
326
  - Login/BackupLogin form improvements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-react-components",
3
- "version": "2.3.5",
3
+ "version": "2.4.0",
4
4
  "description": "React MUI components for Digital Defiance Express Suite",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@digitaldefiance/i18n-lib": "3.6.0",
29
- "@digitaldefiance/suite-core-lib": "^2.2.5",
29
+ "@digitaldefiance/suite-core-lib": "^2.2.10",
30
30
  "@emotion/react": "^11.14.0",
31
31
  "@emotion/styled": "^11.14.0",
32
32
  "@mui/icons-material": "^7.0.2",
@@ -26,7 +26,7 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
26
26
  recoverMnemonic: labels.recoverMnemonic || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_RecoverMnemonic),
27
27
  login: labels.login || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_Login),
28
28
  useUsername: labels.useUsername || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseUsername),
29
- useEmail: labels.useEmail || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmail),
29
+ useEmail: labels.useEmail || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmailAddress),
30
30
  dashboard: labels.dashboard || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard),
31
31
  generateNewCodes: labels.generateNewCodes || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes),
32
32
  mnemonicLabel: labels.mnemonicLabel || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic),
@@ -1 +1 @@
1
- {"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/LoginForm.tsx"],"names":[],"mappings":"AAWA,OAAO,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C/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,eAAe,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9F,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAyOxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/LoginForm.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACj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ACnD;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAsPxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -26,7 +26,7 @@ const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType:
26
26
  forgotPassword: forgotPasswordText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_ForgotPassword),
27
27
  signUp: signUpText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_SignUp),
28
28
  useUsername: useUsernameText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseUsername),
29
- useEmail: useEmailText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmail),
29
+ useEmail: useEmailText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmailAddress),
30
30
  useMnemonic: useMnemonicText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic),
31
31
  usePassword: usePasswordText || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword),
32
32
  toggleVisibility: toggleVisibilityLabel || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.TogglePasswordVisibility),
@@ -61,14 +61,23 @@ const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType:
61
61
  ...additionalValidation,
62
62
  }),
63
63
  enableReinitialize: true,
64
- onSubmit,
64
+ onSubmit: async (values, { setStatus }) => {
65
+ try {
66
+ setStatus(null);
67
+ await onSubmit(values);
68
+ }
69
+ catch (error) {
70
+ setStatus(error.message || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError));
71
+ throw error;
72
+ }
73
+ },
65
74
  });
66
75
  return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
67
76
  marginTop: 8,
68
77
  display: 'flex',
69
78
  flexDirection: 'column',
70
79
  alignItems: 'center',
71
- }, 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: [(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' ? formik.values.email : 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.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: {
80
+ }, 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' ? formik.values.email : 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.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: {
72
81
  input: {
73
82
  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, {}) }) })),
74
83
  },
@@ -1 +1 @@
1
- {"version":3,"file":"TopMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TopMenu.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAStE,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,eAAe,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;CACjD;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAuEpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"TopMenu.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TopMenu.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,EAAE,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAUtE,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,eAAe,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;CACjD;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAmEpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -7,6 +7,7 @@ const Menu_1 = tslib_1.__importDefault(require("@mui/icons-material/Menu"));
7
7
  const DropdownMenu_1 = require("./DropdownMenu");
8
8
  const material_1 = require("@mui/material");
9
9
  const react_1 = require("react");
10
+ const MenuContext_1 = require("../contexts/MenuContext");
10
11
  const react_router_dom_1 = require("react-router-dom");
11
12
  const AuthProvider_1 = require("../contexts/AuthProvider");
12
13
  const I18nProvider_1 = require("../contexts/I18nProvider");
@@ -14,9 +15,9 @@ const SideMenu_1 = require("./SideMenu");
14
15
  const UserLanguageSelector_1 = require("./UserLanguageSelector");
15
16
  const UserMenu_1 = require("./UserMenu");
16
17
  const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
17
- const MenuType_1 = require("../types/MenuType");
18
18
  const TopMenu = ({ Logo, additionalMenus }) => {
19
19
  const { isAuthenticated } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
20
+ const { getTopMenus } = (0, MenuContext_1.useMenu)();
20
21
  const [isSideMenuOpen, setIsSideMenuOpen] = (0, react_1.useState)(false);
21
22
  const handleOpenSideMenu = () => setIsSideMenuOpen(true);
22
23
  const handleCloseSideMenu = () => setIsSideMenuOpen(false);
@@ -31,12 +32,7 @@ const TopMenu = ({ Logo, additionalMenus }) => {
31
32
  marginRight: 2,
32
33
  display: 'flex',
33
34
  alignItems: 'center',
34
- }, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: siteTitle }), (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_dom_1.Link, to: "/dashboard", children: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard)) }), [
35
- ...additionalMenus?.map((menu, index) => ({ ...menu, key: `custom-${index}`, isUserMenu: false })) ?? [],
36
- { menuType: MenuType_1.MenuTypes.UserMenu, menuIcon: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), priority: 0, key: 'user-menu', isUserMenu: true }
37
- ]
38
- .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
39
- .map(menu => menu.isUserMenu ? (0, jsx_runtime_1.jsx)(UserMenu_1.UserMenu, {}, menu.key) : (0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: menu.menuType, menuIcon: menu.menuIcon }, menu.key))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/login", children: t(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_dom_1.Link, to: "/register", children: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton)) })] })), (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
35
+ }, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: siteTitle }), (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_dom_1.Link, to: "/dashboard", children: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard)) }), getTopMenus().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 }, `menu-${index}`))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/login", children: t(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_dom_1.Link, to: "/register", children: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton)) })] })), (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
40
36
  };
41
37
  exports.TopMenu = TopMenu;
42
38
  exports.default = exports.TopMenu;
@@ -170,7 +170,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
170
170
  }, []);
171
171
  const passwordLogin = (0, react_1.useCallback)(async (password, username, email) => {
172
172
  if (!isPasswordLoginAvailable()) {
173
- return { error: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_NotAvailable)) };
173
+ return { error: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup)), errorType: 'PasswordLoginNotSetup' };
174
174
  }
175
175
  setLoading(true);
176
176
  const passwordLoginService = getPasswordLoginService();
@@ -270,7 +270,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
270
270
  }, [baseUrl]);
271
271
  const changePassword = (0, react_1.useCallback)(async (currentPassword, newPassword) => {
272
272
  if (!isPasswordLoginAvailable()) {
273
- return { error: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_NotAvailable)) };
273
+ return { error: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup)), errorType: 'PasswordLoginNotSetup' };
274
274
  }
275
275
  setLoading(true);
276
276
  try {
@@ -1,14 +1,17 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  import { MenuType } from '../types/MenuType';
3
3
  import { IMenuOption } from '../interfaces/IMenuOption';
4
+ import { IMenuConfig } from '../interfaces/IMenuConfig';
4
5
  interface MenuProviderProps {
5
6
  children: ReactNode;
7
+ menuConfigs?: IMenuConfig[];
6
8
  }
7
9
  interface MenuContextType {
8
10
  menuOptions: IMenuOption[];
9
11
  getMenuOptions: (menuType: MenuType, includeDividers: boolean) => IMenuOption[];
10
12
  registerMenuOption: (option: IMenuOption) => () => void;
11
13
  registerMenuOptions: (options: IMenuOption[]) => () => void;
14
+ getTopMenus: () => Array<IMenuConfig>;
12
15
  }
13
16
  export declare const MenuProvider: FC<MenuProviderProps>;
14
17
  export declare const useMenu: () => MenuContextType;
@@ -1 +1 @@
1
- {"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"AAeA,OAAO,EACL,EAAE,EACF,SAAS,EAOV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,cAAc,EAAE,CACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,OAAO,KACrB,WAAW,EAAE,CAAC;IACnB,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,IAAI,CAAC;CAC7D;AAID,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwN9C,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,eAM1B,CAAC"}
1
+ {"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,EAAE,EACF,SAAS,EAQV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,cAAc,EAAE,CACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,OAAO,KACrB,WAAW,EAAE,CAAC;IACnB,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;CACvC;AAID,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwO9C,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,eAM1B,CAAC"}
@@ -12,7 +12,7 @@ const MenuType_1 = require("../types/MenuType");
12
12
  const I18nProvider_1 = require("./I18nProvider");
13
13
  const ThemeProvider_1 = require("./ThemeProvider");
14
14
  const MenuContext = (0, react_1.createContext)(undefined);
15
- const MenuProvider = ({ children }) => {
15
+ const MenuProvider = ({ children, menuConfigs = [] }) => {
16
16
  const { userData: user, isAuthenticated, mnemonic, clearMnemonic, wallet, clearWallet } = (0, AuthProvider_1.useAuth)();
17
17
  const registeredMenuOptions = (0, react_1.useRef)(new Set());
18
18
  const [registeredOptions, setRegisteredOptions] = (0, react_1.useState)(new Map());
@@ -193,14 +193,28 @@ const MenuProvider = ({ children }) => {
193
193
  };
194
194
  return menuOptions.filter(MenuFilter);
195
195
  }, [isAuthenticated, menuOptions]);
196
+ (0, react_1.useEffect)(() => {
197
+ if (menuConfigs.length > 0) {
198
+ return registerMenuOptions(menuConfigs.flatMap(config => config.options));
199
+ }
200
+ return undefined;
201
+ }, [menuConfigs, registerMenuOptions]);
202
+ const getTopMenus = (0, react_1.useCallback)(() => {
203
+ const menus = [
204
+ ...menuConfigs.map(config => ({ ...config, isUserMenu: false })),
205
+ { menuType: MenuType_1.MenuTypes.UserMenu, menuIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AccountCircle, {}), priority: 0, options: [], isUserMenu: true }
206
+ ];
207
+ return menus.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
208
+ }, [menuConfigs]);
196
209
  const contextValue = (0, react_1.useMemo)(() => {
197
210
  return {
198
211
  menuOptions: menuOptions,
199
212
  getMenuOptions: getMenuOptions,
200
213
  registerMenuOption: registerMenuOption,
201
214
  registerMenuOptions: registerMenuOptions,
215
+ getTopMenus: getTopMenus,
202
216
  };
203
- }, [menuOptions, getMenuOptions, registerMenuOption, registerMenuOptions]);
217
+ }, [menuOptions, getMenuOptions, registerMenuOption, registerMenuOptions, getTopMenus]);
204
218
  const memoizedChildren = (0, react_1.useMemo)(() => children, [children]);
205
219
  return ((0, jsx_runtime_1.jsx)(MenuContext.Provider, { value: contextValue, children: memoizedChildren }));
206
220
  };
@@ -3,4 +3,4 @@ export interface IAppConfig {
3
3
  siteTitle: string;
4
4
  server: string;
5
5
  }
6
- //# sourceMappingURL=AppConfig.d.ts.map
6
+ //# sourceMappingURL=IAppConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAppConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/IAppConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from 'react';
2
+ import { IMenuOption } from './IMenuOption';
3
+ import { createMenuType } from '../types';
4
+ export interface IMenuConfig {
5
+ menuType: ReturnType<typeof createMenuType>;
6
+ menuIcon: ReactElement;
7
+ priority?: number;
8
+ options: IMenuOption[];
9
+ isUserMenu?: boolean;
10
+ }
11
+ //# sourceMappingURL=IMenuConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMenuConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/IMenuConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
- export * from './AppConfig';
1
+ export * from './IAppConfig';
2
2
  export * from './IMenuOption';
3
+ export * from './IMenuConfig';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./AppConfig"), exports);
4
+ tslib_1.__exportStar(require("./IAppConfig"), exports);
5
5
  tslib_1.__exportStar(require("./IMenuOption"), exports);
6
+ tslib_1.__exportStar(require("./IMenuConfig"), exports);
@@ -1,21 +1,14 @@
1
1
  import { EmailString, IECIESConfig, SecureString } from '@digitaldefiance/ecies-lib';
2
2
  import { IConstants, IRequestUserDTO } from '@digitaldefiance/suite-core-lib';
3
- import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
4
3
  import { Wallet } from '@ethereumjs/wallet';
5
- interface AuthContextFunctions {
6
- setUser: (user: IRequestUserDTO | null) => void;
7
- setLanguage: (lang: CoreLanguageCode) => void;
8
- }
9
4
  export declare class AuthService {
10
5
  private constants;
11
6
  private baseUrl;
12
- private authContextFunctions;
13
7
  private eciesService;
14
8
  private cryptoCore;
15
9
  private apiClient;
16
10
  private authenticatedApiClient;
17
11
  constructor(constants: IConstants, baseUrl: string, eciesConfig: IECIESConfig);
18
- setAuthContextFunctions(functions: AuthContextFunctions): void;
19
12
  getSiteDomain(): string;
20
13
  register(username: string, email: string, timezone: string, password?: string): Promise<{
21
14
  success: boolean;
@@ -76,5 +69,4 @@ export declare class AuthService {
76
69
  }>;
77
70
  }
78
71
  export declare const createAuthService: (constants: IConstants, baseUrl: string, eciesConfig: IECIESConfig) => AuthService;
79
- export {};
80
72
  //# sourceMappingURL=authService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEX,YAAY,EAGZ,YAAY,EAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA2B,UAAU,EAAE,eAAe,EAA8C,MAAM,iCAAiC,CAAC;AACnJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAK5C,UAAU,oBAAoB;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,WAAW,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC/C;AAED,qBAAa,WAAW;IAQpB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,oBAAoB,CAAqC;IACjE,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,UAAU,CAAkB;IACpC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MAAM,EAAE,aAAa,YAAY,gBACjD,CAAC"}
1
+ {"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEX,YAAY,EACZ,YAAY,EAEb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA2B,UAAU,EAAE,eAAe,EAA8C,MAAM,iCAAiC,CAAC;AAEnJ,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAU5C,qBAAa,WAAW;IAOpB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAPjB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,sBAAsB,CAAsB;gBAG1C,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,MAAM,EACvB,WAAW,EAAE,YAAY;IAQ3B,aAAa,IAAI,MAAM;IAIjB,QAAQ,CACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CACN;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACvD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;KACxC,CACJ;IAsDK,WAAW,CACf,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CACN;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,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AChB,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CACN;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GACD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CACzD;CA2CF;AAED,eAAO,MAAM,iBAAiB,GAAI,WAAW,UAAU,EAAE,SAAS,MAAM,EAAE,aAAa,YAAY,gBACjD,CAAC"}
@@ -10,7 +10,6 @@ const authenticatedApi_1 = require("./authenticatedApi");
10
10
  class AuthService {
11
11
  constants;
12
12
  baseUrl;
13
- authContextFunctions = null;
14
13
  eciesService;
15
14
  cryptoCore;
16
15
  apiClient;
@@ -23,9 +22,6 @@ class AuthService {
23
22
  this.apiClient = (0, api_1.createApiClient)(this.baseUrl);
24
23
  this.authenticatedApiClient = (0, authenticatedApi_1.createAuthenticatedApiClient)(this.baseUrl);
25
24
  }
26
- setAuthContextFunctions(functions) {
27
- this.authContextFunctions = functions;
28
- }
29
25
  getSiteDomain() {
30
26
  return this.constants.AdministratorEmail.split('@')[1];
31
27
  }
@@ -90,17 +86,18 @@ class AuthService {
90
86
  }
91
87
  try {
92
88
  const loginRequest = await this.apiClient.post('/user/request-direct-login');
93
- const usernameOrEmail = (username ?? email !== undefined) ? email.email : '';
94
- const emailString = email
95
- ? email
96
- : new ecies_lib_1.EmailString(`${username}@${this.getSiteDomain()}`);
97
89
  if (loginRequest.data.challenge) {
98
90
  const { wallet } = this.cryptoCore.walletAndSeedFromMnemonic(mnemonic);
99
- const signingUser = new ecies_lib_1.Member(this.eciesService, ecies_lib_1.MemberType.User, usernameOrEmail, emailString, wallet.getPublicKey(), new ecies_lib_1.SecureBuffer(wallet.getPrivateKey()), wallet);
91
+ const publicKey = wallet.getPublicKey();
92
+ // Add 0x04 prefix for uncompressed public key
93
+ const publicKeyWithPrefix = new Uint8Array(publicKey.length + 1);
94
+ publicKeyWithPrefix[0] = 0x04;
95
+ publicKeyWithPrefix.set(publicKey, 1);
100
96
  const challengeBuffer = (0, ecies_lib_1.hexToUint8Array)(loginRequest.data.challenge);
101
- const signature = await signingUser.sign(challengeBuffer);
97
+ const privateKeyBuffer = wallet.getPrivateKey();
98
+ const signature = this.eciesService.signMessage(privateKeyBuffer, challengeBuffer);
102
99
  const signatureHex = (0, ecies_lib_1.uint8ArrayToHex)(signature);
103
- const loginResponse = await this.apiClient.post('/user/direct-login', {
100
+ const loginResponse = await this.apiClient.post('/user/direct-challenge', {
104
101
  username: username,
105
102
  email: email ? email.email : undefined,
106
103
  challenge: loginRequest.data.challenge,
@@ -118,6 +115,20 @@ class AuthService {
118
115
  }
119
116
  catch (error) {
120
117
  if ((0, axios_1.isAxiosError)(error) && error.response) {
118
+ // Check for DirectChallengeNotEnabled error
119
+ if (error.response.status === 403 && error.response.data.errorType === 'DirectChallengeNotEnabledError') {
120
+ return {
121
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Error_Login_DirectChallengeNotEnabled),
122
+ errorType: 'DirectChallengeNotEnabled',
123
+ };
124
+ }
125
+ // Check for PasswordLoginNotEnabled error
126
+ if (error.response.status === 403 && error.response.data.errorType === 'PasswordLoginNotEnabledError') {
127
+ return {
128
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotEnabled),
129
+ errorType: 'PasswordLoginNotEnabled',
130
+ };
131
+ }
121
132
  return {
122
133
  error: error.response.data.error?.message ??
123
134
  error.response.data.message ??
@@ -128,6 +139,7 @@ class AuthService {
128
139
  : {}),
129
140
  };
130
141
  }
142
+ console.error('directLogin: non-axios error:', error);
131
143
  }
132
144
  return {
133
145
  error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
@@ -172,14 +184,10 @@ class AuthService {
172
184
  };
173
185
  }
174
186
  try {
175
- const usernameOrEmail = (username ?? email !== undefined) ? email.email : '';
176
- const emailString = email
177
- ? email
178
- : new ecies_lib_1.EmailString(`${username}@${this.getSiteDomain()}`);
179
187
  const { wallet } = this.cryptoCore.walletAndSeedFromMnemonic(mnemonic);
180
- const signingUser = new ecies_lib_1.Member(this.eciesService, ecies_lib_1.MemberType.User, usernameOrEmail, emailString, wallet.getPublicKey(), new ecies_lib_1.SecureBuffer(wallet.getPrivateKey()), wallet);
181
188
  const challengeBuffer = (0, ecies_lib_1.hexToUint8Array)(token);
182
- const signature = await signingUser.sign(challengeBuffer);
189
+ const privateKeyBuffer = wallet.getPrivateKey();
190
+ const signature = this.eciesService.signMessage(privateKeyBuffer, challengeBuffer);
183
191
  const signatureHex = (0, ecies_lib_1.uint8ArrayToHex)(signature);
184
192
  const response = await this.apiClient.post('/user/email-login', {
185
193
  token,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAaxD,eAAO,MAAM,sBAAsB,EAAE,EAWpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoC1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAevC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EA8B9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAyBjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAK/B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAcxD,eAAO,MAAM,sBAAsB,EAAE,EAWpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoC1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAevC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAkC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAyBjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAK/B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC"}
@@ -14,6 +14,7 @@ const LogoutPage_1 = require("../components/LogoutPage");
14
14
  const VerifyEmailPage_1 = require("../components/VerifyEmailPage");
15
15
  const contexts_1 = require("../contexts");
16
16
  const services_1 = require("../services");
17
+ const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
17
18
  const BackupCodeLoginWrapper = () => {
18
19
  const { backupCodeLogin, isAuthenticated } = (0, contexts_1.useAuth)();
19
20
  const navigate = (0, react_router_dom_1.useNavigate)();
@@ -69,21 +70,25 @@ const LoginFormWrapper = () => {
69
70
  const { directLogin, passwordLogin } = (0, contexts_1.useAuth)();
70
71
  const navigate = (0, react_router_dom_1.useNavigate)();
71
72
  const handleSubmit = async (values) => {
72
- console.log('LoginFormWrapper handleSubmit called with:', { ...values, password: values.password ? '***' : undefined, mnemonic: values.mnemonic ? '***' : undefined });
73
+ const email = values.email && values.email.trim().length > 0 ? new ecies_lib_1.EmailString(values.email) : undefined;
74
+ const username = values.username && values.username.trim() ? values.username : undefined;
73
75
  if (values.password) {
74
- const result = await passwordLogin(new ecies_lib_1.SecureString(values.password), values.username, values.email ? new ecies_lib_1.EmailString(values.email) : undefined);
76
+ const result = await passwordLogin(new ecies_lib_1.SecureString(values.password), username, email);
75
77
  if ('error' in result) {
76
78
  throw new Error(result.error);
77
79
  }
78
80
  navigate('/dashboard');
79
81
  }
80
82
  else if (values.mnemonic) {
81
- const result = await directLogin(new ecies_lib_1.SecureString(values.mnemonic), values.username, values.email ? new ecies_lib_1.EmailString(values.email) : undefined);
83
+ const result = await directLogin(new ecies_lib_1.SecureString(values.mnemonic), username, email);
82
84
  if ('error' in result) {
83
85
  throw new Error(result.error);
84
86
  }
85
87
  navigate('/dashboard');
86
88
  }
89
+ else {
90
+ throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Error_NoPasswordOrMnemonicProvided);
91
+ }
87
92
  };
88
93
  return (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onSubmit: handleSubmit });
89
94
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/AppConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"}
File without changes