@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.
Files changed (73) hide show
  1. package/INSTALL.md +28 -16
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +380 -47
  4. package/package.json +1 -1
  5. package/runtime/core/arrays.d.ts +4 -0
  6. package/runtime/core/arrays.mjs +33 -0
  7. package/runtime/core/host.d.ts +11 -0
  8. package/runtime/core/host.mjs +35 -0
  9. package/runtime/nish.d.ts +645 -66
  10. package/runtime/nish.h +101 -15
  11. package/runtime/nish.mjs +69 -6
  12. package/runtime/node.mjs +117 -0
  13. package/runtime/runtime-aes.c +12 -4
  14. package/runtime/runtime-async.c +267 -51
  15. package/runtime/runtime-checksum.c +207 -15
  16. package/runtime/runtime-cross.c +2 -1
  17. package/runtime/runtime-net.c +32 -3
  18. package/runtime/runtime-os.c +174 -27
  19. package/runtime/runtime-region.c +170 -8
  20. package/runtime/runtime-sandbox.c +377 -17
  21. package/runtime/runtime-sha256.c +11 -4
  22. package/runtime/runtime-text.c +1068 -0
  23. package/runtime/runtime-wasm.c +18 -3
  24. package/runtime/runtime.c +55 -961
  25. package/runtime/vite.mjs +48 -11
  26. package/scripts/build.sh +113 -36
  27. package/std/LICENSE-fdlibm +8 -0
  28. package/std/README.md +7 -4
  29. package/std/array.ts +266 -0
  30. package/std/compress/checksum.ts +13 -0
  31. package/std/compress/deflate.ts +0 -2
  32. package/std/crypto/p256.ts +247 -74
  33. package/std/crypto/p384.ts +3 -1
  34. package/std/crypto/pki.ts +35 -9
  35. package/std/crypto/x25519.ts +153 -64
  36. package/std/crypto/x509.ts +113 -10
  37. package/std/host/text.ts +86 -0
  38. package/std/json-tokenizer.ts +20 -0
  39. package/std/json-typed.ts +217 -8
  40. package/std/math.ts +743 -41
  41. package/std/net/dns-resolver.ts +46 -6
  42. package/std/net/dns.ts +50 -13
  43. package/std/net/fetch.ts +691 -129
  44. package/std/net/handler.ts +142 -16
  45. package/std/net/http-compress.ts +17 -9
  46. package/std/net/http-fields.ts +19 -4
  47. package/std/net/http1-codec.ts +517 -154
  48. package/std/net/http1-server.ts +508 -25
  49. package/std/net/http2-cleartext.ts +526 -0
  50. package/std/net/http2-tls.ts +48 -0
  51. package/std/net/http2.ts +84 -0
  52. package/std/net/postgres-async.ts +2223 -0
  53. package/std/net/postgres-carrier.ts +343 -10
  54. package/std/net/postgres.ts +129 -11
  55. package/std/net/prefork.ts +195 -11
  56. package/std/net/quic-datagram.ts +30 -0
  57. package/std/net/quic-listener.ts +38 -12
  58. package/std/net/quic-packet.ts +19 -6
  59. package/std/net/quic-recovery.ts +134 -19
  60. package/std/net/quic-stream.ts +174 -36
  61. package/std/net/quic.ts +418 -18
  62. package/std/net/router.ts +39 -17
  63. package/std/net/serve.ts +867 -0
  64. package/std/net/tls/codec.ts +110 -32
  65. package/std/net/tls/record-server.ts +37 -7
  66. package/std/net/tls-tcp.ts +56 -1
  67. package/std/net/tls.ts +196 -50
  68. package/std/net/websocket.ts +55 -18
  69. package/std/net/webtransport.ts +179 -1
  70. package/std/regex.ts +69 -47
  71. package/std/region.ts +62 -11
  72. package/std/secret.ts +26 -59
  73. 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. */