Skip to main content

Crate tightbeam_ws

Crate tightbeam_ws 

Source
Expand description

§tightbeam-ws

WebSocket transport for the tightbeam messaging protocol.

§Status

This project is under active development. Public APIs MAY change without notice. No security audit has been conducted. Use this software at your own risk.

§Abstract

tightbeam streams DER-encoded envelopes over raw TCP. This crate carries the same envelopes as WebSocket binary messages (RFC 6455), one envelope per message, so browsers and other WebSocket clients speak tightbeam. It plugs into the transport traits of tightbeam, so the handshake, the policies, multiplexing, and pooling of tightbeam run over it unchanged.

§Install

cargo add tightbeam-ws

§Quick start

use tightbeam::{server, Frame};
use tightbeam_ws::protocol::WsListener;

let listener: WsListener = WsListener::bind_cleartext("127.0.0.1:9101").await?;
let server_handle = server! {
	protocol WsListener: listener,
	handle: |message: Frame| async move {
		Ok(Some(message))
	}
};

The listener serves in the clear here, and bind_cleartext says so: its connections are plaintext, unprotected, and unauthenticated (CWE-319). An encrypted listener binds with its certificate, and each connection runs the tightbeam handshake.

§Transport

WsListener is a tightbeam protocol: it binds, accepts, and dials WebSocket connections, and its stream holds every read and write to the envelope rules of tightbeam-wire. The browser engine shares those rules. Implementation: docs/ws.md.

§Security

Authentication and confidentiality come from the tightbeam handshake above the socket, so the listener binds ws:// and leaves TLS to a terminator in front of it. A listener that serves no anonymous peer requires mutual authentication. Implementation: docs/ws.md.

§Push-capable servers

The serve feature owns one accepted multiplexed connection and lends its service the handle that server-initiated streams leave on. tightbeam-pubsub serves through it. Implementation: docs/ws.md.

§Cluster edge

A tightbeam cluster gateway binds a WebSocket edge that admits signed work frames from browsers, and the colony runs on WebSocket too. Implementation: docs/ws.md.

§Features

socket, on by default, holds the listener and the dial. serve, instrument, testing, and colony select the other parts. Implementation: docs/ws.md.

The browser engine is tightbeam-ws-wasm, packaged for npm as @wahidgroup/tightbeam-ws-client (client). See the repository README for development and release workflows.

§License

Licensed under either of MIT or Apache-2.0 at your option.

Re-exports§

pub use tightbeam;

Modules§

io
WebSocket message I/O for tightbeam, as docs/ws.md (Stream and envelope rules) states it.
protocol
The tightbeam listener over WebSocket, WsListener, as docs/ws.md (Listener) states it.

Enums§

Error
Errors produced by the WebSocket transport.

Type Aliases§

Result
Result alias for fallible tightbeam-ws operations.