@ai-ecoverse/slicc-kernel 1.133.5 → 1.134.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 +7 -1
- package/dist/kernel-worker.js +286 -47
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +291 -52
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/kernel/net/sealed-pg.d.ts +27 -4
- package/dist/types/kernel/net/sealed-scram.d.ts +20 -0
- package/dist/types/kernel/sealed-session.d.ts +16 -3
- package/package.json +3 -3
|
@@ -6600,7 +6600,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
6600
6600
|
var init_version = __esm({
|
|
6601
6601
|
"src/version.ts"() {
|
|
6602
6602
|
"use strict";
|
|
6603
|
-
KERNEL_VERSION = true ? "1.
|
|
6603
|
+
KERNEL_VERSION = true ? "1.134.0" : "0.0.0-dev";
|
|
6604
6604
|
OS_RELEASE = "6.0.0-slicc";
|
|
6605
6605
|
}
|
|
6606
6606
|
});
|
package/dist/node.js
CHANGED
|
@@ -7464,7 +7464,7 @@ function satisfies(version, range2) {
|
|
|
7464
7464
|
}
|
|
7465
7465
|
|
|
7466
7466
|
// src/version.ts
|
|
7467
|
-
var KERNEL_VERSION = true ? "1.
|
|
7467
|
+
var KERNEL_VERSION = true ? "1.134.0" : "0.0.0-dev";
|
|
7468
7468
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7469
7469
|
function procVersion() {
|
|
7470
7470
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -14168,8 +14168,8 @@ var EventFd = class _EventFd {
|
|
|
14168
14168
|
count;
|
|
14169
14169
|
semaphore;
|
|
14170
14170
|
changes = new Notifier();
|
|
14171
|
-
constructor(
|
|
14172
|
-
this.count =
|
|
14171
|
+
constructor(initial2, semaphore) {
|
|
14172
|
+
this.count = initial2;
|
|
14173
14173
|
this.semaphore = semaphore;
|
|
14174
14174
|
}
|
|
14175
14175
|
async read(max, signal) {
|
|
@@ -17760,7 +17760,7 @@ var UNSAFE = /[\r\n\0]/;
|
|
|
17760
17760
|
var POSITIONS = {
|
|
17761
17761
|
http1: (position) => HEADER.test(position),
|
|
17762
17762
|
smtp: (position) => position === "auth-plain" || position === "auth-login",
|
|
17763
|
-
pg: (position) => position === "password-cleartext"
|
|
17763
|
+
pg: (position) => position === "password-cleartext" || position === "scram-sha-256"
|
|
17764
17764
|
};
|
|
17765
17765
|
function boundHost(servername) {
|
|
17766
17766
|
const lower = servername.toLowerCase();
|
|
@@ -17775,6 +17775,15 @@ function placeholdersOk(list) {
|
|
|
17775
17775
|
if (!Array.isArray(list) || list.length === 0 || list.length > SESSION_PLACEHOLDERS) return false;
|
|
17776
17776
|
return new Set(list).size === list.length && list.every((p) => typeof p === "string" && SESSION_PLACEHOLDER.test(p));
|
|
17777
17777
|
}
|
|
17778
|
+
var SCRAM_TEXT = /^[\x21-\x7e]{1,1024}$/;
|
|
17779
|
+
function scramOk(f) {
|
|
17780
|
+
if (f.position !== "scram-sha-256")
|
|
17781
|
+
return f.scram === void 0 && placeholdersOk(f.placeholders);
|
|
17782
|
+
const x = f.scram;
|
|
17783
|
+
if (f.placeholders !== void 0 || typeof x !== "object" || x === null) return false;
|
|
17784
|
+
const texts = [x.clientFirstBare, x.serverFirst, x.clientFinalBare, x.proof];
|
|
17785
|
+
return texts.every((t) => typeof t === "string" && SCRAM_TEXT.test(t));
|
|
17786
|
+
}
|
|
17778
17787
|
function hostOk(host) {
|
|
17779
17788
|
return typeof host === "string" && HOST.test(host) && boundHost(host) === host;
|
|
17780
17789
|
}
|
|
@@ -17786,7 +17795,7 @@ function sessionAskable(f, now) {
|
|
|
17786
17795
|
if (!Number.isInteger(f.port) || f.port < 1 || f.port > 65535) return false;
|
|
17787
17796
|
const age = now - f.handshakeAt;
|
|
17788
17797
|
if (!Number.isFinite(age) || age < 0 || age > SESSION_WINDOW_MS) return false;
|
|
17789
|
-
return typeof f.exit === "string" && SESSION_EXIT.test(f.exit) &&
|
|
17798
|
+
return typeof f.exit === "string" && SESSION_EXIT.test(f.exit) && scramOk(f) && headOk(f);
|
|
17790
17799
|
}
|
|
17791
17800
|
function sessionRequest(f) {
|
|
17792
17801
|
return {
|
|
@@ -17802,8 +17811,16 @@ function sessionRequest(f) {
|
|
|
17802
17811
|
verified: true,
|
|
17803
17812
|
handshakeAt: f.handshakeAt,
|
|
17804
17813
|
exit: f.exit,
|
|
17805
|
-
placeholders: [...f.placeholders],
|
|
17806
|
-
...f.head ? { head: { method: f.head.method, path: f.head.path } } : {}
|
|
17814
|
+
...f.placeholders ? { placeholders: [...f.placeholders] } : {},
|
|
17815
|
+
...f.head ? { head: { method: f.head.method, path: f.head.path } } : {},
|
|
17816
|
+
...f.scram ? {
|
|
17817
|
+
scram: {
|
|
17818
|
+
clientFirstBare: f.scram.clientFirstBare,
|
|
17819
|
+
serverFirst: f.scram.serverFirst,
|
|
17820
|
+
clientFinalBare: f.scram.clientFinalBare,
|
|
17821
|
+
proof: f.scram.proof
|
|
17822
|
+
}
|
|
17823
|
+
} : {}
|
|
17807
17824
|
};
|
|
17808
17825
|
}
|
|
17809
17826
|
function sessionValues(reply, asked) {
|
|
@@ -17811,7 +17828,9 @@ function sessionValues(reply, asked) {
|
|
|
17811
17828
|
const { error, values } = reply;
|
|
17812
17829
|
if (error !== void 0 || typeof values !== "object" || values === null) return void 0;
|
|
17813
17830
|
const out = {};
|
|
17814
|
-
|
|
17831
|
+
const keys = Object.keys(values);
|
|
17832
|
+
const wanted = asked ?? (keys.length === 1 && SESSION_PLACEHOLDER.test(keys[0]) ? keys : []);
|
|
17833
|
+
for (const ph of wanted) {
|
|
17815
17834
|
const value2 = values[ph];
|
|
17816
17835
|
if (typeof value2 === "string" && value2.length > 0 && !UNSAFE.test(value2)) out[ph] = value2;
|
|
17817
17836
|
}
|
|
@@ -18503,6 +18522,104 @@ async function substituteHead(head, ask) {
|
|
|
18503
18522
|
`, values };
|
|
18504
18523
|
}
|
|
18505
18524
|
|
|
18525
|
+
// src/kernel/net/sealed-scram.ts
|
|
18526
|
+
var encoder8 = new TextEncoder();
|
|
18527
|
+
function base64Bytes(text) {
|
|
18528
|
+
try {
|
|
18529
|
+
return Uint8Array.from(atob(text), (c) => c.charCodeAt(0));
|
|
18530
|
+
} catch {
|
|
18531
|
+
return void 0;
|
|
18532
|
+
}
|
|
18533
|
+
}
|
|
18534
|
+
function base64Of(bytes) {
|
|
18535
|
+
let bin = "";
|
|
18536
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
18537
|
+
return btoa(bin);
|
|
18538
|
+
}
|
|
18539
|
+
function clientFirstBare(message3) {
|
|
18540
|
+
const m = /^n,,(n=[^,]*,r=[^,]+)$/.exec(message3);
|
|
18541
|
+
return m ? m[1] : void 0;
|
|
18542
|
+
}
|
|
18543
|
+
var SERVER_FIRST = /^r=([^,]+),s=([^,]+),i=(\d{1,6})$/;
|
|
18544
|
+
var CLIENT_FINAL = /^(c=biws,r=([^,]+)),p=([^,]+)$/;
|
|
18545
|
+
var SCRAM_MAX = 1024;
|
|
18546
|
+
function exchangeOf(clientFirst, serverFirst, clientFinal) {
|
|
18547
|
+
const bare = clientFirstBare(clientFirst);
|
|
18548
|
+
const sf = SERVER_FIRST.exec(serverFirst);
|
|
18549
|
+
const fin = CLIENT_FINAL.exec(clientFinal);
|
|
18550
|
+
if (!bare || !sf || !fin || [bare, serverFirst, clientFinal].some((t) => t.length > SCRAM_MAX))
|
|
18551
|
+
return void 0;
|
|
18552
|
+
const cnonce = bare.slice(bare.indexOf(",r=") + 3);
|
|
18553
|
+
const nonce = sf[1];
|
|
18554
|
+
const salt = base64Bytes(sf[2]);
|
|
18555
|
+
const iterations = Number(sf[3]);
|
|
18556
|
+
const proof = base64Bytes(fin[3]);
|
|
18557
|
+
const ok4 = fin[2] === nonce && nonce.startsWith(cnonce) && iterations >= 1 && iterations <= 1e5 && salt !== void 0 && proof?.length === 32;
|
|
18558
|
+
if (!ok4) return void 0;
|
|
18559
|
+
return {
|
|
18560
|
+
exchange: {
|
|
18561
|
+
clientFirstBare: bare,
|
|
18562
|
+
serverFirst,
|
|
18563
|
+
clientFinalBare: fin[1],
|
|
18564
|
+
salt,
|
|
18565
|
+
iterations
|
|
18566
|
+
},
|
|
18567
|
+
proof
|
|
18568
|
+
};
|
|
18569
|
+
}
|
|
18570
|
+
async function hmac(key, data) {
|
|
18571
|
+
const k = await crypto.subtle.importKey(
|
|
18572
|
+
"raw",
|
|
18573
|
+
key,
|
|
18574
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
18575
|
+
false,
|
|
18576
|
+
["sign"]
|
|
18577
|
+
);
|
|
18578
|
+
return new Uint8Array(await crypto.subtle.sign("HMAC", k, data));
|
|
18579
|
+
}
|
|
18580
|
+
async function scramKeys(password, x) {
|
|
18581
|
+
const base = await crypto.subtle.importKey("raw", encoder8.encode(password), "PBKDF2", false, [
|
|
18582
|
+
"deriveBits"
|
|
18583
|
+
]);
|
|
18584
|
+
const salted = new Uint8Array(
|
|
18585
|
+
await crypto.subtle.deriveBits(
|
|
18586
|
+
{
|
|
18587
|
+
name: "PBKDF2",
|
|
18588
|
+
hash: "SHA-256",
|
|
18589
|
+
salt: x.salt,
|
|
18590
|
+
iterations: x.iterations
|
|
18591
|
+
},
|
|
18592
|
+
base,
|
|
18593
|
+
256
|
|
18594
|
+
)
|
|
18595
|
+
);
|
|
18596
|
+
const clientKey = await hmac(salted, encoder8.encode("Client Key"));
|
|
18597
|
+
const stored = new Uint8Array(
|
|
18598
|
+
await crypto.subtle.digest("SHA-256", clientKey)
|
|
18599
|
+
);
|
|
18600
|
+
const auth = encoder8.encode(`${x.clientFirstBare},${x.serverFirst},${x.clientFinalBare}`);
|
|
18601
|
+
const signature = await hmac(stored, auth);
|
|
18602
|
+
const proof = clientKey.map((b, i) => b ^ signature[i]);
|
|
18603
|
+
const serverKey = await hmac(salted, encoder8.encode("Server Key"));
|
|
18604
|
+
const serverSignature = await hmac(serverKey, auth);
|
|
18605
|
+
for (const k of [salted, clientKey, stored, signature, serverKey]) k.fill(0);
|
|
18606
|
+
return { proof, serverSignature };
|
|
18607
|
+
}
|
|
18608
|
+
var SPACES = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
|
|
18609
|
+
var NOTHING2 = /\u00AD|\u034F|\u1806|[\u180B-\u180D]|\u200C|\u200D|\u2060|[\uFE00-\uFE0F]|\uFEFF/g;
|
|
18610
|
+
var PROHIBITED = /[\u0000-\u001F\u007F-\u009F\uE000-\uF8FF\uFFFE\uFFFF]/;
|
|
18611
|
+
function saslprep(password) {
|
|
18612
|
+
if (/^[\x20-\x7e]*$/.test(password)) return password;
|
|
18613
|
+
const mapped = password.replace(SPACES, " ").replace(NOTHING2, "").normalize("NFKC");
|
|
18614
|
+
return PROHIBITED.test(mapped) ? password : mapped;
|
|
18615
|
+
}
|
|
18616
|
+
function sameBytes(a, b) {
|
|
18617
|
+
if (a.length !== b.length) return false;
|
|
18618
|
+
let d = 0;
|
|
18619
|
+
for (let i = 0; i < a.length; i++) d |= a[i] ^ b[i];
|
|
18620
|
+
return d === 0;
|
|
18621
|
+
}
|
|
18622
|
+
|
|
18506
18623
|
// src/kernel/net/sealed-pg.ts
|
|
18507
18624
|
var PG_MESSAGE_MAX = 16 * 1024;
|
|
18508
18625
|
var PROTOCOL_3 = 196608;
|
|
@@ -18517,44 +18634,101 @@ function sniffPg(start2) {
|
|
|
18517
18634
|
const length2 = int32(bytes, 0);
|
|
18518
18635
|
return length2 >= 8 && length2 <= PG_MESSAGE_MAX && int32(bytes, 4) === PROTOCOL_3 ? "yes" : "no";
|
|
18519
18636
|
}
|
|
18637
|
+
var PLUS = "SCRAM-SHA-256-PLUS";
|
|
18638
|
+
var SASL = 10;
|
|
18639
|
+
var SASL_CONTINUE = 11;
|
|
18640
|
+
var SASL_FINAL = 12;
|
|
18641
|
+
function latin(bytes) {
|
|
18642
|
+
let out = "";
|
|
18643
|
+
for (const b of bytes) out += String.fromCharCode(b);
|
|
18644
|
+
return out;
|
|
18645
|
+
}
|
|
18520
18646
|
var PgServer = class {
|
|
18521
18647
|
buffer = new Uint8Array(0);
|
|
18522
18648
|
skip = 0;
|
|
18523
|
-
lost = false;
|
|
18524
18649
|
cleartext = false;
|
|
18525
|
-
|
|
18526
|
-
|
|
18650
|
+
sasl = false;
|
|
18651
|
+
serverFirst;
|
|
18652
|
+
expect;
|
|
18653
|
+
failed = false;
|
|
18654
|
+
lost = false;
|
|
18655
|
+
auth(message3) {
|
|
18656
|
+
const code = message3.length >= 9 ? int32(message3, 5) : -1;
|
|
18657
|
+
if (this.expect && code !== SASL_FINAL) this.failed = true;
|
|
18658
|
+
this.cleartext = message3.length === 9 && code === CLEARTEXT;
|
|
18659
|
+
if (code === SASL) return this.mechanisms(message3);
|
|
18660
|
+
else if (code === SASL_CONTINUE) this.serverFirst = latin(message3.subarray(9));
|
|
18661
|
+
else if (code === SASL_FINAL) this.final(message3);
|
|
18662
|
+
return message3;
|
|
18663
|
+
}
|
|
18664
|
+
mechanisms(message3) {
|
|
18665
|
+
this.sasl = true;
|
|
18666
|
+
const names2 = latin(message3.subarray(9)).split("\0").filter((n) => n !== "" && n !== PLUS);
|
|
18667
|
+
return frame3(82, `${latin(message3.subarray(5, 9))}${names2.map((n) => `${n}\0`).join("")}\0`);
|
|
18668
|
+
}
|
|
18669
|
+
final(message3) {
|
|
18670
|
+
const expect = this.expect;
|
|
18671
|
+
if (!expect) return;
|
|
18672
|
+
this.expect = void 0;
|
|
18673
|
+
const data = latin(message3.subarray(9));
|
|
18674
|
+
if (data !== expect.real || expect.fake.length !== expect.real.length) {
|
|
18675
|
+
this.failed = true;
|
|
18676
|
+
return;
|
|
18677
|
+
}
|
|
18678
|
+
for (let i = 0; i < expect.fake.length; i++) message3[9 + i] = expect.fake.charCodeAt(i);
|
|
18679
|
+
}
|
|
18680
|
+
lose() {
|
|
18681
|
+
this.lost = true;
|
|
18682
|
+
this.cleartext = false;
|
|
18683
|
+
this.sasl = false;
|
|
18684
|
+
if (this.expect) this.failed = true;
|
|
18685
|
+
this.expect = void 0;
|
|
18686
|
+
}
|
|
18687
|
+
filter(bytes) {
|
|
18688
|
+
if (this.lost) return bytes;
|
|
18527
18689
|
const data = new Uint8Array(this.buffer.length + bytes.length);
|
|
18528
18690
|
data.set(this.buffer);
|
|
18529
18691
|
data.set(bytes, this.buffer.length);
|
|
18692
|
+
const out = [];
|
|
18530
18693
|
let at = 0;
|
|
18531
18694
|
for (; ; ) {
|
|
18532
18695
|
const left = data.length - at;
|
|
18533
18696
|
if (this.skip > 0) {
|
|
18534
18697
|
const n = Math.min(this.skip, left);
|
|
18698
|
+
out.push(data.subarray(at, at + n));
|
|
18535
18699
|
this.skip -= n;
|
|
18536
18700
|
at += n;
|
|
18537
18701
|
if (this.skip > 0) break;
|
|
18538
18702
|
continue;
|
|
18539
18703
|
}
|
|
18540
18704
|
if (left < 5) break;
|
|
18541
|
-
const type = data[at];
|
|
18542
18705
|
const whole = 1 + int32(data, at + 1);
|
|
18543
|
-
if (whole < 5 ||
|
|
18544
|
-
this.
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18706
|
+
if (whole < 5 || data[at] === 82 && whole > PG_MESSAGE_MAX) {
|
|
18707
|
+
this.lose();
|
|
18708
|
+
out.push(data.subarray(at));
|
|
18709
|
+
at = data.length;
|
|
18710
|
+
break;
|
|
18548
18711
|
}
|
|
18549
|
-
if (
|
|
18712
|
+
if (data[at] !== 82) {
|
|
18713
|
+
if (this.expect) {
|
|
18714
|
+
this.failed = true;
|
|
18715
|
+
break;
|
|
18716
|
+
}
|
|
18550
18717
|
this.skip = whole;
|
|
18551
18718
|
continue;
|
|
18552
18719
|
}
|
|
18553
18720
|
if (left < whole) break;
|
|
18554
|
-
this.
|
|
18721
|
+
out.push(this.auth(data.slice(at, at + whole)));
|
|
18555
18722
|
at += whole;
|
|
18556
18723
|
}
|
|
18557
18724
|
this.buffer = data.slice(at);
|
|
18725
|
+
const joined4 = new Uint8Array(out.reduce((n, b) => n + b.length, 0));
|
|
18726
|
+
let to = 0;
|
|
18727
|
+
for (const b of out) {
|
|
18728
|
+
joined4.set(b, to);
|
|
18729
|
+
to += b.length;
|
|
18730
|
+
}
|
|
18731
|
+
return joined4;
|
|
18558
18732
|
}
|
|
18559
18733
|
};
|
|
18560
18734
|
function frame3(type, body) {
|
|
@@ -18571,21 +18745,76 @@ function pgLength(bytes, started) {
|
|
|
18571
18745
|
const length2 = int32(bytes, started ? 1 : 0);
|
|
18572
18746
|
return started ? 1 + length2 : length2;
|
|
18573
18747
|
}
|
|
18574
|
-
|
|
18575
|
-
|
|
18576
|
-
|
|
18577
|
-
let body = "";
|
|
18578
|
-
for (const b of message3.subarray(5)) body += String.fromCharCode(b);
|
|
18748
|
+
var MECHANISMS = /* @__PURE__ */ new Set(["SCRAM-SHA-256"]);
|
|
18749
|
+
async function cleartext(message3, asks) {
|
|
18750
|
+
const body = latin(message3.subarray(5));
|
|
18579
18751
|
if (!body.endsWith("\0") || body.indexOf("\0") !== body.length - 1)
|
|
18580
18752
|
return { bytes: message3, done: true };
|
|
18581
18753
|
const password = body.slice(0, -1);
|
|
18582
18754
|
const placeholders = placeholdersIn(password);
|
|
18583
18755
|
if (placeholders.length === 0 || placeholders.length > SESSION_PLACEHOLDERS)
|
|
18584
18756
|
return { bytes: message3, done: true };
|
|
18585
|
-
const values = usable(await
|
|
18757
|
+
const values = usable(await asks.cleartext(placeholders));
|
|
18586
18758
|
if (Object.keys(values).length === 0) return { bytes: message3, done: true };
|
|
18587
18759
|
return { bytes: frame3(112, `${replaced(password, values)}\0`), values, done: true };
|
|
18588
18760
|
}
|
|
18761
|
+
function initial(message3) {
|
|
18762
|
+
const body = latin(message3.subarray(5));
|
|
18763
|
+
const nul = body.indexOf("\0");
|
|
18764
|
+
if (nul < 0 || !MECHANISMS.has(body.slice(0, nul)) || body.length < nul + 5) return void 0;
|
|
18765
|
+
const data = message3.subarray(5 + nul + 5);
|
|
18766
|
+
return int32(message3, 5 + nul + 1) === data.length ? latin(data) : void 0;
|
|
18767
|
+
}
|
|
18768
|
+
var PgClient = class {
|
|
18769
|
+
clientFirst;
|
|
18770
|
+
server;
|
|
18771
|
+
asks;
|
|
18772
|
+
constructor(server, asks) {
|
|
18773
|
+
this.server = server;
|
|
18774
|
+
this.asks = asks;
|
|
18775
|
+
}
|
|
18776
|
+
async message(message3) {
|
|
18777
|
+
const server = this.server;
|
|
18778
|
+
if (message3[0] !== 112) return { bytes: message3, done: true };
|
|
18779
|
+
if (server.cleartext) {
|
|
18780
|
+
server.cleartext = false;
|
|
18781
|
+
return cleartext(message3, this.asks);
|
|
18782
|
+
}
|
|
18783
|
+
if (server.sasl && this.clientFirst === void 0) {
|
|
18784
|
+
this.clientFirst = initial(message3);
|
|
18785
|
+
return { bytes: message3, done: this.clientFirst === void 0 };
|
|
18786
|
+
}
|
|
18787
|
+
if (this.clientFirst !== void 0 && server.serverFirst !== void 0)
|
|
18788
|
+
return this.final(message3, this.clientFirst, server.serverFirst);
|
|
18789
|
+
return { bytes: message3, done: true };
|
|
18790
|
+
}
|
|
18791
|
+
async final(message3, first, serverFirst) {
|
|
18792
|
+
const got = exchangeOf(first, serverFirst, latin(message3.subarray(5)));
|
|
18793
|
+
if (!got) return { bytes: message3, done: true };
|
|
18794
|
+
const x = got.exchange;
|
|
18795
|
+
const values = usable(
|
|
18796
|
+
await this.asks.scram({
|
|
18797
|
+
clientFirstBare: x.clientFirstBare,
|
|
18798
|
+
serverFirst: x.serverFirst,
|
|
18799
|
+
clientFinalBare: x.clientFinalBare,
|
|
18800
|
+
proof: base64Of(got.proof)
|
|
18801
|
+
})
|
|
18802
|
+
);
|
|
18803
|
+
const [entry, ...more] = Object.entries(values);
|
|
18804
|
+
if (!entry || more.length > 0) return { bytes: message3, done: true };
|
|
18805
|
+
const [placeholder, value2] = entry;
|
|
18806
|
+
const fake = await scramKeys(placeholder, x);
|
|
18807
|
+
if (!sameBytes(fake.proof, got.proof)) return { bytes: message3, done: true };
|
|
18808
|
+
const real = await scramKeys(saslprep(value2), x);
|
|
18809
|
+
this.server.expect = {
|
|
18810
|
+
real: `v=${base64Of(real.serverSignature)}`,
|
|
18811
|
+
fake: `v=${base64Of(fake.serverSignature)}`
|
|
18812
|
+
};
|
|
18813
|
+
const bytes = frame3(112, `${x.clientFinalBare},p=${base64Of(real.proof)}`);
|
|
18814
|
+
for (const k of [real.proof, real.serverSignature, fake.proof, fake.serverSignature]) k.fill(0);
|
|
18815
|
+
return { bytes, values, done: true };
|
|
18816
|
+
}
|
|
18817
|
+
};
|
|
18589
18818
|
|
|
18590
18819
|
// src/kernel/net/sealed-smtp.ts
|
|
18591
18820
|
var SMTP_LINE_MAX = 4096;
|
|
@@ -18730,17 +18959,21 @@ var SessionWriter = class {
|
|
|
18730
18959
|
session = sessionId();
|
|
18731
18960
|
smtp;
|
|
18732
18961
|
pgStarted = false;
|
|
18962
|
+
sawPg = false;
|
|
18733
18963
|
conn;
|
|
18734
18964
|
s;
|
|
18735
|
-
|
|
18965
|
+
pgClient;
|
|
18736
18966
|
scope;
|
|
18737
18967
|
constructor(conn, s, pg, scope) {
|
|
18738
18968
|
this.conn = conn;
|
|
18739
18969
|
this.s = s;
|
|
18740
|
-
this.pg = pg;
|
|
18741
18970
|
this.scope = scope;
|
|
18971
|
+
this.pgClient = new PgClient(pg, {
|
|
18972
|
+
cleartext: (placeholders) => this.ask("pg", "password-cleartext", { placeholders }),
|
|
18973
|
+
scram: (scram) => this.ask("pg", "scram-sha-256", { scram })
|
|
18974
|
+
});
|
|
18742
18975
|
this.smtp = new SmtpClient(
|
|
18743
|
-
(position, placeholders) => this.ask("smtp", position, placeholders)
|
|
18976
|
+
(position, placeholders) => this.ask("smtp", position, { placeholders })
|
|
18744
18977
|
);
|
|
18745
18978
|
}
|
|
18746
18979
|
write(bytes) {
|
|
@@ -18751,7 +18984,7 @@ var SessionWriter = class {
|
|
|
18751
18984
|
);
|
|
18752
18985
|
return run2;
|
|
18753
18986
|
}
|
|
18754
|
-
async ask(protocol, position,
|
|
18987
|
+
async ask(protocol, position, extra) {
|
|
18755
18988
|
const s = this.s;
|
|
18756
18989
|
const values = await s.broker.sessionMaterialize({
|
|
18757
18990
|
stamp: await s.stamp(),
|
|
@@ -18763,8 +18996,7 @@ var SessionWriter = class {
|
|
|
18763
18996
|
verified: s.verified,
|
|
18764
18997
|
handshakeAt: s.handshakeAt,
|
|
18765
18998
|
exit: s.exit,
|
|
18766
|
-
|
|
18767
|
-
...head ? { head } : {}
|
|
18999
|
+
...extra
|
|
18768
19000
|
});
|
|
18769
19001
|
return values;
|
|
18770
19002
|
}
|
|
@@ -18783,6 +19015,7 @@ var SessionWriter = class {
|
|
|
18783
19015
|
this.buffer.fill(0);
|
|
18784
19016
|
this.buffer = joined4;
|
|
18785
19017
|
if (this.mode === "sniff") this.mode = modeOf(latin12(joined4.subarray(0, 8))) ?? "sniff";
|
|
19018
|
+
if (this.mode === "pg") this.sawPg = true;
|
|
18786
19019
|
if (this.mode === "pass") await this.release();
|
|
18787
19020
|
else if (this.mode === "http1") await this.http1();
|
|
18788
19021
|
else if (this.mode === "smtp") await this.lines();
|
|
@@ -18829,11 +19062,7 @@ var SessionWriter = class {
|
|
|
18829
19062
|
this.buffer = this.buffer.slice(whole);
|
|
18830
19063
|
const started = this.pgStarted;
|
|
18831
19064
|
this.pgStarted = true;
|
|
18832
|
-
const out = started ? await
|
|
18833
|
-
message3,
|
|
18834
|
-
this.pg,
|
|
18835
|
-
(placeholders) => this.ask("pg", "password-cleartext", placeholders)
|
|
18836
|
-
).catch(() => ({ bytes: message3, done: true })) : { bytes: message3, done: false };
|
|
19065
|
+
const out = started ? await this.pgClient.message(message3).catch(() => ({ bytes: message3, done: true })) : { bytes: message3, done: false };
|
|
18837
19066
|
if ("values" in out && out.values) this.remember(out.values);
|
|
18838
19067
|
try {
|
|
18839
19068
|
await writeAll4(this.conn, out.bytes);
|
|
@@ -18865,7 +19094,7 @@ var SessionWriter = class {
|
|
|
18865
19094
|
this.buffer = new Uint8Array(0);
|
|
18866
19095
|
const done4 = await substituteHead(
|
|
18867
19096
|
latin12(all.subarray(0, end)),
|
|
18868
|
-
(position, placeholders, head2) => this.ask("http1", position, placeholders, head2)
|
|
19097
|
+
(position, placeholders, head2) => this.ask("http1", position, { placeholders, head: head2 })
|
|
18869
19098
|
).catch(() => void 0);
|
|
18870
19099
|
const head = done4 ? bytesOf(done4.head) : all.subarray(0, end);
|
|
18871
19100
|
if (done4) this.remember(done4.values);
|
|
@@ -18963,9 +19192,19 @@ function sealedConn(conn, s) {
|
|
|
18963
19192
|
const observed = {
|
|
18964
19193
|
...conn,
|
|
18965
19194
|
read: async () => {
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
19195
|
+
for (; ; ) {
|
|
19196
|
+
const bytes = await conn.read();
|
|
19197
|
+
if (!bytes) return bytes;
|
|
19198
|
+
const out = writer?.sawPg ? pg.filter(bytes) : bytes;
|
|
19199
|
+
if (pg.failed) {
|
|
19200
|
+
conn.close();
|
|
19201
|
+
throw new KernelError(
|
|
19202
|
+
"EPROTO",
|
|
19203
|
+
"ERR_SSL_PROTOCOL_ERROR: the pg server failed the SCRAM proof"
|
|
19204
|
+
);
|
|
19205
|
+
}
|
|
19206
|
+
if (out.length > 0) return out;
|
|
19207
|
+
}
|
|
18969
19208
|
}
|
|
18970
19209
|
};
|
|
18971
19210
|
const reader = new ScrubReader(writer ? observed : conn, scope);
|
|
@@ -24045,7 +24284,7 @@ var SEALED_OPS = /* @__PURE__ */ new Set([
|
|
|
24045
24284
|
"cancel",
|
|
24046
24285
|
"materialize"
|
|
24047
24286
|
]);
|
|
24048
|
-
var
|
|
24287
|
+
var encoder9 = new TextEncoder();
|
|
24049
24288
|
var decoder3 = new TextDecoder("utf-8", { fatal: true });
|
|
24050
24289
|
function parseSealed(bytes) {
|
|
24051
24290
|
try {
|
|
@@ -24126,7 +24365,7 @@ var SealedChannel = class {
|
|
|
24126
24365
|
await this.broker.tickets.record(req, reply, caller.pid);
|
|
24127
24366
|
if (this.inflight !== flight) return;
|
|
24128
24367
|
this.inflight = void 0;
|
|
24129
|
-
if (reply) this.reply =
|
|
24368
|
+
if (reply) this.reply = encoder9.encode(serialized(reply));
|
|
24130
24369
|
});
|
|
24131
24370
|
this.inflight = flight;
|
|
24132
24371
|
return length2;
|
|
@@ -25934,9 +26173,9 @@ function importedMemory(bytes) {
|
|
|
25934
26173
|
};
|
|
25935
26174
|
const limits = () => {
|
|
25936
26175
|
const flags2 = bytes[at++];
|
|
25937
|
-
const
|
|
26176
|
+
const initial2 = u32();
|
|
25938
26177
|
const maximum = flags2 & 1 ? u32() : void 0;
|
|
25939
|
-
return { initial, maximum, shared: (flags2 & 2) !== 0 };
|
|
26178
|
+
return { initial: initial2, maximum, shared: (flags2 & 2) !== 0 };
|
|
25940
26179
|
};
|
|
25941
26180
|
while (at < bytes.length) {
|
|
25942
26181
|
const id2 = bytes[at++];
|
|
@@ -26577,7 +26816,7 @@ var LAYOUT = [
|
|
|
26577
26816
|
var IN_TREE = /* @__PURE__ */ new Set([SUDO_PATH, CRONTAB_PATH]);
|
|
26578
26817
|
var LOAD_SAMPLE_MS = 5e3;
|
|
26579
26818
|
var LOAD_WINDOWS_MS = [6e4, 3e5, 9e5];
|
|
26580
|
-
var
|
|
26819
|
+
var encoder10 = new TextEncoder();
|
|
26581
26820
|
var USERS_MODES = ["off", "report", "enforce"];
|
|
26582
26821
|
function usersMode(mode = "off") {
|
|
26583
26822
|
if (USERS_MODES.includes(mode)) return mode;
|
|
@@ -28852,7 +29091,7 @@ var Launcher = class {
|
|
|
28852
29091
|
},
|
|
28853
29092
|
account
|
|
28854
29093
|
);
|
|
28855
|
-
const report = (message3) => options.onData(
|
|
29094
|
+
const report = (message3) => options.onData(encoder10.encode(`${message3}\r
|
|
28856
29095
|
`));
|
|
28857
29096
|
const handle = await this.launch(planned, {
|
|
28858
29097
|
env,
|
|
@@ -28890,7 +29129,7 @@ var Launcher = class {
|
|
|
28890
29129
|
};
|
|
28891
29130
|
const stdout = collect(out, options.onStdout);
|
|
28892
29131
|
const stderr = collect(err, options.onStderr);
|
|
28893
|
-
const report = (message3) => stderr(
|
|
29132
|
+
const report = (message3) => stderr(encoder10.encode(`${message3}
|
|
28894
29133
|
`));
|
|
28895
29134
|
if (!planned) {
|
|
28896
29135
|
const directory = await this.directory(file, this.fs.resolvePath(cwd, file));
|
|
@@ -29694,7 +29933,7 @@ function dialStream(port, onClose) {
|
|
|
29694
29933
|
|
|
29695
29934
|
// src/client/loopback-fetch.ts
|
|
29696
29935
|
var OWN_HEADERS2 = /* @__PURE__ */ new Set(["host", "connection", "content-length", "transfer-encoding"]);
|
|
29697
|
-
var
|
|
29936
|
+
var encoder11 = new TextEncoder();
|
|
29698
29937
|
var latin13 = new TextDecoder("latin1");
|
|
29699
29938
|
var ByteSource = class {
|
|
29700
29939
|
buffered = new Uint8Array(0);
|
|
@@ -29712,7 +29951,7 @@ var ByteSource = class {
|
|
|
29712
29951
|
return true;
|
|
29713
29952
|
}
|
|
29714
29953
|
async until(marker) {
|
|
29715
|
-
const needle =
|
|
29954
|
+
const needle = encoder11.encode(marker);
|
|
29716
29955
|
for (; ; ) {
|
|
29717
29956
|
const at = indexOf(this.buffered, needle);
|
|
29718
29957
|
if (at >= 0) return this.take(at + needle.length);
|
|
@@ -29820,7 +30059,7 @@ async function requestBytes(request) {
|
|
|
29820
30059
|
});
|
|
29821
30060
|
if (body) lines2.push(`Content-Length: ${body.length}`);
|
|
29822
30061
|
lines2.push("Connection: close", "", "");
|
|
29823
|
-
const head =
|
|
30062
|
+
const head = encoder11.encode(lines2.join("\r\n"));
|
|
29824
30063
|
const out = new Uint8Array(head.length + (body?.length ?? 0));
|
|
29825
30064
|
out.set(head);
|
|
29826
30065
|
if (body) out.set(body, head.length);
|
|
@@ -29874,8 +30113,8 @@ var KernelCallError = class extends Error {
|
|
|
29874
30113
|
this.code = code;
|
|
29875
30114
|
}
|
|
29876
30115
|
};
|
|
29877
|
-
var
|
|
29878
|
-
var bytesOf3 = (data) => typeof data === "string" ?
|
|
30116
|
+
var encoder12 = new TextEncoder();
|
|
30117
|
+
var bytesOf3 = (data) => typeof data === "string" ? encoder12.encode(data) : data;
|
|
29879
30118
|
var UNAVAILABLE = {
|
|
29880
30119
|
manualRedirects: false,
|
|
29881
30120
|
encodedBodies: false,
|