@amritk/nish-x86_64-linux 0.44.0 → 0.45.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/bin/nish +0 -0
- package/docs/AI.md +18 -16
- package/package.json +1 -1
- package/runtime/core/numbers.mjs +3 -1
- package/runtime/core/strings.mjs +90 -38
- package/runtime/core.d.ts +8 -0
- package/runtime/core.mjs +16 -0
- package/runtime/nish.d.ts +47 -5
- package/runtime/nish.mjs +4 -0
- package/std/README.md +3 -3
- package/std/array.ts +10 -2
- package/std/bytes.ts +239 -26
- package/std/cli-args.ts +1072 -606
- package/std/cli-flags.ts +180 -98
- package/std/cli.ts +21 -13
- package/std/collections.ts +245 -127
- package/std/compress/checksum.ts +32 -37
- package/std/compress/deflate.ts +1102 -542
- package/std/compress/gzip.ts +290 -145
- package/std/compress/zlib.ts +57 -21
- package/std/crypto/aes.ts +153 -75
- package/std/crypto/base64url.ts +84 -61
- package/std/crypto/bcrypt-batch.ts +164 -90
- package/std/crypto/bcrypt.ts +185 -107
- package/std/crypto/chacha20poly1305.ts +84 -68
- package/std/crypto/ct.ts +9 -7
- package/std/crypto/ed25519.ts +64 -27
- package/std/crypto/hkdf.ts +105 -63
- package/std/crypto/hmac.ts +95 -89
- package/std/crypto/jwt.ts +248 -126
- package/std/crypto/p256.ts +758 -444
- package/std/crypto/p384.ts +20 -13
- package/std/crypto/pki-roots.ts +95 -38
- package/std/crypto/pki.ts +164 -60
- package/std/crypto/rsa.ts +266 -223
- package/std/crypto/scram.ts +3 -4
- package/std/crypto/sha1.ts +107 -65
- package/std/crypto/sha256.ts +502 -422
- package/std/crypto/sha512.ts +204 -135
- package/std/crypto/x509-random.ts +9 -3
- package/std/crypto/x509.ts +331 -171
- package/std/json-equal.ts +35 -19
- package/std/json-format.ts +215 -108
- package/std/json-number.ts +126 -72
- package/std/json-pointer.ts +42 -13
- package/std/json-tokenizer.ts +498 -307
- package/std/json-typed.ts +115 -36
- package/std/json-value.ts +341 -152
- package/std/json.ts +300 -158
- package/std/net/buffer-pool.ts +17 -7
- package/std/net/dns-config.ts +427 -236
- package/std/net/dns-message.ts +114 -47
- package/std/net/dns-resolver.ts +736 -237
- package/std/net/dns.ts +205 -52
- package/std/net/fetch.ts +320 -184
- package/std/net/grpc.ts +948 -0
- package/std/net/handler.ts +1275 -217
- package/std/net/hpack.ts +395 -180
- package/std/net/http-compress.ts +502 -65
- package/std/net/http-fields.ts +85 -49
- package/std/net/http-server.ts +1764 -602
- package/std/net/http1-client-codec.ts +372 -161
- package/std/net/http1-codec.ts +665 -331
- package/std/net/http1-server.ts +660 -278
- package/std/net/http2-cleartext.ts +165 -95
- package/std/net/http2-frame.ts +232 -89
- package/std/net/http2-tls.ts +42 -12
- package/std/net/http2.ts +327 -101
- package/std/net/http3-frame.ts +68 -33
- package/std/net/http3-server.ts +647 -192
- package/std/net/http3.ts +667 -189
- package/std/net/oidc.ts +63 -24
- package/std/net/outbound.ts +207 -142
- package/std/net/postgres-async.ts +1165 -443
- package/std/net/postgres-carrier.ts +575 -372
- package/std/net/postgres.ts +1459 -559
- package/std/net/prefork.ts +254 -98
- package/std/net/protobuf.ts +1017 -0
- package/std/net/qpack.ts +143 -92
- package/std/net/quic-conn-ack.ts +50 -18
- package/std/net/quic-conn-cid.ts +66 -26
- package/std/net/quic-conn-params.ts +13 -7
- package/std/net/quic-datagram.ts +90 -27
- package/std/net/quic-frame.ts +225 -124
- package/std/net/quic-listener.ts +197 -89
- package/std/net/quic-packet.ts +289 -163
- package/std/net/quic-recovery.ts +279 -128
- package/std/net/quic-stream.ts +466 -167
- package/std/net/quic.ts +568 -257
- package/std/net/router.ts +450 -99
- package/std/net/serve.ts +651 -232
- package/std/net/static.ts +1458 -0
- package/std/net/tls/client.ts +140 -45
- package/std/net/tls/codec.ts +510 -260
- package/std/net/tls/record-client.ts +268 -76
- package/std/net/tls/record-server.ts +236 -79
- package/std/net/tls/record.ts +173 -47
- package/std/net/tls/schedule.ts +58 -39
- package/std/net/tls/ticket.ts +295 -103
- package/std/net/tls/verify.ts +1 -1
- package/std/net/tls-tcp.ts +218 -75
- package/std/net/tls.ts +260 -152
- package/std/net/upstream.ts +283 -86
- package/std/net/url.ts +277 -102
- package/std/net/websocket.ts +370 -186
- package/std/net/webtransport.ts +755 -436
- package/std/regex.ts +1659 -829
- package/std/sync/ring.ts +320 -156
- package/std/sync/shm.ts +53 -6
- package/std/text.ts +205 -124
- package/std/threads.ts +22 -2
package/std/net/http2-tls.ts
CHANGED
|
@@ -158,12 +158,13 @@ export class Http2TlsServer {
|
|
|
158
158
|
first.pools = this.pools
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
/** Makes the next slot's connection, on this pool's buffers and `date
|
|
162
|
-
private build():
|
|
161
|
+
/** Makes the next slot's connection, on this pool's buffers and `date`, and answers it. */
|
|
162
|
+
private build(): Http2Connection {
|
|
163
163
|
const conn: Http2Connection = new Http2Connection(this.config)
|
|
164
164
|
conn.date = this.date.current()
|
|
165
165
|
conn.pools = this.pools
|
|
166
166
|
this.connections.push(conn)
|
|
167
|
+
return conn
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
/** Whether `slot` holds a connection and its HTTP/2 side has been made. */
|
|
@@ -220,8 +221,15 @@ export class Http2TlsServer {
|
|
|
220
221
|
*/
|
|
221
222
|
connection(slot: i32): Http2Connection {
|
|
222
223
|
this.date.current()
|
|
223
|
-
const
|
|
224
|
-
|
|
224
|
+
const count: i32 = toI32(this.connections.length)
|
|
225
|
+
if (slot >= 0 && slot < count) {
|
|
226
|
+
return this.connections[slot]
|
|
227
|
+
}
|
|
228
|
+
// Slot 0's connection, made by the constructor, answers for any other slot, so this builds none.
|
|
229
|
+
if (toI32(this.connections.length) > 0) {
|
|
230
|
+
return this.connections[0]
|
|
231
|
+
}
|
|
232
|
+
return this.build()
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
/**
|
|
@@ -256,11 +264,13 @@ export class Http2TlsServer {
|
|
|
256
264
|
}
|
|
257
265
|
// `TlsTcpServer` hands out its lowest slots first, so this makes one
|
|
258
266
|
// connection, unless a program accepted on `tls` itself.
|
|
259
|
-
while (toI32(this.connections.length)
|
|
267
|
+
while (toI32(this.connections.length) < slot) {
|
|
260
268
|
this.build()
|
|
261
269
|
}
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
const conn: Http2Connection =
|
|
271
|
+
slot < toI32(this.connections.length) ? this.connections[slot] : this.build()
|
|
272
|
+
conn.restart()
|
|
273
|
+
conn.begin(monotonicNanos())
|
|
264
274
|
return slot
|
|
265
275
|
}
|
|
266
276
|
|
|
@@ -325,6 +335,10 @@ export class Http2TlsServer {
|
|
|
325
335
|
return H2_ERROR
|
|
326
336
|
}
|
|
327
337
|
this.date.current()
|
|
338
|
+
// `live` checked the slot against the connections; restated here, after the calls, for the index.
|
|
339
|
+
if (slot < 0 || slot >= toI32(this.connections.length)) {
|
|
340
|
+
return H2_ERROR
|
|
341
|
+
}
|
|
328
342
|
const conn: Http2Connection = this.connections[slot]
|
|
329
343
|
// TLS decrypts straight into the connection's input, so a byte is
|
|
330
344
|
// copied once on its way in.
|
|
@@ -374,9 +388,19 @@ export class Http2TlsServer {
|
|
|
374
388
|
if (this.refused(slot)) {
|
|
375
389
|
return this.tls.shutdown(slot)
|
|
376
390
|
}
|
|
391
|
+
// `live` checked the slot against the connections; restated here, after the calls, for the index.
|
|
392
|
+
if (slot < 0 || slot >= toI32(this.connections.length)) {
|
|
393
|
+
return TLS_RECORD_DONE
|
|
394
|
+
}
|
|
377
395
|
const conn: Http2Connection = this.connections[slot]
|
|
378
396
|
while (conn.wantsWrite()) {
|
|
379
|
-
const
|
|
397
|
+
const start: i32 = conn.outputStart
|
|
398
|
+
const end: i32 = conn.outputEnd
|
|
399
|
+
if (start < 0 || end < start) {
|
|
400
|
+
break
|
|
401
|
+
}
|
|
402
|
+
// `start` is 0 or more and `end` at least `start`, so the unsigned difference is the held byte count.
|
|
403
|
+
const n: i32 = this.tls.write(slot, conn.output, start, toI32(toU32(end) - toU32(start)))
|
|
380
404
|
if (n <= 0) {
|
|
381
405
|
break
|
|
382
406
|
}
|
|
@@ -423,8 +447,14 @@ export class Http2TlsServer {
|
|
|
423
447
|
const config: Http2Config = this.config
|
|
424
448
|
const shorter: i32 =
|
|
425
449
|
config.settingsTimeout < config.idleTimeout ? config.settingsTimeout : config.idleTimeout
|
|
426
|
-
|
|
427
|
-
|
|
450
|
+
// A timeout is an i32 of milliseconds, so the span is below 2^52 and the unsigned sum with a time of
|
|
451
|
+
// 0 or more cannot wrap; past the largest i64 it is held there.
|
|
452
|
+
const span: u64 = toU64(shorter > 0 ? shorter : H2_TLS_ZERO) * toU64(1000000)
|
|
453
|
+
const latest: u64 = toU64(now > 0 ? now : toI64(H2_TLS_ZERO)) + span
|
|
454
|
+
const largest: u64 = (toU64(1) << toU64(63)) - toU64(1)
|
|
455
|
+
let soonest: i64 = toI64(latest > largest ? largest : latest)
|
|
456
|
+
// At most one per slot, so the unsigned count cannot wrap.
|
|
457
|
+
let n: u32 = 0
|
|
428
458
|
for (let k: i32 = 0; k < toI32(this.connections.length); k++) {
|
|
429
459
|
if (this.tls.holds(k)) {
|
|
430
460
|
const conn: Http2Connection = this.connections[k]
|
|
@@ -432,14 +462,14 @@ export class Http2TlsServer {
|
|
|
432
462
|
conn.timeOut(now)
|
|
433
463
|
this.flush(k)
|
|
434
464
|
this.close(k)
|
|
435
|
-
n
|
|
465
|
+
n += 1
|
|
436
466
|
} else if (conn.expiresNoSooner(now) < soonest) {
|
|
437
467
|
soonest = conn.expiresNoSooner(now)
|
|
438
468
|
}
|
|
439
469
|
}
|
|
440
470
|
}
|
|
441
471
|
this.expireAfter = soonest
|
|
442
|
-
return n
|
|
472
|
+
return toI32(n)
|
|
443
473
|
}
|
|
444
474
|
|
|
445
475
|
/**
|