@insforge/react 0.6.10 → 0.7.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.js.map +1 -1
- package/dist/components.cjs +23 -8
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +26 -1
- package/dist/components.d.ts +26 -1
- package/dist/components.js +23 -9
- 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 +31 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
|
|
1
|
+
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
|
|
2
2
|
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
|
|
3
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';
|
|
@@ -34,6 +34,13 @@ interface InsforgeProviderProps {
|
|
|
34
34
|
* @internal - Not intended for public use, used by Next.js package
|
|
35
35
|
*/
|
|
36
36
|
initialState?: InitialAuthState;
|
|
37
|
+
/**
|
|
38
|
+
* Internal use only - enables hosted auth mode for centralized auth pages.
|
|
39
|
+
* When true, disables automatic redirects to prevent security issues.
|
|
40
|
+
* @internal - Never set to true in user applications
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
hostedMode?: boolean;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -73,7 +80,7 @@ interface InsforgeProviderProps {
|
|
|
73
80
|
* </InsforgeProvider>
|
|
74
81
|
* ```
|
|
75
82
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, hostedMode, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
84
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
85
|
/**
|
|
79
86
|
* Hook to access Insforge context
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.js';
|
|
1
|
+
export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.js';
|
|
2
2
|
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
|
|
3
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';
|
|
@@ -34,6 +34,13 @@ interface InsforgeProviderProps {
|
|
|
34
34
|
* @internal - Not intended for public use, used by Next.js package
|
|
35
35
|
*/
|
|
36
36
|
initialState?: InitialAuthState;
|
|
37
|
+
/**
|
|
38
|
+
* Internal use only - enables hosted auth mode for centralized auth pages.
|
|
39
|
+
* When true, disables automatic redirects to prevent security issues.
|
|
40
|
+
* @internal - Never set to true in user applications
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
hostedMode?: boolean;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Unified Insforge Provider - manages authentication state and configuration
|
|
@@ -73,7 +80,7 @@ interface InsforgeProviderProps {
|
|
|
73
80
|
* </InsforgeProvider>
|
|
74
81
|
* ```
|
|
75
82
|
*/
|
|
76
|
-
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
declare function InsforgeProviderCore({ children, baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, initialState, hostedMode, }: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
84
|
declare function InsforgeProvider(props: InsforgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
78
85
|
/**
|
|
79
86
|
* Hook to access Insforge context
|
package/dist/index.js
CHANGED
|
@@ -464,6 +464,9 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
464
464
|
// Handle auth redirect after successful authentication
|
|
465
465
|
// Works for all auth sources: OAuth providers, cloud hosting sign-in, email verification
|
|
466
466
|
handleAuthRedirect(isLoaded, user) {
|
|
467
|
+
if (this.config.hostedMode) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
467
470
|
if (!isLoaded || this.hasProcessedCallbackRef) {
|
|
468
471
|
return false;
|
|
469
472
|
}
|
|
@@ -507,7 +510,8 @@ function InsforgeProviderCore({
|
|
|
507
510
|
onAuthChange,
|
|
508
511
|
onSignIn,
|
|
509
512
|
onSignOut,
|
|
510
|
-
initialState
|
|
513
|
+
initialState,
|
|
514
|
+
hostedMode = false
|
|
511
515
|
}) {
|
|
512
516
|
const manager = useMemo(
|
|
513
517
|
() => InsforgeManager.getInstance({
|
|
@@ -515,9 +519,10 @@ function InsforgeProviderCore({
|
|
|
515
519
|
afterSignInUrl,
|
|
516
520
|
onAuthChange,
|
|
517
521
|
onSignIn,
|
|
518
|
-
onSignOut
|
|
522
|
+
onSignOut,
|
|
523
|
+
hostedMode
|
|
519
524
|
}),
|
|
520
|
-
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut]
|
|
525
|
+
[baseUrl, afterSignInUrl, onAuthChange, onSignIn, onSignOut, hostedMode]
|
|
521
526
|
);
|
|
522
527
|
if (initialState) {
|
|
523
528
|
const currentState = manager.getState();
|
|
@@ -3128,6 +3133,25 @@ function VerifyEmail({ token, onSuccess, onError, ...uiProps }) {
|
|
|
3128
3133
|
}, [token, verifyEmail, onSuccess, onError]);
|
|
3129
3134
|
return /* @__PURE__ */ jsx(VerifyEmailStatus, { status, error, ...uiProps });
|
|
3130
3135
|
}
|
|
3136
|
+
function SignOutButton({ children, className, afterSignOutUrl = "/" }) {
|
|
3137
|
+
const { signOut } = useInsforge();
|
|
3138
|
+
const handleClick = async () => {
|
|
3139
|
+
await signOut();
|
|
3140
|
+
window.location.href = afterSignOutUrl;
|
|
3141
|
+
};
|
|
3142
|
+
if (children && isValidElement(children)) {
|
|
3143
|
+
const originalOnClick = children.props?.onClick;
|
|
3144
|
+
return cloneElement(children, {
|
|
3145
|
+
onClick: async (e) => {
|
|
3146
|
+
await handleClick();
|
|
3147
|
+
if (originalOnClick) {
|
|
3148
|
+
originalOnClick(e);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
});
|
|
3152
|
+
}
|
|
3153
|
+
return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: () => void handleClick(), children: children || "Sign out" });
|
|
3154
|
+
}
|
|
3131
3155
|
var UserButtonContainer = styled.div`
|
|
3132
3156
|
position: relative;
|
|
3133
3157
|
display: inline-block;
|
|
@@ -3243,7 +3267,7 @@ var UserButtonMenuItemIcon = styled.div`
|
|
|
3243
3267
|
}
|
|
3244
3268
|
`;
|
|
3245
3269
|
function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
3246
|
-
const { user
|
|
3270
|
+
const { user } = useInsforge();
|
|
3247
3271
|
const [isOpen, setIsOpen] = useState(false);
|
|
3248
3272
|
const [imageError, setImageError] = useState(false);
|
|
3249
3273
|
const dropdownRef = useRef(null);
|
|
@@ -3284,11 +3308,6 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
3284
3308
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
3285
3309
|
};
|
|
3286
3310
|
}, [isOpen]);
|
|
3287
|
-
async function handleSignOut() {
|
|
3288
|
-
await signOut();
|
|
3289
|
-
setIsOpen(false);
|
|
3290
|
-
window.location.href = afterSignOutUrl;
|
|
3291
|
-
}
|
|
3292
3311
|
if (!user) {
|
|
3293
3312
|
return null;
|
|
3294
3313
|
}
|
|
@@ -3317,10 +3336,10 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
3317
3336
|
]
|
|
3318
3337
|
}
|
|
3319
3338
|
),
|
|
3320
|
-
isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () =>
|
|
3339
|
+
isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
|
|
3321
3340
|
/* @__PURE__ */ jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsx(LogOut, {}) }),
|
|
3322
3341
|
"Sign out"
|
|
3323
|
-
] }) })
|
|
3342
|
+
] }) }) })
|
|
3324
3343
|
] });
|
|
3325
3344
|
}
|
|
3326
3345
|
function Protect({
|
|
@@ -3429,6 +3448,6 @@ function useUser() {
|
|
|
3429
3448
|
return { user, isLoaded, updateUser, setUser };
|
|
3430
3449
|
}
|
|
3431
3450
|
|
|
3432
|
-
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, BrowserNavigationAdapter, ForgotPassword, ForgotPasswordForm, InsforgeProvider, InsforgeProviderCore, NavigationProvider, OAUTH_PROVIDER_CONFIG, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, StyleProvider, UserButton, VerifyEmail, VerifyEmailStatus, checkPasswordStrength, createPasswordSchema, emailSchema, getAllProviderConfigs, getProviderConfig, passwordSchema, resolveAuthPath, resolveAuthUrl, theme, useAuth, useInsforge, useNavigationAdapter, usePublicAuthConfig, useSearchParams, useUser, validateEmail, validatePassword };
|
|
3451
|
+
export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, BrowserNavigationAdapter, ForgotPassword, ForgotPasswordForm, InsforgeProvider, InsforgeProviderCore, NavigationProvider, OAUTH_PROVIDER_CONFIG, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignOutButton, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, StyleProvider, UserButton, VerifyEmail, VerifyEmailStatus, checkPasswordStrength, createPasswordSchema, emailSchema, getAllProviderConfigs, getProviderConfig, passwordSchema, resolveAuthPath, resolveAuthUrl, theme, useAuth, useInsforge, useNavigationAdapter, usePublicAuthConfig, useSearchParams, useUser, validateEmail, validatePassword };
|
|
3433
3452
|
//# sourceMappingURL=index.js.map
|
|
3434
3453
|
//# sourceMappingURL=index.js.map
|