@ai-ecoverse/slicc-kernel 1.125.12 → 1.126.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.
@@ -6699,7 +6699,7 @@ function satisfies(version, range2) {
6699
6699
  }
6700
6700
 
6701
6701
  // src/version.ts
6702
- var KERNEL_VERSION = true ? "1.125.12" : "0.0.0-dev";
6702
+ var KERNEL_VERSION = true ? "1.126.0" : "0.0.0-dev";
6703
6703
  var OS_RELEASE = "6.0.0-slicc";
6704
6704
  function procVersion() {
6705
6705
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -8331,10 +8331,10 @@ function tunnelRequestUrl(req, origin) {
8331
8331
  throw new HttpError(400, "malformed request target");
8332
8332
  }
8333
8333
  const hosts = fieldValues(req.headers, "host");
8334
- const hostOk = hosts.every(
8334
+ const hostOk2 = hosts.every(
8335
8335
  (h) => URL.canParse(`https://${h}`) && new URL(`https://${h}`).host === base.host
8336
8336
  );
8337
- if (url.origin !== base.origin || !hostOk) {
8337
+ if (url.origin !== base.origin || !hostOk2) {
8338
8338
  throw new HttpError(421, `this tunnel is for ${base.host}`);
8339
8339
  }
8340
8340
  return url.href;
@@ -17662,6 +17662,10 @@ function controlsOf(o, session, protocol, chain2, shape) {
17662
17662
  ...o.insecure ? insecureOf(session, chain2, shape) : { hostnameMatches: checked || !session.nameMismatch }
17663
17663
  };
17664
17664
  }
17665
+ function verdictOf(o, session) {
17666
+ if (o.bundled !== true || isIP(o.servername) || session.verifyResult !== 0) return false;
17667
+ return o.checkHostname !== false || !session.nameMismatch;
17668
+ }
17665
17669
  async function infoOf(o, session) {
17666
17670
  const flags2 = session.verifyResult;
17667
17671
  const code = verifyCode(flags2);
@@ -17674,7 +17678,9 @@ async function infoOf(o, session) {
17674
17678
  authorized: code === void 0,
17675
17679
  ...code ? { authorizationError: code, authorizationText: o.engine.verifyInfo(flags2).trim() } : {},
17676
17680
  peerCertificates: chain2,
17677
- ...controlsOf(o, session, protocol, chain2, shape)
17681
+ ...controlsOf(o, session, protocol, chain2, shape),
17682
+ verified: verdictOf(o, session),
17683
+ handshakeAt: Date.now()
17678
17684
  };
17679
17685
  }
17680
17686
  var FATAL_ALERT = -30592;
@@ -17792,6 +17798,7 @@ function sessionOf(info, servername) {
17792
17798
  return {
17793
17799
  path: "kernel",
17794
17800
  substitutes: false,
17801
+ verified: info.verified,
17795
17802
  protocol: info.protocol,
17796
17803
  alpnProtocol: info.alpnProtocol,
17797
17804
  authorized: info.authorized,
@@ -17905,7 +17912,8 @@ async function prepareWith(support, req, servername, cert) {
17905
17912
  insecure: req.insecure === true,
17906
17913
  ...req.sni === false ? { sni: false } : {},
17907
17914
  ...req.checkHostname === false ? { checkHostname: false } : {},
17908
- clientCertificate: cert !== void 0
17915
+ clientCertificate: cert !== void 0,
17916
+ bundled: own === void 0
17909
17917
  };
17910
17918
  let session;
17911
17919
  try {
@@ -22645,6 +22653,79 @@ function scrubStdio(fds, scrubber) {
22645
22653
  }
22646
22654
  }
22647
22655
 
22656
+ // src/kernel/sealed-session.ts
22657
+ var SESSION_WINDOW_MS = 6e4;
22658
+ var SESSION_PLACEHOLDERS = 16;
22659
+ var SESSION_PLACEHOLDER = /^fnox_proxy_[0-9a-f]{24}$/;
22660
+ var SESSION_ID = /^[A-Za-z0-9_-]{16,128}$/;
22661
+ var TOKEN5 = "[!#$%&'*+.^_`|~0-9a-z-]+";
22662
+ var HEADER = new RegExp(`^header:${TOKEN5}$`);
22663
+ var METHOD = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
22664
+ var TARGET = /^[\x21-\x7e]+$/;
22665
+ var EXIT = /^(page|proxy|tailscale|device:[\x21-\x7e]+)$/;
22666
+ var HOST = /^[a-z0-9.:-]+$/;
22667
+ var UNSAFE = /[\r\n\0]/;
22668
+ var POSITIONS = {
22669
+ http1: (position) => HEADER.test(position),
22670
+ smtp: (position) => position === "auth-plain" || position === "auth-login",
22671
+ pg: (position) => position === "password-cleartext"
22672
+ };
22673
+ function boundHost(servername) {
22674
+ const lower = servername.toLowerCase();
22675
+ return lower.endsWith(".") ? lower.slice(0, -1) : lower;
22676
+ }
22677
+ function headOk(f) {
22678
+ if (f.protocol !== "http1") return f.head === void 0;
22679
+ const head = f.head;
22680
+ return head !== void 0 && typeof head.method === "string" && METHOD.test(head.method) && typeof head.path === "string" && TARGET.test(head.path);
22681
+ }
22682
+ function placeholdersOk(list) {
22683
+ if (!Array.isArray(list) || list.length === 0 || list.length > SESSION_PLACEHOLDERS) return false;
22684
+ return new Set(list).size === list.length && list.every((p) => typeof p === "string" && SESSION_PLACEHOLDER.test(p));
22685
+ }
22686
+ function hostOk(host) {
22687
+ return typeof host === "string" && HOST.test(host) && boundHost(host) === host;
22688
+ }
22689
+ function sessionAskable(f, now) {
22690
+ if (!Object.hasOwn(POSITIONS, f.protocol) || typeof f.position !== "string") return false;
22691
+ if (!POSITIONS[f.protocol](f.position)) return false;
22692
+ if (typeof f.session !== "string" || !SESSION_ID.test(f.session)) return false;
22693
+ if (f.verified !== true || !hostOk(f.host) || typeof f.handshakeAt !== "number") return false;
22694
+ if (!Number.isInteger(f.port) || f.port < 1 || f.port > 65535) return false;
22695
+ const age = now - f.handshakeAt;
22696
+ if (!Number.isFinite(age) || age < 0 || age > SESSION_WINDOW_MS) return false;
22697
+ return typeof f.exit === "string" && EXIT.test(f.exit) && placeholdersOk(f.placeholders) && headOk(f);
22698
+ }
22699
+ function sessionRequest(f) {
22700
+ return {
22701
+ v: 1,
22702
+ op: "sessionMaterialize",
22703
+ caller: f.stamp,
22704
+ stamp: f.stamp,
22705
+ session: f.session,
22706
+ host: f.host,
22707
+ port: f.port,
22708
+ protocol: f.protocol,
22709
+ position: f.position,
22710
+ verified: true,
22711
+ handshakeAt: f.handshakeAt,
22712
+ exit: f.exit,
22713
+ placeholders: [...f.placeholders],
22714
+ ...f.head ? { head: { method: f.head.method, path: f.head.path } } : {}
22715
+ };
22716
+ }
22717
+ function sessionValues(reply, asked) {
22718
+ if (typeof reply !== "object" || reply === null || Array.isArray(reply)) return void 0;
22719
+ const { error, values } = reply;
22720
+ if (error !== void 0 || typeof values !== "object" || values === null) return void 0;
22721
+ const out = {};
22722
+ for (const ph of asked) {
22723
+ const value2 = values[ph];
22724
+ if (typeof value2 === "string" && value2.length > 0 && !UNSAFE.test(value2)) out[ph] = value2;
22725
+ }
22726
+ return Object.keys(out).length > 0 ? out : void 0;
22727
+ }
22728
+
22648
22729
  // src/kernel/sealed.ts
22649
22730
  var SEALED_MAX_BYTES = 64 * 1024;
22650
22731
  var SEALED_TIMEOUT_MS = 1e4;
@@ -22839,6 +22920,15 @@ var SealedBroker = class {
22839
22920
  };
22840
22921
  }
22841
22922
  async consume(fields) {
22923
+ const req = { ...fields, v: 1, op: "materializeConsume", caller: fields.stamp };
22924
+ return this.ask(req, swapOf);
22925
+ }
22926
+ async sessionMaterialize(fields, now = Date.now()) {
22927
+ if (!sessionAskable(fields, now)) return void 0;
22928
+ const req = sessionRequest(fields);
22929
+ return this.ask(req, (reply) => sessionValues(reply, req.placeholders));
22930
+ }
22931
+ async ask(req, parse) {
22842
22932
  const { hook } = this;
22843
22933
  if (!hook) return void 0;
22844
22934
  const control = new AbortController();
@@ -22846,14 +22936,8 @@ var SealedBroker = class {
22846
22936
  const stopped = new Promise((resolve2) => {
22847
22937
  control.signal.addEventListener("abort", () => resolve2(void 0), { once: true });
22848
22938
  });
22849
- const req = {
22850
- ...fields,
22851
- v: 1,
22852
- op: "materializeConsume",
22853
- caller: fields.stamp
22854
- };
22855
22939
  try {
22856
- const asked = Promise.resolve().then(() => hook(req, { signal: control.signal })).then(swapOf, () => void 0);
22940
+ const asked = Promise.resolve().then(() => hook(req, { signal: control.signal })).then(parse, () => void 0);
22857
22941
  return await Promise.race([asked, stopped]);
22858
22942
  } finally {
22859
22943
  clearTimeout(timer);