@nibssplc/cams-sdk-react 1.0.0-rc.93 → 1.0.0-rc.95

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
@@ -1461,11 +1461,11 @@ var useOTPHandler = function (_a) {
1461
1461
  if (currentAttempt >= MAX_ATTEMPTS) {
1462
1462
  setIsMaxAttemptsReached(true);
1463
1463
  onAuthComplete(false, {
1464
- message: "Maximum attempts reached",
1464
+ message: "Maximum Attempts Reached",
1465
1465
  });
1466
1466
  }
1467
1467
  else {
1468
- onAuthComplete(false, response.response.data);
1468
+ onAuthComplete(false, response);
1469
1469
  }
1470
1470
  return [2 /*return*/, false];
1471
1471
  }
@@ -1475,12 +1475,12 @@ var useOTPHandler = function (_a) {
1475
1475
  currentAttempt = attemptCount + 1;
1476
1476
  if (currentAttempt >= MAX_ATTEMPTS) {
1477
1477
  setIsMaxAttemptsReached(true);
1478
- onAuthComplete(false, error_1.response.data);
1478
+ onAuthComplete(false, error_1);
1479
1479
  }
1480
1480
  else {
1481
- onAuthComplete(false, error_1.response.data);
1481
+ onAuthComplete(false, error_1);
1482
1482
  }
1483
- onAuthComplete(false, error_1.response.data);
1483
+ onAuthComplete(false, error_1);
1484
1484
  return [2 /*return*/, false];
1485
1485
  case 4:
1486
1486
  setLoading(false);
@@ -1507,53 +1507,51 @@ var useCredentialsHandler = function (onAuthComplete) {
1507
1507
  var _a = React.useState(false), loading = _a[0], setLoading = _a[1];
1508
1508
  var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
1509
1509
  var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
1510
- var handleSubmitCredentials = React.useMemo(function () {
1511
- return function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1512
- var currentAttempt, authenticator, response, error_2, currentAttempt;
1513
- return __generator$1(this, function (_a) {
1514
- switch (_a.label) {
1515
- case 0:
1516
- _a.trys.push([0, 2, 3, 4]);
1517
- setLoading(true);
1518
- currentAttempt = attemptCount + 1;
1519
- setAttemptCount(currentAttempt);
1520
- authenticator = new camsSdk.CAMSMFAAuthenticator();
1521
- return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
1522
- case 1:
1523
- response = _a.sent();
1524
- if (response) {
1525
- onAuthComplete(true, response);
1526
- return [2 /*return*/, true];
1527
- }
1528
- else {
1529
- if (currentAttempt >= MAX_ATTEMPTS) {
1530
- setIsMaxAttemptsReached(true);
1531
- onAuthComplete(false, {
1532
- message: "Maximum attempts reached",
1533
- });
1534
- }
1535
- else {
1536
- onAuthComplete(false, response.response.data);
1537
- }
1538
- return [2 /*return*/, false];
1539
- }
1540
- case 2:
1541
- error_2 = _a.sent();
1542
- console.error(error_2);
1543
- currentAttempt = attemptCount + 1;
1510
+ var handleSubmitCredentials = React.useMemo(function () { return function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1511
+ var currentAttempt, authenticator, response, error_2, currentAttempt;
1512
+ return __generator$1(this, function (_a) {
1513
+ switch (_a.label) {
1514
+ case 0:
1515
+ _a.trys.push([0, 2, 3, 4]);
1516
+ setLoading(true);
1517
+ currentAttempt = attemptCount + 1;
1518
+ setAttemptCount(currentAttempt);
1519
+ authenticator = new camsSdk.CAMSMFAAuthenticator();
1520
+ return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
1521
+ case 1:
1522
+ response = _a.sent();
1523
+ if (response) {
1524
+ onAuthComplete(true, response);
1525
+ return [2 /*return*/, true];
1526
+ }
1527
+ else {
1544
1528
  if (currentAttempt >= MAX_ATTEMPTS) {
1545
1529
  setIsMaxAttemptsReached(true);
1530
+ onAuthComplete(false, {
1531
+ message: "Maximum attempts reached",
1532
+ });
1533
+ }
1534
+ else {
1535
+ onAuthComplete(false, response.response.data);
1546
1536
  }
1547
- onAuthComplete(false, error_2.response.data);
1548
1537
  return [2 /*return*/, false];
1549
- case 3:
1550
- setLoading(false);
1551
- return [7 /*endfinally*/];
1552
- case 4: return [2 /*return*/];
1553
- }
1554
- });
1555
- }); };
1556
- }, []);
1538
+ }
1539
+ case 2:
1540
+ error_2 = _a.sent();
1541
+ console.error(error_2);
1542
+ currentAttempt = attemptCount + 1;
1543
+ if (currentAttempt >= MAX_ATTEMPTS) {
1544
+ setIsMaxAttemptsReached(true);
1545
+ }
1546
+ onAuthComplete(false, error_2.response.data);
1547
+ return [2 /*return*/, false];
1548
+ case 3:
1549
+ setLoading(false);
1550
+ return [7 /*endfinally*/];
1551
+ case 4: return [2 /*return*/];
1552
+ }
1553
+ });
1554
+ }); }; }, []);
1557
1555
  return {
1558
1556
  handleSubmitCredentials: handleSubmitCredentials,
1559
1557
  loading: loading,
@@ -1841,11 +1839,7 @@ var MFAEndpointsSchema = z.object({
1841
1839
  AuthChallengeVerify: z.url("MFA AuthChallengeVerify must be a valid URL"),
1842
1840
  });
1843
1841
  var MFAGate = function (_a) {
1844
- var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingSpinner, {}) })) : _b,
1845
- // loginComponent: LoginComponent = DefaultLoginPage,
1846
- _c = _a.usePassKey,
1847
- // loginComponent: LoginComponent = DefaultLoginPage,
1848
- usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
1842
+ var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingSpinner, {}) })) : _b, _c = _a.usePassKey, usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
1849
1843
  var context = useCAMSContext();
1850
1844
  var _e = React.useState("Loading"), authState = _e[0], setAuthState = _e[1];
1851
1845
  var ValidatedMFAEndpoints = React.useMemo(function () {
@@ -1874,7 +1868,7 @@ var MFAGate = function (_a) {
1874
1868
  }
1875
1869
  }
1876
1870
  else if (!success) {
1877
- camsSdk.Logger.error("MFA authentication failed", { context: context || null });
1871
+ camsSdk.Logger.error("MFA Authentication Failed", { context: context || null });
1878
1872
  }
1879
1873
  }, [context, onAuthSuccess]);
1880
1874
  var handleAuthFailed = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {