@adea-ai/app-framework-release-tools 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -34,7 +34,9 @@ __export(exports_src, {
34
34
  expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
35
35
  fileIdentity: () => fileIdentity2,
36
36
  finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
37
+ inspectAptRepositoryPlan: () => inspectAptRepositoryPlan,
37
38
  inspectDailyBatch: () => inspectDailyBatch,
39
+ inspectDailyPreSigning: () => inspectDailyPreSigning,
38
40
  inspectStagedStep: () => inspectStagedStep,
39
41
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
40
42
  planQualificationRun: () => planQualificationRun2,
@@ -3707,6 +3709,223 @@ function createDailyBatchR2Store(send) {
3707
3709
  }
3708
3710
  };
3709
3711
  }
3712
+ // src/library/apt/inspect-apt-repository-plan.ts
3713
+ import { createHash as createHash10 } from "crypto";
3714
+
3715
+ // src/library/apt/apt-metadata.ts
3716
+ import { createHash as createHash9 } from "crypto";
3717
+ import { gzipSync } from "zlib";
3718
+ var sha256 = (data) => createHash9("sha256").update(data).digest("hex");
3719
+ function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
3720
+ if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
3721
+ throw new Error("Invalid release tag");
3722
+ const { packageName, architecture, assetName: name, suite, origin } = policy;
3723
+ if (!/^[a-z][a-z0-9+.-]{1,62}$/.test(packageName) || architecture !== "amd64" && architecture !== "arm64" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(name) || suite !== "daily" && suite !== "stable" || !/^[A-Za-z0-9][A-Za-z0-9 .+_-]{0,62}$/.test(origin))
3724
+ throw new Error("Invalid Debian repository policy");
3725
+ const matching = assets.filter((asset) => asset.name === name);
3726
+ if (matching.length !== 1)
3727
+ throw new Error("Require one staged Debian artifact");
3728
+ const asset = matching[0];
3729
+ if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha256(deb))
3730
+ throw new Error("Staged Debian bytes do not match the verified release inventory");
3731
+ const fields = new Map;
3732
+ let lines = control.replaceAll(`\r
3733
+ `, `
3734
+ `).split(`
3735
+ `);
3736
+ if (lines.at(-1) === "")
3737
+ lines = lines.slice(0, -1);
3738
+ for (const [index, line] of lines.entries()) {
3739
+ if (/^[ \t]/.test(line) && index !== 0)
3740
+ continue;
3741
+ const field = /^([a-z][a-z0-9-]*):[ \t]*(.*)$/i.exec(line);
3742
+ if (!field || fields.has(field[1].toLowerCase()))
3743
+ throw new Error("Invalid or duplicate Debian control field");
3744
+ fields.set(field[1].toLowerCase(), field[2]);
3745
+ }
3746
+ for (const key of ["filename", "size", "md5sum", "sha1", "sha256", "sha512"])
3747
+ if (fields.has(key))
3748
+ throw new Error("Debian control includes repository-owned metadata");
3749
+ if (fields.get("package") !== packageName || fields.get("version") !== tag.slice(1) || fields.get("architecture") !== architecture || !fields.get("description"))
3750
+ throw new Error("Unexpected Debian package, version, architecture or description");
3751
+ if (!Number.isFinite(now.getTime()))
3752
+ throw new Error("Invalid release timestamp");
3753
+ const filename = `pool/main/${packageName[0]}/${packageName}/${name}`;
3754
+ const entries = `${lines.join(`
3755
+ `)}
3756
+ Filename: ${filename}
3757
+ Size: ${asset.size}
3758
+ SHA256: ${asset.sha256}
3759
+
3760
+ `;
3761
+ const plain = new TextEncoder().encode(entries);
3762
+ const compressed = gzipSync(plain);
3763
+ const directories = `main/binary-${architecture}`;
3764
+ const members = [
3765
+ [`${directories}/Packages`, plain],
3766
+ [`${directories}/Packages.gz`, compressed]
3767
+ ];
3768
+ const release = renderRelease({ origin, suite, now, architectures: [architecture], members });
3769
+ return {
3770
+ packagePath: filename,
3771
+ release,
3772
+ files: new Map([
3773
+ ...members,
3774
+ ...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha256(bytes)}`, bytes])
3775
+ ])
3776
+ };
3777
+ }
3778
+ function renderRelease({
3779
+ origin,
3780
+ suite,
3781
+ now,
3782
+ architectures,
3783
+ members
3784
+ }) {
3785
+ return [
3786
+ `Origin: ${origin}`,
3787
+ `Label: ${origin} ${suite}`,
3788
+ `Suite: ${suite}`,
3789
+ `Codename: ${suite}`,
3790
+ `Date: ${now.toUTCString()}`,
3791
+ `Valid-Until: ${new Date(now.getTime() + 30 * 86400000).toUTCString()}`,
3792
+ `Architectures: ${architectures.join(" ")}`,
3793
+ "Components: main",
3794
+ "Acquire-By-Hash: yes",
3795
+ "SHA256:",
3796
+ ...members.map(([path, bytes]) => ` ${sha256(bytes)} ${bytes.length} ${path}`),
3797
+ ""
3798
+ ].join(`
3799
+ `);
3800
+ }
3801
+ function stageMultiarchAptMetadata(variants) {
3802
+ const [first, second] = variants;
3803
+ if (!first || !second || variants.length !== 2 || new Set(variants.map(({ policy }) => policy.architecture)).size !== 2 || first.policy.assetName === second.policy.assetName || first.policy.packageName !== second.policy.packageName || first.policy.suite !== second.policy.suite || first.policy.origin !== second.policy.origin || first.tag !== second.tag || first.now.getTime() !== second.now.getTime())
3804
+ throw new Error("Require exactly one AMD64 and one ARM64 package for a single APT suite");
3805
+ const staged = variants.toSorted((a, b) => a.policy.architecture.localeCompare(b.policy.architecture, "en")).map((input) => ({
3806
+ ...stageAptMetadata(input),
3807
+ architecture: input.policy.architecture,
3808
+ deb: input.deb
3809
+ }));
3810
+ const files = new Map(staged.flatMap((result) => [...result.files]));
3811
+ return {
3812
+ packages: staged.map(({ packagePath, deb }) => ({ packagePath, deb })),
3813
+ files,
3814
+ release: renderRelease({
3815
+ origin: first.policy.origin,
3816
+ suite: first.policy.suite,
3817
+ now: first.now,
3818
+ architectures: staged.map(({ architecture }) => architecture),
3819
+ members: [...files].filter(([path]) => !path.includes("/by-hash/"))
3820
+ })
3821
+ };
3822
+ }
3823
+
3824
+ // src/library/apt/inspect-apt-repository-plan.ts
3825
+ var architectures = ["amd64", "arm64"];
3826
+ var tagPattern2 = /^v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
3827
+ var gitSha2 = /^[a-f0-9]{40}$/;
3828
+ var sha2562 = /^[a-f0-9]{64}$/;
3829
+ var assetNamePattern = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
3830
+ var maxDebBytes = 768 * 1024 ** 2;
3831
+ var maxControlBytes = 64 * 1024;
3832
+ var maxMetadataBytes = 256 * 1024;
3833
+ var hash2 = (bytes) => createHash10("sha256").update(bytes).digest("hex");
3834
+ var scalarIdentityFields = new Set(["package", "version", "architecture"]);
3835
+ function assertUnfoldedIdentity(control, architecture) {
3836
+ let field;
3837
+ for (const line of control.replaceAll(`\r
3838
+ `, `
3839
+ `).split(`
3840
+ `)) {
3841
+ if (/^[ \t]/.test(line)) {
3842
+ if (field && scalarIdentityFields.has(field))
3843
+ throw Error("Folded Debian identity field " + field + " for " + architecture);
3844
+ } else {
3845
+ field = /^([A-Za-z][A-Za-z0-9-]*):/.exec(line)?.[1]?.toLowerCase();
3846
+ }
3847
+ }
3848
+ }
3849
+ function inspectAptRepositoryPlan({
3850
+ expected,
3851
+ verifiedInventory,
3852
+ packages,
3853
+ now
3854
+ }) {
3855
+ const { app, suite, tag, sourceSha, workflowSha, manifestSha256 } = expected;
3856
+ if (app !== "adea" && app !== "cortana" || suite !== "daily" && suite !== "stable" || typeof tag !== "string" || !tagPattern2.test(tag) || typeof sourceSha !== "string" || !gitSha2.test(sourceSha) || /^0+$/.test(sourceSha) || typeof workflowSha !== "string" || !gitSha2.test(workflowSha) || /^0+$/.test(workflowSha) || typeof manifestSha256 !== "string" || !sha2562.test(manifestSha256) || /^0+$/.test(manifestSha256) || !(now instanceof Date) || !Number.isFinite(now.getTime()))
3857
+ throw Error("Invalid expected APT release identity");
3858
+ if (verifiedInventory.app !== app || verifiedInventory.suite !== suite || verifiedInventory.tag !== tag || verifiedInventory.sourceSha !== sourceSha || verifiedInventory.workflowSha !== workflowSha || verifiedInventory.manifestSha256 !== manifestSha256 || !Array.isArray(verifiedInventory.assets) || verifiedInventory.assets.length < 2 || verifiedInventory.assets.length > 256)
3859
+ throw Error("APT inventory bindings do not match the exact release");
3860
+ const inventory = new Map;
3861
+ for (const asset of verifiedInventory.assets) {
3862
+ if (!asset || typeof asset.name !== "string" || !assetNamePattern.test(asset.name) || typeof asset.sha256 !== "string" || !sha2562.test(asset.sha256) || !Number.isSafeInteger(asset.size) || asset.size < 1 || inventory.has(asset.name))
3863
+ throw Error("Invalid or duplicate APT inventory asset");
3864
+ inventory.set(asset.name, asset);
3865
+ }
3866
+ if (!Array.isArray(packages) || packages.length !== architectures.length)
3867
+ throw Error("APT plan needs exactly two ordinary packages");
3868
+ const origin = app === "adea" ? "Adea" : "Cortana";
3869
+ const packageName = app + "-desktop";
3870
+ const checkedInputs = architectures.map((architecture) => {
3871
+ const matches = packages.filter((entry) => entry?.architecture === architecture);
3872
+ if (matches.length !== 1)
3873
+ throw Error("APT plan needs exactly one package for " + architecture);
3874
+ const { bytes, control } = matches[0];
3875
+ const assetName = origin + "-" + tag + "-linux-" + (architecture === "amd64" ? "x64" : "arm64") + ".deb";
3876
+ const binding = inventory.get(assetName);
3877
+ if (!binding)
3878
+ throw Error("Missing independently bound APT package for " + architecture);
3879
+ if (!(bytes instanceof Uint8Array) || bytes.buffer instanceof SharedArrayBuffer || bytes.length !== binding.size || bytes.length > maxDebBytes || hash2(bytes) !== binding.sha256)
3880
+ throw Error("APT package bytes differ from verified inventory for " + architecture);
3881
+ if (typeof control !== "string" || !control || Buffer.byteLength(control) > maxControlBytes || containsAsciiControl(control.replaceAll(`\r
3882
+ `, `
3883
+ `).replaceAll(`
3884
+ `, "").replaceAll("\t", "")))
3885
+ throw Error("Invalid Debian control data for " + architecture);
3886
+ assertUnfoldedIdentity(control, architecture);
3887
+ return {
3888
+ policy: { packageName, assetName, architecture, suite, origin },
3889
+ tag,
3890
+ now,
3891
+ assets: [binding],
3892
+ deb: bytes,
3893
+ control
3894
+ };
3895
+ });
3896
+ const staged = stageMultiarchAptMetadata(checkedInputs);
3897
+ const documents = [
3898
+ { path: "dists/" + suite + "/Release", bytes: new TextEncoder().encode(staged.release) },
3899
+ ...Array.from(staged.files, ([path, bytes]) => ({
3900
+ path: "dists/" + suite + "/" + path,
3901
+ bytes
3902
+ })).filter(({ path }) => path.includes("/by-hash/"))
3903
+ ].map(({ path, bytes }) => {
3904
+ if (bytes.length < 1 || bytes.length > maxMetadataBytes)
3905
+ throw Error("APT metadata size exceeded");
3906
+ return { path, bytes, size: bytes.length, sha256: hash2(bytes) };
3907
+ });
3908
+ const packagesToInspect = staged.packages.map(({ packagePath }, index) => {
3909
+ const { policy, assets } = checkedInputs[index];
3910
+ const binding = assets[0];
3911
+ return {
3912
+ path: packagePath,
3913
+ architecture: policy.architecture,
3914
+ name: binding.name,
3915
+ size: binding.size,
3916
+ sha256: binding.sha256
3917
+ };
3918
+ });
3919
+ return {
3920
+ schema: "framework/apt-inspection/v1",
3921
+ identity: { app, suite, tag, sourceSha, workflowSha, manifestSha256 },
3922
+ selectedPackages: packagesToInspect,
3923
+ unsignedMetadata: documents,
3924
+ inventoryAuthenticatedByPlanner: false,
3925
+ repositorySigningAuthorized: false,
3926
+ publicationAuthorized: false
3927
+ };
3928
+ }
3710
3929
  // src/library/apt/apt-r2-store.ts
3711
3930
  var key = /^apt\/(?:adea|cortana)\/(?:archive-keyring\.gpg|dists\/(?:daily|stable)\/(?:InRelease|main\/binary-(?:amd64|arm64)\/by-hash\/SHA256\/[0-9a-f]{64})|pool\/main\/(?:a\/adea-desktop\/Adea|c\/cortana-desktop\/Cortana)-v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})-linux-(?:x64|arm64)\.deb)$/;
3712
3931
  var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
@@ -3790,7 +4009,7 @@ function createAptR2Store(send) {
3790
4009
  };
3791
4010
  }
3792
4011
  // src/library/apt/publish-apt-repository.ts
3793
- import { createHash as createHash9 } from "crypto";
4012
+ import { createHash as createHash11 } from "crypto";
3794
4013
  import { gunzipSync } from "zlib";
3795
4014
  var ARCHES = ["amd64", "arm64"];
3796
4015
  var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
@@ -3798,7 +4017,7 @@ var hex3 = /^[0-9a-f]{64}$/;
3798
4017
  var indexLimit = 256 * 1024;
3799
4018
  var debLimit = 768 * 1024 ** 2;
3800
4019
  var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
3801
- var digest = (bytes) => createHash9("sha256").update(bytes).digest("hex");
4020
+ var digest = (bytes) => createHash11("sha256").update(bytes).digest("hex");
3802
4021
  var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
3803
4022
  var same2 = (a, b) => Buffer.from(a).equals(b);
3804
4023
  function need(condition, message) {
@@ -3938,7 +4157,7 @@ async function publishAptRepository({ app, suite, tag, assets }, port, now = Dat
3938
4157
  return { tag, changed: true };
3939
4158
  }
3940
4159
  // src/library/apt/verify-apt-signature.ts
3941
- import { createHash as createHash10 } from "crypto";
4160
+ import { createHash as createHash12 } from "crypto";
3942
4161
  import { spawnSync as spawnSync2 } from "child_process";
3943
4162
  import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
3944
4163
  import { tmpdir as tmpdir4 } from "os";
@@ -3946,7 +4165,7 @@ import { join as join7 } from "path";
3946
4165
  function createAptSignatureVerifier(config) {
3947
4166
  const { fingerprint } = config;
3948
4167
  const keyring = Buffer.from(config.keyring);
3949
- if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) || createHash10("sha256").update(keyring).digest("hex") !== config.sha256)
4168
+ if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) || createHash12("sha256").update(keyring).digest("hex") !== config.sha256)
3950
4169
  throw Error("Untrusted APT signing keyring");
3951
4170
  return async (bytes) => {
3952
4171
  if (bytes.length < 1 || bytes.length > 256 * 1024)
@@ -3985,6 +4204,7 @@ import { join as join9 } from "path";
3985
4204
  import { Effect as Effect17 } from "effect";
3986
4205
 
3987
4206
  // src/library/daily-matrix.ts
4207
+ import { createHash as createHash13 } from "crypto";
3988
4208
  import { join as join8 } from "path";
3989
4209
  import { Effect as Effect16 } from "effect";
3990
4210
 
@@ -4275,30 +4495,43 @@ function readNativeReceipt(path, label) {
4275
4495
  const after = await file.stat();
4276
4496
  if (!sameFile(before, after) || before.ctimeMs !== after.ctimeMs)
4277
4497
  throw new Error("Native receipt changed during read");
4278
- return bytes.toString("utf8");
4498
+ return bytes;
4279
4499
  });
4280
4500
  return yield* attempt(() => {
4281
4501
  try {
4282
- return JSON.parse(data);
4502
+ return {
4503
+ value: JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(data)),
4504
+ size: data.length,
4505
+ digest: "sha256:" + createHash13("sha256").update(data).digest("hex")
4506
+ };
4283
4507
  } catch {
4284
4508
  throw new Error(`Invalid native receipt JSON: ${label}`);
4285
4509
  }
4286
4510
  });
4287
4511
  }).pipe(Effect16.scoped);
4288
4512
  }
4289
- var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
4513
+ var verifiedMatrix = (options, verifyPrior) => Effect16.gen(function* () {
4290
4514
  const { config, identity, artifacts, receipts } = options;
4291
4515
  const { tag } = identity;
4292
4516
  yield* attempt(() => assertDailyIdentity(identity));
4293
4517
  const matrix = yield* attempt(() => planDailyReleaseMatrix(config, tag));
4294
- yield* exactDirectory(artifacts, matrix.assets);
4295
- yield* exactDirectory(receipts, matrix.checks.map((c) => c.name + ".json"));
4518
+ if (verifyPrior && matrix.profile !== expandedDesktopDailyProfile)
4519
+ return yield* fail("Pre-signing validation requires the expanded Daily profile");
4520
+ const payloadNames = new Set(matrix.checks.flatMap((check) => check.assets));
4521
+ const selected = verifyPrior ? matrix.assets.filter((name) => payloadNames.has(name)) : matrix.assets;
4522
+ const receiptNames = matrix.checks.map((check) => check.name + ".json");
4523
+ yield* exactDirectory(artifacts, selected);
4524
+ yield* exactDirectory(receipts, receiptNames);
4296
4525
  const inventory = new Map;
4297
- for (const name of matrix.assets)
4526
+ const checkedReceipts = [];
4527
+ const claims = [];
4528
+ for (const name of selected)
4298
4529
  inventory.set(name, yield* fileIdentityEffect(join8(artifacts, name), name));
4299
4530
  for (const check of matrix.checks) {
4300
- const r = yield* readNativeReceipt(join8(receipts, check.name + ".json"), check.name);
4301
- yield* attempt(() => validateDailyNativeEvidence(r, "framework/daily-native-receipt/v2", {
4531
+ const filename = check.name + ".json";
4532
+ const raw = yield* readNativeReceipt(join8(receipts, filename), check.name);
4533
+ checkedReceipts.push({ name: filename, size: raw.size, digest: raw.digest });
4534
+ const valid = yield* attempt(() => validateDailyNativeEvidence(raw.value, "framework/daily-native-receipt/v2", {
4302
4535
  appId: matrix.appId,
4303
4536
  profile: matrix.profile,
4304
4537
  signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
@@ -4307,14 +4540,57 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
4307
4540
  assets: check.assets.map((name) => inventory.get(name)),
4308
4541
  baselineNames: (priorTag) => priorDailyInstallerNames(config, priorTag, check)
4309
4542
  }));
4543
+ if (verifyPrior && "upgrade" in valid.observations) {
4544
+ const claim = {
4545
+ appId: matrix.appId,
4546
+ check: check.name,
4547
+ platform: check.platform,
4548
+ upgrade: valid.observations.upgrade,
4549
+ ...valid.installerSigning ? { installerSigning: valid.installerSigning } : {}
4550
+ };
4551
+ claims.push(claim);
4552
+ }
4553
+ }
4554
+ const assets = [...inventory.values()];
4555
+ if (verifyPrior) {
4556
+ for (const claim of claims)
4557
+ if ((yield* step(() => verifyPrior(claim))) !== true)
4558
+ return yield* fail("Prior Daily installer or payload is not independently authorized");
4559
+ yield* exactDirectory(artifacts, selected);
4560
+ yield* exactDirectory(receipts, receiptNames);
4561
+ for (const [root, files] of [
4562
+ [artifacts, assets],
4563
+ [receipts, checkedReceipts]
4564
+ ]) {
4565
+ for (const expected of files) {
4566
+ const actual = yield* fileIdentityEffect(join8(root, expected.name), expected.name);
4567
+ if (actual.digest !== expected.digest || actual.size !== expected.size)
4568
+ return yield* fail("Daily pre-signing input changed during validation");
4569
+ }
4570
+ }
4310
4571
  }
4572
+ return { profile: matrix.profile, appId: matrix.appId, identity, assets, checkedReceipts };
4573
+ });
4574
+ var verifyDailyReleaseMatrixEffect = (options) => Effect16.map(verifiedMatrix(options), ({ profile, appId, identity, assets }) => ({
4575
+ profile,
4576
+ appId,
4577
+ identity,
4578
+ assets
4579
+ }));
4580
+ var inspectDailyPreSigningEffect = (options, verifyPrior) => Effect16.gen(function* () {
4581
+ if (typeof verifyPrior !== "function")
4582
+ return yield* fail("Expected an independent prior verifier");
4583
+ const { checkedReceipts, ...payloads } = yield* verifiedMatrix(options, verifyPrior);
4311
4584
  return {
4312
- profile: matrix.profile,
4313
- appId: matrix.appId,
4314
- identity,
4315
- assets: [...inventory.values()]
4585
+ ...payloads,
4586
+ receipts: checkedReceipts,
4587
+ descriptorSigningAuthorized: false,
4588
+ promotionAuthorized: false
4316
4589
  };
4317
4590
  });
4591
+ function inspectDailyPreSigning(options, verifyPrior) {
4592
+ return runReleaseLibrary(provideLibraryPorts()(inspectDailyPreSigningEffect(options, verifyPrior)));
4593
+ }
4318
4594
  function verifyDailyReleaseMatrix(options) {
4319
4595
  return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
4320
4596
  }
@@ -4512,7 +4788,7 @@ function createDailyNativeReceipt(options) {
4512
4788
  })));
4513
4789
  }
4514
4790
  // src/library/linux-reproducibility.ts
4515
- import { createHash as createHash11 } from "crypto";
4791
+ import { createHash as createHash14 } from "crypto";
4516
4792
  import { lstat as lstat6, readFile as readFile6, readdir as readdir4, realpath } from "fs/promises";
4517
4793
  import { isAbsolute as isAbsolute2, join as join11, resolve as resolve6 } from "path";
4518
4794
 
@@ -4526,7 +4802,7 @@ function isLinuxPackageArchitecture(value) {
4526
4802
  }
4527
4803
 
4528
4804
  // src/library/linux-reproducibility.ts
4529
- var sha256 = /^[a-f0-9]{64}$/;
4805
+ var sha2563 = /^[a-f0-9]{64}$/;
4530
4806
  var digest3 = /^sha256:[a-f0-9]{64}$/;
4531
4807
  var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
4532
4808
  var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
@@ -4577,7 +4853,7 @@ async function compareLinuxReproducibility(rawInput) {
4577
4853
  check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
4578
4854
  const target = linuxPackageArchitectures[architecture];
4579
4855
  assertDailyIdentity(input.identity);
4580
- check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha256.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest3.test(input.toolchainDigest), "Invalid protected Linux build identity");
4856
+ check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha2563.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest3.test(input.toolchainDigest), "Invalid protected Linux build identity");
4581
4857
  check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
4582
4858
  const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
4583
4859
  const archiveName = requirements.platforms[target.platform]?.[1];
@@ -4642,7 +4918,7 @@ async function compareLinuxReproducibility(rawInput) {
4642
4918
  observed.push({ path, file });
4643
4919
  check2(file.size <= 65536, "Producer receipt is too large");
4644
4920
  const bytes = await readFile6(path);
4645
- check2(bytes.length === file.size && createHash11("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
4921
+ check2(bytes.length === file.size && createHash14("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
4646
4922
  let receipt;
4647
4923
  try {
4648
4924
  receipt = JSON.parse(bytes.toString("utf8"));
@@ -4788,7 +5064,7 @@ function createMacosDmg(options) {
4788
5064
  import { Effect as Effect22 } from "effect";
4789
5065
 
4790
5066
  // src/library/local-release.ts
4791
- import { createHash as createHash13 } from "crypto";
5067
+ import { createHash as createHash16 } from "crypto";
4792
5068
  import { constants as constants3 } from "fs";
4793
5069
  import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
4794
5070
  import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
@@ -4958,7 +5234,7 @@ function createFeedReleaseCutProvider(options) {
4958
5234
  }
4959
5235
 
4960
5236
  // src/library/feed-state.ts
4961
- import { createHash as createHash12 } from "crypto";
5237
+ import { createHash as createHash15 } from "crypto";
4962
5238
  import { Effect as Effect20 } from "effect";
4963
5239
 
4964
5240
  // ../../src/shared/discard-stream.ts
@@ -5206,7 +5482,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
5206
5482
  if (!listed)
5207
5483
  return yield* fail(`Missing signed descriptor: ${policy.name}`);
5208
5484
  const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
5209
- if (!bytes || bytes.length !== listed.size || createHash12("sha256").update(bytes).digest("hex") !== listed.sha256)
5485
+ if (!bytes || bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
5210
5486
  return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
5211
5487
  const verified = verifyReleaseDescriptor(json(bytes), {
5212
5488
  appId: policy.appId,
@@ -5350,7 +5626,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
5350
5626
  var describe = (key, bytes, cacheControl) => ({
5351
5627
  key,
5352
5628
  size: bytes.length,
5353
- sha256: createHash13("sha256").update(bytes).digest("hex"),
5629
+ sha256: createHash16("sha256").update(bytes).digest("hex"),
5354
5630
  contentType: "application/json",
5355
5631
  cacheControl
5356
5632
  });
@@ -5439,7 +5715,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5439
5715
  if (artifact.size > 65536)
5440
5716
  return yield* fail("Signed descriptor is too large");
5441
5717
  const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
5442
- if ("sha256:" + createHash13("sha256").update(bytes).digest("hex") !== artifact.digest)
5718
+ if ("sha256:" + createHash16("sha256").update(bytes).digest("hex") !== artifact.digest)
5443
5719
  return yield* fail("Signed descriptor changed");
5444
5720
  let parsed;
5445
5721
  try {
@@ -5798,12 +6074,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
5798
6074
  });
5799
6075
  var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
5800
6076
  // src/library/staging.ts
5801
- import { createHash as createHash14 } from "crypto";
6077
+ import { createHash as createHash17 } from "crypto";
5802
6078
  import { join as join15, resolve as resolve10 } from "path";
5803
6079
  import { Effect as Effect24 } from "effect";
5804
6080
  var copyHashed = (input, output, size) => Effect24.tryPromise({
5805
6081
  try: async (signal) => {
5806
- const hash = createHash14("sha256");
6082
+ const hash = createHash17("sha256");
5807
6083
  let copied = 0;
5808
6084
  for await (const chunk of input.createReadStream({
5809
6085
  autoClose: false
@@ -5873,7 +6149,7 @@ import { join as join35 } from "path";
5873
6149
  import { Effect as Effect25 } from "effect";
5874
6150
 
5875
6151
  // ../../src/installer/installer-archive-members.ts
5876
- import { createHash as createHash15 } from "crypto";
6152
+ import { createHash as createHash18 } from "crypto";
5877
6153
  import { lstat as lstat7, open as open4 } from "fs/promises";
5878
6154
  import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
5879
6155
 
@@ -5980,7 +6256,7 @@ async function assertEmbeddedArchive(path, size, archive) {
5980
6256
  const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
5981
6257
  if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
5982
6258
  throw new Error("Installer archive marker is missing");
5983
- const hash = createHash15("sha256");
6259
+ const hash = createHash18("sha256");
5984
6260
  let read = 0;
5985
6261
  for await (const chunk of file.createReadStream({
5986
6262
  start: position + marker.length,
@@ -6867,7 +7143,7 @@ function assertInstallerRendererObservation(value, offline = false) {
6867
7143
  }
6868
7144
 
6869
7145
  // ../../src/installer/installed-payload.ts
6870
- import { createHash as createHash16 } from "crypto";
7146
+ import { createHash as createHash19 } from "crypto";
6871
7147
  import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm7 } from "fs/promises";
6872
7148
  import { once as once2 } from "events";
6873
7149
  import { join as join20, resolve as resolve13 } from "path";
@@ -6893,7 +7169,7 @@ async function command2(args, env, limit, collect) {
6893
7169
  const errors = (async () => {
6894
7170
  for await (const _part of child.stderr) {}
6895
7171
  })();
6896
- const hash = createHash16("sha256"), chunks = [];
7172
+ const hash = createHash19("sha256"), chunks = [];
6897
7173
  let size = 0;
6898
7174
  try {
6899
7175
  for await (const part of child.stdout) {
@@ -6947,7 +7223,7 @@ async function readMembers(archive, limits, collect) {
6947
7223
  failure ??= new Error("Archive member missing or ambiguous");
6948
7224
  return entry.resume();
6949
7225
  }
6950
- const hash = createHash16("sha256"), chunks = [];
7226
+ const hash = createHash19("sha256"), chunks = [];
6951
7227
  const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
6952
7228
  members.set(entry.path, member);
6953
7229
  entry.on("data", (chunk) => {
@@ -7089,7 +7365,7 @@ async function extractCandidateRuntime(options) {
7089
7365
  const child = spawn(), errors = (async () => {
7090
7366
  for await (const _part of child.stderr) {}
7091
7367
  })();
7092
- const hash = createHash16("sha256");
7368
+ const hash = createHash19("sha256");
7093
7369
  let size = 0;
7094
7370
  try {
7095
7371
  for await (const part of child.stdout) {
@@ -7323,7 +7599,7 @@ function planUpdateHandoff(options) {
7323
7599
  }
7324
7600
 
7325
7601
  // ../../src/updates/install/update-extraction.ts
7326
- import { createHash as createHash17 } from "crypto";
7602
+ import { createHash as createHash20 } from "crypto";
7327
7603
  import { constants as constants4 } from "fs";
7328
7604
  import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp8, open as open6, readFile as readFile8, realpath as realpath7, rm as rm8, symlink } from "fs/promises";
7329
7605
  import { isAbsolute as isAbsolute6, join as join21 } from "path";
@@ -7398,7 +7674,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7398
7674
  done(null, chunk);
7399
7675
  }
7400
7676
  });
7401
- const hash = createHash17("sha256");
7677
+ const hash = createHash20("sha256");
7402
7678
  let compressedBytes = 0;
7403
7679
  const verifyInput = new Transform({
7404
7680
  transform(chunk, _encoding, done) {
@@ -7554,7 +7830,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7554
7830
  }
7555
7831
 
7556
7832
  // ../../src/updates/install/update-swap.ts
7557
- import { createHash as createHash18 } from "crypto";
7833
+ import { createHash as createHash21 } from "crypto";
7558
7834
  import { constants as constants7 } from "fs";
7559
7835
  import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile9, readlink as readlink2 } from "fs/promises";
7560
7836
  import { basename as basename8, dirname as dirname6, join as join24 } from "path";
@@ -7910,7 +8186,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
7910
8186
  }
7911
8187
  async function readUpdateTreeDigest(tree, options = {}) {
7912
8188
  const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
7913
- const hash = createHash18("sha256");
8189
+ const hash = createHash21("sha256");
7914
8190
  hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
7915
8191
  const root = await lstat14(tree, { bigint: true });
7916
8192
  if (!root.isDirectory() || root.isSymbolicLink())
@@ -8928,7 +9204,7 @@ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as wri
8928
9204
  import { join as join34, resolve as resolve16 } from "path";
8929
9205
 
8930
9206
  // ../../src/installer/upgrade-asset-download.ts
8931
- import { createHash as createHash19 } from "crypto";
9207
+ import { createHash as createHash22 } from "crypto";
8932
9208
  import { open as open10, unlink as unlink3 } from "fs/promises";
8933
9209
 
8934
9210
  // ../../src/installer/write-all.ts
@@ -8966,7 +9242,7 @@ async function downloadAsset(options) {
8966
9242
  discardStream(response.body);
8967
9243
  throw error;
8968
9244
  }
8969
- const hash = createHash19("sha256");
9245
+ const hash = createHash22("sha256");
8970
9246
  let completed = false;
8971
9247
  try {
8972
9248
  let size = 0;
@@ -9006,7 +9282,7 @@ async function downloadAsset(options) {
9006
9282
  }
9007
9283
 
9008
9284
  // ../../src/updates/feed/update-discovery.ts
9009
- import { createHash as createHash20 } from "crypto";
9285
+ import { createHash as createHash23 } from "crypto";
9010
9286
  var MAX_POINTER_BYTES = 262144;
9011
9287
  var MAX_LEDGER_BYTES2 = 1024 * 1024;
9012
9288
  async function discoverSignedRelease(options) {
@@ -9042,7 +9318,7 @@ async function discoverSignedRelease(options) {
9042
9318
  throw new Error("No qualified channel descriptor is available");
9043
9319
  const { tag } = selected;
9044
9320
  const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
9045
- if (bytes.length !== listed.size || createHash20("sha256").update(bytes).digest("hex") !== listed.sha256)
9321
+ if (bytes.length !== listed.size || createHash23("sha256").update(bytes).digest("hex") !== listed.sha256)
9046
9322
  throw new Error("Channel descriptor differs from its release");
9047
9323
  let signed;
9048
9324
  try {
@@ -9626,7 +9902,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
9626
9902
  }
9627
9903
  var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
9628
9904
  // src/library/linux-format-producer.ts
9629
- import { createHash as createHash21 } from "crypto";
9905
+ import { createHash as createHash24 } from "crypto";
9630
9906
  import { createReadStream as createReadStream2, createWriteStream } from "fs";
9631
9907
  import {
9632
9908
  chmod as chmod4,
@@ -9649,9 +9925,9 @@ import { pipeline as pipeline2 } from "stream/promises";
9649
9925
  var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
9650
9926
  var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
9651
9927
  var debDependencyAtom = /^[a-z0-9][a-z0-9+.-]{0,63}(?: \(>= (?:0|[1-9]\d{0,8})(?:\.(?:0|[1-9]\d{0,8})){1,3}\))?$/;
9652
- var sha2562 = /^[a-f0-9]{64}$/;
9928
+ var sha2564 = /^[a-f0-9]{64}$/;
9653
9929
  var sum = async (path) => {
9654
- const hash = createHash21("sha256");
9930
+ const hash = createHash24("sha256");
9655
9931
  for await (const chunk of createReadStream2(path))
9656
9932
  hash.update(chunk);
9657
9933
  return hash.digest("hex");
@@ -9663,7 +9939,7 @@ function check3(ok, message) {
9663
9939
  throw new Error(message);
9664
9940
  }
9665
9941
  async function exactCopy(pin, to) {
9666
- check3(sha2562.test(pin.sha256), "Missing protected input digest");
9942
+ check3(sha2564.test(pin.sha256), "Missing protected input digest");
9667
9943
  const before = await lstat21(pin.path);
9668
9944
  check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
9669
9945
  const input = await open13(pin.path, "r");
@@ -9733,7 +10009,7 @@ async function write(root, path, value, mode = 420) {
9733
10009
  function validatePolicy(policy) {
9734
10010
  const executable = policy.executable ?? policy.packageName;
9735
10011
  const links = policy.links ?? [];
9736
- check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2562.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => x.length <= 256 && x === x.trim() && x.split(" | ").every((atom) => debDependencyAtom.test(atom))), "Invalid app Linux packaging policy");
10012
+ check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2564.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => x.length <= 256 && x === x.trim() && x.split(" | ").every((atom) => debDependencyAtom.test(atom))), "Invalid app Linux packaging policy");
9737
10013
  check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
9738
10014
  }
9739
10015
  async function buildLinuxFormats(input, host) {
@@ -9953,7 +10229,7 @@ exec "$root/${installed}/${policy.launcher}" "$@"
9953
10229
  }
9954
10230
  // src/library/windows-standalone.ts
9955
10231
  import { execFile as execFile5 } from "child_process";
9956
- import { createHash as createHash22 } from "crypto";
10232
+ import { createHash as createHash25 } from "crypto";
9957
10233
  import { constants as constants8 } from "fs";
9958
10234
  import { copyFile as copyFile2, lstat as lstat22, mkdtemp as mkdtemp13, open as open14, readFile as readFile13, readdir as readdir13, rm as rm13, writeFile as writeFile14 } from "fs/promises";
9959
10235
  import { tmpdir as tmpdir6 } from "os";
@@ -10145,7 +10421,7 @@ async function assertStandaloneWindowsPayload(exe, members) {
10145
10421
  throw new Error("Invalid Windows setup payload marker");
10146
10422
  let cursor = offset + marker.length;
10147
10423
  for (const member of members) {
10148
- const hash = createHash22("sha256");
10424
+ const hash = createHash25("sha256");
10149
10425
  const end = cursor + member.size;
10150
10426
  while (cursor < end) {
10151
10427
  const bytes = await read(cursor, Math.min(end - cursor, 1048576));
@@ -10279,7 +10555,9 @@ export {
10279
10555
  expandedDesktopDailyProfile,
10280
10556
  fileIdentity2 as fileIdentity,
10281
10557
  finalizeReleasePleaseDraft,
10558
+ inspectAptRepositoryPlan,
10282
10559
  inspectDailyBatch,
10560
+ inspectDailyPreSigning,
10283
10561
  inspectStagedStep,
10284
10562
  planDailyReleaseMatrix,
10285
10563
  planQualificationRun2 as planQualificationRun,