@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.esm.js CHANGED
@@ -462,24 +462,24 @@ function useCAMSMSALAuth(options) {
462
462
  }, [accessToken, account, instance, options.storageKey]);
463
463
  var login = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
464
464
  var response, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
465
- var _a;
466
- return __generator$1(this, function (_b) {
467
- switch (_b.label) {
465
+ var _a, _b;
466
+ return __generator$1(this, function (_c) {
467
+ switch (_c.label) {
468
468
  case 0:
469
469
  if (inProgress !== InteractionStatus.None) {
470
470
  Logger.warn("Authentication already in progress, ignoring duplicate call");
471
471
  return [2 /*return*/];
472
472
  }
473
473
  setError(null);
474
- _b.label = 1;
474
+ _c.label = 1;
475
475
  case 1:
476
- _b.trys.push([1, 4, , 5]);
476
+ _c.trys.push([1, 4, , 5]);
477
477
  return [4 /*yield*/, instance.loginPopup({
478
478
  scopes: scopes,
479
479
  prompt: prompt || "login",
480
480
  })];
481
481
  case 2:
482
- response = _b.sent();
482
+ response = _c.sent();
483
483
  authenticator = new CAMSMFAAuthenticator();
484
484
  setIsFetchingMFAConfig(true);
485
485
  return [4 /*yield*/, authenticator.GetUserMFAConfig({
@@ -489,7 +489,7 @@ function useCAMSMSALAuth(options) {
489
489
  APIAuthEndpoint: ValidateUserEndpoint,
490
490
  })];
491
491
  case 3:
492
- userConfig = _b.sent();
492
+ userConfig = _c.sent();
493
493
  setIsFetchingMFAConfig(false);
494
494
  Logger.info("CAMS MFA Authenticator initialized. MSAL User Auth is Completed...", {
495
495
  userConfig: userConfig,
@@ -511,28 +511,32 @@ function useCAMSMSALAuth(options) {
511
511
  }
512
512
  else {
513
513
  camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + userConfig.message);
514
- toast.error("Login failed");
514
+ toast.error((_a = userConfig.message) !== null && _a !== void 0 ? _a : "Login failed");
515
+ Logger.error("Login failed: " + userConfig.message);
515
516
  setError(camsError);
516
517
  setIsFetchingMFAConfig(false);
517
518
  }
518
519
  return [3 /*break*/, 5];
519
520
  case 4:
520
- err_1 = _b.sent();
521
+ err_1 = _c.sent();
521
522
  // Handle interaction_in_progress error
522
523
  if (err_1.errorCode === "interaction_in_progress") {
523
524
  Logger.warn("Interaction already in progress, please wait");
525
+ toast.error("Interaction already in progress, please wait");
524
526
  return [2 /*return*/];
525
527
  }
526
528
  // Handle user cancellation gracefully
527
529
  if (err_1.errorCode === "user_cancelled") {
528
530
  Logger.error("User cancelled login");
531
+ toast.error("User cancelled login");
529
532
  setError(null); // Don't treat cancellation as an error
530
533
  return [2 /*return*/];
531
534
  }
532
535
  // If popup is blocked
533
536
  if (err_1.errorCode === "popup_window_error" ||
534
- ((_a = err_1.message) === null || _a === void 0 ? void 0 : _a.includes("popup"))) {
537
+ ((_b = err_1.message) === null || _b === void 0 ? void 0 : _b.includes("popup"))) {
535
538
  camsError_1 = new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Popup blocked by browser. Please allow popups and try again.");
539
+ toast.error(camsError_1.message);
536
540
  setError(camsError_1);
537
541
  return [2 /*return*/];
538
542
  }