@better-auth-ui/react 1.6.1 → 1.6.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/auth/auth-provider.d.ts +4 -3
- package/dist/components/auth/auth-provider.js +24 -40
- package/dist/components/email/email-changed.d.ts +2 -2
- package/dist/components/email/email-changed.js +154 -68
- package/dist/components/email/email-localization.js +18 -23
- package/dist/components/email/email-styles.js +52 -77
- package/dist/components/email/email-verification.d.ts +2 -2
- package/dist/components/email/email-verification.js +138 -73
- package/dist/components/email/index.d.ts +9 -9
- package/dist/components/email/index.js +9 -9
- package/dist/components/email/magic-link.d.ts +2 -2
- package/dist/components/email/magic-link.js +139 -70
- package/dist/components/email/new-device.d.ts +2 -2
- package/dist/components/email/new-device.js +221 -88
- package/dist/components/email/otp-email.d.ts +2 -2
- package/dist/components/email/otp-email.js +127 -63
- package/dist/components/email/password-changed.d.ts +2 -2
- package/dist/components/email/password-changed.js +157 -74
- package/dist/components/email/reset-password.d.ts +2 -2
- package/dist/components/email/reset-password.js +138 -66
- package/dist/components/icons/apple.d.ts +1 -1
- package/dist/components/icons/apple.js +16 -9
- package/dist/components/icons/atlassian.d.ts +1 -1
- package/dist/components/icons/atlassian.js +38 -13
- package/dist/components/icons/cognito.d.ts +1 -1
- package/dist/components/icons/cognito.js +19 -9
- package/dist/components/icons/discord.d.ts +1 -1
- package/dist/components/icons/discord.js +16 -9
- package/dist/components/icons/dropbox.d.ts +1 -1
- package/dist/components/icons/dropbox.js +16 -9
- package/dist/components/icons/facebook.d.ts +1 -1
- package/dist/components/icons/facebook.js +19 -11
- package/dist/components/icons/figma.d.ts +1 -1
- package/dist/components/icons/figma.js +34 -12
- package/dist/components/icons/github.d.ts +1 -1
- package/dist/components/icons/github.js +16 -11
- package/dist/components/icons/gitlab.d.ts +1 -1
- package/dist/components/icons/gitlab.js +30 -9
- package/dist/components/icons/google.d.ts +1 -1
- package/dist/components/icons/google.js +39 -9
- package/dist/components/icons/huggingface.d.ts +1 -1
- package/dist/components/icons/huggingface.js +38 -9
- package/dist/components/icons/index.d.ts +35 -35
- package/dist/components/icons/index.js +35 -35
- package/dist/components/icons/kakao.d.ts +1 -1
- package/dist/components/icons/kakao.js +16 -11
- package/dist/components/icons/kick.d.ts +1 -1
- package/dist/components/icons/kick.js +20 -11
- package/dist/components/icons/line.d.ts +1 -1
- package/dist/components/icons/line.js +16 -9
- package/dist/components/icons/linear.d.ts +1 -1
- package/dist/components/icons/linear.js +16 -9
- package/dist/components/icons/linkedin.d.ts +1 -1
- package/dist/components/icons/linkedin.js +33 -9
- package/dist/components/icons/microsoft.d.ts +1 -1
- package/dist/components/icons/microsoft.js +30 -9
- package/dist/components/icons/naver.d.ts +1 -1
- package/dist/components/icons/naver.js +16 -9
- package/dist/components/icons/notion.d.ts +1 -1
- package/dist/components/icons/notion.js +16 -9
- package/dist/components/icons/paybin.d.ts +1 -1
- package/dist/components/icons/paybin.js +32 -8
- package/dist/components/icons/paypal.d.ts +1 -1
- package/dist/components/icons/paypal.js +30 -9
- package/dist/components/icons/polar.d.ts +1 -1
- package/dist/components/icons/polar.js +24 -9
- package/dist/components/icons/railway.d.ts +1 -1
- package/dist/components/icons/railway.js +16 -9
- package/dist/components/icons/reddit.d.ts +1 -1
- package/dist/components/icons/reddit.js +21 -9
- package/dist/components/icons/roblox.d.ts +1 -1
- package/dist/components/icons/roblox.js +17 -12
- package/dist/components/icons/salesforce.d.ts +1 -1
- package/dist/components/icons/salesforce.js +16 -9
- package/dist/components/icons/slack.d.ts +1 -1
- package/dist/components/icons/slack.js +30 -9
- package/dist/components/icons/spotify.d.ts +1 -1
- package/dist/components/icons/spotify.js +16 -9
- package/dist/components/icons/tiktok.d.ts +1 -1
- package/dist/components/icons/tiktok.js +23 -10
- package/dist/components/icons/twitch.d.ts +1 -1
- package/dist/components/icons/twitch.js +43 -12
- package/dist/components/icons/vercel.d.ts +1 -1
- package/dist/components/icons/vercel.js +16 -9
- package/dist/components/icons/vk.d.ts +1 -1
- package/dist/components/icons/vk.js +16 -9
- package/dist/components/icons/wechat.d.ts +1 -1
- package/dist/components/icons/wechat.js +16 -9
- package/dist/components/icons/x.d.ts +1 -1
- package/dist/components/icons/x.js +16 -9
- package/dist/components/icons/zoom.d.ts +1 -1
- package/dist/components/icons/zoom.js +69 -11
- package/dist/components/settings/account/theme-preview.js +286 -7
- package/dist/core.d.ts +1 -1
- package/dist/hooks/auth/use-authenticate.d.ts +30 -6
- package/dist/hooks/auth/use-authenticate.js +22 -27
- package/dist/hooks/auth/use-is-username-available.d.ts +20 -0
- package/dist/hooks/auth/use-is-username-available.js +13 -0
- package/dist/hooks/auth/use-request-password-reset.d.ts +12 -17
- package/dist/hooks/auth/use-request-password-reset.js +12 -13
- package/dist/hooks/auth/use-reset-password.d.ts +14 -31
- package/dist/hooks/auth/use-reset-password.js +12 -12
- package/dist/hooks/auth/use-send-verification-email.d.ts +11 -16
- package/dist/hooks/auth/use-send-verification-email.js +12 -12
- package/dist/hooks/auth/use-session.d.ts +31 -5
- package/dist/hooks/auth/use-session.js +15 -17
- package/dist/hooks/auth/use-sign-in-email.d.ts +12 -39
- package/dist/hooks/auth/use-sign-in-email.js +16 -24
- package/dist/hooks/auth/use-sign-in-magic-link.d.ts +15 -20
- package/dist/hooks/auth/use-sign-in-magic-link.js +12 -12
- package/dist/hooks/auth/use-sign-in-passkey.d.ts +13 -50
- package/dist/hooks/auth/use-sign-in-passkey.js +16 -24
- package/dist/hooks/auth/use-sign-in-social.d.ts +32 -62
- package/dist/hooks/auth/use-sign-in-social.js +12 -12
- package/dist/hooks/auth/use-sign-in-username.d.ts +25 -0
- package/dist/hooks/auth/use-sign-in-username.js +17 -0
- package/dist/hooks/auth/use-sign-out.d.ts +11 -12
- package/dist/hooks/auth/use-sign-out.js +15 -23
- package/dist/hooks/auth/use-sign-up-email.d.ts +178 -262
- package/dist/hooks/auth/use-sign-up-email.js +16 -24
- package/dist/hooks/auth/use-user.d.ts +63 -61
- package/dist/hooks/auth/use-user.js +10 -13
- package/dist/hooks/settings/use-account-info.d.ts +12 -12
- package/dist/hooks/settings/use-account-info.js +17 -24
- package/dist/hooks/settings/use-add-passkey.d.ts +11 -33
- package/dist/hooks/settings/use-add-passkey.js +16 -23
- package/dist/hooks/settings/use-change-email.d.ts +12 -15
- package/dist/hooks/settings/use-change-email.js +16 -22
- package/dist/hooks/settings/use-change-password.d.ts +12 -45
- package/dist/hooks/settings/use-change-password.js +12 -10
- package/dist/hooks/settings/use-delete-passkey.d.ts +11 -13
- package/dist/hooks/settings/use-delete-passkey.js +16 -23
- package/dist/hooks/settings/use-delete-user.d.ts +14 -32
- package/dist/hooks/settings/use-delete-user.js +12 -10
- package/dist/hooks/settings/use-link-social.d.ts +23 -26
- package/dist/hooks/settings/use-link-social.js +12 -9
- package/dist/hooks/settings/use-list-accounts.d.ts +10 -8
- package/dist/hooks/settings/use-list-accounts.js +14 -22
- package/dist/hooks/settings/use-list-device-sessions.d.ts +30 -7
- package/dist/hooks/settings/use-list-device-sessions.js +14 -21
- package/dist/hooks/settings/use-list-sessions.d.ts +10 -7
- package/dist/hooks/settings/use-list-sessions.js +14 -21
- package/dist/hooks/settings/use-list-user-passkeys.d.ts +9 -6
- package/dist/hooks/settings/use-list-user-passkeys.js +14 -21
- package/dist/hooks/settings/use-revoke-multi-session.d.ts +12 -12
- package/dist/hooks/settings/use-revoke-multi-session.js +16 -19
- package/dist/hooks/settings/use-revoke-session.d.ts +12 -12
- package/dist/hooks/settings/use-revoke-session.js +16 -20
- package/dist/hooks/settings/use-set-active-session.d.ts +13 -30
- package/dist/hooks/settings/use-set-active-session.js +19 -27
- package/dist/hooks/settings/use-unlink-account.d.ts +13 -13
- package/dist/hooks/settings/use-unlink-account.js +16 -20
- package/dist/hooks/settings/use-update-user.d.ts +1179 -5
- package/dist/hooks/settings/use-update-user.js +23 -28
- package/dist/hooks/use-auth-mutation.d.ts +12 -0
- package/dist/hooks/use-auth-mutation.js +11 -0
- package/dist/hooks/use-auth-query.d.ts +14 -0
- package/dist/hooks/use-auth-query.js +15 -0
- package/dist/index.d.ts +40 -36
- package/dist/index.js +84 -36
- package/dist/lib/auth-client.d.ts +1254 -1254
- package/dist/lib/auth-client.js +11 -11
- package/dist/lib/auth-config.d.ts +3 -3
- package/dist/lib/auth-context.d.ts +2 -2
- package/dist/lib/auth-context.js +5 -2
- package/dist/lib/provider-icons.d.ts +2 -2
- package/dist/lib/provider-icons.js +75 -47
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +7 -4
- package/dist/mutations/auth/is-username-available-options.d.ts +19 -0
- package/dist/mutations/auth/is-username-available-options.js +7 -0
- package/dist/mutations/auth/request-password-reset-options.d.ts +15 -0
- package/dist/mutations/auth/request-password-reset-options.js +7 -0
- package/dist/mutations/auth/reset-password-options.d.ts +17 -0
- package/dist/mutations/auth/reset-password-options.js +7 -0
- package/dist/mutations/auth/send-verification-email-options.d.ts +15 -0
- package/dist/mutations/auth/send-verification-email-options.js +7 -0
- package/dist/mutations/auth/sign-in-email-options.d.ts +23 -0
- package/dist/mutations/auth/sign-in-email-options.js +11 -0
- package/dist/mutations/auth/sign-in-magic-link-options.d.ts +23 -0
- package/dist/mutations/auth/sign-in-magic-link-options.js +11 -0
- package/dist/mutations/auth/sign-in-passkey-options.d.ts +15 -0
- package/dist/mutations/auth/sign-in-passkey-options.js +11 -0
- package/dist/mutations/auth/sign-in-social-options.d.ts +61 -0
- package/dist/mutations/auth/sign-in-social-options.js +11 -0
- package/dist/mutations/auth/sign-in-username-options.d.ts +19 -0
- package/dist/mutations/auth/sign-in-username-options.js +11 -0
- package/dist/mutations/auth/sign-out-options.d.ts +12 -0
- package/dist/mutations/auth/sign-out-options.js +7 -0
- package/dist/mutations/auth/sign-up-email-options.d.ts +1180 -0
- package/dist/mutations/auth/sign-up-email-options.js +11 -0
- package/dist/mutations/auth-mutation-options.d.ts +25 -0
- package/dist/mutations/auth-mutation-options.js +19 -0
- package/dist/mutations/settings/add-passkey-options.d.ts +15 -0
- package/dist/mutations/settings/add-passkey-options.js +11 -0
- package/dist/mutations/settings/change-email-options.d.ts +15 -0
- package/dist/mutations/settings/change-email-options.js +7 -0
- package/dist/mutations/settings/change-password-options.d.ts +17 -0
- package/dist/mutations/settings/change-password-options.js +7 -0
- package/dist/mutations/settings/delete-passkey-options.d.ts +13 -0
- package/dist/mutations/settings/delete-passkey-options.js +11 -0
- package/dist/mutations/settings/delete-user-options.d.ts +20 -0
- package/dist/mutations/settings/delete-user-options.js +7 -0
- package/dist/mutations/settings/link-social-options.d.ts +39 -0
- package/dist/mutations/settings/link-social-options.js +7 -0
- package/dist/mutations/settings/revoke-multi-session-options.d.ts +13 -0
- package/dist/mutations/settings/revoke-multi-session-options.js +11 -0
- package/dist/mutations/settings/revoke-session-options.d.ts +13 -0
- package/dist/mutations/settings/revoke-session-options.js +7 -0
- package/dist/mutations/settings/set-active-session-options.d.ts +13 -0
- package/dist/mutations/settings/set-active-session-options.js +11 -0
- package/dist/mutations/settings/unlink-account-options.d.ts +15 -0
- package/dist/mutations/settings/unlink-account-options.js +7 -0
- package/dist/mutations/settings/update-user-options.d.ts +1182 -0
- package/dist/mutations/settings/update-user-options.js +7 -0
- package/dist/queries/auth/session-options.d.ts +110 -0
- package/dist/queries/auth/session-options.js +7 -0
- package/dist/queries/auth-query-options.d.ts +29 -0
- package/dist/queries/auth-query-options.js +17 -0
- package/dist/queries/settings/account-info-options.d.ts +32 -0
- package/dist/queries/settings/account-info-options.js +12 -0
- package/dist/queries/settings/list-accounts-options.d.ts +53 -0
- package/dist/queries/settings/list-accounts-options.js +12 -0
- package/dist/queries/settings/list-device-sessions-options.d.ts +99 -0
- package/dist/queries/settings/list-device-sessions-options.js +12 -0
- package/dist/queries/settings/list-sessions-options.d.ts +54 -0
- package/dist/queries/settings/list-sessions-options.js +12 -0
- package/dist/queries/settings/list-user-passkeys-options.d.ts +18 -0
- package/dist/queries/settings/list-user-passkeys-options.js +12 -0
- package/package.json +11 -11
- package/src/components/auth/auth-provider.tsx +4 -6
- package/src/hooks/auth/use-authenticate.ts +8 -9
- package/src/hooks/auth/use-is-username-available.ts +31 -0
- package/src/hooks/auth/use-request-password-reset.ts +20 -11
- package/src/hooks/auth/use-reset-password.ts +20 -12
- package/src/hooks/auth/use-send-verification-email.ts +19 -11
- package/src/hooks/auth/use-session.ts +22 -17
- package/src/hooks/auth/use-sign-in-email.ts +24 -19
- package/src/hooks/auth/use-sign-in-magic-link.ts +19 -13
- package/src/hooks/auth/use-sign-in-passkey.ts +24 -18
- package/src/hooks/auth/use-sign-in-social.ts +19 -11
- package/src/hooks/auth/use-sign-in-username.ts +40 -0
- package/src/hooks/auth/use-sign-out.ts +20 -20
- package/src/hooks/auth/use-sign-up-email.ts +25 -21
- package/src/hooks/auth/use-user.ts +7 -9
- package/src/hooks/settings/use-account-info.ts +31 -21
- package/src/hooks/settings/use-add-passkey.ts +22 -17
- package/src/hooks/settings/use-change-email.ts +24 -20
- package/src/hooks/settings/use-change-password.ts +19 -11
- package/src/hooks/settings/use-delete-passkey.ts +21 -16
- package/src/hooks/settings/use-delete-user.ts +19 -11
- package/src/hooks/settings/use-link-social.ts +20 -10
- package/src/hooks/settings/use-list-accounts.ts +28 -16
- package/src/hooks/settings/use-list-device-sessions.ts +29 -22
- package/src/hooks/settings/use-list-sessions.ts +28 -15
- package/src/hooks/settings/use-list-user-passkeys.ts +28 -17
- package/src/hooks/settings/use-revoke-multi-session.ts +28 -19
- package/src/hooks/settings/use-revoke-session.ts +26 -18
- package/src/hooks/settings/use-set-active-session.ts +40 -28
- package/src/hooks/settings/use-unlink-account.ts +23 -17
- package/src/hooks/settings/use-update-user.ts +33 -27
- package/src/hooks/use-auth-mutation.ts +29 -0
- package/src/hooks/use-auth-query.ts +36 -0
- package/src/index.ts +4 -0
- package/src/lib/auth-config.ts +1 -1
- package/src/mutations/auth/is-username-available-options.ts +18 -0
- package/src/mutations/auth/request-password-reset-options.ts +14 -0
- package/src/mutations/auth/reset-password-options.ts +14 -0
- package/src/mutations/auth/send-verification-email-options.ts +14 -0
- package/src/mutations/auth/sign-in-email-options.ts +19 -0
- package/src/mutations/auth/sign-in-magic-link-options.ts +15 -0
- package/src/mutations/auth/sign-in-passkey-options.ts +15 -0
- package/src/mutations/auth/sign-in-social-options.ts +19 -0
- package/src/mutations/auth/sign-in-username-options.ts +15 -0
- package/src/mutations/auth/sign-out-options.ts +11 -0
- package/src/mutations/auth/sign-up-email-options.ts +15 -0
- package/src/mutations/auth-mutation-options.ts +49 -0
- package/src/mutations/settings/add-passkey-options.ts +15 -0
- package/src/mutations/settings/change-email-options.ts +11 -0
- package/src/mutations/settings/change-password-options.ts +14 -0
- package/src/mutations/settings/delete-passkey-options.ts +15 -0
- package/src/mutations/settings/delete-user-options.ts +11 -0
- package/src/mutations/settings/link-social-options.ts +11 -0
- package/src/mutations/settings/revoke-multi-session-options.ts +15 -0
- package/src/mutations/settings/revoke-session-options.ts +14 -0
- package/src/mutations/settings/set-active-session-options.ts +15 -0
- package/src/mutations/settings/unlink-account-options.ts +14 -0
- package/src/mutations/settings/update-user-options.ts +15 -0
- package/src/queries/auth/session-options.ts +18 -0
- package/src/queries/auth-query-options.ts +34 -0
- package/src/queries/settings/account-info-options.ts +25 -0
- package/src/queries/settings/list-accounts-options.ts +26 -0
- package/src/queries/settings/list-device-sessions-options.ts +24 -0
- package/src/queries/settings/list-sessions-options.ts +23 -0
- package/src/queries/settings/list-user-passkeys-options.ts +23 -0
- package/dist/hooks/auth/use-auth-mutation.d.ts +0 -18
- package/dist/hooks/auth/use-auth-mutation.js +0 -10
- package/dist/hooks/auth/use-auth-query.d.ts +0 -24
- package/dist/hooks/auth/use-auth-query.js +0 -10
- package/dist/lib/auth-config.js +0 -1
- package/src/hooks/auth/use-auth-mutation.ts +0 -56
- package/src/hooks/auth/use-auth-query.ts +0 -50
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current session.
|
|
4
|
+
*
|
|
5
|
+
* Access `.queryKey` on the returned options for cache seeding or
|
|
6
|
+
* invalidation: `queryClient.setQueryData(sessionOptions(authClient).queryKey, session)`.
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.getSession`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sessionOptions(authClient: AuthClient, params?: Parameters<AuthClient["getSession"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
12
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
email: string;
|
|
17
|
+
emailVerified: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
image?: string | null | undefined;
|
|
20
|
+
} & {} & {
|
|
21
|
+
username?: string | null | undefined;
|
|
22
|
+
displayUsername?: string | null | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
25
|
+
id: string;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
userId: string;
|
|
29
|
+
expiresAt: Date;
|
|
30
|
+
token: string;
|
|
31
|
+
ipAddress?: string | null | undefined;
|
|
32
|
+
userAgent?: string | null | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
} | null, import('better-auth/client').BetterFetchError, {
|
|
35
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
36
|
+
id: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
email: string;
|
|
40
|
+
emailVerified: boolean;
|
|
41
|
+
name: string;
|
|
42
|
+
image?: string | null | undefined;
|
|
43
|
+
} & {} & {
|
|
44
|
+
username?: string | null | undefined;
|
|
45
|
+
displayUsername?: string | null | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
48
|
+
id: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
userId: string;
|
|
52
|
+
expiresAt: Date;
|
|
53
|
+
token: string;
|
|
54
|
+
ipAddress?: string | null | undefined;
|
|
55
|
+
userAgent?: string | null | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
} | null, readonly unknown[]>, "queryFn"> & {
|
|
58
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
59
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
60
|
+
id: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
email: string;
|
|
64
|
+
emailVerified: boolean;
|
|
65
|
+
name: string;
|
|
66
|
+
image?: string | null | undefined;
|
|
67
|
+
} & {} & {
|
|
68
|
+
username?: string | null | undefined;
|
|
69
|
+
displayUsername?: string | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
72
|
+
id: string;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
updatedAt: Date;
|
|
75
|
+
userId: string;
|
|
76
|
+
expiresAt: Date;
|
|
77
|
+
token: string;
|
|
78
|
+
ipAddress?: string | null | undefined;
|
|
79
|
+
userAgent?: string | null | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
} | null, readonly unknown[], never> | undefined;
|
|
82
|
+
} & {
|
|
83
|
+
queryKey: readonly unknown[] & {
|
|
84
|
+
[dataTagSymbol]: {
|
|
85
|
+
user: import('better-auth').StripEmptyObjects<{
|
|
86
|
+
id: string;
|
|
87
|
+
createdAt: Date;
|
|
88
|
+
updatedAt: Date;
|
|
89
|
+
email: string;
|
|
90
|
+
emailVerified: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
image?: string | null | undefined;
|
|
93
|
+
} & {} & {
|
|
94
|
+
username?: string | null | undefined;
|
|
95
|
+
displayUsername?: string | null | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
session: import('better-auth').StripEmptyObjects<{
|
|
98
|
+
id: string;
|
|
99
|
+
createdAt: Date;
|
|
100
|
+
updatedAt: Date;
|
|
101
|
+
userId: string;
|
|
102
|
+
expiresAt: Date;
|
|
103
|
+
token: string;
|
|
104
|
+
ipAddress?: string | null | undefined;
|
|
105
|
+
userAgent?: string | null | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
} | null;
|
|
108
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { BetterFetchError, BetterFetchOption } from 'better-auth/client';
|
|
3
|
+
export type AuthFn<TData = unknown> = (params: {
|
|
4
|
+
query?: Record<string, unknown>;
|
|
5
|
+
fetchOptions?: BetterFetchOption;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
data: TData;
|
|
8
|
+
}>;
|
|
9
|
+
type AuthFnData<TFn> = TFn extends AuthFn<infer TData> ? TData : never;
|
|
10
|
+
/**
|
|
11
|
+
* Build `queryOptions` for a Better Auth endpoint.
|
|
12
|
+
*
|
|
13
|
+
* Appends `params.query` (or `null`) to the supplied `queryKey` so cache
|
|
14
|
+
* identity tracks endpoint inputs. Wires `throw: true` and the React Query
|
|
15
|
+
* `AbortSignal` into `fetchOptions`.
|
|
16
|
+
*
|
|
17
|
+
* @param authFn - Better Auth client method (e.g. `authClient.getSession`).
|
|
18
|
+
* @param queryKey - Scope prefix for the key. `params.query` is appended automatically.
|
|
19
|
+
* @param params - Parameters forwarded to `authFn`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function authQueryOptions<TFn extends AuthFn, const TQueryKey extends QueryKey>(authFn: TFn, queryKey: TQueryKey, params?: Parameters<TFn>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AuthFnData<TFn>, BetterFetchError, AuthFnData<TFn>, readonly unknown[]>, "queryFn"> & {
|
|
22
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<AuthFnData<TFn>, readonly unknown[], never> | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
queryKey: readonly unknown[] & {
|
|
25
|
+
[dataTagSymbol]: AuthFnData<TFn>;
|
|
26
|
+
[dataTagErrorSymbol]: BetterFetchError;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { queryOptions as e } from "@tanstack/react-query";
|
|
2
|
+
//#region src/queries/auth-query-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e({
|
|
5
|
+
queryKey: [...n, r?.query ?? null],
|
|
6
|
+
queryFn: ({ signal: e }) => t({
|
|
7
|
+
...r,
|
|
8
|
+
fetchOptions: {
|
|
9
|
+
...r?.fetchOptions,
|
|
10
|
+
signal: e,
|
|
11
|
+
throw: !0
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as authQueryOptions };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for provider-specific account info.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user. `userId` and `params` are both optional so the factory can
|
|
6
|
+
* build stable options before either is known — the consumer swaps `queryFn`
|
|
7
|
+
* for `skipToken` until ready.
|
|
8
|
+
*
|
|
9
|
+
* @param authClient - The Better Auth client.
|
|
10
|
+
* @param userId - The current signed in user's ID.
|
|
11
|
+
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function accountInfoOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["accountInfo"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
14
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
15
|
+
data: Record<string, any>;
|
|
16
|
+
} | null, import('better-auth/client').BetterFetchError, {
|
|
17
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
18
|
+
data: Record<string, any>;
|
|
19
|
+
} | null, readonly unknown[]>, "queryFn"> & {
|
|
20
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
21
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
22
|
+
data: Record<string, any>;
|
|
23
|
+
} | null, readonly unknown[], never> | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
queryKey: readonly unknown[] & {
|
|
26
|
+
[dataTagSymbol]: {
|
|
27
|
+
user: import('better-auth').OAuth2UserInfo;
|
|
28
|
+
data: Record<string, any>;
|
|
29
|
+
} | null;
|
|
30
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/account-info-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.accountInfo, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"accountInfo"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as accountInfoOptions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for a user's linked social accounts.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
* `userId` is optional so the factory can build stable options before the
|
|
7
|
+
* active session resolves — the consumer swaps `queryFn` for `skipToken`
|
|
8
|
+
* until ready.
|
|
9
|
+
*
|
|
10
|
+
* @param authClient - The Better Auth client.
|
|
11
|
+
* @param userId - The current signed in user's ID.
|
|
12
|
+
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listAccountsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["listAccounts"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
15
|
+
scopes: string[];
|
|
16
|
+
id: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
userId: string;
|
|
20
|
+
providerId: string;
|
|
21
|
+
accountId: string;
|
|
22
|
+
}[] | null, import('better-auth/client').BetterFetchError, {
|
|
23
|
+
scopes: string[];
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
userId: string;
|
|
28
|
+
providerId: string;
|
|
29
|
+
accountId: string;
|
|
30
|
+
}[] | null, readonly unknown[]>, "queryFn"> & {
|
|
31
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
32
|
+
scopes: string[];
|
|
33
|
+
id: string;
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
updatedAt: Date;
|
|
36
|
+
userId: string;
|
|
37
|
+
providerId: string;
|
|
38
|
+
accountId: string;
|
|
39
|
+
}[] | null, readonly unknown[], never> | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
queryKey: readonly unknown[] & {
|
|
42
|
+
[dataTagSymbol]: {
|
|
43
|
+
scopes: string[];
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
userId: string;
|
|
48
|
+
providerId: string;
|
|
49
|
+
accountId: string;
|
|
50
|
+
}[] | null;
|
|
51
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-accounts-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.listAccounts, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listAccounts"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listAccountsOptions };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's device sessions
|
|
4
|
+
* (multi-session account switcher).
|
|
5
|
+
*
|
|
6
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
7
|
+
*
|
|
8
|
+
* @param authClient - The Better Auth client.
|
|
9
|
+
* @param userId - The current signed in user's ID.
|
|
10
|
+
* @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function listDeviceSessionsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["multiSession"]["listDeviceSessions"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
|
|
13
|
+
session: {
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
updatedAt: Date;
|
|
17
|
+
userId: string;
|
|
18
|
+
expiresAt: Date;
|
|
19
|
+
token: string;
|
|
20
|
+
ipAddress?: string | null | undefined;
|
|
21
|
+
userAgent?: string | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
user: {
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
email: string;
|
|
28
|
+
emailVerified: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
image?: string | null | undefined;
|
|
31
|
+
};
|
|
32
|
+
}[] | null, import('better-auth/client').BetterFetchError, {
|
|
33
|
+
session: {
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
userId: string;
|
|
38
|
+
expiresAt: Date;
|
|
39
|
+
token: string;
|
|
40
|
+
ipAddress?: string | null | undefined;
|
|
41
|
+
userAgent?: string | null | undefined;
|
|
42
|
+
};
|
|
43
|
+
user: {
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
email: string;
|
|
48
|
+
emailVerified: boolean;
|
|
49
|
+
name: string;
|
|
50
|
+
image?: string | null | undefined;
|
|
51
|
+
};
|
|
52
|
+
}[] | null, readonly unknown[]>, "queryFn"> & {
|
|
53
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<{
|
|
54
|
+
session: {
|
|
55
|
+
id: string;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
userId: string;
|
|
59
|
+
expiresAt: Date;
|
|
60
|
+
token: string;
|
|
61
|
+
ipAddress?: string | null | undefined;
|
|
62
|
+
userAgent?: string | null | undefined;
|
|
63
|
+
};
|
|
64
|
+
user: {
|
|
65
|
+
id: string;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
updatedAt: Date;
|
|
68
|
+
email: string;
|
|
69
|
+
emailVerified: boolean;
|
|
70
|
+
name: string;
|
|
71
|
+
image?: string | null | undefined;
|
|
72
|
+
};
|
|
73
|
+
}[] | null, readonly unknown[], never> | undefined;
|
|
74
|
+
} & {
|
|
75
|
+
queryKey: readonly unknown[] & {
|
|
76
|
+
[dataTagSymbol]: {
|
|
77
|
+
session: {
|
|
78
|
+
id: string;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
updatedAt: Date;
|
|
81
|
+
userId: string;
|
|
82
|
+
expiresAt: Date;
|
|
83
|
+
token: string;
|
|
84
|
+
ipAddress?: string | null | undefined;
|
|
85
|
+
userAgent?: string | null | undefined;
|
|
86
|
+
};
|
|
87
|
+
user: {
|
|
88
|
+
id: string;
|
|
89
|
+
createdAt: Date;
|
|
90
|
+
updatedAt: Date;
|
|
91
|
+
email: string;
|
|
92
|
+
emailVerified: boolean;
|
|
93
|
+
name: string;
|
|
94
|
+
image?: string | null | undefined;
|
|
95
|
+
};
|
|
96
|
+
}[] | null;
|
|
97
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-device-sessions-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.multiSession.listDeviceSessions, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listDeviceSessions"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listDeviceSessionsOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's active sessions.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
* @param userId - The current signed in user's ID.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function listSessionsOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["listSessions"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('better-auth').Prettify<{
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
userId: string;
|
|
16
|
+
expiresAt: Date;
|
|
17
|
+
token: string;
|
|
18
|
+
ipAddress?: string | null | undefined | undefined;
|
|
19
|
+
userAgent?: string | null | undefined | undefined;
|
|
20
|
+
}>[] | null, import('better-auth/client').BetterFetchError, import('better-auth').Prettify<{
|
|
21
|
+
id: string;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
userId: string;
|
|
25
|
+
expiresAt: Date;
|
|
26
|
+
token: string;
|
|
27
|
+
ipAddress?: string | null | undefined | undefined;
|
|
28
|
+
userAgent?: string | null | undefined | undefined;
|
|
29
|
+
}>[] | null, readonly unknown[]>, "queryFn"> & {
|
|
30
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<import('better-auth').Prettify<{
|
|
31
|
+
id: string;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
updatedAt: Date;
|
|
34
|
+
userId: string;
|
|
35
|
+
expiresAt: Date;
|
|
36
|
+
token: string;
|
|
37
|
+
ipAddress?: string | null | undefined | undefined;
|
|
38
|
+
userAgent?: string | null | undefined | undefined;
|
|
39
|
+
}>[] | null, readonly unknown[], never> | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
queryKey: readonly unknown[] & {
|
|
42
|
+
[dataTagSymbol]: import('better-auth').Prettify<{
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
userId: string;
|
|
47
|
+
expiresAt: Date;
|
|
48
|
+
token: string;
|
|
49
|
+
ipAddress?: string | null | undefined | undefined;
|
|
50
|
+
userAgent?: string | null | undefined | undefined;
|
|
51
|
+
}>[] | null;
|
|
52
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-sessions-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.listSessions, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listSessions"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listSessionsOptions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthClient } from '../../lib/auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Query options factory for the current user's passkeys.
|
|
4
|
+
*
|
|
5
|
+
* Keyed per-user (enables offline account switching with a persister).
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
* @param userId - The current signed in user's ID.
|
|
9
|
+
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function listUserPasskeysOptions(authClient: AuthClient, userId?: string, params?: Parameters<AuthClient["passkey"]["listUserPasskeys"]>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('@better-auth/passkey/client').Passkey[] | null, import('better-auth/client').BetterFetchError, import('@better-auth/passkey/client').Passkey[] | null, readonly unknown[]>, "queryFn"> & {
|
|
12
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<import('@better-auth/passkey/client').Passkey[] | null, readonly unknown[], never> | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
queryKey: readonly unknown[] & {
|
|
15
|
+
[dataTagSymbol]: import('@better-auth/passkey/client').Passkey[] | null;
|
|
16
|
+
[dataTagErrorSymbol]: import('better-auth/client').BetterFetchError;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { authQueryOptions as e } from "../auth-query-options.js";
|
|
2
|
+
//#region src/queries/settings/list-user-passkeys-options.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return e(t.passkey.listUserPasskeys, [
|
|
5
|
+
"auth",
|
|
6
|
+
"user",
|
|
7
|
+
n,
|
|
8
|
+
"listUserPasskeys"
|
|
9
|
+
], r);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as listUserPasskeysOptions };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth-ui/react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "vite build",
|
|
7
7
|
"dev": "tsc --watch",
|
|
8
8
|
"email": "email dev --dir src/components/email -p 9000",
|
|
9
9
|
"test": "vitest"
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"./core": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"types": "./dist/core.d.ts",
|
|
24
|
+
"import": "./dist/core.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@types/react": "^19.2.14",
|
|
34
34
|
"@vitejs/plugin-react": "^6.0.1",
|
|
35
35
|
"@vitest/browser-playwright": "^4.1.4",
|
|
36
|
-
"@better-auth/passkey": "^1.6.
|
|
37
|
-
"better-auth": "^1.6.
|
|
36
|
+
"@better-auth/passkey": "^1.6.5",
|
|
37
|
+
"better-auth": "^1.6.5",
|
|
38
38
|
"clsx": "^2.1.1",
|
|
39
39
|
"playwright": "^1.59.1",
|
|
40
40
|
"react": "^19.2.5",
|
|
41
41
|
"react-dom": "^19.2.5",
|
|
42
|
-
"react-email": "^
|
|
42
|
+
"react-email": "^6.0.0",
|
|
43
43
|
"tailwind-merge": "^3.5.0",
|
|
44
44
|
"tailwindcss": "^4.2.2",
|
|
45
45
|
"vitest": "^4.1.4",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@react-email/components": ">=1.0.12",
|
|
53
53
|
"@tanstack/react-query": ">=5.99.0",
|
|
54
|
-
"@better-auth/passkey": ">=1.6.
|
|
55
|
-
"better-auth": ">=1.6.
|
|
54
|
+
"@better-auth/passkey": ">=1.6.5",
|
|
55
|
+
"better-auth": ">=1.6.5",
|
|
56
56
|
"clsx": ">=2.0.0",
|
|
57
57
|
"react": ">=19.2.5",
|
|
58
58
|
"react-dom": ">=19.2.5",
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { deepmerge, defaultAuthConfig } from "@better-auth-ui/core"
|
|
4
|
-
import {
|
|
5
|
-
type AnyAuthClient,
|
|
6
|
-
type AnyAuthConfig,
|
|
7
|
-
type AuthConfig,
|
|
8
|
-
AuthContext
|
|
9
|
-
} from "@better-auth-ui/react"
|
|
10
4
|
import {
|
|
11
5
|
QueryClient,
|
|
12
6
|
QueryClientContext,
|
|
@@ -14,6 +8,10 @@ import {
|
|
|
14
8
|
} from "@tanstack/react-query"
|
|
15
9
|
import { type PropsWithChildren, useContext } from "react"
|
|
16
10
|
|
|
11
|
+
import type { AnyAuthClient } from "../../lib/auth-client"
|
|
12
|
+
import type { AnyAuthConfig, AuthConfig } from "../../lib/auth-config"
|
|
13
|
+
import { AuthContext } from "../../lib/auth-context"
|
|
14
|
+
|
|
17
15
|
const fallbackQueryClient = new QueryClient()
|
|
18
16
|
|
|
19
17
|
const baseAuthConfig: AnyAuthConfig = {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { type AuthClient, useAuth } from "@better-auth-ui/react"
|
|
2
1
|
import { useEffect } from "react"
|
|
3
|
-
import
|
|
4
|
-
import { useSession } from "./use-session"
|
|
2
|
+
import { useAuth } from "../../components/auth/auth-provider"
|
|
3
|
+
import { type UseSessionOptions, useSession } from "./use-session"
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* Calls `useSession` and redirects unauthenticated users to the sign-in page,
|
|
7
|
+
* preserving the current URL as a `redirectTo` query param.
|
|
8
8
|
*
|
|
9
|
-
* @param options -
|
|
10
|
-
*
|
|
9
|
+
* @param options - Better Auth params (`query`, `fetchOptions`) and React
|
|
10
|
+
* Query options forwarded to `useQuery`.
|
|
11
|
+
* @returns React Query result for the session.
|
|
11
12
|
*/
|
|
12
|
-
export function useAuthenticate(
|
|
13
|
-
options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>
|
|
14
|
-
): UseAuthQueryResult<AuthClient["getSession"]> {
|
|
13
|
+
export function useAuthenticate(options?: UseSessionOptions) {
|
|
15
14
|
const { basePaths, viewPaths, navigate } = useAuth()
|
|
16
15
|
const session = useSession(options)
|
|
17
16
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
2
|
+
|
|
3
|
+
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
+
import { isUsernameAvailableOptions } from "../../mutations/auth/is-username-available-options"
|
|
6
|
+
|
|
7
|
+
export type UseIsUsernameAvailableParams = NonNullable<
|
|
8
|
+
Parameters<AuthClient["isUsernameAvailable"]>[0]
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export type UseIsUsernameAvailableOptions = Omit<
|
|
12
|
+
ReturnType<typeof isUsernameAvailableOptions>,
|
|
13
|
+
"mutationKey" | "mutationFn"
|
|
14
|
+
>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hook that creates a mutation to check if a username is available.
|
|
18
|
+
*
|
|
19
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
20
|
+
* @returns The `useMutation` result where data contains `{ available: boolean }`.
|
|
21
|
+
*/
|
|
22
|
+
export function useIsUsernameAvailable(
|
|
23
|
+
options?: UseIsUsernameAvailableOptions
|
|
24
|
+
) {
|
|
25
|
+
const { authClient } = useAuth()
|
|
26
|
+
|
|
27
|
+
return useMutation({
|
|
28
|
+
...isUsernameAvailableOptions(authClient),
|
|
29
|
+
...options
|
|
30
|
+
})
|
|
31
|
+
}
|