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:
N0VAN0M4LY committed 2026-11-30 11:12:44 +08:00
1 parent 31b38518f8
commit 746b74c564
24 files changed
+638 -28

No files matched your search

@@ -23,17 +23,27 @@ export class FeedUnreachableError extends Error {
const HEADERS = { Accept: 'application/vnd.github+json', 'User-Agent': 'WTOffline-Launcher', 'X-GitHub-Api-Version': '2022-11-28' };
/** The newest complete pack release, or null when none is released (or the repository is not public yet). */
export async function newestPackRelease(): Promise<PackReleaseFiles | null> {
let listing: Promise<readonly unknown[]> | null = null;
/** Share the in-flight request when the launcher checks both release channels at startup. */
export function listProjectReleases(): Promise<readonly unknown[]> {
return listing ??= readProjectReleases().finally(() => { listing = null; });
}
async function readProjectReleases(): Promise<readonly unknown[]> {
const tuning = patchPackTuning();
const url = `https://api.github.com/repos/${tuning.repository}/releases?per_page=${tuning.releasesPerCheck}`;
const response = await request(url, HEADERS, tuning.requestTimeoutMs);
if (response.status === 404) return null;
if (response.status === 404) return [];
if (!response.ok) throw new FeedUnreachableError(`GitHub answered HTTP ${response.status} for the release list`);
const releases = (await response.json()) as unknown;
if (!Array.isArray(releases)) throw new PatchPackError('contents', 'the release list is not a list');
return releases;
}
const packs = releases.map(packRelease).filter((release): release is PackReleaseFiles => release !== null);
/** The newest complete pack release, or null when none is released. */
export async function newestPackRelease(): Promise<PackReleaseFiles | null> {
const packs = (await listProjectReleases()).map(packRelease).filter((release): release is PackReleaseFiles => release !== null);
packs.sort((a, b) => comparePackVersions(b.version, a.version));
return packs[0] ?? null;
}