@pithy-sh/auth 0.8.0 → 0.10.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 +12 -2
- package/dist/audit/actions.d.ts +21 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +22 -1
- package/dist/audit/emit.js +1 -1
- 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 +70 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +28 -7
- package/dist/client/lifecycle.d.ts +19 -0
- package/dist/client/lifecycle.d.ts.map +1 -0
- package/dist/client/lifecycle.js +25 -0
- package/dist/client/projection.d.ts +4 -0
- package/dist/client/projection.d.ts.map +1 -1
- package/dist/data/betterAuth.d.ts +5 -1
- package/dist/data/betterAuth.d.ts.map +1 -1
- package/dist/data/betterAuth.js +7 -3
- package/dist/data/kitFields.d.ts +20 -25
- package/dist/data/kitFields.d.ts.map +1 -1
- package/dist/data/kitFields.js +28 -32
- package/dist/data/tables.d.ts +29 -3
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +5 -3
- package/dist/data/userLifecycle.d.ts +61 -0
- package/dist/data/userLifecycle.d.ts.map +1 -0
- package/dist/data/userLifecycle.js +50 -0
- 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/guards.d.ts +23 -1
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +28 -3
- package/dist/http/lifecycleGate.d.ts +18 -0
- package/dist/http/lifecycleGate.d.ts.map +1 -0
- package/dist/http/lifecycleGate.js +75 -0
- package/dist/http/middleware.d.ts +5 -0
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +113 -21
- package/dist/http/providerRefusal.d.ts +8 -7
- package/dist/http/providerRefusal.d.ts.map +1 -1
- package/dist/http/providerRefusal.js +37 -32
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +23 -5
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +20 -1
- package/dist/instance/auth.d.ts +1280 -5
- package/dist/instance/auth.d.ts.map +1 -1
- package/dist/instance/auth.js +59 -4
- 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/microsoftEmail.d.ts +70 -0
- package/dist/instance/microsoftEmail.d.ts.map +1 -0
- package/dist/instance/microsoftEmail.js +96 -0
- package/dist/instance/providerSignInGate.d.ts +14 -12
- package/dist/instance/providerSignInGate.d.ts.map +1 -1
- package/dist/instance/providerSignInGate.js +23 -20
- package/dist/instance/providers.d.ts +7 -5
- package/dist/instance/providers.d.ts.map +1 -1
- package/dist/instance/providers.js +5 -3
- package/dist/instance/secrets.d.ts +232 -4
- package/dist/instance/secrets.d.ts.map +1 -1
- package/dist/instance/secrets.js +129 -7
- 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/lifecycle/enforce.d.ts +40 -0
- package/dist/lifecycle/enforce.d.ts.map +1 -0
- package/dist/lifecycle/enforce.js +70 -0
- package/dist/lifecycle/hooks.d.ts +53 -0
- package/dist/lifecycle/hooks.d.ts.map +1 -0
- package/dist/lifecycle/hooks.js +2 -0
- package/dist/lifecycle/request.d.ts +15 -0
- package/dist/lifecycle/request.d.ts.map +1 -0
- package/dist/lifecycle/request.js +27 -0
- package/dist/lifecycle/state.d.ts +64 -0
- package/dist/lifecycle/state.d.ts.map +1 -0
- package/dist/lifecycle/state.js +90 -0
- package/dist/lifecycle/transitions.d.ts +132 -0
- package/dist/lifecycle/transitions.d.ts.map +1 -0
- package/dist/lifecycle/transitions.js +349 -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/0004_user_lifecycle.d.ts +28 -0
- package/dist/migrations/0004_user_lifecycle.d.ts.map +1 -0
- package/dist/migrations/0004_user_lifecycle.js +47 -0
- package/dist/migrations/set.d.ts +3 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +6 -2
- package/dist/peer.d.ts +4 -0
- package/dist/peer.d.ts.map +1 -1
- package/dist/test-utils/liveApp.d.ts +26 -0
- package/dist/test-utils/liveApp.d.ts.map +1 -1
- package/dist/test-utils/liveApp.js +1 -0
- 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 +204 -0
- package/dist/test-utils/scopedBackend.d.ts.map +1 -0
- package/dist/test-utils/scopedBackend.js +166 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.d.ts.map +1 -1
- package/dist/version.generated.js +1 -1
- package/docs/account-lifecycle.md +105 -0
- package/docs/apple-signin.md +7 -1
- package/docs/facebook-oauth.md +7 -1
- package/docs/github-oauth.md +7 -1
- package/docs/google-oauth.md +7 -1
- package/docs/microsoft-oauth.md +177 -0
- package/docs/server-authoritative.md +182 -0
- package/package.json +11 -8
- package/pithy.manifest.json +17 -3
- package/src/audit/actions.ts +23 -0
- package/src/audit/emit.ts +1 -1
- 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 +170 -38
- package/src/client/lifecycle.ts +27 -0
- package/src/client/projection.ts +4 -0
- package/src/data/betterAuth.ts +23 -2
- package/src/data/kitFields.ts +27 -0
- package/src/data/tables.ts +4 -2
- package/src/data/userLifecycle.ts +80 -0
- package/src/http/credentialResign.ts +268 -0
- package/src/http/errorCallbackUrl.ts +21 -13
- package/src/http/guards.ts +29 -1
- package/src/http/lifecycleGate.ts +78 -0
- package/src/http/middleware.ts +161 -37
- package/src/http/providerRefusal.ts +40 -32
- package/src/http/resolve.ts +34 -5
- package/src/http/routes.ts +39 -2
- package/src/instance/auth.ts +91 -6
- package/src/instance/jwksReencryption.ts +206 -0
- package/src/instance/microsoftEmail.ts +111 -0
- package/src/instance/providerSignInGate.ts +30 -27
- package/src/instance/providers.ts +8 -4
- package/src/instance/secrets.ts +153 -6
- package/src/instance/sessionSecrets.ts +64 -0
- package/src/lifecycle/enforce.ts +89 -0
- package/src/lifecycle/hooks.ts +54 -0
- package/src/lifecycle/request.ts +31 -0
- package/src/lifecycle/state.ts +101 -0
- package/src/lifecycle/transitions.ts +483 -0
- package/src/migrations/0001_init.ts +8 -10
- package/src/migrations/0003_account_issuer_nullable.ts +199 -0
- package/src/migrations/0004_user_lifecycle.ts +68 -0
- package/src/migrations/set.ts +5 -1
- package/src/test-utils/liveApp.ts +2 -1
- package/src/test-utils/schemaDrift.ts +82 -0
- package/src/test-utils/scopedBackend.ts +137 -0
- package/src/version.generated.ts +1 -1
package/dist/instance/auth.d.ts
CHANGED
|
@@ -6,7 +6,18 @@ 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;
|
|
11
|
+
/**
|
|
12
|
+
* The providers whose email links into an existing account on the strength of their name alone.
|
|
13
|
+
*
|
|
14
|
+
* Google and Apple, and nobody else, permanently. Facebook's verified flag is asserted in its block with
|
|
15
|
+
* a reason; GitHub's comes from its emails API; Microsoft's is decided per sign-in by
|
|
16
|
+
* `./microsoftEmail.ts`, because Entra ID cannot vouch for an email it did not verify. Adding a provider
|
|
17
|
+
* here would skip the verified half of the linking gate for it — `./providerSignInGate.ts` reads the same
|
|
18
|
+
* list off the context.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TRUSTED_PROVIDERS: readonly string[];
|
|
10
21
|
/**
|
|
11
22
|
* The seeding guard: a new account may be created only for an email a provider has **verified**.
|
|
12
23
|
*
|
|
@@ -20,7 +31,7 @@ export declare function socialProviders(deps: AuthInstanceDeps): Record<string,
|
|
|
20
31
|
export declare function isUnverifiedSignup(user: {
|
|
21
32
|
emailVerified?: boolean | null;
|
|
22
33
|
}): boolean;
|
|
23
|
-
/** The endpoint context a database hook is handed, narrowed to
|
|
34
|
+
/** The endpoint context a database hook is handed, narrowed to what attribution and refusal need. */
|
|
24
35
|
interface HookContext {
|
|
25
36
|
headers?: Headers;
|
|
26
37
|
context?: {
|
|
@@ -30,6 +41,8 @@ interface HookContext {
|
|
|
30
41
|
};
|
|
31
42
|
} | null;
|
|
32
43
|
};
|
|
44
|
+
/** The endpoint path this write was reached from, e.g. `/callback/google`. Absent outside an endpoint. */
|
|
45
|
+
path?: string;
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* What the instance hands to Pithy's email seam to deliver. The route never sends inline — the hook
|
|
@@ -71,8 +84,15 @@ export type SendAuthEmail = (message: AuthEmailMessage) => Promise<AuthEmailDeli
|
|
|
71
84
|
export interface AuthInstanceDeps<Plugins extends readonly BetterAuthPlugin[] = readonly BetterAuthPlugin[]> extends ResolvedProviders {
|
|
72
85
|
/** The shared Kysely over the `pithy_auth_*` tables (carries `CamelCasePlugin`). */
|
|
73
86
|
db: AuthDatabase;
|
|
74
|
-
/** The Better-Auth signing/encryption secret, sourced from `@pithy-sh/secrets
|
|
87
|
+
/** The Better-Auth signing/encryption secret, sourced from `@pithy-sh/secrets` — the current version. */
|
|
75
88
|
secret: string;
|
|
89
|
+
/**
|
|
90
|
+
* Every retained version of the session secret, when the caller resolved them (#602). Given, Better Auth
|
|
91
|
+
* gets the whole version set — newest first — so a value sealed under the previous version still opens
|
|
92
|
+
* through a rotation's overlap; see `./sessionSecrets.ts`. Absent, it gets `secret` alone, which is what an
|
|
93
|
+
* instance built outside a request (a seed, a test) has always had.
|
|
94
|
+
*/
|
|
95
|
+
sessionSecrets?: SessionSecretVersions;
|
|
76
96
|
/** The public base URL of this environment's auth worker (no trailing slash). */
|
|
77
97
|
baseURL: string;
|
|
78
98
|
/** The mount path; must equal the Hono route the handler is mounted under. */
|
|
@@ -171,10 +191,14 @@ export type AuthInstance<Plugins extends readonly BetterAuthPlugin[] = readonly
|
|
|
171
191
|
* UUIDs; rate limiting is durable (D1-backed) since memory limiting is per-isolate on Workers.
|
|
172
192
|
*/
|
|
173
193
|
export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin[]>(deps: AuthInstanceDeps<Plugins>): import("better-auth").Auth<{
|
|
194
|
+
secrets: {
|
|
195
|
+
version: number;
|
|
196
|
+
value: string;
|
|
197
|
+
}[];
|
|
198
|
+
secret: string;
|
|
174
199
|
appName: string;
|
|
175
200
|
baseURL: string;
|
|
176
201
|
basePath: string;
|
|
177
|
-
secret: string;
|
|
178
202
|
telemetry: {
|
|
179
203
|
enabled: false;
|
|
180
204
|
};
|
|
@@ -187,6 +211,7 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
187
211
|
advanced: {
|
|
188
212
|
database: {
|
|
189
213
|
generateId: () => string;
|
|
214
|
+
validateSchema: false;
|
|
190
215
|
};
|
|
191
216
|
};
|
|
192
217
|
onAPIError: {
|
|
@@ -254,7 +279,6 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
254
279
|
createdAt: Date;
|
|
255
280
|
updatedAt: Date;
|
|
256
281
|
providerId: string;
|
|
257
|
-
issuer: string;
|
|
258
282
|
accountId: string;
|
|
259
283
|
userId: string;
|
|
260
284
|
accessToken?: string | null | undefined;
|
|
@@ -408,6 +432,1257 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
408
432
|
user: {
|
|
409
433
|
modelName: "pithyAuthUsers";
|
|
410
434
|
additionalFields: {
|
|
435
|
+
readonly suspendedAt: {
|
|
436
|
+
readonly type: "number";
|
|
437
|
+
readonly required: false;
|
|
438
|
+
readonly input: false;
|
|
439
|
+
};
|
|
440
|
+
readonly suspendedUntil: {
|
|
441
|
+
readonly type: "number";
|
|
442
|
+
readonly required: false;
|
|
443
|
+
readonly input: false;
|
|
444
|
+
};
|
|
445
|
+
readonly deletedAt: {
|
|
446
|
+
readonly type: "number";
|
|
447
|
+
readonly required: false;
|
|
448
|
+
readonly input: false;
|
|
449
|
+
};
|
|
450
|
+
readonly purgeAfter: {
|
|
451
|
+
readonly type: "number";
|
|
452
|
+
readonly required: false;
|
|
453
|
+
readonly input: false;
|
|
454
|
+
};
|
|
455
|
+
readonly locale: {
|
|
456
|
+
readonly type: "string";
|
|
457
|
+
readonly required: false;
|
|
458
|
+
readonly input: true;
|
|
459
|
+
readonly validator: {
|
|
460
|
+
readonly input: import("zod").ZodNullable<import("zod").ZodString>;
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
session: {
|
|
466
|
+
modelName: "pithyAuthSessions";
|
|
467
|
+
expiresIn: number;
|
|
468
|
+
updateAge: number;
|
|
469
|
+
/**
|
|
470
|
+
* Better Auth's own re-authentication window, stated rather than inherited.
|
|
471
|
+
*
|
|
472
|
+
* Its default is 24 hours, which nobody here chose, and it is the number `freshSessionMiddleware`
|
|
473
|
+
* holds `/unlink-account` to. Bringing it to the kit's own window means the two checks on that
|
|
474
|
+
* endpoint agree instead of one silently permitting a day.
|
|
475
|
+
*
|
|
476
|
+
* **It is defense in depth, not the control.** `freshSessionMiddleware` measures
|
|
477
|
+
* `session.createdAt`, which `/token/rotate` restamps — so narrowing it narrows a window that is
|
|
478
|
+
* still resettable. The control is `http/providerFreshness.ts`, which reads the authentication
|
|
479
|
+
* instant a rotation carries forward, and it is strictly the stricter of the two: `createdAt` is
|
|
480
|
+
* never older than `authenticatedAt`, so anything our gate admits this one admits too.
|
|
481
|
+
*/
|
|
482
|
+
freshAge: number;
|
|
483
|
+
additionalFields: {
|
|
484
|
+
readonly deviceId: {
|
|
485
|
+
readonly type: "string";
|
|
486
|
+
readonly required: false;
|
|
487
|
+
readonly input: false;
|
|
488
|
+
};
|
|
489
|
+
readonly familyId: {
|
|
490
|
+
readonly type: "string";
|
|
491
|
+
readonly required: false;
|
|
492
|
+
readonly input: false;
|
|
493
|
+
};
|
|
494
|
+
readonly authenticatedAt: {
|
|
495
|
+
readonly type: "date";
|
|
496
|
+
readonly required: false;
|
|
497
|
+
readonly input: false;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
account: {
|
|
502
|
+
modelName: "pithyAuthAccounts";
|
|
503
|
+
accountLinking: {
|
|
504
|
+
enabled: true;
|
|
505
|
+
trustedProviders: string[];
|
|
506
|
+
/**
|
|
507
|
+
* **A signed-in user may attach a provider whose email differs from their account's.**
|
|
508
|
+
*
|
|
509
|
+
* Both sides are proven at that moment: they authenticated as the account, and they just
|
|
510
|
+
* authenticated with the provider. Without this, a GitHub account whose primary is not the
|
|
511
|
+
* sign-up address can never be attached at all.
|
|
512
|
+
*
|
|
513
|
+
* **This flag alone would be the wrong fix and is not the whole of it.** It permits *any*
|
|
514
|
+
* differing address, including one the provider never verified — and Better Auth performs no
|
|
515
|
+
* independent check on what a resolver hands back. The verified boundary is held by
|
|
516
|
+
* `githubUserInfo.ts`, which reports the provider's real per-address flag and never a literal;
|
|
517
|
+
* and `http/linkFreshness.ts` is what stops a stolen credential using this to attach an
|
|
518
|
+
* identity permanently. Neither is optional, and #558 records why the obvious version of that
|
|
519
|
+
* second guard — session age — was defeated by a single `/token/rotate`.
|
|
520
|
+
*/
|
|
521
|
+
allowDifferentEmails: true;
|
|
522
|
+
/**
|
|
523
|
+
* **A provider is never the last way in, which is also what makes an orphaned link recoverable.**
|
|
524
|
+
*
|
|
525
|
+
* Better Auth refuses to unlink somebody's only account, on the reasonable fear of locking them
|
|
526
|
+
* out. That fear does not apply here: magic link is unconditional in this kit, so every user can
|
|
527
|
+
* always reach their own address, and the "last account" it is protecting is a provider link
|
|
528
|
+
* rather than a credential.
|
|
529
|
+
*
|
|
530
|
+
* It also settles #554's orphan without a merge rule. A GitHub sign-in that minted an empty user
|
|
531
|
+
* holds the provider identity, so linking it to the real account collides. With this, the owner
|
|
532
|
+
* of that empty account — who controls its address, or magic link could not have created it —
|
|
533
|
+
* signs in, unlinks GitHub, and links it where it belongs. At no point does one account take an
|
|
534
|
+
* identity from another; one gives it up, authenticated as itself. A claim-from-an-empty-account
|
|
535
|
+
* rule is where takeover bugs live, and this needs none.
|
|
536
|
+
*/
|
|
537
|
+
allowUnlinkingAll: true;
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
verification: {
|
|
541
|
+
modelName: "pithyAuthVerifications";
|
|
542
|
+
};
|
|
543
|
+
socialProviders?: Record<string, unknown>;
|
|
544
|
+
plugins: [BetterAuthPlugin, {
|
|
545
|
+
id: "bearer";
|
|
546
|
+
version: string;
|
|
547
|
+
hooks: {
|
|
548
|
+
before: {
|
|
549
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
550
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
551
|
+
context: {
|
|
552
|
+
headers: Headers;
|
|
553
|
+
};
|
|
554
|
+
} | undefined>>;
|
|
555
|
+
}[];
|
|
556
|
+
after: {
|
|
557
|
+
matcher(context: import("better-auth").HookEndpointContext): true;
|
|
558
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
559
|
+
}[];
|
|
560
|
+
};
|
|
561
|
+
options: import("better-auth/plugins/bearer").BearerOptions | undefined;
|
|
562
|
+
}, {
|
|
563
|
+
id: "jwt";
|
|
564
|
+
version: string;
|
|
565
|
+
options: NoInfer<import("better-auth/plugins/jwt").JwtOptions>;
|
|
566
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
567
|
+
context: {
|
|
568
|
+
sessionConfig: {
|
|
569
|
+
cookieCacheSigner: import("better-auth").CookieCacheSigner;
|
|
570
|
+
updateAge: number;
|
|
571
|
+
expiresIn: number;
|
|
572
|
+
freshAge: number;
|
|
573
|
+
cookieRefreshCache: false | {
|
|
574
|
+
enabled: true;
|
|
575
|
+
updateAge: number;
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
} | undefined;
|
|
580
|
+
endpoints: {
|
|
581
|
+
getJwks: import("better-auth").StrictEndpoint<string, {
|
|
582
|
+
method: "GET";
|
|
583
|
+
metadata: {
|
|
584
|
+
openapi: {
|
|
585
|
+
operationId: string;
|
|
586
|
+
description: string;
|
|
587
|
+
responses: {
|
|
588
|
+
"200": {
|
|
589
|
+
description: string;
|
|
590
|
+
content: {
|
|
591
|
+
"application/json": {
|
|
592
|
+
schema: {
|
|
593
|
+
type: "object";
|
|
594
|
+
properties: {
|
|
595
|
+
keys: {
|
|
596
|
+
type: string;
|
|
597
|
+
description: string;
|
|
598
|
+
items: {
|
|
599
|
+
type: string;
|
|
600
|
+
properties: {
|
|
601
|
+
kid: {
|
|
602
|
+
type: string;
|
|
603
|
+
description: string;
|
|
604
|
+
};
|
|
605
|
+
kty: {
|
|
606
|
+
type: string;
|
|
607
|
+
description: string;
|
|
608
|
+
};
|
|
609
|
+
alg: {
|
|
610
|
+
type: string;
|
|
611
|
+
description: string;
|
|
612
|
+
};
|
|
613
|
+
use: {
|
|
614
|
+
type: string;
|
|
615
|
+
description: string;
|
|
616
|
+
enum: string[];
|
|
617
|
+
nullable: boolean;
|
|
618
|
+
};
|
|
619
|
+
n: {
|
|
620
|
+
type: string;
|
|
621
|
+
description: string;
|
|
622
|
+
nullable: boolean;
|
|
623
|
+
};
|
|
624
|
+
e: {
|
|
625
|
+
type: string;
|
|
626
|
+
description: string;
|
|
627
|
+
nullable: boolean;
|
|
628
|
+
};
|
|
629
|
+
crv: {
|
|
630
|
+
type: string;
|
|
631
|
+
description: string;
|
|
632
|
+
nullable: boolean;
|
|
633
|
+
};
|
|
634
|
+
x: {
|
|
635
|
+
type: string;
|
|
636
|
+
description: string;
|
|
637
|
+
nullable: boolean;
|
|
638
|
+
};
|
|
639
|
+
y: {
|
|
640
|
+
type: string;
|
|
641
|
+
description: string;
|
|
642
|
+
nullable: boolean;
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
required: string[];
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
required: string[];
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
}, import("better-auth").JSONWebKeySet>;
|
|
658
|
+
getToken: import("better-auth").StrictEndpoint<"/token", {
|
|
659
|
+
method: "GET";
|
|
660
|
+
requireHeaders: true;
|
|
661
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
662
|
+
session: {
|
|
663
|
+
session: Record<string, any> & {
|
|
664
|
+
id: string;
|
|
665
|
+
createdAt: Date;
|
|
666
|
+
updatedAt: Date;
|
|
667
|
+
userId: string;
|
|
668
|
+
expiresAt: Date;
|
|
669
|
+
token: string;
|
|
670
|
+
ipAddress?: string | null | undefined;
|
|
671
|
+
userAgent?: string | null | undefined;
|
|
672
|
+
};
|
|
673
|
+
user: Record<string, any> & {
|
|
674
|
+
id: string;
|
|
675
|
+
createdAt: Date;
|
|
676
|
+
updatedAt: Date;
|
|
677
|
+
email: string;
|
|
678
|
+
emailVerified: boolean;
|
|
679
|
+
name: string;
|
|
680
|
+
image?: string | null | undefined;
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
}>>[];
|
|
684
|
+
metadata: {
|
|
685
|
+
openapi: {
|
|
686
|
+
operationId: string;
|
|
687
|
+
description: string;
|
|
688
|
+
responses: {
|
|
689
|
+
200: {
|
|
690
|
+
description: string;
|
|
691
|
+
content: {
|
|
692
|
+
"application/json": {
|
|
693
|
+
schema: {
|
|
694
|
+
type: "object";
|
|
695
|
+
properties: {
|
|
696
|
+
token: {
|
|
697
|
+
type: string;
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
};
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
};
|
|
705
|
+
};
|
|
706
|
+
};
|
|
707
|
+
}, {
|
|
708
|
+
token: string;
|
|
709
|
+
}>;
|
|
710
|
+
signJWT: import("better-auth").StrictEndpoint<string, {
|
|
711
|
+
method: "POST";
|
|
712
|
+
metadata: {
|
|
713
|
+
$Infer: {
|
|
714
|
+
body: {
|
|
715
|
+
payload: import("better-auth").JWTPayload;
|
|
716
|
+
overrideOptions?: import("better-auth/plugins/jwt").JwtOptions | undefined;
|
|
717
|
+
};
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
body: import("zod").ZodObject<{
|
|
721
|
+
payload: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>;
|
|
722
|
+
overrideOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
723
|
+
}, import("zod/v4/core").$strip>;
|
|
724
|
+
}, {
|
|
725
|
+
token: string;
|
|
726
|
+
}>;
|
|
727
|
+
verifyJWT: import("better-auth").StrictEndpoint<string, {
|
|
728
|
+
method: "POST";
|
|
729
|
+
metadata: {
|
|
730
|
+
$Infer: {
|
|
731
|
+
body: {
|
|
732
|
+
token: string;
|
|
733
|
+
issuer?: string;
|
|
734
|
+
};
|
|
735
|
+
response: {
|
|
736
|
+
payload: {
|
|
737
|
+
sub: string;
|
|
738
|
+
aud: string;
|
|
739
|
+
[key: string]: any;
|
|
740
|
+
} | null;
|
|
741
|
+
};
|
|
742
|
+
};
|
|
743
|
+
};
|
|
744
|
+
body: import("zod").ZodObject<{
|
|
745
|
+
token: import("zod").ZodString;
|
|
746
|
+
issuer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
747
|
+
}, import("zod/v4/core").$strip>;
|
|
748
|
+
}, {
|
|
749
|
+
payload: (import("better-auth").JWTPayload & Required<Pick<import("better-auth").JWTPayload, "sub" | "aud">>) | null;
|
|
750
|
+
}>;
|
|
751
|
+
};
|
|
752
|
+
hooks: {
|
|
753
|
+
after: {
|
|
754
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
755
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
756
|
+
}[];
|
|
757
|
+
};
|
|
758
|
+
schema: {
|
|
759
|
+
jwks: {
|
|
760
|
+
fields: {
|
|
761
|
+
publicKey: {
|
|
762
|
+
type: "string";
|
|
763
|
+
required: true;
|
|
764
|
+
};
|
|
765
|
+
privateKey: {
|
|
766
|
+
type: "string";
|
|
767
|
+
required: true;
|
|
768
|
+
};
|
|
769
|
+
createdAt: {
|
|
770
|
+
type: "date";
|
|
771
|
+
required: true;
|
|
772
|
+
};
|
|
773
|
+
expiresAt: {
|
|
774
|
+
type: "date";
|
|
775
|
+
required: false;
|
|
776
|
+
};
|
|
777
|
+
alg: {
|
|
778
|
+
type: "string";
|
|
779
|
+
required: false;
|
|
780
|
+
};
|
|
781
|
+
crv: {
|
|
782
|
+
type: "string";
|
|
783
|
+
required: false;
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
}, {
|
|
789
|
+
id: "magic-link";
|
|
790
|
+
version: string;
|
|
791
|
+
endpoints: {
|
|
792
|
+
signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
|
|
793
|
+
method: "POST";
|
|
794
|
+
requireHeaders: true;
|
|
795
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
796
|
+
body: import("zod").ZodObject<{
|
|
797
|
+
email: import("zod").ZodEmail;
|
|
798
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
799
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
800
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
801
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
802
|
+
metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
803
|
+
}, import("zod/v4/core").$strip>;
|
|
804
|
+
metadata: {
|
|
805
|
+
openapi: {
|
|
806
|
+
operationId: string;
|
|
807
|
+
description: string;
|
|
808
|
+
responses: {
|
|
809
|
+
200: {
|
|
810
|
+
description: string;
|
|
811
|
+
content: {
|
|
812
|
+
"application/json": {
|
|
813
|
+
schema: {
|
|
814
|
+
type: "object";
|
|
815
|
+
properties: {
|
|
816
|
+
status: {
|
|
817
|
+
type: string;
|
|
818
|
+
};
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
};
|
|
827
|
+
}, {
|
|
828
|
+
status: boolean;
|
|
829
|
+
}>;
|
|
830
|
+
magicLinkVerify: import("better-auth").StrictEndpoint<"/magic-link/verify", {
|
|
831
|
+
method: "GET";
|
|
832
|
+
query: import("zod").ZodObject<{
|
|
833
|
+
token: import("zod").ZodString;
|
|
834
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
835
|
+
errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
836
|
+
newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
837
|
+
}, import("zod/v4/core").$strip>;
|
|
838
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
839
|
+
requireHeaders: true;
|
|
840
|
+
metadata: {
|
|
841
|
+
openapi: {
|
|
842
|
+
operationId: string;
|
|
843
|
+
description: string;
|
|
844
|
+
responses: {
|
|
845
|
+
200: {
|
|
846
|
+
description: string;
|
|
847
|
+
content: {
|
|
848
|
+
"application/json": {
|
|
849
|
+
schema: {
|
|
850
|
+
type: "object";
|
|
851
|
+
properties: {
|
|
852
|
+
session: {
|
|
853
|
+
$ref: string;
|
|
854
|
+
};
|
|
855
|
+
user: {
|
|
856
|
+
$ref: string;
|
|
857
|
+
};
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
};
|
|
861
|
+
};
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
}, {
|
|
867
|
+
token: string;
|
|
868
|
+
user: {
|
|
869
|
+
id: string;
|
|
870
|
+
createdAt: Date;
|
|
871
|
+
updatedAt: Date;
|
|
872
|
+
email: string;
|
|
873
|
+
emailVerified: boolean;
|
|
874
|
+
name: string;
|
|
875
|
+
image?: string | null | undefined;
|
|
876
|
+
};
|
|
877
|
+
session: {
|
|
878
|
+
id: string;
|
|
879
|
+
createdAt: Date;
|
|
880
|
+
updatedAt: Date;
|
|
881
|
+
userId: string;
|
|
882
|
+
expiresAt: Date;
|
|
883
|
+
token: string;
|
|
884
|
+
ipAddress?: string | null | undefined;
|
|
885
|
+
userAgent?: string | null | undefined;
|
|
886
|
+
};
|
|
887
|
+
}>;
|
|
888
|
+
};
|
|
889
|
+
rateLimit: {
|
|
890
|
+
pathMatcher(path: string): boolean;
|
|
891
|
+
window: number;
|
|
892
|
+
max: number;
|
|
893
|
+
}[];
|
|
894
|
+
options: import("better-auth/plugins/magic-link").MagicLinkOptions;
|
|
895
|
+
}, {
|
|
896
|
+
id: "email-otp";
|
|
897
|
+
version: string;
|
|
898
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
899
|
+
options: {
|
|
900
|
+
emailVerification: {
|
|
901
|
+
sendVerificationEmail(data: {
|
|
902
|
+
user: import("better-auth").User;
|
|
903
|
+
url: string;
|
|
904
|
+
token: string;
|
|
905
|
+
}, request: Request | undefined): Promise<void>;
|
|
906
|
+
};
|
|
907
|
+
};
|
|
908
|
+
} | undefined;
|
|
909
|
+
endpoints: {
|
|
910
|
+
sendVerificationOTP: import("better-auth").StrictEndpoint<"/email-otp/send-verification-otp", {
|
|
911
|
+
method: "POST";
|
|
912
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
|
|
913
|
+
body: import("zod").ZodObject<{
|
|
914
|
+
email: import("zod").ZodString;
|
|
915
|
+
type: import("zod").ZodEnum<{
|
|
916
|
+
"sign-in": "sign-in";
|
|
917
|
+
"change-email": "change-email";
|
|
918
|
+
"email-verification": "email-verification";
|
|
919
|
+
"forget-password": "forget-password";
|
|
920
|
+
}>;
|
|
921
|
+
}, import("zod/v4/core").$strip>;
|
|
922
|
+
metadata: {
|
|
923
|
+
openapi: {
|
|
924
|
+
operationId: string;
|
|
925
|
+
description: string;
|
|
926
|
+
responses: {
|
|
927
|
+
200: {
|
|
928
|
+
description: string;
|
|
929
|
+
content: {
|
|
930
|
+
"application/json": {
|
|
931
|
+
schema: {
|
|
932
|
+
type: "object";
|
|
933
|
+
properties: {
|
|
934
|
+
success: {
|
|
935
|
+
type: string;
|
|
936
|
+
};
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
};
|
|
945
|
+
}, {
|
|
946
|
+
success: boolean;
|
|
947
|
+
}>;
|
|
948
|
+
createVerificationOTP: import("better-auth").StrictEndpoint<string, {
|
|
949
|
+
method: "POST";
|
|
950
|
+
body: import("zod").ZodObject<{
|
|
951
|
+
email: import("zod").ZodString;
|
|
952
|
+
type: import("zod").ZodEnum<{
|
|
953
|
+
"sign-in": "sign-in";
|
|
954
|
+
"change-email": "change-email";
|
|
955
|
+
"email-verification": "email-verification";
|
|
956
|
+
"forget-password": "forget-password";
|
|
957
|
+
}>;
|
|
958
|
+
}, import("zod/v4/core").$strip>;
|
|
959
|
+
metadata: {
|
|
960
|
+
openapi: {
|
|
961
|
+
operationId: string;
|
|
962
|
+
description: string;
|
|
963
|
+
responses: {
|
|
964
|
+
200: {
|
|
965
|
+
description: string;
|
|
966
|
+
content: {
|
|
967
|
+
"application/json": {
|
|
968
|
+
schema: {
|
|
969
|
+
type: "string";
|
|
970
|
+
};
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
}, string>;
|
|
978
|
+
getVerificationOTP: import("better-auth").StrictEndpoint<string, {
|
|
979
|
+
method: "GET";
|
|
980
|
+
query: import("zod").ZodObject<{
|
|
981
|
+
email: import("zod").ZodString;
|
|
982
|
+
type: import("zod").ZodEnum<{
|
|
983
|
+
"sign-in": "sign-in";
|
|
984
|
+
"change-email": "change-email";
|
|
985
|
+
"email-verification": "email-verification";
|
|
986
|
+
"forget-password": "forget-password";
|
|
987
|
+
}>;
|
|
988
|
+
}, import("zod/v4/core").$strip>;
|
|
989
|
+
metadata: {
|
|
990
|
+
openapi: {
|
|
991
|
+
operationId: string;
|
|
992
|
+
description: string;
|
|
993
|
+
responses: {
|
|
994
|
+
"200": {
|
|
995
|
+
description: string;
|
|
996
|
+
content: {
|
|
997
|
+
"application/json": {
|
|
998
|
+
schema: {
|
|
999
|
+
type: "object";
|
|
1000
|
+
properties: {
|
|
1001
|
+
otp: {
|
|
1002
|
+
type: string;
|
|
1003
|
+
nullable: boolean;
|
|
1004
|
+
description: string;
|
|
1005
|
+
};
|
|
1006
|
+
};
|
|
1007
|
+
required: string[];
|
|
1008
|
+
};
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
};
|
|
1015
|
+
}, {
|
|
1016
|
+
otp: null;
|
|
1017
|
+
} | {
|
|
1018
|
+
otp: string;
|
|
1019
|
+
}>;
|
|
1020
|
+
checkVerificationOTP: import("better-auth").StrictEndpoint<"/email-otp/check-verification-otp", {
|
|
1021
|
+
method: "POST";
|
|
1022
|
+
body: import("zod").ZodObject<{
|
|
1023
|
+
email: import("zod").ZodString;
|
|
1024
|
+
type: import("zod").ZodEnum<{
|
|
1025
|
+
"sign-in": "sign-in";
|
|
1026
|
+
"change-email": "change-email";
|
|
1027
|
+
"email-verification": "email-verification";
|
|
1028
|
+
"forget-password": "forget-password";
|
|
1029
|
+
}>;
|
|
1030
|
+
otp: import("zod").ZodString;
|
|
1031
|
+
}, import("zod/v4/core").$strip>;
|
|
1032
|
+
metadata: {
|
|
1033
|
+
openapi: {
|
|
1034
|
+
operationId: string;
|
|
1035
|
+
description: string;
|
|
1036
|
+
responses: {
|
|
1037
|
+
200: {
|
|
1038
|
+
description: string;
|
|
1039
|
+
content: {
|
|
1040
|
+
"application/json": {
|
|
1041
|
+
schema: {
|
|
1042
|
+
type: "object";
|
|
1043
|
+
properties: {
|
|
1044
|
+
success: {
|
|
1045
|
+
type: string;
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
}, {
|
|
1056
|
+
success: boolean;
|
|
1057
|
+
}>;
|
|
1058
|
+
verifyEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/verify-email", {
|
|
1059
|
+
method: "POST";
|
|
1060
|
+
body: import("zod").ZodObject<{
|
|
1061
|
+
email: import("zod").ZodString;
|
|
1062
|
+
otp: import("zod").ZodString;
|
|
1063
|
+
}, import("zod/v4/core").$strip>;
|
|
1064
|
+
metadata: {
|
|
1065
|
+
openapi: {
|
|
1066
|
+
description: string;
|
|
1067
|
+
responses: {
|
|
1068
|
+
200: {
|
|
1069
|
+
description: string;
|
|
1070
|
+
content: {
|
|
1071
|
+
"application/json": {
|
|
1072
|
+
schema: {
|
|
1073
|
+
type: "object";
|
|
1074
|
+
properties: {
|
|
1075
|
+
status: {
|
|
1076
|
+
type: string;
|
|
1077
|
+
description: string;
|
|
1078
|
+
enum: boolean[];
|
|
1079
|
+
};
|
|
1080
|
+
token: {
|
|
1081
|
+
type: string;
|
|
1082
|
+
nullable: boolean;
|
|
1083
|
+
description: string;
|
|
1084
|
+
};
|
|
1085
|
+
user: {
|
|
1086
|
+
$ref: string;
|
|
1087
|
+
};
|
|
1088
|
+
};
|
|
1089
|
+
required: string[];
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
};
|
|
1093
|
+
};
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
|
+
};
|
|
1097
|
+
}, {
|
|
1098
|
+
status: boolean;
|
|
1099
|
+
token: string;
|
|
1100
|
+
user: {
|
|
1101
|
+
id: string;
|
|
1102
|
+
createdAt: Date;
|
|
1103
|
+
updatedAt: Date;
|
|
1104
|
+
email: string;
|
|
1105
|
+
emailVerified: boolean;
|
|
1106
|
+
name: string;
|
|
1107
|
+
image?: string | null | undefined;
|
|
1108
|
+
} & Record<string, any>;
|
|
1109
|
+
} | {
|
|
1110
|
+
status: boolean;
|
|
1111
|
+
token: null;
|
|
1112
|
+
user: {
|
|
1113
|
+
id: string;
|
|
1114
|
+
createdAt: Date;
|
|
1115
|
+
updatedAt: Date;
|
|
1116
|
+
email: string;
|
|
1117
|
+
emailVerified: boolean;
|
|
1118
|
+
name: string;
|
|
1119
|
+
image?: string | null | undefined;
|
|
1120
|
+
} & Record<string, any>;
|
|
1121
|
+
}>;
|
|
1122
|
+
signInEmailOTP: import("better-auth").StrictEndpoint<"/sign-in/email-otp", {
|
|
1123
|
+
method: "POST";
|
|
1124
|
+
body: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
1125
|
+
email: import("zod").ZodString;
|
|
1126
|
+
otp: import("zod").ZodString;
|
|
1127
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1128
|
+
image: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1129
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
1130
|
+
metadata: {
|
|
1131
|
+
openapi: {
|
|
1132
|
+
operationId: string;
|
|
1133
|
+
description: string;
|
|
1134
|
+
responses: {
|
|
1135
|
+
200: {
|
|
1136
|
+
description: string;
|
|
1137
|
+
content: {
|
|
1138
|
+
"application/json": {
|
|
1139
|
+
schema: {
|
|
1140
|
+
type: "object";
|
|
1141
|
+
properties: {
|
|
1142
|
+
token: {
|
|
1143
|
+
type: string;
|
|
1144
|
+
description: string;
|
|
1145
|
+
};
|
|
1146
|
+
user: {
|
|
1147
|
+
$ref: string;
|
|
1148
|
+
};
|
|
1149
|
+
};
|
|
1150
|
+
required: string[];
|
|
1151
|
+
};
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
};
|
|
1156
|
+
};
|
|
1157
|
+
};
|
|
1158
|
+
}, {
|
|
1159
|
+
token: string;
|
|
1160
|
+
user: {
|
|
1161
|
+
id: string;
|
|
1162
|
+
createdAt: Date;
|
|
1163
|
+
updatedAt: Date;
|
|
1164
|
+
email: string;
|
|
1165
|
+
emailVerified: boolean;
|
|
1166
|
+
name: string;
|
|
1167
|
+
image?: string | null | undefined;
|
|
1168
|
+
};
|
|
1169
|
+
}>;
|
|
1170
|
+
requestPasswordResetEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/request-password-reset", {
|
|
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
|
+
forgetPasswordEmailOTP: import("better-auth").StrictEndpoint<"/forget-password/email-otp", {
|
|
1203
|
+
method: "POST";
|
|
1204
|
+
body: import("zod").ZodObject<{
|
|
1205
|
+
email: import("zod").ZodString;
|
|
1206
|
+
}, import("zod/v4/core").$strip>;
|
|
1207
|
+
metadata: {
|
|
1208
|
+
openapi: {
|
|
1209
|
+
operationId: string;
|
|
1210
|
+
description: string;
|
|
1211
|
+
responses: {
|
|
1212
|
+
200: {
|
|
1213
|
+
description: string;
|
|
1214
|
+
content: {
|
|
1215
|
+
"application/json": {
|
|
1216
|
+
schema: {
|
|
1217
|
+
type: "object";
|
|
1218
|
+
properties: {
|
|
1219
|
+
success: {
|
|
1220
|
+
type: string;
|
|
1221
|
+
description: string;
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
};
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
};
|
|
1229
|
+
};
|
|
1230
|
+
};
|
|
1231
|
+
}, {
|
|
1232
|
+
success: boolean;
|
|
1233
|
+
}>;
|
|
1234
|
+
resetPasswordEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/reset-password", {
|
|
1235
|
+
method: "POST";
|
|
1236
|
+
body: import("zod").ZodObject<{
|
|
1237
|
+
email: import("zod").ZodString;
|
|
1238
|
+
otp: import("zod").ZodString;
|
|
1239
|
+
password: import("zod").ZodString;
|
|
1240
|
+
}, import("zod/v4/core").$strip>;
|
|
1241
|
+
metadata: {
|
|
1242
|
+
openapi: {
|
|
1243
|
+
operationId: string;
|
|
1244
|
+
description: string;
|
|
1245
|
+
responses: {
|
|
1246
|
+
200: {
|
|
1247
|
+
description: string;
|
|
1248
|
+
content: {
|
|
1249
|
+
"application/json": {
|
|
1250
|
+
schema: {
|
|
1251
|
+
type: "object";
|
|
1252
|
+
properties: {
|
|
1253
|
+
success: {
|
|
1254
|
+
type: string;
|
|
1255
|
+
};
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
};
|
|
1259
|
+
};
|
|
1260
|
+
};
|
|
1261
|
+
};
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
}, {
|
|
1265
|
+
success: boolean;
|
|
1266
|
+
}>;
|
|
1267
|
+
requestEmailChangeEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/request-email-change", {
|
|
1268
|
+
method: "POST";
|
|
1269
|
+
body: import("zod").ZodObject<{
|
|
1270
|
+
newEmail: import("zod").ZodString;
|
|
1271
|
+
otp: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1272
|
+
}, import("zod/v4/core").$strip>;
|
|
1273
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
1274
|
+
session: {
|
|
1275
|
+
session: Record<string, any> & {
|
|
1276
|
+
id: string;
|
|
1277
|
+
createdAt: Date;
|
|
1278
|
+
updatedAt: Date;
|
|
1279
|
+
userId: string;
|
|
1280
|
+
expiresAt: Date;
|
|
1281
|
+
token: string;
|
|
1282
|
+
ipAddress?: string | null | undefined;
|
|
1283
|
+
userAgent?: string | null | undefined;
|
|
1284
|
+
};
|
|
1285
|
+
user: Record<string, any> & {
|
|
1286
|
+
id: string;
|
|
1287
|
+
createdAt: Date;
|
|
1288
|
+
updatedAt: Date;
|
|
1289
|
+
email: string;
|
|
1290
|
+
emailVerified: boolean;
|
|
1291
|
+
name: string;
|
|
1292
|
+
image?: string | null | undefined;
|
|
1293
|
+
};
|
|
1294
|
+
};
|
|
1295
|
+
}>>[];
|
|
1296
|
+
metadata: {
|
|
1297
|
+
openapi: {
|
|
1298
|
+
operationId: string;
|
|
1299
|
+
description: string;
|
|
1300
|
+
responses: {
|
|
1301
|
+
200: {
|
|
1302
|
+
description: string;
|
|
1303
|
+
content: {
|
|
1304
|
+
"application/json": {
|
|
1305
|
+
schema: {
|
|
1306
|
+
type: "object";
|
|
1307
|
+
properties: {
|
|
1308
|
+
success: {
|
|
1309
|
+
type: string;
|
|
1310
|
+
};
|
|
1311
|
+
};
|
|
1312
|
+
};
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
};
|
|
1316
|
+
};
|
|
1317
|
+
};
|
|
1318
|
+
};
|
|
1319
|
+
}, {
|
|
1320
|
+
success: boolean;
|
|
1321
|
+
}>;
|
|
1322
|
+
changeEmailEmailOTP: import("better-auth").StrictEndpoint<"/email-otp/change-email", {
|
|
1323
|
+
method: "POST";
|
|
1324
|
+
body: import("zod").ZodObject<{
|
|
1325
|
+
newEmail: import("zod").ZodString;
|
|
1326
|
+
otp: import("zod").ZodString;
|
|
1327
|
+
}, import("zod/v4/core").$strip>;
|
|
1328
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
1329
|
+
session: {
|
|
1330
|
+
session: Record<string, any> & {
|
|
1331
|
+
id: string;
|
|
1332
|
+
createdAt: Date;
|
|
1333
|
+
updatedAt: Date;
|
|
1334
|
+
userId: string;
|
|
1335
|
+
expiresAt: Date;
|
|
1336
|
+
token: string;
|
|
1337
|
+
ipAddress?: string | null | undefined;
|
|
1338
|
+
userAgent?: string | null | undefined;
|
|
1339
|
+
};
|
|
1340
|
+
user: Record<string, any> & {
|
|
1341
|
+
id: string;
|
|
1342
|
+
createdAt: Date;
|
|
1343
|
+
updatedAt: Date;
|
|
1344
|
+
email: string;
|
|
1345
|
+
emailVerified: boolean;
|
|
1346
|
+
name: string;
|
|
1347
|
+
image?: string | null | undefined;
|
|
1348
|
+
};
|
|
1349
|
+
};
|
|
1350
|
+
}>>[];
|
|
1351
|
+
metadata: {
|
|
1352
|
+
openapi: {
|
|
1353
|
+
operationId: string;
|
|
1354
|
+
description: string;
|
|
1355
|
+
responses: {
|
|
1356
|
+
200: {
|
|
1357
|
+
description: string;
|
|
1358
|
+
content: {
|
|
1359
|
+
"application/json": {
|
|
1360
|
+
schema: {
|
|
1361
|
+
type: "object";
|
|
1362
|
+
properties: {
|
|
1363
|
+
success: {
|
|
1364
|
+
type: string;
|
|
1365
|
+
};
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
};
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
};
|
|
1372
|
+
};
|
|
1373
|
+
};
|
|
1374
|
+
}, {
|
|
1375
|
+
success: boolean;
|
|
1376
|
+
}>;
|
|
1377
|
+
};
|
|
1378
|
+
hooks: {
|
|
1379
|
+
after: {
|
|
1380
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
1381
|
+
handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
1382
|
+
}[];
|
|
1383
|
+
};
|
|
1384
|
+
rateLimit: ({
|
|
1385
|
+
pathMatcher(path: string): path is "/email-otp/send-verification-otp";
|
|
1386
|
+
window: number;
|
|
1387
|
+
max: number;
|
|
1388
|
+
} | {
|
|
1389
|
+
pathMatcher(path: string): path is "/email-otp/check-verification-otp";
|
|
1390
|
+
window: number;
|
|
1391
|
+
max: number;
|
|
1392
|
+
} | {
|
|
1393
|
+
pathMatcher(path: string): path is "/email-otp/verify-email";
|
|
1394
|
+
window: number;
|
|
1395
|
+
max: number;
|
|
1396
|
+
} | {
|
|
1397
|
+
pathMatcher(path: string): path is "/sign-in/email-otp";
|
|
1398
|
+
window: number;
|
|
1399
|
+
max: number;
|
|
1400
|
+
} | {
|
|
1401
|
+
pathMatcher(path: string): path is "/email-otp/request-password-reset";
|
|
1402
|
+
window: number;
|
|
1403
|
+
max: number;
|
|
1404
|
+
} | {
|
|
1405
|
+
pathMatcher(path: string): path is "/email-otp/reset-password";
|
|
1406
|
+
window: number;
|
|
1407
|
+
max: number;
|
|
1408
|
+
} | {
|
|
1409
|
+
pathMatcher(path: string): path is "/forget-password/email-otp";
|
|
1410
|
+
window: number;
|
|
1411
|
+
max: number;
|
|
1412
|
+
} | {
|
|
1413
|
+
pathMatcher(path: string): path is "/email-otp/request-email-change";
|
|
1414
|
+
window: number;
|
|
1415
|
+
max: number;
|
|
1416
|
+
} | {
|
|
1417
|
+
pathMatcher(path: string): path is "/email-otp/change-email";
|
|
1418
|
+
window: number;
|
|
1419
|
+
max: number;
|
|
1420
|
+
})[];
|
|
1421
|
+
options: import("better-auth/plugins/email-otp").EmailOTPOptions;
|
|
1422
|
+
$ERROR_CODES: {
|
|
1423
|
+
OTP_EXPIRED: import("better-auth").RawError<"OTP_EXPIRED">;
|
|
1424
|
+
INVALID_OTP: import("better-auth").RawError<"INVALID_OTP">;
|
|
1425
|
+
TOO_MANY_ATTEMPTS: import("better-auth").RawError<"TOO_MANY_ATTEMPTS">;
|
|
1426
|
+
};
|
|
1427
|
+
}, BetterAuthPlugin, ...Plugins];
|
|
1428
|
+
} | {
|
|
1429
|
+
appName: string;
|
|
1430
|
+
baseURL: string;
|
|
1431
|
+
basePath: string;
|
|
1432
|
+
secret: string;
|
|
1433
|
+
telemetry: {
|
|
1434
|
+
enabled: false;
|
|
1435
|
+
};
|
|
1436
|
+
trustedOrigins: string[];
|
|
1437
|
+
database: {
|
|
1438
|
+
db: AuthDatabase;
|
|
1439
|
+
type: string;
|
|
1440
|
+
transaction: boolean;
|
|
1441
|
+
};
|
|
1442
|
+
advanced: {
|
|
1443
|
+
database: {
|
|
1444
|
+
generateId: () => string;
|
|
1445
|
+
validateSchema: false;
|
|
1446
|
+
};
|
|
1447
|
+
};
|
|
1448
|
+
onAPIError: {
|
|
1449
|
+
throw: true;
|
|
1450
|
+
};
|
|
1451
|
+
databaseHooks: {
|
|
1452
|
+
user: {
|
|
1453
|
+
create: {
|
|
1454
|
+
before: (user: {
|
|
1455
|
+
id: string;
|
|
1456
|
+
createdAt: Date;
|
|
1457
|
+
updatedAt: Date;
|
|
1458
|
+
email: string;
|
|
1459
|
+
emailVerified: boolean;
|
|
1460
|
+
name: string;
|
|
1461
|
+
image?: string | null | undefined;
|
|
1462
|
+
} & Record<string, unknown>) => Promise<{
|
|
1463
|
+
data: {
|
|
1464
|
+
id: string;
|
|
1465
|
+
createdAt: Date;
|
|
1466
|
+
updatedAt: Date;
|
|
1467
|
+
email: string;
|
|
1468
|
+
emailVerified: boolean;
|
|
1469
|
+
name: string;
|
|
1470
|
+
image?: string | null | undefined;
|
|
1471
|
+
};
|
|
1472
|
+
} | undefined>;
|
|
1473
|
+
};
|
|
1474
|
+
update: {
|
|
1475
|
+
before: (user: Partial<{
|
|
1476
|
+
id: string;
|
|
1477
|
+
createdAt: Date;
|
|
1478
|
+
updatedAt: Date;
|
|
1479
|
+
email: string;
|
|
1480
|
+
emailVerified: boolean;
|
|
1481
|
+
name: string;
|
|
1482
|
+
image?: string | null | undefined;
|
|
1483
|
+
}> & Record<string, unknown>) => Promise<void>;
|
|
1484
|
+
};
|
|
1485
|
+
};
|
|
1486
|
+
account: {
|
|
1487
|
+
/**
|
|
1488
|
+
* **The provider-link trail, recorded where the account table changes.**
|
|
1489
|
+
*
|
|
1490
|
+
* An account row is what lets a provider sign in as somebody, so its creation and its removal
|
|
1491
|
+
* are the two account-security events — and the row is the only place both are visible. Better
|
|
1492
|
+
* Auth reaches it from several directions: `/callback/:id` on a first social sign-up and on a
|
|
1493
|
+
* link, `linkAccount` from the OAuth linking path, `/unlink-account`, and the cascade that drops
|
|
1494
|
+
* every account when a user is deleted. All of them go through `createWithHooks` /
|
|
1495
|
+
* `deleteWithHooks` on the `account` model (`better-auth/dist/db/internal-adapter.mjs`), so one
|
|
1496
|
+
* pair of hooks covers what four endpoint wirings would have had to enumerate and keep current.
|
|
1497
|
+
*
|
|
1498
|
+
* **This is the seam `session.delete.after` below already argues for**, applied to the other
|
|
1499
|
+
* table: a handler wired to one endpoint misses the others, and the row is what the fact is
|
|
1500
|
+
* keyed by. #627 is what that costs — `/link-social` was wired, so a link recorded the request
|
|
1501
|
+
* rather than the result, and an unlink recorded nothing.
|
|
1502
|
+
*
|
|
1503
|
+
* **After, not before, in both directions.** The write has happened by the time these run, so a
|
|
1504
|
+
* slow or failing audit seam can neither hold up nor refuse a link or an unlink — and
|
|
1505
|
+
* `emitProviderAccountChanged` swallows its own failure for the same reason.
|
|
1506
|
+
*/
|
|
1507
|
+
create: {
|
|
1508
|
+
after: (account: {
|
|
1509
|
+
id: string;
|
|
1510
|
+
createdAt: Date;
|
|
1511
|
+
updatedAt: Date;
|
|
1512
|
+
providerId: string;
|
|
1513
|
+
accountId: string;
|
|
1514
|
+
userId: string;
|
|
1515
|
+
accessToken?: string | null | undefined;
|
|
1516
|
+
refreshToken?: string | null | undefined;
|
|
1517
|
+
idToken?: string | null | undefined;
|
|
1518
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
1519
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
1520
|
+
scope?: string | null | undefined;
|
|
1521
|
+
password?: string | null | undefined;
|
|
1522
|
+
}, ctx: import("better-auth").GenericEndpointContext | null) => Promise<void>;
|
|
1523
|
+
};
|
|
1524
|
+
/**
|
|
1525
|
+
* **Through `claimedDelete`, because `delete.after` fires on the row that was read.** Two
|
|
1526
|
+
* concurrent unlinks of one account both reach `after` and the trail double-counts one removal.
|
|
1527
|
+
* The pair below issues the delete in `before` and runs this body only for the caller whose
|
|
1528
|
+
* statement removed the row — see `../audit/evidence.ts` for the primitive, its two
|
|
1529
|
+
* preconditions, and why every `delete.after` here goes through it rather than two of them.
|
|
1530
|
+
*/
|
|
1531
|
+
delete: import("../audit/evidence").ClaimedDelete<{
|
|
1532
|
+
id: unknown;
|
|
1533
|
+
}, HookContext | null | undefined>;
|
|
1534
|
+
};
|
|
1535
|
+
session: {
|
|
1536
|
+
create: {
|
|
1537
|
+
/**
|
|
1538
|
+
* Stamp when this session's holder authenticated, and bind the session to its device.
|
|
1539
|
+
*
|
|
1540
|
+
* **`authenticatedAt` is stamped here and nowhere else.** A sign-in is the only event that is
|
|
1541
|
+
* an authentication; `/token/rotate` carries the value forward through `createSession`'s
|
|
1542
|
+
* override instead, which is why a rotated session keeps the original instant. A field
|
|
1543
|
+
* `defaultValue` would have looked equivalent and is not: `getSessionDefaultFields` is spread
|
|
1544
|
+
* into the row *after* the caller's override, so it would overwrite the carried value and
|
|
1545
|
+
* silently restore the defect the column exists to fix (#558).
|
|
1546
|
+
*
|
|
1547
|
+
* A value already on the row is left alone — that is the rotation, passing its own.
|
|
1548
|
+
*
|
|
1549
|
+
* **Every other `createSession` is treated as an authentication, which is right for all of
|
|
1550
|
+
* them the kit composes.** `better-auth/plugins/admin`'s `impersonateUser` would be the
|
|
1551
|
+
* exception — an admin impersonating somebody would get a freshly-stamped session and could
|
|
1552
|
+
* attach a provider to that account — but the kit composes no admin plugin, so it is a note
|
|
1553
|
+
* for whoever does rather than a live path.
|
|
1554
|
+
*
|
|
1555
|
+
* Device binding only fires when the request carried device headers; a rotation passes
|
|
1556
|
+
* `deviceId` by override for the same reason.
|
|
1557
|
+
*/
|
|
1558
|
+
before: (session: {
|
|
1559
|
+
id: string;
|
|
1560
|
+
createdAt: Date;
|
|
1561
|
+
updatedAt: Date;
|
|
1562
|
+
userId: string;
|
|
1563
|
+
expiresAt: Date;
|
|
1564
|
+
token: string;
|
|
1565
|
+
ipAddress?: string | null | undefined;
|
|
1566
|
+
userAgent?: string | null | undefined;
|
|
1567
|
+
} & Record<string, unknown>, ctx: import("better-auth").GenericEndpointContext | null) => Promise<{
|
|
1568
|
+
data: {
|
|
1569
|
+
id: string;
|
|
1570
|
+
createdAt: Date;
|
|
1571
|
+
updatedAt: Date;
|
|
1572
|
+
userId: string;
|
|
1573
|
+
expiresAt: Date;
|
|
1574
|
+
token: string;
|
|
1575
|
+
ipAddress?: string | null | undefined;
|
|
1576
|
+
userAgent?: string | null | undefined;
|
|
1577
|
+
authenticatedAt: Date | null;
|
|
1578
|
+
};
|
|
1579
|
+
} | {
|
|
1580
|
+
data: {
|
|
1581
|
+
id: string;
|
|
1582
|
+
createdAt: Date;
|
|
1583
|
+
updatedAt: Date;
|
|
1584
|
+
userId: string;
|
|
1585
|
+
expiresAt: Date;
|
|
1586
|
+
token: string;
|
|
1587
|
+
ipAddress?: string | null | undefined;
|
|
1588
|
+
userAgent?: string | null | undefined;
|
|
1589
|
+
deviceId: string;
|
|
1590
|
+
authenticatedAt: Date | null;
|
|
1591
|
+
};
|
|
1592
|
+
}>;
|
|
1593
|
+
};
|
|
1594
|
+
/**
|
|
1595
|
+
* Tell whoever keyed state on this session that it has gone, and record that it did.
|
|
1596
|
+
*
|
|
1597
|
+
* A sign-out, a revoke, an admin ending somebody's devices — all of them land here, which is
|
|
1598
|
+
* why the seam is on the row rather than on the sign-out endpoint. A handler wired to one
|
|
1599
|
+
* endpoint would miss the other three, and the row is what the state was keyed by.
|
|
1600
|
+
*
|
|
1601
|
+
* **After, not before.** The session is already gone when this runs, so a slow or failing
|
|
1602
|
+
* listener cannot hold up or refuse a sign-out — and it swallows its own failure for the same
|
|
1603
|
+
* reason the audit emit does: the thing it reports has already happened.
|
|
1604
|
+
*
|
|
1605
|
+
* **Through `claimedDelete`, and that is the second half of #627's last hole.** `/sign-out`
|
|
1606
|
+
* reaches `internalAdapter.deleteSession(token)`, so concurrent sign-outs on one cookie all find
|
|
1607
|
+
* the row, all issue a delete, exactly one removes anything — and all of them reached this body.
|
|
1608
|
+
* `markSessionEnded` ran for each, and `emitAfterRequest` wrote `auth/signout outcome=success`
|
|
1609
|
+
* for callers that signed nobody out. The same primitive the account hooks use covers it,
|
|
1610
|
+
* because the defect is `deleteWithHooks`'s rather than either table's.
|
|
1611
|
+
*/
|
|
1612
|
+
delete: import("../audit/evidence").ClaimedDelete<{
|
|
1613
|
+
id: unknown;
|
|
1614
|
+
userId: unknown;
|
|
1615
|
+
}, HookContext | null | undefined>;
|
|
1616
|
+
};
|
|
1617
|
+
};
|
|
1618
|
+
hooks: {
|
|
1619
|
+
/**
|
|
1620
|
+
* Refuse a provider this deployment enables and could not resolve, before Better Auth answers it
|
|
1621
|
+
* with the 404 it gives a provider nobody configured (#381).
|
|
1622
|
+
*
|
|
1623
|
+
* **This is what makes degrading not the same as degrading quietly.** The instance was built
|
|
1624
|
+
* without the provider, so `socialProviders` does not hold it, so `sign-in/social` would throw
|
|
1625
|
+
* `PROVIDER_NOT_FOUND` — a 404 that tells somebody who signs in with GitHub every day that
|
|
1626
|
+
* GitHub was never set up. It is the same answer for a fault and for a choice, and the two are
|
|
1627
|
+
* not the same fact. This hook answers 503 with its own code instead, and records the attempt.
|
|
1628
|
+
*
|
|
1629
|
+
* **A `before` hook rather than a Hono route, and that is forced rather than preferred.** The
|
|
1630
|
+
* provider is in the request *body*, and the body is Better Auth's to read: a Hono handler ahead
|
|
1631
|
+
* of the catch-all would have to consume the stream that the catch-all then hands to
|
|
1632
|
+
* `instance.handler(c.req.raw)`. Here the body is already parsed against the endpoint's own
|
|
1633
|
+
* schema, and this reads one field out of it.
|
|
1634
|
+
*/
|
|
1635
|
+
before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
1636
|
+
/**
|
|
1637
|
+
* Emit audit events for an auth request: sign-in (+device) from the new session, plus the
|
|
1638
|
+
* send/sign-out/token event by path. Endpoint-scoped, so a rotation never emits.
|
|
1639
|
+
*
|
|
1640
|
+
* **`returned` is passed because this hook runs on refusals too.** Better Auth catches an
|
|
1641
|
+
* endpoint's `APIError` into a result and dispatches the `after` hooks over it
|
|
1642
|
+
* (`better-auth/dist/api/dispatch.mjs`), so a 401 `/token` reaches here looking exactly like one
|
|
1643
|
+
* that minted a token — and wrote `auth/token_refresh outcome=success` for a request that was
|
|
1644
|
+
* refused. `ctx.context.returned` is the only thing that tells them apart, and the judgment is
|
|
1645
|
+
* `emitAfterRequest`'s so it is made once for every path rather than per wiring.
|
|
1646
|
+
*
|
|
1647
|
+
* **The two markers are passed because a refusal can answer 200.** `/sign-out` deletes nothing and
|
|
1648
|
+
* says so cheerfully; `/email-otp/send-verification-otp` declines to send and answers
|
|
1649
|
+
* `{"success":true}` on purpose, so a caller cannot tell a registered address from a stranger's.
|
|
1650
|
+
* Neither decline is visible from anything this hook holds, so each audited path names what must
|
|
1651
|
+
* have *happened* and `../audit/evidence.ts` carries it here from the place that saw it — the
|
|
1652
|
+
* session row going away, and the email seam's own answer about the message, which is the send
|
|
1653
|
+
* paths' evidence rather than the fact that a callback was entered. Reading them is all this does:
|
|
1654
|
+
* the response has already been decided and is not touched.
|
|
1655
|
+
*/
|
|
1656
|
+
after: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>;
|
|
1657
|
+
};
|
|
1658
|
+
rateLimit: {
|
|
1659
|
+
enabled: true;
|
|
1660
|
+
storage: "database";
|
|
1661
|
+
modelName: "pithyAuthRateLimit";
|
|
1662
|
+
};
|
|
1663
|
+
user: {
|
|
1664
|
+
modelName: "pithyAuthUsers";
|
|
1665
|
+
additionalFields: {
|
|
1666
|
+
readonly suspendedAt: {
|
|
1667
|
+
readonly type: "number";
|
|
1668
|
+
readonly required: false;
|
|
1669
|
+
readonly input: false;
|
|
1670
|
+
};
|
|
1671
|
+
readonly suspendedUntil: {
|
|
1672
|
+
readonly type: "number";
|
|
1673
|
+
readonly required: false;
|
|
1674
|
+
readonly input: false;
|
|
1675
|
+
};
|
|
1676
|
+
readonly deletedAt: {
|
|
1677
|
+
readonly type: "number";
|
|
1678
|
+
readonly required: false;
|
|
1679
|
+
readonly input: false;
|
|
1680
|
+
};
|
|
1681
|
+
readonly purgeAfter: {
|
|
1682
|
+
readonly type: "number";
|
|
1683
|
+
readonly required: false;
|
|
1684
|
+
readonly input: false;
|
|
1685
|
+
};
|
|
411
1686
|
readonly locale: {
|
|
412
1687
|
readonly type: "string";
|
|
413
1688
|
readonly required: false;
|
|
@@ -458,7 +1733,7 @@ export declare function makeAuth<const Plugins extends readonly BetterAuthPlugin
|
|
|
458
1733
|
modelName: "pithyAuthAccounts";
|
|
459
1734
|
accountLinking: {
|
|
460
1735
|
enabled: true;
|
|
461
|
-
trustedProviders:
|
|
1736
|
+
trustedProviders: string[];
|
|
462
1737
|
/**
|
|
463
1738
|
* **A signed-in user may attach a provider whose email differs from their account's.**
|
|
464
1739
|
*
|