@nibssplc/cams-sdk-react 0.0.1-beta.22 → 0.0.1-beta.23

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
@@ -16704,7 +16704,7 @@ function useCAMSMSALAuth(options) {
16704
16704
  if (account && !isMFAPending) {
16705
16705
  // Get token in foreground popup
16706
16706
  instance
16707
- .acquireTokenPopup({
16707
+ .acquireTokenSilent({
16708
16708
  scopes: scopes,
16709
16709
  account: account,
16710
16710
  prompt: options.prompt || "select_account",
@@ -16747,29 +16747,48 @@ function useCAMSMSALAuth(options) {
16747
16747
  }
16748
16748
  }, [account, instance, isMFAPending]);
16749
16749
  var login = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
16750
- var err_1, camsError;
16751
- var _a;
16752
- return __generator(this, function (_b) {
16753
- switch (_b.label) {
16750
+ var err_1, redirectErr_1, camsError_1, camsError;
16751
+ var _a, _b, _c;
16752
+ return __generator(this, function (_d) {
16753
+ switch (_d.label) {
16754
16754
  case 0:
16755
16755
  setError(null);
16756
- _b.label = 1;
16756
+ _d.label = 1;
16757
16757
  case 1:
16758
- _b.trys.push([1, 3, , 4]);
16759
- return [4 /*yield*/, instance.loginRedirect({
16758
+ _d.trys.push([1, 3, , 8]);
16759
+ return [4 /*yield*/, instance.loginPopup({
16760
16760
  scopes: scopes,
16761
16761
  prompt: options.prompt || "select_account",
16762
16762
  })];
16763
16763
  case 2:
16764
- _b.sent();
16765
- return [3 /*break*/, 4];
16764
+ _d.sent();
16765
+ return [3 /*break*/, 8];
16766
16766
  case 3:
16767
- err_1 = _b.sent();
16767
+ err_1 = _d.sent();
16768
+ if (!(err_1.errorCode === "popup_window_error" ||
16769
+ ((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("popup")))) return [3 /*break*/, 7];
16770
+ _d.label = 4;
16771
+ case 4:
16772
+ _d.trys.push([4, 6, , 7]);
16773
+ return [4 /*yield*/, instance.loginRedirect({
16774
+ scopes: scopes,
16775
+ prompt: options.prompt || "select_account",
16776
+ })];
16777
+ case 5:
16778
+ _d.sent();
16779
+ return [2 /*return*/];
16780
+ case 6:
16781
+ redirectErr_1 = _d.sent();
16782
+ camsError_1 = new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Both popup and redirect failed: " + redirectErr_1);
16783
+ setError(camsError_1);
16784
+ (_b = options.onAuthError) === null || _b === void 0 ? void 0 : _b.call(options, camsError_1);
16785
+ return [2 /*return*/];
16786
+ case 7:
16768
16787
  camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + err_1);
16769
16788
  setError(camsError);
16770
- (_a = options.onAuthError) === null || _a === void 0 ? void 0 : _a.call(options, camsError);
16771
- return [3 /*break*/, 4];
16772
- case 4: return [2 /*return*/];
16789
+ (_c = options.onAuthError) === null || _c === void 0 ? void 0 : _c.call(options, camsError);
16790
+ return [3 /*break*/, 8];
16791
+ case 8: return [2 /*return*/];
16773
16792
  }
16774
16793
  });
16775
16794
  }); }, [instance, scopes, options]);