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

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 (474) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +967 -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 +125 -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 +318 -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/settings-sections.d.ts +31 -0
  236. package/dist/shell/settings-sections.js +50 -0
  237. package/dist/shell/shortcut-platform.d.ts +17 -0
  238. package/dist/shell/shortcut-platform.js +25 -0
  239. package/dist/update-helper.bundle.js +260 -0
  240. package/dist/updates/channel-update-manager.d.ts +46 -0
  241. package/dist/updates/channel-update-manager.js +114 -0
  242. package/dist/updates/desktop-updater.d.ts +104 -0
  243. package/dist/updates/desktop-updater.js +345 -0
  244. package/dist/updates/release-feed.d.ts +61 -0
  245. package/dist/updates/release-feed.js +111 -0
  246. package/dist/updates/release-location.d.ts +9 -0
  247. package/dist/updates/release-location.js +80 -0
  248. package/dist/updates/release-version.d.ts +12 -0
  249. package/dist/updates/release-version.js +43 -0
  250. package/dist/updates/signed-release.d.ts +63 -0
  251. package/dist/updates/signed-release.js +162 -0
  252. package/dist/updates/stable-file.d.ts +10 -0
  253. package/dist/updates/stable-file.js +22 -0
  254. package/dist/updates/update-adapter.d.ts +57 -0
  255. package/dist/updates/update-adapter.js +72 -0
  256. package/dist/updates/update-arm.d.ts +24 -0
  257. package/dist/updates/update-arm.js +95 -0
  258. package/dist/updates/update-channel-store.d.ts +8 -0
  259. package/dist/updates/update-channel-store.js +72 -0
  260. package/dist/updates/update-discovery.d.ts +13 -0
  261. package/dist/updates/update-discovery.js +56 -0
  262. package/dist/updates/update-download.d.ts +14 -0
  263. package/dist/updates/update-download.js +67 -0
  264. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  265. package/dist/updates/update-exclusive-rename.js +52 -0
  266. package/dist/updates/update-extraction.d.ts +18 -0
  267. package/dist/updates/update-extraction.js +183 -0
  268. package/dist/updates/update-handoff-plan.d.ts +22 -0
  269. package/dist/updates/update-handoff-plan.js +28 -0
  270. package/dist/updates/update-helper.d.ts +24 -0
  271. package/dist/updates/update-helper.js +56 -0
  272. package/dist/updates/update-launch.d.ts +5 -0
  273. package/dist/updates/update-launch.js +27 -0
  274. package/dist/updates/update-manager.d.ts +40 -0
  275. package/dist/updates/update-manager.js +83 -0
  276. package/dist/updates/update-process-fence.d.ts +10 -0
  277. package/dist/updates/update-process-fence.js +114 -0
  278. package/dist/updates/update-resume.d.ts +13 -0
  279. package/dist/updates/update-resume.js +34 -0
  280. package/dist/updates/update-shutdown.d.ts +15 -0
  281. package/dist/updates/update-shutdown.js +29 -0
  282. package/dist/updates/update-state.d.ts +30 -0
  283. package/dist/updates/update-state.js +18 -0
  284. package/dist/updates/update-swap-stage.d.ts +27 -0
  285. package/dist/updates/update-swap-stage.js +58 -0
  286. package/dist/updates/update-swap.d.ts +10 -0
  287. package/dist/updates/update-swap.js +30 -0
  288. package/dist/views/app-about.d.ts +22 -0
  289. package/dist/views/app-about.js +43 -0
  290. package/dist/views/app-appearance.d.ts +11 -0
  291. package/dist/views/app-appearance.js +42 -0
  292. package/dist/views/app-help.d.ts +17 -0
  293. package/dist/views/app-help.js +42 -0
  294. package/dist/views/app-settings.d.ts +26 -0
  295. package/dist/views/app-settings.js +97 -0
  296. package/dist/views/appearance-surface.d.ts +9 -0
  297. package/dist/views/appearance-surface.js +334 -0
  298. package/dist/views/update-surface.d.ts +34 -0
  299. package/dist/views/update-surface.js +64 -0
  300. package/package.json +363 -4
  301. package/src/app/application.tsx +138 -0
  302. package/src/app/create-application.ts +245 -0
  303. package/src/app/service-registry.ts +124 -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/ci/toolchain-identity.ts +244 -0
  315. package/src/cli/cef-helper-cli.ts +21 -0
  316. package/src/cli/cli-runner.ts +29 -0
  317. package/src/cli/create-application-cli.ts +62 -0
  318. package/src/cli/electrobun-shortcut-patch-cli.ts +24 -0
  319. package/src/cli/framework-update-cli.ts +41 -0
  320. package/src/cli/release-assets-plan-cli.ts +14 -0
  321. package/src/cli/release-cut-cli.ts +41 -0
  322. package/src/cli/release-descriptor-staging-cli.ts +57 -0
  323. package/src/cli/release-finalize-cli.ts +34 -0
  324. package/src/cli/release-promote-cli.ts +31 -0
  325. package/src/cli/release-publish-cli.ts +46 -0
  326. package/src/cli/release-sign-cli.ts +24 -0
  327. package/src/cli/release-step-cli.ts +71 -0
  328. package/src/cli/toolchain-identity-cli.ts +12 -0
  329. package/src/cli/update-helper-cli.ts +12 -0
  330. package/src/cli/windows-runtime-patch-cli.ts +17 -0
  331. package/src/desktop/application-command-client.ts +43 -0
  332. package/src/desktop/channel-handshake.ts +136 -0
  333. package/src/desktop/channel-proof.ts +122 -0
  334. package/src/desktop/client-assets.ts +75 -0
  335. package/src/desktop/desktop-client.ts +303 -0
  336. package/src/desktop/desktop-gateway.ts +189 -0
  337. package/src/desktop/desktop-host.ts +335 -0
  338. package/src/desktop/desktop-stream.ts +324 -0
  339. package/src/desktop/loopback-policy.ts +41 -0
  340. package/src/desktop/open-url-channel.ts +79 -0
  341. package/src/desktop/string-policy.ts +9 -0
  342. package/src/installer/archive-entry.ts +32 -0
  343. package/src/installer/command-artifact.ts +307 -0
  344. package/src/installer/command-qualification-command.ts +75 -0
  345. package/src/installer/hosted-runner.ts +11 -0
  346. package/src/installer/installed-payload.ts +408 -0
  347. package/src/installer/installer-ci-bootstrap.ts +199 -0
  348. package/src/installer/installer-ci-preflight.ts +61 -0
  349. package/src/installer/installer-ci-worker.ts +105 -0
  350. package/src/installer/installer-extraction.ts +367 -0
  351. package/src/installer/installer-fetch-guard.ts +75 -0
  352. package/src/installer/installer-identity.ts +331 -0
  353. package/src/installer/installer-layout.ts +167 -0
  354. package/src/installer/installer-observation.ts +671 -0
  355. package/src/installer/installer-process-cleanup.ts +167 -0
  356. package/src/installer/installer-qualification-command.ts +81 -0
  357. package/src/installer/installer-renderer-evidence.ts +268 -0
  358. package/src/installer/installer-upgrade-command.ts +226 -0
  359. package/src/installer/installer-worker-guard.ts +112 -0
  360. package/src/installer/native-executable.ts +37 -0
  361. package/src/installer/upgrade-asset-download.ts +72 -0
  362. package/src/installer/write-all.ts +19 -0
  363. package/src/native/app-bundle.ts +86 -0
  364. package/src/native/cef-helper.ts +471 -0
  365. package/src/native/desktop-build-hook.ts +21 -0
  366. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  367. package/src/native/electrobun-source-patch.ts +107 -0
  368. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  369. package/src/native/linux-cef-links.ts +14 -0
  370. package/src/native/native-secret-store.ts +99 -0
  371. package/src/native/native-utilities.ts +166 -0
  372. package/src/native/partitioned-window.ts +62 -0
  373. package/src/native/renderer-profile.ts +27 -0
  374. package/src/native/secure-window.ts +115 -0
  375. package/src/native/sidecar-services.ts +71 -0
  376. package/src/native/sidecar.ts +387 -0
  377. package/src/native/window-bootstrap.ts +77 -0
  378. package/src/native/window-options.ts +24 -0
  379. package/src/native/windows-build-hook-internal.ts +49 -0
  380. package/src/native/windows-build-hook.ts +12 -0
  381. package/src/native/windows-runtime-patch-internal.ts +48 -0
  382. package/src/native/windows-runtime-patch.ts +15 -0
  383. package/src/release/feed-release-cut.ts +110 -0
  384. package/src/release/feed-state.ts +135 -0
  385. package/src/release/framework-package-publish.ts +163 -0
  386. package/src/release/framework-update.ts +196 -0
  387. package/src/release/github-cli.ts +27 -0
  388. package/src/release/github-release-assets.ts +36 -0
  389. package/src/release/github-release-cut.ts +237 -0
  390. package/src/release/github-release-lookup.ts +39 -0
  391. package/src/release/github-release-promotion.ts +112 -0
  392. package/src/release/github-release-provenance.ts +65 -0
  393. package/src/release/github-release-publisher.ts +90 -0
  394. package/src/release/github-release-qualification.ts +144 -0
  395. package/src/release/local-provenance.ts +92 -0
  396. package/src/release/local-release.ts +525 -0
  397. package/src/release/macos-dmg.ts +113 -0
  398. package/src/release/release-artifact.ts +53 -0
  399. package/src/release/release-assets-plan.ts +118 -0
  400. package/src/release/release-config.ts +420 -0
  401. package/src/release/release-cut-command.ts +80 -0
  402. package/src/release/release-cut.ts +133 -0
  403. package/src/release/release-descriptor-staging.ts +242 -0
  404. package/src/release/release-finalize.ts +191 -0
  405. package/src/release/release-promotion-command.ts +36 -0
  406. package/src/release/release-promotion.ts +132 -0
  407. package/src/release/release-publication.ts +213 -0
  408. package/src/release/release-publish-command.ts +163 -0
  409. package/src/release/release-qualification.ts +397 -0
  410. package/src/release/release-staging.ts +87 -0
  411. package/src/release/release-steps.ts +173 -0
  412. package/src/release/retained-release-build.ts +217 -0
  413. package/src/shell/app-shell.tsx +285 -0
  414. package/src/shell/app-utilities.tsx +437 -0
  415. package/src/shell/application-menu-commands.ts +6 -0
  416. package/src/shell/application-menu.ts +250 -0
  417. package/src/shell/help-shortcuts.ts +24 -0
  418. package/src/shell/settings-sections.ts +74 -0
  419. package/src/shell/shortcut-platform.ts +35 -0
  420. package/src/updates/channel-update-manager.ts +127 -0
  421. package/src/updates/desktop-updater.ts +440 -0
  422. package/src/updates/release-feed.ts +187 -0
  423. package/src/updates/release-location.ts +101 -0
  424. package/src/updates/release-version.ts +57 -0
  425. package/src/updates/signed-release.ts +311 -0
  426. package/src/updates/stable-file.ts +32 -0
  427. package/src/updates/update-adapter.ts +129 -0
  428. package/src/updates/update-arm.ts +107 -0
  429. package/src/updates/update-channel-store.ts +86 -0
  430. package/src/updates/update-discovery.ts +113 -0
  431. package/src/updates/update-download.ts +82 -0
  432. package/src/updates/update-exclusive-rename.ts +58 -0
  433. package/src/updates/update-extraction.ts +261 -0
  434. package/src/updates/update-handoff-plan.ts +75 -0
  435. package/src/updates/update-helper.ts +87 -0
  436. package/src/updates/update-launch.ts +33 -0
  437. package/src/updates/update-manager.ts +130 -0
  438. package/src/updates/update-process-fence.ts +125 -0
  439. package/src/updates/update-resume.ts +34 -0
  440. package/src/updates/update-shutdown.ts +37 -0
  441. package/src/updates/update-state.ts +34 -0
  442. package/src/updates/update-swap-stage.ts +75 -0
  443. package/src/updates/update-swap.ts +30 -0
  444. package/src/views/app-about.tsx +44 -0
  445. package/src/views/app-appearance.tsx +32 -0
  446. package/src/views/app-help.tsx +43 -0
  447. package/src/views/app-settings.tsx +88 -0
  448. package/src/views/appearance-surface.tsx +427 -0
  449. package/src/views/update-surface.tsx +85 -0
  450. package/templates/application/.gitattributes +1 -0
  451. package/templates/application/.github/workflows/release-assets.yml +29 -0
  452. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  453. package/templates/application/.github/workflows/release-please.yml +19 -0
  454. package/templates/application/.github/workflows/release.yml +29 -0
  455. package/templates/application/.github/workflows/validation.yml +28 -0
  456. package/templates/application/.oxfmtrc.json +6 -0
  457. package/templates/application/.oxlintrc.json +48 -0
  458. package/templates/application/.release-please-manifest.json +3 -0
  459. package/templates/application/README.md +47 -0
  460. package/templates/application/electrobun.config.ts +22 -0
  461. package/templates/application/release-please-config.json +12 -0
  462. package/templates/application/scripts/app-version.ts +9 -0
  463. package/templates/application/scripts/build-desktop.ts +34 -0
  464. package/templates/application/scripts/secure-build.ts +1 -0
  465. package/templates/application/scripts/stage-release.ts +21 -0
  466. package/templates/application/src/bun/index.ts +80 -0
  467. package/templates/application/src/electrobun.d.ts +27 -0
  468. package/templates/application/src/web/index.html +12 -0
  469. package/templates/application/src/web/main.tsx +97 -0
  470. package/templates/application/src/web/public/icon.svg +1 -0
  471. package/templates/application/src/web/style.css +3 -0
  472. package/templates/application/tests/app-config.test.ts +9 -0
  473. package/templates/application/tsconfig.json +15 -0
  474. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bun
