@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.
@@ -15,7 +15,7 @@ export declare const useOTPHandler: ({ email, appCode, instCode, MFAEndpoint, on
15
15
  remainingAttempts: number;
16
16
  };
17
17
  export declare const useCredentialsHandler: (onAuthComplete: (state: boolean, data: MFAAuthenticatedResponse | null) => void) => {
18
- handleSubmitCredentials: (CredentialsAuthEndpoint: string, credentials: Credentials, appCode: string) => Promise<boolean>;
18
+ handleSubmitCredentials: (CredentialsAuthEndpoint: string, credentials: Credentials) => Promise<boolean>;
19
19
  loading: boolean;
20
20
  setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
21
  attemptCount: number;
package/dist/index.cjs.js CHANGED
@@ -599,7 +599,7 @@ function useCAMSMSALAuth(options) {
599
599
  switch (_a.label) {
600
600
  case 0:
601
601
  authenticator = new camsSdk.CAMSMFAAuthenticator();
602
- return [4 /*yield*/, authenticator.LoginADCredentials(credentials, appCode, CredentialsAuthEndpoint)];
602
+ return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
603
603
  case 1: return [2 /*return*/, _a.sent()];
604
604
  }
605
605
  });
@@ -1472,7 +1472,7 @@ var useCredentialsHandler = function (onAuthComplete) {
1472
1472
  var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
1473
1473
  var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
1474
1474
  var handleSubmitCredentials = React.useMemo(function () {
1475
- return function (CredentialsAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
1475
+ return function (CredentialsAuthEndpoint, credentials) { return __awaiter$1(void 0, void 0, void 0, function () {
1476
1476
  var currentAttempt, authenticator, response, error_2, currentAttempt;
1477
1477
  return __generator$1(this, function (_a) {
1478
1478
  switch (_a.label) {
@@ -1482,23 +1482,10 @@ var useCredentialsHandler = function (onAuthComplete) {
1482
1482
  currentAttempt = attemptCount + 1;
1483
1483
  setAttemptCount(currentAttempt);
1484
1484
  authenticator = new camsSdk.CAMSMFAAuthenticator();
1485
- return [4 /*yield*/, authenticator.LoginADCredentials(credentials, appCode, CredentialsAuthEndpoint)];
1485
+ return [4 /*yield*/, authenticator.LoginADCredentials(credentials, CredentialsAuthEndpoint)];
1486
1486
  case 1:
1487
1487
  response = _a.sent();
1488
- // .then((data) => {
1489
- // context.isAuthenticated = true;
1490
- // (context as any).requiresMFA = false;
1491
- // context.setUserProfile({
1492
- // type: "AUTH_SUCCESS",
1493
- // userProfile: {
1494
- // ...data,
1495
- // },
1496
- // });
1497
- // })
1498
- // .catch((error) => {
1499
- // console.error("AD Login failed:", error);
1500
- // toast.error("❌ AD Login failed.");
1501
- // });
1488
+ console.log(response);
1502
1489
  if (response) {
1503
1490
  onAuthComplete(true, response);
1504
1491
  return [2 /*return*/, true];
@@ -1714,6 +1701,7 @@ var ADLoginModal = function (_a) {
1714
1701
  username: credentials.username,
1715
1702
  password: credentials.password,
1716
1703
  MFACode: code,
1704
+ appCode: "",
1717
1705
  })];
1718
1706
  case 2:
1719
1707
  _a.sent();
@@ -1739,13 +1727,13 @@ var ADLoginModal = function (_a) {
1739
1727
  form.reset();
1740
1728
  setMfaCode("");
1741
1729
  };
1742
- return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: handleClose, children: jsxRuntime.jsxs(DialogContent, { className: "min-w-[50vw] max-w-[70vw]", children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntime.jsx(DialogTitle, { className: "text-2xl", children: "Sign in with AD" })] }) }), step === "credentials" ? (jsxRuntime.jsx(Form, __assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleCredentialsSubmit), className: "space-y-4", children: [jsxRuntime.jsx(FormField, { control: form.control, name: "username", render: function (_a) {
1730
+ return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: handleClose, children: jsxRuntime.jsxs(DialogContent, { className: "min-w-[50vw] max-w-[70vw]", children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [jsxRuntime.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntime.jsx(DialogTitle, { className: "text-xl", children: "Sign in with AD Credentials" })] }) }), step === "credentials" ? (jsxRuntime.jsx(Form, __assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleCredentialsSubmit), className: "space-y-6", children: [jsxRuntime.jsx(FormField, { control: form.control, name: "username", render: function (_a) {
1743
1731
  var field = _a.field;
1744
1732
  return (jsxRuntime.jsxs(FormItem, { children: [jsxRuntime.jsx(FormLabel, { children: "Username" }), jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx(Input, __assign({ className: "h-12", placeholder: "Enter your username" }, field)) }), jsxRuntime.jsx(FormMessage, {})] }));
1745
1733
  } }), jsxRuntime.jsx(FormField, { control: form.control, name: "password", render: function (_a) {
1746
1734
  var field = _a.field;
1747
1735
  return (jsxRuntime.jsxs(FormItem, { children: [jsxRuntime.jsx(FormLabel, { children: "Password" }), jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx(Input, __assign({ className: "h-12", type: "password", placeholder: "Enter your password" }, field)) }), jsxRuntime.jsx(FormMessage, {})] }));
1748
- } }), jsxRuntime.jsx(Button, { type: "submit", className: "w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxRuntime.jsxs("div", { className: "space-y-4", children: [jsxRuntime.jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsxRuntime.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }), jsxRuntime.jsx("span", { children: "Verifying..." })] }))] }))] }) }));
1736
+ } }), jsxRuntime.jsx(Button, { type: "submit", className: "py-3 w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxRuntime.jsxs("div", { className: "space-y-4", children: [jsxRuntime.jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsxRuntime.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }), jsxRuntime.jsx("span", { children: "Verifying..." })] }))] }))] }) }));
1749
1737
  };
1750
1738
 
1751
1739
  var DefaultLoginPage = function (_a) {
@@ -1784,6 +1772,9 @@ var DefaultLoginPage = function (_a) {
1784
1772
  },
1785
1773
  });
1786
1774
  }
1775
+ else {
1776
+ sonner.toast.error("\u274C AD Login failed. ".concat((data === null || data === void 0 ? void 0 : data.message) || 'Unknown error'));
1777
+ }
1787
1778
  return [2 /*return*/];
1788
1779
  });
1789
1780
  }); }), handleSubmitCredentials = _d.handleSubmitCredentials, isCredAuthLoading = _d.loading, setIsCredAuthLoading = _d.setLoading;
@@ -1800,7 +1791,7 @@ var DefaultLoginPage = function (_a) {
1800
1791
  console.warn("Regular CAMS login requires configuration");
1801
1792
  }
1802
1793
  };
