@digitaldefiance/express-suite-react-components 2.3.4 → 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 +28 -0
- package/package.json +2 -2
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -1
- package/src/components/BackupCodeLoginForm.js +13 -9
- package/src/components/LoginForm.d.ts.map +1 -1
- package/src/components/LoginForm.js +29 -12
- package/src/components/TopMenu.d.ts.map +1 -1
- package/src/components/TopMenu.js +3 -7
- package/src/contexts/AuthProvider.js +2 -2
- package/src/contexts/MenuContext.d.ts +3 -0
- package/src/contexts/MenuContext.d.ts.map +1 -1
- package/src/contexts/MenuContext.js +16 -2
- package/src/interfaces/{AppConfig.d.ts → IAppConfig.d.ts} +1 -1
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.d.ts +11 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/index.d.ts +2 -1
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +2 -1
- package/src/services/authService.d.ts +0 -8
- package/src/services/authService.d.ts.map +1 -1
- package/src/services/authService.js +25 -17
- package/src/wrappers/index.d.ts.map +1 -1
- package/src/wrappers/index.js +8 -2
- package/src/interfaces/AppConfig.d.ts.map +0 -1
- /package/src/interfaces/{AppConfig.js → IAppConfig.js} +0 -0
package/README.md
CHANGED
|
@@ -297,6 +297,34 @@ 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
|
+
|
|
324
|
+
### v2.3.5
|
|
325
|
+
|
|
326
|
+
- Login/BackupLogin form improvements
|
|
327
|
+
|
|
300
328
|
### v2.3.4
|
|
301
329
|
|
|
302
330
|
- Simplify Private to use AuthContext and not need props
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.
|
|
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.
|
|
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",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACzE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CACrC,CAAC;IACF,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACzE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CACrC,CAAC;IACF,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CA+P5D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -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.
|
|
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),
|
|
@@ -48,12 +48,6 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
48
48
|
confirmPassword: Yup.string()
|
|
49
49
|
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch)),
|
|
50
50
|
};
|
|
51
|
-
const yupSchema = validationSchema ?? Yup.object({
|
|
52
|
-
[loginType]: loginType === 'email' ? yupFieldValidation.email : yupFieldValidation.username,
|
|
53
|
-
code: yupFieldValidation.code,
|
|
54
|
-
newPassword: yupFieldValidation.password,
|
|
55
|
-
confirmNewPassword: yupFieldValidation.confirmPassword,
|
|
56
|
-
});
|
|
57
51
|
const formik = (0, formik_1.useFormik)({
|
|
58
52
|
initialValues: {
|
|
59
53
|
email: '',
|
|
@@ -63,7 +57,13 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
63
57
|
confirmNewPassword: '',
|
|
64
58
|
recoverMnemonic: false,
|
|
65
59
|
},
|
|
66
|
-
validationSchema:
|
|
60
|
+
validationSchema: validationSchema ?? Yup.object({
|
|
61
|
+
[loginType]: loginType === 'email' ? yupFieldValidation.email : yupFieldValidation.username,
|
|
62
|
+
code: yupFieldValidation.code,
|
|
63
|
+
newPassword: yupFieldValidation.password,
|
|
64
|
+
confirmNewPassword: yupFieldValidation.confirmPassword,
|
|
65
|
+
}),
|
|
66
|
+
enableReinitialize: true,
|
|
67
67
|
onSubmit: async (values, { setSubmitting }) => {
|
|
68
68
|
try {
|
|
69
69
|
const loginResult = await onSubmit(loginType === 'email' ? values.email : values.username, values.code, loginType === 'email', values.recoverMnemonic, values.newPassword && values.newPassword.length > 0 ? values.newPassword : undefined);
|
|
@@ -96,7 +96,11 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
96
96
|
onNavigate?.('/dashboard');
|
|
97
97
|
return null;
|
|
98
98
|
}
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { marginTop: 8, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: translatedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [!isAuthenticated && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, id: loginType, label: loginType === 'email' ? translatedLabels.email : translatedLabels.username, name: loginType, autoComplete: loginType === 'email' ? 'email' : 'username', autoFocus: true, value: loginType === 'email' ? formik.values.email : formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched[loginType] && Boolean(formik.errors[loginType]), helperText: formik.touched[loginType] && formik.errors[loginType], disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "code", label: translatedLabels.code, id: "code", value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.code && Boolean(formik.errors.code), helperText: formik.touched.code && formik.errors.code, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "newPassword", label: translatedLabels.newPassword, type: "password", id: "newPassword", value: formik.values.newPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.newPassword && Boolean(formik.errors.newPassword), helperText: formik.touched.newPassword && formik.errors.newPassword, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "confirmNewPassword", label: translatedLabels.confirmPassword, type: "password", id: "confirmNewPassword", value: formik.values.confirmNewPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.confirmNewPassword && Boolean(formik.errors.confirmNewPassword), helperText: formik.touched.confirmNewPassword && formik.errors.confirmNewPassword, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: formik.values.recoverMnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, name: "recoverMnemonic" }), label: translatedLabels.recoverMnemonic, disabled: isAuthenticated })] })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "success.main", variant: "body2", sx: { mt: 1 }, children: successMessage })), recoveredMnemonic && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2, p: 2, bgcolor: 'grey.100', borderRadius: 1 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: [translatedLabels.mnemonicLabel, ":"] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { fontFamily: 'monospace' }, children: recoveredMnemonic }), (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "contained", sx: { mt: 2 }, onClick: () => onNavigate?.('/dashboard'), children: translatedLabels.dashboard })] })), codesRemaining !== null && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: translatedLabels.codesRemaining.replace('{count}', String(codesRemaining)) }), (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "contained", sx: { mt: 2 }, onClick: () => onNavigate?.('/backup-codes', { codeCount: codesRemaining }), children: translatedLabels.generateNewCodes })] })), loginError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "body2", sx: { mt: 1 }, children: loginError })), !isAuthenticated && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: translatedLabels.login }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', justifyContent: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () =>
|
|
99
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { marginTop: 8, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: translatedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [!isAuthenticated && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, id: loginType, label: loginType === 'email' ? translatedLabels.email : translatedLabels.username, name: loginType, autoComplete: loginType === 'email' ? 'email' : 'username', autoFocus: true, value: loginType === 'email' ? formik.values.email : formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched[loginType] && Boolean(formik.errors[loginType]), helperText: formik.touched[loginType] && formik.errors[loginType], disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "code", label: translatedLabels.code, id: "code", value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.code && Boolean(formik.errors.code), helperText: formik.touched.code && formik.errors.code, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "newPassword", label: translatedLabels.newPassword, type: "password", id: "newPassword", value: formik.values.newPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.newPassword && Boolean(formik.errors.newPassword), helperText: formik.touched.newPassword && formik.errors.newPassword, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "confirmNewPassword", label: translatedLabels.confirmPassword, type: "password", id: "confirmNewPassword", value: formik.values.confirmNewPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.confirmNewPassword && Boolean(formik.errors.confirmNewPassword), helperText: formik.touched.confirmNewPassword && formik.errors.confirmNewPassword, disabled: isAuthenticated }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: formik.values.recoverMnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, name: "recoverMnemonic" }), label: translatedLabels.recoverMnemonic, disabled: isAuthenticated })] })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "success.main", variant: "body2", sx: { mt: 1 }, children: successMessage })), recoveredMnemonic && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2, p: 2, bgcolor: 'grey.100', borderRadius: 1 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: [translatedLabels.mnemonicLabel, ":"] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { fontFamily: 'monospace' }, children: recoveredMnemonic }), (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "contained", sx: { mt: 2 }, onClick: () => onNavigate?.('/dashboard'), children: translatedLabels.dashboard })] })), codesRemaining !== null && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: translatedLabels.codesRemaining.replace('{count}', String(codesRemaining)) }), (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "contained", sx: { mt: 2 }, onClick: () => onNavigate?.('/backup-codes', { codeCount: codesRemaining }), children: translatedLabels.generateNewCodes })] })), loginError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "body2", sx: { mt: 1 }, children: loginError })), !isAuthenticated && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: translatedLabels.login }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', justifyContent: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () => {
|
|
100
|
+
const newType = loginType === 'email' ? 'username' : 'email';
|
|
101
|
+
formik.setFieldValue(loginType, '');
|
|
102
|
+
setLoginType(newType);
|
|
103
|
+
}, children: loginType === 'email' ? translatedLabels.useUsername : translatedLabels.useEmail }) })] }))] })] }) }));
|
|
100
104
|
};
|
|
101
105
|
exports.BackupCodeLoginForm = BackupCodeLoginForm;
|
|
102
106
|
exports.default = exports.BackupCodeLoginForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/LoginForm.tsx"],"names":[],"mappings":"
|
|
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,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/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,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.
|
|
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),
|
|
@@ -45,13 +45,6 @@ const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType:
|
|
|
45
45
|
.matches(suite_core_lib_1.Constants.MnemonicRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidMnemonic))
|
|
46
46
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
47
47
|
};
|
|
48
|
-
const validationSchema = Yup.object({
|
|
49
|
-
[loginType]: loginType === 'email' ? validation.email : validation.username,
|
|
50
|
-
...(authType === 'mnemonic'
|
|
51
|
-
? { mnemonic: validation.mnemonic }
|
|
52
|
-
: { password: validation.password }),
|
|
53
|
-
...additionalValidation,
|
|
54
|
-
});
|
|
55
48
|
const formik = (0, formik_1.useFormik)({
|
|
56
49
|
initialValues: {
|
|
57
50
|
email: '',
|
|
@@ -60,15 +53,31 @@ const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType:
|
|
|
60
53
|
password: '',
|
|
61
54
|
...additionalInitialValues,
|
|
62
55
|
},
|
|
63
|
-
validationSchema
|
|
64
|
-
|
|
56
|
+
validationSchema: Yup.object({
|
|
57
|
+
[loginType]: loginType === 'email' ? validation.email : validation.username,
|
|
58
|
+
...(authType === 'mnemonic'
|
|
59
|
+
? { mnemonic: validation.mnemonic }
|
|
60
|
+
: { password: validation.password }),
|
|
61
|
+
...additionalValidation,
|
|
62
|
+
}),
|
|
63
|
+
enableReinitialize: true,
|
|
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
|
},
|
|
@@ -76,7 +85,15 @@ const LoginForm = ({ onSubmit, loginType: initialLoginType = 'email', authType:
|
|
|
76
85
|
input: {
|
|
77
86
|
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, {}) }) })),
|
|
78
87
|
},
|
|
79
|
-
} })), additionalFields && additionalFields(formik), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: labels.signIn }), (showForgotPassword || showSignUp) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', justifyContent: 'space-between' }, children: [showForgotPassword && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: forgotPasswordLink, variant: "body2", children: labels.forgotPassword })), showSignUp && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: signUpLink, variant: "body2", children: labels.signUp }))] })), (allowLoginTypeToggle || allowAuthTypeToggle) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 1, mt: 2 }, children: [allowLoginTypeToggle && ((0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () =>
|
|
88
|
+
} })), additionalFields && additionalFields(formik), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: labels.signIn }), (showForgotPassword || showSignUp) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', justifyContent: 'space-between' }, children: [showForgotPassword && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: forgotPasswordLink, variant: "body2", children: labels.forgotPassword })), showSignUp && ((0, jsx_runtime_1.jsx)(material_1.Link, { href: signUpLink, variant: "body2", children: labels.signUp }))] })), (allowLoginTypeToggle || allowAuthTypeToggle) && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 1, mt: 2 }, children: [allowLoginTypeToggle && ((0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () => {
|
|
89
|
+
const newType = loginType === 'email' ? 'username' : 'email';
|
|
90
|
+
formik.setFieldValue(loginType, '');
|
|
91
|
+
setLoginType(newType);
|
|
92
|
+
}, children: loginType === 'email' ? labels.useUsername : labels.useEmail })), allowAuthTypeToggle && ((0, jsx_runtime_1.jsx)(material_1.Button, { fullWidth: true, variant: "text", onClick: () => {
|
|
93
|
+
const newType = authType === 'password' ? 'mnemonic' : 'password';
|
|
94
|
+
formik.setFieldValue(authType, '');
|
|
95
|
+
setAuthType(newType);
|
|
96
|
+
}, children: authType === 'password' ? labels.useMnemonic : labels.usePassword }))] }))] })] }) }));
|
|
80
97
|
};
|
|
81
98
|
exports.LoginForm = LoginForm;
|
|
82
99
|
exports.default = exports.LoginForm;
|
|
@@ -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;
|
|
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.
|
|
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.
|
|
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":"
|
|
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
|
};
|
|
@@ -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"}
|
|
@@ -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,
|
|
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"}
|
package/src/interfaces/index.js
CHANGED
|
@@ -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("./
|
|
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,
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/authService.ts"],"names":[],"mappings":"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"}
|
|
@@ -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
|
|
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
|
|
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-
|
|
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
|
|
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;
|
|
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"}
|
package/src/wrappers/index.js
CHANGED
|
@@ -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,20 +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) => {
|
|
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;
|
|
72
75
|
if (values.password) {
|
|
73
|
-
const result = await passwordLogin(new ecies_lib_1.SecureString(values.password),
|
|
76
|
+
const result = await passwordLogin(new ecies_lib_1.SecureString(values.password), username, email);
|
|
74
77
|
if ('error' in result) {
|
|
75
78
|
throw new Error(result.error);
|
|
76
79
|
}
|
|
77
80
|
navigate('/dashboard');
|
|
78
81
|
}
|
|
79
82
|
else if (values.mnemonic) {
|
|
80
|
-
const result = await directLogin(new ecies_lib_1.SecureString(values.mnemonic),
|
|
83
|
+
const result = await directLogin(new ecies_lib_1.SecureString(values.mnemonic), username, email);
|
|
81
84
|
if ('error' in result) {
|
|
82
85
|
throw new Error(result.error);
|
|
83
86
|
}
|
|
84
87
|
navigate('/dashboard');
|
|
85
88
|
}
|
|
89
|
+
else {
|
|
90
|
+
throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Error_NoPasswordOrMnemonicProvided);
|
|
91
|
+
}
|
|
86
92
|
};
|
|
87
93
|
return (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onSubmit: handleSubmit });
|
|
88
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
|