@volter/world-core 3.0.150 → 3.0.151
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 +16 -4
- package/inject.cjs +16 -4
- package/package.json +1 -1
package/dist/inject.cjs
CHANGED
|
@@ -1731,6 +1731,19 @@ function installWorldTime() {
|
|
|
1731
1731
|
function installMiniflareOutbound() {
|
|
1732
1732
|
if (Module.__volterMiniflareOutboundInstalled) return;
|
|
1733
1733
|
Module.__volterMiniflareOutboundInstalled = true;
|
|
1734
|
+
// Miniflare's Request is not necessarily an instance of the receiving fetch's Request. Pass a URL and explicitly
|
|
1735
|
+
// read its getters (spreading the Request loses them); neither Node nor another undici version must stringify it.
|
|
1736
|
+
const nodeFetch = (fetcher, request) => {
|
|
1737
|
+
const init = { method: request.method, headers: Array.from(request.headers) };
|
|
1738
|
+
for (const key of ['signal', 'redirect', 'cache', 'credentials', 'integrity', 'keepalive', 'mode', 'referrer', 'referrerPolicy']) {
|
|
1739
|
+
if (request[key] !== undefined) init[key] = request[key];
|
|
1740
|
+
}
|
|
1741
|
+
if (request.body != null) {
|
|
1742
|
+
init.body = request.body;
|
|
1743
|
+
init.duplex = 'half';
|
|
1744
|
+
}
|
|
1745
|
+
return fetcher(request.url, init);
|
|
1746
|
+
};
|
|
1734
1747
|
// A host this process maps to a twin goes through the patched fetch. Any other goes where the World routes it: through
|
|
1735
1748
|
// its proxy (HTTPS_PROXY, trusting the World's CA), which Node's own fetch does not read, so through miniflare's undici
|
|
1736
1749
|
// with the environment's proxy agent; loopback stays direct.
|
|
@@ -1740,17 +1753,16 @@ function installMiniflareOutbound() {
|
|
|
1740
1753
|
if (process.env.HTTPS_PROXY || process.env.HTTP_PROXY) {
|
|
1741
1754
|
const undici = Module.createRequire(miniflarePath)('undici');
|
|
1742
1755
|
const dispatcher = new undici.EnvHttpProxyAgent({ noProxy: localGuestProxy() ? '' : process.env.NO_PROXY || process.env.no_proxy || 'localhost,127.0.0.1,::1' });
|
|
1743
|
-
proxied = (
|
|
1756
|
+
proxied = (url, init) => undici.fetch(url, { ...init, dispatcher });
|
|
1744
1757
|
}
|
|
1745
1758
|
} catch { proxied = null; }
|
|
1746
1759
|
const mapped = (request) => { try { const url = new URL(request.url); return Boolean(resolveTwin(url.hostname, MAP, url.pathname)); } catch { return false; } };
|
|
1747
|
-
// The Request itself is handed on: its method, headers and body are getters, which a copy of it as `init` loses.
|
|
1748
1760
|
return (request) => {
|
|
1749
1761
|
// Node fetch cannot return an upgraded connection. Miniflare's fetch couples the socket to its response;
|
|
1750
1762
|
// its ws client uses Node's request/socket paths, so the same injector routing and refusals still apply.
|
|
1751
1763
|
if (request.method === 'GET' && request.headers.get('upgrade')?.toLowerCase() === 'websocket'
|
|
1752
1764
|
&& typeof upgradeFetch === 'function') return upgradeFetch(request, {});
|
|
1753
|
-
return !proxied || (installed && mapped(request)) ? globalThis.fetch
|
|
1765
|
+
return nodeFetch(!proxied || (installed && mapped(request)) ? globalThis.fetch : proxied, request);
|
|
1754
1766
|
};
|
|
1755
1767
|
};
|
|
1756
1768
|
let outbound = null;
|
|
@@ -1777,7 +1789,7 @@ function installMiniflareOutbound() {
|
|
|
1777
1789
|
if (!outbound) {
|
|
1778
1790
|
let at = null;
|
|
1779
1791
|
try { at = Module._resolveFilename(request, parent); } catch { at = null; }
|
|
1780
|
-
outbound =
|
|
1792
|
+
outbound = outboundFor(at, exports.fetch);
|
|
1781
1793
|
}
|
|
1782
1794
|
const Original = exports.Miniflare;
|
|
1783
1795
|
class Miniflare extends Original {
|
package/inject.cjs
CHANGED
|
@@ -1731,6 +1731,19 @@ function installWorldTime() {
|
|
|
1731
1731
|
function installMiniflareOutbound() {
|
|
1732
1732
|
if (Module.__volterMiniflareOutboundInstalled) return;
|
|
1733
1733
|
Module.__volterMiniflareOutboundInstalled = true;
|
|
1734
|
+
// Miniflare's Request is not necessarily an instance of the receiving fetch's Request. Pass a URL and explicitly
|
|
1735
|
+
// read its getters (spreading the Request loses them); neither Node nor another undici version must stringify it.
|
|
1736
|
+
const nodeFetch = (fetcher, request) => {
|
|
1737
|
+
const init = { method: request.method, headers: Array.from(request.headers) };
|
|
1738
|
+
for (const key of ['signal', 'redirect', 'cache', 'credentials', 'integrity', 'keepalive', 'mode', 'referrer', 'referrerPolicy']) {
|
|
1739
|
+
if (request[key] !== undefined) init[key] = request[key];
|
|
1740
|
+
}
|
|
1741
|
+
if (request.body != null) {
|
|
1742
|
+
init.body = request.body;
|
|
1743
|
+
init.duplex = 'half';
|
|
1744
|
+
}
|
|
1745
|
+
return fetcher(request.url, init);
|
|
1746
|
+
};
|
|
1734
1747
|
// A host this process maps to a twin goes through the patched fetch. Any other goes where the World routes it: through
|
|
1735
1748
|
// its proxy (HTTPS_PROXY, trusting the World's CA), which Node's own fetch does not read, so through miniflare's undici
|
|
1736
1749
|
// with the environment's proxy agent; loopback stays direct.
|
|
@@ -1740,17 +1753,16 @@ function installMiniflareOutbound() {
|
|
|
1740
1753
|
if (process.env.HTTPS_PROXY || process.env.HTTP_PROXY) {
|
|
1741
1754
|
const undici = Module.createRequire(miniflarePath)('undici');
|
|
1742
1755
|
const dispatcher = new undici.EnvHttpProxyAgent({ noProxy: localGuestProxy() ? '' : process.env.NO_PROXY || process.env.no_proxy || 'localhost,127.0.0.1,::1' });
|
|
1743
|
-
proxied = (
|
|
1756
|
+
proxied = (url, init) => undici.fetch(url, { ...init, dispatcher });
|
|
1744
1757
|
}
|
|
1745
1758
|
} catch { proxied = null; }
|
|
1746
1759
|
const mapped = (request) => { try { const url = new URL(request.url); return Boolean(resolveTwin(url.hostname, MAP, url.pathname)); } catch { return false; } };
|
|
1747
|
-
// The Request itself is handed on: its method, headers and body are getters, which a copy of it as `init` loses.
|
|
1748
1760
|
return (request) => {
|
|
1749
1761
|
// Node fetch cannot return an upgraded connection. Miniflare's fetch couples the socket to its response;
|
|
1750
1762
|
// its ws client uses Node's request/socket paths, so the same injector routing and refusals still apply.
|
|
1751
1763
|
if (request.method === 'GET' && request.headers.get('upgrade')?.toLowerCase() === 'websocket'
|
|
1752
1764
|
&& typeof upgradeFetch === 'function') return upgradeFetch(request, {});
|
|
1753
|
-
return !proxied || (installed && mapped(request)) ? globalThis.fetch
|
|
1765
|
+
return nodeFetch(!proxied || (installed && mapped(request)) ? globalThis.fetch : proxied, request);
|
|
1754
1766
|
};
|
|
1755
1767
|
};
|
|
1756
1768
|
let outbound = null;
|
|
@@ -1777,7 +1789,7 @@ function installMiniflareOutbound() {
|
|
|
1777
1789
|
if (!outbound) {
|
|
1778
1790
|
let at = null;
|
|
1779
1791
|
try { at = Module._resolveFilename(request, parent); } catch { at = null; }
|
|
1780
|
-
outbound =
|
|
1792
|
+
outbound = outboundFor(at, exports.fetch);
|
|
1781
1793
|
}
|
|
1782
1794
|
const Original = exports.Miniflare;
|
|
1783
1795
|
class Miniflare extends Original {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.151",
|
|
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",
|