RC1 Preparation - #57
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds transport helper modules (messageTransport, jsonRpcTransport, fabricWebRtcInterop), wires them into server WebSocket and HTTP JSON‑RPC flows, exposes protocol helpers under ChangesProtocol Helpers & Server Integration Protocol integration cohort
Sequence DiagramsequenceDiagram
participant Client as Client
participant WS as WebSocket
participant MsgTx as MessageTransport
participant JRpcTx as JsonRpcTransport
participant Server as Server
Client->>WS: Send JSON-RPC request (text frame)
WS->>MsgTx: extractTransportControlType()/normalizeTransportType()
MsgTx->>Server: Dispatch canonical JSONCall type
Server->>JRpcTx: parseWebSocketJsonCallBody()/computeWebSocketJsonCallHashPair()
alt Authorized
Server->>Server: Execute handler
Server->>JRpcTx: buildWebSocketJsonCallResultBody()
else Unauthorized
Server->>JRpcTx: buildWebSocketJsonCallErrorBody()
end
JRpcTx->>WS: Return response payload (method, params[hash, result/null])
WS->>Client: Send JSON-RPC response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 104 |
| Duplication | 14 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Stale comment
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Notes:
- No prior automation review threads were present to revalidate.
- Reviewed the new transport helper exports, WebSocket JSONCall refactor, WebRTC registry auth flow, and package export changes.
- No inline findings were left.
Sent by Cursor Automation: Find vulnerabilities
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
types/server.js (1)
2548-2548:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd CHANGELOG and README entries documenting the breaking API change.
The exports of
resolveFabricHttpPackageAssetsDirandacceptFirstHtmlNavigationhave been removed fromtypes/server.js. While the codebase contains no remaining imports of these functions, downstream consumers relying on these exports will break. This breaking change must be documented in CHANGELOG and README (migration guide or deprecation notes) so users are aware and can update their code.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@types/server.js` at line 2548, Update project documentation to record the breaking API change: add a clear CHANGELOG entry and a README (or migration guide/deprecation) note that the named exports resolveFabricHttpPackageAssetsDir and acceptFirstHtmlNavigation were removed from the server module (previously exported from types/server.js). In the CHANGELOG entry, include the version, "breaking change" label, and a short migration snippet advising users to remove imports or replace them with the new recommended approach (or point to alternative APIs). In the README/migration guide, add a brief example showing how to refactor code that imported resolveFabricHttpPackageAssetsDir and acceptFirstHtmlNavigation and link to any upstream replacement or guidance for maintaining equivalent behavior.
🧹 Nitpick comments (2)
types/server.js (2)
1162-1167: 💤 Low valueMinor: redundant authorization recompute and shadowed identifier.
server._isJsonRpcTransportAuthorized(request)is recomputed here even thoughsocket._fabricTransportAuthorizedwas set from the same call at line 996/997 during connection setup, and the new localtransportAuthorizedshadows the outer-scopetransportAuthorizedfrom line 996. The same pattern repeats at lines 1272 and 1300.If the policy decision is intended to be re-evaluated per-message (e.g., to pick up token rotation on
request.headers), the duplication is fine but worth a comment. Otherwise, prefer reusingsocket._fabricTransportAuthorizedto avoid divergent results and the shadow.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@types/server.js` around lines 1162 - 1167, The code recomputes transport authorization into a new local transportAuthorized variable using server._isJsonRpcTransportAuthorized(request) which shadows the outer transportAuthorized set earlier and risks divergence; change the logic in the block that checks server._isWebRtcRegistryMethod(jsonCallPayload.method) && wrtcCfg.requireTransportAuth === true to reuse socket._fabricTransportAuthorized instead of calling server._isJsonRpcTransportAuthorized again (or, if you intentionally want per-message re-evaluation for token rotation, add an explicit comment explaining that server._isJsonRpcTransportAuthorized(request) must be re-run). Update the occurrences at the shown snippet and the similar spots noted (around the uses at lines corresponding to 1272 and 1300) to be consistent.
1095-1108: 💤 Low valueUse
messageTransport.HEARTBEAT_TYPEinstead of hardcoded'HEARTBEAT'at line 1097.Lines 1090 and 1097 both duplicate the extraction
parsed.type || parsed['@type']. While consolidating this extraction would improve DRY, note thatctrl(from line 1080) is out of scope here. A simpler win is replacing the hardcoded literal with the exported constant, keeping the code consistent with the abstraction layer.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@types/server.js` around lines 1095 - 1108, Replace the hardcoded literal 'HEARTBEAT' with the exported constant messageTransport.HEARTBEAT_TYPE in the branch that builds a HEARTBEAT Message (the conditional comparing rawType at the parsed object and the Message.fromVector call); keep the rest of the logic the same (use parsed.type || parsed['@type'] to compute rawType and use parsed.body ?? parsed.data ?? parsed.content ?? parsed['@data'] ?? '' for payload), ensuring you reference messageTransport.HEARTBEAT_TYPE instead of the string so the check and the Message.fromVector payload use the constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@functions/fabricJsonRpcTransport.js`:
- Around line 60-62: The parseWebSocketJsonCallBody function currently blindly
returns JSON.parse(body); update it to parse the body then validate the result
is a non-null object and not an array (e.g., result !== null && typeof result
=== 'object' && !Array.isArray(result')); if the check fails, throw a TypeError
with a clear message indicating an unexpected JSON payload type so downstream
consumers expecting an object-like call body (parseWebSocketJsonCallBody) cannot
receive primitives or arrays.
In `@README.md`:
- Around line 123-124: Add a blank line between the heading "## Resources" and
the table row starting with "| Doc | Purpose |" so the table is separated from
the heading (satisfies markdownlint MD058); update the README.md by inserting an
empty line immediately after the "## Resources" heading.
In `@tests/web.httpHelpers.test.js`:
- Around line 58-67: The test currently compares identical literal arrays
(self-referential) so it never fails; update the test to import the module under
test (the httpHelpers/web module) and assert that its exported registry method
names match the expected array
['RegisterWebRTCPeer','UnregisterWebRTCPeer','ListWebRTCPeers'] — e.g., require
the module, derive the actual names (from exported object keys or the specific
export like registryMethods/allowedMethods), then replace the right-hand literal
with that actual value in the assert.deepStrictEqual call so the assertion
verifies runtime exports instead of two identical literals.
In `@types/server.js`:
- Around line 1257-1262: The GENERIC_MESSAGE branch builds a signed receipt in
the local variable (via Message.fromVector and later signing) but never sends
it; either send that receipt on the current socket or remove the dead
construction. Update the case handling for messageTransport.GENERIC_MESSAGE_TYPE
so that after building/signing local (the GENERIC_MESSAGE_RECEIPT_TYPE message)
you call socket.send(local.toBuffer()) to transmit the receipt (mirroring how
P2P_MESSAGE_RECEIPT is delivered), or if the receipt is no longer required,
delete the local assignment and related signing code to avoid dead code.
- Around line 1147-1149: The code currently calls
jsonRpcTransport.parseWebSocketJsonCallBody(message.body) and
jsonRpcTransport.computeWebSocketJsonCallHashPair(message.body) before checking
socket._fabricJsonRpcTransportAuthorized; move the unauthenticated auth gate to
run immediately after extracting message.body and before invoking
parseWebSocketJsonCallBody or computeWebSocketJsonCallHashPair so
unauthenticated sockets are rejected quickly and never trigger JSON.parse or
SHA256 work; update the control flow around parseWebSocketJsonCallBody and
computeWebSocketJsonCallHashPair to only run for authorized sockets and ensure
unauthenticated branches use the existing error envelope handling (the same
rejection path used for other malformed/unauthorized messages).
---
Outside diff comments:
In `@types/server.js`:
- Line 2548: Update project documentation to record the breaking API change: add
a clear CHANGELOG entry and a README (or migration guide/deprecation) note that
the named exports resolveFabricHttpPackageAssetsDir and
acceptFirstHtmlNavigation were removed from the server module (previously
exported from types/server.js). In the CHANGELOG entry, include the version,
"breaking change" label, and a short migration snippet advising users to remove
imports or replace them with the new recommended approach (or point to
alternative APIs). In the README/migration guide, add a brief example showing
how to refactor code that imported resolveFabricHttpPackageAssetsDir and
acceptFirstHtmlNavigation and link to any upstream replacement or guidance for
maintaining equivalent behavior.
---
Nitpick comments:
In `@types/server.js`:
- Around line 1162-1167: The code recomputes transport authorization into a new
local transportAuthorized variable using
server._isJsonRpcTransportAuthorized(request) which shadows the outer
transportAuthorized set earlier and risks divergence; change the logic in the
block that checks server._isWebRtcRegistryMethod(jsonCallPayload.method) &&
wrtcCfg.requireTransportAuth === true to reuse socket._fabricTransportAuthorized
instead of calling server._isJsonRpcTransportAuthorized again (or, if you
intentionally want per-message re-evaluation for token rotation, add an explicit
comment explaining that server._isJsonRpcTransportAuthorized(request) must be
re-run). Update the occurrences at the shown snippet and the similar spots noted
(around the uses at lines corresponding to 1272 and 1300) to be consistent.
- Around line 1095-1108: Replace the hardcoded literal 'HEARTBEAT' with the
exported constant messageTransport.HEARTBEAT_TYPE in the branch that builds a
HEARTBEAT Message (the conditional comparing rawType at the parsed object and
the Message.fromVector call); keep the rest of the logic the same (use
parsed.type || parsed['@type'] to compute rawType and use parsed.body ??
parsed.data ?? parsed.content ?? parsed['@data'] ?? '' for payload), ensuring
you reference messageTransport.HEARTBEAT_TYPE instead of the string so the check
and the Message.fromVector payload use the constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a8c12cad-d5e7-4784-9cb4-9b7551356ad9
📒 Files selected for processing (11)
README.mdbuilds/esm/fabric.http.jsdocs/MESSAGE_SPEC.mdfunctions/fabricJsonRpcTransport.jsfunctions/fabricMessageTransport.jsfunctions/fabricWebRtcInterop.jspackage.jsontests/sendPayment402.unit.jstests/web.httpHelpers.test.jstypes/server.jstypes/web.js
💤 Files with no reviewable changes (1)
- builds/esm/fabric.http.js
There was a problem hiding this comment.
Stale comment
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Validated areas:
- Prior Cursor automation assessment had no findings; no prior Cursor security-review threads needed re-reporting.
- WebSocket
JSONCalland HTTP JSON-RPC auth paths still gate WebRTC registry methods via_fabricTransportAuthorizedwhenwebrtc.requireTransportAuthis enabled.- New WebRTC registry inputs are bounded/validated, unregister uses the returned secret, and package changes add helper exports without new dependencies.
- No inline finding comments were left.
Sent by Cursor Automation: Find vulnerabilities
There was a problem hiding this comment.
Stale comment
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Validated areas:
- Rechecked previous automation context; prior Cursor security reviews had no inline findings to re-report, and cleanup was requested for stale automation output.
- Validated the unresolved auth-before-parse DoS concern against current and base flow; the unauthenticated JSONCall parse/hash work was already present in the reviewed path and does not rise to a new PR-introduced medium+ finding.
- Reviewed WebSocket JSONCall alias normalization, HTTP JSON-RPC envelope refactor, WebRTC registry auth/limits/secret handling, public protocol exports, and package-lock changes.
No inline security findings were left. Note: targeted tests could not be run because
npmis not available in this environment.Sent by Cursor Automation: Find vulnerabilities
There was a problem hiding this comment.
Stale comment
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Validated areas:
- Rechecked prior automation context and the currently unresolved auth-before-parse DoS concern; the parse/hash work is not newly introduced by this PR and does not meet the medium+ reporting bar here.
- Traced the changed WebSocket JSONCall flow, HTTP JSON-RPC envelopes, WebRTC registry auth/limits/secret handling, protocol helper exports, and package/dependency changes.
npm audit --omit=devreported 0 vulnerabilities, and standalone protocol helper smoke checks passed.No inline security findings were left. Targeted Mocha tests could not run because this checkout is missing
@fabric/core/constants.Sent by Cursor Automation: Find vulnerabilities
There was a problem hiding this comment.
Stale comment
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Validated areas:
- Rechecked prior automation context and the currently unresolved auth-before-parse DoS concern; current code parses JSONCall bodies after the auth gate, and the remaining pre-auth hash is bounded correlation work for the denial response rather than a reportable medium+ issue.
- Traced the changed WebSocket JSONCall and HTTP JSON-RPC paths through
_handleCall, including WebRTC registry auth, peer metadata bounds, and secret-based update/unregister handling.- Reviewed the new protocol helper exports and dependency changes;
npm audit --omit=devreported 0 vulnerabilities, and standalone helper smoke checks passed.No inline security findings were left. Targeted Mocha tests could not run because this checkout is missing
@fabric/core/constants.Sent by Cursor Automation: Find vulnerabilities
There was a problem hiding this comment.
Security review complete. I found no high-confidence medium, high, or critical vulnerabilities introduced by this PR.
Validated areas:
- Rechecked prior review threads; existing threads are resolved, and no prior Cursor security finding remains to re-report.
- Traced the changed WebSocket
JSONCallhelpers, JSON-RPC envelope refactor, WebRTC registry auth/limits/secret handling, protocol helper exports, and lockfile/dependency updates. npm audit --omit=devreported 0 vulnerabilities, and standalone helper smoke checks passed.
No inline security finding comments were left. Targeted npx mocha tests/web.httpHelpers.test.js --exit could not run in this checkout because @fabric/core/constants is missing.
Sent by Cursor Automation: Find vulnerabilities


Streamline the HTTP library for the release of Fabric
0.1.0.Summary by CodeRabbit
New Features
Documentation
Tests
Chores