{"id":15018131,"url":"https://github.com/probot/octokit-auth-probot","last_synced_at":"2025-04-07T11:11:20.080Z","repository":{"id":37794401,"uuid":"305920428","full_name":"probot/octokit-auth-probot","owner":"probot","description":"🛠️ Octokit authentication strategy for token, app (JWT), and event-based installation authentication","archived":false,"fork":false,"pushed_at":"2025-03-25T14:08:49.000Z","size":1716,"stargazers_count":13,"open_issues_count":5,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T10:03:33.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/probot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-21T05:44:13.000Z","updated_at":"2025-03-03T13:56:35.000Z","dependencies_parsed_at":"2024-02-25T16:30:35.700Z","dependency_job_id":"7c3bf50c-2257-4219-b505-c10c064d498c","html_url":"https://github.com/probot/octokit-auth-probot","commit_stats":{"total_commits":247,"total_committers":6,"mean_commits":"41.166666666666664","dds":"0.15384615384615385","last_synced_commit":"95349b20c9f59ba68e84370e8c045bc7b9d2dd66"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probot%2Foctokit-auth-probot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probot%2Foctokit-auth-probot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probot%2Foctokit-auth-probot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probot%2Foctokit-auth-probot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/probot","download_url":"https://codeload.github.com/probot/octokit-auth-probot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640465,"owners_count":20971557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T19:51:29.422Z","updated_at":"2025-04-07T11:11:20.047Z","avatar_url":"https://github.com/probot.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# octokit-auth-probot\n\n\u003e Octokit authentication strategy that supports token, app (JWT), and event-based installation authentication\n\n[![@latest](https://img.shields.io/npm/v/octokit-auth-probot.svg)](https://www.npmjs.com/package/octokit-auth-probot)\n[![Build Status](https://github.com/probot/octokit-auth-probot/workflows/Test/badge.svg)](https://github.com/probot/octokit-auth-probot/actions?query=workflow%3ATest)\n\n`octokit-auth-probot` combines the authentication strategies:\n\n1. [`@octokit/auth-app`](https://github.com/octokit/auth-app.js#readme)\n2. [`@octokit/auth-token`](https://github.com/octokit/auth-token.js#readme)\n3. [`@octokit/auth-unauthenticated`](https://github.com/octokit/auth-unauthenticated.js#readme)\n\nIt adds a new authentication type: `\"event-octokit\"`, which allows to retrieve an Octokit instance which is correctly authenticated based on the Octokit constructors authentication (`app` or `token`) as well as the event, which either results in an installation access token authentication or, in case the event implies that the installation's access has been revoked, in an unauthenticated Octokit instance.\n\n`octokit-auth-probot` is not meant to be used by itself, but in conjuction with [`@octokit/core`](https://github.com/octokit/core.js#readme) or a compatible library.\n\n## Usage\n\n\u003ctable\u003e\n\u003ctbody valign=top align=left\u003e\n\u003ctr\u003e\u003cth\u003e\nBrowsers\n\u003c/th\u003e\u003ctd width=100%\u003e\n\nLoad `octokit-auth-probot` directly from [esm.sh](https://esm.sh)\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { Octokit } from \"https://esm.sh/@octokit/core\";\n  import { createProbotAuth } from \"https://esm.sh/octokit-auth-probot\";\n\u003c/script\u003e\n```\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e\nNode\n\u003c/th\u003e\u003ctd\u003e\n\nInstall with \u003ccode\u003enpm install octokit-auth-probot\u003c/code\u003e\n\n```js\nconst { Octokit } = require(\"@octokit/core\");\nconst { createProbotAuth } = require(\"octokit-auth-probot\");\n// or:\n// import { Octokit } from \"@octokit/core\";\n// import { createProbotAuth } from \"octokit-auth-probot\";\n```\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd colspan=2\u003e\n\n⚠️ For usage in browsers: The private keys provided by GitHub are in `PKCS#1` format, but the WebCrypto API only supports `PKCS#8`. You need to convert it first:\n\n```shell\nopenssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.key\n```\n\nNo conversion is needed in Node, both `PKCS#1` and `PKCS#8` format will work.\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n```js\nconst { Octokit } = require(\"@octokit/core\");\nconst { createProbotAuth } = require(\"octokit-auth-probot\");\n\nconst ProbotOctokit = Octokit.defaults({\n  authStrategy: createProbotAuth,\n});\n```\n\n### Token authentication\n\n```js\nconst octokit = new ProbotOctokit({\n  auth: {\n    token: \"secret 123\",\n  },\n});\n```\n\n**Note**: when using `octokit.auth({ type: \"installation\", factory })`, `factory(options)` will be called with `options.octokit`, `options.octokitOptions`, plus any other properties that have been passed to `octokit.auth()` besides `type` and `factory`. In all other cases, `octokit.auth()` will resolve with an [`oauth` authentication object](https://github.com/octokit/auth-token.js#authentication-object), no matter the passed options.\n\n### App authentication\n\n```js\nconst octokit = new ProbotOctokit({\n  auth: {\n    appId: 123,\n    privateKey: `----BEGIN RSA PRIVATE KEY----- ...`,\n  },\n});\n```\n\n### Unauthenticated\n\n```js\nconst octokit = new ProbotOctokit();\n```\n\nThis is useful if you need to send a request without access to authentication. Probot's use case here is [Create a GitHub App from a manifest](https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#create-a-github-app-from-a-manifest) (`POST /app-manifests/{code}/conversions`), which is used to register a GitHub app and retrieve the credentials in return.\n\n### Get authenticated octokit instance based on event\n\n```js\nconst eventOctokit = await octokit.auth({\n  type: \"event-octokit\",\n  event: { name: \"push\", payload: { installation: { id: 123 } } }, // event payload\n});\n```\n\n`eventOctokit` is now authenticated in one of three ways:\n\n1. If `octokit` was authenticated using a token, `eventOctokit` is authenticated with the same token. In fact, `eventOctokit` _is_ `octokit`\n2. If `event` name is `installation` and `payload.action` is either `suspend` or `deleted`, then `eventOctokit` is unauthenticated using [`@octokit/auth-unauthenticated`](https://github.com/octokit/auth-unauthenticated.js#readme)\n3. Otherwise `eventOctokit` is authenticated as installation based on `payload.installation.id`\n\n## LICENSE\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobot%2Foctokit-auth-probot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobot%2Foctokit-auth-probot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobot%2Foctokit-auth-probot/lists"}