peachsim 0.1.1881 → 0.1.1887
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 +11 -10
- package/cli/commands/reset.ts +1 -1
- package/cli/native-input.ts +1 -1
- package/cli/outbound-endpoints.ts +1 -1
- package/detox/index.ts +62 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.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/bundle-channel.cjs +9079 -4305
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +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/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +35 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +8609 -3976
- package/dist-lib/expo-swift-metadata.cjs +5 -1
- package/dist-lib/expo-swift-metadata.mjs +5 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +9894 -5149
- package/dist-lib/host/fetch-proxy-handler.cjs +93 -13
- package/dist-lib/host/fetch-proxy-overrides.cjs +10 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +8 -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 +538 -120
- 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 +536 -118
- package/dist-lib/native-app-identity-project.cjs +408 -72
- package/dist-lib/native-app-identity-project.mjs +739 -375
- package/dist-lib/native-app-identity.cjs +37 -1
- package/dist-lib/native-app-identity.mjs +36 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.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/public-origins-lib-esm.json +61 -28
- package/dist-lib/public-origins-lib.json +250 -92
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.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 +16568 -11674
- package/dist-lib/swift-compile.cjs +6874 -2537
- package/dist-lib/swift-compile.mjs +6207 -1866
- package/dist-lib/swift-package.cjs +20 -3
- package/dist-lib/swift-package.mjs +20 -3
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +19 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +8753 -4124
- package/dist-lib/vite.cjs +93 -13
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +2 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +10 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +1 -1
- package/dist-types/packages/sootsim-swift/src/securityHostContract.d.ts +10 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHost.h +555 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +6 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURLProtocol.h +0 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarButtonItemBadge.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarMinimization.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIScrollView.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISearchTab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabAccessory.h +2 -2
- package/sdk/ios/usr/include/os/activity.h +534 -0
- package/sdk/ios/usr/include/os.modulemap +15 -0
- package/sdk/ios/wasm/include/fcntl.h +16 -0
- package/sdk/ios/wasm/include/string.h +5 -0
- package/sdk/native-hashes.json +1 -1
- package/src/dns-over-https.ts +61 -9
- package/src/expo-swift-bundle.ts +2 -7
- package/src/expo-swift-host.ts +11 -3
- package/src/host/fetch-proxy-handler.ts +51 -2
- package/src/host/fetch-proxy-overrides.ts +4 -0
- package/src/host/hostname-resolver.ts +9 -5
- package/src/native-app-identity-project.ts +13 -2
- package/src/native-app-identity.ts +47 -0
- package/src/nitro-adapter.lock.json +260 -260
- package/src/nitro-bundle.ts +7 -10
- package/src/nitro-superset.lock.json +4 -4
- package/src/podspec-sources.ts +20 -0
- package/src/storageSnapshotContract.ts +20 -1
- package/src/swift-compile.ts +409 -77
- package/src/swift-compiler-digest.ts +15 -0
- package/src/swift-coverage/xcode-packages.ts +3 -2
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-guest-archive.ts +153 -0
- package/src/swift-guest-compile.ts +449 -0
- package/src/swift-guest-image-ledger.ts +656 -0
- package/src/swift-guest-link-plan.ts +52 -0
- package/src/swift-guest-link.ts +1414 -0
- package/src/swift-guest-linked-spans.ts +338 -0
- package/src/swift-guest-manifest.ts +141 -0
- package/src/swift-guest-projection-storage.ts +310 -0
- package/src/swift-guest-projection.ts +252 -0
- package/src/swift-guest-runtime-plan.ts +834 -0
- package/src/swift-guest-source-inputs.ts +427 -0
- package/src/swift-guest-source-plan.ts +279 -0
- package/src/swift-host.ts +157 -36
- package/src/swift-icu.ts +60 -18
- package/src/swift-link-roots.ts +27 -50
- package/src/swift-package-manifest.ts +34 -18
- package/src/swift-package.ts +32 -2
- package/src/swift-packages.ts +138 -17
- package/src/swift-runtime-products.ts +73 -0
- package/src/swift-shared-sdk.ts +1 -1
- package/src/swift-submit.ts +15 -3
- package/src/swift-toolchain.ts +18 -0
- package/src/swift-wasm-prune.ts +313 -14
- package/src/swiftContract.ts +83 -0
- package/src/swiftRuntimeProductContract.ts +85 -45
- package/src/turbo-bundle.ts +1 -1
- package/src/turbo-codegen-intake.ts +10 -3
- package/src/turbo-runtime.lock.json +23 -23
- package/src/wasm-optimize.ts +16 -4
- package/src/xcode-project.ts +142 -14
package/src/expo-swift-bundle.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// release publishers use the same app compiler as local launches, then carry
|
|
2
2
|
// its immutable native assets beside the javascript bundle.
|
|
3
3
|
import { compileExpoSwiftModules } from './expo-swift-host'
|
|
4
|
+
import { swiftIcuBundleAsset } from './swift-icu'
|
|
4
5
|
import type { ExpoSwiftCompilationResult } from './expoSwiftContract'
|
|
5
6
|
|
|
6
7
|
export interface ExpoSwiftBundle {
|
|
@@ -22,13 +23,7 @@ export async function buildExpoSwiftBundle(
|
|
|
22
23
|
bytes: artifact.bytes,
|
|
23
24
|
contentType: 'application/wasm',
|
|
24
25
|
})
|
|
25
|
-
if ('gzip' in artifact.icu)
|
|
26
|
-
assets.push({
|
|
27
|
-
path: `__peach/swift-icu/${artifact.icu.sha256}`,
|
|
28
|
-
bytes: artifact.icu.gzip,
|
|
29
|
-
contentType: 'application/gzip',
|
|
30
|
-
})
|
|
31
|
-
}
|
|
26
|
+
if ('gzip' in artifact.icu) assets.push(await swiftIcuBundleAsset(artifact.icu))
|
|
32
27
|
},
|
|
33
28
|
)
|
|
34
29
|
if (!metadata) return null
|
package/src/expo-swift-host.ts
CHANGED
|
@@ -656,16 +656,23 @@ function enrichInstalledUnits(
|
|
|
656
656
|
const importedTargets = swiftTargetDependencies(input.files, installedTargets)
|
|
657
657
|
const byPath = [...installedTargets].sort((a, b) => b.path.length - a.path.length)
|
|
658
658
|
const map = (file: string) => {
|
|
659
|
-
const target = byPath.find(
|
|
659
|
+
const target = byPath.find(
|
|
660
|
+
(target) => file === target.path || file.startsWith(`${target.path}/`),
|
|
661
|
+
)
|
|
660
662
|
return target
|
|
661
|
-
?
|
|
663
|
+
? file === target.path
|
|
664
|
+
? `Sources/${target.name}`
|
|
665
|
+
: `Sources/${target.name}/${file.slice(target.path.length + 1).replace(/^(?:.*\/)?node_modules\//, '')}`
|
|
662
666
|
: file
|
|
663
667
|
}
|
|
664
668
|
for (const unit of units) {
|
|
665
669
|
if (bridgeNamespaces.size > 0 && !bridgeNamespaces.has(unit.namespace)) continue
|
|
666
670
|
// native modules resolve the installed workspace resource products through Bundle.
|
|
667
671
|
unit.resources = input.resources
|
|
668
|
-
unit.resourceBundles = input.resourceBundles
|
|
672
|
+
unit.resourceBundles = input.resourceBundles?.map((bundle) => ({
|
|
673
|
+
...bundle,
|
|
674
|
+
sourcePath: map(bundle.sourcePath),
|
|
675
|
+
}))
|
|
669
676
|
unit.frameworks = [...new Set([...unit.frameworks, ...binaryFrameworks])]
|
|
670
677
|
const target = targetByName.get(unit.namespace)
|
|
671
678
|
if (!target) {
|
|
@@ -1722,6 +1729,7 @@ function targetSettings(units: ExpoSwiftSourceUnit[]) {
|
|
|
1722
1729
|
...settings.get(unit.namespace),
|
|
1723
1730
|
languageMode: unit.swiftLanguageMode,
|
|
1724
1731
|
mainActorIsolation: settings.get(unit.namespace)?.mainActorIsolation ?? false,
|
|
1732
|
+
resources: settings.get(unit.namespace)?.resources ?? false,
|
|
1725
1733
|
})
|
|
1726
1734
|
}
|
|
1727
1735
|
return settings
|
|
@@ -42,6 +42,8 @@ import {
|
|
|
42
42
|
FETCH_PROXY_RESPONSE_URL_HEADER,
|
|
43
43
|
FETCH_PROXY_NATIVE_COOKIE_HEADER,
|
|
44
44
|
FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER,
|
|
45
|
+
FETCH_PROXY_TLS_MINIMUM_HEADER,
|
|
46
|
+
FETCH_PROXY_TLS_ENFORCED_HEADER,
|
|
45
47
|
nativeCookieHopHeader,
|
|
46
48
|
isNativeCookieRedirect,
|
|
47
49
|
nodeRequestHeaderEntries,
|
|
@@ -55,6 +57,7 @@ import {
|
|
|
55
57
|
import { projectLoopbackPort, projectLoopbackUrl } from './loopback-ports.ts'
|
|
56
58
|
import { authorizeNetwork, NetworkPolicyDeniedError } from './network-policy.ts'
|
|
57
59
|
import { forwardRolldownBundleResponse } from './rolldown-bundle-forward.ts'
|
|
60
|
+
import type { SecureVersion } from 'node:tls'
|
|
58
61
|
|
|
59
62
|
type FetchProxyRequest = IncomingMessage | Http2ServerRequest
|
|
60
63
|
type FetchProxyResponse = ServerResponse | Http2ServerResponse
|
|
@@ -71,6 +74,13 @@ type FetchProxyResponse = ServerResponse | Http2ServerResponse
|
|
|
71
74
|
// behind it.
|
|
72
75
|
const fetchProxyHttpAgent = new http.Agent({ keepAlive: true, maxSockets: 256 })
|
|
73
76
|
const fetchProxyHttpsAgent = new https.Agent({ keepAlive: true, maxSockets: 256 })
|
|
77
|
+
const tlsMinimumVersions = new Map<string, SecureVersion>([
|
|
78
|
+
['769', 'TLSv1'],
|
|
79
|
+
['770', 'TLSv1.1'],
|
|
80
|
+
['771', 'TLSv1.2'],
|
|
81
|
+
['772', 'TLSv1.3'],
|
|
82
|
+
])
|
|
83
|
+
const tlsMinimumAgents = new Map<SecureVersion, https.Agent>()
|
|
74
84
|
|
|
75
85
|
function fetchProxyAgentFor(targetUrl: URL): http.Agent | https.Agent {
|
|
76
86
|
return targetUrl.protocol === 'https:' ? fetchProxyHttpsAgent : fetchProxyHttpAgent
|
|
@@ -145,6 +155,8 @@ export function buildAppApiProxyHeaders(
|
|
|
145
155
|
if (
|
|
146
156
|
key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_HEADER ||
|
|
147
157
|
key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER ||
|
|
158
|
+
key.toLowerCase() === FETCH_PROXY_TLS_MINIMUM_HEADER ||
|
|
159
|
+
key.toLowerCase() === FETCH_PROXY_TLS_ENFORCED_HEADER ||
|
|
148
160
|
(reqHeaders[FETCH_PROXY_NATIVE_COOKIE_HEADER] !== undefined &&
|
|
149
161
|
key.toLowerCase() === 'cookie') ||
|
|
150
162
|
APP_API_HEADER_REWRITES.has(key.toLowerCase())
|
|
@@ -197,6 +209,8 @@ export async function handleFetchProxyRequest(
|
|
|
197
209
|
res: FetchProxyResponse,
|
|
198
210
|
): Promise<void> {
|
|
199
211
|
if (req.method === 'OPTIONS') {
|
|
212
|
+
if (new URL(req.url ?? '', 'http://localhost').searchParams.has('peachTlsProbe'))
|
|
213
|
+
res.setHeader(FETCH_PROXY_TLS_ENFORCED_HEADER, 'capable')
|
|
200
214
|
applyFetchProxyCors(req, res)
|
|
201
215
|
res.statusCode = 204
|
|
202
216
|
res.end()
|
|
@@ -250,6 +264,7 @@ export async function handleFetchProxyRequest(
|
|
|
250
264
|
lowerKey === 'transfer-encoding' ||
|
|
251
265
|
lowerKey === 'upgrade' ||
|
|
252
266
|
lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER ||
|
|
267
|
+
lowerKey === FETCH_PROXY_TLS_ENFORCED_HEADER ||
|
|
253
268
|
lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER ||
|
|
254
269
|
lowerKey.startsWith('access-control-')
|
|
255
270
|
) {
|
|
@@ -280,6 +295,17 @@ export function handleAppApiRequest(req: IncomingMessage, res: ServerResponse):
|
|
|
280
295
|
// param gets a 400.
|
|
281
296
|
|
|
282
297
|
const reqUrl = req.url || ''
|
|
298
|
+
if (
|
|
299
|
+
req.method === 'OPTIONS' &&
|
|
300
|
+
reqUrl.startsWith('/__app-api?') &&
|
|
301
|
+
new URL(reqUrl, 'http://localhost').searchParams.has('peachTlsProbe')
|
|
302
|
+
) {
|
|
303
|
+
res.setHeader(FETCH_PROXY_TLS_ENFORCED_HEADER, 'capable')
|
|
304
|
+
applyFetchProxyCors(req, res)
|
|
305
|
+
res.statusCode = 204
|
|
306
|
+
res.end()
|
|
307
|
+
return true
|
|
308
|
+
}
|
|
283
309
|
|
|
284
310
|
let targetPath = ''
|
|
285
311
|
let targetOrigin = ''
|
|
@@ -332,6 +358,7 @@ export function handleAppApiRequest(req: IncomingMessage, res: ServerResponse):
|
|
|
332
358
|
value === undefined ||
|
|
333
359
|
lowerKey === 'set-cookie' ||
|
|
334
360
|
lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER ||
|
|
361
|
+
lowerKey === FETCH_PROXY_TLS_ENFORCED_HEADER ||
|
|
335
362
|
lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER
|
|
336
363
|
) {
|
|
337
364
|
continue
|
|
@@ -401,6 +428,9 @@ async function proxyUpstream(
|
|
|
401
428
|
},
|
|
402
429
|
): Promise<void> {
|
|
403
430
|
const originalMethod = req.method || 'GET'
|
|
431
|
+
const minimumHeader = req.headers[FETCH_PROXY_TLS_MINIMUM_HEADER]
|
|
432
|
+
const minimumVersion =
|
|
433
|
+
typeof minimumHeader === 'string' ? tlsMinimumVersions.get(minimumHeader) : undefined
|
|
404
434
|
const proxy = async (
|
|
405
435
|
targetUrl: URL,
|
|
406
436
|
method: string,
|
|
@@ -457,8 +487,23 @@ async function proxyUpstream(
|
|
|
457
487
|
path: targetUrl.pathname + targetUrl.search,
|
|
458
488
|
method,
|
|
459
489
|
headers: targetHeaders,
|
|
460
|
-
|
|
461
|
-
|
|
490
|
+
...(minimumVersion && targetUrl.protocol === 'https:'
|
|
491
|
+
? {
|
|
492
|
+
agent: (() => {
|
|
493
|
+
let agent = tlsMinimumAgents.get(minimumVersion)
|
|
494
|
+
if (!agent) {
|
|
495
|
+
agent = new https.Agent({ keepAlive: true, maxSockets: 256 })
|
|
496
|
+
tlsMinimumAgents.set(minimumVersion, agent)
|
|
497
|
+
}
|
|
498
|
+
return agent
|
|
499
|
+
})(),
|
|
500
|
+
minVersion: minimumVersion,
|
|
501
|
+
rejectUnauthorized: true,
|
|
502
|
+
}
|
|
503
|
+
: {
|
|
504
|
+
agent: fetchProxyAgentFor(targetUrl),
|
|
505
|
+
...loopbackTlsOptions(targetUrl),
|
|
506
|
+
}),
|
|
462
507
|
},
|
|
463
508
|
(upstream) => {
|
|
464
509
|
responded = true
|
|
@@ -508,6 +553,8 @@ async function proxyUpstream(
|
|
|
508
553
|
redirectLimit: 10,
|
|
509
554
|
}
|
|
510
555
|
res.setHeader(FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER, nativeCookieHopHeader(hop))
|
|
556
|
+
if (minimumVersion && targetUrl.protocol === 'https:')
|
|
557
|
+
res.setHeader(FETCH_PROXY_TLS_ENFORCED_HEADER, minimumHeader!)
|
|
511
558
|
await route.respond(proxyRes, hopCookies)
|
|
512
559
|
if (isNativeCookieRedirect(hop)) res.removeHeader('location')
|
|
513
560
|
res.statusCode = isNativeCookieRedirect(hop) ? 200 : status
|
|
@@ -560,6 +607,8 @@ async function proxyUpstream(
|
|
|
560
607
|
let upstreamAnswered = false
|
|
561
608
|
let body: Buffer | undefined
|
|
562
609
|
try {
|
|
610
|
+
if (minimumHeader !== undefined && !minimumVersion)
|
|
611
|
+
throw new TypeError('unsupported URLSession TLS minimum')
|
|
563
612
|
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
564
613
|
const chunks: Buffer[] = []
|
|
565
614
|
for await (const chunk of req) {
|
|
@@ -36,6 +36,8 @@ export const FETCH_PROXY_RESPONSE_URL_HEADER = 'x-peach-response-url'
|
|
|
36
36
|
// that owner before another request, without retaining cookies on the host.
|
|
37
37
|
export const FETCH_PROXY_NATIVE_COOKIE_HEADER = 'x-peach-native-cookie'
|
|
38
38
|
export const FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER = 'x-peach-native-cookie-response'
|
|
39
|
+
export const FETCH_PROXY_TLS_MINIMUM_HEADER = 'x-peach-tls-minimum'
|
|
40
|
+
export const FETCH_PROXY_TLS_ENFORCED_HEADER = 'x-peach-tls-enforced'
|
|
39
41
|
|
|
40
42
|
export type NativeCookieHop = {
|
|
41
43
|
url: string
|
|
@@ -235,6 +237,8 @@ const STRIP_FETCH_PROXY_REQUEST_HEADERS = new Set([
|
|
|
235
237
|
FETCH_PROXY_NATIVE_USER_AGENT_HEADER,
|
|
236
238
|
FETCH_PROXY_NATIVE_COOKIE_HEADER,
|
|
237
239
|
FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER,
|
|
240
|
+
FETCH_PROXY_TLS_MINIMUM_HEADER,
|
|
241
|
+
FETCH_PROXY_TLS_ENFORCED_HEADER,
|
|
238
242
|
])
|
|
239
243
|
|
|
240
244
|
// the one upstream request header policy every fetch-proxy receiver applies
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { lookup } from 'node:dns/promises'
|
|
2
|
+
import { parseIpLiteral } from '../dns-over-https.ts'
|
|
2
3
|
import { authorizeNetwork } from './network-policy.ts'
|
|
3
4
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
4
5
|
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2'
|
|
@@ -22,10 +23,13 @@ export async function handleHostnameResolutionRequest(
|
|
|
22
23
|
res.end()
|
|
23
24
|
return
|
|
24
25
|
}
|
|
25
|
-
let
|
|
26
|
+
let addresses: number[][]
|
|
26
27
|
try {
|
|
27
|
-
await lookup(host)
|
|
28
|
-
|
|
28
|
+
addresses = (await lookup(host, { all: true })).map(({ address }) => {
|
|
29
|
+
const bytes = parseIpLiteral(address)
|
|
30
|
+
if (!bytes) throw new Error('system resolver returned an invalid address')
|
|
31
|
+
return bytes
|
|
32
|
+
})
|
|
29
33
|
} catch (error) {
|
|
30
34
|
const code = error instanceof Error ? Reflect.get(error, 'code') : null
|
|
31
35
|
if (code !== 'ENOTFOUND' && code !== 'EINVAL' && code !== 'ERR_INVALID_ARG_VALUE') {
|
|
@@ -33,12 +37,12 @@ export async function handleHostnameResolutionRequest(
|
|
|
33
37
|
res.end()
|
|
34
38
|
return
|
|
35
39
|
}
|
|
36
|
-
|
|
40
|
+
addresses = []
|
|
37
41
|
}
|
|
38
42
|
res.statusCode = 200
|
|
39
43
|
res.setHeader('content-type', 'application/json')
|
|
40
44
|
res.setHeader('cache-control', 'no-store')
|
|
41
45
|
res.setHeader('access-control-allow-origin', req.headers.origin || '*')
|
|
42
46
|
res.setHeader('cross-origin-resource-policy', 'cross-origin')
|
|
43
|
-
res.end(JSON.stringify(
|
|
47
|
+
res.end(JSON.stringify(addresses))
|
|
44
48
|
}
|
|
@@ -165,6 +165,9 @@ export function readNativeAppIdentityFromXcodeTarget(
|
|
|
165
165
|
)
|
|
166
166
|
|
|
167
167
|
return stampNativeBuildSdk({
|
|
168
|
+
...(app.keychainAccessGroups === undefined
|
|
169
|
+
? {}
|
|
170
|
+
: { keychainAccessGroups: app.keychainAccessGroups }),
|
|
168
171
|
applicationName,
|
|
169
172
|
...(applicationDisplayName ? { applicationDisplayName } : {}),
|
|
170
173
|
...(rootModuleName ? { rootModuleName } : {}),
|
|
@@ -269,13 +272,21 @@ export function readNativeAppIdentityFromSources(
|
|
|
269
272
|
if (entry.isDirectory()) {
|
|
270
273
|
const names = entry.name.endsWith('.xcodeproj')
|
|
271
274
|
? ['project.pbxproj']
|
|
272
|
-
: [
|
|
275
|
+
: [
|
|
276
|
+
'Info.plist',
|
|
277
|
+
'AppDelegate.swift',
|
|
278
|
+
'AppDelegate.mm',
|
|
279
|
+
'AppDelegate.m',
|
|
280
|
+
...fs
|
|
281
|
+
.readdirSync(path.join(iosRoot, entry.name))
|
|
282
|
+
.filter((name) => name.endsWith('.entitlements')),
|
|
283
|
+
]
|
|
273
284
|
for (const name of names) {
|
|
274
285
|
const relative = `${prefix}${entry.name}/${name}`
|
|
275
286
|
const file = path.join(projectRoot, relative)
|
|
276
287
|
if (fs.existsSync(file)) files[relative] = fs.readFileSync(file, 'utf8')
|
|
277
288
|
}
|
|
278
|
-
} else if (/AppDelegate\.(?:swift|mm|m)$/.test(entry.name)) {
|
|
289
|
+
} else if (/AppDelegate\.(?:swift|mm|m)$|\.entitlements$/.test(entry.name)) {
|
|
279
290
|
const relative = `${prefix}${entry.name}`
|
|
280
291
|
const file = path.join(projectRoot, relative)
|
|
281
292
|
if (fs.existsSync(file)) files[relative] = fs.readFileSync(file, 'utf8')
|
|
@@ -80,6 +80,8 @@ export interface NativeAppIdentity {
|
|
|
80
80
|
supportedInterfaceOrientations?: readonly string[]
|
|
81
81
|
ipadSupportedInterfaceOrientations?: readonly string[]
|
|
82
82
|
defaultScreenOrientationMask?: string
|
|
83
|
+
// ordered, resolved keychain groups from the selected signing entitlement input.
|
|
84
|
+
keychainAccessGroups?: readonly string[]
|
|
83
85
|
shareIntoAppGroupId?: string
|
|
84
86
|
rtcAppGroupIdentifier?: string
|
|
85
87
|
screenShareExtensionBundleId?: string
|
|
@@ -92,6 +94,26 @@ export interface NativeAppIdentity {
|
|
|
92
94
|
oneUpdates?: NativeOneUpdatesReceipt
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
/** read explicit signing groups without inventing prefixes or default groups. */
|
|
98
|
+
export function readKeychainAccessGroups(
|
|
99
|
+
dictionary: unknown,
|
|
100
|
+
resolve: (value: string) => string | null,
|
|
101
|
+
): string[] | undefined {
|
|
102
|
+
if (!isRecord(dictionary))
|
|
103
|
+
throw new Error('native app entitlements are not a dictionary')
|
|
104
|
+
const groups = dictionary['keychain-access-groups']
|
|
105
|
+
if (groups === undefined) return undefined
|
|
106
|
+
if (!Array.isArray(groups)) throw new Error('keychain-access-groups is not an array')
|
|
107
|
+
return groups.map((group) => {
|
|
108
|
+
if (typeof group !== 'string')
|
|
109
|
+
throw new Error('keychain access group is not a string')
|
|
110
|
+
const value = resolve(group)
|
|
111
|
+
if (!value || /\$[({]/.test(value))
|
|
112
|
+
throw new Error('keychain access group has unresolved signing settings')
|
|
113
|
+
return value
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
95
117
|
export type NativeAppIdentityFiles = Record<string, string>
|
|
96
118
|
|
|
97
119
|
const NATIVE_APP_IDENTITY_PREFIX = 'globalThis.__sootsimNativeAppIdentity='
|
|
@@ -198,6 +220,14 @@ export function isNativeAppIdentity(value: unknown): value is NativeAppIdentity
|
|
|
198
220
|
!value.backgroundModes.every((mode) => typeof mode === 'string'))
|
|
199
221
|
)
|
|
200
222
|
return false
|
|
223
|
+
if (
|
|
224
|
+
value.keychainAccessGroups !== undefined &&
|
|
225
|
+
(!Array.isArray(value.keychainAccessGroups) ||
|
|
226
|
+
!value.keychainAccessGroups.every(
|
|
227
|
+
(group) => typeof group === 'string' && group.length > 0 && !/\$[({]/.test(group),
|
|
228
|
+
))
|
|
229
|
+
)
|
|
230
|
+
return false
|
|
201
231
|
if (
|
|
202
232
|
value.shareIntoAppGroupId !== undefined &&
|
|
203
233
|
typeof value.shareIntoAppGroupId !== 'string'
|
|
@@ -361,6 +391,9 @@ export function readNativeAppIdentity(value: unknown): NativeAppIdentity | null
|
|
|
361
391
|
...(value.backgroundModes === undefined
|
|
362
392
|
? {}
|
|
363
393
|
: { backgroundModes: [...value.backgroundModes] }),
|
|
394
|
+
...(value.keychainAccessGroups === undefined
|
|
395
|
+
? {}
|
|
396
|
+
: { keychainAccessGroups: [...value.keychainAccessGroups] }),
|
|
364
397
|
...(value.shareIntoAppGroupId === undefined
|
|
365
398
|
? {}
|
|
366
399
|
: { shareIntoAppGroupId: value.shareIntoAppGroupId }),
|
|
@@ -910,6 +943,19 @@ function nativeAppIdentityFromIos(
|
|
|
910
943
|
// with the build-side parser; the browser transport has no XML dependency.
|
|
911
944
|
const dictionary = parseInfoPlist(plist)
|
|
912
945
|
if (!isRecord(dictionary)) throw new Error('native app Info.plist is not a dictionary')
|
|
946
|
+
let keychainAccessGroups: string[] | undefined
|
|
947
|
+
if (settings.CODE_SIGN_ENTITLEMENTS) {
|
|
948
|
+
const entitlementPath = resolveBuildSetting(settings.CODE_SIGN_ENTITLEMENTS, settings)
|
|
949
|
+
if (!entitlementPath)
|
|
950
|
+
throw new Error('CODE_SIGN_ENTITLEMENTS has unresolved build settings')
|
|
951
|
+
const source = files[`ios/${entitlementPath}`] ?? files[entitlementPath]
|
|
952
|
+
if (source === undefined)
|
|
953
|
+
throw new Error(`missing selected entitlement input ${entitlementPath}`)
|
|
954
|
+
keychainAccessGroups = readKeychainAccessGroups(parseInfoPlist(source), (value) =>
|
|
955
|
+
resolveBuildSetting(value, settings),
|
|
956
|
+
)
|
|
957
|
+
}
|
|
958
|
+
|
|
913
959
|
const declaredDisplayName = dictionary.CFBundleDisplayName
|
|
914
960
|
const applicationDisplayName =
|
|
915
961
|
typeof declaredDisplayName === 'string'
|
|
@@ -1170,6 +1216,7 @@ function nativeAppIdentityFromIos(
|
|
|
1170
1216
|
permissionUsageDescriptions,
|
|
1171
1217
|
infoPlistStrings,
|
|
1172
1218
|
urlQuerySchemes,
|
|
1219
|
+
...(keychainAccessGroups === undefined ? {} : { keychainAccessGroups }),
|
|
1173
1220
|
...(shareIntoAppGroupId === undefined ? {} : { shareIntoAppGroupId }),
|
|
1174
1221
|
...(rtcAppGroupIdentifier === undefined ? {} : { rtcAppGroupIdentifier }),
|
|
1175
1222
|
...(screenShareExtensionBundleId === undefined
|