@adea-ai/app-framework-release-tools 0.5.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
@@ -19,6 +19,10 @@ var __export = (target, all) => {
19
19
  var exports_src = {};
20
20
  __export(exports_src, {
21
21
  buildLinuxFormats: () => buildLinuxFormats,
22
+ compareLinuxReproducibility: () => compareLinuxReproducibility,
23
+ createDailyBatchR2Client: () => createDailyBatchR2Client,
24
+ createDailyBatchR2Store: () => createDailyBatchR2Store,
25
+ createDailyBatchS3Transport: () => createDailyBatchS3Transport,
22
26
  createDailyNativeReceipt: () => createDailyNativeReceipt,
23
27
  createGitHubPromotionProvider: () => createGitHubPromotionProvider,
24
28
  createGitHubReleasePublisher: () => createGitHubReleasePublisher,
@@ -26,15 +30,19 @@ __export(exports_src, {
26
30
  desktopDailyProfile: () => desktopDailyProfile,
27
31
  fileIdentity: () => fileIdentity2,
28
32
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
33
+ inspectDailyBatch: () => inspectDailyBatch,
29
34
  inspectStagedStep: () => inspectStagedStep,
30
35
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
31
36
  planQualificationRun: () => planQualificationRun2,
32
37
  planReleaseAssets: () => planReleaseAssets2,
38
+ promoteDailyBatch: () => promoteDailyBatch,
33
39
  publishFrameworkPackage: () => publishFrameworkPackage,
34
40
  publishQualifiedRelease: () => publishQualifiedRelease,
35
41
  qualifyGitHubRelease: () => qualifyGitHubRelease,
36
42
  qualifyStep: () => qualifyStep,
37
43
  qualifyUpgradeStep: () => qualifyUpgradeStep,
44
+ readDailyBatch: () => readDailyBatch,
45
+ rollbackDailyBatch: () => rollbackDailyBatch,
38
46
  runPromotionCommand: () => runPromotionCommand,
39
47
  runReleaseCutCommand: () => runReleaseCutCommand,
40
48
  runReleasePublishCommand: () => runReleasePublishCommand,
@@ -45,16 +53,18 @@ __export(exports_src, {
45
53
  stageLinuxPackagePair: () => stageLinuxPackagePair,
46
54
  stagePlatformArtifacts: () => stagePlatformArtifacts,
47
55
  stageReleaseDescriptors: () => stageReleaseDescriptors,
56
+ verifyDailyBatchDescriptor: () => verifyDailyBatchDescriptor,
57
+ verifyDailyBatchObject: () => verifyDailyBatchObject,
48
58
  verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
49
59
  verifyImage: () => verifyImage,
50
60
  writeDescriptors: () => writeDescriptors
51
61
  });
52
62
 
53
63
  // src/cli.ts
54
- import { Effect as Effect30 } from "effect";
64
+ import { Effect as Effect32, Exit as Exit6 } from "effect";
55
65
 
56
66
  // src/cli-commands.ts
57
- import { Effect as Effect29 } from "effect";
67
+ import { Effect as Effect31 } from "effect";
58
68
 
59
69
  // ../../src/installer/hosted-runner.ts
60
70
  import { isAbsolute } from "path";
@@ -429,7 +439,7 @@ function parseArchPackage(value) {
429
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");
430
440
  assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
431
441
  const repository = policy.repository;
432
- 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");
433
443
  return {
434
444
  pkgname: policy.pkgname,
435
445
  pkgdesc: policy.pkgdesc,
@@ -493,7 +503,8 @@ function parseArchPackage(value) {
493
503
  repository: {
494
504
  name: repository.name,
495
505
  base: repository.base,
496
- publicKey: repository.publicKey
506
+ publicKey: repository.publicKey,
507
+ ...typeof repository.keyFingerprint === "string" ? { keyFingerprint: repository.keyFingerprint } : {}
497
508
  }
498
509
  }
499
510
  };
@@ -1070,15 +1081,122 @@ async function runReleaseEffect(effect) {
1070
1081
  }
1071
1082
 
1072
1083
  // src/release-ports.ts
1073
- import { execFile, spawnSync } from "child_process";
1084
+ import { execFile, spawn, spawnSync } from "child_process";
1074
1085
  import { createPrivateKey } from "crypto";
1075
1086
  import * as fsp from "fs/promises";
1076
1087
  import { Context, Effect as Effect2 } from "effect";
1088
+ import { promisify } from "util";
1077
1089
  import { Effect as Effect3, Fiber, Option } from "effect";
1078
1090
 
1079
1091
  class ReleaseGit extends Context.Service()("ReleaseTools/Git") {
1080
1092
  }
1081
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
+
1082
1200
  class ReleaseGitHub extends Context.Service()("ReleaseTools/GitHub") {
1083
1201
  }
1084
1202
 
@@ -3287,6 +3405,424 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
3287
3405
  });
3288
3406
  var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
3289
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
+
3290
3826
  // src/library/daily-matrix.ts
3291
3827
  import { join as join8 } from "path";
3292
3828
  import { Effect as Effect16 } from "effect";
@@ -3487,10 +4023,136 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
3487
4023
  function verifyDailyReleaseMatrix(options) {
3488
4024
  return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
3489
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() {}
3490
4152
  // src/library/daily-native-receipt.ts
3491
- import { join as join9 } from "path";
3492
- import { Effect as Effect17 } from "effect";
3493
- 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* () {
3494
4156
  const { config, identity, artifacts, checkName, report } = options;
3495
4157
  yield* attempt(() => assertDailyIdentity(identity));
3496
4158
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
@@ -3504,7 +4166,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3504
4166
  const dir = yield* step(() => fs.lstat(artifacts));
3505
4167
  if (!dir.isDirectory() || dir.isSymbolicLink())
3506
4168
  return yield* fail("Expected real native artifact directory");
3507
- 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));
3508
4170
  const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
3509
4171
  appId: matrix.appId,
3510
4172
  identity,
@@ -3522,7 +4184,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function*
3522
4184
  const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
3523
4185
  const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
3524
4186
  for (const expected of proofFiles) {
3525
- const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
4187
+ const observed = yield* fileIdentityEffect(join10(baselineDirectory, expected.name), expected.name);
3526
4188
  if (observed.size !== expected.size || observed.digest !== expected.digest)
3527
4189
  return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
3528
4190
  }
@@ -3545,6 +4207,160 @@ function createDailyNativeReceipt(options) {
3545
4207
  arch: process.arch
3546
4208
  })));
3547
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
+ }
3548
4364
  // src/library/macos-dmg.ts
3549
4365
  import { execFileSync } from "child_process";
3550
4366
  import {
@@ -3556,8 +4372,8 @@ import {
3556
4372
  rmSync,
3557
4373
  symlinkSync
3558
4374
  } from "fs";
3559
- import { basename as basename4, dirname, join as join10, resolve as resolve6 } from "path";
3560
- 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";
3561
4377
 
3562
4378
  // ../../src/release/macos-dmg.ts
3563
4379
  var MIB = 1024 * 1024;
@@ -3588,7 +4404,7 @@ function treeSize(root) {
3588
4404
  logicalBytes += info.size;
3589
4405
  else if (info.isDirectory())
3590
4406
  for (const name of readdirSync(path))
3591
- pending.push(join10(path, name));
4407
+ pending.push(join12(path, name));
3592
4408
  else if (!info.isSymbolicLink())
3593
4409
  throw new Error("Unsupported disk image entry");
3594
4410
  if (!Number.isSafeInteger(logicalBytes))
@@ -3596,29 +4412,29 @@ function treeSize(root) {
3596
4412
  }
3597
4413
  return { logicalBytes, entries };
3598
4414
  }
3599
- var verifyImageEffect = (image) => Effect18.gen(function* () {
4415
+ var verifyImageEffect = (image) => Effect19.gen(function* () {
3600
4416
  const host = yield* MacosHost;
3601
4417
  for (let tries = 1;; tries++) {
3602
- 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)));
3603
4419
  if (verified)
3604
4420
  return;
3605
4421
  host.wait(5000 * 2 ** (tries - 1));
3606
4422
  }
3607
4423
  });
3608
- var createMacosDmgEffect = (options) => Effect18.gen(function* () {
4424
+ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
3609
4425
  const host = yield* MacosHost;
3610
4426
  if (host.platform !== "darwin")
3611
4427
  return yield* fail("Disk image creation requires macOS");
3612
4428
  assertPortableAppName(options.appName);
3613
- const app = resolve6(options.appPath), output = resolve6(options.outputPath);
4429
+ const app = resolve7(options.appPath), output = resolve7(options.outputPath);
3614
4430
  const info = yield* attempt(() => lstatSync(app));
3615
4431
  if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
3616
4432
  return yield* fail("Invalid disk image paths");
3617
- const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join10(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
3618
- 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");
3619
4435
  yield* attempt(() => mkdirSync(payload));
3620
- yield* attempt(() => host.run("/usr/bin/ditto", [app, join10(payload, basename4(app))]));
3621
- 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")));
3622
4438
  const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
3623
4439
  yield* attempt(() => host.run("/usr/bin/hdiutil", [
3624
4440
  "create",
@@ -3635,36 +4451,36 @@ var createMacosDmgEffect = (options) => Effect18.gen(function* () {
3635
4451
  yield* verifyImageEffect(image);
3636
4452
  yield* attempt(() => linkSync(image, output));
3637
4453
  return { capacityMiB };
3638
- }).pipe(Effect18.scoped);
4454
+ }).pipe(Effect19.scoped);
3639
4455
  function verifyImage(image, io = liveHost) {
3640
- runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
4456
+ runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect19.provideService(MacosHost, {
3641
4457
  run: (command, args) => io.run(command, args),
3642
4458
  wait: (milliseconds) => io.wait(milliseconds),
3643
4459
  platform: process.platform
3644
4460
  })));
3645
4461
  }
3646
4462
  function createMacosDmg(options) {
3647
- return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
4463
+ return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect19.provideService(MacosHost, liveHost)));
3648
4464
  }
3649
4465
  // src/library/qualification-run.ts
3650
- import { Effect as Effect21 } from "effect";
4466
+ import { Effect as Effect22 } from "effect";
3651
4467
 
3652
4468
  // src/library/local-release.ts
3653
- import { createHash as createHash8 } from "crypto";
4469
+ import { createHash as createHash11 } from "crypto";
3654
4470
  import { constants as constants3 } from "fs";
3655
- import { dirname as dirname2, join as join12, resolve as resolve8 } from "path";
3656
- 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";
3657
4473
 
3658
4474
  // ../../src/native/native-rename.ts
3659
4475
  import { randomUUID } from "crypto";
3660
- 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";
3661
4477
  import { dlopen, FFIType, ptr } from "bun:ffi";
3662
- import { join as join11 } from "path";
4478
+ import { join as join13 } from "path";
3663
4479
 
3664
4480
  // ../../src/native/canonical-path.ts
3665
- import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
4481
+ import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
3666
4482
  function isCanonicalPath(value) {
3667
- 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");
3668
4484
  }
3669
4485
 
3670
4486
  // ../../src/native/native-rename.ts
@@ -3738,8 +4554,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3738
4554
  if (!isCanonicalPath(parent))
3739
4555
  throw new Error("Invalid directory exchange probe parent");
3740
4556
  const id = randomUUID();
