better-auth 0.5.3-beta.4 → 0.5.3-beta.5

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.
@@ -1,4 +1,4 @@
1
- import { A as Adapter } from '../auth-CS6UmdXR.js';
1
+ import { A as Adapter } from '../auth-ChOWHZz7.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import '../schema-Dkt0LqYs.js';
@@ -1,5 +1,5 @@
1
1
  import { Kysely } from 'kysely';
2
- import { B as BetterAuthOptions, K as KyselyDatabaseType, F as FieldAttribute, A as Adapter } from '../auth-CS6UmdXR.js';
2
+ import { B as BetterAuthOptions, K as KyselyDatabaseType, F as FieldAttribute, A as Adapter } from '../auth-ChOWHZz7.js';
3
3
  import 'zod';
4
4
  import '../schema-Dkt0LqYs.js';
5
5
  import 'better-call';
@@ -1,5 +1,5 @@
1
1
  import { Db } from 'mongodb';
2
- import { W as Where } from '../auth-CS6UmdXR.js';
2
+ import { W as Where } from '../auth-ChOWHZz7.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import '../schema-Dkt0LqYs.js';
@@ -1,4 +1,4 @@
1
- import { A as Adapter } from '../auth-CS6UmdXR.js';
1
+ import { A as Adapter } from '../auth-ChOWHZz7.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import '../schema-Dkt0LqYs.js';
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { e as AuthEndpoint, f as AuthMiddleware, a1 as callbackOAuth, aj as changeEmail, ag as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, ac as createEmailVerificationToken, ao as csrfMiddleware, ai as deleteUser, al as error, a9 as forgetPassword, aa as forgetPasswordCallback, ak as getCSRFToken, Z as getEndpoints, a2 as getSession, a3 as getSessionFromCtx, a5 as listSessions, am as ok, o as optionsMiddleware, ab as resetPassword, a6 as revokeSession, a7 as revokeSessions, _ as router, ad as sendVerificationEmail, a4 as sessionMiddleware, ah as setPassword, a0 as signInEmail, $ as signInOAuth, a8 as signOut, an as signUpEmail, af as updateUser, ae as verifyEmail } from './auth-CS6UmdXR.js';
1
+ export { e as AuthEndpoint, f as AuthMiddleware, a1 as callbackOAuth, aj as changeEmail, ag as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, ac as createEmailVerificationToken, ao as csrfMiddleware, ai as deleteUser, al as error, a9 as forgetPassword, aa as forgetPasswordCallback, ak as getCSRFToken, Z as getEndpoints, a2 as getSession, a3 as getSessionFromCtx, a5 as listSessions, am as ok, o as optionsMiddleware, ab as resetPassword, a6 as revokeSession, a7 as revokeSessions, _ as router, ad as sendVerificationEmail, a4 as sessionMiddleware, ah as setPassword, a0 as signInEmail, $ as signInOAuth, a8 as signOut, an as signUpEmail, af as updateUser, ae as verifyEmail } from './auth-ChOWHZz7.js';
2
2
  import './helper-DPDj8Nix.js';
3
3
  export { APIError } from 'better-call';
4
4
  import 'zod';
@@ -1,7 +1,7 @@
1
1
  import * as zod from 'zod';
2
- import { ZodSchema, z, ZodOptional, ZodString, ZodObject } from 'zod';
2
+ import { ZodSchema, z, ZodObject, ZodOptional, ZodString } from 'zod';
3
3
  import { Kysely, Migration, PostgresPool, Dialect } from 'kysely';
4
- import { U as User, S as Session, A as Account, V as Verification } from './schema-Dkt0LqYs.js';
4
+ import { U as User, A as Account, S as Session, V as Verification } from './schema-Dkt0LqYs.js';
5
5
  import * as better_call from 'better-call';
6
6
  import { ContextTools, CookieOptions, Endpoint, EndpointResponse, Context, Prettify as Prettify$1 } from 'better-call';
7
7
  import { a as OAuthProvider } from './types-Xr2tzd3r.js';
@@ -38,6 +38,329 @@ type zodKey<T> = isAny<T> extends true ? "any" : equals<T, boolean> extends true
38
38
  [k: string]: any;
39
39
  } ? "object" : "rest";
40
40
 
