@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.
- package/build/docs/404.html +2 -2
- package/build/docs/api/classes/Analytics/index.html +2 -2
- package/build/docs/api/classes/CMicroAppGuest/index.html +2 -2
- package/build/docs/api/classes/CMicroAppHost/index.html +2 -2
- package/build/docs/api/classes/ErrorBoundary/index.html +2 -2
- package/build/docs/api/classes/GuestModule/index.html +2 -2
- package/build/docs/api/functions/AppRoot/index.html +2 -2
- package/build/docs/api/functions/Autocomplete/index.html +2 -2
- package/build/docs/api/functions/CheckBox/index.html +2 -2
- package/build/docs/api/functions/ComboBox/index.html +2 -2
- package/build/docs/api/functions/ComboBoxV3/index.html +2 -2
- package/build/docs/api/functions/ConnectForm/index.html +2 -2
- package/build/docs/api/functions/DateInput/index.html +2 -2
- package/build/docs/api/functions/DatePicker/index.html +2 -2
- package/build/docs/api/functions/DateRangePicker/index.html +2 -2
- package/build/docs/api/functions/DateTimePicker/index.html +2 -2
- package/build/docs/api/functions/Form/index.html +2 -2
- package/build/docs/api/functions/FormItemLayout/index.html +2 -2
- package/build/docs/api/functions/FormLayoutBlockItem/index.html +2 -2
- package/build/docs/api/functions/FormSubmitButton/index.html +2 -2
- package/build/docs/api/functions/InputMask/index.html +2 -2
- package/build/docs/api/functions/InputText/index.html +2 -2
- package/build/docs/api/functions/LargeTextBox/index.html +2 -2
- package/build/docs/api/functions/MaskedInputText/index.html +2 -2
- package/build/docs/api/functions/Page/index.html +2 -2
- package/build/docs/api/functions/Radio/index.html +2 -2
- package/build/docs/api/functions/RadioGroup/index.html +2 -2
- package/build/docs/api/functions/RegisterService/index.html +2 -2
- package/build/docs/api/functions/RenderWithStateAddOns/index.html +2 -2
- package/build/docs/api/functions/RequireAuth/index.html +2 -2
- package/build/docs/api/functions/SessionTimeout/index.html +2 -2
- package/build/docs/api/functions/TextBox/index.html +2 -2
- package/build/docs/api/functions/Toggle/index.html +2 -2
- package/build/docs/api/functions/authSaga/index.html +2 -2
- package/build/docs/api/functions/authorize/index.html +2 -2
- package/build/docs/api/functions/buildModuleParams/index.html +2 -2
- package/build/docs/api/functions/cleanup/index.html +2 -2
- package/build/docs/api/functions/configureStore/index.html +2 -2
- package/build/docs/api/functions/createGuestModule/index.html +2 -2
- package/build/docs/api/functions/createManager/index.html +2 -2
- package/build/docs/api/functions/enableReactAppForHostIntegration/index.html +2 -2
- package/build/docs/api/functions/fetchHostAppData/index.html +2 -2
- package/build/docs/api/functions/fetchUserSettings/index.html +2 -2
- package/build/docs/api/functions/getApiActionCreator/index.html +2 -2
- package/build/docs/api/functions/getAppConfig/index.html +2 -2
- package/build/docs/api/functions/getAppConfigValue/index.html +2 -2
- package/build/docs/api/functions/getAuthHTTPClient/index.html +2 -2
- package/build/docs/api/functions/getAuthorizationHeader/index.html +2 -2
- package/build/docs/api/functions/getHTTPClient/index.html +2 -2
- package/build/docs/api/functions/getHostAppDataByKey/index.html +2 -2
- package/build/docs/api/functions/getLogger/index.html +2 -2
- package/build/docs/api/functions/getMicroFrontEndAppConfig/index.html +2 -2
- package/build/docs/api/functions/getNavigationLinks/index.html +2 -2
- package/build/docs/api/functions/getRedirectUrl/index.html +2 -2
- package/build/docs/api/functions/getSelectField/index.html +2 -2
- package/build/docs/api/functions/getStore/index.html +2 -2
- package/build/docs/api/functions/initServiceWorker/index.html +2 -2
- package/build/docs/api/functions/isCIBuild/index.html +2 -2
- package/build/docs/api/functions/isProd/index.html +2 -2
- package/build/docs/api/functions/isUserAuthorized/index.html +2 -2
- package/build/docs/api/functions/listenStorageEvents/index.html +2 -2
- package/build/docs/api/functions/loadAppConfig/index.html +2 -2
- package/build/docs/api/functions/loadable/index.html +2 -2
- package/build/docs/api/functions/login/index.html +2 -2
- package/build/docs/api/functions/notifyGuestUnloadComplete/index.html +2 -2
- package/build/docs/api/functions/onAuthorizationFailure/index.html +2 -2
- package/build/docs/api/functions/onGuestUnloadStart/index.html +2 -2
- package/build/docs/api/functions/redactPii/index.html +2 -2
- package/build/docs/api/functions/removeDoubleSlash/index.html +2 -2
- package/build/docs/api/functions/removeStorageEvents/index.html +2 -2
- package/build/docs/api/functions/render/index.html +2 -2
- package/build/docs/api/functions/renderHook/index.html +2 -2
- package/build/docs/api/functions/renderWithHostData/index.html +2 -2
- package/build/docs/api/functions/renderWithRedux/index.html +2 -2
- package/build/docs/api/functions/renderWithRouter/index.html +2 -2
- package/build/docs/api/functions/renderWithRouterRedux/index.html +2 -2
- package/build/docs/api/functions/sdkBaseQuery/index.html +2 -2
- package/build/docs/api/functions/sendBAEvent/index.html +2 -2
- package/build/docs/api/functions/sendMessageToHost/index.html +2 -2
- package/build/docs/api/functions/setAppConfig/index.html +2 -2
- package/build/docs/api/functions/setAppConfigValue/index.html +2 -2
- package/build/docs/api/functions/setHostAppData/index.html +2 -2
- package/build/docs/api/functions/setLoginParams/index.html +2 -2
- package/build/docs/api/functions/subscribeToResetSession/index.html +7 -10
- package/build/docs/api/functions/subscribeToSessionExpiry/index.html +7 -10
- package/build/docs/api/functions/subscribeToSessionExpiryWarning/index.html +7 -10
- package/build/docs/api/functions/trackActivity/index.html +9 -11
- package/build/docs/api/functions/useAppDispatch/index.html +2 -2
- package/build/docs/api/functions/useAppMiddleware/index.html +2 -2
- package/build/docs/api/functions/useInjectQuery/index.html +2 -2
- package/build/docs/api/functions/useInjectReducer/index.html +2 -2
- package/build/docs/api/functions/useInjectSaga/index.html +2 -2
- package/build/docs/api/functions/useInjectSideEffect/index.html +2 -2
- package/build/docs/api/functions/useMediaQueryList/index.html +2 -2
- package/build/docs/api/functions/useStateSelector/index.html +2 -2
- package/build/docs/api/functions/useStateSelectorShallow/index.html +2 -2
- package/build/docs/api/functions/waitFor/index.html +2 -2
- package/build/docs/api/functions/waitForElementToBeRemoved/index.html +2 -2
- package/build/docs/api/functions/withAppDecorator/index.html +2 -2
- package/build/docs/api/index.html +4 -4
- package/build/docs/api/interfaces/AppConfig/index.html +2 -2
- package/build/docs/api/interfaces/GuestProps/index.html +2 -2
- package/build/docs/api/interfaces/UseStateSelectorOptions/index.html +2 -2
- package/build/docs/api/type-aliases/AppDispatch/index.html +2 -2
- package/build/docs/api/type-aliases/AppStore/index.html +2 -2
- package/build/docs/api/type-aliases/Await/index.html +2 -2
- package/build/docs/api/type-aliases/EMUI/index.html +2 -2
- package/build/docs/api/type-aliases/HostOptions/index.html +2 -2
- package/build/docs/api/type-aliases/HostProvidedParams/index.html +2 -2
- package/build/docs/api/type-aliases/ModuleOverrides/index.html +2 -2
- package/build/docs/api/type-aliases/OnHostInitCallback/index.html +2 -2
- package/build/docs/api/type-aliases/OnInitCallback/index.html +2 -2
- package/build/docs/api/type-aliases/OnMountCallback/index.html +2 -2
- package/build/docs/api/type-aliases/OnUnMountCallback/index.html +2 -2
- package/build/docs/api/type-aliases/RootState/index.html +2 -2
- package/build/docs/api/type-aliases/SelectStateFieldFunction/index.html +2 -2
- package/build/docs/api/variables/ErrorToast/index.html +2 -2
- package/build/docs/api/variables/FormPropsContext/index.html +2 -2
- package/build/docs/api/variables/GuestMicroApp/index.html +2 -2
- package/build/docs/api/variables/MASK_PIPES/index.html +2 -2
- package/build/docs/api/variables/MASK_TYPES/index.html +2 -2
- package/build/docs/api/variables/MicroApp/index.html +2 -2
- package/build/docs/api/variables/MicroIFrameApp/index.html +2 -2
- package/build/docs/api/variables/NavigationPrompt/index.html +2 -2
- package/build/docs/api/variables/NavigationPromptActions/index.html +2 -2
- package/build/docs/api/variables/Themes/index.html +2 -2
- package/build/docs/api/variables/VisuallyHidden/index.html +2 -2
- package/build/docs/api/variables/WaitMessage/index.html +2 -2
- package/build/docs/api/variables/act/index.html +2 -2
- package/build/docs/api/variables/ariaLive/index.html +2 -2
- package/build/docs/api/variables/auth/index.html +2 -2
- package/build/docs/api/variables/authReducer/index.html +2 -2
- package/build/docs/api/variables/clearSideEffects/index.html +2 -2
- package/build/docs/api/variables/createSideEffect/index.html +2 -2
- package/build/docs/api/variables/decorators/index.html +2 -2
- package/build/docs/api/variables/endSession/index.html +2 -2
- package/build/docs/api/variables/error/index.html +2 -2
- package/build/docs/api/variables/errorMiddleware/index.html +2 -2
- package/build/docs/api/variables/fireEvent/index.html +2 -2
- package/build/docs/api/variables/globalConstants/index.html +2 -2
- package/build/docs/api/variables/history/index.html +2 -2
- package/build/docs/api/variables/httpClientProps/index.html +2 -2
- package/build/docs/api/variables/logout/index.html +2 -2
- package/build/docs/api/variables/memoryHistory/index.html +2 -2
- package/build/docs/api/variables/removeSideEffect/index.html +2 -2
- package/build/docs/api/variables/resetUserIdleTime/index.html +8 -8
- package/build/docs/api/variables/screen/index.html +2 -2
- package/build/docs/api/variables/startSideEffect/index.html +2 -2
- package/build/docs/api/variables/updateBAEventParameters/index.html +2 -2
- package/build/docs/api/variables/useAppSelector/index.html +2 -2
- package/build/docs/api/variables/waitMessageAction/index.html +2 -2
- package/build/docs/api/variables/within/index.html +2 -2
- package/build/docs/assets/js/3cb0b0a9.67b20d88.js +1 -0
- package/build/docs/assets/js/{5e8c322a.f1548b2b.js → 5e8c322a.c3cc240b.js} +1 -1
- package/build/docs/assets/js/{822e0178.a567065b.js → 822e0178.dfd661b8.js} +1 -1
- package/build/docs/assets/js/a0eb976e.77667f42.js +1 -0
- package/build/docs/assets/js/c90572d4.0b7362b5.js +1 -0
- package/build/docs/assets/js/f4180cff.0f2ce3bf.js +1 -0
- package/build/docs/assets/js/fed4ae4f.4cbcd19c.js +1 -0
- package/build/docs/assets/js/{main.e2e13725.js → main.1a5a08af.js} +2 -2
- package/build/docs/assets/js/{runtime~main.cd750ab4.js → runtime~main.9f7b9b59.js} +1 -1
- package/build/docs/index.html +2 -2
- package/build/docs/usage-guide/index.html +2 -2
- package/demo/{5685.7040bb5c.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +205 -205
- package/demo/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
- package/demo/9478.1f9d2bf2.iframe.bundle.js.gz +0 -0
- package/demo/{1770.ef5c473d.iframe.bundle.js → 9888.bfe9152c.iframe.bundle.js} +8 -8
- package/demo/9888.bfe9152c.iframe.bundle.js.br +0 -0
- package/demo/9888.bfe9152c.iframe.bundle.js.gz +0 -0
- package/demo/docs/{5685.7040bb5c.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +205 -205
- package/demo/docs/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
- package/demo/docs/9478.1f9d2bf2.iframe.bundle.js.gz +0 -0
- package/demo/docs/{1770.ef5c473d.iframe.bundle.js → 9888.bfe9152c.iframe.bundle.js} +8 -8
- package/demo/docs/9888.bfe9152c.iframe.bundle.js.br +0 -0
- package/demo/docs/9888.bfe9152c.iframe.bundle.js.gz +0 -0
- package/demo/docs/iframe.html +1 -1
- package/demo/docs/index.html +1 -1
- package/demo/docs/main.3ca9a77e.iframe.bundle.js +5 -0
- package/demo/docs/main.3ca9a77e.iframe.bundle.js.br +0 -0
- package/demo/docs/main.3ca9a77e.iframe.bundle.js.gz +0 -0
- package/demo/docs/{main.7644e4ef6d4f1851046c.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
- package/demo/docs/{main.7644e4ef6d4f1851046c.manager.bundle.js.br → main.9379efdc5e6f460465e2.manager.bundle.js.br} +0 -0
- package/demo/docs/main.9379efdc5e6f460465e2.manager.bundle.js.gz +0 -0
- package/demo/docs/project.json +1 -1
- package/demo/docs/{runtime~main.d70e75f8.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +1 -1
- package/demo/docs/runtime~main.b7f50131.iframe.bundle.js.br +0 -0
- package/demo/docs/runtime~main.b7f50131.iframe.bundle.js.gz +0 -0
- package/demo/iframe.html +1 -1
- package/demo/index.html +1 -1
- package/demo/main.3ca9a77e.iframe.bundle.js +5 -0
- package/demo/main.3ca9a77e.iframe.bundle.js.br +0 -0
- package/demo/main.3ca9a77e.iframe.bundle.js.gz +0 -0
- package/demo/{main.7644e4ef6d4f1851046c.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
- package/demo/{main.7644e4ef6d4f1851046c.manager.bundle.js.br → main.9379efdc5e6f460465e2.manager.bundle.js.br} +0 -0
- package/demo/main.9379efdc5e6f460465e2.manager.bundle.js.gz +0 -0
- package/demo/project.json +1 -1
- package/demo/{runtime~main.d70e75f8.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +1 -1
- package/demo/runtime~main.b7f50131.iframe.bundle.js.br +0 -0
- package/demo/runtime~main.b7f50131.iframe.bundle.js.gz +0 -0
- package/dist/cjs/utils/page-wake.js +47 -0
- package/dist/cjs/utils/session-timeout-config.js +60 -0
- package/dist/cjs/utils/session.js +53 -20
- package/dist/cjs/view/modals/session-expiry/customHooks.js +20 -24
- package/dist/cjs/view/modals/session-expiry/index.js +1 -1
- package/dist/esm/utils/page-wake.js +27 -0
- package/dist/esm/utils/session-timeout-config.js +40 -0
- package/dist/esm/utils/session.js +57 -23
- package/dist/esm/view/modals/session-expiry/customHooks.js +23 -24
- package/dist/esm/view/modals/session-expiry/index.js +1 -1
- package/dist/types/lib/utils/page-wake.d.ts +6 -0
- package/dist/types/lib/utils/session-timeout-config.d.ts +6 -0
- package/dist/types/lib/utils/session.d.ts +38 -71
- package/dist/types/lib/utils/tests/page-wake.test.d.ts +1 -0
- package/dist/types/lib/utils/tests/session-idle-guard.test.d.ts +1 -0
- package/dist/types/lib/utils/tests/session-timeout-config.test.d.ts +1 -0
- package/dist/types/lib/utils/tests/session.test.d.ts +1 -0
- package/dist/types/lib/view/modals/session-expiry/tests/customHooks.test.d.ts +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/docs/assets/js/3cb0b0a9.b5efc7a4.js +0 -1
- package/build/docs/assets/js/a0eb976e.fc660f60.js +0 -1
- package/build/docs/assets/js/c90572d4.71073c5c.js +0 -1
- package/build/docs/assets/js/f4180cff.b50f1502.js +0 -1
- package/build/docs/assets/js/fed4ae4f.335f00fb.js +0 -1
- package/demo/1770.ef5c473d.iframe.bundle.js.br +0 -0
- package/demo/1770.ef5c473d.iframe.bundle.js.gz +0 -0
- package/demo/5685.7040bb5c.iframe.bundle.js.br +0 -0
- package/demo/5685.7040bb5c.iframe.bundle.js.gz +0 -0
- package/demo/docs/1770.ef5c473d.iframe.bundle.js.br +0 -0
- package/demo/docs/1770.ef5c473d.iframe.bundle.js.gz +0 -0
- package/demo/docs/5685.7040bb5c.iframe.bundle.js.br +0 -0
- package/demo/docs/5685.7040bb5c.iframe.bundle.js.gz +0 -0
- package/demo/docs/main.7644e4ef6d4f1851046c.manager.bundle.js.gz +0 -0
- package/demo/docs/main.8b6c74fc.iframe.bundle.js +0 -5
- package/demo/docs/main.8b6c74fc.iframe.bundle.js.br +0 -0
- package/demo/docs/main.8b6c74fc.iframe.bundle.js.gz +0 -0
- package/demo/docs/runtime~main.d70e75f8.iframe.bundle.js.br +0 -0
- package/demo/docs/runtime~main.d70e75f8.iframe.bundle.js.gz +0 -0
- package/demo/main.7644e4ef6d4f1851046c.manager.bundle.js.gz +0 -0
- package/demo/main.8b6c74fc.iframe.bundle.js +0 -5
- package/demo/main.8b6c74fc.iframe.bundle.js.br +0 -0
- package/demo/main.8b6c74fc.iframe.bundle.js.gz +0 -0
- package/demo/runtime~main.d70e75f8.iframe.bundle.js.br +0 -0
- package/demo/runtime~main.d70e75f8.iframe.bundle.js.gz +0 -0
- /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
|
|
26
|
-
var
|
|
27
|
-
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 {
|
|
8
|
+
import { SESSION_RENEWAL_INTERVAL } from "./constants.js";
|
|
9
|
+
import { subscribeToPageWake } from "./page-wake.js";
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
68
|
+
() => {
|
|
69
|
+
renewSession().catch(() => {
|
|
70
|
+
});
|
|
71
|
+
},
|
|
51
72
|
SESSION_RENEWAL_INTERVAL,
|
|
52
73
|
{
|
|
53
74
|
leading: true
|
|
54
75
|
}
|
|
55
76
|
);
|
|
56
|
-
const
|
|
57
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|
|
@@ -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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
*
|
|
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
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
55
|
-
*
|
|
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
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
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
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
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
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @param element -
|
|
92
|
-
* @param cb -
|
|
93
|
-
* @returns Cleanup function
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|