@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
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
2
|
+
|
|
3
|
+
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
+
import { setActiveSessionOptions } from "../../mutations/settings/set-active-session-options"
|
|
6
|
+
import { sessionOptions } from "../../queries/auth/session-options"
|
|
7
|
+
import { useSession } from "../auth/use-session"
|
|
8
|
+
import { useListDeviceSessions } from "./use-list-device-sessions"
|
|
9
|
+
|
|
10
|
+
export type UseSetActiveSessionParams = NonNullable<
|
|
11
|
+
Parameters<AuthClient["multiSession"]["setActive"]>[0]
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
export type UseSetActiveSessionOptions = Omit<
|
|
15
|
+
ReturnType<typeof setActiveSessionOptions>,
|
|
16
|
+
"mutationKey" | "mutationFn"
|
|
17
|
+
>
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* Hook that sets an active device session in multi-session mode.
|
|
13
21
|
*
|
|
22
|
+
* Optimistically switches the cached session to the matching device session,
|
|
23
|
+
* scrolls to top, and refetches both the session and device-session queries.
|
|
24
|
+
*
|
|
25
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
14
26
|
* @returns The `useMutation` result.
|
|
15
27
|
*/
|
|
16
|
-
export function useSetActiveSession(
|
|
17
|
-
options?: UseAuthMutationOptions<AuthClient["multiSession"]["setActive"]>
|
|
18
|
-
) {
|
|
28
|
+
export function useSetActiveSession(options?: UseSetActiveSessionOptions) {
|
|
19
29
|
const queryClient = useQueryClient()
|
|
20
30
|
const { authClient } = useAuth()
|
|
21
|
-
|
|
22
31
|
const { refetch: refetchSession } = useSession({ refetchOnMount: false })
|
|
23
32
|
const { data: deviceSessions, refetch: refetchDeviceSessions } =
|
|
24
33
|
useListDeviceSessions({ refetchOnMount: false })
|
|
25
34
|
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
options
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
return useMutation({
|
|
36
|
+
...setActiveSessionOptions(authClient),
|
|
37
|
+
...options,
|
|
38
|
+
onSuccess: async (data, variables, ...rest) => {
|
|
39
|
+
const sessionToken = variables?.sessionToken
|
|
40
|
+
const deviceSession = deviceSessions?.find(
|
|
41
|
+
(session) => session.session.token === sessionToken
|
|
42
|
+
)
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
if (deviceSession) {
|
|
45
|
+
queryClient.setQueryData(
|
|
46
|
+
sessionOptions(authClient).queryKey,
|
|
47
|
+
deviceSession
|
|
48
|
+
)
|
|
49
|
+
}
|
|
37
50
|
|
|
38
|
-
|
|
51
|
+
window.scrollTo({ top: 0 })
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
53
|
+
await refetchSession()
|
|
54
|
+
await refetchDeviceSessions()
|
|
55
|
+
await options?.onSuccess?.(data, variables, ...rest)
|
|
44
56
|
}
|
|
45
57
|
})
|
|
46
58
|
}
|
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AuthClient,
|
|
3
|
-
useAuth,
|
|
4
|
-
useAuthMutation
|
|
5
|
-
} from "@better-auth-ui/react"
|
|
6
|
-
import type { UseAuthMutationOptions } from "../auth/use-auth-mutation"
|
|
1
|
+
import { useMutation } from "@tanstack/react-query"
|
|
7
2
|
|
|
3
|
+
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
+
import { unlinkAccountOptions } from "../../mutations/settings/unlink-account-options"
|
|
8
6
|
import { useListAccounts } from "./use-list-accounts"
|
|
9
7
|
|
|
8
|
+
export type UseUnlinkAccountParams = NonNullable<
|
|
9
|
+
Parameters<AuthClient["unlinkAccount"]>[0]
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
export type UseUnlinkAccountOptions = Omit<
|
|
13
|
+
ReturnType<typeof unlinkAccountOptions>,
|
|
14
|
+
"mutationKey" | "mutationFn"
|
|
15
|
+
>
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* Hook that creates a mutation for unlinking a social provider from the current user.
|
|
12
19
|
*
|
|
20
|
+
* Refetches the linked accounts list on success.
|
|
21
|
+
*
|
|
22
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
13
23
|
* @returns The `useMutation` result.
|
|
14
24
|
*/
|
|
15
|
-
export function useUnlinkAccount(
|
|
16
|
-
options?: UseAuthMutationOptions<AuthClient["unlinkAccount"]>
|
|
17
|
-
) {
|
|
25
|
+
export function useUnlinkAccount(options?: UseUnlinkAccountOptions) {
|
|
18
26
|
const { authClient } = useAuth()
|
|
19
27
|
const { refetch } = useListAccounts({ refetchOnMount: false })
|
|
20
28
|
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
options
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
await options?.onSuccess?.(...args)
|
|
28
|
-
}
|
|
29
|
+
return useMutation({
|
|
30
|
+
...unlinkAccountOptions(authClient),
|
|
31
|
+
...options,
|
|
32
|
+
onSuccess: async (...args) => {
|
|
33
|
+
await refetch()
|
|
34
|
+
await options?.onSuccess?.(...args)
|
|
29
35
|
}
|
|
30
36
|
})
|
|
31
37
|
}
|
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
2
|
+
|
|
3
|
+
import { useAuth } from "../../components/auth/auth-provider"
|
|
4
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
5
|
+
import { updateUserOptions } from "../../mutations/settings/update-user-options"
|
|
6
|
+
import { sessionOptions } from "../../queries/auth/session-options"
|
|
7
|
+
import { useSession } from "../auth/use-session"
|
|
8
|
+
|
|
9
|
+
export type UseUpdateUserParams = NonNullable<
|
|
10
|
+
Parameters<AuthClient["updateUser"]>[0]
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
export type UseUpdateUserOptions = Omit<
|
|
14
|
+
ReturnType<typeof updateUserOptions>,
|
|
15
|
+
"mutationKey" | "mutationFn"
|
|
16
|
+
>
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* Hook that creates a mutation for updating the authenticated user's profile.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
21
|
+
* Optimistically merges the update into the cached session, then refetches
|
|
22
|
+
* the session to reconcile with the server.
|
|
18
23
|
*
|
|
24
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
19
25
|
* @returns The `useMutation` result.
|
|
20
26
|
*/
|
|
21
|
-
export function useUpdateUser(
|
|
22
|
-
options?: UseAuthMutationOptions<AuthClient["updateUser"]>
|
|
23
|
-
): UseAuthMutationResult<AuthClient["updateUser"]> {
|
|
27
|
+
export function useUpdateUser(options?: UseUpdateUserOptions) {
|
|
24
28
|
const { authClient } = useAuth()
|
|
25
|
-
const { data: session, refetch } = useSession({
|
|
29
|
+
const { data: session, refetch: refetchSession } = useSession({
|
|
30
|
+
refetchOnMount: false
|
|
31
|
+
})
|
|
26
32
|
const queryClient = useQueryClient()
|
|
27
33
|
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
options
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
queryClient.setQueryData(
|
|
34
|
+
return useMutation({
|
|
35
|
+
...updateUserOptions(authClient),
|
|
36
|
+
...options,
|
|
37
|
+
onSuccess: async (data, variables, ...rest) => {
|
|
38
|
+
if (session) {
|
|
39
|
+
queryClient.setQueryData(sessionOptions(authClient).queryKey, {
|
|
34
40
|
...session,
|
|
35
|
-
user: { ...session
|
|
41
|
+
user: { ...session.user, ...variables }
|
|
36
42
|
})
|
|
43
|
+
}
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
refetchSession()
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
}
|
|
47
|
+
await options?.onSuccess?.(data, variables, ...rest)
|
|
42
48
|
}
|
|
43
49
|
})
|
|
44
50
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type MutationKey, useMutation } from "@tanstack/react-query"
|
|
2
|
+
import { authMutationOptions } from "../mutations/auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Escape-hatch hook for Better Auth endpoints that don't have a purpose-built
|
|
6
|
+
* mutation hook in this library yet. Thin wrapper over `useMutation` and
|
|
7
|
+
* `authMutationOptions`.
|
|
8
|
+
*
|
|
9
|
+
* @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
|
|
10
|
+
* @param mutationKey - Scope for the mutation cache key.
|
|
11
|
+
* @param options - React Query options forwarded to `useMutation`.
|
|
12
|
+
*/
|
|
13
|
+
export function useAuthMutation<
|
|
14
|
+
// biome-ignore lint/suspicious/noExplicitAny: matches authMutationOptions' widened constraint
|
|
15
|
+
TFn extends (...args: any) => any,
|
|
16
|
+
const TMutationKey extends MutationKey
|
|
17
|
+
>(
|
|
18
|
+
authFn: TFn,
|
|
19
|
+
mutationKey: TMutationKey,
|
|
20
|
+
options?: Omit<
|
|
21
|
+
ReturnType<typeof authMutationOptions<TFn, TMutationKey>>,
|
|
22
|
+
"mutationKey" | "mutationFn"
|
|
23
|
+
>
|
|
24
|
+
) {
|
|
25
|
+
return useMutation({
|
|
26
|
+
...authMutationOptions(authFn, mutationKey),
|
|
27
|
+
...options
|
|
28
|
+
})
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type QueryKey, useQuery } from "@tanstack/react-query"
|
|
2
|
+
import { type AuthFn, authQueryOptions } from "../queries/auth-query-options"
|
|
3
|
+
|
|
4
|
+
type UseAuthQueryOptions<TFn extends AuthFn, TQueryKey extends QueryKey> = Omit<
|
|
5
|
+
ReturnType<typeof authQueryOptions<TFn, TQueryKey>>,
|
|
6
|
+
"queryKey" | "queryFn"
|
|
7
|
+
> &
|
|
8
|
+
NonNullable<Parameters<TFn>[0]>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Escape-hatch hook for Better Auth endpoints that don't have a purpose-built
|
|
12
|
+
* hook in this library yet. Thin wrapper over `useQuery` and `authQueryOptions`.
|
|
13
|
+
*
|
|
14
|
+
* @param authFn - Better Auth client method (e.g. `authClient.magicLink.list`).
|
|
15
|
+
* @param queryKey - Scope prefix for the key. `options.query` is appended automatically.
|
|
16
|
+
* @param options - Better Auth params (`query`, `fetchOptions`) and React
|
|
17
|
+
* Query options forwarded to `useQuery`.
|
|
18
|
+
*/
|
|
19
|
+
export function useAuthQuery<
|
|
20
|
+
TFn extends AuthFn,
|
|
21
|
+
const TQueryKey extends QueryKey
|
|
22
|
+
>(
|
|
23
|
+
authFn: TFn,
|
|
24
|
+
queryKey: TQueryKey,
|
|
25
|
+
options?: UseAuthQueryOptions<TFn, TQueryKey>
|
|
26
|
+
) {
|
|
27
|
+
const { query, fetchOptions, ...queryOptions } = options ?? {}
|
|
28
|
+
|
|
29
|
+
return useQuery({
|
|
30
|
+
...authQueryOptions(authFn, queryKey, {
|
|
31
|
+
query,
|
|
32
|
+
fetchOptions
|
|
33
|
+
} as Parameters<TFn>[0]),
|
|
34
|
+
...queryOptions
|
|
35
|
+
})
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./components/email"
|
|
|
5
5
|
export * from "./components/icons"
|
|
6
6
|
export * from "./components/settings/account/theme-preview"
|
|
7
7
|
export * from "./hooks/auth/use-authenticate"
|
|
8
|
+
export * from "./hooks/auth/use-is-username-available"
|
|
8
9
|
export * from "./hooks/auth/use-request-password-reset"
|
|
9
10
|
export * from "./hooks/auth/use-reset-password"
|
|
10
11
|
export * from "./hooks/auth/use-send-verification-email"
|
|
@@ -13,6 +14,7 @@ export * from "./hooks/auth/use-sign-in-email"
|
|
|
13
14
|
export * from "./hooks/auth/use-sign-in-magic-link"
|
|
14
15
|
export * from "./hooks/auth/use-sign-in-passkey"
|
|
15
16
|
export * from "./hooks/auth/use-sign-in-social"
|
|
17
|
+
export * from "./hooks/auth/use-sign-in-username"
|
|
16
18
|
export * from "./hooks/auth/use-sign-out"
|
|
17
19
|
export * from "./hooks/auth/use-sign-up-email"
|
|
18
20
|
export * from "./hooks/auth/use-user"
|
|
@@ -32,6 +34,8 @@ export * from "./hooks/settings/use-revoke-session"
|
|
|
32
34
|
export * from "./hooks/settings/use-set-active-session"
|
|
33
35
|
export * from "./hooks/settings/use-unlink-account"
|
|
34
36
|
export * from "./hooks/settings/use-update-user"
|
|
37
|
+
export * from "./hooks/use-auth-mutation"
|
|
38
|
+
export * from "./hooks/use-auth-query"
|
|
35
39
|
export * from "./lib/auth-client"
|
|
36
40
|
export * from "./lib/auth-config"
|
|
37
41
|
export * from "./lib/auth-context"
|
package/src/lib/auth-config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthConfig as BaseAuthConfig } from "@better-auth-ui/
|
|
1
|
+
import type { AuthConfig as BaseAuthConfig } from "@better-auth-ui/core"
|
|
2
2
|
import type { ComponentType, PropsWithChildren } from "react"
|
|
3
3
|
import type { AnyAuthClient, AuthClient } from "./auth-client"
|
|
4
4
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for checking username availability.
|
|
6
|
+
*
|
|
7
|
+
* Modeled as a mutation because callers typically trigger the check on
|
|
8
|
+
* user action (debounced input, form submit) rather than on mount.
|
|
9
|
+
*
|
|
10
|
+
* @param authClient - The Better Auth client.
|
|
11
|
+
*/
|
|
12
|
+
export function isUsernameAvailableOptions(authClient: AuthClient) {
|
|
13
|
+
return authMutationOptions<
|
|
14
|
+
typeof authClient.isUsernameAvailable,
|
|
15
|
+
["auth", "isUsernameAvailable"],
|
|
16
|
+
{ available: boolean; message: string | null }
|
|
17
|
+
>(authClient.isUsernameAvailable, ["auth", "isUsernameAvailable"])
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for requesting a password reset email.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function requestPasswordResetOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.requestPasswordReset, [
|
|
11
|
+
"auth",
|
|
12
|
+
"requestPasswordReset"
|
|
13
|
+
])
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for completing a password reset.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function resetPasswordOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.resetPassword, [
|
|
11
|
+
"auth",
|
|
12
|
+
"resetPassword"
|
|
13
|
+
])
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for sending a verification email.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function sendVerificationEmailOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.sendVerificationEmail, [
|
|
11
|
+
"auth",
|
|
12
|
+
"sendVerificationEmail"
|
|
13
|
+
])
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for email/password sign-in.
|
|
6
|
+
*
|
|
7
|
+
* The returned `mutationKey` (`["auth", "signIn", "email"]`) is stable and
|
|
8
|
+
* can be passed to `useIsMutating` or matched inside a global
|
|
9
|
+
* `MutationCache` observer for toast handling.
|
|
10
|
+
*
|
|
11
|
+
* @param authClient - The Better Auth client.
|
|
12
|
+
*/
|
|
13
|
+
export function signInEmailOptions(authClient: AuthClient) {
|
|
14
|
+
return authMutationOptions(authClient.signIn.email, [
|
|
15
|
+
"auth",
|
|
16
|
+
"signIn",
|
|
17
|
+
"email"
|
|
18
|
+
])
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for magic-link sign-in.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signInMagicLinkOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.signIn.magicLink, [
|
|
11
|
+
"auth",
|
|
12
|
+
"signIn",
|
|
13
|
+
"magicLink"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for passkey sign-in.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signInPasskeyOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.signIn.passkey, [
|
|
11
|
+
"auth",
|
|
12
|
+
"signIn",
|
|
13
|
+
"passkey"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for social sign-in.
|
|
6
|
+
*
|
|
7
|
+
* The returned `mutationKey` (`["auth", "signIn", "social"]`) is stable and
|
|
8
|
+
* can be passed to `useIsMutating` or matched inside a global
|
|
9
|
+
* `MutationCache` observer for toast handling.
|
|
10
|
+
*
|
|
11
|
+
* @param authClient - The Better Auth client.
|
|
12
|
+
*/
|
|
13
|
+
export function signInSocialOptions(authClient: AuthClient) {
|
|
14
|
+
return authMutationOptions(authClient.signIn.social, [
|
|
15
|
+
"auth",
|
|
16
|
+
"signIn",
|
|
17
|
+
"social"
|
|
18
|
+
])
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for username/password sign-in.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signInUsernameOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.signIn.username, [
|
|
11
|
+
"auth",
|
|
12
|
+
"signIn",
|
|
13
|
+
"username"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for signing out.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signOutOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.signOut, ["auth", "signOut"])
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for email/password sign-up.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function signUpEmailOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.signUp.email, [
|
|
11
|
+
"auth",
|
|
12
|
+
"signUp",
|
|
13
|
+
"email"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type MutationKey, mutationOptions } from "@tanstack/react-query"
|
|
2
|
+
import type { BetterFetchError, BetterFetchOption } from "better-auth/client"
|
|
3
|
+
|
|
4
|
+
export type AuthMutationFn<TData = unknown, TVariables = unknown> = (
|
|
5
|
+
params: TVariables & { fetchOptions?: BetterFetchOption }
|
|
6
|
+
) => Promise<{ data: TData }>
|
|
7
|
+
|
|
8
|
+
type AuthMutationFnData<TFn> =
|
|
9
|
+
TFn extends AuthMutationFn<infer TData> ? TData : never
|
|
10
|
+
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: loose constraint for overloaded/generic signatures
|
|
12
|
+
type AuthMutationFnVariables<TFn extends (...args: any) => any> =
|
|
13
|
+
undefined extends Parameters<TFn>[0]
|
|
14
|
+
? // biome-ignore lint/suspicious/noConfusingVoidType: void lets `mutate()` be called with no arg
|
|
15
|
+
void | NonNullable<Parameters<TFn>[0]>
|
|
16
|
+
: Parameters<TFn>[0]
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Build `mutationOptions` for a Better Auth endpoint.
|
|
20
|
+
*
|
|
21
|
+
* Wires `throw: true` into `fetchOptions` so the mutation rejects with a
|
|
22
|
+
* `BetterFetchError` on failure instead of resolving with `{ error }`.
|
|
23
|
+
*
|
|
24
|
+
* TData is inferred from the endpoint's non-throw response shape. For
|
|
25
|
+
* required-body endpoints where inference falls back to `never`, pass
|
|
26
|
+
* `TData` explicitly (e.g. `authMutationOptions<_, _, { available: boolean }>`).
|
|
27
|
+
*
|
|
28
|
+
* @param authFn - Better Auth client method (e.g. `authClient.signIn.email`).
|
|
29
|
+
* @param mutationKey - Scope for the mutation cache key.
|
|
30
|
+
*/
|
|
31
|
+
export function authMutationOptions<
|
|
32
|
+
// biome-ignore lint/suspicious/noExplicitAny: constraint widened so required-body endpoints pass
|
|
33
|
+
TFn extends (...args: any) => any,
|
|
34
|
+
const TMutationKey extends MutationKey,
|
|
35
|
+
TData = AuthMutationFnData<TFn>
|
|
36
|
+
>(authFn: TFn, mutationKey: TMutationKey) {
|
|
37
|
+
return mutationOptions<TData, BetterFetchError, AuthMutationFnVariables<TFn>>(
|
|
38
|
+
{
|
|
39
|
+
mutationKey,
|
|
40
|
+
mutationFn: (variables) => {
|
|
41
|
+
const v = variables as { fetchOptions?: BetterFetchOption } | undefined
|
|
42
|
+
return authFn({
|
|
43
|
+
...v,
|
|
44
|
+
fetchOptions: { ...v?.fetchOptions, throw: true }
|
|
45
|
+
} as Parameters<TFn>[0]) as Promise<TData>
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for registering a new passkey.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function addPasskeyOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.passkey.addPasskey, [
|
|
11
|
+
"auth",
|
|
12
|
+
"passkey",
|
|
13
|
+
"addPasskey"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for changing the current user's email address.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function changeEmailOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.changeEmail, ["auth", "changeEmail"])
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for changing the authenticated user's password.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function changePasswordOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.changePassword, [
|
|
11
|
+
"auth",
|
|
12
|
+
"changePassword"
|
|
13
|
+
])
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for deleting a passkey.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function deletePasskeyOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.passkey.deletePasskey, [
|
|
11
|
+
"auth",
|
|
12
|
+
"passkey",
|
|
13
|
+
"deletePasskey"
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for deleting the authenticated user's account.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function deleteUserOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.deleteUser, ["auth", "deleteUser"])
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for linking a social provider to the current user.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function linkSocialOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.linkSocial, ["auth", "linkSocial"])
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthClient } from "../../lib/auth-client"
|
|
2
|
+
import { authMutationOptions } from "../auth-mutation-options"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mutation options factory for revoking a device session in multi-session mode.
|
|
6
|
+
*
|
|
7
|
+
* @param authClient - The Better Auth client.
|
|
8
|
+
*/
|
|
9
|
+
export function revokeMultiSessionOptions(authClient: AuthClient) {
|
|
10
|
+
return authMutationOptions(authClient.multiSession.revoke, [
|
|
11
|
+
"auth",
|
|
12
|
+
"multiSession",
|
|
13
|
+
"revoke"
|
|
14
|
+
])
|
|
15
|
+
}
|