mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-21 00:21:27 +00:00
Write the private key as base64 to avoid multiline quoting issues. Add getGitHubAppPrivateKey() that accepts both raw PEM and base64. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
770 B
TypeScript
27 lines
770 B
TypeScript
import { GitHub, generateState } from "arctic";
|
|
|
|
export { generateState };
|
|
|
|
export function getGitHubOAuth() {
|
|
const clientId = process.env.GITHUB_APP_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 !!process.env.GITHUB_APP_CLIENT_ID;
|
|
}
|
|
|
|
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");
|
|
}
|