@insforge/react 1.0.9-dev.0 → 1.0.9-dev.3
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/components.cjs +39 -13
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +5 -6
- package/dist/components.d.ts +5 -6
- package/dist/components.js +39 -13
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +39 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/components.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { InsforgeUser } from '@insforge/shared';
|
|
3
2
|
import { VerifyEmailResponse } from '@insforge/shared-schemas';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
+
import { InsforgeUser } from '@insforge/shared';
|
|
5
6
|
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
|
|
6
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';
|
|
7
8
|
import './types.cjs';
|
|
@@ -21,7 +22,6 @@ interface SignInProps {
|
|
|
21
22
|
signUpLinkText?: string;
|
|
22
23
|
signUpUrl?: string;
|
|
23
24
|
dividerText?: string;
|
|
24
|
-
onSuccess?: (accessToken: string, user: InsforgeUser, csrfToken?: string | null) => void;
|
|
25
25
|
onError?: (error: Error) => void;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -35,7 +35,7 @@ interface SignInProps {
|
|
|
35
35
|
* />
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
declare function SignIn({
|
|
38
|
+
declare function SignIn({ onError, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
|
|
39
39
|
|
|
40
40
|
interface SignUpProps {
|
|
41
41
|
title?: string;
|
|
@@ -50,7 +50,6 @@ interface SignUpProps {
|
|
|
50
50
|
signInLinkText?: string;
|
|
51
51
|
signInUrl?: string;
|
|
52
52
|
dividerText?: string;
|
|
53
|
-
onSuccess?: (accessToken: string, user: InsforgeUser, csrfToken?: string | null) => void;
|
|
54
53
|
onError?: (error: Error) => void;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
@@ -65,7 +64,7 @@ interface SignUpProps {
|
|
|
65
64
|
*
|
|
66
65
|
* ```
|
|
67
66
|
*/
|
|
68
|
-
declare function SignUp({
|
|
67
|
+
declare function SignUp({ onError, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
|
|
69
68
|
|
|
70
69
|
interface ForgotPasswordProps {
|
|
71
70
|
/** Text customization */
|
|
@@ -186,7 +185,7 @@ interface UserProfileModalProps {
|
|
|
186
185
|
* User profile modal component.
|
|
187
186
|
* Displays user profile information with edit capability for name.
|
|
188
187
|
*/
|
|
189
|
-
declare function UserProfileModal({ onClose, onError }: UserProfileModalProps):
|
|
188
|
+
declare function UserProfileModal({ onClose, onError }: UserProfileModalProps): react.ReactPortal | null;
|
|
190
189
|
|
|
191
190
|
interface ProtectProps {
|
|
192
191
|
children: ReactNode;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { InsforgeUser } from '@insforge/shared';
|
|
3
2
|
import { VerifyEmailResponse } from '@insforge/shared-schemas';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
+
import { InsforgeUser } from '@insforge/shared';
|
|
5
6
|
export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
|
|
6
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';
|
|
7
8
|
import './types.js';
|
|
@@ -21,7 +22,6 @@ interface SignInProps {
|
|
|
21
22
|
signUpLinkText?: string;
|
|
22
23
|
signUpUrl?: string;
|
|
23
24
|
dividerText?: string;
|
|
24
|
-
onSuccess?: (accessToken: string, user: InsforgeUser, csrfToken?: string | null) => void;
|
|
25
25
|
onError?: (error: Error) => void;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -35,7 +35,7 @@ interface SignInProps {
|
|
|
35
35
|
* />
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
declare function SignIn({
|
|
38
|
+
declare function SignIn({ onError, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
|
|
39
39
|
|
|
40
40
|
interface SignUpProps {
|
|
41
41
|
title?: string;
|
|
@@ -50,7 +50,6 @@ interface SignUpProps {
|
|
|
50
50
|
signInLinkText?: string;
|
|
51
51
|
signInUrl?: string;
|
|
52
52
|
dividerText?: string;
|
|
53
|
-
onSuccess?: (accessToken: string, user: InsforgeUser, csrfToken?: string | null) => void;
|
|
54
53
|
onError?: (error: Error) => void;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
@@ -65,7 +64,7 @@ interface SignUpProps {
|
|
|
65
64
|
*
|
|
66
65
|
* ```
|
|
67
66
|
*/
|
|
68
|
-
declare function SignUp({
|
|
67
|
+
declare function SignUp({ onError, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
|
|
69
68
|
|
|
70
69
|
interface ForgotPasswordProps {
|
|
71
70
|
/** Text customization */
|
|
@@ -186,7 +185,7 @@ interface UserProfileModalProps {
|
|
|
186
185
|
* User profile modal component.
|
|
187
186
|
* Displays user profile information with edit capability for name.
|
|
188
187
|
*/
|
|
189
|
-
declare function UserProfileModal({ onClose, onError }: UserProfileModalProps):
|
|
188
|
+
declare function UserProfileModal({ onClose, onError }: UserProfileModalProps): react.ReactPortal | null;
|
|
190
189
|
|
|
191
190
|
interface ProtectProps {
|
|
192
191
|
children: ReactNode;
|
package/dist/components.js
CHANGED
|
@@ -4,6 +4,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
import { InsforgeContext } from '@insforge/shared/react';
|
|
5
5
|
import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, X, User, LogOut } from 'lucide-react';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
7
8
|
|
|
8
9
|
var __create = Object.create;
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
@@ -3624,7 +3625,7 @@ function SignInForm({
|
|
|
3624
3625
|
] })
|
|
3625
3626
|
] });
|
|
3626
3627
|
}
|
|
3627
|
-
function SignIn({
|
|
3628
|
+
function SignIn({ onError, ...uiProps }) {
|
|
3628
3629
|
const { signIn, verifyEmail, loginWithOAuth } = useInsforge();
|
|
3629
3630
|
const { authConfig } = usePublicAuthConfig();
|
|
3630
3631
|
const [email, setEmail] = useState("");
|
|
@@ -3649,12 +3650,18 @@ function SignIn({ onSuccess, onError, ...uiProps }) {
|
|
|
3649
3650
|
}
|
|
3650
3651
|
throw new Error(result.error);
|
|
3651
3652
|
}
|
|
3652
|
-
const {
|
|
3653
|
-
if (
|
|
3654
|
-
|
|
3653
|
+
const { user, accessToken, redirectTo, csrfToken } = result;
|
|
3654
|
+
if (user) {
|
|
3655
|
+
const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
|
|
3656
|
+
finalUrl.searchParams.set("access_token", accessToken);
|
|
3657
|
+
finalUrl.searchParams.set("user_id", user.id);
|
|
3658
|
+
finalUrl.searchParams.set("email", user.email);
|
|
3659
|
+
finalUrl.searchParams.set("name", user.profile?.name || "");
|
|
3660
|
+
if (csrfToken) {
|
|
3661
|
+
finalUrl.searchParams.set("csrf_token", csrfToken);
|
|
3662
|
+
}
|
|
3663
|
+
window.location.href = finalUrl.toString();
|
|
3655
3664
|
}
|
|
3656
|
-
const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
|
|
3657
|
-
window.location.href = finalUrl.toString();
|
|
3658
3665
|
} catch (err) {
|
|
3659
3666
|
const errorMessage = err instanceof Error ? err.message : "Sign in failed";
|
|
3660
3667
|
setError(errorMessage);
|
|
@@ -3673,6 +3680,13 @@ function SignIn({ onSuccess, onError, ...uiProps }) {
|
|
|
3673
3680
|
throw new Error("Verification failed");
|
|
3674
3681
|
}
|
|
3675
3682
|
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
3683
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
3684
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
3685
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
3686
|
+
finalUrl.searchParams.set("name", result.user.profile?.name || "");
|
|
3687
|
+
if (result.csrfToken) {
|
|
3688
|
+
finalUrl.searchParams.set("csrf_token", result.csrfToken);
|
|
3689
|
+
}
|
|
3676
3690
|
window.location.href = finalUrl.toString();
|
|
3677
3691
|
} catch (err) {
|
|
3678
3692
|
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
@@ -3832,7 +3846,7 @@ function createPasswordSchema(options) {
|
|
|
3832
3846
|
return schema;
|
|
3833
3847
|
}
|
|
3834
3848
|
createPasswordSchema();
|
|
3835
|
-
function SignUp({
|
|
3849
|
+
function SignUp({ onError, ...uiProps }) {
|
|
3836
3850
|
const { signUp, verifyEmail, loginWithOAuth } = useInsforge();
|
|
3837
3851
|
const { authConfig } = usePublicAuthConfig();
|
|
3838
3852
|
const [email, setEmail] = useState("");
|
|
@@ -3883,12 +3897,16 @@ function SignUp({ onSuccess, onError, ...uiProps }) {
|
|
|
3883
3897
|
setLoading(false);
|
|
3884
3898
|
return;
|
|
3885
3899
|
}
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3900
|
+
if (result.accessToken && result.user) {
|
|
3901
|
+
const csrfToken = result.csrfToken;
|
|
3902
|
+
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
3903
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
3904
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
3905
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
3906
|
+
finalUrl.searchParams.set("name", result.user.profile?.name || "");
|
|
3907
|
+
if (csrfToken) {
|
|
3908
|
+
finalUrl.searchParams.set("csrf_token", csrfToken);
|
|
3890
3909
|
}
|
|
3891
|
-
const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
|
|
3892
3910
|
window.location.href = finalUrl.toString();
|
|
3893
3911
|
}
|
|
3894
3912
|
} catch (err) {
|
|
@@ -3909,6 +3927,13 @@ function SignUp({ onSuccess, onError, ...uiProps }) {
|
|
|
3909
3927
|
throw new Error("Verification failed");
|
|
3910
3928
|
}
|
|
3911
3929
|
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
3930
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
3931
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
3932
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
3933
|
+
finalUrl.searchParams.set("name", result.user.profile?.name || "");
|
|
3934
|
+
if (result.csrfToken) {
|
|
3935
|
+
finalUrl.searchParams.set("csrf_token", result.csrfToken);
|
|
3936
|
+
}
|
|
3912
3937
|
window.location.href = finalUrl.toString();
|
|
3913
3938
|
} catch (err) {
|
|
3914
3939
|
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
@@ -4926,7 +4951,7 @@ function UserProfileModal({ onClose, onError }) {
|
|
|
4926
4951
|
return null;
|
|
4927
4952
|
}
|
|
4928
4953
|
const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
4929
|
-
|
|
4954
|
+
const modalContent = /* @__PURE__ */ jsx(ProfileModalOverlay, { onClick: handleOverlayClick, children: /* @__PURE__ */ jsxs(ProfileModalContainer, { onClick: (e) => e.stopPropagation(), children: [
|
|
4930
4955
|
/* @__PURE__ */ jsxs(ProfileModalHeader, { children: [
|
|
4931
4956
|
/* @__PURE__ */ jsx(ProfileModalTitle, { children: "Profile" }),
|
|
4932
4957
|
/* @__PURE__ */ jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(X, {}) })
|
|
@@ -4968,6 +4993,7 @@ function UserProfileModal({ onClose, onError }) {
|
|
|
4968
4993
|
] })
|
|
4969
4994
|
] }) : /* @__PURE__ */ jsx(ProfileButton, { $primary: true, onClick: () => setIsEditing(true), children: "Edit Profile" }) })
|
|
4970
4995
|
] }) });
|
|
4996
|
+
return createPortal(modalContent, document.body);
|
|
4971
4997
|
}
|
|
4972
4998
|
function UserButton({
|
|
4973
4999
|
afterSignOutUrl = "/",
|