@adea-ai/app-framework-release-tools 0.6.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/dist/index.js CHANGED
@@ -17,8 +17,12 @@ 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,
21
23
  compareLinuxReproducibility: () => compareLinuxReproducibility,
24
+ createAptR2Store: () => createAptR2Store,
25
+ createAptSignatureVerifier: () => createAptSignatureVerifier,
22
26
  createDailyBatchR2Client: () => createDailyBatchR2Client,
23
27
  createDailyBatchR2Store: () => createDailyBatchR2Store,
24
28
  createDailyBatchS3Transport: () => createDailyBatchS3Transport,
@@ -27,6 +31,7 @@ __export(exports_src, {
27
31
  createGitHubReleasePublisher: () => createGitHubReleasePublisher,
28
32
  createMacosDmg: () => createMacosDmg,
29
33
  desktopDailyProfile: () => desktopDailyProfile,
34
+ expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
30
35
  fileIdentity: () => fileIdentity2,
31
36
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
32
37
  inspectDailyBatch: () => inspectDailyBatch,
@@ -35,6 +40,7 @@ __export(exports_src, {
35
40
  planQualificationRun: () => planQualificationRun2,
36
41
  planReleaseAssets: () => planReleaseAssets2,
37
42
  promoteDailyBatch: () => promoteDailyBatch,
43
+ publishAptRepository: () => publishAptRepository,
38
44
  publishFrameworkPackage: () => publishFrameworkPackage,
39
45
  publishQualifiedRelease: () => publishQualifiedRelease,
40
46
  qualifyGitHubRelease: () => qualifyGitHubRelease,
@@ -364,10 +370,20 @@ var tokens = (value, minimum) => Array.isArray(value) && value.length >= minimum
364
370
  var relativePath = (value) => typeof value === "string" && value.length <= 200 && /^[A-Za-z0-9._/-]+$/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
365
371
  var platformTargets = {
366
372
  "macos-arm64": ["darwin", "arm64"],
373
+ "macos-x64": ["darwin", "x64"],
367
374
  "windows-x64": ["win32", "x64"],
368
- "linux-x64": ["linux", "x64"]
375
+ "linux-x64": ["linux", "x64"],
376
+ "linux-arm64": ["linux", "arm64"]
369
377
  };
370
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
+ }
371
387
  function parseCommandArtifacts(value, platforms) {
372
388
  if (value === undefined)
373
389
  return [];
@@ -442,7 +458,7 @@ function parseReleaseConfig(config) {
442
458
  throw new Error("Invalid offline expected read");
443
459
  }
444
460
  const platforms = config.platforms;
445
- for (const required of releasePlatforms)
461
+ for (const required of requiredDesktopPlatforms(config.dailyReleaseProfile))
446
462
  if (!Object.hasOwn(platforms, required))
447
463
  throw new Error("Releases require all supported desktop platforms");
448
464
  for (const [platform, assets] of Object.entries(platforms))
@@ -572,7 +588,7 @@ function discoveryPolicies(config, tag) {
572
588
  result.push({ name, channel, platform, os, arch, appId: kind.appId, payload });
573
589
  }
574
590
  for (const kind of kinds)
575
- for (const platform of releasePlatforms)
591
+ for (const platform of requiredDesktopPlatforms(config.dailyReleaseProfile))
576
592
  if (!result.some((value) => value.channel === channel && value.appId === kind.appId && value.platform === platform))
577
593
  throw new Error("Missing platform discovery policy");
578
594
  }
@@ -1904,17 +1920,25 @@ function runnerTemp(env) {
1904
1920
  }
1905
1921
 
1906
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
+ }
1907
1936
  function assertInstallerContext(env, platform, host, arch) {
1908
1937
  assertHostedRunner(env, "Installer execution");
1909
1938
  assertInstallerHost(platform, host, arch);
1910
1939
  }
1911
1940
  function assertInstallerHost(platform, host, arch) {
1912
- const expected = {
1913
- "macos-arm64": "darwin/arm64",
1914
- "windows-x64": "win32/x64",
1915
- "linux-x64": "linux/x64",
1916
- "linux-arm64": "linux/arm64"
1917
- }[platform];
1941
+ const expected = INSTALLER_HOSTS[platform];
1918
1942
  if (!expected || `${host}/${arch}` !== expected)
1919
1943
  throw new Error("Installer requires matching native OS and architecture");
1920
1944
  }
@@ -1941,11 +1965,11 @@ function assertPayloadLayout(options) {
1941
1965
  const { platform, appName, renderer } = options;
1942
1966
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
1943
1967
  assertPortableAppName(appName);
1944
- if (!["macos-arm64", "windows-x64", "linux-x64", "linux-arm64"].includes(platform) || !["native", "cef"].includes(renderer))
1968
+ if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer))
1945
1969
  throw new Error("Invalid installer profile");
1946
1970
  const fold = platform === "windows-x64";
1947
1971
  const entries = paths(options.entries, fold);
1948
- const mac = platform === "macos-arm64";
1972
+ const mac = isMacInstallerPlatform(platform);
1949
1973
  const root = mac ? `${appName}.app/Contents` : appName.replaceAll(" ", "");
1950
1974
  const bin = mac ? `${root}/MacOS` : `${root}/bin`;
1951
1975
  const resources = `${root}/Resources`;
@@ -3513,6 +3537,12 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
3513
3537
  throw new Error("Daily manifest upload differs");
3514
3538
  if (JSON.stringify(parseManifest(await candidate.verify())) !== JSON.stringify(first))
3515
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
+ }
3516
3546
  const signed = await signDailyPointer({
3517
3547
  schema: "framework/daily-pointer/v3",
3518
3548
  appId,
@@ -3677,23 +3707,394 @@ function createDailyBatchR2Store(send) {
3677
3707
  }
3678
3708
  };
3679
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";
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
+ }
3680
3983
  // src/library/daily-batch-inspection.ts
3681
- import { join as join8 } from "path";
3984
+ import { join as join9 } from "path";
3682
3985
  import { Effect as Effect17 } from "effect";
3683
3986
 
3684
3987
  // src/library/daily-matrix.ts
3685
- import { join as join7 } from "path";
3988
+ import { join as join8 } from "path";
3686
3989
  import { Effect as Effect16 } from "effect";
3687
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
+
3688
4089
  // src/library/daily-native-evidence.ts
3689
- var digest = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
4090
+ var digest2 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
3690
4091
  var record = (value, keys) => isRecord(value) && hasExactOwnKeys(value, keys);
3691
4092
  function assertDailyIdentity(identity) {
3692
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)
3693
4094
  throw new Error("Invalid exact Daily identity");
3694
4095
  }
3695
4096
  function validArtifact(value) {
3696
- return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 && digest(value.digest);
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);
3697
4098
  }
3698
4099
  function originMatches(value, payloadName) {
3699
4100
  if (record(value, ["kind", "sourceSha"]))
@@ -3718,10 +4119,10 @@ function observationsMatch(value, { identity, check, baselineNames }) {
3718
4119
  "ready",
3719
4120
  "fixtureBefore",
3720
4121
  "fixtureAfter"
3721
- ]) && 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 && digest(upgrade.fixtureBefore) && upgrade.fixtureAfter === upgrade.fixtureBefore;
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;
3722
4123
  }
3723
4124
  function validateDailyNativeEvidence(input, schema, context) {
3724
- const { appId, identity, check, assets } = context;
4125
+ const { appId, identity, check, assets, profile = "desktop-v1", signing } = context;
3725
4126
  const [os, arch] = platformTargets[check.platform];
3726
4127
  if (!record(input, [
3727
4128
  "schema",
@@ -3737,8 +4138,9 @@ function validateDailyNativeEvidence(input, schema, context) {
3737
4138
  "format",
3738
4139
  "host",
3739
4140
  "assets",
3740
- "observations"
3741
- ]) || input.schema !== schema || input.appId !== appId || input.profile !== "desktop-v1" || 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, ["os", "arch"]) || input.host.os !== os || input.host.arch !== arch || !Array.isArray(input.assets) || input.assets.length !== assets.length)
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)
3742
4144
  throw new Error(`Native receipt identity or result mismatch: ${check.name}`);
3743
4145
  for (const expected of assets) {
3744
4146
  const matches = input.assets.filter((item) => validArtifact(item) && item.name === expected.name);
@@ -3747,37 +4149,68 @@ function validateDailyNativeEvidence(input, schema, context) {
3747
4149
  }
3748
4150
  if (!observationsMatch(input.observations, context))
3749
4151
  throw new Error(`Missing or invalid native observations: ${check.name}`);
3750
- return { host: { os, arch }, observations: input.observations };
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
+ };
3751
4161
  }
3752
4162
 
3753
4163
  // src/library/daily-matrix.ts
3754
4164
  var desktopDailyProfile = "desktop-v1";
4165
+ var expandedDesktopDailyProfile = "desktop-v2";
3755
4166
  var platforms = [
3756
4167
  "macos-arm64",
3757
4168
  "windows-x64",
3758
4169
  "linux-x64"
3759
4170
  ];
4171
+ var expandedPlatforms = [
4172
+ "macos-arm64",
4173
+ "macos-x64",
4174
+ "windows-x64",
4175
+ "linux-x64",
4176
+ "linux-arm64"
4177
+ ];
3760
4178
  var receiptLimit = 64 * 1024;
3761
4179
  function requireThat(ok, message) {
3762
4180
  if (!ok)
3763
4181
  throw new Error(message);
3764
4182
  }
3765
4183
  function planDailyReleaseMatrix(config, tag) {
3766
- 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");
3767
4185
  const parsed = parseReleaseConfig(config);
3768
4186
  const requirements = parsed.requirements(tag);
4187
+ const profile = config.dailyReleaseProfile;
4188
+ const expanded = profile === expandedDesktopDailyProfile;
3769
4189
  const checks = [];
3770
- for (const platform of platforms) {
4190
+ const primaryAssets = [];
4191
+ for (const platform of expanded ? expandedPlatforms : platforms) {
3771
4192
  const pair = requirements.platforms[platform];
3772
4193
  requireThat(pair?.length === 2, `Expected installer and updater archive for ${platform}`);
3773
4194
  const [installer, archive] = pair;
3774
- const suffix = platform === "macos-arm64" ? ".dmg" : platform === "windows-x64" ? "-Setup.zip" : "-Setup.tar.gz";
4195
+ const suffix = platform.startsWith("macos-") ? ".dmg" : platform === "windows-x64" ? expanded ? "-Setup.exe" : "-Setup.zip" : "-Setup.tar.gz";
3775
4196
  requireThat(installer.endsWith(suffix) && archive.endsWith(".tar.zst"), `Unexpected desktop installer or updater format for ${platform}`);
3776
- const format = platform === "macos-arm64" ? "dmg" : platform === "windows-x64" ? "windows-setup" : "portable-linux";
3777
- checks.push({ name: `installer-${platform}`, platform, format, assets: pair });
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 });
3778
4210
  for (const command of parsed.commandArtifacts) {
3779
4211
  const name = requirements.commandArtifacts?.[command.kind]?.[platform];
3780
4212
  requireThat(name, `Missing command archive for ${platform}`);
4213
+ primaryAssets.push(name);
3781
4214
  checks.push({
3782
4215
  name: `command-${command.kind}-${platform}`,
3783
4216
  platform,
@@ -3786,25 +4219,27 @@ function planDailyReleaseMatrix(config, tag) {
3786
4219
  });
3787
4220
  }
3788
4221
  }
3789
- const linux = "linux-x64";
3790
- const base = requirements.platforms[linux][1].slice(0, -".tar.zst".length);
3791
- checks.push({ name: "deb-linux-x64", platform: linux, format: "deb", assets: [base + ".deb"] }, {
3792
- name: "appimage-linux-x64",
3793
- platform: linux,
3794
- format: "appimage",
3795
- assets: [base + ".AppImage"]
3796
- });
3797
- 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
+ }
3798
4230
  discoveryPolicies(config, tag);
3799
- const all = [...names, ...requirements.releaseAssets];
4231
+ const all = [...primaryAssets, ...requirements.releaseAssets];
3800
4232
  requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
3801
- return { appId: config.appId, profile: desktopDailyProfile, assets: all, checks };
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");
3802
4237
  }
3803
4238
  function priorDailyInstallerNames(config, tag, check) {
3804
4239
  const plan = planDailyReleaseMatrix(config, tag);
3805
4240
  return {
3806
4241
  installer: plan.checks.find((entry) => entry.name === check.name)?.assets[0],
3807
- payload: plan.checks.find((entry) => entry.name === `installer-${check.platform}`)?.assets[1]
4242
+ payload: plan.checks.find((entry) => entry.platform === check.platform && entry.assets.length === 2)?.assets[1]
3808
4243
  };
3809
4244
  }
3810
4245
  function exactDirectory(root, names) {
@@ -3860,11 +4295,13 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
3860
4295
  yield* exactDirectory(receipts, matrix.checks.map((c) => c.name + ".json"));
3861
4296
  const inventory = new Map;
3862
4297
  for (const name of matrix.assets)
3863
- inventory.set(name, yield* fileIdentityEffect(join7(artifacts, name), name));
4298
+ inventory.set(name, yield* fileIdentityEffect(join8(artifacts, name), name));
3864
4299
  for (const check of matrix.checks) {
3865
- const r = yield* readNativeReceipt(join7(receipts, check.name + ".json"), check.name);
4300
+ const r = yield* readNativeReceipt(join8(receipts, check.name + ".json"), check.name);
3866
4301
  yield* attempt(() => validateDailyNativeEvidence(r, "framework/daily-native-receipt/v2", {
3867
4302
  appId: matrix.appId,
4303
+ profile: matrix.profile,
4304
+ signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
3868
4305
  identity,
3869
4306
  check,
3870
4307
  assets: check.assets.map((name) => inventory.get(name)),
@@ -3903,14 +4340,14 @@ var inspectDailyBatchEffect = (options) => Effect17.gen(function* () {
3903
4340
  const parsed = yield* attempt(() => parseReleaseConfig(config));
3904
4341
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
3905
4342
  const receiptNames = matrix.checks.map((check) => `${check.name}.json`);
3906
- const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join8(receipts, name), name));
4343
+ const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
3907
4344
  const verified = yield* verifyDailyReleaseMatrixEffect({
3908
4345
  config,
3909
4346
  identity,
3910
4347
  artifacts,
3911
4348
  receipts
3912
4349
  });
3913
- const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join8(receipts, name), name));
4350
+ const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
3914
4351
  const after = yield* verifyDailyReleaseMatrixEffect({ config, identity, artifacts, receipts });
3915
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)
3916
4353
  return yield* fail("Daily inputs changed during inspection");
@@ -4008,9 +4445,9 @@ function createDailyBatchS3Transport(client, bucket) {
4008
4445
  }
4009
4446
  async function* empty() {}
4010
4447
  // src/library/daily-native-receipt.ts
4011
- import { join as join9 } from "path";
4448
+ import { join as join10 } from "path";
4012
4449
  import { Effect as Effect18 } from "effect";
4013
- var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function* () {
4450
+ var createDailyNativeReceiptEffect = (options, worker, observedSigning) => Effect18.gen(function* () {
4014
4451
  const { config, identity, artifacts, checkName, report } = options;
4015
4452
  yield* attempt(() => assertDailyIdentity(identity));
4016
4453
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
@@ -4020,18 +4457,27 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function*
4020
4457
  const [os, arch] = platformTargets[check.platform];
4021
4458
  if (worker.os !== os || worker.arch !== arch)
4022
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");
4023
4463
  const fs = yield* ReleaseFs;
4024
4464
  const dir = yield* step(() => fs.lstat(artifacts));
4025
4465
  if (!dir.isDirectory() || dir.isSymbolicLink())
4026
4466
  return yield* fail("Expected real native artifact directory");
4027
- const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join9(artifacts, name), name));
4467
+ const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join10(artifacts, name), name));
4028
4468
  const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
4029
4469
  appId: matrix.appId,
4470
+ profile: matrix.profile,
4471
+ signing,
4030
4472
  identity,
4031
4473
  check,
4032
4474
  assets,
4033
4475
  baselineNames: (tag) => priorDailyInstallerNames(config, tag, check)
4034
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");
4035
4481
  if ("upgrade" in evidence.observations) {
4036
4482
  if (!options.baselineArtifacts)
4037
4483
  return yield* fail("Daily desktop check requires the exact baseline installer");
@@ -4042,7 +4488,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function*
4042
4488
  const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
4043
4489
  const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
4044
4490
  for (const expected of proofFiles) {
4045
- const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
4491
+ const observed = yield* fileIdentityEffect(join10(baselineDirectory, expected.name), expected.name);
4046
4492
  if (observed.size !== expected.size || observed.digest !== expected.digest)
4047
4493
  return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
4048
4494
  }
@@ -4066,47 +4512,59 @@ function createDailyNativeReceipt(options) {
4066
4512
  })));
