@ai-ecoverse/slicc-kernel 1.178.0 → 1.178.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
@@ -3709,7 +3709,7 @@ function satisfies(version, range2) {
3709
3709
  }
3710
3710
 
3711
3711
  // src/version.ts
3712
- var KERNEL_VERSION = true ? "1.178.0" : "0.0.0-dev";
3712
+ var KERNEL_VERSION = true ? "1.178.1" : "0.0.0-dev";
3713
3713
  var OS_RELEASE = "6.0.0-slicc";
3714
3714
  function procVersion() {
3715
3715
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18407,6 +18407,9 @@ function enableNetwork(net, options) {
18407
18407
  return () => proxy;
18408
18408
  }
18409
18409
 
18410
+ // src/kernel/net/transport.ts
18411
+ var FORBIDDEN_HEADER = "forbidden-header";
18412
+
18410
18413
  // src/kernel/net/ws-syscalls.ts
18411
18414
  var WS_OPS = [
18412
18415
  "net-ws-open",
@@ -18706,6 +18709,9 @@ var HttpHandles = class {
18706
18709
  if (e instanceof PlaceholderRefused) {
18707
18710
  return { ok: false, errno: e.code, message: text, detail: "placeholder" };
18708
18711
  }
18712
+ if (e.detail === FORBIDDEN_HEADER) {
18713
+ return { ok: false, errno: "ENOTSUP", message: text, detail: FORBIDDEN_HEADER };
18714
+ }
18709
18715
  const status = e.status;
18710
18716
  if (text === NO_TRANSPORT || typeof status !== "number" || status === 502) {
18711
18717
  const code = codeOf2(e);
@@ -27179,7 +27185,7 @@ var TransportError = class extends Error {
27179
27185
  super(message3);
27180
27186
  this.status = status;
27181
27187
  this.code = code;
27182
- this.detail = detail === "transport" ? detail : void 0;
27188
+ this.detail = detail === "transport" || detail === FORBIDDEN_HEADER ? detail : void 0;
27183
27189
  }
27184
27190
  };
27185
27191
  function unfollowed2(redirect) {
@@ -35600,6 +35606,44 @@ function sentHeaders(headers, inPage) {
35600
35606
  if (inPage) out.delete("user-agent");
35601
35607
  return out;
35602
35608
  }
35609
+ var TRANSPORT_OWN = /* @__PURE__ */ new Set([
35610
+ "accept-encoding",
35611
+ "connection",
35612
+ "content-length",
35613
+ "expect",
35614
+ "host",
35615
+ "keep-alive",
35616
+ "te",
35617
+ "trailer",
35618
+ "transfer-encoding",
35619
+ "upgrade"
35620
+ ]);
35621
+ var PROBE = "http://forbidden-headers.invalid/";
35622
+ var filters;
35623
+ function platformFilters() {
35624
+ filters ??= !new Request(PROBE, { headers: [["cookie", "probe=1"]] }).headers.has("cookie");
35625
+ return filters;
35626
+ }
35627
+ function unsendableHeaders(url, names2, hint) {
35628
+ const which = names2.length > 1 ? "headers" : "header";
35629
+ return Object.assign(
35630
+ new Error(
35631
+ `fetch ${url} refused: the page's fetch can't send the request ${which} ${names2.join(", ")}, so it was not sent${hint ? `: ${hint}` : ""}`
35632
+ ),
35633
+ { status: 502, code: "ENOTSUP", detail: FORBIDDEN_HEADER, headers: [...names2] }
35634
+ );
35635
+ }
35636
+ function refuseUnsendable(url, out, hint) {
35637
+ if (!platformFilters()) return;
35638
+ const kept = new Request(PROBE, { headers: out }).headers;
35639
+ const refused4 = [];
35640
+ for (const name2 of new Set(out.keys())) {
35641
+ if (kept.has(name2)) continue;
35642
+ if (TRANSPORT_OWN.has(name2)) out.delete(name2);
35643
+ else refused4.push(name2);
35644
+ }
35645
+ if (refused4.length > 0) throw unsendableHeaders(url, refused4, hint);
35646
+ }
35603
35647
  function streamOf(body) {
35604
35648
  const it = body[Symbol.asyncIterator]();
35605
35649
  return new ReadableStream(
@@ -35628,6 +35672,7 @@ function fetchTransport(options = {}) {
35628
35672
  const headers = options.webSocketHeaders === true;
35629
35673
  const instance = options.redirect ?? "follow";
35630
35674
  const inPage = !options.fetch && "location" in globalThis;
35675
+ const refuse2 = (options.forbiddenHeaders ?? (options.fetch ? "send" : "refuse")) === "refuse";
35631
35676
  return {
35632
35677
  traits: {
35633
35678
  manualRedirects: instance === "manual",
@@ -35640,11 +35685,13 @@ function fetchTransport(options = {}) {
35640
35685
  },
35641
35686
  ...Socket ? { websocket: (request) => openWebSocket(Socket, request, headers) } : {},
35642
35687
  async fetch(request) {
35688
+ const sent = sentHeaders(request.headers, inPage);
35689
+ if (refuse2) refuseUnsendable(request.url, sent, options.hint);
35643
35690
  let response;
35644
35691
  try {
35645
35692
  response = await send2(request.url, {
35646
35693
  method: request.method,
35647
- headers: sentHeaders(request.headers, inPage),
35694
+ headers: sent,
35648
35695
  ...requestBody(request),
35649
35696
  signal: request.signal,
35650
35697
  redirect: request.redirect ?? instance,
@@ -35745,7 +35792,7 @@ function serveTransport(peer, transport, {
35745
35792
  message: e instanceof Error ? e.message : String(e),
35746
35793
  ...typeof status === "number" ? { status } : {},
35747
35794
  ...typeof code === "string" ? { code } : {},
35748
- ...detail === "transport" ? { detail } : {}
35795
+ ...detail === "transport" || detail === FORBIDDEN_HEADER ? { detail } : {}
35749
35796
  });
35750
35797
  };
35751
35798
  const uploads = uploadsFor(peer);