v3 new release (#87)

add token
This commit is contained in:
github-actions[bot]
2022-07-25 13:23:27 -04:00
committed by GitHub
parent e4f3964f67
commit 84b304dfb7
31 changed files with 1057 additions and 2 deletions

21
node_modules/@octokit/auth-action/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2019 Octokit contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

179
node_modules/@octokit/auth-action/README.md generated vendored Normal file
View File

@ -0,0 +1,179 @@
# auth-action.js
> GitHub API token authentication for GitHub Actions
[![@latest](https://img.shields.io/npm/v/@octokit/auth-action.svg)](https://www.npmjs.com/package/@octokit/auth-action)
[![Build Status](https://github.com/octokit/auth-action.js/workflows/Test/badge.svg)](https://github.com/octokit/auth-action.js/actions?query=workflow%3ATest)
`@octokit/auth-action` is one of [GitHubs authentication strategies](https://github.com/octokit/auth.js).
It does not require any configuration, but instead reads [the `GITHUB_TOKEN` environment variable](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret) that is provided to GitHub Actions.
<!-- toc -->
- [Usage](#usage)
- [`createActionAuth()`](#createactionauth)
- [`auth()`](#auth)
- [Authentication object](#authentication-object)
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
- [Find more information](#find-more-information)
- [License](#license)
<!-- tocstop -->
## Usage
Install with <code>npm install @octokit/auth-action</code>
```js
const { createActionAuth } = require("@octokit/auth-action");
// or: import { createActionAuth } from "@octokit/auth-action";
const auth = createActionAuth();
const authentication = await auth();
// {
// type: 'token',
// token: 'v1.1234567890abcdef1234567890abcdef12345678',
// tokenType: 'oauth'
// }
```
## `createActionAuth()`
The `createActionAuth()` method has no options.
It expects the `GITHUB_TOKEN` variable to be set which is provided to GitHub Actions, but [has to be configured explicitly](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token).
`GITHUB_TOKEN` can be passed as environment variable using [`env:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#env)
```yml
steps:
- name: My action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
or using [`with:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith)
```yml
steps:
- name: My action
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
or named `token` using [`with:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith)
```yml
steps:
- name: My action
with:
token: ${{ secrets.GITHUB_TOKEN }}
```
`GITHUB_TOKEN` can be set to any of the repository's secret, e.g. if you want to use a personal access token.
```yml
steps:
- name: My first action
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
```
`createActionAuth()` is also checking for the `GITHUB_ACTION` variable to be present to make sure that it runs within a GitHub Action.
If `GITHUB_ACTION` or neither `GITHUB_TOKEN`, `INPUT_GITHUB_TOKEN` or `INPUT_TOKEN` are set an error is thrown.
## `auth()`
The `auth()` method has no options. It returns a promise which resolves with the the authentication object.
## Authentication object
<table width="100%">
<thead align=left>
<tr>
<th width=150>
name
</th>
<th width=70>
type
</th>
<th>
description
</th>
</tr>
</thead>
<tbody align=left valign=top>
<tr>
<th>
<code>type</code>
</th>
<th>
<code>string</code>
</th>
<td>
<code>"token"</code>
</td>
</tr>
<tr>
<th>
<code>token</code>
</th>
<th>
<code>string</code>
</th>
<td>
The provided token.
</td>
</tr>
<tr>
<th>
<code>tokenType</code>
</th>
<th>
<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)
</td>
</tr>
</tbody>
</table>
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
`auth.hook()` hooks directly into the request life cycle. It authenticates the request using the provided token.
The `request` option is an instance of [`@octokit/request`](https://github.com/octokit/request.js#readme). The `route`/`options` parameters are the same as for the [`request()` method](https://github.com/octokit/request.js#request).
`auth.hook()` can be called directly to send an authenticated request
```js
const { data: authorizations } = await auth.hook(
request,
"GET /authorizations"
);
```
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
```js
const requestWithAuth = request.defaults({
request: {
hook: auth.hook,
},
});
const { data: authorizations } = await requestWithAuth("GET /authorizations");
```
## Find more information
`auth()` does not send any requests, it only retrieves the token from the environment variable and transforms the provided token string into an authentication object.
The `GITHUB_TOKEN` provided to GitHub Actions is an installation token with all permissions provided. You can use it for `git` commands, too. Learn more about the differences in token authentication at [@octokit/auth-action](https://github.com/octokit/auth-action.js#find-more-information).
## License
[MIT](LICENSE)

27
node_modules/@octokit/auth-action/dist-node/index.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var authToken = require('@octokit/auth-token');
const createActionAuth = function createActionAuth() {
if (!process.env.GITHUB_ACTION) {
throw new Error("[@octokit/auth-action] `GITHUB_ACTION` environment variable is not set. @octokit/auth-action is meant to be used in GitHub Actions only.");
}
const definitions = [process.env.GITHUB_TOKEN, process.env.INPUT_GITHUB_TOKEN, process.env.INPUT_TOKEN].filter(Boolean);
if (definitions.length === 0) {
throw new Error("[@octokit/auth-action] `GITHUB_TOKEN` variable is not set. It must be set on either `env:` or `with:`. See https://github.com/octokit/auth-action.js#createactionauth");
}
if (definitions.length > 1) {
throw new Error("[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth");
}
const token = definitions.pop();
return authToken.createTokenAuth(token);
};
exports.createActionAuth = createActionAuth;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../dist-src/index.js"],"sourcesContent":["import { createTokenAuth } from \"@octokit/auth-token\";\nexport const createActionAuth = function createActionAuth() {\n if (!process.env.GITHUB_ACTION) {\n throw new Error(\"[@octokit/auth-action] `GITHUB_ACTION` environment variable is not set. @octokit/auth-action is meant to be used in GitHub Actions only.\");\n }\n const definitions = [\n process.env.GITHUB_TOKEN,\n process.env.INPUT_GITHUB_TOKEN,\n process.env.INPUT_TOKEN,\n ].filter(Boolean);\n if (definitions.length === 0) {\n throw new Error(\"[@octokit/auth-action] `GITHUB_TOKEN` variable is not set. It must be set on either `env:` or `with:`. See https://github.com/octokit/auth-action.js#createactionauth\");\n }\n if (definitions.length > 1) {\n throw new Error(\"[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth\");\n }\n const token = definitions.pop();\n return createTokenAuth(token);\n};\n"],"names":["createActionAuth","process","env","GITHUB_ACTION","Error","definitions","GITHUB_TOKEN","INPUT_GITHUB_TOKEN","INPUT_TOKEN","filter","Boolean","length","token","pop","createTokenAuth"],"mappings":";;;;;;MACaA,gBAAgB,GAAG,SAASA,gBAAT,GAA4B;AACxD,MAAI,CAACC,OAAO,CAACC,GAAR,CAAYC,aAAjB,EAAgC;AAC5B,UAAM,IAAIC,KAAJ,CAAU,0IAAV,CAAN;AACH;;AACD,QAAMC,WAAW,GAAG,CAChBJ,OAAO,CAACC,GAAR,CAAYI,YADI,EAEhBL,OAAO,CAACC,GAAR,CAAYK,kBAFI,EAGhBN,OAAO,CAACC,GAAR,CAAYM,WAHI,EAIlBC,MAJkB,CAIXC,OAJW,CAApB;;AAKA,MAAIL,WAAW,CAACM,MAAZ,KAAuB,CAA3B,EAA8B;AAC1B,UAAM,IAAIP,KAAJ,CAAU,uKAAV,CAAN;AACH;;AACD,MAAIC,WAAW,CAACM,MAAZ,GAAqB,CAAzB,EAA4B;AACxB,UAAM,IAAIP,KAAJ,CAAU,4MAAV,CAAN;AACH;;AACD,QAAMQ,KAAK,GAAGP,WAAW,CAACQ,GAAZ,EAAd;AACA,SAAOC,yBAAe,CAACF,KAAD,CAAtB;AACH;;;;"}

19
node_modules/@octokit/auth-action/dist-src/index.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
import { createTokenAuth } from "@octokit/auth-token";
export const createActionAuth = function createActionAuth() {
if (!process.env.GITHUB_ACTION) {
throw new Error("[@octokit/auth-action] `GITHUB_ACTION` environment variable is not set. @octokit/auth-action is meant to be used in GitHub Actions only.");
}
const definitions = [
process.env.GITHUB_TOKEN,
process.env.INPUT_GITHUB_TOKEN,
process.env.INPUT_TOKEN,
].filter(Boolean);
if (definitions.length === 0) {
throw new Error("[@octokit/auth-action] `GITHUB_TOKEN` variable is not set. It must be set on either `env:` or `with:`. See https://github.com/octokit/auth-action.js#createactionauth");
}
if (definitions.length > 1) {
throw new Error("[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth");
}
const token = definitions.pop();
return createTokenAuth(token);
};

View File

@ -0,0 +1,10 @@
import { Types as AuthTokenTypes } from "@octokit/auth-token";
import { StrategyInterface } from "@octokit/types";
export declare type Types = {
StrategyOptions: never;
AuthOptions: never;
Authentication: AuthTokenTypes["Authentication"];
};
export declare const createActionAuth: StrategyInterface<[
], [
], Types["Authentication"]>;

46
node_modules/@octokit/auth-action/package.json generated vendored Normal file
View File

@ -0,0 +1,46 @@
{
"name": "@octokit/auth-action",
"description": "GitHub API token authentication for GitHub Actions",
"version": "2.0.0",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"github",
"octokit",
"authentication",
"github-action",
"api"
],
"repository": "github:octokit/auth-action.js",
"dependencies": {
"@octokit/auth-token": "^3.0.0",
"@octokit/types": "^6.0.3"
},
"devDependencies": {
"@octokit/request": "^6.0.0",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^27.0.0",
"fetch-mock": "^9.0.0",
"jest": "^27.0.0",
"prettier": "2.7.1",
"ts-jest": "^27.0.0-next.12",
"typescript": "^4.0.2"
},
"engines": {
"node": ">= 14"
},
"publishConfig": {
"access": "public"
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js"
}