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

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.
Files changed (34) hide show
  1. package/README.md +30 -0
  2. package/package.json +2 -2
  3. package/src/components/BackupCodeLoginForm.js +1 -1
  4. package/src/components/LoginForm.d.ts.map +1 -1
  5. package/src/components/LoginForm.js +12 -3
  6. package/src/components/RegisterForm.d.ts.map +1 -1
  7. package/src/components/RegisterForm.js +2 -1
  8. package/src/components/TopMenu.d.ts.map +1 -1
  9. package/src/components/TopMenu.js +3 -7
  10. package/src/components/UserSettingsForm.d.ts +61 -0
  11. package/src/components/UserSettingsForm.d.ts.map +1 -0
  12. package/src/components/UserSettingsForm.js +88 -0
  13. package/src/components/index.d.ts +1 -0
  14. package/src/components/index.d.ts.map +1 -1
  15. package/src/components/index.js +1 -0
  16. package/src/contexts/AuthProvider.js +2 -2
  17. package/src/contexts/MenuContext.d.ts +3 -0
  18. package/src/contexts/MenuContext.d.ts.map +1 -1
  19. package/src/contexts/MenuContext.js +16 -2
  20. package/src/interfaces/{AppConfig.d.ts → IAppConfig.d.ts} +1 -1
  21. package/src/interfaces/IAppConfig.d.ts.map +1 -0
  22. package/src/interfaces/IMenuConfig.d.ts +11 -0
  23. package/src/interfaces/IMenuConfig.d.ts.map +1 -0
  24. package/src/interfaces/IMenuConfig.js +2 -0
  25. package/src/interfaces/index.d.ts +2 -1
  26. package/src/interfaces/index.d.ts.map +1 -1
  27. package/src/interfaces/index.js +2 -1
  28. package/src/services/authService.d.ts +0 -8
  29. package/src/services/authService.d.ts.map +1 -1
  30. package/src/services/authService.js +25 -17
  31. package/src/wrappers/index.d.ts.map +1 -1
  32. package/src/wrappers/index.js +8 -3
  33. package/src/interfaces/AppConfig.d.ts.map +0 -1
  34. /package/src/interfaces/{AppConfig.js → IAppConfig.js} +0 -0
package/README.md CHANGED
@@ -297,6 +297,36 @@ MIT © Digital Defiance
297
297
 
298
298
  ## ChangeLog
299
299
 
300
+ ### Version 2.4.1
301
+
302
+ - Add directChallenge configuration option to registration
303
+ - Add user settings form
304
+ - Update suite core lib
305
+
306
+ ### Version 2.4.0
307
+
308
+ #### Changed
309
+ - **Version Bump**: Updated from 2.3.5 to 2.4.0
310
+ - **Dependency Update**: Upgraded `@digitaldefiance/suite-core-lib` from ^2.2.5 to ^2.2.10
311
+ - **Translation Keys**: Replaced `Login_UseEmail` with `Login_UseEmailAddress` in BackupCodeLoginForm and LoginForm
312
+ - **Error Messages**: Updated password login error to use `Error_Login_PasswordLoginNotSetup` instead of `PasswordLogin_Setup_NotAvailable` in AuthProvider
313
+
314
+ #### Added
315
+ - **Error Handling**: LoginForm now displays error messages via Alert component with Formik status
316
+ - **Error Recovery**: LoginForm onSubmit wrapped with try-catch to capture and display errors
317
+ - **Menu Context Integration**: TopMenu now uses `useMenu()` hook and `getTopMenus()` method
318
+ - **Menu Types**: Added `AccountCircle` icon import and `IMenuConfig` interface import
319
+
320
+ #### Fixed
321
+ - **Import Path**: Corrected `IAppConfig` import path from `../interfaces/AppConfig` to `../interfaces/IAppConfig`
322
+ - **Menu Rendering**: Simplified TopMenu additional menus logic to use centralized menu context
323
+ - **Error Type**: Added `errorType: 'PasswordLoginNotSetup'` to password login error responses
324
+
325
+ #### Technical
326
+ - Enhanced error propagation in authentication flows
327
+ - Improved menu configuration architecture with context-based management
328
+ - Better alignment with suite-core-lib translation key naming conventions
329
+
300
330
  ### v2.3.5
301
331
 
302
332
  - 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.1",
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.13",
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,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OA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kB,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;IACjC,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mB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@ -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":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,CACnE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM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AAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,CACnE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CACvG,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1E,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA8R9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -43,6 +43,7 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
43
43
  timezone: getInitialTimezone(),
