@better-auth/telemetry
Advanced tools
+223
| import * as _better_auth_core0 from "@better-auth/core"; | ||
| import { BetterAuthOptions } from "@better-auth/core"; | ||
| import * as _better_auth_core_db0 from "@better-auth/core/db"; | ||
| import * as _better_auth_core_social_providers0 from "@better-auth/core/social-providers"; | ||
| //#region src/types.d.ts | ||
| interface TelemetryEvent { | ||
| type: string; | ||
| anonymousId?: string | undefined; | ||
| payload: Record<string, any>; | ||
| } | ||
| interface TelemetryContext { | ||
| customTrack?: ((event: TelemetryEvent) => Promise<void>) | undefined; | ||
| database?: string | undefined; | ||
| adapter?: string | undefined; | ||
| skipTestCheck?: boolean | undefined; | ||
| } | ||
| //#endregion | ||
| //#region src/detectors/detect-auth-config.d.ts | ||
| declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: TelemetryContext | undefined): Promise<{ | ||
| database: string | undefined; | ||
| adapter: string | undefined; | ||
| emailVerification: { | ||
| sendVerificationEmail: boolean; | ||
| sendOnSignUp: boolean; | ||
| sendOnSignIn: boolean; | ||
| autoSignInAfterVerification: boolean; | ||
| expiresIn: number | undefined; | ||
| beforeEmailVerification: boolean; | ||
| afterEmailVerification: boolean; | ||
| }; | ||
| emailAndPassword: { | ||
| enabled: boolean; | ||
| disableSignUp: boolean; | ||
| requireEmailVerification: boolean; | ||
| maxPasswordLength: number | undefined; | ||
| minPasswordLength: number | undefined; | ||
| sendResetPassword: boolean; | ||
| resetPasswordTokenExpiresIn: number | undefined; | ||
| onPasswordReset: boolean; | ||
| password: { | ||
| hash: boolean; | ||
| verify: boolean; | ||
| }; | ||
| autoSignIn: boolean; | ||
| revokeSessionsOnPasswordReset: boolean; | ||
| }; | ||
| socialProviders: ({ | ||
| id?: undefined; | ||
| mapProfileToUser?: undefined; | ||
| disableDefaultScope?: undefined; | ||
| disableIdTokenSignIn?: undefined; | ||
| disableImplicitSignUp?: undefined; | ||
| disableSignUp?: undefined; | ||
| getUserInfo?: undefined; | ||
| overrideUserInfoOnSignIn?: undefined; | ||
| prompt?: undefined; | ||
| verifyIdToken?: undefined; | ||
| scope?: undefined; | ||
| refreshAccessToken?: undefined; | ||
| } | { | ||
| id: string; | ||
| mapProfileToUser: boolean; | ||
| disableDefaultScope: boolean; | ||
| disableIdTokenSignIn: boolean; | ||
| disableImplicitSignUp: boolean | undefined; | ||
| disableSignUp: boolean | undefined; | ||
| getUserInfo: boolean; | ||
| overrideUserInfoOnSignIn: boolean; | ||
| prompt: "none" | "select_account" | "consent" | "login" | "select_account consent" | undefined; | ||
| verifyIdToken: boolean; | ||
| scope: string[] | undefined; | ||
| refreshAccessToken: boolean; | ||
| })[]; | ||
| plugins: string[] | undefined; | ||
| user: { | ||
| modelName: "user" | _better_auth_core0.LiteralString | undefined; | ||
| fields: Partial<Record<"name" | "email" | "image" | "createdAt" | "updatedAt" | "emailVerified", string>> | undefined; | ||
| additionalFields: { | ||
| [x: string]: _better_auth_core_db0.DBFieldAttribute; | ||
| } | undefined; | ||
| changeEmail: { | ||
| enabled: boolean | undefined; | ||
| sendChangeEmailConfirmation: boolean; | ||
| }; | ||
| }; | ||
| verification: { | ||
| modelName: _better_auth_core0.LiteralString | "verification" | undefined; | ||
| disableCleanup: boolean | undefined; | ||
| fields: Partial<Record<"createdAt" | "updatedAt" | "value" | "expiresAt" | "identifier", string>> | undefined; | ||
| }; | ||
| session: { | ||
| modelName: _better_auth_core0.LiteralString | "session" | undefined; | ||
| additionalFields: { | ||
| [x: string]: _better_auth_core_db0.DBFieldAttribute; | ||
| } | undefined; | ||
| cookieCache: { | ||
| enabled: boolean | undefined; | ||
| maxAge: number | undefined; | ||
| strategy: "compact" | "jwt" | "jwe" | undefined; | ||
| }; | ||
| disableSessionRefresh: boolean | undefined; | ||
| expiresIn: number | undefined; | ||
| fields: Partial<Record<"createdAt" | "updatedAt" | "expiresAt" | "userId" | "token" | "ipAddress" | "userAgent", string>> | undefined; | ||
| freshAge: number | undefined; | ||
| preserveSessionInDatabase: boolean | undefined; | ||
| storeSessionInDatabase: boolean | undefined; | ||
| updateAge: number | undefined; | ||
| }; | ||
| account: { | ||
| modelName: _better_auth_core0.LiteralString | "account" | undefined; | ||
| fields: Partial<Record<"scope" | "createdAt" | "updatedAt" | "userId" | "providerId" | "accountId" | "accessToken" | "refreshToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt" | "password", string>> | undefined; | ||
| encryptOAuthTokens: boolean | undefined; | ||
| updateAccountOnSignIn: boolean | undefined; | ||
| accountLinking: { | ||
| enabled: boolean | undefined; | ||
| trustedProviders: _better_auth_core0.LiteralUnion<"linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "email-password", string>[] | ((request?: Request | undefined) => _better_auth_core0.Awaitable<Array<_better_auth_core0.LiteralUnion<_better_auth_core_social_providers0.SocialProviderList[number] | "email-password", string>>>) | undefined; | ||
| updateUserInfoOnLink: boolean | undefined; | ||
| allowUnlinkingAll: boolean | undefined; | ||
| }; | ||
| }; | ||
| hooks: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| secondaryStorage: boolean; | ||
| advanced: { | ||
| cookiePrefix: boolean; | ||
| cookies: boolean; | ||
| crossSubDomainCookies: { | ||
| domain: boolean; | ||
| enabled: boolean | undefined; | ||
| additionalCookies: string[] | undefined; | ||
| }; | ||
| database: { | ||
| generateId: false | _better_auth_core0.GenerateIdFn | "serial" | "uuid" | undefined; | ||
| defaultFindManyLimit: number | undefined; | ||
| }; | ||
| useSecureCookies: boolean | undefined; | ||
| ipAddress: { | ||
| disableIpTracking: boolean | undefined; | ||
| ipAddressHeaders: string[] | undefined; | ||
| }; | ||
| disableCSRFCheck: boolean | undefined; | ||
| cookieAttributes: { | ||
| expires: Date | undefined; | ||
| secure: boolean | undefined; | ||
| sameSite: "none" | "strict" | "Strict" | "Lax" | "None" | "lax" | undefined; | ||
| domain: boolean; | ||
| path: string | undefined; | ||
| httpOnly: boolean | undefined; | ||
| }; | ||
| }; | ||
| trustedOrigins: number | undefined; | ||
| rateLimit: { | ||
| storage: "memory" | "database" | "secondary-storage" | undefined; | ||
| modelName: _better_auth_core0.LiteralString | "rateLimit" | undefined; | ||
| window: number | undefined; | ||
| customStorage: boolean; | ||
| enabled: boolean | undefined; | ||
| max: number | undefined; | ||
| }; | ||
| onAPIError: { | ||
| errorURL: string | undefined; | ||
| onError: boolean; | ||
| throw: boolean | undefined; | ||
| }; | ||
| logger: { | ||
| disabled: boolean | undefined; | ||
| level: "error" | "debug" | "info" | "warn" | undefined; | ||
| log: boolean; | ||
| }; | ||
| databaseHooks: { | ||
| user: { | ||
| create: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| update: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| }; | ||
| session: { | ||
| create: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| update: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| }; | ||
| account: { | ||
| create: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| update: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| }; | ||
| verification: { | ||
| create: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| update: { | ||
| after: boolean; | ||
| before: boolean; | ||
| }; | ||
| }; | ||
| }; | ||
| }>; | ||
| //#endregion | ||
| //#region src/node.d.ts | ||
| declare function createTelemetry(options: BetterAuthOptions, context?: TelemetryContext | undefined): Promise<{ | ||
| publish: (event: TelemetryEvent) => Promise<void>; | ||
| }>; | ||
| //#endregion | ||
| export { type TelemetryEvent, createTelemetry, getTelemetryAuthConfig }; | ||
| //# sourceMappingURL=node.d.mts.map |
+489
| import fs from "node:fs"; | ||
| import fsPromises from "node:fs/promises"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| import { ENV, env, getBooleanEnvVar, getEnvVar, isTest, logger } from "@better-auth/core/env"; | ||
| import { betterFetch } from "@better-fetch/fetch"; | ||
| import { base64 } from "@better-auth/utils/base64"; | ||
| import { createHash } from "@better-auth/utils/hash"; | ||
| import { createRandomStringGenerator } from "@better-auth/utils/random"; | ||
| //#region src/detectors/detect-auth-config.ts | ||
| async function getTelemetryAuthConfig(options, context) { | ||
| return { | ||
| database: context?.database, | ||
| adapter: context?.adapter, | ||
| emailVerification: { | ||
| sendVerificationEmail: !!options.emailVerification?.sendVerificationEmail, | ||
| sendOnSignUp: !!options.emailVerification?.sendOnSignUp, | ||
| sendOnSignIn: !!options.emailVerification?.sendOnSignIn, | ||
| autoSignInAfterVerification: !!options.emailVerification?.autoSignInAfterVerification, | ||
| expiresIn: options.emailVerification?.expiresIn, | ||
| beforeEmailVerification: !!options.emailVerification?.beforeEmailVerification, | ||
| afterEmailVerification: !!options.emailVerification?.afterEmailVerification | ||
| }, | ||
| emailAndPassword: { | ||
| enabled: !!options.emailAndPassword?.enabled, | ||
| disableSignUp: !!options.emailAndPassword?.disableSignUp, | ||
| requireEmailVerification: !!options.emailAndPassword?.requireEmailVerification, | ||
| maxPasswordLength: options.emailAndPassword?.maxPasswordLength, | ||
| minPasswordLength: options.emailAndPassword?.minPasswordLength, | ||
| sendResetPassword: !!options.emailAndPassword?.sendResetPassword, | ||
| resetPasswordTokenExpiresIn: options.emailAndPassword?.resetPasswordTokenExpiresIn, | ||
| onPasswordReset: !!options.emailAndPassword?.onPasswordReset, | ||
| password: { | ||
| hash: !!options.emailAndPassword?.password?.hash, | ||
| verify: !!options.emailAndPassword?.password?.verify | ||
| }, | ||
| autoSignIn: !!options.emailAndPassword?.autoSignIn, | ||
| revokeSessionsOnPasswordReset: !!options.emailAndPassword?.revokeSessionsOnPasswordReset | ||
| }, | ||
| socialProviders: await Promise.all(Object.keys(options.socialProviders || {}).map(async (key) => { | ||
| const p = options.socialProviders?.[key]; | ||
| if (!p) return {}; | ||
| const provider = typeof p === "function" ? await p() : p; | ||
| return { | ||
| id: key, | ||
| mapProfileToUser: !!provider.mapProfileToUser, | ||
| disableDefaultScope: !!provider.disableDefaultScope, | ||
| disableIdTokenSignIn: !!provider.disableIdTokenSignIn, | ||
| disableImplicitSignUp: provider.disableImplicitSignUp, | ||
| disableSignUp: provider.disableSignUp, | ||
| getUserInfo: !!provider.getUserInfo, | ||
| overrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn, | ||
| prompt: provider.prompt, | ||
| verifyIdToken: !!provider.verifyIdToken, | ||
| scope: provider.scope, | ||
| refreshAccessToken: !!provider.refreshAccessToken | ||
| }; | ||
| })), | ||
| plugins: options.plugins?.map((p) => p.id.toString()), | ||
| user: { | ||
| modelName: options.user?.modelName, | ||
| fields: options.user?.fields, | ||
| additionalFields: options.user?.additionalFields, | ||
| changeEmail: { | ||
| enabled: options.user?.changeEmail?.enabled, | ||
| sendChangeEmailConfirmation: !!options.user?.changeEmail?.sendChangeEmailConfirmation | ||
| } | ||
| }, | ||
| verification: { | ||
| modelName: options.verification?.modelName, | ||
| disableCleanup: options.verification?.disableCleanup, | ||
| fields: options.verification?.fields | ||
| }, | ||
| session: { | ||
| modelName: options.session?.modelName, | ||
| additionalFields: options.session?.additionalFields, | ||
| cookieCache: { | ||
| enabled: options.session?.cookieCache?.enabled, | ||
| maxAge: options.session?.cookieCache?.maxAge, | ||
| strategy: options.session?.cookieCache?.strategy | ||
| }, | ||
| disableSessionRefresh: options.session?.disableSessionRefresh, | ||
| expiresIn: options.session?.expiresIn, | ||
| fields: options.session?.fields, | ||
| freshAge: options.session?.freshAge, | ||
| preserveSessionInDatabase: options.session?.preserveSessionInDatabase, | ||
| storeSessionInDatabase: options.session?.storeSessionInDatabase, | ||
| updateAge: options.session?.updateAge | ||
| }, | ||
| account: { | ||
| modelName: options.account?.modelName, | ||
| fields: options.account?.fields, | ||
| encryptOAuthTokens: options.account?.encryptOAuthTokens, | ||
| updateAccountOnSignIn: options.account?.updateAccountOnSignIn, | ||
| accountLinking: { | ||
| enabled: options.account?.accountLinking?.enabled, | ||
| trustedProviders: options.account?.accountLinking?.trustedProviders, | ||
| updateUserInfoOnLink: options.account?.accountLinking?.updateUserInfoOnLink, | ||
| allowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll | ||
| } | ||
| }, | ||
| hooks: { | ||
| after: !!options.hooks?.after, | ||
| before: !!options.hooks?.before | ||
| }, | ||
| secondaryStorage: !!options.secondaryStorage, | ||
| advanced: { | ||
| cookiePrefix: !!options.advanced?.cookiePrefix, | ||
| cookies: !!options.advanced?.cookies, | ||
| crossSubDomainCookies: { | ||
| domain: !!options.advanced?.crossSubDomainCookies?.domain, | ||
| enabled: options.advanced?.crossSubDomainCookies?.enabled, | ||
| additionalCookies: options.advanced?.crossSubDomainCookies?.additionalCookies | ||
| }, | ||
| database: { | ||
| generateId: options.advanced?.database?.generateId, | ||
| defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit | ||
| }, | ||
| useSecureCookies: options.advanced?.useSecureCookies, | ||
| ipAddress: { | ||
| disableIpTracking: options.advanced?.ipAddress?.disableIpTracking, | ||
| ipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders | ||
| }, | ||
| disableCSRFCheck: options.advanced?.disableCSRFCheck, | ||
| cookieAttributes: { | ||
| expires: options.advanced?.defaultCookieAttributes?.expires, | ||
| secure: options.advanced?.defaultCookieAttributes?.secure, | ||
| sameSite: options.advanced?.defaultCookieAttributes?.sameSite, | ||
| domain: !!options.advanced?.defaultCookieAttributes?.domain, | ||
| path: options.advanced?.defaultCookieAttributes?.path, | ||
| httpOnly: options.advanced?.defaultCookieAttributes?.httpOnly | ||
| } | ||
| }, | ||
| trustedOrigins: options.trustedOrigins?.length, | ||
| rateLimit: { | ||
| storage: options.rateLimit?.storage, | ||
| modelName: options.rateLimit?.modelName, | ||
| window: options.rateLimit?.window, | ||
| customStorage: !!options.rateLimit?.customStorage, | ||
| enabled: options.rateLimit?.enabled, | ||
| max: options.rateLimit?.max | ||
| }, | ||
| onAPIError: { | ||
| errorURL: options.onAPIError?.errorURL, | ||
| onError: !!options.onAPIError?.onError, | ||
| throw: options.onAPIError?.throw | ||
| }, | ||
| logger: { | ||
| disabled: options.logger?.disabled, | ||
| level: options.logger?.level, | ||
| log: !!options.logger?.log | ||
| }, | ||
| databaseHooks: { | ||
| user: { | ||
| create: { | ||
| after: !!options.databaseHooks?.user?.create?.after, | ||
| before: !!options.databaseHooks?.user?.create?.before | ||
| }, | ||
| update: { | ||
| after: !!options.databaseHooks?.user?.update?.after, | ||
| before: !!options.databaseHooks?.user?.update?.before | ||
| } | ||
| }, | ||
| session: { | ||
| create: { | ||
| after: !!options.databaseHooks?.session?.create?.after, | ||
| before: !!options.databaseHooks?.session?.create?.before | ||
| }, | ||
| update: { | ||
| after: !!options.databaseHooks?.session?.update?.after, | ||
| before: !!options.databaseHooks?.session?.update?.before | ||
| } | ||
| }, | ||
| account: { | ||
| create: { | ||
| after: !!options.databaseHooks?.account?.create?.after, | ||
| before: !!options.databaseHooks?.account?.create?.before | ||
| }, | ||
| update: { | ||
| after: !!options.databaseHooks?.account?.update?.after, | ||
| before: !!options.databaseHooks?.account?.update?.before | ||
| } | ||
| }, | ||
| verification: { | ||
| create: { | ||
| after: !!options.databaseHooks?.verification?.create?.after, | ||
| before: !!options.databaseHooks?.verification?.create?.before | ||
| }, | ||
| update: { | ||
| after: !!options.databaseHooks?.verification?.update?.after, | ||
| before: !!options.databaseHooks?.verification?.update?.before | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/detectors/detect-project-info.ts | ||
| function detectPackageManager() { | ||
| const userAgent = env.npm_config_user_agent; | ||
| if (!userAgent) return; | ||
| const pmSpec = userAgent.split(" ")[0]; | ||
| const separatorPos = pmSpec.lastIndexOf("/"); | ||
| const name = pmSpec.substring(0, separatorPos); | ||
| return { | ||
| name: name === "npminstall" ? "cnpm" : name, | ||
| version: pmSpec.substring(separatorPos + 1) | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/detectors/detect-system-info.ts | ||
| function isCI() { | ||
| return env.CI !== "false" && ("BUILD_ID" in env || "BUILD_NUMBER" in env || "CI" in env || "CI_APP_ID" in env || "CI_BUILD_ID" in env || "CI_BUILD_NUMBER" in env || "CI_NAME" in env || "CONTINUOUS_INTEGRATION" in env || "RUN_ID" in env); | ||
| } | ||
| //#endregion | ||
| //#region src/detectors/detect-runtime.ts | ||
| function detectRuntime() { | ||
| if (typeof Deno !== "undefined") return { | ||
| name: "deno", | ||
| version: Deno?.version?.deno ?? null | ||
| }; | ||
| if (typeof Bun !== "undefined") return { | ||
| name: "bun", | ||
| version: Bun?.version ?? null | ||
| }; | ||
| if (typeof process !== "undefined" && process?.versions?.node) return { | ||
| name: "node", | ||
| version: process.versions.node ?? null | ||
| }; | ||
| return { | ||
| name: "edge", | ||
| version: null | ||
| }; | ||
| } | ||
| function detectEnvironment() { | ||
| return getEnvVar("NODE_ENV") === "production" ? "production" : isCI() ? "ci" : isTest() ? "test" : "development"; | ||
| } | ||
| //#endregion | ||
| //#region src/utils/hash.ts | ||
| async function hashToBase64(data) { | ||
| const buffer = await createHash("SHA-256").digest(data); | ||
| return base64.encode(buffer); | ||
| } | ||
| //#endregion | ||
| //#region src/utils/id.ts | ||
| const generateId = (size) => { | ||
| return createRandomStringGenerator("a-z", "A-Z", "0-9")(size || 32); | ||
| }; | ||
| //#endregion | ||
| //#region src/node.ts | ||
| let packageJSONCache; | ||
| async function readRootPackageJson() { | ||
| if (packageJSONCache) return packageJSONCache; | ||
| try { | ||
| const cwd = process.cwd(); | ||
| if (!cwd) return void 0; | ||
| const raw = await fsPromises.readFile(path.join(cwd, "package.json"), "utf-8"); | ||
| packageJSONCache = JSON.parse(raw); | ||
| return packageJSONCache; | ||
| } catch {} | ||
| } | ||
| async function getPackageVersion(pkg) { | ||
| if (packageJSONCache) return packageJSONCache.dependencies?.[pkg] || packageJSONCache.devDependencies?.[pkg] || packageJSONCache.peerDependencies?.[pkg]; | ||
| try { | ||
| const cwd = process.cwd(); | ||
| if (!cwd) throw new Error("no-cwd"); | ||
| const pkgJsonPath = path.join(cwd, "node_modules", pkg, "package.json"); | ||
| const raw = await fsPromises.readFile(pkgJsonPath, "utf-8"); | ||
| return JSON.parse(raw).version || await getVersionFromLocalPackageJson(pkg) || void 0; | ||
| } catch {} | ||
| return getVersionFromLocalPackageJson(pkg); | ||
| } | ||
| async function getVersionFromLocalPackageJson(pkg) { | ||
| const json = await readRootPackageJson(); | ||
| if (!json) return void 0; | ||
| return { | ||
| ...json.dependencies, | ||
| ...json.devDependencies, | ||
| ...json.peerDependencies | ||
| }[pkg]; | ||
| } | ||
| async function getNameFromLocalPackageJson() { | ||
| return (await readRootPackageJson())?.name; | ||
| } | ||
| async function detectSystemInfo() { | ||
| try { | ||
| const cpus = os.cpus(); | ||
| return { | ||
| deploymentVendor: getVendor(), | ||
| systemPlatform: os.platform(), | ||
| systemRelease: os.release(), | ||
| systemArchitecture: os.arch(), | ||
| cpuCount: cpus.length, | ||
| cpuModel: cpus.length ? cpus[0].model : null, | ||
| cpuSpeed: cpus.length ? cpus[0].speed : null, | ||
| memory: os.totalmem(), | ||
| isWSL: await isWsl(), | ||
| isDocker: await isDocker(), | ||
| isTTY: process.stdout ? process.stdout.isTTY : null | ||
| }; | ||
| } catch { | ||
| return { | ||
| systemPlatform: null, | ||
| systemRelease: null, | ||
| systemArchitecture: null, | ||
| cpuCount: null, | ||
| cpuModel: null, | ||
| cpuSpeed: null, | ||
| memory: null, | ||
| isWSL: null, | ||
| isDocker: null, | ||
| isTTY: null | ||
| }; | ||
| } | ||
| } | ||
| function getVendor() { | ||
| const env = process.env; | ||
| const hasAny = (...keys) => keys.some((k) => Boolean(env[k])); | ||
| if (hasAny("CF_PAGES", "CF_PAGES_URL", "CF_ACCOUNT_ID") || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") return "cloudflare"; | ||
| if (hasAny("VERCEL", "VERCEL_URL", "VERCEL_ENV")) return "vercel"; | ||
| if (hasAny("NETLIFY", "NETLIFY_URL")) return "netlify"; | ||
| if (hasAny("RENDER", "RENDER_URL", "RENDER_INTERNAL_HOSTNAME", "RENDER_SERVICE_ID")) return "render"; | ||
| if (hasAny("AWS_LAMBDA_FUNCTION_NAME", "AWS_EXECUTION_ENV", "LAMBDA_TASK_ROOT")) return "aws"; | ||
| if (hasAny("GOOGLE_CLOUD_FUNCTION_NAME", "GOOGLE_CLOUD_PROJECT", "GCP_PROJECT", "K_SERVICE")) return "gcp"; | ||
| if (hasAny("AZURE_FUNCTION_NAME", "FUNCTIONS_WORKER_RUNTIME", "WEBSITE_INSTANCE_ID", "WEBSITE_SITE_NAME")) return "azure"; | ||
| if (hasAny("DENO_DEPLOYMENT_ID", "DENO_REGION")) return "deno-deploy"; | ||
| if (hasAny("FLY_APP_NAME", "FLY_REGION", "FLY_ALLOC_ID")) return "fly-io"; | ||
| if (hasAny("RAILWAY_STATIC_URL", "RAILWAY_ENVIRONMENT_NAME")) return "railway"; | ||
| if (hasAny("DYNO", "HEROKU_APP_NAME")) return "heroku"; | ||
| if (hasAny("DO_DEPLOYMENT_ID", "DO_APP_NAME", "DIGITALOCEAN")) return "digitalocean"; | ||
| if (hasAny("KOYEB", "KOYEB_DEPLOYMENT_ID", "KOYEB_APP_NAME")) return "koyeb"; | ||
| return null; | ||
| } | ||
| let isDockerCached; | ||
| async function hasDockerEnv() { | ||
| try { | ||
| fs.statSync("/.dockerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| async function hasDockerCGroup() { | ||
| try { | ||
| return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| async function isDocker() { | ||
| if (isDockerCached === void 0) isDockerCached = await hasDockerEnv() || await hasDockerCGroup(); | ||
| return isDockerCached; | ||
| } | ||
| let isInsideContainerCached; | ||
| const hasContainerEnv = async () => { | ||
| try { | ||
| fs.statSync("/run/.containerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
| async function isInsideContainer() { | ||
| if (isInsideContainerCached === void 0) isInsideContainerCached = await hasContainerEnv() || await isDocker(); | ||
| return isInsideContainerCached; | ||
| } | ||
| async function isWsl() { | ||
| try { | ||
| if (process.platform !== "linux") return false; | ||
| if (os.release().toLowerCase().includes("microsoft")) { | ||
| if (await isInsideContainer()) return false; | ||
| return true; | ||
| } | ||
| return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !await isInsideContainer() : false; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| let projectIdCached = null; | ||
| async function getProjectId(baseUrl) { | ||
| if (projectIdCached) return projectIdCached; | ||
| const projectName = await getNameFromLocalPackageJson(); | ||
| if (projectName) { | ||
| projectIdCached = await hashToBase64(baseUrl ? baseUrl + projectName : projectName); | ||
| return projectIdCached; | ||
| } | ||
| if (baseUrl) { | ||
| projectIdCached = await hashToBase64(baseUrl); | ||
| return projectIdCached; | ||
| } | ||
| projectIdCached = generateId(32); | ||
| return projectIdCached; | ||
| } | ||
| async function detectDatabaseNode() { | ||
| for (const [pkg, name] of Object.entries({ | ||
| pg: "postgresql", | ||
| mysql: "mysql", | ||
| mariadb: "mariadb", | ||
| sqlite3: "sqlite", | ||
| "better-sqlite3": "sqlite", | ||
| "@prisma/client": "prisma", | ||
| mongoose: "mongodb", | ||
| mongodb: "mongodb", | ||
| "drizzle-orm": "drizzle" | ||
| })) { | ||
| const version = await getPackageVersion(pkg); | ||
| if (version) return { | ||
| name, | ||
| version | ||
| }; | ||
| } | ||
| } | ||
| async function detectFrameworkNode() { | ||
| for (const [pkg, name] of Object.entries({ | ||
| next: "next", | ||
| nuxt: "nuxt", | ||
| "react-router": "react-router", | ||
| astro: "astro", | ||
| "@sveltejs/kit": "sveltekit", | ||
| "solid-start": "solid-start", | ||
| "tanstack-start": "tanstack-start", | ||
| hono: "hono", | ||
| express: "express", | ||
| elysia: "elysia", | ||
| expo: "expo" | ||
| })) { | ||
| const version = await getPackageVersion(pkg); | ||
| if (version) return { | ||
| name, | ||
| version | ||
| }; | ||
| } | ||
| } | ||
| const noop = async function noop() {}; | ||
| async function createTelemetry(options, context) { | ||
| const debugEnabled = options.telemetry?.debug || getBooleanEnvVar("BETTER_AUTH_TELEMETRY_DEBUG", false); | ||
| const telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT; | ||
| if (!telemetryEndpoint && !context?.customTrack) return { publish: noop }; | ||
| const track = async (event) => { | ||
| if (context?.customTrack) await context.customTrack(event).catch(logger.error); | ||
| else if (telemetryEndpoint) if (debugEnabled) logger.info("telemetry event", JSON.stringify(event, null, 2)); | ||
| else await betterFetch(telemetryEndpoint, { | ||
| method: "POST", | ||
| body: event | ||
| }).catch(logger.error); | ||
| }; | ||
| const isEnabled = async () => { | ||
| const telemetryEnabled = options.telemetry?.enabled !== void 0 ? options.telemetry.enabled : false; | ||
| return (getBooleanEnvVar("BETTER_AUTH_TELEMETRY", false) || telemetryEnabled) && (context?.skipTestCheck || !isTest()); | ||
| }; | ||
| const enabled = await isEnabled(); | ||
| let anonymousId; | ||
| if (enabled) { | ||
| anonymousId = await getProjectId(typeof options.baseURL === "string" ? options.baseURL : void 0); | ||
| track({ | ||
| type: "init", | ||
| payload: { | ||
| config: await getTelemetryAuthConfig(options, context), | ||
| runtime: detectRuntime(), | ||
| database: await detectDatabaseNode(), | ||
| framework: await detectFrameworkNode(), | ||
| environment: detectEnvironment(), | ||
| systemInfo: await detectSystemInfo(), | ||
| packageManager: detectPackageManager() | ||
| }, | ||
| anonymousId | ||
| }); | ||
| } | ||
| return { publish: async (event) => { | ||
| if (!enabled) return; | ||
| if (!anonymousId) anonymousId = await getProjectId(typeof options.baseURL === "string" ? options.baseURL : void 0); | ||
| await track({ | ||
| type: event.type, | ||
| payload: event.payload, | ||
| anonymousId | ||
| }); | ||
| } }; | ||
| } | ||
| //#endregion | ||
| export { createTelemetry, getTelemetryAuthConfig }; | ||
| //# sourceMappingURL=node.mjs.map |
| {"version":3,"file":"node.mjs","names":[],"sources":["../src/detectors/detect-auth-config.ts","../src/detectors/detect-project-info.ts","../src/detectors/detect-system-info.ts","../src/detectors/detect-runtime.ts","../src/utils/hash.ts","../src/utils/id.ts","../src/node.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"@better-auth/core\";\nimport type { TelemetryContext } from \"../types\";\n\nexport async function getTelemetryAuthConfig(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\treturn {\n\t\tdatabase: context?.database,\n\t\tadapter: context?.adapter,\n\t\temailVerification: {\n\t\t\tsendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,\n\t\t\tsendOnSignUp: !!options.emailVerification?.sendOnSignUp,\n\t\t\tsendOnSignIn: !!options.emailVerification?.sendOnSignIn,\n\t\t\tautoSignInAfterVerification:\n\t\t\t\t!!options.emailVerification?.autoSignInAfterVerification,\n\t\t\texpiresIn: options.emailVerification?.expiresIn,\n\t\t\tbeforeEmailVerification:\n\t\t\t\t!!options.emailVerification?.beforeEmailVerification,\n\t\t\tafterEmailVerification:\n\t\t\t\t!!options.emailVerification?.afterEmailVerification,\n\t\t},\n\t\temailAndPassword: {\n\t\t\tenabled: !!options.emailAndPassword?.enabled,\n\t\t\tdisableSignUp: !!options.emailAndPassword?.disableSignUp,\n\t\t\trequireEmailVerification:\n\t\t\t\t!!options.emailAndPassword?.requireEmailVerification,\n\t\t\tmaxPasswordLength: options.emailAndPassword?.maxPasswordLength,\n\t\t\tminPasswordLength: options.emailAndPassword?.minPasswordLength,\n\t\t\tsendResetPassword: !!options.emailAndPassword?.sendResetPassword,\n\t\t\tresetPasswordTokenExpiresIn:\n\t\t\t\toptions.emailAndPassword?.resetPasswordTokenExpiresIn,\n\t\t\tonPasswordReset: !!options.emailAndPassword?.onPasswordReset,\n\t\t\tpassword: {\n\t\t\t\thash: !!options.emailAndPassword?.password?.hash,\n\t\t\t\tverify: !!options.emailAndPassword?.password?.verify,\n\t\t\t},\n\t\t\tautoSignIn: !!options.emailAndPassword?.autoSignIn,\n\t\t\trevokeSessionsOnPasswordReset:\n\t\t\t\t!!options.emailAndPassword?.revokeSessionsOnPasswordReset,\n\t\t},\n\t\tsocialProviders: await Promise.all(\n\t\t\tObject.keys(options.socialProviders || {}).map(async (key) => {\n\t\t\t\tconst p =\n\t\t\t\t\toptions.socialProviders?.[\n\t\t\t\t\t\tkey as keyof typeof options.socialProviders\n\t\t\t\t\t];\n\t\t\t\tif (!p) return {};\n\t\t\t\tconst provider = typeof p === \"function\" ? await p() : p;\n\t\t\t\treturn {\n\t\t\t\t\tid: key,\n\t\t\t\t\tmapProfileToUser: !!provider.mapProfileToUser,\n\t\t\t\t\tdisableDefaultScope: !!provider.disableDefaultScope,\n\t\t\t\t\tdisableIdTokenSignIn: !!provider.disableIdTokenSignIn,\n\t\t\t\t\tdisableImplicitSignUp: provider.disableImplicitSignUp,\n\t\t\t\t\tdisableSignUp: provider.disableSignUp,\n\t\t\t\t\tgetUserInfo: !!provider.getUserInfo,\n\t\t\t\t\toverrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,\n\t\t\t\t\tprompt: provider.prompt,\n\t\t\t\t\tverifyIdToken: !!provider.verifyIdToken,\n\t\t\t\t\tscope: provider.scope,\n\t\t\t\t\trefreshAccessToken: !!provider.refreshAccessToken,\n\t\t\t\t};\n\t\t\t}),\n\t\t),\n\t\tplugins: options.plugins?.map((p) => p.id.toString()),\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName,\n\t\t\tfields: options.user?.fields,\n\t\t\tadditionalFields: options.user?.additionalFields,\n\t\t\tchangeEmail: {\n\t\t\t\tenabled: options.user?.changeEmail?.enabled,\n\t\t\t\tsendChangeEmailConfirmation:\n\t\t\t\t\t!!options.user?.changeEmail?.sendChangeEmailConfirmation,\n\t\t\t},\n\t\t},\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName,\n\t\t\tdisableCleanup: options.verification?.disableCleanup,\n\t\t\tfields: options.verification?.fields,\n\t\t},\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName,\n\t\t\tadditionalFields: options.session?.additionalFields,\n\t\t\tcookieCache: {\n\t\t\t\tenabled: options.session?.cookieCache?.enabled,\n\t\t\t\tmaxAge: options.session?.cookieCache?.maxAge,\n\t\t\t\tstrategy: options.session?.cookieCache?.strategy,\n\t\t\t},\n\t\t\tdisableSessionRefresh: options.session?.disableSessionRefresh,\n\t\t\texpiresIn: options.session?.expiresIn,\n\t\t\tfields: options.session?.fields,\n\t\t\tfreshAge: options.session?.freshAge,\n\t\t\tpreserveSessionInDatabase: options.session?.preserveSessionInDatabase,\n\t\t\tstoreSessionInDatabase: options.session?.storeSessionInDatabase,\n\t\t\tupdateAge: options.session?.updateAge,\n\t\t},\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName,\n\t\t\tfields: options.account?.fields,\n\t\t\tencryptOAuthTokens: options.account?.encryptOAuthTokens,\n\t\t\tupdateAccountOnSignIn: options.account?.updateAccountOnSignIn,\n\t\t\taccountLinking: {\n\t\t\t\tenabled: options.account?.accountLinking?.enabled,\n\t\t\t\ttrustedProviders: options.account?.accountLinking?.trustedProviders,\n\t\t\t\tupdateUserInfoOnLink:\n\t\t\t\t\toptions.account?.accountLinking?.updateUserInfoOnLink,\n\t\t\t\tallowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll,\n\t\t\t},\n\t\t},\n\t\thooks: {\n\t\t\tafter: !!options.hooks?.after,\n\t\t\tbefore: !!options.hooks?.before,\n\t\t},\n\t\tsecondaryStorage: !!options.secondaryStorage,\n\t\tadvanced: {\n\t\t\tcookiePrefix: !!options.advanced?.cookiePrefix, //this shouldn't be tracked\n\t\t\tcookies: !!options.advanced?.cookies,\n\t\t\tcrossSubDomainCookies: {\n\t\t\t\tdomain: !!options.advanced?.crossSubDomainCookies?.domain,\n\t\t\t\tenabled: options.advanced?.crossSubDomainCookies?.enabled,\n\t\t\t\tadditionalCookies:\n\t\t\t\t\toptions.advanced?.crossSubDomainCookies?.additionalCookies,\n\t\t\t},\n\t\t\tdatabase: {\n\t\t\t\tgenerateId: options.advanced?.database?.generateId,\n\t\t\t\tdefaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit,\n\t\t\t},\n\t\t\tuseSecureCookies: options.advanced?.useSecureCookies,\n\t\t\tipAddress: {\n\t\t\t\tdisableIpTracking: options.advanced?.ipAddress?.disableIpTracking,\n\t\t\t\tipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders,\n\t\t\t},\n\t\t\tdisableCSRFCheck: options.advanced?.disableCSRFCheck,\n\t\t\tcookieAttributes: {\n\t\t\t\texpires: options.advanced?.defaultCookieAttributes?.expires,\n\t\t\t\tsecure: options.advanced?.defaultCookieAttributes?.secure,\n\t\t\t\tsameSite: options.advanced?.defaultCookieAttributes?.sameSite,\n\t\t\t\tdomain: !!options.advanced?.defaultCookieAttributes?.domain,\n\t\t\t\tpath: options.advanced?.defaultCookieAttributes?.path,\n\t\t\t\thttpOnly: options.advanced?.defaultCookieAttributes?.httpOnly,\n\t\t\t},\n\t\t},\n\t\ttrustedOrigins: options.trustedOrigins?.length,\n\t\trateLimit: {\n\t\t\tstorage: options.rateLimit?.storage,\n\t\t\tmodelName: options.rateLimit?.modelName,\n\t\t\twindow: options.rateLimit?.window,\n\t\t\tcustomStorage: !!options.rateLimit?.customStorage,\n\t\t\tenabled: options.rateLimit?.enabled,\n\t\t\tmax: options.rateLimit?.max,\n\t\t},\n\t\tonAPIError: {\n\t\t\terrorURL: options.onAPIError?.errorURL,\n\t\t\tonError: !!options.onAPIError?.onError,\n\t\t\tthrow: options.onAPIError?.throw,\n\t\t},\n\t\tlogger: {\n\t\t\tdisabled: options.logger?.disabled,\n\t\t\tlevel: options.logger?.level,\n\t\t\tlog: !!options.logger?.log,\n\t\t},\n\t\tdatabaseHooks: {\n\t\t\tuser: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsession: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\taccount: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tverification: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n","// https://github.com/zkochan/packages/blob/main/which-pm-runs/index.js\nimport { env } from \"@better-auth/core/env\";\n\nexport function detectPackageManager() {\n\tconst userAgent = env.npm_config_user_agent;\n\tif (!userAgent) {\n\t\treturn undefined;\n\t}\n\n\tconst pmSpec = userAgent.split(\" \")[0]!;\n\tconst separatorPos = pmSpec.lastIndexOf(\"/\");\n\tconst name = pmSpec.substring(0, separatorPos);\n\n\treturn {\n\t\tname: name === \"npminstall\" ? \"cnpm\" : name,\n\t\tversion: pmSpec.substring(separatorPos + 1),\n\t};\n}\n","import { env } from \"@better-auth/core/env\";\n\nfunction getVendor() {\n\tconst hasAny = (...keys: string[]) =>\n\t\tkeys.some((k) => Boolean((env as any)[k]));\n\n\tif (\n\t\thasAny(\"CF_PAGES\", \"CF_PAGES_URL\", \"CF_ACCOUNT_ID\") ||\n\t\t(typeof navigator !== \"undefined\" &&\n\t\t\tnavigator.userAgent === \"Cloudflare-Workers\")\n\t) {\n\t\treturn \"cloudflare\";\n\t}\n\n\tif (hasAny(\"VERCEL\", \"VERCEL_URL\", \"VERCEL_ENV\")) return \"vercel\";\n\n\tif (hasAny(\"NETLIFY\", \"NETLIFY_URL\")) return \"netlify\";\n\n\tif (\n\t\thasAny(\n\t\t\t\"RENDER\",\n\t\t\t\"RENDER_URL\",\n\t\t\t\"RENDER_INTERNAL_HOSTNAME\",\n\t\t\t\"RENDER_SERVICE_ID\",\n\t\t)\n\t) {\n\t\treturn \"render\";\n\t}\n\n\tif (\n\t\thasAny(\"AWS_LAMBDA_FUNCTION_NAME\", \"AWS_EXECUTION_ENV\", \"LAMBDA_TASK_ROOT\")\n\t) {\n\t\treturn \"aws\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"GOOGLE_CLOUD_FUNCTION_NAME\",\n\t\t\t\"GOOGLE_CLOUD_PROJECT\",\n\t\t\t\"GCP_PROJECT\",\n\t\t\t\"K_SERVICE\",\n\t\t)\n\t) {\n\t\treturn \"gcp\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"AZURE_FUNCTION_NAME\",\n\t\t\t\"FUNCTIONS_WORKER_RUNTIME\",\n\t\t\t\"WEBSITE_INSTANCE_ID\",\n\t\t\t\"WEBSITE_SITE_NAME\",\n\t\t)\n\t) {\n\t\treturn \"azure\";\n\t}\n\n\tif (hasAny(\"DENO_DEPLOYMENT_ID\", \"DENO_REGION\")) return \"deno-deploy\";\n\n\tif (hasAny(\"FLY_APP_NAME\", \"FLY_REGION\", \"FLY_ALLOC_ID\")) return \"fly-io\";\n\n\tif (hasAny(\"RAILWAY_STATIC_URL\", \"RAILWAY_ENVIRONMENT_NAME\"))\n\t\treturn \"railway\";\n\n\tif (hasAny(\"DYNO\", \"HEROKU_APP_NAME\")) return \"heroku\";\n\n\tif (hasAny(\"DO_DEPLOYMENT_ID\", \"DO_APP_NAME\", \"DIGITALOCEAN\"))\n\t\treturn \"digitalocean\";\n\n\tif (hasAny(\"KOYEB\", \"KOYEB_DEPLOYMENT_ID\", \"KOYEB_APP_NAME\")) return \"koyeb\";\n\n\treturn null;\n}\n\n// In the default (non-node) build, system info detection is not available.\n// The node build (src/node.ts) provides its own inline implementation\n// using static top-level imports of node:os and node:fs.\nexport async function detectSystemInfo() {\n\treturn {\n\t\tdeploymentVendor: getVendor(),\n\t\tsystemPlatform: null,\n\t\tsystemRelease: null,\n\t\tsystemArchitecture: null,\n\t\tcpuCount: null,\n\t\tcpuModel: null,\n\t\tcpuSpeed: null,\n\t\tmemory: null,\n\t\tisWSL: null,\n\t\tisDocker: null,\n\t\tisTTY: null,\n\t};\n}\n\nexport function isCI() {\n\treturn (\n\t\tenv.CI !== \"false\" &&\n\t\t(\"BUILD_ID\" in env || // Jenkins, Cloudbees\n\t\t\t\"BUILD_NUMBER\" in env || // Jenkins, TeamCity\n\t\t\t\"CI\" in env || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare\n\t\t\t\"CI_APP_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_NUMBER\" in env || // Appflow\n\t\t\t\"CI_NAME\" in env || // Codeship and others\n\t\t\t\"CONTINUOUS_INTEGRATION\" in env || // Travis CI, Cirrus CI\n\t\t\t\"RUN_ID\" in env) // TaskCluster, dsari\n\t);\n}\n","import { getEnvVar, isTest } from \"@better-auth/core/env\";\nimport { isCI } from \"./detect-system-info\";\n\nexport function detectRuntime() {\n\t// @ts-expect-error: TS doesn't know about Deno global\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error: TS doesn't know about Deno global\n\t\tconst denoVersion = Deno?.version?.deno ?? null;\n\t\treturn { name: \"deno\", version: denoVersion };\n\t}\n\n\tif (typeof Bun !== \"undefined\") {\n\t\tconst bunVersion = Bun?.version ?? null;\n\t\treturn { name: \"bun\", version: bunVersion };\n\t}\n\n\tif (typeof process !== \"undefined\" && process?.versions?.node) {\n\t\treturn { name: \"node\", version: process.versions.node ?? null };\n\t}\n\treturn { name: \"edge\", version: null };\n}\n\nexport function detectEnvironment() {\n\treturn getEnvVar(\"NODE_ENV\") === \"production\"\n\t\t? \"production\"\n\t\t: isCI()\n\t\t\t? \"ci\"\n\t\t\t: isTest()\n\t\t\t\t? \"test\"\n\t\t\t\t: \"development\";\n}\n","import { base64 } from \"@better-auth/utils/base64\";\nimport { createHash } from \"@better-auth/utils/hash\";\n\nexport async function hashToBase64(\n\tdata: string | ArrayBuffer,\n): Promise<string> {\n\tconst buffer = await createHash(\"SHA-256\").digest(data);\n\treturn base64.encode(buffer);\n}\n","import { createRandomStringGenerator } from \"@better-auth/utils/random\";\n\nexport const generateId = (size: number) => {\n\treturn createRandomStringGenerator(\"a-z\", \"A-Z\", \"0-9\")(size || 32);\n};\n","import fs from \"node:fs\";\nimport fsPromises from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport type { BetterAuthOptions } from \"@better-auth/core\";\nimport { ENV, getBooleanEnvVar, isTest, logger } from \"@better-auth/core/env\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport type { PackageJson } from \"type-fest\";\nimport { getTelemetryAuthConfig } from \"./detectors/detect-auth-config\";\nimport { detectPackageManager } from \"./detectors/detect-project-info\";\nimport { detectEnvironment, detectRuntime } from \"./detectors/detect-runtime\";\nimport type { TelemetryContext, TelemetryEvent } from \"./types\";\nimport { hashToBase64 } from \"./utils/hash\";\nimport { generateId } from \"./utils/id\";\nexport { getTelemetryAuthConfig };\nexport type { TelemetryEvent } from \"./types\";\n\n// --- Node-specific: package.json reading ---\n\nlet packageJSONCache: PackageJson | undefined;\n\nasync function readRootPackageJson(): Promise<PackageJson | undefined> {\n\tif (packageJSONCache) return packageJSONCache;\n\ttry {\n\t\tconst cwd = process.cwd();\n\t\tif (!cwd) return undefined;\n\t\tconst raw = await fsPromises.readFile(\n\t\t\tpath.join(cwd, \"package.json\"),\n\t\t\t\"utf-8\",\n\t\t);\n\t\tpackageJSONCache = JSON.parse(raw);\n\t\treturn packageJSONCache as PackageJson;\n\t} catch {}\n\treturn undefined;\n}\n\nasync function getPackageVersion(pkg: string): Promise<string | undefined> {\n\tif (packageJSONCache) {\n\t\treturn (packageJSONCache.dependencies?.[pkg] ||\n\t\t\tpackageJSONCache.devDependencies?.[pkg] ||\n\t\t\tpackageJSONCache.peerDependencies?.[pkg]) as string | undefined;\n\t}\n\n\ttry {\n\t\tconst cwd = process.cwd();\n\t\tif (!cwd) throw new Error(\"no-cwd\");\n\t\tconst pkgJsonPath = path.join(cwd, \"node_modules\", pkg, \"package.json\");\n\t\tconst raw = await fsPromises.readFile(pkgJsonPath, \"utf-8\");\n\t\tconst json = JSON.parse(raw);\n\t\tconst resolved =\n\t\t\t(json.version as string) ||\n\t\t\t(await getVersionFromLocalPackageJson(pkg)) ||\n\t\t\tundefined;\n\t\treturn resolved;\n\t} catch {}\n\n\treturn getVersionFromLocalPackageJson(pkg);\n}\n\nasync function getVersionFromLocalPackageJson(\n\tpkg: string,\n): Promise<string | undefined> {\n\tconst json = await readRootPackageJson();\n\tif (!json) return undefined;\n\tconst allDeps = {\n\t\t...json.dependencies,\n\t\t...json.devDependencies,\n\t\t...json.peerDependencies,\n\t} as Record<string, string | undefined>;\n\treturn allDeps[pkg];\n}\n\nasync function getNameFromLocalPackageJson(): Promise<string | undefined> {\n\tconst json = await readRootPackageJson();\n\treturn json?.name as string | undefined;\n}\n\n// --- Node-specific: system info ---\n\nasync function detectSystemInfo() {\n\ttry {\n\t\tconst cpus = os.cpus();\n\t\treturn {\n\t\t\tdeploymentVendor: getVendor(),\n\t\t\tsystemPlatform: os.platform(),\n\t\t\tsystemRelease: os.release(),\n\t\t\tsystemArchitecture: os.arch(),\n\t\t\tcpuCount: cpus.length,\n\t\t\tcpuModel: cpus.length ? cpus[0]!.model : null,\n\t\t\tcpuSpeed: cpus.length ? cpus[0]!.speed : null,\n\t\t\tmemory: os.totalmem(),\n\t\t\tisWSL: await isWsl(),\n\t\t\tisDocker: await isDocker(),\n\t\t\tisTTY: (process as any).stdout ? (process as any).stdout.isTTY : null,\n\t\t};\n\t} catch {\n\t\treturn {\n\t\t\tsystemPlatform: null,\n\t\t\tsystemRelease: null,\n\t\t\tsystemArchitecture: null,\n\t\t\tcpuCount: null,\n\t\t\tcpuModel: null,\n\t\t\tcpuSpeed: null,\n\t\t\tmemory: null,\n\t\t\tisWSL: null,\n\t\t\tisDocker: null,\n\t\t\tisTTY: null,\n\t\t};\n\t}\n}\n\nfunction getVendor() {\n\tconst env = process.env as Record<string, string | undefined>;\n\tconst hasAny = (...keys: string[]) => keys.some((k) => Boolean(env[k]));\n\n\tif (\n\t\thasAny(\"CF_PAGES\", \"CF_PAGES_URL\", \"CF_ACCOUNT_ID\") ||\n\t\t(typeof navigator !== \"undefined\" &&\n\t\t\tnavigator.userAgent === \"Cloudflare-Workers\")\n\t) {\n\t\treturn \"cloudflare\";\n\t}\n\n\tif (hasAny(\"VERCEL\", \"VERCEL_URL\", \"VERCEL_ENV\")) return \"vercel\";\n\tif (hasAny(\"NETLIFY\", \"NETLIFY_URL\")) return \"netlify\";\n\tif (\n\t\thasAny(\n\t\t\t\"RENDER\",\n\t\t\t\"RENDER_URL\",\n\t\t\t\"RENDER_INTERNAL_HOSTNAME\",\n\t\t\t\"RENDER_SERVICE_ID\",\n\t\t)\n\t)\n\t\treturn \"render\";\n\tif (\n\t\thasAny(\"AWS_LAMBDA_FUNCTION_NAME\", \"AWS_EXECUTION_ENV\", \"LAMBDA_TASK_ROOT\")\n\t)\n\t\treturn \"aws\";\n\tif (\n\t\thasAny(\n\t\t\t\"GOOGLE_CLOUD_FUNCTION_NAME\",\n\t\t\t\"GOOGLE_CLOUD_PROJECT\",\n\t\t\t\"GCP_PROJECT\",\n\t\t\t\"K_SERVICE\",\n\t\t)\n\t)\n\t\treturn \"gcp\";\n\tif (\n\t\thasAny(\n\t\t\t\"AZURE_FUNCTION_NAME\",\n\t\t\t\"FUNCTIONS_WORKER_RUNTIME\",\n\t\t\t\"WEBSITE_INSTANCE_ID\",\n\t\t\t\"WEBSITE_SITE_NAME\",\n\t\t)\n\t)\n\t\treturn \"azure\";\n\tif (hasAny(\"DENO_DEPLOYMENT_ID\", \"DENO_REGION\")) return \"deno-deploy\";\n\tif (hasAny(\"FLY_APP_NAME\", \"FLY_REGION\", \"FLY_ALLOC_ID\")) return \"fly-io\";\n\tif (hasAny(\"RAILWAY_STATIC_URL\", \"RAILWAY_ENVIRONMENT_NAME\"))\n\t\treturn \"railway\";\n\tif (hasAny(\"DYNO\", \"HEROKU_APP_NAME\")) return \"heroku\";\n\tif (hasAny(\"DO_DEPLOYMENT_ID\", \"DO_APP_NAME\", \"DIGITALOCEAN\"))\n\t\treturn \"digitalocean\";\n\tif (hasAny(\"KOYEB\", \"KOYEB_DEPLOYMENT_ID\", \"KOYEB_APP_NAME\")) return \"koyeb\";\n\treturn null;\n}\n\nlet isDockerCached: boolean | undefined;\n\nasync function hasDockerEnv() {\n\ttry {\n\t\tfs.statSync(\"/.dockerenv\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function hasDockerCGroup() {\n\ttry {\n\t\treturn fs.readFileSync(\"/proc/self/cgroup\", \"utf8\").includes(\"docker\");\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function isDocker() {\n\tif (isDockerCached === undefined) {\n\t\tisDockerCached = (await hasDockerEnv()) || (await hasDockerCGroup());\n\t}\n\treturn isDockerCached;\n}\n\nlet isInsideContainerCached: boolean | undefined;\n\nconst hasContainerEnv = async () => {\n\ttry {\n\t\tfs.statSync(\"/run/.containerenv\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nasync function isInsideContainer() {\n\tif (isInsideContainerCached === undefined) {\n\t\tisInsideContainerCached = (await hasContainerEnv()) || (await isDocker());\n\t}\n\treturn isInsideContainerCached;\n}\n\nasync function isWsl() {\n\ttry {\n\t\tif (process.platform !== \"linux\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (os.release().toLowerCase().includes(\"microsoft\")) {\n\t\t\tif (await isInsideContainer()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\treturn fs\n\t\t\t.readFileSync(\"/proc/version\", \"utf8\")\n\t\t\t.toLowerCase()\n\t\t\t.includes(\"microsoft\")\n\t\t\t? !(await isInsideContainer())\n\t\t\t: false;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// --- Node-specific: project ID ---\n\nlet projectIdCached: string | null = null;\n\nasync function getProjectId(baseUrl: string | undefined): Promise<string> {\n\tif (projectIdCached) return projectIdCached;\n\n\tconst projectName = await getNameFromLocalPackageJson();\n\tif (projectName) {\n\t\tprojectIdCached = await hashToBase64(\n\t\t\tbaseUrl ? baseUrl + projectName : projectName,\n\t\t);\n\t\treturn projectIdCached;\n\t}\n\n\tif (baseUrl) {\n\t\tprojectIdCached = await hashToBase64(baseUrl);\n\t\treturn projectIdCached;\n\t}\n\n\tprojectIdCached = generateId(32);\n\treturn projectIdCached;\n}\n\n// --- detectDatabase/detectFramework override using local package.json reading ---\n\nasync function detectDatabaseNode() {\n\tconst DATABASES: Record<string, string> = {\n\t\tpg: \"postgresql\",\n\t\tmysql: \"mysql\",\n\t\tmariadb: \"mariadb\",\n\t\tsqlite3: \"sqlite\",\n\t\t\"better-sqlite3\": \"sqlite\",\n\t\t\"@prisma/client\": \"prisma\",\n\t\tmongoose: \"mongodb\",\n\t\tmongodb: \"mongodb\",\n\t\t\"drizzle-orm\": \"drizzle\",\n\t};\n\tfor (const [pkg, name] of Object.entries(DATABASES)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n\nasync function detectFrameworkNode() {\n\tconst FRAMEWORKS: Record<string, string> = {\n\t\tnext: \"next\",\n\t\tnuxt: \"nuxt\",\n\t\t\"react-router\": \"react-router\",\n\t\tastro: \"astro\",\n\t\t\"@sveltejs/kit\": \"sveltekit\",\n\t\t\"solid-start\": \"solid-start\",\n\t\t\"tanstack-start\": \"tanstack-start\",\n\t\thono: \"hono\",\n\t\texpress: \"express\",\n\t\telysia: \"elysia\",\n\t\texpo: \"expo\",\n\t};\n\tfor (const [pkg, name] of Object.entries(FRAMEWORKS)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n\n// --- Main telemetry export (node version) ---\n\nconst noop: (event: TelemetryEvent) => Promise<void> = async function noop() {};\n\nexport async function createTelemetry(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\tconst debugEnabled =\n\t\toptions.telemetry?.debug ||\n\t\tgetBooleanEnvVar(\"BETTER_AUTH_TELEMETRY_DEBUG\", false);\n\n\tconst telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT;\n\tif (!telemetryEndpoint && !context?.customTrack) {\n\t\treturn {\n\t\t\tpublish: noop,\n\t\t};\n\t}\n\tconst track = async (event: TelemetryEvent) => {\n\t\tif (context?.customTrack) {\n\t\t\tawait context.customTrack(event).catch(logger.error);\n\t\t} else if (telemetryEndpoint) {\n\t\t\tif (debugEnabled) {\n\t\t\t\tlogger.info(\"telemetry event\", JSON.stringify(event, null, 2));\n\t\t\t} else {\n\t\t\t\tawait betterFetch(telemetryEndpoint, {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: event,\n\t\t\t\t}).catch(logger.error);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst isEnabled = async () => {\n\t\tconst telemetryEnabled =\n\t\t\toptions.telemetry?.enabled !== undefined\n\t\t\t\t? options.telemetry.enabled\n\t\t\t\t: false;\n\t\tconst envEnabled = getBooleanEnvVar(\"BETTER_AUTH_TELEMETRY\", false);\n\t\treturn (\n\t\t\t(envEnabled || telemetryEnabled) && (context?.skipTestCheck || !isTest())\n\t\t);\n\t};\n\n\tconst enabled = await isEnabled();\n\tlet anonymousId: string | undefined;\n\n\tif (enabled) {\n\t\tanonymousId = await getProjectId(\n\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t);\n\n\t\tconst payload = {\n\t\t\tconfig: await getTelemetryAuthConfig(options, context),\n\t\t\truntime: detectRuntime(),\n\t\t\tdatabase: await detectDatabaseNode(),\n\t\t\tframework: await detectFrameworkNode(),\n\t\t\tenvironment: detectEnvironment(),\n\t\t\tsystemInfo: await detectSystemInfo(),\n\t\t\tpackageManager: detectPackageManager(),\n\t\t};\n\n\t\tvoid track({ type: \"init\", payload, anonymousId });\n\t}\n\n\treturn {\n\t\tpublish: async (event: TelemetryEvent) => {\n\t\t\tif (!enabled) return;\n\t\t\tif (!anonymousId) {\n\t\t\t\tanonymousId = await getProjectId(\n\t\t\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait track({\n\t\t\t\ttype: event.type,\n\t\t\t\tpayload: event.payload,\n\t\t\t\tanonymousId,\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAGA,eAAsB,uBACrB,SACA,SACC;AACD,QAAO;EACN,UAAU,SAAS;EACnB,SAAS,SAAS;EAClB,mBAAmB;GAClB,uBAAuB,CAAC,CAAC,QAAQ,mBAAmB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,OAAO,UAA0B;AAC9C,MAAI,SAAS,YACZ,OAAM,QAAQ,YAAY,MAAM,CAAC,MAAM,OAAO,MAAM;WAC1C,kBACV,KAAI,aACH,QAAO,KAAK,mBAAmB,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;MAE9D,OAAM,YAAY,mBAAmB;GACpC,QAAQ;GACR,MAAM;GACN,CAAC,CAAC,MAAM,OAAO,MAAM;;CAKzB,MAAM,YAAY,YAAY;EAC7B,MAAM,mBACL,QAAQ,WAAW,YAAY,SAC5B,QAAQ,UAAU,UAClB;AAEJ,UADmB,iBAAiB,yBAAyB,MAAM,IAEnD,sBAAsB,SAAS,iBAAiB,CAAC,QAAQ;;CAI1E,MAAM,UAAU,MAAM,WAAW;CACjC,IAAI;AAEJ,KAAI,SAAS;AACZ,gBAAc,MAAM,aACnB,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU,OACxD;AAYD,EAAK,MAAM;GAAE,MAAM;GAAQ,SAVX;IACf,QAAQ,MAAM,uBAAuB,SAAS,QAAQ;IACtD,SAAS,eAAe;IACxB,UAAU,MAAM,oBAAoB;IACpC,WAAW,MAAM,qBAAqB;IACtC,aAAa,mBAAmB;IAChC,YAAY,MAAM,kBAAkB;IACpC,gBAAgB,sBAAsB;IACtC;GAEmC;GAAa,CAAC;;AAGnD,QAAO,EACN,SAAS,OAAO,UAA0B;AACzC,MAAI,CAAC,QAAS;AACd,MAAI,CAAC,YACJ,eAAc,MAAM,aACnB,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU,OACxD;AAEF,QAAM,MAAM;GACX,MAAM,MAAM;GACZ,SAAS,MAAM;GACf;GACA,CAAC;IAEH"} |
+18
-129
@@ -197,40 +197,4 @@ import { ENV, env, getBooleanEnvVar, getEnvVar, isTest, logger } from "@better-auth/core/env"; | ||
| //#region src/utils/package-json.ts | ||
| let packageJSONCache; | ||
| async function readRootPackageJson() { | ||
| if (packageJSONCache) return packageJSONCache; | ||
| try { | ||
| const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ""; | ||
| if (!cwd) return void 0; | ||
| const importRuntime = (m) => Function("mm", "return import(mm)")(m); | ||
| const [{ default: fs }, { default: path }] = await Promise.all([importRuntime("fs/promises"), importRuntime("path")]); | ||
| const raw = await fs.readFile(path.join(cwd, "package.json"), "utf-8"); | ||
| packageJSONCache = JSON.parse(raw); | ||
| return packageJSONCache; | ||
| } catch {} | ||
| } | ||
| async function getPackageVersion(pkg) { | ||
| if (packageJSONCache) return packageJSONCache.dependencies?.[pkg] || packageJSONCache.devDependencies?.[pkg] || packageJSONCache.peerDependencies?.[pkg]; | ||
| try { | ||
| const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ""; | ||
| if (!cwd) throw new Error("no-cwd"); | ||
| const importRuntime = (m) => Function("mm", "return import(mm)")(m); | ||
| const [{ default: fs }, { default: path }] = await Promise.all([importRuntime("fs/promises"), importRuntime("path")]); | ||
| const pkgJsonPath = path.join(cwd, "node_modules", pkg, "package.json"); | ||
| const raw = await fs.readFile(pkgJsonPath, "utf-8"); | ||
| return JSON.parse(raw).version || await getVersionFromLocalPackageJson(pkg) || void 0; | ||
| } catch {} | ||
| return await getVersionFromLocalPackageJson(pkg); | ||
| } | ||
| async function getVersionFromLocalPackageJson(pkg) { | ||
| const json = await readRootPackageJson(); | ||
| if (!json) return void 0; | ||
| return { | ||
| ...json.dependencies, | ||
| ...json.devDependencies, | ||
| ...json.peerDependencies | ||
| }[pkg]; | ||
| } | ||
| async function getNameFromLocalPackageJson() { | ||
| return (await readRootPackageJson())?.name; | ||
| } | ||
| async function getPackageVersion(_pkg) {} | ||
| async function getNameFromLocalPackageJson() {} | ||
@@ -252,3 +216,3 @@ //#endregion | ||
| for (const [pkg, name] of Object.entries(DATABASES)) { | ||
| const version = await getPackageVersion(pkg); | ||
| const version = await /* @__PURE__ */ getPackageVersion(pkg); | ||
| if (version) return { | ||
@@ -278,3 +242,3 @@ name, | ||
| for (const [pkg, name] of Object.entries(FRAMEWORKS)) { | ||
| const version = await getPackageVersion(pkg); | ||
| const version = await /* @__PURE__ */ getPackageVersion(pkg); | ||
| if (version) return { | ||
@@ -302,8 +266,2 @@ name, | ||
| //#endregion | ||
| //#region src/utils/import-util.ts | ||
| const importRuntime = (m) => { | ||
| return Function("mm", "return import(mm)")(m); | ||
| }; | ||
| //#endregion | ||
| //#region src/detectors/detect-system-info.ts | ||
@@ -328,85 +286,16 @@ function getVendor() { | ||
| async function detectSystemInfo() { | ||
| try { | ||
| if (getVendor() === "cloudflare") return "cloudflare"; | ||
| const os = await importRuntime("os"); | ||
| const cpus = os.cpus(); | ||
| return { | ||
| deploymentVendor: getVendor(), | ||
| systemPlatform: os.platform(), | ||
| systemRelease: os.release(), | ||
| systemArchitecture: os.arch(), | ||
| cpuCount: cpus.length, | ||
| cpuModel: cpus.length ? cpus[0].model : null, | ||
| cpuSpeed: cpus.length ? cpus[0].speed : null, | ||
| memory: os.totalmem(), | ||
| isWSL: await isWsl(), | ||
| isDocker: await isDocker(), | ||
| isTTY: typeof process !== "undefined" && process.stdout ? process.stdout.isTTY : null | ||
| }; | ||
| } catch { | ||
| return { | ||
| systemPlatform: null, | ||
| systemRelease: null, | ||
| systemArchitecture: null, | ||
| cpuCount: null, | ||
| cpuModel: null, | ||
| cpuSpeed: null, | ||
| memory: null, | ||
| isWSL: null, | ||
| isDocker: null, | ||
| isTTY: null | ||
| }; | ||
| } | ||
| return { | ||
| deploymentVendor: getVendor(), | ||
| systemPlatform: null, | ||
| systemRelease: null, | ||
| systemArchitecture: null, | ||
| cpuCount: null, | ||
| cpuModel: null, | ||
| cpuSpeed: null, | ||
| memory: null, | ||
| isWSL: null, | ||
| isDocker: null, | ||
| isTTY: null | ||
| }; | ||
| } | ||
| let isDockerCached; | ||
| async function hasDockerEnv() { | ||
| if (getVendor() === "cloudflare") return false; | ||
| try { | ||
| (await importRuntime("fs")).statSync("/.dockerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| async function hasDockerCGroup() { | ||
| if (getVendor() === "cloudflare") return false; | ||
| try { | ||
| return (await importRuntime("fs")).readFileSync("/proc/self/cgroup", "utf8").includes("docker"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| async function isDocker() { | ||
| if (getVendor() === "cloudflare") return false; | ||
| if (isDockerCached === void 0) isDockerCached = await hasDockerEnv() || await hasDockerCGroup(); | ||
| return isDockerCached; | ||
| } | ||
| async function isWsl() { | ||
| try { | ||
| if (getVendor() === "cloudflare") return false; | ||
| if (typeof process === "undefined" || process?.platform !== "linux") return false; | ||
| const fs = await importRuntime("fs"); | ||
| if ((await importRuntime("os")).release().toLowerCase().includes("microsoft")) { | ||
| if (await isInsideContainer()) return false; | ||
| return true; | ||
| } | ||
| return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !await isInsideContainer() : false; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| let isInsideContainerCached; | ||
| const hasContainerEnv = async () => { | ||
| if (getVendor() === "cloudflare") return false; | ||
| try { | ||
| (await importRuntime("fs")).statSync("/run/.containerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
| async function isInsideContainer() { | ||
| if (isInsideContainerCached === void 0) isInsideContainerCached = await hasContainerEnv() || await isDocker(); | ||
| return isInsideContainerCached; | ||
| } | ||
| function isCI() { | ||
@@ -458,3 +347,3 @@ return env.CI !== "false" && ("BUILD_ID" in env || "BUILD_NUMBER" in env || "CI" in env || "CI_APP_ID" in env || "CI_BUILD_ID" in env || "CI_BUILD_NUMBER" in env || "CI_NAME" in env || "CONTINUOUS_INTEGRATION" in env || "RUN_ID" in env); | ||
| if (projectIdCached) return projectIdCached; | ||
| const projectName = await getNameFromLocalPackageJson(); | ||
| const projectName = await /* @__PURE__ */ getNameFromLocalPackageJson(); | ||
| if (projectName) { | ||
@@ -461,0 +350,0 @@ projectIdCached = await hashToBase64(baseUrl ? baseUrl + projectName : projectName); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.mjs","names":[],"sources":["../src/detectors/detect-auth-config.ts","../src/utils/package-json.ts","../src/detectors/detect-database.ts","../src/detectors/detect-framework.ts","../src/detectors/detect-project-info.ts","../src/utils/import-util.ts","../src/detectors/detect-system-info.ts","../src/detectors/detect-runtime.ts","../src/utils/hash.ts","../src/utils/id.ts","../src/project-id.ts","../src/index.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"@better-auth/core\";\nimport type { TelemetryContext } from \"../types\";\n\nexport async function getTelemetryAuthConfig(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\treturn {\n\t\tdatabase: context?.database,\n\t\tadapter: context?.adapter,\n\t\temailVerification: {\n\t\t\tsendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,\n\t\t\tsendOnSignUp: !!options.emailVerification?.sendOnSignUp,\n\t\t\tsendOnSignIn: !!options.emailVerification?.sendOnSignIn,\n\t\t\tautoSignInAfterVerification:\n\t\t\t\t!!options.emailVerification?.autoSignInAfterVerification,\n\t\t\texpiresIn: options.emailVerification?.expiresIn,\n\t\t\tbeforeEmailVerification:\n\t\t\t\t!!options.emailVerification?.beforeEmailVerification,\n\t\t\tafterEmailVerification:\n\t\t\t\t!!options.emailVerification?.afterEmailVerification,\n\t\t},\n\t\temailAndPassword: {\n\t\t\tenabled: !!options.emailAndPassword?.enabled,\n\t\t\tdisableSignUp: !!options.emailAndPassword?.disableSignUp,\n\t\t\trequireEmailVerification:\n\t\t\t\t!!options.emailAndPassword?.requireEmailVerification,\n\t\t\tmaxPasswordLength: options.emailAndPassword?.maxPasswordLength,\n\t\t\tminPasswordLength: options.emailAndPassword?.minPasswordLength,\n\t\t\tsendResetPassword: !!options.emailAndPassword?.sendResetPassword,\n\t\t\tresetPasswordTokenExpiresIn:\n\t\t\t\toptions.emailAndPassword?.resetPasswordTokenExpiresIn,\n\t\t\tonPasswordReset: !!options.emailAndPassword?.onPasswordReset,\n\t\t\tpassword: {\n\t\t\t\thash: !!options.emailAndPassword?.password?.hash,\n\t\t\t\tverify: !!options.emailAndPassword?.password?.verify,\n\t\t\t},\n\t\t\tautoSignIn: !!options.emailAndPassword?.autoSignIn,\n\t\t\trevokeSessionsOnPasswordReset:\n\t\t\t\t!!options.emailAndPassword?.revokeSessionsOnPasswordReset,\n\t\t},\n\t\tsocialProviders: await Promise.all(\n\t\t\tObject.keys(options.socialProviders || {}).map(async (key) => {\n\t\t\t\tconst p =\n\t\t\t\t\toptions.socialProviders?.[\n\t\t\t\t\t\tkey as keyof typeof options.socialProviders\n\t\t\t\t\t];\n\t\t\t\tif (!p) return {};\n\t\t\t\tconst provider = typeof p === \"function\" ? await p() : p;\n\t\t\t\treturn {\n\t\t\t\t\tid: key,\n\t\t\t\t\tmapProfileToUser: !!provider.mapProfileToUser,\n\t\t\t\t\tdisableDefaultScope: !!provider.disableDefaultScope,\n\t\t\t\t\tdisableIdTokenSignIn: !!provider.disableIdTokenSignIn,\n\t\t\t\t\tdisableImplicitSignUp: provider.disableImplicitSignUp,\n\t\t\t\t\tdisableSignUp: provider.disableSignUp,\n\t\t\t\t\tgetUserInfo: !!provider.getUserInfo,\n\t\t\t\t\toverrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,\n\t\t\t\t\tprompt: provider.prompt,\n\t\t\t\t\tverifyIdToken: !!provider.verifyIdToken,\n\t\t\t\t\tscope: provider.scope,\n\t\t\t\t\trefreshAccessToken: !!provider.refreshAccessToken,\n\t\t\t\t};\n\t\t\t}),\n\t\t),\n\t\tplugins: options.plugins?.map((p) => p.id.toString()),\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName,\n\t\t\tfields: options.user?.fields,\n\t\t\tadditionalFields: options.user?.additionalFields,\n\t\t\tchangeEmail: {\n\t\t\t\tenabled: options.user?.changeEmail?.enabled,\n\t\t\t\tsendChangeEmailConfirmation:\n\t\t\t\t\t!!options.user?.changeEmail?.sendChangeEmailConfirmation,\n\t\t\t},\n\t\t},\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName,\n\t\t\tdisableCleanup: options.verification?.disableCleanup,\n\t\t\tfields: options.verification?.fields,\n\t\t},\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName,\n\t\t\tadditionalFields: options.session?.additionalFields,\n\t\t\tcookieCache: {\n\t\t\t\tenabled: options.session?.cookieCache?.enabled,\n\t\t\t\tmaxAge: options.session?.cookieCache?.maxAge,\n\t\t\t\tstrategy: options.session?.cookieCache?.strategy,\n\t\t\t},\n\t\t\tdisableSessionRefresh: options.session?.disableSessionRefresh,\n\t\t\texpiresIn: options.session?.expiresIn,\n\t\t\tfields: options.session?.fields,\n\t\t\tfreshAge: options.session?.freshAge,\n\t\t\tpreserveSessionInDatabase: options.session?.preserveSessionInDatabase,\n\t\t\tstoreSessionInDatabase: options.session?.storeSessionInDatabase,\n\t\t\tupdateAge: options.session?.updateAge,\n\t\t},\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName,\n\t\t\tfields: options.account?.fields,\n\t\t\tencryptOAuthTokens: options.account?.encryptOAuthTokens,\n\t\t\tupdateAccountOnSignIn: options.account?.updateAccountOnSignIn,\n\t\t\taccountLinking: {\n\t\t\t\tenabled: options.account?.accountLinking?.enabled,\n\t\t\t\ttrustedProviders: options.account?.accountLinking?.trustedProviders,\n\t\t\t\tupdateUserInfoOnLink:\n\t\t\t\t\toptions.account?.accountLinking?.updateUserInfoOnLink,\n\t\t\t\tallowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll,\n\t\t\t},\n\t\t},\n\t\thooks: {\n\t\t\tafter: !!options.hooks?.after,\n\t\t\tbefore: !!options.hooks?.before,\n\t\t},\n\t\tsecondaryStorage: !!options.secondaryStorage,\n\t\tadvanced: {\n\t\t\tcookiePrefix: !!options.advanced?.cookiePrefix, //this shouldn't be tracked\n\t\t\tcookies: !!options.advanced?.cookies,\n\t\t\tcrossSubDomainCookies: {\n\t\t\t\tdomain: !!options.advanced?.crossSubDomainCookies?.domain,\n\t\t\t\tenabled: options.advanced?.crossSubDomainCookies?.enabled,\n\t\t\t\tadditionalCookies:\n\t\t\t\t\toptions.advanced?.crossSubDomainCookies?.additionalCookies,\n\t\t\t},\n\t\t\tdatabase: {\n\t\t\t\tgenerateId: options.advanced?.database?.generateId,\n\t\t\t\tdefaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit,\n\t\t\t},\n\t\t\tuseSecureCookies: options.advanced?.useSecureCookies,\n\t\t\tipAddress: {\n\t\t\t\tdisableIpTracking: options.advanced?.ipAddress?.disableIpTracking,\n\t\t\t\tipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders,\n\t\t\t},\n\t\t\tdisableCSRFCheck: options.advanced?.disableCSRFCheck,\n\t\t\tcookieAttributes: {\n\t\t\t\texpires: options.advanced?.defaultCookieAttributes?.expires,\n\t\t\t\tsecure: options.advanced?.defaultCookieAttributes?.secure,\n\t\t\t\tsameSite: options.advanced?.defaultCookieAttributes?.sameSite,\n\t\t\t\tdomain: !!options.advanced?.defaultCookieAttributes?.domain,\n\t\t\t\tpath: options.advanced?.defaultCookieAttributes?.path,\n\t\t\t\thttpOnly: options.advanced?.defaultCookieAttributes?.httpOnly,\n\t\t\t},\n\t\t},\n\t\ttrustedOrigins: options.trustedOrigins?.length,\n\t\trateLimit: {\n\t\t\tstorage: options.rateLimit?.storage,\n\t\t\tmodelName: options.rateLimit?.modelName,\n\t\t\twindow: options.rateLimit?.window,\n\t\t\tcustomStorage: !!options.rateLimit?.customStorage,\n\t\t\tenabled: options.rateLimit?.enabled,\n\t\t\tmax: options.rateLimit?.max,\n\t\t},\n\t\tonAPIError: {\n\t\t\terrorURL: options.onAPIError?.errorURL,\n\t\t\tonError: !!options.onAPIError?.onError,\n\t\t\tthrow: options.onAPIError?.throw,\n\t\t},\n\t\tlogger: {\n\t\t\tdisabled: options.logger?.disabled,\n\t\t\tlevel: options.logger?.level,\n\t\t\tlog: !!options.logger?.log,\n\t\t},\n\t\tdatabaseHooks: {\n\t\t\tuser: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsession: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\taccount: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tverification: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n","import type { PackageJson } from \"type-fest\";\n\nlet packageJSONCache: PackageJson | undefined;\n\nasync function readRootPackageJson() {\n\tif (packageJSONCache) return packageJSONCache;\n\ttry {\n\t\tconst cwd =\n\t\t\ttypeof process !== \"undefined\" && typeof process.cwd === \"function\"\n\t\t\t\t? process.cwd()\n\t\t\t\t: \"\";\n\t\tif (!cwd) return undefined;\n\t\t// Lazily import Node built-ins only when available (Node/Bun/Deno) and\n\t\t// avoid static analyzer/bundler resolution by obfuscating module names\n\t\tconst importRuntime = (m: string) =>\n\t\t\t(Function(\"mm\", \"return import(mm)\") as any)(m);\n\t\tconst [{ default: fs }, { default: path }] = await Promise.all([\n\t\t\timportRuntime(\"fs/promises\"),\n\t\t\timportRuntime(\"path\"),\n\t\t]);\n\t\tconst raw = await fs.readFile(path.join(cwd, \"package.json\"), \"utf-8\");\n\t\tpackageJSONCache = JSON.parse(raw);\n\t\treturn packageJSONCache as PackageJson;\n\t} catch {}\n\treturn undefined;\n}\n\nexport async function getPackageVersion(pkg: string) {\n\tif (packageJSONCache) {\n\t\treturn (packageJSONCache.dependencies?.[pkg] ||\n\t\t\tpackageJSONCache.devDependencies?.[pkg] ||\n\t\t\tpackageJSONCache.peerDependencies?.[pkg]) as string | undefined;\n\t}\n\n\ttry {\n\t\tconst cwd =\n\t\t\ttypeof process !== \"undefined\" && typeof process.cwd === \"function\"\n\t\t\t\t? process.cwd()\n\t\t\t\t: \"\";\n\t\tif (!cwd) throw new Error(\"no-cwd\");\n\t\tconst importRuntime = (m: string) =>\n\t\t\t(Function(\"mm\", \"return import(mm)\") as any)(m);\n\t\tconst [{ default: fs }, { default: path }] = await Promise.all([\n\t\t\timportRuntime(\"fs/promises\"),\n\t\t\timportRuntime(\"path\"),\n\t\t]);\n\t\tconst pkgJsonPath = path.join(cwd, \"node_modules\", pkg, \"package.json\");\n\t\tconst raw = await fs.readFile(pkgJsonPath, \"utf-8\");\n\t\tconst json = JSON.parse(raw);\n\t\tconst resolved =\n\t\t\t(json.version as string) ||\n\t\t\t(await getVersionFromLocalPackageJson(pkg)) ||\n\t\t\tundefined;\n\t\treturn resolved;\n\t} catch {}\n\n\tconst fromRoot = await getVersionFromLocalPackageJson(pkg);\n\treturn fromRoot;\n}\n\nasync function getVersionFromLocalPackageJson(pkg: string) {\n\tconst json = await readRootPackageJson();\n\tif (!json) return undefined;\n\tconst allDeps = {\n\t\t...json.dependencies,\n\t\t...json.devDependencies,\n\t\t...json.peerDependencies,\n\t} as Record<string, string | undefined>;\n\treturn allDeps[pkg];\n}\n\nexport async function getNameFromLocalPackageJson() {\n\tconst json = await readRootPackageJson();\n\treturn json?.name as string | undefined;\n}\n","import type { DetectionInfo } from \"../types\";\nimport { getPackageVersion } from \"../utils/package-json\";\n\nconst DATABASES: Record<string, string> = {\n\tpg: \"postgresql\",\n\tmysql: \"mysql\",\n\tmariadb: \"mariadb\",\n\tsqlite3: \"sqlite\",\n\t\"better-sqlite3\": \"sqlite\",\n\t\"@prisma/client\": \"prisma\",\n\tmongoose: \"mongodb\",\n\tmongodb: \"mongodb\",\n\t\"drizzle-orm\": \"drizzle\",\n};\n\nexport async function detectDatabase(): Promise<DetectionInfo | undefined> {\n\tfor (const [pkg, name] of Object.entries(DATABASES)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n","import { getPackageVersion } from \"../utils/package-json\";\n\nconst FRAMEWORKS: Record<string, string> = {\n\tnext: \"next\",\n\tnuxt: \"nuxt\",\n\t\"react-router\": \"react-router\",\n\tastro: \"astro\",\n\t\"@sveltejs/kit\": \"sveltekit\",\n\t\"solid-start\": \"solid-start\",\n\t\"tanstack-start\": \"tanstack-start\",\n\thono: \"hono\",\n\texpress: \"express\",\n\telysia: \"elysia\",\n\texpo: \"expo\",\n};\n\nexport async function detectFramework() {\n\tfor (const [pkg, name] of Object.entries(FRAMEWORKS)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n","// https://github.com/zkochan/packages/blob/main/which-pm-runs/index.js\nimport { env } from \"@better-auth/core/env\";\n\nexport function detectPackageManager() {\n\tconst userAgent = env.npm_config_user_agent;\n\tif (!userAgent) {\n\t\treturn undefined;\n\t}\n\n\tconst pmSpec = userAgent.split(\" \")[0]!;\n\tconst separatorPos = pmSpec.lastIndexOf(\"/\");\n\tconst name = pmSpec.substring(0, separatorPos);\n\n\treturn {\n\t\tname: name === \"npminstall\" ? \"cnpm\" : name,\n\t\tversion: pmSpec.substring(separatorPos + 1),\n\t};\n}\n","export const importRuntime = <T>(m: string): Promise<T> => {\n\treturn (Function(\"mm\", \"return import(mm)\") as any)(m);\n};\n","import { env } from \"@better-auth/core/env\";\nimport { importRuntime } from \"../utils/import-util\";\n\nfunction getVendor() {\n\tconst hasAny = (...keys: string[]) =>\n\t\tkeys.some((k) => Boolean((env as any)[k]));\n\n\tif (\n\t\thasAny(\"CF_PAGES\", \"CF_PAGES_URL\", \"CF_ACCOUNT_ID\") ||\n\t\t(typeof navigator !== \"undefined\" &&\n\t\t\tnavigator.userAgent === \"Cloudflare-Workers\")\n\t) {\n\t\treturn \"cloudflare\";\n\t}\n\n\tif (hasAny(\"VERCEL\", \"VERCEL_URL\", \"VERCEL_ENV\")) return \"vercel\";\n\n\tif (hasAny(\"NETLIFY\", \"NETLIFY_URL\")) return \"netlify\";\n\n\tif (\n\t\thasAny(\n\t\t\t\"RENDER\",\n\t\t\t\"RENDER_URL\",\n\t\t\t\"RENDER_INTERNAL_HOSTNAME\",\n\t\t\t\"RENDER_SERVICE_ID\",\n\t\t)\n\t) {\n\t\treturn \"render\";\n\t}\n\n\tif (\n\t\thasAny(\"AWS_LAMBDA_FUNCTION_NAME\", \"AWS_EXECUTION_ENV\", \"LAMBDA_TASK_ROOT\")\n\t) {\n\t\treturn \"aws\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"GOOGLE_CLOUD_FUNCTION_NAME\",\n\t\t\t\"GOOGLE_CLOUD_PROJECT\",\n\t\t\t\"GCP_PROJECT\",\n\t\t\t\"K_SERVICE\",\n\t\t)\n\t) {\n\t\treturn \"gcp\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"AZURE_FUNCTION_NAME\",\n\t\t\t\"FUNCTIONS_WORKER_RUNTIME\",\n\t\t\t\"WEBSITE_INSTANCE_ID\",\n\t\t\t\"WEBSITE_SITE_NAME\",\n\t\t)\n\t) {\n\t\treturn \"azure\";\n\t}\n\n\tif (hasAny(\"DENO_DEPLOYMENT_ID\", \"DENO_REGION\")) return \"deno-deploy\";\n\n\tif (hasAny(\"FLY_APP_NAME\", \"FLY_REGION\", \"FLY_ALLOC_ID\")) return \"fly-io\";\n\n\tif (hasAny(\"RAILWAY_STATIC_URL\", \"RAILWAY_ENVIRONMENT_NAME\"))\n\t\treturn \"railway\";\n\n\tif (hasAny(\"DYNO\", \"HEROKU_APP_NAME\")) return \"heroku\";\n\n\tif (hasAny(\"DO_DEPLOYMENT_ID\", \"DO_APP_NAME\", \"DIGITALOCEAN\"))\n\t\treturn \"digitalocean\";\n\n\tif (hasAny(\"KOYEB\", \"KOYEB_DEPLOYMENT_ID\", \"KOYEB_APP_NAME\")) return \"koyeb\";\n\n\treturn null;\n}\n\nexport async function detectSystemInfo() {\n\ttry {\n\t\t//check if it's cloudflare\n\t\tif (getVendor() === \"cloudflare\") return \"cloudflare\";\n\t\tconst os = await importRuntime<typeof import(\"os\")>(\"os\");\n\t\tconst cpus = os.cpus();\n\t\treturn {\n\t\t\tdeploymentVendor: getVendor(),\n\t\t\tsystemPlatform: os.platform(),\n\t\t\tsystemRelease: os.release(),\n\t\t\tsystemArchitecture: os.arch(),\n\t\t\tcpuCount: cpus.length,\n\t\t\tcpuModel: cpus.length ? cpus[0]!.model : null,\n\t\t\tcpuSpeed: cpus.length ? cpus[0]!.speed : null,\n\t\t\tmemory: os.totalmem(),\n\t\t\tisWSL: await isWsl(),\n\t\t\tisDocker: await isDocker(),\n\t\t\tisTTY:\n\t\t\t\ttypeof process !== \"undefined\" && (process as any).stdout\n\t\t\t\t\t? (process as any).stdout.isTTY\n\t\t\t\t\t: null,\n\t\t};\n\t} catch {\n\t\treturn {\n\t\t\tsystemPlatform: null,\n\t\t\tsystemRelease: null,\n\t\t\tsystemArchitecture: null,\n\t\t\tcpuCount: null,\n\t\t\tcpuModel: null,\n\t\t\tcpuSpeed: null,\n\t\t\tmemory: null,\n\t\t\tisWSL: null,\n\t\t\tisDocker: null,\n\t\t\tisTTY: null,\n\t\t};\n\t}\n}\n\nlet isDockerCached: boolean | undefined;\n\nasync function hasDockerEnv() {\n\tif (getVendor() === \"cloudflare\") return false;\n\n\ttry {\n\t\tconst fs = await importRuntime<typeof import(\"fs\")>(\"fs\");\n\t\tfs.statSync(\"/.dockerenv\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function hasDockerCGroup() {\n\tif (getVendor() === \"cloudflare\") return false;\n\ttry {\n\t\tconst fs = await importRuntime<typeof import(\"fs\")>(\"fs\");\n\t\treturn fs.readFileSync(\"/proc/self/cgroup\", \"utf8\").includes(\"docker\");\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function isDocker() {\n\tif (getVendor() === \"cloudflare\") return false;\n\n\tif (isDockerCached === undefined) {\n\t\tisDockerCached = (await hasDockerEnv()) || (await hasDockerCGroup());\n\t}\n\n\treturn isDockerCached;\n}\n\nasync function isWsl() {\n\ttry {\n\t\tif (getVendor() === \"cloudflare\") return false;\n\t\tif (typeof process === \"undefined\" || process?.platform !== \"linux\") {\n\t\t\treturn false;\n\t\t}\n\t\tconst fs = await importRuntime<typeof import(\"fs\")>(\"fs\");\n\t\tconst os = await importRuntime<typeof import(\"os\")>(\"os\");\n\t\tif (os.release().toLowerCase().includes(\"microsoft\")) {\n\t\t\tif (await isInsideContainer()) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn fs\n\t\t\t.readFileSync(\"/proc/version\", \"utf8\")\n\t\t\t.toLowerCase()\n\t\t\t.includes(\"microsoft\")\n\t\t\t? !(await isInsideContainer())\n\t\t\t: false;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nlet isInsideContainerCached: boolean | undefined;\n\nconst hasContainerEnv = async () => {\n\tif (getVendor() === \"cloudflare\") return false;\n\ttry {\n\t\tconst fs = await importRuntime<typeof import(\"fs\")>(\"fs\");\n\t\tfs.statSync(\"/run/.containerenv\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nasync function isInsideContainer() {\n\tif (isInsideContainerCached === undefined) {\n\t\tisInsideContainerCached = (await hasContainerEnv()) || (await isDocker());\n\t}\n\n\treturn isInsideContainerCached;\n}\n\nexport function isCI() {\n\treturn (\n\t\tenv.CI !== \"false\" &&\n\t\t(\"BUILD_ID\" in env || // Jenkins, Cloudbees\n\t\t\t\"BUILD_NUMBER\" in env || // Jenkins, TeamCity (fixed typo: extra space removed)\n\t\t\t\"CI\" in env || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare\n\t\t\t\"CI_APP_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_NUMBER\" in env || // Appflow\n\t\t\t\"CI_NAME\" in env || // Codeship and others\n\t\t\t\"CONTINUOUS_INTEGRATION\" in env || // Travis CI, Cirrus CI\n\t\t\t\"RUN_ID\" in env) // TaskCluster, dsari\n\t);\n}\n","import { getEnvVar, isTest } from \"@better-auth/core/env\";\nimport { isCI } from \"./detect-system-info\";\n\nexport function detectRuntime() {\n\t// @ts-expect-error: TS doesn't know about Deno global\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error: TS doesn't know about Deno global\n\t\tconst denoVersion = Deno?.version?.deno ?? null;\n\t\treturn { name: \"deno\", version: denoVersion };\n\t}\n\n\tif (typeof Bun !== \"undefined\") {\n\t\tconst bunVersion = Bun?.version ?? null;\n\t\treturn { name: \"bun\", version: bunVersion };\n\t}\n\n\tif (typeof process !== \"undefined\" && process?.versions?.node) {\n\t\treturn { name: \"node\", version: process.versions.node ?? null };\n\t}\n\treturn { name: \"edge\", version: null };\n}\n\nexport function detectEnvironment() {\n\treturn getEnvVar(\"NODE_ENV\") === \"production\"\n\t\t? \"production\"\n\t\t: isCI()\n\t\t\t? \"ci\"\n\t\t\t: isTest()\n\t\t\t\t? \"test\"\n\t\t\t\t: \"development\";\n}\n","import { base64 } from \"@better-auth/utils/base64\";\nimport { createHash } from \"@better-auth/utils/hash\";\n\nexport async function hashToBase64(\n\tdata: string | ArrayBuffer,\n): Promise<string> {\n\tconst buffer = await createHash(\"SHA-256\").digest(data);\n\treturn base64.encode(buffer);\n}\n","import { createRandomStringGenerator } from \"@better-auth/utils/random\";\n\nexport const generateId = (size: number) => {\n\treturn createRandomStringGenerator(\"a-z\", \"A-Z\", \"0-9\")(size || 32);\n};\n","import { hashToBase64 } from \"./utils/hash\";\nimport { generateId } from \"./utils/id\";\nimport { getNameFromLocalPackageJson } from \"./utils/package-json\";\n\nlet projectIdCached: string | null = null;\n\nexport async function getProjectId(\n\tbaseUrl: string | undefined,\n): Promise<string> {\n\tif (projectIdCached) return projectIdCached;\n\n\tconst projectName = await getNameFromLocalPackageJson();\n\tif (projectName) {\n\t\tprojectIdCached = await hashToBase64(\n\t\t\tbaseUrl ? baseUrl + projectName : projectName,\n\t\t);\n\t\treturn projectIdCached;\n\t}\n\n\tif (baseUrl) {\n\t\tprojectIdCached = await hashToBase64(baseUrl);\n\t\treturn projectIdCached;\n\t}\n\n\tprojectIdCached = generateId(32);\n\treturn projectIdCached;\n}\n","import type { BetterAuthOptions } from \"@better-auth/core\";\nimport { ENV, getBooleanEnvVar, isTest, logger } from \"@better-auth/core/env\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { getTelemetryAuthConfig } from \"./detectors/detect-auth-config\";\nimport { detectDatabase } from \"./detectors/detect-database\";\nimport { detectFramework } from \"./detectors/detect-framework\";\nimport { detectPackageManager } from \"./detectors/detect-project-info\";\nimport { detectEnvironment, detectRuntime } from \"./detectors/detect-runtime\";\nimport { detectSystemInfo } from \"./detectors/detect-system-info\";\nimport { getProjectId } from \"./project-id\";\nimport type { TelemetryContext, TelemetryEvent } from \"./types\";\nexport { getTelemetryAuthConfig };\nexport type { TelemetryEvent } from \"./types\";\n\nconst noop: (event: TelemetryEvent) => Promise<void> = async function noop() {};\n\nexport async function createTelemetry(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\tconst debugEnabled =\n\t\toptions.telemetry?.debug ||\n\t\tgetBooleanEnvVar(\"BETTER_AUTH_TELEMETRY_DEBUG\", false);\n\n\tconst telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT;\n\t// Return noop if no endpoint and no custom track function\n\tif (!telemetryEndpoint && !context?.customTrack) {\n\t\treturn {\n\t\t\tpublish: noop,\n\t\t};\n\t}\n\tconst track = async (event: TelemetryEvent) => {\n\t\tif (context?.customTrack) {\n\t\t\tawait context.customTrack(event).catch(logger.error);\n\t\t} else if (telemetryEndpoint) {\n\t\t\tif (debugEnabled) {\n\t\t\t\tlogger.info(\"telemetry event\", JSON.stringify(event, null, 2));\n\t\t\t} else {\n\t\t\t\tawait betterFetch(telemetryEndpoint, {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: event,\n\t\t\t\t}).catch(logger.error);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst isEnabled = async () => {\n\t\tconst telemetryEnabled =\n\t\t\toptions.telemetry?.enabled !== undefined\n\t\t\t\t? options.telemetry.enabled\n\t\t\t\t: false;\n\t\tconst envEnabled = getBooleanEnvVar(\"BETTER_AUTH_TELEMETRY\", false);\n\t\treturn (\n\t\t\t(envEnabled || telemetryEnabled) && (context?.skipTestCheck || !isTest())\n\t\t);\n\t};\n\n\tconst enabled = await isEnabled();\n\tlet anonymousId: string | undefined;\n\n\tif (enabled) {\n\t\tanonymousId = await getProjectId(\n\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t);\n\n\t\tconst payload = {\n\t\t\tconfig: await getTelemetryAuthConfig(options, context),\n\t\t\truntime: detectRuntime(),\n\t\t\tdatabase: await detectDatabase(),\n\t\t\tframework: await detectFramework(),\n\t\t\tenvironment: detectEnvironment(),\n\t\t\tsystemInfo: await detectSystemInfo(),\n\t\t\tpackageManager: detectPackageManager(),\n\t\t};\n\n\t\tvoid track({ type: \"init\", payload, anonymousId });\n\t}\n\n\treturn {\n\t\tpublish: async (event: TelemetryEvent) => {\n\t\t\tif (!enabled) return;\n\t\t\tif (!anonymousId) {\n\t\t\t\tanonymousId = await getProjectId(\n\t\t\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait track({\n\t\t\t\ttype: event.type,\n\t\t\t\tpayload: event.payload,\n\t\t\t\tanonymousId,\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAGA,eAAsB,uBACrB,SACA,SACC;AACD,QAAO;EACN,UAAU,SAAS;EACnB,SAAS,SAAS;EAClB,mBAAmB;GAClB,uBAAuB,CAAC,CAAC,QAAQ,mBAAmB;GACpD,cAAc,CAAC,CAAC,QAAQ,mBAAmB;GAC3C,cAAc,CAAC,CAAC,QAAQ,mBAAmB;GAC3C,6BACC,CAAC,CAAC,QAAQ,mBAAmB;GAC9B,WAAW,QAAQ,mBAAmB;GACtC,yBACC,CAAC,CAAC,QAAQ,mBAAmB;GAC9B,wBACC,CAAC,CAAC,QAAQ,mBAAmB;GAC9B;EACD,kBAAkB;GACjB,SAAS,CAAC,CAAC,QAAQ,kBAAkB;GACrC,eAAe,CAAC,CAAC,QAAQ,kBAAkB;GAC3C,0BACC,CAAC,CAAC,QAAQ,kBAAkB;GAC7B,mBAAmB,QAAQ,kBAAkB;GAC7C,mBAAmB,QAAQ,kBAAkB;GAC7C,mBAAmB,CAAC,CAAC,QAAQ,kBAAkB;GAC/C,6BACC,QAAQ,kBAAkB;GAC3B,iBAAiB,CAAC,CAAC,QAAQ,kBAAkB;GAC7C,UAAU;IACT,MAAM,CAAC,CAAC,QAAQ,kBAAkB,UAAU;I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OAAO,UAA0B;AACzC,MAAI,CAAC,QAAS;AACd,MAAI,CAAC,YACJ,eAAc,MAAM,aACnB,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU,OACxD;AAEF,QAAM,MAAM;GACX,MAAM,MAAM;GACZ,SAAS,MAAM;GACf;GACA,CAAC;IAEH"} | ||
| {"version":3,"file":"index.mjs","names":[],"sources":["../src/detectors/detect-auth-config.ts","../src/utils/package-json.ts","../src/detectors/detect-database.ts","../src/detectors/detect-framework.ts","../src/detectors/detect-project-info.ts","../src/detectors/detect-system-info.ts","../src/detectors/detect-runtime.ts","../src/utils/hash.ts","../src/utils/id.ts","../src/project-id.ts","../src/index.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"@better-auth/core\";\nimport type { TelemetryContext } from \"../types\";\n\nexport async function getTelemetryAuthConfig(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\treturn {\n\t\tdatabase: context?.database,\n\t\tadapter: context?.adapter,\n\t\temailVerification: {\n\t\t\tsendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,\n\t\t\tsendOnSignUp: !!options.emailVerification?.sendOnSignUp,\n\t\t\tsendOnSignIn: !!options.emailVerification?.sendOnSignIn,\n\t\t\tautoSignInAfterVerification:\n\t\t\t\t!!options.emailVerification?.autoSignInAfterVerification,\n\t\t\texpiresIn: options.emailVerification?.expiresIn,\n\t\t\tbeforeEmailVerification:\n\t\t\t\t!!options.emailVerification?.beforeEmailVerification,\n\t\t\tafterEmailVerification:\n\t\t\t\t!!options.emailVerification?.afterEmailVerification,\n\t\t},\n\t\temailAndPassword: {\n\t\t\tenabled: !!options.emailAndPassword?.enabled,\n\t\t\tdisableSignUp: !!options.emailAndPassword?.disableSignUp,\n\t\t\trequireEmailVerification:\n\t\t\t\t!!options.emailAndPassword?.requireEmailVerification,\n\t\t\tmaxPasswordLength: options.emailAndPassword?.maxPasswordLength,\n\t\t\tminPasswordLength: options.emailAndPassword?.minPasswordLength,\n\t\t\tsendResetPassword: !!options.emailAndPassword?.sendResetPassword,\n\t\t\tresetPasswordTokenExpiresIn:\n\t\t\t\toptions.emailAndPassword?.resetPasswordTokenExpiresIn,\n\t\t\tonPasswordReset: !!options.emailAndPassword?.onPasswordReset,\n\t\t\tpassword: {\n\t\t\t\thash: !!options.emailAndPassword?.password?.hash,\n\t\t\t\tverify: !!options.emailAndPassword?.password?.verify,\n\t\t\t},\n\t\t\tautoSignIn: !!options.emailAndPassword?.autoSignIn,\n\t\t\trevokeSessionsOnPasswordReset:\n\t\t\t\t!!options.emailAndPassword?.revokeSessionsOnPasswordReset,\n\t\t},\n\t\tsocialProviders: await Promise.all(\n\t\t\tObject.keys(options.socialProviders || {}).map(async (key) => {\n\t\t\t\tconst p =\n\t\t\t\t\toptions.socialProviders?.[\n\t\t\t\t\t\tkey as keyof typeof options.socialProviders\n\t\t\t\t\t];\n\t\t\t\tif (!p) return {};\n\t\t\t\tconst provider = typeof p === \"function\" ? await p() : p;\n\t\t\t\treturn {\n\t\t\t\t\tid: key,\n\t\t\t\t\tmapProfileToUser: !!provider.mapProfileToUser,\n\t\t\t\t\tdisableDefaultScope: !!provider.disableDefaultScope,\n\t\t\t\t\tdisableIdTokenSignIn: !!provider.disableIdTokenSignIn,\n\t\t\t\t\tdisableImplicitSignUp: provider.disableImplicitSignUp,\n\t\t\t\t\tdisableSignUp: provider.disableSignUp,\n\t\t\t\t\tgetUserInfo: !!provider.getUserInfo,\n\t\t\t\t\toverrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,\n\t\t\t\t\tprompt: provider.prompt,\n\t\t\t\t\tverifyIdToken: !!provider.verifyIdToken,\n\t\t\t\t\tscope: provider.scope,\n\t\t\t\t\trefreshAccessToken: !!provider.refreshAccessToken,\n\t\t\t\t};\n\t\t\t}),\n\t\t),\n\t\tplugins: options.plugins?.map((p) => p.id.toString()),\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName,\n\t\t\tfields: options.user?.fields,\n\t\t\tadditionalFields: options.user?.additionalFields,\n\t\t\tchangeEmail: {\n\t\t\t\tenabled: options.user?.changeEmail?.enabled,\n\t\t\t\tsendChangeEmailConfirmation:\n\t\t\t\t\t!!options.user?.changeEmail?.sendChangeEmailConfirmation,\n\t\t\t},\n\t\t},\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName,\n\t\t\tdisableCleanup: options.verification?.disableCleanup,\n\t\t\tfields: options.verification?.fields,\n\t\t},\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName,\n\t\t\tadditionalFields: options.session?.additionalFields,\n\t\t\tcookieCache: {\n\t\t\t\tenabled: options.session?.cookieCache?.enabled,\n\t\t\t\tmaxAge: options.session?.cookieCache?.maxAge,\n\t\t\t\tstrategy: options.session?.cookieCache?.strategy,\n\t\t\t},\n\t\t\tdisableSessionRefresh: options.session?.disableSessionRefresh,\n\t\t\texpiresIn: options.session?.expiresIn,\n\t\t\tfields: options.session?.fields,\n\t\t\tfreshAge: options.session?.freshAge,\n\t\t\tpreserveSessionInDatabase: options.session?.preserveSessionInDatabase,\n\t\t\tstoreSessionInDatabase: options.session?.storeSessionInDatabase,\n\t\t\tupdateAge: options.session?.updateAge,\n\t\t},\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName,\n\t\t\tfields: options.account?.fields,\n\t\t\tencryptOAuthTokens: options.account?.encryptOAuthTokens,\n\t\t\tupdateAccountOnSignIn: options.account?.updateAccountOnSignIn,\n\t\t\taccountLinking: {\n\t\t\t\tenabled: options.account?.accountLinking?.enabled,\n\t\t\t\ttrustedProviders: options.account?.accountLinking?.trustedProviders,\n\t\t\t\tupdateUserInfoOnLink:\n\t\t\t\t\toptions.account?.accountLinking?.updateUserInfoOnLink,\n\t\t\t\tallowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll,\n\t\t\t},\n\t\t},\n\t\thooks: {\n\t\t\tafter: !!options.hooks?.after,\n\t\t\tbefore: !!options.hooks?.before,\n\t\t},\n\t\tsecondaryStorage: !!options.secondaryStorage,\n\t\tadvanced: {\n\t\t\tcookiePrefix: !!options.advanced?.cookiePrefix, //this shouldn't be tracked\n\t\t\tcookies: !!options.advanced?.cookies,\n\t\t\tcrossSubDomainCookies: {\n\t\t\t\tdomain: !!options.advanced?.crossSubDomainCookies?.domain,\n\t\t\t\tenabled: options.advanced?.crossSubDomainCookies?.enabled,\n\t\t\t\tadditionalCookies:\n\t\t\t\t\toptions.advanced?.crossSubDomainCookies?.additionalCookies,\n\t\t\t},\n\t\t\tdatabase: {\n\t\t\t\tgenerateId: options.advanced?.database?.generateId,\n\t\t\t\tdefaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit,\n\t\t\t},\n\t\t\tuseSecureCookies: options.advanced?.useSecureCookies,\n\t\t\tipAddress: {\n\t\t\t\tdisableIpTracking: options.advanced?.ipAddress?.disableIpTracking,\n\t\t\t\tipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders,\n\t\t\t},\n\t\t\tdisableCSRFCheck: options.advanced?.disableCSRFCheck,\n\t\t\tcookieAttributes: {\n\t\t\t\texpires: options.advanced?.defaultCookieAttributes?.expires,\n\t\t\t\tsecure: options.advanced?.defaultCookieAttributes?.secure,\n\t\t\t\tsameSite: options.advanced?.defaultCookieAttributes?.sameSite,\n\t\t\t\tdomain: !!options.advanced?.defaultCookieAttributes?.domain,\n\t\t\t\tpath: options.advanced?.defaultCookieAttributes?.path,\n\t\t\t\thttpOnly: options.advanced?.defaultCookieAttributes?.httpOnly,\n\t\t\t},\n\t\t},\n\t\ttrustedOrigins: options.trustedOrigins?.length,\n\t\trateLimit: {\n\t\t\tstorage: options.rateLimit?.storage,\n\t\t\tmodelName: options.rateLimit?.modelName,\n\t\t\twindow: options.rateLimit?.window,\n\t\t\tcustomStorage: !!options.rateLimit?.customStorage,\n\t\t\tenabled: options.rateLimit?.enabled,\n\t\t\tmax: options.rateLimit?.max,\n\t\t},\n\t\tonAPIError: {\n\t\t\terrorURL: options.onAPIError?.errorURL,\n\t\t\tonError: !!options.onAPIError?.onError,\n\t\t\tthrow: options.onAPIError?.throw,\n\t\t},\n\t\tlogger: {\n\t\t\tdisabled: options.logger?.disabled,\n\t\t\tlevel: options.logger?.level,\n\t\t\tlog: !!options.logger?.log,\n\t\t},\n\t\tdatabaseHooks: {\n\t\t\tuser: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.user?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.user?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsession: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.session?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.session?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\taccount: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.account?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.account?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t\tverification: {\n\t\t\t\tcreate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.create?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.create?.before,\n\t\t\t\t},\n\t\t\t\tupdate: {\n\t\t\t\t\tafter: !!options.databaseHooks?.verification?.update?.after,\n\t\t\t\t\tbefore: !!options.databaseHooks?.verification?.update?.before,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n","// In the default (non-node) build, filesystem access is not available.\n// The node build (src/node.ts) provides its own inline implementation\n// using static top-level imports of node:fs/promises and node:path.\n\nexport async function getPackageVersion(\n\t_pkg: string,\n): Promise<string | undefined> {\n\treturn undefined;\n}\n\nexport async function getNameFromLocalPackageJson(): Promise<\n\tstring | undefined\n> {\n\treturn undefined;\n}\n","import type { DetectionInfo } from \"../types\";\nimport { getPackageVersion } from \"../utils/package-json\";\n\nconst DATABASES: Record<string, string> = {\n\tpg: \"postgresql\",\n\tmysql: \"mysql\",\n\tmariadb: \"mariadb\",\n\tsqlite3: \"sqlite\",\n\t\"better-sqlite3\": \"sqlite\",\n\t\"@prisma/client\": \"prisma\",\n\tmongoose: \"mongodb\",\n\tmongodb: \"mongodb\",\n\t\"drizzle-orm\": \"drizzle\",\n};\n\nexport async function detectDatabase(): Promise<DetectionInfo | undefined> {\n\tfor (const [pkg, name] of Object.entries(DATABASES)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n","import { getPackageVersion } from \"../utils/package-json\";\n\nconst FRAMEWORKS: Record<string, string> = {\n\tnext: \"next\",\n\tnuxt: \"nuxt\",\n\t\"react-router\": \"react-router\",\n\tastro: \"astro\",\n\t\"@sveltejs/kit\": \"sveltekit\",\n\t\"solid-start\": \"solid-start\",\n\t\"tanstack-start\": \"tanstack-start\",\n\thono: \"hono\",\n\texpress: \"express\",\n\telysia: \"elysia\",\n\texpo: \"expo\",\n};\n\nexport async function detectFramework() {\n\tfor (const [pkg, name] of Object.entries(FRAMEWORKS)) {\n\t\tconst version = await getPackageVersion(pkg);\n\t\tif (version) return { name, version };\n\t}\n\treturn undefined;\n}\n","// https://github.com/zkochan/packages/blob/main/which-pm-runs/index.js\nimport { env } from \"@better-auth/core/env\";\n\nexport function detectPackageManager() {\n\tconst userAgent = env.npm_config_user_agent;\n\tif (!userAgent) {\n\t\treturn undefined;\n\t}\n\n\tconst pmSpec = userAgent.split(\" \")[0]!;\n\tconst separatorPos = pmSpec.lastIndexOf(\"/\");\n\tconst name = pmSpec.substring(0, separatorPos);\n\n\treturn {\n\t\tname: name === \"npminstall\" ? \"cnpm\" : name,\n\t\tversion: pmSpec.substring(separatorPos + 1),\n\t};\n}\n","import { env } from \"@better-auth/core/env\";\n\nfunction getVendor() {\n\tconst hasAny = (...keys: string[]) =>\n\t\tkeys.some((k) => Boolean((env as any)[k]));\n\n\tif (\n\t\thasAny(\"CF_PAGES\", \"CF_PAGES_URL\", \"CF_ACCOUNT_ID\") ||\n\t\t(typeof navigator !== \"undefined\" &&\n\t\t\tnavigator.userAgent === \"Cloudflare-Workers\")\n\t) {\n\t\treturn \"cloudflare\";\n\t}\n\n\tif (hasAny(\"VERCEL\", \"VERCEL_URL\", \"VERCEL_ENV\")) return \"vercel\";\n\n\tif (hasAny(\"NETLIFY\", \"NETLIFY_URL\")) return \"netlify\";\n\n\tif (\n\t\thasAny(\n\t\t\t\"RENDER\",\n\t\t\t\"RENDER_URL\",\n\t\t\t\"RENDER_INTERNAL_HOSTNAME\",\n\t\t\t\"RENDER_SERVICE_ID\",\n\t\t)\n\t) {\n\t\treturn \"render\";\n\t}\n\n\tif (\n\t\thasAny(\"AWS_LAMBDA_FUNCTION_NAME\", \"AWS_EXECUTION_ENV\", \"LAMBDA_TASK_ROOT\")\n\t) {\n\t\treturn \"aws\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"GOOGLE_CLOUD_FUNCTION_NAME\",\n\t\t\t\"GOOGLE_CLOUD_PROJECT\",\n\t\t\t\"GCP_PROJECT\",\n\t\t\t\"K_SERVICE\",\n\t\t)\n\t) {\n\t\treturn \"gcp\";\n\t}\n\n\tif (\n\t\thasAny(\n\t\t\t\"AZURE_FUNCTION_NAME\",\n\t\t\t\"FUNCTIONS_WORKER_RUNTIME\",\n\t\t\t\"WEBSITE_INSTANCE_ID\",\n\t\t\t\"WEBSITE_SITE_NAME\",\n\t\t)\n\t) {\n\t\treturn \"azure\";\n\t}\n\n\tif (hasAny(\"DENO_DEPLOYMENT_ID\", \"DENO_REGION\")) return \"deno-deploy\";\n\n\tif (hasAny(\"FLY_APP_NAME\", \"FLY_REGION\", \"FLY_ALLOC_ID\")) return \"fly-io\";\n\n\tif (hasAny(\"RAILWAY_STATIC_URL\", \"RAILWAY_ENVIRONMENT_NAME\"))\n\t\treturn \"railway\";\n\n\tif (hasAny(\"DYNO\", \"HEROKU_APP_NAME\")) return \"heroku\";\n\n\tif (hasAny(\"DO_DEPLOYMENT_ID\", \"DO_APP_NAME\", \"DIGITALOCEAN\"))\n\t\treturn \"digitalocean\";\n\n\tif (hasAny(\"KOYEB\", \"KOYEB_DEPLOYMENT_ID\", \"KOYEB_APP_NAME\")) return \"koyeb\";\n\n\treturn null;\n}\n\n// In the default (non-node) build, system info detection is not available.\n// The node build (src/node.ts) provides its own inline implementation\n// using static top-level imports of node:os and node:fs.\nexport async function detectSystemInfo() {\n\treturn {\n\t\tdeploymentVendor: getVendor(),\n\t\tsystemPlatform: null,\n\t\tsystemRelease: null,\n\t\tsystemArchitecture: null,\n\t\tcpuCount: null,\n\t\tcpuModel: null,\n\t\tcpuSpeed: null,\n\t\tmemory: null,\n\t\tisWSL: null,\n\t\tisDocker: null,\n\t\tisTTY: null,\n\t};\n}\n\nexport function isCI() {\n\treturn (\n\t\tenv.CI !== \"false\" &&\n\t\t(\"BUILD_ID\" in env || // Jenkins, Cloudbees\n\t\t\t\"BUILD_NUMBER\" in env || // Jenkins, TeamCity\n\t\t\t\"CI\" in env || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare\n\t\t\t\"CI_APP_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_ID\" in env || // Appflow\n\t\t\t\"CI_BUILD_NUMBER\" in env || // Appflow\n\t\t\t\"CI_NAME\" in env || // Codeship and others\n\t\t\t\"CONTINUOUS_INTEGRATION\" in env || // Travis CI, Cirrus CI\n\t\t\t\"RUN_ID\" in env) // TaskCluster, dsari\n\t);\n}\n","import { getEnvVar, isTest } from \"@better-auth/core/env\";\nimport { isCI } from \"./detect-system-info\";\n\nexport function detectRuntime() {\n\t// @ts-expect-error: TS doesn't know about Deno global\n\tif (typeof Deno !== \"undefined\") {\n\t\t// @ts-expect-error: TS doesn't know about Deno global\n\t\tconst denoVersion = Deno?.version?.deno ?? null;\n\t\treturn { name: \"deno\", version: denoVersion };\n\t}\n\n\tif (typeof Bun !== \"undefined\") {\n\t\tconst bunVersion = Bun?.version ?? null;\n\t\treturn { name: \"bun\", version: bunVersion };\n\t}\n\n\tif (typeof process !== \"undefined\" && process?.versions?.node) {\n\t\treturn { name: \"node\", version: process.versions.node ?? null };\n\t}\n\treturn { name: \"edge\", version: null };\n}\n\nexport function detectEnvironment() {\n\treturn getEnvVar(\"NODE_ENV\") === \"production\"\n\t\t? \"production\"\n\t\t: isCI()\n\t\t\t? \"ci\"\n\t\t\t: isTest()\n\t\t\t\t? \"test\"\n\t\t\t\t: \"development\";\n}\n","import { base64 } from \"@better-auth/utils/base64\";\nimport { createHash } from \"@better-auth/utils/hash\";\n\nexport async function hashToBase64(\n\tdata: string | ArrayBuffer,\n): Promise<string> {\n\tconst buffer = await createHash(\"SHA-256\").digest(data);\n\treturn base64.encode(buffer);\n}\n","import { createRandomStringGenerator } from \"@better-auth/utils/random\";\n\nexport const generateId = (size: number) => {\n\treturn createRandomStringGenerator(\"a-z\", \"A-Z\", \"0-9\")(size || 32);\n};\n","import { hashToBase64 } from \"./utils/hash\";\nimport { generateId } from \"./utils/id\";\nimport { getNameFromLocalPackageJson } from \"./utils/package-json\";\n\nlet projectIdCached: string | null = null;\n\nexport async function getProjectId(\n\tbaseUrl: string | undefined,\n): Promise<string> {\n\tif (projectIdCached) return projectIdCached;\n\n\tconst projectName = await getNameFromLocalPackageJson();\n\tif (projectName) {\n\t\tprojectIdCached = await hashToBase64(\n\t\t\tbaseUrl ? baseUrl + projectName : projectName,\n\t\t);\n\t\treturn projectIdCached;\n\t}\n\n\tif (baseUrl) {\n\t\tprojectIdCached = await hashToBase64(baseUrl);\n\t\treturn projectIdCached;\n\t}\n\n\tprojectIdCached = generateId(32);\n\treturn projectIdCached;\n}\n","import type { BetterAuthOptions } from \"@better-auth/core\";\nimport { ENV, getBooleanEnvVar, isTest, logger } from \"@better-auth/core/env\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { getTelemetryAuthConfig } from \"./detectors/detect-auth-config\";\nimport { detectDatabase } from \"./detectors/detect-database\";\nimport { detectFramework } from \"./detectors/detect-framework\";\nimport { detectPackageManager } from \"./detectors/detect-project-info\";\nimport { detectEnvironment, detectRuntime } from \"./detectors/detect-runtime\";\nimport { detectSystemInfo } from \"./detectors/detect-system-info\";\nimport { getProjectId } from \"./project-id\";\nimport type { TelemetryContext, TelemetryEvent } from \"./types\";\nexport { getTelemetryAuthConfig };\nexport type { TelemetryEvent } from \"./types\";\n\nconst noop: (event: TelemetryEvent) => Promise<void> = async function noop() {};\n\nexport async function createTelemetry(\n\toptions: BetterAuthOptions,\n\tcontext?: TelemetryContext | undefined,\n) {\n\tconst debugEnabled =\n\t\toptions.telemetry?.debug ||\n\t\tgetBooleanEnvVar(\"BETTER_AUTH_TELEMETRY_DEBUG\", false);\n\n\tconst telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT;\n\t// Return noop if no endpoint and no custom track function\n\tif (!telemetryEndpoint && !context?.customTrack) {\n\t\treturn {\n\t\t\tpublish: noop,\n\t\t};\n\t}\n\tconst track = async (event: TelemetryEvent) => {\n\t\tif (context?.customTrack) {\n\t\t\tawait context.customTrack(event).catch(logger.error);\n\t\t} else if (telemetryEndpoint) {\n\t\t\tif (debugEnabled) {\n\t\t\t\tlogger.info(\"telemetry event\", JSON.stringify(event, null, 2));\n\t\t\t} else {\n\t\t\t\tawait betterFetch(telemetryEndpoint, {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: event,\n\t\t\t\t}).catch(logger.error);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst isEnabled = async () => {\n\t\tconst telemetryEnabled =\n\t\t\toptions.telemetry?.enabled !== undefined\n\t\t\t\t? options.telemetry.enabled\n\t\t\t\t: false;\n\t\tconst envEnabled = getBooleanEnvVar(\"BETTER_AUTH_TELEMETRY\", false);\n\t\treturn (\n\t\t\t(envEnabled || telemetryEnabled) && (context?.skipTestCheck || !isTest())\n\t\t);\n\t};\n\n\tconst enabled = await isEnabled();\n\tlet anonymousId: string | undefined;\n\n\tif (enabled) {\n\t\tanonymousId = await getProjectId(\n\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t);\n\n\t\tconst payload = {\n\t\t\tconfig: await getTelemetryAuthConfig(options, context),\n\t\t\truntime: detectRuntime(),\n\t\t\tdatabase: await detectDatabase(),\n\t\t\tframework: await detectFramework(),\n\t\t\tenvironment: detectEnvironment(),\n\t\t\tsystemInfo: await detectSystemInfo(),\n\t\t\tpackageManager: detectPackageManager(),\n\t\t};\n\n\t\tvoid track({ type: \"init\", payload, anonymousId });\n\t}\n\n\treturn {\n\t\tpublish: async (event: TelemetryEvent) => {\n\t\t\tif (!enabled) return;\n\t\t\tif (!anonymousId) {\n\t\t\t\tanonymousId = await getProjectId(\n\t\t\t\t\ttypeof options.baseURL === \"string\" ? options.baseURL : undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait track({\n\t\t\t\ttype: event.type,\n\t\t\t\tpayload: event.payload,\n\t\t\t\tanonymousId,\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAGA,eAAsB,uBACrB,SACA,SACC;AACD,QAAO;EACN,UAAU,SAAS;EACnB,SAAS,SAAS;EAClB,mBAAmB;GAClB,uBAAuB,CAAC,CAAC,QAAQ,mBAAmB;GACpD,cAAc,CAAC,CAAC,QAAQ,mBAAmB;GAC3C,cAAc,CAAC,CAAC,QAAQ,mBAAmB;GAC3C,6BACC,CAAC,CAAC,QAAQ,mBAAmB;GAC9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AAC,YACJ,eAAc,MAAM,aACnB,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU,OACxD;AAEF,QAAM,MAAM;GACX,MAAM,MAAM;GACZ,SAAS,MAAM;GACf;GACA,CAAC;IAEH"} |
+4
-3
| { | ||
| "name": "@better-auth/telemetry", | ||
| "version": "1.5.4", | ||
| "version": "1.5.5", | ||
| "description": "Telemetry package for Better Auth", | ||
@@ -32,2 +32,3 @@ "type": "module", | ||
| "types": "./dist/index.d.mts", | ||
| "node": "./dist/node.mjs", | ||
| "default": "./dist/index.mjs" | ||
@@ -50,6 +51,6 @@ } | ||
| "type-fest": "^5.4.4", | ||
| "@better-auth/core": "1.5.4" | ||
| "@better-auth/core": "1.5.5" | ||
| }, | ||
| "peerDependencies": { | ||
| "@better-auth/core": "1.5.4" | ||
| "@better-auth/core": "1.5.5" | ||
| }, | ||
@@ -56,0 +57,0 @@ "scripts": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
110657
74.38%9
50%872
73.71%4
-20%1
Infinity%