@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
package/dist/plugins.js CHANGED
@@ -1,18 +1,360 @@
1
- import { apiKeyLocalization as e } from "./plugins/api-key/api-key-localization.js";
2
- import { apiKeyMutationKeys as t } from "./plugins/api-key/api-key-mutation-keys.js";
3
- import { apiKeyPlugin as n } from "./plugins/api-key/api-key-plugin.js";
4
- import { deleteUserLocalization as r } from "./plugins/delete-user/delete-user-localization.js";
5
- import { deleteUserPlugin as i } from "./plugins/delete-user/delete-user-plugin.js";
6
- import { magicLinkLocalization as a } from "./plugins/magic-link/magic-link-localization.js";
7
- import { magicLinkMutationKeys as o } from "./plugins/magic-link/magic-link-mutation-keys.js";
8
- import { magicLinkPlugin as s } from "./plugins/magic-link/magic-link-plugin.js";
9
- import { multiSessionLocalization as c } from "./plugins/multi-session/multi-session-localization.js";
10
- import { multiSessionPlugin as l } from "./plugins/multi-session/multi-session-plugin.js";
11
- import { passkeyLocalization as u } from "./plugins/passkey/passkey-localization.js";
12
- import { passkeyMutationKeys as d } from "./plugins/passkey/passkey-mutation-keys.js";
13
- import { passkeyPlugin as f } from "./plugins/passkey/passkey-plugin.js";
14
- import { themeLocalization as p } from "./plugins/theme/theme-localization.js";
15
- import { themePlugin as m } from "./plugins/theme/theme-plugin.js";
16
- import { usernameLocalization as h } from "./plugins/username/username-localization.js";
17
- import { usernamePlugin as g } from "./plugins/username/username-plugin.js";
18
- export { e as apiKeyLocalization, t as apiKeyMutationKeys, n as apiKeyPlugin, r as deleteUserLocalization, i as deleteUserPlugin, a as magicLinkLocalization, o as magicLinkMutationKeys, s as magicLinkPlugin, c as multiSessionLocalization, l as multiSessionPlugin, u as passkeyLocalization, d as passkeyMutationKeys, f as passkeyPlugin, p as themeLocalization, m as themePlugin, h as usernameLocalization, g as usernamePlugin };
1
+ import { n as e, r as t, t as n } from "./create-auth-plugin-CnH7jMHA.js";
2
+ //#region src/plugins/api-key/api-key-localization.ts
3
+ var r = {
4
+ apiKey: "API key",
5
+ apiKeys: "API keys",
6
+ apiKeysDescription: "Create an API key for programmatic access to your account.",
7
+ createApiKey: "Create API key",
8
+ noApiKeys: "No API keys",
9
+ name: "Name",
10
+ newApiKey: "New API key",
11
+ newApiKeyWarning: "This is the only time you'll see this API key. Copy and store it somewhere safe.",
12
+ deleteApiKey: "Delete API key",
13
+ deleteApiKeyWarning: "This action cannot be undone. Any service using this API key will stop working immediately.",
14
+ dismissNewKey: "I've saved my key"
15
+ }, i = {
16
+ all: ["auth", "apiKey"],
17
+ create: [
18
+ "auth",
19
+ "apiKey",
20
+ "create"
21
+ ],
22
+ delete: [
23
+ "auth",
24
+ "apiKey",
25
+ "delete"
26
+ ]
27
+ }, a = n("apiKey", (e = {}) => ({
28
+ localization: {
29
+ ...r,
30
+ ...e.localization
31
+ },
32
+ organization: e.organization ?? !1
33
+ })), o = {
34
+ all: (t) => [...e.user(t), "apiKey"],
35
+ lists: (e) => [...o.all(e), "list"],
36
+ list: (e, t) => [...o.lists(e), t ?? null]
37
+ }, s = {
38
+ deleteAccount: "Delete account",
39
+ deleteAccountDescription: "Permanently remove your account and all associated data. This cannot be undone.",
40
+ deleteUserVerificationSent: "Check your email to confirm account deletion.",
41
+ deleteUserSuccess: "Your account has been deleted."
42
+ }, c = { deleteUser: ["auth", "deleteUser"] }, l = n("deleteUser", (e = {}) => ({
43
+ localization: {
44
+ ...s,
45
+ ...e.localization
46
+ },
47
+ sendDeleteAccountVerification: e.sendDeleteAccountVerification ?? !1
48
+ })), u = {
49
+ magicLink: "Magic Link",
50
+ sendMagicLink: "Send Magic Link",
51
+ magicLinkSent: "Check your email for the magic link"
52
+ }, d = { signIn: [
53
+ "auth",
54
+ "signIn",
55
+ "magicLink"
56
+ ] }, f = n("magicLink", (e = {}) => ({
57
+ localization: {
58
+ ...u,
59
+ ...e.localization
60
+ },
61
+ viewPaths: { auth: { magicLink: e.path ?? "magic-link" } }
62
+ })), p = {
63
+ switchAccount: "Switch Account",
64
+ addAccount: "Add Account",
65
+ manageAccounts: "Manage accounts",
66
+ manageAccountsDescription: "Manage your accounts for secure access."
67
+ }, m = {
68
+ all: ["auth", "multiSession"],
69
+ revoke: [
70
+ "auth",
71
+ "multiSession",
72
+ "revoke"
73
+ ],
74
+ setActive: [
75
+ "auth",
76
+ "multiSession",
77
+ "setActive"
78
+ ]
79
+ }, h = n("multiSession", (e = {}) => ({ localization: {
80
+ ...p,
81
+ ...e.localization
82
+ } })), g = {
83
+ all: (t) => [...e.user(t), "multiSession"],
84
+ lists: (e) => [...g.all(e), "list"],
85
+ list: (e, t) => [...g.lists(e), t ?? null]
86
+ }, _ = {
87
+ accept: "Accept",
88
+ accepted: "Accepted",
89
+ actions: "Actions",
90
+ admin: "Admin",
91
+ all: "All",
92
+ canceled: "Canceled",
93
+ cancelInvitation: "Cancel invitation",
94
+ changeLogo: "Change logo",
95
+ changeMemberRole: "Change role",
96
+ clear: "Clear",
97
+ createOrganization: "Create organization",
98
+ deleteLogo: "Delete logo",
99
+ deleteOrganization: "Delete organization",
100
+ deleteOrganizationDescription: "Permanently delete this organization and all of its data. All members will lose access and this cannot be undone.",
101
+ invitations: "Invitations",
102
+ invitedAt: "Invited at",
103
+ inviteMember: "Invite member",
104
+ inviteMemberSuccess: "Member invited successfully",
105
+ inviteMemberDescription: "We'll email them a link to join this organization. Choose the role they'll have once they accept.",
106
+ leftOrganization: "You left the organization",
107
+ leaveOrganization: "Leave organization",
108
+ leaveOrganizationDescription: "Leave this organization and lose access to its data and resources. You'll need a new invitation to rejoin.",
109
+ logo: "Logo",
110
+ logoChangedSuccess: "Logo updated successfully",
111
+ logoDeletedSuccess: "Logo removed successfully",
112
+ manage: "Manage",
113
+ member: "Member",
114
+ memberRemoved: "Member removed",
115
+ memberRoleUpdated: "Member role updated",
116
+ members: "Members",
117
+ people: "People",
118
+ name: "Name",
119
+ namePlaceholder: "Enter the organization name",
120
+ noInvitations: "No invitations",
121
+ noOrganizations: "No organizations",
122
+ organization: "Organization",
123
+ organizationDeleted: "Organization deleted",
124
+ organizationInvitationsEmptyDescription: "Invite a teammate to collaborate in this organization.",
125
+ organizations: "Organizations",
126
+ organizationsDescription: "Create an organization to collaborate with others and manage shared access.",
127
+ organizationProfile: "Organization profile",
128
+ organizationUpdatedSuccess: "Organization updated successfully",
129
+ owner: "Owner",
130
+ pending: "Pending",
131
+ personalAccount: "Personal account",
132
+ rejected: "Rejected",
133
+ rejectInvitation: "Reject invitation",
134
+ removeMember: "Remove member",
135
+ removeMemberWarning: "Are you sure you want to remove this member from the organization? They will lose access immediately.",
136
+ role: "Role",
137
+ search: "Search...",
138
+ slug: "Slug",
139
+ slugPlaceholder: "organization-slug",
140
+ status: "Status",
141
+ uploadLogo: "Upload logo",
142
+ userInvitationsEmptyDescription: "Invitations to join an organization will show up here."
143
+ }, v = {
144
+ all: ["auth", "organization"],
145
+ create: [
146
+ "auth",
147
+ "organization",
148
+ "create"
149
+ ],
150
+ delete: [
151
+ "auth",
152
+ "organization",
153
+ "delete"
154
+ ],
155
+ update: [
156
+ "auth",
157
+ "organization",
158
+ "update"
159
+ ],
160
+ setActive: [
161
+ "auth",
162
+ "organization",
163
+ "setActive"
164
+ ],
165
+ inviteMember: [
166
+ "auth",
167
+ "organization",
168
+ "inviteMember"
169
+ ],
170
+ removeMember: [
171
+ "auth",
172
+ "organization",
173
+ "removeMember"
174
+ ],
175
+ leave: [
176
+ "auth",
177
+ "organization",
178
+ "leave"
179
+ ],
180
+ updateMemberRole: [
181
+ "auth",
182
+ "organization",
183
+ "updateMemberRole"
184
+ ],
185
+ acceptInvitation: [
186
+ "auth",
187
+ "organization",
188
+ "acceptInvitation"
189
+ ],
190
+ cancelInvitation: [
191
+ "auth",
192
+ "organization",
193
+ "cancelInvitation"
194
+ ],
195
+ rejectInvitation: [
196
+ "auth",
197
+ "organization",
198
+ "rejectInvitation"
199
+ ],
200
+ checkSlug: [
201
+ "auth",
202
+ "organization",
203
+ "checkSlug"
204
+ ]
205
+ }, y = n("organization", (e = {}) => {
206
+ let n = {
207
+ ..._,
208
+ ...e.localization
209
+ };
210
+ return {
211
+ slug: e.slug,
212
+ checkSlug: e.checkSlug ?? !0,
213
+ localization: n,
214
+ logo: {
215
+ ...t.avatar,
216
+ ...e.logo
217
+ },
218
+ roles: {
219
+ ...e.roles ?? {
220
+ owner: n.owner,
221
+ admin: n.admin,
222
+ member: n.member
223
+ },
224
+ ...e.additionalRoles
225
+ },
226
+ viewPaths: {
227
+ settings: { organizations: e.viewPaths?.settings?.organizations ?? "organizations" },
228
+ organization: {
229
+ settings: e.viewPaths?.organization?.settings ?? "settings",
230
+ people: e.viewPaths?.organization?.people ?? "people"
231
+ }
232
+ }
233
+ };
234
+ }), b = {
235
+ all: (t) => [...e.user(t), "organization"],
236
+ lists: (e) => [...b.all(e), "list"],
237
+ list: (e, t) => [...b.lists(e), t ?? null],
238
+ fullDetails: (e) => [...b.all(e), "fullDetails"],
239
+ fullDetail: (e, t) => [...b.fullDetails(e), t ?? null],
240
+ activeOrganizations: (e) => [...b.all(e), "active"],
241
+ activeOrganization: (e, t) => [...b.activeOrganizations(e), t ?? null],
242
+ members: {
243
+ all: (e) => [...b.all(e), "members"],
244
+ lists: (e) => [...b.members.all(e), "list"],
245
+ list: (e, t) => [...b.members.lists(e), t ?? null]
246
+ },
247
+ invitations: {
248
+ all: (e) => [...b.all(e), "invitations"],
249
+ lists: (e) => [...b.invitations.all(e), "list"],
250
+ list: (e, t) => [...b.invitations.lists(e), t ?? null]
251
+ },
252
+ userInvitations: {
253
+ all: (e) => [...b.all(e), "userInvitations"],
254
+ lists: (e) => [...b.userInvitations.all(e), "list"],
255
+ list: (e, t) => [...b.userInvitations.lists(e), t ?? null]
256
+ },
257
+ permissions: {
258
+ all: (e) => [...b.all(e), "permissions"],
259
+ has: (e, t) => [
260
+ ...b.permissions.all(e),
261
+ "has",
262
+ t ?? null
263
+ ]
264
+ }
265
+ }, x = {
266
+ passkey: "Passkey",
267
+ addPasskey: "Add passkey",
268
+ deletePasskey: "Delete passkey {{name}}",
269
+ deletePasskeyTitle: "Delete passkey",
270
+ deletePasskeyWarning: "This action cannot be undone. You will need to add this passkey again before you can use it to sign in.",
271
+ passkeys: "Passkeys",
272
+ passkeysDescription: "Create a passkey to securely access your account.",
273
+ noPasskeys: "No passkeys",
274
+ name: "Name"
275
+ }, S = {
276
+ signIn: [
277
+ "auth",
278
+ "signIn",
279
+ "passkey"
280
+ ],
281
+ addPasskey: [
282
+ "auth",
283
+ "passkey",
284
+ "addPasskey"
285
+ ],
286
+ deletePasskey: [
287
+ "auth",
288
+ "passkey",
289
+ "deletePasskey"
290
+ ]
291
+ }, C = n("passkey", (e = {}) => ({ localization: {
292
+ ...x,
293
+ ...e.localization
294
+ } })), w = {
295
+ all: (t) => [...e.user(t), "passkey"],
296
+ lists: (e) => [...w.all(e), "list"],
297
+ list: (e, t) => [...w.lists(e), t ?? null]
298
+ }, T = {
299
+ appearance: "Appearance",
300
+ theme: "Theme",
301
+ system: "System",
302
+ light: "Light",
303
+ dark: "Dark"
304
+ }, E = n("theme", (e) => ({
305
+ localization: {
306
+ ...T,
307
+ ...e.localization
308
+ },
309
+ theme: e.theme ?? "system",
310
+ setTheme: e.setTheme,
311
+ themes: e.themes ?? [
312
+ "system",
313
+ "light",
314
+ "dark"
315
+ ]
316
+ })), D = {
317
+ username: "Username",
318
+ usernamePlaceholder: "Enter your username",
319
+ usernameOrEmailPlaceholder: "Enter your username or email",
320
+ usernameAvailable: "Username is available",
321
+ usernameTaken: "Username is already taken. Please try another.",
322
+ displayUsername: "Display Username",
323
+ displayUsernamePlaceholder: "Enter your display username"
324
+ }, O = {
325
+ signIn: [
326
+ "auth",
327
+ "signIn",
328
+ "username"
329
+ ],
330
+ isUsernameAvailable: ["auth", "isUsernameAvailable"]
331
+ }, k = n("username", (e = {}) => {
332
+ let t = e.minUsernameLength ?? 3, n = e.maxUsernameLength ?? 30, r = {
333
+ ...D,
334
+ ...e.localization
335
+ };
336
+ return {
337
+ ...e,
338
+ minUsernameLength: t,
339
+ maxUsernameLength: n,
340
+ localization: r,
341
+ additionalFields: [{
342
+ name: "username",
343
+ type: "string",
344
+ label: r.username,
345
+ placeholder: r.usernamePlaceholder,
346
+ inputType: "input",
347
+ signUp: "above",
348
+ required: !0
349
+ }, ...e.displayUsername ? [{
350
+ name: "displayUsername",
351
+ type: "string",
352
+ label: r.displayUsername,
353
+ placeholder: r.displayUsernamePlaceholder,
354
+ inputType: "input",
355
+ signUp: "above"
356
+ }] : []]
357
+ };
358
+ });
359
+ //#endregion
360
+ export { r as apiKeyLocalization, i as apiKeyMutationKeys, a as apiKeyPlugin, o as apiKeyQueryKeys, s as deleteUserLocalization, c as deleteUserMutationKeys, l as deleteUserPlugin, u as magicLinkLocalization, d as magicLinkMutationKeys, f as magicLinkPlugin, p as multiSessionLocalization, m as multiSessionMutationKeys, h as multiSessionPlugin, g as multiSessionQueryKeys, _ as organizationLocalization, v as organizationMutationKeys, y as organizationPlugin, b as organizationQueryKeys, x as passkeyLocalization, S as passkeyMutationKeys, C as passkeyPlugin, w as passkeyQueryKeys, T as themeLocalization, E as themePlugin, D as usernameLocalization, O as usernameMutationKeys, k as usernamePlugin };
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@better-auth-ui/core",
3
- "version": "1.6.8",
3
+ "version": "1.6.10",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
7
- "dev": "tsc --watch",
8
7
  "test": "vitest"
