better-auth 0.3.4-beta.3 → 0.3.4-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,7 +1,7 @@
1
- import { A as Adapter } from '../index-C9daNPfT.js';
1
+ import { A as Adapter } from '../index-B1Z0XMic.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
- import '../index-CT4RHCuS.js';
4
+ import '../index-QaO4zgiz.js';
5
5
  import 'arctic';
6
6
  import '../helper-DPDj8Nix.js';
7
7
  import 'better-call';
@@ -242,7 +242,10 @@ var drizzleAdapter = (db, options) => {
242
242
  schema,
243
243
  usePlural: options.usePlural
244
244
  });
245
- const res = await db.insert(schemaModel).values(val).returning();
245
+ const mutation = db.insert(schemaModel).values(val);
246
+ if (databaseType !== "mysql") return (await mutation.returning())[0];
247
+ await mutation;
248
+ const res = await db.select().from(schemaModel).where(eq(schemaModel.id, data.data.id));
246
249
  return res[0];
247
250
  },
248
251
  async findOne(data) {
@@ -287,7 +290,10 @@ var drizzleAdapter = (db, options) => {
287
290
  usePlural: options.usePlural
288
291
  });
289
292
  const wheres = whereConvertor(where, schemaModel);
290
- const res = await db.update(schemaModel).set(update).where(...wheres).returning();
293
+ const mutation = db.update(schemaModel).set(update).where(...wheres);
294
+ if (databaseType !== "mysql") return (await mutation.returning())[0];
295
+ await mutation;
296
+ const res = await db.select().from(schemaModel).where(eq(schemaModel.id, data.update.id));
291
297
  return res[0];
292
298
  },
