feat(ts-client): username auth for multi-user servers (0.4.0)#82
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Connectframe 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 absentClientOptions.userthreaded through Client + Pool (Pool inherits structurally — no code change needed).map), fixing the 0.3.4 changelog claimTest plan
pnpm run test:auth): readwrite/admin auth + writes, readonly read OK + insert rejected withpermission denied(connection survives, write never landed), no-user/wrong-password/unknown-user →auth_failed, legacy no-auth server accepts username-less framenpm pack --dry-run: 0.4.0, 16 files, no source mapsnpm publish is deliberately deferred until server v0.4.6 is live on crates.io (release PR next).
🤖 Generated with Claude Code