@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,387 @@
1
+ import { verifyReleaseDescriptor } from "../updates/signed-release.js";
2
+ import { feedAssetKey, feedChannelKey, feedIndexKey, feedReleaseKey, feedUrl, parseReleaseLedger } from "../updates/release-feed.js";
3
+ import { discoveryPolicies, parseReleaseConfig, platformPayloads, platformTargets } from "./release-config.js";
4
+ import { cutRelease, nextDevVersion } from "./release-cut.js";
5
+ import { resolveLocalProvenance } from "./local-provenance.js";
6
+ import { versionLessThan } from "../updates/release-version.js";
7
+ import { createFeedReleaseCutProvider } from "./feed-release-cut.js";
8
+ import { readFeedLedger, readFeedRelease, verifyFeedRelease } from "./feed-state.js";
9
+ import { fileIdentity } from "./release-publication.js";
10
+ import { configuredSigningKey, signDiscoveryDescriptors, writeDescriptors } from "./release-descriptor-staging.js";
11
+ import { promoteDailyRelease } from "./release-promotion.js";
12
+ import { constants, copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
13
+ import { dirname, join, resolve } from "node:path";
14
+ import { createHash } from "node:crypto";
15
+ // src/release/local-release.ts
16
+ /**
17
+ * Local release mode: cut, sign, stage and promote desktop releases from a clean checkout on a
18
+ * developer machine, publishing to the app's HTTPS release feed instead of GitHub Releases.
19
+ * Nothing here uploads. Each publishing step writes a staged tree that mirrors the feed's
20
+ * object keys and an ordered upload plan; the caller uploads it with its own credentials.
21
+ */
22
+ var UPLOAD_PLAN = "upload-plan.json";
23
+ var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
24
+ var channelOf = (tag) => tag.includes("-dev.") ? "dev" : "daily";
25
+ var IMMUTABLE = "public, max-age=31536000, immutable";
26
+ var MUTABLE = "no-cache";
27
+ /** The release platform of this machine. */
28
+ function hostReleasePlatform(platform = process.platform, arch = process.arch) {
29
+ const found = Object.keys(platformTargets).find((value) => platformTargets[value][0] === platform && platformTargets[value][1] === arch);
30
+ if (!found) throw new Error("This machine builds no release platform");
31
+ return found;
32
+ }
33
+ function localConfig(config) {
34
+ const parsed = parseReleaseConfig(config);
35
+ if (!object(config) || typeof config.appId !== "string" || !object(config.releaseSigningKeys) || !object(config.descriptors)) throw new Error("Invalid release signing configuration");
36
+ const entries = Object.entries(config.releaseSigningKeys);
37
+ if (!entries.length || entries.length > 16) throw new Error("Missing release verification keys");
38
+ const keys = /* @__PURE__ */ new Map();
39
+ for (const [id, encoded] of entries) {
40
+ if (!/^[a-z0-9][a-z0-9._-]{0,63}$/.test(id) || typeof encoded !== "string" || Buffer.from(encoded, "base64").length !== 32 || Buffer.from(encoded, "base64").toString("base64") !== encoded) throw new Error("Invalid release verification key");
41
+ keys.set(id, encoded);
42
+ }
43
+ return {
44
+ ...parsed,
45
+ config,
46
+ keys
47
+ };
48
+ }
49
+ var timestamp = (value) => {
50
+ if (!Number.isFinite(Date.parse(value))) throw new Error("Invalid release clock");
51
+ return new Date(value).toISOString();
52
+ };
53
+ /** The directory must hold exactly `names`, all regular files. */
54
+ async function exactFiles(directory, names) {
55
+ const entries = await readdir(directory, { withFileTypes: true });
56
+ if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name))) throw new Error("Staged directory does not hold exactly the platform release files");
57
+ }
58
+ /** Cut or resume a dev or daily release from a clean local checkout of `sourceSha`, with
59
+ * version state from the feed's ledger. `dispatched` means: build and publish this tag. */
60
+ async function runLocalReleaseCut(options) {
61
+ const { kind, git, platform } = options;
62
+ const parsed = parseReleaseConfig(options.config);
63
+ const provenance = await resolveLocalProvenance({
64
+ git,
65
+ sourceSha: options.sourceSha,
66
+ versionSourcePath: parsed.versionSource.path
67
+ });
68
+ const ledger = await readFeedLedger(parsed.feed, options.fetch);
69
+ const provider = createFeedReleaseCutProvider({
70
+ ledger,
71
+ release: (tag) => readFeedRelease(parsed.feed, tag, options.fetch),
72
+ git,
73
+ sourceSha: provenance.sourceSha,
74
+ releasedVersion: provenance.releasedVersion,
75
+ payloads: (tag) => platformPayloads(parsed.requirements(tag), platform)
76
+ });
77
+ const result = await cutRelease({
78
+ kind,
79
+ sourceSha: provenance.sourceSha,
80
+ releasedVersion: provenance.releasedVersion,
81
+ provider
82
+ });
83
+ return {
84
+ ...result,
85
+ version: result.tag.slice(1),
86
+ platform
87
+ };
88
+ }
89
+ /** Local provenance for an already cut tag: a clean checkout of `sourceSha` on origin/main whose
90
+ * manifest version the tag belongs to (the daily itself, or a dev build of the next minor). */
91
+ async function localTagProvenance(options) {
92
+ const parsed = parseReleaseConfig(options.config);
93
+ parsed.requirements(options.tag);
94
+ const provenance = await resolveLocalProvenance({
95
+ git: options.git,
96
+ sourceSha: options.sourceSha,
97
+ versionSourcePath: parsed.versionSource.path
98
+ });
99
+ const expected = channelOf(options.tag) === "dev" ? `v${nextDevVersion(provenance.releasedVersion)}-dev.` : `v${provenance.releasedVersion}`;
100
+ if (channelOf(options.tag) === "dev" ? !options.tag.startsWith(expected) : options.tag !== expected) throw new Error("Release tag does not belong to the source version");
101
+ return { repository: provenance.repository };
102
+ }
103
+ /**
104
+ * Sign this platform's channel descriptors for payloads staged by `release-step stage-build`.
105
+ * Local provenance takes the place of the workflow run: the source commit is also the commit
106
+ * whose release tooling ran, and `runId` is the caller's local run number with attempt 1.
107
+ * Installer qualification needs a disposable hosted runner and is not part of a local release.
108
+ */
109
+ async function stageLocalDescriptors(options) {
110
+ const { tag, platform } = options;
111
+ const local = localConfig(options.config);
112
+ if (!/^[1-9]\d{0,19}$/.test(options.runId) || !/^[a-f0-9]{40}$/.test(options.sourceSha)) throw new Error("Invalid local release identity");
113
+ const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
114
+ const payloads = platformPayloads(local.requirements(tag), platform);
115
+ const directory = resolve(options.directory);
116
+ await exactFiles(directory, payloads);
117
+ const assets = await Promise.all(payloads.map((name) => fileIdentity(join(directory, name), name)));
118
+ const signed = signDiscoveryDescriptors({
119
+ policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
120
+ assets,
121
+ identity: {
122
+ tag,
123
+ sourceSha: options.sourceSha,
124
+ workflowSha: options.sourceSha,
125
+ runId: options.runId,
126
+ runAttempt: 1
127
+ },
128
+ repository: options.repository,
129
+ feed: feedUrl(local.feed),
130
+ keyId: options.keyId,
131
+ publicKey,
132
+ privateKey: options.privateKey
133
+ });
134
+ for (const asset of assets) if (JSON.stringify(await fileIdentity(join(directory, asset.name), asset.name)) !== JSON.stringify(asset)) throw new Error("Staged payload changed before signing");
135
+ await writeDescriptors(directory, signed);
136
+ return signed.map((value) => value.name);
137
+ }
138
+ /** The channel pointers `tag` should hold: each channel where it is the newest release. */
139
+ function pointerChannels(ledger, tag) {
140
+ const entry = ledger.releases.find((item) => item.tag === tag);
141
+ if (!entry) return [];
142
+ const newest = (kinds) => ledger.releases.filter((item) => kinds.includes(item.kind)).reduce((best, item) => !best || versionLessThan(best.tag, item.tag) ? item : best, void 0)?.tag === tag;
143
+ if (entry.kind === "dev") return newest(["dev"]) ? ["dev"] : [];
144
+ return [...newest(["daily", "stable"]) ? ["daily"] : [], ...entry.kind === "stable" && newest(["stable"]) ? ["stable"] : []];
145
+ }
146
+ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + "\n");
147
+ var describe = (key, bytes, cacheControl) => ({
148
+ key,
149
+ size: bytes.length,
150
+ sha256: createHash("sha256").update(bytes).digest("hex"),
151
+ contentType: "application/json",
152
+ cacheControl
153
+ });
154
+ /** Write `<out>/<key>` for each object and the plan beside them; `out` must not exist. */
155
+ async function writeStagedTree(out, feed, assets, documents) {
156
+ const root = resolve(out);
157
+ await mkdir(root, { mode: 448 });
158
+ const objects = [];
159
+ for (const { key, path, artifact } of assets) {
160
+ const target = join(root, key);
161
+ await mkdir(dirname(target), {
162
+ recursive: true,
163
+ mode: 448
164
+ });
165
+ await copyFile(path, target, constants.COPYFILE_EXCL);
166
+ if (JSON.stringify(await fileIdentity(target, artifact.name)) !== JSON.stringify(artifact)) throw new Error("Staged asset changed while copying");
167
+ objects.push({
168
+ key,
169
+ size: artifact.size,
170
+ sha256: artifact.digest.slice(7),
171
+ contentType: key.endsWith(".json") ? "application/json" : "application/octet-stream",
172
+ cacheControl: IMMUTABLE
173
+ });
174
+ }
175
+ for (const { key, bytes } of documents) {
176
+ const target = join(root, key);
177
+ await mkdir(dirname(target), {
178
+ recursive: true,
179
+ mode: 448
180
+ });
181
+ await writeFile(target, bytes, {
182
+ flag: "wx",
183
+ mode: 384
184
+ });
185
+ objects.push(describe(key, bytes, MUTABLE));
186
+ }
187
+ const plan = {
188
+ schema: 1,
189
+ base: feed.base,
190
+ objects
191
+ };
192
+ await writeFile(join(root, UPLOAD_PLAN), jsonBytes(plan), {
193
+ flag: "wx",
194
+ mode: 384
195
+ });
196
+ return plan;
197
+ }
198
+ /** release.json, the ledger and the pointers `tag` now holds, in upload order. */
199
+ function releaseDocuments(feed, ledger, release) {
200
+ return [
201
+ {
202
+ key: feedReleaseKey(feed, release.tag),
203
+ bytes: jsonBytes(release)
204
+ },
205
+ {
206
+ key: feedIndexKey(feed),
207
+ bytes: jsonBytes(ledger)
208
+ },
209
+ ...pointerChannels(ledger, release.tag).map((channel) => ({
210
+ key: feedChannelKey(feed, channel),
211
+ bytes: jsonBytes({
212
+ ...release,
213
+ channel
214
+ })
215
+ }))
216
+ ];
217
+ }
218
+ /**
219
+ * Stage this platform's signed release for upload. `directory` holds exactly the platform's
220
+ * payloads and the descriptors `stageLocalDescriptors` signed; every descriptor must
221
+ * authenticate against the app's trust and name its staged payload. The release merges with
222
+ * what the feed already publishes for the tag (another platform's build), never replacing an
223
+ * existing asset with different bytes. Writes `<out>/<app>/<tag>/<asset>` for new assets, the
224
+ * merged release.json, the ledger with this release newest first, and the channel pointers
225
+ * the release now holds, plus `<out>/upload-plan.json`.
226
+ */
227
+ async function stageLocalRelease(options) {
228
+ const { tag, sourceSha, platform } = options;
229
+ const local = localConfig(options.config);
230
+ const feed = local.feed, now = timestamp(options.now);
231
+ const payloads = platformPayloads(local.requirements(tag), platform);
232
+ const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
233
+ const directory = resolve(options.directory);
234
+ const names = [...payloads, ...policies.map((policy) => policy.name)];
235
+ await exactFiles(directory, names);
236
+ const staged = await Promise.all(names.map((name) => fileIdentity(join(directory, name), name)));
237
+ for (const policy of policies) {
238
+ const artifact = staged.find((asset) => asset.name === policy.name);
239
+ if (artifact.size > 65536) throw new Error("Signed descriptor is too large");
240
+ const bytes = await readFile(join(directory, policy.name));
241
+ if ("sha256:" + createHash("sha256").update(bytes).digest("hex") !== artifact.digest) throw new Error("Signed descriptor changed");
242
+ let parsed;
243
+ try {
244
+ parsed = JSON.parse(bytes.toString("utf8"));
245
+ } catch {
246
+ throw new Error("Invalid signed descriptor");
247
+ }
248
+ const verified = verifyReleaseDescriptor(parsed, {
249
+ appId: policy.appId,
250
+ repository: options.repository,
251
+ channel: policy.channel,
252
+ platform: policy.os,
253
+ arch: policy.arch,
254
+ feed: feedUrl(feed),
255
+ keys: local.keys
256
+ });
257
+ const payload = staged.find((asset) => asset.name === policy.payload);
258
+ if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest) throw new Error(`Untrusted signed descriptor: ${policy.name}`);
259
+ }
260
+ const [ledger, remote] = await Promise.all([readFeedLedger(feed, options.fetch), readFeedRelease(feed, tag, options.fetch)]);
261
+ const entry = ledger.releases.find((item) => item.tag === tag);
262
+ if (entry && entry.sourceSha !== sourceSha) throw new Error("The feed publishes this tag from another source commit");
263
+ const merged = [...remote?.assets ?? []];
264
+ const uploads = [];
265
+ for (const artifact of staged) {
266
+ const existing = merged.find((asset) => asset.name === artifact.name);
267
+ if (existing) {
268
+ if (existing.size !== artifact.size || "sha256:" + existing.sha256 !== artifact.digest) throw new Error(`Immutable asset conflict: ${artifact.name}`);
269
+ continue;
270
+ }
271
+ merged.push({
272
+ name: artifact.name,
273
+ size: artifact.size,
274
+ sha256: artifact.digest.slice(7)
275
+ });
276
+ uploads.push({
277
+ key: feedAssetKey(feed, tag, artifact.name),
278
+ path: join(directory, artifact.name),
279
+ artifact
280
+ });
281
+ }
282
+ const newest = ledger.releases[0];
283
+ if (!entry && newest && Date.parse(newest.publishedAt) > Date.parse(now)) throw new Error("The feed has a release newer than this clock");
284
+ const updated = parseReleaseLedger({
285
+ schema: 1,
286
+ app: feed.app,
287
+ releases: entry ? ledger.releases : [{
288
+ tag,
289
+ kind: channelOf(tag),
290
+ version: tag.slice(1),
291
+ sourceSha,
292
+ publishedAt: now
293
+ }, ...ledger.releases].slice(0, 500)
294
+ }, feed.app);
295
+ const release = {
296
+ tag,
297
+ channel: entry?.kind ?? channelOf(tag),
298
+ publishedAt: remote?.publishedAt ?? now,
299
+ assets: merged
300
+ };
301
+ return writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
302
+ }
303
+ /** Check a release the feed publishes: ledger, release.json and every signed descriptor. */
304
+ async function verifyLocalRelease(options) {
305
+ const local = localConfig(options.config);
306
+ const { release, platforms } = await verifyFeedRelease({
307
+ config: local.config,
308
+ feed: local.feed,
309
+ tag: options.tag,
310
+ repository: options.repository,
311
+ keys: local.keys,
312
+ fetch: options.fetch
313
+ });
314
+ return {
315
+ tag: release.tag,
316
+ channel: release.channel,
317
+ platforms,
318
+ missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
319
+ };
320
+ }
321
+ /**
322
+ * Promote the newest qualified daily after the soak, with the shared promotion policy over the
323
+ * feed's ledger. A daily qualifies when every published platform's stable descriptors verify.
324
+ * Promotion signs nothing (a daily already carries its stable descriptors); it stages the
325
+ * release.json and ledger entry marked stable and the stable channel pointer.
326
+ */
327
+ async function runLocalPromotion(options) {
328
+ const local = localConfig(options.config);
329
+ const feed = local.feed;
330
+ const ledger = await readFeedLedger(feed, options.fetch);
331
+ let plan;
332
+ return {
333
+ ...await promoteDailyRelease({
334
+ now: timestamp(options.now),
335
+ held: options.held,
336
+ soakHours: local.soakHours,
337
+ provider: {
338
+ async list() {
339
+ return ledger.releases.map((entry, index) => ({
340
+ id: ledger.releases.length - index,
341
+ tag: entry.tag,
342
+ body: entry.kind === "dev" ? `adea-channel:dev\n\nSource: ${entry.sourceSha}` : entry.kind === "stable" ? `<!-- adea-stable:v1 ${entry.tag} -->\n<!-- adea-stable-time:${entry.promotedAt} -->` : "",
343
+ draft: false,
344
+ prerelease: entry.kind !== "stable",
345
+ publishedAt: entry.publishedAt
346
+ }));
347
+ },
348
+ async qualify(release) {
349
+ await verifyFeedRelease({
350
+ config: local.config,
351
+ feed,
352
+ tag: release.tag,
353
+ repository: options.repository,
354
+ keys: local.keys,
355
+ fetch: options.fetch,
356
+ channels: ["stable"]
357
+ });
358
+ return true;
359
+ },
360
+ async markStable(selected, at) {
361
+ const entry = ledger.releases.find((item) => item.tag === selected.tag);
362
+ const remote = await readFeedRelease(feed, selected.tag, options.fetch);
363
+ if (!entry || !remote || entry.kind === "dev") throw new Error("Release changed during promotion");
364
+ const promoted = {
365
+ tag: entry.tag,
366
+ kind: "stable",
367
+ version: entry.version,
368
+ sourceSha: entry.sourceSha,
369
+ publishedAt: entry.publishedAt,
370
+ promotedAt: entry.promotedAt ?? timestamp(at)
371
+ };
372
+ const updated = parseReleaseLedger({
373
+ schema: 1,
374
+ app: feed.app,
375
+ releases: ledger.releases.map((item) => item.tag === entry.tag ? promoted : item)
376
+ }, feed.app);
377
+ plan = await writeStagedTree(options.out, feed, [], releaseDocuments(feed, updated, {
378
+ ...remote,
379
+ channel: "stable"
380
+ }));
381
+ }
382
+ }
383
+ }),
384
+ ...plan ? { plan } : {}
385
+ };
386
+ }
387
+ export { hostReleasePlatform, localTagProvenance, runLocalPromotion, runLocalReleaseCut, stageLocalDescriptors, stageLocalRelease, verifyLocalRelease };
@@ -0,0 +1,22 @@
1
+ export declare function dmgCapacityMiB(input: {
2
+ logicalBytes: number;
3
+ entries: number;
4
+ }): number;
5
+ /**
6
+ * Hosted macOS runners intermittently answer `hdiutil verify` with "Resource temporarily
7
+ * unavailable" while the `diskimages-helper` from the image `create` still holds the file.
8
+ * Three attempts five seconds apart were not always enough, so back off from 5 to 80 seconds
9
+ * over six attempts (about 2.5 minutes) before failing.
10
+ */
11
+ export declare function verifyImage(image: string, io?: {
12
+ run(command: string, args: string[]): void;
13
+ wait(ms: number): void;
14
+ }): void;
15
+ /** Build a correctly sized macOS DMG without replacing an existing artifact. */
16
+ export declare function createMacosDmg(options: {
17
+ appName: string;
18
+ appPath: string;
19
+ outputPath: string;
20
+ }): {
21
+ capacityMiB: number;
22
+ };
@@ -0,0 +1,91 @@
1
+ import { assertPortableAppName } from "../installer/installer-layout.js";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
+ import { linkSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, rmSync, symlinkSync } from "node:fs";
4
+ import { execFileSync } from "node:child_process";
5
+ // src/release/macos-dmg.ts
6
+ /** Sizing strategy adapted from adea-ai/adea scripts/create-desktop-dmg.mjs,
7
+ * commit 6155d18941acbb14d9099bc2a33a50ee9683a068 (Apache-2.0). */
8
+ var MIB = 1048576;
9
+ function dmgCapacityMiB(input) {
10
+ if (!Number.isSafeInteger(input.logicalBytes) || input.logicalBytes < 0 || !Number.isSafeInteger(input.entries) || input.entries < 1) throw new Error("Invalid disk image size");
11
+ const bytes = Math.ceil(input.logicalBytes * 1.25) + input.entries * 4096 + 32 * MIB;
12
+ if (!Number.isSafeInteger(bytes)) throw new Error("Disk image size exceeds bound");
13
+ return Math.max(64, Math.ceil(bytes / MIB));
14
+ }
15
+ function treeSize(root) {
16
+ let logicalBytes = 0, entries = 0;
17
+ const pending = [root];
18
+ while (pending.length) {
19
+ const path = pending.pop(), info = lstatSync(path);
20
+ if (++entries > 1e6) throw new Error("Disk image contains too many entries");
21
+ if (info.isFile()) logicalBytes += info.size;
22
+ else if (info.isDirectory()) for (const name of readdirSync(path)) pending.push(join(path, name));
23
+ else if (!info.isSymbolicLink()) throw new Error("Unsupported disk image entry");
24
+ if (!Number.isSafeInteger(logicalBytes)) throw new Error("Disk image size exceeds bound");
25
+ }
26
+ return {
27
+ logicalBytes,
28
+ entries
29
+ };
30
+ }
31
+ function run(command, args) {
32
+ execFileSync(command, args, {
33
+ stdio: "inherit",
34
+ timeout: 6e5
35
+ });
36
+ }
37
+ /**
38
+ * Hosted macOS runners intermittently answer `hdiutil verify` with "Resource temporarily
39
+ * unavailable" while the `diskimages-helper` from the image `create` still holds the file.
40
+ * Three attempts five seconds apart were not always enough, so back off from 5 to 80 seconds
41
+ * over six attempts (about 2.5 minutes) before failing.
42
+ */
43
+ function verifyImage(image, io = {
44
+ run,
45
+ wait: Bun.sleepSync
46
+ }) {
47
+ for (let attempt = 1;; attempt++) try {
48
+ io.run("/usr/bin/hdiutil", ["verify", image]);
49
+ return;
50
+ } catch (error) {
51
+ if (attempt === 6) throw error;
52
+ io.wait(5e3 * 2 ** (attempt - 1));
53
+ }
54
+ }
55
+ /** Build a correctly sized macOS DMG without replacing an existing artifact. */
56
+ function createMacosDmg(options) {
57
+ if (process.platform !== "darwin") throw new Error("Disk image creation requires macOS");
58
+ assertPortableAppName(options.appName);
59
+ const app = resolve(options.appPath), output = resolve(options.outputPath);
60
+ const info = lstatSync(app);
61
+ if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg")) throw new Error("Invalid disk image paths");
62
+ const staging = mkdtempSync(join(dirname(output), ".framework-dmg-"));
63
+ try {
64
+ const payload = join(staging, "payload"), image = join(staging, "result.dmg");
65
+ mkdirSync(payload);
66
+ run("/usr/bin/ditto", [app, join(payload, basename(app))]);
67
+ symlinkSync("/Applications", join(payload, "Applications"));
68
+ const capacityMiB = dmgCapacityMiB(treeSize(payload));
69
+ run("/usr/bin/hdiutil", [
70
+ "create",
71
+ "-volname",
72
+ options.appName,
73
+ "-srcfolder",
74
+ payload,
75
+ "-size",
76
+ `${capacityMiB}m`,
77
+ "-format",
78
+ "ULFO",
79
+ image
80
+ ]);
81
+ verifyImage(image);
82
+ linkSync(image, output);
83
+ return { capacityMiB };
84
+ } finally {
85
+ rmSync(staging, {
86
+ recursive: true,
87
+ force: true
88
+ });
89
+ }
90
+ }
91
+ export { createMacosDmg, dmgCapacityMiB, verifyImage };
@@ -0,0 +1,6 @@
1
+ import { type KeyObject } from 'node:crypto';
2
+ import { type ReleaseDescriptor, type SignedRelease } from '../updates/signed-release';
3
+ export type ReleaseArtifactIdentity = Omit<ReleaseDescriptor, 'schema' | 'asset'>;
4
+ /** Hash the actual staged archive without buffering it, then sign its provenance and its
5
+ * URL in the app's release feed (`feed` ends in `/`). */
6
+ export declare function signReleaseArtifact(path: string, identity: ReleaseArtifactIdentity, key: KeyObject, feed: string): Promise<SignedRelease>;
@@ -0,0 +1,38 @@
1
+ import { signReleaseDescriptor } from "../updates/signed-release.js";
2
+ import { open } from "node:fs/promises";
3
+ import { basename } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ // src/release/release-artifact.ts
6
+ /** Hash the actual staged archive without buffering it, then sign its provenance and its
7
+ * URL in the app's release feed (`feed` ends in `/`). */
8
+ async function signReleaseArtifact(path, identity, key, feed) {
9
+ const file = await open(path, "r");
10
+ try {
11
+ const before = await file.stat();
12
+ if (!before.isFile() || !Number.isSafeInteger(before.size) || before.size < 1) throw new Error("Invalid release artifact");
13
+ const hash = createHash("sha256");
14
+ let size = 0;
15
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
16
+ size += chunk.length;
17
+ if (!Number.isSafeInteger(size) || size > before.size) throw new Error("Release artifact changed during hashing");
18
+ hash.update(chunk);
19
+ }
20
+ const after = await file.stat();
21
+ if (size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ino !== before.ino || after.dev !== before.dev) throw new Error("Release artifact changed during hashing");
22
+ const name = basename(path);
23
+ const asset = {
24
+ name,
25
+ url: `${feed}${identity.tag}/${name}`,
26
+ size,
27
+ sha256: hash.digest("hex")
28
+ };
29
+ return signReleaseDescriptor({
30
+ ...identity,
31
+ schema: 2,
32
+ asset
33
+ }, key);
34
+ } finally {
35
+ await file.close();
36
+ }
37
+ }
38
+ export { signReleaseArtifact };
@@ -0,0 +1,14 @@
1
+ /** GitHub reads need credentials but must not inherit release signing keys. */
2
+ export declare function releasePlanGitHubEnvironment(env: Record<string, string | undefined>): Record<string, string>;
3
+ /** Resolve the immutable release source before building anything in a trusted assets workflow. */
4
+ export declare function planReleaseAssets(options: {
5
+ env: Record<string, string | undefined>;
6
+ config: unknown;
7
+ tag: string;
8
+ run?: (args: string[], input?: string) => Promise<string>;
9
+ }): Promise<{
10
+ tag: string;
11
+ sourceSha: string;
12
+ workflowSha: string;
13
+ version: string;
14
+ }>;
@@ -0,0 +1,65 @@
1
+ import { githubCli } from "./github-cli.js";
2
+ import { isRepositorySlug } from "../updates/signed-release.js";
3
+ import { parseReleaseConfig } from "./release-config.js";
4
+ import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
5
+ // src/release/release-assets-plan.ts
6
+ /** GitHub reads need credentials but must not inherit release signing keys. */
7
+ function releasePlanGitHubEnvironment(env) {
8
+ const clean = {};
9
+ for (const name of [
10
+ "PATH",
11
+ "HOME",
12
+ "USERPROFILE",
13
+ "SystemRoot",
14
+ "WINDIR",
15
+ "TMP",
16
+ "TEMP",
17
+ "TMPDIR",
18
+ "GH_TOKEN",
19
+ "GITHUB_TOKEN",
20
+ "GH_HOST",
21
+ "GH_CONFIG_DIR",
22
+ "XDG_CONFIG_HOME",
23
+ "HTTP_PROXY",
24
+ "HTTPS_PROXY",
25
+ "NO_PROXY",
26
+ "http_proxy",
27
+ "https_proxy",
28
+ "no_proxy",
29
+ "SSL_CERT_FILE",
30
+ "SSL_CERT_DIR"
31
+ ]) if (env[name]) clean[name] = env[name];
32
+ return clean;
33
+ }
34
+ /** Resolve the immutable release source before building anything in a trusted assets workflow. */
35
+ async function planReleaseAssets(options) {
36
+ const { env, config, tag } = options;
37
+ if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || env.GITHUB_EVENT_NAME !== "workflow_dispatch" || !isRepositorySlug(env.GITHUB_REPOSITORY ?? "") || !/^[a-f0-9]{40}$/.test(env.GITHUB_SHA ?? "") || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || !/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Asset planning requires a trusted main workflow and valid tag");
38
+ if (typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string") throw new Error("Invalid release configuration");
39
+ const { requirements, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(config);
40
+ requirements(tag);
41
+ const run = options.run ?? githubCli(releasePlanGitHubEnvironment(env));
42
+ const repository = env.GITHUB_REPOSITORY, workflowSha = env.GITHUB_SHA;
43
+ const provider = createGitHubReleaseCutProvider({
44
+ repository,
45
+ appName: config.appName,
46
+ requirements,
47
+ assetsWorkflow: releaseWorkflows.assets,
48
+ releasePleaseManifestPath,
49
+ hiddenDrafts: true,
50
+ run
51
+ });
52
+ const response = JSON.parse(await run(["api", `repos/${repository}/actions/runs/${env.GITHUB_RUN_ID}/attempts/${env.GITHUB_RUN_ATTEMPT}`]));
53
+ if (typeof response !== "object" || response === null || Array.isArray(response)) throw new Error("Invalid asset workflow response");
54
+ const workflow = response;
55
+ if (String(workflow.id) !== env.GITHUB_RUN_ID || String(workflow.run_attempt) !== env.GITHUB_RUN_ATTEMPT || workflow.head_sha !== workflowSha || workflow.head_branch !== "main" || workflow.event !== "workflow_dispatch" || workflow.path !== releaseWorkflows.assets || workflow.display_title !== `framework-release-assets:${tag}` || workflow.repository?.full_name !== repository) throw new Error("Release-assets workflow provenance mismatch");
56
+ const release = await provider.find(tag);
57
+ if (!release || (release.draft ? release.stageableDraft !== true : !release.prerelease) || !await provider.isMainAncestor(release.sourceSha) || !await provider.isMainAncestor(workflowSha)) throw new Error("Release source or workflow is not an eligible main ancestor");
58
+ return {
59
+ tag,
60
+ sourceSha: release.sourceSha,
61
+ workflowSha,
62
+ version: tag.slice(1)
63
+ };
64
+ }
65
+ export { planReleaseAssets, releasePlanGitHubEnvironment };