better-auth 1.6.0 → 1.6.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 { Prettify as Prettify$1, UnionToIntersection } from "../types/helper.mjs";
1
+ import { OverrideMerge, Prettify as Prettify$1, UnionToIntersection } from "../types/helper.mjs";
2
2
  import { AdditionalSessionFieldsInput, AdditionalUserFieldsInput } from "../types/models.mjs";
3
3
  import { getIp } from "../utils/get-request-ip.mjs";
4
4
  import { isAPIError } from "../utils/is-api-error.mjs";
@@ -31,7 +31,7 @@ import * as zod_v4_core0 from "zod/v4/core";
31
31
  //#region src/api/index.d.ts
32
32
  declare function checkEndpointConflicts(options: BetterAuthOptions, logger: InternalLogger): void;
33
33
  declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<AuthContext>, options: Option): {
34
- api: Omit<{
34
+ api: OverrideMerge<{
35
35
  readonly ok: better_call0.StrictEndpoint<"/ok", {
36
36
  method: "GET";
37
37
  metadata: {
@@ -2007,11 +2007,9 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
2007
2007
  user: _better_auth_core_oauth20.OAuth2UserInfo;
2008
2008
  data: Record<string, any>;
2009
2009
  } | null>;
2010
- }, keyof UnionToIntersection<Option["plugins"] extends (infer T_10)[] ? T_10 extends BetterAuthPlugin ? T_10 extends {
2010
+ }, UnionToIntersection<Option["plugins"] extends (infer T_10)[] ? T_10 extends BetterAuthPlugin ? T_10 extends {
2011
2011
  endpoints: infer E;
2012
- } ? E : {} : {} : {}>> & UnionToIntersection<Option["plugins"] extends (infer T_10)[] ? T_10 extends BetterAuthPlugin ? T_10 extends {
2013
- endpoints: infer E;
2014
- } ? E : {} : {} : {}>;
2012
+ } ? E : {} : {} : {}>>;
2015
2013
  middlewares: {
2016
2014
  path: string;
2017
2015
  middleware: any;
@@ -2019,7 +2017,11 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
2019
2017
  };
2020
2018
  declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, options: Option) => {
2021
2019
  handler: (request: Request) => Promise<Response>;
2022
- endpoints: Omit<{
2020
+ endpoints: UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T extends {
2021
+ endpoints: infer E;
2022
+ } ? E : {} : {} : {}> extends infer T_1 ? T_1 extends UnionToIntersection<Option["plugins"] extends (infer T)[] ? T extends BetterAuthPlugin ? T extends {
2023
+ endpoints: infer E;
2024
+ } ? E : {} : {} : {}> ? T_1 extends unknown ? Prettify$1<({
2023
2025
  readonly ok: better_call0.StrictEndpoint<"/ok", {
2024
2026
  method: "GET";
2025
2027
  metadata: {
@@ -2139,7 +2141,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2139
2141
  emailVerified: boolean;
2140
2142
  name: string;
2141
2143
  image?: string | null | undefined;
2142
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T ? { [K in keyof T]: T[K] } : never) | undefined;
2144
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_3 ? { [K_1 in keyof T_3]: T_3[K_1] } : never) | undefined;
2143
2145
  };
2144
2146
  };
2145
2147
  openapi: {
@@ -2192,7 +2194,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2192
2194
  emailVerified: boolean;
2193
2195
  name: string;
2194
2196
  image?: string | null | undefined;
2195
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_1 ? { [K in keyof T_1]: T_1[K] } : never;
2197
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_4 ? { [K_1 in keyof T_4]: T_4[K_1] } : never;
2196
2198
  }>;
2197
2199
  readonly callbackOAuth: better_call0.StrictEndpoint<"/callback/:id", {
2198
2200
  method: ("GET" | "POST")[];
@@ -2264,7 +2266,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2264
2266
  token: string;
2265
2267
  ipAddress?: string | null | undefined;
2266
2268
  userAgent?: string | null | undefined;
2267
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["session"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"session", Option["plugins"]> extends infer T_2 ? { [K_1 in keyof T_2]: T_2[K_1] } : never;
2269
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["session"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"session", Option["plugins"]> extends infer T_5 ? { [K_2 in keyof T_5]: T_5[K_2] } : never;
2268
2270
  user: {
2269
2271
  id: string;
2270
2272
  createdAt: Date;
@@ -2273,7 +2275,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2273
2275
  emailVerified: boolean;
2274
2276
  name: string;
2275
2277
  image?: string | null | undefined;
2276
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_3 ? { [K in keyof T_3]: T_3[K] } : never;
2278
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_6 ? { [K_1 in keyof T_6]: T_6[K_1] } : never;
2277
2279
  } | null>;
2278
2280
  readonly signOut: better_call0.StrictEndpoint<"/sign-out", {
2279
2281
  method: "POST";
@@ -2338,7 +2340,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2338
2340
  emailVerified: boolean;
2339
2341
  name: string;
2340
2342
  image?: string | null | undefined;
2341
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_4 ? { [K in keyof T_4]: T_4[K] } : never;
2343
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_7 ? { [K_1 in keyof T_7]: T_7[K_1] } : never;
2342
2344
  };
2343
2345
  };
2344
2346
  openapi: {
@@ -2466,7 +2468,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2466
2468
  emailVerified: boolean;
2467
2469
  name: string;
2468
2470
  image?: string | null | undefined;
2469
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_5 ? { [K in keyof T_5]: T_5[K] } : never;
2471
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_8 ? { [K_1 in keyof T_8]: T_8[K_1] } : never;
2470
2472
  } | {
2471
2473
  token: string;
2472
2474
  user: {
@@ -2477,7 +2479,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2477
2479
  emailVerified: boolean;
2478
2480
  name: string;
2479
2481
  image?: string | null | undefined;
2480
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_6 ? { [K in keyof T_6]: T_6[K] } : never;
2482
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_9 ? { [K_1 in keyof T_9]: T_9[K_1] } : never;
2481
2483
  }>;
2482
2484
  readonly signInEmail: better_call0.StrictEndpoint<"/sign-in/email", {
2483
2485
  method: "POST";
@@ -2510,7 +2512,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2510
2512
  emailVerified: boolean;
2511
2513
  name: string;
2512
2514
  image?: string | null | undefined;
2513
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_7 ? { [K in keyof T_7]: T_7[K] } : never;
2515
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_10 ? { [K_1 in keyof T_10]: T_10[K_1] } : never;
2514
2516
  };
2515
2517
  };
2516
2518
  openapi: {
@@ -2562,7 +2564,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
2562
2564
  emailVerified: boolean;
2563
2565
  name: string;
2564
2566
  image?: string | null | undefined;
2565
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_8 ? { [K in keyof T_8]: T_8[K] } : never;
2567
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["user"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"user", Option["plugins"]> extends infer T_11 ? { [K_1 in keyof T_11]: T_11[K_1] } : never;
2566
2568
  }>;
2567
2569
  readonly resetPassword: better_call0.StrictEndpoint<"/reset-password", {
2568
2570
  method: "POST";
@@ -3374,7 +3376,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3374
3376
  token: string;
3375
3377
  ipAddress?: string | null | undefined;
3376
3378
  userAgent?: string | null | undefined;
3377
- } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["session"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"session", Option["plugins"]> extends infer T_9 ? { [K_1 in keyof T_9]: T_9[K_1] } : never>[]>;
3379
+ } & _better_auth_core_db0.InferDBFieldsFromOptions<Option["session"]> & _better_auth_core_db0.InferDBFieldsFromPlugins<"session", Option["plugins"]> extends infer T_12 ? { [K_2 in keyof T_12]: T_12[K_2] } : never>[]>;
3378
3380
  readonly revokeSession: better_call0.StrictEndpoint<"/revoke-session", {
3379
3381
  method: "POST";
3380
3382
  body: zod.ZodObject<{
@@ -3995,11 +3997,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
3995
3997
  user: _better_auth_core_oauth20.OAuth2UserInfo;
3996
3998
  data: Record<string, any>;
3997
3999
  } | null>;
3998
- }, keyof UnionToIntersection<Option["plugins"] extends (infer T_10)[] ? T_10 extends BetterAuthPlugin ? T_10 extends {
3999
- endpoints: infer E;
4000
- } ? E : {} : {} : {}>> & UnionToIntersection<Option["plugins"] extends (infer T_10)[] ? T_10 extends BetterAuthPlugin ? T_10 extends {
4001
- endpoints: infer E;
4002
- } ? E : {} : {} : {}>;
4000
+ } extends infer T_2 ? { [K in keyof T_2 as K extends keyof T_1 ? never : K]: T_2[K] } : never) & T_1> : never : never : never;
4003
4001
  };
4004
4002
  //#endregion
4005
4003
  export { APIError, type AuthEndpoint, type AuthMiddleware, accountInfo, callbackOAuth, changeEmail, changePassword, checkEndpointConflicts, createAuthEndpoint, createAuthMiddleware, createEmailVerificationToken, deleteUser, deleteUserCallback, error, formCsrfMiddleware, freshSessionMiddleware, getAccessToken, getEndpoints, getIp, getOAuthState, getSession, getSessionFromCtx, getShouldSkipSessionRefresh, isAPIError, linkSocialAccount, listSessions, listUserAccounts, ok, optionsMiddleware, originCheck, originCheckMiddleware, refreshToken, requestOnlySessionMiddleware, requestPasswordReset, requestPasswordResetCallback, requireOrgRole, requireResourceOwnership, resetPassword, revokeOtherSessions, revokeSession, revokeSessions, router, sendVerificationEmail, sendVerificationEmailFn, sensitiveSessionMiddleware, sessionMiddleware, setPassword, setShouldSkipSessionRefresh, signInEmail, signInSocial, signOut, signUpEmail, unlinkAccount, updateSession, updateUser, verifyEmail, verifyPassword };
@@ -165,10 +165,9 @@ const router = (ctx, options) => {
165
165
  if (disabledPaths.includes(normalizedPath)) return new Response("Not Found", { status: 404 });
166
166
  let currentRequest = req;
167
167
  for (const plugin of ctx.options.plugins || []) if (plugin.onRequest) {
168
- const response = await withSpan(`onRequest ${normalizedPath} ${plugin.id}`, {
168
+ const response = await withSpan(`onRequest ${plugin.id}`, {
169
169
  [ATTR_HOOK_TYPE]: "onRequest",
170
- [ATTR_CONTEXT]: `plugin:${plugin.id}`,
171
- [ATTR_HTTP_ROUTE]: normalizedPath
170
+ [ATTR_CONTEXT]: `plugin:${plugin.id}`
172
171
  }, () => plugin.onRequest(currentRequest, ctx));
173
172
  if (response && "response" in response) return response.response;
174
173
  if (response && "request" in response) currentRequest = response.request;
@@ -179,12 +178,10 @@ const router = (ctx, options) => {
179
178
  },
180
179
  async onResponse(res, req) {
181
180
  await onResponseRateLimit(req, ctx);
182
- const normalizedPath = normalizePathname(req.url, basePath);
183
181
  for (const plugin of ctx.options.plugins || []) if (plugin.onResponse) {
184
- const response = await withSpan(`onResponse ${normalizedPath} ${plugin.id}`, {
182
+ const response = await withSpan(`onResponse ${plugin.id}`, {
185
183
  [ATTR_HOOK_TYPE]: "onResponse",
186
184
  [ATTR_CONTEXT]: `plugin:${plugin.id}`,
187
- [ATTR_HTTP_ROUTE]: normalizedPath,
188
185
  [ATTR_HTTP_RESPONSE_STATUS_CODE]: res.status
189
186
  }, () => plugin.onResponse(res, ctx));
190
187
  if (response) return response.response;
@@ -28,7 +28,7 @@ function toAuthEndpoints(endpoints, ctx) {
28
28
  const run = async () => {
29
29
  const authContext = await ctx;
30
30
  const methodName = context?.method ?? context?.request?.method ?? defaultMethod ?? "?";
31
- const pathName = context?.path ?? endpoint.path ?? "/:virtual";
31
+ const route = endpoint.path ?? "/:virtual";
32
32
  let internalContext = {
33
33
  ...context,
34
34
  context: {
@@ -42,8 +42,8 @@ function toAuthEndpoints(endpoints, ctx) {
42
42
  };
43
43
  const hasRequest = context?.request instanceof Request;
44
44
  const shouldReturnResponse = context?.asResponse ?? hasRequest;
45
- return withSpan(`${methodName} ${pathName}`, {
46
- [ATTR_HTTP_ROUTE]: pathName,
45
+ return withSpan(`${methodName} ${route}`, {
46
+ [ATTR_HTTP_ROUTE]: route,
47
47
  [ATTR_OPERATION_ID]: operationId
48
48
  }, async () => runWithEndpointContext(internalContext, async () => {
49
49
  const { beforeHooks, afterHooks } = getHooks(authContext);
@@ -70,8 +70,8 @@ function toAuthEndpoints(endpoints, ctx) {
70
70
  internalContext.asResponse = false;
71
71
  internalContext.returnHeaders = true;
72
72
  internalContext.returnStatus = true;
73
- const result = await runWithEndpointContext(internalContext, () => withSpan(`handler ${pathName}`, {
74
- [ATTR_HTTP_ROUTE]: pathName,
73
+ const result = await runWithEndpointContext(internalContext, () => withSpan(`handler ${route}`, {
74
+ [ATTR_HTTP_ROUTE]: route,
75
75
  [ATTR_OPERATION_ID]: operationId
76
76
  }, () => endpoint(internalContext))).catch((e) => {
77
77
  if (isAPIError(e))
@@ -130,10 +130,10 @@ async function runBeforeHooks(context, hooks, endpoint, operationId) {
130
130
  }
131
131
  if (matched) {
132
132
  const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
133
- const path = context.path ?? endpoint?.path ?? "/:virtual";
134
- const result = await withSpan(`hook before ${path} ${hookSource}`, {
133
+ const route = endpoint.path ?? "/:virtual";
134
+ const result = await withSpan(`hook before ${route} ${hookSource}`, {
135
135
  [ATTR_HOOK_TYPE]: "before",
136
- [ATTR_HTTP_ROUTE]: path,
136
+ [ATTR_HTTP_ROUTE]: route,
137
137
  [ATTR_CONTEXT]: hookSource,
138
138
  [ATTR_OPERATION_ID]: operationId
139
139
  }, () => hook.handler({
@@ -162,10 +162,10 @@ async function runBeforeHooks(context, hooks, endpoint, operationId) {
162
162
  async function runAfterHooks(context, hooks, endpoint, operationId) {
163
163
  for (const hook of hooks) if (hook.matcher(context)) {
164
164
  const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
165
- const path = context.path ?? endpoint?.path ?? "/:virtual";
166
- const result = await withSpan(`hook after ${path} ${hookSource}`, {
165
+ const route = endpoint.path ?? "/:virtual";
166
+ const result = await withSpan(`hook after ${route} ${hookSource}`, {
167
167
  [ATTR_HOOK_TYPE]: "after",
168
- [ATTR_HTTP_ROUTE]: path,
168
+ [ATTR_HTTP_ROUTE]: route,
169
169
  [ATTR_CONTEXT]: hookSource,
170
170
  [ATTR_OPERATION_ID]: operationId
171
171
  }, () => hook.handler(context)).catch((e) => {
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../types/helper.mjs";
2
2
  import { CamelCase, InferCtx, InferRoute, InferRoutes, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest } from "./path-to-object.mjs";
3
3
  import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "./types.mjs";
4
4
  import { BroadcastChannel, BroadcastListener, BroadcastMessage, getGlobalBroadcastChannel, kBroadcastChannel } from "./broadcast-channel.mjs";
@@ -31,4 +31,4 @@ declare function InferAuth<O extends {
31
31
  options: BetterAuthOptions;
32
32
  }>(): O["options"];
33
33
  //#endregion
34
- export { AccessControl, ArrayElement, AuthClient, AuthQueryAtom, AuthorizeResponse, BetterAuthClientOptions, BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, CamelCase, ClientAtomListener, ClientStore, type DBPrimitive, DefaultOrganizationPlugin, DynamicAccessControlEndpoints, ExtractPluginField, type FocusListener, type FocusManager, HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, InferCtx, InferErrorCodes, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPlugin, InferPluginFieldFromTuple, InferRoute, InferRoutes, InferSessionFromClient, InferSignUpEmailCtx, InferTeam, InferUserFromClient, InferUserUpdateCtx, Invitation, InvitationInput, InvitationStatus, IsAny, IsSignal, Member, MemberInput, MergeRoutes, type OnlineListener, type OnlineManager, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, PathToObject, Prettify, PrettifyDeep, ProxyRequest, RequiredKeysOf, Role, SessionQueryParams, SessionRefreshOptions, SessionResponse, Statements, StripEmptyObjects, SubArray, Subset, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, type UnionToIntersection, createAccessControl, createAuthClient, createSessionRefreshManager, defaultRolesSchema, getGlobalBroadcastChannel, getOrgAdapter, hasPermission, invitationSchema, invitationStatus, kBroadcastChannel, kFocusManager, kOnlineManager, memberSchema, organization, organizationRoleSchema, organizationSchema, parseJSON, parseRoles, role, roleSchema, teamMemberSchema, teamSchema, useAuthQuery };
34
+ export { AccessControl, ArrayElement, AuthClient, AuthQueryAtom, AuthorizeResponse, BetterAuthClientOptions, BetterAuthClientPlugin, BroadcastChannel, BroadcastListener, BroadcastMessage, CamelCase, ClientAtomListener, ClientStore, type DBPrimitive, DefaultOrganizationPlugin, DynamicAccessControlEndpoints, ExtractPluginField, type FocusListener, type FocusManager, HasRequiredKeys, InferActions, InferAdditionalFromClient, InferAuth, InferClientAPI, InferCtx, InferErrorCodes, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPlugin, InferPluginFieldFromTuple, InferRoute, InferRoutes, InferSessionFromClient, InferSignUpEmailCtx, InferTeam, InferUserFromClient, InferUserUpdateCtx, Invitation, InvitationInput, InvitationStatus, IsAny, IsSignal, Member, MemberInput, MergeRoutes, type OnlineListener, type OnlineManager, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, OverrideMerge, PathToObject, Prettify, PrettifyDeep, ProxyRequest, RequiredKeysOf, Role, SessionQueryParams, SessionRefreshOptions, SessionResponse, Statements, StripEmptyObjects, SubArray, Subset, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, type UnionToIntersection, createAccessControl, createAuthClient, createSessionRefreshManager, defaultRolesSchema, getGlobalBroadcastChannel, getOrgAdapter, hasPermission, invitationSchema, invitationStatus, kBroadcastChannel, kFocusManager, kOnlineManager, memberSchema, organization, organizationRoleSchema, organizationSchema, parseJSON, parseRoles, role, roleSchema, teamMemberSchema, teamSchema, useAuthQuery };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
3
  import { useStore } from "./lynx-store.mjs";
4
4
  import { BetterAuthClientOptions, BetterAuthClientPlugin } from "@better-auth/core";
@@ -123,4 +123,4 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
123
123
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
124
124
  };
125
125
  //#endregion
126
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
126
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferTeam, Invitation, InvitationInput, InvitationStatus, Member, MemberInput, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, Team, TeamInput, TeamMember, TeamMemberInput, defaultRolesSchema, invitationSchema, invitationStatus, memberSchema, organizationRoleSchema, organizationSchema, roleSchema, teamMemberSchema, teamSchema } from "../../plugins/organization/schema.mjs";
3
3
  import { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole } from "../../plugins/admin/types.mjs";
4
4
  import { schema } from "../../plugins/anonymous/schema.mjs";
@@ -52,4 +52,4 @@ import { phoneNumberClient } from "../../plugins/phone-number/client.mjs";
52
52
  import { siweClient } from "../../plugins/siwe/client.mjs";
53
53
  import { usernameClient } from "../../plugins/username/client.mjs";
54
54
  import { InferServerPlugin } from "./infer-plugin.mjs";
55
- export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminOptions, AnonymousOptions, AnonymousSession, Auth0Options, AuthorizationQuery, BackupCodeOptions, BaseOAuthProviderOptions, Client, CodeVerificationValue, EMAIL_OTP_ERROR_CODES, ExtractPluginField, GENERIC_OAUTH_ERROR_CODES, GenericOAuthConfig, GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, GumroadOptions, HasRequiredKeys, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginFieldFromTuple, InferServerPlugin, InferTeam, Invitation, InvitationInput, InvitationStatus, IsAny, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodClientConfig, LineOptions, MULTI_SESSION_ERROR_CODES, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAuthAccessToken, OIDCMetadata, OIDCOptions, ORGANIZATION_ERROR_CODES, OTPOptions, OidcClientPlugin, OktaOptions, OneTimeTokenOptions, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, PHONE_NUMBER_ERROR_CODES, PatreonOptions, PhoneNumberOptions, Prettify, PrettifyDeep, RequiredKeysOf, SessionWithImpersonatedBy, SlackOptions, StripEmptyObjects, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamInput, TeamMember, TeamMemberInput, TokenBody, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UnionToIntersection, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, adminClient, anonymousClient, auth0, backupCode2fa, clientSideHasPermission, customSessionClient, defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, generateBackupCodes, genericOAuthClient, getBackupCodes, gumroad, hubspot, inferAdditionalFields, inferOrgAdditionalFields, invitationSchema, invitationStatus, jwtClient, keycloak, lastLoginMethodClient, line, magicLinkClient, memberSchema, microsoftEntraId, multiSessionClient, oidcClient, okta, oneTapClient, oneTimeTokenClient, organizationClient, organizationRoleSchema, organizationSchema, otp2fa, patreon, phoneNumberClient, roleSchema, schema, siweClient, slack, teamMemberSchema, teamSchema, totp2fa, twoFactorClient, usernameClient, verifyBackupCode };
55
+ export { ADMIN_ERROR_CODES, ANONYMOUS_ERROR_CODES, AdminOptions, AnonymousOptions, AnonymousSession, Auth0Options, AuthorizationQuery, BackupCodeOptions, BaseOAuthProviderOptions, Client, CodeVerificationValue, EMAIL_OTP_ERROR_CODES, ExtractPluginField, GENERIC_OAUTH_ERROR_CODES, GenericOAuthConfig, GenericOAuthOptions, GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, GumroadOptions, HasRequiredKeys, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginFieldFromTuple, InferServerPlugin, InferTeam, Invitation, InvitationInput, InvitationStatus, IsAny, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodClientConfig, LineOptions, MULTI_SESSION_ERROR_CODES, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAuthAccessToken, OIDCMetadata, OIDCOptions, ORGANIZATION_ERROR_CODES, OTPOptions, OidcClientPlugin, OktaOptions, OneTimeTokenOptions, Organization, OrganizationInput, OrganizationRole, OrganizationSchema, OverrideMerge, PHONE_NUMBER_ERROR_CODES, PatreonOptions, PhoneNumberOptions, Prettify, PrettifyDeep, RequiredKeysOf, SessionWithImpersonatedBy, SlackOptions, StripEmptyObjects, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamInput, TeamMember, TeamMemberInput, TokenBody, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UnionToIntersection, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, adminClient, anonymousClient, auth0, backupCode2fa, clientSideHasPermission, customSessionClient, defaultRolesSchema, deviceAuthorizationClient, emailOTPClient, generateBackupCodes, genericOAuthClient, getBackupCodes, gumroad, hubspot, inferAdditionalFields, inferOrgAdditionalFields, invitationSchema, invitationStatus, jwtClient, keycloak, lastLoginMethodClient, line, magicLinkClient, memberSchema, microsoftEntraId, multiSessionClient, oidcClient, okta, oneTapClient, oneTimeTokenClient, organizationClient, organizationRoleSchema, organizationSchema, otp2fa, patreon, phoneNumberClient, roleSchema, schema, siweClient, slack, teamMemberSchema, teamSchema, totp2fa, twoFactorClient, usernameClient, verifyBackupCode };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
3
  import { useStore } from "./react-store.mjs";
4
4
  import { BetterAuthClientOptions, BetterAuthClientPlugin } from "@better-auth/core";
@@ -124,4 +124,4 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
124
124
  $ERROR_CODES: InferErrorCodes<Option> & typeof BASE_ERROR_CODES;
125
125
  };
126
126
  //#endregion
127
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
127
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient, useStore };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
3
  import { BetterAuthClientOptions, BetterAuthClientPlugin } from "@better-auth/core";
4
4
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
@@ -118,4 +118,4 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
118
118
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
119
119
  };
120
120
  //#endregion
121
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
121
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
3
  import { BetterAuthClientOptions, BetterAuthClientPlugin } from "@better-auth/core";
4
4
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
@@ -124,4 +124,4 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
124
124
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
125
125
  };
126
126
  //#endregion
127
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
127
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "../../types/helper.mjs";
2
2
  import { InferActions, InferClientAPI, InferErrorCodes, IsSignal, SessionQueryParams } from "../types.mjs";
3
3
  import { BetterAuthClientOptions, BetterAuthClientPlugin } from "@better-auth/core";
4
4
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
@@ -147,4 +147,4 @@ declare function createAuthClient<Option extends BetterAuthClientOptions>(option
147
147
  $ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
148
148
  };
149
149
  //#endregion
150
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
150
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, type UnionToIntersection, createAuthClient };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "./types/helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "./types/helper.mjs";
2
2
  import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "./client/types.mjs";
3
3
  import { DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where } from "./types/adapter.mjs";
4
4
  import { FilteredAPI, InferAPI, InferSessionAPI } from "./types/api.mjs";
@@ -27,4 +27,4 @@ export * from "@better-auth/core/utils/json";
27
27
  export * from "@better-auth/core/social-providers";
28
28
  export * from "better-call";
29
29
  export * from "zod";
30
- export { APIError, Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, HIDE_METADATA, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, type JSONWebKeySet, type JWTPayload, JoinConfig, JoinOption, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StandardSchemaV1, StateData, StoreIdentifierOption, StripEmptyObjects, type TelemetryEvent, UnionToIntersection, User, Verification, Where, betterAuth, createTelemetry, generateGenericState, generateState, getBaseURL, getCurrentAdapter, getHost, getHostFromRequest, getOrigin, getProtocol, getProtocolFromRequest, getTelemetryAuthConfig, isDynamicBaseURLConfig, matchesHostPattern, parseGenericState, parseState, resolveBaseURL, resolveDynamicBaseURL };
30
+ export { APIError, Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, HIDE_METADATA, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, type JSONWebKeySet, type JWTPayload, JoinConfig, JoinOption, OverrideMerge, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StandardSchemaV1, StateData, StoreIdentifierOption, StripEmptyObjects, type TelemetryEvent, UnionToIntersection, User, Verification, Where, betterAuth, createTelemetry, generateGenericState, generateState, getBaseURL, getCurrentAdapter, getHost, getHostFromRequest, getOrigin, getProtocol, getProtocolFromRequest, getTelemetryAuthConfig, isDynamicBaseURLConfig, matchesHostPattern, parseGenericState, parseState, resolveBaseURL, resolveDynamicBaseURL };
package/dist/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.6.0";
2
+ var version = "1.6.1";
3
3
  //#endregion
4
4
  export { version };
@@ -43,7 +43,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
43
43
  fetchOptions: {
44
44
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
45
45
  };
46
- })["plugins"] extends any[] ? Omit<InferAPI<Omit<{
46
+ })["plugins"] extends any[] ? Omit<InferAPI<Prettify$1<{
47
47
  readonly ok: better_call0.StrictEndpoint<"/ok", {
48
48
  method: "GET";
49
49
  metadata: {
@@ -2019,7 +2019,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
2019
2019
  user: _better_auth_core_oauth20.OAuth2UserInfo;
2020
2020
  data: Record<string, any>;
2021
2021
  } | null>;
2022
- }, never>>, keyof (((C extends undefined ? {} : C) & {
2022
+ }>>, keyof (((C extends undefined ? {} : C) & {
2023
2023
  baseURL: string | undefined;
2024
2024
  fetchOptions: {
2025
2025
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -2047,7 +2047,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
2047
2047
  $InferServerPlugin: infer Plug;
2048
2048
  } ? Plug extends {
2049
2049
  endpoints: infer Endpoints;
2050
- } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Omit<{
2050
+ } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
2051
2051
  readonly ok: better_call0.StrictEndpoint<"/ok", {
2052
2052
  method: "GET";
2053
2053
  metadata: {
@@ -4023,7 +4023,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
4023
4023
  user: _better_auth_core_oauth20.OAuth2UserInfo;
4024
4024
  data: Record<string, any>;
4025
4025
  } | null>;
4026
- }, never>>, (C extends undefined ? {} : C) & {
4026
+ }>>, (C extends undefined ? {} : C) & {
4027
4027
  baseURL: string | undefined;
4028
4028
  fetchOptions: {
4029
4029
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -4054,7 +4054,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
4054
4054
  fetchOptions: {
4055
4055
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
4056
4056
  };
4057
- })["plugins"] extends any[] ? Omit<InferAPI<Omit<{
4057
+ })["plugins"] extends any[] ? Omit<InferAPI<Prettify$1<{
4058
4058
  readonly ok: better_call0.StrictEndpoint<"/ok", {
4059
4059
  method: "GET";
4060
4060
  metadata: {
@@ -6030,7 +6030,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
6030
6030
  user: _better_auth_core_oauth20.OAuth2UserInfo;
6031
6031
  data: Record<string, any>;
6032
6032
  } | null>;
6033
- }, never>>, keyof (((C extends undefined ? {} : C) & {
6033
+ }>>, keyof (((C extends undefined ? {} : C) & {
6034
6034
  baseURL: string | undefined;
6035
6035
  fetchOptions: {
6036
6036
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -6058,7 +6058,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
6058
6058
  $InferServerPlugin: infer Plug;
6059
6059
  } ? Plug extends {
6060
6060
  endpoints: infer Endpoints;
6061
- } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Omit<{
6061
+ } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
6062
6062
  readonly ok: better_call0.StrictEndpoint<"/ok", {
6063
6063
  method: "GET";
6064
6064
  metadata: {
@@ -8034,7 +8034,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
8034
8034
  user: _better_auth_core_oauth20.OAuth2UserInfo;
8035
8035
  data: Record<string, any>;
8036
8036
  } | null>;
8037
- }, never>>, (C extends undefined ? {} : C) & {
8037
+ }>>, (C extends undefined ? {} : C) & {
8038
8038
  baseURL: string | undefined;
8039
8039
  fetchOptions: {
8040
8040
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -8136,7 +8136,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
8136
8136
  fetchOptions: {
8137
8137
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
8138
8138
  };
8139
- })["plugins"] extends any[] ? Omit<InferAPI<Omit<{
8139
+ })["plugins"] extends any[] ? Omit<InferAPI<Prettify$1<{
8140
8140
  readonly ok: better_call0.StrictEndpoint<"/ok", {
8141
8141
  method: "GET";
8142
8142
  metadata: {
@@ -10112,7 +10112,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
10112
10112
  user: _better_auth_core_oauth20.OAuth2UserInfo;
10113
10113
  data: Record<string, any>;
10114
10114
  } | null>;
10115
- }, never>>, keyof (((C extends undefined ? {} : C) & {
10115
+ }>>, keyof (((C extends undefined ? {} : C) & {
10116
10116
  baseURL: string | undefined;
10117
10117
  fetchOptions: {
10118
10118
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -10140,7 +10140,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
10140
10140
  $InferServerPlugin: infer Plug;
10141
10141
  } ? Plug extends {
10142
10142
  endpoints: infer Endpoints;
10143
- } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Omit<{
10143
+ } ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
10144
10144
  readonly ok: better_call0.StrictEndpoint<"/ok", {
10145
10145
  method: "GET";
10146
10146
  metadata: {
@@ -12116,7 +12116,7 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
12116
12116
  user: _better_auth_core_oauth20.OAuth2UserInfo;
12117
12117
  data: Record<string, any>;
12118
12118
  } | null>;
12119
- }, never>>, (C extends undefined ? {} : C) & {
12119
+ }>>, (C extends undefined ? {} : C) & {
12120
12120
  baseURL: string | undefined;
12121
12121
  fetchOptions: {
12122
12122
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
@@ -6,6 +6,13 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
6
6
  type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
7
7
  type HasRequiredKeys<BaseType> = IsAny<BaseType> extends true ? false : [BaseType] extends [object] ? RequiredKeysOf<BaseType & object> extends never ? false : true : false;
8
8
  type StripEmptyObjects<T extends object> = { [K in keyof T]: T[K] };
9
+ /**
10
+ * Object merge replacing `Base`'s keys with `Override`'s.
11
+ * The naive `Omit<Base, keyof Override> & Override` form breaks under generics.
12
+ *
13
+ * @see https://github.com/microsoft/TypeScript/issues/57466#issuecomment-1957988380
14
+ */
15
+ type OverrideMerge<Base, Override> = Base extends unknown ? Override extends unknown ? Prettify<{ [K in keyof Base as K extends keyof Override ? never : K]: Base[K] } & Override> : never : never;
9
16
  /**
10
17
  * Extracts a Record-typed field from a plugin, guarding against `any`.
11
18
  */
@@ -16,4 +23,4 @@ type ExtractPluginField<T, Field extends string> = IsAny<T> extends true ? {} :
16
23
  */
17
24
  type InferPluginFieldFromTuple<T extends readonly unknown[], Field extends string, Acc = {}> = T extends readonly [infer Head, ...infer Tail] ? InferPluginFieldFromTuple<Tail, Field, Acc & ExtractPluginField<Head, Field>> : Acc;
18
25
  //#endregion
19
- export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection };
26
+ export { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection };
@@ -1,4 +1,4 @@
1
- import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "./helper.mjs";
1
+ import { ExtractPluginField, HasRequiredKeys, InferPluginFieldFromTuple, IsAny, OverrideMerge, Prettify, PrettifyDeep, RequiredKeysOf, StripEmptyObjects, UnionToIntersection } from "./helper.mjs";
2
2
  import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientStore, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferSessionFromClient, InferUserFromClient, IsSignal, SessionQueryParams } from "../client/types.mjs";
3
3
  import { DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, JoinConfig, JoinOption, Where } from "./adapter.mjs";
4
4
  import { FilteredAPI, InferAPI, InferSessionAPI } from "./api.mjs";
@@ -7,4 +7,4 @@ import { InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPlug
7
7
  import { Auth } from "./auth.mjs";
8
8
  import { BetterAuthAdvancedOptions, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthRateLimitOptions, StoreIdentifierOption } from "@better-auth/core";
9
9
  export * from "@better-auth/core/social-providers";
10
- export { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, type BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, JoinConfig, JoinOption, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StoreIdentifierOption, StripEmptyObjects, UnionToIntersection, User, Verification, Where };
10
+ export { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, Auth, type BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, type BetterAuthCookies, type BetterAuthOptions, type BetterAuthPlugin, type BetterAuthRateLimitOptions, ClientAtomListener, ClientStore, DBAdapter, DBAdapterInstance, DBAdapterSchemaCreation, DBTransactionAdapter, ExtractPluginField, FilteredAPI, HasRequiredKeys, InferAPI, InferActions, InferAdditionalFromClient, InferClientAPI, InferErrorCodes, InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginFieldFromTuple, InferPluginIDs, InferPluginTypes, InferSessionAPI, InferSessionFromClient, InferUserFromClient, IsAny, IsSignal, JoinConfig, JoinOption, OverrideMerge, Prettify, PrettifyDeep, RateLimit, RequiredKeysOf, Session, SessionQueryParams, type StoreIdentifierOption, StripEmptyObjects, UnionToIntersection, User, Verification, Where };
@@ -12,10 +12,14 @@ async function validatePassword(ctx, data) {
12
12
  async function checkPassword(userId, c) {
13
13
  const credentialAccount = (await c.context.internalAdapter.findAccounts(userId))?.find((account) => account.providerId === "credential");
14
14
  const currentPassword = credentialAccount?.password;
15
- if (!credentialAccount || !currentPassword || !c.body.password) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.CREDENTIAL_ACCOUNT_NOT_FOUND);
15
+ const password = c.body.password;
16
+ if (!credentialAccount || !currentPassword || !password) {
17
+ if (password) await c.context.password.hash(password);
18
+ throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
19
+ }
16
20
  if (!await c.context.password.verify({
17
21
  hash: currentPassword,
18
- password: c.body.password
22
+ password
19
23
  })) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
20
24
  return true;
21
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -489,13 +489,13 @@
489
489
  "kysely": "^0.28.14",
490
490
  "nanostores": "^1.1.1",
491
491
  "zod": "^4.3.6",
492
- "@better-auth/core": "1.6.0",
493
- "@better-auth/drizzle-adapter": "1.6.0",
494
- "@better-auth/kysely-adapter": "1.6.0",
495
- "@better-auth/memory-adapter": "1.6.0",
496
- "@better-auth/mongo-adapter": "1.6.0",
497
- "@better-auth/prisma-adapter": "1.6.0",
498
- "@better-auth/telemetry": "1.6.0"
492
+ "@better-auth/core": "1.6.1",
493
+ "@better-auth/drizzle-adapter": "1.6.1",
494
+ "@better-auth/kysely-adapter": "1.6.1",
495
+ "@better-auth/memory-adapter": "1.6.1",
496
+ "@better-auth/mongo-adapter": "1.6.1",
497
+ "@better-auth/prisma-adapter": "1.6.1",
498
+ "@better-auth/telemetry": "1.6.1"
499
499
  },
500
500
  "devDependencies": {
501
501
  "@lynx-js/react": "^0.116.3",