feat(updates): verify and install launcher releases
Check the versioned release channel, verify the signed manifest and installer digest, and open the installer only after confirmation. Verified type checks, the Windows package, and an upgrade handoff from a local release fixture, including tampering and interrupted downloads.
This commit is contained in:
1 parent
31b38518f8
commit
746b74c564
24 files changed
+638
-28
No files matched your search
@@ -2,6 +2,7 @@ import { cp, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/p
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, join, relative, resolve, sep } from 'node:path';
|
||||
import { Arch, build, Platform } from 'electron-builder';
|
||||
import { launcherReleaseFiles } from '../apps/launcher/src/shared/schemas/app-update.ts';
|
||||
|
||||
const repository = resolve(import.meta.dirname, '..');
|
||||
const launcher = join(repository, 'apps', 'launcher');
|
||||
@@ -46,9 +47,10 @@ async function stageWorkspacePackage(folder: string, resources: string, runtimeM
|
||||
await writeFile(join(bridge, 'index.js'), 'export * from ' + JSON.stringify(entry) + ';\n');
|
||||
}
|
||||
|
||||
async function stageInstaller(stage: string): Promise<void> {
|
||||
async function stageInstaller(stage: string): Promise<string> {
|
||||
const manifest = JSON.parse(await readFile(join(launcher, 'package.json'), 'utf8')) as LauncherManifest;
|
||||
const { productName, version, description, main, type } = manifest;
|
||||
const artifactName = launcherReleaseFiles(version).installer;
|
||||
await writeFile(join(stage, 'package.json'), JSON.stringify({
|
||||
name: 'wtoffline-launcher', productName, version, description, main, type, license: 'AGPL-3.0-or-later',
|
||||
}));
|
||||
@@ -66,6 +68,7 @@ async function stageInstaller(stage: string): Promise<void> {
|
||||
for (const name of ['fflate', 'zod']) {
|
||||
await cp(join(modules, name), join(runtimeModules, name), { recursive: true });
|
||||
}
|
||||
return artifactName;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
@@ -75,7 +78,7 @@ async function main(): Promise<void> {
|
||||
try {
|
||||
const electron = join(modules, 'electron');
|
||||
const { version: electronVersion } = JSON.parse(await readFile(join(electron, 'package.json'), 'utf8')) as { version: string };
|
||||
await stageInstaller(stage);
|
||||
const artifactName = await stageInstaller(stage);
|
||||
const artifacts = await build({
|
||||
projectDir: stage,
|
||||
targets: Platform.WINDOWS.createTarget('nsis', Arch.x64),
|
||||
@@ -92,7 +95,10 @@ async function main(): Promise<void> {
|
||||
{ from: 'installer-resources', to: '.', filter: ['**/*'] },
|
||||
{ from: 'installer-modules', to: 'node_modules', filter: ['**/*'] },
|
||||
],
|
||||
win: { signExecutable: false },
|
||||
win: {
|
||||
artifactName,
|
||||
signExecutable: false,
|
||||
},
|
||||
nsis: { oneClick: false, perMachine: false, allowToChangeInstallationDirectory: true, runAfterFinish: false },
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user