@elliemae/pui-app-sdk 5.42.4 → 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.2c531d5e.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/{9478.de5e6fa2.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +1 -1
- package/demo/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
- package/demo/{docs/9478.de5e6fa2.iframe.bundle.js.gz → 9478.1f9d2bf2.iframe.bundle.js.gz} +0 -0
- package/demo/docs/{9478.de5e6fa2.iframe.bundle.js → 9478.1f9d2bf2.iframe.bundle.js} +1 -1
- package/demo/docs/9478.1f9d2bf2.iframe.bundle.js.br +0 -0
- package/demo/{9478.de5e6fa2.iframe.bundle.js.gz → docs/9478.1f9d2bf2.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.b293ffa609119d831d1a.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
- package/demo/docs/main.9379efdc5e6f460465e2.manager.bundle.js.br +0 -0
- package/demo/docs/{main.b293ffa609119d831d1a.manager.bundle.js.gz → main.9379efdc5e6f460465e2.manager.bundle.js.gz} +0 -0
- package/demo/docs/project.json +1 -1
- package/demo/docs/{runtime~main.79f1fd4d.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +2 -2
- package/demo/docs/{runtime~main.79f1fd4d.iframe.bundle.js.br → 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.b293ffa609119d831d1a.manager.bundle.js → main.9379efdc5e6f460465e2.manager.bundle.js} +1 -1
- package/demo/main.9379efdc5e6f460465e2.manager.bundle.js.br +0 -0
- package/demo/{main.b293ffa609119d831d1a.manager.bundle.js.gz → main.9379efdc5e6f460465e2.manager.bundle.js.gz} +0 -0
- package/demo/project.json +1 -1
- package/demo/{runtime~main.79f1fd4d.iframe.bundle.js → runtime~main.b7f50131.iframe.bundle.js} +2 -2
- package/demo/{runtime~main.79f1fd4d.iframe.bundle.js.br → runtime~main.b7f50131.iframe.bundle.js.br} +0 -0
- package/demo/runtime~main.b7f50131.iframe.bundle.js.gz +0 -0
- package/dist/cjs/utils/session-timeout-config.js +60 -0
- package/dist/cjs/utils/session.js +45 -23
- package/dist/cjs/view/modals/session-expiry/customHooks.js +3 -10
- package/dist/cjs/view/modals/session-expiry/index.js +1 -1
- package/dist/esm/utils/session-timeout-config.js +40 -0
- package/dist/esm/utils/session.js +50 -27
- package/dist/esm/view/modals/session-expiry/customHooks.js +6 -10
- package/dist/esm/view/modals/session-expiry/index.js +1 -1
- 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/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/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/9478.de5e6fa2.iframe.bundle.js.br +0 -0
- package/demo/docs/9478.de5e6fa2.iframe.bundle.js.br +0 -0
- package/demo/docs/main.4a02f0d8.iframe.bundle.js +0 -5
- package/demo/docs/main.4a02f0d8.iframe.bundle.js.br +0 -0
- package/demo/docs/main.4a02f0d8.iframe.bundle.js.gz +0 -0
- package/demo/docs/main.b293ffa609119d831d1a.manager.bundle.js.br +0 -0
- package/demo/docs/runtime~main.79f1fd4d.iframe.bundle.js.gz +0 -0
- package/demo/main.4a02f0d8.iframe.bundle.js +0 -5
- package/demo/main.4a02f0d8.iframe.bundle.js.br +0 -0
- package/demo/main.4a02f0d8.iframe.bundle.js.gz +0 -0
- package/demo/main.b293ffa609119d831d1a.manager.bundle.js.br +0 -0
- package/demo/runtime~main.79f1fd4d.iframe.bundle.js.gz +0 -0
- /package/build/docs/assets/js/{main.2c531d5e.js.LICENSE.txt → main.1a5a08af.js.LICENSE.txt} +0 -0
|
@@ -5,34 +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 {
|
|
9
|
-
import {
|
|
10
|
-
SESSION_TIMEOUT_INTERVAL,
|
|
11
|
-
SESSION_RENEWAL_INTERVAL
|
|
12
|
-
} from "./constants.js";
|
|
8
|
+
import { SESSION_RENEWAL_INTERVAL } from "./constants.js";
|
|
13
9
|
import { subscribeToPageWake } from "./page-wake.js";
|
|
10
|
+
import {
|
|
11
|
+
getSessionWarnIntervalMs,
|
|
12
|
+
getSessionExpiryIntervalMs,
|
|
13
|
+
resetSessionTimeoutCache
|
|
14
|
+
} from "./session-timeout-config.js";
|
|
14
15
|
let lastUserActivityTimeStamp = Date.now();
|
|
15
16
|
const warnListeners = [];
|
|
16
17
|
const expiryListeners = [];
|
|
17
18
|
const resetListeners = [];
|
|
18
19
|
const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
|
|
19
20
|
let sessionExpiryWarningNotified = false;
|
|
21
|
+
let sessionExpired = false;
|
|
20
22
|
let timerHandle;
|
|
21
23
|
let removeWakeListener;
|
|
22
24
|
let sessionExpiryWarningNotifiedAt;
|
|
23
|
-
const
|
|
25
|
+
const resetIdleStateFlags = () => {
|
|
26
|
+
sessionExpired = false;
|
|
24
27
|
sessionExpiryWarningNotified = false;
|
|
25
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();
|
|
26
37
|
lastUserActivityTimeStamp = Date.now();
|
|
27
38
|
Promise.resolve().then(() => {
|
|
28
39
|
resetListeners.forEach((listener) => listener(resetWarningModal));
|
|
29
40
|
}).catch(() => {
|
|
30
41
|
});
|
|
31
42
|
};
|
|
32
|
-
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;
|
|
33
49
|
const loginParams = getLoginParams();
|
|
34
50
|
try {
|
|
35
|
-
|
|
51
|
+
markUserActive(true);
|
|
36
52
|
if (loginParams?.clientId) {
|
|
37
53
|
const authToken = getAuthorizationHeader();
|
|
38
54
|
if (!authToken)
|
|
@@ -49,52 +65,57 @@ const renewSession = async () => {
|
|
|
49
65
|
}
|
|
50
66
|
};
|
|
51
67
|
const renewSessionAtInterval = throttle(
|
|
52
|
-
|
|
68
|
+
() => {
|
|
69
|
+
renewSession().catch(() => {
|
|
70
|
+
});
|
|
71
|
+
},
|
|
53
72
|
SESSION_RENEWAL_INTERVAL,
|
|
54
73
|
{
|
|
55
74
|
leading: true
|
|
56
75
|
}
|
|
57
76
|
);
|
|
58
|
-
const
|
|
59
|
-
|
|
77
|
+
const removeActivityEventListeners = () => {
|
|
78
|
+
userInteractionEvents.forEach((eventType) => {
|
|
79
|
+
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
60
82
|
const notifySessionExpiryWarning = () => {
|
|
61
83
|
sessionExpiryWarningNotified = true;
|
|
62
84
|
sessionExpiryWarningNotifiedAt = Date.now();
|
|
85
|
+
removeActivityEventListeners();
|
|
63
86
|
Promise.resolve().then(() => {
|
|
64
87
|
warnListeners.forEach(
|
|
65
88
|
(listener) => listener(sessionExpiryWarningNotifiedAt)
|
|
66
89
|
);
|
|
67
|
-
userInteractionEvents.forEach((eventType) => {
|
|
68
|
-
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
69
|
-
});
|
|
70
90
|
}).catch(() => {
|
|
71
91
|
});
|
|
72
92
|
};
|
|
73
|
-
const notifySessionExpiry = () => Promise.resolve().then(() => {
|
|
74
|
-
expiryListeners.forEach((listener) => listener());
|
|
75
|
-
});
|
|
76
|
-
const removeActivityEventListeners = () => {
|
|
77
|
-
userInteractionEvents.forEach((eventType) => {
|
|
78
|
-
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
93
|
const stopSessionMonitoring = () => {
|
|
82
94
|
removeActivityEventListeners();
|
|
83
95
|
removeWakeListener?.();
|
|
84
96
|
removeWakeListener = void 0;
|
|
85
97
|
clearInterval(timerHandle);
|
|
98
|
+
resetIdleStateFlags();
|
|
86
99
|
warnListeners.length = 0;
|
|
87
100
|
expiryListeners.length = 0;
|
|
88
101
|
};
|
|
89
|
-
|
|
102
|
+
function enforceIdleThresholds(ignoreActiveWarning = false) {
|
|
103
|
+
if (sessionExpired) return false;
|
|
90
104
|
if (isPastSessionTimeoutTime()) {
|
|
105
|
+
sessionExpired = true;
|
|
91
106
|
notifySessionExpiry().then(() => {
|
|
92
107
|
stopSessionMonitoring();
|
|
93
108
|
}).catch(() => {
|
|
94
109
|
});
|
|
95
|
-
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (!sessionExpiryWarningNotified && isPastWarningTime()) {
|
|
96
113
|
notifySessionExpiryWarning();
|
|
97
|
-
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (sessionExpiryWarningNotified && !ignoreActiveWarning) return false;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
98
119
|
const removeListeners = (arr, cb) => {
|
|
99
120
|
const idx = arr.findIndex((r) => r === cb);
|
|
100
121
|
if (idx > -1) {
|
|
@@ -110,9 +131,11 @@ const initSessionMonitoring = () => {
|
|
|
110
131
|
clearInterval(timerHandle);
|
|
111
132
|
removeWakeListener?.();
|
|
112
133
|
removeActivityEventListeners();
|
|
134
|
+
resetSessionTimeoutCache();
|
|
135
|
+
resetIdleStateFlags();
|
|
113
136
|
addEventListeners();
|
|
114
|
-
removeWakeListener = subscribeToPageWake(
|
|
115
|
-
timerHandle = setInterval(
|
|
137
|
+
removeWakeListener = subscribeToPageWake(enforceIdleThresholds);
|
|
138
|
+
timerHandle = setInterval(enforceIdleThresholds, 1e3);
|
|
116
139
|
};
|
|
117
140
|
const subscribeToSessionExpiryWarning = (onSessionExpiryWarn) => {
|
|
118
141
|
warnListeners.push(onSessionExpiryWarn);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import { SESSION_TIMEOUT_INTERVAL } from "../../../utils/constants.js";
|
|
3
|
-
import { getAppConfigValue } from "../../../utils/app-config/config.js";
|
|
4
2
|
import { subscribeToPageWake } from "../../../utils/page-wake.js";
|
|
3
|
+
import {
|
|
4
|
+
getSessionWarnIntervalMs,
|
|
5
|
+
getSessionExpiryIntervalMs
|
|
6
|
+
} from "../../../utils/session-timeout-config.js";
|
|
5
7
|
const formatTimeLeft = (msLeft) => {
|
|
6
8
|
const totalSeconds = Math.max(0, Math.floor(msLeft / 1e3));
|
|
7
9
|
const minutes = Math.floor(totalSeconds / 60);
|
|
@@ -14,14 +16,8 @@ const formatTimeLeft = (msLeft) => {
|
|
|
14
16
|
const useTrackSessionExpiry = (warningNotifiedAt) => {
|
|
15
17
|
const [timeData, setTimeData] = useState();
|
|
16
18
|
useEffect(() => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
const userTimeoutInterval = getAppConfigValue(
|
|
21
|
-
"sessionTimeoutInterval"
|
|
22
|
-
);
|
|
23
|
-
const warnInterval = userWarnInterval ? parseFloat(userWarnInterval) : SESSION_TIMEOUT_INTERVAL.WARN;
|
|
24
|
-
const sessionTimeout = userTimeoutInterval ? parseFloat(userTimeoutInterval) : SESSION_TIMEOUT_INTERVAL.EXPIRY;
|
|
19
|
+
const warnInterval = getSessionWarnIntervalMs();
|
|
20
|
+
const sessionTimeout = getSessionExpiryIntervalMs();
|
|
25
21
|
const sessionExpiresAt = warningNotifiedAt + (sessionTimeout - warnInterval);
|
|
26
22
|
const updateTimeLeft = () => {
|
|
27
23
|
setTimeData(formatTimeLeft(sessionExpiresAt - Date.now()));
|
|
@@ -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 {};
|