better-auth 0.4.6 → 0.4.7-beta.1

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 '../index-BJKlHmT9.js';
1
+ import { A as Adapter } from '../index-DVWptxzL.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import '../types-IzAbV4nB.js';
@@ -1,5 +1,5 @@
1
1
  import { Db } from 'mongodb';
2
- import { W as Where } from '../index-BJKlHmT9.js';
2
+ import { W as Where } from '../index-DVWptxzL.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import '../types-IzAbV4nB.js';
@@ -1,4 +1,4 @@
1
- import { A as Adapter } from '../index-BJKlHmT9.js';
1
+ import { A as Adapter } from '../index-DVWptxzL.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import '../types-IzAbV4nB.js';
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-BJKlHmT9.js';
1
+ export { e as AuthEndpoint, f as AuthMiddleware, v as callbackOAuth, T as changePassword, d as createAuthEndpoint, c as createAuthMiddleware, M as createEmailVerificationToken, $ as csrfMiddleware, V as deleteUser, Y as error, J as forgetPassword, K as forgetPasswordCallback, X as getCSRFToken, r as getEndpoints, w as getSession, x as getSessionFromCtx, z as listSessions, Z as ok, o as optionsMiddleware, L as resetPassword, C as revokeSession, D as revokeSessions, s as router, N as sendVerificationEmail, y as sessionMiddleware, U as setPassword, u as signInEmail, t as signInOAuth, E as signOut, _ as signUpEmail, Q as updateUser, O as verifyEmail } from './index-DVWptxzL.js';
2
2
  import './helper-DPDj8Nix.js';
3
3
  import 'zod';
4
4
  export { APIError } from 'better-call';
@@ -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, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-DFhZxdCd.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DFhZxdCd.js';
5
+ import { o as organization, j as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous, i as admin } from '../index-D6gELhZi.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-D6gELhZi.js';
7
7
  import { P as Prettify } from '../helper-DPDj8Nix.js';
8
- import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-BJKlHmT9.js';
8
+ import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-DVWptxzL.js';
9
9
  import * as better_call from 'better-call';
10
10
  import { z } from 'zod';
11
11
  import { O as OAuth2Tokens, U as User } from '../types-IzAbV4nB.js';
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 './index-BJKlHmT9.js';
9
+ import './index-DVWptxzL.js';
10
10
  import 'kysely';
11
11
  import './types-IzAbV4nB.js';
12
12
  import 'better-call';
@@ -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, g as AuthContext } from './index-BJKlHmT9.js';
8
+ import { H as HookEndpointContext, g as AuthContext } from './index-DVWptxzL.js';
9
9
  import * as nanostores from 'nanostores';
10
10
  import { atom } from 'nanostores';
11
11
  import * as _simplewebauthn_types from '@simplewebauthn/types';
@@ -3833,13 +3833,7 @@ declare const passkey: (options?: PasskeyOptions) => {
3833
3833
  }>]>(...ctx: C): Promise<C extends [{
3834
3834
  asResponse: true;
3835
3835
  }] ? Response : {
3836
- session: {
3837
- id: string;
3838
- userId: string;
3839
- expiresAt: Date;
3840
- ipAddress?: string | undefined;
3841
- userAgent?: string | undefined;
3842
- };
3836
+ session: any;
3843
3837
  }>;
3844
3838
  path: "/passkey/verify-authentication";
3845
3839
  options: {
@@ -4059,13 +4053,7 @@ declare const username: () => {
4059
4053
  updatedAt: Date;
4060
4054
  image?: string | undefined;
4061
4055
  };
4062
- session: {
4063
- id: string;
4064
- userId: string;
4065
- expiresAt: Date;
4066
- ipAddress?: string | undefined;
4067
- userAgent?: string | undefined;
4068
- };
4056
+ session: any;
4069
4057
  redirect: boolean;
4070
4058
  url: string | undefined;
4071
4059
  } | null>;
