Drop installation ID

This commit is contained in:
Will Hunt 2021-11-29 16:49:49 +00:00
parent fbfadeae1c
commit 2f994fbc81
4 changed files with 14 additions and 7 deletions

View File

@ -9,9 +9,6 @@ bridge:
port: 9993
bindAddress: 127.0.0.1
github:
# (Optional) Configure this to enable GitHub support
#
installationId: 6854059
auth:
id: 123
privateKeyFile: github-key.pem

View File

@ -20,7 +20,6 @@ export interface BridgeConfigGitHub {
// eslint-disable-next-line camelcase
redirect_uri: string;
};
installationId: number|string;
}
export interface GitLabInstance {

View File

@ -35,7 +35,6 @@ export const DefaultConfig = new BridgeConfig({
avatar: "mxc://half-shot.uk/2876e89ccade4cb615e210c458e2a7a6883fe17d"
},
github: {
installationId: 6854059,
auth: {
id: 123,
privateKeyFile: "github-key.pem",

View File

@ -33,7 +33,6 @@ export class GithubInstance {
const auth = {
appId: parseInt(this.config.auth.id as string, 10),
privateKey: await fs.readFile(this.config.auth.privateKeyFile, "utf-8"),
installationId: parseInt(this.config.installationId as string, 10),
};
this.internalOctokit = new Octokit({
@ -43,10 +42,23 @@ export class GithubInstance {
});
try {
const installation = (await this.octokit.apps.listInstallations()).data[0];
if (!installation) {
throw Error("App has no installations, cannot continue. Please ensure you've installed the app somewhere (https://github.com/settings/installations)");
}
log.info(`Using installation ${installation.id} (${installation.app_slug})`)
this.internalOctokit = new Octokit({
authStrategy: createAppAuth,
auth: {
...auth,
installationId: installation.id,
},
userAgent: USER_AGENT,
});
await this.octokit.rateLimit.get();
log.info("Auth check success");
} catch (ex) {
log.info("Auth check failed:", ex);
log.warn("Auth check failed:", ex);
throw Error("Attempting to verify GitHub authentication configration failed");
}
}