rwebtransport 0.2.0 → 0.2.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 CHANGED
@@ -44,6 +44,7 @@
44
44
  4. [Reliable streams and unreliable datagrams](#reliable-streams-and-unreliable-datagrams)
45
45
  5. [The client API](#the-client-api)
46
46
  - [Connecting](#connecting)
47
+ - [Subprotocols, response headers, and keying material](#subprotocols-response-headers-and-keying-material)
47
48
  - [Bidirectional streams](#bidirectional-streams)
48
49
  - [Unidirectional streams](#unidirectional-streams)
49
50
  - [Datagrams](#datagrams)
@@ -307,10 +308,34 @@ await wt.closed; // resolves when the session ends cleanly, rejects on abnormal
307
308
  | `insecure` | `boolean` | Node extension. Disable **all** certificate verification. Development only. |
308
309
  | `headers` | `Record<string, string>` | Node extension. Extra request headers on the Extended CONNECT. |
309
310
  | `origin` | `string` | Node extension. Value for the `Origin` request header. |
311
+ | `protocols` | `string[]` | WebTransport subprotocols to offer, in preference order. Sent in the Extended CONNECT `wt-available-protocols` header; the server's choice is read back via `wt.protocol`. |
310
312
  | `allowPooling`, `requireUnreliable`, `congestionControl` | | Accepted for spec parity; currently informational. |
311
313
 
314
+ A pinned certificate is still validated beyond its fingerprint, matching what browsers enforce: it must be currently valid (now within `notBefore`..`notAfter`), have a total validity period of at most 14 days (`notAfter - notBefore`), and use an ECDSA key on the NIST P-256 (secp256r1) curve. A pinned cert that fails any of these is rejected: the handshake fails and `ready` rejects with a `WebTransportError`.
315
+
312
316
  When neither `serverCertificateHashes` nor `insecure` is set, the client performs full PKI validation against the system trust store with hostname checking.
313
317
 
318
+ ### Subprotocols, response headers, and keying material
319
+
320
+ Once `ready` resolves, a few more W3C session attributes are available:
321
+
322
+ - `wt.protocol` is the subprotocol the server negotiated from the `protocols` you offered, or `''` if none was negotiated.
323
+ - `wt.responseHeaders` is a `Headers` object holding the headers from the server's Extended CONNECT `2xx` response (empty until the session is established).
324
+ - `wt.exportKeyingMaterial(label, context, outputLength)` returns a `Promise<Uint8Array>` of RFC 5705 TLS keying material bound to this session. Both endpoints of the same session derive identical bytes for the same `label`, `context`, and length, and nobody outside the TLS session can, which makes it suitable for channel binding. `label` and `context` are required (`context` may be an empty buffer); the promise rejects if the session is closed or unusable or the TLS export fails (for example before the handshake completes). It is present on both client and server sessions.
325
+
326
+ ```ts
327
+ await wt.ready;
328
+ wt.protocol; // negotiated subprotocol, or '' if none
329
+ wt.responseHeaders; // Headers from the server's Extended CONNECT response
330
+
331
+ // RFC 5705 keying material for channel binding: identical bytes on both ends.
332
+ const keyingMaterial = await wt.exportKeyingMaterial(
333
+ new TextEncoder().encode('rwebtransport channel binding'),
334
+ new Uint8Array(0), // context (may be empty)
335
+ 32, // output length in bytes
336
+ );
337
+ ```
338
+
314
339
  ### Bidirectional streams
315
340
 
316
341
  ```ts
@@ -392,7 +417,9 @@ for (;;) {
392
417
  }
393
418
  ```
394
419
 
395
- `WebTransportServerSession` exposes `ready`, `closed`, `datagrams`, `createBidirectionalStream()`, `createUnidirectionalStream()`, `incomingBidirectionalStreams`, `incomingUnidirectionalStreams`, and `close()`, identical to the client, plus the request metadata (`authority`, `path`, `origin`, `headers`). The server runs on the same quiche engine and inherits the same panic containment and hostile-peer hardening as the client.
420
+ `WebTransportServerSession` exposes `ready`, `closed`, `datagrams`, `createBidirectionalStream()`, `createUnidirectionalStream()`, `incomingBidirectionalStreams`, `incomingUnidirectionalStreams`, `exportKeyingMaterial()`, and `close()`, identical to the client, plus the request metadata (`authority`, `path`, `origin`, `headers`, `requestedProtocols`, and the negotiated `protocol`). The server runs on the same quiche engine and inherits the same panic containment and hostile-peer hardening as the client.
421
+
422
+ `WebTransportServerOptions` also accepts a few negotiation fields alongside `host`, `port`, `cert`, and `key`. `supportedProtocols` lists the subprotocols the server supports, in preference order; for each CONNECT the server selects the first supported protocol the client also offered, echoes it (`wt-protocol`), and exposes it as `session.protocol` (`session.requestedProtocols` holds everything the client offered). `allowedOrigins`, when set, is a built-in origin gate: a CONNECT whose `Origin` header is not in the list is rejected with HTTP 403 before the session is surfaced, so the client's `ready` rejects; when omitted, any origin is accepted and the app can still inspect `session.origin`. `responseHeaders` is a `Record<string, string>` of static extra headers added to every `200` CONNECT response, visible to the client as `wt.responseHeaders`.
396
423
 
397
424
  ---
398
425
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwebtransport",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A fully-compatible WebTransport client and server for Node.js, powered by Cloudflare quiche + BoringSSL via neon.",
5
5
  "author": "Dacely Cloud",
6
6
  "homepage": "https://github.com/dacely-cloud/rwebtransport#readme",