@volter/world-core 3.0.142 → 3.0.143

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/inject.cjs CHANGED
@@ -1734,7 +1734,7 @@ function installMiniflareOutbound() {
1734
1734
  // A host this process maps to a twin goes through the patched fetch. Any other goes where the World routes it: through
1735
1735
  // its proxy (HTTPS_PROXY, trusting the World's CA), which Node's own fetch does not read, so through miniflare's undici
1736
1736
  // with the environment's proxy agent; loopback stays direct.
1737
- const outboundFor = (miniflarePath) => {
1737
+ const outboundFor = (miniflarePath, upgradeFetch) => {
1738
1738
  let proxied = null;
1739
1739
  try {
1740
1740
  if (process.env.HTTPS_PROXY || process.env.HTTP_PROXY) {
@@ -1745,7 +1745,13 @@ function installMiniflareOutbound() {
1745
1745
  } catch { proxied = null; }
1746
1746
  const mapped = (request) => { try { const url = new URL(request.url); return Boolean(resolveTwin(url.hostname, MAP, url.pathname)); } catch { return false; } };
1747
1747
  // The Request itself is handed on: its method, headers and body are getters, which a copy of it as `init` loses.
1748
- return (request) => (!proxied || (installed && mapped(request)) ? globalThis.fetch(request) : proxied(request));
1748
+ return (request) => {
1749
+ // Node fetch cannot return an upgraded connection. Miniflare's fetch couples the socket to its response;
1750
+ // its ws client uses Node's request/socket paths, so the same injector routing and refusals still apply.
1751
+ if (request.method === 'GET' && request.headers.get('upgrade')?.toLowerCase() === 'websocket'
1752
+ && typeof upgradeFetch === 'function') return upgradeFetch(request, {});
1753
+ return !proxied || (installed && mapped(request)) ? globalThis.fetch(request) : proxied(request);
1754
+ };
1749
1755
  };
1750
1756
  let outbound = null;
1751
1757
  const routed = (options) => {
@@ -1771,7 +1777,7 @@ function installMiniflareOutbound() {
1771
1777
  if (!outbound) {
1772
1778
  let at = null;
1773
1779
  try { at = Module._resolveFilename(request, parent); } catch { at = null; }
1774
- outbound = at ? outboundFor(at) : (request) => globalThis.fetch(request);
1780
+ outbound = at ? outboundFor(at, exports.fetch) : (request) => globalThis.fetch(request);
1775
1781
  }
1776
1782
  const Original = exports.Miniflare;
1777
1783
  class Miniflare extends Original {
package/inject.cjs CHANGED
@@ -1734,7 +1734,7 @@ function installMiniflareOutbound() {
1734
1734
  // A host this process maps to a twin goes through the patched fetch. Any other goes where the World routes it: through
1735
1735
  // its proxy (HTTPS_PROXY, trusting the World's CA), which Node's own fetch does not read, so through miniflare's undici
1736
1736
  // with the environment's proxy agent; loopback stays direct.
1737
- const outboundFor = (miniflarePath) => {
1737
+ const outboundFor = (miniflarePath, upgradeFetch) => {
1738
1738
  let proxied = null;
1739
1739
  try {
1740
1740
  if (process.env.HTTPS_PROXY || process.env.HTTP_PROXY) {
@@ -1745,7 +1745,13 @@ function installMiniflareOutbound() {
1745
1745
  } catch { proxied = null; }
1746
1746
  const mapped = (request) => { try { const url = new URL(request.url); return Boolean(resolveTwin(url.hostname, MAP, url.pathname)); } catch { return false; } };
1747
1747
  // The Request itself is handed on: its method, headers and body are getters, which a copy of it as `init` loses.
1748
- return (request) => (!proxied || (installed && mapped(request)) ? globalThis.fetch(request) : proxied(request));
1748
+ return (request) => {
1749
+ // Node fetch cannot return an upgraded connection. Miniflare's fetch couples the socket to its response;
1750
+ // its ws client uses Node's request/socket paths, so the same injector routing and refusals still apply.
1751
+ if (request.method === 'GET' && request.headers.get('upgrade')?.toLowerCase() === 'websocket'
1752
+ && typeof upgradeFetch === 'function') return upgradeFetch(request, {});
1753
+ return !proxied || (installed && mapped(request)) ? globalThis.fetch(request) : proxied(request);
1754
+ };
1749
1755
  };
1750
1756
  let outbound = null;
1751
1757
  const routed = (options) => {
@@ -1771,7 +1777,7 @@ function installMiniflareOutbound() {
1771
1777
  if (!outbound) {
1772
1778
  let at = null;
1773
1779
  try { at = Module._resolveFilename(request, parent); } catch { at = null; }
1774
- outbound = at ? outboundFor(at) : (request) => globalThis.fetch(request);
1780
+ outbound = at ? outboundFor(at, exports.fetch) : (request) => globalThis.fetch(request);
1775
1781
  }
1776
1782
  const Original = exports.Miniflare;
1777
1783
  class Miniflare extends Original {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/world-core",
3
- "version": "3.0.142",
3
+ "version": "3.0.143",
4
4
  "description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
5
5
  "keywords": [
6
6
  "twin",