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