@elliemae/pui-app-sdk 3.12.0 → 3.12.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.
@@ -138,7 +138,6 @@ const authorize = async ({
138
138
  const data = await (0, import_users.getUser)({ userName });
139
139
  sessionStorage.setItem("userSettings", JSON.stringify(data));
140
140
  const pathName = new URL(redirectUri).pathname;
141
- import_history.browserHistory.push(`${pathName.replace(/\/$/, "")}/_rerender`);
142
141
  import_history.browserHistory.replace(pathName);
143
142
  } catch (err) {
144
143
  const code = err?.response?.data?.code;
@@ -165,7 +164,8 @@ const login = async ({
165
164
  };
166
165
  if (idpCode) {
167
166
  await authorize(loginInfo);
168
- } else {
169
- navigateToLoginPage(loginInfo);
167
+ return { authorized: true };
170
168
  }
169
+ navigateToLoginPage(loginInfo);
170
+ return { authorized: false };
171
171
  };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,23 +17,33 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
18
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
22
  var login_exports = {};
20
23
  __export(login_exports, {
21
24
  Login: () => Login
22
25
  });
23
26
  module.exports = __toCommonJS(login_exports);
27
+ var React = __toESM(require("react"));
24
28
  var import_react = require("react");
25
29
  var import_react_redux = require("../../data/react-redux.js");
26
30
  var import_auth = require("../../utils/auth/index.js");
27
31
  var import_actions = require("../../data/auth/actions.js");
28
- const Login = ({ clientId, scope, responseType }) => {
32
+ const Login = ({
33
+ clientId,
34
+ scope,
35
+ responseType,
36
+ children
37
+ }) => {
38
+ const [userAuthorized, setUserAuthorized] = (0, import_react.useState)(false);
29
39
  const dispatch = (0, import_react_redux.useAppDispatch)();
30
40
  (0, import_react.useEffect)(() => {
31
- (0, import_auth.login)({ clientId, scope, responseType }).then(() => {
41
+ (0, import_auth.login)({ clientId, scope, responseType }).then(({ authorized }) => {
42
+ if (authorized)
43
+ setUserAuthorized(true);
32
44
  dispatch({ type: import_actions.LOGIN_SUCCESS });
33
45
  }).catch(() => {
34
46
  });
35
47
  }, [dispatch, clientId, scope, responseType]);
36
- return null;
48
+ return userAuthorized ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : null;
37
49
  };
@@ -48,5 +48,5 @@ const RequireAuth = ({
48
48
  clientId,
49
49
  scope,
50
50
  responseType
51
- });
51
+ }, children);
52
52
  };
@@ -115,7 +115,6 @@ const authorize = async ({
115
115
  const data = await getUser({ userName });
116
116
  sessionStorage.setItem("userSettings", JSON.stringify(data));
117
117
  const pathName = new URL(redirectUri).pathname;
118
- history.push(`${pathName.replace(/\/$/, "")}/_rerender`);
119
118
  history.replace(pathName);
120
119
  } catch (err) {
121
120
  const code = err?.response?.data?.code;
@@ -142,9 +141,10 @@ const login = async ({
142
141
  };
143
142
  if (idpCode) {
144
143
  await authorize(loginInfo);
145
- } else {
146
- navigateToLoginPage(loginInfo);
144
+ return { authorized: true };
147
145
  }
146
+ navigateToLoginPage(loginInfo);
147
+ return { authorized: false };
148
148
  };
149
149
  export {
150
150
  authorize,
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
- import { useEffect } from "react";
2
+ import * as React from "react";
3
+ import { useEffect, useState } from "react";
3
4
  import { useAppDispatch } from "../../data/react-redux.js";
4
5
  import { login } from "../../utils/auth/index.js";
5
6
  import { LOGIN_SUCCESS } from "../../data/auth/actions.js";
6
- const Login = ({ clientId, scope, responseType }) => {
7
+ const Login = ({
8
+ clientId,
9
+ scope,
10
+ responseType,
11
+ children
12
+ }) => {
13
+ const [userAuthorized, setUserAuthorized] = useState(false);
7
14
  const dispatch = useAppDispatch();
8
15
  useEffect(() => {
9
- login({ clientId, scope, responseType }).then(() => {
16
+ login({ clientId, scope, responseType }).then(({ authorized }) => {
17
+ if (authorized)
18
+ setUserAuthorized(true);
10
19
  dispatch({ type: LOGIN_SUCCESS });
11
20
  }).catch(() => {
12
21
  });
13
22
  }, [dispatch, clientId, scope, responseType]);
14
- return null;
23
+ return userAuthorized ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : null;
15
24
  };
16
25
  export {
17
26
  Login
@@ -23,7 +23,7 @@ const RequireAuth = ({
23
23
  clientId,
24
24
  scope,
25
25
  responseType
26
- });
26
+ }, children);
27
27
  };
28
28
  export {
29
29
  RequireAuth
@@ -29,4 +29,6 @@ export declare const login: ({ clientId, scope, responseType, }: {
29
29
  clientId: string;
30
30
  scope: string;
31
31
  responseType: string;
32
- }) => Promise<void>;
32
+ }) => Promise<{
33
+ authorized: boolean;
34
+ }>;
@@ -1,7 +1,9 @@
1
+ /// <reference types="react" />
1
2
  interface LoginParams {
2
3
  clientId: string;
3
4
  scope: string;
4
5
  responseType: string;
6
+ children: React.ReactNode;
5
7
  }
6
- export declare const Login: ({ clientId, scope, responseType }: LoginParams) => null;
8
+ export declare const Login: ({ clientId, scope, responseType, children, }: LoginParams) => JSX.Element | null;
7
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-app-sdk",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "ICE MT UI Platform Application SDK ",
5
5
  "sideEffects": [
6
6
  "*.css",