@better-auth-ui/react 1.6.9 → 1.6.11
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-context.d.ts +2 -2
- package/dist/components/auth/auth-provider.d.ts +4 -4
- package/dist/components/auth/email/email-changed.d.ts +2 -2
- package/dist/components/auth/email/email-verification.d.ts +2 -2
- package/dist/components/auth/email/index.d.ts +10 -10
- package/dist/components/auth/email/magic-link.d.ts +2 -2
- package/dist/components/auth/email/new-device.d.ts +2 -2
- package/dist/components/auth/email/organization-invitation.d.ts +2 -2
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed.d.ts +2 -2
- package/dist/components/auth/email/reset-password.d.ts +2 -2
- package/dist/components/auth/fetch-options-provider.d.ts +1 -1
- package/dist/components/icons/apple.d.ts +1 -1
- package/dist/components/icons/atlassian.d.ts +1 -1
- package/dist/components/icons/cognito.d.ts +1 -1
- package/dist/components/icons/discord.d.ts +1 -1
- package/dist/components/icons/dropbox.d.ts +1 -1
- package/dist/components/icons/facebook.d.ts +1 -1
- package/dist/components/icons/figma.d.ts +1 -1
- package/dist/components/icons/github.d.ts +1 -1
- package/dist/components/icons/gitlab.d.ts +1 -1
- package/dist/components/icons/google.d.ts +1 -1
- package/dist/components/icons/huggingface.d.ts +1 -1
- package/dist/components/icons/index.d.ts +35 -35
- package/dist/components/icons/kakao.d.ts +1 -1
- package/dist/components/icons/kick.d.ts +1 -1
- package/dist/components/icons/line.d.ts +1 -1
- package/dist/components/icons/linear.d.ts +1 -1
- package/dist/components/icons/linkedin.d.ts +1 -1
- package/dist/components/icons/microsoft.d.ts +1 -1
- package/dist/components/icons/naver.d.ts +1 -1
- package/dist/components/icons/notion.d.ts +1 -1
- package/dist/components/icons/paybin.d.ts +1 -1
- package/dist/components/icons/paypal.d.ts +1 -1
- package/dist/components/icons/polar.d.ts +1 -1
- package/dist/components/icons/railway.d.ts +1 -1
- package/dist/components/icons/reddit.d.ts +1 -1
- package/dist/components/icons/roblox.d.ts +1 -1
- package/dist/components/icons/salesforce.d.ts +1 -1
- package/dist/components/icons/slack.d.ts +1 -1
- package/dist/components/icons/spotify.d.ts +1 -1
- package/dist/components/icons/tiktok.d.ts +1 -1
- package/dist/components/icons/twitch.d.ts +1 -1
- package/dist/components/icons/vercel.d.ts +1 -1
- package/dist/components/icons/vk.d.ts +1 -1
- package/dist/components/icons/wechat.d.ts +1 -1
- package/dist/components/icons/x.d.ts +1 -1
- package/dist/components/icons/zoom.d.ts +1 -1
- package/dist/email.d.ts +1 -1
- package/dist/email.js +1348 -1
- package/dist/hooks/auth/use-authenticate.d.ts +3 -3
- package/dist/hooks/auth/use-user.d.ts +34 -34
- package/dist/hooks/use-auth-mutation.d.ts +4 -4
- package/dist/hooks/use-auth-plugin.d.ts +1 -1
- package/dist/hooks/use-auth-query.d.ts +3 -3
- package/dist/index.d.ts +48 -48
- package/dist/index.js +2469 -47
- package/dist/lib/auth-client.d.ts +4 -4
- package/dist/lib/auth-plugin.d.ts +4 -4
- package/dist/lib/auth-server.d.ts +4 -4
- package/dist/lib/provider-icons.d.ts +2 -2
- package/dist/lib/settings-tab.d.ts +2 -2
- package/dist/lib/utils.d.ts +1 -1
- package/dist/mutations/api-key/create-api-key-mutation.d.ts +5 -5
- package/dist/mutations/api-key/delete-api-key-mutation.d.ts +5 -5
- package/dist/mutations/auth/request-password-reset-mutation.d.ts +4 -4
- package/dist/mutations/auth/reset-password-mutation.d.ts +4 -4
- package/dist/mutations/auth/send-verification-email-mutation.d.ts +4 -4
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +7 -7
- package/dist/mutations/auth/sign-in-social-mutation.d.ts +6 -6
- package/dist/mutations/auth/sign-out-mutation.d.ts +5 -5
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +9 -9
- package/dist/mutations/auth-mutation-options.d.ts +2 -2
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +4 -4
- package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +5 -5
- package/dist/mutations/multi-session/set-active-session-mutation.d.ts +5 -5
- package/dist/mutations/organization/accept-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/cancel-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/check-slug-mutation.d.ts +4 -4
- package/dist/mutations/organization/create-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/delete-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/index.d.ts +12 -12
- package/dist/mutations/organization/invite-member-mutation.d.ts +9 -9
- package/dist/mutations/organization/leave-organization-mutation.d.ts +5 -5
- package/dist/mutations/organization/reject-invitation-mutation.d.ts +7 -7
- package/dist/mutations/organization/remove-member-mutation.d.ts +5 -5
- package/dist/mutations/organization/set-active-organization-mutation.d.ts +7 -7
- package/dist/mutations/organization/update-member-role-mutation.d.ts +5 -5
- package/dist/mutations/organization/update-organization-mutation.d.ts +5 -5
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +13 -13
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +5 -5
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +21 -21
- package/dist/mutations/settings/change-email-mutation.d.ts +5 -5
- package/dist/mutations/settings/change-password-mutation.d.ts +6 -6
- package/dist/mutations/settings/delete-user-mutation.d.ts +4 -4
- package/dist/mutations/settings/link-social-mutation.d.ts +4 -4
- package/dist/mutations/settings/revoke-session-mutation.d.ts +5 -5
- package/dist/mutations/settings/unlink-account-mutation.d.ts +5 -5
- package/dist/mutations/settings/update-user-mutation.d.ts +5 -5
- package/dist/mutations/username/is-username-available-mutation.d.ts +4 -4
- package/dist/mutations/username/sign-in-username-mutation.d.ts +7 -7
- package/dist/plugins/captcha-plugin.d.ts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +27 -1
- package/dist/queries/api-key/list-api-keys-query.d.ts +6 -6
- package/dist/queries/auth/session-query.d.ts +6 -6
- package/dist/queries/auth-query-options.d.ts +2 -2
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +6 -6
- package/dist/queries/organization/active-organization-query.d.ts +8 -8
- package/dist/queries/organization/full-organization-query.d.ts +6 -6
- package/dist/queries/organization/has-permission-query.d.ts +6 -6
- package/dist/queries/organization/index.d.ts +7 -7
- package/dist/queries/organization/list-invitations-query.d.ts +6 -6
- package/dist/queries/organization/list-members-query.d.ts +6 -6
- package/dist/queries/organization/list-organizations-query.d.ts +6 -6
- package/dist/queries/organization/list-user-invitations-query.d.ts +6 -6
- package/dist/queries/passkey/list-passkeys-query.d.ts +6 -6
- package/dist/queries/settings/account-info-query.d.ts +6 -6
- package/dist/queries/settings/list-accounts-query.d.ts +6 -6
- package/dist/queries/settings/list-sessions-query.d.ts +6 -6
- package/dist/server/queries/api-key/list-api-keys-query.d.ts +5 -5
- package/dist/server/queries/auth/session-query.d.ts +5 -5
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +5 -5
- package/dist/server/queries/organization/active-organization-query.d.ts +7 -7
- package/dist/server/queries/organization/full-organization-query.d.ts +5 -5
- package/dist/server/queries/organization/has-permission-query.d.ts +5 -5
- package/dist/server/queries/organization/list-invitations-query.d.ts +5 -5
- package/dist/server/queries/organization/list-members-query.d.ts +5 -5
- package/dist/server/queries/organization/list-organizations-query.d.ts +5 -5
- package/dist/server/queries/organization/list-user-invitations-query.d.ts +5 -5
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +5 -5
- package/dist/server/queries/settings/account-info-query.d.ts +5 -5
- package/dist/server/queries/settings/list-accounts-query.d.ts +5 -5
- package/dist/server/queries/settings/list-sessions-query.d.ts +5 -5
- package/dist/server.d.ts +15 -15
- package/dist/server.js +131 -14
- package/dist/use-auth-plugin-ClcP84Uz.js +80 -0
- package/package.json +2 -2
- package/dist/components/auth/auth-context.js +0 -4
- package/dist/components/auth/auth-provider.js +0 -68
- package/dist/components/auth/email/email-changed.js +0 -70
- package/dist/components/auth/email/email-localization.js +0 -26
- package/dist/components/auth/email/email-styles.js +0 -129
- package/dist/components/auth/email/email-verification.js +0 -75
- package/dist/components/auth/email/index.js +0 -10
- package/dist/components/auth/email/magic-link.js +0 -72
- package/dist/components/auth/email/new-device.js +0 -90
- package/dist/components/auth/email/organization-invitation.js +0 -110
- package/dist/components/auth/email/otp-email.js +0 -65
- package/dist/components/auth/email/password-changed.js +0 -76
- package/dist/components/auth/email/reset-password.js +0 -68
- package/dist/components/auth/fetch-options-provider.js +0 -31
- package/dist/components/icons/apple.js +0 -10
- package/dist/components/icons/atlassian.js +0 -14
- package/dist/components/icons/cognito.js +0 -10
- package/dist/components/icons/discord.js +0 -10
- package/dist/components/icons/dropbox.js +0 -10
- package/dist/components/icons/facebook.js +0 -12
- package/dist/components/icons/figma.js +0 -13
- package/dist/components/icons/github.js +0 -12
- package/dist/components/icons/gitlab.js +0 -10
- package/dist/components/icons/google.js +0 -10
- package/dist/components/icons/huggingface.js +0 -10
- package/dist/components/icons/index.js +0 -35
- package/dist/components/icons/kakao.js +0 -12
- package/dist/components/icons/kick.js +0 -12
- package/dist/components/icons/line.js +0 -10
- package/dist/components/icons/linear.js +0 -10
- package/dist/components/icons/linkedin.js +0 -10
- package/dist/components/icons/microsoft.js +0 -10
- package/dist/components/icons/naver.js +0 -10
- package/dist/components/icons/notion.js +0 -10
- package/dist/components/icons/paybin.js +0 -9
- package/dist/components/icons/paypal.js +0 -10
- package/dist/components/icons/polar.js +0 -10
- package/dist/components/icons/railway.js +0 -10
- package/dist/components/icons/reddit.js +0 -10
- package/dist/components/icons/roblox.js +0 -13
- package/dist/components/icons/salesforce.js +0 -10
- package/dist/components/icons/slack.js +0 -10
- package/dist/components/icons/spotify.js +0 -10
- package/dist/components/icons/tiktok.js +0 -11
- package/dist/components/icons/twitch.js +0 -13
- package/dist/components/icons/vercel.js +0 -10
- package/dist/components/icons/vk.js +0 -10
- package/dist/components/icons/wechat.js +0 -10
- package/dist/components/icons/x.js +0 -10
- package/dist/components/icons/zoom.js +0 -12
- package/dist/components/mutation-invalidator.js +0 -31
- package/dist/components/settings/account/theme-preview.js +0 -10
- package/dist/hooks/auth/use-authenticate.js +0 -29
- package/dist/hooks/auth/use-user.js +0 -15
- package/dist/hooks/use-auth-mutation.js +0 -19
- package/dist/hooks/use-auth-plugin.js +0 -28
- package/dist/hooks/use-auth-query.js +0 -21
- package/dist/lib/auth-client.js +0 -1
- package/dist/lib/auth-plugin.js +0 -1
- package/dist/lib/auth-server.js +0 -1
- package/dist/lib/provider-icons.js +0 -48
- package/dist/lib/settings-tab.js +0 -1
- package/dist/lib/utils.js +0 -5
- package/dist/mutations/api-key/create-api-key-mutation.js +0 -39
- package/dist/mutations/api-key/delete-api-key-mutation.js +0 -39
- package/dist/mutations/auth/request-password-reset-mutation.js +0 -33
- package/dist/mutations/auth/reset-password-mutation.js +0 -34
- package/dist/mutations/auth/send-verification-email-mutation.js +0 -33
- package/dist/mutations/auth/sign-in-email-mutation.js +0 -40
- package/dist/mutations/auth/sign-in-social-mutation.js +0 -38
- package/dist/mutations/auth/sign-out-mutation.js +0 -41
- package/dist/mutations/auth/sign-up-email-mutation.js +0 -36
- package/dist/mutations/auth-mutation-options.js +0 -23
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +0 -33
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +0 -39
- package/dist/mutations/multi-session/set-active-session-mutation.js +0 -40
- package/dist/mutations/organization/accept-invitation-mutation.js +0 -32
- package/dist/mutations/organization/cancel-invitation-mutation.js +0 -28
- package/dist/mutations/organization/check-slug-mutation.js +0 -30
- package/dist/mutations/organization/create-organization-mutation.js +0 -29
- package/dist/mutations/organization/delete-organization-mutation.js +0 -29
- package/dist/mutations/organization/index.js +0 -12
- package/dist/mutations/organization/invite-member-mutation.js +0 -35
- package/dist/mutations/organization/leave-organization-mutation.js +0 -32
- package/dist/mutations/organization/reject-invitation-mutation.js +0 -25
- package/dist/mutations/organization/remove-member-mutation.js +0 -29
- package/dist/mutations/organization/set-active-organization-mutation.js +0 -72
- package/dist/mutations/organization/update-member-role-mutation.js +0 -36
- package/dist/mutations/organization/update-organization-mutation.js +0 -36
- package/dist/mutations/passkey/add-passkey-mutation.js +0 -40
- package/dist/mutations/passkey/delete-passkey-mutation.js +0 -39
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +0 -38
- package/dist/mutations/settings/change-email-mutation.js +0 -37
- package/dist/mutations/settings/change-password-mutation.js +0 -33
- package/dist/mutations/settings/delete-user-mutation.js +0 -33
- package/dist/mutations/settings/link-social-mutation.js +0 -33
- package/dist/mutations/settings/revoke-session-mutation.js +0 -39
- package/dist/mutations/settings/unlink-account-mutation.js +0 -39
- package/dist/mutations/settings/update-user-mutation.js +0 -36
- package/dist/mutations/username/is-username-available-mutation.js +0 -36
- package/dist/mutations/username/sign-in-username-mutation.js +0 -37
- package/dist/plugins/captcha-plugin.js +0 -34
- package/dist/queries/api-key/list-api-keys-query.js +0 -54
- package/dist/queries/auth/session-query.js +0 -72
- package/dist/queries/auth-query-options.js +0 -21
- package/dist/queries/multi-session/list-device-sessions-query.js +0 -85
- package/dist/queries/organization/active-organization-query.js +0 -37
- package/dist/queries/organization/full-organization-query.js +0 -31
- package/dist/queries/organization/has-permission-query.js +0 -38
- package/dist/queries/organization/index.js +0 -7
- package/dist/queries/organization/list-invitations-query.js +0 -37
- package/dist/queries/organization/list-members-query.js +0 -37
- package/dist/queries/organization/list-organizations-query.js +0 -31
- package/dist/queries/organization/list-user-invitations-query.js +0 -31
- package/dist/queries/passkey/list-passkeys-query.js +0 -83
- package/dist/queries/settings/account-info-query.js +0 -87
- package/dist/queries/settings/list-accounts-query.js +0 -85
- package/dist/queries/settings/list-sessions-query.js +0 -83
- package/dist/server/queries/api-key/list-api-keys-query.js +0 -49
- package/dist/server/queries/auth/session-query.js +0 -51
- package/dist/server/queries/multi-session/list-device-sessions-query.js +0 -54
- package/dist/server/queries/organization/active-organization-query.js +0 -25
- package/dist/server/queries/organization/full-organization-query.js +0 -21
- package/dist/server/queries/organization/has-permission-query.js +0 -23
- package/dist/server/queries/organization/list-invitations-query.js +0 -21
- package/dist/server/queries/organization/list-members-query.js +0 -21
- package/dist/server/queries/organization/list-organizations-query.js +0 -21
- package/dist/server/queries/organization/list-user-invitations-query.js +0 -21
- package/dist/server/queries/passkey/list-passkeys-query.js +0 -54
- package/dist/server/queries/settings/account-info-query.js +0 -54
- package/dist/server/queries/settings/list-accounts-query.js +0 -54
- package/dist/server/queries/settings/list-sessions-query.js +0 -54
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
2
|
-
/**
|
|
3
|
-
* Retrieve the current authenticated user. Thin wrapper over `useSession`
|
|
4
|
-
* that returns `session.user` as `data`.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
* @param options - `getSession` params & `useQuery` options.
|
|
8
|
-
*/
|
|
9
|
-
export function useUser(authClient, options) {
|
|
10
|
-
const { data, ...rest } = useSession(authClient, options);
|
|
11
|
-
return {
|
|
12
|
-
data: data?.user,
|
|
13
|
-
...rest
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
|
2
|
-
import { authMutationOptions } from "../mutations/auth-mutation-options";
|
|
3
|
-
/**
|
|
4
|
-
* Escape-hatch hook for Better Auth write endpoints that don't have a
|
|
5
|
-
* purpose-built mutation hook in this library yet. Thin wrapper over
|
|
6
|
-
* `useMutation` and `authMutationOptions`.
|
|
7
|
-
*
|
|
8
|
-
* @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
|
|
9
|
-
* @param mutationKey - Stable key for the mutation. Prefer an entry from
|
|
10
|
-
* `authMutationKeys` over an inline tuple so `useIsMutating` and global
|
|
11
|
-
* `MutationCache` observers line up.
|
|
12
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
13
|
-
*/
|
|
14
|
-
export function useAuthMutation(authFn, mutationKey, options) {
|
|
15
|
-
return useMutation({
|
|
16
|
-
...authMutationOptions(authFn, mutationKey),
|
|
17
|
-
...options
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useAuth } from "../components/auth/auth-provider";
|
|
3
|
-
/**
|
|
4
|
-
* Access a registered plugin by passing its factory.
|
|
5
|
-
*
|
|
6
|
-
* Use inside plugin slot components to read plugin state (localization,
|
|
7
|
-
* config, etc.) without prop drilling.
|
|
8
|
-
*
|
|
9
|
-
* Throws if the plugin isn't registered on `AuthProvider` — this is an
|
|
10
|
-
* invariant: plugin slot components only render when their plugin is in
|
|
11
|
-
* `plugins`.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* function PasskeyButton() {
|
|
16
|
-
* const { localization } = useAuthPlugin(passkeyPlugin)
|
|
17
|
-
* return <button>{localization.passkey}</button>
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export function useAuthPlugin(pluginFactory) {
|
|
22
|
-
const { plugins } = useAuth();
|
|
23
|
-
const plugin = plugins?.find((p) => p.id === pluginFactory.id);
|
|
24
|
-
if (!plugin) {
|
|
25
|
-
throw new Error(`[Better Auth UI] useAuthPlugin: plugin "${pluginFactory.id}" is not registered on AuthProvider.`);
|
|
26
|
-
}
|
|
27
|
-
return plugin;
|
|
28
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { authQueryOptions } from "../queries/auth-query-options";
|
|
3
|
-
/**
|
|
4
|
-
* Escape-hatch hook for Better Auth endpoints that don't have a purpose-built
|
|
5
|
-
* hook in this library yet. Thin wrapper over `useQuery` and `authQueryOptions`.
|
|
6
|
-
*
|
|
7
|
-
* @param authFn - Better Auth client method (e.g. `authClient.magicLink.list`).
|
|
8
|
-
* @param queryKey - Scope prefix for the key. `options.query` is appended automatically.
|
|
9
|
-
* @param options - Better Auth params (`query`, `fetchOptions`) and React
|
|
10
|
-
* Query options forwarded to `useQuery`.
|
|
11
|
-
*/
|
|
12
|
-
export function useAuthQuery(authFn, queryKey, options) {
|
|
13
|
-
const { query, fetchOptions, ...queryOptions } = options ?? {};
|
|
14
|
-
return useQuery({
|
|
15
|
-
...authQueryOptions(authFn, queryKey, {
|
|
16
|
-
query,
|
|
17
|
-
fetchOptions
|
|
18
|
-
}),
|
|
19
|
-
...queryOptions
|
|
20
|
-
});
|
|
21
|
-
}
|
package/dist/lib/auth-client.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/auth-plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/auth-server.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Apple, Atlassian, Cognito, Discord, Dropbox, Facebook, Figma, GitHub, GitLab, Google, HuggingFace, Kakao, Kick, Line, Linear, LinkedIn, Microsoft, Naver, Notion, Paybin, PayPal, Polar, Railway, Reddit, Roblox, Salesforce, Slack, Spotify, TikTok, Twitch, Vercel, VK, WeChat, X, Zoom } from "../components/icons";
|
|
2
|
-
/**
|
|
3
|
-
* Mapping of social authentication provider names to their corresponding icon components.
|
|
4
|
-
*
|
|
5
|
-
* Provides React SVG icon components for all supported social authentication providers.
|
|
6
|
-
* Each icon is a React component that accepts standard SVG props and can be customized
|
|
7
|
-
* with className, size, color, etc.
|
|
8
|
-
*
|
|
9
|
-
* Supported providers include: Apple, Google, GitHub, Microsoft, Discord, Facebook,
|
|
10
|
-
* Twitter/X, and many others.
|
|
11
|
-
*/
|
|
12
|
-
export const providerIcons = {
|
|
13
|
-
apple: Apple,
|
|
14
|
-
atlassian: Atlassian,
|
|
15
|
-
cognito: Cognito,
|
|
16
|
-
discord: Discord,
|
|
17
|
-
dropbox: Dropbox,
|
|
18
|
-
facebook: Facebook,
|
|
19
|
-
figma: Figma,
|
|
20
|
-
github: GitHub,
|
|
21
|
-
gitlab: GitLab,
|
|
22
|
-
google: Google,
|
|
23
|
-
huggingface: HuggingFace,
|
|
24
|
-
kakao: Kakao,
|
|
25
|
-
kick: Kick,
|
|
26
|
-
line: Line,
|
|
27
|
-
linear: Linear,
|
|
28
|
-
linkedin: LinkedIn,
|
|
29
|
-
microsoft: Microsoft,
|
|
30
|
-
naver: Naver,
|
|
31
|
-
notion: Notion,
|
|
32
|
-
paybin: Paybin,
|
|
33
|
-
paypal: PayPal,
|
|
34
|
-
polar: Polar,
|
|
35
|
-
railway: Railway,
|
|
36
|
-
reddit: Reddit,
|
|
37
|
-
roblox: Roblox,
|
|
38
|
-
salesforce: Salesforce,
|
|
39
|
-
slack: Slack,
|
|
40
|
-
spotify: Spotify,
|
|
41
|
-
tiktok: TikTok,
|
|
42
|
-
twitch: Twitch,
|
|
43
|
-
twitter: X,
|
|
44
|
-
vercel: Vercel,
|
|
45
|
-
vk: VK,
|
|
46
|
-
wechat: WeChat,
|
|
47
|
-
zoom: Zoom
|
|
48
|
-
};
|
package/dist/lib/settings-tab.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/utils.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { apiKeyMutationKeys, apiKeyQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Mutation options factory for creating an API key.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client with the API key plugin.
|
|
8
|
-
*/
|
|
9
|
-
export function createApiKeyOptions(authClient) {
|
|
10
|
-
const mutationKey = apiKeyMutationKeys.create;
|
|
11
|
-
const mutationFn = (params) => authClient.apiKey.create({
|
|
12
|
-
...params,
|
|
13
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
-
});
|
|
15
|
-
return mutationOptions({
|
|
16
|
-
mutationKey,
|
|
17
|
-
mutationFn
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a mutation for creating an API key.
|
|
22
|
-
*
|
|
23
|
-
* On success, `MutationInvalidator` awaits invalidation of the user's API key
|
|
24
|
-
* list queries (see `meta.awaits`).
|
|
25
|
-
*
|
|
26
|
-
* @param authClient - The Better Auth client with the API key plugin.
|
|
27
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
-
*/
|
|
29
|
-
export function useCreateApiKey(authClient, options, queryClient) {
|
|
30
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
31
|
-
const userId = session?.user.id;
|
|
32
|
-
return useMutation({
|
|
33
|
-
...createApiKeyOptions(authClient),
|
|
34
|
-
...options,
|
|
35
|
-
meta: {
|
|
36
|
-
awaits: [apiKeyQueryKeys.lists(userId)]
|
|
37
|
-
}
|
|
38
|
-
}, queryClient);
|
|
39
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { apiKeyMutationKeys, apiKeyQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Mutation options factory for deleting an API key.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client with the API key plugin.
|
|
8
|
-
*/
|
|
9
|
-
export function deleteApiKeyOptions(authClient) {
|
|
10
|
-
const mutationKey = apiKeyMutationKeys.delete;
|
|
11
|
-
const mutationFn = (params) => authClient.apiKey.delete({
|
|
12
|
-
...params,
|
|
13
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
-
});
|
|
15
|
-
return mutationOptions({
|
|
16
|
-
mutationKey,
|
|
17
|
-
mutationFn
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a mutation for deleting an API key.
|
|
22
|
-
*
|
|
23
|
-
* On success, `MutationInvalidator` awaits invalidation of the user's API key
|
|
24
|
-
* list queries (see `meta.awaits`).
|
|
25
|
-
*
|
|
26
|
-
* @param authClient - The Better Auth client with the API key plugin.
|
|
27
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
-
*/
|
|
29
|
-
export function useDeleteApiKey(authClient, options, queryClient) {
|
|
30
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
31
|
-
const userId = session?.user.id;
|
|
32
|
-
return useMutation({
|
|
33
|
-
...deleteApiKeyOptions(authClient),
|
|
34
|
-
...options,
|
|
35
|
-
meta: {
|
|
36
|
-
awaits: [apiKeyQueryKeys.lists(userId)]
|
|
37
|
-
}
|
|
38
|
-
}, queryClient);
|
|
39
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for requesting a password reset email.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function requestPasswordResetOptions(authClient) {
|
|
9
|
-
const mutationKey = authMutationKeys.requestPasswordReset;
|
|
10
|
-
const mutationFn = (params) => authClient.requestPasswordReset({
|
|
11
|
-
...params,
|
|
12
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
-
});
|
|
14
|
-
return mutationOptions({
|
|
15
|
-
mutationKey,
|
|
16
|
-
mutationFn
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a mutation for requesting a password reset email.
|
|
21
|
-
*
|
|
22
|
-
* Wraps `authClient.requestPasswordReset` and forwards React Query mutation
|
|
23
|
-
* options such as `onSuccess`, `onError`, and `retry`.
|
|
24
|
-
*
|
|
25
|
-
* @param authClient - The Better Auth client.
|
|
26
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
-
*/
|
|
28
|
-
export function useRequestPasswordReset(authClient, options) {
|
|
29
|
-
return useMutation({
|
|
30
|
-
...requestPasswordResetOptions(authClient),
|
|
31
|
-
...options
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for completing a password reset.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function resetPasswordOptions(authClient) {
|
|
9
|
-
const mutationKey = authMutationKeys.resetPassword;
|
|
10
|
-
const mutationFn = (params) => authClient.resetPassword({
|
|
11
|
-
...params,
|
|
12
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
-
});
|
|
14
|
-
return mutationOptions({
|
|
15
|
-
mutationKey,
|
|
16
|
-
mutationFn
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a mutation for completing a password reset.
|
|
21
|
-
*
|
|
22
|
-
* Wraps `authClient.resetPassword` (using the token from the reset email)
|
|
23
|
-
* and forwards React Query mutation options such as `onSuccess`, `onError`,
|
|
24
|
-
* and `retry`.
|
|
25
|
-
*
|
|
26
|
-
* @param authClient - The Better Auth client.
|
|
27
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
-
*/
|
|
29
|
-
export function useResetPassword(authClient, options) {
|
|
30
|
-
return useMutation({
|
|
31
|
-
...resetPasswordOptions(authClient),
|
|
32
|
-
...options
|
|
33
|
-
});
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for sending a verification email.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function sendVerificationEmailOptions(authClient) {
|
|
9
|
-
const mutationKey = authMutationKeys.sendVerificationEmail;
|
|
10
|
-
const mutationFn = (params) => authClient.sendVerificationEmail({
|
|
11
|
-
...params,
|
|
12
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
-
});
|
|
14
|
-
return mutationOptions({
|
|
15
|
-
mutationKey,
|
|
16
|
-
mutationFn
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a mutation for sending an email-verification link.
|
|
21
|
-
*
|
|
22
|
-
* Wraps `authClient.sendVerificationEmail` and forwards React Query mutation
|
|
23
|
-
* options such as `onSuccess`, `onError`, and `retry`.
|
|
24
|
-
*
|
|
25
|
-
* @param authClient - The Better Auth client.
|
|
26
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
-
*/
|
|
28
|
-
export function useSendVerificationEmail(authClient, options) {
|
|
29
|
-
return useMutation({
|
|
30
|
-
...sendVerificationEmailOptions(authClient),
|
|
31
|
-
...options
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for email/password sign-in.
|
|
5
|
-
*
|
|
6
|
-
* The returned `mutationKey` (`authMutationKeys.signIn.email`) is stable and
|
|
7
|
-
* can be passed to `useIsMutating` or matched inside a global
|
|
8
|
-
* `MutationCache` observer for toast handling.
|
|
9
|
-
*
|
|
10
|
-
* @param authClient - The Better Auth client.
|
|
11
|
-
*/
|
|
12
|
-
export function signInEmailOptions(authClient) {
|
|
13
|
-
const mutationKey = authMutationKeys.signIn.email;
|
|
14
|
-
const mutationFn = (params) => authClient.signIn.email({
|
|
15
|
-
...params,
|
|
16
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
17
|
-
});
|
|
18
|
-
return mutationOptions({
|
|
19
|
-
mutationKey,
|
|
20
|
-
mutationFn
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create a mutation for email/password sign-in.
|
|
25
|
-
*
|
|
26
|
-
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
27
|
-
* query so the new session is refetched (see `meta.awaits`).
|
|
28
|
-
*
|
|
29
|
-
* @param authClient - The Better Auth client.
|
|
30
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
31
|
-
*/
|
|
32
|
-
export function useSignInEmail(authClient, options, queryClient) {
|
|
33
|
-
return useMutation({
|
|
34
|
-
...signInEmailOptions(authClient),
|
|
35
|
-
...options,
|
|
36
|
-
meta: {
|
|
37
|
-
awaits: [authQueryKeys.session]
|
|
38
|
-
}
|
|
39
|
-
}, queryClient);
|
|
40
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for social sign-in.
|
|
5
|
-
*
|
|
6
|
-
* The returned `mutationKey` (`["auth", "signIn", "social"]`) is stable and
|
|
7
|
-
* can be passed to `useIsMutating` or matched inside a global
|
|
8
|
-
* `MutationCache` observer for toast handling.
|
|
9
|
-
*
|
|
10
|
-
* @param authClient - The Better Auth client.
|
|
11
|
-
*/
|
|
12
|
-
export function signInSocialOptions(authClient) {
|
|
13
|
-
const mutationKey = authMutationKeys.signIn.social;
|
|
14
|
-
const mutationFn = (params) => authClient.signIn.social({
|
|
15
|
-
...params,
|
|
16
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
17
|
-
});
|
|
18
|
-
return mutationOptions({
|
|
19
|
-
mutationKey,
|
|
20
|
-
mutationFn
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create a mutation for social sign-in.
|
|
25
|
-
*
|
|
26
|
-
* Wraps `authClient.signIn.social` to initiate a provider redirect and
|
|
27
|
-
* forwards React Query mutation options such as `onSuccess`, `onError`,
|
|
28
|
-
* and `retry`.
|
|
29
|
-
*
|
|
30
|
-
* @param authClient - The Better Auth client.
|
|
31
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
32
|
-
*/
|
|
33
|
-
export function useSignInSocial(authClient, options) {
|
|
34
|
-
return useMutation({
|
|
35
|
-
...signInSocialOptions(authClient),
|
|
36
|
-
...options
|
|
37
|
-
});
|
|
38
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for signing out.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function signOutOptions(authClient) {
|
|
9
|
-
const mutationKey = authMutationKeys.signOut;
|
|
10
|
-
// biome-ignore lint/suspicious/noConfusingVoidType: void allows no-arg mutate
|
|
11
|
-
const mutationFn = (params) => authClient.signOut({
|
|
12
|
-
...(params ?? {}),
|
|
13
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
-
});
|
|
15
|
-
return mutationOptions({
|
|
16
|
-
mutationKey,
|
|
17
|
-
mutationFn
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a mutation for signing the current user out.
|
|
22
|
-
*
|
|
23
|
-
* On success, removes every cached auth query so no stale data leaks across
|
|
24
|
-
* accounts. Sign-out uses a direct `removeQueries` call (rather than the
|
|
25
|
-
* `meta.awaits` / `meta.invalidates` pattern) because the goal is to drop
|
|
26
|
-
* cache entries entirely, not to refetch them.
|
|
27
|
-
*
|
|
28
|
-
* @param authClient - The Better Auth client.
|
|
29
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
30
|
-
*/
|
|
31
|
-
export function useSignOut(authClient, options, queryClient) {
|
|
32
|
-
const defaultQueryClient = useQueryClient(queryClient);
|
|
33
|
-
return useMutation({
|
|
34
|
-
...signOutOptions(authClient),
|
|
35
|
-
...options,
|
|
36
|
-
onSuccess: async (...args) => {
|
|
37
|
-
defaultQueryClient.removeQueries({ queryKey: authQueryKeys.all });
|
|
38
|
-
await options?.onSuccess?.(...args);
|
|
39
|
-
}
|
|
40
|
-
}, queryClient);
|
|
41
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for email/password sign-up.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function signUpEmailOptions(authClient) {
|
|
9
|
-
const mutationKey = authMutationKeys.signUp.email;
|
|
10
|
-
const mutationFn = (params) => authClient.signUp.email({
|
|
11
|
-
...params,
|
|
12
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
-
});
|
|
14
|
-
return mutationOptions({
|
|
15
|
-
mutationKey,
|
|
16
|
-
mutationFn
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a mutation for email/password sign-up.
|
|
21
|
-
*
|
|
22
|
-
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
23
|
-
* query so the new session is refetched (see `meta.awaits`).
|
|
24
|
-
*
|
|
25
|
-
* @param authClient - The Better Auth client.
|
|
26
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
-
*/
|
|
28
|
-
export function useSignUpEmail(authClient, options, queryClient) {
|
|
29
|
-
return useMutation({
|
|
30
|
-
...signUpEmailOptions(authClient),
|
|
31
|
-
...options,
|
|
32
|
-
meta: {
|
|
33
|
-
awaits: [authQueryKeys.session]
|
|
34
|
-
}
|
|
35
|
-
}, queryClient);
|
|
36
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { mutationOptions } from "@tanstack/react-query";
|
|
2
|
-
/**
|
|
3
|
-
* Build `mutationOptions` for a write-style Better Auth endpoint.
|
|
4
|
-
*
|
|
5
|
-
* Injects `throw: true` into `fetchOptions` so the promise rejects with a
|
|
6
|
-
* `BetterFetchError` on failure instead of resolving to `{ data, error }`.
|
|
7
|
-
*
|
|
8
|
-
* @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
|
|
9
|
-
* @param mutationKey - Stable key for the mutation (used by `useIsMutating`, `MutationCache`, …).
|
|
10
|
-
*/
|
|
11
|
-
export function authMutationOptions(authFn, mutationKey) {
|
|
12
|
-
const mutationFn = (variables) => {
|
|
13
|
-
const vars = (variables ?? {});
|
|
14
|
-
return authFn({
|
|
15
|
-
...vars,
|
|
16
|
-
fetchOptions: { ...vars.fetchOptions, throw: true }
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
return mutationOptions({
|
|
20
|
-
mutationKey,
|
|
21
|
-
mutationFn
|
|
22
|
-
});
|
|
23
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { magicLinkMutationKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Mutation options factory for magic-link sign-in.
|
|
5
|
-
*
|
|
6
|
-
* @param authClient - The Better Auth client.
|
|
7
|
-
*/
|
|
8
|
-
export function signInMagicLinkOptions(authClient) {
|
|
9
|
-
const mutationKey = magicLinkMutationKeys.signIn;
|
|
10
|
-
const mutationFn = (params) => authClient.signIn.magicLink({
|
|
11
|
-
...params,
|
|
12
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
13
|
-
});
|
|
14
|
-
return mutationOptions({
|
|
15
|
-
mutationKey,
|
|
16
|
-
mutationFn
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a mutation for requesting a magic-link sign-in email.
|
|
21
|
-
*
|
|
22
|
-
* Wraps `authClient.signIn.magicLink` and forwards React Query mutation
|
|
23
|
-
* options such as `onSuccess`, `onError`, and `retry`.
|
|
24
|
-
*
|
|
25
|
-
* @param authClient - The Better Auth client with the magic-link plugin.
|
|
26
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
27
|
-
*/
|
|
28
|
-
export function useSignInMagicLink(authClient, options) {
|
|
29
|
-
return useMutation({
|
|
30
|
-
...signInMagicLinkOptions(authClient),
|
|
31
|
-
...options
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { multiSessionMutationKeys, multiSessionQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Mutation options factory for revoking a device session in multi-session mode.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
8
|
-
*/
|
|
9
|
-
export function revokeMultiSessionOptions(authClient) {
|
|
10
|
-
const mutationKey = multiSessionMutationKeys.revoke;
|
|
11
|
-
const mutationFn = (params) => authClient.multiSession.revoke({
|
|
12
|
-
...params,
|
|
13
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
14
|
-
});
|
|
15
|
-
return mutationOptions({
|
|
16
|
-
mutationKey,
|
|
17
|
-
mutationFn
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a mutation for revoking a device session in multi-session mode.
|
|
22
|
-
*
|
|
23
|
-
* On success, `MutationInvalidator` awaits invalidation of the device
|
|
24
|
-
* sessions list (see `meta.awaits`).
|
|
25
|
-
*
|
|
26
|
-
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
27
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
28
|
-
*/
|
|
29
|
-
export function useRevokeMultiSession(authClient, options, queryClient) {
|
|
30
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
31
|
-
const userId = session?.user.id;
|
|
32
|
-
return useMutation({
|
|
33
|
-
...revokeMultiSessionOptions(authClient),
|
|
34
|
-
...options,
|
|
35
|
-
meta: {
|
|
36
|
-
awaits: [multiSessionQueryKeys.lists(userId)]
|
|
37
|
-
}
|
|
38
|
-
}, queryClient);
|
|
39
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { multiSessionMutationKeys, multiSessionQueryKeys } from "@better-auth-ui/core/plugins";
|
|
3
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
4
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
5
|
-
/**
|
|
6
|
-
* Mutation options factory for switching the active device session.
|
|
7
|
-
*
|
|
8
|
-
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
9
|
-
*/
|
|
10
|
-
export function setActiveSessionOptions(authClient) {
|
|
11
|
-
const mutationKey = multiSessionMutationKeys.setActive;
|
|
12
|
-
const mutationFn = (params) => authClient.multiSession.setActive({
|
|
13
|
-
...params,
|
|
14
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
15
|
-
});
|
|
16
|
-
return mutationOptions({
|
|
17
|
-
mutationKey,
|
|
18
|
-
mutationFn
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a mutation for switching the active device session.
|
|
23
|
-
*
|
|
24
|
-
* On success, `MutationInvalidator` awaits invalidation of the session
|
|
25
|
-
* and device sessions queries (see `meta.awaits`).
|
|
26
|
-
*
|
|
27
|
-
* @param authClient - The Better Auth client with the multi-session plugin.
|
|
28
|
-
* @param options - React Query options forwarded to `useMutation`.
|
|
29
|
-
*/
|
|
30
|
-
export function useSetActiveSession(authClient, options, queryClient) {
|
|
31
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
32
|
-
const userId = session?.user.id;
|
|
33
|
-
return useMutation({
|
|
34
|
-
...setActiveSessionOptions(authClient),
|
|
35
|
-
...options,
|
|
36
|
-
meta: {
|
|
37
|
-
awaits: [authQueryKeys.session, multiSessionQueryKeys.lists(userId)]
|
|
38
|
-
}
|
|
39
|
-
}, queryClient);
|
|
40
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { organizationMutationKeys, organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { mutationOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../../queries/auth/session-query";
|
|
4
|
-
export function acceptInvitationOptions(authClient) {
|
|
5
|
-
const mutationKey = organizationMutationKeys.acceptInvitation;
|
|
6
|
-
const mutationFn = (params) => authClient.organization.acceptInvitation({
|
|
7
|
-
...params,
|
|
8
|
-
fetchOptions: { ...params?.fetchOptions, throw: true }
|
|
9
|
-
});
|
|
10
|
-
return mutationOptions({
|
|
11
|
-
mutationKey,
|
|
12
|
-
mutationFn
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export function useAcceptInvitation(authClient, options, queryClient) {
|
|
16
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
17
|
-
const userId = session?.user.id;
|
|
18
|
-
return useMutation({
|
|
19
|
-
...acceptInvitationOptions(authClient),
|
|
20
|
-
...options,
|
|
21
|
-
meta: {
|
|
22
|
-
awaits: [
|
|
23
|
-
organizationQueryKeys.userInvitations.all(userId),
|
|
24
|
-
organizationQueryKeys.lists(userId)
|
|
25
|
-
],
|
|
26
|
-
invalidates: [
|
|
27
|
-
organizationQueryKeys.fullDetails(userId),
|
|
28
|
-
organizationQueryKeys.activeOrganizations(userId)
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
}, queryClient);
|
|
32
|
-
}
|