@adea-ai/app-framework-release-tools 0.11.3 → 0.11.4

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
@@ -6893,9 +6893,9 @@ import { delimiter, dirname as dirname12, join as join31 } from "path";
6893
6893
  // ../../src/installer/installer-ci-bootstrap.ts
6894
6894
  import { randomBytes as randomBytes2 } from "crypto";
6895
6895
  import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp6, realpath as realpath3, rm as rm6, writeFile as writeFile5 } from "fs/promises";
6896
- import { dirname as dirname4, isAbsolute as isAbsolute5, join as join18, relative as relative4, sep as sep3 } from "path";
6896
+ import { basename as basename6, dirname as dirname4, isAbsolute as isAbsolute5, join as join18, relative as relative4, sep as sep3 } from "path";
6897
6897
  import { fileURLToPath } from "url";
6898
- var bootstrapModules = [
6898
+ var installerCiBootstrapModules = [
6899
6899
  "app/value-guards.js",
6900
6900
  "installer/installer-ci-worker.js",
6901
6901
  "installer/installer-ci-preflight.js",
@@ -6919,10 +6919,11 @@ async function prepareInstallerCiBootstrap(env = process.env) {
6919
6919
  const parent = await realpath3(temp);
6920
6920
  if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
6921
6921
  throw new Error("Runner temp cannot represent a Bun preload path");
6922
- const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
6922
+ const moduleDirectory = dirname4(fileURLToPath(import.meta.url));
6923
+ const source = basename6(moduleDirectory) === "installer" ? dirname4(moduleDirectory) : moduleDirectory;
6923
6924
  const directory = await mkdtemp6(join18(parent, "framework-ci-"));
6924
6925
  try {
6925
- for (const name of bootstrapModules) {
6926
+ for (const name of installerCiBootstrapModules) {
6926
6927
  const contents = await readBoundedFile(join18(source, name), 2 * 1024 * 1024, "installer bootstrap module");
6927
6928
  await mkdir5(dirname4(join18(directory, name)), { recursive: true, mode: 448 });
6928
6929
  await writeFile5(join18(directory, name), contents, { flag: "wx", mode: 384 });
@@ -7666,7 +7667,7 @@ import { lstat as lstat18, mkdtemp as mkdtemp9, readFile as readFile10, realpath
7666
7667
  import { join as join30 } from "path";
7667
7668
 
7668
7669
  // ../../src/updates/install/update-handoff-plan.ts
7669
- import { basename as basename6 } from "path";
7670
+ import { basename as basename7 } from "path";
7670
7671
  function planUpdateHandoff(options) {
7671
7672
  const {
7672
7673
  descriptor,
@@ -7690,7 +7691,7 @@ function planUpdateHandoff(options) {
7690
7691
  if (!expected[platform] || !["native", "cef"].includes(renderer) || !isVerifiedReleaseForTrust(descriptor, trust) || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || approved !== true || approvedVersion !== descriptor.version || !isReleaseVersion(currentVersion) || !versionLessThan(currentVersion, descriptor.version))
7691
7692
  throw new Error("Invalid approved update");
7692
7693
  const name = isMacInstallerPlatform(platform) ? `${appName}.app` : "app";
7693
- if (!isCanonicalPath(target) || basename6(target) !== name)
7694
+ if (!isCanonicalPath(target) || basename7(target) !== name)
7694
7695
  throw new Error("Invalid update target");
7695
7696
  return Object.freeze({
7696
7697
  target,
@@ -7941,7 +7942,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7941
7942
  import { createHash as createHash21 } from "crypto";
7942
7943
  import { constants as constants7 } from "fs";
7943
7944
  import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile9, readlink as readlink2 } from "fs/promises";
7944
- import { basename as basename8, dirname as dirname6, join as join24 } from "path";
7945
+ import { basename as basename9, dirname as dirname6, join as join24 } from "path";
7945
7946
 
7946
7947
  // ../../src/updates/update-state-store.ts
7947
7948
  import { randomUUID as randomUUID2 } from "crypto";
@@ -7950,7 +7951,7 @@ import { open as open8, rename, unlink, writeFile as writeFile6 } from "fs/promi
7950
7951
  import { join as join23 } from "path";
7951
7952
 
7952
7953
  // ../../src/updates/locks/update-lock.ts
7953
- import { basename as basename7, dirname as dirname5, join as join22 } from "path";
7954
+ import { basename as basename8, dirname as dirname5, join as join22 } from "path";
7954
7955
 
7955
7956
  // ../../src/updates/locks/native-file-lock.ts
7956
7957
  import { constants as constants5 } from "fs";
@@ -8118,7 +8119,7 @@ async function tryAcquireWindows(path, mode) {
8118
8119
  function updateLockPath(target) {
8119
8120
  if (!isCanonicalPath(target))
8120
8121
  throw new Error("Invalid update lock target");
8121
- return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
8122
+ return join22(dirname5(target), `.${basename8(target)}.framework-update.lock`);
8122
8123
  }
8123
8124
  async function tryAcquireUpdateLock(target) {
8124
8125
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
@@ -8231,7 +8232,7 @@ async function withUpdateLock(target, operation) {
8231
8232
  function updateStagingFor(target) {
8232
8233
  if (!isCanonicalPath(target))
8233
8234
  throw new Error("Invalid update target");
8234
- return join24(dirname6(target), `.${basename8(target)}.framework-update`);
8235
+ return join24(dirname6(target), `.${basename9(target)}.framework-update`);
8235
8236
  }
8236
8237
  async function readUpdateTreeVersion(tree) {
8237
8238
  const versionPath = join24(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
@@ -8502,10 +8503,10 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
8502
8503
 
8503
8504
  // ../../src/updates/retention/retirement-inventory.ts
8504
8505
  import { lstat as lstat16, readdir as readdir10 } from "fs/promises";
8505
- import { basename as basename12, dirname as dirname10, join as join28 } from "path";
8506
+ import { basename as basename13, dirname as dirname10, join as join28 } from "path";
8506
8507
 
8507
8508
  // ../../src/updates/retention/update-retention-marker.ts
8508
- import { basename as basename9, dirname as dirname7, join as join25 } from "path";
8509
+ import { basename as basename10, dirname as dirname7, join as join25 } from "path";
8509
8510
  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}$/;
8510
8511
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
8511
8512
  function assertCanonicalTarget(target) {
@@ -8524,19 +8525,19 @@ function isTreeIdentity(value) {
8524
8525
  function updateRetentionIntentPath(target, generation) {
8525
8526
  assertCanonicalTarget(target);
8526
8527
  assertGeneration(generation);
8527
- return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
8528
+ return join25(dirname7(target), `.${basename10(target)}.framework-prune-${generation}.json`);
8528
8529
  }
8529
8530
 
8530
8531
  // ../../src/updates/retention/retention-prune-progress.ts
8531
- import { basename as basename11, dirname as dirname9, join as join27 } from "path";
8532
+ import { basename as basename12, dirname as dirname9, join as join27 } from "path";
8532
8533
 
8533
8534
  // ../../src/updates/retention/retirement-records.ts
8534
8535
  import { lstat as lstat15, readdir as readdir9, writeFile as writeFile7 } from "fs/promises";
8535
- import { basename as basename10, dirname as dirname8, join as join26 } from "path";
8536
+ import { basename as basename11, dirname as dirname8, join as join26 } from "path";
8536
8537
  function updateRetirementPaths(target, generation) {
8537
8538
  if (!isCanonicalPath(target) || !isUuid(generation))
8538
8539
  throw new Error("Invalid update retirement identity");
8539
- const prefix = `.${basename10(target)}.framework-retired-${generation}`;
8540
+ const prefix = `.${basename11(target)}.framework-retired-${generation}`;
8540
8541
  const container = join26(dirname8(target), prefix);
8541
8542
  return Object.freeze({
8542
8543
  container,
@@ -8545,15 +8546,15 @@ function updateRetirementPaths(target, generation) {
8545
8546
  healthTemporaryPrefix: ".healthy-",
8546
8547
  claim: join26(dirname8(target), `${prefix}.claim.json`),
8547
8548
  claimTemporaryPrefix: `${prefix}.claim-`,
8548
- cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
8549
- cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
8549
+ cleanupMarker: join26(dirname8(target), `.${basename11(target)}.framework-update-cleanup.json`),
8550
+ cleanupMarkerTemporaryPrefix: `.${basename11(target)}.framework-update-cleanup-`
8550
8551
  });
8551
8552
  }
8552
8553
  function parseOwner(value) {
8553
8554
  if (typeof value !== "object" || value === null || Array.isArray(value))
8554
8555
  return;
8555
8556
  const record = value;
8556
- if (record.schema !== 2 || typeof record.generation !== "string" || !isUuid(record.generation) || !isCanonicalPath(record.target) || typeof record.newVersion !== "string" || !isReleaseVersion(record.newVersion) || typeof record.previousVersion !== "string" || !isReleaseVersion(record.previousVersion) || !isTreeIdentity(record.previousTreeIdentity) || !isTreeIdentity(record.newTreeIdentity) || typeof record.container !== "string" || record.container !== `.${basename10(record.target)}.framework-retired-${record.generation}` || record.tree !== "tree" || !hasExactOwnKeys(record, [
8557
+ if (record.schema !== 2 || typeof record.generation !== "string" || !isUuid(record.generation) || !isCanonicalPath(record.target) || typeof record.newVersion !== "string" || !isReleaseVersion(record.newVersion) || typeof record.previousVersion !== "string" || !isReleaseVersion(record.previousVersion) || !isTreeIdentity(record.previousTreeIdentity) || !isTreeIdentity(record.newTreeIdentity) || typeof record.container !== "string" || record.container !== `.${basename11(record.target)}.framework-retired-${record.generation}` || record.tree !== "tree" || !hasExactOwnKeys(record, [
8557
8558
  "schema",
8558
8559
  "generation",
8559
8560
  "target",
@@ -8574,7 +8575,7 @@ function parseCleanupMarker(value) {
8574
8575
  if (typeof value !== "object" || value === null || Array.isArray(value))
8575
8576
  return;
8576
8577
  const record = value;
8577
- if (record.schema !== 1 || typeof record.generation !== "string" || !isUuid(record.generation) || !isCanonicalPath(record.target) || typeof record.version !== "string" || !isReleaseVersion(record.version) || typeof record.claim !== "string" || record.claim !== basename10(updateRetirementPaths(record.target, record.generation).claim) || record.phase !== "staging-cleanup" || Object.keys(record).length !== 6)
8578
+ if (record.schema !== 1 || typeof record.generation !== "string" || !isUuid(record.generation) || !isCanonicalPath(record.target) || typeof record.version !== "string" || !isReleaseVersion(record.version) || typeof record.claim !== "string" || record.claim !== basename11(updateRetirementPaths(record.target, record.generation).claim) || record.phase !== "staging-cleanup" || Object.keys(record).length !== 6)
8578
8579
  return;
8579
8580
  return record;
8580
8581
  }
@@ -8620,13 +8621,13 @@ function retentionPruneProgressPath(target, generation) {
8620
8621
  return `${base.claim.slice(0, -".claim.json".length)}.prune-progress.json`;
8621
8622
  }
8622
8623
  function pruneProgressNames(target, generation) {
8623
- return [basename11(retentionPruneProgressPath(target, generation))];
8624
+ return [basename12(retentionPruneProgressPath(target, generation))];
8624
8625
  }
8625
8626
  function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {}, message = "An update retirement cleanup marker requires recovery") {
8626
- const pruneMarkerPrefix = `.${basename11(target)}.framework-prune-`;
8627
- const pruneTemporaryPrefix = `..${basename11(target)}.framework-prune-`;
8628
- const retirementPrefix = `.${basename11(target)}.framework-retired-`;
8629
- const allowedRetentionIntentName = allowances.allowedRetentionIntentGeneration ? basename11(updateRetentionIntentPath(target, allowances.allowedRetentionIntentGeneration)) : undefined;
8627
+ const pruneMarkerPrefix = `.${basename12(target)}.framework-prune-`;
8628
+ const pruneTemporaryPrefix = `..${basename12(target)}.framework-prune-`;
8629
+ const retirementPrefix = `.${basename12(target)}.framework-retired-`;
8630
+ const allowedRetentionIntentName = allowances.allowedRetentionIntentGeneration ? basename12(updateRetentionIntentPath(target, allowances.allowedRetentionIntentGeneration)) : undefined;
8630
8631
  const allowedProgressName = allowances.allowedPruneProgressGeneration ? pruneProgressNames(target, allowances.allowedPruneProgressGeneration)[0] : undefined;
8631
8632
  if (names.some((name) => {
8632
8633
  const foldedName = name.toLowerCase();
@@ -8642,17 +8643,17 @@ function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {
8642
8643
 
8643
8644
  // ../../src/updates/retention/retirement-inventory.ts
8644
8645
  async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
8645
- if (!isCanonicalPath(target) || !basename12(target))
8646
+ if (!isCanonicalPath(target) || !basename13(target))
8646
8647
  throw new Error("Invalid update retention prune gate target");
8647
8648
  assertNoUnresolvedRetentionPruneArtifacts(target, await readdir10(dirname10(target)), {}, "update retention prune requires recovery before staging");
8648
8649
  }
8649
8650
 
8650
8651
  // ../../src/updates/retention/update-retirement.ts
8651
8652
  import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile8 } from "fs/promises";
8652
- import { basename as basename13, dirname as dirname11, join as join29 } from "path";
8653
+ import { basename as basename14, dirname as dirname11, join as join29 } from "path";
8653
8654
  async function reconcileRetirementCleanupMarkerWhileLocked(options) {
8654
8655
  const { target, staging, currentVersion } = options;
8655
- const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
8656
+ const markerPath = join29(dirname11(target), `.${basename14(target)}.framework-update-cleanup.json`);
8656
8657
  const markerInfo = await pathInfo(markerPath);
8657
8658
  if (!markerInfo)
8658
8659
  return "none";
@@ -8664,7 +8665,7 @@ async function reconcileRetirementCleanupMarkerWhileLocked(options) {
8664
8665
  return "recovery-required";
8665
8666
  const paths = updateRetirementPaths(target, marker.generation);
8666
8667
  const owner = await readOwner(paths.claim);
8667
- if (!owner || owner.target !== target || owner.generation !== marker.generation || owner.newVersion !== marker.version || marker.claim !== basename13(paths.claim) || !await matchesOwnedTree(paths.tree, owner))
8668
+ if (!owner || owner.target !== target || owner.generation !== marker.generation || owner.newVersion !== marker.version || marker.claim !== basename14(paths.claim) || !await matchesOwnedTree(paths.tree, owner))
8668
8669
  return "recovery-required";
8669
8670
  const containerInfo = await pathInfo(paths.container);
8670
8671
  if (!containerInfo?.isDirectory() || containerInfo.isSymbolicLink())
@@ -9446,7 +9447,7 @@ async function discoverSignedRelease(options) {
9446
9447
 
9447
9448
  // ../../src/updates/install/update-download.ts
9448
9449
  import { mkdtemp as mkdtemp10, open as open11, realpath as realpath10, rm as rm10 } from "fs/promises";
9449
- import { basename as basename14, dirname as dirname13, join as join33, resolve as resolve15 } from "path";
9450
+ import { basename as basename15, dirname as dirname13, join as join33, resolve as resolve15 } from "path";
9450
9451
  async function downloadVerifiedRelease(options) {
9451
9452
  const { descriptor, maxBytes } = options;
9452
9453
  const timeout = options.timeoutMs ?? 120000;
@@ -9481,7 +9482,7 @@ async function downloadVerifiedRelease(options) {
9481
9482
  const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
9482
9483
  const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp10(join33(root, "framework-update-"));
9483
9484
  const temporaryDirectory = resolve15(allocated);
9484
- if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
9485
+ if (dirname13(temporaryDirectory) !== root || !basename15(temporaryDirectory).startsWith("framework-update-"))
9485
9486
  throw new Error("Invalid update download directory");
9486
9487
  temporary = temporaryDirectory;
9487
9488
  const path = join33(temporary, "archive");
@@ -9823,7 +9824,7 @@ import {
9823
9824
  import { dirname as dirname14, join as join36, resolve as resolve17 } from "path";
9824
9825
  import { promisify as promisify4 } from "util";
9825
9826
  var shasum = /^[a-f0-9]{64}$/;
9826
- var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
9827
+ var basename16 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
9827
9828
  var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
9828
9829
  var exec = promisify4(execFile4);
9829
9830
  function requireThat2(condition, message) {
@@ -9836,7 +9837,7 @@ function record2(value) {
9836
9837
  }
9837
9838
  function validIdentity(value) {
9838
9839
  const { name, size, sha256 } = record2(value);
9839
- requireThat2(typeof name === "string" && basename15.test(name) && typeof size === "number" && Number.isSafeInteger(size) && size > 0 && typeof sha256 === "string" && shasum.test(sha256), "Invalid package artifact identity");
9840
+ requireThat2(typeof name === "string" && basename16.test(name) && typeof size === "number" && Number.isSafeInteger(size) && size > 0 && typeof sha256 === "string" && shasum.test(sha256), "Invalid package artifact identity");
9840
9841
  return { name, size, sha256 };
9841
9842
  }
9842
9843
  var inspectWithNativeTools = async (tool, args) => {
@@ -9941,7 +9942,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
9941
9942
  const receipt = record2(options.producer);
9942
9943
  const archive = validIdentity(expected.archive);
9943
9944
  const runtime = validIdentity(expected.runtime);
9944
- requireThat2(validTag.test(expected.tag) && /^[a-f0-9]{40}$/.test(expected.sourceSha) && basename15.test(expected.debName) && expected.debName.endsWith(".deb") && basename15.test(expected.appImageName) && expected.appImageName.endsWith(".AppImage") && archive.name.endsWith(".tar.zst") && /^[a-z0-9][a-z0-9+.-]+$/.test(expected.debPackage) && /^[A-Za-z0-9][A-Za-z0-9_.-]*\.desktop$/.test(expected.desktopId) && expected.desktopName.length > 0 && !/[\r\n]/.test(expected.desktopName) && Number.isSafeInteger(expected.runtime.size) && expected.runtime.size >= 64 && expected.runtime.size <= 64 * 1024 * 1024 && shasum.test(expected.runtime.sha256), "Invalid trusted Linux package policy");
9945
+ requireThat2(validTag.test(expected.tag) && /^[a-f0-9]{40}$/.test(expected.sourceSha) && basename16.test(expected.debName) && expected.debName.endsWith(".deb") && basename16.test(expected.appImageName) && expected.appImageName.endsWith(".AppImage") && archive.name.endsWith(".tar.zst") && /^[a-z0-9][a-z0-9+.-]+$/.test(expected.debPackage) && /^[A-Za-z0-9][A-Za-z0-9_.-]*\.desktop$/.test(expected.desktopId) && expected.desktopName.length > 0 && !/[\r\n]/.test(expected.desktopName) && Number.isSafeInteger(expected.runtime.size) && expected.runtime.size >= 64 && expected.runtime.size <= 64 * 1024 * 1024 && shasum.test(expected.runtime.sha256), "Invalid trusted Linux package policy");
9945
9946
  requireThat2(receipt.releaseAuthorized !== false && receipt.schema !== "private-linux-package-formats/v1" && receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === target.platform && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
9946
9947
  const names = [expected.debName, expected.appImageName];
9947
9948
  const artifacts = receipt.artifacts.map(validIdentity);
@@ -10029,7 +10030,7 @@ import {
10029
10030
  utimes,
10030
10031
  writeFile as writeFile13
10031
10032
  } from "fs/promises";
10032
- import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative5, resolve as resolve18 } from "path";
10033
+ import { basename as basename17, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative5, resolve as resolve18 } from "path";
10033
10034
  import { pipeline as pipeline2 } from "stream/promises";
10034
10035
  var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
10035
10036
  var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
@@ -10137,7 +10138,7 @@ async function buildLinuxFormats(input, host) {
10137
10138
  validatePolicy(policy);
10138
10139
  const requested = resolve18(input.output);
10139
10140
  const parent = await realpath12(dirname15(requested));
10140
- const output = join37(parent, basename16(requested));
10141
+ const output = join37(parent, basename17(requested));
10141
10142
  const work = await mkdtemp12(join37(parent, ".linux-formats-"));
10142
10143
  let outputOwned = false;
10143
10144
  try {
@@ -10308,7 +10309,7 @@ exec "$root/${installed}/${policy.launcher}" "$@"
10308
10309
  outputOwned = true;
10309
10310
  try {
10310
10311
  for (const item of artifacts)
10311
- await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
10312
+ await cp(join37(dest, item.name), join37(output, basename17(item.name)), {
10312
10313
  force: false,
10313
10314
  errorOnExist: true
10314
10315
  });
@@ -10342,7 +10343,7 @@ import { createHash as createHash25 } from "crypto";
10342
10343
  import { constants as constants8 } from "fs";
10343
10344
  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";
10344
10345
  import { tmpdir as tmpdir6 } from "os";
10345
- import { basename as basename17, isAbsolute as isAbsolute8, join as join38, resolve as resolve19 } from "path";
10346
+ import { basename as basename18, isAbsolute as isAbsolute8, join as join38, resolve as resolve19 } from "path";
10346
10347
  import { promisify as promisify5 } from "util";
10347
10348
 
10348
10349
  // src/library/windows-standalone-bootstrap.ts
@@ -10578,7 +10579,7 @@ async function buildStandaloneWindowsExe(options) {
10578
10579
  if (compilerIdentity.sha256 !== zigSha256)
10579
10580
  throw new Error("Pinned Zig compiler SHA-256 mismatch");
10580
10581
  const output = resolve19(options.output);
10581
- if (!basename17(output).endsWith("-Setup.exe"))
10582
+ if (!basename18(output).endsWith("-Setup.exe"))
10582
10583
  throw new Error("Expected final Windows Setup EXE filename");
10583
10584
  const root = resolve19(options.hutchMembers);
10584
10585
  const hidden = join38(root, ".installer");
@@ -0,0 +1,27 @@
1
+ import { isAbsolute } from "node:path";
2
+ const JOB_NUMBER = /^[1-9]\d{0,19}$/;
3
+ export function hostedRunnerRefusal(env) {
4
+ if (env.CI !== "true")
5
+ return "CI is not true";
6
+ if (env.GITHUB_ACTIONS === "true")
7
+ return env.RUNNER_ENVIRONMENT === "github-hosted" ? void 0 : "RUNNER_ENVIRONMENT is not github-hosted";
8
+ if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
9
+ return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
10
+ if (env.GITLAB_CI === "true")
11
+ return JOB_NUMBER.test(env.CI_JOB_ID ?? "") ? void 0 : "CI_JOB_ID is not a job number";
12
+ if (env.CIRCLECI !== "true")
13
+ return "neither GITLAB_CI nor CIRCLECI is true";
14
+ return JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "") ? void 0 : "CIRCLE_BUILD_NUM is not a job number";
15
+ }
16
+ export function isHostedRunner(env) {
17
+ return hostedRunnerRefusal(env) === void 0;
18
+ }
19
+ export function assertHostedRunner(env, subject) {
20
+ const refusal = hostedRunnerRefusal(env);
21
+ if (refusal !== void 0)
22
+ throw Error(`${subject} requires a disposable hosted runner (${refusal})`);
23
+ }
24
+ export function runnerTemp(env) {
25
+ const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
26
+ return path && isAbsolute(path) ? path : void 0;
27
+ }
@@ -0,0 +1,52 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ if (Bun.isMainThread)
3
+ await drivePreflight();
4
+ else
5
+ await reportPreflightState();
6
+ async function drivePreflight() {
7
+ const {
8
+ FRAMEWORK_CI_WORKER_ENTRY: entry,
9
+ FRAMEWORK_CI_NONCE: nonce,
10
+ FRAMEWORK_CI_ACK: ack,
11
+ FRAMEWORK_CI_PERMIT: permit
12
+ } = process.env;
13
+ if (!entry || !nonce || !ack || !permit)
14
+ throw Error("Missing preflight context");
15
+ const worker = new Worker(entry, {}), result = new Promise((resolve) => worker.addEventListener("message", (event) => resolve(event.data), { once: !0 })), deadline = performance.now() + 1e4;
16
+ let acknowledged = !1;
17
+ while (!acknowledged && performance.now() < deadline) {
18
+ try {
19
+ acknowledged = await readFile(ack, "utf8") === nonce + `
20
+ `;
21
+ } catch {}
22
+ if (!acknowledged)
23
+ await Bun.sleep(20);
24
+ }
25
+ if (!acknowledged)
26
+ throw Error("Worker guard acknowledgement missing");
27
+ await writeFile(permit, nonce + `
28
+ `, { flag: "wx", mode: 384 });
29
+ let timer;
30
+ const timeout = new Promise((resolve) => {
31
+ timer = setTimeout(() => resolve(null), Math.max(0, deadline - performance.now()));
32
+ }), value = await Promise.race([result, timeout]);
33
+ clearTimeout(timer);
34
+ worker.terminate();
35
+ if (value?.blocked !== !0 || value.nested !== !0)
36
+ throw Error("Worker guard preflight failed");
37
+ console.log("framework installer preload preflight passed");
38
+ }
39
+ async function reportPreflightState() {
40
+ let blocked = !1, nested = !1;
41
+ try {
42
+ await fetch("https://example.invalid/framework-ci-sentinel");
43
+ } catch {
44
+ blocked = !0;
45
+ }
46
+ try {
47
+ new Worker("unexpected").terminate();
48
+ } catch {
49
+ nested = !0;
50
+ }
51
+ postMessage({ blocked, nested });
52
+ }
@@ -0,0 +1,90 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { isAbsolute } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { installInstallerFetchGuard } from "./installer-fetch-guard";
5
+ import { installInstallerRendererProbe } from "./installer-renderer-evidence";
6
+ import { parseOfflinePolicy } from "../release/release-qualification";
7
+ import { awaitInstallerWorkerPermit, interceptInstallerWorker } from "./installer-worker-guard";
8
+ if (Bun.isMainThread) {
9
+ const entry = process.env.FRAMEWORK_CI_WORKER_ENTRY;
10
+ if (!entry)
11
+ throw Error("Missing installer CI preload context");
12
+ interceptInstallerWorker({
13
+ env: process.env,
14
+ globals: globalThis,
15
+ entry,
16
+ bootstrap: fileURLToPath(import.meta.url)
17
+ });
18
+ } else
19
+ await runGuardedWorker();
20
+ async function runGuardedWorker() {
21
+ const env = process.env, {
22
+ FRAMEWORK_CI_WORKER_ENTRY: entry,
23
+ FRAMEWORK_CI_NONCE: nonce,
24
+ FRAMEWORK_CI_ACK: acknowledgement,
25
+ FRAMEWORK_CI_PERMIT: permit,
26
+ FRAMEWORK_CI_ORIGIN: origin,
27
+ FRAMEWORK_CI_OBSERVATION: observation,
28
+ FRAMEWORK_CI_UNEXPECTED: unexpected,
29
+ FRAMEWORK_CI_PID: pidRecord
30
+ } = env;
31
+ if (pidRecord !== void 0 && (!isAbsolute(pidRecord) || [entry, acknowledgement, permit, observation, unexpected].includes(pidRecord)) || ![entry, acknowledgement, permit, observation, unexpected].every((value) => typeof value === "string" && isAbsolute(value)) || !nonce || !origin || new Set([acknowledgement, permit, observation, unexpected]).size !== 4)
32
+ throw Error("Invalid installer CI worker context");
33
+ const encoded = env.FRAMEWORK_CI_EXPECTED_READS ?? "[]";
34
+ if (encoded.length > 8192)
35
+ throw Error("Invalid expected reads");
36
+ const expectedReads = JSON.parse(encoded), offlineEncoded = env.FRAMEWORK_CI_OFFLINE_POLICY;
37
+ if (offlineEncoded && offlineEncoded.length > 2048)
38
+ throw Error("Invalid offline policy");
39
+ const offlinePolicy = offlineEncoded ? parseOfflinePolicy(JSON.parse(offlineEncoded)) : void 0;
40
+ if (!Array.isArray(expectedReads) || expectedReads.some((value) => typeof value !== "string"))
41
+ throw Error("Invalid expected reads");
42
+ let recordedUnexpected = !1;
43
+ const guard = installInstallerFetchGuard({
44
+ env,
45
+ globals: globalThis,
46
+ origin,
47
+ expectedReads,
48
+ onUnexpected: () => {
49
+ if (!recordedUnexpected) {
50
+ writeFileSync(unexpected, nonce + `
51
+ `, { flag: "wx", mode: 384 });
52
+ recordedUnexpected = !0;
53
+ }
54
+ }
55
+ });
56
+ if (!["0", "1", void 0].includes(env.FRAMEWORK_CI_ALLOW_EPHEMERAL))
57
+ throw Error("Invalid listener selection");
58
+ installInstallerRendererProbe({
59
+ env,
60
+ origin,
61
+ nonce,
62
+ allowEphemeral: env.FRAMEWORK_CI_ALLOW_EPHEMERAL === "1",
63
+ offlinePolicy,
64
+ foreignOrigin: env.FRAMEWORK_CI_FOREIGN_ORIGIN,
65
+ runtime: Bun,
66
+ save: (value, state) => {
67
+ writeFileSync(observation, JSON.stringify({
68
+ nonce,
69
+ origin,
70
+ ...value,
71
+ blockedReads: guard.blockedReads,
72
+ unexpectedActivity: guard.unexpectedActivity,
73
+ ...offlinePolicy ? { offlinePolicy, bootstrapDenied: state.bootstrapDenied } : {}
74
+ }) + `
75
+ `, { flag: "wx", mode: 384 });
76
+ }
77
+ });
78
+ if (pidRecord)
79
+ writeFileSync(pidRecord, nonce + `
80
+ ` + process.pid + `
81
+ `, { flag: "wx", mode: 384 });
82
+ await import(await awaitInstallerWorkerPermit({
83
+ env,
84
+ globals: globalThis,
85
+ entry,
86
+ nonce,
87
+ acknowledgement,
88
+ permit
89
+ }));
90
+ }
@@ -0,0 +1,53 @@
1
+ import { assertHostedRunner } from "./hosted-runner";
2
+ export function installInstallerFetchGuard(options) {
3
+ assertHostedRunner(options.env, "Fetch guard");
4
+ const origin = new URL(options.origin);
5
+ if (origin.protocol !== "http:" || origin.hostname !== "127.0.0.1" || !origin.port || origin.origin !== options.origin)
6
+ throw Error("Invalid installer probe origin");
7
+ const expected = new Set(options.expectedReads ?? []);
8
+ if (expected.size !== (options.expectedReads ?? []).length || expected.size > 32)
9
+ throw Error("Invalid expected reads");
10
+ for (const value of expected) {
11
+ const url = new URL(value);
12
+ if (url.protocol !== "https:" || url.username || url.password || url.hash || url.href !== value)
13
+ throw Error("Invalid expected read");
14
+ }
15
+ const original = options.globals.fetch;
16
+ if (typeof original !== "function")
17
+ throw Error("Missing fetch implementation");
18
+ let blockedReads = 0, unexpectedActivity = !1;
19
+ const unexpected = () => {
20
+ unexpectedActivity = !0;
21
+ options.onUnexpected?.();
22
+ }, guard = Object.assign(async (...[input, init]) => {
23
+ let request;
24
+ try {
25
+ request = new Request(input, init);
26
+ } catch {
27
+ unexpected();
28
+ throw Error("Invalid guarded request");
29
+ }
30
+ const url = new URL(request.url);
31
+ if (url.origin === origin.origin && !url.username && !url.password)
32
+ return original.call(options.globals, request, { redirect: "error" });
33
+ blockedReads++;
34
+ if (request.method !== "GET" || !expected.has(url.href) || request.headers.has("authorization") || request.headers.has("cookie") || init?.credentials === "include")
35
+ unexpected();
36
+ throw Error("Installer qualification blocks external fetch");
37
+ }, {
38
+ preconnect: () => {
39
+ unexpected();
40
+ throw Error("Installer qualification blocks preconnect");
41
+ }
42
+ });
43
+ if (!Reflect.set(options.globals, "fetch", guard) || options.globals.fetch !== guard)
44
+ throw Error("Cannot install fetch guard");
45
+ return {
46
+ get blockedReads() {
47
+ return blockedReads;
48
+ },
49
+ get unexpectedActivity() {
50
+ return unexpectedActivity;
51
+ }
52
+ };
53
+ }
@@ -0,0 +1,124 @@
1
+ import { parseOfflinePolicy } from "../release/release-qualification";
2
+ import { BoundedBodyError, readBoundedText } from "../shared/bounded-body";
3
+ import { assertHostedRunner } from "./hosted-runner";
4
+ function safeScriptString(value) {
5
+ return JSON.stringify(value).replaceAll("<", "\\u003c").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
6
+ }
7
+ export function assertInstallerRendererObservation(value, offline = !1) {
8
+ if (typeof value !== "object" || value === null || Array.isArray(value))
9
+ throw Error("Invalid renderer observation");
10
+ const item = value, keys = [
11
+ "samples",
12
+ "elapsedMs",
13
+ "visible",
14
+ "readyState",
15
+ "width",
16
+ "height",
17
+ "interactiveElements",
18
+ "textLength",
19
+ ...offline ? ["markerObserved", "foreignBlocked"] : []
20
+ ];
21
+ if (offline && (item.markerObserved !== !0 || item.foreignBlocked !== !0) || Object.keys(item).length !== keys.length || keys.some((key) => !Object.hasOwn(item, key)) || item.samples !== 2 || typeof item.elapsedMs !== "number" || !Number.isFinite(item.elapsedMs) || item.elapsedMs < 3000 || item.elapsedMs > 120000 || item.visible !== !0 || !["interactive", "complete"].includes(String(item.readyState)) || typeof item.width !== "number" || !Number.isFinite(item.width) || item.width < 100 || typeof item.height !== "number" || !Number.isFinite(item.height) || item.height < 100 || !Number.isSafeInteger(item.interactiveElements) || Number(item.interactiveElements) < 1 || !Number.isSafeInteger(item.textLength) || Number(item.textLength) < 1)
22
+ throw Error("Incomplete renderer observation");
23
+ }
24
+ async function boundedBody(message, maximum) {
25
+ try {
26
+ return await readBoundedText(message, maximum);
27
+ } catch (error) {
28
+ if (!(error instanceof BoundedBodyError))
29
+ throw error;
30
+ if (error.reason === "too-large")
31
+ throw Error("Renderer body exceeds bound", { cause: error });
32
+ if (error.reason === "missing")
33
+ throw Error("Missing renderer body", { cause: error });
34
+ throw error.cause ?? error;
35
+ }
36
+ }
37
+ function probeScript(nonce, policy, foreignOrigin) {
38
+ return `<script>(()=>{const started=performance.now();requestAnimationFrame(()=>{setTimeout(()=>requestAnimationFrame(async()=>{const d=document;const data={samples:2,elapsedMs:performance.now()-started,visible:d.visibilityState==='visible',readyState:d.readyState,width:innerWidth,height:innerHeight,interactiveElements:d.querySelectorAll('button,input,textarea,select,a[href],[role="button"]').length,textLength:(d.body?.innerText||'').trim().length};${policy ? `data.markerObserved=(d.body?.innerText||'').includes(${safeScriptString(policy.marker)});try{await fetch(${safeScriptString(foreignOrigin)}+'/',{mode:'no-cors',cache:'no-store'});data.foreignBlocked=false}catch{data.foreignBlocked=true}` : ""};fetch('/__framework_installer_probe/${nonce}',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(data),redirect:'error'}).catch(()=>{});}),3100);});})();</script>`;
39
+ }
40
+ export function createInstallerRendererHandler(options) {
41
+ assertHostedRunner(options.env, "Renderer probe");
42
+ const origin = new URL(options.origin);
43
+ if (origin.protocol !== "http:" || origin.hostname !== "127.0.0.1" || !origin.port || origin.origin !== options.origin || !/^[a-f0-9]{48}$/.test(options.nonce))
44
+ throw Error("Invalid renderer probe context");
45
+ const policy = options.offlinePolicy === void 0 ? void 0 : parseOfflinePolicy(options.offlinePolicy);
46
+ if (policy) {
47
+ if (!options.foreignOrigin)
48
+ throw Error("Missing foreign network sentinel");
49
+ const foreign = new URL(options.foreignOrigin);
50
+ if (foreign.protocol !== "http:" || foreign.hostname !== "127.0.0.1" || !foreign.port || foreign.origin !== options.foreignOrigin || foreign.origin === origin.origin)
51
+ throw Error("Invalid foreign network sentinel");
52
+ } else if (options.foreignOrigin !== void 0)
53
+ throw Error("Unexpected foreign network sentinel");
54
+ const path = `/__framework_installer_probe/${options.nonce}`;
55
+ let documentServed = !1, received = !1, bootstrapDenied = !1;
56
+ return async (request) => {
57
+ const url = new URL(request.url);
58
+ if (url.origin !== options.origin || request.headers.get("host") !== origin.host)
59
+ return new Response(null, { status: 403 });
60
+ if (policy?.kind === "local-bootstrap" && url.pathname === policy.path) {
61
+ if (request.headers.get("origin") === options.origin && [null, "same-origin"].includes(request.headers.get("sec-fetch-site")))
62
+ bootstrapDenied = !0;
63
+ return new Response(null, { status: 503 });
64
+ }
65
+ if (url.pathname.startsWith("/__framework_installer_probe/")) {
66
+ if (url.pathname !== path || url.search || request.method !== "POST" || request.headers.get("origin") !== options.origin || ![null, "same-origin"].includes(request.headers.get("sec-fetch-site")) || request.headers.get("content-type") !== "application/json" || !documentServed || received)
67
+ return new Response(null, { status: 403 });
68
+ received = !0;
69
+ try {
70
+ const value = JSON.parse(await boundedBody(request, 4096));
71
+ assertInstallerRendererObservation(value, Boolean(policy));
72
+ await options.save(value, { bootstrapDenied });
73
+ return new Response(null, { status: 204 });
74
+ } catch {
75
+ return new Response(null, { status: 400 });
76
+ }
77
+ }
78
+ const response = await options.handle(request);
79
+ if (request.method !== "GET" || url.pathname !== "/" || url.search || response.status !== 200 || !/^text\/html\b/i.test(response.headers.get("content-type") ?? ""))
80
+ return response;
81
+ if (response.headers.has("content-encoding"))
82
+ throw Error("Encoded renderer documents are unsupported");
83
+ const html = await boundedBody(response, 2097152);
84
+ if (!html.includes("</body>"))
85
+ throw Error("Invalid renderer document");
86
+ documentServed = !0;
87
+ const headers = new Headers(response.headers);
88
+ headers.delete("content-length");
89
+ headers.delete("content-encoding");
90
+ headers.delete("etag");
91
+ headers.append("content-security-policy", "default-src 'self' data:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data: blob:; media-src 'self' data: blob:; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'none'");
92
+ return new Response(html.replace("</body>", probeScript(options.nonce, policy, options.foreignOrigin) + "</body>"), { status: response.status, statusText: response.statusText, headers });
93
+ };
94
+ }
95
+ export function installInstallerRendererProbe(options) {
96
+ const { runtime } = options, original = runtime.serve;
97
+ if (typeof original !== "function")
98
+ throw Error("Missing Bun server implementation");
99
+ let used = !1;
100
+ const port = Number(new URL(options.origin).port), replace = function(config) {
101
+ if (!config || config.hostname !== "127.0.0.1" || Number(config.port) !== port && !(options.allowEphemeral === !0 && config.port === 0))
102
+ return original.call(runtime, config);
103
+ if (used || typeof config.fetch !== "function")
104
+ throw Error("Unexpected renderer probe listener");
105
+ used = !0;
106
+ const fetch = config.fetch;
107
+ let activeServer;
108
+ const handler = createInstallerRendererHandler({
109
+ ...options,
110
+ handle: (request) => fetch(request, activeServer)
111
+ });
112
+ return original.call(runtime, {
113
+ ...config,
114
+ port,
115
+ fetch(request, server) {
116
+ activeServer = server;
117
+ return handler(request);
118
+ }
119
+ });
120
+ };
121
+ createInstallerRendererHandler({ ...options, handle: () => new Response });
122
+ if (!Reflect.set(runtime, "serve", replace) || runtime.serve !== replace)
123
+ throw Error("Cannot install renderer probe");
124
+ }