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

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,7 +1482,7 @@ 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
1488
  // .then((data) => {
@@ -1714,6 +1714,7 @@ var ADLoginModal = function (_a) {
1714
1714
  username: credentials.username,
1715
1715
  password: credentials.password,
1716
1716
  MFACode: code,
1717
+ appCode: "",
1717
1718
  })];
1718
1719
  case 2:
1719
1720
  _a.sent();
@@ -1739,13 +1740,13 @@ var ADLoginModal = function (_a) {
1739
1740
  form.reset();
1740
1741
  setMfaCode("");
1741
1742
  };
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) {
1743
+ 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
1744
  var field = _a.field;
1744
1745
  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
1746
  } }), jsxRuntime.jsx(FormField, { control: form.control, name: "password", render: function (_a) {
1746
1747
  var field = _a.field;
1747
1748
  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..." })] }))] }))] }) }));
1749
+ } }), 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
1750
  };
1750
1751
 
1751
1752
  var DefaultLoginPage = function (_a) {
@@ -1800,7 +1801,7 @@ var DefaultLoginPage = function (_a) {
1800
1801
  console.warn("Regular CAMS login requires configuration");
1801
1802
  }
1802
1803
  };
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
1804
+ 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
1805
  // variant="outline"
1805
1806
  , {
1806
1807
  // variant="outline"
@@ -1814,7 +1815,7 @@ var DefaultLoginPage = function (_a) {
1814
1815
  return __generator$1(this, function (_c) {
1815
1816
  // Implement your AD login logic here
1816
1817
  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);
1818
+ handleSubmitCredentials(CredentialsAuthEndpoint, { username: username, password: password, MFACode: MFACode, appCode: context.appCode });
1818
1819
  return [2 /*return*/];
1819
1820
  });
1820
1821
  }); } })] }));