@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.
Files changed (31) hide show
  1. package/package.json +2 -1
  2. package/src/components/RegisterForm.d.ts +31 -0
  3. package/src/components/RegisterForm.d.ts.map +1 -1
  4. package/src/components/RegisterForm.js +98 -24
  5. package/src/components/TotpSetupForm.d.ts +24 -0
  6. package/src/components/TotpSetupForm.d.ts.map +1 -0
  7. package/src/components/TotpSetupForm.js +82 -0
  8. package/src/components/TotpVerificationForm.d.ts +23 -0
  9. package/src/components/TotpVerificationForm.d.ts.map +1 -0
  10. package/src/components/TotpVerificationForm.js +66 -0
  11. package/src/components/UserSettingsForm.d.ts +53 -0
  12. package/src/components/UserSettingsForm.d.ts.map +1 -1
  13. package/src/components/UserSettingsForm.js +128 -2
  14. package/src/components/index.d.ts +2 -0
  15. package/src/components/index.d.ts.map +1 -1
  16. package/src/components/index.js +2 -0
  17. package/src/contexts/AuthProvider.d.ts +33 -0
  18. package/src/contexts/AuthProvider.d.ts.map +1 -1
  19. package/src/contexts/AuthProvider.js +3 -0
  20. package/src/services/authService.d.ts +32 -0
  21. package/src/services/authService.d.ts.map +1 -1
  22. package/src/services/authService.js +116 -0
  23. package/src/wrappers/LoginFormWrapper.d.ts +12 -0
  24. package/src/wrappers/LoginFormWrapper.d.ts.map +1 -1
  25. package/src/wrappers/LoginFormWrapper.js +36 -9
  26. package/src/wrappers/RegisterFormWrapper.d.ts +6 -0
  27. package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -1
  28. package/src/wrappers/RegisterFormWrapper.js +10 -3
  29. package/src/wrappers/UserSettingsFormWrapper.d.ts +21 -0
  30. package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -1
  31. package/src/wrappers/UserSettingsFormWrapper.js +67 -3
@@ -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;
@@ -134,6 +140,33 @@ export interface AuthContextData {
134
140
  wallet?: Wallet;
135
141
  walletExpirationSeconds: number;
136
142
  verifyToken: (token: string) => Promise<boolean>;
143
+ /**
144
+ * Initiates TOTP setup for the authenticated user.
145
+ * Returns the provisioning URI and raw base32 secret on success.
146
+ */
147
+ setupTotp: () => Promise<{
148
+ provisioningUri: string;
149
+ secret: string;
150
+ } | {
151
+ error: string;
152
+ }>;
153
+ /**
154
+ * Confirms TOTP setup with a 6-digit code.
155
+ */
156
+ confirmTotp: (code: string) => Promise<{
157
+ success: boolean;
158
+ } | {
159
+ error: string;
160
+ }>;
161
+ /**
162
+ * Completes TOTP login by verifying a 6-digit code against a pending TOTP token.
163
+ */
164
+ verifyTotpLogin: (pendingTotpToken: string, code: string) => Promise<{
165
+ token: string;
166
+ user: IRequestUserDTO;
167
+ } | {
168
+ error: string;
169
+ }>;
137
170
  }
