Skip to content

Replace legacy WebSocket dependency with bounded Node transport - #1

Open
mswilkison wants to merge 1 commit into
mainfrom
codex/native-websocket-adapter
Open

mswilkison wants to merge 1 commit into
mainfrom
codex/native-websocket-adapter

Conversation

@mswilkison

Copy link
Copy Markdown

The locked websocket@1.0.29 transport brings a large, obsolete runtime tree into every Node consumer. Replace it with a small event adapter over native browser WebSocket and pinned ws@8.22.1 in Node, reducing required production lock entries from 387 to 1. Remove the unused npm fs security-placeholder package and regenerate the lockfile.

Node retains a maintained protocol implementation because native Node WebSocket cannot express the existing HTTP/TLS request options or configure a pre-assembly receive limit. The adapter preserves custom CA/certificate/key/header/agent options, disables compression, and fixes an 8 MiB aggregate message limit even when callers supply overriding transport options. WebSocket framing and cryptography are not implemented locally. Failed connections reset their status so consumers can retry; late events from replaced sockets are ignored.

Compatibility changes:

  • Node >=22.4.0 replaces the former Node >=6 support promise. This requires a release appropriate for that breaking support change.
  • Browser connections require native WebSocket and reject nonempty Node-only request options explicitly.
  • The former separate 1 MiB frame limit becomes an 8 MiB aggregate message limit, including fragmented messages; this is not exact frame-limit parity.
  • The dapp's independently vendored Electrum wrapper is unaffected and needs a separate consumer update.

Validation:

  • 14 local-server tests pass on exact Node 22.4.0, Node 24.11.1, and Node 26.3.0: text/binary data, request path, close/error events, handshake cancellation/retry, TLS verification/custom CA, headers/proxy agent, oversized single and fragmented messages, Electrum negotiation/subscriptions/reconnect, and browser adapter selection.
  • ESLint, frozen npm ci --ignore-scripts, and git diff --check pass.
  • npm pack plus a clean production-only consumer import/constructor smoke check pass; test TLS fixtures are excluded from the published package.
  • CI runs the local tests across the supported matrix. Existing public-server tests remain available as npm run test:integration and manual CI dispatch.

A full browser bundle and live public Electrum integration were not run. Existing development-tool dependencies are outside this focused reduction; this is not a claim that the entire repository is vulnerability-free.

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