@better-auth/telemetry 1.5.0-beta.9 → 1.5.0
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/README.md +17 -0
- package/dist/index.d.mts +20 -19
- package/dist/index.mjs +24 -21
- package/dist/index.mjs.map +1 -0
- package/package.json +22 -8
- package/.turbo/turbo-build.log +0 -13
- package/src/detectors/detect-auth-config.ts +0 -203
- package/src/detectors/detect-database.ts +0 -22
- package/src/detectors/detect-framework.ts +0 -23
- package/src/detectors/detect-project-info.ts +0 -18
- package/src/detectors/detect-runtime.ts +0 -31
- package/src/detectors/detect-system-info.ts +0 -209
- package/src/index.ts +0 -81
- package/src/project-id.ts +0 -27
- package/src/telemetry.test.ts +0 -321
- package/src/types.ts +0 -16
- package/src/utils/hash.ts +0 -9
- package/src/utils/id.ts +0 -5
- package/src/utils/import-util.ts +0 -3
- package/src/utils/package-json.ts +0 -75
- package/tsconfig.json +0 -8
- package/tsdown.config.ts +0 -7
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Better Auth Telemetry
|
|
2
|
+
|
|
3
|
+
Telemetry package for [Better Auth](https://www.better-auth.com) — anonymous usage analytics to help improve the framework.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @better-auth/telemetry
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
For full documentation, visit [better-auth.com](https://www.better-auth.com).
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _better_auth_core0 from "@better-auth/core";
|
|
2
2
|
import { BetterAuthOptions } from "@better-auth/core";
|
|
3
3
|
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
4
|
+
import * as _better_auth_core_social_providers0 from "@better-auth/core/social-providers";
|
|
4
5
|
|
|
5
6
|
//#region src/types.d.ts
|
|
6
7
|
interface TelemetryEvent {
|
|
@@ -16,7 +17,7 @@ interface TelemetryContext {
|
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
|
18
19
|
//#region src/detectors/detect-auth-config.d.ts
|
|
19
|
-
declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: TelemetryContext | undefined): {
|
|
20
|
+
declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: TelemetryContext | undefined): Promise<{
|
|
20
21
|
database: string | undefined;
|
|
21
22
|
adapter: string | undefined;
|
|
22
23
|
emailVerification: {
|
|
@@ -25,7 +26,7 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
25
26
|
sendOnSignIn: boolean;
|
|
26
27
|
autoSignInAfterVerification: boolean;
|
|
27
28
|
expiresIn: number | undefined;
|
|
28
|
-
|
|
29
|
+
beforeEmailVerification: boolean;
|
|
29
30
|
afterEmailVerification: boolean;
|
|
30
31
|
};
|
|
31
32
|
emailAndPassword: {
|
|
@@ -66,32 +67,32 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
66
67
|
disableSignUp: boolean | undefined;
|
|
67
68
|
getUserInfo: boolean;
|
|
68
69
|
overrideUserInfoOnSignIn: boolean;
|
|
69
|
-
prompt: "
|
|
70
|
+
prompt: "none" | "select_account" | "consent" | "login" | "select_account consent" | undefined;
|
|
70
71
|
verifyIdToken: boolean;
|
|
71
72
|
scope: string[] | undefined;
|
|
72
73
|
refreshAccessToken: boolean;
|
|
73
74
|
})[];
|
|
74
75
|
plugins: string[] | undefined;
|
|
75
76
|
user: {
|
|
76
|
-
modelName:
|
|
77
|
-
fields: Partial<Record<"name" | "
|
|
77
|
+
modelName: "user" | _better_auth_core0.LiteralString | undefined;
|
|
78
|
+
fields: Partial<Record<"name" | "email" | "image" | "createdAt" | "updatedAt" | "emailVerified", string>> | undefined;
|
|
78
79
|
additionalFields: {
|
|
79
|
-
[
|
|
80
|
+
[x: string]: _better_auth_core_db0.DBFieldAttribute;
|
|
80
81
|
} | undefined;
|
|
81
82
|
changeEmail: {
|
|
82
83
|
enabled: boolean | undefined;
|
|
83
|
-
|
|
84
|
+
sendChangeEmailConfirmation: boolean;
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
87
|
verification: {
|
|
87
|
-
modelName:
|
|
88
|
+
modelName: _better_auth_core0.LiteralString | "verification" | undefined;
|
|
88
89
|
disableCleanup: boolean | undefined;
|
|
89
90
|
fields: Partial<Record<"createdAt" | "updatedAt" | "value" | "expiresAt" | "identifier", string>> | undefined;
|
|
90
91
|
};
|
|
91
92
|
session: {
|
|
92
|
-
modelName:
|
|
93
|
+
modelName: _better_auth_core0.LiteralString | "session" | undefined;
|
|
93
94
|
additionalFields: {
|
|
94
|
-
[
|
|
95
|
+
[x: string]: _better_auth_core_db0.DBFieldAttribute;
|
|
95
96
|
} | undefined;
|
|
96
97
|
cookieCache: {
|
|
97
98
|
enabled: boolean | undefined;
|
|
@@ -107,13 +108,13 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
107
108
|
updateAge: number | undefined;
|
|
108
109
|
};
|
|
109
110
|
account: {
|
|
110
|
-
modelName:
|
|
111
|
-
fields: Partial<Record<"createdAt" | "updatedAt" | "userId" | "providerId" | "accountId" | "accessToken" | "refreshToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt" | "
|
|
111
|
+
modelName: _better_auth_core0.LiteralString | "account" | undefined;
|
|
112
|
+
fields: Partial<Record<"scope" | "createdAt" | "updatedAt" | "userId" | "providerId" | "accountId" | "accessToken" | "refreshToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt" | "password", string>> | undefined;
|
|
112
113
|
encryptOAuthTokens: boolean | undefined;
|
|
113
114
|
updateAccountOnSignIn: boolean | undefined;
|
|
114
115
|
accountLinking: {
|
|
115
116
|
enabled: boolean | undefined;
|
|
116
|
-
trustedProviders: _better_auth_core0.LiteralUnion<"github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "
|
|
117
|
+
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;
|
|
117
118
|
updateUserInfoOnLink: boolean | undefined;
|
|
118
119
|
allowUnlinkingAll: boolean | undefined;
|
|
119
120
|
};
|
|
@@ -132,7 +133,6 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
132
133
|
additionalCookies: string[] | undefined;
|
|
133
134
|
};
|
|
134
135
|
database: {
|
|
135
|
-
useNumberId: boolean;
|
|
136
136
|
generateId: false | _better_auth_core0.GenerateIdFn | "serial" | "uuid" | undefined;
|
|
137
137
|
defaultFindManyLimit: number | undefined;
|
|
138
138
|
};
|
|
@@ -145,7 +145,7 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
145
145
|
cookieAttributes: {
|
|
146
146
|
expires: Date | undefined;
|
|
147
147
|
secure: boolean | undefined;
|
|
148
|
-
sameSite: "none" | "
|
|
148
|
+
sameSite: "none" | "strict" | "Strict" | "Lax" | "None" | "lax" | undefined;
|
|
149
149
|
domain: boolean;
|
|
150
150
|
path: string | undefined;
|
|
151
151
|
httpOnly: boolean | undefined;
|
|
@@ -153,8 +153,8 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
153
153
|
};
|
|
154
154
|
trustedOrigins: number | undefined;
|
|
155
155
|
rateLimit: {
|
|
156
|
-
storage: "
|
|
157
|
-
modelName:
|
|
156
|
+
storage: "memory" | "database" | "secondary-storage" | undefined;
|
|
157
|
+
modelName: _better_auth_core0.LiteralString | "rateLimit" | undefined;
|
|
158
158
|
window: number | undefined;
|
|
159
159
|
customStorage: boolean;
|
|
160
160
|
enabled: boolean | undefined;
|
|
@@ -212,11 +212,12 @@ declare function getTelemetryAuthConfig(options: BetterAuthOptions, context?: Te
|
|
|
212
212
|
};
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
|
-
}
|
|
215
|
+
}>;
|
|
216
216
|
//#endregion
|
|
217
217
|
//#region src/index.d.ts
|
|
218
218
|
declare function createTelemetry(options: BetterAuthOptions, context?: TelemetryContext | undefined): Promise<{
|
|
219
219
|
publish: (event: TelemetryEvent) => Promise<void>;
|
|
220
220
|
}>;
|
|
221
221
|
//#endregion
|
|
222
|
-
export { type TelemetryEvent, createTelemetry, getTelemetryAuthConfig };
|
|
222
|
+
export { type TelemetryEvent, createTelemetry, getTelemetryAuthConfig };
|
|
223
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { createHash } from "@better-auth/utils/hash";
|
|
|
5
5
|
import { createRandomStringGenerator } from "@better-auth/utils/random";
|
|
6
6
|
|
|
7
7
|
//#region src/detectors/detect-auth-config.ts
|
|
8
|
-
function getTelemetryAuthConfig(options, context) {
|
|
8
|
+
async function getTelemetryAuthConfig(options, context) {
|
|
9
9
|
return {
|
|
10
10
|
database: context?.database,
|
|
11
11
|
adapter: context?.adapter,
|
|
@@ -15,7 +15,7 @@ function getTelemetryAuthConfig(options, context) {
|
|
|
15
15
|
sendOnSignIn: !!options.emailVerification?.sendOnSignIn,
|
|
16
16
|
autoSignInAfterVerification: !!options.emailVerification?.autoSignInAfterVerification,
|
|
17
17
|
expiresIn: options.emailVerification?.expiresIn,
|
|
18
|
-
|
|
18
|
+
beforeEmailVerification: !!options.emailVerification?.beforeEmailVerification,
|
|
19
19
|
afterEmailVerification: !!options.emailVerification?.afterEmailVerification
|
|
20
20
|
},
|
|
21
21
|
emailAndPassword: {
|
|
@@ -34,11 +34,12 @@ function getTelemetryAuthConfig(options, context) {
|
|
|
34
34
|
autoSignIn: !!options.emailAndPassword?.autoSignIn,
|
|
35
35
|
revokeSessionsOnPasswordReset: !!options.emailAndPassword?.revokeSessionsOnPasswordReset
|
|
36
36
|
},
|
|
37
|
-
socialProviders: Object.keys(options.socialProviders || {}).map((
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
37
|
+
socialProviders: await Promise.all(Object.keys(options.socialProviders || {}).map(async (key) => {
|
|
38
|
+
const p = options.socialProviders?.[key];
|
|
39
|
+
if (!p) return {};
|
|
40
|
+
const provider = typeof p === "function" ? await p() : p;
|
|
40
41
|
return {
|
|
41
|
-
id:
|
|
42
|
+
id: key,
|
|
42
43
|
mapProfileToUser: !!provider.mapProfileToUser,
|
|
43
44
|
disableDefaultScope: !!provider.disableDefaultScope,
|
|
44
45
|
disableIdTokenSignIn: !!provider.disableIdTokenSignIn,
|
|
@@ -51,7 +52,7 @@ function getTelemetryAuthConfig(options, context) {
|
|
|
51
52
|
scope: provider.scope,
|
|
52
53
|
refreshAccessToken: !!provider.refreshAccessToken
|
|
53
54
|
};
|
|
54
|
-
}),
|
|
55
|
+
})),
|
|
55
56
|
plugins: options.plugins?.map((p) => p.id.toString()),
|
|
56
57
|
user: {
|
|
57
58
|
modelName: options.user?.modelName,
|
|
@@ -59,7 +60,7 @@ function getTelemetryAuthConfig(options, context) {
|
|
|
59
60
|
additionalFields: options.user?.additionalFields,
|
|
60
61
|
changeEmail: {
|
|
61
62
|
enabled: options.user?.changeEmail?.enabled,
|
|
62
|
-
|
|
63
|
+
sendChangeEmailConfirmation: !!options.user?.changeEmail?.sendChangeEmailConfirmation
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
verification: {
|
|
@@ -109,7 +110,6 @@ function getTelemetryAuthConfig(options, context) {
|
|
|
109
110
|
additionalCookies: options.advanced?.crossSubDomainCookies?.additionalCookies
|
|
110
111
|
},
|
|
111
112
|
database: {
|
|
112
|
-
useNumberId: !!options.advanced?.database?.useNumberId || options.advanced?.database?.generateId === "serial",
|
|
113
113
|
generateId: options.advanced?.database?.generateId,
|
|
114
114
|
defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit
|
|
115
115
|
},
|
|
@@ -200,8 +200,8 @@ async function readRootPackageJson() {
|
|
|
200
200
|
try {
|
|
201
201
|
const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "";
|
|
202
202
|
if (!cwd) return void 0;
|
|
203
|
-
const importRuntime
|
|
204
|
-
const [{ default: fs }, { default: path }] = await Promise.all([importRuntime
|
|
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
205
|
const raw = await fs.readFile(path.join(cwd, "package.json"), "utf-8");
|
|
206
206
|
packageJSONCache = JSON.parse(raw);
|
|
207
207
|
return packageJSONCache;
|
|
@@ -212,8 +212,8 @@ async function getPackageVersion(pkg) {
|
|
|
212
212
|
try {
|
|
213
213
|
const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "";
|
|
214
214
|
if (!cwd) throw new Error("no-cwd");
|
|
215
|
-
const importRuntime
|
|
216
|
-
const [{ default: fs }, { default: path }] = await Promise.all([importRuntime
|
|
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
217
|
const pkgJsonPath = path.join(cwd, "node_modules", pkg, "package.json");
|
|
218
218
|
const raw = await fs.readFile(pkgJsonPath, "utf-8");
|
|
219
219
|
return JSON.parse(raw).version || await getVersionFromLocalPackageJson(pkg) || void 0;
|
|
@@ -261,7 +261,7 @@ async function detectDatabase() {
|
|
|
261
261
|
const FRAMEWORKS = {
|
|
262
262
|
next: "next",
|
|
263
263
|
nuxt: "nuxt",
|
|
264
|
-
"
|
|
264
|
+
"react-router": "react-router",
|
|
265
265
|
astro: "astro",
|
|
266
266
|
"@sveltejs/kit": "sveltekit",
|
|
267
267
|
"solid-start": "solid-start",
|
|
@@ -465,13 +465,15 @@ async function getProjectId(baseUrl) {
|
|
|
465
465
|
|
|
466
466
|
//#endregion
|
|
467
467
|
//#region src/index.ts
|
|
468
|
+
const noop = async function noop() {};
|
|
468
469
|
async function createTelemetry(options, context) {
|
|
469
470
|
const debugEnabled = options.telemetry?.debug || getBooleanEnvVar("BETTER_AUTH_TELEMETRY_DEBUG", false);
|
|
470
|
-
const
|
|
471
|
+
const telemetryEndpoint = ENV.BETTER_AUTH_TELEMETRY_ENDPOINT;
|
|
472
|
+
if (!telemetryEndpoint && !context?.customTrack) return { publish: noop };
|
|
471
473
|
const track = async (event) => {
|
|
472
474
|
if (context?.customTrack) await context.customTrack(event).catch(logger.error);
|
|
473
|
-
else if (debugEnabled) logger.info("telemetry event", JSON.stringify(event, null, 2));
|
|
474
|
-
else await betterFetch(
|
|
475
|
+
else if (telemetryEndpoint) if (debugEnabled) logger.info("telemetry event", JSON.stringify(event, null, 2));
|
|
476
|
+
else await betterFetch(telemetryEndpoint, {
|
|
475
477
|
method: "POST",
|
|
476
478
|
body: event
|
|
477
479
|
}).catch(logger.error);
|
|
@@ -483,11 +485,11 @@ async function createTelemetry(options, context) {
|
|
|
483
485
|
const enabled = await isEnabled();
|
|
484
486
|
let anonymousId;
|
|
485
487
|
if (enabled) {
|
|
486
|
-
anonymousId = await getProjectId(options.baseURL);
|
|
488
|
+
anonymousId = await getProjectId(typeof options.baseURL === "string" ? options.baseURL : void 0);
|
|
487
489
|
track({
|
|
488
490
|
type: "init",
|
|
489
491
|
payload: {
|
|
490
|
-
config: getTelemetryAuthConfig(options, context),
|
|
492
|
+
config: await getTelemetryAuthConfig(options, context),
|
|
491
493
|
runtime: detectRuntime(),
|
|
492
494
|
database: await detectDatabase(),
|
|
493
495
|
framework: await detectFramework(),
|
|
@@ -500,7 +502,7 @@ async function createTelemetry(options, context) {
|
|
|
500
502
|
}
|
|
501
503
|
return { publish: async (event) => {
|
|
502
504
|
if (!enabled) return;
|
|
503
|
-
if (!anonymousId) anonymousId = await getProjectId(options.baseURL);
|
|
505
|
+
if (!anonymousId) anonymousId = await getProjectId(typeof options.baseURL === "string" ? options.baseURL : void 0);
|
|
504
506
|
await track({
|
|
505
507
|
type: event.type,
|
|
506
508
|
payload: event.payload,
|
|
@@ -510,4 +512,5 @@ async function createTelemetry(options, context) {
|
|
|
510
512
|
}
|
|
511
513
|
|
|
512
514
|
//#endregion
|
|
513
|
-
export { createTelemetry, getTelemetryAuthConfig };
|
|
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 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,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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,gBAAgB;IAChC,WAAW,MAAM,iBAAiB;IAClC,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"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/telemetry",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Telemetry package for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://www.better-auth.com",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
10
|
"url": "git+https://github.com/better-auth/better-auth.git",
|
|
9
11
|
"directory": "packages/telemetry"
|
|
10
12
|
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"auth",
|
|
15
|
+
"telemetry",
|
|
16
|
+
"typescript",
|
|
17
|
+
"better-auth"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
11
25
|
"main": "./dist/index.mjs",
|
|
12
26
|
"module": "./dist/index.mjs",
|
|
13
27
|
"types": "./dist/index.d.mts",
|
|
@@ -25,17 +39,17 @@
|
|
|
25
39
|
]
|
|
26
40
|
}
|
|
27
41
|
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"tsdown": "^0.19.0",
|
|
30
|
-
"type-fest": "^5.4.1",
|
|
31
|
-
"@better-auth/core": "1.5.0-beta.9"
|
|
32
|
-
},
|
|
33
42
|
"dependencies": {
|
|
34
|
-
"@better-auth/utils": "0.3.
|
|
43
|
+
"@better-auth/utils": "0.3.1",
|
|
35
44
|
"@better-fetch/fetch": "1.1.21"
|
|
36
45
|
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"tsdown": "^0.20.3",
|
|
48
|
+
"type-fest": "^5.4.4",
|
|
49
|
+
"@better-auth/core": "1.5.0"
|
|
50
|
+
},
|
|
37
51
|
"peerDependencies": {
|
|
38
|
-
"@better-auth/core": "1.5.0
|
|
52
|
+
"@better-auth/core": "1.5.0"
|
|
39
53
|
},
|
|
40
54
|
"scripts": {
|
|
41
55
|
"build": "tsdown",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @better-auth/telemetry@1.5.0-beta.9 build /home/runner/work/better-auth/better-auth/packages/telemetry
|
|
3
|
-
> tsdown
|
|
4
|
-
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.19.0[22m powered by rolldown [2mv1.0.0-beta.59[22m
|
|
6
|
-
[34mℹ[39m config file: [4m/home/runner/work/better-auth/better-auth/packages/telemetry/tsdown.config.ts[24m
|
|
7
|
-
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
|
-
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m17.97 kB[22m [2m│ gzip: 4.77 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 7.19 kB[22m [2m│ gzip: 1.84 kB[22m
|
|
12
|
-
[34mℹ[39m 2 files, total: 25.16 kB
|
|
13
|
-
[32m✔[39m Build complete in [32m9042ms[39m
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import type { BetterAuthOptions } from "@better-auth/core";
|
|
2
|
-
import type { TelemetryContext } from "../types";
|
|
3
|
-
|
|
4
|
-
export function getTelemetryAuthConfig(
|
|
5
|
-
options: BetterAuthOptions,
|
|
6
|
-
context?: TelemetryContext | undefined,
|
|
7
|
-
) {
|
|
8
|
-
return {
|
|
9
|
-
database: context?.database,
|
|
10
|
-
adapter: context?.adapter,
|
|
11
|
-
emailVerification: {
|
|
12
|
-
sendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,
|
|
13
|
-
sendOnSignUp: !!options.emailVerification?.sendOnSignUp,
|
|
14
|
-
sendOnSignIn: !!options.emailVerification?.sendOnSignIn,
|
|
15
|
-
autoSignInAfterVerification:
|
|
16
|
-
!!options.emailVerification?.autoSignInAfterVerification,
|
|
17
|
-
expiresIn: options.emailVerification?.expiresIn,
|
|
18
|
-
onEmailVerification: !!options.emailVerification?.onEmailVerification,
|
|
19
|
-
afterEmailVerification:
|
|
20
|
-
!!options.emailVerification?.afterEmailVerification,
|
|
21
|
-
},
|
|
22
|
-
emailAndPassword: {
|
|
23
|
-
enabled: !!options.emailAndPassword?.enabled,
|
|
24
|
-
disableSignUp: !!options.emailAndPassword?.disableSignUp,
|
|
25
|
-
requireEmailVerification:
|
|
26
|
-
!!options.emailAndPassword?.requireEmailVerification,
|
|
27
|
-
maxPasswordLength: options.emailAndPassword?.maxPasswordLength,
|
|
28
|
-
minPasswordLength: options.emailAndPassword?.minPasswordLength,
|
|
29
|
-
sendResetPassword: !!options.emailAndPassword?.sendResetPassword,
|
|
30
|
-
resetPasswordTokenExpiresIn:
|
|
31
|
-
options.emailAndPassword?.resetPasswordTokenExpiresIn,
|
|
32
|
-
onPasswordReset: !!options.emailAndPassword?.onPasswordReset,
|
|
33
|
-
password: {
|
|
34
|
-
hash: !!options.emailAndPassword?.password?.hash,
|
|
35
|
-
verify: !!options.emailAndPassword?.password?.verify,
|
|
36
|
-
},
|
|
37
|
-
autoSignIn: !!options.emailAndPassword?.autoSignIn,
|
|
38
|
-
revokeSessionsOnPasswordReset:
|
|
39
|
-
!!options.emailAndPassword?.revokeSessionsOnPasswordReset,
|
|
40
|
-
},
|
|
41
|
-
socialProviders: Object.keys(options.socialProviders || {}).map((p) => {
|
|
42
|
-
const provider =
|
|
43
|
-
options.socialProviders?.[p as keyof typeof options.socialProviders];
|
|
44
|
-
if (!provider) return {};
|
|
45
|
-
return {
|
|
46
|
-
id: p,
|
|
47
|
-
mapProfileToUser: !!provider.mapProfileToUser,
|
|
48
|
-
disableDefaultScope: !!provider.disableDefaultScope,
|
|
49
|
-
disableIdTokenSignIn: !!provider.disableIdTokenSignIn,
|
|
50
|
-
disableImplicitSignUp: provider.disableImplicitSignUp,
|
|
51
|
-
disableSignUp: provider.disableSignUp,
|
|
52
|
-
getUserInfo: !!provider.getUserInfo,
|
|
53
|
-
overrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,
|
|
54
|
-
prompt: provider.prompt,
|
|
55
|
-
verifyIdToken: !!provider.verifyIdToken,
|
|
56
|
-
scope: provider.scope,
|
|
57
|
-
refreshAccessToken: !!provider.refreshAccessToken,
|
|
58
|
-
};
|
|
59
|
-
}),
|
|
60
|
-
plugins: options.plugins?.map((p) => p.id.toString()),
|
|
61
|
-
user: {
|
|
62
|
-
modelName: options.user?.modelName,
|
|
63
|
-
fields: options.user?.fields,
|
|
64
|
-
additionalFields: options.user?.additionalFields,
|
|
65
|
-
changeEmail: {
|
|
66
|
-
enabled: options.user?.changeEmail?.enabled,
|
|
67
|
-
sendChangeEmailVerification:
|
|
68
|
-
!!options.user?.changeEmail?.sendChangeEmailVerification,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
verification: {
|
|
72
|
-
modelName: options.verification?.modelName,
|
|
73
|
-
disableCleanup: options.verification?.disableCleanup,
|
|
74
|
-
fields: options.verification?.fields,
|
|
75
|
-
},
|
|
76
|
-
session: {
|
|
77
|
-
modelName: options.session?.modelName,
|
|
78
|
-
additionalFields: options.session?.additionalFields,
|
|
79
|
-
cookieCache: {
|
|
80
|
-
enabled: options.session?.cookieCache?.enabled,
|
|
81
|
-
maxAge: options.session?.cookieCache?.maxAge,
|
|
82
|
-
strategy: options.session?.cookieCache?.strategy,
|
|
83
|
-
},
|
|
84
|
-
disableSessionRefresh: options.session?.disableSessionRefresh,
|
|
85
|
-
expiresIn: options.session?.expiresIn,
|
|
86
|
-
fields: options.session?.fields,
|
|
87
|
-
freshAge: options.session?.freshAge,
|
|
88
|
-
preserveSessionInDatabase: options.session?.preserveSessionInDatabase,
|
|
89
|
-
storeSessionInDatabase: options.session?.storeSessionInDatabase,
|
|
90
|
-
updateAge: options.session?.updateAge,
|
|
91
|
-
},
|
|
92
|
-
account: {
|
|
93
|
-
modelName: options.account?.modelName,
|
|
94
|
-
fields: options.account?.fields,
|
|
95
|
-
encryptOAuthTokens: options.account?.encryptOAuthTokens,
|
|
96
|
-
updateAccountOnSignIn: options.account?.updateAccountOnSignIn,
|
|
97
|
-
accountLinking: {
|
|
98
|
-
enabled: options.account?.accountLinking?.enabled,
|
|
99
|
-
trustedProviders: options.account?.accountLinking?.trustedProviders,
|
|
100
|
-
updateUserInfoOnLink:
|
|
101
|
-
options.account?.accountLinking?.updateUserInfoOnLink,
|
|
102
|
-
allowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
hooks: {
|
|
106
|
-
after: !!options.hooks?.after,
|
|
107
|
-
before: !!options.hooks?.before,
|
|
108
|
-
},
|
|
109
|
-
secondaryStorage: !!options.secondaryStorage,
|
|
110
|
-
advanced: {
|
|
111
|
-
cookiePrefix: !!options.advanced?.cookiePrefix, //this shouldn't be tracked
|
|
112
|
-
cookies: !!options.advanced?.cookies,
|
|
113
|
-
crossSubDomainCookies: {
|
|
114
|
-
domain: !!options.advanced?.crossSubDomainCookies?.domain,
|
|
115
|
-
enabled: options.advanced?.crossSubDomainCookies?.enabled,
|
|
116
|
-
additionalCookies:
|
|
117
|
-
options.advanced?.crossSubDomainCookies?.additionalCookies,
|
|
118
|
-
},
|
|
119
|
-
database: {
|
|
120
|
-
useNumberId:
|
|
121
|
-
!!options.advanced?.database?.useNumberId ||
|
|
122
|
-
options.advanced?.database?.generateId === "serial",
|
|
123
|
-
generateId: options.advanced?.database?.generateId,
|
|
124
|
-
defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit,
|
|
125
|
-
},
|
|
126
|
-
useSecureCookies: options.advanced?.useSecureCookies,
|
|
127
|
-
ipAddress: {
|
|
128
|
-
disableIpTracking: options.advanced?.ipAddress?.disableIpTracking,
|
|
129
|
-
ipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders,
|
|
130
|
-
},
|
|
131
|
-
disableCSRFCheck: options.advanced?.disableCSRFCheck,
|
|
132
|
-
cookieAttributes: {
|
|
133
|
-
expires: options.advanced?.defaultCookieAttributes?.expires,
|
|
134
|
-
secure: options.advanced?.defaultCookieAttributes?.secure,
|
|
135
|
-
sameSite: options.advanced?.defaultCookieAttributes?.sameSite,
|
|
136
|
-
domain: !!options.advanced?.defaultCookieAttributes?.domain,
|
|
137
|
-
path: options.advanced?.defaultCookieAttributes?.path,
|
|
138
|
-
httpOnly: options.advanced?.defaultCookieAttributes?.httpOnly,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
trustedOrigins: options.trustedOrigins?.length,
|
|
142
|
-
rateLimit: {
|
|
143
|
-
storage: options.rateLimit?.storage,
|
|
144
|
-
modelName: options.rateLimit?.modelName,
|
|
145
|
-
window: options.rateLimit?.window,
|
|
146
|
-
customStorage: !!options.rateLimit?.customStorage,
|
|
147
|
-
enabled: options.rateLimit?.enabled,
|
|
148
|
-
max: options.rateLimit?.max,
|
|
149
|
-
},
|
|
150
|
-
onAPIError: {
|
|
151
|
-
errorURL: options.onAPIError?.errorURL,
|
|
152
|
-
onError: !!options.onAPIError?.onError,
|
|
153
|
-
throw: options.onAPIError?.throw,
|
|
154
|
-
},
|
|
155
|
-
logger: {
|
|
156
|
-
disabled: options.logger?.disabled,
|
|
157
|
-
level: options.logger?.level,
|
|
158
|
-
log: !!options.logger?.log,
|
|
159
|
-
},
|
|
160
|
-
databaseHooks: {
|
|
161
|
-
user: {
|
|
162
|
-
create: {
|
|
163
|
-
after: !!options.databaseHooks?.user?.create?.after,
|
|
164
|
-
before: !!options.databaseHooks?.user?.create?.before,
|
|
165
|
-
},
|
|
166
|
-
update: {
|
|
167
|
-
after: !!options.databaseHooks?.user?.update?.after,
|
|
168
|
-
before: !!options.databaseHooks?.user?.update?.before,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
session: {
|
|
172
|
-
create: {
|
|
173
|
-
after: !!options.databaseHooks?.session?.create?.after,
|
|
174
|
-
before: !!options.databaseHooks?.session?.create?.before,
|
|
175
|
-
},
|
|
176
|
-
update: {
|
|
177
|
-
after: !!options.databaseHooks?.session?.update?.after,
|
|
178
|
-
before: !!options.databaseHooks?.session?.update?.before,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
account: {
|
|
182
|
-
create: {
|
|
183
|
-
after: !!options.databaseHooks?.account?.create?.after,
|
|
184
|
-
before: !!options.databaseHooks?.account?.create?.before,
|
|
185
|
-
},
|
|
186
|
-
update: {
|
|
187
|
-
after: !!options.databaseHooks?.account?.update?.after,
|
|
188
|
-
before: !!options.databaseHooks?.account?.update?.before,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
verification: {
|
|
192
|
-
create: {
|
|
193
|
-
after: !!options.databaseHooks?.verification?.create?.after,
|
|
194
|
-
before: !!options.databaseHooks?.verification?.create?.before,
|
|
195
|
-
},
|
|
196
|
-
update: {
|
|
197
|
-
after: !!options.databaseHooks?.verification?.update?.after,
|
|
198
|
-
before: !!options.databaseHooks?.verification?.update?.before,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|