@elliemae/pui-app-sdk 5.42.3 → 5.42.5

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 (245) hide show
  1. package/build/docs/404.html +2 -2
  2. package/build/docs/api/classes/Analytics/index.html +2 -2
  3. package/build/docs/api/classes/CMicroAppGuest/index.html +2 -2
  4. package/build/docs/api/classes/CMicroAppHost/index.html +2 -2
  5. package/build/docs/api/classes/ErrorBoundary/index.html +2 -2
  6. package/build/docs/api/classes/GuestModule/index.html +2 -2
  7. package/build/docs/api/functions/AppRoot/index.html +2 -2
  8. package/build/docs/api/functions/Autocomplete/index.html +2 -2
  9. package/build/docs/api/functions/CheckBox/index.html +2 -2
  10. package/build/docs/api/functions/ComboBox/index.html +2 -2
  11. package/build/docs/api/functions/ComboBoxV3/index.html +2 -2
  12. package/build/docs/api/functions/ConnectForm/index.html +2 -2
  13. package/build/docs/api/functions/DateInput/index.html +2 -2
  14. package/build/docs/api/functions/DatePicker/index.html +2 -2
  15. package/build/docs/api/functions/DateRangePicker/index.html +2 -2
  16. package/build/docs/api/functions/DateTimePicker/index.html +2 -2
  17. package/build/docs/api/functions/Form/index.html +2 -2
  18. package/build/docs/api/functions/FormItemLayout/index.html +2 -2
  19. package/build/docs/api/functions/FormLayoutBlockItem/index.html +2 -2
  20. package/build/docs/api/functions/FormSubmitButton/index.html +2 -2
  21. package/build/docs/api/functions/InputMask/index.html +2 -2
  22. package/build/docs/api/functions/InputText/index.html +2 -2
  23. package/build/docs/api/functions/LargeTextBox/index.html +2 -2
  24. package/build/docs/api/functions/MaskedInputText/index.html +2 -2
  25. package/build/docs/api/functions/Page/index.html +2 -2
  26. package/build/docs/api/functions/Radio/index.html +2 -2
  27. package/build/docs/api/functions/RadioGroup/index.html +2 -2
  28. package/build/docs/api/functions/RegisterService/index.html +2 -2
  29. package/build/docs/api/functions/RenderWithStateAddOns/index.html +2 -2
  30. package/build/docs/api/functions/RequireAuth/index.html +2 -2
  31. package/build/docs/api/functions/SessionTimeout/index.html +2 -2
  32. package/build/docs/api/functions/TextBox/index.html +2 -2
  33. package/build/docs/api/functions/Toggle/index.html +2 -2
  34. package/build/docs/api/functions/authSaga/index.html +2 -2
  35. package/build/docs/api/functions/authorize/index.html +2 -2
  36. package/build/docs/api/functions/buildModuleParams/index.html +2 -2
  37. package/build/docs/api/functions/cleanup/index.html +2 -2
  38. package/build/docs/api/functions/configureStore/index.html +2 -2
  39. package/build/docs/api/functions/createGuestModule/index.html +2 -2
  40. package/build/docs/api/functions/createManager/index.html +2 -2
  41. package/build/docs/api/functions/enableReactAppForHostIntegration/index.html +2 -2
  42. package/build/docs/api/functions/fetchHostAppData/index.html +2 -2
  43. package/build/docs/api/functions/fetchUserSettings/index.html +2 -2
  44. package/build/docs/api/functions/getApiActionCreator/index.html +2 -2
  45. package/build/docs/api/functions/getAppConfig/index.html +2 -2
  46. package/build/docs/api/functions/getAppConfigValue/index.html +2 -2
  47. package/build/docs/api/functions/getAuthHTTPClient/index.html +2 -2
  48. package/build/docs/api/functions/getAuthorizationHeader/index.html +2 -2
  49. package/build/docs/api/functions/getHTTPClient/index.html +2 -2
  50. package/build/docs/api/functions/getHostAppDataByKey/index.html +2 -2
  51. package/build/docs/api/functions/getLogger/index.html +2 -2
  52. package/build/docs/api/functions/getMicroFrontEndAppConfig/index.html +2 -2
  53. package/build/docs/api/functions/getNavigationLinks/index.html +2 -2
  54. package/build/docs/api/functions/getRedirectUrl/index.html +2 -2
  55. package/build/docs/api/functions/getSelectField/index.html +2 -2
  56. package/build/docs/api/functions/getStore/index.html +2 -2
  57. package/build/docs/api/functions/initServiceWorker/index.html +2 -2
  58. package/build/docs/api/functions/isCIBuild/index.html +2 -2
  59. package/build/docs/api/functions/isProd/index.html +2 -2
  60. package/build/docs/api/functions/isUserAuthorized/index.html +2 -2
  61. package/build/docs/api/functions/listenStorageEvents/index.html +2 -2
  62. package/build/docs/api/functions/loadAppConfig/index.html +2 -2
  63. package/build/docs/api/functions/loadable/index.html +2 -2
  64. package/build/docs/api/functions/login/index.html +2 -2
  65. package/build/docs/api/functions/notifyGuestUnloadComplete/index.html +2 -2
  66. package/build/docs/api/functions/onAuthorizationFailure/index.html +2 -2
  67. package/build/docs/api/functions/onGuestUnloadStart/index.html +2 -2
  68. package/build/docs/api/functions/redactPii/index.html +2 -2
  69. package/build/docs/api/functions/removeDoubleSlash/index.html +2 -2
  70. package/build/docs/api/functions/removeStorageEvents/index.html +2 -2
  71. package/build/docs/api/functions/render/index.html +2 -2
  72. package/build/docs/api/functions/renderHook/index.html +2 -2
  73. package/build/docs/api/functions/renderWithHostData/index.html +2 -2
  74. package/build/docs/api/functions/renderWithRedux/index.html +2 -2
  75. package/build/docs/api/functions/renderWithRouter/index.html +2 -2
  76. package/build/docs/api/functions/renderWithRouterRedux/index.html +2 -2
  77. package/build/docs/api/functions/sdkBaseQuery/index.html +2 -2
  78. package/build/docs/api/functions/sendBAEvent/index.html +2 -2
  79. package/build/docs/api/functions/sendMessageToHost/index.html +2 -2
  80. package/build/docs/api/functions/setAppConfig/index.html +2 -2
  81. package/build/docs/api/functions/setAppConfigValue/index.html +2 -2
  82. package/build/docs/api/functions/setHostAppData/index.html +2 -2
  83. package/build/docs/api/functions/setLoginParams/index.html +2 -2
  84. package/build/docs/api/functions/subscribeToResetSession/index.html +7 -10
  85. package/build/docs/api/functions/subscribeToSessionExpiry/index.html +7 -10
  86. package/build/docs/api/functions/subscribeToSessionExpiryWarning/index.html +7 -10
  87. package/build/docs/api/functions/trackActivity/index.html +9 -11
  88. package/build/docs/api/functions/useAppDispatch/index.html +2 -2
  89. package/build/docs/api/functions/useAppMiddleware/index.html +2 -2
  90. package/build/docs/api/functions/useInjectQuery/index.html +2 -2
  91. package/build/docs/api/functions/useInjectReducer/index.html +2 -2
  92. package/build/docs/api/functions/useInjectSaga/index.html +2 -2
  93. package/build/docs/api/functions/useInjectSideEffect/index.html +2 -2
  94. package/build/docs/api/functions/useMediaQueryList/index.html +2 -2
  95. package/build/docs/api/functions/useStateSelector/index.html +2 -2
  96. package/build/docs/api/functions/useStateSelectorShallow/index.html +2 -2
  97. package/build/docs/api/functions/waitFor/index.html +2 -2
  98. package/build/docs/api/functions/waitForElementToBeRemoved/index.html +2 -2
  99. package/build/docs/api/functions/withAppDecorator/index.html +2 -2
  100. package/build/docs/api/index.html +4 -4
  101. package/build/docs/api/interfaces/AppConfig/index.html +2 -2
  102. package/build/docs/api/interfaces/GuestProps/index.html +2 -2
  103. package/build/docs/api/interfaces/UseStateSelectorOptions/index.html +2 -2
  104. package/build/docs/api/type-aliases/AppDispatch/index.html +2 -2
  105. package/build/docs/api/type-aliases/AppStore/index.html +2 -2
  106. package/build/docs/api/type-aliases/Await/index.html +2 -2
  107. package/build/docs/api/type-aliases/EMUI/index.html +2 -2
  108. package/build/docs/api/type-aliases/HostOptions/index.html +2 -2
  109. package/build/docs/api/type-aliases/HostProvidedParams/index.html +2 -2
  110. package/build/docs/api/type-aliases/ModuleOverrides/index.html +2 -2
  111. package/build/docs/api/type-aliases/OnHostInitCallback/index.html +2 -2
  112. package/build/docs/api/type-aliases/OnInitCallback/index.html +2 -2
  113. package/build/docs/api/type-aliases/OnMountCallback/index.html +2 -2
  114. package/build/docs/api/type-aliases/OnUnMountCallback/index.html +2 -2
  115. package/build/docs/api/type-aliases/RootState/index.html +2 -2
  116. package/build/docs/api/type-aliases/SelectStateFieldFunction/index.html +2 -2
  117. package/build/docs/api/variables/ErrorToast/index.html +2 -2
  118. package/build/docs/api/variables/FormPropsContext/index.html +2 -2
  119. package/build/docs/api/variables/GuestMicroApp/index.html +2 -2
  120. package/build/docs/api/variables/MASK_PIPES/index.html +2 -2
  121. package/build/docs/api/variables/MASK_TYPES/index.html +2 -2
  122. package/build/docs/api/variables/MicroApp/index.html +2 -2
  123. package/build/docs/api/variables/MicroIFrameApp/index.html +2 -2
  124. package/build/docs/api/variables/NavigationPrompt/index.html +2 -2
  125. package/build/docs/api/variables/NavigationPromptActions/index.html +2 -2
  126. package/build/docs/api/variables/Themes/index.html +2 -2
  127. package/build/docs/api/variables/VisuallyHidden/index.html +2 -2
  128. package/build/docs/api/variables/WaitMessage/index.html +2 -2
  129. package/build/docs/api/variables/act/index.html +2 -2
  130. package/build/docs/api/variables/ariaLive/index.html +2 -2
  131. package/build/docs/api/variables/auth/index.html +2 -2
  132. package/build/docs/api/variables/authReducer/index.html +2 -2
  133. package/build/docs/api/variables/clearSideEffects/index.html +2 -2
  134. package/build/docs/api/variables/createSideEffect/index.html +2 -2
  135. package/build/docs/api/variables/decorators/index.html +2 -2
  136. package/build/docs/api/variables/endSession/index.html +2 -2
  137. package/build/docs/api/variables/error/index.html +2 -2
  138. package/build/docs/api/variables/errorMiddleware/index.html +2 -2
  139. package/build/docs/api/variables/fireEvent/index.html +2 -2
  140. package/build/docs/api/variables/globalConstants/index.html +2 -2
  141. package/build/docs/api/variables/history/index.html +2 -2
  142. package/build/docs/api/variables/httpClientProps/index.html +2 -2
  143. package/build/docs/api/variables/logout/index.html +2 -2
  144. package/build/docs/api/variables/memoryHistory/index.html +2 -2
  145. package/build/docs/api/variables/removeSideEffect/index.html +2 -2
  146. package/build/docs/api/variables/resetUserIdleTime/index.html +8 -8
  147. package/build/docs/api/variables/screen/index.html +2 -2
  148. package/build/docs/api/variables/startSideEffect/index.html +2 -2
  149. package/build/docs/api/variables/updateBAEventParameters/index.html +2 -2
  150. package/build/docs/api/variables/useAppSelector/index.html +2 -2
  151. package/build/docs/api/variables/waitMessageAction/index.html +2 -2
  152. package/build/docs/api/variables/within/index.html +2 -2
  153. package/build/docs/assets/js/3cb0b0a9.67b20d88.js +1 -0
  154. package/build/docs/assets/js/{5e8c322a.f1548b2b.js → 5e8c322a.c3cc240b.js} +1 -1
  155. package/build/docs/assets/js/{822e0178.a567065b.js → 822e0178.dfd661b8.js} +1 -1
  156. package/build/docs/assets/js/a0eb976e.77667f42.js +1 -0
  157. package/build/docs/assets/js/c90572d4.0b7362b5.js +1 -0
  158. package/build/docs/assets/js/f4180cff.0f2ce3bf.js +1 -0
  159. package/build/docs/assets/js/fed4ae4f.4cbcd19c.js +1 -0
  160. package/build/docs/assets/js/{main.e2e13725.js → main.1a5a08af.js} +2 -2
  161. package/build/docs/assets/js/{runtime~main.cd750ab4.js → runtime~main.9f7b9b59.js} +1 -1
  162. package/build/docs/index.html +2 -2
  163. package/build/docs/usage-guide/index.html +2 -2
  164. package/demo/{5685.7040bb5c.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +205 -205
  165. package/demo/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
  166. package/demo/9478.1f9d2bf2.iframe.bundle.js.gz +0 -0
  167. package/demo/{1770.ef5c473d.iframe.bundle.js → 9888.bfe9152c.iframe.bundle.js} +8 -8
  168. package/demo/9888.bfe9152c.iframe.bundle.js.br +0 -0
  169. package/demo/9888.bfe9152c.iframe.bundle.js.gz +0 -0
  170. package/demo/docs/{5685.7040bb5c.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +205 -205
  171. package/demo/docs/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
  172. package/demo/docs/9478.1f9d2bf2.iframe.bundle.js.gz +0 -0
  173. package/demo/docs/{1770.ef5c473d.iframe.bundle.js → 9888.bfe9152c.iframe.bundle.js} +8 -8
  174. package/demo/docs/9888.bfe9152c.iframe.bundle.js.br +0 -0
  175. package/demo/docs/9888.bfe9152c.iframe.bundle.js.gz +0 -0
  176. package/demo/docs/iframe.html +1 -1
  177. package/demo/docs/index.html +1 -1
  178. package/demo/docs/main.3ca9a77e.iframe.bundle.js +5 -0
  179. package/demo/docs/main.3ca9a77e.iframe.bundle.js.br +0 -0
  180. package/demo/docs/main.3ca9a77e.iframe.bundle.js.gz +0 -0
  181. package/demo/docs/{main.7644e4ef6d4f1851046c.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
  182. package/demo/docs/{main.7644e4ef6d4f1851046c.manager.bundle.js.br → main.9379efdc5e6f460465e2.manager.bundle.js.br} +0 -0
  183. package/demo/docs/main.9379efdc5e6f460465e2.manager.bundle.js.gz +0 -0
  184. package/demo/docs/project.json +1 -1
  185. package/demo/docs/{runtime~main.d70e75f8.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +1 -1
  186. package/demo/docs/runtime~main.b7f50131.iframe.bundle.js.br +0 -0
  187. package/demo/docs/runtime~main.b7f50131.iframe.bundle.js.gz +0 -0
  188. package/demo/iframe.html +1 -1
  189. package/demo/index.html +1 -1
  190. package/demo/main.3ca9a77e.iframe.bundle.js +5 -0
  191. package/demo/main.3ca9a77e.iframe.bundle.js.br +0 -0
  192. package/demo/main.3ca9a77e.iframe.bundle.js.gz +0 -0
  193. package/demo/{main.7644e4ef6d4f1851046c.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
  194. package/demo/{main.7644e4ef6d4f1851046c.manager.bundle.js.br → main.9379efdc5e6f460465e2.manager.bundle.js.br} +0 -0
  195. package/demo/main.9379efdc5e6f460465e2.manager.bundle.js.gz +0 -0
  196. package/demo/project.json +1 -1
  197. package/demo/{runtime~main.d70e75f8.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +1 -1
  198. package/demo/runtime~main.b7f50131.iframe.bundle.js.br +0 -0
  199. package/demo/runtime~main.b7f50131.iframe.bundle.js.gz +0 -0
  200. package/dist/cjs/utils/page-wake.js +47 -0
  201. package/dist/cjs/utils/session-timeout-config.js +60 -0
  202. package/dist/cjs/utils/session.js +53 -20
  203. package/dist/cjs/view/modals/session-expiry/customHooks.js +20 -24
  204. package/dist/cjs/view/modals/session-expiry/index.js +1 -1
  205. package/dist/esm/utils/page-wake.js +27 -0
  206. package/dist/esm/utils/session-timeout-config.js +40 -0
  207. package/dist/esm/utils/session.js +57 -23
  208. package/dist/esm/view/modals/session-expiry/customHooks.js +23 -24
  209. package/dist/esm/view/modals/session-expiry/index.js +1 -1
  210. package/dist/types/lib/utils/page-wake.d.ts +6 -0
  211. package/dist/types/lib/utils/session-timeout-config.d.ts +6 -0
  212. package/dist/types/lib/utils/session.d.ts +38 -71
  213. package/dist/types/lib/utils/tests/page-wake.test.d.ts +1 -0
  214. package/dist/types/lib/utils/tests/session-idle-guard.test.d.ts +1 -0
  215. package/dist/types/lib/utils/tests/session-timeout-config.test.d.ts +1 -0
  216. package/dist/types/lib/utils/tests/session.test.d.ts +1 -0
  217. package/dist/types/lib/view/modals/session-expiry/tests/customHooks.test.d.ts +1 -0
  218. package/dist/types/tsconfig.tsbuildinfo +1 -1
  219. package/package.json +1 -1
  220. package/build/docs/assets/js/3cb0b0a9.b5efc7a4.js +0 -1
  221. package/build/docs/assets/js/a0eb976e.fc660f60.js +0 -1
  222. package/build/docs/assets/js/c90572d4.71073c5c.js +0 -1
  223. package/build/docs/assets/js/f4180cff.b50f1502.js +0 -1
  224. package/build/docs/assets/js/fed4ae4f.335f00fb.js +0 -1
  225. package/demo/1770.ef5c473d.iframe.bundle.js.br +0 -0
  226. package/demo/1770.ef5c473d.iframe.bundle.js.gz +0 -0
  227. package/demo/5685.7040bb5c.iframe.bundle.js.br +0 -0
  228. package/demo/5685.7040bb5c.iframe.bundle.js.gz +0 -0
  229. package/demo/docs/1770.ef5c473d.iframe.bundle.js.br +0 -0
  230. package/demo/docs/1770.ef5c473d.iframe.bundle.js.gz +0 -0
  231. package/demo/docs/5685.7040bb5c.iframe.bundle.js.br +0 -0
  232. package/demo/docs/5685.7040bb5c.iframe.bundle.js.gz +0 -0
  233. package/demo/docs/main.7644e4ef6d4f1851046c.manager.bundle.js.gz +0 -0
  234. package/demo/docs/main.8b6c74fc.iframe.bundle.js +0 -5
  235. package/demo/docs/main.8b6c74fc.iframe.bundle.js.br +0 -0
  236. package/demo/docs/main.8b6c74fc.iframe.bundle.js.gz +0 -0
  237. package/demo/docs/runtime~main.d70e75f8.iframe.bundle.js.br +0 -0
  238. package/demo/docs/runtime~main.d70e75f8.iframe.bundle.js.gz +0 -0
  239. package/demo/main.7644e4ef6d4f1851046c.manager.bundle.js.gz +0 -0
  240. package/demo/main.8b6c74fc.iframe.bundle.js +0 -5
  241. package/demo/main.8b6c74fc.iframe.bundle.js.br +0 -0
  242. package/demo/main.8b6c74fc.iframe.bundle.js.gz +0 -0
  243. package/demo/runtime~main.d70e75f8.iframe.bundle.js.br +0 -0
  244. package/demo/runtime~main.d70e75f8.iframe.bundle.js.gz +0 -0
  245. /package/build/docs/assets/js/{main.e2e13725.js.LICENSE.txt → main.1a5a08af.js.LICENSE.txt} +0 -0
@@ -22,36 +22,32 @@ __export(customHooks_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(customHooks_exports);
24
24
  var import_react = require("react");
25
- var import_date_fns = require("date-fns");
26
- var import_constants = require("../../../utils/constants.js");
27
- var import_config = require("../../../utils/app-config/config.js");
25
+ var import_page_wake = require("../../../utils/page-wake.js");
26
+ var import_session_timeout_config = require("../../../utils/session-timeout-config.js");
27
+ const formatTimeLeft = (msLeft) => {
28
+ const totalSeconds = Math.max(0, Math.floor(msLeft / 1e3));
29
+ const minutes = Math.floor(totalSeconds / 60);
30
+ const seconds = totalSeconds % 60;
31
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(
32
+ 2,
33
+ "0"
34
+ )}`;
35
+ };
28
36
  const useTrackSessionExpiry = (warningNotifiedAt) => {
29
37
  const [timeData, setTimeData] = (0, import_react.useState)();
30
38
  (0, import_react.useEffect)(() => {
31
- const timeLeftForExpiryAfterWarning = () => {
32
- const userWarnInterval = (0, import_config.getAppConfigValue)(
33
- "sessionTimeoutWarnInterval"
34
- );
35
- const userTimeoutInterval = (0, import_config.getAppConfigValue)(
36
- "sessionTimeoutInterval"
37
- );
38
- const warnInterval = userWarnInterval ? parseFloat(userWarnInterval) : import_constants.SESSION_TIMEOUT_INTERVAL.WARN;
39
- const sessionTimeout = userTimeoutInterval ? parseFloat(userTimeoutInterval) : import_constants.SESSION_TIMEOUT_INTERVAL.EXPIRY;
40
- const diffTime = sessionTimeout - warnInterval;
41
- const sessionExpiresIn = warningNotifiedAt + diffTime;
42
- const seconds = (0, import_date_fns.getSeconds)(sessionExpiresIn - Date.now());
43
- const minutes = (0, import_date_fns.differenceInMinutes)(sessionExpiresIn, Date.now());
44
- return {
45
- seconds: `0${seconds}`.slice(-2),
46
- minutes: `0${minutes}`.slice(-2)
47
- };
39
+ const warnInterval = (0, import_session_timeout_config.getSessionWarnIntervalMs)();
40
+ const sessionTimeout = (0, import_session_timeout_config.getSessionExpiryIntervalMs)();
41
+ const sessionExpiresAt = warningNotifiedAt + (sessionTimeout - warnInterval);
42
+ const updateTimeLeft = () => {
43
+ setTimeData(formatTimeLeft(sessionExpiresAt - Date.now()));
48
44
  };
49
- const interval = setInterval(() => {
50
- const { seconds, minutes } = timeLeftForExpiryAfterWarning();
51
- setTimeData(`${minutes}:${seconds}`);
52
- }, 1e3);
45
+ updateTimeLeft();
46
+ const interval = setInterval(updateTimeLeft, 1e3);
47
+ const removeWakeListener = (0, import_page_wake.subscribeToPageWake)(updateTimeLeft);
53
48
  return () => {
54
49
  clearInterval(interval);
50
+ removeWakeListener();
55
51
  };
56
52
  }, [warningNotifiedAt]);
57
53
  return timeData;
@@ -44,7 +44,7 @@ const SessionExpiry = (0, import_react.memo)(
44
44
  }, [open]);
45
45
  const resetSession = async () => {
46
46
  setIsOpen(false);
47
- await (0, import_session.renewSession)();
47
+ await (0, import_session.renewSession)(true);
48
48
  (0, import_session.addEventListeners)();
49
49
  dispatch(import_actions.logout.cancel());
50
50
  };
@@ -0,0 +1,27 @@
1
+ const subscribeToPageWake = (callback) => {
2
+ let scheduled = false;
3
+ const runCoalesced = () => {
4
+ if (scheduled) return;
5
+ scheduled = true;
6
+ queueMicrotask(() => {
7
+ scheduled = false;
8
+ callback();
9
+ });
10
+ };
11
+ const onVisibilityChange = () => {
12
+ if (!document.hidden) {
13
+ runCoalesced();
14
+ }
15
+ };
16
+ document.addEventListener("visibilitychange", onVisibilityChange);
17
+ window.addEventListener("pageshow", runCoalesced);
18
+ window.addEventListener("focus", runCoalesced);
19
+ return () => {
20
+ document.removeEventListener("visibilitychange", onVisibilityChange);
21
+ window.removeEventListener("pageshow", runCoalesced);
22
+ window.removeEventListener("focus", runCoalesced);
23
+ };
24
+ };
25
+ export {
26
+ subscribeToPageWake
27
+ };
@@ -0,0 +1,40 @@
1
+ import { getAppConfigValue } from "./app-config/config.js";
2
+ import { SESSION_TIMEOUT_INTERVAL } from "./constants.js";
3
+ let cachedWarnIntervalMs;
4
+ let cachedExpiryIntervalMs;
5
+ const resetSessionTimeoutCache = () => {
6
+ cachedWarnIntervalMs = void 0;
7
+ cachedExpiryIntervalMs = void 0;
8
+ };
9
+ const getSessionTimeoutMs = (key, fallback) => {
10
+ const value = getAppConfigValue(key);
11
+ if (value == null || value === "") return fallback;
12
+ const parsed = Number(value);
13
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
14
+ };
15
+ const getSessionWarnIntervalMs = () => {
16
+ if (cachedWarnIntervalMs === void 0) {
17
+ cachedWarnIntervalMs = getSessionTimeoutMs(
18
+ "sessionTimeoutWarnInterval",
19
+ SESSION_TIMEOUT_INTERVAL.WARN
20
+ );
21
+ }
22
+ return cachedWarnIntervalMs;
23
+ };
24
+ const getSessionExpiryIntervalMs = () => {
25
+ if (cachedExpiryIntervalMs === void 0) {
26
+ const warn = getSessionWarnIntervalMs();
27
+ const expiry = getSessionTimeoutMs(
28
+ "sessionTimeoutInterval",
29
+ SESSION_TIMEOUT_INTERVAL.EXPIRY
30
+ );
31
+ cachedExpiryIntervalMs = expiry > warn ? expiry : warn + 1;
32
+ }
33
+ return cachedExpiryIntervalMs;
34
+ };
35
+ export {
36
+ getSessionExpiryIntervalMs,
37
+ getSessionTimeoutMs,
38
+ getSessionWarnIntervalMs,
39
+ resetSessionTimeoutCache
40
+ };
@@ -5,32 +5,50 @@ import { introspectToken } from "../api/auth/index.js";
5
5
  import { getLogger } from "./logger.js";
6
6
  import { logRecords } from "./log-records.js";
7
7
  import { endSession } from "./auth/index.js";
8
- import { getAppConfigValue } from "./app-config/config.js";
8
+ import { SESSION_RENEWAL_INTERVAL } from "./constants.js";
9
+ import { subscribeToPageWake } from "./page-wake.js";
9
10
  import {
10
- SESSION_TIMEOUT_INTERVAL,
11
- SESSION_RENEWAL_INTERVAL
12
- } from "./constants.js";
11
+ getSessionWarnIntervalMs,
12
+ getSessionExpiryIntervalMs,
13
+ resetSessionTimeoutCache
14
+ } from "./session-timeout-config.js";
13
15
  let lastUserActivityTimeStamp = Date.now();
14
16
  const warnListeners = [];
15
17
  const expiryListeners = [];
16
18
  const resetListeners = [];
17
19
  const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
18
20
  let sessionExpiryWarningNotified = false;
21
+ let sessionExpired = false;
19
22
  let timerHandle;
23
+ let removeWakeListener;
20
24
  let sessionExpiryWarningNotifiedAt;
21
- const resetUserIdleTime = (resetWarningModal = false) => {
25
+ const resetIdleStateFlags = () => {
26
+ sessionExpired = false;
22
27
  sessionExpiryWarningNotified = false;
23
28
  sessionExpiryWarningNotifiedAt = null;
29
+ };
30
+ const isPastWarningTime = () => Date.now() - lastUserActivityTimeStamp > getSessionWarnIntervalMs();
31
+ const isPastSessionTimeoutTime = () => Date.now() - lastUserActivityTimeStamp > getSessionExpiryIntervalMs();
32
+ const notifySessionExpiry = () => Promise.resolve().then(() => {
33
+ expiryListeners.forEach((listener) => listener());
34
+ });
35
+ const markUserActive = (resetWarningModal = false) => {
36
+ resetIdleStateFlags();
24
37
  lastUserActivityTimeStamp = Date.now();
25
38
  Promise.resolve().then(() => {
26
39
  resetListeners.forEach((listener) => listener(resetWarningModal));
27
40
  }).catch(() => {
28
41
  });
29
42
  };
30
- const renewSession = async () => {
43
+ const resetUserIdleTime = (resetWarningModal = false) => {
44
+ if (!enforceIdleThresholds(resetWarningModal === true)) return;
45
+ markUserActive(resetWarningModal);
46
+ };
47
+ const renewSession = async (explicit = false) => {
48
+ if (!enforceIdleThresholds(explicit === true)) return;
31
49
  const loginParams = getLoginParams();
32
50
  try {
33
- resetUserIdleTime(true);
51
+ markUserActive(true);
34
52
  if (loginParams?.clientId) {
35
53
  const authToken = getAuthorizationHeader();
36
54
  if (!authToken)
@@ -47,47 +65,57 @@ const renewSession = async () => {
47
65
  }
48
66
  };
49
67
  const renewSessionAtInterval = throttle(
50
- renewSession,
68
+ () => {
69
+ renewSession().catch(() => {
70
+ });
71
+ },
51
72
  SESSION_RENEWAL_INTERVAL,
52
73
  {
53
74
  leading: true
54
75
  }
55
76
  );
56
- const isPastWarningTime = (warnInterval = getAppConfigValue("sessionTimeoutWarnInterval") || SESSION_TIMEOUT_INTERVAL.WARN) => Date.now() - lastUserActivityTimeStamp > warnInterval;
57
- const isPastSessionTimeoutTime = (sessionTimeout = getAppConfigValue("sessionTimeoutInterval") || SESSION_TIMEOUT_INTERVAL.EXPIRY) => Date.now() - lastUserActivityTimeStamp > sessionTimeout;
77
+ const removeActivityEventListeners = () => {
78
+ userInteractionEvents.forEach((eventType) => {
79
+ document.removeEventListener(eventType, renewSessionAtInterval);
80
+ });
81
+ };
58
82
  const notifySessionExpiryWarning = () => {
59
83
  sessionExpiryWarningNotified = true;
60
84
  sessionExpiryWarningNotifiedAt = Date.now();
85
+ removeActivityEventListeners();
61
86
  Promise.resolve().then(() => {
62
87
  warnListeners.forEach(
63
88
  (listener) => listener(sessionExpiryWarningNotifiedAt)
64
89
  );
65
- userInteractionEvents.forEach((eventType) => {
66
- document.removeEventListener(eventType, renewSessionAtInterval);
67
- });
68
90
  }).catch(() => {
69
91
  });
70
92
  };
71
- const notifySessionExpiry = () => Promise.resolve().then(() => {
72
- expiryListeners.forEach((listener) => listener());
73
- });
74
93
  const stopSessionMonitoring = () => {
75
- userInteractionEvents.forEach((eventType) => {
76
- document.removeEventListener(eventType, renewSessionAtInterval);
77
- });
94
+ removeActivityEventListeners();
95
+ removeWakeListener?.();
96
+ removeWakeListener = void 0;
78
97
  clearInterval(timerHandle);
98
+ resetIdleStateFlags();
79
99
  warnListeners.length = 0;
80
100
  expiryListeners.length = 0;
81
101
  };
82
- const monitorSessionEvents = () => {
102
+ function enforceIdleThresholds(ignoreActiveWarning = false) {
103
+ if (sessionExpired) return false;
83
104
  if (isPastSessionTimeoutTime()) {
105
+ sessionExpired = true;
84
106
  notifySessionExpiry().then(() => {
85
107
  stopSessionMonitoring();
86
108
  }).catch(() => {
87
109
  });
88
- } else if (!sessionExpiryWarningNotified && isPastWarningTime())
110
+ return false;
111
+ }
112
+ if (!sessionExpiryWarningNotified && isPastWarningTime()) {
89
113
  notifySessionExpiryWarning();
90
- };
114
+ return false;
115
+ }
116
+ if (sessionExpiryWarningNotified && !ignoreActiveWarning) return false;
117
+ return true;
118
+ }
91
119
  const removeListeners = (arr, cb) => {
92
120
  const idx = arr.findIndex((r) => r === cb);
93
121
  if (idx > -1) {
@@ -100,8 +128,14 @@ const addEventListeners = () => {
100
128
  });
101
129
  };
102
130
  const initSessionMonitoring = () => {
131
+ clearInterval(timerHandle);
132
+ removeWakeListener?.();
133
+ removeActivityEventListeners();
134
+ resetSessionTimeoutCache();
135
+ resetIdleStateFlags();
103
136
  addEventListeners();
104
- timerHandle = setInterval(monitorSessionEvents, 1e3);
137
+ removeWakeListener = subscribeToPageWake(enforceIdleThresholds);
138
+ timerHandle = setInterval(enforceIdleThresholds, 1e3);
105
139
  };
106
140
  const subscribeToSessionExpiryWarning = (onSessionExpiryWarn) => {
107
141
  warnListeners.push(onSessionExpiryWarn);
@@ -1,34 +1,33 @@
1
1
  import { useEffect, useState } from "react";
2
- import { getSeconds, differenceInMinutes } from "date-fns";
3
- import { SESSION_TIMEOUT_INTERVAL } from "../../../utils/constants.js";
4
- import { getAppConfigValue } from "../../../utils/app-config/config.js";
2
+ import { subscribeToPageWake } from "../../../utils/page-wake.js";
3
+ import {
4
+ getSessionWarnIntervalMs,
5
+ getSessionExpiryIntervalMs
6
+ } from "../../../utils/session-timeout-config.js";
7
+ const formatTimeLeft = (msLeft) => {
8
+ const totalSeconds = Math.max(0, Math.floor(msLeft / 1e3));
9
+ const minutes = Math.floor(totalSeconds / 60);
10
+ const seconds = totalSeconds % 60;
11
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(
12
+ 2,
13
+ "0"
14
+ )}`;
15
+ };
5
16
  const useTrackSessionExpiry = (warningNotifiedAt) => {
6
17
  const [timeData, setTimeData] = useState();
7
18
  useEffect(() => {
8
- const timeLeftForExpiryAfterWarning = () => {
9
- const userWarnInterval = getAppConfigValue(
10
- "sessionTimeoutWarnInterval"
11
- );
12
- const userTimeoutInterval = getAppConfigValue(
13
- "sessionTimeoutInterval"
14
- );
15
- const warnInterval = userWarnInterval ? parseFloat(userWarnInterval) : SESSION_TIMEOUT_INTERVAL.WARN;
16
- const sessionTimeout = userTimeoutInterval ? parseFloat(userTimeoutInterval) : SESSION_TIMEOUT_INTERVAL.EXPIRY;
17
- const diffTime = sessionTimeout - warnInterval;
18
- const sessionExpiresIn = warningNotifiedAt + diffTime;
19
- const seconds = getSeconds(sessionExpiresIn - Date.now());
20
- const minutes = differenceInMinutes(sessionExpiresIn, Date.now());
21
- return {
22
- seconds: `0${seconds}`.slice(-2),
23
- minutes: `0${minutes}`.slice(-2)
24
- };
19
+ const warnInterval = getSessionWarnIntervalMs();
20
+ const sessionTimeout = getSessionExpiryIntervalMs();
21
+ const sessionExpiresAt = warningNotifiedAt + (sessionTimeout - warnInterval);
22
+ const updateTimeLeft = () => {
23
+ setTimeData(formatTimeLeft(sessionExpiresAt - Date.now()));
25
24
  };
26
- const interval = setInterval(() => {
27
- const { seconds, minutes } = timeLeftForExpiryAfterWarning();
28
- setTimeData(`${minutes}:${seconds}`);
29
- }, 1e3);
25
+ updateTimeLeft();
26
+ const interval = setInterval(updateTimeLeft, 1e3);
27
+ const removeWakeListener = subscribeToPageWake(updateTimeLeft);
30
28
  return () => {
31
29
  clearInterval(interval);
30
+ removeWakeListener();
32
31
  };
33
32
  }, [warningNotifiedAt]);
34
33
  return timeData;
@@ -29,7 +29,7 @@ const SessionExpiry = memo(
29
29
  }, [open]);
30
30
  const resetSession = async () => {
31
31
  setIsOpen(false);
32
- await renewSession();
32
+ await renewSession(true);
33
33
  addEventListeners();
34
34
  dispatch(logout.cancel());
35
35
  };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Subscribes to browser wake/resume signals and coalesces bursts of events
3
+ * (visibilitychange + pageshow + focus) into a single callback per tick.
4
+ * @param callback
5
+ */
6
+ export declare const subscribeToPageWake: (callback: () => void) => (() => void);
@@ -0,0 +1,6 @@
1
+ type SessionTimeoutKey = 'sessionTimeoutWarnInterval' | 'sessionTimeoutInterval';
2
+ export declare const resetSessionTimeoutCache: () => void;
3
+ export declare const getSessionTimeoutMs: (key: SessionTimeoutKey, fallback: number) => number;
4
+ export declare const getSessionWarnIntervalMs: () => number;
5
+ export declare const getSessionExpiryIntervalMs: () => number;
6
+ export {};
@@ -9,95 +9,62 @@ type LISTENER = {
9
9
  (): void;
10
10
  };
11
11
  /**
12
- * Resets the user idle time counter.
13
- * Call this when user performs an action to extend their session.
14
- * @param resetWarningModal - If true, also resets the warning modal state (default: false)
15
- * @example
16
- * ```typescript
17
- * // Reset idle time on user interaction
18
- * document.addEventListener('click', () => {
19
- * resetUserIdleTime();
20
- * });
21
- *
22
- * // Reset and close warning modal
23
- * resetUserIdleTime(true);
24
- * ```
12
+ * Resets the user idle clock without calling the auth introspection API.
13
+ * Used by the HTTP request interceptor. Runs through `enforceIdleThresholds()`
14
+ * first, so it cannot dismiss the warning modal or extend after expiry.
15
+ * @param {boolean} [resetWarningModal=false] - When true, notifies reset
16
+ * listeners so the warning modal can close. Only for explicit user actions.
25
17
  */
26
18
  export declare const resetUserIdleTime: ResetUserIdleTimeFn;
27
19
  /**
28
- * Extends the PSS session (Encompass session) by introspecting the token.
29
- * Also resets the UI idle time counter.
30
- * @throws Error if authorization token is not found
31
- * @example
32
- * ```typescript
33
- * // Manually renew session
34
- * await renewSession();
35
- * ```
20
+ * Extends the PSS (Encompass) session via token introspection and resets idle.
21
+ * @param {boolean} [explicit=false] - Pass true for deliberate user actions
22
+ * (session expiry modal Reset). False blocks renewal while warning is open.
23
+ * Throttled handlers and `host.renewSessionTimer()` always use the default.
36
24
  * @internal
37
25
  */
38
- export declare const renewSession: () => Promise<void>;
26
+ export declare const renewSession: (explicit?: boolean) => Promise<void>;
27
+ /**
28
+ * Stops idle monitoring, removes listeners, and clears subscriber lists.
29
+ * Called automatically after session expiry.
30
+ */
39
31
  export declare const stopSessionMonitoring: () => void;
32
+ /**
33
+ * Re-attaches host document activity listeners after the warning modal closes.
34
+ * Called by the session expiry modal after a successful explicit reset.
35
+ */
40
36
  export declare const addEventListeners: () => void;
41
- export declare const initSessionMonitoring: () => void;
42
37
  /**
43
- * Subscribes to session expiry warning events.
44
- * The callback is invoked when the session is about to expire (based on warning interval).
45
- * @param onSessionExpiryWarn - Callback function that receives the warning timestamp
46
- * @returns Unsubscribe function to remove the listener
47
- * @example
48
- * ```typescript
49
- * const unsubscribe = subscribeToSessionExpiryWarning((warningTime) => {
50
- * console.log('Session expiring at:', warningTime);
51
- * showWarningModal();
52
- * });
38
+ * Starts session idle monitoring on the host document.
53
39
  *
54
- * // Later, to unsubscribe
55
- * unsubscribe();
56
- * ```
40
+ * Safe to call more than once; clears previous listeners and timers first.
41
+ * Typically wired up once via the `SessionTimeout` component.
42
+ */
43
+ export declare const initSessionMonitoring: () => void;
44
+ /**
45
+ * Registers a callback when idle time crosses the warn threshold.
46
+ * @param {WARNLISTENER} onSessionExpiryWarn - Timestamp the warning was shown.
47
+ * @returns {Function} Unsubscribe function.
57
48
  */
58
49
  export declare const subscribeToSessionExpiryWarning: (onSessionExpiryWarn: WARNLISTENER) => () => void;
59
50
  /**
60
- * Subscribes to session expiry events.
61
- * The callback is invoked when the session has expired.
62
- * @param onSessionExpiry - Callback function invoked on session expiry
63
- * @returns Unsubscribe function to remove the listener
64
- * @example
65
- * ```typescript
66
- * const unsubscribe = subscribeToSessionExpiry(() => {
67
- * console.log('Session expired');
68
- * window.location.href = '/login';
69
- * });
70
- * ```
51
+ * Registers a callback when idle time crosses the expiry threshold.
52
+ * @param {LISTENER} onSessionExpiry - Invoked once when the session should end.
53
+ * @returns {Function} Unsubscribe function.
71
54
  */
72
55
  export declare const subscribeToSessionExpiry: (onSessionExpiry: LISTENER) => () => void;
73
56
  /**
74
- * Subscribes to session reset events.
75
- * The callback is invoked when the session idle time is reset.
76
- * @param onResetListener - Callback function that receives reset modal flag
77
- * @returns Unsubscribe function to remove the listener
78
- * @example
79
- * ```typescript
80
- * subscribeToResetSession((shouldResetModal) => {
81
- * if (shouldResetModal) {
82
- * closeWarningModal();
83
- * }
84
- * });
85
- * ```
57
+ * Registers a callback when the idle clock is reset.
58
+ * @param {RESETLISTENER} onResetListener - Receives the resetWarningModal flag.
59
+ * @returns {Function} Unsubscribe function.
86
60
  */
87
61
  export declare const subscribeToResetSession: (onResetListener: RESETLISTENER) => () => void;
88
62
  /**
89
- * Starts tracking user activity for session management.
90
- * Monitors user interactions on the specified element and invokes callback.
91
- * @param element - DOM element to track activity on (typically document)
92
- * @param cb - Callback function to invoke on user activity
93
- * @returns Cleanup function to stop tracking
94
- * @example
95
- * ```typescript
96
- * const cleanup = trackActivity(document, renewSession);
97
- *
98
- * // Later, stop tracking
99
- * cleanup();
100
- * ```
63
+ * Tracks user interaction on a document and invokes a callback (iframe guests).
64
+ * Does not run `enforceIdleThresholds`; callback should use a guarded renewal path.
65
+ * @param {Document | null} element - Host or iframe document to listen on.
66
+ * @param {Function} cb - Invoked at most once per minute on activity.
67
+ * @returns {Function} Cleanup function that removes listeners.
101
68
  */
102
69
  export declare const trackActivity: (element: Document | null, cb: (...args: unknown[]) => unknown) => () => void;
103
70
  export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};