1803
- return (jsxRuntime.jsxs("main", { className: "cams-sdk min-h-screen bg-gray-50", children: [jsxRuntime.jsx(framerMotion.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.5 }, children: jsxRuntime.jsx("div", { className: "flex h-screen items-center justify-center", children: jsxRuntime.jsxs(framerMotion.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: [jsxRuntime.jsxs(CardHeader, { className: "text-center space-y-3", children: [jsxRuntime.jsx("div", { className: "w-full flex items-center justify-center", children: jsxRuntime.jsx("img", { src: NIBSSLogo, alt: "NIBSS Logo", width: 265, height: 265 }) }), jsxRuntime.jsx(CardTitle, { className: "text-3xl font-bold", children: "NIBSS CAMS" }), jsxRuntime.jsx(CardTitle, { className: "text-gray-500 dark:text-gray-400 font-bold text-lg", children: "Centralized Authentication" })] }), jsxRuntime.jsxs(CardAction, { className: "w-full flex flex-col items-center justify-center text-center text-gray-500 dark:text-gray-400 mb-8", children: [jsxRuntime.jsx("img", { src: AuthLogo, alt: "Auth Logo", width: 365, height: 365 }), "Use Below Identity Providers To Authenticate"] }), jsxRuntime.jsxs("div", { className: "space-y-4", children: [jsxRuntime.jsxs(Button
1794
+ return (jsxRuntime.jsxs("main", { className: "cams-sdk min-h-screen bg-gray-50", children: [jsxRuntime.jsx(framerMotion.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.5 }, children: jsxRuntime.jsx("div", { className: "flex h-screen items-center justify-center", children: jsxRuntime.jsxs(framerMotion.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: [jsxRuntime.jsxs(CardHeader, { className: "text-center space-y-3", children: [jsxRuntime.jsx("div", { className: "w-full flex items-center justify-center", children: jsxRuntime.jsx("img", { src: NIBSSLogo, alt: "NIBSS Logo", width: 225, height: 225 }) }), jsxRuntime.jsx(CardTitle, { className: "text-3xl font-bold", children: "NIBSS CAMS" }), jsxRuntime.jsx(CardTitle, { className: "text-gray-500 dark:text-gray-400 font-bold text-lg", children: "Centralized Authentication" })] }), jsxRuntime.jsxs(CardAction, { className: "w-full flex flex-col items-center justify-center text-center text-gray-500 dark:text-gray-400 mb-8", children: [jsxRuntime.jsx("img", { src: AuthLogo, alt: "Auth Logo", width: 365, height: 365 }), "Use Below Identity Providers To Authenticate"] }), jsxRuntime.jsxs("div", { className: "space-y-4", children: [jsxRuntime.jsxs(Button
1804
1795
  // variant="outline"
1805
1796
  , {
1806
1797
  // variant="outline"
@@ -1814,7 +1805,7 @@ var DefaultLoginPage = function (_a) {
1814
1805
  return __generator$1(this, function (_c) {
1815
1806
  // Implement your AD login logic here
1816
1807
  console.log("AD Login:", { username: username, MFACode: MFACode });
1817
- handleSubmitCredentials(CredentialsAuthEndpoint !== null && CredentialsAuthEndpoint !== void 0 ? CredentialsAuthEndpoint : "/api/auth/validate", { username: username, password: password, MFACode: MFACode }, context.appCode);
1808
+ handleSubmitCredentials(CredentialsAuthEndpoint, { username: username, password: password, MFACode: MFACode, appCode: context.appCode });
1818
1809
  return [2 /*return*/];
1819
1810
  });
1820
1811
  }); } })] }));