Feat/oversized payloads#35
Conversation
Add @noble/hashes dependency for SHA256 digest operations in oversized transfers. Refactor oversized transfer logic into a dedicated sender-session module for better separation of concerns. Add hasSingleTag and hasEventTag utilities to utils.ts. Update session store to track client oversized transfer support. Add E2E tests for oversized request/response transfers and unit tests for the sender session.
- Use nullish coalescing operator instead of non-null assertion in receiver - Replace void with undefined for explicit return types in sender session
eaba5ea to
9d0da30
Compare
…hunk handling Add sequence validation to enforce proper ordering of transfer frames (start, accept, chunks, end), including: - Progress value validation for all frame types - Accept frame must advance past start progress - First chunk cannot skip beyond reserved accept slot - End frame must advance past all prior frames - Detect and reject conflicting duplicate chunks Add out-of-order chunk buffering with configurable limits: - maxOutOfOrderWindow: maximum forward gap allowed - maxOutOfOrderChunks: maximum buffered out-of-order chunks - maxConcurrentTransfers: limit active parallel transfers Add OversizedTransferSequenceError for sequencing violations and new test coverage.
…plitting Refactors the oversized transfer sender to correctly split UTF-8 strings by byte size without breaking multibyte characters. Adds utf8ByteLength and sha256Digest helper functions, adds validation for chunkSizeBytes parameter, and improves error handling for characters exceeding chunk size. Also adds acceptTimeoutMs option to NostrClientTransport for configuring handshake timeout. Includes test coverage for UTF-8 multibyte character handling.
This prerelease documents the new oversized payload transfer protocol for the Nostr transport layer, including sender/receiver flows, sequencing, out-of-order chunk handling, and UTF-8-safe chunk splitting.
|
@ContextVM-org I re-reviewed this PR against the CEP-22 oversized payload constraints. The recent commit fixed the earlier sequencing and UTF-8 splitting gaps. I think there are some issues still remaining (have listed them below, also i have tried to keep in mind the constraints for the implementation)
Let me know what you think! |
|
Hey! @1amKhush great comments. I'll think about them and review the implementation |
… add client capability advertisement Extract discovery tag parsing and merging logic into a new `discovery-tags.ts` module. Add client-side capability advertisement so clients can proactively advertise support for encryption, ephemeral gift wraps, and oversized transfers without waiting for server discovery. Also fix a race condition in the oversized transfer receiver where accept could arrive before waiter registration. BREAKING CHANGE: The `hasKnownDiscoveryTag` function has been removed from `nostr-client-transport.ts` in favor of the new `hasDiscoveryTags` and `parseDiscoveredPeerCapabilities` functions.
|
@1amKhush attached your comments in my last commit, also centralized discovery and capability learn and created some test around that. I'm thinking about creating a new informational cep describing stateless mode and how this capability learning works since currently it is not clear in cep 6. Also after this pr get's merged we can work in a refactor since there are some modules that are becoming pretty large |
|
Great call @ContextVM-org ! Let me know how i can help. If helpful, I can open a follow-up issue right after merge with a proposed refactor breakdown and a draft outline for the informational CEP. |
Extract the logic for composing outbound Nostr tags into a reusable `composeOutboundTags` method in BaseNostrTransport. This standardizes tag ordering across client and server transports (base tags first, then discovery tags, then negotiation tags). Refactor NostrClientTransport and NostrServerTransport to use the shared composition method, and add `chooseServerOutboundGiftWrapKind` for consistent gift wrap kind selection based on session capabilities and configuration. Also update `hasDiscoveryTags` to use a more efficient set-based check and add a test for ephemeral gift wrap kind selection when client advertises support.
|
That sounds great @1amKhush a follow up pr refactoring the code to keep it tidy would be pretty helpful. Im going to be mergin this shortly so we can start with that. Thanks |
This release adds oversized payload transfer support for the Nostr transport layer, including sender and receiver flows, sequencing and out-of-order chunk handling, and UTF-8-safe chunk splitting. Also includes refactoring to extract outbound tag composition into base class and discovery tags into a dedicated module with client capability advertisement.
Sure, I'll keep an eye out for the merge |
No description provided.