@digitaldefiance/express-suite-react-components 5.0.2 → 5.0.3

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 (311) hide show
  1. package/package.json +5 -4
  2. package/src/auth/AdminRoute.d.ts +8 -0
  3. package/src/auth/AdminRoute.d.ts.map +1 -0
  4. package/src/auth/AdminRoute.js +28 -0
  5. package/src/auth/Private.d.ts +6 -0
  6. package/src/auth/Private.d.ts.map +1 -0
  7. package/src/auth/Private.js +14 -0
  8. package/src/auth/PrivateRoute.d.ts +8 -0
  9. package/src/auth/PrivateRoute.d.ts.map +1 -0
  10. package/src/auth/PrivateRoute.js +23 -0
  11. package/src/auth/UnAuth.d.ts +6 -0
  12. package/src/auth/UnAuth.d.ts.map +1 -0
  13. package/src/auth/UnAuth.js +14 -0
  14. package/src/auth/UnAuthRoute.d.ts +8 -0
  15. package/src/auth/UnAuthRoute.d.ts.map +1 -0
  16. package/src/auth/UnAuthRoute.js +22 -0
  17. package/src/auth/{index.ts → index.d.ts} +3 -2
  18. package/src/auth/index.d.ts.map +1 -0
  19. package/src/auth/index.js +12 -0
  20. package/src/components/ApiAccess.d.ts +16 -0
  21. package/src/components/ApiAccess.d.ts.map +1 -0
  22. package/src/components/ApiAccess.js +77 -0
  23. package/src/components/BackupCodeLoginForm.d.ts +43 -0
  24. package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
  25. package/src/components/BackupCodeLoginForm.js +139 -0
  26. package/src/components/BackupCodesForm.d.ts +26 -0
  27. package/src/components/BackupCodesForm.d.ts.map +1 -0
  28. package/src/components/BackupCodesForm.js +120 -0
  29. package/src/components/CategoryMenu.d.ts +17 -0
  30. package/src/components/CategoryMenu.d.ts.map +1 -0
  31. package/src/components/CategoryMenu.js +65 -0
  32. package/src/components/ChangePasswordForm.d.ts +26 -0
  33. package/src/components/ChangePasswordForm.d.ts.map +1 -0
  34. package/src/components/ChangePasswordForm.js +78 -0
  35. package/src/components/ConfirmationDialog.d.ts +13 -0
  36. package/src/components/ConfirmationDialog.d.ts.map +1 -0
  37. package/src/components/ConfirmationDialog.js +10 -0
  38. package/src/components/CurrencyCodeSelector.d.ts +9 -0
  39. package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
  40. package/src/components/CurrencyCodeSelector.js +31 -0
  41. package/src/components/CurrencyInput.d.ts +13 -0
  42. package/src/components/CurrencyInput.d.ts.map +1 -0
  43. package/src/components/CurrencyInput.js +22 -0
  44. package/src/components/DashboardPage.d.ts +8 -0
  45. package/src/components/DashboardPage.d.ts.map +1 -0
  46. package/src/components/DashboardPage.js +10 -0
  47. package/src/components/DropdownMenu.d.ts +13 -0
  48. package/src/components/DropdownMenu.d.ts.map +1 -0
  49. package/src/components/DropdownMenu.js +63 -0
  50. package/src/components/ExpirationSecondsSelector.d.ts +13 -0
  51. package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
  52. package/src/components/ExpirationSecondsSelector.js +32 -0
  53. package/src/components/FakeEmailAdminPanel.d.ts +23 -0
  54. package/src/components/FakeEmailAdminPanel.d.ts.map +1 -0
  55. package/src/components/FakeEmailAdminPanel.js +147 -0
  56. package/src/components/Flag.d.ts +20 -0
  57. package/src/components/Flag.d.ts.map +1 -0
  58. package/src/components/Flag.js +43 -0
  59. package/src/components/ForgotPasswordForm.d.ts +18 -0
  60. package/src/components/ForgotPasswordForm.d.ts.map +1 -0
  61. package/src/components/ForgotPasswordForm.js +61 -0
  62. package/src/components/LoginForm.d.ts +44 -0
  63. package/src/components/LoginForm.d.ts.map +1 -0
  64. package/src/components/LoginForm.js +123 -0
  65. package/src/components/LogoutPage.d.ts +8 -0
  66. package/src/components/LogoutPage.d.ts.map +1 -0
  67. package/src/components/LogoutPage.js +16 -0
  68. package/src/components/RegisterForm.d.ts +100 -0
  69. package/src/components/RegisterForm.d.ts.map +1 -0
  70. package/src/components/RegisterForm.js +306 -0
  71. package/src/components/ResetPasswordForm.d.ts +23 -0
  72. package/src/components/ResetPasswordForm.d.ts.map +1 -0
  73. package/src/components/ResetPasswordForm.js +78 -0
  74. package/src/components/SideMenu.d.ts +8 -0
  75. package/src/components/SideMenu.d.ts.map +1 -0
  76. package/src/components/SideMenu.js +25 -0
  77. package/src/components/SideMenuListItem.d.ts +13 -0
  78. package/src/components/SideMenuListItem.d.ts.map +1 -0
  79. package/src/components/SideMenuListItem.js +44 -0
  80. package/src/components/T.d.ts +7 -0
  81. package/src/components/T.d.ts.map +1 -0
  82. package/src/components/T.js +13 -0
  83. package/src/components/TDiv.d.ts +9 -0
  84. package/src/components/TDiv.d.ts.map +1 -0
  85. package/src/components/TDiv.js +14 -0
  86. package/src/components/TImgAlt.d.ts +10 -0
  87. package/src/components/TImgAlt.d.ts.map +1 -0
  88. package/src/components/TImgAlt.js +14 -0
  89. package/src/components/TopMenu.d.ts +50 -0
  90. package/src/components/TopMenu.d.ts.map +1 -0
  91. package/src/components/TopMenu.js +79 -0
  92. package/src/components/TotpSetupForm.d.ts +24 -0
  93. package/src/components/TotpSetupForm.d.ts.map +1 -0
  94. package/src/components/TotpSetupForm.js +82 -0
  95. package/src/components/TotpVerificationForm.d.ts +23 -0
  96. package/src/components/TotpVerificationForm.d.ts.map +1 -0
  97. package/src/components/TotpVerificationForm.js +66 -0
  98. package/src/components/TranslatedTitle.d.ts +8 -0
  99. package/src/components/TranslatedTitle.d.ts.map +1 -0
  100. package/src/components/TranslatedTitle.js +15 -0
  101. package/src/components/UserLanguageSelector.d.ts +4 -0
  102. package/src/components/UserLanguageSelector.d.ts.map +1 -0
  103. package/src/components/UserLanguageSelector.js +31 -0
  104. package/src/components/UserMenu.d.ts +4 -0
  105. package/src/components/UserMenu.d.ts.map +1 -0
  106. package/src/components/UserMenu.js +12 -0
  107. package/src/components/UserSettingsForm.d.ts +113 -0
  108. package/src/components/UserSettingsForm.d.ts.map +1 -0
  109. package/src/components/UserSettingsForm.js +269 -0
  110. package/src/components/VerifyEmailPage.d.ts +24 -0
  111. package/src/components/VerifyEmailPage.d.ts.map +1 -0
  112. package/src/components/VerifyEmailPage.js +81 -0
  113. package/src/components/{index.ts → index.d.ts} +1 -1
  114. package/src/components/index.d.ts.map +1 -0
  115. package/src/components/index.js +35 -0
  116. package/src/contexts/AuthProvider.d.ts +186 -0
  117. package/src/contexts/AuthProvider.d.ts.map +1 -0
  118. package/src/contexts/AuthProvider.js +515 -0
  119. package/src/contexts/I18nProvider.d.ts +27 -0
  120. package/src/contexts/I18nProvider.d.ts.map +1 -0
  121. package/src/contexts/I18nProvider.js +60 -0
  122. package/src/contexts/MenuContext.d.ts +28 -0
  123. package/src/contexts/MenuContext.d.ts.map +1 -0
  124. package/src/contexts/MenuContext.js +292 -0
  125. package/src/contexts/SuiteConfigProvider.d.ts +44 -0
  126. package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
  127. package/src/contexts/SuiteConfigProvider.js +43 -0
  128. package/src/contexts/ThemeProvider.d.ts +15 -0
  129. package/src/contexts/ThemeProvider.d.ts.map +1 -0
  130. package/src/contexts/ThemeProvider.js +36 -0
  131. package/src/contexts/{index.ts → index.d.ts} +1 -0
  132. package/src/contexts/index.d.ts.map +1 -0
  133. package/src/contexts/index.js +8 -0
  134. package/src/hooks/{index.ts → index.d.ts} +1 -0
  135. package/src/hooks/index.d.ts.map +1 -0
  136. package/src/hooks/index.js +9 -0
  137. package/src/hooks/useAuthenticatedApi.d.ts +34 -0
  138. package/src/hooks/useAuthenticatedApi.d.ts.map +1 -0
  139. package/src/hooks/useAuthenticatedApi.js +46 -0
  140. package/src/hooks/useBackupCodes.d.ts +15 -0
  141. package/src/hooks/useBackupCodes.d.ts.map +1 -0
  142. package/src/hooks/useBackupCodes.js +74 -0
  143. package/src/hooks/useEmailVerification.d.ts +10 -0
  144. package/src/hooks/useEmailVerification.d.ts.map +1 -0
  145. package/src/hooks/useEmailVerification.js +40 -0
  146. package/src/hooks/useExpiringValue.d.ts +14 -0
  147. package/src/hooks/useExpiringValue.d.ts.map +1 -0
  148. package/src/hooks/useExpiringValue.js +53 -0
  149. package/src/hooks/useLocalStorage.d.ts +2 -0
  150. package/src/hooks/useLocalStorage.d.ts.map +1 -0
  151. package/src/hooks/useLocalStorage.js +15 -0
  152. package/src/hooks/useUserSettings.d.ts +48 -0
  153. package/src/hooks/useUserSettings.d.ts.map +1 -0
  154. package/src/hooks/useUserSettings.js +171 -0
  155. package/src/{index.ts → index.d.ts} +1 -1
  156. package/src/index.d.ts.map +1 -0
  157. package/src/index.js +12 -0
  158. package/src/interfaces/IAppConfig.d.ts +8 -0
  159. package/src/interfaces/IAppConfig.d.ts.map +1 -0
  160. package/src/interfaces/IAppConfig.js +2 -0
  161. package/src/interfaces/ICategoryConfig.d.ts +41 -0
  162. package/src/interfaces/ICategoryConfig.d.ts.map +1 -0
  163. package/src/interfaces/ICategoryConfig.js +2 -0
  164. package/src/interfaces/IMenuConfig.d.ts +28 -0
  165. package/src/interfaces/IMenuConfig.d.ts.map +1 -0
  166. package/src/interfaces/IMenuConfig.js +2 -0
  167. package/src/interfaces/IMenuOption.d.ts +82 -0
  168. package/src/interfaces/IMenuOption.d.ts.map +1 -0
  169. package/src/interfaces/IMenuOption.js +2 -0
  170. package/src/interfaces/{index.ts → index.d.ts} +1 -0
  171. package/src/interfaces/index.d.ts.map +1 -0
  172. package/src/interfaces/index.js +7 -0
  173. package/src/services/__mocks__/authService.d.ts +21 -0
  174. package/src/services/__mocks__/authService.d.ts.map +1 -0
  175. package/src/services/__mocks__/authService.js +15 -0
  176. package/src/services/api.d.ts +3 -0
  177. package/src/services/api.d.ts.map +1 -0
  178. package/src/services/api.js +14 -0
  179. package/src/services/authService.d.ts +126 -0
  180. package/src/services/authService.d.ts.map +1 -0
  181. package/src/services/authService.js +471 -0
  182. package/src/services/authenticatedApi.d.ts +3 -0
  183. package/src/services/authenticatedApi.d.ts.map +1 -0
  184. package/src/services/authenticatedApi.js +18 -0
  185. package/src/services/index.d.ts +4 -0
  186. package/src/services/index.d.ts.map +1 -0
  187. package/src/services/index.js +6 -0
  188. package/src/types/MenuType.d.ts +11 -0
  189. package/src/types/MenuType.d.ts.map +1 -0
  190. package/src/types/MenuType.js +12 -0
  191. package/src/types/expirationSeconds.d.ts +3 -0
  192. package/src/types/expirationSeconds.d.ts.map +1 -0
  193. package/src/types/expirationSeconds.js +17 -0
  194. package/src/types/index.d.ts +2 -0
  195. package/src/types/index.d.ts.map +1 -0
  196. package/src/types/index.js +4 -0
  197. package/src/types/translation.d.ts +10 -0
  198. package/src/types/translation.d.ts.map +1 -0
  199. package/src/types/translation.js +9 -0
  200. package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
  201. package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
  202. package/src/wrappers/BackupCodeLoginWrapper.js +20 -0
  203. package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
  204. package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
  205. package/src/wrappers/BackupCodesWrapper.js +17 -0
  206. package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
  207. package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
  208. package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
  209. package/src/wrappers/ForgotPasswordFormWrapper.d.ts +8 -0
  210. package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +1 -0
  211. package/src/wrappers/ForgotPasswordFormWrapper.js +29 -0
  212. package/src/wrappers/LoginFormWrapper.d.ts +21 -0
  213. package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
  214. package/src/wrappers/LoginFormWrapper.js +72 -0
  215. package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
  216. package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
  217. package/src/wrappers/LogoutPageWrapper.js +21 -0
  218. package/src/wrappers/RegisterFormWrapper.d.ts +20 -0
  219. package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
  220. package/src/wrappers/RegisterFormWrapper.js +51 -0
  221. package/src/wrappers/ResetPasswordFormWrapper.d.ts +9 -0
  222. package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +1 -0
  223. package/src/wrappers/ResetPasswordFormWrapper.js +34 -0
  224. package/src/wrappers/UserSettingsFormWrapper.d.ts +29 -0
  225. package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
  226. package/src/wrappers/UserSettingsFormWrapper.js +95 -0
  227. package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
  228. package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
  229. package/src/wrappers/VerifyEmailPageWrapper.js +21 -0
  230. package/src/wrappers/{index.tsx → index.d.ts} +1 -10
  231. package/src/wrappers/index.d.ts.map +1 -0
  232. package/src/wrappers/index.js +24 -0
  233. package/LICENSE +0 -21
  234. package/src/auth/AdminRoute.tsx +0 -54
  235. package/src/auth/Private.tsx +0 -17
  236. package/src/auth/PrivateRoute.tsx +0 -28
  237. package/src/auth/UnAuth.tsx +0 -16
  238. package/src/auth/UnAuthRoute.tsx +0 -30
  239. package/src/components/ApiAccess.tsx +0 -175
  240. package/src/components/BackupCodeLoginForm.tsx +0 -489
  241. package/src/components/BackupCodesForm.tsx +0 -287
  242. package/src/components/CategoryMenu.tsx +0 -155
  243. package/src/components/ChangePasswordForm.tsx +0 -273
  244. package/src/components/ConfirmationDialog.tsx +0 -48
  245. package/src/components/CurrencyCodeSelector.tsx +0 -60
  246. package/src/components/CurrencyInput.tsx +0 -80
  247. package/src/components/DashboardPage.tsx +0 -24
  248. package/src/components/DropdownMenu.tsx +0 -105
  249. package/src/components/ExpirationSecondsSelector.tsx +0 -60
  250. package/src/components/FakeEmailAdminPanel.tsx +0 -374
  251. package/src/components/Flag.tsx +0 -52
  252. package/src/components/ForgotPasswordForm.tsx +0 -174
  253. package/src/components/LoginForm.tsx +0 -468
  254. package/src/components/LogoutPage.tsx +0 -21
  255. package/src/components/RegisterForm.tsx +0 -1169
  256. package/src/components/ResetPasswordForm.tsx +0 -247
  257. package/src/components/SideMenu.tsx +0 -46
  258. package/src/components/SideMenuListItem.tsx +0 -75
  259. package/src/components/T.tsx +0 -24
  260. package/src/components/TDiv.tsx +0 -26
  261. package/src/components/TImgAlt.tsx +0 -28
  262. package/src/components/TopMenu.tsx +0 -252
  263. package/src/components/TotpSetupForm.tsx +0 -188
  264. package/src/components/TotpVerificationForm.tsx +0 -148
  265. package/src/components/TranslatedTitle.tsx +0 -31
  266. package/src/components/UserLanguageSelector.tsx +0 -45
  267. package/src/components/UserMenu.tsx +0 -15
  268. package/src/components/UserSettingsForm.tsx +0 -904
  269. package/src/components/VerifyEmailPage.tsx +0 -222
  270. package/src/components/__tests__/RegisterForm.totp.spec.tsx +0 -377
  271. package/src/components/__tests__/TotpSetupForm.spec.tsx +0 -258
  272. package/src/components/__tests__/TotpVerificationForm.spec.tsx +0 -259
  273. package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +0 -396
  274. package/src/contexts/AuthProvider.spec.tsx +0 -1284
  275. package/src/contexts/AuthProvider.tsx +0 -977
  276. package/src/contexts/I18nProvider.tsx +0 -164
  277. package/src/contexts/MenuContext.tsx +0 -426
  278. package/src/contexts/SuiteConfigProvider.tsx +0 -93
  279. package/src/contexts/ThemeProvider.tsx +0 -67
  280. package/src/hooks/useAuthenticatedApi.tsx +0 -67
  281. package/src/hooks/useBackupCodes.ts +0 -105
  282. package/src/hooks/useEmailVerification.ts +0 -54
  283. package/src/hooks/useExpiringValue.ts +0 -78
  284. package/src/hooks/useLocalStorage.ts +0 -18
  285. package/src/hooks/useUserSettings.ts +0 -271
  286. package/src/interfaces/IAppConfig.ts +0 -7
  287. package/src/interfaces/ICategoryConfig.ts +0 -41
  288. package/src/interfaces/IMenuConfig.ts +0 -28
  289. package/src/interfaces/IMenuOption.ts +0 -79
  290. package/src/services/__mocks__/authService.ts +0 -14
  291. package/src/services/__tests__/authService.totp.property.spec.ts +0 -360
  292. package/src/services/__tests__/authService.totp.spec.ts +0 -439
  293. package/src/services/api.ts +0 -13
  294. package/src/services/authService.ts +0 -692
  295. package/src/services/authenticatedApi.ts +0 -17
  296. package/src/services/index.ts +0 -3
  297. package/src/types/MenuType.ts +0 -15
  298. package/src/types/expirationSeconds.ts +0 -18
  299. package/src/types/index.ts +0 -1
  300. package/src/types/translation.ts +0 -20
  301. package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -34
  302. package/src/wrappers/BackupCodesWrapper.tsx +0 -28
  303. package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -34
  304. package/src/wrappers/ForgotPasswordFormWrapper.tsx +0 -45
  305. package/src/wrappers/LoginFormWrapper.tsx +0 -108
  306. package/src/wrappers/LogoutPageWrapper.tsx +0 -30
  307. package/src/wrappers/RegisterFormWrapper.tsx +0 -109
  308. package/src/wrappers/ResetPasswordFormWrapper.tsx +0 -57
  309. package/src/wrappers/UserSettingsFormWrapper.tsx +0 -140
  310. package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
  311. package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +0 -339
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserSettingsFormWrapper = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const UserSettingsForm_1 = require("../components/UserSettingsForm");
7
+ const contexts_1 = require("../contexts");
8
+ const hooks_1 = require("../hooks");
9
+ const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
10
+ const authService_1 = require("../services/authService");
11
+ const authenticatedApi_1 = require("../services/authenticatedApi");
12
+ const UserSettingsFormWrapper = ({ onSuccess, constants, eciesConfig, emailDomain = '', totpAvailable = false, componentProps = {}, }) => {
13
+ const { settings, updateSettings } = (0, hooks_1.useUserSettingsPublic)();
14
+ const { languages, baseUrl } = (0, contexts_1.useSuiteConfig)();
15
+ // Fetch totpEnabled from the settings API
16
+ const [totpEnabled, setTotpEnabled] = (0, react_1.useState)(undefined);
17
+ const authenticatedApi = (0, react_1.useMemo)(() => (0, authenticatedApi_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
18
+ const authService = (0, react_1.useMemo)(() => {
19
+ if (!constants || !eciesConfig)
20
+ return null;
21
+ return (0, authService_1.createAuthService)(constants, baseUrl, eciesConfig, emailDomain);
22
+ }, [constants, eciesConfig, baseUrl, emailDomain]);
23
+ // Fetch totpEnabled from GET /user/settings.
24
+ // We gate on totpAvailable (no point fetching if TOTP isn't enabled on this
25
+ // deployment) but NOT on isAuthenticated — isAuthenticated can be false
26
+ // transiently (e.g. verify 403 on page refresh with a stale token) even
27
+ // when the user has a valid session token in localStorage. The
28
+ // authenticatedApi interceptor attaches the token automatically; if the
29
+ // call fails we leave totpEnabled undefined so no TOTP controls are shown.
30
+ (0, react_1.useEffect)(() => {
31
+ if (!totpAvailable)
32
+ return;
33
+ authenticatedApi
34
+ .get('/user/settings')
35
+ .then((res) => {
36
+ setTotpEnabled(res.data?.settings?.totpEnabled ?? false);
37
+ })
38
+ .catch(() => {
39
+ // If the endpoint fails, leave totpEnabled undefined (no TOTP controls shown)
40
+ });
41
+ }, [totpAvailable, authenticatedApi]);
42
+ const handleSubmit = async (values) => {
43
+ const result = await updateSettings(values);
44
+ if ('success' in result && result.success && onSuccess) {
45
+ onSuccess();
46
+ }
47
+ return result;
48
+ };
49
+ // TOTP callbacks — only wired when authService is available
50
+ const handleTotpSetup = (0, react_1.useCallback)(async () => {
51
+ if (!authService)
52
+ return { error: 'AuthService not configured' };
53
+ return authService.setupTotp();
54
+ }, [authService]);
55
+ const handleTotpConfirm = (0, react_1.useCallback)(async (code) => {
56
+ if (!authService)
57
+ return { error: 'AuthService not configured' };
58
+ const result = await authService.confirmTotp(code);
59
+ if ('success' in result && result.success) {
60
+ setTotpEnabled(true);
61
+ }
62
+ return result;
63
+ }, [authService]);
64
+ const handleTotpDisable = (0, react_1.useCallback)(async (code) => {
65
+ if (!authService)
66
+ return { error: 'AuthService not configured' };
67
+ const result = await authService.disableTotp(code);
68
+ if ('success' in result && result.success) {
69
+ setTotpEnabled(false);
70
+ }
71
+ return result;
72
+ }, [authService]);
73
+ const handleTotpReset = (0, react_1.useCallback)(async (code) => {
74
+ if (!authService)
75
+ return { error: 'AuthService not configured' };
76
+ return authService.resetTotp(code);
77
+ }, [authService]);
78
+ // Only show loading on initial load, not during updates
79
+ // Once we have settings, keep showing the form even during updates
80
+ if (!settings) {
81
+ return (0, jsx_runtime_1.jsxs)("div", { children: [(0, suite_core_lib_1.getSuiteCoreTranslation)(suite_core_lib_1.SuiteCoreStringKey.Common_Loading), "..."] });
82
+ }
83
+ // Only pass TOTP props when totpAvailable is true, authService is available, and totpEnabled has been fetched
84
+ const totpProps = totpAvailable && authService && totpEnabled !== undefined
85
+ ? {
86
+ totpEnabled,
87
+ onTotpSetup: handleTotpSetup,
88
+ onTotpConfirm: handleTotpConfirm,
89
+ onTotpDisable: handleTotpDisable,
90
+ onTotpReset: handleTotpReset,
91
+ }
92
+ : {};
93
+ return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: settings, onSubmit: handleSubmit, languages: languages, ...totpProps, ...componentProps }));
94
+ };
95
+ exports.UserSettingsFormWrapper = UserSettingsFormWrapper;
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { VerifyEmailPage } from '../components/VerifyEmailPage';
3
+ export interface VerifyEmailPageWrapperProps {
4
+ onSuccess?: () => void;
5
+ componentProps?: Partial<React.ComponentProps<typeof VerifyEmailPage>>;
6
+ }
7
+ export declare const VerifyEmailPageWrapper: FC<VerifyEmailPageWrapperProps>;
8
+ //# sourceMappingURL=VerifyEmailPageWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerifyEmailPageWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/VerifyEmailPageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAiBlE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerifyEmailPageWrapper = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const VerifyEmailPage_1 = require("../components/VerifyEmailPage");
7
+ const hooks_1 = require("../hooks");
8
+ const VerifyEmailPageWrapper = ({ onSuccess, componentProps = {}, }) => {
9
+ const searchParams = new URLSearchParams(window.location.search);
10
+ const token = searchParams.get('token');
11
+ const { verifyEmail } = (0, hooks_1.useEmailVerification)();
12
+ const handleVerify = (0, react_1.useCallback)(async (verificationToken) => {
13
+ const result = await verifyEmail(verificationToken);
14
+ if (result.success && onSuccess) {
15
+ onSuccess();
16
+ }
17
+ return result;
18
+ }, [verifyEmail, onSuccess]);
19
+ return (0, jsx_runtime_1.jsx)(VerifyEmailPage_1.VerifyEmailPage, { token: token, onVerify: handleVerify, ...componentProps });
20
+ };
21
+ exports.VerifyEmailPageWrapper = VerifyEmailPageWrapper;
@@ -1,30 +1,21 @@
1
- // Re-export all wrapper components from their individual files
2
1
  export { BackupCodeLoginWrapper } from './BackupCodeLoginWrapper';
