fix: Replace newlines in generate jwt (#665)

* fix: Replace newlines in generate jwt

* cr
This commit is contained in:
Brace Sproul 2025-08-04 16:46:33 -07:00 • committed by GitHub
parent 1eb315eed9
commit d1a6a78d7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,8 @@
import { generateJWT } from "../jwt.js";
const replaceNewlinesWithBackslashN = (str: string) =>
str.replace(/\n/g, "\\n");
/**
* Gets an installation access token for a GitHub App installation
*/
@ -8,7 +11,10 @@ export async function getInstallationToken(
appId: string,
privateKey: string,
): Promise<string> {
const jwtToken = generateJWT(appId, privateKey);
const jwtToken = generateJWT(
appId,
replaceNewlinesWithBackslashN(privateKey),
);
const response = await fetch(
`https://api.github.com/app/installations/${installationId}/access_tokens`,