@pithy-sh/auth 0.8.0 → 0.9.0
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 +4 -0
- package/dist/caller/certificate.d.ts +83 -0
- package/dist/caller/certificate.d.ts.map +1 -0
- package/dist/caller/certificate.js +92 -0
- package/dist/caller/request.d.ts +66 -0
- package/dist/caller/request.d.ts.map +1 -0
- package/dist/caller/request.js +71 -0
- package/dist/caller/token.d.ts +130 -0
- package/dist/caller/token.d.ts.map +1 -0
- package/dist/caller/token.js +207 -0
- package/dist/capability.d.ts +44 -1
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +7 -4
- package/dist/data/betterAuth.d.ts +1 -1
- package/dist/data/betterAuth.d.ts.map +1 -1
- package/dist/data/betterAuth.js +1 -1
- package/dist/data/tables.d.ts +1 -1
- package/dist/http/credentialResign.d.ts +46 -0
- package/dist/http/credentialResign.d.ts.map +1 -0
- package/dist/http/credentialResign.js +203 -0
- package/dist/http/errorCallbackUrl.d.ts.map +1 -1
- package/dist/http/errorCallbackUrl.js +15 -9
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +66 -15
- package/dist/http/providerRefusal.d.ts +8 -7
- package/dist/http/providerRefusal.d.ts.map +1 -1
- package/dist/http/providerRefusal.js +29 -32
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +18 -3
- package/dist/instance/auth.d.ts +1225 -2
- package/dist/instance/auth.d.ts.map +1 -1
- package/dist/instance/auth.js +6 -2
- package/dist/instance/jwksReencryption.d.ts +75 -0
- package/dist/instance/jwksReencryption.d.ts.map +1 -0
- package/dist/instance/jwksReencryption.js +160 -0
- package/dist/instance/providerSignInGate.d.ts +7 -6
- package/dist/instance/providerSignInGate.d.ts.map +1 -1
- package/dist/instance/providerSignInGate.js +16 -14
- package/dist/instance/secrets.d.ts +168 -1
- package/dist/instance/secrets.d.ts.map +1 -1
- package/dist/instance/secrets.js +86 -3
- package/dist/instance/sessionSecrets.d.ts +45 -0
- package/dist/instance/sessionSecrets.d.ts.map +1 -0
- package/dist/instance/sessionSecrets.js +29 -0
- package/dist/migrations/0001_init.d.ts.map +1 -1
- package/dist/migrations/0003_account_issuer_nullable.d.ts +5 -0
- package/dist/migrations/0003_account_issuer_nullable.d.ts.map +1 -0
- package/dist/migrations/0003_account_issuer_nullable.js +131 -0
- package/dist/migrations/set.d.ts +2 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +4 -2
- package/dist/test-utils/liveApp.d.ts +5 -0
- package/dist/test-utils/liveApp.d.ts.map +1 -1
- package/dist/test-utils/schemaDrift.d.ts +49 -0
- package/dist/test-utils/schemaDrift.d.ts.map +1 -0
- package/dist/test-utils/schemaDrift.js +35 -0
- package/dist/test-utils/scopedBackend.d.ts +183 -0
- package/dist/test-utils/scopedBackend.d.ts.map +1 -0
- package/dist/test-utils/scopedBackend.js +160 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/docs/server-authoritative.md +182 -0
- package/package.json +11 -8
- package/src/caller/certificate.ts +133 -0
- package/src/caller/request.ts +84 -0
- package/src/caller/token.ts +276 -0
- package/src/capability.ts +65 -4
- package/src/data/betterAuth.ts +2 -1
- package/src/http/credentialResign.ts +268 -0
- package/src/http/errorCallbackUrl.ts +21 -13
- package/src/http/middleware.ts +100 -35
- package/src/http/providerRefusal.ts +30 -32
- package/src/http/resolve.ts +27 -3
- package/src/http/routes.ts +1 -1
- package/src/instance/auth.ts +22 -4
- package/src/instance/jwksReencryption.ts +206 -0
- package/src/instance/providerSignInGate.ts +23 -21
- package/src/instance/secrets.ts +94 -1
- package/src/instance/sessionSecrets.ts +64 -0
- package/src/migrations/0001_init.ts +8 -10
- package/src/migrations/0003_account_issuer_nullable.ts +199 -0
- package/src/migrations/set.ts +3 -1
- package/src/test-utils/schemaDrift.ts +82 -0
- package/src/test-utils/scopedBackend.ts +136 -0
- package/src/version.generated.ts +1 -1
package/dist/instance/auth.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type AuthEmailDelivery } from "../audit/evidence";
|
|
|
6
6
|
import type { AuthDatabase } from "../data/tables";
|
|
7
7
|
import { type GithubUserInfoResolver } from "./githubUserInfo";
|
|
8
8
|
import { type ResolvedProviders, type SocialProviderId } from "./providers";
|
|
9
|
+
import { type SessionSecretVersions } from "./sessionSecrets";
|
|
9
10
|
export declare function socialProviders(deps: AuthInstanceDeps): Record<string, unknown> | undefined;
|
|
10
11
|
/**
|
|
11
12
|
* The seeding guard: a new account may be created only for an email a provider has **verified**.
|
|
@@ -71,8 +72,15 @@ export type SendAuthEmail = (message: AuthEmailMessage) => Promise<AuthEmailDeli
|
|
|
71
72
|
export interface AuthInstanceDeps<Plugins extends readonly BetterAuthPlugin[] = readonly BetterAuthPlugin[]> extends ResolvedProviders {
|
|
72
73
|
/** The shared Kysely over the `pithy_auth_*` tables (carries `CamelCasePlugin`). */
|
|
73
74
|
db: AuthDatabase;
|
|
74
|
-
/** The Better-Auth signing/encryption secret, sourced from `@pithy-sh/secrets
|
|
75
|
+
/** The Better-Auth signing/encryption secret, sourced from `@pithy-sh/secrets` — the current version. */
|
|
75
76
|
secret: string;
|
|
77
|
+
/**
|
|
78
|
+
* Every retained version of the session secret, when the caller resolved them (#602). Given, Better Auth
|
|
79
|
+
* gets the whole version set — newest first — so a value sealed under the previous version still opens
|
|
80
|
+
* through a rotation's overlap; see `./sessionSecrets.ts`. Absent, it gets `secret` alone, which is what an
|
|
81
|
+
* instance built outside a request (a seed, a test) has always had.
|
|
82
|
+
*/
|
|
83
|
+
sessionSecrets?: SessionSecretVersions;
|
|
76
84
|
/** The public base URL of this environment's auth worker (no trailing slash). */
|
|
77
85
|
baseURL: string;
|
|
78
86
|
/** The mount path; must equal the Hono route the handler is mounted under. */
|
|
@@ -171,6 +179,1221 @@ export type AuthInstance<Plugins extends readonly BetterAuthPlugin[] = readonly
|
|
|
171
179
|
* UUIDs; rate limiting is durable (D1-backed) since memory limiting is per-isolate on Workers.
|
|
172
180
|
*/
|
|
173
181
|
export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin[]>(deps: AuthInstanceDeps<Plugins>): import("better-auth").Auth<{
|
|
182
|
+
secrets: {
|
|
183
|
+
version: number;
|
|
184
|
+
value: string;
|
|
185
|
+
}[];
|
|
186
|
+
secret: string;
|
|
187
|
+
appName: string;
|
|
188
|
+
baseURL: string;
|
|
189
|
+
basePath: string;
|
|
190
|
+
telemetry: {
|
|
191
|
+
enabled: false;
|
|
192
|
+
};
|
|
193
|
+
trustedOrigins: string[];
|
|
194
|
+
database: {
|
|
195
|
+
db: AuthDatabase;
|
|
196
|
+
type: string;
|
|
197
|
+
transaction: boolean;
|
|
198
|
+
};
|
|
199
|
+
advanced: {
|
|
200
|
+
database: {
|
|
201
|
+
generateId: () => string;
|
|
202
|
+
validateSchema: false;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
onAPIError: {
|
|
206
|
+
throw: true;
|
|
207
|
+
};
|
|
208
|
+
databaseHooks: {
|
|
209
|
+
user: {
|
|
210
|
+
create: {
|
|
211
|
+
before: (user: {
|
|
212
|
+
id: string;
|
|
213
|
+
createdAt: Date;
|
|
214
|
+
updatedAt: Date;
|
|
215
|
+
email: string;
|
|
216
|
+
emailVerified: boolean;
|
|
217
|
+
name: string;
|
|
218
|
+
image?: string | null | undefined;
|
|
219
|
+
} & Record<string, unknown>) => Promise<{
|
|
220
|
+
data: {
|
|
221
|
+
id: string;
|
|
222
|
+
createdAt: Date;
|
|
223
|
+
updatedAt: Date;
|
|
224
|
+
email: string;
|
|
225
|
+
emailVerified: boolean;
|
|
226
|
+
name: string;
|
|
227
|
+
image?: string | null | undefined;
|
|
228
|
+
};
|
|
229
|
+
} | undefined>;
|
|
230
|
+
};
|
|
231
|
+
update: {
|
|
232
|
+
before: (user: Partial<{
|
|
233
|
+
id: string;
|
|
234
|
+
createdAt: Date;
|
|
235
|
+
updatedAt: Date;
|
|
236
|
+
email: string;
|
|
237
|
+
emailVerified: boolean;
|
|
238
|
+
name: string;
|
|
239
|
+
image?: string | null | undefined;
|
|
240
|
+
}> & Record<string, unknown>) => Promise<void>;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
account: {
|
|
244
|
+
/**
|
|
245
|
+
* **The provider-link trail, recorded where the account table changes.**
|
|
246
|
+
*
|
|
247
|
+
* An account row is what lets a provider sign in as somebody, so its creation and its removal
|
|
248
|
+
* are the two account-security events — and the row is the only place both are visible. Better
|
|
249
|
+
* Auth reaches it from several directions: `/callback/:id` on a first social sign-up and on a
|
|
250
|
+
* link, `linkAccount` from the OAuth linking path, `/unlink-account`, and the cascade that drops
|
|
251
|
+
* every account when a user is deleted. All of them go through `createWithHooks` /
|
|
252
|
+
* `deleteWithHooks` on the `account` model (`better-auth/dist/db/internal-adapter.mjs`), so one
|
|
253
|
+
* pair of hooks covers what four endpoint wirings would have had to enumerate and keep current.
|
|
254
|
+
*
|
|
255
|
+
* **This is the seam `session.delete.after` below already argues for**, applied to the other
|
|
256
|
+
* table: a handler wired to one endpoint misses the others, and the row is what the fact is
|
|
257
|
+
* keyed by. #627 is what that costs — `/link-social` was wired, so a link recorded the request
|
|
258
|
+
* rather than the result, and an unlink recorded nothing.
|
|
259
|
+
*
|
|
260
|
+
* **After, not before, in both directions.** The write has happened by the time these run, so a
|
|
261
|
+
* slow or failing audit seam can neither hold up nor refuse a link or an unlink — and
|
|
262
|
+
* `emitProviderAccountChanged` swallows its own failure for the same reason.
|
|
263
|
+
*/
|
|
264
|
+
create: {
|
|
265
|
+
after: (account: {
|
|
266
|
+
id: string;
|
|
267
|
+
createdAt: Date;
|
|
268
|
+
updatedAt: Date;
|
|
269
|
+
providerId: string;
|
|
270
|
+
accountId: string;
|
|
271
|
+
userId: string;
|
|
272
|
+
accessToken?: string | null | undefined;
|
|
273
|
+
refreshToken?: string | null | undefined;
|
|
274
|
+
idToken?: string | null | undefined;
|
|
275
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
276
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
277
|
+
scope?: string | null | undefined;
|
|
278
|
+
password?: string | null | undefined;
|
|
279
|
+
}, ctx: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* **Through `claimedDelete`, because `delete.after` fires on the row that was read.** Two
|
|
283
|
+
* concurrent unlinks of one account both reach `after` and the trail double-counts one removal.
|
|
284
|
+
* The pair below issues the delete in `before` and runs this body only for the caller whose
|
|
285
|
+
* statement removed the row — see `../audit/evidence.ts` for the primitive, its two
|
|
286
|
+
* preconditions, and why every `delete.after` here goes through it rather than two of them.
|
|
287
|
+
*/
|
|
288
|
+
delete: import("../audit/evidence").ClaimedDelete<{
|
|
289
|
+
id: unknown;
|
|
290
|
+
}, HookContext | null | undefined>;
|
|
291
|
+
};
|
|
292
|
+
session: {
|
|
293
|
+
create: {
|
|
294
|
+
/**
|
|
295
|
+
* Stamp when this session's holder authenticated, and bind the session to its device.
|
|
296
|
+
*
|
|
297
|
+
* **`authenticatedAt` is stamped here and nowhere else.** A sign-in is the only event that is
|
|
298
|
+
* an authentication; `/token/rotate` carries the value forward through `createSession`'s
|
|
299
|
+
* override instead, which is why a rotated session keeps the original instant. A field
|
|
300
|
+
* `defaultValue` would have looked equivalent and is not: `getSessionDefaultFields` is spread
|
|
301
|
+
* into the row *after* the caller's override, so it would overwrite the carried value and
|
|
302
|
+
* silently restore the defect the column exists to fix (#558).
|
|
303
|
+
*
|
|
304
|
+
* A value already on the row is left alone — that is the rotation, passing its own.
|
|
305
|
+
*
|
|
306
|
+
* **Every other `createSession` is treated as an authentication, which is right for all of
|
|
307
|
+
* them the kit composes.** `better-auth/plugins/admin`'s `impersonateUser` would be the
|
|
308
|
+
* exception — an admin impersonating somebody would get a freshly-stamped session and could
|
|
309
|
+
* attach a provider to that account — but the kit composes no admin plugin, so it is a note
|
|
310
|
+
* for whoever does rather than a live path.
|
|
311
|
+
*
|
|
312
|
+
* Device binding only fires when the request carried device headers; a rotation passes
|
|
313
|
+
* `deviceId` by override for the same reason.
|
|
314
|
+
*/
|
|
315
|
+
before: (session: {
|
|
316
|
+
id: string;
|
|
317
|
+
createdAt: Date;
|
|
318
|
+
updatedAt: Date;
|
|
319
|
+
userId: string;
|
|
320
|
+
expiresAt: Date;
|
|
321
|
+
token: string;
|
|
322
|
+
ipAddress?: string | null | undefined;
|
|
323
|
+
userAgent?: string | null | undefined;
|
|
324
|
+
} & Record<string, unknown>, ctx: import("better-auth").GenericEndpointContext | null) => Promise<{
|
|
325
|
+
data: {
|
|
326
|
+
id: string;
|
|
327
|
+
createdAt: Date;
|
|
328
|
+
updatedAt: Date;
|
|
329
|
+
userId: string;
|
|
330
|
+
expiresAt: Date;
|
|
331
|
+
token: string;
|
|
332
|
+
ipAddress?: string | null | undefined;
|
|
333
|
+
userAgent?: string | null | undefined;
|
|
334
|
+
authenticatedAt: Date | null;
|
|
335
|
+
};
|
|
336
|
+
} | {
|
|
337
|
+
data: {
|
|
338
|
+
id: string;
|
|
339
|
+
createdAt: Date;
|
|
340
|
+
updatedAt: Date;
|
|
341
|
+
userId: string;
|
|
342
|
+
expiresAt: Date;
|
|
343
|
+
token: string;
|
|
344
|
+
ipAddress?: string | null | undefined;
|
|
345
|
+
userAgent?: string | null | undefined;
|
|
346
|
+
deviceId: string;
|
|
347
|
+
authenticatedAt: Date | null;
|
|
348
|
+
};
|
|
349
|
+
}>;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Tell whoever keyed state on this session that it has gone, and record that it did.
|
|
353
|
+
*
|
|
354
|
+
* A sign-out, a revoke, an admin ending somebody's devices — all of them land here, which is
|
|
355
|
+
* why the seam is on the row rather than on the sign-out endpoint. A handler wired to one
|
|
356
|
+
* endpoint would miss the other three, and the row is what the state was keyed by.
|
|
357
|
+
*
|
|
358
|
+
* **After, not before.** The session is already gone when this runs, so a slow or failing
|
|
359
|
+
* listener cannot hold up or refuse a sign-out — and it swallows its own failure for the same
|
|
360
|
+
* reason the audit emit does: the thing it reports has already happened.
|
|
361
|
+
*
|
|
362
|
+
* **Through `claimedDelete`, and that is the second half of #627's last hole.** `/sign-out`
|
|
363
|
+
* reaches `internalAdapter.deleteSession(token)`, so concurrent sign-outs on one cookie all find
|
|
364
|
+
* the row, all issue a delete, exactly one removes anything — and all of them reached this body.
|
|
365
|
+
* `markSessionEnded` ran for each, and `emitAfterRequest` wrote `auth/signout outcome=success`
|
|
366
|
+
* for callers that signed nobody out. The same primitive the account hooks use covers it,
|
|
367
|
+
* because the defect is `deleteWithHooks`'s rather than either table's.
|
|
368
|
+
*/
|
|
369
|
+
delete: import("../audit/evidence").ClaimedDelete<{
|
|
370
|
+
id: unknown;
|
|
371
|
+
userId: unknown;
|
|
372
|
+
}, HookContext | null | undefined>;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
hooks: {
|
|
376
|
+
/**
|
|
377
|
+
* Refuse a provider this deployment enables and could not resolve, before Better Auth answers it
|
|
378
|
+
* with the 404 it gives a provider nobody configured (#381).
|
|
379
|
+
*
|
|
380
|
+
* **This is what makes degrading not the same as degrading quietly.** The instance was built
|
|
381
|
+
* without the provider, so `socialProviders` does not hold it, so `sign-in/social` would throw
|
|
382
|
+
* `PROVIDER_NOT_FOUND` — a 404 that tells somebody who signs in with GitHub every day that
|
|
383
|
+
* GitHub was never set up. It is the same answer for a fault and for a choice, and the two are
|
|
384
|
+
* not the same fact. This hook answers 503 with its own code instead, and records the attempt.
|
|
385
|
+
*
|
|
386
|
+
* **A `before` hook rather than a Hono route, and that is forced rather than preferred.** The
|
|
387
|
+
* provider is in the request *body*, and the body is Better Auth's to read: a Hono handler ahead
|
|
388
|
+
* of the catch-all would have to consume the stream that the catch-all then hands to
|
|
389
|
+
* `instance.handler(c.req.raw)`. Here the body is already parsed against the endpoint's own
|
|
390
|
+
* schema, and this reads one field out of it.
|
|
391
|
+
*/
|
|
392
|
+
before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
393
|
+
/**
|
|
394
|
+
* Emit audit events for an auth request: sign-in (+device) from the new session, plus the
|
|
395
|
+
* send/sign-out/token event by path. Endpoint-scoped, so a rotation never emits.
|
|
396
|
+
*
|
|
397
|
+
* **`returned` is passed because this hook runs on refusals too.** Better Auth catches an
|
|
398
|
+
* endpoint's `APIError` into a result and dispatches the `after` hooks over it
|
|
399
|
+
* (`better-auth/dist/api/dispatch.mjs`), so a 401 `/token` reaches here looking exactly like one
|
|
400
|
+
* that minted a token — and wrote `auth/token_refresh outcome=success` for a request that was
|
|
401
|
+
* refused. `ctx.context.returned` is the only thing that tells them apart, and the judgment is
|
|
402
|
+
* `emitAfterRequest`'s so it is made once for every path rather than per wiring.
|
|
403
|
+
*
|
|
404
|
+
* **The two markers are passed because a refusal can answer 200.** `/sign-out` deletes nothing and
|
|
405
|
+
* says so cheerfully; `/email-otp/send-verification-otp` declines to send and answers
|
|
406
|
+
* `{"success":true}` on purpose, so a caller cannot tell a registered address from a stranger's.
|
|
407
|
+
* Neither decline is visible from anything this hook holds, so each audited path names what must
|
|
408
|
+
* have *happened* and `../audit/evidence.ts` carries it here from the place that saw it — the
|
|
409
|
+
* session row going away, and the email seam's own answer about the message, which is the send
|
|
410
|
+
* paths' evidence rather than the fact that a callback was entered. Reading them is all this does:
|
|
411
|
+
* the response has already been decided and is not touched.
|
|
412
|
+
*/
|
|
413
|
+
after: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
414
|
+
};
|
|
415
|
+
rateLimit: {
|
|
416
|
+
enabled: true;
|
|
417
|
+
storage: "database";
|
|
418
|
+
modelName: "pithyAuthRateLimit";
|
|
419
|
+
};
|
|
420
|
+
user: {
|
|
421
|
+
modelName: "pithyAuthUsers";
|
|
422
|
+
additionalFields: {
|
|
423
|
+
readonly locale: {
|
|
424
|
+
readonly type: "string";
|
|
425
|
+
readonly required: false;
|
|
426
|
+
readonly input: true;
|
|
427
|
+
readonly validator: {
|
|
428
|
+
readonly input: import("zod").ZodNullable<import("zod").ZodString>;
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
session: {
|
|
434
|
+
modelName: "pithyAuthSessions";
|
|
435
|
+
expiresIn: number;
|
|
436
|
+
updateAge: number;
|
|
437
|
+
/**
|
|
438
|
+
* Better Auth's own re-authentication window, stated rather than inherited.
|
|
439
|
+
*
|
|
440
|
+
* Its default is 24 hours, which nobody here chose, and it is the number `freshSessionMiddleware`
|
|
441
|
+
* holds `/unlink-account` to. Bringing it to the kit's own window means the two checks on that
|
|
442
|
+
* endpoint agree instead of one silently permitting a day.
|
|
443
|
+
*
|
|
444
|
+
* **It is defense in depth, not the control.** `freshSessionMiddleware` measures
|
|
445
|
+
* `session.createdAt`, which `/token/rotate` restamps — so narrowing it narrows a window that is
|
|
446
|
+
* still resettable. The control is `http/providerFreshness.ts`, which reads the authentication
|
|
447
|
+
* instant a rotation carries forward, and it is strictly the stricter of the two: `createdAt` is
|
|
448
|
+
* never older than `authenticatedAt`, so anything our gate admits this one admits too.
|
|
449
|
+
*/
|
|
450
|
+
freshAge: number;
|
|
451
|
+
additionalFields: {
|
|
452
|
+
readonly deviceId: {
|
|
453
|
+
readonly type: "string";
|
|
454
|
+
readonly required: false;
|
|
455
|
+
readonly input: false;
|
|
456
|
+
};
|
|
457
|
+
readonly familyId: {
|
|
458
|
+
readonly type: "string";
|
|
459
|
+
readonly required: false;
|
|
460
|
+
readonly input: false;
|
|
461
|
+
};
|
|
462
|
+
readonly authenticatedAt: {
|
|
463
|
+
readonly type: "date";
|
|
464
|
+
readonly required: false;
|
|
465
|
+
readonly input: false;
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
account: {
|
|
470
|
+
modelName: "pithyAuthAccounts";
|
|
471
|
+
accountLinking: {
|
|
472
|
+
enabled: true;
|
|
473
|
+
trustedProviders: ("apple" | "google")[];
|
|
474
|
+
/**
|
|
475
|
+
* **A signed-in user may attach a provider whose email differs from their account's.**
|
|
476
|
+
*
|
|
477
|
+
* Both sides are proven at that moment: they authenticated as the account, and they just
|
|
478
|
+
* authenticated with the provider. Without this, a GitHub account whose primary is not the
|
|
479
|
+
* sign-up address can never be attached at all.
|
|
480
|
+
*
|
|
481
|
+
* **This flag alone would be the wrong fix and is not the whole of it.** It permits *any*
|
|
482
|
+
* differing address, including one the provider never verified — and Better Auth performs no
|
|
483
|
+
* independent check on what a resolver hands back. The verified boundary is held by
|
|
484
|
+
* `githubUserInfo.ts`, which reports the provider's real per-address flag and never a literal;
|
|
485
|
+
* and `http/linkFreshness.ts` is what stops a stolen credential using this to attach an
|
|
486
|
+
* identity permanently. Neither is optional, and #558 records why the obvious version of that
|
|
487
|
+
* second guard — session age — was defeated by a single `/token/rotate`.
|
|
488
|
+
*/
|
|
489
|
+
allowDifferentEmails: true;
|
|
490
|
+
/**
|
|
491
|
+
* **A provider is never the last way in, which is also what makes an orphaned link recoverable.**
|
|
492
|
+
*
|
|
493
|
+
* Better Auth refuses to unlink somebody's only account, on the reasonable fear of locking them
|
|
494
|
+
* out. That fear does not apply here: magic link is unconditional in this kit, so every user can
|
|
495
|
+
* always reach their own address, and the "last account" it is protecting is a provider link
|
|
496
|
+
* rather than a credential.
|
|
497
|
+
*
|
|
498
|
+
* It also settles #554's orphan without a merge rule. A GitHub sign-in that minted an empty user
|
|
499
|
+
* holds the provider identity, so linking it to the real account collides. With this, the owner
|
|
500
|
+
* of that empty account — who controls its address, or magic link could not have created it —
|
|
501
|
+
* signs in, unlinks GitHub, and links it where it belongs. At no point does one account take an
|
|
502
|
+
* identity from another; one gives it up, authenticated as itself. A claim-from-an-empty-account
|
|
503
|
+
* rule is where takeover bugs live, and this needs none.
|
|
504
|
+
*/
|
|
505
|
+
allowUnlinkingAll: true;
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
verification: {
|
|
509
|
+
modelName: "pithyAuthVerifications";
|
|
510
|
+
};
|
|
511
|
+
socialProviders?: Record<string, unknown>;
|
|
512
|
+
plugins: [BetterAuthPlugin, {
|
|
513
|
+
id: "bearer";
|
|
514
|
+
version: string;
|
|
515
|
+
hooks: {
|
|
516
|
+
before: {
|
|
517
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
518
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
519
|
+
context: {
|
|
520
|
+
headers: Headers;
|
|
521
|
+
};
|
|
522
|
+
} | undefined>>;
|
|
523
|
+
}[];
|
|
524
|
+
after: {
|
|
525
|
+
matcher(context: import("better-auth").HookEndpointContext): true;
|
|
526
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
527
|
+
}[];
|
|
528
|
+
};
|
|
529
|
+
options: import("better-auth/plugins/bearer").BearerOptions | undefined;
|
|
530
|
+
}, {
|
|
531
|
+
id: "jwt";
|
|
532
|
+
version: string;
|
|
533
|
+
options: NoInfer<import("better-auth/plugins/jwt").JwtOptions>;
|
|
534
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
535
|
+
context: {
|
|
536
|
+
sessionConfig: {
|
|
537
|
+
cookieCacheSigner: import("better-auth").CookieCacheSigner;
|
|
538
|
+
updateAge: number;
|
|
539
|
+
expiresIn: number;
|
|
540
|
+
freshAge: number;
|
|
541
|
+
cookieRefreshCache: false | {
|
|
542
|
+
enabled: true;
|
|
543
|
+
updateAge: number;
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
} | undefined;
|
|
548
|
+
endpoints: {
|
|
549
|
+
getJwks: import("better-auth").StrictEndpoint<string, {
|
|
550
|
+
method: "GET";
|
|
551
|
+
metadata: {
|
|
552
|
+
openapi: {
|
|
553
|
+
operationId: string;
|
|
554
|
+
description: string;
|
|
555
|
+
responses: {
|
|
556
|
+
"200": {
|
|
557
|
+
description: string;
|
|
558
|
+
content: {
|
|
559
|
+
"application/json": {
|
|
560
|
+
schema: {
|
|
561
|
+
type: "object";
|
|
562
|
+
properties: {
|
|
563
|
+
keys: {
|
|
564
|
+
type: string;
|
|
565
|
+
description: string;
|
|
566
|
+
items: {
|
|
567
|
+
type: string;
|
|
568
|
+
properties: {
|
|
569
|
+
kid: {
|
|
570
|
+
type: string;
|
|
571
|
+
description: string;
|
|
572
|
+
};
|
|
573
|
+
kty: {
|
|
574
|
+
type: string;
|
|
575
|
+
description: string;
|
|
576
|
+
};
|
|
577
|
+
alg: {
|
|
578
|
+
type: string;
|
|
579
|
+
description: string;
|
|
580
|
+
};
|
|
581
|
+
use: {
|
|
582
|
+
type: string;
|
|
583
|
+
description: string;
|
|
584
|
+
enum: string[];
|
|
585
|
+
nullable: boolean;
|
|
586
|
+
};
|
|
587
|
+
n: {
|
|
588
|
+
type: string;
|
|
589
|
+
description: string;
|
|
590
|
+
nullable: boolean;
|
|
591
|
+
};
|
|
592
|
+
e: {
|
|
593
|
+
type: string;
|
|
594
|
+
description: string;
|
|
595
|
+
nullable: boolean;
|
|
596
|
+
};
|
|
597
|
+
crv: {
|
|
598
|
+
type: string;
|
|
599
|
+
description: string;
|
|
600
|
+
nullable: boolean;
|
|
601
|
+
};
|
|
602
|
+
x: {
|
|
603
|
+
type: string;
|
|
604
|
+
description: string;
|
|
605
|
+
nullable: boolean;
|
|
606
|
+
};
|
|
607
|
+
y: {
|
|
608
|
+
type: string;
|
|
609
|
+
description: string;
|
|
610
|
+
nullable: boolean;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
required: string[];
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
required: string[];
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
}, import("better-auth").JSONWebKeySet>;
|
|
626
|
+
getToken: import("better-auth").StrictEndpoint<"/token", {
|
|
627
|
+
method: "GET";
|
|
628
|
+
requireHeaders: true;
|
|
629
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
630
|
+
session: {
|
|
631
|
+
session: Record<string, any> & {
|
|
632
|
+
id: string;
|
|
633
|
+
createdAt: Date;
|
|
634
|
+
updatedAt: Date;
|
|
635
|
+
userId: string;
|
|
636
|
+
expiresAt: Date;
|
|
637
|
+
token: string;
|
|
638
|
+
ipAddress?: string | null | undefined;
|
|
639
|
+
userAgent?: string | null | undefined;
|
|
640
|
+
};
|
|
641
|
+
user: Record<string, any> & {
|
|
642
|
+
id: string;
|
|
643
|
+
createdAt: Date;
|
|
644
|
+
updatedAt: Date;
|
|
645
|
+
email: string;
|
|
646
|
+
emailVerified: boolean;
|
|
647
|
+
name: string;
|
|
648
|
+
image?: string | null | undefined;
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
}>>[];
|
|
652
|
+
metadata: {
|
|
653
|
+
openapi: {
|
|
654
|
+
operationId: string;
|
|
655
|
+
description: string;
|
|
656
|
+
responses: {
|
|
657
|
+
200: {
|
|
658
|
+
description: string;
|
|
659
|
+
content: {
|
|
660
|
+
"application/json": {
|
|
661
|
+
schema: {
|
|
662
|
+
type: "object";
|
|
663
|
+
properties: {
|
|
664
|
+
token: {
|
|
665
|
+
type: string;
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
}, {
|
|
676
|
+
token: string;
|
|
677
|
+
}>;
|
|
678
|
+
signJWT: import("better-auth").StrictEndpoint<string, {
|
|
679
|
+
method: "POST";
|
|
680
|
+
metadata: {
|
|
681
|
+
$Infer: {
|
|
682
|
+
body: {
|
|
683
|
+
payload: import("better-auth").JWTPayload;
|
|
684
|
+
overrideOptions?: import("better-auth/plugins/jwt").JwtOptions | undefined;
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
body: import("zod").ZodObject<{
|
|
689
|
+
payload: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>;
|
|
690
|
+
overrideOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
691
|
+
}, import("zod/v4/core").$strip>;
|
|
692
|
+
}, {
|
|
693
|
+
token: string;
|
|
694
|
+
}>;
|
|
695
|
+
verifyJWT: import("better-auth").StrictEndpoint<string, {
|
|
696
|
+
method: "POST";
|
|
697
|
+
metadata: {
|
|
698
|
+
$Infer: {
|
|
699
|
+
body: {
|
|
700
|
+
token: string;
|
|
701
|
+
issuer?: string;
|
|
702
|
+
};
|
|
703
|
+
response: {
|
|
704
|
+
payload: {
|
|
705
|
+
sub: string;
|
|
706
|
+
aud: string;
|
|
707
|
+
[key: string]: any;
|
|
708
|
+
} | null;
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
body: import("zod").ZodObject<{
|
|
713
|
+
token: import("zod").ZodString;
|
|
714
|
+
issuer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
715
|
+
}, import("zod/v4/core").$strip>;
|
|
716
|
+
}, {
|
|
717
|
+
payload: (import("better-auth").JWTPayload & Required<Pick<import("better-auth").JWTPayload, "sub" | "aud">>) | null;
|
|
718
|
+
}>;
|
|
719
|
+
};
|
|
720
|
+
hooks: {
|
|
721
|
+
after: {
|
|
722
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
723
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
724
|
+
}[];
|
|
725
|
+
};
|
|
726
|
+
schema: {
|
|
727
|
+
jwks: {
|
|
728
|
+
fields: {
|
|
729
|
+
publicKey: {
|
|
730
|
+
type: "string";
|
|
731
|
+
required: true;
|
|
732
|
+
};
|
|
733
|
+
privateKey: {
|
|
734
|
+
type: "string";
|
|
735
|
+
required: true;
|
|
736
|
+
};
|
|
737
|
+
createdAt: {
|
|
738
|
+
type: "date";
|
|
739
|
+
required: true;
|
|
740
|
+
};
|
|
741
|
+
expiresAt: {
|
|
742
|
+
type: "date";
|
|
743
|
+
required: false;
|
|
744
|
+
};
|
|
745
|
+
alg: {
|
|
746
|
+
type: "string";
|
|
747
|
+
required: false;
|
|
748
|
+
};
|
|
749
|
+
crv: {
|
|
750
|
+
type: "string";
|
|
751
|
+
required: false;
|
|
752
|
+
};
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
}, {
|
|
757
|
+
id: "magic-link";
|
|
758
|
+
version: string;
|
|
759
|
+
endpoints: {
|
|
760
|
+
signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
|
|
761
|
+
method: "POST";
|
|
762
|
+
requireHeaders: true;
|
|
763
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
764
|
+
body: import("zod").ZodObject<{
|
|
765
|
+
email: import("zod").ZodEmail;
|
|
766
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
767
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
768
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
769
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
770
|
+
metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
771
|
+
}, import("zod/v4/core").$strip>;
|
|
772
|
+
metadata: {
|
|
773
|
+
openapi: {
|
|
774
|
+
operationId: string;
|
|
775
|
+
description: string;
|
|
776
|
+
responses: {
|
|
777
|
+
200: {
|
|
778
|
+
description: string;
|
|
779
|
+
content: {
|
|
780
|
+
"application/json": {
|
|
781
|
+
schema: {
|
|
782
|
+
type: "object";
|
|
783
|
+
properties: {
|
|
784
|
+
status: {
|
|
785
|
+
type: string;
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
}, {
|
|
796
|
+
status: boolean;
|
|
797
|
+
}>;
|
|
798
|
+
magicLinkVerify: import("better-auth").StrictEndpoint<"/magic-link/verify", {
|
|
799
|
+
method: "GET";
|
|
800
|
+
query: import("zod").ZodObject<{
|
|
801
|
+
token: import("zod").ZodString;
|
|
802
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
803
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
804
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
805
|
+
}, import("zod/v4/core").$strip>;
|
|
806
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
807
|
+
requireHeaders: true;
|
|
808
|
+
metadata: {
|
|
809
|
+
openapi: {
|
|
810
|
+
operationId: string;
|
|
811
|
+
description: string;
|
|
812
|
+
responses: {
|
|
813
|
+
200: {
|
|
814
|
+
description: string;
|
|
815
|
+
content: {
|
|
816
|
+
"application/json": {
|
|
817
|
+
schema: {
|
|
818
|
+
type: "object";
|
|
819
|
+
properties: {
|
|
820
|
+
session: {
|
|
821
|
+
$ref: string;
|
|
822
|
+
};
|
|
823
|
+
user: {
|
|
824
|
+
$ref: string;
|
|
825
|
+
};
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
}, {
|
|
835
|
+
token: string;
|
|
836
|
+
user: {
|
|
837
|
+
id: string;
|
|
838
|
+
createdAt: Date;
|
|
839
|
+
updatedAt: Date;
|
|
840
|
+
email: string;
|
|
841
|
+
emailVerified: boolean;
|
|
842
|
+
name: string;
|
|
843
|
+
image?: string | null | undefined;
|
|
844
|
+
};
|
|
845
|
+
session: {
|
|
846
|
+
id: string;
|
|
847
|
+
createdAt: Date;
|
|
848
|
+
updatedAt: Date;
|
|
849
|
+
userId: string;
|
|
850
|
+
expiresAt: Date;
|
|
851
|
+
token: string;
|
|
852
|
+
ipAddress?: string | null | undefined;
|
|
853
|
+
userAgent?: string | null | undefined;
|
|
854
|
+
};
|
|
855
|
+
}>;
|
|
856
|
+
};
|
|
857
|
+
rateLimit: {
|
|
858
|
+
pathMatcher(path: string): boolean;
|
|
859
|
+
window: number;
|
|
860
|
+
max: number;
|
|
861
|
+
}[];
|
|
862
|
+
options: import("better-auth/plugins/magic-link").MagicLinkOptions;
|
|
863
|
+
}, {
|
|
864
|
+
id: "email-otp";
|
|
865
|
+
version: string;
|
|
866
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
867
|
+
options: {
|
|
868
|
+
emailVerification: {
|
|
869
|
+
sendVerificationEmail(data: {
|
|
870
|
+
user: import("better-auth").User;
|
|
871
|
+
url: string;
|
|
872
|
+
token: string;
|
|
873
|
+
}, request: Request | undefined): Promise<void>;
|
|
874
|
+
};
|
|
875
|
+
};
|
|
876
|
+
} | undefined;
|
|
877
|
+
endpoints: {
|
|
878
|
+
sendVerificationOTP: import("better-auth").StrictEndpoint<"/email-otp/send-verification-otp", {
|
|
879
|
+
method: "POST";
|
|
880
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
881
|
+
body: import("zod").ZodObject<{
|
|
882
|
+
email: import("zod").ZodString;
|
|
883
|
+
type: import("zod").ZodEnum<{
|
|
884
|
+
"sign-in": "sign-in";
|
|
885
|
+
"change-email": "change-email";
|
|
886
|
+
"email-verification": "email-verification";
|
|
887
|
+
"forget-password": "forget-password";
|
|
888
|
+
}>;
|
|
889
|
+
}, import("zod/v4/core").$strip>;
|
|
890
|
+
metadata: {
|
|
891
|
+
openapi: {
|
|
892
|
+
operationId: string;
|
|
893
|
+
description: string;
|
|
894
|
+
responses: {
|
|
895
|
+
200: {
|
|
896
|
+
description: string;
|
|
897
|
+
content: {
|
|
898
|
+
"application/json": {
|
|
899
|
+
schema: {
|
|
900
|
+
type: "object";
|
|
901
|
+
properties: {
|
|
902
|
+
success: {
|
|
903
|
+
type: string;
|
|
904
|
+
};
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
};
|
|
908
|
+
};
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
}, {
|
|
914
|
+
success: boolean;
|
|
915
|
+
}>;
|
|
916
|
+
createVerificationOTP: import("better-auth").StrictEndpoint<string, {
|
|
917
|
+
method: "POST";
|
|
918
|
+
body: import("zod").ZodObject<{
|
|
919
|
+
email: import("zod").ZodString;
|
|
920
|
+
type: import("zod").ZodEnum<{
|
|
921
|
+
"sign-in": "sign-in";
|
|
922
|
+
"change-email": "change-email";
|
|
923
|
+
"email-verification": "email-verification";
|
|
924
|
+
"forget-password": "forget-password";
|
|
925
|
+
}>;
|
|
926
|
+
}, import("zod/v4/core").$strip>;
|
|
927
|
+
metadata: {
|
|
928
|
+
openapi: {
|
|
929
|
+
operationId: string;
|
|
930
|
+
description: string;
|
|
931
|
+
responses: {
|
|
932
|
+
200: {
|
|
933
|
+
description: string;
|
|
934
|
+
content: {
|
|
935
|
+
"application/json": {
|
|
936
|
+
schema: {
|
|
937
|
+
type: "string";
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
};
|
|
945
|
+
}, string>;
|
|
946
|
+
getVerificationOTP: import("better-auth").StrictEndpoint<string, {
|
|
947
|
+
method: "GET";
|
|
948
|
+
query: import("zod").ZodObject<{
|
|
949
|
+
email: import("zod").ZodString;
|
|
950
|
+
type: import("zod").ZodEnum<{
|
|
951
|
+
"sign-in": "sign-in";
|
|
952
|
+
"change-email": "change-email";
|
|
953
|
+
"email-verification": "email-verification";
|
|
954
|
+
"forget-password": "forget-password";
|
|
955
|
+
}>;
|
|
956
|
+
}, import("zod/v4/core").$strip>;
|
|
957
|
+
metadata: {
|
|
958
|
+
openapi: {
|
|
959
|
+
operationId: string;
|
|
960
|
+
description: string;
|
|
961
|
+
responses: {
|
|
962
|
+
"200": {
|
|
963
|
+
description: string;
|
|
964
|
+
content: {
|
|
965
|
+
"application/json": {
|
|
966
|
+
schema: {
|
|
967
|
+
type: "object";
|
|
968
|
+
properties: {
|
|
969
|
+
otp: {
|
|
970
|
+
type: string;
|
|
971
|
+
nullable: boolean;
|
|
972
|
+
description: string;
|
|
973
|
+
};
|
|
974
|
+
};
|
|
975
|
+
required: string[];
|
|
976
|
+
};
|
|
977
|
+
};
|
|
978
|
+
};
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
};
|
|
982
|
+
};
|
|
983
|
+
}, {
|
|
984
|
+
otp: null;
|
|
985
|
+
} | {
|
|
986
|
+
otp: string;
|
|
987
|
+
}>;
|
|
988
|
+
checkVerificationOTP: import("better-auth").StrictEndpoint<"/email-otp/check-verification-otp", {
|
|
989
|
+
method: "POST";
|
|
990
|
+
body: import("zod").ZodObject<{
|
|
991
|
+
email: import("zod").ZodString;
|
|
992
|
+
type: import("zod").ZodEnum<{
|
|
993
|
+
"sign-in": "sign-in";
|
|
994
|
+
"change-email": "change-email";
|
|
995
|
+
"email-verification": "email-verification";
|
|
996
|
+
"forget-password": "forget-password";
|
|
997
|
+
}>;
|
|
998
|
+
otp: import("zod").ZodString;
|
|
999
|
+
}, import("zod/v4/core").$strip>;
|
|
1000
|
+
metadata: {
|
|
1001
|
+
openapi: {
|
|
1002
|
+
operationId: string;
|
|
1003
|
+
description: string;
|
|
1004
|
+
responses: {
|
|
1005
|
+
200: {
|
|
1006
|
+
description: string;
|
|
1007
|
+
content: {
|
|
1008
|
+
"application/json": {
|
|
1009
|
+
schema: {
|
|
1010
|
+
type: "object";
|
|
1011
|
+
properties: {
|
|
1012
|
+
success: {
|
|
1013
|
+
type: string;
|
|
1014
|
+
};
|
|
1015
|
+
};
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
}, {
|
|
1024
|
+
success: boolean;
|
|
1025
|
+
}>;
|
|
1026
|
+
verifyEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/verify-email", {
|
|
1027
|
+
method: "POST";
|
|
1028
|
+
body: import("zod").ZodObject<{
|
|
1029
|
+
email: import("zod").ZodString;
|
|
1030
|
+
otp: import("zod").ZodString;
|
|
1031
|
+
}, import("zod/v4/core").$strip>;
|
|
1032
|
+
metadata: {
|
|
1033
|
+
openapi: {
|
|
1034
|
+
description: string;
|
|
1035
|
+
responses: {
|
|
1036
|
+
200: {
|
|
1037
|
+
description: string;
|
|
1038
|
+
content: {
|
|
1039
|
+
"application/json": {
|
|
1040
|
+
schema: {
|
|
1041
|
+
type: "object";
|
|
1042
|
+
properties: {
|
|
1043
|
+
status: {
|
|
1044
|
+
type: string;
|
|
1045
|
+
description: string;
|
|
1046
|
+
enum: boolean[];
|
|
1047
|
+
};
|
|
1048
|
+
token: {
|
|
1049
|
+
type: string;
|
|
1050
|
+
nullable: boolean;
|
|
1051
|
+
description: string;
|
|
1052
|
+
};
|
|
1053
|
+
user: {
|
|
1054
|
+
$ref: string;
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
required: string[];
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
};
|
|
1061
|
+
};
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
}, {
|
|
1066
|
+
status: boolean;
|
|
1067
|
+
token: string;
|
|
1068
|
+
user: {
|
|
1069
|
+
id: string;
|
|
1070
|
+
createdAt: Date;
|
|
1071
|
+
updatedAt: Date;
|
|
1072
|
+
email: string;
|
|
1073
|
+
emailVerified: boolean;
|
|
1074
|
+
name: string;
|
|
1075
|
+
image?: string | null | undefined;
|
|
1076
|
+
} & Record<string, any>;
|
|
1077
|
+
} | {
|
|
1078
|
+
status: boolean;
|
|
1079
|
+
token: null;
|
|
1080
|
+
user: {
|
|
1081
|
+
id: string;
|
|
1082
|
+
createdAt: Date;
|
|
1083
|
+
updatedAt: Date;
|
|
1084
|
+
email: string;
|
|
1085
|
+
emailVerified: boolean;
|
|
1086
|
+
name: string;
|
|
1087
|
+
image?: string | null | undefined;
|
|
1088
|
+
} & Record<string, any>;
|
|
1089
|
+
}>;
|
|
1090
|
+
signInEmailOTP: import("better-auth").StrictEndpoint<"/sign-in/email-otp", {
|
|
1091
|
+
method: "POST";
|
|
1092
|
+
body: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
1093
|
+
email: import("zod").ZodString;
|
|
1094
|
+
otp: import("zod").ZodString;
|
|
1095
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1096
|
+
image: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1097
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
1098
|
+
metadata: {
|
|
1099
|
+
openapi: {
|
|
1100
|
+
operationId: string;
|
|
1101
|
+
description: string;
|
|
1102
|
+
responses: {
|
|
1103
|
+
200: {
|
|
1104
|
+
description: string;
|
|
1105
|
+
content: {
|
|
1106
|
+
"application/json": {
|
|
1107
|
+
schema: {
|
|
1108
|
+
type: "object";
|
|
1109
|
+
properties: {
|
|
1110
|
+
token: {
|
|
1111
|
+
type: string;
|
|
1112
|
+
description: string;
|
|
1113
|
+
};
|
|
1114
|
+
user: {
|
|
1115
|
+
$ref: string;
|
|
1116
|
+
};
|
|
1117
|
+
};
|
|
1118
|
+
required: string[];
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
};
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
}, {
|
|
1127
|
+
token: string;
|
|
1128
|
+
user: {
|
|
1129
|
+
id: string;
|
|
1130
|
+
createdAt: Date;
|
|
1131
|
+
updatedAt: Date;
|
|
1132
|
+
email: string;
|
|
1133
|
+
emailVerified: boolean;
|
|
1134
|
+
name: string;
|
|
1135
|
+
image?: string | null | undefined;
|
|
1136
|
+
};
|
|
1137
|
+
}>;
|
|
1138
|
+
requestPasswordResetEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/request-password-reset", {
|
|
1139
|
+
method: "POST";
|
|
1140
|
+
body: import("zod").ZodObject<{
|
|
1141
|
+
email: import("zod").ZodString;
|
|
1142
|
+
}, import("zod/v4/core").$strip>;
|
|
1143
|
+
metadata: {
|
|
1144
|
+
openapi: {
|
|
1145
|
+
operationId: string;
|
|
1146
|
+
description: string;
|
|
1147
|
+
responses: {
|
|
1148
|
+
200: {
|
|
1149
|
+
description: string;
|
|
1150
|
+
content: {
|
|
1151
|
+
"application/json": {
|
|
1152
|
+
schema: {
|
|
1153
|
+
type: "object";
|
|
1154
|
+
properties: {
|
|
1155
|
+
success: {
|
|
1156
|
+
type: string;
|
|
1157
|
+
description: string;
|
|
1158
|
+
};
|
|
1159
|
+
};
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
};
|
|
1166
|
+
};
|
|
1167
|
+
}, {
|
|
1168
|
+
success: boolean;
|
|
1169
|
+
}>;
|
|
1170
|
+
forgetPasswordEmailOTP: import("better-auth").StrictEndpoint<"/forget-password/email-otp", {
|
|
1171
|
+
method: "POST";
|
|
1172
|
+
body: import("zod").ZodObject<{
|
|
1173
|
+
email: import("zod").ZodString;
|
|
1174
|
+
}, import("zod/v4/core").$strip>;
|
|
1175
|
+
metadata: {
|
|
1176
|
+
openapi: {
|
|
1177
|
+
operationId: string;
|
|
1178
|
+
description: string;
|
|
1179
|
+
responses: {
|
|
1180
|
+
200: {
|
|
1181
|
+
description: string;
|
|
1182
|
+
content: {
|
|
1183
|
+
"application/json": {
|
|
1184
|
+
schema: {
|
|
1185
|
+
type: "object";
|
|
1186
|
+
properties: {
|
|
1187
|
+
success: {
|
|
1188
|
+
type: string;
|
|
1189
|
+
description: string;
|
|
1190
|
+
};
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
};
|
|
1195
|
+
};
|
|
1196
|
+
};
|
|
1197
|
+
};
|
|
1198
|
+
};
|
|
1199
|
+
}, {
|
|
1200
|
+
success: boolean;
|
|
1201
|
+
}>;
|
|
1202
|
+
resetPasswordEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/reset-password", {
|
|
1203
|
+
method: "POST";
|
|
1204
|
+
body: import("zod").ZodObject<{
|
|
1205
|
+
email: import("zod").ZodString;
|
|
1206
|
+
otp: import("zod").ZodString;
|
|
1207
|
+
password: import("zod").ZodString;
|
|
1208
|
+
}, import("zod/v4/core").$strip>;
|
|
1209
|
+
metadata: {
|
|
1210
|
+
openapi: {
|
|
1211
|
+
operationId: string;
|
|
1212
|
+
description: string;
|
|
1213
|
+
responses: {
|
|
1214
|
+
200: {
|
|
1215
|
+
description: string;
|
|
1216
|
+
content: {
|
|
1217
|
+
"application/json": {
|
|
1218
|
+
schema: {
|
|
1219
|
+
type: "object";
|
|
1220
|
+
properties: {
|
|
1221
|
+
success: {
|
|
1222
|
+
type: string;
|
|
1223
|
+
};
|
|
1224
|
+
};
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
};
|
|
1231
|
+
};
|
|
1232
|
+
}, {
|
|
1233
|
+
success: boolean;
|
|
1234
|
+
}>;
|
|
1235
|
+
requestEmailChangeEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/request-email-change", {
|
|
1236
|
+
method: "POST";
|
|
1237
|
+
body: import("zod").ZodObject<{
|
|
1238
|
+
newEmail: import("zod").ZodString;
|
|
1239
|
+
otp: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1240
|
+
}, import("zod/v4/core").$strip>;
|
|
1241
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
1242
|
+
session: {
|
|
1243
|
+
session: Record<string, any> & {
|
|
1244
|
+
id: string;
|
|
1245
|
+
createdAt: Date;
|
|
1246
|
+
updatedAt: Date;
|
|
1247
|
+
userId: string;
|
|
1248
|
+
expiresAt: Date;
|
|
1249
|
+
token: string;
|
|
1250
|
+
ipAddress?: string | null | undefined;
|
|
1251
|
+
userAgent?: string | null | undefined;
|
|
1252
|
+
};
|
|
1253
|
+
user: Record<string, any> & {
|
|
1254
|
+
id: string;
|
|
1255
|
+
createdAt: Date;
|
|
1256
|
+
updatedAt: Date;
|
|
1257
|
+
email: string;
|
|
1258
|
+
emailVerified: boolean;
|
|
1259
|
+
name: string;
|
|
1260
|
+
image?: string | null | undefined;
|
|
1261
|
+
};
|
|
1262
|
+
};
|
|
1263
|
+
}>>[];
|
|
1264
|
+
metadata: {
|
|
1265
|
+
openapi: {
|
|
1266
|
+
operationId: string;
|
|
1267
|
+
description: string;
|
|
1268
|
+
responses: {
|
|
1269
|
+
200: {
|
|
1270
|
+
description: string;
|
|
1271
|
+
content: {
|
|
1272
|
+
"application/json": {
|
|
1273
|
+
schema: {
|
|
1274
|
+
type: "object";
|
|
1275
|
+
properties: {
|
|
1276
|
+
success: {
|
|
1277
|
+
type: string;
|
|
1278
|
+
};
|
|
1279
|
+
};
|
|
1280
|
+
};
|
|
1281
|
+
};
|
|
1282
|
+
};
|
|
1283
|
+
};
|
|
1284
|
+
};
|
|
1285
|
+
};
|
|
1286
|
+
};
|
|
1287
|
+
}, {
|
|
1288
|
+
success: boolean;
|
|
1289
|
+
}>;
|
|
1290
|
+
changeEmailEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/change-email", {
|
|
1291
|
+
method: "POST";
|
|
1292
|
+
body: import("zod").ZodObject<{
|
|
1293
|
+
newEmail: import("zod").ZodString;
|
|
1294
|
+
otp: import("zod").ZodString;
|
|
1295
|
+
}, import("zod/v4/core").$strip>;
|
|
1296
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
1297
|
+
session: {
|
|
1298
|
+
session: Record<string, any> & {
|
|
1299
|
+
id: string;
|
|
1300
|
+
createdAt: Date;
|
|
1301
|
+
updatedAt: Date;
|
|
1302
|
+
userId: string;
|
|
1303
|
+
expiresAt: Date;
|
|
1304
|
+
token: string;
|
|
1305
|
+
ipAddress?: string | null | undefined;
|
|
1306
|
+
userAgent?: string | null | undefined;
|
|
1307
|
+
};
|
|
1308
|
+
user: Record<string, any> & {
|
|
1309
|
+
id: string;
|
|
1310
|
+
createdAt: Date;
|
|
1311
|
+
updatedAt: Date;
|
|
1312
|
+
email: string;
|
|
1313
|
+
emailVerified: boolean;
|
|
1314
|
+
name: string;
|
|
1315
|
+
image?: string | null | undefined;
|
|
1316
|
+
};
|
|
1317
|
+
};
|
|
1318
|
+
}>>[];
|
|
1319
|
+
metadata: {
|
|
1320
|
+
openapi: {
|
|
1321
|
+
operationId: string;
|
|
1322
|
+
description: string;
|
|
1323
|
+
responses: {
|
|
1324
|
+
200: {
|
|
1325
|
+
description: string;
|
|
1326
|
+
content: {
|
|
1327
|
+
"application/json": {
|
|
1328
|
+
schema: {
|
|
1329
|
+
type: "object";
|
|
1330
|
+
properties: {
|
|
1331
|
+
success: {
|
|
1332
|
+
type: string;
|
|
1333
|
+
};
|
|
1334
|
+
};
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
};
|
|
1340
|
+
};
|
|
1341
|
+
};
|
|
1342
|
+
}, {
|
|
1343
|
+
success: boolean;
|
|
1344
|
+
}>;
|
|
1345
|
+
};
|
|
1346
|
+
hooks: {
|
|
1347
|
+
after: {
|
|
1348
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
1349
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
1350
|
+
}[];
|
|
1351
|
+
};
|
|
1352
|
+
rateLimit: ({
|
|
1353
|
+
pathMatcher(path: string): path is "/email-otp/send-verification-otp";
|
|
1354
|
+
window: number;
|
|
1355
|
+
max: number;
|
|
1356
|
+
} | {
|
|
1357
|
+
pathMatcher(path: string): path is "/email-otp/check-verification-otp";
|
|
1358
|
+
window: number;
|
|
1359
|
+
max: number;
|
|
1360
|
+
} | {
|
|
1361
|
+
pathMatcher(path: string): path is "/email-otp/verify-email";
|
|
1362
|
+
window: number;
|
|
1363
|
+
max: number;
|
|
1364
|
+
} | {
|
|
1365
|
+
pathMatcher(path: string): path is "/sign-in/email-otp";
|
|
1366
|
+
window: number;
|
|
1367
|
+
max: number;
|
|
1368
|
+
} | {
|
|
1369
|
+
pathMatcher(path: string): path is "/email-otp/request-password-reset";
|
|
1370
|
+
window: number;
|
|
1371
|
+
max: number;
|
|
1372
|
+
} | {
|
|
1373
|
+
pathMatcher(path: string): path is "/email-otp/reset-password";
|
|
1374
|
+
window: number;
|
|
1375
|
+
max: number;
|
|
1376
|
+
} | {
|
|
1377
|
+
pathMatcher(path: string): path is "/forget-password/email-otp";
|
|
1378
|
+
window: number;
|
|
1379
|
+
max: number;
|
|
1380
|
+
} | {
|
|
1381
|
+
pathMatcher(path: string): path is "/email-otp/request-email-change";
|
|
1382
|
+
window: number;
|
|
1383
|
+
max: number;
|
|
1384
|
+
} | {
|
|
1385
|
+
pathMatcher(path: string): path is "/email-otp/change-email";
|
|
1386
|
+
window: number;
|
|
1387
|
+
max: number;
|
|
1388
|
+
})[];
|
|
1389
|
+
options: import("better-auth/plugins/email-otp").EmailOTPOptions;
|
|
1390
|
+
$ERROR_CODES: {
|
|
1391
|
+
OTP_EXPIRED: import("better-auth").RawError<"OTP_EXPIRED">;
|
|
1392
|
+
INVALID_OTP: import("better-auth").RawError<"INVALID_OTP">;
|
|
1393
|
+
TOO_MANY_ATTEMPTS: import("better-auth").RawError<"TOO_MANY_ATTEMPTS">;
|
|
1394
|
+
};
|
|
1395
|
+
}, BetterAuthPlugin, ...Plugins];
|
|
1396
|
+
} | {
|
|
174
1397
|
appName: string;
|
|
175
1398
|
baseURL: string;
|
|
176
1399
|
basePath: string;
|
|
@@ -187,6 +1410,7 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
187
1410
|
advanced: {
|
|
188
1411
|
database: {
|
|
189
1412
|
generateId: () => string;
|
|
1413
|
+
validateSchema: false;
|
|
190
1414
|
};
|
|
191
1415
|
};
|
|
192
1416
|
onAPIError: {
|
|
@@ -254,7 +1478,6 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
254
1478
|
createdAt: Date;
|
|
255
1479
|
updatedAt: Date;
|
|
256
1480
|
providerId: string;
|
|
257
|
-
issuer: string;
|
|
258
1481
|
accountId: string;
|
|
259
1482
|
userId: string;
|
|
260
1483
|
accessToken?: string | null | undefined;
|