universal-github-app-jwt is a JavaScript/TypeScript library designed to securely generate JSON Web Tokens (JWTs) for GitHub Apps. It supports various JavaScript runtimes including Node.js, Deno, and modern web browsers by leveraging the Web Crypto API features or Node's `crypto` module. The current stable version is 2.2.2, with releases occurring as needed for bug fixes and minor features, often multiple times a month, indicating active maintenance and responsiveness. Its key differentiator is its universal compatibility across different environments, simplifying GitHub App authentication by abstracting away the underlying cryptographic implementations. It focuses specifically on generating the app installation token, which is often used in conjunction with other Octokit libraries like `@octokit/auth-app.js` for complete GitHub App authentication flows.
npm install universal-github-app-jwtVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to generate a GitHub App JWT using an application ID and private key, then using it to authenticate an `@octokit/request`.
Ensure your private key is in PKCS#8 format. If generated via `ssh-keygen`, convert it using `ssh-keygen -p -m PKCS8 -f app-private-key.pem`. When setting it as an environment variable, ensure line breaks are preserved or correctly escaped if in a single line (though direct file reading is safer).
For new applications or those targeting `github.com` or modern GHES (3.14+), prioritize using the GitHub App's Client ID for the `options.id` parameter.
If encountering crypto-related errors in Bun, upgrade to `universal-github-app-jwt@2.2.1` or newer. For other runtimes, ensure Web Crypto API or Node.js `crypto` module is available and properly configured.
Verify that your private key starts with `-----BEGIN PRIVATE KEY-----` and ends with `-----END PRIVATE KEY-----`. Ensure all line breaks are preserved exactly as in the `.pem` file. If using an environment variable, ensure proper escaping of newlines or read from a file directly. Convert the key to PKCS#8 if necessary (e.g., `ssh-keygen -p -m PKCS8 -f original-key.pem > new-pkcs8-key.pem`).
Use the correct ESM default import: `import githubAppJwt from 'universal-github-app-jwt';`. If you must use CommonJS, ensure you access the default export: `const githubAppJwt = require('universal-github-app-jwt').default;`.Ensure you are running in a modern browser with Web Crypto API support, a recent Node.js version (15.0.0+ for `crypto.subtle`), Deno, or Bun (>=2.2.1 for specific fixes). If in a browser, ensure it's not an older or highly restricted environment. No polyfills are officially supported by this library.
No dependency data recorded yet.