@elliemae/pui-app-sdk 5.10.0 → 5.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cjs/api/auth/index.js +2 -2
  2. package/dist/cjs/communication/http-client/index.js +3 -6
  3. package/dist/cjs/communication/http-client/response-interceptor.js +24 -11
  4. package/dist/cjs/data/appMiddleware.js +1 -2
  5. package/dist/cjs/data/auth/actions.js +2 -2
  6. package/dist/cjs/data/queryMiddleware.js +1 -2
  7. package/dist/cjs/index.js +0 -1
  8. package/dist/cjs/sideeffect/auth/index.js +2 -0
  9. package/dist/cjs/sideeffect/error-toast/index.js +1 -2
  10. package/dist/cjs/sideeffect/wait-message/index.js +2 -4
  11. package/dist/cjs/utils/app-config/index.js +1 -2
  12. package/dist/cjs/utils/auth/index.js +24 -14
  13. package/dist/cjs/utils/auth/loginParams.js +29 -0
  14. package/dist/cjs/utils/auth/types.js +16 -0
  15. package/dist/cjs/utils/extendSession.js +47 -0
  16. package/dist/cjs/utils/log-records.js +4 -0
  17. package/dist/cjs/utils/micro-frontend/console-logger.js +1 -2
  18. package/dist/cjs/utils/micro-frontend/guest.js +5 -10
  19. package/dist/cjs/utils/micro-frontend/host.js +7 -14
  20. package/dist/cjs/utils/micro-frontend/index.js +4 -8
  21. package/dist/cjs/utils/micro-frontend/ssfguest-adapter.js +1 -2
  22. package/dist/cjs/utils/session.js +2 -3
  23. package/dist/cjs/utils/window.js +3 -6
  24. package/dist/cjs/view/error-toast/index.js +1 -2
  25. package/dist/cjs/view/fields/autocomplete/index.js +2 -4
  26. package/dist/cjs/view/fields/input-mask/index.js +2 -4
  27. package/dist/cjs/view/form/index.js +1 -2
  28. package/dist/cjs/view/login/index.js +2 -4
  29. package/dist/cjs/view/micro-app/app-factory/index.js +8 -16
  30. package/dist/cjs/view/micro-app/resources/manifest.js +1 -2
  31. package/dist/cjs/view/micro-app/resources/script.js +6 -12
  32. package/dist/cjs/view/micro-app/resources/style.js +3 -6
  33. package/dist/cjs/view/micro-app/use-app-will-render.js +6 -11
  34. package/dist/cjs/view/micro-app/utils.js +2 -4
  35. package/dist/cjs/view/micro-iframe-app/use-frame-loaded.js +2 -3
  36. package/dist/cjs/view/modals/session-expiry/index.js +3 -2
  37. package/dist/cjs/view/session-timeout/index.js +1 -2
  38. package/dist/cjs/view/wait-message/use-html-wait-message.js +1 -2
  39. package/dist/esm/api/auth/index.js +2 -2
  40. package/dist/esm/communication/http-client/index.js +3 -6
  41. package/dist/esm/communication/http-client/response-interceptor.js +24 -11
  42. package/dist/esm/data/appMiddleware.js +1 -2
  43. package/dist/esm/data/auth/actions.js +2 -2
  44. package/dist/esm/data/queryMiddleware.js +1 -2
  45. package/dist/esm/index.js +1 -3
  46. package/dist/esm/sideeffect/auth/index.js +2 -0
  47. package/dist/esm/sideeffect/error-toast/index.js +1 -2
  48. package/dist/esm/sideeffect/wait-message/index.js +2 -4
  49. package/dist/esm/utils/app-config/index.js +1 -2
  50. package/dist/esm/utils/auth/index.js +24 -14
  51. package/dist/esm/utils/auth/loginParams.js +9 -0
  52. package/dist/esm/utils/auth/types.js +0 -0
  53. package/dist/esm/utils/extendSession.js +27 -0
  54. package/dist/esm/utils/log-records.js +4 -0
  55. package/dist/esm/utils/micro-frontend/console-logger.js +1 -2
  56. package/dist/esm/utils/micro-frontend/guest.js +5 -10
  57. package/dist/esm/utils/micro-frontend/host.js +7 -14
  58. package/dist/esm/utils/micro-frontend/index.js +4 -8
  59. package/dist/esm/utils/micro-frontend/ssfguest-adapter.js +1 -2
  60. package/dist/esm/utils/session.js +2 -3
  61. package/dist/esm/utils/window.js +3 -6
  62. package/dist/esm/view/error-toast/index.js +1 -2
  63. package/dist/esm/view/fields/autocomplete/index.js +2 -4
  64. package/dist/esm/view/fields/input-mask/index.js +2 -4
  65. package/dist/esm/view/form/index.js +1 -2
  66. package/dist/esm/view/login/index.js +2 -4
  67. package/dist/esm/view/micro-app/app-factory/index.js +8 -16
  68. package/dist/esm/view/micro-app/resources/manifest.js +1 -2
  69. package/dist/esm/view/micro-app/resources/script.js +6 -12
  70. package/dist/esm/view/micro-app/resources/style.js +3 -6
  71. package/dist/esm/view/micro-app/use-app-will-render.js +6 -11
  72. package/dist/esm/view/micro-app/utils.js +2 -4
  73. package/dist/esm/view/micro-iframe-app/use-frame-loaded.js +2 -3
  74. package/dist/esm/view/modals/session-expiry/index.js +4 -6
  75. package/dist/esm/view/session-timeout/index.js +1 -2
  76. package/dist/esm/view/wait-message/use-html-wait-message.js +1 -2
  77. package/dist/types/lib/api/auth/index.d.ts +2 -2
  78. package/dist/types/lib/communication/http-client/response-interceptor.d.ts +2 -0
  79. package/dist/types/lib/data/auth/actions.d.ts +2 -2
  80. package/dist/types/lib/index.d.ts +2 -1
  81. package/dist/types/lib/utils/auth/index.d.ts +4 -9
  82. package/dist/types/lib/utils/auth/loginParams.d.ts +10 -0
  83. package/dist/types/lib/utils/auth/types.d.ts +8 -0
  84. package/dist/types/lib/utils/custom-hooks/use-state-selector.d.ts +0 -2
  85. package/dist/types/lib/utils/extendSession.d.ts +5 -0
  86. package/dist/types/lib/utils/log-records.d.ts +4 -0
  87. package/package.json +36 -36
