freecode-sh 0.1.0-alpha.19 → 0.1.0-alpha.21

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.
Files changed (2) hide show
  1. package/install.sh +55 -15
  2. package/package.json +1 -1
package/install.sh CHANGED
@@ -9,6 +9,14 @@ DEFAULT_CHANNEL="alpha"
9
9
  DEFAULT_DOWNLOAD_BASE_URL="https://releases.freecode.sh/releases"
10
10
  DEFAULT_CHANNEL_BASE_URL="https://releases.freecode.sh/channels"
11
11
  EXPECTED_TEAM_IDENTIFIER="GD597P8KJ2"
12
+ # Apple code requirement language. "anchor apple generic" forces the signing
13
+ # chain to terminate at Apple's root certificate, so only a real Developer ID
14
+ # certificate issued to this team can satisfy it. Text printed by
15
+ # `codesign --display` cannot be trusted for this: Authority and TeamIdentifier
16
+ # lines are read straight out of the certificate, so a self-signed certificate
17
+ # can present any subject and OU it likes.
18
+ RELEASE_CODE_REQUIREMENT="=anchor apple generic and certificate leaf[subject.OU] = \"$EXPECTED_TEAM_IDENTIFIER\""
19
+ CODESIGN_BIN="/usr/bin/codesign"
12
20
  LEGACY_ALPHA6_MANIFEST_SHA256="1bf63e0d6114b12d61c07094936bd2606ae82ce87d5b054fbfb01c5f3d3646d8"
13
21
  LAUNCHER_RELATIVE_PATH="bin/freecode"
14
22
  INTERFACE_RELATIVE_PATH="libexec/freecode/freecode-tui"
@@ -374,6 +382,18 @@ validate_release_security() {
374
382
  esac
375
383
  }
376
384
 
