@insforge/react 0.3.5 → 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.
Files changed (66) hide show
  1. package/README.md +476 -604
  2. package/dist/atoms.cjs +837 -0
  3. package/dist/atoms.cjs.map +1 -0
  4. package/dist/atoms.d.cts +253 -0
  5. package/dist/atoms.d.ts +111 -245
  6. package/dist/atoms.js +412 -468
  7. package/dist/atoms.js.map +1 -1
  8. package/dist/components.cjs +2000 -0
  9. package/dist/components.cjs.map +1 -0
  10. package/dist/components.d.cts +258 -0
  11. package/dist/components.d.ts +71 -123
  12. package/dist/components.js +1040 -1428
  13. package/dist/components.js.map +1 -1
  14. package/dist/forms.cjs +1194 -0
  15. package/dist/forms.cjs.map +1 -0
  16. package/dist/forms.d.cts +135 -0
  17. package/dist/forms.d.ts +113 -163
  18. package/dist/forms.js +657 -943
  19. package/dist/forms.js.map +1 -1
  20. package/dist/{hooks.mjs → hooks.cjs} +15 -13
  21. package/dist/hooks.cjs.map +1 -0
  22. package/dist/{hooks.d.mts → hooks.d.cts} +1 -1
  23. package/dist/hooks.js +9 -15
  24. package/dist/hooks.js.map +1 -1
  25. package/dist/index.cjs +2461 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/{index.d.mts → index.d.cts} +37 -22
  28. package/dist/index.d.ts +34 -19
  29. package/dist/index.js +1142 -1497
  30. package/dist/index.js.map +1 -1
  31. package/dist/{lib.mjs → lib.cjs} +13 -11
  32. package/dist/lib.cjs.map +1 -0
  33. package/dist/{lib.d.mts → lib.d.cts} +1 -8
  34. package/dist/lib.d.ts +1 -8
  35. package/dist/lib.js +4 -17
  36. package/dist/lib.js.map +1 -1
  37. package/dist/{router.mjs → router.cjs} +14 -16
  38. package/dist/router.cjs.map +1 -0
  39. package/dist/{router.d.mts → router.d.cts} +0 -11
  40. package/dist/router.d.ts +0 -11
  41. package/dist/router.js +10 -16
  42. package/dist/router.js.map +1 -1
  43. package/dist/styles.css +864 -2
  44. package/dist/types.cjs +4 -0
  45. package/dist/{types.mjs.map → types.cjs.map} +1 -1
  46. package/dist/types.d.cts +32 -0
  47. package/dist/types.d.ts +11 -613
  48. package/dist/types.js +0 -1
  49. package/package.json +111 -98
  50. package/dist/atoms.d.mts +0 -387
  51. package/dist/atoms.mjs +0 -861
  52. package/dist/atoms.mjs.map +0 -1
  53. package/dist/components.d.mts +0 -310
  54. package/dist/components.mjs +0 -2327
  55. package/dist/components.mjs.map +0 -1
  56. package/dist/forms.d.mts +0 -185
  57. package/dist/forms.mjs +0 -1468
  58. package/dist/forms.mjs.map +0 -1
  59. package/dist/hooks.mjs.map +0 -1
  60. package/dist/index.mjs +0 -2724
  61. package/dist/index.mjs.map +0 -1
  62. package/dist/lib.mjs.map +0 -1
  63. package/dist/router.mjs.map +0 -1
  64. package/dist/types.d.mts +0 -634
  65. package/dist/types.mjs +0 -3
  66. package/src/styles.css +0 -15
@@ -1,15 +1,15 @@
1
- export { ForgotPassword, InsforgeCallback, InsforgeCallbackProps, Protect, ResetPassword, SignIn, SignUp, SignedIn, SignedOut, UserButton, VerifyEmail } from './components.mjs';
2
- export { ForgotPasswordForm, ResetPasswordForm, SignInForm, SignUpForm, VerifyEmailStatus } from './forms.mjs';
3
- export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, validatePasswordStrength } from './atoms.mjs';
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
- import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.mjs';
7
- export { AuthConfig, AuthContainerProps, AuthDividerProps, AuthErrorBannerProps, AuthFormFieldProps, AuthHeaderProps, AuthLinkProps, AuthOAuthButtonProps, AuthOAuthProvidersProps, AuthPasswordFieldProps, AuthPasswordStrengthIndicatorProps, AuthSubmitButtonProps, AuthVerificationCodeInputProps, BaseAppearance, ConditionalProps, ForgotPasswordAppearance, ForgotPasswordFormProps, ProtectProps, ResetPasswordAppearance, ResetPasswordFormProps, SignInAppearance, SignInFormProps, SignInProps, SignUpAppearance, SignUpFormProps, SignUpProps, UserButtonProps, VerifyEmailStatusProps } from './types.mjs';
6
+ import { UserSchema } from '@insforge/sdk';
7
+ import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.cjs';
8
+ export { AuthConfig, EmailVerificationMethod } from './types.cjs';
8
9
  import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
9
- export { useAuth, usePublicAuthConfig, useUser } from './hooks.mjs';
10
- export { checkPasswordStrength, cn, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.mjs';
11
- export { getInsforgeRoutes } from './router.mjs';
12
- import 'clsx';
10
+ export { useAuth, usePublicAuthConfig, useUser } from './hooks.cjs';
11
+ export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.cjs';
12
+ export { getInsforgeRoutes } from './router.cjs';
13
13
  import 'zod';
14
14
  import 'react-router-dom';
15
15
 
@@ -34,16 +34,35 @@ 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: (token: string) => Promise<{
46
+ verifyEmail: (otp: string, email?: string) => Promise<{
43
47
  accessToken: string;
44
- user?: any;
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
  }
@@ -51,8 +70,8 @@ interface InsforgeProviderProps {
51
70
  children: ReactNode;
52
71
  baseUrl: string;
53
72
  onAuthChange?: (user: InsforgeUser | null) => void;
54
- syncTokenToCookie?: (token: string) => Promise<boolean>;
55
- clearCookie?: () => Promise<void>;
73
+ onSignIn?: (authToken: string) => Promise<void>;
74
+ onSignOut?: () => Promise<void>;
56
75
  }
57
76
  /**
58
77
  * Unified Insforge Provider - manages authentication state and configuration
@@ -79,22 +98,18 @@ interface InsforgeProviderProps {
79
98
  * // With cookie sync (Next.js optimization)
80
99
  * <InsforgeProvider
81
100
  * baseUrl={baseUrl}
82
- * syncTokenToCookie={async (token) => {
83
- * await fetch('/api/auth', {
84
- * method: 'POST',
85
- * body: JSON.stringify({ token })
86
- * });
87
- * return true;
101
+ * onSignIn={async (authToken) => {
102
+ * await signIn(authToken);
88
103
  * }}
89
- * clearCookie={async () => {
90
- * await fetch('/api/auth', { method: 'DELETE' });
104
+ * onSignOut={async () => {
105
+ * await signOut();
91
106
  * }}
92
107
  * >
93
108
  * {children}
94
109
  * </InsforgeProvider>
95
110
  * ```
96
111
  */
97
- declare function InsforgeProvider({ children, baseUrl, onAuthChange, syncTokenToCookie, clearCookie, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
112
+ declare function InsforgeProvider({ children, baseUrl, onAuthChange, onSignIn, onSignOut, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
98
113
  /**
99
114
  * Hook to access Insforge context
100
115
  *
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export { ForgotPassword, InsforgeCallback, InsforgeCallbackProps, Protect, ResetPassword, SignIn, SignUp, SignedIn, SignedOut, UserButton, VerifyEmail } from './components.js';
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, validatePasswordStrength } 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
+ import { UserSchema } from '@insforge/sdk';
6
7
  import { InsforgeUser, OAuthProvider, OAuthProviderConfig } from './types.js';
7
- export { AuthConfig, AuthContainerProps, AuthDividerProps, AuthErrorBannerProps, AuthFormFieldProps, AuthHeaderProps, AuthLinkProps, AuthOAuthButtonProps, AuthOAuthProvidersProps, AuthPasswordFieldProps, AuthPasswordStrengthIndicatorProps, AuthSubmitButtonProps, AuthVerificationCodeInputProps, BaseAppearance, ConditionalProps, ForgotPasswordAppearance, ForgotPasswordFormProps, ProtectProps, ResetPasswordAppearance, ResetPasswordFormProps, SignInAppearance, SignInFormProps, SignInProps, SignUpAppearance, SignUpFormProps, SignUpProps, UserButtonProps, VerifyEmailStatusProps } from './types.js';
8
+ export { AuthConfig, EmailVerificationMethod } from './types.js';
8
9
  import { CreateSessionResponse, CreateUserResponse, ResetPasswordResponse, GetPublicAuthConfigResponse } from '@insforge/shared-schemas';
9
10
  export { useAuth, usePublicAuthConfig, useUser } from './hooks.js';
10
- export { checkPasswordStrength, cn, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.js';
11
+ export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, validateEmail, validatePassword } from './lib.js';
11
12
  export { getInsforgeRoutes } from './router.js';
12
- import 'clsx';
13
13
  import 'zod';
14
14
  import 'react-router-dom';
15
15
 
@@ -34,16 +34,35 @@ 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: (token: string) => Promise<{
46
+ verifyEmail: (otp: string, email?: string) => Promise<{
43
47
  accessToken: string;
44
- user?: any;
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
  }
@@ -51,8 +70,8 @@ interface InsforgeProviderProps {
51
70
  children: ReactNode;
52
71
  baseUrl: string;
53
72
  onAuthChange?: (user: InsforgeUser | null) => void;
54
- syncTokenToCookie?: (token: string) => Promise<boolean>;
55
- clearCookie?: () => Promise<void>;
73
+ onSignIn?: (authToken: string) => Promise<void>;
74
+ onSignOut?: () => Promise<void>;
56
75
  }
57
76
  /**
58
77
  * Unified Insforge Provider - manages authentication state and configuration
@@ -79,22 +98,18 @@ interface InsforgeProviderProps {
79
98
  * // With cookie sync (Next.js optimization)
80
99
  * <InsforgeProvider
81
100
  * baseUrl={baseUrl}
82
- * syncTokenToCookie={async (token) => {
83
- * await fetch('/api/auth', {
84
- * method: 'POST',
85
- * body: JSON.stringify({ token })
86
- * });
87
- * return true;
101
+ * onSignIn={async (authToken) => {
102
+ * await signIn(authToken);
88
103
  * }}
89
- * clearCookie={async () => {
90
- * await fetch('/api/auth', { method: 'DELETE' });
104
+ * onSignOut={async () => {
105
+ * await signOut();
91
106
  * }}
92
107
  * >
93
108
  * {children}
94
109
  * </InsforgeProvider>
95
110
  * ```
96
111
  */
97
- declare function InsforgeProvider({ children, baseUrl, onAuthChange, syncTokenToCookie, clearCookie, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
112
+ declare function InsforgeProvider({ children, baseUrl, onAuthChange, onSignIn, onSignOut, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
98
113
  /**
99
114
  * Hook to access Insforge context
100
115
  *