@insforge/shared 1.1.0 → 1.1.1-dev.0
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.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/react.cjs +9 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +29 -2
- package/dist/react.d.ts +29 -2
- package/dist/react.js +7 -1
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -13,13 +13,19 @@ interface InsforgeUser {
|
|
|
13
13
|
*/
|
|
14
14
|
type OAuthProvider = OAuthProvidersSchema;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Auth state - the reactive part that changes when user signs in/out
|
|
17
17
|
*/
|
|
18
|
-
interface
|
|
18
|
+
interface InsforgeAuthState {
|
|
19
19
|
user: InsforgeUser | null | undefined;
|
|
20
20
|
userId: string | null | undefined;
|
|
21
21
|
isLoaded: boolean;
|
|
22
22
|
isSignedIn: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Auth methods interface - stable method references from Manager
|
|
26
|
+
* These method references should NEVER change once created
|
|
27
|
+
*/
|
|
28
|
+
interface InsforgeAuthMethods {
|
|
23
29
|
setUser: (user: InsforgeUser | null) => void;
|
|
24
30
|
signIn: (email: string, password: string) => Promise<CreateSessionResponse | {
|
|
25
31
|
error: string;
|
|
@@ -63,8 +69,19 @@ interface InsforgeContextValue {
|
|
|
63
69
|
}>;
|
|
64
70
|
loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<void>;
|
|
65
71
|
getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Auth config - configuration values
|
|
75
|
+
*/
|
|
76
|
+
interface InsforgeAuthConfig {
|
|
66
77
|
baseUrl: string;
|
|
67
78
|
afterSignInUrl: string;
|
|
68
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Context value interface for InsforgeContext
|
|
82
|
+
* Combines state, methods, and config - maintains backward compatibility
|
|
83
|
+
*/
|
|
84
|
+
interface InsforgeContextValue extends InsforgeAuthState, InsforgeAuthMethods, InsforgeAuthConfig {
|
|
85
|
+
}
|
|
69
86
|
|
|
70
|
-
export type { InsforgeContextValue, InsforgeUser, OAuthProvider };
|
|
87
|
+
export type { InsforgeAuthConfig, InsforgeAuthMethods, InsforgeAuthState, InsforgeContextValue, InsforgeUser, OAuthProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,13 +13,19 @@ interface InsforgeUser {
|
|
|
13
13
|
*/
|
|
14
14
|
type OAuthProvider = OAuthProvidersSchema;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Auth state - the reactive part that changes when user signs in/out
|
|
17
17
|
*/
|
|
18
|
-
interface
|
|
18
|
+
interface InsforgeAuthState {
|
|
19
19
|
user: InsforgeUser | null | undefined;
|
|
20
20
|
userId: string | null | undefined;
|
|
21
21
|
isLoaded: boolean;
|
|
22
22
|
isSignedIn: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Auth methods interface - stable method references from Manager
|
|
26
|
+
* These method references should NEVER change once created
|
|
27
|
+
*/
|
|
28
|
+
interface InsforgeAuthMethods {
|
|
23
29
|
setUser: (user: InsforgeUser | null) => void;
|
|
24
30
|
signIn: (email: string, password: string) => Promise<CreateSessionResponse | {
|
|
25
31
|
error: string;
|
|
@@ -63,8 +69,19 @@ interface InsforgeContextValue {
|
|
|
63
69
|
}>;
|
|
64
70
|
loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<void>;
|
|
65
71
|
getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Auth config - configuration values
|
|
75
|
+
*/
|
|
76
|
+
interface InsforgeAuthConfig {
|
|
66
77
|
baseUrl: string;
|
|
67
78
|
afterSignInUrl: string;
|
|
68
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Context value interface for InsforgeContext
|
|
82
|
+
* Combines state, methods, and config - maintains backward compatibility
|
|
83
|
+
*/
|
|
84
|
+
interface InsforgeContextValue extends InsforgeAuthState, InsforgeAuthMethods, InsforgeAuthConfig {
|
|
85
|
+
}
|
|
69
86
|
|
|
70
|
-
export type { InsforgeContextValue, InsforgeUser, OAuthProvider };
|
|
87
|
+
export type { InsforgeAuthConfig, InsforgeAuthMethods, InsforgeAuthState, InsforgeContextValue, InsforgeUser, OAuthProvider };
|
package/dist/react.cjs
CHANGED
|
@@ -5,7 +5,16 @@ var react = require('react');
|
|
|
5
5
|
// src/react/contexts.tsx
|
|
6
6
|
var InsforgeContext = react.createContext(void 0);
|
|
7
7
|
InsforgeContext.displayName = "InsforgeContext";
|
|
8
|
+
var InsforgeAuthStateContext = react.createContext(void 0);
|
|
9
|
+
InsforgeAuthStateContext.displayName = "InsforgeAuthStateContext";
|
|
10
|
+
var InsforgeMethodsContext = react.createContext(void 0);
|
|
11
|
+
InsforgeMethodsContext.displayName = "InsforgeMethodsContext";
|
|
12
|
+
var InsforgeConfigContext = react.createContext(void 0);
|
|
13
|
+
InsforgeConfigContext.displayName = "InsforgeConfigContext";
|
|
8
14
|
|
|
15
|
+
exports.InsforgeAuthStateContext = InsforgeAuthStateContext;
|
|
16
|
+
exports.InsforgeConfigContext = InsforgeConfigContext;
|
|
9
17
|
exports.InsforgeContext = InsforgeContext;
|
|
18
|
+
exports.InsforgeMethodsContext = InsforgeMethodsContext;
|
|
10
19
|
//# sourceMappingURL=react.cjs.map
|
|
11
20
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/contexts.tsx"],"names":["createContext"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/react/contexts.tsx"],"names":["createContext"],"mappings":";;;;;AAmBO,IAAM,eAAA,GAAkBA,oBAAgD,MAAS;AACxF,eAAA,CAAgB,WAAA,GAAc,iBAAA;AAQvB,IAAM,wBAAA,GAA2BA,oBAA6C,MAAS;AAC9F,wBAAA,CAAyB,WAAA,GAAc,0BAAA;AAYhC,IAAM,sBAAA,GAAyBA,oBAA+C,MAAS;AAC9F,sBAAA,CAAuB,WAAA,GAAc,wBAAA;AAQ9B,IAAM,qBAAA,GAAwBA,oBAA8C,MAAS;AAC5F,qBAAA,CAAsB,WAAA,GAAc,uBAAA","file":"react.cjs","sourcesContent":["import { createContext } from 'react';\nimport type {\n InsforgeContextValue,\n InsforgeAuthState,\n InsforgeAuthMethods,\n InsforgeAuthConfig,\n} from '../types';\n\n/**\n * InsforgeContext - The single source of truth for authentication state\n *\n * This Context is defined in @insforge/shared to prevent duplication across\n * multiple tsup entry points. All packages (@insforge/react, @insforge/nextjs, etc.)\n * import this Context definition, ensuring there's only ONE Context instance.\n *\n * Pattern learned from @clerk/shared\n *\n * @deprecated Internal use only. Use useInsforge() hook instead.\n */\nexport const InsforgeContext = createContext<InsforgeContextValue | undefined>(undefined);\nInsforgeContext.displayName = 'InsforgeContext';\n\n/**\n * InsforgeAuthStateContext - Reactive auth state that changes on sign in/out\n *\n * This context holds the reactive state: user, userId, isLoaded, isSignedIn.\n * It updates when auth state changes.\n */\nexport const InsforgeAuthStateContext = createContext<InsforgeAuthState | undefined>(undefined);\nInsforgeAuthStateContext.displayName = 'InsforgeAuthStateContext';\n\n/**\n * InsforgeMethodsContext - Stable method references\n *\n * This context holds method references that NEVER change once initialized.\n * Methods like signIn, signOut, verifyEmail etc. are stored here.\n * This prevents useEffect re-runs when state changes.\n *\n * Pattern learned from @clerk/shared - they store the Clerk instance\n * in a separate context to keep method references stable.\n */\nexport const InsforgeMethodsContext = createContext<InsforgeAuthMethods | undefined>(undefined);\nInsforgeMethodsContext.displayName = 'InsforgeMethodsContext';\n\n/**\n * InsforgeConfigContext - Static configuration values\n *\n * This context holds configuration values like baseUrl, afterSignInUrl.\n * These rarely change after initialization.\n */\nexport const InsforgeConfigContext = createContext<InsforgeAuthConfig | undefined>(undefined);\nInsforgeConfigContext.displayName = 'InsforgeConfigContext';\n"]}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { InsforgeContextValue } from './index.cjs';
|
|
2
|
+
import { InsforgeContextValue, InsforgeAuthState, InsforgeAuthMethods, InsforgeAuthConfig } from './index.cjs';
|
|
3
3
|
import '@insforge/shared-schemas';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,7 +10,34 @@ import '@insforge/shared-schemas';
|
|
|
10
10
|
* import this Context definition, ensuring there's only ONE Context instance.
|
|
11
11
|
*
|
|
12
12
|
* Pattern learned from @clerk/shared
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Internal use only. Use useInsforge() hook instead.
|
|
13
15
|
*/
|
|
14
16
|
declare const InsforgeContext: react.Context<InsforgeContextValue | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* InsforgeAuthStateContext - Reactive auth state that changes on sign in/out
|
|
19
|
+
*
|
|
20
|
+
* This context holds the reactive state: user, userId, isLoaded, isSignedIn.
|
|
21
|
+
* It updates when auth state changes.
|
|
22
|
+
*/
|
|
23
|
+
declare const InsforgeAuthStateContext: react.Context<InsforgeAuthState | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* InsforgeMethodsContext - Stable method references
|
|
26
|
+
*
|
|
27
|
+
* This context holds method references that NEVER change once initialized.
|
|
28
|
+
* Methods like signIn, signOut, verifyEmail etc. are stored here.
|
|
29
|
+
* This prevents useEffect re-runs when state changes.
|
|
30
|
+
*
|
|
31
|
+
* Pattern learned from @clerk/shared - they store the Clerk instance
|
|
32
|
+
* in a separate context to keep method references stable.
|
|
33
|
+
*/
|
|
34
|
+
declare const InsforgeMethodsContext: react.Context<InsforgeAuthMethods | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* InsforgeConfigContext - Static configuration values
|
|
37
|
+
*
|
|
38
|
+
* This context holds configuration values like baseUrl, afterSignInUrl.
|
|
39
|
+
* These rarely change after initialization.
|
|
40
|
+
*/
|
|
41
|
+
declare const InsforgeConfigContext: react.Context<InsforgeAuthConfig | undefined>;
|
|
15
42
|
|
|
16
|
-
export { InsforgeContext };
|
|
43
|
+
export { InsforgeAuthStateContext, InsforgeConfigContext, InsforgeContext, InsforgeMethodsContext };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { InsforgeContextValue } from './index.js';
|
|
2
|
+
import { InsforgeContextValue, InsforgeAuthState, InsforgeAuthMethods, InsforgeAuthConfig } from './index.js';
|
|
3
3
|
import '@insforge/shared-schemas';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,7 +10,34 @@ import '@insforge/shared-schemas';
|
|
|
10
10
|
* import this Context definition, ensuring there's only ONE Context instance.
|
|
11
11
|
*
|
|
12
12
|
* Pattern learned from @clerk/shared
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Internal use only. Use useInsforge() hook instead.
|
|
13
15
|
*/
|
|
14
16
|
declare const InsforgeContext: react.Context<InsforgeContextValue | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* InsforgeAuthStateContext - Reactive auth state that changes on sign in/out
|
|
19
|
+
*
|
|
20
|
+
* This context holds the reactive state: user, userId, isLoaded, isSignedIn.
|
|
21
|
+
* It updates when auth state changes.
|
|
22
|
+
*/
|
|
23
|
+
declare const InsforgeAuthStateContext: react.Context<InsforgeAuthState | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* InsforgeMethodsContext - Stable method references
|
|
26
|
+
*
|
|
27
|
+
* This context holds method references that NEVER change once initialized.
|
|
28
|
+
* Methods like signIn, signOut, verifyEmail etc. are stored here.
|
|
29
|
+
* This prevents useEffect re-runs when state changes.
|
|
30
|
+
*
|
|
31
|
+
* Pattern learned from @clerk/shared - they store the Clerk instance
|
|
32
|
+
* in a separate context to keep method references stable.
|
|
33
|
+
*/
|
|
34
|
+
declare const InsforgeMethodsContext: react.Context<InsforgeAuthMethods | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* InsforgeConfigContext - Static configuration values
|
|
37
|
+
*
|
|
38
|
+
* This context holds configuration values like baseUrl, afterSignInUrl.
|
|
39
|
+
* These rarely change after initialization.
|
|
40
|
+
*/
|
|
41
|
+
declare const InsforgeConfigContext: react.Context<InsforgeAuthConfig | undefined>;
|
|
15
42
|
|
|
16
|
-
export { InsforgeContext };
|
|
43
|
+
export { InsforgeAuthStateContext, InsforgeConfigContext, InsforgeContext, InsforgeMethodsContext };
|
package/dist/react.js
CHANGED
|
@@ -3,7 +3,13 @@ import { createContext } from 'react';
|
|
|
3
3
|
// src/react/contexts.tsx
|
|
4
4
|
var InsforgeContext = createContext(void 0);
|
|
5
5
|
InsforgeContext.displayName = "InsforgeContext";
|
|
6
|
+
var InsforgeAuthStateContext = createContext(void 0);
|
|
7
|
+
InsforgeAuthStateContext.displayName = "InsforgeAuthStateContext";
|
|
8
|
+
var InsforgeMethodsContext = createContext(void 0);
|
|
9
|
+
InsforgeMethodsContext.displayName = "InsforgeMethodsContext";
|
|
10
|
+
var InsforgeConfigContext = createContext(void 0);
|
|
11
|
+
InsforgeConfigContext.displayName = "InsforgeConfigContext";
|
|
6
12
|
|
|
7
|
-
export { InsforgeContext };
|
|
13
|
+
export { InsforgeAuthStateContext, InsforgeConfigContext, InsforgeContext, InsforgeMethodsContext };
|
|
8
14
|
//# sourceMappingURL=react.js.map
|
|
9
15
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/contexts.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/react/contexts.tsx"],"names":[],"mappings":";;;AAmBO,IAAM,eAAA,GAAkB,cAAgD,MAAS;AACxF,eAAA,CAAgB,WAAA,GAAc,iBAAA;AAQvB,IAAM,wBAAA,GAA2B,cAA6C,MAAS;AAC9F,wBAAA,CAAyB,WAAA,GAAc,0BAAA;AAYhC,IAAM,sBAAA,GAAyB,cAA+C,MAAS;AAC9F,sBAAA,CAAuB,WAAA,GAAc,wBAAA;AAQ9B,IAAM,qBAAA,GAAwB,cAA8C,MAAS;AAC5F,qBAAA,CAAsB,WAAA,GAAc,uBAAA","file":"react.js","sourcesContent":["import { createContext } from 'react';\nimport type {\n InsforgeContextValue,\n InsforgeAuthState,\n InsforgeAuthMethods,\n InsforgeAuthConfig,\n} from '../types';\n\n/**\n * InsforgeContext - The single source of truth for authentication state\n *\n * This Context is defined in @insforge/shared to prevent duplication across\n * multiple tsup entry points. All packages (@insforge/react, @insforge/nextjs, etc.)\n * import this Context definition, ensuring there's only ONE Context instance.\n *\n * Pattern learned from @clerk/shared\n *\n * @deprecated Internal use only. Use useInsforge() hook instead.\n */\nexport const InsforgeContext = createContext<InsforgeContextValue | undefined>(undefined);\nInsforgeContext.displayName = 'InsforgeContext';\n\n/**\n * InsforgeAuthStateContext - Reactive auth state that changes on sign in/out\n *\n * This context holds the reactive state: user, userId, isLoaded, isSignedIn.\n * It updates when auth state changes.\n */\nexport const InsforgeAuthStateContext = createContext<InsforgeAuthState | undefined>(undefined);\nInsforgeAuthStateContext.displayName = 'InsforgeAuthStateContext';\n\n/**\n * InsforgeMethodsContext - Stable method references\n *\n * This context holds method references that NEVER change once initialized.\n * Methods like signIn, signOut, verifyEmail etc. are stored here.\n * This prevents useEffect re-runs when state changes.\n *\n * Pattern learned from @clerk/shared - they store the Clerk instance\n * in a separate context to keep method references stable.\n */\nexport const InsforgeMethodsContext = createContext<InsforgeAuthMethods | undefined>(undefined);\nInsforgeMethodsContext.displayName = 'InsforgeMethodsContext';\n\n/**\n * InsforgeConfigContext - Static configuration values\n *\n * This context holds configuration values like baseUrl, afterSignInUrl.\n * These rarely change after initialization.\n */\nexport const InsforgeConfigContext = createContext<InsforgeAuthConfig | undefined>(undefined);\nInsforgeConfigContext.displayName = 'InsforgeConfigContext';\n"]}
|