Files
Komediruzecki 957e63df72 feat(worker): implement JWT + Google Sign-In auth on the Worker/D1 scaffold
Replaces the auth placeholder with a real, zero-dependency implementation adapted
from mercurypitch's WebCrypto auth module, tuned for a finance app:

- JWT (HS256) session in an httpOnly/Secure/SameSite=Lax cookie (not localStorage).
- Google Sign-In via the server-side code flow with a signed-state CSRF guard and a
  returnTo allowlist; verifies the id_token audience; find-or-create user in D1.
- requireAuth Hono middleware; logout bumps users.token_version to revoke tokens.
- PBKDF2 password helpers (existing bcrypt hashes need a re-hash-on-login migration).
- migrations/0001: users table adapted for OAuth (nullable username/password,
  provider_id, email_verified, token_version + a unique provider index).
- wrangler.toml / .dev.vars.example: GOOGLE_CLIENT_ID var + JWT_SECRET /
  GOOGLE_CLIENT_SECRET secrets; COOKIE_DOMAIN / APP_ORIGINS placeholders.

auth.ts depends only on WebCrypto + a D1 handle, so it can move to a shared
cross-app lib later. Verified: tsc --noEmit clean; migration applies (25 tables).
Setup docs (Cloudflare D1 + Google OAuth) saved under ~/.dotfiles/personal/finance/.
2026-06-27 19:33:06 +02:00

16 lines
339 B
JSON

{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "Bundler",
"lib": ["ES2022"],
"types": ["@cloudflare/workers-types"],
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"include": ["src/**/*.ts"]
}