@@ -4120,22 +4108,8 @@ declare const username: () => {
4120
4108
  }>]>(...ctx: C): Promise<C extends [{
4121
4109
  asResponse: true;
4122
4110
  }] ? Response : {
4123
- user: {
4124
- id: string;
4125
- email: string;
4126
- emailVerified: boolean;
4127
- name: string;
4128
- createdAt: Date;
4129
- updatedAt: Date;
4130
- image?: string | undefined;
4131
- } | null;
4132
- session: {
4133
- id: string;
4134
- userId: string;
4135
- expiresAt: Date;
4136
- ipAddress?: string | undefined;
4137
- userAgent?: string | undefined;
4138
- };
4111
+ user: any;
4112
+ session: any;
4139
4113
  } | null>;
4140
4114
  path: "/sign-up/username";
4141
4115
  options: {
@@ -4344,13 +4318,7 @@ declare const phoneNumber: (options?: {
4344
4318
  updatedAt: Date;
4345
4319
  image?: string | undefined;
4346
4320
  };
4347
- session: {
4348
- id: string;
4349
- userId: string;
4350
- expiresAt: Date;
4351
- ipAddress?: string | undefined;
4352
- userAgent?: string | undefined;
4353
- };
4321
+ session: any;
4354
4322
  redirect: boolean;
4355
4323
  url: string | undefined;
4356
4324
  } | null>;
@@ -4405,22 +4373,8 @@ declare const phoneNumber: (options?: {
4405
4373
  }>]>(...ctx: C): Promise<C extends [{
4406
4374
  asResponse: true;
4407
4375
  }] ? Response : {
4408
- user: {
4409
- id: string;
4410
- email: string;
4411
- emailVerified: boolean;
4412
- name: string;
4413
- createdAt: Date;
4414
- updatedAt: Date;
4415
- image?: string | undefined;
4416
- } | null;
4417
- session: {
4418
- id: string;
4419
- userId: string;
4420
- expiresAt: Date;
4421
- ipAddress?: string | undefined;
4422
- userAgent?: string | undefined;
4423
- };
4376
+ user: any;
4377
+ session: any;
4424
4378
  }>;
4425
4379
  path: "/sign-up/phone-number";
4426
4380
  options: {
@@ -4497,16 +4451,7 @@ declare const phoneNumber: (options?: {
4497
4451
  asResponse: true;
4498
4452
  }] ? Response : {
4499
4453
  user: UserWithPhoneNumber;
4500
- session: {
4501
- id: string;
4502
- userId: string;
4503
- expiresAt: Date;
4504
- ipAddress?: string | undefined;
4505
- userAgent?: string | undefined;
4506
- };
4507
- } | {
4508
- user: UserWithPhoneNumber;
4509
- session: null;
4454
+ session: any;
4510
4455
  }>;
4511
4456
  path: "/phone-number/verify";
4512
4457
  options: {
@@ -4640,13 +4585,7 @@ declare const anonymous: (options?: AnonymousOptions) => {
4640
4585
  updatedAt: Date;
4641
4586
  image?: string | undefined;
4642
4587
  };
4643
- session: {
4644
- id: string;
4645
- userId: string;
4646
- expiresAt: Date;
4647
- ipAddress?: string | undefined;
4648
- userAgent?: string | undefined;
4649
- };
4588
+ session: any;
4650
4589
  } | null>;
4651
4590
  path: "/sign-in/anonymous";
4652
4591
  options: {
@@ -4691,22 +4630,8 @@ declare const anonymous: (options?: AnonymousOptions) => {
4691
4630
  }>]>(...ctx: C): Promise<C extends [{
4692
4631
  asResponse: true;
4693
4632
  }] ? Response : {
4694
- session: {
4695
- id: string;
4696
- userId: string;
4697
- expiresAt: Date;
4698
- ipAddress?: string | undefined;
4699
- userAgent?: string | undefined;
4700
- };
4701
- user: {
4702
- id: string;
4703
- email: string;
4704
- emailVerified: boolean;
4705
- name: string;
4706
- createdAt: Date;
4707
- updatedAt: Date;
4708
- image?: string | undefined;
4709
- };
4633
+ session: any;
4634
+ user: any;
4710
4635
  } | null>;
4711
4636
  path: "/user/link-anonymous";
4712
4637
  options: {
@@ -5152,15 +5077,7 @@ declare const admin: (options?: AdminOptions) => {
5152
5077
  }>]>(...ctx: C): Promise<C extends [{
5153
5078
  asResponse: true;
5154
5079
  }] ? Response : {
5155
- user: {
5156
- id: string;
5157
- email: string;
5158
- emailVerified: boolean;
5159
- name: string;
5160
- createdAt: Date;
5161
- updatedAt: Date;
5162
- image?: string | undefined;
5163
- } | null;
5080
+ user: any;
5164
5081
  }>;
5165
5082
  path: "/admin/unban-user";
5166
5083
  options: {
@@ -5225,15 +5142,7 @@ declare const admin: (options?: AdminOptions) => {
5225
5142
  }>]>(...ctx: C): Promise<C extends [{
5226
5143
  asResponse: true;
5227
5144
  }] ? Response : {
5228
- user: {
5229
- id: string;
5230
- email: string;
5231
- emailVerified: boolean;
5232
- name: string;
5233
- createdAt: Date;
5234
- updatedAt: Date;
5235
- image?: string | undefined;
5236
- } | null;
5145
+ user: any;
5237
5146
  }>;
5238
5147
  path: "/admin/ban-user";
5239
5148
  options: {
@@ -5298,13 +5207,7 @@ declare const admin: (options?: AdminOptions) => {
5298
5207
  }>]>(...ctx: C): Promise<C extends [{
5299
5208
  asResponse: true;
5300
5209
  }] ? Response : {
5301
- session: {
5302
- id: string;
5303
- userId: string;
5304
- expiresAt: Date;
5305
- ipAddress?: string | undefined;
5306
- userAgent?: string | undefined;
5307
- };
5210
+ session: any;
5308
5211
  user: {
5309
5212
  id: string;
5310
5213
  email: string;
@@ -977,26 +977,8 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
977
977
  hooks: Exclude<BetterAuthOptions["databaseHooks"], undefined>[];
978
978
  }) => {
979
979
  createOAuthUser: (user: User, account: Account) => Promise<{
980
- user: {
981
- id: string;
982
- email: string;
983
- emailVerified: boolean;
984
- name: string;
985
- createdAt: Date;
986
- updatedAt: Date;
987
- image?: string | undefined;
988
- } | null;
989
- account: {
990
- id: string;
991
- providerId: string;
992
- accountId: string;
993
- userId: string;
994
- accessToken?: string | null | undefined;
995
- refreshToken?: string | null | undefined;
996
- idToken?: string | null | undefined;
997
- expiresAt?: Date | null | undefined;
998
- password?: string | null | undefined;
999
- } | null;
980
+ user: any;
981
+ account: any;
1000
982
  } | null>;
1001
983
  createUser: <T>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>) => Promise<T & {
1002
984
  id: string;
@@ -1027,24 +1009,12 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
1027
1009
  image?: string | undefined;
1028
1010
  }[]>;
1029
1011
  deleteUser: (userId: string) => Promise<void>;
1030
- createSession: (userId: string, request?: Request | Headers, dontRememberMe?: boolean, override?: Partial<Session> & Record<string, any>) => Promise<{
1031
- id: string;
1032
- userId: string;
1033
- expiresAt: Date;
1034
- ipAddress?: string | undefined;
1035
- userAgent?: string | undefined;
1036
- }>;
1012
+ createSession: (userId: string, request?: Request | Headers, dontRememberMe?: boolean, override?: Partial<Session> & Record<string, any>) => Promise<any>;
1037
1013
  findSession: (sessionId: string) => Promise<{
1038
1014
  session: Session;
1039
1015
  user: User;
1040
1016
  } | null>;
1041
- updateSession: (sessionId: string, session: Partial<Session>) => Promise<{
1042
- id: string;
1043
- userId: string;
1044
- expiresAt: Date;
1045
- ipAddress?: string | undefined;
1046
- userAgent?: string | undefined;
1047
- } | null>;
1017
+ updateSession: (sessionId: string, session: Partial<Session>) => Promise<any>;
1048
1018
  deleteSession: (id: string) => Promise<void>;
1049
1019
  deleteSessions: (userId: string) => Promise<void>;
1050
1020
  findUserByEmail: (email: string, options?: {
@@ -1080,46 +1050,10 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
1080
1050
  updatedAt: Date;
1081
1051
  image?: string | undefined;
1082
1052
  } | null>;
1083
- linkAccount: (account: Omit<Account, "id"> & Partial<Account>) => Promise<{
1084
- providerId: string;
1085
- accountId: string;
1086
- userId: string;
1087
- accessToken?: string | null | undefined;
1088
- refreshToken?: string | null | undefined;
1089
- idToken?: string | null | undefined;
1090
- expiresAt?: Date | null | undefined;
1091
- password?: string | null | undefined;
1092
- id: string;
1093
- } | null>;
1094
- updateUser: (userId: string, data: Partial<User> & Record<string, any>) => Promise<{
1095
- id: string;
1096
- email: string;
1097
- emailVerified: boolean;
1098
- name: string;
1099
- createdAt: Date;
1100
- updatedAt: Date;
1101
- image?: string | undefined;
1102
- } | null>;
1103
- updateUserByEmail: (email: string, data: Partial<User & Record<string, any>>) => Promise<{
1104
- id: string;
1105
- email: string;
1106
- emailVerified: boolean;
1107
- name: string;
1108
- createdAt: Date;
1109
- updatedAt: Date;
1110
- image?: string | undefined;
1111
- } | null>;
1112
- updatePassword: (userId: string, password: string) => Promise<{
1113
- id: string;
1114
- providerId: string;
1115
- accountId: string;
1116
- userId: string;
1117
- accessToken?: string | null | undefined;
1118
- refreshToken?: string | null | undefined;
1119
- idToken?: string | null | undefined;
1120
- expiresAt?: Date | null | undefined;
1121
- password?: string | null | undefined;
1122
- } | null>;
1053
+ linkAccount: (account: Omit<Account, "id"> & Partial<Account>) => Promise<any>;
1054
+ updateUser: (userId: string, data: Partial<User> & Record<string, any>) => Promise<any>;
1055
+ updateUserByEmail: (email: string, data: Partial<User & Record<string, any>>) => Promise<any>;
1056
+ updatePassword: (userId: string, password: string) => Promise<any>;
1123
1057
  findAccounts: (userId: string) => Promise<{
1124
1058
  id: string;
1125
1059
  providerId: string;
@@ -1131,23 +1065,8 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
1131
1065
  expiresAt?: Date | null | undefined;
1132
1066
  password?: string | null | undefined;
1133
1067
  }[]>;
1134
- updateAccount: (accountId: string, data: Partial<Account>) => Promise<{
1135
- id: string;
1136
- providerId: string;
1137
- accountId: string;
1138
- userId: string;
1139
- accessToken?: string | null | undefined;
1140
- refreshToken?: string | null | undefined;
1141
- idToken?: string | null | undefined;
1142
- expiresAt?: Date | null | undefined;
1143
- password?: string | null | undefined;
1144
- } | null>;
1145
- createVerificationValue: (data: Omit<Verification, "id">) => Promise<{
1146
- expiresAt: Date;
1147
- value: string;
1148
- identifier: string;
1149
- id: string;
1150
- } | null>;
1068
+ updateAccount: (accountId: string, data: Partial<Account>) => Promise<any>;
1069
+ createVerificationValue: (data: Omit<Verification, "id">) => Promise<any>;
1151
1070
  findVerificationValue: (identifier: string) => Promise<{
1152
1071
  id: string;
1153
1072
  expiresAt: Date;
@@ -1155,12 +1074,7 @@ declare const createInternalAdapter: (adapter: Adapter, ctx: {
1155
1074
  identifier: string;
1156
1075
  } | null>;
1157
1076
  deleteVerificationValue: (id: string) => Promise<void>;
1158
- updateVerificationValue: (id: string, data: Partial<Verification>) => Promise<{
1159
- id: string;
1160
- expiresAt: Date;
1161
- value: string;
1162
- identifier: string;
1163
- } | null>;
1077
+ updateVerificationValue: (id: string, data: Partial<Verification>) => Promise<any>;
1164
1078
  };
1165
1079
 
1166
1080
  declare const signInOAuth: {
@@ -1272,13 +1186,7 @@ declare const signInEmail: {
1272
1186
  updatedAt: Date;
1273
1187
  image?: string | undefined;
1274
1188
  };
1275
- session: {
1276
- id: string;
1277
- userId: string;
1278
- expiresAt: Date;
1279
- ipAddress?: string | undefined;
1280
- userAgent?: string | undefined;
1281
- };
1189
+ session: any;
1282
1190
  redirect: boolean;
1283
1191
  url: string | undefined;
1284
1192
  }>;
@@ -1885,15 +1793,7 @@ declare const updateUser: {
1885
1793
  }>]>(...ctx: C): Promise<C extends [{
1886
1794
  asResponse: true;
1887
1795
  }] ? Response : {
1888
- user: {
1889
- id: string;
1890
- email: string;
1891
- emailVerified: boolean;
1892
- name: string;
1893
- createdAt: Date;
1894
- updatedAt: Date;
1895
- image?: string | undefined;
1896
- } | null;
1796
+ user: any;
1897
1797
  }>;
1898
1798
  path: "/user/update";
1899
1799
  options: {
@@ -2340,13 +2240,7 @@ declare const signUpEmail: <O extends BetterAuthOptions>() => {
2340
2240
  updatedAt: Date;
2341
2241
  image?: string | undefined;
2342
2242
  };
2343
- session: {
2344
- id: string;
2345
- userId: string;
2346
- expiresAt: Date;
2347
- ipAddress?: string | undefined;
2348
- userAgent?: string | undefined;
2349
- };
2243
+ session: any;
2350
2244
  error: null;
2351
2245
  }>;
2352
2246
  path: "/sign-up/email";
@@ -2701,13 +2595,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2701
2595
  updatedAt: Date;
2702
2596
  image?: string | undefined;
2703
2597
  };
2704
- session: {
2705
- id: string;
2706
- userId: string;
2707
- expiresAt: Date;
2708
- ipAddress?: string | undefined;
2709
- userAgent?: string | undefined;
2710
- };
2598
+ session: any;
2711
2599
  error: null;
2712
2600
  }>;
2713
2601
  path: "/sign-up/email";
@@ -2771,13 +2659,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
2771
2659
  updatedAt: Date;
2772
2660
  image?: string | undefined;
2773
2661
  };
