create-op-node 0.10.1 → 0.10.2

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 CHANGED
@@ -1493,20 +1493,72 @@ set -euo pipefail
1493
1493
 
1494
1494
  SVC="org.opuspopuli.${input.region}"
1495
1495
 
1496
+ # macOS \`security\` exit codes:
1497
+ # 0 = success
1498
+ # 36 = errSecInteractionNotAllowed (keychain is locked)
1499
+ # 44 = errSecItemNotFound (entry doesn't exist)
1500
+ # Earlier wrapper versions conflated 36 and 44 into a generic "missing"
1501
+ # message, which sent operators down the wrong path (re-bootstrap when
1502
+ # the real fix was \`security unlock-keychain\`).
1496
1503
  require_secret() {
1497
1504
  local account="$1"
1498
1505
  local value
1499
- if ! value=$(security find-generic-password -s "$SVC" -a "$account" -w 2>/dev/null); then
1500
- echo "op-compose: missing Keychain entry '$account' under service '$SVC'." >&2
1501
- echo "Run: create-op-node bootstrap --region ${input.region}" >&2
1502
- exit 1
1503
- fi
1504
- printf '%s' "$value"
1506
+ local rc=0
1507
+ value=$(security find-generic-password -s "$SVC" -a "$account" -w 2>/dev/null) || rc=$?
1508
+ case "$rc" in
1509
+ 0)
1510
+ printf '%s' "$value"
1511
+ return 0
1512
+ ;;
1513
+ 36)
1514
+ cat >&2 <<EOM
1515
+ op-compose: keychain is LOCKED \u2014 could not read entry '$account'.
1516
+ SSH sessions don't auto-unlock the login keychain. Unlock with:
1517
+ security unlock-keychain ~/Library/Keychains/login.keychain-db
1518
+ Then re-run this command.
1519
+ EOM
1520
+ exit 1
1521
+ ;;
1522
+ 44)
1523
+ cat >&2 <<EOM
1524
+ op-compose: keychain entry '$account' is MISSING under service '$SVC'.
1525
+ Run: create-op-node bootstrap --region ${input.region}
1526
+ EOM
1527
+ exit 1
1528
+ ;;
1529
+ *)
1530
+ echo "op-compose: \`security\` failed reading '$account' (exit $rc)." >&2
1531
+ exit 1
1532
+ ;;
1533
+ esac
1505
1534
  }
1506
1535
 
1536
+ # Used for entries that may legitimately not exist (TUNNEL_TOKEN in
1537
+ # local-only mode, prompt-service secrets when colocation isn't active).
1538
+ # Treats exit 44 (missing) as a silent OK \u2014 returns empty string.
1539
+ # Treats exit 36 (locked) as a hard error, since the require_secret calls
1540
+ # at the top of the wrapper would have caught this first in normal use;
1541
+ # reaching this path means something else bypassed the lock check.
1507
1542
  optional_secret() {
1508
1543
  local account="$1"
1509
- security find-generic-password -s "$SVC" -a "$account" -w 2>/dev/null || true
1544
+ local value
1545
+ local rc=0
1546
+ value=$(security find-generic-password -s "$SVC" -a "$account" -w 2>/dev/null) || rc=$?
1547
+ case "$rc" in
1548
+ 0) printf '%s' "$value" ;;
1549
+ 44) ;; # legitimately absent \u2014 empty string is correct
1550
+ 36)
1551
+ cat >&2 <<EOM
1552
+ op-compose: keychain is LOCKED \u2014 could not probe optional entry '$account'.
1553
+ Unlock with: security unlock-keychain ~/Library/Keychains/login.keychain-db
1554
+ EOM
1555
+ exit 1
1556
+ ;;
1557
+ *)
1558
+ echo "op-compose: \`security\` failed reading '$account' (exit $rc)." >&2
1559
+ exit 1
1560
+ ;;
1561
+ esac
1510
1562
  }
1511
1563
 
1512
1564
  # Bootstrap-critical: Postgres + Supabase admin credentials.
@@ -4400,7 +4452,7 @@ async function looksLikeRegionsRepo(dir) {
4400
4452
  }
4401
4453
 
4402
4454
  // src/cli.ts
4403
- var VERSION = "0.10.1";
4455
+ var VERSION = "0.10.2";
4404
4456
  var program = new Command();
4405
4457
  program.name("create-op-node").description(
4406
4458
  "Interactive bootstrap for an Opus Populi federation node.\nCloudflare infrastructure \u2192 Mac Studio \u2192 live public API."