peachsim 0.1.823 → 0.1.824
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-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +15 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1 -1
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +32 -34
- package/dist-lib/host/fetch-proxy-handler.cjs +24 -34
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +33 -3
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +32 -34
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1 -1
- package/dist-lib/vite.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/backend-origin.ts +27 -0
- package/src/host/bridge-host.ts +8 -3
- package/src/host/fetch-proxy-handler.ts +20 -37
- package/src/host/fetch-proxy-transport.ts +4 -8
- package/src/host/websocket-proxy.ts +12 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/metro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/plist.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/plist.mjs
CHANGED
package/dist-lib/profiles.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/render-mode.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/sdk.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -26504,6 +26504,18 @@ function isLoopbackHost(hostname) {
|
|
|
26504
26504
|
const normalized = normalizeHostname(hostname);
|
|
26505
26505
|
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
|
|
26506
26506
|
}
|
|
26507
|
+
function isTrustedBridgeRequest(headers) {
|
|
26508
|
+
const origin = headers.origin;
|
|
26509
|
+
if (origin === void 0) return true;
|
|
26510
|
+
try {
|
|
26511
|
+
const { hostname, host: host2 } = new URL(String(origin));
|
|
26512
|
+
return isLoopbackHost(hostname) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
|
|
26513
|
+
(value) => typeof value === "string" && value.toLowerCase() === host2
|
|
26514
|
+
);
|
|
26515
|
+
} catch {
|
|
26516
|
+
return false;
|
|
26517
|
+
}
|
|
26518
|
+
}
|
|
26507
26519
|
function loopbackOriginOf(value) {
|
|
26508
26520
|
try {
|
|
26509
26521
|
const url = new URL(value);
|
|
@@ -39549,6 +39561,13 @@ function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
|
|
|
39549
39561
|
}
|
|
39550
39562
|
return headers;
|
|
39551
39563
|
}
|
|
39564
|
+
function rejectUntrustedBridgeOrigin(req, res) {
|
|
39565
|
+
if (isTrustedBridgeRequest(req.headers)) return false;
|
|
39566
|
+
res.statusCode = 403;
|
|
39567
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
39568
|
+
res.end(`peach bridge: origin ${req.headers.origin} may not use this bridge`);
|
|
39569
|
+
return true;
|
|
39570
|
+
}
|
|
39552
39571
|
function isFetchProxyRequestUrl(rawUrl) {
|
|
39553
39572
|
return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
|
|
39554
39573
|
}
|
|
@@ -39688,35 +39707,6 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
39688
39707
|
else req.socket.destroy();
|
|
39689
39708
|
}
|
|
39690
39709
|
}
|
|
39691
|
-
async function handleBundleProxyRequest(req, res) {
|
|
39692
|
-
const params = new URLSearchParams((req.url || "").split("?")[1] || "");
|
|
39693
|
-
const target = params.get("url");
|
|
39694
|
-
if (!target) {
|
|
39695
|
-
applyFetchProxyCors(req, res);
|
|
39696
|
-
res.statusCode = 400;
|
|
39697
|
-
res.setHeader("Content-Type", "text/plain");
|
|
39698
|
-
res.end("bundle-proxy: missing url query param");
|
|
39699
|
-
return;
|
|
39700
|
-
}
|
|
39701
|
-
let targetUrl;
|
|
39702
|
-
try {
|
|
39703
|
-
targetUrl = new URL(target);
|
|
39704
|
-
} catch {
|
|
39705
|
-
applyFetchProxyCors(req, res);
|
|
39706
|
-
res.statusCode = 400;
|
|
39707
|
-
res.setHeader("Content-Type", "text/plain");
|
|
39708
|
-
res.end("bundle-proxy: invalid url");
|
|
39709
|
-
return;
|
|
39710
|
-
}
|
|
39711
|
-
if (!isLoopbackHost(targetUrl.hostname)) {
|
|
39712
|
-
applyFetchProxyCors(req, res);
|
|
39713
|
-
res.statusCode = 403;
|
|
39714
|
-
res.setHeader("Content-Type", "text/plain");
|
|
39715
|
-
res.end("bundle-proxy: only loopback targets allowed");
|
|
39716
|
-
return;
|
|
39717
|
-
}
|
|
39718
|
-
await handleFetchProxyRequest(req, res);
|
|
39719
|
-
}
|
|
39720
39710
|
function handleAppApiRequest(req, res) {
|
|
39721
39711
|
const reqUrl = req.url || "";
|
|
39722
39712
|
let targetPath = "";
|
|
@@ -39842,15 +39832,15 @@ ${privateKey.toString("base64").match(/.{1,64}/g)?.join("\n")}
|
|
|
39842
39832
|
settings: { maxConcurrentStreams: 256 }
|
|
39843
39833
|
},
|
|
39844
39834
|
(req, res) => {
|
|
39835
|
+
if (rejectUntrustedBridgeOrigin(req, res)) return;
|
|
39845
39836
|
res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
39846
39837
|
res.setHeader("Timing-Allow-Origin", "*");
|
|
39847
|
-
|
|
39848
|
-
if (!handler) {
|
|
39838
|
+
if (!isBundleProxyRequestUrl(req.url) && !isFetchProxyRequestUrl(req.url)) {
|
|
39849
39839
|
res.writeHead(404);
|
|
39850
39840
|
res.end();
|
|
39851
39841
|
return;
|
|
39852
39842
|
}
|
|
39853
|
-
void
|
|
39843
|
+
void handleFetchProxyRequest(req, res).catch(() => res.destroy());
|
|
39854
39844
|
}
|
|
39855
39845
|
);
|
|
39856
39846
|
server.on("session", (session) => {
|
|
@@ -40931,6 +40921,11 @@ ${message}`
|
|
|
40931
40921
|
}
|
|
40932
40922
|
socket.destroy();
|
|
40933
40923
|
}
|
|
40924
|
+
function rejectUntrustedBridgeUpgrade(req, socket) {
|
|
40925
|
+
if (isTrustedBridgeRequest(req.headers)) return false;
|
|
40926
|
+
rejectUpgrade(socket, 403, "forbidden bridge origin");
|
|
40927
|
+
return true;
|
|
40928
|
+
}
|
|
40934
40929
|
function hasHeaderToken(value, token) {
|
|
40935
40930
|
return (value || "").split(",").some((part) => part.trim().toLowerCase() === token);
|
|
40936
40931
|
}
|
|
@@ -41164,6 +41159,7 @@ var init_websocket_proxy = __esm({
|
|
|
41164
41159
|
import_crypto = require("crypto");
|
|
41165
41160
|
import_http3 = require("http");
|
|
41166
41161
|
import_https2 = require("https");
|
|
41162
|
+
init_backend_origin();
|
|
41167
41163
|
WEBSOCKET_PROXY_PATH = "/__websocket-proxy";
|
|
41168
41164
|
WEBSOCKET_PROXY_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
41169
41165
|
WEBSOCKET_PROTOCOL_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
@@ -45773,6 +45769,7 @@ var init_bridge_host = __esm({
|
|
|
45773
45769
|
this.wss = new import_ws.WebSocketServer({ noServer: true });
|
|
45774
45770
|
this.wireWebSocketServer();
|
|
45775
45771
|
server.on("upgrade", (req, socket, head) => {
|
|
45772
|
+
if (rejectUntrustedBridgeUpgrade(req, socket)) return;
|
|
45776
45773
|
if (handleWebSocketProxyUpgrade(req, socket, head)) return;
|
|
45777
45774
|
this.wss?.handleUpgrade(req, socket, head, (ws) => {
|
|
45778
45775
|
this.wss?.emit("connection", ws, req);
|
|
@@ -46543,6 +46540,7 @@ var init_bridge_host = __esm({
|
|
|
46543
46540
|
* non-upgrade routes that don't match serve index.html (SPA behavior) so
|
|
46544
46541
|
* electron's webContents can navigate freely inside the runtime. */
|
|
46545
46542
|
handleHttpRequest(req, res) {
|
|
46543
|
+
if (rejectUntrustedBridgeOrigin(req, res)) return;
|
|
46546
46544
|
if (req.url === "/__peach/fetch-transport") {
|
|
46547
46545
|
res.writeHead(200, {
|
|
46548
46546
|
"Content-Type": "application/json",
|
|
@@ -46723,7 +46721,7 @@ var init_bridge_host = __esm({
|
|
|
46723
46721
|
return;
|
|
46724
46722
|
}
|
|
46725
46723
|
if (url.pathname === "/__bundle-proxy") {
|
|
46726
|
-
void
|
|
46724
|
+
void handleFetchProxyRequest(req, res);
|
|
46727
46725
|
return;
|
|
46728
46726
|
}
|
|
46729
46727
|
if (url.pathname === "/__server-scan") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/package.json
CHANGED
package/src/backend-origin.ts
CHANGED
|
@@ -29,6 +29,33 @@ export function isLoopbackHost(hostname: string): boolean {
|
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// a browser page may use a local peach bridge (its proxies, websocket,
|
|
33
|
+
// settings and account routes) only when this machine served the page: a
|
|
34
|
+
// loopback origin, or the bridge's own host when a tunnel or reverse proxy
|
|
35
|
+
// fronts it (its Host, or the X-Forwarded-Host a proxy that rewrites Host
|
|
36
|
+
// sets; a page cannot send that header without a preflight this rule
|
|
37
|
+
// refuses). any other site could otherwise read local dev servers and
|
|
38
|
+
// intranet hosts through the proxies. a request without an Origin header is
|
|
39
|
+
// no cross-origin browser read: the cli, node clients, and navigations.
|
|
40
|
+
// http/2 carries the host as :authority.
|
|
41
|
+
export function isTrustedBridgeRequest(
|
|
42
|
+
headers: Record<string, string | string[] | undefined>,
|
|
43
|
+
): boolean {
|
|
44
|
+
const origin = headers.origin
|
|
45
|
+
if (origin === undefined) return true
|
|
46
|
+
try {
|
|
47
|
+
const { hostname, host } = new URL(String(origin))
|
|
48
|
+
return (
|
|
49
|
+
isLoopbackHost(hostname) ||
|
|
50
|
+
[headers.host, headers[':authority'], headers['x-forwarded-host']].some(
|
|
51
|
+
(value) => typeof value === 'string' && value.toLowerCase() === host,
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
} catch {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
32
59
|
// the origin of a url whose host is loopback, or null for any other or unparsable url
|
|
33
60
|
export function loopbackOriginOf(value: string): string | null {
|
|
34
61
|
try {
|
package/src/host/bridge-host.ts
CHANGED
|
@@ -49,8 +49,8 @@ import { rnxRuntime } from '../runtime-delivery.ts'
|
|
|
49
49
|
import { AgentHost, type AgentHostOptions } from './agent-host.ts'
|
|
50
50
|
import {
|
|
51
51
|
handleAppApiRequest,
|
|
52
|
-
handleBundleProxyRequest,
|
|
53
52
|
handleFetchProxyRequest,
|
|
53
|
+
rejectUntrustedBridgeOrigin,
|
|
54
54
|
isAppApiRequestUrl,
|
|
55
55
|
isFetchProxyRequestUrl,
|
|
56
56
|
} from './fetch-proxy-handler.ts'
|
|
@@ -62,7 +62,10 @@ import {
|
|
|
62
62
|
handleReplacementModuleRequest,
|
|
63
63
|
isReplacementModuleRequestUrl,
|
|
64
64
|
} from './replacement-module-handler.ts'
|
|
65
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
handleWebSocketProxyUpgrade,
|
|
67
|
+
rejectUntrustedBridgeUpgrade,
|
|
68
|
+
} from './websocket-proxy.ts'
|
|
66
69
|
import type { WsCommand } from '../bridge-contract.ts'
|
|
67
70
|
|
|
68
71
|
const SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY = 'require-corp'
|
|
@@ -571,6 +574,7 @@ export class SootSimBridgeHost {
|
|
|
571
574
|
this.wss = new WebSocketServer({ noServer: true })
|
|
572
575
|
this.wireWebSocketServer()
|
|
573
576
|
server.on('upgrade', (req, socket, head) => {
|
|
577
|
+
if (rejectUntrustedBridgeUpgrade(req, socket)) return
|
|
574
578
|
if (handleWebSocketProxyUpgrade(req, socket, head)) return
|
|
575
579
|
this.wss?.handleUpgrade(req, socket, head, (ws) => {
|
|
576
580
|
this.wss?.emit('connection', ws, req)
|
|
@@ -1499,6 +1503,7 @@ export class SootSimBridgeHost {
|
|
|
1499
1503
|
* non-upgrade routes that don't match serve index.html (SPA behavior) so
|
|
1500
1504
|
* electron's webContents can navigate freely inside the runtime. */
|
|
1501
1505
|
private handleHttpRequest(req: IncomingMessage, res: ServerResponse) {
|
|
1506
|
+
if (rejectUntrustedBridgeOrigin(req, res)) return
|
|
1502
1507
|
if (req.url === '/__peach/fetch-transport') {
|
|
1503
1508
|
res.writeHead(200, {
|
|
1504
1509
|
'Content-Type': 'application/json',
|
|
@@ -1733,7 +1738,7 @@ export class SootSimBridgeHost {
|
|
|
1733
1738
|
// cross-origin URL without CORS headers, and metro doesn't set them.
|
|
1734
1739
|
// we proxy the request and stream the response back.
|
|
1735
1740
|
if (url.pathname === '/__bundle-proxy') {
|
|
1736
|
-
void
|
|
1741
|
+
void handleFetchProxyRequest(req, res)
|
|
1737
1742
|
return
|
|
1738
1743
|
}
|
|
1739
1744
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// routes implemented here:
|
|
17
17
|
// /__fetch-proxy?url=… — generic CORS-bypassing proxy
|
|
18
18
|
// /__proxy?url=… — alias of /__fetch-proxy (demo-gateway path)
|
|
19
|
+
// /__bundle-proxy?url=… — alias of /__fetch-proxy (bundles and assets)
|
|
19
20
|
// /__app-api?origin=…&path=… — tenant API reverse proxy, stateless
|
|
20
21
|
// (bundle origin carried in the query string)
|
|
21
22
|
// /__app-api/<path> — legacy form for callers that registered an
|
|
@@ -27,7 +28,11 @@ import http, { type IncomingMessage, type ServerResponse } from 'http'
|
|
|
27
28
|
import https from 'https'
|
|
28
29
|
import { Http2ServerRequest, type Http2ServerResponse } from 'node:http2'
|
|
29
30
|
import { finished, pipeline } from 'stream/promises'
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
isLoopbackHost,
|
|
33
|
+
isTrustedBridgeRequest,
|
|
34
|
+
normalizeHostname,
|
|
35
|
+
} from '../backend-origin.ts'
|
|
31
36
|
import {
|
|
32
37
|
buildFetchProxyUpstreamHeaders,
|
|
33
38
|
nodeRequestHeaderEntries,
|
|
@@ -131,6 +136,20 @@ export function buildAppApiProxyHeaders(
|
|
|
131
136
|
return headers
|
|
132
137
|
}
|
|
133
138
|
|
|
139
|
+
// every bridge http surface (the daemon server, its http/2 fetch transport,
|
|
140
|
+
// the shell dev server's proxies) answers only pages isTrustedBridgeRequest
|
|
141
|
+
// admits.
|
|
142
|
+
export function rejectUntrustedBridgeOrigin(
|
|
143
|
+
req: FetchProxyRequest,
|
|
144
|
+
res: FetchProxyResponse,
|
|
145
|
+
): boolean {
|
|
146
|
+
if (isTrustedBridgeRequest(req.headers)) return false
|
|
147
|
+
res.statusCode = 403
|
|
148
|
+
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
|
149
|
+
res.end(`peach bridge: origin ${req.headers.origin} may not use this bridge`)
|
|
150
|
+
return true
|
|
151
|
+
}
|
|
152
|
+
|
|
134
153
|
export function isFetchProxyRequestUrl(rawUrl: string | undefined): boolean {
|
|
135
154
|
return rawUrl?.startsWith('/__fetch-proxy?') || rawUrl?.startsWith('/__proxy?') || false
|
|
136
155
|
}
|
|
@@ -327,42 +346,6 @@ export async function handleFetchProxyRequest(
|
|
|
327
346
|
}
|
|
328
347
|
}
|
|
329
348
|
|
|
330
|
-
export async function handleBundleProxyRequest(
|
|
331
|
-
req: FetchProxyRequest,
|
|
332
|
-
res: FetchProxyResponse,
|
|
333
|
-
): Promise<void> {
|
|
334
|
-
const params = new URLSearchParams((req.url || '').split('?')[1] || '')
|
|
335
|
-
const target = params.get('url')
|
|
336
|
-
if (!target) {
|
|
337
|
-
applyFetchProxyCors(req, res)
|
|
338
|
-
res.statusCode = 400
|
|
339
|
-
res.setHeader('Content-Type', 'text/plain')
|
|
340
|
-
res.end('bundle-proxy: missing url query param')
|
|
341
|
-
return
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
let targetUrl: URL
|
|
345
|
-
try {
|
|
346
|
-
targetUrl = new URL(target)
|
|
347
|
-
} catch {
|
|
348
|
-
applyFetchProxyCors(req, res)
|
|
349
|
-
res.statusCode = 400
|
|
350
|
-
res.setHeader('Content-Type', 'text/plain')
|
|
351
|
-
res.end('bundle-proxy: invalid url')
|
|
352
|
-
return
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (!isLoopbackHost(targetUrl.hostname)) {
|
|
356
|
-
applyFetchProxyCors(req, res)
|
|
357
|
-
res.statusCode = 403
|
|
358
|
-
res.setHeader('Content-Type', 'text/plain')
|
|
359
|
-
res.end('bundle-proxy: only loopback targets allowed')
|
|
360
|
-
return
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
await handleFetchProxyRequest(req, res)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
349
|
export function handleAppApiRequest(req: IncomingMessage, res: ServerResponse): boolean {
|
|
367
350
|
// returns true if it handled the request, false if it is not an /__app-api
|
|
368
351
|
// request. the proxy is stateless: a request without an `origin` query
|
|
@@ -2,10 +2,10 @@ import { createHash, randomBytes } from 'node:crypto'
|
|
|
2
2
|
import { createSecureServer, type ServerHttp2Session } from 'node:http2'
|
|
3
3
|
import { SubjectAlternativeNameExtension, X509CertificateGenerator } from '@peculiar/x509'
|
|
4
4
|
import {
|
|
5
|
-
handleBundleProxyRequest,
|
|
6
5
|
handleFetchProxyRequest,
|
|
7
6
|
isBundleProxyRequestUrl,
|
|
8
7
|
isFetchProxyRequestUrl,
|
|
8
|
+
rejectUntrustedBridgeOrigin,
|
|
9
9
|
} from './fetch-proxy-handler.ts'
|
|
10
10
|
|
|
11
11
|
// image bytes use multiplexed tls streams. the websocket control server keeps
|
|
@@ -42,19 +42,15 @@ export async function startFetchProxyTransport() {
|
|
|
42
42
|
settings: { maxConcurrentStreams: 256 },
|
|
43
43
|
},
|
|
44
44
|
(req, res) => {
|
|
45
|
+
if (rejectUntrustedBridgeOrigin(req, res)) return
|
|
45
46
|
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin')
|
|
46
47
|
res.setHeader('Timing-Allow-Origin', '*')
|
|
47
|
-
|
|
48
|
-
? handleBundleProxyRequest
|
|
49
|
-
: isFetchProxyRequestUrl(req.url)
|
|
50
|
-
? handleFetchProxyRequest
|
|
51
|
-
: null
|
|
52
|
-
if (!handler) {
|
|
48
|
+
if (!isBundleProxyRequestUrl(req.url) && !isFetchProxyRequestUrl(req.url)) {
|
|
53
49
|
res.writeHead(404)
|
|
54
50
|
res.end()
|
|
55
51
|
return
|
|
56
52
|
}
|
|
57
|
-
void
|
|
53
|
+
void handleFetchProxyRequest(req, res).catch(() => res.destroy())
|
|
58
54
|
},
|
|
59
55
|
)
|
|
60
56
|
server.on('session', (session) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'crypto'
|
|
2
2
|
import { request as requestHttp, type IncomingMessage } from 'http'
|
|
3
3
|
import { request as requestHttps } from 'https'
|
|
4
|
+
import { isTrustedBridgeRequest } from '../backend-origin.ts'
|
|
4
5
|
import type { Duplex } from 'stream'
|
|
5
6
|
|
|
6
7
|
export const WEBSOCKET_PROXY_PATH = '/__websocket-proxy'
|
|
@@ -45,6 +46,17 @@ function rejectUpgrade(
|
|
|
45
46
|
socket.destroy()
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
// the bridge's websocket upgrade admits browser pages by the same rule as its
|
|
50
|
+
// http routes (rejectUntrustedBridgeOrigin)
|
|
51
|
+
export function rejectUntrustedBridgeUpgrade(
|
|
52
|
+
req: IncomingMessage,
|
|
53
|
+
socket: Duplex,
|
|
54
|
+
): boolean {
|
|
55
|
+
if (isTrustedBridgeRequest(req.headers)) return false
|
|
56
|
+
rejectUpgrade(socket, 403, 'forbidden bridge origin')
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
function hasHeaderToken(value: string | undefined, token: string): boolean {
|
|
49
61
|
return (value || '').split(',').some((part) => part.trim().toLowerCase() === token)
|
|
50
62
|
}
|