2774
- session: {
2775
- id: string;
2776
- userId: string;
2777
- expiresAt: Date;
2778
- ipAddress?: string | undefined;
2779
- userAgent?: string | undefined;
2780
- };
2662
+ session: any;
2781
2663
  redirect: boolean;
2782
2664
  url: string | undefined;
2783
2665
  }>;
@@ -3178,15 +3060,7 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3178
3060
  }>]>(...ctx: C_1): Promise<C_1 extends [{
3179
3061
  asResponse: true;
3180
3062
  }] ? Response : {
3181
- user: {
3182
- id: string;
3183
- email: string;
3184
- emailVerified: boolean;
3185
- name: string;
3186
- createdAt: Date;
3187
- updatedAt: Date;
3188
- image?: string | undefined;
3189
- } | null;
3063
+ user: any;
3190
3064
  }>;
3191
3065
  path: "/user/update";
3192
3066
  options: {
@@ -3810,13 +3684,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
3810
3684
  updatedAt: Date;
3811
3685
  image?: string | undefined;
3812
3686
  };
3813
- session: {
3814
- id: string;
3815
- userId: string;
3816
- expiresAt: Date;
3817
- ipAddress?: string | undefined;
3818
- userAgent?: string | undefined;
3819
- };
3687
+ session: any;
3820
3688
  error: null;
