@nibssplc/cams-sdk-react 1.0.0-rc.89 → 1.0.0-rc.90

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.cjs.js CHANGED
@@ -483,24 +483,24 @@ function useCAMSMSALAuth(options) {
483
483
  }, [accessToken, account, instance, options.storageKey]);
484
484
  var login = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
485
485
  var response, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
486
- var _a;
487
- return __generator$1(this, function (_b) {
488
- switch (_b.label) {
486
+ var _a, _b;
487
+ return __generator$1(this, function (_c) {
488
+ switch (_c.label) {
489
489
  case 0:
490
490
  if (inProgress !== msalBrowser.InteractionStatus.None) {
491
491
  camsSdk.Logger.warn("Authentication already in progress, ignoring duplicate call");
492
492
  return [2 /*return*/];
493
493
  }
494
494
  setError(null);
495
- _b.label = 1;
495
+ _c.label = 1;
496
496
  case 1:
497
- _b.trys.push([1, 4, , 5]);
497
+ _c.trys.push([1, 4, , 5]);
498
498
  return [4 /*yield*/, instance.loginPopup({
499
499
  scopes: scopes,
500
500
  prompt: prompt || "login",
501
501
  })];
502
502
  case 2:
503
- response = _b.sent();
503
+ response = _c.sent();
504
504
  authenticator = new camsSdk.CAMSMFAAuthenticator();
505
505
  setIsFetchingMFAConfig(true);
506
506
  return [4 /*yield*/, authenticator.GetUserMFAConfig({
@@ -510,7 +510,7 @@ function useCAMSMSALAuth(options) {
510
510
  APIAuthEndpoint: ValidateUserEndpoint,
511
511
  })];
512
512
  case 3:
513
- userConfig = _b.sent();
513
+ userConfig = _c.sent();
514
514
  setIsFetchingMFAConfig(false);
515
515
  camsSdk.Logger.info("CAMS MFA Authenticator initialized. MSAL User Auth is Completed...", {
516
516
  userConfig: userConfig,
@@ -532,28 +532,32 @@ function useCAMSMSALAuth(options) {
532
532
  }
533
533
  else {
534
534
  camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + userConfig.message);
535
- sonner.toast.error("Login failed");
535
+ sonner.toast.error((_a = userConfig.message) !== null && _a !== void 0 ? _a : "Login failed");
536
+ camsSdk.Logger.error("Login failed: " + userConfig.message);
536
537
  setError(camsError);
537
538
  setIsFetchingMFAConfig(false);
538
539
  }
539
540
  return [3 /*break*/, 5];
540
541
  case 4:
541
- err_1 = _b.sent();
542
+ err_1 = _c.sent();
542
543
  // Handle interaction_in_progress error
543
544
  if (err_1.errorCode === "interaction_in_progress") {
544
545
  camsSdk.Logger.warn("Interaction already in progress, please wait");
546
+ sonner.toast.error("Interaction already in progress, please wait");
545
547
  return [2 /*return*/];
546
548
  }
547
549
  // Handle user cancellation gracefully
548
550
  if (err_1.errorCode === "user_cancelled") {
549
551
  camsSdk.Logger.error("User cancelled login");
552
+ sonner.toast.error("User cancelled login");
550
553
  setError(null); // Don't treat cancellation as an error
551
554
  return [2 /*return*/];
552
555
  }
553
556
  // If popup is blocked
554
557
  if (err_1.errorCode === "popup_window_error" ||
555
- ((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("popup"))) {
558
+ ((_b = err_1.message) === null || _b === void 0 ? void 0 : _b.includes("popup"))) {
556
559
  camsError_1 = new camsSdk.CAMSError(camsSdk.CAMSErrorType.POPUP_BLOCKED, "Popup blocked by browser. Please allow popups and try again.");
560
+ sonner.toast.error(camsError_1.message);
557
561
  setError(camsError_1);
558
562
  return [2 /*return*/];
559
563
  }