Files
clawhub/scripts/skills-sh-catalog/github-owner-resolution.ts
T
Patrick Erichsen b34a0d69ff feat: add dark skills.sh catalog control plane (#3211)
Ships the fail-closed skills.sh catalog control plane validated by the bounded 500-row permanent Test gate. No production ingestion, schedule, visibility, or bulk scanning is enabled.
2026-07-21 20:50:07 -07:00

21 lines
928 B
TypeScript

import { spawnSync } from "node:child_process";
export function resolveAuthenticatedGitHubOwner(ownerInput: string) {
const owner = ownerInput.trim().toLowerCase();
if (!owner) throw new Error("GitHub owner is required");
const result = spawnSync("gh", ["api", `users/${owner}`, "--jq", "{id,login}"], {
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
});
if (result.status !== 0) {
throw new Error(`Authenticated GitHub owner lookup failed: ${owner}`);
}
const payload = JSON.parse(result.stdout) as { id?: unknown; login?: unknown };
const id = typeof payload.id === "number" ? payload.id : Number.NaN;
const login = typeof payload.login === "string" ? payload.login.trim().toLowerCase() : "";
if (!Number.isSafeInteger(id) || id <= 0 || login !== owner) {
throw new Error(`Authenticated GitHub owner lookup returned invalid identity: ${owner}`);
}
return { owner, id, login };
}