@elliemae/pui-app-sdk 5.18.0 → 5.18.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.
@@ -90,9 +90,9 @@ const endSession = async ({
90
90
  const logoutUrl = new URL("/authorize", idpHost);
91
91
  const params = {
92
92
  client_id: clientId,
93
- redirect_uri: redirectUri,
93
+ redirect_uri: redirectUri || "",
94
94
  ...code && { error_code: code },
95
- response_type: responseType,
95
+ response_type: responseType || "",
96
96
  scope
97
97
  };
98
98
  const searchParams = new URLSearchParams(params);
@@ -28,4 +28,15 @@ const setLoginParams = (params) => {
28
28
  ...params
29
29
  };
30
30
  };
31
- const getLoginParams = () => window.emui.loginParams;
31
+ const getLoginParams = () => {
32
+ if (!window.emui.loginParams) {
33
+ const user = JSON.parse(sessionStorage.getItem("user") || "{}");
34
+ const clientId = user.client_id || "";
35
+ const scope = user.scope || "";
36
+ window.emui.loginParams = {
37
+ clientId,
38
+ scope
39
+ };
40
+ }
41
+ return window.emui.loginParams;
42
+ };
@@ -20,6 +20,7 @@ var constants_exports = {};
20
20
  __export(constants_exports, {
21
21
  HOST_WINDOW_BREAKPOINT_CHANGED: () => HOST_WINDOW_BREAKPOINT_CHANGED,
22
22
  HOST_WINDOW_RESIZED: () => HOST_WINDOW_RESIZED,
23
+ SESSION_RENEWAL_INTERVAL: () => SESSION_RENEWAL_INTERVAL,
23
24
  SESSION_TIMEOUT_INTERVAL: () => SESSION_TIMEOUT_INTERVAL,
24
25
  Themes: () => Themes,
25
26
  default: () => constants_default
@@ -41,3 +42,4 @@ const Themes = {
41
42
  };
42
43
  const HOST_WINDOW_RESIZED = "HOST_WINDOW_RESIZED";
43
44
  const HOST_WINDOW_BREAKPOINT_CHANGED = "HOST_WINDOW_BREAKPOINT_CHANGED";
45
+ const SESSION_RENEWAL_INTERVAL = 6e4;
@@ -22,6 +22,7 @@ __export(host_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(host_exports);
24
24
  var import_pubsub_js = require("pubsub-js");
25
+ var import_lodash = require("lodash");
25
26
  var import_pui_theme = require("@elliemae/pui-theme");
26
27
  var import_store = require("../../data/store.js");
27
28
  var import_actions = require("../../data/wait-message/actions.js");
@@ -47,6 +48,7 @@ class CMicroAppHost {
47
48
  activeGuests;
48
49
  onInit;
49
50
  onRenewSessionTimer;
51
+ throttleRenewSessionTimer;
50
52
  scriptingObjects;
51
53
  #ssfHostRef;
52
54
  // eslint-disable-next-line max-statements
@@ -78,6 +80,16 @@ class CMicroAppHost {
78
80
  this.renewSessionTimer = this.renewSessionTimer.bind(this);
79
81
  this.setSystemVersion = this.setSystemVersion.bind(this);
80
82
  this.sendBAEvent = this.sendBAEvent.bind(this);
83
+ this.throttleRenewSessionTimer = (0, import_lodash.throttle)(
84
+ async () => {
85
+ await (0, import_session.renewSession)();
86
+ if (this.onRenewSessionTimer) this.onRenewSessionTimer();
87
+ },
88
+ import_constants.SESSION_RENEWAL_INTERVAL,
89
+ {
90
+ leading: true
91
+ }
92
+ );
81
93
  (0, import_app_config.loadAppConfig)().then(() => {
82
94
  if (this.onInit) this.onInit(this.props);
83
95
  }).catch(() => {
@@ -150,9 +162,9 @@ class CMicroAppHost {
150
162
  const store = (0, import_store.getStore)();
151
163
  if (store) store.dispatch(import_actions2.logout.confirm());
152
164
  }
165
+ // eslint-disable-next-line @typescript-eslint/require-await
153
166
  async renewSessionTimer() {
154
- await (0, import_session.renewSession)();
155
- if (this.onRenewSessionTimer) this.onRenewSessionTimer();
167
+ this.throttleRenewSessionTimer();
156
168
  }
157
169
  getBreakpoint() {
158
170
  return (0, import_window.getCurrentBreakpoint)();
@@ -38,7 +38,6 @@ var import_log_records = require("./log-records.js");
38
38
  var import_auth2 = require("./auth/index.js");
39
39
  var import_config = require("./app-config/config.js");
40
40
  var import_constants = require("./constants.js");
41
- const SESSION_RENEWAL_INTERVAL = 6e4;
42
41
  let lastUserActivityTimeStamp = Date.now();
43
42
  const warnListeners = [];
44
43
  const expiryListeners = [];
@@ -77,7 +76,7 @@ const renewSession = async () => {
77
76
  };
78
77
  const renewSessionAtInterval = (0, import_lodash.throttle)(
79
78
  renewSession,
80
- SESSION_RENEWAL_INTERVAL,
79
+ import_constants.SESSION_RENEWAL_INTERVAL,
81
80
  {
82
81
  leading: true
83
82
  }
@@ -147,7 +146,7 @@ const subscribeToResetSession = (onResetListener) => {
147
146
  const trackActivity = (element, cb) => {
148
147
  if (!element) return () => {
149
148
  };
150
- const thorttledCb = (0, import_lodash.throttle)(cb, SESSION_RENEWAL_INTERVAL, { leading: true });
149
+ const thorttledCb = (0, import_lodash.throttle)(cb, import_constants.SESSION_RENEWAL_INTERVAL, { leading: true });
151
150
  userInteractionEvents.forEach(
152
151
  (r) => element.addEventListener(r, thorttledCb)
153
152
  );
@@ -43,7 +43,7 @@ const getViewportSize = () => ({
43
43
  window.innerHeight || 0
44
44
  )
45
45
  });
46
- const convertBreakpointToNumber = (breakpoint) => Number(breakpoint.replace("px", ""));
46
+ const convertBreakpointToNumber = (breakpoint) => Number(breakpoint?.replace("px", ""));
47
47
  const getCurrentBreakpoint = () => {
48
48
  const { width } = getViewportSize();
49
49
  const { breakpoints } = (0, import_pui_theme.getDefaultTheme)();
@@ -66,9 +66,9 @@ const endSession = async ({
66
66
  const logoutUrl = new URL("/authorize", idpHost);
67
67
  const params = {
68
68
  client_id: clientId,
69
- redirect_uri: redirectUri,
69
+ redirect_uri: redirectUri || "",
70
70
  ...code && { error_code: code },
71
- response_type: responseType,
71
+ response_type: responseType || "",
72
72
  scope
73
73
  };
74
74
  const searchParams = new URLSearchParams(params);
@@ -4,7 +4,18 @@ const setLoginParams = (params) => {
4
4
  ...params
5
5
  };
6
6
  };
7
- const getLoginParams = () => window.emui.loginParams;
7
+ const getLoginParams = () => {
8
+ if (!window.emui.loginParams) {
9
+ const user = JSON.parse(sessionStorage.getItem("user") || "{}");
10
+ const clientId = user.client_id || "";
11
+ const scope = user.scope || "";
12
+ window.emui.loginParams = {
13
+ clientId,
14
+ scope
15
+ };
16
+ }
17
+ return window.emui.loginParams;
18
+ };
8
19
  export {
9
20
  getLoginParams,
10
21
  setLoginParams
@@ -14,9 +14,11 @@ const Themes = {
14
14
  };
15
15
  const HOST_WINDOW_RESIZED = "HOST_WINDOW_RESIZED";
16
16
  const HOST_WINDOW_BREAKPOINT_CHANGED = "HOST_WINDOW_BREAKPOINT_CHANGED";
17
+ const SESSION_RENEWAL_INTERVAL = 6e4;
17
18
  export {
18
19
  HOST_WINDOW_BREAKPOINT_CHANGED,
19
20
  HOST_WINDOW_RESIZED,
21
+ SESSION_RENEWAL_INTERVAL,
20
22
  SESSION_TIMEOUT_INTERVAL,
21
23
  Themes,
22
24
  constants_default as default
@@ -1,4 +1,5 @@
1
1
  import { publish, subscribe, unsubscribe } from "pubsub-js";
2
+ import { throttle } from "lodash";
2
3
  import { getDefaultTheme } from "@elliemae/pui-theme";
3
4
  import { getStore } from "../../data/store.js";
4
5
  import { waitMessage } from "../../data/wait-message/actions.js";
@@ -11,7 +12,8 @@ import { consoleLogger } from "../console-logger.js";
11
12
  import { setLogger } from "../logger.js";
12
13
  import {
13
14
  HOST_WINDOW_RESIZED,
14
- HOST_WINDOW_BREAKPOINT_CHANGED
15
+ HOST_WINDOW_BREAKPOINT_CHANGED,
16
+ SESSION_RENEWAL_INTERVAL
15
17
  } from "../constants.js";
16
18
  import {
17
19
  getWindow,
@@ -31,6 +33,7 @@ class CMicroAppHost {
31
33
  activeGuests;
32
34
  onInit;
33
35
  onRenewSessionTimer;
36
+ throttleRenewSessionTimer;
34
37
  scriptingObjects;
35
38
  #ssfHostRef;
36
39
  // eslint-disable-next-line max-statements
@@ -62,6 +65,16 @@ class CMicroAppHost {
62
65
  this.renewSessionTimer = this.renewSessionTimer.bind(this);
63
66
  this.setSystemVersion = this.setSystemVersion.bind(this);
64
67
  this.sendBAEvent = this.sendBAEvent.bind(this);
68
+ this.throttleRenewSessionTimer = throttle(
69
+ async () => {
70
+ await renewSession();
71
+ if (this.onRenewSessionTimer) this.onRenewSessionTimer();
72
+ },
73
+ SESSION_RENEWAL_INTERVAL,
74
+ {
75
+ leading: true
76
+ }
77
+ );
65
78
  loadAppConfig().then(() => {
66
79
  if (this.onInit) this.onInit(this.props);
67
80
  }).catch(() => {
@@ -134,9 +147,9 @@ class CMicroAppHost {
134
147
  const store = getStore();
135
148
  if (store) store.dispatch(logout.confirm());
136
149
  }
150
+ // eslint-disable-next-line @typescript-eslint/require-await
137
151
  async renewSessionTimer() {
138
- await renewSession();
139
- if (this.onRenewSessionTimer) this.onRenewSessionTimer();
152
+ this.throttleRenewSessionTimer();
140
153
  }
141
154
  getBreakpoint() {
142
155
  return getCurrentBreakpoint();
@@ -6,8 +6,10 @@ import { getLogger } from "./logger.js";
6
6
  import { logRecords } from "./log-records.js";
7
7
  import { endSession } from "./auth/index.js";
8
8
  import { getAppConfigValue } from "./app-config/config.js";
9
- import { SESSION_TIMEOUT_INTERVAL } from "./constants.js";
10
- const SESSION_RENEWAL_INTERVAL = 6e4;
9
+ import {
10
+ SESSION_TIMEOUT_INTERVAL,
11
+ SESSION_RENEWAL_INTERVAL
12
+ } from "./constants.js";
11
13
  let lastUserActivityTimeStamp = Date.now();
12
14
  const warnListeners = [];
13
15
  const expiryListeners = [];
@@ -17,7 +17,7 @@ const getViewportSize = () => ({
17
17
  window.innerHeight || 0
18
18
  )
19
19
  });
20
- const convertBreakpointToNumber = (breakpoint) => Number(breakpoint.replace("px", ""));
20
+ const convertBreakpointToNumber = (breakpoint) => Number(breakpoint?.replace("px", ""));
21
21
  const getCurrentBreakpoint = () => {
22
22
  const { width } = getViewportSize();
23
23
  const { breakpoints } = getDefaultTheme();
@@ -1,7 +1,7 @@
1
1
  export type EndSessionFn = (params: {
2
2
  clientId: string;
3
- redirectUri: string;
4
- responseType: string;
3
+ redirectUri?: string;
4
+ responseType?: string;
5
5
  scope: string;
6
6
  code?: string;
7
7
  skipRevoke?: boolean;
@@ -9,6 +9,6 @@ export type EndSessionFn = (params: {
9
9
  export type LoginParams = {
10
10
  clientId: string;
11
11
  scope: string;
12
- responseType: string;
13
- redirectUri: string;
12
+ responseType?: string;
13
+ redirectUri?: string;
14
14
  };
@@ -13,3 +13,4 @@ export declare const Themes: {
13
13
  };
14
14
  export declare const HOST_WINDOW_RESIZED = "HOST_WINDOW_RESIZED";
15
15
  export declare const HOST_WINDOW_BREAKPOINT_CHANGED = "HOST_WINDOW_BREAKPOINT_CHANGED";
16
+ export declare const SESSION_RENEWAL_INTERVAL = 60000;
@@ -31,6 +31,7 @@ export declare class CMicroAppHost implements IMicroAppHost {
31
31
  activeGuests: Record<string, unknown>;
32
32
  private readonly onInit?;
33
33
  private readonly onRenewSessionTimer?;
34
+ private readonly throttleRenewSessionTimer;
34
35
  scriptingObjects: Record<string, any>;
35
36
  private constructor();
36
37
  static getInstance(params?: ConstructorParams): CMicroAppHost;