@digitaldefiance/express-suite-react-components 4.26.26 → 4.27.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-react-components",
3
- "version": "4.26.26",
3
+ "version": "4.27.0",
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,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,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,WAAW,EAAE,OAAO,KACjB,OAAO,CACR;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;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AM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAqtB9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"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,WAAW,EAAE,OAAO,KACjB,OAAO,CACR;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAA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AM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC3D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAi7B9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -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 RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidation, emailValidation, displayNameValidation, timezoneValidation, passwordValidation, confirmPasswordValidation, disallowedEmailDomains, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
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
- 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 ||
154
- tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
155
- display: 'grid',
156
- gridTemplateColumns: 'repeat(3, 1fr)',
157
- gap: 1.5,
158
- mb: 3,
159
- }, children: mnemonic.split(/\s+/).map((word, i) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
160
- display: 'flex',
161
- alignItems: 'center',
162
- justifyContent: 'center',
163
- gap: 0.5,
164
- py: 1,
165
- px: 1.5,
166
- borderRadius: 2,
167
- border: '1px solid',
168
- borderColor: 'divider',
169
- bgcolor: 'action.hover',
170
- }, 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 ||
171
- labels.proceedToLogin ||
172
- 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 ||
173
- 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 ||
174
- 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 ||
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":"AAoBA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,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,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CA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CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAgetD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
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,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC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AAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAmvBtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -12,11 +12,119 @@ const react_1 = require("react");
12
12
  const Yup = tslib_1.__importStar(require("yup"));
13
13
  const contexts_1 = require("../contexts");
14
14
  const suite_core_lib_2 = require("@digitaldefiance/suite-core-lib");
15
- const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, displayNameValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
15
+ const TotpSetupForm_1 = require("./TotpSetupForm");
16
+ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, displayNameValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, totpEnabled, onTotpSetup, onTotpConfirm, onTotpDisable, onTotpReset, labels = {}, }) => {
16
17
  const { tComponent } = (0, contexts_1.useI18n)();
17
18
  const [apiErrors, setApiErrors] = (0, react_1.useState)({});
18
19
  const [saving, setSaving] = (0, react_1.useState)(false);
19
20
  const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
21
+ // TOTP management state
22
+ const [totpStatus, setTotpStatus] = (0, react_1.useState)(totpEnabled);
23
+ const [showTotpSetup, setShowTotpSetup] = (0, react_1.useState)(false);
24
+ const [totpProvisioningUri, setTotpProvisioningUri] = (0, react_1.useState)(null);
25
+ const [totpSecret, setTotpSecret] = (0, react_1.useState)(null);
26
+ const [totpSetupLoading, setTotpSetupLoading] = (0, react_1.useState)(false);
27
+ const [totpError, setTotpError] = (0, react_1.useState)(null);
28
+ const [showDisablePrompt, setShowDisablePrompt] = (0, react_1.useState)(false);
29
+ const [disableCode, setDisableCode] = (0, react_1.useState)('');
30
+ const [disableSubmitting, setDisableSubmitting] = (0, react_1.useState)(false);
31
+ const [showResetPrompt, setShowResetPrompt] = (0, react_1.useState)(false);
32
+ const [resetCode, setResetCode] = (0, react_1.useState)('');
33
+ const [resetSubmitting, setResetSubmitting] = (0, react_1.useState)(false);
34
+ const handleEnableTotp = (0, react_1.useCallback)(async () => {
35
+ if (!onTotpSetup)
36
+ return;
37
+ setTotpSetupLoading(true);
38
+ setTotpError(null);
39
+ try {
40
+ const result = await onTotpSetup();
41
+ if ('error' in result) {
42
+ setTotpError(result.error);
43
+ }
44
+ else {
45
+ setTotpProvisioningUri(result.provisioningUri);
46
+ setTotpSecret(result.secret);
47
+ setShowTotpSetup(true);
48
+ }
49
+ }
50
+ catch {
51
+ setTotpError(labels.totpError || 'Failed to set up two-factor authentication');
52
+ }
53
+ finally {
54
+ setTotpSetupLoading(false);
55
+ }
56
+ }, [onTotpSetup, labels.totpError]);
57
+ const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
58
+ if (!onTotpConfirm) {
59
+ return { error: 'TOTP confirmation is not available' };
60
+ }
61
+ const result = await onTotpConfirm(code);
62
+ if ('success' in result && result.success) {
63
+ setTotpStatus(true);
64
+ setShowTotpSetup(false);
65
+ setTotpProvisioningUri(null);
66
+ setTotpSecret(null);
67
+ }
68
+ return result;
69
+ }, [onTotpConfirm]);
70
+ const handleDisableTotp = (0, react_1.useCallback)(async () => {
71
+ if (!onTotpDisable || !disableCode)
72
+ return;
73
+ setDisableSubmitting(true);
74
+ setTotpError(null);
75
+ try {
76
+ const result = await onTotpDisable(disableCode);
77
+ if ('error' in result) {
78
+ setTotpError(result.error);
79
+ }
80
+ else {
81
+ setTotpStatus(false);
82
+ setShowDisablePrompt(false);
83
+ setDisableCode('');
84
+ }
85
+ }
86
+ catch {
87
+ setTotpError(labels.totpError || 'Failed to disable two-factor authentication');
88
+ }
89
+ finally {
90
+ setDisableSubmitting(false);
91
+ }
92
+ }, [onTotpDisable, disableCode, labels.totpError]);
93
+ const handleResetTotp = (0, react_1.useCallback)(async () => {
94
+ if (!onTotpReset || !resetCode)
95
+ return;
96
+ setResetSubmitting(true);
97
+ setTotpError(null);
98
+ try {
99
+ const result = await onTotpReset(resetCode);
100
+ if ('error' in result) {
101
+ setTotpError(result.error);
102
+ }
103
+ else {
104
+ setTotpProvisioningUri(result.provisioningUri);
105
+ setTotpSecret(result.secret);
106
+ setShowResetPrompt(false);
107
+ setResetCode('');
108
+ setShowTotpSetup(true);
109
+ }
110
+ }
111
+ catch {
112
+ setTotpError(labels.totpError || 'Failed to reset two-factor authentication');
113
+ }
114
+ finally {
115
+ setResetSubmitting(false);
116
+ }
117
+ }, [onTotpReset, resetCode, labels.totpError]);
118
+ const handleCancelTotpAction = (0, react_1.useCallback)(() => {
119
+ setShowTotpSetup(false);
120
+ setShowDisablePrompt(false);
121
+ setShowResetPrompt(false);
122
+ setTotpProvisioningUri(null);
123
+ setTotpSecret(null);
124
+ setDisableCode('');
125
+ setResetCode('');
126
+ setTotpError(null);
127
+ }, []);
20
128
  const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
