@adea-ai/app-framework-release-tools 0.8.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/cli.js +282 -175
- package/dist/index.js +257 -38
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(exports_src, {
|
|
|
34
34
|
expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
|
|
35
35
|
fileIdentity: () => fileIdentity2,
|
|
36
36
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
37
|
+
inspectAptRepositoryPlan: () => inspectAptRepositoryPlan,
|
|
37
38
|
inspectDailyBatch: () => inspectDailyBatch,
|
|
38
39
|
inspectDailyPreSigning: () => inspectDailyPreSigning,
|
|
39
40
|
inspectStagedStep: () => inspectStagedStep,
|
|
@@ -3708,6 +3709,223 @@ function createDailyBatchR2Store(send) {
|
|
|
3708
3709
|
}
|
|
3709
3710
|
};
|
|
3710
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
|
+
}
|
|
3711
3929
|
// src/library/apt/apt-r2-store.ts
|
|
3712
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)$/;
|
|
3713
3931
|
var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
|
|
@@ -3791,7 +4009,7 @@ function createAptR2Store(send) {
|
|
|
3791
4009
|
};
|
|
3792
4010
|
}
|
|
3793
4011
|
// src/library/apt/publish-apt-repository.ts
|
|
3794
|
-
import { createHash as
|
|
4012
|
+
import { createHash as createHash11 } from "crypto";
|
|
3795
4013
|
import { gunzipSync } from "zlib";
|
|
3796
4014
|
var ARCHES = ["amd64", "arm64"];
|
|
3797
4015
|
var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
@@ -3799,7 +4017,7 @@ var hex3 = /^[0-9a-f]{64}$/;
|
|
|
3799
4017
|
var indexLimit = 256 * 1024;
|
|
3800
4018
|
var debLimit = 768 * 1024 ** 2;
|
|
3801
4019
|
var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3802
|
-
var digest = (bytes) =>
|
|
4020
|
+
var digest = (bytes) => createHash11("sha256").update(bytes).digest("hex");
|
|
3803
4021
|
var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
3804
4022
|
var same2 = (a, b) => Buffer.from(a).equals(b);
|
|
3805
4023
|
function need(condition, message) {
|
|
@@ -3939,7 +4157,7 @@ async function publishAptRepository({ app, suite, tag, assets }, port, now = Dat
|
|
|
3939
4157
|
return { tag, changed: true };
|
|
3940
4158
|
}
|
|
3941
4159
|
// src/library/apt/verify-apt-signature.ts
|
|
3942
|
-
import { createHash as
|
|
4160
|
+
import { createHash as createHash12 } from "crypto";
|
|
3943
4161
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
3944
4162
|
import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
3945
4163
|
import { tmpdir as tmpdir4 } from "os";
|
|
@@ -3947,7 +4165,7 @@ import { join as join7 } from "path";
|
|
|
3947
4165
|
function createAptSignatureVerifier(config) {
|
|
3948
4166
|
const { fingerprint } = config;
|
|
3949
4167
|
const keyring = Buffer.from(config.keyring);
|
|
3950
|
-
if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(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)
|
|
3951
4169
|
throw Error("Untrusted APT signing keyring");
|
|
3952
4170
|
return async (bytes) => {
|
|
3953
4171
|
if (bytes.length < 1 || bytes.length > 256 * 1024)
|
|
@@ -3986,7 +4204,7 @@ import { join as join9 } from "path";
|
|
|
3986
4204
|
import { Effect as Effect17 } from "effect";
|
|
3987
4205
|
|
|
3988
4206
|
// src/library/daily-matrix.ts
|
|
3989
|
-
import { createHash as
|
|
4207
|
+
import { createHash as createHash13 } from "crypto";
|
|
3990
4208
|
import { join as join8 } from "path";
|
|
3991
4209
|
import { Effect as Effect16 } from "effect";
|
|
3992
4210
|
|
|
@@ -4284,7 +4502,7 @@ function readNativeReceipt(path, label) {
|
|
|
4284
4502
|
return {
|
|
4285
4503
|
value: JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(data)),
|
|
4286
4504
|
size: data.length,
|
|
4287
|
-
digest: "sha256:" +
|
|
4505
|
+
digest: "sha256:" + createHash13("sha256").update(data).digest("hex")
|
|
4288
4506
|
};
|
|
4289
4507
|
} catch {
|
|
4290
4508
|
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
@@ -4570,7 +4788,7 @@ function createDailyNativeReceipt(options) {
|
|
|
4570
4788
|
})));
|
|
4571
4789
|
}
|
|
4572
4790
|
// src/library/linux-reproducibility.ts
|
|
4573
|
-
import { createHash as
|
|
4791
|
+
import { createHash as createHash14 } from "crypto";
|
|
4574
4792
|
import { lstat as lstat6, readFile as readFile6, readdir as readdir4, realpath } from "fs/promises";
|
|
4575
4793
|
import { isAbsolute as isAbsolute2, join as join11, resolve as resolve6 } from "path";
|
|
4576
4794
|
|
|
@@ -4584,7 +4802,7 @@ function isLinuxPackageArchitecture(value) {
|
|
|
4584
4802
|
}
|
|
4585
4803
|
|
|
4586
4804
|
// src/library/linux-reproducibility.ts
|
|
4587
|
-
var
|
|
4805
|
+
var sha2563 = /^[a-f0-9]{64}$/;
|
|
4588
4806
|
var digest3 = /^sha256:[a-f0-9]{64}$/;
|
|
4589
4807
|
var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
|
|
4590
4808
|
var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
@@ -4635,7 +4853,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4635
4853
|
check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
|
|
4636
4854
|
const target = linuxPackageArchitectures[architecture];
|
|
4637
4855
|
assertDailyIdentity(input.identity);
|
|
4638
|
-
check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 &&
|
|
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");
|
|
4639
4857
|
check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
|
|
4640
4858
|
const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
|
|
4641
4859
|
const archiveName = requirements.platforms[target.platform]?.[1];
|
|
@@ -4700,7 +4918,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4700
4918
|
observed.push({ path, file });
|
|
4701
4919
|
check2(file.size <= 65536, "Producer receipt is too large");
|
|
4702
4920
|
const bytes = await readFile6(path);
|
|
4703
|
-
check2(bytes.length === file.size &&
|
|
4921
|
+
check2(bytes.length === file.size && createHash14("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
|
|
4704
4922
|
let receipt;
|
|
4705
4923
|
try {
|
|
4706
4924
|
receipt = JSON.parse(bytes.toString("utf8"));
|
|
@@ -4846,7 +5064,7 @@ function createMacosDmg(options) {
|
|
|
4846
5064
|
import { Effect as Effect22 } from "effect";
|
|
4847
5065
|
|
|
4848
5066
|
// src/library/local-release.ts
|
|
4849
|
-
import { createHash as
|
|
5067
|
+
import { createHash as createHash16 } from "crypto";
|
|
4850
5068
|
import { constants as constants3 } from "fs";
|
|
4851
5069
|
import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
|
|
4852
5070
|
import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
|
|
@@ -5016,7 +5234,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
5016
5234
|
}
|
|
5017
5235
|
|
|
5018
5236
|
// src/library/feed-state.ts
|
|
5019
|
-
import { createHash as
|
|
5237
|
+
import { createHash as createHash15 } from "crypto";
|
|
5020
5238
|
import { Effect as Effect20 } from "effect";
|
|
5021
5239
|
|
|
5022
5240
|
// ../../src/shared/discard-stream.ts
|
|
@@ -5264,7 +5482,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
5264
5482
|
if (!listed)
|
|
5265
5483
|
return yield* fail(`Missing signed descriptor: ${policy.name}`);
|
|
5266
5484
|
const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
|
|
5267
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
5485
|
+
if (!bytes || bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
5268
5486
|
return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
|
|
5269
5487
|
const verified = verifyReleaseDescriptor(json(bytes), {
|
|
5270
5488
|
appId: policy.appId,
|
|
@@ -5408,7 +5626,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
|
|
|
5408
5626
|
var describe = (key, bytes, cacheControl) => ({
|
|
5409
5627
|
key,
|
|
5410
5628
|
size: bytes.length,
|
|
5411
|
-
sha256:
|
|
5629
|
+
sha256: createHash16("sha256").update(bytes).digest("hex"),
|
|
5412
5630
|
contentType: "application/json",
|
|
5413
5631
|
cacheControl
|
|
5414
5632
|
});
|
|
@@ -5497,7 +5715,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
5497
5715
|
if (artifact.size > 65536)
|
|
5498
5716
|
return yield* fail("Signed descriptor is too large");
|
|
5499
5717
|
const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
|
|
5500
|
-
if ("sha256:" +
|
|
5718
|
+
if ("sha256:" + createHash16("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
5501
5719
|
return yield* fail("Signed descriptor changed");
|
|
5502
5720
|
let parsed;
|
|
5503
5721
|
try {
|
|
@@ -5856,12 +6074,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
|
|
|
5856
6074
|
});
|
|
5857
6075
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
5858
6076
|
// src/library/staging.ts
|
|
5859
|
-
import { createHash as
|
|
6077
|
+
import { createHash as createHash17 } from "crypto";
|
|
5860
6078
|
import { join as join15, resolve as resolve10 } from "path";
|
|
5861
6079
|
import { Effect as Effect24 } from "effect";
|
|
5862
6080
|
var copyHashed = (input, output, size) => Effect24.tryPromise({
|
|
5863
6081
|
try: async (signal) => {
|
|
5864
|
-
const hash =
|
|
6082
|
+
const hash = createHash17("sha256");
|
|
5865
6083
|
let copied = 0;
|
|
5866
6084
|
for await (const chunk of input.createReadStream({
|
|
5867
6085
|
autoClose: false
|
|
@@ -5931,7 +6149,7 @@ import { join as join35 } from "path";
|
|
|
5931
6149
|
import { Effect as Effect25 } from "effect";
|
|
5932
6150
|
|
|
5933
6151
|
// ../../src/installer/installer-archive-members.ts
|
|
5934
|
-
import { createHash as
|
|
6152
|
+
import { createHash as createHash18 } from "crypto";
|
|
5935
6153
|
import { lstat as lstat7, open as open4 } from "fs/promises";
|
|
5936
6154
|
import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
|
|
5937
6155
|
|
|
@@ -6038,7 +6256,7 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
6038
6256
|
const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
|
|
6039
6257
|
if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
|
|
6040
6258
|
throw new Error("Installer archive marker is missing");
|
|
6041
|
-
const hash =
|
|
6259
|
+
const hash = createHash18("sha256");
|
|
6042
6260
|
let read = 0;
|
|
6043
6261
|
for await (const chunk of file.createReadStream({
|
|
6044
6262
|
start: position + marker.length,
|
|
@@ -6925,7 +7143,7 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
6925
7143
|
}
|
|
6926
7144
|
|
|
6927
7145
|
// ../../src/installer/installed-payload.ts
|
|
6928
|
-
import { createHash as
|
|
7146
|
+
import { createHash as createHash19 } from "crypto";
|
|
6929
7147
|
import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm7 } from "fs/promises";
|
|
6930
7148
|
import { once as once2 } from "events";
|
|
6931
7149
|
import { join as join20, resolve as resolve13 } from "path";
|
|
@@ -6951,7 +7169,7 @@ async function command2(args, env, limit, collect) {
|
|
|
6951
7169
|
const errors = (async () => {
|
|
6952
7170
|
for await (const _part of child.stderr) {}
|
|
6953
7171
|
})();
|
|
6954
|
-
const hash =
|
|
7172
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
6955
7173
|
let size = 0;
|
|
6956
7174
|
try {
|
|
6957
7175
|
for await (const part of child.stdout) {
|
|
@@ -7005,7 +7223,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
7005
7223
|
failure ??= new Error("Archive member missing or ambiguous");
|
|
7006
7224
|
return entry.resume();
|
|
7007
7225
|
}
|
|
7008
|
-
const hash =
|
|
7226
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
7009
7227
|
const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
|
|
7010
7228
|
members.set(entry.path, member);
|
|
7011
7229
|
entry.on("data", (chunk) => {
|
|
@@ -7147,7 +7365,7 @@ async function extractCandidateRuntime(options) {
|
|
|
7147
7365
|
const child = spawn(), errors = (async () => {
|
|
7148
7366
|
for await (const _part of child.stderr) {}
|
|
7149
7367
|
})();
|
|
7150
|
-
const hash =
|
|
7368
|
+
const hash = createHash19("sha256");
|
|
7151
7369
|
let size = 0;
|
|
7152
7370
|
try {
|
|
7153
7371
|
for await (const part of child.stdout) {
|
|
@@ -7381,7 +7599,7 @@ function planUpdateHandoff(options) {
|
|
|
7381
7599
|
}
|
|
7382
7600
|
|
|
7383
7601
|
// ../../src/updates/install/update-extraction.ts
|
|
7384
|
-
import { createHash as
|
|
7602
|
+
import { createHash as createHash20 } from "crypto";
|
|
7385
7603
|
import { constants as constants4 } from "fs";
|
|
7386
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";
|
|
7387
7605
|
import { isAbsolute as isAbsolute6, join as join21 } from "path";
|
|
@@ -7456,7 +7674,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7456
7674
|
done(null, chunk);
|
|
7457
7675
|
}
|
|
7458
7676
|
});
|
|
7459
|
-
const hash =
|
|
7677
|
+
const hash = createHash20("sha256");
|
|
7460
7678
|
let compressedBytes = 0;
|
|
7461
7679
|
const verifyInput = new Transform({
|
|
7462
7680
|
transform(chunk, _encoding, done) {
|
|
@@ -7612,7 +7830,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7612
7830
|
}
|
|
7613
7831
|
|
|
7614
7832
|
// ../../src/updates/install/update-swap.ts
|
|
7615
|
-
import { createHash as
|
|
7833
|
+
import { createHash as createHash21 } from "crypto";
|
|
7616
7834
|
import { constants as constants7 } from "fs";
|
|
7617
7835
|
import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile9, readlink as readlink2 } from "fs/promises";
|
|
7618
7836
|
import { basename as basename8, dirname as dirname6, join as join24 } from "path";
|
|
@@ -7968,7 +8186,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
|
|
|
7968
8186
|
}
|
|
7969
8187
|
async function readUpdateTreeDigest(tree, options = {}) {
|
|
7970
8188
|
const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
|
|
7971
|
-
const hash =
|
|
8189
|
+
const hash = createHash21("sha256");
|
|
7972
8190
|
hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
|
|
7973
8191
|
const root = await lstat14(tree, { bigint: true });
|
|
7974
8192
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
@@ -8986,7 +9204,7 @@ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as wri
|
|
|
8986
9204
|
import { join as join34, resolve as resolve16 } from "path";
|
|
8987
9205
|
|
|
8988
9206
|
// ../../src/installer/upgrade-asset-download.ts
|
|
8989
|
-
import { createHash as
|
|
9207
|
+
import { createHash as createHash22 } from "crypto";
|
|
8990
9208
|
import { open as open10, unlink as unlink3 } from "fs/promises";
|
|
8991
9209
|
|
|
8992
9210
|
// ../../src/installer/write-all.ts
|
|
@@ -9024,7 +9242,7 @@ async function downloadAsset(options) {
|
|
|
9024
9242
|
discardStream(response.body);
|
|
9025
9243
|
throw error;
|
|
9026
9244
|
}
|
|
9027
|
-
const hash =
|
|
9245
|
+
const hash = createHash22("sha256");
|
|
9028
9246
|
let completed = false;
|
|
9029
9247
|
try {
|
|
9030
9248
|
let size = 0;
|
|
@@ -9064,7 +9282,7 @@ async function downloadAsset(options) {
|
|
|
9064
9282
|
}
|
|
9065
9283
|
|
|
9066
9284
|
// ../../src/updates/feed/update-discovery.ts
|
|
9067
|
-
import { createHash as
|
|
9285
|
+
import { createHash as createHash23 } from "crypto";
|
|
9068
9286
|
var MAX_POINTER_BYTES = 262144;
|
|
9069
9287
|
var MAX_LEDGER_BYTES2 = 1024 * 1024;
|
|
9070
9288
|
async function discoverSignedRelease(options) {
|
|
@@ -9100,7 +9318,7 @@ async function discoverSignedRelease(options) {
|
|
|
9100
9318
|
throw new Error("No qualified channel descriptor is available");
|
|
9101
9319
|
const { tag } = selected;
|
|
9102
9320
|
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
|
|
9103
|
-
if (bytes.length !== listed.size ||
|
|
9321
|
+
if (bytes.length !== listed.size || createHash23("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
9104
9322
|
throw new Error("Channel descriptor differs from its release");
|
|
9105
9323
|
let signed;
|
|
9106
9324
|
try {
|
|
@@ -9684,7 +9902,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9684
9902
|
}
|
|
9685
9903
|
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
9686
9904
|
// src/library/linux-format-producer.ts
|
|
9687
|
-
import { createHash as
|
|
9905
|
+
import { createHash as createHash24 } from "crypto";
|
|
9688
9906
|
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
9689
9907
|
import {
|
|
9690
9908
|
chmod as chmod4,
|
|
@@ -9707,9 +9925,9 @@ import { pipeline as pipeline2 } from "stream/promises";
|
|
|
9707
9925
|
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9708
9926
|
var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
|
|
9709
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}\))?$/;
|
|
9710
|
-
var
|
|
9928
|
+
var sha2564 = /^[a-f0-9]{64}$/;
|
|
9711
9929
|
var sum = async (path) => {
|
|
9712
|
-
const hash =
|
|
9930
|
+
const hash = createHash24("sha256");
|
|
9713
9931
|
for await (const chunk of createReadStream2(path))
|
|
9714
9932
|
hash.update(chunk);
|
|
9715
9933
|
return hash.digest("hex");
|
|
@@ -9721,7 +9939,7 @@ function check3(ok, message) {
|
|
|
9721
9939
|
throw new Error(message);
|
|
9722
9940
|
}
|
|
9723
9941
|
async function exactCopy(pin, to) {
|
|
9724
|
-
check3(
|
|
9942
|
+
check3(sha2564.test(pin.sha256), "Missing protected input digest");
|
|
9725
9943
|
const before = await lstat21(pin.path);
|
|
9726
9944
|
check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
9727
9945
|
const input = await open13(pin.path, "r");
|
|
@@ -9791,7 +10009,7 @@ async function write(root, path, value, mode = 420) {
|
|
|
9791
10009
|
function validatePolicy(policy) {
|
|
9792
10010
|
const executable = policy.executable ?? policy.packageName;
|
|
9793
10011
|
const links = policy.links ?? [];
|
|
9794
|
-
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) =>
|
|
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");
|
|
9795
10013
|
check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
9796
10014
|
}
|
|
9797
10015
|
async function buildLinuxFormats(input, host) {
|
|
@@ -10011,7 +10229,7 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
10011
10229
|
}
|
|
10012
10230
|
// src/library/windows-standalone.ts
|
|
10013
10231
|
import { execFile as execFile5 } from "child_process";
|
|
10014
|
-
import { createHash as
|
|
10232
|
+
import { createHash as createHash25 } from "crypto";
|
|
10015
10233
|
import { constants as constants8 } from "fs";
|
|
10016
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";
|
|
10017
10235
|
import { tmpdir as tmpdir6 } from "os";
|
|
@@ -10203,7 +10421,7 @@ async function assertStandaloneWindowsPayload(exe, members) {
|
|
|
10203
10421
|
throw new Error("Invalid Windows setup payload marker");
|
|
10204
10422
|
let cursor = offset + marker.length;
|
|
10205
10423
|
for (const member of members) {
|
|
10206
|
-
const hash =
|
|
10424
|
+
const hash = createHash25("sha256");
|
|
10207
10425
|
const end = cursor + member.size;
|
|
10208
10426
|
while (cursor < end) {
|
|
10209
10427
|
const bytes = await read(cursor, Math.min(end - cursor, 1048576));
|
|
@@ -10337,6 +10555,7 @@ export {
|
|
|
10337
10555
|
expandedDesktopDailyProfile,
|
|
10338
10556
|
fileIdentity2 as fileIdentity,
|
|
10339
10557
|
finalizeReleasePleaseDraft,
|
|
10558
|
+
inspectAptRepositoryPlan,
|
|
10340
10559
|
inspectDailyBatch,
|
|
10341
10560
|
inspectDailyPreSigning,
|
|
10342
10561
|
inspectStagedStep,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.9.0","commit":"8ab34499ea15c2233d6747f69d262fdd5c74b4ad"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/app-framework-release-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Host-side release tooling for @adea-ai/app-framework apps, on Effect: the release CLIs and the framework package publish. Installing it never adds Effect to the framework itself.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|