mirror of
https://github.com/ButlerLogic/action-autotag.git
synced 2025-09-15 01:24:02 +07:00
stripped down
This commit is contained in:
21
node_modules/@octokit/app/LICENSE
generated
vendored
21
node_modules/@octokit/app/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 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.
|
431
node_modules/@octokit/app/README.md
generated
vendored
431
node_modules/@octokit/app/README.md
generated
vendored
@ -1,431 +0,0 @@
|
||||
# app.js
|
||||
|
||||
> GitHub App toolset for Node.js
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/app)
|
||||
[](https://github.com/octokit/app.js/actions?workflow=Test)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [`App.defaults(options)`](#appdefaultsoptions)
|
||||
- [Constructor](#constructor)
|
||||
- [API](#api)
|
||||
- [`app.octokit`](#appoctokit)
|
||||
- [`app.log`](#applog)
|
||||
- [`app.getInstallationOctokit`](#appgetinstallationoctokit)
|
||||
- [`app.eachInstallation`](#appeachinstallation)
|
||||
- [`app.eachRepository`](#appeachrepository)
|
||||
- [`app.webhooks`](#appwebhooks)
|
||||
- [`app.oauth`](#appoauth)
|
||||
- [Middlewares](#middlewares)
|
||||
- [`createNodeMiddleware(app, options)`](#createnodemiddlewareapp-options)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
|
||||
Browsers
|
||||
|
||||
</th><td width=100%>
|
||||
|
||||
`@octokit/app` is not meant for browser usage.
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
|
||||
Node
|
||||
|
||||
</th><td>
|
||||
|
||||
Install with `npm install @octokit/app`
|
||||
|
||||
```js
|
||||
const { App, createNodeMiddleware } = require("@octokit/app");
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const app = new App({
|
||||
appId: 123,
|
||||
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
|
||||
oauth: {
|
||||
clientId: "0123",
|
||||
clientSecret: "0123secret",
|
||||
},
|
||||
webhooks: {
|
||||
secret: "secret",
|
||||
},
|
||||
});
|
||||
|
||||
const { data } = await app.octokit.request("/app");
|
||||
console.log("authenticated as %s", data.name);
|
||||
for await (const { installation } of app.eachInstallation.iterator()) {
|
||||
for await (const { octokit, repository } of app.eachRepository.iterator({
|
||||
installationId: installation.id,
|
||||
})) {
|
||||
await octokit.request("POST /repos/{owner}/{repo}/dispatches", {
|
||||
owner: repository.owner.login,
|
||||
repo: repository.name,
|
||||
event_type: "my_event",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
app.webhooks.on("issues.opened", async ({ octokit, payload }) => {
|
||||
await octokit.request(
|
||||
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
||||
{
|
||||
owner: payload.repository.owner.login,
|
||||
repo: payload.repository.name,
|
||||
issue_number: payload.issue.number,
|
||||
body: "Hello World!",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
app.oauth.on("token", async ({ token, octokit }) => {
|
||||
const { data } = await octokit.request("GET /user");
|
||||
console.log(`Token retrieved for ${data.login}`);
|
||||
});
|
||||
|
||||
require("http").createServer(createNodeMiddleware(app)).listen(3000);
|
||||
// can now receive requests at /api/github/*
|
||||
```
|
||||
|
||||
## `App.defaults(options)`
|
||||
|
||||
Create a new `App` with custom defaults for the [constructor options](#constructor-options)
|
||||
|
||||
```js
|
||||
const MyApp = App.defaults({
|
||||
Octokit: MyOctokit,
|
||||
});
|
||||
const app = new MyApp({ clientId, clientSecret });
|
||||
// app.octokit is now an instance of MyOctokit
|
||||
```
|
||||
|
||||
## Constructor
|
||||
|
||||
<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>appId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>number</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required</strong>. Find the <strong>App ID</strong> on the app’s about page in settings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>privateKey</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required</strong>. Content of the <code>*.pem</code> file you downloaded from the app’s about page. You can generate a new private key if needed.
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="constructor-option-octokit">
|
||||
<th>
|
||||
<code>Octokit</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>Constructor</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
You can pass in your own Octokit constructor with custom defaults and plugins. Note that `authStrategy` will be always be set to `createAppAuth` from [`@octokit/auth-app`](https://github.com/octokit/auth-app.js).
|
||||
|
||||
For usage with enterprise, set `baseUrl` to the hostname + `/api/v3`. Example:
|
||||
|
||||
```js
|
||||
const { Octokit } = require("@octokit/core");
|
||||
new App({
|
||||
appId: 123,
|
||||
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
|
||||
oauth: {
|
||||
clientId: 123,
|
||||
clientSecret: "secret",
|
||||
},
|
||||
webhooks: {
|
||||
secret: "secret",
|
||||
},
|
||||
Octokit: Octokit.defaults({
|
||||
baseUrl: "https://ghe.my-company.com/api/v3",
|
||||
}),
|
||||
});
|
||||
```
|
||||
|
||||
Defaults to [`@octokit/core`](https://github.com/octokit/core.js).
|
||||
|
||||
</td></tr>
|
||||
<tr id="constructor-option-log">
|
||||
<th>
|
||||
<code>log</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>object</code>
|
||||
</th>
|
||||
<td>
|
||||
Used for internal logging. Defaults to <a href="https://developer.mozilla.org/en-US/docs/Web/API/console"><code>console</code></a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>webhooks.secret</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required.</strong> Secret as configured in the GitHub App's settings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>webhooks.transform</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>function</code>
|
||||
</th>
|
||||
<td>
|
||||
Only relevant for `app.webhooks.on`. Transform emitted event before calling handlers. Can be asynchronous.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>oauth.clientId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>number</code>
|
||||
</th>
|
||||
<td>
|
||||
Find the OAuth <strong>Client ID</strong> on the app’s about page in settings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>oauth.clientSecret</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>number</code>
|
||||
</th>
|
||||
<td>
|
||||
Find the OAuth <strong>Client Secret</strong> on the app’s about page in settings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>oauth.allowSignup</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>boolean</code>
|
||||
</th>
|
||||
<td>
|
||||
Sets the default value for <code>app.oauth.getAuthorizationUrl(options)</code>.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## API
|
||||
|
||||
### `app.octokit`
|
||||
|
||||
Octokit instance. Uses the [`Octokit` constructor option](#constructor-option-octokit) if passed.
|
||||
|
||||
### `app.log`
|
||||
|
||||
See https://github.com/octokit/core.js#logging. Customize using the [`log` constructor option](#constructor-option-log).
|
||||
|
||||
### `app.getInstallationOctokit`
|
||||
|
||||
```js
|
||||
const octokit = await app.getInstallationOctokit(123);
|
||||
```
|
||||
|
||||
### `app.eachInstallation`
|
||||
|
||||
```js
|
||||
for await (const { octokit, installation } of app.eachInstallation.iterator()) { /* ... */ }
|
||||
await app.eachInstallation(({ octokit, installation }) => /* ... */)
|
||||
```
|
||||
|
||||
### `app.eachRepository`
|
||||
|
||||
```js
|
||||
for await (const { octokit, repository } of app.eachRepository.iterator()) { /* ... */ }
|
||||
await app.eachRepository(({ octokit, repository }) => /* ... */)
|
||||
```
|
||||
|
||||
Optionally pass installation ID to iterate through all repositories in one installation
|
||||
|
||||
```js
|
||||
for await (const { octokit, repository } of app.eachRepository.iterator({ installationId })) { /* ... */ }
|
||||
await app.eachRepository({ installationId }, ({ octokit, repository }) => /* ... */)
|
||||
```
|
||||
|
||||
### `app.webhooks`
|
||||
|
||||
An [`@octokit/webhooks` instance](https://github.com/octokit/webhooks.js/#readme)
|
||||
|
||||
### `app.oauth`
|
||||
|
||||
An [`@octokit/oauth-app` instance](https://github.com/octokit/oauth-app.js/#readme)
|
||||
|
||||
## Middlewares
|
||||
|
||||
A middleware is a method or set of methods to handle requests for common environments.
|
||||
|
||||
By default, all middlewares expose the following routes
|
||||
|
||||
| Route | Route Description |
|
||||
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `POST /api/github/webhooks` | Endpoint to receive GitHub Webhook Event requests |
|
||||
| `GET /api/github/oauth/login` | Redirects to GitHub's authorization endpoint. Accepts optional `?state` query parameter. |
|
||||
| `GET /api/github/oauth/callback` | The client's redirect endpoint. This is where the `token` event gets triggered |
|
||||
| `POST /api/github/oauth/token` | Exchange an authorization code for an OAuth Access token. If successful, the `token` event gets triggered. |
|
||||
| `GET /api/github/oauth/token` | Check if token is valid. Must authenticate using token in `Authorization` header. Uses GitHub's [`POST /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) endpoint |
|
||||
| `PATCH /api/github/oauth/token` | Resets a token (invalidates current one, returns new token). Must authenticate using token in `Authorization` header. Uses GitHub's [`PATCH /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) endpoint. |
|
||||
| `DELETE /api/github/oauth/token` | Invalidates current token, basically the equivalent of a logout. Must authenticate using token in `Authorization` header. |
|
||||
| `DELETE /api/github/oauth/grant` | Revokes the user's grant, basically the equivalent of an uninstall. must authenticate using token in `Authorization` header. |
|
||||
|
||||
### `createNodeMiddleware(app, options)`
|
||||
|
||||
Middleware for Node's built in http server or [`express`](https://expressjs.com/).
|
||||
|
||||
```js
|
||||
const { App, createNodeMiddleware } = require("@octokit/app");
|
||||
const app = new App({
|
||||
appId: 123,
|
||||
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
|
||||
oauth: {
|
||||
clientId: "0123",
|
||||
clientSecret: "0123secret",
|
||||
},
|
||||
webhooks: {
|
||||
secret: "secret",
|
||||
},
|
||||
});
|
||||
|
||||
const middleware = createNodeMiddleware(app);
|
||||
|
||||
require("http").createServer(middleware).listen(3000);
|
||||
// can now receive user authorization callbacks at /api/github/*
|
||||
```
|
||||
|
||||
<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>app</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>App instance</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required</strong>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.pathPrefix</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
All exposed paths will be prefixed with the provided prefix. Defaults to `"/api/github"`
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>log</code>
|
||||
<em>
|
||||
object
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Used for internal logging. Defaults to [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console) with `debug` and `info` doing nothing.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.onUnhandledRequest</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>function</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
Defaults to
|
||||
|
||||
```js
|
||||
function onUnhandledRequest(request, response) {
|
||||
response.writeHead(400, {
|
||||
"content-type": "application/json",
|
||||
});
|
||||
response.end(
|
||||
JSON.stringify({
|
||||
error: error.message,
|
||||
})
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
292
node_modules/@octokit/app/dist-node/index.js
generated
vendored
292
node_modules/@octokit/app/dist-node/index.js
generated
vendored
@ -1,292 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var core = require('@octokit/core');
|
||||
var authApp = require('@octokit/auth-app');
|
||||
var oauthApp = require('@octokit/oauth-app');
|
||||
var authUnauthenticated = require('@octokit/auth-unauthenticated');
|
||||
var webhooks$1 = require('@octokit/webhooks');
|
||||
var pluginPaginateRest = require('@octokit/plugin-paginate-rest');
|
||||
|
||||
const VERSION = "13.1.2";
|
||||
|
||||
function webhooks(appOctokit, options
|
||||
// Explict return type for better debugability and performance,
|
||||
// see https://github.com/octokit/app.js/pull/201
|
||||
) {
|
||||
return new webhooks$1.Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async event => {
|
||||
if (!("installation" in event.payload) || typeof event.payload.installation !== "object") {
|
||||
const octokit = new appOctokit.constructor({
|
||||
authStrategy: authUnauthenticated.createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`
|
||||
}
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
const installationId = event.payload.installation.id;
|
||||
const octokit = await appOctokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
return new auth.octokit.constructor({
|
||||
...auth.octokitOptions,
|
||||
authStrategy: authApp.createAppAuth,
|
||||
...{
|
||||
auth: {
|
||||
...auth,
|
||||
installationId
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// set `x-github-delivery` header on all requests sent in response to the current
|
||||
// event. This allows GitHub Support to correlate the request with the event.
|
||||
// This is not documented and not considered public API, the header may change.
|
||||
// Once we document this as best practice on https://docs.github.com/en/rest/guides/best-practices-for-integrators
|
||||
// we will make it official
|
||||
/* istanbul ignore next */
|
||||
octokit.hook.before("request", options => {
|
||||
options.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function getInstallationOctokit(app, installationId) {
|
||||
return app.octokit.auth({
|
||||
type: "installation",
|
||||
installationId: installationId,
|
||||
factory(auth) {
|
||||
const options = {
|
||||
...auth.octokitOptions,
|
||||
authStrategy: authApp.createAppAuth,
|
||||
...{
|
||||
auth: {
|
||||
...auth,
|
||||
installationId: installationId
|
||||
}
|
||||
}
|
||||
};
|
||||
return new auth.octokit.constructor(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function eachInstallationFactory(app) {
|
||||
return Object.assign(eachInstallation.bind(null, app), {
|
||||
iterator: eachInstallationIterator.bind(null, app)
|
||||
});
|
||||
}
|
||||
async function eachInstallation(app, callback) {
|
||||
const i = eachInstallationIterator(app)[Symbol.asyncIterator]();
|
||||
let result = await i.next();
|
||||
while (!result.done) {
|
||||
await callback(result.value);
|
||||
result = await i.next();
|
||||
}
|
||||
}
|
||||
function eachInstallationIterator(app) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const iterator = pluginPaginateRest.composePaginateRest.iterator(app.octokit, "GET /app/installations");
|
||||
for await (const {
|
||||
data: installations
|
||||
} of iterator) {
|
||||
for (const installation of installations) {
|
||||
const installationOctokit = await getInstallationOctokit(app, installation.id);
|
||||
yield {
|
||||
octokit: installationOctokit,
|
||||
installation
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function eachRepositoryFactory(app) {
|
||||
return Object.assign(eachRepository.bind(null, app), {
|
||||
iterator: eachRepositoryIterator.bind(null, app)
|
||||
});
|
||||
}
|
||||
async function eachRepository(app, queryOrCallback, callback) {
|
||||
const i = eachRepositoryIterator(app, callback ? queryOrCallback : undefined)[Symbol.asyncIterator]();
|
||||
let result = await i.next();
|
||||
while (!result.done) {
|
||||
if (callback) {
|
||||
await callback(result.value);
|
||||
} else {
|
||||
await queryOrCallback(result.value);
|
||||
}
|
||||
result = await i.next();
|
||||
}
|
||||
}
|
||||
function singleInstallationIterator(app, installationId) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
yield {
|
||||
octokit: await app.getInstallationOctokit(installationId)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function eachRepositoryIterator(app, query) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const iterator = query ? singleInstallationIterator(app, query.installationId) : app.eachInstallation.iterator();
|
||||
for await (const {
|
||||
octokit
|
||||
} of iterator) {
|
||||
const repositoriesIterator = pluginPaginateRest.composePaginateRest.iterator(octokit, "GET /installation/repositories");
|
||||
for await (const {
|
||||
data: repositories
|
||||
} of repositoriesIterator) {
|
||||
for (const repository of repositories) {
|
||||
yield {
|
||||
octokit: octokit,
|
||||
repository
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function onUnhandledRequestDefault(request, response) {
|
||||
response.writeHead(404, {
|
||||
"content-type": "application/json"
|
||||
});
|
||||
response.end(JSON.stringify({
|
||||
error: `Unknown route: ${request.method} ${request.url}`
|
||||
}));
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
function createNodeMiddleware(app, options = {}) {
|
||||
const log = Object.assign({
|
||||
debug: noop,
|
||||
info: noop,
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
}, options.log);
|
||||
const optionsWithDefaults = {
|
||||
onUnhandledRequest: onUnhandledRequestDefault,
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log
|
||||
};
|
||||
const webhooksMiddleware = webhooks$1.createNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log,
|
||||
onUnhandledRequest: optionsWithDefaults.onUnhandledRequest
|
||||
});
|
||||
const oauthMiddleware = oauthApp.createNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth",
|
||||
onUnhandledRequest: optionsWithDefaults.onUnhandledRequest
|
||||
});
|
||||
return middleware.bind(null, optionsWithDefaults, {
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
});
|
||||
}
|
||||
async function middleware(options, {
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
}, request, response, next) {
|
||||
const {
|
||||
pathname
|
||||
} = new URL(request.url, "http://localhost");
|
||||
if (pathname === `${options.pathPrefix}/webhooks`) {
|
||||
return webhooksMiddleware(request, response, next);
|
||||
}
|
||||
if (pathname.startsWith(`${options.pathPrefix}/oauth/`)) {
|
||||
return oauthMiddleware(request, response, next);
|
||||
}
|
||||
const isExpressMiddleware = typeof next === "function";
|
||||
if (isExpressMiddleware) {
|
||||
// @ts-ignore `next` must be a function as we check two lines above
|
||||
return next();
|
||||
}
|
||||
return options.onUnhandledRequest(request, response);
|
||||
}
|
||||
|
||||
class App {
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
constructor(options) {
|
||||
const Octokit = options.Octokit || core.Octokit;
|
||||
const authOptions = Object.assign({
|
||||
appId: options.appId,
|
||||
privateKey: options.privateKey
|
||||
}, options.oauth ? {
|
||||
clientId: options.oauth.clientId,
|
||||
clientSecret: options.oauth.clientSecret
|
||||
} : {});
|
||||
this.octokit = new Octokit({
|
||||
authStrategy: authApp.createAppAuth,
|
||||
auth: authOptions,
|
||||
log: options.log
|
||||
});
|
||||
this.log = Object.assign({
|
||||
debug: () => {},
|
||||
info: () => {},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
}, options.log);
|
||||
// set app.webhooks depending on whether "webhooks" option has been passed
|
||||
if (options.webhooks) {
|
||||
// @ts-expect-error TODO: figure this out
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
} else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
// set app.oauth depending on whether "oauth" option has been passed
|
||||
if (options.oauth) {
|
||||
this.oauth = new oauthApp.OAuthApp({
|
||||
...options.oauth,
|
||||
clientType: "github-app",
|
||||
Octokit
|
||||
});
|
||||
} else {
|
||||
Object.defineProperty(this, "oauth", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] oauth.clientId / oauth.clientSecret options are not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
this.getInstallationOctokit = getInstallationOctokit.bind(null, this);
|
||||
this.eachInstallation = eachInstallationFactory(this);
|
||||
this.eachRepository = eachRepositoryFactory(this);
|
||||
}
|
||||
}
|
||||
App.VERSION = VERSION;
|
||||
|
||||
exports.App = App;
|
||||
exports.createNodeMiddleware = createNodeMiddleware;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/app/dist-node/index.js.map
generated
vendored
1
node_modules/@octokit/app/dist-node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
28
node_modules/@octokit/app/dist-src/each-installation.js
generated
vendored
28
node_modules/@octokit/app/dist-src/each-installation.js
generated
vendored
@ -1,28 +0,0 @@
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { getInstallationOctokit } from "./get-installation-octokit";
|
||||
export function eachInstallationFactory(app) {
|
||||
return Object.assign(eachInstallation.bind(null, app), {
|
||||
iterator: eachInstallationIterator.bind(null, app),
|
||||
});
|
||||
}
|
||||
export async function eachInstallation(app, callback) {
|
||||
const i = eachInstallationIterator(app)[Symbol.asyncIterator]();
|
||||
let result = await i.next();
|
||||
while (!result.done) {
|
||||
await callback(result.value);
|
||||
result = await i.next();
|
||||
}
|
||||
}
|
||||
export function eachInstallationIterator(app) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const iterator = composePaginateRest.iterator(app.octokit, "GET /app/installations");
|
||||
for await (const { data: installations } of iterator) {
|
||||
for (const installation of installations) {
|
||||
const installationOctokit = await getInstallationOctokit(app, installation.id);
|
||||
yield { octokit: installationOctokit, installation };
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
45
node_modules/@octokit/app/dist-src/each-repository.js
generated
vendored
45
node_modules/@octokit/app/dist-src/each-repository.js
generated
vendored
@ -1,45 +0,0 @@
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
export function eachRepositoryFactory(app) {
|
||||
return Object.assign(eachRepository.bind(null, app), {
|
||||
iterator: eachRepositoryIterator.bind(null, app),
|
||||
});
|
||||
}
|
||||
export async function eachRepository(app, queryOrCallback, callback) {
|
||||
const i = eachRepositoryIterator(app, callback ? queryOrCallback : undefined)[Symbol.asyncIterator]();
|
||||
let result = await i.next();
|
||||
while (!result.done) {
|
||||
if (callback) {
|
||||
await callback(result.value);
|
||||
}
|
||||
else {
|
||||
await queryOrCallback(result.value);
|
||||
}
|
||||
result = await i.next();
|
||||
}
|
||||
}
|
||||
function singleInstallationIterator(app, installationId) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
yield {
|
||||
octokit: await app.getInstallationOctokit(installationId),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
export function eachRepositoryIterator(app, query) {
|
||||
return {
|
||||
async *[Symbol.asyncIterator]() {
|
||||
const iterator = query
|
||||
? singleInstallationIterator(app, query.installationId)
|
||||
: app.eachInstallation.iterator();
|
||||
for await (const { octokit } of iterator) {
|
||||
const repositoriesIterator = composePaginateRest.iterator(octokit, "GET /installation/repositories");
|
||||
for await (const { data: repositories } of repositoriesIterator) {
|
||||
for (const repository of repositories) {
|
||||
yield { octokit: octokit, repository };
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
15
node_modules/@octokit/app/dist-src/get-installation-octokit.js
generated
vendored
15
node_modules/@octokit/app/dist-src/get-installation-octokit.js
generated
vendored
@ -1,15 +0,0 @@
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
export async function getInstallationOctokit(app, installationId) {
|
||||
return app.octokit.auth({
|
||||
type: "installation",
|
||||
installationId: installationId,
|
||||
factory(auth) {
|
||||
const options = {
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth,
|
||||
...{ auth: { ...auth, installationId: installationId } },
|
||||
};
|
||||
return new auth.octokit.constructor(options);
|
||||
},
|
||||
});
|
||||
}
|
77
node_modules/@octokit/app/dist-src/index.js
generated
vendored
77
node_modules/@octokit/app/dist-src/index.js
generated
vendored
@ -1,77 +0,0 @@
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
import { VERSION } from "./version";
|
||||
import { webhooks } from "./webhooks";
|
||||
import { eachInstallationFactory } from "./each-installation";
|
||||
import { eachRepositoryFactory } from "./each-repository";
|
||||
import { getInstallationOctokit } from "./get-installation-octokit";
|
||||
export class App {
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0],
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
constructor(options) {
|
||||
const Octokit = (options.Octokit ||
|
||||
OctokitCore);
|
||||
const authOptions = Object.assign({
|
||||
appId: options.appId,
|
||||
privateKey: options.privateKey,
|
||||
}, options.oauth
|
||||
? {
|
||||
clientId: options.oauth.clientId,
|
||||
clientSecret: options.oauth.clientSecret,
|
||||
}
|
||||
: {});
|
||||
this.octokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
auth: authOptions,
|
||||
log: options.log,
|
||||
});
|
||||
this.log = Object.assign({
|
||||
debug: () => { },
|
||||
info: () => { },
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
}, options.log);
|
||||
// set app.webhooks depending on whether "webhooks" option has been passed
|
||||
if (options.webhooks) {
|
||||
// @ts-expect-error TODO: figure this out
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
},
|
||||
});
|
||||
}
|
||||
// set app.oauth depending on whether "oauth" option has been passed
|
||||
if (options.oauth) {
|
||||
this.oauth = new OAuthApp({
|
||||
...options.oauth,
|
||||
clientType: "github-app",
|
||||
Octokit,
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.defineProperty(this, "oauth", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] oauth.clientId / oauth.clientSecret options are not set");
|
||||
},
|
||||
});
|
||||
}
|
||||
this.getInstallationOctokit = getInstallationOctokit.bind(null, this);
|
||||
this.eachInstallation = eachInstallationFactory(this);
|
||||
this.eachRepository = eachRepositoryFactory(this);
|
||||
}
|
||||
}
|
||||
App.VERSION = VERSION;
|
||||
export { createNodeMiddleware } from "./middleware/node/index";
|
46
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
46
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
@ -1,46 +0,0 @@
|
||||
import { createNodeMiddleware as oauthNodeMiddleware } from "@octokit/oauth-app";
|
||||
import { createNodeMiddleware as webhooksNodeMiddleware } from "@octokit/webhooks";
|
||||
import { onUnhandledRequestDefault } from "./on-unhandled-request-default";
|
||||
function noop() { }
|
||||
export function createNodeMiddleware(app, options = {}) {
|
||||
const log = Object.assign({
|
||||
debug: noop,
|
||||
info: noop,
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
}, options.log);
|
||||
const optionsWithDefaults = {
|
||||
onUnhandledRequest: onUnhandledRequestDefault,
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log,
|
||||
};
|
||||
const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log,
|
||||
onUnhandledRequest: optionsWithDefaults.onUnhandledRequest,
|
||||
});
|
||||
const oauthMiddleware = oauthNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth",
|
||||
onUnhandledRequest: optionsWithDefaults.onUnhandledRequest,
|
||||
});
|
||||
return middleware.bind(null, optionsWithDefaults, {
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware,
|
||||
});
|
||||
}
|
||||
export async function middleware(options, { webhooksMiddleware, oauthMiddleware }, request, response, next) {
|
||||
const { pathname } = new URL(request.url, "http://localhost");
|
||||
if (pathname === `${options.pathPrefix}/webhooks`) {
|
||||
return webhooksMiddleware(request, response, next);
|
||||
}
|
||||
if (pathname.startsWith(`${options.pathPrefix}/oauth/`)) {
|
||||
return oauthMiddleware(request, response, next);
|
||||
}
|
||||
const isExpressMiddleware = typeof next === "function";
|
||||
if (isExpressMiddleware) {
|
||||
// @ts-ignore `next` must be a function as we check two lines above
|
||||
return next();
|
||||
}
|
||||
return options.onUnhandledRequest(request, response);
|
||||
}
|
8
node_modules/@octokit/app/dist-src/middleware/node/on-unhandled-request-default.js
generated
vendored
8
node_modules/@octokit/app/dist-src/middleware/node/on-unhandled-request-default.js
generated
vendored
@ -1,8 +0,0 @@
|
||||
export function onUnhandledRequestDefault(request, response) {
|
||||
response.writeHead(404, {
|
||||
"content-type": "application/json",
|
||||
});
|
||||
response.end(JSON.stringify({
|
||||
error: `Unknown route: ${request.method} ${request.url}`,
|
||||
}));
|
||||
}
|
1
node_modules/@octokit/app/dist-src/types.js
generated
vendored
1
node_modules/@octokit/app/dist-src/types.js
generated
vendored
@ -1 +0,0 @@
|
||||
export {};
|
1
node_modules/@octokit/app/dist-src/version.js
generated
vendored
1
node_modules/@octokit/app/dist-src/version.js
generated
vendored
@ -1 +0,0 @@
|
||||
export const VERSION = "13.1.2";
|
56
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
56
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
@ -1,56 +0,0 @@
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
export function webhooks(appOctokit, options
|
||||
// Explict return type for better debugability and performance,
|
||||
// see https://github.com/octokit/app.js/pull/201
|
||||
) {
|
||||
return new Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async (event) => {
|
||||
if (!("installation" in event.payload) ||
|
||||
typeof event.payload.installation !== "object") {
|
||||
const octokit = new appOctokit.constructor({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`,
|
||||
},
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit,
|
||||
};
|
||||
}
|
||||
const installationId = event.payload.installation.id;
|
||||
const octokit = (await appOctokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
return new auth.octokit.constructor({
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth,
|
||||
...{
|
||||
auth: {
|
||||
...auth,
|
||||
installationId,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
}));
|
||||
// set `x-github-delivery` header on all requests sent in response to the current
|
||||
// event. This allows GitHub Support to correlate the request with the event.
|
||||
// This is not documented and not considered public API, the header may change.
|
||||
// Once we document this as best practice on https://docs.github.com/en/rest/guides/best-practices-for-integrators
|
||||
// we will make it official
|
||||
/* istanbul ignore next */
|
||||
octokit.hook.before("request", (options) => {
|
||||
options.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
121
node_modules/@octokit/app/dist-types/each-installation.d.ts
generated
vendored
121
node_modules/@octokit/app/dist-types/each-installation.d.ts
generated
vendored
@ -1,121 +0,0 @@
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { App } from "./index";
|
||||
import { EachInstallationFunction, EachInstallationInterface } from "./types";
|
||||
export declare function eachInstallationFactory(app: App): EachInstallationInterface<Octokit>;
|
||||
export declare function eachInstallation(app: App, callback: EachInstallationFunction<Octokit>): Promise<void>;
|
||||
export declare function eachInstallationIterator(app: App): {
|
||||
[Symbol.asyncIterator](): AsyncGenerator<{
|
||||
octokit: Octokit;
|
||||
installation: {
|
||||
id: number;
|
||||
account: (Partial<{
|
||||
name?: string | null | undefined;
|
||||
email?: string | null | undefined;
|
||||
login: string;
|
||||
id: number;
|
||||
node_id: string;
|
||||
avatar_url: string;
|
||||
gravatar_id: string | null;
|
||||
url: string;
|
||||
html_url: string;
|
||||
followers_url: string;
|
||||
following_url: string;
|
||||
gists_url: string;
|
||||
starred_url: string;
|
||||
subscriptions_url: string;
|
||||
organizations_url: string;
|
||||
repos_url: string;
|
||||
events_url: string;
|
||||
received_events_url: string;
|
||||
type: string;
|
||||
site_admin: boolean;
|
||||
starred_at?: string | undefined;
|
||||
}> & Partial<{
|
||||
description?: string | null | undefined;
|
||||
html_url: string;
|
||||
website_url?: string | null | undefined;
|
||||
id: number;
|
||||
node_id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
avatar_url: string;
|
||||
}>) | null;
|
||||
repository_selection: "all" | "selected";
|
||||
access_tokens_url: string;
|
||||
repositories_url: string;
|
||||
html_url: string;
|
||||
app_id: number;
|
||||
target_id: number;
|
||||
target_type: string;
|
||||
permissions: {
|
||||
actions?: "read" | "write" | undefined;
|
||||
administration?: "read" | "write" | undefined;
|
||||
checks?: "read" | "write" | undefined;
|
||||
contents?: "read" | "write" | undefined;
|
||||
deployments?: "read" | "write" | undefined;
|
||||
environments?: "read" | "write" | undefined;
|
||||
issues?: "read" | "write" | undefined;
|
||||
metadata?: "read" | "write" | undefined;
|
||||
packages?: "read" | "write" | undefined;
|
||||
pages?: "read" | "write" | undefined;
|
||||
pull_requests?: "read" | "write" | undefined;
|
||||
repository_announcement_banners?: "read" | "write" | undefined;
|
||||
repository_hooks?: "read" | "write" | undefined;
|
||||
repository_projects?: "read" | "write" | "admin" | undefined;
|
||||
secret_scanning_alerts?: "read" | "write" | undefined;
|
||||
secrets?: "read" | "write" | undefined;
|
||||
security_events?: "read" | "write" | undefined;
|
||||
single_file?: "read" | "write" | undefined;
|
||||
statuses?: "read" | "write" | undefined;
|
||||
vulnerability_alerts?: "read" | "write" | undefined;
|
||||
workflows?: "write" | undefined;
|
||||
members?: "read" | "write" | undefined;
|
||||
organization_administration?: "read" | "write" | undefined;
|
||||
organization_custom_roles?: "read" | "write" | undefined;
|
||||
organization_announcement_banners?: "read" | "write" | undefined;
|
||||
organization_hooks?: "read" | "write" | undefined;
|
||||
organization_plan?: "read" | undefined;
|
||||
organization_projects?: "read" | "write" | "admin" | undefined;
|
||||
organization_packages?: "read" | "write" | undefined;
|
||||
organization_secrets?: "read" | "write" | undefined;
|
||||
organization_self_hosted_runners?: "read" | "write" | undefined;
|
||||
organization_user_blocking?: "read" | "write" | undefined;
|
||||
team_discussions?: "read" | "write" | undefined;
|
||||
};
|
||||
events: string[];
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
single_file_name: string | null;
|
||||
has_multiple_single_files?: boolean | undefined;
|
||||
single_file_paths?: string[] | undefined;
|
||||
app_slug: string;
|
||||
suspended_by: {
|
||||
name?: string | null | undefined;
|
||||
email?: string | null | undefined;
|
||||
login: string;
|
||||
id: number;
|
||||
node_id: string;
|
||||
avatar_url: string;
|
||||
gravatar_id: string | null;
|
||||
url: string;
|
||||
html_url: string;
|
||||
followers_url: string;
|
||||
following_url: string;
|
||||
gists_url: string;
|
||||
starred_url: string;
|
||||
subscriptions_url: string;
|
||||
organizations_url: string;
|
||||
repos_url: string;
|
||||
events_url: string;
|
||||
received_events_url: string;
|
||||
type: string;
|
||||
site_admin: boolean;
|
||||
starred_at?: string | undefined;
|
||||
} | null;
|
||||
suspended_at: string | null;
|
||||
contact_email?: string | null | undefined;
|
||||
};
|
||||
}, void, unknown>;
|
||||
};
|
281
node_modules/@octokit/app/dist-types/each-repository.d.ts
generated
vendored
281
node_modules/@octokit/app/dist-types/each-repository.d.ts
generated
vendored
@ -1,281 +0,0 @@
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { App } from "./index";
|
||||
import { EachRepositoryFunction, EachRepositoryInterface, EachRepositoryQuery } from "./types";
|
||||
export declare function eachRepositoryFactory(app: App): EachRepositoryInterface<Octokit>;
|
||||
export declare function eachRepository(app: App, queryOrCallback: EachRepositoryQuery | EachRepositoryFunction<Octokit>, callback?: EachRepositoryFunction<Octokit>): Promise<void>;
|
||||
export declare function eachRepositoryIterator(app: App, query?: EachRepositoryQuery): {
|
||||
[Symbol.asyncIterator](): AsyncGenerator<{
|
||||
octokit: Octokit;
|
||||
repository: {
|
||||
id: number;
|
||||
node_id: string;
|
||||
name: string;
|
||||
full_name: string;
|
||||
license: {
|
||||
key: string;
|
||||
name: string;
|
||||
url: string | null;
|
||||
spdx_id: string | null;
|
||||
node_id: string;
|
||||
html_url?: string | undefined;
|
||||
} | null;
|
||||
organization?: {
|
||||
name?: string | null | undefined;
|
||||
email?: string | null | undefined;
|
||||
login: string;
|
||||
id: number;
|
||||
node_id: string;
|
||||
avatar_url: string;
|
||||
gravatar_id: string | null;
|
||||
url: string;
|
||||
html_url: string;
|
||||
followers_url: string;
|
||||
following_url: string;
|
||||
gists_url: string;
|
||||
starred_url: string;
|
||||
subscriptions_url: string;
|
||||
organizations_url: string;
|
||||
repos_url: string;
|
||||
events_url: string;
|
||||
received_events_url: string;
|
||||
type: string;
|
||||
site_admin: boolean;
|
||||
starred_at?: string | undefined;
|
||||
} | null | undefined;
|
||||
forks: number;
|
||||
permissions?: {
|
||||
admin: boolean;
|
||||
pull: boolean;
|
||||
triage?: boolean | undefined;
|
||||
push: boolean;
|
||||
maintain?: boolean | undefined;
|
||||
} | undefined;
|
||||
owner: {
|
||||
name?: string | null | undefined;
|
||||
email?: string | null | undefined;
|
||||
login: string;
|
||||
id: number;
|
||||
node_id: string;
|
||||
avatar_url: string;
|
||||
gravatar_id: string | null;
|
||||
url: string;
|
||||
html_url: string;
|
||||
followers_url: string;
|
||||
following_url: string;
|
||||
gists_url: string;
|
||||
starred_url: string;
|
||||
subscriptions_url: string;
|
||||
organizations_url: string;
|
||||
repos_url: string;
|
||||
events_url: string;
|
||||
received_events_url: string;
|
||||
type: string;
|
||||
site_admin: boolean;
|
||||
starred_at?: string | undefined;
|
||||
};
|
||||
private: boolean;
|
||||
html_url: string;
|
||||
description: string | null;
|
||||
fork: boolean;
|
||||
url: string;
|
||||
archive_url: string;
|
||||
assignees_url: string;
|
||||
blobs_url: string;
|
||||
branches_url: string;
|
||||
collaborators_url: string;
|
||||
comments_url: string;
|
||||
commits_url: string;
|
||||
compare_url: string;
|
||||
contents_url: string;
|
||||
contributors_url: string;
|
||||
deployments_url: string;
|
||||
downloads_url: string;
|
||||
events_url: string;
|
||||
forks_url: string;
|
||||
git_commits_url: string;
|
||||
git_refs_url: string;
|
||||
git_tags_url: string;
|
||||
git_url: string;
|
||||
issue_comment_url: string;
|
||||
issue_events_url: string;
|
||||
issues_url: string;
|
||||
keys_url: string;
|
||||
labels_url: string;
|
||||
languages_url: string;
|
||||
merges_url: string;
|
||||
milestones_url: string;
|
||||
notifications_url: string;
|
||||
pulls_url: string;
|
||||
releases_url: string;
|
||||
ssh_url: string;
|
||||
stargazers_url: string;
|
||||
statuses_url: string;
|
||||
subscribers_url: string;
|
||||
subscription_url: string;
|
||||
tags_url: string;
|
||||
teams_url: string;
|
||||
trees_url: string;
|
||||
clone_url: string;
|
||||
mirror_url: string | null;
|
||||
hooks_url: string;
|
||||
svn_url: string;
|
||||
homepage: string | null;
|
||||
language: string | null;
|
||||
forks_count: number;
|
||||
stargazers_count: number;
|
||||
watchers_count: number;
|
||||
size: number;
|
||||
default_branch: string;
|
||||
open_issues_count: number;
|
||||
is_template?: boolean | undefined;
|
||||
topics?: string[] | undefined;
|
||||
has_issues: boolean;
|
||||
has_projects: boolean;
|
||||
has_wiki: boolean;
|
||||
has_pages: boolean;
|
||||
has_downloads: boolean;
|
||||
has_discussions?: boolean | undefined;
|
||||
archived: boolean;
|
||||
disabled: boolean;
|
||||
visibility?: string | undefined;
|
||||
pushed_at: string | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
allow_rebase_merge?: boolean | undefined;
|
||||
template_repository?: {
|
||||
id?: number | undefined;
|
||||
node_id?: string | undefined;
|
||||
name?: string | undefined;
|
||||
full_name?: string | undefined;
|
||||
owner?: {
|
||||
login?: string | undefined;
|
||||
id?: number | undefined;
|
||||
node_id?: string | undefined;
|
||||
avatar_url?: string | undefined;
|
||||
gravatar_id?: string | undefined;
|
||||
url?: string | undefined;
|
||||
html_url?: string | undefined;
|
||||
followers_url?: string | undefined;
|
||||
following_url?: string | undefined;
|
||||
gists_url?: string | undefined;
|
||||
starred_url?: string | undefined;
|
||||
subscriptions_url?: string | undefined;
|
||||
organizations_url?: string | undefined;
|
||||
repos_url?: string | undefined;
|
||||
events_url?: string | undefined;
|
||||
received_events_url?: string | undefined;
|
||||
type?: string | undefined;
|
||||
site_admin?: boolean | undefined;
|
||||
} | undefined;
|
||||
private?: boolean | undefined;
|
||||
html_url?: string | undefined;
|
||||
description?: string | undefined;
|
||||
fork?: boolean | undefined;
|
||||
url?: string | undefined;
|
||||
archive_url?: string | undefined;
|
||||
assignees_url?: string | undefined;
|
||||
blobs_url?: string | undefined;
|
||||
branches_url?: string | undefined;
|
||||
collaborators_url?: string | undefined;
|
||||
comments_url?: string | undefined;
|
||||
commits_url?: string | undefined;
|
||||
compare_url?: string | undefined;
|
||||
contents_url?: string | undefined;
|
||||
contributors_url?: string | undefined;
|
||||
deployments_url?: string | undefined;
|
||||
downloads_url?: string | undefined;
|
||||
events_url?: string | undefined;
|
||||
forks_url?: string | undefined;
|
||||
git_commits_url?: string | undefined;
|
||||
git_refs_url?: string | undefined;
|
||||
git_tags_url?: string | undefined;
|
||||
git_url?: string | undefined;
|
||||
issue_comment_url?: string | undefined;
|
||||
issue_events_url?: string | undefined;
|
||||
issues_url?: string | undefined;
|
||||
keys_url?: string | undefined;
|
||||
labels_url?: string | undefined;
|
||||
languages_url?: string | undefined;
|
||||
merges_url?: string | undefined;
|
||||
milestones_url?: string | undefined;
|
||||
notifications_url?: string | undefined;
|
||||
pulls_url?: string | undefined;
|
||||
releases_url?: string | undefined;
|
||||
ssh_url?: string | undefined;
|
||||
stargazers_url?: string | undefined;
|
||||
statuses_url?: string | undefined;
|
||||
subscribers_url?: string | undefined;
|
||||
subscription_url?: string | undefined;
|
||||
tags_url?: string | undefined;
|
||||
teams_url?: string | undefined;
|
||||
trees_url?: string | undefined;
|
||||
clone_url?: string | undefined;
|
||||
mirror_url?: string | undefined;
|
||||
hooks_url?: string | undefined;
|
||||
svn_url?: string | undefined;
|
||||
homepage?: string | undefined;
|
||||
language?: string | undefined;
|
||||
forks_count?: number | undefined;
|
||||
stargazers_count?: number | undefined;
|
||||
watchers_count?: number | undefined;
|
||||
size?: number | undefined;
|
||||
default_branch?: string | undefined;
|
||||
open_issues_count?: number | undefined;
|
||||
is_template?: boolean | undefined;
|
||||
topics?: string[] | undefined;
|
||||
has_issues?: boolean | undefined;
|
||||
has_projects?: boolean | undefined;
|
||||
has_wiki?: boolean | undefined;
|
||||
has_pages?: boolean | undefined;
|
||||
has_downloads?: boolean | undefined;
|
||||
archived?: boolean | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
visibility?: string | undefined;
|
||||
pushed_at?: string | undefined;
|
||||
created_at?: string | undefined;
|
||||
updated_at?: string | undefined;
|
||||
permissions?: {
|
||||
admin?: boolean | undefined;
|
||||
maintain?: boolean | undefined;
|
||||
push?: boolean | undefined;
|
||||
triage?: boolean | undefined;
|
||||
pull?: boolean | undefined;
|
||||
} | undefined;
|
||||
allow_rebase_merge?: boolean | undefined;
|
||||
temp_clone_token?: string | undefined;
|
||||
allow_squash_merge?: boolean | undefined;
|
||||
allow_auto_merge?: boolean | undefined;
|
||||
delete_branch_on_merge?: boolean | undefined;
|
||||
allow_update_branch?: boolean | undefined;
|
||||
use_squash_pr_title_as_default?: boolean | undefined;
|
||||
squash_merge_commit_title?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
|
||||
squash_merge_commit_message?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
|
||||
merge_commit_title?: "PR_TITLE" | "MERGE_MESSAGE" | undefined;
|
||||
merge_commit_message?: "PR_TITLE" | "PR_BODY" | "BLANK" | undefined;
|
||||
allow_merge_commit?: boolean | undefined;
|
||||
subscribers_count?: number | undefined;
|
||||
network_count?: number | undefined;
|
||||
} | null | undefined;
|
||||
temp_clone_token?: string | undefined;
|
||||
allow_squash_merge?: boolean | undefined;
|
||||
allow_auto_merge?: boolean | undefined;
|
||||
delete_branch_on_merge?: boolean | undefined;
|
||||
allow_update_branch?: boolean | undefined;
|
||||
use_squash_pr_title_as_default?: boolean | undefined;
|
||||
squash_merge_commit_title?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
|
||||
squash_merge_commit_message?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
|
||||
merge_commit_title?: "PR_TITLE" | "MERGE_MESSAGE" | undefined;
|
||||
merge_commit_message?: "PR_TITLE" | "PR_BODY" | "BLANK" | undefined;
|
||||
allow_merge_commit?: boolean | undefined;
|
||||
allow_forking?: boolean | undefined;
|
||||
web_commit_signoff_required?: boolean | undefined;
|
||||
subscribers_count?: number | undefined;
|
||||
network_count?: number | undefined;
|
||||
open_issues: number;
|
||||
watchers: number;
|
||||
master_branch?: string | undefined;
|
||||
starred_at?: string | undefined;
|
||||
anonymous_access_enabled?: boolean | undefined;
|
||||
};
|
||||
}, void, unknown>;
|
||||
};
|
3
node_modules/@octokit/app/dist-types/get-installation-octokit.d.ts
generated
vendored
3
node_modules/@octokit/app/dist-types/get-installation-octokit.d.ts
generated
vendored
@ -1,3 +0,0 @@
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { App } from "./index";
|
||||
export declare function getInstallationOctokit(app: App, installationId: number): Promise<Octokit>;
|
52
node_modules/@octokit/app/dist-types/index.d.ts
generated
vendored
52
node_modules/@octokit/app/dist-types/index.d.ts
generated
vendored
@ -1,52 +0,0 @@
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
import { Options, ConstructorOptions, EachInstallationInterface, EachRepositoryInterface, GetInstallationOctokitInterface } from "./types";
|
||||
type Constructor<T> = new (...args: any[]) => T;
|
||||
type OctokitType<TOptions extends Options> = TOptions["Octokit"] extends typeof OctokitCore ? InstanceType<TOptions["Octokit"]> : OctokitCore;
|
||||
type OctokitClassType<TOptions extends Options> = TOptions["Octokit"] extends typeof OctokitCore ? TOptions["Octokit"] : typeof OctokitCore;
|
||||
export declare class App<TOptions extends Options = Options> {
|
||||
static VERSION: string;
|
||||
static defaults<TDefaults extends Options, S extends Constructor<App<TDefaults>>>(this: S, defaults: Partial<TDefaults>): {
|
||||
new (...args: any[]): {
|
||||
octokit: OctokitType<TDefaults>;
|
||||
webhooks: Webhooks<{
|
||||
octokit: OctokitType<TDefaults>;
|
||||
}>;
|
||||
oauth: OAuthApp<{
|
||||
clientType: "github-app";
|
||||
Octokit: OctokitClassType<TDefaults>;
|
||||
}>;
|
||||
getInstallationOctokit: GetInstallationOctokitInterface<OctokitType<TDefaults>>;
|
||||
eachInstallation: EachInstallationInterface<OctokitType<TDefaults>>;
|
||||
eachRepository: EachRepositoryInterface<OctokitType<TDefaults>>;
|
||||
log: {
|
||||
[key: string]: unknown;
|
||||
debug: (message: string, additionalInfo?: object | undefined) => void;
|
||||
info: (message: string, additionalInfo?: object | undefined) => void;
|
||||
warn: (message: string, additionalInfo?: object | undefined) => void;
|
||||
error: (message: string, additionalInfo?: object | undefined) => void;
|
||||
};
|
||||
};
|
||||
} & S;
|
||||
octokit: OctokitType<TOptions>;
|
||||
webhooks: Webhooks<{
|
||||
octokit: OctokitType<TOptions>;
|
||||
}>;
|
||||
oauth: OAuthApp<{
|
||||
clientType: "github-app";
|
||||
Octokit: OctokitClassType<TOptions>;
|
||||
}>;
|
||||
getInstallationOctokit: GetInstallationOctokitInterface<OctokitType<TOptions>>;
|
||||
eachInstallation: EachInstallationInterface<OctokitType<TOptions>>;
|
||||
eachRepository: EachRepositoryInterface<OctokitType<TOptions>>;
|
||||
log: {
|
||||
debug: (message: string, additionalInfo?: object) => void;
|
||||
info: (message: string, additionalInfo?: object) => void;
|
||||
warn: (message: string, additionalInfo?: object) => void;
|
||||
error: (message: string, additionalInfo?: object) => void;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
constructor(options: ConstructorOptions<TOptions>);
|
||||
}
|
||||
export { createNodeMiddleware } from "./middleware/node/index";
|
12
node_modules/@octokit/app/dist-types/middleware/node/index.d.ts
generated
vendored
12
node_modules/@octokit/app/dist-types/middleware/node/index.d.ts
generated
vendored
@ -1,12 +0,0 @@
|
||||
type IncomingMessage = any;
|
||||
type ServerResponse = any;
|
||||
import { App } from "../../index";
|
||||
import { Options } from "../../types";
|
||||
export type MiddlewareOptions = {
|
||||
pathPrefix?: string;
|
||||
log?: Options["log"];
|
||||
onUnhandledRequest?: (request: IncomingMessage, response: ServerResponse) => void;
|
||||
};
|
||||
export declare function createNodeMiddleware(app: App, options?: MiddlewareOptions): (request: any, response: any, next?: Function | undefined) => Promise<any>;
|
||||
export declare function middleware(options: Required<MiddlewareOptions>, { webhooksMiddleware, oauthMiddleware }: any, request: IncomingMessage, response: ServerResponse, next?: Function): Promise<any>;
|
||||
export {};
|
@ -1,4 +0,0 @@
|
||||
type IncomingMessage = any;
|
||||
type ServerResponse = any;
|
||||
export declare function onUnhandledRequestDefault(request: IncomingMessage, response: ServerResponse): void;
|
||||
export {};
|
51
node_modules/@octokit/app/dist-types/types.d.ts
generated
vendored
51
node_modules/@octokit/app/dist-types/types.d.ts
generated
vendored
@ -1,51 +0,0 @@
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { Endpoints } from "@octokit/types";
|
||||
export type Options = {
|
||||
appId?: number | string;
|
||||
privateKey?: string;
|
||||
webhooks?: {
|
||||
secret: string;
|
||||
};
|
||||
oauth?: {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
allowSignup?: boolean;
|
||||
};
|
||||
Octokit?: typeof Octokit;
|
||||
log?: {
|
||||
debug: (...data: any[]) => void;
|
||||
info: (...data: any[]) => void;
|
||||
warn: (...data: any[]) => void;
|
||||
error: (...data: any[]) => void;
|
||||
};
|
||||
};
|
||||
export type ConstructorOptions<TOptions extends Options> = TOptions & {
|
||||
appId: number | string;
|
||||
privateKey: string;
|
||||
};
|
||||
export type InstallationFunctionOptions<O> = {
|
||||
octokit: O;
|
||||
installation: Endpoints["GET /app/installations"]["response"]["data"][0];
|
||||
};
|
||||
export type EachInstallationFunction<O> = (options: InstallationFunctionOptions<O>) => unknown | Promise<unknown>;
|
||||
export interface EachInstallationInterface<O> {
|
||||
(callback: EachInstallationFunction<O>): Promise<void>;
|
||||
iterator: () => AsyncIterable<InstallationFunctionOptions<O>>;
|
||||
}
|
||||
type EachRepositoryFunctionOptions<O> = {
|
||||
octokit: O;
|
||||
repository: Endpoints["GET /installation/repositories"]["response"]["data"]["repositories"][0];
|
||||
};
|
||||
export type EachRepositoryFunction<O> = (options: EachRepositoryFunctionOptions<O>) => unknown | Promise<unknown>;
|
||||
export type EachRepositoryQuery = {
|
||||
installationId: number;
|
||||
};
|
||||
export interface EachRepositoryInterface<O> {
|
||||
(callback: EachRepositoryFunction<O>): Promise<void>;
|
||||
(query: EachRepositoryQuery, callback: EachRepositoryFunction<O>): Promise<void>;
|
||||
iterator: (query?: EachRepositoryQuery) => AsyncIterable<EachRepositoryFunctionOptions<O>>;
|
||||
}
|
||||
export interface GetInstallationOctokitInterface<O> {
|
||||
(installationId: number): Promise<O>;
|
||||
}
|
||||
export {};
|
1
node_modules/@octokit/app/dist-types/version.d.ts
generated
vendored
1
node_modules/@octokit/app/dist-types/version.d.ts
generated
vendored
@ -1 +0,0 @@
|
||||
export declare const VERSION = "13.1.2";
|
6
node_modules/@octokit/app/dist-types/webhooks.d.ts
generated
vendored
6
node_modules/@octokit/app/dist-types/webhooks.d.ts
generated
vendored
@ -1,6 +0,0 @@
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { Webhooks, EmitterWebhookEvent } from "@octokit/webhooks";
|
||||
import { Options } from "./types";
|
||||
export declare function webhooks(appOctokit: Octokit, options: Required<Options>["webhooks"]): Webhooks<EmitterWebhookEvent & {
|
||||
octokit: Octokit;
|
||||
}>;
|
48
node_modules/@octokit/app/package.json
generated
vendored
48
node_modules/@octokit/app/package.json
generated
vendored
@ -1,48 +0,0 @@
|
||||
{
|
||||
"name": "@octokit/app",
|
||||
"description": "GitHub Apps toolset for Node.js",
|
||||
"version": "13.1.2",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"repository": "github:octokit/app.js",
|
||||
"dependencies": {
|
||||
"@octokit/auth-app": "^4.0.8",
|
||||
"@octokit/auth-unauthenticated": "^3.0.0",
|
||||
"@octokit/core": "^4.0.0",
|
||||
"@octokit/oauth-app": "^4.0.7",
|
||||
"@octokit/plugin-paginate-rest": "^6.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"@octokit/webhooks": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.3.7",
|
||||
"@pika/plugin-build-node": "^0.9.1",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.1",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"express": "^4.17.1",
|
||||
"fetch-mock": "^9.10.7",
|
||||
"jest": "^29.0.0",
|
||||
"mockdate": "^3.0.2",
|
||||
"node-fetch": "^2.6.7",
|
||||
"prettier": "2.8.3",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
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.
|
1396
node_modules/@octokit/auth-app/README.md
generated
vendored
1396
node_modules/@octokit/auth-app/README.md
generated
vendored
File diff suppressed because it is too large
Load Diff
418
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
418
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
@ -1,418 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var request = require('@octokit/request');
|
||||
var authOauthApp = require('@octokit/auth-oauth-app');
|
||||
var deprecation = require('deprecation');
|
||||
var universalGithubAppJwt = require('universal-github-app-jwt');
|
||||
var LRU = _interopDefault(require('lru-cache'));
|
||||
var authOauthUser = require('@octokit/auth-oauth-user');
|
||||
|
||||
async function getAppAuthentication({
|
||||
appId,
|
||||
privateKey,
|
||||
timeDifference
|
||||
}) {
|
||||
try {
|
||||
const appAuthentication = await universalGithubAppJwt.githubAppJwt({
|
||||
id: +appId,
|
||||
privateKey,
|
||||
now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference
|
||||
});
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1000).toISOString()
|
||||
};
|
||||
} catch (error) {
|
||||
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
throw new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'");
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/isaacs/node-lru-cache#readme
|
||||
function getCache() {
|
||||
return new LRU({
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
max: 15000,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
maxAge: 1000 * 60 * 59
|
||||
});
|
||||
}
|
||||
async function get(cache, options) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
const result = await cache.get(cacheKey);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const [token, createdAt, expiresAt, repositorySelection, permissionsString, singleFileName] = result.split("|");
|
||||
const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions[string.slice(0, -1)] = "write";
|
||||
} else {
|
||||
permissions[string] = "read";
|
||||
}
|
||||
return permissions;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection: repositorySelection
|
||||
};
|
||||
}
|
||||
async function set(cache, options, data) {
|
||||
const key = optionsToCacheKey(options);
|
||||
const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(name => `${name}${data.permissions[name] === "write" ? "!" : ""}`).join(",");
|
||||
const value = [data.token, data.createdAt, data.expiresAt, data.repositorySelection, permissionsString, data.singleFileName].join("|");
|
||||
await cache.set(key, value);
|
||||
}
|
||||
function optionsToCacheKey({
|
||||
installationId,
|
||||
permissions = {},
|
||||
repositoryIds = [],
|
||||
repositoryNames = []
|
||||
}) {
|
||||
const permissionsString = Object.keys(permissions).sort().map(name => permissions[name] === "read" ? name : `${name}!`).join(",");
|
||||
const repositoryIdsString = repositoryIds.sort().join(",");
|
||||
const repositoryNamesString = repositoryNames.join(",");
|
||||
return [installationId, repositoryIdsString, repositoryNamesString, permissionsString].filter(Boolean).join("|");
|
||||
}
|
||||
|
||||
function toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
}) {
|
||||
return Object.assign({
|
||||
type: "token",
|
||||
tokenType: "installation",
|
||||
token,
|
||||
installationId,
|
||||
permissions,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection
|
||||
}, repositoryIds ? {
|
||||
repositoryIds
|
||||
} : null, repositoryNames ? {
|
||||
repositoryNames
|
||||
} : null, singleFileName ? {
|
||||
singleFileName
|
||||
} : null);
|
||||
}
|
||||
|
||||
async function getInstallationAuthentication(state, options, customRequest) {
|
||||
const installationId = Number(options.installationId || state.installationId);
|
||||
if (!installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");
|
||||
}
|
||||
if (options.factory) {
|
||||
const {
|
||||
type,
|
||||
factory,
|
||||
oauthApp,
|
||||
...factoryAuthOptions
|
||||
} = {
|
||||
...state,
|
||||
...options
|
||||
};
|
||||
// @ts-expect-error if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const optionsWithInstallationTokenFromState = Object.assign({
|
||||
installationId
|
||||
}, options);
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, optionsWithInstallationTokenFromState);
|
||||
if (result) {
|
||||
const {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection
|
||||
} = result;
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositorySelection,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const request = customRequest || state.request;
|
||||
const {
|
||||
data: {
|
||||
token,
|
||||
expires_at: expiresAt,
|
||||
repositories,
|
||||
permissions: permissionsOptional,
|
||||
repository_selection: repositorySelectionOptional,
|
||||
single_file: singleFileName
|
||||
}
|
||||
} = await request("POST /app/installations/{installation_id}/access_tokens", {
|
||||
installation_id: installationId,
|
||||
repository_ids: options.repositoryIds,
|
||||
repositories: options.repositoryNames,
|
||||
permissions: options.permissions,
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`
|
||||
}
|
||||
});
|
||||
/* istanbul ignore next - permissions are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const permissions = permissionsOptional || {};
|
||||
/* istanbul ignore next - repositorySelection are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const repositorySelection = repositorySelectionOptional || "all";
|
||||
const repositoryIds = repositories ? repositories.map(r => r.id) : void 0;
|
||||
const repositoryNames = repositories ? repositories.map(repo => repo.name) : void 0;
|
||||
const createdAt = new Date().toISOString();
|
||||
await set(state.cache, optionsWithInstallationTokenFromState, {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
});
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
});
|
||||
}
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
// @ts-expect-error "oauth" is not supperted in types
|
||||
case "oauth":
|
||||
state.log.warn(
|
||||
// @ts-expect-error `log.warn()` expects string
|
||||
new deprecation.Deprecation(`[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead`));
|
||||
case "oauth-app":
|
||||
return state.oauthApp({
|
||||
type: "oauth-app"
|
||||
});
|
||||
case "installation":
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation"
|
||||
});
|
||||
case "oauth-user":
|
||||
// @ts-expect-error TODO: infer correct auth options type based on type. authOptions should be typed as "WebFlowAuthOptions | OAuthAppDeviceFlowAuthOptions | GitHubAppDeviceFlowAuthOptions"
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
// @ts-expect-error type is "never" at this point
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
const PATHS = ["/app", "/app/hook/config", "/app/hook/deliveries", "/app/hook/deliveries/{delivery_id}", "/app/hook/deliveries/{delivery_id}/attempts", "/app/installations", "/app/installations/{installation_id}", "/app/installations/{installation_id}/access_tokens", "/app/installations/{installation_id}/suspended", "/marketplace_listing/accounts/{account_id}", "/marketplace_listing/plan", "/marketplace_listing/plans", "/marketplace_listing/plans/{plan_id}/accounts", "/marketplace_listing/stubbed/accounts/{account_id}", "/marketplace_listing/stubbed/plan", "/marketplace_listing/stubbed/plans", "/marketplace_listing/stubbed/plans/{plan_id}/accounts", "/orgs/{org}/installation", "/repos/{owner}/{repo}/installation", "/users/{username}/installation"];
|
||||
// CREDIT: Simon Grondin (https://github.com/SGrondin)
|
||||
// https://github.com/octokit/plugin-throttling.js/blob/45c5d7f13b8af448a9dbca468d9c9150a73b3948/lib/route-matcher.js
|
||||
function routeMatcher(paths) {
|
||||
// EXAMPLE. For the following paths:
|
||||
/* [
|
||||
"/orgs/{org}/invitations",
|
||||
"/repos/{owner}/{repo}/collaborators/{username}"
|
||||
] */
|
||||
const regexes = paths.map(p => p.split("/").map(c => c.startsWith("{") ? "(?:.+?)" : c).join("/"));
|
||||
// 'regexes' would contain:
|
||||
/* [
|
||||
'/orgs/(?:.+?)/invitations',
|
||||
'/repos/(?:.+?)/(?:.+?)/collaborators/(?:.+?)'
|
||||
] */
|
||||
const regex = `^(?:${regexes.map(r => `(?:${r})`).join("|")})[^/]*$`;
|
||||
// 'regex' would contain:
|
||||
/*
|
||||
^(?:(?:\/orgs\/(?:.+?)\/invitations)|(?:\/repos\/(?:.+?)\/(?:.+?)\/collaborators\/(?:.+?)))[^\/]*$
|
||||
It may look scary, but paste it into https://www.debuggex.com/
|
||||
and it will make a lot more sense!
|
||||
*/
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
const REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url);
|
||||
}
|
||||
|
||||
const FIVE_SECONDS_IN_MS = 5 * 1000;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/) || error.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/));
|
||||
}
|
||||
async function hook(state, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
const url = endpoint.url;
|
||||
// Do not intercept request to retrieve a new token
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const {
|
||||
token
|
||||
} = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
} catch (error) {
|
||||
// If there's an issue with the expiration, regenerate the token and try again.
|
||||
// Otherwise rethrow the error for upstream handling.
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
// If the date header is missing, we can't correct the system time skew.
|
||||
// Throw the error to be handled upstream.
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor((Date.parse(error.response.headers.date) - Date.parse(new Date().toString())) / 1000);
|
||||
state.log.warn(error.message);
|
||||
state.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`);
|
||||
const {
|
||||
token
|
||||
} = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (authOauthUser.requiresBasicAuth(url)) {
|
||||
const authentication = await state.oauthApp({
|
||||
type: "oauth-app"
|
||||
});
|
||||
endpoint.headers.authorization = authentication.headers.authorization;
|
||||
return request(endpoint);
|
||||
}
|
||||
const {
|
||||
token,
|
||||
createdAt
|
||||
} = await getInstallationAuthentication(state,
|
||||
// @ts-expect-error TBD
|
||||
{}, request);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(state, request, endpoint, createdAt);
|
||||
}
|
||||
/**
|
||||
* Newly created tokens might not be accessible immediately after creation.
|
||||
* In case of a 401 response, we retry with an exponential delay until more
|
||||
* than five seconds pass since the creation of the token.
|
||||
*
|
||||
* @see https://github.com/octokit/auth-app.js/issues/65
|
||||
*/
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +new Date() - +new Date(createdAt);
|
||||
try {
|
||||
return await request(options);
|
||||
} catch (error) {
|
||||
if (error.status !== 401) {
|
||||
throw error;
|
||||
}
|
||||
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
||||
if (retries > 0) {
|
||||
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1000}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
++retries;
|
||||
const awaitTime = retries * 1000;
|
||||
state.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1000}s)`);
|
||||
await new Promise(resolve => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
|
||||
const VERSION = "4.0.9";
|
||||
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!Number.isFinite(+options.appId)) {
|
||||
throw new Error("[@octokit/auth-app] appId option must be a number or numeric string");
|
||||
}
|
||||
if (!options.privateKey) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId is set to a falsy value");
|
||||
}
|
||||
const log = Object.assign({
|
||||
warn: console.warn.bind(console)
|
||||
}, options.log);
|
||||
const request$1 = options.request || request.request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
}
|
||||
});
|
||||
const state = Object.assign({
|
||||
request: request$1,
|
||||
cache: getCache()
|
||||
}, options, options.installationId ? {
|
||||
installationId: Number(options.installationId)
|
||||
} : {}, {
|
||||
log,
|
||||
oauthApp: authOauthApp.createOAuthAppAuth({
|
||||
clientType: "github-app",
|
||||
clientId: options.clientId || "",
|
||||
clientSecret: options.clientSecret || "",
|
||||
request: request$1
|
||||
})
|
||||
});
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, 'createOAuthUserAuth', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return authOauthUser.createOAuthUserAuth;
|
||||
}
|
||||
});
|
||||
exports.createAppAuth = createAppAuth;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
1
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
28
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
28
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
@ -1,28 +0,0 @@
|
||||
import { Deprecation } from "deprecation";
|
||||
import { getAppAuthentication } from "./get-app-authentication";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication";
|
||||
export async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
// @ts-expect-error "oauth" is not supperted in types
|
||||
case "oauth":
|
||||
state.log.warn(
|
||||
// @ts-expect-error `log.warn()` expects string
|
||||
new Deprecation(`[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead`));
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
authOptions;
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation",
|
||||
});
|
||||
case "oauth-user":
|
||||
// @ts-expect-error TODO: infer correct auth options type based on type. authOptions should be typed as "WebFlowAuthOptions | OAuthAppDeviceFlowAuthOptions | GitHubAppDeviceFlowAuthOptions"
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
// @ts-expect-error type is "never" at this point
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
71
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
71
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
@ -1,71 +0,0 @@
|
||||
// https://github.com/isaacs/node-lru-cache#readme
|
||||
import LRU from "lru-cache";
|
||||
export function getCache() {
|
||||
return new LRU({
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
max: 15000,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
maxAge: 1000 * 60 * 59,
|
||||
});
|
||||
}
|
||||
export async function get(cache, options) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
const result = await cache.get(cacheKey);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const [token, createdAt, expiresAt, repositorySelection, permissionsString, singleFileName,] = result.split("|");
|
||||
const permissions = options.permissions ||
|
||||
permissionsString.split(/,/).reduce((permissions, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions[string.slice(0, -1)] = "write";
|
||||
}
|
||||
else {
|
||||
permissions[string] = "read";
|
||||
}
|
||||
return permissions;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection: repositorySelection,
|
||||
};
|
||||
}
|
||||
export async function set(cache, options, data) {
|
||||
const key = optionsToCacheKey(options);
|
||||
const permissionsString = options.permissions
|
||||
? ""
|
||||
: Object.keys(data.permissions)
|
||||
.map((name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`)
|
||||
.join(",");
|
||||
const value = [
|
||||
data.token,
|
||||
data.createdAt,
|
||||
data.expiresAt,
|
||||
data.repositorySelection,
|
||||
permissionsString,
|
||||
data.singleFileName,
|
||||
].join("|");
|
||||
await cache.set(key, value);
|
||||
}
|
||||
function optionsToCacheKey({ installationId, permissions = {}, repositoryIds = [], repositoryNames = [], }) {
|
||||
const permissionsString = Object.keys(permissions)
|
||||
.sort()
|
||||
.map((name) => (permissions[name] === "read" ? name : `${name}!`))
|
||||
.join(",");
|
||||
const repositoryIdsString = repositoryIds.sort().join(",");
|
||||
const repositoryNamesString = repositoryNames.join(",");
|
||||
return [
|
||||
installationId,
|
||||
repositoryIdsString,
|
||||
repositoryNamesString,
|
||||
permissionsString,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("|");
|
||||
}
|
24
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
24
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
@ -1,24 +0,0 @@
|
||||
import { githubAppJwt } from "universal-github-app-jwt";
|
||||
export async function getAppAuthentication({ appId, privateKey, timeDifference, }) {
|
||||
try {
|
||||
const appAuthentication = await githubAppJwt({
|
||||
id: +appId,
|
||||
privateKey,
|
||||
now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference,
|
||||
});
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1000).toISOString(),
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
throw new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'");
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
81
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
81
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
@ -1,81 +0,0 @@
|
||||
import { get, set } from "./cache";
|
||||
import { getAppAuthentication } from "./get-app-authentication";
|
||||
import { toTokenAuthentication } from "./to-token-authentication";
|
||||
export async function getInstallationAuthentication(state, options, customRequest) {
|
||||
const installationId = Number(options.installationId || state.installationId);
|
||||
if (!installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");
|
||||
}
|
||||
if (options.factory) {
|
||||
const { type, factory, oauthApp, ...factoryAuthOptions } = {
|
||||
...state,
|
||||
...options,
|
||||
};
|
||||
// @ts-expect-error if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const optionsWithInstallationTokenFromState = Object.assign({ installationId }, options);
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, optionsWithInstallationTokenFromState);
|
||||
if (result) {
|
||||
const { token, createdAt, expiresAt, permissions, repositoryIds, repositoryNames, singleFileName, repositorySelection, } = result;
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositorySelection,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const request = customRequest || state.request;
|
||||
const { data: { token, expires_at: expiresAt, repositories, permissions: permissionsOptional, repository_selection: repositorySelectionOptional, single_file: singleFileName, }, } = await request("POST /app/installations/{installation_id}/access_tokens", {
|
||||
installation_id: installationId,
|
||||
repository_ids: options.repositoryIds,
|
||||
repositories: options.repositoryNames,
|
||||
permissions: options.permissions,
|
||||
mediaType: {
|
||||
previews: ["machine-man"],
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`,
|
||||
},
|
||||
});
|
||||
/* istanbul ignore next - permissions are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const permissions = permissionsOptional || {};
|
||||
/* istanbul ignore next - repositorySelection are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const repositorySelection = repositorySelectionOptional || "all";
|
||||
const repositoryIds = repositories
|
||||
? repositories.map((r) => r.id)
|
||||
: void 0;
|
||||
const repositoryNames = repositories
|
||||
? repositories.map((repo) => repo.name)
|
||||
: void 0;
|
||||
const createdAt = new Date().toISOString();
|
||||
await set(state.cache, optionsWithInstallationTokenFromState, {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
}
|
88
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
88
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
@ -1,88 +0,0 @@
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
import { getAppAuthentication } from "./get-app-authentication";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication";
|
||||
import { requiresAppAuth } from "./requires-app-auth";
|
||||
const FIVE_SECONDS_IN_MS = 5 * 1000;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/) ||
|
||||
error.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/));
|
||||
}
|
||||
export async function hook(state, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
const url = endpoint.url;
|
||||
// Do not intercept request to retrieve a new token
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
}
|
||||
catch (error) {
|
||||
// If there's an issue with the expiration, regenerate the token and try again.
|
||||
// Otherwise rethrow the error for upstream handling.
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
// If the date header is missing, we can't correct the system time skew.
|
||||
// Throw the error to be handled upstream.
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor((Date.parse(error.response.headers.date) -
|
||||
Date.parse(new Date().toString())) /
|
||||
1000);
|
||||
state.log.warn(error.message);
|
||||
state.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`);
|
||||
const { token } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff,
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (requiresBasicAuth(url)) {
|
||||
const authentication = await state.oauthApp({ type: "oauth-app" });
|
||||
endpoint.headers.authorization = authentication.headers.authorization;
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token, createdAt } = await getInstallationAuthentication(state,
|
||||
// @ts-expect-error TBD
|
||||
{}, request);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(state, request, endpoint, createdAt);
|
||||
}
|
||||
/**
|
||||
* Newly created tokens might not be accessible immediately after creation.
|
||||
* In case of a 401 response, we retry with an exponential delay until more
|
||||
* than five seconds pass since the creation of the token.
|
||||
*
|
||||
* @see https://github.com/octokit/auth-app.js/issues/65
|
||||
*/
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +new Date() - +new Date(createdAt);
|
||||
try {
|
||||
return await request(options);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status !== 401) {
|
||||
throw error;
|
||||
}
|
||||
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
||||
if (retries > 0) {
|
||||
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1000}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
++retries;
|
||||
const awaitTime = retries * 1000;
|
||||
state.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1000}s)`);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
49
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
49
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
@ -1,49 +0,0 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as defaultRequest } from "@octokit/request";
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
import { auth } from "./auth";
|
||||
import { hook } from "./hook";
|
||||
import { getCache } from "./cache";
|
||||
import { VERSION } from "./version";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!Number.isFinite(+options.appId)) {
|
||||
throw new Error("[@octokit/auth-app] appId option must be a number or numeric string");
|
||||
}
|
||||
if (!options.privateKey) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId is set to a falsy value");
|
||||
}
|
||||
const log = Object.assign({
|
||||
warn: console.warn.bind(console),
|
||||
}, options.log);
|
||||
const request = options.request ||
|
||||
defaultRequest.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-app.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
const state = Object.assign({
|
||||
request,
|
||||
cache: getCache(),
|
||||
}, options, options.installationId
|
||||
? { installationId: Number(options.installationId) }
|
||||
: {}, {
|
||||
log,
|
||||
oauthApp: createOAuthAppAuth({
|
||||
clientType: "github-app",
|
||||
clientId: options.clientId || "",
|
||||
clientSecret: options.clientSecret || "",
|
||||
request,
|
||||
}),
|
||||
});
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
53
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
53
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
@ -1,53 +0,0 @@
|
||||
const PATHS = [
|
||||
"/app",
|
||||
"/app/hook/config",
|
||||
"/app/hook/deliveries",
|
||||
"/app/hook/deliveries/{delivery_id}",
|
||||
"/app/hook/deliveries/{delivery_id}/attempts",
|
||||
"/app/installations",
|
||||
"/app/installations/{installation_id}",
|
||||
"/app/installations/{installation_id}/access_tokens",
|
||||
"/app/installations/{installation_id}/suspended",
|
||||
"/marketplace_listing/accounts/{account_id}",
|
||||
"/marketplace_listing/plan",
|
||||
"/marketplace_listing/plans",
|
||||
"/marketplace_listing/plans/{plan_id}/accounts",
|
||||
"/marketplace_listing/stubbed/accounts/{account_id}",
|
||||
"/marketplace_listing/stubbed/plan",
|
||||
"/marketplace_listing/stubbed/plans",
|
||||
"/marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
||||
"/orgs/{org}/installation",
|
||||
"/repos/{owner}/{repo}/installation",
|
||||
"/users/{username}/installation",
|
||||
];
|
||||
// CREDIT: Simon Grondin (https://github.com/SGrondin)
|
||||
// https://github.com/octokit/plugin-throttling.js/blob/45c5d7f13b8af448a9dbca468d9c9150a73b3948/lib/route-matcher.js
|
||||
function routeMatcher(paths) {
|
||||
// EXAMPLE. For the following paths:
|
||||
/* [
|
||||
"/orgs/{org}/invitations",
|
||||
"/repos/{owner}/{repo}/collaborators/{username}"
|
||||
] */
|
||||
const regexes = paths.map((p) => p
|
||||
.split("/")
|
||||
.map((c) => (c.startsWith("{") ? "(?:.+?)" : c))
|
||||
.join("/"));
|
||||
// 'regexes' would contain:
|
||||
/* [
|
||||
'/orgs/(?:.+?)/invitations',
|
||||
'/repos/(?:.+?)/(?:.+?)/collaborators/(?:.+?)'
|
||||
] */
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`;
|
||||
// 'regex' would contain:
|
||||
/*
|
||||
^(?:(?:\/orgs\/(?:.+?)\/invitations)|(?:\/repos\/(?:.+?)\/(?:.+?)\/collaborators\/(?:.+?)))[^\/]*$
|
||||
|
||||
It may look scary, but paste it into https://www.debuggex.com/
|
||||
and it will make a lot more sense!
|
||||
*/
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
const REGEX = routeMatcher(PATHS);
|
||||
export function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url);
|
||||
}
|
12
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
12
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
@ -1,12 +0,0 @@
|
||||
export function toTokenAuthentication({ installationId, token, createdAt, expiresAt, repositorySelection, permissions, repositoryIds, repositoryNames, singleFileName, }) {
|
||||
return Object.assign({
|
||||
type: "token",
|
||||
tokenType: "installation",
|
||||
token,
|
||||
installationId,
|
||||
permissions,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
}, repositoryIds ? { repositoryIds } : null, repositoryNames ? { repositoryNames } : null, singleFileName ? { singleFileName } : null);
|
||||
}
|
1
node_modules/@octokit/auth-app/dist-src/types.js
generated
vendored
1
node_modules/@octokit/auth-app/dist-src/types.js
generated
vendored
@ -1 +0,0 @@
|
||||
export {};
|
1
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
1
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
@ -1 +0,0 @@
|
||||
export const VERSION = "4.0.9";
|
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
@ -1,20 +0,0 @@
|
||||
import * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
import { State, AppAuthOptions, AppAuthentication, OAuthAppAuthentication, OAuthAppAuthOptions, InstallationAuthOptions, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions } from "./types";
|
||||
/** GitHub App authentication */
|
||||
export declare function auth(state: State, authOptions: AppAuthOptions): Promise<AppAuthentication>;
|
||||
/** OAuth App authentication */
|
||||
export declare function auth(state: State, authOptions: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
/** Installation authentication */
|
||||
export declare function auth(state: State, authOptions: InstallationAuthOptions): Promise<InstallationAccessTokenAuthentication>;
|
||||
/** User Authentication via OAuth web flow */
|
||||
export declare function auth(state: State, authOptions: OAuthWebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
/** GitHub App Web flow with `factory` option */
|
||||
export declare function auth<T = unknown>(state: State, authOptions: OAuthWebFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
/** User Authentication via OAuth Device flow */
|
||||
export declare function auth(state: State, authOptions: OAuthDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
/** GitHub App Device flow with `factory` option */
|
||||
export declare function auth<T = unknown>(state: State, authOptions: OAuthDeviceFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
5
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
5
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
@ -1,5 +0,0 @@
|
||||
import LRU from "lru-cache";
|
||||
import { InstallationAuthOptions, Cache, CacheData, InstallationAccessTokenData } from "./types";
|
||||
export declare function getCache(): LRU<number, string>;
|
||||
export declare function get(cache: Cache, options: InstallationAuthOptions): Promise<InstallationAccessTokenData | void>;
|
||||
export declare function set(cache: Cache, options: InstallationAuthOptions, data: CacheData): Promise<void>;
|
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
@ -1,4 +0,0 @@
|
||||
import { AppAuthentication, State } from "./types";
|
||||
export declare function getAppAuthentication({ appId, privateKey, timeDifference, }: State & {
|
||||
timeDifference?: number;
|
||||
}): Promise<AppAuthentication>;
|
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
||||
import { InstallationAuthOptions, InstallationAccessTokenAuthentication, RequestInterface, State } from "./types";
|
||||
export declare function getInstallationAuthentication(state: State, options: InstallationAuthOptions, customRequest?: RequestInterface): Promise<InstallationAccessTokenAuthentication>;
|
2
node_modules/@octokit/auth-app/dist-types/hook.d.ts
generated
vendored
2
node_modules/@octokit/auth-app/dist-types/hook.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
||||
import { AnyResponse, EndpointOptions, RequestParameters, RequestInterface, Route, State } from "./types";
|
||||
export declare function hook(state: State, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
4
node_modules/@octokit/auth-app/dist-types/index.d.ts
generated
vendored
4
node_modules/@octokit/auth-app/dist-types/index.d.ts
generated
vendored
@ -1,4 +0,0 @@
|
||||
import { AuthInterface, StrategyOptions } from "./types";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export { StrategyOptions, AppAuthOptions, OAuthAppAuthOptions, InstallationAuthOptions, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions, Authentication, AppAuthentication, OAuthAppAuthentication, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, } from "./types";
|
||||
export declare function createAppAuth(options: StrategyOptions): AuthInterface;
|
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
@ -1 +0,0 @@
|
||||
export declare function requiresAppAuth(url: string | undefined): Boolean;
|
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
||||
import { CacheData, InstallationAccessTokenAuthentication, WithInstallationId } from "./types";
|
||||
export declare function toTokenAuthentication({ installationId, token, createdAt, expiresAt, repositorySelection, permissions, repositoryIds, repositoryNames, singleFileName, }: CacheData & WithInstallationId): InstallationAccessTokenAuthentication;
|
125
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
125
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
@ -1,125 +0,0 @@
|
||||
import * as OctokitTypes from "@octokit/types";
|
||||
import LRUCache from "lru-cache";
|
||||
import * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
type OAuthStrategyOptions = {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
};
|
||||
type CommonStrategyOptions = {
|
||||
appId: number | string;
|
||||
privateKey: string;
|
||||
installationId?: number | string;
|
||||
request?: OctokitTypes.RequestInterface;
|
||||
cache?: Cache;
|
||||
log?: {
|
||||
warn: (message: string, additionalInfo?: object) => any;
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
export type StrategyOptions = OAuthStrategyOptions & CommonStrategyOptions & Record<string, unknown>;
|
||||
export type AppAuthOptions = {
|
||||
type: "app";
|
||||
};
|
||||
/**
|
||||
Users SHOULD only enter repositoryIds || repositoryNames.
|
||||
However, this moduke still passes both to the backend API to
|
||||
let the API decide how to handle the logic. We just throw the
|
||||
reponse back to the client making the request.
|
||||
**/
|
||||
export type InstallationAuthOptions = {
|
||||
type: "installation";
|
||||
installationId?: number | string;
|
||||
repositoryIds?: number[];
|
||||
repositoryNames?: string[];
|
||||
permissions?: Permissions;
|
||||
refresh?: boolean;
|
||||
factory?: never;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export type InstallationAuthOptionsWithFactory<T> = {
|
||||
type: "installation";
|
||||
installationId?: number | string;
|
||||
repositoryIds?: number[];
|
||||
repositoryNames?: string[];
|
||||
permissions?: Permissions;
|
||||
refresh?: boolean;
|
||||
factory: FactoryInstallation<T>;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export type OAuthAppAuthOptions = OAuthAppAuth.AppAuthOptions;
|
||||
export type OAuthWebFlowAuthOptions = OAuthAppAuth.WebFlowAuthOptions;
|
||||
export type OAuthDeviceFlowAuthOptions = OAuthAppAuth.GitHubAppDeviceFlowAuthOptions;
|
||||
export type Authentication = AppAuthentication | OAuthAppAuthentication | InstallationAccessTokenAuthentication | GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration;
|
||||
export type FactoryInstallationOptions = StrategyOptions & Omit<InstallationAuthOptions, "type">;
|
||||
export interface FactoryInstallation<T> {
|
||||
(options: FactoryInstallationOptions): T;
|
||||
}
|
||||
export interface AuthInterface {
|
||||
(options: AppAuthOptions): Promise<AppAuthentication>;
|
||||
(options: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
(options: InstallationAuthOptions): Promise<InstallationAccessTokenAuthentication>;
|
||||
<T = unknown>(options: InstallationAuthOptionsWithFactory<T>): Promise<T>;
|
||||
(options: OAuthWebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
(options: OAuthDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
<T = unknown>(options: OAuthWebFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
<T = unknown>(options: OAuthDeviceFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
||||
}
|
||||
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
||||
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
||||
export type EndpointOptions = OctokitTypes.EndpointOptions;
|
||||
export type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export type Route = OctokitTypes.Route;
|
||||
export type RequestInterface = OctokitTypes.RequestInterface;
|
||||
export type Cache = LRUCache<string, string> | {
|
||||
get: (key: string) => string;
|
||||
set: (key: string, value: string) => any;
|
||||
};
|
||||
export type APP_TYPE = "app";
|
||||
export type TOKEN_TYPE = "token";
|
||||
export type INSTALLATION_TOKEN_TYPE = "installation";
|
||||
export type OAUTH_TOKEN_TYPE = "oauth";
|
||||
export type REPOSITORY_SELECTION = "all" | "selected";
|
||||
export type JWT = string;
|
||||
export type ACCESS_TOKEN = string;
|
||||
export type UTC_TIMESTAMP = string;
|
||||
export type AppAuthentication = {
|
||||
type: APP_TYPE;
|
||||
token: JWT;
|
||||
appId: number;
|
||||
expiresAt: string;
|
||||
};
|
||||
export type InstallationAccessTokenData = {
|
||||
token: ACCESS_TOKEN;
|
||||
createdAt: UTC_TIMESTAMP;
|
||||
expiresAt: UTC_TIMESTAMP;
|
||||
permissions: Permissions;
|
||||
repositorySelection: REPOSITORY_SELECTION;
|
||||
repositoryIds?: number[];
|
||||
repositoryNames?: string[];
|
||||
singleFileName?: string;
|
||||
};
|
||||
export type CacheData = InstallationAccessTokenData;
|
||||
export type InstallationAccessTokenAuthentication = InstallationAccessTokenData & {
|
||||
type: TOKEN_TYPE;
|
||||
tokenType: INSTALLATION_TOKEN_TYPE;
|
||||
installationId: number;
|
||||
};
|
||||
export type OAuthAppAuthentication = OAuthAppAuth.AppAuthentication;
|
||||
export type GitHubAppUserAuthentication = OAuthAppAuth.GitHubAppUserAuthentication;
|
||||
export type GitHubAppUserAuthenticationWithExpiration = OAuthAppAuth.GitHubAppUserAuthenticationWithExpiration;
|
||||
export type FactoryOptions = Required<Omit<StrategyOptions, keyof State>> & State;
|
||||
export type Permissions = Record<string, string>;
|
||||
export type WithInstallationId = {
|
||||
installationId: number;
|
||||
};
|
||||
export type State = Required<Omit<CommonStrategyOptions, "installationId">> & {
|
||||
installationId?: number;
|
||||
} & OAuthStrategyOptions & {
|
||||
oauthApp: OAuthAppAuth.GitHubAuthInterface;
|
||||
};
|
||||
export {};
|
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
@ -1 +0,0 @@
|
||||
export declare const VERSION = "4.0.9";
|
406
node_modules/@octokit/auth-app/dist-web/index.js
generated
vendored
406
node_modules/@octokit/auth-app/dist-web/index.js
generated
vendored
@ -1,406 +0,0 @@
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
import { request } from '@octokit/request';
|
||||
import { createOAuthAppAuth } from '@octokit/auth-oauth-app';
|
||||
import { Deprecation } from 'deprecation';
|
||||
import { githubAppJwt } from 'universal-github-app-jwt';
|
||||
import LRU from 'lru-cache';
|
||||
import { requiresBasicAuth } from '@octokit/auth-oauth-user';
|
||||
export { createOAuthUserAuth } from '@octokit/auth-oauth-user';
|
||||
|
||||
async function getAppAuthentication({ appId, privateKey, timeDifference, }) {
|
||||
try {
|
||||
const appAuthentication = await githubAppJwt({
|
||||
id: +appId,
|
||||
privateKey,
|
||||
now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference,
|
||||
});
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1000).toISOString(),
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
throw new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'");
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/isaacs/node-lru-cache#readme
|
||||
function getCache() {
|
||||
return new LRU({
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
max: 15000,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
maxAge: 1000 * 60 * 59,
|
||||
});
|
||||
}
|
||||
async function get(cache, options) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
const result = await cache.get(cacheKey);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const [token, createdAt, expiresAt, repositorySelection, permissionsString, singleFileName,] = result.split("|");
|
||||
const permissions = options.permissions ||
|
||||
permissionsString.split(/,/).reduce((permissions, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions[string.slice(0, -1)] = "write";
|
||||
}
|
||||
else {
|
||||
permissions[string] = "read";
|
||||
}
|
||||
return permissions;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection: repositorySelection,
|
||||
};
|
||||
}
|
||||
async function set(cache, options, data) {
|
||||
const key = optionsToCacheKey(options);
|
||||
const permissionsString = options.permissions
|
||||
? ""
|
||||
: Object.keys(data.permissions)
|
||||
.map((name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`)
|
||||
.join(",");
|
||||
const value = [
|
||||
data.token,
|
||||
data.createdAt,
|
||||
data.expiresAt,
|
||||
data.repositorySelection,
|
||||
permissionsString,
|
||||
data.singleFileName,
|
||||
].join("|");
|
||||
await cache.set(key, value);
|
||||
}
|
||||
function optionsToCacheKey({ installationId, permissions = {}, repositoryIds = [], repositoryNames = [], }) {
|
||||
const permissionsString = Object.keys(permissions)
|
||||
.sort()
|
||||
.map((name) => (permissions[name] === "read" ? name : `${name}!`))
|
||||
.join(",");
|
||||
const repositoryIdsString = repositoryIds.sort().join(",");
|
||||
const repositoryNamesString = repositoryNames.join(",");
|
||||
return [
|
||||
installationId,
|
||||
repositoryIdsString,
|
||||
repositoryNamesString,
|
||||
permissionsString,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("|");
|
||||
}
|
||||
|
||||
function toTokenAuthentication({ installationId, token, createdAt, expiresAt, repositorySelection, permissions, repositoryIds, repositoryNames, singleFileName, }) {
|
||||
return Object.assign({
|
||||
type: "token",
|
||||
tokenType: "installation",
|
||||
token,
|
||||
installationId,
|
||||
permissions,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
}, repositoryIds ? { repositoryIds } : null, repositoryNames ? { repositoryNames } : null, singleFileName ? { singleFileName } : null);
|
||||
}
|
||||
|
||||
async function getInstallationAuthentication(state, options, customRequest) {
|
||||
const installationId = Number(options.installationId || state.installationId);
|
||||
if (!installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");
|
||||
}
|
||||
if (options.factory) {
|
||||
const { type, factory, oauthApp, ...factoryAuthOptions } = {
|
||||
...state,
|
||||
...options,
|
||||
};
|
||||
// @ts-expect-error if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const optionsWithInstallationTokenFromState = Object.assign({ installationId }, options);
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, optionsWithInstallationTokenFromState);
|
||||
if (result) {
|
||||
const { token, createdAt, expiresAt, permissions, repositoryIds, repositoryNames, singleFileName, repositorySelection, } = result;
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositorySelection,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const request = customRequest || state.request;
|
||||
const { data: { token, expires_at: expiresAt, repositories, permissions: permissionsOptional, repository_selection: repositorySelectionOptional, single_file: singleFileName, }, } = await request("POST /app/installations/{installation_id}/access_tokens", {
|
||||
installation_id: installationId,
|
||||
repository_ids: options.repositoryIds,
|
||||
repositories: options.repositoryNames,
|
||||
permissions: options.permissions,
|
||||
mediaType: {
|
||||
previews: ["machine-man"],
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`,
|
||||
},
|
||||
});
|
||||
/* istanbul ignore next - permissions are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const permissions = permissionsOptional || {};
|
||||
/* istanbul ignore next - repositorySelection are optional per OpenAPI spec, but we think that is incorrect */
|
||||
const repositorySelection = repositorySelectionOptional || "all";
|
||||
const repositoryIds = repositories
|
||||
? repositories.map((r) => r.id)
|
||||
: void 0;
|
||||
const repositoryNames = repositories
|
||||
? repositories.map((repo) => repo.name)
|
||||
: void 0;
|
||||
const createdAt = new Date().toISOString();
|
||||
await set(state.cache, optionsWithInstallationTokenFromState, {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
return toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName,
|
||||
});
|
||||
}
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
// @ts-expect-error "oauth" is not supperted in types
|
||||
case "oauth":
|
||||
state.log.warn(
|
||||
// @ts-expect-error `log.warn()` expects string
|
||||
new Deprecation(`[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead`));
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation",
|
||||
});
|
||||
case "oauth-user":
|
||||
// @ts-expect-error TODO: infer correct auth options type based on type. authOptions should be typed as "WebFlowAuthOptions | OAuthAppDeviceFlowAuthOptions | GitHubAppDeviceFlowAuthOptions"
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
// @ts-expect-error type is "never" at this point
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
const PATHS = [
|
||||
"/app",
|
||||
"/app/hook/config",
|
||||
"/app/hook/deliveries",
|
||||
"/app/hook/deliveries/{delivery_id}",
|
||||
"/app/hook/deliveries/{delivery_id}/attempts",
|
||||
"/app/installations",
|
||||
"/app/installations/{installation_id}",
|
||||
"/app/installations/{installation_id}/access_tokens",
|
||||
"/app/installations/{installation_id}/suspended",
|
||||
"/marketplace_listing/accounts/{account_id}",
|
||||
"/marketplace_listing/plan",
|
||||
"/marketplace_listing/plans",
|
||||
"/marketplace_listing/plans/{plan_id}/accounts",
|
||||
"/marketplace_listing/stubbed/accounts/{account_id}",
|
||||
"/marketplace_listing/stubbed/plan",
|
||||
"/marketplace_listing/stubbed/plans",
|
||||
"/marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
||||
"/orgs/{org}/installation",
|
||||
"/repos/{owner}/{repo}/installation",
|
||||
"/users/{username}/installation",
|
||||
];
|
||||
// CREDIT: Simon Grondin (https://github.com/SGrondin)
|
||||
// https://github.com/octokit/plugin-throttling.js/blob/45c5d7f13b8af448a9dbca468d9c9150a73b3948/lib/route-matcher.js
|
||||
function routeMatcher(paths) {
|
||||
// EXAMPLE. For the following paths:
|
||||
/* [
|
||||
"/orgs/{org}/invitations",
|
||||
"/repos/{owner}/{repo}/collaborators/{username}"
|
||||
] */
|
||||
const regexes = paths.map((p) => p
|
||||
.split("/")
|
||||
.map((c) => (c.startsWith("{") ? "(?:.+?)" : c))
|
||||
.join("/"));
|
||||
// 'regexes' would contain:
|
||||
/* [
|
||||
'/orgs/(?:.+?)/invitations',
|
||||
'/repos/(?:.+?)/(?:.+?)/collaborators/(?:.+?)'
|
||||
] */
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`;
|
||||
// 'regex' would contain:
|
||||
/*
|
||||
^(?:(?:\/orgs\/(?:.+?)\/invitations)|(?:\/repos\/(?:.+?)\/(?:.+?)\/collaborators\/(?:.+?)))[^\/]*$
|
||||
|
||||
It may look scary, but paste it into https://www.debuggex.com/
|
||||
and it will make a lot more sense!
|
||||
*/
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
const REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url);
|
||||
}
|
||||
|
||||
const FIVE_SECONDS_IN_MS = 5 * 1000;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/) ||
|
||||
error.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/));
|
||||
}
|
||||
async function hook(state, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
const url = endpoint.url;
|
||||
// Do not intercept request to retrieve a new token
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
}
|
||||
catch (error) {
|
||||
// If there's an issue with the expiration, regenerate the token and try again.
|
||||
// Otherwise rethrow the error for upstream handling.
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
// If the date header is missing, we can't correct the system time skew.
|
||||
// Throw the error to be handled upstream.
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor((Date.parse(error.response.headers.date) -
|
||||
Date.parse(new Date().toString())) /
|
||||
1000);
|
||||
state.log.warn(error.message);
|
||||
state.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`);
|
||||
const { token } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff,
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (requiresBasicAuth(url)) {
|
||||
const authentication = await state.oauthApp({ type: "oauth-app" });
|
||||
endpoint.headers.authorization = authentication.headers.authorization;
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token, createdAt } = await getInstallationAuthentication(state,
|
||||
// @ts-expect-error TBD
|
||||
{}, request);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(state, request, endpoint, createdAt);
|
||||
}
|
||||
/**
|
||||
* Newly created tokens might not be accessible immediately after creation.
|
||||
* In case of a 401 response, we retry with an exponential delay until more
|
||||
* than five seconds pass since the creation of the token.
|
||||
*
|
||||
* @see https://github.com/octokit/auth-app.js/issues/65
|
||||
*/
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +new Date() - +new Date(createdAt);
|
||||
try {
|
||||
return await request(options);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status !== 401) {
|
||||
throw error;
|
||||
}
|
||||
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
||||
if (retries > 0) {
|
||||
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1000}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
++retries;
|
||||
const awaitTime = retries * 1000;
|
||||
state.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1000}s)`);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
|
||||
const VERSION = "4.0.9";
|
||||
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!Number.isFinite(+options.appId)) {
|
||||
throw new Error("[@octokit/auth-app] appId option must be a number or numeric string");
|
||||
}
|
||||
if (!options.privateKey) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error("[@octokit/auth-app] installationId is set to a falsy value");
|
||||
}
|
||||
const log = Object.assign({
|
||||
warn: console.warn.bind(console),
|
||||
}, options.log);
|
||||
const request$1 = options.request ||
|
||||
request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-app.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
const state = Object.assign({
|
||||
request: request$1,
|
||||
cache: getCache(),
|
||||
}, options, options.installationId
|
||||
? { installationId: Number(options.installationId) }
|
||||
: {}, {
|
||||
log,
|
||||
oauthApp: createOAuthAppAuth({
|
||||
clientType: "github-app",
|
||||
clientId: options.clientId || "",
|
||||
clientSecret: options.clientSecret || "",
|
||||
request: request$1,
|
||||
}),
|
||||
});
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
||||
|
||||
export { createAppAuth };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-app/dist-web/index.js.map
generated
vendored
1
node_modules/@octokit/auth-app/dist-web/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
58
node_modules/@octokit/auth-app/package.json
generated
vendored
58
node_modules/@octokit/auth-app/package.json
generated
vendored
@ -1,58 +0,0 @@
|
||||
{
|
||||
"name": "@octokit/auth-app",
|
||||
"description": "GitHub App authentication for JavaScript",
|
||||
"version": "4.0.9",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js",
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"repository": "github:octokit/auth-app.js",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-app": "^5.0.0",
|
||||
"@octokit/auth-oauth-user": "^2.0.0",
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/request-error": "^3.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"@types/lru-cache": "^5.1.0",
|
||||
"deprecation": "^2.3.1",
|
||||
"lru-cache": "^6.0.0",
|
||||
"universal-github-app-jwt": "^1.1.1",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.3.7",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@sinonjs/fake-timers": "^8.0.0",
|
||||
"@types/fetch-mock": "^7.3.1",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/sinonjs__fake-timers": "^8.0.0",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"prettier": "2.8.3",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
21
node_modules/@octokit/auth-oauth-app/LICENSE
generated
vendored
21
node_modules/@octokit/auth-oauth-app/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
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.
|
1054
node_modules/@octokit/auth-oauth-app/README.md
generated
vendored
1054
node_modules/@octokit/auth-oauth-app/README.md
generated
vendored
File diff suppressed because it is too large
Load Diff
97
node_modules/@octokit/auth-oauth-app/dist-node/index.js
generated
vendored
97
node_modules/@octokit/auth-oauth-app/dist-node/index.js
generated
vendored
@ -1,97 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var request = require('@octokit/request');
|
||||
var btoa = _interopDefault(require('btoa-lite'));
|
||||
var authOauthUser = require('@octokit/auth-oauth-user');
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
if (authOptions.type === "oauth-app") {
|
||||
return {
|
||||
type: "oauth-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
headers: {
|
||||
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`
|
||||
}
|
||||
};
|
||||
}
|
||||
if ("factory" in authOptions) {
|
||||
const {
|
||||
type,
|
||||
...options
|
||||
} = {
|
||||
...authOptions,
|
||||
...state
|
||||
};
|
||||
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
|
||||
return authOptions.factory(options);
|
||||
}
|
||||
const common = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.request,
|
||||
...authOptions
|
||||
};
|
||||
// TS: Look what you made me do
|
||||
const userAuth = state.clientType === "oauth-app" ? await authOauthUser.createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
}) : await authOauthUser.createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
});
|
||||
return userAuth();
|
||||
}
|
||||
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept OAuth Web/Device flow request
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (state.clientType === "github-app" && !authOauthUser.requiresBasicAuth(endpoint.url)) {
|
||||
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
|
||||
}
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
try {
|
||||
return await request(endpoint);
|
||||
} catch (error) {
|
||||
/* istanbul ignore if */
|
||||
if (error.status !== 401) throw error;
|
||||
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const VERSION = "5.0.5";
|
||||
|
||||
function createOAuthAppAuth(options) {
|
||||
const state = Object.assign({
|
||||
request: request.request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
}
|
||||
}),
|
||||
clientType: "oauth-app"
|
||||
}, options);
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, 'createOAuthUserAuth', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return authOauthUser.createOAuthUserAuth;
|
||||
}
|
||||
});
|
||||
exports.createOAuthAppAuth = createOAuthAppAuth;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-oauth-app/dist-node/index.js.map
generated
vendored
1
node_modules/@octokit/auth-oauth-app/dist-node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
40
node_modules/@octokit/auth-oauth-app/dist-src/auth.js
generated
vendored
40
node_modules/@octokit/auth-oauth-app/dist-src/auth.js
generated
vendored
@ -1,40 +0,0 @@
|
||||
import btoa from "btoa-lite";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export async function auth(state, authOptions) {
|
||||
if (authOptions.type === "oauth-app") {
|
||||
return {
|
||||
type: "oauth-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
headers: {
|
||||
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
if ("factory" in authOptions) {
|
||||
const { type, ...options } = {
|
||||
...authOptions,
|
||||
...state,
|
||||
};
|
||||
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
|
||||
return authOptions.factory(options);
|
||||
}
|
||||
const common = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.request,
|
||||
...authOptions,
|
||||
};
|
||||
// TS: Look what you made me do
|
||||
const userAuth = state.clientType === "oauth-app"
|
||||
? await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType,
|
||||
})
|
||||
: await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType,
|
||||
});
|
||||
return userAuth();
|
||||
}
|
24
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
24
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
@ -1,24 +0,0 @@
|
||||
import btoa from "btoa-lite";
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
export async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept OAuth Web/Device flow request
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
|
||||
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
|
||||
}
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
try {
|
||||
return await request(endpoint);
|
||||
}
|
||||
catch (error) {
|
||||
/* istanbul ignore if */
|
||||
if (error.status !== 401)
|
||||
throw error;
|
||||
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
|
||||
throw error;
|
||||
}
|
||||
}
|
20
node_modules/@octokit/auth-oauth-app/dist-src/index.js
generated
vendored
20
node_modules/@octokit/auth-oauth-app/dist-src/index.js
generated
vendored
@ -1,20 +0,0 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request } from "@octokit/request";
|
||||
import { auth } from "./auth";
|
||||
import { hook } from "./hook";
|
||||
import { VERSION } from "./version";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export function createOAuthAppAuth(options) {
|
||||
const state = Object.assign({
|
||||
request: request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
}),
|
||||
clientType: "oauth-app",
|
||||
}, options);
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
1
node_modules/@octokit/auth-oauth-app/dist-src/types.js
generated
vendored
1
node_modules/@octokit/auth-oauth-app/dist-src/types.js
generated
vendored
@ -1 +0,0 @@
|
||||
export {};
|
1
node_modules/@octokit/auth-oauth-app/dist-src/version.js
generated
vendored
1
node_modules/@octokit/auth-oauth-app/dist-src/version.js
generated
vendored
@ -1 +0,0 @@
|
||||
export const VERSION = "5.0.5";
|
18
node_modules/@octokit/auth-oauth-app/dist-types/auth.d.ts
generated
vendored
18
node_modules/@octokit/auth-oauth-app/dist-types/auth.d.ts
generated
vendored
@ -1,18 +0,0 @@
|
||||
import { OAuthAppState, GitHubAppState, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, FactoryOAuthAppWebFlow, FactoryOAuthAppDeviceFlow, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "./types";
|
||||
export declare function auth(state: OAuthAppState | GitHubAppState, authOptions: AppAuthOptions): Promise<AppAuthentication>;
|
||||
export declare function auth(state: OAuthAppState, authOptions: WebFlowAuthOptions): Promise<OAuthAppUserAuthentication>;
|
||||
export declare function auth<T = unknown>(state: OAuthAppState, authOptions: WebFlowAuthOptions & {
|
||||
factory: FactoryOAuthAppWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
export declare function auth(state: OAuthAppState, authOptions: OAuthAppDeviceFlowAuthOptions): Promise<OAuthAppUserAuthentication>;
|
||||
export declare function auth<T = unknown>(state: OAuthAppState, authOptions: OAuthAppDeviceFlowAuthOptions & {
|
||||
factory: FactoryOAuthAppDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
export declare function auth(state: GitHubAppState, authOptions: WebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
export declare function auth<T = unknown>(state: GitHubAppState, authOptions: WebFlowAuthOptions & {
|
||||
factory: FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
export declare function auth(state: GitHubAppState, authOptions: GitHubAppDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
export declare function auth<T = unknown>(state: GitHubAppState, authOptions: GitHubAppDeviceFlowAuthOptions & {
|
||||
factory: FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
3
node_modules/@octokit/auth-oauth-app/dist-types/hook.d.ts
generated
vendored
3
node_modules/@octokit/auth-oauth-app/dist-types/hook.d.ts
generated
vendored
@ -1,3 +0,0 @@
|
||||
import { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
|
||||
import { OAuthAppState, GitHubAppState } from "./types";
|
||||
export declare function hook(state: OAuthAppState | GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
5
node_modules/@octokit/auth-oauth-app/dist-types/index.d.ts
generated
vendored
5
node_modules/@octokit/auth-oauth-app/dist-types/index.d.ts
generated
vendored
@ -1,5 +0,0 @@
|
||||
import { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAuthInterface } from "./types";
|
||||
export { OAuthAppStrategyOptions, GitHubAppStrategyOptions, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, OAuthAppAuthInterface, GitHubAuthInterface, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, } from "./types";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export declare function createOAuthAppAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
|
||||
export declare function createOAuthAppAuth(options: GitHubAppStrategyOptions): GitHubAuthInterface;
|
98
node_modules/@octokit/auth-oauth-app/dist-types/types.d.ts
generated
vendored
98
node_modules/@octokit/auth-oauth-app/dist-types/types.d.ts
generated
vendored
@ -1,98 +0,0 @@
|
||||
import { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
|
||||
import * as AuthOAuthUser from "@octokit/auth-oauth-user";
|
||||
import * as DeviceTypes from "@octokit/auth-oauth-device";
|
||||
export type ClientType = "oauth-app" | "github-app";
|
||||
export type OAuthAppStrategyOptions = {
|
||||
clientType?: "oauth-app";
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
request?: RequestInterface;
|
||||
};
|
||||
export type GitHubAppStrategyOptions = {
|
||||
clientType: "github-app";
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
request?: RequestInterface;
|
||||
};
|
||||
export type AppAuthOptions = {
|
||||
type: "oauth-app";
|
||||
};
|
||||
export type WebFlowAuthOptions = {
|
||||
type: "oauth-user";
|
||||
code: string;
|
||||
redirectUrl?: string;
|
||||
state?: string;
|
||||
};
|
||||
export type OAuthAppDeviceFlowAuthOptions = {
|
||||
type: "oauth-user";
|
||||
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
||||
scopes?: string[];
|
||||
};
|
||||
export type GitHubAppDeviceFlowAuthOptions = {
|
||||
type: "oauth-user";
|
||||
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
||||
};
|
||||
export type AppAuthentication = {
|
||||
type: "oauth-app";
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
clientType: ClientType;
|
||||
headers: {
|
||||
authorization: string;
|
||||
};
|
||||
};
|
||||
export type OAuthAppUserAuthentication = AuthOAuthUser.OAuthAppAuthentication;
|
||||
export type GitHubAppUserAuthentication = AuthOAuthUser.GitHubAppAuthentication;
|
||||
export type GitHubAppUserAuthenticationWithExpiration = AuthOAuthUser.GitHubAppAuthenticationWithExpiration;
|
||||
export type FactoryOAuthAppWebFlowOptions = OAuthAppStrategyOptions & Omit<WebFlowAuthOptions, "type"> & {
|
||||
clientType: "oauth-app";
|
||||
};
|
||||
export type FactoryOAuthAppDeviceFlowOptions = OAuthAppStrategyOptions & Omit<OAuthAppDeviceFlowAuthOptions, "type"> & {
|
||||
clientType: "oauth-app";
|
||||
};
|
||||
export type FactoryGitHubAppWebFlowOptions = GitHubAppStrategyOptions & Omit<WebFlowAuthOptions, "type">;
|
||||
export type FactoryGitHubAppDeviceFlowOptions = GitHubAppStrategyOptions & Omit<GitHubAppDeviceFlowAuthOptions, "type">;
|
||||
export interface FactoryOAuthAppWebFlow<T> {
|
||||
(options: FactoryOAuthAppWebFlowOptions): T;
|
||||
}
|
||||
export interface FactoryOAuthAppDeviceFlow<T> {
|
||||
(options: FactoryOAuthAppDeviceFlowOptions): T;
|
||||
}
|
||||
export interface FactoryGitHubWebFlow<T> {
|
||||
(options: FactoryGitHubAppWebFlowOptions): T;
|
||||
}
|
||||
export interface FactoryGitHubDeviceFlow<T> {
|
||||
(options: FactoryGitHubAppDeviceFlowOptions): T;
|
||||
}
|
||||
export interface OAuthAppAuthInterface {
|
||||
(options: AppAuthOptions): Promise<AppAuthentication>;
|
||||
<T = unknown>(options: WebFlowAuthOptions & {
|
||||
factory: FactoryOAuthAppWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
<T = unknown>(options: OAuthAppDeviceFlowAuthOptions & {
|
||||
factory: FactoryOAuthAppDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
(options: WebFlowAuthOptions): Promise<OAuthAppUserAuthentication>;
|
||||
(options: OAuthAppDeviceFlowAuthOptions): Promise<OAuthAppUserAuthentication>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
||||
}
|
||||
export interface GitHubAuthInterface {
|
||||
(options?: AppAuthOptions): Promise<AppAuthentication>;
|
||||
<T = unknown>(options: WebFlowAuthOptions & {
|
||||
factory: FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
<T = unknown>(options: GitHubAppDeviceFlowAuthOptions & {
|
||||
factory: FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
(options?: WebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
(options?: GitHubAppDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
||||
}
|
||||
export type OAuthAppState = OAuthAppStrategyOptions & {
|
||||
clientType: "oauth-app";
|
||||
request: RequestInterface;
|
||||
};
|
||||
export type GitHubAppState = GitHubAppStrategyOptions & {
|
||||
clientType: "github-app";
|
||||
request: RequestInterface;
|
||||
};
|
1
node_modules/@octokit/auth-oauth-app/dist-types/version.d.ts
generated
vendored
1
node_modules/@octokit/auth-oauth-app/dist-types/version.d.ts
generated
vendored
@ -1 +0,0 @@
|
||||
export declare const VERSION = "5.0.5";
|
87
node_modules/@octokit/auth-oauth-app/dist-web/index.js
generated
vendored
87
node_modules/@octokit/auth-oauth-app/dist-web/index.js
generated
vendored
@ -1,87 +0,0 @@
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
import { request } from '@octokit/request';
|
||||
import btoa from 'btoa-lite';
|
||||
import { createOAuthUserAuth, requiresBasicAuth } from '@octokit/auth-oauth-user';
|
||||
export { createOAuthUserAuth } from '@octokit/auth-oauth-user';
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
if (authOptions.type === "oauth-app") {
|
||||
return {
|
||||
type: "oauth-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
headers: {
|
||||
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
if ("factory" in authOptions) {
|
||||
const { type, ...options } = {
|
||||
...authOptions,
|
||||
...state,
|
||||
};
|
||||
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
|
||||
return authOptions.factory(options);
|
||||
}
|
||||
const common = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.request,
|
||||
...authOptions,
|
||||
};
|
||||
// TS: Look what you made me do
|
||||
const userAuth = state.clientType === "oauth-app"
|
||||
? await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType,
|
||||
})
|
||||
: await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType,
|
||||
});
|
||||
return userAuth();
|
||||
}
|
||||
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept OAuth Web/Device flow request
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
|
||||
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
|
||||
}
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
try {
|
||||
return await request(endpoint);
|
||||
}
|
||||
catch (error) {
|
||||
/* istanbul ignore if */
|
||||
if (error.status !== 401)
|
||||
throw error;
|
||||
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const VERSION = "5.0.5";
|
||||
|
||||
function createOAuthAppAuth(options) {
|
||||
const state = Object.assign({
|
||||
request: request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
}),
|
||||
clientType: "oauth-app",
|
||||
}, options);
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
||||
|
||||
export { createOAuthAppAuth };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-oauth-app/dist-web/index.js.map
generated
vendored
1
node_modules/@octokit/auth-oauth-app/dist-web/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
54
node_modules/@octokit/auth-oauth-app/package.json
generated
vendored
54
node_modules/@octokit/auth-oauth-app/package.json
generated
vendored
@ -1,54 +0,0 @@
|
||||
{
|
||||
"name": "@octokit/auth-oauth-app",
|
||||
"description": "GitHub OAuth App authentication for JavaScript",
|
||||
"version": "5.0.5",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js",
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"oauth",
|
||||
"api"
|
||||
],
|
||||
"repository": "github:octokit/auth-oauth-app.js",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-device": "^4.0.0",
|
||||
"@octokit/auth-oauth-user": "^2.0.0",
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"@types/btoa-lite": "^1.0.0",
|
||||
"btoa-lite": "^1.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^4.0.0",
|
||||
"@pika/pack": "^0.3.7",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/fetch-mock": "^7.3.1",
|
||||
"@types/jest": "^29.0.0",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"prettier": "2.8.3",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
9
node_modules/@octokit/auth-oauth-device/LICENSE
generated
vendored
9
node_modules/@octokit/auth-oauth-device/LICENSE
generated
vendored
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 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.
|
656
node_modules/@octokit/auth-oauth-device/README.md
generated
vendored
656
node_modules/@octokit/auth-oauth-device/README.md
generated
vendored
@ -1,656 +0,0 @@
|
||||
# auth-oauth-device.js
|
||||
|
||||
> GitHub OAuth Device authentication strategy for JavaScript
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/auth-oauth-device)
|
||||
[](https://github.com/octokit/auth-oauth-device.js/actions?query=workflow%3ATest+branch%3Amain)
|
||||
|
||||
`@octokit/auth-oauth-device` is implementing one of [GitHub’s OAuth Device Flow](https://docs.github.com/en/developers/apps/authorizing-oauth-apps#device-flow).
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [For OAuth Apps](#for-oauth-apps)
|
||||
- [For GitHub Apps](#for-github-apps)
|
||||
- [`createOAuthDeviceAuth(options)`](#createoauthdeviceauthoptions)
|
||||
- [`auth(options)`](#authoptions)
|
||||
- [Authentication object](#authentication-object)
|
||||
- [OAuth APP user authentication](#oauth-app-user-authentication)
|
||||
- [GitHub APP user authentication with expiring tokens disabled](#github-app-user-authentication-with-expiring-tokens-disabled)
|
||||
- [GitHub APP user authentication with expiring tokens enabled](#github-app-user-authentication-with-expiring-tokens-enabled)
|
||||
- [`auth.hook(request, route, parameters)` or `auth.hook(request, options)`](#authhookrequest-route-parameters-or-authhookrequest-options)
|
||||
- [Types](#types)
|
||||
- [How it works](#how-it-works)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
|
||||
Browsers
|
||||
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/auth-oauth-device` directly from [cdn.pika.dev](https://cdn.pika.dev)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { createOAuthDeviceAuth } from "https://cdn.pika.dev/@octokit/auth-oauth-device";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
|
||||
Node
|
||||
|
||||
</th><td>
|
||||
|
||||
Install with `npm install @octokit/core @octokit/auth-oauth-device`
|
||||
|
||||
```js
|
||||
const { createOAuthDeviceAuth } = require("@octokit/auth-oauth-device");
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### For OAuth Apps
|
||||
|
||||
```js
|
||||
const auth = createOAuthDeviceAuth({
|
||||
clientType: "oauth-app",
|
||||
clientId: "1234567890abcdef1234",
|
||||
scopes: ["public_repo"],
|
||||
onVerification(verification) {
|
||||
// verification example
|
||||
// {
|
||||
// device_code: "3584d83530557fdd1f46af8289938c8ef79f9dc5",
|
||||
// user_code: "WDJB-MJHT",
|
||||
// verification_uri: "https://github.com/login/device",
|
||||
// expires_in: 900,
|
||||
// interval: 5,
|
||||
// };
|
||||
|
||||
console.log("Open %s", verification.verification_uri);
|
||||
console.log("Enter code: %s", verification.user_code);
|
||||
},
|
||||
});
|
||||
|
||||
const tokenAuthentication = await auth({
|
||||
type: "oauth",
|
||||
});
|
||||
// resolves with
|
||||
// {
|
||||
// type: "token",
|
||||
// tokenType: "oauth",
|
||||
// clientType: "oauth-app",
|
||||
// clientId: "1234567890abcdef1234",
|
||||
// token: "...", /* the created oauth token */
|
||||
// scopes: [] /* depend on request scopes by OAuth app */
|
||||
// }
|
||||
```
|
||||
|
||||
### For GitHub Apps
|
||||
|
||||
GitHub Apps do not support `scopes`. Client IDs of GitHub Apps have a `lv1.` prefix. If the GitHub App has expiring user tokens enabled, the resulting `authentication` object has extra properties related to expiration and refreshing the token.
|
||||
|
||||
```js
|
||||
const auth = createOAuthDeviceAuth({
|
||||
clientType: "github-app",
|
||||
clientId: "lv1.1234567890abcdef",
|
||||
onVerification(verification) {
|
||||
// verification example
|
||||
// {
|
||||
// device_code: "3584d83530557fdd1f46af8289938c8ef79f9dc5",
|
||||
// user_code: "WDJB-MJHT",
|
||||
// verification_uri: "https://github.com/login/device",
|
||||
// expires_in: 900,
|
||||
// interval: 5,
|
||||
// };
|
||||
|
||||
console.log("Open %s", verification.verification_uri);
|
||||
console.log("Enter code: %s", verification.user_code);
|
||||
},
|
||||
});
|
||||
|
||||
const tokenAuthentication = await auth({
|
||||
type: "oauth",
|
||||
});
|
||||
// resolves with
|
||||
// {
|
||||
// type: "token",
|
||||
// tokenType: "oauth",
|
||||
// clientType: "github-app",
|
||||
// clientId: "lv1.1234567890abcdef",
|
||||
// token: "...", /* the created oauth token */
|
||||
// }
|
||||
// or if expiring user tokens are enabled
|
||||
// {
|
||||
// type: "token",
|
||||
// tokenType: "oauth",
|
||||
// clientType: "github-app",
|
||||
// clientId: "lv1.1234567890abcdef",
|
||||
// token: "...", /* the created oauth token */
|
||||
// refreshToken: "...",
|
||||
// expiresAt: "2022-01-01T08:00:0.000Z",
|
||||
// refreshTokenExpiresAt: "2021-07-01T00:00:0.000Z",
|
||||
// }
|
||||
```
|
||||
|
||||
## `createOAuthDeviceAuth(options)`
|
||||
|
||||
The `createOAuthDeviceAuth` method accepts a single `options` parameter
|
||||
|
||||
<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>clientId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required</strong>. Find your OAuth app’s <code>Client ID</code> in your account’s developer settings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>onVerification</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>function</code>
|
||||
</th>
|
||||
<td>
|
||||
<strong>Required</strong>. A function that is called once the device and user codes were retrieved
|
||||
|
||||
The `onVerification()` callback can be used to pause until the user completes step 2, which might result in a better user experience.
|
||||
|
||||
```js
|
||||
const auth = createOAuthDeviceAuth({
|
||||
clientId: "1234567890abcdef1234",
|
||||
onVerification(verification) {
|
||||
console.log("Open %s", verification.verification_uri);
|
||||
console.log("Enter code: %s", verification.user_code);
|
||||
|
||||
await prompt("press enter when you are ready to continue");
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
Must be either `oauth-app` or `github-app`. Defaults to `oauth-app`.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>request</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>function</code>
|
||||
</th>
|
||||
<td>
|
||||
You can pass in your own <a href="https://github.com/octokit/request.js"><code>@octokit/request</code></a> instance. For usage with enterprise, set <code>baseUrl</code> to the API root endpoint. Example:
|
||||
|
||||
```js
|
||||
const { request } = require("@octokit/request");
|
||||
createOAuthDeviceAuth({
|
||||
clientId: "1234567890abcdef1234",
|
||||
clientSecret: "secret",
|
||||
request: request.defaults({
|
||||
baseUrl: "https://ghe.my-company.com/api/v3",
|
||||
}),
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>scopes</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>array of strings</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
Only relavant if `clientType` is set to `"oauth-app"`.
|
||||
|
||||
Array of scope names enabled for the token. Defaults to `[]`. See [available scopes](https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes).
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## `auth(options)`
|
||||
|
||||
The async `auth()` method returned by `createOAuthDeviceAuth(options)` accepts the following options
|
||||
|
||||
<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>
|
||||
<strong>Required.</strong> Must be set to <code>"oauth"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>scopes</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>array of strings</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
Only relevant if the `clientType` strategy options was set to `"oauth-app"`
|
||||
|
||||
Array of scope names enabled for the token. Defaults to what was set in the [strategy options](#createoauthdeviceauthoptions). See <a href="https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes">available scopes</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>refresh</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>boolean</code>
|
||||
</th>
|
||||
<td>
|
||||
|
||||
Defaults to `false`. When set to `false`, calling `auth(options)` will resolve with a token that was previously created for the same scopes if it exists. If set to `true` a new token will always be created.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Authentication object
|
||||
|
||||
The async `auth(options)` method resolves to one of three possible objects
|
||||
|
||||
1. OAuth APP user authentication
|
||||
1. GitHub APP user authentication with expiring tokens disabled
|
||||
1. GitHub APP user authentication with expiring tokens enabled
|
||||
|
||||
The differences are
|
||||
|
||||
1. `scopes` is only present for OAuth Apps
|
||||
2. `refreshToken`, `expiresAt`, `refreshTokenExpiresAt` are only present for GitHub Apps, and only if token expiration is enabled
|
||||
|
||||
### OAuth APP user authentication
|
||||
|
||||
<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>tokenType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"oauth"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"github-app"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The app's <code>Client ID</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>token</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The personal access token
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>scopes</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>array of strings</code>
|
||||
</th>
|
||||
<td>
|
||||
array of scope names enabled for the token
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### GitHub APP user authentication with expiring tokens disabled
|
||||
|
||||
<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>tokenType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"oauth"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"github-app"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The app's <code>Client ID</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>token</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The personal access token
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### GitHub APP user authentication with expiring tokens enabled
|
||||
|
||||
<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>tokenType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"oauth"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"github-app"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>clientId</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The app's <code>Client ID</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>token</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The user access token
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>refreshToken</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The refresh token
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>expiresAt</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
Date timestamp in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString">ISO 8601</a> standard. Example: <code>2022-01-01T08:00:0.000Z</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>refreshTokenExpiresAt</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
Date timestamp in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString">ISO 8601</a> standard. Example: <code>2021-07-01T00:00:0.000Z</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## `auth.hook(request, route, parameters)` or `auth.hook(request, options)`
|
||||
|
||||
`auth.hook()` hooks directly into the request life cycle. It amends the request to authenticate correctly based on the request URL.
|
||||
|
||||
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: user } = await auth.hook(request, "GET /user");
|
||||
```
|
||||
|
||||
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: user } = await requestWithAuth("GET /user");
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
```ts
|
||||
import {
|
||||
OAuthAppStrategyOptions,
|
||||
OAuthAppAuthOptions,
|
||||
OAuthAppAuthentication,
|
||||
GitHubAppStrategyOptions,
|
||||
GitHubAppAuthOptions,
|
||||
GitHubAppAuthentication,
|
||||
GitHubAppAuthenticationWithExpiration,
|
||||
} from "@octokit/auth-oauth-device";
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
GitHub's OAuth Device flow is different from the web flow in two ways
|
||||
|
||||
1. It does not require a URL redirect, which makes it great for devices and CLI apps
|
||||
2. It does not require the OAuth client secret, which means there is no user-owned server component required.
|
||||
|
||||
The flow has 3 parts (see [GitHub documentation](https://docs.github.com/en/developers/apps/authorizing-oauth-apps#device-flow))
|
||||
|
||||
1. `@octokit/auth-oauth-device` requests a device and user code
|
||||
2. Then the user has to open https://github.com/login/device (or it's GitHub Enterprise Server equivalent) and enter the user code
|
||||
3. While the user enters the code, `@octokit/auth-oauth-device` is sending requests in the background to retrieve the OAuth access token. Once the user completed step 2, the request will succeed and the token will be returned
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
145
node_modules/@octokit/auth-oauth-device/dist-node/index.js
generated
vendored
145
node_modules/@octokit/auth-oauth-device/dist-node/index.js
generated
vendored
@ -1,145 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var request = require('@octokit/request');
|
||||
var oauthMethods = require('@octokit/oauth-methods');
|
||||
|
||||
async function getOAuthAccessToken(state, options) {
|
||||
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
||||
if (cachedAuthentication) return cachedAuthentication;
|
||||
// Step 1: Request device and user codes
|
||||
// https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-1-app-requests-the-device-and-user-verification-codes-from-github
|
||||
const {
|
||||
data: verification
|
||||
} = await oauthMethods.createDeviceCode({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
request: options.request || state.request,
|
||||
// @ts-expect-error the extra code to make TS happy is not worth it
|
||||
scopes: options.auth.scopes || state.scopes
|
||||
});
|
||||
// Step 2: User must enter the user code on https://github.com/login/device
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-2-prompt-the-user-to-enter-the-user-code-in-a-browser
|
||||
await state.onVerification(verification);
|
||||
// Step 3: Exchange device code for access token
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-3-app-polls-github-to-check-if-the-user-authorized-the-device
|
||||
const authentication = await waitForAccessToken(options.request || state.request, state.clientId, state.clientType, verification);
|
||||
state.authentication = authentication;
|
||||
return authentication;
|
||||
}
|
||||
function getCachedAuthentication(state, auth) {
|
||||
if (auth.refresh === true) return false;
|
||||
if (!state.authentication) return false;
|
||||
if (state.clientType === "github-app") {
|
||||
return state.authentication;
|
||||
}
|
||||
const authentication = state.authentication;
|
||||
const newScope = ("scopes" in auth && auth.scopes || state.scopes).join(" ");
|
||||
const currentScope = authentication.scopes.join(" ");
|
||||
return newScope === currentScope ? authentication : false;
|
||||
}
|
||||
async function wait(seconds) {
|
||||
await new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
async function waitForAccessToken(request, clientId, clientType, verification) {
|
||||
try {
|
||||
const options = {
|
||||
clientId,
|
||||
request,
|
||||
code: verification.device_code
|
||||
};
|
||||
// WHY TYPESCRIPT WHY ARE YOU DOING THIS TO ME
|
||||
const {
|
||||
authentication
|
||||
} = clientType === "oauth-app" ? await oauthMethods.exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "oauth-app"
|
||||
}) : await oauthMethods.exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "github-app"
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication
|
||||
};
|
||||
} catch (error) {
|
||||
// istanbul ignore if
|
||||
// @ts-ignore
|
||||
if (!error.response) throw error;
|
||||
// @ts-ignore
|
||||
const errorType = error.response.data.error;
|
||||
if (errorType === "authorization_pending") {
|
||||
await wait(verification.interval);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
if (errorType === "slow_down") {
|
||||
await wait(verification.interval + 5);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
return getOAuthAccessToken(state, {
|
||||
auth: authOptions
|
||||
});
|
||||
}
|
||||
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept request to retrieve codes or token
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
const {
|
||||
token
|
||||
} = await getOAuthAccessToken(state, {
|
||||
request,
|
||||
auth: {
|
||||
type: "oauth"
|
||||
}
|
||||
});
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
const VERSION = "4.0.4";
|
||||
|
||||
function createOAuthDeviceAuth(options) {
|
||||
const requestWithDefaults = options.request || request.request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-device.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
}
|
||||
});
|
||||
const {
|
||||
request: request$1 = requestWithDefaults,
|
||||
...otherOptions
|
||||
} = options;
|
||||
const state = options.clientType === "github-app" ? {
|
||||
...otherOptions,
|
||||
clientType: "github-app",
|
||||
request: request$1
|
||||
} : {
|
||||
...otherOptions,
|
||||
clientType: "oauth-app",
|
||||
request: request$1,
|
||||
scopes: options.scopes || []
|
||||
};
|
||||
if (!options.clientId) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
if (!options.onVerification) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
// @ts-ignore too much for tsc / ts-jest ¯\_(ツ)_/¯
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
|
||||
exports.createOAuthDeviceAuth = createOAuthDeviceAuth;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-oauth-device/dist-node/index.js.map
generated
vendored
1
node_modules/@octokit/auth-oauth-device/dist-node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
node_modules/@octokit/auth-oauth-device/dist-src/auth.js
generated
vendored
6
node_modules/@octokit/auth-oauth-device/dist-src/auth.js
generated
vendored
@ -1,6 +0,0 @@
|
||||
import { getOAuthAccessToken } from "./get-oauth-access-token";
|
||||
export async function auth(state, authOptions) {
|
||||
return getOAuthAccessToken(state, {
|
||||
auth: authOptions,
|
||||
});
|
||||
}
|
80
node_modules/@octokit/auth-oauth-device/dist-src/get-oauth-access-token.js
generated
vendored
80
node_modules/@octokit/auth-oauth-device/dist-src/get-oauth-access-token.js
generated
vendored
@ -1,80 +0,0 @@
|
||||
import { createDeviceCode, exchangeDeviceCode } from "@octokit/oauth-methods";
|
||||
export async function getOAuthAccessToken(state, options) {
|
||||
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
||||
if (cachedAuthentication)
|
||||
return cachedAuthentication;
|
||||
// Step 1: Request device and user codes
|
||||
// https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-1-app-requests-the-device-and-user-verification-codes-from-github
|
||||
const { data: verification } = await createDeviceCode({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
request: options.request || state.request,
|
||||
// @ts-expect-error the extra code to make TS happy is not worth it
|
||||
scopes: options.auth.scopes || state.scopes,
|
||||
});
|
||||
// Step 2: User must enter the user code on https://github.com/login/device
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-2-prompt-the-user-to-enter-the-user-code-in-a-browser
|
||||
await state.onVerification(verification);
|
||||
// Step 3: Exchange device code for access token
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-3-app-polls-github-to-check-if-the-user-authorized-the-device
|
||||
const authentication = await waitForAccessToken(options.request || state.request, state.clientId, state.clientType, verification);
|
||||
state.authentication = authentication;
|
||||
return authentication;
|
||||
}
|
||||
function getCachedAuthentication(state, auth) {
|
||||
if (auth.refresh === true)
|
||||
return false;
|
||||
if (!state.authentication)
|
||||
return false;
|
||||
if (state.clientType === "github-app") {
|
||||
return state.authentication;
|
||||
}
|
||||
const authentication = state.authentication;
|
||||
const newScope = (("scopes" in auth && auth.scopes) || state.scopes).join(" ");
|
||||
const currentScope = authentication.scopes.join(" ");
|
||||
return newScope === currentScope ? authentication : false;
|
||||
}
|
||||
async function wait(seconds) {
|
||||
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
async function waitForAccessToken(request, clientId, clientType, verification) {
|
||||
try {
|
||||
const options = {
|
||||
clientId,
|
||||
request,
|
||||
code: verification.device_code,
|
||||
};
|
||||
// WHY TYPESCRIPT WHY ARE YOU DOING THIS TO ME
|
||||
const { authentication } = clientType === "oauth-app"
|
||||
? await exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "oauth-app",
|
||||
})
|
||||
: await exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "github-app",
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
// istanbul ignore if
|
||||
// @ts-ignore
|
||||
if (!error.response)
|
||||
throw error;
|
||||
// @ts-ignore
|
||||
const errorType = error.response.data.error;
|
||||
if (errorType === "authorization_pending") {
|
||||
await wait(verification.interval);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
if (errorType === "slow_down") {
|
||||
await wait(verification.interval + 5);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
14
node_modules/@octokit/auth-oauth-device/dist-src/hook.js
generated
vendored
14
node_modules/@octokit/auth-oauth-device/dist-src/hook.js
generated
vendored
@ -1,14 +0,0 @@
|
||||
import { getOAuthAccessToken } from "./get-oauth-access-token";
|
||||
export async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept request to retrieve codes or token
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token } = await getOAuthAccessToken(state, {
|
||||
request,
|
||||
auth: { type: "oauth" },
|
||||
});
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
36
node_modules/@octokit/auth-oauth-device/dist-src/index.js
generated
vendored
36
node_modules/@octokit/auth-oauth-device/dist-src/index.js
generated
vendored
@ -1,36 +0,0 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
import { auth } from "./auth";
|
||||
import { hook } from "./hook";
|
||||
import { VERSION } from "./version";
|
||||
export function createOAuthDeviceAuth(options) {
|
||||
const requestWithDefaults = options.request ||
|
||||
octokitRequest.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-device.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
const { request = requestWithDefaults, ...otherOptions } = options;
|
||||
const state = options.clientType === "github-app"
|
||||
? {
|
||||
...otherOptions,
|
||||
clientType: "github-app",
|
||||
request,
|
||||
}
|
||||
: {
|
||||
...otherOptions,
|
||||
clientType: "oauth-app",
|
||||
request,
|
||||
scopes: options.scopes || [],
|
||||
};
|
||||
if (!options.clientId) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
if (!options.onVerification) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
// @ts-ignore too much for tsc / ts-jest ¯\_(ツ)_/¯
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
1
node_modules/@octokit/auth-oauth-device/dist-src/types.js
generated
vendored
1
node_modules/@octokit/auth-oauth-device/dist-src/types.js
generated
vendored
@ -1 +0,0 @@
|
||||
export {};
|
1
node_modules/@octokit/auth-oauth-device/dist-src/version.js
generated
vendored
1
node_modules/@octokit/auth-oauth-device/dist-src/version.js
generated
vendored
@ -1 +0,0 @@
|
||||
export const VERSION = "4.0.4";
|
2
node_modules/@octokit/auth-oauth-device/dist-types/auth.d.ts
generated
vendored
2
node_modules/@octokit/auth-oauth-device/dist-types/auth.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
||||
import { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, OAuthAppState, GitHubAppState } from "./types";
|
||||
export declare function auth(state: OAuthAppState | GitHubAppState, authOptions: OAuthAppAuthOptions | GitHubAppAuthOptions): Promise<OAuthAppAuthentication | GitHubAppAuthentication>;
|
6
node_modules/@octokit/auth-oauth-device/dist-types/get-oauth-access-token.d.ts
generated
vendored
6
node_modules/@octokit/auth-oauth-device/dist-types/get-oauth-access-token.d.ts
generated
vendored
@ -1,6 +0,0 @@
|
||||
import { RequestInterface } from "@octokit/types";
|
||||
import { OAuthAppState, GitHubAppState, OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication } from "./types";
|
||||
export declare function getOAuthAccessToken(state: OAuthAppState | GitHubAppState, options: {
|
||||
request?: RequestInterface;
|
||||
auth: OAuthAppAuthOptions | GitHubAppAuthOptions;
|
||||
}): Promise<OAuthAppAuthentication | GitHubAppAuthentication>;
|
3
node_modules/@octokit/auth-oauth-device/dist-types/hook.d.ts
generated
vendored
3
node_modules/@octokit/auth-oauth-device/dist-types/hook.d.ts
generated
vendored
@ -1,3 +0,0 @@
|
||||
import { RequestInterface, OctokitResponse, EndpointOptions, RequestParameters, Route } from "@octokit/types";
|
||||
import { OAuthAppState, GitHubAppState } from "./types";
|
||||
export declare function hook(state: OAuthAppState | GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
4
node_modules/@octokit/auth-oauth-device/dist-types/index.d.ts
generated
vendored
4
node_modules/@octokit/auth-oauth-device/dist-types/index.d.ts
generated
vendored
@ -1,4 +0,0 @@
|
||||
import { GitHubAppAuthInterface, GitHubAppStrategyOptions, OAuthAppAuthInterface, OAuthAppStrategyOptions } from "./types";
|
||||
export { OAuthAppStrategyOptions, OAuthAppAuthOptions, OAuthAppAuthentication, GitHubAppStrategyOptions, GitHubAppAuthOptions, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types";
|
||||
export declare function createOAuthDeviceAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
|
||||
export declare function createOAuthDeviceAuth(options: GitHubAppStrategyOptions): GitHubAppAuthInterface;
|
68
node_modules/@octokit/auth-oauth-device/dist-types/types.d.ts
generated
vendored
68
node_modules/@octokit/auth-oauth-device/dist-types/types.d.ts
generated
vendored
@ -1,68 +0,0 @@
|
||||
import { RequestInterface, Route, EndpointOptions, RequestParameters, OctokitResponse } from "@octokit/types";
|
||||
import * as OAuthMethodsTypes from "@octokit/oauth-methods";
|
||||
export type ClientType = "oauth-app" | "github-app";
|
||||
export type OAuthAppStrategyOptions = {
|
||||
clientId: string;
|
||||
clientType?: "oauth-app";
|
||||
onVerification: OnVerificationCallback;
|
||||
scopes?: string[];
|
||||
request?: RequestInterface;
|
||||
};
|
||||
export type GitHubAppStrategyOptions = {
|
||||
clientId: string;
|
||||
clientType: "github-app";
|
||||
onVerification: OnVerificationCallback;
|
||||
request?: RequestInterface;
|
||||
};
|
||||
export interface OAuthAppAuthInterface {
|
||||
(options: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
||||
}
|
||||
export interface GitHubAppAuthInterface {
|
||||
(options: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;
|
||||
}
|
||||
export type OAuthAppAuthOptions = {
|
||||
type: "oauth";
|
||||
scopes?: string[];
|
||||
refresh?: boolean;
|
||||
};
|
||||
export type GitHubAppAuthOptions = {
|
||||
type: "oauth";
|
||||
refresh?: boolean;
|
||||
};
|
||||
export type OAuthAppAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
} & Omit<OAuthMethodsTypes.OAuthAppAuthentication, "clientSecret">;
|
||||
export type GitHubAppAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
} & Omit<OAuthMethodsTypes.GitHubAppAuthentication, "clientSecret">;
|
||||
export type GitHubAppAuthenticationWithExpiration = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
} & Omit<OAuthMethodsTypes.GitHubAppAuthentication, "clientSecret">;
|
||||
export type Verification = {
|
||||
device_code: string;
|
||||
user_code: string;
|
||||
verification_uri: string;
|
||||
expires_in: number;
|
||||
interval: number;
|
||||
};
|
||||
export type OnVerificationCallback = (verification: Verification) => any | Promise<any>;
|
||||
export type OAuthAppState = {
|
||||
clientId: string;
|
||||
clientType: "oauth-app";
|
||||
onVerification: OnVerificationCallback;
|
||||
scopes: string[];
|
||||
request: RequestInterface;
|
||||
authentication?: OAuthAppAuthentication;
|
||||
};
|
||||
export type GitHubAppState = {
|
||||
clientId: string;
|
||||
clientType: "github-app";
|
||||
onVerification: OnVerificationCallback;
|
||||
request: RequestInterface;
|
||||
authentication?: GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration;
|
||||
};
|
1
node_modules/@octokit/auth-oauth-device/dist-types/version.d.ts
generated
vendored
1
node_modules/@octokit/auth-oauth-device/dist-types/version.d.ts
generated
vendored
@ -1 +0,0 @@
|
||||
export declare const VERSION = "4.0.4";
|
140
node_modules/@octokit/auth-oauth-device/dist-web/index.js
generated
vendored
140
node_modules/@octokit/auth-oauth-device/dist-web/index.js
generated
vendored
@ -1,140 +0,0 @@
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
import { request } from '@octokit/request';
|
||||
import { createDeviceCode, exchangeDeviceCode } from '@octokit/oauth-methods';
|
||||
|
||||
async function getOAuthAccessToken(state, options) {
|
||||
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
||||
if (cachedAuthentication)
|
||||
return cachedAuthentication;
|
||||
// Step 1: Request device and user codes
|
||||
// https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-1-app-requests-the-device-and-user-verification-codes-from-github
|
||||
const { data: verification } = await createDeviceCode({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
request: options.request || state.request,
|
||||
// @ts-expect-error the extra code to make TS happy is not worth it
|
||||
scopes: options.auth.scopes || state.scopes,
|
||||
});
|
||||
// Step 2: User must enter the user code on https://github.com/login/device
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-2-prompt-the-user-to-enter-the-user-code-in-a-browser
|
||||
await state.onVerification(verification);
|
||||
// Step 3: Exchange device code for access token
|
||||
// See https://docs.github.com/en/developers/apps/authorizing-oauth-apps#step-3-app-polls-github-to-check-if-the-user-authorized-the-device
|
||||
const authentication = await waitForAccessToken(options.request || state.request, state.clientId, state.clientType, verification);
|
||||
state.authentication = authentication;
|
||||
return authentication;
|
||||
}
|
||||
function getCachedAuthentication(state, auth) {
|
||||
if (auth.refresh === true)
|
||||
return false;
|
||||
if (!state.authentication)
|
||||
return false;
|
||||
if (state.clientType === "github-app") {
|
||||
return state.authentication;
|
||||
}
|
||||
const authentication = state.authentication;
|
||||
const newScope = (("scopes" in auth && auth.scopes) || state.scopes).join(" ");
|
||||
const currentScope = authentication.scopes.join(" ");
|
||||
return newScope === currentScope ? authentication : false;
|
||||
}
|
||||
async function wait(seconds) {
|
||||
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
async function waitForAccessToken(request, clientId, clientType, verification) {
|
||||
try {
|
||||
const options = {
|
||||
clientId,
|
||||
request,
|
||||
code: verification.device_code,
|
||||
};
|
||||
// WHY TYPESCRIPT WHY ARE YOU DOING THIS TO ME
|
||||
const { authentication } = clientType === "oauth-app"
|
||||
? await exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "oauth-app",
|
||||
})
|
||||
: await exchangeDeviceCode({
|
||||
...options,
|
||||
clientType: "github-app",
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
// istanbul ignore if
|
||||
// @ts-ignore
|
||||
if (!error.response)
|
||||
throw error;
|
||||
// @ts-ignore
|
||||
const errorType = error.response.data.error;
|
||||
if (errorType === "authorization_pending") {
|
||||
await wait(verification.interval);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
if (errorType === "slow_down") {
|
||||
await wait(verification.interval + 5);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function auth(state, authOptions) {
|
||||
return getOAuthAccessToken(state, {
|
||||
auth: authOptions,
|
||||
});
|
||||
}
|
||||
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept request to retrieve codes or token
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token } = await getOAuthAccessToken(state, {
|
||||
request,
|
||||
auth: { type: "oauth" },
|
||||
});
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
const VERSION = "4.0.4";
|
||||
|
||||
function createOAuthDeviceAuth(options) {
|
||||
const requestWithDefaults = options.request ||
|
||||
request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-device.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
const { request: request$1 = requestWithDefaults, ...otherOptions } = options;
|
||||
const state = options.clientType === "github-app"
|
||||
? {
|
||||
...otherOptions,
|
||||
clientType: "github-app",
|
||||
request: request$1,
|
||||
}
|
||||
: {
|
||||
...otherOptions,
|
||||
clientType: "oauth-app",
|
||||
request: request$1,
|
||||
scopes: options.scopes || [],
|
||||
};
|
||||
if (!options.clientId) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
if (!options.onVerification) {
|
||||
throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');
|
||||
}
|
||||
// @ts-ignore too much for tsc / ts-jest ¯\_(ツ)_/¯
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
||||
|
||||
export { createOAuthDeviceAuth };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-oauth-device/dist-web/index.js.map
generated
vendored
1
node_modules/@octokit/auth-oauth-device/dist-web/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
51
node_modules/@octokit/auth-oauth-device/package.json
generated
vendored
51
node_modules/@octokit/auth-oauth-device/package.json
generated
vendored
@ -1,51 +0,0 @@
|
||||
{
|
||||
"name": "@octokit/auth-oauth-device",
|
||||
"description": "GitHub OAuth Device authentication strategy for JavaScript",
|
||||
"version": "4.0.4",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"repository": "github:octokit/auth-oauth-device.js",
|
||||
"dependencies": {
|
||||
"@octokit/oauth-methods": "^2.0.0",
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/tsconfig": "^1.0.2",
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.2",
|
||||
"@pika/plugin-build-web": "^0.9.2",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.2",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/node": "^18.0.0",
|
||||
"fetch-mock": "^9.11.0",
|
||||
"jest": "^29.0.0",
|
||||
"prettier": "2.8.3",
|
||||
"semantic-release": "^20.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.1.0",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typescript": "^4.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
9
node_modules/@octokit/auth-oauth-user/LICENSE
generated
vendored
9
node_modules/@octokit/auth-oauth-user/LICENSE
generated
vendored
@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 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.
|
1032
node_modules/@octokit/auth-oauth-user/README.md
generated
vendored
1032
node_modules/@octokit/auth-oauth-user/README.md
generated
vendored
File diff suppressed because it is too large
Load Diff
243
node_modules/@octokit/auth-oauth-user/dist-node/index.js
generated
vendored
243
node_modules/@octokit/auth-oauth-user/dist-node/index.js
generated
vendored
@ -1,243 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var request = require('@octokit/request');
|
||||
var authOauthDevice = require('@octokit/auth-oauth-device');
|
||||
var oauthMethods = require('@octokit/oauth-methods');
|
||||
var btoa = _interopDefault(require('btoa-lite'));
|
||||
|
||||
const VERSION = "2.1.1";
|
||||
|
||||
// @ts-nocheck there is only place for one of us in this file. And it's not you, TS
|
||||
async function getAuthentication(state) {
|
||||
// handle code exchange form OAuth Web Flow
|
||||
if ("code" in state.strategyOptions) {
|
||||
const {
|
||||
authentication
|
||||
} = await oauthMethods.exchangeWebFlowCode({
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication
|
||||
};
|
||||
}
|
||||
// handle OAuth device flow
|
||||
if ("onVerification" in state.strategyOptions) {
|
||||
const deviceAuth = authOauthDevice.createOAuthDeviceAuth({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request
|
||||
});
|
||||
const authentication = await deviceAuth({
|
||||
type: "oauth"
|
||||
});
|
||||
return {
|
||||
clientSecret: state.clientSecret,
|
||||
...authentication
|
||||
};
|
||||
}
|
||||
// use existing authentication
|
||||
if ("token" in state.strategyOptions) {
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions
|
||||
};
|
||||
}
|
||||
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
||||
}
|
||||
|
||||
async function auth(state, options = {}) {
|
||||
if (!state.authentication) {
|
||||
// This is what TS makes us do ¯\_(ツ)_/¯
|
||||
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
|
||||
}
|
||||
if (state.authentication.invalid) {
|
||||
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
|
||||
}
|
||||
const currentAuthentication = state.authentication;
|
||||
// (auto) refresh for user-to-server tokens
|
||||
if ("expiresAt" in currentAuthentication) {
|
||||
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < new Date()) {
|
||||
const {
|
||||
authentication
|
||||
} = await oauthMethods.refreshToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
refreshToken: currentAuthentication.refreshToken,
|
||||
request: state.request
|
||||
});
|
||||
state.authentication = {
|
||||
tokenType: "oauth",
|
||||
type: "token",
|
||||
...authentication
|
||||
};
|
||||
}
|
||||
}
|
||||
// throw error for invalid refresh call
|
||||
if (options.type === "refresh") {
|
||||
var _state$onTokenCreated;
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");
|
||||
}
|
||||
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
|
||||
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
|
||||
}
|
||||
await ((_state$onTokenCreated = state.onTokenCreated) === null || _state$onTokenCreated === void 0 ? void 0 : _state$onTokenCreated.call(state, state.authentication, {
|
||||
type: options.type
|
||||
}));
|
||||
}
|
||||
// check or reset token
|
||||
if (options.type === "check" || options.type === "reset") {
|
||||
const method = options.type === "check" ? oauthMethods.checkToken : oauthMethods.resetToken;
|
||||
try {
|
||||
const {
|
||||
authentication
|
||||
} = await method({
|
||||
// @ts-expect-error making TS happy would require unnecessary code so no
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: state.authentication.token,
|
||||
request: state.request
|
||||
});
|
||||
state.authentication = {
|
||||
tokenType: "oauth",
|
||||
type: "token",
|
||||
// @ts-expect-error TBD
|
||||
...authentication
|
||||
};
|
||||
if (options.type === "reset") {
|
||||
var _state$onTokenCreated2;
|
||||
await ((_state$onTokenCreated2 = state.onTokenCreated) === null || _state$onTokenCreated2 === void 0 ? void 0 : _state$onTokenCreated2.call(state, state.authentication, {
|
||||
type: options.type
|
||||
}));
|
||||
}
|
||||
return state.authentication;
|
||||
} catch (error) {
|
||||
// istanbul ignore else
|
||||
if (error.status === 404) {
|
||||
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
||||
// @ts-expect-error TBD
|
||||
state.authentication.invalid = true;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// invalidate
|
||||
if (options.type === "delete" || options.type === "deleteAuthorization") {
|
||||
const method = options.type === "delete" ? oauthMethods.deleteToken : oauthMethods.deleteAuthorization;
|
||||
try {
|
||||
await method({
|
||||
// @ts-expect-error making TS happy would require unnecessary code so no
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: state.authentication.token,
|
||||
request: state.request
|
||||
});
|
||||
} catch (error) {
|
||||
// istanbul ignore if
|
||||
if (error.status !== 404) throw error;
|
||||
}
|
||||
state.authentication.invalid = true;
|
||||
return state.authentication;
|
||||
}
|
||||
return state.authentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following endpoints require an OAuth App to authenticate using its client_id and client_secret.
|
||||
*
|
||||
* - [`POST /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#check-a-token) - Check a token
|
||||
* - [`PATCH /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#reset-a-token) - Reset a token
|
||||
* - [`POST /applications/{client_id}/token/scoped`](https://docs.github.com/en/rest/reference/apps#create-a-scoped-access-token) - Create a scoped access token
|
||||
* - [`DELETE /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#delete-an-app-token) - Delete an app token
|
||||
* - [`DELETE /applications/{client_id}/grant`](https://docs.github.com/en/rest/reference/apps#delete-an-app-authorization) - Delete an app authorization
|
||||
*
|
||||
* deprecated:
|
||||
*
|
||||
* - [`GET /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#check-an-authorization) - Check an authorization
|
||||
* - [`POST /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#reset-an-authorization) - Reset an authorization
|
||||
* - [`DELETE /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#revoke-an-authorization-for-an-application) - Revoke an authorization for an application
|
||||
* - [`DELETE /applications/{client_id}/grants/{access_token}`](https://docs.github.com/en/rest/reference/apps#revoke-a-grant-for-an-application) - Revoke a grant for an application
|
||||
*/
|
||||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
||||
function requiresBasicAuth(url) {
|
||||
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
||||
}
|
||||
|
||||
async function hook(state, request, route, parameters = {}) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept OAuth Web/Device flow request
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresBasicAuth(endpoint.url)) {
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
// TS makes us do this ¯\_(ツ)_/¯
|
||||
const {
|
||||
token
|
||||
} = state.clientType === "oauth-app" ? await auth({
|
||||
...state,
|
||||
request
|
||||
}) : await auth({
|
||||
...state,
|
||||
request
|
||||
});
|
||||
endpoint.headers.authorization = "token " + token;
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
function createOAuthUserAuth({
|
||||
clientId,
|
||||
clientSecret,
|
||||
clientType = "oauth-app",
|
||||
request: request$1 = request.request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
}
|
||||
}),
|
||||
onTokenCreated,
|
||||
...strategyOptions
|
||||
}) {
|
||||
const state = Object.assign({
|
||||
clientType,
|
||||
clientId,
|
||||
clientSecret,
|
||||
onTokenCreated,
|
||||
strategyOptions,
|
||||
request: request$1
|
||||
});
|
||||
// @ts-expect-error not worth the extra code needed to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
// @ts-expect-error not worth the extra code needed to appease TS
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
createOAuthUserAuth.VERSION = VERSION;
|
||||
|
||||
exports.createOAuthUserAuth = createOAuthUserAuth;
|
||||
exports.requiresBasicAuth = requiresBasicAuth;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-oauth-user/dist-node/index.js.map
generated
vendored
1
node_modules/@octokit/auth-oauth-user/dist-node/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
102
node_modules/@octokit/auth-oauth-user/dist-src/auth.js
generated
vendored
102
node_modules/@octokit/auth-oauth-user/dist-src/auth.js
generated
vendored
@ -1,102 +0,0 @@
|
||||
import { getAuthentication } from "./get-authentication";
|
||||
import { checkToken, deleteAuthorization, deleteToken, refreshToken, resetToken, } from "@octokit/oauth-methods";
|
||||
export async function auth(state, options = {}) {
|
||||
if (!state.authentication) {
|
||||
// This is what TS makes us do ¯\_(ツ)_/¯
|
||||
state.authentication =
|
||||
state.clientType === "oauth-app"
|
||||
? await getAuthentication(state)
|
||||
: await getAuthentication(state);
|
||||
}
|
||||
if (state.authentication.invalid) {
|
||||
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
|
||||
}
|
||||
const currentAuthentication = state.authentication;
|
||||
// (auto) refresh for user-to-server tokens
|
||||
if ("expiresAt" in currentAuthentication) {
|
||||
if (options.type === "refresh" ||
|
||||
new Date(currentAuthentication.expiresAt) < new Date()) {
|
||||
const { authentication } = await refreshToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
refreshToken: currentAuthentication.refreshToken,
|
||||
request: state.request,
|
||||
});
|
||||
state.authentication = {
|
||||
tokenType: "oauth",
|
||||
type: "token",
|
||||
...authentication,
|
||||
};
|
||||
}
|
||||
}
|
||||
// throw error for invalid refresh call
|
||||
if (options.type === "refresh") {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");
|
||||
}
|
||||
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
|
||||
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
|
||||
}
|
||||
await state.onTokenCreated?.(state.authentication, {
|
||||
type: options.type,
|
||||
});
|
||||
}
|
||||
// check or reset token
|
||||
if (options.type === "check" || options.type === "reset") {
|
||||
const method = options.type === "check" ? checkToken : resetToken;
|
||||
try {
|
||||
const { authentication } = await method({
|
||||
// @ts-expect-error making TS happy would require unnecessary code so no
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: state.authentication.token,
|
||||
request: state.request,
|
||||
});
|
||||
state.authentication = {
|
||||
tokenType: "oauth",
|
||||
type: "token",
|
||||
// @ts-expect-error TBD
|
||||
...authentication,
|
||||
};
|
||||
if (options.type === "reset") {
|
||||
await state.onTokenCreated?.(state.authentication, {
|
||||
type: options.type,
|
||||
});
|
||||
}
|
||||
return state.authentication;
|
||||
}
|
||||
catch (error) {
|
||||
// istanbul ignore else
|
||||
if (error.status === 404) {
|
||||
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
||||
// @ts-expect-error TBD
|
||||
state.authentication.invalid = true;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// invalidate
|
||||
if (options.type === "delete" || options.type === "deleteAuthorization") {
|
||||
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
|
||||
try {
|
||||
await method({
|
||||
// @ts-expect-error making TS happy would require unnecessary code so no
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: state.authentication.token,
|
||||
request: state.request,
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
// istanbul ignore if
|
||||
if (error.status !== 404)
|
||||
throw error;
|
||||
}
|
||||
state.authentication.invalid = true;
|
||||
return state.authentication;
|
||||
}
|
||||
return state.authentication;
|
||||
}
|
51
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
51
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
@ -1,51 +0,0 @@
|
||||
// @ts-nocheck there is only place for one of us in this file. And it's not you, TS
|
||||
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
||||
export async function getAuthentication(state) {
|
||||
// handle code exchange form OAuth Web Flow
|
||||
if ("code" in state.strategyOptions) {
|
||||
const { authentication } = await exchangeWebFlowCode({
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request,
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication,
|
||||
};
|
||||
}
|
||||
// handle OAuth device flow
|
||||
if ("onVerification" in state.strategyOptions) {
|
||||
const deviceAuth = createOAuthDeviceAuth({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request,
|
||||
});
|
||||
const authentication = await deviceAuth({
|
||||
type: "oauth",
|
||||
});
|
||||
return {
|
||||
clientSecret: state.clientSecret,
|
||||
...authentication,
|
||||
};
|
||||
}
|
||||
// use existing authentication
|
||||
if ("token" in state.strategyOptions) {
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
};
|
||||
}
|
||||
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
||||
}
|
21
node_modules/@octokit/auth-oauth-user/dist-src/hook.js
generated
vendored
21
node_modules/@octokit/auth-oauth-user/dist-src/hook.js
generated
vendored
@ -1,21 +0,0 @@
|
||||
import btoa from "btoa-lite";
|
||||
import { auth } from "./auth";
|
||||
import { requiresBasicAuth } from "./requires-basic-auth";
|
||||
export async function hook(state, request, route, parameters = {}) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
// Do not intercept OAuth Web/Device flow request
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresBasicAuth(endpoint.url)) {
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
// TS makes us do this ¯\_(ツ)_/¯
|
||||
const { token } = state.clientType === "oauth-app"
|
||||
? await auth({ ...state, request })
|
||||
: await auth({ ...state, request });
|
||||
endpoint.headers.authorization = "token " + token;
|
||||
return request(endpoint);
|
||||
}
|
26
node_modules/@octokit/auth-oauth-user/dist-src/index.js
generated
vendored
26
node_modules/@octokit/auth-oauth-user/dist-src/index.js
generated
vendored
@ -1,26 +0,0 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
import { VERSION } from "./version";
|
||||
import { auth } from "./auth";
|
||||
import { hook } from "./hook";
|
||||
export { requiresBasicAuth } from "./requires-basic-auth";
|
||||
export function createOAuthUserAuth({ clientId, clientSecret, clientType = "oauth-app", request = octokitRequest.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
}), onTokenCreated, ...strategyOptions }) {
|
||||
const state = Object.assign({
|
||||
clientType,
|
||||
clientId,
|
||||
clientSecret,
|
||||
onTokenCreated,
|
||||
strategyOptions,
|
||||
request,
|
||||
});
|
||||
// @ts-expect-error not worth the extra code needed to appease TS
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
// @ts-expect-error not worth the extra code needed to appease TS
|
||||
hook: hook.bind(null, state),
|
||||
});
|
||||
}
|
||||
createOAuthUserAuth.VERSION = VERSION;
|
20
node_modules/@octokit/auth-oauth-user/dist-src/requires-basic-auth.js
generated
vendored
20
node_modules/@octokit/auth-oauth-user/dist-src/requires-basic-auth.js
generated
vendored
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* The following endpoints require an OAuth App to authenticate using its client_id and client_secret.
|
||||
*
|
||||
* - [`POST /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#check-a-token) - Check a token
|
||||
* - [`PATCH /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#reset-a-token) - Reset a token
|
||||
* - [`POST /applications/{client_id}/token/scoped`](https://docs.github.com/en/rest/reference/apps#create-a-scoped-access-token) - Create a scoped access token
|
||||
* - [`DELETE /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#delete-an-app-token) - Delete an app token
|
||||
* - [`DELETE /applications/{client_id}/grant`](https://docs.github.com/en/rest/reference/apps#delete-an-app-authorization) - Delete an app authorization
|
||||
*
|
||||
* deprecated:
|
||||
*
|
||||
* - [`GET /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#check-an-authorization) - Check an authorization
|
||||
* - [`POST /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#reset-an-authorization) - Reset an authorization
|
||||
* - [`DELETE /applications/{client_id}/tokens/{access_token}`](https://docs.github.com/en/rest/reference/apps#revoke-an-authorization-for-an-application) - Revoke an authorization for an application
|
||||
* - [`DELETE /applications/{client_id}/grants/{access_token}`](https://docs.github.com/en/rest/reference/apps#revoke-a-grant-for-an-application) - Revoke a grant for an application
|
||||
*/
|
||||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
||||
export function requiresBasicAuth(url) {
|
||||
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
||||
}
|
1
node_modules/@octokit/auth-oauth-user/dist-src/types.js
generated
vendored
1
node_modules/@octokit/auth-oauth-user/dist-src/types.js
generated
vendored
@ -1 +0,0 @@
|
||||
export {};
|
1
node_modules/@octokit/auth-oauth-user/dist-src/version.js
generated
vendored
1
node_modules/@octokit/auth-oauth-user/dist-src/version.js
generated
vendored
@ -1 +0,0 @@
|
||||
export const VERSION = "2.1.1";
|
3
node_modules/@octokit/auth-oauth-user/dist-types/auth.d.ts
generated
vendored
3
node_modules/@octokit/auth-oauth-user/dist-types/auth.d.ts
generated
vendored
@ -1,3 +0,0 @@
|
||||
import { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, OAuthAppState, GitHubAppState } from "./types";
|
||||
export declare function auth(state: OAuthAppState, options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
export declare function auth(state: GitHubAppState, options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
3
node_modules/@octokit/auth-oauth-user/dist-types/get-authentication.d.ts
generated
vendored
3
node_modules/@octokit/auth-oauth-user/dist-types/get-authentication.d.ts
generated
vendored
@ -1,3 +0,0 @@
|
||||
import { OAuthAppState, GitHubAppState, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration } from "./types";
|
||||
export declare function getAuthentication(state: OAuthAppState): Promise<OAuthAppAuthentication>;
|
||||
export declare function getAuthentication(state: GitHubAppState): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
6
node_modules/@octokit/auth-oauth-user/dist-types/hook.d.ts
generated
vendored
6
node_modules/@octokit/auth-oauth-user/dist-types/hook.d.ts
generated
vendored
@ -1,6 +0,0 @@
|
||||
import { EndpointOptions, OctokitResponse, RequestInterface, RequestParameters, Route } from "@octokit/types";
|
||||
import { OAuthAppState, GitHubAppState } from "./types";
|
||||
type AnyResponse = OctokitResponse<any>;
|
||||
export declare function hook(state: OAuthAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
|
||||
export declare function hook(state: GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
|
||||
export {};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user