@nibssplc/cams-sdk-react 1.0.0-rc.124 → 1.0.0-rc.126

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.esm.js CHANGED
@@ -929,14 +929,16 @@ function CAMSProviderCore(props) {
929
929
  }
930
930
  });
931
931
  }); };
932
+ var onAuthSuccessCallback = mode === "MSAL" ? props.onAuthSuccess : undefined;
933
+ var onAuthErrorCallback = mode === "MSAL" ? props.onAuthError : undefined;
932
934
  var value = useMemo(function () {
933
935
  auth.logout; var authRest = __rest(auth, ["logout"]);
934
936
  var baseValue = __assign(__assign({}, authRest), { logout: enhancedLogout, user: userProfile, setUserProfile: setUserProfileWithCookie, authMode: mode });
935
937
  if (mode === "MSAL") {
936
- return __assign(__assign({}, baseValue), { onAuthSuccess: props.onAuthSuccess, onAuthError: props.onAuthError });
938
+ return __assign(__assign({}, baseValue), { onAuthSuccess: onAuthSuccessCallback, onAuthError: onAuthErrorCallback });
937
939
  }
938
940
  return baseValue;
939
- }, [auth, userProfile, mode, props, enhancedLogout]);
941
+ }, [auth, userProfile, mode, onAuthSuccessCallback, onAuthErrorCallback, enhancedLogout]);
940
942
  return jsx(CAMSContext.Provider, { value: value, children: children });
941
943
  }
942
944
  function UnifiedCAMSProvider(props) {
@@ -1296,7 +1298,7 @@ var LoadingScreen = function (_a) {
1296
1298
 
1297
1299
  var AuthSuccessAnimation = function (_a) {
1298
1300
  var onComplete = _a.onComplete;
1299
- return (jsxs(motion.div, { initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut" }, className: "flex flex-col items-center justify-center space-y-6 p-8", onAnimationComplete: onComplete, children: [jsx(motion.div, { initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.2, duration: 0.6, type: "spring", stiffness: 200 }, children: jsx(CheckCircle, { className: "w-20 h-20 text-green-500" }) }), jsxs(motion.div, { initial: { y: 20, opacity: 0 }, animate: { y: 0, opacity: 1 }, transition: { delay: 0.4, duration: 0.5 }, className: "text-center space-y-2", children: [jsx("h2", { className: "text-2xl font-bold text-green-600", children: "Authentication Successful!" }), jsx("p", { className: "text-gray-600", children: "Redirecting you to the application..." })] }), jsx(motion.div, { initial: { width: 0 }, animate: { width: "100%" }, transition: { delay: 0.8, duration: 2 }, className: "h-1 bg-green-500 rounded-full max-w-xs" })] }));
1301
+ return (jsxs(motion.div, { initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut" }, className: "flex flex-col items-center justify-center space-y-6 p-8", onAnimationComplete: onComplete, children: [jsx(motion.div, { initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.2, duration: 0.6, type: "spring", stiffness: 200 }, children: jsx(CheckCircle, { className: "w-20 h-20 text-green-500" }) }), jsxs(motion.div, { initial: { y: 20, opacity: 0 }, animate: { y: 0, opacity: 1 }, transition: { delay: 0.4, duration: 0.5 }, className: "text-center space-y-2", children: [jsx("h2", { className: "text-2xl font-bold text-green-600", children: "Authentication Successful!" }), jsx("p", { className: "text-gray-600", children: "Redirecting you to the application..." })] }), jsx(motion.div, { initial: { width: 0 }, animate: { width: "100%" }, transition: { delay: 0.8, duration: 0.8 }, className: "h-1 bg-green-500 rounded-full max-w-xs", onAnimationComplete: onComplete })] }));
1300
1302
  };
1301
1303
 
1302
1304
  var MAX_ATTEMPTS = 3;
@@ -1491,6 +1493,7 @@ var MFAOptions = function (_a) {
1491
1493
  context.setUserProfile(userProfile);
1492
1494
  toast.success(jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded-lg", children: [jsx(ShieldCheck, { className: "w-4 h-4" }), jsxs("span", { children: ["Multi-Factor Authentication Successful. ", data === null || data === void 0 ? void 0 : data.message] })] }));
1493
1495
  setShowSuccessAnimation(true);
1496
+ setTimeout(function () { return onComplete(true); }, 1000);
1494
1497
  return [3 /*break*/, 3];
1495
1498
  case 2:
1496
1499
  toast.error(jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600 bg-red-50 p-3 rounded-lg", children: [jsx(ShieldClose, { className: "w-4 h-4" }), jsx("span", { children: (data === null || data === void 0 ? void 0 : data.message) || "Unable to Validate User. Please try again." })] }));
@@ -1753,6 +1756,7 @@ var MFAGate = function (_a) {
1753
1756
  Logger.info("MFA Authentication Successful");
1754
1757
  setAuthState("Authenticated");
1755
1758
  var tokens = { accessToken: accessToken, idToken: idToken };
1759
+ console.log("[MFAGate] Calling onAuthSuccess callbacks", { tokens: tokens, hasLocalCallback: !!onAuthSuccess, hasContextCallback: "onAuthSuccess" in context && !!context.onAuthSuccess });
1756
1760
  onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens);
1757
1761
  if ("onAuthSuccess" in context) {
1758
1762
  (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);