3741
- const first = join11(parent, `.framework-exchange-probe-${id}-a`);
3742
- 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`);
3743
4559
  const marker = "exchange-probe";
3744
4560
  const firstValue = `${id}:first`;
3745
4561
  const secondValue = `${id}:second`;
@@ -3750,12 +4566,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
3750
4566
  firstCreated = true;
3751
4567
  await mkdir3(second, { mode: 448 });
3752
4568
  secondCreated = true;
3753
- await writeFile3(join11(first, marker), firstValue, { flag: "wx", mode: 384 });
3754
- 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 });
3755
4571
  exchange(first, second);
3756
4572
  const [firstAfter, secondAfter] = await Promise.all([
3757
- readFile5(join11(first, marker), "utf8"),
3758
- readFile5(join11(second, marker), "utf8")
4573
+ readFile6(join13(first, marker), "utf8"),
4574
+ readFile6(join13(second, marker), "utf8")
3759
4575
  ]);
3760
4576
  if (firstAfter !== secondValue || secondAfter !== firstValue)
3761
4577
  throw new Error("Directory exchange did not exchange both probe trees");
@@ -3820,8 +4636,8 @@ function createFeedReleaseCutProvider(options) {
3820
4636
  }
3821
4637
 
3822
4638
  // src/library/feed-state.ts
3823
- import { createHash as createHash7 } from "crypto";
3824
- import { Effect as Effect19 } from "effect";
4639
+ import { createHash as createHash10 } from "crypto";
4640
+ import { Effect as Effect20 } from "effect";
3825
4641
 
3826
4642
  // ../../src/shared/discard-stream.ts
3827
4643
  function discardStream(stream) {
@@ -3981,11 +4797,11 @@ var json = (bytes) => {
3981
4797
  throw new Error("Invalid release feed response");
3982
4798
  }
3983
4799
  };
3984
- var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
4800
+ var feedObject = (feed, path, maximum) => Effect20.gen(function* () {
3985
4801
  const { fetch: fetch2 } = yield* ReleaseFetch;
3986
4802
  return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
3987
4803
  });
3988
- var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
4804
+ var readFeedLedgerEffect = (feed) => Effect20.gen(function* () {
3989
4805
  const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
3990
4806
  const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
3991
4807
  if (ledger && ledger.releases.length > 0)
@@ -3997,7 +4813,7 @@ var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
3997
4813
  }
3998
4814
  return ledger ?? { schema: 1, app: feed.app, releases: [] };
3999
4815
  });
4000
- var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
4816
+ var readFeedReleaseEffect = (feed, tag) => Effect20.gen(function* () {
4001
4817
  const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
4002
4818
  if (!bytes)
4003
4819
  return null;
@@ -4047,10 +4863,10 @@ class ReleaseFeedSnapshotChanged extends Error {
4047
4863
  var snapshotChanged = step(async () => {
4048
4864
  throw new ReleaseFeedSnapshotChanged;
4049
4865
  });
4050
- var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4866
+ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
4051
4867
  const { config, feed, tag } = options;
4052
4868
  const { fetch: fetcher } = yield* ReleaseFetch;
4053
- 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));
4054
4870
  if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
4055
4871
  return yield* snapshotChanged;
4056
4872
  const release = yield* readFeedReleaseEffect(feed, tag);
@@ -4068,7 +4884,7 @@ var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
4068
4884
  if (!listed)
4069
4885
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
4070
4886
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
4071
- 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)
4072
4888
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
4073
4889
  const verified = verifyReleaseDescriptor(json(bytes), {
4074
4890
  appId: policy.appId,
@@ -4113,13 +4929,13 @@ var timestamp2 = (value) => {
4113
4929
  throw new Error("Invalid release clock");
4114
4930
  return new Date(value).toISOString();
4115
4931
  };
4116
- var exactFiles = (directory, names) => Effect20.gen(function* () {
4932
+ var exactFiles = (directory, names) => Effect21.gen(function* () {
4117
4933
  const fs = yield* ReleaseFs;
4118
4934
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
4119
4935
  if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
4120
4936
  return yield* fail("Staged directory does not hold exactly the platform release files");
4121
4937
  });
4122
- var promised2 = Effect20.gen(function* () {
4938
+ var promised2 = Effect21.gen(function* () {
4123
4939
  const fs = yield* ReleaseFs;
4124
4940
  const { fetch: fetch2 } = yield* ReleaseFetch;
4125
4941
  const { run: git } = yield* ReleaseGit;
@@ -4129,7 +4945,7 @@ var promised2 = Effect20.gen(function* () {
4129
4945
  run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
4130
4946
  };
4131
4947
  });
4132
- var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4948
+ var runLocalReleaseCutEffect = (options) => Effect21.gen(function* () {
4133
4949
  const { kind, platform } = options;
4134
4950
  const parsed = parseReleaseConfig(options.config);
4135
4951
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4154,7 +4970,7 @@ var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
4154
4970
  }));
4155
4971
  return { ...result, version: result.tag.slice(1), platform };
4156
4972
  });
4157
- var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4973
+ var localTagProvenanceEffect = (options) => Effect21.gen(function* () {
4158
4974
  const parsed = parseReleaseConfig(options.config);
4159
4975
  parsed.requirements(options.tag);
4160
4976
  const provenance = yield* resolveLocalProvenanceEffect({
@@ -4165,16 +4981,16 @@ var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
4165
4981
  return yield* fail("Release tag does not belong to the source version");
4166
4982
  return { repository: provenance.repository };
4167
4983
  });
4168
- var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4984
+ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
4169
4985
  const { tag, platform } = options;
4170
4986
  const local = localConfig(options.config);
4171
4987
  if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
4172
4988
  return yield* fail("Invalid local release identity");
4173
4989
  const publicKey = configuredSigningKey(local.config, options.keyId, options.privateKey);
4174
4990
  const payloads = platformPayloads(local.requirements(tag), platform);
4175
- const directory = resolve8(options.directory);
4991
+ const directory = resolve9(options.directory);
4176
4992
  yield* exactFiles(directory, payloads);
4177
- 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" });
4178
4994
  const signed = signDiscoveryDescriptors({
4179
4995
  policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
4180
4996
  assets,
@@ -4192,7 +5008,7 @@ var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
4192
5008
  privateKey: options.privateKey
4193
5009
  });
4194
5010
  for (const asset of assets)
4195
- 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))
4196
5012
  return yield* fail("Staged payload changed before signing");
4197
5013
  yield* writeDescriptorsEffect(directory, signed);
4198
5014
  return signed.map((value) => value.name);
@@ -4212,22 +5028,22 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
4212
5028
  var describe = (key, bytes, cacheControl) => ({
4213
5029
  key,
4214
5030
  size: bytes.length,
4215
- sha256: createHash8("sha256").update(bytes).digest("hex"),
5031
+ sha256: createHash11("sha256").update(bytes).digest("hex"),
4216
5032
  contentType: "application/json",
4217
5033
  cacheControl
4218
5034
  });
4219
- var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
5035
+ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* () {
4220
5036
  const fs = yield* ReleaseFs;
4221
- const root = resolve8(out);
4222
- 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)));
4223
5039
  if (exists)
4224
5040
  return yield* fail("Release output directory already exists");
4225
5041
  yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
4226
- const staging = yield* step(() => fs.mkdtemp(join12(dirname2(root), ".release-staging-")));
4227
- 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* () {
4228
5044
  const objects = [];
4229
5045
  for (const { key, path, artifact } of assets) {
4230
- const target = join12(staging, key);
5046
+ const target = join14(staging, key);
4231
5047
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4232
5048
  yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
4233
5049
  if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
@@ -4241,13 +5057,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4241
5057
  });
4242
5058
  }
4243
5059
  for (const { key, bytes } of documents) {
4244
- const target = join12(staging, key);
5060
+ const target = join14(staging, key);
4245
5061
  yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
4246
5062
  yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
4247
5063
  objects.push(describe(key, bytes, MUTABLE));
4248
5064
  }
4249
5065
  const plan = { schema: 1, base: feed.base, objects };
4250
- 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 }));
4251
5067
  yield* attempt(() => renameExclusive(staging, root));
4252
5068
  return plan;
4253
5069
  }));
@@ -4255,10 +5071,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4255
5071
  return exit.value;
4256
5072
  const error = Cause2.squash(exit.cause);
4257
5073
  const original = error instanceof ReleaseFailure ? error.original ?? error : error;
4258
- 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 })));
4259
5075
  if (Exit3.isFailure(cleanup)) {
4260
5076
  const cleanupError = Cause2.squash(cleanup.cause);
4261
- return yield* Effect20.fail(new ReleaseFailure({
5077
+ return yield* Effect21.fail(new ReleaseFailure({
4262
5078
  reason: "cleanup",
4263
5079
  message: "Release staging failed and its private temporary tree could not be removed",
4264
5080
  original: new AggregateError([
@@ -4267,8 +5083,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* (
4267
5083
  ], "Release staging failed and its private temporary tree could not be removed", { cause: original })
4268
5084
  }));
4269
5085
  }
4270
- return yield* Effect20.failCause(exit.cause);
4271
- }).pipe(Effect20.uninterruptible);
5086
+ return yield* Effect21.failCause(exit.cause);
5087
+ }).pipe(Effect21.uninterruptible);
4272
5088
  function releaseDocuments(feed, ledger, release) {
4273
5089
  return [
4274
5090
  { key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
@@ -4285,23 +5101,23 @@ function releaseDocuments(feed, ledger, release) {
4285
5101
  }))
4286
5102
  ];
4287
5103
  }
4288
- var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
5104
+ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
4289
5105
  const fs = yield* ReleaseFs;
4290
5106
  const { tag, sourceSha, platform } = options;
4291
5107
  const local = localConfig(options.config);
4292
5108
  const feed = local.feed, now = timestamp2(options.now);
4293
5109
  const payloads = platformPayloads(local.requirements(tag), platform);
4294
5110
  const policies = discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform);
4295
- const directory = resolve8(options.directory);
5111
+ const directory = resolve9(options.directory);
4296
5112
  const names = [...payloads, ...policies.map((policy) => policy.name)];
4297
5113
  yield* exactFiles(directory, names);
4298
- 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" });
4299
5115
  for (const policy of policies) {
4300
5116
  const artifact = staged.find((asset) => asset.name === policy.name);
4301
5117
  if (artifact.size > 65536)
4302
5118
  return yield* fail("Signed descriptor is too large");
4303
- const bytes = yield* step(() => fs.readFile(join12(directory, policy.name)));
4304
- 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)
4305
5121
  return yield* fail("Signed descriptor changed");
4306
5122
  let parsed;
4307
5123
  try {
@@ -4322,7 +5138,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4322
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)
4323
5139
  return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
4324
5140
  }
4325
- 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" });
4326
5142
  const entry = ledger.releases.find((item) => item.tag === tag);
4327
5143
  if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
4328
5144
  return yield* fail("Inconsistent feed release; reconcile publication before retrying");
@@ -4340,7 +5156,7 @@ var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
4340
5156
  merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
4341
5157
  uploads.push({
4342
5158
  key: feedAssetKey(feed, tag, artifact.name),
4343
- path: join12(directory, artifact.name),
5159
+ path: join14(directory, artifact.name),
4344
5160
  artifact
4345
5161
  });
4346
5162
  }
@@ -4373,7 +5189,7 @@ function stablePlatforms(config) {
4373
5189
  throw new Error("Invalid stablePlatforms in the release configuration");
4374
5190
  return value;
4375
5191
  }
4376
- var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
5192
+ var verifyLocalReleaseEffect = (options) => Effect21.gen(function* () {
4377
5193
  const local = localConfig(options.config);
4378
5194
  const { release, platforms } = yield* verifyFeedReleaseEffect({
4379
5195
  config: local.config,
@@ -4389,7 +5205,7 @@ var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
4389
5205
  missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
4390
5206
  };
4391
5207
  });
4392
- var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
5208
+ var runLocalPromotionEffect = (options) => Effect21.gen(function* () {
4393
5209
  const local = localConfig(options.config);
4394
5210
  const feed = local.feed;
4395
5211
  const required = stablePlatforms(local.config);
@@ -4447,7 +5263,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4447
5263
  const verification = qualified.get(selected.tag);
4448
5264
  const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
4449
5265
  const entry = ledger.releases.find((item) => item.tag === selected.tag);
4450
- 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)], {
4451
5267
  concurrency: "unbounded"
4452
5268
  }));
4453
5269
  if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
@@ -4486,7 +5302,7 @@ var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
4486
5302
 
4487
5303
  // src/library/qualification-run.ts
4488
5304
  var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
4489
- var tagRun = (options) => Effect21.gen(function* () {
5305
+ var tagRun = (options) => Effect22.gen(function* () {
4490
5306
  const { tag, sha, runId } = options;
4491
5307
  if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
4492
5308
  return yield* fail(REFUSAL);
@@ -4500,7 +5316,7 @@ var tagRun = (options) => Effect21.gen(function* () {
4500
5316
  runAttempt: 1
4501
5317
  };
4502
5318
  });
4503
- var planQualificationRunEffect = (options) => Effect21.gen(function* () {
5319
+ var planQualificationRunEffect = (options) => Effect22.gen(function* () {
4504
5320
  const { env, config, tag } = options;
4505
5321
  if (env.GITHUB_ACTIONS === "true") {
4506
5322
  const plan = yield* planReleaseAssetsEffect({ env, config, tag });
@@ -4533,8 +5349,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
4533
5349
  ...options.git ? { git: options.git } : {}
4534
5350
  })(planQualificationRunEffect(options)));
4535
5351
  // src/library/retained-build.ts
4536
- import { Effect as Effect22 } from "effect";
4537
- var id = (value) => Effect22.gen(function* () {
5352
+ import { Effect as Effect23 } from "effect";
5353
+ var id = (value) => Effect23.gen(function* () {
4538
5354
  if (typeof value === "number" && !Number.isSafeInteger(value))
4539
5355
  return yield* fail("Invalid GitHub identity");
4540
5356
  const text = String(value);
@@ -4542,7 +5358,7 @@ var id = (value) => Effect22.gen(function* () {
4542
5358
  return yield* fail("Invalid GitHub identity");
4543
5359
  return text;
4544
5360
  });
4545
- var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
5361
+ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
4546
5362
  const { env, config, tag, platform } = options;
4547
5363
  if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
4548
5364
  return yield* fail("Invalid retained build context");
@@ -4660,12 +5476,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
4660
5476
  });
4661
5477
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
4662
5478
  // src/library/staging.ts
4663
- import { createHash as createHash9 } from "crypto";
4664
- import { join as join13, resolve as resolve9 } from "path";
4665
- import { Effect as Effect23 } from "effect";
4666
- 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({
4667
5483
  try: async (signal) => {
4668
- const hash = createHash9("sha256");
5484
+ const hash = createHash12("sha256");
4669
5485
  let copied = 0;
4670
5486
  for await (const chunk of input.createReadStream({
4671
5487
  autoClose: false
@@ -4692,14 +5508,14 @@ var copyHashed = (input, output, size) => Effect23.tryPromise({
4692
5508
  original: error
4693
5509
  })
4694
5510
  });
4695
- var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
5511
+ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
4696
5512
  const fs = yield* ReleaseFs;
4697
5513
  const { expected } = options;
4698
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)))
4699
5515
  return yield* fail("Staging sources do not match expected filenames");
4700
- const directory = resolve9(options.directory);
5516
+ const directory = resolve10(options.directory);
4701
5517
  const created = [];
4702
- const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
5518
+ const stage = Effect24.forEach(expected, (name) => Effect24.gen(function* () {
4703
5519
  const sourcePath = options.sources[name];
4704
5520
  if (typeof sourcePath !== "string" || !sourcePath)
4705
5521
  return yield* fail("Invalid staging source");
@@ -4710,7 +5526,7 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4710
5526
  const before = yield* step(() => input.stat());
4711
5527
  if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
4712
5528
  return yield* fail("Staging source changed");
4713
- const target = join13(directory, name);
5529
+ const target = join15(directory, name);
4714
5530
  const output = yield* scopedHandle(() => fs.open(target, "wx"));
4715
5531
  created.push(target);
4716
5532
  const copied = yield* copyHashed(input, output, before.size);
@@ -4719,10 +5535,10 @@ var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
4719
5535
  if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
4720
5536
  return yield* fail("Staging source changed");
4721
5537
  return { name, size: copied.size, digest: copied.digest };
4722
- }).pipe(Effect23.scoped), { concurrency: 1 });
4723
- 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(() => {}))))));
4724
5540
  });
4725
- var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
5541
+ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
4726
5542
  const requirements = parseReleaseConfig(options.config).requirements(options.tag);
4727
5543
  const expected = platformPayloads(requirements, options.platform);
4728
5544
  if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
@@ -4731,13 +5547,13 @@ var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
4731
5547
  });
4732
5548
  var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
4733
5549
  // src/library/steps.ts
4734
- import { join as join33 } from "path";
4735
- import { Effect as Effect24 } from "effect";
5550
+ import { join as join35 } from "path";
5551
+ import { Effect as Effect25 } from "effect";
4736
5552
 
4737
5553
  // ../../src/installer/installer-archive-members.ts
4738
- import { createHash as createHash10 } from "crypto";
4739
- import { lstat as lstat6, open as open5 } from "fs/promises";
4740
- 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";
4741
5557
 
4742
5558
  // ../../src/installer/native-executable.ts
4743
5559
  async function assertNativeExecutable(file, size, platform, what) {
@@ -4761,7 +5577,7 @@ async function assertNativeExecutable(file, size, platform, what) {
4761
5577
  var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
4762
5578
  function isWithin(root, path) {
4763
5579
  const rel = relative4(root, path);
4764
- return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute3(rel);
5580
+ return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute4(rel);
4765
5581
  }
4766
5582
  function normalizeArchiveMember(name) {
4767
5583
  return name.replace(/^\.\//, "").replaceAll("\\", "/");
@@ -4777,7 +5593,7 @@ function findArchiveMember(entries, expected, platform, message) {
4777
5593
  return found[0];
4778
5594
  }
4779
5595
  async function assertArchiveUnchanged(archive, before, message) {
4780
- const after = await lstat6(archive);
5596
+ const after = await lstat7(archive);
4781
5597
  if (!after.isFile() || after.isSymbolicLink() || !sameFile(after, before))
4782
5598
  throw new Error(message);
4783
5599
  }
@@ -4823,7 +5639,7 @@ async function extractArchiveMember(options) {
4823
5639
  }
4824
5640
  }
4825
5641
  async function assertInstallerExecutable(path, platform) {
4826
- const info = await lstat6(path);
5642
+ const info = await lstat7(path);
4827
5643
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
4828
5644
  throw new Error("Invalid installer executable");
4829
5645
  const file = await open5(path, "r");
@@ -4842,7 +5658,7 @@ async function assertEmbeddedArchive(path, size, archive) {
4842
5658
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
4843
5659
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
4844
5660
  throw new Error("Installer archive marker is missing");
4845
- const hash = createHash10("sha256");
5661
+ const hash = createHash13("sha256");
4846
5662
  let read = 0;
4847
5663
  for await (const chunk of file.createReadStream({
4848
5664
  start: position + marker.length,
@@ -4859,23 +5675,23 @@ async function assertEmbeddedArchive(path, size, archive) {
4859
5675
  }
4860
5676
 
4861
5677
  // ../../src/installer/installer-identity.ts
4862
- 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";
4863
5679
  import { tmpdir as tmpdir4 } from "os";
4864
- 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";
4865
5681
 
4866
5682
  // ../../src/installer/installer-image-mount.ts
4867
- import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir5, rm as rm4, stat } from "fs/promises";
4868
- 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";
4869
5685
  var FAILED_ATTACH_PROBES = 5;
4870
5686
  var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
4871
5687
  async function containsMountAt(path, expectedDevice) {
4872
- const info = await lstat7(path);
5688
+ const info = await lstat8(path);
4873
5689
  if (!info.isDirectory() || info.isSymbolicLink())
4874
5690
  return false;
4875
5691
  if (info.dev !== expectedDevice)
4876
5692
  return true;
4877
- for (const name of await readdir5(path)) {
4878
- 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);
4879
5695
  if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
4880
5696
  continue;
4881
5697
  if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
@@ -5069,8 +5885,8 @@ async function withInstallerImageRetries(options) {
5069
5885
  };
5070
5886
  const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
5071
5887
  for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
5072
- const directory = await mkdtemp3(join14(options.parent, options.prefix));
5073
- const mount = join14(directory, "mount");
5888
+ const directory = await mkdtemp3(join16(options.parent, options.prefix));
5889
+ const mount = join16(directory, "mount");
5074
5890
  const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
5075
5891
  let lifecycleStarted = false;
5076
5892
  try {
@@ -5238,7 +6054,7 @@ async function runInstallerCommand(args, env, options) {
5238
6054
 
5239
6055
  // ../../src/installer/installer-identity.ts
5240
6056
  async function identity(path) {
5241
- const info = await lstat8(path);
6057
+ const info = await lstat9(path);
5242
6058
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
5243
6059
  throw new Error("Invalid installer artifact");
5244
6060
  const { size, sha256 } = await hashFileAt(path, info, "Installer artifact changed");
@@ -5265,12 +6081,12 @@ async function verifyInstallerPayload(options) {
5265
6081
  else
5266
6082
  assertInstallerContext(parent, options.platform, process.platform, process.arch);
5267
6083
  assertPortableAppName(options.appName);
5268
- const installerPath = resolve10(options.installer), archivePath = resolve10(options.archive);
6084
+ const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
5269
6085
  const before = { installer: await identity(installerPath), archive: await identity(archivePath) };
5270
6086
  if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
5271
6087
  throw new Error("Installer archive exceeds bound");
5272
6088
  const env = environment(parent);
5273
- const temporary = await mkdtemp4(join15(tmpdir4(), "framework-installer-inspect-"));
6089
+ const temporary = await mkdtemp4(join17(tmpdir4(), "framework-installer-inspect-"));
5274
6090
  const cleanupIo = defaultInstallerImageMountIo(command);
5275
6091
  try {
5276
6092
  if (options.platform === "macos-arm64") {
@@ -5281,24 +6097,24 @@ async function verifyInstallerPayload(options) {
5281
6097
  env,
5282
6098
  run: command,
5283
6099
  work: async (mount) => {
5284
- const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
6100
+ const apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
5285
6101
  if (apps.length !== 1)
5286
6102
  throw new Error("Installer application is missing or ambiguous");
5287
- const resources = join15(mount, apps[0], "Contents", "Resources");
5288
- 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);
5289
6105
  if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
5290
6106
  throw new Error("Installer resources escape mounted image");
5291
- const plist = join15(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
6107
+ const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
5292
6108
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5293
6109
  throw new Error("Invalid installer property list");
5294
6110
  const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
5295
6111
  if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
5296
6112
  throw new Error("Invalid installer executable name");
5297
- await assertInstallerExecutable(join15(actualApp, "Contents", "MacOS", executable), options.platform);
5298
- 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"));
5299
6115
  if (archives.length !== 1)
5300
6116
  throw new Error("Installer archive is missing or ambiguous");
5301
- const embedded = await identity(join15(actualResources, archives[0]));
6117
+ const embedded = await identity(join17(actualResources, archives[0]));
5302
6118
  if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
5303
6119
  throw new Error("Installer archive differs from release archive");
5304
6120
  }
@@ -5316,7 +6132,7 @@ async function verifyInstallerPayload(options) {
5316
6132
  const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
5317
6133
  if (matches.length !== 1)
5318
6134
  throw new Error("Installer archive is missing or ambiguous");
5319
- const extracted = join15(temporary, "member");
6135
+ const extracted = join17(temporary, "member");
5320
6136
  const count = await extractArchiveMember({
5321
6137
  tar,
5322
6138
  archive: installerPath,
@@ -5327,7 +6143,7 @@ async function verifyInstallerPayload(options) {
5327
6143
  });
5328
6144
  if (options.platform === "windows-x64") {
5329
6145
  const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
5330
- const executable = join15(temporary, "setup.exe");
6146
+ const executable = join17(temporary, "setup.exe");
5331
6147
  await extractArchiveMember({
5332
6148
  tar,
5333
6149
  archive: installerPath,
@@ -5363,19 +6179,19 @@ async function verifyInstallerPayload(options) {
5363
6179
  }
5364
6180
 
5365
6181
  // ../../src/installer/installer-qualification-command.ts
5366
- import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
5367
- 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";
5368
6184
 
5369
6185
  // ../../src/installer/installer-observation.ts
5370
- import { randomBytes as randomBytes2 } from "crypto";
5371
- 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";
5372
6188
  import { createServer } from "net";
5373
- import { delimiter, dirname as dirname12, join as join29 } from "path";
6189
+ import { delimiter, dirname as dirname12, join as join31 } from "path";
5374
6190
 
5375
6191
  // ../../src/installer/installer-ci-bootstrap.ts
5376
- import { randomBytes } from "crypto";
5377
- import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
5378
- 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";
5379
6195
  import { fileURLToPath } from "url";
5380
6196
  var bootstrapModules = [
5381
6197
  "app/value-guards.js",
@@ -5398,27 +6214,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5398
6214
  const temp = runnerTemp(env);
5399
6215
  if (!isHostedRunner(env) || !temp)
5400
6216
  throw new Error("Installer bootstrap requires a disposable hosted runner");
5401
- const parent = await realpath2(temp);
5402
- if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
6217
+ const parent = await realpath3(temp);
6218
+ if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
5403
6219
  throw new Error("Runner temp cannot represent a Bun preload path");
5404
6220
  const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
5405
- const directory = await mkdtemp5(join16(parent, "framework-ci-"));
6221
+ const directory = await mkdtemp5(join18(parent, "framework-ci-"));
5406
6222
  try {
5407
6223
  for (const name of bootstrapModules) {
5408
- const contents = await readBoundedFile(join16(source, name), 2 * 1024 * 1024, "installer bootstrap module");
5409
- await mkdir5(dirname4(join16(directory, name)), { recursive: true, mode: 448 });
5410
- 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 });
5411
6227
  }
5412
- await writeFile4(join16(directory, "package.json"), `{"type":"module"}
6228
+ await writeFile4(join18(directory, "package.json"), `{"type":"module"}
5413
6229
  `, {
5414
6230
  flag: "wx",
5415
6231
  mode: 384
5416
6232
  });
5417
- const worker = join16(directory, "installer/installer-ci-worker.js");
6233
+ const worker = join18(directory, "installer/installer-ci-worker.js");
5418
6234
  return {
5419
6235
  directory,
5420
6236
  worker,
5421
- preflight: join16(directory, "installer/installer-ci-preflight.js"),
6237
+ preflight: join18(directory, "installer/installer-ci-preflight.js"),
5422
6238
  bunOptions: `--preload=${worker}`
5423
6239
  };
