@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,289 @@
1
+ import { assertInstallerContext, assertInstallerLayout, assertPortableAppName } from "./installer-layout.js";
2
+ import { assertNativeExecutable } from "./native-executable.js";
3
+ import { verifyInstallerPayload } from "./installer-identity.js";
4
+ import { chmod, lstat, mkdir, mkdtemp, open, readdir, realpath, rm } from "node:fs/promises";
5
+ import { isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
6
+ import { createHash } from "node:crypto";
7
+ // src/installer/installer-extraction.ts
8
+ async function run(cmd, env) {
9
+ const child = Bun.spawn({
10
+ cmd,
11
+ env,
12
+ stdout: "pipe",
13
+ stderr: "pipe",
14
+ signal: AbortSignal.timeout(12e4)
15
+ });
16
+ const output = (async () => {
17
+ const chunks = [];
18
+ let size = 0;
19
+ for await (const chunk of child.stdout) {
20
+ size += chunk.length;
21
+ if (size > 8388608) {
22
+ child.kill();
23
+ throw new Error("Installer command output exceeds bound");
24
+ }
25
+ chunks.push(chunk);
26
+ }
27
+ return Buffer.concat(chunks).toString("utf8");
28
+ })();
29
+ const errors = (async () => {
30
+ for await (const _chunk of child.stderr);
31
+ })();
32
+ const [text, , status] = await Promise.all([
33
+ output,
34
+ errors,
35
+ child.exited
36
+ ]);
37
+ if (status !== 0) throw new Error("Installer preparation command failed");
38
+ return text;
39
+ }
40
+ async function extract(tar, archive, member, destination, maximum, env) {
41
+ const output = await open(destination, "wx", 384);
42
+ const spawn = () => Bun.spawn({
43
+ cmd: [
44
+ tar,
45
+ "-xOf",
46
+ archive,
47
+ member
48
+ ],
49
+ env,
50
+ stdout: "pipe",
51
+ stderr: "pipe",
52
+ signal: AbortSignal.timeout(12e4)
53
+ });
54
+ try {
55
+ const child = spawn();
56
+ const errors = (async () => {
57
+ for await (const _chunk of child.stderr);
58
+ })();
59
+ let count = 0;
60
+ try {
61
+ for await (const chunk of child.stdout) {
62
+ count += chunk.length;
63
+ if (!Number.isSafeInteger(count) || count > maximum) throw new Error("Installer member exceeds bound");
64
+ let offset = 0;
65
+ while (offset < chunk.length) {
66
+ const result = await output.write(chunk, offset, chunk.length - offset);
67
+ if (!result.bytesWritten) throw new Error("Cannot copy installer member");
68
+ offset += result.bytesWritten;
69
+ }
70
+ }
71
+ if (await child.exited !== 0 || count === 0) throw new Error("Cannot copy installer member");
72
+ await errors;
73
+ } catch (error) {
74
+ child.kill();
75
+ await child.exited;
76
+ await errors;
77
+ throw error;
78
+ }
79
+ } finally {
80
+ await output.close();
81
+ }
82
+ }
83
+ async function digest(path) {
84
+ const info = await lstat(path);
85
+ if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1) throw new Error("Invalid extracted file");
86
+ const file = await open(path, "r");
87
+ try {
88
+ const before = await file.stat();
89
+ if (before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size) throw new Error("Extracted file changed");
90
+ const hash = createHash("sha256");
91
+ let size = 0;
92
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
93
+ size += chunk.length;
94
+ if (size > before.size) throw new Error("Extracted file changed");
95
+ hash.update(chunk);
96
+ }
97
+ const after = await file.stat();
98
+ if (size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ino !== before.ino || after.dev !== before.dev) throw new Error("Extracted file changed");
99
+ return {
100
+ size,
101
+ digest: "sha256:" + hash.digest("hex")
102
+ };
103
+ } finally {
104
+ await file.close();
105
+ }
106
+ }
107
+ function normalizeArchiveMember(name) {
108
+ return name.replace(/^\.\//, "").replaceAll("\\", "/");
109
+ }
110
+ async function assertExecutable(path, platform) {
111
+ const info = await lstat(path);
112
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 4096) throw new Error("Invalid copied installer executable");
113
+ const file = await open(path, "r");
114
+ try {
115
+ await assertNativeExecutable(file, info.size, platform, "installer executable");
116
+ } finally {
117
+ await file.close();
118
+ }
119
+ }
120
+ async function assertLinuxEmbedded(path, archive) {
121
+ const info = await lstat(path), marker = Buffer.from("ELECTROBUN_ARCHIVE_V1");
122
+ if (info.size <= archive.size + marker.length) throw new Error("Copied installer archive is incomplete");
123
+ const file = await open(path, "r");
124
+ try {
125
+ const position = info.size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
126
+ if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker)) throw new Error("Copied installer archive marker missing");
127
+ const hash = createHash("sha256");
128
+ for await (const chunk of file.createReadStream({
129
+ start: position + marker.length,
130
+ autoClose: false
131
+ })) hash.update(chunk);
132
+ if ("sha256:" + hash.digest("hex") !== archive.digest) throw new Error("Copied installer archive differs");
133
+ } finally {
134
+ await file.close();
135
+ }
136
+ }
137
+ function within(root, value) {
138
+ const path = relative(root, value);
139
+ return path !== "" && path !== ".." && !path.startsWith(".." + sep) && !isAbsolute(path);
140
+ }
141
+ function cleanEnv(parent) {
142
+ const result = {};
143
+ for (const key of [
144
+ "PATH",
145
+ "SystemRoot",
146
+ "WINDIR",
147
+ "COMSPEC",
148
+ "PATHEXT",
149
+ "TMP",
150
+ "TEMP",
151
+ "TMPDIR",
152
+ "LANG",
153
+ "LC_ALL",
154
+ "DISPLAY",
155
+ "XAUTHORITY",
156
+ "DBUS_SESSION_BUS_ADDRESS"
157
+ ]) if (parent[key]) result[key] = parent[key];
158
+ return result;
159
+ }
160
+ /** Verify and prepare an installer without executing it, on a matching disposable runner. */
161
+ async function prepareInstallerExecution(options) {
162
+ const env = options.env ?? process.env;
163
+ assertInstallerContext(env, options.platform, process.platform, process.arch);
164
+ assertPortableAppName(options.appName);
165
+ if (!env.RUNNER_TEMP || !isAbsolute(env.RUNNER_TEMP)) throw new Error("Missing runner temp directory");
166
+ const parent = await realpath(env.RUNNER_TEMP), sourceInstaller = resolve(options.installer), sourceArchive = resolve(options.archive);
167
+ if (!(await lstat(parent)).isDirectory()) throw new Error("Invalid runner temp directory");
168
+ const verified = await verifyInstallerPayload({
169
+ ...options,
170
+ installer: sourceInstaller,
171
+ archive: sourceArchive,
172
+ env
173
+ });
174
+ const directory = await mkdtemp(join(parent, "framework-installer-"));
175
+ let mounted = false;
176
+ try {
177
+ const profile = join(directory, "profile"), incoming = join(directory, "incoming");
178
+ await mkdir(profile, { mode: 448 });
179
+ await mkdir(incoming, { mode: 448 });
180
+ const clean = cleanEnv(env);
181
+ let executable;
182
+ if (options.platform === "macos-arm64") {
183
+ const mount = join(directory, "mount");
184
+ await mkdir(mount);
185
+ await run([
186
+ "/usr/bin/hdiutil",
187
+ "attach",
188
+ "-readonly",
189
+ "-nobrowse",
190
+ "-mountpoint",
191
+ mount,
192
+ sourceInstaller
193
+ ], clean);
194
+ mounted = true;
195
+ try {
196
+ const appName = `${options.appName}.app`, apps = (await readdir(mount)).filter((name) => name.endsWith(".app"));
197
+ if (apps.length !== 1 || apps[0] !== appName) throw new Error("Unexpected installer application");
198
+ const sourceApp = await realpath(join(mount, appName));
199
+ if (!within(await realpath(mount), sourceApp)) throw new Error("Installer application escapes image");
200
+ const app = join(incoming, appName);
201
+ await run([
202
+ "/usr/bin/ditto",
203
+ sourceApp,
204
+ app
205
+ ], clean);
206
+ const actualApp = await realpath(app), resources = await realpath(join(actualApp, "Contents", "Resources"));
207
+ if (!within(await realpath(incoming), actualApp) || !within(actualApp, resources)) throw new Error("Copied installer escapes profile");
208
+ const plist = join(actualApp, "Contents", "Info.plist"), plistInfo = await lstat(plist);
209
+ if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1048576) throw new Error("Invalid installer property list");
210
+ const name = (await run([
211
+ "/usr/libexec/PlistBuddy",
212
+ "-c",
213
+ "Print :CFBundleExecutable",
214
+ plist
215
+ ], clean)).trim();
216
+ if (!name || name === "." || name === ".." || /[\\/]/.test(name)) throw new Error("Invalid installer executable");
217
+ executable = join(actualApp, "Contents", "MacOS", name);
218
+ const sourceExecutable = join(sourceApp, "Contents", "MacOS", name);
219
+ if (!within(actualApp, await realpath(executable)) || !within(sourceApp, await realpath(sourceExecutable))) throw new Error("Installer executable escapes application");
220
+ await assertExecutable(executable, options.platform);
221
+ if (JSON.stringify(await digest(sourceExecutable)) !== JSON.stringify(await digest(executable))) throw new Error("Copied installer executable differs");
222
+ const archives = (await readdir(resources)).filter((value) => value.endsWith(".tar.zst"));
223
+ if (archives.length !== 1) throw new Error("Missing installer archive");
224
+ const embedded = await digest(join(resources, archives[0]));
225
+ if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest) throw new Error("Copied installer archive differs");
226
+ } finally {
227
+ await run([
228
+ "/usr/bin/hdiutil",
229
+ "detach",
230
+ mount
231
+ ], clean);
232
+ mounted = false;
233
+ }
234
+ } else {
235
+ const root = env.SystemRoot;
236
+ if (options.platform === "windows-x64" && (!root || !/^[A-Za-z]:[\\/]/.test(root))) throw new Error("Missing Windows system directory");
237
+ const tar = options.platform === "windows-x64" ? win32.join(root, "System32", "tar.exe") : "tar";
238
+ const names = (await run([
239
+ tar,
240
+ "-tf",
241
+ sourceInstaller
242
+ ], clean)).split(/\r?\n/).filter(Boolean);
243
+ assertInstallerLayout(options.platform, options.appName, names);
244
+ const find = (name) => {
245
+ const found = names.filter((value) => options.platform === "windows-x64" ? normalizeArchiveMember(value).toLowerCase() === name.toLowerCase() : normalizeArchiveMember(value) === name);
246
+ if (found.length !== 1) throw new Error("Installer member missing or ambiguous");
247
+ return found[0];
248
+ };
249
+ if (options.platform === "windows-x64") {
250
+ const subdirectory = join(incoming, ".installer");
251
+ await mkdir(subdirectory);
252
+ executable = join(incoming, `${options.appName}-Setup.exe`);
253
+ await extract(tar, sourceInstaller, find(`${options.appName}-Setup.exe`), executable, 268435456, clean);
254
+ await assertExecutable(executable, options.platform);
255
+ await extract(tar, sourceInstaller, find(`.installer/${options.appName}-Setup.metadata.json`), join(subdirectory, `${options.appName}-Setup.metadata.json`), 1048576, clean);
256
+ const embeddedPath = join(subdirectory, `${options.appName}-Setup.tar.zst`);
257
+ await extract(tar, sourceInstaller, find(`.installer/${options.appName}-Setup.tar.zst`), embeddedPath, verified.archive.size, clean);
258
+ const embedded = await digest(embeddedPath);
259
+ if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest) throw new Error("Copied installer archive differs");
260
+ } else {
261
+ executable = join(incoming, "installer");
262
+ await extract(tar, sourceInstaller, find("installer"), executable, verified.archive.size + 268435456, clean);
263
+ await assertExecutable(executable, options.platform);
264
+ await assertLinuxEmbedded(executable, verified.archive);
265
+ await chmod(executable, 448);
266
+ }
267
+ }
268
+ const after = await verifyInstallerPayload({
269
+ ...options,
270
+ installer: sourceInstaller,
271
+ archive: sourceArchive,
272
+ env
273
+ });
274
+ if (JSON.stringify(after) !== JSON.stringify(verified)) throw new Error("Installer changed during preparation");
275
+ return {
276
+ directory,
277
+ profile,
278
+ incoming,
279
+ executable
280
+ };
281
+ } catch (error) {
282
+ if (!mounted) await rm(directory, {
283
+ recursive: true,
284
+ force: true
285
+ });
286
+ throw error;
287
+ }
288
+ }
289
+ export { prepareInstallerExecution };
@@ -0,0 +1,15 @@
1
+ import type { FetchFunction } from '../updates/release-location';
2
+ /** CI preflight only: block external fetches while recording unexpected activity.
3
+ * This does not intercept sockets, subprocesses, or webview networking. */
4
+ export declare function installInstallerFetchGuard(options: {
5
+ env: Record<string, string | undefined>;
6
+ globals: {
7
+ fetch: FetchFunction;
8
+ };
9
+ origin: string;
10
+ expectedReads?: readonly string[];
11
+ onUnexpected?: () => void;
12
+ }): {
13
+ readonly blockedReads: number;
14
+ readonly unexpectedActivity: boolean;
15
+ };
@@ -0,0 +1,50 @@
1
+ import { assertHostedRunner } from "./hosted-runner.js";
2
+ // src/installer/installer-fetch-guard.ts
3
+ /** CI preflight only: block external fetches while recording unexpected activity.
4
+ * This does not intercept sockets, subprocesses, or webview networking. */
5
+ function installInstallerFetchGuard(options) {
6
+ assertHostedRunner(options.env, "Fetch guard");
7
+ const origin = new URL(options.origin);
8
+ if (origin.protocol !== "http:" || origin.hostname !== "127.0.0.1" || !origin.port || origin.origin !== options.origin) throw new Error("Invalid installer probe origin");
9
+ const expected = new Set(options.expectedReads ?? []);
10
+ if (expected.size !== (options.expectedReads ?? []).length || expected.size > 32) throw new Error("Invalid expected reads");
11
+ for (const value of expected) {
12
+ const url = new URL(value);
13
+ if (url.protocol !== "https:" || url.username || url.password || url.hash || url.href !== value) throw new Error("Invalid expected read");
14
+ }
15
+ const original = options.globals.fetch;
16
+ if (typeof original !== "function") throw new Error("Missing fetch implementation");
17
+ let blockedReads = 0, unexpectedActivity = false;
18
+ const unexpected = () => {
19
+ unexpectedActivity = true;
20
+ options.onUnexpected?.();
21
+ };
22
+ const guardedFetch = async (...[input, init]) => {
23
+ let request;
24
+ try {
25
+ request = new Request(input, init);
26
+ } catch {
27
+ unexpected();
28
+ throw new Error("Invalid guarded request");
29
+ }
30
+ const url = new URL(request.url);
31
+ if (url.origin === origin.origin && !url.username && !url.password) return original.call(options.globals, request, { redirect: "error" });
32
+ blockedReads++;
33
+ if (request.method !== "GET" || !expected.has(url.href) || request.headers.has("authorization") || request.headers.has("cookie") || init?.credentials === "include") unexpected();
34
+ throw new Error("Installer qualification blocks external fetch");
35
+ };
36
+ const guard = Object.assign(guardedFetch, { preconnect: () => {
37
+ unexpected();
38
+ throw new Error("Installer qualification blocks preconnect");
39
+ } });
40
+ if (!Reflect.set(options.globals, "fetch", guard) || options.globals.fetch !== guard) throw new Error("Cannot install fetch guard");
41
+ return {
42
+ get blockedReads() {
43
+ return blockedReads;
44
+ },
45
+ get unexpectedActivity() {
46
+ return unexpectedActivity;
47
+ }
48
+ };
49
+ }
50
+ export { installInstallerFetchGuard };
@@ -0,0 +1,23 @@
1
+ import { type InstallerPlatform } from './installer-layout';
2
+ import type { Artifact } from '../release/release-qualification';
3
+ export type ImageAttachIo = {
4
+ run(args: string[], env: Record<string, string>): Promise<unknown>;
5
+ mounted(mount: string): Promise<boolean>;
6
+ wait(ms: number): Promise<unknown>;
7
+ };
8
+ /**
9
+ * Attach a disk image read-only, up to three times. A failed or timed-out attach can still
10
+ * have mounted the image, so each failure detaches whatever is mounted before the retry.
11
+ */
12
+ export declare function attachImage(mount: string, image: string, env: Record<string, string>, io?: ImageAttachIo): Promise<void>;
13
+ /** Inspect a shipped installer without executing it, on a matching disposable runner. */
14
+ export declare function verifyInstallerPayload(options: {
15
+ platform: InstallerPlatform;
16
+ appName: string;
17
+ installer: string;
18
+ archive: string;
19
+ env?: Record<string, string | undefined>;
20
+ }): Promise<{
21
+ installer: Artifact;
22
+ archive: Artifact;
23
+ }>;
@@ -0,0 +1,286 @@
1
+ import { assertInstallerContext, assertInstallerLayout, assertPortableAppName } from "./installer-layout.js";
2
+ import { assertNativeExecutable } from "./native-executable.js";
3
+ import { lstat, mkdir, mkdtemp, open, readdir, realpath, rm, stat } from "node:fs/promises";
4
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
5
+ import { createHash } from "node:crypto";
6
+ import { tmpdir } from "node:os";
7
+ // src/installer/installer-identity.ts
8
+ async function identity(path) {
9
+ const info = await lstat(path);
10
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size)) throw new Error("Invalid installer artifact");
11
+ const file = await open(path, "r");
12
+ try {
13
+ const before = await file.stat();
14
+ if (before.ino !== info.ino || before.dev !== info.dev || before.size !== info.size) throw new Error("Installer artifact changed");
15
+ const hash = createHash("sha256");
16
+ let size = 0;
17
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
18
+ size += chunk.length;
19
+ if (size > before.size) throw new Error("Installer artifact changed");
20
+ hash.update(chunk);
21
+ }
22
+ const after = await file.stat();
23
+ if (size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ino !== before.ino || after.dev !== before.dev) throw new Error("Installer artifact changed");
24
+ return {
25
+ name: basename(path),
26
+ size,
27
+ digest: "sha256:" + hash.digest("hex")
28
+ };
29
+ } finally {
30
+ await file.close();
31
+ }
32
+ }
33
+ function environment(parent) {
34
+ const env = {};
35
+ for (const name of [
36
+ "PATH",
37
+ "SystemRoot",
38
+ "WINDIR",
39
+ "TEMP",
40
+ "TMP",
41
+ "TMPDIR",
42
+ "LANG",
43
+ "LC_ALL"
44
+ ]) if (parent[name]) env[name] = parent[name];
45
+ return env;
46
+ }
47
+ /** Hosted macOS runners intermittently refuse an attach while disk arbitration is busy. */
48
+ /** Whether a volume is mounted at a directory; unknown counts as mounted. */
49
+ async function volumeAt(mount) {
50
+ try {
51
+ const [own, parent] = await Promise.all([stat(mount), stat(dirname(mount))]);
52
+ return own.dev !== parent.dev;
53
+ } catch {
54
+ return true;
55
+ }
56
+ }
57
+ /**
58
+ * Attach a disk image read-only, up to three times. A failed or timed-out attach can still
59
+ * have mounted the image, so each failure detaches whatever is mounted before the retry.
60
+ */
61
+ async function attachImage(mount, image, env, io = {
62
+ run: command,
63
+ mounted: volumeAt,
64
+ wait: Bun.sleep
65
+ }) {
66
+ for (let attempt = 1;; attempt++) try {
67
+ await io.run([
68
+ "/usr/bin/hdiutil",
69
+ "attach",
70
+ "-readonly",
71
+ "-nobrowse",
72
+ "-mountpoint",
73
+ mount,
74
+ image
75
+ ], env);
76
+ return;
77
+ } catch (error) {
78
+ if (await io.mounted(mount)) await io.run([
79
+ "/usr/bin/hdiutil",
80
+ "detach",
81
+ "-force",
82
+ mount
83
+ ], env);
84
+ if (attempt === 3) throw error;
85
+ await io.wait(5e3);
86
+ }
87
+ }
88
+ async function command(args, env) {
89
+ const child = Bun.spawn({
90
+ cmd: args,
91
+ env,
92
+ stdout: "pipe",
93
+ stderr: "pipe",
94
+ signal: AbortSignal.timeout(12e4)
95
+ });
96
+ const stdout = (async () => {
97
+ let size = 0;
98
+ const chunks = [];
99
+ for await (const chunk of child.stdout) {
100
+ size += chunk.length;
101
+ if (size > 8388608) {
102
+ child.kill();
103
+ throw new Error("Installer listing exceeds bound");
104
+ }
105
+ chunks.push(Buffer.from(chunk));
106
+ }
107
+ return Buffer.concat(chunks).toString("utf8");
108
+ })();
109
+ const stderr = (async () => {
110
+ for await (const _chunk of child.stderr);
111
+ })();
112
+ const [text, , status] = await Promise.all([
113
+ stdout,
114
+ stderr,
115
+ child.exited
116
+ ]);
117
+ if (status !== 0) throw new Error("Installer inspection command failed");
118
+ return text;
119
+ }
120
+ async function extractMember(tar, installer, member, output, maximum, env) {
121
+ const file = await open(output, "wx", 384);
122
+ const spawn = () => Bun.spawn({
123
+ cmd: [
124
+ tar,
125
+ "-xOf",
126
+ installer,
127
+ member
128
+ ],
129
+ env,
130
+ stdout: "pipe",
131
+ stderr: "pipe",
132
+ signal: AbortSignal.timeout(12e4)
133
+ });
134
+ let child;
135
+ try {
136
+ child = spawn();
137
+ } catch (error) {
138
+ await file.close();
139
+ throw error;
140
+ }
141
+ const errors = (async () => {
142
+ for await (const _chunk of child.stderr);
143
+ })();
144
+ let count = 0;
145
+ try {
146
+ for await (const chunk of child.stdout) {
147
+ count += chunk.length;
148
+ if (!Number.isSafeInteger(count) || count > maximum) throw new Error("Installer member exceeds bound");
149
+ let offset = 0;
150
+ while (offset < chunk.length) {
151
+ const result = await file.write(chunk, offset, chunk.length - offset);
152
+ if (!result.bytesWritten) throw new Error("Cannot read installer member");
153
+ offset += result.bytesWritten;
154
+ }
155
+ }
156
+ if (await child.exited !== 0) throw new Error("Cannot read installer member");
157
+ await errors;
158
+ return count;
159
+ } catch (error) {
160
+ child.kill();
161
+ await child.exited;
162
+ await errors;
163
+ throw error;
164
+ } finally {
165
+ await file.close();
166
+ }
167
+ }
168
+ async function assertExecutable(path, platform) {
169
+ const info = await lstat(path);
170
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 4096) throw new Error("Invalid installer executable");
171
+ const file = await open(path, "r");
172
+ try {
173
+ await assertNativeExecutable(file, info.size, platform, "installer executable");
174
+ } finally {
175
+ await file.close();
176
+ }
177
+ }
178
+ function within(root, path) {
179
+ const rel = relative(root, path);
180
+ return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep) && !isAbsolute(rel);
181
+ }
182
+ /** Inspect a shipped installer without executing it, on a matching disposable runner. */
183
+ async function verifyInstallerPayload(options) {
184
+ const parent = options.env ?? process.env;
185
+ assertInstallerContext(parent, options.platform, process.platform, process.arch);
186
+ assertPortableAppName(options.appName);
187
+ const installerPath = resolve(options.installer), archivePath = resolve(options.archive);
188
+ const before = {
189
+ installer: await identity(installerPath),
190
+ archive: await identity(archivePath)
191
+ };
192
+ if (!Number.isSafeInteger(before.archive.size + 268435456)) throw new Error("Installer archive exceeds bound");
193
+ const env = environment(parent);
194
+ const temporary = await mkdtemp(join(tmpdir(), "framework-installer-inspect-"));
195
+ const mount = join(temporary, "mount");
196
+ let mounted = false;
197
+ try {
198
+ if (options.platform === "macos-arm64") {
199
+ await mkdir(mount);
200
+ mounted = true;
201
+ await attachImage(mount, installerPath, env);
202
+ try {
203
+ const apps = (await readdir(mount)).filter((name) => name.endsWith(".app"));
204
+ if (apps.length !== 1) throw new Error("Installer application is missing or ambiguous");
205
+ const resources = join(mount, apps[0], "Contents", "Resources");
206
+ const actualRoot = await realpath(mount), actualApp = await realpath(join(mount, apps[0])), actualResources = await realpath(resources);
207
+ if (!within(actualRoot, actualApp) || !within(actualApp, actualResources)) throw new Error("Installer resources escape mounted image");
208
+ const plist = join(actualApp, "Contents", "Info.plist"), plistInfo = await lstat(plist);
209
+ if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1048576) throw new Error("Invalid installer property list");
210
+ const executable = (await command([
211
+ "/usr/libexec/PlistBuddy",
212
+ "-c",
213
+ "Print :CFBundleExecutable",
214
+ plist
215
+ ], env)).trim();
216
+ if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable)) throw new Error("Invalid installer executable name");
217
+ await assertExecutable(join(actualApp, "Contents", "MacOS", executable), options.platform);
218
+ const archives = (await readdir(actualResources)).filter((name) => name.endsWith(".tar.zst"));
219
+ if (archives.length !== 1) throw new Error("Installer archive is missing or ambiguous");
220
+ const embedded = await identity(join(actualResources, archives[0]));
221
+ if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest) throw new Error("Installer archive differs from release archive");
222
+ } finally {
223
+ await command([
224
+ "/usr/bin/hdiutil",
225
+ "detach",
226
+ mount
227
+ ], env);
228
+ mounted = false;
229
+ }
230
+ } else {
231
+ const systemRoot = parent.SystemRoot;
232
+ if (options.platform === "windows-x64" && (!systemRoot || !/^[A-Za-z]:[\\/]/.test(systemRoot))) throw new Error("Missing Windows system directory");
233
+ const tar = options.platform === "windows-x64" ? win32.join(systemRoot, "System32", "tar.exe") : "tar";
234
+ if (options.platform === "windows-x64" && !/^bsdtar\s/i.test((await command([tar, "--version"], env)).trim())) throw new Error("Windows installer inspection requires system bsdtar");
235
+ const names = (await command([
236
+ tar,
237
+ "-tf",
238
+ installerPath
239
+ ], env)).split(/\r?\n/).filter(Boolean);
240
+ assertInstallerLayout(options.platform, options.appName, names);
241
+ const candidates = options.platform === "windows-x64" ? [`.installer/${options.appName}-Setup.tar.zst`] : ["installer"];
242
+ const matches = names.filter((name) => candidates.includes(name.replace(/^\.\//, "").replaceAll("\\", "/")));
243
+ if (matches.length !== 1) throw new Error("Installer archive is missing or ambiguous");
244
+ const extracted = join(temporary, "member");
245
+ const count = await extractMember(tar, installerPath, matches[0], extracted, before.archive.size + 268435456, env);
246
+ if (options.platform === "windows-x64") {
247
+ const setup = names.find((name) => name.replace(/^\.\//, "").replaceAll("\\", "/").toLowerCase() === `${options.appName}-Setup.exe`.toLowerCase());
248
+ if (!setup) throw new Error("Installer executable is missing");
249
+ const executable = join(temporary, "setup.exe");
250
+ await extractMember(tar, installerPath, setup, executable, 268435456, env);
251
+ await assertExecutable(executable, options.platform);
252
+ const embedded = await identity(extracted);
253
+ if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest) throw new Error("Installer archive differs from release archive");
254
+ } else {
255
+ await assertExecutable(extracted, options.platform);
256
+ const marker = Buffer.from("ELECTROBUN_ARCHIVE_V1");
257
+ if (count <= before.archive.size + marker.length) throw new Error("Installer archive is incomplete");
258
+ const file = await open(extracted, "r");
259
+ try {
260
+ const position = count - before.archive.size - marker.length, actual = Buffer.alloc(marker.length);
261
+ if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker)) throw new Error("Installer archive marker is missing");
262
+ const hash = createHash("sha256");
263
+ for await (const chunk of file.createReadStream({
264
+ start: position + marker.length,
265
+ autoClose: false
266
+ })) hash.update(chunk);
267
+ if ("sha256:" + hash.digest("hex") !== before.archive.digest) throw new Error("Installer archive differs from release archive");
268
+ } finally {
269
+ await file.close();
270
+ }
271
+ }
272
+ }
273
+ const after = {
274
+ installer: await identity(installerPath),
275
+ archive: await identity(archivePath)
276
+ };
277
+ if (JSON.stringify(before) !== JSON.stringify(after)) throw new Error("Installer artifacts changed during inspection");
278
+ return before;
279
+ } finally {
280
+ if (!mounted || !await volumeAt(mount)) await rm(temporary, {
281
+ recursive: true,
282
+ force: true
283
+ });
284
+ }
285
+ }
286
+ export { attachImage, verifyInstallerPayload };
@@ -0,0 +1,21 @@
1
+ /** Installer preflight adapted from adea-ai/adea scripts/test-desktop-release-install.mjs,
2
+ * commit 6155d18941acbb14d9099bc2a33a50ee9683a068 (Apache-2.0). */
3
+ export type InstallerPlatform = 'macos-arm64' | 'windows-x64' | 'linux-x64';
4
+ export type InstallerRenderer = 'native' | 'cef';
5
+ /** Native installer execution is only allowed on disposable, matching hosted runners. */
6
+ export declare function assertInstallerContext(env: Record<string, string | undefined>, platform: InstallerPlatform, host: string, arch: string): void;
7
+ /** A bundle and installer name usable on macOS, Windows and Linux. */
8
+ export declare function assertPortableAppName(name: string): void;
9
+ /** Check names before extraction. Callers must also reject unsafe links and archive entry types. */
10
+ export declare function assertPayloadLayout(options: {
11
+ platform: InstallerPlatform;
12
+ appName: string;
13
+ renderer: InstallerRenderer;
14
+ entries: readonly string[];
15
+ /** Sidecar executables the app bundles; each must be present. */
16
+ sidecars?: readonly string[];
17
+ }): void;
18
+ /** Check expected installer entries before extraction; links and types require separate validation. */
19
+ export declare function assertInstallerLayout(platform: InstallerPlatform, appName: string, entries: readonly string[]): void;
20
+ /** Check the actual packaged renderer metadata, not merely the app's source config. */
21
+ export declare function assertBuildMetadata(value: unknown, renderer: InstallerRenderer): void;