From d1a6a78d7d360e3f80d69829a4f01654e64b462a Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Mon, 4 Aug 2025 16:46:33 -0700 Subject: [PATCH] fix: Replace newlines in generate jwt (#665) * fix: Replace newlines in generate jwt * cr --- packages/shared/src/github/auth.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/shared/src/github/auth.ts b/packages/shared/src/github/auth.ts index fbea3f8b..6c90812e 100644 --- a/packages/shared/src/github/auth.ts +++ b/packages/shared/src/github/auth.ts @@ -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 { - const jwtToken = generateJWT(appId, privateKey); + const jwtToken = generateJWT( + appId, + replaceNewlinesWithBackslashN(privateKey), + ); const response = await fetch( `https://api.github.com/app/installations/${installationId}/access_tokens`,