npm.io
0.1.1 • Published 7h ago

@ptner/webtrans-lib-core

Licence
MIT
Version
0.1.1
Deps
0
Size
28 kB
Vulns
0
Weekly
0

@ptner/webtrans-lib-core

Transport-neutral building blocks for durable, resumable event delivery. The package defines a small JSON wire protocol, a storage contract, an in-memory implementation, and a persist-before-broadcast broker.

Delivery is at least once. Consumers persist the last processed sequence per channel and deduplicate replayed events. Servers retain events and answer subscribe with either replayed events or snapshot-required when the requested cursor is outside retention.

Sequences are strictly increasing high-water cursors within a channel, but they do not need to be contiguous. This permits backends that allocate sequence numbers globally while clients still keep one cursor per channel.

The protocol works over WebSocket, WebTransport control streams, Socket.IO, SSE, or any ordered message transport. Application-specific persistence such as Cloudflare Durable Objects should implement ReliableEventStore or use the same wire messages.

The in-memory store applies bounded defaults for retained events, channel count, and identifier lengths. Deployments can lower these limits through MemoryReliableEventStoreOptions; authentication and authorization remain the responsibility of the hosting application.