@nibssplc/cams-sdk-react 0.0.1-beta.58 → 0.0.1-beta.59
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/ClientOnly.d.ts +2 -2
- package/dist/components/LoginButton.d.ts +2 -0
- package/dist/components/MFAGate.d.ts +2 -1
- package/dist/components/UnifiedCAMSProvider.d.ts +2 -1
- package/dist/index.cjs.js +23 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +23 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ export * from './components/ClientOnly';
|
|
|
7
7
|
export * from './components/UnifiedCAMSProvider';
|
|
8
8
|
export { default as MFAOptions } from './components/MFAOptions';
|
|
9
9
|
export { default as MFAGate } from './components/MFAGate';
|
|
10
|
+
export { default as LoginButton } from './components/LoginButton';
|
|
11
|
+
export { default as ClientOnly } from './components/ClientOnly';
|
|
10
12
|
export { useCAMSContext } from './context/CAMSContext';
|
|
11
13
|
export * from '@nibssplc/cams-sdk';
|
package/dist/index.esm.js
CHANGED
|
@@ -1082,7 +1082,7 @@ function useCAMSMSALContext() {
|
|
|
1082
1082
|
return context;
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
|
-
function
|
|
1085
|
+
var ClientOnly = function (_a) {
|
|
1086
1086
|
var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? null : _b;
|
|
1087
1087
|
var _c = useState(false), hasMounted = _c[0], setHasMounted = _c[1];
|
|
1088
1088
|
useEffect(function () {
|
|
@@ -1092,7 +1092,7 @@ function ClientOnly(_a) {
|
|
|
1092
1092
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: fallback });
|
|
1093
1093
|
}
|
|
1094
1094
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
1095
|
-
}
|
|
1095
|
+
};
|
|
1096
1096
|
|
|
1097
1097
|
var CAMSContext = createContext(null);
|
|
1098
1098
|
function useCAMSContext() {
|
|
@@ -1123,7 +1123,7 @@ var getCookie = function (name) {
|
|
|
1123
1123
|
var deleteCookie = function (name) {
|
|
1124
1124
|
document.cookie = name + "=; Max-Age=-99999999; path=/";
|
|
1125
1125
|
};
|
|
1126
|
-
function
|
|
1126
|
+
function CAMSProviderCore(props) {
|
|
1127
1127
|
var _this = this;
|
|
1128
1128
|
var _a = props, children = _a.children, mode = _a.mode, appCode = _a.appCode, validateTokenUrl = _a.validateTokenUrl;
|
|
1129
1129
|
// Always call both hooks to satisfy Rules of Hooks
|
|
@@ -1219,9 +1219,9 @@ function UnifiedCAMSProvider(props) {
|
|
|
1219
1219
|
if (props.mode === "MSAL") {
|
|
1220
1220
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1221
1221
|
var instance = msalInstance || new PublicClientApplication(msalConfig);
|
|
1222
|
-
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(
|
|
1222
|
+
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|
|
1223
1223
|
}
|
|
1224
|
-
return jsxRuntimeExports.jsx(
|
|
1224
|
+
return (jsxRuntimeExports.jsx(ClientOnly, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|
|
1225
1225
|
}
|
|
1226
1226
|
// Backward compatibility exports
|
|
1227
1227
|
var CAMSProvider = function (props) { return (jsxRuntimeExports.jsx(UnifiedCAMSProvider, __assign({}, props, { mode: "REGULAR" }))); };
|
|
@@ -1745,8 +1745,23 @@ var MFAOptions = function (_a) {
|
|
|
1745
1745
|
return (jsxRuntimeExports.jsxs(Card, { className: "mx-auto space-y-6 p-6 bg-white rounded-lg shadow-md", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx("img", { src: "/OTPAuthentication1.svg", 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-sm -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" })] })] }));
|
|
1746
1746
|
};
|
|
1747
1747
|
|
|
1748
|
+
var LoginButton = function () {
|
|
1749
|
+
var context = useCAMSContext();
|
|
1750
|
+
var login = context.login, isLoading = context.isLoading, error = context.error, authMode = context.authMode;
|
|
1751
|
+
var handleLogin = function () {
|
|
1752
|
+
if (authMode === "MSAL") {
|
|
1753
|
+
login();
|
|
1754
|
+
}
|
|
1755
|
+
else {
|
|
1756
|
+
// For regular mode, you'd need to provide CAMSConfig
|
|
1757
|
+
console.warn("Regular CAMS login requires configuration");
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
return (jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-4 p-6", children: [jsxRuntimeExports.jsx(Button, { onClick: handleLogin, disabled: isLoading, className: "min-w-[200px]", children: isLoading ? 'Logging in...' : 'Login with Microsoft' }), error && (jsxRuntimeExports.jsxs("p", { className: "text-red-600 text-sm text-center", children: ["Error: ", error.message] }))] }));
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1748
1763
|
var MFAGate = function (_a) {
|
|
1749
|
-
var children = _a.children, fallback = _a.fallback;
|
|
1764
|
+
var children = _a.children, fallback = _a.fallback, LoginComponent = _a.loginComponent;
|
|
1750
1765
|
var context = useCAMSContext();
|
|
1751
1766
|
// Only apply MFA gate for MSAL mode
|
|
1752
1767
|
if (context.authMode !== "MSAL") {
|
|
@@ -1764,10 +1779,10 @@ var MFAGate = function (_a) {
|
|
|
1764
1779
|
} }));
|
|
1765
1780
|
}
|
|
1766
1781
|
if (!isAuthenticated) {
|
|
1767
|
-
return fallback || jsxRuntimeExports.jsx(
|
|
1782
|
+
return fallback || (LoginComponent ? jsxRuntimeExports.jsx(LoginComponent, {}) : jsxRuntimeExports.jsx(LoginButton, {}));
|
|
1768
1783
|
}
|
|
1769
1784
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
1770
1785
|
};
|
|
1771
1786
|
|
|
1772
|
-
export { CAMSMSALProvider, CAMSProvider, ClientOnly, MFAGate, MFAOptions, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSContext, useCAMSMSALAuth, useCAMSMSALContext, useCAMSPopupAuth };
|
|
1787
|
+
export { CAMSMSALProvider, CAMSProvider, ClientOnly, LoginButton, MFAGate, MFAOptions, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSContext, useCAMSMSALAuth, useCAMSMSALContext, useCAMSPopupAuth };
|
|
1773
1788
|
//# sourceMappingURL=index.esm.js.map
|