@better-auth-ui/react 1.6.8 → 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 +3 -0
- package/dist/components/auth/email/email-localization.d.ts +11 -3
- package/dist/components/auth/email/index.d.ts +1 -0
- package/dist/components/auth/email/organization-invitation.d.ts +121 -0
- package/dist/components/mutation-invalidator.d.ts +1 -0
- package/dist/email.js +1348 -11
- package/dist/hooks/auth/use-authenticate.d.ts +1 -1
- package/dist/hooks/auth/use-user.d.ts +12 -12
- package/dist/hooks/use-auth-query.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2469 -79
- package/dist/lib/auth-client.d.ts +4 -1
- package/dist/lib/auth-plugin.d.ts +16 -0
- package/dist/lib/auth-server.d.ts +8 -1
- package/dist/lib/settings-tab.d.ts +19 -0
- package/dist/mutations/api-key/create-api-key-mutation.d.ts +6 -4
- package/dist/mutations/api-key/delete-api-key-mutation.d.ts +7 -3
- package/dist/mutations/auth/sign-in-email-mutation.d.ts +5 -5
- package/dist/mutations/auth/sign-out-mutation.d.ts +6 -4
- package/dist/mutations/auth/sign-up-email-mutation.d.ts +5 -5
- 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 -6
- package/dist/mutations/organization/accept-invitation-mutation.d.ts +43 -0
- package/dist/mutations/organization/cancel-invitation-mutation.d.ts +25 -0
- package/dist/mutations/organization/check-slug-mutation.d.ts +21 -0
- package/dist/mutations/organization/create-organization-mutation.d.ts +39 -0
- package/dist/mutations/organization/delete-organization-mutation.d.ts +21 -0
- package/dist/mutations/organization/index.d.ts +12 -0
- package/dist/mutations/organization/invite-member-mutation.d.ts +43 -0
- package/dist/mutations/organization/leave-organization-mutation.d.ts +65 -0
- package/dist/mutations/organization/reject-invitation-mutation.d.ts +31 -0
- package/dist/mutations/organization/remove-member-mutation.d.ts +35 -0
- package/dist/mutations/organization/set-active-organization-mutation.d.ts +71 -0
- package/dist/mutations/organization/update-member-role-mutation.d.ts +31 -0
- package/dist/mutations/organization/update-organization-mutation.d.ts +21 -0
- package/dist/mutations/passkey/add-passkey-mutation.d.ts +5 -5
- package/dist/mutations/passkey/delete-passkey-mutation.d.ts +5 -5
- package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +5 -5
- package/dist/mutations/settings/change-email-mutation.d.ts +6 -5
- 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/sign-in-username-mutation.d.ts +5 -5
- package/dist/plugins/captcha-plugin.d.ts +2 -2
- package/dist/plugins.js +27 -2
- package/dist/queries/api-key/list-api-keys-query.d.ts +17 -8
- package/dist/queries/auth/session-query.d.ts +1 -1
- package/dist/queries/multi-session/list-device-sessions-query.d.ts +5 -5
- package/dist/queries/organization/active-organization-query.d.ts +39 -0
- package/dist/queries/organization/full-organization-query.d.ts +37 -0
- package/dist/queries/organization/has-permission-query.d.ts +21 -0
- package/dist/queries/organization/index.d.ts +7 -0
- package/dist/queries/organization/list-invitations-query.d.ts +29 -0
- package/dist/queries/organization/list-members-query.d.ts +61 -0
- package/dist/queries/organization/list-organizations-query.d.ts +22 -0
- package/dist/queries/organization/list-user-invitations-query.d.ts +29 -0
- package/dist/queries/passkey/list-passkeys-query.d.ts +5 -5
- package/dist/queries/settings/account-info-query.d.ts +1 -1
- package/dist/queries/settings/list-accounts-query.d.ts +1 -1
- package/dist/queries/settings/list-sessions-query.d.ts +1 -1
- package/dist/server/queries/api-key/list-api-keys-query.d.ts +83 -0
- package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +4 -4
- package/dist/server/queries/organization/active-organization-query.d.ts +61 -0
- package/dist/server/queries/organization/full-organization-query.d.ts +42 -0
- package/dist/server/queries/organization/has-permission-query.d.ts +66 -0
- package/dist/server/queries/organization/list-invitations-query.d.ts +34 -0
- package/dist/server/queries/organization/list-members-query.d.ts +66 -0
- package/dist/server/queries/organization/list-organizations-query.d.ts +27 -0
- package/dist/server/queries/organization/list-user-invitations-query.d.ts +34 -0
- package/dist/server/queries/passkey/list-passkeys-query.d.ts +4 -4
- package/dist/server.d.ts +8 -0
- package/dist/server.js +131 -7
- package/dist/use-auth-plugin-ClcP84Uz.js +80 -0
- package/package.json +19 -16
- package/src/components/auth/auth-context.tsx +7 -0
- package/src/components/auth/auth-provider.tsx +19 -31
- package/src/components/auth/email/email-localization.tsx +5 -3
- package/src/components/auth/email/index.ts +1 -0
- package/src/components/auth/email/organization-invitation.tsx +454 -0
- package/src/components/mutation-invalidator.tsx +67 -0
- package/src/index.ts +3 -0
- package/src/lib/auth-client.ts +7 -0
- package/src/lib/auth-plugin.ts +17 -0
- package/src/lib/auth-server.ts +17 -1
- package/src/lib/settings-tab.ts +21 -0
- package/src/mutations/api-key/create-api-key-mutation.ts +34 -19
- package/src/mutations/api-key/delete-api-key-mutation.ts +36 -19
- package/src/mutations/auth/sign-in-email-mutation.ts +18 -22
- package/src/mutations/auth/sign-out-mutation.ts +19 -13
- package/src/mutations/auth/sign-up-email-mutation.ts +18 -22
- package/src/mutations/multi-session/revoke-multi-session-mutation.ts +31 -20
- package/src/mutations/multi-session/set-active-session-mutation.ts +25 -44
- package/src/mutations/organization/accept-invitation-mutation.ts +71 -0
- package/src/mutations/organization/cancel-invitation-mutation.ts +67 -0
- package/src/mutations/organization/check-slug-mutation.ts +55 -0
- package/src/mutations/organization/create-organization-mutation.ts +71 -0
- package/src/mutations/organization/delete-organization-mutation.ts +71 -0
- package/src/mutations/organization/index.ts +12 -0
- package/src/mutations/organization/invite-member-mutation.ts +81 -0
- package/src/mutations/organization/leave-organization-mutation.ts +74 -0
- package/src/mutations/organization/reject-invitation-mutation.ts +64 -0
- package/src/mutations/organization/remove-member-mutation.ts +67 -0
- package/src/mutations/organization/set-active-organization-mutation.ts +142 -0
- package/src/mutations/organization/update-member-role-mutation.ts +81 -0
- package/src/mutations/organization/update-organization-mutation.ts +84 -0
- package/src/mutations/passkey/add-passkey-mutation.ts +28 -17
- package/src/mutations/passkey/delete-passkey-mutation.ts +27 -17
- package/src/mutations/passkey/sign-in-passkey-mutation.ts +18 -21
- package/src/mutations/settings/change-email-mutation.ts +22 -18
- package/src/mutations/settings/delete-user-mutation.ts +2 -2
- package/src/mutations/settings/revoke-session-mutation.ts +24 -19
- package/src/mutations/settings/unlink-account-mutation.ts +24 -17
- package/src/mutations/settings/update-user-mutation.ts +18 -30
- package/src/mutations/username/is-username-available-mutation.ts +2 -2
- package/src/mutations/username/sign-in-username-mutation.ts +20 -23
- package/src/queries/api-key/list-api-keys-query.ts +20 -8
- package/src/queries/multi-session/list-device-sessions-query.ts +2 -2
- package/src/queries/organization/active-organization-query.ts +140 -0
- package/src/queries/organization/full-organization-query.ts +113 -0
- package/src/queries/organization/has-permission-query.ts +124 -0
- package/src/queries/organization/index.ts +7 -0
- package/src/queries/organization/list-invitations-query.ts +133 -0
- package/src/queries/organization/list-members-query.ts +133 -0
- package/src/queries/organization/list-organizations-query.ts +122 -0
- package/src/queries/organization/list-user-invitations-query.ts +122 -0
- package/src/queries/passkey/list-passkeys-query.ts +2 -2
- package/src/server/queries/api-key/list-api-keys-query.ts +94 -0
- package/src/server/queries/multi-session/list-device-sessions-query.ts +2 -2
- package/src/server/queries/organization/active-organization-query.ts +92 -0
- package/src/server/queries/organization/full-organization-query.ts +64 -0
- package/src/server/queries/organization/has-permission-query.ts +66 -0
- package/src/server/queries/organization/list-invitations-query.ts +81 -0
- package/src/server/queries/organization/list-members-query.ts +75 -0
- package/src/server/queries/organization/list-organizations-query.ts +67 -0
- package/src/server/queries/organization/list-user-invitations-query.ts +68 -0
- package/src/server/queries/passkey/list-passkeys-query.ts +2 -2
- package/src/server.ts +8 -0
- package/dist/components/auth/auth-provider.js +0 -44
- package/dist/components/auth/email/email-changed.js +0 -156
- package/dist/components/auth/email/email-localization.js +0 -19
- package/dist/components/auth/email/email-styles.js +0 -104
- package/dist/components/auth/email/email-verification.js +0 -140
- package/dist/components/auth/email/index.js +0 -9
- package/dist/components/auth/email/magic-link.js +0 -141
- package/dist/components/auth/email/new-device.js +0 -223
- package/dist/components/auth/email/otp-email.js +0 -129
- package/dist/components/auth/email/password-changed.js +0 -159
- package/dist/components/auth/email/reset-password.js +0 -140
- package/dist/components/auth/fetch-options-provider.js +0 -30
- package/dist/components/icons/apple.js +0 -17
- package/dist/components/icons/atlassian.js +0 -39
- package/dist/components/icons/cognito.js +0 -20
- package/dist/components/icons/discord.js +0 -17
- package/dist/components/icons/dropbox.js +0 -17
- package/dist/components/icons/facebook.js +0 -20
- package/dist/components/icons/figma.js +0 -35
- package/dist/components/icons/github.js +0 -17
- package/dist/components/icons/gitlab.js +0 -31
- package/dist/components/icons/google.js +0 -40
- package/dist/components/icons/huggingface.js +0 -39
- package/dist/components/icons/index.js +0 -35
- package/dist/components/icons/kakao.js +0 -17
- package/dist/components/icons/kick.js +0 -21
- package/dist/components/icons/line.js +0 -17
- package/dist/components/icons/linear.js +0 -17
- package/dist/components/icons/linkedin.js +0 -34
- package/dist/components/icons/microsoft.js +0 -31
- package/dist/components/icons/naver.js +0 -17
- package/dist/components/icons/notion.js +0 -17
- package/dist/components/icons/paybin.js +0 -33
- package/dist/components/icons/paypal.js +0 -31
- package/dist/components/icons/polar.js +0 -25
- package/dist/components/icons/railway.js +0 -17
- package/dist/components/icons/reddit.js +0 -22
- package/dist/components/icons/roblox.js +0 -18
- package/dist/components/icons/salesforce.js +0 -17
- package/dist/components/icons/slack.js +0 -31
- package/dist/components/icons/spotify.js +0 -17
- package/dist/components/icons/tiktok.js +0 -24
- package/dist/components/icons/twitch.js +0 -44
- package/dist/components/icons/vercel.js +0 -17
- package/dist/components/icons/vk.js +0 -17
- package/dist/components/icons/wechat.js +0 -17
- package/dist/components/icons/x.js +0 -17
- package/dist/components/icons/zoom.js +0 -70
- package/dist/components/settings/account/theme-preview.js +0 -289
- package/dist/hooks/auth/use-authenticate.js +0 -23
- package/dist/hooks/auth/use-user.js +0 -11
- package/dist/hooks/use-auth-mutation.js +0 -11
- package/dist/hooks/use-auth-plugin.js +0 -10
- package/dist/hooks/use-auth-query.js +0 -15
- package/dist/lib/provider-icons.js +0 -76
- package/dist/lib/utils.js +0 -8
- package/dist/mutations/api-key/create-api-key-mutation.js +0 -29
- package/dist/mutations/api-key/delete-api-key-mutation.js +0 -29
- package/dist/mutations/auth/request-password-reset-mutation.js +0 -24
- package/dist/mutations/auth/reset-password-mutation.js +0 -24
- package/dist/mutations/auth/send-verification-email-mutation.js +0 -24
- package/dist/mutations/auth/sign-in-email-mutation.js +0 -29
- package/dist/mutations/auth/sign-in-social-mutation.js +0 -24
- package/dist/mutations/auth/sign-out-mutation.js +0 -28
- package/dist/mutations/auth/sign-up-email-mutation.js +0 -29
- package/dist/mutations/auth-mutation-options.js +0 -19
- package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +0 -24
- package/dist/mutations/multi-session/revoke-multi-session-mutation.js +0 -29
- package/dist/mutations/multi-session/set-active-session-mutation.js +0 -31
- package/dist/mutations/passkey/add-passkey-mutation.js +0 -29
- package/dist/mutations/passkey/delete-passkey-mutation.js +0 -29
- package/dist/mutations/passkey/sign-in-passkey-mutation.js +0 -29
- package/dist/mutations/settings/change-email-mutation.js +0 -29
- package/dist/mutations/settings/change-password-mutation.js +0 -24
- package/dist/mutations/settings/delete-user-mutation.js +0 -24
- package/dist/mutations/settings/link-social-mutation.js +0 -24
- package/dist/mutations/settings/revoke-session-mutation.js +0 -29
- package/dist/mutations/settings/unlink-account-mutation.js +0 -29
- package/dist/mutations/settings/update-user-mutation.js +0 -35
- package/dist/mutations/username/is-username-available-mutation.js +0 -24
- package/dist/mutations/username/sign-in-username-mutation.js +0 -29
- package/dist/plugins/captcha-plugin.js +0 -29
- package/dist/queries/api-key/list-api-keys-query.js +0 -31
- package/dist/queries/auth/session-query.js +0 -30
- package/dist/queries/auth-query-options.js +0 -17
- package/dist/queries/multi-session/list-device-sessions-query.js +0 -31
- package/dist/queries/passkey/list-passkeys-query.js +0 -31
- package/dist/queries/settings/account-info-query.js +0 -31
- package/dist/queries/settings/list-accounts-query.js +0 -31
- package/dist/queries/settings/list-sessions-query.js +0 -31
- package/dist/server/queries/auth/session-query.js +0 -13
- package/dist/server/queries/multi-session/list-device-sessions-query.js +0 -12
- package/dist/server/queries/passkey/list-passkeys-query.js +0 -12
- package/dist/server/queries/settings/account-info-query.js +0 -12
- package/dist/server/queries/settings/list-accounts-query.js +0 -12
- package/dist/server/queries/settings/list-sessions-query.js +0 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DataTag, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { APIError } from 'better-auth';
|
|
3
|
+
import { OrganizationAuthServer } from '../../../lib/auth-server';
|
|
4
|
+
export type ListOrganizationInvitationsData<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Awaited<ReturnType<TAuth["api"]["listInvitations"]>>;
|
|
5
|
+
export type ListOrganizationInvitationsParams<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Parameters<TAuth["api"]["listInvitations"]>[0];
|
|
6
|
+
/**
|
|
7
|
+
* Query options factory for invitations of an organization.
|
|
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 `listOrganizationInvitationsOptions` for SSR hydration.
|
|
12
|
+
* @param params - Parameters forwarded to `auth.api.listInvitations`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listOrganizationInvitationsOptions<TAuth extends OrganizationAuthServer>(auth: TAuth, userId: string, params: ListOrganizationInvitationsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listInvitations"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listInvitations"]>>, readonly ["auth", "user", string | undefined, "organization", "invitations", "list", {
|
|
15
|
+
organizationId?: string | undefined;
|
|
16
|
+
} | null]>, "queryFn"> & {
|
|
17
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listInvitations"]>>, readonly ["auth", "user", string | undefined, "organization", "invitations", "list", {
|
|
18
|
+
organizationId?: string | undefined;
|
|
19
|
+
} | null], never> | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
queryKey: readonly ["auth", "user", string | undefined, "organization", "invitations", "list", {
|
|
22
|
+
organizationId?: string | undefined;
|
|
23
|
+
} | null] & {
|
|
24
|
+
[dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listInvitations"]>>;
|
|
25
|
+
[dataTagErrorSymbol]: APIError;
|
|
26
|
+
};
|
|
27
|
+
}) & {
|
|
28
|
+
queryKey: DataTag<readonly ["auth", "user", string | undefined, "organization", "invitations", "list", {
|
|
29
|
+
organizationId?: string | undefined;
|
|
30
|
+
} | null], Awaited<ReturnType<TAuth["api"]["listInvitations"]>>, APIError>;
|
|
31
|
+
};
|
|
32
|
+
export declare const ensureListOrganizationInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationInvitationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listInvitations"]>>>;
|
|
33
|
+
export declare const prefetchListOrganizationInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationInvitationsParams<TAuth>) => Promise<void>;
|
|
34
|
+
export declare const fetchListOrganizationInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationInvitationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listInvitations"]>>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DataTag, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { APIError } from 'better-auth';
|
|
3
|
+
import { OrganizationAuthServer } from '../../../lib/auth-server';
|
|
4
|
+
export type ListOrganizationMembersData<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Awaited<ReturnType<TAuth["api"]["listMembers"]>>;
|
|
5
|
+
export type ListOrganizationMembersParams<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Parameters<TAuth["api"]["listMembers"]>[0];
|
|
6
|
+
/**
|
|
7
|
+
* Query options factory for members of an organization.
|
|
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 `listOrganizationMembersOptions` for SSR hydration.
|
|
12
|
+
* @param params - Parameters forwarded to `auth.api.listMembers`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listOrganizationMembersOptions<TAuth extends OrganizationAuthServer>(auth: TAuth, userId: string, params: ListOrganizationMembersParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listMembers"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listMembers"]>>, readonly ["auth", "user", string | undefined, "organization", "members", "list", {
|
|
15
|
+
limit?: string | number | undefined;
|
|
16
|
+
offset?: string | number | undefined;
|
|
17
|
+
sortBy?: string | undefined;
|
|
18
|
+
sortDirection?: "asc" | "desc" | undefined;
|
|
19
|
+
filterField?: string | undefined;
|
|
20
|
+
filterValue?: string | number | boolean | string[] | number[] | undefined;
|
|
21
|
+
filterOperator?: "in" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
22
|
+
organizationId?: string | undefined;
|
|
23
|
+
organizationSlug?: string | undefined;
|
|
24
|
+
} | null]>, "queryFn"> & {
|
|
25
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listMembers"]>>, readonly ["auth", "user", string | undefined, "organization", "members", "list", {
|
|
26
|
+
limit?: string | number | undefined;
|
|
27
|
+
offset?: string | number | undefined;
|
|
28
|
+
sortBy?: string | undefined;
|
|
29
|
+
sortDirection?: "asc" | "desc" | undefined;
|
|
30
|
+
filterField?: string | undefined;
|
|
31
|
+
filterValue?: string | number | boolean | string[] | number[] | undefined;
|
|
32
|
+
filterOperator?: "in" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
33
|
+
organizationId?: string | undefined;
|
|
34
|
+
organizationSlug?: string | undefined;
|
|
35
|
+
} | null], never> | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
queryKey: readonly ["auth", "user", string | undefined, "organization", "members", "list", {
|
|
38
|
+
limit?: string | number | undefined;
|
|
39
|
+
offset?: string | number | undefined;
|
|
40
|
+
sortBy?: string | undefined;
|
|
41
|
+
sortDirection?: "asc" | "desc" | undefined;
|
|
42
|
+
filterField?: string | undefined;
|
|
43
|
+
filterValue?: string | number | boolean | string[] | number[] | undefined;
|
|
44
|
+
filterOperator?: "in" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
45
|
+
organizationId?: string | undefined;
|
|
46
|
+
organizationSlug?: string | undefined;
|
|
47
|
+
} | null] & {
|
|
48
|
+
[dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listMembers"]>>;
|
|
49
|
+
[dataTagErrorSymbol]: APIError;
|
|
50
|
+
};
|
|
51
|
+
}) & {
|
|
52
|
+
queryKey: DataTag<readonly ["auth", "user", string | undefined, "organization", "members", "list", {
|
|
53
|
+
limit?: string | number | undefined;
|
|
54
|
+
offset?: string | number | undefined;
|
|
55
|
+
sortBy?: string | undefined;
|
|
56
|
+
sortDirection?: "asc" | "desc" | undefined;
|
|
57
|
+
filterField?: string | undefined;
|
|
58
|
+
filterValue?: string | number | boolean | string[] | number[] | undefined;
|
|
59
|
+
filterOperator?: "in" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
60
|
+
organizationId?: string | undefined;
|
|
61
|
+
organizationSlug?: string | undefined;
|
|
62
|
+
} | null], Awaited<ReturnType<TAuth["api"]["listMembers"]>>, APIError>;
|
|
63
|
+
};
|
|
64
|
+
export declare const ensureListOrganizationMembers: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationMembersParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listMembers"]>>>;
|
|
65
|
+
export declare const prefetchListOrganizationMembers: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationMembersParams<TAuth>) => Promise<void>;
|
|
66
|
+
export declare const fetchListOrganizationMembers: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationMembersParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listMembers"]>>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DataTag, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { APIError } from 'better-auth';
|
|
3
|
+
import { OrganizationAuthServer } from '../../../lib/auth-server';
|
|
4
|
+
export type ListOrganizationsData<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>;
|
|
5
|
+
export type ListOrganization<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = NonNullable<ListOrganizationsData<TAuth>>[number];
|
|
6
|
+
export type ListOrganizationsParams<TAuth extends OrganizationAuthServer> = Parameters<TAuth["api"]["listOrganizations"]>[0];
|
|
7
|
+
/**
|
|
8
|
+
* Query options factory for organizations the current user belongs to.
|
|
9
|
+
*
|
|
10
|
+
* @param auth - The Better Auth server instance.
|
|
11
|
+
* @param userId - The signed-in user's ID. Used for cache partitioning so
|
|
12
|
+
* the key matches the client-side `listOrganizationsOptions` for SSR hydration.
|
|
13
|
+
* @param params - Parameters forwarded to `auth.api.listOrganizations`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function listOrganizationsOptions<TAuth extends OrganizationAuthServer>(auth: TAuth, userId: string, params: ListOrganizationsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>, readonly ["auth", "user", string | undefined, "organization", "list", Record<string, any> | null]>, "queryFn"> & {
|
|
16
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>, readonly ["auth", "user", string | undefined, "organization", "list", Record<string, any> | null], never> | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
queryKey: readonly ["auth", "user", string | undefined, "organization", "list", Record<string, any> | null] & {
|
|
19
|
+
[dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>;
|
|
20
|
+
[dataTagErrorSymbol]: APIError;
|
|
21
|
+
};
|
|
22
|
+
}) & {
|
|
23
|
+
queryKey: DataTag<readonly ["auth", "user", string | undefined, "organization", "list", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>, APIError>;
|
|
24
|
+
};
|
|
25
|
+
export declare const ensureListOrganizations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>>;
|
|
26
|
+
export declare const prefetchListOrganizations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationsParams<TAuth>) => Promise<void>;
|
|
27
|
+
export declare const fetchListOrganizations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListOrganizationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listOrganizations"]>>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DataTag, QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { APIError } from 'better-auth';
|
|
3
|
+
import { OrganizationAuthServer } from '../../../lib/auth-server';
|
|
4
|
+
export type ListUserInvitationsData<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>;
|
|
5
|
+
export type ListUserInvitationsParams<TAuth extends OrganizationAuthServer = OrganizationAuthServer> = Parameters<TAuth["api"]["listUserInvitations"]>[0];
|
|
6
|
+
/**
|
|
7
|
+
* Query options factory for invitations addressed to the current user.
|
|
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 `listUserInvitationsOptions` for SSR hydration.
|
|
12
|
+
* @param params - Parameters forwarded to `auth.api.listUserInvitations`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listUserInvitationsOptions<TAuth extends OrganizationAuthServer>(auth: TAuth, userId: string, params: ListUserInvitationsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>, readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list", {
|
|
15
|
+
email?: string | undefined;
|
|
16
|
+
} | null]>, "queryFn"> & {
|
|
17
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>, readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list", {
|
|
18
|
+
email?: string | undefined;
|
|
19
|
+
} | null], never> | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
queryKey: readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list", {
|
|
22
|
+
email?: string | undefined;
|
|
23
|
+
} | null] & {
|
|
24
|
+
[dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>;
|
|
25
|
+
[dataTagErrorSymbol]: APIError;
|
|
26
|
+
};
|
|
27
|
+
}) & {
|
|
28
|
+
queryKey: DataTag<readonly ["auth", "user", string | undefined, "organization", "userInvitations", "list", {
|
|
29
|
+
email?: string | undefined;
|
|
30
|
+
} | null], Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>, APIError>;
|
|
31
|
+
};
|
|
32
|
+
export declare const ensureListUserInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListUserInvitationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>>;
|
|
33
|
+
export declare const prefetchListUserInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListUserInvitationsParams<TAuth>) => Promise<void>;
|
|
34
|
+
export declare const fetchListUserInvitations: <TAuth extends OrganizationAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListUserInvitationsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listUserInvitations"]>>>;
|
|
@@ -12,15 +12,15 @@ export type ListPasskey<TAuth extends PasskeyAuthServer = PasskeyAuthServer> = N
|
|
|
12
12
|
* the key matches the client-side `listPasskeysOptions` for SSR hydration.
|
|
13
13
|
* @param params - Parameters forwarded to `auth.api.listPasskeys`.
|
|
14
14
|
*/
|
|
15
|
-
export declare function listPasskeysOptions<TAuth extends PasskeyAuthServer>(auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "
|
|
16
|
-
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "
|
|
15
|
+
export declare function listPasskeysOptions<TAuth extends PasskeyAuthServer>(auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "passkey", "list", Record<string, any> | null]>, "queryFn"> & {
|
|
16
|
+
queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "passkey", "list", Record<string, any> | null], never> | undefined;
|
|
17
17
|
} & {
|
|
18
|
-
queryKey: readonly ["auth", "user", string | undefined, "
|
|
18
|
+
queryKey: readonly ["auth", "user", string | undefined, "passkey", "list", Record<string, any> | null] & {
|
|
19
19
|
[dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>;
|
|
20
20
|
[dataTagErrorSymbol]: APIError;
|
|
21
21
|
};
|
|
22
22
|
}) & {
|
|
23
|
-
queryKey: DataTag<readonly ["auth", "user", string | undefined, "
|
|
23
|
+
queryKey: DataTag<readonly ["auth", "user", string | undefined, "passkey", "list", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, APIError>;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Get the current user's passkeys from the query cache, calling
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export type * from './lib/auth-server';
|
|
2
|
+
export * from './server/queries/api-key/list-api-keys-query';
|
|
2
3
|
export * from './server/queries/auth/session-query';
|
|
3
4
|
export * from './server/queries/multi-session/list-device-sessions-query';
|
|
5
|
+
export * from './server/queries/organization/active-organization-query';
|
|
6
|
+
export * from './server/queries/organization/full-organization-query';
|
|
7
|
+
export * from './server/queries/organization/has-permission-query';
|
|
8
|
+
export * from './server/queries/organization/list-invitations-query';
|
|
9
|
+
export * from './server/queries/organization/list-members-query';
|
|
10
|
+
export * from './server/queries/organization/list-organizations-query';
|
|
11
|
+
export * from './server/queries/organization/list-user-invitations-query';
|
|
4
12
|
export * from './server/queries/passkey/list-passkeys-query';
|
|
5
13
|
export * from './server/queries/settings/account-info-query';
|
|
6
14
|
export * from './server/queries/settings/list-accounts-query';
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,131 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { authQueryKeys as e } from "@better-auth-ui/core";
|
|
2
|
+
import { queryOptions as t } from "@tanstack/react-query";
|
|
3
|
+
import { apiKeyQueryKeys as n, multiSessionQueryKeys as r, organizationQueryKeys as i, passkeyQueryKeys as a } from "@better-auth-ui/core/plugins";
|
|
4
|
+
//#region src/server/queries/api-key/list-api-keys-query.ts
|
|
5
|
+
function o(e, r, i) {
|
|
6
|
+
return t({
|
|
7
|
+
queryKey: n.list(r, i?.query),
|
|
8
|
+
queryFn: () => e.api.listApiKeys(i)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
var s = (e, t, n, r) => e.ensureQueryData(o(t, n, r)), c = (e, t, n, r) => e.prefetchQuery(o(t, n, r)), l = (e, t, n, r) => e.fetchQuery(o(t, n, r));
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/server/queries/auth/session-query.ts
|
|
14
|
+
function u(n, r) {
|
|
15
|
+
let i = e.session;
|
|
16
|
+
return t({
|
|
17
|
+
queryKey: i,
|
|
18
|
+
queryFn: () => n.api.getSession(r)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var d = (e, t, n) => e.ensureQueryData(u(t, n)), f = (e, t, n) => e.prefetchQuery(u(t, n)), p = (e, t, n) => e.fetchQuery(u(t, n));
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/server/queries/multi-session/list-device-sessions-query.ts
|
|
24
|
+
function m(e, n, i) {
|
|
25
|
+
return t({
|
|
26
|
+
queryKey: r.list(n, i?.query),
|
|
27
|
+
queryFn: () => e.api.listDeviceSessions(i)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var h = (e, t, n, r) => e.ensureQueryData(m(t, n, r)), g = (e, t, n, r) => e.prefetchQuery(m(t, n, r)), _ = (e, t, n, r) => e.fetchQuery(m(t, n, r));
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/server/queries/organization/active-organization-query.ts
|
|
33
|
+
function v(e, n, r) {
|
|
34
|
+
return t({
|
|
35
|
+
queryKey: i.activeOrganization(n, r?.query),
|
|
36
|
+
queryFn: () => e.api.getFullOrganization(r)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var ee = (e, t, n, r) => e.ensureQueryData(v(t, n, r)), y = (e, t, n, r) => e.prefetchQuery(v(t, n, r)), b = (e, t, n, r) => e.fetchQuery(v(t, n, r));
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/server/queries/organization/full-organization-query.ts
|
|
42
|
+
function x(e, n, r) {
|
|
43
|
+
return t({
|
|
44
|
+
queryKey: i.fullDetail(n, r?.query),
|
|
45
|
+
queryFn: () => e.api.getFullOrganization(r)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var S = (e, t, n, r) => e.ensureQueryData(x(t, n, r)), C = (e, t, n, r) => e.prefetchQuery(x(t, n, r)), w = (e, t, n, r) => e.fetchQuery(x(t, n, r));
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/server/queries/organization/has-permission-query.ts
|
|
51
|
+
function T(e, n, r) {
|
|
52
|
+
return t({
|
|
53
|
+
queryKey: i.permissions.has(n, r?.body),
|
|
54
|
+
queryFn: () => e.api.hasPermission(r)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var E = (e, t, n, r) => e.ensureQueryData(T(t, n, r)), D = (e, t, n, r) => e.prefetchQuery(T(t, n, r)), O = (e, t, n, r) => e.fetchQuery(T(t, n, r));
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/server/queries/organization/list-invitations-query.ts
|
|
60
|
+
function k(e, n, r) {
|
|
61
|
+
return t({
|
|
62
|
+
queryKey: i.invitations.list(n, r?.query),
|
|
63
|
+
queryFn: () => e.api.listInvitations(r)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var A = (e, t, n, r) => e.ensureQueryData(k(t, n, r)), j = (e, t, n, r) => e.prefetchQuery(k(t, n, r)), M = (e, t, n, r) => e.fetchQuery(k(t, n, r));
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/server/queries/organization/list-members-query.ts
|
|
69
|
+
function N(e, n, r) {
|
|
70
|
+
return t({
|
|
71
|
+
queryKey: i.members.list(n, r?.query),
|
|
72
|
+
queryFn: () => e.api.listMembers(r)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var P = (e, t, n, r) => e.ensureQueryData(N(t, n, r)), F = (e, t, n, r) => e.prefetchQuery(N(t, n, r)), I = (e, t, n, r) => e.fetchQuery(N(t, n, r));
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/server/queries/organization/list-organizations-query.ts
|
|
78
|
+
function L(e, n, r) {
|
|
79
|
+
return t({
|
|
80
|
+
queryKey: i.list(n, r?.query),
|
|
81
|
+
queryFn: () => e.api.listOrganizations(r)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
var R = (e, t, n, r) => e.ensureQueryData(L(t, n, r)), te = (e, t, n, r) => e.prefetchQuery(L(t, n, r)), z = (e, t, n, r) => e.fetchQuery(L(t, n, r));
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/server/queries/organization/list-user-invitations-query.ts
|
|
87
|
+
function B(e, n, r) {
|
|
88
|
+
return t({
|
|
89
|
+
queryKey: i.userInvitations.list(n, r?.query),
|
|
90
|
+
queryFn: () => e.api.listUserInvitations(r)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
var V = (e, t, n, r) => e.ensureQueryData(B(t, n, r)), H = (e, t, n, r) => e.prefetchQuery(B(t, n, r)), U = (e, t, n, r) => e.fetchQuery(B(t, n, r));
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/server/queries/passkey/list-passkeys-query.ts
|
|
96
|
+
function W(e, n, r) {
|
|
97
|
+
return t({
|
|
98
|
+
queryKey: a.list(n, r?.query),
|
|
99
|
+
queryFn: () => e.api.listPasskeys(r)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var G = (e, t, n, r) => e.ensureQueryData(W(t, n, r)), K = (e, t, n, r) => e.prefetchQuery(W(t, n, r)), q = (e, t, n, r) => e.fetchQuery(W(t, n, r));
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/server/queries/settings/account-info-query.ts
|
|
105
|
+
function J(n, r, i) {
|
|
106
|
+
return t({
|
|
107
|
+
queryKey: e.accountInfo(r, i?.query),
|
|
108
|
+
queryFn: () => n.api.accountInfo(i)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var Y = (e, t, n, r) => e.ensureQueryData(J(t, n, r)), X = (e, t, n, r) => e.prefetchQuery(J(t, n, r)), Z = (e, t, n, r) => e.fetchQuery(J(t, n, r));
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/server/queries/settings/list-accounts-query.ts
|
|
114
|
+
function Q(n, r, i) {
|
|
115
|
+
return t({
|
|
116
|
+
queryKey: e.listAccounts(r, i?.query),
|
|
117
|
+
queryFn: () => n.api.listUserAccounts(i)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var ne = (e, t, n, r) => e.ensureQueryData(Q(t, n, r)), re = (e, t, n, r) => e.prefetchQuery(Q(t, n, r)), ie = (e, t, n, r) => e.fetchQuery(Q(t, n, r));
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/server/queries/settings/list-sessions-query.ts
|
|
123
|
+
function $(n, r, i) {
|
|
124
|
+
return t({
|
|
125
|
+
queryKey: e.listSessions(r, i?.query),
|
|
126
|
+
queryFn: () => n.api.listSessions(i)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
var ae = (e, t, n, r) => e.ensureQueryData($(t, n, r)), oe = (e, t, n, r) => e.prefetchQuery($(t, n, r)), se = (e, t, n, r) => e.fetchQuery($(t, n, r));
|
|
130
|
+
//#endregion
|
|
131
|
+
export { J as accountInfoOptions, v as activeOrganizationOptions, Y as ensureAccountInfo, ee as ensureActiveOrganization, S as ensureFullOrganization, E as ensureHasPermission, ne as ensureListAccounts, s as ensureListApiKeys, h as ensureListDeviceSessions, A as ensureListOrganizationInvitations, P as ensureListOrganizationMembers, R as ensureListOrganizations, G as ensureListPasskeys, ae as ensureListSessions, V as ensureListUserInvitations, d as ensureSession, Z as fetchAccountInfo, b as fetchActiveOrganization, w as fetchFullOrganization, O as fetchHasPermission, ie as fetchListAccounts, l as fetchListApiKeys, _ as fetchListDeviceSessions, M as fetchListOrganizationInvitations, I as fetchListOrganizationMembers, z as fetchListOrganizations, q as fetchListPasskeys, se as fetchListSessions, U as fetchListUserInvitations, p as fetchSession, x as fullOrganizationOptions, T as hasPermissionOptions, Q as listAccountsOptions, o as listApiKeysOptions, m as listDeviceSessionsOptions, k as listOrganizationInvitationsOptions, N as listOrganizationMembersOptions, L as listOrganizationsOptions, W as listPasskeysOptions, $ as listSessionsOptions, B as listUserInvitationsOptions, X as prefetchAccountInfo, y as prefetchActiveOrganization, C as prefetchFullOrganization, D as prefetchHasPermission, re as prefetchListAccounts, c as prefetchListApiKeys, g as prefetchListDeviceSessions, j as prefetchListOrganizationInvitations, F as prefetchListOrganizationMembers, te as prefetchListOrganizations, K as prefetchListPasskeys, oe as prefetchListSessions, H as prefetchListUserInvitations, f as prefetchSession, u as sessionOptions };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { authMutationKeys as e, deepmerge as t, defaultAuthConfig as n } from "@better-auth-ui/core";
|
|
2
|
+
import { QueryClient as r, QueryClientContext as i, QueryClientProvider as a, matchMutation as o, matchQuery as s, useQueryClient as c } from "@tanstack/react-query";
|
|
3
|
+
import { createContext as l, useCallback as u, useContext as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
4
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/mutation-invalidator.tsx
|
|
6
|
+
function _() {
|
|
7
|
+
let t = c();
|
|
8
|
+
return f(() => {
|
|
9
|
+
let n = t.getMutationCache(), r = n.config.onSuccess;
|
|
10
|
+
return n.config.onSuccess = async (n, i, a, c, l) => {
|
|
11
|
+
if (await r?.(n, i, a, c, l), !o({ mutationKey: e.all }, c)) return;
|
|
12
|
+
let { invalidates: u, awaits: d } = c.meta ?? {};
|
|
13
|
+
if (u?.length && t.invalidateQueries({ predicate: (e) => u.some((t) => s({ queryKey: t }, e)) }), d?.length) return t.invalidateQueries({ predicate: (e) => d.some((t) => s({ queryKey: t }, e)) }, { cancelRefetch: !1 });
|
|
14
|
+
}, () => {
|
|
15
|
+
n.config.onSuccess = r;
|
|
16
|
+
};
|
|
17
|
+
}, [t]), null;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/auth/auth-context.tsx
|
|
21
|
+
var v = l(void 0), y = l(void 0);
|
|
22
|
+
function b({ children: e }) {
|
|
23
|
+
let [t, n] = m(void 0), r = p(null), i = u((e) => {
|
|
24
|
+
n(e);
|
|
25
|
+
}, []), a = u((e) => {
|
|
26
|
+
r.current = e;
|
|
27
|
+
}, []), o = u(() => {
|
|
28
|
+
n(void 0), r.current?.();
|
|
29
|
+
}, []);
|
|
30
|
+
return /* @__PURE__ */ h(y.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
fetchOptions: t,
|
|
33
|
+
setFetchOptions: i,
|
|
34
|
+
resetFetchOptions: o,
|
|
35
|
+
registerReset: a
|
|
36
|
+
},
|
|
37
|
+
children: e
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function x() {
|
|
41
|
+
let e = d(y);
|
|
42
|
+
if (!e) throw Error("[Better Auth UI] useFetchOptions must be used within FetchOptionsProvider");
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/components/auth/auth-provider.tsx
|
|
47
|
+
var S = new r({ defaultOptions: { queries: { staleTime: 5e3 } } });
|
|
48
|
+
function C({ children: e, queryClient: r, ...o }) {
|
|
49
|
+
let { authClient: s, ...c } = o, l = {
|
|
50
|
+
...t(n, c),
|
|
51
|
+
authClient: s
|
|
52
|
+
};
|
|
53
|
+
l.redirectTo = typeof window < "u" && new URLSearchParams(window.location.search).get("redirectTo")?.trim() || l.redirectTo;
|
|
54
|
+
let u = /* @__PURE__ */ new Map();
|
|
55
|
+
for (let e of l.plugins ?? []) for (let t of e.additionalFields ?? []) u.set(t.name, t);
|
|
56
|
+
for (let e of l.additionalFields ?? []) u.set(e.name, e);
|
|
57
|
+
l.additionalFields = Array.from(u.values());
|
|
58
|
+
let f = d(i);
|
|
59
|
+
return /* @__PURE__ */ h(a, {
|
|
60
|
+
client: r || f || S,
|
|
61
|
+
children: /* @__PURE__ */ h(v.Provider, {
|
|
62
|
+
value: l,
|
|
63
|
+
children: /* @__PURE__ */ g(b, { children: [/* @__PURE__ */ h(_, {}), e] })
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function w() {
|
|
68
|
+
let e = d(v);
|
|
69
|
+
if (!e) throw Error("[Better Auth UI] AuthProvider is required");
|
|
70
|
+
return e;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/hooks/use-auth-plugin.ts
|
|
74
|
+
function T(e) {
|
|
75
|
+
let { plugins: t } = w(), n = t?.find((t) => t.id === e.id);
|
|
76
|
+
if (!n) throw Error(`[Better Auth UI] useAuthPlugin: plugin "${e.id}" is not registered on AuthProvider.`);
|
|
77
|
+
return n;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { x as a, b as i, C as n, w as r, T as t };
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth-ui/react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
7
|
-
"dev": "tsc --watch",
|
|
8
7
|
"email": "email dev --dir src/components/auth/email -p 9000",
|
|
9
8
|
"test": "vitest"
|
|
10
9
|
},
|
|
@@ -16,51 +15,55 @@
|
|
|
16
15
|
"types": "./dist/index.d.ts",
|
|
17
16
|
"exports": {
|
|
18
17
|
".": {
|
|
18
|
+
"development": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"import": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"./email": {
|
|
23
|
+
"development": "./src/email.ts",
|
|
23
24
|
"types": "./dist/email.d.ts",
|
|
24
25
|
"import": "./dist/email.js"
|
|
25
26
|
},
|
|
26
27
|
"./server": {
|
|
28
|
+
"development": "./src/server.ts",
|
|
27
29
|
"types": "./dist/server.d.ts",
|
|
28
30
|
"import": "./dist/server.js"
|
|
29
31
|
},
|
|
30
32
|
"./plugins": {
|
|
33
|
+
"development": "./src/plugins.ts",
|
|
31
34
|
"types": "./dist/plugins.d.ts",
|
|
32
35
|
"import": "./dist/plugins.js"
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
|
-
"@better-auth/api-key": "^1.6.
|
|
37
|
-
"@better-auth/passkey": "^1.6.
|
|
39
|
+
"@better-auth/api-key": "^1.6.11",
|
|
40
|
+
"@better-auth/passkey": "^1.6.11",
|
|
38
41
|
"@react-email/components": "^1.0.12",
|
|
39
42
|
"@react-email/preview-server": "^5.2.10",
|
|
40
|
-
"@tanstack/react-query": "^5.100.
|
|
43
|
+
"@tanstack/react-query": "^5.100.14",
|
|
41
44
|
"@testing-library/react": "^16.3.2",
|
|
42
45
|
"@testing-library/user-event": "^14.5.2",
|
|
43
|
-
"@types/react": "^19.2.
|
|
44
|
-
"@vitejs/plugin-react": "^6.0.
|
|
45
|
-
"@vitest/browser-playwright": "^4.1.
|
|
46
|
-
"better-auth": "^1.6.
|
|
46
|
+
"@types/react": "^19.2.15",
|
|
47
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
48
|
+
"@vitest/browser-playwright": "^4.1.7",
|
|
49
|
+
"better-auth": "^1.6.11",
|
|
47
50
|
"clsx": "^2.1.1",
|
|
48
|
-
"playwright": "^1.
|
|
51
|
+
"playwright": "^1.60.0",
|
|
49
52
|
"react": "^19.2.6",
|
|
50
53
|
"react-dom": "^19.2.6",
|
|
51
|
-
"react-email": "^6.
|
|
54
|
+
"react-email": "^6.4.0",
|
|
52
55
|
"tailwind-merge": "^3.5.0",
|
|
53
56
|
"tailwindcss": "^4.3.0",
|
|
54
|
-
"vitest": "^4.1.
|
|
57
|
+
"vitest": "^4.1.7",
|
|
55
58
|
"zod": "^4.4.3"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
61
|
"@better-auth-ui/core": "*",
|
|
59
|
-
"@better-auth/api-key": ">=1.6.
|
|
60
|
-
"@better-auth/passkey": ">=1.6.
|
|
62
|
+
"@better-auth/api-key": ">=1.6.11",
|
|
63
|
+
"@better-auth/passkey": ">=1.6.11",
|
|
61
64
|
"@react-email/components": ">=1.0.12",
|
|
62
|
-
"@tanstack/react-query": ">=5.100.
|
|
63
|
-
"better-auth": ">=1.6.
|
|
65
|
+
"@tanstack/react-query": ">=5.100.14",
|
|
66
|
+
"better-auth": ">=1.6.11",
|
|
64
67
|
"clsx": ">=2.0.0",
|
|
65
68
|
"react": ">=19.2.6",
|
|
66
69
|
"react-dom": ">=19.2.6",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import type { AuthConfig } from "@better-auth-ui/core"
|
|
4
|
+
import { createContext } from "react"
|
|
5
|
+
|
|
6
|
+
/** Split from `auth-provider` so HMR reloading that file does not replace this context instance. */
|
|
7
|
+
export const AuthContext = createContext<AuthConfig | undefined>(undefined)
|
|
@@ -12,17 +12,12 @@ import {
|
|
|
12
12
|
QueryClientContext,
|
|
13
13
|
QueryClientProvider
|
|
14
14
|
} from "@tanstack/react-query"
|
|
15
|
-
import {
|
|
16
|
-
createContext,
|
|
17
|
-
type PropsWithChildren,
|
|
18
|
-
type ReactNode,
|
|
19
|
-
useContext
|
|
20
|
-
} from "react"
|
|
15
|
+
import { type PropsWithChildren, type ReactNode, useContext } from "react"
|
|
21
16
|
import type { AuthClient } from "../../lib/auth-client"
|
|
17
|
+
import { MutationInvalidator } from "../mutation-invalidator"
|
|
18
|
+
import { AuthContext } from "./auth-context"
|
|
22
19
|
import { FetchOptionsProvider } from "./fetch-options-provider"
|
|
23
20
|
|
|
24
|
-
const AuthContext = createContext<AuthConfig | undefined>(undefined)
|
|
25
|
-
|
|
26
21
|
const fallbackQueryClient = new QueryClient({
|
|
27
22
|
defaultOptions: {
|
|
28
23
|
queries: {
|
|
@@ -70,19 +65,14 @@ export function AuthProvider({
|
|
|
70
65
|
queryClient,
|
|
71
66
|
...config
|
|
72
67
|
}: AuthProviderProps) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...defaultAuthConfig.viewPaths.settings,
|
|
82
|
-
...config.viewPaths?.settings
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} as AuthConfig)
|
|
68
|
+
const { authClient, ...partialConfig } = config
|
|
69
|
+
const mergedConfig = {
|
|
70
|
+
...deepmerge<Omit<AuthConfig, "authClient">>(
|
|
71
|
+
defaultAuthConfig,
|
|
72
|
+
partialConfig
|
|
73
|
+
),
|
|
74
|
+
authClient
|
|
75
|
+
}
|
|
86
76
|
|
|
87
77
|
mergedConfig.redirectTo =
|
|
88
78
|
(typeof window !== "undefined" &&
|
|
@@ -105,18 +95,16 @@ export function AuthProvider({
|
|
|
105
95
|
|
|
106
96
|
const contextQueryClient = useContext(QueryClientContext)
|
|
107
97
|
|
|
108
|
-
if (contextQueryClient) {
|
|
109
|
-
return (
|
|
110
|
-
<AuthContext.Provider value={mergedConfig}>
|
|
111
|
-
<FetchOptionsProvider>{children}</FetchOptionsProvider>
|
|
112
|
-
</AuthContext.Provider>
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
98
|
return (
|
|
117
|
-
<QueryClientProvider
|
|
99
|
+
<QueryClientProvider
|
|
100
|
+
client={queryClient || contextQueryClient || fallbackQueryClient}
|
|
101
|
+
>
|
|
118
102
|
<AuthContext.Provider value={mergedConfig}>
|
|
119
|
-
<FetchOptionsProvider>
|
|
103
|
+
<FetchOptionsProvider>
|
|
104
|
+
<MutationInvalidator />
|
|
105
|
+
|
|
106
|
+
{children}
|
|
107
|
+
</FetchOptionsProvider>
|
|
120
108
|
</AuthContext.Provider>
|
|
121
109
|
</QueryClientProvider>
|
|
122
110
|
)
|
|
@@ -2,6 +2,7 @@ import EmailChangedEmail from "./email-changed"
|
|
|
2
2
|
import EmailVerificationEmail from "./email-verification"
|
|
3
3
|
import MagicLinkEmail from "./magic-link"
|
|
4
4
|
import NewDeviceEmail from "./new-device"
|
|
5
|
+
import OrganizationInvitationEmail from "./organization-invitation"
|
|
5
6
|
import OtpEmail from "./otp-email"
|
|
6
7
|
import PasswordChangedEmail from "./password-changed"
|
|
7
8
|
import ResetPasswordEmail from "./reset-password"
|
|
@@ -10,15 +11,16 @@ import ResetPasswordEmail from "./reset-password"
|
|
|
10
11
|
* Aggregated localization strings for all email components.
|
|
11
12
|
*
|
|
12
13
|
* Combines localization strings from all email templates (EmailChangedEmail,
|
|
13
|
-
* EmailVerificationEmail, MagicLinkEmail, NewDeviceEmail,
|
|
14
|
-
*
|
|
15
|
-
* bulk customization.
|
|
14
|
+
* EmailVerificationEmail, MagicLinkEmail, NewDeviceEmail,
|
|
15
|
+
* OrganizationInvitationEmail, OtpEmail, PasswordChangedEmail,
|
|
16
|
+
* ResetPasswordEmail) into a single object for convenient bulk customization.
|
|
16
17
|
*/
|
|
17
18
|
export const emailLocalization = {
|
|
18
19
|
...EmailChangedEmail.localization,
|
|
19
20
|
...EmailVerificationEmail.localization,
|
|
20
21
|
...MagicLinkEmail.localization,
|
|
21
22
|
...NewDeviceEmail.localization,
|
|
23
|
+
...OrganizationInvitationEmail.localization,
|
|
22
24
|
...OtpEmail.localization,
|
|
23
25
|
...PasswordChangedEmail.localization,
|
|
24
26
|
...ResetPasswordEmail.localization
|
|
@@ -4,6 +4,7 @@ export * from "./email-styles"
|
|
|
4
4
|
export * from "./email-verification"
|
|
5
5
|
export * from "./magic-link"
|
|
6
6
|
export * from "./new-device"
|
|
7
|
+
export * from "./organization-invitation"
|
|
7
8
|
export * from "./otp-email"
|
|
8
9
|
export * from "./password-changed"
|
|
9
10
|
export * from "./reset-password"
|