@elliemae/pui-app-sdk 5.10.4 → 5.10.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/dist/cjs/communication/http-client/props.js +42 -0
- package/dist/cjs/communication/http-client/request-interceptor.js +2 -2
- package/dist/cjs/communication/http-client/response-interceptor.js +4 -10
- package/dist/cjs/sideeffect/auth/index.js +3 -3
- package/dist/cjs/utils/auth/index.js +3 -3
- package/dist/cjs/utils/{micro-frontend/console-logger.js → console-logger.js} +3 -3
- package/dist/cjs/utils/logger.js +29 -0
- package/dist/cjs/utils/micro-frontend/guest.js +4 -2
- package/dist/cjs/utils/micro-frontend/host.js +7 -5
- package/dist/cjs/utils/session.js +37 -9
- package/dist/cjs/view/micro-iframe-app/use-frame-loaded.js +2 -2
- package/dist/cjs/view/modals/session-expiry/index.js +1 -2
- package/dist/cjs/view/require-auth.js +2 -2
- package/dist/cjs/view/session-timeout/index.js +2 -0
- package/dist/esm/communication/http-client/props.js +22 -0
- package/dist/esm/communication/http-client/request-interceptor.js +2 -2
- package/dist/esm/communication/http-client/response-interceptor.js +4 -10
- package/dist/esm/sideeffect/auth/index.js +3 -3
- package/dist/esm/utils/auth/index.js +3 -3
- package/dist/esm/utils/{micro-frontend/console-logger.js → console-logger.js} +3 -3
- package/dist/esm/utils/logger.js +9 -0
- package/dist/esm/utils/micro-frontend/guest.js +4 -2
- package/dist/esm/utils/micro-frontend/host.js +7 -5
- package/dist/esm/utils/session.js +37 -9
- package/dist/esm/view/micro-iframe-app/use-frame-loaded.js +2 -2
- package/dist/esm/view/modals/session-expiry/index.js +2 -3
- package/dist/esm/view/require-auth.js +2 -2
- package/dist/esm/view/session-timeout/index.js +4 -1
- package/dist/types/lib/communication/http-client/props.d.ts +11 -0
- package/dist/types/lib/communication/http-client/response-interceptor.d.ts +0 -2
- package/dist/types/lib/data/reducers.d.ts +2 -2
- package/dist/types/lib/data/store.d.ts +4 -4
- package/dist/types/lib/utils/console-logger.d.ts +1 -0
- package/dist/types/lib/utils/logger.d.ts +3 -0
- package/dist/types/lib/utils/micro-frontend/guest.d.ts +1 -2
- package/dist/types/lib/utils/micro-frontend/host.d.ts +2 -2
- package/dist/types/lib/utils/micro-frontend/index.d.ts +1 -1
- package/dist/types/lib/utils/session.d.ts +12 -2
- package/dist/types/lib/utils/testing/render-with-redux.d.ts +2 -2
- package/dist/types/lib/utils/testing/render-with-router-redux.d.ts +2 -2
- package/dist/types/lib/utils/types.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/utils/extendSession.js +0 -47
- package/dist/esm/utils/extendSession.js +0 -27
- package/dist/types/lib/utils/extendSession.d.ts +0 -5
- package/dist/types/lib/utils/micro-frontend/console-logger.d.ts +0 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var props_exports = {};
|
|
20
|
+
__export(props_exports, {
|
|
21
|
+
httpClientProps: () => httpClientProps
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(props_exports);
|
|
24
|
+
class HttpClientProps {
|
|
25
|
+
#resetUserIdleTime = () => {
|
|
26
|
+
};
|
|
27
|
+
#endSession = async () => {
|
|
28
|
+
};
|
|
29
|
+
get resetUserIdleTime() {
|
|
30
|
+
return this.#resetUserIdleTime;
|
|
31
|
+
}
|
|
32
|
+
set resetUserIdleTime(fn) {
|
|
33
|
+
this.#resetUserIdleTime = fn;
|
|
34
|
+
}
|
|
35
|
+
get endSession() {
|
|
36
|
+
return this.#endSession;
|
|
37
|
+
}
|
|
38
|
+
set endSession(fn) {
|
|
39
|
+
this.#endSession = fn;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const httpClientProps = new HttpClientProps();
|
|
@@ -21,8 +21,8 @@ __export(request_interceptor_exports, {
|
|
|
21
21
|
requestInterceptor: () => requestInterceptor
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(request_interceptor_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_props = require("./props.js");
|
|
25
25
|
const requestInterceptor = (config) => {
|
|
26
|
-
|
|
26
|
+
import_props.httpClientProps.resetUserIdleTime();
|
|
27
27
|
return config;
|
|
28
28
|
};
|
|
@@ -30,22 +30,17 @@ var response_interceptor_exports = {};
|
|
|
30
30
|
__export(response_interceptor_exports, {
|
|
31
31
|
handleFailure: () => handleFailure,
|
|
32
32
|
handleSuccess: () => handleSuccess,
|
|
33
|
-
onAuthorizationFailure: () => onAuthorizationFailure
|
|
34
|
-
setEndSessionHandler: () => setEndSessionHandler
|
|
33
|
+
onAuthorizationFailure: () => onAuthorizationFailure
|
|
35
34
|
});
|
|
36
35
|
module.exports = __toCommonJS(response_interceptor_exports);
|
|
37
36
|
var import_axios = __toESM(require("axios"));
|
|
38
37
|
var import_loginParams = require("../../utils/auth/loginParams.js");
|
|
38
|
+
var import_props = require("./props.js");
|
|
39
39
|
const HTTP_UNAUTHORIZED = 401;
|
|
40
40
|
let unAuthorizedFailureHandler = null;
|
|
41
|
-
let endSessionHandler = null;
|
|
42
41
|
const onAuthorizationFailure = (callback) => {
|
|
43
42
|
unAuthorizedFailureHandler = callback;
|
|
44
43
|
};
|
|
45
|
-
const getEndSessionHandler = () => endSessionHandler;
|
|
46
|
-
const setEndSessionHandler = (handler) => {
|
|
47
|
-
endSessionHandler = handler;
|
|
48
|
-
};
|
|
49
44
|
const handleSuccess = (response) => response;
|
|
50
45
|
const handleFailure = (error) => {
|
|
51
46
|
const { status } = (error || {}).response || {};
|
|
@@ -60,9 +55,8 @@ const handleFailure = (error) => {
|
|
|
60
55
|
});
|
|
61
56
|
}).catch((exception) => Promise.reject(exception));
|
|
62
57
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
endSession({ ...(0, import_loginParams.getLoginParams)(), skipRevoke: true }).catch(() => {
|
|
58
|
+
if (import_props.httpClientProps.endSession) {
|
|
59
|
+
import_props.httpClientProps.endSession({ ...(0, import_loginParams.getLoginParams)(), skipRevoke: true }).catch(() => {
|
|
66
60
|
});
|
|
67
61
|
}
|
|
68
62
|
}
|
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(auth_exports);
|
|
|
26
26
|
var import_effects = require("redux-saga/effects");
|
|
27
27
|
var import_actions = require("../../data/auth/actions.js");
|
|
28
28
|
var import_auth = require("../../utils/auth/index.js");
|
|
29
|
-
var
|
|
29
|
+
var import_logger = require("../../utils/logger.js");
|
|
30
30
|
var import_log_records = require("../../utils/log-records.js");
|
|
31
31
|
function* login({
|
|
32
32
|
payload
|
|
@@ -35,7 +35,7 @@ function* login({
|
|
|
35
35
|
yield (0, import_effects.call)(import_auth.authorize, payload);
|
|
36
36
|
yield (0, import_effects.put)({ type: import_actions.LOGIN_SUCCESS });
|
|
37
37
|
} catch (err) {
|
|
38
|
-
(0,
|
|
38
|
+
(0, import_logger.getLogger)()?.error({
|
|
39
39
|
...import_log_records.logRecords.LOGIN_FAILED,
|
|
40
40
|
exception: err
|
|
41
41
|
});
|
|
@@ -47,7 +47,7 @@ function* logout({
|
|
|
47
47
|
try {
|
|
48
48
|
yield (0, import_effects.call)(import_auth.endSession, payload);
|
|
49
49
|
} catch (err) {
|
|
50
|
-
(0,
|
|
50
|
+
(0, import_logger.getLogger)()?.error({
|
|
51
51
|
...import_log_records.logRecords.LOGOUT_FAILED,
|
|
52
52
|
exception: err
|
|
53
53
|
});
|
|
@@ -33,9 +33,9 @@ var import_user_session_event = require("../../analytics/user-session-event.js")
|
|
|
33
33
|
var import_appdynamics = require("../../analytics/appdynamics.js");
|
|
34
34
|
var import_helper = require("./helper.js");
|
|
35
35
|
var import_config = require("../app-config/config.js");
|
|
36
|
-
var import_micro_frontend = require("../micro-frontend/index.js");
|
|
37
36
|
var import_log_records = require("../log-records.js");
|
|
38
37
|
var import_loginParams = require("./loginParams.js");
|
|
38
|
+
var import_logger = require("../logger.js");
|
|
39
39
|
const IDP_ENDPOINT_CONFIG_KEY = "serviceEndpoints.idp";
|
|
40
40
|
const isUserAuthorized = () => !!(0, import_helper.getAuthorizationHeader)();
|
|
41
41
|
const getIDPInfoFromUrl = () => {
|
|
@@ -99,7 +99,7 @@ const endSession = async ({
|
|
|
99
99
|
logoutUrl.search = searchParams.toString();
|
|
100
100
|
window.location.replace(logoutUrl.href);
|
|
101
101
|
} catch (err) {
|
|
102
|
-
(0,
|
|
102
|
+
(0, import_logger.getLogger)()?.error({
|
|
103
103
|
...import_log_records.logRecords.LOGOUT_FAILED,
|
|
104
104
|
exception: err
|
|
105
105
|
});
|
|
@@ -156,7 +156,7 @@ const authorize = async ({
|
|
|
156
156
|
scope,
|
|
157
157
|
responseType
|
|
158
158
|
});
|
|
159
|
-
(0,
|
|
159
|
+
(0, import_logger.getLogger)()?.error({
|
|
160
160
|
...import_log_records.logRecords.LOGIN_FAILED,
|
|
161
161
|
exception: err
|
|
162
162
|
});
|
|
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var console_logger_exports = {};
|
|
20
20
|
__export(console_logger_exports, {
|
|
21
|
-
|
|
21
|
+
consoleLogger: () => consoleLogger
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(console_logger_exports);
|
|
24
24
|
var import_pui_diagnostics = require("@elliemae/pui-diagnostics");
|
|
25
|
-
var import_config = require("
|
|
26
|
-
const
|
|
25
|
+
var import_config = require("./app-config/config.js");
|
|
26
|
+
const consoleLogger = (() => {
|
|
27
27
|
if (!import_pui_diagnostics.logger) return console;
|
|
28
28
|
return (0, import_pui_diagnostics.logger)({
|
|
29
29
|
transport: (0, import_pui_diagnostics.Console)(),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var logger_exports = {};
|
|
20
|
+
__export(logger_exports, {
|
|
21
|
+
getLogger: () => getLogger,
|
|
22
|
+
setLogger: () => setLogger
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(logger_exports);
|
|
25
|
+
let logger = null;
|
|
26
|
+
const setLogger = (newLogger) => {
|
|
27
|
+
logger = newLogger;
|
|
28
|
+
};
|
|
29
|
+
const getLogger = () => logger;
|
|
@@ -37,7 +37,8 @@ var import_window = require("../window.js");
|
|
|
37
37
|
var import_app_config = require("../app-config/index.js");
|
|
38
38
|
var import_config = require("../app-config/config.js");
|
|
39
39
|
var import_history2 = require("../history.js");
|
|
40
|
-
var import_console_logger = require("
|
|
40
|
+
var import_console_logger = require("../console-logger.js");
|
|
41
|
+
var import_logger = require("../logger.js");
|
|
41
42
|
var import_web_storage = require("../web-storage.js");
|
|
42
43
|
var import_web_analytics = require("../../analytics/web-analytics.js");
|
|
43
44
|
var import_appdynamics = require("../../analytics/appdynamics.js");
|
|
@@ -71,7 +72,8 @@ class CMicroAppGuest {
|
|
|
71
72
|
theme: (0, import_pui_theme.getDefaultTheme)(),
|
|
72
73
|
manifestPath: "./latest"
|
|
73
74
|
};
|
|
74
|
-
this.logger = params?.logger || import_console_logger.
|
|
75
|
+
this.logger = params?.logger || import_console_logger.consoleLogger;
|
|
76
|
+
(0, import_logger.setLogger)(this.logger);
|
|
75
77
|
this.onInit = params?.onInit;
|
|
76
78
|
this.onMount = params?.onMount;
|
|
77
79
|
this.onUnmount = params?.onUnmount;
|
|
@@ -28,15 +28,16 @@ var import_actions = require("../../data/wait-message/actions.js");
|
|
|
28
28
|
var import_error = require("../../data/error/index.js");
|
|
29
29
|
var import_actions2 = require("../../data/logout/actions.js");
|
|
30
30
|
var import_config = require("../app-config/config.js");
|
|
31
|
-
var import_session = require("../session.js");
|
|
32
31
|
var import_app_config = require("../app-config/index.js");
|
|
33
32
|
var import_history2 = require("../history.js");
|
|
34
|
-
var import_console_logger = require("
|
|
33
|
+
var import_console_logger = require("../console-logger.js");
|
|
34
|
+
var import_logger = require("../logger.js");
|
|
35
35
|
var import_constants = require("../constants.js");
|
|
36
36
|
var import_window = require("../window.js");
|
|
37
37
|
var import_analytics = require("../../analytics/index.js");
|
|
38
38
|
var import_appdynamics = require("../../analytics/appdynamics.js");
|
|
39
39
|
var import_web_analytics = require("../../analytics/web-analytics.js");
|
|
40
|
+
var import_session = require("../session.js");
|
|
40
41
|
class CMicroAppHost {
|
|
41
42
|
static instance;
|
|
42
43
|
logger;
|
|
@@ -49,7 +50,8 @@ class CMicroAppHost {
|
|
|
49
50
|
constructor(params) {
|
|
50
51
|
this.appId = (0, import_config.getAppConfigValue)("appId");
|
|
51
52
|
this.onInit = params?.onInit;
|
|
52
|
-
this.logger = params?.logger || import_console_logger.
|
|
53
|
+
this.logger = params?.logger || import_console_logger.consoleLogger;
|
|
54
|
+
(0, import_logger.setLogger)(this.logger);
|
|
53
55
|
this.onRenewSessionTimer = params?.onRenewSessionTimer;
|
|
54
56
|
this.props = {
|
|
55
57
|
systemVersion: params?.version ?? "latest",
|
|
@@ -136,8 +138,8 @@ class CMicroAppHost {
|
|
|
136
138
|
const store = (0, import_store.getStore)();
|
|
137
139
|
if (store) store.dispatch(import_actions2.logout.confirm());
|
|
138
140
|
}
|
|
139
|
-
renewSessionTimer() {
|
|
140
|
-
(0, import_session.
|
|
141
|
+
async renewSessionTimer() {
|
|
142
|
+
await (0, import_session.renewSession)();
|
|
141
143
|
if (this.onRenewSessionTimer) this.onRenewSessionTimer();
|
|
142
144
|
}
|
|
143
145
|
getBreakpoint() {
|
|
@@ -20,6 +20,7 @@ var session_exports = {};
|
|
|
20
20
|
__export(session_exports, {
|
|
21
21
|
addEventListeners: () => addEventListeners,
|
|
22
22
|
initSessionMonitoring: () => initSessionMonitoring,
|
|
23
|
+
renewSession: () => renewSession,
|
|
23
24
|
resetUserIdleTime: () => resetUserIdleTime,
|
|
24
25
|
stopSessionMonitoring: () => stopSessionMonitoring,
|
|
25
26
|
subscribeToResetSession: () => subscribeToResetSession,
|
|
@@ -29,9 +30,15 @@ __export(session_exports, {
|
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(session_exports);
|
|
31
32
|
var import_lodash = require("lodash");
|
|
33
|
+
var import_loginParams = require("./auth/loginParams.js");
|
|
34
|
+
var import_helper = require("./auth/helper.js");
|
|
35
|
+
var import_auth = require("../api/auth/index.js");
|
|
36
|
+
var import_logger = require("./logger.js");
|
|
37
|
+
var import_log_records = require("./log-records.js");
|
|
38
|
+
var import_auth2 = require("./auth/index.js");
|
|
32
39
|
var import_config = require("./app-config/config.js");
|
|
33
40
|
var import_constants = require("./constants.js");
|
|
34
|
-
const
|
|
41
|
+
const SESSION_RENEWAL_INTERVAL = 6e4;
|
|
35
42
|
let lastUserActivityTimeStamp = Date.now();
|
|
36
43
|
const warnListeners = [];
|
|
37
44
|
const expiryListeners = [];
|
|
@@ -49,10 +56,31 @@ const resetUserIdleTime = (resetWarningModal = false) => {
|
|
|
49
56
|
}).catch(() => {
|
|
50
57
|
});
|
|
51
58
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
const renewSession = async () => {
|
|
60
|
+
const loginParams = (0, import_loginParams.getLoginParams)();
|
|
61
|
+
try {
|
|
62
|
+
resetUserIdleTime(true);
|
|
63
|
+
if (loginParams?.clientId) {
|
|
64
|
+
const authToken = (0, import_helper.getAuthorizationHeader)();
|
|
65
|
+
if (!authToken)
|
|
66
|
+
throw new Error("Authorization token not found to extend session");
|
|
67
|
+
const accessToken = authToken.split(" ")[1];
|
|
68
|
+
await (0, import_auth.introspectToken)({ clientId: loginParams.clientId, accessToken });
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
(0, import_logger.getLogger)()?.error({
|
|
72
|
+
...import_log_records.logRecords.SESSION_RENEWAL_FAILED,
|
|
73
|
+
exception: e
|
|
74
|
+
});
|
|
75
|
+
await (0, import_auth2.endSession)({ ...loginParams, skipRevoke: true });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const renewSessionAtInterval = (0, import_lodash.throttle)(
|
|
79
|
+
renewSession,
|
|
80
|
+
SESSION_RENEWAL_INTERVAL,
|
|
81
|
+
{
|
|
82
|
+
leading: true
|
|
83
|
+
}
|
|
56
84
|
);
|
|
57
85
|
const isPastWarningTime = (warnInterval = (0, import_config.getAppConfigValue)("sessionTimeoutWarnInterval") || import_constants.SESSION_TIMEOUT_INTERVAL.WARN) => Date.now() - lastUserActivityTimeStamp > warnInterval;
|
|
58
86
|
const isPastSessionTimeoutTime = (sessionTimeout = (0, import_config.getAppConfigValue)("sessionTimeoutInterval") || import_constants.SESSION_TIMEOUT_INTERVAL.EXPIRY) => Date.now() - lastUserActivityTimeStamp > sessionTimeout;
|
|
@@ -64,7 +92,7 @@ const notifySessionExpiryWarning = () => {
|
|
|
64
92
|
(listener) => listener(sessionExpiryWarningNotifiedAt)
|
|
65
93
|
);
|
|
66
94
|
userInteractionEvents.forEach((eventType) => {
|
|
67
|
-
document.removeEventListener(eventType,
|
|
95
|
+
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
68
96
|
});
|
|
69
97
|
}).catch(() => {
|
|
70
98
|
});
|
|
@@ -74,7 +102,7 @@ const notifySessionExpiry = () => Promise.resolve().then(() => {
|
|
|
74
102
|
});
|
|
75
103
|
const stopSessionMonitoring = () => {
|
|
76
104
|
userInteractionEvents.forEach((eventType) => {
|
|
77
|
-
document.removeEventListener(eventType,
|
|
105
|
+
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
78
106
|
});
|
|
79
107
|
clearInterval(timerHandle);
|
|
80
108
|
warnListeners.length = 0;
|
|
@@ -97,7 +125,7 @@ const removeListeners = (arr, cb) => {
|
|
|
97
125
|
};
|
|
98
126
|
const addEventListeners = () => {
|
|
99
127
|
userInteractionEvents.forEach((eventType) => {
|
|
100
|
-
document.addEventListener(eventType,
|
|
128
|
+
document.addEventListener(eventType, renewSessionAtInterval);
|
|
101
129
|
});
|
|
102
130
|
};
|
|
103
131
|
const initSessionMonitoring = () => {
|
|
@@ -119,7 +147,7 @@ const subscribeToResetSession = (onResetListener) => {
|
|
|
119
147
|
const trackActivity = (element, cb) => {
|
|
120
148
|
if (!element) return () => {
|
|
121
149
|
};
|
|
122
|
-
const thorttledCb = (0, import_lodash.throttle)(cb,
|
|
150
|
+
const thorttledCb = (0, import_lodash.throttle)(cb, SESSION_RENEWAL_INTERVAL, { leading: true });
|
|
123
151
|
userInteractionEvents.forEach(
|
|
124
152
|
(r) => element.addEventListener(r, thorttledCb)
|
|
125
153
|
);
|
|
@@ -48,8 +48,8 @@ const useFrameLoaded = ({ id, documentEle }) => {
|
|
|
48
48
|
const host = import_host.CMicroAppHost.getInstance();
|
|
49
49
|
addBaseTag(id, documentEle);
|
|
50
50
|
updateContainerId(id, documentEle);
|
|
51
|
-
const removeUserActivityListener = (0, import_session.trackActivity)(documentEle, () => {
|
|
52
|
-
host.renewSessionTimer();
|
|
51
|
+
const removeUserActivityListener = (0, import_session.trackActivity)(documentEle, async () => {
|
|
52
|
+
await host.renewSessionTimer();
|
|
53
53
|
});
|
|
54
54
|
return () => {
|
|
55
55
|
if (removeUserActivityListener) {
|
|
@@ -30,7 +30,6 @@ var import_ds_dialog = require("@elliemae/ds-dialog");
|
|
|
30
30
|
var import_react2 = require("../../../data/react.js");
|
|
31
31
|
var import_actions = require("../../../data/logout/actions.js");
|
|
32
32
|
var import_session = require("../../../utils/session.js");
|
|
33
|
-
var import_extendSession = require("../../../utils/extendSession.js");
|
|
34
33
|
var import_customHooks = require("./customHooks.js");
|
|
35
34
|
const SessionExpiry = (0, import_react.memo)(
|
|
36
35
|
({ open, warningNotifiedAt = 0 }) => {
|
|
@@ -45,7 +44,7 @@ const SessionExpiry = (0, import_react.memo)(
|
|
|
45
44
|
}, [open]);
|
|
46
45
|
const resetSession = async () => {
|
|
47
46
|
setIsOpen(false);
|
|
48
|
-
await (0,
|
|
47
|
+
await (0, import_session.renewSession)();
|
|
49
48
|
(0, import_session.addEventListeners)();
|
|
50
49
|
dispatch(import_actions.logout.cancel());
|
|
51
50
|
};
|
|
@@ -38,7 +38,7 @@ var import_reducer = require("../data/auth/reducer.js");
|
|
|
38
38
|
var import_auth = require("../sideeffect/auth/index.js");
|
|
39
39
|
var import_login = require("./login/index.js");
|
|
40
40
|
var import_auth2 = require("../utils/auth/index.js");
|
|
41
|
-
var
|
|
41
|
+
var import_props = require("../communication/http-client/props.js");
|
|
42
42
|
const key = "auth";
|
|
43
43
|
const RequireAuth = ({
|
|
44
44
|
children,
|
|
@@ -52,7 +52,7 @@ const RequireAuth = ({
|
|
|
52
52
|
reducer: import_reducer.authReducer,
|
|
53
53
|
saga: import_auth.authentication
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
import_props.httpClientProps.endSession = import_auth2.endSession;
|
|
56
56
|
const userAuthorized = (0, import_auth2.isUserAuthorized)();
|
|
57
57
|
if (userAuthorized) {
|
|
58
58
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
@@ -27,11 +27,13 @@ var import_react2 = require("../../data/react.js");
|
|
|
27
27
|
var import_actions = require("../../data/logout/actions.js");
|
|
28
28
|
var import_session = require("../../utils/session.js");
|
|
29
29
|
var import_session_expiry = require("../modals/session-expiry/index.js");
|
|
30
|
+
var import_props = require("../../communication/http-client/props.js");
|
|
30
31
|
const SessionTimeout = () => {
|
|
31
32
|
const dispatch = (0, import_react2.useAppDispatch)();
|
|
32
33
|
const [showSessionExpiryWarning, setSessionExpiryWarning] = (0, import_react.useState)(false);
|
|
33
34
|
const [warningNotifiedAt, setwarningNotifiedAt] = (0, import_react.useState)();
|
|
34
35
|
(0, import_react.useEffect)(() => {
|
|
36
|
+
import_props.httpClientProps.resetUserIdleTime = import_session.resetUserIdleTime;
|
|
35
37
|
(0, import_session.initSessionMonitoring)();
|
|
36
38
|
const warningCb = (0, import_session.subscribeToSessionExpiryWarning)(
|
|
37
39
|
(sessionExpiryWarningNotifiedAt) => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class HttpClientProps {
|
|
2
|
+
#resetUserIdleTime = () => {
|
|
3
|
+
};
|
|
4
|
+
#endSession = async () => {
|
|
5
|
+
};
|
|
6
|
+
get resetUserIdleTime() {
|
|
7
|
+
return this.#resetUserIdleTime;
|
|
8
|
+
}
|
|
9
|
+
set resetUserIdleTime(fn) {
|
|
10
|
+
this.#resetUserIdleTime = fn;
|
|
11
|
+
}
|
|
12
|
+
get endSession() {
|
|
13
|
+
return this.#endSession;
|
|
14
|
+
}
|
|
15
|
+
set endSession(fn) {
|
|
16
|
+
this.#endSession = fn;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const httpClientProps = new HttpClientProps();
|
|
20
|
+
export {
|
|
21
|
+
httpClientProps
|
|
22
|
+
};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { getLoginParams } from "../../utils/auth/loginParams.js";
|
|
3
|
+
import { httpClientProps } from "./props.js";
|
|
3
4
|
const HTTP_UNAUTHORIZED = 401;
|
|
4
5
|
let unAuthorizedFailureHandler = null;
|
|
5
|
-
let endSessionHandler = null;
|
|
6
6
|
const onAuthorizationFailure = (callback) => {
|
|
7
7
|
unAuthorizedFailureHandler = callback;
|
|
8
8
|
};
|
|
9
|
-
const getEndSessionHandler = () => endSessionHandler;
|
|
10
|
-
const setEndSessionHandler = (handler) => {
|
|
11
|
-
endSessionHandler = handler;
|
|
12
|
-
};
|
|
13
9
|
const handleSuccess = (response) => response;
|
|
14
10
|
const handleFailure = (error) => {
|
|
15
11
|
const { status } = (error || {}).response || {};
|
|
@@ -24,9 +20,8 @@ const handleFailure = (error) => {
|
|
|
24
20
|
});
|
|
25
21
|
}).catch((exception) => Promise.reject(exception));
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
endSession({ ...getLoginParams(), skipRevoke: true }).catch(() => {
|
|
23
|
+
if (httpClientProps.endSession) {
|
|
24
|
+
httpClientProps.endSession({ ...getLoginParams(), skipRevoke: true }).catch(() => {
|
|
30
25
|
});
|
|
31
26
|
}
|
|
32
27
|
}
|
|
@@ -35,6 +30,5 @@ const handleFailure = (error) => {
|
|
|
35
30
|
export {
|
|
36
31
|
handleFailure,
|
|
37
32
|
handleSuccess,
|
|
38
|
-
onAuthorizationFailure
|
|
39
|
-
setEndSessionHandler
|
|
33
|
+
onAuthorizationFailure
|
|
40
34
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
LOGIN_SUCCESS
|
|
10
10
|
} from "../../data/auth/actions.js";
|
|
11
11
|
import { authorize, endSession } from "../../utils/auth/index.js";
|
|
12
|
-
import { getLogger } from "../../utils/
|
|
12
|
+
import { getLogger } from "../../utils/logger.js";
|
|
13
13
|
import { logRecords } from "../../utils/log-records.js";
|
|
14
14
|
function* login({
|
|
15
15
|
payload
|
|
@@ -18,7 +18,7 @@ function* login({
|
|
|
18
18
|
yield call(authorize, payload);
|
|
19
19
|
yield put({ type: LOGIN_SUCCESS });
|
|
20
20
|
} catch (err) {
|
|
21
|
-
getLogger()
|
|
21
|
+
getLogger()?.error({
|
|
22
22
|
...logRecords.LOGIN_FAILED,
|
|
23
23
|
exception: err
|
|
24
24
|
});
|
|
@@ -30,7 +30,7 @@ function* logout({
|
|
|
30
30
|
try {
|
|
31
31
|
yield call(endSession, payload);
|
|
32
32
|
} catch (err) {
|
|
33
|
-
getLogger()
|
|
33
|
+
getLogger()?.error({
|
|
34
34
|
...logRecords.LOGOUT_FAILED,
|
|
35
35
|
exception: err
|
|
36
36
|
});
|
|
@@ -9,9 +9,9 @@ import { loginEvent, logoutEvent } from "../../analytics/user-session-event.js";
|
|
|
9
9
|
import { setAppDynamicsUserData } from "../../analytics/appdynamics.js";
|
|
10
10
|
import { getAuthorizationHeader, setAuthorizationHeader } from "./helper.js";
|
|
11
11
|
import { getAppConfigValue } from "../app-config/config.js";
|
|
12
|
-
import { getLogger } from "../micro-frontend/index.js";
|
|
13
12
|
import { logRecords } from "../log-records.js";
|
|
14
13
|
import { setLoginParams } from "./loginParams.js";
|
|
14
|
+
import { getLogger } from "../logger.js";
|
|
15
15
|
const IDP_ENDPOINT_CONFIG_KEY = "serviceEndpoints.idp";
|
|
16
16
|
const isUserAuthorized = () => !!getAuthorizationHeader();
|
|
17
17
|
const getIDPInfoFromUrl = () => {
|
|
@@ -75,7 +75,7 @@ const endSession = async ({
|
|
|
75
75
|
logoutUrl.search = searchParams.toString();
|
|
76
76
|
window.location.replace(logoutUrl.href);
|
|
77
77
|
} catch (err) {
|
|
78
|
-
getLogger()
|
|
78
|
+
getLogger()?.error({
|
|
79
79
|
...logRecords.LOGOUT_FAILED,
|
|
80
80
|
exception: err
|
|
81
81
|
});
|
|
@@ -132,7 +132,7 @@ const authorize = async ({
|
|
|
132
132
|
scope,
|
|
133
133
|
responseType
|
|
134
134
|
});
|
|
135
|
-
getLogger()
|
|
135
|
+
getLogger()?.error({
|
|
136
136
|
...logRecords.LOGIN_FAILED,
|
|
137
137
|
exception: err
|
|
138
138
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger as uiLogger, Console } from "@elliemae/pui-diagnostics";
|
|
2
|
-
import { getAppConfigValue } from "
|
|
3
|
-
const
|
|
2
|
+
import { getAppConfigValue } from "./app-config/config.js";
|
|
3
|
+
const consoleLogger = (() => {
|
|
4
4
|
if (!uiLogger) return console;
|
|
5
5
|
return uiLogger({
|
|
6
6
|
transport: Console(),
|
|
@@ -14,5 +14,5 @@ const logger = (() => {
|
|
|
14
14
|
});
|
|
15
15
|
})();
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
consoleLogger
|
|
18
18
|
};
|
|
@@ -4,7 +4,8 @@ import { getWindow } from "../window.js";
|
|
|
4
4
|
import { loadAppConfig } from "../app-config/index.js";
|
|
5
5
|
import { getAppConfigValue } from "../app-config/config.js";
|
|
6
6
|
import { browserHistory } from "../history.js";
|
|
7
|
-
import {
|
|
7
|
+
import { consoleLogger } from "../console-logger.js";
|
|
8
|
+
import { setLogger } from "../logger.js";
|
|
8
9
|
import { removeStorageEvents } from "../web-storage.js";
|
|
9
10
|
import { updateBAEventParameters } from "../../analytics/web-analytics.js";
|
|
10
11
|
import { setAppDynamicsUserData } from "../../analytics/appdynamics.js";
|
|
@@ -38,7 +39,8 @@ class CMicroAppGuest {
|
|
|
38
39
|
theme: getDefaultTheme(),
|
|
39
40
|
manifestPath: "./latest"
|
|
40
41
|
};
|
|
41
|
-
this.logger = params?.logger ||
|
|
42
|
+
this.logger = params?.logger || consoleLogger;
|
|
43
|
+
setLogger(this.logger);
|
|
42
44
|
this.onInit = params?.onInit;
|
|
43
45
|
this.onMount = params?.onMount;
|
|
44
46
|
this.onUnmount = params?.onUnmount;
|
|
@@ -5,10 +5,10 @@ import { waitMessage } from "../../data/wait-message/actions.js";
|
|
|
5
5
|
import { actions as error } from "../../data/error/index.js";
|
|
6
6
|
import { logout } from "../../data/logout/actions.js";
|
|
7
7
|
import { getAppConfigValue } from "../app-config/config.js";
|
|
8
|
-
import { resetUserIdleTime } from "../session.js";
|
|
9
8
|
import { loadAppConfig } from "../app-config/index.js";
|
|
10
9
|
import { browserHistory } from "../history.js";
|
|
11
|
-
import {
|
|
10
|
+
import { consoleLogger } from "../console-logger.js";
|
|
11
|
+
import { setLogger } from "../logger.js";
|
|
12
12
|
import {
|
|
13
13
|
HOST_WINDOW_RESIZED,
|
|
14
14
|
HOST_WINDOW_BREAKPOINT_CHANGED
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { sendBAEvent } from "../../analytics/index.js";
|
|
22
22
|
import { setAppDynamicsUserData } from "../../analytics/appdynamics.js";
|
|
23
23
|
import { updateBAEventParameters } from "../../analytics/web-analytics.js";
|
|
24
|
+
import { renewSession } from "../session.js";
|
|
24
25
|
class CMicroAppHost {
|
|
25
26
|
static instance;
|
|
26
27
|
logger;
|
|
@@ -33,7 +34,8 @@ class CMicroAppHost {
|
|
|
33
34
|
constructor(params) {
|
|
34
35
|
this.appId = getAppConfigValue("appId");
|
|
35
36
|
this.onInit = params?.onInit;
|
|
36
|
-
this.logger = params?.logger ||
|
|
37
|
+
this.logger = params?.logger || consoleLogger;
|
|
38
|
+
setLogger(this.logger);
|
|
37
39
|
this.onRenewSessionTimer = params?.onRenewSessionTimer;
|
|
38
40
|
this.props = {
|
|
39
41
|
systemVersion: params?.version ?? "latest",
|
|
@@ -120,8 +122,8 @@ class CMicroAppHost {
|
|
|
120
122
|
const store = getStore();
|
|
121
123
|
if (store) store.dispatch(logout.confirm());
|
|
122
124
|
}
|
|
123
|
-
renewSessionTimer() {
|
|
124
|
-
|
|
125
|
+
async renewSessionTimer() {
|
|
126
|
+
await renewSession();
|
|
125
127
|
if (this.onRenewSessionTimer) this.onRenewSessionTimer();
|
|
126
128
|
}
|
|
127
129
|
getBreakpoint() {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { throttle } from "lodash";
|
|
2
|
+
import { getLoginParams } from "./auth/loginParams.js";
|
|
3
|
+
import { getAuthorizationHeader } from "./auth/helper.js";
|
|
4
|
+
import { introspectToken } from "../api/auth/index.js";
|
|
5
|
+
import { getLogger } from "./logger.js";
|
|
6
|
+
import { logRecords } from "./log-records.js";
|
|
7
|
+
import { endSession } from "./auth/index.js";
|
|
2
8
|
import { getAppConfigValue } from "./app-config/config.js";
|
|
3
9
|
import { SESSION_TIMEOUT_INTERVAL } from "./constants.js";
|
|
4
|
-
const
|
|
10
|
+
const SESSION_RENEWAL_INTERVAL = 6e4;
|
|
5
11
|
let lastUserActivityTimeStamp = Date.now();
|
|
6
12
|
const warnListeners = [];
|
|
7
13
|
const expiryListeners = [];
|
|
@@ -19,10 +25,31 @@ const resetUserIdleTime = (resetWarningModal = false) => {
|
|
|
19
25
|
}).catch(() => {
|
|
20
26
|
});
|
|
21
27
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const renewSession = async () => {
|
|
29
|
+
const loginParams = getLoginParams();
|
|
30
|
+
try {
|
|
31
|
+
resetUserIdleTime(true);
|
|
32
|
+
if (loginParams?.clientId) {
|
|
33
|
+
const authToken = getAuthorizationHeader();
|
|
34
|
+
if (!authToken)
|
|
35
|
+
throw new Error("Authorization token not found to extend session");
|
|
36
|
+
const accessToken = authToken.split(" ")[1];
|
|
37
|
+
await introspectToken({ clientId: loginParams.clientId, accessToken });
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
getLogger()?.error({
|
|
41
|
+
...logRecords.SESSION_RENEWAL_FAILED,
|
|
42
|
+
exception: e
|
|
43
|
+
});
|
|
44
|
+
await endSession({ ...loginParams, skipRevoke: true });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const renewSessionAtInterval = throttle(
|
|
48
|
+
renewSession,
|
|
49
|
+
SESSION_RENEWAL_INTERVAL,
|
|
50
|
+
{
|
|
51
|
+
leading: true
|
|
52
|
+
}
|
|
26
53
|
);
|
|
27
54
|
const isPastWarningTime = (warnInterval = getAppConfigValue("sessionTimeoutWarnInterval") || SESSION_TIMEOUT_INTERVAL.WARN) => Date.now() - lastUserActivityTimeStamp > warnInterval;
|
|
28
55
|
const isPastSessionTimeoutTime = (sessionTimeout = getAppConfigValue("sessionTimeoutInterval") || SESSION_TIMEOUT_INTERVAL.EXPIRY) => Date.now() - lastUserActivityTimeStamp > sessionTimeout;
|
|
@@ -34,7 +61,7 @@ const notifySessionExpiryWarning = () => {
|
|
|
34
61
|
(listener) => listener(sessionExpiryWarningNotifiedAt)
|
|
35
62
|
);
|
|
36
63
|
userInteractionEvents.forEach((eventType) => {
|
|
37
|
-
document.removeEventListener(eventType,
|
|
64
|
+
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
38
65
|
});
|
|
39
66
|
}).catch(() => {
|
|
40
67
|
});
|
|
@@ -44,7 +71,7 @@ const notifySessionExpiry = () => Promise.resolve().then(() => {
|
|
|
44
71
|
});
|
|
45
72
|
const stopSessionMonitoring = () => {
|
|
46
73
|
userInteractionEvents.forEach((eventType) => {
|
|
47
|
-
document.removeEventListener(eventType,
|
|
74
|
+
document.removeEventListener(eventType, renewSessionAtInterval);
|
|
48
75
|
});
|
|
49
76
|
clearInterval(timerHandle);
|
|
50
77
|
warnListeners.length = 0;
|
|
@@ -67,7 +94,7 @@ const removeListeners = (arr, cb) => {
|
|
|
67
94
|
};
|
|
68
95
|
const addEventListeners = () => {
|
|
69
96
|
userInteractionEvents.forEach((eventType) => {
|
|
70
|
-
document.addEventListener(eventType,
|
|
97
|
+
document.addEventListener(eventType, renewSessionAtInterval);
|
|
71
98
|
});
|
|
72
99
|
};
|
|
73
100
|
const initSessionMonitoring = () => {
|
|
@@ -89,7 +116,7 @@ const subscribeToResetSession = (onResetListener) => {
|
|
|
89
116
|
const trackActivity = (element, cb) => {
|
|
90
117
|
if (!element) return () => {
|
|
91
118
|
};
|
|
92
|
-
const thorttledCb = throttle(cb,
|
|
119
|
+
const thorttledCb = throttle(cb, SESSION_RENEWAL_INTERVAL, { leading: true });
|
|
93
120
|
userInteractionEvents.forEach(
|
|
94
121
|
(r) => element.addEventListener(r, thorttledCb)
|
|
95
122
|
);
|
|
@@ -103,6 +130,7 @@ const trackActivity = (element, cb) => {
|
|
|
103
130
|
export {
|
|
104
131
|
addEventListeners,
|
|
105
132
|
initSessionMonitoring,
|
|
133
|
+
renewSession,
|
|
106
134
|
resetUserIdleTime,
|
|
107
135
|
stopSessionMonitoring,
|
|
108
136
|
subscribeToResetSession,
|
|
@@ -25,8 +25,8 @@ const useFrameLoaded = ({ id, documentEle }) => {
|
|
|
25
25
|
const host = CMicroAppHost.getInstance();
|
|
26
26
|
addBaseTag(id, documentEle);
|
|
27
27
|
updateContainerId(id, documentEle);
|
|
28
|
-
const removeUserActivityListener = trackActivity(documentEle, () => {
|
|
29
|
-
host.renewSessionTimer();
|
|
28
|
+
const removeUserActivityListener = trackActivity(documentEle, async () => {
|
|
29
|
+
await host.renewSessionTimer();
|
|
30
30
|
});
|
|
31
31
|
return () => {
|
|
32
32
|
if (removeUserActivityListener) {
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
} from "@elliemae/ds-dialog";
|
|
15
15
|
import { useAppDispatch } from "../../../data/react.js";
|
|
16
16
|
import { logout } from "../../../data/logout/actions.js";
|
|
17
|
-
import { addEventListeners } from "../../../utils/session.js";
|
|
18
|
-
import { extendUIandPSSSession } from "../../../utils/extendSession.js";
|
|
17
|
+
import { addEventListeners, renewSession } from "../../../utils/session.js";
|
|
19
18
|
import { useTrackSessionExpiry } from "./customHooks.js";
|
|
20
19
|
const SessionExpiry = memo(
|
|
21
20
|
({ open, warningNotifiedAt = 0 }) => {
|
|
@@ -30,7 +29,7 @@ const SessionExpiry = memo(
|
|
|
30
29
|
}, [open]);
|
|
31
30
|
const resetSession = async () => {
|
|
32
31
|
setIsOpen(false);
|
|
33
|
-
await
|
|
32
|
+
await renewSession();
|
|
34
33
|
addEventListeners();
|
|
35
34
|
dispatch(logout.cancel());
|
|
36
35
|
};
|
|
@@ -5,7 +5,7 @@ import { authReducer } from "../data/auth/reducer.js";
|
|
|
5
5
|
import { authentication } from "../sideeffect/auth/index.js";
|
|
6
6
|
import { Login } from "./login/index.js";
|
|
7
7
|
import { endSession, isUserAuthorized } from "../utils/auth/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { httpClientProps } from "../communication/http-client/props.js";
|
|
9
9
|
const key = "auth";
|
|
10
10
|
const RequireAuth = ({
|
|
11
11
|
children,
|
|
@@ -19,7 +19,7 @@ const RequireAuth = ({
|
|
|
19
19
|
reducer: authReducer,
|
|
20
20
|
saga: authentication
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
httpClientProps.endSession = endSession;
|
|
23
23
|
const userAuthorized = isUserAuthorized();
|
|
24
24
|
if (userAuthorized) {
|
|
25
25
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
@@ -7,14 +7,17 @@ import {
|
|
|
7
7
|
stopSessionMonitoring,
|
|
8
8
|
subscribeToSessionExpiryWarning,
|
|
9
9
|
subscribeToResetSession,
|
|
10
|
-
subscribeToSessionExpiry
|
|
10
|
+
subscribeToSessionExpiry,
|
|
11
|
+
resetUserIdleTime
|
|
11
12
|
} from "../../utils/session.js";
|
|
12
13
|
import { SessionExpiry } from "../modals/session-expiry/index.js";
|
|
14
|
+
import { httpClientProps } from "../../communication/http-client/props.js";
|
|
13
15
|
const SessionTimeout = () => {
|
|
14
16
|
const dispatch = useAppDispatch();
|
|
15
17
|
const [showSessionExpiryWarning, setSessionExpiryWarning] = useState(false);
|
|
16
18
|
const [warningNotifiedAt, setwarningNotifiedAt] = useState();
|
|
17
19
|
useEffect(() => {
|
|
20
|
+
httpClientProps.resetUserIdleTime = resetUserIdleTime;
|
|
18
21
|
initSessionMonitoring();
|
|
19
22
|
const warningCb = subscribeToSessionExpiryWarning(
|
|
20
23
|
(sessionExpiryWarningNotifiedAt) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ResetUserIdleTimeFn } from '../../utils/types.js';
|
|
2
|
+
import { EndSessionFn } from '../../utils/auth/types.js';
|
|
3
|
+
declare class HttpClientProps {
|
|
4
|
+
#private;
|
|
5
|
+
get resetUserIdleTime(): ResetUserIdleTimeFn;
|
|
6
|
+
set resetUserIdleTime(fn: ResetUserIdleTimeFn);
|
|
7
|
+
get endSession(): EndSessionFn;
|
|
8
|
+
set endSession(fn: EndSessionFn);
|
|
9
|
+
}
|
|
10
|
+
export declare const httpClientProps: HttpClientProps;
|
|
11
|
+
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { AxiosError, AxiosResponse } from 'axios';
|
|
2
|
-
import type { EndSessionFn } from '../../utils/auth/types.js';
|
|
3
2
|
type FailureCallback = {
|
|
4
3
|
(error: AxiosError): Promise<string>;
|
|
5
4
|
};
|
|
6
5
|
export declare const onAuthorizationFailure: (callback: FailureCallback) => void;
|
|
7
|
-
export declare const setEndSessionHandler: (handler: EndSessionFn) => void;
|
|
8
6
|
export declare const handleSuccess: (response: AxiosResponse) => AxiosResponse;
|
|
9
7
|
export declare const handleFailure: (error: AxiosError) => Promise<unknown>;
|
|
10
8
|
export {};
|
|
@@ -7,10 +7,10 @@ export declare const createReducer: (injectedReducers?: InjectedReducers) => Red
|
|
|
7
7
|
error: import("./error/index.js").ErrorState;
|
|
8
8
|
breakpoint: import("./breakpoint/index.js").BreakpointState;
|
|
9
9
|
liveMessage: import("./live-message/index.js").LiveMessageState;
|
|
10
|
-
}>, {
|
|
10
|
+
}>, import("redux").AnyAction | {
|
|
11
11
|
payload: import("./wait-message/reducer.js").WaitMessageState;
|
|
12
12
|
type: string;
|
|
13
|
-
} |
|
|
13
|
+
} | {
|
|
14
14
|
payload: import("./breakpoint/index.js").Breakpoints;
|
|
15
15
|
type: string;
|
|
16
16
|
}>;
|
|
@@ -5,10 +5,10 @@ declare const rootReducer: import("redux").Reducer<import("redux").CombinedState
|
|
|
5
5
|
error: import("./error/index.js").ErrorState;
|
|
6
6
|
breakpoint: import("./breakpoint/index.js").BreakpointState;
|
|
7
7
|
liveMessage: import("./live-message/index.js").LiveMessageState;
|
|
8
|
-
}>, {
|
|
8
|
+
}>, import("redux").AnyAction | {
|
|
9
9
|
payload: import("./wait-message/reducer.js").WaitMessageState;
|
|
10
10
|
type: string;
|
|
11
|
-
} |
|
|
11
|
+
} | {
|
|
12
12
|
payload: import("./breakpoint/index.js").Breakpoints;
|
|
13
13
|
type: string;
|
|
14
14
|
}>;
|
|
@@ -28,10 +28,10 @@ export declare const createAppStore: (initialState: import("redux").CombinedStat
|
|
|
28
28
|
error: import("./error/index.js").ErrorState;
|
|
29
29
|
breakpoint: import("./breakpoint/index.js").BreakpointState;
|
|
30
30
|
liveMessage: import("./live-message/index.js").LiveMessageState;
|
|
31
|
-
}, {
|
|
31
|
+
}, import("redux").AnyAction | {
|
|
32
32
|
payload: import("./wait-message/reducer.js").WaitMessageState;
|
|
33
33
|
type: string;
|
|
34
|
-
} |
|
|
34
|
+
} | {
|
|
35
35
|
payload: import("./breakpoint/index.js").Breakpoints;
|
|
36
36
|
type: string;
|
|
37
37
|
}, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ListenerMiddleware<unknown, import("@reduxjs/toolkit").ThunkDispatch<unknown, unknown, import("redux").AnyAction>, unknown>, import("@reduxjs/toolkit").ThunkMiddleware<import("redux").CombinedState<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const consoleLogger: Console | import("@elliemae/pui-diagnostics").Logger;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { DefaultTheme } from 'styled-components';
|
|
2
2
|
import { History, To } from 'history';
|
|
3
3
|
import type { IMicroAppGuest, IMicroAppHost, InitOptions, MountOptions } from '@elliemae/pui-micro-frontend-base';
|
|
4
|
-
import { MicroFrontEndLogger } from '
|
|
5
|
-
import { JSONValue } from '../types.js';
|
|
4
|
+
import { JSONValue, MicroFrontEndLogger } from '../types.js';
|
|
6
5
|
export interface GuestProps extends InitOptions {
|
|
7
6
|
prevState: JSONValue | null;
|
|
8
7
|
history: History;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { History, To } from 'history';
|
|
2
2
|
import { DefaultTheme } from 'styled-components';
|
|
3
3
|
import { IMicroAppHost, ResizeEventHandler, BreakpointChangeEventHandler, SubscriptionListener, BAEvent } from '@elliemae/pui-micro-frontend-base';
|
|
4
|
-
import { MicroFrontEndLogger } from '
|
|
4
|
+
import { MicroFrontEndLogger } from '../types.js';
|
|
5
5
|
type HostOptions = {
|
|
6
6
|
systemVersion: string;
|
|
7
7
|
history: History;
|
|
@@ -45,7 +45,7 @@ export declare class CMicroAppHost implements IMicroAppHost {
|
|
|
45
45
|
getAuthToken(): string;
|
|
46
46
|
renewAuthToken(): string;
|
|
47
47
|
logout(): void;
|
|
48
|
-
renewSessionTimer(this: CMicroAppHost): void
|
|
48
|
+
renewSessionTimer(this: CMicroAppHost): Promise<void>;
|
|
49
49
|
getBreakpoint(): keyof import("@elliemae/pui-theme").BreakPoints;
|
|
50
50
|
getViewportSize(): {
|
|
51
51
|
width: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResetUserIdleTimeFn } from './types.js';
|
|
1
2
|
type WARNLISTENER = {
|
|
2
3
|
(sessionExpiryWarningNotifiedAt: number | null): void;
|
|
3
4
|
};
|
|
@@ -7,12 +8,21 @@ type RESETLISTENER = {
|
|
|
7
8
|
type LISTENER = {
|
|
8
9
|
(): void;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* reset the UI idle time counter
|
|
13
|
+
* @param resetWarningModal - reset the warning modal
|
|
14
|
+
*/
|
|
15
|
+
export declare const resetUserIdleTime: ResetUserIdleTimeFn;
|
|
16
|
+
/**
|
|
17
|
+
* Extend the PSS session (Encompass session) by introspecting the token
|
|
18
|
+
* also reset the UI idle time counter
|
|
19
|
+
*/
|
|
20
|
+
export declare const renewSession: () => Promise<void>;
|
|
11
21
|
export declare const stopSessionMonitoring: () => void;
|
|
12
22
|
export declare const addEventListeners: () => void;
|
|
13
23
|
export declare const initSessionMonitoring: () => void;
|
|
14
24
|
export declare const subscribeToSessionExpiryWarning: (onSessionExpiryWarn: WARNLISTENER) => () => void;
|
|
15
25
|
export declare const subscribeToSessionExpiry: (onSessionExpiry: LISTENER) => () => void;
|
|
16
26
|
export declare const subscribeToResetSession: (onResetListener: RESETLISTENER) => () => void;
|
|
17
|
-
export declare const trackActivity: (element: Document | null, cb: (...args: unknown[]) =>
|
|
27
|
+
export declare const trackActivity: (element: Document | null, cb: (...args: unknown[]) => unknown) => () => void;
|
|
18
28
|
export {};
|
|
@@ -10,10 +10,10 @@ export declare const renderWithRedux: (ui: React.ReactElement, { initialState, s
|
|
|
10
10
|
error: import("../../data/error/index.js").ErrorState;
|
|
11
11
|
breakpoint: import("../../data/breakpoint/index.js").BreakpointState;
|
|
12
12
|
liveMessage: import("../../data/live-message/index.js").LiveMessageState;
|
|
13
|
-
}, {
|
|
13
|
+
}, import("redux").AnyAction | {
|
|
14
14
|
payload: import("../../data/wait-message/reducer.js").WaitMessageState;
|
|
15
15
|
type: string;
|
|
16
|
-
} |
|
|
16
|
+
} | {
|
|
17
17
|
payload: import("../../data/breakpoint/index.js").Breakpoints;
|
|
18
18
|
type: string;
|
|
19
19
|
}, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ListenerMiddleware<unknown, import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").AnyAction>, unknown>, import("redux-thunk").ThunkMiddleware<import("redux").CombinedState<{
|
|
@@ -13,10 +13,10 @@ export declare const renderWithRouterRedux: (ui: React.ReactElement, { route, hi
|
|
|
13
13
|
error: import("../../data/error/index.js").ErrorState;
|
|
14
14
|
breakpoint: import("../../data/breakpoint/index.js").BreakpointState;
|
|
15
15
|
liveMessage: import("../../data/live-message/index.js").LiveMessageState;
|
|
16
|
-
}, {
|
|
16
|
+
}, import("redux").AnyAction | {
|
|
17
17
|
payload: import("../../data/wait-message/reducer.js").WaitMessageState;
|
|
18
18
|
type: string;
|
|
19
|
-
} |
|
|
19
|
+
} | {
|
|
20
20
|
payload: import("../../data/breakpoint/index.js").Breakpoints;
|
|
21
21
|
type: string;
|
|
22
22
|
}, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ListenerMiddleware<unknown, import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").AnyAction>, unknown>, import("redux-thunk").ThunkMiddleware<import("redux").CombinedState<{
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Logger } from '@elliemae/pui-diagnostics';
|
|
1
2
|
export type JSONValue = Partial<{
|
|
2
3
|
[key: string]: JSONValue;
|
|
3
4
|
}> | JSONValue[] | string | number | boolean | null;
|
|
5
|
+
export type MicroFrontEndLogger = Logger | typeof console;
|
|
6
|
+
export type ResetUserIdleTimeFn = (resetWarningModal?: unknown) => void;
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var extendSession_exports = {};
|
|
20
|
-
__export(extendSession_exports, {
|
|
21
|
-
extendUIandPSSSession: () => extendUIandPSSSession
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(extendSession_exports);
|
|
24
|
-
var import_loginParams = require("./auth/loginParams.js");
|
|
25
|
-
var import_helper = require("./auth/helper.js");
|
|
26
|
-
var import_auth = require("../api/auth/index.js");
|
|
27
|
-
var import_micro_frontend = require("./micro-frontend/index.js");
|
|
28
|
-
var import_log_records = require("./log-records.js");
|
|
29
|
-
var import_auth2 = require("./auth/index.js");
|
|
30
|
-
var import_session = require("./session.js");
|
|
31
|
-
const extendUIandPSSSession = async () => {
|
|
32
|
-
const loginParams = (0, import_loginParams.getLoginParams)();
|
|
33
|
-
try {
|
|
34
|
-
const authToken = (0, import_helper.getAuthorizationHeader)();
|
|
35
|
-
if (!authToken)
|
|
36
|
-
throw new Error("Authorization token not found to extend session");
|
|
37
|
-
const accessToken = authToken.split(" ")[1];
|
|
38
|
-
await (0, import_auth.introspectToken)({ clientId: loginParams.clientId, accessToken });
|
|
39
|
-
(0, import_session.resetUserIdleTime)(true);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
(0, import_micro_frontend.getLogger)().error({
|
|
42
|
-
...import_log_records.logRecords.SESSION_RENEWAL_FAILED,
|
|
43
|
-
exception: e
|
|
44
|
-
});
|
|
45
|
-
await (0, import_auth2.endSession)({ ...loginParams, skipRevoke: true });
|
|
46
|
-
}
|
|
47
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getLoginParams } from "./auth/loginParams.js";
|
|
2
|
-
import { getAuthorizationHeader } from "./auth/helper.js";
|
|
3
|
-
import { introspectToken } from "../api/auth/index.js";
|
|
4
|
-
import { getLogger } from "./micro-frontend/index.js";
|
|
5
|
-
import { logRecords } from "./log-records.js";
|
|
6
|
-
import { endSession } from "./auth/index.js";
|
|
7
|
-
import { resetUserIdleTime } from "./session.js";
|
|
8
|
-
const extendUIandPSSSession = async () => {
|
|
9
|
-
const loginParams = getLoginParams();
|
|
10
|
-
try {
|
|
11
|
-
const authToken = getAuthorizationHeader();
|
|
12
|
-
if (!authToken)
|
|
13
|
-
throw new Error("Authorization token not found to extend session");
|
|
14
|
-
const accessToken = authToken.split(" ")[1];
|
|
15
|
-
await introspectToken({ clientId: loginParams.clientId, accessToken });
|
|
16
|
-
resetUserIdleTime(true);
|
|
17
|
-
} catch (e) {
|
|
18
|
-
getLogger().error({
|
|
19
|
-
...logRecords.SESSION_RENEWAL_FAILED,
|
|
20
|
-
exception: e
|
|
21
|
-
});
|
|
22
|
-
await endSession({ ...loginParams, skipRevoke: true });
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
extendUIandPSSSession
|
|
27
|
-
};
|