@lalternative/auth 0.4.1 → 0.4.2
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 +3 -2
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.js +407 -74
- package/dist/index.js.map +1 -1
- package/dist/{invitation-DIZAb2BJ.d.ts → invitation-CzfLna7q.d.ts} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/{types-DKEKNQkL.d.ts → types-DxllDyOa.d.ts} +38 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Shared [Better Auth](https://better-auth.com) wrapper for L'Alternative apps.
|
|
4
4
|
|
|
5
5
|
Provides platform auth defaults (email-OTP + admin plugins), a React client,
|
|
6
|
-
and the auth UI forms (verify-email, forgot/reset password,
|
|
6
|
+
and the auth UI forms (login, register, verify-email, forgot/reset password,
|
|
7
|
+
auth layout).
|
|
7
8
|
|
|
8
9
|
## Install
|
|
9
10
|
|
|
@@ -32,7 +33,7 @@ export const authClient = createPlatformAuthClient({ baseURL })
|
|
|
32
33
|
|
|
33
34
|
```tsx
|
|
34
35
|
// UI + hooks
|
|
35
|
-
import { VerifyEmailForm, ForgotPasswordForm, ResetPasswordForm, AuthLayout, useSession, useLogout } from "@lalternative/auth"
|
|
36
|
+
import { LoginForm, RegisterForm, SocialButtons, VerifyEmailForm, ForgotPasswordForm, ResetPasswordForm, AuthLayout, useSession, useLogout } from "@lalternative/auth"
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
### Invitations
|
package/dist/client.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { V as VerifyEmailFormProps, F as ForgotPasswordFormProps,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LoginFormProps, R as RegisterFormProps, V as VerifyEmailFormProps, F as ForgotPasswordFormProps, a as ResetPasswordFormProps, A as AuthLayoutProps, I as InvitationNoticeProps } from './types-DxllDyOa.js';
|
|
2
|
+
export { b as InvitationFailure, P as PlatformAuthClientConfig, c as PlatformAuthConfig, d as PlatformAuthMailer, e as PlatformAuthMailerArgs, f as PlatformAuthMailerType, g as PlatformSession, h as PlatformSessionData, i as PlatformUser } from './types-DxllDyOa.js';
|
|
3
3
|
import * as better_auth_react from 'better-auth/react';
|
|
4
4
|
import * as better_auth from 'better-auth';
|
|
5
5
|
import { PlatformAuthClient } from './client.js';
|
|
6
6
|
import * as react from 'react';
|
|
7
|
-
export { C as ClaimOutcome, i as isInvitationFailure } from './invitation-
|
|
7
|
+
export { C as ClaimOutcome, i as isInvitationFailure } from './invitation-CzfLna7q.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns a useSession hook bound to the given auth client.
|
|
@@ -45,6 +45,17 @@ declare function useSession(authClient: PlatformAuthClient): {
|
|
|
45
45
|
*/
|
|
46
46
|
declare function useLogout(authClient: PlatformAuthClient): () => Promise<void>;
|
|
47
47
|
|
|
48
|
+
declare function LoginForm({ onSuccess, registerUrl, forgotPasswordUrl, socialCallbackUrl, socialProviders, coreTokenUrl, authClient, }: LoginFormProps): react.JSX.Element;
|
|
49
|
+
|
|
50
|
+
declare function RegisterForm({ onSuccess, loginUrl, legal, socialCallbackUrl, socialProviders, authClient, }: RegisterFormProps): react.JSX.Element;
|
|
51
|
+
|
|
52
|
+
interface SocialButtonsProps {
|
|
53
|
+
providers: Array<"google" | "github">;
|
|
54
|
+
onSelect: (provider: "google" | "github") => void | Promise<void>;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
}
|
|
57
|
+
declare function SocialButtons({ providers, onSelect, disabled, }: SocialButtonsProps): react.JSX.Element | null;
|
|
58
|
+
|
|
48
59
|
declare function VerifyEmailForm({ email, onSuccess, authClient, }: VerifyEmailFormProps): react.JSX.Element;
|
|
49
60
|
|
|
50
61
|
declare function ForgotPasswordForm({ onSuccess, loginUrl, authClient, }: ForgotPasswordFormProps): react.JSX.Element;
|
|
@@ -67,4 +78,4 @@ declare function AuthLayout({ logo, title, subtitle, children, footer, }: AuthLa
|
|
|
67
78
|
*/
|
|
68
79
|
declare function InvitationNotice({ reason, supportEmail, title, action, }: InvitationNoticeProps): react.JSX.Element;
|
|
69
80
|
|
|
70
|
-
export { AuthLayout, AuthLayoutProps, ForgotPasswordForm, ForgotPasswordFormProps, InvitationNotice, InvitationNoticeProps, ResetPasswordForm, ResetPasswordFormProps, VerifyEmailForm, VerifyEmailFormProps, useLogout, useSession };
|
|
81
|
+
export { AuthLayout, AuthLayoutProps, ForgotPasswordForm, ForgotPasswordFormProps, InvitationNotice, InvitationNoticeProps, LoginForm, LoginFormProps, RegisterForm, RegisterFormProps, ResetPasswordForm, ResetPasswordFormProps, SocialButtons, VerifyEmailForm, VerifyEmailFormProps, useLogout, useSession };
|
package/dist/index.js
CHANGED
|
@@ -13,19 +13,349 @@ function useLogout(authClient) {
|
|
|
13
13
|
return signOut;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// src/components/
|
|
16
|
+
// src/components/login-form.tsx
|
|
17
17
|
import { useState } from "react";
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
// src/components/social-buttons.tsx
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var LABELS = {
|
|
22
|
+
google: "Continue with Google",
|
|
23
|
+
github: "Continue with GitHub"
|
|
24
|
+
};
|
|
25
|
+
function SocialButtons({
|
|
26
|
+
providers,
|
|
27
|
+
onSelect,
|
|
28
|
+
disabled = false
|
|
29
|
+
}) {
|
|
30
|
+
if (providers.length === 0) return null;
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ jsx("div", { className: "w-full border-t border-input" }) }),
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: "relative flex justify-center", children: /* @__PURE__ */ jsx("span", { className: "bg-background px-2 text-xs uppercase tracking-wider text-muted-foreground", children: "or" }) })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: providers.map((provider) => /* @__PURE__ */ jsx(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: () => onSelect(provider),
|
|
41
|
+
disabled,
|
|
42
|
+
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",
|
|
43
|
+
children: LABELS[provider] ?? provider
|
|
44
|
+
},
|
|
45
|
+
provider
|
|
46
|
+
)) })
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/components/login-form.tsx
|
|
51
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
52
|
+
function oauthErrorMessage(code) {
|
|
53
|
+
switch (code) {
|
|
54
|
+
case "account_not_linked":
|
|
55
|
+
return "This email is already registered with a password. Sign in with your password instead.";
|
|
56
|
+
case "access_denied":
|
|
57
|
+
return "Sign-in was cancelled.";
|
|
58
|
+
default:
|
|
59
|
+
return "Sign-in failed. Please try again.";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function LoginForm({
|
|
63
|
+
onSuccess,
|
|
64
|
+
registerUrl = "/register",
|
|
65
|
+
forgotPasswordUrl = "/forgot-password",
|
|
66
|
+
socialCallbackUrl = "/",
|
|
67
|
+
socialProviders = [],
|
|
68
|
+
coreTokenUrl = "/api/auth/core-token",
|
|
69
|
+
authClient
|
|
70
|
+
}) {
|
|
71
|
+
const [email, setEmail] = useState("");
|
|
72
|
+
const [password, setPassword] = useState("");
|
|
73
|
+
const [error, setError] = useState();
|
|
74
|
+
const [isPending, setIsPending] = useState(false);
|
|
75
|
+
const handleSubmit = async (e) => {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
if (!email.trim()) {
|
|
78
|
+
setError("Please enter your email address");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!password) {
|
|
82
|
+
setError("Please enter your password");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setError(void 0);
|
|
86
|
+
setIsPending(true);
|
|
87
|
+
try {
|
|
88
|
+
const res = await authClient.signIn.email({
|
|
89
|
+
email: email.trim(),
|
|
90
|
+
password
|
|
91
|
+
});
|
|
92
|
+
if (res?.error) {
|
|
93
|
+
setError(res.error.message ?? "Invalid email or password");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (coreTokenUrl) {
|
|
97
|
+
await fetch(coreTokenUrl, { credentials: "include" });
|
|
98
|
+
}
|
|
99
|
+
onSuccess?.();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
setError(err instanceof Error ? err.message : "Invalid email or password");
|
|
102
|
+
} finally {
|
|
103
|
+
setIsPending(false);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const handleSocial = async (provider) => {
|
|
107
|
+
setError(void 0);
|
|
108
|
+
try {
|
|
109
|
+
await authClient.signIn.social({
|
|
110
|
+
provider,
|
|
111
|
+
callbackURL: socialCallbackUrl
|
|
112
|
+
});
|
|
113
|
+
} catch (err) {
|
|
114
|
+
setError(
|
|
115
|
+
err instanceof Error ? oauthErrorMessage(err.message) : oauthErrorMessage("")
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return /* @__PURE__ */ jsxs2("div", { className: "space-y-8", children: [
|
|
120
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
121
|
+
/* @__PURE__ */ jsx2("h1", { className: "text-2xl font-bold tracking-tight", children: "Sign in" }),
|
|
122
|
+
/* @__PURE__ */ jsx2("p", { className: "mt-1 text-sm text-muted-foreground", children: "Welcome back. Enter your credentials to continue." })
|
|
123
|
+
] }),
|
|
124
|
+
error && /* @__PURE__ */ jsx2("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
|
|
125
|
+
/* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
|
|
126
|
+
/* @__PURE__ */ jsx2(
|
|
127
|
+
"input",
|
|
128
|
+
{
|
|
129
|
+
type: "email",
|
|
130
|
+
value: email,
|
|
131
|
+
onChange: (e) => setEmail(e.target.value),
|
|
132
|
+
placeholder: "Email address",
|
|
133
|
+
required: true,
|
|
134
|
+
disabled: isPending,
|
|
135
|
+
autoComplete: "email",
|
|
136
|
+
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"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
|
|
140
|
+
/* @__PURE__ */ jsx2(
|
|
141
|
+
"input",
|
|
142
|
+
{
|
|
143
|
+
type: "password",
|
|
144
|
+
value: password,
|
|
145
|
+
onChange: (e) => setPassword(e.target.value),
|
|
146
|
+
placeholder: "Password",
|
|
147
|
+
required: true,
|
|
148
|
+
disabled: isPending,
|
|
149
|
+
autoComplete: "current-password",
|
|
150
|
+
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"
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsx2("div", { className: "text-right", children: /* @__PURE__ */ jsx2(
|
|
154
|
+
"a",
|
|
155
|
+
{
|
|
156
|
+
href: forgotPasswordUrl,
|
|
157
|
+
className: "text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground",
|
|
158
|
+
children: "Forgot your password?"
|
|
159
|
+
}
|
|
160
|
+
) })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ jsx2(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "submit",
|
|
166
|
+
disabled: isPending || !email.trim() || !password,
|
|
167
|
+
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",
|
|
168
|
+
children: isPending ? "Signing in..." : "Sign in"
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ jsx2(
|
|
173
|
+
SocialButtons,
|
|
174
|
+
{
|
|
175
|
+
providers: socialProviders,
|
|
176
|
+
onSelect: handleSocial,
|
|
177
|
+
disabled: isPending
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
/* @__PURE__ */ jsxs2("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
181
|
+
"Don't have an account?",
|
|
182
|
+
" ",
|
|
183
|
+
/* @__PURE__ */ jsx2(
|
|
184
|
+
"a",
|
|
185
|
+
{
|
|
186
|
+
href: registerUrl,
|
|
187
|
+
className: "font-medium text-foreground underline underline-offset-4 hover:text-foreground/80",
|
|
188
|
+
children: "Sign up"
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
] })
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/components/register-form.tsx
|
|
196
|
+
import { useState as useState2 } from "react";
|
|
197
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
198
|
+
var MIN_PASSWORD_LENGTH = 8;
|
|
199
|
+
function RegisterForm({
|
|
200
|
+
onSuccess,
|
|
201
|
+
loginUrl = "/login",
|
|
202
|
+
legal,
|
|
203
|
+
socialCallbackUrl = "/",
|
|
204
|
+
socialProviders = [],
|
|
205
|
+
authClient
|
|
206
|
+
}) {
|
|
207
|
+
const [name, setName] = useState2("");
|
|
208
|
+
const [email, setEmail] = useState2("");
|
|
209
|
+
const [password, setPassword] = useState2("");
|
|
210
|
+
const [error, setError] = useState2();
|
|
211
|
+
const [isPending, setIsPending] = useState2(false);
|
|
212
|
+
const handleSubmit = async (e) => {
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
if (!name.trim()) {
|
|
215
|
+
setError("Please enter your name");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (!email.trim()) {
|
|
219
|
+
setError("Please enter your email address");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
223
|
+
setError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters`);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
setError(void 0);
|
|
227
|
+
setIsPending(true);
|
|
228
|
+
try {
|
|
229
|
+
const res = await authClient.signUp.email({
|
|
230
|
+
name: name.trim(),
|
|
231
|
+
email: email.trim(),
|
|
232
|
+
password
|
|
233
|
+
});
|
|
234
|
+
if (res?.error) {
|
|
235
|
+
setError(res.error.message ?? "Could not create your account");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
onSuccess?.(email.trim());
|
|
239
|
+
} catch (err) {
|
|
240
|
+
setError(
|
|
241
|
+
err instanceof Error ? err.message : "Could not create your account"
|
|
242
|
+
);
|
|
243
|
+
} finally {
|
|
244
|
+
setIsPending(false);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const handleSocial = async (provider) => {
|
|
248
|
+
setError(void 0);
|
|
249
|
+
try {
|
|
250
|
+
await authClient.signIn.social({
|
|
251
|
+
provider,
|
|
252
|
+
callbackURL: socialCallbackUrl
|
|
253
|
+
});
|
|
254
|
+
} catch (err) {
|
|
255
|
+
setError(err instanceof Error ? err.message : "Sign-up failed");
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return /* @__PURE__ */ jsxs3("div", { className: "space-y-8", children: [
|
|
259
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
260
|
+
/* @__PURE__ */ jsx3("h1", { className: "text-2xl font-bold tracking-tight", children: "Create an account" }),
|
|
261
|
+
/* @__PURE__ */ jsx3("p", { className: "mt-1 text-sm text-muted-foreground", children: "We'll send you a code to confirm your email address." })
|
|
262
|
+
] }),
|
|
263
|
+
error && /* @__PURE__ */ jsx3("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
|
|
264
|
+
/* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
|
|
265
|
+
/* @__PURE__ */ jsx3(
|
|
266
|
+
"input",
|
|
267
|
+
{
|
|
268
|
+
type: "text",
|
|
269
|
+
value: name,
|
|
270
|
+
onChange: (e) => setName(e.target.value),
|
|
271
|
+
placeholder: "Full name",
|
|
272
|
+
required: true,
|
|
273
|
+
disabled: isPending,
|
|
274
|
+
autoComplete: "name",
|
|
275
|
+
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"
|
|
276
|
+
}
|
|
277
|
+
),
|
|
278
|
+
/* @__PURE__ */ jsx3(
|
|
279
|
+
"input",
|
|
280
|
+
{
|
|
281
|
+
type: "email",
|
|
282
|
+
value: email,
|
|
283
|
+
onChange: (e) => setEmail(e.target.value),
|
|
284
|
+
placeholder: "Email address",
|
|
285
|
+
required: true,
|
|
286
|
+
disabled: isPending,
|
|
287
|
+
autoComplete: "email",
|
|
288
|
+
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"
|
|
289
|
+
}
|
|
290
|
+
),
|
|
291
|
+
/* @__PURE__ */ jsxs3("div", { className: "space-y-1", children: [
|
|
292
|
+
/* @__PURE__ */ jsx3(
|
|
293
|
+
"input",
|
|
294
|
+
{
|
|
295
|
+
type: "password",
|
|
296
|
+
value: password,
|
|
297
|
+
onChange: (e) => setPassword(e.target.value),
|
|
298
|
+
placeholder: "Password",
|
|
299
|
+
required: true,
|
|
300
|
+
disabled: isPending,
|
|
301
|
+
autoComplete: "new-password",
|
|
302
|
+
"aria-describedby": "register-password-hint",
|
|
303
|
+
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"
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
/* @__PURE__ */ jsxs3("p", { id: "register-password-hint", className: "text-xs text-muted-foreground", children: [
|
|
307
|
+
"At least ",
|
|
308
|
+
MIN_PASSWORD_LENGTH,
|
|
309
|
+
" characters."
|
|
310
|
+
] })
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ jsx3(
|
|
313
|
+
"button",
|
|
314
|
+
{
|
|
315
|
+
type: "submit",
|
|
316
|
+
disabled: isPending,
|
|
317
|
+
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",
|
|
318
|
+
children: isPending ? "Creating account..." : "Create account"
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
legal && /* @__PURE__ */ jsx3("div", { className: "text-center text-xs text-muted-foreground", children: legal })
|
|
322
|
+
] }),
|
|
323
|
+
/* @__PURE__ */ jsx3(
|
|
324
|
+
SocialButtons,
|
|
325
|
+
{
|
|
326
|
+
providers: socialProviders,
|
|
327
|
+
onSelect: handleSocial,
|
|
328
|
+
disabled: isPending
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ jsxs3("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
332
|
+
"Already have an account?",
|
|
333
|
+
" ",
|
|
334
|
+
/* @__PURE__ */ jsx3(
|
|
335
|
+
"a",
|
|
336
|
+
{
|
|
337
|
+
href: loginUrl,
|
|
338
|
+
className: "font-medium text-foreground underline underline-offset-4 hover:text-foreground/80",
|
|
339
|
+
children: "Sign in"
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
] })
|
|
343
|
+
] });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/components/verify-email-form.tsx
|
|
347
|
+
import { useState as useState3 } from "react";
|
|
348
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
19
349
|
function VerifyEmailForm({
|
|
20
350
|
email,
|
|
21
351
|
onSuccess,
|
|
22
352
|
authClient
|
|
23
353
|
}) {
|
|
24
|
-
const [otp, setOtp] =
|
|
25
|
-
const [isVerifying, setIsVerifying] =
|
|
26
|
-
const [isResending, setIsResending] =
|
|
27
|
-
const [resendMessage, setResendMessage] =
|
|
28
|
-
const [error, setError] =
|
|
354
|
+
const [otp, setOtp] = useState3("");
|
|
355
|
+
const [isVerifying, setIsVerifying] = useState3(false);
|
|
356
|
+
const [isResending, setIsResending] = useState3(false);
|
|
357
|
+
const [resendMessage, setResendMessage] = useState3();
|
|
358
|
+
const [error, setError] = useState3();
|
|
29
359
|
const handleVerify = async (e) => {
|
|
30
360
|
e.preventDefault();
|
|
31
361
|
if (!otp.trim() || otp.length < 6) {
|
|
@@ -68,19 +398,19 @@ function VerifyEmailForm({
|
|
|
68
398
|
setIsResending(false);
|
|
69
399
|
}
|
|
70
400
|
};
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-8", children: [
|
|
402
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
403
|
+
/* @__PURE__ */ jsx4("h1", { className: "text-2xl font-bold tracking-tight", children: "Verify your email" }),
|
|
404
|
+
/* @__PURE__ */ jsx4("p", { className: "mt-1 text-sm text-muted-foreground", children: email ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
75
405
|
"Enter the 6-digit code sent to",
|
|
76
406
|
" ",
|
|
77
|
-
/* @__PURE__ */
|
|
407
|
+
/* @__PURE__ */ jsx4("span", { className: "font-medium text-foreground", children: email })
|
|
78
408
|
] }) : "Enter the 6-digit code sent to your email" })
|
|
79
409
|
] }),
|
|
80
|
-
error && /* @__PURE__ */
|
|
81
|
-
resendMessage && /* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
410
|
+
error && /* @__PURE__ */ jsx4("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
|
|
411
|
+
resendMessage && /* @__PURE__ */ jsx4("div", { className: "rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700", children: resendMessage }),
|
|
412
|
+
/* @__PURE__ */ jsxs4("form", { onSubmit: handleVerify, className: "space-y-4", noValidate: true, children: [
|
|
413
|
+
/* @__PURE__ */ jsx4(
|
|
84
414
|
"input",
|
|
85
415
|
{
|
|
86
416
|
type: "text",
|
|
@@ -96,7 +426,7 @@ function VerifyEmailForm({
|
|
|
96
426
|
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"
|
|
97
427
|
}
|
|
98
428
|
),
|
|
99
|
-
/* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ jsx4(
|
|
100
430
|
"button",
|
|
101
431
|
{
|
|
102
432
|
type: "submit",
|
|
@@ -105,7 +435,7 @@ function VerifyEmailForm({
|
|
|
105
435
|
children: isVerifying ? "Verifying..." : "Verify email"
|
|
106
436
|
}
|
|
107
437
|
),
|
|
108
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ jsx4(
|
|
109
439
|
"button",
|
|
110
440
|
{
|
|
111
441
|
type: "button",
|
|
@@ -116,10 +446,10 @@ function VerifyEmailForm({
|
|
|
116
446
|
}
|
|
117
447
|
)
|
|
118
448
|
] }),
|
|
119
|
-
/* @__PURE__ */
|
|
449
|
+
/* @__PURE__ */ jsxs4("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
120
450
|
"Already verified?",
|
|
121
451
|
" ",
|
|
122
|
-
/* @__PURE__ */
|
|
452
|
+
/* @__PURE__ */ jsx4(
|
|
123
453
|
"a",
|
|
124
454
|
{
|
|
125
455
|
href: "/login",
|
|
@@ -132,16 +462,16 @@ function VerifyEmailForm({
|
|
|
132
462
|
}
|
|
133
463
|
|
|
134
464
|
// src/components/forgot-password-form.tsx
|
|
135
|
-
import { useState as
|
|
136
|
-
import { jsx as
|
|
465
|
+
import { useState as useState4 } from "react";
|
|
466
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
137
467
|
function ForgotPasswordForm({
|
|
138
468
|
onSuccess,
|
|
139
469
|
loginUrl = "/login",
|
|
140
470
|
authClient
|
|
141
471
|
}) {
|
|
142
|
-
const [email, setEmail] =
|
|
143
|
-
const [error, setError] =
|
|
144
|
-
const [isPending, setIsPending] =
|
|
472
|
+
const [email, setEmail] = useState4("");
|
|
473
|
+
const [error, setError] = useState4();
|
|
474
|
+
const [isPending, setIsPending] = useState4(false);
|
|
145
475
|
const handleSubmit = async (e) => {
|
|
146
476
|
e.preventDefault();
|
|
147
477
|
if (!email.trim()) {
|
|
@@ -166,14 +496,14 @@ function ForgotPasswordForm({
|
|
|
166
496
|
setIsPending(false);
|
|
167
497
|
}
|
|
168
498
|
};
|
|
169
|
-
return /* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
499
|
+
return /* @__PURE__ */ jsxs5("div", { className: "space-y-8", children: [
|
|
500
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
501
|
+
/* @__PURE__ */ jsx5("h1", { className: "text-2xl font-bold tracking-tight", children: "Forgot your password?" }),
|
|
502
|
+
/* @__PURE__ */ jsx5("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." })
|
|
173
503
|
] }),
|
|
174
|
-
error && /* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
504
|
+
error && /* @__PURE__ */ jsx5("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
|
|
505
|
+
/* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
|
|
506
|
+
/* @__PURE__ */ jsx5(
|
|
177
507
|
"input",
|
|
178
508
|
{
|
|
179
509
|
type: "email",
|
|
@@ -186,7 +516,7 @@ function ForgotPasswordForm({
|
|
|
186
516
|
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"
|
|
187
517
|
}
|
|
188
518
|
),
|
|
189
|
-
/* @__PURE__ */
|
|
519
|
+
/* @__PURE__ */ jsx5(
|
|
190
520
|
"button",
|
|
191
521
|
{
|
|
192
522
|
type: "submit",
|
|
@@ -196,10 +526,10 @@ function ForgotPasswordForm({
|
|
|
196
526
|
}
|
|
197
527
|
)
|
|
198
528
|
] }),
|
|
199
|
-
/* @__PURE__ */
|
|
529
|
+
/* @__PURE__ */ jsxs5("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
200
530
|
"Remember your password?",
|
|
201
531
|
" ",
|
|
202
|
-
/* @__PURE__ */
|
|
532
|
+
/* @__PURE__ */ jsx5(
|
|
203
533
|
"a",
|
|
204
534
|
{
|
|
205
535
|
href: loginUrl,
|
|
@@ -212,21 +542,21 @@ function ForgotPasswordForm({
|
|
|
212
542
|
}
|
|
213
543
|
|
|
214
544
|
// src/components/reset-password-form.tsx
|
|
215
|
-
import { useState as
|
|
216
|
-
import { jsx as
|
|
545
|
+
import { useState as useState5 } from "react";
|
|
546
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
217
547
|
function ResetPasswordForm({
|
|
218
548
|
email,
|
|
219
549
|
onSuccess,
|
|
220
550
|
loginUrl = "/login",
|
|
221
551
|
authClient
|
|
222
552
|
}) {
|
|
223
|
-
const [otp, setOtp] =
|
|
224
|
-
const [password, setPassword] =
|
|
225
|
-
const [confirmPassword, setConfirmPassword] =
|
|
226
|
-
const [error, setError] =
|
|
227
|
-
const [isResetting, setIsResetting] =
|
|
228
|
-
const [isResending, setIsResending] =
|
|
229
|
-
const [resendMessage, setResendMessage] =
|
|
553
|
+
const [otp, setOtp] = useState5("");
|
|
554
|
+
const [password, setPassword] = useState5("");
|
|
555
|
+
const [confirmPassword, setConfirmPassword] = useState5("");
|
|
556
|
+
const [error, setError] = useState5();
|
|
557
|
+
const [isResetting, setIsResetting] = useState5(false);
|
|
558
|
+
const [isResending, setIsResending] = useState5(false);
|
|
559
|
+
const [resendMessage, setResendMessage] = useState5();
|
|
230
560
|
const handleSubmit = async (e) => {
|
|
231
561
|
e.preventDefault();
|
|
232
562
|
if (!otp.trim() || otp.length < 6) {
|
|
@@ -279,20 +609,20 @@ function ResetPasswordForm({
|
|
|
279
609
|
setIsResending(false);
|
|
280
610
|
}
|
|
281
611
|
};
|
|
282
|
-
return /* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
612
|
+
return /* @__PURE__ */ jsxs6("div", { className: "space-y-8", children: [
|
|
613
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
614
|
+
/* @__PURE__ */ jsx6("h1", { className: "text-2xl font-bold tracking-tight", children: "Reset your password" }),
|
|
615
|
+
/* @__PURE__ */ jsxs6("p", { className: "mt-1 text-sm text-muted-foreground", children: [
|
|
286
616
|
"Enter the 6-digit code sent to",
|
|
287
617
|
" ",
|
|
288
|
-
/* @__PURE__ */
|
|
618
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-foreground", children: email }),
|
|
289
619
|
" and your new password."
|
|
290
620
|
] })
|
|
291
621
|
] }),
|
|
292
|
-
error && /* @__PURE__ */
|
|
293
|
-
resendMessage && /* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
/* @__PURE__ */
|
|
622
|
+
error && /* @__PURE__ */ jsx6("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
|
|
623
|
+
resendMessage && /* @__PURE__ */ jsx6("div", { className: "rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-xs text-green-700", children: resendMessage }),
|
|
624
|
+
/* @__PURE__ */ jsxs6("form", { onSubmit: handleSubmit, className: "space-y-4", noValidate: true, children: [
|
|
625
|
+
/* @__PURE__ */ jsx6(
|
|
296
626
|
"input",
|
|
297
627
|
{
|
|
298
628
|
type: "text",
|
|
@@ -308,7 +638,7 @@ function ResetPasswordForm({
|
|
|
308
638
|
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"
|
|
309
639
|
}
|
|
310
640
|
),
|
|
311
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ jsx6(
|
|
312
642
|
"input",
|
|
313
643
|
{
|
|
314
644
|
type: "password",
|
|
@@ -321,7 +651,7 @@ function ResetPasswordForm({
|
|
|
321
651
|
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"
|
|
322
652
|
}
|
|
323
653
|
),
|
|
324
|
-
/* @__PURE__ */
|
|
654
|
+
/* @__PURE__ */ jsx6(
|
|
325
655
|
"input",
|
|
326
656
|
{
|
|
327
657
|
type: "password",
|
|
@@ -334,7 +664,7 @@ function ResetPasswordForm({
|
|
|
334
664
|
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"
|
|
335
665
|
}
|
|
336
666
|
),
|
|
337
|
-
/* @__PURE__ */
|
|
667
|
+
/* @__PURE__ */ jsx6(
|
|
338
668
|
"button",
|
|
339
669
|
{
|
|
340
670
|
type: "submit",
|
|
@@ -343,7 +673,7 @@ function ResetPasswordForm({
|
|
|
343
673
|
children: isResetting ? "Resetting..." : "Reset password"
|
|
344
674
|
}
|
|
345
675
|
),
|
|
346
|
-
/* @__PURE__ */
|
|
676
|
+
/* @__PURE__ */ jsx6(
|
|
347
677
|
"button",
|
|
348
678
|
{
|
|
349
679
|
type: "button",
|
|
@@ -354,10 +684,10 @@ function ResetPasswordForm({
|
|
|
354
684
|
}
|
|
355
685
|
)
|
|
356
686
|
] }),
|
|
357
|
-
/* @__PURE__ */
|
|
687
|
+
/* @__PURE__ */ jsxs6("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
358
688
|
"Remember your password?",
|
|
359
689
|
" ",
|
|
360
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ jsx6(
|
|
361
691
|
"a",
|
|
362
692
|
{
|
|
363
693
|
href: loginUrl,
|
|
@@ -370,7 +700,7 @@ function ResetPasswordForm({
|
|
|
370
700
|
}
|
|
371
701
|
|
|
372
702
|
// src/components/auth-layout.tsx
|
|
373
|
-
import { jsx as
|
|
703
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
374
704
|
function AuthLayout({
|
|
375
705
|
logo,
|
|
376
706
|
title,
|
|
@@ -378,19 +708,19 @@ function AuthLayout({
|
|
|
378
708
|
children,
|
|
379
709
|
footer
|
|
380
710
|
}) {
|
|
381
|
-
return /* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
logo && /* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
subtitle && /* @__PURE__ */
|
|
711
|
+
return /* @__PURE__ */ jsx7("div", { className: "flex min-h-screen items-center justify-center bg-background", children: /* @__PURE__ */ jsxs7("div", { className: "w-full max-w-md", children: [
|
|
712
|
+
/* @__PURE__ */ jsxs7("div", { className: "mb-10 text-center", children: [
|
|
713
|
+
logo && /* @__PURE__ */ jsx7("div", { className: "mb-6 flex justify-center", children: logo }),
|
|
714
|
+
/* @__PURE__ */ jsx7("h1", { className: "text-[32px] font-light tracking-tight", children: title }),
|
|
715
|
+
subtitle && /* @__PURE__ */ jsx7("p", { className: "mt-2 text-sm text-muted-foreground", children: subtitle })
|
|
386
716
|
] }),
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
footer && /* @__PURE__ */
|
|
717
|
+
/* @__PURE__ */ jsx7("div", { className: "rounded-xl border bg-card p-8 shadow-sm", children }),
|
|
718
|
+
footer && /* @__PURE__ */ jsx7("div", { className: "mt-6 text-center text-xs text-muted-foreground", children: footer })
|
|
389
719
|
] }) });
|
|
390
720
|
}
|
|
391
721
|
|
|
392
722
|
// src/components/invitation-notice.tsx
|
|
393
|
-
import { jsx as
|
|
723
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
394
724
|
function defaultSupportEmail() {
|
|
395
725
|
if (typeof window === "undefined") return void 0;
|
|
396
726
|
const host = window.location.hostname;
|
|
@@ -410,15 +740,15 @@ function InvitationNotice({
|
|
|
410
740
|
action
|
|
411
741
|
}) {
|
|
412
742
|
const contact = supportEmail ?? defaultSupportEmail();
|
|
413
|
-
return /* @__PURE__ */
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
/* @__PURE__ */
|
|
416
|
-
/* @__PURE__ */
|
|
743
|
+
return /* @__PURE__ */ jsxs8("div", { className: "space-y-8", children: [
|
|
744
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
745
|
+
/* @__PURE__ */ jsx8("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
746
|
+
/* @__PURE__ */ jsx8("p", { className: "mt-1 text-sm text-muted-foreground", children: REASON_MESSAGE[reason] ?? REASON_MESSAGE.unknown })
|
|
417
747
|
] }),
|
|
418
|
-
contact ? /* @__PURE__ */
|
|
748
|
+
contact ? /* @__PURE__ */ jsxs8("p", { className: "text-sm text-muted-foreground", children: [
|
|
419
749
|
"\xC9crivez-nous \xE0",
|
|
420
750
|
" ",
|
|
421
|
-
/* @__PURE__ */
|
|
751
|
+
/* @__PURE__ */ jsx8(
|
|
422
752
|
"a",
|
|
423
753
|
{
|
|
424
754
|
href: `mailto:${contact}`,
|
|
@@ -436,7 +766,10 @@ export {
|
|
|
436
766
|
AuthLayout,
|
|
437
767
|
ForgotPasswordForm,
|
|
438
768
|
InvitationNotice,
|
|
769
|
+
LoginForm,
|
|
770
|
+
RegisterForm,
|
|
439
771
|
ResetPasswordForm,
|
|
772
|
+
SocialButtons,
|
|
440
773
|
VerifyEmailForm,
|
|
441
774
|
isInvitationFailure,
|
|
442
775
|
useLogout,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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","../src/components/invitation-notice.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","import type { InvitationNoticeProps } from \"../types\"\n\n/**\n * Every app is reachable at contact@ its own apex domain, so the address is\n * derived rather than configured. Sub-domains are stripped because the app is\n * routinely served from app./admin. while the mailbox lives on the apex;\n * multi-part public suffixes (.co.uk) would need a real suffix list and no app\n * using this is on one.\n */\nfunction defaultSupportEmail(): string | undefined {\n if (typeof window === \"undefined\") return undefined\n const host = window.location.hostname\n if (!host || host === \"localhost\" || /^[\\d.]+$/.test(host)) return undefined\n const apex = host.split(\".\").slice(-2).join(\".\")\n return `contact@${apex}`\n}\n\nconst REASON_MESSAGE: Record<string, string> = {\n expired: \"Cette invitation a expiré.\",\n claimed: \"Cette invitation a déjà été utilisée.\",\n unknown: \"Ce lien d'invitation n'est pas valide.\",\n}\n\n/**\n * What an invitee sees when their link does not work.\n *\n * It names the reason instead of merging the cases into one message: \"expired\"\n * tells someone their link was real and that asking for another one is worth\n * it, which \"invalid\" does not. Short TTLs make that distinction routine.\n *\n * The only way forward offered is a mailto, deliberately. A self-service\n * \"request a new invitation\" form would mean a public endpoint accepting dead\n * tokens, a queue to moderate, and a way to probe which tokens once existed —\n * for a flow where the operator already knows the person by name.\n */\nexport function InvitationNotice({\n reason = \"unknown\",\n supportEmail,\n title = \"Invitation indisponible\",\n action,\n}: InvitationNoticeProps) {\n const contact = supportEmail ?? defaultSupportEmail()\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n {REASON_MESSAGE[reason] ?? REASON_MESSAGE.unknown}\n </p>\n </div>\n\n {contact ? (\n <p className=\"text-sm text-muted-foreground\">\n Écrivez-nous à{\" \"}\n <a\n href={`mailto:${contact}`}\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n {contact}\n </a>{\" \"}\n pour en recevoir une nouvelle.\n </p>\n ) : null}\n\n {action}\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,I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;AAAA;AAAA,MAC5B;AAAA,MACf,gBAAAD;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,UAAU,OAAO;AAAA,UACvB,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA,MAAK;AAAA,MAAI;AAAA,OAEX,IACE;AAAA,IAEH;AAAA,KACH;AAEJ;","names":["useState","jsx","jsxs","useState","jsx","jsxs","jsx","jsxs","jsx","jsxs"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-session.ts","../src/components/login-form.tsx","../src/components/social-buttons.tsx","../src/components/register-form.tsx","../src/components/verify-email-form.tsx","../src/components/forgot-password-form.tsx","../src/components/reset-password-form.tsx","../src/components/auth-layout.tsx","../src/components/invitation-notice.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 { LoginFormProps } from \"../types\"\nimport { SocialButtons } from \"./social-buttons\"\n\n// accountLinking is disabled in createPlatformAuth, so a social sign-in on an\n// address already registered with a password is refused with this code. Without\n// a message the button reads as broken rather than as a rejected account.\nfunction oauthErrorMessage(code: string): string {\n switch (code) {\n case \"account_not_linked\":\n return \"This email is already registered with a password. Sign in with your password instead.\"\n case \"access_denied\":\n return \"Sign-in was cancelled.\"\n default:\n return \"Sign-in failed. Please try again.\"\n }\n}\n\nexport function LoginForm({\n onSuccess,\n registerUrl = \"/register\",\n forgotPasswordUrl = \"/forgot-password\",\n socialCallbackUrl = \"/\",\n socialProviders = [],\n coreTokenUrl = \"/api/auth/core-token\",\n authClient,\n}: LoginFormProps) {\n const [email, setEmail] = useState(\"\")\n const [password, setPassword] = 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 if (!password) {\n setError(\"Please enter your password\")\n return\n }\n setError(undefined)\n setIsPending(true)\n try {\n const res = await authClient.signIn.email({\n email: email.trim(),\n password,\n })\n if (res?.error) {\n setError(res.error.message ?? \"Invalid email or password\")\n return\n }\n // The better-auth session cookie alone does not authenticate the Go core:\n // it verifies the EdDSA JWT minted here against the issuer's JWKS. Skipped\n // when the app has no core to call.\n if (coreTokenUrl) {\n await fetch(coreTokenUrl, { credentials: \"include\" })\n }\n onSuccess?.()\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Invalid email or password\")\n } finally {\n setIsPending(false)\n }\n }\n\n const handleSocial = async (provider: \"google\" | \"github\") => {\n setError(undefined)\n try {\n await authClient.signIn.social({\n provider,\n callbackURL: socialCallbackUrl,\n })\n } catch (err) {\n setError(\n err instanceof Error ? oauthErrorMessage(err.message) : oauthErrorMessage(\"\"),\n )\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">Sign in</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n Welcome back. Enter your credentials to continue.\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 <div className=\"space-y-1\">\n <input\n type=\"password\"\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n placeholder=\"Password\"\n required\n disabled={isPending}\n autoComplete=\"current-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 <div className=\"text-right\">\n <a\n href={forgotPasswordUrl}\n className=\"text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground\"\n >\n Forgot your password?\n </a>\n </div>\n </div>\n\n <button\n type=\"submit\"\n disabled={isPending || !email.trim() || !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 {isPending ? \"Signing in...\" : \"Sign in\"}\n </button>\n </form>\n\n <SocialButtons\n providers={socialProviders}\n onSelect={handleSocial}\n disabled={isPending}\n />\n\n <p className=\"text-center text-sm text-muted-foreground\">\n Don't have an account?{\" \"}\n <a\n href={registerUrl}\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n Sign up\n </a>\n </p>\n </div>\n )\n}\n","const LABELS: Record<string, string> = {\n google: \"Continue with Google\",\n github: \"Continue with GitHub\",\n}\n\ninterface SocialButtonsProps {\n providers: Array<\"google\" | \"github\">\n onSelect: (provider: \"google\" | \"github\") => void | Promise<void>\n disabled?: boolean\n}\n\nexport function SocialButtons({\n providers,\n onSelect,\n disabled = false,\n}: SocialButtonsProps) {\n if (providers.length === 0) return null\n\n return (\n <div className=\"space-y-4\">\n <div className=\"relative\">\n <div className=\"absolute inset-0 flex items-center\">\n <div className=\"w-full border-t border-input\" />\n </div>\n <div className=\"relative flex justify-center\">\n <span className=\"bg-background px-2 text-xs uppercase tracking-wider text-muted-foreground\">\n or\n </span>\n </div>\n </div>\n\n <div className=\"space-y-2\">\n {providers.map((provider) => (\n <button\n key={provider}\n type=\"button\"\n onClick={() => onSelect(provider)}\n disabled={disabled}\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 {LABELS[provider] ?? provider}\n </button>\n ))}\n </div>\n </div>\n )\n}\n","import { useState, type FormEvent } from \"react\"\nimport type { RegisterFormProps } from \"../types\"\nimport { SocialButtons } from \"./social-buttons\"\n\nconst MIN_PASSWORD_LENGTH = 8\n\nexport function RegisterForm({\n onSuccess,\n loginUrl = \"/login\",\n legal,\n socialCallbackUrl = \"/\",\n socialProviders = [],\n authClient,\n}: RegisterFormProps) {\n const [name, setName] = useState(\"\")\n const [email, setEmail] = useState(\"\")\n const [password, setPassword] = 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 (!name.trim()) {\n setError(\"Please enter your name\")\n return\n }\n if (!email.trim()) {\n setError(\"Please enter your email address\")\n return\n }\n if (password.length < MIN_PASSWORD_LENGTH) {\n setError(`Password must be at least ${MIN_PASSWORD_LENGTH} characters`)\n return\n }\n setError(undefined)\n setIsPending(true)\n try {\n const res = await authClient.signUp.email({\n name: name.trim(),\n email: email.trim(),\n password,\n })\n if (res?.error) {\n setError(res.error.message ?? \"Could not create your account\")\n return\n }\n // createPlatformAuth sets requireEmailVerification, so sign-up leaves the\n // account unverified and without a session: the caller routes to the OTP\n // step rather than into the app.\n onSuccess?.(email.trim())\n } catch (err) {\n setError(\n err instanceof Error ? err.message : \"Could not create your account\",\n )\n } finally {\n setIsPending(false)\n }\n }\n\n const handleSocial = async (provider: \"google\" | \"github\") => {\n setError(undefined)\n try {\n await authClient.signIn.social({\n provider,\n callbackURL: socialCallbackUrl,\n })\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Sign-up failed\")\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">Create an account</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n We'll send you a code to confirm your email address.\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=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder=\"Full name\"\n required\n disabled={isPending}\n autoComplete=\"name\"\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=\"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 <div className=\"space-y-1\">\n <input\n type=\"password\"\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n placeholder=\"Password\"\n required\n disabled={isPending}\n autoComplete=\"new-password\"\n aria-describedby=\"register-password-hint\"\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 <p id=\"register-password-hint\" className=\"text-xs text-muted-foreground\">\n At least {MIN_PASSWORD_LENGTH} characters.\n </p>\n </div>\n\n <button\n type=\"submit\"\n disabled={isPending}\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 ? \"Creating account...\" : \"Create account\"}\n </button>\n\n {legal && (\n <div className=\"text-center text-xs text-muted-foreground\">{legal}</div>\n )}\n </form>\n\n <SocialButtons\n providers={socialProviders}\n onSelect={handleSocial}\n disabled={isPending}\n />\n\n <p className=\"text-center text-sm text-muted-foreground\">\n Already have an account?{\" \"}\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 { 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","import type { InvitationNoticeProps } from \"../types\"\n\n/**\n * Every app is reachable at contact@ its own apex domain, so the address is\n * derived rather than configured. Sub-domains are stripped because the app is\n * routinely served from app./admin. while the mailbox lives on the apex;\n * multi-part public suffixes (.co.uk) would need a real suffix list and no app\n * using this is on one.\n */\nfunction defaultSupportEmail(): string | undefined {\n if (typeof window === \"undefined\") return undefined\n const host = window.location.hostname\n if (!host || host === \"localhost\" || /^[\\d.]+$/.test(host)) return undefined\n const apex = host.split(\".\").slice(-2).join(\".\")\n return `contact@${apex}`\n}\n\nconst REASON_MESSAGE: Record<string, string> = {\n expired: \"Cette invitation a expiré.\",\n claimed: \"Cette invitation a déjà été utilisée.\",\n unknown: \"Ce lien d'invitation n'est pas valide.\",\n}\n\n/**\n * What an invitee sees when their link does not work.\n *\n * It names the reason instead of merging the cases into one message: \"expired\"\n * tells someone their link was real and that asking for another one is worth\n * it, which \"invalid\" does not. Short TTLs make that distinction routine.\n *\n * The only way forward offered is a mailto, deliberately. A self-service\n * \"request a new invitation\" form would mean a public endpoint accepting dead\n * tokens, a queue to moderate, and a way to probe which tokens once existed —\n * for a flow where the operator already knows the person by name.\n */\nexport function InvitationNotice({\n reason = \"unknown\",\n supportEmail,\n title = \"Invitation indisponible\",\n action,\n}: InvitationNoticeProps) {\n const contact = supportEmail ?? defaultSupportEmail()\n\n return (\n <div className=\"space-y-8\">\n <div>\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n {REASON_MESSAGE[reason] ?? REASON_MESSAGE.unknown}\n </p>\n </div>\n\n {contact ? (\n <p className=\"text-sm text-muted-foreground\">\n Écrivez-nous à{\" \"}\n <a\n href={`mailto:${contact}`}\n className=\"font-medium text-foreground underline underline-offset-4 hover:text-foreground/80\"\n >\n {contact}\n </a>{\" \"}\n pour en recevoir une nouvelle.\n </p>\n ) : null}\n\n {action}\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;;;ACoBnC,SAEI,KAFJ;AApBN,IAAM,SAAiC;A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E,MADF,QAAAC,aAAA;AApCN,SAAS,sBAA0C;AACjD,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,OAAO,OAAO,SAAS;AAC7B,MAAI,CAAC,QAAQ,SAAS,eAAe,WAAW,KAAK,IAAI,EAAG,QAAO;AACnE,QAAM,OAAO,KAAK,MAAM,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,GAAG;AAC/C,SAAO,WAAW,IAAI;AACxB;AAEA,IAAM,iBAAyC;AAAA,EAC7C,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;AAcO,SAAS,iBAAiB;AAAA,EAC/B,SAAS;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAA0B;AACxB,QAAM,UAAU,gBAAgB,oBAAoB;AAEpD,SACE,gBAAAA,MAAC,SAAI,WAAU,aACb;AAAA,oBAAAA,MAAC,SACC;AAAA,sBAAAD,KAAC,QAAG,WAAU,qCAAqC,iBAAM;AAAA,MACzD,gBAAAA,KAAC,OAAE,WAAU,sCACV,yBAAe,MAAM,KAAK,eAAe,SAC5C;AAAA,OACF;AAAA,IAEC,UACC,gBAAAC,MAAC,OAAE,WAAU,iCAAgC;AAAA;AAAA,MAC5B;AAAA,MACf,gBAAAD;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,UAAU,OAAO;AAAA,UACvB,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA,MAAK;AAAA,MAAI;AAAA,OAEX,IACE;AAAA,IAEH;AAAA,KACH;AAEJ;","names":["jsx","jsxs","useState","jsx","jsxs","useState","useState","jsx","jsxs","useState","jsx","jsxs","useState","jsx","jsxs","jsx","jsxs","jsx","jsxs"]}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Auth, BetterAuthOptions } from 'better-auth';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export { a as ClaimInvitationOptions, C as ClaimOutcome, c as claimInvitation, b as completesSignup, d as invitationOutcomeCookie, e as inviteTokenFrom, i as isInvitationFailure } from './invitation-
|
|
2
|
+
import { c as PlatformAuthConfig } from './types-DxllDyOa.js';
|
|
3
|
+
export { g as PlatformSession, h as PlatformSessionData, i as PlatformUser } from './types-DxllDyOa.js';
|
|
4
|
+
export { a as ClaimInvitationOptions, C as ClaimOutcome, c as claimInvitation, b as completesSignup, d as invitationOutcomeCookie, e as inviteTokenFrom, i as isInvitationFailure } from './invitation-CzfLna7q.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates a Better Auth instance with platform defaults.
|
|
@@ -125,6 +125,43 @@ interface InvitationNoticeProps {
|
|
|
125
125
|
/** Rendered under the contact line — typically a link back to the site. */
|
|
126
126
|
action?: React.ReactNode;
|
|
127
127
|
}
|
|
128
|
+
interface LoginFormProps {
|
|
129
|
+
/** Callback once the session cookie is set and the core token minted */
|
|
130
|
+
onSuccess?: () => void;
|
|
131
|
+
/** Link to the registration page */
|
|
132
|
+
registerUrl?: string;
|
|
133
|
+
/** Link to the password recovery page */
|
|
134
|
+
forgotPasswordUrl?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Where Better Auth sends the browser back after a social sign-in. Social
|
|
137
|
+
* buttons are only rendered when at least one provider is passed.
|
|
138
|
+
*/
|
|
139
|
+
socialCallbackUrl?: string;
|
|
140
|
+
/** Social providers to offer, in display order */
|
|
141
|
+
socialProviders?: Array<"google" | "github">;
|
|
142
|
+
/**
|
|
143
|
+
* Endpoint trading the fresh better-auth session for the short-lived EdDSA
|
|
144
|
+
* token the Go core verifies. Called after a successful password sign-in;
|
|
145
|
+
* pass null to skip when the app has no core.
|
|
146
|
+
*/
|
|
147
|
+
coreTokenUrl?: string | null;
|
|
148
|
+
/** Auth client instance */
|
|
149
|
+
authClient: any;
|
|
150
|
+
}
|
|
151
|
+
interface RegisterFormProps {
|
|
152
|
+
/** Callback on successful sign-up, receives the email to verify */
|
|
153
|
+
onSuccess?: (email: string) => void;
|
|
154
|
+
/** Link to the login page */
|
|
155
|
+
loginUrl?: string;
|
|
156
|
+
/** Rendered under the submit button — typically terms and privacy links */
|
|
157
|
+
legal?: React.ReactNode;
|
|
158
|
+
/** Where Better Auth sends the browser back after a social sign-up */
|
|
159
|
+
socialCallbackUrl?: string;
|
|
160
|
+
/** Social providers to offer, in display order */
|
|
161
|
+
socialProviders?: Array<"google" | "github">;
|
|
162
|
+
/** Auth client instance */
|
|
163
|
+
authClient: any;
|
|
164
|
+
}
|
|
128
165
|
interface ForgotPasswordFormProps {
|
|
129
166
|
/** Callback on successful OTP send, receives the email */
|
|
130
167
|
onSuccess?: (email: string) => void;
|
|
@@ -156,4 +193,4 @@ interface AuthLayoutProps {
|
|
|
156
193
|
footer?: React.ReactNode;
|
|
157
194
|
}
|
|
158
195
|
|
|
159
|
-
export type { AuthLayoutProps as A, ForgotPasswordFormProps as F, InvitationNoticeProps as I, PlatformAuthClientConfig as P,
|
|
196
|
+
export type { AuthLayoutProps as A, ForgotPasswordFormProps as F, InvitationNoticeProps as I, LoginFormProps as L, PlatformAuthClientConfig as P, RegisterFormProps as R, VerifyEmailFormProps as V, ResetPasswordFormProps as a, InvitationFailure as b, PlatformAuthConfig as c, PlatformAuthMailer as d, PlatformAuthMailerArgs as e, PlatformAuthMailerType as f, PlatformSession as g, PlatformSessionData as h, PlatformUser as i };
|