Skip to content

fix(decrypt-node): single-consumer output stream for framed decrypt - #1672

Merged
lucasmcdonald3 merged 1 commit into
v4.xfrom
fix/decrypt-node-4x-stream-truncation
Jul 21, 2026
Merged

fix(decrypt-node): single-consumer output stream for framed decrypt#1672
lucasmcdonald3 merged 1 commit into
v4.xfrom
fix/decrypt-node-4x-stream-truncation

Conversation

@lucasmcdonald3

@lucasmcdonald3 lucasmcdonald3 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

fix(decrypt-node): single-consumer output stream for framed decrypt

Route the decipher output through a single stream consumer (a terminal
PassThrough exposed as the Duplexify readable) so every frame reaches the
caller. Adds regression coverage for a multi-frame message (frameLength
>= the stream highWaterMark) via the one-shot and streaming APIs.

Backport of #1670 to the 4.x maintenance line.

Co-authored-by: sharmabikram <10997020+sharmabikram@users.noreply.github.com>
@lucasmcdonald3
lucasmcdonald3 requested a review from a team as a code owner July 21, 2026 18:09
@lucasmcdonald3
lucasmcdonald3 requested a review from Copilot July 21, 2026 18:11
@lucasmcdonald3 lucasmcdonald3 changed the title fix(decrypt-node): correct multi-frame stream assembly fix(decrypt-node): single-consumer output stream for framed decrypt Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes decrypt-node framed streaming decryption to ensure the decipher stream has a single consumer, preventing frame output from being lost, and adds a regression test vector to validate multi-frame plaintext integrity across different input chunkings.

Changes:

  • Update _decryptStream to expose a single-consumer PassThrough as the readable side of the returned duplex stream.
  • Add a multi-frame ciphertext fixture (frameLength 16384; 3 frames; 40960-byte patterned plaintext).
  • Add one-shot and streaming tests to assert decrypted plaintext matches expected bytes across chunk boundary scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
modules/decrypt-node/src/decrypt_stream.ts Routes decipher output through a single PassThrough that is also the duplex readable side, avoiding multiple consumers of the decipher stream.
modules/decrypt-node/test/fixtures.ts Adds a base64 fixture for a 3-frame, unsigned, non-committing message used to validate multi-frame decryption correctness.
modules/decrypt-node/test/decrypt.test.ts Adds regression tests for one-shot and streaming decrypt to ensure full plaintext is returned across different ciphertext chunk sizes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lucasmcdonald3
lucasmcdonald3 merged commit 66a4c85 into v4.x Jul 21, 2026
35 checks passed
@lucasmcdonald3
lucasmcdonald3 deleted the fix/decrypt-node-4x-stream-truncation branch July 21, 2026 18:32
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.

3 participants