4067
4513
  }
4068
4514
  // src/library/linux-reproducibility.ts
4069
- import { createHash as createHash9 } from "crypto";
4070
- import { lstat as lstat6, readFile as readFile5, readdir as readdir4, realpath } from "fs/promises";
4071
- import { isAbsolute as isAbsolute2, join as join10, resolve as resolve6 } from "path";
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
4072
4529
  var sha256 = /^[a-f0-9]{64}$/;
4073
- var digest2 = /^sha256:[a-f0-9]{64}$/;
4530
+ var digest3 = /^sha256:[a-f0-9]{64}$/;
4074
4531
  var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
4075
4532
  var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
4076
4533
  var filename = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
4077
- function check(ok, message) {
4534
+ function check2(ok, message) {
4078
4535
  if (!ok)
4079
4536
  throw new Error(message);
4080
4537
  }
4081
4538
  async function regular(path) {
4082
- check(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
4539
+ check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
4083
4540
  const stat = await lstat6(path);
4084
- check(stat.isFile() && !stat.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real regular input file");
4085
- check(Number.isSafeInteger(stat.size) && stat.size > 0, "Invalid input file size");
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");
4086
4543
  const result = await hashFileAt(path, stat, "Input changed during comparison");
4087
4544
  const after = await lstat6(path);
4088
- check(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");
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");
4089
4546
  return { ...result, dev: stat.dev, ino: stat.ino };
4090
4547
  }
4091
4548
  async function outputDirectory(path, expected) {
4092
- check(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
4549
+ check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
4093
4550
  const info = await lstat6(path);
4094
- check(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
4551
+ check2(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
4095
4552
  const entries = await readdir4(path, { withFileTypes: true });
4096
4553
  const names = new Set(expected);
4097
- check(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");
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");
4098
4555
  return { path, dev: info.dev, ino: info.ino, mtimeMs: info.mtimeMs, ctimeMs: info.ctimeMs };
4099
4556
  }
4100
4557
  async function directoryUnchanged(before) {
4101
4558
  const after = await lstat6(before.path);
4102
- check(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");
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");
4103
4560
  }
4104
4561
  function sameIdentity(a, b) {
4105
4562
  return a.tag === b.tag && a.sourceSha === b.sourceSha && a.workflowSha === b.workflowSha && a.runId === b.runId && a.runAttempt === b.runAttempt;
4106
4563
  }
4107
4564
  async function compareLinuxReproducibility(rawInput) {
4108
4565
  const input = structuredClone(rawInput);
4109
- check(isRecord(input) && hasExactOwnKeys(input, [
4566
+ check2(isRecord(input) && hasExactOwnKeys(input, [
4567
+ ...Object.hasOwn(input, "architecture") ? ["architecture"] : [],
4110
4568
  "config",
4111
4569
  "identity",
4112
4570
  "sourceDateEpoch",
@@ -4115,19 +4573,22 @@ async function compareLinuxReproducibility(rawInput) {
4115
4573
  "toolchainDigest",
4116
4574
  "runs"
4117
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];
4118
4579
  assertDailyIdentity(input.identity);
4119
- check(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) && digest2.test(input.toolchainDigest), "Invalid protected Linux build identity");
4120
- check(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app 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");
4121
4582
  const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
4122
- const archiveName = requirements.platforms["linux-x64"]?.[1];
4123
- check(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
4583
+ const archiveName = requirements.platforms[target.platform]?.[1];
4584
+ check2(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
4124
4585
  const stem = archiveName.slice(0, -".tar.zst".length);
4125
4586
  const artifacts = [`${stem}.deb`, `${stem}.AppImage`];
4126
4587
  const outputs = [...artifacts, "linux-format-build.json"];
4127
- check(artifacts.every((name) => filename.test(name)) && new Set(outputs).size === outputs.length, "Invalid configured Linux output names");
4128
- check(Array.isArray(input.runs) && input.runs.length === 2, "Exactly two build runs required");
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");
4129
4590
  for (const run of input.runs) {
4130
- check(isRecord(run) && hasExactOwnKeys(run, [
4591
+ check2(isRecord(run) && hasExactOwnKeys(run, [
4131
4592
  "identity",
4132
4593
  "appId",
4133
4594
  "sourceDateEpoch",
@@ -4137,19 +4598,19 @@ async function compareLinuxReproducibility(rawInput) {
4137
4598
  "toolchainDigest",
4138
4599
  "archive",
4139
4600
  "output"
4140
- ]) && 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-x86_64" && run.imageReference === input.imageReference && run.toolchainDigest === input.toolchainDigest && typeof run.archive === "string" && typeof run.output === "string", "Linux build identity mismatch");
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");
4141
4602
  }
4142
4603
  const first = input.runs[0];
4143
4604
  const second = input.runs[1];
4144
- check(first.jobId !== second.jobId, "Build jobs must be distinct");
4605
+ check2(first.jobId !== second.jobId, "Build jobs must be distinct");
4145
4606
  const firstDir = await outputDirectory(first.output, outputs);
4146
4607
  const secondDir = await outputDirectory(second.output, outputs);
4147
- check(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
4608
+ check2(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
4148
4609
  const firstArchive = await regular(first.archive);
4149
4610
  const secondArchive = await regular(second.archive);
4150
4611
  for (const archive of [firstArchive, secondArchive])
4151
- check(archive.size === input.archive.size && archive.sha256 === input.archive.sha256, "Build archive does not match the independently verified input");
4152
- check(firstArchive.dev !== secondArchive.dev || firstArchive.ino !== secondArchive.ino, "Build archive copies must be distinct");
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");
4153
4614
  const observed = [
4154
4615
  { path: first.archive, file: firstArchive },
4155
4616
  { path: second.archive, file: secondArchive }
@@ -4160,37 +4621,39 @@ async function compareLinuxReproducibility(rawInput) {
4160
4621
  ]);
4161
4622
  const result = [];
4162
4623
  for (const name of artifacts) {
4163
- const left = await regular(join10(first.output, name));
4164
- const right = await regular(join10(second.output, name));
4624
+ const left = await regular(join11(first.output, name));
4625
+ const right = await regular(join11(second.output, name));
4165
4626
  for (const file of [left, right]) {
4166
4627
  const key = `${file.dev}:${file.ino}`;
4167
- check(!seen.has(key), "Build inputs and outputs must be independent files");
4628
+ check2(!seen.has(key), "Build inputs and outputs must be independent files");
4168
4629
  seen.add(key);
4169
4630
  }
4170
- observed.push({ path: join10(first.output, name), file: left });
4171
- observed.push({ path: join10(second.output, name), file: right });
4172
- check(left.size === right.size && left.sha256 === right.sha256, `Linux build differs: ${name}`);
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}`);
4173
4634
  result.push({ name, size: left.size, sha256: left.sha256 });
4174
4635
  }
4175
4636
  for (const run of input.runs) {
4176
- const path = join10(run.output, "linux-format-build.json");
4637
+ const path = join11(run.output, "linux-format-build.json");
4177
4638
  const file = await regular(path);
4178
4639
  const key = `${file.dev}:${file.ino}`;
4179
- check(!seen.has(key), "Build inputs and outputs must be independent files");
4640
+ check2(!seen.has(key), "Build inputs and outputs must be independent files");
4180
4641
  seen.add(key);
4181
4642
  observed.push({ path, file });
4182
- check(file.size <= 65536, "Producer receipt is too large");
4183
- const bytes = await readFile5(path);
4184
- check(bytes.length === file.size && createHash9("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
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");
4185
4646
  let receipt;
4186
4647
  try {
4187
4648
  receipt = JSON.parse(bytes.toString("utf8"));
4188
4649
  } catch {
4189
4650
  throw new Error("Invalid producer receipt");
4190
4651
  }
4191
- check(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
4652
+ check2(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
4192
4653
  const receiptArtifacts = receipt.artifacts;
4193
- check(hasExactOwnKeys(receipt, [
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"] : [],
4194
4657
  "schema",
4195
4658
  "tag",
4196
4659
  "sourceSha",
@@ -4198,17 +4661,18 @@ async function compareLinuxReproducibility(rawInput) {
4198
4661
  "platform",
4199
4662
  "updateArchiveSha256",
4200
4663
  "artifacts"
4201
- ]) && receipt.schema === "linux-package-formats/v1" && receipt.tag === input.identity.tag && receipt.sourceSha === input.identity.sourceSha && receipt.sourceDateEpoch === input.sourceDateEpoch && receipt.platform === "linux-x64" && 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");
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");
4202
4665
  }
4203
4666
  for (const previous of observed) {
4204
4667
  const current = await regular(previous.path);
4205
- check(current.dev === previous.file.dev && current.ino === previous.file.ino && current.size === previous.file.size && current.sha256 === previous.file.sha256, "Input changed during comparison");
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");
4206
4669
  }
4207
4670
  await directoryUnchanged(firstDir);
4208
4671
  await directoryUnchanged(secondDir);
4209
4672
  return {
4210
4673
  schema: "framework/linux-format-byte-comparison/v1",
4211
4674
  qualified: false,
4675
+ platform: target.platform,
4212
4676
  appId: input.config.appId,
4213
4677
  identity: input.identity,
4214
4678
  sourceDateEpoch: input.sourceDateEpoch,
@@ -4230,7 +4694,7 @@ import {
4230
4694
  rmSync,
4231
4695
  symlinkSync
4232
4696
  } from "fs";
4233
- import { basename as basename4, dirname, join as join11, resolve as resolve7 } from "path";
4697
+ import { basename as basename4, dirname, join as join12, resolve as resolve7 } from "path";
4234
4698
  import { Context as Context2, Effect as Effect19 } from "effect";
4235
4699
 
4236
4700
  // ../../src/release/macos-dmg.ts
@@ -4262,7 +4726,7 @@ function treeSize(root) {
4262
4726
  logicalBytes += info.size;
4263
4727
  else if (info.isDirectory())
4264
4728
  for (const name of readdirSync(path))
4265
- pending.push(join11(path, name));
4729
+ pending.push(join12(path, name));
4266
4730
  else if (!info.isSymbolicLink())
4267
4731
  throw new Error("Unsupported disk image entry");
4268
4732
  if (!Number.isSafeInteger(logicalBytes))
@@ -4288,11 +4752,11 @@ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
4288
4752
  const info = yield* attempt(() => lstatSync(app));
4289
4753
  if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
4290
4754
  return yield* fail("Invalid disk image paths");
4291
- const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(join11(dirname(output), ".framework-dmg-"))), (path) => Effect19.sync(() => rmSync(path, { recursive: true, force: true })));
4292
- const payload = join11(staging, "payload"), image = join11(staging, "result.dmg");
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");
4293
4757
  yield* attempt(() => mkdirSync(payload));
4294
- yield* attempt(() => host.run("/usr/bin/ditto", [app, join11(payload, basename4(app))]));
4295
- yield* attempt(() => symlinkSync("/Applications", join11(payload, "Applications")));
4758
+ yield* attempt(() => host.run("/usr/bin/ditto", [app, join12(payload, basename4(app))]));
4759
+ yield* attempt(() => symlinkSync("/Applications", join12(payload, "Applications")));
4296
4760
  const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
4297
4761
  yield* attempt(() => host.run("/usr/bin/hdiutil", [
4298
4762
  "create",
@@ -4324,16 +4788,16 @@ function createMacosDmg(options) {
4324
4788
  import { Effect as Effect22 } from "effect";
4325
4789
 
4326
4790
  // src/library/local-release.ts
4327
- import { createHash as createHash11 } from "crypto";
4791
+ import { createHash as createHash13 } from "crypto";
4328
4792
  import { constants as constants3 } from "fs";
4329
- import { dirname as dirname2, join as join13, resolve as resolve9 } from "path";
4793
+ import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
4330
4794
  import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
4331
4795
 
4332
4796
  // ../../src/native/native-rename.ts
4333
4797
  import { randomUUID } from "crypto";
4334
- import { mkdir as mkdir3, readFile as readFile6, rm as rm3, writeFile as writeFile3 } from "fs/promises";
4798
+ import { mkdir as mkdir3, readFile as readFile7, rm as rm4, writeFile as writeFile4 } from "fs/promises";
4335
4799
  import { dlopen, FFIType, ptr } from "bun:ffi";
4336
- import { join as join12 } from "path";
4800
+ import { join as join13 } from "path";
4337
4801
 
4338
4802
  // ../../src/native/canonical-path.ts
4339
4803
  import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
@@ -4412,8 +4876,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
4412
4876
  if (!isCanonicalPath(parent))
4413
4877
  throw new Error("Invalid directory exchange probe parent");
4414
4878
  const id = randomUUID();
4415
- const first = join12(parent, `.framework-exchange-probe-${id}-a`);
4416
- const second = join12(parent, `.framework-exchange-probe-${id}-b`);
4879
+ const first = join13(parent, `.framework-exchange-probe-${id}-a`);
4880
+ const second = join13(parent, `.framework-exchange-probe-${id}-b`);
4417
4881
  const marker = "exchange-probe";
4418
4882
  const firstValue = `${id}:first`;
4419
4883
  const secondValue = `${id}:second`;
@@ -4424,21 +4888,21 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
4424
4888
  firstCreated = true;
4425
4889
  await mkdir3(second, { mode: 448 });
4426
4890
  secondCreated = true;
4427
- await writeFile3(join12(first, marker), firstValue, { flag: "wx", mode: 384 });
4428
- await writeFile3(join12(second, marker), secondValue, { flag: "wx", mode: 384 });
4891
+ await writeFile4(join13(first, marker), firstValue, { flag: "wx", mode: 384 });
4892
+ await writeFile4(join13(second, marker), secondValue, { flag: "wx", mode: 384 });
4429
4893
  exchange(first, second);
4430
4894
  const [firstAfter, secondAfter] = await Promise.all([
4431
- readFile6(join12(first, marker), "utf8"),
4432
- readFile6(join12(second, marker), "utf8")
4895
+ readFile7(join13(first, marker), "utf8"),
4896
+ readFile7(join13(second, marker), "utf8")
4433
4897
  ]);
4434
4898
  if (firstAfter !== secondValue || secondAfter !== firstValue)
4435
4899
  throw new Error("Directory exchange did not exchange both probe trees");
4436
4900
  } finally {
4437
4901
  const cleanup = [];
4438
4902
  if (firstCreated)
4439
- cleanup.push(rm3(first, { recursive: true, force: true }));
4903
+ cleanup.push(rm4(first, { recursive: true, force: true }));
4440
4904
  if (secondCreated)
4441
- cleanup.push(rm3(second, { recursive: true, force: true }));
4905
+ cleanup.push(rm4(second, { recursive: true, force: true }));
4442
4906
  await Promise.all(cleanup);
4443
4907
  }
4444
4908
  }
@@ -4494,7 +4958,7 @@ function createFeedReleaseCutProvider(options) {
4494
4958
  }
4495
4959
 
4496
4960
  // src/library/feed-state.ts
4497
- import { createHash as createHash10 } from "crypto";
4961
+ import { createHash as createHash12 } from "crypto";
4498
4962
  import { Effect as Effect20 } from "effect";
4499
4963
 
4500
4964
  // ../../src/shared/discard-stream.ts
@@ -4742,7 +5206,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
4742
5206
  if (!listed)
4743
5207
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
4744
5208
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
4745
- if (!bytes || bytes.length !== listed.size || createHash10("sha256").update(bytes).digest("hex") !== listed.sha256)
5209
+ if (!bytes || bytes.length !== listed.size || createHash12("sha256").update(bytes).digest("hex") !== listed.sha256)
4746
5210
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
4747
5211
  const verified = verifyReleaseDescriptor(json(bytes), {
4748
5212
  appId: policy.appId,
@@ -4848,7 +5312,7 @@ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4848
5312
  const payloads = platformPayloads(local.requirements(tag), platform);
4849
5313
  const directory = resolve9(options.directory);
4850
5314
  yield* exactFiles(directory, payloads);
4851
- const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join13(directory, name), name), { concurrency: "unbounded" });
5315
+ const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
4852
5316
  const signed = signDiscoveryDescriptors({
4853
5317
  policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
4854
5318
  assets,
@@ -4866,7 +5330,7 @@ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4866
5330
  privateKey: options.privateKey
4867
5331
  });
4868
5332
  for (const asset of assets)
4869
- if (JSON.stringify(yield* fileIdentityEffect(join13(directory, asset.name), asset.name)) !== JSON.stringify(asset))
5333
+ if (JSON.stringify(yield* fileIdentityEffect(join14(directory, asset.name), asset.name)) !== JSON.stringify(asset))
4870
5334
  return yield* fail("Staged payload changed before signing");
4871
5335
  yield* writeDescriptorsEffect(directory, signed);
4872
5336
  return signed.map((value) => value.name);
@@ -4886,7 +5350,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
4886
5350
  var describe = (key, bytes, cacheControl) => ({
4887
5351
  key,
4888
5352
  size: bytes.length,
4889
- sha256: createHash11("sha256").update(bytes).digest("hex"),
5353
+ sha256: createHash13("sha256").update(bytes).digest("hex"),
4890
5354
  contentType: "application/json",
4891
5355
  cacheControl
4892
5356
  });
@@ -4897,11 +5361,11 @@ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* (
4897
5361
  if (exists)
4898
5362
  return yield* fail("Release output directory already exists");
4899
5363
  yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
4900
- const staging = yield* step(() => fs.mkdtemp(join13(dirname2(root), ".release-staging-")));
5364
+ const staging = yield* step(() => fs.mkdtemp(join14(dirname2(root), ".release-staging-")));
4901
5365
  const exit = yield* Effect21.exit(Effect21.gen(function* () {
4902
5366
  const objects = [];
4903
5367
  for (const { key, path, artifact } of assets) {
4904
- const target = join13(staging, key);
5368
+ const target = join14(staging, key);
4905
5369
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4906
5370
  yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
4907
5371
  if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
@@ -4915,13 +5379,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* (
4915
5379
  });
4916
5380
  }
4917
5381
  for (const { key, bytes } of documents) {
4918
- const target = join13(staging, key);
5382
+ const target = join14(staging, key);
4919
5383
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4920
5384
  yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
4921
5385
  objects.push(describe(key, bytes, MUTABLE));
4922
5386
  }
4923
5387
  const plan = { schema: 1, base: feed.base, objects };
4924
- yield* step(() => fs.writeFile(join13(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
5388
+ yield* step(() => fs.writeFile(join14(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
4925
5389
  yield* attempt(() => renameExclusive(staging, root));
4926
5390
  return plan;
4927
5391
  }));
@@ -4969,13 +5433,13 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
4969
5433
  const directory = resolve9(options.directory);
4970
5434
  const names = [...payloads, ...policies.map((policy) => policy.name)];
4971
5435
  yield* exactFiles(directory, names);
4972
- const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join13(directory, name), name), { concurrency: "unbounded" });
5436
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
4973
5437
  for (const policy of policies) {
4974
5438
  const artifact = staged.find((asset) => asset.name === policy.name);
4975
5439
  if (artifact.size > 65536)
4976
5440
  return yield* fail("Signed descriptor is too large");
4977
- const bytes = yield* step(() => fs.readFile(join13(directory, policy.name)));
4978
- if ("sha256:" + createHash11("sha256").update(bytes).digest("hex") !== artifact.digest)
5441
+ const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
5442
+ if ("sha256:" + createHash13("sha256").update(bytes).digest("hex") !== artifact.digest)
4979
5443
  return yield* fail("Signed descriptor changed");
4980
5444
  let parsed;
4981
5445
  try {
@@ -5014,7 +5478,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5014
5478
  merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
5015
5479
  uploads.push({
5016
5480
  key: feedAssetKey(feed, tag, artifact.name),
5017
- path: join13(directory, artifact.name),
5481
+ path: join14(directory, artifact.name),
5018
5482
  artifact
5019
5483
  });
5020
5484
  }
@@ -5334,12 +5798,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
5334
5798
  });
5335
5799
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
5336
5800
  // src/library/staging.ts
5337
- import { createHash as createHash12 } from "crypto";
5338
- import { join as join14, resolve as resolve10 } from "path";
5801
+ import { createHash as createHash14 } from "crypto";
5802
+ import { join as join15, resolve as resolve10 } from "path";
5339
5803
  import { Effect as Effect24 } from "effect";
5340
5804
  var copyHashed = (input, output, size) => Effect24.tryPromise({
5341
5805
  try: async (signal) => {
5342
- const hash = createHash12("sha256");
5806
+ const hash = createHash14("sha256");
5343
5807
  let copied = 0;
5344
5808
  for await (const chunk of input.createReadStream({
5345
5809
  autoClose: false
@@ -5384,7 +5848,7 @@ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
5384
5848
  const before = yield* step(() => input.stat());
5385
5849
  if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
5386
5850
  return yield* fail("Staging source changed");
5387
- const target = join14(directory, name);
5851
+ const target = join15(directory, name);
5388
5852
  const output = yield* scopedHandle(() => fs.open(target, "wx"));
5389
5853
  created.push(target);
5390
5854
  const copied = yield* copyHashed(input, output, before.size);
@@ -5405,11 +5869,11 @@ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
5405
5869
  });
5406
5870
  var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
5407
5871
  // src/library/steps.ts
5408
- import { join as join34 } from "path";
5872
+ import { join as join35 } from "path";
5409
5873
  import { Effect as Effect25 } from "effect";
5410
5874
 
5411
5875
  // ../../src/installer/installer-archive-members.ts
5412
- import { createHash as createHash13 } from "crypto";
5876
+ import { createHash as createHash15 } from "crypto";
5413
5877
  import { lstat as lstat7, open as open4 } from "fs/promises";
5414
5878
  import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
5415
5879
 
@@ -5418,8 +5882,8 @@ async function assertNativeExecutable(file, size, platform, what) {
5418
5882
  const head = Buffer.alloc(64);
5419
5883
  if ((await file.read(head, 0, head.length, 0)).bytesRead !== head.length)
5420
5884
  throw new Error(`Invalid ${what}`);
5421
- if (platform === "macos-arm64") {
5422
- 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))
5423
5887
  throw new Error(`Invalid macOS ${what}`);
5424
5888
  } else if (platform === "linux-x64" || platform === "linux-arm64") {
5425
5889
  if (!head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) || head[4] !== 2 || head.readUInt16LE(18) !== (platform === "linux-x64" ? 62 : 183))
@@ -5516,7 +5980,7 @@ async function assertEmbeddedArchive(path, size, archive) {
5516
5980
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
5517
5981
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
5518
5982
  throw new Error("Installer archive marker is missing");
5519
- const hash = createHash13("sha256");
5983
+ const hash = createHash15("sha256");
5520
5984
  let read = 0;
5521
5985
  for await (const chunk of file.createReadStream({
5522
5986
  start: position + marker.length,
@@ -5533,13 +5997,13 @@ async function assertEmbeddedArchive(path, size, archive) {
5533
5997
  }
5534
5998
 
5535
5999
  // ../../src/installer/installer-identity.ts
5536
- import { lstat as lstat9, mkdtemp as mkdtemp4, readdir as readdir6, realpath as realpath2 } from "fs/promises";
5537
- import { tmpdir as tmpdir4 } from "os";
5538
- import { basename as basename5, join as join16, resolve as resolve11, win32 } from "path";
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";
5539
6003
 
5540
6004
  // ../../src/installer/installer-image-mount.ts
5541
- import { lstat as lstat8, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir5, rm as rm4, stat } from "fs/promises";
5542
- import { dirname as dirname3, join as join15 } from "path";
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";
5543
6007
  var FAILED_ATTACH_PROBES = 5;
5544
6008
  var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
5545
6009
  async function containsMountAt(path, expectedDevice) {
@@ -5549,7 +6013,7 @@ async function containsMountAt(path, expectedDevice) {
5549
6013
  if (info.dev !== expectedDevice)
5550
6014
  return true;
5551
6015
  for (const name of await readdir5(path)) {
5552
- const child = join15(path, name), childInfo = await lstat8(child);
6016
+ const child = join16(path, name), childInfo = await lstat8(child);
5553
6017
  if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
5554
6018
  continue;
5555
6019
  if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
@@ -5575,7 +6039,7 @@ function defaultInstallerImageMountIo(run) {
5575
6039
  state: installerImageMountState,
5576
6040
  containsNestedMount,
5577
6041
  wait: Bun.sleep,
5578
- remove: (directory) => rm4(directory, { recursive: true, force: true })
6042
+ remove: (directory) => rm5(directory, { recursive: true, force: true })
5579
6043
  };
5580
6044
  }
5581
6045
  async function assertNoNestedInstallerMount(directory, io) {
@@ -5743,8 +6207,8 @@ async function withInstallerImageRetries(options) {
5743
6207
  };
5744
6208
  const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
5745
6209
  for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
5746
- const directory = await mkdtemp3(join15(options.parent, options.prefix));
5747
- const mount = join15(directory, "mount");
6210
+ const directory = await mkdtemp4(join16(options.parent, options.prefix));
6211
+ const mount = join16(directory, "mount");
5748
6212
  const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
5749
6213
  let lifecycleStarted = false;
5750
6214
  try {
@@ -5911,7 +6375,7 @@ async function runInstallerCommand(args, env, options) {
5911
6375
  }
5912
6376
 
5913
6377
  // ../../src/installer/installer-identity.ts
5914
- async function identity(path) {
6378
+ async function identity2(path) {
5915
6379
  const info = await lstat9(path);
5916
6380
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
5917
6381
  throw new Error("Invalid installer artifact");
@@ -5940,16 +6404,16 @@ async function verifyInstallerPayload(options) {
5940
6404
  assertInstallerContext(parent, options.platform, process.platform, process.arch);
5941
6405
  assertPortableAppName(options.appName);
5942
6406
  const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
5943
- const before = { installer: await identity(installerPath), archive: await identity(archivePath) };
6407
+ const before = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
5944
6408
  if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
5945
6409
  throw new Error("Installer archive exceeds bound");
5946
6410
  const env = environment(parent);
5947
- const temporary = await mkdtemp4(join16(tmpdir4(), "framework-installer-inspect-"));
6411
+ const temporary = await mkdtemp5(join17(tmpdir5(), "framework-installer-inspect-"));
5948
6412
  const cleanupIo = defaultInstallerImageMountIo(command);
5949
6413
  try {
5950
- if (options.platform === "macos-arm64") {
6414
+ if (isMacInstallerPlatform(options.platform)) {
5951
6415
  await withInstallerImageRetries({
5952
- parent: tmpdir4(),
6416
+ parent: tmpdir5(),
5953
6417
  prefix: "framework-installer-inspect-attempt-",
5954
6418
  image: installerPath,
5955
6419
  env,
@@ -5958,21 +6422,21 @@ async function verifyInstallerPayload(options) {
5958
6422
  const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
5959
6423
  if (apps.length !== 1)
5960
6424
  throw new Error("Installer application is missing or ambiguous");
5961
- const resources = join16(mount, apps[0], "Contents", "Resources");
5962
- const actualRoot = await realpath2(mount), actualApp = await realpath2(join16(mount, apps[0])), actualResources = await realpath2(resources);
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);
5963
6427
  if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
5964
6428
  throw new Error("Installer resources escape mounted image");
5965
- const plist = join16(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
6429
+ const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
5966
6430
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5967
6431
  throw new Error("Invalid installer property list");
5968
6432
  const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
5969
6433
  if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
5970
6434
  throw new Error("Invalid installer executable name");
5971
- await assertInstallerExecutable(join16(actualApp, "Contents", "MacOS", executable), options.platform);
6435
+ await assertInstallerExecutable(join17(actualApp, "Contents", "MacOS", executable), options.platform);
5972
6436
  const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
5973
6437
  if (archives.length !== 1)
5974
6438
  throw new Error("Installer archive is missing or ambiguous");
5975
- const embedded = await identity(join16(actualResources, archives[0]));
6439
+ const embedded = await identity2(join17(actualResources, archives[0]));
5976
6440
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
5977
6441
  throw new Error("Installer archive differs from release archive");
5978
6442
  }
@@ -5981,7 +6445,7 @@ async function verifyInstallerPayload(options) {
5981
6445
  const systemRoot = parent.SystemRoot;
5982
6446
  if (options.platform === "windows-x64" && (!systemRoot || !/^[A-Za-z]:[\\/]/.test(systemRoot)))
5983
6447
  throw new Error("Missing Windows system directory");
5984
- const tar = options.platform === "windows-x64" ? win32.join(systemRoot, "System32", "tar.exe") : "tar";
6448
+ const tar = options.platform === "windows-x64" ? win322.join(systemRoot, "System32", "tar.exe") : "tar";
5985
6449
  if (options.platform === "windows-x64" && !/^bsdtar\s/i.test((await command([tar, "--version"], env)).trim()))
5986
6450
  throw new Error("Windows installer inspection requires system bsdtar");
5987
6451
  const names = (await command([tar, "-tf", installerPath], env)).split(/\r?\n/).filter(Boolean);
@@ -5990,7 +6454,7 @@ async function verifyInstallerPayload(options) {
5990
6454
  const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
5991
6455
  if (matches.length !== 1)
5992
6456
  throw new Error("Installer archive is missing or ambiguous");
5993
- const extracted = join16(temporary, "member");
6457
+ const extracted = join17(temporary, "member");
5994
6458
  const count = await extractArchiveMember({
5995
6459
  tar,
5996
6460
  archive: installerPath,
@@ -6001,7 +6465,7 @@ async function verifyInstallerPayload(options) {
6001
6465
  });
6002
6466
  if (options.platform === "windows-x64") {
6003
6467
  const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
6004
- const executable = join16(temporary, "setup.exe");
6468
+ const executable = join17(temporary, "setup.exe");
6005
6469
  await extractArchiveMember({
6006
6470
  tar,
6007
6471
  archive: installerPath,
@@ -6011,7 +6475,7 @@ async function verifyInstallerPayload(options) {
6011
6475
  env
6012
6476
  });
6013
6477
  await assertInstallerExecutable(executable, options.platform);
6014
- const embedded = await identity(extracted);
6478
+ const embedded = await identity2(extracted);
6015
6479
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
6016
6480
  throw new Error("Installer archive differs from release archive");
6017
6481
  } else {
@@ -6019,7 +6483,7 @@ async function verifyInstallerPayload(options) {
6019
6483
  await assertEmbeddedArchive(extracted, count, before.archive);
6020
6484
  }
6021
6485
  }
6022
- const after = { installer: await identity(installerPath), archive: await identity(archivePath) };
6486
+ const after = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
6023
6487
  if (JSON.stringify(before) !== JSON.stringify(after))
6024
6488
  throw new Error("Installer artifacts changed during inspection");
6025
6489
  await cleanupInstallerDirectoryAfterFailure(temporary, undefined, cleanupIo);
@@ -6037,19 +6501,19 @@ async function verifyInstallerPayload(options) {
6037
6501
  }
6038
6502
 
6039
6503
  // ../../src/installer/installer-qualification-command.ts
6040
- import { lstat as lstat19, writeFile as writeFile9 } from "fs/promises";
6041
- import { join as join31, resolve as resolve14 } from "path";
6504
+ import { lstat as lstat19, writeFile as writeFile10 } from "fs/promises";
6505
+ import { join as join32, resolve as resolve14 } from "path";
6042
6506
 
6043
6507
  // ../../src/installer/installer-observation.ts
6044
6508
  import { randomBytes as randomBytes3 } from "crypto";
6045
- import { chmod as chmod2, mkdir as mkdir9, readFile as readFile10, realpath as realpath9, writeFile as writeFile8 } from "fs/promises";
6509
+ import { chmod as chmod2, mkdir as mkdir9, readFile as readFile11, realpath as realpath9, writeFile as writeFile9 } from "fs/promises";
6046
6510
  import { createServer } from "net";
6047
- import { delimiter, dirname as dirname12, join as join30 } from "path";
6511
+ import { delimiter, dirname as dirname12, join as join31 } from "path";
6048
6512
 
6049
6513
  // ../../src/installer/installer-ci-bootstrap.ts
6050
6514
  import { randomBytes as randomBytes2 } from "crypto";
6051
- import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath3, rm as rm5, writeFile as writeFile4 } from "fs/promises";
6052
- import { dirname as dirname4, isAbsolute as isAbsolute5, join as join17, relative as relative4, sep as sep3 } from "path";
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";
6053
6517
  import { fileURLToPath } from "url";
6054
6518
  var bootstrapModules = [
6055
6519
  "app/value-guards.js",
@@ -6076,27 +6540,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
6076
6540
  if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
6077
6541
  throw new Error("Runner temp cannot represent a Bun preload path");
6078
6542
  const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
6079
- const directory = await mkdtemp5(join17(parent, "framework-ci-"));
6543
+ const directory = await mkdtemp6(join18(parent, "framework-ci-"));
6080
6544
  try {
6081
6545
  for (const name of bootstrapModules) {
6082
- const contents = await readBoundedFile(join17(source, name), 2 * 1024 * 1024, "installer bootstrap module");
6083
- await mkdir5(dirname4(join17(directory, name)), { recursive: true, mode: 448 });
6084
- await writeFile4(join17(directory, name), contents, { flag: "wx", mode: 384 });
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 });
6085
6549
  }
6086
- await writeFile4(join17(directory, "package.json"), `{"type":"module"}
6550
+ await writeFile5(join18(directory, "package.json"), `{"type":"module"}
6087
6551
  `, {
6088
6552
  flag: "wx",
6089
6553
  mode: 384
6090
6554
  });
6091
- const worker = join17(directory, "installer/installer-ci-worker.js");
6555
+ const worker = join18(directory, "installer/installer-ci-worker.js");
6092
6556
  return {
6093
6557
  directory,
6094
6558
  worker,
6095
- preflight: join17(directory, "installer/installer-ci-preflight.js"),
6559
+ preflight: join18(directory, "installer/installer-ci-preflight.js"),
6096
6560
  bunOptions: `--preload=${worker}`
6097
6561
  };
6098
6562
  } catch (error) {
6099
- await rm5(directory, { recursive: true, force: true });
6563
+ await rm6(directory, { recursive: true, force: true });
6100
6564
  throw error;
6101
6565
  }
6102
6566
  }
@@ -6107,7 +6571,7 @@ async function preflightInstallerRuntime(options) {
6107
6571
  throw new Error("Runtime preflight requires a disposable hosted runner");
6108
6572
  const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
6109
6573
  const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
6110
- if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute5(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join17(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join17(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
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}`)
6111
6575
  throw new Error("Invalid installer bootstrap location");
6112
6576
  await runInstallerPreflight({
6113
6577
  env,
@@ -6127,7 +6591,7 @@ async function runInstallerPreflight(options) {
6127
6591
  const info = await lstat10(runtime);
6128
6592
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
6129
6593
  throw new Error("Invalid candidate Bun runtime");
6130
- const temporary = await mkdtemp5(join17(options.parent, "framework-preflight-"));
6594
+ const temporary = await mkdtemp6(join18(options.parent, "framework-preflight-"));
6131
6595
  try {
6132
6596
  const clean = {};
6133
6597
  for (const key of [
@@ -6152,11 +6616,11 @@ async function runInstallerPreflight(options) {
6152
6616
  BUN_OPTIONS: `--preload=${worker}`,
6153
6617
  FRAMEWORK_CI_WORKER_ENTRY: preflight,
6154
6618
  FRAMEWORK_CI_NONCE: nonce,
6155
- FRAMEWORK_CI_ACK: join17(temporary, "ack"),
6156
- FRAMEWORK_CI_PERMIT: join17(temporary, "permit"),
6619
+ FRAMEWORK_CI_ACK: join18(temporary, "ack"),
6620
+ FRAMEWORK_CI_PERMIT: join18(temporary, "permit"),
6157
6621
  FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
6158
- FRAMEWORK_CI_OBSERVATION: join17(temporary, "observation"),
6159
- FRAMEWORK_CI_UNEXPECTED: join17(temporary, "unexpected"),
6622
+ FRAMEWORK_CI_OBSERVATION: join18(temporary, "observation"),
6623
+ FRAMEWORK_CI_UNEXPECTED: join18(temporary, "unexpected"),
6160
6624
  FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
6161
6625
  "https://example.invalid/framework-ci-sentinel"
6162
6626
  ])
@@ -6191,28 +6655,28 @@ async function runInstallerPreflight(options) {
6191
6655
  if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
6192
6656
  throw new Error("Candidate Bun runtime failed installer preflight");
6193
6657
  try {
6194
- await lstat10(join17(temporary, "unexpected"));
6658
+ await lstat10(join18(temporary, "unexpected"));
6195
6659
  throw new Error("Runtime preflight recorded unexpected activity");
6196
6660
  } catch (error) {
6197
6661
  if (errorCode(error) !== "ENOENT")
6198
6662
  throw error;
6199
6663
  }
6200
6664
  } finally {
6201
- await rm5(temporary, { recursive: true, force: true });
6665
+ await rm6(temporary, { recursive: true, force: true });
6202
6666
  }
6203
6667
  }
6204
6668
 
6205
6669
  // ../../src/installer/installer-extraction.ts
6206
- import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir7, realpath as realpath4 } from "fs/promises";
6207
- import { join as join18, resolve as resolve12, win32 as win322 } from "path";
6208
- async function run(cmd, env) {
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) {
6209
6673
  return runInstallerCommand(cmd, env, {
6210
6674
  outputLimit: 8 * 1024 * 1024,
6211
6675
  overflowMessage: "Installer command output exceeds bound",
6212
6676
  failureMessage: "Installer preparation command failed"
6213
6677
  });
6214
6678
  }
6215
- async function digest3(path) {
6679
+ async function digest4(path) {
6216
6680
  const info = await lstat11(path);
6217
6681
  if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
6218
6682
  throw new Error("Invalid extracted file");
@@ -6256,50 +6720,50 @@ async function prepareInstallerExecution(options) {
6256
6720
  archive: sourceArchive,
6257
6721
  env
6258
6722
  });
6259
- const directory = await mkdtemp6(join18(parent, "framework-installer-"));
6260
- const imageIo = defaultInstallerImageMountIo(run);
6723
+ const directory = await mkdtemp7(join19(parent, "framework-installer-"));
6724
+ const imageIo = defaultInstallerImageMountIo(run2);
6261
6725
  try {
6262
- const profile = join18(directory, "profile"), incoming = join18(directory, "incoming");
6726
+ const profile = join19(directory, "profile"), incoming = join19(directory, "incoming");
6263
6727
  await mkdir6(profile, { mode: 448 });
6264
6728
  await mkdir6(incoming, { mode: 448 });
6265
6729
  const clean = cleanEnv(env);
6266
6730
  let executable;
6267
- if (options.platform === "macos-arm64") {
6731
+ if (isMacInstallerPlatform(options.platform)) {
6268
6732
  executable = await withInstallerImageRetries({
6269
6733
  parent,
6270
6734
  prefix: "framework-installer-mount-attempt-",
6271
6735
  image: sourceInstaller,
6272
6736
  env: clean,
6273
- run,
6737
+ run: run2,
6274
6738
  work: async (mount) => {
6275
6739
  const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
6276
6740
  if (apps.length !== 1 || apps[0] !== appName)
6277
6741
  throw new Error("Unexpected installer application");
6278
- const sourceApp = await realpath4(join18(mount, appName)), mountRoot = await realpath4(mount);
6742
+ const sourceApp = await realpath4(join19(mount, appName)), mountRoot = await realpath4(mount);
6279
6743
  if (!isWithin(mountRoot, sourceApp))
6280
6744
  throw new Error("Installer application escapes image");
6281
- const app = join18(incoming, appName);
6282
- await run(["/usr/bin/ditto", sourceApp, app], clean);
6283
- const actualApp = await realpath4(app), resources = await realpath4(join18(actualApp, "Contents", "Resources"));
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"));
6284
6748
  if (!isWithin(await realpath4(incoming), actualApp) || !isWithin(actualApp, resources))
6285
6749
  throw new Error("Copied installer escapes profile");
6286
- const plist = join18(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
6750
+ const plist = join19(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
6287
6751
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
6288
6752
  throw new Error("Invalid installer property list");
6289
- const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
6753
+ const name = (await run2(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
6290
6754
  if (!name || name === "." || name === ".." || /[\\/]/.test(name))
6291
6755
  throw new Error("Invalid installer executable");
6292
- const appExecutable = join18(actualApp, "Contents", "MacOS", name);
6293
- const sourceExecutable = join18(sourceApp, "Contents", "MacOS", name);
6756
+ const appExecutable = join19(actualApp, "Contents", "MacOS", name);
6757
+ const sourceExecutable = join19(sourceApp, "Contents", "MacOS", name);
6294
6758
  if (!isWithin(actualApp, await realpath4(appExecutable)) || !isWithin(sourceApp, await realpath4(sourceExecutable)))
6295
6759
  throw new Error("Installer executable escapes application");
6296
6760
  await assertInstallerExecutable(appExecutable, options.platform);
6297
- if (JSON.stringify(await digest3(sourceExecutable)) !== JSON.stringify(await digest3(appExecutable)))
6761
+ if (JSON.stringify(await digest4(sourceExecutable)) !== JSON.stringify(await digest4(appExecutable)))
6298
6762
  throw new Error("Copied installer executable differs");
6299
6763
  const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
6300
6764
  if (archives.length !== 1)
6301
6765
  throw new Error("Missing installer archive");
6302
- const embedded = await digest3(join18(resources, archives[0]));
6766
+ const embedded = await digest4(join19(resources, archives[0]));
6303
6767
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
6304
6768
  throw new Error("Copied installer archive differs");
6305
6769
  return executable;
@@ -6309,14 +6773,14 @@ async function prepareInstallerExecution(options) {
6309
6773
  const root = env.SystemRoot;
6310
6774
  if (options.platform === "windows-x64" && (!root || !/^[A-Za-z]:[\\/]/.test(root)))
6311
6775
  throw new Error("Missing Windows system directory");
6312
- const tar = options.platform === "windows-x64" ? win322.join(root, "System32", "tar.exe") : "tar";
6313
- const names = (await run([tar, "-tf", sourceInstaller], clean)).split(/\r?\n/).filter(Boolean);
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);
6314
6778
  assertInstallerLayout(options.platform, options.appName, names);
6315
6779
  const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
6316
6780
  if (options.platform === "windows-x64") {
6317
- const subdirectory = join18(incoming, ".installer");
6781
+ const subdirectory = join19(incoming, ".installer");
6318
6782
  await mkdir6(subdirectory);
6319
- executable = join18(incoming, `${options.appName}-Setup.exe`);
6783
+ executable = join19(incoming, `${options.appName}-Setup.exe`);
6320
6784
  await extractArchiveMember({
6321
6785
  tar,
6322
6786
  archive: sourceInstaller,
@@ -6330,11 +6794,11 @@ async function prepareInstallerExecution(options) {
6330
6794
  tar,
6331
6795
  archive: sourceInstaller,
6332
6796
  member: find(`.installer/${options.appName}-Setup.metadata.json`),
6333
- destination: join18(subdirectory, `${options.appName}-Setup.metadata.json`),
6797
+ destination: join19(subdirectory, `${options.appName}-Setup.metadata.json`),
6334
6798
  maximum: 1024 * 1024,
6335
6799
  env: clean
6336
6800
  });
6337
- const embeddedPath = join18(subdirectory, `${options.appName}-Setup.tar.zst`);
6801
+ const embeddedPath = join19(subdirectory, `${options.appName}-Setup.tar.zst`);
6338
6802
  await extractArchiveMember({
6339
6803
  tar,
6340
6804
  archive: sourceInstaller,
@@ -6343,11 +6807,11 @@ async function prepareInstallerExecution(options) {
6343
6807
  maximum: verified.archive.size,
6344
6808
  env: clean
6345
6809
  });
6346
- const embedded = await digest3(embeddedPath);
6810
+ const embedded = await digest4(embeddedPath);
6347
6811
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
6348
6812
  throw new Error("Copied installer archive differs");
6349
6813
  } else {
6350
- executable = join18(incoming, "installer");
6814
+ executable = join19(incoming, "installer");
6351
6815
  await extractArchiveMember({
6352
6816
  tar,
6353
6817
  archive: sourceInstaller,
@@ -6403,10 +6867,10 @@ function assertInstallerRendererObservation(value, offline = false) {
6403
6867
  }
6404
6868
 
6405
6869
  // ../../src/installer/installed-payload.ts
6406
- import { createHash as createHash14 } from "crypto";
6407
- import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm6 } from "fs/promises";
6408
- import { once } from "events";
6409
- import { join as join19, resolve as resolve13 } from "path";
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";
6410
6874
  import { createZstdDecompress } from "zlib";
6411
6875
  import { Parser } from "tar";
6412
6876
  function cleanEnv2(parent, forceLocal) {
@@ -6429,7 +6893,7 @@ async function command2(args, env, limit, collect) {
6429
6893
  const errors = (async () => {
6430
6894
  for await (const _part of child.stderr) {}
6431
6895
  })();
6432
- const hash = createHash14("sha256"), chunks = [];
6896
+ const hash = createHash16("sha256"), chunks = [];
6433
6897
  let size = 0;
6434
6898
  try {
6435
6899
  for await (const part of child.stdout) {
@@ -6483,7 +6947,7 @@ async function readMembers(archive, limits, collect) {
6483
6947
  failure ??= new Error("Archive member missing or ambiguous");
6484
6948
  return entry.resume();
6485
6949
  }
6486
- const hash = createHash14("sha256"), chunks = [];
6950
+ const hash = createHash16("sha256"), chunks = [];
6487
6951
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
6488
6952
  members.set(entry.path, member);
6489
6953
  entry.on("data", (chunk) => {
@@ -6498,7 +6962,7 @@ async function readMembers(archive, limits, collect) {
6498
6962
  });
6499
6963
  }
6500
6964
  });
6501
- const ended = once(parser, "end");
6965
+ const ended = once2(parser, "end");
6502
6966
  ended.catch(() => {
6503
6967
  return;
6504
6968
  });
@@ -6509,7 +6973,7 @@ async function readMembers(archive, limits, collect) {
6509
6973
  parser.on("error", (error) => inflate.destroy(error));
6510
6974
  for await (const chunk of input.pipe(inflate)) {
6511
6975
  if (!parser.write(chunk))
6512
- await once(parser, "drain");
6976
+ await once2(parser, "drain");
6513
6977
  }
6514
6978
  parser.end();
6515
6979
  await ended;
@@ -6553,7 +7017,7 @@ async function verifyInstalledPayload(options) {
6553
7017
  entries,
6554
7018
  sidecars: options.sidecars ?? []
6555
7019
  });
6556
- const mac = options.platform === "macos-arm64", prefix = mac ? `${options.appName}.app/Contents` : options.appName.replaceAll(" ", ""), suffix = options.platform === "windows-x64" ? ".exe" : "";
7020
+ const mac = isMacInstallerPlatform(options.platform), prefix = mac ? `${options.appName}.app/Contents` : options.appName.replaceAll(" ", ""), suffix = options.platform === "windows-x64" ? ".exe" : "";
6557
7021
  const bin = mac ? "MacOS" : "bin";
6558
7022
  const files = [
6559
7023
  `${bin}/launcher${suffix}`,
@@ -6577,7 +7041,7 @@ async function verifyInstalledPayload(options) {
6577
7041
  const member = members.get(path);
6578
7042
  if (!member || member.count !== 1)
6579
7043
  throw new Error("Archive member missing or ambiguous");
6580
- const current = await installed(join19(root, name), root, limit);
7044
+ const current = await installed(join20(root, name), root, limit);
6581
7045
  if (member.size !== current.size || member.digest !== current.digest)
6582
7046
  throw new Error(`Installed file differs from archive: ${name}`);
6583
7047
  if (name === "Resources/version.json") {
@@ -6609,10 +7073,10 @@ async function extractCandidateRuntime(options) {
6609
7073
  appName: options.appName,
6610
7074
  entries
6611
7075
  });
6612
- const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
7076
+ const prefix = isMacInstallerPlatform(options.platform) ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
6613
7077
  const expected = `${prefix}/bun${suffix}`;
6614
7078
  const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
6615
- const destination = join19(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
7079
+ const destination = join20(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
6616
7080
  const spawn = () => Bun.spawn({
6617
7081
  cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
6618
7082
  env: tarEnv,
@@ -6625,7 +7089,7 @@ async function extractCandidateRuntime(options) {
6625
7089
  const child = spawn(), errors = (async () => {
6626
7090
  for await (const _part of child.stderr) {}
6627
7091
  })();
6628
- const hash = createHash14("sha256");
7092
+ const hash = createHash16("sha256");
6629
7093
  let size = 0;
6630
7094
  try {
6631
7095
  for await (const part of child.stdout) {
@@ -6662,14 +7126,14 @@ async function extractCandidateRuntime(options) {
6662
7126
  } finally {
6663
7127
  await output.close();
6664
7128
  if (!successful)
6665
- await rm6(destination, { force: true });
7129
+ await rm7(destination, { force: true });
6666
7130
  }
6667
7131
  }
6668
7132
 
6669
7133
  // ../../src/installer/installer-process-cleanup.ts
6670
- import { execFile as execFile2 } from "child_process";
7134
+ import { execFile as execFile3 } from "child_process";
6671
7135
  import { realpath as realpath6 } from "fs/promises";
6672
- import { promisify as promisify2 } from "util";
7136
+ import { promisify as promisify3 } from "util";
6673
7137
 
6674
7138
  // ../../src/native/windows-process.ts
6675
7139
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
@@ -6713,7 +7177,7 @@ function windowsProcessImage(pid, options) {
6713
7177
  }
6714
7178
 
6715
7179
  // ../../src/installer/installer-process-cleanup.ts
6716
- var execute = promisify2(execFile2);
7180
+ var execute = promisify3(execFile3);
6717
7181
  async function terminateGuardedWorker(options) {
6718
7182
  const { pid, runtime, platform } = options;
6719
7183
  assertInstallerContext(options.env, platform, process.platform, process.arch);
@@ -6745,7 +7209,7 @@ async function terminateGuardedWorker(options) {
6745
7209
  }
6746
7210
  const deadline = performance.now() + 5000;
6747
7211
  while (performance.now() < deadline) {
6748
- if (platform === "macos-arm64" ? await macosWorkerExited(() => readMacosState(pid, env)) : await runningExecutable(pid, platform, env) === undefined)
7212
+ if (isMacInstallerPlatform(platform) ? await macosWorkerExited(() => readMacosState(pid, env)) : await runningExecutable(pid, platform, env) === undefined)
6749
7213
  return;
6750
7214
  await Bun.sleep(100);
6751
7215
  }
@@ -6790,7 +7254,7 @@ async function runningExecutable(pid, platform, env) {
6790
7254
  return;
6791
7255
  throw error;
6792
7256
  });
6793
- if (platform === "macos-arm64") {
7257
+ if (isMacInstallerPlatform(platform)) {
6794
7258
  const listed = await execute("/bin/ps", ["-p", String(pid), "-o", "stat=", "-o", "comm="], {
6795
7259
  env,
6796
7260
  timeout: 5000,
@@ -6818,8 +7282,8 @@ async function windowsRunningExecutable(pid) {
6818
7282
  }
6819
7283
 
6820
7284
  // ../../src/updates/install/update-swap-stage.ts
6821
- import { lstat as lstat18, mkdtemp as mkdtemp8, readFile as readFile9, realpath as realpath8, rm as rm8 } from "fs/promises";
6822
- import { join as join29 } from "path";
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";
6823
7287
 
6824
7288
  // ../../src/updates/install/update-handoff-plan.ts
6825
7289
  import { basename as basename6 } from "path";
@@ -6838,13 +7302,14 @@ function planUpdateHandoff(options) {
6838
7302
  assertPortableAppName(appName);
6839
7303
  const expected = {
6840
7304
  "macos-arm64": ["darwin", "arm64"],
7305
+ "macos-x64": ["darwin", "x64"],
6841
7306
  "windows-x64": ["win32", "x64"],
6842
7307
  "linux-x64": ["linux", "x64"],
6843
7308
  "linux-arm64": ["linux", "arm64"]
6844
7309
  };
6845
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))
6846
7311
  throw new Error("Invalid approved update");
6847
- const name = platform === "macos-arm64" ? `${appName}.app` : "app";
7312
+ const name = isMacInstallerPlatform(platform) ? `${appName}.app` : "app";
6848
7313
  if (!isCanonicalPath(target) || basename6(target) !== name)
6849
7314
  throw new Error("Invalid update target");
6850
7315
  return Object.freeze({
@@ -6858,10 +7323,10 @@ function planUpdateHandoff(options) {
6858
7323
  }
6859
7324
 
6860
7325
  // ../../src/updates/install/update-extraction.ts
6861
- import { createHash as createHash15 } from "crypto";
7326
+ import { createHash as createHash17 } from "crypto";
6862
7327
  import { constants as constants4 } from "fs";
6863
- import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open6, readFile as readFile7, realpath as realpath7, rm as rm7, symlink } from "fs/promises";
6864
- import { isAbsolute as isAbsolute6, join as join20 } from "path";
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";
6865
7330
  import { Transform } from "stream";
6866
7331
  import { pipeline } from "stream/promises";
6867
7332
  import { createZstdDecompress as createZstdDecompress2 } from "zlib";
@@ -6882,19 +7347,26 @@ function isLinuxCefLibraryLink(path, target) {
6882
7347
  }
6883
7348
 
6884
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
+ };
6885
7357
  async function extractVerifiedUpdate(options) {
6886
- const { descriptor, archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } = options;
6887
- const expected = {
6888
- "macos-arm64": ["darwin", "arm64"],
6889
- "windows-x64": ["win32", "x64"],
6890
- "linux-x64": ["linux", "x64"],
6891
- "linux-arm64": ["linux", "arm64"]
6892
- };
6893
- if (!isVerifiedRelease(descriptor) || !expected[platform] || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || !isAbsolute6(archive) || !isAbsolute6(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || descriptor.asset.size > maxCompressedBytes || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
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)
6894
7366
  throw new Error("Invalid update extraction context");
6895
7367
  assertPortableAppName(appName);
6896
7368
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
6897
- const archiveRoot = platform === "macos-arm64" ? `${appName}.app` : appName.replaceAll(" ", "");
7369
+ const archiveRoot = isMacInstallerPlatform(platform) ? `${appName}.app` : appName.replaceAll(" ", "");
6898
7370
  const info = await lstat13(archive);
6899
7371
  if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
6900
7372
  throw new Error("Invalid update archive");
@@ -6902,13 +7374,13 @@ async function extractVerifiedUpdate(options) {
6902
7374
  let directory;
6903
7375
  try {
6904
7376
  const before = await file.stat();
6905
- if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || !await verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor))
7377
+ if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || verifyBeforeExtraction && !await verifyBeforeExtraction(file))
6906
7378
  throw new Error("Update archive verification failed");
6907
7379
  const parent = await realpath7(options.directory);
6908
7380
  if (!(await lstat13(parent)).isDirectory())
6909
7381
  throw new Error("Invalid update staging directory");
6910
- directory = await mkdtemp7(join20(parent, "framework-update-extract-"));
6911
- const payloadRoot = join20(directory, "payload"), decompressed = join20(directory, "payload.tar");
7382
+ directory = await mkdtemp8(join21(parent, "framework-update-extract-"));
7383
+ const payloadRoot = join21(directory, "payload"), decompressed = join21(directory, "payload.tar");
6912
7384
  await mkdir7(payloadRoot, { mode: 448 });
6913
7385
  const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
6914
7386
  let invalid = false;
@@ -6926,7 +7398,7 @@ async function extractVerifiedUpdate(options) {
6926
7398
  done(null, chunk);
6927
7399
  }
6928
7400
  });
6929
- const hash = createHash15("sha256");
7401
+ const hash = createHash17("sha256");
6930
7402
  let compressedBytes = 0;
6931
7403
  const verifyInput = new Transform({
6932
7404
  transform(chunk, _encoding, done) {
@@ -7026,27 +7498,27 @@ async function extractVerifiedUpdate(options) {
7026
7498
  if (invalid)
7027
7499
  throw new Error("Unsafe or unsupported update archive entry");
7028
7500
  if (links.length) {
7029
- const bin = join20(payloadRoot, archiveRoot, "bin"), cef = join20(bin, "cef");
7030
- for (const path of [join20(payloadRoot, archiveRoot), bin, cef]) {
7501
+ const bin = join21(payloadRoot, archiveRoot, "bin"), cef = join21(bin, "cef");
7502
+ for (const path of [join21(payloadRoot, archiveRoot), bin, cef]) {
7031
7503
  const value = await lstat13(path);
7032
7504
  if (!value.isDirectory() || value.isSymbolicLink())
7033
7505
  throw new Error("Invalid CEF link directory");
7034
7506
  }
7035
7507
  for (const link of links) {
7036
- const destination = join20(payloadRoot, link.path), target = join20(bin, link.target), value = await lstat13(target);
7508
+ const destination = join21(payloadRoot, link.path), target = join21(bin, link.target), value = await lstat13(target);
7037
7509
  if (!value.isFile() || value.isSymbolicLink())
7038
7510
  throw new Error("Invalid CEF link target");
7039
7511
  await symlink(link.target, destination);
7040
7512
  }
7041
7513
  }
7042
- await rm7(decompressed);
7514
+ await rm8(decompressed);
7043
7515
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
7044
- const prefix = platform === "macos-arm64" ? join20(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
7045
- const resources = join20(payloadRoot, prefix, "Resources");
7046
- const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
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" : "";
7047
7519
  const executables = [
7048
- join20(bin, `launcher${suffix}`),
7049
- join20(bin, `bun${suffix}`),
7520
+ join21(bin, `launcher${suffix}`),
7521
+ join21(bin, `bun${suffix}`),
7050
7522
  ...sidecars.map((name) => sidecarBundlePath(name, platform))
7051
7523
  ];
7052
7524
  const critical = [
@@ -7056,25 +7528,25 @@ async function extractVerifiedUpdate(options) {
7056
7528
  "Resources/app/client/index.html"
7057
7529
  ];
7058
7530
  for (const path of critical) {
7059
- const item = await lstat13(join20(payloadRoot, prefix, path));
7531
+ const item = await lstat13(join21(payloadRoot, prefix, path));
7060
7532
  if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
7061
7533
  throw new Error("Invalid critical update file");
7062
7534
  }
7063
7535
  for (const name of ["version.json", "build.json"]) {
7064
- const metadata = await lstat13(join20(resources, name));
7536
+ const metadata = await lstat13(join21(resources, name));
7065
7537
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
7066
7538
  throw new Error("Invalid update metadata");
7067
7539
  }
7068
- if (JSON.parse(await readFile7(join20(resources, "version.json"), "utf8")).version !== descriptor.version)
7540
+ if (JSON.parse(await readFile8(join21(resources, "version.json"), "utf8")).version !== descriptor.version)
7069
7541
  throw new Error("Update version mismatch");
7070
- assertBuildMetadata(JSON.parse(await readFile7(join20(resources, "build.json"), "utf8")), renderer);
7542
+ assertBuildMetadata(JSON.parse(await readFile8(join21(resources, "build.json"), "utf8")), renderer);
7071
7543
  return {
7072
7544
  directory,
7073
- payload: join20(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
7545
+ payload: join21(payloadRoot, isMacInstallerPlatform(platform) ? `${appName}.app` : prefix)
7074
7546
  };
7075
7547
  } catch (error) {
7076
7548
  if (directory)
7077
- await rm7(directory, { recursive: true, force: true });
7549
+ await rm8(directory, { recursive: true, force: true });
7078
7550
  throw error;
7079
7551
  } finally {
7080
7552
  await file.close();
@@ -7082,19 +7554,19 @@ async function extractVerifiedUpdate(options) {
7082
7554
  }
7083
7555
 
7084
7556
  // ../../src/updates/install/update-swap.ts
7085
- import { createHash as createHash16 } from "crypto";
7557
+ import { createHash as createHash18 } from "crypto";
7086
7558
  import { constants as constants7 } from "fs";
7087
- import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile8, readlink as readlink2 } from "fs/promises";
7088
- import { basename as basename8, dirname as dirname6, join as join23 } from "path";
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";
7089
7561
 
7090
7562
  // ../../src/updates/update-state-store.ts
7091
7563
  import { randomUUID as randomUUID2 } from "crypto";
7092
7564
  import { constants as constants6 } from "fs";
7093
- import { open as open8, rename, unlink, writeFile as writeFile5 } from "fs/promises";
7094
- import { join as join22 } from "path";
7565
+ import { open as open8, rename, unlink, writeFile as writeFile6 } from "fs/promises";
7566
+ import { join as join23 } from "path";
7095
7567
 
7096
7568
  // ../../src/updates/locks/update-lock.ts
7097
- import { basename as basename7, dirname as dirname5, join as join21 } from "path";
7569
+ import { basename as basename7, dirname as dirname5, join as join22 } from "path";
7098
7570
 
7099
7571
  // ../../src/updates/locks/native-file-lock.ts
7100
7572
  import { constants as constants5 } from "fs";
@@ -7262,7 +7734,7 @@ async function tryAcquireWindows(path, mode) {
7262
7734
  function updateLockPath(target) {
7263
7735
  if (!isCanonicalPath(target))
7264
7736
  throw new Error("Invalid update lock target");
7265
- return join21(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7737
+ return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7266
7738
  }
7267
7739
  async function tryAcquireUpdateLock(target) {
7268
7740
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -7327,7 +7799,7 @@ function parseState(value) {
7327
7799
  return Object.freeze(record);
7328
7800
  }
7329
7801
  async function readUpdateStageState(staging) {
7330
- const text = await readSmallStateFile(join22(staging, "state.json"), 4096, "Invalid update staging state");
7802
+ const text = await readSmallStateFile(join23(staging, "state.json"), 4096, "Invalid update staging state");
7331
7803
  return text === undefined ? undefined : parseState(JSON.parse(text));
7332
7804
  }
7333
7805
  async function writeUpdateStageState(staging, state) {
@@ -7336,8 +7808,8 @@ async function writeUpdateStageState(staging, state) {
7336
7808
  async function replaceUpdateStageState(staging, state, durable) {
7337
7809
  if (typeof state.generation !== "string" || !isUuid(state.generation))
7338
7810
  throw new Error("Invalid update staging state");
7339
- const path = join22(staging, "state.json");
7340
- const temporary = join22(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
7811
+ const path = join23(staging, "state.json");
7812
+ const temporary = join23(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
7341
7813
  const contents = JSON.stringify(state) + `
7342
7814
  `;
7343
7815
  let renamed = false;
@@ -7351,7 +7823,7 @@ async function replaceUpdateStageState(staging, state, durable) {
7351
7823
  await file.close();
7352
7824
  }
7353
7825
  } else
7354
- await writeFile5(temporary, contents, { flag: "wx", mode: 384 });
7826
+ await writeFile6(temporary, contents, { flag: "wx", mode: 384 });
7355
7827
  await rename(temporary, path);
7356
7828
  renamed = true;
7357
7829
  if (durable)
@@ -7375,12 +7847,12 @@ async function withUpdateLock(target, operation) {
7375
7847
  function updateStagingFor(target) {
7376
7848
  if (!isCanonicalPath(target))
7377
7849
  throw new Error("Invalid update target");
7378
- return join23(dirname6(target), `.${basename8(target)}.framework-update`);
7850
+ return join24(dirname6(target), `.${basename8(target)}.framework-update`);
7379
7851
  }
7380
7852
  async function readUpdateTreeVersion(tree) {
7381
- const versionPath = join23(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7853
+ const versionPath = join24(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7382
7854
  try {
7383
- const value = JSON.parse(await readFile8(versionPath, "utf8"));
7855
+ const value = JSON.parse(await readFile9(versionPath, "utf8"));
7384
7856
  if (typeof value !== "object" || value === null || typeof value.version !== "string")
7385
7857
  return;
7386
7858
  return value.version;
@@ -7438,7 +7910,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
7438
7910
  }
7439
7911
  async function readUpdateTreeDigest(tree, options = {}) {
7440
7912
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
7441
- const hash = createHash16("sha256");
7913
+ const hash = createHash18("sha256");
7442
7914
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
7443
7915
  const root = await lstat14(tree, { bigint: true });
7444
7916
  if (!root.isDirectory() || root.isSymbolicLink())
@@ -7472,7 +7944,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
7472
7944
  if (before.isDirectory()) {
7473
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);
7474
7946
  const children = await Promise.all(names.map(async (name) => {
7475
- const childPath = join23(path, name);
7947
+ const childPath = join24(path, name);
7476
7948
  return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat14(childPath, { bigint: true })));
7477
7949
  }));
7478
7950
  return [{ kind: "directory", path, relative, before }, ...children.flat()];
@@ -7615,8 +8087,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
7615
8087
  const { target, staging } = options;
7616
8088
  if (dirname6(staging) !== dirname6(target) || staging === target)
7617
8089
  throw new Error("Invalid update swap context");
7618
- const candidate = join23(staging, "candidate");
7619
- const legacyOld = join23(staging, "old");
8090
+ const candidate = join24(staging, "candidate");
8091
+ const legacyOld = join24(staging, "old");
7620
8092
  if (await pathExists(legacyOld))
7621
8093
  throw new Error("A legacy update tree requires recovery before another swap");
7622
8094
  await assertDirectory(target);
@@ -7646,10 +8118,10 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
7646
8118
 
7647
8119
  // ../../src/updates/retention/retirement-inventory.ts
7648
8120
  import { lstat as lstat16, readdir as readdir10 } from "fs/promises";
7649
- import { basename as basename12, dirname as dirname10, join as join27 } from "path";
8121
+ import { basename as basename12, dirname as dirname10, join as join28 } from "path";
7650
8122
 
7651
8123
  // ../../src/updates/retention/update-retention-marker.ts
7652
- import { basename as basename9, dirname as dirname7, join as join24 } from "path";
8124
+ import { basename as basename9, dirname as dirname7, join as join25 } from "path";
7653
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}$/;
7654
8126
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
7655
8127
  function assertCanonicalTarget(target) {
@@ -7668,28 +8140,28 @@ function isTreeIdentity(value) {
7668
8140
  function updateRetentionIntentPath(target, generation) {
7669
8141
  assertCanonicalTarget(target);
7670
8142
  assertGeneration(generation);
7671
- return join24(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
8143
+ return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
7672
8144
  }
7673
8145
 
7674
8146
  // ../../src/updates/retention/retention-prune-progress.ts
7675
- import { basename as basename11, dirname as dirname9, join as join26 } from "path";
8147
+ import { basename as basename11, dirname as dirname9, join as join27 } from "path";
7676
8148
 
7677
8149
  // ../../src/updates/retention/retirement-records.ts
7678
- import { lstat as lstat15, readdir as readdir9, writeFile as writeFile6 } from "fs/promises";
7679
- import { basename as basename10, dirname as dirname8, join as join25 } from "path";
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";
7680
8152
  function updateRetirementPaths(target, generation) {
7681
8153
  if (!isCanonicalPath(target) || !isUuid(generation))
7682
8154
  throw new Error("Invalid update retirement identity");
7683
8155
  const prefix = `.${basename10(target)}.framework-retired-${generation}`;
7684
- const container = join25(dirname8(target), prefix);
8156
+ const container = join26(dirname8(target), prefix);
7685
8157
  return Object.freeze({
7686
8158
  container,
7687
- tree: join25(container, "tree"),
7688
- healthReceipt: join25(container, "healthy.json"),
8159
+ tree: join26(container, "tree"),
8160
+ healthReceipt: join26(container, "healthy.json"),
7689
8161
  healthTemporaryPrefix: ".healthy-",
7690
- claim: join25(dirname8(target), `${prefix}.claim.json`),
8162
+ claim: join26(dirname8(target), `${prefix}.claim.json`),
7691
8163
  claimTemporaryPrefix: `${prefix}.claim-`,
7692
- cleanupMarker: join25(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
8164
+ cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7693
8165
  cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
7694
8166
  });
7695
8167
  }
@@ -7792,11 +8264,11 @@ async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
7792
8264
  }
7793
8265
 
7794
8266
  // ../../src/updates/retention/update-retirement.ts
7795
- import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
7796
- import { basename as basename13, dirname as dirname11, join as join28 } from "path";
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";
7797
8269
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7798
8270
  const { target, staging, currentVersion } = options;
7799
- const markerPath = join28(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
8271
+ const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7800
8272
  const markerInfo = await pathInfo(markerPath);
7801
8273
  if (!markerInfo)
7802
8274
  return "none";
@@ -7837,17 +8309,18 @@ async function assertInstalledVersion(options) {
7837
8309
  const info = await lstat18(options.target);
7838
8310
  if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(options.target) !== options.target)
7839
8311
  throw new Error("Invalid update install target");
7840
- const versionFile = join29(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
8312
+ const versionFile = join30(options.target, ...isMacInstallerPlatform(options.platform) ? ["Contents", "Resources"] : ["Resources"], "version.json");
7841
8313
  const versionInfo = await lstat18(versionFile);
7842
8314
  if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
7843
8315
  throw new Error("Installed update version mismatch");
7844
- if (JSON.parse(await readFile9(versionFile, "utf8")).version !== options.version)
8316
+ if (JSON.parse(await readFile10(versionFile, "utf8")).version !== options.version)
7845
8317
  throw new Error("Installed update version mismatch");
7846
8318
  }
7847
8319
  async function stageUpdateSwap(options) {
7848
8320
  const plan = planUpdateHandoff(options);
7849
8321
  const expectedHost = {
7850
8322
  "macos-arm64": "darwin/arm64",
8323
+ "macos-x64": "darwin/x64",
7851
8324
  "windows-x64": "win32/x64",
7852
8325
  "linux-x64": "linux/x64",
7853
8326
  "linux-arm64": "linux/arm64"
@@ -7860,8 +8333,8 @@ async function stageUpdateSwap(options) {
7860
8333
  version: plan.currentVersion
7861
8334
  });
7862
8335
  const staging = updateStagingFor(plan.target);
7863
- const preparing = await mkdtemp8(`${staging}.preparing-`);
7864
- const candidate = join29(staging, "candidate");
8336
+ const preparing = await mkdtemp9(`${staging}.preparing-`);
8337
+ const candidate = join30(staging, "candidate");
7865
8338
  let published = false;
7866
8339
  try {
7867
8340
  const extracted = await extractVerifiedUpdate({
@@ -7875,12 +8348,12 @@ async function stageUpdateSwap(options) {
7875
8348
  maxExpandedBytes: options.maxExpandedBytes,
7876
8349
  ...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
7877
8350
  });
7878
- renameExclusive(extracted.payload, join29(preparing, "candidate"));
7879
- await rm8(extracted.directory, { recursive: true, force: true });
7880
- const candidateTreeIdentity = await readUpdateTreeIdentity(join29(preparing, "candidate"));
8351
+ renameExclusive(extracted.payload, join30(preparing, "candidate"));
8352
+ await rm9(extracted.directory, { recursive: true, force: true });
8353
+ const candidateTreeIdentity = await readUpdateTreeIdentity(join30(preparing, "candidate"));
7881
8354
  if (!candidateTreeIdentity)
7882
8355
  throw new Error("Update candidate tree identity could not be read");
7883
- const candidateTreeDigest = await readUpdateTreeDigest(join29(preparing, "candidate"));
8356
+ const candidateTreeDigest = await readUpdateTreeDigest(join30(preparing, "candidate"));
7884
8357
  await writeUpdateStageState(preparing, newUpdateStageState({
7885
8358
  version: plan.version,
7886
8359
  previousVersion: options.currentVersion,
@@ -7938,7 +8411,7 @@ async function stageUpdateSwap(options) {
7938
8411
  return result;
7939
8412
  } finally {
7940
8413
  if (!published)
7941
- await rm8(preparing, { recursive: true, force: true });
8414
+ await rm9(preparing, { recursive: true, force: true });
7942
8415
  }
7943
8416
  }
7944
8417
 
@@ -7965,11 +8438,11 @@ function isolatedEnv(parent, profile, platform) {
7965
8438
  RUNNER_ENVIRONMENT: "github-hosted",
7966
8439
  HOME: profile,
7967
8440
  USERPROFILE: profile,
7968
- LOCALAPPDATA: join30(profile, "LocalAppData"),
7969
- XDG_DATA_HOME: join30(profile, ".local", "share"),
7970
- TMP: join30(profile, "tmp"),
7971
- TEMP: join30(profile, "tmp"),
7972
- TMPDIR: join30(profile, "tmp"),
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"),
7973
8446
  ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
7974
8447
  });
7975
8448
  if (platform === "windows-x64")
@@ -8006,7 +8479,7 @@ async function boundedStderr(stream, limit = 64 * 1024) {
8006
8479
  return text.slice(-limit);
8007
8480
  }
8008
8481
  function shouldLaunchInstalledApp(state) {
8009
- return state.platform === "macos-arm64" && state.ready && !state.launched && !state.acknowledged && state.installerExit === 0;
8482
+ return isMacInstallerPlatform(state.platform) && state.ready && !state.launched && !state.acknowledged && state.installerExit === 0;
8010
8483
  }
8011
8484
  var shim = `#!/bin/sh
8012
8485
  umask 077
@@ -8064,15 +8537,15 @@ async function observeInstalledApp(options) {
8064
8537
  await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
8065
8538
  stage("runtime-preflight-passed");
8066
8539
  for (const path of [
8067
- join30(prepared.profile, "LocalAppData"),
8068
- join30(prepared.profile, ".local", "share"),
8069
- join30(prepared.profile, "tmp")
8540
+ join31(prepared.profile, "LocalAppData"),
8541
+ join31(prepared.profile, ".local", "share"),
8542
+ join31(prepared.profile, "tmp")
8070
8543
  ])
8071
8544
  await mkdir9(path, { recursive: true, mode: 448 });
8072
- const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
8073
- const installedRoot = mac ? join30(prepared.incoming, `${options.appName}.app`, "Contents") : join30(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
8074
- const resources = join30(installedRoot, "Resources"), binary = join30(installedRoot, mac ? "MacOS" : "bin"), launcher = join30(binary, windows ? "launcher.exe" : "launcher"), runtime = join30(binary, windows ? "bun.exe" : "bun");
8075
- const worker = join30(resources, "app", "bun", "index.js");
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");
8076
8549
  const sidecars = options.sidecars ?? [];
8077
8550
  let foreignHits = 0;
8078
8551
  const sentinel = policy ? Bun.serve({
@@ -8123,7 +8596,7 @@ async function observeInstalledApp(options) {
8123
8596
  throw new Error("Foreign network sentinel unavailable");
8124
8597
  foreignHits = 0;
8125
8598
  const nonce = randomBytes3(24).toString("hex");
8126
- const ack = join30(run.directory, "ack"), permit = join30(run.directory, "permit"), observation = join30(run.directory, "observation"), unexpected = join30(run.directory, "unexpected"), pidRecord = join30(run.directory, "worker-pid");
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");
8127
8600
  const env = {
8128
8601
  ...baseEnv,
8129
8602
  FRAMEWORK_CI_NONCE: nonce,
@@ -8136,13 +8609,13 @@ async function observeInstalledApp(options) {
8136
8609
  };
8137
8610
  let launchRecord, expectedApp;
8138
8611
  if (mac && viaInstaller) {
8139
- const shimDir = join30(run.directory, "launch-shim");
8612
+ const shimDir = join31(run.directory, "launch-shim");
8140
8613
  await mkdir9(shimDir, { mode: 448 });
8141
- const path = join30(shimDir, "open");
8142
- await writeFile8(path, shim, { flag: "wx", mode: 448 });
8614
+ const path = join31(shimDir, "open");
8615
+ await writeFile9(path, shim, { flag: "wx", mode: 448 });
8143
8616
  await chmod2(path, 448);
8144
- expectedApp = join30(await realpath9(prepared.incoming), `${options.appName}.app`);
8145
- launchRecord = join30(run.directory, "launch-record");
8617
+ expectedApp = join31(await realpath9(prepared.incoming), `${options.appName}.app`);
8618
+ launchRecord = join31(run.directory, "launch-record");
8146
8619
  Object.assign(env, {
8147
8620
  PATH: shimDir + delimiter + (env.PATH ?? ""),
8148
8621
  FRAMEWORK_CI_EXPECTED_APP: expectedApp,
@@ -8178,7 +8651,7 @@ async function observeInstalledApp(options) {
8178
8651
  const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
8179
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"})`);
8180
8653
  }
8181
- const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join30(resources, "version.json"));
8654
+ const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join31(resources, "version.json"));
8182
8655
  if (installer && shouldLaunchInstalledApp({
8183
8656
  platform: options.platform,
8184
8657
  ready,
@@ -8186,17 +8659,17 @@ async function observeInstalledApp(options) {
8186
8659
  acknowledged: await pathExists(ack),
8187
8660
  installerExit: installer.exitCode
8188
8661
  })) {
8189
- if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile10(launchRecord, "utf8") !== expectedApp + `
8662
+ if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile11(launchRecord, "utf8") !== expectedApp + `
8190
8663
  `)
8191
8664
  throw new Error("Installer launch request mismatch");
8192
8665
  app = spawnApp();
8193
8666
  }
8194
8667
  if (await pathExists(ack) && !granted) {
8195
8668
  stage("worker-acknowledged");
8196
- if (await readFile10(ack, "utf8") !== nonce + `
8669
+ if (await readFile11(ack, "utf8") !== nonce + `
8197
8670
  `)
8198
8671
  throw new Error("Worker guard acknowledgement mismatch");
8199
- const record = await readFile10(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
8672
+ const record = await readFile11(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
8200
8673
  if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
8201
8674
  throw new Error("Worker process identity mismatch");
8202
8675
  guardedPid = Number(match[2]);
@@ -8204,7 +8677,7 @@ async function observeInstalledApp(options) {
8204
8677
  if (viaInstaller)
8205
8678
  await installerUnchanged();
8206
8679
  stage("installed-files-verified");
8207
- await writeFile8(permit, nonce + `
8680
+ await writeFile9(permit, nonce + `
8208
8681
  `, { flag: "wx", mode: 384 });
8209
8682
  granted = true;
8210
8683
  deadline = performance.now() + 90000;
@@ -8354,7 +8827,7 @@ async function observeInstalledApp(options) {
8354
8827
  await swapAfterExit(target, staged.staging);
8355
8828
  stage("update-swapped");
8356
8829
  await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
8357
- const directory = join30(prepared.directory, "update");
8830
+ const directory = join31(prepared.directory, "update");
8358
8831
  await mkdir9(directory, { mode: 448 });
8359
8832
  const updated = await observeRun({
8360
8833
  directory,
@@ -8393,7 +8866,7 @@ async function swapAfterExit(target, staging) {
8393
8866
  // ../../src/installer/installer-qualification-command.ts
8394
8867
  async function qualifyInstallerCommand(options) {
8395
8868
  const { env, config, tag, platform, renderer } = options;
8396
- if (!["macos-arm64", "windows-x64", "linux-x64", "linux-arm64"].includes(platform) || !["native", "cef"].includes(renderer) || typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string" || typeof config.appId !== "string")
8869
+ if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer) || typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string" || typeof config.appId !== "string")
8397
8870
  throw new Error("Invalid installer qualification context");
8398
8871
  if (env.RELEASE_TAG !== tag)
8399
8872
  throw new Error("Installer release tag mismatch");
@@ -8403,7 +8876,7 @@ async function qualifyInstallerCommand(options) {
8403
8876
  const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
8404
8877
  if (!policy || !names || names.length !== 2)
8405
8878
  throw new Error("Installer qualification requires an explicit offline policy and payloads");
8406
- const directory = resolve14(options.directory), destination = join31(directory, `installer-test-${platform}.json`);
8879
+ const directory = resolve14(options.directory), destination = join32(directory, `installer-test-${platform}.json`);
8407
8880
  try {
8408
8881
  await lstat19(destination);
8409
8882
  throw new Error("Installer receipt already exists");
@@ -8419,8 +8892,8 @@ async function qualifyInstallerCommand(options) {
8419
8892
  appName: app.appName,
8420
8893
  appId: app.appId,
8421
8894
  version: plan.version,
8422
- installer: join31(directory, names[0]),
8423
- archive: join31(directory, names[1]),
8895
+ installer: join32(directory, names[0]),
8896
+ archive: join32(directory, names[1]),
8424
8897
  expectedReads: parsed.expectedReads,
8425
8898
  offlinePolicy: policy,
8426
8899
  sidecars: parsed.sidecars
@@ -8445,17 +8918,17 @@ async function qualifyInstallerCommand(options) {
8445
8918
  assets: result.artifacts
8446
8919
  };
8447
8920
  validateInstallerReceipt(identity, receipt, platform, names, result.artifacts, policy);
8448
- await writeFile9(destination, JSON.stringify(receipt, null, 2) + `
8921
+ await writeFile10(destination, JSON.stringify(receipt, null, 2) + `
8449
8922
  `, { flag: "wx", mode: 384 });
8450
8923
  return receipt;
8451
8924
  }
8452
8925
 
8453
8926
  // ../../src/installer/installer-upgrade-command.ts
8454
- import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
8455
- import { join as join33, resolve as resolve16 } from "path";
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";
8456
8929
 
8457
8930
  // ../../src/installer/upgrade-asset-download.ts
8458
- import { createHash as createHash17 } from "crypto";
8931
+ import { createHash as createHash19 } from "crypto";
8459
8932
  import { open as open10, unlink as unlink3 } from "fs/promises";
8460
8933
 
8461
8934
  // ../../src/installer/write-all.ts
@@ -8493,7 +8966,7 @@ async function downloadAsset(options) {
8493
8966
  discardStream(response.body);
8494
8967
  throw error;
8495
8968
  }
8496
- const hash = createHash17("sha256");
8969
+ const hash = createHash19("sha256");
8497
8970
  let completed = false;
8498
8971
  try {
8499
8972
  let size = 0;
@@ -8533,7 +9006,7 @@ async function downloadAsset(options) {
8533
9006
  }
8534
9007
 
8535
9008
  // ../../src/updates/feed/update-discovery.ts
8536
- import { createHash as createHash18 } from "crypto";
9009
+ import { createHash as createHash20 } from "crypto";
8537
9010
  var MAX_POINTER_BYTES = 262144;
8538
9011
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
8539
9012
  async function discoverSignedRelease(options) {
@@ -8569,7 +9042,7 @@ async function discoverSignedRelease(options) {
8569
9042
  throw new Error("No qualified channel descriptor is available");
8570
9043
  const { tag } = selected;
8571
9044
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
8572
- if (bytes.length !== listed.size || createHash18("sha256").update(bytes).digest("hex") !== listed.sha256)
9045
+ if (bytes.length !== listed.size || createHash20("sha256").update(bytes).digest("hex") !== listed.sha256)
8573
9046
  throw new Error("Channel descriptor differs from its release");
8574
9047
  let signed;
8575
9048
  try {
@@ -8587,8 +9060,8 @@ async function discoverSignedRelease(options) {
8587
9060
  }
8588
9061
 
8589
9062
  // ../../src/updates/install/update-download.ts
8590
- import { mkdtemp as mkdtemp9, open as open11, realpath as realpath10, rm as rm9 } from "fs/promises";
8591
- import { basename as basename14, dirname as dirname13, join as join32, resolve as resolve15 } from "path";
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";
8592
9065
  async function downloadVerifiedRelease(options) {
8593
9066
  const { descriptor, maxBytes } = options;
8594
9067
  const timeout = options.timeoutMs ?? 120000;
@@ -8621,12 +9094,12 @@ async function downloadVerifiedRelease(options) {
8621
9094
  throw new Error("Release download size mismatch");
8622
9095
  }
8623
9096
  const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
8624
- const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join32(root, "framework-update-"));
9097
+ const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp10(join33(root, "framework-update-"));
8625
9098
  const temporaryDirectory = resolve15(allocated);
8626
9099
  if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
8627
9100
  throw new Error("Invalid update download directory");
8628
9101
  temporary = temporaryDirectory;
8629
- const path = join32(temporary, "archive");
9102
+ const path = join33(temporary, "archive");
8630
9103
  const file = await open11(path, "wx", 384);
8631
9104
  try {
8632
9105
  async function* writeChunks() {
@@ -8683,7 +9156,7 @@ async function downloadVerifiedRelease(options) {
8683
9156
  return { path, directory: temporary };
8684
9157
  } catch (error) {
8685
9158
  if (temporary)
8686
- await rm9(temporary, { recursive: true, force: true });
9159
+ await rm10(temporary, { recursive: true, force: true });
8687
9160
  throw error;
8688
9161
  } finally {
8689
9162
  clearTimeout(stallTimer);
@@ -8700,6 +9173,7 @@ var MAX_COMPRESSED_BYTES2 = 1024 * 1024 * 1024;
8700
9173
  var MAX_EXPANDED_BYTES2 = 4 * 1024 * 1024 * 1024;
8701
9174
  var targets = {
8702
9175
  "macos-arm64": ["darwin", "arm64"],
9176
+ "macos-x64": ["darwin", "x64"],
8703
9177
  "windows-x64": ["win32", "x64"],
8704
9178
  "linux-x64": ["linux", "x64"],
8705
9179
  "linux-arm64": ["linux", "arm64"]
@@ -8729,7 +9203,7 @@ async function qualifyUpgradeCommand(options) {
8729
9203
  const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
8730
9204
  if (!requirements.offlinePolicy || !names || names.length !== 2)
8731
9205
  throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
8732
- const directory = resolve16(options.directory), destination = join33(directory, `upgrade-test-${platform}.json`);
9206
+ const directory = resolve16(options.directory), destination = join34(directory, `upgrade-test-${platform}.json`);
8733
9207
  try {
8734
9208
  await lstat20(destination);
8735
9209
  throw new Error("Upgrade receipt already exists");
@@ -8752,7 +9226,7 @@ async function qualifyUpgradeCommand(options) {
8752
9226
  const channel = "daily";
8753
9227
  const trust = { ...base, channel };
8754
9228
  const discovery = discoveryName(config, channel, platform);
8755
- const signed = await readJsonFile(join33(directory, discovery), 65536, "staged descriptor");
9229
+ const signed = await readJsonFile(join34(directory, discovery), 65536, "staged descriptor");
8756
9230
  const verified = verifyReleaseDescriptor(signed, trust);
8757
9231
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
8758
9232
  throw new Error("Untrusted staged descriptor");
@@ -8775,7 +9249,7 @@ async function qualifyUpgradeCommand(options) {
8775
9249
  return null;
8776
9250
  if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
8777
9251
  throw new Error("Previous release is not older than this release");
8778
- const work = join33(directory, `upgrade-${platform}`);
9252
+ const work = join34(directory, `upgrade-${platform}`);
8779
9253
  await mkdir10(work, { mode: 448 });
8780
9254
  const downloaded = await downloadVerifiedRelease({
8781
9255
  descriptor: previous,
@@ -8784,12 +9258,12 @@ async function qualifyUpgradeCommand(options) {
8784
9258
  timeoutMs: 600000,
8785
9259
  fetch: fetcher
8786
9260
  });
8787
- const previousArchive = join33(work, previous.asset.name);
9261
+ const previousArchive = join34(work, previous.asset.name);
8788
9262
  await rename2(downloaded.path, previousArchive);
8789
9263
  const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
8790
9264
  if (!installerName)
8791
9265
  throw new Error("Previous release has no installer for this platform");
8792
- const previousInstaller = join33(work, installerName);
9266
+ const previousInstaller = join34(work, installerName);
8793
9267
  await downloadAsset({
8794
9268
  feed,
8795
9269
  tag: previous.tag,
@@ -8813,7 +9287,7 @@ async function qualifyUpgradeCommand(options) {
8813
9287
  update: {
8814
9288
  descriptor,
8815
9289
  trust,
8816
- archive: join33(directory, names[1]),
9290
+ archive: join34(directory, names[1]),
8817
9291
  maxCompressedBytes: MAX_COMPRESSED_BYTES2,
8818
9292
  maxExpandedBytes: MAX_EXPANDED_BYTES2
8819
9293
  }
@@ -8830,7 +9304,7 @@ async function qualifyUpgradeCommand(options) {
8830
9304
  updated: true,
8831
9305
  rendererEvidence: result.updated.evidence
8832
9306
  };
8833
- await writeFile10(destination, JSON.stringify(receipt, null, 2) + `
9307
+ await writeFile11(destination, JSON.stringify(receipt, null, 2) + `
8834
9308
  `, { flag: "wx", mode: 384 });
8835
9309
  return receipt;
8836
9310
  }
@@ -8850,9 +9324,8 @@ function stepRenderer(env) {
8850
9324
  }
8851
9325
 
8852
9326
  // ../../src/release/release-steps.ts
8853
- var PLATFORMS = ["macos-arm64", "windows-x64", "linux-x64"];
8854
9327
  function releasePlatform(value) {
8855
- if (!value || !PLATFORMS.includes(value))
9328
+ if (!isInstallerPlatform(value))
8856
9329
  throw new Error("Expected a release platform");
8857
9330
  return value;
8858
9331
  }
@@ -8861,6 +9334,7 @@ function electrobunArtifacts(appName, platform) {
8861
9334
  const bundle = appName.replaceAll(" ", "");
8862
9335
  return {
8863
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`],
8864
9338
  "windows-x64": [`win-x64-${bundle}-Setup.zip`, `stable-win-x64-${bundle}.tar.zst`],
8865
9339
  "linux-x64": [`linux-x64-${bundle}-Setup.tar.gz`, `stable-linux-x64-${bundle}.tar.zst`],
8866
9340
  "linux-arm64": [`linux-arm64-${bundle}-Setup.tar.gz`, `stable-linux-arm64-${bundle}.tar.zst`]
@@ -8883,18 +9357,20 @@ runId=${result.runId}
8883
9357
  var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
8884
9358
  const fs = yield* ReleaseFs;
8885
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");
8886
9362
  const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
8887
9363
  const parsed = parseReleaseConfig(context.config);
8888
9364
  const requirements = parsed.requirements(context.tag);
8889
9365
  yield* step(() => fs.mkdir(directory, { recursive: true }));
8890
9366
  const packed = yield* scopedTempDirectory("framework-command-pack-");
8891
9367
  const sources = {
8892
- [installerAsset]: join34(artifacts, installer),
8893
- [archiveAsset]: join34(artifacts, archive)
9368
+ [installerAsset]: join35(artifacts, installer),
9369
+ [archiveAsset]: join35(artifacts, archive)
8894
9370
  };
8895
9371
  for (const policy of parsed.commandArtifacts) {
8896
9372
  const name = requirements.commandArtifacts[policy.kind][context.platform];
8897
- sources[name] = join34(packed, name);
9373
+ sources[name] = join35(packed, name);
8898
9374
  yield* step(() => packCommandArtifact({
8899
9375
  source: policy.build,
8900
9376
  archive: sources[name],
@@ -8912,10 +9388,10 @@ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* ()
8912
9388
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
8913
9389
  if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
8914
9390
  return yield* fail("Staged platform directory contains unexpected files");
8915
- const [installer, archive] = platformAssets(context).map((name) => join34(directory, name));
9391
+ const [installer, archive] = platformAssets(context).map((name) => join35(directory, name));
8916
9392
  for (const policy of parsed.commandArtifacts)
8917
9393
  yield* step(() => readCommandArtifact({
8918
- archive: join34(directory, requirements.commandArtifacts[policy.kind][context.platform]),
9394
+ archive: join35(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8919
9395
  executable: policy.executable,
8920
9396
  platform: context.platform
8921
9397
  }));
@@ -8940,31 +9416,31 @@ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend
8940
9416
  const renderer = stepRenderer(context.env);
8941
9417
  return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
8942
9418
  });
8943
- var run2 = (context, effect) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(context.env) })(effect));
8944
- var selectRetainedStep = (context) => run2(context, selectRetainedStepEffect(context));
8945
- var stageBuildStep = (context, directory, artifacts) => run2(context, stageBuildStepEffect(context, directory, artifacts));
8946
- var inspectStagedStep = (context, directory) => run2(context, inspectStagedStepEffect(context, directory));
8947
- var qualifyStep = (context, directory) => run2(context, qualifyStepEffect(context, directory));
8948
- var qualifyUpgradeStep = (context, directory, onStage) => run2(context, qualifyUpgradeStepEffect(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));
8949
9425
  // src/library/linux-package-pair.ts
8950
- import { execFile as execFile3 } from "child_process";
9426
+ import { execFile as execFile4 } from "child_process";
8951
9427
  import {
8952
9428
  chmod as chmod3,
8953
9429
  link,
8954
9430
  mkdir as mkdir11,
8955
- mkdtemp as mkdtemp10,
9431
+ mkdtemp as mkdtemp11,
8956
9432
  open as open12,
8957
- readFile as readFile11,
9433
+ readFile as readFile12,
8958
9434
  realpath as realpath11,
8959
- rm as rm10,
8960
- writeFile as writeFile11
9435
+ rm as rm11,
9436
+ writeFile as writeFile12
8961
9437
  } from "fs/promises";
8962
- import { dirname as dirname14, join as join35, resolve as resolve17 } from "path";
8963
- import { promisify as promisify3 } from "util";
9438
+ import { dirname as dirname14, join as join36, resolve as resolve17 } from "path";
9439
+ import { promisify as promisify4 } from "util";
8964
9440
  var shasum = /^[a-f0-9]{64}$/;
8965
9441
  var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
8966
9442
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
8967
- var exec = promisify3(execFile3);
9443
+ var exec = promisify4(execFile4);
8968
9444
  function requireThat2(condition, message) {
8969
9445
  if (!condition)
8970
9446
  throw new Error(message);
@@ -8993,9 +9469,9 @@ var inspectWithNativeTools = async (tool, args) => {
8993
9469
  throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
8994
9470
  }
8995
9471
  };
8996
- function parseDebianIdentity(text, packageName, version) {
9472
+ function parseDebianIdentity(text, packageName, version, arch) {
8997
9473
  const fields = text.trimEnd().split(/\r?\n/);
8998
- requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`, "Architecture: amd64"].every((value) => fields.includes(value)), "Debian package name, version or architecture does not match the release policy");
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");
8999
9475
  }
9000
9476
  function requireRegularDesktopEntry(listing, id) {
9001
9477
  const lines = listing.trimEnd().split(/\r?\n/);
@@ -9049,11 +9525,11 @@ function digestWindow(runtime) {
9049
9525
  requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
9050
9526
  return matches[0];
9051
9527
  }
9052
- function type2X64(bytes) {
9053
- return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === 62;
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;
9054
9530
  }
9055
- async function verifyEmbeddedRuntime(path, runtime) {
9056
- requireThat2(type2X64(runtime), "Expected a pinned Type 2 x86_64 AppImage runtime");
9531
+ async function verifyEmbeddedRuntime(path, runtime, elfMachine) {
9532
+ requireThat2(type2(runtime, elfMachine), "Expected a pinned native Type 2 AppImage runtime");
9057
9533
  const ignored = digestWindow(runtime);
9058
9534
  const fd = await open12(path, "r");
9059
9535
  try {
@@ -9065,7 +9541,7 @@ async function verifyEmbeddedRuntime(path, runtime) {
9065
9541
  throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
9066
9542
  filled += bytesRead;
9067
9543
  }
9068
- requireThat2(type2X64(prefix), "Expected a Type 2 x86_64 AppImage");
9544
+ requireThat2(type2(prefix, elfMachine), "Expected a native Type 2 AppImage");
9069
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");
9070
9546
  requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
9071
9547
  } finally {
@@ -9074,11 +9550,14 @@ async function verifyEmbeddedRuntime(path, runtime) {
9074
9550
  }
9075
9551
  async function stageLinuxPackagePairWithInspection(options, inspect) {
9076
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];
9077
9556
  const receipt = record2(options.producer);
9078
9557
  const archive = validIdentity(expected.archive);
9079
9558
  const runtime = validIdentity(expected.runtime);
9080
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");
9081
- requireThat2(receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === "linux-x64" && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
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");
9082
9561
  const names = [expected.debName, expected.appImageName];
9083
9562
  const artifacts = receipt.artifacts.map(validIdentity);
9084
9563
  const trustedArtifacts = expected.artifacts.map(validIdentity);
@@ -9089,7 +9568,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
9089
9568
  }), "Package producer receipt must describe exactly the protected DEB and AppImage");
9090
9569
  const destination = resolve17(options.output);
9091
9570
  const parent = await realpath11(dirname14(destination));
9092
- const work = await mkdtemp10(join35(parent, ".linux-package-pair-"));
9571
+ const work = await mkdtemp11(join36(parent, ".linux-package-pair-"));
9093
9572
  try {
9094
9573
  const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
9095
9574
  directory: work,
@@ -9097,11 +9576,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
9097
9576
  sources
9098
9577
  })));
9099
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");
9100
- const deb = join35(work, expected.debName);
9101
- const image = join35(work, expected.appImageName);
9579
+ const deb = join36(work, expected.debName);
9580
+ const image = join36(work, expected.appImageName);
9102
9581
  const version = expected.tag.slice(1);
9103
- parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
9104
- await verifyEmbeddedRuntime(image, await readFile11(join35(work, runtime.name)));
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);
9105
9584
  const offset = String(runtime.size);
9106
9585
  requireRegularDesktopEntry(await inspect("unsquashfs", [
9107
9586
  "-offset",
@@ -9124,30 +9603,30 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
9124
9603
  schema: "linux-package-pair/v1",
9125
9604
  tag: expected.tag,
9126
9605
  sourceSha: expected.sourceSha,
9127
- platform: "linux-x64",
9606
+ platform: target.platform,
9128
9607
  updateArchiveSha256: archive.sha256,
9129
9608
  artifacts: names.map((name) => artifacts.find((file) => file.name === name))
9130
9609
  };
9131
9610
  await mkdir11(destination);
9132
9611
  try {
9133
9612
  for (const name of names)
9134
- await link(join35(work, name), join35(destination, name));
9135
- await writeFile11(join35(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
9613
+ await link(join36(work, name), join36(destination, name));
9614
+ await writeFile12(join36(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
9136
9615
  `, {
9137
9616
  flag: "wx"
9138
9617
  });
9139
9618
  } catch (error) {
9140
- await rm10(destination, { recursive: true, force: true });
9619
+ await rm11(destination, { recursive: true, force: true });
9141
9620
  throw error;
9142
9621
  }
9143
9622
  return staged;
9144
9623
  } finally {
9145
- await rm10(work, { recursive: true, force: true });
9624
+ await rm11(work, { recursive: true, force: true });
9146
9625
  }
9147
9626
  }
9148
9627
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
9149
9628
  // src/library/linux-format-producer.ts
9150
- import { createHash as createHash19 } from "crypto";
9629
+ import { createHash as createHash21 } from "crypto";
9151
9630
  import { createReadStream as createReadStream2, createWriteStream } from "fs";
9152
9631
  import {
9153
9632
  chmod as chmod4,
@@ -9155,89 +9634,90 @@ import {
9155
9634
  lstat as lstat21,
9156
9635
  lutimes,
9157
9636
  mkdir as mkdir12,
9158
- mkdtemp as mkdtemp11,
9637
+ mkdtemp as mkdtemp12,
9159
9638
  open as open13,
9160
9639
  readdir as readdir12,
9161
9640
  readlink as readlink3,
9162
9641
  realpath as realpath12,
9163
- rm as rm11,
9642
+ rm as rm12,
9164
9643
  symlink as symlink2,
9165
9644
  utimes,
9166
- writeFile as writeFile12
9645
+ writeFile as writeFile13
9167
9646
  } from "fs/promises";
9168
- import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join36, relative as relative5, resolve as resolve18 } from "path";
9647
+ import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative5, resolve as resolve18 } from "path";
9169
9648
  import { pipeline as pipeline2 } from "stream/promises";
9170
9649
  var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
9171
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}\))?$/;
9172
9652
  var sha2562 = /^[a-f0-9]{64}$/;
9173
9653
  var sum = async (path) => {
9174
- const hash = createHash19("sha256");
9654
+ const hash = createHash21("sha256");
9175
9655
  for await (const chunk of createReadStream2(path))
9176
9656
  hash.update(chunk);
9177
9657
  return hash.digest("hex");
9178
9658
  };
9179
9659
  var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
9180
9660
  var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
9181
- function check2(ok, message) {
9661
+ function check3(ok, message) {
9182
9662
  if (!ok)
9183
9663
  throw new Error(message);
9184
9664
  }
9185
9665
  async function exactCopy(pin, to) {
9186
- check2(sha2562.test(pin.sha256), "Missing protected input digest");
9666
+ check3(sha2562.test(pin.sha256), "Missing protected input digest");
9187
9667
  const before = await lstat21(pin.path);
9188
- check2(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
9668
+ check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
9189
9669
  const input = await open13(pin.path, "r");
9190
9670
  try {
9191
9671
  const after = await input.stat();
9192
- check2(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9672
+ check3(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9193
9673
  await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
9194
9674
  } finally {
9195
9675
  await input.close();
9196
9676
  }
9197
- check2((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9677
+ check3((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9198
9678
  }
9199
9679
  async function regular2(root, path) {
9200
- const file = join36(root, path);
9201
- check2((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
9680
+ const file = join37(root, path);
9681
+ check3((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
9202
9682
  return file;
9203
9683
  }
9204
- async function elf(path, appImage = false) {
9684
+ async function elf(path, machine, appImage = false) {
9205
9685
  const input = await open13(path, "r");
9206
9686
  try {
9207
9687
  const h = Buffer.alloc(20);
9208
9688
  const { bytesRead } = await input.read(h, 0, h.length, 0);
9209
- check2(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === 62 && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected native Linux x64 executable");
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");
9210
9690
  } finally {
9211
9691
  await input.close();
9212
9692
  }
9213
9693
  }
9214
9694
  async function normalizeTree(root, dir = root) {
9215
9695
  for (const name of await readdir12(dir)) {
9216
- const file = join36(dir, name);
9696
+ const file = join37(dir, name);
9217
9697
  const st = await lstat21(file);
9218
9698
  if (st.isSymbolicLink()) {
9219
- check2(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
9699
+ check3(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
9220
9700
  const target = relative5(root, await realpath12(file));
9221
- check2(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
9701
+ check3(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
9222
9702
  } else if (st.isDirectory()) {
9223
9703
  await chmod4(file, 493);
9224
9704
  await normalizeTree(root, file);
9225
9705
  } else {
9226
- check2(st.isFile(), "Unsupported bundle entry");
9706
+ check3(st.isFile(), "Unsupported bundle entry");
9227
9707
  await chmod4(file, st.mode & 73 ? 493 : 420);
9228
9708
  }
9229
9709
  }
9230
9710
  }
9231
9711
  async function normalizeBuildTimes(directory, epoch) {
9232
9712
  for (const name of (await readdir12(directory)).toSorted()) {
9233
- const path = join36(directory, name);
9713
+ const path = join37(directory, name);
9234
9714
  const info = await lstat21(path);
9235
9715
  if (info.isSymbolicLink()) {
9236
9716
  await lutimes(path, epoch, epoch);
9237
9717
  } else if (info.isDirectory()) {
9238
9718
  await normalizeBuildTimes(path, epoch);
9239
9719
  } else {
9240
- check2(info.isFile(), "Unsupported packaging entry");
9720
+ check3(info.isFile(), "Unsupported packaging entry");
9241
9721
  await utimes(path, epoch, epoch);
9242
9722
  }
9243
9723
  }
@@ -9245,53 +9725,56 @@ async function normalizeBuildTimes(directory, epoch) {
9245
9725
  await utimes(directory, epoch, epoch);
9246
9726
  }
9247
9727
  async function write(root, path, value, mode = 420) {
9248
- const target = join36(root, path);
9728
+ const target = join37(root, path);
9249
9729
  await mkdir12(dirname15(target), { recursive: true });
9250
- await writeFile12(target, value, { flag: "wx", mode });
9730
+ await writeFile13(target, value, { flag: "wx", mode });
9251
9731
  await chmod4(target, mode);
9252
9732
  }
9253
9733
  function validatePolicy(policy) {
9254
9734
  const executable = policy.executable ?? policy.packageName;
9255
9735
  const links = policy.links ?? [];
9256
- check2([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) => /^[a-z0-9][a-z0-9+.-]*(?: \| [a-z0-9][a-z0-9+.-]*)*$/.test(x)), "Invalid app Linux packaging policy");
9257
- check2(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
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");
9258
9738
  }
9259
9739
  async function buildLinuxFormats(input, host) {
9260
9740
  const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
9261
9741
  const checkAbort = () => host.signal?.throwIfAborted();
9262
9742
  checkAbort();
9263
- check2(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
9264
- check2(/^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");
9265
- check2(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
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");
9266
9749
  if (input.identity)
9267
- check2(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");
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");
9268
9751
  const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
9269
9752
  validatePolicy(policy);
9270
9753
  const requested = resolve18(input.output);
9271
9754
  const parent = await realpath12(dirname15(requested));
9272
- const output = join36(parent, basename16(requested));
9273
- const work = await mkdtemp11(join36(parent, ".linux-formats-"));
9755
+ const output = join37(parent, basename16(requested));
9756
+ const work = await mkdtemp12(join37(parent, ".linux-formats-"));
9274
9757
  let outputOwned = false;
9275
9758
  try {
9276
- const archive = join36(work, "payload.tar.zst");
9277
- const tool = join36(work, "appimagetool");
9278
- const runtime = join36(work, "runtime");
9759
+ const archive = join37(work, "payload.tar.zst");
9760
+ const tool = join37(work, "appimagetool");
9761
+ const runtime = join37(work, "runtime");
9279
9762
  for (const [pin, dest] of [
9280
9763
  [input.archive, archive],
9281
9764
  [input.tool, tool],
9282
9765
  [input.runtime, runtime]
9283
9766
  ])
9284
9767
  await exactCopy(pin, dest);
9285
- await elf(tool, true);
9286
- await elf(runtime, true);
9768
+ await elf(tool, target.elfMachine, true);
9769
+ await elf(runtime, target.elfMachine, true);
9287
9770
  await chmod4(tool, 448);
9288
- const extracted = join36(work, "extract");
9771
+ const extracted = join37(work, "extract");
9289
9772
  await mkdir12(extracted);
9290
9773
  if (host.extractVerifiedAppArchive) {
9291
9774
  await host.extractVerifiedAppArchive(archive, extracted);
9292
9775
  } else {
9293
9776
  await host.inspectAppArchive(archive);
9294
- check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
9777
+ check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
9295
9778
  await host.run("tar", [
9296
9779
  "--zstd",
9297
9780
  "--extract",
@@ -9303,28 +9786,28 @@ async function buildLinuxFormats(input, host) {
9303
9786
  "--no-same-permissions"
9304
9787
  ], { env });
9305
9788
  }
9306
- check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
9789
+ check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
9307
9790
  checkAbort();
9308
- const source = join36(extracted, policy.bundleRoot);
9309
- check2((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
9791
+ const source = join37(extracted, policy.bundleRoot);
9792
+ check3((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
9310
9793
  await chmod4(source, 493);
9311
9794
  await normalizeTree(source);
9312
- await elf(await regular2(source, policy.launcher));
9795
+ await elf(await regular2(source, policy.launcher), target.elfMachine);
9313
9796
  for (const link of policy.links ?? []) {
9314
- const target = await regular2(source, link.target);
9315
- check2(((await lstat21(target)).mode & 73) !== 0, "CLI link target is not executable");
9797
+ const linkTarget = await regular2(source, link.target);
9798
+ check3(((await lstat21(linkTarget)).mode & 73) !== 0, "CLI link target is not executable");
9316
9799
  }
9317
9800
  for (const pin of policy.debSetuid) {
9318
9801
  const file = await regular2(source, pin.path);
9319
- await elf(file);
9320
- check2(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9802
+ await elf(file, target.elfMachine);
9803
+ check3(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9321
9804
  }
9322
9805
  const icon = await regular2(source, policy.icon);
9323
- check2(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9324
- const stem = `${policy.artifactStem}-${tag}-linux-x64`;
9806
+ check3(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9807
+ const stem = `${policy.artifactStem}-${tag}-${target.platform}`;
9325
9808
  const debName = `${stem}.deb`;
9326
9809
  const imageName = `${stem}.AppImage`;
9327
- const dest = join36(work, "result");
9810
+ const dest = join37(work, "result");
9328
9811
  await mkdir12(dest);
9329
9812
  const version = tag.slice(1);
9330
9813
  const installed = `usr/lib/${policy.packageName}`;
@@ -9345,23 +9828,23 @@ async function buildLinuxFormats(input, host) {
9345
9828
  `);
9346
9829
  for (const format of ["deb", "appimage"]) {
9347
9830
  checkAbort();
9348
- const tree = join36(work, format);
9349
- await mkdir12(join36(tree, "usr", "lib"), { recursive: true });
9350
- const bundle = join36(tree, installed);
9831
+ const tree = join37(work, format);
9832
+ await mkdir12(join37(tree, "usr", "lib"), { recursive: true });
9833
+ const bundle = join37(tree, installed);
9351
9834
  await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
9352
9835
  await normalizeTree(bundle);
9353
- const appDirectory = join36(bundle, "Resources", "app");
9354
- check2((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
9836
+ const appDirectory = join37(bundle, "Resources", "app");
9837
+ check3((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
9355
9838
  await write(bundle, "Resources/app/.adea-linux-package", `${format}
9356
9839
  `);
9357
9840
  await write(tree, `usr/share/applications/${desktopFile}`, desktop);
9358
- const iconDest = join36(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9841
+ const iconDest = join37(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9359
9842
  await mkdir12(dirname15(iconDest), { recursive: true });
9360
9843
  await cp(icon, iconDest, { force: false, errorOnExist: true });
9361
9844
  await chmod4(iconDest, 420);
9362
- await mkdir12(join36(tree, "usr", "bin"), { recursive: true });
9845
+ await mkdir12(join37(tree, "usr", "bin"), { recursive: true });
9363
9846
  for (const link of policy.links ?? [])
9364
- await symlink2(`../lib/${policy.packageName}/${link.target}`, join36(tree, "usr", "bin", link.name));
9847
+ await symlink2(`../lib/${policy.packageName}/${link.target}`, join37(tree, "usr", "bin", link.name));
9365
9848
  if (format === "deb") {
9366
9849
  for (const pin of policy.debSetuid)
9367
9850
  await chmod4(await regular2(bundle, pin.path), 2541);
@@ -9372,7 +9855,7 @@ exec '/${installed}/${policy.launcher}' "$@"
9372
9855
  await write(tree, "DEBIAN/control", [
9373
9856
  `Package: ${policy.packageName}`,
9374
9857
  `Version: ${version}`,
9375
- "Architecture: amd64",
9858
+ `Architecture: ${target.debian}`,
9376
9859
  `Maintainer: ${policy.maintainer}`,
9377
9860
  `Description: ${policy.description}`,
9378
9861
  `Homepage: ${policy.homepage}`,
@@ -9381,7 +9864,7 @@ exec '/${installed}/${policy.launcher}' "$@"
9381
9864
  ].join(`
9382
9865
  `));
9383
9866
  await normalizeBuildTimes(tree, sourceDateEpoch);
9384
- await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join36(dest, debName)], { env });
9867
+ await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join37(dest, debName)], { env });
9385
9868
  } else {
9386
9869
  await write(tree, `usr/bin/${executable}`, `#!/bin/sh
9387
9870
  set -eu
@@ -9389,7 +9872,7 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
9389
9872
  export ${policy.formatEnvironment}=appimage
9390
9873
  exec "$root/${installed}/${policy.launcher}" "$@"
9391
9874
  `, 493);
9392
- const rootIcon = join36(tree, `${policy.desktopId}.svg`);
9875
+ const rootIcon = join37(tree, `${policy.desktopId}.svg`);
9393
9876
  await cp(icon, rootIcon, { force: false, errorOnExist: true });
9394
9877
  await chmod4(rootIcon, 420);
9395
9878
  await write(tree, desktopFile, desktop);
@@ -9403,9 +9886,9 @@ exec "$root/${installed}/${policy.launcher}" "$@"
9403
9886
  ].join(`
9404
9887
  `), 493);
9405
9888
  await normalizeBuildTimes(tree, sourceDateEpoch);
9406
- await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join36(dest, imageName)], {
9889
+ await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join37(dest, imageName)], {
9407
9890
  executable: tool,
9408
- env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
9891
+ env: { ...env, ARCH: target.appImage, VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
9409
9892
  });
9410
9893
  }
9411
9894
  }
@@ -9413,34 +9896,43 @@ exec "$root/${installed}/${policy.launcher}" "$@"
9413
9896
  for (const name of [debName, imageName]) {
9414
9897
  const path = await regular2(dest, name);
9415
9898
  const size = (await lstat21(path)).size;
9416
- check2(size > 0, "Empty produced artifact");
9899
+ check3(size > 0, "Empty produced artifact");
9417
9900
  artifacts.push({ name, size, sha256: await sum(path) });
9418
9901
  }
9419
9902
  const receipt = {
9420
- 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
+ } : {},
9421
9913
  tag,
9422
9914
  sourceSha,
9423
9915
  sourceDateEpoch,
9424
9916
  ...input.identity,
9425
- platform: "linux-x64",
9917
+ platform: target.platform,
9426
9918
  updateArchiveSha256: input.archive.sha256,
9427
9919
  artifacts
9428
9920
  };
9429
9921
  checkAbort();
9430
- await mkdir12(output);
9922
+ await mkdir12(output, input.privateCandidate ? { mode: 448 } : undefined);
9431
9923
  outputOwned = true;
9432
9924
  try {
9433
9925
  for (const item of artifacts)
9434
- await cp(join36(dest, item.name), join36(output, basename16(item.name)), {
9926
+ await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
9435
9927
  force: false,
9436
9928
  errorOnExist: true
9437
9929
  });
9438
9930
  checkAbort();
9439
- await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
9931
+ await write(output, input.privateCandidate ? "private-linux-format-build.json" : "linux-format-build.json", JSON.stringify(receipt) + `
9440
9932
  `);
9441
9933
  checkAbort();
9442
9934
  } catch (error) {
9443
- await rm11(output, { recursive: true, force: true });
9935
+ await rm12(output, { recursive: true, force: true });
9444
9936
  outputOwned = false;
9445
9937
  throw error;
9446
9938
  }
@@ -9448,20 +9940,334 @@ exec "$root/${installed}/${policy.launcher}" "$@"
9448
9940
  } finally {
9449
9941
  let cleanupComplete = false;
9450
9942
  try {
9451
- await rm11(work, { recursive: true, force: true });
9943
+ await rm12(work, { recursive: true, force: true });
9452
9944
  await host.afterWorkCleanup?.();
9453
9945
  cleanupComplete = true;
9454
9946
  } finally {
9455
9947
  if ((!cleanupComplete || host.signal?.aborted) && outputOwned) {
9456
- await rm11(output, { recursive: true, force: true });
9948
+ await rm12(output, { recursive: true, force: true });
9457
9949
  host.signal?.throwIfAborted();
9458
9950
  }
9459
9951
  }
9460
9952
  }
9461
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 });
10262
+ }
10263
+ }
9462
10264
  export {
10265
+ assertStandaloneWindowsPayload,
9463
10266
  buildLinuxFormats,
10267
+ buildStandaloneWindowsExe,
9464
10268
  compareLinuxReproducibility,
10269
+ createAptR2Store,
10270
+ createAptSignatureVerifier,
9465
10271
  createDailyBatchR2Client,
9466
10272
  createDailyBatchR2Store,
9467
10273
  createDailyBatchS3Transport,
@@ -9470,6 +10276,7 @@ export {
9470
10276
  createGitHubReleasePublisher,
9471
10277
  createMacosDmg,
9472
10278
  desktopDailyProfile,
10279
+ expandedDesktopDailyProfile,
9473
10280
  fileIdentity2 as fileIdentity,
9474
10281
  finalizeReleasePleaseDraft,
9475
10282
  inspectDailyBatch,
@@ -9478,6 +10285,7 @@ export {
9478
10285
  planQualificationRun2 as planQualificationRun,
9479
10286
  planReleaseAssets2 as planReleaseAssets,
9480
10287
  promoteDailyBatch,
10288
+ publishAptRepository,
9481
10289
  publishFrameworkPackage,
9482
10290
  publishQualifiedRelease,
9483
10291
  qualifyGitHubRelease,