@amritk/nish-x86_64-linux 0.49.0 → 0.50.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.
- package/INSTALL.md +1 -1
- package/bin/nish +0 -0
- package/docs/AI.md +233 -159
- package/package.json +1 -1
- package/runtime/gfx/nish-gfx.h +373 -61
- package/runtime/nish.d.ts +12 -9
- package/std/README.md +8 -5
- package/std/base64.ts +74 -1
- package/std/bytes.ts +201 -93
- package/std/compress/deflate.ts +20 -15
- package/std/crypto/base64url.ts +93 -66
- package/std/crypto/bcrypt.ts +25 -21
- package/std/crypto/hmac.ts +1 -1
- package/std/crypto/jwt.ts +32 -19
- package/std/crypto/p256.ts +9 -12
- package/std/crypto/pki-roots.ts +7 -4
- package/std/crypto/pki.ts +43 -55
- package/std/crypto/rsa-sign.ts +1632 -0
- package/std/crypto/rsa.ts +26 -4
- package/std/crypto/sha256.ts +135 -68
- package/std/crypto/x25519.ts +12 -11
- package/std/crypto/x509.ts +164 -40
- package/std/gpu/sys.ts +490 -0
- package/std/json-equal.ts +33 -18
- package/std/json-format.ts +39 -8
- package/std/json-number.ts +15 -3
- package/std/json-tokenizer.ts +4 -3
- package/std/json-typed.ts +29 -12
- package/std/json-value.ts +222 -104
- package/std/json.ts +81 -46
- package/std/net/dns-config.ts +18 -5
- package/std/net/dns-message.ts +60 -27
- package/std/net/dns-resolver.ts +35 -16
- package/std/net/dns.ts +3 -2
- package/std/net/fetch.ts +120 -38
- package/std/net/handler.ts +178 -66
- package/std/net/hpack.ts +192 -98
- package/std/net/http-compress.ts +83 -30
- package/std/net/http-fields.ts +327 -31
- package/std/net/http-server.ts +317 -20
- package/std/net/http1-client-codec.ts +137 -40
- package/std/net/http1-codec.ts +391 -202
- package/std/net/http1-server.ts +220 -38
- package/std/net/http2-cleartext.ts +10 -4
- package/std/net/http2-frame.ts +2 -2
- package/std/net/http2-tls.ts +3 -3
- package/std/net/http2.ts +69 -15
- package/std/net/http3-frame.ts +11 -14
- package/std/net/http3-server.ts +12 -15
- package/std/net/http3.ts +41 -29
- package/std/net/multipart.ts +592 -0
- package/std/net/outbound.ts +24 -8
- package/std/net/postgres-async.ts +92 -54
- package/std/net/postgres-carrier.ts +28 -4
- package/std/net/postgres.ts +166 -65
- package/std/net/prefork.ts +86 -5
- package/std/net/protobuf.ts +6 -2
- package/std/net/qpack.ts +66 -25
- package/std/net/quic-conn-ack.ts +27 -7
- package/std/net/quic-conn-cid.ts +13 -7
- package/std/net/quic-datagram.ts +6 -5
- package/std/net/quic-frame.ts +67 -23
- package/std/net/quic-listener.ts +19 -12
- package/std/net/quic-recovery.ts +11 -9
- package/std/net/quic-stream.ts +7 -5
- package/std/net/quic.ts +36 -31
- package/std/net/router.ts +136 -24
- package/std/net/serve.ts +59 -5
- package/std/net/static.ts +81 -33
- package/std/net/tls/record.ts +26 -13
- package/std/net/tls/ticket.ts +6 -5
- package/std/net/tls-tcp.ts +69 -30
- package/std/net/tls.ts +152 -38
- package/std/net/upstream.ts +65 -19
- package/std/net/url.ts +97 -78
- package/std/net/websocket.ts +33 -15
- package/std/net/webtransport.ts +28 -12
- package/std/regex.ts +600 -388
- package/std/sqlite.ts +37 -19
- package/std/sync/ring.ts +232 -115
- package/std/sync/shm.ts +11 -4
- package/std/temporal.ts +232 -133
- package/std/term-io.ts +12 -6
- package/std/term-pixels.ts +158 -22
- package/std/term-rate.ts +8 -3
- package/std/term.ts +4 -4
- package/std/text.ts +33 -11
- package/std/threads.ts +52 -8
- package/std/yaml-json.ts +238 -106
- package/std/yaml-lines.ts +47 -27
- package/std/yaml-write.ts +58 -24
- package/std/yaml.ts +808 -395
package/std/net/http3.ts
CHANGED
|
@@ -212,7 +212,6 @@ import {
|
|
|
212
212
|
H3_WT_SESSION_GONE,
|
|
213
213
|
Http3FrameHeader,
|
|
214
214
|
Http3Settings,
|
|
215
|
-
h3CheckWindow,
|
|
216
215
|
h3Count,
|
|
217
216
|
h3FrameHeaderSize,
|
|
218
217
|
h3PutFrameHeader,
|
|
@@ -1361,7 +1360,13 @@ export class Http3Connection {
|
|
|
1361
1360
|
}
|
|
1362
1361
|
have = have + n
|
|
1363
1362
|
headLens[k] = have
|
|
1364
|
-
|
|
1363
|
+
const end: i32 = base + have
|
|
1364
|
+
const head: u8[] = this.head
|
|
1365
|
+
// Never: slot `k`'s H3_HEAD bytes lie inside `head`, which nothing resizes.
|
|
1366
|
+
if (base < 0 || base > end || end > toI32(head.length)) {
|
|
1367
|
+
return H3_ZERO
|
|
1368
|
+
}
|
|
1369
|
+
if (h3ReadFrameHeader(this.header, head, base, end - base) > 0) {
|
|
1365
1370
|
if (k < toI32(headLens.length)) {
|
|
1366
1371
|
headLens[k] = 0
|
|
1367
1372
|
}
|
|
@@ -1566,8 +1571,14 @@ export class Http3Connection {
|
|
|
1566
1571
|
|
|
1567
1572
|
/** Acts on a whole control frame of `type` in `control[0 .. controlFill)`. */
|
|
1568
1573
|
private controlFrame(type: i64): i32 {
|
|
1574
|
+
const control: u8[] = this.control
|
|
1575
|
+
const fill: i32 = this.controlFill
|
|
1576
|
+
// Never: `controlStep` keeps `controlFill` within `control`, which nothing resizes.
|
|
1577
|
+
if (fill < 0 || fill > toI32(control.length)) {
|
|
1578
|
+
return this.fail(H3_INTERNAL_ERROR)
|
|
1579
|
+
}
|
|
1569
1580
|
if (type === H3_FRAME_SETTINGS) {
|
|
1570
|
-
const result: i64 = h3ReadSettings(this.peer,
|
|
1581
|
+
const result: i64 = h3ReadSettings(this.peer, control, 0, fill)
|
|
1571
1582
|
if (result !== H3_SETTINGS_OK) {
|
|
1572
1583
|
return this.fail(result)
|
|
1573
1584
|
}
|
|
@@ -1596,7 +1607,7 @@ export class Http3Connection {
|
|
|
1596
1607
|
if (type === H3_SKIP_TYPE) {
|
|
1597
1608
|
return H3_NEED_MORE
|
|
1598
1609
|
}
|
|
1599
|
-
const value: i64 = h3ReadIdPayload(
|
|
1610
|
+
const value: i64 = h3ReadIdPayload(control, 0, fill)
|
|
1600
1611
|
if (value < 0) {
|
|
1601
1612
|
return this.fail(H3_FRAME_ERROR)
|
|
1602
1613
|
}
|
|
@@ -1883,7 +1894,7 @@ export class Http3Connection {
|
|
|
1883
1894
|
* many it took — fewer only when the send buffer filled, and H3_WRITABLE
|
|
1884
1895
|
* then names the stream — or H3_AGAIN when it took none, or H3_CLOSED for
|
|
1885
1896
|
* a stream with no side here to write, finished, reset, held or stopped.
|
|
1886
|
-
* A window outside `buf`
|
|
1897
|
+
* A window outside `buf` answers H3_INVALID, before anything about the stream is asked.
|
|
1887
1898
|
*
|
|
1888
1899
|
* @param id A WebTransport stream this side writes, accepted or opened by `openStream`.
|
|
1889
1900
|
* @param buf The bytes; copied into the stream's send buffer, so the caller may reuse it.
|
|
@@ -1891,10 +1902,14 @@ export class Http3Connection {
|
|
|
1891
1902
|
* @param len How many bytes to offer; 0 with `fin` sends only the FIN.
|
|
1892
1903
|
* @param fin True to finish this side of the stream once all `len` bytes are taken.
|
|
1893
1904
|
* @returns The bytes taken, 1 to `len`, or 0 for a FIN alone; H3_AGAIN when it took none, a `len` of
|
|
1894
|
-
* 0 without `fin` among them; H3_CLOSED as above, or any stream once the connection has failed
|
|
1905
|
+
* 0 without `fin` among them; H3_CLOSED as above, or any stream once the connection has failed;
|
|
1906
|
+
* H3_INVALID for a window outside `buf`.
|
|
1895
1907
|
*/
|
|
1896
1908
|
writeStream(id: i64, buf: u8[], off: i32, len: i32, fin: boolean): i32 {
|
|
1897
|
-
|
|
1909
|
+
const size: i32 = toI32(buf.length)
|
|
1910
|
+
if (off < 0 || len < 0 || off > size || len > size - off) {
|
|
1911
|
+
return H3_INVALID
|
|
1912
|
+
}
|
|
1898
1913
|
const k: i32 = this.wtSlot(id)
|
|
1899
1914
|
const slots: QuicStream[] = this.quic.streams.slots
|
|
1900
1915
|
if (
|
|
@@ -2709,23 +2724,13 @@ export class Http3Connection {
|
|
|
2709
2724
|
digits[2] = toU8(H3_DIGIT_ZERO + (status % 10))
|
|
2710
2725
|
const nameLength: i32 = toI32(this.statusName.length)
|
|
2711
2726
|
const valueLength: i32 = toI32(digits.length)
|
|
2712
|
-
this.encoder.
|
|
2713
|
-
out,
|
|
2714
|
-
this.statusName,
|
|
2715
|
-
H3_ZERO,
|
|
2716
|
-
nameLength,
|
|
2717
|
-
this.statusValue,
|
|
2718
|
-
H3_ZERO,
|
|
2719
|
-
valueLength,
|
|
2720
|
-
false,
|
|
2721
|
-
true
|
|
2722
|
-
)
|
|
2727
|
+
this.encoder.encodeWholeField(out, this.statusName, digits, false, true)
|
|
2723
2728
|
size = toI64(nameLength) + toI64(valueLength) + toI64(QPACK_FIELD_OVERHEAD)
|
|
2724
2729
|
}
|
|
2725
2730
|
if (dated && status >= 200 && toI32(this.date.length) > 0 && !http3NamesHoldDate(names)) {
|
|
2726
2731
|
const nl: i32 = toI32(this.dateName.length)
|
|
2727
2732
|
const vl: i32 = toI32(this.date.length)
|
|
2728
|
-
this.encoder.
|
|
2733
|
+
this.encoder.encodeWholeField(out, this.dateName, this.date, false, true)
|
|
2729
2734
|
if (size >= 0 && size < 1073741824) {
|
|
2730
2735
|
size = size + toI64(nl) + toI64(vl) + toI64(QPACK_FIELD_OVERHEAD)
|
|
2731
2736
|
}
|
|
@@ -2736,7 +2741,7 @@ export class Http3Connection {
|
|
|
2736
2741
|
const value: u8[] = values[j]
|
|
2737
2742
|
const nl: i32 = toI32(name.length)
|
|
2738
2743
|
const vl: i32 = toI32(value.length)
|
|
2739
|
-
this.encoder.
|
|
2744
|
+
this.encoder.encodeWholeField(out, name, value, httpFieldSensitive(name), true)
|
|
2740
2745
|
// The sum stops growing past 2^30 bytes: a section that size is past any stream buffer.
|
|
2741
2746
|
if (size >= 0 && size < 1073741824) {
|
|
2742
2747
|
size = size + toI64(nl) + toI64(vl) + toI64(QPACK_FIELD_OVERHEAD)
|
|
@@ -2859,7 +2864,7 @@ export class Http3Connection {
|
|
|
2859
2864
|
* took none;
|
|
2860
2865
|
* H3_CLOSED, or H3_INVALID before the head or when `endStream` would cut
|
|
2861
2866
|
* short the DATA frame the last call started.
|
|
2862
|
-
* A window outside `buf`
|
|
2867
|
+
* A window outside `buf` answers H3_INVALID, before anything about the stream is asked.
|
|
2863
2868
|
*
|
|
2864
2869
|
* @param id The request stream, after `respond`.
|
|
2865
2870
|
* @param buf The body bytes; copied into the stream's send buffer, so the caller may reuse it.
|
|
@@ -2871,10 +2876,13 @@ export class Http3Connection {
|
|
|
2871
2876
|
* left owed cannot go; H3_CLOSED for a stream that is not an open request: unknown, not yet handed
|
|
2872
2877
|
* to the program, its response finished or reset, stopped by the client, or any stream once the
|
|
2873
2878
|
* connection has failed;
|
|
2874
|
-
* H3_INVALID as above
|
|
2879
|
+
* H3_INVALID as above, or for a window outside `buf`.
|
|
2875
2880
|
*/
|
|
2876
2881
|
writeData(id: i64, buf: u8[], off: i32, len: i32, endStream: boolean): i32 {
|
|
2877
|
-
|
|
2882
|
+
const size: i32 = toI32(buf.length)
|
|
2883
|
+
if (off < 0 || len < 0 || off > size || len > size - off) {
|
|
2884
|
+
return H3_INVALID
|
|
2885
|
+
}
|
|
2878
2886
|
const k: i32 = this.writeSlot(id)
|
|
2879
2887
|
if (k < 0) {
|
|
2880
2888
|
return H3_CLOSED
|
|
@@ -2898,7 +2906,7 @@ export class Http3Connection {
|
|
|
2898
2906
|
return 0
|
|
2899
2907
|
}
|
|
2900
2908
|
if (len < 0) {
|
|
2901
|
-
return H3_INVALID // never:
|
|
2909
|
+
return H3_INVALID // never: the window test refused a negative length
|
|
2902
2910
|
}
|
|
2903
2911
|
// DATA frame after DATA frame, until every byte is taken or the send buffer is full.
|
|
2904
2912
|
let total: i32 = 0
|
|
@@ -2938,7 +2946,7 @@ export class Http3Connection {
|
|
|
2938
2946
|
const fin: boolean = endStream && take === want && toI64(take) === left
|
|
2939
2947
|
const at: i64 = toI64(off) + toI64(total)
|
|
2940
2948
|
if (at > 2147483647) {
|
|
2941
|
-
break // never:
|
|
2949
|
+
break // never: the window test put the window inside `buf`
|
|
2942
2950
|
}
|
|
2943
2951
|
const n: i32 = this.quic.streamWrite(id, buf, toI32(at), take, fin)
|
|
2944
2952
|
if (n < 0) {
|
|
@@ -2971,7 +2979,7 @@ export class Http3Connection {
|
|
|
2971
2979
|
* H3_AGAIN while the send buffer lacks room, and H3_WRITABLE then names the
|
|
2972
2980
|
* stream; or as `writeData` refuses, and H3_TOO_LARGE for a frame past the
|
|
2973
2981
|
* stream's buffer.
|
|
2974
|
-
* A window outside `buf`
|
|
2982
|
+
* A window outside `buf` answers H3_INVALID, before anything about the stream is asked.
|
|
2975
2983
|
*
|
|
2976
2984
|
* @param id The request stream, after `respond`.
|
|
2977
2985
|
* @param buf The frame's payload; copied into the stream's send buffer, so the caller may reuse it.
|
|
@@ -2982,10 +2990,14 @@ export class Http3Connection {
|
|
|
2982
2990
|
* it, and H3_WRITABLE then names the stream; H3_CLOSED for a stream that is not an open request:
|
|
2983
2991
|
* unknown, not yet handed to the program, its response finished or reset, stopped by the client, or
|
|
2984
2992
|
* any stream once the connection has failed;
|
|
2985
|
-
* H3_INVALID before the head
|
|
2993
|
+
* H3_INVALID before the head, inside a DATA frame `writeData` has not finished, or for a window
|
|
2994
|
+
* outside `buf`; H3_TOO_LARGE.
|
|
2986
2995
|
*/
|
|
2987
2996
|
writeDataWhole(id: i64, buf: u8[], off: i32, len: i32, fin: boolean): i32 {
|
|
2988
|
-
|
|
2997
|
+
const size: i32 = toI32(buf.length)
|
|
2998
|
+
if (off < 0 || len < 0 || off > size || len > size - off) {
|
|
2999
|
+
return H3_INVALID
|
|
3000
|
+
}
|
|
2989
3001
|
const k: i32 = this.writeSlot(id)
|
|
2990
3002
|
if (k < 0) {
|
|
2991
3003
|
return H3_CLOSED
|
|
@@ -2997,7 +3009,7 @@ export class Http3Connection {
|
|
|
2997
3009
|
return H3_INVALID
|
|
2998
3010
|
}
|
|
2999
3011
|
if (len < 0) {
|
|
3000
|
-
return H3_INVALID // never:
|
|
3012
|
+
return H3_INVALID // never: the window test refused a negative length
|
|
3001
3013
|
}
|
|
3002
3014
|
const head: i32 = h3FrameHeaderSize(H3_FRAME_DATA, toI64(len))
|
|
3003
3015
|
if (head < 0 || head > 16) {
|