@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.
- package/dist/components/MFAOptions.d.ts +1 -1
- package/dist/index.cjs.js +12 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1686,7 +1686,7 @@ var useOTPHandler = function (_a) {
|
|
|
1686
1686
|
});
|
|
1687
1687
|
}
|
|
1688
1688
|
else {
|
|
1689
|
-
onAuthComplete(false, response);
|
|
1689
|
+
onAuthComplete(false, response.response.data);
|
|
1690
1690
|
}
|
|
1691
1691
|
return [2 /*return*/, false];
|
|
1692
1692
|
}
|
|
@@ -1696,12 +1696,12 @@ var useOTPHandler = function (_a) {
|
|
|
1696
1696
|
currentAttempt = attemptCount + 1;
|
|
1697
1697
|
if (currentAttempt >= MAX_ATTEMPTS) {
|
|
1698
1698
|
setIsMaxAttemptsReached(true);
|
|
1699
|
-
onAuthComplete(false, error_1);
|
|
1699
|
+
onAuthComplete(false, error_1.response.data);
|
|
1700
1700
|
}
|
|
1701
1701
|
else {
|
|
1702
|
-
onAuthComplete(false, error_1);
|
|
1702
|
+
onAuthComplete(false, error_1.response.data);
|
|
1703
1703
|
}
|
|
1704
|
-
onAuthComplete(false, error_1);
|
|
1704
|
+
onAuthComplete(false, error_1.response.data);
|
|
1705
1705
|
return [2 /*return*/, false];
|
|
1706
1706
|
case 4:
|
|
1707
1707
|
setLoading(false);
|
|
@@ -1739,16 +1739,15 @@ var MFAOptions = function (_a) {
|
|
|
1739
1739
|
var _d = useState(false), otpVisible = _d[0], setOtpVisible = _d[1];
|
|
1740
1740
|
var _e = useState(false), showSuccessAnimation = _e[0], setShowSuccessAnimation = _e[1];
|
|
1741
1741
|
var _f = useState(null), authType = _f[0], setAuthType = _f[1];
|
|
1742
|
-
var _g = useState(""); _g[0]; var setLastOTPCode = _g[1];
|
|
1743
1742
|
var context = useCAMSContext$1();
|
|
1744
|
-
var
|
|
1743
|
+
var _g = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1745
1744
|
? context
|
|
1746
1745
|
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
1747
1746
|
return [2 /*return*/];
|
|
1748
|
-
}); }); } }, sendEmailOTP =
|
|
1747
|
+
}); }); } }, sendEmailOTP = _g.sendEmailOTP, completeMFA = _g.completeMFA, logout = _g.logout;
|
|
1749
1748
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1750
1749
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1751
|
-
var
|
|
1750
|
+
var _h = useOTPHandler({
|
|
1752
1751
|
accessToken: accessToken || "",
|
|
1753
1752
|
idToken: idToken || "",
|
|
1754
1753
|
provider: "MSAL",
|
|
@@ -1766,11 +1765,11 @@ var MFAOptions = function (_a) {
|
|
|
1766
1765
|
});
|
|
1767
1766
|
}
|
|
1768
1767
|
setShowSuccessAnimation(true);
|
|
1769
|
-
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(ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.
|
|
1768
|
+
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(ShieldCheck, { className: "w-4 h-4" }), jsxRuntimeExports.jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
|
|
1770
1769
|
setTimeout(function () { return onComplete === null || onComplete === void 0 ? void 0 : onComplete(true); }, 2000);
|
|
1771
1770
|
}
|
|
1772
1771
|
else {
|
|
1773
|
-
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(ShieldClose, { className: "w-4 h-4" }), jsxRuntimeExports.jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "
|
|
1772
|
+
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(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." })] }));
|
|
1774
1773
|
if (isMaxAttemptsReached) {
|
|
1775
1774
|
setTimeout(function () {
|
|
1776
1775
|
logout().then(function () {
|
|
@@ -1781,7 +1780,7 @@ var MFAOptions = function (_a) {
|
|
|
1781
1780
|
}
|
|
1782
1781
|
}
|
|
1783
1782
|
},
|
|
1784
|
-
}), handleSubmitOTP =
|
|
1783
|
+
}), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading, setLoading = _h.setLoading, attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
|
|
1785
1784
|
var handleGoBack = function () {
|
|
1786
1785
|
setAuthType(null);
|
|
1787
1786
|
setOtpVisible(false);
|
|
@@ -1828,16 +1827,10 @@ var MFAOptions = function (_a) {
|
|
|
1828
1827
|
setAuthType(null);
|
|
1829
1828
|
setOtpVisible(false);
|
|
1830
1829
|
setValue("");
|
|
1831
|
-
}, 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) {
|
|
1832
|
-
setLastOTPCode(code);
|
|
1833
|
-
return handleSubmitOTP(code);
|
|
1834
|
-
}, 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" })] })] }) }));
|
|
1830
|
+
}, 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" })] })] }) }));
|
|
1835
1831
|
}
|
|
1836
1832
|
else if (authType === "AuthenticatorCode") {
|
|
1837
|
-
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) {
|
|
1838
|
-
setLastOTPCode(code);
|
|
1839
|
-
return handleSubmitOTP(code);
|
|
1840
|
-
}, 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" })] }))] }) }));
|
|
1833
|
+
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" })] }))] }) }));
|
|
1841
1834
|
}
|
|
1842
1835
|
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(ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }));
|
|
1843
1836
|
};
|