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

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.d.ts CHANGED
@@ -3,9 +3,9 @@ export * from './hooks/useCAMSAuth';
3
3
  export * from './hooks/useCAMSMSALAuth';
4
4
  export { useWebAuthn } from './hooks/useFIDOAuth';
5
5
  export * from './components/ProtectedRoute';
6
- export { CAMSMSALProvider, useCAMSMSALContext } from './components/CAMSMSALProvider';
6
+ export { CAMSMSALProvider, useCAMSMSALContext } from './context/CAMSMSALProvider';
7
7
  export * from './components/ClientOnly';
8
- export * from './components/UnifiedCAMSProvider';
8
+ export * from './context/UnifiedCAMSProvider';
9
9
  export { default as MFAOptions } from './components/MFAOptions';
10
10
  export { default as MFAGate } from './components/MFAGate';
11
11
  export { default as DefaultLoginPage } from './components/DefaultLoginPage';
package/dist/index.esm.js CHANGED
@@ -461,7 +461,7 @@ function useCAMSMSALAuth(options) {
461
461
  }
462
462
  }, [accessToken, account, instance, options.storageKey]);
463
463
  var login = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
464
- var response, authenticator, userConfig, camsError, err_1, camsError_1, camsError;
464
+ var response, authenticator, userConfig, camsError, error_1, err_1, camsError_1, camsError;
465
465
  var _a, _b;
466
466
  return __generator$1(this, function (_c) {
467
467
  switch (_c.label) {
@@ -473,7 +473,7 @@ function useCAMSMSALAuth(options) {
473
473
  setError(null);
474
474
  _c.label = 1;
475
475
  case 1:
476
- _c.trys.push([1, 4, , 5]);
476
+ _c.trys.push([1, 7, , 8]);
477
477
  return [4 /*yield*/, instance.loginPopup({
478
478
  scopes: scopes,
479
479
  prompt: prompt || "login",
@@ -482,13 +482,16 @@ function useCAMSMSALAuth(options) {
482
482
  response = _c.sent();
483
483
  authenticator = new CAMSMFAAuthenticator();
484
484
  setIsFetchingMFAConfig(true);
485
+ _c.label = 3;
486
+ case 3:
487
+ _c.trys.push([3, 5, , 6]);
485
488
  return [4 /*yield*/, authenticator.GetUserMFAConfig({
486
489
  accessToken: response.accessToken,
487
490
  idToken: response.idToken,
488
491
  provider: "MSAL",
489
492
  APIAuthEndpoint: ValidateUserEndpoint,
490
493
  })];
491
- case 3:
494
+ case 4:
492
495
  userConfig = _c.sent();
493
496
  setIsFetchingMFAConfig(false);
494
497
  Logger.info("CAMS MFA Authenticator initialized. MSAL User Auth is Completed...", {
@@ -516,8 +519,20 @@ function useCAMSMSALAuth(options) {
516
519
  setError(camsError);
517
520
  setIsFetchingMFAConfig(false);
518
521
  }
519
- return [3 /*break*/, 5];
520
- case 4:
522
+ return [3 /*break*/, 6];
523
+ case 5:
524
+ error_1 = _c.sent();
525
+ if (error_1 instanceof CAMSError &&
526
+ error_1.type === CAMSErrorType.NETWORK_ERROR) {
527
+ toast.error(error_1.message);
528
+ Logger.error(error_1.message);
529
+ setError(error_1);
530
+ setIsFetchingMFAConfig(false);
531
+ return [2 /*return*/];
532
+ }
533
+ return [3 /*break*/, 6];
534
+ case 6: return [3 /*break*/, 8];
535
+ case 7:
521
536
  err_1 = _c.sent();
522
537
  // Handle interaction_in_progress error
523
538
  if (err_1.errorCode === "interaction_in_progress") {
@@ -527,8 +542,8 @@ function useCAMSMSALAuth(options) {
527
542
  }
528
543
  // Handle user cancellation gracefully
529
544
  if (err_1.errorCode === "user_cancelled") {
530
- Logger.error("User cancelled login");
531
- toast.error("User cancelled login");
545
+ Logger.error("User Cancelled Login Flow");
546
+ toast.error("User Cancelled Login Flow");
532
547
  setError(null); // Don't treat cancellation as an error
533
548
  return [2 /*return*/];
534
549
  }
@@ -543,8 +558,8 @@ function useCAMSMSALAuth(options) {
543
558
  camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Login failed: " + err_1.message || err_1);
544
559
  setError(camsError);
545
560
  setIsFetchingMFAConfig(false);
546
- return [3 /*break*/, 5];
547
- case 5: return [2 /*return*/];
561
+ return [3 /*break*/, 8];
562
+ case 8: return [2 /*return*/];
548
563
  }
549
564
  });
550
565
  }); }, [