@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,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTPS release feed an app publishes to and updates from (Cloudflare R2 behind
|
|
3
|
+
* adea.dev). Object keys are relative to the feed base, one prefix per app:
|
|
4
|
+
* `<app>/<tag>/<asset>` immutable assets and signed descriptors, `<app>/<tag>/release.json`
|
|
5
|
+
* the release's asset inventory, `<app>/index.json` the bounded release ledger and
|
|
6
|
+
* `<app>/channels/<channel>.json` a copy of the newest release.json on that channel.
|
|
7
|
+
*/
|
|
8
|
+
export type ReleaseFeed = Readonly<{ base: string; app: string }>
|
|
9
|
+
export type FeedChannel = 'dev' | 'daily' | 'stable'
|
|
10
|
+
type FeedAsset = Readonly<{ name: string; size: number; sha256: string }>
|
|
11
|
+
/** `<app>/<tag>/release.json` and the channel pointers that copy it; unsigned. */
|
|
12
|
+
export type FeedRelease = Readonly<{
|
|
13
|
+
tag: string
|
|
14
|
+
channel: FeedChannel
|
|
15
|
+
publishedAt: string
|
|
16
|
+
assets: readonly FeedAsset[]
|
|
17
|
+
}>
|
|
18
|
+
export type LedgerEntry = Readonly<{
|
|
19
|
+
tag: string
|
|
20
|
+
kind: FeedChannel
|
|
21
|
+
version: string
|
|
22
|
+
sourceSha: string
|
|
23
|
+
publishedAt: string
|
|
24
|
+
/** When a daily became stable; present exactly on stable entries. */
|
|
25
|
+
promotedAt?: string
|
|
26
|
+
}>
|
|
27
|
+
/** `<app>/index.json`: newest first. */
|
|
28
|
+
export type ReleaseLedger = Readonly<{ schema: 1; app: string; releases: readonly LedgerEntry[] }>
|
|
29
|
+
|
|
30
|
+
/** Ledger entries kept; the oldest fall off a full ledger. */
|
|
31
|
+
export const MAX_LEDGER_RELEASES = 500
|
|
32
|
+
const MAX_RELEASE_ASSETS = 256
|
|
33
|
+
|
|
34
|
+
const record = (value: unknown): value is Record<string, unknown> =>
|
|
35
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
36
|
+
const exactKeys = (value: Record<string, unknown>, keys: readonly string[]) =>
|
|
37
|
+
Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key))
|
|
38
|
+
const segment = /^[a-z0-9][a-z0-9-]{0,62}$/
|
|
39
|
+
const tagPattern = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.[1-9]\d*)?$/
|
|
40
|
+
const timestamp = (value: unknown): value is string =>
|
|
41
|
+
typeof value === 'string' &&
|
|
42
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(value) &&
|
|
43
|
+
Number.isFinite(Date.parse(value)) &&
|
|
44
|
+
new Date(value).toISOString().replace('.000Z', 'Z') === value.replace('.000Z', 'Z')
|
|
45
|
+
/** A release tag in the feed: `vX.Y.Z` or `vX.Y.Z-dev.N`. */
|
|
46
|
+
export const isFeedTag = (value: unknown): value is string =>
|
|
47
|
+
typeof value === 'string' && value.length <= 65 && tagPattern.test(value)
|
|
48
|
+
export const isFeedAssetName = (value: unknown): value is string =>
|
|
49
|
+
typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(value)
|
|
50
|
+
|
|
51
|
+
/** Validate a feed: an https origin and path prefix ending in `/`, with no credentials,
|
|
52
|
+
* port, query or fragment, and an app slug. */
|
|
53
|
+
export function parseReleaseFeed(value: unknown): ReleaseFeed {
|
|
54
|
+
if (!record(value) || !exactKeys(value, ['base', 'app']) || typeof value.base !== 'string')
|
|
55
|
+
throw new Error('Invalid release feed')
|
|
56
|
+
let url: URL
|
|
57
|
+
try {
|
|
58
|
+
url = new URL(value.base)
|
|
59
|
+
} catch {
|
|
60
|
+
throw new Error('Invalid release feed')
|
|
61
|
+
}
|
|
62
|
+
const parts = url.pathname.split('/').slice(1, -1)
|
|
63
|
+
if (
|
|
64
|
+
value.base.length > 200 ||
|
|
65
|
+
url.href !== value.base ||
|
|
66
|
+
url.protocol !== 'https:' ||
|
|
67
|
+
url.username ||
|
|
68
|
+
url.password ||
|
|
69
|
+
url.port ||
|
|
70
|
+
url.search ||
|
|
71
|
+
url.hash ||
|
|
72
|
+
!url.pathname.endsWith('/') ||
|
|
73
|
+
!parts.every((part) => segment.test(part)) ||
|
|
74
|
+
typeof value.app !== 'string' ||
|
|
75
|
+
!/^[a-z][a-z0-9-]{0,63}$/.test(value.app)
|
|
76
|
+
)
|
|
77
|
+
throw new Error('Invalid release feed')
|
|
78
|
+
return { base: value.base, app: value.app }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The URL every key of this app's feed lives under, ending in `/`. */
|
|
82
|
+
export const feedUrl = (feed: ReleaseFeed) => `${feed.base}${feed.app}/`
|
|
83
|
+
/** The bucket key of one release asset. */
|
|
84
|
+
export function feedAssetKey(feed: ReleaseFeed, tag: string, name: string): string {
|
|
85
|
+
if (!isFeedTag(tag) || !isFeedAssetName(name)) throw new Error('Invalid release asset')
|
|
86
|
+
return `${feed.app}/${tag}/${name}`
|
|
87
|
+
}
|
|
88
|
+
export const feedReleaseKey = (feed: ReleaseFeed, tag: string) =>
|
|
89
|
+
feedAssetKey(feed, tag, 'release.json')
|
|
90
|
+
export const feedIndexKey = (feed: ReleaseFeed) => `${feed.app}/index.json`
|
|
91
|
+
export const feedChannelKey = (feed: ReleaseFeed, channel: FeedChannel) =>
|
|
92
|
+
`${feed.app}/channels/${channel}.json`
|
|
93
|
+
|
|
94
|
+
const channelOf = (tag: string): 'dev' | 'daily' => (tag.includes('-dev.') ? 'dev' : 'daily')
|
|
95
|
+
|
|
96
|
+
/** Validate a release.json or channel pointer: a tag of its channel and a bounded,
|
|
97
|
+
* unique asset inventory. */
|
|
98
|
+
export function parseFeedRelease(value: unknown): FeedRelease {
|
|
99
|
+
if (
|
|
100
|
+
!record(value) ||
|
|
101
|
+
!exactKeys(value, ['tag', 'channel', 'publishedAt', 'assets']) ||
|
|
102
|
+
!isFeedTag(value.tag) ||
|
|
103
|
+
!['dev', 'daily', 'stable'].includes(String(value.channel)) ||
|
|
104
|
+
(value.channel === 'dev') !== (channelOf(value.tag) === 'dev') ||
|
|
105
|
+
!timestamp(value.publishedAt) ||
|
|
106
|
+
!Array.isArray(value.assets) ||
|
|
107
|
+
value.assets.length < 1 ||
|
|
108
|
+
value.assets.length > MAX_RELEASE_ASSETS
|
|
109
|
+
)
|
|
110
|
+
throw new Error('Invalid feed release')
|
|
111
|
+
const names = new Set<string>()
|
|
112
|
+
const assets = value.assets.map((asset: unknown): FeedAsset => {
|
|
113
|
+
if (
|
|
114
|
+
!record(asset) ||
|
|
115
|
+
!exactKeys(asset, ['name', 'size', 'sha256']) ||
|
|
116
|
+
!isFeedAssetName(asset.name) ||
|
|
117
|
+
asset.name === 'release.json' ||
|
|
118
|
+
names.has(asset.name) ||
|
|
119
|
+
!Number.isSafeInteger(asset.size) ||
|
|
120
|
+
Number(asset.size) < 1 ||
|
|
121
|
+
typeof asset.sha256 !== 'string' ||
|
|
122
|
+
!/^[a-f0-9]{64}$/.test(asset.sha256)
|
|
123
|
+
)
|
|
124
|
+
throw new Error('Invalid feed release asset')
|
|
125
|
+
names.add(asset.name)
|
|
126
|
+
return { name: asset.name, size: Number(asset.size), sha256: asset.sha256 }
|
|
127
|
+
})
|
|
128
|
+
return {
|
|
129
|
+
tag: value.tag,
|
|
130
|
+
channel: value.channel as FeedChannel,
|
|
131
|
+
publishedAt: value.publishedAt,
|
|
132
|
+
assets,
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Validate the ledger: this app, at most MAX_LEDGER_RELEASES unique tags, newest first,
|
|
137
|
+
* each kind matching its tag and only stable entries carrying a promotion time. */
|
|
138
|
+
export function parseReleaseLedger(value: unknown, app: string): ReleaseLedger {
|
|
139
|
+
if (
|
|
140
|
+
!record(value) ||
|
|
141
|
+
!exactKeys(value, ['schema', 'app', 'releases']) ||
|
|
142
|
+
value.schema !== 1 ||
|
|
143
|
+
value.app !== app ||
|
|
144
|
+
!Array.isArray(value.releases) ||
|
|
145
|
+
value.releases.length > MAX_LEDGER_RELEASES
|
|
146
|
+
)
|
|
147
|
+
throw new Error('Invalid release ledger')
|
|
148
|
+
const tags = new Set<string>()
|
|
149
|
+
let previous = Infinity
|
|
150
|
+
const releases = value.releases.map((entry: unknown): LedgerEntry => {
|
|
151
|
+
const stable = record(entry) && entry.kind === 'stable'
|
|
152
|
+
if (
|
|
153
|
+
!record(entry) ||
|
|
154
|
+
!exactKeys(entry, [
|
|
155
|
+
'tag',
|
|
156
|
+
'kind',
|
|
157
|
+
'version',
|
|
158
|
+
'sourceSha',
|
|
159
|
+
'publishedAt',
|
|
160
|
+
...(stable ? ['promotedAt'] : []),
|
|
161
|
+
]) ||
|
|
162
|
+
!isFeedTag(entry.tag) ||
|
|
163
|
+
tags.has(entry.tag) ||
|
|
164
|
+
entry.version !== entry.tag.slice(1) ||
|
|
165
|
+
!(stable ? channelOf(entry.tag) === 'daily' : entry.kind === channelOf(entry.tag)) ||
|
|
166
|
+
typeof entry.sourceSha !== 'string' ||
|
|
167
|
+
!/^[a-f0-9]{40}$/.test(entry.sourceSha) ||
|
|
168
|
+
!timestamp(entry.publishedAt) ||
|
|
169
|
+
Date.parse(entry.publishedAt) > previous ||
|
|
170
|
+
(stable &&
|
|
171
|
+
(!timestamp(entry.promotedAt) ||
|
|
172
|
+
Date.parse(entry.promotedAt) < Date.parse(entry.publishedAt)))
|
|
173
|
+
)
|
|
174
|
+
throw new Error('Invalid release ledger entry')
|
|
175
|
+
tags.add(entry.tag)
|
|
176
|
+
previous = Date.parse(entry.publishedAt)
|
|
177
|
+
return {
|
|
178
|
+
tag: entry.tag,
|
|
179
|
+
kind: entry.kind as FeedChannel,
|
|
180
|
+
version: entry.version,
|
|
181
|
+
sourceSha: entry.sourceSha,
|
|
182
|
+
publishedAt: entry.publishedAt,
|
|
183
|
+
...(stable ? { promotedAt: entry.promotedAt as string } : {}),
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
return { schema: 1, app, releases }
|
|
187
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** A fetch implementation. Bun's `typeof fetch` also requires `preconnect`, which callers never use. */
|
|
2
|
+
export type FetchFunction = (...args: Parameters<typeof fetch>) => Promise<Response>
|
|
3
|
+
|
|
4
|
+
/** `value` as a URL inside `scope`: the same https origin, under its path prefix, with no
|
|
5
|
+
* credentials, port, fragment or dot segments. */
|
|
6
|
+
function releaseUrl(value: string, scope: URL): URL {
|
|
7
|
+
const url = new URL(value)
|
|
8
|
+
if (
|
|
9
|
+
url.protocol !== 'https:' ||
|
|
10
|
+
url.origin !== scope.origin ||
|
|
11
|
+
url.port ||
|
|
12
|
+
url.username ||
|
|
13
|
+
url.password ||
|
|
14
|
+
url.hash ||
|
|
15
|
+
!url.pathname.startsWith(scope.pathname) ||
|
|
16
|
+
/(?:^|\/)\.{1,2}(?:\/|$)|%2e|%2f|%5c/i.test(url.pathname)
|
|
17
|
+
)
|
|
18
|
+
throw new Error('Untrusted release location')
|
|
19
|
+
return url
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** GET a release feed object without credentials, following at most five redirects that
|
|
23
|
+
* stay under `scope`, the app's feed URL. The caller reads or cancels the response body. */
|
|
24
|
+
export async function fetchReleaseLocation(
|
|
25
|
+
location: string,
|
|
26
|
+
scope: string,
|
|
27
|
+
fetcher: FetchFunction,
|
|
28
|
+
signal: AbortSignal
|
|
29
|
+
): Promise<Response> {
|
|
30
|
+
const root = new URL(scope)
|
|
31
|
+
if (
|
|
32
|
+
root.protocol !== 'https:' ||
|
|
33
|
+
root.href !== scope ||
|
|
34
|
+
!root.pathname.endsWith('/') ||
|
|
35
|
+
root.search ||
|
|
36
|
+
root.hash
|
|
37
|
+
)
|
|
38
|
+
throw new Error('Untrusted release location')
|
|
39
|
+
let url = releaseUrl(location, root)
|
|
40
|
+
for (let redirects = 0; ; redirects++) {
|
|
41
|
+
const response = await fetcher(url, {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
redirect: 'manual',
|
|
44
|
+
credentials: 'omit',
|
|
45
|
+
headers: { 'accept-encoding': 'identity' },
|
|
46
|
+
signal,
|
|
47
|
+
})
|
|
48
|
+
if (![301, 302, 303, 307, 308].includes(response.status)) return response
|
|
49
|
+
const next = response.headers.get('location')
|
|
50
|
+
await response.body?.cancel()
|
|
51
|
+
if (!next || redirects === 5) throw new Error('Invalid release redirect')
|
|
52
|
+
url = releaseUrl(new URL(next, url).href, root)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Read a 200 response body of at most `maximum` bytes. */
|
|
57
|
+
export async function readReleaseBytes(response: Response, maximum: number): Promise<Uint8Array> {
|
|
58
|
+
if (response.status !== 200 || !response.body) {
|
|
59
|
+
await response.body?.cancel()
|
|
60
|
+
throw new Error('Release feed request failed')
|
|
61
|
+
}
|
|
62
|
+
const length = response.headers.get('content-length')
|
|
63
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > maximum)) {
|
|
64
|
+
await response.body.cancel()
|
|
65
|
+
throw new Error('Release feed response exceeds bound')
|
|
66
|
+
}
|
|
67
|
+
const reader = response.body.getReader(),
|
|
68
|
+
chunks: Uint8Array[] = []
|
|
69
|
+
let total = 0
|
|
70
|
+
try {
|
|
71
|
+
for (;;) {
|
|
72
|
+
const { value, done } = await reader.read()
|
|
73
|
+
if (done) break
|
|
74
|
+
total += value.length
|
|
75
|
+
if (total > maximum) {
|
|
76
|
+
await reader.cancel()
|
|
77
|
+
throw new Error('Release feed response exceeds bound')
|
|
78
|
+
}
|
|
79
|
+
chunks.push(value)
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
reader.releaseLock()
|
|
83
|
+
}
|
|
84
|
+
const bytes = new Uint8Array(total)
|
|
85
|
+
let offset = 0
|
|
86
|
+
for (const chunk of chunks) {
|
|
87
|
+
bytes.set(chunk, offset)
|
|
88
|
+
offset += chunk.length
|
|
89
|
+
}
|
|
90
|
+
return bytes
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Parse a 200 response of at most `maximum` bytes as UTF-8 JSON. */
|
|
94
|
+
export async function readReleaseJson(response: Response, maximum: number): Promise<unknown> {
|
|
95
|
+
const bytes = await readReleaseBytes(response, maximum)
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes))
|
|
98
|
+
} catch {
|
|
99
|
+
throw new Error('Invalid release feed response')
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The update channel an installation follows. */
|
|
2
|
+
export type UpdateChannel = 'stable' | 'pre-release' | 'dev'
|
|
3
|
+
|
|
4
|
+
export function isUpdateChannel(value: unknown): value is UpdateChannel {
|
|
5
|
+
return value === 'stable' || value === 'pre-release' || value === 'dev'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parse a version in the update grammar into `[major, minor, patch, dev]`,
|
|
10
|
+
* where a release carries no dev counter and sorts after every dev build of
|
|
11
|
+
* its own triple. Components use exact integers, including the dev counter.
|
|
12
|
+
* Unparseable versions return null so the caller can fall back.
|
|
13
|
+
*/
|
|
14
|
+
function parseUpdateVersion(version: string): [bigint, bigint, bigint, bigint | null] | null {
|
|
15
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-dev\.(\d+))?$/.exec(version.trim())
|
|
16
|
+
if (!match) return null
|
|
17
|
+
return [
|
|
18
|
+
BigInt(match[1]!),
|
|
19
|
+
BigInt(match[2]!),
|
|
20
|
+
BigInt(match[3]!),
|
|
21
|
+
match[4] === undefined ? null : BigInt(match[4]),
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Semver ordering for everything the update grammar produces: `x.y.z` and the
|
|
27
|
+
* dev builds `x.y.z-dev.N`. A dev build sorts below its own release
|
|
28
|
+
* (`0.75.0-dev.1 < 0.75.0`) and above every earlier release, which is why dev
|
|
29
|
+
* builds are numbered for the next unreleased version. The order is the same on
|
|
30
|
+
* every channel. Unparseable versions fall back to the historic numeric-triple
|
|
31
|
+
* comparison — a malformed version must never wedge the state machine.
|
|
32
|
+
*/
|
|
33
|
+
export function versionLessThan(a: string, b: string): boolean {
|
|
34
|
+
const pa = parseUpdateVersion(a)
|
|
35
|
+
const pb = parseUpdateVersion(b)
|
|
36
|
+
if (pa && pb) {
|
|
37
|
+
for (let i = 0; i < 3; i++) {
|
|
38
|
+
if (pa[i] !== pb[i]) return pa[i]! < pb[i]!
|
|
39
|
+
}
|
|
40
|
+
if (pa[3] === null) return false
|
|
41
|
+
if (pb[3] === null) return true
|
|
42
|
+
return pa[3] < pb[3]
|
|
43
|
+
}
|
|
44
|
+
const fallbackA = a
|
|
45
|
+
.replace(/^v/, '')
|
|
46
|
+
.split('.')
|
|
47
|
+
.map((n) => parseInt(n, 10) || 0)
|
|
48
|
+
const fallbackB = b
|
|
49
|
+
.replace(/^v/, '')
|
|
50
|
+
.split('.')
|
|
51
|
+
.map((n) => parseInt(n, 10) || 0)
|
|
52
|
+
for (let i = 0; i < 3; i++) {
|
|
53
|
+
if ((fallbackB[i] ?? 0) !== (fallbackA[i] ?? 0))
|
|
54
|
+
return (fallbackB[i] ?? 0) > (fallbackA[i] ?? 0)
|
|
55
|
+
}
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHash,
|
|
3
|
+
createPublicKey,
|
|
4
|
+
sign,
|
|
5
|
+
timingSafeEqual,
|
|
6
|
+
verify,
|
|
7
|
+
type KeyObject,
|
|
8
|
+
} from 'node:crypto'
|
|
9
|
+
|
|
10
|
+
export type ReleaseDescriptor = Readonly<{
|
|
11
|
+
schema: 2
|
|
12
|
+
appId: string
|
|
13
|
+
repository: string
|
|
14
|
+
channel: 'dev' | 'daily' | 'stable'
|
|
15
|
+
tag: string
|
|
16
|
+
version: string
|
|
17
|
+
sourceSha: string
|
|
18
|
+
workflowSha: string
|
|
19
|
+
runId: string
|
|
20
|
+
runAttempt: number
|
|
21
|
+
platform: 'darwin' | 'win32' | 'linux'
|
|
22
|
+
arch: 'arm64' | 'x64'
|
|
23
|
+
asset: Readonly<{ name: string; url: string; size: number; sha256: string }>
|
|
24
|
+
keyId: string
|
|
25
|
+
}>
|
|
26
|
+
declare const verifiedBrand: unique symbol
|
|
27
|
+
export type VerifiedRelease = ReleaseDescriptor & { readonly [verifiedBrand]: true }
|
|
28
|
+
const verifiedDescriptors = new WeakMap<object, { key: string; signature: string }>()
|
|
29
|
+
export type SignedRelease = Readonly<{ descriptor: ReleaseDescriptor; signature: string }>
|
|
30
|
+
export type ReleaseTrust = Readonly<{
|
|
31
|
+
appId: string
|
|
32
|
+
repository: string
|
|
33
|
+
channel: ReleaseDescriptor['channel']
|
|
34
|
+
platform: ReleaseDescriptor['platform']
|
|
35
|
+
arch: ReleaseDescriptor['arch']
|
|
36
|
+
/** The app's release feed URL, ending in `/`; every asset URL is `<feed><tag>/<name>`. */
|
|
37
|
+
feed: string
|
|
38
|
+
keys: ReadonlyMap<string, string>
|
|
39
|
+
}>
|
|
40
|
+
/** A GitHub `owner/name` slug that is safe to place in API and download paths. */
|
|
41
|
+
export function isRepositorySlug(value: string): boolean {
|
|
42
|
+
return (
|
|
43
|
+
/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value) &&
|
|
44
|
+
value.length <= 200 &&
|
|
45
|
+
value.split('/').every((part) => part !== '.' && part !== '..')
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
export function assertRepositorySlug(value: string): void {
|
|
49
|
+
if (!isRepositorySlug(value)) throw new Error('Invalid GitHub repository')
|
|
50
|
+
}
|
|
51
|
+
const keys = [
|
|
52
|
+
'schema',
|
|
53
|
+
'appId',
|
|
54
|
+
'repository',
|
|
55
|
+
'channel',
|
|
56
|
+
'tag',
|
|
57
|
+
'version',
|
|
58
|
+
'sourceSha',
|
|
59
|
+
'workflowSha',
|
|
60
|
+
'runId',
|
|
61
|
+
'runAttempt',
|
|
62
|
+
'platform',
|
|
63
|
+
'arch',
|
|
64
|
+
'asset',
|
|
65
|
+
'keyId',
|
|
66
|
+
]
|
|
67
|
+
const assetKeys = ['name', 'url', 'size', 'sha256']
|
|
68
|
+
const record = (value: unknown): value is Record<string, unknown> =>
|
|
69
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
70
|
+
const exactKeys = (value: Record<string, unknown>, expected: string[]) =>
|
|
71
|
+
Object.keys(value).length === expected.length &&
|
|
72
|
+
expected.every((key) => Object.hasOwn(value, key))
|
|
73
|
+
function valid(value: unknown): value is ReleaseDescriptor {
|
|
74
|
+
if (
|
|
75
|
+
!record(value) ||
|
|
76
|
+
!exactKeys(value, keys) ||
|
|
77
|
+
!record(value.asset) ||
|
|
78
|
+
!exactKeys(value.asset, assetKeys)
|
|
79
|
+
)
|
|
80
|
+
return false
|
|
81
|
+
if (
|
|
82
|
+
value.schema !== 2 ||
|
|
83
|
+
typeof value.appId !== 'string' ||
|
|
84
|
+
!/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/.test(value.appId) ||
|
|
85
|
+
value.appId.length > 255
|
|
86
|
+
)
|
|
87
|
+
return false
|
|
88
|
+
if (
|
|
89
|
+
typeof value.repository !== 'string' ||
|
|
90
|
+
!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value.repository) ||
|
|
91
|
+
value.repository.length > 200
|
|
92
|
+
)
|
|
93
|
+
return false
|
|
94
|
+
if (value.channel !== 'dev' && value.channel !== 'daily' && value.channel !== 'stable')
|
|
95
|
+
return false
|
|
96
|
+
if (
|
|
97
|
+
typeof value.version !== 'string' ||
|
|
98
|
+
value.version.length > 64 ||
|
|
99
|
+
!/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(value.version) ||
|
|
100
|
+
value.tag !== `v${value.version}` ||
|
|
101
|
+
(value.channel === 'dev') !== /-dev\.\d+$/.test(value.version)
|
|
102
|
+
)
|
|
103
|
+
return false
|
|
104
|
+
if (
|
|
105
|
+
typeof value.sourceSha !== 'string' ||
|
|
106
|
+
!/^[a-f0-9]{40}$/.test(value.sourceSha) ||
|
|
107
|
+
typeof value.workflowSha !== 'string' ||
|
|
108
|
+
!/^[a-f0-9]{40}$/.test(value.workflowSha)
|
|
109
|
+
)
|
|
110
|
+
return false
|
|
111
|
+
if (
|
|
112
|
+
typeof value.runId !== 'string' ||
|
|
113
|
+
!/^[1-9]\d{0,19}$/.test(value.runId) ||
|
|
114
|
+
!Number.isSafeInteger(value.runAttempt) ||
|
|
115
|
+
Number(value.runAttempt) < 1
|
|
116
|
+
)
|
|
117
|
+
return false
|
|
118
|
+
if (
|
|
119
|
+
!['darwin', 'win32', 'linux'].includes(String(value.platform)) ||
|
|
120
|
+
!['arm64', 'x64'].includes(String(value.arch))
|
|
121
|
+
)
|
|
122
|
+
return false
|
|
123
|
+
if (typeof value.keyId !== 'string' || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(value.keyId))
|
|
124
|
+
return false
|
|
125
|
+
const asset = value.asset
|
|
126
|
+
if (
|
|
127
|
+
typeof asset.name !== 'string' ||
|
|
128
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(asset.name) ||
|
|
129
|
+
typeof asset.url !== 'string' ||
|
|
130
|
+
asset.url.length > 2048 ||
|
|
131
|
+
typeof asset.sha256 !== 'string' ||
|
|
132
|
+
!/^[a-f0-9]{64}$/.test(asset.sha256) ||
|
|
133
|
+
!Number.isSafeInteger(asset.size) ||
|
|
134
|
+
Number(asset.size) < 1
|
|
135
|
+
)
|
|
136
|
+
return false
|
|
137
|
+
try {
|
|
138
|
+
const url = new URL(asset.url)
|
|
139
|
+
return (
|
|
140
|
+
url.protocol === 'https:' &&
|
|
141
|
+
url.href === asset.url &&
|
|
142
|
+
!url.port &&
|
|
143
|
+
!url.username &&
|
|
144
|
+
!url.password &&
|
|
145
|
+
!url.search &&
|
|
146
|
+
!url.hash &&
|
|
147
|
+
url.pathname.endsWith(`/${value.tag}/${asset.name}`)
|
|
148
|
+
)
|
|
149
|
+
} catch {
|
|
150
|
+
return false
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Whether the asset URL is exactly this release's object in the trusted feed. */
|
|
154
|
+
const inFeed = (value: ReleaseDescriptor, feed: string) =>
|
|
155
|
+
typeof feed === 'string' &&
|
|
156
|
+
feed.startsWith('https://') &&
|
|
157
|
+
feed.endsWith('/') &&
|
|
158
|
+
value.asset.url === `${feed}${value.tag}/${value.asset.name}`
|
|
159
|
+
function message(value: ReleaseDescriptor): Buffer {
|
|
160
|
+
return Buffer.from(
|
|
161
|
+
JSON.stringify([
|
|
162
|
+
'adea-app-framework-release-v2',
|
|
163
|
+
value.schema,
|
|
164
|
+
value.appId,
|
|
165
|
+
value.repository,
|
|
166
|
+
value.channel,
|
|
167
|
+
value.tag,
|
|
168
|
+
value.version,
|
|
169
|
+
value.sourceSha,
|
|
170
|
+
value.workflowSha,
|
|
171
|
+
value.runId,
|
|
172
|
+
value.runAttempt,
|
|
173
|
+
value.platform,
|
|
174
|
+
value.arch,
|
|
175
|
+
value.asset.name,
|
|
176
|
+
value.asset.url,
|
|
177
|
+
value.asset.size,
|
|
178
|
+
value.asset.sha256,
|
|
179
|
+
value.keyId,
|
|
180
|
+
]),
|
|
181
|
+
'utf8'
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
/** Sign canonical release metadata with an application-owned Ed25519 private key. */
|
|
185
|
+
export function signReleaseDescriptor(
|
|
186
|
+
descriptor: ReleaseDescriptor,
|
|
187
|
+
privateKey: KeyObject
|
|
188
|
+
): SignedRelease {
|
|
189
|
+
if (
|
|
190
|
+
!valid(descriptor) ||
|
|
191
|
+
privateKey.type !== 'private' ||
|
|
192
|
+
privateKey.asymmetricKeyType !== 'ed25519'
|
|
193
|
+
)
|
|
194
|
+
throw new Error('Invalid release descriptor or signing key')
|
|
195
|
+
return {
|
|
196
|
+
descriptor,
|
|
197
|
+
signature: sign(null, message(descriptor), privateKey).toString('base64url'),
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Authenticate the entire descriptor against an application-owned trust policy. */
|
|
201
|
+
export function verifyReleaseDescriptor(
|
|
202
|
+
value: unknown,
|
|
203
|
+
trust: ReleaseTrust
|
|
204
|
+
): { ok: true; descriptor: VerifiedRelease } | { ok: false } {
|
|
205
|
+
try {
|
|
206
|
+
if (
|
|
207
|
+
!record(value) ||
|
|
208
|
+
!exactKeys(value, ['descriptor', 'signature']) ||
|
|
209
|
+
typeof value.signature !== 'string' ||
|
|
210
|
+
!/^[A-Za-z0-9_-]{86}$/.test(value.signature)
|
|
211
|
+
)
|
|
212
|
+
return { ok: false }
|
|
213
|
+
if (!valid(value.descriptor)) return { ok: false }
|
|
214
|
+
const descriptor: unknown = structuredClone(value.descriptor)
|
|
215
|
+
if (!valid(descriptor)) return { ok: false }
|
|
216
|
+
if (
|
|
217
|
+
descriptor.appId !== trust.appId ||
|
|
218
|
+
descriptor.repository !== trust.repository ||
|
|
219
|
+
descriptor.channel !== trust.channel ||
|
|
220
|
+
descriptor.platform !== trust.platform ||
|
|
221
|
+
descriptor.arch !== trust.arch ||
|
|
222
|
+
!inFeed(descriptor, trust.feed)
|
|
223
|
+
)
|
|
224
|
+
return { ok: false }
|
|
225
|
+
const encoded = trust.keys.get(descriptor.keyId)
|
|
226
|
+
if (!encoded) return { ok: false }
|
|
227
|
+
const raw = Buffer.from(encoded, 'base64')
|
|
228
|
+
const signature = Buffer.from(value.signature, 'base64url')
|
|
229
|
+
if (
|
|
230
|
+
raw.length !== 32 ||
|
|
231
|
+
signature.length !== 64 ||
|
|
232
|
+
signature.toString('base64url') !== value.signature
|
|
233
|
+
)
|
|
234
|
+
return { ok: false }
|
|
235
|
+
const key = createPublicKey({
|
|
236
|
+
key: Buffer.concat([Buffer.from('302a300506032b6570032100', 'hex'), raw]),
|
|
237
|
+
format: 'der',
|
|
238
|
+
type: 'spki',
|
|
239
|
+
})
|
|
240
|
+
if (!verify(null, message(descriptor), key, signature)) return { ok: false }
|
|
241
|
+
Object.freeze(descriptor.asset)
|
|
242
|
+
Object.freeze(descriptor)
|
|
243
|
+
verifiedDescriptors.set(descriptor, { key: encoded, signature: value.signature })
|
|
244
|
+
return { ok: true, descriptor: descriptor as VerifiedRelease }
|
|
245
|
+
} catch {
|
|
246
|
+
return { ok: false }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** A verified descriptor remains valid only in the process that authenticated it. */
|
|
250
|
+
export function isVerifiedRelease(value: unknown): value is VerifiedRelease {
|
|
251
|
+
return typeof value === 'object' && value !== null && verifiedDescriptors.has(value)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Check that an authenticated descriptor used this exact application's current trust key. */
|
|
255
|
+
export function isVerifiedReleaseForTrust(
|
|
256
|
+
value: unknown,
|
|
257
|
+
trust: ReleaseTrust
|
|
258
|
+
): value is VerifiedRelease {
|
|
259
|
+
return (
|
|
260
|
+
isVerifiedRelease(value) &&
|
|
261
|
+
value.appId === trust.appId &&
|
|
262
|
+
value.repository === trust.repository &&
|
|
263
|
+
value.channel === trust.channel &&
|
|
264
|
+
value.platform === trust.platform &&
|
|
265
|
+
value.arch === trust.arch &&
|
|
266
|
+
inFeed(value, trust.feed) &&
|
|
267
|
+
verifiedDescriptors.get(value)?.key === trust.keys.get(value.keyId)
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Return the authenticated signed envelope for re-verification in another process. */
|
|
272
|
+
export function exportVerifiedRelease(value: VerifiedRelease, trust: ReleaseTrust): SignedRelease {
|
|
273
|
+
if (!isVerifiedReleaseForTrust(value, trust)) throw new Error('Untrusted release descriptor')
|
|
274
|
+
return Object.freeze({ descriptor: value, signature: verifiedDescriptors.get(value)!.signature })
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Check exact archive bytes after the descriptor has been authenticated. */
|
|
278
|
+
export function verifyReleaseBytes(bytes: Uint8Array, descriptor: VerifiedRelease): boolean {
|
|
279
|
+
if (
|
|
280
|
+
!(bytes instanceof Uint8Array) ||
|
|
281
|
+
!verifiedDescriptors.has(descriptor) ||
|
|
282
|
+
bytes.byteLength !== descriptor.asset.size
|
|
283
|
+
)
|
|
284
|
+
return false
|
|
285
|
+
const actual = createHash('sha256').update(bytes).digest()
|
|
286
|
+
return timingSafeEqual(actual, Buffer.from(descriptor.asset.sha256, 'hex'))
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Check a streamed archive without buffering the whole artifact. */
|
|
290
|
+
export async function verifyReleaseStream(
|
|
291
|
+
chunks: AsyncIterable<Uint8Array>,
|
|
292
|
+
descriptor: VerifiedRelease
|
|
293
|
+
): Promise<boolean> {
|
|
294
|
+
if (!verifiedDescriptors.has(descriptor)) return false
|
|
295
|
+
const hash = createHash('sha256')
|
|
296
|
+
let size = 0
|
|
297
|
+
try {
|
|
298
|
+
for await (const chunk of chunks) {
|
|
299
|
+
if (!(chunk instanceof Uint8Array)) return false
|
|
300
|
+
size += chunk.byteLength
|
|
301
|
+
if (!Number.isSafeInteger(size) || size > descriptor.asset.size) return false
|
|
302
|
+
hash.update(chunk)
|
|
303
|
+
}
|
|
304
|
+
return (
|
|
305
|
+
size === descriptor.asset.size &&
|
|
306
|
+
timingSafeEqual(hash.digest(), Buffer.from(descriptor.asset.sha256, 'hex'))
|
|
307
|
+
)
|
|
308
|
+
} catch {
|
|
309
|
+
return false
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs'
|
|
2
|
+
import { constants } from 'node:fs'
|
|
3
|
+
import { open, type FileHandle } from 'node:fs/promises'
|
|
4
|
+
|
|
5
|
+
/** Whether two stats describe the same, unmodified file. */
|
|
6
|
+
export function sameFile(left: Stats, right: Stats): boolean {
|
|
7
|
+
return (
|
|
8
|
+
left.dev === right.dev &&
|
|
9
|
+
left.ino === right.ino &&
|
|
10
|
+
left.size === right.size &&
|
|
11
|
+
left.mtimeMs === right.mtimeMs
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Open the regular file `info` (from lstat) described, without following a link or
|
|
16
|
+
* blocking on a FIFO, and only if it has not been swapped or modified since. */
|
|
17
|
+
export async function openUnchangedFile(
|
|
18
|
+
path: string,
|
|
19
|
+
info: Stats,
|
|
20
|
+
message: string
|
|
21
|
+
): Promise<{ file: FileHandle; before: Stats }> {
|
|
22
|
+
const file = await open(
|
|
23
|
+
path,
|
|
24
|
+
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
25
|
+
)
|
|
26
|
+
const before = await file.stat()
|
|
27
|
+
if (!before.isFile() || !sameFile(before, info)) {
|
|
28
|
+
await file.close()
|
|
29
|
+
throw new Error(message)
|
|
30
|
+
}
|
|
31
|
+
return { file, before }
|
|
32
|
+
}
|