@nibssplc/cams-sdk-react 1.0.0-rc.102 → 1.0.0-rc.104

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
@@ -622,32 +622,26 @@ function useCAMSMSALAuth(options) {
622
622
  });
623
623
  }); }, []);
624
624
  var logout = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
625
- var err_2, camsError;
625
+ var camsError;
626
626
  return __generator$1(this, function (_a) {
627
- switch (_a.label) {
628
- case 0:
629
- _a.trys.push([0, 2, , 3]);
630
- Logger.info("Logging User Out");
631
- setAccessToken("");
632
- setIdToken("");
633
- setError(null);
634
- setRequiresMFA(false);
635
- setIsAuthenticated(false);
636
- if (typeof window !== "undefined") {
637
- localStorage.removeItem(storageKey);
638
- deleteCookie(storageKey + "-PROFILE");
639
- }
640
- return [4 /*yield*/, instance.logoutRedirect()];
641
- case 1:
642
- _a.sent();
643
- return [3 /*break*/, 3];
644
- case 2:
645
- err_2 = _a.sent();
646
- camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err_2);
647
- setError(camsError);
648
- return [3 /*break*/, 3];
649
- case 3: return [2 /*return*/];
627
+ try {
628
+ Logger.info("Logging User Out");
629
+ setAccessToken("");
630
+ setIdToken("");
631
+ setError(null);
632
+ setRequiresMFA(false);
633
+ setIsAuthenticated(false);
634
+ if (typeof window !== "undefined") {
635
+ localStorage.removeItem(storageKey);
636
+ deleteCookie(storageKey + "-PROFILE");
637
+ }
638
+ // await instance.logoutRedirect();
639
+ }
640
+ catch (err) {
641
+ camsError = new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err);
642
+ setError(camsError);
650
643
  }
644
+ return [2 /*return*/];
651
645
  });
652
646
  }); }, [instance, storageKey]);
653
647
  return {
@@ -1555,16 +1549,20 @@ var MFAOptions = function (_a) {
1555
1549
  var _f = useState(false), showSuccessAnimation = _f[0], setShowSuccessAnimation = _f[1];
1556
1550
  var _g = useState(null), authType = _g[0], setAuthType = _g[1];
1557
1551
  var context = useCAMSContext();
1558
- var _h = context.authMode === "MSAL"
1559
- ? context
1560
- : { completeMFA: function (data) { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1561
- return [2 /*return*/, data];
1562
- }); }); }, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1563
- return [2 /*return*/];
1564
- }); }); } }, completeMFA = _h.completeMFA, logout = _h.logout;
1552
+ // Type-safe extraction of completeMFA and logout
1553
+ var completeMFA = context.authMode === "MSAL"
1554
+ ? context.completeMFA
1555
+ : function (data) { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1556
+ return [2 /*return*/, data];
1557
+ }); }); };
1558
+ var logout = context.authMode === "MSAL"
1559
+ ? context.logout
1560
+ : function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1561
+ return [2 /*return*/];
1562
+ }); }); };
1565
1563
  var authenticate = useWebAuthn().authenticate;
1566
1564
  var authenticator = new CAMSMFAAuthenticator();
1567
- var _j = useOTPHandler({
1565
+ var _h = useOTPHandler({
1568
1566
  email: ((_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email) || context.email,
1569
1567
  appCode: context.appCode || "",
1570
1568
  MFAEndpoint: MFAEndpoints.ValidateUserMFA,
@@ -1603,9 +1601,9 @@ var MFAOptions = function (_a) {
1603
1601
  }
1604
1602
  });
1605
1603
  }); },
1606
- }), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading,
1604
+ }), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading,
1607
1605
  // setLoading,
1608
- attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
1606
+ attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
1609
1607
  var handleGoBack = function () {
1610
1608
  setAuthType(null);
1611
1609
  setOtpVisible(false);