@adea-ai/app-framework 0.0.0-stage → 0.24.1

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.
Files changed (358) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +1009 -2
  4. package/dist/app/application.d.ts +47 -0
  5. package/dist/app/application.js +115 -0
  6. package/dist/app/create-application.d.ts +13 -0
  7. package/dist/app/create-application.js +178 -0
  8. package/dist/app/service-registry.d.ts +44 -0
  9. package/dist/app/service-registry.js +116 -0
  10. package/dist/appearance/appearance-host.d.ts +62 -0
  11. package/dist/appearance/appearance-host.js +115 -0
  12. package/dist/appearance/appearance-preferences.d.ts +106 -0
  13. package/dist/appearance/appearance-preferences.js +175 -0
  14. package/dist/appearance/composition.d.ts +11 -0
  15. package/dist/appearance/composition.js +16 -0
  16. package/dist/appearance/custom-theme-import.d.ts +14 -0
  17. package/dist/appearance/custom-theme-import.js +315 -0
  18. package/dist/appearance/custom-theme-library.d.ts +146 -0
  19. package/dist/appearance/custom-theme-library.js +378 -0
  20. package/dist/appearance/editor.d.ts +20 -0
  21. package/dist/appearance/editor.js +47 -0
  22. package/dist/appearance/theme-file-importer.d.ts +23 -0
  23. package/dist/appearance/theme-file-importer.js +66 -0
  24. package/dist/appearance/theme-record-adapter.d.ts +26 -0
  25. package/dist/appearance/theme-record-adapter.js +64 -0
  26. package/dist/appearance/theme-registry.d.ts +10 -0
  27. package/dist/appearance/theme-registry.js +16 -0
  28. package/dist/appearance/window-surface.d.ts +5 -0
  29. package/dist/appearance/window-surface.js +9 -0
  30. package/dist/ci/toolchain-identity.d.ts +39 -0
  31. package/dist/ci/toolchain-identity.js +196 -0
  32. package/dist/cli/cef-helper-cli.d.ts +2 -0
  33. package/dist/cli/cef-helper-cli.js +18 -0
  34. package/dist/cli/cli-runner.d.ts +8 -0
  35. package/dist/cli/cli-runner.js +23 -0
  36. package/dist/cli/create-application-cli.d.ts +2 -0
  37. package/dist/cli/create-application-cli.js +40 -0
  38. package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
  39. package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
  40. package/dist/cli/framework-update-cli.d.ts +2 -0
  41. package/dist/cli/framework-update-cli.js +40 -0
  42. package/dist/cli/release-assets-plan-cli.d.ts +2 -0
  43. package/dist/cli/release-assets-plan-cli.js +14 -0
  44. package/dist/cli/release-cut-cli.d.ts +2 -0
  45. package/dist/cli/release-cut-cli.js +27 -0
  46. package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
  47. package/dist/cli/release-descriptor-staging-cli.js +45 -0
  48. package/dist/cli/release-finalize-cli.d.ts +1 -0
  49. package/dist/cli/release-finalize-cli.js +30 -0
  50. package/dist/cli/release-promote-cli.d.ts +2 -0
  51. package/dist/cli/release-promote-cli.js +32 -0
  52. package/dist/cli/release-publish-cli.d.ts +2 -0
  53. package/dist/cli/release-publish-cli.js +48 -0
  54. package/dist/cli/release-sign-cli.d.ts +2 -0
  55. package/dist/cli/release-sign-cli.js +13 -0
  56. package/dist/cli/release-step-cli.d.ts +2 -0
  57. package/dist/cli/release-step-cli.js +44 -0
  58. package/dist/cli/toolchain-identity-cli.d.ts +2 -0
  59. package/dist/cli/toolchain-identity-cli.js +10 -0
  60. package/dist/cli/update-helper-cli.d.ts +1 -0
  61. package/dist/cli/update-helper-cli.js +10 -0
  62. package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
  63. package/dist/cli/windows-runtime-patch-cli.js +17 -0
  64. package/dist/desktop/application-command-client.d.ts +15 -0
  65. package/dist/desktop/application-command-client.js +21 -0
  66. package/dist/desktop/channel-handshake.d.ts +32 -0
  67. package/dist/desktop/channel-handshake.js +111 -0
  68. package/dist/desktop/channel-proof.d.ts +43 -0
  69. package/dist/desktop/channel-proof.js +85 -0
  70. package/dist/desktop/client-assets.d.ts +7 -0
  71. package/dist/desktop/client-assets.js +59 -0
  72. package/dist/desktop/desktop-client.d.ts +23 -0
  73. package/dist/desktop/desktop-client.js +231 -0
  74. package/dist/desktop/desktop-gateway.d.ts +18 -0
  75. package/dist/desktop/desktop-gateway.js +146 -0
  76. package/dist/desktop/desktop-host.d.ts +48 -0
  77. package/dist/desktop/desktop-host.js +208 -0
  78. package/dist/desktop/desktop-stream.d.ts +36 -0
  79. package/dist/desktop/desktop-stream.js +231 -0
  80. package/dist/desktop/loopback-policy.d.ts +19 -0
  81. package/dist/desktop/loopback-policy.js +23 -0
  82. package/dist/desktop/open-url-channel.d.ts +15 -0
  83. package/dist/desktop/open-url-channel.js +55 -0
  84. package/dist/desktop/string-policy.d.ts +2 -0
  85. package/dist/desktop/string-policy.js +11 -0
  86. package/dist/framework-source.json +1 -0
  87. package/dist/installer/archive-entry.d.ts +6 -0
  88. package/dist/installer/archive-entry.js +14 -0
  89. package/dist/installer/command-artifact.d.ts +47 -0
  90. package/dist/installer/command-artifact.js +261 -0
  91. package/dist/installer/command-qualification-command.d.ts +12 -0
  92. package/dist/installer/command-qualification-command.js +71 -0
  93. package/dist/installer/hosted-runner.d.ts +4 -0
  94. package/dist/installer/hosted-runner.js +10 -0
  95. package/dist/installer/installed-payload.d.ts +29 -0
  96. package/dist/installer/installed-payload.js +312 -0
  97. package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
  98. package/dist/installer/installer-ci-bootstrap.js +160 -0
  99. package/dist/installer/installer-ci-preflight.d.ts +1 -0
  100. package/dist/installer/installer-ci-preflight.js +49 -0
  101. package/dist/installer/installer-ci-worker.d.ts +1 -0
  102. package/dist/installer/installer-ci-worker.js +105 -0
  103. package/dist/installer/installer-extraction.d.ts +14 -0
  104. package/dist/installer/installer-extraction.js +289 -0
  105. package/dist/installer/installer-fetch-guard.d.ts +15 -0
  106. package/dist/installer/installer-fetch-guard.js +50 -0
  107. package/dist/installer/installer-identity.d.ts +23 -0
  108. package/dist/installer/installer-identity.js +286 -0
  109. package/dist/installer/installer-layout.d.ts +21 -0
  110. package/dist/installer/installer-layout.js +89 -0
  111. package/dist/installer/installer-observation.d.ts +64 -0
  112. package/dist/installer/installer-observation.js +473 -0
  113. package/dist/installer/installer-process-cleanup.d.ts +18 -0
  114. package/dist/installer/installer-process-cleanup.js +158 -0
  115. package/dist/installer/installer-qualification-command.d.ts +11 -0
  116. package/dist/installer/installer-qualification-command.js +71 -0
  117. package/dist/installer/installer-renderer-evidence.d.ts +43 -0
  118. package/dist/installer/installer-renderer-evidence.js +136 -0
  119. package/dist/installer/installer-upgrade-command.d.ts +37 -0
  120. package/dist/installer/installer-upgrade-command.js +172 -0
  121. package/dist/installer/installer-worker-guard.d.ts +21 -0
  122. package/dist/installer/installer-worker-guard.js +72 -0
  123. package/dist/installer/native-executable.d.ts +5 -0
  124. package/dist/installer/native-executable.js +21 -0
  125. package/dist/installer/upgrade-asset-download.d.ts +13 -0
  126. package/dist/installer/upgrade-asset-download.js +41 -0
  127. package/dist/installer/write-all.d.ts +6 -0
  128. package/dist/installer/write-all.js +11 -0
  129. package/dist/native/app-bundle.d.ts +28 -0
  130. package/dist/native/app-bundle.js +60 -0
  131. package/dist/native/cef-helper.d.ts +28 -0
  132. package/dist/native/cef-helper.js +402 -0
  133. package/dist/native/desktop-build-hook.d.ts +7 -0
  134. package/dist/native/desktop-build-hook.js +20 -0
  135. package/dist/native/electrobun-source-patch.d.ts +25 -0
  136. package/dist/native/electrobun-source-patch.js +93 -0
  137. package/dist/native/linux-cef-links.d.ts +2 -0
  138. package/dist/native/linux-cef-links.js +15 -0
  139. package/dist/native/native-secret-store.d.ts +27 -0
  140. package/dist/native/native-secret-store.js +70 -0
  141. package/dist/native/native-utilities.d.ts +24 -0
  142. package/dist/native/native-utilities.js +85 -0
  143. package/dist/native/partitioned-window.d.ts +34 -0
  144. package/dist/native/partitioned-window.js +44 -0
  145. package/dist/native/renderer-profile.d.ts +53 -0
  146. package/dist/native/renderer-profile.js +30 -0
  147. package/dist/native/secure-window.d.ts +38 -0
  148. package/dist/native/secure-window.js +77 -0
  149. package/dist/native/sidecar-services.d.ts +23 -0
  150. package/dist/native/sidecar-services.js +46 -0
  151. package/dist/native/sidecar.d.ts +81 -0
  152. package/dist/native/sidecar.js +250 -0
  153. package/dist/native/window-bootstrap.d.ts +24 -0
  154. package/dist/native/window-bootstrap.js +63 -0
  155. package/dist/native/window-options.d.ts +32 -0
  156. package/dist/native/window-options.js +23 -0
  157. package/dist/native/windows-build-hook-internal.d.ts +2 -0
  158. package/dist/native/windows-build-hook-internal.js +32 -0
  159. package/dist/native/windows-build-hook.d.ts +2 -0
  160. package/dist/native/windows-build-hook.js +12 -0
  161. package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
  162. package/dist/native/windows-runtime-patch-internal.js +20 -0
  163. package/dist/native/windows-runtime-patch.d.ts +4 -0
  164. package/dist/native/windows-runtime-patch.js +12 -0
  165. package/dist/release/feed-release-cut.d.ts +23 -0
  166. package/dist/release/feed-release-cut.js +93 -0
  167. package/dist/release/feed-state.d.ts +25 -0
  168. package/dist/release/feed-state.js +81 -0
  169. package/dist/release/framework-package-publish.d.ts +21 -0
  170. package/dist/release/framework-package-publish.js +127 -0
  171. package/dist/release/framework-update.d.ts +30 -0
  172. package/dist/release/framework-update.js +139 -0
  173. package/dist/release/github-cli.d.ts +6 -0
  174. package/dist/release/github-cli.js +16 -0
  175. package/dist/release/github-release-assets.d.ts +3 -0
  176. package/dist/release/github-release-assets.js +24 -0
  177. package/dist/release/github-release-cut.d.ts +14 -0
  178. package/dist/release/github-release-cut.js +174 -0
  179. package/dist/release/github-release-lookup.d.ts +7 -0
  180. package/dist/release/github-release-lookup.js +29 -0
  181. package/dist/release/github-release-promotion.d.ts +10 -0
  182. package/dist/release/github-release-promotion.js +78 -0
  183. package/dist/release/github-release-provenance.d.ts +9 -0
  184. package/dist/release/github-release-provenance.js +27 -0
  185. package/dist/release/github-release-publisher.d.ts +9 -0
  186. package/dist/release/github-release-publisher.js +63 -0
  187. package/dist/release/github-release-qualification.d.ts +12 -0
  188. package/dist/release/github-release-qualification.js +80 -0
  189. package/dist/release/local-provenance.d.ts +24 -0
  190. package/dist/release/local-provenance.js +72 -0
  191. package/dist/release/local-release.d.ts +133 -0
  192. package/dist/release/local-release.js +387 -0
  193. package/dist/release/macos-dmg.d.ts +22 -0
  194. package/dist/release/macos-dmg.js +91 -0
  195. package/dist/release/release-artifact.d.ts +6 -0
  196. package/dist/release/release-artifact.js +38 -0
  197. package/dist/release/release-assets-plan.d.ts +14 -0
  198. package/dist/release/release-assets-plan.js +65 -0
  199. package/dist/release/release-config.d.ts +76 -0
  200. package/dist/release/release-config.js +180 -0
  201. package/dist/release/release-cut-command.d.ts +13 -0
  202. package/dist/release/release-cut-command.js +39 -0
  203. package/dist/release/release-cut.d.ts +54 -0
  204. package/dist/release/release-cut.js +76 -0
  205. package/dist/release/release-descriptor-staging.d.ts +34 -0
  206. package/dist/release/release-descriptor-staging.js +147 -0
  207. package/dist/release/release-finalize.d.ts +16 -0
  208. package/dist/release/release-finalize.js +104 -0
  209. package/dist/release/release-promotion-command.d.ts +12 -0
  210. package/dist/release/release-promotion-command.js +28 -0
  211. package/dist/release/release-promotion.d.ts +29 -0
  212. package/dist/release/release-promotion.js +57 -0
  213. package/dist/release/release-publication.d.ts +33 -0
  214. package/dist/release/release-publication.js +138 -0
  215. package/dist/release/release-publish-command.d.ts +7 -0
  216. package/dist/release/release-publish-command.js +91 -0
  217. package/dist/release/release-qualification.d.ts +106 -0
  218. package/dist/release/release-qualification.js +135 -0
  219. package/dist/release/release-staging.d.ts +9 -0
  220. package/dist/release/release-staging.js +61 -0
  221. package/dist/release/release-steps.d.ts +38 -0
  222. package/dist/release/release-steps.js +147 -0
  223. package/dist/release/retained-release-build.d.ts +19 -0
  224. package/dist/release/retained-release-build.js +122 -0
  225. package/dist/shell/app-shell.d.ts +61 -0
  226. package/dist/shell/app-shell.js +306 -0
  227. package/dist/shell/app-utilities.d.ts +122 -0
  228. package/dist/shell/app-utilities.js +334 -0
  229. package/dist/shell/application-menu-commands.d.ts +5 -0
  230. package/dist/shell/application-menu-commands.js +11 -0
  231. package/dist/shell/application-menu.d.ts +61 -0
  232. package/dist/shell/application-menu.js +208 -0
  233. package/dist/shell/help-shortcuts.d.ts +12 -0
  234. package/dist/shell/help-shortcuts.js +22 -0
  235. package/dist/shell/navigation-drawer.d.ts +12 -0
  236. package/dist/shell/navigation-drawer.js +42 -0
  237. package/dist/shell/settings-sections.d.ts +31 -0
  238. package/dist/shell/settings-sections.js +50 -0
  239. package/dist/shell/shortcut-platform.d.ts +17 -0
  240. package/dist/shell/shortcut-platform.js +25 -0
  241. package/dist/update-helper.bundle.js +260 -0
  242. package/dist/updates/channel-update-manager.d.ts +46 -0
  243. package/dist/updates/channel-update-manager.js +114 -0
  244. package/dist/updates/desktop-updater.d.ts +104 -0
  245. package/dist/updates/desktop-updater.js +345 -0
  246. package/dist/updates/release-feed.d.ts +61 -0
  247. package/dist/updates/release-feed.js +111 -0
  248. package/dist/updates/release-location.d.ts +9 -0
  249. package/dist/updates/release-location.js +80 -0
  250. package/dist/updates/release-version.d.ts +12 -0
  251. package/dist/updates/release-version.js +43 -0
  252. package/dist/updates/signed-release.d.ts +63 -0
  253. package/dist/updates/signed-release.js +162 -0
  254. package/dist/updates/stable-file.d.ts +10 -0
  255. package/dist/updates/stable-file.js +22 -0
  256. package/dist/updates/update-adapter.d.ts +57 -0
  257. package/dist/updates/update-adapter.js +72 -0
  258. package/dist/updates/update-arm.d.ts +24 -0
  259. package/dist/updates/update-arm.js +95 -0
  260. package/dist/updates/update-channel-store.d.ts +8 -0
  261. package/dist/updates/update-channel-store.js +72 -0
  262. package/dist/updates/update-discovery.d.ts +13 -0
  263. package/dist/updates/update-discovery.js +56 -0
  264. package/dist/updates/update-download.d.ts +14 -0
  265. package/dist/updates/update-download.js +67 -0
  266. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  267. package/dist/updates/update-exclusive-rename.js +52 -0
  268. package/dist/updates/update-extraction.d.ts +18 -0
  269. package/dist/updates/update-extraction.js +183 -0
  270. package/dist/updates/update-handoff-plan.d.ts +22 -0
  271. package/dist/updates/update-handoff-plan.js +28 -0
  272. package/dist/updates/update-helper.d.ts +24 -0
  273. package/dist/updates/update-helper.js +56 -0
  274. package/dist/updates/update-launch.d.ts +5 -0
  275. package/dist/updates/update-launch.js +27 -0
  276. package/dist/updates/update-manager.d.ts +40 -0
  277. package/dist/updates/update-manager.js +83 -0
  278. package/dist/updates/update-process-fence.d.ts +10 -0
  279. package/dist/updates/update-process-fence.js +114 -0
  280. package/dist/updates/update-resume.d.ts +13 -0
  281. package/dist/updates/update-resume.js +34 -0
  282. package/dist/updates/update-shutdown.d.ts +15 -0
  283. package/dist/updates/update-shutdown.js +29 -0
  284. package/dist/updates/update-state.d.ts +30 -0
  285. package/dist/updates/update-state.js +18 -0
  286. package/dist/updates/update-swap-stage.d.ts +27 -0
  287. package/dist/updates/update-swap-stage.js +58 -0
  288. package/dist/updates/update-swap.d.ts +10 -0
  289. package/dist/updates/update-swap.js +30 -0
  290. package/dist/views/app-about.d.ts +22 -0
  291. package/dist/views/app-about.js +43 -0
  292. package/dist/views/app-appearance.d.ts +11 -0
  293. package/dist/views/app-appearance.js +42 -0
  294. package/dist/views/app-help.d.ts +17 -0
  295. package/dist/views/app-help.js +42 -0
  296. package/dist/views/app-settings.d.ts +26 -0
  297. package/dist/views/app-settings.js +97 -0
  298. package/dist/views/appearance-surface.d.ts +9 -0
  299. package/dist/views/appearance-surface.js +334 -0
  300. package/dist/views/update-surface.d.ts +34 -0
  301. package/dist/views/update-surface.js +64 -0
  302. package/package.json +374 -4
  303. package/src/app/application.tsx +138 -0
  304. package/src/appearance/appearance-host.tsx +205 -0
  305. package/src/appearance/appearance-preferences.ts +287 -0
  306. package/src/appearance/composition.ts +29 -0
  307. package/src/appearance/custom-theme-import.ts +424 -0
  308. package/src/appearance/custom-theme-library.ts +600 -0
  309. package/src/appearance/editor.ts +94 -0
  310. package/src/appearance/theme-file-importer.ts +103 -0
  311. package/src/appearance/theme-record-adapter.ts +106 -0
  312. package/src/appearance/theme-registry.ts +20 -0
  313. package/src/appearance/window-surface.ts +18 -0
  314. package/src/desktop/client-assets.ts +75 -0
  315. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  316. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  317. package/src/native/renderer-profile.ts +27 -0
  318. package/src/native/window-options.ts +24 -0
  319. package/src/shell/app-shell.tsx +294 -0
  320. package/src/shell/app-utilities.tsx +437 -0
  321. package/src/shell/help-shortcuts.ts +24 -0
  322. package/src/shell/navigation-drawer.tsx +36 -0
  323. package/src/shell/settings-sections.ts +74 -0
  324. package/src/shell/shortcut-platform.ts +35 -0
  325. package/src/updates/release-version.ts +57 -0
  326. package/src/updates/update-adapter.ts +129 -0
  327. package/src/updates/update-state.ts +34 -0
  328. package/src/views/app-about.tsx +44 -0
  329. package/src/views/app-appearance.tsx +32 -0
  330. package/src/views/app-help.tsx +43 -0
  331. package/src/views/app-settings.tsx +88 -0
  332. package/src/views/appearance-surface.tsx +427 -0
  333. package/src/views/update-surface.tsx +85 -0
  334. package/templates/application/.gitattributes +1 -0
  335. package/templates/application/.github/workflows/release-assets.yml +29 -0
  336. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  337. package/templates/application/.github/workflows/release-please.yml +19 -0
  338. package/templates/application/.github/workflows/release.yml +29 -0
  339. package/templates/application/.github/workflows/validation.yml +28 -0
  340. package/templates/application/.oxfmtrc.json +6 -0
  341. package/templates/application/.oxlintrc.json +48 -0
  342. package/templates/application/.release-please-manifest.json +3 -0
  343. package/templates/application/README.md +47 -0
  344. package/templates/application/electrobun.config.ts +22 -0
  345. package/templates/application/release-please-config.json +12 -0
  346. package/templates/application/scripts/app-version.ts +9 -0
  347. package/templates/application/scripts/build-desktop.ts +34 -0
  348. package/templates/application/scripts/secure-build.ts +1 -0
  349. package/templates/application/scripts/stage-release.ts +21 -0
  350. package/templates/application/src/bun/index.ts +80 -0
  351. package/templates/application/src/electrobun.d.ts +27 -0
  352. package/templates/application/src/web/index.html +12 -0
  353. package/templates/application/src/web/main.tsx +97 -0
  354. package/templates/application/src/web/public/icon.svg +1 -0
  355. package/templates/application/src/web/style.css +3 -0
  356. package/templates/application/tests/app-config.test.ts +9 -0
  357. package/templates/application/tsconfig.json +15 -0
  358. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,312 @@
