Skip to content

Conversation

@juslesan
Copy link
Contributor

@juslesan juslesan commented Dec 22, 2025

Summary

Run validation of messages in a worker thread in the browser


Note

Medium Risk
Changes the core signature verification path to cross-thread worker execution and adds new build/test plumbing for worker bundles, which can introduce subtle runtime/env issues if bundling or serialization breaks.

Overview
Moves SDK signature verification for non-ERC_1271 messages into a Comlink-backed worker (SignatureValidation + SignatureValidationWorker), extracting the crypto checks into serializable, pure helpers (signatureValidationUtils) and adding MessageIdLike/MessageRefLike payload types to support worker transfer.

Adds platform-specific worker factories (src/_browser, src/_nodejs, src/_jest, src/_karma) and Rollup build outputs for worker bundles under dist/workers, updates Karma to serve worker assets, and includes workers in the published @streamr/sdk package. CLI behavior is adjusted to process.exit(0) after successful commands (to avoid worker threads keeping the event loop alive), and resend switches the non-subscribe path to async-iterate the client.resend() stream.

Tests are updated for the new SignatureValidator constructor (now requires DestroySignal) and an integration test timeout is increased to reduce flakiness.

Written by Cursor Bugbot for commit 738a126. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Dec 22, 2025

@github-actions github-actions bot added the sdk label Dec 22, 2025
@juslesan juslesan changed the title feat(sdk): [NET-1663] Validation in worker thread (draft) feat(sdk): [NET-1663] Signature validation in worker thread (draft) Dec 23, 2025
@github-actions github-actions bot added the cli-tools Related to CLI Tools Package label Jan 20, 2026
@mondoreale mondoreale changed the title feat(sdk): [NET-1663] Signature validation in worker thread (draft) feat(sdk): [NET-1663] Signature validation in worker thread Jan 28, 2026
@mondoreale mondoreale marked this pull request as ready for review January 28, 2026 23:37
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

await client.resend(streamId, resendOpts, handler)
const messageStream = await client.resend(streamId, resendOpts)
for await (const message of messageStream) {
console.info(JSON.stringify(message.content))
Copy link

Choose a reason for hiding this comment

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

Inconsistent CLI output between subscribe and resend modes

Medium Severity

Subscribe mode logs the full Message object via JSON.stringify(message) (line 24), but resend mode now logs only message.content via JSON.stringify(message.content). This creates inconsistent output where subscribe mode shows all message metadata (streamId, timestamp, publisherId, etc.) while resend mode shows only the payload content.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

@juslesan, thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-tools Related to CLI Tools Package sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants