-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: decouple github auth from api calls
- Loading branch information
Showing
10 changed files
with
248 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 5 additions & 32 deletions
37
src/application/cloudfunction/github-webhook-entrypoint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Octokit } from "@octokit/rest"; | ||
import { getAppAuthorizedOctokit } from "../infrastructure/github.js"; | ||
import { SecretsClient } from "../infrastructure/secrets.js"; | ||
|
||
export async function createAppAuthorizedOctokit( | ||
secretsClient: SecretsClient | ||
): Promise<Octokit> { | ||
const [githubAppPrivateKey, githubAppClientId, githubAppClientSecret] = | ||
await Promise.all([ | ||
secretsClient.accessSecret("github-app-private-key"), | ||
secretsClient.accessSecret("github-app-client-id"), | ||
secretsClient.accessSecret("github-app-client-secret"), | ||
]); | ||
|
||
return getAppAuthorizedOctokit( | ||
Number(process.env.GITHUB_APP_ID), | ||
githubAppPrivateKey, | ||
githubAppClientId, | ||
githubAppClientSecret | ||
); | ||
} | ||
|
||
export async function createBotAppAuthorizedOctokit( | ||
secretsClient: SecretsClient | ||
): Promise<Octokit> { | ||
const [ | ||
githubBotAppPrivateKey, | ||
githubBotAppClientId, | ||
githubBotAppClientSecret, | ||
] = await Promise.all([ | ||
secretsClient.accessSecret("github-bot-app-private-key"), | ||
secretsClient.accessSecret("github-bot-app-client-id"), | ||
secretsClient.accessSecret("github-bot-app-client-secret"), | ||
]); | ||
return getAppAuthorizedOctokit( | ||
Number(process.env.GITHUB_BOT_APP_ID), | ||
githubBotAppPrivateKey, | ||
githubBotAppClientId, | ||
githubBotAppClientSecret | ||
); | ||
} |
Oops, something went wrong.