First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

21
node_modules/@octokit/app/LICENSE generated vendored Normal file
View 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
View File

@@ -0,0 +1,440 @@
# app.js
> GitHub App toolset for Node.js
[![@latest](https://img.shields.io/npm/v/@octokit/app.svg)](https://www.npmjs.com/package/@octokit/app)
[![Build Status](https://github.com/octokit/app.js/workflows/Test/badge.svg)](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 apps 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 apps 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 apps 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 apps 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
View 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

File diff suppressed because one or more lines are too long

View 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
View 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
};

View 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
};

View 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
View 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
};

View 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
View 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
View 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
};

View 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>;
};

View 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>;
};

View 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>;

View 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
View 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";

View 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
View 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
View 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
View 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
View 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

File diff suppressed because one or more lines are too long

62
node_modules/@octokit/app/package.json generated vendored Normal file
View 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
}