21
129
  const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map((c) => ({
22
130
  code: c.code,
@@ -126,7 +234,25 @@ const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation,
126
234
  (formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode ||
127
235
  tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge ||
128
236
  tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper ||
129
- tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
237
+ tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), totpStatus !== undefined && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mt: 3, mb: 2 } }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "h2", gutterBottom: true, children: labels.totpSectionTitle || 'Two-Factor Authentication' }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: totpStatus
238
+ ? (labels.totpStatusEnabled || '2FA is currently enabled')
239
+ : (labels.totpStatusDisabled || '2FA is currently disabled') }), totpError && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 2 }, role: "alert", children: totpError })), !totpStatus && !showTotpSetup && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleEnableTotp, disabled: totpSetupLoading, "data-testid": "enable-totp-button", children: totpSetupLoading
240
+ ? 'Setting up...'
241
+ : (labels.totpEnableButton || 'Enable 2FA') })), showTotpSetup && totpProvisioningUri && totpSecret && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(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: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-totp-setup-button", children: labels.totpCancelButton || 'Cancel' }) })] })), totpStatus && !showTotpSetup && !showDisablePrompt && !showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", color: "error", onClick: () => { setShowDisablePrompt(true); setTotpError(null); }, "data-testid": "disable-totp-button", children: labels.totpDisableButton || 'Disable 2FA' }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: () => { setShowResetPrompt(true); setTotpError(null); }, "data-testid": "reset-totp-button", children: labels.totpResetButton || 'Reset 2FA' })] })), showDisablePrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to disable two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-disable-code", name: "totp-disable-code", label: labels.totpDisableCodeLabel || 'TOTP Code', value: disableCode, onChange: (e) => setDisableCode(e.target.value), inputProps: {
242
+ 'aria-label': labels.totpDisableCodeLabel || 'TOTP Code',
243
+ inputMode: 'numeric',
244
+ maxLength: 6,
245
+ pattern: '\\d{6}',
246
+ }, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "error", onClick: handleDisableTotp, disabled: disableSubmitting || !/^\d{6}$/.test(disableCode), "data-testid": "disable-totp-submit-button", children: disableSubmitting
247
+ ? 'Disabling...'
248
+ : (labels.totpDisableSubmitButton || 'Confirm Disable') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-disable-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] })), showResetPrompt && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: "Enter your current 2FA code to reset two-factor authentication:" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "totp-reset-code", name: "totp-reset-code", label: labels.totpResetCodeLabel || 'TOTP Code', value: resetCode, onChange: (e) => setResetCode(e.target.value), inputProps: {
249
+ 'aria-label': labels.totpResetCodeLabel || 'TOTP Code',
250
+ inputMode: 'numeric',
251
+ maxLength: 6,
252
+ pattern: '\\d{6}',
253
+ }, autoComplete: "one-time-code", margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleResetTotp, disabled: resetSubmitting || !/^\d{6}$/.test(resetCode), "data-testid": "reset-totp-submit-button", children: resetSubmitting
254
+ ? 'Resetting...'
255
+ : (labels.totpResetSubmitButton || 'Confirm Reset') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: handleCancelTotpAction, "data-testid": "cancel-reset-totp-button", children: labels.totpCancelButton || 'Cancel' })] })] }))] })), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
130
256
  ? labels.saving ||
