@insforge/react 1.0.2-refresh.1 → 1.0.2-refresh.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.map +1 -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 +17 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +101 -101
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,7 @@ interface InsforgeProviderProps {
|
|
|
29
29
|
onAuthChange?: (user: InsforgeUser | null) => void;
|
|
30
30
|
onSignIn?: (authToken: string) => Promise<void>;
|
|
31
31
|
onSignOut?: () => Promise<void>;
|
|
32
|
+
onRefresh?: (authToken: string) => Promise<void>;
|
|
32
33
|
/**
|
|
33
34
|
* Initial auth state from server (for SSR hydration)
|
|
34
35
|
* @internal - Not intended for public use, used by Next.js package
|
|
@@ -73,7 +74,7 @@ interface InsforgeProviderProps {
|
|
|
73
74
|
* </InsforgeProvider>
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, onRefresh, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
78
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
79
|
/**
|
|
79
80
|
* Hook to access Insforge context
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ interface InsforgeProviderProps {
|
|
|
29
29
|
onAuthChange?: (user: InsforgeUser | null) => void;
|
|
30
30
|
onSignIn?: (authToken: string) => Promise<void>;
|
|
31
31
|
onSignOut?: () => Promise<void>;
|
|
32
|
+
onRefresh?: (authToken: string) => Promise<void>;
|
|
32
33
|
/**
|
|
33
34
|
* Initial auth state from server (for SSR hydration)
|
|
34
35
|
* @internal - Not intended for public use, used by Next.js package
|
|
@@ -73,7 +74,7 @@ interface InsforgeProviderProps {
|
|
|
73
74
|
* </InsforgeProvider>
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, onRefresh, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
78
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
79
|
/**
|
|
79
80
|
* Hook to access Insforge context
|
package/dist/index.js
CHANGED
|
@@ -556,9 +556,18 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
556
556
|
this.notifyListeners();
|
|
557
557
|
return { success: false, error: "no_session" };
|
|
558
558
|
}
|
|
559
|
+
if (this.config.onRefresh && session.accessToken) {
|
|
560
|
+
try {
|
|
561
|
+
await this.config.onRefresh(session.accessToken);
|
|
562
|
+
} catch (error) {
|
|
563
|
+
if (error instanceof Error) {
|
|
564
|
+
console.error("[InsforgeManager] Error syncing token on refresh:", error.message);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
559
568
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
560
569
|
if (userResult.data) {
|
|
561
|
-
const profile = userResult.data.profile;
|
|
570
|
+
const profile = userResult.data.user.profile;
|
|
562
571
|
const userData = {
|
|
563
572
|
id: userResult.data.user.id,
|
|
564
573
|
email: userResult.data.user.email,
|
|
@@ -600,7 +609,7 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
600
609
|
async handleAuthSuccess(authToken, fallbackUser) {
|
|
601
610
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
602
611
|
if (userResult.data) {
|
|
603
|
-
const profile = userResult.data.profile;
|
|
612
|
+
const profile = userResult.data.user.profile;
|
|
604
613
|
const userData = {
|
|
605
614
|
id: userResult.data.user.id,
|
|
606
615
|
email: userResult.data.user.email,
|
|
@@ -714,12 +723,12 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
714
723
|
if (result.data) {
|
|
715
724
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
716
725
|
if (userResult.data) {
|
|
717
|
-
const profile = userResult.data.profile;
|
|
726
|
+
const profile = userResult.data.user.profile;
|
|
718
727
|
const updatedUser = {
|
|
719
728
|
id: userResult.data.user.id,
|
|
720
729
|
email: userResult.data.user.email,
|
|
721
730
|
name: profile?.name || "",
|
|
722
|
-
avatarUrl: profile?.
|
|
731
|
+
avatarUrl: profile?.avatar_url || ""
|
|
723
732
|
};
|
|
724
733
|
this.user = updatedUser;
|
|
725
734
|
if (this.config.onAuthChange) {
|
|
@@ -2176,6 +2185,7 @@ function InsforgeProviderCore({
|
|
|
2176
2185
|
onAuthChange,
|
|
2177
2186
|
onSignIn,
|
|
2178
2187
|
onSignOut,
|
|
2188
|
+
onRefresh,
|
|
2179
2189
|
initialState
|
|
2180
2190
|
}) {
|
|
2181
2191
|
const manager = useMemo(
|
|
@@ -2184,9 +2194,10 @@ function InsforgeProviderCore({
|
|
|
2184
2194
|
afterSignInUrl,
|
|
2185
2195
|
onAuthChange,
|
|
2186
2196
|
onSignIn,
|
|
2187
|
-
onSignOut
|
|
2197
|
+
onSignOut,
|
|
2198
|
+
onRefresh
|
|
2188
2199
|
}),
|
|
2189
|
-
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut]
|
|
2200
|
+
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, onRefresh]
|
|
2190
2201
|
);
|
|
2191
2202
|
if (initialState) {
|
|
2192
2203
|
const currentState = manager.getState();
|