github-app-token.ts is a JSR package to create and revoke GitHub App installation access tokens.
import { create, hasExpired, revoke } from "@suzuki-shunsuke/github-app-token";
// Create a GitHub App installation access token.
const token = await githubAppToken.create({
appId: "123456",
privateKey,
owner: "suzuki-shunsuke",
repositories: ["tfcmt"],
permissions: {
issues: "write",
},
});
const octokit = github.getOctokit(token.token);
// Use octokit...
if (!hasExpired(token.expiresAt)) { // Check if the token has expired.
await revoke(token.token); // Revoke the token.
}