@better-auth-ui/react 1.6.9 → 1.6.10
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,31 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
export function listOrganizationsOptions(authClient, userId, params) {
|
|
5
|
-
const queryKey = organizationQueryKeys.list(userId, params?.query);
|
|
6
|
-
const options = queryOptions({
|
|
7
|
-
queryKey,
|
|
8
|
-
queryFn: ({ signal }) => authClient.organization.list({
|
|
9
|
-
...params,
|
|
10
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
return options;
|
|
14
|
-
}
|
|
15
|
-
export const ensureListOrganizations = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(listOrganizationsOptions(authClient, userId, params));
|
|
16
|
-
export const prefetchListOrganizations = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(listOrganizationsOptions(authClient, userId, params));
|
|
17
|
-
export const fetchListOrganizations = (queryClient, authClient, userId, params) => queryClient.fetchQuery(listOrganizationsOptions(authClient, userId, params));
|
|
18
|
-
export function useListOrganizations(authClient, options = {}, queryClient) {
|
|
19
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
20
|
-
const userId = session?.user.id;
|
|
21
|
-
const { query, fetchOptions, ...queryOptionsRest } = options;
|
|
22
|
-
const baseOptions = listOrganizationsOptions(authClient, userId, {
|
|
23
|
-
query,
|
|
24
|
-
fetchOptions
|
|
25
|
-
});
|
|
26
|
-
return useQuery({
|
|
27
|
-
...queryOptionsRest,
|
|
28
|
-
...baseOptions,
|
|
29
|
-
queryFn: userId ? baseOptions.queryFn : skipToken
|
|
30
|
-
}, queryClient);
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
export function listUserInvitationsOptions(authClient, userId, params) {
|
|
5
|
-
const queryKey = organizationQueryKeys.userInvitations.list(userId, params?.query);
|
|
6
|
-
const options = queryOptions({
|
|
7
|
-
queryKey,
|
|
8
|
-
queryFn: ({ signal }) => authClient.organization.listUserInvitations({
|
|
9
|
-
...params,
|
|
10
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
return options;
|
|
14
|
-
}
|
|
15
|
-
export const ensureListUserInvitations = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(listUserInvitationsOptions(authClient, userId, params));
|
|
16
|
-
export const prefetchListUserInvitations = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(listUserInvitationsOptions(authClient, userId, params));
|
|
17
|
-
export const fetchListUserInvitations = (queryClient, authClient, userId, params) => queryClient.fetchQuery(listUserInvitationsOptions(authClient, userId, params));
|
|
18
|
-
export function useListUserInvitations(authClient, options = {}, queryClient) {
|
|
19
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
20
|
-
const userId = session?.user.id;
|
|
21
|
-
const { query, fetchOptions, ...queryOptions } = options;
|
|
22
|
-
const baseOptions = listUserInvitationsOptions(authClient, userId, {
|
|
23
|
-
query,
|
|
24
|
-
fetchOptions
|
|
25
|
-
});
|
|
26
|
-
return useQuery({
|
|
27
|
-
...queryOptions,
|
|
28
|
-
...baseOptions,
|
|
29
|
-
queryFn: userId ? baseOptions.queryFn : skipToken
|
|
30
|
-
}, queryClient);
|
|
31
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { passkeyQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Query options factory for the current user's passkeys.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client with the passkey plugin.
|
|
8
|
-
* @param userId - The current signed-in user's ID. Used for cache partitioning.
|
|
9
|
-
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
10
|
-
*/
|
|
11
|
-
export function listPasskeysOptions(authClient, userId, params) {
|
|
12
|
-
const queryKey = passkeyQueryKeys.list(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: ({ signal }) => authClient.passkey.listUserPasskeys({
|
|
16
|
-
...params,
|
|
17
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get the current user's passkeys from the query cache, calling
|
|
24
|
-
* `fetchListPasskeys` under the hood if no cached entry exists. Resolves
|
|
25
|
-
* with the passkey list, making it ideal for loaders or `beforeLoad` guards.
|
|
26
|
-
*
|
|
27
|
-
* @param queryClient - The React Query client.
|
|
28
|
-
* @param authClient - The Better Auth client with the passkey plugin.
|
|
29
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
30
|
-
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
31
|
-
*/
|
|
32
|
-
export const ensureListPasskeys = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(listPasskeysOptions(authClient, userId, params));
|
|
33
|
-
/**
|
|
34
|
-
* Prefetch the current user's passkeys into the query cache. Behaves like
|
|
35
|
-
* `fetchListPasskeys`, but does not throw on error and does not return
|
|
36
|
-
* the data — use this to warm the cache without blocking navigation.
|
|
37
|
-
*
|
|
38
|
-
* @param queryClient - The React Query client.
|
|
39
|
-
* @param authClient - The Better Auth client with the passkey plugin.
|
|
40
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
41
|
-
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
42
|
-
*/
|
|
43
|
-
export const prefetchListPasskeys = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(listPasskeysOptions(authClient, userId, params));
|
|
44
|
-
/**
|
|
45
|
-
* Fetch and cache the current user's passkeys, resolving with the data or
|
|
46
|
-
* throwing on error. If a cached entry exists and is neither invalidated
|
|
47
|
-
* nor older than `staleTime`, the cached value is returned without a
|
|
48
|
-
* network call; otherwise the latest data is fetched.
|
|
49
|
-
*
|
|
50
|
-
* @param queryClient - The React Query client.
|
|
51
|
-
* @param authClient - The Better Auth client with the passkey plugin.
|
|
52
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
53
|
-
* @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
|
|
54
|
-
*/
|
|
55
|
-
export const fetchListPasskeys = (queryClient, authClient, userId, params) => queryClient.fetchQuery(listPasskeysOptions(authClient, userId, params));
|
|
56
|
-
/**
|
|
57
|
-
* Subscribe to the current user's passkeys via TanStack Query.
|
|
58
|
-
*
|
|
59
|
-
* Shares a query key with the server-side `listPasskeysOptions`, so
|
|
60
|
-
* SSR-hydrated data is reused from the cache without an immediate refetch.
|
|
61
|
-
* The query is gated on a signed-in user; while the session is loading or
|
|
62
|
-
* absent, the underlying `queryFn` is replaced with `skipToken`.
|
|
63
|
-
*
|
|
64
|
-
* @param authClient - The Better Auth client with the passkey plugin.
|
|
65
|
-
* @param options - `listPasskeys` params (`query`, `fetchOptions`) merged
|
|
66
|
-
* with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
|
|
67
|
-
* @param queryClient - Optional custom `QueryClient`. Defaults to the client
|
|
68
|
-
* from the nearest `QueryClientProvider`.
|
|
69
|
-
*/
|
|
70
|
-
export function useListPasskeys(authClient, options = {}, queryClient) {
|
|
71
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
72
|
-
const userId = session?.user.id;
|
|
73
|
-
const { query, fetchOptions, ...queryOptions } = options;
|
|
74
|
-
const baseOptions = listPasskeysOptions(authClient, userId, {
|
|
75
|
-
query,
|
|
76
|
-
fetchOptions
|
|
77
|
-
});
|
|
78
|
-
return useQuery({
|
|
79
|
-
...queryOptions,
|
|
80
|
-
...baseOptions,
|
|
81
|
-
queryFn: userId ? baseOptions.queryFn : skipToken
|
|
82
|
-
}, queryClient);
|
|
83
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Query options factory for provider-specific account info.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client.
|
|
8
|
-
* @param userId - The current signed-in user's ID. Used for cache partitioning.
|
|
9
|
-
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
10
|
-
*/
|
|
11
|
-
export function accountInfoOptions(authClient, userId, params) {
|
|
12
|
-
const queryKey = authQueryKeys.accountInfo(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: ({ signal }) => authClient.accountInfo({
|
|
16
|
-
...params,
|
|
17
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get the current user's provider-specific account info from the query
|
|
24
|
-
* cache, calling `fetchAccountInfo` under the hood if no cached entry
|
|
25
|
-
* exists. Resolves with the data, making it ideal for loaders or
|
|
26
|
-
* `beforeLoad` guards.
|
|
27
|
-
*
|
|
28
|
-
* @param queryClient - The React Query client.
|
|
29
|
-
* @param authClient - The Better Auth client.
|
|
30
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
31
|
-
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
32
|
-
*/
|
|
33
|
-
export const ensureAccountInfo = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(accountInfoOptions(authClient, userId, params));
|
|
34
|
-
/**
|
|
35
|
-
* Prefetch the current user's provider-specific account info into the query
|
|
36
|
-
* cache. Behaves like `fetchAccountInfo`, but does not throw on error and
|
|
37
|
-
* does not return the data — use this to warm the cache without blocking
|
|
38
|
-
* navigation.
|
|
39
|
-
*
|
|
40
|
-
* @param queryClient - The React Query client.
|
|
41
|
-
* @param authClient - The Better Auth client.
|
|
42
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
43
|
-
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
44
|
-
*/
|
|
45
|
-
export const prefetchAccountInfo = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(accountInfoOptions(authClient, userId, params));
|
|
46
|
-
/**
|
|
47
|
-
* Fetch and cache the current user's provider-specific account info,
|
|
48
|
-
* resolving with the data or throwing on error. If a cached entry exists
|
|
49
|
-
* and is neither invalidated nor older than `staleTime`, the cached value
|
|
50
|
-
* is returned without a network call; otherwise the latest data is fetched.
|
|
51
|
-
*
|
|
52
|
-
* @param queryClient - The React Query client.
|
|
53
|
-
* @param authClient - The Better Auth client.
|
|
54
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
55
|
-
* @param params - Parameters forwarded to `authClient.accountInfo`.
|
|
56
|
-
*/
|
|
57
|
-
export const fetchAccountInfo = (queryClient, authClient, userId, params) => queryClient.fetchQuery(accountInfoOptions(authClient, userId, params));
|
|
58
|
-
/**
|
|
59
|
-
* Subscribe to provider-specific info for a linked account via TanStack Query.
|
|
60
|
-
*
|
|
61
|
-
* Shares a query key with the server-side `accountInfoOptions`, so
|
|
62
|
-
* SSR-hydrated data is reused from the cache without an immediate refetch.
|
|
63
|
-
* The query is gated on both a signed-in user and a resolved `accountId`;
|
|
64
|
-
* until both are present, the underlying `queryFn` is replaced with
|
|
65
|
-
* `skipToken`.
|
|
66
|
-
*
|
|
67
|
-
* @param authClient - The Better Auth client.
|
|
68
|
-
* @param options - `accountInfo` params (`query`, `fetchOptions`) merged
|
|
69
|
-
* with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
|
|
70
|
-
* @param queryClient - Optional custom `QueryClient`. Defaults to the client
|
|
71
|
-
* from the nearest `QueryClientProvider`.
|
|
72
|
-
*/
|
|
73
|
-
export function useAccountInfo(authClient, options = {}, queryClient) {
|
|
74
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
75
|
-
const userId = session?.user.id;
|
|
76
|
-
const { query, fetchOptions, ...queryOptions } = options;
|
|
77
|
-
const baseOptions = accountInfoOptions(authClient, userId, {
|
|
78
|
-
query,
|
|
79
|
-
fetchOptions
|
|
80
|
-
});
|
|
81
|
-
const canFetch = Boolean(userId && query?.accountId);
|
|
82
|
-
return useQuery({
|
|
83
|
-
...queryOptions,
|
|
84
|
-
...baseOptions,
|
|
85
|
-
queryFn: canFetch ? baseOptions.queryFn : skipToken
|
|
86
|
-
}, queryClient);
|
|
87
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Query options factory for a user's linked social accounts.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client.
|
|
8
|
-
* @param userId - The current signed-in user's ID. Used for cache partitioning.
|
|
9
|
-
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
10
|
-
*/
|
|
11
|
-
export function listAccountsOptions(authClient, userId, params) {
|
|
12
|
-
const queryKey = authQueryKeys.listAccounts(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: ({ signal }) => authClient.listAccounts({
|
|
16
|
-
...params,
|
|
17
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get the current user's linked social accounts from the query cache,
|
|
24
|
-
* calling `fetchListAccounts` under the hood if no cached entry exists.
|
|
25
|
-
* Resolves with the account list, making it ideal for loaders or
|
|
26
|
-
* `beforeLoad` guards.
|
|
27
|
-
*
|
|
28
|
-
* @param queryClient - The React Query client.
|
|
29
|
-
* @param authClient - The Better Auth client.
|
|
30
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
31
|
-
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
32
|
-
*/
|
|
33
|
-
export const ensureListAccounts = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(listAccountsOptions(authClient, userId, params));
|
|
34
|
-
/**
|
|
35
|
-
* Prefetch the current user's linked social accounts into the query cache.
|
|
36
|
-
* Behaves like `fetchListAccounts`, but does not throw on error and does
|
|
37
|
-
* not return the data — use this to warm the cache without blocking
|
|
38
|
-
* navigation.
|
|
39
|
-
*
|
|
40
|
-
* @param queryClient - The React Query client.
|
|
41
|
-
* @param authClient - The Better Auth client.
|
|
42
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
43
|
-
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
44
|
-
*/
|
|
45
|
-
export const prefetchListAccounts = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(listAccountsOptions(authClient, userId, params));
|
|
46
|
-
/**
|
|
47
|
-
* Fetch and cache the current user's linked social accounts, resolving
|
|
48
|
-
* with the data or throwing on error. If a cached entry exists and is
|
|
49
|
-
* neither invalidated nor older than `staleTime`, the cached value is
|
|
50
|
-
* returned without a network call; otherwise the latest data is fetched.
|
|
51
|
-
*
|
|
52
|
-
* @param queryClient - The React Query client.
|
|
53
|
-
* @param authClient - The Better Auth client.
|
|
54
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
55
|
-
* @param params - Parameters forwarded to `authClient.listAccounts`.
|
|
56
|
-
*/
|
|
57
|
-
export const fetchListAccounts = (queryClient, authClient, userId, params) => queryClient.fetchQuery(listAccountsOptions(authClient, userId, params));
|
|
58
|
-
/**
|
|
59
|
-
* Subscribe to the current user's linked social accounts via TanStack Query.
|
|
60
|
-
*
|
|
61
|
-
* Shares a query key with the server-side `listAccountsOptions`, so
|
|
62
|
-
* SSR-hydrated data is reused from the cache without an immediate refetch.
|
|
63
|
-
* The query is gated on a signed-in user; while the session is loading or
|
|
64
|
-
* absent, the underlying `queryFn` is replaced with `skipToken`.
|
|
65
|
-
*
|
|
66
|
-
* @param authClient - The Better Auth client.
|
|
67
|
-
* @param options - `listAccounts` params (`query`, `fetchOptions`) merged
|
|
68
|
-
* with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
|
|
69
|
-
* @param queryClient - Optional custom `QueryClient`. Defaults to the client
|
|
70
|
-
* from the nearest `QueryClientProvider`.
|
|
71
|
-
*/
|
|
72
|
-
export function useListAccounts(authClient, options = {}, queryClient) {
|
|
73
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
74
|
-
const userId = session?.user.id;
|
|
75
|
-
const { query, fetchOptions, ...queryOptions } = options;
|
|
76
|
-
const baseOptions = listAccountsOptions(authClient, userId, {
|
|
77
|
-
query,
|
|
78
|
-
fetchOptions
|
|
79
|
-
});
|
|
80
|
-
return useQuery({
|
|
81
|
-
...queryOptions,
|
|
82
|
-
...baseOptions,
|
|
83
|
-
queryFn: userId ? baseOptions.queryFn : skipToken
|
|
84
|
-
}, queryClient);
|
|
85
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useSession } from "../auth/session-query";
|
|
4
|
-
/**
|
|
5
|
-
* Query options factory for the current user's active sessions.
|
|
6
|
-
*
|
|
7
|
-
* @param authClient - The Better Auth client.
|
|
8
|
-
* @param userId - The current signed-in user's ID. Used for cache partitioning.
|
|
9
|
-
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
10
|
-
*/
|
|
11
|
-
export function listSessionsOptions(authClient, userId, params) {
|
|
12
|
-
const queryKey = authQueryKeys.listSessions(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: ({ signal }) => authClient.listSessions({
|
|
16
|
-
...params,
|
|
17
|
-
fetchOptions: { ...params?.fetchOptions, signal, throw: true }
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get the current user's active sessions from the query cache, calling
|
|
24
|
-
* `fetchListSessions` under the hood if no cached entry exists. Resolves
|
|
25
|
-
* with the session list, making it ideal for loaders or `beforeLoad` guards.
|
|
26
|
-
*
|
|
27
|
-
* @param queryClient - The React Query client.
|
|
28
|
-
* @param authClient - The Better Auth client.
|
|
29
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
30
|
-
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
31
|
-
*/
|
|
32
|
-
export const ensureListSessions = (queryClient, authClient, userId, params) => queryClient.ensureQueryData(listSessionsOptions(authClient, userId, params));
|
|
33
|
-
/**
|
|
34
|
-
* Prefetch the current user's active sessions into the query cache. Behaves
|
|
35
|
-
* like `fetchListSessions`, but does not throw on error and does not return
|
|
36
|
-
* the data — use this to warm the cache without blocking navigation.
|
|
37
|
-
*
|
|
38
|
-
* @param queryClient - The React Query client.
|
|
39
|
-
* @param authClient - The Better Auth client.
|
|
40
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
41
|
-
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
42
|
-
*/
|
|
43
|
-
export const prefetchListSessions = (queryClient, authClient, userId, params) => queryClient.prefetchQuery(listSessionsOptions(authClient, userId, params));
|
|
44
|
-
/**
|
|
45
|
-
* Fetch and cache the current user's active sessions, resolving with the
|
|
46
|
-
* data or throwing on error. If a cached entry exists and is neither
|
|
47
|
-
* invalidated nor older than `staleTime`, the cached value is returned
|
|
48
|
-
* without a network call; otherwise the latest data is fetched.
|
|
49
|
-
*
|
|
50
|
-
* @param queryClient - The React Query client.
|
|
51
|
-
* @param authClient - The Better Auth client.
|
|
52
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
53
|
-
* @param params - Parameters forwarded to `authClient.listSessions`.
|
|
54
|
-
*/
|
|
55
|
-
export const fetchListSessions = (queryClient, authClient, userId, params) => queryClient.fetchQuery(listSessionsOptions(authClient, userId, params));
|
|
56
|
-
/**
|
|
57
|
-
* Subscribe to the current user's active sessions via TanStack Query.
|
|
58
|
-
*
|
|
59
|
-
* Shares a query key with the server-side `listSessionsOptions`, so
|
|
60
|
-
* SSR-hydrated data is reused from the cache without an immediate refetch.
|
|
61
|
-
* The query is gated on a signed-in user; while the session is loading or
|
|
62
|
-
* absent, the underlying `queryFn` is replaced with `skipToken`.
|
|
63
|
-
*
|
|
64
|
-
* @param authClient - The Better Auth client.
|
|
65
|
-
* @param options - `listSessions` params (`query`, `fetchOptions`) merged
|
|
66
|
-
* with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
|
|
67
|
-
* @param queryClient - Optional custom `QueryClient`. Defaults to the client
|
|
68
|
-
* from the nearest `QueryClientProvider`.
|
|
69
|
-
*/
|
|
70
|
-
export function useListSessions(authClient, options = {}, queryClient) {
|
|
71
|
-
const { data: session } = useSession(authClient, undefined, queryClient);
|
|
72
|
-
const userId = session?.user.id;
|
|
73
|
-
const { query, fetchOptions, ...queryOptions } = options;
|
|
74
|
-
const baseOptions = listSessionsOptions(authClient, userId, {
|
|
75
|
-
query,
|
|
76
|
-
fetchOptions
|
|
77
|
-
});
|
|
78
|
-
return useQuery({
|
|
79
|
-
...queryOptions,
|
|
80
|
-
...baseOptions,
|
|
81
|
-
queryFn: userId ? baseOptions.queryFn : skipToken
|
|
82
|
-
}, queryClient);
|
|
83
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { apiKeyQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for the current user's API keys on the server.
|
|
5
|
-
*
|
|
6
|
-
* Uses the same query key as the client-side `listApiKeysOptions` so that data
|
|
7
|
-
* fetched during SSR hydrates seamlessly into the client's React Query cache.
|
|
8
|
-
*
|
|
9
|
-
* @param auth - The Better Auth server instance with the API key plugin.
|
|
10
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning.
|
|
11
|
-
* @param params - Parameters forwarded to `auth.api.listApiKeys`.
|
|
12
|
-
*/
|
|
13
|
-
export function listApiKeysOptions(auth, userId, params) {
|
|
14
|
-
const queryKey = apiKeyQueryKeys.list(userId, params?.query);
|
|
15
|
-
const options = queryOptions({
|
|
16
|
-
queryKey,
|
|
17
|
-
queryFn: () => auth.api.listApiKeys(params)
|
|
18
|
-
});
|
|
19
|
-
return options;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get the current user's API keys from the query cache, calling
|
|
23
|
-
* `fetchListApiKeys` under the hood if no cached entry exists.
|
|
24
|
-
*
|
|
25
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
26
|
-
* @param auth - The Better Auth server instance with the API key plugin.
|
|
27
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
28
|
-
* @param params - Parameters forwarded to `auth.api.listApiKeys`.
|
|
29
|
-
*/
|
|
30
|
-
export const ensureListApiKeys = (queryClient, auth, userId, params) => queryClient.ensureQueryData(listApiKeysOptions(auth, userId, params));
|
|
31
|
-
/**
|
|
32
|
-
* Prefetch the current user's API keys into the query cache.
|
|
33
|
-
*
|
|
34
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
35
|
-
* @param auth - The Better Auth server instance with the API key plugin.
|
|
36
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
37
|
-
* @param params - Parameters forwarded to `auth.api.listApiKeys`.
|
|
38
|
-
*/
|
|
39
|
-
export const prefetchListApiKeys = (queryClient, auth, userId, params) => queryClient.prefetchQuery(listApiKeysOptions(auth, userId, params));
|
|
40
|
-
/**
|
|
41
|
-
* Fetch and cache the current user's API keys, resolving with the data or
|
|
42
|
-
* throwing on error.
|
|
43
|
-
*
|
|
44
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
45
|
-
* @param auth - The Better Auth server instance with the API key plugin.
|
|
46
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
47
|
-
* @param params - Parameters forwarded to `auth.api.listApiKeys`.
|
|
48
|
-
*/
|
|
49
|
-
export const fetchListApiKeys = (queryClient, auth, userId, params) => queryClient.fetchQuery(listApiKeysOptions(auth, userId, params));
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for the current session on the server.
|
|
5
|
-
*
|
|
6
|
-
* Uses the same query key as the client-side `sessionOptions` so that data
|
|
7
|
-
* fetched during SSR hydrates seamlessly into the client's React Query cache.
|
|
8
|
-
*
|
|
9
|
-
* @param auth - The Better Auth server instance.
|
|
10
|
-
* @param params - Parameters forwarded to `auth.api.getSession` (typically
|
|
11
|
-
* includes request `headers` for cookie-based session resolution).
|
|
12
|
-
*/
|
|
13
|
-
export function sessionOptions(auth, params) {
|
|
14
|
-
const queryKey = authQueryKeys.session;
|
|
15
|
-
const options = queryOptions({
|
|
16
|
-
queryKey,
|
|
17
|
-
queryFn: () => auth.api.getSession(params)
|
|
18
|
-
});
|
|
19
|
-
return options;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get the current session from the query cache, calling `fetchSession` under
|
|
23
|
-
* the hood if no cached entry exists. Resolves with the session data, making
|
|
24
|
-
* it suitable for reading the value directly in a server component.
|
|
25
|
-
*
|
|
26
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
27
|
-
* @param auth - The Better Auth server instance.
|
|
28
|
-
* @param params - Parameters forwarded to `auth.api.getSession`.
|
|
29
|
-
*/
|
|
30
|
-
export const ensureSession = (queryClient, auth, params) => queryClient.ensureQueryData(sessionOptions(auth, params));
|
|
31
|
-
/**
|
|
32
|
-
* Prefetch the current session into the query cache. Behaves like
|
|
33
|
-
* `fetchSession`, but does not throw on error and does not return the data —
|
|
34
|
-
* use this when you only need the value to be available after hydration.
|
|
35
|
-
*
|
|
36
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
37
|
-
* @param auth - The Better Auth server instance.
|
|
38
|
-
* @param params - Parameters forwarded to `auth.api.getSession`.
|
|
39
|
-
*/
|
|
40
|
-
export const prefetchSession = (queryClient, auth, params) => queryClient.prefetchQuery(sessionOptions(auth, params));
|
|
41
|
-
/**
|
|
42
|
-
* Fetch and cache the current session, resolving with the data or throwing
|
|
43
|
-
* on error. If a cached entry exists and is neither invalidated nor older
|
|
44
|
-
* than `staleTime`, the cached value is returned without a network call;
|
|
45
|
-
* otherwise the latest data is fetched.
|
|
46
|
-
*
|
|
47
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
48
|
-
* @param auth - The Better Auth server instance.
|
|
49
|
-
* @param params - Parameters forwarded to `auth.api.getSession`.
|
|
50
|
-
*/
|
|
51
|
-
export const fetchSession = (queryClient, auth, params) => queryClient.fetchQuery(sessionOptions(auth, params));
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { multiSessionQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for the current user's device sessions.
|
|
5
|
-
*
|
|
6
|
-
* @param auth - The Better Auth server instance with the multi-session plugin.
|
|
7
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
8
|
-
* the key matches the client-side `listDeviceSessionsOptions` for SSR hydration.
|
|
9
|
-
* @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
|
|
10
|
-
*/
|
|
11
|
-
export function listDeviceSessionsOptions(auth, userId, params) {
|
|
12
|
-
const queryKey = multiSessionQueryKeys.list(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: () => auth.api.listDeviceSessions(params)
|
|
16
|
-
});
|
|
17
|
-
return options;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get the current user's device sessions from the query cache, calling
|
|
21
|
-
* `fetchListDeviceSessions` under the hood if no cached entry exists.
|
|
22
|
-
* Resolves with the device session list, making it suitable for reading
|
|
23
|
-
* directly in a server component.
|
|
24
|
-
*
|
|
25
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
26
|
-
* @param auth - The Better Auth server instance with the multi-session plugin.
|
|
27
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
28
|
-
* @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
|
|
29
|
-
*/
|
|
30
|
-
export const ensureListDeviceSessions = (queryClient, auth, userId, params) => queryClient.ensureQueryData(listDeviceSessionsOptions(auth, userId, params));
|
|
31
|
-
/**
|
|
32
|
-
* Prefetch the current user's device sessions into the query cache. Behaves
|
|
33
|
-
* like `fetchListDeviceSessions`, but does not throw on error and does not
|
|
34
|
-
* return the data — use this when you only need the value to be available
|
|
35
|
-
* after hydration.
|
|
36
|
-
*
|
|
37
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
38
|
-
* @param auth - The Better Auth server instance with the multi-session plugin.
|
|
39
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
40
|
-
* @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
|
|
41
|
-
*/
|
|
42
|
-
export const prefetchListDeviceSessions = (queryClient, auth, userId, params) => queryClient.prefetchQuery(listDeviceSessionsOptions(auth, userId, params));
|
|
43
|
-
/**
|
|
44
|
-
* Fetch and cache the current user's device sessions, resolving with the
|
|
45
|
-
* data or throwing on error. If a cached entry exists and is neither
|
|
46
|
-
* invalidated nor older than `staleTime`, the cached value is returned
|
|
47
|
-
* without a network call; otherwise the latest data is fetched.
|
|
48
|
-
*
|
|
49
|
-
* @param queryClient - The React Query client used for SSR hydration.
|
|
50
|
-
* @param auth - The Better Auth server instance with the multi-session plugin.
|
|
51
|
-
* @param userId - The signed-in user's ID, used for cache partitioning.
|
|
52
|
-
* @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
|
|
53
|
-
*/
|
|
54
|
-
export const fetchListDeviceSessions = (queryClient, auth, userId, params) => queryClient.fetchQuery(listDeviceSessionsOptions(auth, userId, params));
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for the active organization. Shares its cache key
|
|
5
|
-
* with the client-side `activeOrganizationOptions` (including any
|
|
6
|
-
* `params.query` partition such as `{ organizationSlug }`) so SSR-prefetched
|
|
7
|
-
* data hydrates without a refetch — even on slug-prefixed routes.
|
|
8
|
-
*
|
|
9
|
-
* @param auth - The Better Auth server instance.
|
|
10
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
11
|
-
* the key matches the client-side `activeOrganizationOptions` for SSR hydration.
|
|
12
|
-
* @param params - Parameters forwarded to `auth.api.getFullOrganization`. Pass
|
|
13
|
-
* `{ query: { organizationSlug } }` for slug-driven prefetches.
|
|
14
|
-
*/
|
|
15
|
-
export function activeOrganizationOptions(auth, userId, params) {
|
|
16
|
-
const queryKey = organizationQueryKeys.activeOrganization(userId, params?.query);
|
|
17
|
-
const options = queryOptions({
|
|
18
|
-
queryKey,
|
|
19
|
-
queryFn: () => auth.api.getFullOrganization(params)
|
|
20
|
-
});
|
|
21
|
-
return options;
|
|
22
|
-
}
|
|
23
|
-
export const ensureActiveOrganization = (queryClient, auth, userId, params) => queryClient.ensureQueryData(activeOrganizationOptions(auth, userId, params));
|
|
24
|
-
export const prefetchActiveOrganization = (queryClient, auth, userId, params) => queryClient.prefetchQuery(activeOrganizationOptions(auth, userId, params));
|
|
25
|
-
export const fetchActiveOrganization = (queryClient, auth, userId, params) => queryClient.fetchQuery(activeOrganizationOptions(auth, userId, params));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for full organization details (members, invitations, etc.).
|
|
5
|
-
*
|
|
6
|
-
* @param auth - The Better Auth server instance.
|
|
7
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
8
|
-
* the key matches the client-side `fullOrganizationOptions` for SSR hydration.
|
|
9
|
-
* @param params - Parameters forwarded to `auth.api.getFullOrganization`.
|
|
10
|
-
*/
|
|
11
|
-
export function fullOrganizationOptions(auth, userId, params) {
|
|
12
|
-
const queryKey = organizationQueryKeys.fullDetail(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: () => auth.api.getFullOrganization(params)
|
|
16
|
-
});
|
|
17
|
-
return options;
|
|
18
|
-
}
|
|
19
|
-
export const ensureFullOrganization = (queryClient, auth, userId, params) => queryClient.ensureQueryData(fullOrganizationOptions(auth, userId, params));
|
|
20
|
-
export const prefetchFullOrganization = (queryClient, auth, userId, params) => queryClient.prefetchQuery(fullOrganizationOptions(auth, userId, params));
|
|
21
|
-
export const fetchFullOrganization = (queryClient, auth, userId, params) => queryClient.fetchQuery(fullOrganizationOptions(auth, userId, params));
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for organization permission checks.
|
|
5
|
-
*
|
|
6
|
-
* @param auth - The Better Auth server instance.
|
|
7
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
8
|
-
* the key matches the client-side `hasPermissionOptions` for SSR hydration.
|
|
9
|
-
* @param params - Parameters forwarded to `auth.api.hasPermission`.
|
|
10
|
-
*/
|
|
11
|
-
export function hasPermissionOptions(auth, userId, params) {
|
|
12
|
-
// Same logical payload as the client key (permissions ± organizationId): client
|
|
13
|
-
// strips `fetchOptions`; server keeps that shape under `body`.
|
|
14
|
-
const queryKey = organizationQueryKeys.permissions.has(userId, params?.body);
|
|
15
|
-
const options = queryOptions({
|
|
16
|
-
queryKey,
|
|
17
|
-
queryFn: () => auth.api.hasPermission(params)
|
|
18
|
-
});
|
|
19
|
-
return options;
|
|
20
|
-
}
|
|
21
|
-
export const ensureHasPermission = (queryClient, auth, userId, params) => queryClient.ensureQueryData(hasPermissionOptions(auth, userId, params));
|
|
22
|
-
export const prefetchHasPermission = (queryClient, auth, userId, params) => queryClient.prefetchQuery(hasPermissionOptions(auth, userId, params));
|
|
23
|
-
export const fetchHasPermission = (queryClient, auth, userId, params) => queryClient.fetchQuery(hasPermissionOptions(auth, userId, params));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { organizationQueryKeys } from "@better-auth-ui/core/plugins";
|
|
2
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
-
/**
|
|
4
|
-
* Query options factory for invitations of an organization.
|
|
5
|
-
*
|
|
6
|
-
* @param auth - The Better Auth server instance.
|
|
7
|
-
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
8
|
-
* the key matches the client-side `listOrganizationInvitationsOptions` for SSR hydration.
|
|
9
|
-
* @param params - Parameters forwarded to `auth.api.listInvitations`.
|
|
10
|
-
*/
|
|
11
|
-
export function listOrganizationInvitationsOptions(auth, userId, params) {
|
|
12
|
-
const queryKey = organizationQueryKeys.invitations.list(userId, params?.query);
|
|
13
|
-
const options = queryOptions({
|
|
14
|
-
queryKey,
|
|
15
|
-
queryFn: () => auth.api.listInvitations(params)
|
|
16
|
-
});
|
|
17
|
-
return options;
|
|
18
|
-
}
|
|
19
|
-
export const ensureListOrganizationInvitations = (queryClient, auth, userId, params) => queryClient.ensureQueryData(listOrganizationInvitationsOptions(auth, userId, params));
|
|
20
|
-
export const prefetchListOrganizationInvitations = (queryClient, auth, userId, params) => queryClient.prefetchQuery(listOrganizationInvitationsOptions(auth, userId, params));
|
|
21
|
-
export const fetchListOrganizationInvitations = (queryClient, auth, userId, params) => queryClient.fetchQuery(listOrganizationInvitationsOptions(auth, userId, params));
|