@better-auth-ui/core 1.6.8 → 1.6.9

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 (102) hide show
  1. package/dist/config/additional-fields-config.js +37 -25
  2. package/dist/config/auth-config.d.ts +9 -9
  3. package/dist/config/auth-config.js +33 -31
  4. package/dist/config/avatar-config.js +1 -0
  5. package/dist/config/email-and-password-config.js +1 -0
  6. package/dist/config/index.d.ts +4 -4
  7. package/dist/config/index.js +4 -0
  8. package/dist/index.d.ts +11 -11
  9. package/dist/index.js +11 -11
  10. package/dist/lib/auth-mutation-keys.d.ts +9 -20
  11. package/dist/lib/auth-mutation-keys.js +69 -56
  12. package/dist/lib/auth-plugin.d.ts +6 -7
  13. package/dist/lib/auth-plugin.js +1 -0
  14. package/dist/lib/auth-query-keys.d.ts +6 -6
  15. package/dist/lib/auth-query-keys.js +41 -38
  16. package/dist/lib/base-paths.js +4 -7
  17. package/dist/lib/create-auth-plugin.d.ts +5 -21
  18. package/dist/lib/create-auth-plugin.js +22 -8
  19. package/dist/lib/deep-partial.js +1 -0
  20. package/dist/lib/localization.d.ts +2 -2
  21. package/dist/lib/localization.js +149 -80
  22. package/dist/lib/provider-names.d.ts +1 -1
  23. package/dist/lib/provider-names.js +48 -41
  24. package/dist/lib/utils.d.ts +1 -1
  25. package/dist/lib/utils.js +111 -43
  26. package/dist/lib/view-paths.d.ts +0 -4
  27. package/dist/lib/view-paths.js +12 -15
  28. package/dist/plugins/api-key/api-key-localization.js +23 -15
  29. package/dist/plugins/api-key/api-key-mutation-keys.d.ts +4 -2
  30. package/dist/plugins/api-key/api-key-mutation-keys.js +10 -14
  31. package/dist/plugins/api-key/api-key-plugin.d.ts +24 -3
  32. package/dist/plugins/api-key/api-key-plugin.js +6 -9
  33. package/dist/plugins/api-key/api-key-query-keys.d.ts +6 -0
  34. package/dist/plugins/api-key/api-key-query-keys.js +7 -0
  35. package/dist/plugins/delete-user/delete-user-localization.d.ts +3 -3
  36. package/dist/plugins/delete-user/delete-user-localization.js +9 -8
  37. package/dist/plugins/delete-user/delete-user-mutation-keys.d.ts +7 -0
  38. package/dist/plugins/delete-user/delete-user-mutation-keys.js +7 -0
  39. package/dist/plugins/delete-user/delete-user-plugin.d.ts +5 -5
  40. package/dist/plugins/delete-user/delete-user-plugin.js +5 -11
  41. package/dist/plugins/magic-link/magic-link-localization.js +7 -7
  42. package/dist/plugins/magic-link/magic-link-mutation-keys.js +17 -8
  43. package/dist/plugins/magic-link/magic-link-plugin.d.ts +3 -3
  44. package/dist/plugins/magic-link/magic-link-plugin.js +7 -11
  45. package/dist/plugins/multi-session/multi-session-localization.js +9 -8
  46. package/dist/plugins/multi-session/multi-session-mutation-keys.d.ts +11 -0
  47. package/dist/plugins/multi-session/multi-session-mutation-keys.js +11 -0
  48. package/dist/plugins/multi-session/multi-session-plugin.d.ts +3 -3
  49. package/dist/plugins/multi-session/multi-session-plugin.js +5 -9
  50. package/dist/plugins/multi-session/multi-session-query-keys.d.ts +6 -0
  51. package/dist/plugins/multi-session/multi-session-query-keys.js +7 -0
  52. package/dist/plugins/organization/organization-localization.d.ts +115 -0
  53. package/dist/plugins/organization/organization-localization.js +114 -0
  54. package/dist/plugins/organization/organization-mutation-keys.d.ts +40 -0
  55. package/dist/plugins/organization/organization-mutation-keys.js +40 -0
  56. package/dist/plugins/organization/organization-plugin.d.ts +152 -0
  57. package/dist/plugins/organization/organization-plugin.js +35 -0
  58. package/dist/plugins/organization/organization-query-keys.d.ts +40 -0
  59. package/dist/plugins/organization/organization-query-keys.js +54 -0
  60. package/dist/plugins/organization/organization-view-paths.d.ts +19 -0
  61. package/dist/plugins/organization/organization-view-paths.js +1 -0
  62. package/dist/plugins/passkey/passkey-localization.js +19 -13
  63. package/dist/plugins/passkey/passkey-mutation-keys.js +14 -19
  64. package/dist/plugins/passkey/passkey-plugin.d.ts +3 -3
  65. package/dist/plugins/passkey/passkey-plugin.js +5 -9
  66. package/dist/plugins/passkey/passkey-query-keys.d.ts +6 -0
  67. package/dist/plugins/passkey/passkey-query-keys.js +7 -0
  68. package/dist/plugins/theme/theme-localization.js +11 -9
  69. package/dist/plugins/theme/theme-plugin.d.ts +3 -3
  70. package/dist/plugins/theme/theme-plugin.js +7 -17
  71. package/dist/plugins/username/username-localization.js +15 -11
  72. package/dist/plugins/username/username-mutation-keys.d.ts +17 -0
  73. package/dist/plugins/username/username-mutation-keys.js +17 -0
  74. package/dist/plugins/username/username-plugin.d.ts +4 -4
  75. package/dist/plugins/username/username-plugin.js +35 -32
  76. package/dist/plugins.d.ts +28 -0
  77. package/dist/plugins.js +28 -18
  78. package/package.json +8 -7
  79. package/src/config/auth-config.ts +1 -1
  80. package/src/lib/auth-mutation-keys.ts +11 -24
  81. package/src/lib/auth-plugin.ts +4 -5
  82. package/src/lib/auth-query-keys.ts +6 -23
  83. package/src/lib/create-auth-plugin.ts +9 -26
  84. package/src/lib/localization.ts +4 -4
  85. package/src/lib/view-paths.ts +0 -4
  86. package/src/plugins/api-key/api-key-mutation-keys.ts +4 -2
  87. package/src/plugins/api-key/api-key-plugin.ts +22 -1
  88. package/src/plugins/api-key/api-key-query-keys.ts +13 -0
  89. package/src/plugins/delete-user/delete-user-localization.ts +3 -3
  90. package/src/plugins/delete-user/delete-user-mutation-keys.ts +7 -0
  91. package/src/plugins/multi-session/multi-session-mutation-keys.ts +11 -0
  92. package/src/plugins/multi-session/multi-session-query-keys.ts +13 -0
  93. package/src/plugins/organization/organization-localization.ts +123 -0
  94. package/src/plugins/organization/organization-mutation-keys.ts +52 -0
  95. package/src/plugins/organization/organization-plugin.ts +112 -0
  96. package/src/plugins/organization/organization-query-keys.ts +86 -0
  97. package/src/plugins/organization/organization-view-paths.ts +20 -0
  98. package/src/plugins/passkey/passkey-query-keys.ts +13 -0
  99. package/src/plugins/username/username-mutation-keys.ts +17 -0
  100. package/src/plugins.ts +28 -0
  101. package/dist/plugins/index.d.ts +0 -17
  102. package/src/plugins/index.ts +0 -17
