better-auth 0.4.9-beta.8 → 0.4.9-beta.9

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-DyhG32S0.js';
1
+ import { A as Adapter } from '../index-BQ_rbsXC.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-DyhG32S0.js';
2
+ import { W as Where } from '../index-BQ_rbsXC.js';
3
3
  import 'zod';
4
4
  import 'kysely';
5
5
  import '../types-IzAbV4nB.js';
@@ -80,15 +80,25 @@ var mongodbAdapter = (mongo) => {
80
80
  async update(data) {
81
81
  const { model, where, update } = data;
82
82
  const wheres = whereConvertor(where);
83
- const res = await db.collection(model).findOneAndUpdate(
83
+ if (where.length === 1) {
84
+ const res2 = await db.collection(model).findOneAndUpdate(
85
+ //@ts-expect-error
86
+ wheres,
87
+ {
88
+ $set: update
89
+ },
90
+ { returnDocument: "after" }
91
+ );
92
+ return removeMongoId(res2);
93
+ }
94
+ const res = await db.collection(model).updateMany(
84
95
  //@ts-expect-error
85
96
  wheres,
86
97
  {
87
98
  $set: update
88
- },
89
- { returnDocument: "after" }
99
+ }
90
100
  );
91
- return removeMongoId(res);
101
+ return {};
92
102
  },
93
103
  async delete(data) {
94
104
  const { model, where } = data;
@@ -1,4 +1,4 @@
1
- import { A as Adapter } from '../index-DyhG32S0.js';
1
+ import { A as Adapter } from '../index-BQ_rbsXC.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import '../types-IzAbV4nB.js';
@@ -81,7 +81,13 @@ var prismaAdapter = (prisma, {
81
81
  async update(data) {
82
82
  const { model, where, update } = data;
83
83
  const whereClause = whereConvertor(where);
84
- return await db[model].update({
84
+ if (where.length === 1) {
85
+ return await db[model].update({
86
+ where: whereClause,
87
+ data: update
88
+ });
89
+ }
90
+ return await db[model].updateMany({
85
91
  where: whereClause,
86
92
  data: update
87
93
  });
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-DyhG32S0.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-BQ_rbsXC.js';
2
2
  import './helper-DPDj8Nix.js';
3
3
  import 'zod';
4
4
  export { APIError } from 'better-call';
package/dist/api.js CHANGED
@@ -2599,7 +2599,7 @@ function getEndpoints(ctx, options) {
2599
2599
  };
2600
2600
  let api = {};
2601
2601
  for (const [key, value] of Object.entries(endpoints)) {
2602
- api[key] = async (context) => {
2602
+ api[key] = async (context = {}) => {
2603
2603
  let c = await ctx;
2604
2604
  for (const plugin of options.plugins || []) {
2605
2605
  if (plugin.hooks?.before) {
@@ -2614,7 +2614,7 @@ function getEndpoints(ctx, options) {
2614
2614
  ...context,
2615
2615
  context: {
2616
2616
  ...c,
2617
- ...context.context
2617
+ ...context?.context
2618
2618
  }
2619
2619
  });
2620
2620
  if (hookRes && "context" in hookRes) {
@@ -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, k 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 } from '../index-D9nYnMiJ.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-D9nYnMiJ.js';
5
+ import { o as organization, k 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 } from '../index-7R4SuAdU.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-7R4SuAdU.js';
7
7
  import { P as Prettify } from '../helper-DPDj8Nix.js';
8
- import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-DyhG32S0.js';
8
+ import { F as FieldAttribute, B as BetterAuthOptions, b as BetterAuthPlugin } from '../index-BQ_rbsXC.js';
9
9
  import '../types-IzAbV4nB.js';
10
10
  import 'zod';
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 './index-DyhG32S0.js';
9
+ import './index-BQ_rbsXC.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-DyhG32S0.js';
8
+ import { H as HookEndpointContext, g as AuthContext } from './index-BQ_rbsXC.js';
9
9
  import * as nanostores from 'nanostores';
10
10
  import { atom } from 'nanostores';
11
11
  import * as _simplewebauthn_types from '@simplewebauthn/types';
@@ -488,7 +488,7 @@ type BetterAuthPlugin = {
488
488
  */
489
489
  type Where = {
490
490
  operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte";
491
- value: string;
491
+ value: string | number | boolean;
492
492
  field: string;
493
493
  connector?: "AND" | "OR";
494
494
  };
@@ -517,6 +517,10 @@ interface Adapter {
517
517
  };
518
518
  offset?: number;
519
519
  }) => Promise<T[]>;
520
+ /**
521
+ * ⚠︎ Update may not return the updated data
522
+ * if multiple where clauses are provided
523
+ */
520
524
  update: <T>(data: {
521
525
  model: string;
522
526
  where: Where[];
@@ -3388,7 +3392,9 @@ declare function getEndpoints<C extends AuthContext, Option extends BetterAuthOp
3388
3392
  method: better_call.Method | better_call.Method[];
3389
3393
  headers: Headers;
3390
3394
  };
3391
- } & UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T["endpoints"] : {} : {}>;
3395
+ } & UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T extends {
3396
+ endpoints: infer E;
3397
+ } ? E : {} : {} : {}>;
3392
3398
  middlewares: {
3393
3399
  path: string;
3394
3400
  middleware: Endpoint;
@@ -4477,7 +4483,9 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
4477
4483
  method: better_call.Method | better_call.Method[];
4478
4484
  headers: Headers;
4479
4485
  };
4480
- } & UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T["endpoints"] : {} : {}>;
4486
+ } & UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T extends {
4487
+ endpoints: infer E;
4488
+ } ? E : {} : {} : {}>;
4481
4489
  };
4482
4490
 
4483
4491
  type InferAPI<API> = Omit<API, API extends {
@@ -5568,7 +5576,9 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
5568
5576
  method: better_call.Method | better_call.Method[];
5569
5577
  headers: Headers;
5570
5578
  };
5571
- } & UnionToIntersection<O["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T["endpoints"] : {} : {}>>;
5579
+ } & UnionToIntersection<O["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T extends {
5580
+ endpoints: infer E;
5581
+ } ? E : {} : {} : {}>>;
5572
5582
  options: O;
5573
5583
  $Infer: {
5574
5584
  Session: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a as Auth, a0 as betterAuth } from './index-DyhG32S0.js';
1
+ export { a as Auth, a0 as betterAuth } from './index-BQ_rbsXC.js';
2
2
  import 'zod';
3
3
  import 'kysely';
4
4
  import './types-IzAbV4nB.js';
package/dist/index.js CHANGED
@@ -2705,7 +2705,7 @@ function getEndpoints(ctx, options) {
2705
2705
  };
2706
2706
  let api = {};
2707
2707
  for (const [key, value] of Object.entries(endpoints)) {
2708
- api[key] = async (context) => {
2708
+ api[key] = async (context = {}) => {
2709
2709
  let c = await ctx;
2710
2710
  for (const plugin of options.plugins || []) {
2711
2711
  if (plugin.hooks?.before) {
@@ -2720,7 +2720,7 @@ function getEndpoints(ctx, options) {
2720
2720
  ...context,
2721
2721
  context: {
2722
2722
  ...c,
2723
- ...context.context
2723
+ ...context?.context
2724
2724
  }
2725
2725
  });
2726
2726
  if (hookRes && "context" in hookRes) {
package/dist/next-js.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Auth } from './index-DyhG32S0.js';
1
+ import { a as Auth } from './index-BQ_rbsXC.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-DyhG32S0.js';
2
+ import { a as Auth } from './index-BQ_rbsXC.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, j as genericOAuth, 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-D9nYnMiJ.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, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-7R4SuAdU.js';
2
2
  export { i as ac } from './index-DfAHOgpj.js';
3
- import { H as HookEndpointContext } from './index-DyhG32S0.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-DyhG32S0.js';
3
+ import { H as HookEndpointContext } from './index-BQ_rbsXC.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-BQ_rbsXC.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-DyhG32S0.js';
6
+ import './index-BQ_rbsXC.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-DyhG32S0.js';
1
+ import { a as Auth } from './index-BQ_rbsXC.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-DyhG32S0.js';
6
+ import './index-BQ_rbsXC.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-DyhG32S0.js';
1
+ import { a as Auth, B as BetterAuthOptions } from './index-BQ_rbsXC.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-DyhG32S0.js';
6
+ import './index-BQ_rbsXC.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-DyhG32S0.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-DyhG32S0.js';
1
+ import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-BQ_rbsXC.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-BQ_rbsXC.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-DyhG32S0.js';
6
+ import './index-BQ_rbsXC.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.9-beta.8",
3
+ "version": "0.4.9-beta.9",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "repository": {