41
+ /**
42
+ * Adapter where clause
43
+ */
44
+ type Where = {
45
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "contains" | "starts_with" | "ends_with";
46
+ value: string | number | boolean | string[] | number[];
47
+ field: string;
48
+ connector?: "AND" | "OR";
49
+ };
50
+ /**
51
+ * Adapter Interface
52
+ */
53
+ interface Adapter {
54
+ id: string;
55
+ create: <T extends {
56
+ id?: string;
57
+ } & Record<string, any>, R = T>(data: {
58
+ model: string;
59
+ data: T;
60
+ select?: string[];
61
+ }) => Promise<R>;
62
+ findOne: <T>(data: {
63
+ model: string;
64
+ where: Where[];
65
+ select?: string[];
66
+ }) => Promise<T | null>;
67
+ findMany: <T>(data: {
68
+ model: string;
69
+ where?: Where[];
70
+ limit?: number;
71
+ sortBy?: {
72
+ field: string;
73
+ direction: "asc" | "desc";
74
+ };
75
+ offset?: number;
76
+ }) => Promise<T[]>;
77
+ /**
78
+ * ⚠︎ Update may not return the updated data
79
+ * if multiple where clauses are provided
80
+ */
81
+ update: <T>(data: {
82
+ model: string;
83
+ where: Where[];
84
+ update: Record<string, any>;
85
+ }) => Promise<T | null>;
86
+ delete: <T>(data: {
87
+ model: string;
88
+ where: Where[];
89
+ }) => Promise<void>;
90
+ deleteMany: (data: {
91
+ model: string;
92
+ where: Where[];
93
+ }) => Promise<void>;
94
+ /**
95
+ *
96
+ * @param options
97
+ * @param file - file path if provided by the user
98
+ * @returns
99
+ */
100
+ createSchema?: (options: BetterAuthOptions, file?: string) => Promise<{
101
+ code: string;
102
+ fileName: string;
103
+ append?: boolean;
104
+ overwrite?: boolean;
105
+ }>;
106
+ options?: Record<string, any>;
107
+ }
108
+ interface SecondaryStorage {
109
+ get: (key: string) => Promise<string | null> | string | null;
110
+ set: (key: string, value: string, ttl?: number) => Promise<void | null | string> | void;
111
+ delete: (key: string) => Promise<void | null | string> | void;
112
+ }
113
+
114
+ declare const createInternalAdapter: (adapter: Adapter, ctx: {
115
+ options: BetterAuthOptions;
116
+ hooks: Exclude<BetterAuthOptions["databaseHooks"], undefined>[];
117
+ }) => {
118
+ createOAuthUser: (user: Omit<User, "id" | "createdAt" | "updatedAt"> & Partial<User>, account: Omit<Account, "userId" | "id"> & Partial<Account>) => Promise<{
119
+ user: any;
120
+ account: any;
121
+ } | null>;
122
+ createUser: <T>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>) => Promise<T & {
123
+ id: string;
124
+ email: string;
125
+ emailVerified: boolean;
126
+ name: string;
127
+ createdAt: Date;
128
+ updatedAt: Date;
129
+ image?: string | undefined;
130
+ }>;
131
+ createAccount: <T>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & Record<string, any>) => Promise<T & {
132
+ id: string;
133
+ providerId: string;
134
+ accountId: string;
135
+ userId: string;
136
+ accessToken?: string | null | undefined;
137
+ refreshToken?: string | null | undefined;
138
+ idToken?: string | null | undefined;
139
+ expiresAt?: Date | null | undefined;
140
+ password?: string | null | undefined;
141
+ }>;
142
+ listSessions: (userId: string) => Promise<{
143
+ id: string;
144
+ userId: string;
145
+ expiresAt: Date;
146
+ ipAddress?: string | undefined;
147
+ userAgent?: string | undefined;
148
+ }[]>;
149
+ listUsers: (limit?: number, offset?: number, sortBy?: {
150
+ field: string;
151
+ direction: "asc" | "desc";
152
+ }, where?: Where[]) => Promise<({
153
+ id: string;
154
+ email: string;
155
+ emailVerified: boolean;
156
+ name: string;
157
+ createdAt: Date;
158
+ updatedAt: Date;
159
+ image?: string | undefined;
160
+ } | null)[]>;
161
+ deleteUser: (userId: string) => Promise<void>;
162
+ createSession: (userId: string, request?: Request | Headers, dontRememberMe?: boolean, override?: Partial<Session> & Record<string, any>) => Promise<any>;
163
+ findSession: (sessionId: string) => Promise<{
164
+ session: Session;
165
+ user: User;
166
+ } | null>;
167
+ findSessions: (sessionIds: string[]) => Promise<{
168
+ session: Session;
169
+ user: User;
170
+ }[]>;
171
+ updateSession: (sessionId: string, session: Partial<Session>) => Promise<any>;
172
+ deleteSession: (id: string) => Promise<void>;
173
+ deleteSessions: (userId: string) => Promise<void>;
174
+ findUserByEmail: (email: string, options?: {
175
+ includeAccounts: boolean;
176
+ }) => Promise<{
177
+ user: {
178
+ id: string;
179
+ email: string;
180
+ emailVerified: boolean;
181
+ name: string;
182
+ createdAt: Date;
183
+ updatedAt: Date;
184
+ image?: string | undefined;
185
+ };
186
+ accounts: {
187
+ id: string;
188
+ providerId: string;
189
+ accountId: string;
190
+ userId: string;
191
+ accessToken?: string | null | undefined;
192
+ refreshToken?: string | null | undefined;
193
+ idToken?: string | null | undefined;
194
+ expiresAt?: Date | null | undefined;
195
+ password?: string | null | undefined;
196
+ }[];
197
+ } | null>;
198
+ findUserById: (userId: string) => Promise<{
199
+ id: string;
200
+ email: string;
201
+ emailVerified: boolean;
202
+ name: string;
203
+ createdAt: Date;
204
+ updatedAt: Date;
205
+ image?: string | undefined;
206
+ } | null>;
207
+ linkAccount: (account: Omit<Account, "id"> & Partial<Account>) => Promise<any>;
208
+ updateUser: (userId: string, data: Partial<User> & Record<string, any>) => Promise<any>;
209
+ updateUserByEmail: (email: string, data: Partial<User & Record<string, any>>) => Promise<any>;
210
+ updatePassword: (userId: string, password: string) => Promise<any>;
211
+ findAccounts: (userId: string) => Promise<{
212
+ id: string;
213
+ providerId: string;
214
+ accountId: string;
215
+ userId: string;
216
+ accessToken?: string | null | undefined;
217
+ refreshToken?: string | null | undefined;
218
+ idToken?: string | null | undefined;
219
+ expiresAt?: Date | null | undefined;
220
+ password?: string | null | undefined;
221
+ }[]>;
222
+ updateAccount: (accountId: string, data: Partial<Account>) => Promise<any>;
223
+ createVerificationValue: (data: Omit<Verification, "id">) => Promise<any>;
224
+ findVerificationValue: (identifier: string) => Promise<{
225
+ id: string;
226
+ expiresAt: Date;
227
+ value: string;
228
+ identifier: string;
229
+ } | null>;
230
+ deleteVerificationValue: (id: string) => Promise<void>;
231
+ updateVerificationValue: (id: string, data: Partial<Verification>) => Promise<any>;
232
+ };
233
+ type InternalAdapter = ReturnType<typeof createInternalAdapter>;
234
+
235
+ type FieldType = "string" | "number" | "boolean" | "date" | `${"string" | "number"}[]`;
236
+ type FieldAttributeConfig<T extends FieldType = FieldType> = {
237
+ /**
238
+ * If the field should be required on a new record.
239
+ * @default false
240
+ */
241
+ required?: boolean;
242
+ /**
243
+ * If the value should be returned on a response body.
244
+ * @default true
245
+ */
246
+ returned?: boolean;
247
+ /**
248
+ * If a value should be provided when creating a new record.
249
+ * @default true
250
+ */
251
+ input?: boolean;
252
+ /**
253
+ * If the value should be hashed when it's stored.
254
+ * @default false
255
+ */
256
+ hashValue?: boolean;
257
+ /**
258
+ * Default value for the field
259
+ *
260
+ * Note: This will not create a default value on the database level. It will only
261
+ * be used when creating a new record.
262
+ */
263
+ defaultValue?: any;
264
+ /**
265
+ * transform the value before storing it.
266
+ */
267
+ transform?: (value: InferValueType<T>) => InferValueType<T>;
268
+ /**
269
+ * Reference to another model.
270
+ */
271
+ references?: {
272
+ /**
273
+ * The model to reference.
274
+ */
275
+ model: string;
276
+ /**
277
+ * The field on the referenced model.
278
+ */
279
+ field: string;
280
+ /**
281
+ * The action to perform when the reference is deleted.
282
+ * @default "cascade"
283
+ */
284
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
285
+ };
286
+ unique?: boolean;
287
+ /**
288
+ * A zod schema to validate the value.
289
+ */
290
+ validator?: ZodSchema;
291
+ /**
292
+ * The name of the field on the database.
293
+ *
294
+ * @default
295
+ * ```txt
296
+ * the key in the fields object.
297
+ * ```
298
+ */
299
+ fieldName?: string;
300
+ };
301
+ type FieldAttribute<T extends FieldType = FieldType> = {
302
+ type: T;
303
+ } & FieldAttributeConfig<T>;
304
+ declare const createFieldAttribute: <T extends FieldType, C extends Omit<FieldAttributeConfig<T>, "type">>(type: T, config?: C) => {
305
+ transform?: ((value: InferValueType<T>) => InferValueType<T>) | undefined;
306
+ required?: boolean;
307
+ returned?: boolean;
308
+ input?: boolean;
309
+ hashValue?: boolean;
310
+ defaultValue?: any;
311
+ references?: {
312
+ /**
313
+ * The model to reference.
314
+ */
315
+ model: string;
316
+ /**
317
+ * The field on the referenced model.
318
+ */
319
+ field: string;
320
+ /**
321
+ * The action to perform when the reference is deleted.
322
+ * @default "cascade"
323
+ */
324
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
325
+ };
326
+ unique?: boolean;
327
+ validator?: ZodSchema;
328
+ fieldName?: string;
329
+ type: T;
330
+ };
331
+ type InferValueType<T extends FieldType> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends `${infer T}[]` ? T extends "string" ? string[] : number[] : never;
332
+ type InferFieldsOutput<Field> = Field extends Record<infer Key, FieldAttribute> ? {
333
+ [key in Key as Field[key]["required"] extends false ? Field[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Field[key]>;
334
+ } & {
335
+ [key in Key as Field[key]["returned"] extends false ? never : key]?: InferFieldOutput<Field[key]>;
336
+ } : {};
337
+ type InferFieldsInput<Field> = Field extends Record<infer Key, FieldAttribute> ? {
338
+ [key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : key]: InferFieldInput<Field[key]>;
339
+ } & {
340
+ [key in Key as Field[key]["input"] extends false ? never : key]: InferFieldInput<Field[key]> | undefined;
341
+ } : {};
342
+ /**
343
+ * For client will add "?" on optional fields
344
+ */
345
+ type InferFieldsInputClient<Field> = Field extends Record<infer Key, FieldAttribute> ? {
346
+ [key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : key]: InferFieldInput<Field[key]>;
347
+ } & {
348
+ [key in Key]?: InferFieldInput<Field[key]> | undefined;
349
+ } : {};
350
+ type InferFieldOutput<T extends FieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferValueType<T["type"]> | undefined : InferValueType<T["type"]>;
351
+ type InferFieldInput<T extends FieldAttribute> = InferValueType<T["type"]>;
352
+ type PluginFieldAttribute = Omit<FieldAttribute, "transform" | "defaultValue" | "hashValue">;
353
+ type InferFieldsFromPlugins<Options extends BetterAuthOptions, Key extends string, Format extends "output" | "input" = "output"> = Options["plugins"] extends Array<infer T> ? T extends {
354
+ schema: {
355
+ [key in Key]: {
356
+ fields: infer Field;
357
+ };
358
+ };
359
+ } ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {} : {};
360
+ type InferFieldsFromOptions<Options extends BetterAuthOptions, Key extends "session" | "user", Format extends "output" | "input" = "output"> = Options[Key] extends {
361
+ additionalFields: infer Field;
362
+ } ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {};
363
+
41
364
  type BetterAuthDbSchema = Record<string, {
42
365
  /**
43
366
  * The name of the table in the database
@@ -59,6 +382,8 @@ type BetterAuthDbSchema = Record<string, {
59
382
  }>;
60
383
  declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDbSchema;
61
384
 
385
+ type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
386
+
62
387
  type HookEndpointContext<C extends Record<string, any> = {}> = ContextTools & {
63
388
  context: AuthContext & C;
64
389
  } & {
@@ -290,147 +615,18 @@ declare const createAuthEndpoint: <Path extends string, Opts extends better_call
290
615
  body: infer B;
291
616
  } ? B : null : Awaited<R>>;
292
617
  path: Path;
293
- options: Opts;
294
- method: better_call.Method | better_call.Method[];
295
- headers: Headers;
296
- };
297
- type AuthEndpoint = Endpoint<(ctx: {
298
- options: BetterAuthOptions;
299
- body: any;
300
- query: any;
301
- params: any;
302
- headers: Headers;
303
- }) => Promise<EndpointResponse>>;
304
- type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
305
-
306
- type FieldType = "string" | "number" | "boolean" | "date" | `${"string" | "number"}[]`;
307
- type FieldAttributeConfig<T extends FieldType = FieldType> = {
308
- /**
309
- * If the field should be required on a new record.
310
- * @default false
311
- */
312
- required?: boolean;
313
- /**
314
- * If the value should be returned on a response body.
315
- * @default true
316
- */
317
- returned?: boolean;
318
- /**
319
- * If a value should be provided when creating a new record.
320
- * @default true
321
- */
322
- input?: boolean;
323
- /**
324
- * If the value should be hashed when it's stored.
325
- * @default false
326
- */
327
- hashValue?: boolean;
328
- /**
329
- * Default value for the field
330
- *
331
- * Note: This will not create a default value on the database level. It will only
332
- * be used when creating a new record.
333
- */
334
- defaultValue?: any;
335
- /**
336
- * transform the value before storing it.
337
- */
338
- transform?: (value: InferValueType<T>) => InferValueType<T>;
339
- /**
340
- * Reference to another model.
341
- */
342
- references?: {
343
- /**
344
- * The model to reference.
345
- */
346
- model: string;
347
- /**
348
- * The field on the referenced model.
349
- */
350
- field: string;
351
- /**
352
- * The action to perform when the reference is deleted.
353
- * @default "cascade"
354
- */
355
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
356
- };
357
- unique?: boolean;
358
- /**
359
- * A zod schema to validate the value.
360
- */
361
- validator?: ZodSchema;
362
- /**
363
- * The name of the field on the database.
364
- *
365
- * @default
366
- * ```txt
367
- * the key in the fields object.
368
- * ```
369
- */
370
- fieldName?: string;
371
- };
372
- type FieldAttribute<T extends FieldType = FieldType> = {
373
- type: T;
374
- } & FieldAttributeConfig<T>;
375
- declare const createFieldAttribute: <T extends FieldType, C extends Omit<FieldAttributeConfig<T>, "type">>(type: T, config?: C) => {
376
- transform?: ((value: InferValueType<T>) => InferValueType<T>) | undefined;
377
- required?: boolean;
378
- returned?: boolean;
379
- input?: boolean;
380
- hashValue?: boolean;
381
- defaultValue?: any;
382
- references?: {
383
- /**
384
- * The model to reference.
385
- */
386
- model: string;
387
- /**
388
- * The field on the referenced model.
389
- */
390
- field: string;
391
- /**
392
- * The action to perform when the reference is deleted.
393
- * @default "cascade"
394
- */
395
- onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
396
- };
397
- unique?: boolean;
398
- validator?: ZodSchema;
399
- fieldName?: string;
400
- type: T;
401
- };
402
- type InferValueType<T extends FieldType> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends `${infer T}[]` ? T extends "string" ? string[] : number[] : never;
403
- type InferFieldsOutput<Field> = Field extends Record<infer Key, FieldAttribute> ? {
404
- [key in Key as Field[key]["required"] extends false ? Field[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Field[key]>;
405
- } & {
406
- [key in Key as Field[key]["returned"] extends false ? never : key]?: InferFieldOutput<Field[key]>;
407
- } : {};
408
- type InferFieldsInput<Field> = Field extends Record<infer Key, FieldAttribute> ? {
409
- [key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : key]: InferFieldInput<Field[key]>;
410
- } & {
411
- [key in Key as Field[key]["input"] extends false ? never : key]: InferFieldInput<Field[key]> | undefined;
412
- } : {};
413
- /**
414
- * For client will add "?" on optional fields
415
- */
416
- type InferFieldsInputClient<Field> = Field extends Record<infer Key, FieldAttribute> ? {
417
- [key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : key]: InferFieldInput<Field[key]>;
418
- } & {
419
- [key in Key]?: InferFieldInput<Field[key]> | undefined;
420
- } : {};
421
- type InferFieldOutput<T extends FieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferValueType<T["type"]> | undefined : InferValueType<T["type"]>;
422
- type InferFieldInput<T extends FieldAttribute> = InferValueType<T["type"]>;
423
- type PluginFieldAttribute = Omit<FieldAttribute, "transform" | "defaultValue" | "hashValue">;
424
- type InferFieldsFromPlugins<Options extends BetterAuthOptions, Key extends string, Format extends "output" | "input" = "output"> = Options["plugins"] extends Array<infer T> ? T extends {
425
- schema: {
426
- [key in Key]: {
427
- fields: infer Field;
428
- };
429
- };
430
- } ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {} : {};
431
- type InferFieldsFromOptions<Options extends BetterAuthOptions, Key extends "session" | "user", Format extends "output" | "input" = "output"> = Options[Key] extends {
432
- additionalFields: infer Field;
433
- } ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {};
618
+ options: Opts;
619
+ method: better_call.Method | better_call.Method[];
620
+ headers: Headers;
621
+ };
622
+ type AuthEndpoint = Endpoint<(ctx: {
623
+ options: BetterAuthOptions;
624
+ body: any;
625
+ query: any;
626
+ params: any;
627
+ headers: Headers;
628
+ }) => Promise<EndpointResponse>>;
629
+ type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
434
630
 
435
631
  type PluginSchema = {
436
632
  [table in string]: {
@@ -533,85 +729,10 @@ type BetterAuthPlugin = {
533
729
  }[];
534
730
  };
535
731
 
536
- /**
537
- * Adapter where clause
538
- */
539
- type Where = {
540
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "contains" | "starts_with" | "ends_with";
541
- value: string | number | boolean | string[] | number[];
542
- field: string;
543
- connector?: "AND" | "OR";
544
- };
545
- /**
546
- * Adapter Interface
547
- */
548
- interface Adapter {
549
- id: string;
550
- create: <T extends {
551
- id?: string;
552
- } & Record<string, any>, R = T>(data: {
553
- model: string;
554
- data: T;
555
- select?: string[];
556
- }) => Promise<R>;
557
- findOne: <T>(data: {
558
- model: string;
559
- where: Where[];
560
- select?: string[];
561
- }) => Promise<T | null>;
562
- findMany: <T>(data: {
563
- model: string;
564
- where?: Where[];
565
- limit?: number;
566
- sortBy?: {
567
- field: string;
568
- direction: "asc" | "desc";
569
- };
570
- offset?: number;
571
- }) => Promise<T[]>;
572
- /**
573
- * ⚠︎ Update may not return the updated data
574
- * if multiple where clauses are provided
575
- */
576
- update: <T>(data: {
577
- model: string;
578
- where: Where[];
579
- update: Record<string, any>;
580
- }) => Promise<T | null>;
581
- delete: <T>(data: {
582
- model: string;
583
- where: Where[];
584
- }) => Promise<void>;
585
- deleteMany: (data: {
586
- model: string;
587
- where: Where[];
588
- }) => Promise<void>;
589
- /**
590
- *
591
- * @param options
592
- * @param file - file path if provided by the user
593
- * @returns
594
- */
595
- createSchema?: (options: BetterAuthOptions, file?: string) => Promise<{
596
- code: string;
597
- fileName: string;
598
- append?: boolean;
599
- overwrite?: boolean;
600
- }>;
601
- options?: Record<string, any>;
602
- }
603
- interface SecondaryStorage {
604
- get: (key: string) => Promise<string | null> | string | null;
605
- set: (key: string, value: string, ttl?: number) => Promise<void | null | string> | void;
606
- delete: (key: string) => Promise<void | null | string> | void;
607
- }
608
-
609
732
  type BetterSqlite3Database = Database.Database;
610
733
  type MysqlPool = Pool;
611
734
 
612
- type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
613
-
614
- type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferFieldsFromOptions<Options, "user", "input">;
735
+ type AdditionalUserFieldsInput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "user", "input"> & InferFieldsFromOptions<Options, "user", "input">;
615
736
  type AdditionalUserFieldsOutput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "user"> & InferFieldsFromOptions<Options, "user">;
616
737
  type AdditionalSessionFieldsInput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "session", "input"> & InferFieldsFromOptions<Options, "session", "input">;
617
738
  type AdditionalSessionFieldsOutput<Options extends BetterAuthOptions> = InferFieldsFromPlugins<Options, "session"> & InferFieldsFromOptions<Options, "session">;
@@ -1107,127 +1228,6 @@ interface BetterAuthOptions {
1107
1228
  };
1108
1229
  }
1109
1230
 
1110
- declare const createInternalAdapter: (adapter: Adapter, ctx: {
1111
- options: BetterAuthOptions;
1112
- hooks: Exclude<BetterAuthOptions["databaseHooks"], undefined>[];
1113
- }) => {
1114
- createOAuthUser: (user: Omit<User, "id" | "createdAt" | "updatedAt"> & Partial<User>, account: Omit<Account, "userId" | "id"> & Partial<Account>) => Promise<{
1115
- user: any;
1116
- account: any;
1117
- } | null>;
1118
- createUser: <T>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>) => Promise<T & {
1119
- id: string;
1120
- email: string;
1121
- emailVerified: boolean;
1122
- name: string;
1123
- createdAt: Date;
1124
- updatedAt: Date;
1125
- image?: string | undefined;
1126
- }>;
1127
- createAccount: <T>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & Record<string, any>) => Promise<T & {
1128
- id: string;
1129
- providerId: string;
1130
- accountId: string;
1131
- userId: string;
1132
- accessToken?: string | null | undefined;
1133
- refreshToken?: string | null | undefined;
1134
- idToken?: string | null | undefined;
1135
- expiresAt?: Date | null | undefined;
1136
- password?: string | null | undefined;
1137
- }>;
1138
- listSessions: (userId: string) => Promise<{
1139
- id: string;
1140
- userId: string;
1141
- expiresAt: Date;
1142
- ipAddress?: string | undefined;
1143
- userAgent?: string | undefined;
1144
- }[]>;
1145
- listUsers: (limit?: number, offset?: number, sortBy?: {
1146
- field: string;
1147
- direction: "asc" | "desc";
1148
- }, where?: Where[]) => Promise<({
1149
- id: string;
1150
- email: string;
1151
- emailVerified: boolean;
1152
- name: string;
1153
- createdAt: Date;
1154
- updatedAt: Date;
1155
- image?: string | undefined;
1156
- } | null)[]>;
1157
- deleteUser: (userId: string) => Promise<void>;
1158
- createSession: (userId: string, request?: Request | Headers, dontRememberMe?: boolean, override?: Partial<Session> & Record<string, any>) => Promise<any>;
1159
- findSession: (sessionId: string) => Promise<{
1160
- session: Session;
1161
- user: User;
1162
- } | null>;
1163
- findSessions: (sessionIds: string[]) => Promise<{
1164
- session: Session;
1165
- user: User;
1166
- }[]>;
1167
- updateSession: (sessionId: string, session: Partial<Session>) => Promise<any>;
1168
- deleteSession: (id: string) => Promise<void>;
1169
- deleteSessions: (userId: string) => Promise<void>;
1170
- findUserByEmail: (email: string, options?: {
1171
- includeAccounts: boolean;
1172
- }) => Promise<{
1173
- user: {
1174
- id: string;
1175
- email: string;
1176
- emailVerified: boolean;
1177
- name: string;
1178
- createdAt: Date;
1179
- updatedAt: Date;
1180
- image?: string | undefined;
1181
- };
1182
- accounts: {
1183
- id: string;
1184
- providerId: string;
1185
- accountId: string;
1186
- userId: string;
1187
- accessToken?: string | null | undefined;
1188
- refreshToken?: string | null | undefined;
1189
- idToken?: string | null | undefined;
1190
- expiresAt?: Date | null | undefined;
1191
- password?: string | null | undefined;
1192
- }[];
1193
- } | null>;
1194
- findUserById: (userId: string) => Promise<{
1195
- id: string;
1196
- email: string;
1197
- emailVerified: boolean;
1198
- name: string;
1199
- createdAt: Date;
1200
- updatedAt: Date;
1201
- image?: string | undefined;
1202
- } | null>;
1203
- linkAccount: (account: Omit<Account, "id"> & Partial<Account>) => Promise<any>;
1204
- updateUser: (userId: string, data: Partial<User> & Record<string, any>) => Promise<any>;
1205
- updateUserByEmail: (email: string, data: Partial<User & Record<string, any>>) => Promise<any>;
1206
- updatePassword: (userId: string, password: string) => Promise<any>;
1207
- findAccounts: (userId: string) => Promise<{
1208
- id: string;
1209
- providerId: string;
1210
- accountId: string;
1211
- userId: string;
1212
- accessToken?: string | null | undefined;
1213
- refreshToken?: string | null | undefined;
1214
- idToken?: string | null | undefined;
1215
- expiresAt?: Date | null | undefined;
1216
- password?: string | null | undefined;
1217
- }[]>;
1218
- updateAccount: (accountId: string, data: Partial<Account>) => Promise<any>;
1219
- createVerificationValue: (data: Omit<Verification, "id">) => Promise<any>;
1220
- findVerificationValue: (identifier: string) => Promise<{
1221
- id: string;
1222
- expiresAt: Date;
1223
- value: string;
1224
- identifier: string;
1225
- } | null>;
1226
- deleteVerificationValue: (id: string) => Promise<void>;
1227
- updateVerificationValue: (id: string, data: Partial<Verification>) => Promise<any>;
1228
- };
1229
- type InternalAdapter = ReturnType<typeof createInternalAdapter>;
1230
-
1231
1231
  declare const signInOAuth: {
1232
1232
  <C extends [better_call.Context<"/sign-in/social", {
1233
1233
  method: "POST";
@@ -1925,15 +1925,9 @@ declare const verifyEmail: {
1925
1925
  declare const updateUser: <O extends BetterAuthOptions>() => {
1926
1926
  <C extends HasRequiredKeys<better_call.Context<"/user/update", {
1927
1927
  method: "POST";
1928
- body: z.ZodObject<{
1928
+ body: ZodObject<{
1929
1929
  name: ZodOptional<ZodString>;
1930
1930
  image: ZodOptional<ZodString>;
1931
- }, z.UnknownKeysParam, z.ZodTypeAny, {
1932
- name?: string | undefined;
1933
- image?: string | undefined;
1934
- }, {
1935
- name?: string | undefined;
1936
- image?: string | undefined;
1937
1931
  }> & toZod<AdditionalUserFieldsInput<O>>;
1938
1932
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1939
1933
  session: {
@@ -1957,15 +1951,9 @@ declare const updateUser: <O extends BetterAuthOptions>() => {
1957
1951
  }>, better_call.EndpointOptions>)[];
1958
1952
  }>> extends true ? [better_call.Context<"/user/update", {
1959
1953
  method: "POST";
1960
- body: z.ZodObject<{
1954
+ body: ZodObject<{
1961
1955
  name: ZodOptional<ZodString>;
1962
1956
  image: ZodOptional<ZodString>;
1963
- }, z.UnknownKeysParam, z.ZodTypeAny, {
1964
- name?: string | undefined;
1965
- image?: string | undefined;
1966
- }, {
1967
- name?: string | undefined;
1968
- image?: string | undefined;
1969
1957
  }> & toZod<AdditionalUserFieldsInput<O>>;
1970
1958
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
1971
1959
  session: {
@@ -1989,15 +1977,9 @@ declare const updateUser: <O extends BetterAuthOptions>() => {
1989
1977
  }>, better_call.EndpointOptions>)[];
1990
1978
  }>] : [(better_call.Context<"/user/update", {
1991
1979
  method: "POST";
1992
- body: z.ZodObject<{
1980
+ body: ZodObject<{
1993
1981
  name: ZodOptional<ZodString>;
1994
1982
  image: ZodOptional<ZodString>;
1995
- }, z.UnknownKeysParam, z.ZodTypeAny, {
1996
- name?: string | undefined;
1997
- image?: string | undefined;
1998
- }, {
1999
- name?: string | undefined;
2000
- image?: string | undefined;
2001
1983
  }> & toZod<AdditionalUserFieldsInput<O>>;
2002
1984
  use: (better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
2003
1985
  session: {
@@ -2475,21 +2457,11 @@ declare const signUpEmail: <O extends BetterAuthOptions>() => {
2475
2457
  }, {
2476
2458
  currentURL?: string | undefined;
2477
2459
  }>>;
2478
- body: z.ZodObject<{
2460
+ body: ZodObject<{
2479
2461
  name: ZodString;
2480
2462
  email: ZodString;
2481
2463
  password: ZodString;
2482
2464
  callbackURL: ZodOptional<ZodString>;
2483
- }, z.UnknownKeysParam, z.ZodTypeAny, {
2484
- password: string;
2485
- email: string;
2486
- name: string;
2487
- callbackURL?: string | undefined;
2488
- }, {
2489
- password: string;
2490
- email: string;
2491
- name: string;
2492
- callbackURL?: string | undefined;
2493
2465
  }> & toZod<AdditionalUserFieldsInput<O>>;
2494
2466
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2495
2467
  }>> extends true ? [better_call.Context<"/sign-up/email", {
@@ -2501,21 +2473,11 @@ declare const signUpEmail: <O extends BetterAuthOptions>() => {
2501
2473
  }, {
2502
2474
  currentURL?: string | undefined;
2503
2475
  }>>;
2504
- body: z.ZodObject<{
2476
+ body: ZodObject<{
2505
2477
  name: ZodString;
2506
2478
  email: ZodString;
2507
2479
  password: ZodString;
2508
2480
  callbackURL: ZodOptional<ZodString>;
2509
- }, z.UnknownKeysParam, z.ZodTypeAny, {
2510
- password: string;
2511
- email: string;
2512
- name: string;
2513
- callbackURL?: string | undefined;
2514
- }, {
2515
- password: string;
2516
- email: string;
2517
- name: string;
2518
- callbackURL?: string | undefined;
2519
2481
  }> & toZod<AdditionalUserFieldsInput<O>>;
2520
2482
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2521
2483
  }>] : [(better_call.Context<"/sign-up/email", {
@@ -2527,21 +2489,11 @@ declare const signUpEmail: <O extends BetterAuthOptions>() => {
2527
2489
  }, {
2528
2490
  currentURL?: string | undefined;
2529
2491
  }>>;
2530
- body: z.ZodObject<{
2492
+ body: ZodObject<{
2531
2493
  name: ZodString;
2532
2494
  email: ZodString;
2533
2495
  password: ZodString;
2534
2496
  callbackURL: ZodOptional<ZodString>;
2535
- }, z.UnknownKeysParam, z.ZodTypeAny, {
2536
- password: string;
2537
- email: string;
2538
- name: string;
2539
- callbackURL?: string | undefined;
2540
- }, {
2541
- password: string;
2542
- email: string;
2543
- name: string;
2544
- callbackURL?: string | undefined;
2545
2497
  }> & toZod<AdditionalUserFieldsInput<O>>;
2546
2498
  use: better_call.Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2547
2499
  }> | undefined)?]>(...ctx: C): Promise<C extends [{
@@ -2841,7 +2793,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2841
2793
  email: string;
2842
2794
  name: string;
2843
2795
  callbackURL?: string | undefined;
2844
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
2796
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
2845
2797
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2846
2798
  }>> extends true ? [better_call.Context<"/sign-up/email", {
2847
2799
  method: "POST";
@@ -2867,7 +2819,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2867
2819
  email: string;
2868
2820
  name: string;
2869
2821
  callbackURL?: string | undefined;
2870
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
2822
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
2871
2823
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2872
2824
  }>] : [(better_call.Context<"/sign-up/email", {
2873
2825
  method: "POST";
@@ -2893,7 +2845,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2893
2845
  email: string;
2894
2846
  name: string;
2895
2847
  callbackURL?: string | undefined;
2896
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
2848
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
2897
2849
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2898
2850
  }> | undefined)?]>(...ctx: C_1): Promise<C_1 extends [{
2899
2851
  asResponse: true;
@@ -2934,7 +2886,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2934
2886
  email: string;
2935
2887
  name: string;
2936
2888
  callbackURL?: string | undefined;
2937
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
2889
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
2938
2890
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
2939
2891
  };
2940
2892
  method: better_call.Method | better_call.Method[];
@@ -3439,7 +3391,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3439
3391
  }, {
3440
3392
  name?: string | undefined;
3441
3393
  image?: string | undefined;
3442
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
3394
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
3443
3395
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3444
3396
  session: {
3445
3397
  session: {
@@ -3471,7 +3423,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3471
3423
  }, {
3472
3424
  name?: string | undefined;
3473
3425
  image?: string | undefined;
3474
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
3426
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
3475
3427
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3476
3428
  session: {
3477
3429
  session: {
@@ -3503,7 +3455,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3503
3455
  }, {
3504
3456
  name?: string | undefined;
3505
3457
  image?: string | undefined;
3506
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
3458
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
3507
3459
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3508
3460
  session: {
3509
3461
  session: {
@@ -3541,7 +3493,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3541
3493
  }, {
3542
3494
  name?: string | undefined;
3543
3495
  image?: string | undefined;
3544
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
3496
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
3545
3497
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
3546
3498
  session: {
3547
3499
  session: {
@@ -4099,7 +4051,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4099
4051
  email: string;
4100
4052
  name: string;
4101
4053
  callbackURL?: string | undefined;
4102
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4054
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4103
4055
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
4104
4056
  }>> extends true ? [better_call.Context<"/sign-up/email", {
4105
4057
  method: "POST";
@@ -4125,7 +4077,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4125
4077
  email: string;
4126
4078
  name: string;
4127
4079
  callbackURL?: string | undefined;
4128
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4080
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4129
4081
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
4130
4082
  }>] : [(better_call.Context<"/sign-up/email", {
4131
4083
  method: "POST";
@@ -4151,7 +4103,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4151
4103
  email: string;
4152
4104
  name: string;
4153
4105
  callbackURL?: string | undefined;
4154
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4106
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4155
4107
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
4156
4108
  }> | undefined)?]>(...ctx: C_1): Promise<C_1 extends [{
4157
4109
  asResponse: true;
@@ -4192,7 +4144,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4192
4144
  email: string;
4193
4145
  name: string;
4194
4146
  callbackURL?: string | undefined;
4195
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4147
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4196
4148
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
4197
4149
  };
4198
4150
  method: better_call.Method | better_call.Method[];
@@ -4697,7 +4649,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4697
4649
  }, {
4698
4650
  name?: string | undefined;
4699
4651
  image?: string | undefined;
4700
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4652
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4701
4653
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
4702
4654
  session: {
4703
4655
  session: {
@@ -4729,7 +4681,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4729
4681
  }, {
4730
4682
  name?: string | undefined;
4731
4683
  image?: string | undefined;
4732
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4684
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4733
4685
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
4734
4686
  session: {
4735
4687
  session: {
@@ -4761,7 +4713,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4761
4713
  }, {
4762
4714
  name?: string | undefined;
4763
4715
  image?: string | undefined;
4764
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4716
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4765
4717
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
4766
4718
  session: {
4767
4719
  session: {
@@ -4799,7 +4751,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4799
4751
  }, {
4800
4752
  name?: string | undefined;
4801
4753
  image?: string | undefined;
4802
- }> & toZod<InferFieldsFromOptions<Option, "user", "input">>;
4754
+ }> & toZod<AdditionalUserFieldsInput<Option>>;
4803
4755
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
4804
4756
  session: {
4805
4757
  session: {
@@ -5359,7 +5311,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5359
5311
  email: string;
5360
5312
  name: string;
5361
5313
  callbackURL?: string | undefined;
5362
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5314
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5363
5315
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
5364
5316
  }>> extends true ? [better_call.Context<"/sign-up/email", {
5365
5317
  method: "POST";
@@ -5385,7 +5337,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5385
5337
  email: string;
5386
5338
  name: string;
5387
5339
  callbackURL?: string | undefined;
5388
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5340
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5389
5341
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
5390
5342
  }>] : [(better_call.Context<"/sign-up/email", {
5391
5343
  method: "POST";
@@ -5411,7 +5363,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5411
5363
  email: string;
5412
5364
  name: string;
5413
5365
  callbackURL?: string | undefined;
5414
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5366
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5415
5367
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
5416
5368
  }> | undefined)?]>(...ctx: C): Promise<C extends [{
5417
5369
  asResponse: true;
@@ -5452,7 +5404,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5452
5404
  email: string;
5453
5405
  name: string;
5454
5406
  callbackURL?: string | undefined;
5455
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5407
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5456
5408
  use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions>[];
5457
5409
  };
5458
5410
  method: better_call.Method | better_call.Method[];
@@ -5957,7 +5909,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5957
5909
  }, {
5958
5910
  name?: string | undefined;
5959
5911
  image?: string | undefined;
5960
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5912
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5961
5913
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
5962
5914
  session: {
5963
5915
  session: {
@@ -5989,7 +5941,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5989
5941
  }, {
5990
5942
  name?: string | undefined;
5991
5943
  image?: string | undefined;
5992
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5944
+ }> & toZod<AdditionalUserFieldsInput<O>>;
5993
5945
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
5994
5946
  session: {
5995
5947
  session: {
@@ -6021,7 +5973,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
6021
5973
  }, {
6022
5974
  name?: string | undefined;
6023
5975
  image?: string | undefined;
6024
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
5976
+ }> & toZod<AdditionalUserFieldsInput<O>>;
6025
5977
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
6026
5978
  session: {
6027
5979
  session: {
@@ -6059,7 +6011,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
6059
6011
  }, {
6060
6012
  name?: string | undefined;
6061
6013
  image?: string | undefined;
6062
- }> & toZod<InferFieldsFromOptions<O, "user", "input">>;
6014
+ }> & toZod<AdditionalUserFieldsInput<O>>;
6063
6015
  use: (Endpoint<better_call.Handler<string, better_call.EndpointOptions, void>, better_call.EndpointOptions> | Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
6064
6016
  session: {
6065
6017
  session: {
@@ -2,10 +2,10 @@ import * as nanostores from 'nanostores';
2
2
  import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.js';
3
3
  import * as _better_fetch_fetch from '@better-fetch/fetch';
4
4
  import { BetterFetchOption } from '@better-fetch/fetch';
5
- import { o as organization, l as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin, j as genericOAuth, k as multiSession } from '../index-Cw_LIJVp.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-Cw_LIJVp.js';
5
+ import { o as organization, l as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin, j as genericOAuth, k as multiSession } from '../index-BwCQ9u_T.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-BwCQ9u_T.js';
7
7
  import { P as Prettify } from '../helper-DPDj8Nix.js';
8
- import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../auth-CS6UmdXR.js';
8
+ import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../auth-ChOWHZz7.js';
9
9
  import 'zod';
10
10
  import '../schema-Dkt0LqYs.js';
11
11
  import 'better-call';
package/dist/client.d.ts CHANGED
@@ -6,7 +6,7 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
6
6
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
7
7
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
8
8
  export { AtomListener, InferPluginsFromClient } from './types.js';
9
- import './auth-CS6UmdXR.js';
9
+ import './auth-ChOWHZz7.js';
10
10
  import 'kysely';
11
11
  import './schema-Dkt0LqYs.js';
12
12
  import 'better-call';
package/dist/cookies.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'better-call';
2
- export { s as BetterAuthCookies, E as EligibleCookies, r as createCookieGetter, u as deleteSessionCookie, q as getCookies, w as parseCookies, v as parseSetCookieHeader, t as setSessionCookie } from './auth-CS6UmdXR.js';
2
+ export { s as BetterAuthCookies, E as EligibleCookies, r as createCookieGetter, u as deleteSessionCookie, q as getCookies, w as parseCookies, v as parseSetCookieHeader, t as setSessionCookie } from './auth-ChOWHZz7.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import './schema-Dkt0LqYs.js';
package/dist/db.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Adapter, B as BetterAuthOptions, W as Where, F as FieldAttribute, z as FieldType, K as KyselyDatabaseType } from './auth-CS6UmdXR.js';
2
- export { X as BetterAuthDbSchema, J as FieldAttributeConfig, V as InferFieldsFromOptions, U as InferFieldsFromPlugins, O as InferFieldsInput, Q as InferFieldsInputClient, N as InferFieldsOutput, M as InferValueType, D as InternalAdapter, T as PluginFieldAttribute, L as createFieldAttribute, C as createInternalAdapter, Y as getAuthTables } from './auth-CS6UmdXR.js';
1
+ import { A as Adapter, B as BetterAuthOptions, W as Where, F as FieldAttribute, z as FieldType, K as KyselyDatabaseType } from './auth-ChOWHZz7.js';
2
+ export { X as BetterAuthDbSchema, J as FieldAttributeConfig, V as InferFieldsFromOptions, U as InferFieldsFromPlugins, O as InferFieldsInput, Q as InferFieldsInputClient, N as InferFieldsOutput, M as InferValueType, D as InternalAdapter, T as PluginFieldAttribute, L as createFieldAttribute, C as createInternalAdapter, Y as getAuthTables } from './auth-ChOWHZz7.js';
3
3
  import { z } from 'zod';
4
4
  import 'kysely';
5
5
  import './schema-Dkt0LqYs.js';
@@ -5,7 +5,7 @@ import { P as Prettify } from './helper-DPDj8Nix.js';
5
5
  import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.js';
6
6
  import * as _better_fetch_fetch from '@better-fetch/fetch';
7
7
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
8
- import { H as HookEndpointContext, p as AuthContext } from './auth-CS6UmdXR.js';
8
+ import { H as HookEndpointContext, p as AuthContext } from './auth-ChOWHZz7.js';
9
9
  import * as nanostores from 'nanostores';
10
10
  import { atom } from 'nanostores';
11
11
  import * as _simplewebauthn_types from '@simplewebauthn/types';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as Adapter, j as AdditionalSessionFieldsInput, k as AdditionalSessionFieldsOutput, h as AdditionalUserFieldsInput, i as AdditionalUserFieldsOutput, a as Auth, p as AuthContext, s as BetterAuthCookies, B as BetterAuthOptions, b as BetterAuthPlugin, E as EligibleCookies, G as GenericEndpointContext, H as HookEndpointContext, m as InferPluginTypes, l as InferSession, I as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, g as betterAuth, r as createCookieGetter, x as createLogger, u as deleteSessionCookie, q as getCookies, n as init, y as logger, w as parseCookies, v as parseSetCookieHeader, t as setSessionCookie } from './auth-CS6UmdXR.js';
1
+ export { A as Adapter, j as AdditionalSessionFieldsInput, k as AdditionalSessionFieldsOutput, h as AdditionalUserFieldsInput, i as AdditionalUserFieldsOutput, a as Auth, p as AuthContext, s as BetterAuthCookies, B as BetterAuthOptions, b as BetterAuthPlugin, E as EligibleCookies, G as GenericEndpointContext, H as HookEndpointContext, m as InferPluginTypes, l as InferSession, I as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, g as betterAuth, r as createCookieGetter, x as createLogger, u as deleteSessionCookie, q as getCookies, n as init, y as logger, w as parseCookies, v as parseSetCookieHeader, t as setSessionCookie } from './auth-ChOWHZz7.js';
2
2
  export { D as DeepPartial, H as HasRequiredKeys, L as LiteralString, a as LiteralUnion, P as Prettify, R as RequiredKeysOf, S as StripEmptyObjects, U as UnionToIntersection, W as WithoutEmpty } from './helper-DPDj8Nix.js';
3
3
  export { AtomListener, BetterAuthClientPlugin, ClientOptions, InferActions, InferAdditionalFromClient, InferClientAPI, InferPluginsFromClient, InferSessionFromClient, InferUserFromClient, IsSignal } from './types.js';
4
4
  export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
package/dist/node.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as http from 'http';
2
2
  import { IncomingHttpHeaders } from 'http';
3
- import { a as Auth } from './auth-CS6UmdXR.js';
3
+ import { a as Auth } from './auth-ChOWHZz7.js';
4
4
  import 'zod';
5
5
  import 'kysely';
6
6
  import './schema-Dkt0LqYs.js';
package/dist/plugins.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, j as genericOAuth, g as getPasskeyActions, m as magicLink, k as multiSession, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-Cw_LIJVp.js';
1
+ export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, j as genericOAuth, g as getPasskeyActions, m as magicLink, k as multiSession, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-BwCQ9u_T.js';
2
2
  export { i as ac } from './index-DfAHOgpj.js';
3
- import { H as HookEndpointContext, P as PluginSchema } from './auth-CS6UmdXR.js';
4
- export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './auth-CS6UmdXR.js';
3
+ import { H as HookEndpointContext, P as PluginSchema } from './auth-ChOWHZz7.js';
4
+ export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './auth-ChOWHZz7.js';
5
5
  export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
6
6
  import { U as User } from './schema-Dkt0LqYs.js';
7
7
  import * as better_call from 'better-call';
package/dist/react.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
3
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import { useStore } from '@nanostores/react';
6
- import './auth-CS6UmdXR.js';
6
+ import './auth-ChOWHZz7.js';
7
7
  import 'kysely';
8
8
  import './schema-Dkt0LqYs.js';
9
9
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { a as Auth } from './auth-CS6UmdXR.js';
1
+ import { a as Auth } from './auth-ChOWHZz7.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './schema-Dkt0LqYs.js';
package/dist/solid.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
3
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import { Accessor } from 'solid-js';
6
- import './auth-CS6UmdXR.js';
6
+ import './auth-ChOWHZz7.js';
7
7
  import 'kysely';
8
8
  import './schema-Dkt0LqYs.js';
9
9
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { a as Auth, B as BetterAuthOptions } from './auth-CS6UmdXR.js';
1
+ import { a as Auth, B as BetterAuthOptions } from './auth-ChOWHZz7.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './schema-Dkt0LqYs.js';
package/dist/svelte.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as nanostores from 'nanostores';
3
3
  import * as _better_fetch_fetch from '@better-fetch/fetch';
4
4
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
5
5
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
6
- import './auth-CS6UmdXR.js';
6
+ import './auth-ChOWHZz7.js';
7
7
  import 'kysely';
8
8
  import './schema-Dkt0LqYs.js';
9
9
  import 'better-call';
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as BetterAuthPlugin, a as Auth, Q as InferFieldsInputClient, N as InferFieldsOutput } from './auth-CS6UmdXR.js';
2
- export { A as Adapter, j as AdditionalSessionFieldsInput, k as AdditionalSessionFieldsOutput, h as AdditionalUserFieldsInput, i as AdditionalUserFieldsOutput, p as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, m as InferPluginTypes, l as InferSession, I as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, n as init } from './auth-CS6UmdXR.js';
1
+ import { b as BetterAuthPlugin, a as Auth, Q as InferFieldsInputClient, N as InferFieldsOutput } from './auth-ChOWHZz7.js';
2
+ export { A as Adapter, j as AdditionalSessionFieldsInput, k as AdditionalSessionFieldsOutput, h as AdditionalUserFieldsInput, i as AdditionalUserFieldsOutput, p as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, m as InferPluginTypes, l as InferSession, I as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, n as init } from './auth-ChOWHZz7.js';
3
3
  import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
4
4
  export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
5
5
  import { BetterFetchOption, BetterFetchResponse, BetterFetch, BetterFetchPlugin } from '@better-fetch/fetch';
package/dist/vue.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
3
  import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import { Ref, DeepReadonly } from 'vue';
6
- import './auth-CS6UmdXR.js';
6
+ import './auth-ChOWHZz7.js';
7
7
  import 'kysely';
8
8
  import './schema-Dkt0LqYs.js';
9
9
  import 'better-call';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "0.5.3-beta.4",
3
+ "version": "0.5.3-beta.5",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "repository": {