@better-auth-ui/core 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.
Files changed (83) hide show
  1. package/dist/config/auth-config.d.ts +1 -1
  2. package/dist/create-auth-plugin-CnH7jMHA.js +199 -0
  3. package/dist/index.js +103 -11
  4. package/dist/lib/auth-mutation-keys.d.ts +9 -20
  5. package/dist/lib/auth-plugin.d.ts +5 -6
  6. package/dist/lib/auth-query-keys.d.ts +6 -6
  7. package/dist/lib/create-auth-plugin.d.ts +5 -21
  8. package/dist/lib/localization.d.ts +2 -2
  9. package/dist/lib/view-paths.d.ts +0 -4
  10. package/dist/plugins/api-key/api-key-mutation-keys.d.ts +4 -2
  11. package/dist/plugins/api-key/api-key-plugin.d.ts +23 -2
  12. package/dist/plugins/api-key/api-key-query-keys.d.ts +6 -0
  13. package/dist/plugins/delete-user/delete-user-localization.d.ts +3 -3
  14. package/dist/plugins/delete-user/delete-user-mutation-keys.d.ts +7 -0
  15. package/dist/plugins/delete-user/delete-user-plugin.d.ts +4 -4
  16. package/dist/plugins/magic-link/magic-link-plugin.d.ts +2 -2
  17. package/dist/plugins/multi-session/multi-session-mutation-keys.d.ts +11 -0
  18. package/dist/plugins/multi-session/multi-session-plugin.d.ts +2 -2
  19. package/dist/plugins/multi-session/multi-session-query-keys.d.ts +6 -0
  20. package/dist/plugins/organization/organization-localization.d.ts +115 -0
  21. package/dist/plugins/organization/organization-mutation-keys.d.ts +40 -0
  22. package/dist/plugins/organization/organization-plugin.d.ts +152 -0
  23. package/dist/plugins/organization/organization-query-keys.d.ts +40 -0
  24. package/dist/plugins/organization/organization-view-paths.d.ts +19 -0
  25. package/dist/plugins/passkey/passkey-plugin.d.ts +2 -2
  26. package/dist/plugins/passkey/passkey-query-keys.d.ts +6 -0
  27. package/dist/plugins/theme/theme-plugin.d.ts +2 -2
  28. package/dist/plugins/username/username-mutation-keys.d.ts +17 -0
  29. package/dist/plugins/username/username-plugin.d.ts +3 -3
  30. package/dist/plugins.d.ts +28 -0
  31. package/dist/plugins.js +360 -18
  32. package/package.json +7 -6
  33. package/src/config/auth-config.ts +1 -1
  34. package/src/lib/auth-mutation-keys.ts +11 -24
  35. package/src/lib/auth-plugin.ts +4 -5
  36. package/src/lib/auth-query-keys.ts +6 -23
  37. package/src/lib/create-auth-plugin.ts +9 -26
  38. package/src/lib/localization.ts +4 -4
  39. package/src/lib/view-paths.ts +0 -4
  40. package/src/plugins/api-key/api-key-mutation-keys.ts +4 -2
  41. package/src/plugins/api-key/api-key-plugin.ts +22 -1
  42. package/src/plugins/api-key/api-key-query-keys.ts +13 -0
  43. package/src/plugins/delete-user/delete-user-localization.ts +3 -3
  44. package/src/plugins/delete-user/delete-user-mutation-keys.ts +7 -0
  45. package/src/plugins/multi-session/multi-session-mutation-keys.ts +11 -0
  46. package/src/plugins/multi-session/multi-session-query-keys.ts +13 -0
  47. package/src/plugins/organization/organization-localization.ts +123 -0
  48. package/src/plugins/organization/organization-mutation-keys.ts +52 -0
  49. package/src/plugins/organization/organization-plugin.ts +112 -0
  50. package/src/plugins/organization/organization-query-keys.ts +86 -0
  51. package/src/plugins/organization/organization-view-paths.ts +20 -0
  52. package/src/plugins/passkey/passkey-query-keys.ts +13 -0
  53. package/src/plugins/username/username-mutation-keys.ts +17 -0
  54. package/src/plugins.ts +28 -0
  55. package/dist/config/additional-fields-config.js +0 -27
  56. package/dist/config/auth-config.js +0 -32
  57. package/dist/lib/auth-mutation-keys.js +0 -57
  58. package/dist/lib/auth-query-keys.js +0 -39
  59. package/dist/lib/base-paths.js +0 -8
  60. package/dist/lib/create-auth-plugin.js +0 -9
  61. package/dist/lib/localization.js +0 -81
  62. package/dist/lib/provider-names.js +0 -43
  63. package/dist/lib/utils.js +0 -48
  64. package/dist/lib/view-paths.js +0 -16
  65. package/dist/plugins/api-key/api-key-localization.js +0 -16
  66. package/dist/plugins/api-key/api-key-mutation-keys.js +0 -15
  67. package/dist/plugins/api-key/api-key-plugin.js +0 -9
  68. package/dist/plugins/delete-user/delete-user-localization.js +0 -9
  69. package/dist/plugins/delete-user/delete-user-plugin.js +0 -12
  70. package/dist/plugins/index.d.ts +0 -17
  71. package/dist/plugins/magic-link/magic-link-localization.js +0 -8
  72. package/dist/plugins/magic-link/magic-link-mutation-keys.js +0 -8
  73. package/dist/plugins/magic-link/magic-link-plugin.js +0 -12
  74. package/dist/plugins/multi-session/multi-session-localization.js +0 -9
  75. package/dist/plugins/multi-session/multi-session-plugin.js +0 -9
  76. package/dist/plugins/passkey/passkey-localization.js +0 -14
  77. package/dist/plugins/passkey/passkey-mutation-keys.js +0 -20
  78. package/dist/plugins/passkey/passkey-plugin.js +0 -9
  79. package/dist/plugins/theme/theme-localization.js +0 -10
  80. package/dist/plugins/theme/theme-plugin.js +0 -18
  81. package/dist/plugins/username/username-localization.js +0 -12
  82. package/dist/plugins/username/username-plugin.js +0 -33
  83. package/src/plugins/index.ts +0 -17
