@ai-ecoverse/slicc-kernel 1.133.5 → 1.134.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/dist/node.js CHANGED
@@ -5827,15 +5827,21 @@ var OpfsFs = class {
5827
5827
  let writable2;
5828
5828
  let handle;
5829
5829
  try {
5830
- const [made2, existed, at] = await this.fileFor(destination);
5831
- handle = made2;
5832
- target = at;
5833
- if (!existed && !created4) {
5834
- created4 = true;
5835
- await this.stampNew(target, options.owner, false);
5830
+ const kept = created4 ? this.files.get(destination) : void 0;
5831
+ if (kept) {
5832
+ if (options.owner?.fifo || options.owner?.socket) throw fsError("ENXIO", to);
5833
+ handle = kept;
5834
+ } else {
5835
+ const [made2, existed, at] = await this.fileFor(destination);
5836
+ handle = made2;
5837
+ target = at;
5838
+ if (!existed && !created4) {
5839
+ created4 = true;
5840
+ await this.stampNew(target, options.owner, false);
5841
+ }
5842
+ const [entry] = await this.meta.get([target]);
5843
+ if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
5836
5844
  }
5837
- const [entry] = await this.meta.get([target]);
5838
- if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
5839
5845
  this.wrote(handle);
5840
5846
  writable2 = await handle.createWritable();
5841
5847
  await writable2.write(file);
@@ -7464,7 +7470,7 @@ function satisfies(version, range2) {
7464
7470
  }
7465
7471
 
7466
7472
  // src/version.ts
7467
- var KERNEL_VERSION = true ? "1.133.5" : "0.0.0-dev";
7473
+ var KERNEL_VERSION = true ? "1.134.1" : "0.0.0-dev";
7468
7474
  var OS_RELEASE = "6.0.0-slicc";
7469
7475
  function procVersion() {
7470
7476
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14168,8 +14174,8 @@ var EventFd = class _EventFd {
14168
14174
  count;
14169
14175
  semaphore;
14170
14176
  changes = new Notifier();
14171
- constructor(initial, semaphore) {
14172
- this.count = initial;
14177
+ constructor(initial2, semaphore) {
14178
+ this.count = initial2;
14173
14179
  this.semaphore = semaphore;
14174
14180
  }
14175
14181
  async read(max, signal) {
@@ -17760,7 +17766,7 @@ var UNSAFE = /[\r\n\0]/;
17760
17766
  var POSITIONS = {
17761
17767
  http1: (position) => HEADER.test(position),
17762
17768
  smtp: (position) => position === "auth-plain" || position === "auth-login",
17763
- pg: (position) => position === "password-cleartext"
17769
+ pg: (position) => position === "password-cleartext" || position === "scram-sha-256"
17764
17770
  };
17765
17771
  function boundHost(servername) {
17766
17772
  const lower = servername.toLowerCase();
@@ -17775,6 +17781,15 @@ function placeholdersOk(list) {
17775
17781
  if (!Array.isArray(list) || list.length === 0 || list.length > SESSION_PLACEHOLDERS) return false;
17776
17782
  return new Set(list).size === list.length && list.every((p) => typeof p === "string" && SESSION_PLACEHOLDER.test(p));
17777
17783
  }
17784
+ var SCRAM_TEXT = /^[\x21-\x7e]{1,1024}$/;
17785
+ function scramOk(f) {
17786
+ if (f.position !== "scram-sha-256")
17787
+ return f.scram === void 0 && placeholdersOk(f.placeholders);
17788
+ const x = f.scram;
17789
+ if (f.placeholders !== void 0 || typeof x !== "object" || x === null) return false;
17790
+ const texts = [x.clientFirstBare, x.serverFirst, x.clientFinalBare, x.proof];
17791
+ return texts.every((t) => typeof t === "string" && SCRAM_TEXT.test(t));
17792
+ }
17778
17793
  function hostOk(host) {
17779
17794
  return typeof host === "string" && HOST.test(host) && boundHost(host) === host;
17780
17795
  }
@@ -17786,7 +17801,7 @@ function sessionAskable(f, now) {
17786
17801
  if (!Number.isInteger(f.port) || f.port < 1 || f.port > 65535) return false;
17787
17802
  const age = now - f.handshakeAt;
17788
17803
  if (!Number.isFinite(age) || age < 0 || age > SESSION_WINDOW_MS) return false;
17789
- return typeof f.exit === "string" && SESSION_EXIT.test(f.exit) && placeholdersOk(f.placeholders) && headOk(f);
17804
+ return typeof f.exit === "string" && SESSION_EXIT.test(f.exit) && scramOk(f) && headOk(f);
17790
17805
  }
17791
17806
  function sessionRequest(f) {
17792
17807
  return {
@@ -17802,8 +17817,16 @@ function sessionRequest(f) {
17802
17817
  verified: true,
17803
17818
  handshakeAt: f.handshakeAt,
17804
17819
  exit: f.exit,
17805
- placeholders: [...f.placeholders],
17806
- ...f.head ? { head: { method: f.head.method, path: f.head.path } } : {}
17820
+ ...f.placeholders ? { placeholders: [...f.placeholders] } : {},
17821
+ ...f.head ? { head: { method: f.head.method, path: f.head.path } } : {},
17822
+ ...f.scram ? {
17823
+ scram: {
17824
+ clientFirstBare: f.scram.clientFirstBare,
17825
+ serverFirst: f.scram.serverFirst,
17826
+ clientFinalBare: f.scram.clientFinalBare,
17827
+ proof: f.scram.proof
17828
+ }
17829
+ } : {}
17807
17830
  };
17808
17831
  }
17809
17832
  function sessionValues(reply, asked) {
@@ -17811,7 +17834,9 @@ function sessionValues(reply, asked) {
17811
17834
  const { error, values } = reply;
17812
17835
  if (error !== void 0 || typeof values !== "object" || values === null) return void 0;
17813
17836
  const out = {};
17814
- for (const ph of asked) {
17837
+ const keys = Object.keys(values);
17838
+ const wanted = asked ?? (keys.length === 1 && SESSION_PLACEHOLDER.test(keys[0]) ? keys : []);
17839
+ for (const ph of wanted) {
17815
17840
  const value2 = values[ph];
17816
17841
  if (typeof value2 === "string" && value2.length > 0 && !UNSAFE.test(value2)) out[ph] = value2;
17817
17842
  }
@@ -18503,6 +18528,104 @@ async function substituteHead(head, ask) {
18503
18528
  `, values };
18504
18529
  }
18505
18530
 
18531
+ // src/kernel/net/sealed-scram.ts
18532
+ var encoder8 = new TextEncoder();
18533
+ function base64Bytes(text) {
18534
+ try {
18535
+ return Uint8Array.from(atob(text), (c) => c.charCodeAt(0));
18536
+ } catch {
18537
+ return void 0;
18538
+ }
18539
+ }
18540
+ function base64Of(bytes) {
18541
+ let bin = "";
18542
+ for (const b of bytes) bin += String.fromCharCode(b);
18543
+ return btoa(bin);
18544
+ }
18545
+ function clientFirstBare(message3) {
18546
+ const m = /^n,,(n=[^,]*,r=[^,]+)$/.exec(message3);
18547
+ return m ? m[1] : void 0;
18548
+ }
18549
+ var SERVER_FIRST = /^r=([^,]+),s=([^,]+),i=(\d{1,6})$/;
18550
+ var CLIENT_FINAL = /^(c=biws,r=([^,]+)),p=([^,]+)$/;
18551
+ var SCRAM_MAX = 1024;
18552
+ function exchangeOf(clientFirst, serverFirst, clientFinal) {
18553
+ const bare = clientFirstBare(clientFirst);
18554
+ const sf = SERVER_FIRST.exec(serverFirst);
18555
+ const fin = CLIENT_FINAL.exec(clientFinal);
18556
+ if (!bare || !sf || !fin || [bare, serverFirst, clientFinal].some((t) => t.length > SCRAM_MAX))
18557
+ return void 0;
18558
+ const cnonce = bare.slice(bare.indexOf(",r=") + 3);
18559
+ const nonce = sf[1];
18560
+ const salt = base64Bytes(sf[2]);
18561
+ const iterations = Number(sf[3]);
18562
+ const proof = base64Bytes(fin[3]);
18563
+ const ok4 = fin[2] === nonce && nonce.startsWith(cnonce) && iterations >= 1 && iterations <= 1e5 && salt !== void 0 && proof?.length === 32;
18564
+ if (!ok4) return void 0;
18565
+ return {
18566
+ exchange: {
18567
+ clientFirstBare: bare,
18568
+ serverFirst,
18569
+ clientFinalBare: fin[1],
18570
+ salt,
18571
+ iterations
18572
+ },
18573
+ proof
18574
+ };
18575
+ }
18576
+ async function hmac(key, data) {
18577
+ const k = await crypto.subtle.importKey(
18578
+ "raw",
18579
+ key,
18580
+ { name: "HMAC", hash: "SHA-256" },
18581
+ false,
18582
+ ["sign"]
18583
+ );
18584
+ return new Uint8Array(await crypto.subtle.sign("HMAC", k, data));
18585
+ }
18586
+ async function scramKeys(password, x) {
18587
+ const base = await crypto.subtle.importKey("raw", encoder8.encode(password), "PBKDF2", false, [
18588
+ "deriveBits"
18589
+ ]);
18590
+ const salted = new Uint8Array(
18591
+ await crypto.subtle.deriveBits(
18592
+ {
18593
+ name: "PBKDF2",
18594
+ hash: "SHA-256",
18595
+ salt: x.salt,
18596
+ iterations: x.iterations
18597
+ },
18598
+ base,
18599
+ 256
18600
+ )
18601
+ );
18602
+ const clientKey = await hmac(salted, encoder8.encode("Client Key"));
18603
+ const stored = new Uint8Array(
18604
+ await crypto.subtle.digest("SHA-256", clientKey)
18605
+ );
18606
+ const auth = encoder8.encode(`${x.clientFirstBare},${x.serverFirst},${x.clientFinalBare}`);
18607
+ const signature = await hmac(stored, auth);
18608
+ const proof = clientKey.map((b, i) => b ^ signature[i]);
18609
+ const serverKey = await hmac(salted, encoder8.encode("Server Key"));
18610
+ const serverSignature = await hmac(serverKey, auth);
18611
+ for (const k of [salted, clientKey, stored, signature, serverKey]) k.fill(0);
18612
+ return { proof, serverSignature };
18613
+ }
18614
+ var SPACES = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
18615
+ var NOTHING2 = /\u00AD|\u034F|\u1806|[\u180B-\u180D]|\u200C|\u200D|\u2060|[\uFE00-\uFE0F]|\uFEFF/g;
18616
+ var PROHIBITED = /[\u0000-\u001F\u007F-\u009F\uE000-\uF8FF\uFFFE\uFFFF]/;
18617
+ function saslprep(password) {
18618
+ if (/^[\x20-\x7e]*$/.test(password)) return password;
18619
+ const mapped = password.replace(SPACES, " ").replace(NOTHING2, "").normalize("NFKC");
18620
+ return PROHIBITED.test(mapped) ? password : mapped;
18621
+ }
18622
+ function sameBytes(a, b) {
18623
+ if (a.length !== b.length) return false;
18624
+ let d = 0;
18625
+ for (let i = 0; i < a.length; i++) d |= a[i] ^ b[i];
18626
+ return d === 0;
18627
+ }
18628
+
18506
18629
  // src/kernel/net/sealed-pg.ts
18507
18630
  var PG_MESSAGE_MAX = 16 * 1024;
18508
18631
  var PROTOCOL_3 = 196608;
@@ -18517,44 +18640,101 @@ function sniffPg(start2) {
18517
18640
  const length2 = int32(bytes, 0);
18518
18641
  return length2 >= 8 && length2 <= PG_MESSAGE_MAX && int32(bytes, 4) === PROTOCOL_3 ? "yes" : "no";
18519
18642
  }
18643
+ var PLUS = "SCRAM-SHA-256-PLUS";
18644
+ var SASL = 10;
18645
+ var SASL_CONTINUE = 11;
18646
+ var SASL_FINAL = 12;
18647
+ function latin(bytes) {
18648
+ let out = "";
18649
+ for (const b of bytes) out += String.fromCharCode(b);
18650
+ return out;
18651
+ }
18520
18652
  var PgServer = class {
18521
18653
  buffer = new Uint8Array(0);
18522
18654
  skip = 0;
18523
- lost = false;
18524
18655
  cleartext = false;
18525
- feed(bytes) {
18526
- if (this.lost) return;
18656
+ sasl = false;
18657
+ serverFirst;
18658
+ expect;
18659
+ failed = false;
18660
+ lost = false;
18661
+ auth(message3) {
18662
+ const code = message3.length >= 9 ? int32(message3, 5) : -1;
18663
+ if (this.expect && code !== SASL_FINAL) this.failed = true;
18664
+ this.cleartext = message3.length === 9 && code === CLEARTEXT;
18665
+ if (code === SASL) return this.mechanisms(message3);
18666
+ else if (code === SASL_CONTINUE) this.serverFirst = latin(message3.subarray(9));
18667
+ else if (code === SASL_FINAL) this.final(message3);
18668
+ return message3;
18669
+ }
18670
+ mechanisms(message3) {
18671
+ this.sasl = true;
18672
+ const names2 = latin(message3.subarray(9)).split("\0").filter((n) => n !== "" && n !== PLUS);
18673
+ return frame3(82, `${latin(message3.subarray(5, 9))}${names2.map((n) => `${n}\0`).join("")}\0`);
18674
+ }
18675
+ final(message3) {
18676
+ const expect = this.expect;
18677
+ if (!expect) return;
18678
+ this.expect = void 0;
18679
+ const data = latin(message3.subarray(9));
18680
+ if (data !== expect.real || expect.fake.length !== expect.real.length) {
18681
+ this.failed = true;
18682
+ return;
18683
+ }
18684
+ for (let i = 0; i < expect.fake.length; i++) message3[9 + i] = expect.fake.charCodeAt(i);
18685
+ }
18686
+ lose() {
18687
+ this.lost = true;
18688
+ this.cleartext = false;
18689
+ this.sasl = false;
18690
+ if (this.expect) this.failed = true;
18691
+ this.expect = void 0;
18692
+ }
18693
+ filter(bytes) {
18694
+ if (this.lost) return bytes;
18527
18695
  const data = new Uint8Array(this.buffer.length + bytes.length);
18528
18696
  data.set(this.buffer);
18529
18697
  data.set(bytes, this.buffer.length);
18698
+ const out = [];
18530
18699
  let at = 0;
18531
18700
  for (; ; ) {
18532
18701
  const left = data.length - at;
18533
18702
  if (this.skip > 0) {
18534
18703
  const n = Math.min(this.skip, left);
18704
+ out.push(data.subarray(at, at + n));
18535
18705
  this.skip -= n;
18536
18706
  at += n;
18537
18707
  if (this.skip > 0) break;
18538
18708
  continue;
18539
18709
  }
18540
18710
  if (left < 5) break;
18541
- const type = data[at];
18542
18711
  const whole = 1 + int32(data, at + 1);
18543
- if (whole < 5 || type === 82 && whole > PG_MESSAGE_MAX) {
18544
- this.lost = true;
18545
- this.cleartext = false;
18546
- this.buffer = new Uint8Array(0);
18547
- return;
18712
+ if (whole < 5 || data[at] === 82 && whole > PG_MESSAGE_MAX) {
18713
+ this.lose();
18714
+ out.push(data.subarray(at));
18715
+ at = data.length;
18716
+ break;
18548
18717
  }
18549
- if (type !== 82) {
18718
+ if (data[at] !== 82) {
18719
+ if (this.expect) {
18720
+ this.failed = true;
18721
+ break;
18722
+ }
18550
18723
  this.skip = whole;
18551
18724
  continue;
18552
18725
  }
18553
18726
  if (left < whole) break;
18554
- this.cleartext = whole === 9 && int32(data, at + 5) === CLEARTEXT;
18727
+ out.push(this.auth(data.slice(at, at + whole)));
18555
18728
  at += whole;
18556
18729
  }
18557
18730
  this.buffer = data.slice(at);
18731
+ const joined4 = new Uint8Array(out.reduce((n, b) => n + b.length, 0));
18732
+ let to = 0;
18733
+ for (const b of out) {
18734
+ joined4.set(b, to);
18735
+ to += b.length;
18736
+ }
18737
+ return joined4;
18558
18738
  }
18559
18739
  };
18560
18740
  function frame3(type, body) {
@@ -18571,21 +18751,76 @@ function pgLength(bytes, started) {
18571
18751
  const length2 = int32(bytes, started ? 1 : 0);
18572
18752
  return started ? 1 + length2 : length2;
18573
18753
  }
18574
- async function pgPassword(message3, server, ask) {
18575
- if (message3[0] !== 112 || !server.cleartext) return { bytes: message3, done: true };
18576
- server.cleartext = false;
18577
- let body = "";
18578
- for (const b of message3.subarray(5)) body += String.fromCharCode(b);
18754
+ var MECHANISMS = /* @__PURE__ */ new Set(["SCRAM-SHA-256"]);
18755
+ async function cleartext(message3, asks) {
18756
+ const body = latin(message3.subarray(5));
18579
18757
  if (!body.endsWith("\0") || body.indexOf("\0") !== body.length - 1)
18580
18758
  return { bytes: message3, done: true };
18581
18759
  const password = body.slice(0, -1);
18582
18760
  const placeholders = placeholdersIn(password);
18583
18761
  if (placeholders.length === 0 || placeholders.length > SESSION_PLACEHOLDERS)
18584
18762
  return { bytes: message3, done: true };
18585
- const values = usable(await ask(placeholders));
18763
+ const values = usable(await asks.cleartext(placeholders));
18586
18764
  if (Object.keys(values).length === 0) return { bytes: message3, done: true };
18587
18765
  return { bytes: frame3(112, `${replaced(password, values)}\0`), values, done: true };
18588
18766
  }
18767
+ function initial(message3) {
18768
+ const body = latin(message3.subarray(5));
18769
+ const nul = body.indexOf("\0");
18770
+ if (nul < 0 || !MECHANISMS.has(body.slice(0, nul)) || body.length < nul + 5) return void 0;
18771
+ const data = message3.subarray(5 + nul + 5);
18772
+ return int32(message3, 5 + nul + 1) === data.length ? latin(data) : void 0;
18773
+ }
18774
+ var PgClient = class {
18775
+ clientFirst;
18776
+ server;
18777
+ asks;
18778
+ constructor(server, asks) {
18779
+ this.server = server;
18780
+ this.asks = asks;
18781
+ }
18782
+ async message(message3) {
18783
+ const server = this.server;
18784
+ if (message3[0] !== 112) return { bytes: message3, done: true };
18785
+ if (server.cleartext) {
18786
+ server.cleartext = false;
18787
+ return cleartext(message3, this.asks);
18788
+ }
18789
+ if (server.sasl && this.clientFirst === void 0) {
18790
+ this.clientFirst = initial(message3);
18791
+ return { bytes: message3, done: this.clientFirst === void 0 };
18792
+ }
18793
+ if (this.clientFirst !== void 0 && server.serverFirst !== void 0)
18794
+ return this.final(message3, this.clientFirst, server.serverFirst);
18795
+ return { bytes: message3, done: true };
18796
+ }
18797
+ async final(message3, first, serverFirst) {
18798
+ const got = exchangeOf(first, serverFirst, latin(message3.subarray(5)));
18799
+ if (!got) return { bytes: message3, done: true };
18800
+ const x = got.exchange;
18801
+ const values = usable(
18802
+ await this.asks.scram({
18803
+ clientFirstBare: x.clientFirstBare,
18804
+ serverFirst: x.serverFirst,
18805
+ clientFinalBare: x.clientFinalBare,
18806
+ proof: base64Of(got.proof)
18807
+ })
18808
+ );
18809
+ const [entry, ...more] = Object.entries(values);
18810
+ if (!entry || more.length > 0) return { bytes: message3, done: true };
18811
+ const [placeholder, value2] = entry;
18812
+ const fake = await scramKeys(placeholder, x);
18813
+ if (!sameBytes(fake.proof, got.proof)) return { bytes: message3, done: true };
18814
+ const real = await scramKeys(saslprep(value2), x);
18815
+ this.server.expect = {
18816
+ real: `v=${base64Of(real.serverSignature)}`,
18817
+ fake: `v=${base64Of(fake.serverSignature)}`
18818
+ };
18819
+ const bytes = frame3(112, `${x.clientFinalBare},p=${base64Of(real.proof)}`);
18820
+ for (const k of [real.proof, real.serverSignature, fake.proof, fake.serverSignature]) k.fill(0);
18821
+ return { bytes, values, done: true };
18822
+ }
18823
+ };
18589
18824
 
18590
18825
  // src/kernel/net/sealed-smtp.ts
18591
18826
  var SMTP_LINE_MAX = 4096;
@@ -18730,17 +18965,21 @@ var SessionWriter = class {
18730
18965
  session = sessionId();
18731
18966
  smtp;
18732
18967
  pgStarted = false;
18968
+ sawPg = false;
18733
18969
  conn;
18734
18970
  s;
18735
- pg;
18971
+ pgClient;
18736
18972
  scope;
18737
18973
  constructor(conn, s, pg, scope) {
18738
18974
  this.conn = conn;
18739
18975
  this.s = s;
18740
- this.pg = pg;
18741
18976
  this.scope = scope;
18977
+ this.pgClient = new PgClient(pg, {
18978
+ cleartext: (placeholders) => this.ask("pg", "password-cleartext", { placeholders }),
18979
+ scram: (scram) => this.ask("pg", "scram-sha-256", { scram })
18980
+ });
18742
18981
  this.smtp = new SmtpClient(
18743
- (position, placeholders) => this.ask("smtp", position, placeholders)
18982
+ (position, placeholders) => this.ask("smtp", position, { placeholders })
18744
18983
  );
18745
18984
  }
18746
18985
  write(bytes) {
@@ -18751,7 +18990,7 @@ var SessionWriter = class {
18751
18990
  );
18752
18991
  return run2;
18753
18992
  }
18754
- async ask(protocol, position, placeholders, head) {
18993
+ async ask(protocol, position, extra) {
18755
18994
  const s = this.s;
18756
18995
  const values = await s.broker.sessionMaterialize({
18757
18996
  stamp: await s.stamp(),
@@ -18763,8 +19002,7 @@ var SessionWriter = class {
18763
19002
  verified: s.verified,
18764
19003
  handshakeAt: s.handshakeAt,
18765
19004
  exit: s.exit,
18766
- placeholders,
18767
- ...head ? { head } : {}
19005
+ ...extra
18768
19006
  });
18769
19007
  return values;
18770
19008
  }
@@ -18783,6 +19021,7 @@ var SessionWriter = class {
18783
19021
  this.buffer.fill(0);
18784
19022
  this.buffer = joined4;
18785
19023
  if (this.mode === "sniff") this.mode = modeOf(latin12(joined4.subarray(0, 8))) ?? "sniff";
19024
+ if (this.mode === "pg") this.sawPg = true;
18786
19025
  if (this.mode === "pass") await this.release();
18787
19026
  else if (this.mode === "http1") await this.http1();
18788
19027
  else if (this.mode === "smtp") await this.lines();
@@ -18829,11 +19068,7 @@ var SessionWriter = class {
18829
19068
  this.buffer = this.buffer.slice(whole);
18830
19069
  const started = this.pgStarted;
18831
19070
  this.pgStarted = true;
18832
- const out = started ? await pgPassword(
18833
- message3,
18834
- this.pg,
18835
- (placeholders) => this.ask("pg", "password-cleartext", placeholders)
18836
- ).catch(() => ({ bytes: message3, done: true })) : { bytes: message3, done: false };
19071
+ const out = started ? await this.pgClient.message(message3).catch(() => ({ bytes: message3, done: true })) : { bytes: message3, done: false };
18837
19072
  if ("values" in out && out.values) this.remember(out.values);
18838
19073
  try {
18839
19074
  await writeAll4(this.conn, out.bytes);
@@ -18865,7 +19100,7 @@ var SessionWriter = class {
18865
19100
  this.buffer = new Uint8Array(0);
18866
19101
  const done4 = await substituteHead(
18867
19102
  latin12(all.subarray(0, end)),
18868
- (position, placeholders, head2) => this.ask("http1", position, placeholders, head2)
19103
+ (position, placeholders, head2) => this.ask("http1", position, { placeholders, head: head2 })
18869
19104
  ).catch(() => void 0);
18870
19105
  const head = done4 ? bytesOf(done4.head) : all.subarray(0, end);
18871
19106
  if (done4) this.remember(done4.values);
@@ -18963,9 +19198,19 @@ function sealedConn(conn, s) {
18963
19198
  const observed = {
18964
19199
  ...conn,
18965
19200
  read: async () => {
18966
- const bytes = await conn.read();
18967
- if (bytes) pg.feed(bytes);
18968
- return bytes;
19201
+ for (; ; ) {
19202
+ const bytes = await conn.read();
19203
+ if (!bytes) return bytes;
19204
+ const out = writer?.sawPg ? pg.filter(bytes) : bytes;
19205
+ if (pg.failed) {
19206
+ conn.close();
19207
+ throw new KernelError(
19208
+ "EPROTO",
19209
+ "ERR_SSL_PROTOCOL_ERROR: the pg server failed the SCRAM proof"
19210
+ );
19211
+ }
19212
+ if (out.length > 0) return out;
19213
+ }
18969
19214
  }
18970
19215
  };
18971
19216
  const reader = new ScrubReader(writer ? observed : conn, scope);
@@ -24045,7 +24290,7 @@ var SEALED_OPS = /* @__PURE__ */ new Set([
24045
24290
  "cancel",
24046
24291
  "materialize"
24047
24292
  ]);
24048
- var encoder8 = new TextEncoder();
24293
+ var encoder9 = new TextEncoder();
24049
24294
  var decoder3 = new TextDecoder("utf-8", { fatal: true });
24050
24295
  function parseSealed(bytes) {
24051
24296
  try {
@@ -24126,7 +24371,7 @@ var SealedChannel = class {
24126
24371
  await this.broker.tickets.record(req, reply, caller.pid);
24127
24372
  if (this.inflight !== flight) return;
24128
24373
  this.inflight = void 0;
24129
- if (reply) this.reply = encoder8.encode(serialized(reply));
24374
+ if (reply) this.reply = encoder9.encode(serialized(reply));
24130
24375
  });
24131
24376
  this.inflight = flight;
24132
24377
  return length2;
@@ -25934,9 +26179,9 @@ function importedMemory(bytes) {
25934
26179
  };
25935
26180
  const limits = () => {
25936
26181
  const flags2 = bytes[at++];
25937
- const initial = u32();
26182
+ const initial2 = u32();
25938
26183
  const maximum = flags2 & 1 ? u32() : void 0;
25939
- return { initial, maximum, shared: (flags2 & 2) !== 0 };
26184
+ return { initial: initial2, maximum, shared: (flags2 & 2) !== 0 };
25940
26185
  };
25941
26186
  while (at < bytes.length) {
25942
26187
  const id2 = bytes[at++];
@@ -26577,7 +26822,7 @@ var LAYOUT = [
26577
26822
  var IN_TREE = /* @__PURE__ */ new Set([SUDO_PATH, CRONTAB_PATH]);
26578
26823
  var LOAD_SAMPLE_MS = 5e3;
26579
26824
  var LOAD_WINDOWS_MS = [6e4, 3e5, 9e5];
26580
- var encoder9 = new TextEncoder();
26825
+ var encoder10 = new TextEncoder();
26581
26826
  var USERS_MODES = ["off", "report", "enforce"];
26582
26827
  function usersMode(mode = "off") {
26583
26828
  if (USERS_MODES.includes(mode)) return mode;
@@ -28852,7 +29097,7 @@ var Launcher = class {
28852
29097
  },
28853
29098
  account
28854
29099
  );
28855
- const report = (message3) => options.onData(encoder9.encode(`${message3}\r
29100
+ const report = (message3) => options.onData(encoder10.encode(`${message3}\r
28856
29101
  `));
28857
29102
  const handle = await this.launch(planned, {
28858
29103
  env,
@@ -28890,7 +29135,7 @@ var Launcher = class {
28890
29135
  };
28891
29136
  const stdout = collect(out, options.onStdout);
28892
29137
  const stderr = collect(err, options.onStderr);
28893
- const report = (message3) => stderr(encoder9.encode(`${message3}
29138
+ const report = (message3) => stderr(encoder10.encode(`${message3}
28894
29139
  `));
28895
29140
  if (!planned) {
28896
29141
  const directory = await this.directory(file, this.fs.resolvePath(cwd, file));
@@ -29694,7 +29939,7 @@ function dialStream(port, onClose) {
29694
29939
 
29695
29940
  // src/client/loopback-fetch.ts
29696
29941
  var OWN_HEADERS2 = /* @__PURE__ */ new Set(["host", "connection", "content-length", "transfer-encoding"]);
29697
- var encoder10 = new TextEncoder();
29942
+ var encoder11 = new TextEncoder();
29698
29943
  var latin13 = new TextDecoder("latin1");
29699
29944
  var ByteSource = class {
29700
29945
  buffered = new Uint8Array(0);
@@ -29712,7 +29957,7 @@ var ByteSource = class {
29712
29957
  return true;
29713
29958
  }
29714
29959
  async until(marker) {
29715
- const needle = encoder10.encode(marker);
29960
+ const needle = encoder11.encode(marker);
29716
29961
  for (; ; ) {
29717
29962
  const at = indexOf(this.buffered, needle);
29718
29963
  if (at >= 0) return this.take(at + needle.length);
@@ -29820,7 +30065,7 @@ async function requestBytes(request) {
29820
30065
  });
29821
30066
  if (body) lines2.push(`Content-Length: ${body.length}`);
29822
30067
  lines2.push("Connection: close", "", "");
29823
- const head = encoder10.encode(lines2.join("\r\n"));
30068
+ const head = encoder11.encode(lines2.join("\r\n"));
29824
30069
  const out = new Uint8Array(head.length + (body?.length ?? 0));
29825
30070
  out.set(head);
29826
30071
  if (body) out.set(body, head.length);
@@ -29874,8 +30119,8 @@ var KernelCallError = class extends Error {
29874
30119
  this.code = code;
29875
30120
  }
29876
30121
  };
29877
- var encoder11 = new TextEncoder();
29878
- var bytesOf3 = (data) => typeof data === "string" ? encoder11.encode(data) : data;
30122
+ var encoder12 = new TextEncoder();
30123
+ var bytesOf3 = (data) => typeof data === "string" ? encoder12.encode(data) : data;
29879
30124
  var UNAVAILABLE = {
29880
30125
  manualRedirects: false,
29881
30126
  encodedBodies: false,