@better-auth-ui/core 1.6.7 → 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.d.ts +9 -3
- package/dist/plugins/passkey/passkey-localization.js +19 -10
- package/dist/plugins/passkey/passkey-mutation-keys.js +14 -19
- package/dist/plugins/passkey/passkey-plugin.d.ts +7 -4
- 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-localization.ts +11 -4
- 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,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates a plugin factory and attaches its `id` as a static property so
|
|
3
|
+
* consumers (e.g. `useAuthPlugin`) can look it up without invoking the
|
|
4
|
+
* factory.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* export const themePlugin = createAuthPlugin(
|
|
9
|
+
* "theme",
|
|
10
|
+
* (options: ThemePluginOptions) => ({
|
|
11
|
+
* setTheme: options.setTheme,
|
|
12
|
+
* themes: options.themes ?? ["system", "light", "dark"]
|
|
13
|
+
* })
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function createAuthPlugin(id, factory) {
|
|
18
|
+
const wrapped = (...args) => ({
|
|
19
|
+
...factory(...args),
|
|
20
|
+
id
|
|
21
|
+
});
|
|
22
|
+
return Object.assign(wrapped, { id });
|
|
7
23
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { e as createAuthPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -116,8 +116,6 @@ export declare const localization: {
|
|
|
116
116
|
delete: string;
|
|
117
117
|
/** @remarks `"Optional"` */
|
|
118
118
|
optional: string;
|
|
119
|
-
/** @remarks `"Profile"` */
|
|
120
|
-
profile: string;
|
|
121
119
|
/** @remarks `"Profile updated successfully"` */
|
|
122
120
|
profileUpdatedSuccess: string;
|
|
123
121
|
/** @remarks `"Revoke"` */
|
|
@@ -146,6 +144,8 @@ export declare const localization: {
|
|
|
146
144
|
updatePassword: string;
|
|
147
145
|
/** @remarks `"Upload avatar"` */
|
|
148
146
|
uploadAvatar: string;
|
|
147
|
+
/** @remarks `"User profile"` */
|
|
148
|
+
userProfile: string;
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
export type Localization = typeof localization;
|
package/dist/lib/localization.js
CHANGED
|
@@ -1,81 +1,150 @@
|
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
export const localization = {
|
|
2
|
+
auth: {
|
|
3
|
+
/** @remarks `"Account"` */
|
|
4
|
+
account: "Account",
|
|
5
|
+
/** @remarks `"Already have an account?"` */
|
|
6
|
+
alreadyHaveAnAccount: "Already have an account?",
|
|
7
|
+
/** @remarks `"Confirm password"` */
|
|
8
|
+
confirmPassword: "Confirm password",
|
|
9
|
+
/** @remarks `"Confirm your password"` */
|
|
10
|
+
confirmPasswordPlaceholder: "Confirm your password",
|
|
11
|
+
/** @remarks `"Continue with {{provider}}"` */
|
|
12
|
+
continueWith: "Continue with {{provider}}",
|
|
13
|
+
/** @remarks `"Email"` */
|
|
14
|
+
email: "Email",
|
|
15
|
+
/** @remarks `"Enter your email"` */
|
|
16
|
+
emailPlaceholder: "Enter your email",
|
|
17
|
+
/** @remarks `"Forgot Password"` */
|
|
18
|
+
forgotPassword: "Forgot Password",
|
|
19
|
+
/** @remarks `"Forgot password?"` */
|
|
20
|
+
forgotPasswordLink: "Forgot password?",
|
|
21
|
+
/** @remarks `"Hide password"` */
|
|
22
|
+
hidePassword: "Hide password",
|
|
23
|
+
/** @remarks `"Invalid reset password token"` */
|
|
24
|
+
invalidResetPasswordToken: "Invalid reset password token",
|
|
25
|
+
/** @remarks `"Name"` */
|
|
26
|
+
name: "Name",
|
|
27
|
+
/** @remarks `"Enter your name"` */
|
|
28
|
+
namePlaceholder: "Enter your name",
|
|
29
|
+
/** @remarks `"Need to create an account?"` */
|
|
30
|
+
needToCreateAnAccount: "Need to create an account?",
|
|
31
|
+
/** @remarks `"New password"` */
|
|
32
|
+
newPassword: "New password",
|
|
33
|
+
/** @remarks `"Enter your new password"` */
|
|
34
|
+
newPasswordPlaceholder: "Enter your new password",
|
|
35
|
+
/** @remarks `"OR"` */
|
|
36
|
+
or: "OR",
|
|
37
|
+
/** @remarks `"Password"` */
|
|
38
|
+
password: "Password",
|
|
39
|
+
/** @remarks `"Enter your password"` */
|
|
40
|
+
passwordPlaceholder: "Enter your password",
|
|
41
|
+
/** @remarks `"Password reset email sent"` */
|
|
42
|
+
passwordResetEmailSent: "Password reset email sent",
|
|
43
|
+
/** @remarks `"Password reset successfully"` */
|
|
44
|
+
passwordResetSuccess: "Password reset successfully",
|
|
45
|
+
/** @remarks `"Passwords do not match"` */
|
|
46
|
+
passwordsDoNotMatch: "Passwords do not match",
|
|
47
|
+
/** @remarks `"Remember me"` */
|
|
48
|
+
rememberMe: "Remember me",
|
|
49
|
+
/** @remarks `"Remember your password?"` */
|
|
50
|
+
rememberYourPassword: "Remember your password?",
|
|
51
|
+
/** @remarks `"Resend"` */
|
|
52
|
+
resend: "Resend",
|
|
53
|
+
/** @remarks `"Reset Password"` */
|
|
54
|
+
resetPassword: "Reset Password",
|
|
55
|
+
/** @remarks `"Send reset link"` */
|
|
56
|
+
sendResetLink: "Send reset link",
|
|
57
|
+
/** @remarks `"Show password"` */
|
|
58
|
+
showPassword: "Show password",
|
|
59
|
+
/** @remarks `"Sign In"` */
|
|
60
|
+
signIn: "Sign In",
|
|
61
|
+
/** @remarks `"Sign Out"` */
|
|
62
|
+
signOut: "Sign Out",
|
|
63
|
+
/** @remarks `"Sign Up"` */
|
|
64
|
+
signUp: "Sign Up",
|
|
65
|
+
/** @remarks `"Verification email sent!"` */
|
|
66
|
+
verificationEmailSent: "Verification email sent!",
|
|
67
|
+
/** @remarks `"Verify your email"` */
|
|
68
|
+
verifyYourEmail: "Verify your email"
|
|
69
|
+
},
|
|
70
|
+
settings: {
|
|
71
|
+
/** @remarks `"Account"` */
|
|
72
|
+
account: "Account",
|
|
73
|
+
/** @remarks `"Account unlinked"` */
|
|
74
|
+
accountUnlinked: "Account unlinked",
|
|
75
|
+
/** @remarks `"Active"` */
|
|
76
|
+
active: "Active",
|
|
77
|
+
/** @remarks `"Active sessions"` */
|
|
78
|
+
activeSessions: "Active sessions",
|
|
79
|
+
/** @remarks `"Avatar"` */
|
|
80
|
+
avatar: "Avatar",
|
|
81
|
+
/** @remarks `"Current session"` */
|
|
82
|
+
currentSession: "Current session",
|
|
83
|
+
/** @remarks `"Avatar changed successfully"` */
|
|
84
|
+
avatarChangedSuccess: "Avatar changed successfully",
|
|
85
|
+
/** @remarks `"Avatar deleted successfully"` */
|
|
86
|
+
avatarDeletedSuccess: "Avatar deleted successfully",
|
|
87
|
+
/** @remarks `"Change avatar"` */
|
|
88
|
+
changeAvatar: "Change avatar",
|
|
89
|
+
/** @remarks `"Delete avatar"` */
|
|
90
|
+
deleteAvatar: "Delete avatar",
|
|
91
|
+
/** @remarks `"Link"` */
|
|
92
|
+
link: "Link",
|
|
93
|
+
/** @remarks `"Linked accounts"` */
|
|
94
|
+
linkedAccounts: "Linked accounts",
|
|
95
|
+
/** @remarks `"Link your {{provider}} account"` */
|
|
96
|
+
linkProvider: "Link your {{provider}} account",
|
|
97
|
+
/** @remarks `"Cancel"` */
|
|
98
|
+
cancel: "Cancel",
|
|
99
|
+
/** @remarks `"Copy to clipboard"` */
|
|
100
|
+
copyToClipboard: "Copy to clipboard",
|
|
101
|
+
/** @remarks `"Change email"` */
|
|
102
|
+
changeEmail: "Change email",
|
|
103
|
+
/** @remarks `"Check your email to confirm the change"` */
|
|
104
|
+
changeEmailSuccess: "Check your email to confirm the change",
|
|
105
|
+
/** @remarks `"Change password"` */
|
|
106
|
+
changePassword: "Change password",
|
|
107
|
+
/** @remarks `"Password changed successfully"` */
|
|
108
|
+
changePasswordSuccess: "Password changed successfully",
|
|
109
|
+
/** @remarks `"Current password"` */
|
|
110
|
+
currentPassword: "Current password",
|
|
111
|
+
/** @remarks `"Enter your current password"` */
|
|
112
|
+
currentPasswordPlaceholder: "Enter your current password",
|
|
113
|
+
/** @remarks `"Danger zone"` */
|
|
114
|
+
dangerZone: "Danger zone",
|
|
115
|
+
/** @remarks `"Delete"` */
|
|
116
|
+
delete: "Delete",
|
|
117
|
+
/** @remarks `"Optional"` */
|
|
118
|
+
optional: "Optional",
|
|
119
|
+
/** @remarks `"Profile updated successfully"` */
|
|
120
|
+
profileUpdatedSuccess: "Profile updated successfully",
|
|
121
|
+
/** @remarks `"Revoke"` */
|
|
122
|
+
revoke: "Revoke",
|
|
123
|
+
/** @remarks `"Revoke session"` */
|
|
124
|
+
revokeSession: "Revoke session",
|
|
125
|
+
/** @remarks `"Session revoked successfully"` */
|
|
126
|
+
revokeSessionSuccess: "Session revoked successfully",
|
|
127
|
+
/** @remarks `"Save changes"` */
|
|
128
|
+
saveChanges: "Save changes",
|
|
129
|
+
/** @remarks `"Set password"` */
|
|
130
|
+
setPassword: "Set password",
|
|
131
|
+
/** @remarks `"You don't have a password yet. Request a reset link to set one up."` */
|
|
132
|
+
setPasswordDescription: "You don't have a password yet. Request a reset link to set one up.",
|
|
133
|
+
/** @remarks `"Security"` */
|
|
134
|
+
security: "Security",
|
|
135
|
+
/** @remarks `"Settings"` */
|
|
136
|
+
settings: "Settings",
|
|
137
|
+
/** @remarks `"Time"` */
|
|
138
|
+
time: "Time",
|
|
139
|
+
/** @remarks `"Unlink {{provider}}"` */
|
|
140
|
+
unlinkProvider: "Unlink {{provider}}",
|
|
141
|
+
/** @remarks `"Update email"` */
|
|
142
|
+
updateEmail: "Update email",
|
|
143
|
+
/** @remarks `"Update password"` */
|
|
144
|
+
updatePassword: "Update password",
|
|
145
|
+
/** @remarks `"Upload avatar"` */
|
|
146
|
+
uploadAvatar: "Upload avatar",
|
|
147
|
+
/** @remarks `"User profile"` */
|
|
148
|
+
userProfile: "User profile"
|
|
149
|
+
}
|
|
79
150
|
};
|
|
80
|
-
//#endregion
|
|
81
|
-
export { e as localization };
|
|
@@ -1,43 +1,50 @@
|
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Mapping of social authentication provider identifiers to their human-readable display names.
|
|
3
|
+
*/
|
|
4
|
+
export const providerNames = {
|
|
5
|
+
apple: "Apple",
|
|
6
|
+
atlassian: "Atlassian",
|
|
7
|
+
cognito: "Cognito",
|
|
8
|
+
discord: "Discord",
|
|
9
|
+
dropbox: "Dropbox",
|
|
10
|
+
facebook: "Facebook",
|
|
11
|
+
figma: "Figma",
|
|
12
|
+
github: "GitHub",
|
|
13
|
+
gitlab: "GitLab",
|
|
14
|
+
google: "Google",
|
|
15
|
+
huggingface: "Hugging Face",
|
|
16
|
+
kakao: "Kakao",
|
|
17
|
+
kick: "Kick",
|
|
18
|
+
line: "LINE",
|
|
19
|
+
linear: "Linear",
|
|
20
|
+
linkedin: "LinkedIn",
|
|
21
|
+
microsoft: "Microsoft",
|
|
22
|
+
naver: "Naver",
|
|
23
|
+
notion: "Notion",
|
|
24
|
+
paybin: "Paybin",
|
|
25
|
+
paypal: "PayPal",
|
|
26
|
+
polar: "Polar",
|
|
27
|
+
railway: "Railway",
|
|
28
|
+
reddit: "Reddit",
|
|
29
|
+
roblox: "Roblox",
|
|
30
|
+
salesforce: "Salesforce",
|
|
31
|
+
slack: "Slack",
|
|
32
|
+
spotify: "Spotify",
|
|
33
|
+
tiktok: "TikTok",
|
|
34
|
+
twitch: "Twitch",
|
|
35
|
+
twitter: "X",
|
|
36
|
+
vercel: "Vercel",
|
|
37
|
+
vk: "VK",
|
|
38
|
+
wechat: "WeChat",
|
|
39
|
+
zoom: "Zoom"
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Get the human-readable display name for an authentication provider.
|
|
43
|
+
*
|
|
44
|
+
* @param provider - The provider identifier (e.g., "github", "google").
|
|
45
|
+
* @returns The mapped display name for `provider` if available, otherwise `provider` with its first character capitalized.
|
|
46
|
+
*/
|
|
47
|
+
export function getProviderName(provider) {
|
|
48
|
+
return (providerNames[provider] ||
|
|
49
|
+
provider.charAt(0).toUpperCase() + provider.slice(1));
|
|
41
50
|
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { t as getProviderName, e as providerNames };
|
package/dist/lib/utils.d.ts
CHANGED
package/dist/lib/utils.js
CHANGED
|
@@ -1,48 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks whether a value is a non-null, non-array object.
|
|
3
|
+
*/
|
|
4
|
+
function isObject(item) {
|
|
5
|
+
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Type guard that checks whether a value is a plain object suitable for deep merging.
|
|
9
|
+
* Excludes `Date`, `RegExp`, and other special object types.
|
|
10
|
+
*/
|
|
11
|
+
function isPlainObject(item) {
|
|
12
|
+
if (!isObject(item))
|
|
13
|
+
return false;
|
|
14
|
+
// Handle special object types that should not be merged
|
|
15
|
+
if (item instanceof Date)
|
|
16
|
+
return false;
|
|
17
|
+
if (item instanceof RegExp)
|
|
18
|
+
return false;
|
|
19
|
+
return true;
|
|
7
20
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Resize and square-crop an image file for use as an avatar.
|
|
23
|
+
*
|
|
24
|
+
* The image is center-cropped to a square, scaled down to at most {@link size} pixels,
|
|
25
|
+
* and converted to the specified output format.
|
|
26
|
+
*
|
|
27
|
+
* @param file - The source image file.
|
|
28
|
+
* @param size - Max dimension in pixels for the output image.
|
|
29
|
+
* @param extension - Output format. Use `"inherit"` to keep the original format.
|
|
30
|
+
* @returns A promise that resolves to the processed `File`.
|
|
31
|
+
*/
|
|
32
|
+
export function resizeAvatar(file, size = 256, extension = "png") {
|
|
33
|
+
const MAX_SIZE = size;
|
|
34
|
+
const resolvedExtension = extension === "inherit" ? file.name.split(".").pop() : extension;
|
|
35
|
+
const mimeType = extension === "inherit"
|
|
36
|
+
? file.type
|
|
37
|
+
: `image/${extension === "jpg" ? "jpeg" : extension}`;
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const img = new Image();
|
|
40
|
+
const url = URL.createObjectURL(file);
|
|
41
|
+
img.onload = () => {
|
|
42
|
+
URL.revokeObjectURL(url);
|
|
43
|
+
const { naturalWidth: w, naturalHeight: h } = img;
|
|
44
|
+
const side = Math.min(w, h);
|
|
45
|
+
const cropX = (w - side) / 2;
|
|
46
|
+
const cropY = (h - side) / 2;
|
|
47
|
+
const outSize = Math.min(side, MAX_SIZE);
|
|
48
|
+
const canvas = document.createElement("canvas");
|
|
49
|
+
canvas.width = outSize;
|
|
50
|
+
canvas.height = outSize;
|
|
51
|
+
const ctx = canvas.getContext("2d");
|
|
52
|
+
if (!ctx) {
|
|
53
|
+
reject(new Error("Could not get canvas context"));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
ctx.drawImage(img, cropX, cropY, side, side, 0, 0, outSize, outSize);
|
|
57
|
+
canvas.toBlob((blob) => {
|
|
58
|
+
if (!blob) {
|
|
59
|
+
reject(new Error("Could not create blob from canvas"));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
resolve(new File([blob], file.name.replace(/\.[^.]+$/, `.${resolvedExtension}`), {
|
|
63
|
+
type: mimeType
|
|
64
|
+
}));
|
|
65
|
+
}, mimeType, 1);
|
|
66
|
+
};
|
|
67
|
+
img.onerror = () => {
|
|
68
|
+
URL.revokeObjectURL(url);
|
|
69
|
+
reject(new Error("Failed to load image"));
|
|
70
|
+
};
|
|
71
|
+
img.src = url;
|
|
72
|
+
});
|
|
32
73
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Convert a `File` to a base64-encoded data URL string.
|
|
76
|
+
*
|
|
77
|
+
* @param file - The file to encode.
|
|
78
|
+
* @returns A promise that resolves to the base64 data URL.
|
|
79
|
+
*/
|
|
80
|
+
export function fileToBase64(file) {
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const reader = new FileReader();
|
|
83
|
+
reader.onload = () => resolve(reader.result);
|
|
84
|
+
reader.onerror = () => reject(new Error("Failed to read file"));
|
|
85
|
+
reader.readAsDataURL(file);
|
|
86
|
+
});
|
|
38
87
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Recursively merge `source` into `target`, producing a new object.
|
|
90
|
+
*
|
|
91
|
+
* - Plain objects are merged key-by-key; nested objects are merged recursively.
|
|
92
|
+
* - `undefined` values in `source` are skipped (existing `target` values are preserved).
|
|
93
|
+
* - Non-plain values (arrays, `Date`, `RegExp`, primitives, functions) in `source`
|
|
94
|
+
* replace the corresponding `target` value outright.
|
|
95
|
+
*
|
|
96
|
+
* @param target - The base object.
|
|
97
|
+
* @param source - Partial overrides to apply on top of `target`.
|
|
98
|
+
* @returns A new merged object of type `T`.
|
|
99
|
+
*/
|
|
100
|
+
export function deepmerge(target, source) {
|
|
101
|
+
if (isPlainObject(target) && isPlainObject(source)) {
|
|
102
|
+
const result = { ...target };
|
|
103
|
+
for (const [key, value] of Object.entries(source)) {
|
|
104
|
+
if (value === undefined)
|
|
105
|
+
continue; // skip undefineds
|
|
106
|
+
if (key in target) {
|
|
107
|
+
result[key] = deepmerge(target[key], value);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
result[key] = value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
return source;
|
|
46
116
|
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { i as deepmerge, r as fileToBase64, n as resizeAvatar };
|
package/dist/lib/view-paths.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/lib/view-paths.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
export const viewPaths = {
|
|
2
|
+
auth: {
|
|
3
|
+
signIn: "sign-in",
|
|
4
|
+
signUp: "sign-up",
|
|
5
|
+
forgotPassword: "forgot-password",
|
|
6
|
+
resetPassword: "reset-password",
|
|
7
|
+
signOut: "sign-out"
|
|
8
|
+
},
|
|
9
|
+
settings: {
|
|
10
|
+
account: "account",
|
|
11
|
+
security: "security"
|
|
12
|
+
}
|
|
14
13
|
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { e as viewPaths };
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
export const apiKeyLocalization = {
|
|
2
|
+
/** @remarks `"API key"` */
|
|
3
|
+
apiKey: "API key",
|
|
4
|
+
/** @remarks `"API keys"` */
|
|
5
|
+
apiKeys: "API keys",
|
|
6
|
+
/** @remarks `"Create an API key for programmatic access to your account."` */
|
|
7
|
+
apiKeysDescription: "Create an API key for programmatic access to your account.",
|
|
8
|
+
/** @remarks `"Create API key"` */
|
|
9
|
+
createApiKey: "Create API key",
|
|
10
|
+
/** @remarks `"No API keys"` */
|
|
11
|
+
noApiKeys: "No API keys",
|
|
12
|
+
/** @remarks `"Name"` */
|
|
13
|
+
name: "Name",
|
|
14
|
+
/** @remarks `"New API key"` */
|
|
15
|
+
newApiKey: "New API key",
|
|
16
|
+
/** @remarks `"Copy this key now. For security reasons you will not be able to see it again."` */
|
|
17
|
+
newApiKeyWarning: "This is the only time you'll see this API key. Copy and store it somewhere safe.",
|
|
18
|
+
/** @remarks `"Delete API key"` */
|
|
19
|
+
deleteApiKey: "Delete API key",
|
|
20
|
+
/** @remarks `"This action cannot be undone. Any service using this API key will stop working immediately."` */
|
|
21
|
+
deleteApiKeyWarning: "This action cannot be undone. Any service using this API key will stop working immediately.",
|
|
22
|
+
/** @remarks `"I've saved my key"` */
|
|
23
|
+
dismissNewKey: "I've saved my key"
|
|
14
24
|
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { e as apiKeyLocalization };
|