@digitaldefiance/express-suite-react-components 2.9.11 → 2.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/components/ApiAccess.d.ts.map +1 -1
- package/src/components/ApiAccess.js +16 -9
- package/src/components/BackupCodeLoginForm.d.ts +2 -2
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -1
- package/src/components/BackupCodeLoginForm.js +62 -29
- package/src/components/BackupCodesForm.d.ts.map +1 -1
- package/src/components/BackupCodesForm.js +29 -17
- package/src/components/ChangePasswordForm.d.ts.map +1 -1
- package/src/components/ChangePasswordForm.js +29 -17
- package/src/components/ExpirationSecondsSelector.d.ts +3 -3
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -1
- package/src/components/ExpirationSecondsSelector.js +1 -1
- package/src/components/Flag.d.ts.map +1 -1
- package/src/components/ForgotPasswordForm.d.ts.map +1 -1
- package/src/components/ForgotPasswordForm.js +16 -9
- package/src/components/LoginForm.d.ts +2 -2
- package/src/components/LoginForm.d.ts.map +1 -1
- package/src/components/LoginForm.js +52 -29
- package/src/components/RegisterForm.d.ts +5 -3
- package/src/components/RegisterForm.d.ts.map +1 -1
- package/src/components/RegisterForm.js +62 -27
- package/src/components/ResetPasswordForm.d.ts.map +1 -1
- package/src/components/ResetPasswordForm.js +25 -15
- package/src/components/TopMenu.d.ts.map +1 -1
- package/src/components/TopMenu.js +2 -3
- package/src/components/TranslatedTitle.d.ts +1 -1
- package/src/components/TranslatedTitle.d.ts.map +1 -1
- package/src/components/TranslatedTitle.js +1 -1
- package/src/components/UserSettingsForm.d.ts +4 -3
- package/src/components/UserSettingsForm.d.ts.map +1 -1
- package/src/components/UserSettingsForm.js +58 -25
- package/src/components/VerifyEmailPage.d.ts.map +1 -1
- package/src/components/VerifyEmailPage.js +20 -11
- package/src/contexts/AuthProvider.d.ts +4 -4
- package/src/contexts/AuthProvider.d.ts.map +1 -1
- package/src/contexts/AuthProvider.js +82 -27
- package/src/contexts/I18nProvider.d.ts.map +1 -1
- package/src/contexts/MenuContext.d.ts +2 -2
- package/src/contexts/MenuContext.d.ts.map +1 -1
- package/src/contexts/MenuContext.js +72 -43
- package/src/hooks/useBackupCodes.d.ts.map +1 -1
- package/src/hooks/useBackupCodes.js +8 -4
- package/src/hooks/useEmailVerification.d.ts.map +1 -1
- package/src/hooks/useEmailVerification.js +8 -4
- package/src/hooks/useUserSettings.d.ts +4 -2
- package/src/hooks/useUserSettings.d.ts.map +1 -1
- package/src/hooks/useUserSettings.js +30 -13
- package/src/services/authService.d.ts.map +1 -1
- package/src/services/authService.js +45 -63
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -1
- package/src/wrappers/BackupCodeLoginWrapper.js +0 -1
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -1
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -1
- package/src/wrappers/RegisterFormWrapper.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.12",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"react-router-dom": "6.29.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@digitaldefiance/i18n-lib": "3.8.
|
|
34
|
-
"@digitaldefiance/suite-core-lib": "3.6.
|
|
33
|
+
"@digitaldefiance/i18n-lib": "3.8.10",
|
|
34
|
+
"@digitaldefiance/suite-core-lib": "3.6.18",
|
|
35
35
|
"@emotion/react": "^11.14.0",
|
|
36
36
|
"@emotion/styled": "^11.14.0",
|
|
37
37
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiAccess.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ApiAccess.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ApiAccess.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ApiAccess.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AA2BrC,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAmHxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ApiAccess = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
7
|
const ContentCopy_1 = tslib_1.__importDefault(require("@mui/icons-material/ContentCopy"));
|
|
7
8
|
const material_1 = require("@mui/material");
|
|
8
9
|
const react_1 = require("react");
|
|
9
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
10
10
|
const contexts_1 = require("../contexts");
|
|
11
11
|
const ApiAccessContainer = (0, material_1.styled)(material_1.Box)(({ theme }) => ({
|
|
12
12
|
display: 'flex',
|
|
@@ -36,13 +36,20 @@ const ApiAccess = ({ token: tokenProp, labels = {}, }) => {
|
|
|
36
36
|
const [dialogOpen, setDialogOpen] = (0, react_1.useState)(false);
|
|
37
37
|
const [isError, setIsError] = (0, react_1.useState)(false);
|
|
38
38
|
const translatedLabels = {
|
|
39
|
-
title: labels.title ||
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
title: labels.title ||
|
|
40
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ApiAccess_Title),
|
|
41
|
+
tokenNotAvailable: labels.tokenNotAvailable ||
|
|
42
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ApiAccess_TokenNotAvailable),
|
|
43
|
+
copyButton: labels.copyButton ||
|
|
44
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CopyToClipboard),
|
|
45
|
+
notificationTitle: labels.notificationTitle ||
|
|
46
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Notification),
|
|
47
|
+
copied: labels.copied ||
|
|
48
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CopiedToClipboard),
|
|
49
|
+
copyFailed: labels.copyFailed ||
|
|
50
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_FailedToCopy),
|
|
51
|
+
ok: labels.ok ||
|
|
52
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_OK),
|
|
46
53
|
};
|
|
47
54
|
const copyToClipboard = async () => {
|
|
48
55
|
if (token) {
|
|
@@ -51,7 +58,7 @@ const ApiAccess = ({ token: tokenProp, labels = {}, }) => {
|
|
|
51
58
|
setIsError(false);
|
|
52
59
|
setDialogOpen(true);
|
|
53
60
|
}
|
|
54
|
-
catch
|
|
61
|
+
catch {
|
|
55
62
|
setIsError(true);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
@@ -18,9 +18,9 @@ export interface BackupCodeLoginFormProps {
|
|
|
18
18
|
error: string;
|
|
19
19
|
status?: number;
|
|
20
20
|
}>;
|
|
21
|
-
onNavigate?: (path: string, state?:
|
|
21
|
+
onNavigate?: (path: string, state?: Record<string, unknown>) => void;
|
|
22
22
|
isAuthenticated?: boolean;
|
|
23
|
-
validationSchema?: Yup.ObjectSchema<
|
|
23
|
+
validationSchema?: Yup.ObjectSchema<BackupCodeLoginFormValues>;
|
|
24
24
|
labels?: {
|
|
25
25
|
title?: string;
|
|
26
26
|
email?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BackupCodeLoginForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodeLoginForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACrE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAC/D,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,CAya5D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BackupCodeLoginForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const formik_1 = require("formik");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
12
|
const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, validationSchema, labels = {}, }) => {
|
|
13
13
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
@@ -17,20 +17,34 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
17
17
|
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
18
18
|
const [codesRemaining, setCodesRemaining] = (0, react_1.useState)(null);
|
|
19
19
|
const translatedLabels = {
|
|
20
|
-
title: labels.title ||
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
title: labels.title ||
|
|
21
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_Title),
|
|
22
|
+
email: labels.email ||
|
|
23
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email),
|
|
24
|
+
username: labels.username ||
|
|
25
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username),
|
|
26
|
+
code: labels.code ||
|
|
27
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_BackupCode),
|
|
28
|
+
newPassword: labels.newPassword ||
|
|
29
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_NewPassword),
|
|
30
|
+
confirmPassword: labels.confirmPassword ||
|
|
31
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword),
|
|
32
|
+
recoverMnemonic: labels.recoverMnemonic ||
|
|
33
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_RecoverMnemonic),
|
|
34
|
+
login: labels.login ||
|
|
35
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_Login),
|
|
36
|
+
useUsername: labels.useUsername ||
|
|
37
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseUsername),
|
|
38
|
+
useEmail: labels.useEmail ||
|
|
39
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_UseEmailAddress),
|
|
40
|
+
dashboard: labels.dashboard ||
|
|
41
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard),
|
|
42
|
+
generateNewCodes: labels.generateNewCodes ||
|
|
43
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes),
|
|
44
|
+
mnemonicLabel: labels.mnemonicLabel ||
|
|
45
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic),
|
|
46
|
+
codesRemaining: labels.codesRemaining ||
|
|
47
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_CodesRemainingTemplate),
|
|
34
48
|
unexpectedError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
|
|
35
49
|
};
|
|
36
50
|
const yupFieldValidation = {
|
|
@@ -43,10 +57,8 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
43
57
|
code: Yup.string()
|
|
44
58
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
45
59
|
.matches(suite_core_lib_1.Constants.BACKUP_CODES.DisplayRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidBackupCode)),
|
|
46
|
-
password: Yup.string()
|
|
47
|
-
|
|
48
|
-
confirmPassword: Yup.string()
|
|
49
|
-
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch)),
|
|
60
|
+
password: Yup.string().matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate)),
|
|
61
|
+
confirmPassword: Yup.string().oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch)),
|
|
50
62
|
};
|
|
51
63
|
const formik = (0, formik_1.useFormik)({
|
|
52
64
|
initialValues: {
|
|
@@ -57,16 +69,21 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
57
69
|
confirmNewPassword: '',
|
|
58
70
|
recoverMnemonic: false,
|
|
59
71
|
},
|
|
60
|
-
validationSchema: validationSchema ??
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
validationSchema: validationSchema ??
|
|
73
|
+
Yup.object({
|
|
74
|
+
[loginType]: loginType === 'email'
|
|
75
|
+
? yupFieldValidation.email
|
|
76
|
+
: yupFieldValidation.username,
|
|
77
|
+
code: yupFieldValidation.code,
|
|
78
|
+
newPassword: yupFieldValidation.password,
|
|
79
|
+
confirmNewPassword: yupFieldValidation.confirmPassword,
|
|
80
|
+
}),
|
|
66
81
|
enableReinitialize: true,
|
|
67
82
|
onSubmit: async (values, { setSubmitting }) => {
|
|
68
83
|
try {
|
|
69
|
-
const loginResult = await onSubmit(loginType === 'email' ? values.email : values.username, values.code, loginType === 'email', values.recoverMnemonic, values.newPassword && values.newPassword.length > 0
|
|
84
|
+
const loginResult = await onSubmit(loginType === 'email' ? values.email : values.username, values.code, loginType === 'email', values.recoverMnemonic, values.newPassword && values.newPassword.length > 0
|
|
85
|
+
? values.newPassword
|
|
86
|
+
: undefined);
|
|
70
87
|
if ('error' in loginResult) {
|
|
71
88
|
setLoginError(loginResult.error);
|
|
72
89
|
setCodesRemaining(null);
|
|
@@ -92,15 +109,31 @@ const BackupCodeLoginForm = ({ onSubmit, onNavigate, isAuthenticated = false, va
|
|
|
92
109
|
}
|
|
93
110
|
},
|
|
94
111
|
});
|
|
95
|
-
if (isAuthenticated &&
|
|
112
|
+
if (isAuthenticated &&
|
|
113
|
+
recoveredMnemonic === null &&
|
|
114
|
+
codesRemaining === null) {
|
|
96
115
|
onNavigate?.('/dashboard');
|
|
97
116
|
return null;
|
|
98
117
|
}
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
118
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
119
|
+
marginTop: 8,
|
|
120
|
+
display: 'flex',
|
|
121
|
+
flexDirection: 'column',
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
}, 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'
|
|
124
|
+
? translatedLabels.email
|
|
125
|
+
: translatedLabels.username, name: loginType, autoComplete: loginType === 'email' ? 'email' : 'username', autoFocus: true, value: loginType === 'email'
|
|
126
|
+
? formik.values.email
|
|
127
|
+
: 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 &&
|
|
128
|
+
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 &&
|
|
129
|
+
Boolean(formik.errors.confirmNewPassword), helperText: formik.touched.confirmNewPassword &&
|
|
130
|
+
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
131
|
const newType = loginType === 'email' ? 'username' : 'email';
|
|
101
132
|
formik.setFieldValue(loginType, '');
|
|
102
133
|
setLoginType(newType);
|
|
103
|
-
}, children: loginType === 'email'
|
|
134
|
+
}, children: loginType === 'email'
|
|
135
|
+
? translatedLabels.useUsername
|
|
136
|
+
: translatedLabels.useEmail }) })] }))] })] }) }));
|
|
104
137
|
};
|
|
105
138
|
exports.BackupCodeLoginForm = BackupCodeLoginForm;
|
|
106
139
|
exports.default = exports.BackupCodeLoginForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupCodesForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodesForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BackupCodesForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/BackupCodesForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC;QACnD,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC,CAAC;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAkPpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -3,33 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BackupCodesForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const formik_1 = require("formik");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
12
|
const BackupCodesForm = ({ onSubmit, backupCodesRemaining = null, mnemonicValidation, passwordValidation, labels = {}, }) => {
|
|
13
|
-
const {
|
|
13
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
14
|
const [apiError, setApiError] = (0, react_1.useState)(null);
|
|
15
15
|
const [apiSuccess, setApiSuccess] = (0, react_1.useState)(null);
|
|
16
16
|
const [backupCodes, setBackupCodes] = (0, react_1.useState)(null);
|
|
17
17
|
const validation = {
|
|
18
|
-
mnemonic: mnemonicValidation ||
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
18
|
+
mnemonic: mnemonicValidation ||
|
|
19
|
+
Yup.string()
|
|
20
|
+
.trim()
|
|
21
|
+
.matches(suite_core_lib_1.Constants.MnemonicRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicRegex))
|
|
22
|
+
.optional(),
|
|
23
|
+
password: passwordValidation ||
|
|
24
|
+
Yup.string()
|
|
25
|
+
.trim()
|
|
26
|
+
.matches(suite_core_lib_1.Constants.PasswordRegex, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate))
|
|
27
|
+
.optional(),
|
|
26
28
|
};
|
|
27
29
|
const translatedLabels = {
|
|
28
|
-
codesRemaining: labels.codesRemaining ||
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
codesRemaining: labels.codesRemaining ||
|
|
31
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_CodesRemainingTemplate),
|
|
32
|
+
mnemonic: labels.mnemonic ||
|
|
33
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Mnemonic),
|
|
34
|
+
password: labels.password ||
|
|
35
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password),
|
|
36
|
+
generateButton: labels.generateButton ||
|
|
37
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes),
|
|
38
|
+
successTitle: labels.successTitle ||
|
|
39
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.BackupCodeRecovery_YourNewCodes),
|
|
33
40
|
xorError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_MnemonicOrPasswordRequired),
|
|
34
41
|
unexpectedError: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
|
|
35
42
|
};
|
|
@@ -95,14 +102,19 @@ const BackupCodesForm = ({ onSubmit, backupCodesRemaining = null, mnemonicValida
|
|
|
95
102
|
}
|
|
96
103
|
catch (e) {
|
|
97
104
|
setApiSuccess(null);
|
|
98
|
-
|
|
105
|
+
const error = e;
|
|
106
|
+
setApiError(error.response?.data?.message ?? translatedLabels.unexpectedError);
|
|
99
107
|
}
|
|
100
108
|
finally {
|
|
101
109
|
setSubmitting(false);
|
|
102
110
|
}
|
|
103
111
|
},
|
|
104
112
|
});
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Container, { component: "main", maxWidth: "xs", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: translatedLabels.codesRemaining.replace('{count}', String(backupCodesRemaining ?? 0)) }) }), (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: "mnemonic", label: translatedLabels.mnemonic, type: "password", name: "mnemonic", autoComplete: "mnemonic", autoFocus: true, value: formik.values.mnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.mnemonic || formik.submitCount > 0) &&
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Container, { component: "main", maxWidth: "xs", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: translatedLabels.codesRemaining.replace('{count}', String(backupCodesRemaining ?? 0)) }) }), (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: "mnemonic", label: translatedLabels.mnemonic, type: "password", name: "mnemonic", autoComplete: "mnemonic", autoFocus: true, value: formik.values.mnemonic, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.mnemonic || formik.submitCount > 0) &&
|
|
114
|
+
Boolean(formik.errors.mnemonic), helperText: (formik.touched.mnemonic || formik.submitCount > 0) &&
|
|
115
|
+
formik.errors.mnemonic }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, name: "password", label: translatedLabels.password, type: "password", id: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.password || formik.submitCount > 0) &&
|
|
116
|
+
Boolean(formik.errors.password), helperText: (formik.touched.password || formik.submitCount > 0) &&
|
|
117
|
+
formik.errors.password }), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 2 }, children: translatedLabels.generateButton })] }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), backupCodes && apiSuccess && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", variant: "h6", children: apiSuccess }), (0, jsx_runtime_1.jsx)("ul", { children: backupCodes.map((code, index) => ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("pre", { children: code }) }, index))) })] }))] }));
|
|
106
118
|
};
|
|
107
119
|
exports.BackupCodesForm = BackupCodesForm;
|
|
108
120
|
exports.default = exports.BackupCodesForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangePasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ChangePasswordForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChangePasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ChangePasswordForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,CACR,MAAM,EAAE,wBAAwB,KAC7B,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,qBAAqB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACzC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;CAC9C;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAqO1D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -3,33 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ChangePasswordForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const formik_1 = require("formik");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
12
|
const ChangePasswordForm = ({ onSubmit, titleText, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, submitButtonText, submittingButtonText, successMessage, currentPasswordValidation, newPasswordValidation, confirmPasswordValidation, }) => {
|
|
13
|
-
const {
|
|
13
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
14
|
const [success, setSuccess] = (0, react_1.useState)(false);
|
|
15
15
|
const [apiError, setApiError] = (0, react_1.useState)('');
|
|
16
16
|
const validation = {
|
|
17
|
-
currentPassword: currentPasswordValidation ||
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
currentPassword: currentPasswordValidation ||
|
|
18
|
+
Yup.string().required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
19
|
+
newPassword: newPasswordValidation ||
|
|
20
|
+
Yup.string()
|
|
21
|
+
.min(suite_core_lib_1.Constants.PasswordMinLength, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMinLengthTemplate))
|
|
22
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
23
|
+
confirmPassword: confirmPasswordValidation ||
|
|
24
|
+
Yup.string()
|
|
25
|
+
.oneOf([Yup.ref('newPassword')], tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_PasswordMatch))
|
|
26
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
24
27
|
};
|
|
25
28
|
const labels = {
|
|
26
|
-
title: titleText ||
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
title: titleText ||
|
|
30
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangePassword),
|
|
31
|
+
currentPassword: currentPasswordLabel ||
|
|
32
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CurrentPassword),
|
|
33
|
+
newPassword: newPasswordLabel ||
|
|
34
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_NewPassword),
|
|
35
|
+
confirmPassword: confirmPasswordLabel ||
|
|
36
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword),
|
|
37
|
+
submitButton: submitButtonText ||
|
|
38
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangePassword),
|
|
39
|
+
submittingButton: submittingButtonText ||
|
|
40
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ChangingPassword),
|
|
41
|
+
success: successMessage ||
|
|
42
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordChange_Success),
|
|
33
43
|
};
|
|
34
44
|
const formik = (0, formik_1.useFormik)({
|
|
35
45
|
initialValues: {
|
|
@@ -60,7 +70,9 @@ const ChangePasswordForm = ({ onSubmit, titleText, currentPasswordLabel, newPass
|
|
|
60
70
|
display: 'flex',
|
|
61
71
|
flexDirection: 'column',
|
|
62
72
|
alignItems: 'center',
|
|
63
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, 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, { fullWidth: true, id: "currentPassword", name: "currentPassword", label: labels.currentPassword, type: "password", value: formik.values.currentPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.currentPassword && formik.errors.currentPassword), helperText: formik.touched.currentPassword && formik.errors.currentPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "newPassword", name: "newPassword", label: labels.newPassword, type: "password", value: formik.values.newPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.newPassword && formik.errors.newPassword), helperText: formik.touched.newPassword && formik.errors.newPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword, 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" }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), success && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.success })), (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: formik.isSubmitting
|
|
73
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, 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, { fullWidth: true, id: "currentPassword", name: "currentPassword", label: labels.currentPassword, type: "password", value: formik.values.currentPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.currentPassword && formik.errors.currentPassword), helperText: formik.touched.currentPassword && formik.errors.currentPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "newPassword", name: "newPassword", label: labels.newPassword, type: "password", value: formik.values.newPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.newPassword && formik.errors.newPassword), helperText: formik.touched.newPassword && formik.errors.newPassword, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword, 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" }), apiError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiError })), success && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.success })), (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: formik.isSubmitting
|
|
74
|
+
? labels.submittingButton
|
|
75
|
+
: labels.submitButton })] })] }) }));
|
|
64
76
|
};
|
|
65
77
|
exports.ChangePasswordForm = ChangePasswordForm;
|
|
66
78
|
exports.default = exports.ChangePasswordForm;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FormikProps } from 'formik';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
export interface ExpirationSecondsSelectorProps {
|
|
3
|
+
export interface ExpirationSecondsSelectorProps<T = Record<string, unknown>> {
|
|
4
4
|
name: string;
|
|
5
5
|
label: string;
|
|
6
|
-
formik: FormikProps<
|
|
6
|
+
formik: FormikProps<T>;
|
|
7
7
|
optionValues: number[];
|
|
8
8
|
optionNames: string[];
|
|
9
9
|
onChange?: (value: number) => void;
|
|
10
10
|
}
|
|
11
|
-
export declare const ExpirationSecondsSelector: FC<ExpirationSecondsSelectorProps
|
|
11
|
+
export declare const ExpirationSecondsSelector: FC<ExpirationSecondsSelectorProps<Record<string, unknown>>>;
|
|
12
12
|
export default ExpirationSecondsSelector;
|
|
13
13
|
//# sourceMappingURL=ExpirationSecondsSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpirationSecondsSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ExpirationSecondsSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,8BAA8B;
|
|
1
|
+
{"version":3,"file":"ExpirationSecondsSelector.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ExpirationSecondsSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,WAAW,8BAA8B,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,yBAAyB,EAAE,EAAE,CACxC,8BAA8B,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2CxD,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExpirationSecondsSelector = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
-
const ExpirationSecondsSelector = ({ name, label, formik, optionValues, optionNames, onChange
|
|
6
|
+
const ExpirationSecondsSelector = ({ name, label, formik, optionValues, optionNames, onChange }) => {
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { select: true, fullWidth: true, label: label, name: name, value: formik.values[name] ?? '', onChange: (event) => {
|
|
8
8
|
const selectedValue = event.target.value;
|
|
9
9
|
formik.setFieldValue(name, selectedValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flag.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/Flag.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Flag.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/Flag.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA6B9B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ForgotPasswordForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CA0I1D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -3,26 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ForgotPasswordForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const formik_1 = require("formik");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
-
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
12
|
const ForgotPasswordForm = ({ onSubmit, emailValidation, labels = {}, }) => {
|
|
13
13
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
14
|
const [success, setSuccess] = (0, react_1.useState)(false);
|
|
15
15
|
const [apiError, setApiError] = (0, react_1.useState)('');
|
|
16
16
|
const validation = {
|
|
17
|
-
email: emailValidation ||
|
|
18
|
-
.
|
|
19
|
-
|
|
17
|
+
email: emailValidation ||
|
|
18
|
+
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)),
|
|
20
21
|
};
|
|
21
22
|
const translatedLabels = {
|
|
22
|
-
title: labels.title ||
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
title: labels.title ||
|
|
24
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_Title),
|
|
25
|
+
email: labels.email ||
|
|
26
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email),
|
|
27
|
+
sendResetLink: labels.sendResetLink ||
|
|
28
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_SendResetLink),
|
|
29
|
+
successMessage: labels.successMessage ||
|
|
30
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordReset_Success),
|
|
26
31
|
};
|
|
27
32
|
const formik = (0, formik_1.useFormik)({
|
|
28
33
|
initialValues: {
|
|
@@ -38,7 +43,9 @@ const ForgotPasswordForm = ({ onSubmit, emailValidation, labels = {}, }) => {
|
|
|
38
43
|
setApiError('');
|
|
39
44
|
}
|
|
40
45
|
catch (error) {
|
|
41
|
-
|
|
46
|
+
const err = error;
|
|
47
|
+
setApiError(err.response?.data?.message ||
|
|
48
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ForgotPassword_Error));
|
|
42
49
|
setSuccess(false);
|
|
43
50
|
}
|
|
44
51
|
},
|
|
@@ -6,7 +6,7 @@ export interface LoginFormValues {
|
|
|
6
6
|
username?: string;
|
|
7
7
|
password?: string;
|
|
8
8
|
mnemonic?: string;
|
|
9
|
-
[key: string]:
|
|
9
|
+
[key: string]: string | boolean | undefined;
|
|
10
10
|
}
|
|
11
11
|
export interface LoginFormProps {
|
|
12
12
|
onSubmit: (values: LoginFormValues) => Promise<void>;
|
|
@@ -36,7 +36,7 @@ export interface LoginFormProps {
|
|
|
36
36
|
passwordValidation?: Yup.StringSchema;
|
|
37
37
|
mnemonicValidation?: Yup.StringSchema;
|
|
38
38
|
additionalFields?: (formik: ReturnType<typeof useFormik<LoginFormValues>>) => React.ReactNode;
|
|
39
|
-
additionalInitialValues?: Record<string,
|
|
39
|
+
additionalInitialValues?: Record<string, string | boolean>;
|
|
40
40
|
additionalValidation?: Record<string, Yup.Schema>;
|
|
41
41
|
}
|
|
42
42
|
export declare const LoginForm: FC<LoginFormProps>;
|
|
@@ -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":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,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,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC7C;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,CACjB,MAAM,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,eAAe,CAAC,CAAC,KAClD,KAAK,CAAC,SAAS,CAAC;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC3D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAoYxC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|