@nibssplc/cams-sdk-react 1.0.0-rc.84 → 1.0.0-rc.85
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.cjs.js +23 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -22
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1535,29 +1535,22 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1535
1535
|
};
|
|
1536
1536
|
|
|
1537
1537
|
var MFAOptions = function (_a) {
|
|
1538
|
-
var _b, _c
|
|
1538
|
+
var _b, _c;
|
|
1539
1539
|
var onComplete = _a.onComplete, onAuthFailed = _a.onAuthFailed, MFAEndpoints = _a.MFAEndpoints, usePassKey = _a.usePassKey;
|
|
1540
|
-
var
|
|
1541
|
-
var
|
|
1542
|
-
var
|
|
1543
|
-
var
|
|
1540
|
+
var _d = useState(""), value = _d[0], setValue = _d[1];
|
|
1541
|
+
var _e = useState(false), otpVisible = _e[0], setOtpVisible = _e[1];
|
|
1542
|
+
var _f = useState(false), showSuccessAnimation = _f[0], setShowSuccessAnimation = _f[1];
|
|
1543
|
+
var _g = useState(null), authType = _g[0], setAuthType = _g[1];
|
|
1544
1544
|
var context = useCAMSContext();
|
|
1545
|
-
var
|
|
1545
|
+
var _h = context.authMode === "MSAL" && "AuthenticatorCode" in context
|
|
1546
1546
|
? context
|
|
1547
1547
|
: { completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1548
1548
|
return [2 /*return*/];
|
|
1549
|
-
}); }); } }, completeMFA =
|
|
1550
|
-
context.authMode === "MSAL" ? context.accessToken : "";
|
|
1551
|
-
context.authMode === "MSAL" ? context.idToken : "";
|
|
1549
|
+
}); }); } }, completeMFA = _h.completeMFA, logout = _h.logout;
|
|
1552
1550
|
var authenticate = useWebAuthn().authenticate;
|
|
1553
1551
|
var authenticator = new CAMSMFAAuthenticator();
|
|
1554
|
-
|
|
1555
|
-
user: context.
|
|
1556
|
-
profile: (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile,
|
|
1557
|
-
email: (_d = (_c = context.user) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.email,
|
|
1558
|
-
});
|
|
1559
|
-
var _m = useOTPHandler({
|
|
1560
|
-
email: ((_f = (_e = context.user) === null || _e === void 0 ? void 0 : _e.profile) === null || _f === void 0 ? void 0 : _f.email) || context.email,
|
|
1552
|
+
var _j = useOTPHandler({
|
|
1553
|
+
email: ((_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email) || context.email,
|
|
1561
1554
|
appCode: context.appCode || "",
|
|
1562
1555
|
MFAEndpoint: MFAEndpoints.ValidateUserMFA,
|
|
1563
1556
|
onAuthComplete: function (state, data) {
|
|
@@ -1586,7 +1579,7 @@ var MFAOptions = function (_a) {
|
|
|
1586
1579
|
}
|
|
1587
1580
|
}
|
|
1588
1581
|
},
|
|
1589
|
-
}), handleSubmitOTP =
|
|
1582
|
+
}), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading, attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
|
|
1590
1583
|
var handleGoBack = function () {
|
|
1591
1584
|
setAuthType(null);
|
|
1592
1585
|
setOtpVisible(false);
|
|
@@ -1727,20 +1720,20 @@ var DefaultLoginPage = function (_a) {
|
|
|
1727
1720
|
var context = useCAMSContext();
|
|
1728
1721
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
1729
1722
|
var _b = useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
1723
|
+
var _c = useState(false), showSuccessAnimation = _c[0], setShowSuccessAnimation = _c[1];
|
|
1730
1724
|
var register = useWebAuthn().register;
|
|
1731
1725
|
var authentication = new CAMSMFAAuthenticator();
|
|
1732
|
-
var
|
|
1726
|
+
var _d = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1733
1727
|
return __generator$1(this, function (_a) {
|
|
1734
1728
|
console.log(data);
|
|
1735
1729
|
if (state && data && data.isValid) {
|
|
1736
|
-
|
|
1730
|
+
setShowSuccessAnimation(true);
|
|
1737
1731
|
localStorage.setItem(context.storageKey, JSON.stringify({
|
|
1738
|
-
isAuthenticated:
|
|
1732
|
+
isAuthenticated: true,
|
|
1739
1733
|
requiresMFA: false,
|
|
1740
1734
|
accessToken: "Credentials",
|
|
1741
1735
|
idToken: "Credentials",
|
|
1742
1736
|
}));
|
|
1743
|
-
context.requiresMFA = false;
|
|
1744
1737
|
context.setUserProfile({
|
|
1745
1738
|
state: "AUTH_SUCCESS",
|
|
1746
1739
|
message: data.message,
|
|
@@ -1753,13 +1746,14 @@ var DefaultLoginPage = function (_a) {
|
|
|
1753
1746
|
tokens: data.tokens,
|
|
1754
1747
|
},
|
|
1755
1748
|
});
|
|
1749
|
+
setShowADModal(false);
|
|
1756
1750
|
}
|
|
1757
1751
|
else {
|
|
1758
1752
|
toast.error("\u274C AD Login failed. ".concat((data === null || data === void 0 ? void 0 : data.message) || "Unknown error"));
|
|
1759
1753
|
}
|
|
1760
1754
|
return [2 /*return*/];
|
|
1761
1755
|
});
|
|
1762
|
-
}); }), handleSubmitCredentials =
|
|
1756
|
+
}); }), handleSubmitCredentials = _d.handleSubmitCredentials, isCredAuthLoading = _d.loading, setIsCredAuthLoading = _d.setLoading;
|
|
1763
1757
|
var handleMSALLogin = function () {
|
|
1764
1758
|
if (typeof window !== "undefined" && !window.crypto) {
|
|
1765
1759
|
toast.error("Crypto API not available. Please use a modern browser.");
|
|
@@ -1773,6 +1767,11 @@ var DefaultLoginPage = function (_a) {
|
|
|
1773
1767
|
console.warn("Regular CAMS login requires configuration");
|
|
1774
1768
|
}
|
|
1775
1769
|
};
|
|
1770
|
+
if (showSuccessAnimation && useADLogin) {
|
|
1771
|
+
return (jsx("div", { className: "flex justify-center items-center h-dvh", children: jsx(Card, { className: "mx-auto space-y-6 p-6 bg-white rounded-lg shadow-md", children: jsx(AuthSuccessAnimation, { onComplete: function () {
|
|
1772
|
+
// Animation completed, can add additional logic here if needed
|
|
1773
|
+
} }) }) }));
|
|
1774
|
+
}
|
|
1776
1775
|
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
|
|
1777
1776
|
// variant="outline"
|
|
1778
1777
|
, {
|
|
@@ -1841,6 +1840,8 @@ var MFAGate = function (_a) {
|
|
|
1841
1840
|
(_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
|
|
1842
1841
|
}
|
|
1843
1842
|
}
|
|
1843
|
+
// Force state update after MFA completion
|
|
1844
|
+
setAuthState("Authenticated");
|
|
1844
1845
|
}
|
|
1845
1846
|
else if (!success) {
|
|
1846
1847
|
Logger.error("MFA authentication failed", { context: context || null });
|