3
2
  export type { BackupCodeLoginWrapperProps } from './BackupCodeLoginWrapper';
4
-
5
3
  export { BackupCodesWrapper } from './BackupCodesWrapper';
6
4
  export type { BackupCodesWrapperProps } from './BackupCodesWrapper';
7
-
8
5
  export { ChangePasswordFormWrapper } from './ChangePasswordFormWrapper';
9
6
  export type { ChangePasswordFormWrapperProps } from './ChangePasswordFormWrapper';
10
-
11
7
  export { ForgotPasswordFormWrapper } from './ForgotPasswordFormWrapper';
12
8
  export type { ForgotPasswordFormWrapperProps } from './ForgotPasswordFormWrapper';
13
-
14
9
  export { LoginFormWrapper } from './LoginFormWrapper';
15
10
  export type { LoginFormWrapperProps } from './LoginFormWrapper';
16
-
17
11
  export { RegisterFormWrapper } from './RegisterFormWrapper';
18
12
  export type { RegisterFormWrapperProps } from './RegisterFormWrapper';
19
-
20
13
  export { ResetPasswordFormWrapper } from './ResetPasswordFormWrapper';
21
14
  export type { ResetPasswordFormWrapperProps } from './ResetPasswordFormWrapper';
22
-
23
15
  export { LogoutPageWrapper } from './LogoutPageWrapper';