@@ -10,11 +10,32 @@ export type ApiKeyPluginOptions = {
10
10
  * @remarks `ApiKeyLocalization`
11
11
  */
12
12
  localization?: Partial<ApiKeyLocalization>
13
+ /**
14
+ * Enable organization-owned API keys.
15
+ *
16
+ * When `true`, the plugin contributes an organization-scoped API keys card
17
+ * to `<OrganizationSettings />`, and list/create/delete operations made on
18
+ * behalf of an organization send `configId: "organization"`.
19
+ *
20
+ * Requires a matching server-side `apiKey` config entry with
21
+ * `configId: "organization"` and `references: "organization"`:
22
+ *
23
+ * ```ts
24
+ * apiKey([
25
+ * { configId: "default", references: "user" },
26
+ * { configId: "organization", references: "organization" }
27
+ * ])
28
+ * ```
29
+ *
30
+ * @default false
31
+ */
32
+ organization?: boolean
13
33
  }
14
34
 
15
35
  export const apiKeyPlugin = createAuthPlugin(
16
36
  "apiKey",
17
37
  (options: ApiKeyPluginOptions = {}) => ({
18
- localization: { ...apiKeyLocalization, ...options.localization }
38
+ localization: { ...apiKeyLocalization, ...options.localization },
39
+ organization: options.organization ?? false
19
40
  })
20
41
  )
