@insforge/react 0.7.1 → 0.7.2

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 CHANGED
@@ -116,22 +116,36 @@ var InsforgeManager = class _InsforgeManager {
116
116
  // Public initialization method
117
117
  // Even if we have initialState (isLoaded=true from cookies), we still need to load full user data from SDK/API
118
118
  async initialize() {
119
+ console.log("[InsforgeManager] initialize() called", {
120
+ isInitializing: this.isInitializing,
121
+ currentUser: this.user?.id || "none",
122
+ isLoaded: this.isLoaded,
123
+ hostedMode: this.config.hostedMode
124
+ });
119
125
  if (this.isInitializing) {
126
+ console.log("[InsforgeManager] Already initializing, skipping");
120
127
  return;
121
128
  }
122
129
  this.isInitializing = true;
123
130
  try {
124
131
  const sessionResult = this.sdk.auth.getCurrentSession();
125
132
  const hasToken = !!sessionResult.data?.session?.accessToken;
133
+ console.log("[InsforgeManager] Session check:", {
134
+ hasToken,
135
+ tokenPreview: hasToken ? sessionResult.data?.session?.accessToken?.substring(0, 20) + "..." : "none"
136
+ });
126
137
  if (hasToken) {
138
+ console.log("[InsforgeManager] Token found, loading auth state...");
127
139
  await this.loadAuthState();
128
140
  } else if (this.user === void 0) {
141
+ console.log("[InsforgeManager] No token and no initialState, marking as loaded with no user");
129
142
  this.user = null;
130
143
  this.isLoaded = true;
131
144
  this.notifyListeners();
132
145
  }
133
146
  } finally {
134
147
  this.isInitializing = false;
148
+ console.log("[InsforgeManager] initialize() completed");
135
149
  }
136
150
  }
137
151
  // Get current state
@@ -471,23 +485,39 @@ var InsforgeManager = class _InsforgeManager {
471
485
  // Handle auth redirect after successful authentication
472
486
  // Works for all auth sources: OAuth providers, cloud hosting sign-in, email verification
473
487
  handleAuthRedirect(isLoaded, user) {
488
+ console.log("[InsforgeManager] handleAuthRedirect called:", {
489
+ isLoaded,
490
+ hasUser: !!user,
491
+ userId: user?.id,
492
+ hostedMode: this.config.hostedMode,
493
+ afterSignInUrl: this.config.afterSignInUrl,
494
+ hasProcessedCallback: this.hasProcessedCallbackRef,
495
+ currentPath: typeof window !== "undefined" ? window.location.pathname : "SSR"
496
+ });
474
497
  if (this.config.hostedMode) {
498
+ console.log("[InsforgeManager] \u{1F6AB} BLOCKED: hostedMode is enabled, skipping redirect");
475
499
  return false;
476
500
  }
477
501
  if (!isLoaded || this.hasProcessedCallbackRef) {
502
+ console.log("[InsforgeManager] \u{1F6AB} BLOCKED: isLoaded=", isLoaded, "hasProcessedCallback=", this.hasProcessedCallbackRef);
478
503
  return false;
479
504
  }
480
505
  if (user && this.config.afterSignInUrl) {
481
506
  const currentPath = window.location.pathname + window.location.search;
482
507
  const targetPath = this.config.afterSignInUrl;
508
+ console.log("[InsforgeManager] Checking redirect conditions:", {
509
+ currentPath,
510
+ targetPath,
511
+ shouldRedirect: currentPath !== targetPath
512
+ });
483
513
  if (currentPath !== targetPath && !this.hasProcessedCallbackRef) {
484
514
  this.hasProcessedCallbackRef = true;
485
- setTimeout(() => {
486
- window.location.href = targetPath;
487
- }, 100);
488
- return true;
515
+ console.log("[InsforgeManager] \u{1F504} REDIRECTING to:", targetPath);
516
+ console.log("[InsforgeManager] \u26A0\uFE0F REDIRECT BLOCKED FOR DEBUGGING");
517
+ return false;
489
518
  }
490
519
  }
520
+ console.log("[InsforgeManager] No redirect performed");
491
521
  return false;
492
522
  }
493
523
  // Cleanup
@@ -2220,13 +2250,22 @@ function SignIn({ onError, ...uiProps }) {
2220
2250
  throw new Error(result.error);
2221
2251
  }
2222
2252
  const { user, accessToken, redirectTo } = result;
2253
+ console.log("[SignIn] Login success:", {
2254
+ hasUser: !!user,
2255
+ userId: user?.id,
2256
+ hasAccessToken: !!accessToken,
2257
+ redirectTo,
2258
+ redirectUrl,
2259
+ currentLocation: window.location.href
2260
+ });
2223
2261
  if (user) {
2224
2262
  const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
2225
2263
  finalUrl.searchParams.set("access_token", accessToken);
2226
2264
  finalUrl.searchParams.set("user_id", user.id);
2227
2265
  finalUrl.searchParams.set("email", user.email);
2228
2266
  finalUrl.searchParams.set("name", user.name);
2229
- window.location.href = finalUrl.toString();
2267
+ console.log("[SignIn] \u{1F504} About to redirect to:", finalUrl.toString());
2268
+ console.log("[SignIn] \u26A0\uFE0F REDIRECT BLOCKED FOR DEBUGGING");
2230
2269
  }
2231
2270
  } catch (err) {
2232
2271
  const errorMessage = err instanceof Error ? err.message : "Sign in failed";