@digitaldefiance/express-suite-react-components 4.26.26 → 4.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/components/RegisterForm.d.ts +31 -0
- package/src/components/RegisterForm.d.ts.map +1 -1
- package/src/components/RegisterForm.js +98 -24
- package/src/components/TotpSetupForm.d.ts +24 -0
- package/src/components/TotpSetupForm.d.ts.map +1 -0
- package/src/components/TotpSetupForm.js +82 -0
- package/src/components/TotpVerificationForm.d.ts +23 -0
- package/src/components/TotpVerificationForm.d.ts.map +1 -0
- package/src/components/TotpVerificationForm.js +66 -0
- package/src/components/UserSettingsForm.d.ts +53 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -1
- package/src/components/UserSettingsForm.js +128 -2
- package/src/components/index.d.ts +2 -0
- package/src/components/index.d.ts.map +1 -1
- package/src/components/index.js +2 -0
- package/src/contexts/AuthProvider.d.ts +33 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -1
- package/src/contexts/AuthProvider.js +3 -0
- package/src/services/authService.d.ts +32 -0
- package/src/services/authService.d.ts.map +1 -1
- package/src/services/authService.js +116 -0
- package/src/wrappers/LoginFormWrapper.d.ts +12 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -1
- package/src/wrappers/LoginFormWrapper.js +36 -9
- package/src/wrappers/RegisterFormWrapper.d.ts +6 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -1
- package/src/wrappers/RegisterFormWrapper.js +10 -3
- package/src/wrappers/UserSettingsFormWrapper.d.ts +21 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -1
- package/src/wrappers/UserSettingsFormWrapper.js +67 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.1",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"currency-codes": "^2.2.0",
|
|
44
44
|
"formik": "^2.4.6",
|
|
45
45
|
"moment-timezone": "^0.6.0",
|
|
46
|
+
"qrcode.react": "^4.2.0",
|
|
46
47
|
"react-number-format": "^5.4.4",
|
|
47
48
|
"yup": "^1.6.1"
|
|
48
49
|
},
|
|
@@ -34,6 +34,33 @@ export interface RegisterFormProps {
|
|
|
34
34
|
timezoneValidation?: Yup.StringSchema;
|
|
35
35
|
passwordValidation?: Yup.StringSchema;
|
|
36
36
|
confirmPasswordValidation?: Yup.StringSchema;
|
|
37
|
+
/**
|
|
38
|
+
* When true, display a TOTP setup step after successful registration.
|
|
39
|
+
* Defaults to false. When false or not provided, existing flow is unchanged.
|
|
40
|
+
*/
|
|
41
|
+
enableTotpSetup?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Called to initiate TOTP setup (e.g. AuthService.setupTotp()).
|
|
44
|
+
* Must return provisioning URI and secret on success, or an error.
|
|
45
|
+
*/
|
|
46
|
+
onTotpSetup?: () => Promise<{
|
|
47
|
+
provisioningUri: string;
|
|
48
|
+
secret: string;
|
|
49
|
+
} | {
|
|
50
|
+
error: string;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Called to confirm TOTP setup with a 6-digit code (e.g. AuthService.confirmTotp()).
|
|
54
|
+
*/
|
|
55
|
+
onTotpConfirm?: (code: string) => Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
} | {
|
|
58
|
+
error: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Called after the user successfully confirms TOTP during the registration flow.
|
|
62
|
+
*/
|
|
63
|
+
onTotpSetupComplete?: () => void;
|
|
37
64
|
/**
|
|
38
65
|
* List of email domains that are not allowed during registration.
|
|
39
66
|
* For example, the home system's email domain should be disallowed
|
|
@@ -61,6 +88,10 @@ export interface RegisterFormProps {
|
|
|
61
88
|
savedRecoveryPhrase?: string;
|
|
62
89
|
loginLink?: string;
|
|
63
90
|
mnemonic?: string;
|
|
91
|
+
totpSetupTitle?: string;
|
|
92
|
+
totpSkipButton?: string;
|
|
93
|
+
totpSetupError?: string;
|
|
94
|
+
totpSetupSuccess?: string;
|
|
64
95
|
};
|
|
65
96
|
}
|
|
66
97
|
export declare const RegisterForm: FC<RegisterFormProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CACR,MAAM,EAAE,kBAAkB,EAC1B,W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AC"}
|
|
@@ -9,7 +9,8 @@ const formik_1 = require("formik");
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
11
|
const contexts_1 = require("../contexts");
|
|
12
|
-
const
|
|
12
|
+
const TotpSetupForm_1 = require("./TotpSetupForm");
|
|
13
|
+
const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidation, emailValidation, displayNameValidation, timezoneValidation, passwordValidation, confirmPasswordValidation, enableTotpSetup = false, onTotpSetup, onTotpConfirm, onTotpSetupComplete, disallowedEmailDomains, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
13
14
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
15
|
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
15
16
|
const [mnemonic, setMnemonic] = (0, react_1.useState)(null);
|
|
@@ -17,6 +18,51 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
|
|
|
17
18
|
const [registrationSuccess, setRegistrationSuccess] = (0, react_1.useState)(false);
|
|
18
19
|
const [registering, setRegistering] = (0, react_1.useState)(false);
|
|
19
20
|
const [showMnemonicInput, setShowMnemonicInput] = (0, react_1.useState)(false);
|
|
21
|
+
const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
|
|
22
|
+
const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
|
|
23
|
+
const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
|
|
24
|
+
const [totpSetupError, setTotpSetupError] = (0, react_1.useState)(null);
|
|
25
|
+
const [totpSetupComplete, setTotpSetupComplete] = (0, react_1.useState)(false);
|
|
26
|
+
const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
|
|
27
|
+
const initiateTotpSetup = (0, react_1.useCallback)(async () => {
|
|
28
|
+
if (!onTotpSetup)
|
|
29
|
+
return;
|
|
30
|
+
setTotpSetupLoading(true);
|
|
31
|
+
setTotpSetupError(null);
|
|
32
|
+
try {
|
|
33
|
+
const result = await onTotpSetup();
|
|
34
|
+
if ('error' in result) {
|
|
35
|
+
setTotpSetupError(result.error);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
setTotpProvisioningUri(result.provisioningUri);
|
|
39
|
+
setTotpSecret(result.secret);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
setTotpSetupError(labels.totpSetupError || 'Failed to set up two-factor authentication');
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setTotpSetupLoading(false);
|
|
47
|
+
}
|
|
48
|
+
}, [onTotpSetup, labels.totpSetupError]);
|
|
49
|
+
const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
|
|
50
|
+
if (!onTotpConfirm) {
|
|
51
|
+
return { error: 'TOTP confirmation is not available' };
|
|
52
|
+
}
|
|
53
|
+
const result = await onTotpConfirm(code);
|
|
54
|
+
if ('success' in result && result.success) {
|
|
55
|
+
setTotpSetupComplete(true);
|
|
56
|
+
setShowTotpSetup(false);
|
|
57
|
+
if (onTotpSetupComplete) {
|
|
58
|
+
onTotpSetupComplete();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}, [onTotpConfirm, onTotpSetupComplete]);
|
|
63
|
+
const handleSkipTotp = (0, react_1.useCallback)(() => {
|
|
64
|
+
setShowTotpSetup(false);
|
|
65
|
+
}, []);
|
|
20
66
|
const validation = {
|
|
21
67
|
username: usernameValidation ||
|
|
22
68
|
Yup.string()
|
|
@@ -109,6 +155,12 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
|
|
|
109
155
|
if (registerResult.mnemonic) {
|
|
110
156
|
setMnemonic(registerResult.mnemonic);
|
|
111
157
|
}
|
|
158
|
+
if (enableTotpSetup && onTotpSetup) {
|
|
159
|
+
setShowTotpSetup(true);
|
|
160
|
+
// Fire-and-forget: initiate TOTP setup in background
|
|
161
|
+
// The setup state is managed by initiateTotpSetup
|
|
162
|
+
initiateTotpSetup();
|
|
163
|
+
}
|
|
112
164
|
}
|
|
113
165
|
else {
|
|
114
166
|
setRegistrationSuccess(false);
|
|
@@ -149,29 +201,51 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
|
|
|
149
201
|
flexDirection: 'column',
|
|
150
202
|
alignItems: 'center',
|
|
151
203
|
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title ||
|
|
152
|
-
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), (mnemonic || registrationSuccess) ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, width: '100%' }, children: mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
204
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), (mnemonic || registrationSuccess) ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, width: '100%' }, children: showTotpSetup && !totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", sx: { textAlign: 'center' }, children: labels.totpSetupTitle || 'Set Up Two-Factor Authentication' }), totpSetupLoading && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { textAlign: 'center', mt: 2 }, children: "Loading TOTP setup..." })), totpSetupError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: totpSetupError })), totpProvisioningUri && totpSecret && ((0, jsx_runtime_1.jsx)(TotpSetupForm_1.TotpSetupForm, { provisioningUri: totpProvisioningUri, secret: totpSecret, onConfirm: handleTotpConfirm })), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleSkipTotp, "data-testid": "skip-totp-button", children: labels.totpSkipButton || 'Skip' }) })] })) : totpSetupComplete ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: labels.totpSetupSuccess || 'Two-factor authentication has been enabled successfully.' }), mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
205
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
206
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
207
|
+
display: 'grid',
|
|
208
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
209
|
+
gap: 1.5,
|
|
210
|
+
mb: 3,
|
|
211
|
+
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
212
|
+
display: 'flex',
|
|
213
|
+
alignItems: 'center',
|
|
214
|
+
justifyContent: 'center',
|
|
215
|
+
gap: 0.5,
|
|
216
|
+
py: 1,
|
|
217
|
+
px: 1.5,
|
|
218
|
+
borderRadius: 2,
|
|
219
|
+
border: '1px solid',
|
|
220
|
+
borderColor: 'divider',
|
|
221
|
+
bgcolor: 'action.hover',
|
|
222
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
223
|
+
labels.proceedToLogin ||
|
|
224
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
225
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
226
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] }))] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: mnemonic ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'center', mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", component: "h2", gutterBottom: true, fontWeight: "bold", children: labels.successTitle ||
|
|
227
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: labels.mnemonicSuccess ||
|
|
228
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
229
|
+
display: 'grid',
|
|
230
|
+
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
231
|
+
gap: 1.5,
|
|
232
|
+
mb: 3,
|
|
233
|
+
}, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
234
|
+
display: 'flex',
|
|
235
|
+
alignItems: 'center',
|
|
236
|
+
justifyContent: 'center',
|
|
237
|
+
gap: 0.5,
|
|
238
|
+
py: 1,
|
|
239
|
+
px: 1.5,
|
|
240
|
+
borderRadius: 2,
|
|
241
|
+
border: '1px solid',
|
|
242
|
+
borderColor: 'divider',
|
|
243
|
+
bgcolor: 'action.hover',
|
|
244
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { minWidth: '1.5em', textAlign: 'right' }, children: [i + 1, "."] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "bold", children: word })] }, i))) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", size: "large", href: "/verify-email", sx: { borderRadius: 6, px: 4 }, children: labels.savedRecoveryPhrase ||
|
|
245
|
+
labels.proceedToLogin ||
|
|
246
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SavedRecoveryPhrase) }) }), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success) })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle ||
|
|
247
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center', mt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin ||
|
|
248
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })) })) })) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "username", name: "username", label: labels.username ||
|
|
175
249
|
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username), value: formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.username &&
|
|
176
250
|
(formik.errors.username || apiErrors.username)), helperText: formik.touched.username &&
|
|
177
251
|
(formik.errors.username || apiErrors.username), margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email ||
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface TotpSetupFormValues {
|
|
3
|
+
code: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TotpSetupFormProps {
|
|
6
|
+
provisioningUri: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
onConfirm: (code: string) => Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
error: string;
|
|
12
|
+
}>;
|
|
13
|
+
labels?: {
|
|
14
|
+
title?: string;
|
|
15
|
+
qrCodeAlt?: string;
|
|
16
|
+
secretLabel?: string;
|
|
17
|
+
codeLabel?: string;
|
|
18
|
+
confirmButton?: string;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const TotpSetupForm: FC<TotpSetupFormProps>;
|
|
23
|
+
export default TotpSetupForm;
|
|
24
|
+
//# sourceMappingURL=TotpSetupForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotpSetupForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TotpSetupForm.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAGrC,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CACT,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAiBD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA+IhD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TotpSetupForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const qrcode_react_1 = require("qrcode.react");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
11
|
+
const defaultLabels = {
|
|
12
|
+
title: 'Set Up Two-Factor Authentication',
|
|
13
|
+
qrCodeAlt: 'QR code for TOTP authenticator app setup',
|
|
14
|
+
secretLabel: 'Manual entry key',
|
|
15
|
+
codeLabel: 'Confirmation code',
|
|
16
|
+
confirmButton: 'Confirm',
|
|
17
|
+
errorMessage: 'An unexpected error occurred',
|
|
18
|
+
};
|
|
19
|
+
const totpCodeSchema = Yup.object({
|
|
20
|
+
code: Yup.string()
|
|
21
|
+
.required('Confirmation code is required')
|
|
22
|
+
.matches(/^\d{6}$/, 'Code must be exactly 6 digits'),
|
|
23
|
+
});
|
|
24
|
+
const TotpSetupForm = ({ provisioningUri, secret, onConfirm, labels = {}, }) => {
|
|
25
|
+
const [confirmError, setConfirmError] = (0, react_1.useState)(null);
|
|
26
|
+
const resolvedLabels = {
|
|
27
|
+
title: labels.title ?? defaultLabels.title,
|
|
28
|
+
qrCodeAlt: labels.qrCodeAlt ?? defaultLabels.qrCodeAlt,
|
|
29
|
+
secretLabel: labels.secretLabel ?? defaultLabels.secretLabel,
|
|
30
|
+
codeLabel: labels.codeLabel ?? defaultLabels.codeLabel,
|
|
31
|
+
confirmButton: labels.confirmButton ?? defaultLabels.confirmButton,
|
|
32
|
+
errorMessage: labels.errorMessage ?? defaultLabels.errorMessage,
|
|
33
|
+
};
|
|
34
|
+
const formik = (0, formik_1.useFormik)({
|
|
35
|
+
initialValues: {
|
|
36
|
+
code: '',
|
|
37
|
+
},
|
|
38
|
+
validationSchema: totpCodeSchema,
|
|
39
|
+
onSubmit: async (values, { setSubmitting }) => {
|
|
40
|
+
try {
|
|
41
|
+
setConfirmError(null);
|
|
42
|
+
const result = await onConfirm(values.code);
|
|
43
|
+
if ('error' in result) {
|
|
44
|
+
setConfirmError(result.error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
setConfirmError(resolvedLabels.errorMessage);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
setSubmitting(false);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const errorId = 'totp-setup-error';
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
57
|
+
marginTop: 8,
|
|
58
|
+
display: 'flex',
|
|
59
|
+
flexDirection: 'column',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: resolvedLabels.title }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 3, display: 'flex', justifyContent: 'center' }, children: (0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: provisioningUri, size: 200, role: "img", "aria-label": resolvedLabels.qrCodeAlt }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
62
|
+
mt: 2,
|
|
63
|
+
p: 2,
|
|
64
|
+
bgcolor: 'grey.100',
|
|
65
|
+
borderRadius: 1,
|
|
66
|
+
width: '100%',
|
|
67
|
+
textAlign: 'center',
|
|
68
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: resolvedLabels.secretLabel }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: {
|
|
69
|
+
fontFamily: 'monospace',
|
|
70
|
+
wordBreak: 'break-all',
|
|
71
|
+
userSelect: 'all',
|
|
72
|
+
}, children: secret })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 2, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "code", name: "code", label: resolvedLabels.codeLabel, inputProps: {
|
|
73
|
+
'aria-label': resolvedLabels.codeLabel,
|
|
74
|
+
inputMode: 'numeric',
|
|
75
|
+
maxLength: 6,
|
|
76
|
+
pattern: '\\d{6}',
|
|
77
|
+
...(confirmError ? { 'aria-describedby': errorId } : {}),
|
|
78
|
+
}, autoComplete: "one-time-code", autoFocus: true, value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.code && Boolean(formik.errors.code)) ||
|
|
79
|
+
Boolean(confirmError), helperText: formik.touched.code && formik.errors.code }), confirmError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { id: errorId, color: "error", variant: "body2", sx: { mt: 1 }, role: "alert", children: confirmError })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: resolvedLabels.confirmButton })] })] }) }));
|
|
80
|
+
};
|
|
81
|
+
exports.TotpSetupForm = TotpSetupForm;
|
|
82
|
+
exports.default = exports.TotpSetupForm;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IRequestUserDTO } from '@digitaldefiance/suite-core-lib';
|
|
3
|
+
export interface TotpVerificationFormValues {
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TotpVerificationFormProps {
|
|
7
|
+
pendingTotpToken: string;
|
|
8
|
+
onSubmit: (code: string, pendingTotpToken: string) => Promise<{
|
|
9
|
+
token: string;
|
|
10
|
+
user: IRequestUserDTO;
|
|
11
|
+
} | {
|
|
12
|
+
error: string;
|
|
13
|
+
}>;
|
|
14
|
+
labels?: {
|
|
15
|
+
title?: string;
|
|
16
|
+
codeLabel?: string;
|
|
17
|
+
submitButton?: string;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare const TotpVerificationForm: FC<TotpVerificationFormProps>;
|
|
22
|
+
export default TotpVerificationForm;
|
|
23
|
+
//# sourceMappingURL=TotpVerificationForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TotpVerificationForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/TotpVerificationForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,KACrB,OAAO,CACV;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAC7D,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAeD,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA0G9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TotpVerificationForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
+
const defaultLabels = {
|
|
11
|
+
title: 'Two-Factor Authentication',
|
|
12
|
+
codeLabel: 'Authentication code',
|
|
13
|
+
submitButton: 'Verify',
|
|
14
|
+
errorMessage: 'An unexpected error occurred',
|
|
15
|
+
};
|
|
16
|
+
const totpCodeSchema = Yup.object({
|
|
17
|
+
code: Yup.string()
|
|
18
|
+
.required('Authentication code is required')
|
|
19
|
+
.matches(/^\d{6}$/, 'Code must be exactly 6 digits'),
|
|
20
|
+
});
|
|
21
|
+
const TotpVerificationForm = ({ pendingTotpToken, onSubmit, labels = {}, }) => {
|
|
22
|
+
const [submitError, setSubmitError] = (0, react_1.useState)(null);
|
|
23
|
+
const resolvedLabels = {
|
|
24
|
+
title: labels.title ?? defaultLabels.title,
|
|
25
|
+
codeLabel: labels.codeLabel ?? defaultLabels.codeLabel,
|
|
26
|
+
submitButton: labels.submitButton ?? defaultLabels.submitButton,
|
|
27
|
+
errorMessage: labels.errorMessage ?? defaultLabels.errorMessage,
|
|
28
|
+
};
|
|
29
|
+
const formik = (0, formik_1.useFormik)({
|
|
30
|
+
initialValues: {
|
|
31
|
+
code: '',
|
|
32
|
+
},
|
|
33
|
+
validationSchema: totpCodeSchema,
|
|
34
|
+
onSubmit: async (values, { setSubmitting }) => {
|
|
35
|
+
try {
|
|
36
|
+
setSubmitError(null);
|
|
37
|
+
const result = await onSubmit(values.code, pendingTotpToken);
|
|
38
|
+
if ('error' in result) {
|
|
39
|
+
setSubmitError(result.error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
setSubmitError(resolvedLabels.errorMessage);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setSubmitting(false);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const errorId = 'totp-verification-error';
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { component: "main", maxWidth: "xs", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
52
|
+
marginTop: 8,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", variant: "h5", children: resolvedLabels.title }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 2, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "code", name: "code", label: resolvedLabels.codeLabel, inputProps: {
|
|
57
|
+
'aria-label': resolvedLabels.codeLabel,
|
|
58
|
+
inputMode: 'numeric',
|
|
59
|
+
maxLength: 6,
|
|
60
|
+
pattern: '\\d{6}',
|
|
61
|
+
...(submitError ? { 'aria-describedby': errorId } : {}),
|
|
62
|
+
}, autoComplete: "one-time-code", autoFocus: true, value: formik.values.code, onChange: formik.handleChange, onBlur: formik.handleBlur, error: (formik.touched.code && Boolean(formik.errors.code)) ||
|
|
63
|
+
Boolean(submitError), helperText: formik.touched.code && formik.errors.code }), submitError && ((0, jsx_runtime_1.jsx)(material_1.Typography, { id: errorId, color: "error", variant: "body2", sx: { mt: 1 }, role: "alert", children: submitError })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: resolvedLabels.submitButton })] })] }) }));
|
|
64
|
+
};
|
|
65
|
+
exports.TotpVerificationForm = TotpVerificationForm;
|
|
66
|
+
exports.default = exports.TotpVerificationForm;
|
|
@@ -39,6 +39,47 @@ export interface UserSettingsFormProps {
|
|
|
39
39
|
additionalFields?: (formik: ReturnType<typeof useFormik<UserSettingsFormValues>>) => React.ReactNode;
|
|
40
40
|
additionalInitialValues?: Record<string, string | boolean>;
|
|
41
41
|
additionalValidation?: Record<string, Yup.Schema>;
|
|
42
|
+
/**
|
|
43
|
+
* Current TOTP 2FA status. When undefined (not passed), no TOTP controls are rendered.
|
|
44
|
+
* When false, an "Enable 2FA" button is shown. When true, "Disable 2FA" and "Reset 2FA" buttons are shown.
|
|
45
|
+
*/
|
|
46
|
+
totpEnabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Called to initiate TOTP setup (e.g. AuthService.setupTotp()).
|
|
49
|
+
* Must return provisioning URI and secret on success, or an error.
|
|
50
|
+
*/
|
|
51
|
+
onTotpSetup?: () => Promise<{
|
|
52
|
+
provisioningUri: string;
|
|
53
|
+
secret: string;
|
|
54
|
+
} | {
|
|
55
|
+
error: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Called to confirm TOTP setup with a 6-digit code (e.g. AuthService.confirmTotp()).
|
|
59
|
+
*/
|
|
60
|
+
onTotpConfirm?: (code: string) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
} | {
|
|
63
|
+
error: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Called to disable TOTP with a 6-digit code (e.g. AuthService.disableTotp()).
|
|
67
|
+
*/
|
|
68
|
+
onTotpDisable?: (code: string) => Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
error: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Called to reset TOTP with a 6-digit code (e.g. AuthService.resetTotp()).
|
|
75
|
+
* Returns new provisioning URI and secret on success.
|
|
76
|
+
*/
|
|
77
|
+
onTotpReset?: (code: string) => Promise<{
|
|
78
|
+
provisioningUri: string;
|
|
79
|
+
secret: string;
|
|
80
|
+
} | {
|
|
81
|
+
error: string;
|
|
82
|
+
}>;
|
|
42
83
|
labels?: {
|
|
43
84
|
title?: string;
|
|
44
85
|
email?: string;
|
|
@@ -53,6 +94,18 @@ export interface UserSettingsFormProps {
|
|
|
53
94
|
saving?: string;
|
|
54
95
|
save?: string;
|
|
55
96
|
successMessage?: string;
|
|
97
|
+
totpSectionTitle?: string;
|
|
98
|
+
totpStatusEnabled?: string;
|
|
99
|
+
totpStatusDisabled?: string;
|
|
100
|
+
totpEnableButton?: string;
|
|
101
|
+
totpDisableButton?: string;
|
|
102
|
+
totpResetButton?: string;
|
|
103
|
+
totpDisableCodeLabel?: string;
|
|
104
|
+
totpDisableSubmitButton?: string;
|
|
105
|
+
totpResetCodeLabel?: string;
|
|
106
|
+
totpResetSubmitButton?: string;
|
|
107
|
+
totpCancelButton?: string;
|
|
108
|
+
totpError?: string;
|
|
56
109
|
};
|
|
57
110
|
}
|
|
58
111
|
export declare const UserSettingsForm: FC<UserSettingsFormProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,EAAE,EAAkC,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,OAAO,CACjD;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACrC;QACE,KAAK,EAAE,MAAM,CAA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