@nibssplc/cams-sdk-react 0.0.1-beta.77 → 0.0.1-beta.78

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.
@@ -3,5 +3,5 @@ interface MFAOptionsProps {
3
3
  onAuthFailed?: () => void;
4
4
  MFAEndpoint?: string;
5
5
  }
6
- declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoint }?: MFAOptionsProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoint, }?: MFAOptionsProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default MFAOptions;
package/dist/index.cjs.js CHANGED
@@ -1706,7 +1706,7 @@ var useOTPHandler = function (_a) {
1706
1706
  });
1707
1707
  }
1708
1708
  else {
1709
- onAuthComplete(false, response);
1709
+ onAuthComplete(false, response.response.data);
1710
1710
  }
1711
1711
  return [2 /*return*/, false];
1712
1712
  }
@@ -1716,12 +1716,12 @@ var useOTPHandler = function (_a) {
1716
1716
  currentAttempt = attemptCount + 1;
1717
1717
  if (currentAttempt >= MAX_ATTEMPTS) {
1718
1718
  setIsMaxAttemptsReached(true);
1719
- onAuthComplete(false, error_1);
1719
+ onAuthComplete(false, error_1.response.data);
1720
1720
  }
1721
1721
  else {
1722
- onAuthComplete(false, error_1);
1722
+ onAuthComplete(false, error_1.response.data);
1723
1723
  }
1724
- onAuthComplete(false, error_1);
1724
+ onAuthComplete(false, error_1.response.data);
1725
1725
  return [2 /*return*/, false];
1726
1726
  case 4:
1727
1727
  setLoading(false);
@@ -1759,16 +1759,15 @@ var MFAOptions = function (_a) {
1759
1759
  var _d = React.useState(false), otpVisible = _d[0], setOtpVisible = _d[1];
1760
1760
  var _e = React.useState(false), showSuccessAnimation = _e[0], setShowSuccessAnimation = _e[1];
1761
1761
  var _f = React.useState(null), authType = _f[0], setAuthType = _f[1];
1762
- var _g = React.useState(""); _g[0]; var setLastOTPCode = _g[1];
1763
1762
  var context = useCAMSContext$1();
1764
- var _h = context.authMode === "MSAL" && "sendEmailOTP" in context
1763
+ var _g = context.authMode === "MSAL" && "sendEmailOTP" in context
1765
1764
  ? context
1766
1765
  : { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
1767
1766
  return [2 /*return*/];
1768
- }); }); } }, sendEmailOTP = _h.sendEmailOTP, completeMFA = _h.completeMFA, logout = _h.logout;
1767
+ }); }); } }, sendEmailOTP = _g.sendEmailOTP, completeMFA = _g.completeMFA, logout = _g.logout;
1769
1768
  var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
1770
1769
  var idToken = context.authMode === "MSAL" ? context.idToken : "";
1771
- var _j = useOTPHandler({
1770
+ var _h = useOTPHandler({
1772
1771
  accessToken: accessToken || "",
1773
1772
  idToken: idToken || "",
1774
1773
  provider: "MSAL",
@@ -1786,11 +1785,11 @@ var MFAOptions = function (_a) {
1786
1785
  });
1787
1786
  }
1788
1787
  setShowSuccessAnimation(true);
1789
- sonner.toast.success(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: "Multi-Factor Authentication Successful" })] }));
1788
+ sonner.toast.success(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
1790
1789
  setTimeout(function () { return onComplete === null || onComplete === void 0 ? void 0 : onComplete(true); }, 2000);
1791
1790
  }
