@nibssplc/cams-sdk-react 1.0.0-rc.98 → 1.0.0-rc.99

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
@@ -1411,15 +1411,15 @@ var useOTPHandler = function (_a) {
1411
1411
  return __generator$1(this, function (_a) {
1412
1412
  switch (_a.label) {
1413
1413
  case 0:
1414
- if (isMaxAttemptsReached) {
1415
- onAuthComplete(false, {
1414
+ if (!isMaxAttemptsReached) return [3 /*break*/, 2];
1415
+ return [4 /*yield*/, onAuthComplete(false, {
1416
1416
  message: "Maximum attempts reached",
1417
- });
1418
- return [2 /*return*/, false];
1419
- }
1420
- _a.label = 1;
1417
+ })];
1421
1418
  case 1:
1422
- _a.trys.push([1, 3, 4, 5]);
1419
+ _a.sent();
1420
+ return [2 /*return*/, false];
1421
+ case 2:
1422
+ _a.trys.push([2, 11, 13, 14]);
1423
1423
  setLoading(true);
1424
1424
  currentAttempt = attemptCount + 1;
1425
1425
  setAttemptCount(currentAttempt);
@@ -1430,41 +1430,43 @@ var useOTPHandler = function (_a) {
1430
1430
  email: email,
1431
1431
  MFACode: authenticationValue,
1432
1432
  }, MFAEndpoint || "")];
1433
- case 2:
1434
- response = _a.sent();
1435
- if (response) {
1436
- onAuthComplete(true, response);
1437
- return [2 /*return*/, true];
1438
- }
1439
- else {
1440
- if (currentAttempt >= MAX_ATTEMPTS) {
1441
- setIsMaxAttemptsReached(true);
1442
- onAuthComplete(false, {
1443
- message: "Maximum Attempts Reached",
1444
- });
1445
- }
1446
- else {
1447
- onAuthComplete(false, response);
1448
- }
1449
- return [2 /*return*/, false];
1450
- }
1451
1433
  case 3:
1434
+ response = _a.sent();
1435
+ if (!response) return [3 /*break*/, 5];
1436
+ return [4 /*yield*/, onAuthComplete(true, response)];
1437
+ case 4:
1438
+ _a.sent();
1439
+ return [2 /*return*/, true];
1440
+ case 5:
1441
+ if (!(currentAttempt >= MAX_ATTEMPTS)) return [3 /*break*/, 7];
1442
+ setIsMaxAttemptsReached(true);
1443
+ return [4 /*yield*/, onAuthComplete(false, {
1444
+ message: "Maximum Attempts Reached",
1445
+ })];
1446
+ case 6:
1447
+ _a.sent();
1448
+ return [3 /*break*/, 9];
1449
+ case 7: return [4 /*yield*/, onAuthComplete(false, response)];
1450
+ case 8:
1451
+ _a.sent();
1452
+ _a.label = 9;
1453
+ case 9: return [2 /*return*/, false];
1454
+ case 10: return [3 /*break*/, 14];
1455
+ case 11:
1452
1456
  error_1 = _a.sent();
1453
1457
  console.error(error_1);
1454
1458
  currentAttempt = attemptCount + 1;
1455
1459
  if (currentAttempt >= MAX_ATTEMPTS) {
1456
1460
  setIsMaxAttemptsReached(true);
1457
- onAuthComplete(false, error_1);
1458
- }
1459
- else {
1460
- onAuthComplete(false, error_1);
1461
1461
  }
1462
- onAuthComplete(false, error_1);
1462
+ return [4 /*yield*/, onAuthComplete(false, error_1)];
1463
+ case 12:
1464
+ _a.sent();
1463
1465
  return [2 /*return*/, false];
1464
- case 4:
1466
+ case 13:
1465
1467
  setLoading(false);
1466
1468
  return [7 /*endfinally*/];
1467
- case 5: return [2 /*return*/];
1469
+ case 14: return [2 /*return*/];
1468
1470
  }
1469
1471
  });
1470
1472
  }); }; }, [onAuthComplete, MFAEndpoint, attemptCount, isMaxAttemptsReached]);
@@ -1574,9 +1576,8 @@ var MFAOptions = function (_a) {
1574
1576
  }))];
1575
1577
  case 1:
1576
1578
  _a.sent();
1577
- onComplete(true);
1578
1579
  toast.success(jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsx(ShieldCheck, { className: "w-4 h-4" }), jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
1579
- setTimeout(function () { return setShowSuccessAnimation(true); }, 2000);
1580
+ setShowSuccessAnimation(true);
1580
1581
  return [3 /*break*/, 3];
1581
1582
  case 2:
1582
1583
  toast.error(jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsx(ShieldClose, { className: "w-4 h-4" }), jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
@@ -1604,9 +1605,7 @@ var MFAOptions = function (_a) {
1604
1605
  };
1605
1606
  // Show success animation if authentication is successful
1606
1607
  if (showSuccessAnimation) {
1607
- return (jsx("div", { className: "flex justify-center items-center h-dvh", children: jsx(Card, { className: "mx-auto space-y-6 p-6 bg-white rounded-lg shadow-md", children: jsx(AuthSuccessAnimation, { onComplete: function () {
1608
- // Animation completed, can add additional logic here if needed
1609
- } }) }) }));
1608
+ return (jsx("div", { className: "flex justify-center items-center h-dvh", children: jsx(Card, { className: "mx-auto space-y-6 p-6 bg-white rounded-lg shadow-md", children: jsx(AuthSuccessAnimation, { onComplete: function () { return onComplete(true); } }) }) }));
1610
1609
  }
1611
1610
  var content = jsx(Fragment, {});
1612
1611
  if (!authType) {
@@ -1847,6 +1846,7 @@ var MFAGate = function (_a) {
1847
1846
  var idToken = "idToken" in context ? context.idToken : "";
1848
1847
  Logger.info("MFA Authentication Successful", { context: context || null });
1849
1848
  context.isAuthenticated = true;
1849
+ setAuthState("Authenticated");
1850
1850
  if (context.authMode === "MSAL") {
1851
1851
  var tokens = { accessToken: accessToken, idToken: idToken };
1852
1852
  onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens);