@amritk/nish-x86_64-linux 0.36.0 → 0.38.0

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.
Files changed (103) hide show
  1. package/INSTALL.md +92 -71
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +75 -14
  4. package/package.json +1 -1
  5. package/runtime/async.d.mts +2 -0
  6. package/runtime/async.mjs +7 -0
  7. package/runtime/core/arrays.d.ts +4 -0
  8. package/runtime/core/arrays.mjs +33 -0
  9. package/runtime/nish.d.ts +1045 -512
  10. package/runtime/nish.h +53 -6
  11. package/runtime/page.d.ts +53 -0
  12. package/runtime/page.mjs +146 -0
  13. package/runtime/runtime-async.c +740 -0
  14. package/runtime/runtime-cross.c +2 -1
  15. package/runtime/runtime-region.c +85 -7
  16. package/runtime/runtime-text.c +1068 -0
  17. package/runtime/runtime-wasm.c +65 -9
  18. package/runtime/runtime.c +50 -961
  19. package/runtime/vite.mjs +48 -11
  20. package/scripts/build.sh +231 -31
  21. package/std/LICENSE-fdlibm +8 -0
  22. package/std/README.md +109 -82
  23. package/std/array.ts +266 -0
  24. package/std/bytes.ts +23 -19
  25. package/std/compress/checksum.ts +1 -1
  26. package/std/crypto/aes.ts +48 -43
  27. package/std/crypto/base64url.ts +7 -5
  28. package/std/crypto/bcrypt-batch.ts +13 -13
  29. package/std/crypto/bcrypt.ts +33 -27
  30. package/std/crypto/chacha20poly1305.ts +16 -14
  31. package/std/crypto/ed25519.ts +19 -16
  32. package/std/crypto/hmac.ts +7 -6
  33. package/std/crypto/jwt.ts +23 -20
  34. package/std/crypto/p256.ts +63 -56
  35. package/std/crypto/p384.ts +23 -20
  36. package/std/crypto/pki.ts +18 -15
  37. package/std/crypto/rsa.ts +23 -19
  38. package/std/crypto/x25519.ts +11 -10
  39. package/std/crypto/x509.ts +69 -62
  40. package/std/host/ring.ts +124 -0
  41. package/std/host/text.ts +86 -0
  42. package/std/json-equal.ts +12 -11
  43. package/std/json-number.ts +12 -12
  44. package/std/json-tokenizer.ts +26 -22
  45. package/std/json-typed.ts +92 -78
  46. package/std/json-value.ts +38 -33
  47. package/std/json.ts +32 -28
  48. package/std/math.ts +743 -41
  49. package/std/net/dns-resolver.ts +46 -6
  50. package/std/net/dns.ts +50 -13
  51. package/std/net/fetch.ts +1744 -295
  52. package/std/net/handler.ts +30 -0
  53. package/std/net/hpack.ts +29 -26
  54. package/std/net/http-compress.ts +42 -28
  55. package/std/net/http-fields.ts +19 -4
  56. package/std/net/http1-client-codec.ts +29 -25
  57. package/std/net/http1-codec.ts +62 -91
  58. package/std/net/http1-server.ts +79 -57
  59. package/std/net/http2-frame.ts +17 -16
  60. package/std/net/http2-tls.ts +17 -15
  61. package/std/net/http2.ts +67 -54
  62. package/std/net/http3-frame.ts +11 -10
  63. package/std/net/http3-server.ts +36 -35
  64. package/std/net/http3.ts +70 -58
  65. package/std/net/postgres-async.ts +1005 -0
  66. package/std/net/postgres.ts +185 -164
  67. package/std/net/prefork.ts +38 -34
  68. package/std/net/qpack.ts +15 -14
  69. package/std/net/quic-conn-ack.ts +1 -0
  70. package/std/net/quic-conn-cid.ts +11 -0
  71. package/std/net/quic-conn-params.ts +41 -14
  72. package/std/net/quic-datagram.ts +7 -0
  73. package/std/net/quic-frame.ts +48 -12
  74. package/std/net/quic-listener.ts +61 -44
  75. package/std/net/quic-packet.ts +71 -52
  76. package/std/net/quic-recovery.ts +59 -21
  77. package/std/net/quic-stream.ts +83 -55
  78. package/std/net/quic.ts +204 -152
  79. package/std/net/serve.ts +763 -0
  80. package/std/net/tls/client.ts +1 -0
  81. package/std/net/tls/codec.ts +81 -12
  82. package/std/net/tls/record-client.ts +30 -18
  83. package/std/net/tls/record-server.ts +74 -46
  84. package/std/net/tls/record.ts +33 -24
  85. package/std/net/tls/ticket.ts +2 -0
  86. package/std/net/tls/verify.ts +8 -7
  87. package/std/net/tls-tcp.ts +58 -50
  88. package/std/net/tls.ts +55 -43
  89. package/std/net/url.ts +12 -9
  90. package/std/net/websocket.ts +23 -19
  91. package/std/net/webtransport.ts +24 -18
  92. package/std/random.ts +8 -6
  93. package/std/regex.ts +70 -59
  94. package/std/sync/ring.ts +24 -21
  95. package/std/sync/shm.ts +9 -7
  96. package/std/term-io.ts +17 -14
  97. package/std/term-probe.ts +11 -10
  98. package/std/term-rate.ts +71 -61
  99. package/std/term.ts +73 -59
  100. package/std/text.ts +242 -15
  101. package/std/threads.ts +19 -15
  102. package/std/yaml-json.ts +17 -15
  103. package/std/yaml-write.ts +21 -14
package/std/net/http2.ts CHANGED
@@ -34,64 +34,77 @@
34
34
  * // then conn.consume(sent)
35
35
  * };
36
36
  *
37
- * **Events.** `next()` reads the frames `feed` handed it and answers the
38
- * first that means something to the program: `H2_REQUEST` (a stream opened
39
- * with a request's header section; `fields` holds it until the next header
40
- * block on the connection is read, for any stream, and a program copies what
41
- * it keeps past that: the next block empties `fields` and reuses the arrays
42
- * it pointed into), `H2_DATA` (some of a request body, a window onto the input
43
- * buffer that stays valid until the next `feed`), `H2_TRAILERS`, `H2_RESET`
44
- * (the stream is gone: the peer reset it, or broke a rule that resets it —
45
- * `errorCode` says which), `H2_WINDOW` (a send window that held `writeData`
46
- * back has opened: `stream`, or 0 for the connection's), `H2_GOAWAY` (the
47
- * peer is going away; `lastStreamId`), and
48
- * `H2_ERROR`, final: the connection broke a rule, a GOAWAY with `errorCode`
49
- * is queued, and every later call answers it again. `H2_NEED_MORE` asks for
50
- * more input, or for the output to drain: a frame is read only while the
51
- * output has room for whatever it makes the connection answer, so a peer
52
- * that sends PINGs or SETTINGS and never reads the acknowledgements stops
53
- * being read rather than growing a queue. Bodies move a frame at a time and
54
- * nothing buffers a whole one.
37
+ * **Events.**
55
38
  *
56
- * **What the connection refuses**, as RFC 9113 classes it. A connection error
57
- * sends GOAWAY and ends the connection: a bad preface or a first frame that is
58
- * not SETTINGS (PROTOCOL_ERROR, §3.4); every refusal of
59
- * `nish/net/http2-frame`; a frame other than CONTINUATION inside a header
60
- * block, or a CONTINUATION outside one (§6.10); a stream identifier that is
61
- * even or does not increase (§5.1.1); DATA, WINDOW_UPDATE or RST_STREAM on an
62
- * idle stream, and a PUSH_PROMISE from a client (PROTOCOL_ERROR); HEADERS on
63
- * a closed stream (STREAM_CLOSED); a header block HPACK cannot decode
64
- * (COMPRESSION_ERROR, RFC 7541 §2.3.2); DATA past the connection window, or a
65
- * window pushed past 2^31 − 1 (FLOW_CONTROL_ERROR, §6.9); a setting
66
- * `http2SettingError` refuses; a header block longer than `maxHeaderBlock`
67
- * or cut into more than `H2_MAX_FRAGMENTS` frames, a header block that would
68
- * make the HPACK table copy past its budget (`HPACK_ERR_COPY_BUDGET`), and
69
- * more streams reset than `resetBudget` allows — by the peer, or by the
70
- * server for a stream error the peer caused (ENHANCE_YOUR_CALM, §10.5). A
71
- * stream error resets one stream and the connection lives: a malformed request
72
- * — any refusal of `nish/net/http-fields`, trailers without END_STREAM, a body
73
- * that disagrees with `content-length` (PROTOCOL_ERROR, §8.1.1); DATA or
74
- * HEADERS after the peer ended the stream (STREAM_CLOSED, §5.1); DATA past the
75
- * stream's window, or its window pushed past 2^31 − 1 (FLOW_CONTROL_ERROR); a
76
- * stream past `maxStreams` (REFUSED_STREAM, §5.1.2); a stream that depends on
77
- * itself and a PRIORITY of the wrong length. A request whose header list is
78
- * longer than `maxHeaderListSize` is answered with a 431 and never reaches the
79
- * program (§10.5.1).
39
+ * `next()` reads the frames `feed` handed it and answers the first that means
40
+ * something to the program:
41
+ * - `H2_REQUEST` (a stream opened with a request's header section; `fields`
42
+ * holds it until the next header block on the connection is read, for any
43
+ * stream, and a program copies what it keeps past that: the next block
44
+ * empties `fields` and reuses the arrays it pointed into),
45
+ * - `H2_DATA` (some of a request body, a window onto the input buffer that
46
+ * stays valid until the next `feed`),
47
+ * - `H2_TRAILERS`,
48
+ * - `H2_RESET` (the stream is gone: the peer reset it, or broke a rule that
49
+ * resets it — `errorCode` says which),
50
+ * - `H2_WINDOW` (a send window that held `writeData` back has opened: `stream`,
51
+ * or 0 for the connection's),
52
+ * - `H2_GOAWAY` (the peer is going away; `lastStreamId`),
53
+ * - and `H2_ERROR`, final: the connection broke a rule, a GOAWAY with
54
+ * `errorCode` is queued, and every later call answers it again.
55
+ *
56
+ * `H2_NEED_MORE` asks for more input, or for the output to drain: a frame is
57
+ * read only while the output has room for whatever it makes the connection
58
+ * answer, so a peer that sends PINGs or SETTINGS and never reads the
59
+ * acknowledgements stops being read rather than growing a queue. Bodies move a
60
+ * frame at a time and nothing buffers a whole one.
61
+ *
62
+ * **What the connection refuses**, as RFC 9113 classes it.
63
+ *
64
+ * A connection error sends GOAWAY and ends the connection:
65
+ * - a bad preface or a first frame that is not SETTINGS (PROTOCOL_ERROR, §3.4);
66
+ * - every refusal of `nish/net/http2-frame`;
67
+ * - a frame other than CONTINUATION inside a header block, or a CONTINUATION
68
+ * outside one (§6.10);
69
+ * - a stream identifier that is even or does not increase (§5.1.1);
70
+ * - DATA, WINDOW_UPDATE or RST_STREAM on an idle stream, and a PUSH_PROMISE
71
+ * from a client (PROTOCOL_ERROR);
72
+ * - HEADERS on a closed stream (STREAM_CLOSED);
73
+ * - a header block HPACK cannot decode (COMPRESSION_ERROR, RFC 7541 §2.3.2);
74
+ * - DATA past the connection window, or a window pushed past 2^31 − 1
75
+ * (FLOW_CONTROL_ERROR, §6.9);
76
+ * - a setting `http2SettingError` refuses;
77
+ * - a header block longer than `maxHeaderBlock` or cut into more than
78
+ * `H2_MAX_FRAGMENTS` frames, a header block that would make the HPACK table
79
+ * copy past its budget (`HPACK_ERR_COPY_BUDGET`), and more streams reset than
80
+ * `resetBudget` allows — by the peer, or by the server for a stream error the
81
+ * peer caused (ENHANCE_YOUR_CALM, §10.5).
82
+ *
83
+ * A stream error resets one stream and the connection lives: a malformed
84
+ * request — any refusal of `nish/net/http-fields`, trailers without END_STREAM,
85
+ * a body that disagrees with `content-length` (PROTOCOL_ERROR, §8.1.1); DATA or
86
+ * HEADERS after the peer ended the stream (STREAM_CLOSED, §5.1); DATA past the
87
+ * stream's window, or its window pushed past 2^31 − 1 (FLOW_CONTROL_ERROR); a
88
+ * stream past `maxStreams` (REFUSED_STREAM, §5.1.2); a stream that depends on
89
+ * itself and a PRIORITY of the wrong length. A request whose header list is
90
+ * longer than `maxHeaderListSize` is answered with a 431 and never reaches the
91
+ * program (§10.5.1).
80
92
  *
81
93
  * **Caps are start-up numbers**, all in `Http2Config`: the streams open at
82
94
  * once, the windows, the largest frame and header block accepted, the header
83
- * list, the output buffer and the reset budget. Every stream slot is
84
- * allocated by the constructor; the input, output and header-block buffers
85
- * are borrowed from an `Http2Pools` when first needed and given back, zeroed
86
- * as far as they were written, once each is empty or the connection ends, so
87
- * an idle connection holds none. A server shares one `Http2Pools` among its
88
- * slots; a connection on its own makes a private one that holds one buffer of
89
- * each. Once the pools are warm, reading DATA, writing DATA and every control
90
- * frame allocate nothing, and neither does a header block once the
91
- * decoder's arrays have grown to the largest block and header list seen: it
92
- * decodes into storage the connection owns, bounded by `maxHeaderBlock` and
93
- * `maxHeaderListSize` whether the stream is opened, refused or reset
94
- * (`docs/security/http2.md`, H2-1).
95
+ * list, the output buffer and the reset budget. Every stream slot is allocated
96
+ * by the constructor; the input, output and header-block buffers are borrowed
97
+ * from an `Http2Pools` when first needed and given back, zeroed as far as they
98
+ * were written, once each is empty or the connection ends, so an idle
99
+ * connection holds none.
100
+ *
101
+ * A server shares one `Http2Pools` among its slots; a connection on its own
102
+ * makes a private one that holds one buffer of each. Once the pools are warm,
103
+ * reading DATA, writing DATA and every control frame allocate nothing, and
104
+ * neither does a header block once the decoder's arrays have grown to the
105
+ * largest block and header list seen: it decodes into storage the connection
106
+ * owns, bounded by `maxHeaderBlock` and `maxHeaderListSize` whether the stream
107
+ * is opened, refused or reset (`docs/security/http2.md`, H2-1).
95
108
  *
96
109
  * The server sends no PUSH_PROMISE and no PRIORITY, and reads PRIORITY only to
97
110
  * check it: RFC 9113 §5.3.2 deprecates the scheme. Every field it sends is a
@@ -38,16 +38,17 @@
38
38
  * **SETTINGS** (§7.2.4). `h3ReadSettings` reads a whole payload into an
39
39
  * `Http3Settings`: the three identifiers this endpoint understands, and the
40
40
  * first `H3_SETTINGS_KEEP` it does not, kept rather than dropped so that an
41
- * extension can read them. The four that extended CONNECT and WebTransport
42
- * read (RFC 9220's, RFC 9297's and the two of the WebTransport drafts) are
43
- * also recorded in fields of their own, refused when repeated, so a peer
44
- * cannot push them out of reach behind eight others. A payload that ends
45
- * inside a pair is H3_FRAME_ERROR (§7.1); an identifier HTTP/2 defined with
46
- * no HTTP/3 counterpart (0x00, 0x02 to 0x05), or one that appears twice, is
47
- * H3_SETTINGS_ERROR (§7.2.4, §7.2.4.1). A repeat among the unknown ones is
48
- * caught while they are kept, and past `H3_SETTINGS_KEEP` they are counted,
49
- * not compared, so a peer cannot make the read cost more than a fixed number
50
- * of compares per setting.
41
+ * extension can read them. The four that extended CONNECT and WebTransport read
42
+ * (RFC 9220's, RFC 9297's and the two of the WebTransport drafts) are also
43
+ * recorded in fields of their own, refused when repeated, so a peer cannot push
44
+ * them out of reach behind eight others.
45
+ *
46
+ * A payload that ends inside a pair is H3_FRAME_ERROR (§7.1); an identifier
47
+ * HTTP/2 defined with no HTTP/3 counterpart (0x00, 0x02 to 0x05), or one that
48
+ * appears twice, is H3_SETTINGS_ERROR (§7.2.4, §7.2.4.1). A repeat among the
49
+ * unknown ones is caught while they are kept, and past `H3_SETTINGS_KEEP` they
50
+ * are counted, not compared, so a peer cannot make the read cost more than a
51
+ * fixed number of compares per setting.
51
52
  *
52
53
  * **Stream types** (§6.2): control 0x00, push 0x01, RFC 9204's QPACK
53
54
  * encoder 0x02 and decoder 0x03, and WebTransport's 0x54, whose bidirectional
@@ -65,19 +65,19 @@
65
65
  * GSO where the platform has it and one datagram at a time where it does not.
66
66
  * Each flight goes with the ECN codepoint its connection marked it with
67
67
  * (`QuicFlight.ecn`, RFC 9000 §13.4), so the peer's ACK_ECN counts are
68
- * validated and a CE mark shrinks the window. Where the platform sends no
69
- * ECN (Darwin, whose `udpSendTo` answers -95 to a marked send), the first
70
- * marked send goes again unmarked and no slot marks after it. A -95 is also
71
- * what a platform without segmentation offload answers, so a refused GSO
72
- * send goes again one datagram at a time, still marked, and only a -95 to
73
- * one of those turns marking off.
74
- * The pacer counts the microseconds `clock` gives it, so on a path whose
75
- * round trip is under a millisecond it neither waits for the next
76
- * millisecond to earn credit nor holds a slot back for a whole one; without
77
- * `clock` it counts whole milliseconds.
78
- * A slot whose HTTP/3 side sent GOAWAY and whose requests have all finished,
79
- * every byte acknowledged, is closed with H3_NO_ERROR; a closed slot is freed
80
- * once its CONNECTION_CLOSE is out.
68
+ * validated and a CE mark shrinks the window. Where the platform sends no ECN
69
+ * (Darwin, whose `udpSendTo` answers -95 to a marked send), the first marked
70
+ * send goes again unmarked and no slot marks after it.
71
+ *
72
+ * A -95 is also what a platform without segmentation offload answers, so a
73
+ * refused GSO send goes again one datagram at a time, still marked, and only a
74
+ * -95 to one of those turns marking off. The pacer counts the microseconds
75
+ * `clock` gives it, so on a path whose round trip is under a millisecond it
76
+ * neither waits for the next millisecond to earn credit nor holds a slot back
77
+ * for a whole one; without `clock` it counts whole milliseconds. A slot whose
78
+ * HTTP/3 side sent GOAWAY and whose requests have all finished, every byte
79
+ * acknowledged, is closed with H3_NO_ERROR; a closed slot is freed once its
80
+ * CONNECTION_CLOSE is out.
81
81
  *
82
82
  * **Timers** are a wheel of `H3_SERVER_WHEEL` one-millisecond buckets, a
83
83
  * slot in at most one: after every datagram and every flush the slot is filed
@@ -88,15 +88,16 @@
88
88
  *
89
89
  * **Caps, fixed at start-up**: the slots, and inside each the QUIC
90
90
  * configuration's streams and buffers and the `Http3Config`'s field section,
91
- * body chunk and DATA frame. A slot's connections and address are built on
92
- * the first Initial accepted into it and kept, so a pool sized for its peak
93
- * costs at start-up only its per-slot tables (the index, the wheel, the
94
- * queues), and holds at most `size` connections once the peak has come;
95
- * a datagram an established connection reads, and every datagram it sends,
96
- * allocates nothing; nor does a datagram no slot owns, which the listener
97
- * reads where it lies and answers into scratch made once, nor a handshake
98
- * into a slot built before, whose state is the slot's —
99
- * `docs/security/http3.md` (H3-1, H3-3).
91
+ * body chunk and DATA frame.
92
+ *
93
+ * A slot's connections and address are built on the first Initial accepted into
94
+ * it and kept, so a pool sized for its peak costs at start-up only its per-slot
95
+ * tables (the index, the wheel, the queues), and holds at most `size`
96
+ * connections once the peak has come; a datagram an established connection
97
+ * reads, and every datagram it sends, allocates nothing; nor does a datagram no
98
+ * slot owns, which the listener reads where it lies and answers into scratch
99
+ * made once, nor a handshake into a slot built before, whose state is the
100
+ * slot's — `docs/security/http3.md` (H3-1, H3-3).
100
101
  *
101
102
  * **The Date.** Every response carries one `date` field (RFC 9110 §6.6.1)
102
103
  * from the pool's `HttpDate`, which formats the IMF-fixdate at most once a
@@ -1223,19 +1224,19 @@ export class Http3Server {
1223
1224
 
1224
1225
  /**
1225
1226
  * Stops the server for good and wipes the keys it holds: every built slot's
1226
- * connection is released (`QuicConnection.release`, which sends nothing),
1227
- * as is one built after, by `connection` or `quic`; the listener is
1228
- * released; and the configuration's `statelessResetKey` and
1229
- * `retryTokenKey`, the index's salt, the connections' entropy scratch
1230
- * and the listener's last answer (a Retry's or a reset's token) are
1231
- * zeroed. From then on every datagram is dropped and no connection is
1232
- * accepted. The configuration's two keys are the server's once it is made
1233
- * with them: a program that keeps a copy of either, to start the next
1234
- * server with, wipes its own copy. The keys are zeroed in place, so give
1235
- * each server a `QuicServerConfig` of its own: any other listener,
1236
- * connection or server made with the same one would go on MACing Retry
1237
- * tokens and deriving stateless reset tokens under an all-zero key, which
1238
- * anyone can forge.
1227
+ * connection is released (`QuicConnection.release`, which sends nothing), as
1228
+ * is one built after, by `connection` or `quic`; the listener is released;
1229
+ * and the configuration's `statelessResetKey` and `retryTokenKey`, the
1230
+ * index's salt, the connections' entropy scratch and the listener's last
1231
+ * answer (a Retry's or a reset's token) are zeroed. From then on every
1232
+ * datagram is dropped and no connection is accepted.
1233
+ *
1234
+ * The configuration's two keys are the server's once it is made with them: a
1235
+ * program that keeps a copy of either, to start the next server with, wipes
1236
+ * its own copy. The keys are zeroed in place, so give each server a
1237
+ * `QuicServerConfig` of its own: any other listener, connection or server
1238
+ * made with the same one would go on MACing Retry tokens and deriving
1239
+ * stateless reset tokens under an all-zero key, which anyone can forge.
1239
1240
  */
1240
1241
  stop(): void {
1241
1242
  this.stopped = true
package/std/net/http3.ts CHANGED
@@ -38,19 +38,24 @@
38
38
  * }
39
39
  * }
40
40
  *
41
- * **Events.** `next()` reads the streams the QUIC connection has news for and
42
- * answers the first thing that means something to the program: `H3_REQUEST`
43
- * (a request's field section, in `fields`), `H3_DATA` (a piece of its body, a
44
- * window onto `data` valid until the next call), `H3_TRAILERS`, `H3_END` (the
45
- * request ended, and its `content-length`, if any, matched), `H3_RESET` (the
46
- * stream is gone: the client reset it or stopped it, or it broke a rule that
47
- * resets it — `errorCode` says which, `resetByPeer` who), `H3_WRITABLE` (a
48
- * stream whose write was held back can take more), `H3_GOAWAY` (the client is
49
- * going away; `lastStreamId` is its push ID), and `H3_ERROR`, final: the
50
- * connection broke a rule, it is closed with `errorCode`, and every later call
51
- * answers it again. `H3_NEED_MORE` asks for more datagrams. A request's events
52
- * come in order — REQUEST, DATA…, TRAILERS, END — and after `H3_RESET` its
53
- * stream has no more.
41
+ * **Events.**
42
+ *
43
+ * `next()` reads the streams the QUIC connection has news for and answers the
44
+ * first thing that means something to the program:
45
+ * - `H3_REQUEST` (a request's field section, in `fields`),
46
+ * - `H3_DATA` (a piece of its body, a window onto `data` valid until the next
47
+ * call),
48
+ * - `H3_TRAILERS`,
49
+ * - `H3_END` (the request ended, and its `content-length`, if any, matched),
50
+ * - `H3_RESET` (the stream is gone: the client reset it or stopped it, or it
51
+ * broke a rule that resets it — `errorCode` says which, `resetByPeer` who),
52
+ * - `H3_WRITABLE` (a stream whose write was held back can take more),
53
+ * - `H3_GOAWAY` (the client is going away; `lastStreamId` is its push ID),
54
+ * - and `H3_ERROR`, final: the connection broke a rule, it is closed with
55
+ * `errorCode`, and every later call answers it again.
56
+ *
57
+ * `H3_NEED_MORE` asks for more datagrams. A request's events come in order —
58
+ * REQUEST, DATA…, TRAILERS, END — and after `H3_RESET` its stream has no more.
54
59
  *
55
60
  * **Back-pressure** is QUIC's flow control. A body is read only as the
56
61
  * program calls `next()`, `bodyChunk` bytes at most at a time, and QUIC gives
@@ -71,29 +76,34 @@
71
76
  * A unidirectional stream of a type it does not know is asked to stop
72
77
  * (H3_STREAM_CREATION_ERROR) and read to its end (§6.2).
73
78
  *
74
- * **What it refuses.** A connection error closes the QUIC connection with
75
- * the code: a second control, encoder or decoder stream, or a push stream
76
- * from a client (H3_STREAM_CREATION_ERROR, §6.2.1, §6.2.2); a control stream
77
- * whose first frame is not SETTINGS (H3_MISSING_SETTINGS); the end, reset or
78
- * STOP_SENDING of any critical stream, either side's (H3_CLOSED_CRITICAL_STREAM);
79
- * a frame where it may not be — DATA or HEADERS on the control stream, a
80
- * control frame on a request stream, a second SETTINGS, DATA before HEADERS,
81
- * anything but the end after trailers, any PUSH_PROMISE from a client, and an
82
- * HTTP/2 type HTTP/3 reserves (H3_FRAME_UNEXPECTED, §7.2.8); a frame cut off
83
- * by its stream's end or a payload of the wrong length (H3_FRAME_ERROR, §7.1);
84
- * a SETTINGS frame `nish/net/http3-frame` refuses (H3_SETTINGS_ERROR); a
85
- * GOAWAY whose push ID rose, a MAX_PUSH_ID that fell, a CANCEL_PUSH past the
86
- * push IDs allowed (H3_ID_ERROR, §5.2, §7.2.7, §7.2.3); a control frame past
87
- * `H3_CONTROL_FRAME_MAX` (H3_EXCESSIVE_LOAD); and QPACK's three. A stream
88
- * error resets one request, both ways, and the connection lives: a field
89
- * section `nish/net/http-fields` refuses, and a body that disagrees with
90
- * `content-length` (H3_MESSAGE_ERROR, §4.1.2); a request stream that ends
91
- * before its HEADERS (H3_REQUEST_INCOMPLETE, §4.1.1); a request on a stream at
92
- * or past the ID of the GOAWAY this side sent (H3_REQUEST_REJECTED, §5.2).
93
- * A request whose field section is longer than `maxFieldSectionSize` — the
94
- * frame, or the section once decoded — is answered with a 431, never reaches
95
- * the program, and its stream is asked to stop with H3_NO_ERROR (§4.2.2,
96
- * §4.1.2).
79
+ * **What it refuses.**
80
+ *
81
+ * A connection error closes the QUIC connection with the code:
82
+ * - a second control, encoder or decoder stream, or a push stream from a client
83
+ * (H3_STREAM_CREATION_ERROR, §6.2.1, §6.2.2);
84
+ * - a control stream whose first frame is not SETTINGS (H3_MISSING_SETTINGS);
85
+ * - the end, reset or STOP_SENDING of any critical stream, either side's
86
+ * (H3_CLOSED_CRITICAL_STREAM);
87
+ * - a frame where it may not be — DATA or HEADERS on the control stream, a
88
+ * control frame on a request stream, a second SETTINGS, DATA before HEADERS,
89
+ * anything but the end after trailers, any PUSH_PROMISE from a client, and an
90
+ * HTTP/2 type HTTP/3 reserves (H3_FRAME_UNEXPECTED, §7.2.8);
91
+ * - a frame cut off by its stream's end or a payload of the wrong length
92
+ * (H3_FRAME_ERROR, §7.1);
93
+ * - a SETTINGS frame `nish/net/http3-frame` refuses (H3_SETTINGS_ERROR);
94
+ * - a GOAWAY whose push ID rose, a MAX_PUSH_ID that fell, a CANCEL_PUSH past
95
+ * the push IDs allowed (H3_ID_ERROR, §5.2, §7.2.7, §7.2.3);
96
+ * - a control frame past `H3_CONTROL_FRAME_MAX` (H3_EXCESSIVE_LOAD);
97
+ * - and QPACK's three.
98
+ *
99
+ * A stream error resets one request, both ways, and the connection lives: a
100
+ * field section `nish/net/http-fields` refuses, and a body that disagrees with
101
+ * `content-length` (H3_MESSAGE_ERROR, §4.1.2); a request stream that ends
102
+ * before its HEADERS (H3_REQUEST_INCOMPLETE, §4.1.1); a request on a stream at
103
+ * or past the ID of the GOAWAY this side sent (H3_REQUEST_REJECTED, §5.2). A
104
+ * request whose field section is longer than `maxFieldSectionSize` — the frame,
105
+ * or the section once decoded — is answered with a 431, never reaches the
106
+ * program, and its stream is asked to stop with H3_NO_ERROR (§4.2.2, §4.1.2).
97
107
  *
98
108
  * **No server push.** It never sends PUSH_PROMISE; a client's MAX_PUSH_ID is
99
109
  * allowed, checked and ignored.
@@ -109,28 +119,30 @@
109
119
  * counters saturate, and the lookup of a stream's state is the QUIC
110
120
  * connection's own hash index (`QuicStreams.slotOf`), never a scan.
111
121
  *
112
- * **Extended CONNECT and WebTransport.** With `extendedConnect` the
113
- * connection sends SETTINGS_ENABLE_CONNECT_PROTOCOL 1 and a request may carry
114
- * `:protocol` (RFC 9220); without it `:protocol` is malformed,
115
- * H3_MESSAGE_ERROR. `webtransportSessions` above 0 turns that on and also
116
- * sends SETTINGS_H3_DATAGRAM 1, draft-02's SETTINGS_ENABLE_WEBTRANSPORT 1 and
117
- * draft-07's SETTINGS_WEBTRANSPORT_MAX_SESSIONS, and `nish/net/webtransport`
118
- * runs its sessions on top: a request then waits for the client's SETTINGS
119
- * (draft-02 §3.1), and a stream that opens with WebTransport's unidirectional
120
- * type (0x54) or bidirectional signal (0x41) is read as far as its session ID,
121
- * held unread and named in `H3_STREAM` until the program calls
122
- * `acceptStream` (its bytes then come as H3_DATA, H3_END, H3_RESET and
123
- * H3_STOPPED, and `writeStream` writes them as they are) or `refuseStream`.
124
- * `openStream` opens one of this side's; `writeDataWhole` writes a capsule;
125
- * a GOAWAY still lets a session's new stream in, and `H3_DROPPED` names a
126
- * request stream that ended before its request reached the program. The
127
- * client's SETTINGS_ENABLE_CONNECT_PROTOCOL and SETTINGS_H3_DATAGRAM must be
128
- * 0 or 1 (H3_SETTINGS_ERROR), a session ID that is no client-initiated
129
- * bidirectional stream is H3_ID_ERROR, and the signal anywhere but a stream's
130
- * start is H3_FRAME_ERROR. Holding every request, not only an extended
131
- * CONNECT, until the client's SETTINGS keeps a decoded field section from
132
- * having to be held per stream; it costs a request only when the client's
133
- * control stream is lost or reordered.
122
+ * **Extended CONNECT and WebTransport.** With `extendedConnect` the connection
123
+ * sends SETTINGS_ENABLE_CONNECT_PROTOCOL 1 and a request may carry `:protocol`
124
+ * (RFC 9220); without it `:protocol` is malformed, H3_MESSAGE_ERROR.
125
+ *
126
+ * `webtransportSessions` above 0 turns that on and also sends
127
+ * SETTINGS_H3_DATAGRAM 1, draft-02's SETTINGS_ENABLE_WEBTRANSPORT 1 and
128
+ * draft-07's SETTINGS_WEBTRANSPORT_MAX_SESSIONS, and `nish/net/webtransport`
129
+ * runs its sessions on top: a request then waits for the client's SETTINGS
130
+ * (draft-02 §3.1), and a stream that opens with WebTransport's unidirectional
131
+ * type (0x54) or bidirectional signal (0x41) is read as far as its session ID,
132
+ * held unread and named in `H3_STREAM` until the program calls `acceptStream`
133
+ * (its bytes then come as H3_DATA, H3_END, H3_RESET and H3_STOPPED, and
134
+ * `writeStream` writes them as they are) or `refuseStream`.
135
+ *
136
+ * `openStream` opens one of this side's; `writeDataWhole` writes a capsule; a
137
+ * GOAWAY still lets a session's new stream in, and `H3_DROPPED` names a request
138
+ * stream that ended before its request reached the program. The client's
139
+ * SETTINGS_ENABLE_CONNECT_PROTOCOL and SETTINGS_H3_DATAGRAM must be 0 or 1
140
+ * (H3_SETTINGS_ERROR), a session ID that is no client-initiated bidirectional
141
+ * stream is H3_ID_ERROR, and the signal anywhere but a stream's start is
142
+ * H3_FRAME_ERROR. Holding every request, not only an extended CONNECT, until
143
+ * the client's SETTINGS keeps a decoded field section from having to be held
144
+ * per stream; it costs a request only when the client's control stream is lost
145
+ * or reordered.
134
146
  *
135
147
  * Private helpers share the importing program's flat symbol namespace
136
148
  * (`docs/wp26-stdlib.md` §3e), which is why each one carries the module's name.