385
+ # Test-only seam. Signature verification runs /usr/bin/codesign by absolute path
386
+ # so nothing on PATH can impersonate it; the installer test suite substitutes a
387
+ # stub, and like every other FREECODE_TEST_* override it is refused unless the
388
+ # release is being read from a local file:// URL.
389
+ resolve_codesign_bin() {
390
+ [ -n "${FREECODE_TEST_CODESIGN_BIN:-}" ] || return 0
391
+ case "$DOWNLOAD_BASE_URL" in
392
+ file://*) CODESIGN_BIN="$FREECODE_TEST_CODESIGN_BIN" ;;
393
+ *) fail "the test codesign override is permitted only with local file URLs" ;;
394
+ esac
395
+ }
396
+
377
397
  verify_release_signatures() {
378
398
  root=$1
379
399
  if [ "$RELEASE_MODE" = "unsigned-override" ]; then
@@ -381,19 +401,15 @@ verify_release_signatures() {
381
401
  return
382
402
  fi
383
403
 
384
- [ -x /usr/bin/codesign ] || fail "/usr/bin/codesign is required to verify this release"
404
+ [ -x "$CODESIGN_BIN" ] || fail "$CODESIGN_BIN is required to verify this release"
385
405
  for executable in \
386
406
  "$root/$LAUNCHER_RELATIVE_PATH" \
387
407
  "$root/$INTERFACE_RELATIVE_PATH" \
388
408
  "$root/$ENGINE_RELATIVE_PATH"
389
409
  do
390
- /usr/bin/codesign --verify --strict --verbose=2 "$executable" \
391
- || fail "Apple signature verification failed for $executable"
392
- SIGNATURE_DETAILS=$(/usr/bin/codesign --display --verbose=4 "$executable" 2>&1) \
393
- || fail "could not inspect Apple signature for $executable"
394
- TEAM_IDENTIFIER=$(printf '%s\n' "$SIGNATURE_DETAILS" | sed -n 's/^TeamIdentifier=//p' | head -n 1)
395
- [ "$TEAM_IDENTIFIER" = "$EXPECTED_TEAM_IDENTIFIER" ] \
396
- || fail "unexpected Apple TeamIdentifier for $executable (expected $EXPECTED_TEAM_IDENTIFIER, received ${TEAM_IDENTIFIER:-missing})"
410
+ # Without -R this only proves the seal is intact, not who signed it.
411
+ "$CODESIGN_BIN" --verify --strict --verbose=2 -R "$RELEASE_CODE_REQUIREMENT" "$executable" \
412
+ || fail "Apple signature verification failed for $executable; it must be Developer ID signed by Apple team $EXPECTED_TEAM_IDENTIFIER"
397
413
  done
398
414
  }
399
415
 
@@ -466,6 +482,8 @@ DOWNLOAD_BASE_URL=${DOWNLOAD_BASE_URL%/}
466
482
  CHANNEL_BASE_URL=${CHANNEL_BASE_URL%/}
467
483
  validate_channel "$CHANNEL"
468
484
 
485
+ resolve_codesign_bin
486
+
469
487
  TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/freecode-install.XXXXXX")
470
488
  RELEASE_PUBLIC_KEY="$TEMP_DIR/release-signing-public.pem"
471
489
  write_release_public_key "$RELEASE_PUBLIC_KEY"
@@ -627,16 +645,38 @@ printf '\nUninstall:\n'
627
645
  printf ' rm -f "%s/freecode" && rm -rf "%s"\n' "$BIN_DIR" "$INSTALL_ROOT"
628
646
 
629
647
  if [ "$LAUNCH_AFTER_INSTALL" = "true" ]; then
630
- TTY_DEVICE="${FREECODE_TEST_TTY_FILE:-}"
631
- if [ -z "$TTY_DEVICE" ] && [ -t 1 ]; then
632
- TTY_DEVICE="/dev/tty"
648
+ if [ -n "${FREECODE_TEST_TTY_FILE:-}" ]; then
649
+ if [ -r "$FREECODE_TEST_TTY_FILE" ]; then
650
+ CAN_LAUNCH="true"
651
+ else
652
+ CAN_LAUNCH="false"
653
+ fi
654
+ elif [ -t 1 ]; then
655
+ CAN_LAUNCH="true"
656
+ else
657
+ CAN_LAUNCH="false"
633
658
  fi
634
- if [ -n "$TTY_DEVICE" ] && [ -r "$TTY_DEVICE" ]; then
659
+
660
+ if [ "$CAN_LAUNCH" = "true" ]; then
635
661
  printf '\nStarting Free Code...\n'
636
- if ! "$BIN_DIR/freecode" < "$TTY_DEVICE"; then
637
- printf '\nFree Code closed before startup finished. The installation is still ready.\n' >&2
662
+ if [ -n "${FREECODE_TEST_TTY_FILE:-}" ]; then
663
+ if "$BIN_DIR/freecode" < "$FREECODE_TEST_TTY_FILE"; then
664
+ LAUNCH_SUCCEEDED="true"
665
+ else
666
+ LAUNCH_SUCCEEDED="false"
667
+ fi
668
+ elif "$BIN_DIR/freecode" 0<&1; then
669
+ LAUNCH_SUCCEEDED="true"
670
+ else
671
+ LAUNCH_SUCCEEDED="false"
672
+ fi
673
+
674
+ if [ "$LAUNCH_SUCCEEDED" != "true" ]; then
675
+ printf '\nFree Code could not start automatically, but the installation succeeded.\n' >&2
676
+ printf 'Open a Terminal and run:\n "%s/freecode"\n' "$BIN_DIR" >&2
638
677
  fi
639
678
  else
640
- printf '\nFree Code is installed. Open a Terminal and run freecode when you are ready.\n'
679
+ printf '\nFree Code is installed. Open a Terminal and run:\n'
680
+ printf ' "%s/freecode"\n' "$BIN_DIR"
641
681
  fi
642
682
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freecode-sh",
3
- "version": "0.1.0-alpha.19",
3
+ "version": "0.1.0-alpha.21",
4
4
  "description": "A free coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Free Code",