@better-auth-ui/react 1.6.0
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/auth/auth-provider.d.ts +32 -0
- package/dist/components/auth/auth-provider.js +44 -0
- package/dist/components/email/email-changed.d.ts +97 -0
- package/dist/components/email/email-changed.js +70 -0
- package/dist/components/email/email-localization.d.ts +61 -0
- package/dist/components/email/email-localization.js +24 -0
- package/dist/components/email/email-styles.d.ts +89 -0
- package/dist/components/email/email-styles.js +129 -0
- package/dist/components/email/email-verification.d.ts +97 -0
- package/dist/components/email/email-verification.js +75 -0
- package/dist/components/email/index.d.ts +9 -0
- package/dist/components/email/index.js +9 -0
- package/dist/components/email/magic-link.d.ts +93 -0
- package/dist/components/email/magic-link.js +72 -0
- package/dist/components/email/new-device.d.ts +123 -0
- package/dist/components/email/new-device.js +90 -0
- package/dist/components/email/otp-email.d.ts +88 -0
- package/dist/components/email/otp-email.js +65 -0
- package/dist/components/email/password-changed.d.ts +96 -0
- package/dist/components/email/password-changed.js +76 -0
- package/dist/components/email/reset-password.d.ts +90 -0
- package/dist/components/email/reset-password.js +68 -0
- package/dist/components/icons/apple.d.ts +8 -0
- package/dist/components/icons/apple.js +10 -0
- package/dist/components/icons/atlassian.d.ts +10 -0
- package/dist/components/icons/atlassian.js +14 -0
- package/dist/components/icons/cognito.d.ts +8 -0
- package/dist/components/icons/cognito.js +10 -0
- package/dist/components/icons/discord.d.ts +8 -0
- package/dist/components/icons/discord.js +10 -0
- package/dist/components/icons/dropbox.d.ts +8 -0
- package/dist/components/icons/dropbox.js +10 -0
- package/dist/components/icons/facebook.d.ts +10 -0
- package/dist/components/icons/facebook.js +12 -0
- package/dist/components/icons/figma.d.ts +11 -0
- package/dist/components/icons/figma.js +13 -0
- package/dist/components/icons/github.d.ts +10 -0
- package/dist/components/icons/github.js +12 -0
- package/dist/components/icons/gitlab.d.ts +8 -0
- package/dist/components/icons/gitlab.js +10 -0
- package/dist/components/icons/google.d.ts +8 -0
- package/dist/components/icons/google.js +10 -0
- package/dist/components/icons/huggingface.d.ts +8 -0
- package/dist/components/icons/huggingface.js +10 -0
- package/dist/components/icons/index.d.ts +35 -0
- package/dist/components/icons/index.js +35 -0
- package/dist/components/icons/kakao.d.ts +10 -0
- package/dist/components/icons/kakao.js +12 -0
- package/dist/components/icons/kick.d.ts +10 -0
- package/dist/components/icons/kick.js +12 -0
- package/dist/components/icons/line.d.ts +8 -0
- package/dist/components/icons/line.js +10 -0
- package/dist/components/icons/linear.d.ts +8 -0
- package/dist/components/icons/linear.js +10 -0
- package/dist/components/icons/linkedin.d.ts +8 -0
- package/dist/components/icons/linkedin.js +10 -0
- package/dist/components/icons/microsoft.d.ts +8 -0
- package/dist/components/icons/microsoft.js +10 -0
- package/dist/components/icons/naver.d.ts +8 -0
- package/dist/components/icons/naver.js +10 -0
- package/dist/components/icons/notion.d.ts +8 -0
- package/dist/components/icons/notion.js +10 -0
- package/dist/components/icons/paybin.d.ts +7 -0
- package/dist/components/icons/paybin.js +9 -0
- package/dist/components/icons/paypal.d.ts +8 -0
- package/dist/components/icons/paypal.js +10 -0
- package/dist/components/icons/polar.d.ts +8 -0
- package/dist/components/icons/polar.js +10 -0
- package/dist/components/icons/railway.d.ts +8 -0
- package/dist/components/icons/railway.js +10 -0
- package/dist/components/icons/reddit.d.ts +8 -0
- package/dist/components/icons/reddit.js +10 -0
- package/dist/components/icons/roblox.d.ts +11 -0
- package/dist/components/icons/roblox.js +13 -0
- package/dist/components/icons/salesforce.d.ts +8 -0
- package/dist/components/icons/salesforce.js +10 -0
- package/dist/components/icons/slack.d.ts +8 -0
- package/dist/components/icons/slack.js +10 -0
- package/dist/components/icons/spotify.d.ts +8 -0
- package/dist/components/icons/spotify.js +10 -0
- package/dist/components/icons/tiktok.d.ts +9 -0
- package/dist/components/icons/tiktok.js +11 -0
- package/dist/components/icons/twitch.d.ts +8 -0
- package/dist/components/icons/twitch.js +13 -0
- package/dist/components/icons/vercel.d.ts +8 -0
- package/dist/components/icons/vercel.js +10 -0
- package/dist/components/icons/vk.d.ts +8 -0
- package/dist/components/icons/vk.js +10 -0
- package/dist/components/icons/wechat.d.ts +8 -0
- package/dist/components/icons/wechat.js +10 -0
- package/dist/components/icons/x.d.ts +8 -0
- package/dist/components/icons/x.js +10 -0
- package/dist/components/icons/zoom.d.ts +8 -0
- package/dist/components/icons/zoom.js +12 -0
- package/dist/components/settings/account/theme-preview.d.ts +3 -0
- package/dist/components/settings/account/theme-preview.js +10 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/hooks/auth/use-auth-mutation.d.ts +18 -0
- package/dist/hooks/auth/use-auth-mutation.js +10 -0
- package/dist/hooks/auth/use-auth-query.d.ts +24 -0
- package/dist/hooks/auth/use-auth-query.js +10 -0
- package/dist/hooks/auth/use-authenticate.d.ts +9 -0
- package/dist/hooks/auth/use-authenticate.js +28 -0
- package/dist/hooks/auth/use-forgot-password.d.ts +20 -0
- package/dist/hooks/auth/use-forgot-password.js +14 -0
- package/dist/hooks/auth/use-request-password-reset.d.ts +26 -0
- package/dist/hooks/auth/use-request-password-reset.js +14 -0
- package/dist/hooks/auth/use-reset-password.d.ts +40 -0
- package/dist/hooks/auth/use-reset-password.js +13 -0
- package/dist/hooks/auth/use-send-verification-email.d.ts +24 -0
- package/dist/hooks/auth/use-send-verification-email.js +13 -0
- package/dist/hooks/auth/use-session.d.ts +9 -0
- package/dist/hooks/auth/use-session.js +18 -0
- package/dist/hooks/auth/use-sign-in-email.d.ts +53 -0
- package/dist/hooks/auth/use-sign-in-email.js +24 -0
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +32 -0
- package/dist/hooks/auth/use-sign-in-magic-link.js +13 -0
- package/dist/hooks/auth/use-sign-in-social.d.ts +93 -0
- package/dist/hooks/auth/use-sign-in-social.js +13 -0
- package/dist/hooks/auth/use-sign-out.d.ts +19 -0
- package/dist/hooks/auth/use-sign-out.js +24 -0
- package/dist/hooks/auth/use-sign-up-email.d.ts +526 -0
- package/dist/hooks/auth/use-sign-up-email.js +24 -0
- package/dist/hooks/auth/use-user.d.ts +513 -0
- package/dist/hooks/auth/use-user.js +14 -0
- package/dist/hooks/settings/use-account-info.d.ts +17 -0
- package/dist/hooks/settings/use-account-info.js +25 -0
- package/dist/hooks/settings/use-change-email.d.ts +24 -0
- package/dist/hooks/settings/use-change-email.js +23 -0
- package/dist/hooks/settings/use-change-password.d.ts +54 -0
- package/dist/hooks/settings/use-change-password.js +11 -0
- package/dist/hooks/settings/use-delete-user.d.ts +42 -0
- package/dist/hooks/settings/use-delete-user.js +11 -0
- package/dist/hooks/settings/use-link-social.d.ts +46 -0
- package/dist/hooks/settings/use-link-social.js +10 -0
- package/dist/hooks/settings/use-list-accounts.d.ts +20 -0
- package/dist/hooks/settings/use-list-accounts.js +23 -0
- package/dist/hooks/settings/use-list-device-sessions.d.ts +11 -0
- package/dist/hooks/settings/use-list-device-sessions.js +22 -0
- package/dist/hooks/settings/use-list-sessions.d.ts +20 -0
- package/dist/hooks/settings/use-list-sessions.js +22 -0
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +19 -0
- package/dist/hooks/settings/use-revoke-multi-session.js +20 -0
- package/dist/hooks/settings/use-revoke-session.d.ts +19 -0
- package/dist/hooks/settings/use-revoke-session.js +21 -0
- package/dist/hooks/settings/use-set-active-session.d.ts +37 -0
- package/dist/hooks/settings/use-set-active-session.js +28 -0
- package/dist/hooks/settings/use-unlink-account.d.ts +21 -0
- package/dist/hooks/settings/use-unlink-account.js +21 -0
- package/dist/hooks/settings/use-update-user.d.ts +11 -0
- package/dist/hooks/settings/use-update-user.js +29 -0
- package/dist/hooks/use-hydrated.d.ts +6 -0
- package/dist/hooks/use-hydrated.js +18 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +33 -0
- package/dist/lib/auth-client.d.ts +1979 -0
- package/dist/lib/auth-client.js +5 -0
- package/dist/lib/auth-config.d.ts +43 -0
- package/dist/lib/auth-config.js +1 -0
- package/dist/lib/auth-context.d.ts +2 -0
- package/dist/lib/auth-context.js +3 -0
- package/dist/lib/auth-hook-options.d.ts +8 -0
- package/dist/lib/auth-hook-options.js +1 -0
- package/dist/lib/provider-icons.d.ts +13 -0
- package/dist/lib/provider-icons.js +48 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +64 -0
- package/src/components/auth/auth-provider.tsx +82 -0
- package/src/components/email/email-changed.tsx +381 -0
- package/src/components/email/email-localization.tsx +33 -0
- package/src/components/email/email-styles.tsx +175 -0
- package/src/components/email/email-verification.tsx +350 -0
- package/src/components/email/index.ts +9 -0
- package/src/components/email/magic-link.tsx +349 -0
- package/src/components/email/new-device.tsx +452 -0
- package/src/components/email/otp-email.tsx +321 -0
- package/src/components/email/password-changed.tsx +380 -0
- package/src/components/email/reset-password.tsx +343 -0
- package/src/components/icons/apple.tsx +24 -0
- package/src/components/icons/atlassian.tsx +43 -0
- package/src/components/icons/cognito.tsx +25 -0
- package/src/components/icons/discord.tsx +24 -0
- package/src/components/icons/dropbox.tsx +24 -0
- package/src/components/icons/facebook.tsx +30 -0
- package/src/components/icons/figma.tsx +43 -0
- package/src/components/icons/github.tsx +26 -0
- package/src/components/icons/gitlab.tsx +36 -0
- package/src/components/icons/google.tsx +42 -0
- package/src/components/icons/huggingface.tsx +44 -0
- package/src/components/icons/index.ts +35 -0
- package/src/components/icons/kakao.tsx +26 -0
- package/src/components/icons/kick.tsx +30 -0
- package/src/components/icons/line.tsx +24 -0
- package/src/components/icons/linear.tsx +24 -0
- package/src/components/icons/linkedin.tsx +28 -0
- package/src/components/icons/microsoft.tsx +24 -0
- package/src/components/icons/naver.tsx +24 -0
- package/src/components/icons/notion.tsx +25 -0
- package/src/components/icons/paybin.tsx +37 -0
- package/src/components/icons/paypal.tsx +36 -0
- package/src/components/icons/polar.tsx +31 -0
- package/src/components/icons/railway.tsx +24 -0
- package/src/components/icons/reddit.tsx +25 -0
- package/src/components/icons/roblox.tsx +28 -0
- package/src/components/icons/salesforce.tsx +24 -0
- package/src/components/icons/slack.tsx +36 -0
- package/src/components/icons/spotify.tsx +24 -0
- package/src/components/icons/tiktok.tsx +32 -0
- package/src/components/icons/twitch.tsx +50 -0
- package/src/components/icons/vercel.tsx +21 -0
- package/src/components/icons/vk.tsx +24 -0
- package/src/components/icons/wechat.tsx +24 -0
- package/src/components/icons/x.tsx +24 -0
- package/src/components/icons/zoom.tsx +48 -0
- package/src/components/settings/account/theme-preview.tsx +271 -0
- package/src/core.ts +1 -0
- package/src/hooks/auth/use-auth-mutation.ts +56 -0
- package/src/hooks/auth/use-auth-query.ts +50 -0
- package/src/hooks/auth/use-authenticate.ts +35 -0
- package/src/hooks/auth/use-request-password-reset.ts +24 -0
- package/src/hooks/auth/use-reset-password.ts +23 -0
- package/src/hooks/auth/use-send-verification-email.ts +23 -0
- package/src/hooks/auth/use-session.ts +26 -0
- package/src/hooks/auth/use-sign-in-email.ts +35 -0
- package/src/hooks/auth/use-sign-in-magic-link.ts +23 -0
- package/src/hooks/auth/use-sign-in-social.ts +23 -0
- package/src/hooks/auth/use-sign-out.ts +34 -0
- package/src/hooks/auth/use-sign-up-email.ts +35 -0
- package/src/hooks/auth/use-user.ts +21 -0
- package/src/hooks/settings/use-account-info.ts +30 -0
- package/src/hooks/settings/use-change-email.ts +33 -0
- package/src/hooks/settings/use-change-password.ts +21 -0
- package/src/hooks/settings/use-delete-user.ts +21 -0
- package/src/hooks/settings/use-link-social.ts +19 -0
- package/src/hooks/settings/use-list-accounts.ts +27 -0
- package/src/hooks/settings/use-list-device-sessions.ts +32 -0
- package/src/hooks/settings/use-list-sessions.ts +26 -0
- package/src/hooks/settings/use-revoke-multi-session.ts +30 -0
- package/src/hooks/settings/use-revoke-session.ts +31 -0
- package/src/hooks/settings/use-set-active-session.ts +46 -0
- package/src/hooks/settings/use-unlink-account.ts +31 -0
- package/src/hooks/settings/use-update-user.ts +44 -0
- package/src/index.ts +34 -0
- package/src/lib/auth-client.ts +37 -0
- package/src/lib/auth-config.ts +48 -0
- package/src/lib/auth-context.ts +6 -0
- package/src/lib/provider-icons.ts +90 -0
- package/src/lib/utils.ts +6 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation, useSession } from "@better-auth-ui/react";
|
|
2
|
+
export { useAuthMutation } from "./use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for email/password sign-up.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends an email/password sign-up request and
|
|
7
|
+
* refetches the session on success.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export function useSignUpEmail(options) {
|
|
12
|
+
const { authClient } = useAuth();
|
|
13
|
+
const { refetch } = useSession({ refetchOnMount: false });
|
|
14
|
+
return useAuthMutation({
|
|
15
|
+
authFn: authClient.signUp.email,
|
|
16
|
+
options: {
|
|
17
|
+
...options,
|
|
18
|
+
onSuccess: async (...args) => {
|
|
19
|
+
await refetch();
|
|
20
|
+
await options?.onSuccess?.(...args);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import type { AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthQueryOptions } from "./use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve the current authenticated user.
|
|
5
|
+
*
|
|
6
|
+
* @param options - Options to merge into the React Query configuration for the session query.
|
|
7
|
+
* @returns The React Query result with `data` containing the user object from the session.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useUser(options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>): {
|
|
10
|
+
error: import("better-auth/react").BetterFetchError;
|
|
11
|
+
isError: true;
|
|
12
|
+
isPending: false;
|
|
13
|
+
isLoading: false;
|
|
14
|
+
isLoadingError: false;
|
|
15
|
+
isRefetchError: true;
|
|
16
|
+
isSuccess: false;
|
|
17
|
+
isPlaceholderData: false;
|
|
18
|
+
status: "error";
|
|
19
|
+
dataUpdatedAt: number;
|
|
20
|
+
errorUpdatedAt: number;
|
|
21
|
+
failureCount: number;
|
|
22
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
23
|
+
errorUpdateCount: number;
|
|
24
|
+
isFetched: boolean;
|
|
25
|
+
isFetchedAfterMount: boolean;
|
|
26
|
+
isFetching: boolean;
|
|
27
|
+
isInitialLoading: boolean;
|
|
28
|
+
isPaused: boolean;
|
|
29
|
+
isRefetching: boolean;
|
|
30
|
+
isStale: boolean;
|
|
31
|
+
isEnabled: boolean;
|
|
32
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
33
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
email: string;
|
|
38
|
+
emailVerified: boolean;
|
|
39
|
+
name: string;
|
|
40
|
+
image?: string | null | undefined;
|
|
41
|
+
} & {} & {
|
|
42
|
+
username?: string | null | undefined;
|
|
43
|
+
displayUsername?: string | null | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
46
|
+
id: string;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
updatedAt: Date;
|
|
49
|
+
userId: string;
|
|
50
|
+
expiresAt: Date;
|
|
51
|
+
token: string;
|
|
52
|
+
ipAddress?: string | null | undefined;
|
|
53
|
+
userAgent?: string | null | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
56
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
57
|
+
promise: Promise<{
|
|
58
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
59
|
+
id: string;
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
updatedAt: Date;
|
|
62
|
+
email: string;
|
|
63
|
+
emailVerified: boolean;
|
|
64
|
+
name: string;
|
|
65
|
+
image?: string | null | undefined;
|
|
66
|
+
} & {} & {
|
|
67
|
+
username?: string | null | undefined;
|
|
68
|
+
displayUsername?: string | null | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
71
|
+
id: string;
|
|
72
|
+
createdAt: Date;
|
|
73
|
+
updatedAt: Date;
|
|
74
|
+
userId: string;
|
|
75
|
+
expiresAt: Date;
|
|
76
|
+
token: string;
|
|
77
|
+
ipAddress?: string | null | undefined;
|
|
78
|
+
userAgent?: string | null | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
} | null>;
|
|
81
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
82
|
+
id: string;
|
|
83
|
+
createdAt: Date;
|
|
84
|
+
updatedAt: Date;
|
|
85
|
+
email: string;
|
|
86
|
+
emailVerified: boolean;
|
|
87
|
+
name: string;
|
|
88
|
+
image?: string | null | undefined;
|
|
89
|
+
} & {} & {
|
|
90
|
+
username?: string | null | undefined;
|
|
91
|
+
displayUsername?: string | null | undefined;
|
|
92
|
+
}> | undefined;
|
|
93
|
+
} | {
|
|
94
|
+
error: null;
|
|
95
|
+
isError: false;
|
|
96
|
+
isPending: false;
|
|
97
|
+
isLoading: false;
|
|
98
|
+
isLoadingError: false;
|
|
99
|
+
isRefetchError: false;
|
|
100
|
+
isSuccess: true;
|
|
101
|
+
isPlaceholderData: false;
|
|
102
|
+
status: "success";
|
|
103
|
+
dataUpdatedAt: number;
|
|
104
|
+
errorUpdatedAt: number;
|
|
105
|
+
failureCount: number;
|
|
106
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
107
|
+
errorUpdateCount: number;
|
|
108
|
+
isFetched: boolean;
|
|
109
|
+
isFetchedAfterMount: boolean;
|
|
110
|
+
isFetching: boolean;
|
|
111
|
+
isInitialLoading: boolean;
|
|
112
|
+
isPaused: boolean;
|
|
113
|
+
isRefetching: boolean;
|
|
114
|
+
isStale: boolean;
|
|
115
|
+
isEnabled: boolean;
|
|
116
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
117
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
118
|
+
id: string;
|
|
119
|
+
createdAt: Date;
|
|
120
|
+
updatedAt: Date;
|
|
121
|
+
email: string;
|
|
122
|
+
emailVerified: boolean;
|
|
123
|
+
name: string;
|
|
124
|
+
image?: string | null | undefined;
|
|
125
|
+
} & {} & {
|
|
126
|
+
username?: string | null | undefined;
|
|
127
|
+
displayUsername?: string | null | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
130
|
+
id: string;
|
|
131
|
+
createdAt: Date;
|
|
132
|
+
updatedAt: Date;
|
|
133
|
+
userId: string;
|
|
134
|
+
expiresAt: Date;
|
|
135
|
+
token: string;
|
|
136
|
+
ipAddress?: string | null | undefined;
|
|
137
|
+
userAgent?: string | null | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
140
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
141
|
+
promise: Promise<{
|
|
142
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
143
|
+
id: string;
|
|
144
|
+
createdAt: Date;
|
|
145
|
+
updatedAt: Date;
|
|
146
|
+
email: string;
|
|
147
|
+
emailVerified: boolean;
|
|
148
|
+
name: string;
|
|
149
|
+
image?: string | null | undefined;
|
|
150
|
+
} & {} & {
|
|
151
|
+
username?: string | null | undefined;
|
|
152
|
+
displayUsername?: string | null | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
155
|
+
id: string;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
userId: string;
|
|
159
|
+
expiresAt: Date;
|
|
160
|
+
token: string;
|
|
161
|
+
ipAddress?: string | null | undefined;
|
|
162
|
+
userAgent?: string | null | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
} | null>;
|
|
165
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
166
|
+
id: string;
|
|
167
|
+
createdAt: Date;
|
|
168
|
+
updatedAt: Date;
|
|
169
|
+
email: string;
|
|
170
|
+
emailVerified: boolean;
|
|
171
|
+
name: string;
|
|
172
|
+
image?: string | null | undefined;
|
|
173
|
+
} & {} & {
|
|
174
|
+
username?: string | null | undefined;
|
|
175
|
+
displayUsername?: string | null | undefined;
|
|
176
|
+
}> | undefined;
|
|
177
|
+
} | {
|
|
178
|
+
error: import("better-auth/react").BetterFetchError;
|
|
179
|
+
isError: true;
|
|
180
|
+
isPending: false;
|
|
181
|
+
isLoading: false;
|
|
182
|
+
isLoadingError: true;
|
|
183
|
+
isRefetchError: false;
|
|
184
|
+
isSuccess: false;
|
|
185
|
+
isPlaceholderData: false;
|
|
186
|
+
status: "error";
|
|
187
|
+
dataUpdatedAt: number;
|
|
188
|
+
errorUpdatedAt: number;
|
|
189
|
+
failureCount: number;
|
|
190
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
191
|
+
errorUpdateCount: number;
|
|
192
|
+
isFetched: boolean;
|
|
193
|
+
isFetchedAfterMount: boolean;
|
|
194
|
+
isFetching: boolean;
|
|
195
|
+
isInitialLoading: boolean;
|
|
196
|
+
isPaused: boolean;
|
|
197
|
+
isRefetching: boolean;
|
|
198
|
+
isStale: boolean;
|
|
199
|
+
isEnabled: boolean;
|
|
200
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
201
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
202
|
+
id: string;
|
|
203
|
+
createdAt: Date;
|
|
204
|
+
updatedAt: Date;
|
|
205
|
+
email: string;
|
|
206
|
+
emailVerified: boolean;
|
|
207
|
+
name: string;
|
|
208
|
+
image?: string | null | undefined;
|
|
209
|
+
} & {} & {
|
|
210
|
+
username?: string | null | undefined;
|
|
211
|
+
displayUsername?: string | null | undefined;
|
|
212
|
+
}>;
|
|
213
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
214
|
+
id: string;
|
|
215
|
+
createdAt: Date;
|
|
216
|
+
updatedAt: Date;
|
|
217
|
+
userId: string;
|
|
218
|
+
expiresAt: Date;
|
|
219
|
+
token: string;
|
|
220
|
+
ipAddress?: string | null | undefined;
|
|
221
|
+
userAgent?: string | null | undefined;
|
|
222
|
+
}>;
|
|
223
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
224
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
225
|
+
promise: Promise<{
|
|
226
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
227
|
+
id: string;
|
|
228
|
+
createdAt: Date;
|
|
229
|
+
updatedAt: Date;
|
|
230
|
+
email: string;
|
|
231
|
+
emailVerified: boolean;
|
|
232
|
+
name: string;
|
|
233
|
+
image?: string | null | undefined;
|
|
234
|
+
} & {} & {
|
|
235
|
+
username?: string | null | undefined;
|
|
236
|
+
displayUsername?: string | null | undefined;
|
|
237
|
+
}>;
|
|
238
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
239
|
+
id: string;
|
|
240
|
+
createdAt: Date;
|
|
241
|
+
updatedAt: Date;
|
|
242
|
+
userId: string;
|
|
243
|
+
expiresAt: Date;
|
|
244
|
+
token: string;
|
|
245
|
+
ipAddress?: string | null | undefined;
|
|
246
|
+
userAgent?: string | null | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
} | null>;
|
|
249
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
250
|
+
id: string;
|
|
251
|
+
createdAt: Date;
|
|
252
|
+
updatedAt: Date;
|
|
253
|
+
email: string;
|
|
254
|
+
emailVerified: boolean;
|
|
255
|
+
name: string;
|
|
256
|
+
image?: string | null | undefined;
|
|
257
|
+
} & {} & {
|
|
258
|
+
username?: string | null | undefined;
|
|
259
|
+
displayUsername?: string | null | undefined;
|
|
260
|
+
}> | undefined;
|
|
261
|
+
} | {
|
|
262
|
+
error: null;
|
|
263
|
+
isError: false;
|
|
264
|
+
isPending: true;
|
|
265
|
+
isLoading: true;
|
|
266
|
+
isLoadingError: false;
|
|
267
|
+
isRefetchError: false;
|
|
268
|
+
isSuccess: false;
|
|
269
|
+
isPlaceholderData: false;
|
|
270
|
+
status: "pending";
|
|
271
|
+
dataUpdatedAt: number;
|
|
272
|
+
errorUpdatedAt: number;
|
|
273
|
+
failureCount: number;
|
|
274
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
275
|
+
errorUpdateCount: number;
|
|
276
|
+
isFetched: boolean;
|
|
277
|
+
isFetchedAfterMount: boolean;
|
|
278
|
+
isFetching: boolean;
|
|
279
|
+
isInitialLoading: boolean;
|
|
280
|
+
isPaused: boolean;
|
|
281
|
+
isRefetching: boolean;
|
|
282
|
+
isStale: boolean;
|
|
283
|
+
isEnabled: boolean;
|
|
284
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
285
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
286
|
+
id: string;
|
|
287
|
+
createdAt: Date;
|
|
288
|
+
updatedAt: Date;
|
|
289
|
+
email: string;
|
|
290
|
+
emailVerified: boolean;
|
|
291
|
+
name: string;
|
|
292
|
+
image?: string | null | undefined;
|
|
293
|
+
} & {} & {
|
|
294
|
+
username?: string | null | undefined;
|
|
295
|
+
displayUsername?: string | null | undefined;
|
|
296
|
+
}>;
|
|
297
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
298
|
+
id: string;
|
|
299
|
+
createdAt: Date;
|
|
300
|
+
updatedAt: Date;
|
|
301
|
+
userId: string;
|
|
302
|
+
expiresAt: Date;
|
|
303
|
+
token: string;
|
|
304
|
+
ipAddress?: string | null | undefined;
|
|
305
|
+
userAgent?: string | null | undefined;
|
|
306
|
+
}>;
|
|
307
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
308
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
309
|
+
promise: Promise<{
|
|
310
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
311
|
+
id: string;
|
|
312
|
+
createdAt: Date;
|
|
313
|
+
updatedAt: Date;
|
|
314
|
+
email: string;
|
|
315
|
+
emailVerified: boolean;
|
|
316
|
+
name: string;
|
|
317
|
+
image?: string | null | undefined;
|
|
318
|
+
} & {} & {
|
|
319
|
+
username?: string | null | undefined;
|
|
320
|
+
displayUsername?: string | null | undefined;
|
|
321
|
+
}>;
|
|
322
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
323
|
+
id: string;
|
|
324
|
+
createdAt: Date;
|
|
325
|
+
updatedAt: Date;
|
|
326
|
+
userId: string;
|
|
327
|
+
expiresAt: Date;
|
|
328
|
+
token: string;
|
|
329
|
+
ipAddress?: string | null | undefined;
|
|
330
|
+
userAgent?: string | null | undefined;
|
|
331
|
+
}>;
|
|
332
|
+
} | null>;
|
|
333
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
334
|
+
id: string;
|
|
335
|
+
createdAt: Date;
|
|
336
|
+
updatedAt: Date;
|
|
337
|
+
email: string;
|
|
338
|
+
emailVerified: boolean;
|
|
339
|
+
name: string;
|
|
340
|
+
image?: string | null | undefined;
|
|
341
|
+
} & {} & {
|
|
342
|
+
username?: string | null | undefined;
|
|
343
|
+
displayUsername?: string | null | undefined;
|
|
344
|
+
}> | undefined;
|
|
345
|
+
} | {
|
|
346
|
+
error: null;
|
|
347
|
+
isError: false;
|
|
348
|
+
isPending: true;
|
|
349
|
+
isLoadingError: false;
|
|
350
|
+
isRefetchError: false;
|
|
351
|
+
isSuccess: false;
|
|
352
|
+
isPlaceholderData: false;
|
|
353
|
+
status: "pending";
|
|
354
|
+
dataUpdatedAt: number;
|
|
355
|
+
errorUpdatedAt: number;
|
|
356
|
+
failureCount: number;
|
|
357
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
358
|
+
errorUpdateCount: number;
|
|
359
|
+
isFetched: boolean;
|
|
360
|
+
isFetchedAfterMount: boolean;
|
|
361
|
+
isFetching: boolean;
|
|
362
|
+
isLoading: boolean;
|
|
363
|
+
isInitialLoading: boolean;
|
|
364
|
+
isPaused: boolean;
|
|
365
|
+
isRefetching: boolean;
|
|
366
|
+
isStale: boolean;
|
|
367
|
+
isEnabled: boolean;
|
|
368
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
369
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
370
|
+
id: string;
|
|
371
|
+
createdAt: Date;
|
|
372
|
+
updatedAt: Date;
|
|
373
|
+
email: string;
|
|
374
|
+
emailVerified: boolean;
|
|
375
|
+
name: string;
|
|
376
|
+
image?: string | null | undefined;
|
|
377
|
+
} & {} & {
|
|
378
|
+
username?: string | null | undefined;
|
|
379
|
+
displayUsername?: string | null | undefined;
|
|
380
|
+
}>;
|
|
381
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
382
|
+
id: string;
|
|
383
|
+
createdAt: Date;
|
|
384
|
+
updatedAt: Date;
|
|
385
|
+
userId: string;
|
|
386
|
+
expiresAt: Date;
|
|
387
|
+
token: string;
|
|
388
|
+
ipAddress?: string | null | undefined;
|
|
389
|
+
userAgent?: string | null | undefined;
|
|
390
|
+
}>;
|
|
391
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
392
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
393
|
+
promise: Promise<{
|
|
394
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
395
|
+
id: string;
|
|
396
|
+
createdAt: Date;
|
|
397
|
+
updatedAt: Date;
|
|
398
|
+
email: string;
|
|
399
|
+
emailVerified: boolean;
|
|
400
|
+
name: string;
|
|
401
|
+
image?: string | null | undefined;
|
|
402
|
+
} & {} & {
|
|
403
|
+
username?: string | null | undefined;
|
|
404
|
+
displayUsername?: string | null | undefined;
|
|
405
|
+
}>;
|
|
406
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
407
|
+
id: string;
|
|
408
|
+
createdAt: Date;
|
|
409
|
+
updatedAt: Date;
|
|
410
|
+
userId: string;
|
|
411
|
+
expiresAt: Date;
|
|
412
|
+
token: string;
|
|
413
|
+
ipAddress?: string | null | undefined;
|
|
414
|
+
userAgent?: string | null | undefined;
|
|
415
|
+
}>;
|
|
416
|
+
} | null>;
|
|
417
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
418
|
+
id: string;
|
|
419
|
+
createdAt: Date;
|
|
420
|
+
updatedAt: Date;
|
|
421
|
+
email: string;
|
|
422
|
+
emailVerified: boolean;
|
|
423
|
+
name: string;
|
|
424
|
+
image?: string | null | undefined;
|
|
425
|
+
} & {} & {
|
|
426
|
+
username?: string | null | undefined;
|
|
427
|
+
displayUsername?: string | null | undefined;
|
|
428
|
+
}> | undefined;
|
|
429
|
+
} | {
|
|
430
|
+
isError: false;
|
|
431
|
+
error: null;
|
|
432
|
+
isPending: false;
|
|
433
|
+
isLoading: false;
|
|
434
|
+
isLoadingError: false;
|
|
435
|
+
isRefetchError: false;
|
|
436
|
+
isSuccess: true;
|
|
437
|
+
isPlaceholderData: true;
|
|
438
|
+
status: "success";
|
|
439
|
+
dataUpdatedAt: number;
|
|
440
|
+
errorUpdatedAt: number;
|
|
441
|
+
failureCount: number;
|
|
442
|
+
failureReason: import("better-auth/react").BetterFetchError | null;
|
|
443
|
+
errorUpdateCount: number;
|
|
444
|
+
isFetched: boolean;
|
|
445
|
+
isFetchedAfterMount: boolean;
|
|
446
|
+
isFetching: boolean;
|
|
447
|
+
isInitialLoading: boolean;
|
|
448
|
+
isPaused: boolean;
|
|
449
|
+
isRefetching: boolean;
|
|
450
|
+
isStale: boolean;
|
|
451
|
+
isEnabled: boolean;
|
|
452
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
453
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
454
|
+
id: string;
|
|
455
|
+
createdAt: Date;
|
|
456
|
+
updatedAt: Date;
|
|
457
|
+
email: string;
|
|
458
|
+
emailVerified: boolean;
|
|
459
|
+
name: string;
|
|
460
|
+
image?: string | null | undefined;
|
|
461
|
+
} & {} & {
|
|
462
|
+
username?: string | null | undefined;
|
|
463
|
+
displayUsername?: string | null | undefined;
|
|
464
|
+
}>;
|
|
465
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
466
|
+
id: string;
|
|
467
|
+
createdAt: Date;
|
|
468
|
+
updatedAt: Date;
|
|
469
|
+
userId: string;
|
|
470
|
+
expiresAt: Date;
|
|
471
|
+
token: string;
|
|
472
|
+
ipAddress?: string | null | undefined;
|
|
473
|
+
userAgent?: string | null | undefined;
|
|
474
|
+
}>;
|
|
475
|
+
} | null, import("better-auth/react").BetterFetchError>>;
|
|
476
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
477
|
+
promise: Promise<{
|
|
478
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
479
|
+
id: string;
|
|
480
|
+
createdAt: Date;
|
|
481
|
+
updatedAt: Date;
|
|
482
|
+
email: string;
|
|
483
|
+
emailVerified: boolean;
|
|
484
|
+
name: string;
|
|
485
|
+
image?: string | null | undefined;
|
|
486
|
+
} & {} & {
|
|
487
|
+
username?: string | null | undefined;
|
|
488
|
+
displayUsername?: string | null | undefined;
|
|
489
|
+
}>;
|
|
490
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
491
|
+
id: string;
|
|
492
|
+
createdAt: Date;
|
|
493
|
+
updatedAt: Date;
|
|
494
|
+
userId: string;
|
|
495
|
+
expiresAt: Date;
|
|
496
|
+
token: string;
|
|
497
|
+
ipAddress?: string | null | undefined;
|
|
498
|
+
userAgent?: string | null | undefined;
|
|
499
|
+
}>;
|
|
500
|
+
} | null>;
|
|
501
|
+
data: import("better-auth").StripEmptyObjects<{
|
|
502
|
+
id: string;
|
|
503
|
+
createdAt: Date;
|
|
504
|
+
updatedAt: Date;
|
|
505
|
+
email: string;
|
|
506
|
+
emailVerified: boolean;
|
|
507
|
+
name: string;
|
|
508
|
+
image?: string | null | undefined;
|
|
509
|
+
} & {} & {
|
|
510
|
+
username?: string | null | undefined;
|
|
511
|
+
displayUsername?: string | null | undefined;
|
|
512
|
+
}> | undefined;
|
|
513
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useSession } from "./use-session";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve the current authenticated user.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Options to merge into the React Query configuration for the session query.
|
|
6
|
+
* @returns The React Query result with `data` containing the user object from the session.
|
|
7
|
+
*/
|
|
8
|
+
export function useUser(options) {
|
|
9
|
+
const { data, ...rest } = useSession(options);
|
|
10
|
+
return {
|
|
11
|
+
data: data?.user,
|
|
12
|
+
...rest
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import { type UseAuthQueryOptions } from "../auth/use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve provider-specific account info for a given account ID.
|
|
5
|
+
*
|
|
6
|
+
* Uses the `accountInfo` API endpoint to fetch detailed information
|
|
7
|
+
* from the social provider. The provider is automatically detected
|
|
8
|
+
* from the account ID.
|
|
9
|
+
*
|
|
10
|
+
* @param accountId - The provider-given account ID to fetch info for
|
|
11
|
+
* @param options - Optional react-query options forwarded to `useQuery`
|
|
12
|
+
* @returns The react-query result containing account info data, loading state, and error state
|
|
13
|
+
*/
|
|
14
|
+
export declare function useAccountInfo(accountId?: string, options?: Partial<UseAuthQueryOptions<AuthClient["accountInfo"]>>): import("@tanstack/react-query").UseQueryResult<{
|
|
15
|
+
user: import("better-auth").OAuth2UserInfo;
|
|
16
|
+
data: Record<string, any>;
|
|
17
|
+
} | null, import("better-auth/react").BetterFetchError>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useAuth } from "@better-auth-ui/react";
|
|
2
|
+
import { useAuthQuery } from "../auth/use-auth-query";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve provider-specific account info for a given account ID.
|
|
5
|
+
*
|
|
6
|
+
* Uses the `accountInfo` API endpoint to fetch detailed information
|
|
7
|
+
* from the social provider. The provider is automatically detected
|
|
8
|
+
* from the account ID.
|
|
9
|
+
*
|
|
10
|
+
* @param accountId - The provider-given account ID to fetch info for
|
|
11
|
+
* @param options - Optional react-query options forwarded to `useQuery`
|
|
12
|
+
* @returns The react-query result containing account info data, loading state, and error state
|
|
13
|
+
*/
|
|
14
|
+
export function useAccountInfo(accountId, options) {
|
|
15
|
+
const { authClient } = useAuth();
|
|
16
|
+
return useAuthQuery({
|
|
17
|
+
authFn: authClient.accountInfo,
|
|
18
|
+
params: { query: { accountId } },
|
|
19
|
+
options: {
|
|
20
|
+
queryKey: ["auth", "accountInfo", accountId],
|
|
21
|
+
enabled: !!accountId,
|
|
22
|
+
...options
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type AuthClient } from "@better-auth-ui/react";
|
|
2
|
+
import type { UseAuthMutationOptions } from "../auth/use-auth-mutation";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates a mutation for changing the current user's email address.
|
|
5
|
+
*
|
|
6
|
+
* The mutation sends an email-change request and shows success or error toasts.
|
|
7
|
+
* On success the callback URL is set to the account settings view.
|
|
8
|
+
*
|
|
9
|
+
* @returns The `useMutation` result.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useChangeEmail(options?: UseAuthMutationOptions<AuthClient["changeEmail"]>): import("../auth/use-auth-mutation").UseAuthMutationResult<(<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
12
|
+
newEmail: string;
|
|
13
|
+
callbackURL?: string | undefined;
|
|
14
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
15
|
+
newEmail: string;
|
|
16
|
+
callbackURL?: string | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
fetchOptions?: FetchOptions | undefined;
|
|
19
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/react").BetterFetchResponse<{
|
|
20
|
+
status: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
code?: string | undefined;
|
|
23
|
+
message?: string | undefined;
|
|
24
|
+
}, FetchOptions["throw"] extends true ? true : false>>)>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useAuth, useAuthMutation, useSession } from "@better-auth-ui/react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that creates a mutation for changing the current user's email address.
|
|
4
|
+
*
|
|
5
|
+
* The mutation sends an email-change request and shows success or error toasts.
|
|
6
|
+
* On success the callback URL is set to the account settings view.
|
|
7
|
+
*
|
|
8
|
+
* @returns The `useMutation` result.
|
|
9
|
+
*/
|
|
10
|
+
export function useChangeEmail(options) {
|
|
11
|
+
const { authClient } = useAuth();
|
|
12
|
+
const { refetch } = useSession({ refetchOnMount: false });
|
|
13
|
+
return useAuthMutation({
|
|
14
|
+
authFn: authClient.changeEmail,
|
|
15
|
+
options: {
|
|
16
|
+
...options,
|
|
17
|
+
onSuccess: async (...args) => {
|
|
18
|
+
refetch();
|
|
19
|
+
await options?.onSuccess?.(...args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|