@@ -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"],
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"]
17
+ };
@@ -1,4 +1,4 @@
1
- import { UsernameLocalization } from './username-localization';
1
+ import { type UsernameLocalization } from "./username-localization";
2
2
  export type UsernamePluginOptions = {
3
3
  /**
4
4
  * Whether to use displayUsername for the visible username field in the profile.
@@ -24,7 +24,7 @@ export type UsernamePluginOptions = {
24
24
  */
25
25
  localization?: Partial<UsernameLocalization>;
26
26
  };
27
- export declare const usernamePlugin: ((options?: UsernamePluginOptions | undefined) => Omit<{
27
+ export declare const usernamePlugin: ((options?: UsernamePluginOptions | undefined) => {
28
28
  minUsernameLength: number;
29
29
  maxUsernameLength: number;
30
30
  localization: {
@@ -43,7 +43,7 @@ export declare const usernamePlugin: ((options?: UsernamePluginOptions | undefin
43
43
  placeholder: string;
44
44
  inputType: "input";
45
45
  signUp: "above";
46
- required: boolean;
46
+ required: true;
47
47
  } | {
48
48
  name: string;
49
49
  type: "string";
@@ -61,7 +61,7 @@ export declare const usernamePlugin: ((options?: UsernamePluginOptions | undefin
61
61
  * Whether to check username availability on sign-up and user profile.
62
62
  */
63
63
  isUsernameAvailable?: boolean;
64
- }, "id"> & {
64
+ } & {
65
65
  id: "username";
66
66
  }) & {
67
67
  id: "username";
@@ -1,33 +1,36 @@
1
- import { createAuthPlugin as e } from "../../lib/create-auth-plugin.js";
2
- import { usernameLocalization as t } from "./username-localization.js";
3
- //#region src/plugins/username/username-plugin.ts
4
- var n = e("username", (e = {}) => {
5
- let n = e.minUsernameLength ?? 3, r = e.maxUsernameLength ?? 30, i = {
6
- ...t,
7
- ...e.localization
8
- };
9
- return {
10
- ...e,
11
- minUsernameLength: n,
12
- maxUsernameLength: r,
13
- localization: i,
14
- additionalFields: [{
15
- name: "username",
16
- type: "string",
17
- label: i.username,
18
- placeholder: i.usernamePlaceholder,
19
- inputType: "input",
20
- signUp: "above",
21
- required: !0
22
- }, ...e.displayUsername ? [{
23
- name: "displayUsername",
24
- type: "string",
25
- label: i.displayUsername,
26
- placeholder: i.displayUsernamePlaceholder,
27
- inputType: "input",
28
- signUp: "above"
29
- }] : []]
30
- };
1
+ import { createAuthPlugin } from "../../lib/create-auth-plugin";
2
+ import { usernameLocalization } from "./username-localization";
3
+ export const usernamePlugin = createAuthPlugin("username", (options = {}) => {
4
+ const minUsernameLength = options.minUsernameLength ?? 3;
5
+ const maxUsernameLength = options.maxUsernameLength ?? 30;
6
+ const localization = { ...usernameLocalization, ...options.localization };
7
+ return {
8
+ ...options,
9
+ minUsernameLength,
10
+ maxUsernameLength,
11
+ localization,
12
+ additionalFields: [
13
+ {
14
+ name: "username",
15
+ type: "string",
16
+ label: localization.username,
17
+ placeholder: localization.usernamePlaceholder,
18
+ inputType: "input",
19
+ signUp: "above",
20
+ required: true
21
+ },
22
+ ...(options.displayUsername
23
+ ? [
24
+ {
25
+ name: "displayUsername",
26
+ type: "string",
27
+ label: localization.displayUsername,
28
+ placeholder: localization.displayUsernamePlaceholder,
29
+ inputType: "input",
30
+ signUp: "above"
31
+ }
32
+ ]
33
+ : [])
34
+ ]
35
+ };
31
36
  });
32
- //#endregion
33
- export { n as usernamePlugin };
@@ -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";
package/dist/plugins.js CHANGED
@@ -1,18 +1,28 @@
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
+ 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";
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.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "build": "vite build",
7
- "dev": "tsc --watch",
6
+ "build": "tsc",
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
@@ -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