@better-auth-ui/core 1.6.8 → 1.6.10
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/auth-config.d.ts +1 -1
- package/dist/create-auth-plugin-CnH7jMHA.js +199 -0
- package/dist/index.js +103 -11
- package/dist/lib/auth-mutation-keys.d.ts +9 -20
- package/dist/lib/auth-plugin.d.ts +5 -6
- package/dist/lib/auth-query-keys.d.ts +6 -6
- package/dist/lib/create-auth-plugin.d.ts +5 -21
- package/dist/lib/localization.d.ts +2 -2
- package/dist/lib/view-paths.d.ts +0 -4
- package/dist/plugins/api-key/api-key-mutation-keys.d.ts +4 -2
- package/dist/plugins/api-key/api-key-plugin.d.ts +23 -2
- package/dist/plugins/api-key/api-key-query-keys.d.ts +6 -0
- package/dist/plugins/delete-user/delete-user-localization.d.ts +3 -3
- package/dist/plugins/delete-user/delete-user-mutation-keys.d.ts +7 -0
- package/dist/plugins/delete-user/delete-user-plugin.d.ts +4 -4
- package/dist/plugins/magic-link/magic-link-plugin.d.ts +2 -2
- package/dist/plugins/multi-session/multi-session-mutation-keys.d.ts +11 -0
- package/dist/plugins/multi-session/multi-session-plugin.d.ts +2 -2
- package/dist/plugins/multi-session/multi-session-query-keys.d.ts +6 -0
- package/dist/plugins/organization/organization-localization.d.ts +115 -0
- package/dist/plugins/organization/organization-mutation-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-plugin.d.ts +152 -0
- package/dist/plugins/organization/organization-query-keys.d.ts +40 -0
- package/dist/plugins/organization/organization-view-paths.d.ts +19 -0
- package/dist/plugins/passkey/passkey-plugin.d.ts +2 -2
- package/dist/plugins/passkey/passkey-query-keys.d.ts +6 -0
- package/dist/plugins/theme/theme-plugin.d.ts +2 -2
- package/dist/plugins/username/username-mutation-keys.d.ts +17 -0
- package/dist/plugins/username/username-plugin.d.ts +3 -3
- package/dist/plugins.d.ts +28 -0
- package/dist/plugins.js +360 -18
- package/package.json +7 -6
- 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/config/additional-fields-config.js +0 -27
- package/dist/config/auth-config.js +0 -32
- package/dist/lib/auth-mutation-keys.js +0 -57
- package/dist/lib/auth-query-keys.js +0 -39
- package/dist/lib/base-paths.js +0 -8
- package/dist/lib/create-auth-plugin.js +0 -9
- package/dist/lib/localization.js +0 -81
- package/dist/lib/provider-names.js +0 -43
- package/dist/lib/utils.js +0 -48
- package/dist/lib/view-paths.js +0 -16
- package/dist/plugins/api-key/api-key-localization.js +0 -16
- package/dist/plugins/api-key/api-key-mutation-keys.js +0 -15
- package/dist/plugins/api-key/api-key-plugin.js +0 -9
- package/dist/plugins/delete-user/delete-user-localization.js +0 -9
- package/dist/plugins/delete-user/delete-user-plugin.js +0 -12
- package/dist/plugins/index.d.ts +0 -17
- package/dist/plugins/magic-link/magic-link-localization.js +0 -8
- package/dist/plugins/magic-link/magic-link-mutation-keys.js +0 -8
- package/dist/plugins/magic-link/magic-link-plugin.js +0 -12
- package/dist/plugins/multi-session/multi-session-localization.js +0 -9
- package/dist/plugins/multi-session/multi-session-plugin.js +0 -9
- package/dist/plugins/passkey/passkey-localization.js +0 -14
- package/dist/plugins/passkey/passkey-mutation-keys.js +0 -20
- package/dist/plugins/passkey/passkey-plugin.js +0 -9
- package/dist/plugins/theme/theme-localization.js +0 -10
- package/dist/plugins/theme/theme-plugin.js +0 -18
- package/dist/plugins/username/username-localization.js +0 -12
- package/dist/plugins/username/username-plugin.js +0 -33
- package/src/plugins/index.ts +0 -17
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
//#region src/lib/base-paths.ts
|
|
2
|
+
var e = {
|
|
3
|
+
auth: "/auth",
|
|
4
|
+
settings: "/settings",
|
|
5
|
+
organization: "/organization"
|
|
6
|
+
}, t = {
|
|
7
|
+
auth: {
|
|
8
|
+
account: "Account",
|
|
9
|
+
alreadyHaveAnAccount: "Already have an account?",
|
|
10
|
+
confirmPassword: "Confirm password",
|
|
11
|
+
confirmPasswordPlaceholder: "Confirm your password",
|
|
12
|
+
continueWith: "Continue with {{provider}}",
|
|
13
|
+
email: "Email",
|
|
14
|
+
emailPlaceholder: "Enter your email",
|
|
15
|
+
forgotPassword: "Forgot Password",
|
|
16
|
+
forgotPasswordLink: "Forgot password?",
|
|
17
|
+
hidePassword: "Hide password",
|
|
18
|
+
invalidResetPasswordToken: "Invalid reset password token",
|
|
19
|
+
name: "Name",
|
|
20
|
+
namePlaceholder: "Enter your name",
|
|
21
|
+
needToCreateAnAccount: "Need to create an account?",
|
|
22
|
+
newPassword: "New password",
|
|
23
|
+
newPasswordPlaceholder: "Enter your new password",
|
|
24
|
+
or: "OR",
|
|
25
|
+
password: "Password",
|
|
26
|
+
passwordPlaceholder: "Enter your password",
|
|
27
|
+
passwordResetEmailSent: "Password reset email sent",
|
|
28
|
+
passwordResetSuccess: "Password reset successfully",
|
|
29
|
+
passwordsDoNotMatch: "Passwords do not match",
|
|
30
|
+
rememberMe: "Remember me",
|
|
31
|
+
rememberYourPassword: "Remember your password?",
|
|
32
|
+
resend: "Resend",
|
|
33
|
+
resetPassword: "Reset Password",
|
|
34
|
+
sendResetLink: "Send reset link",
|
|
35
|
+
showPassword: "Show password",
|
|
36
|
+
signIn: "Sign In",
|
|
37
|
+
signOut: "Sign Out",
|
|
38
|
+
signUp: "Sign Up",
|
|
39
|
+
verificationEmailSent: "Verification email sent!",
|
|
40
|
+
verifyYourEmail: "Verify your email"
|
|
41
|
+
},
|
|
42
|
+
settings: {
|
|
43
|
+
account: "Account",
|
|
44
|
+
accountUnlinked: "Account unlinked",
|
|
45
|
+
active: "Active",
|
|
46
|
+
activeSessions: "Active sessions",
|
|
47
|
+
avatar: "Avatar",
|
|
48
|
+
currentSession: "Current session",
|
|
49
|
+
avatarChangedSuccess: "Avatar changed successfully",
|
|
50
|
+
avatarDeletedSuccess: "Avatar deleted successfully",
|
|
51
|
+
changeAvatar: "Change avatar",
|
|
52
|
+
deleteAvatar: "Delete avatar",
|
|
53
|
+
link: "Link",
|
|
54
|
+
linkedAccounts: "Linked accounts",
|
|
55
|
+
linkProvider: "Link your {{provider}} account",
|
|
56
|
+
cancel: "Cancel",
|
|
57
|
+
copyToClipboard: "Copy to clipboard",
|
|
58
|
+
changeEmail: "Change email",
|
|
59
|
+
changeEmailSuccess: "Check your email to confirm the change",
|
|
60
|
+
changePassword: "Change password",
|
|
61
|
+
changePasswordSuccess: "Password changed successfully",
|
|
62
|
+
currentPassword: "Current password",
|
|
63
|
+
currentPasswordPlaceholder: "Enter your current password",
|
|
64
|
+
dangerZone: "Danger zone",
|
|
65
|
+
delete: "Delete",
|
|
66
|
+
optional: "Optional",
|
|
67
|
+
profileUpdatedSuccess: "Profile updated successfully",
|
|
68
|
+
revoke: "Revoke",
|
|
69
|
+
revokeSession: "Revoke session",
|
|
70
|
+
revokeSessionSuccess: "Session revoked successfully",
|
|
71
|
+
saveChanges: "Save changes",
|
|
72
|
+
setPassword: "Set password",
|
|
73
|
+
setPasswordDescription: "You don't have a password yet. Request a reset link to set one up.",
|
|
74
|
+
security: "Security",
|
|
75
|
+
settings: "Settings",
|
|
76
|
+
time: "Time",
|
|
77
|
+
unlinkProvider: "Unlink {{provider}}",
|
|
78
|
+
updateEmail: "Update email",
|
|
79
|
+
updatePassword: "Update password",
|
|
80
|
+
uploadAvatar: "Upload avatar",
|
|
81
|
+
userProfile: "User profile"
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/lib/utils.ts
|
|
86
|
+
function n(e) {
|
|
87
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
88
|
+
}
|
|
89
|
+
function r(e) {
|
|
90
|
+
return !(!n(e) || e instanceof Date || e instanceof RegExp);
|
|
91
|
+
}
|
|
92
|
+
function i(e, t = 256, n = "png") {
|
|
93
|
+
let r = t, i = n === "inherit" ? e.name.split(".").pop() : n, a = n === "inherit" ? e.type : `image/${n === "jpg" ? "jpeg" : n}`;
|
|
94
|
+
return new Promise((t, n) => {
|
|
95
|
+
let o = new Image(), s = URL.createObjectURL(e);
|
|
96
|
+
o.onload = () => {
|
|
97
|
+
URL.revokeObjectURL(s);
|
|
98
|
+
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");
|
|
99
|
+
m.width = p, m.height = p;
|
|
100
|
+
let h = m.getContext("2d");
|
|
101
|
+
if (!h) {
|
|
102
|
+
n(/* @__PURE__ */ Error("Could not get canvas context"));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
h.drawImage(o, d, f, u, u, 0, 0, p, p), m.toBlob((r) => {
|
|
106
|
+
if (!r) {
|
|
107
|
+
n(/* @__PURE__ */ Error("Could not create blob from canvas"));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
t(new File([r], e.name.replace(/\.[^.]+$/, `.${i}`), { type: a }));
|
|
111
|
+
}, a, 1);
|
|
112
|
+
}, o.onerror = () => {
|
|
113
|
+
URL.revokeObjectURL(s), n(/* @__PURE__ */ Error("Failed to load image"));
|
|
114
|
+
}, o.src = s;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function a(e) {
|
|
118
|
+
return new Promise((t, n) => {
|
|
119
|
+
let r = new FileReader();
|
|
120
|
+
r.onload = () => t(r.result), r.onerror = () => n(/* @__PURE__ */ Error("Failed to read file")), r.readAsDataURL(e);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function o(e, t) {
|
|
124
|
+
if (r(e) && r(t)) {
|
|
125
|
+
let n = { ...e };
|
|
126
|
+
for (let [r, i] of Object.entries(t)) i !== void 0 && (r in e ? n[r] = o(e[r], i) : n[r] = i);
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
return t;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/lib/view-paths.ts
|
|
133
|
+
var s = {
|
|
134
|
+
auth: {
|
|
135
|
+
signIn: "sign-in",
|
|
136
|
+
signUp: "sign-up",
|
|
137
|
+
forgotPassword: "forgot-password",
|
|
138
|
+
resetPassword: "reset-password",
|
|
139
|
+
signOut: "sign-out"
|
|
140
|
+
},
|
|
141
|
+
settings: {
|
|
142
|
+
account: "account",
|
|
143
|
+
security: "security"
|
|
144
|
+
}
|
|
145
|
+
}, c = {
|
|
146
|
+
avatar: {
|
|
147
|
+
enabled: !0,
|
|
148
|
+
resize: i,
|
|
149
|
+
size: 256,
|
|
150
|
+
extension: "png"
|
|
151
|
+
},
|
|
152
|
+
basePaths: e,
|
|
153
|
+
baseURL: "",
|
|
154
|
+
emailAndPassword: {
|
|
155
|
+
enabled: !0,
|
|
156
|
+
forgotPassword: !0,
|
|
157
|
+
name: !0,
|
|
158
|
+
rememberMe: !1,
|
|
159
|
+
minPasswordLength: 8,
|
|
160
|
+
maxPasswordLength: 128
|
|
161
|
+
},
|
|
162
|
+
plugins: [],
|
|
163
|
+
redirectTo: "/",
|
|
164
|
+
viewPaths: s,
|
|
165
|
+
localization: t,
|
|
166
|
+
navigate: ({ to: e, replace: t }) => {
|
|
167
|
+
t ? window.location.replace(e) : window.location.href = e;
|
|
168
|
+
}
|
|
169
|
+
}, l = {
|
|
170
|
+
all: ["auth"],
|
|
171
|
+
session: ["auth", "getSession"],
|
|
172
|
+
users: () => [...l.all, "user"],
|
|
173
|
+
user: (e) => [...l.users(), e],
|
|
174
|
+
accountInfo: (e, t) => [
|
|
175
|
+
...l.user(e),
|
|
176
|
+
"accountInfo",
|
|
177
|
+
t ?? null
|
|
178
|
+
],
|
|
179
|
+
listAccounts: (e, t) => [
|
|
180
|
+
...l.user(e),
|
|
181
|
+
"listAccounts",
|
|
182
|
+
t ?? null
|
|
183
|
+
],
|
|
184
|
+
listSessions: (e, t) => [
|
|
185
|
+
...l.user(e),
|
|
186
|
+
"listSessions",
|
|
187
|
+
t ?? null
|
|
188
|
+
]
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/lib/create-auth-plugin.ts
|
|
192
|
+
function u(e, t) {
|
|
193
|
+
return Object.assign((...n) => ({
|
|
194
|
+
...t(...n),
|
|
195
|
+
id: e
|
|
196
|
+
}), { id: e });
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { o as a, t as c, s as i, e as l, l as n, a as o, c as r, i as s, u as t };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./create-auth-plugin-CnH7jMHA.js";
|
|
2
|
+
//#region src/config/additional-fields-config.ts
|
|
3
|
+
function l(e, t) {
|
|
4
|
+
if (e.type === "boolean") return t === "on" || t === "true";
|
|
5
|
+
if (t != null) {
|
|
6
|
+
if (t === "") return null;
|
|
7
|
+
if (e.type === "number") {
|
|
8
|
+
let e = Number(t);
|
|
9
|
+
return Number.isNaN(e) ? void 0 : e;
|
|
10
|
+
}
|
|
11
|
+
if (e.type === "date") {
|
|
12
|
+
let e = new Date(t);
|
|
13
|
+
return Number.isNaN(e.getTime()) ? void 0 : e;
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function u(e) {
|
|
19
|
+
if (e.inputType) return e.inputType;
|
|
20
|
+
switch (e.type) {
|
|
21
|
+
case "number": return "number";
|
|
22
|
+
case "boolean": return "switch";
|
|
23
|
+
case "date": return "date";
|
|
24
|
+
default: return "input";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/lib/auth-mutation-keys.ts
|
|
29
|
+
var d = {
|
|
30
|
+
all: ["auth"],
|
|
31
|
+
signIn: {
|
|
32
|
+
all: ["auth", "signIn"],
|
|
33
|
+
email: [
|
|
34
|
+
"auth",
|
|
35
|
+
"signIn",
|
|
36
|
+
"email"
|
|
37
|
+
],
|
|
38
|
+
social: [
|
|
39
|
+
"auth",
|
|
40
|
+
"signIn",
|
|
41
|
+
"social"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
signUp: {
|
|
45
|
+
all: ["auth", "signUp"],
|
|
46
|
+
email: [
|
|
47
|
+
"auth",
|
|
48
|
+
"signUp",
|
|
49
|
+
"email"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
signOut: ["auth", "signOut"],
|
|
53
|
+
requestPasswordReset: ["auth", "requestPasswordReset"],
|
|
54
|
+
resetPassword: ["auth", "resetPassword"],
|
|
55
|
+
sendVerificationEmail: ["auth", "sendVerificationEmail"],
|
|
56
|
+
changeEmail: ["auth", "changeEmail"],
|
|
57
|
+
changePassword: ["auth", "changePassword"],
|
|
58
|
+
linkSocial: ["auth", "linkSocial"],
|
|
59
|
+
revokeSession: ["auth", "revokeSession"],
|
|
60
|
+
unlinkAccount: ["auth", "unlinkAccount"],
|
|
61
|
+
updateUser: ["auth", "updateUser"]
|
|
62
|
+
}, f = {
|
|
63
|
+
apple: "Apple",
|
|
64
|
+
atlassian: "Atlassian",
|
|
65
|
+
cognito: "Cognito",
|
|
66
|
+
discord: "Discord",
|
|
67
|
+
dropbox: "Dropbox",
|
|
68
|
+
facebook: "Facebook",
|
|
69
|
+
figma: "Figma",
|
|
70
|
+
github: "GitHub",
|
|
71
|
+
gitlab: "GitLab",
|
|
72
|
+
google: "Google",
|
|
73
|
+
huggingface: "Hugging Face",
|
|
74
|
+
kakao: "Kakao",
|
|
75
|
+
kick: "Kick",
|
|
76
|
+
line: "LINE",
|
|
77
|
+
linear: "Linear",
|
|
78
|
+
linkedin: "LinkedIn",
|
|
79
|
+
microsoft: "Microsoft",
|
|
80
|
+
naver: "Naver",
|
|
81
|
+
notion: "Notion",
|
|
82
|
+
paybin: "Paybin",
|
|
83
|
+
paypal: "PayPal",
|
|
84
|
+
polar: "Polar",
|
|
85
|
+
railway: "Railway",
|
|
86
|
+
reddit: "Reddit",
|
|
87
|
+
roblox: "Roblox",
|
|
88
|
+
salesforce: "Salesforce",
|
|
89
|
+
slack: "Slack",
|
|
90
|
+
spotify: "Spotify",
|
|
91
|
+
tiktok: "TikTok",
|
|
92
|
+
twitch: "Twitch",
|
|
93
|
+
twitter: "X",
|
|
94
|
+
vercel: "Vercel",
|
|
95
|
+
vk: "VK",
|
|
96
|
+
wechat: "WeChat",
|
|
97
|
+
zoom: "Zoom"
|
|
98
|
+
};
|
|
99
|
+
function p(e) {
|
|
100
|
+
return f[e] || e.charAt(0).toUpperCase() + e.slice(1);
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { d as authMutationKeys, i as authQueryKeys, r as basePaths, c as createAuthPlugin, e as deepmerge, o as defaultAuthConfig, a as fileToBase64, p as getProviderName, t as localization, l as parseAdditionalFieldValue, f as providerNames, s as resizeAvatar, u as resolveInputType, n as viewPaths };
|
|
@@ -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
|
};
|
|
@@ -5,11 +5,14 @@ import { AdditionalFields } from '../config/additional-fields-config';
|
|
|
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
|
|
@@ -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,37 +1,21 @@
|
|
|
1
|
+
import { 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;
|
|
@@ -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/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
|
/**
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Mutation keys contributed by the API key plugin.
|
|
3
3
|
*/
|
|
4
4
|
export declare const apiKeyMutationKeys: {
|
|
5
|
+
/** Root key for every api key mutation. */
|
|
6
|
+
readonly all: readonly ["auth", "apiKey"];
|
|
5
7
|
/** Key for `apiKey.create`. */
|
|
6
|
-
readonly
|
|
8
|
+
readonly create: readonly ["auth", "apiKey", "create"];
|
|
7
9
|
/** Key for `apiKey.delete`. */
|
|
8
|
-
readonly
|
|
10
|
+
readonly delete: readonly ["auth", "apiKey", "delete"];
|
|
9
11
|
};
|
|
@@ -5,8 +5,28 @@ export type ApiKeyPluginOptions = {
|
|
|
5
5
|
* @remarks `ApiKeyLocalization`
|
|
6
6
|
*/
|
|
7
7
|
localization?: Partial<ApiKeyLocalization>;
|
|
8
|
+
/**
|
|
9
|
+
* Enable organization-owned API keys.
|
|
10
|
+
*
|
|
11
|
+
* When `true`, the plugin contributes an organization-scoped API keys card
|
|
12
|
+
* to `<OrganizationSettings />`, and list/create/delete operations made on
|
|
13
|
+
* behalf of an organization send `configId: "organization"`.
|
|
14
|
+
*
|
|
15
|
+
* Requires a matching server-side `apiKey` config entry with
|
|
16
|
+
* `configId: "organization"` and `references: "organization"`:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* apiKey([
|
|
20
|
+
* { configId: "default", references: "user" },
|
|
21
|
+
* { configId: "organization", references: "organization" }
|
|
22
|
+
* ])
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
organization?: boolean;
|
|
8
28
|
};
|
|
9
|
-
export declare const apiKeyPlugin: ((options?: ApiKeyPluginOptions | undefined) =>
|
|
29
|
+
export declare const apiKeyPlugin: ((options?: ApiKeyPluginOptions | undefined) => {
|
|
10
30
|
localization: {
|
|
11
31
|
apiKey: string;
|
|
12
32
|
apiKeys: string;
|
|
@@ -20,7 +40,8 @@ export declare const apiKeyPlugin: ((options?: ApiKeyPluginOptions | undefined)
|
|
|
20
40
|
deleteApiKeyWarning: string;
|
|
21
41
|
dismissNewKey: string;
|
|
22
42
|
};
|
|
23
|
-
|
|
43
|
+
organization: boolean;
|
|
44
|
+
} & {
|
|
24
45
|
id: "apiKey";
|
|
25
46
|
}) & {
|
|
26
47
|
id: "apiKey";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Query key factory for API key queries, scoped per user. */
|
|
2
|
+
export declare const apiKeyQueryKeys: {
|
|
3
|
+
readonly all: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "apiKey"];
|
|
4
|
+
readonly lists: (userId: string | undefined) => readonly ["auth", "user", string | undefined, "apiKey", "list"];
|
|
5
|
+
readonly list: <TQuery = undefined>(userId: string | undefined, query?: TQuery) => readonly ["auth", "user", string | undefined, "apiKey", "list", NonNullable<TQuery> | null];
|
|
6
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const deleteUserLocalization: {
|
|
2
|
-
/** @remarks `"Delete
|
|
3
|
-
|
|
2
|
+
/** @remarks `"Delete account"` */
|
|
3
|
+
deleteAccount: string;
|
|
4
4
|
/** @remarks `"Permanently remove your account and all associated data. This cannot be undone."` */
|
|
5
|
-
|
|
5
|
+
deleteAccountDescription: string;
|
|
6
6
|
/** @remarks `"Check your email to confirm account deletion."` */
|
|
7
7
|
deleteUserVerificationSent: string;
|
|
8
8
|
/** @remarks `"Your account has been deleted."` */
|
|
@@ -11,15 +11,15 @@ export type DeleteUserPluginOptions = {
|
|
|
11
11
|
*/
|
|
12
12
|
localization?: Partial<DeleteUserLocalization>;
|
|
13
13
|
};
|
|
14
|
-
export declare const deleteUserPlugin: ((options?: DeleteUserPluginOptions | undefined) =>
|
|
14
|
+
export declare const deleteUserPlugin: ((options?: DeleteUserPluginOptions | undefined) => {
|
|
15
15
|
localization: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
deleteAccount: string;
|
|
17
|
+
deleteAccountDescription: string;
|
|
18
18
|
deleteUserVerificationSent: string;
|
|
19
19
|
deleteUserSuccess: string;
|
|
20
20
|
};
|
|
21
21
|
sendDeleteAccountVerification: boolean;
|
|
22
|
-
}
|
|
22
|
+
} & {
|
|
23
23
|
id: "deleteUser";
|
|
24
24
|
}) & {
|
|
25
25
|
id: "deleteUser";
|
|
@@ -19,7 +19,7 @@ export type MagicLinkPluginOptions = {
|
|
|
19
19
|
*/
|
|
20
20
|
path?: string;
|
|
21
21
|
};
|
|
22
|
-
export declare const magicLinkPlugin: ((options?: MagicLinkPluginOptions | undefined) =>
|
|
22
|
+
export declare const magicLinkPlugin: ((options?: MagicLinkPluginOptions | undefined) => {
|
|
23
23
|
localization: {
|
|
24
24
|
magicLink: string;
|
|
25
25
|
sendMagicLink: string;
|
|
@@ -30,7 +30,7 @@ export declare const magicLinkPlugin: ((options?: MagicLinkPluginOptions | undef
|
|
|
30
30
|
magicLink: string;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
}
|
|
33
|
+
} & {
|
|
34
34
|
id: "magicLink";
|
|
35
35
|
}) & {
|
|
36
36
|
id: "magicLink";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation keys contributed by the multi-session plugin.
|
|
3
|
+
*/
|
|
4
|
+
export declare const multiSessionMutationKeys: {
|
|
5
|
+
/** Root key for every multi-session mutation. */
|
|
6
|
+
readonly all: readonly ["auth", "multiSession"];
|
|
7
|
+
/** Key for `multiSession.revoke`. */
|
|
8
|
+
readonly revoke: readonly ["auth", "multiSession", "revoke"];
|
|
9
|
+
/** Key for `multiSession.setActive`. */
|
|
10
|
+
readonly setActive: readonly ["auth", "multiSession", "setActive"];
|
|
11
|
+
};
|
|
@@ -6,14 +6,14 @@ export type MultiSessionPluginOptions = {
|
|
|
6
6
|
*/
|
|
7
7
|
localization?: Partial<MultiSessionLocalization>;
|
|
8
8
|
};
|
|
9
|
-
export declare const multiSessionPlugin: ((options?: MultiSessionPluginOptions | undefined) =>
|
|
9
|
+
export declare const multiSessionPlugin: ((options?: MultiSessionPluginOptions | undefined) => {
|
|
10
10
|
localization: {
|
|
11
11
|
switchAccount: string;
|
|
12
12
|
addAccount: string;
|
|
13
13
|
manageAccounts: string;
|
|
14
14
|
manageAccountsDescription: string;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
} & {
|
|
17
17
|
id: "multiSession";
|
|
18
18
|
}) & {
|
|
19
19
|
id: "multiSession";
|