@insforge/nextjs 0.6.8 → 0.6.9

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/api.d.mts ADDED
@@ -0,0 +1,50 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ interface AuthRouteConfig {
4
+ baseUrl: string;
5
+ cookieName?: string;
6
+ cookieMaxAge?: number;
7
+ secure?: boolean;
8
+ }
9
+ declare function createAuthRouteHandlers(config: AuthRouteConfig): {
10
+ POST: (request: NextRequest) => Promise<NextResponse<{
11
+ error: string;
12
+ }> | NextResponse<{
13
+ user: any;
14
+ session: {
15
+ userId: any;
16
+ expiresAt: string;
17
+ createdAt: string;
18
+ };
19
+ }>>;
20
+ GET: (request: NextRequest) => Promise<NextResponse<{
21
+ user: null;
22
+ session: null;
23
+ }> | NextResponse<{
24
+ user: any;
25
+ session: {
26
+ userId: any;
27
+ token: string;
28
+ expiresAt: string;
29
+ createdAt: string;
30
+ };
31
+ }>>;
32
+ DELETE: (request: NextRequest) => Promise<NextResponse<{
33
+ success: boolean;
34
+ }> | NextResponse<{
35
+ error: string;
36
+ }>>;
37
+ };
38
+
39
+ interface ProfileHandlerConfig {
40
+ baseUrl: string;
41
+ }
42
+ declare function createProfileHandler(config: ProfileHandlerConfig): (request: NextRequest) => Promise<NextResponse<{
43
+ success: boolean;
44
+ error: string;
45
+ }> | NextResponse<{
46
+ success: boolean;
47
+ user: any;
48
+ }>>;
49
+
50
+ export { type AuthRouteConfig, type ProfileHandlerConfig, createAuthRouteHandlers, createProfileHandler };
package/dist/api.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ interface AuthRouteConfig {
4
+ baseUrl: string;
5
+ cookieName?: string;
6
+ cookieMaxAge?: number;
7
+ secure?: boolean;
8
+ }
9
+ declare function createAuthRouteHandlers(config: AuthRouteConfig): {
10
+ POST: (request: NextRequest) => Promise<NextResponse<{
11
+ error: string;
12
+ }> | NextResponse<{
13
+ user: any;
14
+ session: {
15
+ userId: any;
16
+ expiresAt: string;
17
+ createdAt: string;
18
+ };
19
+ }>>;
20
+ GET: (request: NextRequest) => Promise<NextResponse<{
21
+ user: null;
22
+ session: null;
23
+ }> | NextResponse<{
24
+ user: any;
25
+ session: {
26
+ userId: any;
27
+ token: string;
28
+ expiresAt: string;
29
+ createdAt: string;
30
+ };
31
+ }>>;
32
+ DELETE: (request: NextRequest) => Promise<NextResponse<{
33
+ success: boolean;
34
+ }> | NextResponse<{
35
+ error: string;
36
+ }>>;
37
+ };
38
+
39
+ interface ProfileHandlerConfig {
40
+ baseUrl: string;
41
+ }
42
+ declare function createProfileHandler(config: ProfileHandlerConfig): (request: NextRequest) => Promise<NextResponse<{
43
+ success: boolean;
44
+ error: string;
45
+ }> | NextResponse<{
46
+ success: boolean;
47
+ user: any;
48
+ }>>;
49
+
50
+ export { type AuthRouteConfig, type ProfileHandlerConfig, createAuthRouteHandlers, createProfileHandler };
@@ -0,0 +1,250 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, CSSProperties, InputHTMLAttributes } from 'react';
4
+
5
+ interface InsforgeUser {
6
+ id: string;
7
+ email: string;
8
+ avatar_url?: string;
9
+ nickname?: string;
10
+ bio?: string;
11
+ birthday?: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ [key: string]: any;
15
+ }
16
+ interface InsforgeSession {
17
+ userId: string;
18
+ token: string;
19
+ expiresAt: string;
20
+ createdAt: string;
21
+ }
22
+ interface SignInProps {
23
+ afterSignInUrl?: string;
24
+ appearance?: {
25
+ container?: React.CSSProperties;
26
+ form?: React.CSSProperties;
27
+ button?: React.CSSProperties;
28
+ };
29
+ title?: string;
30
+ subtitle?: string;
31
+ emailLabel?: string;
32
+ emailPlaceholder?: string;
33
+ passwordLabel?: string;
34
+ passwordPlaceholder?: string;
35
+ forgotPasswordText?: string;
36
+ submitButtonText?: string;
37
+ loadingButtonText?: string;
38
+ signUpText?: string;
39
+ signUpLinkText?: string;
40
+ signUpUrl?: string;
41
+ dividerText?: string;
42
+ onSuccess?: (user: InsforgeUser) => void;
43
+ onError?: (error: Error) => void;
44
+ }
45
+ interface SignUpProps {
46
+ afterSignUpUrl?: string;
47
+ appearance?: {
48
+ container?: React.CSSProperties;
49
+ form?: React.CSSProperties;
50
+ button?: React.CSSProperties;
51
+ };
52
+ title?: string;
53
+ subtitle?: string;
54
+ emailLabel?: string;
55
+ emailPlaceholder?: string;
56
+ passwordLabel?: string;
57
+ passwordPlaceholder?: string;
58
+ submitButtonText?: string;
59
+ loadingButtonText?: string;
60
+ signInText?: string;
61
+ signInLinkText?: string;
62
+ signInUrl?: string;
63
+ dividerText?: string;
64
+ onSuccess?: (user: InsforgeUser) => void;
65
+ onError?: (error: Error) => void;
66
+ }
67
+ interface UserButtonProps {
68
+ afterSignOutUrl?: string;
69
+ mode?: 'detailed' | 'simple';
70
+ appearance?: {
71
+ button?: React.CSSProperties;
72
+ dropdown?: React.CSSProperties;
73
+ };
74
+ }
75
+ interface ProtectProps {
76
+ children: ReactNode;
77
+ fallback?: ReactNode;
78
+ redirectTo?: string;
79
+ condition?: (user: InsforgeUser) => boolean;
80
+ }
81
+ interface ConditionalProps {
82
+ children: ReactNode;
83
+ }
84
+ type OAuthProvider = 'google' | 'github' | 'discord' | 'facebook' | 'linkedin' | 'instagram' | 'tiktok' | 'apple' | 'x' | 'spotify' | 'microsoft';
85
+ interface OAuthProviderConfig {
86
+ name: string;
87
+ svg: React.ReactElement;
88
+ className: string;
89
+ }
90
+
91
+ interface InsforgeContextValue {
92
+ user: InsforgeUser | null;
93
+ session: InsforgeSession | null;
94
+ isLoaded: boolean;
95
+ isSignedIn: boolean;
96
+ setUser: (user: InsforgeUser | null) => void;
97
+ signIn: (email: string, password: string) => Promise<void>;
98
+ signUp: (email: string, password: string) => Promise<void>;
99
+ signOut: () => Promise<void>;
100
+ updateUser: (data: Partial<InsforgeUser>) => Promise<void>;
101
+ baseUrl: string;
102
+ }
103
+ interface InsforgeProviderProps {
104
+ children: ReactNode;
105
+ baseUrl: string;
106
+ frontendUrl?: string;
107
+ onAuthChange?: (user: InsforgeUser | null) => void;
108
+ useBuiltInAuth?: boolean;
109
+ }
110
+ declare function InsforgeProvider({ children, baseUrl, frontendUrl, onAuthChange, useBuiltInAuth }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
111
+ declare function useInsforge(): InsforgeContextValue;
112
+
113
+ declare function useAuth(): {
114
+ signIn: (email: string, password: string) => Promise<void>;
115
+ signUp: (email: string, password: string) => Promise<void>;
116
+ signOut: () => Promise<void>;
117
+ isLoaded: boolean;
118
+ isSignedIn: boolean;
119
+ };
120
+
121
+ declare function useUser(): {
122
+ user: InsforgeUser | null;
123
+ isLoaded: boolean;
124
+ updateUser: (data: Partial<InsforgeUser>) => Promise<void>;
125
+ setUser: (user: InsforgeUser | null) => void;
126
+ };
127
+
128
+ declare function useSession(): {
129
+ session: InsforgeSession | null;
130
+ isLoaded: boolean;
131
+ };
132
+
133
+ declare function useOAuthProviders(): {
134
+ providers: OAuthProvider[];
135
+ isLoaded: boolean;
136
+ };
137
+
138
+ declare function SignIn({ afterSignInUrl, appearance, title, subtitle, emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, forgotPasswordText, submitButtonText, loadingButtonText, signUpText, signUpLinkText, signUpUrl, dividerText, onSuccess, onError, }: SignInProps): react_jsx_runtime.JSX.Element;
139
+
140
+ declare function SignUp({ afterSignUpUrl, appearance, title, subtitle, emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, submitButtonText, loadingButtonText, signInText, signInLinkText, signInUrl, dividerText, onSuccess, onError, }: SignUpProps): react_jsx_runtime.JSX.Element;
141
+
142
+ declare function UserButton({ afterSignOutUrl, mode, appearance, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
143
+
144
+ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
145
+
146
+ declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
147
+
148
+ declare function Protect({ children, fallback, redirectTo, condition, }: ProtectProps): string | number | bigint | true | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
149
+
150
+ interface AuthContainerProps {
151
+ children: ReactNode;
152
+ style?: CSSProperties;
153
+ }
154
+ declare function AuthContainer({ children, style }: AuthContainerProps): react_jsx_runtime.JSX.Element;
155
+
156
+ interface AuthHeaderProps {
157
+ title: string;
158
+ subtitle?: string;
159
+ }
160
+ declare function AuthHeader({ title, subtitle }: AuthHeaderProps): react_jsx_runtime.JSX.Element;
161
+
162
+ interface AuthErrorBannerProps {
163
+ error: string;
164
+ }
165
+ declare function AuthErrorBanner({ error }: AuthErrorBannerProps): react_jsx_runtime.JSX.Element | null;
166
+
167
+ interface AuthFormFieldProps extends InputHTMLAttributes<HTMLInputElement> {
168
+ label: string;
169
+ id: string;
170
+ }
171
+ declare function AuthFormField({ label, id, className, ...props }: AuthFormFieldProps): react_jsx_runtime.JSX.Element;
172
+
173
+ interface AuthPasswordFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
174
+ label: string;
175
+ id: string;
176
+ showStrengthIndicator?: boolean;
177
+ forgotPasswordLink?: {
178
+ href: string;
179
+ text?: string;
180
+ };
181
+ }
182
+ declare function AuthPasswordField({ label, id, showStrengthIndicator, forgotPasswordLink, value, className, onFocus, ...props }: AuthPasswordFieldProps): react_jsx_runtime.JSX.Element;
183
+
184
+ interface AuthSubmitButtonProps {
185
+ children: ReactNode;
186
+ isLoading?: boolean;
187
+ confirmed?: boolean;
188
+ disabled?: boolean;
189
+ style?: CSSProperties;
190
+ }
191
+ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, style, }: AuthSubmitButtonProps): react_jsx_runtime.JSX.Element;
192
+
193
+ interface AuthDividerProps {
194
+ text?: string;
195
+ }
196
+ declare function AuthDivider({ text }: AuthDividerProps): react_jsx_runtime.JSX.Element;
197
+
198
+ interface AuthLinkProps {
199
+ text: string;
200
+ linkText: string;
201
+ href: string;
202
+ }
203
+ declare function AuthLink({ text, linkText, href }: AuthLinkProps): react_jsx_runtime.JSX.Element;
204
+
205
+ interface AuthOAuthProvidersProps {
206
+ providers: OAuthProvider[];
207
+ onClick: (provider: OAuthProvider) => void;
208
+ disabled?: boolean;
209
+ loading: OAuthProvider | null;
210
+ }
211
+ declare function AuthOAuthProviders({ providers, onClick, disabled, loading, }: AuthOAuthProvidersProps): react_jsx_runtime.JSX.Element | null;
212
+
213
+ interface AuthBrandingProps {
214
+ text?: string;
215
+ href?: string;
216
+ }
217
+ declare function AuthBranding({ text, href }: AuthBrandingProps): react_jsx_runtime.JSX.Element;
218
+
219
+ type DisplayMode = 'full' | 'short' | 'icon';
220
+ interface AuthOAuthButtonProps {
221
+ provider: OAuthProvider;
222
+ onClick: (provider: OAuthProvider) => void;
223
+ disabled?: boolean;
224
+ loading?: boolean;
225
+ displayMode?: DisplayMode;
226
+ style?: React.CSSProperties;
227
+ }
228
+ declare function AuthOAuthButton({ provider, onClick, disabled, loading, displayMode, style }: AuthOAuthButtonProps): react_jsx_runtime.JSX.Element | null;
229
+
230
+ interface AuthPasswordStrengthIndicatorProps {
231
+ password: string;
232
+ }
233
+ declare function validatePasswordStrength(password: string): boolean;
234
+ declare function AuthPasswordStrengthIndicator({ password }: AuthPasswordStrengthIndicatorProps): react_jsx_runtime.JSX.Element;
235
+
236
+ interface AuthVerificationCodeInputProps {
237
+ length?: number;
238
+ value: string;
239
+ email: string;
240
+ onChange: (value: string) => void;
241
+ disabled?: boolean;
242
+ }
243
+ declare function AuthVerificationCodeInput({ length, value, email, onChange, disabled, }: AuthVerificationCodeInputProps): react_jsx_runtime.JSX.Element;
244
+
245
+ declare const OAUTH_PROVIDER_CONFIG: Record<OAuthProvider, OAuthProviderConfig>;
246
+ declare function getProviderConfig(provider: OAuthProvider): OAuthProviderConfig | null;
247
+ declare function getProviderName(provider: OAuthProvider): string;
248
+ declare function isProviderSupported(provider: string): provider is OAuthProvider;
249
+
250
+ export { AuthBranding, AuthContainer, AuthDivider, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, type ConditionalProps, InsforgeProvider, type InsforgeSession, type InsforgeUser, OAUTH_PROVIDER_CONFIG, type OAuthProvider, type OAuthProviderConfig, Protect, type ProtectProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, getProviderConfig, getProviderName, isProviderSupported, useAuth, useInsforge, useOAuthProviders, useSession, useUser, validatePasswordStrength };
@@ -0,0 +1,250 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, CSSProperties, InputHTMLAttributes } from 'react';
4
+
5
+ interface InsforgeUser {
6
+ id: string;
7
+ email: string;
8
+ avatar_url?: string;
9
+ nickname?: string;
10
+ bio?: string;
11
+ birthday?: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ [key: string]: any;
15
+ }
16
+ interface InsforgeSession {
17
+ userId: string;
18
+ token: string;
19
+ expiresAt: string;
20
+ createdAt: string;
21
+ }
22
+ interface SignInProps {
23
+ afterSignInUrl?: string;
24
+ appearance?: {
25
+ container?: React.CSSProperties;
26
+ form?: React.CSSProperties;
27
+ button?: React.CSSProperties;
28
+ };
29
+ title?: string;
30
+ subtitle?: string;
31
+ emailLabel?: string;
32
+ emailPlaceholder?: string;
33
+ passwordLabel?: string;
34
+ passwordPlaceholder?: string;
35
+ forgotPasswordText?: string;
36
+ submitButtonText?: string;
37
+ loadingButtonText?: string;
38
+ signUpText?: string;
39
+ signUpLinkText?: string;
40
+ signUpUrl?: string;
41
+ dividerText?: string;
42
+ onSuccess?: (user: InsforgeUser) => void;
43
+ onError?: (error: Error) => void;
44
+ }
45
+ interface SignUpProps {
46
+ afterSignUpUrl?: string;
47
+ appearance?: {
48
+ container?: React.CSSProperties;
49
+ form?: React.CSSProperties;
50
+ button?: React.CSSProperties;
51
+ };
52
+ title?: string;
53
+ subtitle?: string;
54
+ emailLabel?: string;
55
+ emailPlaceholder?: string;
56
+ passwordLabel?: string;
57
+ passwordPlaceholder?: string;
58
+ submitButtonText?: string;
59
+ loadingButtonText?: string;
60
+ signInText?: string;
61
+ signInLinkText?: string;
62
+ signInUrl?: string;
63
+ dividerText?: string;
64
+ onSuccess?: (user: InsforgeUser) => void;
65
+ onError?: (error: Error) => void;
66
+ }
67
+ interface UserButtonProps {
68
+ afterSignOutUrl?: string;
69
+ mode?: 'detailed' | 'simple';
70
+ appearance?: {
71
+ button?: React.CSSProperties;
72
+ dropdown?: React.CSSProperties;
73
+ };
74
+ }
75
+ interface ProtectProps {
76
+ children: ReactNode;
77
+ fallback?: ReactNode;
78
+ redirectTo?: string;
79
+ condition?: (user: InsforgeUser) => boolean;
80
+ }
81
+ interface ConditionalProps {
82
+ children: ReactNode;
83
+ }
84
+ type OAuthProvider = 'google' | 'github' | 'discord' | 'facebook' | 'linkedin' | 'instagram' | 'tiktok' | 'apple' | 'x' | 'spotify' | 'microsoft';
85
+ interface OAuthProviderConfig {
86
+ name: string;
87
+ svg: React.ReactElement;
88
+ className: string;
89
+ }
90
+
91
+ interface InsforgeContextValue {
92
+ user: InsforgeUser | null;
93
+ session: InsforgeSession | null;
94
+ isLoaded: boolean;
95
+ isSignedIn: boolean;
96
+ setUser: (user: InsforgeUser | null) => void;
97
+ signIn: (email: string, password: string) => Promise<void>;
98
+ signUp: (email: string, password: string) => Promise<void>;
99
+ signOut: () => Promise<void>;
100
+ updateUser: (data: Partial<InsforgeUser>) => Promise<void>;
101
+ baseUrl: string;
102
+ }
103
+ interface InsforgeProviderProps {
104
+ children: ReactNode;
105
+ baseUrl: string;
106
+ frontendUrl?: string;
107
+ onAuthChange?: (user: InsforgeUser | null) => void;
108
+ useBuiltInAuth?: boolean;
109
+ }
110
+ declare function InsforgeProvider({ children, baseUrl, frontendUrl, onAuthChange, useBuiltInAuth }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
111
+ declare function useInsforge(): InsforgeContextValue;
112
+
113
+ declare function useAuth(): {
114
+ signIn: (email: string, password: string) => Promise<void>;
115
+ signUp: (email: string, password: string) => Promise<void>;
116
+ signOut: () => Promise<void>;
117
+ isLoaded: boolean;
118
+ isSignedIn: boolean;
119
+ };
120
+
121
+ declare function useUser(): {
122
+ user: InsforgeUser | null;
123
+ isLoaded: boolean;
124
+ updateUser: (data: Partial<InsforgeUser>) => Promise<void>;
125
+ setUser: (user: InsforgeUser | null) => void;
126
+ };
127
+
128
+ declare function useSession(): {
129
+ session: InsforgeSession | null;
130
+ isLoaded: boolean;
131
+ };
132
+
133
+ declare function useOAuthProviders(): {
134
+ providers: OAuthProvider[];
135
+ isLoaded: boolean;
136
+ };
137
+
138
+ declare function SignIn({ afterSignInUrl, appearance, title, subtitle, emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, forgotPasswordText, submitButtonText, loadingButtonText, signUpText, signUpLinkText, signUpUrl, dividerText, onSuccess, onError, }: SignInProps): react_jsx_runtime.JSX.Element;
139
+
140
+ declare function SignUp({ afterSignUpUrl, appearance, title, subtitle, emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, submitButtonText, loadingButtonText, signInText, signInLinkText, signInUrl, dividerText, onSuccess, onError, }: SignUpProps): react_jsx_runtime.JSX.Element;
141
+
142
+ declare function UserButton({ afterSignOutUrl, mode, appearance, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
143
+
144
+ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
145
+
146
+ declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
147
+
148
+ declare function Protect({ children, fallback, redirectTo, condition, }: ProtectProps): string | number | bigint | true | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
149
+
150
+ interface AuthContainerProps {
151
+ children: ReactNode;
152
+ style?: CSSProperties;
153
+ }
154
+ declare function AuthContainer({ children, style }: AuthContainerProps): react_jsx_runtime.JSX.Element;
155
+
156
+ interface AuthHeaderProps {
157
+ title: string;
158
+ subtitle?: string;
159
+ }
160
+ declare function AuthHeader({ title, subtitle }: AuthHeaderProps): react_jsx_runtime.JSX.Element;
161
+
162
+ interface AuthErrorBannerProps {
163
+ error: string;
164
+ }
165
+ declare function AuthErrorBanner({ error }: AuthErrorBannerProps): react_jsx_runtime.JSX.Element | null;
166
+
167
+ interface AuthFormFieldProps extends InputHTMLAttributes<HTMLInputElement> {
168
+ label: string;
169
+ id: string;
170
+ }
171
+ declare function AuthFormField({ label, id, className, ...props }: AuthFormFieldProps): react_jsx_runtime.JSX.Element;
172
+
173
+ interface AuthPasswordFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
174
+ label: string;
175
+ id: string;
176
+ showStrengthIndicator?: boolean;
177
+ forgotPasswordLink?: {
178
+ href: string;
179
+ text?: string;
180
+ };
181
+ }
182
+ declare function AuthPasswordField({ label, id, showStrengthIndicator, forgotPasswordLink, value, className, onFocus, ...props }: AuthPasswordFieldProps): react_jsx_runtime.JSX.Element;
183
+
184
+ interface AuthSubmitButtonProps {
185
+ children: ReactNode;
186
+ isLoading?: boolean;
187
+ confirmed?: boolean;
188
+ disabled?: boolean;
189
+ style?: CSSProperties;
190
+ }
191
+ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, style, }: AuthSubmitButtonProps): react_jsx_runtime.JSX.Element;
192
+
193
+ interface AuthDividerProps {
194
+ text?: string;
195
+ }
196
+ declare function AuthDivider({ text }: AuthDividerProps): react_jsx_runtime.JSX.Element;
197
+
198
+ interface AuthLinkProps {
199
+ text: string;
200
+ linkText: string;
201
+ href: string;
202
+ }
203
+ declare function AuthLink({ text, linkText, href }: AuthLinkProps): react_jsx_runtime.JSX.Element;
204
+
205
+ interface AuthOAuthProvidersProps {
206
+ providers: OAuthProvider[];
207
+ onClick: (provider: OAuthProvider) => void;
208
+ disabled?: boolean;
209
+ loading: OAuthProvider | null;
210
+ }
211
+ declare function AuthOAuthProviders({ providers, onClick, disabled, loading, }: AuthOAuthProvidersProps): react_jsx_runtime.JSX.Element | null;
212
+
213
+ interface AuthBrandingProps {
214
+ text?: string;
215
+ href?: string;
216
+ }
217
+ declare function AuthBranding({ text, href }: AuthBrandingProps): react_jsx_runtime.JSX.Element;
218
+
219
+ type DisplayMode = 'full' | 'short' | 'icon';
220
+ interface AuthOAuthButtonProps {
221
+ provider: OAuthProvider;
222
+ onClick: (provider: OAuthProvider) => void;
223
+ disabled?: boolean;
224
+ loading?: boolean;
225
+ displayMode?: DisplayMode;
226
+ style?: React.CSSProperties;
227
+ }
228
+ declare function AuthOAuthButton({ provider, onClick, disabled, loading, displayMode, style }: AuthOAuthButtonProps): react_jsx_runtime.JSX.Element | null;
229
+
230
+ interface AuthPasswordStrengthIndicatorProps {
231
+ password: string;
232
+ }
233
+ declare function validatePasswordStrength(password: string): boolean;
234
+ declare function AuthPasswordStrengthIndicator({ password }: AuthPasswordStrengthIndicatorProps): react_jsx_runtime.JSX.Element;
235
+
236
+ interface AuthVerificationCodeInputProps {
237
+ length?: number;
238
+ value: string;
239
+ email: string;
240
+ onChange: (value: string) => void;
241
+ disabled?: boolean;
242
+ }
243
+ declare function AuthVerificationCodeInput({ length, value, email, onChange, disabled, }: AuthVerificationCodeInputProps): react_jsx_runtime.JSX.Element;
244
+
245
+ declare const OAUTH_PROVIDER_CONFIG: Record<OAuthProvider, OAuthProviderConfig>;
246
+ declare function getProviderConfig(provider: OAuthProvider): OAuthProviderConfig | null;
247
+ declare function getProviderName(provider: OAuthProvider): string;
248
+ declare function isProviderSupported(provider: string): provider is OAuthProvider;
249
+
250
+ export { AuthBranding, AuthContainer, AuthDivider, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, type ConditionalProps, InsforgeProvider, type InsforgeSession, type InsforgeUser, OAUTH_PROVIDER_CONFIG, type OAuthProvider, type OAuthProviderConfig, Protect, type ProtectProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, getProviderConfig, getProviderName, isProviderSupported, useAuth, useInsforge, useOAuthProviders, useSession, useUser, validatePasswordStrength };
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ function InsforgeProvider({
113
113
  const [user, setUser] = (0, import_react.useState)(null);
114
114
  const [session, setSession] = (0, import_react.useState)(null);
115
115
  const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
116
- const refreshIntervalRef = (0, import_react.useRef)();
116
+ const refreshIntervalRef = (0, import_react.useRef)(null);
117
117
  const [insforge] = (0, import_react.useState)(() => (0, import_sdk.createClient)({ baseUrl }));
118
118
  const loadAuthState = (0, import_react.useCallback)(async () => {
119
119
  try {
@@ -367,7 +367,6 @@ function useSession() {
367
367
 
368
368
  // src/hooks/useOAuthProviders.ts
369
369
  var import_react2 = require("react");
370
- var import_sdk2 = require("@insforge/sdk");
371
370
  function useOAuthProviders() {
372
371
  const { baseUrl } = useInsforge();
373
372
  const [providers, setProviders] = (0, import_react2.useState)([]);
@@ -376,20 +375,25 @@ function useOAuthProviders() {
376
375
  let mounted = true;
377
376
  async function fetchProviders() {
378
377
  try {
379
- const insforge = (0, import_sdk2.createClient)({ baseUrl });
380
- const { data, error } = await insforge.auth.getOAuthProviders();
381
- if (!mounted) return;
382
- if (error) {
383
- console.warn("[useOAuthProviders] Failed to fetch OAuth providers:", error);
384
- setProviders([]);
385
- } else if (data) {
386
- setProviders(data);
387
- } else {
388
- setProviders([]);
378
+ const response = await fetch(`${baseUrl}/api/auth/oauth/providers`);
379
+ if (!response.ok) {
380
+ if (mounted) {
381
+ setProviders([]);
382
+ setIsLoaded(true);
383
+ }
384
+ return;
385
+ }
386
+ const result = await response.json();
387
+ if (mounted) {
388
+ if (result?.data && Array.isArray(result.data)) {
389
+ setProviders(result.data);
390
+ } else {
391
+ setProviders([]);
392
+ }
393
+ setIsLoaded(true);
389
394
  }
390
- setIsLoaded(true);
391
395
  } catch (error) {
392
- console.warn("[useOAuthProviders] Unexpected error:", error);
396
+ console.warn("[useOAuthProviders] Failed to fetch OAuth providers:", error);
393
397
  if (mounted) {
394
398
  setProviders([]);
395
399
  setIsLoaded(true);
@@ -406,7 +410,7 @@ function useOAuthProviders() {
406
410
 
407
411
  // src/components/SignIn.tsx
408
412
  var import_react5 = require("react");
409
- var import_sdk3 = require("@insforge/sdk");
413
+ var import_sdk2 = require("@insforge/sdk");
410
414
 
411
415
  // src/components/auth/AuthBranding.tsx
412
416
  var import_link = __toESM(require("next/link"));
@@ -1000,7 +1004,7 @@ function SignIn({
1000
1004
  const [error, setError] = (0, import_react5.useState)("");
1001
1005
  const [loading, setLoading] = (0, import_react5.useState)(false);
1002
1006
  const [oauthLoading, setOauthLoading] = (0, import_react5.useState)(null);
1003
- const insforge = (0, import_react5.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
1007
+ const insforge = (0, import_react5.useState)(() => (0, import_sdk2.createClient)({ baseUrl }))[0];
1004
1008
  async function handleSubmit(e) {
1005
1009
  e.preventDefault();
1006
1010
  setLoading(true);
@@ -1094,7 +1098,7 @@ function SignIn({
1094
1098
 
1095
1099
  // src/components/SignUp.tsx
1096
1100
  var import_react6 = require("react");
1097
- var import_sdk4 = require("@insforge/sdk");
1101
+ var import_sdk3 = require("@insforge/sdk");
1098
1102
  var import_jsx_runtime17 = require("react/jsx-runtime");
1099
1103
  function SignUp({
1100
1104
  afterSignUpUrl = "/",
@@ -1124,7 +1128,7 @@ function SignUp({
1124
1128
  const [error, setError] = (0, import_react6.useState)("");
1125
1129
  const [loading, setLoading] = (0, import_react6.useState)(false);
1126
1130
  const [oauthLoading, setOauthLoading] = (0, import_react6.useState)(null);
1127
- const insforge = (0, import_react6.useState)(() => (0, import_sdk4.createClient)({ baseUrl }))[0];
1131
+ const insforge = (0, import_react6.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
1128
1132
  async function handleCredentialsSubmit(e) {
1129
1133
  e.preventDefault();
1130
1134
  setLoading(true);