44
44
  password: '',
45
45
  confirmPassword: '',
46
+ directChallenge: false,
46
47
  ...additionalInitialValues,
47
48
  },
48
49
  enableReinitialize: true,
@@ -96,7 +97,7 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
96
97
  });
97
98
  return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 8, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "username", name: "username", label: labels.username || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username), value: formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.username && (formik.errors.username || apiErrors.username)), helperText: formik.touched.username && (formik.errors.username || apiErrors.username), margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: formik.touched.email && (formik.errors.email || apiErrors.email), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone && (formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: () => setUsePassword(!usePassword), children: usePassword
98
99
  ? labels.useMnemonic || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic)
99
- : labels.usePassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" })] })), additionalFields && additionalFields(formik, usePassword), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: registering
100
+ : labels.usePassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" })] })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge || false, onChange: formik.handleChange }), label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik, usePassword), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: registering
100
101
  ? labels.registering || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering)
101
102
  : labels.register || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisterButton) }), registering && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.registering || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisteringMessage) })] })), mnemonic && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [labels.mnemonicSuccess || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", component: "div", sx: { mt: 1, fontFamily: 'monospace' }, children: mnemonic }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })), registrationSuccess && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })), !mnemonic && !registrationSuccess && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", variant: "body2", children: labels.loginLink || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_LoginLink) }) }))] })] }) }));
102
103
  };