@@ -36,12 +36,10 @@ const Login = ({
36
36
  const dispatch = (0, import_react2.useAppDispatch)();
37
37
  const ref = (0, import_react.useRef)(false);
38
38
  (0, import_react.useEffect)(() => {
39
- if (ref.current)
40
- return;
39
+ if (ref.current) return;
41
40
  ref.current = true;
42
41
  (0, import_auth.login)({ clientId, scope, responseType }).then(({ authorized }) => {
43
- if (authorized)
44
- setUserAuthorized(true);
42
+ if (authorized) setUserAuthorized(true);
45
43
  dispatch({ type: import_actions.LOGIN_SUCCESS });
46
44
  }).catch(() => {
47
45
  }).finally(() => {
@@ -85,11 +85,9 @@ const mountApp = async ({ id, name }) => {
85
85
  };
86
86
  const unmountApp = async ({ id, name }) => {
87
87
  const app = (window.emui || {})[id];
88
- if (!app)
89
- return null;
88
+ if (!app) return null;
90
89
  const { unmount } = app;
91
- if (!unmount)
92
- return null;
90
+ if (!unmount) return null;
93
91
  if (typeof unmount !== "function")
94
92
  throw new Error(
95
93
  `unmount failed for application ${name} with id ${id}. unmount is not a valid function`
@@ -107,8 +105,7 @@ const addAppToActiveAppList = (id, elementIds) => {
107
105
  const { getRef } = app;
108
106
  activeApps[id] = { elementIds };
109
107
  const host = import_host.CMicroAppHost.getInstance();
110
- if (host)
111
- host.activeGuests[id] = getRef && getRef() || {};
108
+ if (host) host.activeGuests[id] = getRef && getRef() || {};
112
109
  return Promise.resolve();
113
110
  };
114
111
  const waitAndInitApplication = (appConfig, requests) => (
@@ -121,14 +118,12 @@ const waitAndInitApplication = (appConfig, requests) => (
121
118
  );
122
119
  const removeAssetsFromDOM = (id, documentEle = document) => {
123
120
  const host = import_host.CMicroAppHost.getInstance();
124
- if (host)
125
- delete host.activeGuests[id];
121
+ if (host) delete host.activeGuests[id];
126
122
  const { elementIds } = activeApps[id] || {};
127
123
  if (elementIds) {
128
124
  elementIds.forEach((elementId) => {
129
125
  const ele = documentEle.getElementById(elementId);
130
- if (ele)
131
- ele.remove();
126
+ if (ele) ele.remove();
132
127
  });
133
128
  delete activeApps[id];
134
129
  }
@@ -151,17 +146,14 @@ const unloadApp = ({
151
146
  hostUrl,
152
147
  documentEle
153
148
  }) => {
154
- if (!hostUrl)
155
- throw new Error("Unable to unload app. hostUrl is required");
149
+ if (!hostUrl) throw new Error("Unable to unload app. hostUrl is required");
156
150
  (0, import_micro_frontend.getLogger)().info(import_log_records.logRecords.APP_UNLOADING(id));
157
151
  const app = (window.emui || {})[id];
158
- if (!app)
159
- return;
152
+ if (!app) return;
160
153
  removeAssetsFromDOM(id, documentEle);
161
154
  (0, import_script.removeDynamicImportedScripts)(hostUrl, documentEle);
162
155
  (0, import_script.removePrefetchLinks)(hostUrl, documentEle);
163
156
  (0, import_style.removeDynamicImportedStyles)(hostUrl, documentEle);
164
- if (window.emui && window.emui[id])
165
- delete window.emui[id];
157
+ if (window.emui && window.emui[id]) delete window.emui[id];
166
158
  (0, import_micro_frontend.getLogger)().info(import_log_records.logRecords.APP_UNLOADING_COMPLETE(id));
167
159
  };
@@ -63,8 +63,7 @@ const getAppManifest = async ({
63
63
  };
64
64
  const getFullFileNameofAssetsFromManifest = (manifest, assetNames = []) => assetNames.reduce((assets, assetName) => {
65
65
  const fullFileName = manifest[assetName];
66
- if (fullFileName)
67
- assets.push(fullFileName);
66
+ if (fullFileName) assets.push(fullFileName);
68
67
  else {
69
68
  const logRecord = import_log_records.logRecords.ASSET_NOT_FOUND_IN_MANIFEST(assetName);
70
69
  (0, import_micro_frontend.getLogger)().error(logRecord);
@@ -34,24 +34,20 @@ const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
34
34
  throw new Error("Unable to add scripts to DOM. hostUrl is required.");
35
35
  return new Promise((resolve, reject) => {
36
36
  const ele = documentEle.createElement("script");
37
- if (!ele)
38
- reject(new Error("Unable to insert Application scripts."));
37
+ if (!ele) reject(new Error("Unable to insert Application scripts."));
39
38
  ele.id = `${APP_SCRIPT_ID_PREFIX}${name}-${index}`;
40
39
  const url = new URL(fileName, hostUrl);
41
40
  ele.src = (0, import_url.removeDoubleSlash)(url.href);
42
41
  ele.onload = resolve.bind(null, ele.id);
43
42
  ele.onerror = reject.bind(null, ele.id);
44
43
  ele.async = false;
45
- if (isHeadScript(ele.src))
46
- documentEle.head.appendChild(ele);
47
- else
48
- documentEle.body.appendChild(ele);
44
+ if (isHeadScript(ele.src)) documentEle.head.appendChild(ele);
45
+ else documentEle.body.appendChild(ele);
49
46
  });
50
47
  };
51
48
  const removeScriptFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
52
49
  const ele = documentEle.getElementById(elementId);
53
- if (!ele)
54
- console.warn(new Error(`script with id ${elementId} not found`));
50
+ if (!ele) console.warn(new Error(`script with id ${elementId} not found`));
55
51
  ele.remove();
56
52
  resolve();
57
53
  });
@@ -61,8 +57,7 @@ const removeDynamicImportedScripts = (hostUrl, documentEle) => {
61
57
  for (let index = scriptElements.length - 1; index >= 0; index -= 1) {
62
58
  const scriptEle = scriptElements[index];
63
59
  const { src } = scriptEle;
64
- if (hostPattern.test(src))
65
- scriptEle.remove();
60
+ if (hostPattern.test(src)) scriptEle.remove();
66
61
  }
67
62
  };
68
63
  const removePrefetchLinks = (hostUrl, documentEle) => {
@@ -71,7 +66,6 @@ const removePrefetchLinks = (hostUrl, documentEle) => {
71
66
  for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
72
67
  const ele = prefetchElements[index];
73
68
  const { href } = ele;
74
- if (hostPattern.test(href))
75
- ele.remove();
69
+ if (hostPattern.test(href)) ele.remove();
76
70
  }
77
71
  };
@@ -31,8 +31,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
31
31
  throw new Error("Unable to add styles to DOM. hostUrl is required.");
32
32
  return new Promise((resolve, reject) => {
33
33
  const ele = documentEle.createElement("link");
34
- if (!ele)
35
- reject(new Error("Unable to insert Application styles."));
34
+ if (!ele) reject(new Error("Unable to insert Application styles."));
36
35
  ele.id = `${APP_STYLE_ID_PREFIX}${name}-${index}`;
37
36
  ele.rel = "stylesheet";
38
37
  const url = new URL(fileName, hostUrl);
@@ -43,8 +42,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
43
42
  };
44
43
  const removeStyleFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
45
44
  const ele = documentEle.getElementById(elementId);
46
- if (!ele)
47
- console.warn(new Error(`style with id ${elementId} not found`));
45
+ if (!ele) console.warn(new Error(`style with id ${elementId} not found`));
48
46
  ele.remove();
49
47
  resolve();
50
48
  });
@@ -54,7 +52,6 @@ const removeDynamicImportedStyles = (hostUrl, documentEle) => {
54
52
  for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
55
53
  const ele = prefetchElements[index];
56
54
  const { href } = ele;
57
- if (hostPattern.test(href))
58
- ele.remove();
55
+ if (hostPattern.test(href)) ele.remove();
59
56
  }
60
57
  };
@@ -48,19 +48,16 @@ const useAppWillRender = ({
48
48
  async (appConfig, loadFailed = false) => {
49
49
  await (0, import_app_factory.unmountApp)(appConfig);
50
50
  (0, import_app_factory.unloadApp)(appConfig);
51
- if (!loadFailed && onUnloadComplete)
52
- onUnloadComplete();
51
+ if (!loadFailed && onUnloadComplete) onUnloadComplete();
53
52
  },
54
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
55
54
  []
56
55
  );
57
56
  const load = (0, import_react.useCallback)(
58
57
  async (appConfig) => {
59
- if (dispatch)
60
- dispatch(import_actions.waitMessage.open());
58
+ if (dispatch) dispatch(import_actions.waitMessage.open());
61
59
  try {
62
- if (ref.current)
63
- await ref.current;
60
+ if (ref.current) await ref.current;
64
61
  await (0, import_app_factory.loadApp)(appConfig);
65
62
  await (0, import_app_factory.mountApp)(appConfig);
66
63
  } catch (ex) {
@@ -71,15 +68,13 @@ const useAppWillRender = ({
71
68
  await unload(appConfig, true);
72
69
  throw ex;
73
70
  }
74
- if (dispatch)
75
- dispatch(import_actions.waitMessage.close());
71
+ if (dispatch) dispatch(import_actions.waitMessage.close());
76
72
  },
77
73
  [dispatch, unload]
78
74
  );
79
75
  (0, import_react.useLayoutEffect)(() => {
80
- if (!documentEle)
81
- return () => {
82
- };
76
+ if (!documentEle) return () => {
77
+ };
83
78
  const appConfig = (0, import_lodash.merge)(getConfig(), {
84
79
  documentEle,
85
80
  history,
@@ -24,12 +24,10 @@ module.exports = __toCommonJS(utils_exports);
24
24
  var import_config = require("../../utils/app-config/config.js");
25
25
  const getNavigationLinks = () => {
26
26
  const microApps = (0, import_config.getAppConfigValue)("microFrontendApps");
27
- if (!microApps)
28
- return [];
27
+ if (!microApps) return [];
29
28
  return Object.keys(microApps).reduce((value, id) => {
30
29
  const { name, homeRoute } = microApps[id] || {};
31
- if (name && homeRoute)
32
- value.push({ id, name, path: homeRoute });
30
+ if (name && homeRoute) value.push({ id, name, path: homeRoute });
33
31
  return value;
34
32
  }, []);
35
33
  };
@@ -43,9 +43,8 @@ const updateContainerId = (id, documentEle) => {
43
43
  };
44
44
  const useFrameLoaded = ({ id, documentEle }) => {
45
45
  (0, import_react.useEffect)(() => {
46
- if (!documentEle)
47
- return () => {
48
- };
46
+ if (!documentEle) return () => {
47
+ };
49
48
  const host = import_host.CMicroAppHost.getInstance();
50
49
  addBaseTag(id, documentEle);
51
50
  updateContainerId(id, documentEle);
@@ -30,6 +30,7 @@ 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");
33
34
  var import_customHooks = require("./customHooks.js");
34
35
  const SessionExpiry = (0, import_react.memo)(
35
36
  ({ open, warningNotifiedAt = 0 }) => {
@@ -42,9 +43,9 @@ const SessionExpiry = (0, import_react.memo)(
42
43
  (0, import_react.useEffect)(() => {
43
44
  setIsOpen(open);
44
45
  }, [open]);
45
- const resetSession = () => {
46
+ const resetSession = async () => {
46
47
  setIsOpen(false);
47
- (0, import_session.resetUserIdleTime)(true);
48
+ await (0, import_extendSession.extendUIandPSSSession)();
48
49
  (0, import_session.addEventListeners)();
49
50
  dispatch(import_actions.logout.cancel());
50
51
  };
@@ -35,8 +35,7 @@ const SessionTimeout = () => {
35
35
  (0, import_session.initSessionMonitoring)();
36
36
  const warningCb = (0, import_session.subscribeToSessionExpiryWarning)(
37
37
  (sessionExpiryWarningNotifiedAt) => {
38
- if (!sessionExpiryWarningNotifiedAt)
39
- return;
38
+ if (!sessionExpiryWarningNotifiedAt) return;
40
39
  setwarningNotifiedAt(sessionExpiryWarningNotifiedAt);
41
40
  setSessionExpiryWarning(true);
42
41
  }
@@ -25,7 +25,6 @@ var import_react = require("react");
25
25
  const useHTMLWaitMessage = (close) => {
26
26
  (0, import_react.useEffect)(() => {
27
27
  const htmlWaitMsgElement = document.getElementById("em-wait-message");
28
- if (htmlWaitMsgElement && close)
29
- htmlWaitMsgElement.remove();
28
+ if (htmlWaitMsgElement && close) htmlWaitMsgElement.remove();
30
29
  }, [close]);
31
30
  };
@@ -1,6 +1,6 @@
1
1
  import { getHTTPClient } from "../../communication/http-client/index.js";
2
2
  const getToken = async ({
3
- idpCode,
3
+ code,
4
4
  clientId,
5
5
  scope,
6
6
  redirectUri
@@ -10,7 +10,7 @@ const getToken = async ({
10
10
  params.append("client_id", clientId);
11
11
  params.append("redirect_uri", redirectUri);
12
12
  params.append("scope", scope);
13
- params.append("code", idpCode);
13
+ params.append("code", code);
14
14
  const { data } = await getHTTPClient().post(
15
15
  "/oauth2/v1/token",
16
16
  params
@@ -13,14 +13,11 @@ const getHTTPClient = ({
13
13
  baseURL,
14
14
  headers
15
15
  });
16
- if (client?.defaults?.timeout)
17
- client.defaults.timeout = REQUEST_TIMEOUT;
16
+ if (client?.defaults?.timeout) client.defaults.timeout = REQUEST_TIMEOUT;
18
17
  setupRetry(client);
19
18
  const { request, response } = client?.interceptors || {};
20
- if (request)
21
- request.use(requestInterceptor);
22
- if (response)
23
- response.use(handleSuccess, handleFailure);
19
+ if (request) request.use(requestInterceptor);
20
+ if (response) response.use(handleSuccess, handleFailure);
24
21
  return client;
25
22
  };
26
23
  const getAuthHTTPClient = ({
@@ -1,27 +1,40 @@
1
1
  import axios from "axios";
2
+ import { getLoginParams } from "../../utils/auth/loginParams.js";
2
3
  const HTTP_UNAUTHORIZED = 401;
3
4
  let unAuthorizedFailureHandler = null;
5
+ let endSessionHandler = null;
4
6
  const onAuthorizationFailure = (callback) => {
5
7
  unAuthorizedFailureHandler = callback;
6
8
  };
9
+ const setEndSessionHandler = (handler) => {
10
+ endSessionHandler = handler;
11
+ };
7
12
  const handleSuccess = (response) => response;
8
13
  const handleFailure = (error) => {
9
14
  const { status } = (error || {}).response || {};
10
- if (status === HTTP_UNAUTHORIZED && unAuthorizedFailureHandler && typeof unAuthorizedFailureHandler === "function") {
11
- return unAuthorizedFailureHandler(error).then((authorizationHeader) => {
12
- const { config } = error;
13
- if (!config?.headers)
14
- throw error;
15
- config.headers["Authorization"] = authorizationHeader;
16
- return new Promise((resolve, reject) => {
17
- axios.request(config).then(resolve).catch(reject);
18
- });
19
- }).catch((exception) => Promise.reject(exception));
15
+ if (status === HTTP_UNAUTHORIZED) {
16
+ if (unAuthorizedFailureHandler && typeof unAuthorizedFailureHandler === "function") {
17
+ return unAuthorizedFailureHandler(error).then((authorizationHeader) => {
18
+ const { config } = error;
19
+ if (!config?.headers) throw error;
20
+ config.headers["Authorization"] = authorizationHeader;
21
+ return new Promise((resolve, reject) => {
22
+ axios.request(config).then(resolve).catch(reject);
23
+ });
24
+ }).catch((exception) => Promise.reject(exception));
25
+ }
26
+ if (endSessionHandler) {
27
+ endSessionHandler({ ...getLoginParams(), skipRevoke: true }).catch(
28
+ () => {
29
+ }
30
+ );
31
+ }
20
32
  }
21
33
  return Promise.reject(error);
22
34
  };
23
35
  export {
24
36
  handleFailure,
25
37
  handleSuccess,
26
- onAuthorizationFailure
38
+ onAuthorizationFailure,
39
+ setEndSessionHandler
27
40
  };
@@ -13,8 +13,7 @@ const addMiddleware = ({
13
13
  key,
14
14
  middleware
15
15
  }) => {
16
- if (middlewareDispatchFns.has(key) || !store)
17
- return;
16
+ if (middlewareDispatchFns.has(key) || !store) return;
18
17
  middlewareDispatchFns.set(key, middleware(store));
19
18
  };
20
19
  const removeMiddleware = (key) => {
@@ -3,14 +3,14 @@ const LOGIN_SUCCESS = "auth/LOGIN_SUCCESS";
3
3
  const LOGOUT = "auth/LOGOUT";
4
4
  const auth = {
5
5
  login: ({
6
- idpCode,
6
+ code,
7
7
  redirectUri,
8
8
  clientId,
9
9
  responseType,
10
10
  scope
11
11
  }) => ({
12
12
  type: LOGIN,
13
- payload: { idpCode, redirectUri, clientId, responseType, scope }
13
+ payload: { code, redirectUri, clientId, responseType, scope }
14
14
  }),
15
15
  logout: ({
16
16
  clientId,
@@ -12,8 +12,7 @@ const addMiddleware = ({
12
12
  reducerPath,
13
13
  middleware
14
14
  }) => {
15
- if (middlewareDispatchFns.has(reducerPath) || !store)
16
- return;
15
+ if (middlewareDispatchFns.has(reducerPath) || !store) return;
17
16
  middlewareDispatchFns.set(reducerPath, middleware(store));
18
17
  };
19
18
  const removeMiddleware = (reducerPath) => {
package/dist/esm/index.js CHANGED
@@ -25,8 +25,7 @@ import {
25
25
  } from "./data/react.js";
26
26
  import {
27
27
  useStateSelector,
28
- useStateSelectorShallow,
29
- UseStateSelectorOptions
28
+ useStateSelectorShallow
30
29
  } from "./utils/custom-hooks/use-state-selector.js";
31
30
  import { errorMiddleware } from "./data/errorMiddleware.js";
32
31
  import {
@@ -172,7 +171,6 @@ export {
172
171
  TextBox,
173
172
  Themes,
174
173
  Toggle,
175
- UseStateSelectorOptions,
176
174
  VisuallyHidden,
177
175
  WaitMessage,
178
176
  actions as ariaLive,
@@ -11,11 +11,13 @@ import {
11
11
  import { authorize, endSession } from "../../utils/auth/index.js";
12
12
  import { getLogger } from "../../utils/micro-frontend/index.js";
13
13
  import { logRecords } from "../../utils/log-records.js";
14
+ import { setEndSessionHandler } from "../../communication/http-client/response-interceptor.js";
14
15
  function* login({
15
16
  payload
16
17
  }) {
17
18
  try {
18
19
  yield call(authorize, payload);
20
+ yield call(setEndSessionHandler, endSession);
19
21
  yield put({ type: LOGIN_SUCCESS });
20
22
  } catch (err) {
21
23
  getLogger().error({
@@ -10,8 +10,7 @@ function* openErrorToast(action) {
10
10
  );
11
11
  const host = yield call(microApp.getHost.bind(microApp));
12
12
  const message = action?.payload?.description || action?.payload?.messageText;
13
- if (host && message)
14
- yield call(host.openErrorBanner.bind(host), message);
13
+ if (host && message) yield call(host.openErrorBanner.bind(host), message);
15
14
  } catch (ex) {
16
15
  getLogger().error({
17
16
  ...logRecords.ERR_TOAST_OPEN_FAILED,
@@ -9,8 +9,7 @@ function* openWaitMessage() {
9
9
  CMicroAppGuest.getInstance.bind(CMicroAppGuest)
10
10
  );
11
11
  const host = yield call(microApp.getHost.bind(microApp));
12
- if (host)
13
- yield call(host.openWaitMessage.bind(host));
12
+ if (host) yield call(host.openWaitMessage.bind(host));
14
13
  } catch (ex) {
15
14
  getLogger().error({
16
15
  ...logRecords.WAIT_MSG_OPEN_FAILED,
@@ -24,8 +23,7 @@ function* closeWaitMessage() {
24
23
  CMicroAppGuest.getInstance.bind(CMicroAppGuest)
25
24
  );
26
25
  const host = yield call(microApp.getHost.bind(microApp));
27
- if (host)
28
- yield call(host.closeWaitMessage.bind(host));
26
+ if (host) yield call(host.closeWaitMessage.bind(host));
29
27
  } catch (ex) {
30
28
  getLogger().error({
31
29
  ...logRecords.WAIT_MSG_CLOSE_FAILED,
@@ -7,8 +7,7 @@ import { getAppConfigValue } from "./config.js";
7
7
  const parseAppConfig = (data) => {
8
8
  const { activeEnv } = data;
9
9
  const activeEnvConfig = data.env[activeEnv] || {};
10
- if (data.env)
11
- delete data.env;
10
+ if (data.env) delete data.env;
12
11
  setAppConfig(_.merge(data, activeEnvConfig));
13
12
  sessionStorage.setItem("envName", activeEnv);
14
13
  setAppDynamicsUserData({ envName: activeEnv });
@@ -11,14 +11,15 @@ import { getAuthorizationHeader, setAuthorizationHeader } from "./helper.js";
11
11
  import { getAppConfigValue } from "../app-config/config.js";
12
12
  import { getLogger } from "../micro-frontend/index.js";
13
13
  import { logRecords } from "../log-records.js";
14
+ import { setLoginParams } from "./loginParams.js";
14
15
  const IDP_ENDPOINT_CONFIG_KEY = "serviceEndpoints.idp";
15
16
  const isUserAuthorized = () => !!getAuthorizationHeader();
16
17
  const getIDPInfoFromUrl = () => {
17
18
  const currentUrl = new URL(window.location.href);
18
- const idpCode = currentUrl.searchParams.get("code") || "";
19
+ const code = currentUrl.searchParams.get("code") || "";
19
20
  const idpErrorCode = currentUrl.searchParams.get("error_code") || "";
20
21
  currentUrl.search = "";
21
- return { idpCode, idpErrorCode, redirectUri: currentUrl.href };
22
+ return { code, idpErrorCode, redirectUri: currentUrl.href };
22
23
  };
23
24
  const navigateToLoginPage = ({
24
25
  clientId,
@@ -47,16 +48,18 @@ const endSession = async ({
47
48
  redirectUri,
48
49
  responseType,
49
50
  scope,
50
- code = "1004"
51
+ code = "1004",
52
+ skipRevoke = false
51
53
  }) => {
52
54
  try {
53
55
  const authorization = getAuthorizationHeader();
54
56
  sessionStorage.clear();
55
57
  const token = authorization ? authorization.split(" ")[1] : "";
56
- await revokeToken({
57
- clientId,
58
- token
59
- });
58
+ if (!skipRevoke)
59
+ await revokeToken({
60
+ clientId,
61
+ token
62
+ });
60
63
  logoutEvent();
61
64
  setAppDynamicsUserData({ instanceId: "", userId: "" });
62
65
  const idpHost = getAppConfigValue(IDP_ENDPOINT_CONFIG_KEY, "");
@@ -79,7 +82,7 @@ const endSession = async ({
79
82
  }
80
83
  };
81
84
  const authorize = async ({
82
- idpCode,
85
+ code,
83
86
  redirectUri,
84
87
  clientId,
85
88
  scope,
@@ -87,11 +90,12 @@ const authorize = async ({
87
90
  }) => {
88
91
  try {
89
92
  const { tokenType, accessToken } = await getToken({
90
- idpCode,
93
+ code,
91
94
  clientId,
92
95
  scope,
93
96
  redirectUri
94
97
  });
98
+ setLoginParams({ clientId, scope, responseType, redirectUri, code });
95
99
  const authorizationToken = `${tokenType} ${accessToken}`;
96
100
  setAuthorizationHeader(authorizationToken);
97
101
  const introspectResponse = await introspectToken({
@@ -120,8 +124,14 @@ const authorize = async ({
120
124
  const pathName = new URL(redirectUri).pathname;
121
125
  history.replace(pathName);
122
126
  } catch (err) {
123
- const code = err?.response?.data?.code;
124
- await endSession({ clientId, redirectUri, code, scope, responseType });
127
+ const errCode = err?.response?.data?.code;
128
+ await endSession({
129
+ clientId,
130
+ redirectUri,
131
+ code: errCode,
132
+ scope,
133
+ responseType
134
+ });
125
135
  getLogger().error({
126
136
  ...logRecords.LOGIN_FAILED,
127
137
  exception: err
@@ -133,16 +143,16 @@ const login = async ({
133
143
  scope,
134
144
  responseType
135
145
  }) => {
136
- const { idpCode, idpErrorCode, redirectUri } = getIDPInfoFromUrl();
146
+ const { code, idpErrorCode, redirectUri } = getIDPInfoFromUrl();
137
147
  const loginInfo = {
138
148
  clientId,
139
149
  scope,
140
150
  responseType,
141
151
  redirectUri,
142
- idpCode,
152
+ code,
143
153
  idpErrorCode
144
154
  };
145
- if (idpCode) {
155
+ if (code) {
146
156
  await authorize(loginInfo);
147
157
  return { authorized: true };
148
158
  }
@@ -0,0 +1,9 @@
1
+ let loginParams;
2
+ const setLoginParams = (params) => {
3
+ loginParams = params;
4
+ };
5
+ const getLoginParams = () => loginParams;
6
+ export {
7
+ getLoginParams,
8
+ setLoginParams
9
+ };
File without changes
@@ -0,0 +1,27 @@
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
+ };
@@ -58,6 +58,10 @@ const logRecords = {
58
58
  UNHANDLED_ERROR: {
59
59
  code: "appsdk15",
60
60
  message: "Unhandled error in react component"
61
+ },
62
+ SESSION_RENEWAL_FAILED: {
63
+ code: "appsdk16",
64
+ message: "Unable to extend PSS session"
61
65
  }
62
66
  };
63
67
  export {
@@ -1,8 +1,7 @@
1
1
  import { logger as uiLogger, Console } from "@elliemae/pui-diagnostics";
2
2
  import { getAppConfigValue } from "../app-config/config.js";
3
3
  const logger = (() => {
4
- if (!uiLogger)
5
- return console;
4
+ if (!uiLogger) return console;
6
5
  return uiLogger({
7
6
  transport: Console(),
8
7
  index: "app",