peachsim 0.1.708 → 0.1.710
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/cli/commands/control.ts +55 -1
- package/cli/current-sim.ts +15 -1
- package/cli/drivers/playwright-sim-host.ts +14 -1
- package/cli/drivers/playwright.ts +36 -3
- package/cli/main.ts +8 -0
- package/cli/outbound-endpoints.ts +95 -27
- package/cli/parent-pid.ts +91 -15
- package/cli/ws-bridge.ts +5 -0
- 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 +1 -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/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 +78 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +172 -30
- package/dist-lib/host/fetch-proxy-handler.cjs +45 -21
- package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +78 -5
- 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 +333 -53
- package/dist-lib/swift-compile.cjs +8 -2
- package/dist-lib/swift-compile.mjs +8 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +9 -3
- package/dist-lib/vite.cjs +1 -1
- package/package.json +2 -1
- package/src/host/bridge-host.ts +65 -0
- package/src/host/fetch-proxy-handler.ts +52 -23
- package/src/host/fetch-proxy-overrides.ts +5 -1
- package/src/host/fetch-proxy-transport.ts +82 -0
- package/src/swift-compile.ts +8 -2
- package/src/swift-submit.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -917,8 +917,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
917
917
|
}
|
|
918
918
|
] : compileTargets(input);
|
|
919
919
|
const files = /* @__PURE__ */ new Map();
|
|
920
|
+
const modulePlan = (0, import_node_crypto2.createHash)("sha256").update(
|
|
921
|
+
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
922
|
+
);
|
|
923
|
+
if (!distribution) {
|
|
924
|
+
modulePlan.update((0, import_node_fs2.readFileSync)(import_node_path2.default.join(moduleRoot, "Package.swift")));
|
|
925
|
+
}
|
|
920
926
|
const moduleFiles = `
|
|
921
|
-
// sootsim-swift files ${
|
|
927
|
+
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
922
928
|
`;
|
|
923
929
|
if (targets.length === 0) {
|
|
924
930
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import { execFile as execFile2 } from "node:child_process";
|
|
@@ -877,8 +877,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
877
877
|
}
|
|
878
878
|
] : compileTargets(input);
|
|
879
879
|
const files = /* @__PURE__ */ new Map();
|
|
880
|
+
const modulePlan = createHash2("sha256").update(
|
|
881
|
+
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
882
|
+
);
|
|
883
|
+
if (!distribution) {
|
|
884
|
+
modulePlan.update(readFileSync2(path2.join(moduleRoot, "Package.swift")));
|
|
885
|
+
}
|
|
880
886
|
const moduleFiles = `
|
|
881
|
-
// sootsim-swift files ${
|
|
887
|
+
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
882
888
|
`;
|
|
883
889
|
if (targets.length === 0) {
|
|
884
890
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -51,7 +51,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
51
51
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
52
52
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
53
53
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
54
|
-
var SWIFT_HOST_ABI =
|
|
54
|
+
var SWIFT_HOST_ABI = 17;
|
|
55
55
|
var POLL_INTERVAL_MS = 1500;
|
|
56
56
|
function swiftNativeEntry(native, file) {
|
|
57
57
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-submit.ts
|
|
4
4
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
@@ -12,7 +12,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
12
12
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
13
13
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
14
14
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
15
|
-
var SWIFT_HOST_ABI =
|
|
15
|
+
var SWIFT_HOST_ABI = 17;
|
|
16
16
|
var POLL_INTERVAL_MS = 1500;
|
|
17
17
|
function swiftNativeEntry(native, file) {
|
|
18
18
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } 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.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } 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.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -948,8 +948,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
948
948
|
}
|
|
949
949
|
] : compileTargets(input);
|
|
950
950
|
const files = /* @__PURE__ */ new Map();
|
|
951
|
+
const modulePlan = (0, import_node_crypto2.createHash)("sha256").update(
|
|
952
|
+
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
953
|
+
);
|
|
954
|
+
if (!distribution) {
|
|
955
|
+
modulePlan.update((0, import_node_fs2.readFileSync)(import_node_path2.default.join(moduleRoot, "Package.swift")));
|
|
956
|
+
}
|
|
951
957
|
const moduleFiles = `
|
|
952
|
-
// sootsim-swift files ${
|
|
958
|
+
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
953
959
|
`;
|
|
954
960
|
if (targets.length === 0) {
|
|
955
961
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -1882,7 +1888,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
1882
1888
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
1883
1889
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
1884
1890
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
1885
|
-
var SWIFT_HOST_ABI =
|
|
1891
|
+
var SWIFT_HOST_ABI = 17;
|
|
1886
1892
|
var POLL_INTERVAL_MS = 1500;
|
|
1887
1893
|
function swiftNativeEntry(native, file) {
|
|
1888
1894
|
return {
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peachsim",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.710",
|
|
4
4
|
"description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
|
|
5
5
|
"author": "Tamagui LLC",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -321,6 +321,7 @@
|
|
|
321
321
|
},
|
|
322
322
|
"dependencies": {
|
|
323
323
|
"@expo/plist": "^0.5.4",
|
|
324
|
+
"@peculiar/x509": "1.14.3",
|
|
324
325
|
"@sucrase/jest-plugin": "3.0.0",
|
|
325
326
|
"jiti": "2.7.0",
|
|
326
327
|
"magic-string": "^0.30.21",
|
package/src/host/bridge-host.ts
CHANGED
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
isAppApiRequestUrl,
|
|
55
55
|
isFetchProxyRequestUrl,
|
|
56
56
|
} from './fetch-proxy-handler.ts'
|
|
57
|
+
import { startFetchProxyTransport } from './fetch-proxy-transport.ts'
|
|
57
58
|
import { openUrl as openUrlInBrowser, type OpenUrlOptions } from './open-url.ts'
|
|
58
59
|
import { PlaneHost } from './plane-host.ts'
|
|
59
60
|
import {
|
|
@@ -173,6 +174,26 @@ interface BridgeCliLease {
|
|
|
173
174
|
cliIdentityKey: string
|
|
174
175
|
cliLabel?: string
|
|
175
176
|
expiresAt: number
|
|
177
|
+
// owning session's process group, sent by the cli in bridge:hello. a cli
|
|
178
|
+
// lease whose group no longer exists is free (getActiveLease) even before
|
|
179
|
+
// the TTL burns out, so a dead session never blocks others. absent for
|
|
180
|
+
// user-active leases and clis that could not read their ancestry.
|
|
181
|
+
ownerPgid?: number
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// true when the process group still has members. ESRCH = the group is gone;
|
|
185
|
+
// EPERM = alive but owned by another user, which still counts as alive. any
|
|
186
|
+
// other failure (or a bogus id) resolves alive, so a lease is only ever freed
|
|
187
|
+
// on positive proof its owner session is gone — never kill(-1) (everyone).
|
|
188
|
+
function isProcessGroupAlive(pgid: number): boolean {
|
|
189
|
+
if (!Number.isInteger(pgid) || pgid <= 1) return true
|
|
190
|
+
try {
|
|
191
|
+
process.kill(-pgid, 0)
|
|
192
|
+
return true
|
|
193
|
+
} catch (error) {
|
|
194
|
+
const code = error && typeof error === 'object' ? Reflect.get(error, 'code') : null
|
|
195
|
+
return code !== 'ESRCH'
|
|
196
|
+
}
|
|
176
197
|
}
|
|
177
198
|
|
|
178
199
|
// interactive commands change app state and must respect the lease.
|
|
@@ -373,6 +394,9 @@ export class SootSimBridgeHost {
|
|
|
373
394
|
private openUrlHandler?: (url: string, options?: OpenUrlOptions) => Promise<void> | void
|
|
374
395
|
private httpServer: ReturnType<typeof createServer> | null = null
|
|
375
396
|
private wss: WebSocketServer | null = null
|
|
397
|
+
private fetchProxyTransport: Awaited<
|
|
398
|
+
ReturnType<typeof startFetchProxyTransport>
|
|
399
|
+
> | null = null
|
|
376
400
|
private nextCommandId = 1
|
|
377
401
|
private nextSimNumber = 0xa1
|
|
378
402
|
private sims = new Map<string, BridgeSimConnection>()
|
|
@@ -383,6 +407,7 @@ export class SootSimBridgeHost {
|
|
|
383
407
|
private cliLastCommandAt = new Map<WebSocket, number>()
|
|
384
408
|
private cliIdentityKeyBySocket = new Map<WebSocket, string>()
|
|
385
409
|
private cliLabelBySocket = new Map<WebSocket, string>()
|
|
410
|
+
private cliOwnerPgidBySocket = new Map<WebSocket, number>()
|
|
386
411
|
private restorableSims = new Map<string, BridgeRestorableSimState>()
|
|
387
412
|
private nextCliFallbackId = 1
|
|
388
413
|
private cliIdleTimer: NodeJS.Timeout | null = null
|
|
@@ -501,6 +526,12 @@ export class SootSimBridgeHost {
|
|
|
501
526
|
`ws bridge bound to port ${candidate} (preferred ${this.preferredPort} was taken)\n`,
|
|
502
527
|
)
|
|
503
528
|
}
|
|
529
|
+
try {
|
|
530
|
+
this.fetchProxyTransport = await startFetchProxyTransport()
|
|
531
|
+
} catch (error) {
|
|
532
|
+
await this.close()
|
|
533
|
+
throw error
|
|
534
|
+
}
|
|
504
535
|
this.afterBind()
|
|
505
536
|
return boundPort
|
|
506
537
|
} catch (err: unknown) {
|
|
@@ -877,6 +908,7 @@ export class SootSimBridgeHost {
|
|
|
877
908
|
this.cliLastCommandAt.delete(ws)
|
|
878
909
|
this.cliIdentityKeyBySocket.delete(ws)
|
|
879
910
|
this.cliLabelBySocket.delete(ws)
|
|
911
|
+
this.cliOwnerPgidBySocket.delete(ws)
|
|
880
912
|
for (const [sentId, entry] of this.cliBySentId) {
|
|
881
913
|
if (entry.ws === ws) this.cliBySentId.delete(sentId)
|
|
882
914
|
}
|
|
@@ -894,6 +926,15 @@ export class SootSimBridgeHost {
|
|
|
894
926
|
if (typeof msg.cliLabel === 'string' && msg.cliLabel.trim()) {
|
|
895
927
|
this.cliLabelBySocket.set(ws, msg.cliLabel.trim())
|
|
896
928
|
}
|
|
929
|
+
if (
|
|
930
|
+
typeof msg.cliOwnerPgid === 'number' &&
|
|
931
|
+
Number.isInteger(msg.cliOwnerPgid) &&
|
|
932
|
+
msg.cliOwnerPgid > 1
|
|
933
|
+
) {
|
|
934
|
+
this.cliOwnerPgidBySocket.set(ws, msg.cliOwnerPgid)
|
|
935
|
+
} else {
|
|
936
|
+
this.cliOwnerPgidBySocket.delete(ws)
|
|
937
|
+
}
|
|
897
938
|
// same-identity cli sockets are allowed to coexist. this avoids
|
|
898
939
|
// self-disconnects when agent tooling issues multiple commands
|
|
899
940
|
// in parallel from the same logical identity key.
|
|
@@ -1064,6 +1105,7 @@ export class SootSimBridgeHost {
|
|
|
1064
1105
|
this.cliLastCommandAt.delete(ws)
|
|
1065
1106
|
this.cliIdentityKeyBySocket.delete(ws)
|
|
1066
1107
|
this.cliLabelBySocket.delete(ws)
|
|
1108
|
+
this.cliOwnerPgidBySocket.delete(ws)
|
|
1067
1109
|
for (const [sentId, entry] of this.cliBySentId) {
|
|
1068
1110
|
if (entry.ws === ws) this.cliBySentId.delete(sentId)
|
|
1069
1111
|
}
|
|
@@ -1466,6 +1508,14 @@ export class SootSimBridgeHost {
|
|
|
1466
1508
|
* non-upgrade routes that don't match serve index.html (SPA behavior) so
|
|
1467
1509
|
* electron's webContents can navigate freely inside the runtime. */
|
|
1468
1510
|
private handleHttpRequest(req: IncomingMessage, res: ServerResponse) {
|
|
1511
|
+
if (req.url === '/__peach/fetch-transport') {
|
|
1512
|
+
res.writeHead(200, {
|
|
1513
|
+
'Content-Type': 'application/json',
|
|
1514
|
+
'Cache-Control': 'no-store',
|
|
1515
|
+
})
|
|
1516
|
+
res.end(JSON.stringify(this.fetchProxyTransport?.descriptor))
|
|
1517
|
+
return
|
|
1518
|
+
}
|
|
1469
1519
|
// cross-origin isolation — without this, Electron / Chromium refuses
|
|
1470
1520
|
// `SharedArrayBuffer`, and the engine's render-worker crashes on boot
|
|
1471
1521
|
// ("render worker crashed during boot" / "app:one surface registration
|
|
@@ -2173,6 +2223,8 @@ export class SootSimBridgeHost {
|
|
|
2173
2223
|
})
|
|
2174
2224
|
} catch {}
|
|
2175
2225
|
}
|
|
2226
|
+
await this.fetchProxyTransport?.close()
|
|
2227
|
+
this.fetchProxyTransport = null
|
|
2176
2228
|
this.effectivePort = 0
|
|
2177
2229
|
this.startedAt = 0
|
|
2178
2230
|
this.agentHost.close()
|
|
@@ -2250,6 +2302,18 @@ export class SootSimBridgeHost {
|
|
|
2250
2302
|
sim.cliLease = undefined
|
|
2251
2303
|
return null
|
|
2252
2304
|
}
|
|
2305
|
+
// a cli lease whose owning process group is gone is free: the session
|
|
2306
|
+
// that held it can never renew, so holding the sim until the TTL burns
|
|
2307
|
+
// out only blocks live callers behind a dead owner. user-active leases
|
|
2308
|
+
// carry no group and keep TTL-only expiry.
|
|
2309
|
+
if (
|
|
2310
|
+
lease.kind === 'cli' &&
|
|
2311
|
+
lease.ownerPgid !== undefined &&
|
|
2312
|
+
!isProcessGroupAlive(lease.ownerPgid)
|
|
2313
|
+
) {
|
|
2314
|
+
sim.cliLease = undefined
|
|
2315
|
+
return null
|
|
2316
|
+
}
|
|
2253
2317
|
return lease
|
|
2254
2318
|
}
|
|
2255
2319
|
|
|
@@ -2308,6 +2372,7 @@ export class SootSimBridgeHost {
|
|
|
2308
2372
|
cliIdentityKey,
|
|
2309
2373
|
cliLabel,
|
|
2310
2374
|
expiresAt: now + SootSimBridgeHost.CLI_LEASE_TTL_MS,
|
|
2375
|
+
ownerPgid: this.cliOwnerPgidBySocket.get(ws),
|
|
2311
2376
|
}
|
|
2312
2377
|
sim.cliLease = lease
|
|
2313
2378
|
return { granted: true, lease, bootedCount }
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import http, { type IncomingMessage, type ServerResponse } from 'http'
|
|
27
27
|
import https from 'https'
|
|
28
|
+
import { Http2ServerRequest, type Http2ServerResponse } from 'node:http2'
|
|
28
29
|
import { finished, pipeline } from 'stream/promises'
|
|
29
30
|
import { isLoopbackHost, normalizeHostname } from '../backend-origin.ts'
|
|
30
31
|
import {
|
|
@@ -33,6 +34,9 @@ import {
|
|
|
33
34
|
resolveFetchProxyTargetUrl,
|
|
34
35
|
} from './fetch-proxy-overrides.ts'
|
|
35
36
|
|
|
37
|
+
type FetchProxyRequest = IncomingMessage | Http2ServerRequest
|
|
38
|
+
type FetchProxyResponse = ServerResponse | Http2ServerResponse
|
|
39
|
+
|
|
36
40
|
// every proxied request reuses one pooled, keep-alive connection per upstream
|
|
37
41
|
// host instead of opening (and TLS-handshaking) a fresh socket per request.
|
|
38
42
|
// node's default global agents have `keepAlive: false`, so without this every
|
|
@@ -51,10 +55,7 @@ function fetchProxyAgentFor(targetUrl: URL): http.Agent | https.Agent {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
const FETCH_PROXY_CORS_HEADERS: Record<string, string> = {
|
|
54
|
-
'access-control-allow-
|
|
55
|
-
'access-control-allow-methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
56
|
-
'access-control-allow-headers': '*',
|
|
57
|
-
'access-control-expose-headers': '*',
|
|
58
|
+
'access-control-allow-methods': 'GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
58
59
|
'access-control-max-age': '3600',
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -77,10 +78,32 @@ function loopbackTlsOptions(targetUrl: URL): { rejectUnauthorized?: boolean } {
|
|
|
77
78
|
return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
function applyFetchProxyCors(res:
|
|
81
|
+
function applyFetchProxyCors(req: FetchProxyRequest, res: FetchProxyResponse) {
|
|
81
82
|
for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
|
|
82
83
|
res.setHeader(key, value)
|
|
83
84
|
}
|
|
85
|
+
// the data listener is cross-origin, including for fonts with credentials.
|
|
86
|
+
// wildcard origins and exposed headers do not apply to credentialed fetches.
|
|
87
|
+
res.setHeader('access-control-allow-origin', req.headers.origin ?? '*')
|
|
88
|
+
res.setHeader('access-control-allow-credentials', 'true')
|
|
89
|
+
res.setHeader(
|
|
90
|
+
'access-control-allow-headers',
|
|
91
|
+
req.headers['access-control-request-headers'] ?? '*',
|
|
92
|
+
)
|
|
93
|
+
res.setHeader(
|
|
94
|
+
'access-control-expose-headers',
|
|
95
|
+
[
|
|
96
|
+
...Object.keys(res.getHeaders()).filter(
|
|
97
|
+
(name) => !name.startsWith('access-control-'),
|
|
98
|
+
),
|
|
99
|
+
'x-sootsim-set-cookie',
|
|
100
|
+
].join(', '),
|
|
101
|
+
)
|
|
102
|
+
const vary = res.getHeader('vary')
|
|
103
|
+
res.setHeader(
|
|
104
|
+
'vary',
|
|
105
|
+
vary ? `${Array.isArray(vary) ? vary.join(', ') : vary}, Origin` : 'Origin',
|
|
106
|
+
)
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
export function buildFetchProxyHeaders(
|
|
@@ -124,12 +147,12 @@ export function isAppApiRequestUrl(rawUrl: string | undefined): boolean {
|
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
export async function handleFetchProxyRequest(
|
|
127
|
-
req:
|
|
128
|
-
res:
|
|
150
|
+
req: FetchProxyRequest,
|
|
151
|
+
res: FetchProxyResponse,
|
|
129
152
|
): Promise<void> {
|
|
130
153
|
if (req.method === 'OPTIONS') {
|
|
131
|
-
applyFetchProxyCors(res)
|
|
132
|
-
res.
|
|
154
|
+
applyFetchProxyCors(req, res)
|
|
155
|
+
res.statusCode = 204
|
|
133
156
|
res.end()
|
|
134
157
|
return
|
|
135
158
|
}
|
|
@@ -137,8 +160,9 @@ export async function handleFetchProxyRequest(
|
|
|
137
160
|
const params = new URLSearchParams((req.url || '').split('?')[1] || '')
|
|
138
161
|
const targetUrl = params.get('url')
|
|
139
162
|
if (!targetUrl) {
|
|
140
|
-
applyFetchProxyCors(res)
|
|
141
|
-
res.
|
|
163
|
+
applyFetchProxyCors(req, res)
|
|
164
|
+
res.statusCode = 400
|
|
165
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
142
166
|
res.end('missing url param')
|
|
143
167
|
return
|
|
144
168
|
}
|
|
@@ -147,8 +171,9 @@ export async function handleFetchProxyRequest(
|
|
|
147
171
|
try {
|
|
148
172
|
upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl))
|
|
149
173
|
} catch {
|
|
150
|
-
applyFetchProxyCors(res)
|
|
151
|
-
res.
|
|
174
|
+
applyFetchProxyCors(req, res)
|
|
175
|
+
res.statusCode = 400
|
|
176
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
152
177
|
res.end('invalid url param')
|
|
153
178
|
return
|
|
154
179
|
}
|
|
@@ -242,7 +267,7 @@ export async function handleFetchProxyRequest(
|
|
|
242
267
|
}
|
|
243
268
|
res.setHeader(key, value)
|
|
244
269
|
}
|
|
245
|
-
applyFetchProxyCors(res)
|
|
270
|
+
applyFetchProxyCors(req, res)
|
|
246
271
|
const setCookie = proxyRes.headers['set-cookie'] ?? []
|
|
247
272
|
if (setCookie.length > 0) {
|
|
248
273
|
res.setHeader(
|
|
@@ -297,19 +322,21 @@ export async function handleFetchProxyRequest(
|
|
|
297
322
|
// a cold build) and hands guest code a Response where React Native rejects.
|
|
298
323
|
// close the connection itself: bun's node:http answers a destroyed
|
|
299
324
|
// response that never sent headers with an empty 200.
|
|
300
|
-
req.
|
|
325
|
+
if (req instanceof Http2ServerRequest) req.stream.destroy()
|
|
326
|
+
else req.socket.destroy()
|
|
301
327
|
}
|
|
302
328
|
}
|
|
303
329
|
|
|
304
330
|
export async function handleBundleProxyRequest(
|
|
305
|
-
req:
|
|
306
|
-
res:
|
|
331
|
+
req: FetchProxyRequest,
|
|
332
|
+
res: FetchProxyResponse,
|
|
307
333
|
): Promise<void> {
|
|
308
334
|
const params = new URLSearchParams((req.url || '').split('?')[1] || '')
|
|
309
335
|
const target = params.get('url')
|
|
310
336
|
if (!target) {
|
|
311
|
-
applyFetchProxyCors(res)
|
|
312
|
-
res.
|
|
337
|
+
applyFetchProxyCors(req, res)
|
|
338
|
+
res.statusCode = 400
|
|
339
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
313
340
|
res.end('bundle-proxy: missing url query param')
|
|
314
341
|
return
|
|
315
342
|
}
|
|
@@ -318,15 +345,17 @@ export async function handleBundleProxyRequest(
|
|
|
318
345
|
try {
|
|
319
346
|
targetUrl = new URL(target)
|
|
320
347
|
} catch {
|
|
321
|
-
applyFetchProxyCors(res)
|
|
322
|
-
res.
|
|
348
|
+
applyFetchProxyCors(req, res)
|
|
349
|
+
res.statusCode = 400
|
|
350
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
323
351
|
res.end('bundle-proxy: invalid url')
|
|
324
352
|
return
|
|
325
353
|
}
|
|
326
354
|
|
|
327
355
|
if (!isLoopbackHost(targetUrl.hostname)) {
|
|
328
|
-
applyFetchProxyCors(res)
|
|
329
|
-
res.
|
|
356
|
+
applyFetchProxyCors(req, res)
|
|
357
|
+
res.statusCode = 403
|
|
358
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
330
359
|
res.end('bundle-proxy: only loopback targets allowed')
|
|
331
360
|
return
|
|
332
361
|
}
|
|
@@ -125,7 +125,11 @@ export function buildFetchProxyUpstreamHeaders(
|
|
|
125
125
|
for (const [rawKey, value] of requestHeaders) {
|
|
126
126
|
const key = rawKey.toLowerCase()
|
|
127
127
|
if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value
|
|
128
|
-
if (
|
|
128
|
+
if (
|
|
129
|
+
key.startsWith(':') ||
|
|
130
|
+
STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) ||
|
|
131
|
+
key.startsWith('x-forwarded-')
|
|
132
|
+
) {
|
|
129
133
|
continue
|
|
130
134
|
}
|
|
131
135
|
headers[key] = value
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto'
|
|
2
|
+
import { createSecureServer, type ServerHttp2Session } from 'node:http2'
|
|
3
|
+
import { SubjectAlternativeNameExtension, X509CertificateGenerator } from '@peculiar/x509'
|
|
4
|
+
import {
|
|
5
|
+
handleBundleProxyRequest,
|
|
6
|
+
handleFetchProxyRequest,
|
|
7
|
+
isBundleProxyRequestUrl,
|
|
8
|
+
isFetchProxyRequestUrl,
|
|
9
|
+
} from './fetch-proxy-handler.ts'
|
|
10
|
+
|
|
11
|
+
// image bytes use multiplexed tls streams. the websocket control server keeps
|
|
12
|
+
// its own listener, so image backpressure cannot consume its connection slots.
|
|
13
|
+
export async function startFetchProxyTransport() {
|
|
14
|
+
const algorithm = { name: 'ECDSA', namedCurve: 'P-256', hash: 'SHA-256' }
|
|
15
|
+
const keys = await crypto.subtle.generateKey(algorithm, true, ['sign', 'verify'])
|
|
16
|
+
const certificate = await X509CertificateGenerator.createSelfSigned(
|
|
17
|
+
{
|
|
18
|
+
serialNumber: randomBytes(16).toString('hex'),
|
|
19
|
+
name: 'CN=localhost',
|
|
20
|
+
notBefore: new Date(Date.now() - 60_000),
|
|
21
|
+
notAfter: new Date(Date.now() + 365 * 24 * 60 * 60_000),
|
|
22
|
+
signingAlgorithm: algorithm,
|
|
23
|
+
keys,
|
|
24
|
+
extensions: [
|
|
25
|
+
new SubjectAlternativeNameExtension([{ type: 'ip', value: '127.0.0.1' }]),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
crypto,
|
|
29
|
+
)
|
|
30
|
+
const privateKey = Buffer.from(await crypto.subtle.exportKey('pkcs8', keys.privateKey))
|
|
31
|
+
const spki = createHash('sha256')
|
|
32
|
+
.update(Buffer.from(await crypto.subtle.exportKey('spki', keys.publicKey)))
|
|
33
|
+
.digest('base64')
|
|
34
|
+
const sessions = new Set<ServerHttp2Session>()
|
|
35
|
+
const server = createSecureServer(
|
|
36
|
+
{
|
|
37
|
+
cert: certificate.toString('pem'),
|
|
38
|
+
key: `-----BEGIN PRIVATE KEY-----\n${privateKey
|
|
39
|
+
.toString('base64')
|
|
40
|
+
.match(/.{1,64}/g)
|
|
41
|
+
?.join('\n')}\n-----END PRIVATE KEY-----\n`,
|
|
42
|
+
settings: { maxConcurrentStreams: 256 },
|
|
43
|
+
},
|
|
44
|
+
(req, res) => {
|
|
45
|
+
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin')
|
|
46
|
+
res.setHeader('Timing-Allow-Origin', '*')
|
|
47
|
+
const handler = isBundleProxyRequestUrl(req.url)
|
|
48
|
+
? handleBundleProxyRequest
|
|
49
|
+
: isFetchProxyRequestUrl(req.url)
|
|
50
|
+
? handleFetchProxyRequest
|
|
51
|
+
: null
|
|
52
|
+
if (!handler) {
|
|
53
|
+
res.writeHead(404)
|
|
54
|
+
res.end()
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
void handler(req, res).catch(() => res.destroy())
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
server.on('session', (session) => {
|
|
61
|
+
sessions.add(session)
|
|
62
|
+
session.once('close', () => sessions.delete(session))
|
|
63
|
+
session.on('error', () => session.destroy())
|
|
64
|
+
})
|
|
65
|
+
await new Promise<void>((resolve, reject) => {
|
|
66
|
+
server.once('error', reject)
|
|
67
|
+
server.listen(0, '127.0.0.1', () => {
|
|
68
|
+
server.off('error', reject)
|
|
69
|
+
resolve()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
const address = server.address()
|
|
73
|
+
if (!address || typeof address === 'string')
|
|
74
|
+
throw new Error('fetch proxy has no address')
|
|
75
|
+
return {
|
|
76
|
+
descriptor: { origin: `https://127.0.0.1:${address.port}`, spki },
|
|
77
|
+
async close() {
|
|
78
|
+
for (const session of sessions) session.destroy()
|
|
79
|
+
await new Promise<void>((resolve) => server.close(() => resolve()))
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/swift-compile.ts
CHANGED
|
@@ -1010,8 +1010,14 @@ export function writeSwiftProject(
|
|
|
1010
1010
|
// swiftpm plans a build root's build once and reuses the plan until a
|
|
1011
1011
|
// manifest changes, so a file added to the module would never compile
|
|
1012
1012
|
// there (RAN: a broken new UIKitCore file built "complete" in 0.1s). the
|
|
1013
|
-
// module's file list
|
|
1014
|
-
const
|
|
1013
|
+
// module's file list and package flags replan when either changes.
|
|
1014
|
+
const modulePlan = createHash('sha256').update(
|
|
1015
|
+
swiftModuleInputFiles(moduleRoot).join('\n'),
|
|
1016
|
+
)
|
|
1017
|
+
if (!distribution) {
|
|
1018
|
+
modulePlan.update(readFileSync(path.join(moduleRoot, 'Package.swift')))
|
|
1019
|
+
}
|
|
1020
|
+
const moduleFiles = `\n// sootsim-swift files ${modulePlan.digest('hex').slice(0, 16)}\n`
|
|
1015
1021
|
if (targets.length === 0) {
|
|
1016
1022
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1017
1023
|
if (file === 'Package.swift') continue
|
package/src/swift-submit.ts
CHANGED
|
@@ -62,8 +62,9 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
|
|
|
62
62
|
* 14: `permission_status` answers notifications (2) as UNAuthorizationStatus.
|
|
63
63
|
* 15: `rnx_display_link_active` asks the host to tick on every display frame.
|
|
64
64
|
* 16: `peach_expo_call` uses the tagged Expo wire and coded exception replies.
|
|
65
|
+
* 17: CoreLocation reads location services and shares permission and device fixes.
|
|
65
66
|
*/
|
|
66
|
-
export const SWIFT_HOST_ABI =
|
|
67
|
+
export const SWIFT_HOST_ABI = 17
|
|
67
68
|
|
|
68
69
|
export interface SwiftImageUpload {
|
|
69
70
|
/** the raster file picked for the asset (has the extension). */
|