@@ -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;
@@ -0,0 +1,61 @@
1
+ import { FC } from 'react';
2
+ import * as Yup from 'yup';
3
+ export interface UserSettingsFormValues {
4
+ email: string;
5
+ timezone: string;
6
+ siteLanguage: string;
7
+ currency: string;
8
+ darkMode: boolean;
9
+ directChallenge: boolean;
10
+ [key: string]: any;
11
+ }
12
+ export interface UserSettingsFormProps {
13
+ initialValues: UserSettingsFormValues;
14
+ onSubmit: (values: UserSettingsFormValues) => Promise<{
15
+ success: boolean;
16
+ message: string;
17
+ } | {
18
+ error: string;
19
+ errorType?: string;
20
+ field?: string;
21
+ errors?: Array<{
22
+ path: string;
23
+ msg: string;
24
+ }>;
25
+ }>;
26
+ timezones: string[];
27
+ languages: Array<{
28
+ code: string;
29
+ label: string;
30
+ }>;
31
+ currencies: Array<{
32
+ code: string;
33
+ label: string;
34
+ }>;
35
+ emailValidation?: Yup.StringSchema;
36
+ timezoneValidation?: Yup.StringSchema;
37
+ siteLanguageValidation?: Yup.StringSchema;
38
+ currencyValidation?: Yup.StringSchema;
39
+ darkModeValidation?: Yup.BooleanSchema;
40
+ directChallengeValidation?: Yup.BooleanSchema;
41
+ additionalFields?: (formik: any) => React.ReactNode;
42
+ additionalInitialValues?: Record<string, any>;
43
+ additionalValidation?: Record<string, Yup.Schema>;
44
+ labels?: {
45
+ title?: string;
46
+ email?: string;
47
+ emailHelper?: string;
48
+ timezone?: string;
49
+ siteLanguage?: string;
50
+ currency?: string;
51
+ darkMode?: string;
52
+ directChallenge?: string;
53
+ directChallengeHelper?: string;
54
+ saving?: string;
55
+ save?: string;
56
+ successMessage?: string;
57
+ };
58
+ }
59
+ export declare const UserSettingsForm: FC<UserSettingsFormProps>;
60
+ export default UserSettingsForm;
61
+ //# 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":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,OAAO,CACjD;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACrC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CACvG,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,sBAAsB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC1C,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IACvC,yBAAyB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;IACpD,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAmQtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserSettingsForm = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const 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 suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
11
+ const contexts_1 = require("../contexts");
12
+ const UserSettingsForm = ({ initialValues, onSubmit, timezones, languages, currencies, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
13
+ const { t, tComponent } = (0, contexts_1.useI18n)();
14
+ const [apiErrors, setApiErrors] = (0, react_1.useState)({});
15
+ const [saving, setSaving] = (0, react_1.useState)(false);
16
+ const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
17
+ const validation = {
18
+ email: emailValidation || Yup.string()
19
+ .email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
20
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
21
+ timezone: timezoneValidation || Yup.string()
22
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
23
+ .oneOf(timezones, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid)),
24
+ siteLanguage: siteLanguageValidation || Yup.string()
25
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
26
+ currency: currencyValidation || Yup.string()
27
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
28
+ darkMode: darkModeValidation || Yup.boolean()
29
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
30
+ directChallenge: directChallengeValidation || Yup.boolean()
31
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
32
+ };
33
+ const formik = (0, formik_1.useFormik)({
34
+ initialValues: {
35
+ ...initialValues,
36
+ ...additionalInitialValues,
37
+ },
38
+ enableReinitialize: true,
39
+ validationSchema: Yup.object({
40
+ email: validation.email,
41
+ timezone: validation.timezone,
42
+ siteLanguage: validation.siteLanguage,
43
+ currency: validation.currency,
44
+ darkMode: validation.darkMode,
45
+ directChallenge: validation.directChallenge,
46
+ ...additionalValidation,
47
+ }),
48
+ onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
49
+ setSaving(true);
50
+ setSuccessMessage(null);
51
+ const result = await onSubmit(values);
52
+ if ('success' in result && result.success) {
53
+ setSuccessMessage(result.message || labels.successMessage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess));
54
+ setApiErrors({});
55
+ }
56
+ else {
57
+ const newApiErrors = {};
58
+ const fieldsToTouch = {};
59
+ if ('field' in result && result.field) {
60
+ setFieldError(result.field, result.error);
61
+ fieldsToTouch[result.field] = true;
62
+ }
63
+ if ('errors' in result && result.errors) {
64
+ result.errors.forEach((err) => {
65
+ if (err.path && err.msg) {
66
+ setFieldError(err.path, err.msg);
67
+ fieldsToTouch[err.path] = true;
68
+ }
69
+ });
70
+ }
71
+ if ('error' in result && result.error && !Object.keys(newApiErrors).length) {
72
+ newApiErrors.general = result.error;
73
+ }
74
+ setApiErrors(newApiErrors);
75
+ setTouched(fieldsToTouch, false);
76
+ }
77
+ setSubmitting(false);
78
+ setSaving(false);
79
+ },
80
+ });
81
+ return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 4, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Title) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: (formik.touched.email && (formik.errors.email || apiErrors.email)) ||
82
+ labels.emailHelper ||
83
+ tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone && (formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "language-label", children: labels.siteLanguage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "language-label", id: "siteLanguage", name: "siteLanguage", value: formik.values.siteLanguage, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.siteLanguage && Boolean(formik.errors.siteLanguage), label: labels.siteLanguage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage), children: languages.map((lang) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: lang.code, children: lang.label }, lang.code))) }), formik.touched.siteLanguage && (formik.errors.siteLanguage || apiErrors.siteLanguage) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.siteLanguage || apiErrors.siteLanguage }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "currency-label", children: labels.currency || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "currency-label", id: "currency", name: "currency", value: formik.values.currency, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.currency && Boolean(formik.errors.currency), label: labels.currency || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency), children: currencies.map((curr) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: curr.code, children: curr.label }, curr.code))) }), formik.touched.currency && (formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
84
+ ? labels.saving || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
85
+ : labels.save || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Save) })] })] }) }));
86
+ };
87
+ exports.UserSettingsForm = UserSettingsForm;
88
+ exports.default = exports.UserSettingsForm;
@@ -14,6 +14,7 @@ export * from './LoginForm';
14
14
  export * from './LogoutPage';
15
15
  export * from './RegisterForm';
16
16
  export * from './ResetPasswordForm';
17
+ export * from './UserSettingsForm';
17
18
  export * from './SideMenu';
18
19
  export * from './SideMenuListItem';
19
20
  export * from './TopMenu';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -18,6 +18,7 @@ tslib_1.__exportStar(require("./LoginForm"), exports);
18
18
  tslib_1.__exportStar(require("./LogoutPage"), exports);
19
19
  tslib_1.__exportStar(require("./RegisterForm"), exports);
20
20
  tslib_1.__exportStar(require("./ResetPasswordForm"), exports);
21
+ tslib_1.__exportStar(require("./UserSettingsForm"), exports);
21
22
  tslib_1.__exportStar(require("./SideMenu"), exports);
22
23
  tslib_1.__exportStar(require("./SideMenuListItem"), exports);
23
24
  tslib_1.__exportStar(require("./TopMenu"), exports);
@@ -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,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,sBAAsB,CAAsB;gBAG1C,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,MAAM,EACvB,WAAW,EAAE,YAAY;IAQ3B,uBAAuB,CAAC,SAAS,EAAE,oBAAoB;IAIvD,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,C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IA2BI,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAwBlE,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,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"}
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,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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