5424
6240
  } catch (error) {
@@ -5429,11 +6245,11 @@ async function prepareInstallerCiBootstrap(env = process.env) {
5429
6245
  async function preflightInstallerRuntime(options) {
5430
6246
  const { env, runtime, bootstrap } = options;
5431
6247
  const temp = runnerTemp(env);
5432
- if (!isHostedRunner(env) || !temp || !isAbsolute4(runtime))
6248
+ if (!isHostedRunner(env) || !temp || !isAbsolute5(runtime))
5433
6249
  throw new Error("Runtime preflight requires a disposable hosted runner");
5434
- const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
6250
+ const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
5435
6251
  const relativeBootstrap = relative5(tempRoot, bootstrapRoot);
5436
- 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}`)
5437
6253
  throw new Error("Invalid installer bootstrap location");
5438
6254
  await runInstallerPreflight({
5439
6255
  env,
@@ -5446,14 +6262,14 @@ async function preflightInstallerRuntime(options) {
5446
6262
  async function runInstallerPreflight(options) {
5447
6263
  const { env, runtime, worker, preflight } = options;
5448
6264
  for (const path of [worker, preflight]) {
5449
- const item = await lstat9(path);
6265
+ const item = await lstat10(path);
5450
6266
  if (!item.isFile() || item.isSymbolicLink())
5451
6267
  throw new Error("Invalid installer bootstrap module");
5452
6268
  }
5453
- const info = await lstat9(runtime);
6269
+ const info = await lstat10(runtime);
5454
6270
  if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
5455
6271
  throw new Error("Invalid candidate Bun runtime");
5456
- const temporary = await mkdtemp5(join16(options.parent, "framework-preflight-"));
6272
+ const temporary = await mkdtemp5(join18(options.parent, "framework-preflight-"));
5457
6273
  try {
5458
6274
  const clean = {};
5459
6275
  for (const key of [
@@ -5470,7 +6286,7 @@ async function runInstallerPreflight(options) {
5470
6286
  ])
5471
6287
  if (env[key])
5472
6288
  clean[key] = env[key];
5473
- const nonce = randomBytes(24).toString("hex");
6289
+ const nonce = randomBytes2(24).toString("hex");
5474
6290
  Object.assign(clean, {
5475
6291
  CI: "true",
5476
6292
  GITHUB_ACTIONS: "true",
@@ -5478,11 +6294,11 @@ async function runInstallerPreflight(options) {
5478
6294
  BUN_OPTIONS: `--preload=${worker}`,
5479
6295
  FRAMEWORK_CI_WORKER_ENTRY: preflight,
5480
6296
  FRAMEWORK_CI_NONCE: nonce,
5481
- FRAMEWORK_CI_ACK: join16(temporary, "ack"),
5482
- FRAMEWORK_CI_PERMIT: join16(temporary, "permit"),
6297
+ FRAMEWORK_CI_ACK: join18(temporary, "ack"),
6298
+ FRAMEWORK_CI_PERMIT: join18(temporary, "permit"),
5483
6299
  FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
5484
- FRAMEWORK_CI_OBSERVATION: join16(temporary, "observation"),
5485
- FRAMEWORK_CI_UNEXPECTED: join16(temporary, "unexpected"),
6300
+ FRAMEWORK_CI_OBSERVATION: join18(temporary, "observation"),
6301
+ FRAMEWORK_CI_UNEXPECTED: join18(temporary, "unexpected"),
5486
6302
  FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
5487
6303
  "https://example.invalid/framework-ci-sentinel"
5488
6304
  ])
@@ -5517,7 +6333,7 @@ async function runInstallerPreflight(options) {
5517
6333
  if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
5518
6334
  throw new Error("Candidate Bun runtime failed installer preflight");
5519
6335
  try {
5520
- await lstat9(join16(temporary, "unexpected"));
6336
+ await lstat10(join18(temporary, "unexpected"));
5521
6337
  throw new Error("Runtime preflight recorded unexpected activity");
5522
6338
  } catch (error) {
5523
6339
  if (errorCode(error) !== "ENOENT")
@@ -5529,8 +6345,8 @@ async function runInstallerPreflight(options) {
5529
6345
  }
5530
6346
 
5531
6347
  // ../../src/installer/installer-extraction.ts
5532
- import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir7, realpath as realpath3 } from "fs/promises";
5533
- 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";
5534
6350
  async function run(cmd, env) {
5535
6351
  return runInstallerCommand(cmd, env, {
5536
6352
  outputLimit: 8 * 1024 * 1024,
@@ -5538,8 +6354,8 @@ async function run(cmd, env) {
5538
6354
  failureMessage: "Installer preparation command failed"
5539
6355
  });
5540
6356
  }
5541
- async function digest2(path) {
5542
- const info = await lstat10(path);
6357
+ async function digest3(path) {
6358
+ const info = await lstat11(path);
5543
6359
  if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
5544
6360
  throw new Error("Invalid extracted file");
5545
6361
  const { size, sha256 } = await hashFileAt(path, info, "Extracted file changed");
@@ -5573,8 +6389,8 @@ async function prepareInstallerExecution(options) {
5573
6389
  const temp = runnerTemp(env);
5574
6390
  if (!temp)
5575
6391
  throw new Error("Missing runner temp directory");
5576
- const parent = await realpath3(temp), sourceInstaller = resolve11(options.installer), sourceArchive = resolve11(options.archive);
5577
- 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())
5578
6394
  throw new Error("Invalid runner temp directory");
5579
6395
  const verified = await verifyInstallerPayload({
5580
6396
  ...options,
@@ -5582,10 +6398,10 @@ async function prepareInstallerExecution(options) {
5582
6398
  archive: sourceArchive,
5583
6399
  env
5584
6400
  });
5585
- const directory = await mkdtemp6(join17(parent, "framework-installer-"));
6401
+ const directory = await mkdtemp6(join19(parent, "framework-installer-"));
5586
6402
  const imageIo = defaultInstallerImageMountIo(run);
5587
6403
  try {
5588
- const profile = join17(directory, "profile"), incoming = join17(directory, "incoming");
6404
+ const profile = join19(directory, "profile"), incoming = join19(directory, "incoming");
5589
6405
  await mkdir6(profile, { mode: 448 });
5590
6406
  await mkdir6(incoming, { mode: 448 });
5591
6407
  const clean = cleanEnv(env);
@@ -5598,34 +6414,34 @@ async function prepareInstallerExecution(options) {
5598
6414
  env: clean,
5599
6415
  run,
5600
6416
  work: async (mount) => {
5601
- 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"));
5602
6418
  if (apps.length !== 1 || apps[0] !== appName)
5603
6419
  throw new Error("Unexpected installer application");
5604
- const sourceApp = await realpath3(join17(mount, appName)), mountRoot = await realpath3(mount);
6420
+ const sourceApp = await realpath4(join19(mount, appName)), mountRoot = await realpath4(mount);
5605
6421
  if (!isWithin(mountRoot, sourceApp))
5606
6422
  throw new Error("Installer application escapes image");
5607
- const app = join17(incoming, appName);
6423
+ const app = join19(incoming, appName);
5608
6424
  await run(["/usr/bin/ditto", sourceApp, app], clean);
5609
- const actualApp = await realpath3(app), resources = await realpath3(join17(actualApp, "Contents", "Resources"));
5610
- 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))
5611
6427
  throw new Error("Copied installer escapes profile");
5612
- const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
6428
+ const plist = join19(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
5613
6429
  if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
5614
6430
  throw new Error("Invalid installer property list");
5615
6431
  const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
5616
6432
  if (!name || name === "." || name === ".." || /[\\/]/.test(name))
5617
6433
  throw new Error("Invalid installer executable");
5618
- const appExecutable = join17(actualApp, "Contents", "MacOS", name);
5619
- const sourceExecutable = join17(sourceApp, "Contents", "MacOS", name);
5620
- 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)))
5621
6437
  throw new Error("Installer executable escapes application");
5622
6438
  await assertInstallerExecutable(appExecutable, options.platform);
5623
- if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
6439
+ if (JSON.stringify(await digest3(sourceExecutable)) !== JSON.stringify(await digest3(appExecutable)))
5624
6440
  throw new Error("Copied installer executable differs");
5625
- const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
6441
+ const archives = (await readdir8(resources)).filter((value) => value.endsWith(".tar.zst"));
5626
6442
  if (archives.length !== 1)
5627
6443
  throw new Error("Missing installer archive");
5628
- const embedded = await digest2(join17(resources, archives[0]));
6444
+ const embedded = await digest3(join19(resources, archives[0]));
5629
6445
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5630
6446
  throw new Error("Copied installer archive differs");
5631
6447
  return executable;
@@ -5640,9 +6456,9 @@ async function prepareInstallerExecution(options) {
5640
6456
  assertInstallerLayout(options.platform, options.appName, names);
5641
6457
  const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
5642
6458
  if (options.platform === "windows-x64") {
5643
- const subdirectory = join17(incoming, ".installer");
6459
+ const subdirectory = join19(incoming, ".installer");
5644
6460
  await mkdir6(subdirectory);
5645
- executable = join17(incoming, `${options.appName}-Setup.exe`);
6461
+ executable = join19(incoming, `${options.appName}-Setup.exe`);
5646
6462
  await extractArchiveMember({
5647
6463
  tar,
5648
6464
  archive: sourceInstaller,
@@ -5656,11 +6472,11 @@ async function prepareInstallerExecution(options) {
5656
6472
  tar,
5657
6473
  archive: sourceInstaller,
5658
6474
  member: find(`.installer/${options.appName}-Setup.metadata.json`),
5659
- destination: join17(subdirectory, `${options.appName}-Setup.metadata.json`),
6475
+ destination: join19(subdirectory, `${options.appName}-Setup.metadata.json`),
5660
6476
  maximum: 1024 * 1024,
5661
6477
  env: clean
5662
6478
  });
5663
- const embeddedPath = join17(subdirectory, `${options.appName}-Setup.tar.zst`);
6479
+ const embeddedPath = join19(subdirectory, `${options.appName}-Setup.tar.zst`);
5664
6480
  await extractArchiveMember({
5665
6481
  tar,
5666
6482
  archive: sourceInstaller,
@@ -5669,11 +6485,11 @@ async function prepareInstallerExecution(options) {
5669
6485
  maximum: verified.archive.size,
5670
6486
  env: clean
5671
6487
  });
5672
- const embedded = await digest2(embeddedPath);
6488
+ const embedded = await digest3(embeddedPath);
5673
6489
  if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
5674
6490
  throw new Error("Copied installer archive differs");
5675
6491
  } else {
5676
- executable = join17(incoming, "installer");
6492
+ executable = join19(incoming, "installer");
5677
6493
  await extractArchiveMember({
5678
6494
  tar,
5679
6495
  archive: sourceInstaller,
@@ -5683,7 +6499,7 @@ async function prepareInstallerExecution(options) {
5683
6499
  env: clean
5684
6500
  });
5685
6501
  await assertInstallerExecutable(executable, options.platform);
5686
- await assertEmbeddedArchive(executable, (await lstat10(executable)).size, verified.archive);
6502
+ await assertEmbeddedArchive(executable, (await lstat11(executable)).size, verified.archive);
5687
6503
  await chmod(executable, 448);
5688
6504
  }
5689
6505
  }
@@ -5729,10 +6545,10 @@ function assertInstallerRendererObservation(value, offline = false) {
5729
6545
  }
5730
6546
 
5731
6547
  // ../../src/installer/installed-payload.ts
5732
- import { createHash as createHash11 } from "crypto";
5733
- 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";
5734
6550
  import { once } from "events";
5735
- import { join as join18, resolve as resolve12 } from "path";
6551
+ import { join as join20, resolve as resolve13 } from "path";
5736
6552
  import { createZstdDecompress } from "zlib";
5737
6553
  import { Parser } from "tar";
5738
6554
  function cleanEnv2(parent, forceLocal) {
@@ -5755,7 +6571,7 @@ async function command2(args, env, limit, collect) {
5755
6571
  const errors = (async () => {
5756
6572
  for await (const _part of child.stderr) {}
5757
6573
  })();
5758
- const hash = createHash11("sha256"), chunks = [];
6574
+ const hash = createHash14("sha256"), chunks = [];
5759
6575
  let size = 0;
5760
6576
  try {
5761
6577
  for await (const part of child.stdout) {
@@ -5778,7 +6594,7 @@ async function command2(args, env, limit, collect) {
5778
6594
  }
5779
6595
  }
5780
6596
  async function listArchive(archive, platform, env) {
5781
- const archiveInfo = await lstat11(archive);
6597
+ const archiveInfo = await lstat12(archive);
5782
6598
  if (!archiveInfo.isFile() || archiveInfo.isSymbolicLink() || archiveInfo.size < 1)
5783
6599
  throw new Error("Invalid staged archive");
5784
6600
  const version = await command2(["tar", "--version"], cleanEnv2(env, false), 65536, true);
@@ -5809,7 +6625,7 @@ async function readMembers(archive, limits, collect) {
5809
6625
  failure ??= new Error("Archive member missing or ambiguous");
5810
6626
  return entry.resume();
5811
6627
  }
5812
- const hash = createHash11("sha256"), chunks = [];
6628
+ const hash = createHash14("sha256"), chunks = [];
5813
6629
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
5814
6630
  members.set(entry.path, member);
5815
6631
  entry.on("data", (chunk) => {
@@ -5847,14 +6663,14 @@ async function readMembers(archive, limits, collect) {
5847
6663
  return members;
5848
6664
  }
5849
6665
  async function installed(path, root, limit) {
5850
- const info = await lstat11(path);
5851
- 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)))
5852
6668
  throw new Error("Invalid installed file");
5853
6669
  const { size, sha256 } = await hashFileAt(path, info, "Installed file changed");
5854
6670
  return { digest: sha256, size };
5855
6671
  }
5856
6672
  async function assertRuntimeBinary(path, platform) {
5857
- const info = await lstat11(path), file = await open6(path, "r");
6673
+ const info = await lstat12(path), file = await open6(path, "r");
5858
6674
  try {
5859
6675
  await assertNativeExecutable(file, info.size, platform, "runtime executable");
5860
6676
  } finally {
@@ -5868,8 +6684,8 @@ async function verifyInstalledPayload(options) {
5868
6684
  const sidecars = assertSidecarNames(options.sidecars ?? [], options.platform).map((name) => sidecarBundlePath(name, options.platform));
5869
6685
  if (!/^\d+\.\d+\.\d+$/.test(options.version) || options.version.length > 64)
5870
6686
  throw new Error("Invalid installed version");
5871
- const profile = await realpath4(options.profile), root = await realpath4(options.installedRoot), archive = resolve12(options.archive);
5872
- 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))
5873
6689
  throw new Error("Installed root escapes isolated profile");
5874
6690
  const { archiveInfo, entries } = await listArchive(archive, options.platform, env);
5875
6691
  assertPayloadLayout({
@@ -5903,7 +6719,7 @@ async function verifyInstalledPayload(options) {
5903
6719
  const member = members.get(path);
5904
6720
  if (!member || member.count !== 1)
5905
6721
  throw new Error("Archive member missing or ambiguous");
5906
- const current = await installed(join18(root, name), root, limit);
6722
+ const current = await installed(join20(root, name), root, limit);
5907
6723
  if (member.size !== current.size || member.digest !== current.digest)
5908
6724
  throw new Error(`Installed file differs from archive: ${name}`);
5909
6725
  if (name === "Resources/version.json") {
@@ -5925,8 +6741,8 @@ async function extractCandidateRuntime(options) {
5925
6741
  const temp = runnerTemp(env);
5926
6742
  if (!temp)
5927
6743
  throw new Error("Missing runner temp directory");
5928
- const tempRoot = await realpath4(temp), profile = await realpath4(options.profile), archive = resolve12(options.archive);
5929
- 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())
5930
6746
  throw new Error("Runtime profile escapes runner temp");
5931
6747
  const { archiveInfo, tarEnv, entries } = await listArchive(archive, options.platform, env);
5932
6748
  assertPayloadLayout({
@@ -5938,7 +6754,7 @@ async function extractCandidateRuntime(options) {
5938
6754
  const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
5939
6755
  const expected = `${prefix}/bun${suffix}`;
5940
6756
  const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
5941
- 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);
5942
6758
  const spawn = () => Bun.spawn({
5943
6759
  cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
5944
6760
  env: tarEnv,
@@ -5951,7 +6767,7 @@ async function extractCandidateRuntime(options) {
5951
6767
  const child = spawn(), errors = (async () => {
5952
6768
  for await (const _part of child.stderr) {}
5953
6769
  })();
5954
- const hash = createHash11("sha256");
6770
+ const hash = createHash14("sha256");
5955
6771
  let size = 0;
5956
6772
  try {
5957
6773
  for await (const part of child.stdout) {
@@ -5994,8 +6810,8 @@ async function extractCandidateRuntime(options) {
5994
6810
 
5995
6811
  // ../../src/installer/installer-process-cleanup.ts
5996
6812
  import { execFile as execFile2 } from "child_process";
5997
- import { realpath as realpath5 } from "fs/promises";
5998
- import { promisify } from "util";
6813
+ import { realpath as realpath6 } from "fs/promises";
6814
+ import { promisify as promisify2 } from "util";
5999
6815
 
6000
6816
  // ../../src/native/windows-process.ts
6001
6817
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
@@ -6039,7 +6855,7 @@ function windowsProcessImage(pid, options) {
6039
6855
  }
6040
6856
 
6041
6857
  // ../../src/installer/installer-process-cleanup.ts
6042
- var execute = promisify(execFile2);
6858
+ var execute = promisify2(execFile2);
6043
6859
  async function terminateGuardedWorker(options) {
6044
6860
  const { pid, runtime, platform } = options;
6045
6861
  assertInstallerContext(options.env, platform, process.platform, process.arch);
@@ -6060,7 +6876,7 @@ async function terminateGuardedWorker(options) {
6060
6876
  ])
6061
6877
  if (options.env[name])
6062
6878
  env[name] = options.env[name];
6063
- const expected = await realpath5(runtime);
6879
+ const expected = await realpath6(runtime);
6064
6880
  const actual = await runningExecutable(pid, platform, env);
6065
6881
  if (actual === undefined)
6066
6882
  return;
@@ -6111,7 +6927,7 @@ async function readMacosState(pid, env) {
6111
6927
  }
6112
6928
  async function runningExecutable(pid, platform, env) {
6113
6929
  if (platform === "linux-x64" || platform === "linux-arm64")
6114
- return realpath5(`/proc/${pid}/exe`).catch((error) => {
6930
+ return realpath6(`/proc/${pid}/exe`).catch((error) => {
6115
6931
  if (error.code === "ENOENT")
6116
6932
  return;
6117
6933
  throw error;
@@ -6129,7 +6945,7 @@ async function runningExecutable(pid, platform, env) {
6129
6945
  if (!listed)
6130
6946
  return;
6131
6947
  const state = macosProcess(listed.stdout);
6132
- return state === EXITING || state === undefined ? state : realpath5(state);
6948
+ return state === EXITING || state === undefined ? state : realpath6(state);
6133
6949
  }
6134
6950
  return windowsRunningExecutable(pid);
6135
6951
  }
@@ -6140,12 +6956,12 @@ async function windowsRunningExecutable(pid) {
6140
6956
  } catch (error) {
6141
6957
  throw new Error("Unable to query guarded process executable", { cause: error });
6142
6958
  }
6143
- return image === "missing" ? undefined : realpath5(image);
6959
+ return image === "missing" ? undefined : realpath6(image);
6144
6960
  }
6145
6961
 
6146
6962
  // ../../src/updates/install/update-swap-stage.ts
6147
- import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
6148
- 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";
6149
6965
 
6150
6966
  // ../../src/updates/install/update-handoff-plan.ts
6151
6967
  import { basename as basename6 } from "path";
@@ -6184,10 +7000,10 @@ function planUpdateHandoff(options) {
6184
7000
  }
6185
7001
 
6186
7002
  // ../../src/updates/install/update-extraction.ts
6187
- import { createHash as createHash12 } from "crypto";
7003
+ import { createHash as createHash15 } from "crypto";
6188
7004
  import { constants as constants4 } from "fs";
6189
- 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";
6190
- 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";
6191
7007
  import { Transform } from "stream";
6192
7008
  import { pipeline } from "stream/promises";
6193
7009
  import { createZstdDecompress as createZstdDecompress2 } from "zlib";
@@ -6216,12 +7032,12 @@ async function extractVerifiedUpdate(options) {
6216
7032
  "linux-x64": ["linux", "x64"],
6217
7033
  "linux-arm64": ["linux", "arm64"]
6218
7034
  };
6219
- 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)
6220
7036
  throw new Error("Invalid update extraction context");
6221
7037
  assertPortableAppName(appName);
6222
7038
  const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
6223
7039
  const archiveRoot = platform === "macos-arm64" ? `${appName}.app` : appName.replaceAll(" ", "");
6224
- const info = await lstat12(archive);
7040
+ const info = await lstat13(archive);
6225
7041
  if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
6226
7042
  throw new Error("Invalid update archive");
6227
7043
  const file = await open7(archive, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
@@ -6230,11 +7046,11 @@ async function extractVerifiedUpdate(options) {
6230
7046
  const before = await file.stat();
6231
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))
6232
7048
  throw new Error("Update archive verification failed");
6233
- const parent = await realpath6(options.directory);
6234
- if (!(await lstat12(parent)).isDirectory())
7049
+ const parent = await realpath7(options.directory);
7050
+ if (!(await lstat13(parent)).isDirectory())
6235
7051
  throw new Error("Invalid update staging directory");
6236
- directory = await mkdtemp7(join19(parent, "framework-update-extract-"));
6237
- 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");
6238
7054
  await mkdir7(payloadRoot, { mode: 448 });
6239
7055
  const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
6240
7056
  let invalid = false;
@@ -6252,7 +7068,7 @@ async function extractVerifiedUpdate(options) {
6252
7068
  done(null, chunk);
6253
7069
  }
6254
7070
  });
6255
- const hash = createHash12("sha256");
7071
+ const hash = createHash15("sha256");
6256
7072
  let compressedBytes = 0;
6257
7073
  const verifyInput = new Transform({
6258
7074
  transform(chunk, _encoding, done) {
@@ -6352,14 +7168,14 @@ async function extractVerifiedUpdate(options) {
6352
7168
  if (invalid)
6353
7169
  throw new Error("Unsafe or unsupported update archive entry");
6354
7170
  if (links.length) {
6355
- const bin = join19(payloadRoot, archiveRoot, "bin"), cef = join19(bin, "cef");
6356
- for (const path of [join19(payloadRoot, archiveRoot), bin, cef]) {
6357
- 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);
6358
7174
  if (!value.isDirectory() || value.isSymbolicLink())
6359
7175
  throw new Error("Invalid CEF link directory");
6360
7176
  }
6361
7177
  for (const link of links) {
6362
- 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);
6363
7179
  if (!value.isFile() || value.isSymbolicLink())
6364
7180
  throw new Error("Invalid CEF link target");
6365
7181
  await symlink(link.target, destination);
@@ -6367,12 +7183,12 @@ async function extractVerifiedUpdate(options) {
6367
7183
  }
6368
7184
  await rm7(decompressed);
6369
7185
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
6370
- const prefix = platform === "macos-arm64" ? join19(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
6371
- 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");
6372
7188
  const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
6373
7189
  const executables = [
6374
- join19(bin, `launcher${suffix}`),
6375
- join19(bin, `bun${suffix}`),
7190
+ join21(bin, `launcher${suffix}`),
7191
+ join21(bin, `bun${suffix}`),
6376
7192
  ...sidecars.map((name) => sidecarBundlePath(name, platform))
6377
7193
  ];
6378
7194
  const critical = [
@@ -6382,21 +7198,21 @@ async function extractVerifiedUpdate(options) {
6382
7198
  "Resources/app/client/index.html"
6383
7199
  ];
6384
7200
  for (const path of critical) {
6385
- const item = await lstat12(join19(payloadRoot, prefix, path));
7201
+ const item = await lstat13(join21(payloadRoot, prefix, path));
6386
7202
  if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
6387
7203
  throw new Error("Invalid critical update file");
6388
7204
  }
6389
7205
  for (const name of ["version.json", "build.json"]) {
6390
- const metadata = await lstat12(join19(resources, name));
7206
+ const metadata = await lstat13(join21(resources, name));
6391
7207
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
6392
7208
  throw new Error("Invalid update metadata");
6393
7209
  }
6394
- 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)
6395
7211
  throw new Error("Update version mismatch");
6396
- assertBuildMetadata(JSON.parse(await readFile6(join19(resources, "build.json"), "utf8")), renderer);
7212
+ assertBuildMetadata(JSON.parse(await readFile7(join21(resources, "build.json"), "utf8")), renderer);
6397
7213
  return {
6398
7214
  directory,
6399
- payload: join19(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
7215
+ payload: join21(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
6400
7216
  };
6401
7217
  } catch (error) {
6402
7218
  if (directory)
@@ -6408,19 +7224,19 @@ async function extractVerifiedUpdate(options) {
6408
7224
  }
6409
7225
 
6410
7226
  // ../../src/updates/install/update-swap.ts
6411
- import { createHash as createHash13 } from "crypto";
7227
+ import { createHash as createHash16 } from "crypto";
6412
7228
  import { constants as constants7 } from "fs";
6413
- import { lstat as lstat13, open as open10, readdir as readdir8, readFile as readFile7, readlink as readlink2 } from "fs/promises";
6414
- 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";
6415
7231
 
6416
7232
  // ../../src/updates/update-state-store.ts
6417
7233
  import { randomUUID as randomUUID2 } from "crypto";
6418
7234
  import { constants as constants6 } from "fs";
6419
7235
  import { open as open9, rename, unlink, writeFile as writeFile5 } from "fs/promises";
6420
- import { join as join21 } from "path";
7236
+ import { join as join23 } from "path";
6421
7237
 
6422
7238
  // ../../src/updates/locks/update-lock.ts
6423
- 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";
6424
7240
 
6425
7241
  // ../../src/updates/locks/native-file-lock.ts
6426
7242
  import { constants as constants5 } from "fs";
@@ -6588,7 +7404,7 @@ async function tryAcquireWindows(path, mode) {
6588
7404
  function updateLockPath(target) {
6589
7405
  if (!isCanonicalPath(target))
6590
7406
  throw new Error("Invalid update lock target");
6591
- return join20(dirname5(target), `.${basename7(target)}.framework-update.lock`);
7407
+ return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
6592
7408
  }
6593
7409
  async function tryAcquireUpdateLock(target) {
6594
7410
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -6653,7 +7469,7 @@ function parseState(value) {
6653
7469
  return Object.freeze(record);
6654
7470
  }
6655
7471
  async function readUpdateStageState(staging) {
6656
- 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");
6657
7473
  return text === undefined ? undefined : parseState(JSON.parse(text));
6658
7474
  }
6659
7475
  async function writeUpdateStageState(staging, state) {
@@ -6662,8 +7478,8 @@ async function writeUpdateStageState(staging, state) {
6662
7478
  async function replaceUpdateStageState(staging, state, durable) {
6663
7479
  if (typeof state.generation !== "string" || !isUuid(state.generation))
6664
7480
  throw new Error("Invalid update staging state");
6665
- const path = join21(staging, "state.json");
6666
- 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`);
6667
7483
  const contents = JSON.stringify(state) + `
6668
7484
  `;
6669
7485
  let renamed = false;
@@ -6701,12 +7517,12 @@ async function withUpdateLock(target, operation) {
6701
7517
  function updateStagingFor(target) {
6702
7518
  if (!isCanonicalPath(target))
6703
7519
  throw new Error("Invalid update target");
6704
- return join22(dirname6(target), `.${basename8(target)}.framework-update`);
7520
+ return join24(dirname6(target), `.${basename8(target)}.framework-update`);
6705
7521
  }
6706
7522
  async function readUpdateTreeVersion(tree) {
6707
- 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");
6708
7524
  try {
6709
- const value = JSON.parse(await readFile7(versionPath, "utf8"));
7525
+ const value = JSON.parse(await readFile8(versionPath, "utf8"));
6710
7526
  if (typeof value !== "object" || value === null || typeof value.version !== "string")
6711
7527
  return;
6712
7528
  return value.version;
@@ -6720,7 +7536,7 @@ function updateTreeIdentityFromStat(info) {
6720
7536
  return { device: info.dev.toString(10), inode: info.ino.toString(10) };
6721
7537
  }
6722
7538
  async function readUpdateTreeIdentity(tree) {
6723
- const info = await lstat13(tree, { bigint: true });
7539
+ const info = await lstat14(tree, { bigint: true });
6724
7540
  return updateTreeIdentityFromStat(info);
6725
7541
  }
6726
7542
  function sameUpdateTreeIdentity(left, right) {
@@ -6764,9 +7580,9 @@ async function readTreeFileBytes(file, buffer, length, position) {
6764
7580
  }
6765
7581
  async function readUpdateTreeDigest(tree, options = {}) {
6766
7582
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
6767
- const hash = createHash13("sha256");
7583
+ const hash = createHash16("sha256");
6768
7584
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
6769
- const root = await lstat13(tree, { bigint: true });
7585
+ const root = await lstat14(tree, { bigint: true });
6770
7586
  if (!root.isDirectory() || root.isSymbolicLink())
6771
7587
  throw new Error("Update tree is not a real directory");
6772
7588
  const rootDevice = root.dev;
@@ -6796,10 +7612,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
6796
7612
  if (before.isSymbolicLink())
6797
7613
  return [{ kind: "symlink", path, relative, before }];
6798
7614
  if (before.isDirectory()) {
6799
- 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);
6800
7616
  const children = await Promise.all(names.map(async (name) => {
6801
- const childPath = join22(path, name);
6802
- 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 })));
6803
7619
  }));
6804
7620
  return [{ kind: "directory", path, relative, before }, ...children.flat()];
6805
7621
  }
@@ -6813,7 +7629,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6813
7629
  return { kind: "none" };
6814
7630
  if (entry.kind === "symlink") {
6815
7631
  const target = Buffer.from(await readlink2(path), "utf8");
6816
- const after = await lstat13(path, { bigint: true });
7632
+ const after = await lstat14(path, { bigint: true });
6817
7633
  if (!sameTreeEntrySnapshot(before, after))
6818
7634
  throw new Error("Update tree changed while reading a symbolic link");
6819
7635
  return { kind: "bytes", bytes: target };
@@ -6832,7 +7648,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6832
7648
  const size = Number(before.size);
6833
7649
  const bytes = Buffer.allocUnsafe(size);
6834
7650
  await readTreeFileBytes(file, bytes, size, 0);
6835
- if (!sameTreeEntrySnapshot(before, await lstat13(path, { bigint: true })))
7651
+ if (!sameTreeEntrySnapshot(before, await lstat14(path, { bigint: true })))
6836
7652
  throw new Error("Update tree changed while reading a file");
6837
7653
  return { kind: "bytes", bytes };
6838
7654
  } finally {
@@ -6901,7 +7717,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6901
7717
  position = nextPosition;
6902
7718
  index = nextIndex;
6903
7719
  }
6904
- if (!sameTreeEntrySnapshot(entry.before, await lstat13(entry.path, { bigint: true })))
7720
+ if (!sameTreeEntrySnapshot(entry.before, await lstat14(entry.path, { bigint: true })))
6905
7721
  throw new Error("Update tree changed while reading a file");
6906
7722
  } finally {
6907
7723
  await file.close();
@@ -6917,11 +7733,11 @@ async function readUpdateTreeDigest(tree, options = {}) {
6917
7733
  await Promise.all(entries.map(async (entry) => {
6918
7734
  if (entry.kind !== "directory" || entry.relative === "")
6919
7735
  return;
6920
- const after = await limit(() => lstat13(entry.path, { bigint: true }));
7736
+ const after = await limit(() => lstat14(entry.path, { bigint: true }));
6921
7737
  if (!sameTreeEntrySnapshot(entry.before, after))
6922
7738
  throw new Error("Update tree changed while reading a directory");
6923
7739
  }));
6924
- const finalRoot = await lstat13(tree, { bigint: true });
7740
+ const finalRoot = await lstat14(tree, { bigint: true });
6925
7741
  if (!sameTreeEntrySnapshot(root, finalRoot))
6926
7742
  throw new Error("Update tree changed while its digest was computed");
6927
7743
  const count = Buffer.allocUnsafe(8);
@@ -6930,7 +7746,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
6930
7746
  return hash.digest("hex");
6931
7747
  }
6932
7748
  async function assertDirectory(path) {
6933
- const info = await lstat13(path);
7749
+ const info = await lstat14(path);
6934
7750
  if (!info.isDirectory() || info.isSymbolicLink())
6935
7751
  throw new Error("Update exchange requires real directories");
6936
7752
  }
@@ -6941,8 +7757,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6941
7757
  const { target, staging } = options;
6942
7758
  if (dirname6(staging) !== dirname6(target) || staging === target)
6943
7759
  throw new Error("Invalid update swap context");
6944
- const candidate = join22(staging, "candidate");
6945
- const legacyOld = join22(staging, "old");
7760
+ const candidate = join24(staging, "candidate");
7761
+ const legacyOld = join24(staging, "old");
6946
7762
  if (await pathExists(legacyOld))
6947
7763
  throw new Error("A legacy update tree requires recovery before another swap");
6948
7764
  await assertDirectory(target);
@@ -6971,11 +7787,11 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
6971
7787
  }
