peerix - v0.8.0
    Preparing search index...

    Changelog

    All notable changes to this project will be documented in this file.

    The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

    • NostrDriver signals over Nostr relays you pass in, signing events with a built-in BIP-340 Schnorr implementation, so it needs no server or library of your own.
    • A channel opened with a protocol is raw: send() passes strings and binary data straight to it with no chunking or acknowledgments, and on an unreliable channel drops a message while the buffer is backed up. channel:message events for it have raw: true and data as the payload itself.
    • channel:message events have a type field ("text", "json", "blob", or "bytes") that tells what data resolves to.
    • Room, Peer, and their events take a metadata type parameter, as in new Room<{ name: string }>(), and Addon takes an event map type parameter. The new PeerInfo type describes a peer's id and metadata.
    • on() and once() return a function that removes the handler and accept a signal option that removes it when aborted.
    • Event handlers that throw or reject are reported as HANDLER_ERROR events on their room or peer, or as error events on their driver, instead of becoming uncaught exceptions.
    • The webrtc room option passes RTCPeerConnection and MediaStream classes to use instead of the globals, so a peer can run in Node.js with @roamhq/wrtc. Without MediaStream, a peer handles data only.
    • Breaking: on(), once(), off(), and emit() take a single event name instead of an array. Subscribe to each event separately, or use a general event such as connection, channel, stream, or track. Each call is a separate subscription, and handlers run in a microtask in emit order.
    • Breaking: connectionTimeout is in milliseconds, like the other time options, and defaults to 15000. Multiply existing values by 1000.
    • Breaking: Encrypted signaling is incompatible with earlier versions. Packet type, flags, and sender are authenticated, every message except announcements is encrypted, replayed messages are dropped, and malformed or oversized messages (including ones that decompress to more than 1 MiB) are rejected. The docs describe this as hiding messages from the signaling backend, not end-to-end encryption.
    • Breaking: Data channel transfers are flow-controlled, so a slow reader no longer buffers a whole transfer in memory. Update all peers together: a sender stops after about 1 MB when the receiver runs an earlier version.
    • Breaking: Without a protocol, send() works only on ordered, reliable channels, and fails on channels with maxRetransmits or maxPacketLifeTime.
    • Breaking: MemoryDriver no longer takes a delay option.
    • Breaking: The build targets ES2022 and supports Chrome and Edge 85+, Firefox 90+, and Safari and iOS 15.4+ (previously Chrome and Edge 80+, Firefox 78+). The bundle is about 15% smaller.
    • ChannelEvent is a union of ChannelStateEvent, ChannelMessageEvent, and ChannelErrorEvent, so data and error are no longer optional on the events that carry them.
    • room.send() without to sends only to peers whose channel is open. With to, it fails before sending if a target is unknown or has no open channel. Send failures are PeerixErrors with the DATACHANNEL_ERROR code. send() also fails with Info cannot be serialized to JSON when info can't be serialized, rejects a function or symbol message, and reads binary data and JSON objects at call time, as RTCDataChannel.send does.
    • join() resolves with the local peer when the room is already joined. Joins and leaves run in call order, and concurrent calls share one subscription. A room announces itself once per join, after both of its namespaces are subscribed. Peers that join at the same time no longer stall until the connection timeout: only one side of each pair starts the connection, so the verify callback may be called more than once for the same peer.
    • Rooms report driver errors, such as a lost connection or a refused subscription, as SIGNALING_ERROR events while joined.
    • Disposing a peer emits track:remove, stream:remove, and channel:close for its remote streams and channels before connection:closed.
    • room.attach() and room.detach() do nothing for an addon that is already attached or not attached. Room.emit(), Peer.emit(), and the internal signal event are no longer part of the public API.
    • Peers reconnect after a failed connection when signaling encryption is enabled, instead of failing with Encryption key not found. connectionTimeout: 0 disables the connection timeout instead of closing every peer immediately, a peer whose ICE state moves to completed counts as connected, and concurrent signals from one peer, or a join and leave racing with verification, no longer create duplicate or stale peers that leak their RTCPeerConnection. leave() closes every peer even if unsubscribing fails.
    • Sharing a stream reaches peers that joined after the first share() and peers still connecting, and a track shared under a second label is no longer sent twice. Re-sharing, unsharing, and ended tracks update the remote side, peer.unshare() no longer stops tracks shared with the whole room, and ended listeners are no longer leaked. share() rejects an invalid stream with MEDIASTREAM_ERROR.
    • Sender and receiver aborts, AbortSignals, and closed channels fail transfers at once with a clear reason instead of hanging, and a message nobody listens for is discarded instead of stalling its sender. A transfer on a slow link fails only once the channel buffer stops draining for 10 seconds. Empty messages are delivered, and a superseded incomplete transfer fails instead of resolving with truncated data.
    • room.send(stream, { to }) splits the stream only between the target peers, and a failed or stopped transfer aborts the rest. A broadcast room.send() keeps sending to the other peers when one stalls or fails mid-transfer, and rejects with that failure once every transfer has ended.
    • A remote peer can no longer grow memory without bound: a receiver aborts a transfer whose sender runs past the granted receive window, and the signaling layer keeps at most 4096 derived shared keys, like its other per-peer caches.
    • Peers running on @roamhq/wrtc work: a data channel that is already open when Peerix receives it reports channel:open instead of never opening, and 65535 reported for unset maxRetransmits or maxPacketLifeTime is treated as reliable instead of rejecting sends as unsupported.
    • Peers on Firefox 90–112 and Safari 15.4–16.3, which lack DecompressionStream, can connect: signaling messages are compressed only for peers that advertise they can decompress them. Streamed data can be iterated with for await in Safari, and ICE candidates without a usernameFragment are applied instead of dropped.
    • The internal control channel no longer appears as a data channel with an empty label, and control-channel failures are reported as SIGNALING_ERROR events instead of being dropped or rejected unhandled.
    • PeerixError keeps its code, cause, and stack when it wraps another error and always has a string message.
    • SseDriver reopens connections the browser gives up on, times out subscribes that never open, shares one connection per namespace, makes subscriber and publisher optional, sends Headers or array publisher headers, waits for a reconnecting connection in subscribe(), and reports errors as Error instances with the original event as cause.
    • SupabaseDriver delivers messages on a real Supabase backend: it sends { ns, data } objects as the Realtime REST API requires and routes each broadcast only to the namespace of its channel. It waits for the channel join before subscribe() resolves, keeps shared channels until the last handler unsubscribes, ignores payload-less broadcasts, and rejects failed publishes.
    • CentrifugeDriver waits for subscriptions to be ready, can rejoin after leaving, emits the base driver events, is inactive while reconnecting, and rejects a pending subscribe() when its namespace is unsubscribed or the driver is destroyed.
    • MqttDriver and SocketIoDriver reject subscribes cancelled before the acknowledgment, stay inactive when destroyed mid-reconnect, and unsubscribe on destroy(). MqttDriver rejects subscriptions the broker refuses, fails one the broker doesn't acknowledge within 10 seconds, like the other drivers, and goes inactive on every closed connection. SocketIoDriver honors server error acks with ackTimeout.
    • NatsDriver goes inactive when the connection closes or drains, and forwards nats.js v3 status errors.
    • Drivers recover subscriptions instead of going silent. NatsDriver and CentrifugeDriver resubscribe with backoff when the server ends one, and NatsDriver waits for the server to accept it (via flush(), when the client has it) before rooms announce again. SupabaseDriver rejoins a channel the server closed. A namespace that fails to subscribe no longer turns the whole driver inactive: MqttDriver, SocketIoDriver, SupabaseDriver and SseDriver retry it on its own with backoff, and rooms announce themselves again once it is restored.
    • CentrifugeDriver, MqttDriver, SocketIoDriver, SseDriver, and SupabaseDriver keep receiving on a namespace that is unsubscribed and subscribed again while its join is pending. BroadcastChannelDriver ignores foreign messages, BroadcastChannelDriver and MemoryDriver ignore calls after destroy(), and Driver.destroy() delivers inactive before removing handlers.
    • Room class as the top-level entry point for managing a room and its peers.
    • me object returned by the join() method contains the id and metadata of the local peer.
    • Breaking: Room identifier is now set via id option in the Room constructor instead of passed to join().
    • Breaking: join() no longer accepts a room name and now returns local peer information ({ id, metadata }).
    • Breaking: Peer class replaced the previous RemotePeer — it is now a peer connection handler created by Room.
    • Breaking: remote property on event payloads renamed to peer across all events.
    • Breaking: Stream and track events emitted from Room for local sharing have an undefined peer, allowing consumers to distinguish local from remote updates.
    • Breaking: connections property renamed to peers.
    • Breaking: Local events (local:join, local:leave, local:share, local:unshare, local:open, local:close). Use the stream and track events without a peer property for local stream sharing instead.
    • local:join and local:leave events emitted when join() / leave() methods are called.
    • local:share and local:unshare events emitted when share() / unshare() methods are called.
    • local:open and local:close events emitted when open() / close() methods are called.
    • Streams with all tracks ended are automatically unshared (unless managed is true).
    • Breaking: namespace option in signaling drivers is now a string instead of string[].
    • Breaking: share() / unshare() no longer return a MediaStream.
    • Breaking: managed now means the stream is externally managed and will not be stopped or unshared automatically.
    • Support for ReadableStream data in the send() method.
    • Optional metadata (info field) when sending messages.
    • Abort signal support to stop message transmission early.
    • toJSON() method on peer classes to serialize peer information.
    • Breaking: send() now returns an async iterator (for tracking transmission progress) or a Promise (for delivery confirmation).
    • Breaking: Incoming data is now delivered as a ReadableStream or a Promise — read the stream to track receiving progress, or await the Promise to receive the full message.
    • Chunking and buffering for large message payloads via data channels.
    • Data is sent through a single data channel (using the default label when label is omitted).
    • MqttDriver for signaling over MQTT via WebSockets.
    • CentrifugeDriver for signaling with a Centrifuge backend.
    • ackTimeout option in SocketIoDriver to configure server acknowledgment timeout.
    • iceCandidateDebounce option in Peer to configure ICE candidate debounce interval.
    • Breaking: Renamed dispatch to publish in the Driver interface for consistency with messaging terminology.
    • Breaking: Renamed publish / unpublish to share / unshare in Peer and RemotePeer to avoid confusion with the driver publish() method.
    • Signaling messages now use a Protobuf-like format instead of the previous custom binary format.
    • SseDriver defaults to a Mercure-compatible endpoint (/.well-known/mercure).
    • active property in drivers defaults to false.
    • Room property is escaped when namespace hashing is disabled.
    • Drivers use peer or room identifiers as event names instead of concatenated strings, simplifying event names.
    • Some drivers use empty prefixes by default — specify a prefix explicitly if needed.
    • Some drivers with a prefix option concatenate it directly to the event name without a separator — include a separator in the prefix if desired.
    • SseDriver for signaling via Server-Sent Events (SSE).
    • Debouncing for ICE candidates sent via signaling to reduce message volume.
    • Encryption keys are now derived automatically instead of using manually specified secrets.
    • Signaling encryption is enabled by default.
    • Peer IDs use the compressed public key format.
    • Minimum build target is ES2020 to support modern JavaScript features such as BigInt.
    • Renamed signalingHashing option to namespaceHashing.
    • License changed from GPL-3.0 to Apache-2.0.
    • SocketIoDriver for signaling via Socket.IO.
    • SupabaseDriver for signaling via Supabase Realtime.
    • destroy() method in supported drivers.
    • NATS driver updated to use nats-core instead of nats.ws.
    • Namespace hashing is enabled by default for improved privacy and compatibility.
    • Refactored error codes for clarity.
    • Driver interface uses plain arrays instead of TypedArrays for improved serialization.
    • Initial release.
    • Core WebRTC peer connections, signaling, media streams, and data channels.
    • Pluggable signaling drivers with a unified interface.