2
+ import { planReleaseAssets } from '../release/release-assets-plan'
3
+ import { readJsonFile, runCli } from './cli-runner'
4
+
5
+ await runCli(
6
+ 'Unable to plan release assets; check release provenance and the trusted workflow.',
7
+ async () => {
8
+ const [tag, path, ...extra] = process.argv.slice(2)
9
+ if (!tag || !path || extra.length)
10
+ throw new Error('Expected release tag and configuration file')
11
+ const config = await readJsonFile(path, 262144)
12
+ console.log(JSON.stringify(await planReleaseAssets({ env: process.env, config, tag })))
13
+ }
14
+ )
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bun
2
+ import { runReleaseCutCommand } from '../release/release-cut-command'
3
+ import { gitCli } from '../release/local-provenance'
4
+ import { hostReleasePlatform, runLocalReleaseCut } from '../release/local-release'
5
+ import { readJsonFile, runCli } from './cli-runner'
6
+
7
+ // `release-cut-cli.js <dev|daily> <config>` in the trusted control workflow, or
8
+ // `release-cut-cli.js --local <dev|daily> <config> <source-sha>` from a clean checkout.
9
+ const local = process.argv[2] === '--local'
10
+ await runCli(
11
+ 'Unable to cut the release; check the trusted workflow or local checkout and release configuration.',
12
+ async () => {
13
+ const [kind, path, sourceSha, ...extra] = process.argv.slice(local ? 3 : 2)
14
+ if ((kind !== 'daily' && kind !== 'dev') || !path || extra.length || !sourceSha !== !local)
15
+ throw new Error('Invalid workflow invocation')
16
+ const config = await readJsonFile(path, 65536)
17
+ if (
18
+ typeof config !== 'object' ||
19
+ config === null ||
20
+ typeof (config as { appName?: unknown }).appName !== 'string'
21
+ )
22
+ throw new Error('Missing app name')
23
+ const result = local
24
+ ? await runLocalReleaseCut({
25
+ kind,
26
+ config,
27
+ sourceSha: sourceSha!,
28
+ platform: hostReleasePlatform(),
29
+ git: gitCli(),
30
+ fetch,
31
+ })
32
+ : await runReleaseCutCommand({
33
+ env: process.env,
34
+ kind,
35
+ appName: (config as { appName: string }).appName,
36
+ config,
37
+ })
38
+ process.stdout.write(JSON.stringify(result) + '\n')
39
+ },
40
+ { requireGitHubActions: !local }
41
+ )
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bun
2
+ import { createPrivateKey } from 'node:crypto'
3
+ import { gitCli } from '../release/local-provenance'
4
+ import {
5
+ hostReleasePlatform,
6
+ localTagProvenance,
7
+ stageLocalDescriptors,
8
+ } from '../release/local-release'
9
+ import { stageReleaseDescriptors } from '../release/release-descriptor-staging'
10
+ import { readJsonFile, runCli } from './cli-runner'
11
+
12
+ // `release-descriptor-staging-cli.js [--local] <directory> <config>` with RELEASE_TAG and the
13
+ // signing key in the environment. Locally it signs this machine's platform only, with
14
+ // SOURCE_SHA and the local run number RELEASE_RUN_ID as provenance.
15
+ const local = process.argv[2] === '--local'
16
+ await runCli(
17
+ 'Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.',
18
+ async () => {
19
+ const [directory, configPath, ...extra] = process.argv.slice(local ? 3 : 2)
20
+ const {
21
+ RELEASE_TAG: tag,
22
+ ADEA_RELEASE_SIGNING_KEY: pem,
23
+ ADEA_RELEASE_SIGNING_KEY_ID: keyId,
24
+ SOURCE_SHA: sourceSha,
25
+ RELEASE_RUN_ID: runId,
26
+ } = process.env
27
+ if (!directory || !configPath || extra.length || !tag || !pem || !keyId)
28
+ throw new Error('Missing signing context')
29
+ const config = await readJsonFile(configPath, 262144)
30
+ if (!local) {
31
+ const names = await stageReleaseDescriptors({
32
+ env: process.env,
33
+ config,
34
+ directory,
35
+ tag,
36
+ keyId,
37
+ privateKey: createPrivateKey(pem),
38
+ })
39
+ console.log(JSON.stringify(names))
40
+ return
41
+ }
42
+ if (!sourceSha || !runId) throw new Error('Missing local release identity')
43
+ const { repository } = await localTagProvenance({ config, tag, sourceSha, git: gitCli() })
44
+ const names = await stageLocalDescriptors({
45
+ config,
46
+ directory,
47
+ tag,
48
+ sourceSha,
49
+ repository,
50
+ runId,
51
+ platform: hostReleasePlatform(),
52
+ keyId,
53
+ privateKey: createPrivateKey(pem),
54
+ })
55
+ console.log(JSON.stringify(names))
56
+ }
57
+ )
@@ -0,0 +1,34 @@
1
+ import { readFile } from 'node:fs/promises'
2
+ import { gitCli, originRepository } from '../release/local-provenance'
3
+ import { verifyLocalRelease } from '../release/local-release'
4
+ import { finalizeReleasePleaseDraft, parseFinalizationEvent } from '../release/release-finalize'
5
+
6
+ // A local release has no draft to finalize: `--local <config> <tag>` verifies what the feed
7
+ // publishes for the tag instead, after an upload.
8
+ if (process.argv[2] === '--local') {
9
+ const [configPath, tag, ...extra] = process.argv.slice(3)
10
+ if (!configPath || !tag || extra.length) throw new Error('Expected release configuration and tag')
11
+ const config: unknown = JSON.parse(await readFile(configPath, 'utf8'))
12
+ const result = await verifyLocalRelease({
13
+ config,
14
+ tag,
15
+ repository: await originRepository(gitCli()),
16
+ fetch,
17
+ })
18
+ console.log(JSON.stringify(result))
19
+ } else {
20
+ const configPath = process.argv[2]
21
+ if (!configPath || process.argv.length !== 3 || !process.env.GITHUB_EVENT_PATH)
22
+ throw new Error('Expected release configuration and workflow event')
23
+ const config: unknown = JSON.parse(await readFile(configPath, 'utf8'))
24
+ if (typeof config !== 'object' || config === null || Array.isArray(config))
25
+ throw new Error('Invalid release configuration')
26
+ const event: unknown = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH, 'utf8'))
27
+ const identity = parseFinalizationEvent(
28
+ event,
29
+ process.env.GITHUB_REPOSITORY ?? '',
30
+ process.env.GITHUB_EVENT_NAME
31
+ )
32
+ await finalizeReleasePleaseDraft({ env: process.env, config, ...identity })
33
+ console.log('Qualified draft published as a prerelease')
34
+ }
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bun
2
+ import { gitCli, originRepository } from '../release/local-provenance'
3
+ import { runLocalPromotion } from '../release/local-release'
4
+ import { runPromotionCommand } from '../release/release-promotion-command'
5
+ import { readJsonFile, runCli } from './cli-runner'
6
+
7
+ // `release-promote-cli.js <config>` in the trusted workflow, or
8
+ // `release-promote-cli.js --local <config> <out>`, which stages the feed update under <out>.
9
+ const local = process.argv[2] === '--local'
10
+ await runCli(
11
+ 'Unable to promote the release; check the trusted workflow or feed and release configuration.',
12
+ async () => {
13
+ const [path, out, ...extra] = process.argv.slice(local ? 3 : 2)
14
+ const held = process.env.STABLE_PROMOTION_HELD
15
+ if (!path || extra.length || !out !== !local || !['true', 'false', undefined].includes(held))
16
+ throw new Error('Invalid workflow invocation')
17
+ const config = await readJsonFile(path, 65536)
18
+ const result = local
19
+ ? await runLocalPromotion({
20
+ config,
21
+ out: out!,
22
+ now: new Date().toISOString(),
23
+ held: held === 'true',
24
+ repository: await originRepository(gitCli()),
25
+ fetch,
26
+ })
27
+ : await runPromotionCommand({ env: process.env, config })
28
+ process.stdout.write(JSON.stringify(local ? { ...result, plan: undefined } : result) + '\n')
29
+ },
30
+ { requireGitHubActions: !local }
31
+ )
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bun
2
+ import { gitCli } from '../release/local-provenance'
3
+ import {
4
+ hostReleasePlatform,
5
+ localTagProvenance,
6
+ stageLocalRelease,
7
+ } from '../release/local-release'
8
+ import { runReleasePublishCommand } from '../release/release-publish-command'
9
+ import { readJsonFile, runCli } from './cli-runner'
10
+
11
+ // `release-publish-cli.js <directory> <config>` in the trusted assets workflow, or
12
+ // `release-publish-cli.js --local <directory> <config> <out>` with RELEASE_TAG and SOURCE_SHA,
13
+ // which stages the feed upload under <out> instead of publishing.
14
+ const local = process.argv[2] === '--local'
15
+ await runCli(
16
+ 'Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.',
17
+ async () => {
18
+ const [directory, configPath, out, ...extra] = process.argv.slice(local ? 3 : 2)
19
+ if (!directory || !configPath || extra.length || !out !== !local)
20
+ throw new Error('Invalid workflow invocation')
21
+ const config = await readJsonFile(configPath, 65536)
22
+ if (local) {
23
+ const { RELEASE_TAG: tag, SOURCE_SHA: sourceSha } = process.env
24
+ if (!tag || !sourceSha) throw new Error('Missing local release identity')
25
+ const { repository } = await localTagProvenance({ config, tag, sourceSha, git: gitCli() })
26
+ const plan = await stageLocalRelease({
27
+ config,
28
+ directory,
29
+ out: out!,
30
+ tag,
31
+ sourceSha,
32
+ repository,
33
+ platform: hostReleasePlatform(),
34
+ now: new Date().toISOString(),
35
+ fetch,
36
+ })
37
+ process.stdout.write(JSON.stringify({ tag, objects: plan.objects.length }) + '\n')
38
+ return
39
+ }
40
+ const result = await runReleasePublishCommand({ env: process.env, config, directory })
41
+ process.stdout.write(
42
+ JSON.stringify({ tag: result.tag, runId: result.runId, runAttempt: result.runAttempt }) + '\n'
43
+ )
44
+ },
45
+ { requireGitHubActions: !local }
46
+ )
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bun
2
+ import { createPrivateKey } from 'node:crypto'
3
+ import { signReleaseArtifact, type ReleaseArtifactIdentity } from '../release/release-artifact'
4
+ import { readJsonFile, runCli } from './cli-runner'
5
+
6
+ // The signing key is passed in the environment, never in command arguments or output.
7
+ await runCli(
8
+ 'Unable to sign release artifact; check the identity, archive and signing key.',
9
+ async () => {
10
+ const [identityPath, artifactPath, feed, ...extra] = process.argv.slice(2)
11
+ if (
12
+ !identityPath ||
13
+ !artifactPath ||
14
+ !feed ||
15
+ extra.length ||
16
+ !process.env.ADEA_RELEASE_SIGNING_KEY
17
+ )
18
+ throw new Error('usage')
19
+ const identity = (await readJsonFile(identityPath, 16384)) as ReleaseArtifactIdentity
20
+ const key = createPrivateKey(process.env.ADEA_RELEASE_SIGNING_KEY)
21
+ const result = await signReleaseArtifact(artifactPath, identity, key, feed)
22
+ process.stdout.write(JSON.stringify(result) + '\n')
23
+ }
24
+ )
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bun
2
+ import {
3
+ inspectStagedStep,
4
+ qualifyStep,
5
+ qualifyUpgradeStep,
6
+ releasePlatform,
7
+ selectRetainedStep,
8
+ stageBuildStep,
9
+ type ReleaseStepContext,
10
+ } from '../release/release-steps'
11
+ import { readJsonFile, runCli } from './cli-runner'
12
+
13
+ // `release-step-cli.js <step> [--artifacts <dir>] <platform> [directory]`, run
14
+ // in the app directory with RELEASE_TAG. The reusable release-assets workflow
15
+ // appends the platform and staging directory to each `release:<step>` script.
16
+ await runCli(
17
+ (error) => `Release step failed: ${error instanceof Error ? error.message : String(error)}`,
18
+ async () => {
19
+ const args = process.argv.slice(2)
20
+ const flag = args.indexOf('--artifacts')
21
+ const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1]
22
+ if (flag !== -1 && !artifacts) throw new Error('Expected a directory after --artifacts')
23
+ const [step, platform, directory, ...extra] = args
24
+ const tag = process.env.RELEASE_TAG
25
+ if (!tag || extra.length)
26
+ throw new Error('Expected <step> <platform> [directory] and RELEASE_TAG')
27
+ const config = await readJsonFile('release-config.json', 262144)
28
+ if (
29
+ typeof config !== 'object' ||
30
+ config === null ||
31
+ typeof (config as { appName?: unknown }).appName !== 'string'
32
+ )
33
+ throw new Error('release-config.json names no app')
34
+ const context: ReleaseStepContext = {
35
+ env: process.env,
36
+ config: config as ReleaseStepContext['config'],
37
+ tag,
38
+ platform: releasePlatform(platform),
39
+ }
40
+ if (step === 'select-retained') {
41
+ if (directory) throw new Error('select-retained takes only the platform')
42
+ return selectRetainedStep(context)
43
+ }
44
+ if (!directory) throw new Error('Expected a staging directory')
45
+ switch (step) {
46
+ case 'stage-build':
47
+ console.log(JSON.stringify(await stageBuildStep(context, directory, artifacts)))
48
+ return
49
+ case 'inspect':
50
+ console.log(JSON.stringify((await inspectStagedStep(context, directory)).identity))
51
+ return
52
+ case 'qualify':
53
+ await qualifyStep(context, directory)
54
+ console.log('Installer qualification receipt staged')
55
+ return
56
+ case 'qualify-upgrade': {
57
+ const receipt = await qualifyUpgradeStep(context, directory, (stage) =>
58
+ console.log(`upgrade: ${stage}`)
59
+ )
60
+ console.log(
61
+ receipt
62
+ ? `Upgraded ${receipt.from.tag} to ${tag} and observed the new version`
63
+ : 'No earlier published release to upgrade from'
64
+ )
65
+ return
66
+ }
67
+ default:
68
+ throw new Error(`Unknown release step ${String(step)}`)
69
+ }
70
+ }
71
+ )
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { verifyToolchain } from '../ci/toolchain-identity'
3
+
4
+ // Run with node: the id's libc comes from Node's process report, as in the
5
+ // `vp` config process that wrote it.
6
+ const at = process.argv.indexOf('--expect')
7
+ const expected = at === -1 ? undefined : process.argv[at + 1]
8
+ if (!expected) {
9
+ console.error('toolchain-identity: usage: adea-toolchain-identity --expect <id>')
10
+ process.exit(2)
11
+ }
12
+ process.exit(verifyToolchain(expected))
@@ -0,0 +1,12 @@
1
+ import { runUpdateHelper } from '../updates/update-helper'
2
+
3
+ // Bundled standalone (dist/update-helper.bundle.js) so an app can ship it next
4
+ // to its own bundle and run it with a copy of its Bun runtime.
5
+ const index = process.argv.indexOf('--staging')
6
+ const staging = index > 0 ? process.argv[index + 1] : undefined
7
+ if (!staging) {
8
+ console.error('Usage: update-helper --staging <directory>')
9
+ process.exit(2)
10
+ }
11
+ const outcome = await runUpdateHelper({ staging }).catch(() => 'failed' as const)
12
+ process.exit(outcome === 'updated' ? 0 : 1)
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bun
2
+ import { readFile, stat, writeFile } from 'node:fs/promises'
3
+ import {
4
+ patchPinnedWindowsRuntime,
5
+ SECURE_WINDOWS_WRAPPER_SHA256,
6
+ } from '../native/windows-runtime-patch'
7
+ import { runCli } from './cli-runner'
8
+
9
+ await runCli('Unable to patch the pinned unsigned Windows runtime.', async () => {
10
+ const [input, output, ...extra] = process.argv.slice(2)
11
+ if (!input || !output || extra.length) throw new Error('Invalid invocation')
12
+ const info = await stat(input)
13
+ if (!info.isFile() || info.size > 64 * 1024 * 1024) throw new Error('Invalid runtime')
14
+ const patched = patchPinnedWindowsRuntime(await readFile(input))
15
+ await writeFile(output, patched, { flag: 'wx', mode: 0o600 })
16
+ process.stdout.write(`Patched Windows runtime SHA-256: ${SECURE_WINDOWS_WRAPPER_SHA256}\n`)
17
+ })
@@ -0,0 +1,43 @@
1
+ import {
2
+ applicationCommandStream,
3
+ applicationMenuCommands,
4
+ } from '../shell/application-menu-commands'
5
+
6
+ /** The shared-surface commands `ApplicationUtilities` provides. */
7
+ export type ApplicationCommandTarget = Readonly<{
8
+ openAbout(): void
9
+ openSettings(): void
10
+ openHelp(): void
11
+ openUpdates(): void
12
+ }>
13
+
14
+ type StreamClient = {
15
+ openStream(
16
+ name: string,
17
+ input: unknown,
18
+ onMessage: (payload: string | ArrayBuffer) => void,
19
+ onClose?: () => void
20
+ ): Promise<{ close(): void }>
21
+ }
22
+
23
+ /** Route native menu commands from the desktop host to the shared surfaces. */
24
+ export async function connectApplicationCommands(
25
+ client: StreamClient,
26
+ commands: ApplicationCommandTarget
27
+ ): Promise<() => void> {
28
+ const stream = await client.openStream(applicationCommandStream, null, (payload) => {
29
+ if (typeof payload !== 'string' || payload.length > 64) return
30
+ let command: unknown
31
+ try {
32
+ command = (JSON.parse(payload) as { command?: unknown }).command
33
+ } catch {
34
+ return
35
+ }
36
+ if (!(applicationMenuCommands as readonly unknown[]).includes(command)) return
37
+ if (command === 'about') commands.openAbout()
38
+ else if (command === 'settings') commands.openSettings()
39
+ else if (command === 'help') commands.openHelp()
40
+ else commands.openUpdates()
41
+ })
42
+ return () => stream.close()
43
+ }
@@ -0,0 +1,136 @@
1
+ // Adapted from adea-ai/adea's dev-runtime/channel/authority.ts at
2
+ // eb11acdf14cb21a56bd90fdd9e6bdef9170e71d9 (Apache-2.0).
3
+ import { randomBytes, randomUUID, timingSafeEqual } from 'node:crypto'
4
+ import type { ChannelIdentity, VerifiedChannel } from './channel-proof'
5
+
6
+ type Channel<Principal> = VerifiedChannel<Principal> & { credentialId: string; secret: Buffer }
7
+ type Launch<Principal> = { secret: Buffer; expiresAt: number; principal: Principal }
8
+
9
+ /**
10
+ * In-process channel authority. Deliver bootstrap only through a trusted native
11
+ * window and require origin screening separately. Never put bootstrap in an HTTP
12
+ * document or treat browser headers as proof of window identity.
13
+ */
14
+ export function createChannelAuthority<Principal>(
15
+ options: {
16
+ now?: () => number
17
+ bootstrapLifetimeMs?: number
18
+ channelLifetimeMs?: number
19
+ maxChannels?: number
20
+ } = {}
21
+ ) {
22
+ const clock = options.now ?? Date.now
23
+ const bootstrapLifetime = options.bootstrapLifetimeMs ?? 60000
24
+ const channelLifetime = options.channelLifetimeMs ?? 12 * 60 * 60 * 1000
25
+ const maxChannels = options.maxChannels ?? 4
26
+ if (
27
+ ![bootstrapLifetime, channelLifetime, maxChannels].every(
28
+ (value) => Number.isSafeInteger(value) && value > 0
29
+ )
30
+ )
31
+ throw new Error('Invalid channel authority configuration')
32
+ let launch: Launch<Principal> | undefined
33
+ const channels = new Map<string, Channel<Principal>>()
34
+ const listeners = new Set<(identity: ChannelIdentity) => void>()
35
+ function remove(id: string, channel: Channel<Principal>) {
36
+ if (channels.get(id) !== channel) return
37
+ channels.delete(id)
38
+ channel.secret.fill(0)
39
+ // Snapshot because listeners may add or remove subscriptions while revocation is delivered.
40
+ // oxlint-disable-next-line unicorn/no-useless-spread
41
+ for (const listener of [...listeners]) {
42
+ try {
43
+ listener({ channelId: id, credentialId: channel.credentialId })
44
+ } catch {
45
+ /* Revocation must not be interrupted by a listener. */
46
+ }
47
+ }
48
+ }
49
+ function time() {
50
+ const at = clock()
51
+ if (
52
+ !Number.isSafeInteger(at) ||
53
+ at < 0 ||
54
+ at > Number.MAX_SAFE_INTEGER - Math.max(bootstrapLifetime, channelLifetime)
55
+ )
56
+ throw new Error('Invalid channel clock')
57
+ return at
58
+ }
59
+ function clearLaunch() {
60
+ launch?.secret.fill(0)
61
+ launch = undefined
62
+ }
63
+ function sweep(at: number) {
64
+ if (launch && launch.expiresAt <= at) clearLaunch()
65
+ for (const [id, channel] of channels) if (channel.expiresAt <= at) remove(id, channel)
66
+ }
67
+ return {
68
+ /** Invalidates an earlier unused bootstrap; the caller must keep the result secret. */
69
+ issue(principal: Principal) {
70
+ const at = time()
71
+ sweep(at)
72
+ clearLaunch()
73
+ const secret = randomBytes(32)
74
+ launch = { secret, expiresAt: at + bootstrapLifetime, principal }
75
+ return { bootstrap: secret.toString('base64url'), expiresAt: launch.expiresAt }
76
+ },
77
+ handshake(bootstrap: string):
78
+ | { ok: false }
79
+ | {
80
+ ok: true
81
+ channelId: string
82
+ credentialId: string
83
+ clientSecret: string
84
+ expiresAt: number
85
+ } {
86
+ const at = time()
87
+ sweep(at)
88
+ if (!launch || typeof bootstrap !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(bootstrap))
89
+ return { ok: false }
90
+ const supplied = Buffer.from(bootstrap, 'base64url')
91
+ if (
92
+ supplied.length !== launch.secret.length ||
93
+ !timingSafeEqual(supplied, launch.secret) ||
94
+ channels.size >= maxChannels
95
+ )
96
+ return { ok: false }
97
+ const principal = launch.principal
98
+ clearLaunch()
99
+ const channelId = randomUUID()
100
+ const credentialId = randomUUID()
101
+ const secret = randomBytes(32)
102
+ const expiresAt = at + channelLifetime
103
+ channels.set(channelId, { credentialId, secret, expiresAt, principal })
104
+ return {
105
+ ok: true,
106
+ channelId,
107
+ credentialId,
108
+ clientSecret: secret.toString('base64url'),
109
+ expiresAt,
110
+ }
111
+ },
112
+ resolve(identity: ChannelIdentity): VerifiedChannel<Principal> | undefined {
113
+ const at = time()
114
+ sweep(at)
115
+ const channel = channels.get(identity.channelId)
116
+ if (!channel || channel.credentialId !== identity.credentialId) return undefined
117
+ return channel
118
+ },
119
+ revoke(identity: ChannelIdentity) {
120
+ const channel = channels.get(identity.channelId)
121
+ if (channel && channel.credentialId === identity.credentialId)
122
+ remove(identity.channelId, channel)
123
+ },
124
+ revokeAll() {
125
+ clearLaunch()
126
+ for (const [id, channel] of channels) remove(id, channel)
127
+ },
128
+ /** Notify long-lived transports after a channel is removed. Expiry is swept on authority access. */
129
+ onRevoke(listener: (identity: ChannelIdentity) => void) {
130
+ listeners.add(listener)
131
+ return () => {
132
+ listeners.delete(listener)
133
+ }
134
+ },
135
+ }
136
+ }
@@ -0,0 +1,122 @@
1
+ // Compatible with the legacy invoke proof in adea-ai/adea's channel/authority.ts
2
+ // at eb11acdf14cb21a56bd90fdd9e6bdef9170e71d9 (Apache-2.0).
3
+ import { createHash, createHmac, timingSafeEqual } from 'node:crypto'
4
+ import { containsAsciiControl } from './string-policy'
5
+
6
+ export type ChannelIdentity = Readonly<{ channelId: string; credentialId: string }>
7
+ export type ProofFields = ChannelIdentity &
8
+ Readonly<{ nonce: string; timestamp: string; bodySha256: string }>
9
+ export type SignedRequest = ChannelIdentity &
10
+ Readonly<{ nonce: string; timestamp: string; proof: string; body: string }>
11
+ export type VerifiedChannel<Principal> = Readonly<{
12
+ secret: Uint8Array
13
+ expiresAt: number
14
+ principal: Principal
15
+ }>
16
+ export type ProofResult<Principal> =
17
+ | { ok: true; principal: Principal }
18
+ | { ok: false; code: 'unauthenticated' | 'expired' | 'replay' | 'capacity' | 'invalid' }
19
+ const separator = '\u001f'
20
+ const field = (value: unknown): value is string =>
21
+ typeof value === 'string' &&
22
+ value.length > 0 &&
23
+ value.length <= 128 &&
24
+ !containsAsciiControl(value)
25
+
26
+ /** Exact wire input used by Adea's current signed invoke bridge. */
27
+ export function legacyProofMessage(input: ProofFields, context = 'adea-invoke-v1'): string {
28
+ if (
29
+ !field(context) ||
30
+ !field(input.channelId) ||
31
+ !field(input.credentialId) ||
32
+ !field(input.nonce) ||
33
+ !/^\d{1,16}$/.test(input.timestamp) ||
34
+ !/^[a-f0-9]{64}$/.test(input.bodySha256)
35
+ )
36
+ throw new Error('Invalid proof fields')
37
+ return [
38
+ context,
39
+ input.channelId,
40
+ input.credentialId,
41
+ input.nonce,
42
+ input.timestamp,
43
+ input.bodySha256,
44
+ ].join(separator)
45
+ }
46
+
47
+ /**
48
+ * Authenticate exact invoke bodies against an already established channel.
49
+ * The host owns secure channel creation, credential delivery and revocation;
50
+ * origin checks alone cannot supply a channel. This does not authorize services.
51
+ */
52
+ export function createChannelProofVerifier<Principal>(options: {
53
+ resolve(identity: ChannelIdentity): VerifiedChannel<Principal> | undefined
54
+ now?: () => number
55
+ context?: string
56
+ maxNonces?: number
57
+ maxBodyBytes?: number
58
+ }) {
59
+ const now = options.now ?? Date.now
60
+ const maxNonces = options.maxNonces ?? 4096
61
+ const maxBodyBytes = options.maxBodyBytes ?? 256 * 1024
62
+ const context = options.context ?? 'adea-invoke-v1'
63
+ if (
64
+ !field(context) ||
65
+ !Number.isSafeInteger(maxNonces) ||
66
+ maxNonces < 1 ||
67
+ !Number.isSafeInteger(maxBodyBytes) ||
68
+ maxBodyBytes < 1
69
+ )
70
+ throw new Error('Invalid channel proof configuration')
71
+ const nonces = new Map<string, number>()
72
+ return {
73
+ verify(input: SignedRequest): ProofResult<Principal> {
74
+ if (
75
+ !field(input?.channelId) ||
76
+ !field(input.credentialId) ||
77
+ !field(input.nonce) ||
78
+ typeof input.body !== 'string' ||
79
+ Buffer.byteLength(input.body) > maxBodyBytes ||
80
+ typeof input.timestamp !== 'string' ||
81
+ !/^\d{1,16}$/.test(input.timestamp) ||
82
+ typeof input.proof !== 'string' ||
83
+ !/^[A-Za-z0-9_-]{43}$/.test(input.proof)
84
+ )
85
+ return { ok: false, code: 'invalid' }
86
+ const at = now()
87
+ const timestamp = Number(input.timestamp)
88
+ if (
89
+ !Number.isSafeInteger(at) ||
90
+ !Number.isSafeInteger(timestamp) ||
91
+ Math.abs(at - timestamp) > 30000
92
+ )
93
+ return { ok: false, code: 'expired' }
94
+ let channel: VerifiedChannel<Principal> | undefined
95
+ try {
96
+ channel = options.resolve({ channelId: input.channelId, credentialId: input.credentialId })
97
+ } catch {
98
+ return { ok: false, code: 'unauthenticated' }
99
+ }
100
+ if (
101
+ !channel ||
102
+ !(channel.secret instanceof Uint8Array) ||
103
+ channel.secret.byteLength !== 32 ||
104
+ !Number.isSafeInteger(channel.expiresAt) ||
105
+ channel.expiresAt <= at
106
+ )
107
+ return { ok: false, code: 'unauthenticated' }
108
+ const bodySha256 = createHash('sha256').update(input.body, 'utf8').digest('hex')
109
+ const message = legacyProofMessage({ ...input, bodySha256 }, context)
110
+ const expected = createHmac('sha256', channel.secret).update(message, 'utf8').digest()
111
+ const received = Buffer.from(input.proof, 'base64url')
112
+ if (received.length !== expected.length || !timingSafeEqual(received, expected))
113
+ return { ok: false, code: 'unauthenticated' }
114
+ for (const [key, expiry] of nonces) if (expiry < at) nonces.delete(key)
115
+ const key = `${input.channelId}\0${input.credentialId}\0${input.nonce}`
116
+ if (nonces.has(key)) return { ok: false, code: 'replay' }
117
+ if (nonces.size >= maxNonces) return { ok: false, code: 'capacity' }
118
+ nonces.set(key, timestamp + 60000)
119
+ return { ok: true, principal: channel.principal }
120
+ },
121
+ }
122
+ }