@adea-ai/app-framework-release-tools 0.5.0 → 0.7.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/README.md +17 -12
- package/dist/circleci/circleci-daily-workspace.js +473 -0
- package/dist/circleci/circleci-gitlab-qualification.js +103 -0
- package/dist/circleci/prepare-daily-workspace.js +155 -0
- package/dist/cli.js +3444 -797
- package/dist/index.js +2249 -565
- package/dist/release-tools-source.json +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -17,23 +17,37 @@ var __export = (target, all) => {
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var exports_src = {};
|
|
19
19
|
__export(exports_src, {
|
|
20
|
+
assertStandaloneWindowsPayload: () => assertStandaloneWindowsPayload,
|
|
20
21
|
buildLinuxFormats: () => buildLinuxFormats,
|
|
22
|
+
buildStandaloneWindowsExe: () => buildStandaloneWindowsExe,
|
|
23
|
+
compareLinuxReproducibility: () => compareLinuxReproducibility,
|
|
24
|
+
createAptR2Store: () => createAptR2Store,
|
|
25
|
+
createAptSignatureVerifier: () => createAptSignatureVerifier,
|
|
26
|
+
createDailyBatchR2Client: () => createDailyBatchR2Client,
|
|
27
|
+
createDailyBatchR2Store: () => createDailyBatchR2Store,
|
|
28
|
+
createDailyBatchS3Transport: () => createDailyBatchS3Transport,
|
|
21
29
|
createDailyNativeReceipt: () => createDailyNativeReceipt,
|
|
22
30
|
createGitHubPromotionProvider: () => createGitHubPromotionProvider,
|
|
23
31
|
createGitHubReleasePublisher: () => createGitHubReleasePublisher,
|
|
24
32
|
createMacosDmg: () => createMacosDmg,
|
|
25
33
|
desktopDailyProfile: () => desktopDailyProfile,
|
|
34
|
+
expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
|
|
26
35
|
fileIdentity: () => fileIdentity2,
|
|
27
36
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
37
|
+
inspectDailyBatch: () => inspectDailyBatch,
|
|
28
38
|
inspectStagedStep: () => inspectStagedStep,
|
|
29
39
|
planDailyReleaseMatrix: () => planDailyReleaseMatrix,
|
|
30
40
|
planQualificationRun: () => planQualificationRun2,
|
|
31
41
|
planReleaseAssets: () => planReleaseAssets2,
|
|
42
|
+
promoteDailyBatch: () => promoteDailyBatch,
|
|
43
|
+
publishAptRepository: () => publishAptRepository,
|
|
32
44
|
publishFrameworkPackage: () => publishFrameworkPackage,
|
|
33
45
|
publishQualifiedRelease: () => publishQualifiedRelease,
|
|
34
46
|
qualifyGitHubRelease: () => qualifyGitHubRelease,
|
|
35
47
|
qualifyStep: () => qualifyStep,
|
|
36
48
|
qualifyUpgradeStep: () => qualifyUpgradeStep,
|
|
49
|
+
readDailyBatch: () => readDailyBatch,
|
|
50
|
+
rollbackDailyBatch: () => rollbackDailyBatch,
|
|
37
51
|
runPromotionCommand: () => runPromotionCommand,
|
|
38
52
|
runReleaseCutCommand: () => runReleaseCutCommand,
|
|
39
53
|
runReleasePublishCommand: () => runReleasePublishCommand,
|
|
@@ -44,6 +58,8 @@ __export(exports_src, {
|
|
|
44
58
|
stageLinuxPackagePair: () => stageLinuxPackagePair,
|
|
45
59
|
stagePlatformArtifacts: () => stagePlatformArtifacts,
|
|
46
60
|
stageReleaseDescriptors: () => stageReleaseDescriptors,
|
|
61
|
+
verifyDailyBatchDescriptor: () => verifyDailyBatchDescriptor,
|
|
62
|
+
verifyDailyBatchObject: () => verifyDailyBatchObject,
|
|
47
63
|
verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
|
|
48
64
|
verifyImage: () => verifyImage,
|
|
49
65
|
writeDescriptors: () => writeDescriptors
|
|
@@ -176,7 +192,7 @@ function parseArchPackage(value) {
|
|
|
176
192
|
assert(Array.isArray(links) && links.length <= 8 && links.every((link, index) => isRecord(link) && Object.keys(link).length === 2 && text(link.name, 64) && executableName.test(link.name) && link.name !== policy.executable && links.findIndex((item) => isRecord(item) && item.name === link.name) === index && bundlePath(link.target)), "Invalid Arch package links");
|
|
177
193
|
assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
|
|
178
194
|
const repository = policy.repository;
|
|
179
|
-
assert(repository === undefined || isRecord(repository) && Object.keys(repository).
|
|
195
|
+
assert(repository === undefined || isRecord(repository) && Object.keys(repository).every((key) => ["name", "base", "publicKey", "keyFingerprint"].includes(key)) && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey) && (repository.keyFingerprint === undefined || typeof repository.keyFingerprint === "string" && /^[0-9A-F]{40}$/.test(repository.keyFingerprint)), "Invalid Arch package repository");
|
|
180
196
|
return {
|
|
181
197
|
pkgname: policy.pkgname,
|
|
182
198
|
pkgdesc: policy.pkgdesc,
|
|
@@ -240,7 +256,8 @@ function parseArchPackage(value) {
|
|
|
240
256
|
repository: {
|
|
241
257
|
name: repository.name,
|
|
242
258
|
base: repository.base,
|
|
243
|
-
publicKey: repository.publicKey
|
|
259
|
+
publicKey: repository.publicKey,
|
|
260
|
+
...typeof repository.keyFingerprint === "string" ? { keyFingerprint: repository.keyFingerprint } : {}
|
|
244
261
|
}
|
|
245
262
|
}
|
|
246
263
|
};
|
|
@@ -353,10 +370,20 @@ var tokens = (value, minimum) => Array.isArray(value) && value.length >= minimum
|
|
|
353
370
|
var relativePath = (value) => typeof value === "string" && value.length <= 200 && /^[A-Za-z0-9._/-]+$/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
354
371
|
var platformTargets = {
|
|
355
372
|
"macos-arm64": ["darwin", "arm64"],
|
|
373
|
+
"macos-x64": ["darwin", "x64"],
|
|
356
374
|
"windows-x64": ["win32", "x64"],
|
|
357
|
-
"linux-x64": ["linux", "x64"]
|
|
375
|
+
"linux-x64": ["linux", "x64"],
|
|
376
|
+
"linux-arm64": ["linux", "arm64"]
|
|
358
377
|
};
|
|
359
378
|
var releasePlatforms = Object.keys(platformTargets);
|
|
379
|
+
var legacyDesktopPlatforms = [
|
|
380
|
+
"macos-arm64",
|
|
381
|
+
"windows-x64",
|
|
382
|
+
"linux-x64"
|
|
383
|
+
];
|
|
384
|
+
function requiredDesktopPlatforms(profile) {
|
|
385
|
+
return profile === "desktop-v2" ? releasePlatforms : legacyDesktopPlatforms;
|
|
386
|
+
}
|
|
360
387
|
function parseCommandArtifacts(value, platforms) {
|
|
361
388
|
if (value === undefined)
|
|
362
389
|
return [];
|
|
@@ -431,7 +458,7 @@ function parseReleaseConfig(config) {
|
|
|
431
458
|
throw new Error("Invalid offline expected read");
|
|
432
459
|
}
|
|
433
460
|
const platforms = config.platforms;
|
|
434
|
-
for (const required of
|
|
461
|
+
for (const required of requiredDesktopPlatforms(config.dailyReleaseProfile))
|
|
435
462
|
if (!Object.hasOwn(platforms, required))
|
|
436
463
|
throw new Error("Releases require all supported desktop platforms");
|
|
437
464
|
for (const [platform, assets] of Object.entries(platforms))
|
|
@@ -561,7 +588,7 @@ function discoveryPolicies(config, tag) {
|
|
|
561
588
|
result.push({ name, channel, platform, os, arch, appId: kind.appId, payload });
|
|
562
589
|
}
|
|
563
590
|
for (const kind of kinds)
|
|
564
|
-
for (const platform of
|
|
591
|
+
for (const platform of requiredDesktopPlatforms(config.dailyReleaseProfile))
|
|
565
592
|
if (!result.some((value) => value.channel === channel && value.appId === kind.appId && value.platform === platform))
|
|
566
593
|
throw new Error("Missing platform discovery policy");
|
|
567
594
|
}
|
|
@@ -800,15 +827,122 @@ async function runReleaseEffect(effect) {
|
|
|
800
827
|
}
|
|
801
828
|
|
|
802
829
|
// src/release-ports.ts
|
|
803
|
-
import { execFile, spawnSync } from "child_process";
|
|
830
|
+
import { execFile, spawn, spawnSync } from "child_process";
|
|
804
831
|
import { createPrivateKey } from "crypto";
|
|
805
832
|
import * as fsp from "fs/promises";
|
|
806
833
|
import { Context, Effect as Effect2 } from "effect";
|
|
834
|
+
import { promisify } from "util";
|
|
807
835
|
import { Effect as Effect3, Fiber, Option } from "effect";
|
|
808
836
|
|
|
809
837
|
class ReleaseGit extends Context.Service()("ReleaseTools/Git") {
|
|
810
838
|
}
|
|
811
839
|
|
|
840
|
+
class ReleaseLinuxBuild extends Context.Service()("ReleaseTools/LinuxBuild") {
|
|
841
|
+
}
|
|
842
|
+
var execFileAsync = promisify(execFile);
|
|
843
|
+
var liveLinuxBuild = {
|
|
844
|
+
async git(args, cwd) {
|
|
845
|
+
const { stdout } = await execFileAsync("/usr/bin/git", [
|
|
846
|
+
"--no-replace-objects",
|
|
847
|
+
"-c",
|
|
848
|
+
"core.fsmonitor=false",
|
|
849
|
+
"-c",
|
|
850
|
+
"core.hooksPath=/dev/null",
|
|
851
|
+
...args
|
|
852
|
+
], {
|
|
853
|
+
cwd,
|
|
854
|
+
encoding: "buffer",
|
|
855
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
856
|
+
timeout: 30000,
|
|
857
|
+
env: {
|
|
858
|
+
PATH: "/usr/bin:/bin",
|
|
859
|
+
HOME: "/nonexistent",
|
|
860
|
+
LC_ALL: "C",
|
|
861
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
862
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
863
|
+
GIT_NO_REPLACE_OBJECTS: "1",
|
|
864
|
+
GIT_OPTIONAL_LOCKS: "0",
|
|
865
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
return stdout;
|
|
869
|
+
},
|
|
870
|
+
async tool(command, args, env, signal) {
|
|
871
|
+
signal?.throwIfAborted();
|
|
872
|
+
await new Promise((resolve, reject) => {
|
|
873
|
+
const child = spawn(command, [...args], { env, stdio: "inherit", detached: true });
|
|
874
|
+
let timer;
|
|
875
|
+
const stop = () => {
|
|
876
|
+
if (!child.pid)
|
|
877
|
+
return;
|
|
878
|
+
try {
|
|
879
|
+
process.kill(-child.pid, "SIGTERM");
|
|
880
|
+
} catch {}
|
|
881
|
+
timer = setTimeout(() => {
|
|
882
|
+
try {
|
|
883
|
+
process.kill(-child.pid, "SIGKILL");
|
|
884
|
+
} catch {}
|
|
885
|
+
}, 2000);
|
|
886
|
+
};
|
|
887
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
888
|
+
if (signal?.aborted)
|
|
889
|
+
stop();
|
|
890
|
+
let spawnError;
|
|
891
|
+
child.once("error", (error) => {
|
|
892
|
+
spawnError = error;
|
|
893
|
+
});
|
|
894
|
+
child.once("close", async (code, childSignal) => {
|
|
895
|
+
signal?.removeEventListener("abort", stop);
|
|
896
|
+
if (timer)
|
|
897
|
+
clearTimeout(timer);
|
|
898
|
+
let leftDescendants = false;
|
|
899
|
+
if (child.pid) {
|
|
900
|
+
for (;; ) {
|
|
901
|
+
try {
|
|
902
|
+
const entries = await fsp.readdir("/proc");
|
|
903
|
+
let live = false;
|
|
904
|
+
for (const entry of entries) {
|
|
905
|
+
if (!/^\d+$/.test(entry))
|
|
906
|
+
continue;
|
|
907
|
+
let stat;
|
|
908
|
+
try {
|
|
909
|
+
stat = await fsp.readFile(`/proc/${entry}/stat`, "utf8");
|
|
910
|
+
} catch (error) {
|
|
911
|
+
if (error.code === "ENOENT")
|
|
912
|
+
continue;
|
|
913
|
+
throw error;
|
|
914
|
+
}
|
|
915
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
916
|
+
if (Number(fields[2]) === child.pid && fields[0] !== "Z" && fields[0] !== "X") {
|
|
917
|
+
live = true;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
if (!live)
|
|
922
|
+
break;
|
|
923
|
+
leftDescendants = true;
|
|
924
|
+
try {
|
|
925
|
+
process.kill(-child.pid, "SIGKILL");
|
|
926
|
+
} catch {}
|
|
927
|
+
} catch {}
|
|
928
|
+
await new Promise((done) => setTimeout(done, 20));
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (signal?.aborted)
|
|
932
|
+
reject(signal.reason);
|
|
933
|
+
else if (spawnError)
|
|
934
|
+
reject(spawnError);
|
|
935
|
+
else if (leftDescendants)
|
|
936
|
+
reject(new Error("Linux build tool left running descendants"));
|
|
937
|
+
else if (code === 0)
|
|
938
|
+
resolve();
|
|
939
|
+
else
|
|
940
|
+
reject(new Error(`Linux build tool failed (${childSignal ?? code})`));
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
|
|
812
946
|
class ReleaseGitHub extends Context.Service()("ReleaseTools/GitHub") {
|
|
813
947
|
}
|
|
814
948
|
|
|
@@ -1786,17 +1920,25 @@ function runnerTemp(env) {
|
|
|
1786
1920
|
}
|
|
1787
1921
|
|
|
1788
1922
|
// ../../src/installer/installer-layout.ts
|
|
1923
|
+
var INSTALLER_HOSTS = {
|
|
1924
|
+
"macos-arm64": "darwin/arm64",
|
|
1925
|
+
"macos-x64": "darwin/x64",
|
|
1926
|
+
"windows-x64": "win32/x64",
|
|
1927
|
+
"linux-x64": "linux/x64",
|
|
1928
|
+
"linux-arm64": "linux/arm64"
|
|
1929
|
+
};
|
|
1930
|
+
function isInstallerPlatform(value) {
|
|
1931
|
+
return typeof value === "string" && Object.hasOwn(INSTALLER_HOSTS, value);
|
|
1932
|
+
}
|
|
1933
|
+
function isMacInstallerPlatform(platform) {
|
|
1934
|
+
return platform === "macos-arm64" || platform === "macos-x64";
|
|
1935
|
+
}
|
|
1789
1936
|
function assertInstallerContext(env, platform, host, arch) {
|
|
1790
1937
|
assertHostedRunner(env, "Installer execution");
|
|
1791
1938
|
assertInstallerHost(platform, host, arch);
|
|
1792
1939
|
}
|
|
1793
1940
|
function assertInstallerHost(platform, host, arch) {
|
|
1794
|
-
const expected =
|
|
1795
|
-
"macos-arm64": "darwin/arm64",
|
|
1796
|
-
"windows-x64": "win32/x64",
|
|
1797
|
-
"linux-x64": "linux/x64",
|
|
1798
|
-
"linux-arm64": "linux/arm64"
|
|
1799
|
-
}[platform];
|
|
1941
|
+
const expected = INSTALLER_HOSTS[platform];
|
|
1800
1942
|
if (!expected || `${host}/${arch}` !== expected)
|
|
1801
1943
|
throw new Error("Installer requires matching native OS and architecture");
|
|
1802
1944
|
}
|
|
@@ -1823,11 +1965,11 @@ function assertPayloadLayout(options) {
|
|
|
1823
1965
|
const { platform, appName, renderer } = options;
|
|
1824
1966
|
const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
|
|
1825
1967
|
assertPortableAppName(appName);
|
|
1826
|
-
if (!
|
|
1968
|
+
if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer))
|
|
1827
1969
|
throw new Error("Invalid installer profile");
|
|
1828
1970
|
const fold = platform === "windows-x64";
|
|
1829
1971
|
const entries = paths(options.entries, fold);
|
|
1830
|
-
const mac = platform
|
|
1972
|
+
const mac = isMacInstallerPlatform(platform);
|
|
1831
1973
|
const root = mac ? `${appName}.app/Contents` : appName.replaceAll(" ", "");
|
|
1832
1974
|
const bin = mac ? `${root}/MacOS` : `${root}/bin`;
|
|
1833
1975
|
const resources = `${root}/Resources`;
|
|
@@ -3145,19 +3287,814 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
|
|
|
3145
3287
|
});
|
|
3146
3288
|
var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
|
|
3147
3289
|
var stageReleaseDescriptors = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(stageReleaseDescriptorsEffect(options)));
|
|
3148
|
-
// src/library/daily-
|
|
3290
|
+
// src/library/daily-batch-publication.ts
|
|
3291
|
+
import { createHash as createHash7, randomBytes } from "crypto";
|
|
3292
|
+
import { createReadStream } from "fs";
|
|
3293
|
+
|
|
3294
|
+
// ../../src/updates/feed/daily-batch-pointer.ts
|
|
3295
|
+
import { createPublicKey as createPublicKey3, verify as verify2 } from "crypto";
|
|
3296
|
+
var hex = /^[a-f0-9]{64}$/;
|
|
3297
|
+
var keyId = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
3298
|
+
function valid2(value) {
|
|
3299
|
+
return isRecord(value) && hasExactOwnKeys(value, [
|
|
3300
|
+
"schema",
|
|
3301
|
+
"appId",
|
|
3302
|
+
"feedApp",
|
|
3303
|
+
"manifestDigest",
|
|
3304
|
+
"generation",
|
|
3305
|
+
"sequence",
|
|
3306
|
+
"operation",
|
|
3307
|
+
"keyId"
|
|
3308
|
+
]) && value.schema === "framework/daily-pointer/v3" && typeof value.appId === "string" && /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value.appId) && typeof value.feedApp === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(value.feedApp) && typeof value.manifestDigest === "string" && hex.test(value.manifestDigest) && typeof value.generation === "string" && hex.test(value.generation) && Number.isSafeInteger(value.sequence) && Number(value.sequence) >= 1 && (value.operation === "promote" || value.operation === "rollback") && typeof value.keyId === "string" && keyId.test(value.keyId);
|
|
3309
|
+
}
|
|
3310
|
+
function message2(pointer) {
|
|
3311
|
+
return Buffer.from(JSON.stringify([
|
|
3312
|
+
"adea-app-framework-daily-pointer-v3",
|
|
3313
|
+
pointer.schema,
|
|
3314
|
+
pointer.appId,
|
|
3315
|
+
pointer.feedApp,
|
|
3316
|
+
pointer.manifestDigest,
|
|
3317
|
+
pointer.generation,
|
|
3318
|
+
pointer.sequence,
|
|
3319
|
+
pointer.operation,
|
|
3320
|
+
pointer.keyId
|
|
3321
|
+
]), "utf8");
|
|
3322
|
+
}
|
|
3323
|
+
async function signDailyPointer(pointer, signer) {
|
|
3324
|
+
if (!valid2(pointer) || signer.keyId !== pointer.keyId)
|
|
3325
|
+
throw new Error("Invalid Daily pointer signing policy");
|
|
3326
|
+
const signature = await signer.sign(message2(pointer));
|
|
3327
|
+
if (!(signature instanceof Uint8Array) || signature.length !== 64)
|
|
3328
|
+
throw new Error("Invalid Daily pointer signature");
|
|
3329
|
+
return { pointer, signature: Buffer.from(signature).toString("base64url") };
|
|
3330
|
+
}
|
|
3331
|
+
function verifyDailyPointer(value, target, keys) {
|
|
3332
|
+
try {
|
|
3333
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["pointer", "signature"]) || !valid2(value.pointer) || value.pointer.appId !== target.appId || value.pointer.feedApp !== target.feedApp || typeof value.signature !== "string" || !/^[A-Za-z0-9_-]{86}$/.test(value.signature))
|
|
3334
|
+
throw new Error;
|
|
3335
|
+
const encoded = keys.get(value.pointer.keyId);
|
|
3336
|
+
if (!encoded)
|
|
3337
|
+
throw new Error;
|
|
3338
|
+
const raw = Buffer.from(encoded, "base64");
|
|
3339
|
+
const signature = Buffer.from(value.signature, "base64url");
|
|
3340
|
+
if (raw.length !== 32 || signature.length !== 64 || signature.toString("base64url") !== value.signature)
|
|
3341
|
+
throw new Error;
|
|
3342
|
+
const key = createPublicKey3({
|
|
3343
|
+
key: Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]),
|
|
3344
|
+
format: "der",
|
|
3345
|
+
type: "spki"
|
|
3346
|
+
});
|
|
3347
|
+
if (!verify2(null, message2(value.pointer), key, signature))
|
|
3348
|
+
throw new Error;
|
|
3349
|
+
return value.pointer;
|
|
3350
|
+
} catch {
|
|
3351
|
+
throw new Error("Untrusted Daily pointer");
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
// src/library/daily-batch-publication.ts
|
|
3356
|
+
var authenticatedSnapshots = new WeakMap;
|
|
3357
|
+
var encoder = new TextEncoder;
|
|
3358
|
+
var hash = (bytes) => createHash7("sha256").update(bytes).digest("hex");
|
|
3359
|
+
var keyPart = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,199}$/;
|
|
3360
|
+
var hex2 = /^[a-f0-9]{64}$/;
|
|
3361
|
+
var app = /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
3362
|
+
var feedApp = /^[a-z][a-z0-9-]{0,63}$/;
|
|
3363
|
+
var gitSha = /^[a-f0-9]{40}$/;
|
|
3364
|
+
var tag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
3365
|
+
var own = (value, keys) => {
|
|
3366
|
+
const actual = Object.keys(value);
|
|
3367
|
+
return actual.length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
3368
|
+
};
|
|
3369
|
+
function parseManifest(value) {
|
|
3370
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3371
|
+
throw new Error("Invalid Daily batch");
|
|
3372
|
+
const m = value;
|
|
3373
|
+
if (!own(m, ["schema", "identity", "artifacts", "receipts"]) || m.schema !== "framework/daily-batch/v1" || !m.identity || typeof m.identity !== "object" || !own(m.identity, [
|
|
3374
|
+
"appId",
|
|
3375
|
+
"feedApp",
|
|
3376
|
+
"tag",
|
|
3377
|
+
"sourceSha",
|
|
3378
|
+
"workflowSha",
|
|
3379
|
+
"runId",
|
|
3380
|
+
"runAttempt"
|
|
3381
|
+
]) || typeof m.identity.appId !== "string" || !app.test(m.identity.appId) || typeof m.identity.feedApp !== "string" || !feedApp.test(m.identity.feedApp) || typeof m.identity.tag !== "string" || !tag.test(m.identity.tag) || typeof m.identity.sourceSha !== "string" || !gitSha.test(m.identity.sourceSha) || m.identity.workflowSha !== m.identity.sourceSha || typeof m.identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(m.identity.runId) || !Number.isSafeInteger(m.identity.runAttempt) || m.identity.runAttempt < 1)
|
|
3382
|
+
throw new Error("Invalid Daily batch identity");
|
|
3383
|
+
for (const list of [m.artifacts, m.receipts]) {
|
|
3384
|
+
if (!Array.isArray(list) || !list.length || list.length > 256)
|
|
3385
|
+
throw new Error("Invalid Daily batch inventory");
|
|
3386
|
+
const seen = new Set;
|
|
3387
|
+
for (const item of list) {
|
|
3388
|
+
if (!item || typeof item !== "object" || !own(item, ["name", "size", "digest"]) || typeof item.name !== "string" || !keyPart.test(item.name) || seen.has(item.name) || !Number.isSafeInteger(item.size) || item.size < 1 || typeof item.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(item.digest))
|
|
3389
|
+
throw new Error("Invalid Daily batch file");
|
|
3390
|
+
seen.add(item.name);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
return m;
|
|
3394
|
+
}
|
|
3395
|
+
async function verifyBytes(bytes, expected) {
|
|
3396
|
+
const digest = createHash7("sha256");
|
|
3397
|
+
let size = 0;
|
|
3398
|
+
for await (const chunk of bytes) {
|
|
3399
|
+
size += chunk.byteLength;
|
|
3400
|
+
if (size > expected.size)
|
|
3401
|
+
throw new Error(`Daily batch object too large: ${expected.name}`);
|
|
3402
|
+
digest.update(chunk);
|
|
3403
|
+
}
|
|
3404
|
+
if (size !== expected.size || `sha256:${digest.digest("hex")}` !== expected.digest)
|
|
3405
|
+
throw new Error(`Daily batch object differs: ${expected.name}`);
|
|
3406
|
+
}
|
|
3407
|
+
async function readSmall(bytes, limit) {
|
|
3408
|
+
const parts = [];
|
|
3409
|
+
let size = 0;
|
|
3410
|
+
for await (const part of bytes) {
|
|
3411
|
+
size += part.byteLength;
|
|
3412
|
+
if (size > limit)
|
|
3413
|
+
throw new Error("Daily batch record too large");
|
|
3414
|
+
parts.push(part);
|
|
3415
|
+
}
|
|
3416
|
+
return Buffer.concat(parts);
|
|
3417
|
+
}
|
|
3418
|
+
var one = async function* (bytes) {
|
|
3419
|
+
yield bytes;
|
|
3420
|
+
};
|
|
3421
|
+
var prefix = (slug, digest) => `${slug}/batches/sha256-${digest}`;
|
|
3422
|
+
var pointer = (slug) => `${slug}/channels/daily-batch.json`;
|
|
3423
|
+
var parseJson = (bytes) => JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
3424
|
+
var compareTag = (a, b) => {
|
|
3425
|
+
const left = a.slice(1).split(".").map(BigInt);
|
|
3426
|
+
const right = b.slice(1).split(".").map(BigInt);
|
|
3427
|
+
for (let index = 0;index < 3; index++) {
|
|
3428
|
+
if (left[index] > right[index])
|
|
3429
|
+
return 1;
|
|
3430
|
+
if (left[index] < right[index])
|
|
3431
|
+
return -1;
|
|
3432
|
+
}
|
|
3433
|
+
return 0;
|
|
3434
|
+
};
|
|
3435
|
+
async function readDailyBatch(store, target, keys) {
|
|
3436
|
+
if (!app.test(target.appId) || !feedApp.test(target.feedApp))
|
|
3437
|
+
throw new Error("Invalid Daily app");
|
|
3438
|
+
const current = await store.readPointer(pointer(target.feedApp));
|
|
3439
|
+
if (!current)
|
|
3440
|
+
return null;
|
|
3441
|
+
if (!current.version || current.bytes.byteLength > 4096)
|
|
3442
|
+
throw new Error("Invalid Daily pointer");
|
|
3443
|
+
const signedPointer = parseJson(current.bytes);
|
|
3444
|
+
const p = verifyDailyPointer(signedPointer, target, keys);
|
|
3445
|
+
const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, p.manifestDigest)}/manifest.json`), 262144);
|
|
3446
|
+
if (hash(bytes) !== p.manifestDigest)
|
|
3447
|
+
throw new Error("Daily batch manifest changed");
|
|
3448
|
+
const manifest = parseManifest(parseJson(bytes));
|
|
3449
|
+
if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
|
|
3450
|
+
throw new Error("Daily batch app mismatch");
|
|
3451
|
+
Object.freeze(manifest.identity);
|
|
3452
|
+
for (const file of [...manifest.artifacts, ...manifest.receipts])
|
|
3453
|
+
Object.freeze(file);
|
|
3454
|
+
Object.freeze(manifest.artifacts);
|
|
3455
|
+
Object.freeze(manifest.receipts);
|
|
3456
|
+
Object.freeze(manifest);
|
|
3457
|
+
const snapshot = Object.freeze({
|
|
3458
|
+
version: current.version,
|
|
3459
|
+
sequence: p.sequence,
|
|
3460
|
+
manifestDigest: p.manifestDigest,
|
|
3461
|
+
manifest
|
|
3462
|
+
});
|
|
3463
|
+
authenticatedSnapshots.set(snapshot, signedPointer);
|
|
3464
|
+
return snapshot;
|
|
3465
|
+
}
|
|
3466
|
+
async function verifyDailyBatchDescriptor(store, snapshot, discoveryName, trust) {
|
|
3467
|
+
if (!authenticatedSnapshots.has(snapshot))
|
|
3468
|
+
throw new Error("Untrusted Daily snapshot");
|
|
3469
|
+
const { identity, artifacts } = snapshot.manifest;
|
|
3470
|
+
verifyDailyPointer(authenticatedSnapshots.get(snapshot), identity, trust.keys);
|
|
3471
|
+
let feed;
|
|
3472
|
+
try {
|
|
3473
|
+
feed = new URL(trust.feed);
|
|
3474
|
+
if (feed.protocol !== "https:" || feed.href !== trust.feed || feed.username || feed.password || feed.port || feed.search || feed.hash || !feed.pathname.endsWith(`/${identity.feedApp}/`) || trust.appId !== identity.appId || trust.channel !== "daily")
|
|
3475
|
+
throw new Error;
|
|
3476
|
+
} catch {
|
|
3477
|
+
throw new Error("Untrusted Daily feed");
|
|
3478
|
+
}
|
|
3479
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.json$/.test(discoveryName))
|
|
3480
|
+
throw new Error("Invalid Daily descriptor name");
|
|
3481
|
+
const listed = artifacts.find((file) => file.name === discoveryName);
|
|
3482
|
+
if (!listed || listed.size > 65536)
|
|
3483
|
+
throw new Error("Daily descriptor is missing");
|
|
3484
|
+
const base = prefix(identity.feedApp, snapshot.manifestDigest);
|
|
3485
|
+
const bytes = await readSmall(await store.readObject(`${base}/artifacts/${discoveryName}`), 65536);
|
|
3486
|
+
if (bytes.byteLength !== listed.size || `sha256:${hash(bytes)}` !== listed.digest)
|
|
3487
|
+
throw new Error("Daily descriptor differs from its snapshot");
|
|
3488
|
+
let signed;
|
|
3489
|
+
try {
|
|
3490
|
+
signed = parseJson(bytes);
|
|
3491
|
+
} catch {
|
|
3492
|
+
throw new Error("Invalid Daily descriptor");
|
|
3493
|
+
}
|
|
3494
|
+
const verified = verifyReleaseDescriptor(signed, trust);
|
|
3495
|
+
if (!verified.ok)
|
|
3496
|
+
throw new Error("Untrusted Daily descriptor");
|
|
3497
|
+
const descriptor = verified.descriptor;
|
|
3498
|
+
const payload = artifacts.find((file) => file.name === descriptor.asset.name);
|
|
3499
|
+
if (descriptor.tag !== identity.tag || descriptor.sourceSha !== identity.sourceSha || descriptor.workflowSha !== identity.workflowSha || descriptor.runId !== identity.runId || descriptor.runAttempt !== identity.runAttempt || !payload || payload.size !== descriptor.asset.size || payload.digest !== `sha256:${descriptor.asset.sha256}`)
|
|
3500
|
+
throw new Error("Daily descriptor does not match its snapshot");
|
|
3501
|
+
return {
|
|
3502
|
+
descriptor,
|
|
3503
|
+
artifactUrl: `${trust.feed}batches/sha256-${snapshot.manifestDigest}/artifacts/${payload.name}`
|
|
3504
|
+
};
|
|
3505
|
+
}
|
|
3506
|
+
async function verifyDailyBatchObject(store, snapshot, kind, name) {
|
|
3507
|
+
const file = snapshot.manifest[kind].find((item) => item.name === name);
|
|
3508
|
+
if (!file)
|
|
3509
|
+
throw new Error("Object is not in the selected Daily batch");
|
|
3510
|
+
await verifyBytes(await store.readObject(`${prefix(snapshot.manifest.identity.feedApp, snapshot.manifestDigest)}/${kind}/${name}`), file);
|
|
3511
|
+
}
|
|
3512
|
+
async function promoteDailyBatch(store, candidate, signer, keys) {
|
|
3513
|
+
const first = parseManifest(parseJson(encoder.encode(JSON.stringify(await candidate.verify()))));
|
|
3514
|
+
const { appId, feedApp: slug } = first.identity;
|
|
3515
|
+
const target = { appId, feedApp: slug };
|
|
3516
|
+
const old = await readDailyBatch(store, target, keys);
|
|
3517
|
+
const manifestBytes = encoder.encode(JSON.stringify(first) + `
|
|
3518
|
+
`);
|
|
3519
|
+
if (manifestBytes.byteLength > 262144)
|
|
3520
|
+
throw new Error("Daily manifest too large");
|
|
3521
|
+
const digest = hash(manifestBytes);
|
|
3522
|
+
if (old && compareTag(first.identity.tag, old.manifest.identity.tag) <= 0 && old.manifestDigest !== digest)
|
|
3523
|
+
throw new Error("Daily promotion must advance the version; use explicit rollback");
|
|
3524
|
+
const base = prefix(slug, digest);
|
|
3525
|
+
for (const kind of ["artifacts", "receipts"]) {
|
|
3526
|
+
for (const file of first[kind]) {
|
|
3527
|
+
const filePath = candidate.path(kind, file.name);
|
|
3528
|
+
await verifyBytes(createReadStream(filePath), file);
|
|
3529
|
+
const key = `${base}/${kind}/${file.name}`;
|
|
3530
|
+
await store.putImmutable(key, createReadStream(filePath), file.size, file.digest.slice(7));
|
|
3531
|
+
await verifyBytes(await store.readObject(key), file);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
await store.putImmutable(`${base}/manifest.json`, one(manifestBytes), manifestBytes.byteLength, digest);
|
|
3535
|
+
const storedManifest = await readSmall(await store.readObject(`${base}/manifest.json`), 262144);
|
|
3536
|
+
if (hash(storedManifest) !== digest)
|
|
3537
|
+
throw new Error("Daily manifest upload differs");
|
|
3538
|
+
if (JSON.stringify(parseManifest(await candidate.verify())) !== JSON.stringify(first))
|
|
3539
|
+
throw new Error("Daily candidate changed during upload");
|
|
3540
|
+
if (old?.manifestDigest === digest) {
|
|
3541
|
+
const selected = await readDailyBatch(store, target, keys);
|
|
3542
|
+
if (!selected || selected.manifestDigest !== digest)
|
|
3543
|
+
throw new Error("Daily pointer changed during promotion retry");
|
|
3544
|
+
return selected;
|
|
3545
|
+
}
|
|
3546
|
+
const signed = await signDailyPointer({
|
|
3547
|
+
schema: "framework/daily-pointer/v3",
|
|
3548
|
+
appId,
|
|
3549
|
+
feedApp: slug,
|
|
3550
|
+
manifestDigest: digest,
|
|
3551
|
+
generation: randomBytes(32).toString("hex"),
|
|
3552
|
+
sequence: (old?.sequence ?? 0) + 1,
|
|
3553
|
+
operation: "promote",
|
|
3554
|
+
keyId: signer.keyId
|
|
3555
|
+
}, signer);
|
|
3556
|
+
verifyDailyPointer(signed, target, keys);
|
|
3557
|
+
const bytes = encoder.encode(JSON.stringify(signed) + `
|
|
3558
|
+
`);
|
|
3559
|
+
if (!await store.compareAndSwap(pointer(slug), old?.version ?? null, bytes))
|
|
3560
|
+
throw new Error("Daily pointer changed during promotion");
|
|
3561
|
+
const selected = await readDailyBatch(store, target, keys);
|
|
3562
|
+
if (!selected || selected.manifestDigest !== digest)
|
|
3563
|
+
throw new Error("Daily promotion could not be read back");
|
|
3564
|
+
return selected;
|
|
3565
|
+
}
|
|
3566
|
+
async function rollbackDailyBatch(store, current, target, signer, keys) {
|
|
3567
|
+
const appId = current.manifest.identity.appId;
|
|
3568
|
+
const slug = current.manifest.identity.feedApp;
|
|
3569
|
+
if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
|
|
3570
|
+
throw new Error("Invalid rollback target");
|
|
3571
|
+
const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
|
|
3572
|
+
if (!selected || selected.version !== current.version)
|
|
3573
|
+
throw new Error("Daily pointer changed during rollback");
|
|
3574
|
+
const bytes = await readSmall(await store.readObject(`${prefix(slug, target.manifestDigest)}/manifest.json`), 262144);
|
|
3575
|
+
if (hash(bytes) !== target.manifestDigest || JSON.stringify(parseManifest(parseJson(bytes))) !== JSON.stringify(target.manifest))
|
|
3576
|
+
throw new Error("Rollback target differs");
|
|
3577
|
+
for (const kind of ["artifacts", "receipts"])
|
|
3578
|
+
for (const file of target.manifest[kind])
|
|
3579
|
+
await verifyDailyBatchObject(store, target, kind, file.name);
|
|
3580
|
+
const signed = await signDailyPointer({
|
|
3581
|
+
schema: "framework/daily-pointer/v3",
|
|
3582
|
+
appId,
|
|
3583
|
+
feedApp: slug,
|
|
3584
|
+
manifestDigest: target.manifestDigest,
|
|
3585
|
+
generation: randomBytes(32).toString("hex"),
|
|
3586
|
+
sequence: selected.sequence + 1,
|
|
3587
|
+
operation: "rollback",
|
|
3588
|
+
keyId: signer.keyId
|
|
3589
|
+
}, signer);
|
|
3590
|
+
verifyDailyPointer(signed, { appId, feedApp: slug }, keys);
|
|
3591
|
+
const next = encoder.encode(JSON.stringify(signed) + `
|
|
3592
|
+
`);
|
|
3593
|
+
if (!await store.compareAndSwap(pointer(slug), current.version, next))
|
|
3594
|
+
throw new Error("Daily pointer changed during rollback");
|
|
3595
|
+
}
|
|
3596
|
+
// src/library/daily-batch-r2.ts
|
|
3597
|
+
import { createHash as createHash8 } from "crypto";
|
|
3598
|
+
var single = async function* (bytes) {
|
|
3599
|
+
yield bytes;
|
|
3600
|
+
};
|
|
3601
|
+
var maxSingle = 4 * 1024 * 1024 * 1024;
|
|
3602
|
+
var keyPattern = /^(?:[a-zA-Z0-9][a-zA-Z0-9._-]*\/)*[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
3603
|
+
var safeKey = (key) => {
|
|
3604
|
+
if (key.length > 1024 || !keyPattern.test(key))
|
|
3605
|
+
throw new Error("Invalid R2 object key");
|
|
3606
|
+
return key;
|
|
3607
|
+
};
|
|
3608
|
+
async function drain(body) {
|
|
3609
|
+
for await (const _ of body) {}
|
|
3610
|
+
}
|
|
3611
|
+
async function bounded(body, limit) {
|
|
3612
|
+
const chunks = [];
|
|
3613
|
+
let size = 0;
|
|
3614
|
+
for await (const chunk of body) {
|
|
3615
|
+
size += chunk.byteLength;
|
|
3616
|
+
if (size > limit)
|
|
3617
|
+
throw new Error("R2 pointer too large");
|
|
3618
|
+
chunks.push(chunk);
|
|
3619
|
+
}
|
|
3620
|
+
return Buffer.concat(chunks);
|
|
3621
|
+
}
|
|
3622
|
+
async function verify3(body, size, sha256) {
|
|
3623
|
+
const digest = createHash8("sha256");
|
|
3624
|
+
let actual = 0;
|
|
3625
|
+
for await (const chunk of body) {
|
|
3626
|
+
actual += chunk.byteLength;
|
|
3627
|
+
if (actual > size)
|
|
3628
|
+
throw new Error("Existing immutable R2 object differs");
|
|
3629
|
+
digest.update(chunk);
|
|
3630
|
+
}
|
|
3631
|
+
if (actual !== size || digest.digest("hex") !== sha256)
|
|
3632
|
+
throw new Error("Existing immutable R2 object differs");
|
|
3633
|
+
}
|
|
3634
|
+
function createDailyBatchR2Store(send) {
|
|
3635
|
+
const get = (key) => send({ method: "GET", key: safeKey(key), headers: {} });
|
|
3636
|
+
return {
|
|
3637
|
+
async readObject(key) {
|
|
3638
|
+
const response = await get(key);
|
|
3639
|
+
if (response.status !== 200) {
|
|
3640
|
+
await drain(response.body);
|
|
3641
|
+
throw new Error(`R2 object read failed (${response.status})`);
|
|
3642
|
+
}
|
|
3643
|
+
return response.body;
|
|
3644
|
+
},
|
|
3645
|
+
async readPointer(key) {
|
|
3646
|
+
const response = await get(key);
|
|
3647
|
+
if (response.status === 404) {
|
|
3648
|
+
await drain(response.body);
|
|
3649
|
+
return null;
|
|
3650
|
+
}
|
|
3651
|
+
if (response.status !== 200) {
|
|
3652
|
+
await drain(response.body);
|
|
3653
|
+
throw new Error(`R2 pointer read failed (${response.status})`);
|
|
3654
|
+
}
|
|
3655
|
+
const version = response.headers.etag;
|
|
3656
|
+
if (!version || /[\r\n]/.test(version)) {
|
|
3657
|
+
await drain(response.body);
|
|
3658
|
+
throw new Error("R2 pointer has no safe ETag");
|
|
3659
|
+
}
|
|
3660
|
+
return { version, bytes: await bounded(response.body, 4096) };
|
|
3661
|
+
},
|
|
3662
|
+
async putImmutable(key, body, size, sha256) {
|
|
3663
|
+
if (!Number.isSafeInteger(size) || size < 1 || size > maxSingle || !/^[a-f0-9]{64}$/.test(sha256))
|
|
3664
|
+
throw new Error("Invalid R2 immutable object identity");
|
|
3665
|
+
const response = await send({
|
|
3666
|
+
method: "PUT",
|
|
3667
|
+
key: safeKey(key),
|
|
3668
|
+
headers: {
|
|
3669
|
+
"if-none-match": "*",
|
|
3670
|
+
"content-length": String(size),
|
|
3671
|
+
"content-type": "application/octet-stream",
|
|
3672
|
+
"cache-control": "public, max-age=31536000, immutable"
|
|
3673
|
+
},
|
|
3674
|
+
body
|
|
3675
|
+
});
|
|
3676
|
+
await drain(response.body);
|
|
3677
|
+
if (response.status === 412) {
|
|
3678
|
+
const prior = await get(key);
|
|
3679
|
+
if (prior.status !== 200) {
|
|
3680
|
+
await drain(prior.body);
|
|
3681
|
+
throw new Error("Cannot verify existing R2 object");
|
|
3682
|
+
}
|
|
3683
|
+
await verify3(prior.body, size, sha256);
|
|
3684
|
+
} else if (response.status !== 200)
|
|
3685
|
+
throw new Error(`R2 immutable upload failed (${response.status})`);
|
|
3686
|
+
},
|
|
3687
|
+
async compareAndSwap(key, expectedVersion, bytes) {
|
|
3688
|
+
if (!bytes.byteLength || bytes.byteLength > 4096 || expectedVersion !== null && (!expectedVersion || /[\r\n]/.test(expectedVersion)))
|
|
3689
|
+
throw new Error("Invalid R2 pointer update");
|
|
3690
|
+
const response = await send({
|
|
3691
|
+
method: "PUT",
|
|
3692
|
+
key: safeKey(key),
|
|
3693
|
+
headers: {
|
|
3694
|
+
...expectedVersion === null ? { "if-none-match": "*" } : { "if-match": expectedVersion },
|
|
3695
|
+
"content-length": String(bytes.byteLength),
|
|
3696
|
+
"content-type": "application/json",
|
|
3697
|
+
"cache-control": "no-cache"
|
|
3698
|
+
},
|
|
3699
|
+
body: single(bytes)
|
|
3700
|
+
});
|
|
3701
|
+
await drain(response.body);
|
|
3702
|
+
if (response.status === 412)
|
|
3703
|
+
return false;
|
|
3704
|
+
if (response.status !== 200)
|
|
3705
|
+
throw new Error(`R2 pointer update failed (${response.status})`);
|
|
3706
|
+
return true;
|
|
3707
|
+
}
|
|
3708
|
+
};
|
|
3709
|
+
}
|
|
3710
|
+
// src/library/apt/apt-r2-store.ts
|
|
3711
|
+
var key = /^apt\/(?:adea|cortana)\/(?:archive-keyring\.gpg|dists\/(?:daily|stable)\/(?:InRelease|main\/binary-(?:amd64|arm64)\/by-hash\/SHA256\/[0-9a-f]{64})|pool\/main\/(?:a\/adea-desktop\/Adea|c\/cortana-desktop\/Cortana)-v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})-linux-(?:x64|arm64)\.deb)$/;
|
|
3712
|
+
var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
|
|
3713
|
+
var validEtag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3714
|
+
var max = 768 * 1024 ** 2;
|
|
3715
|
+
var metadataLimit = 256 * 1024;
|
|
3716
|
+
function validKey(k, mode) {
|
|
3717
|
+
if (!key.test(k) || mode === "pointer" !== pointer2.test(k))
|
|
3718
|
+
throw Error("Unapproved APT repository path");
|
|
3719
|
+
const parts = k.split("/");
|
|
3720
|
+
if (parts[2] === "pool" && parts[1][0] !== parts[4])
|
|
3721
|
+
throw Error("Cross-application APT pool path");
|
|
3722
|
+
return k;
|
|
3723
|
+
}
|
|
3724
|
+
async function* once(bytes) {
|
|
3725
|
+
yield bytes;
|
|
3726
|
+
}
|
|
3727
|
+
async function discard(body) {
|
|
3728
|
+
for await (const _ of body) {}
|
|
3729
|
+
}
|
|
3730
|
+
async function bounded2(body, limit) {
|
|
3731
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > max)
|
|
3732
|
+
throw Error("Invalid read bound");
|
|
3733
|
+
const chunks = [];
|
|
3734
|
+
let size = 0;
|
|
3735
|
+
for await (const chunk of body) {
|
|
3736
|
+
size += chunk.length;
|
|
3737
|
+
if (size > limit)
|
|
3738
|
+
throw Error("APT repository object beyond read bound");
|
|
3739
|
+
chunks.push(chunk);
|
|
3740
|
+
}
|
|
3741
|
+
return Buffer.concat(chunks, size);
|
|
3742
|
+
}
|
|
3743
|
+
function createAptR2Store(send) {
|
|
3744
|
+
const immutable = createDailyBatchR2Store(send);
|
|
3745
|
+
return {
|
|
3746
|
+
async remote(k, limit) {
|
|
3747
|
+
return bounded2(await immutable.readObject(validKey(k, "immutable")), limit);
|
|
3748
|
+
},
|
|
3749
|
+
async putImmutable(k, b, expected) {
|
|
3750
|
+
if (b.length > max || b.length !== expected.size)
|
|
3751
|
+
throw Error("Invalid immutable APT size");
|
|
3752
|
+
await immutable.putImmutable(validKey(k, "immutable"), once(b), expected.size, expected.sha256);
|
|
3753
|
+
},
|
|
3754
|
+
async readPointer(k, limit) {
|
|
3755
|
+
if (limit > metadataLimit)
|
|
3756
|
+
throw Error("Invalid InRelease read bound");
|
|
3757
|
+
const response = await send({ method: "GET", key: validKey(k, "pointer"), headers: {} });
|
|
3758
|
+
if (response.status === 404) {
|
|
3759
|
+
await discard(response.body);
|
|
3760
|
+
return null;
|
|
3761
|
+
}
|
|
3762
|
+
const etag = response.headers.etag;
|
|
3763
|
+
if (response.status !== 200 || !etag || !validEtag.test(etag)) {
|
|
3764
|
+
await discard(response.body);
|
|
3765
|
+
throw Error("Cannot read InRelease validator");
|
|
3766
|
+
}
|
|
3767
|
+
return { etag, bytes: await bounded2(response.body, limit) };
|
|
3768
|
+
},
|
|
3769
|
+
async casInRelease(k, prev, b) {
|
|
3770
|
+
if (prev !== null && !validEtag.test(prev) || !b.length || b.length > metadataLimit)
|
|
3771
|
+
throw Error("Invalid conditional InRelease write");
|
|
3772
|
+
const response = await send({
|
|
3773
|
+
method: "PUT",
|
|
3774
|
+
key: validKey(k, "pointer"),
|
|
3775
|
+
headers: {
|
|
3776
|
+
...prev === null ? { "if-none-match": "*" } : { "if-match": prev },
|
|
3777
|
+
"content-length": String(b.length),
|
|
3778
|
+
"content-type": "application/octet-stream",
|
|
3779
|
+
"cache-control": "no-cache"
|
|
3780
|
+
},
|
|
3781
|
+
body: once(b)
|
|
3782
|
+
});
|
|
3783
|
+
await discard(response.body);
|
|
3784
|
+
if (response.status === 412)
|
|
3785
|
+
return false;
|
|
3786
|
+
if (response.status !== 200)
|
|
3787
|
+
throw Error("Conditional InRelease write failed");
|
|
3788
|
+
return true;
|
|
3789
|
+
}
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3792
|
+
// src/library/apt/publish-apt-repository.ts
|
|
3793
|
+
import { createHash as createHash9 } from "crypto";
|
|
3794
|
+
import { gunzipSync } from "zlib";
|
|
3795
|
+
var ARCHES = ["amd64", "arm64"];
|
|
3796
|
+
var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
3797
|
+
var hex3 = /^[0-9a-f]{64}$/;
|
|
3798
|
+
var indexLimit = 256 * 1024;
|
|
3799
|
+
var debLimit = 768 * 1024 ** 2;
|
|
3800
|
+
var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3801
|
+
var digest = (bytes) => createHash9("sha256").update(bytes).digest("hex");
|
|
3802
|
+
var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
3803
|
+
var same2 = (a, b) => Buffer.from(a).equals(b);
|
|
3804
|
+
function need(condition, message) {
|
|
3805
|
+
if (!condition)
|
|
3806
|
+
throw Error(message);
|
|
3807
|
+
}
|
|
3808
|
+
function release(bytes, suite) {
|
|
3809
|
+
need(bytes.length > 0 && bytes.length <= indexLimit, "Invalid APT Release size");
|
|
3810
|
+
const lines = decode(bytes).trimEnd().split(`
|
|
3811
|
+
`);
|
|
3812
|
+
const fields = new Map;
|
|
3813
|
+
const bindings = new Map;
|
|
3814
|
+
let hashes = false;
|
|
3815
|
+
for (const line of lines) {
|
|
3816
|
+
if (line === "SHA256:" && !hashes) {
|
|
3817
|
+
hashes = true;
|
|
3818
|
+
continue;
|
|
3819
|
+
}
|
|
3820
|
+
if (!hashes) {
|
|
3821
|
+
const m = /^([A-Za-z-]+): (.{1,200})$/.exec(line);
|
|
3822
|
+
need(m && !fields.has(m[1]), "Invalid APT Release header");
|
|
3823
|
+
fields.set(m[1], m[2]);
|
|
3824
|
+
continue;
|
|
3825
|
+
}
|
|
3826
|
+
const m = /^ ([0-9a-f]{64}) ([1-9]\d{0,5}) (main\/binary-(?:amd64|arm64)\/Packages(?:\.gz)?)$/.exec(line);
|
|
3827
|
+
need(m && Number(m[2]) <= indexLimit && !bindings.has(m[3]), "Invalid APT Release index binding");
|
|
3828
|
+
bindings.set(m[3], { sha256: m[1], size: Number(m[2]) });
|
|
3829
|
+
}
|
|
3830
|
+
need(fields.get("Suite") === suite && fields.get("Codename") === suite && fields.get("Architectures") === "amd64 arm64" && fields.get("Components") === "main" && fields.get("Acquire-By-Hash") === "yes" && !!fields.get("Origin") && !!fields.get("Label") && bindings.size === 4, "APT Release metadata does not match the exact suite and architecture policy");
|
|
3831
|
+
const created = Date.parse(fields.get("Date") ?? "");
|
|
3832
|
+
const validUntil = Date.parse(fields.get("Valid-Until") ?? "");
|
|
3833
|
+
need(Number.isFinite(created) && validUntil - created === 30 * 86400000, "Invalid APT metadata clock");
|
|
3834
|
+
return { fields, bindings, created, validUntil };
|
|
3835
|
+
}
|
|
3836
|
+
function identity(app, arch, v) {
|
|
3837
|
+
const pkg = app + "-desktop";
|
|
3838
|
+
const brand = app === "adea" ? "Adea" : "Cortana";
|
|
3839
|
+
const name = brand + "-v" + v + "-linux-" + (arch === "amd64" ? "x64" : "arm64") + ".deb";
|
|
3840
|
+
return { pkg, name, path: "pool/main/" + app[0] + "/" + pkg + "/" + name };
|
|
3841
|
+
}
|
|
3842
|
+
function packageIndex(bytes, app, arch) {
|
|
3843
|
+
const text = decode(bytes);
|
|
3844
|
+
need(text.endsWith(`
|
|
3845
|
+
|
|
3846
|
+
`) && !text.slice(0, -2).includes(`
|
|
3847
|
+
|
|
3848
|
+
`), "Expected a single APT package stanza");
|
|
3849
|
+
const fields = new Map;
|
|
3850
|
+
for (const line of text.slice(0, -2).split(`
|
|
3851
|
+
`)) {
|
|
3852
|
+
if (/^[ \t]/.test(line) && fields.size)
|
|
3853
|
+
continue;
|
|
3854
|
+
const m = /^([A-Za-z0-9-]+):[ \t]*(.*)$/.exec(line);
|
|
3855
|
+
need(m && !fields.has(m[1].toLowerCase()), "Invalid APT Packages field");
|
|
3856
|
+
fields.set(m[1].toLowerCase(), m[2]);
|
|
3857
|
+
}
|
|
3858
|
+
const v = fields.get("version") ?? "";
|
|
3859
|
+
need(version.test(v), "Invalid APT package version");
|
|
3860
|
+
const id = identity(app, arch, v);
|
|
3861
|
+
const size = Number(fields.get("size"));
|
|
3862
|
+
const sha256 = fields.get("sha256") ?? "";
|
|
3863
|
+
need(fields.get("architecture") === arch && fields.get("package") === id.pkg && fields.get("filename") === id.path && String(size) === fields.get("size") && Number.isSafeInteger(size) && size > 0 && size <= debLimit && hex3.test(sha256), "Unexpected APT package identity or size");
|
|
3864
|
+
return { ...id, version: v, size, sha256 };
|
|
3865
|
+
}
|
|
3866
|
+
function byHash(path, binding) {
|
|
3867
|
+
return path.slice(0, path.lastIndexOf("/")) + "/by-hash/SHA256/" + binding.sha256;
|
|
3868
|
+
}
|
|
3869
|
+
function check(bytes, expected) {
|
|
3870
|
+
need(bytes.length === expected.size && digest(bytes) === expected.sha256, "APT object bytes mismatch");
|
|
3871
|
+
return bytes;
|
|
3872
|
+
}
|
|
3873
|
+
function compare(a, b) {
|
|
3874
|
+
const old = b.split(".").map(Number);
|
|
3875
|
+
return a.split(".").map(Number).map((n, i) => n - old[i]).find(Boolean) ?? 0;
|
|
3876
|
+
}
|
|
3877
|
+
async function index(read, app, arch, bindings, base) {
|
|
3878
|
+
const prefix = "main/binary-" + arch + "/Packages";
|
|
3879
|
+
const entries = await Promise.all(["", ".gz"].map(async (suffix) => {
|
|
3880
|
+
const path = prefix + suffix;
|
|
3881
|
+
const binding = bindings.get(path);
|
|
3882
|
+
need(binding, "Missing APT index binding");
|
|
3883
|
+
const key = base + byHash(path, binding);
|
|
3884
|
+
return { key, binding, bytes: check(await read(key, binding.size), binding) };
|
|
3885
|
+
}));
|
|
3886
|
+
need(same2(entries[0].bytes, gunzipSync(entries[1].bytes, { maxOutputLength: indexLimit })), "Compressed and plain APT indices differ");
|
|
3887
|
+
return { entries, pkg: packageIndex(entries[0].bytes, app, arch) };
|
|
3888
|
+
}
|
|
3889
|
+
async function publishAptRepository({ app, suite, tag, assets }, port, now = Date.now()) {
|
|
3890
|
+
need((app === "adea" || app === "cortana") && (suite === "stable" || suite === "daily") && tag.startsWith("v") && version.test(tag.slice(1)) && Number.isFinite(now) && assets.length <= 256, "Invalid authorized APT candidate");
|
|
3891
|
+
const root = "apt/" + app + "/";
|
|
3892
|
+
const dists = "dists/" + suite + "/";
|
|
3893
|
+
const key = root + dists + "InRelease";
|
|
3894
|
+
const proposed = await port.staged(dists + "InRelease", indexLimit);
|
|
3895
|
+
need(proposed.length > 0 && proposed.length <= indexLimit, "Invalid staged InRelease");
|
|
3896
|
+
const plan = release(await port.verify(proposed), suite);
|
|
3897
|
+
need(plan.created <= now + 5 * 60000 && plan.validUntil > now, "Candidate APT metadata is not current");
|
|
3898
|
+
const parts = await Promise.all(ARCHES.map((arch) => index(port.staged, app, arch, plan.bindings, dists)));
|
|
3899
|
+
for (const { pkg } of parts) {
|
|
3900
|
+
const allowed = assets.filter((a) => a.name === pkg.name);
|
|
3901
|
+
need(pkg.version === tag.slice(1) && allowed.length === 1 && allowed[0].size === pkg.size && allowed[0].sha256 === pkg.sha256, "APT package is not part of the independently verified release");
|
|
3902
|
+
}
|
|
3903
|
+
const prior = await port.readPointer(key, indexLimit);
|
|
3904
|
+
if (prior) {
|
|
3905
|
+
need(etag.test(prior.etag) && prior.bytes.length <= indexLimit, "Invalid current APT pointer");
|
|
3906
|
+
const old = release(await port.verify(prior.bytes), suite);
|
|
3907
|
+
need(old.fields.get("Origin") === plan.fields.get("Origin") && old.fields.get("Label") === plan.fields.get("Label"), "APT repository identity changed");
|
|
3908
|
+
const oldParts = await Promise.all(ARCHES.map((arch) => index(port.remote, app, arch, old.bindings, root + dists)));
|
|
3909
|
+
const current = oldParts[0].pkg.version;
|
|
3910
|
+
need(oldParts[1].pkg.version === current, "Incumbent APT architectures disagree");
|
|
3911
|
+
need(compare(tag.slice(1), current) >= 0 && plan.created >= old.created, "APT version or date would go backwards");
|
|
3912
|
+
if (tag.slice(1) === current) {
|
|
3913
|
+
need(parts.every(({ pkg }, i) => pkg.sha256 === oldParts[i].pkg.sha256 && pkg.size === oldParts[i].pkg.size), "Cannot replace published bytes for the same APT version");
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
for (const { entries, pkg } of parts) {
|
|
3917
|
+
for (const item of [
|
|
3918
|
+
...entries,
|
|
3919
|
+
{
|
|
3920
|
+
key: pkg.path,
|
|
3921
|
+
binding: pkg,
|
|
3922
|
+
bytes: check(await port.staged(pkg.path, pkg.size), pkg)
|
|
3923
|
+
}
|
|
3924
|
+
]) {
|
|
3925
|
+
const name = root + item.key;
|
|
3926
|
+
await port.putImmutable(name, item.bytes, item.binding);
|
|
3927
|
+
check(await port.remote(name, item.binding.size), item.binding);
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
if (prior && same2(prior.bytes, proposed)) {
|
|
3931
|
+
const current = await port.readPointer(key, indexLimit);
|
|
3932
|
+
need(current && current.etag === prior.etag && same2(current.bytes, proposed), "APT pointer changed during retry");
|
|
3933
|
+
return { tag, changed: false };
|
|
3934
|
+
}
|
|
3935
|
+
need(await port.casInRelease(key, prior?.etag ?? null, proposed), "APT InRelease changed concurrently");
|
|
3936
|
+
const current = await port.readPointer(key, indexLimit);
|
|
3937
|
+
need(current && etag.test(current.etag) && same2(current.bytes, proposed), "APT InRelease did not read back as committed");
|
|
3938
|
+
return { tag, changed: true };
|
|
3939
|
+
}
|
|
3940
|
+
// src/library/apt/verify-apt-signature.ts
|
|
3941
|
+
import { createHash as createHash10 } from "crypto";
|
|
3942
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
3943
|
+
import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
3944
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
3149
3945
|
import { join as join7 } from "path";
|
|
3946
|
+
function createAptSignatureVerifier(config) {
|
|
3947
|
+
const { fingerprint } = config;
|
|
3948
|
+
const keyring = Buffer.from(config.keyring);
|
|
3949
|
+
if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) || createHash10("sha256").update(keyring).digest("hex") !== config.sha256)
|
|
3950
|
+
throw Error("Untrusted APT signing keyring");
|
|
3951
|
+
return async (bytes) => {
|
|
3952
|
+
if (bytes.length < 1 || bytes.length > 256 * 1024)
|
|
3953
|
+
throw Error("Invalid InRelease size");
|
|
3954
|
+
const scratch = await mkdtemp3(join7(tmpdir4(), "framework-apt-verification-"));
|
|
3955
|
+
try {
|
|
3956
|
+
const file = join7(scratch, "InRelease");
|
|
3957
|
+
const plain = join7(scratch, "Release");
|
|
3958
|
+
const ring = join7(scratch, "trusted.gpg");
|
|
3959
|
+
await Promise.all([
|
|
3960
|
+
writeFile3(ring, keyring, { flag: "wx", mode: 384 }),
|
|
3961
|
+
writeFile3(file, bytes, { flag: "wx", mode: 384 })
|
|
3962
|
+
]);
|
|
3963
|
+
const status = spawnSync2("gpgv", ["--homedir", scratch, "--keyring", ring, "--status-fd", "1", "--output", plain, file], {
|
|
3964
|
+
env: { PATH: process.env.PATH, HOME: scratch, LC_ALL: "C" },
|
|
3965
|
+
encoding: "utf8",
|
|
3966
|
+
timeout: 15000,
|
|
3967
|
+
maxBuffer: 256 * 1024
|
|
3968
|
+
});
|
|
3969
|
+
const lines = (status.stdout ?? "").split(`
|
|
3970
|
+
`).filter((line) => line.startsWith("[GNUPG:] VALIDSIG "));
|
|
3971
|
+
const signature = (lines[0] ?? "").split(" ");
|
|
3972
|
+
if (status.error || status.status !== 0 || lines.length !== 1 || signature[2] !== fingerprint || signature.at(-1) !== fingerprint || signature[9] !== "8" || signature[10] !== "01" || (status.stdout ?? "").match(/^\[GNUPG:\] (?:REVKEYSIG|EXPKEYSIG|EXPSIG|BADSIG|ERRSIG|KEYEXPIRED)(?:\s|$)/m))
|
|
3973
|
+
throw Error("InRelease lacks an exact valid SHA-256 repository signature");
|
|
3974
|
+
const decoded = await readFile5(plain);
|
|
3975
|
+
if (!decoded.length || decoded.length > 256 * 1024)
|
|
3976
|
+
throw Error("Invalid signed Release size");
|
|
3977
|
+
return decoded;
|
|
3978
|
+
} finally {
|
|
3979
|
+
await rm3(scratch, { recursive: true, force: true });
|
|
3980
|
+
}
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3983
|
+
// src/library/daily-batch-inspection.ts
|
|
3984
|
+
import { join as join9 } from "path";
|
|
3985
|
+
import { Effect as Effect17 } from "effect";
|
|
3986
|
+
|
|
3987
|
+
// src/library/daily-matrix.ts
|
|
3988
|
+
import { join as join8 } from "path";
|
|
3150
3989
|
import { Effect as Effect16 } from "effect";
|
|
3151
3990
|
|
|
3991
|
+
// src/library/daily-native-platform.ts
|
|
3992
|
+
import { execFile as execFile2 } from "child_process";
|
|
3993
|
+
import { win32 } from "path";
|
|
3994
|
+
import { promisify as promisify2 } from "util";
|
|
3995
|
+
function parseWindowsClient(value) {
|
|
3996
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["Version", "BuildNumber", "ProductType", "Architecture"]) || typeof value.BuildNumber !== "string" || !/^\d{5}$/.test(value.BuildNumber) || value.Version !== `10.0.${value.BuildNumber}` || value.ProductType !== 1 || !Array.isArray(value.Architecture) || value.Architecture.length === 0 || !value.Architecture.every((v) => v === 9))
|
|
3997
|
+
throw new Error("Windows native qualification requires an x64 client workstation");
|
|
3998
|
+
const build = Number(value.BuildNumber);
|
|
3999
|
+
if (build === 19045)
|
|
4000
|
+
return { release: "10", build, productType: 1 };
|
|
4001
|
+
if ([22000, 22621, 22631, 26100, 26200, 28000].includes(build))
|
|
4002
|
+
return { release: "11", build, productType: 1 };
|
|
4003
|
+
throw new Error("Windows native qualification requires a reviewed Windows 10 or 11 build");
|
|
4004
|
+
}
|
|
4005
|
+
function matchesWindowsClient(value, release) {
|
|
4006
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["release", "build", "productType"]))
|
|
4007
|
+
return false;
|
|
4008
|
+
try {
|
|
4009
|
+
return value.release === release && parseWindowsClient({
|
|
4010
|
+
Version: `10.0.${value.build}`,
|
|
4011
|
+
BuildNumber: String(value.build),
|
|
4012
|
+
ProductType: value.productType,
|
|
4013
|
+
Architecture: [9]
|
|
4014
|
+
}).release === release && typeof value.build === "number";
|
|
4015
|
+
} catch {
|
|
4016
|
+
return false;
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
var run = promisify2(execFile2);
|
|
4020
|
+
var macToolOptions = {
|
|
4021
|
+
timeout: 30000,
|
|
4022
|
+
maxBuffer: 64 * 1024,
|
|
4023
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" }
|
|
4024
|
+
};
|
|
4025
|
+
async function assertNativeMacHost(arch) {
|
|
4026
|
+
const { stdout } = await run("/usr/sbin/sysctl", ["-in", "hw.optional.arm64"], macToolOptions);
|
|
4027
|
+
const value = stdout.trim();
|
|
4028
|
+
if (arch === "arm64" && value !== "1" || arch === "x64" && value !== "0" && value !== "")
|
|
4029
|
+
throw new Error("Daily native check requires matching Mac hardware, not Rosetta");
|
|
4030
|
+
}
|
|
4031
|
+
var windowsRoot = (env) => {
|
|
4032
|
+
const root = env.SystemRoot;
|
|
4033
|
+
if (!root || !/^[A-Za-z]:\\[A-Za-z0-9 _-]+(?:\\[A-Za-z0-9 _-]+)*$/.test(root))
|
|
4034
|
+
throw new Error("Missing Windows system directory");
|
|
4035
|
+
return root;
|
|
4036
|
+
};
|
|
4037
|
+
var powershell = async (env, script, installer) => {
|
|
4038
|
+
const root = windowsRoot(env);
|
|
4039
|
+
const { stdout } = await run(win32.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
4040
|
+
env: {
|
|
4041
|
+
SystemRoot: root,
|
|
4042
|
+
WINDIR: root,
|
|
4043
|
+
...installer ? { FRAMEWORK_SIGNED_INSTALLER: installer } : {}
|
|
4044
|
+
},
|
|
4045
|
+
timeout: 30000,
|
|
4046
|
+
maxBuffer: 16384,
|
|
4047
|
+
windowsHide: true
|
|
4048
|
+
});
|
|
4049
|
+
return JSON.parse(stdout);
|
|
4050
|
+
};
|
|
4051
|
+
var readWindowsClient = async (env) => parseWindowsClient(await powershell(env, `$ErrorActionPreference='Stop'; $os=Get-CimInstance Win32_OperatingSystem; $cpu=@(Get-CimInstance Win32_Processor | ForEach-Object { [int]$_.Architecture }); @{Version=[string]$os.Version;BuildNumber=[string]$os.BuildNumber;ProductType=[int]$os.ProductType;Architecture=$cpu} | ConvertTo-Json -Compress`));
|
|
4052
|
+
function installerSigningPolicy(config, check) {
|
|
4053
|
+
const value = isRecord(config) && isRecord(config.dailyNativeSigning) ? config.dailyNativeSigning : {};
|
|
4054
|
+
if (check.format === "dmg" && typeof value.macTeamId === "string" && /^[A-Z0-9]{10}$/.test(value.macTeamId))
|
|
4055
|
+
return { kind: "developer-id", teamId: value.macTeamId };
|
|
4056
|
+
if (check.format === "windows-setup" && typeof value.windowsCertificateSha256 === "string" && /^[a-f0-9]{64}$/.test(value.windowsCertificateSha256))
|
|
4057
|
+
return { kind: "authenticode", certificateSha256: value.windowsCertificateSha256 };
|
|
4058
|
+
throw new Error("Daily desktop qualification requires a reviewed native signing identity");
|
|
4059
|
+
}
|
|
4060
|
+
function matchInstallerSigning(value, policy) {
|
|
4061
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["candidate", "baseline"]))
|
|
4062
|
+
return false;
|
|
4063
|
+
return [value.candidate, value.baseline].every((v) => isRecord(v) && hasExactOwnKeys(v, Object.keys(policy)) && Object.entries(policy).every(([key, expected]) => v[key] === expected));
|
|
4064
|
+
}
|
|
4065
|
+
async function verifyInstallerSigning(policy, installer, env) {
|
|
4066
|
+
if (policy.kind === "authenticode") {
|
|
4067
|
+
const value = await powershell(env, `$ErrorActionPreference='Stop'; $s=Get-AuthenticodeSignature -LiteralPath $env:FRAMEWORK_SIGNED_INSTALLER; if ($s.Status -ne 'Valid' -or $s.SignatureType -ne 'Authenticode' -or $null -eq $s.SignerCertificate -or $null -eq $s.TimeStamperCertificate) { throw 'Invalid Authenticode signature or timestamp' }; $sha=[System.Security.Cryptography.SHA256]::Create(); try { ([BitConverter]::ToString($sha.ComputeHash($s.SignerCertificate.RawData))).Replace('-','').ToLowerInvariant() | ConvertTo-Json -Compress } finally { $sha.Dispose() }`, installer);
|
|
4068
|
+
if (value !== policy.certificateSha256)
|
|
4069
|
+
throw new Error("Windows installer signer is not approved");
|
|
4070
|
+
} else {
|
|
4071
|
+
const opts = {
|
|
4072
|
+
timeout: 120000,
|
|
4073
|
+
maxBuffer: 64 * 1024,
|
|
4074
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" }
|
|
4075
|
+
};
|
|
4076
|
+
await run("/usr/bin/codesign", ["--verify", "--strict", installer], opts);
|
|
4077
|
+
const { stderr } = await run("/usr/bin/codesign", ["-dv", "--verbose=4", installer], opts);
|
|
4078
|
+
if (!stderr.split(/\r?\n/).includes(`TeamIdentifier=${policy.teamId}`) || !stderr.split(/\r?\n/).some((line) => /^Authority=Developer ID Application: .+/.test(line)))
|
|
4079
|
+
throw new Error("macOS installer signer is not approved");
|
|
4080
|
+
await run("/usr/bin/xcrun", ["stapler", "validate", installer], opts);
|
|
4081
|
+
const { stdout: assessmentStatus, stderr: assessmentError } = await run("/usr/sbin/spctl", ["--status"], opts);
|
|
4082
|
+
if ((assessmentStatus + assessmentError).trim() !== "assessments enabled")
|
|
4083
|
+
throw new Error("macOS installer qualification requires enabled Gatekeeper assessments");
|
|
4084
|
+
await run("/usr/sbin/spctl", ["--assess", "--type", "open", "--context", "context:primary-signature", installer], opts);
|
|
4085
|
+
}
|
|
4086
|
+
return policy;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
3152
4089
|
// src/library/daily-native-evidence.ts
|
|
3153
|
-
var
|
|
4090
|
+
var digest2 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
|
|
3154
4091
|
var record = (value, keys) => isRecord(value) && hasExactOwnKeys(value, keys);
|
|
3155
4092
|
function assertDailyIdentity(identity) {
|
|
3156
4093
|
if (!isReleaseTag(identity.tag) || !isGitSha(identity.sourceSha) || identity.workflowSha !== identity.sourceSha || typeof identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(identity.runId) || !Number.isSafeInteger(identity.runAttempt) || identity.runAttempt <= 0)
|
|
3157
4094
|
throw new Error("Invalid exact Daily identity");
|
|
3158
4095
|
}
|
|
3159
4096
|
function validArtifact(value) {
|
|
3160
|
-
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 &&
|
|
4097
|
+
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 && digest2(value.digest);
|
|
3161
4098
|
}
|
|
3162
4099
|
function originMatches(value, payloadName) {
|
|
3163
4100
|
if (record(value, ["kind", "sourceSha"]))
|
|
@@ -3182,10 +4119,10 @@ function observationsMatch(value, { identity, check, baselineNames }) {
|
|
|
3182
4119
|
"ready",
|
|
3183
4120
|
"fixtureBefore",
|
|
3184
4121
|
"fixtureAfter"
|
|
3185
|
-
]) && isReleaseTag(upgrade.baselineTag) && versionLessThan(upgrade.baselineTag, identity.tag) && validArtifact(upgrade.baselineAsset) && upgrade.baselineAsset.name === baselineNames(upgrade.baselineTag).installer && originMatches(upgrade.baselineOrigin, baselineNames(upgrade.baselineTag).payload) && upgrade.baselineVersion === upgrade.baselineTag.slice(1) && upgrade.upgradedVersion === version && upgrade.ready === true &&
|
|
4122
|
+
]) && isReleaseTag(upgrade.baselineTag) && versionLessThan(upgrade.baselineTag, identity.tag) && validArtifact(upgrade.baselineAsset) && upgrade.baselineAsset.name === baselineNames(upgrade.baselineTag).installer && originMatches(upgrade.baselineOrigin, baselineNames(upgrade.baselineTag).payload) && upgrade.baselineVersion === upgrade.baselineTag.slice(1) && upgrade.upgradedVersion === version && upgrade.ready === true && digest2(upgrade.fixtureBefore) && upgrade.fixtureAfter === upgrade.fixtureBefore;
|
|
3186
4123
|
}
|
|
3187
4124
|
function validateDailyNativeEvidence(input, schema, context) {
|
|
3188
|
-
const { appId, identity, check, assets } = context;
|
|
4125
|
+
const { appId, identity, check, assets, profile = "desktop-v1", signing } = context;
|
|
3189
4126
|
const [os, arch] = platformTargets[check.platform];
|
|
3190
4127
|
if (!record(input, [
|
|
3191
4128
|
"schema",
|
|
@@ -3201,8 +4138,9 @@ function validateDailyNativeEvidence(input, schema, context) {
|
|
|
3201
4138
|
"format",
|
|
3202
4139
|
"host",
|
|
3203
4140
|
"assets",
|
|
3204
|
-
"observations"
|
|
3205
|
-
|
|
4141
|
+
"observations",
|
|
4142
|
+
...signing ? ["installerSigning"] : []
|
|
4143
|
+
]) || input.schema !== schema || input.appId !== appId || input.profile !== profile || input.tag !== identity.tag || input.sourceSha !== identity.sourceSha || input.workflowSha !== identity.workflowSha || input.runId !== identity.runId || input.runAttempt !== identity.runAttempt || input.check !== check.name || input.platform !== check.platform || input.format !== check.format || !record(input.host, check.windowsClient ? ["os", "arch", "windowsClient"] : ["os", "arch"]) || input.host.os !== os || input.host.arch !== arch || check.windowsClient && !matchesWindowsClient(input.host.windowsClient, check.windowsClient) || signing && !matchInstallerSigning(input.installerSigning, signing) || !Array.isArray(input.assets) || input.assets.length !== assets.length)
|
|
3206
4144
|
throw new Error(`Native receipt identity or result mismatch: ${check.name}`);
|
|
3207
4145
|
for (const expected of assets) {
|
|
3208
4146
|
const matches = input.assets.filter((item) => validArtifact(item) && item.name === expected.name);
|
|
@@ -3211,37 +4149,68 @@ function validateDailyNativeEvidence(input, schema, context) {
|
|
|
3211
4149
|
}
|
|
3212
4150
|
if (!observationsMatch(input.observations, context))
|
|
3213
4151
|
throw new Error(`Missing or invalid native observations: ${check.name}`);
|
|
3214
|
-
return {
|
|
4152
|
+
return {
|
|
4153
|
+
host: {
|
|
4154
|
+
os,
|
|
4155
|
+
arch,
|
|
4156
|
+
...check.windowsClient ? { windowsClient: input.host.windowsClient } : {}
|
|
4157
|
+
},
|
|
4158
|
+
...signing ? { installerSigning: input.installerSigning } : {},
|
|
4159
|
+
observations: input.observations
|
|
4160
|
+
};
|
|
3215
4161
|
}
|
|
3216
4162
|
|
|
3217
4163
|
// src/library/daily-matrix.ts
|
|
3218
4164
|
var desktopDailyProfile = "desktop-v1";
|
|
4165
|
+
var expandedDesktopDailyProfile = "desktop-v2";
|
|
3219
4166
|
var platforms = [
|
|
3220
4167
|
"macos-arm64",
|
|
3221
4168
|
"windows-x64",
|
|
3222
4169
|
"linux-x64"
|
|
3223
4170
|
];
|
|
4171
|
+
var expandedPlatforms = [
|
|
4172
|
+
"macos-arm64",
|
|
4173
|
+
"macos-x64",
|
|
4174
|
+
"windows-x64",
|
|
4175
|
+
"linux-x64",
|
|
4176
|
+
"linux-arm64"
|
|
4177
|
+
];
|
|
3224
4178
|
var receiptLimit = 64 * 1024;
|
|
3225
4179
|
function requireThat(ok, message) {
|
|
3226
4180
|
if (!ok)
|
|
3227
4181
|
throw new Error(message);
|
|
3228
4182
|
}
|
|
3229
4183
|
function planDailyReleaseMatrix(config, tag) {
|
|
3230
|
-
requireThat(isRecord(config) && config.dailyReleaseProfile === desktopDailyProfile && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
4184
|
+
requireThat(isRecord(config) && (config.dailyReleaseProfile === desktopDailyProfile || config.dailyReleaseProfile === expandedDesktopDailyProfile) && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
3231
4185
|
const parsed = parseReleaseConfig(config);
|
|
3232
4186
|
const requirements = parsed.requirements(tag);
|
|
4187
|
+
const profile = config.dailyReleaseProfile;
|
|
4188
|
+
const expanded = profile === expandedDesktopDailyProfile;
|
|
3233
4189
|
const checks = [];
|
|
3234
|
-
|
|
4190
|
+
const primaryAssets = [];
|
|
4191
|
+
for (const platform of expanded ? expandedPlatforms : platforms) {
|
|
3235
4192
|
const pair = requirements.platforms[platform];
|
|
3236
4193
|
requireThat(pair?.length === 2, `Expected installer and updater archive for ${platform}`);
|
|
3237
4194
|
const [installer, archive] = pair;
|
|
3238
|
-
const suffix = platform
|
|
4195
|
+
const suffix = platform.startsWith("macos-") ? ".dmg" : platform === "windows-x64" ? expanded ? "-Setup.exe" : "-Setup.zip" : "-Setup.tar.gz";
|
|
3239
4196
|
requireThat(installer.endsWith(suffix) && archive.endsWith(".tar.zst"), `Unexpected desktop installer or updater format for ${platform}`);
|
|
3240
|
-
const format = platform
|
|
3241
|
-
|
|
4197
|
+
const format = platform.startsWith("macos-") ? "dmg" : platform === "windows-x64" ? "windows-setup" : "portable-linux";
|
|
4198
|
+
primaryAssets.push(installer, archive);
|
|
4199
|
+
if (expanded && platform === "windows-x64") {
|
|
4200
|
+
for (const windowsClient of ["10", "11"])
|
|
4201
|
+
checks.push({
|
|
4202
|
+
name: `installer-${platform}-win${windowsClient}`,
|
|
4203
|
+
platform,
|
|
4204
|
+
format,
|
|
4205
|
+
assets: pair,
|
|
4206
|
+
windowsClient
|
|
4207
|
+
});
|
|
4208
|
+
} else
|
|
4209
|
+
checks.push({ name: `installer-${platform}`, platform, format, assets: pair });
|
|
3242
4210
|
for (const command of parsed.commandArtifacts) {
|
|
3243
4211
|
const name = requirements.commandArtifacts?.[command.kind]?.[platform];
|
|
3244
4212
|
requireThat(name, `Missing command archive for ${platform}`);
|
|
4213
|
+
primaryAssets.push(name);
|
|
3245
4214
|
checks.push({
|
|
3246
4215
|
name: `command-${command.kind}-${platform}`,
|
|
3247
4216
|
platform,
|
|
@@ -3250,25 +4219,27 @@ function planDailyReleaseMatrix(config, tag) {
|
|
|
3250
4219
|
});
|
|
3251
4220
|
}
|
|
3252
4221
|
}
|
|
3253
|
-
const linux
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
assets: [
|
|
3260
|
-
}
|
|
3261
|
-
const names = checks.flatMap((check) => check.assets);
|
|
4222
|
+
for (const linux of expanded ? ["linux-x64", "linux-arm64"] : ["linux-x64"]) {
|
|
4223
|
+
const archive = requirements.platforms[linux][1];
|
|
4224
|
+
const base = archive.slice(0, -".tar.zst".length);
|
|
4225
|
+
const deb = base + ".deb";
|
|
4226
|
+
const appimage = base + ".AppImage";
|
|
4227
|
+
primaryAssets.push(deb, appimage);
|
|
4228
|
+
checks.push({ name: `deb-${linux}`, platform: linux, format: "deb", assets: [deb] }, { name: `appimage-${linux}`, platform: linux, format: "appimage", assets: [appimage] });
|
|
4229
|
+
}
|
|
3262
4230
|
discoveryPolicies(config, tag);
|
|
3263
|
-
const all = [...
|
|
4231
|
+
const all = [...primaryAssets, ...requirements.releaseAssets];
|
|
3264
4232
|
requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
|
|
3265
|
-
return { appId: config.appId, profile
|
|
4233
|
+
return { appId: config.appId, profile, assets: all, checks };
|
|
4234
|
+
}
|
|
4235
|
+
function requiresDailyInstallerSigning(profile, check) {
|
|
4236
|
+
return profile === expandedDesktopDailyProfile && (check.format === "dmg" || check.format === "windows-setup");
|
|
3266
4237
|
}
|
|
3267
4238
|
function priorDailyInstallerNames(config, tag, check) {
|
|
3268
4239
|
const plan = planDailyReleaseMatrix(config, tag);
|
|
3269
4240
|
return {
|
|
3270
4241
|
installer: plan.checks.find((entry) => entry.name === check.name)?.assets[0],
|
|
3271
|
-
payload: plan.checks.find((entry) => entry.
|
|
4242
|
+
payload: plan.checks.find((entry) => entry.platform === check.platform && entry.assets.length === 2)?.assets[1]
|
|
3272
4243
|
};
|
|
3273
4244
|
}
|
|
3274
4245
|
function exactDirectory(root, names) {
|
|
@@ -3324,11 +4295,13 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
|
|
|
3324
4295
|
yield* exactDirectory(receipts, matrix.checks.map((c) => c.name + ".json"));
|
|
3325
4296
|
const inventory = new Map;
|
|
3326
4297
|
for (const name of matrix.assets)
|
|
3327
|
-
inventory.set(name, yield* fileIdentityEffect(
|
|
4298
|
+
inventory.set(name, yield* fileIdentityEffect(join8(artifacts, name), name));
|
|
3328
4299
|
for (const check of matrix.checks) {
|
|
3329
|
-
const r = yield* readNativeReceipt(
|
|
4300
|
+
const r = yield* readNativeReceipt(join8(receipts, check.name + ".json"), check.name);
|
|
3330
4301
|
yield* attempt(() => validateDailyNativeEvidence(r, "framework/daily-native-receipt/v2", {
|
|
3331
4302
|
appId: matrix.appId,
|
|
4303
|
+
profile: matrix.profile,
|
|
4304
|
+
signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
|
|
3332
4305
|
identity,
|
|
3333
4306
|
check,
|
|
3334
4307
|
assets: check.assets.map((name) => inventory.get(name)),
|
|
@@ -3345,10 +4318,136 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
|
|
|
3345
4318
|
function verifyDailyReleaseMatrix(options) {
|
|
3346
4319
|
return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
|
|
3347
4320
|
}
|
|
4321
|
+
|
|
4322
|
+
// src/library/daily-batch-inspection.ts
|
|
4323
|
+
var inspectDailyBatchEffect = (options) => Effect17.gen(function* () {
|
|
4324
|
+
const git = yield* ReleaseGit;
|
|
4325
|
+
const { identity, configPath, artifacts, receipts } = options;
|
|
4326
|
+
yield* attempt(() => assertDailyIdentity(identity));
|
|
4327
|
+
if (configPath.length > 200 || !/^[A-Za-z0-9._/-]+\.json$/.test(configPath) || configPath.startsWith("/") || configPath.split("/").some((part) => !part || part === "." || part === ".."))
|
|
4328
|
+
return yield* fail("Invalid committed release configuration path");
|
|
4329
|
+
if ((yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
|
|
4330
|
+
return yield* fail("Daily inspection checkout does not match the source commit");
|
|
4331
|
+
const tree = yield* step(() => git.run(["--no-replace-objects", "ls-tree", identity.sourceSha, "--", configPath]));
|
|
4332
|
+
const match = /^100(?:644|755) blob ([a-f0-9]{40})\t([^\n]+)$/.exec(tree);
|
|
4333
|
+
if (!match || match[2] !== configPath)
|
|
4334
|
+
return yield* fail("Daily release configuration is not a committed regular file");
|
|
4335
|
+
const configBlob = match[1];
|
|
4336
|
+
const raw = yield* step(() => git.run(["--no-replace-objects", "show", `${identity.sourceSha}:${configPath}`]));
|
|
4337
|
+
if (Buffer.byteLength(raw) > 1024 * 1024)
|
|
4338
|
+
return yield* fail("Daily release configuration is too large");
|
|
4339
|
+
const config = yield* attempt(() => JSON.parse(raw));
|
|
4340
|
+
const parsed = yield* attempt(() => parseReleaseConfig(config));
|
|
4341
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
4342
|
+
const receiptNames = matrix.checks.map((check) => `${check.name}.json`);
|
|
4343
|
+
const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
|
|
4344
|
+
const verified = yield* verifyDailyReleaseMatrixEffect({
|
|
4345
|
+
config,
|
|
4346
|
+
identity,
|
|
4347
|
+
artifacts,
|
|
4348
|
+
receipts
|
|
4349
|
+
});
|
|
4350
|
+
const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
|
|
4351
|
+
const after = yield* verifyDailyReleaseMatrixEffect({ config, identity, artifacts, receipts });
|
|
4352
|
+
if (JSON.stringify(receiptHashes) !== JSON.stringify(afterReceipts) || JSON.stringify(verified.assets) !== JSON.stringify(after.assets) || (yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
|
|
4353
|
+
return yield* fail("Daily inputs changed during inspection");
|
|
4354
|
+
return {
|
|
4355
|
+
schema: "framework/daily-batch-inspection/v1",
|
|
4356
|
+
identity: { appId: matrix.appId, feedApp: parsed.feed.app, ...identity },
|
|
4357
|
+
config: { path: configPath, gitBlob: configBlob },
|
|
4358
|
+
artifacts: verified.assets,
|
|
4359
|
+
receipts: receiptHashes,
|
|
4360
|
+
promotionAuthorized: false,
|
|
4361
|
+
unverified: [
|
|
4362
|
+
"windows-10-and-11",
|
|
4363
|
+
"independent-clean-environments",
|
|
4364
|
+
"signatures-and-notarization",
|
|
4365
|
+
"linux-reproducibility",
|
|
4366
|
+
"protected-source-and-workflow"
|
|
4367
|
+
]
|
|
4368
|
+
};
|
|
4369
|
+
});
|
|
4370
|
+
var inspectDailyBatch = (options) => runReleaseLibrary(provideLibraryPorts()(inspectDailyBatchEffect(options)));
|
|
4371
|
+
// src/library/daily-batch-s3.ts
|
|
4372
|
+
import { GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
4373
|
+
import { Readable } from "stream";
|
|
4374
|
+
function createDailyBatchR2Client(accountId, credentials) {
|
|
4375
|
+
if (!/^[a-f0-9]{32}$/.test(accountId))
|
|
4376
|
+
throw new Error("Invalid R2 account ID");
|
|
4377
|
+
return new S3Client({
|
|
4378
|
+
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
|
|
4379
|
+
region: "auto",
|
|
4380
|
+
credentials,
|
|
4381
|
+
forcePathStyle: true,
|
|
4382
|
+
maxAttempts: 1,
|
|
4383
|
+
requestChecksumCalculation: "WHEN_REQUIRED",
|
|
4384
|
+
responseChecksumValidation: "WHEN_REQUIRED"
|
|
4385
|
+
});
|
|
4386
|
+
}
|
|
4387
|
+
function createDailyBatchS3Transport(client, bucket) {
|
|
4388
|
+
if (!/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/.test(bucket) || bucket.includes(".."))
|
|
4389
|
+
throw new Error("Invalid R2 bucket");
|
|
4390
|
+
return async ({ method, key, headers, body }) => {
|
|
4391
|
+
if (await client.config.maxAttempts() !== 1)
|
|
4392
|
+
throw new Error("S3 retries must be disabled");
|
|
4393
|
+
const allowed = new Set([
|
|
4394
|
+
"if-match",
|
|
4395
|
+
"if-none-match",
|
|
4396
|
+
"content-length",
|
|
4397
|
+
"content-type",
|
|
4398
|
+
"cache-control"
|
|
4399
|
+
]);
|
|
4400
|
+
if (Object.keys(headers).some((name) => !allowed.has(name)))
|
|
4401
|
+
throw new Error("Unexpected S3 header");
|
|
4402
|
+
let stream;
|
|
4403
|
+
try {
|
|
4404
|
+
if (method === "GET") {
|
|
4405
|
+
if (body || Object.keys(headers).length)
|
|
4406
|
+
throw new Error("Invalid S3 GET");
|
|
4407
|
+
const result = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
|
|
4408
|
+
if (!result.Body || !(Symbol.asyncIterator in result.Body))
|
|
4409
|
+
throw new Error("S3 body is not a stream");
|
|
4410
|
+
return {
|
|
4411
|
+
status: result.$metadata.httpStatusCode ?? 0,
|
|
4412
|
+
headers: { etag: result.ETag },
|
|
4413
|
+
body: result.Body
|
|
4414
|
+
};
|
|
4415
|
+
}
|
|
4416
|
+
const length = Number(headers["content-length"]);
|
|
4417
|
+
if (!body || !Number.isSafeInteger(length) || length < 1 || String(length) !== headers["content-length"])
|
|
4418
|
+
throw new Error("Invalid S3 upload length");
|
|
4419
|
+
stream = Readable.from(body);
|
|
4420
|
+
const result = await client.send(new PutObjectCommand({
|
|
4421
|
+
Bucket: bucket,
|
|
4422
|
+
Key: key,
|
|
4423
|
+
Body: stream,
|
|
4424
|
+
ContentLength: length,
|
|
4425
|
+
ContentType: headers["content-type"],
|
|
4426
|
+
CacheControl: headers["cache-control"],
|
|
4427
|
+
IfMatch: headers["if-match"],
|
|
4428
|
+
IfNoneMatch: headers["if-none-match"]
|
|
4429
|
+
}));
|
|
4430
|
+
if (!stream.readableEnded)
|
|
4431
|
+
throw new Error("S3 upload body not fully consumed");
|
|
4432
|
+
return {
|
|
4433
|
+
status: result.$metadata.httpStatusCode ?? 0,
|
|
4434
|
+
headers: { etag: result.ETag },
|
|
4435
|
+
body: empty()
|
|
4436
|
+
};
|
|
4437
|
+
} catch (error) {
|
|
4438
|
+
stream?.destroy();
|
|
4439
|
+
const status = error?.$metadata?.httpStatusCode;
|
|
4440
|
+
if (status === 404 || status === 412)
|
|
4441
|
+
return { status, headers: {}, body: empty() };
|
|
4442
|
+
throw error;
|
|
4443
|
+
}
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
async function* empty() {}
|
|
3348
4447
|
// src/library/daily-native-receipt.ts
|
|
3349
|
-
import { join as
|
|
3350
|
-
import { Effect as
|
|
3351
|
-
var createDailyNativeReceiptEffect = (options, worker) =>
|
|
4448
|
+
import { join as join10 } from "path";
|
|
4449
|
+
import { Effect as Effect18 } from "effect";
|
|
4450
|
+
var createDailyNativeReceiptEffect = (options, worker, observedSigning) => Effect18.gen(function* () {
|
|
3352
4451
|
const { config, identity, artifacts, checkName, report } = options;
|
|
3353
4452
|
yield* attempt(() => assertDailyIdentity(identity));
|
|
3354
4453
|
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
@@ -3358,18 +4457,27 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
|
|
|
3358
4457
|
const [os, arch] = platformTargets[check.platform];
|
|
3359
4458
|
if (worker.os !== os || worker.arch !== arch)
|
|
3360
4459
|
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
4460
|
+
const signing = requiresDailyInstallerSigning(matrix.profile, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
|
|
4461
|
+
if (signing && !observedSigning)
|
|
4462
|
+
return yield* fail("Expanded Daily installers require proof from the live native observer");
|
|
3361
4463
|
const fs = yield* ReleaseFs;
|
|
3362
4464
|
const dir = yield* step(() => fs.lstat(artifacts));
|
|
3363
4465
|
if (!dir.isDirectory() || dir.isSymbolicLink())
|
|
3364
4466
|
return yield* fail("Expected real native artifact directory");
|
|
3365
|
-
const assets = yield*
|
|
4467
|
+
const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join10(artifacts, name), name));
|
|
3366
4468
|
const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
|
|
3367
4469
|
appId: matrix.appId,
|
|
4470
|
+
profile: matrix.profile,
|
|
4471
|
+
signing,
|
|
3368
4472
|
identity,
|
|
3369
4473
|
check,
|
|
3370
4474
|
assets,
|
|
3371
4475
|
baselineNames: (tag) => priorDailyInstallerNames(config, tag, check)
|
|
3372
4476
|
}));
|
|
4477
|
+
if (check.windowsClient && (!worker.windowsClient || worker.windowsClient.release !== evidence.host.windowsClient?.release || worker.windowsClient.build !== evidence.host.windowsClient?.build))
|
|
4478
|
+
return yield* fail("Native receipt does not match the measured Windows host");
|
|
4479
|
+
if (signing && JSON.stringify(observedSigning) !== JSON.stringify(evidence.installerSigning))
|
|
4480
|
+
return yield* fail("Native receipt does not match observed installer signing");
|
|
3373
4481
|
if ("upgrade" in evidence.observations) {
|
|
3374
4482
|
if (!options.baselineArtifacts)
|
|
3375
4483
|
return yield* fail("Daily desktop check requires the exact baseline installer");
|
|
@@ -3380,7 +4488,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
|
|
|
3380
4488
|
const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
|
|
3381
4489
|
const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
|
|
3382
4490
|
for (const expected of proofFiles) {
|
|
3383
|
-
const observed = yield* fileIdentityEffect(
|
|
4491
|
+
const observed = yield* fileIdentityEffect(join10(baselineDirectory, expected.name), expected.name);
|
|
3384
4492
|
if (observed.size !== expected.size || observed.digest !== expected.digest)
|
|
3385
4493
|
return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
|
|
3386
4494
|
}
|
|
@@ -3403,6 +4511,178 @@ function createDailyNativeReceipt(options) {
|
|
|
3403
4511
|
arch: process.arch
|
|
3404
4512
|
})));
|
|
3405
4513
|
}
|
|
4514
|
+
// src/library/linux-reproducibility.ts
|
|
4515
|
+
import { createHash as createHash11 } from "crypto";
|
|
4516
|
+
import { lstat as lstat6, readFile as readFile6, readdir as readdir4, realpath } from "fs/promises";
|
|
4517
|
+
import { isAbsolute as isAbsolute2, join as join11, resolve as resolve6 } from "path";
|
|
4518
|
+
|
|
4519
|
+
// src/library/linux-package-architecture.ts
|
|
4520
|
+
var linuxPackageArchitectures = {
|
|
4521
|
+
x64: { platform: "linux-x64", debian: "amd64", appImage: "x86_64", elfMachine: 62 },
|
|
4522
|
+
arm64: { platform: "linux-arm64", debian: "arm64", appImage: "aarch64", elfMachine: 183 }
|
|
4523
|
+
};
|
|
4524
|
+
function isLinuxPackageArchitecture(value) {
|
|
4525
|
+
return value === "x64" || value === "arm64";
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
// src/library/linux-reproducibility.ts
|
|
4529
|
+
var sha256 = /^[a-f0-9]{64}$/;
|
|
4530
|
+
var digest3 = /^sha256:[a-f0-9]{64}$/;
|
|
4531
|
+
var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
|
|
4532
|
+
var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
4533
|
+
var filename = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
|
|
4534
|
+
function check2(ok, message) {
|
|
4535
|
+
if (!ok)
|
|
4536
|
+
throw new Error(message);
|
|
4537
|
+
}
|
|
4538
|
+
async function regular(path) {
|
|
4539
|
+
check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
|
|
4540
|
+
const stat = await lstat6(path);
|
|
4541
|
+
check2(stat.isFile() && !stat.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real regular input file");
|
|
4542
|
+
check2(Number.isSafeInteger(stat.size) && stat.size > 0, "Invalid input file size");
|
|
4543
|
+
const result = await hashFileAt(path, stat, "Input changed during comparison");
|
|
4544
|
+
const after = await lstat6(path);
|
|
4545
|
+
check2(after.isFile() && !after.isSymbolicLink() && after.dev === stat.dev && after.ino === stat.ino && after.size === stat.size && after.mtimeMs === stat.mtimeMs && after.ctimeMs === stat.ctimeMs, "Input changed during comparison");
|
|
4546
|
+
return { ...result, dev: stat.dev, ino: stat.ino };
|
|
4547
|
+
}
|
|
4548
|
+
async function outputDirectory(path, expected) {
|
|
4549
|
+
check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
|
|
4550
|
+
const info = await lstat6(path);
|
|
4551
|
+
check2(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
|
|
4552
|
+
const entries = await readdir4(path, { withFileTypes: true });
|
|
4553
|
+
const names = new Set(expected);
|
|
4554
|
+
check2(names.size === expected.length && entries.length === names.size && entries.every((entry) => entry.isFile() && names.has(entry.name)), "Build output must contain exactly the DEB, AppImage and producer receipt");
|
|
4555
|
+
return { path, dev: info.dev, ino: info.ino, mtimeMs: info.mtimeMs, ctimeMs: info.ctimeMs };
|
|
4556
|
+
}
|
|
4557
|
+
async function directoryUnchanged(before) {
|
|
4558
|
+
const after = await lstat6(before.path);
|
|
4559
|
+
check2(after.isDirectory() && !after.isSymbolicLink() && await realpath(before.path) === resolve6(before.path) && after.dev === before.dev && after.ino === before.ino && after.mtimeMs === before.mtimeMs && after.ctimeMs === before.ctimeMs, "Build output directory changed during comparison");
|
|
4560
|
+
}
|
|
4561
|
+
function sameIdentity(a, b) {
|
|
4562
|
+
return a.tag === b.tag && a.sourceSha === b.sourceSha && a.workflowSha === b.workflowSha && a.runId === b.runId && a.runAttempt === b.runAttempt;
|
|
4563
|
+
}
|
|
4564
|
+
async function compareLinuxReproducibility(rawInput) {
|
|
4565
|
+
const input = structuredClone(rawInput);
|
|
4566
|
+
check2(isRecord(input) && hasExactOwnKeys(input, [
|
|
4567
|
+
...Object.hasOwn(input, "architecture") ? ["architecture"] : [],
|
|
4568
|
+
"config",
|
|
4569
|
+
"identity",
|
|
4570
|
+
"sourceDateEpoch",
|
|
4571
|
+
"archive",
|
|
4572
|
+
"imageReference",
|
|
4573
|
+
"toolchainDigest",
|
|
4574
|
+
"runs"
|
|
4575
|
+
]) && isRecord(input.identity) && hasExactOwnKeys(input.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && isRecord(input.archive) && hasExactOwnKeys(input.archive, ["size", "sha256"]), "Invalid Linux comparison input");
|
|
4576
|
+
const architecture = Object.hasOwn(input, "architecture") ? input.architecture : "x64";
|
|
4577
|
+
check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
|
|
4578
|
+
const target = linuxPackageArchitectures[architecture];
|
|
4579
|
+
assertDailyIdentity(input.identity);
|
|
4580
|
+
check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha256.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest3.test(input.toolchainDigest), "Invalid protected Linux build identity");
|
|
4581
|
+
check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
|
|
4582
|
+
const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
|
|
4583
|
+
const archiveName = requirements.platforms[target.platform]?.[1];
|
|
4584
|
+
check2(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
|
|
4585
|
+
const stem = archiveName.slice(0, -".tar.zst".length);
|
|
4586
|
+
const artifacts = [`${stem}.deb`, `${stem}.AppImage`];
|
|
4587
|
+
const outputs = [...artifacts, "linux-format-build.json"];
|
|
4588
|
+
check2(artifacts.every((name) => filename.test(name)) && new Set(outputs).size === outputs.length, "Invalid configured Linux output names");
|
|
4589
|
+
check2(Array.isArray(input.runs) && input.runs.length === 2, "Exactly two build runs required");
|
|
4590
|
+
for (const run of input.runs) {
|
|
4591
|
+
check2(isRecord(run) && hasExactOwnKeys(run, [
|
|
4592
|
+
"identity",
|
|
4593
|
+
"appId",
|
|
4594
|
+
"sourceDateEpoch",
|
|
4595
|
+
"jobId",
|
|
4596
|
+
"platform",
|
|
4597
|
+
"imageReference",
|
|
4598
|
+
"toolchainDigest",
|
|
4599
|
+
"archive",
|
|
4600
|
+
"output"
|
|
4601
|
+
]) && isRecord(run.identity) && hasExactOwnKeys(run.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && sameIdentity(run.identity, input.identity) && run.appId === input.config.appId && run.sourceDateEpoch === input.sourceDateEpoch && typeof run.jobId === "string" && identifier.test(run.jobId) && run.platform === `linux-${target.appImage}` && run.imageReference === input.imageReference && run.toolchainDigest === input.toolchainDigest && typeof run.archive === "string" && typeof run.output === "string", "Linux build identity mismatch");
|
|
4602
|
+
}
|
|
4603
|
+
const first = input.runs[0];
|
|
4604
|
+
const second = input.runs[1];
|
|
4605
|
+
check2(first.jobId !== second.jobId, "Build jobs must be distinct");
|
|
4606
|
+
const firstDir = await outputDirectory(first.output, outputs);
|
|
4607
|
+
const secondDir = await outputDirectory(second.output, outputs);
|
|
4608
|
+
check2(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
|
|
4609
|
+
const firstArchive = await regular(first.archive);
|
|
4610
|
+
const secondArchive = await regular(second.archive);
|
|
4611
|
+
for (const archive of [firstArchive, secondArchive])
|
|
4612
|
+
check2(archive.size === input.archive.size && archive.sha256 === input.archive.sha256, "Build archive does not match the independently verified input");
|
|
4613
|
+
check2(firstArchive.dev !== secondArchive.dev || firstArchive.ino !== secondArchive.ino, "Build archive copies must be distinct");
|
|
4614
|
+
const observed = [
|
|
4615
|
+
{ path: first.archive, file: firstArchive },
|
|
4616
|
+
{ path: second.archive, file: secondArchive }
|
|
4617
|
+
];
|
|
4618
|
+
const seen = new Set([
|
|
4619
|
+
`${firstArchive.dev}:${firstArchive.ino}`,
|
|
4620
|
+
`${secondArchive.dev}:${secondArchive.ino}`
|
|
4621
|
+
]);
|
|
4622
|
+
const result = [];
|
|
4623
|
+
for (const name of artifacts) {
|
|
4624
|
+
const left = await regular(join11(first.output, name));
|
|
4625
|
+
const right = await regular(join11(second.output, name));
|
|
4626
|
+
for (const file of [left, right]) {
|
|
4627
|
+
const key = `${file.dev}:${file.ino}`;
|
|
4628
|
+
check2(!seen.has(key), "Build inputs and outputs must be independent files");
|
|
4629
|
+
seen.add(key);
|
|
4630
|
+
}
|
|
4631
|
+
observed.push({ path: join11(first.output, name), file: left });
|
|
4632
|
+
observed.push({ path: join11(second.output, name), file: right });
|
|
4633
|
+
check2(left.size === right.size && left.sha256 === right.sha256, `Linux build differs: ${name}`);
|
|
4634
|
+
result.push({ name, size: left.size, sha256: left.sha256 });
|
|
4635
|
+
}
|
|
4636
|
+
for (const run of input.runs) {
|
|
4637
|
+
const path = join11(run.output, "linux-format-build.json");
|
|
4638
|
+
const file = await regular(path);
|
|
4639
|
+
const key = `${file.dev}:${file.ino}`;
|
|
4640
|
+
check2(!seen.has(key), "Build inputs and outputs must be independent files");
|
|
4641
|
+
seen.add(key);
|
|
4642
|
+
observed.push({ path, file });
|
|
4643
|
+
check2(file.size <= 65536, "Producer receipt is too large");
|
|
4644
|
+
const bytes = await readFile6(path);
|
|
4645
|
+
check2(bytes.length === file.size && createHash11("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
|
|
4646
|
+
let receipt;
|
|
4647
|
+
try {
|
|
4648
|
+
receipt = JSON.parse(bytes.toString("utf8"));
|
|
4649
|
+
} catch {
|
|
4650
|
+
throw new Error("Invalid producer receipt");
|
|
4651
|
+
}
|
|
4652
|
+
check2(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
|
|
4653
|
+
const receiptArtifacts = receipt.artifacts;
|
|
4654
|
+
const workflowBound = ["workflowSha", "runId", "runAttempt"].some((field) => Object.hasOwn(receipt, field));
|
|
4655
|
+
check2((architecture === "x64" || workflowBound) && (!workflowBound || receipt.workflowSha === input.identity.workflowSha && receipt.runId === input.identity.runId && receipt.runAttempt === input.identity.runAttempt) && hasExactOwnKeys(receipt, [
|
|
4656
|
+
...workflowBound ? ["workflowSha", "runId", "runAttempt"] : [],
|
|
4657
|
+
"schema",
|
|
4658
|
+
"tag",
|
|
4659
|
+
"sourceSha",
|
|
4660
|
+
"sourceDateEpoch",
|
|
4661
|
+
"platform",
|
|
4662
|
+
"updateArchiveSha256",
|
|
4663
|
+
"artifacts"
|
|
4664
|
+
]) && receipt.schema === "linux-package-formats/v1" && receipt.tag === input.identity.tag && receipt.sourceSha === input.identity.sourceSha && receipt.sourceDateEpoch === input.sourceDateEpoch && receipt.platform === target.platform && receipt.updateArchiveSha256 === input.archive.sha256 && receiptArtifacts.length === result.length && result.every((expected) => receiptArtifacts.some((item) => isRecord(item) && hasExactOwnKeys(item, ["name", "size", "sha256"]) && item.name === expected.name && item.size === expected.size && item.sha256 === expected.sha256)), "Producer receipt does not match the checked inputs and outputs");
|
|
4665
|
+
}
|
|
4666
|
+
for (const previous of observed) {
|
|
4667
|
+
const current = await regular(previous.path);
|
|
4668
|
+
check2(current.dev === previous.file.dev && current.ino === previous.file.ino && current.size === previous.file.size && current.sha256 === previous.file.sha256, "Input changed during comparison");
|
|
4669
|
+
}
|
|
4670
|
+
await directoryUnchanged(firstDir);
|
|
4671
|
+
await directoryUnchanged(secondDir);
|
|
4672
|
+
return {
|
|
4673
|
+
schema: "framework/linux-format-byte-comparison/v1",
|
|
4674
|
+
qualified: false,
|
|
4675
|
+
platform: target.platform,
|
|
4676
|
+
appId: input.config.appId,
|
|
4677
|
+
identity: input.identity,
|
|
4678
|
+
sourceDateEpoch: input.sourceDateEpoch,
|
|
4679
|
+
archive: input.archive,
|
|
4680
|
+
imageReference: input.imageReference,
|
|
4681
|
+
toolchainDigest: input.toolchainDigest,
|
|
4682
|
+
jobs: input.runs.map((run) => ({ jobId: run.jobId })),
|
|
4683
|
+
artifacts: result
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
3406
4686
|
// src/library/macos-dmg.ts
|
|
3407
4687
|
import { execFileSync } from "child_process";
|
|
3408
4688
|
import {
|
|
@@ -3414,8 +4694,8 @@ import {
|
|
|
3414
4694
|
rmSync,
|
|
3415
4695
|
symlinkSync
|
|
3416
4696
|
} from "fs";
|
|
3417
|
-
import { basename as basename4, dirname, join as
|
|
3418
|
-
import { Context as Context2, Effect as
|
|
4697
|
+
import { basename as basename4, dirname, join as join12, resolve as resolve7 } from "path";
|
|
4698
|
+
import { Context as Context2, Effect as Effect19 } from "effect";
|
|
3419
4699
|
|
|
3420
4700
|
// ../../src/release/macos-dmg.ts
|
|
3421
4701
|
var MIB = 1024 * 1024;
|
|
@@ -3446,7 +4726,7 @@ function treeSize(root) {
|
|
|
3446
4726
|
logicalBytes += info.size;
|
|
3447
4727
|
else if (info.isDirectory())
|
|
3448
4728
|
for (const name of readdirSync(path))
|
|
3449
|
-
pending.push(
|
|
4729
|
+
pending.push(join12(path, name));
|
|
3450
4730
|
else if (!info.isSymbolicLink())
|
|
3451
4731
|
throw new Error("Unsupported disk image entry");
|
|
3452
4732
|
if (!Number.isSafeInteger(logicalBytes))
|
|
@@ -3454,29 +4734,29 @@ function treeSize(root) {
|
|
|
3454
4734
|
}
|
|
3455
4735
|
return { logicalBytes, entries };
|
|
3456
4736
|
}
|
|
3457
|
-
var verifyImageEffect = (image) =>
|
|
4737
|
+
var verifyImageEffect = (image) => Effect19.gen(function* () {
|
|
3458
4738
|
const host = yield* MacosHost;
|
|
3459
4739
|
for (let tries = 1;; tries++) {
|
|
3460
|
-
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(
|
|
4740
|
+
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect19.as(true), Effect19.catchIf(() => tries < 6, () => Effect19.succeed(false)));
|
|
3461
4741
|
if (verified)
|
|
3462
4742
|
return;
|
|
3463
4743
|
host.wait(5000 * 2 ** (tries - 1));
|
|
3464
4744
|
}
|
|
3465
4745
|
});
|
|
3466
|
-
var createMacosDmgEffect = (options) =>
|
|
4746
|
+
var createMacosDmgEffect = (options) => Effect19.gen(function* () {
|
|
3467
4747
|
const host = yield* MacosHost;
|
|
3468
4748
|
if (host.platform !== "darwin")
|
|
3469
4749
|
return yield* fail("Disk image creation requires macOS");
|
|
3470
4750
|
assertPortableAppName(options.appName);
|
|
3471
|
-
const app =
|
|
4751
|
+
const app = resolve7(options.appPath), output = resolve7(options.outputPath);
|
|
3472
4752
|
const info = yield* attempt(() => lstatSync(app));
|
|
3473
4753
|
if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
|
|
3474
4754
|
return yield* fail("Invalid disk image paths");
|
|
3475
|
-
const staging = yield*
|
|
3476
|
-
const payload =
|
|
4755
|
+
const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(join12(dirname(output), ".framework-dmg-"))), (path) => Effect19.sync(() => rmSync(path, { recursive: true, force: true })));
|
|
4756
|
+
const payload = join12(staging, "payload"), image = join12(staging, "result.dmg");
|
|
3477
4757
|
yield* attempt(() => mkdirSync(payload));
|
|
3478
|
-
yield* attempt(() => host.run("/usr/bin/ditto", [app,
|
|
3479
|
-
yield* attempt(() => symlinkSync("/Applications",
|
|
4758
|
+
yield* attempt(() => host.run("/usr/bin/ditto", [app, join12(payload, basename4(app))]));
|
|
4759
|
+
yield* attempt(() => symlinkSync("/Applications", join12(payload, "Applications")));
|
|
3480
4760
|
const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
|
|
3481
4761
|
yield* attempt(() => host.run("/usr/bin/hdiutil", [
|
|
3482
4762
|
"create",
|
|
@@ -3493,36 +4773,36 @@ var createMacosDmgEffect = (options) => Effect18.gen(function* () {
|
|
|
3493
4773
|
yield* verifyImageEffect(image);
|
|
3494
4774
|
yield* attempt(() => linkSync(image, output));
|
|
3495
4775
|
return { capacityMiB };
|
|
3496
|
-
}).pipe(
|
|
4776
|
+
}).pipe(Effect19.scoped);
|
|
3497
4777
|
function verifyImage(image, io = liveHost) {
|
|
3498
|
-
runReleaseLibrarySync(verifyImageEffect(image).pipe(
|
|
4778
|
+
runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect19.provideService(MacosHost, {
|
|
3499
4779
|
run: (command, args) => io.run(command, args),
|
|
3500
4780
|
wait: (milliseconds) => io.wait(milliseconds),
|
|
3501
4781
|
platform: process.platform
|
|
3502
4782
|
})));
|
|
3503
4783
|
}
|
|
3504
4784
|
function createMacosDmg(options) {
|
|
3505
|
-
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(
|
|
4785
|
+
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect19.provideService(MacosHost, liveHost)));
|
|
3506
4786
|
}
|
|
3507
4787
|
// src/library/qualification-run.ts
|
|
3508
|
-
import { Effect as
|
|
4788
|
+
import { Effect as Effect22 } from "effect";
|
|
3509
4789
|
|
|
3510
4790
|
// src/library/local-release.ts
|
|
3511
|
-
import { createHash as
|
|
4791
|
+
import { createHash as createHash13 } from "crypto";
|
|
3512
4792
|
import { constants as constants3 } from "fs";
|
|
3513
|
-
import { dirname as dirname2, join as
|
|
3514
|
-
import { Cause as Cause2, Effect as
|
|
4793
|
+
import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
|
|
4794
|
+
import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
|
|
3515
4795
|
|
|
3516
4796
|
// ../../src/native/native-rename.ts
|
|
3517
4797
|
import { randomUUID } from "crypto";
|
|
3518
|
-
import { mkdir as mkdir3, readFile as
|
|
4798
|
+
import { mkdir as mkdir3, readFile as readFile7, rm as rm4, writeFile as writeFile4 } from "fs/promises";
|
|
3519
4799
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
3520
|
-
import { join as
|
|
4800
|
+
import { join as join13 } from "path";
|
|
3521
4801
|
|
|
3522
4802
|
// ../../src/native/canonical-path.ts
|
|
3523
|
-
import { isAbsolute as
|
|
4803
|
+
import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
|
|
3524
4804
|
function isCanonicalPath(value) {
|
|
3525
|
-
return typeof value === "string" &&
|
|
4805
|
+
return typeof value === "string" && isAbsolute3(value) && resolve8(value) === value && !value.includes("\x00");
|
|
3526
4806
|
}
|
|
3527
4807
|
|
|
3528
4808
|
// ../../src/native/native-rename.ts
|
|
@@ -3596,8 +4876,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3596
4876
|
if (!isCanonicalPath(parent))
|
|
3597
4877
|
throw new Error("Invalid directory exchange probe parent");
|
|
3598
4878
|
const id = randomUUID();
|
|
3599
|
-
const first =
|
|
3600
|
-
const second =
|
|
4879
|
+
const first = join13(parent, `.framework-exchange-probe-${id}-a`);
|
|
4880
|
+
const second = join13(parent, `.framework-exchange-probe-${id}-b`);
|
|
3601
4881
|
const marker = "exchange-probe";
|
|
3602
4882
|
const firstValue = `${id}:first`;
|
|
3603
4883
|
const secondValue = `${id}:second`;
|
|
@@ -3608,21 +4888,21 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3608
4888
|
firstCreated = true;
|
|
3609
4889
|
await mkdir3(second, { mode: 448 });
|
|
3610
4890
|
secondCreated = true;
|
|
3611
|
-
await
|
|
3612
|
-
await
|
|
4891
|
+
await writeFile4(join13(first, marker), firstValue, { flag: "wx", mode: 384 });
|
|
4892
|
+
await writeFile4(join13(second, marker), secondValue, { flag: "wx", mode: 384 });
|
|
3613
4893
|
exchange(first, second);
|
|
3614
4894
|
const [firstAfter, secondAfter] = await Promise.all([
|
|
3615
|
-
|
|
3616
|
-
|
|
4895
|
+
readFile7(join13(first, marker), "utf8"),
|
|
4896
|
+
readFile7(join13(second, marker), "utf8")
|
|
3617
4897
|
]);
|
|
3618
4898
|
if (firstAfter !== secondValue || secondAfter !== firstValue)
|
|
3619
4899
|
throw new Error("Directory exchange did not exchange both probe trees");
|
|
3620
4900
|
} finally {
|
|
3621
4901
|
const cleanup = [];
|
|
3622
4902
|
if (firstCreated)
|
|
3623
|
-
cleanup.push(
|
|
4903
|
+
cleanup.push(rm4(first, { recursive: true, force: true }));
|
|
3624
4904
|
if (secondCreated)
|
|
3625
|
-
cleanup.push(
|
|
4905
|
+
cleanup.push(rm4(second, { recursive: true, force: true }));
|
|
3626
4906
|
await Promise.all(cleanup);
|
|
3627
4907
|
}
|
|
3628
4908
|
}
|
|
@@ -3678,8 +4958,8 @@ function createFeedReleaseCutProvider(options) {
|
|
|
3678
4958
|
}
|
|
3679
4959
|
|
|
3680
4960
|
// src/library/feed-state.ts
|
|
3681
|
-
import { createHash as
|
|
3682
|
-
import { Effect as
|
|
4961
|
+
import { createHash as createHash12 } from "crypto";
|
|
4962
|
+
import { Effect as Effect20 } from "effect";
|
|
3683
4963
|
|
|
3684
4964
|
// ../../src/shared/discard-stream.ts
|
|
3685
4965
|
function discardStream(stream) {
|
|
@@ -3839,11 +5119,11 @@ var json = (bytes) => {
|
|
|
3839
5119
|
throw new Error("Invalid release feed response");
|
|
3840
5120
|
}
|
|
3841
5121
|
};
|
|
3842
|
-
var feedObject = (feed, path, maximum) =>
|
|
5122
|
+
var feedObject = (feed, path, maximum) => Effect20.gen(function* () {
|
|
3843
5123
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3844
5124
|
return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
|
|
3845
5125
|
});
|
|
3846
|
-
var readFeedLedgerEffect = (feed) =>
|
|
5126
|
+
var readFeedLedgerEffect = (feed) => Effect20.gen(function* () {
|
|
3847
5127
|
const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
|
|
3848
5128
|
const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
|
|
3849
5129
|
if (ledger && ledger.releases.length > 0)
|
|
@@ -3855,7 +5135,7 @@ var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
|
|
|
3855
5135
|
}
|
|
3856
5136
|
return ledger ?? { schema: 1, app: feed.app, releases: [] };
|
|
3857
5137
|
});
|
|
3858
|
-
var readFeedReleaseEffect = (feed, tag) =>
|
|
5138
|
+
var readFeedReleaseEffect = (feed, tag) => Effect20.gen(function* () {
|
|
3859
5139
|
const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
|
|
3860
5140
|
if (!bytes)
|
|
3861
5141
|
return null;
|
|
@@ -3905,10 +5185,10 @@ class ReleaseFeedSnapshotChanged extends Error {
|
|
|
3905
5185
|
var snapshotChanged = step(async () => {
|
|
3906
5186
|
throw new ReleaseFeedSnapshotChanged;
|
|
3907
5187
|
});
|
|
3908
|
-
var verifyFeedReleaseEffect = (options) =>
|
|
5188
|
+
var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
|
|
3909
5189
|
const { config, feed, tag } = options;
|
|
3910
5190
|
const { fetch: fetcher } = yield* ReleaseFetch;
|
|
3911
|
-
const ledger = yield* readFeedLedgerEffect(feed).pipe(
|
|
5191
|
+
const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect20.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
|
|
3912
5192
|
if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
|
|
3913
5193
|
return yield* snapshotChanged;
|
|
3914
5194
|
const release = yield* readFeedReleaseEffect(feed, tag);
|
|
@@ -3926,7 +5206,7 @@ var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
|
|
|
3926
5206
|
if (!listed)
|
|
3927
5207
|
return yield* fail(`Missing signed descriptor: ${policy.name}`);
|
|
3928
5208
|
const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
|
|
3929
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
5209
|
+
if (!bytes || bytes.length !== listed.size || createHash12("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
3930
5210
|
return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
|
|
3931
5211
|
const verified = verifyReleaseDescriptor(json(bytes), {
|
|
3932
5212
|
appId: policy.appId,
|
|
@@ -3971,13 +5251,13 @@ var timestamp2 = (value) => {
|
|
|
3971
5251
|
throw new Error("Invalid release clock");
|
|
3972
5252
|
return new Date(value).toISOString();
|
|
3973
5253
|
};
|
|
3974
|
-
var exactFiles = (directory, names) =>
|
|
5254
|
+
var exactFiles = (directory, names) => Effect21.gen(function* () {
|
|
3975
5255
|
const fs = yield* ReleaseFs;
|
|
3976
5256
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
3977
5257
|
if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
|
|
3978
5258
|
return yield* fail("Staged directory does not hold exactly the platform release files");
|
|
3979
5259
|
});
|
|
3980
|
-
var promised2 =
|
|
5260
|
+
var promised2 = Effect21.gen(function* () {
|
|
3981
5261
|
const fs = yield* ReleaseFs;
|
|
3982
5262
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3983
5263
|
const { run: git } = yield* ReleaseGit;
|
|
@@ -3987,7 +5267,7 @@ var promised2 = Effect20.gen(function* () {
|
|
|
3987
5267
|
run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
|
|
3988
5268
|
};
|
|
3989
5269
|
});
|
|
3990
|
-
var runLocalReleaseCutEffect = (options) =>
|
|
5270
|
+
var runLocalReleaseCutEffect = (options) => Effect21.gen(function* () {
|
|
3991
5271
|
const { kind, platform } = options;
|
|
3992
5272
|
const parsed = parseReleaseConfig(options.config);
|
|
3993
5273
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -4012,7 +5292,7 @@ var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
|
|
|
4012
5292
|
}));
|
|
4013
5293
|
return { ...result, version: result.tag.slice(1), platform };
|
|
4014
5294
|
});
|
|
4015
|
-
var localTagProvenanceEffect = (options) =>
|
|
5295
|
+
var localTagProvenanceEffect = (options) => Effect21.gen(function* () {
|
|
4016
5296
|
const parsed = parseReleaseConfig(options.config);
|
|
4017
5297
|
parsed.requirements(options.tag);
|
|
4018
5298
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -4023,16 +5303,16 @@ var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
|
|
|
4023
5303
|
return yield* fail("Release tag does not belong to the source version");
|
|
4024
5304
|
return { repository: provenance.repository };
|
|
4025
5305
|
});
|
|
4026
|
-
var stageLocalDescriptorsEffect = (options) =>
|
|
5306
|
+
var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
|
|
4027
5307
|
const { tag, platform } = options;
|
|
4028
5308
|
const local = localConfig(options.config);
|
|
4029
5309
|
if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
|
|
4030
5310
|
return yield* fail("Invalid local release identity");
|
|
4031
5311
|
const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
|
|
4032
5312
|
const payloads = platformPayloads(local.requirements(tag), platform);
|
|
4033
|
-
const directory =
|
|
5313
|
+
const directory = resolve9(options.directory);
|
|
4034
5314
|
yield* exactFiles(directory, payloads);
|
|
4035
|
-
const assets = yield*
|
|
5315
|
+
const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
|
|
4036
5316
|
const signed = signDiscoveryDescriptors({
|
|
4037
5317
|
policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
|
|
4038
5318
|
assets,
|
|
@@ -4050,7 +5330,7 @@ var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
|
|
|
4050
5330
|
privateKey: options.privateKey
|
|
4051
5331
|
});
|
|
4052
5332
|
for (const asset of assets)
|
|
4053
|
-
if (JSON.stringify(yield* fileIdentityEffect(
|
|
5333
|
+
if (JSON.stringify(yield* fileIdentityEffect(join14(directory, asset.name), asset.name)) !== JSON.stringify(asset))
|
|
4054
5334
|
return yield* fail("Staged payload changed before signing");
|
|
4055
5335
|
yield* writeDescriptorsEffect(directory, signed);
|
|
4056
5336
|
return signed.map((value) => value.name);
|
|
@@ -4070,22 +5350,22 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
|
|
|
4070
5350
|
var describe = (key, bytes, cacheControl) => ({
|
|
4071
5351
|
key,
|
|
4072
5352
|
size: bytes.length,
|
|
4073
|
-
sha256:
|
|
5353
|
+
sha256: createHash13("sha256").update(bytes).digest("hex"),
|
|
4074
5354
|
contentType: "application/json",
|
|
4075
5355
|
cacheControl
|
|
4076
5356
|
});
|
|
4077
|
-
var writeStagedTree = (out, feed, assets, documents) =>
|
|
5357
|
+
var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* () {
|
|
4078
5358
|
const fs = yield* ReleaseFs;
|
|
4079
|
-
const root =
|
|
4080
|
-
const exists = yield* step(() => fs.lstat(root)).pipe(
|
|
5359
|
+
const root = resolve9(out);
|
|
5360
|
+
const exists = yield* step(() => fs.lstat(root)).pipe(Effect21.as(true), Effect21.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect21.succeed(false)));
|
|
4081
5361
|
if (exists)
|
|
4082
5362
|
return yield* fail("Release output directory already exists");
|
|
4083
5363
|
yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
|
|
4084
|
-
const staging = yield* step(() => fs.mkdtemp(
|
|
4085
|
-
const exit = yield*
|
|
5364
|
+
const staging = yield* step(() => fs.mkdtemp(join14(dirname2(root), ".release-staging-")));
|
|
5365
|
+
const exit = yield* Effect21.exit(Effect21.gen(function* () {
|
|
4086
5366
|
const objects = [];
|
|
4087
5367
|
for (const { key, path, artifact } of assets) {
|
|
4088
|
-
const target =
|
|
5368
|
+
const target = join14(staging, key);
|
|
4089
5369
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
4090
5370
|
yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
|
|
4091
5371
|
if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
|
|
@@ -4099,13 +5379,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
|
|
|
4099
5379
|
});
|
|
4100
5380
|
}
|
|
4101
5381
|
for (const { key, bytes } of documents) {
|
|
4102
|
-
const target =
|
|
5382
|
+
const target = join14(staging, key);
|
|
4103
5383
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
4104
5384
|
yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
|
|
4105
5385
|
objects.push(describe(key, bytes, MUTABLE));
|
|
4106
5386
|
}
|
|
4107
5387
|
const plan = { schema: 1, base: feed.base, objects };
|
|
4108
|
-
yield* step(() => fs.writeFile(
|
|
5388
|
+
yield* step(() => fs.writeFile(join14(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
|
|
4109
5389
|
yield* attempt(() => renameExclusive(staging, root));
|
|
4110
5390
|
return plan;
|
|
4111
5391
|
}));
|
|
@@ -4113,10 +5393,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
|
|
|
4113
5393
|
return exit.value;
|
|
4114
5394
|
const error = Cause2.squash(exit.cause);
|
|
4115
5395
|
const original = error instanceof ReleaseFailure ? error.original ?? error : error;
|
|
4116
|
-
const cleanup = yield*
|
|
5396
|
+
const cleanup = yield* Effect21.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
|
|
4117
5397
|
if (Exit3.isFailure(cleanup)) {
|
|
4118
5398
|
const cleanupError = Cause2.squash(cleanup.cause);
|
|
4119
|
-
return yield*
|
|
5399
|
+
return yield* Effect21.fail(new ReleaseFailure({
|
|
4120
5400
|
reason: "cleanup",
|
|
4121
5401
|
message: "Release staging failed and its private temporary tree could not be removed",
|
|
4122
5402
|
original: new AggregateError([
|
|
@@ -4125,8 +5405,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
|
|
|
4125
5405
|
], "Release staging failed and its private temporary tree could not be removed", { cause: original })
|
|
4126
5406
|
}));
|
|
4127
5407
|
}
|
|
4128
|
-
return yield*
|
|
4129
|
-
}).pipe(
|
|
5408
|
+
return yield* Effect21.failCause(exit.cause);
|
|
5409
|
+
}).pipe(Effect21.uninterruptible);
|
|
4130
5410
|
function releaseDocuments(feed, ledger, release) {
|
|
4131
5411
|
return [
|
|
4132
5412
|
{ key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
|
|
@@ -4143,23 +5423,23 @@ function releaseDocuments(feed, ledger, release) {
|
|
|
4143
5423
|
}))
|
|
4144
5424
|
];
|
|
4145
5425
|
}
|
|
4146
|
-
var stageLocalReleaseEffect = (options) =>
|
|
5426
|
+
var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
4147
5427
|
const fs = yield* ReleaseFs;
|
|
4148
5428
|
const { tag, sourceSha, platform } = options;
|
|
4149
5429
|
const local = localConfig(options.config);
|
|
4150
5430
|
const feed = local.feed, now = timestamp2(options.now);
|
|
4151
5431
|
const payloads = platformPayloads(local.requirements(tag), platform);
|
|
4152
5432
|
const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
|
|
4153
|
-
const directory =
|
|
5433
|
+
const directory = resolve9(options.directory);
|
|
4154
5434
|
const names = [...payloads, ...policies.map((policy) => policy.name)];
|
|
4155
5435
|
yield* exactFiles(directory, names);
|
|
4156
|
-
const staged = yield*
|
|
5436
|
+
const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
|
|
4157
5437
|
for (const policy of policies) {
|
|
4158
5438
|
const artifact = staged.find((asset) => asset.name === policy.name);
|
|
4159
5439
|
if (artifact.size > 65536)
|
|
4160
5440
|
return yield* fail("Signed descriptor is too large");
|
|
4161
|
-
const bytes = yield* step(() => fs.readFile(
|
|
4162
|
-
if ("sha256:" +
|
|
5441
|
+
const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
|
|
5442
|
+
if ("sha256:" + createHash13("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
4163
5443
|
return yield* fail("Signed descriptor changed");
|
|
4164
5444
|
let parsed;
|
|
4165
5445
|
try {
|
|
@@ -4180,7 +5460,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
4180
5460
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest)
|
|
4181
5461
|
return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
|
|
4182
5462
|
}
|
|
4183
|
-
const [ledger, remote] = yield*
|
|
5463
|
+
const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
|
|
4184
5464
|
const entry = ledger.releases.find((item) => item.tag === tag);
|
|
4185
5465
|
if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
|
|
4186
5466
|
return yield* fail("Inconsistent feed release; reconcile publication before retrying");
|
|
@@ -4198,7 +5478,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
4198
5478
|
merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
|
|
4199
5479
|
uploads.push({
|
|
4200
5480
|
key: feedAssetKey(feed, tag, artifact.name),
|
|
4201
|
-
path:
|
|
5481
|
+
path: join14(directory, artifact.name),
|
|
4202
5482
|
artifact
|
|
4203
5483
|
});
|
|
4204
5484
|
}
|
|
@@ -4231,7 +5511,7 @@ function stablePlatforms(config) {
|
|
|
4231
5511
|
throw new Error("Invalid stablePlatforms in the release configuration");
|
|
4232
5512
|
return value;
|
|
4233
5513
|
}
|
|
4234
|
-
var verifyLocalReleaseEffect = (options) =>
|
|
5514
|
+
var verifyLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
4235
5515
|
const local = localConfig(options.config);
|
|
4236
5516
|
const { release, platforms } = yield* verifyFeedReleaseEffect({
|
|
4237
5517
|
config: local.config,
|
|
@@ -4247,7 +5527,7 @@ var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
4247
5527
|
missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
|
|
4248
5528
|
};
|
|
4249
5529
|
});
|
|
4250
|
-
var runLocalPromotionEffect = (options) =>
|
|
5530
|
+
var runLocalPromotionEffect = (options) => Effect21.gen(function* () {
|
|
4251
5531
|
const local = localConfig(options.config);
|
|
4252
5532
|
const feed = local.feed;
|
|
4253
5533
|
const required = stablePlatforms(local.config);
|
|
@@ -4305,7 +5585,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
|
|
|
4305
5585
|
const verification = qualified.get(selected.tag);
|
|
4306
5586
|
const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
|
|
4307
5587
|
const entry = ledger.releases.find((item) => item.tag === selected.tag);
|
|
4308
|
-
const [currentLedger, remote] = await run(
|
|
5588
|
+
const [currentLedger, remote] = await run(Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
|
|
4309
5589
|
concurrency: "unbounded"
|
|
4310
5590
|
}));
|
|
4311
5591
|
if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
|
|
@@ -4344,7 +5624,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
|
|
|
4344
5624
|
|
|
4345
5625
|
// src/library/qualification-run.ts
|
|
4346
5626
|
var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
|
|
4347
|
-
var tagRun = (options) =>
|
|
5627
|
+
var tagRun = (options) => Effect22.gen(function* () {
|
|
4348
5628
|
const { tag, sha, runId } = options;
|
|
4349
5629
|
if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
|
|
4350
5630
|
return yield* fail(REFUSAL);
|
|
@@ -4358,7 +5638,7 @@ var tagRun = (options) => Effect21.gen(function* () {
|
|
|
4358
5638
|
runAttempt: 1
|
|
4359
5639
|
};
|
|
4360
5640
|
});
|
|
4361
|
-
var planQualificationRunEffect = (options) =>
|
|
5641
|
+
var planQualificationRunEffect = (options) => Effect22.gen(function* () {
|
|
4362
5642
|
const { env, config, tag } = options;
|
|
4363
5643
|
if (env.GITHUB_ACTIONS === "true") {
|
|
4364
5644
|
const plan = yield* planReleaseAssetsEffect({ env, config, tag });
|
|
@@ -4391,8 +5671,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
|
|
|
4391
5671
|
...options.git ? { git: options.git } : {}
|
|
4392
5672
|
})(planQualificationRunEffect(options)));
|
|
4393
5673
|
// src/library/retained-build.ts
|
|
4394
|
-
import { Effect as
|
|
4395
|
-
var id = (value) =>
|
|
5674
|
+
import { Effect as Effect23 } from "effect";
|
|
5675
|
+
var id = (value) => Effect23.gen(function* () {
|
|
4396
5676
|
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
4397
5677
|
return yield* fail("Invalid GitHub identity");
|
|
4398
5678
|
const text = String(value);
|
|
@@ -4400,7 +5680,7 @@ var id = (value) => Effect22.gen(function* () {
|
|
|
4400
5680
|
return yield* fail("Invalid GitHub identity");
|
|
4401
5681
|
return text;
|
|
4402
5682
|
});
|
|
4403
|
-
var selectRetainedReleaseBuildEffect = (options) =>
|
|
5683
|
+
var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
|
|
4404
5684
|
const { env, config, tag, platform } = options;
|
|
4405
5685
|
if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
|
|
4406
5686
|
return yield* fail("Invalid retained build context");
|
|
@@ -4518,12 +5798,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
|
|
|
4518
5798
|
});
|
|
4519
5799
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
4520
5800
|
// src/library/staging.ts
|
|
4521
|
-
import { createHash as
|
|
4522
|
-
import { join as
|
|
4523
|
-
import { Effect as
|
|
4524
|
-
var copyHashed = (input, output, size) =>
|
|
5801
|
+
import { createHash as createHash14 } from "crypto";
|
|
5802
|
+
import { join as join15, resolve as resolve10 } from "path";
|
|
5803
|
+
import { Effect as Effect24 } from "effect";
|
|
5804
|
+
var copyHashed = (input, output, size) => Effect24.tryPromise({
|
|
4525
5805
|
try: async (signal) => {
|
|
4526
|
-
const hash =
|
|
5806
|
+
const hash = createHash14("sha256");
|
|
4527
5807
|
let copied = 0;
|
|
4528
5808
|
for await (const chunk of input.createReadStream({
|
|
4529
5809
|
autoClose: false
|
|
@@ -4550,14 +5830,14 @@ var copyHashed = (input, output, size) => Effect23.tryPromise({
|
|
|
4550
5830
|
original: error
|
|
4551
5831
|
})
|
|
4552
5832
|
});
|
|
4553
|
-
var stageExpectedFilesEffect = (options) =>
|
|
5833
|
+
var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
|
|
4554
5834
|
const fs = yield* ReleaseFs;
|
|
4555
5835
|
const { expected } = options;
|
|
4556
5836
|
if (!expected.length || new Set(expected).size !== expected.length || expected.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(name)) || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
4557
5837
|
return yield* fail("Staging sources do not match expected filenames");
|
|
4558
|
-
const directory =
|
|
5838
|
+
const directory = resolve10(options.directory);
|
|
4559
5839
|
const created = [];
|
|
4560
|
-
const stage =
|
|
5840
|
+
const stage = Effect24.forEach(expected, (name) => Effect24.gen(function* () {
|
|
4561
5841
|
const sourcePath = options.sources[name];
|
|
4562
5842
|
if (typeof sourcePath !== "string" || !sourcePath)
|
|
4563
5843
|
return yield* fail("Invalid staging source");
|
|
@@ -4568,7 +5848,7 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
|
|
|
4568
5848
|
const before = yield* step(() => input.stat());
|
|
4569
5849
|
if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
|
|
4570
5850
|
return yield* fail("Staging source changed");
|
|
4571
|
-
const target =
|
|
5851
|
+
const target = join15(directory, name);
|
|
4572
5852
|
const output = yield* scopedHandle(() => fs.open(target, "wx"));
|
|
4573
5853
|
created.push(target);
|
|
4574
5854
|
const copied = yield* copyHashed(input, output, before.size);
|
|
@@ -4577,10 +5857,10 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
|
|
|
4577
5857
|
if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
|
|
4578
5858
|
return yield* fail("Staging source changed");
|
|
4579
5859
|
return { name, size: copied.size, digest: copied.digest };
|
|
4580
|
-
}).pipe(
|
|
4581
|
-
return yield* stage.pipe(
|
|
5860
|
+
}).pipe(Effect24.scoped), { concurrency: 1 });
|
|
5861
|
+
return yield* stage.pipe(Effect24.onError(() => Effect24.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
|
|
4582
5862
|
});
|
|
4583
|
-
var stagePlatformArtifactsEffect = (options) =>
|
|
5863
|
+
var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
|
|
4584
5864
|
const requirements = parseReleaseConfig(options.config).requirements(options.tag);
|
|
4585
5865
|
const expected = platformPayloads(requirements, options.platform);
|
|
4586
5866
|
if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
@@ -4589,21 +5869,21 @@ var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
|
|
|
4589
5869
|
});
|
|
4590
5870
|
var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
|
|
4591
5871
|
// src/library/steps.ts
|
|
4592
|
-
import { join as
|
|
4593
|
-
import { Effect as
|
|
5872
|
+
import { join as join35 } from "path";
|
|
5873
|
+
import { Effect as Effect25 } from "effect";
|
|
4594
5874
|
|
|
4595
5875
|
// ../../src/installer/installer-archive-members.ts
|
|
4596
|
-
import { createHash as
|
|
4597
|
-
import { lstat as
|
|
4598
|
-
import { isAbsolute as
|
|
5876
|
+
import { createHash as createHash15 } from "crypto";
|
|
5877
|
+
import { lstat as lstat7, open as open4 } from "fs/promises";
|
|
5878
|
+
import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
|
|
4599
5879
|
|
|
4600
5880
|
// ../../src/installer/native-executable.ts
|
|
4601
5881
|
async function assertNativeExecutable(file, size, platform, what) {
|
|
4602
5882
|
const head = Buffer.alloc(64);
|
|
4603
5883
|
if ((await file.read(head, 0, head.length, 0)).bytesRead !== head.length)
|
|
4604
5884
|
throw new Error(`Invalid ${what}`);
|
|
4605
|
-
if (platform
|
|
4606
|
-
if (head.readUInt32LE(0) !== 4277009103 || head.readUInt32LE(4) !== 16777228)
|
|
5885
|
+
if (isMacInstallerPlatform(platform)) {
|
|
5886
|
+
if (head.readUInt32LE(0) !== 4277009103 || head.readUInt32LE(4) !== (platform === "macos-arm64" ? 16777228 : 16777223))
|
|
4607
5887
|
throw new Error(`Invalid macOS ${what}`);
|
|
4608
5888
|
} else if (platform === "linux-x64" || platform === "linux-arm64") {
|
|
4609
5889
|
if (!head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) || head[4] !== 2 || head.readUInt16LE(18) !== (platform === "linux-x64" ? 62 : 183))
|
|
@@ -4619,7 +5899,7 @@ async function assertNativeExecutable(file, size, platform, what) {
|
|
|
4619
5899
|
var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
|
|
4620
5900
|
function isWithin(root, path) {
|
|
4621
5901
|
const rel = relative3(root, path);
|
|
4622
|
-
return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !
|
|
5902
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute4(rel);
|
|
4623
5903
|
}
|
|
4624
5904
|
function normalizeArchiveMember(name) {
|
|
4625
5905
|
return name.replace(/^\.\//, "").replaceAll("\\", "/");
|
|
@@ -4635,7 +5915,7 @@ function findArchiveMember(entries, expected, platform, message) {
|
|
|
4635
5915
|
return found[0];
|
|
4636
5916
|
}
|
|
4637
5917
|
async function assertArchiveUnchanged(archive, before, message) {
|
|
4638
|
-
const after = await
|
|
5918
|
+
const after = await lstat7(archive);
|
|
4639
5919
|
if (!after.isFile() || after.isSymbolicLink() || !sameFile(after, before))
|
|
4640
5920
|
throw new Error(message);
|
|
4641
5921
|
}
|
|
@@ -4681,7 +5961,7 @@ async function extractArchiveMember(options) {
|
|
|
4681
5961
|
}
|
|
4682
5962
|
}
|
|
4683
5963
|
async function assertInstallerExecutable(path, platform) {
|
|
4684
|
-
const info = await
|
|
5964
|
+
const info = await lstat7(path);
|
|
4685
5965
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
|
|
4686
5966
|
throw new Error("Invalid installer executable");
|
|
4687
5967
|
const file = await open4(path, "r");
|
|
@@ -4700,7 +5980,7 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
4700
5980
|
const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
|
|
4701
5981
|
if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
|
|
4702
5982
|
throw new Error("Installer archive marker is missing");
|
|
4703
|
-
const hash =
|
|
5983
|
+
const hash = createHash15("sha256");
|
|
4704
5984
|
let read = 0;
|
|
4705
5985
|
for await (const chunk of file.createReadStream({
|
|
4706
5986
|
start: position + marker.length,
|
|
@@ -4717,23 +5997,23 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
4717
5997
|
}
|
|
4718
5998
|
|
|
4719
5999
|
// ../../src/installer/installer-identity.ts
|
|
4720
|
-
import { lstat as
|
|
4721
|
-
import { tmpdir as
|
|
4722
|
-
import { basename as basename5, join as
|
|
6000
|
+
import { lstat as lstat9, mkdtemp as mkdtemp5, readdir as readdir6, realpath as realpath2 } from "fs/promises";
|
|
6001
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
6002
|
+
import { basename as basename5, join as join17, resolve as resolve11, win32 as win322 } from "path";
|
|
4723
6003
|
|
|
4724
6004
|
// ../../src/installer/installer-image-mount.ts
|
|
4725
|
-
import { lstat as
|
|
4726
|
-
import { dirname as dirname3, join as
|
|
6005
|
+
import { lstat as lstat8, mkdir as mkdir4, mkdtemp as mkdtemp4, readdir as readdir5, rm as rm5, stat } from "fs/promises";
|
|
6006
|
+
import { dirname as dirname3, join as join16 } from "path";
|
|
4727
6007
|
var FAILED_ATTACH_PROBES = 5;
|
|
4728
6008
|
var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
|
|
4729
6009
|
async function containsMountAt(path, expectedDevice) {
|
|
4730
|
-
const info = await
|
|
6010
|
+
const info = await lstat8(path);
|
|
4731
6011
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
4732
6012
|
return false;
|
|
4733
6013
|
if (info.dev !== expectedDevice)
|
|
4734
6014
|
return true;
|
|
4735
|
-
for (const name of await
|
|
4736
|
-
const child =
|
|
6015
|
+
for (const name of await readdir5(path)) {
|
|
6016
|
+
const child = join16(path, name), childInfo = await lstat8(child);
|
|
4737
6017
|
if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
|
|
4738
6018
|
continue;
|
|
4739
6019
|
if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
|
|
@@ -4759,7 +6039,7 @@ function defaultInstallerImageMountIo(run) {
|
|
|
4759
6039
|
state: installerImageMountState,
|
|
4760
6040
|
containsNestedMount,
|
|
4761
6041
|
wait: Bun.sleep,
|
|
4762
|
-
remove: (directory) =>
|
|
6042
|
+
remove: (directory) => rm5(directory, { recursive: true, force: true })
|
|
4763
6043
|
};
|
|
4764
6044
|
}
|
|
4765
6045
|
async function assertNoNestedInstallerMount(directory, io) {
|
|
@@ -4927,8 +6207,8 @@ async function withInstallerImageRetries(options) {
|
|
|
4927
6207
|
};
|
|
4928
6208
|
const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
|
|
4929
6209
|
for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
|
|
4930
|
-
const directory = await
|
|
4931
|
-
const mount =
|
|
6210
|
+
const directory = await mkdtemp4(join16(options.parent, options.prefix));
|
|
6211
|
+
const mount = join16(directory, "mount");
|
|
4932
6212
|
const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
|
|
4933
6213
|
let lifecycleStarted = false;
|
|
4934
6214
|
try {
|
|
@@ -5095,8 +6375,8 @@ async function runInstallerCommand(args, env, options) {
|
|
|
5095
6375
|
}
|
|
5096
6376
|
|
|
5097
6377
|
// ../../src/installer/installer-identity.ts
|
|
5098
|
-
async function
|
|
5099
|
-
const info = await
|
|
6378
|
+
async function identity2(path) {
|
|
6379
|
+
const info = await lstat9(path);
|
|
5100
6380
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
|
|
5101
6381
|
throw new Error("Invalid installer artifact");
|
|
5102
6382
|
const { size, sha256 } = await hashFileAt(path, info, "Installer artifact changed");
|
|
@@ -5123,40 +6403,40 @@ async function verifyInstallerPayload(options) {
|
|
|
5123
6403
|
else
|
|
5124
6404
|
assertInstallerContext(parent, options.platform, process.platform, process.arch);
|
|
5125
6405
|
assertPortableAppName(options.appName);
|
|
5126
|
-
const installerPath =
|
|
5127
|
-
const before = { installer: await
|
|
6406
|
+
const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
|
|
6407
|
+
const before = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
|
|
5128
6408
|
if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
|
|
5129
6409
|
throw new Error("Installer archive exceeds bound");
|
|
5130
6410
|
const env = environment(parent);
|
|
5131
|
-
const temporary = await
|
|
6411
|
+
const temporary = await mkdtemp5(join17(tmpdir5(), "framework-installer-inspect-"));
|
|
5132
6412
|
const cleanupIo = defaultInstallerImageMountIo(command);
|
|
5133
6413
|
try {
|
|
5134
|
-
if (options.platform
|
|
6414
|
+
if (isMacInstallerPlatform(options.platform)) {
|
|
5135
6415
|
await withInstallerImageRetries({
|
|
5136
|
-
parent:
|
|
6416
|
+
parent: tmpdir5(),
|
|
5137
6417
|
prefix: "framework-installer-inspect-attempt-",
|
|
5138
6418
|
image: installerPath,
|
|
5139
6419
|
env,
|
|
5140
6420
|
run: command,
|
|
5141
6421
|
work: async (mount) => {
|
|
5142
|
-
const apps = (await
|
|
6422
|
+
const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
|
|
5143
6423
|
if (apps.length !== 1)
|
|
5144
6424
|
throw new Error("Installer application is missing or ambiguous");
|
|
5145
|
-
const resources =
|
|
5146
|
-
const actualRoot = await
|
|
6425
|
+
const resources = join17(mount, apps[0], "Contents", "Resources");
|
|
6426
|
+
const actualRoot = await realpath2(mount), actualApp = await realpath2(join17(mount, apps[0])), actualResources = await realpath2(resources);
|
|
5147
6427
|
if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
|
|
5148
6428
|
throw new Error("Installer resources escape mounted image");
|
|
5149
|
-
const plist =
|
|
6429
|
+
const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
|
|
5150
6430
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5151
6431
|
throw new Error("Invalid installer property list");
|
|
5152
6432
|
const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
|
|
5153
6433
|
if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
|
|
5154
6434
|
throw new Error("Invalid installer executable name");
|
|
5155
|
-
await assertInstallerExecutable(
|
|
5156
|
-
const archives = (await
|
|
6435
|
+
await assertInstallerExecutable(join17(actualApp, "Contents", "MacOS", executable), options.platform);
|
|
6436
|
+
const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
|
|
5157
6437
|
if (archives.length !== 1)
|
|
5158
6438
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5159
|
-
const embedded = await
|
|
6439
|
+
const embedded = await identity2(join17(actualResources, archives[0]));
|
|
5160
6440
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
5161
6441
|
throw new Error("Installer archive differs from release archive");
|
|
5162
6442
|
}
|
|
@@ -5165,7 +6445,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5165
6445
|
const systemRoot = parent.SystemRoot;
|
|
5166
6446
|
if (options.platform === "windows-x64" && (!systemRoot || !/^[A-Za-z]:[\\/]/.test(systemRoot)))
|
|
5167
6447
|
throw new Error("Missing Windows system directory");
|
|
5168
|
-
const tar = options.platform === "windows-x64" ?
|
|
6448
|
+
const tar = options.platform === "windows-x64" ? win322.join(systemRoot, "System32", "tar.exe") : "tar";
|
|
5169
6449
|
if (options.platform === "windows-x64" && !/^bsdtar\s/i.test((await command([tar, "--version"], env)).trim()))
|
|
5170
6450
|
throw new Error("Windows installer inspection requires system bsdtar");
|
|
5171
6451
|
const names = (await command([tar, "-tf", installerPath], env)).split(/\r?\n/).filter(Boolean);
|
|
@@ -5174,7 +6454,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5174
6454
|
const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
|
|
5175
6455
|
if (matches.length !== 1)
|
|
5176
6456
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5177
|
-
const extracted =
|
|
6457
|
+
const extracted = join17(temporary, "member");
|
|
5178
6458
|
const count = await extractArchiveMember({
|
|
5179
6459
|
tar,
|
|
5180
6460
|
archive: installerPath,
|
|
@@ -5185,7 +6465,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5185
6465
|
});
|
|
5186
6466
|
if (options.platform === "windows-x64") {
|
|
5187
6467
|
const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
|
|
5188
|
-
const executable =
|
|
6468
|
+
const executable = join17(temporary, "setup.exe");
|
|
5189
6469
|
await extractArchiveMember({
|
|
5190
6470
|
tar,
|
|
5191
6471
|
archive: installerPath,
|
|
@@ -5195,7 +6475,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5195
6475
|
env
|
|
5196
6476
|
});
|
|
5197
6477
|
await assertInstallerExecutable(executable, options.platform);
|
|
5198
|
-
const embedded = await
|
|
6478
|
+
const embedded = await identity2(extracted);
|
|
5199
6479
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
5200
6480
|
throw new Error("Installer archive differs from release archive");
|
|
5201
6481
|
} else {
|
|
@@ -5203,7 +6483,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5203
6483
|
await assertEmbeddedArchive(extracted, count, before.archive);
|
|
5204
6484
|
}
|
|
5205
6485
|
}
|
|
5206
|
-
const after = { installer: await
|
|
6486
|
+
const after = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
|
|
5207
6487
|
if (JSON.stringify(before) !== JSON.stringify(after))
|
|
5208
6488
|
throw new Error("Installer artifacts changed during inspection");
|
|
5209
6489
|
await cleanupInstallerDirectoryAfterFailure(temporary, undefined, cleanupIo);
|
|
@@ -5221,19 +6501,19 @@ async function verifyInstallerPayload(options) {
|
|
|
5221
6501
|
}
|
|
5222
6502
|
|
|
5223
6503
|
// ../../src/installer/installer-qualification-command.ts
|
|
5224
|
-
import { lstat as
|
|
5225
|
-
import { join as
|
|
6504
|
+
import { lstat as lstat19, writeFile as writeFile10 } from "fs/promises";
|
|
6505
|
+
import { join as join32, resolve as resolve14 } from "path";
|
|
5226
6506
|
|
|
5227
6507
|
// ../../src/installer/installer-observation.ts
|
|
5228
|
-
import { randomBytes as
|
|
5229
|
-
import { chmod as chmod2, mkdir as mkdir9, readFile as
|
|
6508
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
6509
|
+
import { chmod as chmod2, mkdir as mkdir9, readFile as readFile11, realpath as realpath9, writeFile as writeFile9 } from "fs/promises";
|
|
5230
6510
|
import { createServer } from "net";
|
|
5231
|
-
import { delimiter, dirname as dirname12, join as
|
|
6511
|
+
import { delimiter, dirname as dirname12, join as join31 } from "path";
|
|
5232
6512
|
|
|
5233
6513
|
// ../../src/installer/installer-ci-bootstrap.ts
|
|
5234
|
-
import { randomBytes } from "crypto";
|
|
5235
|
-
import { lstat as
|
|
5236
|
-
import { dirname as dirname4, isAbsolute as
|
|
6514
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
6515
|
+
import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp6, realpath as realpath3, rm as rm6, writeFile as writeFile5 } from "fs/promises";
|
|
6516
|
+
import { dirname as dirname4, isAbsolute as isAbsolute5, join as join18, relative as relative4, sep as sep3 } from "path";
|
|
5237
6517
|
import { fileURLToPath } from "url";
|
|
5238
6518
|
var bootstrapModules = [
|
|
5239
6519
|
"app/value-guards.js",
|
|
@@ -5256,42 +6536,42 @@ async function prepareInstallerCiBootstrap(env = process.env) {
|
|
|
5256
6536
|
const temp = runnerTemp(env);
|
|
5257
6537
|
if (!isHostedRunner(env) || !temp)
|
|
5258
6538
|
throw new Error("Installer bootstrap requires a disposable hosted runner");
|
|
5259
|
-
const parent = await
|
|
5260
|
-
if (/\s/.test(parent) || !(await
|
|
6539
|
+
const parent = await realpath3(temp);
|
|
6540
|
+
if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
|
|
5261
6541
|
throw new Error("Runner temp cannot represent a Bun preload path");
|
|
5262
6542
|
const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
|
|
5263
|
-
const directory = await
|
|
6543
|
+
const directory = await mkdtemp6(join18(parent, "framework-ci-"));
|
|
5264
6544
|
try {
|
|
5265
6545
|
for (const name of bootstrapModules) {
|
|
5266
|
-
const contents = await readBoundedFile(
|
|
5267
|
-
await mkdir5(dirname4(
|
|
5268
|
-
await
|
|
6546
|
+
const contents = await readBoundedFile(join18(source, name), 2 * 1024 * 1024, "installer bootstrap module");
|
|
6547
|
+
await mkdir5(dirname4(join18(directory, name)), { recursive: true, mode: 448 });
|
|
6548
|
+
await writeFile5(join18(directory, name), contents, { flag: "wx", mode: 384 });
|
|
5269
6549
|
}
|
|
5270
|
-
await
|
|
6550
|
+
await writeFile5(join18(directory, "package.json"), `{"type":"module"}
|
|
5271
6551
|
`, {
|
|
5272
6552
|
flag: "wx",
|
|
5273
6553
|
mode: 384
|
|
5274
6554
|
});
|
|
5275
|
-
const worker =
|
|
6555
|
+
const worker = join18(directory, "installer/installer-ci-worker.js");
|
|
5276
6556
|
return {
|
|
5277
6557
|
directory,
|
|
5278
6558
|
worker,
|
|
5279
|
-
preflight:
|
|
6559
|
+
preflight: join18(directory, "installer/installer-ci-preflight.js"),
|
|
5280
6560
|
bunOptions: `--preload=${worker}`
|
|
5281
6561
|
};
|
|
5282
6562
|
} catch (error) {
|
|
5283
|
-
await
|
|
6563
|
+
await rm6(directory, { recursive: true, force: true });
|
|
5284
6564
|
throw error;
|
|
5285
6565
|
}
|
|
5286
6566
|
}
|
|
5287
6567
|
async function preflightInstallerRuntime(options) {
|
|
5288
6568
|
const { env, runtime, bootstrap } = options;
|
|
5289
6569
|
const temp = runnerTemp(env);
|
|
5290
|
-
if (!isHostedRunner(env) || !temp || !
|
|
6570
|
+
if (!isHostedRunner(env) || !temp || !isAbsolute5(runtime))
|
|
5291
6571
|
throw new Error("Runtime preflight requires a disposable hosted runner");
|
|
5292
|
-
const tempRoot = await
|
|
6572
|
+
const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
|
|
5293
6573
|
const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
|
|
5294
|
-
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) ||
|
|
6574
|
+
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute5(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join18(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join18(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
|
|
5295
6575
|
throw new Error("Invalid installer bootstrap location");
|
|
5296
6576
|
await runInstallerPreflight({
|
|
5297
6577
|
env,
|
|
@@ -5304,14 +6584,14 @@ async function preflightInstallerRuntime(options) {
|
|
|
5304
6584
|
async function runInstallerPreflight(options) {
|
|
5305
6585
|
const { env, runtime, worker, preflight } = options;
|
|
5306
6586
|
for (const path of [worker, preflight]) {
|
|
5307
|
-
const item = await
|
|
6587
|
+
const item = await lstat10(path);
|
|
5308
6588
|
if (!item.isFile() || item.isSymbolicLink())
|
|
5309
6589
|
throw new Error("Invalid installer bootstrap module");
|
|
5310
6590
|
}
|
|
5311
|
-
const info = await
|
|
6591
|
+
const info = await lstat10(runtime);
|
|
5312
6592
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
|
|
5313
6593
|
throw new Error("Invalid candidate Bun runtime");
|
|
5314
|
-
const temporary = await
|
|
6594
|
+
const temporary = await mkdtemp6(join18(options.parent, "framework-preflight-"));
|
|
5315
6595
|
try {
|
|
5316
6596
|
const clean = {};
|
|
5317
6597
|
for (const key of [
|
|
@@ -5328,7 +6608,7 @@ async function runInstallerPreflight(options) {
|
|
|
5328
6608
|
])
|
|
5329
6609
|
if (env[key])
|
|
5330
6610
|
clean[key] = env[key];
|
|
5331
|
-
const nonce =
|
|
6611
|
+
const nonce = randomBytes2(24).toString("hex");
|
|
5332
6612
|
Object.assign(clean, {
|
|
5333
6613
|
CI: "true",
|
|
5334
6614
|
GITHUB_ACTIONS: "true",
|
|
@@ -5336,11 +6616,11 @@ async function runInstallerPreflight(options) {
|
|
|
5336
6616
|
BUN_OPTIONS: `--preload=${worker}`,
|
|
5337
6617
|
FRAMEWORK_CI_WORKER_ENTRY: preflight,
|
|
5338
6618
|
FRAMEWORK_CI_NONCE: nonce,
|
|
5339
|
-
FRAMEWORK_CI_ACK:
|
|
5340
|
-
FRAMEWORK_CI_PERMIT:
|
|
6619
|
+
FRAMEWORK_CI_ACK: join18(temporary, "ack"),
|
|
6620
|
+
FRAMEWORK_CI_PERMIT: join18(temporary, "permit"),
|
|
5341
6621
|
FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
|
|
5342
|
-
FRAMEWORK_CI_OBSERVATION:
|
|
5343
|
-
FRAMEWORK_CI_UNEXPECTED:
|
|
6622
|
+
FRAMEWORK_CI_OBSERVATION: join18(temporary, "observation"),
|
|
6623
|
+
FRAMEWORK_CI_UNEXPECTED: join18(temporary, "unexpected"),
|
|
5344
6624
|
FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
|
|
5345
6625
|
"https://example.invalid/framework-ci-sentinel"
|
|
5346
6626
|
])
|
|
@@ -5375,29 +6655,29 @@ async function runInstallerPreflight(options) {
|
|
|
5375
6655
|
if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
|
|
5376
6656
|
throw new Error("Candidate Bun runtime failed installer preflight");
|
|
5377
6657
|
try {
|
|
5378
|
-
await
|
|
6658
|
+
await lstat10(join18(temporary, "unexpected"));
|
|
5379
6659
|
throw new Error("Runtime preflight recorded unexpected activity");
|
|
5380
6660
|
} catch (error) {
|
|
5381
6661
|
if (errorCode(error) !== "ENOENT")
|
|
5382
6662
|
throw error;
|
|
5383
6663
|
}
|
|
5384
6664
|
} finally {
|
|
5385
|
-
await
|
|
6665
|
+
await rm6(temporary, { recursive: true, force: true });
|
|
5386
6666
|
}
|
|
5387
6667
|
}
|
|
5388
6668
|
|
|
5389
6669
|
// ../../src/installer/installer-extraction.ts
|
|
5390
|
-
import { chmod, lstat as
|
|
5391
|
-
import { join as
|
|
5392
|
-
async function
|
|
6670
|
+
import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as mkdtemp7, readdir as readdir7, realpath as realpath4 } from "fs/promises";
|
|
6671
|
+
import { join as join19, resolve as resolve12, win32 as win323 } from "path";
|
|
6672
|
+
async function run2(cmd, env) {
|
|
5393
6673
|
return runInstallerCommand(cmd, env, {
|
|
5394
6674
|
outputLimit: 8 * 1024 * 1024,
|
|
5395
6675
|
overflowMessage: "Installer command output exceeds bound",
|
|
5396
6676
|
failureMessage: "Installer preparation command failed"
|
|
5397
6677
|
});
|
|
5398
6678
|
}
|
|
5399
|
-
async function
|
|
5400
|
-
const info = await
|
|
6679
|
+
async function digest4(path) {
|
|
6680
|
+
const info = await lstat11(path);
|
|
5401
6681
|
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
|
|
5402
6682
|
throw new Error("Invalid extracted file");
|
|
5403
6683
|
const { size, sha256 } = await hashFileAt(path, info, "Extracted file changed");
|
|
@@ -5431,8 +6711,8 @@ async function prepareInstallerExecution(options) {
|
|
|
5431
6711
|
const temp = runnerTemp(env);
|
|
5432
6712
|
if (!temp)
|
|
5433
6713
|
throw new Error("Missing runner temp directory");
|
|
5434
|
-
const parent = await
|
|
5435
|
-
if (!(await
|
|
6714
|
+
const parent = await realpath4(temp), sourceInstaller = resolve12(options.installer), sourceArchive = resolve12(options.archive);
|
|
6715
|
+
if (!(await lstat11(parent)).isDirectory())
|
|
5436
6716
|
throw new Error("Invalid runner temp directory");
|
|
5437
6717
|
const verified = await verifyInstallerPayload({
|
|
5438
6718
|
...options,
|
|
@@ -5440,50 +6720,50 @@ async function prepareInstallerExecution(options) {
|
|
|
5440
6720
|
archive: sourceArchive,
|
|
5441
6721
|
env
|
|
5442
6722
|
});
|
|
5443
|
-
const directory = await
|
|
5444
|
-
const imageIo = defaultInstallerImageMountIo(
|
|
6723
|
+
const directory = await mkdtemp7(join19(parent, "framework-installer-"));
|
|
6724
|
+
const imageIo = defaultInstallerImageMountIo(run2);
|
|
5445
6725
|
try {
|
|
5446
|
-
const profile =
|
|
6726
|
+
const profile = join19(directory, "profile"), incoming = join19(directory, "incoming");
|
|
5447
6727
|
await mkdir6(profile, { mode: 448 });
|
|
5448
6728
|
await mkdir6(incoming, { mode: 448 });
|
|
5449
6729
|
const clean = cleanEnv(env);
|
|
5450
6730
|
let executable;
|
|
5451
|
-
if (options.platform
|
|
6731
|
+
if (isMacInstallerPlatform(options.platform)) {
|
|
5452
6732
|
executable = await withInstallerImageRetries({
|
|
5453
6733
|
parent,
|
|
5454
6734
|
prefix: "framework-installer-mount-attempt-",
|
|
5455
6735
|
image: sourceInstaller,
|
|
5456
6736
|
env: clean,
|
|
5457
|
-
run,
|
|
6737
|
+
run: run2,
|
|
5458
6738
|
work: async (mount) => {
|
|
5459
|
-
const appName = `${options.appName}.app`, apps = (await
|
|
6739
|
+
const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
|
|
5460
6740
|
if (apps.length !== 1 || apps[0] !== appName)
|
|
5461
6741
|
throw new Error("Unexpected installer application");
|
|
5462
|
-
const sourceApp = await
|
|
6742
|
+
const sourceApp = await realpath4(join19(mount, appName)), mountRoot = await realpath4(mount);
|
|
5463
6743
|
if (!isWithin(mountRoot, sourceApp))
|
|
5464
6744
|
throw new Error("Installer application escapes image");
|
|
5465
|
-
const app =
|
|
5466
|
-
await
|
|
5467
|
-
const actualApp = await
|
|
5468
|
-
if (!isWithin(await
|
|
6745
|
+
const app = join19(incoming, appName);
|
|
6746
|
+
await run2(["/usr/bin/ditto", sourceApp, app], clean);
|
|
6747
|
+
const actualApp = await realpath4(app), resources = await realpath4(join19(actualApp, "Contents", "Resources"));
|
|
6748
|
+
if (!isWithin(await realpath4(incoming), actualApp) || !isWithin(actualApp, resources))
|
|
5469
6749
|
throw new Error("Copied installer escapes profile");
|
|
5470
|
-
const plist =
|
|
6750
|
+
const plist = join19(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
|
|
5471
6751
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5472
6752
|
throw new Error("Invalid installer property list");
|
|
5473
|
-
const name = (await
|
|
6753
|
+
const name = (await run2(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
|
|
5474
6754
|
if (!name || name === "." || name === ".." || /[\\/]/.test(name))
|
|
5475
6755
|
throw new Error("Invalid installer executable");
|
|
5476
|
-
const appExecutable =
|
|
5477
|
-
const sourceExecutable =
|
|
5478
|
-
if (!isWithin(actualApp, await
|
|
6756
|
+
const appExecutable = join19(actualApp, "Contents", "MacOS", name);
|
|
6757
|
+
const sourceExecutable = join19(sourceApp, "Contents", "MacOS", name);
|
|
6758
|
+
if (!isWithin(actualApp, await realpath4(appExecutable)) || !isWithin(sourceApp, await realpath4(sourceExecutable)))
|
|
5479
6759
|
throw new Error("Installer executable escapes application");
|
|
5480
6760
|
await assertInstallerExecutable(appExecutable, options.platform);
|
|
5481
|
-
if (JSON.stringify(await
|
|
6761
|
+
if (JSON.stringify(await digest4(sourceExecutable)) !== JSON.stringify(await digest4(appExecutable)))
|
|
5482
6762
|
throw new Error("Copied installer executable differs");
|
|
5483
|
-
const archives = (await
|
|
6763
|
+
const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
|
|
5484
6764
|
if (archives.length !== 1)
|
|
5485
6765
|
throw new Error("Missing installer archive");
|
|
5486
|
-
const embedded = await
|
|
6766
|
+
const embedded = await digest4(join19(resources, archives[0]));
|
|
5487
6767
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5488
6768
|
throw new Error("Copied installer archive differs");
|
|
5489
6769
|
return executable;
|
|
@@ -5493,14 +6773,14 @@ async function prepareInstallerExecution(options) {
|
|
|
5493
6773
|
const root = env.SystemRoot;
|
|
5494
6774
|
if (options.platform === "windows-x64" && (!root || !/^[A-Za-z]:[\\/]/.test(root)))
|
|
5495
6775
|
throw new Error("Missing Windows system directory");
|
|
5496
|
-
const tar = options.platform === "windows-x64" ?
|
|
5497
|
-
const names = (await
|
|
6776
|
+
const tar = options.platform === "windows-x64" ? win323.join(root, "System32", "tar.exe") : "tar";
|
|
6777
|
+
const names = (await run2([tar, "-tf", sourceInstaller], clean)).split(/\r?\n/).filter(Boolean);
|
|
5498
6778
|
assertInstallerLayout(options.platform, options.appName, names);
|
|
5499
6779
|
const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
|
|
5500
6780
|
if (options.platform === "windows-x64") {
|
|
5501
|
-
const subdirectory =
|
|
6781
|
+
const subdirectory = join19(incoming, ".installer");
|
|
5502
6782
|
await mkdir6(subdirectory);
|
|
5503
|
-
executable =
|
|
6783
|
+
executable = join19(incoming, `${options.appName}-Setup.exe`);
|
|
5504
6784
|
await extractArchiveMember({
|
|
5505
6785
|
tar,
|
|
5506
6786
|
archive: sourceInstaller,
|
|
@@ -5514,11 +6794,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5514
6794
|
tar,
|
|
5515
6795
|
archive: sourceInstaller,
|
|
5516
6796
|
member: find(`.installer/${options.appName}-Setup.metadata.json`),
|
|
5517
|
-
destination:
|
|
6797
|
+
destination: join19(subdirectory, `${options.appName}-Setup.metadata.json`),
|
|
5518
6798
|
maximum: 1024 * 1024,
|
|
5519
6799
|
env: clean
|
|
5520
6800
|
});
|
|
5521
|
-
const embeddedPath =
|
|
6801
|
+
const embeddedPath = join19(subdirectory, `${options.appName}-Setup.tar.zst`);
|
|
5522
6802
|
await extractArchiveMember({
|
|
5523
6803
|
tar,
|
|
5524
6804
|
archive: sourceInstaller,
|
|
@@ -5527,11 +6807,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5527
6807
|
maximum: verified.archive.size,
|
|
5528
6808
|
env: clean
|
|
5529
6809
|
});
|
|
5530
|
-
const embedded = await
|
|
6810
|
+
const embedded = await digest4(embeddedPath);
|
|
5531
6811
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5532
6812
|
throw new Error("Copied installer archive differs");
|
|
5533
6813
|
} else {
|
|
5534
|
-
executable =
|
|
6814
|
+
executable = join19(incoming, "installer");
|
|
5535
6815
|
await extractArchiveMember({
|
|
5536
6816
|
tar,
|
|
5537
6817
|
archive: sourceInstaller,
|
|
@@ -5541,7 +6821,7 @@ async function prepareInstallerExecution(options) {
|
|
|
5541
6821
|
env: clean
|
|
5542
6822
|
});
|
|
5543
6823
|
await assertInstallerExecutable(executable, options.platform);
|
|
5544
|
-
await assertEmbeddedArchive(executable, (await
|
|
6824
|
+
await assertEmbeddedArchive(executable, (await lstat11(executable)).size, verified.archive);
|
|
5545
6825
|
await chmod(executable, 448);
|
|
5546
6826
|
}
|
|
5547
6827
|
}
|
|
@@ -5587,10 +6867,10 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
5587
6867
|
}
|
|
5588
6868
|
|
|
5589
6869
|
// ../../src/installer/installed-payload.ts
|
|
5590
|
-
import { createHash as
|
|
5591
|
-
import { lstat as
|
|
5592
|
-
import { once } from "events";
|
|
5593
|
-
import { join as
|
|
6870
|
+
import { createHash as createHash16 } from "crypto";
|
|
6871
|
+
import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm7 } from "fs/promises";
|
|
6872
|
+
import { once as once2 } from "events";
|
|
6873
|
+
import { join as join20, resolve as resolve13 } from "path";
|
|
5594
6874
|
import { createZstdDecompress } from "zlib";
|
|
5595
6875
|
import { Parser } from "tar";
|
|
5596
6876
|
function cleanEnv2(parent, forceLocal) {
|
|
@@ -5613,7 +6893,7 @@ async function command2(args, env, limit, collect) {
|
|
|
5613
6893
|
const errors = (async () => {
|
|
5614
6894
|
for await (const _part of child.stderr) {}
|
|
5615
6895
|
})();
|
|
5616
|
-
const hash =
|
|
6896
|
+
const hash = createHash16("sha256"), chunks = [];
|
|
5617
6897
|
let size = 0;
|
|
5618
6898
|
try {
|
|
5619
6899
|
for await (const part of child.stdout) {
|
|
@@ -5636,7 +6916,7 @@ async function command2(args, env, limit, collect) {
|
|
|
5636
6916
|
}
|
|
5637
6917
|
}
|
|
5638
6918
|
async function listArchive(archive, platform, env) {
|
|
5639
|
-
const archiveInfo = await
|
|
6919
|
+
const archiveInfo = await lstat12(archive);
|
|
5640
6920
|
if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1)
|
|
5641
6921
|
throw new Error("Invalid staged archive");
|
|
5642
6922
|
const version = await command2(["tar", "--version"], cleanEnv2(env, false), 65536, true);
|
|
@@ -5667,7 +6947,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
5667
6947
|
failure ??= new Error("Archive member missing or ambiguous");
|
|
5668
6948
|
return entry.resume();
|
|
5669
6949
|
}
|
|
5670
|
-
const hash =
|
|
6950
|
+
const hash = createHash16("sha256"), chunks = [];
|
|
5671
6951
|
const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
|
|
5672
6952
|
members.set(entry.path, member);
|
|
5673
6953
|
entry.on("data", (chunk) => {
|
|
@@ -5682,7 +6962,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
5682
6962
|
});
|
|
5683
6963
|
}
|
|
5684
6964
|
});
|
|
5685
|
-
const ended =
|
|
6965
|
+
const ended = once2(parser, "end");
|
|
5686
6966
|
ended.catch(() => {
|
|
5687
6967
|
return;
|
|
5688
6968
|
});
|
|
@@ -5693,7 +6973,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
5693
6973
|
parser.on("error", (error) => inflate.destroy(error));
|
|
5694
6974
|
for await (const chunk of input.pipe(inflate)) {
|
|
5695
6975
|
if (!parser.write(chunk))
|
|
5696
|
-
await
|
|
6976
|
+
await once2(parser, "drain");
|
|
5697
6977
|
}
|
|
5698
6978
|
parser.end();
|
|
5699
6979
|
await ended;
|
|
@@ -5705,14 +6985,14 @@ async function readMembers(archive, limits, collect) {
|
|
|
5705
6985
|
return members;
|
|
5706
6986
|
}
|
|
5707
6987
|
async function installed(path, root, limit) {
|
|
5708
|
-
const info = await
|
|
5709
|
-
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await
|
|
6988
|
+
const info = await lstat12(path);
|
|
6989
|
+
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await realpath5(path)))
|
|
5710
6990
|
throw new Error("Invalid installed file");
|
|
5711
6991
|
const { size, sha256 } = await hashFileAt(path, info, "Installed file changed");
|
|
5712
6992
|
return { digest: sha256, size };
|
|
5713
6993
|
}
|
|
5714
6994
|
async function assertRuntimeBinary(path, platform) {
|
|
5715
|
-
const info = await
|
|
6995
|
+
const info = await lstat12(path), file = await open5(path, "r");
|
|
5716
6996
|
try {
|
|
5717
6997
|
await assertNativeExecutable(file, info.size, platform, "runtime executable");
|
|
5718
6998
|
} finally {
|
|
@@ -5726,8 +7006,8 @@ async function verifyInstalledPayload(options) {
|
|
|
5726
7006
|
const sidecars = assertSidecarNames(options.sidecars ?? [], options.platform).map((name) => sidecarBundlePath(name, options.platform));
|
|
5727
7007
|
if (!/^\d+\.\d+\.\d+$/.test(options.version) || options.version.length > 64)
|
|
5728
7008
|
throw new Error("Invalid installed version");
|
|
5729
|
-
const profile = await
|
|
5730
|
-
if (!(await
|
|
7009
|
+
const profile = await realpath5(options.profile), root = await realpath5(options.installedRoot), archive = resolve13(options.archive);
|
|
7010
|
+
if (!(await lstat12(profile)).isDirectory() || !(await lstat12(root)).isDirectory() || !isWithin(profile, root))
|
|
5731
7011
|
throw new Error("Installed root escapes isolated profile");
|
|
5732
7012
|
const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
|
|
5733
7013
|
assertPayloadLayout({
|
|
@@ -5737,7 +7017,7 @@ async function verifyInstalledPayload(options) {
|
|
|
5737
7017
|
entries,
|
|
5738
7018
|
sidecars: options.sidecars ?? []
|
|
5739
7019
|
});
|
|
5740
|
-
const mac = options.platform
|
|
7020
|
+
const mac = isMacInstallerPlatform(options.platform), prefix = mac ? `${options.appName}.app/Contents` : options.appName.replaceAll(" ", ""), suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
5741
7021
|
const bin = mac ? "MacOS" : "bin";
|
|
5742
7022
|
const files = [
|
|
5743
7023
|
`${bin}/launcher${suffix}`,
|
|
@@ -5761,7 +7041,7 @@ async function verifyInstalledPayload(options) {
|
|
|
5761
7041
|
const member = members.get(path);
|
|
5762
7042
|
if (!member || member.count !== 1)
|
|
5763
7043
|
throw new Error("Archive member missing or ambiguous");
|
|
5764
|
-
const current = await installed(
|
|
7044
|
+
const current = await installed(join20(root, name), root, limit);
|
|
5765
7045
|
if (member.size !== current.size || member.digest !== current.digest)
|
|
5766
7046
|
throw new Error(`Installed file differs from archive: ${name}`);
|
|
5767
7047
|
if (name === "Resources/version.json") {
|
|
@@ -5783,8 +7063,8 @@ async function extractCandidateRuntime(options) {
|
|
|
5783
7063
|
const temp = runnerTemp(env);
|
|
5784
7064
|
if (!temp)
|
|
5785
7065
|
throw new Error("Missing runner temp directory");
|
|
5786
|
-
const tempRoot = await
|
|
5787
|
-
if (!isWithin(tempRoot, profile) || !(await
|
|
7066
|
+
const tempRoot = await realpath5(temp), profile = await realpath5(options.profile), archive = resolve13(options.archive);
|
|
7067
|
+
if (!isWithin(tempRoot, profile) || !(await lstat12(profile)).isDirectory())
|
|
5788
7068
|
throw new Error("Runtime profile escapes runner temp");
|
|
5789
7069
|
const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
|
|
5790
7070
|
assertPayloadLayout({
|
|
@@ -5793,10 +7073,10 @@ async function extractCandidateRuntime(options) {
|
|
|
5793
7073
|
appName: options.appName,
|
|
5794
7074
|
entries
|
|
5795
7075
|
});
|
|
5796
|
-
const prefix = options.platform
|
|
7076
|
+
const prefix = isMacInstallerPlatform(options.platform) ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
5797
7077
|
const expected = `${prefix}/bun${suffix}`;
|
|
5798
7078
|
const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
|
|
5799
|
-
const destination =
|
|
7079
|
+
const destination = join20(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
|
|
5800
7080
|
const spawn = () => Bun.spawn({
|
|
5801
7081
|
cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
|
|
5802
7082
|
env: tarEnv,
|
|
@@ -5809,7 +7089,7 @@ async function extractCandidateRuntime(options) {
|
|
|
5809
7089
|
const child = spawn(), errors = (async () => {
|
|
5810
7090
|
for await (const _part of child.stderr) {}
|
|
5811
7091
|
})();
|
|
5812
|
-
const hash =
|
|
7092
|
+
const hash = createHash16("sha256");
|
|
5813
7093
|
let size = 0;
|
|
5814
7094
|
try {
|
|
5815
7095
|
for await (const part of child.stdout) {
|
|
@@ -5846,14 +7126,14 @@ async function extractCandidateRuntime(options) {
|
|
|
5846
7126
|
} finally {
|
|
5847
7127
|
await output.close();
|
|
5848
7128
|
if (!successful)
|
|
5849
|
-
await
|
|
7129
|
+
await rm7(destination, { force: true });
|
|
5850
7130
|
}
|
|
5851
7131
|
}
|
|
5852
7132
|
|
|
5853
7133
|
// ../../src/installer/installer-process-cleanup.ts
|
|
5854
|
-
import { execFile as
|
|
5855
|
-
import { realpath as
|
|
5856
|
-
import { promisify } from "util";
|
|
7134
|
+
import { execFile as execFile3 } from "child_process";
|
|
7135
|
+
import { realpath as realpath6 } from "fs/promises";
|
|
7136
|
+
import { promisify as promisify3 } from "util";
|
|
5857
7137
|
|
|
5858
7138
|
// ../../src/native/windows-process.ts
|
|
5859
7139
|
import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
|
|
@@ -5897,7 +7177,7 @@ function windowsProcessImage(pid, options) {
|
|
|
5897
7177
|
}
|
|
5898
7178
|
|
|
5899
7179
|
// ../../src/installer/installer-process-cleanup.ts
|
|
5900
|
-
var execute =
|
|
7180
|
+
var execute = promisify3(execFile3);
|
|
5901
7181
|
async function terminateGuardedWorker(options) {
|
|
5902
7182
|
const { pid, runtime, platform } = options;
|
|
5903
7183
|
assertInstallerContext(options.env, platform, process.platform, process.arch);
|
|
@@ -5918,7 +7198,7 @@ async function terminateGuardedWorker(options) {
|
|
|
5918
7198
|
])
|
|
5919
7199
|
if (options.env[name])
|
|
5920
7200
|
env[name] = options.env[name];
|
|
5921
|
-
const expected = await
|
|
7201
|
+
const expected = await realpath6(runtime);
|
|
5922
7202
|
const actual = await runningExecutable(pid, platform, env);
|
|
5923
7203
|
if (actual === undefined)
|
|
5924
7204
|
return;
|
|
@@ -5929,7 +7209,7 @@ async function terminateGuardedWorker(options) {
|
|
|
5929
7209
|
}
|
|
5930
7210
|
const deadline = performance.now() + 5000;
|
|
5931
7211
|
while (performance.now() < deadline) {
|
|
5932
|
-
if (platform
|
|
7212
|
+
if (isMacInstallerPlatform(platform) ? await macosWorkerExited(() => readMacosState(pid, env)) : await runningExecutable(pid, platform, env) === undefined)
|
|
5933
7213
|
return;
|
|
5934
7214
|
await Bun.sleep(100);
|
|
5935
7215
|
}
|
|
@@ -5969,12 +7249,12 @@ async function readMacosState(pid, env) {
|
|
|
5969
7249
|
}
|
|
5970
7250
|
async function runningExecutable(pid, platform, env) {
|
|
5971
7251
|
if (platform === "linux-x64" || platform === "linux-arm64")
|
|
5972
|
-
return
|
|
7252
|
+
return realpath6(`/proc/${pid}/exe`).catch((error) => {
|
|
5973
7253
|
if (error.code === "ENOENT")
|
|
5974
7254
|
return;
|
|
5975
7255
|
throw error;
|
|
5976
7256
|
});
|
|
5977
|
-
if (platform
|
|
7257
|
+
if (isMacInstallerPlatform(platform)) {
|
|
5978
7258
|
const listed = await execute("/bin/ps", ["-p", String(pid), "-o", "stat=", "-o", "comm="], {
|
|
5979
7259
|
env,
|
|
5980
7260
|
timeout: 5000,
|
|
@@ -5987,7 +7267,7 @@ async function runningExecutable(pid, platform, env) {
|
|
|
5987
7267
|
if (!listed)
|
|
5988
7268
|
return;
|
|
5989
7269
|
const state = macosProcess(listed.stdout);
|
|
5990
|
-
return state === EXITING || state === undefined ? state :
|
|
7270
|
+
return state === EXITING || state === undefined ? state : realpath6(state);
|
|
5991
7271
|
}
|
|
5992
7272
|
return windowsRunningExecutable(pid);
|
|
5993
7273
|
}
|
|
@@ -5998,12 +7278,12 @@ async function windowsRunningExecutable(pid) {
|
|
|
5998
7278
|
} catch (error) {
|
|
5999
7279
|
throw new Error("Unable to query guarded process executable", { cause: error });
|
|
6000
7280
|
}
|
|
6001
|
-
return image === "missing" ? undefined :
|
|
7281
|
+
return image === "missing" ? undefined : realpath6(image);
|
|
6002
7282
|
}
|
|
6003
7283
|
|
|
6004
7284
|
// ../../src/updates/install/update-swap-stage.ts
|
|
6005
|
-
import { lstat as
|
|
6006
|
-
import { join as
|
|
7285
|
+
import { lstat as lstat18, mkdtemp as mkdtemp9, readFile as readFile10, realpath as realpath8, rm as rm9 } from "fs/promises";
|
|
7286
|
+
import { join as join30 } from "path";
|
|
6007
7287
|
|
|
6008
7288
|
// ../../src/updates/install/update-handoff-plan.ts
|
|
6009
7289
|
import { basename as basename6 } from "path";
|
|
@@ -6022,13 +7302,14 @@ function planUpdateHandoff(options) {
|
|
|
6022
7302
|
assertPortableAppName(appName);
|
|
6023
7303
|
const expected = {
|
|
6024
7304
|
"macos-arm64": ["darwin", "arm64"],
|
|
7305
|
+
"macos-x64": ["darwin", "x64"],
|
|
6025
7306
|
"windows-x64": ["win32", "x64"],
|
|
6026
7307
|
"linux-x64": ["linux", "x64"],
|
|
6027
7308
|
"linux-arm64": ["linux", "arm64"]
|
|
6028
7309
|
};
|
|
6029
7310
|
if (!expected[platform] || !["native", "cef"].includes(renderer) || !isVerifiedReleaseForTrust(descriptor, trust) || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || approved !== true || approvedVersion !== descriptor.version || !isReleaseVersion(currentVersion) || !versionLessThan(currentVersion, descriptor.version))
|
|
6030
7311
|
throw new Error("Invalid approved update");
|
|
6031
|
-
const name = platform
|
|
7312
|
+
const name = isMacInstallerPlatform(platform) ? `${appName}.app` : "app";
|
|
6032
7313
|
if (!isCanonicalPath(target) || basename6(target) !== name)
|
|
6033
7314
|
throw new Error("Invalid update target");
|
|
6034
7315
|
return Object.freeze({
|
|
@@ -6042,10 +7323,10 @@ function planUpdateHandoff(options) {
|
|
|
6042
7323
|
}
|
|
6043
7324
|
|
|
6044
7325
|
// ../../src/updates/install/update-extraction.ts
|
|
6045
|
-
import { createHash as
|
|
7326
|
+
import { createHash as createHash17 } from "crypto";
|
|
6046
7327
|
import { constants as constants4 } from "fs";
|
|
6047
|
-
import { lstat as
|
|
6048
|
-
import { isAbsolute as
|
|
7328
|
+
import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp8, open as open6, readFile as readFile8, realpath as realpath7, rm as rm8, symlink } from "fs/promises";
|
|
7329
|
+
import { isAbsolute as isAbsolute6, join as join21 } from "path";
|
|
6049
7330
|
import { Transform } from "stream";
|
|
6050
7331
|
import { pipeline } from "stream/promises";
|
|
6051
7332
|
import { createZstdDecompress as createZstdDecompress2 } from "zlib";
|
|
@@ -6066,33 +7347,40 @@ function isLinuxCefLibraryLink(path, target) {
|
|
|
6066
7347
|
}
|
|
6067
7348
|
|
|
6068
7349
|
// ../../src/updates/install/update-extraction.ts
|
|
7350
|
+
var expectedPlatform = {
|
|
7351
|
+
"macos-arm64": ["darwin", "arm64"],
|
|
7352
|
+
"macos-x64": ["darwin", "x64"],
|
|
7353
|
+
"windows-x64": ["win32", "x64"],
|
|
7354
|
+
"linux-x64": ["linux", "x64"],
|
|
7355
|
+
"linux-arm64": ["linux", "arm64"]
|
|
7356
|
+
};
|
|
6069
7357
|
async function extractVerifiedUpdate(options) {
|
|
6070
|
-
const { descriptor,
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
};
|
|
6077
|
-
if (!
|
|
7358
|
+
const { descriptor, platform } = options;
|
|
7359
|
+
if (!isVerifiedRelease(descriptor) || !expectedPlatform[platform] || descriptor.platform !== expectedPlatform[platform][0] || descriptor.arch !== expectedPlatform[platform][1])
|
|
7360
|
+
throw new Error("Invalid update extraction context");
|
|
7361
|
+
return extractBoundArchive(options, descriptor, async (file) => verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor));
|
|
7362
|
+
}
|
|
7363
|
+
async function extractBoundArchive(options, descriptor, verifyBeforeExtraction) {
|
|
7364
|
+
const { archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } = options;
|
|
7365
|
+
if (!isAbsolute6(archive) || !isAbsolute6(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || !Number.isSafeInteger(descriptor.asset.size) || descriptor.asset.size < 1 || descriptor.asset.size > maxCompressedBytes || !/^[a-f0-9]{64}$/.test(descriptor.asset.sha256) || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
|
|
6078
7366
|
throw new Error("Invalid update extraction context");
|
|
6079
7367
|
assertPortableAppName(appName);
|
|
6080
7368
|
const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
|
|
6081
|
-
const archiveRoot = platform
|
|
6082
|
-
const info = await
|
|
7369
|
+
const archiveRoot = isMacInstallerPlatform(platform) ? `${appName}.app` : appName.replaceAll(" ", "");
|
|
7370
|
+
const info = await lstat13(archive);
|
|
6083
7371
|
if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
|
|
6084
7372
|
throw new Error("Invalid update archive");
|
|
6085
7373
|
const file = await open6(archive, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
|
|
6086
7374
|
let directory;
|
|
6087
7375
|
try {
|
|
6088
7376
|
const before = await file.stat();
|
|
6089
|
-
if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || !await
|
|
7377
|
+
if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || verifyBeforeExtraction && !await verifyBeforeExtraction(file))
|
|
6090
7378
|
throw new Error("Update archive verification failed");
|
|
6091
|
-
const parent = await
|
|
6092
|
-
if (!(await
|
|
7379
|
+
const parent = await realpath7(options.directory);
|
|
7380
|
+
if (!(await lstat13(parent)).isDirectory())
|
|
6093
7381
|
throw new Error("Invalid update staging directory");
|
|
6094
|
-
directory = await
|
|
6095
|
-
const payloadRoot =
|
|
7382
|
+
directory = await mkdtemp8(join21(parent, "framework-update-extract-"));
|
|
7383
|
+
const payloadRoot = join21(directory, "payload"), decompressed = join21(directory, "payload.tar");
|
|
6096
7384
|
await mkdir7(payloadRoot, { mode: 448 });
|
|
6097
7385
|
const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
|
|
6098
7386
|
let invalid = false;
|
|
@@ -6110,7 +7398,7 @@ async function extractVerifiedUpdate(options) {
|
|
|
6110
7398
|
done(null, chunk);
|
|
6111
7399
|
}
|
|
6112
7400
|
});
|
|
6113
|
-
const hash =
|
|
7401
|
+
const hash = createHash17("sha256");
|
|
6114
7402
|
let compressedBytes = 0;
|
|
6115
7403
|
const verifyInput = new Transform({
|
|
6116
7404
|
transform(chunk, _encoding, done) {
|
|
@@ -6210,27 +7498,27 @@ async function extractVerifiedUpdate(options) {
|
|
|
6210
7498
|
if (invalid)
|
|
6211
7499
|
throw new Error("Unsafe or unsupported update archive entry");
|
|
6212
7500
|
if (links.length) {
|
|
6213
|
-
const bin =
|
|
6214
|
-
for (const path of [
|
|
6215
|
-
const value = await
|
|
7501
|
+
const bin = join21(payloadRoot, archiveRoot, "bin"), cef = join21(bin, "cef");
|
|
7502
|
+
for (const path of [join21(payloadRoot, archiveRoot), bin, cef]) {
|
|
7503
|
+
const value = await lstat13(path);
|
|
6216
7504
|
if (!value.isDirectory() || value.isSymbolicLink())
|
|
6217
7505
|
throw new Error("Invalid CEF link directory");
|
|
6218
7506
|
}
|
|
6219
7507
|
for (const link of links) {
|
|
6220
|
-
const destination =
|
|
7508
|
+
const destination = join21(payloadRoot, link.path), target = join21(bin, link.target), value = await lstat13(target);
|
|
6221
7509
|
if (!value.isFile() || value.isSymbolicLink())
|
|
6222
7510
|
throw new Error("Invalid CEF link target");
|
|
6223
7511
|
await symlink(link.target, destination);
|
|
6224
7512
|
}
|
|
6225
7513
|
}
|
|
6226
|
-
await
|
|
7514
|
+
await rm8(decompressed);
|
|
6227
7515
|
assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
|
|
6228
|
-
const prefix = platform
|
|
6229
|
-
const resources =
|
|
6230
|
-
const bin = platform
|
|
7516
|
+
const prefix = isMacInstallerPlatform(platform) ? join21(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
|
|
7517
|
+
const resources = join21(payloadRoot, prefix, "Resources");
|
|
7518
|
+
const bin = isMacInstallerPlatform(platform) ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
|
|
6231
7519
|
const executables = [
|
|
6232
|
-
|
|
6233
|
-
|
|
7520
|
+
join21(bin, `launcher${suffix}`),
|
|
7521
|
+
join21(bin, `bun${suffix}`),
|
|
6234
7522
|
...sidecars.map((name) => sidecarBundlePath(name, platform))
|
|
6235
7523
|
];
|
|
6236
7524
|
const critical = [
|
|
@@ -6240,25 +7528,25 @@ async function extractVerifiedUpdate(options) {
|
|
|
6240
7528
|
"Resources/app/client/index.html"
|
|
6241
7529
|
];
|
|
6242
7530
|
for (const path of critical) {
|
|
6243
|
-
const item = await
|
|
7531
|
+
const item = await lstat13(join21(payloadRoot, prefix, path));
|
|
6244
7532
|
if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
|
|
6245
7533
|
throw new Error("Invalid critical update file");
|
|
6246
7534
|
}
|
|
6247
7535
|
for (const name of ["version.json", "build.json"]) {
|
|
6248
|
-
const metadata = await
|
|
7536
|
+
const metadata = await lstat13(join21(resources, name));
|
|
6249
7537
|
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
|
|
6250
7538
|
throw new Error("Invalid update metadata");
|
|
6251
7539
|
}
|
|
6252
|
-
if (JSON.parse(await
|
|
7540
|
+
if (JSON.parse(await readFile8(join21(resources, "version.json"), "utf8")).version !== descriptor.version)
|
|
6253
7541
|
throw new Error("Update version mismatch");
|
|
6254
|
-
assertBuildMetadata(JSON.parse(await
|
|
7542
|
+
assertBuildMetadata(JSON.parse(await readFile8(join21(resources, "build.json"), "utf8")), renderer);
|
|
6255
7543
|
return {
|
|
6256
7544
|
directory,
|
|
6257
|
-
payload:
|
|
7545
|
+
payload: join21(payloadRoot, isMacInstallerPlatform(platform) ? `${appName}.app` : prefix)
|
|
6258
7546
|
};
|
|
6259
7547
|
} catch (error) {
|
|
6260
7548
|
if (directory)
|
|
6261
|
-
await
|
|
7549
|
+
await rm8(directory, { recursive: true, force: true });
|
|
6262
7550
|
throw error;
|
|
6263
7551
|
} finally {
|
|
6264
7552
|
await file.close();
|
|
@@ -6266,19 +7554,19 @@ async function extractVerifiedUpdate(options) {
|
|
|
6266
7554
|
}
|
|
6267
7555
|
|
|
6268
7556
|
// ../../src/updates/install/update-swap.ts
|
|
6269
|
-
import { createHash as
|
|
7557
|
+
import { createHash as createHash18 } from "crypto";
|
|
6270
7558
|
import { constants as constants7 } from "fs";
|
|
6271
|
-
import { lstat as
|
|
6272
|
-
import { basename as basename8, dirname as dirname6, join as
|
|
7559
|
+
import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile9, readlink as readlink2 } from "fs/promises";
|
|
7560
|
+
import { basename as basename8, dirname as dirname6, join as join24 } from "path";
|
|
6273
7561
|
|
|
6274
7562
|
// ../../src/updates/update-state-store.ts
|
|
6275
7563
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6276
7564
|
import { constants as constants6 } from "fs";
|
|
6277
|
-
import { open as open8, rename, unlink, writeFile as
|
|
6278
|
-
import { join as
|
|
7565
|
+
import { open as open8, rename, unlink, writeFile as writeFile6 } from "fs/promises";
|
|
7566
|
+
import { join as join23 } from "path";
|
|
6279
7567
|
|
|
6280
7568
|
// ../../src/updates/locks/update-lock.ts
|
|
6281
|
-
import { basename as basename7, dirname as dirname5, join as
|
|
7569
|
+
import { basename as basename7, dirname as dirname5, join as join22 } from "path";
|
|
6282
7570
|
|
|
6283
7571
|
// ../../src/updates/locks/native-file-lock.ts
|
|
6284
7572
|
import { constants as constants5 } from "fs";
|
|
@@ -6446,7 +7734,7 @@ async function tryAcquireWindows(path, mode) {
|
|
|
6446
7734
|
function updateLockPath(target) {
|
|
6447
7735
|
if (!isCanonicalPath(target))
|
|
6448
7736
|
throw new Error("Invalid update lock target");
|
|
6449
|
-
return
|
|
7737
|
+
return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
|
|
6450
7738
|
}
|
|
6451
7739
|
async function tryAcquireUpdateLock(target) {
|
|
6452
7740
|
return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
|
|
@@ -6511,7 +7799,7 @@ function parseState(value) {
|
|
|
6511
7799
|
return Object.freeze(record);
|
|
6512
7800
|
}
|
|
6513
7801
|
async function readUpdateStageState(staging) {
|
|
6514
|
-
const text = await readSmallStateFile(
|
|
7802
|
+
const text = await readSmallStateFile(join23(staging, "state.json"), 4096, "Invalid update staging state");
|
|
6515
7803
|
return text === undefined ? undefined : parseState(JSON.parse(text));
|
|
6516
7804
|
}
|
|
6517
7805
|
async function writeUpdateStageState(staging, state) {
|
|
@@ -6520,8 +7808,8 @@ async function writeUpdateStageState(staging, state) {
|
|
|
6520
7808
|
async function replaceUpdateStageState(staging, state, durable) {
|
|
6521
7809
|
if (typeof state.generation !== "string" || !isUuid(state.generation))
|
|
6522
7810
|
throw new Error("Invalid update staging state");
|
|
6523
|
-
const path =
|
|
6524
|
-
const temporary =
|
|
7811
|
+
const path = join23(staging, "state.json");
|
|
7812
|
+
const temporary = join23(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
|
|
6525
7813
|
const contents = JSON.stringify(state) + `
|
|
6526
7814
|
`;
|
|
6527
7815
|
let renamed = false;
|
|
@@ -6535,7 +7823,7 @@ async function replaceUpdateStageState(staging, state, durable) {
|
|
|
6535
7823
|
await file.close();
|
|
6536
7824
|
}
|
|
6537
7825
|
} else
|
|
6538
|
-
await
|
|
7826
|
+
await writeFile6(temporary, contents, { flag: "wx", mode: 384 });
|
|
6539
7827
|
await rename(temporary, path);
|
|
6540
7828
|
renamed = true;
|
|
6541
7829
|
if (durable)
|
|
@@ -6559,12 +7847,12 @@ async function withUpdateLock(target, operation) {
|
|
|
6559
7847
|
function updateStagingFor(target) {
|
|
6560
7848
|
if (!isCanonicalPath(target))
|
|
6561
7849
|
throw new Error("Invalid update target");
|
|
6562
|
-
return
|
|
7850
|
+
return join24(dirname6(target), `.${basename8(target)}.framework-update`);
|
|
6563
7851
|
}
|
|
6564
7852
|
async function readUpdateTreeVersion(tree) {
|
|
6565
|
-
const versionPath =
|
|
7853
|
+
const versionPath = join24(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
6566
7854
|
try {
|
|
6567
|
-
const value = JSON.parse(await
|
|
7855
|
+
const value = JSON.parse(await readFile9(versionPath, "utf8"));
|
|
6568
7856
|
if (typeof value !== "object" || value === null || typeof value.version !== "string")
|
|
6569
7857
|
return;
|
|
6570
7858
|
return value.version;
|
|
@@ -6578,7 +7866,7 @@ function updateTreeIdentityFromStat(info) {
|
|
|
6578
7866
|
return { device: info.dev.toString(10), inode: info.ino.toString(10) };
|
|
6579
7867
|
}
|
|
6580
7868
|
async function readUpdateTreeIdentity(tree) {
|
|
6581
|
-
const info = await
|
|
7869
|
+
const info = await lstat14(tree, { bigint: true });
|
|
6582
7870
|
return updateTreeIdentityFromStat(info);
|
|
6583
7871
|
}
|
|
6584
7872
|
function sameUpdateTreeIdentity(left, right) {
|
|
@@ -6622,9 +7910,9 @@ async function readTreeFileBytes(file, buffer, length, position) {
|
|
|
6622
7910
|
}
|
|
6623
7911
|
async function readUpdateTreeDigest(tree, options = {}) {
|
|
6624
7912
|
const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
|
|
6625
|
-
const hash =
|
|
7913
|
+
const hash = createHash18("sha256");
|
|
6626
7914
|
hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
|
|
6627
|
-
const root = await
|
|
7915
|
+
const root = await lstat14(tree, { bigint: true });
|
|
6628
7916
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
6629
7917
|
throw new Error("Update tree is not a real directory");
|
|
6630
7918
|
const rootDevice = root.dev;
|
|
@@ -6654,10 +7942,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6654
7942
|
if (before.isSymbolicLink())
|
|
6655
7943
|
return [{ kind: "symlink", path, relative, before }];
|
|
6656
7944
|
if (before.isDirectory()) {
|
|
6657
|
-
const names = (await limit(() =>
|
|
7945
|
+
const names = (await limit(() => readdir8(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
|
|
6658
7946
|
const children = await Promise.all(names.map(async (name) => {
|
|
6659
|
-
const childPath =
|
|
6660
|
-
return list(childPath, relative ? `${relative}/${name}` : name, await limit(() =>
|
|
7947
|
+
const childPath = join24(path, name);
|
|
7948
|
+
return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat14(childPath, { bigint: true })));
|
|
6661
7949
|
}));
|
|
6662
7950
|
return [{ kind: "directory", path, relative, before }, ...children.flat()];
|
|
6663
7951
|
}
|
|
@@ -6671,7 +7959,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6671
7959
|
return { kind: "none" };
|
|
6672
7960
|
if (entry.kind === "symlink") {
|
|
6673
7961
|
const target = Buffer.from(await readlink2(path), "utf8");
|
|
6674
|
-
const after = await
|
|
7962
|
+
const after = await lstat14(path, { bigint: true });
|
|
6675
7963
|
if (!sameTreeEntrySnapshot(before, after))
|
|
6676
7964
|
throw new Error("Update tree changed while reading a symbolic link");
|
|
6677
7965
|
return { kind: "bytes", bytes: target };
|
|
@@ -6690,7 +7978,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6690
7978
|
const size = Number(before.size);
|
|
6691
7979
|
const bytes = Buffer.allocUnsafe(size);
|
|
6692
7980
|
await readTreeFileBytes(file, bytes, size, 0);
|
|
6693
|
-
if (!sameTreeEntrySnapshot(before, await
|
|
7981
|
+
if (!sameTreeEntrySnapshot(before, await lstat14(path, { bigint: true })))
|
|
6694
7982
|
throw new Error("Update tree changed while reading a file");
|
|
6695
7983
|
return { kind: "bytes", bytes };
|
|
6696
7984
|
} finally {
|
|
@@ -6759,7 +8047,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6759
8047
|
position = nextPosition;
|
|
6760
8048
|
index = nextIndex;
|
|
6761
8049
|
}
|
|
6762
|
-
if (!sameTreeEntrySnapshot(entry.before, await
|
|
8050
|
+
if (!sameTreeEntrySnapshot(entry.before, await lstat14(entry.path, { bigint: true })))
|
|
6763
8051
|
throw new Error("Update tree changed while reading a file");
|
|
6764
8052
|
} finally {
|
|
6765
8053
|
await file.close();
|
|
@@ -6775,11 +8063,11 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6775
8063
|
await Promise.all(entries.map(async (entry) => {
|
|
6776
8064
|
if (entry.kind !== "directory" || entry.relative === "")
|
|
6777
8065
|
return;
|
|
6778
|
-
const after = await limit(() =>
|
|
8066
|
+
const after = await limit(() => lstat14(entry.path, { bigint: true }));
|
|
6779
8067
|
if (!sameTreeEntrySnapshot(entry.before, after))
|
|
6780
8068
|
throw new Error("Update tree changed while reading a directory");
|
|
6781
8069
|
}));
|
|
6782
|
-
const finalRoot = await
|
|
8070
|
+
const finalRoot = await lstat14(tree, { bigint: true });
|
|
6783
8071
|
if (!sameTreeEntrySnapshot(root, finalRoot))
|
|
6784
8072
|
throw new Error("Update tree changed while its digest was computed");
|
|
6785
8073
|
const count = Buffer.allocUnsafe(8);
|
|
@@ -6788,7 +8076,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6788
8076
|
return hash.digest("hex");
|
|
6789
8077
|
}
|
|
6790
8078
|
async function assertDirectory(path) {
|
|
6791
|
-
const info = await
|
|
8079
|
+
const info = await lstat14(path);
|
|
6792
8080
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
6793
8081
|
throw new Error("Update exchange requires real directories");
|
|
6794
8082
|
}
|
|
@@ -6799,8 +8087,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6799
8087
|
const { target, staging } = options;
|
|
6800
8088
|
if (dirname6(staging) !== dirname6(target) || staging === target)
|
|
6801
8089
|
throw new Error("Invalid update swap context");
|
|
6802
|
-
const candidate =
|
|
6803
|
-
const legacyOld =
|
|
8090
|
+
const candidate = join24(staging, "candidate");
|
|
8091
|
+
const legacyOld = join24(staging, "old");
|
|
6804
8092
|
if (await pathExists(legacyOld))
|
|
6805
8093
|
throw new Error("A legacy update tree requires recovery before another swap");
|
|
6806
8094
|
await assertDirectory(target);
|
|
@@ -6829,11 +8117,11 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6829
8117
|
}
|
|
6830
8118
|
|
|
6831
8119
|
// ../../src/updates/retention/retirement-inventory.ts
|
|
6832
|
-
import { lstat as
|
|
6833
|
-
import { basename as basename12, dirname as dirname10, join as
|
|
8120
|
+
import { lstat as lstat16, readdir as readdir10 } from "fs/promises";
|
|
8121
|
+
import { basename as basename12, dirname as dirname10, join as join28 } from "path";
|
|
6834
8122
|
|
|
6835
8123
|
// ../../src/updates/retention/update-retention-marker.ts
|
|
6836
|
-
import { basename as basename9, dirname as dirname7, join as
|
|
8124
|
+
import { basename as basename9, dirname as dirname7, join as join25 } from "path";
|
|
6837
8125
|
var LOWERCASE_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6838
8126
|
var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
|
|
6839
8127
|
function assertCanonicalTarget(target) {
|
|
@@ -6852,28 +8140,28 @@ function isTreeIdentity(value) {
|
|
|
6852
8140
|
function updateRetentionIntentPath(target, generation) {
|
|
6853
8141
|
assertCanonicalTarget(target);
|
|
6854
8142
|
assertGeneration(generation);
|
|
6855
|
-
return
|
|
8143
|
+
return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
|
|
6856
8144
|
}
|
|
6857
8145
|
|
|
6858
8146
|
// ../../src/updates/retention/retention-prune-progress.ts
|
|
6859
|
-
import { basename as basename11, dirname as dirname9, join as
|
|
8147
|
+
import { basename as basename11, dirname as dirname9, join as join27 } from "path";
|
|
6860
8148
|
|
|
6861
8149
|
// ../../src/updates/retention/retirement-records.ts
|
|
6862
|
-
import { lstat as
|
|
6863
|
-
import { basename as basename10, dirname as dirname8, join as
|
|
8150
|
+
import { lstat as lstat15, readdir as readdir9, writeFile as writeFile7 } from "fs/promises";
|
|
8151
|
+
import { basename as basename10, dirname as dirname8, join as join26 } from "path";
|
|
6864
8152
|
function updateRetirementPaths(target, generation) {
|
|
6865
8153
|
if (!isCanonicalPath(target) || !isUuid(generation))
|
|
6866
8154
|
throw new Error("Invalid update retirement identity");
|
|
6867
8155
|
const prefix = `.${basename10(target)}.framework-retired-${generation}`;
|
|
6868
|
-
const container =
|
|
8156
|
+
const container = join26(dirname8(target), prefix);
|
|
6869
8157
|
return Object.freeze({
|
|
6870
8158
|
container,
|
|
6871
|
-
tree:
|
|
6872
|
-
healthReceipt:
|
|
8159
|
+
tree: join26(container, "tree"),
|
|
8160
|
+
healthReceipt: join26(container, "healthy.json"),
|
|
6873
8161
|
healthTemporaryPrefix: ".healthy-",
|
|
6874
|
-
claim:
|
|
8162
|
+
claim: join26(dirname8(target), `${prefix}.claim.json`),
|
|
6875
8163
|
claimTemporaryPrefix: `${prefix}.claim-`,
|
|
6876
|
-
cleanupMarker:
|
|
8164
|
+
cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
|
|
6877
8165
|
cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
|
|
6878
8166
|
});
|
|
6879
8167
|
}
|
|
@@ -6924,7 +8212,7 @@ async function readCleanupMarker(path) {
|
|
|
6924
8212
|
}
|
|
6925
8213
|
async function pathInfo(path) {
|
|
6926
8214
|
try {
|
|
6927
|
-
return await
|
|
8215
|
+
return await lstat15(path);
|
|
6928
8216
|
} catch (error) {
|
|
6929
8217
|
if (errorCode(error) === "ENOENT")
|
|
6930
8218
|
return;
|
|
@@ -6972,15 +8260,15 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
|
|
|
6972
8260
|
async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
|
|
6973
8261
|
if (!isCanonicalPath(target) || !basename12(target))
|
|
6974
8262
|
throw new Error("Invalid update retention prune gate target");
|
|
6975
|
-
assertNoUnresolvedRetentionPruneArtifacts(target, await
|
|
8263
|
+
assertNoUnresolvedRetentionPruneArtifacts(target, await readdir10(dirname10(target)), {}, "update retention prune requires recovery before staging");
|
|
6976
8264
|
}
|
|
6977
8265
|
|
|
6978
8266
|
// ../../src/updates/retention/update-retirement.ts
|
|
6979
|
-
import { lstat as
|
|
6980
|
-
import { basename as basename13, dirname as dirname11, join as
|
|
8267
|
+
import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile8 } from "fs/promises";
|
|
8268
|
+
import { basename as basename13, dirname as dirname11, join as join29 } from "path";
|
|
6981
8269
|
async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
6982
8270
|
const { target, staging, currentVersion } = options;
|
|
6983
|
-
const markerPath =
|
|
8271
|
+
const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
|
|
6984
8272
|
const markerInfo = await pathInfo(markerPath);
|
|
6985
8273
|
if (!markerInfo)
|
|
6986
8274
|
return "none";
|
|
@@ -6997,14 +8285,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
|
6997
8285
|
const containerInfo = await pathInfo(paths.container);
|
|
6998
8286
|
if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
|
|
6999
8287
|
return "recovery-required";
|
|
7000
|
-
const containerEntries = await
|
|
8288
|
+
const containerEntries = await readdir11(paths.container);
|
|
7001
8289
|
if (containerEntries.length !== 1 || containerEntries[0] !== "tree")
|
|
7002
8290
|
return "recovery-required";
|
|
7003
8291
|
const stagingInfo = await pathInfo(staging);
|
|
7004
8292
|
if (stagingInfo) {
|
|
7005
8293
|
if (!stagingInfo.isDirectory() || stagingInfo.isSymbolicLink())
|
|
7006
8294
|
return "recovery-required";
|
|
7007
|
-
const stagingEntries = await
|
|
8295
|
+
const stagingEntries = await readdir11(staging);
|
|
7008
8296
|
if (stagingEntries.length !== 0)
|
|
7009
8297
|
return "recovery-required";
|
|
7010
8298
|
await rmdir(staging);
|
|
@@ -7018,20 +8306,21 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
|
7018
8306
|
|
|
7019
8307
|
// ../../src/updates/install/update-swap-stage.ts
|
|
7020
8308
|
async function assertInstalledVersion(options) {
|
|
7021
|
-
const info = await
|
|
7022
|
-
if (!info.isDirectory() || info.isSymbolicLink() || await
|
|
8309
|
+
const info = await lstat18(options.target);
|
|
8310
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(options.target) !== options.target)
|
|
7023
8311
|
throw new Error("Invalid update install target");
|
|
7024
|
-
const versionFile =
|
|
7025
|
-
const versionInfo = await
|
|
8312
|
+
const versionFile = join30(options.target, ...isMacInstallerPlatform(options.platform) ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
8313
|
+
const versionInfo = await lstat18(versionFile);
|
|
7026
8314
|
if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
|
|
7027
8315
|
throw new Error("Installed update version mismatch");
|
|
7028
|
-
if (JSON.parse(await
|
|
8316
|
+
if (JSON.parse(await readFile10(versionFile, "utf8")).version !== options.version)
|
|
7029
8317
|
throw new Error("Installed update version mismatch");
|
|
7030
8318
|
}
|
|
7031
8319
|
async function stageUpdateSwap(options) {
|
|
7032
8320
|
const plan = planUpdateHandoff(options);
|
|
7033
8321
|
const expectedHost = {
|
|
7034
8322
|
"macos-arm64": "darwin/arm64",
|
|
8323
|
+
"macos-x64": "darwin/x64",
|
|
7035
8324
|
"windows-x64": "win32/x64",
|
|
7036
8325
|
"linux-x64": "linux/x64",
|
|
7037
8326
|
"linux-arm64": "linux/arm64"
|
|
@@ -7044,8 +8333,8 @@ async function stageUpdateSwap(options) {
|
|
|
7044
8333
|
version: plan.currentVersion
|
|
7045
8334
|
});
|
|
7046
8335
|
const staging = updateStagingFor(plan.target);
|
|
7047
|
-
const preparing = await
|
|
7048
|
-
const candidate =
|
|
8336
|
+
const preparing = await mkdtemp9(`${staging}.preparing-`);
|
|
8337
|
+
const candidate = join30(staging, "candidate");
|
|
7049
8338
|
let published = false;
|
|
7050
8339
|
try {
|
|
7051
8340
|
const extracted = await extractVerifiedUpdate({
|
|
@@ -7059,12 +8348,12 @@ async function stageUpdateSwap(options) {
|
|
|
7059
8348
|
maxExpandedBytes: options.maxExpandedBytes,
|
|
7060
8349
|
...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
|
|
7061
8350
|
});
|
|
7062
|
-
renameExclusive(extracted.payload,
|
|
7063
|
-
await
|
|
7064
|
-
const candidateTreeIdentity = await readUpdateTreeIdentity(
|
|
8351
|
+
renameExclusive(extracted.payload, join30(preparing, "candidate"));
|
|
8352
|
+
await rm9(extracted.directory, { recursive: true, force: true });
|
|
8353
|
+
const candidateTreeIdentity = await readUpdateTreeIdentity(join30(preparing, "candidate"));
|
|
7065
8354
|
if (!candidateTreeIdentity)
|
|
7066
8355
|
throw new Error("Update candidate tree identity could not be read");
|
|
7067
|
-
const candidateTreeDigest = await readUpdateTreeDigest(
|
|
8356
|
+
const candidateTreeDigest = await readUpdateTreeDigest(join30(preparing, "candidate"));
|
|
7068
8357
|
await writeUpdateStageState(preparing, newUpdateStageState({
|
|
7069
8358
|
version: plan.version,
|
|
7070
8359
|
previousVersion: options.currentVersion,
|
|
@@ -7083,7 +8372,7 @@ async function stageUpdateSwap(options) {
|
|
|
7083
8372
|
});
|
|
7084
8373
|
let existingInfo;
|
|
7085
8374
|
try {
|
|
7086
|
-
existingInfo = await
|
|
8375
|
+
existingInfo = await lstat18(staging);
|
|
7087
8376
|
} catch (error) {
|
|
7088
8377
|
if (errorCode(error) === "ENOENT") {
|
|
7089
8378
|
const retirement = await reconcileRetirementCleanupMarkerWhileLocked({
|
|
@@ -7122,7 +8411,7 @@ async function stageUpdateSwap(options) {
|
|
|
7122
8411
|
return result;
|
|
7123
8412
|
} finally {
|
|
7124
8413
|
if (!published)
|
|
7125
|
-
await
|
|
8414
|
+
await rm9(preparing, { recursive: true, force: true });
|
|
7126
8415
|
}
|
|
7127
8416
|
}
|
|
7128
8417
|
|
|
@@ -7149,11 +8438,11 @@ function isolatedEnv(parent, profile, platform) {
|
|
|
7149
8438
|
RUNNER_ENVIRONMENT: "github-hosted",
|
|
7150
8439
|
HOME: profile,
|
|
7151
8440
|
USERPROFILE: profile,
|
|
7152
|
-
LOCALAPPDATA:
|
|
7153
|
-
XDG_DATA_HOME:
|
|
7154
|
-
TMP:
|
|
7155
|
-
TEMP:
|
|
7156
|
-
TMPDIR:
|
|
8441
|
+
LOCALAPPDATA: join31(profile, "LocalAppData"),
|
|
8442
|
+
XDG_DATA_HOME: join31(profile, ".local", "share"),
|
|
8443
|
+
TMP: join31(profile, "tmp"),
|
|
8444
|
+
TEMP: join31(profile, "tmp"),
|
|
8445
|
+
TMPDIR: join31(profile, "tmp"),
|
|
7157
8446
|
ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
|
|
7158
8447
|
});
|
|
7159
8448
|
if (platform === "windows-x64")
|
|
@@ -7190,7 +8479,7 @@ async function boundedStderr(stream, limit = 64 * 1024) {
|
|
|
7190
8479
|
return text.slice(-limit);
|
|
7191
8480
|
}
|
|
7192
8481
|
function shouldLaunchInstalledApp(state) {
|
|
7193
|
-
return state.platform
|
|
8482
|
+
return isMacInstallerPlatform(state.platform) && state.ready && !state.launched && !state.acknowledged && state.installerExit === 0;
|
|
7194
8483
|
}
|
|
7195
8484
|
var shim = `#!/bin/sh
|
|
7196
8485
|
umask 077
|
|
@@ -7248,15 +8537,15 @@ async function observeInstalledApp(options) {
|
|
|
7248
8537
|
await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
|
|
7249
8538
|
stage("runtime-preflight-passed");
|
|
7250
8539
|
for (const path of [
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
8540
|
+
join31(prepared.profile, "LocalAppData"),
|
|
8541
|
+
join31(prepared.profile, ".local", "share"),
|
|
8542
|
+
join31(prepared.profile, "tmp")
|
|
7254
8543
|
])
|
|
7255
8544
|
await mkdir9(path, { recursive: true, mode: 448 });
|
|
7256
|
-
const mac = options.platform
|
|
7257
|
-
const installedRoot = mac ?
|
|
7258
|
-
const resources =
|
|
7259
|
-
const worker =
|
|
8545
|
+
const mac = isMacInstallerPlatform(options.platform), windows = options.platform === "windows-x64";
|
|
8546
|
+
const installedRoot = mac ? join31(prepared.incoming, `${options.appName}.app`, "Contents") : join31(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
|
|
8547
|
+
const resources = join31(installedRoot, "Resources"), binary = join31(installedRoot, mac ? "MacOS" : "bin"), launcher = join31(binary, windows ? "launcher.exe" : "launcher"), runtime = join31(binary, windows ? "bun.exe" : "bun");
|
|
8548
|
+
const worker = join31(resources, "app", "bun", "index.js");
|
|
7260
8549
|
const sidecars = options.sidecars ?? [];
|
|
7261
8550
|
let foreignHits = 0;
|
|
7262
8551
|
const sentinel = policy ? Bun.serve({
|
|
@@ -7306,8 +8595,8 @@ async function observeInstalledApp(options) {
|
|
|
7306
8595
|
if (sentinel && (!(await fetch(foreignOrigin + "/", { signal: AbortSignal.timeout(1000) })).ok || foreignHits !== 1))
|
|
7307
8596
|
throw new Error("Foreign network sentinel unavailable");
|
|
7308
8597
|
foreignHits = 0;
|
|
7309
|
-
const nonce =
|
|
7310
|
-
const ack =
|
|
8598
|
+
const nonce = randomBytes3(24).toString("hex");
|
|
8599
|
+
const ack = join31(run.directory, "ack"), permit = join31(run.directory, "permit"), observation = join31(run.directory, "observation"), unexpected = join31(run.directory, "unexpected"), pidRecord = join31(run.directory, "worker-pid");
|
|
7311
8600
|
const env = {
|
|
7312
8601
|
...baseEnv,
|
|
7313
8602
|
FRAMEWORK_CI_NONCE: nonce,
|
|
@@ -7320,13 +8609,13 @@ async function observeInstalledApp(options) {
|
|
|
7320
8609
|
};
|
|
7321
8610
|
let launchRecord, expectedApp;
|
|
7322
8611
|
if (mac && viaInstaller) {
|
|
7323
|
-
const shimDir =
|
|
8612
|
+
const shimDir = join31(run.directory, "launch-shim");
|
|
7324
8613
|
await mkdir9(shimDir, { mode: 448 });
|
|
7325
|
-
const path =
|
|
7326
|
-
await
|
|
8614
|
+
const path = join31(shimDir, "open");
|
|
8615
|
+
await writeFile9(path, shim, { flag: "wx", mode: 448 });
|
|
7327
8616
|
await chmod2(path, 448);
|
|
7328
|
-
expectedApp =
|
|
7329
|
-
launchRecord =
|
|
8617
|
+
expectedApp = join31(await realpath9(prepared.incoming), `${options.appName}.app`);
|
|
8618
|
+
launchRecord = join31(run.directory, "launch-record");
|
|
7330
8619
|
Object.assign(env, {
|
|
7331
8620
|
PATH: shimDir + delimiter + (env.PATH ?? ""),
|
|
7332
8621
|
FRAMEWORK_CI_EXPECTED_APP: expectedApp,
|
|
@@ -7362,7 +8651,7 @@ async function observeInstalledApp(options) {
|
|
|
7362
8651
|
const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
|
|
7363
8652
|
throw new Error(`Installer exited unsuccessfully (exit=${installer.exitCode}, signal=${installer.signalCode ?? "none"}, ` + `ready=${await pathExists(worker) && await pathExists(launcher)}, acknowledged=${await pathExists(ack)}, ` + `error=${error ?? "none"})`);
|
|
7364
8653
|
}
|
|
7365
|
-
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(
|
|
8654
|
+
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join31(resources, "version.json"));
|
|
7366
8655
|
if (installer && shouldLaunchInstalledApp({
|
|
7367
8656
|
platform: options.platform,
|
|
7368
8657
|
ready,
|
|
@@ -7370,17 +8659,17 @@ async function observeInstalledApp(options) {
|
|
|
7370
8659
|
acknowledged: await pathExists(ack),
|
|
7371
8660
|
installerExit: installer.exitCode
|
|
7372
8661
|
})) {
|
|
7373
|
-
if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await
|
|
8662
|
+
if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile11(launchRecord, "utf8") !== expectedApp + `
|
|
7374
8663
|
`)
|
|
7375
8664
|
throw new Error("Installer launch request mismatch");
|
|
7376
8665
|
app = spawnApp();
|
|
7377
8666
|
}
|
|
7378
8667
|
if (await pathExists(ack) && !granted) {
|
|
7379
8668
|
stage("worker-acknowledged");
|
|
7380
|
-
if (await
|
|
8669
|
+
if (await readFile11(ack, "utf8") !== nonce + `
|
|
7381
8670
|
`)
|
|
7382
8671
|
throw new Error("Worker guard acknowledgement mismatch");
|
|
7383
|
-
const record = await
|
|
8672
|
+
const record = await readFile11(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
|
|
7384
8673
|
if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
|
|
7385
8674
|
throw new Error("Worker process identity mismatch");
|
|
7386
8675
|
guardedPid = Number(match[2]);
|
|
@@ -7388,7 +8677,7 @@ async function observeInstalledApp(options) {
|
|
|
7388
8677
|
if (viaInstaller)
|
|
7389
8678
|
await installerUnchanged();
|
|
7390
8679
|
stage("installed-files-verified");
|
|
7391
|
-
await
|
|
8680
|
+
await writeFile9(permit, nonce + `
|
|
7392
8681
|
`, { flag: "wx", mode: 384 });
|
|
7393
8682
|
granted = true;
|
|
7394
8683
|
deadline = performance.now() + 90000;
|
|
@@ -7538,7 +8827,7 @@ async function observeInstalledApp(options) {
|
|
|
7538
8827
|
await swapAfterExit(target, staged.staging);
|
|
7539
8828
|
stage("update-swapped");
|
|
7540
8829
|
await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
|
|
7541
|
-
const directory =
|
|
8830
|
+
const directory = join31(prepared.directory, "update");
|
|
7542
8831
|
await mkdir9(directory, { mode: 448 });
|
|
7543
8832
|
const updated = await observeRun({
|
|
7544
8833
|
directory,
|
|
@@ -7577,7 +8866,7 @@ async function swapAfterExit(target, staging) {
|
|
|
7577
8866
|
// ../../src/installer/installer-qualification-command.ts
|
|
7578
8867
|
async function qualifyInstallerCommand(options) {
|
|
7579
8868
|
const { env, config, tag, platform, renderer } = options;
|
|
7580
|
-
if (!
|
|
8869
|
+
if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer) || typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string" || typeof config.appId !== "string")
|
|
7581
8870
|
throw new Error("Invalid installer qualification context");
|
|
7582
8871
|
if (env.RELEASE_TAG !== tag)
|
|
7583
8872
|
throw new Error("Installer release tag mismatch");
|
|
@@ -7587,9 +8876,9 @@ async function qualifyInstallerCommand(options) {
|
|
|
7587
8876
|
const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
|
|
7588
8877
|
if (!policy || !names || names.length !== 2)
|
|
7589
8878
|
throw new Error("Installer qualification requires an explicit offline policy and payloads");
|
|
7590
|
-
const directory =
|
|
8879
|
+
const directory = resolve14(options.directory), destination = join32(directory, `installer-test-${platform}.json`);
|
|
7591
8880
|
try {
|
|
7592
|
-
await
|
|
8881
|
+
await lstat19(destination);
|
|
7593
8882
|
throw new Error("Installer receipt already exists");
|
|
7594
8883
|
} catch (error) {
|
|
7595
8884
|
if (errorCode(error) !== "ENOENT")
|
|
@@ -7603,8 +8892,8 @@ async function qualifyInstallerCommand(options) {
|
|
|
7603
8892
|
appName: app.appName,
|
|
7604
8893
|
appId: app.appId,
|
|
7605
8894
|
version: plan.version,
|
|
7606
|
-
installer:
|
|
7607
|
-
archive:
|
|
8895
|
+
installer: join32(directory, names[0]),
|
|
8896
|
+
archive: join32(directory, names[1]),
|
|
7608
8897
|
expectedReads: parsed.expectedReads,
|
|
7609
8898
|
offlinePolicy: policy,
|
|
7610
8899
|
sidecars: parsed.sidecars
|
|
@@ -7629,17 +8918,17 @@ async function qualifyInstallerCommand(options) {
|
|
|
7629
8918
|
assets: result.artifacts
|
|
7630
8919
|
};
|
|
7631
8920
|
validateInstallerReceipt(identity, receipt, platform, names, result.artifacts, policy);
|
|
7632
|
-
await
|
|
8921
|
+
await writeFile10(destination, JSON.stringify(receipt, null, 2) + `
|
|
7633
8922
|
`, { flag: "wx", mode: 384 });
|
|
7634
8923
|
return receipt;
|
|
7635
8924
|
}
|
|
7636
8925
|
|
|
7637
8926
|
// ../../src/installer/installer-upgrade-command.ts
|
|
7638
|
-
import { lstat as
|
|
7639
|
-
import { join as
|
|
8927
|
+
import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as writeFile11 } from "fs/promises";
|
|
8928
|
+
import { join as join34, resolve as resolve16 } from "path";
|
|
7640
8929
|
|
|
7641
8930
|
// ../../src/installer/upgrade-asset-download.ts
|
|
7642
|
-
import { createHash as
|
|
8931
|
+
import { createHash as createHash19 } from "crypto";
|
|
7643
8932
|
import { open as open10, unlink as unlink3 } from "fs/promises";
|
|
7644
8933
|
|
|
7645
8934
|
// ../../src/installer/write-all.ts
|
|
@@ -7677,7 +8966,7 @@ async function downloadAsset(options) {
|
|
|
7677
8966
|
discardStream(response.body);
|
|
7678
8967
|
throw error;
|
|
7679
8968
|
}
|
|
7680
|
-
const hash =
|
|
8969
|
+
const hash = createHash19("sha256");
|
|
7681
8970
|
let completed = false;
|
|
7682
8971
|
try {
|
|
7683
8972
|
let size = 0;
|
|
@@ -7717,7 +9006,7 @@ async function downloadAsset(options) {
|
|
|
7717
9006
|
}
|
|
7718
9007
|
|
|
7719
9008
|
// ../../src/updates/feed/update-discovery.ts
|
|
7720
|
-
import { createHash as
|
|
9009
|
+
import { createHash as createHash20 } from "crypto";
|
|
7721
9010
|
var MAX_POINTER_BYTES = 262144;
|
|
7722
9011
|
var MAX_LEDGER_BYTES2 = 1024 * 1024;
|
|
7723
9012
|
async function discoverSignedRelease(options) {
|
|
@@ -7753,7 +9042,7 @@ async function discoverSignedRelease(options) {
|
|
|
7753
9042
|
throw new Error("No qualified channel descriptor is available");
|
|
7754
9043
|
const { tag } = selected;
|
|
7755
9044
|
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
|
|
7756
|
-
if (bytes.length !== listed.size ||
|
|
9045
|
+
if (bytes.length !== listed.size || createHash20("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
7757
9046
|
throw new Error("Channel descriptor differs from its release");
|
|
7758
9047
|
let signed;
|
|
7759
9048
|
try {
|
|
@@ -7771,8 +9060,8 @@ async function discoverSignedRelease(options) {
|
|
|
7771
9060
|
}
|
|
7772
9061
|
|
|
7773
9062
|
// ../../src/updates/install/update-download.ts
|
|
7774
|
-
import { mkdtemp as
|
|
7775
|
-
import { basename as basename14, dirname as dirname13, join as
|
|
9063
|
+
import { mkdtemp as mkdtemp10, open as open11, realpath as realpath10, rm as rm10 } from "fs/promises";
|
|
9064
|
+
import { basename as basename14, dirname as dirname13, join as join33, resolve as resolve15 } from "path";
|
|
7776
9065
|
async function downloadVerifiedRelease(options) {
|
|
7777
9066
|
const { descriptor, maxBytes } = options;
|
|
7778
9067
|
const timeout = options.timeoutMs ?? 120000;
|
|
@@ -7804,13 +9093,13 @@ async function downloadVerifiedRelease(options) {
|
|
|
7804
9093
|
if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
|
|
7805
9094
|
throw new Error("Release download size mismatch");
|
|
7806
9095
|
}
|
|
7807
|
-
const root = options.createTemporaryDirectory ? await
|
|
7808
|
-
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await
|
|
7809
|
-
const temporaryDirectory =
|
|
9096
|
+
const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
|
|
9097
|
+
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp10(join33(root, "framework-update-"));
|
|
9098
|
+
const temporaryDirectory = resolve15(allocated);
|
|
7810
9099
|
if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
|
|
7811
9100
|
throw new Error("Invalid update download directory");
|
|
7812
9101
|
temporary = temporaryDirectory;
|
|
7813
|
-
const path =
|
|
9102
|
+
const path = join33(temporary, "archive");
|
|
7814
9103
|
const file = await open11(path, "wx", 384);
|
|
7815
9104
|
try {
|
|
7816
9105
|
async function* writeChunks() {
|
|
@@ -7867,7 +9156,7 @@ async function downloadVerifiedRelease(options) {
|
|
|
7867
9156
|
return { path, directory: temporary };
|
|
7868
9157
|
} catch (error) {
|
|
7869
9158
|
if (temporary)
|
|
7870
|
-
await
|
|
9159
|
+
await rm10(temporary, { recursive: true, force: true });
|
|
7871
9160
|
throw error;
|
|
7872
9161
|
} finally {
|
|
7873
9162
|
clearTimeout(stallTimer);
|
|
@@ -7884,6 +9173,7 @@ var MAX_COMPRESSED_BYTES2 = 1024 * 1024 * 1024;
|
|
|
7884
9173
|
var MAX_EXPANDED_BYTES2 = 4 * 1024 * 1024 * 1024;
|
|
7885
9174
|
var targets = {
|
|
7886
9175
|
"macos-arm64": ["darwin", "arm64"],
|
|
9176
|
+
"macos-x64": ["darwin", "x64"],
|
|
7887
9177
|
"windows-x64": ["win32", "x64"],
|
|
7888
9178
|
"linux-x64": ["linux", "x64"],
|
|
7889
9179
|
"linux-arm64": ["linux", "arm64"]
|
|
@@ -7913,9 +9203,9 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7913
9203
|
const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
|
|
7914
9204
|
if (!requirements.offlinePolicy || !names || names.length !== 2)
|
|
7915
9205
|
throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
|
|
7916
|
-
const directory =
|
|
9206
|
+
const directory = resolve16(options.directory), destination = join34(directory, `upgrade-test-${platform}.json`);
|
|
7917
9207
|
try {
|
|
7918
|
-
await
|
|
9208
|
+
await lstat20(destination);
|
|
7919
9209
|
throw new Error("Upgrade receipt already exists");
|
|
7920
9210
|
} catch (error) {
|
|
7921
9211
|
if (errorCode(error) !== "ENOENT")
|
|
@@ -7936,7 +9226,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7936
9226
|
const channel = "daily";
|
|
7937
9227
|
const trust = { ...base, channel };
|
|
7938
9228
|
const discovery = discoveryName(config, channel, platform);
|
|
7939
|
-
const signed = await readJsonFile(
|
|
9229
|
+
const signed = await readJsonFile(join34(directory, discovery), 65536, "staged descriptor");
|
|
7940
9230
|
const verified = verifyReleaseDescriptor(signed, trust);
|
|
7941
9231
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
|
|
7942
9232
|
throw new Error("Untrusted staged descriptor");
|
|
@@ -7959,7 +9249,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7959
9249
|
return null;
|
|
7960
9250
|
if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
|
|
7961
9251
|
throw new Error("Previous release is not older than this release");
|
|
7962
|
-
const work =
|
|
9252
|
+
const work = join34(directory, `upgrade-${platform}`);
|
|
7963
9253
|
await mkdir10(work, { mode: 448 });
|
|
7964
9254
|
const downloaded = await downloadVerifiedRelease({
|
|
7965
9255
|
descriptor: previous,
|
|
@@ -7968,12 +9258,12 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7968
9258
|
timeoutMs: 600000,
|
|
7969
9259
|
fetch: fetcher
|
|
7970
9260
|
});
|
|
7971
|
-
const previousArchive =
|
|
9261
|
+
const previousArchive = join34(work, previous.asset.name);
|
|
7972
9262
|
await rename2(downloaded.path, previousArchive);
|
|
7973
9263
|
const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
|
|
7974
9264
|
if (!installerName)
|
|
7975
9265
|
throw new Error("Previous release has no installer for this platform");
|
|
7976
|
-
const previousInstaller =
|
|
9266
|
+
const previousInstaller = join34(work, installerName);
|
|
7977
9267
|
await downloadAsset({
|
|
7978
9268
|
feed,
|
|
7979
9269
|
tag: previous.tag,
|
|
@@ -7997,7 +9287,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7997
9287
|
update: {
|
|
7998
9288
|
descriptor,
|
|
7999
9289
|
trust,
|
|
8000
|
-
archive:
|
|
9290
|
+
archive: join34(directory, names[1]),
|
|
8001
9291
|
maxCompressedBytes: MAX_COMPRESSED_BYTES2,
|
|
8002
9292
|
maxExpandedBytes: MAX_EXPANDED_BYTES2
|
|
8003
9293
|
}
|
|
@@ -8014,7 +9304,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8014
9304
|
updated: true,
|
|
8015
9305
|
rendererEvidence: result.updated.evidence
|
|
8016
9306
|
};
|
|
8017
|
-
await
|
|
9307
|
+
await writeFile11(destination, JSON.stringify(receipt, null, 2) + `
|
|
8018
9308
|
`, { flag: "wx", mode: 384 });
|
|
8019
9309
|
return receipt;
|
|
8020
9310
|
}
|
|
@@ -8034,9 +9324,8 @@ function stepRenderer(env) {
|
|
|
8034
9324
|
}
|
|
8035
9325
|
|
|
8036
9326
|
// ../../src/release/release-steps.ts
|
|
8037
|
-
var PLATFORMS = ["macos-arm64", "windows-x64", "linux-x64"];
|
|
8038
9327
|
function releasePlatform(value) {
|
|
8039
|
-
if (!
|
|
9328
|
+
if (!isInstallerPlatform(value))
|
|
8040
9329
|
throw new Error("Expected a release platform");
|
|
8041
9330
|
return value;
|
|
8042
9331
|
}
|
|
@@ -8045,6 +9334,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
8045
9334
|
const bundle = appName.replaceAll(" ", "");
|
|
8046
9335
|
return {
|
|
8047
9336
|
"macos-arm64": [`macos-arm64-${bundle}.dmg`, `stable-macos-arm64-${bundle}.app.tar.zst`],
|
|
9337
|
+
"macos-x64": [`macos-x64-${bundle}.dmg`, `stable-macos-x64-${bundle}.app.tar.zst`],
|
|
8048
9338
|
"windows-x64": [`win-x64-${bundle}-Setup.zip`, `stable-win-x64-${bundle}.tar.zst`],
|
|
8049
9339
|
"linux-x64": [`linux-x64-${bundle}-Setup.tar.gz`, `stable-linux-x64-${bundle}.tar.zst`],
|
|
8050
9340
|
"linux-arm64": [`linux-arm64-${bundle}-Setup.tar.gz`, `stable-linux-arm64-${bundle}.tar.zst`]
|
|
@@ -8052,7 +9342,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
8052
9342
|
}
|
|
8053
9343
|
|
|
8054
9344
|
// src/library/steps.ts
|
|
8055
|
-
var selectRetainedStepEffect = (context) =>
|
|
9345
|
+
var selectRetainedStepEffect = (context) => Effect25.gen(function* () {
|
|
8056
9346
|
const output = context.env.GITHUB_OUTPUT;
|
|
8057
9347
|
if (!output)
|
|
8058
9348
|
return yield* fail("Expected GITHUB_OUTPUT");
|
|
@@ -8064,21 +9354,23 @@ runId=${result.runId}
|
|
|
8064
9354
|
` : `reuse=false
|
|
8065
9355
|
`));
|
|
8066
9356
|
});
|
|
8067
|
-
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") =>
|
|
9357
|
+
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
|
|
8068
9358
|
const fs = yield* ReleaseFs;
|
|
8069
9359
|
const [installerAsset, archiveAsset] = platformAssets(context);
|
|
9360
|
+
if (context.platform === "windows-x64" && !installerAsset.toLowerCase().endsWith(".zip"))
|
|
9361
|
+
return yield* fail("Electrobun Setup ZIP cannot produce the configured Windows installer");
|
|
8070
9362
|
const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
|
|
8071
9363
|
const parsed = parseReleaseConfig(context.config);
|
|
8072
9364
|
const requirements = parsed.requirements(context.tag);
|
|
8073
9365
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
8074
9366
|
const packed = yield* scopedTempDirectory("framework-command-pack-");
|
|
8075
9367
|
const sources = {
|
|
8076
|
-
[installerAsset]:
|
|
8077
|
-
[archiveAsset]:
|
|
9368
|
+
[installerAsset]: join35(artifacts, installer),
|
|
9369
|
+
[archiveAsset]: join35(artifacts, archive)
|
|
8078
9370
|
};
|
|
8079
9371
|
for (const policy of parsed.commandArtifacts) {
|
|
8080
9372
|
const name = requirements.commandArtifacts[policy.kind][context.platform];
|
|
8081
|
-
sources[name] =
|
|
9373
|
+
sources[name] = join35(packed, name);
|
|
8082
9374
|
yield* step(() => packCommandArtifact({
|
|
8083
9375
|
source: policy.build,
|
|
8084
9376
|
archive: sources[name],
|
|
@@ -8087,8 +9379,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
|
|
|
8087
9379
|
}));
|
|
8088
9380
|
}
|
|
8089
9381
|
return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
|
|
8090
|
-
}).pipe(
|
|
8091
|
-
var inspectStagedStepEffect = (context, directory) =>
|
|
9382
|
+
}).pipe(Effect25.scoped);
|
|
9383
|
+
var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* () {
|
|
8092
9384
|
const fs = yield* ReleaseFs;
|
|
8093
9385
|
const parsed = parseReleaseConfig(context.config);
|
|
8094
9386
|
const requirements = parsed.requirements(context.tag);
|
|
@@ -8096,10 +9388,10 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
|
|
|
8096
9388
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
8097
9389
|
if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
|
|
8098
9390
|
return yield* fail("Staged platform directory contains unexpected files");
|
|
8099
|
-
const [installer, archive] = platformAssets(context).map((name) =>
|
|
9391
|
+
const [installer, archive] = platformAssets(context).map((name) => join35(directory, name));
|
|
8100
9392
|
for (const policy of parsed.commandArtifacts)
|
|
8101
9393
|
yield* step(() => readCommandArtifact({
|
|
8102
|
-
archive:
|
|
9394
|
+
archive: join35(directory, requirements.commandArtifacts[policy.kind][context.platform]),
|
|
8103
9395
|
executable: policy.executable,
|
|
8104
9396
|
platform: context.platform
|
|
8105
9397
|
}));
|
|
@@ -8115,40 +9407,40 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
|
|
|
8115
9407
|
}))
|
|
8116
9408
|
};
|
|
8117
9409
|
});
|
|
8118
|
-
var qualifyStepEffect = (context, directory) =>
|
|
9410
|
+
var qualifyStepEffect = (context, directory) => Effect25.gen(function* () {
|
|
8119
9411
|
const mode = stepRenderer(context.env);
|
|
8120
9412
|
yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
|
|
8121
9413
|
yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
|
|
8122
9414
|
});
|
|
8123
|
-
var qualifyUpgradeStepEffect = (context, directory, onStage) =>
|
|
9415
|
+
var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend(() => {
|
|
8124
9416
|
const renderer = stepRenderer(context.env);
|
|
8125
9417
|
return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
|
|
8126
9418
|
});
|
|
8127
|
-
var
|
|
8128
|
-
var selectRetainedStep = (context) =>
|
|
8129
|
-
var stageBuildStep = (context, directory, artifacts) =>
|
|
8130
|
-
var inspectStagedStep = (context, directory) =>
|
|
8131
|
-
var qualifyStep = (context, directory) =>
|
|
8132
|
-
var qualifyUpgradeStep = (context, directory, onStage) =>
|
|
9419
|
+
var run3 = (context, effect) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(context.env) })(effect));
|
|
9420
|
+
var selectRetainedStep = (context) => run3(context, selectRetainedStepEffect(context));
|
|
9421
|
+
var stageBuildStep = (context, directory, artifacts) => run3(context, stageBuildStepEffect(context, directory, artifacts));
|
|
9422
|
+
var inspectStagedStep = (context, directory) => run3(context, inspectStagedStepEffect(context, directory));
|
|
9423
|
+
var qualifyStep = (context, directory) => run3(context, qualifyStepEffect(context, directory));
|
|
9424
|
+
var qualifyUpgradeStep = (context, directory, onStage) => run3(context, qualifyUpgradeStepEffect(context, directory, onStage));
|
|
8133
9425
|
// src/library/linux-package-pair.ts
|
|
8134
|
-
import { execFile as
|
|
9426
|
+
import { execFile as execFile4 } from "child_process";
|
|
8135
9427
|
import {
|
|
8136
9428
|
chmod as chmod3,
|
|
8137
9429
|
link,
|
|
8138
9430
|
mkdir as mkdir11,
|
|
8139
|
-
mkdtemp as
|
|
9431
|
+
mkdtemp as mkdtemp11,
|
|
8140
9432
|
open as open12,
|
|
8141
|
-
readFile as
|
|
8142
|
-
realpath as
|
|
8143
|
-
rm as
|
|
8144
|
-
writeFile as
|
|
9433
|
+
readFile as readFile12,
|
|
9434
|
+
realpath as realpath11,
|
|
9435
|
+
rm as rm11,
|
|
9436
|
+
writeFile as writeFile12
|
|
8145
9437
|
} from "fs/promises";
|
|
8146
|
-
import { dirname as dirname14, join as
|
|
8147
|
-
import { promisify as
|
|
9438
|
+
import { dirname as dirname14, join as join36, resolve as resolve17 } from "path";
|
|
9439
|
+
import { promisify as promisify4 } from "util";
|
|
8148
9440
|
var shasum = /^[a-f0-9]{64}$/;
|
|
8149
9441
|
var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
8150
9442
|
var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
8151
|
-
var exec =
|
|
9443
|
+
var exec = promisify4(execFile4);
|
|
8152
9444
|
function requireThat2(condition, message) {
|
|
8153
9445
|
if (!condition)
|
|
8154
9446
|
throw new Error(message);
|
|
@@ -8177,9 +9469,9 @@ var inspectWithNativeTools = async (tool, args) => {
|
|
|
8177
9469
|
throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
|
|
8178
9470
|
}
|
|
8179
9471
|
};
|
|
8180
|
-
function parseDebianIdentity(text, packageName, version) {
|
|
9472
|
+
function parseDebianIdentity(text, packageName, version, arch) {
|
|
8181
9473
|
const fields = text.trimEnd().split(/\r?\n/);
|
|
8182
|
-
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`,
|
|
9474
|
+
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`, `Architecture: ${arch}`].every((value) => fields.includes(value)), "Debian package name, version or architecture does not match the release policy");
|
|
8183
9475
|
}
|
|
8184
9476
|
function requireRegularDesktopEntry(listing, id) {
|
|
8185
9477
|
const lines = listing.trimEnd().split(/\r?\n/);
|
|
@@ -8233,11 +9525,11 @@ function digestWindow(runtime) {
|
|
|
8233
9525
|
requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
|
|
8234
9526
|
return matches[0];
|
|
8235
9527
|
}
|
|
8236
|
-
function
|
|
8237
|
-
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) ===
|
|
9528
|
+
function type2(bytes, elfMachine) {
|
|
9529
|
+
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === elfMachine;
|
|
8238
9530
|
}
|
|
8239
|
-
async function verifyEmbeddedRuntime(path, runtime) {
|
|
8240
|
-
requireThat2(
|
|
9531
|
+
async function verifyEmbeddedRuntime(path, runtime, elfMachine) {
|
|
9532
|
+
requireThat2(type2(runtime, elfMachine), "Expected a pinned native Type 2 AppImage runtime");
|
|
8241
9533
|
const ignored = digestWindow(runtime);
|
|
8242
9534
|
const fd = await open12(path, "r");
|
|
8243
9535
|
try {
|
|
@@ -8249,7 +9541,7 @@ async function verifyEmbeddedRuntime(path, runtime) {
|
|
|
8249
9541
|
throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
|
|
8250
9542
|
filled += bytesRead;
|
|
8251
9543
|
}
|
|
8252
|
-
requireThat2(
|
|
9544
|
+
requireThat2(type2(prefix, elfMachine), "Expected a native Type 2 AppImage");
|
|
8253
9545
|
requireThat2(runtime.subarray(0, ignored).equals(prefix.subarray(0, ignored)) && runtime.subarray(ignored + 16).equals(prefix.subarray(ignored + 16, runtime.length)), "AppImage runtime differs from its trusted pin outside the tool-generated digest");
|
|
8254
9546
|
requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
|
|
8255
9547
|
} finally {
|
|
@@ -8258,11 +9550,14 @@ async function verifyEmbeddedRuntime(path, runtime) {
|
|
|
8258
9550
|
}
|
|
8259
9551
|
async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
8260
9552
|
const { expected, sources } = options;
|
|
9553
|
+
const architecture = expected.architecture === undefined ? "x64" : expected.architecture;
|
|
9554
|
+
requireThat2(isLinuxPackageArchitecture(architecture), "Invalid trusted Linux package architecture");
|
|
9555
|
+
const target = linuxPackageArchitectures[architecture];
|
|
8261
9556
|
const receipt = record2(options.producer);
|
|
8262
9557
|
const archive = validIdentity(expected.archive);
|
|
8263
9558
|
const runtime = validIdentity(expected.runtime);
|
|
8264
9559
|
requireThat2(validTag.test(expected.tag) && /^[a-f0-9]{40}$/.test(expected.sourceSha) && basename15.test(expected.debName) && expected.debName.endsWith(".deb") && basename15.test(expected.appImageName) && expected.appImageName.endsWith(".AppImage") && archive.name.endsWith(".tar.zst") && /^[a-z0-9][a-z0-9+.-]+$/.test(expected.debPackage) && /^[A-Za-z0-9][A-Za-z0-9_.-]*\.desktop$/.test(expected.desktopId) && expected.desktopName.length > 0 && !/[\r\n]/.test(expected.desktopName) && Number.isSafeInteger(expected.runtime.size) && expected.runtime.size >= 64 && expected.runtime.size <= 64 * 1024 * 1024 && shasum.test(expected.runtime.sha256), "Invalid trusted Linux package policy");
|
|
8265
|
-
requireThat2(receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform ===
|
|
9560
|
+
requireThat2(receipt.releaseAuthorized !== false && receipt.schema !== "private-linux-package-formats/v1" && receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === target.platform && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
|
|
8266
9561
|
const names = [expected.debName, expected.appImageName];
|
|
8267
9562
|
const artifacts = receipt.artifacts.map(validIdentity);
|
|
8268
9563
|
const trustedArtifacts = expected.artifacts.map(validIdentity);
|
|
@@ -8271,9 +9566,9 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
8271
9566
|
const trusted = trustedArtifacts.find((file) => file.name === name);
|
|
8272
9567
|
return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
|
|
8273
9568
|
}), "Package producer receipt must describe exactly the protected DEB and AppImage");
|
|
8274
|
-
const destination =
|
|
8275
|
-
const parent = await
|
|
8276
|
-
const work = await
|
|
9569
|
+
const destination = resolve17(options.output);
|
|
9570
|
+
const parent = await realpath11(dirname14(destination));
|
|
9571
|
+
const work = await mkdtemp11(join36(parent, ".linux-package-pair-"));
|
|
8277
9572
|
try {
|
|
8278
9573
|
const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
|
|
8279
9574
|
directory: work,
|
|
@@ -8281,11 +9576,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
8281
9576
|
sources
|
|
8282
9577
|
})));
|
|
8283
9578
|
requireThat2([...artifacts, archive, runtime].every((asset) => files.some((file) => file.name === asset.name && file.size === asset.size && file.digest === `sha256:${asset.sha256}`)), "Staged package or update archive does not agree with its bound size and digest");
|
|
8284
|
-
const deb =
|
|
8285
|
-
const image =
|
|
9579
|
+
const deb = join36(work, expected.debName);
|
|
9580
|
+
const image = join36(work, expected.appImageName);
|
|
8286
9581
|
const version = expected.tag.slice(1);
|
|
8287
|
-
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
|
|
8288
|
-
await verifyEmbeddedRuntime(image, await
|
|
9582
|
+
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version, target.debian);
|
|
9583
|
+
await verifyEmbeddedRuntime(image, await readFile12(join36(work, runtime.name)), target.elfMachine);
|
|
8289
9584
|
const offset = String(runtime.size);
|
|
8290
9585
|
requireRegularDesktopEntry(await inspect("unsquashfs", [
|
|
8291
9586
|
"-offset",
|
|
@@ -8308,118 +9603,121 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
8308
9603
|
schema: "linux-package-pair/v1",
|
|
8309
9604
|
tag: expected.tag,
|
|
8310
9605
|
sourceSha: expected.sourceSha,
|
|
8311
|
-
platform:
|
|
9606
|
+
platform: target.platform,
|
|
8312
9607
|
updateArchiveSha256: archive.sha256,
|
|
8313
9608
|
artifacts: names.map((name) => artifacts.find((file) => file.name === name))
|
|
8314
9609
|
};
|
|
8315
9610
|
await mkdir11(destination);
|
|
8316
9611
|
try {
|
|
8317
9612
|
for (const name of names)
|
|
8318
|
-
await link(
|
|
8319
|
-
await
|
|
9613
|
+
await link(join36(work, name), join36(destination, name));
|
|
9614
|
+
await writeFile12(join36(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
|
|
8320
9615
|
`, {
|
|
8321
9616
|
flag: "wx"
|
|
8322
9617
|
});
|
|
8323
9618
|
} catch (error) {
|
|
8324
|
-
await
|
|
9619
|
+
await rm11(destination, { recursive: true, force: true });
|
|
8325
9620
|
throw error;
|
|
8326
9621
|
}
|
|
8327
9622
|
return staged;
|
|
8328
9623
|
} finally {
|
|
8329
|
-
await
|
|
9624
|
+
await rm11(work, { recursive: true, force: true });
|
|
8330
9625
|
}
|
|
8331
9626
|
}
|
|
8332
9627
|
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
8333
9628
|
// src/library/linux-format-producer.ts
|
|
8334
|
-
import { createHash as
|
|
8335
|
-
import { createReadStream, createWriteStream } from "fs";
|
|
9629
|
+
import { createHash as createHash21 } from "crypto";
|
|
9630
|
+
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
8336
9631
|
import {
|
|
8337
9632
|
chmod as chmod4,
|
|
8338
9633
|
cp,
|
|
8339
|
-
lstat as
|
|
9634
|
+
lstat as lstat21,
|
|
8340
9635
|
lutimes,
|
|
8341
9636
|
mkdir as mkdir12,
|
|
8342
|
-
mkdtemp as
|
|
9637
|
+
mkdtemp as mkdtemp12,
|
|
8343
9638
|
open as open13,
|
|
8344
|
-
readdir as
|
|
9639
|
+
readdir as readdir12,
|
|
8345
9640
|
readlink as readlink3,
|
|
8346
|
-
realpath as
|
|
8347
|
-
rm as
|
|
9641
|
+
realpath as realpath12,
|
|
9642
|
+
rm as rm12,
|
|
9643
|
+
symlink as symlink2,
|
|
8348
9644
|
utimes,
|
|
8349
|
-
writeFile as
|
|
9645
|
+
writeFile as writeFile13
|
|
8350
9646
|
} from "fs/promises";
|
|
8351
|
-
import { basename as basename16, dirname as dirname15, isAbsolute as
|
|
9647
|
+
import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative5, resolve as resolve18 } from "path";
|
|
8352
9648
|
import { pipeline as pipeline2 } from "stream/promises";
|
|
8353
9649
|
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8354
|
-
var
|
|
9650
|
+
var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
|
|
9651
|
+
var debDependencyAtom = /^[a-z0-9][a-z0-9+.-]{0,63}(?: \(>= (?:0|[1-9]\d{0,8})(?:\.(?:0|[1-9]\d{0,8})){1,3}\))?$/;
|
|
9652
|
+
var sha2562 = /^[a-f0-9]{64}$/;
|
|
8355
9653
|
var sum = async (path) => {
|
|
8356
|
-
const hash =
|
|
8357
|
-
for await (const chunk of
|
|
9654
|
+
const hash = createHash21("sha256");
|
|
9655
|
+
for await (const chunk of createReadStream2(path))
|
|
8358
9656
|
hash.update(chunk);
|
|
8359
9657
|
return hash.digest("hex");
|
|
8360
9658
|
};
|
|
8361
9659
|
var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
|
|
8362
9660
|
var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
|
|
8363
|
-
function
|
|
9661
|
+
function check3(ok, message) {
|
|
8364
9662
|
if (!ok)
|
|
8365
9663
|
throw new Error(message);
|
|
8366
9664
|
}
|
|
8367
9665
|
async function exactCopy(pin, to) {
|
|
8368
|
-
|
|
8369
|
-
const before = await
|
|
8370
|
-
|
|
9666
|
+
check3(sha2562.test(pin.sha256), "Missing protected input digest");
|
|
9667
|
+
const before = await lstat21(pin.path);
|
|
9668
|
+
check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
8371
9669
|
const input = await open13(pin.path, "r");
|
|
8372
9670
|
try {
|
|
8373
9671
|
const after = await input.stat();
|
|
8374
|
-
|
|
9672
|
+
check3(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
|
|
8375
9673
|
await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
|
|
8376
9674
|
} finally {
|
|
8377
9675
|
await input.close();
|
|
8378
9676
|
}
|
|
8379
|
-
|
|
9677
|
+
check3((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
|
|
8380
9678
|
}
|
|
8381
|
-
async function
|
|
8382
|
-
const file =
|
|
8383
|
-
|
|
9679
|
+
async function regular2(root, path) {
|
|
9680
|
+
const file = join37(root, path);
|
|
9681
|
+
check3((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
|
|
8384
9682
|
return file;
|
|
8385
9683
|
}
|
|
8386
|
-
async function elf(path, appImage = false) {
|
|
9684
|
+
async function elf(path, machine, appImage = false) {
|
|
8387
9685
|
const input = await open13(path, "r");
|
|
8388
9686
|
try {
|
|
8389
9687
|
const h = Buffer.alloc(20);
|
|
8390
9688
|
const { bytesRead } = await input.read(h, 0, h.length, 0);
|
|
8391
|
-
|
|
9689
|
+
check3(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === machine && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected a native Linux executable matching the requested architecture");
|
|
8392
9690
|
} finally {
|
|
8393
9691
|
await input.close();
|
|
8394
9692
|
}
|
|
8395
9693
|
}
|
|
8396
9694
|
async function normalizeTree(root, dir = root) {
|
|
8397
|
-
for (const name of await
|
|
8398
|
-
const file =
|
|
8399
|
-
const st = await
|
|
9695
|
+
for (const name of await readdir12(dir)) {
|
|
9696
|
+
const file = join37(dir, name);
|
|
9697
|
+
const st = await lstat21(file);
|
|
8400
9698
|
if (st.isSymbolicLink()) {
|
|
8401
|
-
|
|
8402
|
-
const target = relative5(root, await
|
|
8403
|
-
|
|
9699
|
+
check3(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
|
|
9700
|
+
const target = relative5(root, await realpath12(file));
|
|
9701
|
+
check3(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
|
|
8404
9702
|
} else if (st.isDirectory()) {
|
|
8405
9703
|
await chmod4(file, 493);
|
|
8406
9704
|
await normalizeTree(root, file);
|
|
8407
9705
|
} else {
|
|
8408
|
-
|
|
9706
|
+
check3(st.isFile(), "Unsupported bundle entry");
|
|
8409
9707
|
await chmod4(file, st.mode & 73 ? 493 : 420);
|
|
8410
9708
|
}
|
|
8411
9709
|
}
|
|
8412
9710
|
}
|
|
8413
9711
|
async function normalizeBuildTimes(directory, epoch) {
|
|
8414
|
-
for (const name of (await
|
|
8415
|
-
const path =
|
|
8416
|
-
const info = await
|
|
9712
|
+
for (const name of (await readdir12(directory)).toSorted()) {
|
|
9713
|
+
const path = join37(directory, name);
|
|
9714
|
+
const info = await lstat21(path);
|
|
8417
9715
|
if (info.isSymbolicLink()) {
|
|
8418
9716
|
await lutimes(path, epoch, epoch);
|
|
8419
9717
|
} else if (info.isDirectory()) {
|
|
8420
9718
|
await normalizeBuildTimes(path, epoch);
|
|
8421
9719
|
} else {
|
|
8422
|
-
|
|
9720
|
+
check3(info.isFile(), "Unsupported packaging entry");
|
|
8423
9721
|
await utimes(path, epoch, epoch);
|
|
8424
9722
|
}
|
|
8425
9723
|
}
|
|
@@ -8427,79 +9725,100 @@ async function normalizeBuildTimes(directory, epoch) {
|
|
|
8427
9725
|
await utimes(directory, epoch, epoch);
|
|
8428
9726
|
}
|
|
8429
9727
|
async function write(root, path, value, mode = 420) {
|
|
8430
|
-
const target =
|
|
9728
|
+
const target = join37(root, path);
|
|
8431
9729
|
await mkdir12(dirname15(target), { recursive: true });
|
|
8432
|
-
await
|
|
9730
|
+
await writeFile13(target, value, { flag: "wx", mode });
|
|
8433
9731
|
await chmod4(target, mode);
|
|
8434
9732
|
}
|
|
8435
9733
|
function validatePolicy(policy) {
|
|
8436
|
-
|
|
8437
|
-
|
|
9734
|
+
const executable = policy.executable ?? policy.packageName;
|
|
9735
|
+
const links = policy.links ?? [];
|
|
9736
|
+
check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2562.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => x.length <= 256 && x === x.trim() && x.split(" | ").every((atom) => debDependencyAtom.test(atom))), "Invalid app Linux packaging policy");
|
|
9737
|
+
check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
8438
9738
|
}
|
|
8439
9739
|
async function buildLinuxFormats(input, host) {
|
|
8440
9740
|
const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
9741
|
+
const checkAbort = () => host.signal?.throwIfAborted();
|
|
9742
|
+
checkAbort();
|
|
9743
|
+
const architecture = input.architecture === undefined ? "x64" : input.architecture;
|
|
9744
|
+
check3(isLinuxPackageArchitecture(architecture), "Unsupported Linux package architecture");
|
|
9745
|
+
check3(host.os === "linux" && host.arch === architecture, `Requires native Linux ${architecture}`);
|
|
9746
|
+
const target = linuxPackageArchitectures[architecture];
|
|
9747
|
+
check3(/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) && /^[a-f0-9]{40}$/.test(sourceSha) && sourceSha === expectedSourceSha, "Wrong protected build source or tag");
|
|
9748
|
+
check3(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
|
|
9749
|
+
if (input.identity)
|
|
9750
|
+
check3(input.identity.workflowSha === sourceSha && /^[1-9]\d{0,19}$/.test(input.identity.runId) && Number.isSafeInteger(input.identity.runAttempt) && input.identity.runAttempt > 0, "Invalid Linux build workflow identity");
|
|
8444
9751
|
const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
|
|
8445
9752
|
validatePolicy(policy);
|
|
8446
|
-
const requested =
|
|
8447
|
-
const parent = await
|
|
8448
|
-
const output =
|
|
8449
|
-
const work = await
|
|
9753
|
+
const requested = resolve18(input.output);
|
|
9754
|
+
const parent = await realpath12(dirname15(requested));
|
|
9755
|
+
const output = join37(parent, basename16(requested));
|
|
9756
|
+
const work = await mkdtemp12(join37(parent, ".linux-formats-"));
|
|
9757
|
+
let outputOwned = false;
|
|
8450
9758
|
try {
|
|
8451
|
-
const archive =
|
|
8452
|
-
const tool =
|
|
8453
|
-
const runtime =
|
|
9759
|
+
const archive = join37(work, "payload.tar.zst");
|
|
9760
|
+
const tool = join37(work, "appimagetool");
|
|
9761
|
+
const runtime = join37(work, "runtime");
|
|
8454
9762
|
for (const [pin, dest] of [
|
|
8455
9763
|
[input.archive, archive],
|
|
8456
9764
|
[input.tool, tool],
|
|
8457
9765
|
[input.runtime, runtime]
|
|
8458
9766
|
])
|
|
8459
9767
|
await exactCopy(pin, dest);
|
|
8460
|
-
await elf(tool, true);
|
|
8461
|
-
await elf(runtime, true);
|
|
8462
|
-
await host.inspectAppArchive(archive);
|
|
8463
|
-
check((await lstat20(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
|
|
9768
|
+
await elf(tool, target.elfMachine, true);
|
|
9769
|
+
await elf(runtime, target.elfMachine, true);
|
|
8464
9770
|
await chmod4(tool, 448);
|
|
8465
|
-
const extracted =
|
|
9771
|
+
const extracted = join37(work, "extract");
|
|
8466
9772
|
await mkdir12(extracted);
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
archive,
|
|
8472
|
-
"
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
9773
|
+
if (host.extractVerifiedAppArchive) {
|
|
9774
|
+
await host.extractVerifiedAppArchive(archive, extracted);
|
|
9775
|
+
} else {
|
|
9776
|
+
await host.inspectAppArchive(archive);
|
|
9777
|
+
check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
|
|
9778
|
+
await host.run("tar", [
|
|
9779
|
+
"--zstd",
|
|
9780
|
+
"--extract",
|
|
9781
|
+
"--file",
|
|
9782
|
+
archive,
|
|
9783
|
+
"--directory",
|
|
9784
|
+
extracted,
|
|
9785
|
+
"--no-same-owner",
|
|
9786
|
+
"--no-same-permissions"
|
|
9787
|
+
], { env });
|
|
9788
|
+
}
|
|
9789
|
+
check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
|
|
9790
|
+
checkAbort();
|
|
9791
|
+
const source = join37(extracted, policy.bundleRoot);
|
|
9792
|
+
check3((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
|
|
8479
9793
|
await chmod4(source, 493);
|
|
8480
9794
|
await normalizeTree(source);
|
|
8481
|
-
await elf(await
|
|
9795
|
+
await elf(await regular2(source, policy.launcher), target.elfMachine);
|
|
9796
|
+
for (const link of policy.links ?? []) {
|
|
9797
|
+
const linkTarget = await regular2(source, link.target);
|
|
9798
|
+
check3(((await lstat21(linkTarget)).mode & 73) !== 0, "CLI link target is not executable");
|
|
9799
|
+
}
|
|
8482
9800
|
for (const pin of policy.debSetuid) {
|
|
8483
|
-
const file = await
|
|
8484
|
-
await elf(file);
|
|
8485
|
-
|
|
9801
|
+
const file = await regular2(source, pin.path);
|
|
9802
|
+
await elf(file, target.elfMachine);
|
|
9803
|
+
check3(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
|
|
8486
9804
|
}
|
|
8487
|
-
const icon = await
|
|
8488
|
-
|
|
8489
|
-
const stem = `${policy.artifactStem}-${tag}
|
|
9805
|
+
const icon = await regular2(source, policy.icon);
|
|
9806
|
+
check3(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
|
|
9807
|
+
const stem = `${policy.artifactStem}-${tag}-${target.platform}`;
|
|
8490
9808
|
const debName = `${stem}.deb`;
|
|
8491
9809
|
const imageName = `${stem}.AppImage`;
|
|
8492
|
-
const dest =
|
|
9810
|
+
const dest = join37(work, "result");
|
|
8493
9811
|
await mkdir12(dest);
|
|
8494
9812
|
const version = tag.slice(1);
|
|
8495
9813
|
const installed = `usr/lib/${policy.packageName}`;
|
|
9814
|
+
const executable = policy.executable ?? policy.packageName;
|
|
8496
9815
|
const desktopFile = `${policy.desktopId}.desktop`;
|
|
8497
9816
|
const desktop = [
|
|
8498
9817
|
"[Desktop Entry]",
|
|
8499
9818
|
"Type=Application",
|
|
8500
9819
|
`Name=${policy.name}`,
|
|
8501
9820
|
`Comment=${policy.description}`,
|
|
8502
|
-
`Exec=${
|
|
9821
|
+
`Exec=${executable} %U`,
|
|
8503
9822
|
`Icon=${policy.desktopId}`,
|
|
8504
9823
|
`Categories=${policy.categories.join(";")};`,
|
|
8505
9824
|
...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
|
|
@@ -8508,27 +9827,35 @@ async function buildLinuxFormats(input, host) {
|
|
|
8508
9827
|
].join(`
|
|
8509
9828
|
`);
|
|
8510
9829
|
for (const format of ["deb", "appimage"]) {
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
9830
|
+
checkAbort();
|
|
9831
|
+
const tree = join37(work, format);
|
|
9832
|
+
await mkdir12(join37(tree, "usr", "lib"), { recursive: true });
|
|
9833
|
+
const bundle = join37(tree, installed);
|
|
8514
9834
|
await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
|
|
8515
9835
|
await normalizeTree(bundle);
|
|
9836
|
+
const appDirectory = join37(bundle, "Resources", "app");
|
|
9837
|
+
check3((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
|
|
9838
|
+
await write(bundle, "Resources/app/.adea-linux-package", `${format}
|
|
9839
|
+
`);
|
|
8516
9840
|
await write(tree, `usr/share/applications/${desktopFile}`, desktop);
|
|
8517
|
-
const iconDest =
|
|
9841
|
+
const iconDest = join37(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
|
|
8518
9842
|
await mkdir12(dirname15(iconDest), { recursive: true });
|
|
8519
9843
|
await cp(icon, iconDest, { force: false, errorOnExist: true });
|
|
8520
9844
|
await chmod4(iconDest, 420);
|
|
9845
|
+
await mkdir12(join37(tree, "usr", "bin"), { recursive: true });
|
|
9846
|
+
for (const link of policy.links ?? [])
|
|
9847
|
+
await symlink2(`../lib/${policy.packageName}/${link.target}`, join37(tree, "usr", "bin", link.name));
|
|
8521
9848
|
if (format === "deb") {
|
|
8522
9849
|
for (const pin of policy.debSetuid)
|
|
8523
|
-
await chmod4(await
|
|
8524
|
-
await write(tree, `usr/bin/${
|
|
9850
|
+
await chmod4(await regular2(bundle, pin.path), 2541);
|
|
9851
|
+
await write(tree, `usr/bin/${executable}`, `#!/bin/sh
|
|
8525
9852
|
export ${policy.formatEnvironment}=deb
|
|
8526
9853
|
exec '/${installed}/${policy.launcher}' "$@"
|
|
8527
9854
|
`, 493);
|
|
8528
9855
|
await write(tree, "DEBIAN/control", [
|
|
8529
9856
|
`Package: ${policy.packageName}`,
|
|
8530
9857
|
`Version: ${version}`,
|
|
8531
|
-
|
|
9858
|
+
`Architecture: ${target.debian}`,
|
|
8532
9859
|
`Maintainer: ${policy.maintainer}`,
|
|
8533
9860
|
`Description: ${policy.description}`,
|
|
8534
9861
|
`Homepage: ${policy.homepage}`,
|
|
@@ -8537,9 +9864,15 @@ exec '/${installed}/${policy.launcher}' "$@"
|
|
|
8537
9864
|
].join(`
|
|
8538
9865
|
`));
|
|
8539
9866
|
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
8540
|
-
await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree,
|
|
9867
|
+
await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join37(dest, debName)], { env });
|
|
8541
9868
|
} else {
|
|
8542
|
-
|
|
9869
|
+
await write(tree, `usr/bin/${executable}`, `#!/bin/sh
|
|
9870
|
+
set -eu
|
|
9871
|
+
root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
|
|
9872
|
+
export ${policy.formatEnvironment}=appimage
|
|
9873
|
+
exec "$root/${installed}/${policy.launcher}" "$@"
|
|
9874
|
+
`, 493);
|
|
9875
|
+
const rootIcon = join37(tree, `${policy.desktopId}.svg`);
|
|
8543
9876
|
await cp(icon, rootIcon, { force: false, errorOnExist: true });
|
|
8544
9877
|
await chmod4(rootIcon, 420);
|
|
8545
9878
|
await write(tree, desktopFile, desktop);
|
|
@@ -8553,64 +9886,413 @@ exec '/${installed}/${policy.launcher}' "$@"
|
|
|
8553
9886
|
].join(`
|
|
8554
9887
|
`), 493);
|
|
8555
9888
|
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
8556
|
-
await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree,
|
|
9889
|
+
await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join37(dest, imageName)], {
|
|
8557
9890
|
executable: tool,
|
|
8558
|
-
env: { ...env, ARCH:
|
|
9891
|
+
env: { ...env, ARCH: target.appImage, VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
|
|
8559
9892
|
});
|
|
8560
9893
|
}
|
|
8561
9894
|
}
|
|
8562
9895
|
const artifacts = [];
|
|
8563
9896
|
for (const name of [debName, imageName]) {
|
|
8564
|
-
const path = await
|
|
8565
|
-
const size = (await
|
|
8566
|
-
|
|
9897
|
+
const path = await regular2(dest, name);
|
|
9898
|
+
const size = (await lstat21(path)).size;
|
|
9899
|
+
check3(size > 0, "Empty produced artifact");
|
|
8567
9900
|
artifacts.push({ name, size, sha256: await sum(path) });
|
|
8568
9901
|
}
|
|
8569
9902
|
const receipt = {
|
|
8570
|
-
schema: "linux-package-formats/v1",
|
|
9903
|
+
schema: input.privateCandidate ? "private-linux-package-formats/v1" : "linux-package-formats/v1",
|
|
9904
|
+
...input.privateCandidate ? {
|
|
9905
|
+
releaseAuthorized: false,
|
|
9906
|
+
appName: input.privateCandidate.appName,
|
|
9907
|
+
updateArchive: {
|
|
9908
|
+
name: input.privateCandidate.archiveName,
|
|
9909
|
+
size: input.privateCandidate.archiveSize,
|
|
9910
|
+
sha256: input.archive.sha256
|
|
9911
|
+
}
|
|
9912
|
+
} : {},
|
|
8571
9913
|
tag,
|
|
8572
9914
|
sourceSha,
|
|
8573
9915
|
sourceDateEpoch,
|
|
8574
|
-
|
|
9916
|
+
...input.identity,
|
|
9917
|
+
platform: target.platform,
|
|
8575
9918
|
updateArchiveSha256: input.archive.sha256,
|
|
8576
9919
|
artifacts
|
|
8577
9920
|
};
|
|
8578
|
-
|
|
9921
|
+
checkAbort();
|
|
9922
|
+
await mkdir12(output, input.privateCandidate ? { mode: 448 } : undefined);
|
|
9923
|
+
outputOwned = true;
|
|
8579
9924
|
try {
|
|
8580
9925
|
for (const item of artifacts)
|
|
8581
|
-
await cp(
|
|
9926
|
+
await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
|
|
8582
9927
|
force: false,
|
|
8583
9928
|
errorOnExist: true
|
|
8584
9929
|
});
|
|
8585
|
-
|
|
9930
|
+
checkAbort();
|
|
9931
|
+
await write(output, input.privateCandidate ? "private-linux-format-build.json" : "linux-format-build.json", JSON.stringify(receipt) + `
|
|
8586
9932
|
`);
|
|
9933
|
+
checkAbort();
|
|
8587
9934
|
} catch (error) {
|
|
8588
|
-
await
|
|
9935
|
+
await rm12(output, { recursive: true, force: true });
|
|
9936
|
+
outputOwned = false;
|
|
8589
9937
|
throw error;
|
|
8590
9938
|
}
|
|
8591
9939
|
return receipt;
|
|
8592
9940
|
} finally {
|
|
8593
|
-
|
|
9941
|
+
let cleanupComplete = false;
|
|
9942
|
+
try {
|
|
9943
|
+
await rm12(work, { recursive: true, force: true });
|
|
9944
|
+
await host.afterWorkCleanup?.();
|
|
9945
|
+
cleanupComplete = true;
|
|
9946
|
+
} finally {
|
|
9947
|
+
if ((!cleanupComplete || host.signal?.aborted) && outputOwned) {
|
|
9948
|
+
await rm12(output, { recursive: true, force: true });
|
|
9949
|
+
host.signal?.throwIfAborted();
|
|
9950
|
+
}
|
|
9951
|
+
}
|
|
9952
|
+
}
|
|
9953
|
+
}
|
|
9954
|
+
// src/library/windows-standalone.ts
|
|
9955
|
+
import { execFile as execFile5 } from "child_process";
|
|
9956
|
+
import { createHash as createHash22 } from "crypto";
|
|
9957
|
+
import { constants as constants8 } from "fs";
|
|
9958
|
+
import { copyFile as copyFile2, lstat as lstat22, mkdtemp as mkdtemp13, open as open14, readFile as readFile13, readdir as readdir13, rm as rm13, writeFile as writeFile14 } from "fs/promises";
|
|
9959
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
9960
|
+
import { basename as basename17, isAbsolute as isAbsolute8, join as join38, resolve as resolve19 } from "path";
|
|
9961
|
+
import { promisify as promisify5 } from "util";
|
|
9962
|
+
|
|
9963
|
+
// src/library/windows-standalone-bootstrap.ts
|
|
9964
|
+
var windowsBootstrapSource = String.raw`
|
|
9965
|
+
#define WIN32_LEAN_AND_MEAN
|
|
9966
|
+
#include <windows.h>
|
|
9967
|
+
#include <bcrypt.h>
|
|
9968
|
+
#include <sddl.h>
|
|
9969
|
+
#include <stdint.h>
|
|
9970
|
+
#include <wchar.h>
|
|
9971
|
+
#include "app.h"
|
|
9972
|
+
|
|
9973
|
+
extern const unsigned char setup_bytes[], metadata_bytes[], archive_bytes[];
|
|
9974
|
+
|
|
9975
|
+
static BOOL join_path(wchar_t *out, const wchar_t *dir, const wchar_t *name) {
|
|
9976
|
+
int n = swprintf(out, MAX_PATH, L"%ls\\%ls", dir, name);
|
|
9977
|
+
return n > 0 && n < MAX_PATH;
|
|
9978
|
+
}
|
|
9979
|
+
|
|
9980
|
+
static BOOL create_private_dir(const wchar_t *path) {
|
|
9981
|
+
HANDLE token = NULL;
|
|
9982
|
+
TOKEN_USER *user = NULL;
|
|
9983
|
+
LPWSTR sid = NULL;
|
|
9984
|
+
PSECURITY_DESCRIPTOR descriptor = NULL;
|
|
9985
|
+
DWORD size = 0;
|
|
9986
|
+
wchar_t policy[256];
|
|
9987
|
+
BOOL result = FALSE;
|
|
9988
|
+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) goto done;
|
|
9989
|
+
if (GetTokenInformation(token, TokenUser, NULL, 0, &size) ||
|
|
9990
|
+
GetLastError() != ERROR_INSUFFICIENT_BUFFER || !size || size > 65536) goto done;
|
|
9991
|
+
user = LocalAlloc(LPTR, size);
|
|
9992
|
+
if (!user || !GetTokenInformation(token, TokenUser, user, size, &size) ||
|
|
9993
|
+
!ConvertSidToStringSidW(user->User.Sid, &sid)) goto done;
|
|
9994
|
+
int n = swprintf(policy, 256, L"D:P(A;OICI;FA;;;%ls)(A;OICI;FA;;;SY)", sid);
|
|
9995
|
+
if (n <= 0 || n >= 256 || !ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
|
9996
|
+
policy, SDDL_REVISION_1, &descriptor, NULL)) goto done;
|
|
9997
|
+
SECURITY_ATTRIBUTES security = { sizeof(security), descriptor, FALSE };
|
|
9998
|
+
result = CreateDirectoryW(path, &security);
|
|
9999
|
+
done:
|
|
10000
|
+
if (descriptor) LocalFree(descriptor);
|
|
10001
|
+
if (sid) LocalFree(sid);
|
|
10002
|
+
if (user) LocalFree(user);
|
|
10003
|
+
if (token) CloseHandle(token);
|
|
10004
|
+
return result;
|
|
10005
|
+
}
|
|
10006
|
+
|
|
10007
|
+
static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWORD size) {
|
|
10008
|
+
HANDLE file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_NEW,
|
|
10009
|
+
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
|
10010
|
+
if (file == INVALID_HANDLE_VALUE) return FALSE;
|
|
10011
|
+
BOOL ok = TRUE;
|
|
10012
|
+
while (size != 0) {
|
|
10013
|
+
DWORD sent = 0;
|
|
10014
|
+
DWORD chunk = size > 1048576 ? 1048576 : size;
|
|
10015
|
+
if (!WriteFile(file, bytes, chunk, &sent, NULL) || !sent) { ok = FALSE; break; }
|
|
10016
|
+
bytes += sent;
|
|
10017
|
+
size -= sent;
|
|
10018
|
+
}
|
|
10019
|
+
return CloseHandle(file) && ok;
|
|
10020
|
+
}
|
|
10021
|
+
|
|
10022
|
+
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
|
|
10023
|
+
(void)instance; (void)previous; (void)show;
|
|
10024
|
+
// No undocumented silent or arbitrary installer arguments are forwarded.
|
|
10025
|
+
if (command[0]) {
|
|
10026
|
+
MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
10027
|
+
return 2;
|
|
10028
|
+
}
|
|
10029
|
+
wchar_t base[MAX_PATH], work[MAX_PATH], child[MAX_PATH], hidden[MAX_PATH];
|
|
10030
|
+
wchar_t meta[MAX_PATH], archive[MAX_PATH], child_command[MAX_PATH+3];
|
|
10031
|
+
DWORD n = GetTempPathW(MAX_PATH, base), code = 2;
|
|
10032
|
+
if (!n || n >= MAX_PATH || base[n-1] != L'\\') goto fail;
|
|
10033
|
+
DWORD attributes = GetFileAttributesW(base);
|
|
10034
|
+
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
10035
|
+
|| (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) goto fail;
|
|
10036
|
+
if (n + 36 >= MAX_PATH) goto fail;
|
|
10037
|
+
uint32_t random[4];
|
|
10038
|
+
if (BCryptGenRandom(NULL, (PUCHAR)random, sizeof random, BCRYPT_USE_SYSTEM_PREFERRED_RNG) < 0) goto fail;
|
|
10039
|
+
if (swprintf(work, MAX_PATH, L"%lsaf-%08lx%08lx%08lx%08lx", base,
|
|
10040
|
+
(unsigned long)random[0], (unsigned long)random[1],
|
|
10041
|
+
(unsigned long)random[2], (unsigned long)random[3]) <= 0) goto fail;
|
|
10042
|
+
if (!join_path(child, work, APP_NAME L"-Setup.exe") ||
|
|
10043
|
+
!join_path(hidden, work, L".installer") ||
|
|
10044
|
+
!join_path(meta, hidden, APP_NAME L"-Setup.metadata.json") ||
|
|
10045
|
+
!join_path(archive, hidden, APP_NAME L"-Setup.tar.zst") ||
|
|
10046
|
+
swprintf(child_command, MAX_PATH+3, L"\"%ls\"", child) <= 0) goto fail;
|
|
10047
|
+
|
|
10048
|
+
// Use a fixed current-user/SYSTEM ACL and prevent replacement through a shared parent.
|
|
10049
|
+
if (!create_private_dir(work)) goto fail;
|
|
10050
|
+
HANDLE guard = CreateFileW(work, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
10051
|
+
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
|
10052
|
+
if (guard == INVALID_HANDLE_VALUE) goto fail;
|
|
10053
|
+
FILE_ATTRIBUTE_TAG_INFO tag = {0};
|
|
10054
|
+
if (!GetFileInformationByHandleEx(guard, FileAttributeTagInfo, &tag, sizeof tag) ||
|
|
10055
|
+
!(tag.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
|
|
10056
|
+
(tag.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
|
|
10057
|
+
CloseHandle(guard);
|
|
10058
|
+
goto fail;
|
|
10059
|
+
}
|
|
10060
|
+
if (!CreateDirectoryW(hidden, NULL) ||
|
|
10061
|
+
!write_exclusive(child, setup_bytes, SETUP_SIZE) ||
|
|
10062
|
+
!write_exclusive(meta, metadata_bytes, METADATA_SIZE) ||
|
|
10063
|
+
!write_exclusive(archive, archive_bytes, ARCHIVE_SIZE)) goto cleanup;
|
|
10064
|
+
|
|
10065
|
+
PROCESS_INFORMATION pi = {0};
|
|
10066
|
+
STARTUPINFOW si = {0};
|
|
10067
|
+
si.cb = sizeof si;
|
|
10068
|
+
if (CreateProcessW(child, child_command, NULL, NULL, FALSE, 0, NULL, work, &si, &pi)) {
|
|
10069
|
+
CloseHandle(pi.hThread);
|
|
10070
|
+
if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0 ||
|
|
10071
|
+
!GetExitCodeProcess(pi.hProcess, &code)) code = 2;
|
|
10072
|
+
CloseHandle(pi.hProcess);
|
|
10073
|
+
}
|
|
10074
|
+
cleanup:
|
|
10075
|
+
DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
|
|
10076
|
+
RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
|
|
10077
|
+
if (code == 0) return 0;
|
|
10078
|
+
fail:
|
|
10079
|
+
MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
10080
|
+
return (int)code;
|
|
10081
|
+
}
|
|
10082
|
+
`;
|
|
10083
|
+
|
|
10084
|
+
// src/library/windows-standalone.ts
|
|
10085
|
+
var MAX_ARCHIVE = 1024 * 1024 * 1024;
|
|
10086
|
+
var marker = Buffer.from("ADEA-WIN-SETUP01");
|
|
10087
|
+
var zigVersion = "0.15.2";
|
|
10088
|
+
var execute2 = promisify5(execFile5);
|
|
10089
|
+
async function identity3(path, limit) {
|
|
10090
|
+
const stat = await lstat22(path);
|
|
10091
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size <= 0 || stat.size > limit)
|
|
10092
|
+
throw new Error("Invalid Windows installer input");
|
|
10093
|
+
return hashFileAt(path, stat, "Windows installer input changed");
|
|
10094
|
+
}
|
|
10095
|
+
function equal(first, second) {
|
|
10096
|
+
return first.size === second.size && first.sha256 === second.sha256;
|
|
10097
|
+
}
|
|
10098
|
+
async function copySnapshot(source, destination, limit) {
|
|
10099
|
+
const expected = await identity3(source, limit);
|
|
10100
|
+
await copyFile2(source, destination, constants8.COPYFILE_EXCL);
|
|
10101
|
+
if (!equal(expected, await identity3(destination, limit)) || !equal(expected, await identity3(source, limit)))
|
|
10102
|
+
throw new Error("Windows installer input changed during staging");
|
|
10103
|
+
return expected;
|
|
10104
|
+
}
|
|
10105
|
+
var exact = async (directory, expected) => {
|
|
10106
|
+
const names = await readdir13(directory);
|
|
10107
|
+
if (names.length !== expected.length || expected.some((name) => !names.includes(name)))
|
|
10108
|
+
throw new Error("Unexpected Windows installer staging members");
|
|
10109
|
+
};
|
|
10110
|
+
async function assertStandaloneWindowsPayload(exe, members) {
|
|
10111
|
+
if (members.length !== 3 || members.some((part) => !Number.isSafeInteger(part.size) || part.size < 1 || part.size > MAX_ARCHIVE || !/^[0-9a-f]{64}$/.test(part.sha256)))
|
|
10112
|
+
throw new Error("Invalid Windows installer member identity");
|
|
10113
|
+
const info = await identity3(exe, 2 * MAX_ARCHIVE);
|
|
10114
|
+
const file = await open14(exe, "r");
|
|
10115
|
+
async function read(position, length) {
|
|
10116
|
+
const buffer = Buffer.alloc(length);
|
|
10117
|
+
if (position < 0 || position + length > info.size || (await file.read(buffer, 0, length, position)).bytesRead !== length)
|
|
10118
|
+
throw new Error("Malformed standalone Windows executable");
|
|
10119
|
+
return buffer;
|
|
10120
|
+
}
|
|
10121
|
+
try {
|
|
10122
|
+
await assertNativeExecutable(file, info.size, "windows-x64", "standalone installer");
|
|
10123
|
+
const pe = (await read(60, 4)).readUInt32LE(0);
|
|
10124
|
+
const coff = await read(pe + 4, 20);
|
|
10125
|
+
const count = coff.readUInt16LE(2);
|
|
10126
|
+
const headers = pe + 24 + coff.readUInt16LE(16);
|
|
10127
|
+
if (count === 0 || count > 96)
|
|
10128
|
+
throw new Error("Malformed Windows PE sections");
|
|
10129
|
+
const payloads = [];
|
|
10130
|
+
for (let i = 0;i < count; i++) {
|
|
10131
|
+
const section = await read(headers + i * 40, 40);
|
|
10132
|
+
if (section.subarray(0, 8).toString() === ".afsetup")
|
|
10133
|
+
payloads.push(section);
|
|
10134
|
+
}
|
|
10135
|
+
if (payloads.length !== 1)
|
|
10136
|
+
throw new Error("Missing unique Windows setup payload section");
|
|
10137
|
+
const section = payloads[0];
|
|
10138
|
+
const length = section.readUInt32LE(8);
|
|
10139
|
+
const rawLength = section.readUInt32LE(16);
|
|
10140
|
+
const offset = section.readUInt32LE(20);
|
|
10141
|
+
const expected = marker.length + members.reduce((total, part) => total + part.size, 0);
|
|
10142
|
+
if (length !== expected || rawLength < length || rawLength - length > 4096 || offset < headers + count * 40 || offset + rawLength > info.size || !(section.readUInt32LE(36) & 1073741824) || section.readUInt32LE(36) & 2684354560)
|
|
10143
|
+
throw new Error("Invalid Windows setup payload section bounds");
|
|
10144
|
+
if (!(await read(offset, marker.length)).equals(marker))
|
|
10145
|
+
throw new Error("Invalid Windows setup payload marker");
|
|
10146
|
+
let cursor = offset + marker.length;
|
|
10147
|
+
for (const member of members) {
|
|
10148
|
+
const hash = createHash22("sha256");
|
|
10149
|
+
const end = cursor + member.size;
|
|
10150
|
+
while (cursor < end) {
|
|
10151
|
+
const bytes = await read(cursor, Math.min(end - cursor, 1048576));
|
|
10152
|
+
hash.update(bytes);
|
|
10153
|
+
cursor += bytes.length;
|
|
10154
|
+
}
|
|
10155
|
+
if (hash.digest("hex") !== member.sha256)
|
|
10156
|
+
throw new Error("Windows setup payload differs");
|
|
10157
|
+
}
|
|
10158
|
+
if ((await read(cursor, rawLength - length)).some((byte) => byte !== 0))
|
|
10159
|
+
throw new Error("Unexpected trailing Windows setup section bytes");
|
|
10160
|
+
} finally {
|
|
10161
|
+
await file.close();
|
|
10162
|
+
}
|
|
10163
|
+
if (!equal(info, await identity3(exe, 2 * MAX_ARCHIVE)))
|
|
10164
|
+
throw new Error("Windows executable changed during inspection");
|
|
10165
|
+
}
|
|
10166
|
+
async function buildStandaloneWindowsExe(options) {
|
|
10167
|
+
const { appName, appId, zig, zigSha256 } = options;
|
|
10168
|
+
if (!/^[A-Za-z0-9]+(?:[ -][A-Za-z0-9]+)*$/.test(appName) || appName.length > 64 || !/^[A-Za-z0-9]+(?:[.-][A-Za-z0-9]+)+$/.test(appId) || appId.length > 128)
|
|
10169
|
+
throw new Error("Invalid Windows installer application identity");
|
|
10170
|
+
if (!isAbsolute8(zig) || !/^[0-9a-f]{64}$/.test(zigSha256))
|
|
10171
|
+
throw new Error("Expected an absolute pinned Zig compiler path");
|
|
10172
|
+
const compilerIdentity = await identity3(zig, 512 * 1024 * 1024);
|
|
10173
|
+
if (compilerIdentity.sha256 !== zigSha256)
|
|
10174
|
+
throw new Error("Pinned Zig compiler SHA-256 mismatch");
|
|
10175
|
+
const output = resolve19(options.output);
|
|
10176
|
+
if (!basename17(output).endsWith("-Setup.exe"))
|
|
10177
|
+
throw new Error("Expected final Windows Setup EXE filename");
|
|
10178
|
+
const root = resolve19(options.hutchMembers);
|
|
10179
|
+
const hidden = join38(root, ".installer");
|
|
10180
|
+
for (const directory of [root, hidden]) {
|
|
10181
|
+
const info = await lstat22(directory);
|
|
10182
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
10183
|
+
throw new Error("Invalid Windows installer input directory");
|
|
10184
|
+
}
|
|
10185
|
+
const app = appName + "-Setup";
|
|
10186
|
+
await exact(root, [app + ".exe", ".installer"]);
|
|
10187
|
+
await exact(hidden, [app + ".metadata.json", app + ".tar.zst"]);
|
|
10188
|
+
const work = await mkdtemp13(join38(tmpdir6(), "adea-windows-setup-"));
|
|
10189
|
+
try {
|
|
10190
|
+
const setupPath = join38(work, "setup.bin");
|
|
10191
|
+
const setup = await copySnapshot(join38(root, app + ".exe"), setupPath, 256 * 1024 * 1024);
|
|
10192
|
+
const handle = await open14(setupPath, "r");
|
|
10193
|
+
try {
|
|
10194
|
+
await assertNativeExecutable(handle, setup.size, "windows-x64", "Hutch installer");
|
|
10195
|
+
} finally {
|
|
10196
|
+
await handle.close();
|
|
10197
|
+
}
|
|
10198
|
+
const metadataPath = join38(work, "metadata.bin");
|
|
10199
|
+
const metadata = await copySnapshot(join38(hidden, app + ".metadata.json"), metadataPath, 1024 * 1024);
|
|
10200
|
+
const text = await readFile13(metadataPath, "utf8");
|
|
10201
|
+
const parsed = JSON.parse(text);
|
|
10202
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
10203
|
+
throw new Error("Invalid Hutch metadata");
|
|
10204
|
+
const fields = parsed;
|
|
10205
|
+
if (Object.keys(fields).length !== 4 || fields.name !== appName || fields.identifier !== appId || fields.channel !== "stable" || typeof fields.hash !== "string" || !/^[0-9a-z]{1,13}$/.test(fields.hash))
|
|
10206
|
+
throw new Error("Hutch metadata does not name the configured stable application");
|
|
10207
|
+
if (text.trim() !== JSON.stringify({ identifier: appId, name: appName, channel: "stable", hash: fields.hash }, null, 2))
|
|
10208
|
+
throw new Error("Noncanonical Hutch installer metadata");
|
|
10209
|
+
const archive = await copySnapshot(join38(hidden, app + ".tar.zst"), join38(work, "archive.bin"), MAX_ARCHIVE);
|
|
10210
|
+
if (!equal(archive, await identity3(resolve19(options.updateArchive), MAX_ARCHIVE)))
|
|
10211
|
+
throw new Error("Hutch payload differs from update archive");
|
|
10212
|
+
const version = await execute2(zig, ["version"], { cwd: work, timeout: 15000 });
|
|
10213
|
+
if (version.stdout.trim() !== zigVersion)
|
|
10214
|
+
throw new Error("Unexpected pinned Zig compiler version");
|
|
10215
|
+
await writeFile14(join38(work, "app.h"), [
|
|
10216
|
+
`#define APP_NAME L"${appName}"`,
|
|
10217
|
+
`#define SETUP_SIZE ${setup.size}u`,
|
|
10218
|
+
`#define METADATA_SIZE ${metadata.size}u`,
|
|
10219
|
+
`#define ARCHIVE_SIZE ${archive.size}u`
|
|
10220
|
+
].join(`
|
|
10221
|
+
`) + `
|
|
10222
|
+
`, { flag: "wx" });
|
|
10223
|
+
await writeFile14(join38(work, "bootstrap.c"), windowsBootstrapSource, { flag: "wx" });
|
|
10224
|
+
await writeFile14(join38(work, "payload.s"), [
|
|
10225
|
+
'.section .afsetup,"dr"',
|
|
10226
|
+
`.ascii "${marker.toString()}"`,
|
|
10227
|
+
".globl setup_bytes",
|
|
10228
|
+
"setup_bytes:",
|
|
10229
|
+
'.incbin "setup.bin"',
|
|
10230
|
+
".globl metadata_bytes",
|
|
10231
|
+
"metadata_bytes:",
|
|
10232
|
+
'.incbin "metadata.bin"',
|
|
10233
|
+
".globl archive_bytes",
|
|
10234
|
+
"archive_bytes:",
|
|
10235
|
+
'.incbin "archive.bin"'
|
|
10236
|
+
].join(`
|
|
10237
|
+
`) + `
|
|
10238
|
+
`, { flag: "wx" });
|
|
10239
|
+
const exe = join38(work, "standalone.exe");
|
|
10240
|
+
await execute2(zig, [
|
|
10241
|
+
"cc",
|
|
10242
|
+
"-target",
|
|
10243
|
+
"x86_64-windows-gnu",
|
|
10244
|
+
"-O2",
|
|
10245
|
+
"-municode",
|
|
10246
|
+
"-mwindows",
|
|
10247
|
+
"-fno-ident",
|
|
10248
|
+
"bootstrap.c",
|
|
10249
|
+
"payload.s",
|
|
10250
|
+
"-lbcrypt",
|
|
10251
|
+
"-ladvapi32",
|
|
10252
|
+
"-luser32",
|
|
10253
|
+
"-o",
|
|
10254
|
+
exe
|
|
10255
|
+
], { cwd: work, timeout: 300000 });
|
|
10256
|
+
await assertStandaloneWindowsPayload(exe, [setup, metadata, archive]);
|
|
10257
|
+
if (!equal(await identity3(zig, 512 * 1024 * 1024), compilerIdentity))
|
|
10258
|
+
throw new Error("Pinned Zig compiler changed during build");
|
|
10259
|
+
await copyFile2(exe, output, constants8.COPYFILE_EXCL);
|
|
10260
|
+
} finally {
|
|
10261
|
+
await rm13(work, { recursive: true, force: true });
|
|
8594
10262
|
}
|
|
8595
10263
|
}
|
|
8596
10264
|
export {
|
|
10265
|
+
assertStandaloneWindowsPayload,
|
|
8597
10266
|
buildLinuxFormats,
|
|
10267
|
+
buildStandaloneWindowsExe,
|
|
10268
|
+
compareLinuxReproducibility,
|
|
10269
|
+
createAptR2Store,
|
|
10270
|
+
createAptSignatureVerifier,
|
|
10271
|
+
createDailyBatchR2Client,
|
|
10272
|
+
createDailyBatchR2Store,
|
|
10273
|
+
createDailyBatchS3Transport,
|
|
8598
10274
|
createDailyNativeReceipt,
|
|
8599
10275
|
createGitHubPromotionProvider,
|
|
8600
10276
|
createGitHubReleasePublisher,
|
|
8601
10277
|
createMacosDmg,
|
|
8602
10278
|
desktopDailyProfile,
|
|
10279
|
+
expandedDesktopDailyProfile,
|
|
8603
10280
|
fileIdentity2 as fileIdentity,
|
|
8604
10281
|
finalizeReleasePleaseDraft,
|
|
10282
|
+
inspectDailyBatch,
|
|
8605
10283
|
inspectStagedStep,
|
|
8606
10284
|
planDailyReleaseMatrix,
|
|
8607
10285
|
planQualificationRun2 as planQualificationRun,
|
|
8608
10286
|
planReleaseAssets2 as planReleaseAssets,
|
|
10287
|
+
promoteDailyBatch,
|
|
10288
|
+
publishAptRepository,
|
|
8609
10289
|
publishFrameworkPackage,
|
|
8610
10290
|
publishQualifiedRelease,
|
|
8611
10291
|
qualifyGitHubRelease,
|
|
8612
10292
|
qualifyStep,
|
|
8613
10293
|
qualifyUpgradeStep,
|
|
10294
|
+
readDailyBatch,
|
|
10295
|
+
rollbackDailyBatch,
|
|
8614
10296
|
runPromotionCommand,
|
|
8615
10297
|
runReleaseCutCommand,
|
|
8616
10298
|
runReleasePublishCommand,
|
|
@@ -8621,6 +10303,8 @@ export {
|
|
|
8621
10303
|
stageLinuxPackagePair,
|
|
8622
10304
|
stagePlatformArtifacts,
|
|
8623
10305
|
stageReleaseDescriptors,
|
|
10306
|
+
verifyDailyBatchDescriptor,
|
|
10307
|
+
verifyDailyBatchObject,
|
|
8624
10308
|
verifyDailyReleaseMatrix,
|
|
8625
10309
|
verifyImage,
|
|
8626
10310
|
writeDescriptors
|