1
+ import { assertSidecarNames, sidecarBundlePath } from "../native/app-bundle.js";
2
+ import { assertBuildMetadata, assertInstallerContext, assertPayloadLayout, assertPortableAppName } from "./installer-layout.js";
3
+ import { assertNativeExecutable } from "./native-executable.js";
4
+ import { lstat, open, realpath, rm } from "node:fs/promises";
5
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ import { createHash } from "node:crypto";
7
+ import { Parser } from "tar";
8
+ import { once } from "node:events";
9
+ import { createZstdDecompress } from "node:zlib";
10
+ // src/installer/installed-payload.ts
11
+ function within(root, path) {
12
+ const value = relative(root, path);
13
+ return value !== "" && value !== ".." && !value.startsWith(".." + sep) && !isAbsolute(value);
14
+ }
15
+ function cleanEnv(parent, forceLocal) {
16
+ const env = {};
17
+ for (const name of [
18
+ "PATH",
19
+ "SystemRoot",
20
+ "WINDIR",
21
+ "TMP",
22
+ "TEMP",
23
+ "TMPDIR",
24
+ "LANG",
25
+ "LC_ALL"
26
+ ]) if (parent[name]) env[name] = parent[name];
27
+ if (forceLocal) env.TAR_OPTIONS = "--force-local";
28
+ return env;
29
+ }
30
+ async function command(args, env, limit, collect) {
31
+ const child = Bun.spawn({
32
+ cmd: args,
33
+ env,
34
+ stdout: "pipe",
35
+ stderr: "pipe",
36
+ signal: AbortSignal.timeout(12e4)
37
+ });
38
+ const errors = (async () => {
39
+ for await (const _part of child.stderr);
40
+ })();
41
+ const hash = createHash("sha256"), chunks = [];
42
+ let size = 0;
43
+ try {
44
+ for await (const part of child.stdout) {
45
+ size += part.length;
46
+ if (!Number.isSafeInteger(size) || size > limit) throw new Error("Archive output exceeds bound");
47
+ hash.update(part);
48
+ if (collect) chunks.push(Buffer.from(part));
49
+ }
50
+ if (await child.exited !== 0 || size < 1) throw new Error("Cannot read archive member");
51
+ await errors;
52
+ return {
53
+ digest: hash.digest("hex"),
54
+ size,
55
+ bytes: Buffer.concat(chunks)
56
+ };
57
+ } catch (error) {
58
+ child.kill();
59
+ await child.exited;
60
+ await errors;
61
+ throw error;
62
+ }
63
+ }
64
+ /** Check and list a staged payload archive with the tar environment that extracts it: GNU
65
+ * tar on Windows needs the forced-local flag `cleanEnv` adds. */
66
+ async function listArchive(archive, platform, env) {
67
+ const archiveInfo = await lstat(archive);
68
+ if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1) throw new Error("Invalid staged archive");
69
+ const version = await command(["tar", "--version"], cleanEnv(env, false), 65536, true);
70
+ const tarEnv = cleanEnv(env, platform === "windows-x64" && version.bytes.toString("utf8").startsWith("tar (GNU tar)"));
71
+ return {
72
+ archiveInfo,
73
+ tarEnv,
74
+ entries: (await command([
75
+ "tar",
76
+ "--zstd",
77
+ "-tf",
78
+ archive
79
+ ], tarEnv, 8388608, true)).bytes.toString("utf8").split(/\r?\n/).filter(Boolean)
80
+ };
81
+ }
82
+ /** Hash the selected members of a staged payload archive in one decompression pass.
83
+ * `limits` maps each archive path to its byte bound; `collect` names the members whose
84
+ * bytes are kept. Every match is counted, so a duplicated member is visible to the caller. */
85
+ async function readMembers(archive, limits, collect) {
86
+ const members = /* @__PURE__ */ new Map();
87
+ let failure;
88
+ const parser = new Parser({
89
+ strict: true,
90
+ maxMetaEntrySize: 1048576,
91
+ onReadEntry(entry) {
92
+ const limit = limits.get(entry.path);
93
+ if (limit === void 0) return entry.resume();
94
+ const previous = members.get(entry.path);
95
+ if (previous) {
96
+ previous.count += 1;
97
+ return entry.resume();
98
+ }
99
+ if (entry.type !== "File" || entry.size < 1 || entry.size > limit) {
100
+ failure ??= /* @__PURE__ */ new Error("Archive member missing or ambiguous");
101
+ return entry.resume();
102
+ }
103
+ const hash = createHash("sha256"), chunks = [];
104
+ const member = {
105
+ digest: "",
106
+ size: 0,
107
+ bytes: Buffer.alloc(0),
108
+ count: 1
109
+ };
110
+ members.set(entry.path, member);
111
+ entry.on("data", (chunk) => {
112
+ member.size += chunk.length;
113
+ hash.update(chunk);
114
+ if (collect.has(entry.path)) chunks.push(chunk);
115
+ });
116
+ entry.on("end", () => {
117
+ member.digest = hash.digest("hex");
118
+ member.bytes = Buffer.concat(chunks);
119
+ });
120
+ }
121
+ });
122
+ const ended = once(parser, "end");
123
+ const file = await open(archive, "r");
124
+ try {
125
+ const input = file.createReadStream({ autoClose: false }), inflate = createZstdDecompress();
126
+ input.on("error", (error) => inflate.destroy(error));
127
+ for await (const chunk of input.pipe(inflate)) if (!parser.write(chunk)) await once(parser, "drain");
128
+ parser.end();
129
+ await ended;
130
+ } finally {
131
+ await file.close();
132
+ }
133
+ if (failure) throw failure;
134
+ return members;
135
+ }
136
+ async function installed(path, root, limit) {
137
+ const info = await lstat(path);
138
+ if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !within(root, await realpath(path))) throw new Error("Invalid installed file");
139
+ const file = await open(path, "r");
140
+ try {
141
+ const before = await file.stat();
142
+ if (before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size) throw new Error("Installed file changed");
143
+ const hash = createHash("sha256");
144
+ let size = 0;
145
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
146
+ size += chunk.length;
147
+ if (size > before.size) throw new Error("Installed file changed");
148
+ hash.update(chunk);
149
+ }
150
+ const after = await file.stat();
151
+ if (size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino) throw new Error("Installed file changed");
152
+ return {
153
+ digest: hash.digest("hex"),
154
+ size
155
+ };
156
+ } finally {
157
+ await file.close();
158
+ }
159
+ }
160
+ async function assertRuntimeBinary(path, platform) {
161
+ const info = await lstat(path), file = await open(path, "r");
162
+ try {
163
+ await assertNativeExecutable(file, info.size, platform, "runtime executable");
164
+ } finally {
165
+ await file.close();
166
+ }
167
+ }
168
+ /** Compare critical installed files to the staged archive before allowing app startup. */
169
+ async function verifyInstalledPayload(options) {
170
+ const env = options.env ?? process.env;
171
+ assertInstallerContext(env, options.platform, process.platform, process.arch);
172
+ assertPortableAppName(options.appName);
173
+ const sidecars = assertSidecarNames(options.sidecars ?? []).map((name) => sidecarBundlePath(name, options.platform));
174
+ if (!/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(options.version) || options.version.length > 64) throw new Error("Invalid installed version");
175
+ const profile = await realpath(options.profile), root = await realpath(options.installedRoot), archive = resolve(options.archive);
176
+ if (!(await lstat(profile)).isDirectory() || !(await lstat(root)).isDirectory() || !within(profile, root)) throw new Error("Installed root escapes isolated profile");
177
+ const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
178
+ assertPayloadLayout({
179
+ platform: options.platform,
180
+ renderer: options.renderer,
181
+ appName: options.appName,
182
+ entries,
183
+ sidecars: options.sidecars ?? []
184
+ });
185
+ const mac = options.platform === "macos-arm64", prefix = mac ? `${options.appName}.app/Contents` : options.appName.replaceAll(" ", ""), suffix = options.platform === "windows-x64" ? ".exe" : "";
186
+ const bin = mac ? "MacOS" : "bin";
187
+ const files = [
188
+ `${bin}/launcher${suffix}`,
189
+ `${bin}/bun${suffix}`,
190
+ "Resources/version.json",
191
+ "Resources/build.json",
192
+ "Resources/main.js",
193
+ "Resources/app/bun/index.js",
194
+ "Resources/app/client/index.html",
195
+ ...sidecars
196
+ ];
197
+ const selected = files.map((name) => {
198
+ const metadata = name === "Resources/version.json" || name === "Resources/build.json";
199
+ const limit = metadata ? 1048576 : name === `${bin}/bun${suffix}` || sidecars.includes(name) ? 268435456 : 67108864;
200
+ const expected = `${prefix}/${name}`;
201
+ const candidates = entries.filter((entry) => {
202
+ const normalized = entry.replace(/^\.\//, "").replaceAll("\\", "/");
203
+ return options.platform === "windows-x64" ? normalized.toLowerCase() === expected.toLowerCase() : normalized === expected;
204
+ });
205
+ if (candidates.length !== 1) throw new Error("Archive member missing or ambiguous");
206
+ return {
207
+ name,
208
+ metadata,
209
+ limit,
210
+ path: candidates[0]
211
+ };
212
+ });
213
+ const members = await readMembers(archive, new Map(selected.map(({ path, limit }) => [path, limit])), new Set(selected.filter(({ metadata }) => metadata).map(({ path }) => path)));
214
+ for (const { name, limit, path } of selected) {
215
+ const member = members.get(path);
216
+ if (!member || member.count !== 1) throw new Error("Archive member missing or ambiguous");
217
+ const current = await installed(join(root, name), root, limit);
218
+ if (member.size !== current.size || member.digest !== current.digest) throw new Error(`Installed file differs from archive: ${name}`);
219
+ if (name === "Resources/version.json") {
220
+ if (member.size > 1048576 || JSON.parse(member.bytes.toString("utf8")).version !== options.version) throw new Error("Installed version mismatch");
221
+ } else if (name === "Resources/build.json") {
222
+ if (member.size > 1048576) throw new Error("Invalid installed build metadata");
223
+ assertBuildMetadata(JSON.parse(member.bytes.toString("utf8")), options.renderer);
224
+ }
225
+ }
226
+ const after = await lstat(archive);
227
+ if (!after.isFile() || after.isSymbolicLink() || after.dev !== archiveInfo.dev || after.ino !== archiveInfo.ino || after.size !== archiveInfo.size || after.mtimeMs !== archiveInfo.mtimeMs) throw new Error("Staged archive changed during verification");
228
+ return { files };
229
+ }
230
+ /** Extract only the candidate Bun executable to an isolated profile for guard preflight. */
231
+ async function extractCandidateRuntime(options) {
232
+ const env = options.env ?? process.env;
233
+ assertInstallerContext(env, options.platform, process.platform, process.arch);
234
+ assertPortableAppName(options.appName);
235
+ if (!env.RUNNER_TEMP || !isAbsolute(env.RUNNER_TEMP)) throw new Error("Missing runner temp directory");
236
+ const tempRoot = await realpath(env.RUNNER_TEMP), profile = await realpath(options.profile), archive = resolve(options.archive);
237
+ if (!within(tempRoot, profile) || !(await lstat(profile)).isDirectory()) throw new Error("Runtime profile escapes runner temp");
238
+ const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
239
+ assertPayloadLayout({
240
+ platform: options.platform,
241
+ renderer: options.renderer,
242
+ appName: options.appName,
243
+ entries
244
+ });
245
+ const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
246
+ const expected = `${prefix}/bun${suffix}`;
247
+ const candidates = entries.filter((entry) => {
248
+ const normalized = entry.replace(/^\.\//, "").replaceAll("\\", "/");
249
+ return options.platform === "windows-x64" ? normalized.toLowerCase() === expected.toLowerCase() : normalized === expected;
250
+ });
251
+ if (candidates.length !== 1) throw new Error("Runtime archive member missing or ambiguous");
252
+ const destination = join(profile, `candidate-bun${suffix}`), output = await open(destination, "wx", 448);
253
+ const spawn = () => Bun.spawn({
254
+ cmd: [
255
+ "tar",
256
+ "--zstd",
257
+ "-xOf",
258
+ archive,
259
+ "--",
260
+ candidates[0]
261
+ ],
262
+ env: tarEnv,
263
+ stdout: "pipe",
264
+ stderr: "pipe",
265
+ signal: AbortSignal.timeout(12e4)
266
+ });
267
+ let successful = false;
268
+ try {
269
+ const child = spawn(), errors = (async () => {
270
+ for await (const _part of child.stderr);
271
+ })();
272
+ const hash = createHash("sha256");
273
+ let size = 0;
274
+ try {
275
+ for await (const part of child.stdout) {
276
+ size += part.length;
277
+ if (!Number.isSafeInteger(size) || size > 268435456) throw new Error("Candidate runtime exceeds bound");
278
+ hash.update(part);
279
+ let offset = 0;
280
+ while (offset < part.length) {
281
+ const result = await output.write(part, offset, part.length - offset);
282
+ if (!result.bytesWritten) throw new Error("Cannot stage candidate runtime");
283
+ offset += result.bytesWritten;
284
+ }
285
+ }
286
+ if (await child.exited !== 0 || size < 4096) throw new Error("Invalid candidate runtime");
287
+ await errors;
288
+ const after = await lstat(archive);
289
+ if (!after.isFile() || after.isSymbolicLink() || after.dev !== archiveInfo.dev || after.ino !== archiveInfo.ino || after.size !== archiveInfo.size || after.mtimeMs !== archiveInfo.mtimeMs) throw new Error("Staged archive changed during extraction");
290
+ const digest = hash.digest("hex");
291
+ await output.sync();
292
+ const copied = await installed(destination, profile, 268435456);
293
+ if (copied.size !== size || copied.digest !== digest) throw new Error("Candidate runtime copy differs");
294
+ await assertRuntimeBinary(destination, options.platform);
295
+ successful = true;
296
+ return {
297
+ path: destination,
298
+ size,
299
+ digest
300
+ };
301
+ } catch (error) {
302
+ child.kill();
303
+ await child.exited;
304
+ await errors;
305
+ throw error;
306
+ }
307
+ } finally {
308
+ await output.close();
309
+ if (!successful) await rm(destination, { force: true });
310
+ }
311
+ }
312
+ export { extractCandidateRuntime, verifyInstalledPayload };
@@ -0,0 +1,26 @@
1
+ export type InstallerCiBootstrap = {
2
+ directory: string;
3
+ /** The Bun preload, which also runs as the guarded app worker. */
4
+ worker: string;
5
+ preflight: string;
6
+ bunOptions: string;
7
+ };
8
+ /** Copy a bounded external preload into the current disposable runner's temp directory. */
9
+ export declare function prepareInstallerCiBootstrap(env?: Record<string, string | undefined>): Promise<InstallerCiBootstrap>;
10
+ /** Exercise the externally prepared guard with the actual candidate Bun runtime. */
11
+ export declare function preflightInstallerRuntime(options: {
12
+ env: Record<string, string | undefined>;
13
+ runtime: string;
14
+ bootstrap: InstallerCiBootstrap;
15
+ }): Promise<void>;
16
+ /** Run the guard preflight from explicit worker and preflight modules in a clean,
17
+ * hosted-shaped environment. `preflightInstallerRuntime` validates a prepared bootstrap
18
+ * before calling this; tests call it directly with the source modules. */
19
+ export declare function runInstallerPreflight(options: {
20
+ env: Record<string, string | undefined>;
21
+ runtime: string;
22
+ worker: string;
23
+ preflight: string;
24
+ /** Directory that receives the short-lived acknowledgement and permit files. */
25
+ parent: string;
26
+ }): Promise<void>;
@@ -0,0 +1,160 @@
1
+ import { isHostedRunner } from "./hosted-runner.js";
2
+ import { lstat, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises";
3
+ import { dirname, isAbsolute, join, relative, sep } from "node:path";
4
+ import { randomBytes } from "node:crypto";
5
+ import { fileURLToPath } from "node:url";
6
+ // src/installer/installer-ci-bootstrap.ts
7
+ /** The modules copied into the runner. The worker and preflight scripts import the rest. */
8
+ var bootstrapModules = [
9
+ "installer/installer-ci-worker.js",
10
+ "installer/installer-ci-preflight.js",
11
+ "installer/installer-worker-guard.js",
12
+ "installer/installer-fetch-guard.js",
13
+ "installer/installer-renderer-evidence.js",
14
+ "installer/hosted-runner.js",
15
+ "release/release-qualification.js",
16
+ "desktop/string-policy.js"
17
+ ];
18
+ /** Copy a bounded external preload into the current disposable runner's temp directory. */
19
+ async function prepareInstallerCiBootstrap(env = process.env) {
20
+ if (!isHostedRunner(env) || !env.RUNNER_TEMP || !isAbsolute(env.RUNNER_TEMP)) throw new Error("Installer bootstrap requires a disposable GitHub-hosted runner");
21
+ const parent = await realpath(env.RUNNER_TEMP);
22
+ if (/\s/.test(parent) || !(await lstat(parent)).isDirectory()) throw new Error("Runner temp cannot represent a Bun preload path");
23
+ const source = dirname(dirname(fileURLToPath(import.meta.url)));
24
+ const directory = await mkdtemp(join(parent, "framework-ci-"));
25
+ try {
26
+ for (const name of bootstrapModules) {
27
+ const file = join(source, name), info = await lstat(file);
28
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > 2097152) throw new Error("Invalid installer bootstrap module");
29
+ const contents = await readFile(file);
30
+ if (contents.length !== info.size) throw new Error("Installer bootstrap module changed");
31
+ await mkdir(dirname(join(directory, name)), {
32
+ recursive: true,
33
+ mode: 448
34
+ });
35
+ await writeFile(join(directory, name), contents, {
36
+ flag: "wx",
37
+ mode: 384
38
+ });
39
+ }
40
+ await writeFile(join(directory, "package.json"), "{\"type\":\"module\"}\n", {
41
+ flag: "wx",
42
+ mode: 384
43
+ });
44
+ const worker = join(directory, "installer/installer-ci-worker.js");
45
+ return {
46
+ directory,
47
+ worker,
48
+ preflight: join(directory, "installer/installer-ci-preflight.js"),
49
+ bunOptions: `--preload=${worker}`
50
+ };
51
+ } catch (error) {
52
+ await rm(directory, {
53
+ recursive: true,
54
+ force: true
55
+ });
56
+ throw error;
57
+ }
58
+ }
59
+ /** Exercise the externally prepared guard with the actual candidate Bun runtime. */
60
+ async function preflightInstallerRuntime(options) {
61
+ const { env, runtime, bootstrap } = options;
62
+ if (!isHostedRunner(env) || !env.RUNNER_TEMP || !isAbsolute(env.RUNNER_TEMP) || !isAbsolute(runtime)) throw new Error("Runtime preflight requires a disposable hosted runner");
63
+ const tempRoot = await realpath(env.RUNNER_TEMP), bootstrapRoot = await realpath(bootstrap.directory);
64
+ const relativeBootstrap = relative(tempRoot, bootstrapRoot);
65
+ if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep) || isAbsolute(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`) throw new Error("Invalid installer bootstrap location");
66
+ await runInstallerPreflight({
67
+ env,
68
+ runtime,
69
+ worker: bootstrap.worker,
70
+ preflight: bootstrap.preflight,
71
+ parent: tempRoot
72
+ });
73
+ }
74
+ /** Run the guard preflight from explicit worker and preflight modules in a clean,
75
+ * hosted-shaped environment. `preflightInstallerRuntime` validates a prepared bootstrap
76
+ * before calling this; tests call it directly with the source modules. */
77
+ async function runInstallerPreflight(options) {
78
+ const { env, runtime, worker, preflight } = options;
79
+ for (const path of [worker, preflight]) {
80
+ const item = await lstat(path);
81
+ if (!item.isFile() || item.isSymbolicLink()) throw new Error("Invalid installer bootstrap module");
82
+ }
83
+ const info = await lstat(runtime);
84
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 4096) throw new Error("Invalid candidate Bun runtime");
85
+ const temporary = await mkdtemp(join(options.parent, "framework-preflight-"));
86
+ try {
87
+ const clean = {};
88
+ for (const key of [
89
+ "PATH",
90
+ "SystemRoot",
91
+ "WINDIR",
92
+ "COMSPEC",
93
+ "PATHEXT",
94
+ "TMP",
95
+ "TEMP",
96
+ "TMPDIR",
97
+ "LANG",
98
+ "LC_ALL"
99
+ ]) if (env[key]) clean[key] = env[key];
100
+ const nonce = randomBytes(24).toString("hex");
101
+ Object.assign(clean, {
102
+ CI: "true",
103
+ GITHUB_ACTIONS: "true",
104
+ RUNNER_ENVIRONMENT: "github-hosted",
105
+ BUN_OPTIONS: `--preload=${worker}`,
106
+ FRAMEWORK_CI_WORKER_ENTRY: preflight,
107
+ FRAMEWORK_CI_NONCE: nonce,
108
+ FRAMEWORK_CI_ACK: join(temporary, "ack"),
109
+ FRAMEWORK_CI_PERMIT: join(temporary, "permit"),
110
+ FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
111
+ FRAMEWORK_CI_OBSERVATION: join(temporary, "observation"),
112
+ FRAMEWORK_CI_UNEXPECTED: join(temporary, "unexpected"),
113
+ FRAMEWORK_CI_EXPECTED_READS: JSON.stringify(["https://example.invalid/framework-ci-sentinel"])
114
+ });
115
+ const child = Bun.spawn({
116
+ cmd: [runtime, preflight],
117
+ env: clean,
118
+ stdout: "pipe",
119
+ stderr: "pipe",
120
+ signal: AbortSignal.timeout(15e3)
121
+ });
122
+ const hardStop = setTimeout(() => {
123
+ try {
124
+ child.kill("SIGKILL");
125
+ } catch {}
126
+ }, 2e4);
127
+ const out = (async () => {
128
+ let text = "";
129
+ for await (const chunk of child.stdout) {
130
+ text += new TextDecoder().decode(chunk);
131
+ if (text.length > 65536) {
132
+ child.kill();
133
+ throw new Error("Runtime preflight output exceeds bound");
134
+ }
135
+ }
136
+ return text;
137
+ })();
138
+ const err = (async () => {
139
+ for await (const _chunk of child.stderr);
140
+ })();
141
+ const [stdout, , status] = await Promise.all([
142
+ out,
143
+ err,
144
+ child.exited
145
+ ]).finally(() => clearTimeout(hardStop));
146
+ if (status !== 0 || !stdout.includes("framework installer preload preflight passed")) throw new Error("Candidate Bun runtime failed installer preflight");
147
+ try {
148
+ await lstat(join(temporary, "unexpected"));
149
+ throw new Error("Runtime preflight recorded unexpected activity");
150
+ } catch (error) {
151
+ if (error.code !== "ENOENT") throw error;
152
+ }
153
+ } finally {
154
+ await rm(temporary, {
155
+ recursive: true,
156
+ force: true
157
+ });
158
+ }
159
+ }
160
+ export { preflightInstallerRuntime, prepareInstallerCiBootstrap, runInstallerPreflight };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ // src/installer/installer-ci-preflight.ts
3
+ if (Bun.isMainThread) await drivePreflight();
4
+ else await reportPreflightState();
5
+ async function drivePreflight() {
6
+ const { FRAMEWORK_CI_WORKER_ENTRY: entry, FRAMEWORK_CI_NONCE: nonce, FRAMEWORK_CI_ACK: ack, FRAMEWORK_CI_PERMIT: permit } = process.env;
7
+ if (!entry || !nonce || !ack || !permit) throw new Error("Missing preflight context");
8
+ const worker = new Worker(entry, {});
9
+ const result = new Promise((resolve) => worker.addEventListener("message", (event) => resolve(event.data), { once: true }));
10
+ const deadline = Date.now() + 1e4;
11
+ let acknowledged = false;
12
+ while (!acknowledged && Date.now() < deadline) {
13
+ try {
14
+ acknowledged = await readFile(ack, "utf8") === nonce + "\n";
15
+ } catch {}
16
+ if (!acknowledged) await Bun.sleep(20);
17
+ }
18
+ if (!acknowledged) throw new Error("Worker guard acknowledgement missing");
19
+ await writeFile(permit, nonce + "\n", {
20
+ flag: "wx",
21
+ mode: 384
22
+ });
23
+ let timer;
24
+ const timeout = new Promise((resolve) => {
25
+ timer = setTimeout(() => resolve(null), Math.max(0, deadline - Date.now()));
26
+ });
27
+ const value = await Promise.race([result, timeout]);
28
+ clearTimeout(timer);
29
+ worker.terminate();
30
+ if (value?.blocked !== true || value.nested !== true) throw new Error("Worker guard preflight failed");
31
+ console.log("framework installer preload preflight passed");
32
+ }
33
+ async function reportPreflightState() {
34
+ let blocked = false, nested = false;
35
+ try {
36
+ await fetch("https://example.invalid/framework-ci-sentinel");
37
+ } catch {
38
+ blocked = true;
39
+ }
40
+ try {
41
+ new Worker("unexpected").terminate();
42
+ } catch {
43
+ nested = true;
44
+ }
45
+ postMessage({
46
+ blocked,
47
+ nested
48
+ });
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,105 @@
1
+ import { parseOfflinePolicy } from "../release/release-qualification.js";
2
+ import { installInstallerRendererProbe } from "./installer-renderer-evidence.js";
3
+ import { installInstallerFetchGuard } from "./installer-fetch-guard.js";
4
+ import { awaitInstallerWorkerPermit, interceptInstallerWorker } from "./installer-worker-guard.js";
5
+ import { isAbsolute } from "node:path";
6
+ import { writeFileSync } from "node:fs";
7
+ import { fileURLToPath } from "node:url";
8
+ // src/installer/installer-ci-worker.ts
9
+ if (Bun.isMainThread) {
10
+ const entry = process.env.FRAMEWORK_CI_WORKER_ENTRY;
11
+ if (!entry) throw new Error("Missing installer CI preload context");
12
+ interceptInstallerWorker({
13
+ env: process.env,
14
+ globals: globalThis,
15
+ entry,
16
+ bootstrap: fileURLToPath(import.meta.url)
17
+ });
18
+ } else await runGuardedWorker();
19
+ async function runGuardedWorker() {
20
+ const env = process.env;
21
+ const { FRAMEWORK_CI_WORKER_ENTRY: entry, FRAMEWORK_CI_NONCE: nonce, FRAMEWORK_CI_ACK: acknowledgement, FRAMEWORK_CI_PERMIT: permit, FRAMEWORK_CI_ORIGIN: origin, FRAMEWORK_CI_OBSERVATION: observation, FRAMEWORK_CI_UNEXPECTED: unexpected, FRAMEWORK_CI_PID: pidRecord } = env;
22
+ if (pidRecord !== void 0 && (!isAbsolute(pidRecord) || [
23
+ entry,
24
+ acknowledgement,
25
+ permit,
26
+ observation,
27
+ unexpected
28
+ ].includes(pidRecord)) || ![
29
+ entry,
30
+ acknowledgement,
31
+ permit,
32
+ observation,
33
+ unexpected
34
+ ].every((value) => typeof value === "string" && isAbsolute(value)) || !nonce || !origin || (/* @__PURE__ */ new Set([
35
+ acknowledgement,
36
+ permit,
37
+ observation,
38
+ unexpected
39
+ ])).size !== 4) throw new Error("Invalid installer CI worker context");
40
+ const encoded = env.FRAMEWORK_CI_EXPECTED_READS ?? "[]";
41
+ if (encoded.length > 8192) throw new Error("Invalid expected reads");
42
+ const expectedReads = JSON.parse(encoded);
43
+ const offlineEncoded = env.FRAMEWORK_CI_OFFLINE_POLICY;
44
+ if (offlineEncoded && offlineEncoded.length > 2048) throw new Error("Invalid offline policy");
45
+ const offlinePolicy = offlineEncoded ? parseOfflinePolicy(JSON.parse(offlineEncoded)) : void 0;
46
+ if (!Array.isArray(expectedReads) || expectedReads.some((value) => typeof value !== "string")) throw new Error("Invalid expected reads");
47
+ let recordedUnexpected = false;
48
+ const guard = installInstallerFetchGuard({
49
+ env,
50
+ globals: globalThis,
51
+ origin,
52
+ expectedReads,
53
+ onUnexpected: () => {
54
+ if (!recordedUnexpected) {
55
+ writeFileSync(unexpected, nonce + "\n", {
56
+ flag: "wx",
57
+ mode: 384
58
+ });
59
+ recordedUnexpected = true;
60
+ }
61
+ }
62
+ });
63
+ if (![
64
+ "0",
65
+ "1",
66
+ void 0
67
+ ].includes(env.FRAMEWORK_CI_ALLOW_EPHEMERAL)) throw new Error("Invalid listener selection");
68
+ installInstallerRendererProbe({
69
+ env,
70
+ origin,
71
+ nonce,
72
+ allowEphemeral: env.FRAMEWORK_CI_ALLOW_EPHEMERAL === "1",
73
+ offlinePolicy,
74
+ foreignOrigin: env.FRAMEWORK_CI_FOREIGN_ORIGIN,
75
+ runtime: Bun,
76
+ save: (value, state) => {
77
+ writeFileSync(observation, JSON.stringify({
78
+ nonce,
79
+ origin,
80
+ ...value,
81
+ blockedReads: guard.blockedReads,
82
+ unexpectedActivity: guard.unexpectedActivity,
83
+ ...offlinePolicy ? {
84
+ offlinePolicy,
85
+ bootstrapDenied: state.bootstrapDenied
86
+ } : {}
87
+ }) + "\n", {
88
+ flag: "wx",
89
+ mode: 384
90
+ });
91
+ }
92
+ });
93
+ if (pidRecord) writeFileSync(pidRecord, nonce + "\n" + process.pid + "\n", {
94
+ flag: "wx",
95
+ mode: 384
96
+ });
97
+ await import(await awaitInstallerWorkerPermit({
98
+ env,
99
+ globals: globalThis,
100
+ entry,
101
+ nonce,
102
+ acknowledgement,
103
+ permit
104
+ }));
105
+ }
@@ -0,0 +1,14 @@
1
+ import { type InstallerPlatform } from './installer-layout';
2
+ /** Verify and prepare an installer without executing it, on a matching disposable runner. */
3
+ export declare function prepareInstallerExecution(options: {
4
+ platform: InstallerPlatform;
5
+ appName: string;
6
+ installer: string;
7
+ archive: string;
8
+ env?: Record<string, string | undefined>;
9
+ }): Promise<{
10
+ directory: string;
11
+ profile: string;
12
+ incoming: string;
13
+ executable: string;
14
+ }>;