@insforge/react 1.1.1-dev.0 → 1.1.1
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/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +3 -5
- package/dist/atoms.d.ts +3 -5
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs.map +1 -1
- 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 +36 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -11
- package/dist/index.d.ts +2 -11
- package/dist/index.js +37 -45
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, UserProfileModal, UserProfileModalProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
|
|
2
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';
|
|
3
|
+
export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthEmailVerificationStepProps, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthResetPasswordVerificationStepProps, 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 { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
|
|
7
|
-
export {
|
|
7
|
+
export { InsforgeContextValue, InsforgeUser, OAuthProvider } from '@insforge/shared';
|
|
8
8
|
import { InsForgeClient } from '@insforge/sdk';
|
|
9
9
|
export { useAuth, usePublicAuthConfig, useUser } from './hooks.cjs';
|
|
10
10
|
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword } from './lib.cjs';
|
|
@@ -51,15 +51,6 @@ interface InsforgeProviderProps {
|
|
|
51
51
|
* Uses singleton InsforgeManager to manage state across packages.
|
|
52
52
|
* Context only subscribes to Manager and triggers React re-renders.
|
|
53
53
|
*
|
|
54
|
-
* Architecture (pattern learned from Clerk):
|
|
55
|
-
* - InsforgeMethodsContext: Stable method references (NEVER change)
|
|
56
|
-
* - InsforgeAuthStateContext: Reactive auth state (changes on sign in/out)
|
|
57
|
-
* - InsforgeConfigContext: Static configuration values
|
|
58
|
-
* - InsforgeContext: Combined context for backward compatibility
|
|
59
|
-
*
|
|
60
|
-
* This architecture prevents useEffect re-runs when auth state changes,
|
|
61
|
-
* solving the "duplicate request" bug in components like VerifyEmail.
|
|
62
|
-
*
|
|
63
54
|
* @example
|
|
64
55
|
* ```tsx
|
|
65
56
|
* // Basic usage (React/Vite)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, UserProfileModal, UserProfileModalProps, VerifyEmail, VerifyEmailProps } from './components.js';
|
|
2
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';
|
|
3
|
+
export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthEmailVerificationStepProps, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthResetPasswordVerificationStepProps, 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 { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
|
|
7
|
-
export {
|
|
7
|
+
export { InsforgeContextValue, InsforgeUser, OAuthProvider } from '@insforge/shared';
|
|
8
8
|
import { InsForgeClient } from '@insforge/sdk';
|
|
9
9
|
export { useAuth, usePublicAuthConfig, useUser } from './hooks.js';
|
|
10
10
|
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword } from './lib.js';
|
|
@@ -51,15 +51,6 @@ interface InsforgeProviderProps {
|
|
|
51
51
|
* Uses singleton InsforgeManager to manage state across packages.
|
|
52
52
|
* Context only subscribes to Manager and triggers React re-renders.
|
|
53
53
|
*
|
|
54
|
-
* Architecture (pattern learned from Clerk):
|
|
55
|
-
* - InsforgeMethodsContext: Stable method references (NEVER change)
|
|
56
|
-
* - InsforgeAuthStateContext: Reactive auth state (changes on sign in/out)
|
|
57
|
-
* - InsforgeConfigContext: Static configuration values
|
|
58
|
-
* - InsforgeContext: Combined context for backward compatibility
|
|
59
|
-
*
|
|
60
|
-
* This architecture prevents useEffect re-runs when auth state changes,
|
|
61
|
-
* solving the "duplicate request" bug in components like VerifyEmail.
|
|
62
|
-
*
|
|
63
54
|
* @example
|
|
64
55
|
* ```tsx
|
|
65
56
|
* // Basic usage (React/Vite)
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|
|
15
15
|
import * as React2 from 'react';
|
|
16
16
|
import { createContext, forwardRef, useContext, useState, useMemo, useEffect, useRef, useCallback, isValidElement, cloneElement } from 'react';
|
|
17
17
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
18
|
-
import {
|
|
18
|
+
import { InsforgeContext } from '@insforge/shared/react';
|
|
19
19
|
import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, X, User, LogOut } from 'lucide-react';
|
|
20
20
|
import { z } from 'zod';
|
|
21
21
|
import { createPortal } from 'react-dom';
|
|
@@ -545,8 +545,8 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
545
545
|
this.listeners.forEach((listener) => listener(state));
|
|
546
546
|
}
|
|
547
547
|
// Load auth state
|
|
548
|
-
//
|
|
549
|
-
// Called after hydration to
|
|
548
|
+
// This loads the FULL user data from SDK (including complete profile)
|
|
549
|
+
// Called after hydration to get complete user information beyond what's in cookies
|
|
550
550
|
async loadAuthState() {
|
|
551
551
|
try {
|
|
552
552
|
const {
|
|
@@ -570,18 +570,30 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
this.
|
|
573
|
+
const userResult = await this.sdk.auth.getCurrentUser();
|
|
574
|
+
if (userResult.data) {
|
|
575
|
+
const userData = {
|
|
576
|
+
id: userResult.data.user.id,
|
|
577
|
+
email: userResult.data.user.email,
|
|
578
|
+
profile: userResult.data.user.profile
|
|
579
|
+
};
|
|
580
|
+
this.user = userData;
|
|
581
|
+
if (this.config.onAuthChange) {
|
|
582
|
+
this.config.onAuthChange(userData);
|
|
583
|
+
}
|
|
584
|
+
this.isLoaded = true;
|
|
585
|
+
this.notifyListeners();
|
|
586
|
+
return { success: true };
|
|
587
|
+
} else {
|
|
588
|
+
this.user = null;
|
|
589
|
+
if (this.config.onAuthChange) {
|
|
590
|
+
this.config.onAuthChange(null);
|
|
591
|
+
}
|
|
592
|
+
this.isLoaded = true;
|
|
593
|
+
this.notifyListeners();
|
|
594
|
+
const errorMessage = userResult.error?.message ?? "failed_to_get_user";
|
|
595
|
+
return { success: false, error: errorMessage };
|
|
581
596
|
}
|
|
582
|
-
this.isLoaded = true;
|
|
583
|
-
this.notifyListeners();
|
|
584
|
-
return { success: true };
|
|
585
597
|
} catch (error) {
|
|
586
598
|
this.user = null;
|
|
587
599
|
if (this.config.onAuthChange) {
|
|
@@ -2179,8 +2191,14 @@ function InsforgeProviderCore({
|
|
|
2179
2191
|
unsubscribe();
|
|
2180
2192
|
};
|
|
2181
2193
|
}, [manager]);
|
|
2182
|
-
const
|
|
2194
|
+
const contextValue = useMemo(
|
|
2183
2195
|
() => ({
|
|
2196
|
+
// State from Manager
|
|
2197
|
+
user: state.user,
|
|
2198
|
+
userId: state.userId,
|
|
2199
|
+
isLoaded: state.isLoaded,
|
|
2200
|
+
isSignedIn: state.isSignedIn,
|
|
2201
|
+
// Methods delegated to Manager
|
|
2184
2202
|
setUser: (user) => manager.setUser(user),
|
|
2185
2203
|
signIn: (email, password) => manager.signIn(email, password),
|
|
2186
2204
|
signUp: (email, password) => manager.signUp(email, password),
|
|
@@ -2193,40 +2211,14 @@ function InsforgeProviderCore({
|
|
|
2193
2211
|
verifyEmail: (otp, email) => manager.verifyEmail(otp, email),
|
|
2194
2212
|
exchangeResetPasswordToken: (email, code) => manager.exchangeResetPasswordToken(email, code),
|
|
2195
2213
|
loginWithOAuth: (provider, redirectTo) => manager.loginWithOAuth(provider, redirectTo),
|
|
2196
|
-
getPublicAuthConfig: () => manager.getPublicAuthConfig()
|
|
2197
|
-
|
|
2198
|
-
[manager]
|
|
2199
|
-
// Only depends on manager (stable)
|
|
2200
|
-
);
|
|
2201
|
-
const stableConfig = useMemo(
|
|
2202
|
-
() => ({
|
|
2214
|
+
getPublicAuthConfig: () => manager.getPublicAuthConfig(),
|
|
2215
|
+
// Config
|
|
2203
2216
|
baseUrl: manager.getConfig().client.getHttpClient().baseUrl,
|
|
2204
2217
|
afterSignInUrl: manager.getConfig().afterSignInUrl || "/"
|
|
2205
2218
|
}),
|
|
2206
|
-
[manager]
|
|
2207
|
-
// Only depends on manager (stable)
|
|
2208
|
-
);
|
|
2209
|
-
const authState = useMemo(
|
|
2210
|
-
() => ({
|
|
2211
|
-
user: state.user,
|
|
2212
|
-
userId: state.userId,
|
|
2213
|
-
isLoaded: state.isLoaded,
|
|
2214
|
-
isSignedIn: state.isSignedIn
|
|
2215
|
-
}),
|
|
2216
|
-
[state.user, state.userId, state.isLoaded, state.isSignedIn]
|
|
2217
|
-
);
|
|
2218
|
-
const contextValue = useMemo(
|
|
2219
|
-
() => ({
|
|
2220
|
-
// Reactive state
|
|
2221
|
-
...authState,
|
|
2222
|
-
// Stable methods (references don't change!)
|
|
2223
|
-
...stableMethods,
|
|
2224
|
-
// Stable config
|
|
2225
|
-
...stableConfig
|
|
2226
|
-
}),
|
|
2227
|
-
[authState, stableMethods, stableConfig]
|
|
2219
|
+
[state, manager]
|
|
2228
2220
|
);
|
|
2229
|
-
return /* @__PURE__ */ jsx(
|
|
2221
|
+
return /* @__PURE__ */ jsx(InsforgeContext.Provider, { value: contextValue, children });
|
|
2230
2222
|
}
|
|
2231
2223
|
function InsforgeProvider(props) {
|
|
2232
2224
|
return /* @__PURE__ */ jsx(StyleProvider, { children: /* @__PURE__ */ jsx(NavigationProvider, { adapter: BrowserNavigationAdapter, children: /* @__PURE__ */ jsx(InsforgeProviderCore, { ...props }) }) });
|