Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -33,11 +33,11 @@ It is useful if you want to support multiple authentication strategies, as it
Browsers
</th><td width=100%>
Load `@octokit/auth-token` directly from [cdn.pika.dev](https://cdn.pika.dev)
Load `@octokit/auth-token` directly from [cdn.skypack.dev](https://cdn.skypack.dev)
```html
<script type="module">
import { createTokenAuth } from "https://cdn.pika.dev/@octokit/auth-token";
import { createTokenAuth } from "https://cdn.skypack.dev/@octokit/auth-token";
</script>
```
@ -58,12 +58,13 @@ const { createTokenAuth } = require("@octokit/auth-token");
</table>
```js
const auth = createTokenAuth("1234567890abcdef1234567890abcdef12345678");
const auth = createTokenAuth("ghp_PersonalAccessToken01245678900000000");
const authentication = await auth();
// {
// type: 'token',
// token: '1234567890abcdef1234567890abcdef12345678',
// token: 'ghp_PersonalAccessToken01245678900000000',
// tokenType: 'oauth'
// }
```
## `createTokenAuth(token) options`
@ -72,17 +73,36 @@ The `createTokenAuth` method accepts a single argument of type string, which is
- [Personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
- [OAuth access token](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
- Installation access token ([GitHub App Installation](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
- [GITHUB_TOKEN provided to GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables)
- Installation access token ([server-to-server](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
- User authentication for installation ([user-to-server](https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps))
Examples
```js
// Personal access token or OAuth access token
createTokenAuth("1234567890abcdef1234567890abcdef12345678");
createTokenAuth("ghp_PersonalAccessToken01245678900000000");
// {
// type: 'token',
// token: 'ghp_PersonalAccessToken01245678900000000',
// tokenType: 'oauth'
// }
// Installation access token or GitHub Action token
createTokenAuth("v1.d3d433526f780fbcc3129004e2731b3904ad0b86");
createTokenAuth("ghs_InstallallationOrActionToken00000000");
// {
// type: 'token',
// token: 'ghs_InstallallationOrActionToken00000000',
// tokenType: 'installation'
// }
// Installation access token or GitHub Action token
createTokenAuth("ghu_InstallationUserToServer000000000000");
// {
// type: 'token',
// token: 'ghu_InstallationUserToServer000000000000',
// tokenType: 'user-to-server'
// }
```
## `auth()`
@ -136,7 +156,7 @@ The `auth()` method has no options. It returns a promise which resolves with the
<code>string</code>
</th>
<td>
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, or <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions)
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions), <code>"app"</code> for a GitHub App JSON Web Token, or <code>"user-to-server"</code> for a user authentication token through an app installation.
</td>
</tr>
</tbody>
@ -180,14 +200,12 @@ Here is a list of things you can do to retrieve further information
Note that this does not work for installations. There is no way to retrieve permissions based on an installation access tokens.
```js
const TOKEN = "1234567890abcdef1234567890abcdef12345678";
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
const auth = createTokenAuth(TOKEN);
const authentication = await auth();
const response = await request("HEAD /", {
headers: authentication.headers,
});
const response = await request("HEAD /");
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
if (scopes.length) {
@ -202,14 +220,12 @@ if (scopes.length) {
### Find out if token is a personal access token or if it belongs to an OAuth app
```js
const TOKEN = "1234567890abcdef1234567890abcdef12345678";
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
const auth = createTokenAuth(TOKEN);
const authentication = await auth();
const response = await request("HEAD /", {
headers: authentication.headers,
});
const response = await request("HEAD /");
const clientId = response.headers["x-oauth-client-id"];
if (clientId) {
@ -226,18 +242,17 @@ if (clientId) {
Note that the `permissions` key is not set when authenticated using an installation access token.
```js
const TOKEN = "1234567890abcdef1234567890abcdef12345678";
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
const auth = createTokenAuth(TOKEN);
const authentication = await auth();
const response = await request("GET /repos/:owner/:repo", {
owner: 'octocat',
repo: 'hello-world'
headers: authentication.headers
const response = await request("GET /repos/{owner}/{repo}", {
owner: "octocat",
repo: "hello-world",
});
console.log(response.data.permissions)
console.log(response.data.permissions);
// {
// admin: true,
// push: true,
@ -252,7 +267,7 @@ Both OAuth and installation access tokens can be used for git operations. Howeve
This example is using the [`execa`](https://github.com/sindresorhus/execa) package to run a `git push` command.
```js
const TOKEN = "1234567890abcdef1234567890abcdef12345678";
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
const auth = createTokenAuth(TOKEN);
const { token, tokenType } = await auth();