1792
1791
  else {
1793
- sonner.toast.error(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldClose, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Invalid code. Please try again." })] }));
1792
+ sonner.toast.error(jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsxRuntimeExports.jsx(lucideReact.ShieldClose, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
1794
1793
  if (isMaxAttemptsReached) {
1795
1794
  setTimeout(function () {
1796
1795
  logout().then(function () {
@@ -1801,7 +1800,7 @@ var MFAOptions = function (_a) {
1801
1800
  }
1802
1801
  }
1803
1802
  },
1804
- }), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading, setLoading = _j.setLoading, attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
1803
+ }), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading, setLoading = _h.setLoading, attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
1805
1804
  var handleGoBack = function () {
1806
1805
  setAuthType(null);
1807
1806
  setOtpVisible(false);
@@ -1848,16 +1847,10 @@ var MFAOptions = function (_a) {
1848
1847
  setAuthType(null);
1849
1848
  setOtpVisible(false);
1850
1849
  setValue("");
1851
- }, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Email OTP" }) }), jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) {
1852
- setLastOTPCode(code);
1853
- return handleSubmitOTP(code);
1854
- }, fieldName: "EmailOTP", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] })] }) }));
1850
+ }, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Email OTP" }) }), jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "EmailOTP", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] })] }) }));
1855
1851
  }
1856
1852
  else if (authType === "AuthenticatorCode") {
1857
- content = (jsxRuntimeExports.jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsxRuntimeExports.jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsxRuntimeExports.jsx(LoadingSpinner, {}) })) : (jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(CardDescription, { className: "text-sm text-gray-600 text-center", children: "Enter the 6-digit Code from your Authenticator app" }), jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) {
1858
- setLastOTPCode(code);
1859
- return handleSubmitOTP(code);
1860
- }, fieldName: "AuthenticatorCode", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] }))] }) }));
1853
+ content = (jsxRuntimeExports.jsx(Dialog, { open: otpVisible, onOpenChange: handleGoBack, children: jsxRuntimeExports.jsxs(DialogContent, { className: "space-y-2 w-[425px] max-w-[80%]", children: [jsxRuntimeExports.jsx("div", { className: "absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-lime-400 to-emerald-600" }), jsxRuntimeExports.jsx(DialogHeader, { className: "w-full", children: jsxRuntimeExports.jsx(DialogTitle, { className: "text-center", children: "Authenticator App" }) }), loading ? (jsxRuntimeExports.jsx("div", { className: "p-3 h-full flex justify-center items-center", children: jsxRuntimeExports.jsx(LoadingSpinner, {}) })) : (jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [jsxRuntimeExports.jsx(CardDescription, { className: "text-sm text-gray-600 text-center", children: "Enter the 6-digit Code from your Authenticator app" }), jsxRuntimeExports.jsx(GenericOTPVerifier, { value: value, setValue: setValue, isDisabled: loading || isMaxAttemptsReached, onChangeOTP: function (code) { return handleSubmitOTP(code); }, fieldName: "AuthenticatorCode", attemptCount: attemptCount, remainingAttempts: remainingAttempts, isMaxAttemptsReached: isMaxAttemptsReached }), jsxRuntimeExports.jsx(Button, { variant: "ghost", className: "w-full text-sm", onClick: handleGoBack, children: "\u2190 Choose different method" })] }))] }) }));
1861
1854
  }
1862
1855
  return (jsxRuntimeExports.jsx("div", { className: "flex justify-center items-center h-dvh", children: jsxRuntimeExports.jsxs(Card, { className: "space-y-6 p-6 rounded-lg shadow-md", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx("div", { className: "flex justify-center items", children: jsxRuntimeExports.jsx("img", { src: OTPAuthenticationImg, alt: "NIBSS Logo", width: 365, height: 365 }) }), jsxRuntimeExports.jsx(CardTitle, { className: "text-3xl font-bold mb-6 text-center", children: "Two-Factor Authentication" }), jsxRuntimeExports.jsx(CardTitle, { className: "text-gray-300 text-base -tracking-wide text-center", children: "Your Microsoft account has been validated. Please complete two-factor authentication to continue." })] }), jsxRuntimeExports.jsx(CardContent, { children: content }), jsxRuntimeExports.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntimeExports.jsx(lucideReact.ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }));
1863
1856
  };