harnessed 4.32.18 → 4.32.19

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.mjs CHANGED
@@ -11,7 +11,7 @@ import { Ajv } from 'ajv';
11
11
  import * as ajvFormatsNs from 'ajv-formats';
12
12
  import { execFileSync, spawnSync, spawn, execSync, exec, execFile } from 'child_process';
13
13
  import { pathToFileURL, fileURLToPath } from 'url';
14
- import { createHash } from 'crypto';
14
+ import { createHash, verify, createPublicKey } from 'crypto';
15
15
  import { promisify } from 'util';
16
16
  import { Parser } from 'expr-eval';
17
17
  import * as p from '@clack/prompts';
@@ -38,7 +38,7 @@ var init_package = __esm({
38
38
  "package.json"() {
39
39
  package_default = {
40
40
  name: "harnessed",
41
- version: "4.32.18",
41
+ version: "4.32.19",
42
42
  description: "AI coding harness package manager + composition orchestrator",
43
43
  type: "module",
44
44
  license: "Apache-2.0",
@@ -8657,6 +8657,24 @@ var init_auto_install = __esm({
8657
8657
  init_doctor_registry();
8658
8658
  }
8659
8659
  });
8660
+ function verifyShaSignature(shaText, sigBase64, publicKeyPem = HARNESSED_RELEASE_PUBKEY_PEM) {
8661
+ try {
8662
+ const sig = Buffer.from(sigBase64.trim(), "base64");
8663
+ if (sig.length === 0) return false;
8664
+ return verify(null, Buffer.from(shaText, "utf8"), createPublicKey(publicKeyPem), sig);
8665
+ } catch {
8666
+ return false;
8667
+ }
8668
+ }
8669
+ var HARNESSED_RELEASE_PUBKEY_PEM;
8670
+ var init_updateSignature = __esm({
8671
+ "src/cli/lib/updateSignature.ts"() {
8672
+ HARNESSED_RELEASE_PUBKEY_PEM = `-----BEGIN PUBLIC KEY-----
8673
+ MCowBQYDK2VwAyEAgCsfkZ+uCRNIBSHGfiOzp+TCSwQqOVJW1tsCW/beF4g=
8674
+ -----END PUBLIC KEY-----
8675
+ `;
8676
+ }
8677
+ });
8660
8678
 
8661
8679
  // src/cli/lib/selfUpdateBinary.ts
8662
8680
  var selfUpdateBinary_exports = {};
@@ -8740,6 +8758,7 @@ async function runBinarySelfUpdate(deps, opts) {
8740
8758
  const steps = [
8741
8759
  deps.sourceDir ? `copy ${sourceAsset} \u2192 ${tempPath} (local source dir \u2014 rehearsal seam)` : `download ${assetUrl ?? `latest ${asset}`} \u2192 ${tempPath}`,
8742
8760
  `verify sha256 against ${deps.sourceDir ? sourceSha : shaUrl ?? `${asset}.sha256`}`,
8761
+ "verify the ed25519 signature (.sha256.sig) against the embedded release public key",
8743
8762
  ...deps.platform === "win32" ? [] : ["chmod 755 the downloaded binary"],
8744
8763
  "smoke: spawn `--version` on the new binary",
8745
8764
  `rename ${deps.execPath} \u2192 ${bakPath} (same-dir, same-volume)`,
@@ -8770,6 +8789,16 @@ async function runBinarySelfUpdate(deps, opts) {
8770
8789
  `sha256 mismatch \u2014 expected ${expected.slice(0, 12)}\u2026, got ${actual.slice(0, 12)}\u2026`
8771
8790
  );
8772
8791
  }
8792
+ const sigText = deps.sourceDir ? await readFile(`${sourceSha ?? ""}.sig`, "utf8").catch(() => {
8793
+ throw new Error(`missing .sha256.sig (signature is contractual since 4.32.19)`);
8794
+ }) : await deps.fetchShaText(`${shaUrl ?? ""}.sig`).catch(() => {
8795
+ throw new Error(`missing .sha256.sig (signature is contractual since 4.32.19)`);
8796
+ });
8797
+ if (!verifyShaSignature(shaText, sigText, deps.publicKeyPem)) {
8798
+ throw new Error(
8799
+ `ed25519 signature over .sha256 did not verify \u2014 the release assets may be tampered`
8800
+ );
8801
+ }
8773
8802
  } catch (e) {
8774
8803
  await unlink2(tempPath).catch(() => {
8775
8804
  });
@@ -8933,6 +8962,7 @@ var init_selfUpdateBinary = __esm({
8933
8962
  "src/cli/lib/selfUpdateBinary.ts"() {
8934
8963
  init_package();
8935
8964
  init_platform();
8965
+ init_updateSignature();
8936
8966
  init_version_check();
8937
8967
  OWNER_REPO = "easyinplay/harnessed";
8938
8968
  RELEASES_LATEST_URL = `https://api.github.com/repos/${OWNER_REPO}/releases/latest`;