3821
3689
  }>;
3822
3690
  path: "/sign-up/email";
@@ -3880,13 +3748,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
3880
3748
  updatedAt: Date;
3881
3749
  image?: string | undefined;
3882
3750
  };
3883
- session: {
3884
- id: string;
3885
- userId: string;
3886
- expiresAt: Date;
3887
- ipAddress?: string | undefined;
3888
- userAgent?: string | undefined;
3889
- };
3751
+ session: any;
3890
3752
  redirect: boolean;
3891
3753
  url: string | undefined;
3892
3754
  }>;
@@ -4287,15 +4149,7 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4287
4149
  }>]>(...ctx: C_1): Promise<C_1 extends [{
4288
4150
  asResponse: true;
4289
4151
  }] ? Response : {
4290
- user: {
4291
- id: string;
4292
- email: string;
4293
- emailVerified: boolean;
4294
- name: string;
4295
- createdAt: Date;
4296
- updatedAt: Date;
4297
- image?: string | undefined;
4298
- } | null;
4152
+ user: any;
4299
4153
  }>;
4300
4154
  path: "/user/update";
4301
4155
  options: {
@@ -4921,13 +4775,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
4921
4775
  updatedAt: Date;
4922
4776
  image?: string | undefined;
4923
4777
  };
4924
- session: {
4925
- id: string;
4926
- userId: string;
4927
- expiresAt: Date;
4928
- ipAddress?: string | undefined;
4929
- userAgent?: string | undefined;
4930
- };
4778
+ session: any;
4931
4779
  error: null;
