better-auth 1.6.29 → 1.6.31

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.
@@ -4,7 +4,7 @@ import { runWithEndpointContext } from "@better-auth/core/context";
4
4
  import { shouldPublishLog } from "@better-auth/core/env";
5
5
  import { APIError } from "@better-auth/core/error";
6
6
  import { createDefu } from "defu";
7
- import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID, withSpan } from "@better-auth/core/instrumentation";
7
+ import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID, createWithSpan } from "@better-auth/core/instrumentation";
8
8
  import { kAPIErrorHeaderSymbol, toResponse } from "better-call";
9
9
  //#region src/api/dispatch.ts
10
10
  const defuReplaceArrays = createDefu((obj, key, value) => {
@@ -62,6 +62,7 @@ function mergeAPIErrorHeaders(error) {
62
62
  return headers;
63
63
  }
64
64
  async function runBeforeHooks(context, hooks, endpoint, operationId) {
65
+ const withSpan = createWithSpan(context.context.options);
65
66
  let modifiedContext = {};
66
67
  for (const hook of hooks) {
67
68
  let matched = false;
@@ -105,6 +106,7 @@ async function runBeforeHooks(context, hooks, endpoint, operationId) {
105
106
  return { context: modifiedContext };
106
107
  }
107
108
  async function runAfterHooks(context, hooks, endpoint, operationId) {
109
+ const withSpan = createWithSpan(context.context.options);
108
110
  for (const hook of hooks) {
109
111
  if (!hook.matcher(context)) continue;
110
112
  const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
@@ -182,6 +184,7 @@ function getHooks(authContext) {
182
184
  * @param input Input context whose `context` is an already-resolved `AuthContext`.
183
185
  */
184
186
  async function dispatchAuthEndpoint(endpoint, input) {
187
+ const withSpan = createWithSpan(input.context.options);
185
188
  const operationId = input.operationId ?? getOperationId(endpoint);
186
189
  const route = endpoint.path ?? "/:virtual";
187
190
  const endpointMethod = endpoint.options?.method;
@@ -21,7 +21,7 @@ import { toAuthEndpoints } from "./to-auth-endpoints.mjs";
21
21
  import { logger } from "@better-auth/core/env";
22
22
  import { APIError } from "@better-auth/core/error";
23
23
  import { getIp } from "@better-auth/core/utils/ip";
24
- import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, withSpan } from "@better-auth/core/instrumentation";
24
+ import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, createWithSpan } from "@better-auth/core/instrumentation";
25
25
  import { normalizePathname } from "@better-auth/core/utils/url";
26
26
  import { createRouter } from "better-call";
27
27
  import { createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "@better-auth/core/api";
@@ -82,6 +82,7 @@ To resolve this, you can:
82
82
  }
83
83
  }
84
84
  function getEndpoints(ctx, options) {
85
+ const withSpan = createWithSpan(options);
85
86
  const pluginEndpoints = options.plugins?.reduce((acc, plugin) => {
86
87
  return {
87
88
  ...acc,
@@ -148,6 +149,7 @@ function getEndpoints(ctx, options) {
148
149
  };
149
150
  }
150
151
  const router = (ctx, options) => {
152
+ const withSpan = createWithSpan(options);
151
153
  const { api, middlewares } = getEndpoints(ctx, options);
152
154
  const basePath = new URL(ctx.baseURL).pathname;
153
155
  return createRouter(api, {
@@ -7,7 +7,6 @@ import { handleOAuthUserInfo } from "../../oauth2/link-account.mjs";
7
7
  import { generateState } from "../../oauth2/state.mjs";
8
8
  import { safeCloneRequest } from "../../utils/request.mjs";
9
9
  import { createEmailVerificationToken } from "./email-verification.mjs";
10
- import "../../utils/index.mjs";
11
10
  import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
12
11
  import { SocialProviderListEnum } from "@better-auth/core/social-providers";
13
12
  import { createAuthEndpoint } from "@better-auth/core/api";
@@ -1,7 +1,8 @@
1
1
  import { getCurrentAdapter, getCurrentAuthContext, queueAfterTransactionHook } from "@better-auth/core/context";
2
- import { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_HOOK_TYPE, withSpan } from "@better-auth/core/instrumentation";
2
+ import { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_HOOK_TYPE, createWithSpan } from "@better-auth/core/instrumentation";
3
3
  //#region src/db/with-hooks.ts
4
4
  function getWithHooks(adapter, ctx) {
5
+ const withSpan = createWithSpan(ctx.options);
5
6
  const hooksEntries = ctx.hooks;
6
7
  async function createWithHooks(data, model, customCreateFn) {
7
8
  const context = await getCurrentAuthContext().catch(() => null);
package/dist/index.mjs CHANGED
@@ -2,7 +2,6 @@ import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProt
2
2
  import { generateGenericState, parseGenericState } from "./state.mjs";
3
3
  import { generateState, parseState } from "./oauth2/state.mjs";
4
4
  import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
5
- import "./utils/index.mjs";
6
5
  import { APIError } from "./api/index.mjs";
7
6
  import { betterAuth } from "./auth/full.mjs";
8
7
  import { getCurrentAdapter } from "@better-auth/core/context";
package/dist/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.6.29";
2
+ var version = "1.6.31";
3
3
  //#endregion
4
4
  export { version };
@@ -6,7 +6,6 @@ import { applyUpdateUserInfoOnLink, handleOAuthUserInfo } from "../../oauth2/lin
6
6
  import { generateState, parseState } from "../../oauth2/state.mjs";
7
7
  import { sessionMiddleware } from "../../api/routes/session.mjs";
8
8
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
9
- import "../../utils/index.mjs";
10
9
  import { APIError as APIError$1 } from "../../api/index.mjs";
11
10
  import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes.mjs";
12
11
  import { BASE_ERROR_CODES } from "@better-auth/core/error";
@@ -6,7 +6,6 @@ import { expireCookie } from "../../cookies/index.mjs";
6
6
  import { resolveDynamicTrustedProxyHeaders } from "../../context/helpers.mjs";
7
7
  import { getSessionFromCtx } from "../../api/routes/session.mjs";
8
8
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
9
- import "../../utils/index.mjs";
10
9
  import { APIError } from "../../api/index.mjs";
11
10
  import { PACKAGE_VERSION } from "../../version.mjs";
12
11
  import { parsePrompt } from "../oidc-provider/utils/prompt.mjs";
@@ -6,7 +6,6 @@ import { symmetricDecrypt, symmetricEncrypt } from "../../crypto/index.mjs";
6
6
  import { expireCookie } from "../../cookies/index.mjs";
7
7
  import { getSessionFromCtx, sessionMiddleware } from "../../api/routes/session.mjs";
8
8
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
9
- import "../../utils/index.mjs";
10
9
  import { APIError } from "../../api/index.mjs";
11
10
  import { PACKAGE_VERSION } from "../../version.mjs";
12
11
  import { getJwtToken } from "../jwt/sign.mjs";
@@ -1,5 +1,4 @@
1
1
  import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
2
- import "../../utils/index.mjs";
3
2
  import { APIError } from "../../api/index.mjs";
4
3
  import { PACKAGE_VERSION } from "../../version.mjs";
5
4
  import { generator } from "./generator.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "1.6.29",
3
+ "version": "1.6.31",
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.17 || ^0.29.0",
490
490
  "nanostores": "^1.1.1",
491
491
  "zod": "^4.3.6",
492
- "@better-auth/core": "1.6.29",
493
- "@better-auth/drizzle-adapter": "1.6.29",
494
- "@better-auth/kysely-adapter": "1.6.29",
495
- "@better-auth/memory-adapter": "1.6.29",
496
- "@better-auth/mongo-adapter": "1.6.29",
497
- "@better-auth/prisma-adapter": "1.6.29",
498
- "@better-auth/telemetry": "1.6.29"
492
+ "@better-auth/core": "1.6.31",
493
+ "@better-auth/drizzle-adapter": "1.6.31",
494
+ "@better-auth/kysely-adapter": "1.6.31",
495
+ "@better-auth/memory-adapter": "1.6.31",
496
+ "@better-auth/mongo-adapter": "1.6.31",
497
+ "@better-auth/prisma-adapter": "1.6.31",
498
+ "@better-auth/telemetry": "1.6.31"
499
499
  },
500
500
  "devDependencies": {
501
501
  "@lynx-js/react": "^0.116.3",
@@ -1,5 +0,0 @@
1
- import "./url.mjs";
2
- import "../state.mjs";
3
- import "../oauth2/state.mjs";
4
- import "./hide-metadata.mjs";
5
- export {};