feat: pass Bearer token credentials through to Rust client#11
Merged
w1am merged 4 commits intoMay 5, 2026
Merged
Conversation
Detect `{ bearerToken }` vs `{ username, password }` on the JS credentials
object and construct the matching `Authentication` variant from kurrentdb 1.1.0.
- Bump kurrentdb to 1.1.0 (DEV-1643 added the Authentication enum).
- Bridge `read_stream` and `read_all` now branch on credential shape via a
shared `authentication_from_js` helper and emit `Authentication::Bearer` or
`Authentication::Basic` accordingly.
- Widen `RustReadStreamOptions.credentials` and `RustReadAllOptions.credentials`
to a `Credentials = BasicCredentials | BearerCredentials` discriminated
union, mirroring the Node client's shape from DEV-1642.
- Add bridge-level integration tests covering basic and bearer reads on both
`readStream` and `readAll`.
Closes DEV-1644.
Review Summary by QodoSupport Bearer token credentials in Kurrent bridge
WalkthroughsDescription• Support Bearer token credentials alongside basic auth in bridge • Add authentication_from_js helper to detect credential shape • Widen credentials types to discriminated union (BasicCredentials | BearerCredentials) • Add integration tests for bearer token and basic auth flows Diagramflowchart LR
JS["JS Credentials Object<br/>bearerToken or username/password"]
Helper["authentication_from_js<br/>Helper Function"]
Auth["Authentication Enum<br/>Bearer or Basic"]
RustClient["Rust Client<br/>kurrentdb 1.1.0"]
JS -- "Detect shape" --> Helper
Helper -- "Convert to" --> Auth
Auth -- "Pass through" --> RustClient
File Changes1. crates/bridge/Cargo.toml
|
Code Review by Qodo
1.
|
Validate credentials shape explicitly so JS callers get a targeted error instead of a low-level Neon property/type message:
- bearerToken present but not a string -> 'credentials.bearerToken must be a string'.
- Otherwise require both username and password as strings -> 'credentials must include either { bearerToken } or { username, password }'.
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
kurrentdbto1.1.0(the version DEV-1643 published with the newAuthenticationenum) and reworks the bridge to detect credential shape on the JS side:{ bearerToken }becomesAuthentication::Bearer,{ username, password }becomesAuthentication::Basic.RustReadStreamOptions.credentialsandRustReadAllOptions.credentialsto aCredentials = BasicCredentials | BearerCredentialsdiscriminated union, mirroring the Node client's shape from DEV-1642.readStreamandreadAllcovering basic and bearer credentials. The tests run against the existing insecure docker-compose KurrentDB; success proves the JS->Rust plumbing carries bearer tokens without error (header structure is independently verified by the Rust crate's unit tests in DEV-1643).Closes DEV-1644. Once this is published,
packages/db-client/src/streams/{readStream,readAll}.tsin the Node client can drop their bearer-token guard and resolveauthorizationHeaderProviderinto aCredentialsvalue before calling the bridge, closing DEV-1341.Out of scope of this PR
release-package.ymland publishing the new@kurrent/bridgenpm version — those run as the workflow-driven release step after merge.Test plan
cargo build -p bridgesucceeds againstkurrentdb = 1.1.0.npx tscproduces the updatedlib/index.d.tswith the discriminated union.node --test— all 12 tests pass againstdocker compose up -dKurrentDB, including the 3 new credential cases.