@ac-kit/net-websocket 0.1.0 → 0.1.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @ac-kit/net-websocket
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5075202: HTTP/3, over a multiplexed connection contract.
|
|
8
|
+
|
|
9
|
+
- `net-core`: `IMultiplexedConnection` and `IMultiplexedStream` — a secure
|
|
10
|
+
connection carrying many streams, each a `Transport` that either side can
|
|
11
|
+
reset or stop on its own — with `MultiplexedStreamHandlers` and the errors a
|
|
12
|
+
reset, a stop or the connection's end report. `Connector` is now generic over
|
|
13
|
+
what it establishes, like `IListener`.
|
|
14
|
+
- `async`: `staggeredRace`, RFC 8305 connection racing for any candidates.
|
|
15
|
+
- `format-varint`: QUIC variable-length integers (RFC 9000 §16) —
|
|
16
|
+
`readQuicVarint`, `readBigQuicVarint` (the whole 62-bit range, as a
|
|
17
|
+
`bigint`), `writeQuicVarint`, `encodeQuicVarint`, `quicVarintByteLength` and
|
|
18
|
+
`quicVarintEncodedLength`.
|
|
19
|
+
- `format-http`: `QpackDecoder` (RFC 9204, dynamic table and blocked streams)
|
|
20
|
+
and `QpackEncoder` (static table and literals); `Http3FrameDecoder` and
|
|
21
|
+
`encodeHttp3Frame` for HTTP/3 frames (RFC 9114), with DATA streamed in
|
|
22
|
+
pieces; `Http3Settings`, `Http3StreamType`, `Http3Error` and
|
|
23
|
+
`Http3ErrorCode`. `parseAltSvc` and `tryParseAltSvc` read the `Alt-Svc`
|
|
24
|
+
field (RFC 7838), `AltSvcSyntaxError` reporting a malformed one.
|
|
25
|
+
- `net-http`: `Http3ServerConnection` and `Http3ClientConnection`, with
|
|
26
|
+
trailers, GOAWAY and extended `CONNECT` tunnels (RFC 9220). `HttpServer`
|
|
27
|
+
serves HTTP/3 on multiplexed listeners with its `http3` option; `HttpAgent`
|
|
28
|
+
reaches `https:` origins over HTTP/3 with its own: those advertising it
|
|
29
|
+
through `Alt-Svc`, raced against TCP and falling back to it, or every one
|
|
30
|
+
with `priorKnowledge`.
|
|
31
|
+
- `net-quic`: first release. `QuicListener` and `createQuicConnector` over a
|
|
32
|
+
native quiche binding; the binding of each platform is its own optional
|
|
33
|
+
package, `@ac-kit/net-quic-<platform>`. A client's UDP socket is connected,
|
|
34
|
+
so a refused port fails the attempt at once.
|
|
35
|
+
- `node`: `DgramSocket.connect`, `disconnect`, `remoteAddress` and
|
|
36
|
+
`sendConnected`, for a UDP socket bound to one remote endpoint.
|
|
37
|
+
- `integration-test-util`: `createSelfSignedCertificate` takes the names the
|
|
38
|
+
certificate is valid for.
|
|
39
|
+
- `net-websocket`: documented over HTTP/3, which needed no change.
|
|
40
|
+
- Updated dependencies [5075202]
|
|
41
|
+
- @ac-kit/net-core@0.3.0
|
|
42
|
+
- @ac-kit/async@0.2.0
|
|
43
|
+
- @ac-kit/format-http@0.3.0
|
|
44
|
+
- @ac-kit/net-http@0.3.0
|
|
45
|
+
|
|
3
46
|
## 0.1.0
|
|
4
47
|
|
|
5
48
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ const server = new HttpServer({
|
|
|
41
41
|
- `connectWebSocket` — sends the opening handshake through an `HttpAgent` (or
|
|
42
42
|
one client connection), checks the answer, and returns the peer. The request
|
|
43
43
|
is version-neutral: an HTTP/1.1 connection carries it as an `Upgrade`, an
|
|
44
|
-
HTTP/2 one as an extended `CONNECT` on its own stream, beside the
|
|
44
|
+
HTTP/2 or HTTP/3 one as an extended `CONNECT` on its own stream, beside the
|
|
45
45
|
connection's other streams.
|
|
46
46
|
- `computeWebSocketAccept` — the `Sec-WebSocket-Accept` for a key.
|
|
47
47
|
|
|
@@ -50,8 +50,8 @@ page the user visits can open a WebSocket to the server with the user's
|
|
|
50
50
|
cookies.
|
|
51
51
|
|
|
52
52
|
Portable: no Node.js built-ins. The peer only ever sees a `Transport`, so it
|
|
53
|
-
runs the same over a TCP connection after `Upgrade`, over an HTTP/2
|
|
54
|
-
over any other transport.
|
|
53
|
+
runs the same over a TCP connection after `Upgrade`, over an HTTP/2 or HTTP/3
|
|
54
|
+
stream, or over any other transport.
|
|
55
55
|
|
|
56
56
|
See the
|
|
57
57
|
[generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/net-websocket/)
|
|
@@ -63,3 +63,4 @@ for the full reference.
|
|
|
63
63
|
(authoritative).
|
|
64
64
|
- [RFC 8441](https://www.rfc-editor.org/rfc/rfc8441) — WebSocket over HTTP/2's
|
|
65
65
|
extended `CONNECT`.
|
|
66
|
+
- [RFC 9220](https://www.rfc-editor.org/rfc/rfc9220) — the same over HTTP/3.
|
|
@@ -33,12 +33,13 @@ export declare class WebSocketHandshakeError extends Error {
|
|
|
33
33
|
*
|
|
34
34
|
* `ws:` and `wss:` URLs are requested as `http:` and `https:`. The request is a
|
|
35
35
|
* `CONNECT` with protocol `websocket`, which HTTP/1.1 sends as its `Upgrade`
|
|
36
|
-
* handshake and HTTP/2 as an extended `CONNECT` (RFC 8441
|
|
36
|
+
* handshake and HTTP/2 and HTTP/3 as an extended `CONNECT` (RFC 8441, RFC
|
|
37
|
+
* 9220).
|
|
37
38
|
*
|
|
38
39
|
* Over HTTP/1.1 the response must be a `101` with `Upgrade: websocket`, the
|
|
39
|
-
* `Sec-WebSocket-Accept` matching the key sent; over HTTP/2, a
|
|
40
|
-
* way it must choose no extension (none is offered), and a
|
|
41
|
-
* from those offered.
|
|
40
|
+
* `Sec-WebSocket-Accept` matching the key sent; over HTTP/2 and HTTP/3, a
|
|
41
|
+
* `2xx`. Either way it must choose no extension (none is offered), and a
|
|
42
|
+
* subprotocol only from those offered.
|
|
42
43
|
*
|
|
43
44
|
* @throws {WebSocketHandshakeError} When the server refuses or answers
|
|
44
45
|
* incorrectly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-websocket.d.ts","sourceRoot":"","sources":["../../src/handshake/connect-websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,CACN,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG;IACrC,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAE/B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,CAAC;AAEF,yEAAyE;AACzE,qBAAa,uBAAwB,SAAQ,KAAK;IAIhD,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHxB,2EAA2E;IAC3E,YACC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EAIvB;CACD;AAED
|
|
1
|
+
{"version":3,"file":"connect-websocket.d.ts","sourceRoot":"","sources":["../../src/handshake/connect-websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,CACN,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG;IACrC,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAE/B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,CAAC;AAEF,yEAAyE;AACzE,qBAAa,uBAAwB,SAAQ,KAAK;IAIhD,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHxB,2EAA2E;IAC3E,YACC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EAIvB;CACD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CACrC,SAAS,EAAE,aAAa,EACxB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC,aAAa,CAAC,CAsCxB"}
|
|
@@ -18,12 +18,13 @@ export class WebSocketHandshakeError extends Error {
|
|
|
18
18
|
*
|
|
19
19
|
* `ws:` and `wss:` URLs are requested as `http:` and `https:`. The request is a
|
|
20
20
|
* `CONNECT` with protocol `websocket`, which HTTP/1.1 sends as its `Upgrade`
|
|
21
|
-
* handshake and HTTP/2 as an extended `CONNECT` (RFC 8441
|
|
21
|
+
* handshake and HTTP/2 and HTTP/3 as an extended `CONNECT` (RFC 8441, RFC
|
|
22
|
+
* 9220).
|
|
22
23
|
*
|
|
23
24
|
* Over HTTP/1.1 the response must be a `101` with `Upgrade: websocket`, the
|
|
24
|
-
* `Sec-WebSocket-Accept` matching the key sent; over HTTP/2, a
|
|
25
|
-
* way it must choose no extension (none is offered), and a
|
|
26
|
-
* from those offered.
|
|
25
|
+
* `Sec-WebSocket-Accept` matching the key sent; over HTTP/2 and HTTP/3, a
|
|
26
|
+
* `2xx`. Either way it must choose no extension (none is offered), and a
|
|
27
|
+
* subprotocol only from those offered.
|
|
27
28
|
*
|
|
28
29
|
* @throws {WebSocketHandshakeError} When the server refuses or answers
|
|
29
30
|
* incorrectly.
|
|
@@ -36,7 +37,7 @@ export async function connectWebSocket(requester, url, options) {
|
|
|
36
37
|
}
|
|
37
38
|
const key = createWebSocketKey_();
|
|
38
39
|
const headers = new HttpHeaders(options.headers);
|
|
39
|
-
// Used by HTTP/1.1 only; RFC 8441
|
|
40
|
+
// Used by HTTP/1.1 only; RFC 8441 and RFC 9220 ignore it.
|
|
40
41
|
headers.set("sec-websocket-key", [key]);
|
|
41
42
|
headers.set("sec-websocket-version", ["13"]);
|
|
42
43
|
const offered = options.protocols ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-websocket.js","sourceRoot":"","sources":["../../src/handshake/connect-websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOlD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AA+B/D,yEAAyE;AACzE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAIvC,MAAM;IAHhB,2EAA2E;IAC3E,YACC,OAAe,EACN,MAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,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CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/net-websocket",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "WebSocket endpoints (RFC 6455) over any @ac-kit/net-core Transport: a message-level peer and the opening handshake for both sides.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rfc6455",
|
|
@@ -44,17 +44,19 @@
|
|
|
44
44
|
"prepack": "yarn build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ac-kit/async": "^0.
|
|
47
|
+
"@ac-kit/async": "^0.2.0",
|
|
48
48
|
"@ac-kit/core": "^0.5.0",
|
|
49
49
|
"@ac-kit/crypto-hash": "^0.1.4",
|
|
50
|
-
"@ac-kit/format-http": "^0.
|
|
50
|
+
"@ac-kit/format-http": "^0.3.0",
|
|
51
51
|
"@ac-kit/format-websocket": "^0.1.0",
|
|
52
|
-
"@ac-kit/net-core": "^0.
|
|
53
|
-
"@ac-kit/net-http": "^0.
|
|
54
|
-
"@types/web": "^0.0.
|
|
52
|
+
"@ac-kit/net-core": "^0.3.0",
|
|
53
|
+
"@ac-kit/net-http": "^0.3.0",
|
|
54
|
+
"@types/web": "^0.0.361"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@ac-kit/
|
|
57
|
+
"@ac-kit/integration-test-util": "0.4.0",
|
|
58
|
+
"@ac-kit/net-quic": "0.1.0",
|
|
59
|
+
"@ac-kit/net-transport-node": "0.2.1",
|
|
58
60
|
"@ac-kit/tsconfig": "0.1.0",
|
|
59
61
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
60
62
|
"@ac-kit/vitest-config": "0.1.1",
|