@adea-ai/app-framework-release-tools 0.4.0 → 0.6.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/cli.js CHANGED
@@ -18,6 +18,11 @@ var __export = (target, all) => {
18
18
  // src/index.ts
19
19
  var exports_src = {};
20
20
  __export(exports_src, {
21
+ buildLinuxFormats: () => buildLinuxFormats,
22
+ compareLinuxReproducibility: () => compareLinuxReproducibility,
23
+ createDailyBatchR2Client: () => createDailyBatchR2Client,
24
+ createDailyBatchR2Store: () => createDailyBatchR2Store,
25
+ createDailyBatchS3Transport: () => createDailyBatchS3Transport,
21
26
  createDailyNativeReceipt: () => createDailyNativeReceipt,
22
27
  createGitHubPromotionProvider: () => createGitHubPromotionProvider,
23
28
  createGitHubReleasePublisher: () => createGitHubReleasePublisher,
@@ -25,15 +30,19 @@ __export(exports_src, {
25
30
  desktopDailyProfile: () => desktopDailyProfile,
26
31
  fileIdentity: () => fileIdentity2,
27
32
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
33
+ inspectDailyBatch: () => inspectDailyBatch,
28
34
  inspectStagedStep: () => inspectStagedStep,
29
35
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
30
36
  planQualificationRun: () => planQualificationRun2,
31
37
  planReleaseAssets: () => planReleaseAssets2,
38
+ promoteDailyBatch: () => promoteDailyBatch,
32
39
  publishFrameworkPackage: () => publishFrameworkPackage,
33
40
  publishQualifiedRelease: () => publishQualifiedRelease,
34
41
  qualifyGitHubRelease: () => qualifyGitHubRelease,
35
42
  qualifyStep: () => qualifyStep,
36
43
  qualifyUpgradeStep: () => qualifyUpgradeStep,
44
+ readDailyBatch: () => readDailyBatch,
45
+ rollbackDailyBatch: () => rollbackDailyBatch,
37
46
  runPromotionCommand: () => runPromotionCommand,
38
47
  runReleaseCutCommand: () => runReleaseCutCommand,
39
48
  runReleasePublishCommand: () => runReleasePublishCommand,
@@ -44,16 +53,18 @@ __export(exports_src, {
44
53
  stageLinuxPackagePair: () => stageLinuxPackagePair,
45
54
  stagePlatformArtifacts: () => stagePlatformArtifacts,
46
55
  stageReleaseDescriptors: () => stageReleaseDescriptors,
56
+ verifyDailyBatchDescriptor: () => verifyDailyBatchDescriptor,
57
+ verifyDailyBatchObject: () => verifyDailyBatchObject,
47
58
  verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
48
59
  verifyImage: () => verifyImage,
49
60
  writeDescriptors: () => writeDescriptors
50
61
  });
51
62
 
52
63
  // src/cli.ts
53
- import { Effect as Effect30 } from "effect";
64
+ import { Effect as Effect32, Exit as Exit6 } from "effect";
54
65
 
55
66
  // src/cli-commands.ts
56
- import { Effect as Effect29 } from "effect";
67
+ import { Effect as Effect31 } from "effect";
57
68
 
58
69
  // ../../src/installer/hosted-runner.ts
59
70
  import { isAbsolute } from "path";
@@ -428,7 +439,7 @@ function parseArchPackage(value) {
428
439
  assert(Array.isArray(links) && links.length <= 8 && links.every((link, index) => isRecord(link) && Object.keys(link).length === 2 && text(link.name, 64) && executableName.test(link.name) && link.name !== policy.executable && links.findIndex((item) => isRecord(item) && item.name === link.name) === index && bundlePath(link.target)), "Invalid Arch package links");
429
440
  assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
430
441
  const repository = policy.repository;
431
- assert(repository === undefined || isRecord(repository) && Object.keys(repository).length === 3 && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey), "Invalid Arch package repository");
442
+ assert(repository === undefined || isRecord(repository) && Object.keys(repository).every((key) => ["name", "base", "publicKey", "keyFingerprint"].includes(key)) && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey) && (repository.keyFingerprint === undefined || typeof repository.keyFingerprint === "string" && /^[0-9A-F]{40}$/.test(repository.keyFingerprint)), "Invalid Arch package repository");
432
443
  return {
433
444
  pkgname: policy.pkgname,
434
445
  pkgdesc: policy.pkgdesc,
@@ -492,7 +503,8 @@ function parseArchPackage(value) {
492
503
  repository: {
493
504
  name: repository.name,
494
505
  base: repository.base,
495
- publicKey: repository.publicKey
506
+ publicKey: repository.publicKey,
507
+ ...typeof repository.keyFingerprint === "string" ? { keyFingerprint: repository.keyFingerprint } : {}
496
508
  }
497
509
  }
498
510
  };
@@ -1069,15 +1081,122 @@ async function runReleaseEffect(effect) {
1069
1081
  }
1070
1082
 
1071
1083
  // src/release-ports.ts
1072
- import { execFile, spawnSync } from "child_process";
1084
+ import { execFile, spawn, spawnSync } from "child_process";
1073
1085
  import { createPrivateKey } from "crypto";
1074
1086
  import * as fsp from "fs/promises";
1075
1087
  import { Context, Effect as Effect2 } from "effect";
1088
+ import { promisify } from "util";
1076
1089
  import { Effect as Effect3, Fiber, Option } from "effect";
1077
1090
 
1078
1091
  class ReleaseGit extends Context.Service()("ReleaseTools/Git") {
1079
1092
  }
1080
1093
 
1094
+ class ReleaseLinuxBuild extends Context.Service()("ReleaseTools/LinuxBuild") {
1095
+ }
1096
+ var execFileAsync = promisify(execFile);
1097
+ var liveLinuxBuild = {
1098
+ async git(args, cwd) {
1099
+ const { stdout } = await execFileAsync("/usr/bin/git", [
1100
+ "--no-replace-objects",
1101
+ "-c",
1102
+ "core.fsmonitor=false",
1103
+ "-c",
1104
+ "core.hooksPath=/dev/null",
1105
+ ...args
1106
+ ], {
1107
+ cwd,
1108
+ encoding: "buffer",
1109
+ maxBuffer: 8 * 1024 * 1024,
1110
+ timeout: 30000,
1111
+ env: {
1112
+ PATH: "/usr/bin:/bin",
1113
+ HOME: "/nonexistent",
1114
+ LC_ALL: "C",
1115
+ GIT_CONFIG_NOSYSTEM: "1",
1116
+ GIT_CONFIG_GLOBAL: "/dev/null",
1117
+ GIT_NO_REPLACE_OBJECTS: "1",
1118
+ GIT_OPTIONAL_LOCKS: "0",
1119
+ GIT_TERMINAL_PROMPT: "0"
1120
+ }
1121
+ });
1122
+ return stdout;
1123
+ },
1124
+ async tool(command, args, env, signal) {
1125
+ signal?.throwIfAborted();
1126
+ await new Promise((resolve, reject) => {
1127
+ const child = spawn(command, [...args], { env, stdio: "inherit", detached: true });
1128
+ let timer;
1129
+ const stop = () => {
1130
+ if (!child.pid)
1131
+ return;
1132
+ try {
1133
+ process.kill(-child.pid, "SIGTERM");
1134
+ } catch {}
1135
+ timer = setTimeout(() => {
1136
+ try {
1137
+ process.kill(-child.pid, "SIGKILL");
1138
+ } catch {}
1139
+ }, 2000);
1140
+ };
1141
+ signal?.addEventListener("abort", stop, { once: true });
1142
+ if (signal?.aborted)
1143
+ stop();
1144
+ let spawnError;
1145
+ child.once("error", (error) => {
1146
+ spawnError = error;
1147
+ });
1148
+ child.once("close", async (code, childSignal) => {
1149
+ signal?.removeEventListener("abort", stop);
1150
+ if (timer)
1151
+ clearTimeout(timer);
1152
+ let leftDescendants = false;
1153
+ if (child.pid) {
1154
+ for (;; ) {
1155
+ try {
1156
+ const entries = await fsp.readdir("/proc");
1157
+ let live = false;
1158
+ for (const entry of entries) {
1159
+ if (!/^\d+$/.test(entry))
1160
+ continue;
1161
+ let stat;
1162
+ try {
1163
+ stat = await fsp.readFile(`/proc/${entry}/stat`, "utf8");
1164
+ } catch (error) {
1165
+ if (error.code === "ENOENT")
1166
+ continue;
1167
+ throw error;
1168
+ }
1169
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
1170
+ if (Number(fields[2]) === child.pid && fields[0] !== "Z" && fields[0] !== "X") {
1171
+ live = true;
1172
+ break;
1173
+ }
1174
+ }
1175
+ if (!live)
1176
+ break;
1177
+ leftDescendants = true;
1178
+ try {
1179
+ process.kill(-child.pid, "SIGKILL");
1180
+ } catch {}
1181
+ } catch {}
1182
+ await new Promise((done) => setTimeout(done, 20));
1183
+ }
1184
+ }
1185
+ if (signal?.aborted)
1186
+ reject(signal.reason);
1187
+ else if (spawnError)
1188
+ reject(spawnError);
1189
+ else if (leftDescendants)
1190
+ reject(new Error("Linux build tool left running descendants"));
1191
+ else if (code === 0)
1192
+ resolve();
1193
+ else
1194
+ reject(new Error(`Linux build tool failed (${childSignal ?? code})`));
1195
+ });
1196
+ });
1197
+ }
1198
+ };
1199
+
1081
1200
  class ReleaseGitHub extends Context.Service()("ReleaseTools/GitHub") {
1082
1201
  }
1083
1202
 
@@ -3286,6 +3405,424 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
3286
3405
  });
3287
3406
  var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
3288
3407
  var stageReleaseDescriptors = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(stageReleaseDescriptorsEffect(options)));
3408
+ // src/library/daily-batch-publication.ts
3409
+ import { createHash as createHash7, randomBytes } from "crypto";
3410
+ import { createReadStream } from "fs";
3411
+
3412
+ // ../../src/updates/feed/daily-batch-pointer.ts
3413
+ import { createPublicKey as createPublicKey3, verify as verify2 } from "crypto";
3414
+ var hex = /^[a-f0-9]{64}$/;
3415
+ var keyId = /^[a-z0-9][a-z0-9._-]{0,63}$/;
3416
+ function valid2(value) {
3417
+ return isRecord(value) && hasExactOwnKeys(value, [
3418
+ "schema",
3419
+ "appId",
3420
+ "feedApp",
3421
+ "manifestDigest",
3422
+ "generation",
3423
+ "sequence",
3424
+ "operation",
3425
+ "keyId"
3426
+ ]) && value.schema === "framework/daily-pointer/v3" && typeof value.appId === "string" && /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(value.appId) && typeof value.feedApp === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(value.feedApp) && typeof value.manifestDigest === "string" && hex.test(value.manifestDigest) && typeof value.generation === "string" && hex.test(value.generation) && Number.isSafeInteger(value.sequence) && Number(value.sequence) >= 1 && (value.operation === "promote" || value.operation === "rollback") && typeof value.keyId === "string" && keyId.test(value.keyId);
3427
+ }
3428
+ function message2(pointer) {
3429
+ return Buffer.from(JSON.stringify([
3430
+ "adea-app-framework-daily-pointer-v3",
3431
+ pointer.schema,
3432
+ pointer.appId,
3433
+ pointer.feedApp,
3434
+ pointer.manifestDigest,
3435
+ pointer.generation,
3436
+ pointer.sequence,
3437
+ pointer.operation,
3438
+ pointer.keyId
3439
+ ]), "utf8");
3440
+ }
3441
+ async function signDailyPointer(pointer, signer) {
3442
+ if (!valid2(pointer) || signer.keyId !== pointer.keyId)
3443
+ throw new Error("Invalid Daily pointer signing policy");
3444
+ const signature = await signer.sign(message2(pointer));
3445
+ if (!(signature instanceof Uint8Array) || signature.length !== 64)
3446
+ throw new Error("Invalid Daily pointer signature");
3447
+ return { pointer, signature: Buffer.from(signature).toString("base64url") };
3448
+ }
3449
+ function verifyDailyPointer(value, target, keys) {
3450
+ try {
3451
+ if (!isRecord(value) || !hasExactOwnKeys(value, ["pointer", "signature"]) || !valid2(value.pointer) || value.pointer.appId !== target.appId || value.pointer.feedApp !== target.feedApp || typeof value.signature !== "string" || !/^[A-Za-z0-9_-]{86}$/.test(value.signature))
3452
+ throw new Error;
3453
+ const encoded = keys.get(value.pointer.keyId);
3454
+ if (!encoded)
3455
+ throw new Error;
3456
+ const raw = Buffer.from(encoded, "base64");
3457
+ const signature = Buffer.from(value.signature, "base64url");
3458
+ if (raw.length !== 32 || signature.length !== 64 || signature.toString("base64url") !== value.signature)
3459
+ throw new Error;
3460
+ const key = createPublicKey3({
3461
+ key: Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]),
3462
+ format: "der",
3463
+ type: "spki"
3464
+ });
3465
+ if (!verify2(null, message2(value.pointer), key, signature))
3466
+ throw new Error;
3467
+ return value.pointer;
3468
+ } catch {
3469
+ throw new Error("Untrusted Daily pointer");
3470
+ }
3471
+ }
3472
+
3473
+ // src/library/daily-batch-publication.ts
3474
+ var authenticatedSnapshots = new WeakMap;
3475
+ var encoder = new TextEncoder;
3476
+ var hash = (bytes) => createHash7("sha256").update(bytes).digest("hex");
3477
+ var keyPart = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,199}$/;
3478
+ var hex2 = /^[a-f0-9]{64}$/;
3479
+ var app = /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
3480
+ var feedApp = /^[a-z][a-z0-9-]{0,63}$/;
3481
+ var gitSha = /^[a-f0-9]{40}$/;
3482
+ var tag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
3483
+ var own = (value, keys) => {
3484
+ const actual = Object.keys(value);
3485
+ return actual.length === keys.length && keys.every((key) => Object.hasOwn(value, key));
3486
+ };
3487
+ function parseManifest(value) {
3488
+ if (!value || typeof value !== "object" || Array.isArray(value))
3489
+ throw new Error("Invalid Daily batch");
3490
+ const m = value;
3491
+ if (!own(m, ["schema", "identity", "artifacts", "receipts"]) || m.schema !== "framework/daily-batch/v1" || !m.identity || typeof m.identity !== "object" || !own(m.identity, [
3492
+ "appId",
3493
+ "feedApp",
3494
+ "tag",
3495
+ "sourceSha",
3496
+ "workflowSha",
3497
+ "runId",
3498
+ "runAttempt"
3499
+ ]) || typeof m.identity.appId !== "string" || !app.test(m.identity.appId) || typeof m.identity.feedApp !== "string" || !feedApp.test(m.identity.feedApp) || typeof m.identity.tag !== "string" || !tag.test(m.identity.tag) || typeof m.identity.sourceSha !== "string" || !gitSha.test(m.identity.sourceSha) || m.identity.workflowSha !== m.identity.sourceSha || typeof m.identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(m.identity.runId) || !Number.isSafeInteger(m.identity.runAttempt) || m.identity.runAttempt < 1)
3500
+ throw new Error("Invalid Daily batch identity");
3501
+ for (const list of [m.artifacts, m.receipts]) {
3502
+ if (!Array.isArray(list) || !list.length || list.length > 256)
3503
+ throw new Error("Invalid Daily batch inventory");
3504
+ const seen = new Set;
3505
+ for (const item of list) {
3506
+ if (!item || typeof item !== "object" || !own(item, ["name", "size", "digest"]) || typeof item.name !== "string" || !keyPart.test(item.name) || seen.has(item.name) || !Number.isSafeInteger(item.size) || item.size < 1 || typeof item.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(item.digest))
3507
+ throw new Error("Invalid Daily batch file");
3508
+ seen.add(item.name);
3509
+ }
3510
+ }
3511
+ return m;
3512
+ }
3513
+ async function verifyBytes(bytes, expected) {
3514
+ const digest = createHash7("sha256");
3515
+ let size = 0;
3516
+ for await (const chunk of bytes) {
3517
+ size += chunk.byteLength;
3518
+ if (size > expected.size)
3519
+ throw new Error(`Daily batch object too large: ${expected.name}`);
3520
+ digest.update(chunk);
3521
+ }
3522
+ if (size !== expected.size || `sha256:${digest.digest("hex")}` !== expected.digest)
3523
+ throw new Error(`Daily batch object differs: ${expected.name}`);
3524
+ }
3525
+ async function readSmall(bytes, limit) {
3526
+ const parts = [];
3527
+ let size = 0;
3528
+ for await (const part of bytes) {
3529
+ size += part.byteLength;
3530
+ if (size > limit)
3531
+ throw new Error("Daily batch record too large");
3532
+ parts.push(part);
3533
+ }
3534
+ return Buffer.concat(parts);
3535
+ }
3536
+ var one = async function* (bytes) {
3537
+ yield bytes;
3538
+ };
3539
+ var prefix = (slug, digest) => `${slug}/batches/sha256-${digest}`;
3540
+ var pointer = (slug) => `${slug}/channels/daily-batch.json`;
3541
+ var parseJson = (bytes) => JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
3542
+ var compareTag = (a, b) => {
3543
+ const left = a.slice(1).split(".").map(BigInt);
3544
+ const right = b.slice(1).split(".").map(BigInt);
3545
+ for (let index = 0;index < 3; index++) {
3546
+ if (left[index] > right[index])
3547
+ return 1;
3548
+ if (left[index] < right[index])
3549
+ return -1;
3550
+ }
3551
+ return 0;
3552
+ };
3553
+ async function readDailyBatch(store, target, keys) {
3554
+ if (!app.test(target.appId) || !feedApp.test(target.feedApp))
3555
+ throw new Error("Invalid Daily app");
3556
+ const current = await store.readPointer(pointer(target.feedApp));
3557
+ if (!current)
3558
+ return null;
3559
+ if (!current.version || current.bytes.byteLength > 4096)
3560
+ throw new Error("Invalid Daily pointer");
3561
+ const signedPointer = parseJson(current.bytes);
3562
+ const p = verifyDailyPointer(signedPointer, target, keys);
3563
+ const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, p.manifestDigest)}/manifest.json`), 262144);
3564
+ if (hash(bytes) !== p.manifestDigest)
3565
+ throw new Error("Daily batch manifest changed");
3566
+ const manifest = parseManifest(parseJson(bytes));
3567
+ if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
3568
+ throw new Error("Daily batch app mismatch");
3569
+ Object.freeze(manifest.identity);
3570
+ for (const file of [...manifest.artifacts, ...manifest.receipts])
3571
+ Object.freeze(file);
3572
+ Object.freeze(manifest.artifacts);
3573
+ Object.freeze(manifest.receipts);
3574
+ Object.freeze(manifest);
3575
+ const snapshot = Object.freeze({
3576
+ version: current.version,
3577
+ sequence: p.sequence,
3578
+ manifestDigest: p.manifestDigest,
3579
+ manifest
3580
+ });
3581
+ authenticatedSnapshots.set(snapshot, signedPointer);
3582
+ return snapshot;
3583
+ }
3584
+ async function verifyDailyBatchDescriptor(store, snapshot, discoveryName, trust) {
3585
+ if (!authenticatedSnapshots.has(snapshot))
3586
+ throw new Error("Untrusted Daily snapshot");
3587
+ const { identity, artifacts } = snapshot.manifest;
3588
+ verifyDailyPointer(authenticatedSnapshots.get(snapshot), identity, trust.keys);
3589
+ let feed;
3590
+ try {
3591
+ feed = new URL(trust.feed);
3592
+ if (feed.protocol !== "https:" || feed.href !== trust.feed || feed.username || feed.password || feed.port || feed.search || feed.hash || !feed.pathname.endsWith(`/${identity.feedApp}/`) || trust.appId !== identity.appId || trust.channel !== "daily")
3593
+ throw new Error;
3594
+ } catch {
3595
+ throw new Error("Untrusted Daily feed");
3596
+ }
3597
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.json$/.test(discoveryName))
3598
+ throw new Error("Invalid Daily descriptor name");
3599
+ const listed = artifacts.find((file) => file.name === discoveryName);
3600
+ if (!listed || listed.size > 65536)
3601
+ throw new Error("Daily descriptor is missing");
3602
+ const base = prefix(identity.feedApp, snapshot.manifestDigest);
3603
+ const bytes = await readSmall(await store.readObject(`${base}/artifacts/${discoveryName}`), 65536);
3604
+ if (bytes.byteLength !== listed.size || `sha256:${hash(bytes)}` !== listed.digest)
3605
+ throw new Error("Daily descriptor differs from its snapshot");
3606
+ let signed;
3607
+ try {
3608
+ signed = parseJson(bytes);
3609
+ } catch {
3610
+ throw new Error("Invalid Daily descriptor");
3611
+ }
3612
+ const verified = verifyReleaseDescriptor(signed, trust);
3613
+ if (!verified.ok)
3614
+ throw new Error("Untrusted Daily descriptor");
3615
+ const descriptor = verified.descriptor;
3616
+ const payload = artifacts.find((file) => file.name === descriptor.asset.name);
3617
+ if (descriptor.tag !== identity.tag || descriptor.sourceSha !== identity.sourceSha || descriptor.workflowSha !== identity.workflowSha || descriptor.runId !== identity.runId || descriptor.runAttempt !== identity.runAttempt || !payload || payload.size !== descriptor.asset.size || payload.digest !== `sha256:${descriptor.asset.sha256}`)
3618
+ throw new Error("Daily descriptor does not match its snapshot");
3619
+ return {
3620
+ descriptor,
3621
+ artifactUrl: `${trust.feed}batches/sha256-${snapshot.manifestDigest}/artifacts/${payload.name}`
3622
+ };
3623
+ }
3624
+ async function verifyDailyBatchObject(store, snapshot, kind, name) {
3625
+ const file = snapshot.manifest[kind].find((item) => item.name === name);
3626
+ if (!file)
3627
+ throw new Error("Object is not in the selected Daily batch");
3628
+ await verifyBytes(await store.readObject(`${prefix(snapshot.manifest.identity.feedApp, snapshot.manifestDigest)}/${kind}/${name}`), file);
3629
+ }
3630
+ async function promoteDailyBatch(store, candidate, signer, keys) {
3631
+ const first = parseManifest(parseJson(encoder.encode(JSON.stringify(await candidate.verify()))));
3632
+ const { appId, feedApp: slug } = first.identity;
3633
+ const target = { appId, feedApp: slug };
3634
+ const old = await readDailyBatch(store, target, keys);
3635
+ const manifestBytes = encoder.encode(JSON.stringify(first) + `
3636
+ `);
3637
+ if (manifestBytes.byteLength > 262144)
3638
+ throw new Error("Daily manifest too large");
3639
+ const digest = hash(manifestBytes);
3640
+ if (old && compareTag(first.identity.tag, old.manifest.identity.tag) <= 0 && old.manifestDigest !== digest)
3641
+ throw new Error("Daily promotion must advance the version; use explicit rollback");
3642
+ const base = prefix(slug, digest);
3643
+ for (const kind of ["artifacts", "receipts"]) {
3644
+ for (const file of first[kind]) {
3645
+ const filePath = candidate.path(kind, file.name);
3646
+ await verifyBytes(createReadStream(filePath), file);
3647
+ const key = `${base}/${kind}/${file.name}`;
3648
+ await store.putImmutable(key, createReadStream(filePath), file.size, file.digest.slice(7));
3649
+ await verifyBytes(await store.readObject(key), file);
3650
+ }
3651
+ }
3652
+ await store.putImmutable(`${base}/manifest.json`, one(manifestBytes), manifestBytes.byteLength, digest);
3653
+ const storedManifest = await readSmall(await store.readObject(`${base}/manifest.json`), 262144);
3654
+ if (hash(storedManifest) !== digest)
3655
+ throw new Error("Daily manifest upload differs");
3656
+ if (JSON.stringify(parseManifest(await candidate.verify())) !== JSON.stringify(first))
3657
+ throw new Error("Daily candidate changed during upload");
3658
+ const signed = await signDailyPointer({
3659
+ schema: "framework/daily-pointer/v3",
3660
+ appId,
3661
+ feedApp: slug,
3662
+ manifestDigest: digest,
3663
+ generation: randomBytes(32).toString("hex"),
3664
+ sequence: (old?.sequence ?? 0) + 1,
3665
+ operation: "promote",
3666
+ keyId: signer.keyId
3667
+ }, signer);
3668
+ verifyDailyPointer(signed, target, keys);
3669
+ const bytes = encoder.encode(JSON.stringify(signed) + `
3670
+ `);
3671
+ if (!await store.compareAndSwap(pointer(slug), old?.version ?? null, bytes))
3672
+ throw new Error("Daily pointer changed during promotion");
3673
+ const selected = await readDailyBatch(store, target, keys);
3674
+ if (!selected || selected.manifestDigest !== digest)
3675
+ throw new Error("Daily promotion could not be read back");
3676
+ return selected;
3677
+ }
3678
+ async function rollbackDailyBatch(store, current, target, signer, keys) {
3679
+ const appId = current.manifest.identity.appId;
3680
+ const slug = current.manifest.identity.feedApp;
3681
+ if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3682
+ throw new Error("Invalid rollback target");
3683
+ const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3684
+ if (!selected || selected.version !== current.version)
3685
+ throw new Error("Daily pointer changed during rollback");
3686
+ const bytes = await readSmall(await store.readObject(`${prefix(slug, target.manifestDigest)}/manifest.json`), 262144);
3687
+ if (hash(bytes) !== target.manifestDigest || JSON.stringify(parseManifest(parseJson(bytes))) !== JSON.stringify(target.manifest))
3688
+ throw new Error("Rollback target differs");
3689
+ for (const kind of ["artifacts", "receipts"])
3690
+ for (const file of target.manifest[kind])
3691
+ await verifyDailyBatchObject(store, target, kind, file.name);
3692
+ const signed = await signDailyPointer({
3693
+ schema: "framework/daily-pointer/v3",
3694
+ appId,
3695
+ feedApp: slug,
3696
+ manifestDigest: target.manifestDigest,
3697
+ generation: randomBytes(32).toString("hex"),
3698
+ sequence: selected.sequence + 1,
3699
+ operation: "rollback",
3700
+ keyId: signer.keyId
3701
+ }, signer);
3702
+ verifyDailyPointer(signed, { appId, feedApp: slug }, keys);
3703
+ const next = encoder.encode(JSON.stringify(signed) + `
3704
+ `);
3705
+ if (!await store.compareAndSwap(pointer(slug), current.version, next))
3706
+ throw new Error("Daily pointer changed during rollback");
3707
+ }
3708
+ // src/library/daily-batch-r2.ts
3709
+ import { createHash as createHash8 } from "crypto";
3710
+ var single = async function* (bytes) {
3711
+ yield bytes;
3712
+ };
3713
+ var maxSingle = 4 * 1024 * 1024 * 1024;
3714
+ var keyPattern = /^(?:[a-zA-Z0-9][a-zA-Z0-9._-]*\/)*[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
3715
+ var safeKey = (key) => {
3716
+ if (key.length > 1024 || !keyPattern.test(key))
3717
+ throw new Error("Invalid R2 object key");
3718
+ return key;
3719
+ };
3720
+ async function drain(body) {
3721
+ for await (const _ of body) {}
3722
+ }
3723
+ async function bounded(body, limit) {
3724
+ const chunks = [];
3725
+ let size = 0;
3726
+ for await (const chunk of body) {
3727
+ size += chunk.byteLength;
3728
+ if (size > limit)
3729
+ throw new Error("R2 pointer too large");
3730
+ chunks.push(chunk);
3731
+ }
3732
+ return Buffer.concat(chunks);
3733
+ }
3734
+ async function verify3(body, size, sha256) {
3735
+ const digest = createHash8("sha256");
3736
+ let actual = 0;
3737
+ for await (const chunk of body) {
3738
+ actual += chunk.byteLength;
3739
+ if (actual > size)
3740
+ throw new Error("Existing immutable R2 object differs");
3741
+ digest.update(chunk);
3742
+ }
3743
+ if (actual !== size || digest.digest("hex") !== sha256)
3744
+ throw new Error("Existing immutable R2 object differs");
3745
+ }
3746
+ function createDailyBatchR2Store(send) {
3747
+ const get = (key) => send({ method: "GET", key: safeKey(key), headers: {} });
3748
+ return {
3749
+ async readObject(key) {
3750
+ const response = await get(key);
3751
+ if (response.status !== 200) {
3752
+ await drain(response.body);
3753
+ throw new Error(`R2 object read failed (${response.status})`);
3754
+ }
3755
+ return response.body;
3756
+ },
3757
+ async readPointer(key) {
3758
+ const response = await get(key);
3759
+ if (response.status === 404) {
3760
+ await drain(response.body);
3761
+ return null;
3762
+ }
3763
+ if (response.status !== 200) {
3764
+ await drain(response.body);
3765
+ throw new Error(`R2 pointer read failed (${response.status})`);
3766
+ }
3767
+ const version = response.headers.etag;
3768
+ if (!version || /[\r\n]/.test(version)) {
3769
+ await drain(response.body);
3770
+ throw new Error("R2 pointer has no safe ETag");
3771
+ }
3772
+ return { version, bytes: await bounded(response.body, 4096) };
3773
+ },
3774
+ async putImmutable(key, body, size, sha256) {
3775
+ if (!Number.isSafeInteger(size) || size < 1 || size > maxSingle || !/^[a-f0-9]{64}$/.test(sha256))
3776
+ throw new Error("Invalid R2 immutable object identity");
3777
+ const response = await send({
3778
+ method: "PUT",
3779
+ key: safeKey(key),
3780
+ headers: {
3781
+ "if-none-match": "*",
3782
+ "content-length": String(size),
3783
+ "content-type": "application/octet-stream",
3784
+ "cache-control": "public, max-age=31536000, immutable"
3785
+ },
3786
+ body
3787
+ });
3788
+ await drain(response.body);
3789
+ if (response.status === 412) {
3790
+ const prior = await get(key);
3791
+ if (prior.status !== 200) {
3792
+ await drain(prior.body);
3793
+ throw new Error("Cannot verify existing R2 object");
3794
+ }
3795
+ await verify3(prior.body, size, sha256);
3796
+ } else if (response.status !== 200)
3797
+ throw new Error(`R2 immutable upload failed (${response.status})`);
3798
+ },
3799
+ async compareAndSwap(key, expectedVersion, bytes) {
3800
+ if (!bytes.byteLength || bytes.byteLength > 4096 || expectedVersion !== null && (!expectedVersion || /[\r\n]/.test(expectedVersion)))
3801
+ throw new Error("Invalid R2 pointer update");
3802
+ const response = await send({
3803
+ method: "PUT",
3804
+ key: safeKey(key),
3805
+ headers: {
3806
+ ...expectedVersion === null ? { "if-none-match": "*" } : { "if-match": expectedVersion },
3807
+ "content-length": String(bytes.byteLength),
3808
+ "content-type": "application/json",
3809
+ "cache-control": "no-cache"
3810
+ },
3811
+ body: single(bytes)
3812
+ });
3813
+ await drain(response.body);
3814
+ if (response.status === 412)
3815
+ return false;
3816
+ if (response.status !== 200)
3817
+ throw new Error(`R2 pointer update failed (${response.status})`);
3818
+ return true;
3819
+ }
3820
+ };
3821
+ }
3822
+ // src/library/daily-batch-inspection.ts
3823
+ import { join as join9 } from "path";
3824
+ import { Effect as Effect17 } from "effect";
3825
+
3289
3826
  // src/library/daily-matrix.ts
3290
3827
  import { join as join8 } from "path";
3291
3828
  import { Effect as Effect16 } from "effect";
@@ -3486,10 +4023,136 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
3486
4023
  function verifyDailyReleaseMatrix(options) {
3487
4024
  return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
3488
4025
  }
4026
+
4027
+ // src/library/daily-batch-inspection.ts
4028
+ var inspectDailyBatchEffect = (options) => Effect17.gen(function* () {
4029
+ const git = yield* ReleaseGit;
4030
+ const { identity, configPath, artifacts, receipts } = options;
4031
+ yield* attempt(() => assertDailyIdentity(identity));
4032
+ if (configPath.length > 200 || !/^[A-Za-z0-9._/-]+\.json$/.test(configPath) || configPath.startsWith("/") || configPath.split("/").some((part) => !part || part === "." || part === ".."))
4033
+ return yield* fail("Invalid committed release configuration path");
4034
+ if ((yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
4035
+ return yield* fail("Daily inspection checkout does not match the source commit");
4036
+ const tree = yield* step(() => git.run(["--no-replace-objects", "ls-tree", identity.sourceSha, "--", configPath]));
4037
+ const match = /^100(?:644|755) blob ([a-f0-9]{40})\t([^\n]+)$/.exec(tree);
4038
+ if (!match || match[2] !== configPath)
4039
+ return yield* fail("Daily release configuration is not a committed regular file");
4040
+ const configBlob = match[1];
4041
+ const raw = yield* step(() => git.run(["--no-replace-objects", "show", `${identity.sourceSha}:${configPath}`]));
4042
+ if (Buffer.byteLength(raw) > 1024 * 1024)
4043
+ return yield* fail("Daily release configuration is too large");
4044
+ const config = yield* attempt(() => JSON.parse(raw));
4045
+ const parsed = yield* attempt(() => parseReleaseConfig(config));
4046
+ const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
4047
+ const receiptNames = matrix.checks.map((check) => `${check.name}.json`);
4048
+ const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
4049
+ const verified = yield* verifyDailyReleaseMatrixEffect({
4050
+ config,
4051
+ identity,
4052
+ artifacts,
4053
+ receipts
4054
+ });
4055
+ const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
4056
+ const after = yield* verifyDailyReleaseMatrixEffect({ config, identity, artifacts, receipts });
4057
+ 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)
4058
+ return yield* fail("Daily inputs changed during inspection");
4059
+ return {
4060
+ schema: "framework/daily-batch-inspection/v1",
4061
+ identity: { appId: matrix.appId, feedApp: parsed.feed.app, ...identity },
4062
+ config: { path: configPath, gitBlob: configBlob },
4063
+ artifacts: verified.assets,
4064
+ receipts: receiptHashes,
4065
+ promotionAuthorized: false,
4066
+ unverified: [
4067
+ "windows-10-and-11",
4068
+ "independent-clean-environments",
4069
+ "signatures-and-notarization",
4070
+ "linux-reproducibility",
4071
+ "protected-source-and-workflow"
4072
+ ]
4073
+ };
4074
+ });
4075
+ var inspectDailyBatch = (options) => runReleaseLibrary(provideLibraryPorts()(inspectDailyBatchEffect(options)));
4076
+ // src/library/daily-batch-s3.ts
4077
+ import { GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
4078
+ import { Readable } from "stream";
4079
+ function createDailyBatchR2Client(accountId, credentials) {
4080
+ if (!/^[a-f0-9]{32}$/.test(accountId))
4081
+ throw new Error("Invalid R2 account ID");
4082
+ return new S3Client({
4083
+ endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
4084
+ region: "auto",
4085
+ credentials,
4086
+ forcePathStyle: true,
4087
+ maxAttempts: 1,
4088
+ requestChecksumCalculation: "WHEN_REQUIRED",
4089
+ responseChecksumValidation: "WHEN_REQUIRED"
4090
+ });
4091
+ }
4092
+ function createDailyBatchS3Transport(client, bucket) {
4093
+ if (!/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/.test(bucket) || bucket.includes(".."))
4094
+ throw new Error("Invalid R2 bucket");
4095
+ return async ({ method, key, headers, body }) => {
4096
+ if (await client.config.maxAttempts() !== 1)
4097
+ throw new Error("S3 retries must be disabled");
4098
+ const allowed = new Set([
4099
+ "if-match",
4100
+ "if-none-match",
4101
+ "content-length",
4102
+ "content-type",
4103
+ "cache-control"
4104
+ ]);
4105
+ if (Object.keys(headers).some((name) => !allowed.has(name)))
4106
+ throw new Error("Unexpected S3 header");
4107
+ let stream;
4108
+ try {
4109
+ if (method === "GET") {
4110
+ if (body || Object.keys(headers).length)
4111
+ throw new Error("Invalid S3 GET");
4112
+ const result = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
4113
+ if (!result.Body || !(Symbol.asyncIterator in result.Body))
4114
+ throw new Error("S3 body is not a stream");
4115
+ return {
4116
+ status: result.$metadata.httpStatusCode ?? 0,
4117
+ headers: { etag: result.ETag },
4118
+ body: result.Body
4119
+ };
4120
+ }
4121
+ const length = Number(headers["content-length"]);
4122
+ if (!body || !Number.isSafeInteger(length) || length < 1 || String(length) !== headers["content-length"])
4123
+ throw new Error("Invalid S3 upload length");
4124
+ stream = Readable.from(body);
4125
+ const result = await client.send(new PutObjectCommand({
4126
+ Bucket: bucket,
4127
+ Key: key,
4128
+ Body: stream,
4129
+ ContentLength: length,
4130
+ ContentType: headers["content-type"],
4131
+ CacheControl: headers["cache-control"],
4132
+ IfMatch: headers["if-match"],
4133
+ IfNoneMatch: headers["if-none-match"]
4134
+ }));
4135
+ if (!stream.readableEnded)
4136
+ throw new Error("S3 upload body not fully consumed");
4137
+ return {
4138
+ status: result.$metadata.httpStatusCode ?? 0,
4139
+ headers: { etag: result.ETag },
4140
+ body: empty()
4141
+ };
4142
+ } catch (error) {
4143
+ stream?.destroy();
4144
+ const status = error?.$metadata?.httpStatusCode;
4145
+ if (status === 404 || status === 412)
4146
+ return { status, headers: {}, body: empty() };
4147
+ throw error;
4148
+ }
4149
+ };
4150
+ }
4151
+ async function* empty() {}
3489
4152
  // src/library/daily-native-receipt.ts
3490
- import { join as join9 } from "path";
3491
- import { Effect as Effect17 } from "effect";
3492
- var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function* () {
4153
+ import { join as join10 } from "path";
4154
+ import { Effect as Effect18 } from "effect";
4155
+ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function* () {
3493
4156
  const { config, identity, artifacts, checkName, report } = options;
3494
4157
  yield* attempt(() => assertDailyIdentity(identity));
3495
4158
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
@@ -3503,7 +4166,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3503
4166
  const dir = yield* step(() => fs.lstat(artifacts));
3504
4167
  if (!dir.isDirectory() || dir.isSymbolicLink())
3505
4168
  return yield* fail("Expected real native artifact directory");
3506
- const assets = yield* Effect17.forEach(check.assets, (name) => fileIdentityEffect(join9(artifacts, name), name));
4169
+ const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join10(artifacts, name), name));
3507
4170
  const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
3508
4171
  appId: matrix.appId,
3509
4172
  identity,
@@ -3521,7 +4184,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3521
4184
  const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
3522
4185
  const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
3523
4186
  for (const expected of proofFiles) {
3524
- const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
4187
+ const observed = yield* fileIdentityEffect(join10(baselineDirectory, expected.name), expected.name);
3525
4188
  if (observed.size !== expected.size || observed.digest !== expected.digest)
3526
4189
  return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
3527
4190
  }
@@ -3544,6 +4207,160 @@ function createDailyNativeReceipt(options) {
3544
4207
  arch: process.arch
3545
4208
  })));
3546
4209
  }
4210
+ // src/library/linux-reproducibility.ts
4211
+ import { createHash as createHash9 } from "crypto";
4212
+ import { lstat as lstat6, readFile as readFile5, readdir as readdir5, realpath } from "fs/promises";
4213
+ import { isAbsolute as isAbsolute2, join as join11, resolve as resolve6 } from "path";
4214
+ var sha256 = /^[a-f0-9]{64}$/;
4215
+ var digest2 = /^sha256:[a-f0-9]{64}$/;
4216
+ var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
4217
+ var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
4218
+ var filename = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
4219
+ function check(ok, message) {
4220
+ if (!ok)
4221
+ throw new Error(message);
4222
+ }
4223
+ async function regular(path) {
4224
+ check(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
4225
+ const stat = await lstat6(path);
4226
+ check(stat.isFile() && !stat.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real regular input file");
4227
+ check(Number.isSafeInteger(stat.size) && stat.size > 0, "Invalid input file size");
4228
+ const result = await hashFileAt(path, stat, "Input changed during comparison");
4229
+ const after = await lstat6(path);
4230
+ 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");
4231
+ return { ...result, dev: stat.dev, ino: stat.ino };
4232
+ }
4233
+ async function outputDirectory(path, expected) {
4234
+ check(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
4235
+ const info = await lstat6(path);
4236
+ check(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
4237
+ const entries = await readdir5(path, { withFileTypes: true });
4238
+ const names = new Set(expected);
4239
+ 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");
4240
+ return { path, dev: info.dev, ino: info.ino, mtimeMs: info.mtimeMs, ctimeMs: info.ctimeMs };
4241
+ }
4242
+ async function directoryUnchanged(before) {
4243
+ const after = await lstat6(before.path);
4244
+ 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");
4245
+ }
4246
+ function sameIdentity(a, b) {
4247
+ return a.tag === b.tag && a.sourceSha === b.sourceSha && a.workflowSha === b.workflowSha && a.runId === b.runId && a.runAttempt === b.runAttempt;
4248
+ }
4249
+ async function compareLinuxReproducibility(rawInput) {
4250
+ const input = structuredClone(rawInput);
4251
+ check(isRecord(input) && hasExactOwnKeys(input, [
4252
+ "config",
4253
+ "identity",
4254
+ "sourceDateEpoch",
4255
+ "archive",
4256
+ "imageReference",
4257
+ "toolchainDigest",
4258
+ "runs"
4259
+ ]) && isRecord(input.identity) && hasExactOwnKeys(input.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && isRecord(input.archive) && hasExactOwnKeys(input.archive, ["size", "sha256"]), "Invalid Linux comparison input");
4260
+ assertDailyIdentity(input.identity);
4261
+ 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");
4262
+ check(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
4263
+ const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
4264
+ const archiveName = requirements.platforms["linux-x64"]?.[1];
4265
+ check(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
4266
+ const stem = archiveName.slice(0, -".tar.zst".length);
4267
+ const artifacts = [`${stem}.deb`, `${stem}.AppImage`];
4268
+ const outputs = [...artifacts, "linux-format-build.json"];
4269
+ check(artifacts.every((name) => filename.test(name)) && new Set(outputs).size === outputs.length, "Invalid configured Linux output names");
4270
+ check(Array.isArray(input.runs) && input.runs.length === 2, "Exactly two build runs required");
4271
+ for (const run of input.runs) {
4272
+ check(isRecord(run) && hasExactOwnKeys(run, [
4273
+ "identity",
4274
+ "appId",
4275
+ "sourceDateEpoch",
4276
+ "jobId",
4277
+ "platform",
4278
+ "imageReference",
4279
+ "toolchainDigest",
4280
+ "archive",
4281
+ "output"
4282
+ ]) && 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");
4283
+ }
4284
+ const first = input.runs[0];
4285
+ const second = input.runs[1];
4286
+ check(first.jobId !== second.jobId, "Build jobs must be distinct");
4287
+ const firstDir = await outputDirectory(first.output, outputs);
4288
+ const secondDir = await outputDirectory(second.output, outputs);
4289
+ check(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
4290
+ const firstArchive = await regular(first.archive);
4291
+ const secondArchive = await regular(second.archive);
4292
+ for (const archive of [firstArchive, secondArchive])
4293
+ check(archive.size === input.archive.size && archive.sha256 === input.archive.sha256, "Build archive does not match the independently verified input");
4294
+ check(firstArchive.dev !== secondArchive.dev || firstArchive.ino !== secondArchive.ino, "Build archive copies must be distinct");
4295
+ const observed = [
4296
+ { path: first.archive, file: firstArchive },
4297
+ { path: second.archive, file: secondArchive }
4298
+ ];
4299
+ const seen = new Set([
4300
+ `${firstArchive.dev}:${firstArchive.ino}`,
4301
+ `${secondArchive.dev}:${secondArchive.ino}`
4302
+ ]);
4303
+ const result = [];
4304
+ for (const name of artifacts) {
4305
+ const left = await regular(join11(first.output, name));
4306
+ const right = await regular(join11(second.output, name));
4307
+ for (const file of [left, right]) {
4308
+ const key = `${file.dev}:${file.ino}`;
4309
+ check(!seen.has(key), "Build inputs and outputs must be independent files");
4310
+ seen.add(key);
4311
+ }
4312
+ observed.push({ path: join11(first.output, name), file: left });
4313
+ observed.push({ path: join11(second.output, name), file: right });
4314
+ check(left.size === right.size && left.sha256 === right.sha256, `Linux build differs: ${name}`);
4315
+ result.push({ name, size: left.size, sha256: left.sha256 });
4316
+ }
4317
+ for (const run of input.runs) {
4318
+ const path = join11(run.output, "linux-format-build.json");
4319
+ const file = await regular(path);
4320
+ const key = `${file.dev}:${file.ino}`;
4321
+ check(!seen.has(key), "Build inputs and outputs must be independent files");
4322
+ seen.add(key);
4323
+ observed.push({ path, file });
4324
+ check(file.size <= 65536, "Producer receipt is too large");
4325
+ const bytes = await readFile5(path);
4326
+ check(bytes.length === file.size && createHash9("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
4327
+ let receipt;
4328
+ try {
4329
+ receipt = JSON.parse(bytes.toString("utf8"));
4330
+ } catch {
4331
+ throw new Error("Invalid producer receipt");
4332
+ }
4333
+ check(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
4334
+ const receiptArtifacts = receipt.artifacts;
4335
+ check(hasExactOwnKeys(receipt, [
4336
+ "schema",
4337
+ "tag",
4338
+ "sourceSha",
4339
+ "sourceDateEpoch",
4340
+ "platform",
4341
+ "updateArchiveSha256",
4342
+ "artifacts"
4343
+ ]) && 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");
4344
+ }
4345
+ for (const previous of observed) {
4346
+ const current = await regular(previous.path);
4347
+ 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");
4348
+ }
4349
+ await directoryUnchanged(firstDir);
4350
+ await directoryUnchanged(secondDir);
4351
+ return {
4352
+ schema: "framework/linux-format-byte-comparison/v1",
4353
+ qualified: false,
4354
+ appId: input.config.appId,
4355
+ identity: input.identity,
4356
+ sourceDateEpoch: input.sourceDateEpoch,
4357
+ archive: input.archive,
4358
+ imageReference: input.imageReference,
4359
+ toolchainDigest: input.toolchainDigest,
4360
+ jobs: input.runs.map((run) => ({ jobId: run.jobId })),
4361
+ artifacts: result
4362
+ };
4363
+ }
3547
4364
  // src/library/macos-dmg.ts
3548
4365
  import { execFileSync } from "child_process";
3549
4366
  import {
@@ -3555,8 +4372,8 @@ import {
3555
4372
  rmSync,
3556
4373
  symlinkSync
3557
4374
  } from "fs";
3558
- import { basename as basename4, dirname, join as join10, resolve as resolve6 } from "path";
3559
- import { Context as Context2, Effect as Effect18 } from "effect";
4375
+ import { basename as basename4, dirname, join as join12, resolve as resolve7 } from "path";
4376
+ import { Context as Context2, Effect as Effect19 } from "effect";
3560
4377
 
3561
4378
  // ../../src/release/macos-dmg.ts
3562
4379
  var MIB = 1024 * 1024;
@@ -3587,7 +4404,7 @@ function treeSize(root) {
3587
4404
  logicalBytes += info.size;
3588
4405
  else if (info.isDirectory())
3589
4406
  for (const name of readdirSync(path))
3590
- pending.push(join10(path, name));
4407
+ pending.push(join12(path, name));
3591
4408
  else if (!info.isSymbolicLink())
3592
4409
  throw new Error("Unsupported disk image entry");
3593
4410
  if (!Number.isSafeInteger(logicalBytes))
@@ -3595,29 +4412,29 @@ function treeSize(root) {
3595
4412
  }
3596
4413
  return { logicalBytes, entries };
3597
4414
  }
3598
- var verifyImageEffect = (image) => Effect18.gen(function* () {
4415
+ var verifyImageEffect = (image) => Effect19.gen(function* () {
3599
4416
  const host = yield* MacosHost;
3600
4417
  for (let tries = 1;; tries++) {
3601
- const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect18.as(true), Effect18.catchIf(() => tries < 6, () => Effect18.succeed(false)));
4418
+ const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect19.as(true), Effect19.catchIf(() => tries < 6, () => Effect19.succeed(false)));
3602
4419
  if (verified)
3603
4420
  return;
3604
4421
  host.wait(5000 * 2 ** (tries - 1));
3605
4422
  }
3606
4423
  });
3607
- var createMacosDmgEffect = (options) => Effect18.gen(function* () {
4424
+ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
3608
4425
  const host = yield* MacosHost;
3609
4426
  if (host.platform !== "darwin")
3610
4427
  return yield* fail("Disk image creation requires macOS");
3611
4428
  assertPortableAppName(options.appName);
3612
- const app = resolve6(options.appPath), output = resolve6(options.outputPath);
4429
+ const app = resolve7(options.appPath), output = resolve7(options.outputPath);
3613
4430
  const info = yield* attempt(() => lstatSync(app));
3614
4431
  if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
3615
4432
  return yield* fail("Invalid disk image paths");
3616
- const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join10(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
3617
- const payload = join10(staging, "payload"), image = join10(staging, "result.dmg");
4433
+ const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(join12(dirname(output), ".framework-dmg-"))), (path) => Effect19.sync(() => rmSync(path, { recursive: true, force: true })));
4434
+ const payload = join12(staging, "payload"), image = join12(staging, "result.dmg");
3618
4435
  yield* attempt(() => mkdirSync(payload));
3619
- yield* attempt(() => host.run("/usr/bin/ditto", [app, join10(payload, basename4(app))]));
3620
- yield* attempt(() => symlinkSync("/Applications", join10(payload, "Applications")));
4436
+ yield* attempt(() => host.run("/usr/bin/ditto", [app, join12(payload, basename4(app))]));
4437
+ yield* attempt(() => symlinkSync("/Applications", join12(payload, "Applications")));
3621
4438
  const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
3622
4439
  yield* attempt(() => host.run("/usr/bin/hdiutil", [
3623
4440
  "create",
@@ -3634,36 +4451,36 @@ var createMacosDmgEffect = (options) => Effect18.gen(function* () {
3634
4451
  yield* verifyImageEffect(image);
3635
4452
  yield* attempt(() => linkSync(image, output));
3636
4453
  return { capacityMiB };
3637
- }).pipe(Effect18.scoped);
4454
+ }).pipe(Effect19.scoped);
3638
4455
  function verifyImage(image, io = liveHost) {
3639
- runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
4456
+ runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect19.provideService(MacosHost, {
3640
4457
  run: (command, args) => io.run(command, args),
3641
4458
  wait: (milliseconds) => io.wait(milliseconds),
3642
4459
  platform: process.platform
3643
4460
  })));
3644
4461
  }
3645
4462
  function createMacosDmg(options) {
3646
- return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
4463
+ return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect19.provideService(MacosHost, liveHost)));
3647
4464
  }
3648
4465
  // src/library/qualification-run.ts
3649
- import { Effect as Effect21 } from "effect";
4466
+ import { Effect as Effect22 } from "effect";
3650
4467
 
3651
4468
  // src/library/local-release.ts
3652
- import { createHash as createHash8 } from "crypto";
4469
+ import { createHash as createHash11 } from "crypto";
3653
4470
  import { constants as constants3 } from "fs";
3654
- import { dirname as dirname2, join as join12, resolve as resolve8 } from "path";
3655
- import { Cause as Cause2, Effect as Effect20, Exit as Exit3 } from "effect";
4471
+ import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
4472
+ import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
3656
4473
 
3657
4474
  // ../../src/native/native-rename.ts
3658
4475
  import { randomUUID } from "crypto";
3659
- import { mkdir as mkdir3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
4476
+ import { mkdir as mkdir3, readFile as readFile6, rm as rm3, writeFile as writeFile3 } from "fs/promises";
3660
4477
  import { dlopen, FFIType, ptr } from "bun:ffi";
3661
- import { join as join11 } from "path";
4478
+ import { join as join13 } from "path";
3662
4479
 
3663
4480
  // ../../src/native/canonical-path.ts
3664
- import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
4481
+ import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
3665
4482
  function isCanonicalPath(value) {
3666
- return typeof value === "string" && isAbsolute2(value) && resolve7(value) === value && !value.includes("\x00");
4483
+ return typeof value === "string" && isAbsolute3(value) && resolve8(value) === value && !value.includes("\x00");
3667
4484
  }
3668
4485
 
3669
4486
  // ../../src/native/native-rename.ts
@@ -3737,8 +4554,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3737
4554
  if (!isCanonicalPath(parent))
3738
4555
  throw new Error("Invalid directory exchange probe parent");
3739
4556
  const id = randomUUID();
3740
- const first = join11(parent, `.framework-exchange-probe-${id}-a`);
3741
- const second = join11(parent, `.framework-exchange-probe-${id}-b`);
4557
+ const first = join13(parent, `.framework-exchange-probe-${id}-a`);
4558
+ const second = join13(parent, `.framework-exchange-probe-${id}-b`);
3742
4559
  const marker = "exchange-probe";
3743
4560
  const firstValue = `${id}:first`;
3744
4561
  const secondValue = `${id}:second`;
@@ -3749,12 +4566,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3749
4566
  firstCreated = true;
3750
4567
  await mkdir3(second, { mode: 448 });
3751
4568
  secondCreated = true;
3752
- await writeFile3(join11(first, marker), firstValue, { flag: "wx", mode: 384 });
3753
- await writeFile3(join11(second, marker), secondValue, { flag: "wx", mode: 384 });
4569
+ await writeFile3(join13(first, marker), firstValue, { flag: "wx", mode: 384 });
4570
+ await writeFile3(join13(second, marker), secondValue, { flag: "wx", mode: 384 });
3754
4571
  exchange(first, second);
3755
4572
  const [firstAfter, secondAfter] = await Promise.all([
3756
- readFile5(join11(first, marker), "utf8"),
3757
- readFile5(join11(second, marker), "utf8")
4573
+ readFile6(join13(first, marker), "utf8"),
4574
+ readFile6(join13(second, marker), "utf8")
3758
4575
  ]);
3759
4576
  if (firstAfter !== secondValue || secondAfter !== firstValue)
3760
4577
  throw new Error("Directory exchange did not exchange both probe trees");
@@ -3819,8 +4636,8 @@ function createFeedReleaseCutProvider(options) {
3819
4636
  }
3820
4637
 
3821
4638
  // src/library/feed-state.ts
3822
- import { createHash as createHash7 } from "crypto";
3823
- import { Effect as Effect19 } from "effect";
4639
+ import { createHash as createHash10 } from "crypto";
4640
+ import { Effect as Effect20 } from "effect";
3824
4641
 
3825
4642
  // ../../src/shared/discard-stream.ts
3826
4643
  function discardStream(stream) {
@@ -3980,11 +4797,11 @@ var json = (bytes) => {
3980
4797
  throw new Error("Invalid release feed response");
3981
4798
  }
3982
4799
  };
3983
- var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
4800
+ var feedObject = (feed, path, maximum) => Effect20.gen(function* () {
3984
4801
  const { fetch: fetch2 } = yield* ReleaseFetch;
3985
4802
  return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
3986
4803
  });
3987
- var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
4804
+ var readFeedLedgerEffect = (feed) => Effect20.gen(function* () {
3988
4805
  const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
3989
4806
  const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
3990
4807
  if (ledger && ledger.releases.length > 0)
@@ -3996,7 +4813,7 @@ var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
3996
4813
  }
3997
4814
  return ledger ?? { schema: 1, app: feed.app, releases: [] };
3998
4815
  });
3999
- var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
4816
+ var readFeedReleaseEffect = (feed, tag) => Effect20.gen(function* () {
4000
4817
  const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
4001
4818
  if (!bytes)
4002
4819
  return null;
@@ -4046,10 +4863,10 @@ class ReleaseFeedSnapshotChanged extends Error {
4046
4863
  var snapshotChanged = step(async () => {
4047
4864
  throw new ReleaseFeedSnapshotChanged;
4048
4865
  });
4049
- var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4866
+ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
4050
4867
  const { config, feed, tag } = options;
4051
4868
  const { fetch: fetcher } = yield* ReleaseFetch;
4052
- const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect19.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
4869
+ const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect20.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
4053
4870
  if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
4054
4871
  return yield* snapshotChanged;
4055
4872
  const release = yield* readFeedReleaseEffect(feed, tag);
@@ -4067,7 +4884,7 @@ var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4067
4884
  if (!listed)
4068
4885
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
4069
4886
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
4070
- if (!bytes || bytes.length !== listed.size || createHash7("sha256").update(bytes).digest("hex") !== listed.sha256)
4887
+ if (!bytes || bytes.length !== listed.size || createHash10("sha256").update(bytes).digest("hex") !== listed.sha256)
4071
4888
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
4072
4889
  const verified = verifyReleaseDescriptor(json(bytes), {
4073
4890
  appId: policy.appId,
@@ -4112,13 +4929,13 @@ var timestamp2 = (value) => {
4112
4929
  throw new Error("Invalid release clock");
4113
4930
  return new Date(value).toISOString();
4114
4931
  };
4115
- var exactFiles = (directory, names) => Effect20.gen(function* () {
4932
+ var exactFiles = (directory, names) => Effect21.gen(function* () {
4116
4933
  const fs = yield* ReleaseFs;
4117
4934
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
4118
4935
  if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
4119
4936
  return yield* fail("Staged directory does not hold exactly the platform release files");
4120
4937
  });
4121
- var promised2 = Effect20.gen(function* () {
4938
+ var promised2 = Effect21.gen(function* () {
4122
4939
  const fs = yield* ReleaseFs;
4123
4940
  const { fetch: fetch2 } = yield* ReleaseFetch;
4124
4941
  const { run: git } = yield* ReleaseGit;
@@ -4128,7 +4945,7 @@ var promised2 = Effect20.gen(function* () {
4128
4945
  run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
4129
4946
  };
4130
4947
  });
4131
- var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4948
+ var runLocalReleaseCutEffect = (options) => Effect21.gen(function* () {
4132
4949
  const { kind, platform } = options;
4133
4950
  const parsed = parseReleaseConfig(options.config);
4134
4951
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4153,7 +4970,7 @@ var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4153
4970
  }));
4154
4971
  return { ...result, version: result.tag.slice(1), platform };
4155
4972
  });
4156
- var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4973
+ var localTagProvenanceEffect = (options) => Effect21.gen(function* () {
4157
4974
  const parsed = parseReleaseConfig(options.config);
4158
4975
  parsed.requirements(options.tag);
4159
4976
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4164,16 +4981,16 @@ var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4164
4981
  return yield* fail("Release tag does not belong to the source version");
4165
4982
  return { repository: provenance.repository };
4166
4983
  });
4167
- var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4984
+ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4168
4985
  const { tag, platform } = options;
4169
4986
  const local = localConfig(options.config);
4170
4987
  if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
4171
4988
  return yield* fail("Invalid local release identity");
4172
4989
  const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
4173
4990
  const payloads = platformPayloads(local.requirements(tag), platform);
4174
- const directory = resolve8(options.directory);
4991
+ const directory = resolve9(options.directory);
4175
4992
  yield* exactFiles(directory, payloads);
4176
- const assets = yield* Effect20.forEach(payloads, (name) => fileIdentityEffect(join12(directory, name), name), { concurrency: "unbounded" });
4993
+ const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
4177
4994
  const signed = signDiscoveryDescriptors({
4178
4995
  policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
4179
4996
  assets,
@@ -4191,7 +5008,7 @@ var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4191
5008
  privateKey: options.privateKey
4192
5009
  });
4193
5010
  for (const asset of assets)
4194
- if (JSON.stringify(yield* fileIdentityEffect(join12(directory, asset.name), asset.name)) !== JSON.stringify(asset))
5011
+ if (JSON.stringify(yield* fileIdentityEffect(join14(directory, asset.name), asset.name)) !== JSON.stringify(asset))
4195
5012
  return yield* fail("Staged payload changed before signing");
4196
5013
  yield* writeDescriptorsEffect(directory, signed);
4197
5014
  return signed.map((value) => value.name);
@@ -4211,22 +5028,22 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
4211
5028
  var describe = (key, bytes, cacheControl) => ({
4212
5029
  key,
4213
5030
  size: bytes.length,
4214
- sha256: createHash8("sha256").update(bytes).digest("hex"),
5031
+ sha256: createHash11("sha256").update(bytes).digest("hex"),
4215
5032
  contentType: "application/json",
4216
5033
  cacheControl
4217
5034
  });
4218
- var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
5035
+ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* () {
4219
5036
  const fs = yield* ReleaseFs;
4220
- const root = resolve8(out);
4221
- const exists = yield* step(() => fs.lstat(root)).pipe(Effect20.as(true), Effect20.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect20.succeed(false)));
5037
+ const root = resolve9(out);
5038
+ const exists = yield* step(() => fs.lstat(root)).pipe(Effect21.as(true), Effect21.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect21.succeed(false)));
4222
5039
  if (exists)
4223
5040
  return yield* fail("Release output directory already exists");
4224
5041
  yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
4225
- const staging = yield* step(() => fs.mkdtemp(join12(dirname2(root), ".release-staging-")));
4226
- const exit = yield* Effect20.exit(Effect20.gen(function* () {
5042
+ const staging = yield* step(() => fs.mkdtemp(join14(dirname2(root), ".release-staging-")));
5043
+ const exit = yield* Effect21.exit(Effect21.gen(function* () {
4227
5044
  const objects = [];
4228
5045
  for (const { key, path, artifact } of assets) {
4229
- const target = join12(staging, key);
5046
+ const target = join14(staging, key);
4230
5047
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4231
5048
  yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
4232
5049
  if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
@@ -4240,13 +5057,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4240
5057
  });
4241
5058
  }
4242
5059
  for (const { key, bytes } of documents) {
4243
- const target = join12(staging, key);
5060
+ const target = join14(staging, key);
4244
5061
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4245
5062
  yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
4246
5063
  objects.push(describe(key, bytes, MUTABLE));
4247
5064
  }
4248
5065
  const plan = { schema: 1, base: feed.base, objects };
4249
- yield* step(() => fs.writeFile(join12(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
5066
+ yield* step(() => fs.writeFile(join14(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
4250
5067
  yield* attempt(() => renameExclusive(staging, root));
4251
5068
  return plan;
4252
5069
  }));
@@ -4254,10 +5071,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4254
5071
  return exit.value;
4255
5072
  const error = Cause2.squash(exit.cause);
4256
5073
  const original = error instanceof ReleaseFailure ? error.original ?? error : error;
4257
- const cleanup = yield* Effect20.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
5074
+ const cleanup = yield* Effect21.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
4258
5075
  if (Exit3.isFailure(cleanup)) {
4259
5076
  const cleanupError = Cause2.squash(cleanup.cause);
4260
- return yield* Effect20.fail(new ReleaseFailure({
5077
+ return yield* Effect21.fail(new ReleaseFailure({
4261
5078
  reason: "cleanup",
4262
5079
  message: "Release staging failed and its private temporary tree could not be removed",
4263
5080
  original: new AggregateError([
@@ -4266,8 +5083,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4266
5083
  ], "Release staging failed and its private temporary tree could not be removed", { cause: original })
4267
5084
  }));
4268
5085
  }
4269
- return yield* Effect20.failCause(exit.cause);
4270
- }).pipe(Effect20.uninterruptible);
5086
+ return yield* Effect21.failCause(exit.cause);
5087
+ }).pipe(Effect21.uninterruptible);
4271
5088
  function releaseDocuments(feed, ledger, release) {
4272
5089
  return [
4273
5090
  { key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
@@ -4284,23 +5101,23 @@ function releaseDocuments(feed, ledger, release) {
4284
5101
  }))
4285
5102
  ];
4286
5103
  }
4287
- var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
5104
+ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
4288
5105
  const fs = yield* ReleaseFs;
4289
5106
  const { tag, sourceSha, platform } = options;
4290
5107
  const local = localConfig(options.config);
4291
5108
  const feed = local.feed, now = timestamp2(options.now);
4292
5109
  const payloads = platformPayloads(local.requirements(tag), platform);
4293
5110
  const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
4294
- const directory = resolve8(options.directory);
5111
+ const directory = resolve9(options.directory);
4295
5112
  const names = [...payloads, ...policies.map((policy) => policy.name)];
4296
5113
  yield* exactFiles(directory, names);
4297
- const staged = yield* Effect20.forEach(names, (name) => fileIdentityEffect(join12(directory, name), name), { concurrency: "unbounded" });
5114
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
4298
5115
  for (const policy of policies) {
4299
5116
  const artifact = staged.find((asset) => asset.name === policy.name);
4300
5117
  if (artifact.size > 65536)
4301
5118
  return yield* fail("Signed descriptor is too large");
4302
- const bytes = yield* step(() => fs.readFile(join12(directory, policy.name)));
4303
- if ("sha256:" + createHash8("sha256").update(bytes).digest("hex") !== artifact.digest)
5119
+ const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
5120
+ if ("sha256:" + createHash11("sha256").update(bytes).digest("hex") !== artifact.digest)
4304
5121
  return yield* fail("Signed descriptor changed");
4305
5122
  let parsed;
4306
5123
  try {
@@ -4321,7 +5138,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4321
5138
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest)
4322
5139
  return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
4323
5140
  }
4324
- const [ledger, remote] = yield* Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
5141
+ const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
4325
5142
  const entry = ledger.releases.find((item) => item.tag === tag);
4326
5143
  if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
4327
5144
  return yield* fail("Inconsistent feed release; reconcile publication before retrying");
@@ -4339,7 +5156,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4339
5156
  merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
4340
5157
  uploads.push({
4341
5158
  key: feedAssetKey(feed, tag, artifact.name),
4342
- path: join12(directory, artifact.name),
5159
+ path: join14(directory, artifact.name),
4343
5160
  artifact
4344
5161
  });
4345
5162
  }
@@ -4372,7 +5189,7 @@ function stablePlatforms(config) {
4372
5189
  throw new Error("Invalid stablePlatforms in the release configuration");
4373
5190
  return value;
4374
5191
  }
4375
- var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
5192
+ var verifyLocalReleaseEffect = (options) => Effect21.gen(function* () {
4376
5193
  const local = localConfig(options.config);
4377
5194
  const { release, platforms } = yield* verifyFeedReleaseEffect({
4378
5195
  config: local.config,
@@ -4388,7 +5205,7 @@ var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
4388
5205
  missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
4389
5206
  };
4390
5207
  });
4391
- var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
5208
+ var runLocalPromotionEffect = (options) => Effect21.gen(function* () {
4392
5209
  const local = localConfig(options.config);
4393
5210
  const feed = local.feed;
4394
5211
  const required = stablePlatforms(local.config);
@@ -4446,7 +5263,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4446
5263
  const verification = qualified.get(selected.tag);
4447
5264
  const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
4448
5265
  const entry = ledger.releases.find((item) => item.tag === selected.tag);
4449
- const [currentLedger, remote] = await run(Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
5266
+ const [currentLedger, remote] = await run(Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
4450
5267
  concurrency: "unbounded"
4451
5268
  }));
4452
5269
  if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
@@ -4485,7 +5302,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4485
5302
 
4486
5303
  // src/library/qualification-run.ts
4487
5304
  var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
4488
- var tagRun = (options) => Effect21.gen(function* () {
5305
+ var tagRun = (options) => Effect22.gen(function* () {
4489
5306
  const { tag, sha, runId } = options;
4490
5307
  if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
4491
5308
  return yield* fail(REFUSAL);
@@ -4499,7 +5316,7 @@ var tagRun = (options) => Effect21.gen(function* () {
4499
5316
  runAttempt: 1
4500
5317
  };
4501
5318
  });
4502
- var planQualificationRunEffect = (options) => Effect21.gen(function* () {
5319
+ var planQualificationRunEffect = (options) => Effect22.gen(function* () {
4503
5320
  const { env, config, tag } = options;
4504
5321
  if (env.GITHUB_ACTIONS === "true") {
4505
5322
  const plan = yield* planReleaseAssetsEffect({ env, config, tag });
@@ -4532,8 +5349,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
4532
5349
  ...options.git ? { git: options.git } : {}
4533
5350
  })(planQualificationRunEffect(options)));
4534
5351
  // src/library/retained-build.ts
4535
- import { Effect as Effect22 } from "effect";
4536
- var id = (value) => Effect22.gen(function* () {
5352
+ import { Effect as Effect23 } from "effect";
5353
+ var id = (value) => Effect23.gen(function* () {
4537
5354
  if (typeof value === "number" && !Number.isSafeInteger(value))
4538
5355
  return yield* fail("Invalid GitHub identity");
4539
5356
  const text = String(value);
@@ -4541,7 +5358,7 @@ var id = (value) => Effect22.gen(function* () {
4541
5358
  return yield* fail("Invalid GitHub identity");
4542
5359
  return text;
4543
5360
  });
4544
- var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
5361
+ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
4545
5362
  const { env, config, tag, platform } = options;
4546
5363
  if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
4547
5364
  return yield* fail("Invalid retained build context");
@@ -4659,12 +5476,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
4659
5476
  });
4660
5477
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
4661
5478
  // src/library/staging.ts
4662
- import { createHash as createHash9 } from "crypto";
4663
- import { join as join13, resolve as resolve9 } from "path";
4664
- import { Effect as Effect23 } from "effect";
4665
- var copyHashed = (input, output, size) => Effect23.tryPromise({
5479
+ import { createHash as createHash12 } from "crypto";
5480
+ import { join as join15, resolve as resolve10 } from "path";
5481
+ import { Effect as Effect24 } from "effect";
5482
+ var copyHashed = (input, output, size) => Effect24.tryPromise({
4666
5483
  try: async (signal) => {
4667
- const hash = createHash9("sha256");
5484
+ const hash = createHash12("sha256");
4668
5485
  let copied = 0;
4669
5486
  for await (const chunk of input.createReadStream({
4670
5487
  autoClose: false
@@ -4691,14 +5508,14 @@ var copyHashed = (input, output, size) => Effect23.tryPromise({
4691
5508
  original: error
4692
5509
  })
4693
5510
  });
4694
- var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
5511
+ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
4695
5512
  const fs = yield* ReleaseFs;
4696
5513
  const { expected } = options;
4697
5514
  if (!expected.length || new Set(expected).size !== expected.length || expected.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(name)) || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
4698
5515
  return yield* fail("Staging sources do not match expected filenames");
4699
- const directory = resolve9(options.directory);
5516
+ const directory = resolve10(options.directory);
4700
5517
  const created = [];
4701
- const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
5518
+ const stage = Effect24.forEach(expected, (name) => Effect24.gen(function* () {
4702
5519
  const sourcePath = options.sources[name];
4703
5520
  if (typeof sourcePath !== "string" || !sourcePath)
4704
5521
  return yield* fail("Invalid staging source");
@@ -4709,7 +5526,7 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4709
5526
  const before = yield* step(() => input.stat());
4710
5527
  if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
4711
5528
  return yield* fail("Staging source changed");
4712
- const target = join13(directory, name);
5529
+ const target = join15(directory, name);
4713
5530
  const output = yield* scopedHandle(() => fs.open(target, "wx"));
4714
5531
  created.push(target);
4715
5532
  const copied = yield* copyHashed(input, output, before.size);
@@ -4718,10 +5535,10 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4718
5535
  if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
4719
5536
  return yield* fail("Staging source changed");
4720
5537
  return { name, size: copied.size, digest: copied.digest };
4721
- }).pipe(Effect23.scoped), { concurrency: 1 });
4722
- return yield* stage.pipe(Effect23.onError(() => Effect23.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
5538
+ }).pipe(Effect24.scoped), { concurrency: 1 });
5539
+ return yield* stage.pipe(Effect24.onError(() => Effect24.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
4723
5540
  });
4724
- var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
5541
+ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
4725
5542
  const requirements = parseReleaseConfig(options.config).requirements(options.tag);
4726
5543
  const expected = platformPayloads(requirements, options.platform);
4727
5544
  if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
@@ -4730,13 +5547,13 @@ var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
4730
5547
  });
4731
5548
  var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
4732
5549
  // src/library/steps.ts
4733
- import { join as join33 } from "path";
4734
- import { Effect as Effect24 } from "effect";
5550
+ import { join as join35 } from "path";
5551
+ import { Effect as Effect25 } from "effect";
4735
5552
 
4736
5553
  // ../../src/installer/installer-archive-members.ts
4737
- import { createHash as createHash10 } from "crypto";
4738
- import { lstat as lstat6, open as open5 } from "fs/promises";
4739
- import { isAbsolute as isAbsolute3, relative as relative4, sep as sep2 } from "path";
5554
+ import { createHash as createHash13 } from "crypto";
5555
+ import { lstat as lstat7, open as open5 } from "fs/promises";
5556
+ import { isAbsolute as isAbsolute4, relative as relative4, sep as sep2 } from "path";
4740
5557
 
4741
5558
  // ../../src/installer/native-executable.ts
4742
5559
  async function assertNativeExecutable(file, size, platform, what) {
@@ -4760,7 +5577,7 @@ async function assertNativeExecutable(file, size, platform, what) {
4760
5577
  var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
4761
5578
  function isWithin(root, path) {
4762
5579
  const rel = relative4(root, path);
4763
- return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute3(rel);
5580
+ return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute4(rel);
4764
5581
  }
4765
5582
  function normalizeArchiveMember(name) {
4766
5583
  return name.replace(/^\.\//, "").replaceAll("\\", "/");
@@ -4776,7 +5593,7 @@ function findArchiveMember(entries, expected, platform, message) {
4776
5593
  return found[0];
4777
5594
  }
4778
5595
  async function assertArchiveUnchanged(archive, before, message) {
4779
- const after = await lstat6(archive);
5596
+ const after = await lstat7(archive);
4780
5597
  if (!after.isFile() || after.isSymbolicLink() || !sameFile(after, before))
4781
5598
  throw new Error(message);
4782
5599
  }
@@ -4822,7 +5639,7 @@ async function extractArchiveMember(options) {
4822
5639
  }
4823
5640
  }
4824
5641
  async function assertInstallerExecutable(path, platform) {
4825
- const info = await lstat6(path);
5642
+ const info = await lstat7(path);
4826
5643
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
4827
5644
  throw new Error("Invalid installer executable");
4828
5645
  const file = await open5(path, "r");
@@ -4841,7 +5658,7 @@ async function assertEmbeddedArchive(path, size, archive) {
4841
5658
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
4842
5659
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
4843
5660
  throw new Error("Installer archive marker is missing");
4844
- const hash = createHash10("sha256");
5661
+ const hash = createHash13("sha256");
4845
5662
  let read = 0;
4846
5663
  for await (const chunk of file.createReadStream({
4847
5664
  start: position + marker.length,
@@ -4858,23 +5675,23 @@ async function assertEmbeddedArchive(path, size, archive) {
4858
5675
  }
4859
5676
 
4860
5677
  // ../../src/installer/installer-identity.ts
4861
- import { lstat as lstat8, mkdtemp as mkdtemp4, readdir as readdir6, realpath } from "fs/promises";
5678
+ import { lstat as lstat9, mkdtemp as mkdtemp4, readdir as readdir7, realpath as realpath2 } from "fs/promises";
4862
5679
  import { tmpdir as tmpdir4 } from "os";
4863
- import { basename as basename5, join as join15, resolve as resolve10, win32 } from "path";
5680
+ import { basename as basename5, join as join17, resolve as resolve11, win32 } from "path";
4864
5681
 
4865
5682
  // ../../src/installer/installer-image-mount.ts
4866
- import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir5, rm as rm4, stat } from "fs/promises";
4867
- import { dirname as dirname3, join as join14 } from "path";
5683
+ import { lstat as lstat8, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir6, rm as rm4, stat } from "fs/promises";
5684
+ import { dirname as dirname3, join as join16 } from "path";
4868
5685
  var FAILED_ATTACH_PROBES = 5;
4869
5686
  var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
4870
5687
  async function containsMountAt(path, expectedDevice) {
4871
- const info = await lstat7(path);
5688
+ const info = await lstat8(path);
4872
5689
  if (!info.isDirectory() || info.isSymbolicLink())
4873
5690
  return false;
4874
5691
  if (info.dev !== expectedDevice)
4875
5692
  return true;
4876
- for (const name of await readdir5(path)) {
4877
- const child = join14(path, name), childInfo = await lstat7(child);
5693
+ for (const name of await readdir6(path)) {
5694
+ const child = join16(path, name), childInfo = await lstat8(child);
4878
5695
  if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
4879
5696
  continue;
4880
5697
  if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
@@ -5068,8 +5885,8 @@ async function withInstallerImageRetries(options) {
5068
5885
  };
5069
5886
  const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
5070
5887
  for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
5071
- const directory = await mkdtemp3(join14(options.parent, options.prefix));
5072
- const mount = join14(directory, "mount");
5888
+ const directory = await mkdtemp3(join16(options.parent, options.prefix));
5889
+ const mount = join16(directory, "mount");
5073
5890
  const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
5074
5891
  let lifecycleStarted = false;
5075
5892
  try {
@@ -5237,7 +6054,7 @@ async function runInstallerCommand(args, env, options) {
5237
6054
 
5238
6055
  // ../../src/installer/installer-identity.ts
5239
6056
  async function identity(path) {
5240
- const info = await lstat8(path);
6057
+ const info = await lstat9(path);
5241
6058
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
5242
6059
  throw new Error("Invalid installer artifact");
5243
6060
  const { size, sha256 } = await hashFileAt(path, info, "Installer artifact changed");
@@ -5264,12 +6081,12 @@ async function verifyInstallerPayload(options) {
5264
6081
  else
5265
6082
  assertInstallerContext(parent, options.platform, process.platform, process.arch);
5266
6083
  assertPortableAppName(options.appName);
5267
- const installerPath = resolve10(options.installer), archivePath = resolve10(options.archive);
6084
+ const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
5268
6085
  const before = { installer: await identity(installerPath), archive: await identity(archivePath) };
5269
6086
  if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
5270
6087
  throw new Error("Installer archive exceeds bound");
5271
6088
  const env = environment(parent);
5272
- const temporary = await mkdtemp4(join15(tmpdir4(), "framework-installer-inspect-"));
6089
+ const temporary = await mkdtemp4(join17(tmpdir4(), "framework-installer-inspect-"));
5273
6090
  const cleanupIo = defaultInstallerImageMountIo(command);
5274
6091
  try {
5275
6092
  if (options.platform === "macos-arm64") {
@@ -5280,24 +6097,24 @@ async function verifyInstallerPayload(options) {
5280
6097
  env,
5281
6098
  run: command,
5282
6099
  work: async (mount) => {
5283
- const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
6100
+ const apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
5284
6101
  if (apps.length !== 1)
5285
6102
  throw new Error("Installer application is missing or ambiguous");
5286
- const resources = join15(mount, apps[0], "Contents", "Resources");
5287
- const actualRoot = await realpath(mount), actualApp = await realpath(join15(mount, apps[0])), actualResources = await realpath(resources);
6103
+ const resources = join17(mount, apps[0], "Contents", "Resources");
6104
+ const actualRoot = await realpath2(mount), actualApp = await realpath2(join17(mount, apps[0])), actualResources = await realpath2(resources);
5288
6105
  if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
5289
6106
  throw new Error("Installer resources escape mounted image");
5290
- const plist = join15(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
6107
+ const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
5291
6108
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5292
6109
  throw new Error("Invalid installer property list");
5293
6110
  const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
5294
6111
  if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
5295
6112
  throw new Error("Invalid installer executable name");
5296
- await assertInstallerExecutable(join15(actualApp, "Contents", "MacOS", executable), options.platform);
5297
- const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
6113
+ await assertInstallerExecutable(join17(actualApp, "Contents", "MacOS", executable), options.platform);
6114
+ const archives = (await readdir7(actualResources)).filter((name) => name.endsWith(".tar.zst"));
5298
6115
  if (archives.length !== 1)
5299
6116
  throw new Error("Installer archive is missing or ambiguous");
5300
- const embedded = await identity(join15(actualResources, archives[0]));
6117
+ const embedded = await identity(join17(actualResources, archives[0]));
5301
6118
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
5302
6119
  throw new Error("Installer archive differs from release archive");
5303
6120
  }
@@ -5315,7 +6132,7 @@ async function verifyInstallerPayload(options) {
5315
6132
  const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
5316
6133
  if (matches.length !== 1)
5317
6134
  throw new Error("Installer archive is missing or ambiguous");
5318
- const extracted = join15(temporary, "member");
6135
+ const extracted = join17(temporary, "member");
5319
6136
  const count = await extractArchiveMember({
5320
6137
  tar,
5321
6138
  archive: installerPath,
@@ -5326,7 +6143,7 @@ async function verifyInstallerPayload(options) {
5326
6143
  });
5327
6144
  if (options.platform === "windows-x64") {
5328
6145
  const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
5329
- const executable = join15(temporary, "setup.exe");
6146
+ const executable = join17(temporary, "setup.exe");
5330
6147
  await extractArchiveMember({
5331
6148
  tar,
5332
6149
  archive: installerPath,
@@ -5362,19 +6179,19 @@ async function verifyInstallerPayload(options) {
5362
6179
  }
5363
6180
 
5364
6181
  // ../../src/installer/installer-qualification-command.ts
5365
- import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
5366
- import { join as join30, resolve as resolve13 } from "path";
6182
+ import { lstat as lstat19, writeFile as writeFile9 } from "fs/promises";
6183
+ import { join as join32, resolve as resolve14 } from "path";
5367
6184
 
5368
6185
  // ../../src/installer/installer-observation.ts
5369
- import { randomBytes as randomBytes2 } from "crypto";
5370
- import { chmod as chmod2, mkdir as mkdir9, readFile as readFile9, realpath as realpath8, writeFile as writeFile8 } from "fs/promises";
6186
+ import { randomBytes as randomBytes3 } from "crypto";
6187
+ import { chmod as chmod2, mkdir as mkdir9, readFile as readFile10, realpath as realpath9, writeFile as writeFile8 } from "fs/promises";
5371
6188
  import { createServer } from "net";
5372
- import { delimiter, dirname as dirname12, join as join29 } from "path";
6189
+ import { delimiter, dirname as dirname12, join as join31 } from "path";
5373
6190
 
5374
6191
  // ../../src/installer/installer-ci-bootstrap.ts
5375
- import { randomBytes } from "crypto";
5376
- import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
5377
- import { dirname as dirname4, isAbsolute as isAbsolute4, join as join16, relative as relative5, sep as sep3 } from "path";
6192
+ import { randomBytes as randomBytes2 } from "crypto";
6193
+ import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath3, rm as rm5, writeFile as writeFile4 } from "fs/promises";
6194
+ import { dirname as dirname4, isAbsolute as isAbsolute5, join as join18, relative as relative5, sep as sep3 } from "path";
5378
6195
  import { fileURLToPath } from "url";
5379
6196
  var bootstrapModules = [
5380
6197
  "app/value-guards.js",
@@ -5397,27 +6214,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5397
6214
  const temp = runnerTemp(env);
5398
6215
  if (!isHostedRunner(env) || !temp)
5399
6216
  throw new Error("Installer bootstrap requires a disposable hosted runner");
5400
- const parent = await realpath2(temp);
5401
- if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
6217
+ const parent = await realpath3(temp);
6218
+ if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
5402
6219
  throw new Error("Runner temp cannot represent a Bun preload path");
5403
6220
  const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
5404
- const directory = await mkdtemp5(join16(parent, "framework-ci-"));
6221
+ const directory = await mkdtemp5(join18(parent, "framework-ci-"));
5405
6222
  try {
5406
6223
  for (const name of bootstrapModules) {
5407
- const contents = await readBoundedFile(join16(source, name), 2 * 1024 * 1024, "installer bootstrap module");
5408
- await mkdir5(dirname4(join16(directory, name)), { recursive: true, mode: 448 });
5409
- await writeFile4(join16(directory, name), contents, { flag: "wx", mode: 384 });
6224
+ const contents = await readBoundedFile(join18(source, name), 2 * 1024 * 1024, "installer bootstrap module");
6225
+ await mkdir5(dirname4(join18(directory, name)), { recursive: true, mode: 448 });
6226
+ await writeFile4(join18(directory, name), contents, { flag: "wx", mode: 384 });
5410
6227
  }
5411
- await writeFile4(join16(directory, "package.json"), `{"type":"module"}
6228
+ await writeFile4(join18(directory, "package.json"), `{"type":"module"}
5412
6229
  `, {
5413
6230
  flag: "wx",
5414
6231
  mode: 384
5415
6232
  });
