@hammadj/better-auth-telemetry 1.5.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +52 -0
- package/LICENSE.md +20 -0
- package/dist/index.d.mts +217 -0
- package/dist/index.mjs +516 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
- package/src/detectors/detect-auth-config.ts +203 -0
- package/src/detectors/detect-database.ts +22 -0
- package/src/detectors/detect-framework.ts +23 -0
- package/src/detectors/detect-project-info.ts +18 -0
- package/src/detectors/detect-runtime.ts +31 -0
- package/src/detectors/detect-system-info.ts +209 -0
- package/src/index.ts +90 -0
- package/src/project-id.ts +27 -0
- package/src/telemetry.test.ts +350 -0
- package/src/types.ts +16 -0
- package/src/utils/hash.ts +9 -0
- package/src/utils/id.ts +5 -0
- package/src/utils/import-util.ts +3 -0
- package/src/utils/package-json.ts +75 -0
- package/tsconfig.json +8 -0
- package/tsdown.config.ts +8 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { ENV, env, getBooleanEnvVar, getEnvVar, isTest, logger } from "@better-auth/core/env";
|
|
2
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
+
import { base64 } from "@better-auth/utils/base64";
|
|
4
|
+
import { createHash } from "@better-auth/utils/hash";
|
|
5
|
+
import { createRandomStringGenerator } from "@better-auth/utils/random";
|
|
6
|
+
|
|
7
|
+
//#region src/detectors/detect-auth-config.ts
|
|
8
|
+
function getTelemetryAuthConfig(options, context) {
|
|
9
|
+
return {
|
|
10
|
+
database: context?.database,
|
|
11
|
+
adapter: context?.adapter,
|
|
12
|
+
emailVerification: {
|
|
13
|
+
sendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,
|
|
14
|
+
sendOnSignUp: !!options.emailVerification?.sendOnSignUp,
|
|
15
|
+
sendOnSignIn: !!options.emailVerification?.sendOnSignIn,
|
|
16
|
+
autoSignInAfterVerification: !!options.emailVerification?.autoSignInAfterVerification,
|
|
17
|
+
expiresIn: options.emailVerification?.expiresIn,
|
|
18
|
+
onEmailVerification: !!options.emailVerification?.onEmailVerification,
|
|
19
|
+
afterEmailVerification: !!options.emailVerification?.afterEmailVerification
|
|
20
|
+
},
|
|
21
|
+
emailAndPassword: {
|
|
22
|
+
enabled: !!options.emailAndPassword?.enabled,
|
|
23
|
+
disableSignUp: !!options.emailAndPassword?.disableSignUp,
|
|
24
|
+
requireEmailVerification: !!options.emailAndPassword?.requireEmailVerification,
|
|
25
|
+
maxPasswordLength: options.emailAndPassword?.maxPasswordLength,
|
|
26
|
+
minPasswordLength: options.emailAndPassword?.minPasswordLength,
|
|
27
|
+
sendResetPassword: !!options.emailAndPassword?.sendResetPassword,
|
|
28
|
+
resetPasswordTokenExpiresIn: options.emailAndPassword?.resetPasswordTokenExpiresIn,
|
|
29
|
+
onPasswordReset: !!options.emailAndPassword?.onPasswordReset,
|
|
30
|
+
password: {
|
|
31
|
+
hash: !!options.emailAndPassword?.password?.hash,
|
|
32
|
+
verify: !!options.emailAndPassword?.password?.verify
|
|
33
|
+
},
|
|
34
|
+
autoSignIn: !!options.emailAndPassword?.autoSignIn,
|
|
35
|
+
revokeSessionsOnPasswordReset: !!options.emailAndPassword?.revokeSessionsOnPasswordReset
|
|
36
|
+
},
|
|
37
|
+
socialProviders: Object.keys(options.socialProviders || {}).map((p) => {
|
|
38
|
+
const provider = options.socialProviders?.[p];
|
|
39
|
+
if (!provider) return {};
|
|
40
|
+
return {
|
|
41
|
+
id: p,
|
|
42
|
+
mapProfileToUser: !!provider.mapProfileToUser,
|
|
43
|
+
disableDefaultScope: !!provider.disableDefaultScope,
|
|
44
|
+
disableIdTokenSignIn: !!provider.disableIdTokenSignIn,
|
|
45
|
+
disableImplicitSignUp: provider.disableImplicitSignUp,
|
|
46
|
+
disableSignUp: provider.disableSignUp,
|
|
47
|
+
getUserInfo: !!provider.getUserInfo,
|
|
48
|
+
overrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,
|
|
49
|
+
prompt: provider.prompt,
|
|
50
|
+
verifyIdToken: !!provider.verifyIdToken,
|
|
51
|
+
scope: provider.scope,
|
|
52
|
+
refreshAccessToken: !!provider.refreshAccessToken
|
|
53
|
+
};
|
|
54
|
+
}),
|
|
55
|
+
plugins: options.plugins?.map((p) => p.id.toString()),
|
|
56
|
+
user: {
|
|
57
|
+
modelName: options.user?.modelName,
|
|
58
|
+
fields: options.user?.fields,
|
|
59
|
+
additionalFields: options.user?.additionalFields,
|
|
60
|
+
changeEmail: {
|
|
61
|
+
enabled: options.user?.changeEmail?.enabled,
|
|
62
|
+
sendChangeEmailVerification: !!options.user?.changeEmail?.sendChangeEmailVerification
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
verification: {
|
|
66
|
+
modelName: options.verification?.modelName,
|
|
67
|
+
disableCleanup: options.verification?.disableCleanup,
|
|
68
|
+
fields: options.verification?.fields
|
|
69
|
+
},
|
|
70
|
+
session: {
|
|
71
|
+
modelName: options.session?.modelName,
|
|
72
|
+
additionalFields: options.session?.additionalFields,
|
|
73
|
+
cookieCache: {
|
|
74
|
+
enabled: options.session?.cookieCache?.enabled,
|
|
75
|
+
maxAge: options.session?.cookieCache?.maxAge,
|
|
76
|
+
strategy: options.session?.cookieCache?.strategy
|
|
77
|
+
},
|
|
78
|
+
disableSessionRefresh: options.session?.disableSessionRefresh,
|
|
79
|
+
expiresIn: options.session?.expiresIn,
|
|
80
|
+
fields: options.session?.fields,
|
|
81
|
+
freshAge: options.session?.freshAge,
|
|
82
|
+
preserveSessionInDatabase: options.session?.preserveSessionInDatabase,
|
|
83
|
+
storeSessionInDatabase: options.session?.storeSessionInDatabase,
|
|
84
|
+
updateAge: options.session?.updateAge
|
|
85
|
+
},
|
|
86
|
+
account: {
|
|
87
|
+
modelName: options.account?.modelName,
|
|
88
|
+
fields: options.account?.fields,
|
|
89
|
+
encryptOAuthTokens: options.account?.encryptOAuthTokens,
|
|
90
|
+
updateAccountOnSignIn: options.account?.updateAccountOnSignIn,
|
|
91
|
+
accountLinking: {
|
|
92
|
+
enabled: options.account?.accountLinking?.enabled,
|
|
93
|
+
trustedProviders: options.account?.accountLinking?.trustedProviders,
|
|
94
|
+
updateUserInfoOnLink: options.account?.accountLinking?.updateUserInfoOnLink,
|
|
95
|
+
allowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
hooks: {
|
|
99
|
+
after: !!options.hooks?.after,
|
|
100
|
+
before: !!options.hooks?.before
|
|
101
|
+
},
|
|
102
|
+
secondaryStorage: !!options.secondaryStorage,
|
|
103
|
+
advanced: {
|
|
104
|
+
cookiePrefix: !!options.advanced?.cookiePrefix,
|
|
105
|
+
cookies: !!options.advanced?.cookies,
|
|
106
|
+
crossSubDomainCookies: {
|
|
107
|
+
domain: !!options.advanced?.crossSubDomainCookies?.domain,
|
|
108
|
+
enabled: options.advanced?.crossSubDomainCookies?.enabled,
|
|
109
|
+
additionalCookies: options.advanced?.crossSubDomainCookies?.additionalCookies
|
|
110
|
+
},
|
|
111
|
+
database: {
|
|
112
|
+
useNumberId: !!options.advanced?.database?.useNumberId || options.advanced?.database?.generateId === "serial",
|
|
113
|
+
generateId: options.advanced?.database?.generateId,
|
|
114
|
+
defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit
|
|
115
|
+
},
|
|
116
|
+
useSecureCookies: options.advanced?.useSecureCookies,
|
|
117
|
+
ipAddress: {
|
|
118
|
+
disableIpTracking: options.advanced?.ipAddress?.disableIpTracking,
|
|
119
|
+
ipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders
|
|
120
|
+
},
|
|
121
|
+
disableCSRFCheck: options.advanced?.disableCSRFCheck,
|
|
122
|
+
cookieAttributes: {
|
|
123
|
+
expires: options.advanced?.defaultCookieAttributes?.expires,
|
|
124
|
+
secure: options.advanced?.defaultCookieAttributes?.secure,
|
|
125
|
+
sameSite: options.advanced?.defaultCookieAttributes?.sameSite,
|
|
126
|
+
domain: !!options.advanced?.defaultCookieAttributes?.domain,
|
|
127
|
+
path: options.advanced?.defaultCookieAttributes?.path,
|
|
128
|
+
httpOnly: options.advanced?.defaultCookieAttributes?.httpOnly
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
trustedOrigins: options.trustedOrigins?.length,
|
|
132
|
+
rateLimit: {
|
|
133
|
+
storage: options.rateLimit?.storage,
|
|
134
|
+
modelName: options.rateLimit?.modelName,
|
|
135
|
+
window: options.rateLimit?.window,
|
|
136
|
+
customStorage: !!options.rateLimit?.customStorage,
|
|
137
|
+
enabled: options.rateLimit?.enabled,
|
|
138
|
+
max: options.rateLimit?.max
|
|
139
|
+
},
|
|
140
|
+
onAPIError: {
|
|
141
|
+
errorURL: options.onAPIError?.errorURL,
|
|
142
|
+
onError: !!options.onAPIError?.onError,
|
|
143
|
+
throw: options.onAPIError?.throw
|
|
144
|
+
},
|
|
145
|
+
logger: {
|
|
146
|
+
disabled: options.logger?.disabled,
|
|
147
|
+
level: options.logger?.level,
|
|
148
|
+
log: !!options.logger?.log
|
|
149
|
+
},
|
|
150
|
+
databaseHooks: {
|
|
151
|
+
user: {
|
|
152
|
+
create: {
|
|
153
|
+
after: !!options.databaseHooks?.user?.create?.after,
|
|
154
|
+
before: !!options.databaseHooks?.user?.create?.before
|
|
155
|
+
},
|
|
156
|
+
update: {
|
|
157
|
+
after: !!options.databaseHooks?.user?.update?.after,
|
|
158
|
+
before: !!options.databaseHooks?.user?.update?.before
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
session: {
|
|
162
|
+
create: {
|
|
163
|
+
after: !!options.databaseHooks?.session?.create?.after,
|
|
164
|
+
before: !!options.databaseHooks?.session?.create?.before
|
|
165
|
+
},
|
|
166
|
+
update: {
|
|
167
|
+
after: !!options.databaseHooks?.session?.update?.after,
|
|
168
|
+
before: !!options.databaseHooks?.session?.update?.before
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
account: {
|
|
172
|
+
create: {
|
|
173
|
+
after: !!options.databaseHooks?.account?.create?.after,
|
|
174
|
+
before: !!options.databaseHooks?.account?.create?.before
|
|
175
|
+
},
|
|
176
|
+
update: {
|
|
177
|
+
after: !!options.databaseHooks?.account?.update?.after,
|
|
178
|
+
before: !!options.databaseHooks?.account?.update?.before
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
verification: {
|
|
182
|
+
create: {
|
|
183
|
+
after: !!options.databaseHooks?.verification?.create?.after,
|
|
184
|
+
before: !!options.databaseHooks?.verification?.create?.before
|
|
185
|
+
},
|
|
186
|
+
update: {
|
|
187
|
+
after: !!options.databaseHooks?.verification?.update?.after,
|
|
188
|
+
before: !!options.databaseHooks?.verification?.update?.before
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/utils/package-json.ts
|
|
197
|
+
let packageJSONCache;
|
|
198
|
+
async function readRootPackageJson() {
|
|
199
|
+
if (packageJSONCache) return packageJSONCache;
|
|
200
|
+
try {
|
|
201
|
+
const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "";
|
|
202
|
+
if (!cwd) return void 0;
|
|
203
|
+
const importRuntime = (m) => Function("mm", "return import(mm)")(m);
|
|
204
|
+
const [{ default: fs }, { default: path }] = await Promise.all([importRuntime("fs/promises"), importRuntime("path")]);
|
|
205
|
+
const raw = await fs.readFile(path.join(cwd, "package.json"), "utf-8");
|
|
206
|
+
packageJSONCache = JSON.parse(raw);
|
|
207
|
+
return packageJSONCache;
|
|
208
|
+
} catch {}
|
|
209
|
+
}
|
|
210
|
+
async function getPackageVersion(pkg) {
|
|
211
|
+
if (packageJSONCache) return packageJSONCache.dependencies?.[pkg] || packageJSONCache.devDependencies?.[pkg] || packageJSONCache.peerDependencies?.[pkg];
|
|
212
|
+
try {
|
|
213
|
+
const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "";
|
|
214
|
+
if (!cwd) throw new Error("no-cwd");
|
|
215
|
+
const importRuntime = (m) => Function("mm", "return import(mm)")(m);
|
|
216
|
+
const [{ default: fs }, { default: path }] = await Promise.all([importRuntime("fs/promises"), importRuntime("path")]);
|
|
217
|
+
const pkgJsonPath = path.join(cwd, "node_modules", pkg, "package.json");
|
|
218
|
+
const raw = await fs.readFile(pkgJsonPath, "utf-8");
|
|
219
|
+
return JSON.parse(raw).version || await getVersionFromLocalPackageJson(pkg) || void 0;
|
|
220
|
+
} catch {}
|
|
221
|
+
return await getVersionFromLocalPackageJson(pkg);
|
|
222
|
+
}
|
|
223
|
+
async function getVersionFromLocalPackageJson(pkg) {
|
|
224
|
+
const json = await readRootPackageJson();
|
|
225
|
+
if (!json) return void 0;
|
|
226
|
+
return {
|
|
227
|
+
...json.dependencies,
|
|
228
|
+
...json.devDependencies,
|
|
229
|
+
...json.peerDependencies
|
|
230
|
+
}[pkg];
|
|
231
|
+
}
|
|
232
|
+
async function getNameFromLocalPackageJson() {
|
|
233
|
+
return (await readRootPackageJson())?.name;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/detectors/detect-database.ts
|
|
238
|
+
const DATABASES = {
|
|
239
|
+
pg: "postgresql",
|
|
240
|
+
mysql: "mysql",
|
|
241
|
+
mariadb: "mariadb",
|
|
242
|
+
sqlite3: "sqlite",
|
|
243
|
+
"better-sqlite3": "sqlite",
|
|
244
|
+
"@prisma/client": "prisma",
|
|
245
|
+
mongoose: "mongodb",
|
|
246
|
+
mongodb: "mongodb",
|
|
247
|
+
"drizzle-orm": "drizzle"
|
|
248
|
+
};
|
|
249
|
+
async function detectDatabase() {
|
|
250
|
+
for (const [pkg, name] of Object.entries(DATABASES)) {
|
|
251
|
+
const version = await getPackageVersion(pkg);
|
|
252
|
+
if (version) return {
|
|
253
|
+
name,
|
|
254
|
+
version
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/detectors/detect-framework.ts
|
|
261
|
+
const FRAMEWORKS = {
|
|
262
|
+
next: "next",
|
|
263
|
+
nuxt: "nuxt",
|
|
264
|
+
"@remix-run/server-runtime": "remix",
|
|
265
|
+
astro: "astro",
|
|
266
|
+
"@sveltejs/kit": "sveltekit",
|
|
267
|
+
"solid-start": "solid-start",
|
|
268
|
+
"tanstack-start": "tanstack-start",
|
|
269
|
+
hono: "hono",
|
|
270
|
+
express: "express",
|
|
271
|
+
elysia: "elysia",
|
|
272
|
+
expo: "expo"
|
|
273
|
+
};
|
|
274
|
+
async function detectFramework() {
|
|
275
|
+
for (const [pkg, name] of Object.entries(FRAMEWORKS)) {
|
|
276
|
+
const version = await getPackageVersion(pkg);
|
|
277
|
+
if (version) return {
|
|
278
|
+
name,
|
|
279
|
+
version
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/detectors/detect-project-info.ts
|
|
286
|
+
function detectPackageManager() {
|
|
287
|
+
const userAgent = env.npm_config_user_agent;
|
|
288
|
+
if (!userAgent) return;
|
|
289
|
+
const pmSpec = userAgent.split(" ")[0];
|
|
290
|
+
const separatorPos = pmSpec.lastIndexOf("/");
|
|
291
|
+
const name = pmSpec.substring(0, separatorPos);
|
|
292
|
+
return {
|
|
293
|
+
name: name === "npminstall" ? "cnpm" : name,
|
|
294
|
+
version: pmSpec.substring(separatorPos + 1)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/utils/import-util.ts
|
|
300
|
+
const importRuntime = (m) => {
|
|
301
|
+
return Function("mm", "return import(mm)")(m);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/detectors/detect-system-info.ts
|
|
306
|
+
function getVendor() {
|
|
307
|
+
const hasAny = (...keys) => keys.some((k) => Boolean(env[k]));
|
|
308
|
+
if (hasAny("CF_PAGES", "CF_PAGES_URL", "CF_ACCOUNT_ID") || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") return "cloudflare";
|
|
309
|
+
if (hasAny("VERCEL", "VERCEL_URL", "VERCEL_ENV")) return "vercel";
|
|
310
|
+
if (hasAny("NETLIFY", "NETLIFY_URL")) return "netlify";
|
|
311
|
+
if (hasAny("RENDER", "RENDER_URL", "RENDER_INTERNAL_HOSTNAME", "RENDER_SERVICE_ID")) return "render";
|
|
312
|
+
if (hasAny("AWS_LAMBDA_FUNCTION_NAME", "AWS_EXECUTION_ENV", "LAMBDA_TASK_ROOT")) return "aws";
|
|
313
|
+
if (hasAny("GOOGLE_CLOUD_FUNCTION_NAME", "GOOGLE_CLOUD_PROJECT", "GCP_PROJECT", "K_SERVICE")) return "gcp";
|
|
314
|
+
if (hasAny("AZURE_FUNCTION_NAME", "FUNCTIONS_WORKER_RUNTIME", "WEBSITE_INSTANCE_ID", "WEBSITE_SITE_NAME")) return "azure";
|
|
315
|
+
if (hasAny("DENO_DEPLOYMENT_ID", "DENO_REGION")) return "deno-deploy";
|
|
316
|
+
if (hasAny("FLY_APP_NAME", "FLY_REGION", "FLY_ALLOC_ID")) return "fly-io";
|
|
317
|
+
if (hasAny("RAILWAY_STATIC_URL", "RAILWAY_ENVIRONMENT_NAME")) return "railway";
|
|
318
|
+
if (hasAny("DYNO", "HEROKU_APP_NAME")) return "heroku";
|
|
319
|
+
if (hasAny("DO_DEPLOYMENT_ID", "DO_APP_NAME", "DIGITALOCEAN")) return "digitalocean";
|
|
320
|
+
if (hasAny("KOYEB", "KOYEB_DEPLOYMENT_ID", "KOYEB_APP_NAME")) return "koyeb";
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
async function detectSystemInfo() {
|
|
324
|
+
try {
|
|
325
|
+
if (getVendor() === "cloudflare") return "cloudflare";
|
|
326
|
+
const os = await importRuntime("os");
|
|
327
|
+
const cpus = os.cpus();
|
|
328
|
+
return {
|
|
329
|
+
deploymentVendor: getVendor(),
|
|
330
|
+
systemPlatform: os.platform(),
|
|
331
|
+
systemRelease: os.release(),
|
|
332
|
+
systemArchitecture: os.arch(),
|
|
333
|
+
cpuCount: cpus.length,
|
|
334
|
+
cpuModel: cpus.length ? cpus[0].model : null,
|
|
335
|
+
cpuSpeed: cpus.length ? cpus[0].speed : null,
|
|
336
|
+
memory: os.totalmem(),
|
|
337
|
+
isWSL: await isWsl(),
|
|
338
|
+
isDocker: await isDocker(),
|
|
339
|
+
isTTY: typeof process !== "undefined" && process.stdout ? process.stdout.isTTY : null
|
|
340
|
+
};
|
|
341
|
+
} catch {
|
|
342
|
+
return {
|
|
343
|
+
systemPlatform: null,
|
|
344
|
+
systemRelease: null,
|
|
345
|
+
systemArchitecture: null,
|
|
346
|
+
cpuCount: null,
|
|
347
|
+
cpuModel: null,
|
|
348
|
+
cpuSpeed: null,
|
|
349
|
+
memory: null,
|
|
350
|
+
isWSL: null,
|
|
351
|
+
isDocker: null,
|
|
352
|
+
isTTY: null
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
let isDockerCached;
|
|
357
|
+
async function hasDockerEnv() {
|
|
358
|
+
if (getVendor() === "cloudflare") return false;
|
|
359
|
+
try {
|
|
360
|
+
(await importRuntime("fs")).statSync("/.dockerenv");
|
|
361
|
+
return true;
|
|
362
|
+
} catch {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
async function hasDockerCGroup() {
|
|
367
|
+
if (getVendor() === "cloudflare") return false;
|
|
368
|
+
try {
|
|
369
|
+
return (await importRuntime("fs")).readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
370
|
+
} catch {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async function isDocker() {
|
|
375
|
+
if (getVendor() === "cloudflare") return false;
|
|
376
|
+
if (isDockerCached === void 0) isDockerCached = await hasDockerEnv() || await hasDockerCGroup();
|
|
377
|
+
return isDockerCached;
|
|
378
|
+
}
|
|
379
|
+
async function isWsl() {
|
|
380
|
+
try {
|
|
381
|
+
if (getVendor() === "cloudflare") return false;
|
|
382
|
+
if (typeof process === "undefined" || process?.platform !== "linux") return false;
|
|
383
|
+
const fs = await importRuntime("fs");
|
|
384
|
+
if ((await importRuntime("os")).release().toLowerCase().includes("microsoft")) {
|
|
385
|
+
if (await isInsideContainer()) return false;
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !await isInsideContainer() : false;
|
|
389
|
+
} catch {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
let isInsideContainerCached;
|
|
394
|
+
const hasContainerEnv = async () => {
|
|
395
|
+
if (getVendor() === "cloudflare") return false;
|
|
396
|
+
try {
|
|
397
|
+
(await importRuntime("fs")).statSync("/run/.containerenv");
|
|
398
|
+
return true;
|
|
399
|
+
} catch {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
async function isInsideContainer() {
|
|
404
|
+
if (isInsideContainerCached === void 0) isInsideContainerCached = await hasContainerEnv() || await isDocker();
|
|
405
|
+
return isInsideContainerCached;
|
|
406
|
+
}
|
|
407
|
+
function isCI() {
|
|
408
|
+
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);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/detectors/detect-runtime.ts
|
|
413
|
+
function detectRuntime() {
|
|
414
|
+
if (typeof Deno !== "undefined") return {
|
|
415
|
+
name: "deno",
|
|
416
|
+
version: Deno?.version?.deno ?? null
|
|
417
|
+
};
|
|
418
|
+
if (typeof Bun !== "undefined") return {
|
|
419
|
+
name: "bun",
|
|
420
|
+
version: Bun?.version ?? null
|
|
421
|
+
};
|
|
422
|
+
if (typeof process !== "undefined" && process?.versions?.node) return {
|
|
423
|
+
name: "node",
|
|
424
|
+
version: process.versions.node ?? null
|
|
425
|
+
};
|
|
426
|
+
return {
|
|
427
|
+
name: "edge",
|
|
428
|
+
version: null
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function detectEnvironment() {
|
|
432
|
+
return getEnvVar("NODE_ENV") === "production" ? "production" : isCI() ? "ci" : isTest() ? "test" : "development";
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/utils/hash.ts
|
|
437
|
+
async function hashToBase64(data) {
|
|
438
|
+
const buffer = await createHash("SHA-256").digest(data);
|
|
439
|
+
return base64.encode(buffer);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/utils/id.ts
|
|
444
|
+
const generateId = (size) => {
|
|
445
|
+
return createRandomStringGenerator("a-z", "A-Z", "0-9")(size || 32);
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/project-id.ts
|
|
450
|
+
let projectIdCached = null;
|
|
451
|
+
async function getProjectId(baseUrl) {
|
|
452
|
+
if (projectIdCached) return projectIdCached;
|
|
453
|
+
const projectName = await getNameFromLocalPackageJson();
|
|
454
|
+
if (projectName) {
|
|
455
|
+
projectIdCached = await hashToBase64(baseUrl ? baseUrl + projectName : projectName);
|
|
456
|
+
return projectIdCached;
|
|
457
|
+
}
|
|
458
|
+
if (baseUrl) {
|
|
459
|
+
projectIdCached = await hashToBase64(baseUrl);
|
|
460
|
+
return projectIdCached;
|
|
461
|
+
}
|
|
462
|
+
projectIdCached = generateId(32);
|
|
463
|
+
return projectIdCached;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/index.ts
|
|
468
|
+
const noop = async function noop() {};
|
|
469
|
+
async function createTelemetry(options, context) {
|
|
470
|
+
const debugEnabled = options.telemetry?.debug || getBooleanEnvVar("BETTER_AUTH_TELEMETRY_DEBUG", false);
|
|
471
|
+
const telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT;
|
|
472
|
+
if (!telemetryEndpoint && !context?.customTrack) return { publish: noop };
|
|
473
|
+
const track = async (event) => {
|
|
474
|
+
if (context?.customTrack) await context.customTrack(event).catch(logger.error);
|
|
475
|
+
else if (telemetryEndpoint) if (debugEnabled) logger.info("telemetry event", JSON.stringify(event, null, 2));
|
|
476
|
+
else await betterFetch(telemetryEndpoint, {
|
|
477
|
+
method: "POST",
|
|
478
|
+
body: event
|
|
479
|
+
}).catch(logger.error);
|
|
480
|
+
};
|
|
481
|
+
const isEnabled = async () => {
|
|
482
|
+
const telemetryEnabled = options.telemetry?.enabled !== void 0 ? options.telemetry.enabled : false;
|
|
483
|
+
return (getBooleanEnvVar("BETTER_AUTH_TELEMETRY", false) || telemetryEnabled) && (context?.skipTestCheck || !isTest());
|
|
484
|
+
};
|
|
485
|
+
const enabled = await isEnabled();
|
|
486
|
+
let anonymousId;
|
|
487
|
+
if (enabled) {
|
|
488
|
+
anonymousId = await getProjectId(options.baseURL);
|
|
489
|
+
track({
|
|
490
|
+
type: "init",
|
|
491
|
+
payload: {
|
|
492
|
+
config: getTelemetryAuthConfig(options, context),
|
|
493
|
+
runtime: detectRuntime(),
|
|
494
|
+
database: await detectDatabase(),
|
|
495
|
+
framework: await detectFramework(),
|
|
496
|
+
environment: detectEnvironment(),
|
|
497
|
+
systemInfo: await detectSystemInfo(),
|
|
498
|
+
packageManager: detectPackageManager()
|
|
499
|
+
},
|
|
500
|
+
anonymousId
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
return { publish: async (event) => {
|
|
504
|
+
if (!enabled) return;
|
|
505
|
+
if (!anonymousId) anonymousId = await getProjectId(options.baseURL);
|
|
506
|
+
await track({
|
|
507
|
+
type: event.type,
|
|
508
|
+
payload: event.payload,
|
|
509
|
+
anonymousId
|
|
510
|
+
});
|
|
511
|
+
} };
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
//#endregion
|
|
515
|
+
export { createTelemetry, getTelemetryAuthConfig };
|
|
516
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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\tonEmailVerification: !!options.emailVerification?.onEmailVerification,\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: Object.keys(options.socialProviders || {}).map((p) => {\n\t\t\tconst provider =\n\t\t\t\toptions.socialProviders?.[p as keyof typeof options.socialProviders];\n\t\t\tif (!provider) return {};\n\t\t\treturn {\n\t\t\t\tid: p,\n\t\t\t\tmapProfileToUser: !!provider.mapProfileToUser,\n\t\t\t\tdisableDefaultScope: !!provider.disableDefaultScope,\n\t\t\t\tdisableIdTokenSignIn: !!provider.disableIdTokenSignIn,\n\t\t\t\tdisableImplicitSignUp: provider.disableImplicitSignUp,\n\t\t\t\tdisableSignUp: provider.disableSignUp,\n\t\t\t\tgetUserInfo: !!provider.getUserInfo,\n\t\t\t\toverrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,\n\t\t\t\tprompt: provider.prompt,\n\t\t\t\tverifyIdToken: !!provider.verifyIdToken,\n\t\t\t\tscope: provider.scope,\n\t\t\t\trefreshAccessToken: !!provider.refreshAccessToken,\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\tsendChangeEmailVerification:\n\t\t\t\t\t!!options.user?.changeEmail?.sendChangeEmailVerification,\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\tuseNumberId:\n\t\t\t\t\t!!options.advanced?.database?.useNumberId ||\n\t\t\t\t\toptions.advanced?.database?.generateId === \"serial\",\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\"@remix-run/server-runtime\": \"remix\",\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(options.baseURL);\n\n\t\tconst payload = {\n\t\t\tconfig: 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(options.baseURL);\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,SAAgB,uBACf,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,qBAAqB,CAAC,CAAC,QAAQ,mBAAmB;GAClD,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,QA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IACpC,gBAAgB,sBAAsB;IACtC;GAEmC;GAAa,CAAC;;AAGnD,QAAO,EACN,SAAS,OAAO,UAA0B;AACzC,MAAI,CAAC,QAAS;AACd,MAAI,CAAC,YACJ,eAAc,MAAM,aAAa,QAAQ,QAAQ;AAElD,QAAM,MAAM;GACX,MAAM,MAAM;GACZ,SAAS,MAAM;GACf;GACA,CAAC;IAEH"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hammadj/better-auth-telemetry",
|
|
3
|
+
"version": "1.5.0-beta.9",
|
|
4
|
+
"description": "Telemetry package for Better Auth",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/META-DREAMER/better-auth.git",
|
|
9
|
+
"directory": "packages/telemetry"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.mjs",
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"dev-source": "./src/index.ts",
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"default": "./dist/index.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
"index": [
|
|
24
|
+
"dist/index.d.mts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"tsdown": "^0.20.1",
|
|
30
|
+
"type-fest": "^5.4.2",
|
|
31
|
+
"@hammadj/better-auth-core": "1.5.0-beta.9"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@better-auth/utils": "0.3.1",
|
|
35
|
+
"@better-fetch/fetch": "1.1.21"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@hammadj/better-auth-core": "1.5.0-beta.9"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"dev": "tsdown --watch",
|
|
43
|
+
"lint:package": "publint run --strict",
|
|
44
|
+
"lint:types": "attw --profile esm-only --pack .",
|
|
45
|
+
"typecheck": "tsc --project tsconfig.json"
|
|
46
|
+
}
|
|
47
|
+
}
|