138
171
  export type AuthProviderProps = {
139
172
  children: ReactNode;
@@ -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;A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 {"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,OAAO,EACxB,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CACR;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACzE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CACrC,CAAC;IACF;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;OAKG;IACH,cAAc,EAAE,CACd,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,KAChB,OAAO,CACR,eAAe,GACf;QACE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAA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W,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1F;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjF;;OAEG;IACH,eAAe,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpI;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;AAisBF,eAAO,MAAM,YAAY,GAAI,uEAO1B,iBAAiB,4CAYnB,CAAC;AAEF,eAAO,MAAM,OAAO,uBAEnB,CAAC"}
@@ -441,6 +441,9 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
441
441
  setUserSetting: setUserSettingAndUpdateSettings,
442
442
  setWallet,
443
443
  setWalletExpirationSeconds,
444
+ setupTotp: () => authService.setupTotp(),
445
+ confirmTotp: (code) => authService.confirmTotp(code),
446
+ verifyTotpLogin: (pendingTotpToken, code) => authService.verifyTotpLogin(pendingTotpToken, code),
444
447
  token,
445
448
  user: frontendUser,
446
449
  userData: user,
@@ -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,EAAE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E,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,E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,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,CAkFtD,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 = {}, }) => {
11
- const { directLogin, passwordLogin } = (0, contexts_1.useAuth)();
12
+ const LoginFormWrapper = ({ onSuccess, redirectTo, componentProps = {}, onVerifyTotp, }) => {
13
+ const { directLogin, passwordLogin, verifyTotpLogin } = (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,43 @@ 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
+ // Use the explicitly provided callback, or fall back to verifyTotpLogin from AuthContext
54
+ const verifyFn = onVerifyTotp ?? ((c, t) => verifyTotpLogin(t, c));
55
+ const result = await verifyFn(code, token);
56
+ if ('error' in result) {
57
+ return result;
58
+ }
59
+ // Store the full JWT and complete the login flow
60
+ localStorage.setItem('authToken', result.token);
61
+ localStorage.setItem('user', JSON.stringify(result.user));
62
+ handleLoginSuccess();
63
+ return result;
64
+ };
65
+ if (pendingTotpToken) {
66
+ return ((0, jsx_runtime_1.jsx)(TotpVerificationForm_1.TotpVerificationForm, { pendingTotpToken: pendingTotpToken, onSubmit: handleTotpSubmit }));
67
+ }
41
68
  return (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onSubmit: handleSubmit, ...componentProps });
42
69
  };
43
70
  exports.LoginFormWrapper = LoginFormWrapper;
@@ -2,6 +2,12 @@ import { FC } from 'react';
2
2
  import { RegisterFormProps } from '../components/RegisterForm';
3
3
  export interface RegisterFormWrapperProps {
4
4
  onSuccess?: () => void;
5
+ /**
6
+ * When true, offer the TOTP setup step after successful registration.
7
+ * Typically sourced from window.APP_CONFIG.totpAvailable.
8
+ * Defaults to false.
9
+ */
10
+ enableTotpSetup?: boolean;
5
11
  componentProps?: Partial<Omit<RegisterFormProps, 'onSubmit' | 'timezones' | 'getInitialTimezone'>>;
6
12
  }
7
13
  export declare const RegisterFormWrapper: FC<RegisterFormWrapperProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/RegisterFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAEL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CACtB,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,GAAG,oBAAoB,CAAC,CACzE,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CA8C5D,CAAC"}
1
+ {"version":3,"file":"RegisterFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/RegisterFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAEL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CACtB,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,GAAG,oBAAoB,CAAC,CACzE,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAwD5D,CAAC"}
@@ -4,8 +4,8 @@ exports.RegisterFormWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const RegisterForm_1 = require("../components/RegisterForm");
6
6
  const contexts_1 = require("../contexts");
7
- const RegisterFormWrapper = ({ onSuccess, componentProps = {}, }) => {
8
- const { register } = (0, contexts_1.useAuth)();
7
+ const RegisterFormWrapper = ({ onSuccess, enableTotpSetup = false, componentProps = {}, }) => {
8
+ const { register, setupTotp, confirmTotp } = (0, contexts_1.useAuth)();
9
9
  const { timezones } = (0, contexts_1.useSuiteConfig)();
10
10
  const handleSubmit = async (values) => {
11
11
  const result = await register(values.username, values.email, values.timezone || 'UTC', values.password, values.mnemonic, values.displayName);
@@ -27,6 +27,13 @@ const RegisterFormWrapper = ({ onSuccess, componentProps = {}, }) => {
27
27
  'America/Los_Angeles',
28
28
  'Europe/London',
29
29
  ];
30
- return ((0, jsx_runtime_1.jsx)(RegisterForm_1.RegisterForm, { onSubmit: handleSubmit, timezones: defaultTimezones, getInitialTimezone: () => Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC', ...componentProps }));
30
+ const totpProps = enableTotpSetup
31
+ ? {
32
+ enableTotpSetup: true,
33
+ onTotpSetup: setupTotp,
34
+ onTotpConfirm: confirmTotp,
35
+ }
36
+ : {};
37
+ return ((0, jsx_runtime_1.jsx)(RegisterForm_1.RegisterForm, { onSubmit: handleSubmit, timezones: defaultTimezones, getInitialTimezone: () => Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC', ...totpProps, ...componentProps }));
31
38
  };
32
39
  exports.RegisterFormWrapper = RegisterFormWrapper;