@nibssplc/cams-sdk-react 0.0.1-beta.90 → 0.0.1-beta.92

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.
@@ -1,2 +1,7 @@
1
- declare const DefaultLoginPage: () => import("react/jsx-runtime").JSX.Element;
1
+ import { MFAEndpoints } from "./MFAGate";
2
+ interface LoginPageProps {
3
+ usePassKey?: boolean;
4
+ MFAEndpoints: MFAEndpoints;
5
+ }
6
+ declare const DefaultLoginPage: ({ usePassKey, MFAEndpoints }: LoginPageProps) => import("react/jsx-runtime").JSX.Element;
2
7
  export default DefaultLoginPage;
@@ -1,7 +1,17 @@
1
+ import z from "zod";
2
+ declare const MFAEndpointsSchema: z.ZodObject<{
3
+ ValidateMFA: z.ZodURL;
4
+ RegisterNewChallenge: z.ZodURL;
5
+ RegisterVerify: z.ZodURL;
6
+ RetrieveAuthChallenge: z.ZodURL;
7
+ AuthChallengeVerify: z.ZodURL;
8
+ }, z.core.$strip>;
9
+ export type MFAEndpoints = z.infer<typeof MFAEndpointsSchema>;
1
10
  interface MFAGateProps {
2
11
  children: React.ReactNode;
3
12
  fallback?: React.ReactNode;
4
- MFAEndpoint?: string;
13
+ usePassKey?: boolean;
14
+ MFAEndpoints?: MFAEndpoints;
5
15
  }
6
- declare const MFAGate: ({ children, fallback, MFAEndpoint, }: 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;
16
+ declare const MFAGate: ({ children, fallback, usePassKey, 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
17
  export default MFAGate;
@@ -1,7 +1,9 @@
1
+ import { MFAEndpoints } from "./MFAGate";
1
2
  interface MFAOptionsProps {
2
3
  onComplete?: (success: boolean) => void;
3
4
  onAuthFailed?: () => void;
4
- MFAEndpoint?: string;
5
+ MFAEndpoints: MFAEndpoints;
6
+ usePassKey?: boolean;
5
7
  }
6
- declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoint, }?: MFAOptionsProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoints, usePassKey, }: MFAOptionsProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default MFAOptions;
package/dist/index.cjs.js CHANGED
@@ -1849,26 +1849,61 @@ var useOTPHandler = function (_a) {
1849
1849
  };
1850
1850
 
1851
1851
  var MFAOptions = function (_a) {
1852
- var _b = _a === void 0 ? {} : _a, onComplete = _b.onComplete, onAuthFailed = _b.onAuthFailed, MFAEndpoint = _b.MFAEndpoint;
1853
- var _c = React.useState(""), value = _c[0], setValue = _c[1];
1854
- var _d = React.useState(false), otpVisible = _d[0], setOtpVisible = _d[1];
1855
- var _e = React.useState(false), showSuccessAnimation = _e[0], setShowSuccessAnimation = _e[1];
1856
- var _f = React.useState(null), authType = _f[0], setAuthType = _f[1];
1852
+ var onComplete = _a.onComplete, onAuthFailed = _a.onAuthFailed, MFAEndpoints = _a.MFAEndpoints, usePassKey = _a.usePassKey;
1853
+ var _b = React.useState(""), value = _b[0], setValue = _b[1];
1854
+ var _c = React.useState(false), otpVisible = _c[0], setOtpVisible = _c[1];
1855
+ var _d = React.useState(false), showSuccessAnimation = _d[0], setShowSuccessAnimation = _d[1];
1856
+ var _e = React.useState(null), authType = _e[0], setAuthType = _e[1];
1857
1857
  var context = useCAMSContext();
1858
- var _g = context.authMode === "MSAL" && "sendEmailOTP" in context
1858
+ var _f = context.authMode === "MSAL" && "sendEmailOTP" in context
1859
1859
  ? context
1860
1860
  : { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
1861
1861
  return [2 /*return*/];
1862
- }); }); } }, sendEmailOTP = _g.sendEmailOTP, completeMFA = _g.completeMFA, logout = _g.logout;
1862
+ }); }); } }, sendEmailOTP = _f.sendEmailOTP, completeMFA = _f.completeMFA, logout = _f.logout;
1863
1863
  var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
