better-auth 0.0.2-beta.7 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/access.d.ts +4 -0
  2. package/dist/access.js +126 -0
  3. package/dist/access.js.map +1 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +553 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/client/plugins.d.ts +2436 -0
  8. package/dist/client/plugins.js +411 -0
  9. package/dist/client/plugins.js.map +1 -0
  10. package/dist/client-A2Mt04KQ.d.ts +3503 -0
  11. package/dist/client.d.ts +1433 -0
  12. package/dist/client.js +693 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/helper-B5_2Vzba.d.ts +14 -0
  15. package/dist/index-Dg4eEXZW.d.ts +24 -0
  16. package/dist/index-W5nXvJ-p.d.ts +1498 -0
  17. package/dist/index.d.ts +6 -4
  18. package/dist/index.js +2195 -1191
  19. package/dist/index.js.map +1 -1
  20. package/dist/next-js.d.ts +14 -0
  21. package/dist/next-js.js +14 -0
  22. package/dist/next-js.js.map +1 -0
  23. package/dist/plugins.d.ts +892 -49
  24. package/dist/plugins.js +3951 -253
  25. package/dist/plugins.js.map +1 -1
  26. package/dist/preact.d.ts +8 -0
  27. package/dist/preact.js +294 -0
  28. package/dist/preact.js.map +1 -0
  29. package/dist/react.d.ts +14 -0
  30. package/dist/react.js +314 -0
  31. package/dist/react.js.map +1 -0
  32. package/dist/schema-BOszzrbQ.d.ts +792 -0
  33. package/dist/social.d.ts +4 -0
  34. package/dist/social.js +509 -0
  35. package/dist/social.js.map +1 -0
  36. package/dist/solid-start.d.ts +18 -0
  37. package/dist/solid-start.js +14 -0
  38. package/dist/solid-start.js.map +1 -0
  39. package/dist/solid.d.ts +2790 -0
  40. package/dist/solid.js +306 -0
  41. package/dist/solid.js.map +1 -0
  42. package/dist/statement-COylZd3J.d.ts +81 -0
  43. package/dist/svelte-kit.d.ts +10 -7
  44. package/dist/svelte-kit.js +12 -17
  45. package/dist/svelte-kit.js.map +1 -1
  46. package/dist/svelte.d.ts +2791 -0
  47. package/dist/svelte.js +304 -0
  48. package/dist/svelte.js.map +1 -0
  49. package/dist/type-DbMyI3b5.d.ts +5724 -0
  50. package/dist/types.d.ts +7 -0
  51. package/dist/types.js +1 -0
  52. package/dist/types.js.map +1 -0
  53. package/dist/vue.d.ts +14 -0
  54. package/dist/vue.js +311 -0
  55. package/dist/vue.js.map +1 -0
  56. package/package.json +80 -54
  57. package/LICENSE +0 -21
  58. package/dist/actions.d.ts +0 -33
  59. package/dist/actions.js +0 -1373
  60. package/dist/actions.js.map +0 -1
  61. package/dist/adapters/drizzle-adapter.d.ts +0 -10
  62. package/dist/adapters/drizzle-adapter.js +0 -1095
  63. package/dist/adapters/drizzle-adapter.js.map +0 -1
  64. package/dist/adapters/memory.d.ts +0 -8
  65. package/dist/adapters/memory.js +0 -136
  66. package/dist/adapters/memory.js.map +0 -1
  67. package/dist/adapters/mongodb-adapter.d.ts +0 -9
  68. package/dist/adapters/mongodb-adapter.js +0 -97
  69. package/dist/adapters/mongodb-adapter.js.map +0 -1
  70. package/dist/adapters/prisma-adapter.d.ts +0 -7
  71. package/dist/adapters/prisma-adapter.js +0 -144
  72. package/dist/adapters/prisma-adapter.js.map +0 -1
  73. package/dist/adapters/redis-adapter.d.ts +0 -7
  74. package/dist/adapters/redis-adapter.js +0 -65
  75. package/dist/adapters/redis-adapter.js.map +0 -1
  76. package/dist/adapters.d.ts +0 -3
  77. package/dist/adapters.js +0 -206
  78. package/dist/adapters.js.map +0 -1
  79. package/dist/h3.d.ts +0 -10
  80. package/dist/h3.js +0 -326
  81. package/dist/h3.js.map +0 -1
  82. package/dist/hono.d.ts +0 -10
  83. package/dist/hono.js +0 -25
  84. package/dist/hono.js.map +0 -1
  85. package/dist/index-UcTu1vUg.d.ts +0 -107
  86. package/dist/next.d.ts +0 -17
  87. package/dist/next.js +0 -26
  88. package/dist/next.js.map +0 -1
  89. package/dist/options-CH15FEBw.d.ts +0 -1562
  90. package/dist/providers.d.ts +0 -3
  91. package/dist/providers.js +0 -653
  92. package/dist/providers.js.map +0 -1
  93. package/dist/routes/session.d.ts +0 -39
  94. package/dist/routes/session.js +0 -128
  95. package/dist/routes/session.js.map +0 -1
  96. package/dist/types-DAxaMWCy.d.ts +0 -136
