dorfteich/packages/shared/src
Claude Opus 4.8 d4ebcfcfbe
All checks were successful
CD / Build and push images (push) Successful in 2m45s
CI / Lint, typecheck, test (push) Successful in 1m56s
CI / Auth e2e pack (push) Successful in 2m1s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 9s
CD / Smoke tests against Test (push) Successful in 1m9s
CD / Promote to Int (push) Successful in 12s
Add collaboration token issuance and connection authentication (#34)
The api mints a short-lived (60 s) HS256 JWT per page open after an interim
permission check; the collab server authenticates every connection with it
(ADR 0003/0007 — the only JWTs in the system).

- packages/shared: browser-safe token schema/types in `collab-token`, and the
  Node `crypto` sign/verify in `token-crypto` behind its own subpath export
  (`@dorfteich/shared/token-crypto`) so the web bundle never pulls in
  `node:crypto`. Only HS256 is produced/accepted; the signature is checked in
  constant time before any untrusted field is read.
- api: `GET /pages/:id/collab-token` (auth-required) returns
  {token, mode, expiresInSeconds}; `mode` is rw/ro via the interim access
  service; issuance is logged at debug level without the token value.
- collab: `onAuthenticate` verifies the token, checks the pageId matches the
  document name, stores {userId, mode} context, and enforces `ro` via
  Hocuspocus' read-only connection flag. Hocuspocus' own signal handling is
  disabled so index.ts remains the single shutdown owner.
- Shared COLLAB_TOKEN_SECRET env for api + collab (compose, dev overlay,
  .env.example, stage docs); a dev default keeps native dev/test/CI running.

Tests: shared token round-trip/rejection; api endpoint e2e (auth required,
claims, 404 for non-members/unknown ids); collab integration via
HocuspocusProvider (valid token connects; expired/tampered/mismatched-page/
wrong-secret rejected; read-only writes dropped, verified with two clients).

Closes #34

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 15:52:19 +02:00
..
editor-schema Add link UX: edit URL and open in new tab (#29) 2026-07-08 11:50:34 +02:00
api-error.ts Add NestJS API skeleton with config, logging, and /healthz 2026-07-04 19:10:07 +02:00
auth.test.ts Add user, identity, session, and auth-support data model 2026-07-05 00:42:22 +02:00
auth.ts Define the reset-password form schema in shared 2026-07-05 05:47:40 +02:00
collab-token.test.ts Add collaboration token issuance and connection authentication (#34) 2026-07-08 15:52:19 +02:00
collab-token.ts Add collaboration token issuance and connection authentication (#34) 2026-07-08 15:52:19 +02:00
env.test.ts Add Prisma with PostgreSQL, automatic migrations, and /readyz 2026-07-04 19:16:44 +02:00
env.ts Add collaboration token issuance and connection authentication (#34) 2026-07-08 15:52:19 +02:00
files.ts Add file storage service and image upload API (#27) 2026-07-08 10:35:03 +02:00
health.test.ts Scaffold pnpm monorepo with lint, format, and test tooling 2026-07-04 19:06:27 +02:00
health.ts Scaffold pnpm monorepo with lint, format, and test tooling 2026-07-04 19:06:27 +02:00
i18n-tools.test.ts Add i18n with i18next, German and English, and a key-parity check 2026-07-04 19:23:45 +02:00
i18n-tools.ts Add i18n with i18next, German and English, and a key-parity check 2026-07-04 19:23:45 +02:00
index.ts Add collaboration token issuance and connection authentication (#34) 2026-07-08 15:52:19 +02:00
pages.ts Add page CRUD and Yjs state persistence (#23) 2026-07-05 22:25:41 +02:00
ponds.ts Ponds: data model, CRUD API, personal pond on verification (#21) 2026-07-05 11:08:16 +02:00
quotas.ts Quota foundation: overrides, resolution, race-safe consumption (#22) 2026-07-05 20:55:59 +02:00
token-crypto.ts Add collaboration token issuance and connection authentication (#34) 2026-07-08 15:52:19 +02:00