5416
- const worker = join16(directory, "installer/installer-ci-worker.js");
6233
+ const worker = join18(directory, "installer/installer-ci-worker.js");
5417
6234
  return {
5418
6235
  directory,
5419
6236
  worker,
5420
- preflight: join16(directory, "installer/installer-ci-preflight.js"),
6237
+ preflight: join18(directory, "installer/installer-ci-preflight.js"),
5421
6238
  bunOptions: `--preload=${worker}`
5422
6239
  };
5423
6240
  } catch (error) {
@@ -5428,11 +6245,11 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5428
6245
  async function preflightInstallerRuntime(options) {
5429
6246
  const { env, runtime, bootstrap } = options;
5430
6247
  const temp = runnerTemp(env);
5431
- if (!isHostedRunner(env) || !temp || !isAbsolute4(runtime))
6248
+ if (!isHostedRunner(env) || !temp || !isAbsolute5(runtime))
5432
6249
  throw new Error("Runtime preflight requires a disposable hosted runner");
5433
- const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
6250
+ const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
5434
6251
  const relativeBootstrap = relative5(tempRoot, bootstrapRoot);
5435
- if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join16(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join16(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
6252
+ 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}`)
5436
6253
  throw new Error("Invalid installer bootstrap location");
5437
6254
  await runInstallerPreflight({
5438
6255
  env,
@@ -5445,14 +6262,14 @@ async function preflightInstallerRuntime(options) {
5445
6262
  async function runInstallerPreflight(options) {
5446
6263
  const { env, runtime, worker, preflight } = options;
5447
6264
  for (const path of [worker, preflight]) {
5448
- const item = await lstat9(path);
6265
+ const item = await lstat10(path);
5449
6266
  if (!item.isFile() || item.isSymbolicLink())
5450
6267
  throw new Error("Invalid installer bootstrap module");
5451
6268
  }
5452
- const info = await lstat9(runtime);
6269
+ const info = await lstat10(runtime);
5453
6270
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
5454
6271
  throw new Error("Invalid candidate Bun runtime");
5455
- const temporary = await mkdtemp5(join16(options.parent, "framework-preflight-"));
6272
+ const temporary = await mkdtemp5(join18(options.parent, "framework-preflight-"));
5456
6273
  try {
5457
6274
  const clean = {};
5458
6275
  for (const key of [
@@ -5469,7 +6286,7 @@ async function runInstallerPreflight(options) {
5469
6286
  ])
5470
6287
  if (env[key])
5471
6288
  clean[key] = env[key];
5472
- const nonce = randomBytes(24).toString("hex");
6289
+ const nonce = randomBytes2(24).toString("hex");
5473
6290
  Object.assign(clean, {
5474
6291
  CI: "true",
5475
6292
  GITHUB_ACTIONS: "true",
@@ -5477,11 +6294,11 @@ async function runInstallerPreflight(options) {
5477
6294
  BUN_OPTIONS: `--preload=${worker}`,
5478
6295
  FRAMEWORK_CI_WORKER_ENTRY: preflight,
5479
6296
  FRAMEWORK_CI_NONCE: nonce,
5480
- FRAMEWORK_CI_ACK: join16(temporary, "ack"),
5481
- FRAMEWORK_CI_PERMIT: join16(temporary, "permit"),
6297
+ FRAMEWORK_CI_ACK: join18(temporary, "ack"),
6298
+ FRAMEWORK_CI_PERMIT: join18(temporary, "permit"),
5482
6299
  FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
5483
- FRAMEWORK_CI_OBSERVATION: join16(temporary, "observation"),
5484
- FRAMEWORK_CI_UNEXPECTED: join16(temporary, "unexpected"),
6300
+ FRAMEWORK_CI_OBSERVATION: join18(temporary, "observation"),
6301
+ FRAMEWORK_CI_UNEXPECTED: join18(temporary, "unexpected"),
5485
6302
  FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
5486
6303
  "https://example.invalid/framework-ci-sentinel"
5487
6304
  ])
@@ -5516,7 +6333,7 @@ async function runInstallerPreflight(options) {
5516
6333
  if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
5517
6334
  throw new Error("Candidate Bun runtime failed installer preflight");
5518
6335
  try {
5519
- await lstat9(join16(temporary, "unexpected"));
6336
+ await lstat10(join18(temporary, "unexpected"));
5520
6337
  throw new Error("Runtime preflight recorded unexpected activity");
5521
6338
  } catch (error) {
5522
6339
  if (errorCode(error) !== "ENOENT")
@@ -5528,8 +6345,8 @@ async function runInstallerPreflight(options) {
5528
6345
  }
5529
6346
 
5530
6347
  // ../../src/installer/installer-extraction.ts
5531
- import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir7, realpath as realpath3 } from "fs/promises";
5532
- import { join as join17, resolve as resolve11, win32 as win322 } from "path";
6348
+ import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir8, realpath as realpath4 } from "fs/promises";
6349
+ import { join as join19, resolve as resolve12, win32 as win322 } from "path";
5533
6350
  async function run(cmd, env) {
5534
6351
  return runInstallerCommand(cmd, env, {
5535
6352
  outputLimit: 8 * 1024 * 1024,
@@ -5537,8 +6354,8 @@ async function run(cmd, env) {
5537
6354
  failureMessage: "Installer preparation command failed"
5538
6355
  });
5539
6356
  }
5540
- async function digest2(path) {
5541
- const info = await lstat10(path);
6357
+ async function digest3(path) {
6358
+ const info = await lstat11(path);
5542
6359
  if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
5543
6360
  throw new Error("Invalid extracted file");
5544
6361
  const { size, sha256 } = await hashFileAt(path, info, "Extracted file changed");
@@ -5572,8 +6389,8 @@ async function prepareInstallerExecution(options) {
5572
6389
  const temp = runnerTemp(env);
5573
6390
  if (!temp)
5574
6391
  throw new Error("Missing runner temp directory");
5575
- const parent = await realpath3(temp), sourceInstaller = resolve11(options.installer), sourceArchive = resolve11(options.archive);
5576
- if (!(await lstat10(parent)).isDirectory())
6392
+ const parent = await realpath4(temp), sourceInstaller = resolve12(options.installer), sourceArchive = resolve12(options.archive);
6393
+ if (!(await lstat11(parent)).isDirectory())
5577
6394
  throw new Error("Invalid runner temp directory");
5578
6395
  const verified = await verifyInstallerPayload({
5579
6396
  ...options,
@@ -5581,10 +6398,10 @@ async function prepareInstallerExecution(options) {
5581
6398
  archive: sourceArchive,
5582
6399
  env
5583
6400
  });
5584
- const directory = await mkdtemp6(join17(parent, "framework-installer-"));
6401
+ const directory = await mkdtemp6(join19(parent, "framework-installer-"));
5585
6402
  const imageIo = defaultInstallerImageMountIo(run);
5586
6403
  try {
5587
- const profile = join17(directory, "profile"), incoming = join17(directory, "incoming");
6404
+ const profile = join19(directory, "profile"), incoming = join19(directory, "incoming");
5588
6405
  await mkdir6(profile, { mode: 448 });
5589
6406
  await mkdir6(incoming, { mode: 448 });
5590
6407
  const clean = cleanEnv(env);
@@ -5597,34 +6414,34 @@ async function prepareInstallerExecution(options) {
5597
6414
  env: clean,
5598
6415
  run,
5599
6416
  work: async (mount) => {
5600
- const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
6417
+ const appName = `${options.appName}.app`, apps = (await readdir8(mount)).filter((name) => name.endsWith(".app"));
5601
6418
  if (apps.length !== 1 || apps[0] !== appName)
5602
6419
  throw new Error("Unexpected installer application");
5603
- const sourceApp = await realpath3(join17(mount, appName)), mountRoot = await realpath3(mount);
6420
+ const sourceApp = await realpath4(join19(mount, appName)), mountRoot = await realpath4(mount);
5604
6421
  if (!isWithin(mountRoot, sourceApp))
5605
6422
  throw new Error("Installer application escapes image");
5606
- const app = join17(incoming, appName);
6423
+ const app = join19(incoming, appName);
5607
6424
  await run(["/usr/bin/ditto", sourceApp, app], clean);
5608
- const actualApp = await realpath3(app), resources = await realpath3(join17(actualApp, "Contents", "Resources"));
5609
- if (!isWithin(await realpath3(incoming), actualApp) || !isWithin(actualApp, resources))
6425
+ const actualApp = await realpath4(app), resources = await realpath4(join19(actualApp, "Contents", "Resources"));
6426
+ if (!isWithin(await realpath4(incoming), actualApp) || !isWithin(actualApp, resources))
5610
6427
  throw new Error("Copied installer escapes profile");
5611
- const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
6428
+ const plist = join19(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
5612
6429
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5613
6430
  throw new Error("Invalid installer property list");
5614
6431
  const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
5615
6432
  if (!name || name === "." || name === ".." || /[\\/]/.test(name))
5616
6433
  throw new Error("Invalid installer executable");
5617
- const appExecutable = join17(actualApp, "Contents", "MacOS", name);
5618
- const sourceExecutable = join17(sourceApp, "Contents", "MacOS", name);
5619
- if (!isWithin(actualApp, await realpath3(appExecutable)) || !isWithin(sourceApp, await realpath3(sourceExecutable)))
6434
+ const appExecutable = join19(actualApp, "Contents", "MacOS", name);
6435
+ const sourceExecutable = join19(sourceApp, "Contents", "MacOS", name);
6436
+ if (!isWithin(actualApp, await realpath4(appExecutable)) || !isWithin(sourceApp, await realpath4(sourceExecutable)))
5620
6437
  throw new Error("Installer executable escapes application");
5621
6438
  await assertInstallerExecutable(appExecutable, options.platform);
5622
- if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
6439
+ if (JSON.stringify(await digest3(sourceExecutable)) !== JSON.stringify(await digest3(appExecutable)))
5623
6440
  throw new Error("Copied installer executable differs");
5624
- const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
6441
+ const archives = (await readdir8(resources)).filter((value) => value.endsWith(".tar.zst"));
5625
6442
  if (archives.length !== 1)
5626
6443
  throw new Error("Missing installer archive");
5627
- const embedded = await digest2(join17(resources, archives[0]));
6444
+ const embedded = await digest3(join19(resources, archives[0]));
5628
6445
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5629
6446
  throw new Error("Copied installer archive differs");
5630
6447
  return executable;
@@ -5639,9 +6456,9 @@ async function prepareInstallerExecution(options) {
5639
6456
  assertInstallerLayout(options.platform, options.appName, names);
5640
6457
  const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
5641
6458
  if (options.platform === "windows-x64") {
5642
- const subdirectory = join17(incoming, ".installer");
6459
+ const subdirectory = join19(incoming, ".installer");
5643
6460
  await mkdir6(subdirectory);
5644
- executable = join17(incoming, `${options.appName}-Setup.exe`);
6461
+ executable = join19(incoming, `${options.appName}-Setup.exe`);
5645
6462
  await extractArchiveMember({
5646
6463
  tar,
5647
6464
  archive: sourceInstaller,
@@ -5655,11 +6472,11 @@ async function prepareInstallerExecution(options) {
5655
6472
  tar,
5656
6473
  archive: sourceInstaller,
5657
6474
  member: find(`.installer/${options.appName}-Setup.metadata.json`),
5658
- destination: join17(subdirectory, `${options.appName}-Setup.metadata.json`),
6475
+ destination: join19(subdirectory, `${options.appName}-Setup.metadata.json`),
5659
6476
  maximum: 1024 * 1024,
5660
6477
  env: clean
5661
6478
  });
5662
- const embeddedPath = join17(subdirectory, `${options.appName}-Setup.tar.zst`);
6479
+ const embeddedPath = join19(subdirectory, `${options.appName}-Setup.tar.zst`);
5663
6480
  await extractArchiveMember({
5664
6481
  tar,
5665
6482
  archive: sourceInstaller,
@@ -5668,11 +6485,11 @@ async function prepareInstallerExecution(options) {
5668
6485
  maximum: verified.archive.size,
5669
6486
  env: clean
5670
6487
  });
5671
- const embedded = await digest2(embeddedPath);
6488
+ const embedded = await digest3(embeddedPath);
5672
6489
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5673
6490
  throw new Error("Copied installer archive differs");
5674
6491
  } else {
5675
- executable = join17(incoming, "installer");
6492
+ executable = join19(incoming, "installer");
5676
6493
  await extractArchiveMember({
5677
6494
  tar,
5678
6495
  archive: sourceInstaller,
@@ -5682,7 +6499,7 @@ async function prepareInstallerExecution(options) {
5682
6499
  env: clean
5683
6500
  });
5684
6501
  await assertInstallerExecutable(executable, options.platform);
5685
- await assertEmbeddedArchive(executable, (await lstat10(executable)).size, verified.archive);
6502
+ await assertEmbeddedArchive(executable, (await lstat11(executable)).size, verified.archive);
5686
6503
  await chmod(executable, 448);
5687
6504
  }
5688
6505
  }
@@ -5728,10 +6545,10 @@ function assertInstallerRendererObservation(value, offline = false) {
5728
6545
  }
5729
6546
 
5730
6547
  // ../../src/installer/installed-payload.ts
5731
- import { createHash as createHash11 } from "crypto";
5732
- import { lstat as lstat11, open as open6, realpath as realpath4, rm as rm6 } from "fs/promises";
6548
+ import { createHash as createHash14 } from "crypto";
6549
+ import { lstat as lstat12, open as open6, realpath as realpath5, rm as rm6 } from "fs/promises";
5733
6550
  import { once } from "events";
5734
- import { join as join18, resolve as resolve12 } from "path";
6551
+ import { join as join20, resolve as resolve13 } from "path";
5735
6552
  import { createZstdDecompress } from "zlib";
5736
6553
  import { Parser } from "tar";
5737
6554
  function cleanEnv2(parent, forceLocal) {
@@ -5754,7 +6571,7 @@ async function command2(args, env, limit, collect) {
5754
6571
  const errors = (async () => {
5755
6572
  for await (const _part of child.stderr) {}
5756
6573
  })();
5757
- const hash = createHash11("sha256"), chunks = [];
6574
+ const hash = createHash14("sha256"), chunks = [];
5758
6575
  let size = 0;
5759
6576
  try {
5760
6577
  for await (const part of child.stdout) {
@@ -5777,7 +6594,7 @@ async function command2(args, env, limit, collect) {
5777
6594
  }
5778
6595
  }
5779
6596
  async function listArchive(archive, platform, env) {
5780
- const archiveInfo = await lstat11(archive);
6597
+ const archiveInfo = await lstat12(archive);
5781
6598
  if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1)
5782
6599
  throw new Error("Invalid staged archive");
5783
6600
  const version = await command2(["tar", "--version"], cleanEnv2(env, false), 65536, true);
@@ -5808,7 +6625,7 @@ async function readMembers(archive, limits, collect) {
5808
6625
  failure ??= new Error("Archive member missing or ambiguous");
5809
6626
  return entry.resume();
5810
6627
  }
5811
- const hash = createHash11("sha256"), chunks = [];
6628
+ const hash = createHash14("sha256"), chunks = [];
5812
6629
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
5813
6630
  members.set(entry.path, member);
5814
6631
  entry.on("data", (chunk) => {
@@ -5846,14 +6663,14 @@ async function readMembers(archive, limits, collect) {
5846
6663
  return members;
5847
6664
  }
5848
6665
  async function installed(path, root, limit) {
5849
- const info = await lstat11(path);
5850
- if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await realpath4(path)))
6666
+ const info = await lstat12(path);
6667
+ if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1 || info.size > limit || !isWithin(root, await realpath5(path)))
5851
6668
  throw new Error("Invalid installed file");
5852
6669
  const { size, sha256 } = await hashFileAt(path, info, "Installed file changed");
5853
6670
  return { digest: sha256, size };
5854
6671
  }
5855
6672
  async function assertRuntimeBinary(path, platform) {
5856
- const info = await lstat11(path), file = await open6(path, "r");
6673
+ const info = await lstat12(path), file = await open6(path, "r");
5857
6674
  try {
5858
6675
  await assertNativeExecutable(file, info.size, platform, "runtime executable");
5859
6676
  } finally {
@@ -5867,8 +6684,8 @@ async function verifyInstalledPayload(options) {
5867
6684
  const sidecars = assertSidecarNames(options.sidecars ?? [], options.platform).map((name) => sidecarBundlePath(name, options.platform));
5868
6685
  if (!/^\d+\.\d+\.\d+$/.test(options.version) || options.version.length > 64)
5869
6686
  throw new Error("Invalid installed version");
5870
- const profile = await realpath4(options.profile), root = await realpath4(options.installedRoot), archive = resolve12(options.archive);
5871
- if (!(await lstat11(profile)).isDirectory() || !(await lstat11(root)).isDirectory() || !isWithin(profile, root))
6687
+ const profile = await realpath5(options.profile), root = await realpath5(options.installedRoot), archive = resolve13(options.archive);
6688
+ if (!(await lstat12(profile)).isDirectory() || !(await lstat12(root)).isDirectory() || !isWithin(profile, root))
5872
6689
  throw new Error("Installed root escapes isolated profile");
5873
6690
  const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
5874
6691
  assertPayloadLayout({
@@ -5902,7 +6719,7 @@ async function verifyInstalledPayload(options) {
5902
6719
  const member = members.get(path);
5903
6720
  if (!member || member.count !== 1)
5904
6721
  throw new Error("Archive member missing or ambiguous");
5905
- const current = await installed(join18(root, name), root, limit);
6722
+ const current = await installed(join20(root, name), root, limit);
5906
6723
  if (member.size !== current.size || member.digest !== current.digest)
5907
6724
  throw new Error(`Installed file differs from archive: ${name}`);
5908
6725
  if (name === "Resources/version.json") {
@@ -5924,8 +6741,8 @@ async function extractCandidateRuntime(options) {
5924
6741
  const temp = runnerTemp(env);
5925
6742
  if (!temp)
5926
6743
  throw new Error("Missing runner temp directory");
5927
- const tempRoot = await realpath4(temp), profile = await realpath4(options.profile), archive = resolve12(options.archive);
5928
- if (!isWithin(tempRoot, profile) || !(await lstat11(profile)).isDirectory())
6744
+ const tempRoot = await realpath5(temp), profile = await realpath5(options.profile), archive = resolve13(options.archive);
6745
+ if (!isWithin(tempRoot, profile) || !(await lstat12(profile)).isDirectory())
5929
6746
  throw new Error("Runtime profile escapes runner temp");
5930
6747
  const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
5931
6748
  assertPayloadLayout({
@@ -5937,7 +6754,7 @@ async function extractCandidateRuntime(options) {
5937
6754
  const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
5938
6755
  const expected = `${prefix}/bun${suffix}`;
5939
6756
  const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
5940
- const destination = join18(profile, `candidate-bun${suffix}`), output = await open6(destination, "wx", 448);
6757
+ const destination = join20(profile, `candidate-bun${suffix}`), output = await open6(destination, "wx", 448);
5941
6758
  const spawn = () => Bun.spawn({
5942
6759
  cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
5943
6760
  env: tarEnv,
@@ -5950,7 +6767,7 @@ async function extractCandidateRuntime(options) {
5950
6767
  const child = spawn(), errors = (async () => {
5951
6768
  for await (const _part of child.stderr) {}
5952
6769
  })();
5953
- const hash = createHash11("sha256");
6770
+ const hash = createHash14("sha256");
5954
6771
  let size = 0;
5955
6772
  try {
5956
6773
  for await (const part of child.stdout) {
@@ -5993,8 +6810,8 @@ async function extractCandidateRuntime(options) {
5993
6810
 
5994
6811
  // ../../src/installer/installer-process-cleanup.ts
5995
6812
  import { execFile as execFile2 } from "child_process";
5996
- import { realpath as realpath5 } from "fs/promises";
5997
- import { promisify } from "util";
6813
+ import { realpath as realpath6 } from "fs/promises";
6814
+ import { promisify as promisify2 } from "util";
5998
6815
 
5999
6816
  // ../../src/native/windows-process.ts
6000
6817
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
@@ -6038,7 +6855,7 @@ function windowsProcessImage(pid, options) {
6038
6855
  }
6039
6856
 
6040
6857
  // ../../src/installer/installer-process-cleanup.ts
6041
- var execute = promisify(execFile2);
6858
+ var execute = promisify2(execFile2);
6042
6859
  async function terminateGuardedWorker(options) {
6043
6860
  const { pid, runtime, platform } = options;
6044
6861
  assertInstallerContext(options.env, platform, process.platform, process.arch);
@@ -6059,7 +6876,7 @@ async function terminateGuardedWorker(options) {
6059
6876
  ])
6060
6877
  if (options.env[name])
6061
6878
  env[name] = options.env[name];
6062
- const expected = await realpath5(runtime);
6879
+ const expected = await realpath6(runtime);
6063
6880
  const actual = await runningExecutable(pid, platform, env);
6064
6881
  if (actual === undefined)
6065
6882
  return;
@@ -6110,7 +6927,7 @@ async function readMacosState(pid, env) {
6110
6927
  }
6111
6928
  async function runningExecutable(pid, platform, env) {
6112
6929
  if (platform === "linux-x64" || platform === "linux-arm64")
6113
- return realpath5(`/proc/${pid}/exe`).catch((error) => {
6930
+ return realpath6(`/proc/${pid}/exe`).catch((error) => {
6114
6931
  if (error.code === "ENOENT")
6115
6932
  return;
6116
6933
  throw error;
@@ -6128,7 +6945,7 @@ async function runningExecutable(pid, platform, env) {
6128
6945
  if (!listed)
6129
6946
  return;
6130
6947
  const state = macosProcess(listed.stdout);
6131
- return state === EXITING || state === undefined ? state : realpath5(state);
6948
+ return state === EXITING || state === undefined ? state : realpath6(state);
6132
6949
  }
6133
6950
  return windowsRunningExecutable(pid);
6134
6951
  }
@@ -6139,12 +6956,12 @@ async function windowsRunningExecutable(pid) {
6139
6956
  } catch (error) {
6140
6957
  throw new Error("Unable to query guarded process executable", { cause: error });
6141
6958
  }
6142
- return image === "missing" ? undefined : realpath5(image);
6959
+ return image === "missing" ? undefined : realpath6(image);
6143
6960
  }
6144
6961
 
6145
6962
  // ../../src/updates/install/update-swap-stage.ts
6146
- import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
6147
- import { join as join28 } from "path";
6963
+ import { lstat as lstat18, mkdtemp as mkdtemp8, readFile as readFile9, realpath as realpath8, rm as rm8 } from "fs/promises";
6964
+ import { join as join30 } from "path";
6148
6965
 
6149
6966
  // ../../src/updates/install/update-handoff-plan.ts
6150
6967
  import { basename as basename6 } from "path";
@@ -6183,10 +7000,10 @@ function planUpdateHandoff(options) {
6183
7000
  }
6184
7001
 
6185
7002
  // ../../src/updates/install/update-extraction.ts
6186
- import { createHash as createHash12 } from "crypto";
7003
+ import { createHash as createHash15 } from "crypto";
6187
7004
  import { constants as constants4 } from "fs";
6188
- import { lstat as lstat12, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open7, readFile as readFile6, realpath as realpath6, rm as rm7, symlink } from "fs/promises";
6189
- import { isAbsolute as isAbsolute5, join as join19 } from "path";
7005
+ import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open7, readFile as readFile7, realpath as realpath7, rm as rm7, symlink } from "fs/promises";
7006
+ import { isAbsolute as isAbsolute6, join as join21 } from "path";
6190
7007
  import { Transform } from "stream";
6191
7008
  import { pipeline } from "stream/promises";
6192
7009
  import { createZstdDecompress as createZstdDecompress2 } from "zlib";
@@ -6215,12 +7032,12 @@ async function extractVerifiedUpdate(options) {
6215
7032
  "linux-x64": ["linux", "x64"],
6216
7033
  "linux-arm64": ["linux", "arm64"]
6217
7034
  };
6218
- if (!isVerifiedRelease(descriptor) || !expected[platform] || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || !isAbsolute5(archive) || !isAbsolute5(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || descriptor.asset.size > maxCompressedBytes || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
7035
+ 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)
6219
7036
  throw new Error("Invalid update extraction context");
6220
7037
  assertPortableAppName(appName);
6221
7038
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
6222
7039
  const archiveRoot = platform === "macos-arm64" ? `${appName}.app` : appName.replaceAll(" ", "");
6223
- const info = await lstat12(archive);
7040
+ const info = await lstat13(archive);
6224
7041
  if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
6225
7042
  throw new Error("Invalid update archive");
6226
7043
  const file = await open7(archive, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
@@ -6229,11 +7046,11 @@ async function extractVerifiedUpdate(options) {
6229
7046
  const before = await file.stat();
6230
7047
  if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || !await verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor))
6231
7048
  throw new Error("Update archive verification failed");
6232
- const parent = await realpath6(options.directory);
6233
- if (!(await lstat12(parent)).isDirectory())
7049
+ const parent = await realpath7(options.directory);
7050
+ if (!(await lstat13(parent)).isDirectory())
6234
7051
  throw new Error("Invalid update staging directory");
6235
- directory = await mkdtemp7(join19(parent, "framework-update-extract-"));
6236
- const payloadRoot = join19(directory, "payload"), decompressed = join19(directory, "payload.tar");
7052
+ directory = await mkdtemp7(join21(parent, "framework-update-extract-"));
7053
+ const payloadRoot = join21(directory, "payload"), decompressed = join21(directory, "payload.tar");
6237
7054
  await mkdir7(payloadRoot, { mode: 448 });
6238
7055
  const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
6239
7056
  let invalid = false;
@@ -6251,7 +7068,7 @@ async function extractVerifiedUpdate(options) {
6251
7068
  done(null, chunk);
6252
7069
  }
6253
7070
  });
6254
- const hash = createHash12("sha256");
7071
+ const hash = createHash15("sha256");
6255
7072
  let compressedBytes = 0;
6256
7073
  const verifyInput = new Transform({
6257
7074
  transform(chunk, _encoding, done) {
@@ -6351,14 +7168,14 @@ async function extractVerifiedUpdate(options) {
6351
7168
  if (invalid)
6352
7169
  throw new Error("Unsafe or unsupported update archive entry");
6353
7170
  if (links.length) {
6354
- const bin = join19(payloadRoot, archiveRoot, "bin"), cef = join19(bin, "cef");
6355
- for (const path of [join19(payloadRoot, archiveRoot), bin, cef]) {
6356
- const value = await lstat12(path);
7171
+ const bin = join21(payloadRoot, archiveRoot, "bin"), cef = join21(bin, "cef");
7172
+ for (const path of [join21(payloadRoot, archiveRoot), bin, cef]) {
7173
+ const value = await lstat13(path);
6357
7174
  if (!value.isDirectory() || value.isSymbolicLink())
6358
7175
  throw new Error("Invalid CEF link directory");
6359
7176
  }
6360
7177
  for (const link of links) {
6361
- const destination = join19(payloadRoot, link.path), target = join19(bin, link.target), value = await lstat12(target);
7178
+ const destination = join21(payloadRoot, link.path), target = join21(bin, link.target), value = await lstat13(target);
6362
7179
  if (!value.isFile() || value.isSymbolicLink())
6363
7180
  throw new Error("Invalid CEF link target");
6364
7181
  await symlink(link.target, destination);
@@ -6366,12 +7183,12 @@ async function extractVerifiedUpdate(options) {
6366
7183
  }
6367
7184
  await rm7(decompressed);
6368
7185
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
6369
- const prefix = platform === "macos-arm64" ? join19(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
6370
- const resources = join19(payloadRoot, prefix, "Resources");
7186
+ const prefix = platform === "macos-arm64" ? join21(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
7187
+ const resources = join21(payloadRoot, prefix, "Resources");
6371
7188
  const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
6372
7189
  const executables = [
6373
- join19(bin, `launcher${suffix}`),
6374
- join19(bin, `bun${suffix}`),
7190
+ join21(bin, `launcher${suffix}`),
7191
+ join21(bin, `bun${suffix}`),
6375
7192
  ...sidecars.map((name) => sidecarBundlePath(name, platform))
6376
7193
  ];
6377
7194
  const critical = [
@@ -6381,21 +7198,21 @@ async function extractVerifiedUpdate(options) {
6381
7198
  "Resources/app/client/index.html"
6382
7199
  ];
6383
7200
  for (const path of critical) {
6384
- const item = await lstat12(join19(payloadRoot, prefix, path));
7201
+ const item = await lstat13(join21(payloadRoot, prefix, path));
6385
7202
  if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
6386
7203
  throw new Error("Invalid critical update file");
6387
7204
  }
6388
7205
  for (const name of ["version.json", "build.json"]) {
6389
- const metadata = await lstat12(join19(resources, name));
7206
+ const metadata = await lstat13(join21(resources, name));
6390
7207
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
6391
7208
  throw new Error("Invalid update metadata");
6392
7209
  }
6393
- if (JSON.parse(await readFile6(join19(resources, "version.json"), "utf8")).version !== descriptor.version)
7210
+ if (JSON.parse(await readFile7(join21(resources, "version.json"), "utf8")).version !== descriptor.version)
6394
7211
  throw new Error("Update version mismatch");
6395
- assertBuildMetadata(JSON.parse(await readFile6(join19(resources, "build.json"), "utf8")), renderer);
7212
+ assertBuildMetadata(JSON.parse(await readFile7(join21(resources, "build.json"), "utf8")), renderer);
6396
7213
  return {
6397
7214
  directory,
6398
- payload: join19(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
7215
+ payload: join21(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
6399
7216
  };
6400
7217
  } catch (error) {
6401
7218
  if (directory)
@@ -6407,19 +7224,19 @@ async function extractVerifiedUpdate(options) {
6407
7224
  }
6408
7225
 
6409
7226
  // ../../src/updates/install/update-swap.ts
6410
- import { createHash as createHash13 } from "crypto";
7227
+ import { createHash as createHash16 } from "crypto";
6411
7228
  import { constants as constants7 } from "fs";
6412
- import { lstat as lstat13, open as open10, readdir as readdir8, readFile as readFile7, readlink as readlink2 } from "fs/promises";
6413
- import { basename as basename8, dirname as dirname6, join as join22 } from "path";
7229
+ import { lstat as lstat14, open as open10, readdir as readdir9, readFile as readFile8, readlink as readlink2 } from "fs/promises";
7230
+ import { basename as basename8, dirname as dirname6, join as join24 } from "path";
6414
7231
 
6415
7232
  // ../../src/updates/update-state-store.ts
6416
7233
  import { randomUUID as randomUUID2 } from "crypto";
6417
7234
  import { constants as constants6 } from "fs";
6418
7235
  import { open as open9, rename, unlink, writeFile as writeFile5 } from "fs/promises";
6419
- import { join as join21 } from "path";
7236
+ import { join as join23 } from "path";
6420
7237
 
6421
7238
  // ../../src/updates/locks/update-lock.ts
6422
- import { basename as basename7, dirname as dirname5, join as join20 } from "path";
7239
+ import { basename as basename7, dirname as dirname5, join as join22 } from "path";
6423
7240
 
6424
7241
  // ../../src/updates/locks/native-file-lock.ts
6425
7242
  import { constants as constants5 } from "fs";
@@ -6587,7 +7404,7 @@ async function tryAcquireWindows(path, mode) {
6587
7404
  function updateLockPath(target) {
6588
7405
  if (!isCanonicalPath(target))
6589
7406
  throw new Error("Invalid update lock target");
6590
- return join20(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7407
+ return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
6591
7408
  }
6592
7409
  async function tryAcquireUpdateLock(target) {
6593
7410
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -6652,7 +7469,7 @@ function parseState(value) {
6652
7469
  return Object.freeze(record);
6653
7470
  }
6654
7471
  async function readUpdateStageState(staging) {
6655
- const text = await readSmallStateFile(join21(staging, "state.json"), 4096, "Invalid update staging state");
7472
+ const text = await readSmallStateFile(join23(staging, "state.json"), 4096, "Invalid update staging state");
6656
7473
  return text === undefined ? undefined : parseState(JSON.parse(text));
6657
7474
  }
6658
7475
  async function writeUpdateStageState(staging, state) {
@@ -6661,8 +7478,8 @@ async function writeUpdateStageState(staging, state) {
6661
7478
  async function replaceUpdateStageState(staging, state, durable) {
6662
7479
  if (typeof state.generation !== "string" || !isUuid(state.generation))
6663
7480
  throw new Error("Invalid update staging state");
6664
- const path = join21(staging, "state.json");
6665
- const temporary = join21(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
7481
+ const path = join23(staging, "state.json");
7482
+ const temporary = join23(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
6666
7483
  const contents = JSON.stringify(state) + `
6667
7484
  `;
6668
7485
  let renamed = false;
@@ -6700,12 +7517,12 @@ async function withUpdateLock(target, operation) {
6700
7517
  function updateStagingFor(target) {
6701
7518
  if (!isCanonicalPath(target))
6702
7519
  throw new Error("Invalid update target");
6703
- return join22(dirname6(target), `.${basename8(target)}.framework-update`);
7520
+ return join24(dirname6(target), `.${basename8(target)}.framework-update`);
6704
7521
  }
6705
7522
  async function readUpdateTreeVersion(tree) {
6706
- const versionPath = join22(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7523
+ const versionPath = join24(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
6707
7524
  try {
6708
- const value = JSON.parse(await readFile7(versionPath, "utf8"));
7525
+ const value = JSON.parse(await readFile8(versionPath, "utf8"));
6709
7526
  if (typeof value !== "object" || value === null || typeof value.version !== "string")
6710
7527
  return;
6711
7528
  return value.version;
@@ -6719,7 +7536,7 @@ function updateTreeIdentityFromStat(info) {
6719
7536
  return { device: info.dev.toString(10), inode: info.ino.toString(10) };
6720
7537
  }
6721
7538
  async function readUpdateTreeIdentity(tree) {
6722
- const info = await lstat13(tree, { bigint: true });
7539
+ const info = await lstat14(tree, { bigint: true });
6723
7540
  return updateTreeIdentityFromStat(info);
6724
7541
  }
6725
7542
  function sameUpdateTreeIdentity(left, right) {
@@ -6763,9 +7580,9 @@ async function readTreeFileBytes(file, buffer, length, position) {
6763
7580
  }
6764
7581
  async function readUpdateTreeDigest(tree, options = {}) {
6765
7582
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
6766
- const hash = createHash13("sha256");
7583
+ const hash = createHash16("sha256");
6767
7584
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
6768
- const root = await lstat13(tree, { bigint: true });
7585
+ const root = await lstat14(tree, { bigint: true });
6769
7586
  if (!root.isDirectory() || root.isSymbolicLink())
6770
7587
  throw new Error("Update tree is not a real directory");
6771
7588
  const rootDevice = root.dev;
@@ -6795,10 +7612,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
6795
7612
  if (before.isSymbolicLink())
6796
7613
  return [{ kind: "symlink", path, relative, before }];
6797
7614
  if (before.isDirectory()) {
6798
- 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);
7615
+ const names = (await limit(() => readdir9(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
6799
7616
  const children = await Promise.all(names.map(async (name) => {
6800
- const childPath = join22(path, name);
6801
- return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat13(childPath, { bigint: true })));
7617
+ const childPath = join24(path, name);
7618
+ return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat14(childPath, { bigint: true })));
6802
7619
  }));
6803
7620
  return [{ kind: "directory", path, relative, before }, ...children.flat()];
6804
7621
  }
@@ -6812,7 +7629,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6812
7629
  return { kind: "none" };
6813
7630
  if (entry.kind === "symlink") {
6814
7631
  const target = Buffer.from(await readlink2(path), "utf8");
6815
- const after = await lstat13(path, { bigint: true });
7632
+ const after = await lstat14(path, { bigint: true });
6816
7633
  if (!sameTreeEntrySnapshot(before, after))
6817
7634
  throw new Error("Update tree changed while reading a symbolic link");
6818
7635
  return { kind: "bytes", bytes: target };
@@ -6831,7 +7648,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6831
7648
  const size = Number(before.size);
6832
7649
  const bytes = Buffer.allocUnsafe(size);
6833
7650
  await readTreeFileBytes(file, bytes, size, 0);
6834
- if (!sameTreeEntrySnapshot(before, await lstat13(path, { bigint: true })))
7651
+ if (!sameTreeEntrySnapshot(before, await lstat14(path, { bigint: true })))
6835
7652
  throw new Error("Update tree changed while reading a file");
6836
7653
  return { kind: "bytes", bytes };
6837
7654
  } finally {
@@ -6900,7 +7717,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6900
7717
  position = nextPosition;
6901
7718
  index = nextIndex;
6902
7719
  }
6903
- if (!sameTreeEntrySnapshot(entry.before, await lstat13(entry.path, { bigint: true })))
7720
+ if (!sameTreeEntrySnapshot(entry.before, await lstat14(entry.path, { bigint: true })))
6904
7721
  throw new Error("Update tree changed while reading a file");
6905
7722
  } finally {
6906
7723
  await file.close();
@@ -6916,11 +7733,11 @@ async function readUpdateTreeDigest(tree, options = {}) {
6916
7733
  await Promise.all(entries.map(async (entry) => {
6917
7734
  if (entry.kind !== "directory" || entry.relative === "")
6918
7735
  return;
6919
- const after = await limit(() => lstat13(entry.path, { bigint: true }));
7736
+ const after = await limit(() => lstat14(entry.path, { bigint: true }));
6920
7737
  if (!sameTreeEntrySnapshot(entry.before, after))
6921
7738
  throw new Error("Update tree changed while reading a directory");
6922
7739
  }));
6923
- const finalRoot = await lstat13(tree, { bigint: true });
7740
+ const finalRoot = await lstat14(tree, { bigint: true });
6924
7741
  if (!sameTreeEntrySnapshot(root, finalRoot))
6925
7742
  throw new Error("Update tree changed while its digest was computed");
6926
7743
  const count = Buffer.allocUnsafe(8);
@@ -6929,7 +7746,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6929
7746
  return hash.digest("hex");
6930
7747
  }
6931
7748
  async function assertDirectory(path) {
6932
- const info = await lstat13(path);
7749
+ const info = await lstat14(path);
6933
7750
  if (!info.isDirectory() || info.isSymbolicLink())
6934
7751
  throw new Error("Update exchange requires real directories");
6935
7752
  }
@@ -6940,8 +7757,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6940
7757
  const { target, staging } = options;
6941
7758
  if (dirname6(staging) !== dirname6(target) || staging === target)
6942
7759
  throw new Error("Invalid update swap context");
6943
- const candidate = join22(staging, "candidate");
6944
- const legacyOld = join22(staging, "old");
7760
+ const candidate = join24(staging, "candidate");
7761
+ const legacyOld = join24(staging, "old");
6945
7762
  if (await pathExists(legacyOld))
6946
7763
  throw new Error("A legacy update tree requires recovery before another swap");
6947
7764
  await assertDirectory(target);
@@ -6970,11 +7787,11 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6970
7787
  }
6971
7788
 
6972
7789
  // ../../src/updates/retention/retirement-inventory.ts
6973
- import { lstat as lstat15, readdir as readdir10 } from "fs/promises";
6974
- import { basename as basename12, dirname as dirname10, join as join26 } from "path";
7790
+ import { lstat as lstat16, readdir as readdir11 } from "fs/promises";
7791
+ import { basename as basename12, dirname as dirname10, join as join28 } from "path";
6975
7792
 
6976
7793
  // ../../src/updates/retention/update-retention-marker.ts
6977
- import { basename as basename9, dirname as dirname7, join as join23 } from "path";
7794
+ import { basename as basename9, dirname as dirname7, join as join25 } from "path";
6978
7795
  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}$/;
6979
7796
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
6980
7797
  function assertCanonicalTarget(target) {
@@ -6993,28 +7810,28 @@ function isTreeIdentity(value) {
6993
7810
  function updateRetentionIntentPath(target, generation) {
6994
7811
  assertCanonicalTarget(target);
6995
7812
  assertGeneration(generation);
6996
- return join23(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
7813
+ return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
6997
7814
  }
6998
7815
 
6999
7816
  // ../../src/updates/retention/retention-prune-progress.ts
7000
- import { basename as basename11, dirname as dirname9, join as join25 } from "path";
7817
+ import { basename as basename11, dirname as dirname9, join as join27 } from "path";
7001
7818
 
7002
7819
  // ../../src/updates/retention/retirement-records.ts
7003
- import { lstat as lstat14, readdir as readdir9, writeFile as writeFile6 } from "fs/promises";
7004
- import { basename as basename10, dirname as dirname8, join as join24 } from "path";
7820
+ import { lstat as lstat15, readdir as readdir10, writeFile as writeFile6 } from "fs/promises";
7821
+ import { basename as basename10, dirname as dirname8, join as join26 } from "path";
7005
7822
  function updateRetirementPaths(target, generation) {
7006
7823
  if (!isCanonicalPath(target) || !isUuid(generation))
7007
7824
  throw new Error("Invalid update retirement identity");
7008
7825
  const prefix = `.${basename10(target)}.framework-retired-${generation}`;
7009
- const container = join24(dirname8(target), prefix);
7826
+ const container = join26(dirname8(target), prefix);
7010
7827
  return Object.freeze({
7011
7828
  container,
7012
- tree: join24(container, "tree"),
7013
- healthReceipt: join24(container, "healthy.json"),
7829
+ tree: join26(container, "tree"),
7830
+ healthReceipt: join26(container, "healthy.json"),
7014
7831
  healthTemporaryPrefix: ".healthy-",
7015
- claim: join24(dirname8(target), `${prefix}.claim.json`),
7832
+ claim: join26(dirname8(target), `${prefix}.claim.json`),
7016
7833
  claimTemporaryPrefix: `${prefix}.claim-`,
7017
- cleanupMarker: join24(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7834
+ cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7018
7835
  cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
7019
7836
  });
7020
7837
  }
@@ -7065,7 +7882,7 @@ async function readCleanupMarker(path) {
7065
7882
  }
7066
7883
  async function pathInfo(path) {
7067
7884
  try {
7068
- return await lstat14(path);
7885
+ return await lstat15(path);
7069
7886
  } catch (error) {
7070
7887
  if (errorCode(error) === "ENOENT")
7071
7888
  return;
@@ -7113,15 +7930,15 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
7113
7930
  async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
7114
7931
  if (!isCanonicalPath(target) || !basename12(target))
7115
7932
  throw new Error("Invalid update retention prune gate target");
7116
- assertNoUnresolvedRetentionPruneArtifacts(target, await readdir10(dirname10(target)), {}, "update retention prune requires recovery before staging");
7933
+ assertNoUnresolvedRetentionPruneArtifacts(target, await readdir11(dirname10(target)), {}, "update retention prune requires recovery before staging");
7117
7934
  }
7118
7935
 
7119
7936
  // ../../src/updates/retention/update-retirement.ts
7120
- import { lstat as lstat16, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
7121
- import { basename as basename13, dirname as dirname11, join as join27 } from "path";
7937
+ import { lstat as lstat17, mkdir as mkdir8, readdir as readdir12, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
7938
+ import { basename as basename13, dirname as dirname11, join as join29 } from "path";
7122
7939
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7123
7940
  const { target, staging, currentVersion } = options;
7124
- const markerPath = join27(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7941
+ const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7125
7942
  const markerInfo = await pathInfo(markerPath);
7126
7943
  if (!markerInfo)
7127
7944
  return "none";
@@ -7138,14 +7955,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7138
7955
  const containerInfo = await pathInfo(paths.container);
7139
7956
  if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
7140
7957
  return "recovery-required";
7141
- const containerEntries = await readdir11(paths.container);
7958
+ const containerEntries = await readdir12(paths.container);
7142
7959
  if (containerEntries.length !== 1 || containerEntries[0] !== "tree")
7143
7960
  return "recovery-required";
7144
7961
  const stagingInfo = await pathInfo(staging);
7145
7962
  if (stagingInfo) {
7146
7963
  if (!stagingInfo.isDirectory() || stagingInfo.isSymbolicLink())
7147
7964
  return "recovery-required";
7148
- const stagingEntries = await readdir11(staging);
7965
+ const stagingEntries = await readdir12(staging);
7149
7966
  if (stagingEntries.length !== 0)
7150
7967
  return "recovery-required";
7151
7968
  await rmdir(staging);
@@ -7159,14 +7976,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7159
7976
 
7160
7977
  // ../../src/updates/install/update-swap-stage.ts
7161
7978
  async function assertInstalledVersion(options) {
7162
- const info = await lstat17(options.target);
7163
- if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(options.target) !== options.target)
7979
+ const info = await lstat18(options.target);
7980
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(options.target) !== options.target)
7164
7981
  throw new Error("Invalid update install target");
7165
- const versionFile = join28(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7166
- const versionInfo = await lstat17(versionFile);
7982
+ const versionFile = join30(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7983
+ const versionInfo = await lstat18(versionFile);
7167
7984
  if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
7168
7985
  throw new Error("Installed update version mismatch");
7169
- if (JSON.parse(await readFile8(versionFile, "utf8")).version !== options.version)
7986
+ if (JSON.parse(await readFile9(versionFile, "utf8")).version !== options.version)
7170
7987
  throw new Error("Installed update version mismatch");
7171
7988
  }
7172
7989
  async function stageUpdateSwap(options) {
@@ -7186,7 +8003,7 @@ async function stageUpdateSwap(options) {
7186
8003
  });
7187
8004
  const staging = updateStagingFor(plan.target);
7188
8005
  const preparing = await mkdtemp8(`${staging}.preparing-`);
7189
- const candidate = join28(staging, "candidate");
8006
+ const candidate = join30(staging, "candidate");
7190
8007
  let published = false;
7191
8008
  try {
7192
8009
  const extracted = await extractVerifiedUpdate({
@@ -7200,12 +8017,12 @@ async function stageUpdateSwap(options) {
7200
8017
  maxExpandedBytes: options.maxExpandedBytes,
7201
8018
  ...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
7202
8019
  });
7203
- renameExclusive(extracted.payload, join28(preparing, "candidate"));
8020
+ renameExclusive(extracted.payload, join30(preparing, "candidate"));
7204
8021
  await rm8(extracted.directory, { recursive: true, force: true });
7205
- const candidateTreeIdentity = await readUpdateTreeIdentity(join28(preparing, "candidate"));
8022
+ const candidateTreeIdentity = await readUpdateTreeIdentity(join30(preparing, "candidate"));
7206
8023
  if (!candidateTreeIdentity)
7207
8024
  throw new Error("Update candidate tree identity could not be read");
7208
- const candidateTreeDigest = await readUpdateTreeDigest(join28(preparing, "candidate"));
8025
+ const candidateTreeDigest = await readUpdateTreeDigest(join30(preparing, "candidate"));
7209
8026
  await writeUpdateStageState(preparing, newUpdateStageState({
7210
8027
  version: plan.version,
7211
8028
  previousVersion: options.currentVersion,
@@ -7224,7 +8041,7 @@ async function stageUpdateSwap(options) {
7224
8041
  });
7225
8042
  let existingInfo;
7226
8043
  try {
7227
- existingInfo = await lstat17(staging);
8044
+ existingInfo = await lstat18(staging);
7228
8045
  } catch (error) {
7229
8046
  if (errorCode(error) === "ENOENT") {
7230
8047
  const retirement = await reconcileRetirementCleanupMarkerWhileLocked({
@@ -7290,11 +8107,11 @@ function isolatedEnv(parent, profile, platform) {
7290
8107
  RUNNER_ENVIRONMENT: "github-hosted",
7291
8108
  HOME: profile,
7292
8109
  USERPROFILE: profile,
7293
- LOCALAPPDATA: join29(profile, "LocalAppData"),
7294
- XDG_DATA_HOME: join29(profile, ".local", "share"),
7295
- TMP: join29(profile, "tmp"),
7296
- TEMP: join29(profile, "tmp"),
7297
- TMPDIR: join29(profile, "tmp"),
8110
+ LOCALAPPDATA: join31(profile, "LocalAppData"),
8111
+ XDG_DATA_HOME: join31(profile, ".local", "share"),
8112
+ TMP: join31(profile, "tmp"),
8113
+ TEMP: join31(profile, "tmp"),
8114
+ TMPDIR: join31(profile, "tmp"),
7298
8115
  ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
7299
8116
  });
7300
8117
  if (platform === "windows-x64")
@@ -7389,15 +8206,15 @@ async function observeInstalledApp(options) {
7389
8206
  await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
7390
8207
  stage("runtime-preflight-passed");
7391
8208
  for (const path of [
7392
- join29(prepared.profile, "LocalAppData"),
7393
- join29(prepared.profile, ".local", "share"),
7394
- join29(prepared.profile, "tmp")
8209
+ join31(prepared.profile, "LocalAppData"),
8210
+ join31(prepared.profile, ".local", "share"),
8211
+ join31(prepared.profile, "tmp")
7395
8212
  ])
7396
8213
  await mkdir9(path, { recursive: true, mode: 448 });
7397
8214
  const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
7398
- const installedRoot = mac ? join29(prepared.incoming, `${options.appName}.app`, "Contents") : join29(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
7399
- const resources = join29(installedRoot, "Resources"), binary = join29(installedRoot, mac ? "MacOS" : "bin"), launcher = join29(binary, windows ? "launcher.exe" : "launcher"), runtime = join29(binary, windows ? "bun.exe" : "bun");
7400
- const worker = join29(resources, "app", "bun", "index.js");
8215
+ const installedRoot = mac ? join31(prepared.incoming, `${options.appName}.app`, "Contents") : join31(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
8216
+ 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");
8217
+ const worker = join31(resources, "app", "bun", "index.js");
7401
8218
  const sidecars = options.sidecars ?? [];
7402
8219
  let foreignHits = 0;
7403
8220
  const sentinel = policy ? Bun.serve({
@@ -7447,8 +8264,8 @@ async function observeInstalledApp(options) {
7447
8264
  if (sentinel && (!(await fetch(foreignOrigin + "/", { signal: AbortSignal.timeout(1000) })).ok || foreignHits !== 1))
7448
8265
  throw new Error("Foreign network sentinel unavailable");
7449
8266
  foreignHits = 0;
7450
- const nonce = randomBytes2(24).toString("hex");
7451
- const ack = join29(run.directory, "ack"), permit = join29(run.directory, "permit"), observation = join29(run.directory, "observation"), unexpected = join29(run.directory, "unexpected"), pidRecord = join29(run.directory, "worker-pid");
8267
+ const nonce = randomBytes3(24).toString("hex");
8268
+ 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");
7452
8269
  const env = {
7453
8270
  ...baseEnv,
7454
8271
  FRAMEWORK_CI_NONCE: nonce,
@@ -7461,13 +8278,13 @@ async function observeInstalledApp(options) {
7461
8278
  };
7462
8279
  let launchRecord, expectedApp;
7463
8280
  if (mac && viaInstaller) {
7464
- const shimDir = join29(run.directory, "launch-shim");
8281
+ const shimDir = join31(run.directory, "launch-shim");
7465
8282
  await mkdir9(shimDir, { mode: 448 });
7466
- const path = join29(shimDir, "open");
8283
+ const path = join31(shimDir, "open");
7467
8284
  await writeFile8(path, shim, { flag: "wx", mode: 448 });
7468
8285
  await chmod2(path, 448);
7469
- expectedApp = join29(await realpath8(prepared.incoming), `${options.appName}.app`);
7470
- launchRecord = join29(run.directory, "launch-record");
8286
+ expectedApp = join31(await realpath9(prepared.incoming), `${options.appName}.app`);
8287
+ launchRecord = join31(run.directory, "launch-record");
7471
8288
  Object.assign(env, {
7472
8289
  PATH: shimDir + delimiter + (env.PATH ?? ""),
7473
8290
  FRAMEWORK_CI_EXPECTED_APP: expectedApp,
@@ -7503,7 +8320,7 @@ async function observeInstalledApp(options) {
7503
8320
  const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
7504
8321
  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"})`);
7505
8322
  }
7506
- const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join29(resources, "version.json"));
8323
+ const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join31(resources, "version.json"));
7507
8324
  if (installer && shouldLaunchInstalledApp({
7508
8325
  platform: options.platform,
7509
8326
  ready,
@@ -7511,17 +8328,17 @@ async function observeInstalledApp(options) {
7511
8328
  acknowledged: await pathExists(ack),
7512
8329
  installerExit: installer.exitCode
7513
8330
  })) {
7514
- if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile9(launchRecord, "utf8") !== expectedApp + `
8331
+ if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile10(launchRecord, "utf8") !== expectedApp + `
7515
8332
  `)
7516
8333
  throw new Error("Installer launch request mismatch");
7517
8334
  app = spawnApp();
7518
8335
  }
7519
8336
  if (await pathExists(ack) && !granted) {
7520
8337
  stage("worker-acknowledged");
7521
- if (await readFile9(ack, "utf8") !== nonce + `
8338
+ if (await readFile10(ack, "utf8") !== nonce + `
7522
8339
  `)
7523
8340
  throw new Error("Worker guard acknowledgement mismatch");
7524
- const record = await readFile9(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
8341
+ const record = await readFile10(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
7525
8342
  if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
7526
8343
  throw new Error("Worker process identity mismatch");
7527
8344
  guardedPid = Number(match[2]);
@@ -7679,7 +8496,7 @@ async function observeInstalledApp(options) {
7679
8496
  await swapAfterExit(target, staged.staging);
7680
8497
  stage("update-swapped");
7681
8498
  await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
7682
- const directory = join29(prepared.directory, "update");
8499
+ const directory = join31(prepared.directory, "update");
7683
8500
  await mkdir9(directory, { mode: 448 });
7684
8501
  const updated = await observeRun({
7685
8502
  directory,
@@ -7728,9 +8545,9 @@ async function qualifyInstallerCommand(options) {
7728
8545
  const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
7729
8546
  if (!policy || !names || names.length !== 2)
7730
8547
  throw new Error("Installer qualification requires an explicit offline policy and payloads");
7731
- const directory = resolve13(options.directory), destination = join30(directory, `installer-test-${platform}.json`);
8548
+ const directory = resolve14(options.directory), destination = join32(directory, `installer-test-${platform}.json`);
7732
8549
  try {
7733
- await lstat18(destination);
8550
+ await lstat19(destination);
7734
8551
  throw new Error("Installer receipt already exists");
7735
8552
  } catch (error) {
7736
8553
  if (errorCode(error) !== "ENOENT")
@@ -7744,8 +8561,8 @@ async function qualifyInstallerCommand(options) {
7744
8561
  appName: app.appName,
7745
8562
  appId: app.appId,
7746
8563
  version: plan.version,
7747
- installer: join30(directory, names[0]),
7748
- archive: join30(directory, names[1]),
8564
+ installer: join32(directory, names[0]),
8565
+ archive: join32(directory, names[1]),
7749
8566
  expectedReads: parsed.expectedReads,
7750
8567
  offlinePolicy: policy,
7751
8568
  sidecars: parsed.sidecars
@@ -7776,11 +8593,11 @@ async function qualifyInstallerCommand(options) {
7776
8593
  }
7777
8594
 
7778
8595
  // ../../src/installer/installer-upgrade-command.ts
7779
- import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
7780
- import { join as join32, resolve as resolve15 } from "path";
8596
+ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
8597
+ import { join as join34, resolve as resolve16 } from "path";
7781
8598
 
7782
8599
  // ../../src/installer/upgrade-asset-download.ts
7783
- import { createHash as createHash14 } from "crypto";
8600
+ import { createHash as createHash17 } from "crypto";
7784
8601
  import { open as open11, unlink as unlink3 } from "fs/promises";
7785
8602
 
7786
8603
  // ../../src/installer/write-all.ts
@@ -7818,7 +8635,7 @@ async function downloadAsset(options) {
7818
8635
  discardStream(response.body);
7819
8636
  throw error;
7820
8637
  }
7821
- const hash = createHash14("sha256");
8638
+ const hash = createHash17("sha256");
7822
8639
  let completed = false;
7823
8640
  try {
7824
8641
  let size = 0;
@@ -7858,7 +8675,7 @@ async function downloadAsset(options) {
7858
8675
  }
7859
8676
 
7860
8677
  // ../../src/updates/feed/update-discovery.ts
7861
- import { createHash as createHash15 } from "crypto";
8678
+ import { createHash as createHash18 } from "crypto";
7862
8679
  var MAX_POINTER_BYTES = 262144;
7863
8680
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
7864
8681
  async function discoverSignedRelease(options) {
@@ -7894,7 +8711,7 @@ async function discoverSignedRelease(options) {
7894
8711
  throw new Error("No qualified channel descriptor is available");
7895
8712
  const { tag } = selected;
7896
8713
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
7897
- if (bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
8714
+ if (bytes.length !== listed.size || createHash18("sha256").update(bytes).digest("hex") !== listed.sha256)
7898
8715
  throw new Error("Channel descriptor differs from its release");
7899
8716
  let signed;
7900
8717
  try {
@@ -7912,8 +8729,8 @@ async function discoverSignedRelease(options) {
7912
8729
  }
7913
8730
 
7914
8731
  // ../../src/updates/install/update-download.ts
7915
- import { mkdtemp as mkdtemp9, open as open12, realpath as realpath9, rm as rm9 } from "fs/promises";
7916
- import { basename as basename14, dirname as dirname13, join as join31, resolve as resolve14 } from "path";
8732
+ import { mkdtemp as mkdtemp9, open as open12, realpath as realpath10, rm as rm9 } from "fs/promises";
8733
+ import { basename as basename14, dirname as dirname13, join as join33, resolve as resolve15 } from "path";
7917
8734
  async function downloadVerifiedRelease(options) {
7918
8735
  const { descriptor, maxBytes } = options;
7919
8736
  const timeout = options.timeoutMs ?? 120000;
@@ -7945,13 +8762,13 @@ async function downloadVerifiedRelease(options) {
7945
8762
  if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
7946
8763
  throw new Error("Release download size mismatch");
7947
8764
  }
7948
- const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
7949
- const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join31(root, "framework-update-"));
7950
- const temporaryDirectory = resolve14(allocated);
8765
+ const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
8766
+ const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join33(root, "framework-update-"));
8767
+ const temporaryDirectory = resolve15(allocated);
7951
8768
  if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
7952
8769
  throw new Error("Invalid update download directory");
7953
8770
  temporary = temporaryDirectory;
7954
- const path = join31(temporary, "archive");
8771
+ const path = join33(temporary, "archive");
7955
8772
  const file = await open12(path, "wx", 384);
7956
8773
  try {
7957
8774
  async function* writeChunks() {
@@ -8054,9 +8871,9 @@ async function qualifyUpgradeCommand(options) {
8054
8871
  const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
8055
8872
  if (!requirements.offlinePolicy || !names || names.length !== 2)
8056
8873
  throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
8057
- const directory = resolve15(options.directory), destination = join32(directory, `upgrade-test-${platform}.json`);
8874
+ const directory = resolve16(options.directory), destination = join34(directory, `upgrade-test-${platform}.json`);
8058
8875
  try {
8059
- await lstat19(destination);
8876
+ await lstat20(destination);
8060
8877
  throw new Error("Upgrade receipt already exists");
8061
8878
  } catch (error) {
8062
8879
  if (errorCode(error) !== "ENOENT")
@@ -8077,7 +8894,7 @@ async function qualifyUpgradeCommand(options) {
8077
8894
  const channel = "daily";
8078
8895
  const trust = { ...base, channel };
8079
8896
  const discovery = discoveryName(config, channel, platform);
8080
- const signed = await readJsonFile(join32(directory, discovery), 65536, "staged descriptor");
8897
+ const signed = await readJsonFile(join34(directory, discovery), 65536, "staged descriptor");
8081
8898
  const verified = verifyReleaseDescriptor(signed, trust);
8082
8899
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
8083
8900
  throw new Error("Untrusted staged descriptor");
@@ -8100,7 +8917,7 @@ async function qualifyUpgradeCommand(options) {
8100
8917
  return null;
8101
8918
  if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
8102
8919
  throw new Error("Previous release is not older than this release");
8103
- const work = join32(directory, `upgrade-${platform}`);
8920
+ const work = join34(directory, `upgrade-${platform}`);
8104
8921
  await mkdir10(work, { mode: 448 });
8105
8922
  const downloaded = await downloadVerifiedRelease({
8106
8923
  descriptor: previous,
@@ -8109,12 +8926,12 @@ async function qualifyUpgradeCommand(options) {
8109
8926
  timeoutMs: 600000,
8110
8927
  fetch: fetcher
8111
8928
  });
8112
- const previousArchive = join32(work, previous.asset.name);
8929
+ const previousArchive = join34(work, previous.asset.name);
8113
8930
  await rename2(downloaded.path, previousArchive);
8114
8931
  const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
8115
8932
  if (!installerName)
8116
8933
  throw new Error("Previous release has no installer for this platform");
8117
- const previousInstaller = join32(work, installerName);
8934
+ const previousInstaller = join34(work, installerName);
8118
8935
  await downloadAsset({
8119
8936
  feed,
8120
8937
  tag: previous.tag,
@@ -8138,7 +8955,7 @@ async function qualifyUpgradeCommand(options) {
8138
8955
  update: {
8139
8956
  descriptor,
8140
8957
  trust,
8141
- archive: join32(directory, names[1]),
8958
+ archive: join34(directory, names[1]),
8142
8959
  maxCompressedBytes: MAX_COMPRESSED_BYTES2,
8143
8960
  maxExpandedBytes: MAX_EXPANDED_BYTES2
8144
8961
  }
@@ -8161,7 +8978,7 @@ async function qualifyUpgradeCommand(options) {
8161
8978
  }
8162
8979
 
8163
8980
  // src/library/steps.ts
8164
- var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
8981
+ var selectRetainedStepEffect = (context) => Effect25.gen(function* () {
8165
8982
  const output = context.env.GITHUB_OUTPUT;
8166
8983
  if (!output)
8167
8984
  return yield* fail("Expected GITHUB_OUTPUT");
@@ -8173,7 +8990,7 @@ runId=${result.runId}
8173
8990
  ` : `reuse=false
8174
8991
  `));
8175
8992
  });
8176
- var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
8993
+ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
8177
8994
  const fs = yield* ReleaseFs;
8178
8995
  const [installerAsset, archiveAsset] = platformAssets(context);
8179
8996
  const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
@@ -8182,12 +8999,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8182
8999
  yield* step(() => fs.mkdir(directory, { recursive: true }));
8183
9000
  const packed = yield* scopedTempDirectory("framework-command-pack-");
8184
9001
  const sources = {
8185
- [installerAsset]: join33(artifacts, installer),
8186
- [archiveAsset]: join33(artifacts, archive)
9002
+ [installerAsset]: join35(artifacts, installer),
9003
+ [archiveAsset]: join35(artifacts, archive)
8187
9004
  };
8188
9005
  for (const policy of parsed.commandArtifacts) {
8189
9006
  const name = requirements.commandArtifacts[policy.kind][context.platform];
8190
- sources[name] = join33(packed, name);
9007
+ sources[name] = join35(packed, name);
8191
9008
  yield* step(() => packCommandArtifact({
8192
9009
  source: policy.build,
8193
9010
  archive: sources[name],
@@ -8196,8 +9013,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8196
9013
  }));
8197
9014
  }
8198
9015
  return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
8199
- }).pipe(Effect24.scoped);
8200
- var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
9016
+ }).pipe(Effect25.scoped);
9017
+ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* () {
8201
9018
  const fs = yield* ReleaseFs;
8202
9019
  const parsed = parseReleaseConfig(context.config);
8203
9020
  const requirements = parsed.requirements(context.tag);
@@ -8205,10 +9022,10 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8205
9022
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
8206
9023
  if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
8207
9024
  return yield* fail("Staged platform directory contains unexpected files");
8208
- const [installer, archive] = platformAssets(context).map((name) => join33(directory, name));
9025
+ const [installer, archive] = platformAssets(context).map((name) => join35(directory, name));
8209
9026
  for (const policy of parsed.commandArtifacts)
8210
9027
  yield* step(() => readCommandArtifact({
8211
- archive: join33(directory, requirements.commandArtifacts[policy.kind][context.platform]),
9028
+ archive: join35(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8212
9029
  executable: policy.executable,
8213
9030
  platform: context.platform
8214
9031
  }));
@@ -8224,12 +9041,12 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8224
9041
  }))
8225
9042
  };
8226
9043
  });
8227
- var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
9044
+ var qualifyStepEffect = (context, directory) => Effect25.gen(function* () {
8228
9045
  const mode = stepRenderer(context.env);
8229
9046
  yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
8230
9047
  yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
8231
9048
  });
8232
- var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
9049
+ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend(() => {
8233
9050
  const renderer = stepRenderer(context.env);
8234
9051
  return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
8235
9052
  });
@@ -8247,17 +9064,17 @@ import {
8247
9064
  mkdir as mkdir11,
8248
9065
  mkdtemp as mkdtemp10,
8249
9066
  open as open13,
8250
- readFile as readFile10,
8251
- realpath as realpath10,
9067
+ readFile as readFile11,
9068
+ realpath as realpath11,
8252
9069
  rm as rm10,
8253
9070
  writeFile as writeFile11
8254
9071
  } from "fs/promises";
8255
- import { dirname as dirname14, join as join34, resolve as resolve16 } from "path";
8256
- import { promisify as promisify2 } from "util";
9072
+ import { dirname as dirname14, join as join36, resolve as resolve17 } from "path";
9073
+ import { promisify as promisify3 } from "util";
8257
9074
  var shasum = /^[a-f0-9]{64}$/;
8258
9075
  var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
8259
9076
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
8260
- var exec = promisify2(execFile3);
9077
+ var exec = promisify3(execFile3);
8261
9078
  function requireThat2(condition, message) {
8262
9079
  if (!condition)
8263
9080
  throw new Error(message);
@@ -8380,9 +9197,9 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8380
9197
  const trusted = trustedArtifacts.find((file) => file.name === name);
8381
9198
  return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
8382
9199
  }), "Package producer receipt must describe exactly the protected DEB and AppImage");
8383
- const destination = resolve16(options.output);
8384
- const parent = await realpath10(dirname14(destination));
8385
- const work = await mkdtemp10(join34(parent, ".linux-package-pair-"));
9200
+ const destination = resolve17(options.output);
9201
+ const parent = await realpath11(dirname14(destination));
9202
+ const work = await mkdtemp10(join36(parent, ".linux-package-pair-"));
8386
9203
  try {
8387
9204
  const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
8388
9205
  directory: work,
@@ -8390,11 +9207,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8390
9207
  sources
8391
9208
  })));
8392
9209
  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");
8393
- const deb = join34(work, expected.debName);
8394
- const image = join34(work, expected.appImageName);
9210
+ const deb = join36(work, expected.debName);
9211
+ const image = join36(work, expected.appImageName);
8395
9212
  const version = expected.tag.slice(1);
8396
9213
  parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
8397
- await verifyEmbeddedRuntime(image, await readFile10(join34(work, runtime.name)));
9214
+ await verifyEmbeddedRuntime(image, await readFile11(join36(work, runtime.name)));
8398
9215
  const offset = String(runtime.size);
8399
9216
  requireRegularDesktopEntry(await inspect("unsquashfs", [
8400
9217
  "-offset",
@@ -8424,8 +9241,8 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8424
9241
  await mkdir11(destination);
8425
9242
  try {
8426
9243
  for (const name of names)
8427
- await link(join34(work, name), join34(destination, name));
8428
- await writeFile11(join34(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
9244
+ await link(join36(work, name), join36(destination, name));
9245
+ await writeFile11(join36(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
8429
9246
  `, {
8430
9247
  flag: "wx"
8431
9248
  });
@@ -8439,6 +9256,319 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8439
9256
  }
8440
9257
  }
8441
9258
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
9259
+ // src/library/linux-format-producer.ts
9260
+ import { createHash as createHash19 } from "crypto";
9261
+ import { createReadStream as createReadStream2, createWriteStream } from "fs";
9262
+ import {
9263
+ chmod as chmod4,
9264
+ cp,
9265
+ lstat as lstat21,
9266
+ lutimes,
9267
+ mkdir as mkdir12,
9268
+ mkdtemp as mkdtemp11,
9269
+ open as open14,
9270
+ readdir as readdir13,
9271
+ readlink as readlink3,
9272
+ realpath as realpath12,
9273
+ rm as rm11,
9274
+ symlink as symlink2,
9275
+ utimes,
9276
+ writeFile as writeFile12
9277
+ } from "fs/promises";
9278
+ import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative6, resolve as resolve18 } from "path";
9279
+ import { pipeline as pipeline2 } from "stream/promises";
9280
+ var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
9281
+ var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
9282
+ var sha2562 = /^[a-f0-9]{64}$/;
9283
+ var sum = async (path) => {
9284
+ const hash = createHash19("sha256");
9285
+ for await (const chunk of createReadStream2(path))
9286
+ hash.update(chunk);
9287
+ return hash.digest("hex");
9288
+ };
9289
+ var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
9290
+ var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
9291
+ function check2(ok, message) {
9292
+ if (!ok)
9293
+ throw new Error(message);
9294
+ }
9295
+ async function exactCopy(pin, to) {
9296
+ check2(sha2562.test(pin.sha256), "Missing protected input digest");
9297
+ const before = await lstat21(pin.path);
9298
+ check2(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
9299
+ const input = await open14(pin.path, "r");
9300
+ try {
9301
+ const after = await input.stat();
9302
+ check2(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9303
+ await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
9304
+ } finally {
9305
+ await input.close();
9306
+ }
9307
+ check2((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9308
+ }
9309
+ async function regular2(root, path) {
9310
+ const file = join37(root, path);
9311
+ check2((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
9312
+ return file;
9313
+ }
9314
+ async function elf(path, appImage = false) {
9315
+ const input = await open14(path, "r");
9316
+ try {
9317
+ const h = Buffer.alloc(20);
9318
+ const { bytesRead } = await input.read(h, 0, h.length, 0);
9319
+ 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");
9320
+ } finally {
9321
+ await input.close();
9322
+ }
9323
+ }
9324
+ async function normalizeTree(root, dir = root) {
9325
+ for (const name of await readdir13(dir)) {
9326
+ const file = join37(dir, name);
9327
+ const st = await lstat21(file);
9328
+ if (st.isSymbolicLink()) {
9329
+ check2(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
9330
+ const target = relative6(root, await realpath12(file));
9331
+ check2(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
9332
+ } else if (st.isDirectory()) {
9333
+ await chmod4(file, 493);
9334
+ await normalizeTree(root, file);
9335
+ } else {
9336
+ check2(st.isFile(), "Unsupported bundle entry");
9337
+ await chmod4(file, st.mode & 73 ? 493 : 420);
9338
+ }
9339
+ }
9340
+ }
9341
+ async function normalizeBuildTimes(directory, epoch) {
9342
+ for (const name of (await readdir13(directory)).toSorted()) {
9343
+ const path = join37(directory, name);
9344
+ const info = await lstat21(path);
9345
+ if (info.isSymbolicLink()) {
9346
+ await lutimes(path, epoch, epoch);
9347
+ } else if (info.isDirectory()) {
9348
+ await normalizeBuildTimes(path, epoch);
9349
+ } else {
9350
+ check2(info.isFile(), "Unsupported packaging entry");
9351
+ await utimes(path, epoch, epoch);
9352
+ }
9353
+ }
9354
+ await chmod4(directory, 493);
9355
+ await utimes(directory, epoch, epoch);
9356
+ }
9357
+ async function write(root, path, value, mode = 420) {
9358
+ const target = join37(root, path);
9359
+ await mkdir12(dirname15(target), { recursive: true });
9360
+ await writeFile12(target, value, { flag: "wx", mode });
9361
+ await chmod4(target, mode);
9362
+ }
9363
+ function validatePolicy(policy) {
9364
+ const executable = policy.executable ?? policy.packageName;
9365
+ const links = policy.links ?? [];
9366
+ 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");
9367
+ check2(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
9368
+ }
9369
+ async function buildLinuxFormats(input, host) {
9370
+ const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
9371
+ const checkAbort = () => host.signal?.throwIfAborted();
9372
+ checkAbort();
9373
+ check2(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
9374
+ 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");
9375
+ check2(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
9376
+ if (input.identity)
9377
+ 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");
9378
+ const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
9379
+ validatePolicy(policy);
9380
+ const requested = resolve18(input.output);
9381
+ const parent = await realpath12(dirname15(requested));
9382
+ const output = join37(parent, basename16(requested));
9383
+ const work = await mkdtemp11(join37(parent, ".linux-formats-"));
9384
+ let outputOwned = false;
9385
+ try {
9386
+ const archive = join37(work, "payload.tar.zst");
9387
+ const tool = join37(work, "appimagetool");
9388
+ const runtime = join37(work, "runtime");
9389
+ for (const [pin, dest] of [
9390
+ [input.archive, archive],
9391
+ [input.tool, tool],
9392
+ [input.runtime, runtime]
9393
+ ])
9394
+ await exactCopy(pin, dest);
9395
+ await elf(tool, true);
9396
+ await elf(runtime, true);
9397
+ await chmod4(tool, 448);
9398
+ const extracted = join37(work, "extract");
9399
+ await mkdir12(extracted);
9400
+ if (host.extractVerifiedAppArchive) {
9401
+ await host.extractVerifiedAppArchive(archive, extracted);
9402
+ } else {
9403
+ await host.inspectAppArchive(archive);
9404
+ check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
9405
+ await host.run("tar", [
9406
+ "--zstd",
9407
+ "--extract",
9408
+ "--file",
9409
+ archive,
9410
+ "--directory",
9411
+ extracted,
9412
+ "--no-same-owner",
9413
+ "--no-same-permissions"
9414
+ ], { env });
9415
+ }
9416
+ check2((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
9417
+ checkAbort();
9418
+ const source = join37(extracted, policy.bundleRoot);
9419
+ check2((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
9420
+ await chmod4(source, 493);
9421
+ await normalizeTree(source);
9422
+ await elf(await regular2(source, policy.launcher));
9423
+ for (const link of policy.links ?? []) {
9424
+ const target = await regular2(source, link.target);
9425
+ check2(((await lstat21(target)).mode & 73) !== 0, "CLI link target is not executable");
9426
+ }
9427
+ for (const pin of policy.debSetuid) {
9428
+ const file = await regular2(source, pin.path);
9429
+ await elf(file);
9430
+ check2(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9431
+ }
9432
+ const icon = await regular2(source, policy.icon);
9433
+ check2(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9434
+ const stem = `${policy.artifactStem}-${tag}-linux-x64`;
9435
+ const debName = `${stem}.deb`;
9436
+ const imageName = `${stem}.AppImage`;
9437
+ const dest = join37(work, "result");
9438
+ await mkdir12(dest);
9439
+ const version = tag.slice(1);
9440
+ const installed = `usr/lib/${policy.packageName}`;
9441
+ const executable = policy.executable ?? policy.packageName;
9442
+ const desktopFile = `${policy.desktopId}.desktop`;
9443
+ const desktop = [
9444
+ "[Desktop Entry]",
9445
+ "Type=Application",
9446
+ `Name=${policy.name}`,
9447
+ `Comment=${policy.description}`,
9448
+ `Exec=${executable} %U`,
9449
+ `Icon=${policy.desktopId}`,
9450
+ `Categories=${policy.categories.join(";")};`,
9451
+ ...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
9452
+ "Terminal=false",
9453
+ ""
9454
+ ].join(`
9455
+ `);
9456
+ for (const format of ["deb", "appimage"]) {
9457
+ checkAbort();
9458
+ const tree = join37(work, format);
9459
+ await mkdir12(join37(tree, "usr", "lib"), { recursive: true });
9460
+ const bundle = join37(tree, installed);
9461
+ await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
9462
+ await normalizeTree(bundle);
9463
+ const appDirectory = join37(bundle, "Resources", "app");
9464
+ check2((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
9465
+ await write(bundle, "Resources/app/.adea-linux-package", `${format}
9466
+ `);
9467
+ await write(tree, `usr/share/applications/${desktopFile}`, desktop);
9468
+ const iconDest = join37(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9469
+ await mkdir12(dirname15(iconDest), { recursive: true });
9470
+ await cp(icon, iconDest, { force: false, errorOnExist: true });
9471
+ await chmod4(iconDest, 420);
9472
+ await mkdir12(join37(tree, "usr", "bin"), { recursive: true });
9473
+ for (const link of policy.links ?? [])
9474
+ await symlink2(`../lib/${policy.packageName}/${link.target}`, join37(tree, "usr", "bin", link.name));
9475
+ if (format === "deb") {
9476
+ for (const pin of policy.debSetuid)
9477
+ await chmod4(await regular2(bundle, pin.path), 2541);
9478
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
9479
+ export ${policy.formatEnvironment}=deb
9480
+ exec '/${installed}/${policy.launcher}' "$@"
9481
+ `, 493);
9482
+ await write(tree, "DEBIAN/control", [
9483
+ `Package: ${policy.packageName}`,
9484
+ `Version: ${version}`,
9485
+ "Architecture: amd64",
9486
+ `Maintainer: ${policy.maintainer}`,
9487
+ `Description: ${policy.description}`,
9488
+ `Homepage: ${policy.homepage}`,
9489
+ ...policy.dependencies.length ? [`Depends: ${policy.dependencies.join(", ")}`] : [],
9490
+ ""
9491
+ ].join(`
9492
+ `));
9493
+ await normalizeBuildTimes(tree, sourceDateEpoch);
9494
+ await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join37(dest, debName)], { env });
9495
+ } else {
9496
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
9497
+ set -eu
9498
+ root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
9499
+ export ${policy.formatEnvironment}=appimage
9500
+ exec "$root/${installed}/${policy.launcher}" "$@"
9501
+ `, 493);
9502
+ const rootIcon = join37(tree, `${policy.desktopId}.svg`);
9503
+ await cp(icon, rootIcon, { force: false, errorOnExist: true });
9504
+ await chmod4(rootIcon, 420);
9505
+ await write(tree, desktopFile, desktop);
9506
+ await write(tree, "AppRun", [
9507
+ "#!/bin/sh",
9508
+ "set -eu",
9509
+ 'root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
9510
+ `export ${policy.formatEnvironment}=appimage`,
9511
+ `exec "$root/${installed}/${policy.launcher}" "$@"`,
9512
+ ""
9513
+ ].join(`
9514
+ `), 493);
9515
+ await normalizeBuildTimes(tree, sourceDateEpoch);
9516
+ await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join37(dest, imageName)], {
9517
+ executable: tool,
9518
+ env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
9519
+ });
9520
+ }
9521
+ }
9522
+ const artifacts = [];
9523
+ for (const name of [debName, imageName]) {
9524
+ const path = await regular2(dest, name);
9525
+ const size = (await lstat21(path)).size;
9526
+ check2(size > 0, "Empty produced artifact");
9527
+ artifacts.push({ name, size, sha256: await sum(path) });
9528
+ }
9529
+ const receipt = {
9530
+ schema: "linux-package-formats/v1",
9531
+ tag,
9532
+ sourceSha,
9533
+ sourceDateEpoch,
9534
+ ...input.identity,
9535
+ platform: "linux-x64",
9536
+ updateArchiveSha256: input.archive.sha256,
9537
+ artifacts
9538
+ };
9539
+ checkAbort();
9540
+ await mkdir12(output);
9541
+ outputOwned = true;
9542
+ try {
9543
+ for (const item of artifacts)
9544
+ await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
9545
+ force: false,
9546
+ errorOnExist: true
9547
+ });
9548
+ checkAbort();
9549
+ await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
9550
+ `);
9551
+ checkAbort();
9552
+ } catch (error) {
9553
+ await rm11(output, { recursive: true, force: true });
9554
+ outputOwned = false;
9555
+ throw error;
9556
+ }
9557
+ return receipt;
9558
+ } finally {
9559
+ let cleanupComplete = false;
9560
+ try {
9561
+ await rm11(work, { recursive: true, force: true });
9562
+ await host.afterWorkCleanup?.();
9563
+ cleanupComplete = true;
9564
+ } finally {
9565
+ if ((!cleanupComplete || host.signal?.aborted) && outputOwned) {
9566
+ await rm11(output, { recursive: true, force: true });
9567
+ host.signal?.throwIfAborted();
9568
+ }
9569
+ }
9570
+ }
9571
+ }
8442
9572
  // src/framework-loader.ts
8443
9573
  var releaseTools = async () => exports_src;
8444
9574
 
@@ -8462,9 +9592,9 @@ function electrobunArtifacts(appName, platform) {
8462
9592
 
8463
9593
  // src/library/daily-native-observer.ts
8464
9594
  import { execFile as execFile4 } from "child_process";
8465
- import { createHash as createHash16, randomBytes as randomBytes3 } from "crypto";
8466
- import { join as join35, resolve as resolve17 } from "path";
8467
- import { Effect as Effect25 } from "effect";
9595
+ import { createHash as createHash20, randomBytes as randomBytes4 } from "crypto";
9596
+ import { join as join38, resolve as resolve19 } from "path";
9597
+ import { Effect as Effect26 } from "effect";
8468
9598
  var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
8469
9599
  const child = execFile4(process.execPath, ["--no-env-file", script], {
8470
9600
  cwd: input.profile,
@@ -8517,12 +9647,12 @@ function phaseEnvironment(env, profile) {
8517
9647
  ...clean,
8518
9648
  HOME: profile,
8519
9649
  USERPROFILE: profile,
8520
- LOCALAPPDATA: join35(profile, "LocalAppData"),
8521
- XDG_CONFIG_HOME: join35(profile, ".config"),
8522
- XDG_DATA_HOME: join35(profile, ".local", "share"),
8523
- TEMP: join35(profile, "tmp"),
8524
- TMP: join35(profile, "tmp"),
8525
- TMPDIR: join35(profile, "tmp")
9650
+ LOCALAPPDATA: join38(profile, "LocalAppData"),
9651
+ XDG_CONFIG_HOME: join38(profile, ".config"),
9652
+ XDG_DATA_HOME: join38(profile, ".local", "share"),
9653
+ TEMP: join38(profile, "tmp"),
9654
+ TMP: join38(profile, "tmp"),
9655
+ TMPDIR: join38(profile, "tmp")
8526
9656
  };
8527
9657
  }
8528
9658
  function parseBaseline(value, target) {
@@ -8540,9 +9670,9 @@ function driverPath(value) {
8540
9670
  throw new Error("Invalid native observer path");
8541
9671
  return value;
8542
9672
  }
8543
- var fixtureDigest = (nonce) => "sha256:" + createHash16("sha256").update(nonce).digest("hex");
9673
+ var fixtureDigest = (nonce) => "sha256:" + createHash20("sha256").update(nonce).digest("hex");
8544
9674
  var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
8545
- var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
9675
+ var observeDailyNativeEffect = (options, run) => Effect26.gen(function* () {
8546
9676
  const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
8547
9677
  const fs = yield* ReleaseFs;
8548
9678
  const git = yield* ReleaseGit;
@@ -8582,29 +9712,29 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8582
9712
  const tempStat = yield* step(() => fs.lstat(temp));
8583
9713
  if (!tempStat.isDirectory() || tempStat.isSymbolicLink())
8584
9714
  return yield* fail("Expected real runner temp directory");
8585
- const root = yield* Effect25.acquireRelease(step(() => fs.mkdtemp(join35(temp, "daily-native-"))), (dir) => Effect25.promise(() => fs.rm(dir, { recursive: true, force: true })));
8586
- const make = (name) => Effect25.gen(function* () {
8587
- const dir = join35(root, name);
9715
+ const root = yield* Effect26.acquireRelease(step(() => fs.mkdtemp(join38(temp, "daily-native-"))), (dir) => Effect26.promise(() => fs.rm(dir, { recursive: true, force: true })));
9716
+ const make = (name) => Effect26.gen(function* () {
9717
+ const dir = join38(root, name);
8588
9718
  yield* step(() => fs.mkdir(dir, { mode: 448 }));
8589
9719
  return dir;
8590
9720
  });
8591
- const snapshot = (source, target, names) => Effect25.gen(function* () {
8592
- const directory = resolve17(source);
9721
+ const snapshot = (source, target, names) => Effect26.gen(function* () {
9722
+ const directory = resolve19(source);
8593
9723
  const info = yield* step(() => fs.lstat(directory));
8594
9724
  if (!info.isDirectory() || info.isSymbolicLink())
8595
9725
  return yield* fail("Expected real native input directory");
8596
9726
  return yield* stageExpectedFilesEffect({
8597
9727
  expected: names,
8598
9728
  directory: target,
8599
- sources: Object.fromEntries(names.map((name) => [name, join35(directory, name)]))
9729
+ sources: Object.fromEntries(names.map((name) => [name, join38(directory, name)]))
8600
9730
  });
8601
9731
  });
8602
9732
  const scriptName = path.endsWith(".mjs") ? "observer.mjs" : "observer.ts";
8603
- const script = join35(root, scriptName);
9733
+ const script = join38(root, scriptName);
8604
9734
  yield* stageExpectedFilesEffect({
8605
9735
  directory: root,
8606
9736
  expected: [scriptName],
8607
- sources: { [scriptName]: join35(cwd, path) }
9737
+ sources: { [scriptName]: join38(cwd, path) }
8608
9738
  });
8609
9739
  const hash = yield* step(() => git.run(["hash-object", "--no-filters", "--", script]));
8610
9740
  if (hash !== blob)
@@ -8617,9 +9747,9 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8617
9747
  ...previous.kind === "private-from-verified-payload" ? [prior.payload] : []
8618
9748
  ] : undefined;
8619
9749
  const earlier = previous && baseline ? yield* snapshot(previous.directory, baseline, baselineFiles) : undefined;
8620
- const freshProfile = (name) => Effect25.gen(function* () {
9750
+ const freshProfile = (name) => Effect26.gen(function* () {
8621
9751
  const dir = yield* make(name);
8622
- yield* step(() => fs.mkdir(join35(dir, "tmp"), { mode: 448 }));
9752
+ yield* step(() => fs.mkdir(join38(dir, "tmp"), { mode: 448 }));
8623
9753
  return dir;
8624
9754
  });
8625
9755
  const fresh = yield* freshProfile("fresh");
@@ -8642,14 +9772,14 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8642
9772
  if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
8643
9773
  throw new Error("Native observer changed during qualification");
8644
9774
  return output;
8645
- }).pipe(Effect25.mapError(() => new Error(`Native observer phase failed: ${phase}`)));
8646
- const installVersion = (phase, version, where) => Effect25.gen(function* () {
9775
+ }).pipe(Effect26.mapError(() => new Error(`Native observer phase failed: ${phase}`)));
9776
+ const installVersion = (phase, version, where) => Effect26.gen(function* () {
8647
9777
  const result = yield* call(phase, where);
8648
9778
  if (!isRecord(result) || !hasExactOwnKeys(result, ["version"]) || result.version !== version)
8649
9779
  return yield* fail(`Native observer did not observe the expected version: ${phase}`);
8650
9780
  return { version };
8651
9781
  });
8652
- const launch = (phase, version, where) => Effect25.gen(function* () {
9782
+ const launch = (phase, version, where) => Effect26.gen(function* () {
8653
9783
  const result = yield* call(phase, where);
8654
9784
  if (!isRecord(result) || !hasExactOwnKeys(result, ["version", "ready", "stopped"]) || result.version !== version || result.ready !== true || result.stopped !== true)
8655
9785
  return yield* fail(`Native observer did not observe a ready renderer: ${phase}`);
@@ -8662,7 +9792,7 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8662
9792
  const install = yield* installVersion("fresh-install", version, fresh);
8663
9793
  const launchedFresh = yield* launch("fresh-launch", version, fresh);
8664
9794
  const installedBefore = yield* installVersion("baseline-install", previous.tag.slice(1), upgrade);
8665
- const nonce = randomBytes3(24).toString("hex");
9795
+ const nonce = randomBytes4(24).toString("hex");
8666
9796
  const before = yield* call("fixture-write", upgrade, nonce);
8667
9797
  if (!confirmFixture(before, nonce))
8668
9798
  return yield* fail("Native baseline did not observe synthetic fixture");
@@ -8713,27 +9843,27 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8713
9843
  observations
8714
9844
  }
8715
9845
  }, { os, arch });
8716
- }).pipe(Effect25.scoped);
9846
+ }).pipe(Effect26.scoped);
8717
9847
 
8718
9848
  // src/library/daily-batch.ts
8719
- import { join as join36, resolve as resolve18 } from "path";
8720
- import { Effect as Effect26, Exit as Exit4 } from "effect";
8721
- var stageDailyBatchEffect = (options) => Effect26.gen(function* () {
9849
+ import { join as join39, resolve as resolve20 } from "path";
9850
+ import { Effect as Effect27, Exit as Exit4 } from "effect";
9851
+ var stageDailyBatchEffect = (options) => Effect27.gen(function* () {
8722
9852
  const fs = yield* ReleaseFs;
8723
- const parent = resolve18(options.parent);
9853
+ const parent = resolve20(options.parent);
8724
9854
  const root = yield* step(() => fs.lstat(parent));
8725
9855
  if (!root.isDirectory() || root.isSymbolicLink())
8726
9856
  return yield* fail("Daily staging needs an existing real scratch parent");
8727
9857
  const original = yield* verifyDailyReleaseMatrixEffect(options);
8728
9858
  const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, options.identity.tag));
8729
- const directory = yield* Effect26.acquireRelease(step(() => fs.mkdtemp(join36(parent, "daily-candidate-"))), (path, exit) => Exit4.isSuccess(exit) ? Effect26.void : Effect26.promise(() => fs.rm(path, { recursive: true, force: true })));
8730
- const copy = (source, name, expected) => Effect26.gen(function* () {
8731
- const target = join36(directory, name);
9859
+ const directory = yield* Effect27.acquireRelease(step(() => fs.mkdtemp(join39(parent, "daily-candidate-"))), (path, exit) => Exit4.isSuccess(exit) ? Effect27.void : Effect27.promise(() => fs.rm(path, { recursive: true, force: true })));
9860
+ const copy = (source, name, expected) => Effect27.gen(function* () {
9861
+ const target = join39(directory, name);
8732
9862
  yield* step(() => fs.mkdir(target, { mode: 448 }));
8733
9863
  yield* stageExpectedFilesEffect({
8734
9864
  expected,
8735
9865
  directory: target,
8736
- sources: Object.fromEntries(expected.map((file) => [file, join36(source, file)]))
9866
+ sources: Object.fromEntries(expected.map((file) => [file, join39(source, file)]))
8737
9867
  });
8738
9868
  return target;
8739
9869
  });
@@ -8743,26 +9873,26 @@ var stageDailyBatchEffect = (options) => Effect26.gen(function* () {
8743
9873
  if (original.assets.some((a, index) => a.name !== staged.assets[index]?.name || a.size !== staged.assets[index]?.size || a.digest !== staged.assets[index]?.digest))
8744
9874
  return yield* fail("Daily inputs changed between inspection and local staging");
8745
9875
  const manifest = { schema: "framework/daily-staged-batch/v1", ...staged };
8746
- yield* step(() => fs.writeFile(join36(directory, "candidate.json"), JSON.stringify(manifest) + `
9876
+ yield* step(() => fs.writeFile(join39(directory, "candidate.json"), JSON.stringify(manifest) + `
8747
9877
  `, {
8748
9878
  flag: "wx",
8749
9879
  mode: 384
8750
9880
  }));
8751
9881
  return { directory, ...manifest };
8752
- }).pipe(Effect26.scoped);
9882
+ }).pipe(Effect27.scoped);
8753
9883
 
8754
9884
  // src/cli-runner.ts
8755
- import { Cause as Cause3, Effect as Effect27, Exit as Exit5 } from "effect";
9885
+ import { Cause as Cause3, Effect as Effect28, Exit as Exit5 } from "effect";
8756
9886
  function failureError(cause) {
8757
9887
  const error = Cause3.squash(cause);
8758
9888
  if (error instanceof ReleaseFailure)
8759
9889
  return new Error(error.message);
8760
9890
  return error instanceof Error ? error : new Error(String(error));
8761
9891
  }
8762
- var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
9892
+ var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
8763
9893
  const { env } = yield* ReleaseConfig;
8764
9894
  const output = yield* ReleaseOutput;
8765
- const exit = yield* Effect27.exit(options.requireGitHubActions && env.GITHUB_ACTIONS !== "true" ? refuse("untrusted", "Invalid workflow invocation") : program);
9895
+ const exit = yield* Effect28.exit(options.requireGitHubActions && env.GITHUB_ACTIONS !== "true" ? refuse("untrusted", "Invalid workflow invocation") : program);
8766
9896
  if (Exit5.isSuccess(exit))
8767
9897
  return 0;
8768
9898
  if (Cause3.hasInterruptsOnly(exit.cause))
@@ -8773,7 +9903,7 @@ var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
8773
9903
  return 1;
8774
9904
  });
8775
9905
  var readReleaseConfig = (path) => readBoundedJson(path, 262144);
8776
- var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.gen(function* () {
9906
+ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect28.gen(function* () {
8777
9907
  const fs = yield* ReleaseFs;
8778
9908
  const info = yield* step(() => fs.lstat(path));
8779
9909
  if (!info.isFile() || info.size < 1 || info.size > maxBytes)
@@ -8783,27 +9913,27 @@ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.
8783
9913
  return yield* refuse("file-changed", `${name[0].toUpperCase()}${name.slice(1)} changed`);
8784
9914
  return yield* step(async () => JSON.parse(bytes.toString("utf8")));
8785
9915
  });
8786
- var provideLivePorts = (program) => program.pipe(Effect27.provideService(ReleaseConfig, {
9916
+ var provideLivePorts = (program) => program.pipe(Effect28.provideService(ReleaseConfig, {
8787
9917
  env: process.env,
8788
9918
  platform: process.platform,
8789
9919
  arch: process.arch,
8790
9920
  cwd: process.cwd()
8791
- }), Effect27.provideService(ReleaseOutput, {
9921
+ }), Effect28.provideService(ReleaseOutput, {
8792
9922
  stdout: (text) => void process.stdout.write(text),
8793
9923
  stderr: (text) => void process.stderr.write(text)
8794
- }), Effect27.provideService(ReleaseGit, { run: gitRun }), Effect27.provideService(ReleaseGitHub, { run: ghRun, withEnvironment: ghRunWith }), Effect27.provideService(ReleaseFetch, { fetch }), Effect27.provideService(ReleaseClock, {
9924
+ }), Effect28.provideService(ReleaseGit, { run: gitRun }), Effect28.provideService(ReleaseGitHub, { run: ghRun, withEnvironment: ghRunWith }), Effect28.provideService(ReleaseLinuxBuild, liveLinuxBuild), Effect28.provideService(ReleaseFetch, { fetch }), Effect28.provideService(ReleaseClock, {
8795
9925
  sleep: (milliseconds) => Bun.sleep(milliseconds),
8796
9926
  now: () => new Date().toISOString()
8797
- }), Effect27.provideService(ReleaseFs, nodeFs), Effect27.provideService(ReleaseSigning, {
9927
+ }), Effect28.provideService(ReleaseFs, nodeFs), Effect28.provideService(ReleaseSigning, {
8798
9928
  privateKey: environmentKey(process.env),
8799
9929
  codesign: codesignRun
8800
9930
  }));
8801
9931
 
8802
9932
  // src/commands/prepare-stable-catalog.ts
8803
- import { createHash as createHash17 } from "crypto";
8804
- import { createReadStream } from "fs";
8805
- import { lstat as lstat20, mkdir as mkdir12, readFile as readFile11, rm as rm11, writeFile as writeFile12 } from "fs/promises";
8806
- import { basename as basename16, dirname as dirname15, join as join37 } from "path";
9933
+ import { createHash as createHash21 } from "crypto";
9934
+ import { createReadStream as createReadStream3 } from "fs";
9935
+ import { lstat as lstat22, mkdir as mkdir13, readFile as readFile12, rm as rm12, writeFile as writeFile13 } from "fs/promises";
9936
+ import { basename as basename17, dirname as dirname16, join as join40 } from "path";
8807
9937
 
8808
9938
  // src/library/stable-catalogs.ts
8809
9939
  function object(value) {
@@ -8964,10 +10094,10 @@ ShortDescription: ${quoted(desc)}
8964
10094
 
8965
10095
  // src/commands/prepare-stable-catalog.ts
8966
10096
  var read2 = async (path) => {
8967
- const stat = await lstat20(path);
10097
+ const stat = await lstat22(path);
8968
10098
  if (!stat.isFile() || stat.size > 1024 * 1024)
8969
10099
  throw new Error("Expected bounded ordinary JSON file");
8970
- return JSON.parse(await readFile11(path, "utf8"));
10100
+ return JSON.parse(await readFile12(path, "utf8"));
8971
10101
  };
8972
10102
  async function prepareStableCatalogCommand(args) {
8973
10103
  const [
@@ -8984,11 +10114,11 @@ async function prepareStableCatalogCommand(args) {
8984
10114
  ] = args;
8985
10115
  if (channel !== "homebrew" && channel !== "winget" || phase !== "preflight" && phase !== "published-stable" || !expectedSourceSha || !configPath || !receiptPath || !manifestPath || !artifact || !out || extra.length || phase === "published-stable" !== Boolean(stablePointerPath))
8986
10116
  throw new Error("Expected channel, phase, source SHA, config, receipt, manifest, archive, new output directory [stable pointer]");
8987
- const st = await lstat20(artifact);
10117
+ const st = await lstat22(artifact);
8988
10118
  if (!st.isFile())
8989
10119
  throw new Error("Expected ordinary installer file");
8990
- const hash = createHash17("sha256");
8991
- for await (const chunk of createReadStream(artifact))
10120
+ const hash = createHash21("sha256");
10121
+ for await (const chunk of createReadStream3(artifact))
8992
10122
  hash.update(chunk);
8993
10123
  const files = prepareStableCatalog({
8994
10124
  channel,
@@ -8998,31 +10128,297 @@ async function prepareStableCatalogCommand(args) {
8998
10128
  receipt: await read2(receiptPath),
8999
10129
  manifest: await read2(manifestPath),
9000
10130
  stablePointer: stablePointerPath && await read2(stablePointerPath),
9001
- measuredAsset: { name: basename16(artifact), size: st.size, sha256: hash.digest("hex") }
10131
+ measuredAsset: { name: basename17(artifact), size: st.size, sha256: hash.digest("hex") }
9002
10132
  });
9003
- await mkdir12(out);
10133
+ await mkdir13(out);
9004
10134
  try {
9005
10135
  for (const entry of files) {
9006
- const target = join37(out, entry.path);
9007
- await mkdir12(dirname15(target), { recursive: true });
9008
- await writeFile12(target, entry.contents, { flag: "wx" });
10136
+ const target = join40(out, entry.path);
10137
+ await mkdir13(dirname16(target), { recursive: true });
10138
+ await writeFile13(target, entry.contents, { flag: "wx" });
9009
10139
  }
9010
10140
  return { channel, phase, files: files.length };
9011
10141
  } catch (error) {
9012
- await rm11(out, { recursive: true, force: true });
10142
+ await rm12(out, { recursive: true, force: true });
9013
10143
  throw error;
9014
10144
  }
9015
10145
  }
9016
10146
 
10147
+ // src/commands/build-linux-formats.ts
10148
+ import { mkdtemp as mkdtemp12, rename as rename3, rm as rm13 } from "fs/promises";
10149
+ import { tmpdir as tmpdir5 } from "os";
10150
+ import { basename as basename18, dirname as dirname17, isAbsolute as isAbsolute8, join as join41, resolve as resolve21 } from "path";
10151
+ import { Effect as Effect29 } from "effect";
10152
+
10153
+ // src/library/verified-git-source.ts
10154
+ import { createHash as createHash22 } from "crypto";
10155
+ var id2 = /^[a-f0-9]{40}$/;
10156
+ var pathPart = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
10157
+ async function object2(git, type, oid, max) {
10158
+ if (!id2.test(oid))
10159
+ throw new Error("Invalid source object");
10160
+ const bytes = await git(["cat-file", type, oid]);
10161
+ if (bytes.length > max || createHash22("sha1").update(`${type} ${bytes.length}\x00`).update(bytes).digest("hex") !== oid)
10162
+ throw new Error("Source object identity mismatch");
10163
+ return bytes;
10164
+ }
10165
+ async function verifiedSourceCommit(git, sha) {
10166
+ const bytes = await object2(git, "commit", sha, 1024 * 1024);
10167
+ const headers = bytes.toString("utf8").split(`
10168
+
10169
+ `, 1)[0];
10170
+ const trees = [...headers.matchAll(/^tree ([a-f0-9]{40})$/gm)];
10171
+ const committers = [...headers.matchAll(/^committer .* ([1-9][0-9]{0,9}) [+-][0-9]{4}$/gm)];
10172
+ if (trees.length !== 1 || committers.length !== 1)
10173
+ throw new Error("Invalid source commit");
10174
+ return { tree: trees[0][1], epoch: Number(committers[0][1]) };
10175
+ }
10176
+ async function verifiedSourceFile(git, rootTree, path) {
10177
+ const parts = path.split("/");
10178
+ if (path.length > 512 || !parts.length || parts.some((part) => !pathPart.test(part)))
10179
+ throw new Error("Invalid source metadata path");
10180
+ let tree = rootTree;
10181
+ for (let index = 0;index < parts.length; index++) {
10182
+ const bytes = await object2(git, "tree", tree, 8 * 1024 * 1024);
10183
+ let offset = 0;
10184
+ let found;
10185
+ while (offset < bytes.length) {
10186
+ const space = bytes.indexOf(32, offset);
10187
+ const zero = bytes.indexOf(0, space + 1);
10188
+ if (space < 0 || zero < 0 || zero + 21 > bytes.length)
10189
+ throw new Error("Invalid source tree");
10190
+ const mode = bytes.subarray(offset, space).toString("ascii");
10191
+ const name = bytes.subarray(space + 1, zero);
10192
+ if (name.equals(Buffer.from(parts[index]))) {
10193
+ if (found)
10194
+ throw new Error("Duplicate source tree entry");
10195
+ found = { mode, oid: bytes.subarray(zero + 1, zero + 21).toString("hex") };
10196
+ }
10197
+ offset = zero + 21;
10198
+ }
10199
+ if (!found)
10200
+ throw new Error("Missing source metadata");
10201
+ if (index === parts.length - 1) {
10202
+ if (found.mode !== "100644" && found.mode !== "100755")
10203
+ throw new Error("Source metadata must be a regular blob");
10204
+ return object2(git, "blob", found.oid, 262144);
10205
+ }
10206
+ if (found.mode !== "40000" && found.mode !== "040000")
10207
+ throw new Error("Invalid source metadata directory");
10208
+ tree = found.oid;
10209
+ }
10210
+ throw new Error("Missing source metadata");
10211
+ }
10212
+
10213
+ // src/commands/build-linux-formats.ts
10214
+ var sha2563 = /^[a-f0-9]{64}$/;
10215
+ var sourcePath = (path) => path.length <= 512 && path.split("/").every((part) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(part));
10216
+ var exact = (value, required, optional = []) => required.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => required.includes(key) || optional.includes(key));
10217
+ var strings2 = (value, max) => Array.isArray(value) && value.length <= max && value.every((item) => typeof item === "string" && item.length <= 512);
10218
+ function parsePolicy(value) {
10219
+ if (!isRecord(value) || !exact(value, ["schema", "renderer", "appimagetoolSha256", "runtimeSha256", "policy"]) || value.schema !== "linux-format-build-policy/v1" || value.renderer !== "native" && value.renderer !== "cef" || typeof value.appimagetoolSha256 !== "string" || !sha2563.test(value.appimagetoolSha256) || typeof value.runtimeSha256 !== "string" || !sha2563.test(value.runtimeSha256) || !isRecord(value.policy))
10220
+ throw new Error("Invalid Linux format build policy");
10221
+ const p = value.policy;
10222
+ const required = [
10223
+ "bundleRoot",
10224
+ "artifactStem",
10225
+ "packageName",
10226
+ "desktopId",
10227
+ "name",
10228
+ "description",
10229
+ "homepage",
10230
+ "maintainer",
10231
+ "launcher",
10232
+ "icon",
10233
+ "dependencies",
10234
+ "categories",
10235
+ "mimeTypes",
10236
+ "formatEnvironment",
10237
+ "debSetuid"
10238
+ ];
10239
+ const textFields = [
10240
+ "bundleRoot",
10241
+ "artifactStem",
10242
+ "packageName",
10243
+ "desktopId",
10244
+ "name",
10245
+ "description",
10246
+ "homepage",
10247
+ "maintainer",
10248
+ "launcher",
10249
+ "icon",
10250
+ "formatEnvironment"
10251
+ ];
10252
+ if (!exact(p, required, ["executable", "links"]) || textFields.some((key) => typeof p[key] !== "string" || p[key].length > 512 || [...p[key]].some((character) => {
10253
+ const code = character.charCodeAt(0);
10254
+ return code < 32 || code === 127;
10255
+ })) || p.executable !== undefined && (typeof p.executable !== "string" || p.executable.length > 64) || !strings2(p.dependencies, 128) || !strings2(p.categories, 32) || !strings2(p.mimeTypes, 32) || !Array.isArray(p.debSetuid) || p.debSetuid.length > 32 || p.debSetuid.some((pin) => !isRecord(pin) || !exact(pin, ["path", "sha256"]) || typeof pin.path !== "string" || pin.path.length > 512 || typeof pin.sha256 !== "string" || !sha2563.test(pin.sha256)) || p.links !== undefined && (!Array.isArray(p.links) || p.links.length > 32 || p.links.some((link) => !isRecord(link) || !exact(link, ["name", "target"]) || typeof link.name !== "string" || link.name.length > 64 || typeof link.target !== "string" || link.target.length > 512)))
10256
+ throw new Error("Invalid Linux format build policy");
10257
+ return {
10258
+ renderer: value.renderer,
10259
+ appimagetoolSha256: value.appimagetoolSha256,
10260
+ runtimeSha256: value.runtimeSha256,
10261
+ policy: structuredClone(p)
10262
+ };
10263
+ }
10264
+ var buildLinuxFormatsCommand = (args) => runCommand("Unable to build Linux format candidates", Effect29.gen(function* () {
10265
+ const [
10266
+ sourceSha,
10267
+ expectedRepository,
10268
+ expectedRunId,
10269
+ expectedAttempt,
10270
+ expectedChannel,
10271
+ descriptorPath,
10272
+ archive,
10273
+ tool,
10274
+ runtime,
10275
+ output,
10276
+ ...extra
10277
+ ] = args;
10278
+ if (extra.length || !sourceSha || !/^[a-f0-9]{40}$/.test(sourceSha) || !expectedRepository || !isRepositorySlug(expectedRepository) || !expectedRunId || !/^[1-9]\d{0,19}$/.test(expectedRunId) || !expectedAttempt || !/^[1-9]\d{0,8}$/.test(expectedAttempt) || expectedChannel !== "daily" && expectedChannel !== "stable" || !descriptorPath || !archive || !tool || !runtime || !output || ![descriptorPath, archive, tool, runtime, output].every(isAbsolute8))
10279
+ return yield* fail("Expected trusted source, repository, run, attempt and channel, then descriptor, archive, tools and output");
10280
+ const { env, platform, arch, cwd } = yield* ReleaseConfig;
10281
+ if (platform !== "linux" || arch !== "x64" || env.CIRCLECI === "true" && env.CIRCLE_SHA1 !== sourceSha || env.GITLAB_CI === "true" && (env.CI_COMMIT_SHA !== sourceSha || env.CI_PIPELINE_ID !== expectedRunId) || env.GITHUB_ACTIONS === "true" && (env.GITHUB_SHA !== sourceSha || env.GITHUB_RUN_ID !== expectedRunId || env.GITHUB_RUN_ATTEMPT !== expectedAttempt))
10282
+ return yield* fail("Linux source or host does not match the workflow");
10283
+ const linux = yield* ReleaseLinuxBuild;
10284
+ const rawGit = (gitArgs) => linux.git(gitArgs, cwd);
10285
+ const run = async (gitArgs) => (await rawGit(gitArgs)).toString("utf8").trim();
10286
+ const commit = yield* step(() => verifiedSourceCommit(rawGit, sourceSha));
10287
+ const sourceJson = (path) => step(async () => {
10288
+ const contents = await verifiedSourceFile(rawGit, commit.tree, path);
10289
+ return JSON.parse(new TextDecoder("utf8", { fatal: true }).decode(contents));
10290
+ });
10291
+ const manifest = yield* sourceJson("linux-format-build.json");
10292
+ if (!isRecord(manifest) || !exact(manifest, ["schema", "releaseConfig", "policy"]) || manifest.schema !== "linux-format-build-manifest/v1" || typeof manifest.releaseConfig !== "string" || !sourcePath(manifest.releaseConfig) || typeof manifest.policy !== "string" || !sourcePath(manifest.policy) || manifest.releaseConfig === manifest.policy || manifest.releaseConfig === "linux-format-build.json" || manifest.policy === "linux-format-build.json")
10293
+ return yield* fail("Invalid source Linux format manifest");
10294
+ const config = yield* sourceJson(manifest.releaseConfig);
10295
+ const policyValue = yield* sourceJson(manifest.policy);
10296
+ const metadata = yield* step(async () => parsePolicy(policyValue));
10297
+ const parsed = yield* step(async () => parseReleaseConfig(config));
10298
+ const sourceManifest = yield* sourceJson(parsed.versionSource.path);
10299
+ const provenance = yield* resolveLocalProvenanceEffect({
10300
+ sourceSha,
10301
+ versionSourcePath: parsed.versionSource.path
10302
+ }).pipe(Effect29.provideService(ReleaseGit, { run }));
10303
+ if (!isRecord(config) || typeof config.repository !== "string" || config.repository !== expectedRepository || config.repository !== provenance.repository || !isRecord(sourceManifest) || sourceManifest.version !== provenance.releasedVersion || typeof config.appName !== "string" || typeof config.appId !== "string")
10304
+ return yield* fail("Source release identity does not match the checkout");
10305
+ const signed = yield* readBoundedJson(descriptorPath, 65536, "signed descriptor");
10306
+ if (!isRecord(signed) || !isRecord(signed.descriptor) || signed.descriptor.channel !== "daily" && signed.descriptor.channel !== "stable")
10307
+ return yield* fail("Invalid signed descriptor");
10308
+ const channel = signed.descriptor.channel;
10309
+ if (channel !== expectedChannel)
10310
+ return yield* fail("Descriptor channel differs from the requested channel");
10311
+ const tag = `v${provenance.releasedVersion}`;
10312
+ const selected = yield* step(async () => discoveryPolicies(config, tag).find((candidate) => candidate.appId === config.appId && candidate.platform === "linux-x64" && candidate.channel === channel));
10313
+ if (!selected)
10314
+ return yield* fail("Missing Linux desktop descriptor policy");
10315
+ const verified = yield* step(async () => verifyReleaseDescriptor(signed, {
10316
+ appId: selected.appId,
10317
+ repository: provenance.repository,
10318
+ channel: selected.channel,
10319
+ platform: selected.os,
10320
+ arch: selected.arch,
10321
+ feed: feedUrl(parsed.feed),
10322
+ keys: releaseVerificationKeys(config)
10323
+ }));
10324
+ if (!verified.ok || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.runId !== expectedRunId || verified.descriptor.runAttempt !== Number(expectedAttempt) || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== selected.payload || metadata.policy.bundleRoot !== config.appName.replaceAll(" ", "") || metadata.policy.desktopId !== config.appId || `${metadata.policy.artifactStem}-${tag}-linux-x64.tar.zst` !== selected.payload || basename18(archive) !== selected.payload)
10325
+ return yield* fail("Descriptor, source and Linux package identity differ");
10326
+ const receipt = yield* Effect29.callback((resume, signal) => {
10327
+ const promise = (async () => {
10328
+ signal.throwIfAborted();
10329
+ const scratch = await mkdtemp12(join41(tmpdir5(), "adea-linux-formats-"));
10330
+ let scratchCleaned = false;
10331
+ try {
10332
+ signal.throwIfAborted();
10333
+ const result = await buildLinuxFormats({
10334
+ tag,
10335
+ sourceSha,
10336
+ expectedSourceSha: sourceSha,
10337
+ sourceDateEpoch: commit.epoch,
10338
+ identity: {
10339
+ workflowSha: sourceSha,
10340
+ runId: expectedRunId,
10341
+ runAttempt: Number(expectedAttempt)
10342
+ },
10343
+ archive: { path: archive, sha256: verified.descriptor.asset.sha256 },
10344
+ tool: { path: tool, sha256: metadata.appimagetoolSha256 },
10345
+ runtime: { path: runtime, sha256: metadata.runtimeSha256 },
10346
+ policy: metadata.policy,
10347
+ output: resolve21(output)
10348
+ }, {
10349
+ os: platform,
10350
+ arch,
10351
+ signal,
10352
+ afterWorkCleanup: async () => {
10353
+ await rm13(scratch, { recursive: true, force: true });
10354
+ scratchCleaned = true;
10355
+ },
10356
+ inspectAppArchive: async () => {
10357
+ throw new Error("Unsafe archive inspection path");
10358
+ },
10359
+ extractVerifiedAppArchive: async (copy, destination) => {
10360
+ const extracted = await extractVerifiedUpdate({
10361
+ descriptor: verified.descriptor,
10362
+ archive: copy,
10363
+ directory: dirname17(destination),
10364
+ platform: "linux-x64",
10365
+ renderer: metadata.renderer,
10366
+ appName: config.appName,
10367
+ sidecars: parsed.sidecars,
10368
+ maxCompressedBytes: 1024 ** 3,
10369
+ maxExpandedBytes: 8 * 1024 ** 3
10370
+ });
10371
+ try {
10372
+ await rename3(extracted.payload, join41(destination, metadata.policy.bundleRoot));
10373
+ } finally {
10374
+ await rm13(extracted.directory, { recursive: true, force: true });
10375
+ }
10376
+ },
10377
+ run: async (name, toolArgs, options) => {
10378
+ if (name !== "dpkg-deb" && name !== "appimagetool")
10379
+ throw new Error("Unexpected Linux build tool");
10380
+ const executable = name === "dpkg-deb" ? "/usr/bin/dpkg-deb" : options?.executable;
10381
+ if (!executable || !isAbsolute8(executable))
10382
+ throw new Error("Invalid Linux build tool");
10383
+ await linux.tool(executable, toolArgs, {
10384
+ PATH: "/usr/bin:/bin",
10385
+ HOME: scratch,
10386
+ TMPDIR: scratch,
10387
+ ...options?.env
10388
+ }, signal);
10389
+ }
10390
+ });
10391
+ return result;
10392
+ } finally {
10393
+ if (!scratchCleaned)
10394
+ await rm13(scratch, { recursive: true, force: true });
10395
+ }
10396
+ })();
10397
+ promise.then((value) => resume(Effect29.succeed(value)), (error) => resume(Effect29.fail(new ReleaseFailure({
10398
+ reason: "step",
10399
+ message: error instanceof Error ? error.message : String(error),
10400
+ original: error
10401
+ }))));
10402
+ return Effect29.promise(() => promise.then(() => {
10403
+ return;
10404
+ }, () => {
10405
+ return;
10406
+ }));
10407
+ });
10408
+ const { stdout } = yield* ReleaseOutput;
10409
+ stdout(JSON.stringify(receipt) + `
10410
+ `);
10411
+ }));
10412
+
9017
10413
  // src/library/apt/stage-apt-repository.ts
9018
10414
  import { spawnSync as spawnSync2 } from "child_process";
9019
- import { mkdir as mkdir13, readFile as readFile12, rm as rm12, writeFile as writeFile13 } from "fs/promises";
9020
- import { dirname as dirname16, isAbsolute as isAbsolute6, join as join38 } from "path";
10415
+ import { mkdir as mkdir14, readFile as readFile13, rm as rm14, writeFile as writeFile14 } from "fs/promises";
10416
+ import { dirname as dirname18, isAbsolute as isAbsolute9, join as join42 } from "path";
9021
10417
 
9022
10418
  // src/library/apt/apt-metadata.ts
9023
- import { createHash as createHash18 } from "crypto";
10419
+ import { createHash as createHash23 } from "crypto";
9024
10420
  import { gzipSync } from "zlib";
9025
- var sha256 = (data) => createHash18("sha256").update(data).digest("hex");
10421
+ var sha2564 = (data) => createHash23("sha256").update(data).digest("hex");
9026
10422
  function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
9027
10423
  if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
9028
10424
  throw new Error("Invalid release tag");
@@ -9033,7 +10429,7 @@ function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
9033
10429
  if (matching.length !== 1)
9034
10430
  throw new Error("Require one staged Debian artifact");
9035
10431
  const asset = matching[0];
9036
- if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha256(deb))
10432
+ if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2564(deb))
9037
10433
  throw new Error("Staged Debian bytes do not match the verified release inventory");
9038
10434
  const fields = new Map;
9039
10435
  let lines = control.replaceAll(`\r
@@ -9083,7 +10479,7 @@ SHA256: ${asset.sha256}
9083
10479
  "Components: main",
9084
10480
  "Acquire-By-Hash: yes",
9085
10481
  "SHA256:",
9086
- ...members.map(([path, bytes]) => ` ${sha256(bytes)} ${bytes.length} ${path}`),
10482
+ ...members.map(([path, bytes]) => ` ${sha2564(bytes)} ${bytes.length} ${path}`),
9087
10483
  ""
9088
10484
  ].join(`
9089
10485
  `);
@@ -9092,7 +10488,7 @@ SHA256: ${asset.sha256}
9092
10488
  release,
9093
10489
  files: new Map([
9094
10490
  ...members,
9095
- ...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha256(bytes)}`, bytes])
10491
+ ...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2564(bytes)}`, bytes])
9096
10492
  ])
9097
10493
  };
9098
10494
  }
@@ -9105,22 +10501,22 @@ function cmd(program, options, label) {
9105
10501
  return run.stdout;
9106
10502
  }
9107
10503
  async function add(path, bytes) {
9108
- await mkdir13(dirname16(path), { recursive: true });
9109
- await writeFile13(path, bytes, { flag: "wx" });
10504
+ await mkdir14(dirname18(path), { recursive: true });
10505
+ await writeFile14(path, bytes, { flag: "wx" });
9110
10506
  }
9111
10507
  async function stageAptRepositoryCommand(args) {
9112
10508
  const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
9113
- if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute6(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
10509
+ if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute9(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
9114
10510
  throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
9115
- const policy = JSON.parse(await readFile12(policyPath, "utf8"));
9116
- const inventory = JSON.parse(await readFile12(inventoryPath, "utf8"));
10511
+ const policy = JSON.parse(await readFile13(policyPath, "utf8"));
10512
+ const inventory = JSON.parse(await readFile13(inventoryPath, "utf8"));
9117
10513
  if (inventory.tag !== tag || !Array.isArray(inventory.assets))
9118
10514
  throw new Error("Verified inventory does not name requested release");
9119
- const deb = await readFile12(packagePath);
9120
- await mkdir13(output, { mode: 448 });
10515
+ const deb = await readFile13(packagePath);
10516
+ await mkdir14(output, { mode: 448 });
9121
10517
  try {
9122
- const stagedInput = join38(output, ".input.deb");
9123
- await writeFile13(stagedInput, deb, { mode: 384, flag: "wx" });
10518
+ const stagedInput = join42(output, ".input.deb");
10519
+ await writeFile14(stagedInput, deb, { mode: 384, flag: "wx" });
9124
10520
  const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
9125
10521
  const staged = stageAptMetadata({
9126
10522
  policy,
@@ -9130,11 +10526,11 @@ async function stageAptRepositoryCommand(args) {
9130
10526
  control,
9131
10527
  now: new Date
9132
10528
  });
9133
- const base = join38(output, "dists", policy.suite);
9134
- await add(join38(output, staged.packagePath), deb);
10529
+ const base = join42(output, "dists", policy.suite);
10530
+ await add(join42(output, staged.packagePath), deb);
9135
10531
  for (const [path, contents] of staged.files)
9136
- await add(join38(base, path), contents);
9137
- await add(join38(base, "Release"), staged.release);
10532
+ await add(join42(base, path), contents);
10533
+ await add(join42(base, "Release"), staged.release);
9138
10534
  const flags = [
9139
10535
  "--batch",
9140
10536
  "--no-tty",
@@ -9151,34 +10547,37 @@ async function stageAptRepositoryCommand(args) {
9151
10547
  ["InRelease", "--clearsign"],
9152
10548
  ["Release.gpg", "--detach-sign"]
9153
10549
  ]) {
9154
- cmd("gpg", [...flags, "--armor", "--output", join38(base, name), mode, join38(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
10550
+ cmd("gpg", [...flags, "--armor", "--output", join42(base, name), mode, join42(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
9155
10551
  }
9156
10552
  const { unlink } = await import("fs/promises");
9157
10553
  await unlink(stagedInput);
9158
- await add(join38(output, "STAGED"), `${tag}
10554
+ await add(join42(output, "STAGED"), `${tag}
9159
10555
  `);
9160
10556
  return { tag, staged: true };
9161
10557
  } catch (error) {
9162
- await rm12(output, { recursive: true, force: true });
10558
+ await rm14(output, { recursive: true, force: true });
9163
10559
  throw error;
9164
10560
  }
9165
10561
  }
9166
10562
 
9167
10563
  // src/linux-channel-proof-cli.ts
9168
10564
  import { spawnSync as spawnSync3 } from "child_process";
9169
- import { createHash as createHash19 } from "crypto";
9170
- import { createReadStream as createReadStream2 } from "fs";
9171
- import { lstat as lstat21, readFile as readFile13, realpath as realpath11 } from "fs/promises";
9172
- import { join as join39 } from "path";
10565
+ import { createHash as createHash24 } from "crypto";
10566
+ import { createReadStream as createReadStream4 } from "fs";
10567
+ import { constants as constants8, createWriteStream as createWriteStream2 } from "fs";
10568
+ import { lstat as lstat23, mkdtemp as mkdtemp13, open as open15, readFile as readFile14, realpath as realpath13, rm as rm15 } from "fs/promises";
10569
+ import { tmpdir as tmpdir6 } from "os";
10570
+ import { basename as basename19, join as join43 } from "path";
10571
+ import { pipeline as pipeline3 } from "stream/promises";
9173
10572
  import { pathToFileURL } from "url";
9174
- function check(ok, message) {
10573
+ function check3(ok, message) {
9175
10574
  if (!ok)
9176
10575
  throw new Error(message);
9177
10576
  }
9178
- async function hash(path) {
9179
- check((await lstat21(path)).isFile(), "artifact must be a regular file");
9180
- const digest = createHash19("sha256");
9181
- for await (const chunk of createReadStream2(path))
10577
+ async function hash2(path) {
10578
+ check3((await lstat23(path)).isFile(), "artifact must be a regular file");
10579
+ const digest = createHash24("sha256");
10580
+ for await (const chunk of createReadStream4(path))
9182
10581
  digest.update(chunk);
9183
10582
  return digest.digest("hex");
9184
10583
  }
@@ -9194,56 +10593,139 @@ function options(text, section) {
9194
10593
  continue;
9195
10594
  }
9196
10595
  const field = /^([a-z_]+)\s*=\s*(\S+)$/.exec(line);
9197
- check(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
10596
+ check3(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
9198
10597
  values.set(field[1], field[2]);
9199
10598
  }
9200
- check(matched, "expected exactly one repository section");
10599
+ check3(matched, "expected exactly one repository section");
9201
10600
  return values;
9202
10601
  }
9203
10602
  async function verifyRpmStage(stage) {
9204
- check(/^[0-9a-f]{40}$/.test(stage.sourceSha), "expected an exact source commit");
9205
- check(/^[a-z0-9][a-z0-9._+-]*$/.test(stage.packageName), "invalid RPM package name");
9206
- check(/^[a-zA-Z0-9][a-zA-Z0-9._+~^]*$/.test(stage.version), "invalid RPM version");
9207
- check(stage.architecture === "x86_64", "only x86_64 is supported");
9208
- check(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/.test(stage.repoId), "invalid repository ID");
10603
+ check3(/^[0-9a-f]{40}$/.test(stage.sourceSha), "expected an exact source commit");
10604
+ check3(/^[a-z0-9][a-z0-9._+-]*$/.test(stage.packageName), "invalid RPM package name");
10605
+ check3(/^[a-zA-Z0-9][a-zA-Z0-9._+~^]*$/.test(stage.version), "invalid RPM version");
10606
+ check3(stage.architecture === "x86_64", "only x86_64 is supported");
10607
+ check3(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/.test(stage.repoId), "invalid repository ID");
10608
+ if (stage.payload.expectedName !== undefined) {
10609
+ check3(/^[a-zA-Z0-9][a-zA-Z0-9._+-]*$/.test(stage.payload.expectedName) && basename19(stage.payload.path) === stage.payload.expectedName, "portable payload filename does not match the configured name");
10610
+ }
9209
10611
  for (const artifact of [stage.payload, stage.rpm]) {
9210
- check(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
9211
- check(await hash(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
9212
- }
9213
- const repo = await realpath11(stage.repository);
9214
- const keyUrl = pathToFileURL(await realpath11(stage.publicKey)).href;
9215
- const config = options(await readFile13(stage.repoFile, "utf8"), stage.repoId);
9216
- check(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
9217
- check(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
10612
+ check3(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
10613
+ check3(await hash2(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
10614
+ }
10615
+ const repo = await realpath13(stage.repository);
10616
+ const keyUrl = pathToFileURL(await realpath13(stage.publicKey)).href;
10617
+ const config = options(await readFile14(stage.repoFile, "utf8"), stage.repoId);
10618
+ check3(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
10619
+ check3(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
9218
10620
  for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
9219
- check(config.get(flag) === "1", `${flag} must be enabled`);
10621
+ check3(config.get(flag) === "1", `${flag} must be enabled`);
9220
10622
  }
9221
10623
  const allowed = new Set(["name", "enabled", "baseurl", "gpgkey", "pkg_gpgcheck", "repo_gpgcheck"]);
9222
- check([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
10624
+ check3([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
9223
10625
  for (const path of [
9224
10626
  stage.publicKey,
9225
- join39(repo, "repodata/repomd.xml"),
9226
- join39(repo, "repodata/repomd.xml.asc")
10627
+ join43(repo, "repodata/repomd.xml"),
10628
+ join43(repo, "repodata/repomd.xml.asc")
9227
10629
  ]) {
9228
- check((await lstat21(path)).isFile(), "expected regular key and signed metadata files");
10630
+ check3((await lstat23(path)).isFile(), "expected regular key and signed metadata files");
9229
10631
  }
9230
- const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath11(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
9231
- check(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
9232
- check(result.status === 0 && result.stdout === `${stage.packageName}|${stage.version}|${stage.architecture}`, "RPM header does not match the requested package, version and architecture");
10632
+ const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath13(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
10633
+ check3(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
10634
+ check3(result.status === 0 && result.stdout === `${stage.packageName}|${stage.version}|${stage.architecture}`, "RPM header does not match the requested package, version and architecture");
9233
10635
  return { kind: "rpm-staging-inputs", sourceSha: stage.sourceSha };
9234
10636
  }
10637
+ async function verifySignedRpmStage(stage, fingerprint) {
10638
+ check3(/^[A-F0-9]{40}$/.test(fingerprint), "expected an independently trusted full primary fingerprint");
10639
+ await verifyRpmStage(stage);
10640
+ const root = await mkdtemp13(join43(tmpdir6(), "rpm-signature-proof-"));
10641
+ const rpm = join43(root, "package.rpm");
10642
+ const key = join43(root, "key.asc");
10643
+ const metadata = join43(root, "repomd.xml");
10644
+ const signature = join43(root, "repomd.xml.asc");
10645
+ const originalMetadata = join43(stage.repository, "repodata/repomd.xml");
10646
+ const originalSignature = `${originalMetadata}.asc`;
10647
+ const snapshot = async (source, target, max) => {
10648
+ const file = await open15(source, constants8.O_RDONLY | constants8.O_NOFOLLOW);
10649
+ try {
10650
+ const info = await file.stat();
10651
+ check3(info.isFile() && info.size > 0 && info.size <= max, "invalid signed input file");
10652
+ await pipeline3(file.createReadStream({ autoClose: false }), createWriteStream2(target, { flags: "wx", mode: 384 }));
10653
+ } finally {
10654
+ await file.close();
10655
+ }
10656
+ };
10657
+ const isolatedEnv = { PATH: "/usr/bin:/bin", HOME: root, GNUPGHOME: root, LANG: "C" };
10658
+ const command = (name, args) => {
10659
+ const result = spawnSync3(`/usr/bin/${name}`, args, {
10660
+ encoding: "utf8",
10661
+ timeout: 30000,
10662
+ maxBuffer: 2 * 1024 * 1024,
10663
+ env: isolatedEnv
10664
+ });
10665
+ check3(result.status === 0, `${name} signature verification failed`);
10666
+ return result.stdout;
10667
+ };
10668
+ try {
10669
+ await snapshot(stage.rpm.path, rpm, 4 * 1024 * 1024 * 1024);
10670
+ await snapshot(stage.publicKey, key, 1024 * 1024);
10671
+ await snapshot(originalMetadata, metadata, 8 * 1024 * 1024);
10672
+ await snapshot(originalSignature, signature, 1024 * 1024);
10673
+ check3(await hash2(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
10674
+ const gpg = ["--no-options", "--batch", "--homedir", root, "--no-auto-key-retrieve"];
10675
+ const list = command("gpg", [...gpg, "--with-colons", "--fingerprint", "--show-keys", key]);
10676
+ const lines = list.split(`
10677
+ `).map((line) => line.split(":"));
10678
+ check3(!lines.some((fields) => fields[0] === "sec" || fields[0] === "ssb"), "public key input contains secret key material");
10679
+ const keys = lines.flatMap((fields, index) => fields[0] === "pub" ? [lines.slice(index + 1).find((line) => line[0] === "fpr")?.[9]] : []);
10680
+ check3(keys.length === 1 && keys[0] === fingerprint, "public key does not match the pinned primary fingerprint");
10681
+ command("gpg", [...gpg, "--import", key]);
10682
+ const verified = command("gpg", [...gpg, "--status-fd", "1", "--verify", signature, metadata]);
10683
+ const signatures = verified.split(`
10684
+ `).filter((line) => line.startsWith("[GNUPG:] VALIDSIG "));
10685
+ check3(signatures.length === 1 && signatures[0].split(" ").at(-1) === fingerprint, "metadata signer does not match pinned primary fingerprint");
10686
+ const db = join43(root, "rpmdb");
10687
+ command("rpm", ["--dbpath", db, "--initdb"]);
10688
+ command("rpmkeys", ["--dbpath", db, "--import", key]);
10689
+ command("rpmkeys", ["--dbpath", db, "--define", "_pkgverify_level all", "--checksig", rpm]);
10690
+ const identity = command("rpm", [
10691
+ "--dbpath",
10692
+ db,
10693
+ "-qp",
10694
+ "--queryformat",
10695
+ "%{NAME}|%{EPOCHNUM}|%{VERSION}|%{RELEASE}|%{ARCH}",
10696
+ rpm
10697
+ ]);
10698
+ const rpmIdentity = identity.split("|");
10699
+ check3(rpmIdentity.length === 5 && rpmIdentity[0] === stage.packageName && /^[0-9]+$/.test(rpmIdentity[1]) && rpmIdentity[2] === stage.version && /^[A-Za-z0-9][A-Za-z0-9._+~^]*$/.test(rpmIdentity[3]) && rpmIdentity[4] === stage.architecture, "signed RPM header does not match the requested package");
10700
+ const rpmSha256 = await hash2(rpm);
10701
+ const metadataSha256 = await hash2(metadata);
10702
+ const signatureSha256 = await hash2(signature);
10703
+ check3(await hash2(stage.rpm.path) === rpmSha256 && await hash2(originalMetadata) === metadataSha256 && await hash2(originalSignature) === signatureSha256, "signed inputs changed during verification");
10704
+ return {
10705
+ kind: "rpm-signature-proof",
10706
+ sourceSha: stage.sourceSha,
10707
+ fingerprint,
10708
+ rpmIdentity,
10709
+ rpmSha256,
10710
+ metadataSha256,
10711
+ signatureSha256
10712
+ };
10713
+ } finally {
10714
+ await rm15(root, { recursive: true, force: true });
10715
+ }
10716
+ }
9235
10717
  var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
9236
10718
  function verifyFlatpakCapabilities(policy, result) {
9237
- check(/^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/.test(policy.applicationId) && result.applicationId === policy.applicationId, "unexpected Flatpak app identity");
9238
- check(/^[0-9a-f]{40}$/.test(policy.sourceSha) && result.sourceSha === policy.sourceSha && /^[0-9a-f]{64}$/.test(policy.artifactSha256) && result.artifactSha256 === policy.artifactSha256, "Flatpak evidence does not match the expected source and artifact");
9239
- check(result.architecture === "x86_64", "only x86_64 is supported");
10719
+ check3(/^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/.test(policy.applicationId) && result.applicationId === policy.applicationId, "unexpected Flatpak app identity");
10720
+ check3(/^[0-9a-f]{40}$/.test(policy.sourceSha) && result.sourceSha === policy.sourceSha && /^[0-9a-f]{64}$/.test(policy.artifactSha256) && result.artifactSha256 === policy.artifactSha256, "Flatpak evidence does not match the expected source and artifact");
10721
+ check3(result.architecture === "x86_64", "only x86_64 is supported");
9240
10722
  const cap = policy.permissions;
9241
10723
  const actual = result.effectivePermissions;
9242
- check(cap.sockets.every((name) => name === "wayland" || name === "pulseaudio"), "unsafe socket policy");
9243
- check(cap.devices.every((name) => name === "dri"), "unsafe device policy");
9244
- check(cap.sessionTalkNames.every((name) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(name) && !systemTalkDenied.test(name)), "unsafe session-bus policy");
9245
- check(typeof actual.network === "boolean" && typeof cap.network === "boolean" && (!actual.network || cap.network === true) && actual.sockets.every((name) => cap.sockets.some((allowed) => allowed === name)) && actual.devices.every((name) => cap.devices.some((allowed) => allowed === name)) && actual.sessionTalkNames.every((name) => cap.sessionTalkNames.includes(name)) && actual.filesystems.length === 0 && actual.systemTalkNames.length === 0, "effective Flatpak permissions exceed policy");
9246
- check([
10724
+ check3(cap.sockets.every((name) => name === "wayland" || name === "pulseaudio"), "unsafe socket policy");
10725
+ check3(cap.devices.every((name) => name === "dri"), "unsafe device policy");
10726
+ check3(cap.sessionTalkNames.every((name) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(name) && !systemTalkDenied.test(name)), "unsafe session-bus policy");
10727
+ check3(typeof actual.network === "boolean" && typeof cap.network === "boolean" && (!actual.network || cap.network === true) && actual.sockets.every((name) => cap.sockets.some((allowed) => allowed === name)) && actual.devices.every((name) => cap.devices.some((allowed) => allowed === name)) && actual.sessionTalkNames.every((name) => cap.sessionTalkNames.includes(name)) && actual.filesystems.length === 0 && actual.systemTalkNames.length === 0, "effective Flatpak permissions exceed policy");
10728
+ check3([
9247
10729
  result.localRepositoryInstall,
9248
10730
  result.upgradedAndRetainedData,
9249
10731
  result.sandboxedRenderer,
@@ -9256,11 +10738,181 @@ function verifyFlatpakCapabilities(policy, result) {
9256
10738
  return { kind: "flatpak-observations", sourceSha: result.sourceSha };
9257
10739
  }
9258
10740
 
10741
+ // src/linux-rpm-metadata-proof.ts
10742
+ import { spawnSync as spawnSync4 } from "child_process";
10743
+ import { createHash as createHash25 } from "crypto";
10744
+ import { constants as constants9 } from "fs";
10745
+ import { lstat as lstat24, open as open16, realpath as realpath14 } from "fs/promises";
10746
+ import { isAbsolute as isAbsolute10, join as join44, relative as relative7, resolve as resolve22 } from "path";
10747
+ import { gunzipSync } from "zlib";
10748
+ var maxCompressed = 16 * 1024 * 1024;
10749
+ var maxOpen = 32 * 1024 * 1024;
10750
+ var digest4 = (bytes) => createHash25("sha256").update(bytes).digest("hex");
10751
+ function ensure(ok, reason) {
10752
+ if (!ok)
10753
+ throw new Error(reason);
10754
+ }
10755
+ var xmlReader = String.raw`
10756
+ import json, re, sys, xml.etree.ElementTree as ET
10757
+ class Bounded(ET.TreeBuilder):
10758
+ def __init__(self): super().__init__(); self.depth=0; self.count=0
10759
+ def start(self, tag, attrs):
10760
+ self.depth+=1; self.count+=1
10761
+ if self.depth>64 or self.count>100000: raise ValueError('XML bounds')
10762
+ return super().start(tag, attrs)
10763
+ def end(self, tag):
10764
+ self.depth-=1; return super().end(tag)
10765
+ data=sys.stdin.buffer.read(33554433)
10766
+ if len(data)>33554432 or b'\0' in data or re.search(br'<!\s*(DOCTYPE|ENTITY)', data, re.I): raise ValueError('unsafe XML')
10767
+ parser=ET.XMLParser(target=Bounded()); parser.feed(data.decode('utf-8')); root=parser.close()
10768
+ def single(parent, name):
10769
+ items=parent.findall(name)
10770
+ if len(items)!=1: raise ValueError('ambiguous XML field')
10771
+ return items[0]
10772
+ def text(parent, name):
10773
+ element=single(parent,name)
10774
+ if len(element) or element.text is None: raise ValueError('invalid XML text')
10775
+ return element.text.strip()
10776
+ def attrs(element, names):
10777
+ if set(element.attrib)!=set(names): raise ValueError('unexpected XML attributes')
10778
+ if sys.argv[1]=='repomd':
10779
+ ns='{http://linux.duke.edu/metadata/repo}'
10780
+ if root.tag!=ns+'repomd': raise ValueError('invalid repomd root')
10781
+ prim=[x for x in root.findall(ns+'data') if x.get('type')=='primary']
10782
+ if len(prim)!=1: raise ValueError('ambiguous primary metadata')
10783
+ p=prim[0]; loc=single(p,ns+'location'); attrs(loc,['href'])
10784
+ ch=single(p,ns+'checksum'); attrs(ch,['type'])
10785
+ op=single(p,ns+'open-checksum'); attrs(op,['type'])
10786
+ if ch.get('type')!='sha256' or op.get('type')!='sha256': raise ValueError('unsupported checksum')
10787
+ print(json.dumps({'href':loc.get('href'),'checksum':ch.text.strip(),'openChecksum':op.text.strip(),'size':int(text(p,ns+'size')),'openSize':int(text(p,ns+'open-size'))}))
10788
+ else:
10789
+ ns='{http://linux.duke.edu/metadata/common}'
10790
+ if root.tag!=ns+'metadata': raise ValueError('invalid primary root')
10791
+ name, epoch, version, release, arch, expected_href, expected_hash, expected_size=sys.argv[2:]
10792
+ identities=[]; paths=[]
10793
+ for p in root.findall(ns+'package'):
10794
+ if p.get('type')!='rpm': raise ValueError('unexpected package type')
10795
+ loc=single(p,ns+'location'); attrs(loc,['href']); href=loc.get('href'); paths.append(href)
10796
+ v=single(p,ns+'version'); attrs(v,['epoch','ver','rel'])
10797
+ if text(p,ns+'name')==name and text(p,ns+'arch')==arch and (v.get('epoch'),v.get('ver'),v.get('rel'))==(epoch,version,release): identities.append(p)
10798
+ if len(identities)!=1 or paths.count(expected_href)!=1: raise ValueError('ambiguous package identity or path')
10799
+ p=identities[0]; loc=single(p,ns+'location'); ch=single(p,ns+'checksum'); size=single(p,ns+'size')
10800
+ if loc.get('href')!=expected_href or ch.get('type')!='sha256' or ch.get('pkgid')!='YES' or (ch.text or '').strip()!=expected_hash or size.get('package')!=expected_size: raise ValueError('RPM metadata differs')
10801
+ print(json.dumps({'href':expected_href}))
10802
+ `;
10803
+ function parseXml(kind, bytes, args = []) {
10804
+ const result = spawnSync4("/usr/bin/python3", ["-I", "-S", "-c", xmlReader, kind, ...args], {
10805
+ input: bytes,
10806
+ encoding: "utf8",
10807
+ timeout: 30000,
10808
+ maxBuffer: 64 * 1024,
10809
+ env: { PATH: "/usr/bin:/bin", LANG: "C" }
10810
+ });
10811
+ ensure(result.status === 0, `Invalid ${kind} XML or package binding`);
10812
+ return JSON.parse(result.stdout);
10813
+ }
10814
+ async function readRegular(path, limit) {
10815
+ const file = await open16(path, constants9.O_RDONLY | constants9.O_NOFOLLOW);
10816
+ try {
10817
+ const stat = await file.stat();
10818
+ ensure(stat.isFile() && stat.size > 0 && stat.size <= limit, "Invalid repository file");
10819
+ const bytes = Buffer.allocUnsafe(stat.size + 1);
10820
+ let total = 0;
10821
+ while (total < bytes.length) {
10822
+ const { bytesRead } = await file.read(bytes, total, bytes.length - total, null);
10823
+ if (!bytesRead)
10824
+ break;
10825
+ total += bytesRead;
10826
+ }
10827
+ ensure(total === stat.size, "Repository file changed while reading");
10828
+ return bytes.subarray(0, total);
10829
+ } finally {
10830
+ await file.close();
10831
+ }
10832
+ }
10833
+ async function digestRegular(path, expectedSize) {
10834
+ const file = await open16(path, constants9.O_RDONLY | constants9.O_NOFOLLOW);
10835
+ try {
10836
+ const stat = await file.stat();
10837
+ ensure(stat.isFile() && stat.size === expectedSize && stat.size > 0 && stat.size <= 4 * 1024 * 1024 * 1024, "Invalid RPM file");
10838
+ const hash = createHash25("sha256");
10839
+ let size = 0;
10840
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
10841
+ size += chunk.length;
10842
+ ensure(size <= expectedSize, "RPM changed while reading");
10843
+ hash.update(chunk);
10844
+ }
10845
+ ensure(size === expectedSize, "RPM changed while reading");
10846
+ return hash.digest("hex");
10847
+ } finally {
10848
+ await file.close();
10849
+ }
10850
+ }
10851
+ async function contained(repo, href) {
10852
+ ensure(!isAbsolute10(href) && href.length <= 1024, "Invalid repository path");
10853
+ const parts = href.split("/");
10854
+ ensure(parts.every((part) => /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(part)), "Invalid repository path");
10855
+ let current = repo;
10856
+ for (let i = 0;i < parts.length; i++) {
10857
+ current = join44(current, parts[i]);
10858
+ const info = await lstat24(current);
10859
+ ensure(i === parts.length - 1 ? info.isFile() : info.isDirectory(), "Unsafe repository path");
10860
+ }
10861
+ ensure(await realpath14(current) === current, "Repository path resolves outside its location");
10862
+ return current;
10863
+ }
10864
+ async function verifyRpmRepository(stage, fingerprint) {
10865
+ const proof = await verifySignedRpmStage(stage, fingerprint);
10866
+ const repo = await realpath14(stage.repository);
10867
+ const metadata = await readRegular(await contained(repo, "repodata/repomd.xml"), 8 * 1024 * 1024);
10868
+ ensure(digest4(metadata) === proof.metadataSha256, "Signed repomd changed");
10869
+ const record = parseXml("repomd", metadata);
10870
+ const href = record.href;
10871
+ const packedHash = record.checksum;
10872
+ const openHash = record.openChecksum;
10873
+ ensure(typeof href === "string" && /^repodata\/[A-Za-z0-9][A-Za-z0-9._+-]*\.xml\.(?:gz|zst)$/.test(href), "Unsupported primary metadata location");
10874
+ ensure(typeof packedHash === "string" && /^[a-f0-9]{64}$/.test(packedHash) && typeof openHash === "string" && /^[a-f0-9]{64}$/.test(openHash), "Invalid primary metadata checksum");
10875
+ ensure(Number.isSafeInteger(record.size) && record.size > 0 && record.size <= maxCompressed && Number.isSafeInteger(record.openSize) && record.openSize > 0 && record.openSize <= maxOpen, "Primary metadata exceeds bounds");
10876
+ const packed = await readRegular(await contained(repo, href), maxCompressed);
10877
+ ensure(packed.length === record.size && digest4(packed) === packedHash, "Primary metadata checksum mismatch");
10878
+ let plain;
10879
+ if (href.endsWith(".gz")) {
10880
+ try {
10881
+ plain = gunzipSync(packed, { maxOutputLength: maxOpen });
10882
+ } catch {
10883
+ throw new Error("Cannot decompress gzip primary metadata within bounds");
10884
+ }
10885
+ } else {
10886
+ const zstd = spawnSync4("/usr/bin/zstd", ["-q", "-d", "-c", "--memory=64MB"], {
10887
+ input: packed,
10888
+ timeout: 30000,
10889
+ maxBuffer: maxOpen,
10890
+ env: { PATH: "/usr/bin:/bin", LANG: "C" }
10891
+ });
10892
+ ensure(zstd.status === 0, "Cannot decompress zstd primary metadata within bounds");
10893
+ plain = zstd.stdout;
10894
+ }
10895
+ ensure(plain.length === record.openSize && digest4(plain) === openHash, "Uncompressed primary metadata checksum mismatch");
10896
+ const rpmPath = resolve22(stage.rpm.path);
10897
+ const rpmHref = relative7(repo, rpmPath);
10898
+ ensure(!rpmHref.startsWith("../") && rpmHref !== "" && await contained(repo, rpmHref) === rpmPath, "RPM must be a regular file inside the local repository");
10899
+ const rpmStat = await lstat24(rpmPath);
10900
+ parseXml("primary", plain, [...proof.rpmIdentity, rpmHref, proof.rpmSha256, String(rpmStat.size)]);
10901
+ ensure(await digestRegular(rpmPath, rpmStat.size) === proof.rpmSha256, "RPM changed during repository verification");
10902
+ return {
10903
+ ...proof,
10904
+ kind: "rpm-repository-proof",
10905
+ primarySha256: packedHash,
10906
+ primaryOpenSha256: openHash,
10907
+ rpmPath: rpmHref
10908
+ };
10909
+ }
10910
+
9259
10911
  // src/library/arch-publish.ts
9260
- import { createHash as createHash20 } from "crypto";
9261
- import { join as join40 } from "path";
9262
- import { tmpdir as tmpdir5 } from "os";
9263
- import { Effect as Effect28 } from "effect";
10912
+ import { createHash as createHash26 } from "crypto";
10913
+ import { join as join45 } from "path";
10914
+ import { tmpdir as tmpdir7 } from "os";
10915
+ import { Effect as Effect30 } from "effect";
9264
10916
 
9265
10917
  // ../../src/release/arch-package.ts
9266
10918
  function archPkgver(tag) {
@@ -9388,11 +11040,11 @@ function renderArchPackage(input) {
9388
11040
  }
9389
11041
  function renderPacmanRepository(policy) {
9390
11042
  const { repository } = policy;
9391
- if (!repository)
11043
+ if (!repository?.keyFingerprint)
9392
11044
  return {};
9393
11045
  const stanza = [
9394
11046
  `[${repository.name}]`,
9395
- "SigLevel = Required DatabaseOptional",
11047
+ "SigLevel = Required TrustedOnly",
9396
11048
  `Server = ${repository.base}$arch`,
9397
11049
  ""
9398
11050
  ].join(`
@@ -9400,37 +11052,48 @@ function renderPacmanRepository(policy) {
9400
11052
  const bootstrap = `#!/bin/sh
9401
11053
  # Install ${policy.desktop.name} from the ${repository.name} pacman repository.
9402
11054
  #
9403
- # curl -fsSL ${repository.base}install.sh | sudo sh
9404
- # curl -fsSL ${repository.base}install.sh | sudo sh -s -- <package>...
11055
+ # Obtain this installer and its expected fingerprint through a separate trusted source.
11056
+ # sudo ADEA_PACMAN_TRUSTED_FINGERPRINT=<verified fingerprint> sh ./install.sh
9405
11057
  set -eu
9406
11058
 
9407
11059
  repo=${shell(repository.name)}
9408
11060
  package=${shell(policy.pkgname)}
9409
11061
  server=${shell(repository.base)}
9410
11062
  key_url=${shell(repository.publicKey)}
11063
+ expected=${shell(repository.keyFingerprint)}
9411
11064
 
9412
11065
  if [ "$(id -u)" -ne 0 ]; then
9413
- echo "Run this script as root, for example: curl -fsSL ${repository.base}install.sh | sudo sh" >&2
11066
+ echo "Run a trusted local copy as root with a verified repository fingerprint" >&2
9414
11067
  exit 1
9415
11068
  fi
9416
- for tool in curl pacman-key pacman grep; do
11069
+ [ "\${ADEA_PACMAN_TRUSTED_FINGERPRINT:-}" = "$expected" ] || { echo 'Provide an independently verified repository fingerprint before installing' >&2; exit 1; }
11070
+ for tool in curl gpg awk pacman-key pacman pacman-conf grep; do
9417
11071
  command -v "$tool" >/dev/null || { echo "Missing $tool" >&2; exit 1; }
9418
11072
  done
9419
- # A fresh container or a minimal install may have no local keyring; lsign needs one.
9420
- [ -s /etc/pacman.d/gnupg/pubring.gpg ] || pacman-key --init >/dev/null
11073
+ # Existing repositories can carry DatabaseOptional, a different server, or included settings.
11074
+ # Refuse rather than silently preserving weaker trust; an operator must first review and remove
11075
+ # the old stanza, including any included configuration, before running this bootstrap again.
11076
+ repositories=$(pacman-conf --repo-list) || { echo 'Cannot inspect existing pacman repositories' >&2; exit 1; }
11077
+ if printf '%s\\n' "$repositories" | grep -Fxq -- "$repo"; then
11078
+ echo "Existing repository $repo requires manual migration before bootstrap" >&2
11079
+ exit 1
11080
+ fi
9421
11081
  tmp=$(mktemp)
9422
11082
  trap 'rm -f "$tmp"' EXIT
9423
- curl -fsSL "$key_url" -o "$tmp"
11083
+ curl -fsSL --proto '=https' --proto-redir '=https' "$key_url" -o "$tmp"
11084
+ key_records=$(gpg --batch --show-keys --with-colons "$tmp" 2>/dev/null)
11085
+ fingerprint=$(printf '%s\\n' "$key_records" | awk -F: '
11086
+ /^pub:/ {pub++; want=1; next}
11087
+ /^sub:/ {want=0}
11088
+ /^fpr:/ && want {if (!first) first=$10; want=0}
11089
+ END {if (pub==1 && first) print first; else exit 1}
11090
+ ')
11091
+ [ "$fingerprint" = "$expected" ] || { echo 'Repository key does not match the pinned fingerprint' >&2; exit 1; }
11092
+ # No trust-store or package-manager mutation before the independent pin is verified.
11093
+ [ -s /etc/pacman.d/gnupg/pubring.gpg ] || pacman-key --init >/dev/null
9424
11094
  pacman-key --add "$tmp" >/dev/null
9425
- # The key's own fingerprint, so the script trusts exactly the key it just imported.
9426
- fingerprint=$(gpg --batch --show-keys --with-colons "$tmp" 2>/dev/null |
9427
- awk -F: '/^fpr:/{print $10; exit}')
9428
- [ -n "$fingerprint" ] || { echo "Could not read the signing key at $key_url" >&2; exit 1; }
9429
- # Trust the key locally. It is the only key this repository's packages are signed with.
9430
- pacman-key --lsign-key "$fingerprint" >/dev/null
9431
- if ! grep -q "^\\[$repo\\]" /etc/pacman.conf; then
9432
- printf '\\n[%s]\\nSigLevel = Required DatabaseOptional\\nServer = %s$arch\\n' "$repo" "$server" >> /etc/pacman.conf
9433
- fi
11095
+ pacman-key --lsign-key "$expected" >/dev/null
11096
+ printf '\\n[%s]\\nSigLevel = Required TrustedOnly\\nServer = %s$arch\\n' "$repo" "$server" >> /etc/pacman.conf
9434
11097
  pacman -Sy --noconfirm >/dev/null
9435
11098
  if [ "$#" -eq 0 ]; then set -- "$package"; fi
9436
11099
  exec pacman -S --needed --noconfirm "$@"
@@ -9441,7 +11104,7 @@ exec pacman -S --needed --noconfirm "$@"
9441
11104
  // src/library/arch-publish.ts
9442
11105
  var AUR_HOST_KEY = "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN";
9443
11106
  var MAX_LICENSE_BYTES = 1024 * 1024;
9444
- var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
11107
+ var feedBytes = (feed, path, maximum) => Effect30.gen(function* () {
9445
11108
  const { fetch: fetch2 } = yield* ReleaseFetch;
9446
11109
  const scope = feedUrl(feed);
9447
11110
  const response = yield* step(() => fetchReleaseLocation(`${scope}${path}`, scope, fetch2, AbortSignal.timeout(30000)));
@@ -9451,7 +11114,7 @@ var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
9451
11114
  }
9452
11115
  return yield* step(() => readReleaseBytes(response, maximum));
9453
11116
  });
9454
- var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
11117
+ var feedJson = (feed, path, maximum) => Effect30.gen(function* () {
9455
11118
  const bytes = yield* feedBytes(feed, path, maximum);
9456
11119
  if (!bytes)
9457
11120
  return null;
@@ -9463,13 +11126,13 @@ var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
9463
11126
  }
9464
11127
  });
9465
11128
  });
9466
- var readChannelTag = (feed, channel) => Effect28.gen(function* () {
11129
+ var readChannelTag = (feed, channel) => Effect30.gen(function* () {
9467
11130
  const parsed = yield* feedJson(feed, `channels/${channel}.json`, 262144);
9468
11131
  if (parsed === null)
9469
11132
  return null;
9470
11133
  return yield* step(async () => parseFeedRelease(parsed).tag);
9471
11134
  });
9472
- var readLicense = (url) => Effect28.gen(function* () {
11135
+ var readLicense = (url) => Effect30.gen(function* () {
9473
11136
  const { fetch: fetch2 } = yield* ReleaseFetch;
9474
11137
  const response = yield* step(() => fetch2(url, { redirect: "follow", signal: AbortSignal.timeout(30000) }));
9475
11138
  if (response.status !== 200 || !response.body) {
@@ -9477,12 +11140,12 @@ var readLicense = (url) => Effect28.gen(function* () {
9477
11140
  return yield* fail("Release license is unavailable");
9478
11141
  }
9479
11142
  const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
9480
- const sha256 = yield* step(async () => createHash20("sha256").update(bytes).digest("hex"));
11143
+ const sha256 = yield* step(async () => createHash26("sha256").update(bytes).digest("hex"));
9481
11144
  return { url, sha256 };
9482
11145
  });
9483
- var git2 = (args) => Effect28.gen(function* () {
11146
+ var git2 = (args) => Effect30.gen(function* () {
9484
11147
  const { run } = yield* ReleaseGit;
9485
- return yield* Effect28.tryPromise({
11148
+ return yield* Effect30.tryPromise({
9486
11149
  try: () => run(args),
9487
11150
  catch: (error) => {
9488
11151
  const stderr = String(error.stderr ?? "").trim().split(`
@@ -9495,11 +11158,11 @@ var git2 = (args) => Effect28.gen(function* () {
9495
11158
  }
9496
11159
  });
9497
11160
  });
9498
- var gitExit = (args) => Effect28.gen(function* () {
11161
+ var gitExit = (args) => Effect30.gen(function* () {
9499
11162
  const { run } = yield* ReleaseGit;
9500
- return yield* Effect28.promise(() => run(args).then(() => 0, (error) => Number(error.code ?? 1) || 1));
11163
+ return yield* Effect30.promise(() => run(args).then(() => 0, (error) => Number(error.code ?? 1) || 1));
9501
11164
  });
9502
- var verifyArchRelease = (options) => Effect28.gen(function* () {
11165
+ var verifyArchRelease = (options) => Effect30.gen(function* () {
9503
11166
  const parsed = parseReleaseConfig(options.config);
9504
11167
  const { config } = options;
9505
11168
  const repository = typeof config.repository === "string" && isRepositorySlug(config.repository) ? config.repository : null;
@@ -9519,7 +11182,7 @@ var verifyArchRelease = (options) => Effect28.gen(function* () {
9519
11182
  if (!listed)
9520
11183
  return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
9521
11184
  const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
9522
- if (!bytes || bytes.length !== listed.size || createHash20("sha256").update(bytes).digest("hex") !== listed.sha256)
11185
+ if (!bytes || bytes.length !== listed.size || createHash26("sha256").update(bytes).digest("hex") !== listed.sha256)
9523
11186
  return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
9524
11187
  const json = yield* step(async () => {
9525
11188
  try {
@@ -9549,7 +11212,7 @@ var verifyArchRelease = (options) => Effect28.gen(function* () {
9549
11212
  return yield* fail("Signed descriptor does not bind the published archive");
9550
11213
  return descriptor.asset;
9551
11214
  });
9552
- var publishArchPackageEffect = (options) => Effect28.gen(function* () {
11215
+ var publishArchPackageEffect = (options) => Effect30.gen(function* () {
9553
11216
  const { archPackage: policy, feed } = parseReleaseConfig(options.config);
9554
11217
  if (!policy)
9555
11218
  return { status: "not-configured" };
@@ -9591,7 +11254,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9591
11254
  const directory = options.printDirectory;
9592
11255
  yield* step(() => fs.mkdir(directory, { recursive: true }));
9593
11256
  for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
9594
- yield* step(() => fs.writeFile(join40(directory, name), contents, { mode: 420 }));
11257
+ yield* step(() => fs.writeFile(join45(directory, name), contents, { mode: 420 }));
9595
11258
  }
9596
11259
  const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
9597
11260
  if (options.dryRun)
@@ -9603,15 +11266,15 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9603
11266
  const key = Buffer.from(encodedKey, "base64").toString("utf8");
9604
11267
  if (!key.includes("PRIVATE KEY"))
9605
11268
  return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
9606
- return yield* Effect28.gen(function* () {
9607
- const work = yield* step(() => fs.mkdtemp(join40(tmpdir5(), "arch-package-")));
9608
- yield* Effect28.addFinalizer(() => Effect28.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
11269
+ return yield* Effect30.gen(function* () {
11270
+ const work = yield* step(() => fs.mkdtemp(join45(tmpdir7(), "arch-package-")));
11271
+ yield* Effect30.addFinalizer(() => Effect30.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
9609
11272
  return;
9610
11273
  }, () => {
9611
11274
  return;
9612
11275
  })));
9613
- const keyFile = join40(work, "aur_id_ed25519");
9614
- const knownHosts = join40(work, "aur_known_hosts");
11276
+ const keyFile = join45(work, "aur_id_ed25519");
11277
+ const knownHosts = join45(work, "aur_known_hosts");
9615
11278
  yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
9616
11279
  yield* step(() => fs.writeFile(keyFile, key.endsWith(`
9617
11280
  `) ? key : `${key}
@@ -9619,7 +11282,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9619
11282
  yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
9620
11283
  `, { mode: 420 }));
9621
11284
  const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
9622
- const checkout = join40(work, policy.pkgname);
11285
+ const checkout = join45(work, policy.pkgname);
9623
11286
  yield* git2([
9624
11287
  "-c",
9625
11288
  `core.sshCommand=${ssh}`,
@@ -9632,7 +11295,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9632
11295
  checkout
9633
11296
  ]);
9634
11297
  for (const [name, contents] of Object.entries(files))
9635
- yield* step(() => fs.writeFile(join40(checkout, name), contents, { mode: 420 }));
11298
+ yield* step(() => fs.writeFile(join45(checkout, name), contents, { mode: 420 }));
9636
11299
  yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
9637
11300
  const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
9638
11301
  if (staged === 0)
@@ -9653,35 +11316,35 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9653
11316
  ]);
9654
11317
  yield* git2(["-C", checkout, "-c", `core.sshCommand=${ssh}`, "push", "origin", "HEAD:master"]);
9655
11318
  return { status: "published", ...base };
9656
- }).pipe(Effect28.scoped);
11319
+ }).pipe(Effect30.scoped);
9657
11320
  });
9658
11321
 
9659
11322
  // src/cli-commands.ts
9660
- var print = (value) => Effect29.gen(function* () {
11323
+ var print = (value) => Effect31.gen(function* () {
9661
11324
  const { stdout } = yield* ReleaseOutput;
9662
11325
  stdout(JSON.stringify(value) + `
9663
11326
  `);
9664
11327
  });
9665
- var say = (line) => Effect29.gen(function* () {
11328
+ var say = (line) => Effect31.gen(function* () {
9666
11329
  const { stdout } = yield* ReleaseOutput;
9667
11330
  stdout(line + `
9668
11331
  `);
9669
11332
  });
9670
11333
  var invalid = (message = "Invalid workflow invocation") => refuse("usage", message);
9671
11334
  var localFlag = (args) => args[0] === "--local" ? [true, args.slice(1)] : [false, args];
9672
- var hostPlatform = Effect29.gen(function* () {
11335
+ var hostPlatform = Effect31.gen(function* () {
9673
11336
  const { platform, arch } = yield* ReleaseConfig;
9674
11337
  return yield* step(async () => hostReleasePlatform(platform, arch));
9675
11338
  });
9676
- var withPlanGitHub = (env, effect) => Effect29.gen(function* () {
11339
+ var withPlanGitHub = (env, effect) => Effect31.gen(function* () {
9677
11340
  const github = yield* ReleaseGitHub;
9678
- return yield* effect.pipe(Effect29.provideService(ReleaseGitHub, {
11341
+ return yield* effect.pipe(Effect31.provideService(ReleaseGitHub, {
9679
11342
  run: github.withEnvironment ? github.withEnvironment(releasePlanGitHubEnvironment(env)) : github.run
9680
11343
  }));
9681
11344
  });
9682
11345
  var publish = (argv) => {
9683
11346
  const [local, args] = localFlag(argv);
9684
- return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect29.gen(function* () {
11347
+ return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect31.gen(function* () {
9685
11348
  const [directory, configPath, out, ...extra] = args;
9686
11349
  if (!directory || !configPath || extra.length || !out !== !local)
9687
11350
  return yield* invalid();
@@ -9694,7 +11357,7 @@ var publish = (argv) => {
9694
11357
  const clock = yield* ReleaseClock;
9695
11358
  const platform = yield* hostPlatform;
9696
11359
  const { repository } = yield* localTagProvenanceEffect({ config, tag, sourceSha });
9697
- const plan = yield* Effect29.uninterruptible(stageLocalReleaseEffect({
11360
+ const plan = yield* Effect31.uninterruptible(stageLocalReleaseEffect({
9698
11361
  config,
9699
11362
  directory,
9700
11363
  out,
@@ -9712,7 +11375,7 @@ var publish = (argv) => {
9712
11375
  };
9713
11376
  var cut = (argv) => {
9714
11377
  const [local, args] = localFlag(argv);
9715
- return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect29.gen(function* () {
11378
+ return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect31.gen(function* () {
9716
11379
  const [kind, path, sourceSha, ...extra] = args;
9717
11380
  if (kind !== "daily" || !path || extra.length || !sourceSha !== !local)
9718
11381
  return yield* invalid();
@@ -9722,7 +11385,7 @@ var cut = (argv) => {
9722
11385
  const { env } = yield* ReleaseConfig;
9723
11386
  if (local) {
9724
11387
  const platform = yield* hostPlatform;
9725
- const result = yield* Effect29.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
11388
+ const result = yield* Effect31.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
9726
11389
  return yield* print(result);
9727
11390
  }
9728
11391
  const result = yield* releaseCutCommand({
@@ -9736,7 +11399,7 @@ var cut = (argv) => {
9736
11399
  };
9737
11400
  var promote = (argv) => {
9738
11401
  const [local, args] = localFlag(argv);
9739
- return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect29.gen(function* () {
11402
+ return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect31.gen(function* () {
9740
11403
  const [path, out, ...extra] = args;
9741
11404
  const { env } = yield* ReleaseConfig;
9742
11405
  const held = env.STABLE_PROMOTION_HELD;
@@ -9746,7 +11409,7 @@ var promote = (argv) => {
9746
11409
  if (local) {
9747
11410
  const clock = yield* ReleaseClock;
9748
11411
  const repository = yield* originRepositoryEffect;
9749
- const result = yield* Effect29.uninterruptible(runLocalPromotionEffect({
11412
+ const result = yield* Effect31.uninterruptible(runLocalPromotionEffect({
9750
11413
  config,
9751
11414
  out,
9752
11415
  now: clock.now(),
@@ -9759,7 +11422,7 @@ var promote = (argv) => {
9759
11422
  yield* print(yield* promotionCommand({ env, config }));
9760
11423
  }), { requireGitHubActions: !local });
9761
11424
  };
9762
- var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
11425
+ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect31.gen(function* () {
9763
11426
  const { env } = yield* ReleaseConfig;
9764
11427
  if (argv[0] === "--local") {
9765
11428
  const [configPath, tag, ...extra] = argv.slice(1);
@@ -9780,7 +11443,7 @@ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${r
9780
11443
  yield* finalizeReleasePleaseDraftEffect({ env, config, ...identity });
9781
11444
  yield* say("Qualified draft published as a prerelease");
9782
11445
  }));
9783
- var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect29.gen(function* () {
11446
+ var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect31.gen(function* () {
9784
11447
  const [tag, path, ...extra] = args;
9785
11448
  if (!tag || !path || extra.length)
9786
11449
  return yield* invalid("Expected release tag and configuration file");
@@ -9788,7 +11451,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
9788
11451
  const { env } = yield* ReleaseConfig;
9789
11452
  yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
9790
11453
  }));
9791
- var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect29.gen(function* () {
11454
+ var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect31.gen(function* () {
9792
11455
  const [identityPath, artifactPath, feed, ...extra] = args;
9793
11456
  const { env } = yield* ReleaseConfig;
9794
11457
  if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
@@ -9799,7 +11462,7 @@ var sign2 = (args) => runCommand("Unable to sign release artifact; check the ide
9799
11462
  }));
9800
11463
  var signDescriptors = (argv) => {
9801
11464
  const [local, args] = localFlag(argv);
9802
- return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect29.gen(function* () {
11465
+ return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect31.gen(function* () {
9803
11466
  const [directory, configPath, ...extra] = args;
9804
11467
  const { env } = yield* ReleaseConfig;
9805
11468
  const {
@@ -9832,7 +11495,7 @@ var signDescriptors = (argv) => {
9832
11495
  }));
9833
11496
  }));
9834
11497
  };
9835
- var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect29.gen(function* () {
11498
+ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect31.gen(function* () {
9836
11499
  const args = [...argv];
9837
11500
  const flag = args.indexOf("--artifacts");
9838
11501
  const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1];
@@ -9884,9 +11547,9 @@ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.
9884
11547
  return yield* invalid(`Unknown release step ${String(name)}`);
9885
11548
  }
9886
11549
  }));
9887
- var verifyMacosSigning = (args) => Effect29.gen(function* () {
11550
+ var verifyMacosSigning = (args) => Effect31.gen(function* () {
9888
11551
  let problems = 0;
9889
- const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect29.gen(function* () {
11552
+ const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect31.gen(function* () {
9890
11553
  const [app, flag, ...extra] = args;
9891
11554
  if (!app || extra.length || ![undefined, "--hardened"].includes(flag))
9892
11555
  return yield* invalid("usage");
@@ -9899,14 +11562,14 @@ var verifyMacosSigning = (args) => Effect29.gen(function* () {
9899
11562
  }));
9900
11563
  return code || (problems ? 1 : 0);
9901
11564
  });
9902
- var publishFramework = (args) => runCommand((error) => error.message, Effect29.gen(function* () {
11565
+ var publishFramework = (args) => runCommand((error) => error.message, Effect31.gen(function* () {
9903
11566
  const [archive, flag, ...extra] = args;
9904
11567
  if (!archive || extra.length || flag !== undefined && flag !== "--dry-run")
9905
11568
  return yield* invalid("Expected one framework package archive and an optional --dry-run");
9906
11569
  const { env } = yield* ReleaseConfig;
9907
11570
  yield* print(yield* step(() => publishFrameworkPackage({ env, archive, dryRun: flag === "--dry-run" })));
9908
11571
  }));
9909
- var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
11572
+ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`, Effect31.gen(function* () {
9910
11573
  const args = [...argv];
9911
11574
  const printIndex = args.indexOf("--print");
9912
11575
  const printDirectory = printIndex === -1 ? undefined : args[printIndex + 1];
@@ -9941,7 +11604,7 @@ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch pa
9941
11604
  ...printDirectory ? { printDirectory } : {}
9942
11605
  }));
9943
11606
  }));
9944
- var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; check the command arguments and use matching exact staged artifacts and native receipts.", Effect29.gen(function* () {
11607
+ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; check the command arguments and use matching exact staged artifacts and native receipts.", Effect31.gen(function* () {
9945
11608
  const [action, configPath, ...operands] = args;
9946
11609
  if (!configPath)
9947
11610
  return yield* invalid();
@@ -9992,25 +11655,42 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
9992
11655
  const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
9993
11656
  return yield* print(result);
9994
11657
  }));
9995
- var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
11658
+ var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect31.gen(function* () {
9996
11659
  yield* print(yield* step(() => prepareStableCatalogCommand(args)));
9997
11660
  }));
9998
- var stageAptRepository = (args) => runCommand((error) => `Unable to stage Apt repository: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
11661
+ var stageAptRepository = (args) => runCommand((error) => `Unable to stage Apt repository: ${redactedErrorMessage(error)}`, Effect31.gen(function* () {
9999
11662
  yield* print(yield* step(() => stageAptRepositoryCommand(args)));
10000
11663
  }));
10001
- var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
10002
- const [channel, input, ...extra] = args;
10003
- if (channel !== "rpm" && channel !== "flatpak" || !input || extra.length)
10004
- return yield* invalid("Expected <rpm|flatpak> <input.json>");
11664
+ var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`, Effect31.gen(function* () {
11665
+ const [channel, input, ...rawExtra] = args;
11666
+ const signed = channel === "rpm-signed" || channel === "rpm-repository";
11667
+ const fingerprint = signed && rawExtra[0] === "--fingerprint" ? rawExtra[1] : undefined;
11668
+ const extra = signed ? rawExtra.slice(2) : rawExtra;
11669
+ const configMode = (channel === "rpm" || signed) && extra.length === 4 && extra[0] === "--release-config" && extra[2] === "--tag";
11670
+ if (channel !== "rpm" && channel !== "flatpak" && !signed || !input || signed && !fingerprint || extra.length && !configMode)
11671
+ return yield* invalid("Expected <rpm|flatpak> <input.json> or <rpm-signed|rpm-repository> <input.json> --fingerprint <primary-fingerprint> [--release-config <path> --tag <tag>]");
10005
11672
  const value = yield* readBoundedJson(input, 1024 * 1024, "Linux channel proof");
10006
- if (channel === "rpm") {
10007
- yield* print(yield* step(() => verifyRpmStage(value)));
11673
+ if (channel === "rpm" || signed) {
11674
+ let stage = value;
11675
+ if (configMode) {
11676
+ const config = yield* readReleaseConfig(extra[1]);
11677
+ const tag = extra[3];
11678
+ const archive = yield* step(async () => {
11679
+ const expected = parseReleaseConfig(config).requirements(tag).platforms["linux-x64"]?.[1];
11680
+ if (!expected || stage.version !== tag.slice(1))
11681
+ throw new Error("RPM version or Linux archive does not match release configuration");
11682
+ return expected;
11683
+ });
11684
+ stage = { ...stage, payload: { ...stage.payload, expectedName: archive } };
11685
+ }
11686
+ yield* print(yield* step(() => channel === "rpm-repository" ? verifyRpmRepository(stage, fingerprint) : signed ? verifySignedRpmStage(stage, fingerprint) : verifyRpmStage(stage)));
10008
11687
  } else {
10009
11688
  const { policy, observation } = value;
10010
11689
  yield* print(yield* step(async () => verifyFlatpakCapabilities(policy, observation)));
10011
11690
  }
10012
11691
  }));
10013
11692
  var commands = {
11693
+ "build-linux-formats": buildLinuxFormatsCommand,
10014
11694
  cut,
10015
11695
  "daily-matrix": dailyMatrix,
10016
11696
  finalize,
@@ -10032,7 +11712,7 @@ var releaseCli = (argv) => {
10032
11712
  const command = name === undefined ? undefined : commands[name];
10033
11713
  if (command)
10034
11714
  return command(args);
10035
- return Effect29.gen(function* () {
11715
+ return Effect31.gen(function* () {
10036
11716
  const { stderr } = yield* ReleaseOutput;
10037
11717
  stderr(`Usage: adea-release <${Object.keys(commands).join("|")}> [arguments]; unknown command ${String(name)}
10038
11718
  `);
@@ -10041,4 +11721,20 @@ var releaseCli = (argv) => {
10041
11721
  };
10042
11722
 
10043
11723
  // src/cli.ts
10044
- process.exitCode = await Effect30.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));
11724
+ if (process.argv[2] === "build-linux-formats") {
11725
+ const controller = new AbortController;
11726
+ const stop = () => controller.abort();
11727
+ process.on("SIGINT", stop);
11728
+ process.on("SIGTERM", stop);
11729
+ try {
11730
+ const result = await Effect32.runPromiseExit(provideLivePorts(releaseCli(process.argv.slice(2))), {
11731
+ signal: controller.signal
11732
+ });
11733
+ process.exitCode = controller.signal.aborted ? 130 : Exit6.isSuccess(result) ? result.value : 1;
11734
+ } finally {
11735
+ process.removeListener("SIGINT", stop);
11736
+ process.removeListener("SIGTERM", stop);
11737
+ }
11738
+ } else {
11739
+ process.exitCode = await Effect32.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));
11740
+ }