mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-06 08:18:58 +00:00
Non-secret config (app_id, client_id) now lives in [git] section of ~/.arc/arc.toml. Secrets remain in .env. Setup callback writes non-secrets to TOML and secrets to .env. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
817 B
TypeScript
28 lines
817 B
TypeScript
import { GitHub, generateState } from "arctic";
|
|
import { getAppConfig } from "./config.server";
|
|
|
|
export { generateState };
|
|
|
|
export function getGitHubOAuth() {
|
|
const clientId = getAppConfig().git.client_id;
|
|
const clientSecret = process.env.GITHUB_APP_CLIENT_SECRET;
|
|
if (!clientId || !clientSecret) {
|
|
throw new Error("GitHub App is not configured");
|
|
}
|
|
return new GitHub(clientId, clientSecret, null);
|
|
}
|
|
|
|
export function isGitHubAppConfigured(): boolean {
|
|
return getAppConfig().git.client_id !== null;
|
|
}
|
|
|
|
export function getGitHubAppPrivateKey(): string {
|
|
const raw = process.env.GITHUB_APP_PRIVATE_KEY;
|
|
if (!raw) {
|
|
throw new Error("GITHUB_APP_PRIVATE_KEY is not configured");
|
|
}
|
|
if (raw.startsWith("-----BEGIN")) {
|
|
return raw;
|
|
}
|
|
return Buffer.from(raw, "base64").toString("utf-8");
|
|
}
|