@lalternative/auth 0.1.1

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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @lalternative/auth
2
+
3
+ Shared [Better Auth](https://better-auth.com) wrapper for L'Alternative apps.
4
+
5
+ Provides platform auth defaults (email-OTP + admin plugins), a React client,
6
+ and the auth UI forms (verify-email, forgot/reset password, auth layout).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @lalternative/auth better-auth react react-dom
12
+ ```
13
+
14
+ The package is published to GitHub Packages. Consumers need a `.npmrc`:
15
+
16
+ ```
17
+ @lalternative:registry=https://npm.pkg.github.com
18
+ //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ // server (e.g. lib/auth.ts)
25
+ import { createPlatformAuth } from "@lalternative/auth/server"
26
+
27
+ export const auth = createPlatformAuth({ database, secret, /* ... */ })
28
+ ```
29
+
30
+ ```ts
31
+ // client (e.g. lib/auth-client.ts)
32
+ import { createPlatformAuthClient } from "@lalternative/auth/client"
33
+
34
+ export const authClient = createPlatformAuthClient({ baseURL })
35
+ ```
36
+
37
+ ```tsx
38
+ // UI + hooks
39
+ import { VerifyEmailForm, ForgotPasswordForm, ResetPasswordForm, AuthLayout, useSession, useLogout } from "@lalternative/auth"
40
+ ```
@@ -0,0 +1,15 @@
1
+ import * as better_auth_react from 'better-auth/react';
2
+ import { P as PlatformAuthClientConfig } from './types-CLsvniwT.js';
3
+ import 'better-auth';
4
+
5
+ /**
6
+ * Creates a Better Auth client for React usage.
7
+ * Provides useSession() hook and other React-integrated methods.
8
+ */
9
+ declare function createPlatformAuthClient(config?: PlatformAuthClientConfig): better_auth_react.ReactAuthClient<{
10
+ baseURL: string;
11
+ plugins: any[];
12
+ }>;
13
+ type PlatformAuthClient = ReturnType<typeof createPlatformAuthClient>;
14
+
15
+ export { type PlatformAuthClient, createPlatformAuthClient };
package/dist/client.js ADDED
@@ -0,0 +1,13 @@
1
+ // src/client.ts
2
+ import { createAuthClient } from "better-auth/react";
3
+ import { emailOTPClient, adminClient } from "better-auth/client/plugins";
4
+ function createPlatformAuthClient(config) {
5
+ return createAuthClient({
6
+ baseURL: config?.baseURL ?? (typeof window !== "undefined" ? window.location.origin : "http://localhost:3000"),
7
+ plugins: [emailOTPClient(), adminClient(), ...config?.plugins ?? []]
8
+ });
9
+ }
10
+ export {
11
+ createPlatformAuthClient
12
+ };
13
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\"\nimport { emailOTPClient, adminClient } from \"better-auth/client/plugins\"\nimport type { PlatformAuthClientConfig } from \"./types\"\n\n/**\n * Creates a Better Auth client for React usage.\n * Provides useSession() hook and other React-integrated methods.\n */\nexport function createPlatformAuthClient(config?: PlatformAuthClientConfig) {\n return createAuthClient({\n baseURL:\n config?.baseURL ??\n (typeof window !== \"undefined\"\n ? window.location.origin\n : \"http://localhost:3000\"),\n plugins: [emailOTPClient(), adminClient(), ...(config?.plugins ?? [])],\n })\n}\n\nexport type PlatformAuthClient = ReturnType<typeof createPlatformAuthClient>\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,mBAAmB;AAOrC,SAAS,yBAAyB,QAAmC;AAC1E,SAAO,iBAAiB;AAAA,IACtB,SACE,QAAQ,YACP,OAAO,WAAW,cACf,OAAO,SAAS,SAChB;AAAA,IACN,SAAS,CAAC,eAAe,GAAG,YAAY,GAAG,GAAI,QAAQ,WAAW,CAAC,CAAE;AAAA,EACvE,CAAC;AACH;","names":[]}
@@ -0,0 +1,55 @@
1
+ import { V as VerifyEmailFormProps, F as ForgotPasswordFormProps, R as ResetPasswordFormProps, A as AuthLayoutProps } from './types-CLsvniwT.js';
2
+ export { P as PlatformAuthClientConfig, a as PlatformAuthConfig, b as PlatformAuthMailer, c as PlatformAuthMailerArgs, d as PlatformAuthMailerType } from './types-CLsvniwT.js';
3
+ import * as better_auth_react from 'better-auth/react';
4
+ import * as better_auth from 'better-auth';
5
+ import { PlatformAuthClient } from './client.js';
6
+ import * as react from 'react';
7
+
8
+ /**
9
+ * Returns a useSession hook bound to the given auth client.
10
+ * Usage: const { data: session, isPending } = useSession(authClient)
11
+ */
12
+ declare function useSession(authClient: PlatformAuthClient): {
13
+ data: {
14
+ user: better_auth.StripEmptyObjects<{
15
+ id: string;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ email: string;
19
+ emailVerified: boolean;
20
+ name: string;
21
+ image?: string | null | undefined;
22
+ }>;
23
+ session: better_auth.StripEmptyObjects<{
24
+ id: string;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ userId: string;
28
+ expiresAt: Date;
29
+ token: string;
30
+ ipAddress?: string | null | undefined;
31
+ userAgent?: string | null | undefined;
32
+ }>;
33
+ } | null;
34
+ isPending: boolean;
35
+ isRefetching: boolean;
36
+ error: better_auth_react.BetterFetchError | null;
37
+ refetch: (queryParams?: {
38
+ query?: better_auth.SessionQueryParams;
39
+ } | undefined) => Promise<void>;
40
+ };
41
+ /**
42
+ * Returns a logout function bound to the given auth client.
43
+ * Usage: const logout = useLogout(authClient)
44
+ */
45
+ declare function useLogout(authClient: PlatformAuthClient): () => Promise<void>;
46
+
47
+ declare function VerifyEmailForm({ email, onSuccess, authClient, }: VerifyEmailFormProps): react.JSX.Element;
48
+
49
+ declare function ForgotPasswordForm({ onSuccess, loginUrl, authClient, }: ForgotPasswordFormProps): react.JSX.Element;
50
+
51
+ declare function ResetPasswordForm({ email, onSuccess, loginUrl, authClient, }: ResetPasswordFormProps): react.JSX.Element;
52
+
53
+ declare function AuthLayout({ logo, title, subtitle, children, footer, }: AuthLayoutProps): react.JSX.Element;
54
+
55
+ export { AuthLayout, AuthLayoutProps, ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, VerifyEmailForm, VerifyEmailFormProps, useLogout, useSession };
package/dist/index.js ADDED
@@ -0,0 +1,395 @@
1
+ // src/hooks/use-session.ts
2
+ function useSession(authClient) {
3
+ return authClient.useSession();
4
+ }
5
+ function useLogout(authClient) {
6
+ const signOut = async () => {
7
+ await authClient.signOut();
8
+ };
9
+ return signOut;
10
+ }
11
+
12
+ // src/components/verify-email-form.tsx
13
+ import { useState } from "react";
14
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
+ function VerifyEmailForm({
16
+ email,
17
+ onSuccess,
18
+ authClient
19
+ }) {
20
+ const [otp, setOtp] = useState("");
21
+ const [isVerifying, setIsVerifying] = useState(false);
22
+ const [isResending, setIsResending] = useState(false);
23
+ const [resendMessage, setResendMessage] = useState();
24
+ const [error, setError] = useState();
25
+ const handleVerify = async (e) => {
26
+ e.preventDefault();
27
+ if (!otp.trim() || otp.length < 6) {
28
+ setError("Please enter the 6-digit code");
29
+ return;
30
+ }
31
+ setError(void 0);
32
+ setIsVerifying(true);
33
+ try {
34
+ const res = await authClient.emailOtp.verifyEmail({ email, otp });
35
+ console.log("[verify-email] response:", JSON.stringify(res?.data), "error:", JSON.stringify(res?.error));
36
+ if (res?.error) {
37
+ setError(res.error.message ?? "Invalid code. Please try again.");
38
+ return;
39
+ }
40
+ onSuccess?.();
41
+ } catch (err) {
42
+ setError(err instanceof Error ? err.message : "Invalid code. Please try again.");
43
+ } finally {
44
+ setIsVerifying(false);
45
+ }
46
+ };
47
+ const handleResend = async () => {
48
+ if (!email) {
49
+ setError("Email address is not available. Please register again.");
50
+ return;
51
+ }
52
+ setError(void 0);
53
+ setResendMessage(void 0);
54
+ setIsResending(true);
55
+ try {
56
+ await authClient.emailOtp.sendVerificationOtp({
57
+ email,
58
+ type: "email-verification"
59
+ });
60
+ setResendMessage("A new code has been sent to your inbox.");
61
+ } catch (err) {
62
+ setError(err instanceof Error ? err.message : "Failed to resend code.");
63
+ } finally {
64
+ setIsResending(false);
65
+ }
66
+ };
67
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-8", children: [
68
+ /* @__PURE__ */ jsxs("div", { children: [
69
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Verify your email" }),
70
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: email ? /* @__PURE__ */ jsxs(Fragment, { children: [
71
+ "Enter the 6-digit code sent to",
72
+ " ",
73
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: email })
74
+ ] }) : "Enter the 6-digit code sent to your email" })
75
+ ] }),
76
+ error && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
77
+ resendMessage && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700", children: resendMessage }),
78
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleVerify, className: "space-y-4", noValidate: true, children: [
79
+ /* @__PURE__ */ jsx(
80
+ "input",
81
+ {
82
+ type: "text",
83
+ inputMode: "numeric",
84
+ pattern: "[0-9]*",
85
+ maxLength: 6,
86
+ value: otp,
87
+ onChange: (e) => setOtp(e.target.value.replace(/\D/g, "")),
88
+ placeholder: "000000",
89
+ required: true,
90
+ disabled: isVerifying,
91
+ autoComplete: "one-time-code",
92
+ className: "flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-lg tracking-[0.4em] font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx(
96
+ "button",
97
+ {
98
+ type: "submit",
99
+ disabled: isVerifying || otp.length < 6,
100
+ className: "inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
101
+ children: isVerifying ? "Verifying..." : "Verify email"
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsx(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ onClick: handleResend,
109
+ disabled: isResending,
110
+ className: "inline-flex h-11 w-full items-center justify-center rounded-md border border-input bg-background px-4 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",
111
+ children: isResending ? "Sending..." : "Resend code"
112
+ }
113
+ )
114
+ ] }),
115
+ /* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-muted-foreground", children: [
116
+ "Already verified?",
117
+ " ",
118
+ /* @__PURE__ */ jsx(
119
+ "a",
120
+ {
121
+ href: "/login",
122
+ className: "font-medium text-foreground underline underline-offset-4 hover:text-foreground/80",
123
+ children: "Sign in"
124
+ }
125
+ )
126
+ ] })
127
+ ] });
128
+ }
129
+
130
+ // src/components/forgot-password-form.tsx
131
+ import { useState as useState2 } from "react";
132
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
133
+ function ForgotPasswordForm({
134
+ onSuccess,
135
+ loginUrl = "/login",
136
+ authClient
137
+ }) {
138
+ const [email, setEmail] = useState2("");
139
+ const [error, setError] = useState2();
140
+ const [isPending, setIsPending] = useState2(false);
141
+ const handleSubmit = async (e) => {
142
+ e.preventDefault();
143
+ if (!email.trim()) {
144
+ setError("Please enter your email address");
145
+ return;
146
+ }
147
+ setError(void 0);
148
+ setIsPending(true);
149
+ try {
150
+ const res = await authClient.emailOtp.sendVerificationOtp({
151
+ email,
152
+ type: "forget-password"
153
+ });
154
+ if (res?.error) {
155
+ setError(res.error.message ?? "Failed to send reset code");
156
+ return;
157
+ }
158
+ onSuccess?.(email);
159
+ } catch (err) {
160
+ setError(err instanceof Error ? err.message : "Failed to send reset code");
161
+ } finally {
162
+ setIsPending(false);
163
+ }
164
+ };
165
+ return /* @__PURE__ */ jsxs2("div", { className: "space-y-8", children: [
166
+ /* @__PURE__ */ jsxs2("div", { children: [
167
+ /* @__PURE__ */ jsx2("h1", { className: "text-2xl font-bold tracking-tight", children: "Forgot your password?" }),
168
+ /* @__PURE__ */ jsx2("p", { className: "mt-1 text-sm text-muted-foreground", children: "Enter your email address and we'll send you a code to reset your password." })
169
+ ] }),
170
+ error && /* @__PURE__ */ jsx2("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
171
+ /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
172
+ /* @__PURE__ */ jsx2(
173
+ "input",
174
+ {
175
+ type: "email",
176
+ value: email,
177
+ onChange: (e) => setEmail(e.target.value),
178
+ placeholder: "Email address",
179
+ required: true,
180
+ disabled: isPending,
181
+ autoComplete: "email",
182
+ className: "flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed"
183
+ }
184
+ ),
185
+ /* @__PURE__ */ jsx2(
186
+ "button",
187
+ {
188
+ type: "submit",
189
+ disabled: isPending || !email.trim(),
190
+ className: "inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
191
+ children: isPending ? "Sending..." : "Send reset code"
192
+ }
193
+ )
194
+ ] }),
195
+ /* @__PURE__ */ jsxs2("p", { className: "text-center text-sm text-muted-foreground", children: [
196
+ "Remember your password?",
197
+ " ",
198
+ /* @__PURE__ */ jsx2(
199
+ "a",
200
+ {
201
+ href: loginUrl,
202
+ className: "font-medium text-foreground underline underline-offset-4 hover:text-foreground/80",
203
+ children: "Sign in"
204
+ }
205
+ )
206
+ ] })
207
+ ] });
208
+ }
209
+
210
+ // src/components/reset-password-form.tsx
211
+ import { useState as useState3 } from "react";
212
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
213
+ function ResetPasswordForm({
214
+ email,
215
+ onSuccess,
216
+ loginUrl = "/login",
217
+ authClient
218
+ }) {
219
+ const [otp, setOtp] = useState3("");
220
+ const [password, setPassword] = useState3("");
221
+ const [confirmPassword, setConfirmPassword] = useState3("");
222
+ const [error, setError] = useState3();
223
+ const [isResetting, setIsResetting] = useState3(false);
224
+ const [isResending, setIsResending] = useState3(false);
225
+ const [resendMessage, setResendMessage] = useState3();
226
+ const handleSubmit = async (e) => {
227
+ e.preventDefault();
228
+ if (!otp.trim() || otp.length < 6) {
229
+ setError("Please enter the 6-digit code");
230
+ return;
231
+ }
232
+ if (password.length < 8) {
233
+ setError("Password must be at least 8 characters");
234
+ return;
235
+ }
236
+ if (password !== confirmPassword) {
237
+ setError("Passwords do not match");
238
+ return;
239
+ }
240
+ setError(void 0);
241
+ setIsResetting(true);
242
+ try {
243
+ const res = await fetch("/api/auth/email-otp/reset-password", {
244
+ method: "POST",
245
+ headers: { "Content-Type": "application/json" },
246
+ body: JSON.stringify({ email, otp, password })
247
+ });
248
+ if (!res.ok) {
249
+ const body = await res.json().catch(() => null);
250
+ setError(body?.message ?? "Failed to reset password");
251
+ return;
252
+ }
253
+ onSuccess?.();
254
+ } catch (err) {
255
+ setError(
256
+ err instanceof Error ? err.message : "Failed to reset password"
257
+ );
258
+ } finally {
259
+ setIsResetting(false);
260
+ }
261
+ };
262
+ const handleResend = async () => {
263
+ setError(void 0);
264
+ setResendMessage(void 0);
265
+ setIsResending(true);
266
+ try {
267
+ await authClient.emailOtp.sendVerificationOtp({
268
+ email,
269
+ type: "forget-password"
270
+ });
271
+ setResendMessage("A new code has been sent to your inbox.");
272
+ } catch (err) {
273
+ setError(err instanceof Error ? err.message : "Failed to resend code.");
274
+ } finally {
275
+ setIsResending(false);
276
+ }
277
+ };
278
+ return /* @__PURE__ */ jsxs3("div", { className: "space-y-8", children: [
279
+ /* @__PURE__ */ jsxs3("div", { children: [
280
+ /* @__PURE__ */ jsx3("h1", { className: "text-2xl font-bold tracking-tight", children: "Reset your password" }),
281
+ /* @__PURE__ */ jsxs3("p", { className: "mt-1 text-sm text-muted-foreground", children: [
282
+ "Enter the 6-digit code sent to",
283
+ " ",
284
+ /* @__PURE__ */ jsx3("span", { className: "font-medium text-foreground", children: email }),
285
+ " and your new password."
286
+ ] })
287
+ ] }),
288
+ error && /* @__PURE__ */ jsx3("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
289
+ resendMessage && /* @__PURE__ */ jsx3("div", { className: "rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700", children: resendMessage }),
290
+ /* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
291
+ /* @__PURE__ */ jsx3(
292
+ "input",
293
+ {
294
+ type: "text",
295
+ inputMode: "numeric",
296
+ pattern: "[0-9]*",
297
+ maxLength: 6,
298
+ value: otp,
299
+ onChange: (e) => setOtp(e.target.value.replace(/\D/g, "")),
300
+ placeholder: "000000",
301
+ required: true,
302
+ disabled: isResetting,
303
+ autoComplete: "one-time-code",
304
+ className: "flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-lg tracking-[0.4em] font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed"
305
+ }
306
+ ),
307
+ /* @__PURE__ */ jsx3(
308
+ "input",
309
+ {
310
+ type: "password",
311
+ value: password,
312
+ onChange: (e) => setPassword(e.target.value),
313
+ placeholder: "New password",
314
+ required: true,
315
+ disabled: isResetting,
316
+ autoComplete: "new-password",
317
+ className: "flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed"
318
+ }
319
+ ),
320
+ /* @__PURE__ */ jsx3(
321
+ "input",
322
+ {
323
+ type: "password",
324
+ value: confirmPassword,
325
+ onChange: (e) => setConfirmPassword(e.target.value),
326
+ placeholder: "Confirm new password",
327
+ required: true,
328
+ disabled: isResetting,
329
+ autoComplete: "new-password",
330
+ className: "flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed"
331
+ }
332
+ ),
333
+ /* @__PURE__ */ jsx3(
334
+ "button",
335
+ {
336
+ type: "submit",
337
+ disabled: isResetting || otp.length < 6 || !password,
338
+ className: "inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
339
+ children: isResetting ? "Resetting..." : "Reset password"
340
+ }
341
+ ),
342
+ /* @__PURE__ */ jsx3(
343
+ "button",
344
+ {
345
+ type: "button",
346
+ onClick: handleResend,
347
+ disabled: isResending,
348
+ className: "inline-flex h-11 w-full items-center justify-center rounded-md border border-input bg-background px-4 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",
349
+ children: isResending ? "Sending..." : "Resend code"
350
+ }
351
+ )
352
+ ] }),
353
+ /* @__PURE__ */ jsxs3("p", { className: "text-center text-sm text-muted-foreground", children: [
354
+ "Remember your password?",
355
+ " ",
356
+ /* @__PURE__ */ jsx3(
357
+ "a",
358
+ {
359
+ href: loginUrl,
360
+ className: "font-medium text-foreground underline underline-offset-4 hover:text-foreground/80",
361
+ children: "Sign in"
362
+ }
363
+ )
364
+ ] })
365
+ ] });
366
+ }
367
+
368
+ // src/components/auth-layout.tsx
369
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
370
+ function AuthLayout({
371
+ logo,
372
+ title,
373
+ subtitle,
374
+ children,
375
+ footer
376
+ }) {
377
+ return /* @__PURE__ */ jsx4("div", { className: "flex min-h-screen items-center justify-center bg-background", children: /* @__PURE__ */ jsxs4("div", { className: "w-full max-w-md", children: [
378
+ /* @__PURE__ */ jsxs4("div", { className: "mb-10 text-center", children: [
379
+ logo && /* @__PURE__ */ jsx4("div", { className: "mb-6 flex justify-center", children: logo }),
380
+ /* @__PURE__ */ jsx4("h1", { className: "text-[32px] font-light tracking-tight", children: title }),
381
+ subtitle && /* @__PURE__ */ jsx4("p", { className: "mt-2 text-sm text-muted-foreground", children: subtitle })
382
+ ] }),
383
+ /* @__PURE__ */ jsx4("div", { className: "rounded-xl border bg-card p-8 shadow-sm", children }),
384
+ footer && /* @__PURE__ */ jsx4("div", { className: "mt-6 text-center text-xs text-muted-foreground", children: footer })
385
+ ] }) });
386
+ }
387
+ export {
388
+ AuthLayout,
389
+ ForgotPasswordForm,
390
+ ResetPasswordForm,
391
+ VerifyEmailForm,
392
+ useLogout,
393
+ useSession
394
+ };
395
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-session.ts","../src/components/verify-email-form.tsx","../src/components/forgot-password-form.tsx","../src/components/reset-password-form.tsx","../src/components/auth-layout.tsx"],"sourcesContent":["import type { PlatformAuthClient } from \"../client\"\n\n/**\n * Returns a useSession hook bound to the given auth client.\n * Usage: const { data: session, isPending } = useSession(authClient)\n */\nexport function useSession(authClient: PlatformAuthClient) {\n return authClient.useSession()\n}\n\n/**\n * Returns a logout function bound to the given auth client.\n * Usage: const logout = useLogout(authClient)\n */\nexport function useLogout(authClient: PlatformAuthClient) {\n const signOut = async () => {\n await authClient.signOut()\n }\n return signOut\n}\n","import { useState, type FormEvent } from \"react\"\nimport type { VerifyEmailFormProps } from \"../types\"\n\nexport function VerifyEmailForm({\n email,\n onSuccess,\n authClient,\n}: VerifyEmailFormProps) {\n const [otp, setOtp] = useState(\"\")\n const [isVerifying, setIsVerifying] = useState(false)\n const [isResending, setIsResending] = useState(false)\n const [resendMessage, setResendMessage] = useState<string | undefined>()\n const [error, setError] = useState<string | undefined>()\n\n const handleVerify = async (e: FormEvent) => {\n e.preventDefault()\n if (!otp.trim() || otp.length < 6) {\n setError(\"Please enter the 6-digit code\")\n return\n }\n setError(undefined)\n setIsVerifying(true)\n try {\n const res = await authClient.emailOtp.verifyEmail({ email, otp })\n console.log(\"[verify-email] response:\", JSON.stringify(res?.data), \"error:\", JSON.stringify(res?.error))\n if (res?.error) {\n setError(res.error.message ?? \"Invalid code. Please try again.\")\n return\n }\n onSuccess?.()\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Invalid code. Please try again.\")\n } finally {\n setIsVerifying(false)\n }\n }\n\n const handleResend = async () => {\n if (!email) {\n setError(\"Email address is not available. Please register again.\")\n return\n }\n setError(undefined)\n setResendMessage(undefined)\n setIsResending(true)\n try {\n await authClient.emailOtp.sendVerificationOtp({\n email,\n type: \"email-verification\",\n })\n setResendMessage(\"A new code has been sent to your inbox.\")\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Failed to resend code.\")\n } finally {\n setIsResending(false)\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">\n Verify your email\n </h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n {email ? (\n <>\n Enter the 6-digit code sent to{\" \"}\n <span className=\"font-medium text-foreground\">{email}</span>\n </>\n ) : (\n \"Enter the 6-digit code sent to your email\"\n )}\n </p>\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive\">\n {error}\n </div>\n )}\n\n {resendMessage && (\n <div className=\"rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700\">\n {resendMessage}\n </div>\n )}\n\n <form onSubmit={handleVerify} className=\"space-y-4\" noValidate>\n <input\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={6}\n value={otp}\n onChange={(e) => setOtp(e.target.value.replace(/\\D/g, \"\"))}\n placeholder=\"000000\"\n required\n disabled={isVerifying}\n autoComplete=\"one-time-code\"\n className=\"flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-lg tracking-[0.4em] font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n\n <button\n type=\"submit\"\n disabled={isVerifying || otp.length < 6}\n className=\"inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {isVerifying ? \"Verifying...\" : \"Verify email\"}\n </button>\n\n <button\n type=\"button\"\n onClick={handleResend}\n disabled={isResending}\n className=\"inline-flex h-11 w-full items-center justify-center rounded-md border border-input bg-background px-4 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50\"\n >\n {isResending ? \"Sending...\" : \"Resend code\"}\n </button>\n </form>\n\n <p className=\"text-center text-sm text-muted-foreground\">\n Already verified?{\" \"}\n <a\n href=\"/login\"\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n Sign in\n </a>\n </p>\n </div>\n )\n}\n","import { useState, type FormEvent } from \"react\"\nimport type { ForgotPasswordFormProps } from \"../types\"\n\nexport function ForgotPasswordForm({\n onSuccess,\n loginUrl = \"/login\",\n authClient,\n}: ForgotPasswordFormProps) {\n const [email, setEmail] = useState(\"\")\n const [error, setError] = useState<string | undefined>()\n const [isPending, setIsPending] = useState(false)\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault()\n if (!email.trim()) {\n setError(\"Please enter your email address\")\n return\n }\n setError(undefined)\n setIsPending(true)\n try {\n const res = await authClient.emailOtp.sendVerificationOtp({\n email,\n type: \"forget-password\",\n })\n if (res?.error) {\n setError(res.error.message ?? \"Failed to send reset code\")\n return\n }\n onSuccess?.(email)\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Failed to send reset code\")\n } finally {\n setIsPending(false)\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">\n Forgot your password?\n </h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n Enter your email address and we'll send you a code to reset your\n password.\n </p>\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive\">\n {error}\n </div>\n )}\n\n <form onSubmit={handleSubmit} className=\"space-y-4\" noValidate>\n <input\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder=\"Email address\"\n required\n disabled={isPending}\n autoComplete=\"email\"\n className=\"flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n\n <button\n type=\"submit\"\n disabled={isPending || !email.trim()}\n className=\"inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {isPending ? \"Sending...\" : \"Send reset code\"}\n </button>\n </form>\n\n <p className=\"text-center text-sm text-muted-foreground\">\n Remember your password?{\" \"}\n <a\n href={loginUrl}\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n Sign in\n </a>\n </p>\n </div>\n )\n}\n","import { useState, type FormEvent } from \"react\"\nimport type { ResetPasswordFormProps } from \"../types\"\n\nexport function ResetPasswordForm({\n email,\n onSuccess,\n loginUrl = \"/login\",\n authClient,\n}: ResetPasswordFormProps) {\n const [otp, setOtp] = useState(\"\")\n const [password, setPassword] = useState(\"\")\n const [confirmPassword, setConfirmPassword] = useState(\"\")\n const [error, setError] = useState<string | undefined>()\n const [isResetting, setIsResetting] = useState(false)\n const [isResending, setIsResending] = useState(false)\n const [resendMessage, setResendMessage] = useState<string | undefined>()\n\n const handleSubmit = async (e: FormEvent) => {\n e.preventDefault()\n if (!otp.trim() || otp.length < 6) {\n setError(\"Please enter the 6-digit code\")\n return\n }\n if (password.length < 8) {\n setError(\"Password must be at least 8 characters\")\n return\n }\n if (password !== confirmPassword) {\n setError(\"Passwords do not match\")\n return\n }\n setError(undefined)\n setIsResetting(true)\n try {\n const res = await fetch(\"/api/auth/email-otp/reset-password\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ email, otp, password }),\n })\n if (!res.ok) {\n const body = await res.json().catch(() => null)\n setError(body?.message ?? \"Failed to reset password\")\n return\n }\n onSuccess?.()\n } catch (err) {\n setError(\n err instanceof Error ? err.message : \"Failed to reset password\",\n )\n } finally {\n setIsResetting(false)\n }\n }\n\n const handleResend = async () => {\n setError(undefined)\n setResendMessage(undefined)\n setIsResending(true)\n try {\n await authClient.emailOtp.sendVerificationOtp({\n email,\n type: \"forget-password\",\n })\n setResendMessage(\"A new code has been sent to your inbox.\")\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Failed to resend code.\")\n } finally {\n setIsResending(false)\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">\n Reset your password\n </h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n Enter the 6-digit code sent to{\" \"}\n <span className=\"font-medium text-foreground\">{email}</span> and your\n new password.\n </p>\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive\">\n {error}\n </div>\n )}\n\n {resendMessage && (\n <div className=\"rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700\">\n {resendMessage}\n </div>\n )}\n\n <form onSubmit={handleSubmit} className=\"space-y-4\" noValidate>\n <input\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={6}\n value={otp}\n onChange={(e) => setOtp(e.target.value.replace(/\\D/g, \"\"))}\n placeholder=\"000000\"\n required\n disabled={isResetting}\n autoComplete=\"one-time-code\"\n className=\"flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-lg tracking-[0.4em] font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n\n <input\n type=\"password\"\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n placeholder=\"New password\"\n required\n disabled={isResetting}\n autoComplete=\"new-password\"\n className=\"flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n\n <input\n type=\"password\"\n value={confirmPassword}\n onChange={(e) => setConfirmPassword(e.target.value)}\n placeholder=\"Confirm new password\"\n required\n disabled={isResetting}\n autoComplete=\"new-password\"\n className=\"flex h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n\n <button\n type=\"submit\"\n disabled={isResetting || otp.length < 6 || !password}\n className=\"inline-flex h-11 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {isResetting ? \"Resetting...\" : \"Reset password\"}\n </button>\n\n <button\n type=\"button\"\n onClick={handleResend}\n disabled={isResending}\n className=\"inline-flex h-11 w-full items-center justify-center rounded-md border border-input bg-background px-4 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50\"\n >\n {isResending ? \"Sending...\" : \"Resend code\"}\n </button>\n </form>\n\n <p className=\"text-center text-sm text-muted-foreground\">\n Remember your password?{\" \"}\n <a\n href={loginUrl}\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n Sign in\n </a>\n </p>\n </div>\n )\n}\n","import type { AuthLayoutProps } from \"../types\"\n\nexport function AuthLayout({\n logo,\n title,\n subtitle,\n children,\n footer,\n}: AuthLayoutProps) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background\">\n <div className=\"w-full max-w-md\">\n <div className=\"mb-10 text-center\">\n {logo && <div className=\"mb-6 flex justify-center\">{logo}</div>}\n <h1 className=\"text-[32px] font-light tracking-tight\">{title}</h1>\n {subtitle && (\n <p className=\"mt-2 text-sm text-muted-foreground\">{subtitle}</p>\n )}\n </div>\n\n <div className=\"rounded-xl border bg-card p-8 shadow-sm\">\n {children}\n </div>\n\n {footer && (\n <div className=\"mt-6 text-center text-xs text-muted-foreground\">\n {footer}\n </div>\n )}\n </div>\n </div>\n )\n}\n"],"mappings":";AAMO,SAAS,WAAW,YAAgC;AACzD,SAAO,WAAW,WAAW;AAC/B;AAMO,SAAS,UAAU,YAAgC;AACxD,QAAM,UAAU,YAAY;AAC1B,UAAM,WAAW,QAAQ;AAAA,EAC3B;AACA,SAAO;AACT;;;ACnBA,SAAS,gBAAgC;AA6DjC,SAKI,UALJ,KAKI,YALJ;AA1DD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,KAAK,MAAM,IAAI,SAAS,EAAE;AACjC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAA6B;AACvE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA6B;AAEvD,QAAM,eAAe,OAAO,MAAiB;AAC3C,MAAE,eAAe;AACjB,QAAI,CAAC,IAAI,KAAK,KAAK,IAAI,SAAS,GAAG;AACjC,eAAS,+BAA+B;AACxC;AAAA,IACF;AACA,aAAS,MAAS;AAClB,mBAAe,IAAI;AACnB,QAAI;AACF,YAAM,MAAM,MAAM,WAAW,SAAS,YAAY,EAAE,OAAO,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AEC,UACC,gBAAAA,KAAC,SAAI,WAAU,kDACZ,kBACH;AAAA,KAEJ,GACF;AAEJ;","names":["useState","jsx","jsxs","useState","jsx","jsxs","jsx","jsxs"]}
@@ -0,0 +1,11 @@
1
+ import { Auth, BetterAuthOptions } from 'better-auth';
2
+ import { a as PlatformAuthConfig } from './types-CLsvniwT.js';
3
+
4
+ /**
5
+ * Creates a Better Auth instance with platform defaults.
6
+ * Each app calls this with its own config (DB, secret, providers, plugins).
7
+ */
8
+ declare function createPlatformAuth(config: PlatformAuthConfig): Auth<BetterAuthOptions>;
9
+ type PlatformAuth = ReturnType<typeof createPlatformAuth>;
10
+
11
+ export { type PlatformAuth, createPlatformAuth };
package/dist/server.js ADDED
@@ -0,0 +1,109 @@
1
+ // src/server.ts
2
+ import { betterAuth, APIError } from "better-auth";
3
+ import { emailOTP, admin } from "better-auth/plugins";
4
+ var DEFAULT_EMAIL_SUBJECTS = {
5
+ "email-verification": "Verify your account",
6
+ "forget-password": "Reset your password",
7
+ "sign-in": "Your sign-in code"
8
+ };
9
+ function defaultRenderOtpEmail(otp) {
10
+ return `
11
+ <div style="font-family:sans-serif;max-width:480px;margin:0 auto;padding:32px">
12
+ <h2 style="font-size:20px;font-weight:600;margin-bottom:16px">Your verification code</h2>
13
+ <p style="color:#555;margin-bottom:24px">Use the code below to continue. It expires in 5 minutes.</p>
14
+ <div style="background:#f5f5f5;border-radius:8px;padding:24px;text-align:center;letter-spacing:8px;font-size:32px;font-weight:700">
15
+ ${otp}
16
+ </div>
17
+ <p style="color:#999;font-size:12px;margin-top:24px">If you didn't request this, you can safely ignore this email.</p>
18
+ </div>
19
+ `;
20
+ }
21
+ function createPlatformAuth(config) {
22
+ const {
23
+ database,
24
+ baseURL,
25
+ secret,
26
+ appName,
27
+ mailer,
28
+ google,
29
+ github,
30
+ plugins = [],
31
+ betaMode = false,
32
+ isInvited,
33
+ emailSubjects,
34
+ renderOtpEmail
35
+ } = config;
36
+ const subjects = { ...DEFAULT_EMAIL_SUBJECTS, ...emailSubjects };
37
+ const renderEmail = renderOtpEmail ?? defaultRenderOtpEmail;
38
+ return betterAuth({
39
+ database,
40
+ baseURL,
41
+ secret,
42
+ emailAndPassword: {
43
+ enabled: true,
44
+ requireEmailVerification: true
45
+ },
46
+ hooks: {
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ before: async (ctx) => {
49
+ if (!betaMode) return;
50
+ if (ctx.path !== "/sign-up/email") return;
51
+ const body = ctx.body;
52
+ const email = body?.email;
53
+ const inviteToken = body?.inviteToken;
54
+ if (email && inviteToken && isInvited) {
55
+ const ok = await isInvited(email, inviteToken);
56
+ if (ok) return;
57
+ }
58
+ throw new APIError("FORBIDDEN", {
59
+ message: "Registration is invite-only during the private beta."
60
+ });
61
+ }
62
+ },
63
+ plugins: [
64
+ emailOTP({
65
+ async sendVerificationOTP({ email, otp, type }) {
66
+ const subject = subjects[type] ? `${subjects[type]} - ${appName}` : `Your ${appName} code`;
67
+ const html = renderEmail(otp, type);
68
+ if (mailer) {
69
+ await mailer({
70
+ to: email,
71
+ subject,
72
+ html,
73
+ type,
74
+ otp
75
+ });
76
+ return;
77
+ }
78
+ console.warn(
79
+ `[EMAIL] No mailer configured \u2014 logging OTP to stdout for ${email} (${type}): ${otp}`
80
+ );
81
+ },
82
+ otpLength: 6,
83
+ expiresIn: 300,
84
+ overrideDefaultEmailVerification: true
85
+ }),
86
+ admin(),
87
+ ...plugins
88
+ // app-specific plugins (e.g. tanstackStartCookies)
89
+ ],
90
+ socialProviders: {
91
+ ...google ? {
92
+ google: {
93
+ clientId: google.clientId,
94
+ clientSecret: google.clientSecret
95
+ }
96
+ } : {},
97
+ ...github ? {
98
+ github: {
99
+ clientId: github.clientId,
100
+ clientSecret: github.clientSecret
101
+ }
102
+ } : {}
103
+ }
104
+ });
105
+ }
106
+ export {
107
+ createPlatformAuth
108
+ };
109
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import { betterAuth, APIError, type Auth, type BetterAuthOptions } from \"better-auth\"\nimport { emailOTP, admin } from \"better-auth/plugins\"\nimport type { PlatformAuthConfig, PlatformAuthMailerType } from \"./types\"\n\nconst DEFAULT_EMAIL_SUBJECTS: Record<string, string> = {\n \"email-verification\": \"Verify your account\",\n \"forget-password\": \"Reset your password\",\n \"sign-in\": \"Your sign-in code\",\n}\n\nfunction defaultRenderOtpEmail(otp: string): string {\n return `\n <div style=\"font-family:sans-serif;max-width:480px;margin:0 auto;padding:32px\">\n <h2 style=\"font-size:20px;font-weight:600;margin-bottom:16px\">Your verification code</h2>\n <p style=\"color:#555;margin-bottom:24px\">Use the code below to continue. It expires in 5 minutes.</p>\n <div style=\"background:#f5f5f5;border-radius:8px;padding:24px;text-align:center;letter-spacing:8px;font-size:32px;font-weight:700\">\n ${otp}\n </div>\n <p style=\"color:#999;font-size:12px;margin-top:24px\">If you didn't request this, you can safely ignore this email.</p>\n </div>\n `\n}\n\n/**\n * Creates a Better Auth instance with platform defaults.\n * Each app calls this with its own config (DB, secret, providers, plugins).\n */\nexport function createPlatformAuth(\n config: PlatformAuthConfig,\n): Auth<BetterAuthOptions> {\n const {\n database,\n baseURL,\n secret,\n appName,\n mailer,\n google,\n github,\n plugins = [],\n betaMode = false,\n isInvited,\n emailSubjects,\n renderOtpEmail,\n } = config\n\n const subjects = { ...DEFAULT_EMAIL_SUBJECTS, ...emailSubjects }\n const renderEmail = renderOtpEmail ?? defaultRenderOtpEmail\n\n // The concrete instance type (with email-otp/admin plugins) is widened to\n // the base Auth type so the published .d.ts stays portable — consumers use\n // the standard auth API (handler, api.getSession, …), not plugin-inferred types.\n return betterAuth({\n database,\n baseURL,\n secret,\n emailAndPassword: {\n enabled: true,\n requireEmailVerification: true,\n },\n hooks: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n before: async (ctx: any) => {\n if (!betaMode) return\n if (ctx.path !== \"/sign-up/email\") return\n const body = ctx.body as { email?: string; inviteToken?: string } | undefined\n const email = body?.email\n const inviteToken = body?.inviteToken\n if (email && inviteToken && isInvited) {\n const ok = await isInvited(email, inviteToken)\n if (ok) return\n }\n throw new APIError(\"FORBIDDEN\", {\n message: \"Registration is invite-only during the private beta.\",\n })\n },\n },\n plugins: [\n emailOTP({\n async sendVerificationOTP({ email, otp, type }) {\n const subject = subjects[type]\n ? `${subjects[type]} - ${appName}`\n : `Your ${appName} code`\n const html = renderEmail(otp, type as PlatformAuthMailerType)\n\n if (mailer) {\n await mailer({\n to: email,\n subject,\n html,\n type: type as PlatformAuthMailerType,\n otp,\n })\n return\n }\n\n console.warn(\n `[EMAIL] No mailer configured — logging OTP to stdout for ${email} (${type}): ${otp}`,\n )\n },\n otpLength: 6,\n expiresIn: 300,\n overrideDefaultEmailVerification: true,\n }),\n admin(),\n ...plugins, // app-specific plugins (e.g. tanstackStartCookies)\n ],\n socialProviders: {\n ...(google\n ? {\n google: {\n clientId: google.clientId,\n clientSecret: google.clientSecret,\n },\n }\n : {}),\n ...(github\n ? {\n github: {\n clientId: github.clientId,\n clientSecret: github.clientSecret,\n },\n }\n : {}),\n },\n }) as unknown as Auth<BetterAuthOptions>\n}\n\nexport type PlatformAuth = ReturnType<typeof createPlatformAuth>\n"],"mappings":";AAAA,SAAS,YAAY,gBAAmD;AACxE,SAAS,UAAU,aAAa;AAGhC,IAAM,yBAAiD;AAAA,EACrD,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,WAAW;AACb;AAEA,SAAS,sBAAsB,KAAqB;AAClD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKW,GAAG;AAAA;AAAA;AAAA;AAAA;AAKvB;AAMO,SAAS,mBACd,QACyB;AACzB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,IACX,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI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jB,cAAc,OAAO;AAAA,QACvB;AAAA,MACF,IACA,CAAC;AAAA,MACL,GAAI,SACA;AAAA,QACE,QAAQ;AAAA,UACN,UAAU,OAAO;AAAA,UACjB,cAAc,OAAO;AAAA,QACvB;AAAA,MACF,IACA,CAAC;AAAA,IACP;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,109 @@
1
+ import { BetterAuthOptions } from 'better-auth';
2
+
3
+ type PlatformAuthMailerType = "email-verification" | "forget-password" | "sign-in" | "change-email";
4
+ interface PlatformAuthMailerArgs {
5
+ /** Recipient address */
6
+ to: string;
7
+ /** Pre-rendered subject line */
8
+ subject: string;
9
+ /** Pre-rendered HTML body */
10
+ html: string;
11
+ /** Better Auth verification kind */
12
+ type: PlatformAuthMailerType;
13
+ /** The OTP value, in case the consumer wants to render its own template */
14
+ otp: string;
15
+ }
16
+ type PlatformAuthMailer = (args: PlatformAuthMailerArgs) => Promise<void>;
17
+ interface PlatformAuthConfig {
18
+ /** PostgreSQL connection pool or connection string */
19
+ database: BetterAuthOptions["database"];
20
+ /** Base URL for Better Auth callbacks (e.g. http://localhost:3001) */
21
+ baseURL: string;
22
+ /** Secret for signing sessions */
23
+ secret: string;
24
+ /** Application name (used in emails) */
25
+ appName: string;
26
+ /**
27
+ * Transactional mailer. Receives the fully-rendered subject and HTML body
28
+ * and is responsible for pushing the message onto the wire (e.g. via the
29
+ * @digstack/spore-sdk, SES, postfix, …). When omitted, OTPs are logged to
30
+ * stdout — useful in dev/test, useless in production.
31
+ */
32
+ mailer?: PlatformAuthMailer;
33
+ /** Google OAuth config (omit to disable) */
34
+ google?: {
35
+ clientId: string;
36
+ clientSecret: string;
37
+ };
38
+ /** GitHub OAuth config (omit to disable) */
39
+ github?: {
40
+ clientId: string;
41
+ clientSecret: string;
42
+ };
43
+ /**
44
+ * Override the OTP email subject line per verification type. Merged over
45
+ * the platform defaults — provide only the keys you want to change. The
46
+ * resulting subject is suffixed with ` - ${appName}` like the defaults.
47
+ */
48
+ emailSubjects?: Partial<Record<PlatformAuthMailerType, string>>;
49
+ /**
50
+ * Override the OTP email HTML renderer. Receives the OTP code and the
51
+ * verification type, returns the HTML body. When omitted, the platform's
52
+ * default branded template is used.
53
+ */
54
+ renderOtpEmail?: (otp: string, type: PlatformAuthMailerType) => string;
55
+ /** Additional Better Auth plugins to append */
56
+ plugins?: BetterAuthOptions["plugins"];
57
+ /** Enable private beta mode (blocks public registration) */
58
+ betaMode?: boolean;
59
+ /** Check if an email+token pair has been invited (required when betaMode is true) */
60
+ isInvited?: (email: string, inviteToken: string) => Promise<boolean>;
61
+ }
62
+ interface PlatformAuthClientConfig {
63
+ /** Base URL override (defaults to window.location.origin in browser) */
64
+ baseURL?: string;
65
+ /** Additional client plugins */
66
+ plugins?: any[];
67
+ }
68
+ interface VerifyEmailFormProps {
69
+ /** Email to verify */
70
+ email: string;
71
+ /** Callback on successful verification */
72
+ onSuccess?: () => void;
73
+ /** URL to navigate to on success */
74
+ successUrl?: string;
75
+ /** Auth client instance */
76
+ authClient: any;
77
+ }
78
+ interface ForgotPasswordFormProps {
79
+ /** Callback on successful OTP send, receives the email */
80
+ onSuccess?: (email: string) => void;
81
+ /** Link to login page */
82
+ loginUrl?: string;
83
+ /** Auth client instance */
84
+ authClient: any;
85
+ }
86
+ interface ResetPasswordFormProps {
87
+ /** Email address to reset password for */
88
+ email: string;
89
+ /** Callback on successful password reset */
90
+ onSuccess?: () => void;
91
+ /** Link to login page */
92
+ loginUrl?: string;
93
+ /** Auth client instance */
94
+ authClient: any;
95
+ }
96
+ interface AuthLayoutProps {
97
+ /** Logo element to display at the top */
98
+ logo?: React.ReactNode;
99
+ /** Page title */
100
+ title: string;
101
+ /** Subtitle below the title */
102
+ subtitle?: string;
103
+ /** Content to render inside the card */
104
+ children: React.ReactNode;
105
+ /** Footer content below the card (e.g. legal links) */
106
+ footer?: React.ReactNode;
107
+ }
108
+
109
+ export type { AuthLayoutProps as A, ForgotPasswordFormProps as F, PlatformAuthClientConfig as P, ResetPasswordFormProps as R, VerifyEmailFormProps as V, PlatformAuthConfig as a, PlatformAuthMailer as b, PlatformAuthMailerArgs as c, PlatformAuthMailerType as d };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@lalternative/auth",
3
+ "version": "0.1.1",
4
+ "description": "Shared Better Auth wrapper for L'Alternative apps (server + React client + auth UI)",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./server": {
14
+ "import": "./dist/server.js",
15
+ "types": "./dist/server.d.ts"
16
+ },
17
+ "./client": {
18
+ "import": "./dist/client.js",
19
+ "types": "./dist/client.d.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "typecheck": "tsc --noEmit"
29
+ },
30
+ "peerDependencies": {
31
+ "better-auth": ">=1.4.0",
32
+ "react": ">=18.0.0",
33
+ "react-dom": ">=18.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^19.0.0",
37
+ "@types/react-dom": "^19.0.0",
38
+ "better-auth": "^1.6.11",
39
+ "react": "^19.0.0",
40
+ "react-dom": "^19.0.0",
41
+ "tsup": "^8.5.1",
42
+ "typescript": "^5.7.0",
43
+ "zod": "^4.4.3"
44
+ },
45
+ "publishConfig": {
46
+ "registry": "https://registry.npmjs.org",
47
+ "access": "public"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/lalternative/packages.git",
52
+ "directory": "auth"
53
+ }
54
+ }