@insforge/react 0.4.0 → 0.4.5
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/README.md +2 -11
- package/dist/atoms.cjs +158 -139
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +72 -41
- package/dist/atoms.d.ts +72 -41
- package/dist/atoms.js +159 -141
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +544 -798
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +64 -94
- package/dist/components.d.ts +64 -94
- package/dist/components.js +544 -798
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +217 -310
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.d.cts +10 -13
- package/dist/forms.d.ts +10 -13
- package/dist/forms.js +218 -311
- 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 +581 -794
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -16
- package/dist/index.d.ts +31 -16
- package/dist/index.js +581 -794
- package/dist/index.js.map +1 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +0 -11
- package/dist/router.d.ts +0 -11
- package/dist/router.js.map +1 -1
- package/dist/styles.css +212 -3
- package/dist/types.d.cts +11 -613
- package/dist/types.d.ts +11 -613
- package/package.json +7 -2
package/dist/components.d.cts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { SignInProps, SignUpProps, ProtectProps, ConditionalProps } from './types.cjs';
|
|
3
2
|
import { UserSchema } from '@insforge/sdk';
|
|
4
3
|
import * as react from 'react';
|
|
5
4
|
import { ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
export {
|
|
5
|
+
import { InsforgeUser } from './types.cjs';
|
|
6
|
+
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
|
|
7
|
+
export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.cjs';
|
|
8
8
|
import '@insforge/shared-schemas';
|
|
9
9
|
|
|
10
|
+
interface SignInProps {
|
|
11
|
+
title?: string;
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
emailLabel?: string;
|
|
14
|
+
emailPlaceholder?: string;
|
|
15
|
+
passwordLabel?: string;
|
|
16
|
+
passwordPlaceholder?: string;
|
|
17
|
+
forgotPasswordText?: string;
|
|
18
|
+
forgotPasswordUrl?: string;
|
|
19
|
+
submitButtonText?: string;
|
|
20
|
+
loadingButtonText?: string;
|
|
21
|
+
signUpText?: string;
|
|
22
|
+
signUpLinkText?: string;
|
|
23
|
+
signUpUrl?: string;
|
|
24
|
+
dividerText?: string;
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
}
|
|
10
27
|
/**
|
|
11
28
|
* Pre-built sign-in component with full authentication logic.
|
|
12
29
|
*
|
|
@@ -14,14 +31,28 @@ import '@insforge/shared-schemas';
|
|
|
14
31
|
* @example
|
|
15
32
|
* ```tsx
|
|
16
33
|
* <SignIn
|
|
17
|
-
* afterSignInUrl="/auth/callback"
|
|
18
34
|
* onSuccess={(user) => console.log('Signed in:', user)}
|
|
19
35
|
* onError={(error) => console.error('Error:', error)}
|
|
20
36
|
* />
|
|
21
37
|
* ```
|
|
22
38
|
*/
|
|
23
|
-
declare function SignIn({
|
|
39
|
+
declare function SignIn({ onError, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
|
|
24
40
|
|
|
41
|
+
interface SignUpProps {
|
|
42
|
+
title?: string;
|
|
43
|
+
subtitle?: string;
|
|
44
|
+
emailLabel?: string;
|
|
45
|
+
emailPlaceholder?: string;
|
|
46
|
+
passwordLabel?: string;
|
|
47
|
+
passwordPlaceholder?: string;
|
|
48
|
+
submitButtonText?: string;
|
|
49
|
+
loadingButtonText?: string;
|
|
50
|
+
signInText?: string;
|
|
51
|
+
signInLinkText?: string;
|
|
52
|
+
signInUrl?: string;
|
|
53
|
+
dividerText?: string;
|
|
54
|
+
onError?: (error: Error) => void;
|
|
55
|
+
}
|
|
25
56
|
/**
|
|
26
57
|
* Pre-built sign-up component with full authentication logic.
|
|
27
58
|
*
|
|
@@ -29,14 +60,12 @@ declare function SignIn({ afterSignInUrl, onSuccess, onError, ...uiProps }: Sign
|
|
|
29
60
|
* @example
|
|
30
61
|
* ```tsx
|
|
31
62
|
* <SignUp
|
|
32
|
-
* afterSignUpUrl="/auth/callback"
|
|
33
|
-
* onSuccess={(user) => console.log('Signed up:', user)}
|
|
34
63
|
* onError={(error) => console.error('Error:', error)}
|
|
35
64
|
* />
|
|
36
65
|
*
|
|
37
66
|
* ```
|
|
38
67
|
*/
|
|
39
|
-
declare function SignUp({
|
|
68
|
+
declare function SignUp({ onError, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
|
|
40
69
|
|
|
41
70
|
interface ForgotPasswordProps {
|
|
42
71
|
/** Text customization */
|
|
@@ -47,11 +76,6 @@ interface ForgotPasswordProps {
|
|
|
47
76
|
submitButtonText?: string;
|
|
48
77
|
loadingButtonText?: string;
|
|
49
78
|
backToSignInText?: string;
|
|
50
|
-
backToSignInUrl?: string;
|
|
51
|
-
successTitle?: string;
|
|
52
|
-
successMessage?: string;
|
|
53
|
-
/** Callback when password is successfully reset */
|
|
54
|
-
onSuccess?: () => void;
|
|
55
79
|
/** Callback when an error occurs */
|
|
56
80
|
onError?: (error: Error) => void;
|
|
57
81
|
}
|
|
@@ -59,24 +83,22 @@ interface ForgotPasswordProps {
|
|
|
59
83
|
* Pre-built forgot password component with full business logic.
|
|
60
84
|
*
|
|
61
85
|
* Supports two password reset methods (auto-detected from backend config):
|
|
62
|
-
* - **Link method**:
|
|
86
|
+
* - **Link method**: Two-step flow (email → check email message)
|
|
87
|
+
* User receives an email with a reset link to complete the process in a new tab
|
|
63
88
|
* - **Code method**: Three-step flow (email → verify code → reset password)
|
|
89
|
+
* User receives a verification code, enters it, then sets a new password
|
|
64
90
|
*
|
|
65
91
|
* @component
|
|
66
92
|
* @example
|
|
67
93
|
* ```tsx
|
|
68
94
|
* <ForgotPassword
|
|
69
|
-
* backToSignInUrl="/sign-in"
|
|
70
|
-
* onSuccess={() => console.log('Password reset!')}
|
|
71
95
|
* onError={(error) => console.error('Error:', error)}
|
|
72
96
|
* />
|
|
73
97
|
* ```
|
|
74
98
|
*/
|
|
75
|
-
declare function ForgotPassword({
|
|
99
|
+
declare function ForgotPassword({ onError, ...uiProps }: ForgotPasswordProps): react_jsx_runtime.JSX.Element | null;
|
|
76
100
|
|
|
77
101
|
interface ResetPasswordProps {
|
|
78
|
-
/** Reset password token (from URL query params) */
|
|
79
|
-
token: string;
|
|
80
102
|
/** Text customization */
|
|
81
103
|
title?: string;
|
|
82
104
|
subtitle?: string;
|
|
@@ -86,30 +108,23 @@ interface ResetPasswordProps {
|
|
|
86
108
|
confirmPasswordPlaceholder?: string;
|
|
87
109
|
submitButtonText?: string;
|
|
88
110
|
loadingButtonText?: string;
|
|
89
|
-
backToSignInText?: string;
|
|
90
|
-
backToSignInUrl?: string;
|
|
91
|
-
/** Callback when password reset is successful */
|
|
92
|
-
onSuccess?: () => void;
|
|
93
111
|
/** Callback when an error occurs */
|
|
94
112
|
onError?: (error: Error) => void;
|
|
95
113
|
}
|
|
96
114
|
/**
|
|
97
|
-
* Pre-built reset password component with full business logic.
|
|
115
|
+
* Pre-built reset password page component with full business logic.
|
|
116
|
+
*
|
|
117
|
+
* Automatically reads the reset token from URL query parameter (?token=xxx).
|
|
118
|
+
* Shows an error if token is missing.
|
|
98
119
|
*
|
|
99
120
|
* @component
|
|
100
121
|
* @example
|
|
101
122
|
* ```tsx
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* <ResetPassword
|
|
105
|
-
* token={token || ''}
|
|
106
|
-
* backToSignInUrl="/sign-in"
|
|
107
|
-
* onSuccess={(redirectTo) => window.location.href = redirectTo || '/'}
|
|
108
|
-
* onError={(error) => console.error('Error:', error)}
|
|
109
|
-
* />
|
|
123
|
+
* // Used at /reset-password?token=xxxxx
|
|
124
|
+
* <ResetPassword />
|
|
110
125
|
* ```
|
|
111
126
|
*/
|
|
112
|
-
declare function ResetPassword({
|
|
127
|
+
declare function ResetPassword({ onError, ...uiProps }: ResetPasswordProps): react_jsx_runtime.JSX.Element | null;
|
|
113
128
|
|
|
114
129
|
interface VerifyEmailProps {
|
|
115
130
|
/** Verification token (from URL query params) */
|
|
@@ -159,6 +174,13 @@ interface UserButtonProps {
|
|
|
159
174
|
*/
|
|
160
175
|
declare function UserButton({ afterSignOutUrl, mode }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
161
176
|
|
|
177
|
+
interface ProtectProps {
|
|
178
|
+
children: ReactNode;
|
|
179
|
+
fallback?: ReactNode;
|
|
180
|
+
redirectTo?: string;
|
|
181
|
+
condition?: (user: InsforgeUser) => boolean;
|
|
182
|
+
onRedirect?: (url: string) => void;
|
|
183
|
+
}
|
|
162
184
|
/**
|
|
163
185
|
* Protected route component that redirects unauthenticated users.
|
|
164
186
|
*
|
|
@@ -193,8 +215,11 @@ declare function UserButton({ afterSignOutUrl, mode }: UserButtonProps): react_j
|
|
|
193
215
|
* @param {function} [condition] - Custom access condition
|
|
194
216
|
* @param {function} [onRedirect] - Custom redirect handler (default: window.location)
|
|
195
217
|
*/
|
|
196
|
-
declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<
|
|
218
|
+
declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
|
|
197
219
|
|
|
220
|
+
interface ConditionalProps$1 {
|
|
221
|
+
children: ReactNode;
|
|
222
|
+
}
|
|
198
223
|
/**
|
|
199
224
|
* Conditional component that renders children only when user is signed in.
|
|
200
225
|
*
|
|
@@ -209,8 +234,11 @@ declare function Protect({ children, fallback, redirectTo, condition, onRedirect
|
|
|
209
234
|
* @param {ReactNode} children - React nodes to render when user is authenticated
|
|
210
235
|
* @returns {JSX.Element | null} Renders children when signed in, null otherwise
|
|
211
236
|
*/
|
|
212
|
-
declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
|
|
237
|
+
declare function SignedIn({ children }: ConditionalProps$1): react_jsx_runtime.JSX.Element | null;
|
|
213
238
|
|
|
239
|
+
interface ConditionalProps {
|
|
240
|
+
children: ReactNode;
|
|
241
|
+
}
|
|
214
242
|
/**
|
|
215
243
|
* Conditional component that renders children only when user is signed out.
|
|
216
244
|
*
|
|
@@ -227,62 +255,4 @@ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX
|
|
|
227
255
|
*/
|
|
228
256
|
declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
|
|
229
257
|
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Redirect destination after successful authentication
|
|
233
|
-
*/
|
|
234
|
-
redirectTo?: string;
|
|
235
|
-
/**
|
|
236
|
-
* Callback fired on successful authentication
|
|
237
|
-
*/
|
|
238
|
-
onSuccess?: () => void;
|
|
239
|
-
/**
|
|
240
|
-
* Callback fired on authentication error
|
|
241
|
-
*/
|
|
242
|
-
onError?: (error: string) => void;
|
|
243
|
-
/**
|
|
244
|
-
* Custom loading component
|
|
245
|
-
*/
|
|
246
|
-
loadingComponent?: ReactNode;
|
|
247
|
-
/**
|
|
248
|
-
* Custom redirect handler (default: window.location)
|
|
249
|
-
*/
|
|
250
|
-
onRedirect?: (url: string) => void;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* InsforgeCallback - Handles OAuth authentication callbacks
|
|
254
|
-
*
|
|
255
|
-
* Place this component on your `/auth/callback` page.
|
|
256
|
-
*
|
|
257
|
-
* How it works:
|
|
258
|
-
* 1. SDK automatically detects OAuth callback parameters and saves to localStorage
|
|
259
|
-
* 2. Provider validates the session from localStorage
|
|
260
|
-
* 3. This component waits for validation and handles redirect
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```tsx
|
|
264
|
-
* // Minimal usage
|
|
265
|
-
* export default function CallbackPage() {
|
|
266
|
-
* return <InsforgeCallback redirectTo="/dashboard" />;
|
|
267
|
-
* }
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```tsx
|
|
272
|
-
* // With Next.js router
|
|
273
|
-
* import { useRouter } from 'next/navigation';
|
|
274
|
-
*
|
|
275
|
-
* export default function CallbackPage() {
|
|
276
|
-
* const router = useRouter();
|
|
277
|
-
* return (
|
|
278
|
-
* <InsforgeCallback
|
|
279
|
-
* redirectTo="/dashboard"
|
|
280
|
-
* onRedirect={(url) => router.push(url)}
|
|
281
|
-
* />
|
|
282
|
-
* );
|
|
283
|
-
* }
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
declare function InsforgeCallback({ redirectTo, onSuccess, onError, loadingComponent, onRedirect, }: InsforgeCallbackProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
|
|
287
|
-
|
|
288
|
-
export { ForgotPassword, InsforgeCallback, type InsforgeCallbackProps, Protect, ResetPassword, SignIn, SignUp, SignedIn, SignedOut, UserButton, VerifyEmail };
|
|
258
|
+
export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { SignInProps, SignUpProps, ProtectProps, ConditionalProps } from './types.js';
|
|
3
2
|
import { UserSchema } from '@insforge/sdk';
|
|
4
3
|
import * as react from 'react';
|
|
5
4
|
import { ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
export {
|
|
5
|
+
import { InsforgeUser } from './types.js';
|
|
6
|
+
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
|
|
7
|
+
export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.js';
|
|
8
8
|
import '@insforge/shared-schemas';
|
|
9
9
|
|
|
10
|
+
interface SignInProps {
|
|
11
|
+
title?: string;
|
|
12
|
+
subtitle?: string;
|
|
13
|
+
emailLabel?: string;
|
|
14
|
+
emailPlaceholder?: string;
|
|
15
|
+
passwordLabel?: string;
|
|
16
|
+
passwordPlaceholder?: string;
|
|
17
|
+
forgotPasswordText?: string;
|
|
18
|
+
forgotPasswordUrl?: string;
|
|
19
|
+
submitButtonText?: string;
|
|
20
|
+
loadingButtonText?: string;
|
|
21
|
+
signUpText?: string;
|
|
22
|
+
signUpLinkText?: string;
|
|
23
|
+
signUpUrl?: string;
|
|
24
|
+
dividerText?: string;
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
}
|
|
10
27
|
/**
|
|
11
28
|
* Pre-built sign-in component with full authentication logic.
|
|
12
29
|
*
|
|
@@ -14,14 +31,28 @@ import '@insforge/shared-schemas';
|
|
|
14
31
|
* @example
|
|
15
32
|
* ```tsx
|
|
16
33
|
* <SignIn
|
|
17
|
-
* afterSignInUrl="/auth/callback"
|
|
18
34
|
* onSuccess={(user) => console.log('Signed in:', user)}
|
|
19
35
|
* onError={(error) => console.error('Error:', error)}
|
|
20
36
|
* />
|
|
21
37
|
* ```
|
|
22
38
|
*/
|
|
23
|
-
declare function SignIn({
|
|
39
|
+
declare function SignIn({ onError, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
|
|
24
40
|
|
|
41
|
+
interface SignUpProps {
|
|
42
|
+
title?: string;
|
|
43
|
+
subtitle?: string;
|
|
44
|
+
emailLabel?: string;
|
|
45
|
+
emailPlaceholder?: string;
|
|
46
|
+
passwordLabel?: string;
|
|
47
|
+
passwordPlaceholder?: string;
|
|
48
|
+
submitButtonText?: string;
|
|
49
|
+
loadingButtonText?: string;
|
|
50
|
+
signInText?: string;
|
|
51
|
+
signInLinkText?: string;
|
|
52
|
+
signInUrl?: string;
|
|
53
|
+
dividerText?: string;
|
|
54
|
+
onError?: (error: Error) => void;
|
|
55
|
+
}
|
|
25
56
|
/**
|
|
26
57
|
* Pre-built sign-up component with full authentication logic.
|
|
27
58
|
*
|
|
@@ -29,14 +60,12 @@ declare function SignIn({ afterSignInUrl, onSuccess, onError, ...uiProps }: Sign
|
|
|
29
60
|
* @example
|
|
30
61
|
* ```tsx
|
|
31
62
|
* <SignUp
|
|
32
|
-
* afterSignUpUrl="/auth/callback"
|
|
33
|
-
* onSuccess={(user) => console.log('Signed up:', user)}
|
|
34
63
|
* onError={(error) => console.error('Error:', error)}
|
|
35
64
|
* />
|
|
36
65
|
*
|
|
37
66
|
* ```
|
|
38
67
|
*/
|
|
39
|
-
declare function SignUp({
|
|
68
|
+
declare function SignUp({ onError, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
|
|
40
69
|
|
|
41
70
|
interface ForgotPasswordProps {
|
|
42
71
|
/** Text customization */
|
|
@@ -47,11 +76,6 @@ interface ForgotPasswordProps {
|
|
|
47
76
|
submitButtonText?: string;
|
|
48
77
|
loadingButtonText?: string;
|
|
49
78
|
backToSignInText?: string;
|
|
50
|
-
backToSignInUrl?: string;
|
|
51
|
-
successTitle?: string;
|
|
52
|
-
successMessage?: string;
|
|
53
|
-
/** Callback when password is successfully reset */
|
|
54
|
-
onSuccess?: () => void;
|
|
55
79
|
/** Callback when an error occurs */
|
|
56
80
|
onError?: (error: Error) => void;
|
|
57
81
|
}
|
|
@@ -59,24 +83,22 @@ interface ForgotPasswordProps {
|
|
|
59
83
|
* Pre-built forgot password component with full business logic.
|
|
60
84
|
*
|
|
61
85
|
* Supports two password reset methods (auto-detected from backend config):
|
|
62
|
-
* - **Link method**:
|
|
86
|
+
* - **Link method**: Two-step flow (email → check email message)
|
|
87
|
+
* User receives an email with a reset link to complete the process in a new tab
|
|
63
88
|
* - **Code method**: Three-step flow (email → verify code → reset password)
|
|
89
|
+
* User receives a verification code, enters it, then sets a new password
|
|
64
90
|
*
|
|
65
91
|
* @component
|
|
66
92
|
* @example
|
|
67
93
|
* ```tsx
|
|
68
94
|
* <ForgotPassword
|
|
69
|
-
* backToSignInUrl="/sign-in"
|
|
70
|
-
* onSuccess={() => console.log('Password reset!')}
|
|
71
95
|
* onError={(error) => console.error('Error:', error)}
|
|
72
96
|
* />
|
|
73
97
|
* ```
|
|
74
98
|
*/
|
|
75
|
-
declare function ForgotPassword({
|
|
99
|
+
declare function ForgotPassword({ onError, ...uiProps }: ForgotPasswordProps): react_jsx_runtime.JSX.Element | null;
|
|
76
100
|
|
|
77
101
|
interface ResetPasswordProps {
|
|
78
|
-
/** Reset password token (from URL query params) */
|
|
79
|
-
token: string;
|
|
80
102
|
/** Text customization */
|
|
81
103
|
title?: string;
|
|
82
104
|
subtitle?: string;
|
|
@@ -86,30 +108,23 @@ interface ResetPasswordProps {
|
|
|
86
108
|
confirmPasswordPlaceholder?: string;
|
|
87
109
|
submitButtonText?: string;
|
|
88
110
|
loadingButtonText?: string;
|
|
89
|
-
backToSignInText?: string;
|
|
90
|
-
backToSignInUrl?: string;
|
|
91
|
-
/** Callback when password reset is successful */
|
|
92
|
-
onSuccess?: () => void;
|
|
93
111
|
/** Callback when an error occurs */
|
|
94
112
|
onError?: (error: Error) => void;
|
|
95
113
|
}
|
|
96
114
|
/**
|
|
97
|
-
* Pre-built reset password component with full business logic.
|
|
115
|
+
* Pre-built reset password page component with full business logic.
|
|
116
|
+
*
|
|
117
|
+
* Automatically reads the reset token from URL query parameter (?token=xxx).
|
|
118
|
+
* Shows an error if token is missing.
|
|
98
119
|
*
|
|
99
120
|
* @component
|
|
100
121
|
* @example
|
|
101
122
|
* ```tsx
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* <ResetPassword
|
|
105
|
-
* token={token || ''}
|
|
106
|
-
* backToSignInUrl="/sign-in"
|
|
107
|
-
* onSuccess={(redirectTo) => window.location.href = redirectTo || '/'}
|
|
108
|
-
* onError={(error) => console.error('Error:', error)}
|
|
109
|
-
* />
|
|
123
|
+
* // Used at /reset-password?token=xxxxx
|
|
124
|
+
* <ResetPassword />
|
|
110
125
|
* ```
|
|
111
126
|
*/
|
|
112
|
-
declare function ResetPassword({
|
|
127
|
+
declare function ResetPassword({ onError, ...uiProps }: ResetPasswordProps): react_jsx_runtime.JSX.Element | null;
|
|
113
128
|
|
|
114
129
|
interface VerifyEmailProps {
|
|
115
130
|
/** Verification token (from URL query params) */
|
|
@@ -159,6 +174,13 @@ interface UserButtonProps {
|
|
|
159
174
|
*/
|
|
160
175
|
declare function UserButton({ afterSignOutUrl, mode }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
161
176
|
|
|
177
|
+
interface ProtectProps {
|
|
178
|
+
children: ReactNode;
|
|
179
|
+
fallback?: ReactNode;
|
|
180
|
+
redirectTo?: string;
|
|
181
|
+
condition?: (user: InsforgeUser) => boolean;
|
|
182
|
+
onRedirect?: (url: string) => void;
|
|
183
|
+
}
|
|
162
184
|
/**
|
|
163
185
|
* Protected route component that redirects unauthenticated users.
|
|
164
186
|
*
|
|
@@ -193,8 +215,11 @@ declare function UserButton({ afterSignOutUrl, mode }: UserButtonProps): react_j
|
|
|
193
215
|
* @param {function} [condition] - Custom access condition
|
|
194
216
|
* @param {function} [onRedirect] - Custom redirect handler (default: window.location)
|
|
195
217
|
*/
|
|
196
|
-
declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<
|
|
218
|
+
declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
|
|
197
219
|
|
|
220
|
+
interface ConditionalProps$1 {
|
|
221
|
+
children: ReactNode;
|
|
222
|
+
}
|
|
198
223
|
/**
|
|
199
224
|
* Conditional component that renders children only when user is signed in.
|
|
200
225
|
*
|
|
@@ -209,8 +234,11 @@ declare function Protect({ children, fallback, redirectTo, condition, onRedirect
|
|
|
209
234
|
* @param {ReactNode} children - React nodes to render when user is authenticated
|
|
210
235
|
* @returns {JSX.Element | null} Renders children when signed in, null otherwise
|
|
211
236
|
*/
|
|
212
|
-
declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
|
|
237
|
+
declare function SignedIn({ children }: ConditionalProps$1): react_jsx_runtime.JSX.Element | null;
|
|
213
238
|
|
|
239
|
+
interface ConditionalProps {
|
|
240
|
+
children: ReactNode;
|
|
241
|
+
}
|
|
214
242
|
/**
|
|
215
243
|
* Conditional component that renders children only when user is signed out.
|
|
216
244
|
*
|
|
@@ -227,62 +255,4 @@ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX
|
|
|
227
255
|
*/
|
|
228
256
|
declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
|
|
229
257
|
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Redirect destination after successful authentication
|
|
233
|
-
*/
|
|
234
|
-
redirectTo?: string;
|
|
235
|
-
/**
|
|
236
|
-
* Callback fired on successful authentication
|
|
237
|
-
*/
|
|
238
|
-
onSuccess?: () => void;
|
|
239
|
-
/**
|
|
240
|
-
* Callback fired on authentication error
|
|
241
|
-
*/
|
|
242
|
-
onError?: (error: string) => void;
|
|
243
|
-
/**
|
|
244
|
-
* Custom loading component
|
|
245
|
-
*/
|
|
246
|
-
loadingComponent?: ReactNode;
|
|
247
|
-
/**
|
|
248
|
-
* Custom redirect handler (default: window.location)
|
|
249
|
-
*/
|
|
250
|
-
onRedirect?: (url: string) => void;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* InsforgeCallback - Handles OAuth authentication callbacks
|
|
254
|
-
*
|
|
255
|
-
* Place this component on your `/auth/callback` page.
|
|
256
|
-
*
|
|
257
|
-
* How it works:
|
|
258
|
-
* 1. SDK automatically detects OAuth callback parameters and saves to localStorage
|
|
259
|
-
* 2. Provider validates the session from localStorage
|
|
260
|
-
* 3. This component waits for validation and handles redirect
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```tsx
|
|
264
|
-
* // Minimal usage
|
|
265
|
-
* export default function CallbackPage() {
|
|
266
|
-
* return <InsforgeCallback redirectTo="/dashboard" />;
|
|
267
|
-
* }
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```tsx
|
|
272
|
-
* // With Next.js router
|
|
273
|
-
* import { useRouter } from 'next/navigation';
|
|
274
|
-
*
|
|
275
|
-
* export default function CallbackPage() {
|
|
276
|
-
* const router = useRouter();
|
|
277
|
-
* return (
|
|
278
|
-
* <InsforgeCallback
|
|
279
|
-
* redirectTo="/dashboard"
|
|
280
|
-
* onRedirect={(url) => router.push(url)}
|
|
281
|
-
* />
|
|
282
|
-
* );
|
|
283
|
-
* }
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
declare function InsforgeCallback({ redirectTo, onSuccess, onError, loadingComponent, onRedirect, }: InsforgeCallbackProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
|
|
287
|
-
|
|
288
|
-
export { ForgotPassword, InsforgeCallback, type InsforgeCallbackProps, Protect, ResetPassword, SignIn, SignUp, SignedIn, SignedOut, UserButton, VerifyEmail };
|
|
258
|
+
export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
|