@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.
- package/dist/config/additional-fields-config.js +37 -25
- package/dist/config/auth-config.d.ts +9 -9
- package/dist/config/auth-config.js +33 -31
- package/dist/config/avatar-config.js +1 -0
- package/dist/config/email-and-password-config.js +1 -0
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +4 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/lib/auth-mutation-keys.d.ts +9 -20
- package/dist/lib/auth-mutation-keys.js +69 -56
- package/dist/lib/auth-plugin.d.ts +6 -7
- package/dist/lib/auth-plugin.js +1 -0
- package/dist/lib/auth-query-keys.d.ts +6 -6
- package/dist/lib/auth-query-keys.js +41 -38
- package/dist/lib/base-paths.js +4 -7
- package/dist/lib/create-auth-plugin.d.ts +5 -21
- package/dist/lib/create-auth-plugin.js +22 -8
- package/dist/lib/deep-partial.js +1 -0
- package/dist/lib/localization.d.ts +2 -2
- package/dist/lib/localization.js +149 -80
- package/dist/lib/provider-names.d.ts +1 -1
- package/dist/lib/provider-names.js +48 -41
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +111 -43
- package/dist/lib/view-paths.d.ts +0 -4
- package/dist/lib/view-paths.js +12 -15
- package/dist/plugins/api-key/api-key-localization.js +23 -15
- package/dist/plugins/api-key/api-key-mutation-keys.d.ts +4 -2
- package/dist/plugins/api-key/api-key-mutation-keys.js +10 -14
- package/dist/plugins/api-key/api-key-plugin.d.ts +24 -3
- package/dist/plugins/api-key/api-key-plugin.js +6 -9
- package/dist/plugins/api-key/api-key-query-keys.d.ts +6 -0
- package/dist/plugins/api-key/api-key-query-keys.js +7 -0
- package/dist/plugins/delete-user/delete-user-localization.d.ts +3 -3
- package/dist/plugins/delete-user/delete-user-localization.js +9 -8
- package/dist/plugins/delete-user/delete-user-mutation-keys.d.ts +7 -0
- package/dist/plugins/delete-user/delete-user-mutation-keys.js +7 -0
- package/dist/plugins/delete-user/delete-user-plugin.d.ts +5 -5
- package/dist/plugins/delete-user/delete-user-plugin.js +5 -11
- package/dist/plugins/magic-link/magic-link-localization.js +7 -7
- package/dist/plugins/magic-link/magic-link-mutation-keys.js +17 -8
- package/dist/plugins/magic-link/magic-link-plugin.d.ts +3 -3
- package/dist/plugins/magic-link/magic-link-plugin.js +7 -11
- package/dist/plugins/multi-session/multi-session-localization.js +9 -8
- package/dist/plugins/multi-session/multi-session-mutation-keys.d.ts +11 -0
- package/dist/plugins/multi-session/multi-session-mutation-keys.js +11 -0
- package/dist/plugins/multi-session/multi-session-plugin.d.ts +3 -3
- package/dist/plugins/multi-session/multi-session-plugin.js +5 -9
- package/dist/plugins/multi-session/multi-session-query-keys.d.ts +6 -0
- package/dist/plugins/multi-session/multi-session-query-keys.js +7 -0
- package/dist/plugins/organization/organization-localization.d.ts +115 -0
- package/dist/plugins/organization/organization-localization.js +114 -0
- package/dist/plugins/organization/organization-mutation-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-mutation-keys.js +40 -0
- package/dist/plugins/organization/organization-plugin.d.ts +152 -0
- package/dist/plugins/organization/organization-plugin.js +35 -0
- package/dist/plugins/organization/organization-query-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-query-keys.js +54 -0
- package/dist/plugins/organization/organization-view-paths.d.ts +19 -0
- package/dist/plugins/organization/organization-view-paths.js +1 -0
- package/dist/plugins/passkey/passkey-localization.js +19 -13
- package/dist/plugins/passkey/passkey-mutation-keys.js +14 -19
- package/dist/plugins/passkey/passkey-plugin.d.ts +3 -3
- package/dist/plugins/passkey/passkey-plugin.js +5 -9
- package/dist/plugins/passkey/passkey-query-keys.d.ts +6 -0
- package/dist/plugins/passkey/passkey-query-keys.js +7 -0
- package/dist/plugins/theme/theme-localization.js +11 -9
- package/dist/plugins/theme/theme-plugin.d.ts +3 -3
- package/dist/plugins/theme/theme-plugin.js +7 -17
- package/dist/plugins/username/username-localization.js +15 -11
- package/dist/plugins/username/username-mutation-keys.d.ts +17 -0
- package/dist/plugins/username/username-mutation-keys.js +17 -0
- package/dist/plugins/username/username-plugin.d.ts +4 -4
- package/dist/plugins/username/username-plugin.js +35 -32
- package/dist/plugins.d.ts +28 -0
- package/dist/plugins.js +28 -18
- package/package.json +8 -7
- package/src/config/auth-config.ts +1 -1
- package/src/lib/auth-mutation-keys.ts +11 -24
- package/src/lib/auth-plugin.ts +4 -5
- package/src/lib/auth-query-keys.ts +6 -23
- package/src/lib/create-auth-plugin.ts +9 -26
- package/src/lib/localization.ts +4 -4
- package/src/lib/view-paths.ts +0 -4
- package/src/plugins/api-key/api-key-mutation-keys.ts +4 -2
- package/src/plugins/api-key/api-key-plugin.ts +22 -1
- package/src/plugins/api-key/api-key-query-keys.ts +13 -0
- package/src/plugins/delete-user/delete-user-localization.ts +3 -3
- package/src/plugins/delete-user/delete-user-mutation-keys.ts +7 -0
- package/src/plugins/multi-session/multi-session-mutation-keys.ts +11 -0
- package/src/plugins/multi-session/multi-session-query-keys.ts +13 -0
- package/src/plugins/organization/organization-localization.ts +123 -0
- package/src/plugins/organization/organization-mutation-keys.ts +52 -0
- package/src/plugins/organization/organization-plugin.ts +112 -0
- package/src/plugins/organization/organization-query-keys.ts +86 -0
- package/src/plugins/organization/organization-view-paths.ts +20 -0
- package/src/plugins/passkey/passkey-query-keys.ts +13 -0
- package/src/plugins/username/username-mutation-keys.ts +17 -0
- package/src/plugins.ts +28 -0
- package/dist/plugins/index.d.ts +0 -17
- package/src/plugins/index.ts +0 -17
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Convert a raw form value into the JS value Better Auth expects.
|
|
3
|
+
* Returns `null` for blank input (explicit clear), `undefined` when omitted
|
|
4
|
+
* or unparseable. Booleans always return `true`/`false`.
|
|
5
|
+
*/
|
|
6
|
+
export function parseAdditionalFieldValue(field, raw) {
|
|
7
|
+
if (field.type === "boolean") {
|
|
8
|
+
// FormData: checked checkbox/switch sends "on"; unchecked sends nothing.
|
|
9
|
+
return raw === "on" || raw === "true";
|
|
10
|
+
}
|
|
11
|
+
if (raw == null)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (raw === "")
|
|
14
|
+
return null;
|
|
15
|
+
if (field.type === "number") {
|
|
16
|
+
const parsed = Number(raw);
|
|
17
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
18
|
+
}
|
|
19
|
+
if (field.type === "date") {
|
|
20
|
+
const parsed = new Date(raw);
|
|
21
|
+
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
22
|
+
}
|
|
23
|
+
return raw;
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
/** Resolve the effective `inputType`, defaulting based on `field.type`. */
|
|
26
|
+
export function resolveInputType(field) {
|
|
27
|
+
if (field.inputType)
|
|
28
|
+
return field.inputType;
|
|
29
|
+
switch (field.type) {
|
|
30
|
+
case "number":
|
|
31
|
+
return "number";
|
|
32
|
+
case "boolean":
|
|
33
|
+
return "switch";
|
|
34
|
+
case "date":
|
|
35
|
+
return "date";
|
|
36
|
+
default:
|
|
37
|
+
return "input";
|
|
38
|
+
}
|
|
25
39
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { e as parseAdditionalFieldValue, t as resolveInputType };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SocialProvider } from
|
|
2
|
-
import { AuthPlugin } from
|
|
3
|
-
import { BasePaths } from
|
|
4
|
-
import { Localization } from
|
|
5
|
-
import { ViewPaths } from
|
|
6
|
-
import { AdditionalFields } from
|
|
7
|
-
import { AvatarConfig } from
|
|
8
|
-
import { EmailAndPasswordConfig } from
|
|
1
|
+
import type { SocialProvider } from "better-auth/social-providers";
|
|
2
|
+
import type { AuthPlugin } from "../lib/auth-plugin";
|
|
3
|
+
import { type BasePaths } from "../lib/base-paths";
|
|
4
|
+
import { type Localization } from "../lib/localization";
|
|
5
|
+
import { type ViewPaths } from "../lib/view-paths";
|
|
6
|
+
import type { AdditionalFields } from "./additional-fields-config";
|
|
7
|
+
import type { AvatarConfig } from "./avatar-config";
|
|
8
|
+
import type { EmailAndPasswordConfig } from "./email-and-password-config";
|
|
9
9
|
/**
|
|
10
10
|
* Core authentication configuration interface.
|
|
11
11
|
*
|
|
@@ -81,4 +81,4 @@ export interface AuthConfig {
|
|
|
81
81
|
replace?: boolean;
|
|
82
82
|
}) => void;
|
|
83
83
|
}
|
|
84
|
-
export declare const defaultAuthConfig: AuthConfig
|
|
84
|
+
export declare const defaultAuthConfig: Omit<AuthConfig, "authClient">;
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import { basePaths
|
|
2
|
-
import { localization
|
|
3
|
-
import { resizeAvatar
|
|
4
|
-
import { viewPaths
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { basePaths } from "../lib/base-paths";
|
|
2
|
+
import { localization } from "../lib/localization";
|
|
3
|
+
import { resizeAvatar } from "../lib/utils";
|
|
4
|
+
import { viewPaths } from "../lib/view-paths";
|
|
5
|
+
export const defaultAuthConfig = {
|
|
6
|
+
avatar: {
|
|
7
|
+
enabled: true,
|
|
8
|
+
resize: resizeAvatar,
|
|
9
|
+
size: 256,
|
|
10
|
+
extension: "png"
|
|
11
|
+
},
|
|
12
|
+
basePaths,
|
|
13
|
+
baseURL: "",
|
|
14
|
+
emailAndPassword: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
forgotPassword: true,
|
|
17
|
+
name: true,
|
|
18
|
+
rememberMe: false,
|
|
19
|
+
minPasswordLength: 8,
|
|
20
|
+
maxPasswordLength: 128
|
|
21
|
+
},
|
|
22
|
+
plugins: [],
|
|
23
|
+
redirectTo: "/",
|
|
24
|
+
viewPaths,
|
|
25
|
+
localization,
|
|
26
|
+
navigate: ({ to, replace }) => {
|
|
27
|
+
if (replace) {
|
|
28
|
+
window.location.replace(to);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
window.location.href = to;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
30
34
|
};
|
|
31
|
-
//#endregion
|
|
32
|
-
export { i as defaultAuthConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./additional-fields-config";
|
|
2
|
+
export * from "./auth-config";
|
|
3
|
+
export * from "./avatar-config";
|
|
4
|
+
export * from "./email-and-password-config";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
1
|
+
export * from "./config";
|
|
2
|
+
export * from "./lib/auth-mutation-keys";
|
|
3
|
+
export * from "./lib/auth-plugin";
|
|
4
|
+
export * from "./lib/auth-query-keys";
|
|
5
|
+
export * from "./lib/base-paths";
|
|
6
|
+
export * from "./lib/create-auth-plugin";
|
|
7
|
+
export * from "./lib/deep-partial";
|
|
8
|
+
export * from "./lib/localization";
|
|
9
|
+
export * from "./lib/provider-names";
|
|
10
|
+
export * from "./lib/utils";
|
|
11
|
+
export * from "./lib/view-paths";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
1
|
+
export * from "./config";
|
|
2
|
+
export * from "./lib/auth-mutation-keys";
|
|
3
|
+
export * from "./lib/auth-plugin";
|
|
4
|
+
export * from "./lib/auth-query-keys";
|
|
5
|
+
export * from "./lib/base-paths";
|
|
6
|
+
export * from "./lib/create-auth-plugin";
|
|
7
|
+
export * from "./lib/deep-partial";
|
|
8
|
+
export * from "./lib/localization";
|
|
9
|
+
export * from "./lib/provider-names";
|
|
10
|
+
export * from "./lib/utils";
|
|
11
|
+
export * from "./lib/view-paths";
|
|
@@ -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 declare const authMutationKeys: {
|
|
@@ -25,14 +33,12 @@ export declare const authMutationKeys: {
|
|
|
25
33
|
readonly all: readonly ["auth"];
|
|
26
34
|
/** Sign-in mutations, grouped by strategy. */
|
|
27
35
|
readonly signIn: {
|
|
28
|
-
/** Prefix matching every sign-in mutation. */
|
|
36
|
+
/** Prefix matching every sign-in mutation (including plugin strategies). */
|
|
29
37
|
readonly all: readonly ["auth", "signIn"];
|
|
30
38
|
/** Key for `signIn.email`. */
|
|
31
39
|
readonly email: readonly ["auth", "signIn", "email"];
|
|
32
40
|
/** Key for `signIn.social`. */
|
|
33
41
|
readonly social: readonly ["auth", "signIn", "social"];
|
|
34
|
-
/** Key for `signIn.username`. */
|
|
35
|
-
readonly username: readonly ["auth", "signIn", "username"];
|
|
36
42
|
};
|
|
37
43
|
/** Sign-up mutations, grouped by strategy. */
|
|
38
44
|
readonly signUp: {
|
|
@@ -49,21 +55,10 @@ export declare const authMutationKeys: {
|
|
|
49
55
|
readonly resetPassword: readonly ["auth", "resetPassword"];
|
|
50
56
|
/** Key for `sendVerificationEmail`. */
|
|
51
57
|
readonly sendVerificationEmail: readonly ["auth", "sendVerificationEmail"];
|
|
52
|
-
/** Multi-session mutations. */
|
|
53
|
-
readonly multiSession: {
|
|
54
|
-
/** Prefix matching every multi-session mutation. */
|
|
55
|
-
readonly all: readonly ["auth", "multiSession"];
|
|
56
|
-
/** Key for `multiSession.revoke`. */
|
|
57
|
-
readonly revoke: readonly ["auth", "multiSession", "revoke"];
|
|
58
|
-
/** Key for `multiSession.setActive`. */
|
|
59
|
-
readonly setActive: readonly ["auth", "multiSession", "setActive"];
|
|
60
|
-
};
|
|
61
58
|
/** Key for `changeEmail`. */
|
|
62
59
|
readonly changeEmail: readonly ["auth", "changeEmail"];
|
|
63
60
|
/** Key for `changePassword`. */
|
|
64
61
|
readonly changePassword: readonly ["auth", "changePassword"];
|
|
65
|
-
/** Key for `deleteUser`. */
|
|
66
|
-
readonly deleteUser: readonly ["auth", "deleteUser"];
|
|
67
62
|
/** Key for `linkSocial`. */
|
|
68
63
|
readonly linkSocial: readonly ["auth", "linkSocial"];
|
|
69
64
|
/** Key for `revokeSession`. */
|
|
@@ -72,10 +67,4 @@ export declare const authMutationKeys: {
|
|
|
72
67
|
readonly unlinkAccount: readonly ["auth", "unlinkAccount"];
|
|
73
68
|
/** Key for `updateUser`. */
|
|
74
69
|
readonly updateUser: readonly ["auth", "updateUser"];
|
|
75
|
-
/**
|
|
76
|
-
* Key for `isUsernameAvailable`. This is technically a read, but it's
|
|
77
|
-
* exposed via better-auth's mutation surface and lives under the mutation
|
|
78
|
-
* factories for parity with other username flows.
|
|
79
|
-
*/
|
|
80
|
-
readonly isUsernameAvailable: readonly ["auth", "isUsernameAvailable"];
|
|
81
70
|
};
|
|
@@ -1,57 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical mutation key factory for every Better Auth mutation managed by
|
|
3
|
+
* this library.
|
|
4
|
+
*
|
|
5
|
+
* Mutation keys are mostly used for `useIsMutating` and global
|
|
6
|
+
* `MutationCache` observers (e.g. toast handling), so the keys are static
|
|
7
|
+
* tuples rather than parameterised factories. Each grouping exposes an
|
|
8
|
+
* `all` prefix so consumers can match a whole feature at once:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* useIsMutating({ mutationKey: authMutationKeys.all })
|
|
12
|
+
* useIsMutating({ mutationKey: authMutationKeys.signIn.all })
|
|
13
|
+
* useIsMutating({ mutationKey: authMutationKeys.signIn.email })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* This factory lives in `@better-auth-ui/core` so it can be shared across
|
|
17
|
+
* framework packages (`@better-auth-ui/react`, a future `/solid` package,
|
|
18
|
+
* etc.) — the mutation cache entries line up regardless of which framework
|
|
19
|
+
* package the mutation options factory came from.
|
|
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
|
+
*
|
|
29
|
+
* For query keys, see `authQueryKeys` in `./auth-query-keys`.
|
|
30
|
+
*/
|
|
31
|
+
export const authMutationKeys = {
|
|
32
|
+
/** Root key for every Better Auth mutation. */
|
|
33
|
+
all: ["auth"],
|
|
34
|
+
/** Sign-in mutations, grouped by strategy. */
|
|
35
|
+
signIn: {
|
|
36
|
+
/** Prefix matching every sign-in mutation (including plugin strategies). */
|
|
37
|
+
all: ["auth", "signIn"],
|
|
38
|
+
/** Key for `signIn.email`. */
|
|
39
|
+
email: ["auth", "signIn", "email"],
|
|
40
|
+
/** Key for `signIn.social`. */
|
|
41
|
+
social: ["auth", "signIn", "social"]
|
|
42
|
+
},
|
|
43
|
+
/** Sign-up mutations, grouped by strategy. */
|
|
44
|
+
signUp: {
|
|
45
|
+
/** Prefix matching every sign-up mutation. */
|
|
46
|
+
all: ["auth", "signUp"],
|
|
47
|
+
/** Key for `signUp.email`. */
|
|
48
|
+
email: ["auth", "signUp", "email"]
|
|
49
|
+
},
|
|
50
|
+
/** Key for `signOut`. */
|
|
51
|
+
signOut: ["auth", "signOut"],
|
|
52
|
+
/** Key for `requestPasswordReset`. */
|
|
53
|
+
requestPasswordReset: ["auth", "requestPasswordReset"],
|
|
54
|
+
/** Key for `resetPassword`. */
|
|
55
|
+
resetPassword: ["auth", "resetPassword"],
|
|
56
|
+
/** Key for `sendVerificationEmail`. */
|
|
57
|
+
sendVerificationEmail: ["auth", "sendVerificationEmail"],
|
|
58
|
+
/** Key for `changeEmail`. */
|
|
59
|
+
changeEmail: ["auth", "changeEmail"],
|
|
60
|
+
/** Key for `changePassword`. */
|
|
61
|
+
changePassword: ["auth", "changePassword"],
|
|
62
|
+
/** Key for `linkSocial`. */
|
|
63
|
+
linkSocial: ["auth", "linkSocial"],
|
|
64
|
+
/** Key for `revokeSession`. */
|
|
65
|
+
revokeSession: ["auth", "revokeSession"],
|
|
66
|
+
/** Key for `unlinkAccount`. */
|
|
67
|
+
unlinkAccount: ["auth", "unlinkAccount"],
|
|
68
|
+
/** Key for `updateUser`. */
|
|
69
|
+
updateUser: ["auth", "updateUser"]
|
|
55
70
|
};
|
|
56
|
-
//#endregion
|
|
57
|
-
export { e as authMutationKeys };
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { AdditionalFields } from
|
|
1
|
+
import type { AdditionalFields } from "../config/additional-fields-config";
|
|
2
2
|
/**
|
|
3
3
|
* View-path contributions kept on the plugin object.
|
|
4
4
|
*
|
|
5
5
|
* Plugins that add routable sub-pages (e.g. `magicLinkPlugin` adds
|
|
6
6
|
* `/auth/magic-link`) declare the URL segment under the matching section.
|
|
7
7
|
* Read at runtime via `useAuthPlugin(plugin).viewPaths.*`.
|
|
8
|
+
*
|
|
9
|
+
* Plugin-specific namespaces (e.g. organization route segments) are merged
|
|
10
|
+
* via module augmentation from that plugin’s module — not declared here.
|
|
8
11
|
*/
|
|
9
|
-
export
|
|
12
|
+
export interface AuthPluginViewPaths {
|
|
10
13
|
auth?: Record<string, string>;
|
|
11
14
|
settings?: Record<string, string>;
|
|
12
|
-
}
|
|
15
|
+
}
|
|
13
16
|
/**
|
|
14
17
|
* Core authentication plugin interface.
|
|
15
18
|
*
|
|
@@ -32,10 +35,6 @@ export interface AuthPluginBase {
|
|
|
32
35
|
* user-defined additionalFields in the auth config.
|
|
33
36
|
*/
|
|
34
37
|
additionalFields?: AdditionalFields;
|
|
35
|
-
/**
|
|
36
|
-
* Additional properties contributed by the plugin.
|
|
37
|
-
*/
|
|
38
|
-
[key: string]: unknown;
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* Composable module-augmentation slot for narrowing the plugin type returned
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 declare const authQueryKeys: {
|
|
@@ -27,12 +33,6 @@ export declare const authQueryKeys: {
|
|
|
27
33
|
readonly users: () => readonly ["auth", "user"];
|
|
28
34
|
/** Prefix for every query scoped to a specific user. */
|
|
29
35
|
readonly user: (userId: string | undefined) => readonly ["auth", "user", string | undefined];
|
|
30
|
-
/** Key for `multiSession.listDeviceSessions` for the given user. */
|
|
31
|
-
readonly listDeviceSessions: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "listDeviceSessions", NonNullable<TQuery> | null];
|
|
32
|
-
/** Key for the user's passkey list. */
|
|
33
|
-
readonly listPasskeys: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "listPasskeys", NonNullable<TQuery> | null];
|
|
34
|
-
/** Key for the user's API keys list (`apiKey.list`). */
|
|
35
|
-
readonly listApiKeys: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "listApiKeys", NonNullable<TQuery> | null];
|
|
36
36
|
/** Key for `accountInfo` for the given user. */
|
|
37
37
|
readonly accountInfo: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "accountInfo", NonNullable<TQuery> | null];
|
|
38
38
|
/** Key for `listAccounts` for the given user. */
|
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical query key factory for every Better Auth query managed by
|
|
3
|
+
* this library.
|
|
4
|
+
*
|
|
5
|
+
* Keys are nested — higher-level keys are valid prefixes of their
|
|
6
|
+
* descendants — so a single call can invalidate a whole subtree:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* queryClient.invalidateQueries({ queryKey: authQueryKeys.all })
|
|
10
|
+
* queryClient.invalidateQueries({ queryKey: authQueryKeys.user(userId) })
|
|
11
|
+
* queryClient.invalidateQueries({ queryKey: authQueryKeys.session })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* This factory lives in `@better-auth-ui/core` so it can be shared across
|
|
15
|
+
* framework packages (`@better-auth-ui/react`, a future `/solid` package,
|
|
16
|
+
* etc.) and across client- and server-side query variants — the cache
|
|
17
|
+
* entries line up regardless of which query options factory produced them.
|
|
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
|
+
*
|
|
25
|
+
* For mutation keys, see `authMutationKeys` in `./auth-mutation-keys`.
|
|
26
|
+
*/
|
|
27
|
+
export const authQueryKeys = {
|
|
28
|
+
/** Root key for every Better Auth query. */
|
|
29
|
+
all: ["auth"],
|
|
30
|
+
/** Key for the current `getSession` query. */
|
|
31
|
+
session: ["auth", "getSession"],
|
|
32
|
+
/** Prefix for every per-user query. */
|
|
33
|
+
users: () => [...authQueryKeys.all, "user"],
|
|
34
|
+
/** Prefix for every query scoped to a specific user. */
|
|
35
|
+
user: (userId) => [...authQueryKeys.users(), userId],
|
|
36
|
+
/** Key for `accountInfo` for the given user. */
|
|
37
|
+
accountInfo: (userId, query) => [...authQueryKeys.user(userId), "accountInfo", query ?? null],
|
|
38
|
+
/** Key for `listAccounts` for the given user. */
|
|
39
|
+
listAccounts: (userId, query) => [...authQueryKeys.user(userId), "listAccounts", query ?? null],
|
|
40
|
+
/** Key for `listSessions` for the given user. */
|
|
41
|
+
listSessions: (userId, query) => [...authQueryKeys.user(userId), "listSessions", query ?? null]
|
|
37
42
|
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { e as authQueryKeys };
|
package/dist/lib/base-paths.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
organization: "/organization"
|
|
1
|
+
export const basePaths = {
|
|
2
|
+
auth: "/auth",
|
|
3
|
+
settings: "/settings",
|
|
4
|
+
organization: "/organization"
|
|
6
5
|
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { e as basePaths };
|
|
@@ -1,37 +1,21 @@
|
|
|
1
|
+
import type { AuthPlugin } from "./auth-plugin";
|
|
1
2
|
/**
|
|
2
|
-
* Creates a plugin factory and attaches its `id` as a static property
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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[]`.
|
|
3
|
+
* Creates a plugin factory and attaches its `id` as a static property so
|
|
4
|
+
* consumers (e.g. `useAuthPlugin`) can look it up without invoking the
|
|
5
|
+
* factory.
|
|
17
6
|
*
|
|
18
7
|
* @example
|
|
19
8
|
* ```ts
|
|
20
9
|
* export const themePlugin = createAuthPlugin(
|
|
21
10
|
* "theme",
|
|
22
11
|
* (options: ThemePluginOptions) => ({
|
|
23
|
-
* localization: { ...themeLocalization, ...options.localization },
|
|
24
|
-
* theme: options.theme ?? "system",
|
|
25
12
|
* setTheme: options.setTheme,
|
|
26
13
|
* themes: options.themes ?? ["system", "light", "dark"]
|
|
27
14
|
* })
|
|
28
15
|
* )
|
|
29
|
-
*
|
|
30
|
-
* themePlugin.id // "theme"
|
|
31
|
-
* themePlugin({ setTheme }) // { id: "theme", localization, theme, setTheme, themes }
|
|
32
16
|
* ```
|
|
33
17
|
*/
|
|
34
|
-
export declare function createAuthPlugin<const TId extends string, TArgs extends unknown[], TResult extends object>(id: TId, factory: (...args: TArgs) => TResult): ((...args: TArgs) =>
|
|
18
|
+
export declare function createAuthPlugin<const TId extends string, TArgs extends unknown[], TResult extends Omit<AuthPlugin, "id"> & object>(id: TId, factory: (...args: TArgs) => TResult): ((...args: TArgs) => TResult & {
|
|
35
19
|
id: TId;
|
|
36
20
|
}) & {
|
|
37
21
|
id: TId;
|