@nibssplc/cams-sdk-react 0.0.1-beta.90 → 0.0.1-beta.91
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/MFAGate.d.ts +7 -2
- package/dist/index.cjs.js +12 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
declare const MFAEndpointsSchema: z.ZodObject<{
|
|
3
|
+
ValidateMFA: z.ZodURL;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type MFAEndpoints = z.infer<typeof MFAEndpointsSchema>;
|
|
1
6
|
interface MFAGateProps {
|
|
2
7
|
children: React.ReactNode;
|
|
3
8
|
fallback?: React.ReactNode;
|
|
4
|
-
|
|
9
|
+
MFAEndpoints?: MFAEndpoints;
|
|
5
10
|
}
|
|
6
|
-
declare const MFAGate: ({ children, fallback,
|
|
11
|
+
declare const MFAGate: ({ children, fallback, MFAEndpoints, }: MFAGateProps) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
|
|
7
12
|
export default MFAGate;
|
package/dist/index.cjs.js
CHANGED
|
@@ -2151,11 +2151,11 @@ var DefaultLoginPage = function () {
|
|
|
2151
2151
|
// variant="outline"
|
|
2152
2152
|
, {
|
|
2153
2153
|
// variant="outline"
|
|
2154
|
-
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick:
|
|
2154
|
+
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleRegister, disabled: isLoading, children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntimeExports.jsx("span", { children: "Create a Passkey" })] }), jsxRuntimeExports.jsxs(Button
|
|
2155
2155
|
// variant="outline"
|
|
2156
2156
|
, {
|
|
2157
2157
|
// variant="outline"
|
|
2158
|
-
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick:
|
|
2158
|
+
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleFIDOLogin, disabled: isLoading, children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntimeExports.jsx("span", { children: "Sign In with Passkey" })] })] }), 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" })] })] }) }) }, "landing"), jsxRuntimeExports.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, onLogin: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
2159
2159
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
2160
2160
|
return __generator(this, function (_c) {
|
|
2161
2161
|
// Implement your AD login logic here
|
|
@@ -2170,20 +2170,22 @@ var ErrorFallback = function (_a) {
|
|
|
2170
2170
|
return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center min-h-screen bg-gray-50", children: jsxRuntimeExports.jsxs("div", { className: "bg-white p-6 rounded-lg shadow-lg border border-red-200 max-w-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3 mb-2", children: [jsxRuntimeExports.jsx("svg", { className: "w-6 h-6 text-red-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }), jsxRuntimeExports.jsx("h2", { className: "text-lg font-semibold text-gray-900", children: "Configuration Error" })] }), jsxRuntimeExports.jsx("p", { className: "text-red-600", children: message })] }) }));
|
|
2171
2171
|
};
|
|
2172
2172
|
|
|
2173
|
-
var
|
|
2173
|
+
var MFAEndpointsSchema = z.object({
|
|
2174
|
+
ValidateMFA: z.url("MFAEndpoint must be a valid URL"),
|
|
2175
|
+
});
|
|
2174
2176
|
var MFAGate = function (_a) {
|
|
2175
2177
|
var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? jsxRuntimeExports.jsx(LoadingSpinner, {}) : _b,
|
|
2176
2178
|
// loginComponent: LoginComponent = DefaultLoginPage,
|
|
2177
|
-
|
|
2179
|
+
MFAEndpoints = _a.MFAEndpoints;
|
|
2178
2180
|
var context = useCAMSContext();
|
|
2179
|
-
var
|
|
2180
|
-
var parsed =
|
|
2181
|
+
var validatedMFAEndpoints = React.useMemo(function () {
|
|
2182
|
+
var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
|
|
2181
2183
|
if (!parsed.success) {
|
|
2182
2184
|
camsSdk.Logger.error("Invalid MFAEndpoint", parsed.error);
|
|
2183
2185
|
return null;
|
|
2184
2186
|
}
|
|
2185
2187
|
return parsed.data;
|
|
2186
|
-
}, [
|
|
2188
|
+
}, [MFAEndpoints]);
|
|
2187
2189
|
var handleComplete = React.useCallback(function (success) {
|
|
2188
2190
|
if (!success)
|
|
2189
2191
|
camsSdk.Logger.error("MFA authentication failed");
|
|
@@ -2198,15 +2200,15 @@ var MFAGate = function (_a) {
|
|
|
2198
2200
|
}
|
|
2199
2201
|
});
|
|
2200
2202
|
}); }, [context.logout]);
|
|
2201
|
-
camsSdk.Logger.debug("MFA Endpoint >>>", {
|
|
2202
|
-
if (!
|
|
2203
|
+
camsSdk.Logger.debug("MFA Endpoint >>>", { MFAEndpoints: MFAEndpoints });
|
|
2204
|
+
if (!validatedMFAEndpoints)
|
|
2203
2205
|
return jsxRuntimeExports.jsx(ErrorFallback, { message: "Invalid MFA configuration." });
|
|
2204
2206
|
if (context.authMode !== "MSAL")
|
|
2205
2207
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
2206
2208
|
if (context.isLoading)
|
|
2207
2209
|
return fallback;
|
|
2208
2210
|
if (context.requiresMFA) {
|
|
2209
|
-
return (jsxRuntimeExports.jsx(MFAOptions, { MFAEndpoint:
|
|
2211
|
+
return (jsxRuntimeExports.jsx(MFAOptions, { MFAEndpoint: validatedMFAEndpoints.ValidateMFA, onComplete: handleComplete, onAuthFailed: handleAuthFailed }));
|
|
2210
2212
|
}
|
|
2211
2213
|
if (!context.isAuthenticated) {
|
|
2212
2214
|
return jsxRuntimeExports.jsx(DefaultLoginPage, {});
|