9
8
  },
10
9
  "files": [
@@ -15,20 +14,22 @@
15
14
  "types": "./dist/index.d.ts",
16
15
  "exports": {
17
16
  ".": {
17
+ "development": "./src/index.ts",
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js"
20
20
  },
21
21
  "./plugins": {
22
- "types": "./dist/plugins/index.d.ts",
22
+ "development": "./src/plugins.ts",
23
+ "types": "./dist/plugins.d.ts",
23
24
  "import": "./dist/plugins.js"
24
25
  }
25
26
  },
26
27
  "devDependencies": {
27
- "better-auth": "^1.6.10",
28
- "vitest": "^4.1.5"
28
+ "better-auth": "^1.6.11",
29
+ "vitest": "^4.1.7"
29
30
  },
30
31
  "peerDependencies": {
31
- "better-auth": ">=1.6.10"
32
+ "better-auth": ">=1.6.11"
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
@@ -82,7 +82,7 @@ export interface AuthConfig {
82
82
  navigate: (options: { to: string; replace?: boolean }) => void
83
83
  }
84
84
 
85
- export const defaultAuthConfig: AuthConfig = {
85
+ export const defaultAuthConfig: Omit<AuthConfig, "authClient"> = {
86
86
  avatar: {
87
87
  enabled: true,
88
88
  resize: resizeAvatar,
@@ -18,6 +18,14 @@
18
18
  * etc.) — the mutation cache entries line up regardless of which framework
19
19
  * package the mutation options factory came from.
20
20
  *
21
+ * Plugin-specific mutation keys live alongside their plugin (e.g.
22
+ * `apiKeyMutationKeys`, `organizationMutationKeys`, `passkeyMutationKeys`,
23
+ * `magicLinkMutationKeys`, `multiSessionMutationKeys`, `usernameMutationKeys`,
24
+ * `deleteUserMutationKeys`). Plugin-contributed sign-in strategies stay
25
+ * under the shared `["auth", "signIn", ...]` namespace so
26
+ * `useIsMutating({ mutationKey: authMutationKeys.signIn.all })` still
27
+ * matches them.
28
+ *
21
29
  * For query keys, see `authQueryKeys` in `./auth-query-keys`.
22
30
  */
23
31
  export const authMutationKeys = {
@@ -26,14 +34,12 @@ export const authMutationKeys = {
26
34
 
27
35
  /** Sign-in mutations, grouped by strategy. */
28
36
  signIn: {
29
- /** Prefix matching every sign-in mutation. */
37
+ /** Prefix matching every sign-in mutation (including plugin strategies). */
30
38
  all: ["auth", "signIn"] as const,
31
39
  /** Key for `signIn.email`. */
32
40
  email: ["auth", "signIn", "email"] as const,
33
41
  /** Key for `signIn.social`. */
34
- social: ["auth", "signIn", "social"] as const,
35
- /** Key for `signIn.username`. */
36
- username: ["auth", "signIn", "username"] as const
42
+ social: ["auth", "signIn", "social"] as const
37
43
  },
38
44
 
39
45
  /** Sign-up mutations, grouped by strategy. */
@@ -54,22 +60,10 @@ export const authMutationKeys = {
54
60
  /** Key for `sendVerificationEmail`. */
55
61
  sendVerificationEmail: ["auth", "sendVerificationEmail"] as const,
56
62
 
57
- /** Multi-session mutations. */
58
- multiSession: {
59
- /** Prefix matching every multi-session mutation. */
60
- all: ["auth", "multiSession"] as const,
61
- /** Key for `multiSession.revoke`. */
62
- revoke: ["auth", "multiSession", "revoke"] as const,
63
- /** Key for `multiSession.setActive`. */
64
- setActive: ["auth", "multiSession", "setActive"] as const
65
- },
66
-
67
63
  /** Key for `changeEmail`. */
68
64
  changeEmail: ["auth", "changeEmail"] as const,
69
65
  /** Key for `changePassword`. */
70
66
  changePassword: ["auth", "changePassword"] as const,
71
- /** Key for `deleteUser`. */
72
- deleteUser: ["auth", "deleteUser"] as const,
73
67
  /** Key for `linkSocial`. */
74
68
  linkSocial: ["auth", "linkSocial"] as const,
75
69
  /** Key for `revokeSession`. */
@@ -77,12 +71,5 @@ export const authMutationKeys = {
77
71
  /** Key for `unlinkAccount`. */
78
72
  unlinkAccount: ["auth", "unlinkAccount"] as const,
79
73
  /** Key for `updateUser`. */
80
- updateUser: ["auth", "updateUser"] as const,
81
-
82
- /**
83
- * Key for `isUsernameAvailable`. This is technically a read, but it's
84
- * exposed via better-auth's mutation surface and lives under the mutation
85
- * factories for parity with other username flows.
86
- */
87
- isUsernameAvailable: ["auth", "isUsernameAvailable"] as const
74
+ updateUser: ["auth", "updateUser"] as const
88
75
  } as const
@@ -6,8 +6,11 @@ import type { AdditionalFields } from "../config/additional-fields-config"
6
6
  * Plugins that add routable sub-pages (e.g. `magicLinkPlugin` adds
7
7
  * `/auth/magic-link`) declare the URL segment under the matching section.
8
8
  * Read at runtime via `useAuthPlugin(plugin).viewPaths.*`.
9
+ *
10
+ * Plugin-specific namespaces (e.g. organization route segments) are merged
11
+ * via module augmentation from that plugin’s module — not declared here.
9
12
  */
10
- export type AuthPluginViewPaths = {
13
+ export interface AuthPluginViewPaths {
11
14
  auth?: Record<string, string>
12
15
  settings?: Record<string, string>
13
16
  }
@@ -34,10 +37,6 @@ export interface AuthPluginBase {
34
37
  * user-defined additionalFields in the auth config.
35
38
  */
36
39
  additionalFields?: AdditionalFields
37
- /**
38
- * Additional properties contributed by the plugin.
39
- */
40
- [key: string]: unknown
41
40
  }
42
41
 
43
42
  /**
@@ -16,6 +16,12 @@
16
16
  * etc.) and across client- and server-side query variants — the cache
17
17
  * entries line up regardless of which query options factory produced them.
18
18
  *
19
+ * Plugin-specific query keys live alongside their plugin (e.g.
20
+ * `apiKeyQueryKeys`, `organizationQueryKeys`, `passkeyQueryKeys`,
21
+ * `multiSessionQueryKeys`) and chain off `authQueryKeys.user(userId)` so
22
+ * everything still sits under the shared `["auth", "user", userId, ...]`
23
+ * subtree.
24
+ *
19
25
  * For mutation keys, see `authMutationKeys` in `./auth-mutation-keys`.
20
26
  */
21
27
  export const authQueryKeys = {
@@ -31,29 +37,6 @@ export const authQueryKeys = {
31
37
  user: (userId: string | undefined) =>
32
38
  [...authQueryKeys.users(), userId] as const,
33
39
 
34
- /** Key for `multiSession.listDeviceSessions` for the given user. */
35
- listDeviceSessions: <TQuery = undefined>(
36
- userId: string | undefined,
37
- query?: TQuery
38
- ) =>
39
- [
40
- ...authQueryKeys.user(userId),
41
- "listDeviceSessions",
42
- query ?? null
43
- ] as const,
44
-
45
- /** Key for the user's passkey list. */
46
- listPasskeys: <TQuery = undefined>(
47
- userId: string | undefined,
48
- query?: TQuery
49
- ) => [...authQueryKeys.user(userId), "listPasskeys", query ?? null] as const,
50
-
51
- /** Key for the user's API keys list (`apiKey.list`). */
52
- listApiKeys: <TQuery = undefined>(
53
- userId: string | undefined,
54
- query?: TQuery
55
- ) => [...authQueryKeys.user(userId), "listApiKeys", query ?? null] as const,
56
-
57
40
  /** Key for `accountInfo` for the given user. */
58
41
  accountInfo: <TQuery = undefined>(
59
42
  userId: string | undefined,
@@ -1,47 +1,30 @@
1
+ import type { AuthPlugin } from "./auth-plugin"
2
+
1
3
  /**
2
- * Creates a plugin factory and attaches its `id` as a static property.
3
- *
4
- * Lifts the plugin's `id` out of the factory's runtime output so consumers
5
- * (e.g. `useAuthPlugin`) can read it without invoking the factory. This lets
6
- * plugins keep required options (like `themePlugin`'s `setTheme`) without
7
- * forcing every factory to be callable with zero arguments.
8
- *
9
- * The returned factory:
10
- * - is callable with the original arguments and returns the factory's result
11
- * merged with `{ id }`
12
- * - exposes `id` as a static property so it can be read at registration or
13
- * lookup time without allocating a plugin instance
14
- *
15
- * Type safety for the plugin's shape is enforced at the registration site
16
- * (`<AuthProvider plugins={[…]} />`) where `plugins` is typed as `AuthPlugin[]`.
4
+ * Creates a plugin factory and attaches its `id` as a static property so
5
+ * consumers (e.g. `useAuthPlugin`) can look it up without invoking the
6
+ * factory.
17
7
  *
18
8
  * @example
19
9
  * ```ts
20
10
  * export const themePlugin = createAuthPlugin(
21
11
  * "theme",
22
12
  * (options: ThemePluginOptions) => ({
23
- * localization: { ...themeLocalization, ...options.localization },
24
- * theme: options.theme ?? "system",
25
13
  * setTheme: options.setTheme,
26
14
  * themes: options.themes ?? ["system", "light", "dark"]
27
15
  * })
28
16
  * )
29
- *
30
- * themePlugin.id // "theme"
31
- * themePlugin({ setTheme }) // { id: "theme", localization, theme, setTheme, themes }
32
17
  * ```
33
18
  */
34
19
  export function createAuthPlugin<
35
20
  const TId extends string,
36
21
  TArgs extends unknown[],
37
- TResult extends object
38
- >(
39
- id: TId,
40
- factory: (...args: TArgs) => TResult
41
- ): ((...args: TArgs) => Omit<TResult, "id"> & { id: TId }) & { id: TId } {
42
- const wrapped = (...args: TArgs): Omit<TResult, "id"> & { id: TId } => ({
22
+ TResult extends Omit<AuthPlugin, "id"> & object
23
+ >(id: TId, factory: (...args: TArgs) => TResult) {
24
+ const wrapped = (...args: TArgs) => ({
43
25
  ...factory(...args),
44
26
  id
45
27
  })
28
+
46
29
  return Object.assign(wrapped, { id })
47
30
  }
@@ -172,9 +172,6 @@ export const localization = {
172
172
  /** @remarks `"Optional"` */
173
173
  optional: "Optional",
174
174
 
175
- /** @remarks `"Profile"` */
176
- profile: "Profile",
177
-
178
175
  /** @remarks `"Profile updated successfully"` */
179
176
  profileUpdatedSuccess: "Profile updated successfully",
180
177
 
@@ -216,7 +213,10 @@ export const localization = {
216
213
  updatePassword: "Update password",
217
214
 
218
215
  /** @remarks `"Upload avatar"` */
219
- uploadAvatar: "Upload avatar"
216
+ uploadAvatar: "Upload avatar",
217
+
218
+ /** @remarks `"User profile"` */
219
+ userProfile: "User profile"
220
220
  }
221
221
  }
222
222
 
@@ -1,9 +1,5 @@
1
1
  /**
2
2
  * View path segments for authentication routes.
3
- *
4
- * Contains the fixed built-ins every install ships with. Plugin-contributed
5
- * paths (e.g. `magicLinkPlugin`'s `magicLink`) live on the plugin object and
6
- * are read via `useAuthPlugin(plugin).viewPaths.auth.*`.
7
3
  */
8
4
  export interface AuthViewPaths {
9
5
  /**
@@ -2,8 +2,10 @@
2
2
  * Mutation keys contributed by the API key plugin.
3
3
  */
4
4
  export const apiKeyMutationKeys = {
5
+ /** Root key for every api key mutation. */
6
+ all: ["auth", "apiKey"] as const,
5
7
  /** Key for `apiKey.create`. */
6
- createApiKey: ["auth", "apiKey", "create"] as const,
8
+ create: ["auth", "apiKey", "create"] as const,
7
9
  /** Key for `apiKey.delete`. */
8
- deleteApiKey: ["auth", "apiKey", "delete"] as const
10
+ delete: ["auth", "apiKey", "delete"] as const
9
11
  } as const