6972
7788
 
6973
7789
  // ../../src/updates/retention/retirement-inventory.ts
6974
- import { lstat as lstat15, readdir as readdir10 } from "fs/promises";
6975
- 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";
6976
7792
 
6977
7793
  // ../../src/updates/retention/update-retention-marker.ts
6978
- 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";
6979
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}$/;
6980
7796
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
6981
7797
  function assertCanonicalTarget(target) {
@@ -6994,28 +7810,28 @@ function isTreeIdentity(value) {
6994
7810
  function updateRetentionIntentPath(target, generation) {
6995
7811
  assertCanonicalTarget(target);
6996
7812
  assertGeneration(generation);
6997
- return join23(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
7813
+ return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
6998
7814
  }
6999
7815
 
7000
7816
  // ../../src/updates/retention/retention-prune-progress.ts
7001
- 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";
7002
7818
 
7003
7819
  // ../../src/updates/retention/retirement-records.ts
7004
- import { lstat as lstat14, readdir as readdir9, writeFile as writeFile6 } from "fs/promises";
7005
- 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";
7006
7822
  function updateRetirementPaths(target, generation) {
7007
7823
  if (!isCanonicalPath(target) || !isUuid(generation))
7008
7824
  throw new Error("Invalid update retirement identity");
7009
7825
  const prefix = `.${basename10(target)}.framework-retired-${generation}`;
7010
- const container = join24(dirname8(target), prefix);
7826
+ const container = join26(dirname8(target), prefix);
7011
7827
  return Object.freeze({
7012
7828
  container,
7013
- tree: join24(container, "tree"),
7014
- healthReceipt: join24(container, "healthy.json"),
7829
+ tree: join26(container, "tree"),
7830
+ healthReceipt: join26(container, "healthy.json"),
7015
7831
  healthTemporaryPrefix: ".healthy-",
7016
- claim: join24(dirname8(target), `${prefix}.claim.json`),
7832
+ claim: join26(dirname8(target), `${prefix}.claim.json`),
7017
7833
  claimTemporaryPrefix: `${prefix}.claim-`,
7018
- cleanupMarker: join24(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7834
+ cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
7019
7835
  cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
7020
7836
  });
7021
7837
  }
@@ -7066,7 +7882,7 @@ async function readCleanupMarker(path) {
7066
7882
  }
7067
7883
  async function pathInfo(path) {
7068
7884
  try {
7069
- return await lstat14(path);
7885
+ return await lstat15(path);
7070
7886
  } catch (error) {
7071
7887
  if (errorCode(error) === "ENOENT")
7072
7888
  return;
@@ -7114,15 +7930,15 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
7114
7930
  async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
7115
7931
  if (!isCanonicalPath(target) || !basename12(target))
7116
7932
  throw new Error("Invalid update retention prune gate target");
7117
- 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");
7118
7934
  }
7119
7935
 
7120
7936
  // ../../src/updates/retention/update-retirement.ts
7121
- import { lstat as lstat16, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
7122
- 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";
7123
7939
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7124
7940
  const { target, staging, currentVersion } = options;
7125
- const markerPath = join27(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7941
+ const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
7126
7942
  const markerInfo = await pathInfo(markerPath);
7127
7943
  if (!markerInfo)
7128
7944
  return "none";
@@ -7139,14 +7955,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7139
7955
  const containerInfo = await pathInfo(paths.container);
7140
7956
  if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
7141
7957
  return "recovery-required";
7142
- const containerEntries = await readdir11(paths.container);
7958
+ const containerEntries = await readdir12(paths.container);
7143
7959
  if (containerEntries.length !== 1 || containerEntries[0] !== "tree")
7144
7960
  return "recovery-required";
7145
7961
  const stagingInfo = await pathInfo(staging);
7146
7962
  if (stagingInfo) {
7147
7963
  if (!stagingInfo.isDirectory() || stagingInfo.isSymbolicLink())
7148
7964
  return "recovery-required";
7149
- const stagingEntries = await readdir11(staging);
7965
+ const stagingEntries = await readdir12(staging);
7150
7966
  if (stagingEntries.length !== 0)
7151
7967
  return "recovery-required";
7152
7968
  await rmdir(staging);
@@ -7160,14 +7976,14 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
7160
7976
 
7161
7977
  // ../../src/updates/install/update-swap-stage.ts
7162
7978
  async function assertInstalledVersion(options) {
7163
- const info = await lstat17(options.target);
7164
- 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)
7165
7981
  throw new Error("Invalid update install target");
7166
- const versionFile = join28(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
7167
- 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);
7168
7984
  if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
7169
7985
  throw new Error("Installed update version mismatch");
7170
- if (JSON.parse(await readFile8(versionFile, "utf8")).version !== options.version)
7986
+ if (JSON.parse(await readFile9(versionFile, "utf8")).version !== options.version)
7171
7987
  throw new Error("Installed update version mismatch");
7172
7988
  }
7173
7989
  async function stageUpdateSwap(options) {
@@ -7187,7 +8003,7 @@ async function stageUpdateSwap(options) {
7187
8003
  });
7188
8004
  const staging = updateStagingFor(plan.target);
7189
8005
  const preparing = await mkdtemp8(`${staging}.preparing-`);
7190
- const candidate = join28(staging, "candidate");
8006
+ const candidate = join30(staging, "candidate");
7191
8007
  let published = false;
7192
8008
  try {
7193
8009
  const extracted = await extractVerifiedUpdate({
@@ -7201,12 +8017,12 @@ async function stageUpdateSwap(options) {
7201
8017
  maxExpandedBytes: options.maxExpandedBytes,
7202
8018
  ...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
7203
8019
  });
7204
- renameExclusive(extracted.payload, join28(preparing, "candidate"));
8020
+ renameExclusive(extracted.payload, join30(preparing, "candidate"));
7205
8021
  await rm8(extracted.directory, { recursive: true, force: true });
7206
- const candidateTreeIdentity = await readUpdateTreeIdentity(join28(preparing, "candidate"));
8022
+ const candidateTreeIdentity = await readUpdateTreeIdentity(join30(preparing, "candidate"));
7207
8023
  if (!candidateTreeIdentity)
7208
8024
  throw new Error("Update candidate tree identity could not be read");
7209
- const candidateTreeDigest = await readUpdateTreeDigest(join28(preparing, "candidate"));
8025
+ const candidateTreeDigest = await readUpdateTreeDigest(join30(preparing, "candidate"));
7210
8026
  await writeUpdateStageState(preparing, newUpdateStageState({
7211
8027
  version: plan.version,
7212
8028
  previousVersion: options.currentVersion,
@@ -7225,7 +8041,7 @@ async function stageUpdateSwap(options) {
7225
8041
  });
7226
8042
  let existingInfo;
7227
8043
  try {
7228
- existingInfo = await lstat17(staging);
8044
+ existingInfo = await lstat18(staging);
7229
8045
  } catch (error) {
7230
8046
  if (errorCode(error) === "ENOENT") {
7231
8047
  const retirement = await reconcileRetirementCleanupMarkerWhileLocked({
@@ -7291,11 +8107,11 @@ function isolatedEnv(parent, profile, platform) {
7291
8107
  RUNNER_ENVIRONMENT: "github-hosted",
7292
8108
  HOME: profile,
7293
8109
  USERPROFILE: profile,
7294
- LOCALAPPDATA: join29(profile, "LocalAppData"),
7295
- XDG_DATA_HOME: join29(profile, ".local", "share"),
7296
- TMP: join29(profile, "tmp"),
7297
- TEMP: join29(profile, "tmp"),
7298
- 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"),
7299
8115
  ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
7300
8116
  });
7301
8117
  if (platform === "windows-x64")
@@ -7390,15 +8206,15 @@ async function observeInstalledApp(options) {
7390
8206
  await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
7391
8207
  stage("runtime-preflight-passed");
7392
8208
  for (const path of [
7393
- join29(prepared.profile, "LocalAppData"),
7394
- join29(prepared.profile, ".local", "share"),
7395
- join29(prepared.profile, "tmp")
8209
+ join31(prepared.profile, "LocalAppData"),
8210
+ join31(prepared.profile, ".local", "share"),
8211
+ join31(prepared.profile, "tmp")
7396
8212
  ])
7397
8213
  await mkdir9(path, { recursive: true, mode: 448 });
7398
8214
  const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
7399
- const installedRoot = mac ? join29(prepared.incoming, `${options.appName}.app`, "Contents") : join29(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
7400
- 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");
7401
- 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");
7402
8218
  const sidecars = options.sidecars ?? [];
7403
8219
  let foreignHits = 0;
7404
8220
  const sentinel = policy ? Bun.serve({
@@ -7448,8 +8264,8 @@ async function observeInstalledApp(options) {
7448
8264
  if (sentinel && (!(await fetch(foreignOrigin + "/", { signal: AbortSignal.timeout(1000) })).ok || foreignHits !== 1))
7449
8265
  throw new Error("Foreign network sentinel unavailable");
7450
8266
  foreignHits = 0;
7451
- const nonce = randomBytes2(24).toString("hex");
7452
- 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");
7453
8269
  const env = {
7454
8270
  ...baseEnv,
7455
8271
  FRAMEWORK_CI_NONCE: nonce,
@@ -7462,13 +8278,13 @@ async function observeInstalledApp(options) {
7462
8278
  };
7463
8279
  let launchRecord, expectedApp;
7464
8280
  if (mac && viaInstaller) {
7465
- const shimDir = join29(run.directory, "launch-shim");
8281
+ const shimDir = join31(run.directory, "launch-shim");
7466
8282
  await mkdir9(shimDir, { mode: 448 });
7467
- const path = join29(shimDir, "open");
8283
+ const path = join31(shimDir, "open");
7468
8284
  await writeFile8(path, shim, { flag: "wx", mode: 448 });
7469
8285
  await chmod2(path, 448);
7470
- expectedApp = join29(await realpath8(prepared.incoming), `${options.appName}.app`);
7471
- launchRecord = join29(run.directory, "launch-record");
8286
+ expectedApp = join31(await realpath9(prepared.incoming), `${options.appName}.app`);
8287
+ launchRecord = join31(run.directory, "launch-record");
7472
8288
  Object.assign(env, {
7473
8289
  PATH: shimDir + delimiter + (env.PATH ?? ""),
7474
8290
  FRAMEWORK_CI_EXPECTED_APP: expectedApp,
@@ -7504,7 +8320,7 @@ async function observeInstalledApp(options) {
7504
8320
  const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
7505
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"})`);
7506
8322
  }
7507
- 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"));
7508
8324
  if (installer && shouldLaunchInstalledApp({
7509
8325
  platform: options.platform,
7510
8326
  ready,
@@ -7512,17 +8328,17 @@ async function observeInstalledApp(options) {
7512
8328
  acknowledged: await pathExists(ack),
7513
8329
  installerExit: installer.exitCode
7514
8330
  })) {
7515
- if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile9(launchRecord, "utf8") !== expectedApp + `
8331
+ if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile10(launchRecord, "utf8") !== expectedApp + `
7516
8332
  `)
7517
8333
  throw new Error("Installer launch request mismatch");
7518
8334
  app = spawnApp();
7519
8335
  }
7520
8336
  if (await pathExists(ack) && !granted) {
7521
8337
  stage("worker-acknowledged");
7522
- if (await readFile9(ack, "utf8") !== nonce + `
8338
+ if (await readFile10(ack, "utf8") !== nonce + `
7523
8339
  `)
7524
8340
  throw new Error("Worker guard acknowledgement mismatch");
7525
- 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);
7526
8342
  if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
7527
8343
  throw new Error("Worker process identity mismatch");
7528
8344
  guardedPid = Number(match[2]);
@@ -7680,7 +8496,7 @@ async function observeInstalledApp(options) {
7680
8496
  await swapAfterExit(target, staged.staging);
7681
8497
  stage("update-swapped");
7682
8498
  await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
7683
- const directory = join29(prepared.directory, "update");
8499
+ const directory = join31(prepared.directory, "update");
7684
8500
  await mkdir9(directory, { mode: 448 });
7685
8501
  const updated = await observeRun({
7686
8502
  directory,
@@ -7729,9 +8545,9 @@ async function qualifyInstallerCommand(options) {
7729
8545
  const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
7730
8546
  if (!policy || !names || names.length !== 2)
7731
8547
  throw new Error("Installer qualification requires an explicit offline policy and payloads");
7732
- 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`);
7733
8549
  try {
7734
- await lstat18(destination);
8550
+ await lstat19(destination);
7735
8551
  throw new Error("Installer receipt already exists");
7736
8552
  } catch (error) {
7737
8553
  if (errorCode(error) !== "ENOENT")
@@ -7745,8 +8561,8 @@ async function qualifyInstallerCommand(options) {
7745
8561
  appName: app.appName,
7746
8562
  appId: app.appId,
7747
8563
  version: plan.version,
7748
- installer: join30(directory, names[0]),
7749
- archive: join30(directory, names[1]),
8564
+ installer: join32(directory, names[0]),
8565
+ archive: join32(directory, names[1]),
7750
8566
  expectedReads: parsed.expectedReads,
7751
8567
  offlinePolicy: policy,
7752
8568
  sidecars: parsed.sidecars
@@ -7777,11 +8593,11 @@ async function qualifyInstallerCommand(options) {
7777
8593
  }
7778
8594
 
7779
8595
  // ../../src/installer/installer-upgrade-command.ts
7780
- import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
7781
- 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";
7782
8598
 
7783
8599
  // ../../src/installer/upgrade-asset-download.ts
7784
- import { createHash as createHash14 } from "crypto";
8600
+ import { createHash as createHash17 } from "crypto";
7785
8601
  import { open as open11, unlink as unlink3 } from "fs/promises";
7786
8602
 
7787
8603
  // ../../src/installer/write-all.ts
@@ -7819,7 +8635,7 @@ async function downloadAsset(options) {
7819
8635
  discardStream(response.body);
7820
8636
  throw error;
7821
8637
  }
7822
- const hash = createHash14("sha256");
8638
+ const hash = createHash17("sha256");
7823
8639
  let completed = false;
7824
8640
  try {
7825
8641
  let size = 0;
@@ -7859,7 +8675,7 @@ async function downloadAsset(options) {
7859
8675
  }
7860
8676
 
7861
8677
  // ../../src/updates/feed/update-discovery.ts
7862
- import { createHash as createHash15 } from "crypto";
8678
+ import { createHash as createHash18 } from "crypto";
7863
8679
  var MAX_POINTER_BYTES = 262144;
7864
8680
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
7865
8681
  async function discoverSignedRelease(options) {
@@ -7895,7 +8711,7 @@ async function discoverSignedRelease(options) {
7895
8711
  throw new Error("No qualified channel descriptor is available");
7896
8712
  const { tag } = selected;
7897
8713
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
7898
- 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)
7899
8715
  throw new Error("Channel descriptor differs from its release");
7900
8716
  let signed;
7901
8717
  try {
@@ -7913,8 +8729,8 @@ async function discoverSignedRelease(options) {
7913
8729
  }
7914
8730
 
7915
8731
  // ../../src/updates/install/update-download.ts
7916
- import { mkdtemp as mkdtemp9, open as open12, realpath as realpath9, rm as rm9 } from "fs/promises";
7917
- 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";
7918
8734
  async function downloadVerifiedRelease(options) {
7919
8735
  const { descriptor, maxBytes } = options;
7920
8736
  const timeout = options.timeoutMs ?? 120000;
@@ -7946,13 +8762,13 @@ async function downloadVerifiedRelease(options) {
7946
8762
  if (length !== null && (!/^\d+$/.test(length) || Number(length) !== descriptor.asset.size)) {
7947
8763
  throw new Error("Release download size mismatch");
7948
8764
  }
7949
- const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
7950
- const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join31(root, "framework-update-"));
7951
- 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);
7952
8768
  if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
7953
8769
  throw new Error("Invalid update download directory");
7954
8770
  temporary = temporaryDirectory;
7955
- const path = join31(temporary, "archive");
8771
+ const path = join33(temporary, "archive");
7956
8772
  const file = await open12(path, "wx", 384);
7957
8773
  try {
7958
8774
  async function* writeChunks() {
@@ -8055,9 +8871,9 @@ async function qualifyUpgradeCommand(options) {
8055
8871
  const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
8056
8872
  if (!requirements.offlinePolicy || !names || names.length !== 2)
8057
8873
  throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
8058
- 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`);
8059
8875
  try {
8060
- await lstat19(destination);
8876
+ await lstat20(destination);
8061
8877
  throw new Error("Upgrade receipt already exists");
8062
8878
  } catch (error) {
8063
8879
  if (errorCode(error) !== "ENOENT")
@@ -8078,7 +8894,7 @@ async function qualifyUpgradeCommand(options) {
8078
8894
  const channel = "daily";
8079
8895
  const trust = { ...base, channel };
8080
8896
  const discovery = discoveryName(config, channel, platform);
8081
- const signed = await readJsonFile(join32(directory, discovery), 65536, "staged descriptor");
8897
+ const signed = await readJsonFile(join34(directory, discovery), 65536, "staged descriptor");
8082
8898
  const verified = verifyReleaseDescriptor(signed, trust);
8083
8899
  if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
8084
8900
  throw new Error("Untrusted staged descriptor");
@@ -8101,7 +8917,7 @@ async function qualifyUpgradeCommand(options) {
8101
8917
  return null;
8102
8918
  if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
8103
8919
  throw new Error("Previous release is not older than this release");
8104
- const work = join32(directory, `upgrade-${platform}`);
8920
+ const work = join34(directory, `upgrade-${platform}`);
8105
8921
  await mkdir10(work, { mode: 448 });
8106
8922
  const downloaded = await downloadVerifiedRelease({
8107
8923
  descriptor: previous,
@@ -8110,12 +8926,12 @@ async function qualifyUpgradeCommand(options) {
8110
8926
  timeoutMs: 600000,
8111
8927
  fetch: fetcher
8112
8928
  });
8113
- const previousArchive = join32(work, previous.asset.name);
8929
+ const previousArchive = join34(work, previous.asset.name);
8114
8930
  await rename2(downloaded.path, previousArchive);
8115
8931
  const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
8116
8932
  if (!installerName)
8117
8933
  throw new Error("Previous release has no installer for this platform");
8118
- const previousInstaller = join32(work, installerName);
8934
+ const previousInstaller = join34(work, installerName);
8119
8935
  await downloadAsset({
8120
8936
  feed,
8121
8937
  tag: previous.tag,
@@ -8139,7 +8955,7 @@ async function qualifyUpgradeCommand(options) {
8139
8955
  update: {
8140
8956
  descriptor,
8141
8957
  trust,
8142
- archive: join32(directory, names[1]),
8958
+ archive: join34(directory, names[1]),
8143
8959
  maxCompressedBytes: MAX_COMPRESSED_BYTES2,
8144
8960
  maxExpandedBytes: MAX_EXPANDED_BYTES2
8145
8961
  }
@@ -8162,7 +8978,7 @@ async function qualifyUpgradeCommand(options) {
8162
8978
  }
8163
8979
 
8164
8980
  // src/library/steps.ts
8165
- var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
8981
+ var selectRetainedStepEffect = (context) => Effect25.gen(function* () {
8166
8982
  const output = context.env.GITHUB_OUTPUT;
8167
8983
  if (!output)
8168
8984
  return yield* fail("Expected GITHUB_OUTPUT");
@@ -8174,7 +8990,7 @@ runId=${result.runId}
8174
8990
  ` : `reuse=false
8175
8991
  `));
8176
8992
  });
8177
- var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
8993
+ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
8178
8994
  const fs = yield* ReleaseFs;
8179
8995
  const [installerAsset, archiveAsset] = platformAssets(context);
8180
8996
  const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
@@ -8183,12 +8999,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8183
8999
  yield* step(() => fs.mkdir(directory, { recursive: true }));
8184
9000
  const packed = yield* scopedTempDirectory("framework-command-pack-");
8185
9001
  const sources = {
8186
- [installerAsset]: join33(artifacts, installer),
8187
- [archiveAsset]: join33(artifacts, archive)
9002
+ [installerAsset]: join35(artifacts, installer),
9003
+ [archiveAsset]: join35(artifacts, archive)
8188
9004
  };
8189
9005
  for (const policy of parsed.commandArtifacts) {
8190
9006
  const name = requirements.commandArtifacts[policy.kind][context.platform];
8191
- sources[name] = join33(packed, name);
9007
+ sources[name] = join35(packed, name);
8192
9008
  yield* step(() => packCommandArtifact({
8193
9009
  source: policy.build,
8194
9010
  archive: sources[name],
@@ -8197,8 +9013,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
8197
9013
  }));
8198
9014
  }
8199
9015
  return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
8200
- }).pipe(Effect24.scoped);
8201
- var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
9016
+ }).pipe(Effect25.scoped);
9017
+ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* () {
8202
9018
  const fs = yield* ReleaseFs;
8203
9019
  const parsed = parseReleaseConfig(context.config);
8204
9020
  const requirements = parsed.requirements(context.tag);
@@ -8206,10 +9022,10 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8206
9022
  const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
8207
9023
  if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
8208
9024
  return yield* fail("Staged platform directory contains unexpected files");
8209
- const [installer, archive] = platformAssets(context).map((name) => join33(directory, name));
9025
+ const [installer, archive] = platformAssets(context).map((name) => join35(directory, name));
8210
9026
  for (const policy of parsed.commandArtifacts)
8211
9027
  yield* step(() => readCommandArtifact({
8212
- archive: join33(directory, requirements.commandArtifacts[policy.kind][context.platform]),
9028
+ archive: join35(directory, requirements.commandArtifacts[policy.kind][context.platform]),
8213
9029
  executable: policy.executable,
8214
9030
  platform: context.platform
8215
9031
  }));
@@ -8225,12 +9041,12 @@ var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* ()
8225
9041
  }))
8226
9042
  };
8227
9043
  });
8228
- var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
9044
+ var qualifyStepEffect = (context, directory) => Effect25.gen(function* () {
8229
9045
  const mode = stepRenderer(context.env);
8230
9046
  yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
8231
9047
  yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
8232
9048
  });
8233
- var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
9049
+ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend(() => {
8234
9050
  const renderer = stepRenderer(context.env);
8235
9051
  return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
8236
9052
  });
@@ -8248,17 +9064,17 @@ import {
8248
9064
  mkdir as mkdir11,
8249
9065
  mkdtemp as mkdtemp10,
8250
9066
  open as open13,
8251
- readFile as readFile10,
8252
- realpath as realpath10,
9067
+ readFile as readFile11,
9068
+ realpath as realpath11,
8253
9069
  rm as rm10,
8254
9070
  writeFile as writeFile11
8255
9071
  } from "fs/promises";
8256
- import { dirname as dirname14, join as join34, resolve as resolve16 } from "path";
8257
- 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";
8258
9074
  var shasum = /^[a-f0-9]{64}$/;
8259
9075
  var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
8260
9076
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
8261
- var exec = promisify2(execFile3);
9077
+ var exec = promisify3(execFile3);
8262
9078
  function requireThat2(condition, message) {
8263
9079
  if (!condition)
8264
9080
  throw new Error(message);
@@ -8381,9 +9197,9 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8381
9197
  const trusted = trustedArtifacts.find((file) => file.name === name);
8382
9198
  return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
8383
9199
  }), "Package producer receipt must describe exactly the protected DEB and AppImage");
8384
- const destination = resolve16(options.output);
8385
- const parent = await realpath10(dirname14(destination));
8386
- 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-"));
8387
9203
  try {
8388
9204
  const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
8389
9205
  directory: work,
@@ -8391,11 +9207,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8391
9207
  sources
8392
9208
  })));
8393
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");
8394
- const deb = join34(work, expected.debName);
8395
- const image = join34(work, expected.appImageName);
9210
+ const deb = join36(work, expected.debName);
9211
+ const image = join36(work, expected.appImageName);
8396
9212
  const version = expected.tag.slice(1);
8397
9213
  parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
8398
- await verifyEmbeddedRuntime(image, await readFile10(join34(work, runtime.name)));
9214
+ await verifyEmbeddedRuntime(image, await readFile11(join36(work, runtime.name)));
8399
9215
  const offset = String(runtime.size);
8400
9216
  requireRegularDesktopEntry(await inspect("unsquashfs", [
8401
9217
  "-offset",
@@ -8425,8 +9241,8 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8425
9241
  await mkdir11(destination);
8426
9242
  try {
8427
9243
  for (const name of names)
8428
- await link(join34(work, name), join34(destination, name));
8429
- 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) + `
8430
9246
  `, {
8431
9247
  flag: "wx"
8432
9248
  });
@@ -8441,56 +9257,58 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
8441
9257
  }
8442
9258
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
8443
9259
  // src/library/linux-format-producer.ts
8444
- import { createHash as createHash16 } from "crypto";
8445
- import { createReadStream, createWriteStream } from "fs";
9260
+ import { createHash as createHash19 } from "crypto";
9261
+ import { createReadStream as createReadStream2, createWriteStream } from "fs";
8446
9262
  import {
8447
9263
  chmod as chmod4,
8448
9264
  cp,
8449
- lstat as lstat20,
9265
+ lstat as lstat21,
8450
9266
  lutimes,
8451
9267
  mkdir as mkdir12,
8452
9268
  mkdtemp as mkdtemp11,
8453
9269
  open as open14,
8454
- readdir as readdir12,
9270
+ readdir as readdir13,
8455
9271
  readlink as readlink3,
8456
- realpath as realpath11,
9272
+ realpath as realpath12,
8457
9273
  rm as rm11,
9274
+ symlink as symlink2,
8458
9275
  utimes,
8459
9276
  writeFile as writeFile12
8460
9277
  } from "fs/promises";
8461
- import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute6, join as join35, relative as relative6, resolve as resolve17 } from "path";
9278
+ import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative6, resolve as resolve18 } from "path";
8462
9279
  import { pipeline as pipeline2 } from "stream/promises";
8463
9280
  var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8464
- var sha256 = /^[a-f0-9]{64}$/;
9281
+ var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
9282
+ var sha2562 = /^[a-f0-9]{64}$/;
8465
9283
  var sum = async (path) => {
8466
- const hash = createHash16("sha256");
8467
- for await (const chunk of createReadStream(path))
9284
+ const hash = createHash19("sha256");
9285
+ for await (const chunk of createReadStream2(path))
8468
9286
  hash.update(chunk);
8469
9287
  return hash.digest("hex");
8470
9288
  };
8471
9289
  var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
8472
9290
  var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
8473
- function check(ok, message) {
9291
+ function check2(ok, message) {
8474
9292
  if (!ok)
8475
9293
  throw new Error(message);
8476
9294
  }
8477
9295
  async function exactCopy(pin, to) {
8478
- check(sha256.test(pin.sha256), "Missing protected input digest");
8479
- const before = await lstat20(pin.path);
8480
- check(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
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");
8481
9299
  const input = await open14(pin.path, "r");
8482
9300
  try {
8483
9301
  const after = await input.stat();
8484
- check(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
9302
+ check2(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
8485
9303
  await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
8486
9304
  } finally {
8487
9305
  await input.close();
8488
9306
  }
8489
- check((await lstat20(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
9307
+ check2((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
8490
9308
  }
8491
- async function regular(root, path) {
8492
- const file = join35(root, path);
8493
- check((await lstat20(file)).isFile() && await realpath11(file) === file, "Required bundle member is not a regular file");
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");
8494
9312
  return file;
8495
9313
  }
8496
9314
  async function elf(path, appImage = false) {
@@ -8498,38 +9316,38 @@ async function elf(path, appImage = false) {
8498
9316
  try {
8499
9317
  const h = Buffer.alloc(20);
8500
9318
  const { bytesRead } = await input.read(h, 0, h.length, 0);
8501
- check(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === 62 && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected native Linux x64 executable");
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");
8502
9320
  } finally {
8503
9321
  await input.close();
8504
9322
  }
8505
9323
  }
8506
9324
  async function normalizeTree(root, dir = root) {
8507
- for (const name of await readdir12(dir)) {
8508
- const file = join35(dir, name);
8509
- const st = await lstat20(file);
9325
+ for (const name of await readdir13(dir)) {
9326
+ const file = join37(dir, name);
9327
+ const st = await lstat21(file);
8510
9328
  if (st.isSymbolicLink()) {
8511
- check(!isAbsolute6(await readlink3(file)), "Absolute bundle symlink");
8512
- const target = relative6(root, await realpath11(file));
8513
- check(target !== ".." && !target.startsWith("../") && !isAbsolute6(target), "Escaping bundle symlink");
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");
8514
9332
  } else if (st.isDirectory()) {
8515
9333
  await chmod4(file, 493);
8516
9334
  await normalizeTree(root, file);
8517
9335
  } else {
8518
- check(st.isFile(), "Unsupported bundle entry");
9336
+ check2(st.isFile(), "Unsupported bundle entry");
8519
9337
  await chmod4(file, st.mode & 73 ? 493 : 420);
8520
9338
  }
8521
9339
  }
8522
9340
  }
8523
9341
  async function normalizeBuildTimes(directory, epoch) {
8524
- for (const name of (await readdir12(directory)).toSorted()) {
8525
- const path = join35(directory, name);
8526
- const info = await lstat20(path);
9342
+ for (const name of (await readdir13(directory)).toSorted()) {
9343
+ const path = join37(directory, name);
9344
+ const info = await lstat21(path);
8527
9345
  if (info.isSymbolicLink()) {
8528
9346
  await lutimes(path, epoch, epoch);
8529
9347
  } else if (info.isDirectory()) {
8530
9348
  await normalizeBuildTimes(path, epoch);
8531
9349
  } else {
8532
- check(info.isFile(), "Unsupported packaging entry");
9350
+ check2(info.isFile(), "Unsupported packaging entry");
8533
9351
  await utimes(path, epoch, epoch);
8534
9352
  }
8535
9353
  }
@@ -8537,30 +9355,37 @@ async function normalizeBuildTimes(directory, epoch) {
8537
9355
  await utimes(directory, epoch, epoch);
8538
9356
  }
8539
9357
  async function write(root, path, value, mode = 420) {
8540
- const target = join35(root, path);
9358
+ const target = join37(root, path);
8541
9359
  await mkdir12(dirname15(target), { recursive: true });
8542
9360
  await writeFile12(target, value, { flag: "wx", mode });
8543
9361
  await chmod4(target, mode);
8544
9362
  }
8545
9363
  function validatePolicy(policy) {
8546
- check([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha256.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");
8547
- check(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
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");
8548
9368
  }
8549
9369
  async function buildLinuxFormats(input, host) {
8550
9370
  const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
8551
- check(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
8552
- check(/^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");
8553
- check(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
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");
8554
9378
  const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
8555
9379
  validatePolicy(policy);
8556
- const requested = resolve17(input.output);
8557
- const parent = await realpath11(dirname15(requested));
8558
- const output = join35(parent, basename16(requested));
8559
- const work = await mkdtemp11(join35(parent, ".linux-formats-"));
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;
8560
9385
  try {
8561
- const archive = join35(work, "payload.tar.zst");
8562
- const tool = join35(work, "appimagetool");
8563
- const runtime = join35(work, "runtime");
9386
+ const archive = join37(work, "payload.tar.zst");
9387
+ const tool = join37(work, "appimagetool");
9388
+ const runtime = join37(work, "runtime");
8564
9389
  for (const [pin, dest] of [
8565
9390
  [input.archive, archive],
8566
9391
  [input.tool, tool],
@@ -8569,47 +9394,58 @@ async function buildLinuxFormats(input, host) {
8569
9394
  await exactCopy(pin, dest);
8570
9395
  await elf(tool, true);
8571
9396
  await elf(runtime, true);
8572
- await host.inspectAppArchive(archive);
8573
- check((await lstat20(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
8574
9397
  await chmod4(tool, 448);
8575
- const extracted = join35(work, "extract");
9398
+ const extracted = join37(work, "extract");
8576
9399
  await mkdir12(extracted);
8577
- await host.run("tar", [
8578
- "--zstd",
8579
- "--extract",
8580
- "--file",
8581
- archive,
8582
- "--directory",
8583
- extracted,
8584
- "--no-same-owner",
8585
- "--no-same-permissions"
8586
- ], { env });
8587
- const source = join35(extracted, policy.bundleRoot);
8588
- check((await lstat20(source)).isDirectory() && await realpath11(source) === source, "Wrong extracted app root");
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");
8589
9420
  await chmod4(source, 493);
8590
9421
  await normalizeTree(source);
8591
- await elf(await regular(source, policy.launcher));
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
+ }
8592
9427
  for (const pin of policy.debSetuid) {
8593
- const file = await regular(source, pin.path);
9428
+ const file = await regular2(source, pin.path);
8594
9429
  await elf(file);
8595
- check(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
9430
+ check2(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
8596
9431
  }
8597
- const icon = await regular(source, policy.icon);
8598
- check(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
9432
+ const icon = await regular2(source, policy.icon);
9433
+ check2(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
8599
9434
  const stem = `${policy.artifactStem}-${tag}-linux-x64`;
8600
9435
  const debName = `${stem}.deb`;
8601
9436
  const imageName = `${stem}.AppImage`;
8602
- const dest = join35(work, "result");
9437
+ const dest = join37(work, "result");
8603
9438
  await mkdir12(dest);
8604
9439
  const version = tag.slice(1);
8605
9440
  const installed = `usr/lib/${policy.packageName}`;
9441
+ const executable = policy.executable ?? policy.packageName;
8606
9442
  const desktopFile = `${policy.desktopId}.desktop`;
8607
9443
  const desktop = [
8608
9444
  "[Desktop Entry]",
8609
9445
  "Type=Application",
8610
9446
  `Name=${policy.name}`,
8611
9447
  `Comment=${policy.description}`,
8612
- `Exec=${policy.packageName} %U`,
9448
+ `Exec=${executable} %U`,
8613
9449
  `Icon=${policy.desktopId}`,
8614
9450
  `Categories=${policy.categories.join(";")};`,
8615
9451
  ...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
@@ -8618,20 +9454,28 @@ async function buildLinuxFormats(input, host) {
8618
9454
  ].join(`
8619
9455
  `);
8620
9456
  for (const format of ["deb", "appimage"]) {
8621
- const tree = join35(work, format);
8622
- await mkdir12(join35(tree, "usr", "lib"), { recursive: true });
8623
- const bundle = join35(tree, installed);
9457
+ checkAbort();
9458
+ const tree = join37(work, format);
9459
+ await mkdir12(join37(tree, "usr", "lib"), { recursive: true });
9460
+ const bundle = join37(tree, installed);
8624
9461
  await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
8625
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
+ `);
8626
9467
  await write(tree, `usr/share/applications/${desktopFile}`, desktop);
8627
- const iconDest = join35(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
9468
+ const iconDest = join37(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
8628
9469
  await mkdir12(dirname15(iconDest), { recursive: true });
8629
9470
  await cp(icon, iconDest, { force: false, errorOnExist: true });
8630
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));
8631
9475
  if (format === "deb") {
8632
9476
  for (const pin of policy.debSetuid)
8633
- await chmod4(await regular(bundle, pin.path), 2541);
8634
- await write(tree, `usr/bin/${policy.packageName}`, `#!/bin/sh
9477
+ await chmod4(await regular2(bundle, pin.path), 2541);
9478
+ await write(tree, `usr/bin/${executable}`, `#!/bin/sh
8635
9479
  export ${policy.formatEnvironment}=deb
8636
9480
  exec '/${installed}/${policy.launcher}' "$@"
8637
9481
  `, 493);
@@ -8647,9 +9491,15 @@ exec '/${installed}/${policy.launcher}' "$@"
8647
9491
  ].join(`
8648
9492
  `));
8649
9493
  await normalizeBuildTimes(tree, sourceDateEpoch);
8650
- await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join35(dest, debName)], { env });
9494
+ await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join37(dest, debName)], { env });
8651
9495
  } else {
8652
- const rootIcon = join35(tree, `${policy.desktopId}.svg`);
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`);
8653
9503
  await cp(icon, rootIcon, { force: false, errorOnExist: true });
8654
9504
  await chmod4(rootIcon, 420);
8655
9505
  await write(tree, desktopFile, desktop);
@@ -8663,7 +9513,7 @@ exec '/${installed}/${policy.launcher}' "$@"
8663
9513
  ].join(`
8664
9514
  `), 493);
8665
9515
  await normalizeBuildTimes(tree, sourceDateEpoch);
8666
- await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join35(dest, imageName)], {
9516
+ await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join37(dest, imageName)], {
8667
9517
  executable: tool,
8668
9518
  env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
8669
9519
  });
@@ -8671,9 +9521,9 @@ exec '/${installed}/${policy.launcher}' "$@"
8671
9521
  }
8672
9522
  const artifacts = [];
8673
9523
  for (const name of [debName, imageName]) {
8674
- const path = await regular(dest, name);
8675
- const size = (await lstat20(path)).size;
8676
- check(size > 0, "Empty produced artifact");
9524
+ const path = await regular2(dest, name);
9525
+ const size = (await lstat21(path)).size;
9526
+ check2(size > 0, "Empty produced artifact");
8677
9527
  artifacts.push({ name, size, sha256: await sum(path) });
8678
9528
  }
8679
9529
  const receipt = {
@@ -8681,26 +9531,42 @@ exec '/${installed}/${policy.launcher}' "$@"
8681
9531
  tag,
8682
9532
  sourceSha,
8683
9533
  sourceDateEpoch,
9534
+ ...input.identity,
8684
9535
  platform: "linux-x64",
8685
9536
  updateArchiveSha256: input.archive.sha256,
8686
9537
  artifacts
8687
9538
  };
9539
+ checkAbort();
8688
9540
  await mkdir12(output);
9541
+ outputOwned = true;
8689
9542
  try {
8690
9543
  for (const item of artifacts)
8691
- await cp(join35(dest, item.name), join35(output, basename16(item.name)), {
9544
+ await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
8692
9545
  force: false,
8693
9546
  errorOnExist: true
8694
9547
  });
9548
+ checkAbort();
8695
9549
  await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
8696
9550
  `);
9551
+ checkAbort();
8697
9552
  } catch (error) {
8698
9553
  await rm11(output, { recursive: true, force: true });
9554
+ outputOwned = false;
8699
9555
  throw error;
8700
9556
  }
8701
9557
  return receipt;
8702
9558
  } finally {
8703
- await rm11(work, { recursive: true, force: true });
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
+ }
8704
9570
  }
8705
9571
  }
8706
9572
  // src/framework-loader.ts
@@ -8726,9 +9592,9 @@ function electrobunArtifacts(appName, platform) {
8726
9592
 
8727
9593
  // src/library/daily-native-observer.ts
8728
9594
  import { execFile as execFile4 } from "child_process";
8729
- import { createHash as createHash17, randomBytes as randomBytes3 } from "crypto";
8730
- import { join as join36, resolve as resolve18 } from "path";
8731
- 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";
8732
9598
  var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
8733
9599
  const child = execFile4(process.execPath, ["--no-env-file", script], {
8734
9600
  cwd: input.profile,
@@ -8781,12 +9647,12 @@ function phaseEnvironment(env, profile) {
8781
9647
  ...clean,
8782
9648
  HOME: profile,
8783
9649
  USERPROFILE: profile,
8784
- LOCALAPPDATA: join36(profile, "LocalAppData"),
8785
- XDG_CONFIG_HOME: join36(profile, ".config"),
8786
- XDG_DATA_HOME: join36(profile, ".local", "share"),
8787
- TEMP: join36(profile, "tmp"),
8788
- TMP: join36(profile, "tmp"),
8789
- TMPDIR: join36(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")
8790
9656
  };
8791
9657
  }
8792
9658
  function parseBaseline(value, target) {
@@ -8804,9 +9670,9 @@ function driverPath(value) {
8804
9670
  throw new Error("Invalid native observer path");
8805
9671
  return value;
8806
9672
  }
8807
- var fixtureDigest = (nonce) => "sha256:" + createHash17("sha256").update(nonce).digest("hex");
9673
+ var fixtureDigest = (nonce) => "sha256:" + createHash20("sha256").update(nonce).digest("hex");
8808
9674
  var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
8809
- var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
9675
+ var observeDailyNativeEffect = (options, run) => Effect26.gen(function* () {
8810
9676
  const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
8811
9677
  const fs = yield* ReleaseFs;
8812
9678
  const git = yield* ReleaseGit;
@@ -8846,29 +9712,29 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8846
9712
  const tempStat = yield* step(() => fs.lstat(temp));
8847
9713
  if (!tempStat.isDirectory() || tempStat.isSymbolicLink())
8848
9714
  return yield* fail("Expected real runner temp directory");
8849
- const root = yield* Effect25.acquireRelease(step(() => fs.mkdtemp(join36(temp, "daily-native-"))), (dir) => Effect25.promise(() => fs.rm(dir, { recursive: true, force: true })));
8850
- const make = (name) => Effect25.gen(function* () {
8851
- const dir = join36(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);
8852
9718
  yield* step(() => fs.mkdir(dir, { mode: 448 }));
8853
9719
  return dir;
8854
9720
  });
8855
- const snapshot = (source, target, names) => Effect25.gen(function* () {
8856
- const directory = resolve18(source);
9721
+ const snapshot = (source, target, names) => Effect26.gen(function* () {
9722
+ const directory = resolve19(source);
8857
9723
  const info = yield* step(() => fs.lstat(directory));
8858
9724
  if (!info.isDirectory() || info.isSymbolicLink())
8859
9725
  return yield* fail("Expected real native input directory");
8860
9726
  return yield* stageExpectedFilesEffect({
8861
9727
  expected: names,
8862
9728
  directory: target,
8863
- sources: Object.fromEntries(names.map((name) => [name, join36(directory, name)]))
9729
+ sources: Object.fromEntries(names.map((name) => [name, join38(directory, name)]))
8864
9730
  });
8865
9731
  });
8866
9732
  const scriptName = path.endsWith(".mjs") ? "observer.mjs" : "observer.ts";
8867
- const script = join36(root, scriptName);
9733
+ const script = join38(root, scriptName);
8868
9734
  yield* stageExpectedFilesEffect({
8869
9735
  directory: root,
8870
9736
  expected: [scriptName],
8871
- sources: { [scriptName]: join36(cwd, path) }
9737
+ sources: { [scriptName]: join38(cwd, path) }
8872
9738
  });
8873
9739
  const hash = yield* step(() => git.run(["hash-object", "--no-filters", "--", script]));
8874
9740
  if (hash !== blob)
@@ -8881,9 +9747,9 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8881
9747
  ...previous.kind === "private-from-verified-payload" ? [prior.payload] : []
8882
9748
  ] : undefined;
8883
9749
  const earlier = previous && baseline ? yield* snapshot(previous.directory, baseline, baselineFiles) : undefined;
8884
- const freshProfile = (name) => Effect25.gen(function* () {
9750
+ const freshProfile = (name) => Effect26.gen(function* () {
8885
9751
  const dir = yield* make(name);
8886
- yield* step(() => fs.mkdir(join36(dir, "tmp"), { mode: 448 }));
9752
+ yield* step(() => fs.mkdir(join38(dir, "tmp"), { mode: 448 }));
8887
9753
  return dir;
8888
9754
  });
8889
9755
  const fresh = yield* freshProfile("fresh");
@@ -8906,14 +9772,14 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8906
9772
  if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
8907
9773
  throw new Error("Native observer changed during qualification");
8908
9774
  return output;
8909
- }).pipe(Effect25.mapError(() => new Error(`Native observer phase failed: ${phase}`)));
8910
- 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* () {
8911
9777
  const result = yield* call(phase, where);
8912
9778
  if (!isRecord(result) || !hasExactOwnKeys(result, ["version"]) || result.version !== version)
8913
9779
  return yield* fail(`Native observer did not observe the expected version: ${phase}`);
8914
9780
  return { version };
8915
9781
  });
8916
- const launch = (phase, version, where) => Effect25.gen(function* () {
9782
+ const launch = (phase, version, where) => Effect26.gen(function* () {
8917
9783
  const result = yield* call(phase, where);
8918
9784
  if (!isRecord(result) || !hasExactOwnKeys(result, ["version", "ready", "stopped"]) || result.version !== version || result.ready !== true || result.stopped !== true)
8919
9785
  return yield* fail(`Native observer did not observe a ready renderer: ${phase}`);
@@ -8926,7 +9792,7 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8926
9792
  const install = yield* installVersion("fresh-install", version, fresh);
8927
9793
  const launchedFresh = yield* launch("fresh-launch", version, fresh);
8928
9794
  const installedBefore = yield* installVersion("baseline-install", previous.tag.slice(1), upgrade);
8929
- const nonce = randomBytes3(24).toString("hex");
9795
+ const nonce = randomBytes4(24).toString("hex");
8930
9796
  const before = yield* call("fixture-write", upgrade, nonce);
8931
9797
  if (!confirmFixture(before, nonce))
8932
9798
  return yield* fail("Native baseline did not observe synthetic fixture");
@@ -8977,27 +9843,27 @@ var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
8977
9843
  observations
8978
9844
  }
8979
9845
  }, { os, arch });
8980
- }).pipe(Effect25.scoped);
9846
+ }).pipe(Effect26.scoped);
8981
9847
 
8982
9848
  // src/library/daily-batch.ts
8983
- import { join as join37, resolve as resolve19 } from "path";
8984
- import { Effect as Effect26, Exit as Exit4 } from "effect";
8985
- 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* () {
8986
9852
  const fs = yield* ReleaseFs;
8987
- const parent = resolve19(options.parent);
9853
+ const parent = resolve20(options.parent);
8988
9854
  const root = yield* step(() => fs.lstat(parent));
8989
9855
  if (!root.isDirectory() || root.isSymbolicLink())
8990
9856
  return yield* fail("Daily staging needs an existing real scratch parent");
8991
9857
  const original = yield* verifyDailyReleaseMatrixEffect(options);
8992
9858
  const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, options.identity.tag));
8993
- const directory = yield* Effect26.acquireRelease(step(() => fs.mkdtemp(join37(parent, "daily-candidate-"))), (path, exit) => Exit4.isSuccess(exit) ? Effect26.void : Effect26.promise(() => fs.rm(path, { recursive: true, force: true })));
8994
- const copy = (source, name, expected) => Effect26.gen(function* () {
8995
- const target = join37(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);
8996
9862
  yield* step(() => fs.mkdir(target, { mode: 448 }));
8997
9863
  yield* stageExpectedFilesEffect({
8998
9864
  expected,
8999
9865
  directory: target,
9000
- sources: Object.fromEntries(expected.map((file) => [file, join37(source, file)]))
9866
+ sources: Object.fromEntries(expected.map((file) => [file, join39(source, file)]))
9001
9867
  });
9002
9868
  return target;
9003
9869
  });
@@ -9007,26 +9873,26 @@ var stageDailyBatchEffect = (options) => Effect26.gen(function* () {
9007
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))
9008
9874
  return yield* fail("Daily inputs changed between inspection and local staging");
9009
9875
  const manifest = { schema: "framework/daily-staged-batch/v1", ...staged };
9010
- yield* step(() => fs.writeFile(join37(directory, "candidate.json"), JSON.stringify(manifest) + `
9876
+ yield* step(() => fs.writeFile(join39(directory, "candidate.json"), JSON.stringify(manifest) + `
9011
9877
  `, {
9012
9878
  flag: "wx",
9013
9879
  mode: 384
9014
9880
  }));
9015
9881
  return { directory, ...manifest };
9016
- }).pipe(Effect26.scoped);
9882
+ }).pipe(Effect27.scoped);
9017
9883
 
9018
9884
  // src/cli-runner.ts
9019
- 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";
9020
9886
  function failureError(cause) {
9021
9887
  const error = Cause3.squash(cause);
9022
9888
  if (error instanceof ReleaseFailure)
9023
9889
  return new Error(error.message);
9024
9890
  return error instanceof Error ? error : new Error(String(error));
9025
9891
  }
9026
- var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
9892
+ var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
9027
9893
  const { env } = yield* ReleaseConfig;
9028
9894
  const output = yield* ReleaseOutput;
9029
- 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);
9030
9896
  if (Exit5.isSuccess(exit))
9031
9897
  return 0;
9032
9898
  if (Cause3.hasInterruptsOnly(exit.cause))
@@ -9037,7 +9903,7 @@ var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
9037
9903
  return 1;
9038
9904
  });
9039
9905
  var readReleaseConfig = (path) => readBoundedJson(path, 262144);
9040
- var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.gen(function* () {
9906
+ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect28.gen(function* () {
9041
9907
  const fs = yield* ReleaseFs;
9042
9908
  const info = yield* step(() => fs.lstat(path));
9043
9909
  if (!info.isFile() || info.size < 1 || info.size > maxBytes)
@@ -9047,27 +9913,27 @@ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.
9047
9913
  return yield* refuse("file-changed", `${name[0].toUpperCase()}${name.slice(1)} changed`);
9048
9914
  return yield* step(async () => JSON.parse(bytes.toString("utf8")));
9049
9915
  });
9050
- var provideLivePorts = (program) => program.pipe(Effect27.provideService(ReleaseConfig, {
9916
+ var provideLivePorts = (program) => program.pipe(Effect28.provideService(ReleaseConfig, {
9051
9917
  env: process.env,
9052
9918
  platform: process.platform,
9053
9919
  arch: process.arch,
9054
9920
  cwd: process.cwd()
9055
- }), Effect27.provideService(ReleaseOutput, {
9921
+ }), Effect28.provideService(ReleaseOutput, {
9056
9922
  stdout: (text) => void process.stdout.write(text),
9057
9923
  stderr: (text) => void process.stderr.write(text)
9058
- }), 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, {
9059
9925
  sleep: (milliseconds) => Bun.sleep(milliseconds),
9060
9926
  now: () => new Date().toISOString()
9061
- }), Effect27.provideService(ReleaseFs, nodeFs), Effect27.provideService(ReleaseSigning, {
9927
+ }), Effect28.provideService(ReleaseFs, nodeFs), Effect28.provideService(ReleaseSigning, {
9062
9928
  privateKey: environmentKey(process.env),
9063
9929
  codesign: codesignRun
9064
9930
  }));
9065
9931
 
9066
9932
  // src/commands/prepare-stable-catalog.ts
9067
- import { createHash as createHash18 } from "crypto";
9068
- import { createReadStream as createReadStream2 } from "fs";
9069
- import { lstat as lstat21, mkdir as mkdir13, readFile as readFile11, rm as rm12, writeFile as writeFile13 } from "fs/promises";
9070
- import { basename as basename17, dirname as dirname16, join as join38 } 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";
9071
9937
 
9072
9938
  // src/library/stable-catalogs.ts
9073
9939
  function object(value) {
@@ -9228,10 +10094,10 @@ ShortDescription: ${quoted(desc)}
9228
10094
 
9229
10095
  // src/commands/prepare-stable-catalog.ts
9230
10096
  var read2 = async (path) => {
9231
- const stat = await lstat21(path);
10097
+ const stat = await lstat22(path);
9232
10098
  if (!stat.isFile() || stat.size > 1024 * 1024)
9233
10099
  throw new Error("Expected bounded ordinary JSON file");
9234
- return JSON.parse(await readFile11(path, "utf8"));
10100
+ return JSON.parse(await readFile12(path, "utf8"));
9235
10101
  };
9236
10102
  async function prepareStableCatalogCommand(args) {
9237
10103
  const [
@@ -9248,11 +10114,11 @@ async function prepareStableCatalogCommand(args) {
9248
10114
  ] = args;
9249
10115
  if (channel !== "homebrew" && channel !== "winget" || phase !== "preflight" && phase !== "published-stable" || !expectedSourceSha || !configPath || !receiptPath || !manifestPath || !artifact || !out || extra.length || phase === "published-stable" !== Boolean(stablePointerPath))
9250
10116
  throw new Error("Expected channel, phase, source SHA, config, receipt, manifest, archive, new output directory [stable pointer]");
9251
- const st = await lstat21(artifact);
10117
+ const st = await lstat22(artifact);
9252
10118
  if (!st.isFile())
9253
10119
  throw new Error("Expected ordinary installer file");
9254
- const hash = createHash18("sha256");
9255
- for await (const chunk of createReadStream2(artifact))
10120
+ const hash = createHash21("sha256");
10121
+ for await (const chunk of createReadStream3(artifact))
9256
10122
  hash.update(chunk);
9257
10123
  const files = prepareStableCatalog({
9258
10124
  channel,
@@ -9267,7 +10133,7 @@ async function prepareStableCatalogCommand(args) {
9267
10133
  await mkdir13(out);
9268
10134
  try {
9269
10135
  for (const entry of files) {
9270
- const target = join38(out, entry.path);
10136
+ const target = join40(out, entry.path);
9271
10137
  await mkdir13(dirname16(target), { recursive: true });
9272
10138
  await writeFile13(target, entry.contents, { flag: "wx" });
9273
10139
  }
@@ -9278,15 +10144,281 @@ async function prepareStableCatalogCommand(args) {
9278
10144
  }
9279
10145
  }
9280
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
+
9281
10413
  // src/library/apt/stage-apt-repository.ts
9282
10414
  import { spawnSync as spawnSync2 } from "child_process";
9283
- import { mkdir as mkdir14, readFile as readFile12, rm as rm13, writeFile as writeFile14 } from "fs/promises";
9284
- import { dirname as dirname17, isAbsolute as isAbsolute7, join as join39 } 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";
9285
10417
 
9286
10418
  // src/library/apt/apt-metadata.ts
9287
- import { createHash as createHash19 } from "crypto";
10419
+ import { createHash as createHash23 } from "crypto";
9288
10420
  import { gzipSync } from "zlib";
9289
- var sha2562 = (data) => createHash19("sha256").update(data).digest("hex");
10421
+ var sha2564 = (data) => createHash23("sha256").update(data).digest("hex");
9290
10422
  function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
9291
10423
  if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
9292
10424
  throw new Error("Invalid release tag");
@@ -9297,7 +10429,7 @@ function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
9297
10429
  if (matching.length !== 1)
9298
10430
  throw new Error("Require one staged Debian artifact");
9299
10431
  const asset = matching[0];
9300
- if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2562(deb))
10432
+ if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2564(deb))
9301
10433
  throw new Error("Staged Debian bytes do not match the verified release inventory");
9302
10434
  const fields = new Map;
9303
10435
  let lines = control.replaceAll(`\r
@@ -9347,7 +10479,7 @@ SHA256: ${asset.sha256}
9347
10479
  "Components: main",
9348
10480
  "Acquire-By-Hash: yes",
9349
10481
  "SHA256:",
9350
- ...members.map(([path, bytes]) => ` ${sha2562(bytes)} ${bytes.length} ${path}`),
10482
+ ...members.map(([path, bytes]) => ` ${sha2564(bytes)} ${bytes.length} ${path}`),
9351
10483
  ""
9352
10484
  ].join(`
9353
10485
  `);
@@ -9356,7 +10488,7 @@ SHA256: ${asset.sha256}
9356
10488
  release,
9357
10489
  files: new Map([
9358
10490
  ...members,
9359
- ...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2562(bytes)}`, bytes])
10491
+ ...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2564(bytes)}`, bytes])
9360
10492
  ])
9361
10493
  };
9362
10494
  }
@@ -9369,21 +10501,21 @@ function cmd(program, options, label) {
9369
10501
  return run.stdout;
9370
10502
  }
9371
10503
  async function add(path, bytes) {
9372
- await mkdir14(dirname17(path), { recursive: true });
10504
+ await mkdir14(dirname18(path), { recursive: true });
9373
10505
  await writeFile14(path, bytes, { flag: "wx" });
9374
10506
  }
9375
10507
  async function stageAptRepositoryCommand(args) {
9376
10508
  const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
9377
- 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 || !isAbsolute7(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))
9378
10510
  throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
9379
- const policy = JSON.parse(await readFile12(policyPath, "utf8"));
9380
- 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"));
9381
10513
  if (inventory.tag !== tag || !Array.isArray(inventory.assets))
9382
10514
  throw new Error("Verified inventory does not name requested release");
9383
- const deb = await readFile12(packagePath);
10515
+ const deb = await readFile13(packagePath);
9384
10516
  await mkdir14(output, { mode: 448 });
9385
10517
  try {
9386
- const stagedInput = join39(output, ".input.deb");
10518
+ const stagedInput = join42(output, ".input.deb");
9387
10519
  await writeFile14(stagedInput, deb, { mode: 384, flag: "wx" });
9388
10520
  const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
9389
10521
  const staged = stageAptMetadata({
@@ -9394,11 +10526,11 @@ async function stageAptRepositoryCommand(args) {
9394
10526
  control,
9395
10527
  now: new Date
9396
10528
  });
9397
- const base = join39(output, "dists", policy.suite);
9398
- await add(join39(output, staged.packagePath), deb);
10529
+ const base = join42(output, "dists", policy.suite);
10530
+ await add(join42(output, staged.packagePath), deb);
9399
10531
  for (const [path, contents] of staged.files)
9400
- await add(join39(base, path), contents);
9401
- await add(join39(base, "Release"), staged.release);
10532
+ await add(join42(base, path), contents);
10533
+ await add(join42(base, "Release"), staged.release);
9402
10534
  const flags = [
9403
10535
  "--batch",
9404
10536
  "--no-tty",
@@ -9415,34 +10547,37 @@ async function stageAptRepositoryCommand(args) {
9415
10547
  ["InRelease", "--clearsign"],
9416
10548
  ["Release.gpg", "--detach-sign"]
9417
10549
  ]) {
9418
- cmd("gpg", [...flags, "--armor", "--output", join39(base, name), mode, join39(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`);
9419
10551
  }
9420
10552
  const { unlink } = await import("fs/promises");
9421
10553
  await unlink(stagedInput);
9422
- await add(join39(output, "STAGED"), `${tag}
10554
+ await add(join42(output, "STAGED"), `${tag}
9423
10555
  `);
9424
10556
  return { tag, staged: true };
9425
10557
  } catch (error) {
9426
- await rm13(output, { recursive: true, force: true });
10558
+ await rm14(output, { recursive: true, force: true });
9427
10559
  throw error;
9428
10560
  }
9429
10561
  }
9430
10562
 
9431
10563
  // src/linux-channel-proof-cli.ts
9432
10564
  import { spawnSync as spawnSync3 } from "child_process";
9433
- import { createHash as createHash20 } from "crypto";
9434
- import { createReadStream as createReadStream3 } from "fs";
9435
- import { lstat as lstat22, readFile as readFile13, realpath as realpath12 } from "fs/promises";
9436
- import { join as join40 } 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";
9437
10572
  import { pathToFileURL } from "url";
9438
- function check2(ok, message) {
10573
+ function check3(ok, message) {
9439
10574
  if (!ok)
9440
10575
  throw new Error(message);
9441
10576
  }
9442
- async function hash(path) {
9443
- check2((await lstat22(path)).isFile(), "artifact must be a regular file");
9444
- const digest = createHash20("sha256");
9445
- for await (const chunk of createReadStream3(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))
9446
10581
  digest.update(chunk);
9447
10582
  return digest.digest("hex");
9448
10583
  }
@@ -9458,56 +10593,139 @@ function options(text, section) {
9458
10593
  continue;
9459
10594
  }
9460
10595
  const field = /^([a-z_]+)\s*=\s*(\S+)$/.exec(line);
9461
- check2(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
10596
+ check3(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
9462
10597
  values.set(field[1], field[2]);
9463
10598
  }
9464
- check2(matched, "expected exactly one repository section");
10599
+ check3(matched, "expected exactly one repository section");
9465
10600
  return values;
9466
10601
  }
9467
10602
  async function verifyRpmStage(stage) {
9468
- check2(/^[0-9a-f]{40}$/.test(stage.sourceSha), "expected an exact source commit");
9469
- check2(/^[a-z0-9][a-z0-9._+-]*$/.test(stage.packageName), "invalid RPM package name");
9470
- check2(/^[a-zA-Z0-9][a-zA-Z0-9._+~^]*$/.test(stage.version), "invalid RPM version");
9471
- check2(stage.architecture === "x86_64", "only x86_64 is supported");
9472
- check2(/^[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
+ }
9473
10611
  for (const artifact of [stage.payload, stage.rpm]) {
9474
- check2(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
9475
- check2(await hash(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
9476
- }
9477
- const repo = await realpath12(stage.repository);
9478
- const keyUrl = pathToFileURL(await realpath12(stage.publicKey)).href;
9479
- const config = options(await readFile13(stage.repoFile, "utf8"), stage.repoId);
9480
- check2(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
9481
- check2(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");
9482
10620
  for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
9483
- check2(config.get(flag) === "1", `${flag} must be enabled`);
10621
+ check3(config.get(flag) === "1", `${flag} must be enabled`);
9484
10622
  }
9485
10623
  const allowed = new Set(["name", "enabled", "baseurl", "gpgkey", "pkg_gpgcheck", "repo_gpgcheck"]);
9486
- check2([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
10624
+ check3([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
9487
10625
  for (const path of [
9488
10626
  stage.publicKey,
9489
- join40(repo, "repodata/repomd.xml"),
9490
- join40(repo, "repodata/repomd.xml.asc")
10627
+ join43(repo, "repodata/repomd.xml"),
10628
+ join43(repo, "repodata/repomd.xml.asc")
9491
10629
  ]) {
9492
- check2((await lstat22(path)).isFile(), "expected regular key and signed metadata files");
10630
+ check3((await lstat23(path)).isFile(), "expected regular key and signed metadata files");
9493
10631
  }
9494
- const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath12(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
9495
- check2(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
9496
- check2(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");
9497
10635
  return { kind: "rpm-staging-inputs", sourceSha: stage.sourceSha };
9498
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
+ }
9499
10717
  var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
9500
10718
  function verifyFlatpakCapabilities(policy, result) {
9501
- check2(/^[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");
9502
- check2(/^[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");
9503
- check2(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");
9504
10722
  const cap = policy.permissions;
9505
10723
  const actual = result.effectivePermissions;
9506
- check2(cap.sockets.every((name) => name === "wayland" || name === "pulseaudio"), "unsafe socket policy");
9507
- check2(cap.devices.every((name) => name === "dri"), "unsafe device policy");
9508
- check2(cap.sessionTalkNames.every((name) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(name) && !systemTalkDenied.test(name)), "unsafe session-bus policy");
9509
- check2(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");
9510
- check2([
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([
9511
10729
  result.localRepositoryInstall,
9512
10730
  result.upgradedAndRetainedData,
9513
10731
  result.sandboxedRenderer,
@@ -9520,11 +10738,181 @@ function verifyFlatpakCapabilities(policy, result) {
9520
10738
  return { kind: "flatpak-observations", sourceSha: result.sourceSha };
9521
10739
  }
9522
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
+
9523
10911
  // src/library/arch-publish.ts
9524
- import { createHash as createHash21 } from "crypto";
9525
- import { join as join41 } from "path";
9526
- import { tmpdir as tmpdir5 } from "os";
9527
- 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";
9528
10916
 
9529
10917
  // ../../src/release/arch-package.ts
9530
10918
  function archPkgver(tag) {
@@ -9652,11 +11040,11 @@ function renderArchPackage(input) {
9652
11040
  }
9653
11041
  function renderPacmanRepository(policy) {
9654
11042
  const { repository } = policy;
9655
- if (!repository)
11043
+ if (!repository?.keyFingerprint)
9656
11044
  return {};
9657
11045
  const stanza = [
9658
11046
  `[${repository.name}]`,
9659
- "SigLevel = Required DatabaseOptional",
11047
+ "SigLevel = Required TrustedOnly",
9660
11048
  `Server = ${repository.base}$arch`,
9661
11049
  ""
9662
11050
  ].join(`
@@ -9664,37 +11052,48 @@ function renderPacmanRepository(policy) {
9664
11052
  const bootstrap = `#!/bin/sh
9665
11053
  # Install ${policy.desktop.name} from the ${repository.name} pacman repository.
9666
11054
  #
9667
- # curl -fsSL ${repository.base}install.sh | sudo sh
9668
- # 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
9669
11057
  set -eu
9670
11058
 
9671
11059
  repo=${shell(repository.name)}
9672
11060
  package=${shell(policy.pkgname)}
9673
11061
  server=${shell(repository.base)}
9674
11062
  key_url=${shell(repository.publicKey)}
11063
+ expected=${shell(repository.keyFingerprint)}
9675
11064
 
9676
11065
  if [ "$(id -u)" -ne 0 ]; then
9677
- 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
9678
11067
  exit 1
9679
11068
  fi
9680
- 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
9681
11071
  command -v "$tool" >/dev/null || { echo "Missing $tool" >&2; exit 1; }
9682
11072
  done
9683
- # A fresh container or a minimal install may have no local keyring; lsign needs one.
9684
- [ -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
9685
11081
  tmp=$(mktemp)
9686
11082
  trap 'rm -f "$tmp"' EXIT
9687
- 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
9688
11094
  pacman-key --add "$tmp" >/dev/null
9689
- # The key's own fingerprint, so the script trusts exactly the key it just imported.
9690
- fingerprint=$(gpg --batch --show-keys --with-colons "$tmp" 2>/dev/null |
9691
- awk -F: '/^fpr:/{print $10; exit}')
9692
- [ -n "$fingerprint" ] || { echo "Could not read the signing key at $key_url" >&2; exit 1; }
9693
- # Trust the key locally. It is the only key this repository's packages are signed with.
9694
- pacman-key --lsign-key "$fingerprint" >/dev/null
9695
- if ! grep -q "^\\[$repo\\]" /etc/pacman.conf; then
9696
- printf '\\n[%s]\\nSigLevel = Required DatabaseOptional\\nServer = %s$arch\\n' "$repo" "$server" >> /etc/pacman.conf
9697
- 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
9698
11097
  pacman -Sy --noconfirm >/dev/null
9699
11098
  if [ "$#" -eq 0 ]; then set -- "$package"; fi
9700
11099
  exec pacman -S --needed --noconfirm "$@"
@@ -9705,7 +11104,7 @@ exec pacman -S --needed --noconfirm "$@"
9705
11104
  // src/library/arch-publish.ts
9706
11105
  var AUR_HOST_KEY = "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN";
9707
11106
  var MAX_LICENSE_BYTES = 1024 * 1024;
9708
- var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
11107
+ var feedBytes = (feed, path, maximum) => Effect30.gen(function* () {
9709
11108
  const { fetch: fetch2 } = yield* ReleaseFetch;
9710
11109
  const scope = feedUrl(feed);
9711
11110
  const response = yield* step(() => fetchReleaseLocation(`${scope}${path}`, scope, fetch2, AbortSignal.timeout(30000)));
@@ -9715,7 +11114,7 @@ var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
9715
11114
  }
9716
11115
  return yield* step(() => readReleaseBytes(response, maximum));
9717
11116
  });
9718
- var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
11117
+ var feedJson = (feed, path, maximum) => Effect30.gen(function* () {
9719
11118
  const bytes = yield* feedBytes(feed, path, maximum);
9720
11119
  if (!bytes)
9721
11120
  return null;
@@ -9727,13 +11126,13 @@ var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
9727
11126
  }
9728
11127
  });
9729
11128
  });
9730
- var readChannelTag = (feed, channel) => Effect28.gen(function* () {
11129
+ var readChannelTag = (feed, channel) => Effect30.gen(function* () {
9731
11130
  const parsed = yield* feedJson(feed, `channels/${channel}.json`, 262144);
9732
11131
  if (parsed === null)
9733
11132
  return null;
9734
11133
  return yield* step(async () => parseFeedRelease(parsed).tag);
9735
11134
  });
9736
- var readLicense = (url) => Effect28.gen(function* () {
11135
+ var readLicense = (url) => Effect30.gen(function* () {
9737
11136
  const { fetch: fetch2 } = yield* ReleaseFetch;
9738
11137
  const response = yield* step(() => fetch2(url, { redirect: "follow", signal: AbortSignal.timeout(30000) }));
9739
11138
  if (response.status !== 200 || !response.body) {
@@ -9741,12 +11140,12 @@ var readLicense = (url) => Effect28.gen(function* () {
9741
11140
  return yield* fail("Release license is unavailable");
9742
11141
  }
9743
11142
  const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
9744
- const sha256 = yield* step(async () => createHash21("sha256").update(bytes).digest("hex"));
11143
+ const sha256 = yield* step(async () => createHash26("sha256").update(bytes).digest("hex"));
9745
11144
  return { url, sha256 };
9746
11145
  });
9747
- var git2 = (args) => Effect28.gen(function* () {
11146
+ var git2 = (args) => Effect30.gen(function* () {
9748
11147
  const { run } = yield* ReleaseGit;
9749
- return yield* Effect28.tryPromise({
11148
+ return yield* Effect30.tryPromise({
9750
11149
  try: () => run(args),
9751
11150
  catch: (error) => {
9752
11151
  const stderr = String(error.stderr ?? "").trim().split(`
@@ -9759,11 +11158,11 @@ var git2 = (args) => Effect28.gen(function* () {
9759
11158
  }
9760
11159
  });
9761
11160
  });
9762
- var gitExit = (args) => Effect28.gen(function* () {
11161
+ var gitExit = (args) => Effect30.gen(function* () {
9763
11162
  const { run } = yield* ReleaseGit;
9764
- 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));
9765
11164
  });
9766
- var verifyArchRelease = (options) => Effect28.gen(function* () {
11165
+ var verifyArchRelease = (options) => Effect30.gen(function* () {
9767
11166
  const parsed = parseReleaseConfig(options.config);
9768
11167
  const { config } = options;
9769
11168
  const repository = typeof config.repository === "string" && isRepositorySlug(config.repository) ? config.repository : null;
@@ -9783,7 +11182,7 @@ var verifyArchRelease = (options) => Effect28.gen(function* () {
9783
11182
  if (!listed)
9784
11183
  return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
9785
11184
  const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
9786
- if (!bytes || bytes.length !== listed.size || createHash21("sha256").update(bytes).digest("hex") !== listed.sha256)
11185
+ if (!bytes || bytes.length !== listed.size || createHash26("sha256").update(bytes).digest("hex") !== listed.sha256)
9787
11186
  return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
9788
11187
  const json = yield* step(async () => {
9789
11188
  try {
@@ -9813,7 +11212,7 @@ var verifyArchRelease = (options) => Effect28.gen(function* () {
9813
11212
  return yield* fail("Signed descriptor does not bind the published archive");
9814
11213
  return descriptor.asset;
9815
11214
  });
9816
- var publishArchPackageEffect = (options) => Effect28.gen(function* () {
11215
+ var publishArchPackageEffect = (options) => Effect30.gen(function* () {
9817
11216
  const { archPackage: policy, feed } = parseReleaseConfig(options.config);
9818
11217
  if (!policy)
9819
11218
  return { status: "not-configured" };
@@ -9855,7 +11254,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9855
11254
  const directory = options.printDirectory;
9856
11255
  yield* step(() => fs.mkdir(directory, { recursive: true }));
9857
11256
  for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
9858
- yield* step(() => fs.writeFile(join41(directory, name), contents, { mode: 420 }));
11257
+ yield* step(() => fs.writeFile(join45(directory, name), contents, { mode: 420 }));
9859
11258
  }
9860
11259
  const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
9861
11260
  if (options.dryRun)
@@ -9867,15 +11266,15 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9867
11266
  const key = Buffer.from(encodedKey, "base64").toString("utf8");
9868
11267
  if (!key.includes("PRIVATE KEY"))
9869
11268
  return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
9870
- return yield* Effect28.gen(function* () {
9871
- const work = yield* step(() => fs.mkdtemp(join41(tmpdir5(), "arch-package-")));
9872
- 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(() => {
9873
11272
  return;
9874
11273
  }, () => {
9875
11274
  return;
9876
11275
  })));
9877
- const keyFile = join41(work, "aur_id_ed25519");
9878
- const knownHosts = join41(work, "aur_known_hosts");
11276
+ const keyFile = join45(work, "aur_id_ed25519");
11277
+ const knownHosts = join45(work, "aur_known_hosts");
9879
11278
  yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
9880
11279
  yield* step(() => fs.writeFile(keyFile, key.endsWith(`
9881
11280
  `) ? key : `${key}
@@ -9883,7 +11282,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9883
11282
  yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
9884
11283
  `, { mode: 420 }));
9885
11284
  const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
9886
- const checkout = join41(work, policy.pkgname);
11285
+ const checkout = join45(work, policy.pkgname);
9887
11286
  yield* git2([
9888
11287
  "-c",
9889
11288
  `core.sshCommand=${ssh}`,
@@ -9896,7 +11295,7 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9896
11295
  checkout
9897
11296
  ]);
9898
11297
  for (const [name, contents] of Object.entries(files))
9899
- yield* step(() => fs.writeFile(join41(checkout, name), contents, { mode: 420 }));
11298
+ yield* step(() => fs.writeFile(join45(checkout, name), contents, { mode: 420 }));
9900
11299
  yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
9901
11300
  const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
9902
11301
  if (staged === 0)
@@ -9917,35 +11316,35 @@ var publishArchPackageEffect = (options) => Effect28.gen(function* () {
9917
11316
  ]);
9918
11317
  yield* git2(["-C", checkout, "-c", `core.sshCommand=${ssh}`, "push", "origin", "HEAD:master"]);
9919
11318
  return { status: "published", ...base };
9920
- }).pipe(Effect28.scoped);
11319
+ }).pipe(Effect30.scoped);
9921
11320
  });
9922
11321
 
9923
11322
  // src/cli-commands.ts
9924
- var print = (value) => Effect29.gen(function* () {
11323
+ var print = (value) => Effect31.gen(function* () {
9925
11324
  const { stdout } = yield* ReleaseOutput;
9926
11325
  stdout(JSON.stringify(value) + `
9927
11326
  `);
9928
11327
  });
9929
- var say = (line) => Effect29.gen(function* () {
11328
+ var say = (line) => Effect31.gen(function* () {
9930
11329
  const { stdout } = yield* ReleaseOutput;
9931
11330
  stdout(line + `
9932
11331
  `);
9933
11332
  });
9934
11333
  var invalid = (message = "Invalid workflow invocation") => refuse("usage", message);
9935
11334
  var localFlag = (args) => args[0] === "--local" ? [true, args.slice(1)] : [false, args];
9936
- var hostPlatform = Effect29.gen(function* () {
11335
+ var hostPlatform = Effect31.gen(function* () {
9937
11336
  const { platform, arch } = yield* ReleaseConfig;
9938
11337
  return yield* step(async () => hostReleasePlatform(platform, arch));
9939
11338
  });
9940
- var withPlanGitHub = (env, effect) => Effect29.gen(function* () {
11339
+ var withPlanGitHub = (env, effect) => Effect31.gen(function* () {
9941
11340
  const github = yield* ReleaseGitHub;
9942
- return yield* effect.pipe(Effect29.provideService(ReleaseGitHub, {
11341
+ return yield* effect.pipe(Effect31.provideService(ReleaseGitHub, {
9943
11342
  run: github.withEnvironment ? github.withEnvironment(releasePlanGitHubEnvironment(env)) : github.run
9944
11343
  }));
9945
11344
  });
9946
11345
  var publish = (argv) => {
9947
11346
  const [local, args] = localFlag(argv);
9948
- 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* () {
9949
11348
  const [directory, configPath, out, ...extra] = args;
9950
11349
  if (!directory || !configPath || extra.length || !out !== !local)
9951
11350
  return yield* invalid();
@@ -9958,7 +11357,7 @@ var publish = (argv) => {
9958
11357
  const clock = yield* ReleaseClock;
9959
11358
  const platform = yield* hostPlatform;
9960
11359
  const { repository } = yield* localTagProvenanceEffect({ config, tag, sourceSha });
9961
- const plan = yield* Effect29.uninterruptible(stageLocalReleaseEffect({
11360
+ const plan = yield* Effect31.uninterruptible(stageLocalReleaseEffect({
9962
11361
  config,
9963
11362
  directory,
9964
11363
  out,
@@ -9976,7 +11375,7 @@ var publish = (argv) => {
9976
11375
  };
9977
11376
  var cut = (argv) => {
9978
11377
  const [local, args] = localFlag(argv);
9979
- 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* () {
9980
11379
  const [kind, path, sourceSha, ...extra] = args;
9981
11380
  if (kind !== "daily" || !path || extra.length || !sourceSha !== !local)
9982
11381
  return yield* invalid();
@@ -9986,7 +11385,7 @@ var cut = (argv) => {
9986
11385
  const { env } = yield* ReleaseConfig;
9987
11386
  if (local) {
9988
11387
  const platform = yield* hostPlatform;
9989
- const result = yield* Effect29.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
11388
+ const result = yield* Effect31.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
9990
11389
  return yield* print(result);
9991
11390
  }
9992
11391
  const result = yield* releaseCutCommand({
@@ -10000,7 +11399,7 @@ var cut = (argv) => {
10000
11399
  };
10001
11400
  var promote = (argv) => {
10002
11401
  const [local, args] = localFlag(argv);
10003
- 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* () {
10004
11403
  const [path, out, ...extra] = args;
10005
11404
  const { env } = yield* ReleaseConfig;
10006
11405
  const held = env.STABLE_PROMOTION_HELD;
@@ -10010,7 +11409,7 @@ var promote = (argv) => {
10010
11409
  if (local) {
10011
11410
  const clock = yield* ReleaseClock;
10012
11411
  const repository = yield* originRepositoryEffect;
10013
- const result = yield* Effect29.uninterruptible(runLocalPromotionEffect({
11412
+ const result = yield* Effect31.uninterruptible(runLocalPromotionEffect({
10014
11413
  config,
10015
11414
  out,
10016
11415
  now: clock.now(),
@@ -10023,7 +11422,7 @@ var promote = (argv) => {
10023
11422
  yield* print(yield* promotionCommand({ env, config }));
10024
11423
  }), { requireGitHubActions: !local });
10025
11424
  };
10026
- 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* () {
10027
11426
  const { env } = yield* ReleaseConfig;
10028
11427
  if (argv[0] === "--local") {
10029
11428
  const [configPath, tag, ...extra] = argv.slice(1);
@@ -10044,7 +11443,7 @@ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${r
10044
11443
  yield* finalizeReleasePleaseDraftEffect({ env, config, ...identity });
10045
11444
  yield* say("Qualified draft published as a prerelease");
10046
11445
  }));
10047
- 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* () {
10048
11447
  const [tag, path, ...extra] = args;
10049
11448
  if (!tag || !path || extra.length)
10050
11449
  return yield* invalid("Expected release tag and configuration file");
@@ -10052,7 +11451,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
10052
11451
  const { env } = yield* ReleaseConfig;
10053
11452
  yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
10054
11453
  }));
10055
- 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* () {
10056
11455
  const [identityPath, artifactPath, feed, ...extra] = args;
10057
11456
  const { env } = yield* ReleaseConfig;
10058
11457
  if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
@@ -10063,7 +11462,7 @@ var sign2 = (args) => runCommand("Unable to sign release artifact; check the ide
10063
11462
  }));
10064
11463
  var signDescriptors = (argv) => {
10065
11464
  const [local, args] = localFlag(argv);
10066
- 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* () {
10067
11466
  const [directory, configPath, ...extra] = args;
10068
11467
  const { env } = yield* ReleaseConfig;
10069
11468
  const {
@@ -10096,7 +11495,7 @@ var signDescriptors = (argv) => {
10096
11495
  }));
10097
11496
  }));
10098
11497
  };
10099
- 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* () {
10100
11499
  const args = [...argv];
10101
11500
  const flag = args.indexOf("--artifacts");
10102
11501
  const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1];
@@ -10148,9 +11547,9 @@ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.
10148
11547
  return yield* invalid(`Unknown release step ${String(name)}`);
10149
11548
  }
10150
11549
  }));
10151
- var verifyMacosSigning = (args) => Effect29.gen(function* () {
11550
+ var verifyMacosSigning = (args) => Effect31.gen(function* () {
10152
11551
  let problems = 0;
10153
- 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* () {
10154
11553
  const [app, flag, ...extra] = args;
10155
11554
  if (!app || extra.length || ![undefined, "--hardened"].includes(flag))
10156
11555
  return yield* invalid("usage");
@@ -10163,14 +11562,14 @@ var verifyMacosSigning = (args) => Effect29.gen(function* () {
10163
11562
  }));
10164
11563
  return code || (problems ? 1 : 0);
10165
11564
  });
10166
- var publishFramework = (args) => runCommand((error) => error.message, Effect29.gen(function* () {
11565
+ var publishFramework = (args) => runCommand((error) => error.message, Effect31.gen(function* () {
10167
11566
  const [archive, flag, ...extra] = args;
10168
11567
  if (!archive || extra.length || flag !== undefined && flag !== "--dry-run")
10169
11568
  return yield* invalid("Expected one framework package archive and an optional --dry-run");
10170
11569
  const { env } = yield* ReleaseConfig;
10171
11570
  yield* print(yield* step(() => publishFrameworkPackage({ env, archive, dryRun: flag === "--dry-run" })));
10172
11571
  }));
10173
- 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* () {
10174
11573
  const args = [...argv];
10175
11574
  const printIndex = args.indexOf("--print");
10176
11575
  const printDirectory = printIndex === -1 ? undefined : args[printIndex + 1];
@@ -10205,7 +11604,7 @@ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch pa
10205
11604
  ...printDirectory ? { printDirectory } : {}
10206
11605
  }));
10207
11606
  }));
10208
- 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* () {
10209
11608
  const [action, configPath, ...operands] = args;
10210
11609
  if (!configPath)
10211
11610
  return yield* invalid();
@@ -10256,25 +11655,42 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
10256
11655
  const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
10257
11656
  return yield* print(result);
10258
11657
  }));
10259
- 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* () {
10260
11659
  yield* print(yield* step(() => prepareStableCatalogCommand(args)));
10261
11660
  }));
10262
- 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* () {
10263
11662
  yield* print(yield* step(() => stageAptRepositoryCommand(args)));
10264
11663
  }));
10265
- var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
10266
- const [channel, input, ...extra] = args;
10267
- if (channel !== "rpm" && channel !== "flatpak" || !input || extra.length)
10268
- 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>]");
10269
11672
  const value = yield* readBoundedJson(input, 1024 * 1024, "Linux channel proof");
10270
- if (channel === "rpm") {
10271
- 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)));
10272
11687
  } else {
10273
11688
  const { policy, observation } = value;
10274
11689
  yield* print(yield* step(async () => verifyFlatpakCapabilities(policy, observation)));
10275
11690
  }
10276
11691
  }));
10277
11692
  var commands = {
11693
+ "build-linux-formats": buildLinuxFormatsCommand,
10278
11694
  cut,
10279
11695
  "daily-matrix": dailyMatrix,
10280
11696
  finalize,
@@ -10296,7 +11712,7 @@ var releaseCli = (argv) => {
10296
11712
  const command = name === undefined ? undefined : commands[name];
10297
11713
  if (command)
10298
11714
  return command(args);
10299
- return Effect29.gen(function* () {
11715
+ return Effect31.gen(function* () {
10300
11716
  const { stderr } = yield* ReleaseOutput;
10301
11717
  stderr(`Usage: adea-release <${Object.keys(commands).join("|")}> [arguments]; unknown command ${String(name)}
10302
11718
  `);
@@ -10305,4 +11721,20 @@ var releaseCli = (argv) => {
10305
11721
  };
10306
11722
 
10307
11723
  // src/cli.ts
10308
- 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
+ }