@ai-ecoverse/slicc-kernel 1.149.1 → 1.150.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/README.md +2 -1
- package/dist/kernel-worker.js +75 -43
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +75 -43
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/kernel/socket.d.ts +1 -1
- package/package.json +3 -3
|
@@ -7187,7 +7187,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
7187
7187
|
var init_version = __esm({
|
|
7188
7188
|
"src/version.ts"() {
|
|
7189
7189
|
"use strict";
|
|
7190
|
-
KERNEL_VERSION = true ? "1.
|
|
7190
|
+
KERNEL_VERSION = true ? "1.150.0" : "0.0.0-dev";
|
|
7191
7191
|
OS_RELEASE = "6.0.0-slicc";
|
|
7192
7192
|
}
|
|
7193
7193
|
});
|
package/dist/node.js
CHANGED
|
@@ -843,12 +843,12 @@ var KernelPipe = class {
|
|
|
843
843
|
await this.changed(signal);
|
|
844
844
|
}
|
|
845
845
|
const out = new Uint8Array(Math.min(max, this.size));
|
|
846
|
-
let
|
|
846
|
+
let filled2 = 0;
|
|
847
847
|
for (const chunk2 of this.chunks) {
|
|
848
|
-
if (
|
|
849
|
-
const count2 = Math.min(chunk2.length, out.length -
|
|
850
|
-
out.set(chunk2.subarray(0, count2),
|
|
851
|
-
|
|
848
|
+
if (filled2 === out.length) break;
|
|
849
|
+
const count2 = Math.min(chunk2.length, out.length - filled2);
|
|
850
|
+
out.set(chunk2.subarray(0, count2), filled2);
|
|
851
|
+
filled2 += count2;
|
|
852
852
|
}
|
|
853
853
|
return out;
|
|
854
854
|
}
|
|
@@ -876,12 +876,12 @@ var KernelPipe = class {
|
|
|
876
876
|
}
|
|
877
877
|
take(n) {
|
|
878
878
|
const out = new Uint8Array(n);
|
|
879
|
-
let
|
|
880
|
-
while (
|
|
879
|
+
let filled2 = 0;
|
|
880
|
+
while (filled2 < n) {
|
|
881
881
|
const head = this.chunks[0];
|
|
882
|
-
const count2 = Math.min(head.length, n -
|
|
883
|
-
out.set(head.subarray(0, count2),
|
|
884
|
-
|
|
882
|
+
const count2 = Math.min(head.length, n - filled2);
|
|
883
|
+
out.set(head.subarray(0, count2), filled2);
|
|
884
|
+
filled2 += count2;
|
|
885
885
|
if (count2 === head.length) this.chunks.shift();
|
|
886
886
|
else this.chunks[0] = head.subarray(count2);
|
|
887
887
|
}
|
|
@@ -1646,8 +1646,8 @@ var DIAL_ERRORS = [
|
|
|
1646
1646
|
"ETIMEDOUT",
|
|
1647
1647
|
"ECONNRESET"
|
|
1648
1648
|
];
|
|
1649
|
-
function dialError(e,
|
|
1650
|
-
if (
|
|
1649
|
+
function dialError(e, timedOut2, closed) {
|
|
1650
|
+
if (timedOut2) return new KernelError("ETIMEDOUT");
|
|
1651
1651
|
if (closed) return new KernelError("ECONNABORTED");
|
|
1652
1652
|
const code = e?.code;
|
|
1653
1653
|
const known = DIAL_ERRORS.find((errno3) => errno3 === code);
|
|
@@ -1902,7 +1902,7 @@ var KernelSocket = class _KernelSocket {
|
|
|
1902
1902
|
get loopbackLinked() {
|
|
1903
1903
|
return this.state === "connected" && !this.switch;
|
|
1904
1904
|
}
|
|
1905
|
-
async secureLink(make, signal = NEVER_ABORTED) {
|
|
1905
|
+
async secureLink(make, signal = NEVER_ABORTED, keeps = () => false) {
|
|
1906
1906
|
const raw2 = this.connection();
|
|
1907
1907
|
if (this.switch || this.served || this.writeShut || this.readShut)
|
|
1908
1908
|
throw new KernelError("EINVAL");
|
|
@@ -1924,14 +1924,18 @@ var KernelSocket = class _KernelSocket {
|
|
|
1924
1924
|
}
|
|
1925
1925
|
};
|
|
1926
1926
|
let made2;
|
|
1927
|
-
const abandon = () =>
|
|
1927
|
+
const abandon = () => {
|
|
1928
|
+
if (!keeps(signal.reason)) view2.close();
|
|
1929
|
+
};
|
|
1928
1930
|
signal.addEventListener("abort", abandon, { once: true });
|
|
1929
1931
|
try {
|
|
1930
1932
|
made2 = await make(view2);
|
|
1931
1933
|
} catch (err) {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1934
|
+
if (!(signal.aborted && keeps(signal.reason))) {
|
|
1935
|
+
view2.close();
|
|
1936
|
+
this.readShut = true;
|
|
1937
|
+
this.writeShut = true;
|
|
1938
|
+
}
|
|
1935
1939
|
this.changes.wake();
|
|
1936
1940
|
throw signal.aborted ? signal.reason : err;
|
|
1937
1941
|
} finally {
|
|
@@ -1955,9 +1959,9 @@ var KernelSocket = class _KernelSocket {
|
|
|
1955
1959
|
this.state = "connecting";
|
|
1956
1960
|
const abort = new AbortController();
|
|
1957
1961
|
this.dialing = abort;
|
|
1958
|
-
let
|
|
1962
|
+
let timedOut2 = false;
|
|
1959
1963
|
const timer = setTimeout(() => {
|
|
1960
|
-
|
|
1964
|
+
timedOut2 = true;
|
|
1961
1965
|
abort.abort(new KernelError("ETIMEDOUT"));
|
|
1962
1966
|
}, route2.timeoutMs ?? DIAL_TIMEOUT_MS);
|
|
1963
1967
|
const abandoned = new Promise((_, reject) => {
|
|
@@ -1973,7 +1977,7 @@ var KernelSocket = class _KernelSocket {
|
|
|
1973
1977
|
);
|
|
1974
1978
|
return Promise.race([dialled, abandoned]).then(
|
|
1975
1979
|
async (raw2) => {
|
|
1976
|
-
if (abort.signal.aborted) throw dialError(abort.signal.reason,
|
|
1980
|
+
if (abort.signal.aborted) throw dialError(abort.signal.reason, timedOut2, true);
|
|
1977
1981
|
const conn = new SwitchConn(raw2);
|
|
1978
1982
|
if (secure2) {
|
|
1979
1983
|
clearTimeout(timer);
|
|
@@ -1999,7 +2003,7 @@ var KernelSocket = class _KernelSocket {
|
|
|
1999
2003
|
);
|
|
2000
2004
|
},
|
|
2001
2005
|
(e) => {
|
|
2002
|
-
throw this.dialFailed(abort, dialError(e,
|
|
2006
|
+
throw this.dialFailed(abort, dialError(e, timedOut2, abort.signal.aborted));
|
|
2003
2007
|
}
|
|
2004
2008
|
).finally(() => clearTimeout(timer));
|
|
2005
2009
|
}
|
|
@@ -3358,7 +3362,7 @@ function satisfies(version, range2) {
|
|
|
3358
3362
|
}
|
|
3359
3363
|
|
|
3360
3364
|
// src/version.ts
|
|
3361
|
-
var KERNEL_VERSION = true ? "1.
|
|
3365
|
+
var KERNEL_VERSION = true ? "1.150.0" : "0.0.0-dev";
|
|
3362
3366
|
var OS_RELEASE = "6.0.0-slicc";
|
|
3363
3367
|
function procVersion() {
|
|
3364
3368
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -13691,8 +13695,8 @@ var HttpHandles = class {
|
|
|
13691
13695
|
else entry.left = next3.value;
|
|
13692
13696
|
} catch (e) {
|
|
13693
13697
|
entry.done = true;
|
|
13694
|
-
const
|
|
13695
|
-
return { ok: false, errno:
|
|
13698
|
+
const timedOut2 = e?.code === "ETIMEDOUT";
|
|
13699
|
+
return { ok: false, errno: timedOut2 ? "ETIMEDOUT" : "EIO", message: message2(e) };
|
|
13696
13700
|
}
|
|
13697
13701
|
}
|
|
13698
13702
|
const bytes = entry.left.subarray(0, Math.max(0, max));
|
|
@@ -14746,15 +14750,22 @@ async function tlsClient(conn, o, taken = new Uint8Array(0)) {
|
|
|
14746
14750
|
throw err;
|
|
14747
14751
|
}
|
|
14748
14752
|
}
|
|
14749
|
-
|
|
14753
|
+
var HTTP_REQUEST = /^[A-Z]{3,10} [!-~]/;
|
|
14754
|
+
function serverRefusal(err, session, first) {
|
|
14755
|
+
const opening2 = first ? new TextDecoder("latin1").decode(first.subarray(0, 16)) : "";
|
|
14756
|
+
if (HTTP_REQUEST.test(opening2))
|
|
14757
|
+
return new KernelError("EPROTO", "ERR_SSL_HTTP_REQUEST: http request");
|
|
14758
|
+
const text = err instanceof TlsError ? err.message : String(err);
|
|
14759
|
+
return new KernelError("EPROTO", `ERR_SSL_HANDSHAKE_FAILURE: ${text}${alertOf(session)}`);
|
|
14760
|
+
}
|
|
14761
|
+
async function serverHandshake(conn, session, inbox, first) {
|
|
14750
14762
|
for (; ; ) {
|
|
14751
14763
|
let done4;
|
|
14752
14764
|
try {
|
|
14753
14765
|
done4 = session.handshake();
|
|
14754
14766
|
} catch (err) {
|
|
14755
14767
|
await send(conn, session).catch(() => void 0);
|
|
14756
|
-
|
|
14757
|
-
throw new KernelError("EPROTO", `ERR_SSL_HANDSHAKE_FAILURE: ${text}${alertOf(session)}`);
|
|
14768
|
+
throw serverRefusal(err, session, first());
|
|
14758
14769
|
}
|
|
14759
14770
|
await send(conn, session);
|
|
14760
14771
|
if (done4) return;
|
|
@@ -14767,9 +14778,18 @@ async function serverHandshake(conn, session, inbox) {
|
|
|
14767
14778
|
}
|
|
14768
14779
|
}
|
|
14769
14780
|
async function tlsServer(conn, session, clientCerts) {
|
|
14770
|
-
|
|
14781
|
+
let first;
|
|
14782
|
+
const watched = {
|
|
14783
|
+
...conn,
|
|
14784
|
+
read: async () => {
|
|
14785
|
+
const bytes = await conn.read();
|
|
14786
|
+
first ??= bytes ?? void 0;
|
|
14787
|
+
return bytes;
|
|
14788
|
+
}
|
|
14789
|
+
};
|
|
14790
|
+
const inbox = new Ciphertext(watched, session);
|
|
14771
14791
|
try {
|
|
14772
|
-
await serverHandshake(conn, session, inbox);
|
|
14792
|
+
await serverHandshake(conn, session, inbox, () => first);
|
|
14773
14793
|
const chain2 = session.peerChain();
|
|
14774
14794
|
const code = clientCerts ? verifyCode(session.verifyResult) : void 0;
|
|
14775
14795
|
const info = {
|
|
@@ -15239,6 +15259,7 @@ var RANK = {
|
|
|
15239
15259
|
var CR2 = 13;
|
|
15240
15260
|
var LF2 = 10;
|
|
15241
15261
|
var EMPTY4 = new Uint8Array(0);
|
|
15262
|
+
var FILLER = 42;
|
|
15242
15263
|
function register(automaton, sources, ids, bytes, source) {
|
|
15243
15264
|
const key = Array.from(bytes).join(",");
|
|
15244
15265
|
let id2 = ids.get(key);
|
|
@@ -15249,7 +15270,7 @@ function register(automaton, sources, ids, bytes, source) {
|
|
|
15249
15270
|
}
|
|
15250
15271
|
sources[id2].push(source);
|
|
15251
15272
|
}
|
|
15252
|
-
function prepare(secrets) {
|
|
15273
|
+
function prepare(secrets, sameLength) {
|
|
15253
15274
|
const main = new Automaton();
|
|
15254
15275
|
const wrap = new Automaton();
|
|
15255
15276
|
const sources = [];
|
|
@@ -15273,7 +15294,19 @@ function prepare(secrets) {
|
|
|
15273
15294
|
utf82(secret.placeholder),
|
|
15274
15295
|
utf82(`[redacted:${secret.name}]`)
|
|
15275
15296
|
]);
|
|
15276
|
-
return { secrets, values, main, wrap, sources, wrapSources, replacements };
|
|
15297
|
+
return { secrets, values, main, wrap, sources, wrapSources, replacements, sameLength };
|
|
15298
|
+
}
|
|
15299
|
+
function filled(input, start2, end) {
|
|
15300
|
+
const out = new Uint8Array(end - start2);
|
|
15301
|
+
for (let i = start2; i < end; i++) {
|
|
15302
|
+
const byte = input[i];
|
|
15303
|
+
out[i - start2] = byte === CR2 || byte === LF2 ? byte : FILLER;
|
|
15304
|
+
}
|
|
15305
|
+
return out;
|
|
15306
|
+
}
|
|
15307
|
+
function replacement(c, input, candidate) {
|
|
15308
|
+
if (c.sameLength) return filled(input, candidate.start, candidate.end);
|
|
15309
|
+
return c.replacements[candidate.secret][candidate.form === "raw" ? 0 : 1];
|
|
15277
15310
|
}
|
|
15278
15311
|
function better(a, b) {
|
|
15279
15312
|
if (!b) return true;
|
|
@@ -15382,10 +15415,7 @@ function pass(c, input, final) {
|
|
|
15382
15415
|
break;
|
|
15383
15416
|
}
|
|
15384
15417
|
const candidate = best.get(next3);
|
|
15385
|
-
parts2.push(
|
|
15386
|
-
input.subarray(pos, next3),
|
|
15387
|
-
c.replacements[candidate.secret][candidate.form === "raw" ? 0 : 1]
|
|
15388
|
-
);
|
|
15418
|
+
parts2.push(input.subarray(pos, next3), replacement(c, input, candidate));
|
|
15389
15419
|
count(c, hits, candidate);
|
|
15390
15420
|
pos = candidate.end;
|
|
15391
15421
|
}
|
|
@@ -15400,7 +15430,10 @@ function merge(into, from) {
|
|
|
15400
15430
|
}
|
|
15401
15431
|
}
|
|
15402
15432
|
function compile(secrets, options = {}) {
|
|
15403
|
-
const c = prepare(
|
|
15433
|
+
const c = prepare(
|
|
15434
|
+
secrets.map((secret) => ({ ...secret })),
|
|
15435
|
+
options.sameLength === true
|
|
15436
|
+
);
|
|
15404
15437
|
const decoder4 = new TextDecoder();
|
|
15405
15438
|
const idleMs = options.idleMs ?? 250;
|
|
15406
15439
|
const scrubBytes = (input) => {
|
|
@@ -17973,12 +18006,10 @@ function timeoutOf(req) {
|
|
|
17973
18006
|
);
|
|
17974
18007
|
return ms;
|
|
17975
18008
|
}
|
|
18009
|
+
var timedOut = new KernelError("EPROTO", "ERR_TLS_HANDSHAKE_TIMEOUT: TLS handshake timeout");
|
|
17976
18010
|
function handshakeSignal(proc, ms) {
|
|
17977
18011
|
const timer = new AbortController();
|
|
17978
|
-
const id2 = setTimeout(
|
|
17979
|
-
() => timer.abort(new KernelError("EPROTO", "ERR_TLS_HANDSHAKE_TIMEOUT: TLS handshake timeout")),
|
|
17980
|
-
ms
|
|
17981
|
-
);
|
|
18012
|
+
const id2 = setTimeout(() => timer.abort(timedOut), ms);
|
|
17982
18013
|
return {
|
|
17983
18014
|
signal: AbortSignal.any([handshakeAbort(proc), timer.signal]),
|
|
17984
18015
|
done: () => clearTimeout(id2)
|
|
@@ -18036,7 +18067,8 @@ async function serveSecure(proc, socket, req) {
|
|
|
18036
18067
|
const limit = handshakeSignal(proc, server.timeoutMs);
|
|
18037
18068
|
const info = await socket.secureLink(
|
|
18038
18069
|
(raw2) => tlsServer(raw2, engine.serverSession(leaf, alpn, store, flags2), flags2 !== 0),
|
|
18039
|
-
limit.signal
|
|
18070
|
+
limit.signal,
|
|
18071
|
+
(reason) => !shared && reason === timedOut
|
|
18040
18072
|
).finally(limit.done);
|
|
18041
18073
|
return {
|
|
18042
18074
|
path: "kernel",
|
|
@@ -31213,7 +31245,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS3 } = {})
|
|
|
31213
31245
|
deadline: () => AbortSignal.timeout(closeWaitMs).addEventListener("abort", late, { once: true })
|
|
31214
31246
|
};
|
|
31215
31247
|
credit.set(nid, flow);
|
|
31216
|
-
const
|
|
31248
|
+
const timedOut2 = { code: 1006, reason: "the far end did not answer the close" };
|
|
31217
31249
|
let oversize = false;
|
|
31218
31250
|
try {
|
|
31219
31251
|
const messages = socket.messages[Symbol.asyncIterator]();
|
|
@@ -31239,7 +31271,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS3 } = {})
|
|
|
31239
31271
|
}
|
|
31240
31272
|
}
|
|
31241
31273
|
if (oversize) socket.close(1e3, "a message is too big");
|
|
31242
|
-
ending = oversize ? { code: 1009, reason: `a message is over ${MESSAGE_LIMIT} bytes` } : await Promise.race([socket.closed, unanswered.then(() =>
|
|
31274
|
+
ending = oversize ? { code: 1009, reason: `a message is over ${MESSAGE_LIMIT} bytes` } : await Promise.race([socket.closed, unanswered.then(() => timedOut2)]);
|
|
31243
31275
|
} catch (e) {
|
|
31244
31276
|
socket.close(1e3, "the relay failed");
|
|
31245
31277
|
ending = { code: 1011, reason: e instanceof Error ? e.message : String(e) };
|