@nibssplc/cams-sdk-react 1.0.0-rc.63 → 1.0.0-rc.65

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
@@ -578,7 +578,7 @@ function useCAMSMSALAuth(options) {
578
578
  switch (_a.label) {
579
579
  case 0:
580
580
  authenticator = new CAMSMFAAuthenticator();
581
- return [4 /*yield*/, authenticator.LoginADCredentials(credentials, appCode, CredentialsAuthEndpoint)];
581
+ return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
582
582
  case 1: return [2 /*return*/, _a.sent()];
583
583
  }
584
584
  });
@@ -1451,7 +1451,7 @@ var useCredentialsHandler = function (onAuthComplete) {
1451
1451
  var _b = useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
1452
1452
  var _c = useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
1453
1453
  var handleSubmitCredentials = useMemo(function () {
1454
- return function (CredentialsAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
1454
+ return function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1455
1455
  var currentAttempt, authenticator, response, error_2, currentAttempt;
1456
1456
  return __generator$1(this, function (_a) {
1457
1457
  switch (_a.label) {
@@ -1461,23 +1461,10 @@ var useCredentialsHandler = function (onAuthComplete) {
1461
1461
  currentAttempt = attemptCount + 1;
1462
1462
  setAttemptCount(currentAttempt);
1463
1463
  authenticator = new CAMSMFAAuthenticator();
1464
- return [4 /*yield*/, authenticator.LoginADCredentials(credentials, appCode, CredentialsAuthEndpoint)];
1464
+ return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
1465
1465
  case 1:
1466
1466
  response = _a.sent();
1467
- // .then((data) => {
1468
- // context.isAuthenticated = true;
1469
- // (context as any).requiresMFA = false;
1470
- // context.setUserProfile({
1471
- // type: "AUTH_SUCCESS",
1472
- // userProfile: {
1473
- // ...data,
1474
- // },
1475
- // });
1476
- // })
1477
- // .catch((error) => {
1478
- // console.error("AD Login failed:", error);
1479
- // toast.error("❌ AD Login failed.");
1480
- // });
1467
+ console.log(response);
1481
1468
  if (response) {
1482
1469
  onAuthComplete(true, response);
1483
1470
  return [2 /*return*/, true];
@@ -1693,6 +1680,7 @@ var ADLoginModal = function (_a) {
1693
1680
  username: credentials.username,
1694
1681
  password: credentials.password,
1695
1682
  MFACode: code,
1683
+ appCode: "",
1696
1684
  })];
1697
1685
  case 2:
1698
1686
  _a.sent();
@@ -1718,13 +1706,13 @@ var ADLoginModal = function (_a) {
1718
1706
  form.reset();
1719
1707
  setMfaCode("");
1720
1708
  };
1721
- return (jsx(Dialog, { open: open, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "min-w-[50vw] max-w-[70vw]", children: [jsx(DialogHeader, { children: jsxs("div", { className: "flex items-center gap-2", children: [jsx(KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsx(DialogTitle, { className: "text-2xl", children: "Sign in with AD" })] }) }), step === "credentials" ? (jsx(Form, __assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(handleCredentialsSubmit), className: "space-y-4", children: [jsx(FormField, { control: form.control, name: "username", render: function (_a) {
1709
+ return (jsx(Dialog, { open: open, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "min-w-[50vw] max-w-[70vw]", children: [jsx(DialogHeader, { children: jsxs("div", { className: "flex items-center gap-4", children: [jsx(KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsx(DialogTitle, { className: "text-xl", children: "Sign in with AD Credentials" })] }) }), step === "credentials" ? (jsx(Form, __assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(handleCredentialsSubmit), className: "space-y-6", children: [jsx(FormField, { control: form.control, name: "username", render: function (_a) {
1722
1710
  var field = _a.field;
1723
1711
  return (jsxs(FormItem, { children: [jsx(FormLabel, { children: "Username" }), jsx(FormControl, { children: jsx(Input, __assign({ className: "h-12", placeholder: "Enter your username" }, field)) }), jsx(FormMessage, {})] }));
1724
1712
  } }), jsx(FormField, { control: form.control, name: "password", render: function (_a) {
1725
1713
  var field = _a.field;
1726
1714
  return (jsxs(FormItem, { children: [jsx(FormLabel, { children: "Password" }), jsx(FormControl, { children: jsx(Input, __assign({ className: "h-12", type: "password", placeholder: "Enter your password" }, field)) }), jsx(FormMessage, {})] }));
1727
- } }), jsx(Button, { type: "submit", className: "w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxs("div", { className: "space-y-4", children: [jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsx(Loader2, { className: "w-4 h-4 animate-spin" }), jsx("span", { children: "Verifying..." })] }))] }))] }) }));
1715
+ } }), jsx(Button, { type: "submit", className: "py-3 w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxs("div", { className: "space-y-4", children: [jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsx(Loader2, { className: "w-4 h-4 animate-spin" }), jsx("span", { children: "Verifying..." })] }))] }))] }) }));
1728
1716
  };
1729
1717
 
1730
1718
  var DefaultLoginPage = function (_a) {
@@ -1763,6 +1751,9 @@ var DefaultLoginPage = function (_a) {
1763
1751
  },
1764
1752
  });
1765
1753
  }
1754
+ else {
1755
+ toast.error("\u274C AD Login failed. ".concat((data === null || data === void 0 ? void 0 : data.message) || 'Unknown error'));
1756
+ }
1766
1757
  return [2 /*return*/];
1767
1758
  });
1768
1759
  }); }), handleSubmitCredentials = _d.handleSubmitCredentials, isCredAuthLoading = _d.loading, setIsCredAuthLoading = _d.setLoading;
@@ -1779,7 +1770,7 @@ var DefaultLoginPage = function (_a) {
1779
1770
  console.warn("Regular CAMS login requires configuration");
1780
1771
  }
1781
1772
  };
1782
- return (jsxs("main", { className: "cams-sdk min-h-screen bg-gray-50", children: [jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.5 }, children: jsx("div", { className: "flex h-screen items-center justify-center", children: jsxs(motion.div, { variants: cardVariants, initial: "hidden", animate: "visible", exit: "exit", className: "w-full max-w-md p-6 space-y-4 rounded-2xl shadow-2xl", children: [jsxs(CardHeader, { className: "text-center space-y-3", children: [jsx("div", { className: "w-full flex items-center justify-center", children: jsx("img", { src: NIBSSLogo, alt: "NIBSS Logo", width: 265, height: 265 }) }), jsx(CardTitle, { className: "text-3xl font-bold", children: "NIBSS CAMS" }), jsx(CardTitle, { className: "text-gray-500 dark:text-gray-400 font-bold text-lg", children: "Centralized Authentication" })] }), jsxs(CardAction, { className: "w-full flex flex-col items-center justify-center text-center text-gray-500 dark:text-gray-400 mb-8", children: [jsx("img", { src: AuthLogo, alt: "Auth Logo", width: 365, height: 365 }), "Use Below Identity Providers To Authenticate"] }), jsxs("div", { className: "space-y-4", children: [jsxs(Button
1773
+ return (jsxs("main", { className: "cams-sdk min-h-screen bg-gray-50", children: [jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.5 }, children: jsx("div", { className: "flex h-screen items-center justify-center", children: jsxs(motion.div, { variants: cardVariants, initial: "hidden", animate: "visible", exit: "exit", className: "w-full max-w-md p-6 space-y-4 rounded-2xl shadow-2xl", children: [jsxs(CardHeader, { className: "text-center space-y-3", children: [jsx("div", { className: "w-full flex items-center justify-center", children: jsx("img", { src: NIBSSLogo, alt: "NIBSS Logo", width: 225, height: 225 }) }), jsx(CardTitle, { className: "text-3xl font-bold", children: "NIBSS CAMS" }), jsx(CardTitle, { className: "text-gray-500 dark:text-gray-400 font-bold text-lg", children: "Centralized Authentication" })] }), jsxs(CardAction, { className: "w-full flex flex-col items-center justify-center text-center text-gray-500 dark:text-gray-400 mb-8", children: [jsx("img", { src: AuthLogo, alt: "Auth Logo", width: 365, height: 365 }), "Use Below Identity Providers To Authenticate"] }), jsxs("div", { className: "space-y-4", children: [jsxs(Button
1783
1774
  // variant="outline"
1784
1775
  , {
1785
1776
  // variant="outline"
@@ -1793,7 +1784,7 @@ var DefaultLoginPage = function (_a) {
1793
1784
  return __generator$1(this, function (_c) {
1794
1785
  // Implement your AD login logic here
1795
1786
  console.log("AD Login:", { username: username, MFACode: MFACode });
1796
- handleSubmitCredentials(CredentialsAuthEndpoint !== null && CredentialsAuthEndpoint !== void 0 ? CredentialsAuthEndpoint : "/api/auth/validate", { username: username, password: password, MFACode: MFACode }, context.appCode);
1787
+ handleSubmitCredentials(CredentialsAuthEndpoint, { username: username, password: password, MFACode: MFACode, appCode: context.appCode });
1797
1788
  return [2 /*return*/];
1798
1789
  });
1799
1790
  }); } })] }));