@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.
- package/LICENSE +201 -0
- package/NOTICE +30 -0
- package/README.md +967 -2
- package/dist/app/application.d.ts +47 -0
- package/dist/app/application.js +115 -0
- package/dist/app/create-application.d.ts +13 -0
- package/dist/app/create-application.js +178 -0
- package/dist/app/service-registry.d.ts +44 -0
- package/dist/app/service-registry.js +116 -0
- package/dist/appearance/appearance-host.d.ts +62 -0
- package/dist/appearance/appearance-host.js +115 -0
- package/dist/appearance/appearance-preferences.d.ts +106 -0
- package/dist/appearance/appearance-preferences.js +175 -0
- package/dist/appearance/composition.d.ts +11 -0
- package/dist/appearance/composition.js +16 -0
- package/dist/appearance/custom-theme-import.d.ts +14 -0
- package/dist/appearance/custom-theme-import.js +315 -0
- package/dist/appearance/custom-theme-library.d.ts +146 -0
- package/dist/appearance/custom-theme-library.js +378 -0
- package/dist/appearance/editor.d.ts +20 -0
- package/dist/appearance/editor.js +47 -0
- package/dist/appearance/theme-file-importer.d.ts +23 -0
- package/dist/appearance/theme-file-importer.js +66 -0
- package/dist/appearance/theme-record-adapter.d.ts +26 -0
- package/dist/appearance/theme-record-adapter.js +64 -0
- package/dist/appearance/theme-registry.d.ts +10 -0
- package/dist/appearance/theme-registry.js +16 -0
- package/dist/appearance/window-surface.d.ts +5 -0
- package/dist/appearance/window-surface.js +9 -0
- package/dist/ci/toolchain-identity.d.ts +39 -0
- package/dist/ci/toolchain-identity.js +196 -0
- package/dist/cli/cef-helper-cli.d.ts +2 -0
- package/dist/cli/cef-helper-cli.js +18 -0
- package/dist/cli/cli-runner.d.ts +8 -0
- package/dist/cli/cli-runner.js +23 -0
- package/dist/cli/create-application-cli.d.ts +2 -0
- package/dist/cli/create-application-cli.js +40 -0
- package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
- package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
- package/dist/cli/framework-update-cli.d.ts +2 -0
- package/dist/cli/framework-update-cli.js +40 -0
- package/dist/cli/release-assets-plan-cli.d.ts +2 -0
- package/dist/cli/release-assets-plan-cli.js +14 -0
- package/dist/cli/release-cut-cli.d.ts +2 -0
- package/dist/cli/release-cut-cli.js +27 -0
- package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
- package/dist/cli/release-descriptor-staging-cli.js +45 -0
- package/dist/cli/release-finalize-cli.d.ts +1 -0
- package/dist/cli/release-finalize-cli.js +30 -0
- package/dist/cli/release-promote-cli.d.ts +2 -0
- package/dist/cli/release-promote-cli.js +32 -0
- package/dist/cli/release-publish-cli.d.ts +2 -0
- package/dist/cli/release-publish-cli.js +48 -0
- package/dist/cli/release-sign-cli.d.ts +2 -0
- package/dist/cli/release-sign-cli.js +13 -0
- package/dist/cli/release-step-cli.d.ts +2 -0
- package/dist/cli/release-step-cli.js +44 -0
- package/dist/cli/toolchain-identity-cli.d.ts +2 -0
- package/dist/cli/toolchain-identity-cli.js +10 -0
- package/dist/cli/update-helper-cli.d.ts +1 -0
- package/dist/cli/update-helper-cli.js +10 -0
- package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
- package/dist/cli/windows-runtime-patch-cli.js +17 -0
- package/dist/desktop/application-command-client.d.ts +15 -0
- package/dist/desktop/application-command-client.js +21 -0
- package/dist/desktop/channel-handshake.d.ts +32 -0
- package/dist/desktop/channel-handshake.js +111 -0
- package/dist/desktop/channel-proof.d.ts +43 -0
- package/dist/desktop/channel-proof.js +85 -0
- package/dist/desktop/client-assets.d.ts +7 -0
- package/dist/desktop/client-assets.js +59 -0
- package/dist/desktop/desktop-client.d.ts +23 -0
- package/dist/desktop/desktop-client.js +231 -0
- package/dist/desktop/desktop-gateway.d.ts +18 -0
- package/dist/desktop/desktop-gateway.js +146 -0
- package/dist/desktop/desktop-host.d.ts +48 -0
- package/dist/desktop/desktop-host.js +208 -0
- package/dist/desktop/desktop-stream.d.ts +36 -0
- package/dist/desktop/desktop-stream.js +231 -0
- package/dist/desktop/loopback-policy.d.ts +19 -0
- package/dist/desktop/loopback-policy.js +23 -0
- package/dist/desktop/open-url-channel.d.ts +15 -0
- package/dist/desktop/open-url-channel.js +55 -0
- package/dist/desktop/string-policy.d.ts +2 -0
- package/dist/desktop/string-policy.js +11 -0
- package/dist/framework-source.json +1 -0
- package/dist/installer/archive-entry.d.ts +6 -0
- package/dist/installer/archive-entry.js +14 -0
- package/dist/installer/command-artifact.d.ts +47 -0
- package/dist/installer/command-artifact.js +261 -0
- package/dist/installer/command-qualification-command.d.ts +12 -0
- package/dist/installer/command-qualification-command.js +71 -0
- package/dist/installer/hosted-runner.d.ts +4 -0
- package/dist/installer/hosted-runner.js +10 -0
- package/dist/installer/installed-payload.d.ts +29 -0
- package/dist/installer/installed-payload.js +312 -0
- package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
- package/dist/installer/installer-ci-bootstrap.js +160 -0
- package/dist/installer/installer-ci-preflight.d.ts +1 -0
- package/dist/installer/installer-ci-preflight.js +49 -0
- package/dist/installer/installer-ci-worker.d.ts +1 -0
- package/dist/installer/installer-ci-worker.js +105 -0
- package/dist/installer/installer-extraction.d.ts +14 -0
- package/dist/installer/installer-extraction.js +289 -0
- package/dist/installer/installer-fetch-guard.d.ts +15 -0
- package/dist/installer/installer-fetch-guard.js +50 -0
- package/dist/installer/installer-identity.d.ts +23 -0
- package/dist/installer/installer-identity.js +286 -0
- package/dist/installer/installer-layout.d.ts +21 -0
- package/dist/installer/installer-layout.js +89 -0
- package/dist/installer/installer-observation.d.ts +64 -0
- package/dist/installer/installer-observation.js +473 -0
- package/dist/installer/installer-process-cleanup.d.ts +18 -0
- package/dist/installer/installer-process-cleanup.js +158 -0
- package/dist/installer/installer-qualification-command.d.ts +11 -0
- package/dist/installer/installer-qualification-command.js +71 -0
- package/dist/installer/installer-renderer-evidence.d.ts +43 -0
- package/dist/installer/installer-renderer-evidence.js +136 -0
- package/dist/installer/installer-upgrade-command.d.ts +37 -0
- package/dist/installer/installer-upgrade-command.js +172 -0
- package/dist/installer/installer-worker-guard.d.ts +21 -0
- package/dist/installer/installer-worker-guard.js +72 -0
- package/dist/installer/native-executable.d.ts +5 -0
- package/dist/installer/native-executable.js +21 -0
- package/dist/installer/upgrade-asset-download.d.ts +13 -0
- package/dist/installer/upgrade-asset-download.js +41 -0
- package/dist/installer/write-all.d.ts +6 -0
- package/dist/installer/write-all.js +11 -0
- package/dist/native/app-bundle.d.ts +28 -0
- package/dist/native/app-bundle.js +60 -0
- package/dist/native/cef-helper.d.ts +28 -0
- package/dist/native/cef-helper.js +402 -0
- package/dist/native/desktop-build-hook.d.ts +7 -0
- package/dist/native/desktop-build-hook.js +20 -0
- package/dist/native/electrobun-source-patch.d.ts +25 -0
- package/dist/native/electrobun-source-patch.js +93 -0
- package/dist/native/linux-cef-links.d.ts +2 -0
- package/dist/native/linux-cef-links.js +15 -0
- package/dist/native/native-secret-store.d.ts +27 -0
- package/dist/native/native-secret-store.js +70 -0
- package/dist/native/native-utilities.d.ts +24 -0
- package/dist/native/native-utilities.js +85 -0
- package/dist/native/partitioned-window.d.ts +34 -0
- package/dist/native/partitioned-window.js +44 -0
- package/dist/native/renderer-profile.d.ts +53 -0
- package/dist/native/renderer-profile.js +30 -0
- package/dist/native/secure-window.d.ts +38 -0
- package/dist/native/secure-window.js +77 -0
- package/dist/native/sidecar-services.d.ts +23 -0
- package/dist/native/sidecar-services.js +46 -0
- package/dist/native/sidecar.d.ts +81 -0
- package/dist/native/sidecar.js +250 -0
- package/dist/native/window-bootstrap.d.ts +24 -0
- package/dist/native/window-bootstrap.js +63 -0
- package/dist/native/window-options.d.ts +32 -0
- package/dist/native/window-options.js +23 -0
- package/dist/native/windows-build-hook-internal.d.ts +2 -0
- package/dist/native/windows-build-hook-internal.js +32 -0
- package/dist/native/windows-build-hook.d.ts +2 -0
- package/dist/native/windows-build-hook.js +12 -0
- package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
- package/dist/native/windows-runtime-patch-internal.js +20 -0
- package/dist/native/windows-runtime-patch.d.ts +4 -0
- package/dist/native/windows-runtime-patch.js +12 -0
- package/dist/release/feed-release-cut.d.ts +23 -0
- package/dist/release/feed-release-cut.js +93 -0
- package/dist/release/feed-state.d.ts +25 -0
- package/dist/release/feed-state.js +81 -0
- package/dist/release/framework-package-publish.d.ts +21 -0
- package/dist/release/framework-package-publish.js +125 -0
- package/dist/release/framework-update.d.ts +30 -0
- package/dist/release/framework-update.js +139 -0
- package/dist/release/github-cli.d.ts +6 -0
- package/dist/release/github-cli.js +16 -0
- package/dist/release/github-release-assets.d.ts +3 -0
- package/dist/release/github-release-assets.js +24 -0
- package/dist/release/github-release-cut.d.ts +14 -0
- package/dist/release/github-release-cut.js +174 -0
- package/dist/release/github-release-lookup.d.ts +7 -0
- package/dist/release/github-release-lookup.js +29 -0
- package/dist/release/github-release-promotion.d.ts +10 -0
- package/dist/release/github-release-promotion.js +78 -0
- package/dist/release/github-release-provenance.d.ts +9 -0
- package/dist/release/github-release-provenance.js +27 -0
- package/dist/release/github-release-publisher.d.ts +9 -0
- package/dist/release/github-release-publisher.js +63 -0
- package/dist/release/github-release-qualification.d.ts +12 -0
- package/dist/release/github-release-qualification.js +80 -0
- package/dist/release/local-provenance.d.ts +24 -0
- package/dist/release/local-provenance.js +72 -0
- package/dist/release/local-release.d.ts +133 -0
- package/dist/release/local-release.js +387 -0
- package/dist/release/macos-dmg.d.ts +22 -0
- package/dist/release/macos-dmg.js +91 -0
- package/dist/release/release-artifact.d.ts +6 -0
- package/dist/release/release-artifact.js +38 -0
- package/dist/release/release-assets-plan.d.ts +14 -0
- package/dist/release/release-assets-plan.js +65 -0
- package/dist/release/release-config.d.ts +76 -0
- package/dist/release/release-config.js +180 -0
- package/dist/release/release-cut-command.d.ts +13 -0
- package/dist/release/release-cut-command.js +39 -0
- package/dist/release/release-cut.d.ts +54 -0
- package/dist/release/release-cut.js +76 -0
- package/dist/release/release-descriptor-staging.d.ts +34 -0
- package/dist/release/release-descriptor-staging.js +147 -0
- package/dist/release/release-finalize.d.ts +16 -0
- package/dist/release/release-finalize.js +104 -0
- package/dist/release/release-promotion-command.d.ts +12 -0
- package/dist/release/release-promotion-command.js +28 -0
- package/dist/release/release-promotion.d.ts +29 -0
- package/dist/release/release-promotion.js +57 -0
- package/dist/release/release-publication.d.ts +33 -0
- package/dist/release/release-publication.js +138 -0
- package/dist/release/release-publish-command.d.ts +7 -0
- package/dist/release/release-publish-command.js +91 -0
- package/dist/release/release-qualification.d.ts +106 -0
- package/dist/release/release-qualification.js +135 -0
- package/dist/release/release-staging.d.ts +9 -0
- package/dist/release/release-staging.js +61 -0
- package/dist/release/release-steps.d.ts +38 -0
- package/dist/release/release-steps.js +147 -0
- package/dist/release/retained-release-build.d.ts +19 -0
- package/dist/release/retained-release-build.js +122 -0
- package/dist/shell/app-shell.d.ts +61 -0
- package/dist/shell/app-shell.js +318 -0
- package/dist/shell/app-utilities.d.ts +122 -0
- package/dist/shell/app-utilities.js +334 -0
- package/dist/shell/application-menu-commands.d.ts +5 -0
- package/dist/shell/application-menu-commands.js +11 -0
- package/dist/shell/application-menu.d.ts +61 -0
- package/dist/shell/application-menu.js +208 -0
- package/dist/shell/help-shortcuts.d.ts +12 -0
- package/dist/shell/help-shortcuts.js +22 -0
- package/dist/shell/settings-sections.d.ts +31 -0
- package/dist/shell/settings-sections.js +50 -0
- package/dist/shell/shortcut-platform.d.ts +17 -0
- package/dist/shell/shortcut-platform.js +25 -0
- package/dist/update-helper.bundle.js +260 -0
- package/dist/updates/channel-update-manager.d.ts +46 -0
- package/dist/updates/channel-update-manager.js +114 -0
- package/dist/updates/desktop-updater.d.ts +104 -0
- package/dist/updates/desktop-updater.js +345 -0
- package/dist/updates/release-feed.d.ts +61 -0
- package/dist/updates/release-feed.js +111 -0
- package/dist/updates/release-location.d.ts +9 -0
- package/dist/updates/release-location.js +80 -0
- package/dist/updates/release-version.d.ts +12 -0
- package/dist/updates/release-version.js +43 -0
- package/dist/updates/signed-release.d.ts +63 -0
- package/dist/updates/signed-release.js +162 -0
- package/dist/updates/stable-file.d.ts +10 -0
- package/dist/updates/stable-file.js +22 -0
- package/dist/updates/update-adapter.d.ts +57 -0
- package/dist/updates/update-adapter.js +72 -0
- package/dist/updates/update-arm.d.ts +24 -0
- package/dist/updates/update-arm.js +95 -0
- package/dist/updates/update-channel-store.d.ts +8 -0
- package/dist/updates/update-channel-store.js +72 -0
- package/dist/updates/update-discovery.d.ts +13 -0
- package/dist/updates/update-discovery.js +56 -0
- package/dist/updates/update-download.d.ts +14 -0
- package/dist/updates/update-download.js +67 -0
- package/dist/updates/update-exclusive-rename.d.ts +2 -0
- package/dist/updates/update-exclusive-rename.js +52 -0
- package/dist/updates/update-extraction.d.ts +18 -0
- package/dist/updates/update-extraction.js +183 -0
- package/dist/updates/update-handoff-plan.d.ts +22 -0
- package/dist/updates/update-handoff-plan.js +28 -0
- package/dist/updates/update-helper.d.ts +24 -0
- package/dist/updates/update-helper.js +56 -0
- package/dist/updates/update-launch.d.ts +5 -0
- package/dist/updates/update-launch.js +27 -0
- package/dist/updates/update-manager.d.ts +40 -0
- package/dist/updates/update-manager.js +83 -0
- package/dist/updates/update-process-fence.d.ts +10 -0
- package/dist/updates/update-process-fence.js +114 -0
- package/dist/updates/update-resume.d.ts +13 -0
- package/dist/updates/update-resume.js +34 -0
- package/dist/updates/update-shutdown.d.ts +15 -0
- package/dist/updates/update-shutdown.js +29 -0
- package/dist/updates/update-state.d.ts +30 -0
- package/dist/updates/update-state.js +18 -0
- package/dist/updates/update-swap-stage.d.ts +27 -0
- package/dist/updates/update-swap-stage.js +58 -0
- package/dist/updates/update-swap.d.ts +10 -0
- package/dist/updates/update-swap.js +30 -0
- package/dist/views/app-about.d.ts +22 -0
- package/dist/views/app-about.js +43 -0
- package/dist/views/app-appearance.d.ts +11 -0
- package/dist/views/app-appearance.js +42 -0
- package/dist/views/app-help.d.ts +17 -0
- package/dist/views/app-help.js +42 -0
- package/dist/views/app-settings.d.ts +26 -0
- package/dist/views/app-settings.js +97 -0
- package/dist/views/appearance-surface.d.ts +9 -0
- package/dist/views/appearance-surface.js +334 -0
- package/dist/views/update-surface.d.ts +34 -0
- package/dist/views/update-surface.js +64 -0
- package/package.json +363 -4
- package/src/app/application.tsx +138 -0
- package/src/app/create-application.ts +245 -0
- package/src/app/service-registry.ts +124 -0
- package/src/appearance/appearance-host.tsx +205 -0
- package/src/appearance/appearance-preferences.ts +287 -0
- package/src/appearance/composition.ts +29 -0
- package/src/appearance/custom-theme-import.ts +424 -0
- package/src/appearance/custom-theme-library.ts +600 -0
- package/src/appearance/editor.ts +94 -0
- package/src/appearance/theme-file-importer.ts +103 -0
- package/src/appearance/theme-record-adapter.ts +106 -0
- package/src/appearance/theme-registry.ts +20 -0
- package/src/appearance/window-surface.ts +18 -0
- package/src/ci/toolchain-identity.ts +244 -0
- package/src/cli/cef-helper-cli.ts +21 -0
- package/src/cli/cli-runner.ts +29 -0
- package/src/cli/create-application-cli.ts +62 -0
- package/src/cli/electrobun-shortcut-patch-cli.ts +24 -0
- package/src/cli/framework-update-cli.ts +41 -0
- package/src/cli/release-assets-plan-cli.ts +14 -0
- package/src/cli/release-cut-cli.ts +41 -0
- package/src/cli/release-descriptor-staging-cli.ts +57 -0
- package/src/cli/release-finalize-cli.ts +34 -0
- package/src/cli/release-promote-cli.ts +31 -0
- package/src/cli/release-publish-cli.ts +46 -0
- package/src/cli/release-sign-cli.ts +24 -0
- package/src/cli/release-step-cli.ts +71 -0
- package/src/cli/toolchain-identity-cli.ts +12 -0
- package/src/cli/update-helper-cli.ts +12 -0
- package/src/cli/windows-runtime-patch-cli.ts +17 -0
- package/src/desktop/application-command-client.ts +43 -0
- package/src/desktop/channel-handshake.ts +136 -0
- package/src/desktop/channel-proof.ts +122 -0
- package/src/desktop/client-assets.ts +75 -0
- package/src/desktop/desktop-client.ts +303 -0
- package/src/desktop/desktop-gateway.ts +189 -0
- package/src/desktop/desktop-host.ts +335 -0
- package/src/desktop/desktop-stream.ts +324 -0
- package/src/desktop/loopback-policy.ts +41 -0
- package/src/desktop/open-url-channel.ts +79 -0
- package/src/desktop/string-policy.ts +9 -0
- package/src/installer/archive-entry.ts +32 -0
- package/src/installer/command-artifact.ts +307 -0
- package/src/installer/command-qualification-command.ts +75 -0
- package/src/installer/hosted-runner.ts +11 -0
- package/src/installer/installed-payload.ts +408 -0
- package/src/installer/installer-ci-bootstrap.ts +199 -0
- package/src/installer/installer-ci-preflight.ts +61 -0
- package/src/installer/installer-ci-worker.ts +105 -0
- package/src/installer/installer-extraction.ts +367 -0
- package/src/installer/installer-fetch-guard.ts +75 -0
- package/src/installer/installer-identity.ts +331 -0
- package/src/installer/installer-layout.ts +167 -0
- package/src/installer/installer-observation.ts +671 -0
- package/src/installer/installer-process-cleanup.ts +167 -0
- package/src/installer/installer-qualification-command.ts +81 -0
- package/src/installer/installer-renderer-evidence.ts +268 -0
- package/src/installer/installer-upgrade-command.ts +226 -0
- package/src/installer/installer-worker-guard.ts +112 -0
- package/src/installer/native-executable.ts +37 -0
- package/src/installer/upgrade-asset-download.ts +72 -0
- package/src/installer/write-all.ts +19 -0
- package/src/native/app-bundle.ts +86 -0
- package/src/native/cef-helper.ts +471 -0
- package/src/native/desktop-build-hook.ts +21 -0
- package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
- package/src/native/electrobun-source-patch.ts +107 -0
- package/src/native/electrobun-windows-shortcut-com.patch +923 -0
- package/src/native/linux-cef-links.ts +14 -0
- package/src/native/native-secret-store.ts +99 -0
- package/src/native/native-utilities.ts +166 -0
- package/src/native/partitioned-window.ts +62 -0
- package/src/native/renderer-profile.ts +27 -0
- package/src/native/secure-window.ts +115 -0
- package/src/native/sidecar-services.ts +71 -0
- package/src/native/sidecar.ts +387 -0
- package/src/native/window-bootstrap.ts +77 -0
- package/src/native/window-options.ts +24 -0
- package/src/native/windows-build-hook-internal.ts +49 -0
- package/src/native/windows-build-hook.ts +12 -0
- package/src/native/windows-runtime-patch-internal.ts +48 -0
- package/src/native/windows-runtime-patch.ts +15 -0
- package/src/release/feed-release-cut.ts +110 -0
- package/src/release/feed-state.ts +135 -0
- package/src/release/framework-package-publish.ts +163 -0
- package/src/release/framework-update.ts +196 -0
- package/src/release/github-cli.ts +27 -0
- package/src/release/github-release-assets.ts +36 -0
- package/src/release/github-release-cut.ts +237 -0
- package/src/release/github-release-lookup.ts +39 -0
- package/src/release/github-release-promotion.ts +112 -0
- package/src/release/github-release-provenance.ts +65 -0
- package/src/release/github-release-publisher.ts +90 -0
- package/src/release/github-release-qualification.ts +144 -0
- package/src/release/local-provenance.ts +92 -0
- package/src/release/local-release.ts +525 -0
- package/src/release/macos-dmg.ts +113 -0
- package/src/release/release-artifact.ts +53 -0
- package/src/release/release-assets-plan.ts +118 -0
- package/src/release/release-config.ts +420 -0
- package/src/release/release-cut-command.ts +80 -0
- package/src/release/release-cut.ts +133 -0
- package/src/release/release-descriptor-staging.ts +242 -0
- package/src/release/release-finalize.ts +191 -0
- package/src/release/release-promotion-command.ts +36 -0
- package/src/release/release-promotion.ts +132 -0
- package/src/release/release-publication.ts +213 -0
- package/src/release/release-publish-command.ts +163 -0
- package/src/release/release-qualification.ts +397 -0
- package/src/release/release-staging.ts +87 -0
- package/src/release/release-steps.ts +173 -0
- package/src/release/retained-release-build.ts +217 -0
- package/src/shell/app-shell.tsx +285 -0
- package/src/shell/app-utilities.tsx +437 -0
- package/src/shell/application-menu-commands.ts +6 -0
- package/src/shell/application-menu.ts +250 -0
- package/src/shell/help-shortcuts.ts +24 -0
- package/src/shell/settings-sections.ts +74 -0
- package/src/shell/shortcut-platform.ts +35 -0
- package/src/updates/channel-update-manager.ts +127 -0
- package/src/updates/desktop-updater.ts +440 -0
- package/src/updates/release-feed.ts +187 -0
- package/src/updates/release-location.ts +101 -0
- package/src/updates/release-version.ts +57 -0
- package/src/updates/signed-release.ts +311 -0
- package/src/updates/stable-file.ts +32 -0
- package/src/updates/update-adapter.ts +129 -0
- package/src/updates/update-arm.ts +107 -0
- package/src/updates/update-channel-store.ts +86 -0
- package/src/updates/update-discovery.ts +113 -0
- package/src/updates/update-download.ts +82 -0
- package/src/updates/update-exclusive-rename.ts +58 -0
- package/src/updates/update-extraction.ts +261 -0
- package/src/updates/update-handoff-plan.ts +75 -0
- package/src/updates/update-helper.ts +87 -0
- package/src/updates/update-launch.ts +33 -0
- package/src/updates/update-manager.ts +130 -0
- package/src/updates/update-process-fence.ts +125 -0
- package/src/updates/update-resume.ts +34 -0
- package/src/updates/update-shutdown.ts +37 -0
- package/src/updates/update-state.ts +34 -0
- package/src/updates/update-swap-stage.ts +75 -0
- package/src/updates/update-swap.ts +30 -0
- package/src/views/app-about.tsx +44 -0
- package/src/views/app-appearance.tsx +32 -0
- package/src/views/app-help.tsx +43 -0
- package/src/views/app-settings.tsx +88 -0
- package/src/views/appearance-surface.tsx +427 -0
- package/src/views/update-surface.tsx +85 -0
- package/templates/application/.gitattributes +1 -0
- package/templates/application/.github/workflows/release-assets.yml +29 -0
- package/templates/application/.github/workflows/release-finalize.yml +29 -0
- package/templates/application/.github/workflows/release-please.yml +19 -0
- package/templates/application/.github/workflows/release.yml +29 -0
- package/templates/application/.github/workflows/validation.yml +28 -0
- package/templates/application/.oxfmtrc.json +6 -0
- package/templates/application/.oxlintrc.json +48 -0
- package/templates/application/.release-please-manifest.json +3 -0
- package/templates/application/README.md +47 -0
- package/templates/application/electrobun.config.ts +22 -0
- package/templates/application/release-please-config.json +12 -0
- package/templates/application/scripts/app-version.ts +9 -0
- package/templates/application/scripts/build-desktop.ts +34 -0
- package/templates/application/scripts/secure-build.ts +1 -0
- package/templates/application/scripts/stage-release.ts +21 -0
- package/templates/application/src/bun/index.ts +80 -0
- package/templates/application/src/electrobun.d.ts +27 -0
- package/templates/application/src/web/index.html +12 -0
- package/templates/application/src/web/main.tsx +97 -0
- package/templates/application/src/web/public/icon.svg +1 -0
- package/templates/application/src/web/style.css +3 -0
- package/templates/application/tests/app-config.test.ts +9 -0
- package/templates/application/tsconfig.json +15 -0
- package/templates/application/vite.config.ts +10 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
UpdateAdapter,
|
|
3
|
+
UpdateChannel,
|
|
4
|
+
UpdateState,
|
|
5
|
+
} from '@adea-ai/ui/components/composites/update-dialog'
|
|
6
|
+
|
|
7
|
+
export type { UpdateAdapter, UpdateChannel, UpdateState }
|
|
8
|
+
|
|
9
|
+
/** Channel persistence as a `read`/`persist` pair. */
|
|
10
|
+
export type UpdateChannelStore = Readonly<{
|
|
11
|
+
read(): Promise<UpdateChannel>
|
|
12
|
+
/** Persist a selection; resolves with the channel that actually stuck. */
|
|
13
|
+
persist(channel: UpdateChannel): Promise<UpdateChannel>
|
|
14
|
+
}>
|
|
15
|
+
|
|
16
|
+
/** Channel persistence as a service exposing `channel`/`setChannel`. */
|
|
17
|
+
export type UpdateChannelService = Readonly<{
|
|
18
|
+
channel(): Promise<UpdateChannel>
|
|
19
|
+
setChannel(channel: UpdateChannel): Promise<UpdateChannel>
|
|
20
|
+
}>
|
|
21
|
+
|
|
22
|
+
/** Either channel shape the update surface accepts. */
|
|
23
|
+
export type UpdateChannelSource = UpdateChannelStore | UpdateChannelService
|
|
24
|
+
|
|
25
|
+
/** Normalize either channel shape to `read`/`persist`. */
|
|
26
|
+
export function updateChannelStore(source: UpdateChannelSource): UpdateChannelStore {
|
|
27
|
+
if ('read' in source) return source
|
|
28
|
+
return {
|
|
29
|
+
read: () => source.channel(),
|
|
30
|
+
persist: (channel) => source.setChannel(channel),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Report every snapshot the updater answers with, for a pending-update badge that
|
|
36
|
+
* must not run a second checker. The wrapped adapter otherwise behaves identically.
|
|
37
|
+
*/
|
|
38
|
+
export function mirrorUpdateState(
|
|
39
|
+
adapter: UpdateAdapter,
|
|
40
|
+
onState: (state: UpdateState) => void
|
|
41
|
+
): UpdateAdapter {
|
|
42
|
+
const note = async (pending: Promise<UpdateState>) => {
|
|
43
|
+
const state = await pending
|
|
44
|
+
onState(state)
|
|
45
|
+
return state
|
|
46
|
+
}
|
|
47
|
+
const cancel = adapter.cancel
|
|
48
|
+
return {
|
|
49
|
+
...adapter,
|
|
50
|
+
check: () => note(adapter.check()),
|
|
51
|
+
getStatus: () => note(adapter.getStatus()),
|
|
52
|
+
install: (expectedVersion) => note(adapter.install(expectedVersion)),
|
|
53
|
+
...(cancel ? { cancel: () => note(cancel.call(adapter)) } : {}),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A native updater snapshot in snake_case, as Rust and older desktop hosts report it. */
|
|
58
|
+
export type NativeUpdateSnapshot = Readonly<{
|
|
59
|
+
available_version: string | null
|
|
60
|
+
changelog: string
|
|
61
|
+
current_version: string
|
|
62
|
+
downloaded_bytes: number
|
|
63
|
+
error: string | null
|
|
64
|
+
github_url: string | null
|
|
65
|
+
phase: UpdateState['phase']
|
|
66
|
+
release_date: string | null
|
|
67
|
+
release_notes?: string | null
|
|
68
|
+
restart_required: boolean
|
|
69
|
+
total_bytes: number | null
|
|
70
|
+
}>
|
|
71
|
+
|
|
72
|
+
/** A native updater that answers with snake_case snapshots. */
|
|
73
|
+
export type NativeUpdateAdapter = Readonly<{
|
|
74
|
+
check(): Promise<NativeUpdateSnapshot>
|
|
75
|
+
getStatus(): Promise<NativeUpdateSnapshot>
|
|
76
|
+
install(expectedVersion: string): Promise<NativeUpdateSnapshot>
|
|
77
|
+
isDesktopRuntime(): boolean
|
|
78
|
+
pollIntervalMs?: number
|
|
79
|
+
}>
|
|
80
|
+
|
|
81
|
+
/** Map a snake_case native snapshot to the shared update state. */
|
|
82
|
+
export function updateStateFromNative(
|
|
83
|
+
update: NativeUpdateSnapshot,
|
|
84
|
+
options: { releaseNotes?: boolean } = {}
|
|
85
|
+
): UpdateState {
|
|
86
|
+
return {
|
|
87
|
+
availableVersion: update.available_version,
|
|
88
|
+
changelog: update.changelog,
|
|
89
|
+
currentVersion: update.current_version,
|
|
90
|
+
downloadedBytes: update.downloaded_bytes,
|
|
91
|
+
error: update.error,
|
|
92
|
+
phase: update.phase,
|
|
93
|
+
releaseDate: update.release_date,
|
|
94
|
+
releaseNotes: options.releaseNotes ? (update.release_notes ?? null) : null,
|
|
95
|
+
releaseUrl: update.github_url,
|
|
96
|
+
restartRequired: update.restart_required,
|
|
97
|
+
totalBytes: update.total_bytes,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Bridge a snake_case native updater to the shared adapter. Release notes are dropped
|
|
103
|
+
* unless requested, which keeps the dialog's per-release notes section hidden.
|
|
104
|
+
*/
|
|
105
|
+
export function nativeUpdateAdapter(
|
|
106
|
+
native: NativeUpdateAdapter | (() => NativeUpdateAdapter),
|
|
107
|
+
options: { releaseNotes?: boolean } = {}
|
|
108
|
+
): UpdateAdapter {
|
|
109
|
+
const current = typeof native === 'function' ? native : () => native
|
|
110
|
+
return {
|
|
111
|
+
check: async () => updateStateFromNative(await current().check(), options),
|
|
112
|
+
getStatus: async () => updateStateFromNative(await current().getStatus(), options),
|
|
113
|
+
install: async (expectedVersion) =>
|
|
114
|
+
updateStateFromNative(await current().install(expectedVersion), options),
|
|
115
|
+
isDesktopRuntime: () => current().isDesktopRuntime(),
|
|
116
|
+
pollIntervalMs: current().pollIntervalMs,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The adapter for a build with no installer: the dialog explains updates are desktop-only. */
|
|
121
|
+
export function browserUpdateAdapter(currentVersion = ''): UpdateAdapter {
|
|
122
|
+
const state: UpdateState = { phase: 'unavailable', currentVersion }
|
|
123
|
+
return {
|
|
124
|
+
check: async () => state,
|
|
125
|
+
getStatus: async () => state,
|
|
126
|
+
install: async () => state,
|
|
127
|
+
isDesktopRuntime: () => false,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { spawn, type ChildProcess } from 'node:child_process'
|
|
2
|
+
import { copyFile, lstat, mkdir, realpath, rm, unlink, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
|
|
4
|
+
import { updateLauncherPath } from './update-launch'
|
|
5
|
+
import { updateStagingFor } from './update-swap'
|
|
6
|
+
import type { UpdateHelperRequest } from './update-helper'
|
|
7
|
+
|
|
8
|
+
function exited(child: ChildProcess): boolean {
|
|
9
|
+
return child.exitCode !== null || child.signalCode !== null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The Bun runtime inside an installed app tree, which the helper copy runs on. */
|
|
13
|
+
function updateRuntimePath(platform: UpdateHelperRequest['platform'], target: string) {
|
|
14
|
+
const launcher = updateLauncherPath(platform, target)
|
|
15
|
+
return join(dirname(launcher), platform === 'windows-x64' ? 'bun.exe' : 'bun')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Start the post-exit update helper for a staged update, then resolve once the
|
|
20
|
+
* helper has verified this app's processes. The helper runs from copies of the
|
|
21
|
+
* app's Bun runtime and bundled helper script inside the private staging
|
|
22
|
+
* directory, because the install tree is about to move.
|
|
23
|
+
*
|
|
24
|
+
* Use it as the `arm` step of `scheduleUpdateShutdown`: quit only after it
|
|
25
|
+
* resolves, and call `cancel()` if the quit is vetoed.
|
|
26
|
+
*/
|
|
27
|
+
export async function armUpdateHelper(options: {
|
|
28
|
+
target: string
|
|
29
|
+
platform: UpdateHelperRequest['platform']
|
|
30
|
+
version: string
|
|
31
|
+
/** Absolute path of the bundled helper script shipped with the app. */
|
|
32
|
+
helperScript: string
|
|
33
|
+
/** Processes that must exit before the swap. Defaults to this process and its launcher parent. */
|
|
34
|
+
processes?: UpdateHelperRequest['processes']
|
|
35
|
+
processTimeoutMs?: number
|
|
36
|
+
armTimeoutMs?: number
|
|
37
|
+
env?: Record<string, string | undefined>
|
|
38
|
+
}): Promise<{ cancel(): Promise<void> }> {
|
|
39
|
+
const staging = updateStagingFor(options.target)
|
|
40
|
+
if (!isAbsolute(options.helperScript) || resolve(options.helperScript) !== options.helperScript)
|
|
41
|
+
throw new Error('Invalid update helper script')
|
|
42
|
+
const info = await lstat(staging)
|
|
43
|
+
if (!info.isDirectory() || info.isSymbolicLink() || (await realpath(staging)) !== staging)
|
|
44
|
+
throw new Error('Invalid update staging directory')
|
|
45
|
+
const helper = join(staging, 'helper')
|
|
46
|
+
const runtime = join(helper, basename(updateRuntimePath(options.platform, options.target)))
|
|
47
|
+
const script = join(helper, 'update-helper.js')
|
|
48
|
+
const request: UpdateHelperRequest = {
|
|
49
|
+
schema: 1,
|
|
50
|
+
target: options.target,
|
|
51
|
+
platform: options.platform,
|
|
52
|
+
version: options.version,
|
|
53
|
+
processes: options.processes ?? [
|
|
54
|
+
{ pid: process.pid, executable: process.execPath },
|
|
55
|
+
...(process.ppid > 1
|
|
56
|
+
? [{ pid: process.ppid, executable: updateLauncherPath(options.platform, options.target) }]
|
|
57
|
+
: []),
|
|
58
|
+
],
|
|
59
|
+
processTimeoutMs: options.processTimeoutMs ?? 30000,
|
|
60
|
+
}
|
|
61
|
+
const armed = join(staging, 'helper-armed')
|
|
62
|
+
let child: ChildProcess | undefined
|
|
63
|
+
async function reset() {
|
|
64
|
+
if (child && !exited(child) && child.pid !== undefined) {
|
|
65
|
+
try {
|
|
66
|
+
process.kill(child.pid)
|
|
67
|
+
} catch {
|
|
68
|
+
/* Already gone. */
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const name of ['request.json', 'helper-armed'])
|
|
72
|
+
await unlink(join(staging, name)).catch(() => undefined)
|
|
73
|
+
await rm(helper, { recursive: true, force: true })
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
await mkdir(helper, { mode: 0o700 })
|
|
77
|
+
await copyFile(updateRuntimePath(options.platform, options.target), runtime)
|
|
78
|
+
await copyFile(options.helperScript, script)
|
|
79
|
+
await writeFile(join(staging, 'request.json'), JSON.stringify(request) + '\n', {
|
|
80
|
+
flag: 'wx',
|
|
81
|
+
mode: 0o600,
|
|
82
|
+
})
|
|
83
|
+
const started = spawn(runtime, [script, '--staging', staging], {
|
|
84
|
+
cwd: helper,
|
|
85
|
+
detached: true,
|
|
86
|
+
stdio: 'ignore',
|
|
87
|
+
env: options.env ?? process.env,
|
|
88
|
+
windowsHide: true,
|
|
89
|
+
})
|
|
90
|
+
child = started
|
|
91
|
+
await new Promise<void>((done, reject) => {
|
|
92
|
+
started.once('spawn', () => done())
|
|
93
|
+
started.once('error', reject)
|
|
94
|
+
})
|
|
95
|
+
started.unref()
|
|
96
|
+
const deadline = Date.now() + (options.armTimeoutMs ?? 15000)
|
|
97
|
+
while (!(await lstat(armed).catch(() => undefined))) {
|
|
98
|
+
if (exited(started)) throw new Error('Update helper exited before arming')
|
|
99
|
+
if (Date.now() >= deadline) throw new Error('Update helper did not arm in time')
|
|
100
|
+
await Bun.sleep(50)
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
await reset()
|
|
104
|
+
throw error
|
|
105
|
+
}
|
|
106
|
+
return { cancel: reset }
|
|
107
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
2
|
+
import { lstat, open, realpath, rename, unlink } from 'node:fs/promises'
|
|
3
|
+
import { isAbsolute, join, resolve } from 'node:path'
|
|
4
|
+
import { openUnchangedFile, sameFile } from './stable-file'
|
|
5
|
+
import { isUpdateChannel, type UpdateChannel } from './release-version'
|
|
6
|
+
|
|
7
|
+
/** Persist one app-owned update channel; the caller must supply a private state directory. */
|
|
8
|
+
export function createUpdateChannelStore(directory: string) {
|
|
9
|
+
if (typeof directory !== 'string' || !isAbsolute(directory) || resolve(directory) !== directory)
|
|
10
|
+
throw new Error('Invalid update channel directory')
|
|
11
|
+
const path = join(directory, 'update-channel.json')
|
|
12
|
+
let queue = Promise.resolve()
|
|
13
|
+
async function assertDirectory() {
|
|
14
|
+
const info = await lstat(directory)
|
|
15
|
+
if (!info.isDirectory() || info.isSymbolicLink() || (await realpath(directory)) !== directory)
|
|
16
|
+
throw new Error('Invalid update channel directory')
|
|
17
|
+
}
|
|
18
|
+
async function read(): Promise<UpdateChannel> {
|
|
19
|
+
await assertDirectory()
|
|
20
|
+
let info
|
|
21
|
+
try {
|
|
22
|
+
info = await lstat(path)
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return 'stable'
|
|
25
|
+
throw error
|
|
26
|
+
}
|
|
27
|
+
if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > 4096)
|
|
28
|
+
throw new Error('Invalid update channel file')
|
|
29
|
+
const { file, before } = await openUnchangedFile(path, info, 'Invalid update channel file')
|
|
30
|
+
try {
|
|
31
|
+
const bytes = Buffer.alloc(before.size + 1)
|
|
32
|
+
const fileRead = await file.read(bytes, 0, bytes.length, 0)
|
|
33
|
+
if (fileRead.bytesRead !== before.size) throw new Error('Invalid update channel file')
|
|
34
|
+
const value: unknown = JSON.parse(bytes.subarray(0, fileRead.bytesRead).toString('utf8'))
|
|
35
|
+
const after = await file.stat()
|
|
36
|
+
if (
|
|
37
|
+
!sameFile(before, after) ||
|
|
38
|
+
typeof value !== 'object' ||
|
|
39
|
+
value === null ||
|
|
40
|
+
Array.isArray(value) ||
|
|
41
|
+
Object.keys(value).length !== 1 ||
|
|
42
|
+
!isUpdateChannel((value as { channel?: unknown }).channel)
|
|
43
|
+
)
|
|
44
|
+
throw new Error('Invalid update channel file')
|
|
45
|
+
return (value as { channel: UpdateChannel }).channel
|
|
46
|
+
} finally {
|
|
47
|
+
await file.close()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function ordered<T>(task: () => Promise<T>): Promise<T> {
|
|
51
|
+
const result = queue.then(task)
|
|
52
|
+
queue = result.then(
|
|
53
|
+
() => {},
|
|
54
|
+
() => {}
|
|
55
|
+
)
|
|
56
|
+
return result
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
read: () => ordered(read),
|
|
60
|
+
save: (channel: UpdateChannel) =>
|
|
61
|
+
ordered(async () => {
|
|
62
|
+
if (!isUpdateChannel(channel)) throw new Error('Invalid update channel')
|
|
63
|
+
await assertDirectory()
|
|
64
|
+
const temporary = join(directory, `.update-channel-${randomUUID()}.tmp`)
|
|
65
|
+
const file = await open(temporary, 'wx', 0o600)
|
|
66
|
+
let moved = false
|
|
67
|
+
try {
|
|
68
|
+
await file.writeFile(JSON.stringify({ channel }) + '\n')
|
|
69
|
+
await file.sync()
|
|
70
|
+
await file.close()
|
|
71
|
+
await rename(temporary, path)
|
|
72
|
+
moved = true
|
|
73
|
+
if ((await read()) !== channel) throw new Error('Update channel write did not persist')
|
|
74
|
+
return channel
|
|
75
|
+
} finally {
|
|
76
|
+
await file.close().catch(() => {})
|
|
77
|
+
if (!moved) await unlink(temporary).catch(() => {})
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Shared UI uses pre-release; release descriptors use daily. */
|
|
83
|
+
export function releaseChannelForUpdate(channel: UpdateChannel): 'stable' | 'daily' | 'dev' {
|
|
84
|
+
if (!isUpdateChannel(channel)) throw new Error('Invalid update channel')
|
|
85
|
+
return channel === 'pre-release' ? 'daily' : channel
|
|
86
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import {
|
|
3
|
+
isRepositorySlug,
|
|
4
|
+
verifyReleaseDescriptor,
|
|
5
|
+
type ReleaseTrust,
|
|
6
|
+
type VerifiedRelease,
|
|
7
|
+
} from './signed-release'
|
|
8
|
+
import {
|
|
9
|
+
fetchReleaseLocation,
|
|
10
|
+
readReleaseBytes,
|
|
11
|
+
readReleaseJson,
|
|
12
|
+
type FetchFunction,
|
|
13
|
+
} from './release-location'
|
|
14
|
+
import { parseFeedRelease, parseReleaseLedger, type FeedRelease } from './release-feed'
|
|
15
|
+
import { versionLessThan } from './release-version'
|
|
16
|
+
|
|
17
|
+
const MAX_POINTER_BYTES = 262_144,
|
|
18
|
+
MAX_LEDGER_BYTES = 1024 * 1024
|
|
19
|
+
|
|
20
|
+
/** Discover and authenticate the app's channel descriptor without trusting feed metadata as an update. */
|
|
21
|
+
export async function discoverSignedRelease(options: {
|
|
22
|
+
trust: ReleaseTrust
|
|
23
|
+
discoveryName: string
|
|
24
|
+
timeoutMs?: number
|
|
25
|
+
signal?: AbortSignal
|
|
26
|
+
fetch?: FetchFunction
|
|
27
|
+
/** Take the newest release of the channel that sorts below this version instead of the
|
|
28
|
+
* channel pointer's release. */
|
|
29
|
+
olderThan?: string
|
|
30
|
+
}): Promise<VerifiedRelease> {
|
|
31
|
+
const { trust, discoveryName, olderThan } = options
|
|
32
|
+
const timeout = options.timeoutMs ?? 10_000
|
|
33
|
+
if (
|
|
34
|
+
!trust ||
|
|
35
|
+
!isRepositorySlug(trust.repository) ||
|
|
36
|
+
!['stable', 'daily', 'dev'].includes(trust.channel) ||
|
|
37
|
+
typeof trust.feed !== 'string' ||
|
|
38
|
+
typeof discoveryName !== 'string' ||
|
|
39
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.json$/.test(discoveryName) ||
|
|
40
|
+
discoveryName === 'release.json' ||
|
|
41
|
+
!Number.isSafeInteger(timeout) ||
|
|
42
|
+
timeout < 1 ||
|
|
43
|
+
timeout > 60_000
|
|
44
|
+
)
|
|
45
|
+
throw new Error('Invalid release discovery policy')
|
|
46
|
+
const controller = new AbortController(),
|
|
47
|
+
timer = setTimeout(() => controller.abort(), timeout)
|
|
48
|
+
const signal = options.signal
|
|
49
|
+
? AbortSignal.any([controller.signal, options.signal])
|
|
50
|
+
: controller.signal
|
|
51
|
+
const fetcher = options.fetch ?? globalThis.fetch
|
|
52
|
+
const get = (path: string) =>
|
|
53
|
+
fetchReleaseLocation(`${trust.feed}${path}`, trust.feed, fetcher, signal)
|
|
54
|
+
try {
|
|
55
|
+
if (signal.aborted) throw new Error('Release discovery cancelled')
|
|
56
|
+
let selected: FeedRelease | null = null
|
|
57
|
+
if (olderThan === undefined) {
|
|
58
|
+
selected = parseFeedRelease(
|
|
59
|
+
await readReleaseJson(await get(`channels/${trust.channel}.json`), MAX_POINTER_BYTES)
|
|
60
|
+
)
|
|
61
|
+
if (selected.channel !== trust.channel) throw new Error('Invalid channel pointer')
|
|
62
|
+
} else {
|
|
63
|
+
// A daily stays on the daily channel after promotion; dev builds are their own line.
|
|
64
|
+
const kinds =
|
|
65
|
+
trust.channel === 'stable'
|
|
66
|
+
? ['stable']
|
|
67
|
+
: trust.channel === 'dev'
|
|
68
|
+
? ['dev']
|
|
69
|
+
: ['daily', 'stable']
|
|
70
|
+
const ledger = parseReleaseLedger(
|
|
71
|
+
await readReleaseJson(await get('index.json'), MAX_LEDGER_BYTES),
|
|
72
|
+
// The feed URL ends in the app slug the ledger names.
|
|
73
|
+
new URL(trust.feed).pathname.split('/').at(-2)!
|
|
74
|
+
)
|
|
75
|
+
const entry = ledger.releases.find(
|
|
76
|
+
(item) => kinds.includes(item.kind) && versionLessThan(item.tag, olderThan)
|
|
77
|
+
)
|
|
78
|
+
if (entry) {
|
|
79
|
+
selected = parseFeedRelease(
|
|
80
|
+
await readReleaseJson(await get(`${entry.tag}/release.json`), MAX_POINTER_BYTES)
|
|
81
|
+
)
|
|
82
|
+
if (selected.tag !== entry.tag) throw new Error('Invalid feed release')
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const listed = selected?.assets.find((asset) => asset.name === discoveryName)
|
|
86
|
+
if (!selected || !listed) throw new Error('No qualified channel descriptor is available')
|
|
87
|
+
const { tag } = selected
|
|
88
|
+
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65_536)
|
|
89
|
+
if (
|
|
90
|
+
bytes.length !== listed.size ||
|
|
91
|
+
createHash('sha256').update(bytes).digest('hex') !== listed.sha256
|
|
92
|
+
)
|
|
93
|
+
throw new Error('Channel descriptor differs from its release')
|
|
94
|
+
let signed: unknown
|
|
95
|
+
try {
|
|
96
|
+
signed = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes))
|
|
97
|
+
} catch {
|
|
98
|
+
throw new Error('Invalid release feed response')
|
|
99
|
+
}
|
|
100
|
+
const result = verifyReleaseDescriptor(signed, trust)
|
|
101
|
+
if (!result.ok || result.descriptor.tag !== tag) throw new Error('Untrusted channel descriptor')
|
|
102
|
+
const payload = selected.assets.find((asset) => asset.name === result.descriptor.asset.name)
|
|
103
|
+
if (
|
|
104
|
+
!payload ||
|
|
105
|
+
payload.size !== result.descriptor.asset.size ||
|
|
106
|
+
payload.sha256 !== result.descriptor.asset.sha256
|
|
107
|
+
)
|
|
108
|
+
throw new Error('Release payload is missing or differs from its descriptor')
|
|
109
|
+
return result.descriptor
|
|
110
|
+
} finally {
|
|
111
|
+
clearTimeout(timer)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { mkdtemp, open, rm } from 'node:fs/promises'
|
|
2
|
+
import { join, resolve } from 'node:path'
|
|
3
|
+
import { isVerifiedRelease, verifyReleaseStream, type VerifiedRelease } from './signed-release'
|
|
4
|
+
import { fetchReleaseLocation, type FetchFunction } from './release-location'
|
|
5
|
+
|
|
6
|
+
/** Download an authenticated release to a new private directory; caller owns cleanup and installation. */
|
|
7
|
+
export async function downloadVerifiedRelease(options: {
|
|
8
|
+
descriptor: VerifiedRelease
|
|
9
|
+
directory: string
|
|
10
|
+
maxBytes: number
|
|
11
|
+
timeoutMs?: number
|
|
12
|
+
signal?: AbortSignal
|
|
13
|
+
fetch?: FetchFunction
|
|
14
|
+
}): Promise<{ path: string; directory: string }> {
|
|
15
|
+
const { descriptor, maxBytes } = options
|
|
16
|
+
const timeout = options.timeoutMs ?? 120_000
|
|
17
|
+
if (
|
|
18
|
+
!isVerifiedRelease(descriptor) ||
|
|
19
|
+
!Number.isSafeInteger(maxBytes) ||
|
|
20
|
+
maxBytes < 1 ||
|
|
21
|
+
descriptor.asset.size > maxBytes ||
|
|
22
|
+
!Number.isSafeInteger(timeout) ||
|
|
23
|
+
timeout < 1 ||
|
|
24
|
+
timeout > 600_000
|
|
25
|
+
)
|
|
26
|
+
throw new Error('Invalid verified download request')
|
|
27
|
+
const controller = new AbortController()
|
|
28
|
+
const timer = setTimeout(() => controller.abort(), timeout)
|
|
29
|
+
const signal = options.signal
|
|
30
|
+
? AbortSignal.any([controller.signal, options.signal])
|
|
31
|
+
: controller.signal
|
|
32
|
+
const fetcher = options.fetch ?? globalThis.fetch
|
|
33
|
+
let temporary: string | undefined
|
|
34
|
+
try {
|
|
35
|
+
if (signal.aborted) throw new Error('Release download cancelled')
|
|
36
|
+
// Verification bound the URL to `<feed><tag>/<name>`; redirects stay inside that feed.
|
|
37
|
+
const { url, name } = descriptor.asset
|
|
38
|
+
const feed = url.slice(0, url.length - `${descriptor.tag}/${name}`.length)
|
|
39
|
+
const response = await fetchReleaseLocation(url, feed, fetcher, signal)
|
|
40
|
+
if (response.status !== 200 || !response.body) {
|
|
41
|
+
await response.body?.cancel()
|
|
42
|
+
throw new Error('Release download failed')
|
|
43
|
+
}
|
|
44
|
+
const length = response.headers.get('content-length')
|
|
45
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
|
|
46
|
+
await response.body.cancel()
|
|
47
|
+
throw new Error('Release download size mismatch')
|
|
48
|
+
}
|
|
49
|
+
temporary = await mkdtemp(join(resolve(options.directory), 'framework-update-'))
|
|
50
|
+
const path = join(temporary, 'archive')
|
|
51
|
+
const file = await open(path, 'wx', 0o600)
|
|
52
|
+
try {
|
|
53
|
+
async function* writeChunks() {
|
|
54
|
+
let size = 0
|
|
55
|
+
for await (const chunk of response.body!) {
|
|
56
|
+
if (!(chunk instanceof Uint8Array) || signal.aborted)
|
|
57
|
+
throw new Error('Invalid download chunk')
|
|
58
|
+
size += chunk.length
|
|
59
|
+
if (!Number.isSafeInteger(size) || size > descriptor.asset.size)
|
|
60
|
+
throw new Error('Release download exceeds signed size')
|
|
61
|
+
let offset = 0
|
|
62
|
+
while (offset < chunk.length) {
|
|
63
|
+
const { bytesWritten } = await file.write(chunk, offset, chunk.length - offset)
|
|
64
|
+
if (!bytesWritten) throw new Error('Unable to write update')
|
|
65
|
+
offset += bytesWritten
|
|
66
|
+
}
|
|
67
|
+
yield chunk
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!(await verifyReleaseStream(writeChunks(), descriptor)))
|
|
71
|
+
throw new Error('Release download verification failed')
|
|
72
|
+
} finally {
|
|
73
|
+
await file.close()
|
|
74
|
+
}
|
|
75
|
+
return { path, directory: temporary }
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (temporary) await rm(temporary, { recursive: true, force: true })
|
|
78
|
+
throw error
|
|
79
|
+
} finally {
|
|
80
|
+
clearTimeout(timer)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { dlopen, FFIType, ptr } from 'bun:ffi'
|
|
2
|
+
import { isAbsolute, resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
/** Rename without replacing an existing destination. The caller must validate and own both parent directories. */
|
|
5
|
+
export function renameUpdateExclusive(source: string, destination: string): void {
|
|
6
|
+
if (
|
|
7
|
+
typeof source !== 'string' ||
|
|
8
|
+
typeof destination !== 'string' ||
|
|
9
|
+
!isAbsolute(source) ||
|
|
10
|
+
!isAbsolute(destination) ||
|
|
11
|
+
resolve(source) !== source ||
|
|
12
|
+
resolve(destination) !== destination ||
|
|
13
|
+
source === destination ||
|
|
14
|
+
source.includes('\0') ||
|
|
15
|
+
destination.includes('\0')
|
|
16
|
+
)
|
|
17
|
+
throw new Error('Invalid exclusive rename paths')
|
|
18
|
+
if (process.platform === 'darwin') {
|
|
19
|
+
const library = dlopen('libSystem.B.dylib', {
|
|
20
|
+
renamex_np: { args: [FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
|
|
21
|
+
})
|
|
22
|
+
try {
|
|
23
|
+
const from = Buffer.from(source + '\0'),
|
|
24
|
+
to = Buffer.from(destination + '\0')
|
|
25
|
+
if (library.symbols.renamex_np(ptr(from), ptr(to), 4) !== 0)
|
|
26
|
+
throw new Error('Exclusive rename failed')
|
|
27
|
+
} finally {
|
|
28
|
+
library.close()
|
|
29
|
+
}
|
|
30
|
+
} else if (process.platform === 'linux') {
|
|
31
|
+
const library = dlopen('libc.so.6', {
|
|
32
|
+
renameat2: {
|
|
33
|
+
args: [FFIType.i32, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.u32],
|
|
34
|
+
returns: FFIType.i32,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
try {
|
|
38
|
+
const from = Buffer.from(source + '\0'),
|
|
39
|
+
to = Buffer.from(destination + '\0')
|
|
40
|
+
if (library.symbols.renameat2(-100, ptr(from), -100, ptr(to), 1) !== 0)
|
|
41
|
+
throw new Error('Exclusive rename failed')
|
|
42
|
+
} finally {
|
|
43
|
+
library.close()
|
|
44
|
+
}
|
|
45
|
+
} else if (process.platform === 'win32') {
|
|
46
|
+
const library = dlopen('kernel32.dll', {
|
|
47
|
+
MoveFileW: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.i32 },
|
|
48
|
+
})
|
|
49
|
+
try {
|
|
50
|
+
const from = Buffer.from(source + '\0', 'utf16le'),
|
|
51
|
+
to = Buffer.from(destination + '\0', 'utf16le')
|
|
52
|
+
if (library.symbols.MoveFileW(ptr(from), ptr(to)) === 0)
|
|
53
|
+
throw new Error('Exclusive rename failed')
|
|
54
|
+
} finally {
|
|
55
|
+
library.close()
|
|
56
|
+
}
|
|
57
|
+
} else throw new Error('Unsupported exclusive rename platform')
|
|
58
|
+
}
|