1864
1864
  var idToken = context.authMode === "MSAL" ? context.idToken : "";
1865
- var _h = useOTPHandler({
1865
+ var authenticate = useWebAuthn().authenticate;
1866
+ var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
1867
+ var options, assertionResponse, error_1;
1868
+ return __generator(this, function (_a) {
1869
+ switch (_a.label) {
1870
+ case 0:
1871
+ _a.trys.push([0, 4, , 5]);
1872
+ // 1. Fetch authentication challenge from your server
1873
+ console.log("Requesting authentication challenge from server...");
1874
+ return [4 /*yield*/, axios.get(MFAEndpoints.RetrieveAuthChallenge)];
1875
+ case 1:
1876
+ options = (_a.sent()).data;
1877
+ console.log("Received challenge:", options);
1878
+ // 2. Call the SDK to trigger the browser's passkey authentication UI
1879
+ console.log("Calling SDK authenticate function...");
1880
+ return [4 /*yield*/, authenticate(options)];
1881
+ case 2:
1882
+ assertionResponse = _a.sent();
1883
+ console.log("Authentication assertion received from client:", assertionResponse);
1884
+ // 3. Send the assertion back to the server for verification
1885
+ console.log("Sending assertion to server for verification...");
1886
+ return [4 /*yield*/, axios.post("/api/webauthn/auth-verify", assertionResponse)];
1887
+ case 3:
1888
+ _a.sent();
1889
+ sonner.toast.success("🔑 Sign-in successful!");
1890
+ return [3 /*break*/, 5];
1891
+ case 4:
1892
+ error_1 = _a.sent();
1893
+ console.error("Authentication failed:", error_1);
1894
+ sonner.toast.error("❌ Could not sign in.");
1895
+ return [3 /*break*/, 5];
1896
+ case 5: return [2 /*return*/];
1897
+ }
1898
+ });
1899
+ }); };
1900
+ var _g = useOTPHandler({
1866
1901
  accessToken: accessToken || "",
1867
1902
  idToken: idToken || "",
1868
1903
  provider: "MSAL",
1869
1904
  appCode: context.appCode || "",
1870
1905
  authenticationType: authType,
1871
- MFAEndpoint: MFAEndpoint,
1906
+ MFAEndpoint: MFAEndpoints.ValidateMFA,
1872
1907
  onAuthComplete: function (state, data) {
1873
1908
  console.log("Completed Auth. Handling MFA", state);
1874
1909
  if (state) {
@@ -1895,7 +1930,7 @@ var MFAOptions = function (_a) {
1895
1930
  }
1896
1931
  }
1897
1932
  },
1898
- }), handleSubmitOTP = _h.handleSubmitOTP, loading = _h.loading, setLoading = _h.setLoading, attemptCount = _h.attemptCount, remainingAttempts = _h.remainingAttempts, isMaxAttemptsReached = _h.isMaxAttemptsReached, resetAttempts = _h.resetAttempts;
1933
+ }), handleSubmitOTP = _g.handleSubmitOTP, loading = _g.loading, setLoading = _g.setLoading, attemptCount = _g.attemptCount, remainingAttempts = _g.remainingAttempts, isMaxAttemptsReached = _g.isMaxAttemptsReached, resetAttempts = _g.resetAttempts;
1899
1934
  var handleGoBack = function () {
1900
1935
  setAuthType(null);
1901
1936
  setOtpVisible(false);
@@ -1935,7 +1970,13 @@ var MFAOptions = function (_a) {
1935
1970
  resetAttempts();
1936
1971
  setAuthType("AuthenticatorCode");
1937
1972
  setOtpVisible(true);
1938
- }, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftAuthenticatorImg, alt: "Authenticator", className: "rounded-full", width: 24, height: 24, onError: function () { return jsxRuntimeExports.jsx(lucideReact.Shield, {}); } }), jsxRuntimeExports.jsxs("div", { className: "text-left", children: [jsxRuntimeExports.jsx("div", { className: "font-medium", children: "Authenticator App" }), jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-500", children: "Use Authenticator App" })] })] })] })] }));
1973
+ }, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftAuthenticatorImg, alt: "Authenticator", className: "rounded-full", width: 24, height: 24, onError: function () { return jsxRuntimeExports.jsx(lucideReact.Shield, {}); } }), jsxRuntimeExports.jsxs("div", { className: "text-left", children: [jsxRuntimeExports.jsx("div", { className: "font-medium", children: "Authenticator App" }), jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-500", children: "Use Authenticator App" })] })] }), usePassKey && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full flex items-center justify-start gap-3 p-4 h-auto border-2 hover:border-[#506f4a] hover:bg-[#506f4a]/5 transition-all",
1974
+ // onClick={() => {
1975
+ // resetAttempts();
1976
+ // setAuthType("AuthenticatorCode");
1977
+ // setOtpVisible(true);
1978
+ // }}
1979
+ onClick: handleFIDOLogin, disabled: context.isLoading, children: [jsxRuntimeExports.jsx(Button, { 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", children: jsxRuntimeExports.jsx("span", { children: "Sign In " }) }), jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-16 h-16 text-[#506f4a]" }), jsxRuntimeExports.jsxs("div", { className: "text-left", children: [jsxRuntimeExports.jsx("div", { className: "font-medium", children: "Continue with Passkey" }), jsxRuntimeExports.jsx("div", { className: "text-sm text-gray-500", children: "Passkey" })] })] }))] })] }));
1939
1980
  }
