@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
@@ -1,9 +1,23 @@
1
- //#region src/lib/create-auth-plugin.ts
2
- function e(e, t) {
3
- return Object.assign((...n) => ({
4
- ...t(...n),
5
- id: e
6
- }), { id: e });
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;
@@ -1,81 +1,150 @@
1
- //#region src/lib/localization.ts
2
- var e = {
3
- auth: {
4
- account: "Account",
5
- alreadyHaveAnAccount: "Already have an account?",
6
- confirmPassword: "Confirm password",
7
- confirmPasswordPlaceholder: "Confirm your password",
8
- continueWith: "Continue with {{provider}}",
9
- email: "Email",
10
- emailPlaceholder: "Enter your email",
11
- forgotPassword: "Forgot Password",
12
- forgotPasswordLink: "Forgot password?",
13
- hidePassword: "Hide password",
14
- invalidResetPasswordToken: "Invalid reset password token",
15
- name: "Name",
16
- namePlaceholder: "Enter your name",
17
- needToCreateAnAccount: "Need to create an account?",
18
- newPassword: "New password",
19
- newPasswordPlaceholder: "Enter your new password",
20
- or: "OR",
21
- password: "Password",
22
- passwordPlaceholder: "Enter your password",
23
- passwordResetEmailSent: "Password reset email sent",
24
- passwordResetSuccess: "Password reset successfully",
25
- passwordsDoNotMatch: "Passwords do not match",
26
- rememberMe: "Remember me",
27
- rememberYourPassword: "Remember your password?",
28
- resend: "Resend",
29
- resetPassword: "Reset Password",
30
- sendResetLink: "Send reset link",
31
- showPassword: "Show password",
32
- signIn: "Sign In",
33
- signOut: "Sign Out",
34
- signUp: "Sign Up",
35
- verificationEmailSent: "Verification email sent!",
36
- verifyYourEmail: "Verify your email"
37
- },
38
- settings: {
39
- account: "Account",
40
- accountUnlinked: "Account unlinked",
41
- active: "Active",
42
- activeSessions: "Active sessions",
43
- avatar: "Avatar",
44
- currentSession: "Current session",
45
- avatarChangedSuccess: "Avatar changed successfully",
46
- avatarDeletedSuccess: "Avatar deleted successfully",
47
- changeAvatar: "Change avatar",
48
- deleteAvatar: "Delete avatar",
49
- link: "Link",
50
- linkedAccounts: "Linked accounts",
51
- linkProvider: "Link your {{provider}} account",
52
- cancel: "Cancel",
53
- copyToClipboard: "Copy to clipboard",
54
- changeEmail: "Change email",
55
- changeEmailSuccess: "Check your email to confirm the change",
56
- changePassword: "Change password",
57
- changePasswordSuccess: "Password changed successfully",
58
- currentPassword: "Current password",
59
- currentPasswordPlaceholder: "Enter your current password",
60
- dangerZone: "Danger zone",
61
- delete: "Delete",
62
- optional: "Optional",
63
- profile: "Profile",
64
- profileUpdatedSuccess: "Profile updated successfully",
65
- revoke: "Revoke",
66
- revokeSession: "Revoke session",
67
- revokeSessionSuccess: "Session revoked successfully",
68
- saveChanges: "Save changes",
69
- setPassword: "Set password",
70
- setPasswordDescription: "You don't have a password yet. Request a reset link to set one up.",
71
- security: "Security",
72
- settings: "Settings",
73
- time: "Time",
74
- unlinkProvider: "Unlink {{provider}}",
75
- updateEmail: "Update email",
76
- updatePassword: "Update password",
77
- uploadAvatar: "Upload avatar"
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,4 +1,4 @@
1
- import { SocialProvider } from 'better-auth/social-providers';
1
+ import type { SocialProvider } from "better-auth/social-providers";
2
2
  /**
3
3
  * Mapping of social authentication provider identifiers to their human-readable display names.
4
4
  */
@@ -1,43 +1,50 @@
1
- //#region src/lib/provider-names.ts
2
- var e = {
3
- apple: "Apple",
4
- atlassian: "Atlassian",
5
- cognito: "Cognito",
6
- discord: "Discord",
7
- dropbox: "Dropbox",
8
- facebook: "Facebook",
9
- figma: "Figma",
10
- github: "GitHub",
11
- gitlab: "GitLab",
12
- google: "Google",
13
- huggingface: "Hugging Face",
14
- kakao: "Kakao",
15
- kick: "Kick",
16
- line: "LINE",
17
- linear: "Linear",
18
- linkedin: "LinkedIn",
19
- microsoft: "Microsoft",
20
- naver: "Naver",
21
- notion: "Notion",
22
- paybin: "Paybin",
23
- paypal: "PayPal",
24
- polar: "Polar",
25
- railway: "Railway",
26
- reddit: "Reddit",
27
- roblox: "Roblox",
28
- salesforce: "Salesforce",
29
- slack: "Slack",
30
- spotify: "Spotify",
31
- tiktok: "TikTok",
32
- twitch: "Twitch",
33
- twitter: "X",
34
- vercel: "Vercel",
35
- vk: "VK",
36
- wechat: "WeChat",
37
- zoom: "Zoom"
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
- function t(t) {
40
- return e[t] || t.charAt(0).toUpperCase() + t.slice(1);
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 };
@@ -1,4 +1,4 @@
1
- import { DeepPartial } from './deep-partial';
1
+ import type { DeepPartial } from "./deep-partial";
2
2
  /**
3
3
  * Resize and square-crop an image file for use as an avatar.
4
4
  *
package/dist/lib/utils.js CHANGED
@@ -1,48 +1,116 @@
1
- //#region src/lib/utils.ts
2
- function e(e) {
3
- return typeof e == "object" && !!e && !Array.isArray(e);
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
- function t(t) {
6
- return !(!e(t) || t instanceof Date || t instanceof RegExp);
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
- function n(e, t = 256, n = "png") {
9
- let r = t, i = n === "inherit" ? e.name.split(".").pop() : n, a = n === "inherit" ? e.type : `image/${n === "jpg" ? "jpeg" : n}`;
10
- return new Promise((t, n) => {
11
- let o = new Image(), s = URL.createObjectURL(e);
12
- o.onload = () => {
13
- URL.revokeObjectURL(s);
14
- let { naturalWidth: c, naturalHeight: l } = o, u = Math.min(c, l), d = (c - u) / 2, f = (l - u) / 2, p = Math.min(u, r), m = document.createElement("canvas");
15
- m.width = p, m.height = p;
16
- let h = m.getContext("2d");
17
- if (!h) {
18
- n(/* @__PURE__ */ Error("Could not get canvas context"));
19
- return;
20
- }
21
- h.drawImage(o, d, f, u, u, 0, 0, p, p), m.toBlob((r) => {
22
- if (!r) {
23
- n(/* @__PURE__ */ Error("Could not create blob from canvas"));
24
- return;
25
- }
26
- t(new File([r], e.name.replace(/\.[^.]+$/, `.${i}`), { type: a }));
27
- }, a, 1);
28
- }, o.onerror = () => {
29
- URL.revokeObjectURL(s), n(/* @__PURE__ */ Error("Failed to load image"));
30
- }, o.src = s;
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
- function r(e) {
34
- return new Promise((t, n) => {
35
- let r = new FileReader();
36
- r.onload = () => t(r.result), r.onerror = () => n(/* @__PURE__ */ Error("Failed to read file")), r.readAsDataURL(e);
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
- function i(e, n) {
40
- if (t(e) && t(n)) {
41
- let t = { ...e };
42
- for (let [r, a] of Object.entries(n)) a !== void 0 && (r in e ? t[r] = i(e[r], a) : t[r] = a);
43
- return t;
44
- }
45
- return n;
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 };
@@ -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
  /**
@@ -1,16 +1,13 @@
1
- //#region src/lib/view-paths.ts
2
- var e = {
3
- auth: {
4
- signIn: "sign-in",
5
- signUp: "sign-up",
6
- forgotPassword: "forgot-password",
7
- resetPassword: "reset-password",
8
- signOut: "sign-out"
9
- },
10
- settings: {
11
- account: "account",
12
- security: "security"
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
- //#region src/plugins/api-key/api-key-localization.ts
2
- var e = {
3
- apiKey: "API key",
4
- apiKeys: "API keys",
5
- apiKeysDescription: "Create an API key for programmatic access to your account.",
6
- createApiKey: "Create API key",
7
- noApiKeys: "No API keys",
8
- name: "Name",
9
- newApiKey: "New API key",
10
- newApiKeyWarning: "This is the only time you'll see this API key. Copy and store it somewhere safe.",
11
- deleteApiKey: "Delete API key",
12
- deleteApiKeyWarning: "This action cannot be undone. Any service using this API key will stop working immediately.",
13
- dismissNewKey: "I've saved my key"
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 };