@insforge/react 0.4.0 → 0.4.6
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 +6 -12
- 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 +600 -795
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -17
- package/dist/index.d.ts +40 -17
- package/dist/index.js +600 -795
- package/dist/index.js.map +1 -1
- package/dist/router.cjs +2 -2
- 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 +2 -2
- 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/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { ForgotPasswordForm, ResetPasswordForm, SignInForm, SignUpForm, VerifyEmailStatus } from './forms.cjs';
|
|
3
|
-
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput } from './atoms.cjs';
|
|
1
|
+
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInProps, SignUp, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
|
|
2
|
+
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
|
|
3
|
+
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';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import { UserSchema } from '@insforge/sdk';
|
|
7
7
|
import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.cjs';
|
|
8
|
-
export { AuthConfig,
|
|
8
|
+
export { AuthConfig, EmailVerificationMethod } from './types.cjs';
|
|
9
9
|
import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
|
|
10
10
|
export { useAuth, usePublicAuthConfig, useUser } from './hooks.cjs';
|
|
11
11
|
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.cjs';
|
|
@@ -34,25 +34,49 @@ interface InsforgeContextValue {
|
|
|
34
34
|
success: boolean;
|
|
35
35
|
error?: string;
|
|
36
36
|
}>;
|
|
37
|
+
sendVerificationEmail: (email: string) => Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
} | null>;
|
|
37
41
|
sendResetPasswordEmail: (email: string) => Promise<{
|
|
38
42
|
success: boolean;
|
|
39
43
|
message: string;
|
|
40
44
|
} | null>;
|
|
41
45
|
resetPassword: (token: string, newPassword: string) => Promise<ResetPasswordResponse | null>;
|
|
42
|
-
verifyEmail: (
|
|
46
|
+
verifyEmail: (otp: string, email?: string) => Promise<{
|
|
43
47
|
accessToken: string;
|
|
44
48
|
user?: UserSchema;
|
|
45
49
|
redirectTo?: string;
|
|
50
|
+
error?: {
|
|
51
|
+
message: string;
|
|
52
|
+
};
|
|
46
53
|
} | null>;
|
|
54
|
+
exchangeResetPasswordToken: (email: string, code: string) => Promise<{
|
|
55
|
+
token: string;
|
|
56
|
+
expiresAt?: string;
|
|
57
|
+
} | {
|
|
58
|
+
error: {
|
|
59
|
+
message: string;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<{
|
|
63
|
+
url?: string | undefined;
|
|
64
|
+
provider?: string | undefined;
|
|
65
|
+
}>;
|
|
47
66
|
getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
|
|
48
67
|
baseUrl: string;
|
|
49
68
|
}
|
|
50
69
|
interface InsforgeProviderProps {
|
|
51
70
|
children: ReactNode;
|
|
52
71
|
baseUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* URL to redirect to after successful sign in (when token is detected in URL)
|
|
74
|
+
* @default '/'
|
|
75
|
+
*/
|
|
76
|
+
afterSignInUrl?: string;
|
|
53
77
|
onAuthChange?: (user: InsforgeUser | null) => void;
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
onSignIn?: (authToken: string) => Promise<void>;
|
|
79
|
+
onSignOut?: () => Promise<void>;
|
|
56
80
|
}
|
|
57
81
|
/**
|
|
58
82
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -67,7 +91,10 @@ interface InsforgeProviderProps {
|
|
|
67
91
|
*
|
|
68
92
|
* export default function App() {
|
|
69
93
|
* return (
|
|
70
|
-
* <InsforgeProvider
|
|
94
|
+
* <InsforgeProvider
|
|
95
|
+
* baseUrl={process.env.VITE_INSFORGE_BASE_URL}
|
|
96
|
+
* afterSignInUrl="/dashboard"
|
|
97
|
+
* >
|
|
71
98
|
* {children}
|
|
72
99
|
* </InsforgeProvider>
|
|
73
100
|
* );
|
|
@@ -79,22 +106,18 @@ interface InsforgeProviderProps {
|
|
|
79
106
|
* // With cookie sync (Next.js optimization)
|
|
80
107
|
* <InsforgeProvider
|
|
81
108
|
* baseUrl={baseUrl}
|
|
82
|
-
*
|
|
83
|
-
* await
|
|
84
|
-
* method: 'POST',
|
|
85
|
-
* body: JSON.stringify({ token })
|
|
86
|
-
* });
|
|
87
|
-
* return true;
|
|
109
|
+
* onSignIn={async (authToken) => {
|
|
110
|
+
* await signIn(authToken);
|
|
88
111
|
* }}
|
|
89
|
-
*
|
|
90
|
-
* await
|
|
112
|
+
* onSignOut={async () => {
|
|
113
|
+
* await signOut();
|
|
91
114
|
* }}
|
|
92
115
|
* >
|
|
93
116
|
* {children}
|
|
94
117
|
* </InsforgeProvider>
|
|
95
118
|
* ```
|
|
96
119
|
*/
|
|
97
|
-
declare function InsforgeProvider({ children, baseUrl, onAuthChange,
|
|
120
|
+
declare function InsforgeProvider({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
98
121
|
/**
|
|
99
122
|
* Hook to access Insforge context
|
|
100
123
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { ForgotPasswordForm, ResetPasswordForm, SignInForm, SignUpForm, VerifyEmailStatus } from './forms.js';
|
|
3
|
-
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput } from './atoms.js';
|
|
1
|
+
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInProps, SignUp, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.js';
|
|
2
|
+
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
|
|
3
|
+
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';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import { UserSchema } from '@insforge/sdk';
|
|
7
7
|
import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.js';
|
|
8
|
-
export { AuthConfig,
|
|
8
|
+
export { AuthConfig, EmailVerificationMethod } from './types.js';
|
|
9
9
|
import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
|
|
10
10
|
export { useAuth, usePublicAuthConfig, useUser } from './hooks.js';
|
|
11
11
|
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.js';
|
|
@@ -34,25 +34,49 @@ interface InsforgeContextValue {
|
|
|
34
34
|
success: boolean;
|
|
35
35
|
error?: string;
|
|
36
36
|
}>;
|
|
37
|
+
sendVerificationEmail: (email: string) => Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
} | null>;
|
|
37
41
|
sendResetPasswordEmail: (email: string) => Promise<{
|
|
38
42
|
success: boolean;
|
|
39
43
|
message: string;
|
|
40
44
|
} | null>;
|
|
41
45
|
resetPassword: (token: string, newPassword: string) => Promise<ResetPasswordResponse | null>;
|
|
42
|
-
verifyEmail: (
|
|
46
|
+
verifyEmail: (otp: string, email?: string) => Promise<{
|
|
43
47
|
accessToken: string;
|
|
44
48
|
user?: UserSchema;
|
|
45
49
|
redirectTo?: string;
|
|
50
|
+
error?: {
|
|
51
|
+
message: string;
|
|
52
|
+
};
|
|
46
53
|
} | null>;
|
|
54
|
+
exchangeResetPasswordToken: (email: string, code: string) => Promise<{
|
|
55
|
+
token: string;
|
|
56
|
+
expiresAt?: string;
|
|
57
|
+
} | {
|
|
58
|
+
error: {
|
|
59
|
+
message: string;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
loginWithOAuth: (provider: OAuthProvider, redirectTo: string) => Promise<{
|
|
63
|
+
url?: string | undefined;
|
|
64
|
+
provider?: string | undefined;
|
|
65
|
+
}>;
|
|
47
66
|
getPublicAuthConfig: () => Promise<GetPublicAuthConfigResponse | null>;
|
|
48
67
|
baseUrl: string;
|
|
49
68
|
}
|
|
50
69
|
interface InsforgeProviderProps {
|
|
51
70
|
children: ReactNode;
|
|
52
71
|
baseUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* URL to redirect to after successful sign in (when token is detected in URL)
|
|
74
|
+
* @default '/'
|
|
75
|
+
*/
|
|
76
|
+
afterSignInUrl?: string;
|
|
53
77
|
onAuthChange?: (user: InsforgeUser | null) => void;
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
onSignIn?: (authToken: string) => Promise<void>;
|
|
79
|
+
onSignOut?: () => Promise<void>;
|
|
56
80
|
}
|
|
57
81
|
/**
|
|
58
82
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -67,7 +91,10 @@ interface InsforgeProviderProps {
|
|
|
67
91
|
*
|
|
68
92
|
* export default function App() {
|
|
69
93
|
* return (
|
|
70
|
-
* <InsforgeProvider
|
|
94
|
+
* <InsforgeProvider
|
|
95
|
+
* baseUrl={process.env.VITE_INSFORGE_BASE_URL}
|
|
96
|
+
* afterSignInUrl="/dashboard"
|
|
97
|
+
* >
|
|
71
98
|
* {children}
|
|
72
99
|
* </InsforgeProvider>
|
|
73
100
|
* );
|
|
@@ -79,22 +106,18 @@ interface InsforgeProviderProps {
|
|
|
79
106
|
* // With cookie sync (Next.js optimization)
|
|
80
107
|
* <InsforgeProvider
|
|
81
108
|
* baseUrl={baseUrl}
|
|
82
|
-
*
|
|
83
|
-
* await
|
|
84
|
-
* method: 'POST',
|
|
85
|
-
* body: JSON.stringify({ token })
|
|
86
|
-
* });
|
|
87
|
-
* return true;
|
|
109
|
+
* onSignIn={async (authToken) => {
|
|
110
|
+
* await signIn(authToken);
|
|
88
111
|
* }}
|
|
89
|
-
*
|
|
90
|
-
* await
|
|
112
|
+
* onSignOut={async () => {
|
|
113
|
+
* await signOut();
|
|
91
114
|
* }}
|
|
92
115
|
* >
|
|
93
116
|
* {children}
|
|
94
117
|
* </InsforgeProvider>
|
|
95
118
|
* ```
|
|
96
119
|
*/
|
|
97
|
-
declare function InsforgeProvider({ children, baseUrl, onAuthChange,
|
|
120
|
+
declare function InsforgeProvider({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
98
121
|
/**
|
|
99
122
|
* Hook to access Insforge context
|
|
100
123
|
*
|