@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.cjs.js CHANGED
@@ -643,32 +643,26 @@ function useCAMSMSALAuth(options) {
643
643
  });
644
644
  }); }, []);
645
645
  var logout = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
646
- var err_2, camsError;
646
+ var camsError;
647
647
  return __generator$1(this, function (_a) {
648
- switch (_a.label) {
649
- case 0:
650
- _a.trys.push([0, 2, , 3]);
651
- camsSdk.Logger.info("Logging User Out");
652
- setAccessToken("");
653
- setIdToken("");
654
- setError(null);
655
- setRequiresMFA(false);
656
- setIsAuthenticated(false);
657
- if (typeof window !== "undefined") {
658
- localStorage.removeItem(storageKey);
659
- deleteCookie(storageKey + "-PROFILE");
660
- }
661
- return [4 /*yield*/, instance.logoutRedirect()];
662
- case 1:
663
- _a.sent();
664
- return [3 /*break*/, 3];
665
- case 2:
666
- err_2 = _a.sent();
667
- camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err_2);
668
- setError(camsError);
669
- return [3 /*break*/, 3];
670
- case 3: return [2 /*return*/];
648
+ try {
649
+ camsSdk.Logger.info("Logging User Out");
650
+ setAccessToken("");
651
+ setIdToken("");
652
+ setError(null);
653
+ setRequiresMFA(false);
654
+ setIsAuthenticated(false);
655
+ if (typeof window !== "undefined") {
656
+ localStorage.removeItem(storageKey);
657
+ deleteCookie(storageKey + "-PROFILE");
658
+ }
659
+ // await instance.logoutRedirect();
660
+ }
661
+ catch (err) {
662
+ camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Logout failed: " + err);
663
+ setError(camsError);
671
664
  }
665
+ return [2 /*return*/];
672
666
  });
673
667
  }); }, [instance, storageKey]);
674
668
  return {
@@ -1576,16 +1570,20 @@ var MFAOptions = function (_a) {
1576
1570
  var _f = React.useState(false), showSuccessAnimation = _f[0], setShowSuccessAnimation = _f[1];
1577
1571
  var _g = React.useState(null), authType = _g[0], setAuthType = _g[1];
1578
1572
  var context = useCAMSContext();
1579
- var _h = context.authMode === "MSAL"
1580
- ? context
1581
- : { completeMFA: function (data) { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1582
- return [2 /*return*/, data];
1583
- }); }); }, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1584
- return [2 /*return*/];
1585
- }); }); } }, completeMFA = _h.completeMFA, logout = _h.logout;
1573
+ // Type-safe extraction of completeMFA and logout
1574
+ var completeMFA = context.authMode === "MSAL"
1575
+ ? context.completeMFA
1576
+ : function (data) { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1577
+ return [2 /*return*/, data];
1578
+ }); }); };
1579
+ var logout = context.authMode === "MSAL"
1580
+ ? context.logout
1581
+ : function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
1582
+ return [2 /*return*/];
1583
+ }); }); };
1586
1584
  var authenticate = useWebAuthn().authenticate;
1587
1585
  var authenticator = new camsSdk.CAMSMFAAuthenticator();
1588
- var _j = useOTPHandler({
1586
+ var _h = useOTPHandler({
1589
1587
  email: ((_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email) || context.email,
1590
1588
  appCode: context.appCode || "",
1591
1589
  MFAEndpoint: MFAEndpoints.ValidateUserMFA,
@@ -1624,9 +1622,9 @@ var MFAOptions = function (_a) {
1624
1622
  }
1625
1623
  });
1626
1624
  }); },
1627
- }), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading,
1625
+ }), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading,
1628
1626
  // setLoading,
1629
- attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
1627
+ attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
1630
1628
  var handleGoBack = function () {
1631
1629
  setAuthType(null);
1632
1630
  setOtpVisible(false);