( app: GithubAppMetadata, orgOrRepo: Org | Repo = context.repo, )
| 37 | export async function getAuthTokenFor(app: GithubAppMetadata, org: Org): Promise<string>; |
| 38 | export async function getAuthTokenFor(app: GithubAppMetadata, repo?: Repo): Promise<string>; |
| 39 | export async function getAuthTokenFor( |
| 40 | app: GithubAppMetadata, |
| 41 | orgOrRepo: Org | Repo = context.repo, |
| 42 | ): Promise<string> { |
| 43 | const github = await getJwtAuthedAppClient(app); |
| 44 | let id: number; |
| 45 | let org = orgOrRepo as Org; |
| 46 | let repo = orgOrRepo as Repo; |
| 47 | |
| 48 | if (typeof org.org === 'string') { |
| 49 | id = (await github.apps.getOrgInstallation({...org})).data.id; |
| 50 | } else { |
| 51 | id = (await github.apps.getRepoInstallation({...repo})).data.id; |
| 52 | } |
| 53 | |
| 54 | const {token} = ( |
| 55 | await github.rest.apps.createInstallationAccessToken({ |
| 56 | installation_id: id, |
| 57 | }) |
| 58 | ).data; |
| 59 | |
| 60 | return token; |
| 61 | } |
| 62 | |
| 63 | /** Revoke the currently-authenticated installation token for the Octokit instance. */ |
| 64 | export async function revokeActiveInstallationToken(octokitInstallation: Octokit): Promise<void>; |
no test coverage detected