git-colabor 0.1.13 → 0.1.15

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.cjs CHANGED
@@ -140,17 +140,14 @@ var init_io = __esm({
140
140
  var map_exports = {};
141
141
  __export(map_exports, {
142
142
  addIdentity: () => addIdentity,
143
- clearStandingDown: () => clearStandingDown,
144
143
  findByIdentityEmail: () => findByIdentityEmail,
145
144
  findIdentity: () => findIdentity,
146
145
  getIdentity: () => getIdentity,
147
146
  getKeyBinding: () => getKeyBinding,
148
147
  hideIdentityEmail: () => hideIdentityEmail,
149
148
  idOf: () => idOf,
150
- isStandingDown: () => isStandingDown,
151
149
  listHiddenEmails: () => listHiddenEmails,
152
150
  listIdentities: () => listIdentities,
153
- markStandingDown: () => markStandingDown,
154
151
  readMap: () => readMap,
155
152
  removeIdentity: () => removeIdentity,
156
153
  setDefault: () => setDefault,
@@ -242,8 +239,7 @@ async function readMap() {
242
239
  // any v1 shape on disk folds into the v2 list above
243
240
  identities,
244
241
  ...defaultIdentity ? { defaultIdentity } : {},
245
- ...parsed.hidden ? { hidden: parsed.hidden } : {},
246
- ...parsed.standingDown ? { standingDown: parsed.standingDown } : {}
242
+ ...parsed.hidden ? { hidden: parsed.hidden } : {}
247
243
  };
248
244
  if (JSON.stringify(parsed) !== JSON.stringify(migrated)) {
249
245
  await writeMap(migrated);
@@ -318,23 +314,6 @@ async function hideIdentityEmail(email) {
318
314
  map.hidden = { ...map.hidden, [norm(email)]: true };
319
315
  await writeMap(map);
320
316
  }
321
- async function markStandingDown(root) {
322
- const map = await readMap();
323
- const roots = new Set(map.standingDown ?? []);
324
- roots.add(root);
325
- map.standingDown = [...roots];
326
- await writeMap(map);
327
- }
328
- async function clearStandingDown(root) {
329
- const map = await readMap();
330
- if (!map.standingDown?.includes(root)) return;
331
- map.standingDown = map.standingDown.filter((r) => r !== root);
332
- await writeMap(map);
333
- }
334
- async function isStandingDown(root) {
335
- const map = await readMap();
336
- return (map.standingDown ?? []).includes(root);
337
- }
338
317
  async function unhideIdentityEmail(email) {
339
318
  const map = await readMap();
340
319
  const key = norm(email);
@@ -764,7 +743,13 @@ async function loadKey(opts) {
764
743
  const useSetsid = process.platform !== "win32" && hasBin("setsid");
765
744
  code = await runInherit(useSetsid ? ["setsid", "ssh-add", opts.keyPath] : ["ssh-add", opts.keyPath], env, true);
766
745
  if (code === 0) return { loaded: true, via: "askpass" };
767
- if (await verifyKey(opts)) {
746
+ let preverified = false;
747
+ try {
748
+ preverified = await verifyKey(opts);
749
+ } catch {
750
+ preverified = false;
751
+ }
752
+ if (preverified) {
768
753
  return {
769
754
  loaded: true,
770
755
  via: "keygen-verify",
@@ -800,7 +785,8 @@ async function removeKey(keyPath) {
800
785
  return code === 0;
801
786
  }
802
787
  async function verifyKey(opts) {
803
- if (!opts.askpassScriptPath || !(opts.socketPath && opts.token)) return false;
788
+ if (!opts.askpassScriptPath) throw new Error("verify: askpass wrapper missing (resolveAskpass failed)");
789
+ if (!opts.socketPath || !opts.token) throw new Error("verify: askpass bridge env missing (GIT_COLABOR_ASKPASS_SOCK/TOKEN)");
804
790
  const env = { ...process.env };
805
791
  env.SSH_ASKPASS = opts.askpassScriptPath;
806
792
  env.SSH_ASKPASS_REQUIRE = "force";
@@ -810,20 +796,21 @@ async function verifyKey(opts) {
810
796
  env.GIT_COLABOR_FINGERPRINT = opts.fingerprint;
811
797
  const verifyQuiet = (args) => new Promise((resolve4) => {
812
798
  const child = child_process.spawn("ssh-keygen", args, { env, stdio: ["ignore", "pipe", "pipe"] });
799
+ let err = "";
800
+ child.stderr.on("data", (d) => err += d.toString("utf8"));
813
801
  const killTimer = setTimeout(() => child.kill("SIGKILL"), 1e4);
814
802
  child.on("error", () => {
815
803
  clearTimeout(killTimer);
816
- resolve4(127);
804
+ resolve4({ code: 127, stderr: "ssh-keygen spawn failed" });
817
805
  });
818
806
  child.on("close", (c) => {
819
807
  clearTimeout(killTimer);
820
- resolve4(c ?? 127);
808
+ resolve4({ code: c ?? 127, stderr: err });
821
809
  });
822
810
  });
823
- const verify = await verifyQuiet(["-y", "-P", "", "-f", opts.keyPath]).then(
824
- (c) => c === 0 ? Promise.resolve(0) : verifyQuiet(["-y", "-f", opts.keyPath])
825
- );
826
- return verify === 0;
811
+ const r = await verifyQuiet(["-y", "-f", opts.keyPath]);
812
+ if (r.code === 0) return true;
813
+ throw new Error(`verify failed (exit ${r.code}): ${r.stderr.trim().split("\n")[0].slice(0, 160)}`);
827
814
  }
828
815
  var init_agent = __esm({
829
816
  "src/core/identity/agent.ts"() {
@@ -1119,10 +1106,6 @@ async function applyResolvedIdentity(args) {
1119
1106
  if (binding?.pushKey) {
1120
1107
  agent = { inAgent: await keyInAgent(binding.pushKey.fingerprint) };
1121
1108
  }
1122
- if (scope === "local") {
1123
- const tl = await safeTopLevel2(opts.cwd);
1124
- if (tl) await clearStandingDown(tl);
1125
- }
1126
1109
  await appendAudit({
1127
1110
  action: "identity.use",
1128
1111
  source: opts.source,
@@ -1766,10 +1749,6 @@ async function logoutIdentity(opts) {
1766
1749
  await clearTemplate2(opts.cwd).catch(() => {
1767
1750
  });
1768
1751
  }
1769
- if (cleared.identityLayer || cleared.sshCommand || cleared.signing) {
1770
- const tl = await safeTopLevel3(opts.cwd);
1771
- if (tl) await markStandingDown(tl);
1772
- }
1773
1752
  await appendAudit({
1774
1753
  action: "identity.logout",
1775
1754
  source: opts.source,
@@ -1998,8 +1977,15 @@ async function agentKey(p, ctx) {
1998
1977
  }
1999
1978
  const askpassScriptPath = ctx.askpassScriptPath ? await (await Promise.resolve().then(() => (init_apply(), apply_exports))).ensureAskpassWrapper(ctx.askpassScriptPath) : void 0;
2000
1979
  if (verify) {
2001
- const verified = await verifyKey({ keyPath, fingerprint, askpassScriptPath, socketPath: ctx.socketPath, token: ctx.token });
2002
- return ok({ verified, inAgent: await keyInAgent(fingerprint) });
1980
+ try {
1981
+ const verified = await verifyKey({ keyPath, fingerprint, askpassScriptPath, socketPath: ctx.socketPath, token: ctx.token });
1982
+ return ok({ verified, inAgent: await keyInAgent(fingerprint) });
1983
+ } catch (e) {
1984
+ return ok(
1985
+ { verified: false, inAgent: await keyInAgent(fingerprint) },
1986
+ [{ code: "verify-error", message: e instanceof Error ? e.message : String(e) }]
1987
+ );
1988
+ }
2003
1989
  }
2004
1990
  const loaded = await loadKey({ keyPath, fingerprint, askpassScriptPath, socketPath: ctx.socketPath, token: ctx.token, useAppleKeychain: true });
2005
1991
  if (loaded.loaded) {
@@ -2268,10 +2254,6 @@ async function unsetConfigForIdentity(p, ctx) {
2268
2254
  { name: identity.name, email: identity.email, pushKeyPath: binding.pushKey?.path, signKey: binding.signKey },
2269
2255
  { cwd: ctx.cwd, scope: scope === "global" ? "global" : "local" }
2270
2256
  );
2271
- if (scope !== "global" && (cleared.identityLayer || cleared.sshCommand || cleared.signing)) {
2272
- const tl = await (await Promise.resolve().then(() => (init_rev(), rev_exports))).topLevel(ctx.cwd).catch(() => void 0);
2273
- if (tl) await markStandingDown(tl);
2274
- }
2275
2257
  await appendAudit({
2276
2258
  action: "identity.logout",
2277
2259
  source: process.env.GIT_COLABOR_SOURCE === "ext" ? "ext" : "cli",
@@ -2364,9 +2346,6 @@ async function status(ctx) {
2364
2346
  // which identity each git-config SCOPE names (repo-local / global) —
2365
2347
  // drives the "found in repo config" / "found in git global config" rows
2366
2348
  configIdentities,
2367
- // the user stripped this repo's config and auto-apply stands down here
2368
- // until an explicit local use (see map.ts standingDown)
2369
- standingDown: rs.repo ? await isStandingDown(rs.repo) : false,
2370
2349
  selected: rs.selected,
2371
2350
  available: rs.available
2372
2351
  });
package/dist/index.cjs CHANGED
@@ -795,8 +795,7 @@ async function readMap() {
795
795
  // any v1 shape on disk folds into the v2 list above
796
796
  identities,
797
797
  ...defaultIdentity ? { defaultIdentity } : {},
798
- ...parsed.hidden ? { hidden: parsed.hidden } : {},
799
- ...parsed.standingDown ? { standingDown: parsed.standingDown } : {}
798
+ ...parsed.hidden ? { hidden: parsed.hidden } : {}
800
799
  };
801
800
  if (JSON.stringify(parsed) !== JSON.stringify(migrated)) {
802
801
  await writeMap(migrated);
@@ -871,23 +870,6 @@ async function hideIdentityEmail(email) {
871
870
  map.hidden = { ...map.hidden, [norm(email)]: true };
872
871
  await writeMap(map);
873
872
  }
874
- async function markStandingDown(root) {
875
- const map = await readMap();
876
- const roots = new Set(map.standingDown ?? []);
877
- roots.add(root);
878
- map.standingDown = [...roots];
879
- await writeMap(map);
880
- }
881
- async function clearStandingDown(root) {
882
- const map = await readMap();
883
- if (!map.standingDown?.includes(root)) return;
884
- map.standingDown = map.standingDown.filter((r) => r !== root);
885
- await writeMap(map);
886
- }
887
- async function isStandingDown(root) {
888
- const map = await readMap();
889
- return (map.standingDown ?? []).includes(root);
890
- }
891
873
  async function unhideIdentityEmail(email) {
892
874
  const map = await readMap();
893
875
  const key = norm(email);
@@ -1062,7 +1044,13 @@ async function loadKey(opts) {
1062
1044
  const useSetsid = process.platform !== "win32" && hasBin("setsid");
1063
1045
  code = await runInherit(useSetsid ? ["setsid", "ssh-add", opts.keyPath] : ["ssh-add", opts.keyPath], env, true);
1064
1046
  if (code === 0) return { loaded: true, via: "askpass" };
1065
- if (await verifyKey(opts)) {
1047
+ let preverified = false;
1048
+ try {
1049
+ preverified = await verifyKey(opts);
1050
+ } catch {
1051
+ preverified = false;
1052
+ }
1053
+ if (preverified) {
1066
1054
  return {
1067
1055
  loaded: true,
1068
1056
  via: "keygen-verify",
@@ -1098,7 +1086,8 @@ async function removeKey(keyPath) {
1098
1086
  return code === 0;
1099
1087
  }
1100
1088
  async function verifyKey(opts) {
1101
- if (!opts.askpassScriptPath || !(opts.socketPath && opts.token)) return false;
1089
+ if (!opts.askpassScriptPath) throw new Error("verify: askpass wrapper missing (resolveAskpass failed)");
1090
+ if (!opts.socketPath || !opts.token) throw new Error("verify: askpass bridge env missing (GIT_COLABOR_ASKPASS_SOCK/TOKEN)");
1102
1091
  const env = { ...process.env };
1103
1092
  env.SSH_ASKPASS = opts.askpassScriptPath;
1104
1093
  env.SSH_ASKPASS_REQUIRE = "force";
@@ -1108,20 +1097,21 @@ async function verifyKey(opts) {
1108
1097
  env.GIT_COLABOR_FINGERPRINT = opts.fingerprint;
1109
1098
  const verifyQuiet = (args) => new Promise((resolve4) => {
1110
1099
  const child = child_process.spawn("ssh-keygen", args, { env, stdio: ["ignore", "pipe", "pipe"] });
1100
+ let err = "";
1101
+ child.stderr.on("data", (d) => err += d.toString("utf8"));
1111
1102
  const killTimer = setTimeout(() => child.kill("SIGKILL"), 1e4);
1112
1103
  child.on("error", () => {
1113
1104
  clearTimeout(killTimer);
1114
- resolve4(127);
1105
+ resolve4({ code: 127, stderr: "ssh-keygen spawn failed" });
1115
1106
  });
1116
1107
  child.on("close", (c) => {
1117
1108
  clearTimeout(killTimer);
1118
- resolve4(c ?? 127);
1109
+ resolve4({ code: c ?? 127, stderr: err });
1119
1110
  });
1120
1111
  });
1121
- const verify = await verifyQuiet(["-y", "-P", "", "-f", opts.keyPath]).then(
1122
- (c) => c === 0 ? Promise.resolve(0) : verifyQuiet(["-y", "-f", opts.keyPath])
1123
- );
1124
- return verify === 0;
1112
+ const r = await verifyQuiet(["-y", "-f", opts.keyPath]);
1113
+ if (r.code === 0) return true;
1114
+ throw new Error(`verify failed (exit ${r.code}): ${r.stderr.trim().split("\n")[0].slice(0, 160)}`);
1125
1115
  }
1126
1116
 
1127
1117
  // src/core/identity/apply.ts
@@ -1386,10 +1376,6 @@ async function applyResolvedIdentity(args) {
1386
1376
  if (binding?.pushKey) {
1387
1377
  agent = { inAgent: await keyInAgent(binding.pushKey.fingerprint) };
1388
1378
  }
1389
- if (scope === "local") {
1390
- const tl = await safeTopLevel2(opts.cwd);
1391
- if (tl) await clearStandingDown(tl);
1392
- }
1393
1379
  await appendAudit({
1394
1380
  action: "identity.use",
1395
1381
  source: opts.source,
@@ -1573,10 +1559,6 @@ async function logoutIdentity(opts) {
1573
1559
  await clearTemplate2(opts.cwd).catch(() => {
1574
1560
  });
1575
1561
  }
1576
- if (cleared.identityLayer || cleared.sshCommand || cleared.signing) {
1577
- const tl = await safeTopLevel3(opts.cwd);
1578
- if (tl) await markStandingDown(tl);
1579
- }
1580
1562
  await appendAudit({
1581
1563
  action: "identity.logout",
1582
1564
  source: opts.source,
@@ -1668,7 +1650,6 @@ exports.auditLogPath = auditLogPath;
1668
1650
  exports.captureBackupIfFirstTouch = captureBackupIfFirstTouch;
1669
1651
  exports.clearIdentityConfigLayer = clearIdentityConfigLayer;
1670
1652
  exports.clearSelected = clearSelected;
1671
- exports.clearStandingDown = clearStandingDown;
1672
1653
  exports.clearTemplate = clearTemplate;
1673
1654
  exports.cliSessionId = cliSessionId;
1674
1655
  exports.createLogger = createLogger;
@@ -1703,7 +1684,6 @@ exports.insideWorkTree = insideWorkTree;
1703
1684
  exports.isEncrypted = isEncrypted;
1704
1685
  exports.isRepo = isRepo;
1705
1686
  exports.isStale = isStale;
1706
- exports.isStandingDown = isStandingDown;
1707
1687
  exports.keyFileName = keyFileName;
1708
1688
  exports.keyFilePath = keyFilePath;
1709
1689
  exports.keyInAgent = keyInAgent;
@@ -1715,7 +1695,6 @@ exports.listIdentities = listIdentities;
1715
1695
  exports.loadKey = loadKey;
1716
1696
  exports.logoutIdentity = logoutIdentity;
1717
1697
  exports.mapPath = mapPath;
1718
- exports.markStandingDown = markStandingDown;
1719
1698
  exports.nowHeldBy = nowHeldBy;
1720
1699
  exports.printTrailers = printTrailers;
1721
1700
  exports.readAudit = readAudit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-colabor",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Git co-author + multi-identity + SSH key management CLI",
5
5
  "repository": {
6
6
  "type": "git",