First upload version 0.0.1
This commit is contained in:
21
node_modules/@octokit/app/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/app/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
440
node_modules/@octokit/app/README.md
generated
vendored
Normal file
440
node_modules/@octokit/app/README.md
generated
vendored
Normal file
@@ -0,0 +1,440 @@
|
||||
# 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.getInstallationUrl`](#appgetinstallationurl)
|
||||
- [`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>
|
||||
|
||||
> [!IMPORTANT]
|
||||
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
|
||||
>
|
||||
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
|
||||
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
|
||||
|
||||
```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.getInstallationUrl`
|
||||
|
||||
```js
|
||||
const installationUrl = await app.getInstallationUrl();
|
||||
return res.redirect(installationUrl);
|
||||
```
|
||||
|
||||
Optionally pass the ID of a GitHub organization or user to request installation on that specific target.
|
||||
|
||||
If the user will be sent to a redirect URL after installation (such as if you request user authorization during installation), you can also supply a `state` string that will be included in the query of the post-install redirect.
|
||||
|
||||
```js
|
||||
const installationUrl = await app.getInstallationUrl({ state, target_id });
|
||||
return res.redirect(installationUrl);
|
||||
```
|
||||
|
||||
### `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(async (req, res) => {
|
||||
// `middleware` returns `false` when `req` is unhandled (beyond `/api/github`)
|
||||
if (await middleware(req, res)) return;
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
})
|
||||
.listen(3000);
|
||||
// can now receive user authorization callbacks at /api/github/*
|
||||
```
|
||||
|
||||
The middleware returned from `createNodeMiddleware` can also serve as an
|
||||
`Express.js` middleware directly.
|
||||
|
||||
<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>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
341
node_modules/@octokit/app/dist-node/index.js
generated
vendored
Normal file
341
node_modules/@octokit/app/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { createAppAuth as createAppAuth3 } from "@octokit/auth-app";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "16.1.2";
|
||||
|
||||
// pkg/dist-src/webhooks.js
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
function webhooks(appOctokit, options) {
|
||||
return new Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async (event) => {
|
||||
if (!("installation" in event.payload) || typeof event.payload.installation !== "object") {
|
||||
const octokit2 = new appOctokit.constructor({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`
|
||||
}
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit: octokit2
|
||||
};
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
octokit.hook.before("request", (options2) => {
|
||||
options2.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-installation.js
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
|
||||
// pkg/dist-src/get-installation-octokit.js
|
||||
import { createAppAuth as createAppAuth2 } from "@octokit/auth-app";
|
||||
async function getInstallationOctokit(app, installationId) {
|
||||
return app.octokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
const options = {
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth2,
|
||||
...{ auth: { ...auth, installationId } }
|
||||
};
|
||||
return new auth.octokit.constructor(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-installation.js
|
||||
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 = 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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-repository.js
|
||||
import { composePaginateRest as composePaginateRest2 } from "@octokit/plugin-paginate-rest";
|
||||
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 : void 0
|
||||
)[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 = composePaginateRest2.iterator(
|
||||
octokit,
|
||||
"GET /installation/repositories"
|
||||
);
|
||||
for await (const { data: repositories } of repositoriesIterator) {
|
||||
for (const repository of repositories) {
|
||||
yield { octokit, repository };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/get-installation-url.js
|
||||
function getInstallationUrlFactory(app) {
|
||||
let installationUrlBasePromise;
|
||||
return async function getInstallationUrl(options = {}) {
|
||||
if (!installationUrlBasePromise) {
|
||||
installationUrlBasePromise = getInstallationUrlBase(app);
|
||||
}
|
||||
const installationUrlBase = await installationUrlBasePromise;
|
||||
const installationUrl = new URL(installationUrlBase);
|
||||
if (options.target_id !== void 0) {
|
||||
installationUrl.pathname += "/permissions";
|
||||
installationUrl.searchParams.append(
|
||||
"target_id",
|
||||
options.target_id.toFixed()
|
||||
);
|
||||
}
|
||||
if (options.state !== void 0) {
|
||||
installationUrl.searchParams.append("state", options.state);
|
||||
}
|
||||
return installationUrl.href;
|
||||
};
|
||||
}
|
||||
async function getInstallationUrlBase(app) {
|
||||
const { data: appInfo } = await app.octokit.request("GET /app");
|
||||
if (!appInfo) {
|
||||
throw new Error("[@octokit/app] unable to fetch metadata for app");
|
||||
}
|
||||
return `${appInfo.html_url}/installations/new`;
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/node/index.js
|
||||
import {
|
||||
createNodeMiddleware as oauthNodeMiddleware,
|
||||
sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
} from "@octokit/oauth-app";
|
||||
import { createNodeMiddleware as webhooksNodeMiddleware } from "@octokit/webhooks";
|
||||
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 = {
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log
|
||||
};
|
||||
const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log
|
||||
});
|
||||
const oauthMiddleware = oauthNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth"
|
||||
});
|
||||
return middleware.bind(
|
||||
null,
|
||||
optionsWithDefaults.pathPrefix,
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
);
|
||||
}
|
||||
async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) {
|
||||
const { pathname } = new URL(request.url, "http://localhost");
|
||||
if (pathname.startsWith(`${pathPrefix}/`)) {
|
||||
if (pathname === `${pathPrefix}/webhooks`) {
|
||||
webhooksMiddleware(request, response);
|
||||
} else if (pathname.startsWith(`${pathPrefix}/oauth/`)) {
|
||||
oauthMiddleware(request, response);
|
||||
} else {
|
||||
sendNodeResponse(unknownRouteResponse(request), response);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var App = class {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
octokit;
|
||||
// @ts-ignore calling app.webhooks will throw a helpful error when options.webhooks is not set
|
||||
webhooks;
|
||||
// @ts-ignore calling app.oauth will throw a helpful error when options.oauth is not set
|
||||
oauth;
|
||||
getInstallationOctokit;
|
||||
eachInstallation;
|
||||
eachRepository;
|
||||
getInstallationUrl;
|
||||
log;
|
||||
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
|
||||
} : {}
|
||||
);
|
||||
const octokitOptions = {
|
||||
authStrategy: createAppAuth3,
|
||||
auth: authOptions
|
||||
};
|
||||
if ("log" in options && typeof options.log !== "undefined") {
|
||||
octokitOptions.log = options.log;
|
||||
}
|
||||
this.octokit = new Octokit(octokitOptions);
|
||||
this.log = Object.assign(
|
||||
{
|
||||
debug: () => {
|
||||
},
|
||||
info: () => {
|
||||
},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
},
|
||||
options.log
|
||||
);
|
||||
if (options.webhooks) {
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
} else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
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
|
||||
);
|
||||
this.getInstallationUrl = getInstallationUrlFactory(this);
|
||||
}
|
||||
};
|
||||
export {
|
||||
App,
|
||||
createNodeMiddleware
|
||||
};
|
||||
7
node_modules/@octokit/app/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/app/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
39
node_modules/@octokit/app/dist-src/each-installation.js
generated
vendored
Normal file
39
node_modules/@octokit/app/dist-src/each-installation.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { getInstallationOctokit } from "./get-installation-octokit.js";
|
||||
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 = 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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
eachInstallation,
|
||||
eachInstallationFactory,
|
||||
eachInstallationIterator
|
||||
};
|
||||
53
node_modules/@octokit/app/dist-src/each-repository.js
generated
vendored
Normal file
53
node_modules/@octokit/app/dist-src/each-repository.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
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 : void 0
|
||||
)[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 = composePaginateRest.iterator(
|
||||
octokit,
|
||||
"GET /installation/repositories"
|
||||
);
|
||||
for await (const { data: repositories } of repositoriesIterator) {
|
||||
for (const repository of repositories) {
|
||||
yield { octokit, repository };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
eachRepository,
|
||||
eachRepositoryFactory,
|
||||
eachRepositoryIterator
|
||||
};
|
||||
18
node_modules/@octokit/app/dist-src/get-installation-octokit.js
generated
vendored
Normal file
18
node_modules/@octokit/app/dist-src/get-installation-octokit.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
async function getInstallationOctokit(app, installationId) {
|
||||
return app.octokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
const options = {
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth,
|
||||
...{ auth: { ...auth, installationId } }
|
||||
};
|
||||
return new auth.octokit.constructor(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
getInstallationOctokit
|
||||
};
|
||||
31
node_modules/@octokit/app/dist-src/get-installation-url.js
generated
vendored
Normal file
31
node_modules/@octokit/app/dist-src/get-installation-url.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
function getInstallationUrlFactory(app) {
|
||||
let installationUrlBasePromise;
|
||||
return async function getInstallationUrl(options = {}) {
|
||||
if (!installationUrlBasePromise) {
|
||||
installationUrlBasePromise = getInstallationUrlBase(app);
|
||||
}
|
||||
const installationUrlBase = await installationUrlBasePromise;
|
||||
const installationUrl = new URL(installationUrlBase);
|
||||
if (options.target_id !== void 0) {
|
||||
installationUrl.pathname += "/permissions";
|
||||
installationUrl.searchParams.append(
|
||||
"target_id",
|
||||
options.target_id.toFixed()
|
||||
);
|
||||
}
|
||||
if (options.state !== void 0) {
|
||||
installationUrl.searchParams.append("state", options.state);
|
||||
}
|
||||
return installationUrl.href;
|
||||
};
|
||||
}
|
||||
async function getInstallationUrlBase(app) {
|
||||
const { data: appInfo } = await app.octokit.request("GET /app");
|
||||
if (!appInfo) {
|
||||
throw new Error("[@octokit/app] unable to fetch metadata for app");
|
||||
}
|
||||
return `${appInfo.html_url}/installations/new`;
|
||||
}
|
||||
export {
|
||||
getInstallationUrlFactory
|
||||
};
|
||||
105
node_modules/@octokit/app/dist-src/index.js
generated
vendored
Normal file
105
node_modules/@octokit/app/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
import { VERSION } from "./version.js";
|
||||
import { webhooks } from "./webhooks.js";
|
||||
import { eachInstallationFactory } from "./each-installation.js";
|
||||
import { eachRepositoryFactory } from "./each-repository.js";
|
||||
import { getInstallationOctokit } from "./get-installation-octokit.js";
|
||||
import { getInstallationUrlFactory } from "./get-installation-url.js";
|
||||
class App {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
octokit;
|
||||
// @ts-ignore calling app.webhooks will throw a helpful error when options.webhooks is not set
|
||||
webhooks;
|
||||
// @ts-ignore calling app.oauth will throw a helpful error when options.oauth is not set
|
||||
oauth;
|
||||
getInstallationOctokit;
|
||||
eachInstallation;
|
||||
eachRepository;
|
||||
getInstallationUrl;
|
||||
log;
|
||||
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
|
||||
} : {}
|
||||
);
|
||||
const octokitOptions = {
|
||||
authStrategy: createAppAuth,
|
||||
auth: authOptions
|
||||
};
|
||||
if ("log" in options && typeof options.log !== "undefined") {
|
||||
octokitOptions.log = options.log;
|
||||
}
|
||||
this.octokit = new Octokit(octokitOptions);
|
||||
this.log = Object.assign(
|
||||
{
|
||||
debug: () => {
|
||||
},
|
||||
info: () => {
|
||||
},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
},
|
||||
options.log
|
||||
);
|
||||
if (options.webhooks) {
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
} else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
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
|
||||
);
|
||||
this.getInstallationUrl = getInstallationUrlFactory(this);
|
||||
}
|
||||
}
|
||||
import { createNodeMiddleware } from "./middleware/node/index.js";
|
||||
export {
|
||||
App,
|
||||
createNodeMiddleware
|
||||
};
|
||||
57
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
Normal file
57
node_modules/@octokit/app/dist-src/middleware/node/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
createNodeMiddleware as oauthNodeMiddleware,
|
||||
sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
} from "@octokit/oauth-app";
|
||||
import { createNodeMiddleware as webhooksNodeMiddleware } from "@octokit/webhooks";
|
||||
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 = {
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log
|
||||
};
|
||||
const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log
|
||||
});
|
||||
const oauthMiddleware = oauthNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth"
|
||||
});
|
||||
return middleware.bind(
|
||||
null,
|
||||
optionsWithDefaults.pathPrefix,
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
);
|
||||
}
|
||||
async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) {
|
||||
const { pathname } = new URL(request.url, "http://localhost");
|
||||
if (pathname.startsWith(`${pathPrefix}/`)) {
|
||||
if (pathname === `${pathPrefix}/webhooks`) {
|
||||
webhooksMiddleware(request, response);
|
||||
} else if (pathname.startsWith(`${pathPrefix}/oauth/`)) {
|
||||
oauthMiddleware(request, response);
|
||||
} else {
|
||||
sendNodeResponse(unknownRouteResponse(request), response);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export {
|
||||
createNodeMiddleware,
|
||||
middleware
|
||||
};
|
||||
4
node_modules/@octokit/app/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/app/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "16.1.2";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
49
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
Normal file
49
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
function webhooks(appOctokit, options) {
|
||||
return new Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async (event) => {
|
||||
if (!("installation" in event.payload) || typeof event.payload.installation !== "object") {
|
||||
const octokit2 = new appOctokit.constructor({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`
|
||||
}
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit: octokit2
|
||||
};
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
octokit.hook.before("request", (options2) => {
|
||||
options2.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
webhooks
|
||||
};
|
||||
122
node_modules/@octokit/app/dist-types/each-installation.d.ts
generated
vendored
Normal file
122
node_modules/@octokit/app/dist-types/each-installation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import type { App } from "./index.js";
|
||||
import type { EachInstallationFunction, EachInstallationInterface } from "./types.js";
|
||||
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: ({
|
||||
name?: string | null;
|
||||
email?: string | null;
|
||||
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;
|
||||
} & {
|
||||
description?: string | null;
|
||||
html_url: string;
|
||||
website_url?: string | null;
|
||||
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";
|
||||
administration?: "read" | "write";
|
||||
checks?: "read" | "write";
|
||||
contents?: "read" | "write";
|
||||
deployments?: "read" | "write";
|
||||
environments?: "read" | "write";
|
||||
issues?: "read" | "write";
|
||||
metadata?: "read" | "write";
|
||||
packages?: "read" | "write";
|
||||
pages?: "read" | "write";
|
||||
pull_requests?: "read" | "write";
|
||||
repository_hooks?: "read" | "write";
|
||||
repository_projects?: "read" | "write" | "admin";
|
||||
secret_scanning_alerts?: "read" | "write";
|
||||
secrets?: "read" | "write";
|
||||
security_events?: "read" | "write";
|
||||
single_file?: "read" | "write";
|
||||
statuses?: "read" | "write";
|
||||
vulnerability_alerts?: "read" | "write";
|
||||
workflows?: "write";
|
||||
members?: "read" | "write";
|
||||
organization_administration?: "read" | "write";
|
||||
organization_custom_roles?: "read" | "write";
|
||||
organization_announcement_banners?: "read" | "write";
|
||||
organization_hooks?: "read" | "write";
|
||||
organization_personal_access_tokens?: "read" | "write";
|
||||
organization_personal_access_token_requests?: "read" | "write";
|
||||
organization_plan?: "read";
|
||||
organization_projects?: "read" | "write" | "admin";
|
||||
organization_packages?: "read" | "write";
|
||||
organization_secrets?: "read" | "write";
|
||||
organization_self_hosted_runners?: "read" | "write";
|
||||
organization_user_blocking?: "read" | "write";
|
||||
team_discussions?: "read" | "write";
|
||||
};
|
||||
events: string[];
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
single_file_name: string | null;
|
||||
has_multiple_single_files?: boolean;
|
||||
single_file_paths?: string[];
|
||||
app_slug: string;
|
||||
suspended_by: {
|
||||
name?: string | null;
|
||||
email?: string | null;
|
||||
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;
|
||||
} | null;
|
||||
suspended_at: string | null;
|
||||
contact_email?: string | null;
|
||||
};
|
||||
}, void, unknown>;
|
||||
};
|
||||
147
node_modules/@octokit/app/dist-types/each-repository.d.ts
generated
vendored
Normal file
147
node_modules/@octokit/app/dist-types/each-repository.d.ts
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import type { App } from "./index.js";
|
||||
import type { EachRepositoryFunction, EachRepositoryInterface, EachRepositoryQuery } from "./types.js";
|
||||
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;
|
||||
} | null;
|
||||
forks: number;
|
||||
permissions?: {
|
||||
admin: boolean;
|
||||
pull: boolean;
|
||||
triage?: boolean;
|
||||
push: boolean;
|
||||
maintain?: boolean;
|
||||
};
|
||||
owner: {
|
||||
name?: string | null;
|
||||
email?: string | null;
|
||||
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;
|
||||
user_view_type?: string;
|
||||
};
|
||||
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;
|
||||
topics?: string[];
|
||||
has_issues: boolean;
|
||||
has_projects: boolean;
|
||||
has_wiki: boolean;
|
||||
has_pages: boolean;
|
||||
has_downloads: boolean;
|
||||
has_discussions?: boolean;
|
||||
archived: boolean;
|
||||
disabled: boolean;
|
||||
visibility?: string;
|
||||
pushed_at: string | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
allow_rebase_merge?: boolean;
|
||||
temp_clone_token?: string;
|
||||
allow_squash_merge?: boolean;
|
||||
allow_auto_merge?: boolean;
|
||||
delete_branch_on_merge?: boolean;
|
||||
allow_update_branch?: boolean;
|
||||
use_squash_pr_title_as_default?: boolean;
|
||||
squash_merge_commit_title?: "PR_TITLE" | "COMMIT_OR_PR_TITLE";
|
||||
squash_merge_commit_message?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK";
|
||||
merge_commit_title?: "PR_TITLE" | "MERGE_MESSAGE";
|
||||
merge_commit_message?: "PR_BODY" | "PR_TITLE" | "BLANK";
|
||||
allow_merge_commit?: boolean;
|
||||
allow_forking?: boolean;
|
||||
web_commit_signoff_required?: boolean;
|
||||
open_issues: number;
|
||||
watchers: number;
|
||||
master_branch?: string;
|
||||
starred_at?: string;
|
||||
anonymous_access_enabled?: boolean;
|
||||
code_search_index_status?: {
|
||||
lexical_search_ok?: boolean;
|
||||
lexical_commit_sha?: string;
|
||||
};
|
||||
};
|
||||
}, void, unknown>;
|
||||
};
|
||||
3
node_modules/@octokit/app/dist-types/get-installation-octokit.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/app/dist-types/get-installation-octokit.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import type { App } from "./index.js";
|
||||
export declare function getInstallationOctokit(app: App, installationId: number): Promise<Octokit>;
|
||||
3
node_modules/@octokit/app/dist-types/get-installation-url.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/app/dist-types/get-installation-url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { App } from "./index.js";
|
||||
import type { GetInstallationUrlOptions } from "./types.js";
|
||||
export declare function getInstallationUrlFactory(app: App): (options?: GetInstallationUrlOptions) => Promise<string>;
|
||||
55
node_modules/@octokit/app/dist-types/index.d.ts
generated
vendored
Normal file
55
node_modules/@octokit/app/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
import type { Webhooks } from "@octokit/webhooks";
|
||||
import type { Options, ConstructorOptions, EachInstallationInterface, EachRepositoryInterface, GetInstallationOctokitInterface, GetInstallationUrlInterface } from "./types.js";
|
||||
export type { EachInstallationInterface, EachRepositoryInterface, GetInstallationOctokitInterface, GetInstallationUrlInterface, } from "./types.js";
|
||||
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>>;
|
||||
getInstallationUrl: GetInstallationUrlInterface;
|
||||
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;
|
||||
};
|
||||
};
|
||||
} & S) & typeof this;
|
||||
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>>;
|
||||
getInstallationUrl: GetInstallationUrlInterface;
|
||||
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.js";
|
||||
11
node_modules/@octokit/app/dist-types/middleware/node/index.d.ts
generated
vendored
Normal file
11
node_modules/@octokit/app/dist-types/middleware/node/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
type IncomingMessage = any;
|
||||
type ServerResponse = any;
|
||||
import type { App } from "../../index.js";
|
||||
import type { Options } from "../../types.js";
|
||||
export type MiddlewareOptions = {
|
||||
pathPrefix?: string;
|
||||
log?: Options["log"];
|
||||
};
|
||||
export declare function createNodeMiddleware(app: App, options?: MiddlewareOptions): (request: any, response: any, next?: Function | undefined) => Promise<boolean>;
|
||||
export declare function middleware(pathPrefix: string, webhooksMiddleware: any, oauthMiddleware: any, request: IncomingMessage, response: ServerResponse, next?: Function): Promise<boolean>;
|
||||
export {};
|
||||
58
node_modules/@octokit/app/dist-types/types.d.ts
generated
vendored
Normal file
58
node_modules/@octokit/app/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import type { 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 interface GetInstallationUrlOptions {
|
||||
state?: string;
|
||||
target_id?: number;
|
||||
}
|
||||
export interface GetInstallationUrlInterface {
|
||||
(options?: GetInstallationUrlOptions): Promise<string>;
|
||||
}
|
||||
export {};
|
||||
1
node_modules/@octokit/app/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/app/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "16.1.2";
|
||||
6
node_modules/@octokit/app/dist-types/webhooks.d.ts
generated
vendored
Normal file
6
node_modules/@octokit/app/dist-types/webhooks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Octokit } from "@octokit/core";
|
||||
import { Webhooks, type EmitterWebhookEvent } from "@octokit/webhooks";
|
||||
import type { Options } from "./types.js";
|
||||
export declare function webhooks(appOctokit: Octokit, options: Required<Options>["webhooks"]): Webhooks<EmitterWebhookEvent & {
|
||||
octokit: Octokit;
|
||||
}>;
|
||||
341
node_modules/@octokit/app/dist-web/index.js
generated
vendored
Normal file
341
node_modules/@octokit/app/dist-web/index.js
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { createAppAuth as createAppAuth3 } from "@octokit/auth-app";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "16.1.2";
|
||||
|
||||
// pkg/dist-src/webhooks.js
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
function webhooks(appOctokit, options) {
|
||||
return new Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async (event) => {
|
||||
if (!("installation" in event.payload) || typeof event.payload.installation !== "object") {
|
||||
const octokit2 = new appOctokit.constructor({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`
|
||||
}
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit: octokit2
|
||||
};
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
octokit.hook.before("request", (options2) => {
|
||||
options2.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-installation.js
|
||||
import { composePaginateRest } from "@octokit/plugin-paginate-rest";
|
||||
|
||||
// pkg/dist-src/get-installation-octokit.js
|
||||
import { createAppAuth as createAppAuth2 } from "@octokit/auth-app";
|
||||
async function getInstallationOctokit(app, installationId) {
|
||||
return app.octokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
const options = {
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth2,
|
||||
...{ auth: { ...auth, installationId } }
|
||||
};
|
||||
return new auth.octokit.constructor(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-installation.js
|
||||
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 = 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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/each-repository.js
|
||||
import { composePaginateRest as composePaginateRest2 } from "@octokit/plugin-paginate-rest";
|
||||
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 : void 0
|
||||
)[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 = composePaginateRest2.iterator(
|
||||
octokit,
|
||||
"GET /installation/repositories"
|
||||
);
|
||||
for await (const { data: repositories } of repositoriesIterator) {
|
||||
for (const repository of repositories) {
|
||||
yield { octokit, repository };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/get-installation-url.js
|
||||
function getInstallationUrlFactory(app) {
|
||||
let installationUrlBasePromise;
|
||||
return async function getInstallationUrl(options = {}) {
|
||||
if (!installationUrlBasePromise) {
|
||||
installationUrlBasePromise = getInstallationUrlBase(app);
|
||||
}
|
||||
const installationUrlBase = await installationUrlBasePromise;
|
||||
const installationUrl = new URL(installationUrlBase);
|
||||
if (options.target_id !== void 0) {
|
||||
installationUrl.pathname += "/permissions";
|
||||
installationUrl.searchParams.append(
|
||||
"target_id",
|
||||
options.target_id.toFixed()
|
||||
);
|
||||
}
|
||||
if (options.state !== void 0) {
|
||||
installationUrl.searchParams.append("state", options.state);
|
||||
}
|
||||
return installationUrl.href;
|
||||
};
|
||||
}
|
||||
async function getInstallationUrlBase(app) {
|
||||
const { data: appInfo } = await app.octokit.request("GET /app");
|
||||
if (!appInfo) {
|
||||
throw new Error("[@octokit/app] unable to fetch metadata for app");
|
||||
}
|
||||
return `${appInfo.html_url}/installations/new`;
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/node/index.js
|
||||
import {
|
||||
createNodeMiddleware as oauthNodeMiddleware,
|
||||
sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
} from "@octokit/oauth-app";
|
||||
import { createNodeMiddleware as webhooksNodeMiddleware } from "@octokit/webhooks";
|
||||
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 = {
|
||||
pathPrefix: "/api/github",
|
||||
...options,
|
||||
log
|
||||
};
|
||||
const webhooksMiddleware = webhooksNodeMiddleware(app.webhooks, {
|
||||
path: optionsWithDefaults.pathPrefix + "/webhooks",
|
||||
log
|
||||
});
|
||||
const oauthMiddleware = oauthNodeMiddleware(app.oauth, {
|
||||
pathPrefix: optionsWithDefaults.pathPrefix + "/oauth"
|
||||
});
|
||||
return middleware.bind(
|
||||
null,
|
||||
optionsWithDefaults.pathPrefix,
|
||||
webhooksMiddleware,
|
||||
oauthMiddleware
|
||||
);
|
||||
}
|
||||
async function middleware(pathPrefix, webhooksMiddleware, oauthMiddleware, request, response, next) {
|
||||
const { pathname } = new URL(request.url, "http://localhost");
|
||||
if (pathname.startsWith(`${pathPrefix}/`)) {
|
||||
if (pathname === `${pathPrefix}/webhooks`) {
|
||||
webhooksMiddleware(request, response);
|
||||
} else if (pathname.startsWith(`${pathPrefix}/oauth/`)) {
|
||||
oauthMiddleware(request, response);
|
||||
} else {
|
||||
sendNodeResponse(unknownRouteResponse(request), response);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var App = class {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
octokit;
|
||||
// @ts-ignore calling app.webhooks will throw a helpful error when options.webhooks is not set
|
||||
webhooks;
|
||||
// @ts-ignore calling app.oauth will throw a helpful error when options.oauth is not set
|
||||
oauth;
|
||||
getInstallationOctokit;
|
||||
eachInstallation;
|
||||
eachRepository;
|
||||
getInstallationUrl;
|
||||
log;
|
||||
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
|
||||
} : {}
|
||||
);
|
||||
const octokitOptions = {
|
||||
authStrategy: createAppAuth3,
|
||||
auth: authOptions
|
||||
};
|
||||
if ("log" in options && typeof options.log !== "undefined") {
|
||||
octokitOptions.log = options.log;
|
||||
}
|
||||
this.octokit = new Octokit(octokitOptions);
|
||||
this.log = Object.assign(
|
||||
{
|
||||
debug: () => {
|
||||
},
|
||||
info: () => {
|
||||
},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
},
|
||||
options.log
|
||||
);
|
||||
if (options.webhooks) {
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
} else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
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
|
||||
);
|
||||
this.getInstallationUrl = getInstallationUrlFactory(this);
|
||||
}
|
||||
};
|
||||
export {
|
||||
App,
|
||||
createNodeMiddleware
|
||||
};
|
||||
7
node_modules/@octokit/app/dist-web/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/app/dist-web/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
62
node_modules/@octokit/app/package.json
generated
vendored
Normal file
62
node_modules/@octokit/app/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "@octokit/app",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "16.1.2",
|
||||
"description": "GitHub Apps toolset for Node.js",
|
||||
"main": "./dist-node/index.js",
|
||||
"repository": "github:octokit/app.js",
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-app": "^8.1.2",
|
||||
"@octokit/auth-unauthenticated": "^7.0.3",
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/oauth-app": "^8.0.3",
|
||||
"@octokit/plugin-paginate-rest": "^14.0.0",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"@octokit/webhooks": "^14.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"express": "^4.17.1",
|
||||
"fetch-mock": "^12.0.0",
|
||||
"mockdate": "^3.0.2",
|
||||
"prettier": "3.6.2",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"tinyglobby": "^0.2.13",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js"
|
||||
},
|
||||
"browser": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-web/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
1430
node_modules/@octokit/auth-app/README.md
generated
vendored
Normal file
1430
node_modules/@octokit/auth-app/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
490
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
Normal file
490
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,490 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as defaultRequest } from "@octokit/request";
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
|
||||
// pkg/dist-src/get-app-authentication.js
|
||||
import githubAppJwt from "universal-github-app-jwt";
|
||||
async function getAppAuthentication({
|
||||
appId,
|
||||
privateKey,
|
||||
timeDifference,
|
||||
createJwt
|
||||
}) {
|
||||
try {
|
||||
if (createJwt) {
|
||||
const { jwt, expiresAt } = await createJwt(appId, timeDifference);
|
||||
return {
|
||||
type: "app",
|
||||
token: jwt,
|
||||
appId,
|
||||
expiresAt
|
||||
};
|
||||
}
|
||||
const authOptions = {
|
||||
id: appId,
|
||||
privateKey
|
||||
};
|
||||
if (timeDifference) {
|
||||
Object.assign(authOptions, {
|
||||
now: Math.floor(Date.now() / 1e3) + timeDifference
|
||||
});
|
||||
}
|
||||
const appAuthentication = await githubAppJwt(authOptions);
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1e3).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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/cache.js
|
||||
import { Lru } from "toad-cache";
|
||||
function getCache() {
|
||||
return new Lru(
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
15e3,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
1e3 * 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((permissions2, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions2[string.slice(0, -1)] = "write";
|
||||
} else {
|
||||
permissions2[string] = "read";
|
||||
}
|
||||
return permissions2;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
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("|");
|
||||
}
|
||||
|
||||
// pkg/dist-src/to-token-authentication.js
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
// pkg/dist-src/get-installation-authentication.js
|
||||
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
|
||||
};
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const request = customRequest || state.request;
|
||||
return getInstallationAuthenticationConcurrently(
|
||||
state,
|
||||
{ ...options, installationId },
|
||||
request
|
||||
);
|
||||
}
|
||||
var pendingPromises = /* @__PURE__ */ new Map();
|
||||
function getInstallationAuthenticationConcurrently(state, options, request) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
if (pendingPromises.has(cacheKey)) {
|
||||
return pendingPromises.get(cacheKey);
|
||||
}
|
||||
const promise = getInstallationAuthenticationImpl(
|
||||
state,
|
||||
options,
|
||||
request
|
||||
).finally(() => pendingPromises.delete(cacheKey));
|
||||
pendingPromises.set(cacheKey, promise);
|
||||
return promise;
|
||||
}
|
||||
async function getInstallationAuthenticationImpl(state, options, request) {
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, options);
|
||||
if (result) {
|
||||
const {
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2,
|
||||
repositorySelection: repositorySelection2
|
||||
} = result;
|
||||
return toTokenAuthentication({
|
||||
installationId: options.installationId,
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositorySelection: repositorySelection2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const payload = {
|
||||
installation_id: options.installationId,
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`
|
||||
}
|
||||
};
|
||||
if (options.repositoryIds) {
|
||||
Object.assign(payload, { repository_ids: options.repositoryIds });
|
||||
}
|
||||
if (options.repositoryNames) {
|
||||
Object.assign(payload, {
|
||||
repositories: options.repositoryNames
|
||||
});
|
||||
}
|
||||
if (options.permissions) {
|
||||
Object.assign(payload, { permissions: options.permissions });
|
||||
}
|
||||
const {
|
||||
data: {
|
||||
token,
|
||||
expires_at: expiresAt,
|
||||
repositories,
|
||||
permissions: permissionsOptional,
|
||||
repository_selection: repositorySelectionOptional,
|
||||
single_file: singleFileName
|
||||
}
|
||||
} = await request(
|
||||
"POST /app/installations/{installation_id}/access_tokens",
|
||||
payload
|
||||
);
|
||||
const permissions = permissionsOptional || {};
|
||||
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 = (/* @__PURE__ */ new Date()).toISOString();
|
||||
const cacheOptions = {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(payload, { singleFileName });
|
||||
}
|
||||
await set(state.cache, options, cacheOptions);
|
||||
const cacheData = {
|
||||
installationId: options.installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(cacheData, { singleFileName });
|
||||
}
|
||||
return toTokenAuthentication(cacheData);
|
||||
}
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
authOptions;
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation"
|
||||
});
|
||||
case "oauth-user":
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
|
||||
// pkg/dist-src/requires-app-auth.js
|
||||
var 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",
|
||||
"/app/installation-requests",
|
||||
"/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",
|
||||
"/enterprises/{enterprise}/installation"
|
||||
];
|
||||
function routeMatcher(paths) {
|
||||
const regexes = paths.map(
|
||||
(p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
|
||||
);
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`;
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
var REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url.split("?")[0]);
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
var FIVE_SECONDS_IN_MS = 5 * 1e3;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(
|
||||
/'Expiration time' claim \('exp'\) is too far in the future/
|
||||
) || 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;
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token: token2 } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token2}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
} catch (error) {
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor(
|
||||
(Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3
|
||||
);
|
||||
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: token3 } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token3}`;
|
||||
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.defaults({ baseUrl: endpoint.baseUrl })
|
||||
);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(
|
||||
state,
|
||||
request,
|
||||
endpoint,
|
||||
createdAt
|
||||
);
|
||||
}
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +/* @__PURE__ */ 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 / 1e3}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 * 1e3;
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "8.2.0";
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!options.privateKey && !options.createJwt) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
} else if (options.privateKey && options.createJwt) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] privateKey and createJwt options are mutually exclusive"
|
||||
);
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId is set to a falsy value"
|
||||
);
|
||||
}
|
||||
const log = options.log || {};
|
||||
if (typeof log.warn !== "function") {
|
||||
log.warn = console.warn.bind(console);
|
||||
}
|
||||
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
|
||||
})
|
||||
}
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createAppAuth,
|
||||
createOAuthUserAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
23
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
Normal file
23
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication.js";
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
authOptions;
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation"
|
||||
});
|
||||
case "oauth-user":
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
79
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
Normal file
79
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Lru } from "toad-cache";
|
||||
function getCache() {
|
||||
return new Lru(
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
15e3,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
1e3 * 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((permissions2, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions2[string.slice(0, -1)] = "write";
|
||||
} else {
|
||||
permissions2[string] = "read";
|
||||
}
|
||||
return permissions2;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
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("|");
|
||||
}
|
||||
export {
|
||||
get,
|
||||
getCache,
|
||||
optionsToCacheKey,
|
||||
set
|
||||
};
|
||||
46
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
Normal file
46
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import githubAppJwt from "universal-github-app-jwt";
|
||||
async function getAppAuthentication({
|
||||
appId,
|
||||
privateKey,
|
||||
timeDifference,
|
||||
createJwt
|
||||
}) {
|
||||
try {
|
||||
if (createJwt) {
|
||||
const { jwt, expiresAt } = await createJwt(appId, timeDifference);
|
||||
return {
|
||||
type: "app",
|
||||
token: jwt,
|
||||
appId,
|
||||
expiresAt
|
||||
};
|
||||
}
|
||||
const authOptions = {
|
||||
id: appId,
|
||||
privateKey
|
||||
};
|
||||
if (timeDifference) {
|
||||
Object.assign(authOptions, {
|
||||
now: Math.floor(Date.now() / 1e3) + timeDifference
|
||||
});
|
||||
}
|
||||
const appAuthentication = await githubAppJwt(authOptions);
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1e3).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;
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
getAppAuthentication
|
||||
};
|
||||
135
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
Normal file
135
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
import { get, optionsToCacheKey, set } from "./cache.js";
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { toTokenAuthentication } from "./to-token-authentication.js";
|
||||
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
|
||||
};
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const request = customRequest || state.request;
|
||||
return getInstallationAuthenticationConcurrently(
|
||||
state,
|
||||
{ ...options, installationId },
|
||||
request
|
||||
);
|
||||
}
|
||||
const pendingPromises = /* @__PURE__ */ new Map();
|
||||
function getInstallationAuthenticationConcurrently(state, options, request) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
if (pendingPromises.has(cacheKey)) {
|
||||
return pendingPromises.get(cacheKey);
|
||||
}
|
||||
const promise = getInstallationAuthenticationImpl(
|
||||
state,
|
||||
options,
|
||||
request
|
||||
).finally(() => pendingPromises.delete(cacheKey));
|
||||
pendingPromises.set(cacheKey, promise);
|
||||
return promise;
|
||||
}
|
||||
async function getInstallationAuthenticationImpl(state, options, request) {
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, options);
|
||||
if (result) {
|
||||
const {
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2,
|
||||
repositorySelection: repositorySelection2
|
||||
} = result;
|
||||
return toTokenAuthentication({
|
||||
installationId: options.installationId,
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositorySelection: repositorySelection2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const payload = {
|
||||
installation_id: options.installationId,
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`
|
||||
}
|
||||
};
|
||||
if (options.repositoryIds) {
|
||||
Object.assign(payload, { repository_ids: options.repositoryIds });
|
||||
}
|
||||
if (options.repositoryNames) {
|
||||
Object.assign(payload, {
|
||||
repositories: options.repositoryNames
|
||||
});
|
||||
}
|
||||
if (options.permissions) {
|
||||
Object.assign(payload, { permissions: options.permissions });
|
||||
}
|
||||
const {
|
||||
data: {
|
||||
token,
|
||||
expires_at: expiresAt,
|
||||
repositories,
|
||||
permissions: permissionsOptional,
|
||||
repository_selection: repositorySelectionOptional,
|
||||
single_file: singleFileName
|
||||
}
|
||||
} = await request(
|
||||
"POST /app/installations/{installation_id}/access_tokens",
|
||||
payload
|
||||
);
|
||||
const permissions = permissionsOptional || {};
|
||||
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 = (/* @__PURE__ */ new Date()).toISOString();
|
||||
const cacheOptions = {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(payload, { singleFileName });
|
||||
}
|
||||
await set(state.cache, options, cacheOptions);
|
||||
const cacheData = {
|
||||
installationId: options.installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(cacheData, { singleFileName });
|
||||
}
|
||||
return toTokenAuthentication(cacheData);
|
||||
}
|
||||
export {
|
||||
getInstallationAuthentication
|
||||
};
|
||||
95
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
Normal file
95
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication.js";
|
||||
import { requiresAppAuth } from "./requires-app-auth.js";
|
||||
const FIVE_SECONDS_IN_MS = 5 * 1e3;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(
|
||||
/'Expiration time' claim \('exp'\) is too far in the future/
|
||||
) || 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;
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token: token2 } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token2}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
} catch (error) {
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor(
|
||||
(Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3
|
||||
);
|
||||
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: token3 } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token3}`;
|
||||
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.defaults({ baseUrl: endpoint.baseUrl })
|
||||
);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(
|
||||
state,
|
||||
request,
|
||||
endpoint,
|
||||
createdAt
|
||||
);
|
||||
}
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +/* @__PURE__ */ 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 / 1e3}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 * 1e3;
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
58
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
Normal file
58
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as defaultRequest } from "@octokit/request";
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
import { getCache } from "./cache.js";
|
||||
import { VERSION } from "./version.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!options.privateKey && !options.createJwt) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
} else if (options.privateKey && options.createJwt) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] privateKey and createJwt options are mutually exclusive"
|
||||
);
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId is set to a falsy value"
|
||||
);
|
||||
}
|
||||
const log = options.log || {};
|
||||
if (typeof log.warn !== "function") {
|
||||
log.warn = console.warn.bind(console);
|
||||
}
|
||||
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
|
||||
})
|
||||
}
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createAppAuth,
|
||||
createOAuthUserAuth
|
||||
};
|
||||
38
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
Normal file
38
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
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",
|
||||
"/app/installation-requests",
|
||||
"/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",
|
||||
"/enterprises/{enterprise}/installation"
|
||||
];
|
||||
function routeMatcher(paths) {
|
||||
const regexes = paths.map(
|
||||
(p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
|
||||
);
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`;
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
const REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url.split("?")[0]);
|
||||
}
|
||||
export {
|
||||
requiresAppAuth
|
||||
};
|
||||
30
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
Normal file
30
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
export {
|
||||
toTokenAuthentication
|
||||
};
|
||||
4
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "8.2.0";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
Normal file
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
import type { State, AppAuthOptions, AppAuthentication, OAuthAppAuthentication, OAuthAppAuthOptions, InstallationAuthOptions, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions } from "./types.js";
|
||||
/** 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>;
|
||||
6
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
Normal file
6
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Lru } from "toad-cache";
|
||||
import type { CacheableInstallationAuthOptions, Cache, CacheData, InstallationAccessTokenData } from "./types.js";
|
||||
export declare function getCache(): Lru<string>;
|
||||
export declare function get(cache: Cache, options: CacheableInstallationAuthOptions): Promise<InstallationAccessTokenData | void>;
|
||||
export declare function set(cache: Cache, options: CacheableInstallationAuthOptions, data: CacheData): Promise<void>;
|
||||
export declare function optionsToCacheKey({ installationId, permissions, repositoryIds, repositoryNames, }: CacheableInstallationAuthOptions): string;
|
||||
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { AppAuthentication, State } from "./types.js";
|
||||
export declare function getAppAuthentication({ appId, privateKey, timeDifference, createJwt, }: State & {
|
||||
timeDifference?: number | undefined;
|
||||
}): Promise<AppAuthentication>;
|
||||
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { InstallationAuthOptions, InstallationAccessTokenAuthentication, RequestInterface, State } from "./types.js";
|
||||
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
Normal file
2
node_modules/@octokit/auth-app/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { AnyResponse, EndpointOptions, RequestParameters, RequestInterface, Route, State } from "./types.js";
|
||||
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
Normal file
4
node_modules/@octokit/auth-app/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { AuthInterface, StrategyOptions } from "./types.js";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export type { StrategyOptions, AppAuthOptions, OAuthAppAuthOptions, InstallationAuthOptions, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions, Authentication, AppAuthentication, OAuthAppAuthentication, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, } from "./types.js";
|
||||
export declare function createAppAuth(options: StrategyOptions): AuthInterface;
|
||||
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function requiresAppAuth(url: string | undefined): Boolean;
|
||||
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { CacheData, InstallationAccessTokenAuthentication, WithInstallationId } from "./types.js";
|
||||
export declare function toTokenAuthentication({ installationId, token, createdAt, expiresAt, repositorySelection, permissions, repositoryIds, repositoryNames, singleFileName, }: CacheData & WithInstallationId): InstallationAccessTokenAuthentication;
|
||||
136
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
Normal file
136
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
import type * as OctokitTypes from "@octokit/types";
|
||||
import type { Lru } from "toad-cache";
|
||||
import type * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
type OAuthStrategyOptions = {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
};
|
||||
type AppAuthStrategyOptions = {
|
||||
privateKey: string;
|
||||
};
|
||||
type AppAuthJwtSigningStrategyOptions = {
|
||||
createJwt: (clientIdOrAppId: string | number, timeDifference?: number | undefined) => Promise<{
|
||||
jwt: string;
|
||||
expiresAt: string;
|
||||
}>;
|
||||
};
|
||||
type CommonStrategyOptions = {
|
||||
appId: number | string;
|
||||
installationId?: number | string;
|
||||
request?: OctokitTypes.RequestInterface;
|
||||
cache?: Cache;
|
||||
log?: {
|
||||
warn: (message: string, additionalInfo?: object) => any;
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
export type StrategyOptions = OAuthStrategyOptions & CommonStrategyOptions & (AppAuthStrategyOptions | AppAuthJwtSigningStrategyOptions) & Record<string, unknown>;
|
||||
export type AppAuthOptions = Partial<AppAuthJwtSigningStrategyOptions> & {
|
||||
type: "app";
|
||||
};
|
||||
/**
|
||||
Users SHOULD only enter repositoryIds || repositoryNames.
|
||||
However, this module still passes both to the backend API to
|
||||
let the API decide how to handle the logic. We just throw the
|
||||
response 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 CacheableInstallationAuthOptions = InstallationAuthOptions & {
|
||||
installationId: number;
|
||||
};
|
||||
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 | AppAuthJwtSigningStrategyOptions): 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 = Lru<string> | {
|
||||
get: (key: string) => string | Promise<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 | string;
|
||||
expiresAt: string;
|
||||
};
|
||||
export type InstallationAccessTokenData = {
|
||||
token: ACCESS_TOKEN;
|
||||
createdAt: UTC_TIMESTAMP;
|
||||
expiresAt: UTC_TIMESTAMP;
|
||||
permissions: Permissions;
|
||||
repositorySelection: REPOSITORY_SELECTION;
|
||||
repositoryIds?: number[] | undefined;
|
||||
repositoryNames?: string[] | undefined;
|
||||
singleFileName?: string | undefined;
|
||||
};
|
||||
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">> & Pick<Partial<AppAuthStrategyOptions>, "privateKey"> & Pick<Partial<AppAuthJwtSigningStrategyOptions>, "createJwt"> & {
|
||||
installationId?: number;
|
||||
} & OAuthStrategyOptions & {
|
||||
oauthApp: OAuthAppAuth.GitHubAuthInterface;
|
||||
};
|
||||
export {};
|
||||
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "8.2.0";
|
||||
59
node_modules/@octokit/auth-app/package.json
generated
vendored
Normal file
59
node_modules/@octokit/auth-app/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "@octokit/auth-app",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "8.2.0",
|
||||
"description": "GitHub App authentication for JavaScript",
|
||||
"repository": "github:octokit/auth-app.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-app": "^9.0.3",
|
||||
"@octokit/auth-oauth-user": "^6.0.2",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"toad-cache": "^3.7.0",
|
||||
"universal-github-app-jwt": "^2.2.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"@vitest/ui": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^11.0.0",
|
||||
"prettier": "3.6.2",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"tinyglobby": "^0.2.13",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"main": "dist-node/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js",
|
||||
"default": "./dist-node/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
21
node_modules/@octokit/auth-oauth-app/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-oauth-app/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
1059
node_modules/@octokit/auth-oauth-app/README.md
generated
vendored
Normal file
1059
node_modules/@octokit/auth-oauth-app/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
94
node_modules/@octokit/auth-oauth-app/dist-bundle/index.js
generated
vendored
Normal file
94
node_modules/@octokit/auth-oauth-app/dist-bundle/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request } from "@octokit/request";
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
import { 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
|
||||
};
|
||||
return authOptions.factory(options);
|
||||
}
|
||||
const common = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.request,
|
||||
...authOptions
|
||||
};
|
||||
const userAuth = state.clientType === "oauth-app" ? await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
}) : await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
});
|
||||
return userAuth();
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
async function hook(state, request2, route, parameters) {
|
||||
let endpoint = request2.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request2(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 request2(endpoint);
|
||||
} catch (error) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "0.0.0-development";
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
import { createOAuthUserAuth as createOAuthUserAuth2 } from "@octokit/auth-oauth-user";
|
||||
function createOAuthAppAuth(options) {
|
||||
const state = Object.assign(
|
||||
{
|
||||
request: request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
|
||||
}
|
||||
}),
|
||||
clientType: "oauth-app"
|
||||
},
|
||||
options
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createOAuthAppAuth,
|
||||
createOAuthUserAuth2 as createOAuthUserAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-oauth-app/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-oauth-app/dist-bundle/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/index.js", "../dist-src/auth.js", "../dist-src/hook.js", "../dist-src/version.js"],
|
||||
"sourcesContent": ["import { getUserAgent } from \"universal-user-agent\";\nimport { request } from \"@octokit/request\";\nimport { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nimport { VERSION } from \"./version.js\";\nimport { createOAuthUserAuth } from \"@octokit/auth-oauth-user\";\nfunction createOAuthAppAuth(options) {\n const state = Object.assign(\n {\n request: request.defaults({\n headers: {\n \"user-agent\": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`\n }\n }),\n clientType: \"oauth-app\"\n },\n options\n );\n return Object.assign(auth.bind(null, state), {\n hook: hook.bind(null, state)\n });\n}\nexport {\n createOAuthAppAuth,\n createOAuthUserAuth\n};\n", "import { createOAuthUserAuth } from \"@octokit/auth-oauth-user\";\nasync function auth(state, authOptions) {\n if (authOptions.type === \"oauth-app\") {\n return {\n type: \"oauth-app\",\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n clientType: state.clientType,\n headers: {\n authorization: `basic ${btoa(\n `${state.clientId}:${state.clientSecret}`\n )}`\n }\n };\n }\n if (\"factory\" in authOptions) {\n const { type, ...options } = {\n ...authOptions,\n ...state\n };\n return authOptions.factory(options);\n }\n const common = {\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n request: state.request,\n ...authOptions\n };\n const userAuth = state.clientType === \"oauth-app\" ? await createOAuthUserAuth({\n ...common,\n clientType: state.clientType\n }) : await createOAuthUserAuth({\n ...common,\n clientType: state.clientType\n });\n return userAuth();\n}\nexport {\n auth\n};\n", "import { requiresBasicAuth } from \"@octokit/auth-oauth-user\";\nasync function hook(state, request, route, parameters) {\n let endpoint = request.endpoint.merge(\n route,\n parameters\n );\n if (/\\/login\\/(oauth\\/access_token|device\\/code)$/.test(endpoint.url)) {\n return request(endpoint);\n }\n if (state.clientType === \"github-app\" && !requiresBasicAuth(endpoint.url)) {\n throw new Error(\n `[@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.`\n );\n }\n const credentials = btoa(`${state.clientId}:${state.clientSecret}`);\n endpoint.headers.authorization = `basic ${credentials}`;\n try {\n return await request(endpoint);\n } catch (error) {\n if (error.status !== 401) throw error;\n error.message = `[@octokit/auth-oauth-app] \"${endpoint.method} ${endpoint.url}\" does not support clientId/clientSecret basic authentication.`;\n throw error;\n }\n}\nexport {\n hook\n};\n", "const VERSION = \"0.0.0-development\";\nexport {\n VERSION\n};\n"],
|
||||
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,eAAe;;;ACDxB,SAAS,2BAA2B;AACpC,eAAe,KAAK,OAAO,aAAa;AACtC,MAAI,YAAY,SAAS,aAAa;AACpC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU,MAAM;AAAA,MAChB,cAAc,MAAM;AAAA,MACpB,YAAY,MAAM;AAAA,MAClB,SAAS;AAAA,QACP,eAAe,SAAS;AAAA,UACtB,GAAG,MAAM,QAAQ,IAAI,MAAM,YAAY;AAAA,QACzC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACA,MAAI,aAAa,aAAa;AAC5B,UAAM,EAAE,MAAM,GAAG,QAAQ,IAAI;AAAA,MAC3B,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AACA,WAAO,YAAY,QAAQ,OAAO;AAAA,EACpC;AACA,QAAM,SAAS;AAAA,IACb,UAAU,MAAM;AAAA,IAChB,cAAc,MAAM;AAAA,IACpB,SAAS,MAAM;AAAA,IACf,GAAG;AAAA,EACL;AACA,QAAM,WAAW,MAAM,eAAe,cAAc,MAAM,oBAAoB;AAAA,IAC5E,GAAG;AAAA,IACH,YAAY,MAAM;AAAA,EACpB,CAAC,IAAI,MAAM,oBAAoB;AAAA,IAC7B,GAAG;AAAA,IACH,YAAY,MAAM;AAAA,EACpB,CAAC;AACD,SAAO,SAAS;AAClB;;;ACpCA,SAAS,yBAAyB;AAClC,eAAe,KAAK,OAAOA,UAAS,OAAO,YAAY;AACrD,MAAI,WAAWA,SAAQ,SAAS;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AACA,MAAI,+CAA+C,KAAK,SAAS,GAAG,GAAG;AACrE,WAAOA,SAAQ,QAAQ;AAAA,EACzB;AACA,MAAI,MAAM,eAAe,gBAAgB,CAAC,kBAAkB,SAAS,GAAG,GAAG;AACzE,UAAM,IAAI;AAAA,MACR,8JAA8J,SAAS,MAAM,IAAI,SAAS,GAAG;AAAA,IAC/L;AAAA,EACF;AACA,QAAM,cAAc,KAAK,GAAG,MAAM,QAAQ,IAAI,MAAM,YAAY,EAAE;AAClE,WAAS,QAAQ,gBAAgB,SAAS,WAAW;AACrD,MAAI;AACF,WAAO,MAAMA,SAAQ,QAAQ;AAAA,EAC/B,SAAS,OAAO;AACd,QAAI,MAAM,WAAW,IAAK,OAAM;AAChC,UAAM,UAAU,8BAA8B,SAAS,MAAM,IAAI,SAAS,GAAG;AAC7E,UAAM;AAAA,EACR;AACF;;;ACvBA,IAAM,UAAU;;;AHKhB,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,mBAAmB,SAAS;AACnC,QAAM,QAAQ,OAAO;AAAA,IACnB;AAAA,MACE,SAAS,QAAQ,SAAS;AAAA,QACxB,SAAS;AAAA,UACP,cAAc,6BAA6B,OAAO,IAAI,aAAa,CAAC;AAAA,QACtE;AAAA,MACF,CAAC;AAAA,MACD,YAAY;AAAA,IACd;AAAA,IACA;AAAA,EACF;AACA,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;AAAA,IAC3C,MAAM,KAAK,KAAK,MAAM,KAAK;AAAA,EAC7B,CAAC;AACH;",
|
||||
"names": ["request", "createOAuthUserAuth"]
|
||||
}
|
||||
40
node_modules/@octokit/auth-oauth-app/dist-src/auth.js
generated
vendored
Normal file
40
node_modules/@octokit/auth-oauth-app/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { 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
|
||||
};
|
||||
return authOptions.factory(options);
|
||||
}
|
||||
const common = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.request,
|
||||
...authOptions
|
||||
};
|
||||
const userAuth = state.clientType === "oauth-app" ? await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
}) : await createOAuthUserAuth({
|
||||
...common,
|
||||
clientType: state.clientType
|
||||
});
|
||||
return userAuth();
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
27
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
Normal file
27
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
26
node_modules/@octokit/auth-oauth-app/dist-src/index.js
generated
vendored
Normal file
26
node_modules/@octokit/auth-oauth-app/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request } from "@octokit/request";
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
import { VERSION } from "./version.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
function createOAuthAppAuth(options) {
|
||||
const state = Object.assign(
|
||||
{
|
||||
request: request.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
|
||||
}
|
||||
}),
|
||||
clientType: "oauth-app"
|
||||
},
|
||||
options
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createOAuthAppAuth,
|
||||
createOAuthUserAuth
|
||||
};
|
||||
4
node_modules/@octokit/auth-oauth-app/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/auth-oauth-app/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "9.0.3";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
18
node_modules/@octokit/auth-oauth-app/dist-types/auth.d.ts
generated
vendored
Normal file
18
node_modules/@octokit/auth-oauth-app/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { OAuthAppState, GitHubAppState, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, FactoryOAuthAppWebFlow, FactoryOAuthAppDeviceFlow, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "./types.js";
|
||||
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
Normal file
3
node_modules/@octokit/auth-oauth-app/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
|
||||
import type { OAuthAppState, GitHubAppState } from "./types.js";
|
||||
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
Normal file
5
node_modules/@octokit/auth-oauth-app/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAuthInterface } from "./types.js";
|
||||
export type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, OAuthAppAuthInterface, GitHubAuthInterface, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, } from "./types.js";
|
||||
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
Normal file
98
node_modules/@octokit/auth-oauth-app/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import type { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
|
||||
import type * as AuthOAuthUser from "@octokit/auth-oauth-user";
|
||||
import type * 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
Normal file
1
node_modules/@octokit/auth-oauth-app/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "9.0.3";
|
||||
56
node_modules/@octokit/auth-oauth-app/package.json
generated
vendored
Normal file
56
node_modules/@octokit/auth-oauth-app/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "@octokit/auth-oauth-app",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "9.0.3",
|
||||
"description": "GitHub OAuth App authentication for JavaScript",
|
||||
"repository": "github:octokit/auth-oauth-app.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"oauth",
|
||||
"api"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-device": "^8.0.3",
|
||||
"@octokit/auth-oauth-user": "^6.0.2",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^22.13.1",
|
||||
"@vitest/coverage-v8": "^3.0.5",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^12.0.0",
|
||||
"prettier": "3.5.3",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"tinyglobby": "^0.2.13",
|
||||
"typescript": "^5.3.0",
|
||||
"vitest": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-bundle/index.js",
|
||||
"default": "./dist-bundle/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
9
node_modules/@octokit/auth-oauth-device/LICENSE
generated
vendored
Normal file
9
node_modules/@octokit/auth-oauth-device/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
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.
|
||||
662
node_modules/@octokit/auth-oauth-device/README.md
generated
vendored
Normal file
662
node_modules/@octokit/auth-oauth-device/README.md
generated
vendored
Normal file
@@ -0,0 +1,662 @@
|
||||
# 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 [esm.sh](https://esm.sh)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { createOAuthDeviceAuth } from "https://esm.sh/@octokit/auth-oauth-device";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
|
||||
Node
|
||||
|
||||
</th><td>
|
||||
|
||||
Install with `npm install @octokit/core @octokit/auth-oauth-device`
|
||||
|
||||
```js
|
||||
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
> [!IMPORTANT]
|
||||
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
|
||||
>
|
||||
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
|
||||
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
|
||||
|
||||
### 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
|
||||
import { request } from "@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 relevant 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)
|
||||
138
node_modules/@octokit/auth-oauth-device/dist-bundle/index.js
generated
vendored
Normal file
138
node_modules/@octokit/auth-oauth-device/dist-bundle/index.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
|
||||
// pkg/dist-src/get-oauth-access-token.js
|
||||
import { createDeviceCode, exchangeDeviceCode } from "@octokit/oauth-methods";
|
||||
async function getOAuthAccessToken(state, options) {
|
||||
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
||||
if (cachedAuthentication) return cachedAuthentication;
|
||||
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
|
||||
});
|
||||
await state.onVerification(verification);
|
||||
const authentication = await waitForAccessToken(
|
||||
options.request || state.request,
|
||||
state.clientId,
|
||||
state.clientType,
|
||||
verification
|
||||
);
|
||||
state.authentication = authentication;
|
||||
return authentication;
|
||||
}
|
||||
function getCachedAuthentication(state, auth2) {
|
||||
if (auth2.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 auth2 && auth2.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 * 1e3));
|
||||
}
|
||||
async function waitForAccessToken(request, clientId, clientType, verification) {
|
||||
try {
|
||||
const options = {
|
||||
clientId,
|
||||
request,
|
||||
code: verification.device_code
|
||||
};
|
||||
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) {
|
||||
if (!error.response) throw error;
|
||||
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 + 7);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(state, authOptions) {
|
||||
return getOAuthAccessToken(state, {
|
||||
auth: authOptions
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "0.0.0-development";
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
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)'
|
||||
);
|
||||
}
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createOAuthDeviceAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-oauth-device/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-oauth-device/dist-bundle/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/index.js", "../dist-src/get-oauth-access-token.js", "../dist-src/auth.js", "../dist-src/hook.js", "../dist-src/version.js"],
|
||||
"sourcesContent": ["import { getUserAgent } from \"universal-user-agent\";\nimport { request as octokitRequest } from \"@octokit/request\";\nimport { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nimport { VERSION } from \"./version.js\";\nfunction createOAuthDeviceAuth(options) {\n const requestWithDefaults = options.request || octokitRequest.defaults({\n headers: {\n \"user-agent\": `octokit-auth-oauth-device.js/${VERSION} ${getUserAgent()}`\n }\n });\n const { request = requestWithDefaults, ...otherOptions } = options;\n const state = options.clientType === \"github-app\" ? {\n ...otherOptions,\n clientType: \"github-app\",\n request\n } : {\n ...otherOptions,\n clientType: \"oauth-app\",\n request,\n scopes: options.scopes || []\n };\n if (!options.clientId) {\n throw new Error(\n '[@octokit/auth-oauth-device] \"clientId\" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)'\n );\n }\n if (!options.onVerification) {\n throw new Error(\n '[@octokit/auth-oauth-device] \"onVerification\" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)'\n );\n }\n return Object.assign(auth.bind(null, state), {\n hook: hook.bind(null, state)\n });\n}\nexport {\n createOAuthDeviceAuth\n};\n", "import { createDeviceCode, exchangeDeviceCode } from \"@octokit/oauth-methods\";\nasync function getOAuthAccessToken(state, options) {\n const cachedAuthentication = getCachedAuthentication(state, options.auth);\n if (cachedAuthentication) return cachedAuthentication;\n const { data: verification } = await createDeviceCode({\n clientType: state.clientType,\n clientId: state.clientId,\n request: options.request || state.request,\n // @ts-expect-error the extra code to make TS happy is not worth it\n scopes: options.auth.scopes || state.scopes\n });\n await state.onVerification(verification);\n const authentication = await waitForAccessToken(\n options.request || state.request,\n state.clientId,\n state.clientType,\n verification\n );\n state.authentication = authentication;\n return authentication;\n}\nfunction getCachedAuthentication(state, auth) {\n if (auth.refresh === true) return false;\n if (!state.authentication) return false;\n if (state.clientType === \"github-app\") {\n return state.authentication;\n }\n const authentication = state.authentication;\n const newScope = (\"scopes\" in auth && auth.scopes || state.scopes).join(\n \" \"\n );\n const currentScope = authentication.scopes.join(\" \");\n return newScope === currentScope ? authentication : false;\n}\nasync function wait(seconds) {\n await new Promise((resolve) => setTimeout(resolve, seconds * 1e3));\n}\nasync function waitForAccessToken(request, clientId, clientType, verification) {\n try {\n const options = {\n clientId,\n request,\n code: verification.device_code\n };\n const { authentication } = clientType === \"oauth-app\" ? await exchangeDeviceCode({\n ...options,\n clientType: \"oauth-app\"\n }) : await exchangeDeviceCode({\n ...options,\n clientType: \"github-app\"\n });\n return {\n type: \"token\",\n tokenType: \"oauth\",\n ...authentication\n };\n } catch (error) {\n if (!error.response) throw error;\n const errorType = error.response.data.error;\n if (errorType === \"authorization_pending\") {\n await wait(verification.interval);\n return waitForAccessToken(request, clientId, clientType, verification);\n }\n if (errorType === \"slow_down\") {\n await wait(verification.interval + 7);\n return waitForAccessToken(request, clientId, clientType, verification);\n }\n throw error;\n }\n}\nexport {\n getOAuthAccessToken\n};\n", "import { getOAuthAccessToken } from \"./get-oauth-access-token.js\";\nasync function auth(state, authOptions) {\n return getOAuthAccessToken(state, {\n auth: authOptions\n });\n}\nexport {\n auth\n};\n", "import { getOAuthAccessToken } from \"./get-oauth-access-token.js\";\nasync function hook(state, request, route, parameters) {\n let endpoint = request.endpoint.merge(\n route,\n parameters\n );\n if (/\\/login\\/(oauth\\/access_token|device\\/code)$/.test(endpoint.url)) {\n return request(endpoint);\n }\n const { token } = await getOAuthAccessToken(state, {\n request,\n auth: { type: \"oauth\" }\n });\n endpoint.headers.authorization = `token ${token}`;\n return request(endpoint);\n}\nexport {\n hook\n};\n", "const VERSION = \"0.0.0-development\";\nexport {\n VERSION\n};\n"],
|
||||
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,WAAW,sBAAsB;;;ACD1C,SAAS,kBAAkB,0BAA0B;AACrD,eAAe,oBAAoB,OAAO,SAAS;AACjD,QAAM,uBAAuB,wBAAwB,OAAO,QAAQ,IAAI;AACxE,MAAI,qBAAsB,QAAO;AACjC,QAAM,EAAE,MAAM,aAAa,IAAI,MAAM,iBAAiB;AAAA,IACpD,YAAY,MAAM;AAAA,IAClB,UAAU,MAAM;AAAA,IAChB,SAAS,QAAQ,WAAW,MAAM;AAAA;AAAA,IAElC,QAAQ,QAAQ,KAAK,UAAU,MAAM;AAAA,EACvC,CAAC;AACD,QAAM,MAAM,eAAe,YAAY;AACvC,QAAM,iBAAiB,MAAM;AAAA,IAC3B,QAAQ,WAAW,MAAM;AAAA,IACzB,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACF;AACA,QAAM,iBAAiB;AACvB,SAAO;AACT;AACA,SAAS,wBAAwB,OAAOA,OAAM;AAC5C,MAAIA,MAAK,YAAY,KAAM,QAAO;AAClC,MAAI,CAAC,MAAM,eAAgB,QAAO;AAClC,MAAI,MAAM,eAAe,cAAc;AACrC,WAAO,MAAM;AAAA,EACf;AACA,QAAM,iBAAiB,MAAM;AAC7B,QAAM,YAAY,YAAYA,SAAQA,MAAK,UAAU,MAAM,QAAQ;AAAA,IACjE;AAAA,EACF;AACA,QAAM,eAAe,eAAe,OAAO,KAAK,GAAG;AACnD,SAAO,aAAa,eAAe,iBAAiB;AACtD;AACA,eAAe,KAAK,SAAS;AAC3B,QAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,UAAU,GAAG,CAAC;AACnE;AACA,eAAe,mBAAmB,SAAS,UAAU,YAAY,cAAc;AAC7E,MAAI;AACF,UAAM,UAAU;AAAA,MACd;AAAA,MACA;AAAA,MACA,MAAM,aAAa;AAAA,IACrB;AACA,UAAM,EAAE,eAAe,IAAI,eAAe,cAAc,MAAM,mBAAmB;AAAA,MAC/E,GAAG;AAAA,MACH,YAAY;AAAA,IACd,CAAC,IAAI,MAAM,mBAAmB;AAAA,MAC5B,GAAG;AAAA,MACH,YAAY;AAAA,IACd,CAAC;AACD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,MACX,GAAG;AAAA,IACL;AAAA,EACF,SAAS,OAAO;AACd,QAAI,CAAC,MAAM,SAAU,OAAM;AAC3B,UAAM,YAAY,MAAM,SAAS,KAAK;AACtC,QAAI,cAAc,yBAAyB;AACzC,YAAM,KAAK,aAAa,QAAQ;AAChC,aAAO,mBAAmB,SAAS,UAAU,YAAY,YAAY;AAAA,IACvE;AACA,QAAI,cAAc,aAAa;AAC7B,YAAM,KAAK,aAAa,WAAW,CAAC;AACpC,aAAO,mBAAmB,SAAS,UAAU,YAAY,YAAY;AAAA,IACvE;AACA,UAAM;AAAA,EACR;AACF;;;ACpEA,eAAe,KAAK,OAAO,aAAa;AACtC,SAAO,oBAAoB,OAAO;AAAA,IAChC,MAAM;AAAA,EACR,CAAC;AACH;;;ACJA,eAAe,KAAK,OAAO,SAAS,OAAO,YAAY;AACrD,MAAI,WAAW,QAAQ,SAAS;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AACA,MAAI,+CAA+C,KAAK,SAAS,GAAG,GAAG;AACrE,WAAO,QAAQ,QAAQ;AAAA,EACzB;AACA,QAAM,EAAE,MAAM,IAAI,MAAM,oBAAoB,OAAO;AAAA,IACjD;AAAA,IACA,MAAM,EAAE,MAAM,QAAQ;AAAA,EACxB,CAAC;AACD,WAAS,QAAQ,gBAAgB,SAAS,KAAK;AAC/C,SAAO,QAAQ,QAAQ;AACzB;;;ACfA,IAAM,UAAU;;;AJKhB,SAAS,sBAAsB,SAAS;AACtC,QAAM,sBAAsB,QAAQ,WAAW,eAAe,SAAS;AAAA,IACrE,SAAS;AAAA,MACP,cAAc,gCAAgC,OAAO,IAAI,aAAa,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACD,QAAM,EAAE,UAAU,qBAAqB,GAAG,aAAa,IAAI;AAC3D,QAAM,QAAQ,QAAQ,eAAe,eAAe;AAAA,IAClD,GAAG;AAAA,IACH,YAAY;AAAA,IACZ;AAAA,EACF,IAAI;AAAA,IACF,GAAG;AAAA,IACH,YAAY;AAAA,IACZ;AAAA,IACA,QAAQ,QAAQ,UAAU,CAAC;AAAA,EAC7B;AACA,MAAI,CAAC,QAAQ,UAAU;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,QAAQ,gBAAgB;AAC3B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;AAAA,IAC3C,MAAM,KAAK,KAAK,MAAM,KAAK;AAAA,EAC7B,CAAC;AACH;",
|
||||
"names": ["auth"]
|
||||
}
|
||||
9
node_modules/@octokit/auth-oauth-device/dist-src/auth.js
generated
vendored
Normal file
9
node_modules/@octokit/auth-oauth-device/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getOAuthAccessToken } from "./get-oauth-access-token.js";
|
||||
async function auth(state, authOptions) {
|
||||
return getOAuthAccessToken(state, {
|
||||
auth: authOptions
|
||||
});
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
73
node_modules/@octokit/auth-oauth-device/dist-src/get-oauth-access-token.js
generated
vendored
Normal file
73
node_modules/@octokit/auth-oauth-device/dist-src/get-oauth-access-token.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import { createDeviceCode, exchangeDeviceCode } from "@octokit/oauth-methods";
|
||||
async function getOAuthAccessToken(state, options) {
|
||||
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
||||
if (cachedAuthentication) return cachedAuthentication;
|
||||
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
|
||||
});
|
||||
await state.onVerification(verification);
|
||||
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 * 1e3));
|
||||
}
|
||||
async function waitForAccessToken(request, clientId, clientType, verification) {
|
||||
try {
|
||||
const options = {
|
||||
clientId,
|
||||
request,
|
||||
code: verification.device_code
|
||||
};
|
||||
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) {
|
||||
if (!error.response) throw error;
|
||||
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 + 7);
|
||||
return waitForAccessToken(request, clientId, clientType, verification);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
export {
|
||||
getOAuthAccessToken
|
||||
};
|
||||
19
node_modules/@octokit/auth-oauth-device/dist-src/hook.js
generated
vendored
Normal file
19
node_modules/@octokit/auth-oauth-device/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getOAuthAccessToken } from "./get-oauth-access-token.js";
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
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);
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
39
node_modules/@octokit/auth-oauth-device/dist-src/index.js
generated
vendored
Normal file
39
node_modules/@octokit/auth-oauth-device/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
import { VERSION } from "./version.js";
|
||||
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)'
|
||||
);
|
||||
}
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createOAuthDeviceAuth
|
||||
};
|
||||
4
node_modules/@octokit/auth-oauth-device/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/auth-oauth-device/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "8.0.3";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
2
node_modules/@octokit/auth-oauth-device/dist-types/auth.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-oauth-device/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, OAuthAppState, GitHubAppState } from "./types.js";
|
||||
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
Normal file
6
node_modules/@octokit/auth-oauth-device/dist-types/get-oauth-access-token.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { RequestInterface } from "@octokit/types";
|
||||
import type { OAuthAppState, GitHubAppState, OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication } from "./types.js";
|
||||
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
Normal file
3
node_modules/@octokit/auth-oauth-device/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { RequestInterface, OctokitResponse, EndpointOptions, RequestParameters, Route } from "@octokit/types";
|
||||
import type { OAuthAppState, GitHubAppState } from "./types.js";
|
||||
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
Normal file
4
node_modules/@octokit/auth-oauth-device/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { GitHubAppAuthInterface, GitHubAppStrategyOptions, OAuthAppAuthInterface, OAuthAppStrategyOptions } from "./types.js";
|
||||
export type { OAuthAppStrategyOptions, OAuthAppAuthOptions, OAuthAppAuthentication, GitHubAppStrategyOptions, GitHubAppAuthOptions, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types.js";
|
||||
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
Normal file
68
node_modules/@octokit/auth-oauth-device/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { RequestInterface, Route, EndpointOptions, RequestParameters, OctokitResponse } from "@octokit/types";
|
||||
import type * 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.GitHubAppAuthenticationWithExpirationDisabled, "clientSecret">;
|
||||
export type GitHubAppAuthenticationWithExpiration = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
} & Omit<OAuthMethodsTypes.GitHubAppAuthenticationWithRefreshToken, "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
Normal file
1
node_modules/@octokit/auth-oauth-device/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "8.0.3";
|
||||
53
node_modules/@octokit/auth-oauth-device/package.json
generated
vendored
Normal file
53
node_modules/@octokit/auth-oauth-device/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "@octokit/auth-oauth-device",
|
||||
"version": "8.0.3",
|
||||
"description": "GitHub OAuth Device authentication strategy for JavaScript",
|
||||
"type": "module",
|
||||
"repository": "github:octokit/auth-oauth-device.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"author": "Gregor Martynus (https://dev.to/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/oauth-methods": "^6.0.2",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^12.0.0",
|
||||
"glob": "^11.0.0",
|
||||
"prettier": "3.6.2",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-bundle/index.js",
|
||||
"default": "./dist-bundle/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
9
node_modules/@octokit/auth-oauth-user/LICENSE
generated
vendored
Normal file
9
node_modules/@octokit/auth-oauth-user/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
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.
|
||||
1038
node_modules/@octokit/auth-oauth-user/README.md
generated
vendored
Normal file
1038
node_modules/@octokit/auth-oauth-user/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
208
node_modules/@octokit/auth-oauth-user/dist-bundle/index.js
generated
vendored
Normal file
208
node_modules/@octokit/auth-oauth-user/dist-bundle/index.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "0.0.0-development";
|
||||
|
||||
// pkg/dist-src/get-authentication.js
|
||||
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
||||
async function getAuthentication(state) {
|
||||
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
|
||||
};
|
||||
}
|
||||
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
|
||||
};
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
import {
|
||||
checkToken,
|
||||
deleteAuthorization,
|
||||
deleteToken,
|
||||
refreshToken,
|
||||
resetToken
|
||||
} from "@octokit/oauth-methods";
|
||||
async function auth(state, options = {}) {
|
||||
if (!state.authentication) {
|
||||
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;
|
||||
if ("expiresAt" in currentAuthentication) {
|
||||
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ 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
|
||||
};
|
||||
}
|
||||
}
|
||||
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
|
||||
});
|
||||
}
|
||||
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) {
|
||||
if (error.status === 404) {
|
||||
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
||||
state.authentication.invalid = true;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
if (error.status !== 404) throw error;
|
||||
}
|
||||
state.authentication.invalid = true;
|
||||
return state.authentication;
|
||||
}
|
||||
return state.authentication;
|
||||
}
|
||||
|
||||
// pkg/dist-src/requires-basic-auth.js
|
||||
var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
||||
function requiresBasicAuth(url) {
|
||||
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(state, request, route, parameters = {}) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
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);
|
||||
}
|
||||
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
|
||||
endpoint.headers.authorization = "token " + token;
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
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
|
||||
});
|
||||
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;
|
||||
export {
|
||||
createOAuthUserAuth,
|
||||
requiresBasicAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-oauth-user/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-oauth-user/dist-bundle/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
98
node_modules/@octokit/auth-oauth-user/dist-src/auth.js
generated
vendored
Normal file
98
node_modules/@octokit/auth-oauth-user/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import { getAuthentication } from "./get-authentication.js";
|
||||
import {
|
||||
checkToken,
|
||||
deleteAuthorization,
|
||||
deleteToken,
|
||||
refreshToken,
|
||||
resetToken
|
||||
} from "@octokit/oauth-methods";
|
||||
async function auth(state, options = {}) {
|
||||
if (!state.authentication) {
|
||||
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;
|
||||
if ("expiresAt" in currentAuthentication) {
|
||||
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ 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
|
||||
};
|
||||
}
|
||||
}
|
||||
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
|
||||
});
|
||||
}
|
||||
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) {
|
||||
if (error.status === 404) {
|
||||
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
||||
state.authentication.invalid = true;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
if (error.status !== 404) throw error;
|
||||
}
|
||||
state.authentication.invalid = true;
|
||||
return state.authentication;
|
||||
}
|
||||
return state.authentication;
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
50
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
Normal file
50
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
||||
async function getAuthentication(state) {
|
||||
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
|
||||
};
|
||||
}
|
||||
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
|
||||
};
|
||||
}
|
||||
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");
|
||||
}
|
||||
export {
|
||||
getAuthentication
|
||||
};
|
||||
22
node_modules/@octokit/auth-oauth-user/dist-src/hook.js
generated
vendored
Normal file
22
node_modules/@octokit/auth-oauth-user/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { auth } from "./auth.js";
|
||||
import { requiresBasicAuth } from "./requires-basic-auth.js";
|
||||
async function hook(state, request, route, parameters = {}) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
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);
|
||||
}
|
||||
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
|
||||
endpoint.headers.authorization = "token " + token;
|
||||
return request(endpoint);
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
36
node_modules/@octokit/auth-oauth-user/dist-src/index.js
generated
vendored
Normal file
36
node_modules/@octokit/auth-oauth-user/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as octokitRequest } from "@octokit/request";
|
||||
import { VERSION } from "./version.js";
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
import { requiresBasicAuth } from "./requires-basic-auth.js";
|
||||
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
|
||||
});
|
||||
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;
|
||||
export {
|
||||
createOAuthUserAuth,
|
||||
requiresBasicAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-oauth-user/dist-src/requires-basic-auth.js
generated
vendored
Normal file
7
node_modules/@octokit/auth-oauth-user/dist-src/requires-basic-auth.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
||||
function requiresBasicAuth(url) {
|
||||
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
||||
}
|
||||
export {
|
||||
requiresBasicAuth
|
||||
};
|
||||
4
node_modules/@octokit/auth-oauth-user/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/auth-oauth-user/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "6.0.2";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
3
node_modules/@octokit/auth-oauth-user/dist-types/auth.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/auth-oauth-user/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, OAuthAppState, GitHubAppState } from "./types.js";
|
||||
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
Normal file
3
node_modules/@octokit/auth-oauth-user/dist-types/get-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { OAuthAppState, GitHubAppState, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration } from "./types.js";
|
||||
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
Normal file
6
node_modules/@octokit/auth-oauth-user/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { EndpointOptions, OctokitResponse, RequestInterface, RequestParameters, Route } from "@octokit/types";
|
||||
import type { OAuthAppState, GitHubAppState } from "./types.js";
|
||||
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 {};
|
||||
8
node_modules/@octokit/auth-oauth-user/dist-types/index.d.ts
generated
vendored
Normal file
8
node_modules/@octokit/auth-oauth-user/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAppAuthInterface } from "./types.js";
|
||||
export type { OAuthAppStrategyOptionsWebFlow, GitHubAppStrategyOptionsWebFlow, OAuthAppStrategyOptionsDeviceFlow, GitHubAppStrategyOptionsDeviceFlow, OAuthAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthenticationWithExpiration, OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types.js";
|
||||
export { requiresBasicAuth } from "./requires-basic-auth.js";
|
||||
export declare function createOAuthUserAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
|
||||
export declare function createOAuthUserAuth(options: GitHubAppStrategyOptions): GitHubAppAuthInterface;
|
||||
export declare namespace createOAuthUserAuth {
|
||||
var VERSION: string;
|
||||
}
|
||||
1
node_modules/@octokit/auth-oauth-user/dist-types/requires-basic-auth.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-oauth-user/dist-types/requires-basic-auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function requiresBasicAuth(url: string | undefined): boolean | "" | undefined;
|
||||
114
node_modules/@octokit/auth-oauth-user/dist-types/types.d.ts
generated
vendored
Normal file
114
node_modules/@octokit/auth-oauth-user/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
import type * as OctokitTypes from "@octokit/types";
|
||||
import type * as DeviceTypes from "@octokit/auth-oauth-device";
|
||||
import type * as OAuthMethodsTypes from "@octokit/oauth-methods";
|
||||
export type ClientType = "oauth-app" | "github-app";
|
||||
export type WebFlowOptions = {
|
||||
code: string;
|
||||
state?: string;
|
||||
redirectUrl?: string;
|
||||
};
|
||||
type CommonAppStrategyOptions = {
|
||||
clientType?: ClientType;
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
request?: OctokitTypes.RequestInterface;
|
||||
onTokenCreated?: OnTokenCreatedCallback;
|
||||
};
|
||||
type CommonOAuthAppStrategyOptions = {
|
||||
clientType?: "oauth-app";
|
||||
} & CommonAppStrategyOptions;
|
||||
type CommonGitHubAppStrategyOptions = {
|
||||
clientType?: "github-app";
|
||||
} & CommonAppStrategyOptions;
|
||||
type OAuthAppDeviceFlowOptions = {
|
||||
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
||||
scopes?: string[];
|
||||
};
|
||||
type GitHubDeviceFlowOptions = {
|
||||
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
||||
};
|
||||
type ExistingOAuthAppAuthenticationOptions = {
|
||||
clientType: "oauth-app";
|
||||
token: string;
|
||||
scopes: string[];
|
||||
};
|
||||
type ExistingGitHubAppAuthenticationOptions = {
|
||||
token: string;
|
||||
};
|
||||
type ExistingGitHubAppAuthenticationWithExpirationOptions = {
|
||||
token: string;
|
||||
refreshToken: string;
|
||||
expiresAt: string;
|
||||
refreshTokenExpiresAt: string;
|
||||
};
|
||||
export type OAuthAppStrategyOptionsWebFlow = CommonOAuthAppStrategyOptions & WebFlowOptions;
|
||||
export type GitHubAppStrategyOptionsWebFlow = CommonGitHubAppStrategyOptions & WebFlowOptions;
|
||||
export type OAuthAppStrategyOptionsDeviceFlow = CommonOAuthAppStrategyOptions & OAuthAppDeviceFlowOptions;
|
||||
export type GitHubAppStrategyOptionsDeviceFlow = CommonGitHubAppStrategyOptions & GitHubDeviceFlowOptions;
|
||||
export type OAuthAppStrategyOptionsExistingAuthentication = CommonOAuthAppStrategyOptions & ExistingOAuthAppAuthenticationOptions;
|
||||
export type GitHubAppStrategyOptionsExistingAuthentication = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationOptions;
|
||||
export type GitHubAppStrategyOptionsExistingAuthenticationWithExpiration = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationWithExpirationOptions;
|
||||
export type OAuthAppStrategyOptions = OAuthAppStrategyOptionsWebFlow | OAuthAppStrategyOptionsDeviceFlow | OAuthAppStrategyOptionsExistingAuthentication;
|
||||
export type GitHubAppStrategyOptions = GitHubAppStrategyOptionsWebFlow | GitHubAppStrategyOptionsDeviceFlow | GitHubAppStrategyOptionsExistingAuthentication | GitHubAppStrategyOptionsExistingAuthenticationWithExpiration;
|
||||
export type OAuthAppAuthentication = {
|
||||
tokenType: "oauth";
|
||||
type: "token";
|
||||
} & OAuthMethodsTypes.OAuthAppAuthentication;
|
||||
export type GitHubAppAuthentication = {
|
||||
tokenType: "oauth";
|
||||
type: "token";
|
||||
} & OAuthMethodsTypes.GitHubAppAuthentication;
|
||||
export type GitHubAppAuthenticationWithExpiration = {
|
||||
tokenType: "oauth";
|
||||
type: "token";
|
||||
} & OAuthMethodsTypes.GitHubAppAuthenticationWithExpiration;
|
||||
export interface OAuthAppAuthInterface {
|
||||
(options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
||||
}
|
||||
export interface GitHubAppAuthInterface {
|
||||
(options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
||||
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
||||
}
|
||||
type OnTokenCreatedCallback = (authentication: OAuthAppAuthentication | GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration | undefined, options: OAuthAppAuthOptions | GitHubAppAuthOptions) => void | Promise<void>;
|
||||
export type OAuthAppState = {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
clientType: "oauth-app";
|
||||
request: OctokitTypes.RequestInterface;
|
||||
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
|
||||
strategyOptions: WebFlowOptions | OAuthAppDeviceFlowOptions | ExistingOAuthAppAuthenticationOptions;
|
||||
authentication?: OAuthAppAuthentication & {
|
||||
invalid?: true;
|
||||
};
|
||||
};
|
||||
type GitHubAppStateAuthentication = GitHubAppAuthentication & {
|
||||
invalid?: true;
|
||||
};
|
||||
type GitHubAppStateAuthenticationWIthExpiration = GitHubAppAuthenticationWithExpiration & {
|
||||
invalid?: true;
|
||||
};
|
||||
export type GitHubAppState = {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
clientType: "github-app";
|
||||
request: OctokitTypes.RequestInterface;
|
||||
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
|
||||
strategyOptions: WebFlowOptions | GitHubDeviceFlowOptions | ExistingGitHubAppAuthenticationOptions | ExistingGitHubAppAuthenticationWithExpirationOptions;
|
||||
authentication?: GitHubAppStateAuthentication | GitHubAppStateAuthenticationWIthExpiration;
|
||||
};
|
||||
export type State = OAuthAppState | GitHubAppState;
|
||||
export type WebFlowState = {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
clientType: ClientType;
|
||||
request: OctokitTypes.RequestInterface;
|
||||
strategyOptions: WebFlowOptions;
|
||||
};
|
||||
export type OAuthAppAuthOptions = {
|
||||
type?: "get" | "check" | "reset" | "delete" | "deleteAuthorization";
|
||||
};
|
||||
export type GitHubAppAuthOptions = {
|
||||
type?: "get" | "check" | "reset" | "refresh" | "delete" | "deleteAuthorization";
|
||||
};
|
||||
export {};
|
||||
1
node_modules/@octokit/auth-oauth-user/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-oauth-user/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "6.0.2";
|
||||
56
node_modules/@octokit/auth-oauth-user/package.json
generated
vendored
Normal file
56
node_modules/@octokit/auth-oauth-user/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "@octokit/auth-oauth-user",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "6.0.2",
|
||||
"description": "Octokit authentication strategy for OAuth clients",
|
||||
"repository": "https://github.com/octokit/auth-oauth-user.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"author": "Gregor Martynus (https://dev.to/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-device": "^8.0.3",
|
||||
"@octokit/oauth-methods": "^6.0.2",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^11.0.0",
|
||||
"glob": "^11.0.0",
|
||||
"mockdate": "^3.0.4",
|
||||
"prettier": "3.6.2",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-bundle/index.js",
|
||||
"default": "./dist-bundle/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
21
node_modules/@octokit/auth-token/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-token/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
284
node_modules/@octokit/auth-token/README.md
generated
vendored
Normal file
284
node_modules/@octokit/auth-token/README.md
generated
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
# auth-token.js
|
||||
|
||||
> GitHub API token authentication for browsers and Node.js
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/auth-token)
|
||||
[](https://github.com/octokit/auth-token.js/actions?query=workflow%3ATest)
|
||||
|
||||
`@octokit/auth-token` is the simplest of [GitHub’s authentication strategies](https://github.com/octokit/auth.js).
|
||||
|
||||
It is useful if you want to support multiple authentication strategies, as it’s API is compatible with its sibling packages for [basic](https://github.com/octokit/auth-basic.js), [GitHub App](https://github.com/octokit/auth-app.js) and [OAuth app](https://github.com/octokit/auth.js) authentication.
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [`createTokenAuth(token) options`](#createtokenauthtoken-options)
|
||||
- [`auth()`](#auth)
|
||||
- [Authentication object](#authentication-object)
|
||||
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
||||
- [Find more information](#find-more-information)
|
||||
- [Find out what scopes are enabled for oauth tokens](#find-out-what-scopes-are-enabled-for-oauth-tokens)
|
||||
- [Find out if token is a personal access token or if it belongs to an OAuth app](#find-out-if-token-is-a-personal-access-token-or-if-it-belongs-to-an-oauth-app)
|
||||
- [Find out what permissions are enabled for a repository](#find-out-what-permissions-are-enabled-for-a-repository)
|
||||
- [Use token for git operations](#use-token-for-git-operations)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/auth-token` directly from [esm.sh](https://esm.sh)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { createTokenAuth } from "https://esm.sh/@octokit/auth-token";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/auth-token</code>
|
||||
|
||||
```js
|
||||
import { createTokenAuth } from "@octokit/auth-token";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const auth = createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
||||
const authentication = await auth();
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghp_PersonalAccessToken01245678900000000',
|
||||
// tokenType: 'oauth'
|
||||
// }
|
||||
```
|
||||
|
||||
## `createTokenAuth(token) options`
|
||||
|
||||
The `createTokenAuth` method accepts a single argument of type string, which is the token. The passed token can be one of the following:
|
||||
|
||||
- [Personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
|
||||
- [OAuth access token](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
|
||||
- [GITHUB_TOKEN provided to GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables)
|
||||
- Installation access token ([server-to-server](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
|
||||
- User authentication for installation ([user-to-server](https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps))
|
||||
|
||||
Examples
|
||||
|
||||
```js
|
||||
// Personal access token or OAuth access token
|
||||
createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghp_PersonalAccessToken01245678900000000',
|
||||
// tokenType: 'oauth'
|
||||
// }
|
||||
|
||||
// Installation access token or GitHub Action token
|
||||
createTokenAuth("ghs_InstallallationOrActionToken00000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghs_InstallallationOrActionToken00000000',
|
||||
// tokenType: 'installation'
|
||||
// }
|
||||
|
||||
// Installation access token or GitHub Action token
|
||||
createTokenAuth("ghu_InstallationUserToServer000000000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghu_InstallationUserToServer000000000000',
|
||||
// tokenType: 'user-to-server'
|
||||
// }
|
||||
```
|
||||
|
||||
## `auth()`
|
||||
|
||||
The `auth()` method has no options. It returns a promise which resolves with the the authentication object.
|
||||
|
||||
## Authentication object
|
||||
|
||||
<table width="100%">
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th width=150>
|
||||
name
|
||||
</th>
|
||||
<th width=70>
|
||||
type
|
||||
</th>
|
||||
<th>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>type</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"token"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>token</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The provided token.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>tokenType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions), <code>"app"</code> for a GitHub App JSON Web Token, or <code>"user-to-server"</code> for a user authentication token through an app installation.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
||||
|
||||
`auth.hook()` hooks directly into the request life cycle. It authenticates the request using the provided token.
|
||||
|
||||
The `request` option is an instance of [`@octokit/request`](https://github.com/octokit/request.js#readme). The `route`/`options` parameters are the same as for the [`request()` method](https://github.com/octokit/request.js#request).
|
||||
|
||||
`auth.hook()` can be called directly to send an authenticated request
|
||||
|
||||
```js
|
||||
const { data: authorizations } = await auth.hook(
|
||||
request,
|
||||
"GET /authorizations",
|
||||
);
|
||||
```
|
||||
|
||||
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
});
|
||||
|
||||
const { data: authorizations } = await requestWithAuth("GET /authorizations");
|
||||
```
|
||||
|
||||
## Find more information
|
||||
|
||||
`auth()` does not send any requests, it only transforms the provided token string into an authentication object.
|
||||
|
||||
Here is a list of things you can do to retrieve further information
|
||||
|
||||
### Find out what scopes are enabled for oauth tokens
|
||||
|
||||
Note that this does not work for installations. There is no way to retrieve permissions based on an installation access tokens.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("HEAD /");
|
||||
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
|
||||
|
||||
if (scopes.length) {
|
||||
console.log(
|
||||
`"${TOKEN}" has ${scopes.length} scopes enabled: ${scopes.join(", ")}`,
|
||||
);
|
||||
} else {
|
||||
console.log(`"${TOKEN}" has no scopes enabled`);
|
||||
}
|
||||
```
|
||||
|
||||
### Find out if token is a personal access token or if it belongs to an OAuth app
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("HEAD /");
|
||||
const clientId = response.headers["x-oauth-client-id"];
|
||||
|
||||
if (clientId) {
|
||||
console.log(
|
||||
`"${token}" is an OAuth token, its app’s client_id is ${clientId}.`,
|
||||
);
|
||||
} else {
|
||||
console.log(`"${token}" is a personal access token`);
|
||||
}
|
||||
```
|
||||
|
||||
### Find out what permissions are enabled for a repository
|
||||
|
||||
Note that the `permissions` key is not set when authenticated using an installation access token.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("GET /repos/{owner}/{repo}", {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
});
|
||||
|
||||
console.log(response.data.permissions);
|
||||
// {
|
||||
// admin: true,
|
||||
// push: true,
|
||||
// pull: true
|
||||
// }
|
||||
```
|
||||
|
||||
### Use token for git operations
|
||||
|
||||
Both OAuth and installation access tokens can be used for git operations. However, when using with an installation, [the token must be prefixed with `x-access-token`](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation).
|
||||
|
||||
This example is using the [`execa`](https://github.com/sindresorhus/execa) package to run a `git push` command.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const { token, tokenType } = await auth();
|
||||
const tokenWithPrefix =
|
||||
tokenType === "installation" ? `x-access-token:${token}` : token;
|
||||
|
||||
const repositoryUrl = `https://${tokenWithPrefix}@github.com/octocat/hello-world.git`;
|
||||
|
||||
const { stdout } = await execa("git", ["push", repositoryUrl]);
|
||||
console.log(stdout);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
55
node_modules/@octokit/auth-token/dist-bundle/index.js
generated
vendored
Normal file
55
node_modules/@octokit/auth-token/dist-bundle/index.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// pkg/dist-src/is-jwt.js
|
||||
var b64url = "(?:[a-zA-Z0-9_-]+)";
|
||||
var sep = "\\.";
|
||||
var jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
||||
var isJWT = jwtRE.test.bind(jwtRE);
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(token) {
|
||||
const isApp = isJWT(token);
|
||||
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
||||
const isUserToServer = token.startsWith("ghu_");
|
||||
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token,
|
||||
tokenType
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/with-authorization-prefix.js
|
||||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
return `token ${token}`;
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var createTokenAuth = function createTokenAuth2(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
if (typeof token !== "string") {
|
||||
throw new Error(
|
||||
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
||||
);
|
||||
}
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token)
|
||||
});
|
||||
};
|
||||
export {
|
||||
createTokenAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-token/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-token/dist-bundle/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/is-jwt.js", "../dist-src/auth.js", "../dist-src/with-authorization-prefix.js", "../dist-src/hook.js", "../dist-src/index.js"],
|
||||
"sourcesContent": ["const b64url = \"(?:[a-zA-Z0-9_-]+)\";\nconst sep = \"\\\\.\";\nconst jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);\nconst isJWT = jwtRE.test.bind(jwtRE);\nexport {\n isJWT\n};\n", "import { isJWT } from \"./is-jwt.js\";\nasync function auth(token) {\n const isApp = isJWT(token);\n const isInstallation = token.startsWith(\"v1.\") || token.startsWith(\"ghs_\");\n const isUserToServer = token.startsWith(\"ghu_\");\n const tokenType = isApp ? \"app\" : isInstallation ? \"installation\" : isUserToServer ? \"user-to-server\" : \"oauth\";\n return {\n type: \"token\",\n token,\n tokenType\n };\n}\nexport {\n auth\n};\n", "function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\nexport {\n withAuthorizationPrefix\n};\n", "import { withAuthorizationPrefix } from \"./with-authorization-prefix.js\";\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\nexport {\n hook\n};\n", "import { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nconst createTokenAuth = function createTokenAuth2(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\n \"[@octokit/auth-token] Token passed to createTokenAuth is not a string\"\n );\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\nexport {\n createTokenAuth\n};\n"],
|
||||
"mappings": ";AAAA,IAAM,SAAS;AACf,IAAM,MAAM;AACZ,IAAM,QAAQ,IAAI,OAAO,IAAI,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG;AACpE,IAAM,QAAQ,MAAM,KAAK,KAAK,KAAK;;;ACFnC,eAAe,KAAK,OAAO;AACzB,QAAM,QAAQ,MAAM,KAAK;AACzB,QAAM,iBAAiB,MAAM,WAAW,KAAK,KAAK,MAAM,WAAW,MAAM;AACzE,QAAM,iBAAiB,MAAM,WAAW,MAAM;AAC9C,QAAM,YAAY,QAAQ,QAAQ,iBAAiB,iBAAiB,iBAAiB,mBAAmB;AACxG,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;;;ACXA,SAAS,wBAAwB,OAAO;AACtC,MAAI,MAAM,MAAM,IAAI,EAAE,WAAW,GAAG;AAClC,WAAO,UAAU,KAAK;AAAA,EACxB;AACA,SAAO,SAAS,KAAK;AACvB;;;ACJA,eAAe,KAAK,OAAO,SAAS,OAAO,YAAY;AACrD,QAAM,WAAW,QAAQ,SAAS;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,WAAS,QAAQ,gBAAgB,wBAAwB,KAAK;AAC9D,SAAO,QAAQ,QAAQ;AACzB;;;ACNA,IAAM,kBAAkB,SAAS,iBAAiB,OAAO;AACvD,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,UAAQ,MAAM,QAAQ,sBAAsB,EAAE;AAC9C,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;AAAA,IAC3C,MAAM,KAAK,KAAK,MAAM,KAAK;AAAA,EAC7B,CAAC;AACH;",
|
||||
"names": []
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user