1940
1981
  else if (authType === "EmailOTP") {
1941
1982
  content = (jsxRuntimeExports.jsx(Dialog, { open: otpVisible, onOpenChange: function () {
@@ -2033,11 +2074,12 @@ var ADLoginModal = function (_a) {
2033
2074
  } }), jsxRuntimeExports.jsx(Button, { type: "submit", className: "w-full bg-[#506f4a] hover:bg-[#506f4a]/90", children: "Continue" })] }) }))) : (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsx(GenericOTPVerifier, { value: mfaCode, setValue: setMfaCode, setLoading: setIsLoading, isDisabled: isLoading, onChangeOTP: handleMFASubmit, fieldName: "AuthenticatorCode" }), isLoading && (jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }), jsxRuntimeExports.jsx("span", { children: "Verifying..." })] }))] }))] }) }));
2034
2075
  };
2035
2076
 
2036
- var DefaultLoginPage = function () {
2077
+ var DefaultLoginPage = function (_a) {
2078
+ var usePassKey = _a.usePassKey, MFAEndpoints = _a.MFAEndpoints;
2037
2079
  var context = useCAMSContext();
2038
2080
  var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
2039
- var _a = React.useState(false), showADModal = _a[0], setShowADModal = _a[1];
2040
- var _b = useWebAuthn(), register = _b.register, authenticate = _b.authenticate;
2081
+ var _b = React.useState(false), showADModal = _b[0], setShowADModal = _b[1];
2082
+ var register = useWebAuthn().register;
2041
2083
  var handleMSALLogin = function () {
2042
2084
  if (authMode === "MSAL") {
2043
2085
  login();
@@ -2058,84 +2100,39 @@ var DefaultLoginPage = function () {
2058
2100
  exit: { opacity: 0, scale: 0.8, y: -50, transition: { duration: 0.3 } },
2059
2101
  };
2060
2102
  var handleRegister = function () { return __awaiter(void 0, void 0, void 0, function () {
2061
- var res, options, attestationResponse, error_1;
2103
+ var options, attestationResponse, error_1;
2062
2104
  return __generator(this, function (_a) {
2063
2105
  switch (_a.label) {
2064
2106
  case 0:
2065
- _a.trys.push([0, 5, , 6]);
2107
+ _a.trys.push([0, 4, , 5]);
2066
2108
  // 1. Fetch challenge from your server
2067
2109
  console.log("Requesting registration challenge from server...");
2068
- return [4 /*yield*/, fetch("/api/webauthn/register-challenge")];
2110
+ return [4 /*yield*/, axios.get(MFAEndpoints.RegisterNewChallenge)];
2069
2111
  case 1:
2070
- res = _a.sent();
2071
- return [4 /*yield*/, res.json()];
2072
- case 2:
2073
- options = _a.sent();
2112
+ options = (_a.sent()).data;
2074
2113
  console.log("Received challenge:", options);
2075
2114
  // 2. Call the SDK to trigger the browser's passkey creation UI
2076
2115
  console.log("Calling SDK register function...");
2077
2116
  return [4 /*yield*/, register(options)];
2078
- case 3:
2117
+ case 2:
2079
2118
  attestationResponse = _a.sent();
2080
2119
  console.log("Passkey created on client:", attestationResponse);
2081
2120
  // 3. Send the response back to the server for verification
2082
2121
  console.log("Sending attestation to server for verification...");
2083
- return [4 /*yield*/, fetch("/api/webauthn/register-verify", {
2084
- method: "POST",
2122
+ return [4 /*yield*/, axios.post(MFAEndpoints.RegisterVerify, attestationResponse, {
2085
2123
  headers: { "Content-Type": "application/json" },
2086
- body: JSON.stringify(attestationResponse),
2124
+ withCredentials: true, // credentials: 'include'
2087
2125
  })];
2088
- case 4:
2126
+ case 3:
2089
2127
  _a.sent();
2090
- alert("✅ Registration successful! Passkey created.");
2091
- return [3 /*break*/, 6];
2092
- case 5:
2128
+ sonner.toast.success("✅ Registration successful! Passkey created.");
2129
+ return [3 /*break*/, 5];
2130
+ case 4:
2093
2131
  error_1 = _a.sent();
2094
2132
  console.error("Registration failed:", error_1);
2095
- alert("❌ Could not create passkey.");
2096
- return [3 /*break*/, 6];
2097
- case 6: return [2 /*return*/];
2098
- }
2099
- });
2100
- }); };
2101
- var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
2102
- var res, options, assertionResponse, error_2;
2103
- return __generator(this, function (_a) {
2104
- switch (_a.label) {
2105
- case 0:
2106
- _a.trys.push([0, 5, , 6]);
2107
- // 1. Fetch authentication challenge from your server
2108
- console.log("Requesting authentication challenge from server...");
2109
- return [4 /*yield*/, fetch("/api/webauthn/auth-challenge")];
2110
- case 1:
2111
- res = _a.sent();
2112
- return [4 /*yield*/, res.json()];
2113
- case 2:
2114
- options = _a.sent();
2115
- console.log("Received challenge:", options);
2116
- // 2. Call the SDK to trigger the browser's passkey authentication UI
2117
- console.log("Calling SDK authenticate function...");
2118
- return [4 /*yield*/, authenticate(options)];
2119
- case 3:
2120
- assertionResponse = _a.sent();
2121
- console.log("Authentication assertion received from client:", assertionResponse);
2122
- // 3. Send the assertion back to the server for verification
2123
- console.log("Sending assertion to server for verification...");
2124
- return [4 /*yield*/, fetch("/api/webauthn/auth-verify", {
2125
- method: "POST",
2126
- headers: { "Content-Type": "application/json" },
2127
- body: JSON.stringify(assertionResponse),
2128
- })];
2129
- case 4:
2130
- _a.sent();
2131
- alert("🔑 Sign-in successful!");
2132
- return [3 /*break*/, 6];
2133
- case 5:
2134
- error_2 = _a.sent();
2135
- console.error("Authentication failed:", error_2);
2136
- alert("❌ Could not sign in.");
2137
- return [3 /*break*/, 6];
2138
- case 6: return [2 /*return*/];
2133
+ sonner.toast.error("❌ Could not create passkey.");
2134
+ return [3 /*break*/, 5];
2135
+ case 5: return [2 /*return*/];
2139
2136
  }
2140
2137
  });
2141
2138
  }); };
@@ -2143,19 +2140,7 @@ var DefaultLoginPage = function () {
2143
2140
  // variant="outline"
2144
2141
  , {
2145
2142
  // variant="outline"
2146
- 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: handleMSALLogin, disabled: isLoading, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntimeExports.jsx("span", { children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), jsxRuntimeExports.jsxs(Button
2147
- // variant="outline"
2148
- , {
2149
- // variant="outline"
2150
- 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: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntimeExports.jsx("span", { children: isLoading ? "Logging in..." : "Sign in with ActiveDirectory" })] }), jsxRuntimeExports.jsxs(Button
2151
- // variant="outline"
2152
- , {
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: function () { return 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
- // variant="outline"
2156
- , {
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: function () { return 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) {
2143
+ 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: handleMSALLogin, disabled: isLoading, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntimeExports.jsx("span", { className: "ml-2", children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), jsxRuntimeExports.jsxs(Button, { 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: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(lucideReact.KeyIcon, { className: "w-8 h-8 text-[#506f4a]" }), jsxRuntimeExports.jsx("span", { children: isLoading ? "Logging in..." : "Sign in with ActiveDirectory" })] }), usePassKey && (jsxRuntimeExports.jsxs(Button, { 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-12 h-12 text-[#506f4a]" }), jsxRuntimeExports.jsx("span", { children: "Create a 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
2144
  var username = _b.username, password = _b.password, MFACode = _b.MFACode;
2160
2145
  return __generator(this, function (_c) {
2161
2146
  // Implement your AD login logic here
@@ -2170,20 +2155,28 @@ var ErrorFallback = function (_a) {
2170
2155
  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
2156
  };
2172
2157
 
2173
- var MFAEndpointUrlSchema = z.url("MFAEndpoint must be a valid URL");
2158
+ var MFAEndpointsSchema = z.object({
2159
+ ValidateMFA: z.url("MFAEndpoint must be a valid URL"),
2160
+ RegisterNewChallenge: z.url("MFA RegisterNewChallenge must be a valid URL"),
2161
+ RegisterVerify: z.url("MFA RegisterVerify must be a valid URL"),
2162
+ RetrieveAuthChallenge: z.url("MFA RetrieveAuthChallenge must be a valid URL"),
2163
+ AuthChallengeVerify: z.url("MFA AuthChallengeVerify must be a valid URL"),
2164
+ });
2174
2165
  var MFAGate = function (_a) {
2175
2166
  var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? jsxRuntimeExports.jsx(LoadingSpinner, {}) : _b,
2176
2167
  // loginComponent: LoginComponent = DefaultLoginPage,
2177
- MFAEndpoint = _a.MFAEndpoint;
2168
+ _c = _a.usePassKey,
2169
+ // loginComponent: LoginComponent = DefaultLoginPage,
2170
+ usePassKey = _c === void 0 ? false : _c, MFAEndpoints = _a.MFAEndpoints;
2178
2171
  var context = useCAMSContext();
2179
- var validatedMFAEndpoint = React.useMemo(function () {
2180
- var parsed = MFAEndpointUrlSchema.safeParse(MFAEndpoint);
2172
+ var validatedMFAEndpoints = React.useMemo(function () {
2173
+ var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
2181
2174
  if (!parsed.success) {
2182
2175
  camsSdk.Logger.error("Invalid MFAEndpoint", parsed.error);
2183
2176
  return null;
2184
2177
  }
2185
2178
  return parsed.data;
2186
- }, [MFAEndpoint]);
2179
+ }, [MFAEndpoints]);
2187
2180
  var handleComplete = React.useCallback(function (success) {
2188
2181
  if (!success)
2189
2182
  camsSdk.Logger.error("MFA authentication failed");
@@ -2198,18 +2191,18 @@ var MFAGate = function (_a) {
2198
2191
  }
2199
2192
  });
2200
2193
  }); }, [context.logout]);
2201
- camsSdk.Logger.debug("MFA Endpoint >>>", { MFAEndpoint: MFAEndpoint });
2202
- if (!validatedMFAEndpoint)
2194
+ camsSdk.Logger.debug("MFA Endpoint >>>", { MFAEndpoints: MFAEndpoints });
2195
+ if (!validatedMFAEndpoints)
2203
2196
  return jsxRuntimeExports.jsx(ErrorFallback, { message: "Invalid MFA configuration." });
2204
2197
  if (context.authMode !== "MSAL")
2205
2198
  return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
2206
2199
  if (context.isLoading)
2207
2200
  return fallback;
2208
2201
  if (context.requiresMFA) {
2209
- return (jsxRuntimeExports.jsx(MFAOptions, { MFAEndpoint: validatedMFAEndpoint, onComplete: handleComplete, onAuthFailed: handleAuthFailed }));
2202
+ return (jsxRuntimeExports.jsx(MFAOptions, { MFAEndpoints: validatedMFAEndpoints, usePassKey: usePassKey, onComplete: handleComplete, onAuthFailed: handleAuthFailed }));
2210
2203
  }
2211
2204
  if (!context.isAuthenticated) {
2212
- return jsxRuntimeExports.jsx(DefaultLoginPage, {});
2205
+ return jsxRuntimeExports.jsx(DefaultLoginPage, { usePassKey: usePassKey, MFAEndpoints: MFAEndpoints });
2213
2206
  }
2214
2207
  return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
2215
2208
  };