131
257
  tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
132
258
  : labels.save ||
@@ -26,4 +26,6 @@ export * from './VerifyEmailPage';
26
26
  export * from './T';
27
27
  export * from './TDiv';
28
28
  export * from './TImgAlt';
29
+ export * from './TotpSetupForm';
30
+ export * from './TotpVerificationForm';
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,KAAK,CAAC;AACpB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,KAAK,CAAC;AACpB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
@@ -30,3 +30,5 @@ tslib_1.__exportStar(require("./VerifyEmailPage"), exports);
30
30
  tslib_1.__exportStar(require("./T"), exports);
31
31
  tslib_1.__exportStar(require("./TDiv"), exports);
32
32
  tslib_1.__exportStar(require("./TImgAlt"), exports);
33
+ tslib_1.__exportStar(require("./TotpSetupForm"), exports);
34
+ tslib_1.__exportStar(require("./TotpVerificationForm"), exports);
@@ -54,6 +54,8 @@ export interface AuthContextData {
54
54
  token: string;
55
55
  user: IRequestUserDTO;
56
56
  wallet: Wallet;
57
+ } | {
58
+ pendingTotpToken: string;
57
59
  } | {
58
60
  error: string;
59
61
  errorType?: string;
@@ -63,6 +65,8 @@ export interface AuthContextData {
63
65
  user: IRequestUserDTO;
64
66
  wallet: Wallet;
65
67
  message: string;
68
+ } | {
69
+ pendingTotpToken: string;
66
70
  } | {
67
71
  error: string;
68
72
  errorType?: string;
@@ -78,6 +82,8 @@ export interface AuthContextData {
78
82
  token: string;
79
83
  user: IRequestUserDTO;
80
84
  wallet: Wallet;
85
+ } | {
86
+ pendingTotpToken: string;
81
87
  } | {
82
88
  error: string;
83
89
  errorType?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,MAAM,IAAI,cAAc,EACxB,YAAY,EAGZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,YAAY,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EAId,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAEL,SAAS,EAMV,MAAM,OAAO,CAAC;AASf,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,eAAe,EAAE,CACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,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AAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC;IACxC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB,EAAE,MAAM,CAAC;IAChC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAClD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,WAAW,0CAEvB,CAAC;AA8rBF,eAAO,MAAM,YAAY,GAAI,uEAO1B,iBAAiB,4CAYnB,CAAC;AAEF,eAAO,MAAM,OAAO,uBAEnB,CAAC"}
1
+ {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,MAAM,IAAI,cAAc,EACxB,YAAY,EAGZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,YAAY,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,aAAa,EAId,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,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MAAM,YAAY,GAAI,uEAO1B,iBAAiB,4CAYnB,CAAC;AAEF,eAAO,MAAM,OAAO,uBAEnB,CAAC"}
@@ -46,6 +46,8 @@ export declare class AuthService {
46
46
  user: IRequestUserDTO;
47
47
  wallet: Wallet;
48
48
  message: string;
49
+ } | {
50
+ pendingTotpToken: string;
49
51
  } | {
50
52
  error: string;
51
53
  errorType?: string;
@@ -59,6 +61,8 @@ export declare class AuthService {
59
61
  user: IRequestUserDTO;
60
62
  wallet: Wallet;
61
63
  message: string;
64
+ } | {
65
+ pendingTotpToken: string;
62
66
  } | {
63
67
  error: string;
64
68
  errorType?: string;
@@ -88,6 +92,34 @@ export declare class AuthService {
88
92
  status?: number;
89
93
  errorType?: string;
90
94
  }>;
95
+ setupTotp(): Promise<{
96
+ provisioningUri: string;
97
+ secret: string;
98
+ } | {
99
+ error: string;
100
+ }>;
101
+ confirmTotp(code: string): Promise<{
102
+ success: boolean;
103
+ } | {
104
+ error: string;
105
+ }>;
106
+ disableTotp(code: string): Promise<{
107
+ success: boolean;
108
+ } | {
109
+ error: string;
110
+ }>;
111
+ resetTotp(code: string): Promise<{
112
+ provisioningUri: string;
113
+ secret: string;
114
+ } | {
115
+ error: string;
116
+ }>;
117
+ verifyTotpLogin(pendingTotpToken: string, code: string): Promise<{
118
+ token: string;
119
+ user: IRequestUserDTO;
120
+ } | {
121
+ error: string;
122
+ }>;
91
123
  }
92
124
  export declare const createAuthService: (constants: IConstants, baseUrl: string, eciesConfig: IECIESConfig, siteDomain: string) => AuthService;
93
125
  export {};
@@ -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,EACZ,YAAY,EAEb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,UAAU,EACV,eAAe,EAGhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EA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AAE,eAAe,CAAC;KACvB,CAAC;IA+BI,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA0BlE,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CACN;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GACD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CACzD;CAiDF;AAED,eAAO,MAAM,iBAAiB,GAC5B,WAAW,UAAU,EACrB,SAAS,MAAM,EACf,aAAa,YAAY,EACzB,YAAY,MAAM,gBAC6C,CAAC"}
1
+ {"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEX,YAAY,EACZ,YAAY,EAEb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,UAAU,EACV,eAAe,EAGhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM5C,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC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xB,IAAI,EAAE,MAAM,GACX,OAAO,CACN;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GACxC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CACpB;CA6BF;AAED,eAAO,MAAM,iBAAiB,GAC5B,WAAW,UAAU,EACrB,SAAS,MAAM,EACf,aAAa,YAAY,EACzB,YAAY,MAAM,gBAC6C,CAAC"}
@@ -116,6 +116,11 @@ class AuthService {
116
116
  challenge: loginRequest.data.challenge,
117
117
  signature: signatureHex,
118
118
  });
119
+ if (loginResponse.data.pendingTotpToken) {
120
+ return {
121
+ pendingTotpToken: loginResponse.data.pendingTotpToken,
122
+ };
123
+ }
119
124
  if (loginResponse.data.token && loginResponse.data.user) {
120
125
  return {
121
126
  message: loginResponse.data.message ?? '',
@@ -206,6 +211,11 @@ class AuthService {
206
211
  username: username ?? null,
207
212
  email: email ?? null,
208
213
  });
214
+ if (response.data.pendingTotpToken) {
215
+ return {
216
+ pendingTotpToken: response.data.pendingTotpToken,
217
+ };
218
+ }
209
219
  if (response.data.token && response.data.user) {
210
220
  return {
211
221
  message: response.data.message ?? '',
@@ -348,6 +358,112 @@ class AuthService {
348
358
  };
349
359
  }
350
360
  }
361
+ async setupTotp() {
362
+ try {
363
+ const response = await this.authenticatedApiClient.post('/user/totp/setup');
364
+ return {
365
+ provisioningUri: response.data.provisioningUri,
366
+ secret: response.data.secret,
367
+ };
368
+ }
369
+ catch (error) {
370
+ if ((0, axios_1.isAxiosError)(error) && error.response) {
371
+ const errorData = error.response.data;
372
+ return {
373
+ error: extractErrorMessage(errorData) ??
374
+ error.message ??
375
+ (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
376
+ };
377
+ }
378
+ return {
379
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
380
+ };
381
+ }
382
+ }
383
+ async confirmTotp(code) {
384
+ try {
385
+ await this.authenticatedApiClient.post('/user/totp/confirm', { code });
386
+ return { success: true };
387
+ }
388
+ catch (error) {
389
+ if ((0, axios_1.isAxiosError)(error) && error.response) {
390
+ const errorData = error.response.data;
391
+ return {
392
+ error: extractErrorMessage(errorData) ??
393
+ error.message ??
394
+ (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
395
+ };
396
+ }
397
+ return {
398
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
399
+ };
400
+ }
401
+ }
402
+ async disableTotp(code) {
403
+ try {
404
+ await this.authenticatedApiClient.post('/user/totp/disable', { code });
405
+ return { success: true };
406
+ }
407
+ catch (error) {
408
+ if ((0, axios_1.isAxiosError)(error) && error.response) {
409
+ const errorData = error.response.data;
410
+ return {
411
+ error: extractErrorMessage(errorData) ??
412
+ error.message ??
413
+ (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
414
+ };
415
+ }
416
+ return {
417
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
418
+ };
419
+ }
420
+ }
421
+ async resetTotp(code) {
422
+ try {
423
+ const response = await this.authenticatedApiClient.post('/user/totp/reset', { code });
424
+ return {
425
+ provisioningUri: response.data.provisioningUri,
426
+ secret: response.data.secret,
427
+ };
428
+ }
429
+ catch (error) {
430
+ if ((0, axios_1.isAxiosError)(error) && error.response) {
431
+ const errorData = error.response.data;
432
+ return {
433
+ error: extractErrorMessage(errorData) ??
434
+ error.message ??
435
+ (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
436
+ };
437
+ }
438
+ return {
439
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
440
+ };
441
+ }
442
+ }
443
+ async verifyTotpLogin(pendingTotpToken, code) {
444
+ try {
445
+ const response = await this.apiClient.post('/user/totp/verify', { code }, {
446
+ headers: { Authorization: `Bearer ${pendingTotpToken}` },
447
+ });
448
+ return {
449
+ token: response.data.token,
450
+ user: response.data.user,
451
+ };
452
+ }
453
+ catch (error) {
454
+ if ((0, axios_1.isAxiosError)(error) && error.response) {
455
+ const errorData = error.response.data;
456
+ return {
457
+ error: extractErrorMessage(errorData) ??
458
+ error.message ??
459
+ (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
460
+ };
461
+ }
462
+ return {
463
+ error: (0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_UnexpectedError),
464
+ };
465
+ }
466
+ }
351
467
  }
352
468
  exports.AuthService = AuthService;
353
469
  const createAuthService = (constants, baseUrl, eciesConfig, siteDomain) => new AuthService(constants, baseUrl, eciesConfig, siteDomain);
@@ -1,9 +1,21 @@
1
1
  import { FC } from 'react';
2
+ import { IRequestUserDTO } from '@digitaldefiance/suite-core-lib';
2
3
  import { LoginFormProps } from '../components/LoginForm';
3
4
  export interface LoginFormWrapperProps {
4
5
  onSuccess?: () => void;
5
6
  redirectTo?: string;
6
7
  componentProps?: Partial<Omit<LoginFormProps, 'onSubmit'>>;
8
+ /**
9
+ * Called when the user submits a TOTP verification code during login.
10
+ * Typically wired to `AuthService.verifyTotpLogin(pendingTotpToken, code)`.
11
+ * When not provided, the wrapper cannot complete TOTP-protected logins.
12
+ */
13
+ onVerifyTotp?: (code: string, pendingTotpToken: string) => Promise<{
14
+ token: string;
15
+ user: IRequestUserDTO;
16
+ } | {
17
+ error: string;
18
+ }>;
7
19
  }
8
20
  export declare const LoginFormWrapper: FC<LoginFormWrapperProps>;
9
21
  //# sourceMappingURL=LoginFormWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoginFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/LoginFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAA8B,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIrF,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA6CtD,CAAC"}
1
+ {"version":3,"file":"LoginFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/LoginFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAGrC,OAAO,EAAE,eAAe,EAA8C,MAAM,iCAAiC,CAAC;AAC9G,OAAO,EAA8B,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIrF,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D;;;;OAIG;IACH,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,KACrB,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5E;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAmFtD,CAAC"}
@@ -2,15 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoginFormWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const react_router_dom_1 = require("react-router-dom");
6
7
  const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
8
+ const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
7
9
  const LoginForm_1 = require("../components/LoginForm");
10
+ const TotpVerificationForm_1 = require("../components/TotpVerificationForm");
8
11
  const contexts_1 = require("../contexts");
9
- const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
10
- const LoginFormWrapper = ({ onSuccess, redirectTo, componentProps = {}, }) => {
12
+ const LoginFormWrapper = ({ onSuccess, redirectTo, componentProps = {}, onVerifyTotp, }) => {
11
13
  const { directLogin, passwordLogin } = (0, contexts_1.useAuth)();
12
14
  const navigate = (0, react_router_dom_1.useNavigate)();
13
15
  const { routes } = (0, contexts_1.useSuiteConfig)();
16
+ const [pendingTotpToken, setPendingTotpToken] = (0, react_1.useState)(null);
17
+ const handleLoginSuccess = () => {
18
+ if (onSuccess) {
19
+ onSuccess();
20
+ }
21
+ navigate(redirectTo || routes.dashboard || '/dashboard');
22
+ };
14
23
  const handleSubmit = async (values) => {
15
24
  const email = values.email && values.email.trim().length > 0 ? new ecies_lib_1.EmailString(values.email) : undefined;
16
25
  const username = values.username && values.username.trim() ? values.username : undefined;
@@ -19,25 +28,44 @@ const LoginFormWrapper = ({ onSuccess, redirectTo, componentProps = {}, }) => {
19
28
  if ('error' in result) {
20
29
  throw new Error(result.error);
21
30
  }
22
- if (onSuccess) {
23
- onSuccess();
31
+ if ('pendingTotpToken' in result) {
32
+ setPendingTotpToken(result.pendingTotpToken);
33
+ return;
24
34
  }
25
- navigate(redirectTo || routes.dashboard || '/dashboard');
35
+ handleLoginSuccess();
26
36
  }
27
37
  else if (values.mnemonic) {
28
38
  const result = await directLogin(new ecies_lib_1.SecureString(values.mnemonic), username, email);
29
39
  if ('error' in result) {
30
40
  throw new Error(result.error);
31
41
  }
32
- if (onSuccess) {
33
- onSuccess();
42
+ if ('pendingTotpToken' in result) {
43
+ setPendingTotpToken(result.pendingTotpToken);
44
+ return;
34
45
  }
35
- navigate(redirectTo || routes.dashboard || '/dashboard');
46
+ handleLoginSuccess();
36
47
  }
37
48
  else {
38
49
  throw new suite_core_lib_1.TranslatableSuiteError(suite_core_lib_1.SuiteCoreStringKey.Error_NoPasswordOrMnemonicProvided);
39
50
  }
40
51
  };
52
+ const handleTotpSubmit = async (code, token) => {
53
+ if (!onVerifyTotp) {
54
+ return { error: 'TOTP verification is not configured' };
55
+ }
56
+ const result = await onVerifyTotp(code, token);
57
+ if ('error' in result) {
58
+ return result;
59
+ }
60
+ // Store the full JWT and complete the login flow
61
+ localStorage.setItem('authToken', result.token);
62
+ localStorage.setItem('user', JSON.stringify(result.user));
63
+ handleLoginSuccess();
64
+ return result;
65
+ };
66
+ if (pendingTotpToken) {
67
+ return ((0, jsx_runtime_1.jsx)(TotpVerificationForm_1.TotpVerificationForm, { pendingTotpToken: pendingTotpToken, onSubmit: handleTotpSubmit }));
68
+ }
41
69
  return (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onSubmit: handleSubmit, ...componentProps });
42
70
  };
43
71
  exports.LoginFormWrapper = LoginFormWrapper;