@elliemae/pui-app-sdk 5.22.0-beta.2 → 5.23.0-beta.1

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.
@@ -22,9 +22,11 @@ __export(users_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(users_exports);
24
24
  var import_http_client = require("../../communication/http-client/index.js");
25
- const getUser = async ({ userName }) => {
26
- const { data } = await (0, import_http_client.getAuthHTTPClient)().get(
27
- `/encompass/v1/users/${userName}`
28
- );
25
+ const getUser = async ({
26
+ userName,
27
+ isConsumerUser
28
+ }) => {
29
+ const URL = isConsumerUser ? "/iam/v1/users/me" : `/encompass/v1/users/${userName}`;
30
+ const { data } = await (0, import_http_client.getAuthHTTPClient)().get(URL);
29
31
  return data;
30
32
  };
@@ -33,10 +33,18 @@ const auth = {
33
33
  redirectUri,
34
34
  clientId,
35
35
  responseType,
36
- scope
36
+ scope,
37
+ isConsumerUser
37
38
  }) => ({
38
39
  type: LOGIN,
39
- payload: { code, redirectUri, clientId, responseType, scope }
40
+ payload: {
41
+ code,
42
+ redirectUri,
43
+ clientId,
44
+ responseType,
45
+ scope,
46
+ isConsumerUser
47
+ }
40
48
  }),
41
49
  logout: ({
42
50
  clientId,
@@ -110,7 +110,8 @@ const authorize = async ({
110
110
  redirectUri,
111
111
  clientId,
112
112
  scope,
113
- responseType
113
+ responseType,
114
+ isConsumerUser
114
115
  }) => {
115
116
  try {
116
117
  const { tokenType, accessToken } = await (0, import_auth.getToken)({
@@ -136,14 +137,14 @@ const authorize = async ({
136
137
  bearerToken,
137
138
  realm: instanceId,
138
139
  userName,
139
- sessionId: bearerToken.replace(`${instanceId} `, "")
140
+ sessionId: bearerToken?.replace(`${instanceId} `, "")
140
141
  };
141
142
  sessionStorage.setItem("cred", JSON.stringify(cred));
142
143
  sessionStorage.setItem("instanceId", instanceId);
143
144
  sessionStorage.setItem("userId", userName);
144
145
  (0, import_user_session_event.loginEvent)({ instanceId, userId: userName });
145
146
  (0, import_appdynamics.setAppDynamicsUserData)({ instanceId, userId: userName });
146
- const data = await (0, import_users.getUser)({ userName });
147
+ const data = await (0, import_users.getUser)({ userName, isConsumerUser });
147
148
  sessionStorage.setItem("userSettings", JSON.stringify(data));
148
149
  const pathName = new URL(redirectUri).pathname;
149
150
  import_history.browserHistory.replace(pathName);
@@ -165,7 +166,8 @@ const authorize = async ({
165
166
  const login = async ({
166
167
  clientId,
167
168
  scope,
168
- responseType
169
+ responseType,
170
+ isConsumerUser
169
171
  }) => {
170
172
  const { code, idpErrorCode, redirectUri } = getIDPInfoFromUrl();
171
173
  const loginInfo = {
@@ -174,7 +176,8 @@ const login = async ({
174
176
  responseType,
175
177
  redirectUri,
176
178
  code,
177
- idpErrorCode
179
+ idpErrorCode,
180
+ isConsumerUser
178
181
  };
179
182
  if (code) {
180
183
  await authorize(loginInfo);
@@ -160,8 +160,13 @@ function Throttle(delay = 300) {
160
160
  }
161
161
  function AsyncSingleExecution(_target, _propertyKey, descriptor) {
162
162
  const originalMethod = descriptor.value;
163
- const promiseMap = /* @__PURE__ */ new Map();
163
+ const instanceMap = /* @__PURE__ */ new WeakMap();
164
164
  descriptor.value = function(...args) {
165
+ const instance = this;
166
+ if (!instanceMap.has(instance)) {
167
+ instanceMap.set(instance, /* @__PURE__ */ new Map());
168
+ }
169
+ const promiseMap = instanceMap.get(instance);
165
170
  const key = JSON.stringify(args);
166
171
  if (promiseMap.has(key)) {
167
172
  return promiseMap.get(key);
@@ -46,14 +46,7 @@ const Div = import_styled_components.default.div`
46
46
  overflow: hidden;
47
47
  `;
48
48
  const useAppRenderer = (props) => {
49
- const {
50
- id,
51
- frameOptions,
52
- history,
53
- onLoadComplete,
54
- onUnloadComplete,
55
- containerId
56
- } = props;
49
+ const { id, history, onLoadComplete, onUnloadComplete, containerId } = props;
57
50
  const dispatch = (0, import_react_redux.useDispatch)();
58
51
  (0, import_react.useLayoutEffect)(() => {
59
52
  let isMounted = true;
@@ -70,7 +63,7 @@ const useAppRenderer = (props) => {
70
63
  if (isMounted) {
71
64
  instanceId = await appBridge.openApp({
72
65
  id,
73
- frameOptions: { containerId, ...frameOptions },
66
+ frameOptions: { containerId },
74
67
  history
75
68
  });
76
69
  setTimeout(() => {
@@ -109,18 +102,12 @@ const useAppRenderer = (props) => {
109
102
  });
110
103
  }
111
104
  };
112
- }, [
113
- containerId,
114
- dispatch,
115
- frameOptions,
116
- history,
117
- id,
118
- onLoadComplete,
119
- onUnloadComplete
120
- ]);
105
+ }, [containerId, dispatch, history, id, onLoadComplete, onUnloadComplete]);
121
106
  };
122
- const GuestMicroApp = (0, import_react.memo)((props) => {
123
- const containerId = (0, import_react.useRef)(crypto.randomUUID());
124
- useAppRenderer({ ...props, containerId: containerId.current });
125
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Div, { id: containerId.current });
126
- });
107
+ const GuestMicroApp = (0, import_react.memo)(
108
+ (props) => {
109
+ const containerId = (0, import_react.useRef)(crypto.randomUUID());
110
+ useAppRenderer({ ...props, containerId: containerId.current });
111
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Div, { id: containerId.current });
112
+ }
113
+ );
@@ -30,7 +30,8 @@ const Login = ({
30
30
  clientId,
31
31
  scope,
32
32
  responseType,
33
- children
33
+ children,
34
+ isConsumerUser
34
35
  }) => {
35
36
  const [userAuthorized, setUserAuthorized] = (0, import_react.useState)(false);
36
37
  const dispatch = (0, import_react2.useAppDispatch)();
@@ -38,13 +39,13 @@ const Login = ({
38
39
  (0, import_react.useEffect)(() => {
39
40
  if (ref.current) return;
40
41
  ref.current = true;
41
- (0, import_auth.login)({ clientId, scope, responseType }).then(({ authorized }) => {
42
+ (0, import_auth.login)({ clientId, scope, responseType, isConsumerUser }).then(({ authorized }) => {
42
43
  if (authorized) setUserAuthorized(true);
43
44
  dispatch({ type: import_actions.LOGIN_SUCCESS });
44
45
  }).catch(() => {
45
46
  }).finally(() => {
46
47
  ref.current = false;
47
48
  });
48
- }, [dispatch, clientId, scope, responseType]);
49
+ }, [dispatch, clientId, scope, responseType, isConsumerUser]);
49
50
  return userAuthorized ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }) : null;
50
51
  };
@@ -45,7 +45,8 @@ const RequireAuth = ({
45
45
  children,
46
46
  clientId = import_constants.default.CLIENT_ID,
47
47
  scope = "loc",
48
- responseType = "code"
48
+ responseType = "code",
49
+ isConsumerUser = false
49
50
  }) => {
50
51
  const AuthManager = (0, import_redux_injectors.createManager)({
51
52
  name: "AuthManager",
@@ -59,5 +60,14 @@ const RequireAuth = ({
59
60
  (0, import_loginParams.setLoginParams)({ clientId, scope, responseType });
60
61
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthManager, { children });
61
62
  }
62
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthManager, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_login.Login, { clientId, scope, responseType, children }) });
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthManager, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ import_login.Login,
65
+ {
66
+ clientId,
67
+ scope,
68
+ responseType,
69
+ isConsumerUser,
70
+ children
71
+ }
72
+ ) });
63
73
  };
@@ -1,8 +1,10 @@
1
1
  import { getAuthHTTPClient } from "../../communication/http-client/index.js";
2
- const getUser = async ({ userName }) => {
3
- const { data } = await getAuthHTTPClient().get(
4
- `/encompass/v1/users/${userName}`
5
- );
2
+ const getUser = async ({
3
+ userName,
4
+ isConsumerUser
5
+ }) => {
6
+ const URL = isConsumerUser ? "/iam/v1/users/me" : `/encompass/v1/users/${userName}`;
7
+ const { data } = await getAuthHTTPClient().get(URL);
6
8
  return data;
7
9
  };
8
10
  export {
@@ -7,10 +7,18 @@ const auth = {
7
7
  redirectUri,
8
8
  clientId,
9
9
  responseType,
10
- scope
10
+ scope,
11
+ isConsumerUser
11
12
  }) => ({
12
13
  type: LOGIN,
13
- payload: { code, redirectUri, clientId, responseType, scope }
14
+ payload: {
15
+ code,
16
+ redirectUri,
17
+ clientId,
18
+ responseType,
19
+ scope,
20
+ isConsumerUser
21
+ }
14
22
  }),
15
23
  logout: ({
16
24
  clientId,
@@ -86,7 +86,8 @@ const authorize = async ({
86
86
  redirectUri,
87
87
  clientId,
88
88
  scope,
89
- responseType
89
+ responseType,
90
+ isConsumerUser
90
91
  }) => {
91
92
  try {
92
93
  const { tokenType, accessToken } = await getToken({
@@ -112,14 +113,14 @@ const authorize = async ({
112
113
  bearerToken,
113
114
  realm: instanceId,
114
115
  userName,
115
- sessionId: bearerToken.replace(`${instanceId} `, "")
116
+ sessionId: bearerToken?.replace(`${instanceId} `, "")
116
117
  };
117
118
  sessionStorage.setItem("cred", JSON.stringify(cred));
118
119
  sessionStorage.setItem("instanceId", instanceId);
119
120
  sessionStorage.setItem("userId", userName);
120
121
  loginEvent({ instanceId, userId: userName });
121
122
  setAppDynamicsUserData({ instanceId, userId: userName });
122
- const data = await getUser({ userName });
123
+ const data = await getUser({ userName, isConsumerUser });
123
124
  sessionStorage.setItem("userSettings", JSON.stringify(data));
124
125
  const pathName = new URL(redirectUri).pathname;
125
126
  history.replace(pathName);
@@ -141,7 +142,8 @@ const authorize = async ({
141
142
  const login = async ({
142
143
  clientId,
143
144
  scope,
144
- responseType
145
+ responseType,
146
+ isConsumerUser
145
147
  }) => {
146
148
  const { code, idpErrorCode, redirectUri } = getIDPInfoFromUrl();
147
149
  const loginInfo = {
@@ -150,7 +152,8 @@ const login = async ({
150
152
  responseType,
151
153
  redirectUri,
152
154
  code,
153
- idpErrorCode
155
+ idpErrorCode,
156
+ isConsumerUser
154
157
  };
155
158
  if (code) {
156
159
  await authorize(loginInfo);
@@ -129,8 +129,13 @@ function Throttle(delay = 300) {
129
129
  }
130
130
  function AsyncSingleExecution(_target, _propertyKey, descriptor) {
131
131
  const originalMethod = descriptor.value;
132
- const promiseMap = /* @__PURE__ */ new Map();
132
+ const instanceMap = /* @__PURE__ */ new WeakMap();
133
133
  descriptor.value = function(...args) {
134
+ const instance = this;
135
+ if (!instanceMap.has(instance)) {
136
+ instanceMap.set(instance, /* @__PURE__ */ new Map());
137
+ }
138
+ const promiseMap = instanceMap.get(instance);
134
139
  const key = JSON.stringify(args);
135
140
  if (promiseMap.has(key)) {
136
141
  return promiseMap.get(key);
@@ -13,14 +13,7 @@ const Div = styled.div`
13
13
  overflow: hidden;
14
14
  `;
15
15
  const useAppRenderer = (props) => {
16
- const {
17
- id,
18
- frameOptions,
19
- history,
20
- onLoadComplete,
21
- onUnloadComplete,
22
- containerId
23
- } = props;
16
+ const { id, history, onLoadComplete, onUnloadComplete, containerId } = props;
24
17
  const dispatch = useDispatch();
25
18
  useLayoutEffect(() => {
26
19
  let isMounted = true;
@@ -37,7 +30,7 @@ const useAppRenderer = (props) => {
37
30
  if (isMounted) {
38
31
  instanceId = await appBridge.openApp({
39
32
  id,
40
- frameOptions: { containerId, ...frameOptions },
33
+ frameOptions: { containerId },
41
34
  history
42
35
  });
43
36
  setTimeout(() => {
@@ -76,21 +69,15 @@ const useAppRenderer = (props) => {
76
69
  });
77
70
  }
78
71
  };
79
- }, [
80
- containerId,
81
- dispatch,
82
- frameOptions,
83
- history,
84
- id,
85
- onLoadComplete,
86
- onUnloadComplete
87
- ]);
72
+ }, [containerId, dispatch, history, id, onLoadComplete, onUnloadComplete]);
88
73
  };
89
- const GuestMicroApp = memo((props) => {
90
- const containerId = useRef(crypto.randomUUID());
91
- useAppRenderer({ ...props, containerId: containerId.current });
92
- return /* @__PURE__ */ jsx(Div, { id: containerId.current });
93
- });
74
+ const GuestMicroApp = memo(
75
+ (props) => {
76
+ const containerId = useRef(crypto.randomUUID());
77
+ useAppRenderer({ ...props, containerId: containerId.current });
78
+ return /* @__PURE__ */ jsx(Div, { id: containerId.current });
79
+ }
80
+ );
94
81
  export {
95
82
  GuestMicroApp
96
83
  };
@@ -7,7 +7,8 @@ const Login = ({
7
7
  clientId,
8
8
  scope,
9
9
  responseType,
10
- children
10
+ children,
11
+ isConsumerUser
11
12
  }) => {
12
13
  const [userAuthorized, setUserAuthorized] = useState(false);
13
14
  const dispatch = useAppDispatch();
@@ -15,14 +16,14 @@ const Login = ({
15
16
  useEffect(() => {
16
17
  if (ref.current) return;
17
18
  ref.current = true;
18
- login({ clientId, scope, responseType }).then(({ authorized }) => {
19
+ login({ clientId, scope, responseType, isConsumerUser }).then(({ authorized }) => {
19
20
  if (authorized) setUserAuthorized(true);
20
21
  dispatch({ type: LOGIN_SUCCESS });
21
22
  }).catch(() => {
22
23
  }).finally(() => {
23
24
  ref.current = false;
24
25
  });
25
- }, [dispatch, clientId, scope, responseType]);
26
+ }, [dispatch, clientId, scope, responseType, isConsumerUser]);
26
27
  return userAuthorized ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
27
28
  };
28
29
  export {
@@ -12,7 +12,8 @@ const RequireAuth = ({
12
12
  children,
13
13
  clientId = enums.CLIENT_ID,
14
14
  scope = "loc",
15
- responseType = "code"
15
+ responseType = "code",
16
+ isConsumerUser = false
16
17
  }) => {
17
18
  const AuthManager = createManager({
18
19
  name: "AuthManager",
@@ -26,7 +27,16 @@ const RequireAuth = ({
26
27
  setLoginParams({ clientId, scope, responseType });
27
28
  return /* @__PURE__ */ jsx(AuthManager, { children });
28
29
  }
29
- return /* @__PURE__ */ jsx(AuthManager, { children: /* @__PURE__ */ jsx(Login, { clientId, scope, responseType, children }) });
30
+ return /* @__PURE__ */ jsx(AuthManager, { children: /* @__PURE__ */ jsx(
31
+ Login,
32
+ {
33
+ clientId,
34
+ scope,
35
+ responseType,
36
+ isConsumerUser,
37
+ children
38
+ }
39
+ ) });
30
40
  };
31
41
  export {
32
42
  RequireAuth
@@ -1,5 +1,6 @@
1
1
  interface UsersRequestParams {
2
2
  userName: string;
3
+ isConsumerUser: boolean;
3
4
  }
4
- export declare const getUser: ({ userName }: UsersRequestParams) => Promise<Record<string, unknown>>;
5
+ export declare const getUser: ({ userName, isConsumerUser, }: UsersRequestParams) => Promise<Record<string, unknown>>;
5
6
  export {};
@@ -8,6 +8,7 @@ export interface LoginParms {
8
8
  clientId: string;
9
9
  responseType: string;
10
10
  scope: string;
11
+ isConsumerUser: boolean;
11
12
  }
12
13
  export interface LogoutParams {
13
14
  redirectUri: string;
@@ -17,6 +18,6 @@ export interface LogoutParams {
17
18
  code: string;
18
19
  }
19
20
  export declare const auth: {
20
- login: ({ code, redirectUri, clientId, responseType, scope, }: LoginParms) => PayloadAction<LoginParms>;
21
+ login: ({ code, redirectUri, clientId, responseType, scope, isConsumerUser, }: LoginParms) => PayloadAction<LoginParms>;
21
22
  logout: ({ clientId, redirectUri, responseType, scope, code, }: LogoutParams) => PayloadAction<LogoutParams>;
22
23
  };
@@ -13,17 +13,19 @@ export declare const navigateToLoginPage: ({ clientId, redirectUri, idpErrorCode
13
13
  responseType: string;
14
14
  }) => void;
15
15
  export declare const endSession: EndSessionFn;
16
- export declare const authorize: ({ code, redirectUri, clientId, scope, responseType, }: {
16
+ export declare const authorize: ({ code, redirectUri, clientId, scope, responseType, isConsumerUser, }: {
17
17
  code: string;
18
18
  redirectUri: string;
19
19
  clientId: string;
20
20
  scope: string;
21
21
  responseType: string;
22
+ isConsumerUser: boolean;
22
23
  }) => Promise<void>;
23
- export declare const login: ({ clientId, scope, responseType, }: {
24
+ export declare const login: ({ clientId, scope, responseType, isConsumerUser, }: {
24
25
  clientId: string;
25
26
  scope: string;
26
27
  responseType: string;
28
+ isConsumerUser: boolean;
27
29
  }) => Promise<{
28
30
  authorized: boolean;
29
31
  }>;
@@ -10,4 +10,4 @@ export type GuestMicroAppParams = OpenAppParams & {
10
10
  * Component to load a guest microapp
11
11
  * @param props - The props for the MicroApp component.
12
12
  */
13
- export declare const GuestMicroApp: import("react").NamedExoticComponent<GuestMicroAppParams>;
13
+ export declare const GuestMicroApp: import("react").NamedExoticComponent<Omit<GuestMicroAppParams, "containerId">>;
@@ -3,6 +3,7 @@ interface LoginParams {
3
3
  scope: string;
4
4
  responseType: string;
5
5
  children: React.ReactNode;
6
+ isConsumerUser: boolean;
6
7
  }
7
- export declare const Login: ({ clientId, scope, responseType, children, }: LoginParams) => import("react/jsx-runtime.js").JSX.Element | null;
8
+ export declare const Login: ({ clientId, scope, responseType, children, isConsumerUser, }: LoginParams) => import("react/jsx-runtime.js").JSX.Element | null;
8
9
  export {};
@@ -3,5 +3,6 @@ export interface RequireAuthProps {
3
3
  scope?: string;
4
4
  responseType?: string;
5
5
  children: React.ReactNode;
6
+ isConsumerUser?: boolean;
6
7
  }
7
- export declare const RequireAuth: ({ children, clientId, scope, responseType, }: RequireAuthProps) => import("react/jsx-runtime.js").JSX.Element;
8
+ export declare const RequireAuth: ({ children, clientId, scope, responseType, isConsumerUser, }: RequireAuthProps) => import("react/jsx-runtime.js").JSX.Element;