@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.cjs.js
CHANGED
|
@@ -1556,29 +1556,22 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1556
1556
|
};
|
|
1557
1557
|
|
|
1558
1558
|
var MFAOptions = function (_a) {
|
|
1559
|
-
var _b, _c
|
|
1559
|
+
var _b, _c;
|
|
1560
1560
|
var onComplete = _a.onComplete, onAuthFailed = _a.onAuthFailed, MFAEndpoints = _a.MFAEndpoints, usePassKey = _a.usePassKey;
|
|
1561
|
-
var
|
|
1562
|
-
var
|
|
1563
|
-
var
|
|
1564
|
-
var
|
|
1561
|
+
var _d = React.useState(""), value = _d[0], setValue = _d[1];
|
|
1562
|
+
var _e = React.useState(false), otpVisible = _e[0], setOtpVisible = _e[1];
|
|
1563
|
+
var _f = React.useState(false), showSuccessAnimation = _f[0], setShowSuccessAnimation = _f[1];
|
|
1564
|
+
var _g = React.useState(null), authType = _g[0], setAuthType = _g[1];
|
|
1565
1565
|
var context = useCAMSContext();
|
|
1566
|
-
var
|
|
1566
|
+
var _h = context.authMode === "MSAL" && "AuthenticatorCode" in context
|
|
1567
1567
|
? context
|
|
1568
1568
|
: { completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1569
1569
|
return [2 /*return*/];
|
|
1570
|
-
}); }); } }, completeMFA =
|
|
1571
|
-
context.authMode === "MSAL" ? context.accessToken : "";
|
|
1572
|
-
context.authMode === "MSAL" ? context.idToken : "";
|
|
1570
|
+
}); }); } }, completeMFA = _h.completeMFA, logout = _h.logout;
|
|
1573
1571
|
var authenticate = useWebAuthn().authenticate;
|
|
1574
1572
|
var authenticator = new camsSdk.CAMSMFAAuthenticator();
|
|
1575
|
-
|
|
1576
|
-
user: context.
|
|
1577
|
-
profile: (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile,
|
|
1578
|
-
email: (_d = (_c = context.user) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.email,
|
|
1579
|
-
});
|
|
1580
|
-
var _m = useOTPHandler({
|
|
1581
|
-
email: ((_f = (_e = context.user) === null || _e === void 0 ? void 0 : _e.profile) === null || _f === void 0 ? void 0 : _f.email) || context.email,
|
|
1573
|
+
var _j = useOTPHandler({
|
|
1574
|
+
email: ((_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email) || context.email,
|
|
1582
1575
|
appCode: context.appCode || "",
|
|
1583
1576
|
MFAEndpoint: MFAEndpoints.ValidateUserMFA,
|
|
1584
1577
|
onAuthComplete: function (state, data) {
|
|
@@ -1607,7 +1600,7 @@ var MFAOptions = function (_a) {
|
|
|
1607
1600
|
}
|
|
1608
1601
|
}
|
|
1609
1602
|
},
|
|
1610
|
-
}), handleSubmitOTP =
|
|
1603
|
+
}), handleSubmitOTP = _j.handleSubmitOTP, loading = _j.loading, attemptCount = _j.attemptCount, remainingAttempts = _j.remainingAttempts, isMaxAttemptsReached = _j.isMaxAttemptsReached, resetAttempts = _j.resetAttempts;
|
|
1611
1604
|
var handleGoBack = function () {
|
|
1612
1605
|
setAuthType(null);
|
|
1613
1606
|
setOtpVisible(false);
|
|
@@ -1748,20 +1741,20 @@ var DefaultLoginPage = function (_a) {
|
|
|
1748
1741
|
var context = useCAMSContext();
|
|
1749
1742
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
1750
1743
|
var _b = React.useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
1744
|
+
var _c = React.useState(false), showSuccessAnimation = _c[0], setShowSuccessAnimation = _c[1];
|
|
1751
1745
|
var register = useWebAuthn().register;
|
|
1752
1746
|
var authentication = new camsSdk.CAMSMFAAuthenticator();
|
|
1753
|
-
var
|
|
1747
|
+
var _d = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1754
1748
|
return __generator$1(this, function (_a) {
|
|
1755
1749
|
console.log(data);
|
|
1756
1750
|
if (state && data && data.isValid) {
|
|
1757
|
-
|
|
1751
|
+
setShowSuccessAnimation(true);
|
|
1758
1752
|
localStorage.setItem(context.storageKey, JSON.stringify({
|
|
1759
|
-
isAuthenticated:
|
|
1753
|
+
isAuthenticated: true,
|
|
1760
1754
|
requiresMFA: false,
|
|
1761
1755
|
accessToken: "Credentials",
|
|
1762
1756
|
idToken: "Credentials",
|
|
1763
1757
|
}));
|
|
1764
|
-
context.requiresMFA = false;
|
|
1765
1758
|
context.setUserProfile({
|
|
1766
1759
|
state: "AUTH_SUCCESS",
|
|
1767
1760
|
message: data.message,
|
|
@@ -1774,13 +1767,14 @@ var DefaultLoginPage = function (_a) {
|
|
|
1774
1767
|
tokens: data.tokens,
|
|
1775
1768
|
},
|
|
1776
1769
|
});
|
|
1770
|
+
setShowADModal(false);
|
|
1777
1771
|
}
|
|
1778
1772
|
else {
|
|
1779
1773
|
sonner.toast.error("\u274C AD Login failed. ".concat((data === null || data === void 0 ? void 0 : data.message) || "Unknown error"));
|
|
1780
1774
|
}
|
|
1781
1775
|
return [2 /*return*/];
|
|
1782
1776
|
});
|
|
1783
|
-
}); }), handleSubmitCredentials =
|
|
1777
|
+
}); }), handleSubmitCredentials = _d.handleSubmitCredentials, isCredAuthLoading = _d.loading, setIsCredAuthLoading = _d.setLoading;
|
|
1784
1778
|
var handleMSALLogin = function () {
|
|
1785
1779
|
if (typeof window !== "undefined" && !window.crypto) {
|
|
1786
1780
|
sonner.toast.error("Crypto API not available. Please use a modern browser.");
|
|
@@ -1794,6 +1788,11 @@ var DefaultLoginPage = function (_a) {
|
|
|
1794
1788
|
console.warn("Regular CAMS login requires configuration");
|
|
1795
1789
|
}
|
|
1796
1790
|
};
|
|
1791
|
+
if (showSuccessAnimation && useADLogin) {
|
|
1792
|
+
return (jsxRuntime.jsx("div", { className: "flex justify-center items-center h-dvh", children: jsxRuntime.jsx(Card, { className: "mx-auto space-y-6 p-6 bg-white rounded-lg shadow-md", children: jsxRuntime.jsx(AuthSuccessAnimation, { onComplete: function () {
|
|
1793
|
+
// Animation completed, can add additional logic here if needed
|
|
1794
|
+
} }) }) }));
|
|
1795
|
+
}
|
|
1797
1796
|
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
|
|
1798
1797
|
// variant="outline"
|
|
1799
1798
|
, {
|
|
@@ -1862,6 +1861,8 @@ var MFAGate = function (_a) {
|
|
|
1862
1861
|
(_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
|
|
1863
1862
|
}
|
|
1864
1863
|
}
|
|
1864
|
+
// Force state update after MFA completion
|
|
1865
|
+
setAuthState("Authenticated");
|
|
1865
1866
|
}
|
|
1866
1867
|
else if (!success) {
|
|
1867
1868
|
camsSdk.Logger.error("MFA authentication failed", { context: context || null });
|