293
299
  async delete(data) {
@@ -1,8 +1,8 @@
1
1
  import { Db } from 'mongodb';
2
- import { W as Where } from '../index-C9daNPfT.js';
2
+ import { W as Where } from '../index-B1Z0XMic.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
- import '../index-CT4RHCuS.js';
5
+ import '../index-QaO4zgiz.js';
6
6
  import 'arctic';
7
7
  import '../helper-DPDj8Nix.js';
8
8
  import 'better-call';
@@ -1,7 +1,7 @@
1
- import { A as Adapter } from '../index-C9daNPfT.js';
1
+ import { A as Adapter } from '../index-B1Z0XMic.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
- import '../index-CT4RHCuS.js';
4
+ import '../index-QaO4zgiz.js';
5
5
  import 'arctic';
6
6
  import '../helper-DPDj8Nix.js';
7
7
  import 'better-call';
package/dist/api.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { f as AuthEndpoint, g as AuthMiddleware, u as callbackOAuth, Q as changePassword, e as createAuthEndpoint, d as createAuthMiddleware, L as createEmailVerificationToken, _ as csrfMiddleware, U as deleteUser, X as error, E as forgetPassword, J as forgetPasswordCallback, V as getCSRFToken, q as getEndpoints, v as getSession, w as getSessionFromCtx, y as listSessions, Y as ok, o as optionsMiddleware, K as resetPassword, z as revokeSession, C as revokeSessions, r as router, M as sendVerificationEmail, x as sessionMiddleware, T as setPassword, t as signInEmail, s as signInOAuth, D as signOut, Z as signUpEmail, O as updateUser, N as verifyEmail } from './index-C9daNPfT.js';
1
+ export { f as AuthEndpoint, g as AuthMiddleware, v as callbackOAuth, T as changePassword, e as createAuthEndpoint, d 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-B1Z0XMic.js';
2
2
  import './helper-DPDj8Nix.js';
3
3
  import 'zod';
4
4
  export { APIError } from 'better-call';
5
5
  import 'kysely';
6
- import './index-CT4RHCuS.js';
6
+ import './index-QaO4zgiz.js';
7
7
  import 'arctic';
8
8
  import 'better-sqlite3';
9
9
  import 'mysql2';
package/dist/api.js CHANGED
@@ -1218,21 +1218,6 @@ var verificationSchema = z5.object({
1218
1218
  expiresAt: z5.date(),
1219
1219
  identifier: z5.string()
1220
1220
  });
1221
- function getAllFields(options, table) {
1222
- let schema = {
1223
- ...table === "user" ? options.user?.additionalFields : {},
1224
- ...table === "session" ? options.session?.additionalFields : {}
1225
- };
1226
- for (const plugin of options.plugins || []) {
1227
- if (plugin.schema && plugin.schema[table]) {
1228
- schema = {
1229
- ...schema,
1230
- ...plugin.schema[table].fields
1231
- };
1232
- }
1233
- }
1234
- return schema;
1235
- }
1236
1221
  function parseInputData(data, schema) {
1237
1222
  const fields = schema.fields;
1238
1223
  const parsedData = {};
@@ -1248,8 +1233,10 @@ function parseInputData(data, schema) {
1248
1233
  }
1249
1234
  return parsedData;
1250
1235
  }
1251
- function parseUserInput(options, user) {
1252
- const schema = getAllFields(options, "user");
1236
+ function parseAdditionalUserInput(options, user) {
1237
+ const schema = {
1238
+ ...options.user?.additionalFields
1239
+ };
1253
1240
  return parseInputData(user || {}, { fields: schema });
1254
1241
  }
1255
1242
 
@@ -2191,14 +2178,7 @@ var signUpEmail = () => createAuthEndpoint(
2191
2178
  query: z11.object({
2192
2179
  currentURL: z11.string().optional()
2193
2180
  }).optional(),
2194
- body: z11.object({
2195
- name: z11.string(),
2196
- email: z11.string(),
2197
- password: z11.string(),
2198
- image: z11.string().optional(),
2199
- callbackURL: z11.string().optional(),
2200
- additionalFields: z11.record(z11.string(), z11.any()).optional()
2201
- })
2181
+ body: z11.record(z11.string(), z11.any())
2202
2182
  },
2203
2183
  async (ctx) => {
2204
2184
  if (!ctx.context.options.emailAndPassword?.enabled) {
@@ -2206,8 +2186,8 @@ var signUpEmail = () => createAuthEndpoint(
2206
2186
  message: "Email and password sign up is not enabled"
2207
2187
  });
2208
2188
  }
2209
- const { name, email, password, image } = ctx.body;
2210
- const additionalFields = ctx.body.additionalFields;
2189
+ const body = ctx.body;
2190
+ const { name, email, password, image, ...additionalFields } = body;
2211
2191
  const isValidEmail = z11.string().email().safeParse(email);
2212
2192
  if (!isValidEmail.success) {
2213
2193
  throw new APIError9("BAD_REQUEST", {
@@ -2234,7 +2214,7 @@ var signUpEmail = () => createAuthEndpoint(
2234
2214
  message: "User already exists"
2235
2215
  });
2236
2216
  }
2237
- const additionalData = parseUserInput(
2217
+ const additionalData = parseAdditionalUserInput(
2238
2218
  ctx.context.options,
2239
2219
  additionalFields
2240
2220
  );
@@ -2276,7 +2256,7 @@ var signUpEmail = () => createAuthEndpoint(
2276
2256
  ctx.context.secret,
2277
2257
  createdUser.email
2278
2258
  );
2279
- const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${ctx.body.callbackURL || ctx.query?.currentURL || "/"}`;
2259
+ const url = `${ctx.context.baseURL}/verify-email?token=${token}&callbackURL=${body.callbackURL || ctx.query?.currentURL || "/"}`;
2280
2260
  await ctx.context.options.emailAndPassword.sendVerificationEmail?.(
2281
2261
  createdUser.email,
2282
2262
  url,
@@ -2290,8 +2270,8 @@ var signUpEmail = () => createAuthEndpoint(
2290
2270
  error: null
2291
2271
  },
2292
2272
  {
2293
- body: ctx.body.callbackURL ? {
2294
- url: ctx.body.callbackURL,
2273
+ body: body.callbackURL ? {
2274
+ url: body.callbackURL,
2295
2275
  redirect: true
2296
2276
  } : {
2297
2277
  user: createdUser,
@@ -2,11 +2,11 @@ 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, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-CUhY6myj.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-CUhY6myj.js';
5
+ import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-DY0drFY6.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DY0drFY6.js';
7
7
  import { P as Prettify } from '../helper-DPDj8Nix.js';
8
- import { F as FieldAttribute, B as BetterAuthOptions, c as BetterAuthPlugin } from '../index-C9daNPfT.js';
9
- import '../index-CT4RHCuS.js';
8
+ import { F as FieldAttribute, B as BetterAuthOptions, c as BetterAuthPlugin } from '../index-B1Z0XMic.js';
9
+ import '../index-QaO4zgiz.js';
10
10
  import 'arctic';
11
11
  import 'zod';
12
12
  import 'better-call';
package/dist/client.d.ts CHANGED
@@ -6,9 +6,9 @@ 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-C9daNPfT.js';
9
+ import './index-B1Z0XMic.js';
10
10
  import 'kysely';
11
- import './index-CT4RHCuS.js';
11
+ import './index-QaO4zgiz.js';
12
12
  import 'arctic';
13
13
  import 'better-call';
14
14
  import 'better-sqlite3';
@@ -28,14 +28,14 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
28
28
  createdAt: Date;
29
29
  updatedAt: Date;
30
30
  image?: string | undefined;
31
- } & UnionToIntersection<InferAdditionalFromClient<Option, "user">>>>;
31
+ } & UnionToIntersection<InferAdditionalFromClient<Option, "user", "output">>>>;
32
32
  session: Prettify<StripEmptyObjects<{
33
33
  id: string;
34
34
  userId: string;
35
35
  expiresAt: Date;
36
36
  ipAddress?: string | undefined;
37
37
  userAgent?: string | undefined;
38
- } & UnionToIntersection<InferAdditionalFromClient<Option, "session">>>>;
38
+ } & UnionToIntersection<InferAdditionalFromClient<Option, "session", "output">>>>;
39
39
  } | null;
40
40
  error: null | _better_fetch_fetch.BetterFetchError;
41
41
  isPending: boolean;
@@ -196,7 +196,7 @@ declare function createAuthClient<Option extends ClientOptions>(options?: Option
196
196
  authorization: "Bearer" | "Basic";
197
197
  })) | undefined;
198
198
  redirect?: RequestRedirect;
199
- method?: string;
199
+ method: string;
200
200
  cache?: RequestCache;
201
201
  credentials: RequestCredentials;
202
202
  integrity?: string;
package/dist/client.js CHANGED
@@ -138,6 +138,7 @@ var getClientConfig = (options) => {
138
138
  const $fetch = createFetch({
139
139
  baseURL: getBaseURL(options?.fetchOptions?.baseURL || options?.baseURL),
140
140
  credentials: "include",
141
+ method: "GET",
141
142
  ...options?.fetchOptions,
142
143
  plugins: [
143
144
  csrfPlugin,