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

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
@@ -16697,9 +16697,10 @@ function useCAMSMSALAuth(options) {
16697
16697
  var account = useAccount(accounts[0] || {});
16698
16698
  var storageKey = "CAMS-MSAL-AUTH-SDK";
16699
16699
  var _b = useState(null), error = _b[0], setError = _b[1];
16700
- var _c = useState(null), token = _c[0], setToken = _c[1];
16701
- var _d = useState(null), idToken = _d[0], setIdToken = _d[1];
16702
- var _e = useState(null), accessToken = _e[0], setAccessToken = _e[1];
16700
+ var _c = useState(""), token = _c[0], setToken = _c[1];
16701
+ var _d = useState(""), idToken = _d[0], setIdToken = _d[1];
16702
+ var _e = useState(""), appCode = _e[0], setAppCode = _e[1];
16703
+ var _f = useState(""), accessToken = _f[0], setAccessToken = _f[1];
16703
16704
  var isLoading = inProgress !== InteractionStatus.None;
16704
16705
  var isAuthenticated = !!account && !!token;
16705
16706
  var scopes = options.scopes || ["openid", "profile", "email"];
@@ -16717,11 +16718,12 @@ function useCAMSMSALAuth(options) {
16717
16718
  var stored = localStorage.getItem(storageKey);
16718
16719
  if (stored) {
16719
16720
  try {
16720
- var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken;
16721
+ var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode_1 = _a.appCode;
16721
16722
  if (accessToken_1 && isTokenValid(accessToken_1)) {
16722
16723
  setToken(accessToken_1);
16723
16724
  setAccessToken(accessToken_1);
16724
16725
  setIdToken(idToken_1);
16726
+ setAppCode(appCode_1);
16725
16727
  }
16726
16728
  else {
16727
16729
  localStorage.removeItem(storageKey);
@@ -16795,13 +16797,21 @@ function useCAMSMSALAuth(options) {
16795
16797
  idToken: response.idToken,
16796
16798
  }));
16797
16799
  }
16798
- (_a = options.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken);
16799
16800
  if (typeof window !== "undefined" &&
16800
16801
  process.env.NODE_ENV !== "test") {
16801
16802
  // Center the popup window
16802
16803
  var left = (window.screen.width - 500) / 2;
16803
16804
  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"));
16805
+ var authWindow = window.open(options.mfaUrl, "_blank", "width=500,height=600,left=".concat(left, ",top=").concat(top_1, ",scrollbars=yes,resizable=yes"));
16806
+ if (!authWindow) {
16807
+ Logger$1.error("Popup window blocked");
16808
+ throw new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Popup blocked by browser. Please allow popups and try again.");
16809
+ }
16810
+ if (authWindow.closed) {
16811
+ Logger$1.error("Popup immediately closed by blocker");
16812
+ throw new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Popup blocked by browser. Please allow popups and try again.");
16813
+ }
16814
+ (_a = options.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken);
16805
16815
  }
16806
16816
  })];
16807
16817
  case 2:
@@ -16838,9 +16848,9 @@ function useCAMSMSALAuth(options) {
16838
16848
  return [4 /*yield*/, instance.logoutRedirect()];
16839
16849
  case 1:
16840
16850
  _a.sent();
16841
- setToken(null);
16842
- setAccessToken(null);
16843
- setIdToken(null);
16851
+ setToken("");
16852
+ setAccessToken("");
16853
+ setIdToken("");
16844
16854
  setError(null);
16845
16855
  if (typeof window !== "undefined") {
16846
16856
  localStorage.removeItem(storageKey);
@@ -16862,9 +16872,9 @@ function useCAMSMSALAuth(options) {
16862
16872
  isAuthenticated: isAuthenticated,
16863
16873
  isLoading: isLoading,
16864
16874
  error: error,
16865
- token: token,
16866
16875
  idToken: idToken,
16867
16876
  accessToken: accessToken,
16877
+ appCode: appCode,
16868
16878
  };
16869
16879
  }
16870
16880