@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.cjs.js CHANGED
@@ -506,12 +506,6 @@ function useCAMSMSALAuth(options) {
506
506
  })];
507
507
  case 2:
508
508
  response = _b.sent();
509
- console.log("Login Token response:", {
510
- accessToken: response.accessToken,
511
- idToken: response.idToken,
512
- });
513
- setAccessToken(response.accessToken);
514
- setIdToken(response.idToken);
515
509
  mfaConfig = {
516
510
  accessToken: response.accessToken,
517
511
  idToken: response.idToken,
@@ -522,9 +516,11 @@ function useCAMSMSALAuth(options) {
522
516
  return [4 /*yield*/, authenticator.GetUserMFAConfig(mfaConfig)];
523
517
  case 3:
524
518
  userConfig = _b.sent();
525
- camsSdk.Logger.info("MFA Authenticator initialized:", userConfig);
519
+ camsSdk.Logger.debug("MFA Authenticator initialized:", userConfig);
526
520
  // Don't persist as authenticated until MFA is complete
527
521
  if (typeof window !== "undefined" && userConfig.isValid) {
522
+ setAccessToken(response.accessToken);
523
+ setIdToken(response.idToken);
528
524
  localStorage.setItem(storageKey, JSON.stringify({
529
525
  isAuthenticated: false,
530
526
  requiresMFA: userConfig.userInfo.isMFAEnabled,
@@ -1040,8 +1036,8 @@ function CAMSProviderCore(props) {
1040
1036
  var value = React.useMemo(function () {
1041
1037
  auth.logout; var authRest = __rest(auth, ["logout"]);
1042
1038
  return __assign(__assign({}, authRest), { logout: enhancedLogout, user: userProfile, setUserProfile: setUserProfile, authMode: mode, onAuthSuccess: mode === "MSAL"
1043
- ? props.onAuthSuccess
1044
- : undefined, onAuthError: mode === "MSAL" ? props.onAuthError : undefined });
1039
+ ? (props).onAuthSuccess
1040
+ : undefined, onAuthError: mode === "MSAL" ? (props).onAuthError : undefined });
1045
1041
  }, [auth, userProfile, mode, props]);
1046
1042
  return jsxRuntime.jsx(CAMSContext.Provider, { value: value, children: children });
1047
1043
  }
@@ -1807,13 +1803,14 @@ var MFAEndpointsSchema = z.object({
1807
1803
  AuthChallengeVerify: z.url("MFA AuthChallengeVerify must be a valid URL"),
1808
1804
  });
1809
1805
  var MFAGate = function (_a) {
1810
- var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingSpinner, {}) })) : _b,
1806
+ var _b, _c, _d;
1807
+ var children = _a.children, _e = _a.fallback, fallback = _e === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingSpinner, {}) })) : _e,
1811
1808
  // loginComponent: LoginComponent = DefaultLoginPage,
1812
- _c = _a.usePassKey,
1809
+ _f = _a.usePassKey,
1813
1810
  // loginComponent: LoginComponent = DefaultLoginPage,
1814
- 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;
1811
+ 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;
1815
1812
  var context = useCAMSContext();
1816
- var _e = React.useState("Loading"), authState = _e[0], setAuthState = _e[1];
1813
+ var _h = React.useState("Loading"), authState = _h[0], setAuthState = _h[1];
1817
1814
  var validatedMFAEndpoints = React.useMemo(function () {
1818
1815
  var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
1819
1816
  if (!parsed.success) {
@@ -1857,6 +1854,11 @@ var MFAGate = function (_a) {
1857
1854
  }
1858
1855
  });
1859
1856
  }); }, [context, onAuthError]);
1857
+ camsSdk.Logger.debug("User context:", {
1858
+ user: context.user,
1859
+ profile: (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile,
1860
+ email: (_d = (_c = context.user) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.email,
1861
+ });
1860
1862
  React.useEffect(function () {
1861
1863
  if (context.isLoading) {
1862
1864
  setAuthState("Loading");
@@ -1868,12 +1870,6 @@ var MFAGate = function (_a) {
1868
1870
  }
1869
1871
  // Small delay to ensure all context updates are processed
1870
1872
  var timer = setTimeout(function () {
1871
- var _a, _b, _c;
1872
- camsSdk.Logger.debug("User context:", {
1873
- user: context.user,
1874
- profile: (_a = context.user) === null || _a === void 0 ? void 0 : _a.profile,
1875
- email: (_c = (_b = context.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.email,
1876
- });
1877
1873
  var shouldRequireMFA = requiresMFA !== null && requiresMFA !== void 0 ? requiresMFA : ("requiresMFA" in context ? context.requiresMFA : false);
1878
1874
  var accessToken = "accessToken" in context ? context.accessToken : "";
1879
1875
  if (shouldRequireMFA && accessToken) {