@@ -0,0 +1,13 @@
1
+ import { authQueryKeys } from "../../lib/auth-query-keys"
2
+
3
+ /** Query key factory for API key queries, scoped per user. */
4
+ export const apiKeyQueryKeys = {
5
+ all: (userId: string | undefined) =>
6
+ [...authQueryKeys.user(userId), "apiKey"] as const,
7
+
8
+ lists: (userId: string | undefined) =>
9
+ [...apiKeyQueryKeys.all(userId), "list"] as const,
10
+
11
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
12
+ [...apiKeyQueryKeys.lists(userId), query ?? null] as const
13
+ } as const
@@ -1,9 +1,9 @@
1
1
  export const deleteUserLocalization = {
2
- /** @remarks `"Delete user"` */
3
- deleteUser: "Delete user",
2
+ /** @remarks `"Delete account"` */
3
+ deleteAccount: "Delete account",
4
4
 
5
5
  /** @remarks `"Permanently remove your account and all associated data. This cannot be undone."` */
6
- deleteUserDescription:
6
+ deleteAccountDescription:
7
7
  "Permanently remove your account and all associated data. This cannot be undone.",
8
8
 
9
9
  /** @remarks `"Check your email to confirm account deletion."` */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Mutation keys contributed by the delete-user plugin.
3
+ */
4
+ export const deleteUserMutationKeys = {
5
+ /** Key for `deleteUser`. */
6
+ deleteUser: ["auth", "deleteUser"] as const
7
+ } as const
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Mutation keys contributed by the multi-session plugin.
3
+ */
4
+ export const multiSessionMutationKeys = {
5
+ /** Root key for every multi-session mutation. */
6
+ all: ["auth", "multiSession"] as const,
7
+ /** Key for `multiSession.revoke`. */
8
+ revoke: ["auth", "multiSession", "revoke"] as const,
9
+ /** Key for `multiSession.setActive`. */
10
+ setActive: ["auth", "multiSession", "setActive"] as const
11
+ } as const
@@ -0,0 +1,13 @@
1
+ import { authQueryKeys } from "../../lib/auth-query-keys"
2
+
3
+ /** Query key factory for multi-session queries, scoped per user. */
4
+ export const multiSessionQueryKeys = {
5
+ all: (userId: string | undefined) =>
6
+ [...authQueryKeys.user(userId), "multiSession"] as const,
7
+
8
+ lists: (userId: string | undefined) =>
9
+ [...multiSessionQueryKeys.all(userId), "list"] as const,
10
+
11
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
12
+ [...multiSessionQueryKeys.lists(userId), query ?? null] as const
13
+ } as const
@@ -0,0 +1,123 @@
1
+ export const organizationLocalization = {
2
+ /** @remarks `"Accept"` */
3
+ accept: "Accept",
4
+ /** @remarks `"Accepted"` */
5
+ accepted: "Accepted",
6
+ /** @remarks `"Actions"` */
7
+ actions: "Actions",
8
+ /** @remarks `"Admin"` */
9
+ admin: "Admin",
10
+ /** @remarks `"All"` */
11
+ all: "All",
12
+ /** @remarks `"Canceled"` */
13
+ canceled: "Canceled",
14
+ /** @remarks `"Cancel invitation"` */
15
+ cancelInvitation: "Cancel invitation",
16
+ /** @remarks `"Change logo"` */
17
+ changeLogo: "Change logo",
18
+ /** @remarks `"Change role"` */
19
+ changeMemberRole: "Change role",
20
+ /** @remarks `"Clear"` */
21
+ clear: "Clear",
22
+ /** @remarks `"Create organization"` */
23
+ createOrganization: "Create organization",
24
+ /** @remarks `"Delete logo"` */
25
+ deleteLogo: "Delete logo",
26
+ /** @remarks `"Delete organization"` */
27
+ deleteOrganization: "Delete organization",
28
+ /** @remarks `"Permanently delete this organization and all of its data. All members will lose access and this cannot be undone."` */
29
+ deleteOrganizationDescription:
30
+ "Permanently delete this organization and all of its data. All members will lose access and this cannot be undone.",
31
+ /** @remarks `"Invitations"` */
32
+ invitations: "Invitations",
33
+ /** @remarks `"Invited at"` */
34
+ invitedAt: "Invited at",
35
+ /** @remarks `"Invite member"` */
36
+ inviteMember: "Invite member",
37
+ /** @remarks `"Member invited successfully"` */
38
+ inviteMemberSuccess: "Member invited successfully",
39
+ /** @remarks `"We'll email them a link to join this organization. Choose the role they'll have once they accept."` */
40
+ inviteMemberDescription:
41
+ "We'll email them a link to join this organization. Choose the role they'll have once they accept.",
42
+ /** @remarks `"You left the organization"` */
43
+ leftOrganization: "You left the organization",
44
+ /** @remarks `"Leave organization"` */
45
+ leaveOrganization: "Leave organization",
46
+ /** @remarks `"Leave this organization and lose access to its data and resources. You'll need a new invitation to rejoin."` */
47
+ leaveOrganizationDescription:
48
+ "Leave this organization and lose access to its data and resources. You'll need a new invitation to rejoin.",
49
+ /** @remarks `"Logo"` */
50
+ logo: "Logo",
51
+ /** @remarks `"Logo updated successfully"` */
52
+ logoChangedSuccess: "Logo updated successfully",
53
+ /** @remarks `"Logo removed successfully"` */
54
+ logoDeletedSuccess: "Logo removed successfully",
55
+ /** @remarks `"Manage"` */
56
+ manage: "Manage",
57
+ /** @remarks `"Member"` */
58
+ member: "Member",
59
+ /** @remarks `"Member removed"` */
60
+ memberRemoved: "Member removed",
61
+ /** @remarks `"Member role updated"` */
62
+ memberRoleUpdated: "Member role updated",
63
+ /** @remarks `"Members"` */
64
+ members: "Members",
65
+ /** @remarks `"People"` */
66
+ people: "People",
67
+ /** @remarks `"Name"` */
68
+ name: "Name",
69
+ /** @remarks `"Enter the organization name"` */
70
+ namePlaceholder: "Enter the organization name",
71
+ /** @remarks `"No invitations"` */
72
+ noInvitations: "No invitations",
73
+ /** @remarks `"No organizations"` */
74
+ noOrganizations: "No organizations",
75
+ /** @remarks `"Organization"` */
76
+ organization: "Organization",
77
+ /** @remarks `"Organization deleted"` */
78
+ organizationDeleted: "Organization deleted",
79
+ /** @remarks `"Invite a teammate to collaborate in this organization."` */
80
+ organizationInvitationsEmptyDescription:
81
+ "Invite a teammate to collaborate in this organization.",
82
+ /** @remarks `"Organizations"` */
83
+ organizations: "Organizations",
84
+ /** @remarks `"Create an organization to collaborate with others and manage shared access."` */
85
+ organizationsDescription:
86
+ "Create an organization to collaborate with others and manage shared access.",
87
+ /** @remarks `"Organization profile"` */
88
+ organizationProfile: "Organization profile",
89
+ /** @remarks `"Organization updated successfully"` */
90
+ organizationUpdatedSuccess: "Organization updated successfully",
91
+ /** @remarks `"Owner"` */
92
+ owner: "Owner",
93
+ /** @remarks `"Pending"` */
94
+ pending: "Pending",
95
+ /** @remarks `"Personal account"` */
96
+ personalAccount: "Personal account",
97
+ /** @remarks `"Rejected"` */
98
+ rejected: "Rejected",
99
+ /** @remarks `"Reject invitation"` */
100
+ rejectInvitation: "Reject invitation",
101
+ /** @remarks `"Remove member"` */
102
+ removeMember: "Remove member",
103
+ /** @remarks `"Are you sure you want to remove this member from the organization? They will lose access immediately."` */
104
+ removeMemberWarning:
105
+ "Are you sure you want to remove this member from the organization? They will lose access immediately.",
106
+ /** @remarks `"Role"` */
107
+ role: "Role",
108
+ /** @remarks `"Search..."` */
109
+ search: "Search...",
110
+ /** @remarks `"Slug"` */
111
+ slug: "Slug",
112
+ /** @remarks `"organization-slug"` */
113
+ slugPlaceholder: "organization-slug",
114
+ /** @remarks `"Status"` */
115
+ status: "Status",
116
+ /** @remarks `"Upload logo"` */
117
+ uploadLogo: "Upload logo",
118
+ /** @remarks `"Invitations to join an organization will show up here."` */
119
+ userInvitationsEmptyDescription:
120
+ "Invitations to join an organization will show up here."
121
+ }
122
+
123
+ export type OrganizationLocalization = typeof organizationLocalization
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Hierarchical mutation key factory for organization-related mutations.
3
+ *
4
+ * Mutation keys are mostly used for `useIsMutating` and global
5
+ * `MutationCache` observers (e.g. toast handling), so the keys are static
6
+ * tuples rather than parameterised factories. Each grouping exposes an
7
+ * `all` prefix so consumers can match a whole feature at once:
8
+ *
9
+ * ```ts
10
+ * useIsMutating({ mutationKey: organizationMutationKeys.all })
11
+ * ```
12
+ */
13
+ export const organizationMutationKeys = {
14
+ /** Root key for every organization mutation. */
15
+ all: ["auth", "organization"] as const,
16
+
17
+ /** Key for `organization.create`. */
18
+ create: ["auth", "organization", "create"] as const,
19
+
20
+ /** Key for `organization.delete`. */
21
+ delete: ["auth", "organization", "delete"] as const,
22
+
23
+ /** Key for `organization.update`. */
24
+ update: ["auth", "organization", "update"] as const,
25
+
26
+ /** Key for `organization.setActive`. */
27
+ setActive: ["auth", "organization", "setActive"] as const,
28
+
29
+ /** Key for `organization.inviteMember`. */
30
+ inviteMember: ["auth", "organization", "inviteMember"] as const,
31
+
32
+ /** Key for `organization.removeMember`. */
33
+ removeMember: ["auth", "organization", "removeMember"] as const,
34
+
35
+ /** Key for `organization.leave`. */
36
+ leave: ["auth", "organization", "leave"] as const,
37
+
38
+ /** Key for `organization.updateMemberRole`. */
39
+ updateMemberRole: ["auth", "organization", "updateMemberRole"] as const,
40
+
41
+ /** Key for `organization.acceptInvitation`. */
42
+ acceptInvitation: ["auth", "organization", "acceptInvitation"] as const,
43
+
44
+ /** Key for `organization.cancelInvitation`. */
45
+ cancelInvitation: ["auth", "organization", "cancelInvitation"] as const,
46
+
47
+ /** Key for `organization.rejectInvitation` (invitee declines). */
48
+ rejectInvitation: ["auth", "organization", "rejectInvitation"] as const,
49
+
50
+ /** Key for `organization.checkSlug`. */
51
+ checkSlug: ["auth", "organization", "checkSlug"] as const
52
+ } as const
@@ -0,0 +1,112 @@
1
+ import { defaultAuthConfig } from "../../config"
2
+ import type { AvatarConfig } from "../../config/avatar-config"
3
+ import { createAuthPlugin } from "../../lib/create-auth-plugin"
4
+ import {
5
+ type OrganizationLocalization,
6
+ organizationLocalization
7
+ } from "./organization-localization"
8
+ import type { OrganizationViewPaths } from "./organization-view-paths"
9
+
10
+ declare module "../../lib/view-paths" {
11
+ /** Widens `SettingsViewPaths` by adding the `"organizations"` path when this plugin is imported. */
12
+ interface SettingsViewPaths {
13
+ /** @default "organizations" */
14
+ organizations?: string
15
+ }
16
+ }
17
+
18
+ declare module "../../lib/auth-plugin" {
19
+ interface AuthPluginViewPaths {
20
+ organization?: Partial<OrganizationViewPaths>
21
+ }
22
+ }
23
+
24
+ export type OrganizationPluginOptions = {
25
+ /**
26
+ * Whether to call `organization.checkSlug` when entering an organization slug.
27
+ * @default true
28
+ */
29
+ checkSlug?: boolean
30
+ /**
31
+ * Override the plugin's default localization strings.
32
+ * @remarks `OrganizationLocalization`
33
+ */
34
+ localization?: Partial<OrganizationLocalization>
35
+ /**
36
+ * Override URL segments contributed by this plugin.
37
+ *
38
+ * - `settings.organizations` — segment for the organizations settings view (default `"organizations"`).
39
+ * - `organization.settings` — segment for the `/organization/...` profile and danger zone tab (default `"settings"`).
40
+ * - `organization.people` — segment for the `/organization/...` members and invitations tab (default `"people"`).
41
+ */
42
+ viewPaths?: {
43
+ settings?: {
44
+ /** @default "organizations" */
45
+ organizations?: string
46
+ }
47
+ organization?: Partial<OrganizationViewPaths>
48
+ }
49
+ /**
50
+ * Organization logo upload, optimization, and deletion configuration.
51
+ * Same shape as {@link AvatarConfig} used for user avatars (`AuthConfig.avatar`).
52
+ * @remarks `AvatarConfig`
53
+ * @default { enabled: true, resize: resizeAvatar, size: 256, extension: "png" }
54
+ */
55
+ logo?: Partial<AvatarConfig>
56
+ /**
57
+ * Map of role keys to display labels. When omitted, defaults to localized
58
+ * labels for `owner`, `admin`, and `member` (from `localization.owner`
59
+ * etc.) plus {@link OrganizationPluginOptions.additionalRoles}. When set,
60
+ * replaces that default map entirely; use {@link OrganizationPluginOptions.additionalRoles}
61
+ * to add more labels on top. Looked up at render time via `roles?.[role]`.
62
+ * @remarks `Record<string, string>`
63
+ */
64
+ roles?: Record<string, string>
65
+ /**
66
+ * Extra role labels merged after the effective role map (either
67
+ * {@link OrganizationPluginOptions.roles} when provided, or the localized
68
+ * defaults). Use this for custom server roles without redefining built-in
69
+ * labels.
70
+ * @remarks `Record<string, string>`
71
+ */
72
+ additionalRoles?: Record<string, string>
73
+ slug?: string | null
74
+ }
75
+
76
+ export const organizationPlugin = createAuthPlugin(
77
+ "organization",
78
+ (options: OrganizationPluginOptions = {}) => {
79
+ const localization = {
80
+ ...organizationLocalization,
81
+ ...options.localization
82
+ }
83
+
84
+ return {
85
+ slug: options.slug,
86
+ checkSlug: options.checkSlug ?? true,
87
+ localization,
88
+ logo: {
89
+ ...defaultAuthConfig.avatar,
90
+ ...options.logo
91
+ },
92
+ roles: {
93
+ ...(options.roles ?? {
94
+ owner: localization.owner,
95
+ admin: localization.admin,
96
+ member: localization.member
97
+ }),
98
+ ...options.additionalRoles
99
+ },
100
+ viewPaths: {
101
+ settings: {
102
+ organizations:
103
+ options.viewPaths?.settings?.organizations ?? "organizations"
104
+ },
105
+ organization: {
106
+ settings: options.viewPaths?.organization?.settings ?? "settings",
107
+ people: options.viewPaths?.organization?.people ?? "people"
108
+ }
109
+ }
110
+ }
111
+ }
112
+ )
@@ -0,0 +1,86 @@
1
+ import { authQueryKeys } from "../../lib/auth-query-keys"
2
+
3
+ /** Query key factory for organization queries, scoped per user. */
4
+ export const organizationQueryKeys = {
5
+ all: (userId: string | undefined) =>
6
+ [...authQueryKeys.user(userId), "organization"] as const,
7
+
8
+ lists: (userId: string | undefined) =>
9
+ [...organizationQueryKeys.all(userId), "list"] as const,
10
+
11
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
12
+ [...organizationQueryKeys.lists(userId), query ?? null] as const,
13
+
14
+ fullDetails: (userId: string | undefined) =>
15
+ [...organizationQueryKeys.all(userId), "fullDetails"] as const,
16
+ fullDetail: <TQuery = undefined>(
17
+ userId: string | undefined,
18
+ query?: TQuery
19
+ ) => [...organizationQueryKeys.fullDetails(userId), query ?? null] as const,
20
+
21
+ /**
22
+ * Prefix for every active-organization cache entry (used for invalidation
23
+ * across slug-partitioned variants).
24
+ */
25
+ activeOrganizations: (userId: string | undefined) =>
26
+ [...organizationQueryKeys.all(userId), "active"] as const,
27
+ /**
28
+ * Cache entry for the currently active organization. Holds a {@link
29
+ * ListOrganization}-shaped value — distinct from `fullDetail`, which
30
+ * carries members and invitations — so `setActive`'s optimistic update
31
+ * (which can only produce a list-shaped org) doesn't corrupt the full
32
+ * cache.
33
+ */
34
+ activeOrganization: <TQuery = undefined>(
35
+ userId: string | undefined,
36
+ query?: TQuery
37
+ ) =>
38
+ [
39
+ ...organizationQueryKeys.activeOrganizations(userId),
40
+ query ?? null
41
+ ] as const,
42
+
43
+ members: {
44
+ all: (userId: string | undefined) =>
45
+ [...organizationQueryKeys.all(userId), "members"] as const,
46
+ lists: (userId: string | undefined) =>
47
+ [...organizationQueryKeys.members.all(userId), "list"] as const,
48
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
49
+ [...organizationQueryKeys.members.lists(userId), query ?? null] as const
50
+ },
51
+
52
+ invitations: {
53
+ all: (userId: string | undefined) =>
54
+ [...organizationQueryKeys.all(userId), "invitations"] as const,
55
+ lists: (userId: string | undefined) =>
56
+ [...organizationQueryKeys.invitations.all(userId), "list"] as const,
57
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
58
+ [
59
+ ...organizationQueryKeys.invitations.lists(userId),
60
+ query ?? null
61
+ ] as const
62
+ },
63
+
64
+ userInvitations: {
65
+ all: (userId: string | undefined) =>
66
+ [...organizationQueryKeys.all(userId), "userInvitations"] as const,
67
+ lists: (userId: string | undefined) =>
68
+ [...organizationQueryKeys.userInvitations.all(userId), "list"] as const,
69
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
70
+ [
71
+ ...organizationQueryKeys.userInvitations.lists(userId),
72
+ query ?? null
73
+ ] as const
74
+ },
75
+
76
+ permissions: {
77
+ all: (userId: string | undefined) =>
78
+ [...organizationQueryKeys.all(userId), "permissions"] as const,
79
+ has: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
80
+ [
81
+ ...organizationQueryKeys.permissions.all(userId),
82
+ "has",
83
+ query ?? null
84
+ ] as const
85
+ }
86
+ } as const
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Path segments under `/organization/...` contributed by `organizationPlugin`.
3
+ *
4
+ * Read at runtime via `useAuthPlugin(organizationPlugin).viewPaths.organization`.
5
+ */
6
+ export interface OrganizationViewPaths {
7
+ /**
8
+ * Path segment for organization profile and danger zone
9
+ * @default "settings"
10
+ */
11
+ settings: string
12
+ /**
13
+ * Path segment for members and invitations
14
+ * @default "people"
15
+ */
16
+ people: string
17
+ }
18
+
19
+ /** Valid organization management tab / route key. */
20
+ export type OrganizationView = keyof OrganizationViewPaths
@@ -0,0 +1,13 @@
1
+ import { authQueryKeys } from "../../lib/auth-query-keys"
2
+
3
+ /** Query key factory for passkey queries, scoped per user. */
4
+ export const passkeyQueryKeys = {
5
+ all: (userId: string | undefined) =>
6
+ [...authQueryKeys.user(userId), "passkey"] as const,
7
+
8
+ lists: (userId: string | undefined) =>
9
+ [...passkeyQueryKeys.all(userId), "list"] as const,
10
+
11
+ list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) =>
12
+ [...passkeyQueryKeys.lists(userId), query ?? null] as const
13
+ } as const
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Mutation keys contributed by the username plugin.
3
+ *
4
+ * `signIn` is kept under the shared `["auth", "signIn", ...]` namespace so
5
+ * consumers can match the whole sign-in surface with
6
+ * `useIsMutating({ mutationKey: ["auth", "signIn"] })`.
7
+ */
8
+ export const usernameMutationKeys = {
9
+ /** Key for `signIn.username`. */
10
+ signIn: ["auth", "signIn", "username"] as const,
11
+ /**
12
+ * Key for `isUsernameAvailable`. This is technically a read, but it's
13
+ * exposed via better-auth's mutation surface and lives under the mutation
14
+ * factories for parity with other username flows.
15
+ */
16
+ isUsernameAvailable: ["auth", "isUsernameAvailable"] as const
17
+ } as const
package/src/plugins.ts ADDED
@@ -0,0 +1,28 @@
1
+ export * from "./plugins/api-key/api-key-localization"
2
+ export * from "./plugins/api-key/api-key-mutation-keys"
3
+ export * from "./plugins/api-key/api-key-plugin"
4
+ export * from "./plugins/api-key/api-key-query-keys"
5
+ export * from "./plugins/delete-user/delete-user-localization"
6
+ export * from "./plugins/delete-user/delete-user-mutation-keys"
7
+ export * from "./plugins/delete-user/delete-user-plugin"
8
+ export * from "./plugins/magic-link/magic-link-localization"
9
+ export * from "./plugins/magic-link/magic-link-mutation-keys"
10
+ export * from "./plugins/magic-link/magic-link-plugin"
11
+ export * from "./plugins/multi-session/multi-session-localization"
12
+ export * from "./plugins/multi-session/multi-session-mutation-keys"
13
+ export * from "./plugins/multi-session/multi-session-plugin"
14
+ export * from "./plugins/multi-session/multi-session-query-keys"
15
+ export * from "./plugins/organization/organization-localization"
16
+ export * from "./plugins/organization/organization-mutation-keys"
17
+ export * from "./plugins/organization/organization-plugin"
18
+ export * from "./plugins/organization/organization-query-keys"
19
+ export * from "./plugins/organization/organization-view-paths"
20
+ export * from "./plugins/passkey/passkey-localization"
21
+ export * from "./plugins/passkey/passkey-mutation-keys"
22
+ export * from "./plugins/passkey/passkey-plugin"
23
+ export * from "./plugins/passkey/passkey-query-keys"
24
+ export * from "./plugins/theme/theme-localization"
25
+ export * from "./plugins/theme/theme-plugin"
26
+ export * from "./plugins/username/username-localization"
27
+ export * from "./plugins/username/username-mutation-keys"
28
+ export * from "./plugins/username/username-plugin"
@@ -1,27 +0,0 @@
1
- //#region src/config/additional-fields-config.ts
2
- function e(e, t) {
3
- if (e.type === "boolean") return t === "on" || t === "true";
4
- if (t != null) {
5
- if (t === "") return null;
6
- if (e.type === "number") {
7
- let e = Number(t);
8
- return Number.isNaN(e) ? void 0 : e;
9
- }
10
- if (e.type === "date") {
11
- let e = new Date(t);
12
- return Number.isNaN(e.getTime()) ? void 0 : e;
13
- }
14
- return t;
15
- }
16
- }
17
- function t(e) {
18
- if (e.inputType) return e.inputType;
19
- switch (e.type) {
20
- case "number": return "number";
21
- case "boolean": return "switch";
22
- case "date": return "date";
23
- default: return "input";
24
- }
25
- }
26
- //#endregion
27
- export { e as parseAdditionalFieldValue, t as resolveInputType };
@@ -1,32 +0,0 @@
1
- import { basePaths as e } from "../lib/base-paths.js";
2
- import { localization as t } from "../lib/localization.js";
3
- import { resizeAvatar as n } from "../lib/utils.js";
4
- import { viewPaths as r } from "../lib/view-paths.js";
5
- //#region src/config/auth-config.ts
6
- var i = {
7
- avatar: {
8
- enabled: !0,
9
- resize: n,
10
- size: 256,
11
- extension: "png"
12
- },
13
- basePaths: e,
14
- baseURL: "",
15
- emailAndPassword: {
16
- enabled: !0,
17
- forgotPassword: !0,
18
- name: !0,
19
- rememberMe: !1,
20
- minPasswordLength: 8,
21
- maxPasswordLength: 128
22
- },
23
- plugins: [],
24
- redirectTo: "/",
25
- viewPaths: r,
26
- localization: t,
27
- navigate: ({ to: e, replace: t }) => {
28
- t ? window.location.replace(e) : window.location.href = e;
29
- }
30
- };
31
- //#endregion
32
- export { i as defaultAuthConfig };