4932
4780
  }>;
4933
4781
  path: "/sign-up/email";
@@ -4991,13 +4839,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
4991
4839
  updatedAt: Date;
4992
4840
  image?: string | undefined;
4993
4841
  };
4994
- session: {
4995
- id: string;
4996
- userId: string;
4997
- expiresAt: Date;
4998
- ipAddress?: string | undefined;
4999
- userAgent?: string | undefined;
5000
- };
4842
+ session: any;
5001
4843
  redirect: boolean;
5002
4844
  url: string | undefined;
5003
4845
  }>;
@@ -5398,15 +5240,7 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5398
5240
  }>]>(...ctx: C): Promise<C extends [{
5399
5241
  asResponse: true;
5400
5242
  }] ? Response : {
5401
- user: {
5402
- id: string;
5403
- email: string;
5404
- emailVerified: boolean;
5405
- name: string;
5406
- createdAt: Date;
5407
- updatedAt: Date;
5408
- image?: string | undefined;
5409
- } | null;
5243
+ user: any;
5410
5244
  }>;
5411
5245
  path: "/user/update";
5412
5246
  options: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a as Auth, a0 as betterAuth } from './index-BJKlHmT9.js';
1
+ export { a as Auth, a0 as betterAuth } from './index-DVWptxzL.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './types-IzAbV4nB.js';
package/dist/index.js CHANGED
@@ -3617,7 +3617,7 @@ var verifyPassword = async (hash, password) => {
3617
3617
  function getWithHooks(adapter, ctx) {
3618
3618
  const hooks = ctx.hooks;
3619
3619
  const tables = getAuthTables(ctx.options);
3620
- async function createWithHooks(data, model) {
3620
+ async function createWithHooks(data, model, customCreateFn) {
3621
3621
  let actualData = data;
3622
3622
  const table = tables[model];
3623
3623
  for (const hook of hooks || []) {
@@ -3633,13 +3633,14 @@ function getWithHooks(adapter, ctx) {
3633
3633
  }
3634
3634
  }
3635
3635
  }
3636
- const created = await adapter.create({
3636
+ const customCreated = customCreateFn ? await customCreateFn.fn(actualData) : null;
3637
+ const created = !customCreateFn || customCreateFn.executeMainFn ? await adapter.create({
3637
3638
  model: table.tableName,
3638
3639
  data: {
3639
3640
  id: generateId(),
3640
3641
  ...convertToDB(table.fields, actualData)
3641
3642
  }
3642
- });
3643
+ }) : customCreated;
3643
3644
  for (const hook of hooks || []) {
3644
3645
  const toRun = hook[model]?.create?.after;
3645
3646
  if (toRun) {
@@ -3648,7 +3649,7 @@ function getWithHooks(adapter, ctx) {
3648
3649
  }
3649
3650
  return convertFromDB(table.fields, created);
3650
3651
  }
3651
- async function updateWithHooks(data, where, model) {
3652
+ async function updateWithHooks(data, where, model, customUpdateFn) {
3652
3653
  let actualData = data;
3653
3654
  for (const hook of hooks || []) {
3654
3655
  const toRun = hook[model]?.update?.before;
@@ -3661,11 +3662,12 @@ function getWithHooks(adapter, ctx) {
3661
3662
  actualData = isObject ? result.data : result;
3662
3663
  }
3663
3664
  }
3664
- const updated = await adapter.update({
3665
+ const customUpdated = customUpdateFn ? await customUpdateFn.fn(actualData) : null;
3666
+ const updated = !customUpdateFn || customUpdateFn.executeMainFn ? await adapter.update({
3665
3667
  model: tables[model].tableName,
3666
3668
  update: convertToDB(tables[model].fields, actualData),
3667
3669
  where
3668
- });
3670
+ }) : customUpdated;
3669
3671
  for (const hook of hooks || []) {
3670
3672
  const toRun = hook[model]?.update?.after;
3671
3673
  if (toRun) {
@@ -3779,26 +3781,28 @@ var createInternalAdapter = (adapter, ctx) => {
3779
3781
  userAgent: headers?.get("user-agent") || "",
3780
3782
  ...override
3781
3783
  };
3782
- if (secondaryStorage) {
3783
- const user = await adapter.findOne({
3784
- model: tables.user.tableName,
3785
- where: [{ field: "id", value: userId }]
3786
- });
3787
- secondaryStorage.set(
3788
- data.id,
3789
- JSON.stringify({
3790
- session: data,
3791
- user
3792
- }),
3793
- sessionExpiration
3794
- );
3795
- if (options.session?.storeSessionInDatabase) {
3796
- await createWithHooks(data, "session");
3797
- }
3798
- } else {
3799
- await createWithHooks(data, "session");
3800
- }
3801
- return data;
3784
+ const res = await createWithHooks(
3785
+ data,
3786
+ "session",
3787
+ secondaryStorage ? {
3788
+ fn: async (data2) => {
3789
+ const user = await adapter.findOne({
3790
+ model: tables.user.tableName,
3791
+ where: [{ field: "id", value: userId }]
3792
+ });
3793
+ secondaryStorage.set(
3794
+ data2.id,
3795
+ JSON.stringify({
3796
+ session: data2,
3797
+ user
3798
+ }),
3799
+ sessionExpiration
3800
+ );
3801
+ },
3802
+ executeMainFn: options.session?.storeSessionInDatabase
3803
+ } : void 0
3804
+ );
3805
+ return res;
3802
3806
  },
3803
3807
  findSession: async (sessionId) => {
3804
3808
  if (secondaryStorage) {
@@ -3848,39 +3852,34 @@ var createInternalAdapter = (adapter, ctx) => {
3848
3852
  };
3849
3853
  },
3850
3854
  updateSession: async (sessionId, session) => {
3851
- if (secondaryStorage) {
3852
- const currentSession = await secondaryStorage.get(sessionId);
3853
- let updatedSession2 = null;
3854
- if (currentSession) {
3855
- const parsedSession = JSON.parse(currentSession);
3856
- updatedSession2 = {
3857
- ...parsedSession.session,
3858
- ...session
3859
- };
3860
- await secondaryStorage.set(
3861
- sessionId,
3862
- JSON.stringify({
3863
- session: updatedSession2,
3864
- user: parsedSession.user
3865
- }),
3866
- parsedSession.session.expiresAt ? new Date(parsedSession.session.expiresAt).getTime() : void 0
3867
- );
3868
- } else {
3869
- return null;
3870
- }
3871
- if (options.session?.storeSessionInDatabase) {
3872
- await updateWithHooks(
3873
- session,
3874
- [{ field: "id", value: sessionId }],
3875
- "session"
3876
- );
3877
- }
3878
- return updatedSession2;
3879
- }
3880
3855
  const updatedSession = await updateWithHooks(
3881
3856
  session,
3882
3857
  [{ field: "id", value: sessionId }],
3883
- "session"
3858
+ "session",
3859
+ secondaryStorage ? {
3860
+ async fn(data) {
3861
+ const currentSession = await secondaryStorage.get(sessionId);
3862
+ let updatedSession2 = null;
3863
+ if (currentSession) {
3864
+ const parsedSession = JSON.parse(currentSession);
3865
+ updatedSession2 = {
3866
+ ...parsedSession.session,
3867
+ ...data
3868
+ };
3869
+ await secondaryStorage.set(
3870
+ sessionId,
3871
+ JSON.stringify({
3872
+ session: updatedSession2,
3873
+ user: parsedSession.user
3874
+ }),
3875
+ parsedSession.session.expiresAt ? new Date(parsedSession.session.expiresAt).getTime() : void 0
3876
+ );
3877
+ } else {
3878
+ return null;
3879
+ }
3880
+ },
3881
+ executeMainFn: options.session?.storeSessionInDatabase
3882
+ } : void 0
3884
3883
  );
3885
3884
  return updatedSession;
3886
3885
  },
package/dist/next-js.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Auth } from './index-BJKlHmT9.js';
1
+ import { a as Auth } from './index-DVWptxzL.js';
2
2
  import { U as User, S as Session } from './types-IzAbV4nB.js';
3
3
  import { NextRequest } from 'next/server';
4
4
  import 'zod';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as http from 'http';
2
- import { a as Auth } from './index-BJKlHmT9.js';
2
+ import { a as Auth } from './index-DVWptxzL.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import './types-IzAbV4nB.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, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-DFhZxdCd.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, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-D6gELhZi.js';
2
2
  export { i as ac } from './index-DfAHOgpj.js';
3
- import { H as HookEndpointContext } from './index-BJKlHmT9.js';
4
- export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-BJKlHmT9.js';
3
+ import { H as HookEndpointContext } from './index-DVWptxzL.js';
4
+ export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-DVWptxzL.js';
5
5
  import './types-IzAbV4nB.js';
6
6
  import 'zod';
7
7
  import './helper-DPDj8Nix.js';
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 './index-BJKlHmT9.js';
6
+ import './index-DVWptxzL.js';
7
7
  import 'kysely';
8
8
  import './types-IzAbV4nB.js';
9
9
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { a as Auth } from './index-BJKlHmT9.js';
1
+ import { a as Auth } from './index-DVWptxzL.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './types-IzAbV4nB.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 './index-BJKlHmT9.js';
6
+ import './index-DVWptxzL.js';
7
7
  import 'kysely';
8
8
  import './types-IzAbV4nB.js';
9
9
  import 'better-call';
@@ -1,4 +1,4 @@
1
- import { a as Auth, B as BetterAuthOptions } from './index-BJKlHmT9.js';
1
+ import { a as Auth, B as BetterAuthOptions } from './index-DVWptxzL.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './types-IzAbV4nB.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 './index-BJKlHmT9.js';
6
+ import './index-DVWptxzL.js';
7
7
  import 'kysely';
8
8
  import './types-IzAbV4nB.js';
9
9
  import 'better-call';
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-BJKlHmT9.js';
2
- export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-BJKlHmT9.js';
1
+ import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-DVWptxzL.js';
2
+ export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-DVWptxzL.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 { S as Session, U as User } from './types-IzAbV4nB.js';
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 './index-BJKlHmT9.js';
6
+ import './index-DVWptxzL.js';
7
7
  import 'kysely';
8
8
  import './types-IzAbV4nB.js';
9
9
  import 'better-call';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "0.4.6",
3
+ "version": "0.4.7-beta.1",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",