@amritk/nish-aarch64-linux 0.37.0 → 0.39.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 +28 -16
- package/bin/nish +0 -0
- package/docs/AI.md +380 -47
- package/package.json +1 -1
- package/runtime/core/arrays.d.ts +4 -0
- package/runtime/core/arrays.mjs +33 -0
- package/runtime/core/host.d.ts +11 -0
- package/runtime/core/host.mjs +35 -0
- package/runtime/nish.d.ts +645 -66
- package/runtime/nish.h +101 -15
- package/runtime/nish.mjs +69 -6
- package/runtime/node.mjs +117 -0
- package/runtime/runtime-aes.c +12 -4
- package/runtime/runtime-async.c +267 -51
- package/runtime/runtime-checksum.c +207 -15
- package/runtime/runtime-cross.c +2 -1
- package/runtime/runtime-net.c +32 -3
- package/runtime/runtime-os.c +174 -27
- package/runtime/runtime-region.c +170 -8
- package/runtime/runtime-sandbox.c +377 -17
- package/runtime/runtime-sha256.c +11 -4
- package/runtime/runtime-text.c +1068 -0
- package/runtime/runtime-wasm.c +18 -3
- package/runtime/runtime.c +55 -961
- package/runtime/vite.mjs +48 -11
- package/scripts/build.sh +113 -36
- package/std/LICENSE-fdlibm +8 -0
- package/std/README.md +7 -4
- package/std/array.ts +266 -0
- package/std/compress/checksum.ts +13 -0
- package/std/compress/deflate.ts +0 -2
- package/std/crypto/p256.ts +247 -74
- package/std/crypto/p384.ts +3 -1
- package/std/crypto/pki.ts +35 -9
- package/std/crypto/x25519.ts +153 -64
- package/std/crypto/x509.ts +113 -10
- package/std/host/text.ts +86 -0
- package/std/json-tokenizer.ts +20 -0
- package/std/json-typed.ts +217 -8
- package/std/math.ts +743 -41
- package/std/net/dns-resolver.ts +46 -6
- package/std/net/dns.ts +50 -13
- package/std/net/fetch.ts +691 -129
- package/std/net/handler.ts +142 -16
- package/std/net/http-compress.ts +17 -9
- package/std/net/http-fields.ts +19 -4
- package/std/net/http1-codec.ts +517 -154
- package/std/net/http1-server.ts +508 -25
- package/std/net/http2-cleartext.ts +526 -0
- package/std/net/http2-tls.ts +48 -0
- package/std/net/http2.ts +84 -0
- package/std/net/postgres-async.ts +2223 -0
- package/std/net/postgres-carrier.ts +343 -10
- package/std/net/postgres.ts +129 -11
- package/std/net/prefork.ts +195 -11
- package/std/net/quic-datagram.ts +30 -0
- package/std/net/quic-listener.ts +38 -12
- package/std/net/quic-packet.ts +19 -6
- package/std/net/quic-recovery.ts +134 -19
- package/std/net/quic-stream.ts +174 -36
- package/std/net/quic.ts +418 -18
- package/std/net/router.ts +39 -17
- package/std/net/serve.ts +867 -0
- package/std/net/tls/codec.ts +110 -32
- package/std/net/tls/record-server.ts +37 -7
- package/std/net/tls-tcp.ts +56 -1
- package/std/net/tls.ts +196 -50
- package/std/net/websocket.ts +55 -18
- package/std/net/webtransport.ts +179 -1
- package/std/regex.ts +69 -47
- package/std/region.ts +62 -11
- package/std/secret.ts +26 -59
- package/std/text.ts +464 -5
package/std/net/http2.ts
CHANGED
|
@@ -175,6 +175,7 @@ import {
|
|
|
175
175
|
H2_SETTINGS_MAX_CONCURRENT_STREAMS,
|
|
176
176
|
H2_SETTINGS_MAX_FRAME_SIZE,
|
|
177
177
|
H2_SETTINGS_MAX_HEADER_LIST_SIZE,
|
|
178
|
+
H2_SETTINGS_TIMEOUT,
|
|
178
179
|
H2_STREAM_CLOSED,
|
|
179
180
|
Http2Frame,
|
|
180
181
|
http2ParseFrame,
|
|
@@ -292,6 +293,16 @@ export class Http2Config {
|
|
|
292
293
|
* stream error the peer caused — net of the ones the server finishes.
|
|
293
294
|
*/
|
|
294
295
|
resetBudget: i32 = 100
|
|
296
|
+
/**
|
|
297
|
+
* Milliseconds the peer has, from `begin`, to acknowledge the server's SETTINGS: past them
|
|
298
|
+
* `expired` answers true and `timeOut` ends the connection with SETTINGS_TIMEOUT (RFC 9113 §6.5.3).
|
|
299
|
+
*/
|
|
300
|
+
settingsTimeout: i32 = 10000
|
|
301
|
+
/**
|
|
302
|
+
* Milliseconds without a byte read or written, counted from `lastActive`, after which `expired`
|
|
303
|
+
* answers true and `timeOut` ends the connection with GOAWAY NO_ERROR, streams open or not.
|
|
304
|
+
*/
|
|
305
|
+
idleTimeout: i32 = 60000
|
|
295
306
|
}
|
|
296
307
|
|
|
297
308
|
/**
|
|
@@ -509,6 +520,10 @@ export class Http2Connection {
|
|
|
509
520
|
data: u8[]
|
|
510
521
|
/** H2_RESET's, H2_GOAWAY's and H2_ERROR's code. */
|
|
511
522
|
errorCode: i64 = 0
|
|
523
|
+
/** When the carrier last moved a byte for the connection, in `monotonicNanos`; `begin` starts it. */
|
|
524
|
+
lastActive: i64 = 0
|
|
525
|
+
/** When the server's SETTINGS began to wait for their acknowledgement, in `monotonicNanos`; `begin` sets it. */
|
|
526
|
+
settingsSince: i64 = 0
|
|
512
527
|
/** Where the bytes fed and not read yet start in `input`. */
|
|
513
528
|
inputStart: i32 = 0
|
|
514
529
|
/** Where the bytes fed and not read yet end in `input`. */
|
|
@@ -590,6 +605,8 @@ export class Http2Connection {
|
|
|
590
605
|
http2CheckCap("headerTableSize", config.headerTableSize, 0, H2_MAX_WINDOW)
|
|
591
606
|
http2CheckCap("outputSize", config.outputSize, 1024, H2_MAX_WINDOW)
|
|
592
607
|
http2CheckCap("resetBudget", config.resetBudget, 0, H2_MAX_WINDOW)
|
|
608
|
+
http2CheckCap("settingsTimeout", config.settingsTimeout, 1, H2_MAX_WINDOW)
|
|
609
|
+
http2CheckCap("idleTimeout", config.idleTimeout, 1, H2_MAX_WINDOW)
|
|
593
610
|
this.config = config
|
|
594
611
|
this.frame = new Http2Frame()
|
|
595
612
|
this.empty = []
|
|
@@ -688,6 +705,73 @@ export class Http2Connection {
|
|
|
688
705
|
this.prefaceOwed = true
|
|
689
706
|
}
|
|
690
707
|
|
|
708
|
+
// ---- The clock ----------------------------------------------------------------
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Starts both of the connection's clocks at `now`: the deadline for the
|
|
712
|
+
* peer's acknowledgement of the server's SETTINGS, and the idle one. The
|
|
713
|
+
* connection reads no clock itself; a carrier calls this when it takes the
|
|
714
|
+
* peer, stamps `lastActive` whenever bytes move, and asks `expired`.
|
|
715
|
+
*
|
|
716
|
+
* @param now the current time in `monotonicNanos`, which both timeouts count from
|
|
717
|
+
*/
|
|
718
|
+
begin(now: i64): void {
|
|
719
|
+
this.settingsSince = now
|
|
720
|
+
this.lastActive = now
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/** Whether the server's SETTINGS have waited longer than `settingsTimeout` at `now` (`monotonicNanos`). */
|
|
724
|
+
private settingsLate(now: i64): boolean {
|
|
725
|
+
return (
|
|
726
|
+
!this.settingsAcked && now - this.settingsSince > toI64(this.config.settingsTimeout) * toI64(1000000)
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Whether the connection has outlived a timeout at `now`: the peer has not
|
|
732
|
+
* acknowledged the server's SETTINGS within `settingsTimeout` of `begin`,
|
|
733
|
+
* or nothing has moved for longer than `idleTimeout`.
|
|
734
|
+
*
|
|
735
|
+
* @param now the current time in `monotonicNanos`
|
|
736
|
+
* @returns true when the carrier should end the connection, after `timeOut` has written its GOAWAY
|
|
737
|
+
*/
|
|
738
|
+
expired(now: i64): boolean {
|
|
739
|
+
return this.settingsLate(now) || now - this.lastActive > toI64(this.config.idleTimeout) * toI64(1000000)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* The soonest `expired` can answer true at or after now, however the
|
|
744
|
+
* connection moves from here: `lastActive` only grows, and the SETTINGS
|
|
745
|
+
* deadline goes once they are acknowledged.
|
|
746
|
+
*
|
|
747
|
+
* @param now the current time in `monotonicNanos`
|
|
748
|
+
* @returns the earliest `monotonicNanos` instant at which `expired` could answer true
|
|
749
|
+
*/
|
|
750
|
+
expiresNoSooner(now: i64): i64 {
|
|
751
|
+
let soonest: i64 = this.lastActive + toI64(this.config.idleTimeout) * toI64(1000000)
|
|
752
|
+
if (!this.settingsAcked) {
|
|
753
|
+
const settings: i64 = this.settingsSince + toI64(this.config.settingsTimeout) * toI64(1000000)
|
|
754
|
+
soonest = settings < soonest ? settings : soonest
|
|
755
|
+
}
|
|
756
|
+
return soonest > now ? soonest : now
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Ends a connection `expired` at `now`: the connection fails with GOAWAY
|
|
761
|
+
* SETTINGS_TIMEOUT when the peer never acknowledged the server's SETTINGS
|
|
762
|
+
* in time (§6.5.3), and with GOAWAY NO_ERROR when it was idle. The
|
|
763
|
+
* carrier sends what it can of the output, then closes.
|
|
764
|
+
*
|
|
765
|
+
* @param now the current time in `monotonicNanos`, as `expired` was asked at
|
|
766
|
+
*/
|
|
767
|
+
timeOut(now: i64): void {
|
|
768
|
+
if (this.state === H2_STATE_FAILED) {
|
|
769
|
+
return
|
|
770
|
+
}
|
|
771
|
+
this.room()
|
|
772
|
+
this.fail(this.settingsLate(now) ? H2_SETTINGS_TIMEOUT : H2_NO_ERROR)
|
|
773
|
+
}
|
|
774
|
+
|
|
691
775
|
// ---- Borrowed buffers ---------------------------------------------------------
|
|
692
776
|
|
|
693
777
|
/** The pools the connection borrows from, made at ceiling 1 the first time a bare connection asks. */
|