@better-auth-ui/core 1.6.3 → 1.6.4
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.d.ts +118 -0
- package/dist/config/additional-fields-config.js +27 -0
- package/dist/config/auth-config.d.ts +12 -23
- package/dist/config/auth-config.js +2 -12
- package/dist/config/email-and-password-config.d.ts +4 -2
- package/dist/config/index.d.ts +1 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -7
- package/dist/lib/auth-mutation-keys.d.ts +81 -0
- package/dist/lib/auth-mutation-keys.js +57 -0
- package/dist/lib/auth-plugin.d.ts +69 -0
- package/dist/lib/auth-query-keys.d.ts +40 -0
- package/dist/lib/auth-query-keys.js +34 -0
- package/dist/lib/create-auth-plugin.d.ts +38 -0
- package/dist/lib/create-auth-plugin.js +9 -0
- package/dist/lib/deep-partial.d.ts +7 -0
- package/dist/lib/localization.d.ts +6 -50
- package/dist/lib/localization.js +3 -25
- package/dist/lib/utils.d.ts +2 -1
- package/dist/lib/view-paths.d.ts +8 -9
- package/dist/lib/view-paths.js +0 -1
- package/dist/plugins/delete-user/delete-user-localization.d.ts +11 -0
- package/dist/plugins/delete-user/delete-user-localization.js +9 -0
- package/dist/plugins/delete-user/delete-user-plugin.d.ts +26 -0
- package/dist/plugins/delete-user/delete-user-plugin.js +12 -0
- package/dist/plugins/index.d.ts +14 -0
- package/dist/plugins/magic-link/magic-link-localization.d.ts +9 -0
- package/dist/plugins/magic-link/magic-link-localization.js +8 -0
- package/dist/plugins/magic-link/magic-link-mutation-keys.d.ts +17 -0
- package/dist/plugins/magic-link/magic-link-mutation-keys.js +8 -0
- package/dist/plugins/magic-link/magic-link-plugin.d.ts +37 -0
- package/dist/plugins/magic-link/magic-link-plugin.js +12 -0
- package/dist/plugins/multi-session/multi-session-localization.d.ts +11 -0
- package/dist/plugins/multi-session/multi-session-localization.js +9 -0
- package/dist/plugins/multi-session/multi-session-plugin.d.ts +20 -0
- package/dist/plugins/multi-session/multi-session-plugin.js +9 -0
- package/dist/plugins/passkey/passkey-localization.d.ts +15 -0
- package/dist/plugins/passkey/passkey-localization.js +11 -0
- package/dist/plugins/passkey/passkey-mutation-keys.d.ts +15 -0
- package/dist/plugins/passkey/passkey-mutation-keys.js +20 -0
- package/dist/plugins/passkey/passkey-plugin.d.ts +22 -0
- package/dist/plugins/passkey/passkey-plugin.js +9 -0
- package/dist/plugins/theme/theme-localization.d.ts +13 -0
- package/dist/plugins/theme/theme-localization.js +10 -0
- package/dist/plugins/theme/theme-plugin.d.ts +37 -0
- package/dist/plugins/theme/theme-plugin.js +18 -0
- package/dist/plugins/username/username-localization.d.ts +17 -0
- package/dist/plugins/username/username-localization.js +12 -0
- package/dist/plugins/username/username-plugin.d.ts +68 -0
- package/dist/plugins/username/username-plugin.js +33 -0
- package/dist/plugins.js +15 -0
- package/package.json +9 -5
- package/src/config/additional-fields-config.ts +182 -0
- package/src/config/auth-config.ts +14 -33
- package/src/config/email-and-password-config.ts +4 -2
- package/src/config/index.ts +1 -3
- package/src/index.ts +5 -0
- package/src/lib/auth-mutation-keys.ts +88 -0
- package/src/lib/auth-plugin.ts +79 -0
- package/src/lib/auth-query-keys.ts +68 -0
- package/src/lib/create-auth-plugin.ts +47 -0
- package/src/lib/deep-partial.ts +12 -0
- package/src/lib/localization.ts +7 -74
- package/src/lib/utils.ts +4 -2
- package/src/lib/view-paths.ts +6 -8
- package/src/plugins/delete-user/delete-user-localization.ts +16 -0
- package/src/plugins/delete-user/delete-user-plugin.ts +27 -0
- package/src/plugins/index.ts +14 -0
- package/src/plugins/magic-link/magic-link-localization.ts +10 -0
- package/src/plugins/magic-link/magic-link-mutation-keys.ts +17 -0
- package/src/plugins/magic-link/magic-link-plugin.ts +40 -0
- package/src/plugins/multi-session/multi-session-localization.ts +12 -0
- package/src/plugins/multi-session/multi-session-plugin.ts +20 -0
- package/src/plugins/passkey/passkey-localization.ts +16 -0
- package/src/plugins/passkey/passkey-mutation-keys.ts +15 -0
- package/src/plugins/passkey/passkey-plugin.ts +20 -0
- package/src/plugins/theme/theme-localization.ts +14 -0
- package/src/plugins/theme/theme-plugin.ts +33 -0
- package/src/plugins/username/username-localization.ts +24 -0
- package/src/plugins/username/username-plugin.ts +70 -0
- package/dist/config/appearance-config.d.ts +0 -23
- package/dist/config/delete-user-config.d.ts +0 -14
- package/dist/config/username-config.d.ts +0 -18
- package/src/config/appearance-config.ts +0 -24
- package/src/config/delete-user-config.ts +0 -14
- package/src/config/username-config.ts +0 -18
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createAuthPlugin } from "../../lib/create-auth-plugin"
|
|
2
|
+
import { type ThemeLocalization, themeLocalization } from "./theme-localization"
|
|
3
|
+
|
|
4
|
+
export type ThemePluginOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Override the plugin's default localization strings.
|
|
7
|
+
* @remarks `ThemeLocalization`
|
|
8
|
+
*/
|
|
9
|
+
localization?: Partial<ThemeLocalization>
|
|
10
|
+
/**
|
|
11
|
+
* Initial theme value
|
|
12
|
+
*/
|
|
13
|
+
theme?: string
|
|
14
|
+
/**
|
|
15
|
+
* Function to set the theme.
|
|
16
|
+
*/
|
|
17
|
+
setTheme: (theme: string) => void
|
|
18
|
+
/**
|
|
19
|
+
* Available theme options
|
|
20
|
+
* @default ["system", "light", "dark"]
|
|
21
|
+
*/
|
|
22
|
+
themes?: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const themePlugin = createAuthPlugin(
|
|
26
|
+
"theme",
|
|
27
|
+
(options: ThemePluginOptions) => ({
|
|
28
|
+
localization: { ...themeLocalization, ...options.localization },
|
|
29
|
+
theme: options.theme ?? "system",
|
|
30
|
+
setTheme: options.setTheme,
|
|
31
|
+
themes: options.themes ?? ["system", "light", "dark"]
|
|
32
|
+
})
|
|
33
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const usernameLocalization = {
|
|
2
|
+
/** @remarks `"Username"` */
|
|
3
|
+
username: "Username",
|
|
4
|
+
|
|
5
|
+
/** @remarks `"Enter your username"` */
|
|
6
|
+
usernamePlaceholder: "Enter your username",
|
|
7
|
+
|
|
8
|
+
/** @remarks `"Enter your username or email"` */
|
|
9
|
+
usernameOrEmailPlaceholder: "Enter your username or email",
|
|
10
|
+
|
|
11
|
+
/** @remarks `"Username is available"` */
|
|
12
|
+
usernameAvailable: "Username is available",
|
|
13
|
+
|
|
14
|
+
/** @remarks `"Username is already taken. Please try another."` */
|
|
15
|
+
usernameTaken: "Username is already taken. Please try another.",
|
|
16
|
+
|
|
17
|
+
/** @remarks `"Display Username"` */
|
|
18
|
+
displayUsername: "Display Username",
|
|
19
|
+
|
|
20
|
+
/** @remarks `"Enter your display username"` */
|
|
21
|
+
displayUsernamePlaceholder: "Enter your display username"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type UsernameLocalization = typeof usernameLocalization
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createAuthPlugin } from "../../lib/create-auth-plugin"
|
|
2
|
+
import {
|
|
3
|
+
type UsernameLocalization,
|
|
4
|
+
usernameLocalization
|
|
5
|
+
} from "./username-localization"
|
|
6
|
+
|
|
7
|
+
export type UsernamePluginOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to use displayUsername for the visible username field in the profile.
|
|
10
|
+
*/
|
|
11
|
+
displayUsername?: boolean
|
|
12
|
+
/**
|
|
13
|
+
* Whether to check username availability on sign-up and user profile.
|
|
14
|
+
*/
|
|
15
|
+
isUsernameAvailable?: boolean
|
|
16
|
+
/**
|
|
17
|
+
* Minimum allowed username length.
|
|
18
|
+
* @default 3
|
|
19
|
+
*/
|
|
20
|
+
minUsernameLength?: number
|
|
21
|
+
/**
|
|
22
|
+
* Maximum allowed username length.
|
|
23
|
+
* @default 30
|
|
24
|
+
*/
|
|
25
|
+
maxUsernameLength?: number
|
|
26
|
+
/**
|
|
27
|
+
* Override the plugin's default localization strings.
|
|
28
|
+
* @remarks `UsernameLocalization`
|
|
29
|
+
*/
|
|
30
|
+
localization?: Partial<UsernameLocalization>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const usernamePlugin = createAuthPlugin(
|
|
34
|
+
"username",
|
|
35
|
+
(options: UsernamePluginOptions = {}) => {
|
|
36
|
+
const minUsernameLength = options.minUsernameLength ?? 3
|
|
37
|
+
const maxUsernameLength = options.maxUsernameLength ?? 30
|
|
38
|
+
const localization = { ...usernameLocalization, ...options.localization }
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...options,
|
|
42
|
+
minUsernameLength,
|
|
43
|
+
maxUsernameLength,
|
|
44
|
+
localization,
|
|
45
|
+
additionalFields: [
|
|
46
|
+
{
|
|
47
|
+
name: "username",
|
|
48
|
+
type: "string" as const,
|
|
49
|
+
label: localization.username,
|
|
50
|
+
placeholder: localization.usernamePlaceholder,
|
|
51
|
+
inputType: "input" as const,
|
|
52
|
+
signUp: "above" as const,
|
|
53
|
+
required: true
|
|
54
|
+
},
|
|
55
|
+
...(options.displayUsername
|
|
56
|
+
? [
|
|
57
|
+
{
|
|
58
|
+
name: "displayUsername",
|
|
59
|
+
type: "string" as const,
|
|
60
|
+
label: localization.displayUsername,
|
|
61
|
+
placeholder: localization.displayUsernamePlaceholder,
|
|
62
|
+
inputType: "input" as const,
|
|
63
|
+
signUp: "above" as const
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
: [])
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Available theme options for the application.
|
|
3
|
-
*/
|
|
4
|
-
export type Theme = "system" | "light" | "dark";
|
|
5
|
-
/**
|
|
6
|
-
* Configuration options for appearance/theme settings.
|
|
7
|
-
*/
|
|
8
|
-
export type AppearanceConfig = {
|
|
9
|
-
/**
|
|
10
|
-
* Function to set the application theme
|
|
11
|
-
* @param theme - The theme value to set
|
|
12
|
-
*/
|
|
13
|
-
setTheme?: (theme: string) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Current theme value
|
|
16
|
-
*/
|
|
17
|
-
theme?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Available theme options to display in the theme switcher
|
|
20
|
-
* @default ["system", "light", "dark"]
|
|
21
|
-
*/
|
|
22
|
-
themes: Theme[];
|
|
23
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for account deletion in the UI (mirrors server `user.deleteUser` flags).
|
|
3
|
-
*/
|
|
4
|
-
export interface DeleteUserConfig {
|
|
5
|
-
/**
|
|
6
|
-
* Whether the delete user feature is enabled.
|
|
7
|
-
*/
|
|
8
|
-
enabled?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* When `true`, matches server `sendDeleteAccountVerification`: deletion starts by sending a
|
|
11
|
-
* verification email instead of deleting immediately in this request.
|
|
12
|
-
*/
|
|
13
|
-
sendDeleteAccountVerification?: boolean;
|
|
14
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface UsernameConfig {
|
|
2
|
-
/** Whether the username plugin is enabled */
|
|
3
|
-
enabled: boolean;
|
|
4
|
-
/** Whether to use displayUsername for the visible username field */
|
|
5
|
-
displayUsername: boolean;
|
|
6
|
-
/** Whether to check username availability on sign-up and user profile */
|
|
7
|
-
isUsernameAvailable: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Minimum allowed username length
|
|
10
|
-
* @default 3
|
|
11
|
-
*/
|
|
12
|
-
minUsernameLength: number;
|
|
13
|
-
/**
|
|
14
|
-
* Maximum allowed username length
|
|
15
|
-
* @default 30
|
|
16
|
-
*/
|
|
17
|
-
maxUsernameLength: number;
|
|
18
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Available theme options for the application.
|
|
3
|
-
*/
|
|
4
|
-
export type Theme = "system" | "light" | "dark"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configuration options for appearance/theme settings.
|
|
8
|
-
*/
|
|
9
|
-
export type AppearanceConfig = {
|
|
10
|
-
/**
|
|
11
|
-
* Function to set the application theme
|
|
12
|
-
* @param theme - The theme value to set
|
|
13
|
-
*/
|
|
14
|
-
setTheme?: (theme: string) => void
|
|
15
|
-
/**
|
|
16
|
-
* Current theme value
|
|
17
|
-
*/
|
|
18
|
-
theme?: string
|
|
19
|
-
/**
|
|
20
|
-
* Available theme options to display in the theme switcher
|
|
21
|
-
* @default ["system", "light", "dark"]
|
|
22
|
-
*/
|
|
23
|
-
themes: Theme[]
|
|
24
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for account deletion in the UI (mirrors server `user.deleteUser` flags).
|
|
3
|
-
*/
|
|
4
|
-
export interface DeleteUserConfig {
|
|
5
|
-
/**
|
|
6
|
-
* Whether the delete user feature is enabled.
|
|
7
|
-
*/
|
|
8
|
-
enabled?: boolean
|
|
9
|
-
/**
|
|
10
|
-
* When `true`, matches server `sendDeleteAccountVerification`: deletion starts by sending a
|
|
11
|
-
* verification email instead of deleting immediately in this request.
|
|
12
|
-
*/
|
|
13
|
-
sendDeleteAccountVerification?: boolean
|
|
14
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface UsernameConfig {
|
|
2
|
-
/** Whether the username plugin is enabled */
|
|
3
|
-
enabled: boolean
|
|
4
|
-
/** Whether to use displayUsername for the visible username field */
|
|
5
|
-
displayUsername: boolean
|
|
6
|
-
/** Whether to check username availability on sign-up and user profile */
|
|
7
|
-
isUsernameAvailable: boolean
|
|
8
|
-
/**
|
|
9
|
-
* Minimum allowed username length
|
|
10
|
-
* @default 3
|
|
11
|
-
*/
|
|
12
|
-
minUsernameLength: number
|
|
13
|
-
/**
|
|
14
|
-
* Maximum allowed username length
|
|
15
|
-
* @default 30
|
|
16
|
-
*/
|
|
17
|
-
maxUsernameLength: number
|
|
18
|
-
}
|