@@ -0,0 +1,1498 @@
1
+ import * as better_call from 'better-call';
2
+ import { Endpoint, EndpointResponse, ContextTools, CookieOptions, Context } from 'better-call';
3
+ import * as zod from 'zod';
4
+ import { ZodSchema } from 'zod';
5
+ import { L as LiteralString, U as UnionToIntersection, P as Prettify } from './helper-B5_2Vzba.js';
6
+ import { O as OAuthProvider, U as User, S as Session, A as Account } from './schema-BOszzrbQ.js';
7
+ import { Migration, Kysely } from 'kysely';
8
+
9
+ declare const createFieldAttribute: <T extends FieldType, C extends Omit<FieldAttributeConfig<T>, "type">>(type: T, config?: C) => {
10
+ required?: boolean;
11
+ returned?: boolean;
12
+ hashValue?: boolean;
13
+ defaultValue?: InferValueType<T> | (() => InferValueType<T>) | undefined;
14
+ transform?: ((value: InferValueType<T>) => InferValueType<T>) | undefined;
15
+ references?: {
16
+ /**
17
+ * The model to reference.
18
+ */
19
+ model: string;
20
+ /**
21
+ * The field on the referenced model.
22
+ */
23
+ field: string;
24
+ /**
25
+ * The action to perform when the reference is deleted.
26
+ * @default "cascade"
27
+ */
28
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
29
+ };
30
+ unique?: boolean;
31
+ validator?: ZodSchema;
32
+ type: T;
33
+ };
34
+ type FieldAttribute<T extends FieldType = FieldType> = {
35
+ type: T;
36
+ } & FieldAttributeConfig<T>;
37
+ type FieldType = "string" | "number" | "boolean" | "date";
38
+ type InferValueType<T extends FieldType> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "date" ? Date : never;
39
+ type InferFieldOutput<T extends FieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferValueType<T["type"]> | undefined : InferValueType<T["type"]>;
40
+ type FieldAttributeConfig<T extends FieldType = FieldType> = {
41
+ /**
42
+ * if the field should be required on a new record.
43
+ * @default false
44
+ */
45
+ required?: boolean;
46
+ /**
47
+ * If the value should be returned on a response body.
48
+ * @default true
49
+ */
50
+ returned?: boolean;
51
+ /**
52
+ * If the value should be hashed when it's stored.
53
+ * @default false
54
+ */
55
+ hashValue?: boolean;
56
+ /**
57
+ * Default value for the field
58
+ *
59
+ * Note: This will not create a default value on the database level. It will only
60
+ * be used when creating a new record.
61
+ */
62
+ defaultValue?: InferValueType<T> | (() => InferValueType<T>);
63
+ /**
64
+ * transform the value before storing it.
65
+ */
66
+ transform?: (value: InferValueType<T>) => InferValueType<T>;
67
+ /**
68
+ * Reference to another model.
69
+ */
70
+ references?: {
71
+ /**
72
+ * The model to reference.
73
+ */
74
+ model: string;
75
+ /**
76
+ * The field on the referenced model.
77
+ */
78
+ field: string;
79
+ /**
80
+ * The action to perform when the reference is deleted.
81
+ * @default "cascade"
82
+ */
83
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
84
+ };
85
+ unique?: boolean;
86
+ /**
87
+ * A zod schema to validate the value.
88
+ */
89
+ validator?: ZodSchema;
90
+ };
91
+
92
+ /**
93
+ * Adapter where clause
94
+ */
95
+ type Where = {
96
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte";
97
+ value: string;
98
+ field: string;
99
+ connector?: "AND" | "OR";
100
+ };
101
+ /**
102
+ * Adapter Interface
103
+ */
104
+ interface Adapter {
105
+ create: <T, R = T>(data: {
106
+ model: string;
107
+ data: T;
108
+ select?: string[];
109
+ }) => Promise<R>;
110
+ findOne: <T>(data: {
111
+ model: string;
112
+ where: Where[];
113
+ select?: string[];
114
+ }) => Promise<T | null>;
115
+ findMany: <T>(data: {
116
+ model: string;
117
+ where?: Where[];
118
+ }) => Promise<T[]>;
119
+ update: <T>(data: {
120
+ model: string;
121
+ where: Where[];
122
+ update: Record<string, any>;
123
+ }) => Promise<T>;
124
+ delete: <T>(data: {
125
+ model: string;
126
+ where: Where[];
127
+ }) => Promise<void>;
128
+ /**
129
+ * adapter specific configuration
130
+ */
131
+ config?: {
132
+ /**
133
+ * the format of the date fields
134
+ */
135
+ dateFormat?: "number" | "date";
136
+ /**
137
+ * if the adapter will throw an error when a
138
+ * record already exists. If this is set to
139
+ * false, there will be a check if the record
140
+ * exists or not before creating a new one.
141
+ */
142
+ failsOnRecordExist?: boolean;
143
+ };
144
+ createSchema?: (data: {
145
+ model: string;
146
+ fields: Record<string, FieldAttribute>;
147
+ }[]) => Promise<void>;
148
+ }
149
+
150
+ type AuthEndpoint = Endpoint<(ctx: {
151
+ options: BetterAuthOptions;
152
+ body: any;
153
+ query: any;
154
+ headers: Headers;
155
+ }) => Promise<EndpointResponse>>;
156
+
157
+ type GenericEndpointContext = ContextTools & {
158
+ context: AuthContext;
159
+ } & {
160
+ body: any;
161
+ request: Request;
162
+ headers: Headers;
163
+ params?: Record<string, string> | undefined;
164
+ query: any;
165
+ method: "*";
166
+ };
167
+
168
+ type PluginSchema = {
169
+ [table: string]: {
170
+ fields: {
171
+ [field in string]: FieldAttribute;
172
+ };
173
+ disableMigration?: boolean;
174
+ };
175
+ };
176
+ type BetterAuthPlugin = {
177
+ id: LiteralString;
178
+ endpoints?: {
179
+ [key: string]: AuthEndpoint;
180
+ };
181
+ middlewares?: {
182
+ path: string;
183
+ middleware: Endpoint;
184
+ }[];
185
+ hooks?: {
186
+ before?: {
187
+ matcher: (context: GenericEndpointContext) => boolean;
188
+ handler: (context: GenericEndpointContext) => Promise<void | {
189
+ context: Partial<GenericEndpointContext>;
190
+ }>;
191
+ }[];
192
+ after?: {
193
+ matcher: (context: GenericEndpointContext) => boolean;
194
+ handler: (context: GenericEndpointContext & {
195
+ returned: EndpointResponse;
196
+ }) => Promise<void | {
197
+ response: EndpointResponse;
198
+ }>;
199
+ }[];
200
+ };
201
+ /**
202
+ * Schema the plugin needs
203
+ *
204
+ * This will also be used to migrate the database. If the fields are dynamic from the plugins
205
+ * configuration each time the configuration is changed a new migration will be created.
206
+ *
207
+ * NOTE: If you want to create migrations manually using
208
+ * migrations option or any other way you
209
+ * can disable migration per table basis.
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * schema: {
214
+ * user: {
215
+ * fields: {
216
+ * email: {
217
+ * type: "string",
218
+ * },
219
+ * emailVerified: {
220
+ * type: "boolean",
221
+ * defaultValue: false,
222
+ * },
223
+ * },
224
+ * }
225
+ * } as PluginSchema
226
+ * ```
227
+ */
228
+ schema?: PluginSchema;
229
+ /**
230
+ * The migrations of the plugin. If you define schema that will automatically create
231
+ * migrations for you.
232
+ *
233
+ * ⚠️ Only uses this if you dont't want to use the schema option and you disabled migrations for
234
+ * the tables.
235
+ */
236
+ migrations?: Record<string, Migration>;
237
+ /**
238
+ * The options of the plugin
239
+ */
240
+ options?: Record<string, any>;
241
+ };
242
+
243
+ interface BetterAuthOptions {
244
+ /**
245
+ * Base URL for the better auth. This is typically the
246
+ * root URL where your
247
+ * application server is hosted. If not explicitly set,
248
+ * the system will check the following environment variable:
249
+ *
250
+ * process.env.BETTER_AUTH_URL
251
+ *
252
+ * If not set it will throw an error.
253
+ */
254
+ baseURL?: string;
255
+ /**
256
+ * Base path for the better auth. This is typically the path where the
257
+ * better auth routes are mounted.
258
+ *
259
+ * @default "/api/auth"
260
+ */
261
+ basePath?: string;
262
+ /**
263
+ * The secret to use for encryption,
264
+ * signing and hashing.
265
+ *
266
+ * By default better auth will look for
267
+ * the following environment variables:
268
+ * process.env.BETTER_AUTH_SECRET,
269
+ * process.env.AUTH_SECRET
270
+ * If none of these environment
271
+ * variables are set,
272
+ * it will default to
273
+ * "better-auth-secret-123456789".
274
+ *
275
+ * on production if it's not set
276
+ * it will throw an error.
277
+ *
278
+ * you can generate a good secret
279
+ * using the following command:
280
+ * @example
281
+ * ```bash
282
+ * openssl rand -base64 32
283
+ * ```
284
+ */
285
+ secret?: string;
286
+ /**
287
+ * list of social providers
288
+ */
289
+ socialProvider?: OAuthProvider[];
290
+ /**
291
+ * Plugins
292
+ */
293
+ plugins?: BetterAuthPlugin[];
294
+ /**
295
+ * Advanced options
296
+ */
297
+ advanced?: {
298
+ /**
299
+ * Use secure cookies
300
+ *
301
+ * @default false
302
+ */
303
+ useSecureCookies?: boolean;
304
+ /**
305
+ * Disable CSRF check
306
+ */
307
+ disableCSRFCheck?: boolean;
308
+ };
309
+ /**
310
+ * Disable logging
311
+ *
312
+ * @default false
313
+ */
314
+ disableLog?: boolean;
315
+ /**
316
+ * Database configuration
317
+ */
318
+ database: {
319
+ provider: "postgres" | "sqlite" | "mysql";
320
+ url: string;
321
+ } | Adapter;
322
+ /**
323
+ * User configuration
324
+ */
325
+ user?: {
326
+ /**
327
+ * The model name for the user. Defaults to "user".
328
+ */
329
+ modelName?: string;
330
+ /**
331
+ * Additional fields to add to the user model
332
+ */
333
+ additionalFields?: Record<string, FieldAttribute>;
334
+ };
335
+ session?: {
336
+ modelName?: string;
337
+ /**
338
+ * Expiration time for the session token. The value
339
+ * should be in seconds.
340
+ * @default 7 days (60 * 60 * 24 * 7)
341
+ */
342
+ expiresIn?: number;
343
+ /**
344
+ * How often the session should be refreshed. The value
345
+ * should be in seconds.
346
+ * If set 0 the session will be refreshed every time it is used.
347
+ * @default 1 day (60 * 60 * 24)
348
+ */
349
+ updateAge?: number;
350
+ };
351
+ account?: {
352
+ modelName?: string;
353
+ };
354
+ /**
355
+ * Email and password authentication
356
+ */
357
+ emailAndPassword?: {
358
+ /**
359
+ * Enable email and password authentication
360
+ *
361
+ * @default false
362
+ */
363
+ enabled: boolean;
364
+ /**
365
+ * The maximum length of the password.
366
+ *
367
+ * @default 8
368
+ */
369
+ maxPasswordLength?: number;
370
+ /**
371
+ * The minimum length of the password.
372
+ *
373
+ * @default 32
374
+ */
375
+ minPasswordLength?: number;
376
+ /**
377
+ * send reset password email
378
+ *
379
+ * @param token the token to send to the email. Make sure to include the token as a
380
+ * parameter in the URL. You'll need to send it back to reset the password.
381
+ * @param user the user to send the email to
382
+ */
383
+ sendResetPasswordToken?: (token: string, user: User) => Promise<void>;
384
+ /**
385
+ * @param email the email to send the verification email to
386
+ * @param url the url to send the verification email to
387
+ */
388
+ sendVerificationEmail?: (email: string, url: string) => Promise<void>;
389
+ };
390
+ /**
391
+ * List of trusted origins.
392
+ */
393
+ trustedOrigins?: string[];
394
+ }
395
+
396
+ type AdditionalSessionFields<Options extends BetterAuthOptions> = Options["plugins"] extends Array<infer T> ? T extends {
397
+ schema: {
398
+ session: {
399
+ fields: infer Field;
400
+ };
401
+ };
402
+ } ? Field extends Record<string, FieldAttribute> ? {
403
+ [key in keyof Field]: InferFieldOutput<Field[key]>;
404
+ } : {} : {} : {};
405
+ type AdditionalUserFields<Options extends BetterAuthOptions> = Options["plugins"] extends Array<infer T> ? T extends {
406
+ schema: {
407
+ user: {
408
+ fields: infer Field;
409
+ };
410
+ };
411
+ } ? Field extends Record<infer Key, FieldAttribute> ? Prettify<{
412
+ [key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends boolean | string | number | Date | Function ? key : never]: InferFieldOutput<Field[key]>;
413
+ } & {
414
+ [key in Key as Field[key]["returned"] extends false ? never : key]?: InferFieldOutput<Field[key]>;
415
+ }> : {} : {} : {};
416
+ type InferUser<O extends BetterAuthOptions | Auth> = UnionToIntersection<User & (O extends BetterAuthOptions ? AdditionalUserFields<O> : O extends Auth ? AdditionalUserFields<O["options"]> : {})>;
417
+ type InferSession<O extends BetterAuthOptions | Auth> = UnionToIntersection<Session & (O extends BetterAuthOptions ? AdditionalSessionFields<O> : O extends Auth ? AdditionalSessionFields<O["options"]> : {})>;
418
+
419
+ declare const createInternalAdapter: (adapter: Adapter, options: BetterAuthOptions) => {
420
+ createOAuthUser: (user: User, account: Account) => Promise<{
421
+ user: {
422
+ id: string;
423
+ name: string;
424
+ email: string;
425
+ emailVerified: boolean;
426
+ createdAt: Date;
427
+ updatedAt: Date;
428
+ image?: string | undefined;
429
+ };
430
+ account: {
431
+ id: string;
432
+ userId: string;
433
+ accountId: string;
434
+ providerId: string;
435
+ password?: string | null | undefined;
436
+ accessToken?: string | null | undefined;
437
+ refreshToken?: string | null | undefined;
438
+ idToken?: string | null | undefined;
439
+ accessTokenExpiresAt?: Date | null | undefined;
440
+ refreshTokenExpiresAt?: Date | null | undefined;
441
+ };
442
+ } | null>;
443
+ createUser: (user: User) => Promise<{
444
+ id: string;
445
+ name: string;
446
+ email: string;
447
+ emailVerified: boolean;
448
+ createdAt: Date;
449
+ updatedAt: Date;
450
+ image?: string | undefined;
451
+ }>;
452
+ createSession: (userId: string, request?: Request) => Promise<{
453
+ id: string;
454
+ userId: string;
455
+ expiresAt: Date;
456
+ ipAddress?: string | undefined;
457
+ userAgent?: string | undefined;
458
+ }>;
459
+ findSession: (sessionId: string) => Promise<{
460
+ session: {
461
+ id: string;
462
+ userId: string;
463
+ expiresAt: Date;
464
+ ipAddress?: string | undefined;
465
+ userAgent?: string | undefined;
466
+ };
467
+ user: {
468
+ id: string;
469
+ name: string;
470
+ email: string;
471
+ emailVerified: boolean;
472
+ createdAt: Date;
473
+ updatedAt: Date;
474
+ image?: string | undefined;
475
+ };
476
+ } | null>;
477
+ updateSession: (session: Session) => Promise<{
478
+ id: string;
479
+ userId: string;
480
+ expiresAt: Date;
481
+ ipAddress?: string | undefined;
482
+ userAgent?: string | undefined;
483
+ }>;
484
+ deleteSession: (id: string) => Promise<void>;
485
+ findUserByEmail: (email: string) => Promise<{
486
+ user: {
487
+ id: string;
488
+ name: string;
489
+ email: string;
490
+ emailVerified: boolean;
491
+ createdAt: Date;
492
+ updatedAt: Date;
493
+ image?: string | undefined;
494
+ };
495
+ accounts: {
496
+ id: string;
497
+ userId: string;
498
+ accountId: string;
499
+ providerId: string;
500
+ password?: string | null | undefined;
501
+ accessToken?: string | null | undefined;
502
+ refreshToken?: string | null | undefined;
503
+ idToken?: string | null | undefined;
504
+ accessTokenExpiresAt?: Date | null | undefined;
505
+ refreshTokenExpiresAt?: Date | null | undefined;
506
+ }[];
507
+ } | null>;
508
+ findUserById: (userId: string) => Promise<{
509
+ id: string;
510
+ name: string;
511
+ email: string;
512
+ emailVerified: boolean;
513
+ createdAt: Date;
514
+ updatedAt: Date;
515
+ image?: string | undefined;
516
+ } | null>;
517
+ linkAccount: (account: Account) => Promise<{
518
+ id: string;
519
+ userId: string;
520
+ accountId: string;
521
+ providerId: string;
522
+ password?: string | null | undefined;
523
+ accessToken?: string | null | undefined;
524
+ refreshToken?: string | null | undefined;
525
+ idToken?: string | null | undefined;
526
+ accessTokenExpiresAt?: Date | null | undefined;
527
+ refreshTokenExpiresAt?: Date | null | undefined;
528
+ }>;
529
+ updateUserByEmail: (email: string, data: Partial<User & Record<string, any>>) => Promise<{
530
+ id: string;
531
+ name: string;
532
+ email: string;
533
+ emailVerified: boolean;
534
+ createdAt: Date;
535
+ updatedAt: Date;
536
+ image?: string | undefined;
537
+ }>;
538
+ updatePassword: (userId: string, password: string) => Promise<{
539
+ id: string;
540
+ userId: string;
541
+ accountId: string;
542
+ providerId: string;
543
+ password?: string | null | undefined;
544
+ accessToken?: string | null | undefined;
545
+ refreshToken?: string | null | undefined;
546
+ idToken?: string | null | undefined;
547
+ accessTokenExpiresAt?: Date | null | undefined;
548
+ refreshTokenExpiresAt?: Date | null | undefined;
549
+ }>;
550
+ };
551
+ type InternalAdapter = ReturnType<typeof createInternalAdapter>;
552
+
553
+ declare const createKyselyAdapter: (config: BetterAuthOptions) => Kysely<any> | null;
554
+
555
+ declare function getAdapter(options: BetterAuthOptions): Adapter;
556
+
557
+ declare function getCookies(options: BetterAuthOptions): {
558
+ sessionToken: {
559
+ name: string;
560
+ options: {
561
+ httpOnly: true;
562
+ sameSite: "lax";
563
+ path: string;
564
+ secure: boolean;
565
+ maxAge: number;
566
+ };
567
+ };
568
+ csrfToken: {
569
+ name: string;
570
+ options: {
571
+ httpOnly: true;
572
+ sameSite: "lax";
573
+ path: string;
574
+ secure: boolean;
575
+ maxAge: number;
576
+ };
577
+ };
578
+ state: {
579
+ name: string;
580
+ options: {
581
+ httpOnly: true;
582
+ sameSite: "lax";
583
+ path: string;
584
+ secure: boolean;
585
+ maxAge: number;
586
+ };
587
+ };
588
+ pkCodeVerifier: {
589
+ name: string;
590
+ options: CookieOptions;
591
+ };
592
+ nonce: {
593
+ name: string;
594
+ options: CookieOptions;
595
+ };
596
+ };
597
+ declare function createCookieGetter(options: BetterAuthOptions): (cookieName: string, options?: CookieOptions) => {
598
+ name: string;
599
+ options: CookieOptions;
600
+ };
601
+ type BetterAuthCookies = ReturnType<typeof getCookies>;
602
+
603
+ declare const createLogger: (options?: {
604
+ disabled?: boolean;
605
+ }) => {
606
+ log: (...args: any[]) => void;
607
+ error: (...args: any[]) => void;
608
+ warn: (...args: any[]) => void;
609
+ info: (...args: any[]) => void;
610
+ debug: (...args: any[]) => void;
611
+ box: (...args: any[]) => void;
612
+ success: (...args: any[]) => void;
613
+ break: (...args: any[]) => void;
614
+ };
615
+
616
+ type AuthContext = {
617
+ options: BetterAuthOptions;
618
+ baseURL: string;
619
+ authCookies: BetterAuthCookies;
620
+ logger: ReturnType<typeof createLogger>;
621
+ db: ReturnType<typeof createKyselyAdapter>;
622
+ adapter: ReturnType<typeof getAdapter>;
623
+ internalAdapter: ReturnType<typeof createInternalAdapter>;
624
+ createAuthCookie: ReturnType<typeof createCookieGetter>;
625
+ secret: string;
626
+ };
627
+
628
+ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(ctx: C) => {
629
+ handler: (request: Request) => Promise<Response>;
630
+ endpoints: {
631
+ signInOAuth: {
632
+ (ctx_0: Context<"/sign-in/social", {
633
+ method: "POST";
634
+ requireHeaders: true;
635
+ query: zod.ZodOptional<zod.ZodObject<{
636
+ currentURL: zod.ZodOptional<zod.ZodString>;
637
+ }, "strip", zod.ZodTypeAny, {
638
+ currentURL?: string | undefined;
639
+ }, {
640
+ currentURL?: string | undefined;
641
+ }>>;
642
+ body: zod.ZodObject<{
643
+ callbackURL: zod.ZodOptional<zod.ZodString>;
644
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
645
+ }, "strip", zod.ZodTypeAny, {
646
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
647
+ callbackURL?: string | undefined;
648
+ }, {
649
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
650
+ callbackURL?: string | undefined;
651
+ }>;
652
+ }>): Promise<{
653
+ url: string;
654
+ state: string;
655
+ codeVerifier: string;
656
+ redirect: boolean;
657
+ }>;
658
+ path: "/sign-in/social";
659
+ options: {
660
+ method: "POST";
661
+ requireHeaders: true;
662
+ query: zod.ZodOptional<zod.ZodObject<{
663
+ currentURL: zod.ZodOptional<zod.ZodString>;
664
+ }, "strip", zod.ZodTypeAny, {
665
+ currentURL?: string | undefined;
666
+ }, {
667
+ currentURL?: string | undefined;
668
+ }>>;
669
+ body: zod.ZodObject<{
670
+ callbackURL: zod.ZodOptional<zod.ZodString>;
671
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
672
+ }, "strip", zod.ZodTypeAny, {
673
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
674
+ callbackURL?: string | undefined;
675
+ }, {
676
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
677
+ callbackURL?: string | undefined;
678
+ }>;
679
+ };
680
+ method: better_call.Method | better_call.Method[];
681
+ headers: Headers;
682
+ };
683
+ callbackOAuth: {
684
+ (ctx_0: Context<"/callback/:id", {
685
+ method: "GET";
686
+ query: zod.ZodObject<{
687
+ state: zod.ZodString;
688
+ code: zod.ZodString;
689
+ code_verifier: zod.ZodOptional<zod.ZodString>;
690
+ }, "strip", zod.ZodTypeAny, {
691
+ code: string;
692
+ state: string;
693
+ code_verifier?: string | undefined;
694
+ }, {
695
+ code: string;
696
+ state: string;
697
+ code_verifier?: string | undefined;
698
+ }>;
699
+ metadata: {
700
+ onClient: "hide";
701
+ };
702
+ }>): Promise<never>;
703
+ path: "/callback/:id";
704
+ options: {
705
+ method: "GET";
706
+ query: zod.ZodObject<{
707
+ state: zod.ZodString;
708
+ code: zod.ZodString;
709
+ code_verifier: zod.ZodOptional<zod.ZodString>;
710
+ }, "strip", zod.ZodTypeAny, {
711
+ code: string;
712
+ state: string;
713
+ code_verifier?: string | undefined;
714
+ }, {
715
+ code: string;
716
+ state: string;
717
+ code_verifier?: string | undefined;
718
+ }>;
719
+ metadata: {
720
+ onClient: "hide";
721
+ };
722
+ };
723
+ method: better_call.Method | better_call.Method[];
724
+ headers: Headers;
725
+ };
726
+ getCSRFToken: {
727
+ (ctx_0?: Context<"/csrf", {
728
+ method: "GET";
729
+ metadata: {
730
+ onClient: "hide";
731
+ };
732
+ }> | undefined): Promise<{
733
+ csrfToken: string;
734
+ }>;
735
+ path: "/csrf";
736
+ options: {
737
+ method: "GET";
738
+ metadata: {
739
+ onClient: "hide";
740
+ };
741
+ };
742
+ method: better_call.Method | better_call.Method[];
743
+ headers: Headers;
744
+ };
745
+ getSession: {
746
+ (ctx: Context<"/session", {
747
+ method: "GET";
748
+ requireHeaders: true;
749
+ }>): Promise<{
750
+ session: Prettify<InferSession<Option>>;
751
+ user: Prettify<InferUser<Option>>;
752
+ } | null>;
753
+ path: "/session";
754
+ method: better_call.Method | better_call.Method[];
755
+ options: {
756
+ method: "GET";
757
+ requireHeaders: true;
758
+ };
759
+ headers: Headers;
760
+ };
761
+ signOut: {
762
+ (ctx_0?: Context<"/sign-out", {
763
+ method: "POST";
764
+ body: zod.ZodOptional<zod.ZodObject<{
765
+ callbackURL: zod.ZodOptional<zod.ZodString>;
766
+ }, "strip", zod.ZodTypeAny, {
767
+ callbackURL?: string | undefined;
768
+ }, {
769
+ callbackURL?: string | undefined;
770
+ }>>;
771
+ }> | undefined): Promise<null>;
772
+ path: "/sign-out";
773
+ options: {
774
+ method: "POST";
775
+ body: zod.ZodOptional<zod.ZodObject<{
776
+ callbackURL: zod.ZodOptional<zod.ZodString>;
777
+ }, "strip", zod.ZodTypeAny, {
778
+ callbackURL?: string | undefined;
779
+ }, {
780
+ callbackURL?: string | undefined;
781
+ }>>;
782
+ };
783
+ method: better_call.Method | better_call.Method[];
784
+ headers: Headers;
785
+ };
786
+ signUpEmail: {
787
+ (ctx_0: Context<"/sign-up/email", {
788
+ method: "POST";
789
+ body: zod.ZodObject<{
790
+ name: zod.ZodString;
791
+ email: zod.ZodString;
792
+ password: zod.ZodString;
793
+ image: zod.ZodOptional<zod.ZodString>;
794
+ callbackURL: zod.ZodOptional<zod.ZodString>;
795
+ }, "strip", zod.ZodTypeAny, {
796
+ password: string;
797
+ name: string;
798
+ email: string;
799
+ image?: string | undefined;
800
+ callbackURL?: string | undefined;
801
+ }, {
802
+ password: string;
803
+ name: string;
804
+ email: string;
805
+ image?: string | undefined;
806
+ callbackURL?: string | undefined;
807
+ }>;
808
+ }>): Promise<{
809
+ user: {
810
+ id: string;
811
+ name: string;
812
+ email: string;
813
+ emailVerified: boolean;
814
+ createdAt: Date;
815
+ updatedAt: Date;
816
+ image?: string | undefined;
817
+ };
818
+ session: {
819
+ id: string;
820
+ userId: string;
821
+ expiresAt: Date;
822
+ ipAddress?: string | undefined;
823
+ userAgent?: string | undefined;
824
+ };
825
+ } | null>;
826
+ path: "/sign-up/email";
827
+ options: {
828
+ method: "POST";
829
+ body: zod.ZodObject<{
830
+ name: zod.ZodString;
831
+ email: zod.ZodString;
832
+ password: zod.ZodString;
833
+ image: zod.ZodOptional<zod.ZodString>;
834
+ callbackURL: zod.ZodOptional<zod.ZodString>;
835
+ }, "strip", zod.ZodTypeAny, {
836
+ password: string;
837
+ name: string;
838
+ email: string;
839
+ image?: string | undefined;
840
+ callbackURL?: string | undefined;
841
+ }, {
842
+ password: string;
843
+ name: string;
844
+ email: string;
845
+ image?: string | undefined;
846
+ callbackURL?: string | undefined;
847
+ }>;
848
+ };
849
+ method: better_call.Method | better_call.Method[];
850
+ headers: Headers;
851
+ };
852
+ signInEmail: {
853
+ (ctx_0: Context<"/sign-in/email", {
854
+ method: "POST";
855
+ body: zod.ZodObject<{
856
+ email: zod.ZodString;
857
+ password: zod.ZodString;
858
+ callbackURL: zod.ZodOptional<zod.ZodString>;
859
+ dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
860
+ }, "strip", zod.ZodTypeAny, {
861
+ password: string;
862
+ email: string;
863
+ callbackURL?: string | undefined;
864
+ dontRememberMe?: boolean | undefined;
865
+ }, {
866
+ password: string;
867
+ email: string;
868
+ callbackURL?: string | undefined;
869
+ dontRememberMe?: boolean | undefined;
870
+ }>;
871
+ }>): Promise<{
872
+ user: {
873
+ id: string;
874
+ name: string;
875
+ email: string;
876
+ emailVerified: boolean;
877
+ createdAt: Date;
878
+ updatedAt: Date;
879
+ image?: string | undefined;
880
+ };
881
+ session: {
882
+ id: string;
883
+ userId: string;
884
+ expiresAt: Date;
885
+ ipAddress?: string | undefined;
886
+ userAgent?: string | undefined;
887
+ };
888
+ redirect: boolean;
889
+ url: string | undefined;
890
+ }>;
891
+ path: "/sign-in/email";
892
+ options: {
893
+ method: "POST";
894
+ body: zod.ZodObject<{
895
+ email: zod.ZodString;
896
+ password: zod.ZodString;
897
+ callbackURL: zod.ZodOptional<zod.ZodString>;
898
+ dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
899
+ }, "strip", zod.ZodTypeAny, {
900
+ password: string;
901
+ email: string;
902
+ callbackURL?: string | undefined;
903
+ dontRememberMe?: boolean | undefined;
904
+ }, {
905
+ password: string;
906
+ email: string;
907
+ callbackURL?: string | undefined;
908
+ dontRememberMe?: boolean | undefined;
909
+ }>;
910
+ };
911
+ method: better_call.Method | better_call.Method[];
912
+ headers: Headers;
913
+ };
914
+ forgetPassword: {
915
+ (ctx_0: Context<"/forget-password", {
916
+ method: "POST";
917
+ body: zod.ZodObject<{
918
+ email: zod.ZodString;
919
+ }, "strip", zod.ZodTypeAny, {
920
+ email: string;
921
+ }, {
922
+ email: string;
923
+ }>;
924
+ }>): Promise<{
925
+ error: string;
926
+ } | {
927
+ status: boolean;
928
+ } | null>;
929
+ path: "/forget-password";
930
+ options: {
931
+ method: "POST";
932
+ body: zod.ZodObject<{
933
+ email: zod.ZodString;
934
+ }, "strip", zod.ZodTypeAny, {
935
+ email: string;
936
+ }, {
937
+ email: string;
938
+ }>;
939
+ };
940
+ method: better_call.Method | better_call.Method[];
941
+ headers: Headers;
942
+ };
943
+ resetPassword: {
944
+ (ctx_0: Context<"/reset-password", {
945
+ method: "POST";
946
+ body: zod.ZodObject<{
947
+ token: zod.ZodString;
948
+ newPassword: zod.ZodString;
949
+ callbackURL: zod.ZodOptional<zod.ZodString>;
950
+ }, "strip", zod.ZodTypeAny, {
951
+ token: string;
952
+ newPassword: string;
953
+ callbackURL?: string | undefined;
954
+ }, {
955
+ token: string;
956
+ newPassword: string;
957
+ callbackURL?: string | undefined;
958
+ }>;
959
+ }>): Promise<{
960
+ status: boolean;
961
+ url: string | undefined;
962
+ redirect: boolean;
963
+ } | null>;
964
+ path: "/reset-password";
965
+ options: {
966
+ method: "POST";
967
+ body: zod.ZodObject<{
968
+ token: zod.ZodString;
969
+ newPassword: zod.ZodString;
970
+ callbackURL: zod.ZodOptional<zod.ZodString>;
971
+ }, "strip", zod.ZodTypeAny, {
972
+ token: string;
973
+ newPassword: string;
974
+ callbackURL?: string | undefined;
975
+ }, {
976
+ token: string;
977
+ newPassword: string;
978
+ callbackURL?: string | undefined;
979
+ }>;
980
+ };
981
+ method: better_call.Method | better_call.Method[];
982
+ headers: Headers;
983
+ };
984
+ verifyEmail: {
985
+ (ctx_0: Context<"/verify-email", {
986
+ method: "GET";
987
+ query: zod.ZodObject<{
988
+ token: zod.ZodString;
989
+ callbackURL: zod.ZodString;
990
+ }, "strip", zod.ZodTypeAny, {
991
+ token: string;
992
+ callbackURL: string;
993
+ }, {
994
+ token: string;
995
+ callbackURL: string;
996
+ }>;
997
+ }>): Promise<{
998
+ status: boolean;
999
+ } | null>;
1000
+ path: "/verify-email";
1001
+ options: {
1002
+ method: "GET";
1003
+ query: zod.ZodObject<{
1004
+ token: zod.ZodString;
1005
+ callbackURL: zod.ZodString;
1006
+ }, "strip", zod.ZodTypeAny, {
1007
+ token: string;
1008
+ callbackURL: string;
1009
+ }, {
1010
+ token: string;
1011
+ callbackURL: string;
1012
+ }>;
1013
+ };
1014
+ method: better_call.Method | better_call.Method[];
1015
+ headers: Headers;
1016
+ };
1017
+ sendVerificationEmail: {
1018
+ (ctx_0: Context<"/send-verification-email", {
1019
+ method: "POST";
1020
+ body: zod.ZodObject<{
1021
+ email: zod.ZodString;
1022
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1023
+ }, "strip", zod.ZodTypeAny, {
1024
+ email: string;
1025
+ callbackURL?: string | undefined;
1026
+ }, {
1027
+ email: string;
1028
+ callbackURL?: string | undefined;
1029
+ }>;
1030
+ }>): Promise<{
1031
+ status: boolean;
1032
+ } | null>;
1033
+ path: "/send-verification-email";
1034
+ options: {
1035
+ method: "POST";
1036
+ body: zod.ZodObject<{
1037
+ email: zod.ZodString;
1038
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1039
+ }, "strip", zod.ZodTypeAny, {
1040
+ email: string;
1041
+ callbackURL?: string | undefined;
1042
+ }, {
1043
+ email: string;
1044
+ callbackURL?: string | undefined;
1045
+ }>;
1046
+ };
1047
+ method: better_call.Method | better_call.Method[];
1048
+ headers: Headers;
1049
+ };
1050
+ };
1051
+ };
1052
+
1053
+ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
1054
+ handler: (request: Request) => Promise<Response>;
1055
+ api: {
1056
+ signInOAuth: {
1057
+ (ctx_0: better_call.Context<"/sign-in/social", {
1058
+ method: "POST";
1059
+ requireHeaders: true;
1060
+ query: zod.ZodOptional<zod.ZodObject<{
1061
+ currentURL: zod.ZodOptional<zod.ZodString>;
1062
+ }, "strip", zod.ZodTypeAny, {
1063
+ currentURL?: string | undefined;
1064
+ }, {
1065
+ currentURL?: string | undefined;
1066
+ }>>;
1067
+ body: zod.ZodObject<{
1068
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1069
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
1070
+ }, "strip", zod.ZodTypeAny, {
1071
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
1072
+ callbackURL?: string | undefined;
1073
+ }, {
1074
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
1075
+ callbackURL?: string | undefined;
1076
+ }>;
1077
+ }>): Promise<{
1078
+ url: string;
1079
+ state: string;
1080
+ codeVerifier: string;
1081
+ redirect: boolean;
1082
+ }>;
1083
+ path: "/sign-in/social";
1084
+ options: {
1085
+ method: "POST";
1086
+ requireHeaders: true;
1087
+ query: zod.ZodOptional<zod.ZodObject<{
1088
+ currentURL: zod.ZodOptional<zod.ZodString>;
1089
+ }, "strip", zod.ZodTypeAny, {
1090
+ currentURL?: string | undefined;
1091
+ }, {
1092
+ currentURL?: string | undefined;
1093
+ }>>;
1094
+ body: zod.ZodObject<{
1095
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1096
+ provider: zod.ZodEnum<["github", ...("github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter")[]]>;
1097
+ }, "strip", zod.ZodTypeAny, {
1098
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
1099
+ callbackURL?: string | undefined;
1100
+ }, {
1101
+ provider: "github" | "apple" | "discord" | "facebook" | "google" | "spotify" | "twitch" | "twitter";
1102
+ callbackURL?: string | undefined;
1103
+ }>;
1104
+ };
1105
+ method: better_call.Method | better_call.Method[];
1106
+ headers: Headers;
1107
+ };
1108
+ callbackOAuth: {
1109
+ (ctx_0: better_call.Context<"/callback/:id", {
1110
+ method: "GET";
1111
+ query: zod.ZodObject<{
1112
+ state: zod.ZodString;
1113
+ code: zod.ZodString;
1114
+ code_verifier: zod.ZodOptional<zod.ZodString>;
1115
+ }, "strip", zod.ZodTypeAny, {
1116
+ code: string;
1117
+ state: string;
1118
+ code_verifier?: string | undefined;
1119
+ }, {
1120
+ code: string;
1121
+ state: string;
1122
+ code_verifier?: string | undefined;
1123
+ }>;
1124
+ metadata: {
1125
+ onClient: "hide";
1126
+ };
1127
+ }>): Promise<never>;
1128
+ path: "/callback/:id";
1129
+ options: {
1130
+ method: "GET";
1131
+ query: zod.ZodObject<{
1132
+ state: zod.ZodString;
1133
+ code: zod.ZodString;
1134
+ code_verifier: zod.ZodOptional<zod.ZodString>;
1135
+ }, "strip", zod.ZodTypeAny, {
1136
+ code: string;
1137
+ state: string;
1138
+ code_verifier?: string | undefined;
1139
+ }, {
1140
+ code: string;
1141
+ state: string;
1142
+ code_verifier?: string | undefined;
1143
+ }>;
1144
+ metadata: {
1145
+ onClient: "hide";
1146
+ };
1147
+ };
1148
+ method: better_call.Method | better_call.Method[];
1149
+ headers: Headers;
1150
+ };
1151
+ getCSRFToken: {
1152
+ (ctx_0?: better_call.Context<"/csrf", {
1153
+ method: "GET";
1154
+ metadata: {
1155
+ onClient: "hide";
1156
+ };
1157
+ }> | undefined): Promise<{
1158
+ csrfToken: string;
1159
+ }>;
1160
+ path: "/csrf";
1161
+ options: {
1162
+ method: "GET";
1163
+ metadata: {
1164
+ onClient: "hide";
1165
+ };
1166
+ };
1167
+ method: better_call.Method | better_call.Method[];
1168
+ headers: Headers;
1169
+ };
1170
+ getSession: {
1171
+ (ctx: better_call.Context<"/session", {
1172
+ method: "GET";
1173
+ requireHeaders: true;
1174
+ }>): Promise<{
1175
+ session: {
1176
+ id: string;
1177
+ userId: string;
1178
+ expiresAt: Date;
1179
+ ipAddress?: string | undefined;
1180
+ userAgent?: string | undefined;
1181
+ };
1182
+ user: {
1183
+ id: string;
1184
+ name: string;
1185
+ email: string;
1186
+ emailVerified: boolean;
1187
+ createdAt: Date;
1188
+ updatedAt: Date;
1189
+ image?: string | undefined;
1190
+ };
1191
+ } | null>;
1192
+ path: "/session";
1193
+ method: better_call.Method | better_call.Method[];
1194
+ options: {
1195
+ method: "GET";
1196
+ requireHeaders: true;
1197
+ };
1198
+ headers: Headers;
1199
+ };
1200
+ signOut: {
1201
+ (ctx_0?: better_call.Context<"/sign-out", {
1202
+ method: "POST";
1203
+ body: zod.ZodOptional<zod.ZodObject<{
1204
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1205
+ }, "strip", zod.ZodTypeAny, {
1206
+ callbackURL?: string | undefined;
1207
+ }, {
1208
+ callbackURL?: string | undefined;
1209
+ }>>;
1210
+ }> | undefined): Promise<null>;
1211
+ path: "/sign-out";
1212
+ options: {
1213
+ method: "POST";
1214
+ body: zod.ZodOptional<zod.ZodObject<{
1215
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1216
+ }, "strip", zod.ZodTypeAny, {
1217
+ callbackURL?: string | undefined;
1218
+ }, {
1219
+ callbackURL?: string | undefined;
1220
+ }>>;
1221
+ };
1222
+ method: better_call.Method | better_call.Method[];
1223
+ headers: Headers;
1224
+ };
1225
+ signUpEmail: {
1226
+ (ctx_0: better_call.Context<"/sign-up/email", {
1227
+ method: "POST";
1228
+ body: zod.ZodObject<{
1229
+ name: zod.ZodString;
1230
+ email: zod.ZodString;
1231
+ password: zod.ZodString;
1232
+ image: zod.ZodOptional<zod.ZodString>;
1233
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1234
+ }, "strip", zod.ZodTypeAny, {
1235
+ password: string;
1236
+ name: string;
1237
+ email: string;
1238
+ image?: string | undefined;
1239
+ callbackURL?: string | undefined;
1240
+ }, {
1241
+ password: string;
1242
+ name: string;
1243
+ email: string;
1244
+ image?: string | undefined;
1245
+ callbackURL?: string | undefined;
1246
+ }>;
1247
+ }>): Promise<{
1248
+ user: {
1249
+ id: string;
1250
+ name: string;
1251
+ email: string;
1252
+ emailVerified: boolean;
1253
+ createdAt: Date;
1254
+ updatedAt: Date;
1255
+ image?: string | undefined;
1256
+ };
1257
+ session: {
1258
+ id: string;
1259
+ userId: string;
1260
+ expiresAt: Date;
1261
+ ipAddress?: string | undefined;
1262
+ userAgent?: string | undefined;
1263
+ };
1264
+ } | null>;
1265
+ path: "/sign-up/email";
1266
+ options: {
1267
+ method: "POST";
1268
+ body: zod.ZodObject<{
1269
+ name: zod.ZodString;
1270
+ email: zod.ZodString;
1271
+ password: zod.ZodString;
1272
+ image: zod.ZodOptional<zod.ZodString>;
1273
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1274
+ }, "strip", zod.ZodTypeAny, {
1275
+ password: string;
1276
+ name: string;
1277
+ email: string;
1278
+ image?: string | undefined;
1279
+ callbackURL?: string | undefined;
1280
+ }, {
1281
+ password: string;
1282
+ name: string;
1283
+ email: string;
1284
+ image?: string | undefined;
1285
+ callbackURL?: string | undefined;
1286
+ }>;
1287
+ };
1288
+ method: better_call.Method | better_call.Method[];
1289
+ headers: Headers;
1290
+ };
1291
+ signInEmail: {
1292
+ (ctx_0: better_call.Context<"/sign-in/email", {
1293
+ method: "POST";
1294
+ body: zod.ZodObject<{
1295
+ email: zod.ZodString;
1296
+ password: zod.ZodString;
1297
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1298
+ dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
1299
+ }, "strip", zod.ZodTypeAny, {
1300
+ password: string;
1301
+ email: string;
1302
+ callbackURL?: string | undefined;
1303
+ dontRememberMe?: boolean | undefined;
1304
+ }, {
1305
+ password: string;
1306
+ email: string;
1307
+ callbackURL?: string | undefined;
1308
+ dontRememberMe?: boolean | undefined;
1309
+ }>;
1310
+ }>): Promise<{
1311
+ user: {
1312
+ id: string;
1313
+ name: string;
1314
+ email: string;
1315
+ emailVerified: boolean;
1316
+ createdAt: Date;
1317
+ updatedAt: Date;
1318
+ image?: string | undefined;
1319
+ };
1320
+ session: {
1321
+ id: string;
1322
+ userId: string;
1323
+ expiresAt: Date;
1324
+ ipAddress?: string | undefined;
1325
+ userAgent?: string | undefined;
1326
+ };
1327
+ redirect: boolean;
1328
+ url: string | undefined;
1329
+ }>;
1330
+ path: "/sign-in/email";
1331
+ options: {
1332
+ method: "POST";
1333
+ body: zod.ZodObject<{
1334
+ email: zod.ZodString;
1335
+ password: zod.ZodString;
1336
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1337
+ dontRememberMe: zod.ZodOptional<zod.ZodDefault<zod.ZodBoolean>>;
1338
+ }, "strip", zod.ZodTypeAny, {
1339
+ password: string;
1340
+ email: string;
1341
+ callbackURL?: string | undefined;
1342
+ dontRememberMe?: boolean | undefined;
1343
+ }, {
1344
+ password: string;
1345
+ email: string;
1346
+ callbackURL?: string | undefined;
1347
+ dontRememberMe?: boolean | undefined;
1348
+ }>;
1349
+ };
1350
+ method: better_call.Method | better_call.Method[];
1351
+ headers: Headers;
1352
+ };
1353
+ forgetPassword: {
1354
+ (ctx_0: better_call.Context<"/forget-password", {
1355
+ method: "POST";
1356
+ body: zod.ZodObject<{
1357
+ email: zod.ZodString;
1358
+ }, "strip", zod.ZodTypeAny, {
1359
+ email: string;
1360
+ }, {
1361
+ email: string;
1362
+ }>;
1363
+ }>): Promise<{
1364
+ error: string;
1365
+ } | {
1366
+ status: boolean;
1367
+ } | null>;
1368
+ path: "/forget-password";
1369
+ options: {
1370
+ method: "POST";
1371
+ body: zod.ZodObject<{
1372
+ email: zod.ZodString;
1373
+ }, "strip", zod.ZodTypeAny, {
1374
+ email: string;
1375
+ }, {
1376
+ email: string;
1377
+ }>;
1378
+ };
1379
+ method: better_call.Method | better_call.Method[];
1380
+ headers: Headers;
1381
+ };
1382
+ resetPassword: {
1383
+ (ctx_0: better_call.Context<"/reset-password", {
1384
+ method: "POST";
1385
+ body: zod.ZodObject<{
1386
+ token: zod.ZodString;
1387
+ newPassword: zod.ZodString;
1388
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1389
+ }, "strip", zod.ZodTypeAny, {
1390
+ token: string;
1391
+ newPassword: string;
1392
+ callbackURL?: string | undefined;
1393
+ }, {
1394
+ token: string;
1395
+ newPassword: string;
1396
+ callbackURL?: string | undefined;
1397
+ }>;
1398
+ }>): Promise<{
1399
+ status: boolean;
1400
+ url: string | undefined;
1401
+ redirect: boolean;
1402
+ } | null>;
1403
+ path: "/reset-password";
1404
+ options: {
1405
+ method: "POST";
1406
+ body: zod.ZodObject<{
1407
+ token: zod.ZodString;
1408
+ newPassword: zod.ZodString;
1409
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1410
+ }, "strip", zod.ZodTypeAny, {
1411
+ token: string;
1412
+ newPassword: string;
1413
+ callbackURL?: string | undefined;
1414
+ }, {
1415
+ token: string;
1416
+ newPassword: string;
1417
+ callbackURL?: string | undefined;
1418
+ }>;
1419
+ };
1420
+ method: better_call.Method | better_call.Method[];
1421
+ headers: Headers;
1422
+ };
1423
+ verifyEmail: {
1424
+ (ctx_0: better_call.Context<"/verify-email", {
1425
+ method: "GET";
1426
+ query: zod.ZodObject<{
1427
+ token: zod.ZodString;
1428
+ callbackURL: zod.ZodString;
1429
+ }, "strip", zod.ZodTypeAny, {
1430
+ token: string;
1431
+ callbackURL: string;
1432
+ }, {
1433
+ token: string;
1434
+ callbackURL: string;
1435
+ }>;
1436
+ }>): Promise<{
1437
+ status: boolean;
1438
+ } | null>;
1439
+ path: "/verify-email";
1440
+ options: {
1441
+ method: "GET";
1442
+ query: zod.ZodObject<{
1443
+ token: zod.ZodString;
1444
+ callbackURL: zod.ZodString;
1445
+ }, "strip", zod.ZodTypeAny, {
1446
+ token: string;
1447
+ callbackURL: string;
1448
+ }, {
1449
+ token: string;
1450
+ callbackURL: string;
1451
+ }>;
1452
+ };
1453
+ method: better_call.Method | better_call.Method[];
1454
+ headers: Headers;
1455
+ };
1456
+ sendVerificationEmail: {
1457
+ (ctx_0: better_call.Context<"/send-verification-email", {
1458
+ method: "POST";
1459
+ body: zod.ZodObject<{
1460
+ email: zod.ZodString;
1461
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1462
+ }, "strip", zod.ZodTypeAny, {
1463
+ email: string;
1464
+ callbackURL?: string | undefined;
1465
+ }, {
1466
+ email: string;
1467
+ callbackURL?: string | undefined;
1468
+ }>;
1469
+ }>): Promise<{
1470
+ status: boolean;
1471
+ } | null>;
1472
+ path: "/send-verification-email";
1473
+ options: {
1474
+ method: "POST";
1475
+ body: zod.ZodObject<{
1476
+ email: zod.ZodString;
1477
+ callbackURL: zod.ZodOptional<zod.ZodString>;
1478
+ }, "strip", zod.ZodTypeAny, {
1479
+ email: string;
1480
+ callbackURL?: string | undefined;
1481
+ }, {
1482
+ email: string;
1483
+ callbackURL?: string | undefined;
1484
+ }>;
1485
+ };
1486
+ method: better_call.Method | better_call.Method[];
1487
+ headers: Headers;
1488
+ };
1489
+ } & UnionToIntersection<O["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? { [key in T["id"]]: T["endpoints"]; } : {} : {}>;
1490
+ options: O;
1491
+ };
1492
+ type Auth = {
1493
+ handler: (request: Request) => Promise<Response>;
1494
+ api: ReturnType<typeof router>["endpoints"];
1495
+ options: BetterAuthOptions;
1496
+ };
1497
+
1498
+ export { type Auth as A, type BetterAuthPlugin as B, type FieldAttribute as F, type GenericEndpointContext as G, type InferFieldOutput as I, type BetterAuthOptions as a, type InferUser as b, type InferSession as c, betterAuth as d, createInternalAdapter as e, type InternalAdapter as f, createFieldAttribute as g, type FieldType as h, type InferValueType as i, type FieldAttributeConfig as j };