@better-auth/telemetry 1.4.0-beta.13 → 1.4.0-beta.15
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 +10 -10
- package/dist/index.cjs +277 -276
- package/dist/index.d.cts +13 -101
- package/dist/index.d.ts +13 -101
- package/dist/index.js +280 -279
- package/package.json +4 -4
- package/src/detectors/detect-auth-config.ts +3 -2
- package/src/detectors/detect-database.ts +1 -1
- package/src/index.ts +8 -9
- package/src/project-id.ts +1 -1
- package/src/types.ts +5 -5
- package/src/utils/hash.ts +1 -1
- package/src/utils/id.ts +1 -1
- package/src/utils/package-json.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/telemetry@1.4.0-beta.
|
|
2
|
+
> @better-auth/telemetry@1.4.0-beta.15 build /home/runner/work/better-auth/better-auth/packages/telemetry
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.15.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.15.11[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
6
6
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/better-auth/better-auth/packages/telemetry/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m19.
|
|
11
|
-
[34mℹ[39m [33m[CJS][39m 1 files, total: 19.
|
|
12
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.js[22m [2m17.
|
|
13
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m
|
|
14
|
-
[34mℹ[39m [34m[ESM][39m 2 files, total:
|
|
15
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [
|
|
16
|
-
[34mℹ[39m [33m[CJS][39m 1 files, total:
|
|
17
|
-
[32m✔[39m Build complete in [
|
|
10
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m19.88 kB[22m [2m│ gzip: 5.26 kB[22m
|
|
11
|
+
[34mℹ[39m [33m[CJS][39m 1 files, total: 19.88 kB
|
|
12
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.js[22m [2m17.92 kB[22m [2m│ gzip: 4.77 kB[22m
|
|
13
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 7.16 kB[22m [2m│ gzip: 1.82 kB[22m
|
|
14
|
+
[34mℹ[39m [34m[ESM][39m 2 files, total: 25.07 kB
|
|
15
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m7.16 kB[22m [2m│ gzip: 1.82 kB[22m
|
|
16
|
+
[34mℹ[39m [33m[CJS][39m 1 files, total: 7.16 kB
|
|
17
|
+
[32m✔[39m Build complete in [32m3209ms[39m
|
package/dist/index.cjs
CHANGED
|
@@ -23,25 +23,201 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let __better_auth_core_env = require("@better-auth/core/env");
|
|
25
25
|
__better_auth_core_env = __toESM(__better_auth_core_env);
|
|
26
|
-
let __better_auth_utils_random = require("@better-auth/utils/random");
|
|
27
|
-
__better_auth_utils_random = __toESM(__better_auth_utils_random);
|
|
28
|
-
let __better_auth_utils_hash = require("@better-auth/utils/hash");
|
|
29
|
-
__better_auth_utils_hash = __toESM(__better_auth_utils_hash);
|
|
30
|
-
let __better_auth_utils_base64 = require("@better-auth/utils/base64");
|
|
31
|
-
__better_auth_utils_base64 = __toESM(__better_auth_utils_base64);
|
|
32
26
|
let __better_fetch_fetch = require("@better-fetch/fetch");
|
|
33
27
|
__better_fetch_fetch = __toESM(__better_fetch_fetch);
|
|
28
|
+
let __better_auth_utils_base64 = require("@better-auth/utils/base64");
|
|
29
|
+
__better_auth_utils_base64 = __toESM(__better_auth_utils_base64);
|
|
30
|
+
let __better_auth_utils_hash = require("@better-auth/utils/hash");
|
|
31
|
+
__better_auth_utils_hash = __toESM(__better_auth_utils_hash);
|
|
32
|
+
let __better_auth_utils_random = require("@better-auth/utils/random");
|
|
33
|
+
__better_auth_utils_random = __toESM(__better_auth_utils_random);
|
|
34
34
|
|
|
35
|
-
//#region src/
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
//#region src/detectors/detect-auth-config.ts
|
|
36
|
+
function getTelemetryAuthConfig(options, context) {
|
|
37
|
+
return {
|
|
38
|
+
database: context?.database,
|
|
39
|
+
adapter: context?.adapter,
|
|
40
|
+
emailVerification: {
|
|
41
|
+
sendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,
|
|
42
|
+
sendOnSignUp: !!options.emailVerification?.sendOnSignUp,
|
|
43
|
+
sendOnSignIn: !!options.emailVerification?.sendOnSignIn,
|
|
44
|
+
autoSignInAfterVerification: !!options.emailVerification?.autoSignInAfterVerification,
|
|
45
|
+
expiresIn: options.emailVerification?.expiresIn,
|
|
46
|
+
onEmailVerification: !!options.emailVerification?.onEmailVerification,
|
|
47
|
+
afterEmailVerification: !!options.emailVerification?.afterEmailVerification
|
|
48
|
+
},
|
|
49
|
+
emailAndPassword: {
|
|
50
|
+
enabled: !!options.emailAndPassword?.enabled,
|
|
51
|
+
disableSignUp: !!options.emailAndPassword?.disableSignUp,
|
|
52
|
+
requireEmailVerification: !!options.emailAndPassword?.requireEmailVerification,
|
|
53
|
+
maxPasswordLength: options.emailAndPassword?.maxPasswordLength,
|
|
54
|
+
minPasswordLength: options.emailAndPassword?.minPasswordLength,
|
|
55
|
+
sendResetPassword: !!options.emailAndPassword?.sendResetPassword,
|
|
56
|
+
resetPasswordTokenExpiresIn: options.emailAndPassword?.resetPasswordTokenExpiresIn,
|
|
57
|
+
onPasswordReset: !!options.emailAndPassword?.onPasswordReset,
|
|
58
|
+
password: {
|
|
59
|
+
hash: !!options.emailAndPassword?.password?.hash,
|
|
60
|
+
verify: !!options.emailAndPassword?.password?.verify
|
|
61
|
+
},
|
|
62
|
+
autoSignIn: !!options.emailAndPassword?.autoSignIn,
|
|
63
|
+
revokeSessionsOnPasswordReset: !!options.emailAndPassword?.revokeSessionsOnPasswordReset
|
|
64
|
+
},
|
|
65
|
+
socialProviders: Object.keys(options.socialProviders || {}).map((p) => {
|
|
66
|
+
const provider = options.socialProviders?.[p];
|
|
67
|
+
if (!provider) return {};
|
|
68
|
+
return {
|
|
69
|
+
id: p,
|
|
70
|
+
mapProfileToUser: !!provider.mapProfileToUser,
|
|
71
|
+
disableDefaultScope: !!provider.disableDefaultScope,
|
|
72
|
+
disableIdTokenSignIn: !!provider.disableIdTokenSignIn,
|
|
73
|
+
disableImplicitSignUp: provider.disableImplicitSignUp,
|
|
74
|
+
disableSignUp: provider.disableSignUp,
|
|
75
|
+
getUserInfo: !!provider.getUserInfo,
|
|
76
|
+
overrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,
|
|
77
|
+
prompt: provider.prompt,
|
|
78
|
+
verifyIdToken: !!provider.verifyIdToken,
|
|
79
|
+
scope: provider.scope,
|
|
80
|
+
refreshAccessToken: !!provider.refreshAccessToken
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
plugins: options.plugins?.map((p) => p.id.toString()),
|
|
84
|
+
user: {
|
|
85
|
+
modelName: options.user?.modelName,
|
|
86
|
+
fields: options.user?.fields,
|
|
87
|
+
additionalFields: options.user?.additionalFields,
|
|
88
|
+
changeEmail: {
|
|
89
|
+
enabled: options.user?.changeEmail?.enabled,
|
|
90
|
+
sendChangeEmailVerification: !!options.user?.changeEmail?.sendChangeEmailVerification
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
verification: {
|
|
94
|
+
modelName: options.verification?.modelName,
|
|
95
|
+
disableCleanup: options.verification?.disableCleanup,
|
|
96
|
+
fields: options.verification?.fields
|
|
97
|
+
},
|
|
98
|
+
session: {
|
|
99
|
+
modelName: options.session?.modelName,
|
|
100
|
+
additionalFields: options.session?.additionalFields,
|
|
101
|
+
cookieCache: {
|
|
102
|
+
enabled: options.session?.cookieCache?.enabled,
|
|
103
|
+
maxAge: options.session?.cookieCache?.maxAge,
|
|
104
|
+
strategy: options.session?.cookieCache?.strategy
|
|
105
|
+
},
|
|
106
|
+
disableSessionRefresh: options.session?.disableSessionRefresh,
|
|
107
|
+
expiresIn: options.session?.expiresIn,
|
|
108
|
+
fields: options.session?.fields,
|
|
109
|
+
freshAge: options.session?.freshAge,
|
|
110
|
+
preserveSessionInDatabase: options.session?.preserveSessionInDatabase,
|
|
111
|
+
storeSessionInDatabase: options.session?.storeSessionInDatabase,
|
|
112
|
+
updateAge: options.session?.updateAge
|
|
113
|
+
},
|
|
114
|
+
account: {
|
|
115
|
+
modelName: options.account?.modelName,
|
|
116
|
+
fields: options.account?.fields,
|
|
117
|
+
encryptOAuthTokens: options.account?.encryptOAuthTokens,
|
|
118
|
+
updateAccountOnSignIn: options.account?.updateAccountOnSignIn,
|
|
119
|
+
accountLinking: {
|
|
120
|
+
enabled: options.account?.accountLinking?.enabled,
|
|
121
|
+
trustedProviders: options.account?.accountLinking?.trustedProviders,
|
|
122
|
+
updateUserInfoOnLink: options.account?.accountLinking?.updateUserInfoOnLink,
|
|
123
|
+
allowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
hooks: {
|
|
127
|
+
after: !!options.hooks?.after,
|
|
128
|
+
before: !!options.hooks?.before
|
|
129
|
+
},
|
|
130
|
+
secondaryStorage: !!options.secondaryStorage,
|
|
131
|
+
advanced: {
|
|
132
|
+
cookiePrefix: !!options.advanced?.cookiePrefix,
|
|
133
|
+
cookies: !!options.advanced?.cookies,
|
|
134
|
+
crossSubDomainCookies: {
|
|
135
|
+
domain: !!options.advanced?.crossSubDomainCookies?.domain,
|
|
136
|
+
enabled: options.advanced?.crossSubDomainCookies?.enabled,
|
|
137
|
+
additionalCookies: options.advanced?.crossSubDomainCookies?.additionalCookies
|
|
138
|
+
},
|
|
139
|
+
database: {
|
|
140
|
+
useNumberId: !!options.advanced?.database?.useNumberId,
|
|
141
|
+
generateId: options.advanced?.database?.generateId,
|
|
142
|
+
defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit
|
|
143
|
+
},
|
|
144
|
+
useSecureCookies: options.advanced?.useSecureCookies,
|
|
145
|
+
ipAddress: {
|
|
146
|
+
disableIpTracking: options.advanced?.ipAddress?.disableIpTracking,
|
|
147
|
+
ipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders
|
|
148
|
+
},
|
|
149
|
+
disableCSRFCheck: options.advanced?.disableCSRFCheck,
|
|
150
|
+
cookieAttributes: {
|
|
151
|
+
expires: options.advanced?.defaultCookieAttributes?.expires,
|
|
152
|
+
secure: options.advanced?.defaultCookieAttributes?.secure,
|
|
153
|
+
sameSite: options.advanced?.defaultCookieAttributes?.sameSite,
|
|
154
|
+
domain: !!options.advanced?.defaultCookieAttributes?.domain,
|
|
155
|
+
path: options.advanced?.defaultCookieAttributes?.path,
|
|
156
|
+
httpOnly: options.advanced?.defaultCookieAttributes?.httpOnly
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
trustedOrigins: options.trustedOrigins?.length,
|
|
160
|
+
rateLimit: {
|
|
161
|
+
storage: options.rateLimit?.storage,
|
|
162
|
+
modelName: options.rateLimit?.modelName,
|
|
163
|
+
window: options.rateLimit?.window,
|
|
164
|
+
customStorage: !!options.rateLimit?.customStorage,
|
|
165
|
+
enabled: options.rateLimit?.enabled,
|
|
166
|
+
max: options.rateLimit?.max
|
|
167
|
+
},
|
|
168
|
+
onAPIError: {
|
|
169
|
+
errorURL: options.onAPIError?.errorURL,
|
|
170
|
+
onError: !!options.onAPIError?.onError,
|
|
171
|
+
throw: options.onAPIError?.throw
|
|
172
|
+
},
|
|
173
|
+
logger: {
|
|
174
|
+
disabled: options.logger?.disabled,
|
|
175
|
+
level: options.logger?.level,
|
|
176
|
+
log: !!options.logger?.log
|
|
177
|
+
},
|
|
178
|
+
databaseHooks: {
|
|
179
|
+
user: {
|
|
180
|
+
create: {
|
|
181
|
+
after: !!options.databaseHooks?.user?.create?.after,
|
|
182
|
+
before: !!options.databaseHooks?.user?.create?.before
|
|
183
|
+
},
|
|
184
|
+
update: {
|
|
185
|
+
after: !!options.databaseHooks?.user?.update?.after,
|
|
186
|
+
before: !!options.databaseHooks?.user?.update?.before
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
session: {
|
|
190
|
+
create: {
|
|
191
|
+
after: !!options.databaseHooks?.session?.create?.after,
|
|
192
|
+
before: !!options.databaseHooks?.session?.create?.before
|
|
193
|
+
},
|
|
194
|
+
update: {
|
|
195
|
+
after: !!options.databaseHooks?.session?.update?.after,
|
|
196
|
+
before: !!options.databaseHooks?.session?.update?.before
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
account: {
|
|
200
|
+
create: {
|
|
201
|
+
after: !!options.databaseHooks?.account?.create?.after,
|
|
202
|
+
before: !!options.databaseHooks?.account?.create?.before
|
|
203
|
+
},
|
|
204
|
+
update: {
|
|
205
|
+
after: !!options.databaseHooks?.account?.update?.after,
|
|
206
|
+
before: !!options.databaseHooks?.account?.update?.before
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
verification: {
|
|
210
|
+
create: {
|
|
211
|
+
after: !!options.databaseHooks?.verification?.create?.after,
|
|
212
|
+
before: !!options.databaseHooks?.verification?.create?.before
|
|
213
|
+
},
|
|
214
|
+
update: {
|
|
215
|
+
after: !!options.databaseHooks?.verification?.update?.after,
|
|
216
|
+
before: !!options.databaseHooks?.verification?.update?.before
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
45
221
|
}
|
|
46
222
|
|
|
47
223
|
//#endregion
|
|
@@ -86,29 +262,73 @@ async function getNameFromLocalPackageJson() {
|
|
|
86
262
|
}
|
|
87
263
|
|
|
88
264
|
//#endregion
|
|
89
|
-
//#region src/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
265
|
+
//#region src/detectors/detect-database.ts
|
|
266
|
+
const DATABASES = {
|
|
267
|
+
pg: "postgresql",
|
|
268
|
+
mysql: "mysql",
|
|
269
|
+
mariadb: "mariadb",
|
|
270
|
+
sqlite3: "sqlite",
|
|
271
|
+
"better-sqlite3": "sqlite",
|
|
272
|
+
"@prisma/client": "prisma",
|
|
273
|
+
mongoose: "mongodb",
|
|
274
|
+
mongodb: "mongodb",
|
|
275
|
+
"drizzle-orm": "drizzle"
|
|
276
|
+
};
|
|
277
|
+
async function detectDatabase() {
|
|
278
|
+
for (const [pkg, name] of Object.entries(DATABASES)) {
|
|
279
|
+
const version = await getPackageVersion(pkg);
|
|
280
|
+
if (version) return {
|
|
281
|
+
name,
|
|
282
|
+
version
|
|
283
|
+
};
|
|
101
284
|
}
|
|
102
|
-
projectIdCached = generateId(32);
|
|
103
|
-
return projectIdCached;
|
|
104
285
|
}
|
|
105
286
|
|
|
106
287
|
//#endregion
|
|
107
|
-
//#region src/
|
|
108
|
-
const
|
|
109
|
-
|
|
288
|
+
//#region src/detectors/detect-framework.ts
|
|
289
|
+
const FRAMEWORKS = {
|
|
290
|
+
next: "next",
|
|
291
|
+
nuxt: "nuxt",
|
|
292
|
+
"@remix-run/server-runtime": "remix",
|
|
293
|
+
astro: "astro",
|
|
294
|
+
"@sveltejs/kit": "sveltekit",
|
|
295
|
+
"solid-start": "solid-start",
|
|
296
|
+
"tanstack-start": "tanstack-start",
|
|
297
|
+
hono: "hono",
|
|
298
|
+
express: "express",
|
|
299
|
+
elysia: "elysia",
|
|
300
|
+
expo: "expo"
|
|
110
301
|
};
|
|
111
|
-
|
|
302
|
+
async function detectFramework() {
|
|
303
|
+
for (const [pkg, name] of Object.entries(FRAMEWORKS)) {
|
|
304
|
+
const version = await getPackageVersion(pkg);
|
|
305
|
+
if (version) return {
|
|
306
|
+
name,
|
|
307
|
+
version
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/detectors/detect-project-info.ts
|
|
314
|
+
function detectPackageManager() {
|
|
315
|
+
const userAgent = __better_auth_core_env.env.npm_config_user_agent;
|
|
316
|
+
if (!userAgent) return;
|
|
317
|
+
const pmSpec = userAgent.split(" ")[0];
|
|
318
|
+
const separatorPos = pmSpec.lastIndexOf("/");
|
|
319
|
+
const name = pmSpec.substring(0, separatorPos);
|
|
320
|
+
return {
|
|
321
|
+
name: name === "npminstall" ? "cnpm" : name,
|
|
322
|
+
version: pmSpec.substring(separatorPos + 1)
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/utils/import-util.ts
|
|
328
|
+
const importRuntime = (m) => {
|
|
329
|
+
return Function("mm", "return import(mm)")(m);
|
|
330
|
+
};
|
|
331
|
+
|
|
112
332
|
//#endregion
|
|
113
333
|
//#region src/detectors/detect-system-info.ts
|
|
114
334
|
function getVendor() {
|
|
@@ -241,253 +461,34 @@ function detectEnvironment() {
|
|
|
241
461
|
}
|
|
242
462
|
|
|
243
463
|
//#endregion
|
|
244
|
-
//#region src/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
mariadb: "mariadb",
|
|
249
|
-
sqlite3: "sqlite",
|
|
250
|
-
"better-sqlite3": "sqlite",
|
|
251
|
-
"@prisma/client": "prisma",
|
|
252
|
-
mongoose: "mongodb",
|
|
253
|
-
mongodb: "mongodb",
|
|
254
|
-
"drizzle-orm": "drizzle"
|
|
255
|
-
};
|
|
256
|
-
async function detectDatabase() {
|
|
257
|
-
for (const [pkg, name] of Object.entries(DATABASES)) {
|
|
258
|
-
const version = await getPackageVersion(pkg);
|
|
259
|
-
if (version) return {
|
|
260
|
-
name,
|
|
261
|
-
version
|
|
262
|
-
};
|
|
263
|
-
}
|
|
464
|
+
//#region src/utils/hash.ts
|
|
465
|
+
async function hashToBase64(data) {
|
|
466
|
+
const buffer = await (0, __better_auth_utils_hash.createHash)("SHA-256").digest(data);
|
|
467
|
+
return __better_auth_utils_base64.base64.encode(buffer);
|
|
264
468
|
}
|
|
265
469
|
|
|
266
470
|
//#endregion
|
|
267
|
-
//#region src/
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
nuxt: "nuxt",
|
|
271
|
-
"@remix-run/server-runtime": "remix",
|
|
272
|
-
astro: "astro",
|
|
273
|
-
"@sveltejs/kit": "sveltekit",
|
|
274
|
-
"solid-start": "solid-start",
|
|
275
|
-
"tanstack-start": "tanstack-start",
|
|
276
|
-
hono: "hono",
|
|
277
|
-
express: "express",
|
|
278
|
-
elysia: "elysia",
|
|
279
|
-
expo: "expo"
|
|
471
|
+
//#region src/utils/id.ts
|
|
472
|
+
const generateId = (size) => {
|
|
473
|
+
return (0, __better_auth_utils_random.createRandomStringGenerator)("a-z", "A-Z", "0-9")(size || 32);
|
|
280
474
|
};
|
|
281
|
-
async function detectFramework() {
|
|
282
|
-
for (const [pkg, name] of Object.entries(FRAMEWORKS)) {
|
|
283
|
-
const version = await getPackageVersion(pkg);
|
|
284
|
-
if (version) return {
|
|
285
|
-
name,
|
|
286
|
-
version
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
475
|
|
|
291
476
|
//#endregion
|
|
292
|
-
//#region src/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
function getTelemetryAuthConfig(options, context) {
|
|
308
|
-
return {
|
|
309
|
-
database: context?.database,
|
|
310
|
-
adapter: context?.adapter,
|
|
311
|
-
emailVerification: {
|
|
312
|
-
sendVerificationEmail: !!options.emailVerification?.sendVerificationEmail,
|
|
313
|
-
sendOnSignUp: !!options.emailVerification?.sendOnSignUp,
|
|
314
|
-
sendOnSignIn: !!options.emailVerification?.sendOnSignIn,
|
|
315
|
-
autoSignInAfterVerification: !!options.emailVerification?.autoSignInAfterVerification,
|
|
316
|
-
expiresIn: options.emailVerification?.expiresIn,
|
|
317
|
-
onEmailVerification: !!options.emailVerification?.onEmailVerification,
|
|
318
|
-
afterEmailVerification: !!options.emailVerification?.afterEmailVerification
|
|
319
|
-
},
|
|
320
|
-
emailAndPassword: {
|
|
321
|
-
enabled: !!options.emailAndPassword?.enabled,
|
|
322
|
-
disableSignUp: !!options.emailAndPassword?.disableSignUp,
|
|
323
|
-
requireEmailVerification: !!options.emailAndPassword?.requireEmailVerification,
|
|
324
|
-
maxPasswordLength: options.emailAndPassword?.maxPasswordLength,
|
|
325
|
-
minPasswordLength: options.emailAndPassword?.minPasswordLength,
|
|
326
|
-
sendResetPassword: !!options.emailAndPassword?.sendResetPassword,
|
|
327
|
-
resetPasswordTokenExpiresIn: options.emailAndPassword?.resetPasswordTokenExpiresIn,
|
|
328
|
-
onPasswordReset: !!options.emailAndPassword?.onPasswordReset,
|
|
329
|
-
password: {
|
|
330
|
-
hash: !!options.emailAndPassword?.password?.hash,
|
|
331
|
-
verify: !!options.emailAndPassword?.password?.verify
|
|
332
|
-
},
|
|
333
|
-
autoSignIn: !!options.emailAndPassword?.autoSignIn,
|
|
334
|
-
revokeSessionsOnPasswordReset: !!options.emailAndPassword?.revokeSessionsOnPasswordReset
|
|
335
|
-
},
|
|
336
|
-
socialProviders: Object.keys(options.socialProviders || {}).map((p) => {
|
|
337
|
-
const provider = options.socialProviders?.[p];
|
|
338
|
-
if (!provider) return {};
|
|
339
|
-
return {
|
|
340
|
-
id: p,
|
|
341
|
-
mapProfileToUser: !!provider.mapProfileToUser,
|
|
342
|
-
disableDefaultScope: !!provider.disableDefaultScope,
|
|
343
|
-
disableIdTokenSignIn: !!provider.disableIdTokenSignIn,
|
|
344
|
-
disableImplicitSignUp: provider.disableImplicitSignUp,
|
|
345
|
-
disableSignUp: provider.disableSignUp,
|
|
346
|
-
getUserInfo: !!provider.getUserInfo,
|
|
347
|
-
overrideUserInfoOnSignIn: !!provider.overrideUserInfoOnSignIn,
|
|
348
|
-
prompt: provider.prompt,
|
|
349
|
-
verifyIdToken: !!provider.verifyIdToken,
|
|
350
|
-
scope: provider.scope,
|
|
351
|
-
refreshAccessToken: !!provider.refreshAccessToken
|
|
352
|
-
};
|
|
353
|
-
}),
|
|
354
|
-
plugins: options.plugins?.map((p) => p.id.toString()),
|
|
355
|
-
user: {
|
|
356
|
-
modelName: options.user?.modelName,
|
|
357
|
-
fields: options.user?.fields,
|
|
358
|
-
additionalFields: options.user?.additionalFields,
|
|
359
|
-
changeEmail: {
|
|
360
|
-
enabled: options.user?.changeEmail?.enabled,
|
|
361
|
-
sendChangeEmailVerification: !!options.user?.changeEmail?.sendChangeEmailVerification
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
verification: {
|
|
365
|
-
modelName: options.verification?.modelName,
|
|
366
|
-
disableCleanup: options.verification?.disableCleanup,
|
|
367
|
-
fields: options.verification?.fields
|
|
368
|
-
},
|
|
369
|
-
session: {
|
|
370
|
-
modelName: options.session?.modelName,
|
|
371
|
-
additionalFields: options.session?.additionalFields,
|
|
372
|
-
cookieCache: {
|
|
373
|
-
enabled: options.session?.cookieCache?.enabled,
|
|
374
|
-
maxAge: options.session?.cookieCache?.maxAge
|
|
375
|
-
},
|
|
376
|
-
disableSessionRefresh: options.session?.disableSessionRefresh,
|
|
377
|
-
expiresIn: options.session?.expiresIn,
|
|
378
|
-
fields: options.session?.fields,
|
|
379
|
-
freshAge: options.session?.freshAge,
|
|
380
|
-
preserveSessionInDatabase: options.session?.preserveSessionInDatabase,
|
|
381
|
-
storeSessionInDatabase: options.session?.storeSessionInDatabase,
|
|
382
|
-
updateAge: options.session?.updateAge
|
|
383
|
-
},
|
|
384
|
-
account: {
|
|
385
|
-
modelName: options.account?.modelName,
|
|
386
|
-
fields: options.account?.fields,
|
|
387
|
-
encryptOAuthTokens: options.account?.encryptOAuthTokens,
|
|
388
|
-
updateAccountOnSignIn: options.account?.updateAccountOnSignIn,
|
|
389
|
-
accountLinking: {
|
|
390
|
-
enabled: options.account?.accountLinking?.enabled,
|
|
391
|
-
trustedProviders: options.account?.accountLinking?.trustedProviders,
|
|
392
|
-
updateUserInfoOnLink: options.account?.accountLinking?.updateUserInfoOnLink,
|
|
393
|
-
allowUnlinkingAll: options.account?.accountLinking?.allowUnlinkingAll
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
hooks: {
|
|
397
|
-
after: !!options.hooks?.after,
|
|
398
|
-
before: !!options.hooks?.before
|
|
399
|
-
},
|
|
400
|
-
secondaryStorage: !!options.secondaryStorage,
|
|
401
|
-
advanced: {
|
|
402
|
-
cookiePrefix: !!options.advanced?.cookiePrefix,
|
|
403
|
-
cookies: !!options.advanced?.cookies,
|
|
404
|
-
crossSubDomainCookies: {
|
|
405
|
-
domain: !!options.advanced?.crossSubDomainCookies?.domain,
|
|
406
|
-
enabled: options.advanced?.crossSubDomainCookies?.enabled,
|
|
407
|
-
additionalCookies: options.advanced?.crossSubDomainCookies?.additionalCookies
|
|
408
|
-
},
|
|
409
|
-
database: {
|
|
410
|
-
useNumberId: !!options.advanced?.database?.useNumberId,
|
|
411
|
-
generateId: options.advanced?.database?.generateId,
|
|
412
|
-
defaultFindManyLimit: options.advanced?.database?.defaultFindManyLimit
|
|
413
|
-
},
|
|
414
|
-
useSecureCookies: options.advanced?.useSecureCookies,
|
|
415
|
-
ipAddress: {
|
|
416
|
-
disableIpTracking: options.advanced?.ipAddress?.disableIpTracking,
|
|
417
|
-
ipAddressHeaders: options.advanced?.ipAddress?.ipAddressHeaders
|
|
418
|
-
},
|
|
419
|
-
disableCSRFCheck: options.advanced?.disableCSRFCheck,
|
|
420
|
-
cookieAttributes: {
|
|
421
|
-
expires: options.advanced?.defaultCookieAttributes?.expires,
|
|
422
|
-
secure: options.advanced?.defaultCookieAttributes?.secure,
|
|
423
|
-
sameSite: options.advanced?.defaultCookieAttributes?.sameSite,
|
|
424
|
-
domain: !!options.advanced?.defaultCookieAttributes?.domain,
|
|
425
|
-
path: options.advanced?.defaultCookieAttributes?.path,
|
|
426
|
-
httpOnly: options.advanced?.defaultCookieAttributes?.httpOnly
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
trustedOrigins: options.trustedOrigins?.length,
|
|
430
|
-
rateLimit: {
|
|
431
|
-
storage: options.rateLimit?.storage,
|
|
432
|
-
modelName: options.rateLimit?.modelName,
|
|
433
|
-
window: options.rateLimit?.window,
|
|
434
|
-
customStorage: !!options.rateLimit?.customStorage,
|
|
435
|
-
enabled: options.rateLimit?.enabled,
|
|
436
|
-
max: options.rateLimit?.max
|
|
437
|
-
},
|
|
438
|
-
onAPIError: {
|
|
439
|
-
errorURL: options.onAPIError?.errorURL,
|
|
440
|
-
onError: !!options.onAPIError?.onError,
|
|
441
|
-
throw: options.onAPIError?.throw
|
|
442
|
-
},
|
|
443
|
-
logger: {
|
|
444
|
-
disabled: options.logger?.disabled,
|
|
445
|
-
level: options.logger?.level,
|
|
446
|
-
log: !!options.logger?.log
|
|
447
|
-
},
|
|
448
|
-
databaseHooks: {
|
|
449
|
-
user: {
|
|
450
|
-
create: {
|
|
451
|
-
after: !!options.databaseHooks?.user?.create?.after,
|
|
452
|
-
before: !!options.databaseHooks?.user?.create?.before
|
|
453
|
-
},
|
|
454
|
-
update: {
|
|
455
|
-
after: !!options.databaseHooks?.user?.update?.after,
|
|
456
|
-
before: !!options.databaseHooks?.user?.update?.before
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
session: {
|
|
460
|
-
create: {
|
|
461
|
-
after: !!options.databaseHooks?.session?.create?.after,
|
|
462
|
-
before: !!options.databaseHooks?.session?.create?.before
|
|
463
|
-
},
|
|
464
|
-
update: {
|
|
465
|
-
after: !!options.databaseHooks?.session?.update?.after,
|
|
466
|
-
before: !!options.databaseHooks?.session?.update?.before
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
account: {
|
|
470
|
-
create: {
|
|
471
|
-
after: !!options.databaseHooks?.account?.create?.after,
|
|
472
|
-
before: !!options.databaseHooks?.account?.create?.before
|
|
473
|
-
},
|
|
474
|
-
update: {
|
|
475
|
-
after: !!options.databaseHooks?.account?.update?.after,
|
|
476
|
-
before: !!options.databaseHooks?.account?.update?.before
|
|
477
|
-
}
|
|
478
|
-
},
|
|
479
|
-
verification: {
|
|
480
|
-
create: {
|
|
481
|
-
after: !!options.databaseHooks?.verification?.create?.after,
|
|
482
|
-
before: !!options.databaseHooks?.verification?.create?.before
|
|
483
|
-
},
|
|
484
|
-
update: {
|
|
485
|
-
after: !!options.databaseHooks?.verification?.update?.after,
|
|
486
|
-
before: !!options.databaseHooks?.verification?.update?.before
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
};
|
|
477
|
+
//#region src/project-id.ts
|
|
478
|
+
let projectIdCached = null;
|
|
479
|
+
async function getProjectId(baseUrl) {
|
|
480
|
+
if (projectIdCached) return projectIdCached;
|
|
481
|
+
const projectName = await getNameFromLocalPackageJson();
|
|
482
|
+
if (projectName) {
|
|
483
|
+
projectIdCached = await hashToBase64(baseUrl ? baseUrl + projectName : projectName);
|
|
484
|
+
return projectIdCached;
|
|
485
|
+
}
|
|
486
|
+
if (baseUrl) {
|
|
487
|
+
projectIdCached = await hashToBase64(baseUrl);
|
|
488
|
+
return projectIdCached;
|
|
489
|
+
}
|
|
490
|
+
projectIdCached = generateId(32);
|
|
491
|
+
return projectIdCached;
|
|
491
492
|
}
|
|
492
493
|
|
|
493
494
|
//#endregion
|
|
@@ -514,7 +515,7 @@ async function createTelemetry(options, context) {
|
|
|
514
515
|
track({
|
|
515
516
|
type: "init",
|
|
516
517
|
payload: {
|
|
517
|
-
config: getTelemetryAuthConfig(options),
|
|
518
|
+
config: getTelemetryAuthConfig(options, context),
|
|
518
519
|
runtime: detectRuntime(),
|
|
519
520
|
database: await detectDatabase(),
|
|
520
521
|
framework: await detectFramework(),
|