Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Security: better-auth 1.7.7 and happy-dom 21.0.4 (#4010)

Milind Soni095804cb817c
diff --git a/cloudflare/control-plane/README.md b/cloudflare/control-plane/README.md
index dacb9d5706..fa82a58e72 100644
--- a/cloudflare/control-plane/README.md
+++ b/cloudflare/control-plane/README.md
@@ -7,7 +7,7 @@ tool output.
## What is included
-- Better Auth 1.7.1 with email OTP, signed bearer sessions, hashed OTP storage,
+- Better Auth 1.7.7 with email OTP, signed bearer sessions, hashed OTP storage,
and D1-backed IP plus recipient rate limits.
- A Cloudflare Email Sending binding that produces both HTML and plain-text OTP
messages. Authentication responses remain generic even when delivery fails;
@@ -46,7 +46,11 @@ or by a Worker deployed before it, keep their account) and moves capacity
state to one row per account (`managed_endpoint_account_capacity`, seeded from
the `0006` row, which stays but is no longer written). Endpoint rows
deliberately do not cascade away with a hard installation deletion: losing the
-tunnel and DNS IDs would make operator cleanup impossible.
+tunnel and DNS IDs would make operator cleanup impossible. `0011` drops
+`account.issuer` and its unique index: `0001` created them for Better Auth
+1.7.1, and from 1.7.3 Better Auth never writes the column, so it would refuse
+any new account row. Apply `0011` before deploying a Worker on Better Auth
+1.7.7.
## API surface
diff --git a/cloudflare/control-plane/migrations/0011_better_auth_account_issuer.sql b/cloudflare/control-plane/migrations/0011_better_auth_account_issuer.sql
new file mode 100644
index 0000000000..a50b122de1
--- /dev/null
+++ b/cloudflare/control-plane/migrations/0011_better_auth_account_issuer.sql
@@ -0,0 +1,8 @@
+-- Better Auth 1.7.0 through 1.7.2 required account.issuer, with a unique index
+-- on (issuer, accountId). 1.7.3 restored the 1.6 account schema and never
+-- writes issuer, so the NOT NULL column would refuse every new account row.
+-- SQLite has no ALTER COLUMN: drop the index, then the column, as Better
+-- Auth's 1.7 upgrade guide prescribes for SQLite.
+DROP INDEX IF EXISTS "account_issuer_accountId_uidx";
+
+ALTER TABLE "account" DROP COLUMN "issuer";
diff --git a/cloudflare/control-plane/package.json b/cloudflare/control-plane/package.json
index b062f821d1..dd4568b4f0 100644
--- a/cloudflare/control-plane/package.json
+++ b/cloudflare/control-plane/package.json
@@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"dependencies": {
- "better-auth": "1.7.1",
+ "better-auth": "1.7.7",
"zod": "4.6.7"
},
"devDependencies": {
diff --git a/cloudflare/control-plane/src/auth.ts b/cloudflare/control-plane/src/auth.ts
index 0f7fea762c..5a6e0b42ec 100644
--- a/cloudflare/control-plane/src/auth.ts
+++ b/cloudflare/control-plane/src/auth.ts
@@ -39,7 +39,10 @@ export function createAuth(
// supplied x-forwarded-for chain for rate limits or session metadata.
ipAddressHeaders: ["cf-connecting-ip"],
},
- database: { generateId: "uuid" },
+ // Better Auth 1.7.3+ introspects D1 as each auth instance starts (once per
+ // request here) and makes auth requests wait on it: one more D1 round trip
+ // per request for a schema the pinned migrations already fix.
+ database: { generateId: "uuid", validateSchema: false },
backgroundTasks: {
handler(promise) {
ctx.waitUntil(promise);
diff --git a/cloudflare/control-plane/test/control-plane.test.ts b/cloudflare/control-plane/test/control-plane.test.ts
index e25245faf8..bbcc564a1a 100644
--- a/cloudflare/control-plane/test/control-plane.test.ts
+++ b/cloudflare/control-plane/test/control-plane.test.ts
@@ -209,6 +209,18 @@ describe("control-plane migrations and health", () => {
expect(accountIndex?.name).toBe("installation_endpoints_account_status_idx");
});
+ it("lets Better Auth write an account row on the migrated schema", async () => {
+ const { userId } = await signIn("[email protected]");
+ const ctx = createExecutionContext();
+ const context = await createAuth(env, ctx, readConfig(env), crypto.randomUUID()).$context;
+ // Better Auth 1.7.3 and later never write account.issuer, which 0001 created NOT NULL.
+ await context.internalAdapter.createAccount({ userId, providerId: "credential", accountId: userId });
+ await waitOnExecutionContext(ctx);
+ const rows = await env.DB.prepare('SELECT "providerId", "accountId" FROM "account" WHERE "userId" = ?')
+ .bind(userId).all();
+ expect(rows.results).toEqual([{ providerId: "credential", accountId: userId }]);
+ });
+
it("ties every existing endpoint to the original account and carries its capacity state over", async () => {
const db = env.MIGRATION_DB;
const accounts = env.TEST_MIGRATIONS.findIndex((migration) => migration.name.startsWith("0007_"));
diff --git a/package.json b/package.json
index ddf13f160a..9644abf397 100644
--- a/package.json
+++ b/package.json
@@ -160,7 +160,7 @@
"electron-builder": "^26.15.3",
"electron-updater": "^6.8.9",
"esbuild": "^0.28.2",
- "happy-dom": "^20.14.5",
+ "happy-dom": "^21.0.4",
"oxlint": "1.80.0",
"tailwindcss": "^4.1.11",
"typebox": "1.3.7",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7dae8dfe01..e79dc87fd7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -218,8 +218,8 @@ importers:
specifier: ^0.28.2
version: 0.28.2
happy-dom:
- specifier: ^20.14.5
- version: 20.14.5
+ specifier: ^21.0.4
+ version: 21.0.4
oxlint:
specifier: 1.80.0
version: 1.80.0
@@ -237,7 +237,7 @@ importers:
vitest:
specifier: ^4.1.11
wrangler:
specifier: 4.123.0
version: 4.123.0(@cloudflare/[email protected])
@@ -303,15 +303,15 @@ importers:
cloudflare/control-plane:
dependencies:
better-auth:
- specifier: 1.7.1
+ specifier: 1.7.7
zod:
specifier: 4.6.7
version: 4.6.7
devDependencies:
'@cloudflare/vitest-plugin':
specifier: 1.0.0
'@cloudflare/workers-types':
specifier: 5.20260825.1
version: 5.20260825.1
@@ -323,7 +323,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^4.1.11
wrangler:
specifier: 4.125.0
version: 4.125.0(@cloudflare/[email protected])
@@ -457,63 +457,60 @@ packages:
'@types/react':
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-eZ9lqcnVLMZ3QtUByRo4VZqkB1ESyRddd9NfWjBdDPgh+jcwLScoIUAqhtHLR8zaSUJZah8OLGlkzObyPdUH7A==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-srgFzHEjB2WWlokFz1i4BfG41sNhsA105Pukgqu6RrEh5A+LSkzf1mCHydVipkjt9l5qswtBMi7IL6ouHbZL4Q==}
peerDependencies:
'@better-auth/utils': 0.4.2
- '@better-fetch/fetch': 1.3.1
- '@cloudflare/workers-types': '>=4'
+ '@better-fetch/fetch': 1.3.2
'@opentelemetry/api': ^1.9.0
better-call: 1.4.0
jose: ^6.1.0
kysely: ^0.28.5 || ^0.29.0
nanostores: ^1.0.1
peerDependenciesMeta:
- '@cloudflare/workers-types':
- optional: true
'@opentelemetry/api':
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-qlqNyg5V9bXHSP68/vtlsiZayhR4hgvEGiS/E3SIj8bCpWWFGmyQkxJbQCqpBmC7vT30wE/kNtJMHIgnV3rkiw==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-qon0U94PR5FQysuyGoAlGVQpIIiNg5dtDpwjE63sN/HjoRWZadZzHPcS9mn7JsJyQZK6iTNhd7LD0AaXt2f78w==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
drizzle-orm: ^0.45.2 || >=1.0.0-rc.1 <2.0.0
peerDependenciesMeta:
drizzle-orm:
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-yWCpE1cZpMUj37nD6JFDK+GDR8zS37L5WI73il3qbU9TXtWsxUQKc/5c3IHsHizWQsmcQI8uv2pAFKxsRDa+AQ==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-9FONOCgOcrQI9wJ5v1oDGIg9sT7pa9RjZZQ4fsCTudo8R87SrIGNUvUxDFTJhZvUblvFfGaIBR9Vb8LA+8bqLQ==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
kysely: ^0.28.17 || ^0.29.0
peerDependenciesMeta:
kysely:
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-6NX1yv88DeqdoG7owYFqKwlrDGaIPhsC52JUGrUgeGVKyOq8a/6hHlHsqG1C2FwT23SHQiKVYCEAG9N6aH5OvQ==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-FqKFEe+b5tXXV0gRbyirca+qXgMpLOeJ8Wk19yykb/scQKy0WJ4k22WzEV3TTPctQV9DZhwCXPlDtQhnlOv5Gg==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-9ILTcNqhG37QK//qR4UhYLyKzNqq6w6zVTf5KX6xkiTjNcV7Oh1yS31lkIJEVTqRNcy9AoV6FZMW6Bbsm8IMDA==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-ZnVDuRrXqbf0oHphrEN27oTImNH5NTO26dtWatq5cXyYAsH7goof9QIoTOmxTbBxUQahKBw9T6+9h6n+RtOE+g==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
mongodb: ^6.0.0 || ^7.0.0
peerDependenciesMeta:
mongodb:
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-ZiUcafQ85InAofcUjyGgCPjKLfQjXr9SvDmMjuFUW8oEbreA6C6GaFAEA77VuV2doZUQlzvQQ4gCoTmS28W92A==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-4YcnrcVdvWiAZw0sZl63tWUClPXg5r3QsLn7C2sG7kKEBY06zOng0ibecyxRBixKq1zE1ceHuEUqez5Rhi+nQA==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
'@prisma/client': ^5.0.0 || ^6.0.0 || ^7.0.0
prisma: ^5.0.0 || ^6.0.0 || ^7.0.0
@@ -523,12 +520,12 @@ packages:
prisma:
optional: true
- '@better-auth/[email protected]':
- resolution: {integrity: sha512-kLKjMfFlTbyt49DGeI9okHAsn0MtBZcMoQYKaEdgR0H3BHzqqyzePcQz/hxAmRgjB4p/6inise3zJwhX0sgXrQ==}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-PaRA6i+kAioVYmza2gHPcdrxP0hAotph4KV9hft2GeNJq+AZXDiBu3FuLM9HxvcmiZeUT74Vufqd9ypmB8veTA==}
peerDependencies:
- '@better-auth/core': ^1.7.1
+ '@better-auth/core': ^1.7.7
'@better-auth/utils': 0.4.2
- '@better-fetch/fetch': 1.3.1
+ '@better-fetch/fetch': 1.3.2
'@better-auth/[email protected]':
resolution: {integrity: sha512-AUxrvu+HaaODsUyzDxFgwd/8RZ1yZaYo42LXKSrU2oGgR38pS1ij8nqQKNgtTWoYGpNevNXtCfgTy6loHveW9A==}
@@ -536,8 +533,8 @@ packages:
'@better-auth/[email protected]':
resolution: {integrity: sha512-BL8W4EfIZFwlu0r54m3v1ztjDhu6dDe/amLTm0xybmbZaNgYUqhD3SjpAsnq0q8YD6/ki4iwIgxJNLP/N3TxiA==}
- '@better-fetch/[email protected]':
- resolution: {integrity: sha512-ABkD1WhyfPZprKRQI3bhATjeiFuNWC9PXhfGWqL+sg/gKrM977oFrYkdb4msM3hgUGonr7KlOsOFT5TU2rht9g==}
+ '@better-fetch/[email protected]':
+ resolution: {integrity: sha512-Gs7n99b5tqUC6cQAPbV0uED3IraHB6xQbHLQ/C3l7ZFafHScOx9pQ+DYmP5blbLFShVWLqxNUlI9wi4xU/X+ow==}
'@braintree/[email protected]':
resolution: {integrity: sha512-jigsZK+sMF/cuiB7sERuo9V7N9jx+dhmHHnQyDSVdpZwVutaBu7WvNYqMDLSgFgfB30n452TP3vjDAvFC973mA==}
@@ -2715,15 +2712,14 @@ packages:
engines: {node: '>=6.0.0'}
hasBin: true
- resolution: {integrity: sha512-g8WlTQijxXWJjPVZfFu1+EJg9cwwHrKDmIkcYMzx8CzYA+tDxl6NI7qQbKkbgw5UtHILsT5VH+RMzFzwnVJqAg==}
+ resolution: {integrity: sha512-Zhgxi/c5ylmfB/sX+nwnBbsFf/j6k0L8DvL6CJXZSrXgxc5pPMC/e7j812zNd4L4B4ELmdURCPw3X8nAOUdcjw==}
peerDependencies:
'@lynx-js/react': '*'
'@prisma/client': ^5.0.0 || ^6.0.0 || ^7.0.0
'@sveltejs/kit': ^2.0.0
'@tanstack/react-start': ^1.0.0
'@tanstack/solid-start': ^1.0.0
- better-sqlite3: ^12.0.0
drizzle-kit: '>=0.31.4 || >=1.0.0-beta.1'
drizzle-orm: ^0.45.2 || >=1.0.0-rc.1 <2.0.0
mongodb: ^6.0.0 || ^7.0.0
@@ -2735,7 +2731,7 @@ packages:
react-dom: ^18.0.0 || ^19.0.0
solid-js: ^1.0.0
svelte: ^4.0.0 || ^5.0.0
- vitest: ^2.0.0 || ^3.0.0 || ^4.0.0
+ vitest: ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0
vue: ^3.0.0
peerDependenciesMeta:
'@lynx-js/react':
@@ -2748,8 +2744,6 @@ packages:
optional: true
'@tanstack/solid-start':
optional: true
- better-sqlite3:
- optional: true
drizzle-kit:
optional: true
drizzle-orm:
@@ -3650,8 +3644,8 @@ packages:
resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==}
- resolution: {integrity: sha512-x/RzkpWO40bTjIoT30iQtt64FLLmH/iRcUCN2X//bLx7H3ifkdfPXyqsro/OYtqzIAhiLMMA7mmiOR9C3NOKjQ==}
+ resolution: {integrity: sha512-tFm+GaLBgo6o0awHnvHaNoraVo27qJ+2tZEtZ+cIa08hXbeitrxAJajLI05hsUy/2/YTKcUjQYzHe5mCcraLBw==}
engines: {node: '>=20.0.0'}
@@ -5614,10 +5608,10 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.18
dependencies:
'@better-auth/utils': 0.4.2
- '@better-fetch/fetch': 1.3.1
+ '@better-fetch/fetch': 1.3.2
'@opentelemetry/semantic-conventions': 1.43.0
'@standard-schema/spec': 1.1.0
better-call: 1.4.0([email protected])
@@ -5625,41 +5619,39 @@ snapshots:
kysely: 0.29.5
nanostores: 1.5.2
zod: 4.6.7
- optionalDependencies:
- '@cloudflare/workers-types': 5.20260825.1
dependencies:
'@better-auth/utils': 0.4.2
dependencies:
'@better-auth/utils': 0.4.2
optionalDependencies:
kysely: 0.29.5
dependencies:
'@better-auth/utils': 0.4.2
dependencies:
'@better-auth/utils': 0.4.2
dependencies:
'@better-auth/utils': 0.4.2
dependencies:
'@better-auth/utils': 0.4.2
- '@better-fetch/fetch': 1.3.1
+ '@better-fetch/fetch': 1.3.2
'@better-auth/[email protected]':
dependencies:
@@ -5669,7 +5661,7 @@ snapshots:
dependencies:
'@noble/hashes': 2.3.0
- '@better-fetch/[email protected]': {}
+ '@better-fetch/[email protected]': {}
'@braintree/[email protected]': {}
@@ -5714,14 +5706,14 @@ snapshots:
optionalDependencies:
workerd: 1.20260820.1
dependencies:
'@vitest/runner': 4.1.11
'@vitest/snapshot': 4.1.11
cjs-module-lexer: 1.2.3
esbuild: 0.28.1
miniflare: 5.20260820.0-alpha
wrangler: 4.125.0(@cloudflare/[email protected])
zod: 4.4.3
transitivePeerDependencies:
@@ -7463,17 +7455,17 @@ snapshots:
dependencies:
- '@better-auth/drizzle-adapter': 1.7.1(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
- '@better-auth/memory-adapter': 1.7.1(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
- '@better-auth/mongo-adapter': 1.7.1(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
- '@better-auth/prisma-adapter': 1.7.1(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
- '@better-auth/telemetry': 1.7.1(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])
+ '@better-auth/drizzle-adapter': 1.7.7(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
+ '@better-auth/memory-adapter': 1.7.7(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
+ '@better-auth/mongo-adapter': 1.7.7(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
+ '@better-auth/prisma-adapter': 1.7.7(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
+ '@better-auth/telemetry': 1.7.7(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])
'@better-auth/utils': 0.4.2
- '@better-fetch/fetch': 1.3.1
+ '@better-fetch/fetch': 1.3.2
'@noble/ciphers': 2.3.0
'@noble/hashes': 2.3.0
better-call: 1.4.0([email protected])
@@ -7486,15 +7478,14 @@ snapshots:
react: 19.2.8
react-dom: 19.2.8([email protected])
transitivePeerDependencies:
- - '@cloudflare/workers-types'
- '@opentelemetry/api'
dependencies:
'@better-auth/utils': 0.5.0
- '@better-fetch/fetch': 1.3.1
+ '@better-fetch/fetch': 1.3.2
rou3: 0.9.2
set-cookie-parser: 3.1.2
optionalDependencies:
@@ -8482,7 +8473,7 @@ snapshots:
dependencies:
'@types/node': 26.2.0
'@types/whatwg-mimetype': 3.0.2
@@ -10703,7 +10694,7 @@ snapshots:
terser: 5.16.9
yaml: 2.9.0
dependencies:
'@vitest/expect': 4.1.11
@@ -10727,7 +10718,7 @@ snapshots:
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 26.2.0
- happy-dom: 20.14.5
+ happy-dom: 21.0.4
transitivePeerDependencies:
- msw