@nibssplc/cams-sdk-react 1.0.0-rc.73 → 1.0.0-rc.75

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
@@ -485,12 +485,6 @@ function useCAMSMSALAuth(options) {
485
485
  })];
486
486
  case 2:
487
487
  response = _b.sent();
488
- console.log("Login Token response:", {
489
- accessToken: response.accessToken,
490
- idToken: response.idToken,
491
- });
492
- setAccessToken(response.accessToken);
493
- setIdToken(response.idToken);
494
488
  mfaConfig = {
495
489
  accessToken: response.accessToken,
496
490
  idToken: response.idToken,
@@ -501,9 +495,11 @@ function useCAMSMSALAuth(options) {
501
495
  return [4 /*yield*/, authenticator.GetUserMFAConfig(mfaConfig)];
502
496
  case 3:
503
497
  userConfig = _b.sent();
504
- Logger.info("MFA Authenticator initialized:", userConfig);
498
+ Logger.debug("MFA Authenticator initialized:", userConfig);
505
499
  // Don't persist as authenticated until MFA is complete
506
500
  if (typeof window !== "undefined" && userConfig.isValid) {
501
+ setAccessToken(response.accessToken);
502
+ setIdToken(response.idToken);
507
503
  localStorage.setItem(storageKey, JSON.stringify({
508
504
  isAuthenticated: false,
509
505
  requiresMFA: userConfig.userInfo.isMFAEnabled,
@@ -1019,8 +1015,8 @@ function CAMSProviderCore(props) {
1019
1015
  var value = useMemo(function () {
1020
1016
  auth.logout; var authRest = __rest(auth, ["logout"]);
1021
1017
  return __assign(__assign({}, authRest), { logout: enhancedLogout, user: userProfile, setUserProfile: setUserProfile, authMode: mode, onAuthSuccess: mode === "MSAL"
1022
- ? props.onAuthSuccess
1023
- : undefined, onAuthError: mode === "MSAL" ? props.onAuthError : undefined });
1018
+ ? (props).onAuthSuccess
1019
+ : undefined, onAuthError: mode === "MSAL" ? (props).onAuthError : undefined });
1024
1020
  }, [auth, userProfile, mode, props]);
1025
1021
  return jsx(CAMSContext.Provider, { value: value, children: children });
1026
1022
  }
@@ -1786,13 +1782,14 @@ var MFAEndpointsSchema = z$1.object({
1786
1782
  AuthChallengeVerify: z$1.url("MFA AuthChallengeVerify must be a valid URL"),
1787
1783
  });
1788
1784
  var MFAGate = function (_a) {
1789
- var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsx("div", { className: "h-screen flex items-center justify-center", children: jsx(LoadingSpinner, {}) })) : _b,
1785
+ var _b, _c, _d;
1786
+ var children = _a.children, _e = _a.fallback, fallback = _e === void 0 ? (jsx("div", { className: "h-screen flex items-center justify-center", children: jsx(LoadingSpinner, {}) })) : _e,
1790
1787
  // loginComponent: LoginComponent = DefaultLoginPage,
1791
- _c = _a.usePassKey,
1788
+ _f = _a.usePassKey,
1792
1789
  // loginComponent: LoginComponent = DefaultLoginPage,
1793
- usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
1790
+ usePassKey = _f === void 0 ? false : _f, _g = _a.useADLogin, useADLogin = _g === void 0 ? false : _g, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
1794
1791
  var context = useCAMSContext();
1795
- var _e = useState("Loading"), authState = _e[0], setAuthState = _e[1];
1792
+ var _h = useState("Loading"), authState = _h[0], setAuthState = _h[1];
1796
1793
  var validatedMFAEndpoints = useMemo(function () {
1797
1794
  var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
1798
1795
  if (!parsed.success) {
@@ -1836,6 +1833,11 @@ var MFAGate = function (_a) {
1836
1833
  }
1837
1834
  });
1838
1835
  }); }, [context, onAuthError]);
1836
+ Logger.debug("User context:", {
1837
+ user: context.user,
1838
+ profile: (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile,
1839
+ email: (_d = (_c = context.user) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.email,
1840
+ });
1839
1841
  useEffect(function () {
1840
1842
  if (context.isLoading) {
1841
1843
  setAuthState("Loading");
@@ -1847,12 +1849,6 @@ var MFAGate = function (_a) {
1847
1849
  }
1848
1850
  // Small delay to ensure all context updates are processed
1849
1851
  var timer = setTimeout(function () {
1850
- var _a, _b, _c;
1851
- Logger.debug("User context:", {
1852
- user: context.user,
1853
- profile: (_a = context.user) === null || _a === void 0 ? void 0 : _a.profile,
1854
- email: (_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email,
1855
- });
1856
1852
  var shouldRequireMFA = requiresMFA !== null && requiresMFA !== void 0 ? requiresMFA : ("requiresMFA" in context ? context.requiresMFA : false);
1857
1853
  var accessToken = "accessToken" in context ? context.accessToken : "";
1858
1854
  if (shouldRequireMFA && accessToken) {