feat(launcher): add configurable update mirror
Let a saved HTTPS repository serve as the fallback for launcher and adaptation pack releases. Retry downloads for the selected version and validate against the project signing key. Verified type checks, the launcher build, and a simulated primary outage.
This commit is contained in:
1 parent
ca9843c304
commit
152be6af0e
13 files changed
+416
-257
No files matched your search
@@ -16,7 +16,7 @@ import {
|
||||
} from '../schemas/install.ts';
|
||||
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
|
||||
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
|
||||
import { ActivePatchSetSchema, PackApplyResultSchema, PackCheckSchema } from '../schemas/patch-pack.ts';
|
||||
import { ActivePatchSetSchema, PackApplyResultSchema, PackCheckSchema, PackReleaseSchema } from '../schemas/patch-pack.ts';
|
||||
import { AccountEditsSchema, SaveAvatarChoicesSchema, SaveAvatarIdSchema, ResearchBranchSchema, ResearchOperationSchema, SaveResearchSchema, OfficialImportOptionsSchema, OfficialPreviewSchema, OnlineDataSourceSchema, SaveOfficialRequestSchema, CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
|
||||
import { TuningPatchSchema, TuningViewSchema } from '../schemas/tuning.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
@@ -282,13 +282,13 @@ export const ipcContract = {
|
||||
output: ActivePatchSetSchema,
|
||||
},
|
||||
'patches:check': {
|
||||
/** Asks GitHub for the newest adaptation pack. */
|
||||
/** Checks for a newer adaptation pack. */
|
||||
input: z.void(),
|
||||
output: PackCheckSchema,
|
||||
},
|
||||
'patches:apply': {
|
||||
/** Downloads, verifies and activates the newest pack; the window asks the player first. */
|
||||
input: z.void(),
|
||||
/** Downloads, verifies and activates the pack version selected by the player. */
|
||||
input: z.object({ version: PackReleaseSchema.shape.version }),
|
||||
output: PackApplyResultSchema,
|
||||
},
|
||||
'patches:useBundled': {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
import { LANGUAGE_CHOICES } from '../languages.ts';
|
||||
import { parseLaunchArguments } from '../launch-arguments.ts';
|
||||
import { releaseRepositoryUrl } from '../update-source.ts';
|
||||
import { BACKGROUND_RANDOM, BackgroundChoiceSchema } from './background.ts';
|
||||
|
||||
const LanguageChoiceSchema = z.enum(LANGUAGE_CHOICES);
|
||||
@@ -11,6 +12,7 @@ const PortModeSchema = z.enum(['auto', 'fixed']);
|
||||
const PortSchema = z.number().int().min(1).max(65535);
|
||||
export const LAUNCH_ARGUMENTS_LIMIT = 4000;
|
||||
const LaunchArgumentsSchema = z.string().max(LAUNCH_ARGUMENTS_LIMIT).refine((value) => parseLaunchArguments(value) !== null);
|
||||
export const UpdateMirrorUrlSchema = z.string().trim().refine((value) => value === '' || releaseRepositoryUrl(value) !== null);
|
||||
|
||||
/** The launcher's own settings (not the game's, not the local service's tuning). */
|
||||
export const SettingsSchema = z.object({
|
||||
@@ -19,9 +21,10 @@ export const SettingsSchema = z.object({
|
||||
background: BackgroundChoiceSchema.default(BACKGROUND_RANDOM),
|
||||
/** Fetch wallpapers from the game website's public gallery. */
|
||||
officialWallpapers: z.boolean().default(true),
|
||||
/** Ask GitHub for a newer adaptation pack when the launcher starts. */
|
||||
/** Check for a newer adaptation pack when the launcher starts. */
|
||||
checkPatchPacksOnStart: z.boolean().default(true),
|
||||
checkLauncherUpdatesOnStart: z.boolean().default(true),
|
||||
updateMirrorUrl: UpdateMirrorUrlSchema.default(''),
|
||||
windowClose: WindowCloseSchema.default('quit'),
|
||||
afterGameStarts: AfterGameStartsSchema.default('minimize'),
|
||||
autoSaveBackups: z.boolean().default(true),
|
||||
@@ -43,6 +46,7 @@ export const SettingsPatchSchema = z.object({
|
||||
officialWallpapers: z.boolean().optional(),
|
||||
checkPatchPacksOnStart: z.boolean().optional(),
|
||||
checkLauncherUpdatesOnStart: z.boolean().optional(),
|
||||
updateMirrorUrl: UpdateMirrorUrlSchema.optional(),
|
||||
windowClose: WindowCloseSchema.optional(),
|
||||
afterGameStarts: AfterGameStartsSchema.optional(),
|
||||
autoSaveBackups: z.boolean().optional(),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/** Parse a repository URL that can be used with the release update protocol. */
|
||||
export function releaseRepositoryUrl(value: string): URL | null {
|
||||
try {
|
||||
const url = new URL(value);
|
||||
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) return null;
|
||||
url.pathname = url.pathname.replace(/\/+$/, '').replace(/\.git$/, '') || '/';
|
||||
if (url.origin === 'https://github.com' && !/^\/[\w.-]+\/[\w.-]+$/.test(url.pathname)) return null;
|
||||
return url;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user