@johnhenry/browsermesh-transport 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/package.json +2 -2
- package/src/wsh-bridge.mjs +16 -12
package/README.md
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
# browsermesh-transport
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@johnhenry/browsermesh-transport)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
3
6
|
WebSocket, WebRTC, WebTransport, relay, and streaming adapters for BrowserMesh.
|
|
4
7
|
|
|
8
|
+
## Why this exists
|
|
9
|
+
|
|
10
|
+
A mesh peer needs to move bytes to another peer, but browsers offer several incompatible ways to do that (WebRTC data channels, plain WebSockets, WebTransport) with wildly different connection-setup, NAT-traversal, and reliability characteristics -- and no single one works in every environment. `browsermesh-transport` exists so the rest of the mesh doesn't have to care which one is in play: `MeshTransportNegotiator`/`TransportFactory` try each candidate in a preferred order (`webrtc` → `wsh-wt` → `wsh-ws`) and hand back one object shaped like `MeshTransport`, regardless of which underlying protocol won. `WebRTCMeshManager` handles the harder WebRTC-specific problem of multiple independent connections per peer; `GatewayNode`/`RouteTable` and `MeshRelayClient` cover routing through and relaying via a gateway when a direct connection isn't possible. It depends only on `browsermesh-primitives`, for the shared `MESH_TYPE`/`MESH_ERROR` types its transports and streams report.
|
|
11
|
+
|
|
12
|
+
## Used by
|
|
13
|
+
|
|
14
|
+
`@johnhenry/browsermesh-apps` treats this package as an optional peer, reaching for it lazily: `webrtc-negotiator.mjs` `import()`s `WebRTCTransportAdapter` at connection time, and `mesh-bootstrap.mjs` does the same to wire a real transport negotiator into `createMeshNode()`. `@johnhenry/browsermesh-priority-mux` is a different kind of companion -- it has no hard dependency on this package at all, but is purpose-built to wrap this package's `WebSocketTransport` (or anything shaped the same way) with application-level priority scheduling, since a WebSocket -- unlike the `WebRTCTransport` here, which gets a second data channel almost for free -- is one ordered byte stream with no way to stop a bulk transfer from blocking an urgent message behind it. See `browsermesh-priority-mux`'s README for the full rationale.
|
|
15
|
+
|
|
5
16
|
## Provenance
|
|
6
17
|
|
|
7
18
|
Extracted from the private `clawser` monorepo (previously `packages/browsermesh-transport`), where it was manually published to npm, unscoped, as `browsermesh-transport@0.1.0` (2026-07-17) with no CI ever automating that publish. This is its first release as part of the `@johnhenry/browsermesh` monorepo; the version restarts at `0.0.0` per family convention.
|
|
@@ -32,7 +43,7 @@ npm install @johnhenry/browsermesh-transport @johnhenry/browsermesh-primitives
|
|
|
32
43
|
## Usage
|
|
33
44
|
|
|
34
45
|
```js
|
|
35
|
-
import { MeshTransport, WebSocketTransport, StreamMultiplexer } from 'browsermesh-transport';
|
|
46
|
+
import { MeshTransport, WebSocketTransport, StreamMultiplexer } from '@johnhenry/browsermesh-transport';
|
|
36
47
|
```
|
|
37
48
|
|
|
38
49
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/browsermesh-transport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "WebSocket, WebRTC, WebTransport, and relay adapters for BrowserMesh",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://opensource.johnhenry.me/browsermesh/",
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=26.0.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/wsh-bridge.mjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// Not a functional replacement for clawser-kernel-wsh-bridge.js despite the
|
|
6
|
-
// similar name and shared mention in docs/data/networking.yaml's "WSH Bridge
|
|
7
|
-
// Deprecation" entry — this bridges identity key *formats*, not wsh session
|
|
8
|
-
// tenant/capability routing.
|
|
9
|
-
* clawser-mesh-wsh-bridge.js -- Bridge between WshKeyStore and MeshIdentityManager.
|
|
2
|
+
* MeshWshBridge -- bridges identity key *formats* between WshKeyStore and
|
|
3
|
+
* MeshIdentityManager (not a general-purpose session/tenant/capability
|
|
4
|
+
* router).
|
|
10
5
|
*
|
|
11
6
|
* WshKeyStore uses hex-encoded SHA-256 fingerprints.
|
|
12
7
|
* MeshIdentityManager uses base64url-encoded SHA-256 pod IDs.
|
|
@@ -14,8 +9,14 @@
|
|
|
14
9
|
*
|
|
15
10
|
* This bridge converts between the two formats and syncs keys.
|
|
16
11
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
12
|
+
* Implemented and unit-tested (`test/wsh-bridge.test.mjs`), but this repo
|
|
13
|
+
* doesn't currently construct it anywhere outside that test suite -- there
|
|
14
|
+
* is no `new MeshWshBridge(...)` call site in this package's own source.
|
|
15
|
+
* It's kept available for consumers that maintain both a WshKeyStore and a
|
|
16
|
+
* MeshIdentityManager and need to keep their key formats in sync.
|
|
17
|
+
*
|
|
18
|
+
* Run tests: `npm test` in this package (runs `test/wsh-bridge.test.mjs`
|
|
19
|
+
* along with the rest of the suite).
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
import {
|
|
@@ -62,10 +63,13 @@ function bytesToHex(bytes) {
|
|
|
62
63
|
* uses base64url (no padding).
|
|
63
64
|
*/
|
|
64
65
|
export class MeshWshBridge {
|
|
65
|
-
|
|
66
|
+
// Duck-typed, not imported: this package doesn't depend on `@johnhenry/wsh`
|
|
67
|
+
// (source of WshKeyStore) or `@johnhenry/browsermesh-core` (source of
|
|
68
|
+
// MeshIdentityManager) -- see the constructor's own `{*}` params below.
|
|
69
|
+
/** @type {*} A WshKeyStore instance (hex-encoded fingerprints). */
|
|
66
70
|
#wshKeyStore;
|
|
67
71
|
|
|
68
|
-
/** @type {
|
|
72
|
+
/** @type {*} A MeshIdentityManager instance (base64url-encoded pod IDs). */
|
|
69
73
|
#meshIdentityManager;
|
|
70
74
|
|
|
71
75
|
/**
|