@insforge/react 0.7.0 → 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/atoms.cjs.map +1 -1
- package/dist/atoms.js.map +1 -1
- 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/forms.cjs.map +1 -1
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +52 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +52 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,13 @@ interface InsforgeProviderProps {
|
|
|
34
34
|
* @internal - Not intended for public use, used by Next.js package
|
|
35
35
|
*/
|
|
36
36
|
initialState?: InitialAuthState;
|
|
37
|
+
/**
|
|
38
|
+
* Internal use only - enables hosted auth mode for centralized auth pages.
|
|
39
|
+
* When true, disables automatic redirects to prevent security issues.
|
|
40
|
+
* @internal - Never set to true in user applications
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
hostedMode?: boolean;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -73,7 +80,7 @@ interface InsforgeProviderProps {
|
|
|
73
80
|
* </InsforgeProvider>
|
|
74
81
|
* ```
|
|
75
82
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, hostedMode, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
84
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
85
|
/**
|
|
79
86
|
* Hook to access Insforge context
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,13 @@ interface InsforgeProviderProps {
|
|
|
34
34
|
* @internal - Not intended for public use, used by Next.js package
|
|
35
35
|
*/
|
|
36
36
|
initialState?: InitialAuthState;
|
|
37
|
+
/**
|
|
38
|
+
* Internal use only - enables hosted auth mode for centralized auth pages.
|
|
39
|
+
* When true, disables automatic redirects to prevent security issues.
|
|
40
|
+
* @internal - Never set to true in user applications
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
hostedMode?: boolean;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -73,7 +80,7 @@ interface InsforgeProviderProps {
|
|
|
73
80
|
* </InsforgeProvider>
|
|
74
81
|
* ```
|
|
75
82
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, hostedMode, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
84
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
85
|
/**
|
|
79
86
|
* Hook to access Insforge context
|
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,20 +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
|
+
});
|
|
490
|
+
if (this.config.hostedMode) {
|
|
491
|
+
console.log("[InsforgeManager] \u{1F6AB} BLOCKED: hostedMode is enabled, skipping redirect");
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
467
494
|
if (!isLoaded || this.hasProcessedCallbackRef) {
|
|
495
|
+
console.log("[InsforgeManager] \u{1F6AB} BLOCKED: isLoaded=", isLoaded, "hasProcessedCallback=", this.hasProcessedCallbackRef);
|
|
468
496
|
return false;
|
|
469
497
|
}
|
|
470
498
|
if (user && this.config.afterSignInUrl) {
|
|
471
499
|
const currentPath = window.location.pathname + window.location.search;
|
|
472
500
|
const targetPath = this.config.afterSignInUrl;
|
|
501
|
+
console.log("[InsforgeManager] Checking redirect conditions:", {
|
|
502
|
+
currentPath,
|
|
503
|
+
targetPath,
|
|
504
|
+
shouldRedirect: currentPath !== targetPath
|
|
505
|
+
});
|
|
473
506
|
if (currentPath !== targetPath && !this.hasProcessedCallbackRef) {
|
|
474
507
|
this.hasProcessedCallbackRef = true;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return true;
|
|
508
|
+
console.log("[InsforgeManager] \u{1F504} REDIRECTING to:", targetPath);
|
|
509
|
+
console.log("[InsforgeManager] \u26A0\uFE0F REDIRECT BLOCKED FOR DEBUGGING");
|
|
510
|
+
return false;
|
|
479
511
|
}
|
|
480
512
|
}
|
|
513
|
+
console.log("[InsforgeManager] No redirect performed");
|
|
481
514
|
return false;
|
|
482
515
|
}
|
|
483
516
|
// Cleanup
|
|
@@ -507,7 +540,8 @@ function InsforgeProviderCore({
|
|
|
507
540
|
onAuthChange,
|
|
508
541
|
onSignIn,
|
|
509
542
|
onSignOut,
|
|
510
|
-
initialState
|
|
543
|
+
initialState,
|
|
544
|
+
hostedMode = false
|
|
511
545
|
}) {
|
|
512
546
|
const manager = useMemo(
|
|
513
547
|
() => InsforgeManager.getInstance({
|
|
@@ -515,9 +549,10 @@ function InsforgeProviderCore({
|
|
|
515
549
|
afterSignInUrl,
|
|
516
550
|
onAuthChange,
|
|
517
551
|
onSignIn,
|
|
518
|
-
onSignOut
|
|
552
|
+
onSignOut,
|
|
553
|
+
hostedMode
|
|
519
554
|
}),
|
|
520
|
-
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut]
|
|
555
|
+
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, hostedMode]
|
|
521
556
|
);
|
|
522
557
|
if (initialState) {
|
|
523
558
|
const currentState = manager.getState();
|
|
@@ -2208,13 +2243,22 @@ function SignIn({ onError, ...uiProps }) {
|
|
|
2208
2243
|
throw new Error(result.error);
|
|
2209
2244
|
}
|
|
2210
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
|
+
});
|
|
2211
2254
|
if (user) {
|
|
2212
2255
|
const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
|
|
2213
2256
|
finalUrl.searchParams.set("access_token", accessToken);
|
|
2214
2257
|
finalUrl.searchParams.set("user_id", user.id);
|
|
2215
2258
|
finalUrl.searchParams.set("email", user.email);
|
|
2216
2259
|
finalUrl.searchParams.set("name", user.name);
|
|
2217
|
-
|
|
2260
|
+
console.log("[SignIn] \u{1F504} About to redirect to:", finalUrl.toString());
|
|
2261
|
+
console.log("[SignIn] \u26A0\uFE0F REDIRECT BLOCKED FOR DEBUGGING");
|
|
2218
2262
|
}
|
|
2219
2263
|
} catch (err) {
|
|
2220
2264
|
const errorMessage = err instanceof Error ? err.message : "Sign in failed";
|