@nibssplc/cams-sdk-react 0.0.1-beta.41 → 0.0.1-beta.42

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/index.esm.js CHANGED
@@ -16695,7 +16695,7 @@ function useCAMSMSALAuth(options) {
16695
16695
  }; }
16696
16696
  var _a = useMsal(), instance = _a.instance, inProgress = _a.inProgress, accounts = _a.accounts;
16697
16697
  var account = useAccount(accounts[0] || {});
16698
- var storageKey = 'CAMS-MSAL-AUTH-SDK';
16698
+ var storageKey = "CAMS-MSAL-AUTH-SDK";
16699
16699
  var _b = useState(null), error = _b[0], setError = _b[1];
16700
16700
  var _c = useState(null), token = _c[0], setToken = _c[1];
16701
16701
  var _d = useState(null), idToken = _d[0], setIdToken = _d[1];
@@ -16705,7 +16705,7 @@ function useCAMSMSALAuth(options) {
16705
16705
  var scopes = options.scopes || ["openid", "profile", "email"];
16706
16706
  var isTokenValid = function (token) {
16707
16707
  try {
16708
- var payload = JSON.parse(atob(token.split('.')[1]));
16708
+ var payload = JSON.parse(atob(token.split(".")[1]));
16709
16709
  return payload.exp * 1000 > Date.now();
16710
16710
  }
16711
16711
  catch (_a) {
@@ -16713,7 +16713,7 @@ function useCAMSMSALAuth(options) {
16713
16713
  }
16714
16714
  };
16715
16715
  useEffect(function () {
16716
- if (typeof window !== 'undefined' && !token) {
16716
+ if (typeof window !== "undefined" && !token) {
16717
16717
  var stored = localStorage.getItem(storageKey);
16718
16718
  if (stored) {
16719
16719
  try {
@@ -16782,23 +16782,26 @@ function useCAMSMSALAuth(options) {
16782
16782
  var _a;
16783
16783
  Logger$1.debug("Login Token response:", {
16784
16784
  accessToken: accessToken,
16785
- idToken: idToken
16785
+ idToken: idToken,
16786
16786
  });
16787
16787
  setToken(response.accessToken);
16788
16788
  setAccessToken(response.accessToken);
16789
16789
  setIdToken(response.idToken);
16790
16790
  // Persist tokens to localStorage
16791
- if (typeof window !== 'undefined') {
16791
+ if (typeof window !== "undefined") {
16792
16792
  localStorage.setItem(storageKey, JSON.stringify({
16793
16793
  isAuthenticated: true,
16794
16794
  accessToken: response.accessToken,
16795
- idToken: response.idToken
16795
+ idToken: response.idToken,
16796
16796
  }));
16797
16797
  }
16798
16798
  (_a = options.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken);
16799
16799
  if (typeof window !== "undefined" &&
16800
16800
  process.env.NODE_ENV !== "test") {
16801
- window.location.href = options.mfaUrl;
16801
+ // Center the popup window
16802
+ var left = (window.screen.width - 500) / 2;
16803
+ var top_1 = (window.screen.height - 600) / 2;
16804
+ window.open(options.mfaUrl, "_blank", "width=500,height=600,left=".concat(left, ",top=").concat(top_1, ",scrollbars=yes,resizable=yes"));
16802
16805
  }
16803
16806
  })];
16804
16807
  case 2:
@@ -16839,7 +16842,7 @@ function useCAMSMSALAuth(options) {
16839
16842
  setAccessToken(null);
16840
16843
  setIdToken(null);
16841
16844
  setError(null);
16842
- if (typeof window !== 'undefined') {
16845
+ if (typeof window !== "undefined") {
16843
16846
  localStorage.removeItem(storageKey);
16844
16847
  }
16845
16848
  return [3 /*break*/, 3];