24
16
  export type { LogoutPageWrapperProps } from './LogoutPageWrapper';
25
-
26
17
  export { VerifyEmailPageWrapper } from './VerifyEmailPageWrapper';
27
18
  export type { VerifyEmailPageWrapperProps } from './VerifyEmailPageWrapper';
28
-
29
19
  export { UserSettingsFormWrapper } from './UserSettingsFormWrapper';
30
20
  export type { UserSettingsFormWrapperProps } from './UserSettingsFormWrapper';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserSettingsFormWrapper = exports.VerifyEmailPageWrapper = exports.LogoutPageWrapper = exports.ResetPasswordFormWrapper = exports.RegisterFormWrapper = exports.LoginFormWrapper = exports.ForgotPasswordFormWrapper = exports.ChangePasswordFormWrapper = exports.BackupCodesWrapper = exports.BackupCodeLoginWrapper = void 0;
4
+ // Re-export all wrapper components from their individual files
5
+ var BackupCodeLoginWrapper_1 = require("./BackupCodeLoginWrapper");
6
+ Object.defineProperty(exports, "BackupCodeLoginWrapper", { enumerable: true, get: function () { return BackupCodeLoginWrapper_1.BackupCodeLoginWrapper; } });
7
+ var BackupCodesWrapper_1 = require("./BackupCodesWrapper");
8
+ Object.defineProperty(exports, "BackupCodesWrapper", { enumerable: true, get: function () { return BackupCodesWrapper_1.BackupCodesWrapper; } });
9
+ var ChangePasswordFormWrapper_1 = require("./ChangePasswordFormWrapper");
10
+ Object.defineProperty(exports, "ChangePasswordFormWrapper", { enumerable: true, get: function () { return ChangePasswordFormWrapper_1.ChangePasswordFormWrapper; } });
11
+ var ForgotPasswordFormWrapper_1 = require("./ForgotPasswordFormWrapper");
12
+ Object.defineProperty(exports, "ForgotPasswordFormWrapper", { enumerable: true, get: function () { return ForgotPasswordFormWrapper_1.ForgotPasswordFormWrapper; } });
13
+ var LoginFormWrapper_1 = require("./LoginFormWrapper");
14
+ Object.defineProperty(exports, "LoginFormWrapper", { enumerable: true, get: function () { return LoginFormWrapper_1.LoginFormWrapper; } });
15
+ var RegisterFormWrapper_1 = require("./RegisterFormWrapper");
16
+ Object.defineProperty(exports, "RegisterFormWrapper", { enumerable: true, get: function () { return RegisterFormWrapper_1.RegisterFormWrapper; } });
17
+ var ResetPasswordFormWrapper_1 = require("./ResetPasswordFormWrapper");
18
+ Object.defineProperty(exports, "ResetPasswordFormWrapper", { enumerable: true, get: function () { return ResetPasswordFormWrapper_1.ResetPasswordFormWrapper; } });
19
+ var LogoutPageWrapper_1 = require("./LogoutPageWrapper");
20
+ Object.defineProperty(exports, "LogoutPageWrapper", { enumerable: true, get: function () { return LogoutPageWrapper_1.LogoutPageWrapper; } });
21
+ var VerifyEmailPageWrapper_1 = require("./VerifyEmailPageWrapper");
22
+ Object.defineProperty(exports, "VerifyEmailPageWrapper", { enumerable: true, get: function () { return VerifyEmailPageWrapper_1.VerifyEmailPageWrapper; } });
23
+ var UserSettingsFormWrapper_1 = require("./UserSettingsFormWrapper");
24
+ Object.defineProperty(exports, "UserSettingsFormWrapper", { enumerable: true, get: function () { return UserSettingsFormWrapper_1.UserSettingsFormWrapper; } });
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Digital Defiance, Jessica Mulein
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,54 +0,0 @@
1
- import { FC, ReactNode, useContext } from 'react';
2
- import { Navigate, useLocation } from 'react-router';
3
- import { AuthContext } from '../contexts/AuthProvider';
4
- import { useI18n } from '../contexts';
5
- import {
6
- SuiteCoreComponentId,
7
- SuiteCoreStringKey,
8
- SuiteCoreStringKeyValue,
9
- } from '@digitaldefiance/suite-core-lib';
10
- import { useAuth } from '../contexts/AuthProvider';
11
-
12
- interface AdminRouteProps {
13
- children: ReactNode;
14
- redirectTo?: string;
15
- }
16
-
17
- export const AdminRoute: FC<AdminRouteProps> = ({ children, redirectTo }) => {
18
- const { admin } = useAuth();
19
- const { tComponent } = useI18n();
20
- const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
21
- const location = useLocation();
22
-
23
- if (isCheckingAuth) {
24
- return (
25
- <div>
26
- {tComponent<SuiteCoreStringKeyValue>(
27
- SuiteCoreComponentId,
28
- SuiteCoreStringKey.Common_CheckingAuthentication
29
- )}
30
- ...
31
- </div>
32
- );
33
- }
34
-
35
- if (!isAuthenticated) {
36
- return (
37
- <Navigate
38
- to={redirectTo ?? '/login'}
39
- state={{ from: location }}
40
- replace
41
- />
42
- );
43
- }
44
-
45
- if (!admin) {
46
- return (
47
- <Navigate to={redirectTo ?? '/'} state={{ from: location }} replace />
48
- );
49
- }
50
-
51
- return <>{children}</>;
52
- };
53
-
54
- export default AdminRoute;
@@ -1,17 +0,0 @@
1
- import { FC, ReactNode, useContext } from 'react';
2
- import { AuthContext } from '../contexts/AuthProvider';
3
- export interface PrivateProps {
4
- children: ReactNode;
5
- }
6
-
7
- export const Private: FC<PrivateProps> = ({
8
- children,
9
- }) => {
10
- const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
11
-
12
- if (isCheckingAuth || !isAuthenticated) {
13
- return <></>;
14
- }
15
-
16
- return <>{children}</>;
17
- };
@@ -1,28 +0,0 @@
1
- import { FC, ReactNode, useContext } from 'react';
2
- import { Navigate, useLocation } from 'react-router';
3
- import { AuthContext } from '../contexts/AuthProvider';
4
- import { useI18n } from '../contexts';
5
- import { SuiteCoreComponentId, SuiteCoreStringKey, SuiteCoreStringKeyValue } from '@digitaldefiance/suite-core-lib';
6
-
7
- interface PrivateRouteProps {
8
- children: ReactNode;
9
- redirectTo?: string;
10
- }
11
-
12
- export const PrivateRoute: FC<PrivateRouteProps> = ({ children, redirectTo }) => {
13
- const { tComponent } = useI18n();
14
- const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
15
- const location = useLocation();
16
-
17
- if (isCheckingAuth) {
18
- return <div>{tComponent<SuiteCoreStringKeyValue>(SuiteCoreComponentId, SuiteCoreStringKey.Common_CheckingAuthentication)}...</div>;
19
- }
20
-
21
- if (!isAuthenticated) {
22
- return <Navigate to={redirectTo ?? "/login"} state={{ from: location }} replace />;
23
- }
24
-
25
- return <>{children}</>;
26
- };
27
-
28
- export default PrivateRoute;
@@ -1,16 +0,0 @@
1
- import { FC, ReactNode, useContext } from 'react';
2
- import { AuthContext } from '../contexts/AuthProvider';
3
-
4
- export interface UnAuthProps {
5
- children: ReactNode;
6
- }
7
-
8
- export const UnAuth: FC<UnAuthProps> = ({ children }) => {
9
- const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
10
-
11
- if (isCheckingAuth || isAuthenticated) {
12
- return null;
13
- }
14
-
15
- return <>{children}</>;
16
- };
@@ -1,30 +0,0 @@
1
- import { FC, ReactNode, useContext } from 'react';
2
- import { Navigate, useLocation } from 'react-router';
3
- import { AuthContext, useI18n } from '../contexts';
4
- import { SuiteCoreComponentId, SuiteCoreStringKey, SuiteCoreStringKeyValue } from '@digitaldefiance/suite-core-lib';
5
-
6
- export interface UnAuthRouteProps {
7
- children: ReactNode;
8
- redirectTo?: string;
9
- }
10
-
11
- export const UnAuthRoute: FC<UnAuthRouteProps> = ({
12
- children,
13
- redirectTo = '/dashboard',
14
- }) => {
15
- const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
16
- const { tComponent } = useI18n();
17
- const location = useLocation();
18
-
19
- if (isCheckingAuth) {
20
- return <div>{tComponent<SuiteCoreStringKeyValue>(SuiteCoreComponentId, SuiteCoreStringKey.Common_CheckingAuthentication)}...</div>;
21
- }
22
-
23
- if (isAuthenticated) {
24
- return <Navigate to={redirectTo ?? "/dashboard"} state={{ from: location }} replace />;
25
- }
26
-
27
- return <>{children}</>;
28
- };
29
-
30
- export default UnAuthRoute;
@@ -1,175 +0,0 @@
1
- import {
2
- SuiteCoreComponentId,
3
- SuiteCoreStringKey,
4
- SuiteCoreStringKeyValue,
5
- } from '@digitaldefiance/suite-core-lib';
6
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
7
- import {
8
- Box,
9
- Button,
10
- Dialog,
11
- DialogActions,
12
- DialogContent,
13
- DialogTitle,
14
- styled,
15
- TextField,
16
- Typography,
17
- } from '@mui/material';
18
- import { FC, useState } from 'react';
19
- import { useAuth, useI18n } from '../contexts';
20
-
21
- const ApiAccessContainer = styled(Box)(({ theme }) => ({
22
- display: 'flex',
23
- flexDirection: 'column',
24
- alignItems: 'center',
25
- justifyContent: 'center',
26
- minHeight: '100vh',
27
- backgroundColor: theme.palette.background.default,
28
- padding: theme.spacing(3),
29
- }));
30
-
31
- const ApiAccessContent = styled(Box)(({ theme }) => ({
32
- maxWidth: '600px',
33
- width: '100%',
34
- backgroundColor: theme.palette.background.paper,
35
- borderRadius: theme.shape.borderRadius,
36
- padding: theme.spacing(4),
37
- boxShadow: theme.shadows[3],
38
- }));
39
-
40
- const ApiAccessTitle = styled(Typography)(({ theme }) => ({
41
- marginBottom: theme.spacing(3),
42
- color: theme.palette.primary.main,
43
- }));
44
-
45
- export interface ApiAccessProps {
46
- token?: string | null;
47
- labels?: {
48
- title?: string;
49
- tokenNotAvailable?: string;
50
- copyButton?: string;
51
- notificationTitle?: string;
52
- copied?: string;
53
- copyFailed?: string;
54
- ok?: string;
55
- };
56
- }
57
-
58
- export const ApiAccess: FC<ApiAccessProps> = ({
59
- token: tokenProp,
60
- labels = {},
61
- }) => {
62
- const { token: authToken } = useAuth();
63
- const token = tokenProp !== undefined ? tokenProp : authToken;
64
- const { tComponent } = useI18n();
65
- const [dialogOpen, setDialogOpen] = useState(false);
66
- const [isError, setIsError] = useState(false);
67
-
68
- const translatedLabels = {
69
- title:
70
- labels.title ||
71
- tComponent<SuiteCoreStringKeyValue>(
72
- SuiteCoreComponentId,
73
- SuiteCoreStringKey.ApiAccess_Title
74
- ),
75
- tokenNotAvailable:
76
- labels.tokenNotAvailable ||
77
- tComponent<SuiteCoreStringKeyValue>(
78
- SuiteCoreComponentId,
79
- SuiteCoreStringKey.ApiAccess_TokenNotAvailable
80
- ),
81
- copyButton:
82
- labels.copyButton ||
83
- tComponent<SuiteCoreStringKeyValue>(
84
- SuiteCoreComponentId,
85
- SuiteCoreStringKey.Common_CopyToClipboard
86
- ),
87
- notificationTitle:
88
- labels.notificationTitle ||
89
- tComponent<SuiteCoreStringKeyValue>(
90
- SuiteCoreComponentId,
91
- SuiteCoreStringKey.Common_Notification
92
- ),
93
- copied:
94
- labels.copied ||
95
- tComponent<SuiteCoreStringKeyValue>(
96
- SuiteCoreComponentId,
97
- SuiteCoreStringKey.Common_CopiedToClipboard
98
- ),
99
- copyFailed:
100
- labels.copyFailed ||
101
- tComponent<SuiteCoreStringKeyValue>(
102
- SuiteCoreComponentId,
103
- SuiteCoreStringKey.Error_FailedToCopy
104
- ),
105
- ok:
106
- labels.ok ||
107
- tComponent<SuiteCoreStringKeyValue>(
108
- SuiteCoreComponentId,
109
- SuiteCoreStringKey.Common_OK
110
- ),
111
- };
112
-
113
- const copyToClipboard = async () => {
114
- if (token) {
115
- try {
116
- await navigator.clipboard.writeText(token);
117
- setIsError(false);
118
- setDialogOpen(true);
119
- } catch {
120
- setIsError(true);
121
- }
122
- }
123
- };
124
-
125
- const handleClose = () => {
126
- setDialogOpen(false);
127
- setIsError(false);
128
- };
129
-
130
- return (
131
- <ApiAccessContainer>
132
- <ApiAccessContent>
133
- <ApiAccessTitle variant="h4" align="center">
134
- {translatedLabels.title}
135
- </ApiAccessTitle>
136
- <TextField
137
- fullWidth
138
- multiline
139
- rows={4}
140
- value={token || translatedLabels.tokenNotAvailable}
141
- slotProps={{
142
- input: {
143
- readOnly: true,
144
- },
145
- }}
146
- variant="outlined"
147
- margin="normal"
148
- />
149
- <Button
150
- variant="contained"
151
- color="primary"
152
- startIcon={<ContentCopyIcon />}
153
- onClick={copyToClipboard}
154
- fullWidth
155
- style={{ marginTop: '16px' }}
156
- >
157
- {translatedLabels.copyButton}
158
- </Button>
159
- </ApiAccessContent>
160
- <Dialog open={dialogOpen} onClose={handleClose}>
161
- <DialogTitle>{translatedLabels.notificationTitle}</DialogTitle>
162
- <DialogContent>
163
- {isError ? translatedLabels.copyFailed : translatedLabels.copied}
164
- </DialogContent>
165
- <DialogActions>
166
- <Button onClick={handleClose} color="primary">
167
- {translatedLabels.ok}
168
- </Button>
169
- </DialogActions>
170
- </Dialog>
171
- </ApiAccessContainer>
172
- );
173
- };
174
-
175
- export default ApiAccess;