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

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
@@ -1485,15 +1485,20 @@ var useCredentialsHandler = function (onAuthComplete) {
1485
1485
  var _a = useState(false), loading = _a[0], setLoading = _a[1];
1486
1486
  var _b = useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
1487
1487
  var _c = useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
1488
- var handleSubmitCredentials = useMemo(function () { return function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1489
- var currentAttempt, authenticator, response, error_2, currentAttempt;
1488
+ var handleSubmitCredentials = useCallback(function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1489
+ var authenticator, response, error_2;
1490
1490
  return __generator$1(this, function (_a) {
1491
1491
  switch (_a.label) {
1492
1492
  case 0:
1493
1493
  _a.trys.push([0, 2, 3, 4]);
1494
1494
  setLoading(true);
1495
- currentAttempt = attemptCount + 1;
1496
- setAttemptCount(currentAttempt);
1495
+ setAttemptCount(function (prev) {
1496
+ var currentAttempt = prev + 1;
1497
+ if (currentAttempt >= MAX_ATTEMPTS) {
1498
+ setIsMaxAttemptsReached(true);
1499
+ }
1500
+ return currentAttempt;
1501
+ });
1497
1502
  authenticator = new CAMSMFAAuthenticator();
1498
1503
  return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
1499
1504
  case 1:
@@ -1503,25 +1508,13 @@ var useCredentialsHandler = function (onAuthComplete) {
1503
1508
  return [2 /*return*/, true];
1504
1509
  }
1505
1510
  else {
1506
- if (currentAttempt >= MAX_ATTEMPTS) {
1507
- setIsMaxAttemptsReached(true);
1508
- onAuthComplete(false, {
1509
- message: "Maximum attempts reached",
1510
- });
1511
- }
1512
- else {
1513
- onAuthComplete(false, response.response.data);
1514
- }
1511
+ onAuthComplete(false, response);
1515
1512
  return [2 /*return*/, false];
1516
1513
  }
1517
1514
  case 2:
1518
1515
  error_2 = _a.sent();
1519
1516
  console.error(error_2);
1520
- currentAttempt = attemptCount + 1;
1521
- if (currentAttempt >= MAX_ATTEMPTS) {
1522
- setIsMaxAttemptsReached(true);
1523
- }
1524
- onAuthComplete(false, error_2.response.data);
1517
+ onAuthComplete(false, error_2);
1525
1518
  return [2 /*return*/, false];
1526
1519
  case 3:
1527
1520
  setLoading(false);
@@ -1529,7 +1522,7 @@ var useCredentialsHandler = function (onAuthComplete) {
1529
1522
  case 4: return [2 /*return*/];
1530
1523
  }
1531
1524
  });
1532
- }); }; }, []);
1525
+ }); }, [onAuthComplete]);
1533
1526
  return {
1534
1527
  handleSubmitCredentials: handleSubmitCredentials,
1535
1528
  loading: loading,
@@ -1800,15 +1793,20 @@ var DefaultLoginPage = function (_a) {
1800
1793
  }, disabled: isLoading, children: [jsx(KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsx("span", { children: "Create a Passkey" })] }))] }), jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsx(ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsx("span", { children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, isLoading: context.isLoading || isCredAuthLoading, setIsLoading: setIsCredAuthLoading, onLogin: function (_a) { return __awaiter$1(void 0, [_a], void 0, function (_b) {
1801
1794
  var username = _b.username, password = _b.password, MFACode = _b.MFACode;
1802
1795
  return __generator$1(this, function (_c) {
1803
- // Implement your AD login logic here
1804
- console.log("AD Login:", { username: username, MFACode: MFACode });
1805
- handleSubmitCredentials(CredentialsAuthEndpoint, {
1806
- username: username,
1807
- password: password,
1808
- MFACode: MFACode,
1809
- appCode: context.appCode,
1810
- });
1811
- return [2 /*return*/];
1796
+ switch (_c.label) {
1797
+ case 0:
1798
+ // Implement your AD login logic here
1799
+ console.log("AD Login:", { username: username, MFACode: MFACode });
1800
+ return [4 /*yield*/, handleSubmitCredentials(CredentialsAuthEndpoint, {
1801
+ username: username,
1802
+ password: password,
1803
+ MFACode: MFACode,
1804
+ appCode: context.appCode,
1805
+ })];
1806
+ case 1:
1807
+ _c.sent();
1808
+ return [2 /*return*/];
1809
+ }
1812
1810
  });
1813
1811
  }); } })] }));
1814
1812
  };