Get private key from a file path, environment variables, or a
*.pemfile in the current working directory
Finds a private key through various user-(un)specified methods. Order of precedence:
- Explicit file path option
PRIVATE_KEYenvironment variable or explicitenv.PRIVATE_KEYoption. The private key can optionally be base64 encoded.PRIVATE_KEY_PATHenvironment variable or explicitenv.PRIVATE_KEY_PATHoption- Any file w/
.pemextension in current working dir
Supports both PKCS1 (i.e -----BEGIN RSA PRIVATE KEY-----) and PKCS8 (i.e -----BEGIN PRIVATE KEY-----).
| Browsers |
|
|---|---|
| Node |
Install with import { Probot } from "probot";
import { getPrivateKey } from "@probot/get-private-key";Important As we use conditional exports, you will need to adapt your See the TypeScript docs on package.json "exports". |
const probot = new Probot({
appId: 123,
privateKey: getPrivateKey(),
});| name | type | description |
|---|---|---|
options.filepath
|
string |
Pass a path to a const privateKey = getPrivateKey({
filepath: "private-key.pem",
}); |
options.cwd
|
string |
Defaults to const privateKey = getPrivateKey({
cwd: "/app/current",
}); |
options.env
|
object |
Defaults to const privateKey = getPrivateKey({
env: {
PRIVATE_KEY: "-----BEGIN RSA PRIVATE KEY-----\n...",
},
}); |