Skip to content

feat(ts-client): username auth for multi-user servers (0.4.0)#82

Merged
zvndev merged 1 commit into
mainfrom
feat/ts-client-user-auth
Jun 10, 2026
Merged

feat(ts-client): username auth for multi-user servers (0.4.0)#82
zvndev merged 1 commit into
mainfrom
feat/ts-client-user-auth

Conversation

@zvndev

@zvndev zvndev commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Plan 1 / Task 1 (docs/superpowers/plans/2026-06-09-week1-v046-security-release.md): the TS client can now authenticate to v0.4.5+ servers running in multi-user mode — previously the headline auth feature locked out every Node client.

  • Connect frame gains optional trailing username, byte-compatible both ways: null username emits a frame byte-identical to 0.3.x (verified by test against a hand-built legacy frame); old servers ignore nothing because the field is simply absent
  • ClientOptions.user threaded through Client + Pool (Pool inherits structurally — no code change needed)
  • Tarball: source maps dropped (16 files, zero .map), fixing the 0.3.4 changelog claim
  • Version 0.4.0 — minor aligned with the server line; README gains an Authentication section + compat matrix (multi-user needs client ≥0.4.0 AND server ≥0.4.6)

Test plan

  • TDD: 4 new protocol tests (red→green), incl. legacy-frame byte-identity
  • New 10-test live auth suite (pnpm run test:auth): readwrite/admin auth + writes, readonly read OK + insert rejected with permission denied (connection survives, write never landed), no-user/wrong-password/unknown-user → auth_failed, legacy no-auth server accepts username-less frame
  • Full suite green post-rebase onto main: 207/207 across 7 suites
  • npm pack --dry-run: 0.4.0, 16 files, no source maps

npm publish is deliberately deferred until server v0.4.6 is live on crates.io (release PR next).

🤖 Generated with Claude Code

…maps (0.4.0)

Adds the optional Connect-frame username (length-prefixed, appended after
the password — mirrors crates/server/src/protocol.rs) so Node clients can
authenticate to multi-user servers. When `user` is omitted the frame stays
byte-identical to the 0.3.x legacy shape, so old servers are unaffected.

- protocol.ts: Connect variant gains `username: string | null`; encoder
  omits the field entirely when null; decoder parses the optional trailing
  username exactly like the server (absent or empty → null)
- index.ts: `user?: string` on ClientOptions, threaded into the handshake;
  PoolOptions inherits it via the existing ClientOptions spread
- test/protocol.test.ts: 4 new round-trip/byte-compat tests (TDD-first)
- test/auth.test.ts: new live integration suite (pnpm run test:auth) —
  alice(readwrite) writes OK; bob(readonly) reads OK, insert rejected with
  `permission denied` and the connection survives; no-user / wrong-password /
  unknown-user all reject with auth_failed; legacy no-auth server still
  accepts the username-less frame
- tsconfig.json: sourceMap/declarationMap off — tarball no longer ships 12
  dead .map files (verified with npm pack --dry-run)
- version 0.4.0; CHANGELOG + README document the `user` option and the
  compat matrix (multi-user mode requires client >=0.4.0 AND server >=0.4.6),
  replacing the 0.3.x incompatibility caveat

All suites green: 207 tests (193 existing + 14 new).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@zvndev zvndev merged commit 164a513 into main Jun 10, 2026
7 checks passed
@zvndev zvndev deleted the feat/ts-client-user-auth branch June 10, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant