Upgrade octokit to v4.1.2
This commit is contained in:
parent
dbbcbe019d
commit
c1745a9831
1214 changed files with 160765 additions and 0 deletions
7
node_modules/@octokit/oauth-app/LICENSE
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
MIT License Copyright (c) 2020 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 (including the next paragraph) 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.
|
||||
1176
node_modules/@octokit/oauth-app/README.md
generated
vendored
Normal file
1176
node_modules/@octokit/oauth-app/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
787
node_modules/@octokit/oauth-app/dist-node/index.js
generated
vendored
Normal file
787
node_modules/@octokit/oauth-app/dist-node/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,787 @@
|
|||
// pkg/dist-src/index.js
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "7.1.6";
|
||||
|
||||
// pkg/dist-src/add-event-handler.js
|
||||
function addEventHandler(state, eventName, eventHandler) {
|
||||
if (Array.isArray(eventName)) {
|
||||
for (const singleEventName of eventName) {
|
||||
addEventHandler(state, singleEventName, eventHandler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!state.eventHandlers[eventName]) {
|
||||
state.eventHandlers[eventName] = [];
|
||||
}
|
||||
state.eventHandlers[eventName].push(eventHandler);
|
||||
}
|
||||
|
||||
// pkg/dist-src/oauth-app-octokit.js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
var OAuthAppOctokit = Octokit.defaults({
|
||||
userAgent: `octokit-oauth-app.js/${VERSION} ${getUserAgent()}`
|
||||
});
|
||||
|
||||
// pkg/dist-src/methods/get-user-octokit.js
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
|
||||
// pkg/dist-src/emit-event.js
|
||||
async function emitEvent(state, context) {
|
||||
const { name, action } = context;
|
||||
if (state.eventHandlers[`${name}.${action}`]) {
|
||||
for (const eventHandler of state.eventHandlers[`${name}.${action}`]) {
|
||||
await eventHandler(context);
|
||||
}
|
||||
}
|
||||
if (state.eventHandlers[name]) {
|
||||
for (const eventHandler of state.eventHandlers[name]) {
|
||||
await eventHandler(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/get-user-octokit.js
|
||||
async function getUserOctokitWithState(state, options) {
|
||||
return state.octokit.auth({
|
||||
type: "oauth-user",
|
||||
...options,
|
||||
async factory(options2) {
|
||||
const octokit = new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: options2
|
||||
});
|
||||
const authentication = await octokit.auth({
|
||||
type: "get"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "created",
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
authentication,
|
||||
octokit
|
||||
});
|
||||
return octokit;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/get-web-flow-authorization-url.js
|
||||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
function getWebFlowAuthorizationUrlWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
request: state.octokit.request,
|
||||
...options,
|
||||
allowSignup: state.allowSignup ?? options.allowSignup,
|
||||
redirectUrl: options.redirectUrl ?? state.redirectUrl,
|
||||
scopes: options.scopes ?? state.defaultScopes
|
||||
};
|
||||
return OAuthMethods.getWebFlowAuthorizationUrl({
|
||||
clientType: state.clientType,
|
||||
...optionsWithDefaults
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/create-token.js
|
||||
import * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
async function createTokenWithState(state, options) {
|
||||
const authentication = await state.octokit.auth({
|
||||
type: "oauth-user",
|
||||
...options
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "created",
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: OAuthAppAuth.createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
refreshToken: authentication.refreshToken,
|
||||
expiresAt: authentication.expiresAt,
|
||||
refreshTokenExpiresAt: authentication.refreshTokenExpiresAt
|
||||
}
|
||||
})
|
||||
});
|
||||
return { authentication };
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/check-token.js
|
||||
import * as OAuthMethods2 from "@octokit/oauth-methods";
|
||||
async function checkTokenWithState(state, options) {
|
||||
const result = await OAuthMethods2.checkToken({
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
});
|
||||
Object.assign(result.authentication, { type: "token", tokenType: "oauth" });
|
||||
return result;
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/reset-token.js
|
||||
import * as OAuthMethods3 from "@octokit/oauth-methods";
|
||||
import { createOAuthUserAuth as createOAuthUserAuth3 } from "@octokit/auth-oauth-user";
|
||||
async function resetTokenWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
if (state.clientType === "oauth-app") {
|
||||
const response2 = await OAuthMethods3.resetToken({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
});
|
||||
const authentication2 = Object.assign(response2.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "reset",
|
||||
token: response2.authentication.token,
|
||||
scopes: response2.authentication.scopes || void 0,
|
||||
authentication: authentication2,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth3,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response2.authentication.token,
|
||||
scopes: response2.authentication.scopes
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response2, authentication: authentication2 };
|
||||
}
|
||||
const response = await OAuthMethods3.resetToken({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "reset",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth3,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/refresh-token.js
|
||||
import * as OAuthMethods4 from "@octokit/oauth-methods";
|
||||
import { createOAuthUserAuth as createOAuthUserAuth4 } from "@octokit/auth-oauth-user";
|
||||
async function refreshTokenWithState(state, options) {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps"
|
||||
);
|
||||
}
|
||||
const response = await OAuthMethods4.refreshToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
refreshToken: options.refreshToken
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "refreshed",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth4,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/scope-token.js
|
||||
import * as OAuthMethods5 from "@octokit/oauth-methods";
|
||||
import { createOAuthUserAuth as createOAuthUserAuth5 } from "@octokit/auth-oauth-user";
|
||||
async function scopeTokenWithState(state, options) {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps"
|
||||
);
|
||||
}
|
||||
const response = await OAuthMethods5.scopeToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "scoped",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth5,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/delete-token.js
|
||||
import * as OAuthMethods6 from "@octokit/oauth-methods";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
async function deleteTokenWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
const response = state.clientType === "oauth-app" ? await OAuthMethods6.deleteToken({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
}) : (
|
||||
/* v8 ignore next 4 */
|
||||
await OAuthMethods6.deleteToken({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
})
|
||||
);
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `Handling "token.deleted" event. The access for the token has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
// pkg/dist-src/methods/delete-authorization.js
|
||||
import * as OAuthMethods7 from "@octokit/oauth-methods";
|
||||
import { createUnauthenticatedAuth as createUnauthenticatedAuth2 } from "@octokit/auth-unauthenticated";
|
||||
async function deleteAuthorizationWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
const response = state.clientType === "oauth-app" ? await OAuthMethods7.deleteAuthorization({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
}) : (
|
||||
/* v8 ignore next 4 */
|
||||
await OAuthMethods7.deleteAuthorization({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
})
|
||||
);
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth2,
|
||||
auth: {
|
||||
reason: `Handling "token.deleted" event. The access for the token has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "authorization",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth2,
|
||||
auth: {
|
||||
reason: `Handling "authorization.deleted" event. The access for the app has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/unknown-route-response.js
|
||||
function unknownRouteResponse(request) {
|
||||
return {
|
||||
status: 404,
|
||||
headers: { "content-type": "application/json" },
|
||||
text: JSON.stringify({
|
||||
error: `Unknown route: ${request.method} ${request.url}`
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/handle-request.js
|
||||
async function handleRequest(app, { pathPrefix = "/api/github/oauth" }, request) {
|
||||
let { pathname } = new URL(request.url, "http://localhost");
|
||||
if (!pathname.startsWith(`${pathPrefix}/`)) {
|
||||
return void 0;
|
||||
}
|
||||
if (request.method === "OPTIONS") {
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-allow-methods": "*",
|
||||
"access-control-allow-headers": "Content-Type, User-Agent, Authorization"
|
||||
}
|
||||
};
|
||||
}
|
||||
pathname = pathname.slice(pathPrefix.length + 1);
|
||||
const route = [request.method, pathname].join(" ");
|
||||
const routes = {
|
||||
getLogin: `GET login`,
|
||||
getCallback: `GET callback`,
|
||||
createToken: `POST token`,
|
||||
getToken: `GET token`,
|
||||
patchToken: `PATCH token`,
|
||||
patchRefreshToken: `PATCH refresh-token`,
|
||||
scopeToken: `POST token/scoped`,
|
||||
deleteToken: `DELETE token`,
|
||||
deleteGrant: `DELETE grant`
|
||||
};
|
||||
if (!Object.values(routes).includes(route)) {
|
||||
return unknownRouteResponse(request);
|
||||
}
|
||||
let json;
|
||||
try {
|
||||
const text = await request.text();
|
||||
json = text ? JSON.parse(text) : {};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 400,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify({
|
||||
error: "[@octokit/oauth-app] request error"
|
||||
})
|
||||
};
|
||||
}
|
||||
const { searchParams } = new URL(request.url, "http://localhost");
|
||||
const query = Object.fromEntries(searchParams);
|
||||
const headers = request.headers;
|
||||
try {
|
||||
if (route === routes.getLogin) {
|
||||
const authOptions = {};
|
||||
if (query.state) {
|
||||
Object.assign(authOptions, { state: query.state });
|
||||
}
|
||||
if (query.scopes) {
|
||||
Object.assign(authOptions, { scopes: query.scopes.split(",") });
|
||||
}
|
||||
if (query.allowSignup) {
|
||||
Object.assign(authOptions, {
|
||||
allowSignup: query.allowSignup === "true"
|
||||
});
|
||||
}
|
||||
if (query.redirectUrl) {
|
||||
Object.assign(authOptions, { redirectUrl: query.redirectUrl });
|
||||
}
|
||||
const { url } = app.getWebFlowAuthorizationUrl(authOptions);
|
||||
return { status: 302, headers: { location: url } };
|
||||
}
|
||||
if (route === routes.getCallback) {
|
||||
if (query.error) {
|
||||
throw new Error(
|
||||
`[@octokit/oauth-app] ${query.error} ${query.error_description}`
|
||||
);
|
||||
}
|
||||
if (!query.code) {
|
||||
throw new Error('[@octokit/oauth-app] "code" parameter is required');
|
||||
}
|
||||
const {
|
||||
authentication: { token: token2 }
|
||||
} = await app.createToken({
|
||||
code: query.code
|
||||
});
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "text/html"
|
||||
},
|
||||
text: `<h1>Token created successfully</h1>
|
||||
|
||||
<p>Your token is: <strong>${token2}</strong>. Copy it now as it cannot be shown again.</p>`
|
||||
};
|
||||
}
|
||||
if (route === routes.createToken) {
|
||||
const { code, redirectUrl } = json;
|
||||
if (!code) {
|
||||
throw new Error('[@octokit/oauth-app] "code" parameter is required');
|
||||
}
|
||||
const result = await app.createToken({
|
||||
code,
|
||||
redirectUrl
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 201,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.getToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.checkToken({
|
||||
token: token2
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.patchToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.resetToken({ token: token2 });
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.patchRefreshToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const { refreshToken: refreshToken2 } = json;
|
||||
if (!refreshToken2) {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] refreshToken must be sent in request body"
|
||||
);
|
||||
}
|
||||
const result = await app.refreshToken({ refreshToken: refreshToken2 });
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.scopeToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.scopeToken({
|
||||
token: token2,
|
||||
...json
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.deleteToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
await app.deleteToken({
|
||||
token: token2
|
||||
});
|
||||
return {
|
||||
status: 204,
|
||||
headers: { "access-control-allow-origin": "*" }
|
||||
};
|
||||
}
|
||||
const token = headers.authorization?.substr("token ".length);
|
||||
if (!token) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
await app.deleteAuthorization({
|
||||
token
|
||||
});
|
||||
return {
|
||||
status: 204,
|
||||
headers: { "access-control-allow-origin": "*" }
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 400,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify({ error: error.message })
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/node/parse-request.js
|
||||
function parseRequest(request) {
|
||||
const { method, url, headers } = request;
|
||||
async function text() {
|
||||
const text2 = await new Promise((resolve, reject) => {
|
||||
let bodyChunks = [];
|
||||
request.on("error", reject).on("data", (chunk) => bodyChunks.push(chunk)).on("end", () => resolve(Buffer.concat(bodyChunks).toString()));
|
||||
});
|
||||
return text2;
|
||||
}
|
||||
return { method, url, headers, text };
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/node/send-response.js
|
||||
function sendResponse(octokitResponse, response) {
|
||||
response.writeHead(octokitResponse.status, octokitResponse.headers);
|
||||
response.end(octokitResponse.text);
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/node/index.js
|
||||
function createNodeMiddleware(app, options = {}) {
|
||||
return async function(request, response, next) {
|
||||
const octokitRequest = await parseRequest(request);
|
||||
const octokitResponse = await handleRequest(app, options, octokitRequest);
|
||||
if (octokitResponse) {
|
||||
sendResponse(octokitResponse, response);
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/web-worker/parse-request.js
|
||||
function parseRequest2(request) {
|
||||
const headers = Object.fromEntries(request.headers.entries());
|
||||
return {
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
headers,
|
||||
text: () => request.text()
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/web-worker/send-response.js
|
||||
function sendResponse2(octokitResponse) {
|
||||
const responseOptions = {
|
||||
status: octokitResponse.status
|
||||
};
|
||||
if (octokitResponse.headers) {
|
||||
Object.assign(responseOptions, { headers: octokitResponse.headers });
|
||||
}
|
||||
return new Response(octokitResponse.text, responseOptions);
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/web-worker/index.js
|
||||
function createWebWorkerHandler(app, options = {}) {
|
||||
return async function(request) {
|
||||
const octokitRequest = await parseRequest2(request);
|
||||
const octokitResponse = await handleRequest(app, options, octokitRequest);
|
||||
return octokitResponse ? sendResponse2(octokitResponse) : void 0;
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/aws-lambda/api-gateway-v2-parse-request.js
|
||||
function parseRequest3(request) {
|
||||
const { method } = request.requestContext.http;
|
||||
let url = request.rawPath;
|
||||
const { stage } = request.requestContext;
|
||||
if (url.startsWith("/" + stage)) url = url.substring(stage.length + 1);
|
||||
if (request.rawQueryString) url += "?" + request.rawQueryString;
|
||||
const headers = request.headers;
|
||||
const text = async () => request.body || "";
|
||||
return { method, url, headers, text };
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/aws-lambda/api-gateway-v2-send-response.js
|
||||
function sendResponse3(octokitResponse) {
|
||||
return {
|
||||
statusCode: octokitResponse.status,
|
||||
headers: octokitResponse.headers,
|
||||
body: octokitResponse.text
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/middleware/aws-lambda/api-gateway-v2.js
|
||||
function createAWSLambdaAPIGatewayV2Handler(app, options = {}) {
|
||||
return async function(event) {
|
||||
const request = parseRequest3(event);
|
||||
const response = await handleRequest(app, options, request);
|
||||
return response ? sendResponse3(response) : void 0;
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var OAuthApp = class {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const OAuthAppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return OAuthAppWithDefaults;
|
||||
}
|
||||
constructor(options) {
|
||||
const Octokit2 = options.Octokit || OAuthAppOctokit;
|
||||
this.type = options.clientType || "oauth-app";
|
||||
const octokit = new Octokit2({
|
||||
authStrategy: createOAuthAppAuth,
|
||||
auth: {
|
||||
clientType: this.type,
|
||||
clientId: options.clientId,
|
||||
clientSecret: options.clientSecret
|
||||
}
|
||||
});
|
||||
const state = {
|
||||
clientType: this.type,
|
||||
clientId: options.clientId,
|
||||
clientSecret: options.clientSecret,
|
||||
// @ts-expect-error defaultScopes not permitted for GitHub Apps
|
||||
defaultScopes: options.defaultScopes || [],
|
||||
allowSignup: options.allowSignup,
|
||||
baseUrl: options.baseUrl,
|
||||
redirectUrl: options.redirectUrl,
|
||||
log: options.log,
|
||||
Octokit: Octokit2,
|
||||
octokit,
|
||||
eventHandlers: {}
|
||||
};
|
||||
this.on = addEventHandler.bind(null, state);
|
||||
this.octokit = octokit;
|
||||
this.getUserOctokit = getUserOctokitWithState.bind(null, state);
|
||||
this.getWebFlowAuthorizationUrl = getWebFlowAuthorizationUrlWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.createToken = createTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.checkToken = checkTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.resetToken = resetTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.refreshToken = refreshTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.scopeToken = scopeTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.deleteToken = deleteTokenWithState.bind(null, state);
|
||||
this.deleteAuthorization = deleteAuthorizationWithState.bind(null, state);
|
||||
}
|
||||
// assigned during constructor
|
||||
type;
|
||||
on;
|
||||
octokit;
|
||||
getUserOctokit;
|
||||
getWebFlowAuthorizationUrl;
|
||||
createToken;
|
||||
checkToken;
|
||||
resetToken;
|
||||
refreshToken;
|
||||
scopeToken;
|
||||
deleteToken;
|
||||
deleteAuthorization;
|
||||
};
|
||||
export {
|
||||
OAuthApp,
|
||||
createAWSLambdaAPIGatewayV2Handler,
|
||||
createNodeMiddleware,
|
||||
createWebWorkerHandler,
|
||||
handleRequest,
|
||||
sendResponse as sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
};
|
||||
7
node_modules/@octokit/oauth-app/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/@octokit/oauth-app/dist-src/add-event-handler.js
generated
vendored
Normal file
15
node_modules/@octokit/oauth-app/dist-src/add-event-handler.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function addEventHandler(state, eventName, eventHandler) {
|
||||
if (Array.isArray(eventName)) {
|
||||
for (const singleEventName of eventName) {
|
||||
addEventHandler(state, singleEventName, eventHandler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!state.eventHandlers[eventName]) {
|
||||
state.eventHandlers[eventName] = [];
|
||||
}
|
||||
state.eventHandlers[eventName].push(eventHandler);
|
||||
}
|
||||
export {
|
||||
addEventHandler
|
||||
};
|
||||
16
node_modules/@octokit/oauth-app/dist-src/emit-event.js
generated
vendored
Normal file
16
node_modules/@octokit/oauth-app/dist-src/emit-event.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
async function emitEvent(state, context) {
|
||||
const { name, action } = context;
|
||||
if (state.eventHandlers[`${name}.${action}`]) {
|
||||
for (const eventHandler of state.eventHandlers[`${name}.${action}`]) {
|
||||
await eventHandler(context);
|
||||
}
|
||||
}
|
||||
if (state.eventHandlers[name]) {
|
||||
for (const eventHandler of state.eventHandlers[name]) {
|
||||
await eventHandler(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
emitEvent
|
||||
};
|
||||
128
node_modules/@octokit/oauth-app/dist-src/index.js
generated
vendored
Normal file
128
node_modules/@octokit/oauth-app/dist-src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
import { VERSION } from "./version.js";
|
||||
import { addEventHandler } from "./add-event-handler.js";
|
||||
import { OAuthAppOctokit } from "./oauth-app-octokit.js";
|
||||
import {
|
||||
getUserOctokitWithState
|
||||
} from "./methods/get-user-octokit.js";
|
||||
import {
|
||||
getWebFlowAuthorizationUrlWithState
|
||||
} from "./methods/get-web-flow-authorization-url.js";
|
||||
import {
|
||||
createTokenWithState
|
||||
} from "./methods/create-token.js";
|
||||
import {
|
||||
checkTokenWithState
|
||||
} from "./methods/check-token.js";
|
||||
import {
|
||||
resetTokenWithState
|
||||
} from "./methods/reset-token.js";
|
||||
import {
|
||||
refreshTokenWithState
|
||||
} from "./methods/refresh-token.js";
|
||||
import {
|
||||
scopeTokenWithState
|
||||
} from "./methods/scope-token.js";
|
||||
import {
|
||||
deleteTokenWithState
|
||||
} from "./methods/delete-token.js";
|
||||
import {
|
||||
deleteAuthorizationWithState
|
||||
} from "./methods/delete-authorization.js";
|
||||
import { handleRequest } from "./middleware/handle-request.js";
|
||||
import { unknownRouteResponse } from "./middleware/unknown-route-response.js";
|
||||
import { createNodeMiddleware } from "./middleware/node/index.js";
|
||||
import { sendResponse } from "./middleware/node/send-response.js";
|
||||
import { createWebWorkerHandler } from "./middleware/web-worker/index.js";
|
||||
import { createAWSLambdaAPIGatewayV2Handler } from "./middleware/aws-lambda/api-gateway-v2.js";
|
||||
class OAuthApp {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const OAuthAppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return OAuthAppWithDefaults;
|
||||
}
|
||||
constructor(options) {
|
||||
const Octokit = options.Octokit || OAuthAppOctokit;
|
||||
this.type = options.clientType || "oauth-app";
|
||||
const octokit = new Octokit({
|
||||
authStrategy: createOAuthAppAuth,
|
||||
auth: {
|
||||
clientType: this.type,
|
||||
clientId: options.clientId,
|
||||
clientSecret: options.clientSecret
|
||||
}
|
||||
});
|
||||
const state = {
|
||||
clientType: this.type,
|
||||
clientId: options.clientId,
|
||||
clientSecret: options.clientSecret,
|
||||
// @ts-expect-error defaultScopes not permitted for GitHub Apps
|
||||
defaultScopes: options.defaultScopes || [],
|
||||
allowSignup: options.allowSignup,
|
||||
baseUrl: options.baseUrl,
|
||||
redirectUrl: options.redirectUrl,
|
||||
log: options.log,
|
||||
Octokit,
|
||||
octokit,
|
||||
eventHandlers: {}
|
||||
};
|
||||
this.on = addEventHandler.bind(null, state);
|
||||
this.octokit = octokit;
|
||||
this.getUserOctokit = getUserOctokitWithState.bind(null, state);
|
||||
this.getWebFlowAuthorizationUrl = getWebFlowAuthorizationUrlWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.createToken = createTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.checkToken = checkTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.resetToken = resetTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.refreshToken = refreshTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.scopeToken = scopeTokenWithState.bind(
|
||||
null,
|
||||
state
|
||||
);
|
||||
this.deleteToken = deleteTokenWithState.bind(null, state);
|
||||
this.deleteAuthorization = deleteAuthorizationWithState.bind(null, state);
|
||||
}
|
||||
// assigned during constructor
|
||||
type;
|
||||
on;
|
||||
octokit;
|
||||
getUserOctokit;
|
||||
getWebFlowAuthorizationUrl;
|
||||
createToken;
|
||||
checkToken;
|
||||
resetToken;
|
||||
refreshToken;
|
||||
scopeToken;
|
||||
deleteToken;
|
||||
deleteAuthorization;
|
||||
}
|
||||
export {
|
||||
OAuthApp,
|
||||
createAWSLambdaAPIGatewayV2Handler,
|
||||
createNodeMiddleware,
|
||||
createWebWorkerHandler,
|
||||
handleRequest,
|
||||
sendResponse as sendNodeResponse,
|
||||
unknownRouteResponse
|
||||
};
|
||||
16
node_modules/@octokit/oauth-app/dist-src/methods/check-token.js
generated
vendored
Normal file
16
node_modules/@octokit/oauth-app/dist-src/methods/check-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
async function checkTokenWithState(state, options) {
|
||||
const result = await OAuthMethods.checkToken({
|
||||
// @ts-expect-error not worth the extra code to appease TS
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
});
|
||||
Object.assign(result.authentication, { type: "token", tokenType: "oauth" });
|
||||
return result;
|
||||
}
|
||||
export {
|
||||
checkTokenWithState
|
||||
};
|
||||
32
node_modules/@octokit/oauth-app/dist-src/methods/create-token.js
generated
vendored
Normal file
32
node_modules/@octokit/oauth-app/dist-src/methods/create-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
async function createTokenWithState(state, options) {
|
||||
const authentication = await state.octokit.auth({
|
||||
type: "oauth-user",
|
||||
...options
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "created",
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: OAuthAppAuth.createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
refreshToken: authentication.refreshToken,
|
||||
expiresAt: authentication.expiresAt,
|
||||
refreshTokenExpiresAt: authentication.refreshTokenExpiresAt
|
||||
}
|
||||
})
|
||||
});
|
||||
return { authentication };
|
||||
}
|
||||
export {
|
||||
createTokenWithState
|
||||
};
|
||||
47
node_modules/@octokit/oauth-app/dist-src/methods/delete-authorization.js
generated
vendored
Normal file
47
node_modules/@octokit/oauth-app/dist-src/methods/delete-authorization.js
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
async function deleteAuthorizationWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
const response = state.clientType === "oauth-app" ? await OAuthMethods.deleteAuthorization({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
}) : (
|
||||
/* v8 ignore next 4 */
|
||||
await OAuthMethods.deleteAuthorization({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
})
|
||||
);
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `Handling "token.deleted" event. The access for the token has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "authorization",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `Handling "authorization.deleted" event. The access for the app has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
return response;
|
||||
}
|
||||
export {
|
||||
deleteAuthorizationWithState
|
||||
};
|
||||
36
node_modules/@octokit/oauth-app/dist-src/methods/delete-token.js
generated
vendored
Normal file
36
node_modules/@octokit/oauth-app/dist-src/methods/delete-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
async function deleteTokenWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
const response = state.clientType === "oauth-app" ? await OAuthMethods.deleteToken({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
}) : (
|
||||
/* v8 ignore next 4 */
|
||||
await OAuthMethods.deleteToken({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
})
|
||||
);
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "deleted",
|
||||
token: options.token,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `Handling "token.deleted" event. The access for the token has been revoked.`
|
||||
}
|
||||
})
|
||||
});
|
||||
return response;
|
||||
}
|
||||
export {
|
||||
deleteTokenWithState
|
||||
};
|
||||
10
node_modules/@octokit/oauth-app/dist-src/methods/get-oauth-client-code.js
generated
vendored
Normal file
10
node_modules/@octokit/oauth-app/dist-src/methods/get-oauth-client-code.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function getOAuthClientCode() {
|
||||
return `import { Octokit: Core } from "https://esm.sh/@octokit/core";
|
||||
|
||||
export const Octokit = Core.defaults({
|
||||
oauth: {}
|
||||
})`;
|
||||
}
|
||||
export {
|
||||
getOAuthClientCode
|
||||
};
|
||||
29
node_modules/@octokit/oauth-app/dist-src/methods/get-user-octokit.js
generated
vendored
Normal file
29
node_modules/@octokit/oauth-app/dist-src/methods/get-user-octokit.js
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
async function getUserOctokitWithState(state, options) {
|
||||
return state.octokit.auth({
|
||||
type: "oauth-user",
|
||||
...options,
|
||||
async factory(options2) {
|
||||
const octokit = new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: options2
|
||||
});
|
||||
const authentication = await octokit.auth({
|
||||
type: "get"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "created",
|
||||
token: authentication.token,
|
||||
scopes: authentication.scopes,
|
||||
authentication,
|
||||
octokit
|
||||
});
|
||||
return octokit;
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
getUserOctokitWithState
|
||||
};
|
||||
18
node_modules/@octokit/oauth-app/dist-src/methods/get-web-flow-authorization-url.js
generated
vendored
Normal file
18
node_modules/@octokit/oauth-app/dist-src/methods/get-web-flow-authorization-url.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
function getWebFlowAuthorizationUrlWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
request: state.octokit.request,
|
||||
...options,
|
||||
allowSignup: state.allowSignup ?? options.allowSignup,
|
||||
redirectUrl: options.redirectUrl ?? state.redirectUrl,
|
||||
scopes: options.scopes ?? state.defaultScopes
|
||||
};
|
||||
return OAuthMethods.getWebFlowAuthorizationUrl({
|
||||
clientType: state.clientType,
|
||||
...optionsWithDefaults
|
||||
});
|
||||
}
|
||||
export {
|
||||
getWebFlowAuthorizationUrlWithState
|
||||
};
|
||||
40
node_modules/@octokit/oauth-app/dist-src/methods/refresh-token.js
generated
vendored
Normal file
40
node_modules/@octokit/oauth-app/dist-src/methods/refresh-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
async function refreshTokenWithState(state, options) {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps"
|
||||
);
|
||||
}
|
||||
const response = await OAuthMethods.refreshToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
refreshToken: options.refreshToken
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "refreshed",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
export {
|
||||
refreshTokenWithState
|
||||
};
|
||||
66
node_modules/@octokit/oauth-app/dist-src/methods/reset-token.js
generated
vendored
Normal file
66
node_modules/@octokit/oauth-app/dist-src/methods/reset-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
async function resetTokenWithState(state, options) {
|
||||
const optionsWithDefaults = {
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
};
|
||||
if (state.clientType === "oauth-app") {
|
||||
const response2 = await OAuthMethods.resetToken({
|
||||
clientType: "oauth-app",
|
||||
...optionsWithDefaults
|
||||
});
|
||||
const authentication2 = Object.assign(response2.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "reset",
|
||||
token: response2.authentication.token,
|
||||
scopes: response2.authentication.scopes || void 0,
|
||||
authentication: authentication2,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response2.authentication.token,
|
||||
scopes: response2.authentication.scopes
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response2, authentication: authentication2 };
|
||||
}
|
||||
const response = await OAuthMethods.resetToken({
|
||||
clientType: "github-app",
|
||||
...optionsWithDefaults
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "reset",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
export {
|
||||
resetTokenWithState
|
||||
};
|
||||
40
node_modules/@octokit/oauth-app/dist-src/methods/scope-token.js
generated
vendored
Normal file
40
node_modules/@octokit/oauth-app/dist-src/methods/scope-token.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
async function scopeTokenWithState(state, options) {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps"
|
||||
);
|
||||
}
|
||||
const response = await OAuthMethods.scopeToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
...options
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "scoped",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
export {
|
||||
scopeTokenWithState
|
||||
};
|
||||
13
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2-parse-request.js
generated
vendored
Normal file
13
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2-parse-request.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function parseRequest(request) {
|
||||
const { method } = request.requestContext.http;
|
||||
let url = request.rawPath;
|
||||
const { stage } = request.requestContext;
|
||||
if (url.startsWith("/" + stage)) url = url.substring(stage.length + 1);
|
||||
if (request.rawQueryString) url += "?" + request.rawQueryString;
|
||||
const headers = request.headers;
|
||||
const text = async () => request.body || "";
|
||||
return { method, url, headers, text };
|
||||
}
|
||||
export {
|
||||
parseRequest
|
||||
};
|
||||
10
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2-send-response.js
generated
vendored
Normal file
10
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2-send-response.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function sendResponse(octokitResponse) {
|
||||
return {
|
||||
statusCode: octokitResponse.status,
|
||||
headers: octokitResponse.headers,
|
||||
body: octokitResponse.text
|
||||
};
|
||||
}
|
||||
export {
|
||||
sendResponse
|
||||
};
|
||||
13
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2.js
generated
vendored
Normal file
13
node_modules/@octokit/oauth-app/dist-src/middleware/aws-lambda/api-gateway-v2.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { parseRequest } from "./api-gateway-v2-parse-request.js";
|
||||
import { sendResponse } from "./api-gateway-v2-send-response.js";
|
||||
import { handleRequest } from "../handle-request.js";
|
||||
function createAWSLambdaAPIGatewayV2Handler(app, options = {}) {
|
||||
return async function(event) {
|
||||
const request = parseRequest(event);
|
||||
const response = await handleRequest(app, options, request);
|
||||
return response ? sendResponse(response) : void 0;
|
||||
};
|
||||
}
|
||||
export {
|
||||
createAWSLambdaAPIGatewayV2Handler
|
||||
};
|
||||
240
node_modules/@octokit/oauth-app/dist-src/middleware/handle-request.js
generated
vendored
Normal file
240
node_modules/@octokit/oauth-app/dist-src/middleware/handle-request.js
generated
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
import { OAuthApp } from "../index.js";
|
||||
import { unknownRouteResponse } from "./unknown-route-response.js";
|
||||
async function handleRequest(app, { pathPrefix = "/api/github/oauth" }, request) {
|
||||
let { pathname } = new URL(request.url, "http://localhost");
|
||||
if (!pathname.startsWith(`${pathPrefix}/`)) {
|
||||
return void 0;
|
||||
}
|
||||
if (request.method === "OPTIONS") {
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-allow-methods": "*",
|
||||
"access-control-allow-headers": "Content-Type, User-Agent, Authorization"
|
||||
}
|
||||
};
|
||||
}
|
||||
pathname = pathname.slice(pathPrefix.length + 1);
|
||||
const route = [request.method, pathname].join(" ");
|
||||
const routes = {
|
||||
getLogin: `GET login`,
|
||||
getCallback: `GET callback`,
|
||||
createToken: `POST token`,
|
||||
getToken: `GET token`,
|
||||
patchToken: `PATCH token`,
|
||||
patchRefreshToken: `PATCH refresh-token`,
|
||||
scopeToken: `POST token/scoped`,
|
||||
deleteToken: `DELETE token`,
|
||||
deleteGrant: `DELETE grant`
|
||||
};
|
||||
if (!Object.values(routes).includes(route)) {
|
||||
return unknownRouteResponse(request);
|
||||
}
|
||||
let json;
|
||||
try {
|
||||
const text = await request.text();
|
||||
json = text ? JSON.parse(text) : {};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 400,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify({
|
||||
error: "[@octokit/oauth-app] request error"
|
||||
})
|
||||
};
|
||||
}
|
||||
const { searchParams } = new URL(request.url, "http://localhost");
|
||||
const query = Object.fromEntries(searchParams);
|
||||
const headers = request.headers;
|
||||
try {
|
||||
if (route === routes.getLogin) {
|
||||
const authOptions = {};
|
||||
if (query.state) {
|
||||
Object.assign(authOptions, { state: query.state });
|
||||
}
|
||||
if (query.scopes) {
|
||||
Object.assign(authOptions, { scopes: query.scopes.split(",") });
|
||||
}
|
||||
if (query.allowSignup) {
|
||||
Object.assign(authOptions, {
|
||||
allowSignup: query.allowSignup === "true"
|
||||
});
|
||||
}
|
||||
if (query.redirectUrl) {
|
||||
Object.assign(authOptions, { redirectUrl: query.redirectUrl });
|
||||
}
|
||||
const { url } = app.getWebFlowAuthorizationUrl(authOptions);
|
||||
return { status: 302, headers: { location: url } };
|
||||
}
|
||||
if (route === routes.getCallback) {
|
||||
if (query.error) {
|
||||
throw new Error(
|
||||
`[@octokit/oauth-app] ${query.error} ${query.error_description}`
|
||||
);
|
||||
}
|
||||
if (!query.code) {
|
||||
throw new Error('[@octokit/oauth-app] "code" parameter is required');
|
||||
}
|
||||
const {
|
||||
authentication: { token: token2 }
|
||||
} = await app.createToken({
|
||||
code: query.code
|
||||
});
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "text/html"
|
||||
},
|
||||
text: `<h1>Token created successfully</h1>
|
||||
|
||||
<p>Your token is: <strong>${token2}</strong>. Copy it now as it cannot be shown again.</p>`
|
||||
};
|
||||
}
|
||||
if (route === routes.createToken) {
|
||||
const { code, redirectUrl } = json;
|
||||
if (!code) {
|
||||
throw new Error('[@octokit/oauth-app] "code" parameter is required');
|
||||
}
|
||||
const result = await app.createToken({
|
||||
code,
|
||||
redirectUrl
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 201,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.getToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.checkToken({
|
||||
token: token2
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.patchToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.resetToken({ token: token2 });
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.patchRefreshToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const { refreshToken } = json;
|
||||
if (!refreshToken) {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] refreshToken must be sent in request body"
|
||||
);
|
||||
}
|
||||
const result = await app.refreshToken({ refreshToken });
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.scopeToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
const result = await app.scopeToken({
|
||||
token: token2,
|
||||
...json
|
||||
});
|
||||
delete result.authentication.clientSecret;
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify(result)
|
||||
};
|
||||
}
|
||||
if (route === routes.deleteToken) {
|
||||
const token2 = headers.authorization?.substr("token ".length);
|
||||
if (!token2) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
await app.deleteToken({
|
||||
token: token2
|
||||
});
|
||||
return {
|
||||
status: 204,
|
||||
headers: { "access-control-allow-origin": "*" }
|
||||
};
|
||||
}
|
||||
const token = headers.authorization?.substr("token ".length);
|
||||
if (!token) {
|
||||
throw new Error(
|
||||
'[@octokit/oauth-app] "Authorization" header is required'
|
||||
);
|
||||
}
|
||||
await app.deleteAuthorization({
|
||||
token
|
||||
});
|
||||
return {
|
||||
status: 204,
|
||||
headers: { "access-control-allow-origin": "*" }
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 400,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"access-control-allow-origin": "*"
|
||||
},
|
||||
text: JSON.stringify({ error: error.message })
|
||||
};
|
||||
}
|
||||
}
|
||||
export {
|
||||
handleRequest
|
||||
};
|
||||
19
node_modules/@octokit/oauth-app/dist-src/middleware/node/index.js
generated
vendored
Normal file
19
node_modules/@octokit/oauth-app/dist-src/middleware/node/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { parseRequest } from "./parse-request.js";
|
||||
import { sendResponse } from "./send-response.js";
|
||||
import { handleRequest } from "../handle-request.js";
|
||||
function createNodeMiddleware(app, options = {}) {
|
||||
return async function(request, response, next) {
|
||||
const octokitRequest = await parseRequest(request);
|
||||
const octokitResponse = await handleRequest(app, options, octokitRequest);
|
||||
if (octokitResponse) {
|
||||
sendResponse(octokitResponse, response);
|
||||
return true;
|
||||
} else {
|
||||
next?.();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
createNodeMiddleware
|
||||
};
|
||||
14
node_modules/@octokit/oauth-app/dist-src/middleware/node/parse-request.js
generated
vendored
Normal file
14
node_modules/@octokit/oauth-app/dist-src/middleware/node/parse-request.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function parseRequest(request) {
|
||||
const { method, url, headers } = request;
|
||||
async function text() {
|
||||
const text2 = await new Promise((resolve, reject) => {
|
||||
let bodyChunks = [];
|
||||
request.on("error", reject).on("data", (chunk) => bodyChunks.push(chunk)).on("end", () => resolve(Buffer.concat(bodyChunks).toString()));
|
||||
});
|
||||
return text2;
|
||||
}
|
||||
return { method, url, headers, text };
|
||||
}
|
||||
export {
|
||||
parseRequest
|
||||
};
|
||||
7
node_modules/@octokit/oauth-app/dist-src/middleware/node/send-response.js
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/dist-src/middleware/node/send-response.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function sendResponse(octokitResponse, response) {
|
||||
response.writeHead(octokitResponse.status, octokitResponse.headers);
|
||||
response.end(octokitResponse.text);
|
||||
}
|
||||
export {
|
||||
sendResponse
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/dist-src/middleware/unknown-route-response.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/dist-src/middleware/unknown-route-response.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function unknownRouteResponse(request) {
|
||||
return {
|
||||
status: 404,
|
||||
headers: { "content-type": "application/json" },
|
||||
text: JSON.stringify({
|
||||
error: `Unknown route: ${request.method} ${request.url}`
|
||||
})
|
||||
};
|
||||
}
|
||||
export {
|
||||
unknownRouteResponse
|
||||
};
|
||||
13
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/index.js
generated
vendored
Normal file
13
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { parseRequest } from "./parse-request.js";
|
||||
import { sendResponse } from "./send-response.js";
|
||||
import { handleRequest } from "../handle-request.js";
|
||||
function createWebWorkerHandler(app, options = {}) {
|
||||
return async function(request) {
|
||||
const octokitRequest = await parseRequest(request);
|
||||
const octokitResponse = await handleRequest(app, options, octokitRequest);
|
||||
return octokitResponse ? sendResponse(octokitResponse) : void 0;
|
||||
};
|
||||
}
|
||||
export {
|
||||
createWebWorkerHandler
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/parse-request.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/parse-request.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function parseRequest(request) {
|
||||
const headers = Object.fromEntries(request.headers.entries());
|
||||
return {
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
headers,
|
||||
text: () => request.text()
|
||||
};
|
||||
}
|
||||
export {
|
||||
parseRequest
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/send-response.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/dist-src/middleware/web-worker/send-response.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function sendResponse(octokitResponse) {
|
||||
const responseOptions = {
|
||||
status: octokitResponse.status
|
||||
};
|
||||
if (octokitResponse.headers) {
|
||||
Object.assign(responseOptions, { headers: octokitResponse.headers });
|
||||
}
|
||||
return new Response(octokitResponse.text, responseOptions);
|
||||
}
|
||||
export {
|
||||
sendResponse
|
||||
};
|
||||
9
node_modules/@octokit/oauth-app/dist-src/oauth-app-octokit.js
generated
vendored
Normal file
9
node_modules/@octokit/oauth-app/dist-src/oauth-app-octokit.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { Octokit } from "@octokit/core";
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version.js";
|
||||
const OAuthAppOctokit = Octokit.defaults({
|
||||
userAgent: `octokit-oauth-app.js/${VERSION} ${getUserAgent()}`
|
||||
});
|
||||
export {
|
||||
OAuthAppOctokit
|
||||
};
|
||||
4
node_modules/@octokit/oauth-app/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/dist-src/version.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
const VERSION = "7.1.6";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
2
node_modules/@octokit/oauth-app/dist-types/add-event-handler.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/dist-types/add-event-handler.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { EventHandler, EventAndActionName, State, ClientType, Options } from "./types.js";
|
||||
export declare function addEventHandler(state: State, eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<Options<ClientType>>): void;
|
||||
2
node_modules/@octokit/oauth-app/dist-types/emit-event.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/dist-types/emit-event.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { State, EventHandlerContext, ClientType, Options } from "./types.js";
|
||||
export declare function emitEvent(state: State, context: EventHandlerContext<Options<ClientType>>): Promise<void>;
|
||||
60
node_modules/@octokit/oauth-app/dist-types/index.d.ts
generated
vendored
Normal file
60
node_modules/@octokit/oauth-app/dist-types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { type GetUserOctokitWithStateInterface } from "./methods/get-user-octokit.js";
|
||||
import { type GetWebFlowAuthorizationUrlInterface } from "./methods/get-web-flow-authorization-url.js";
|
||||
import { type CreateTokenInterface } from "./methods/create-token.js";
|
||||
import { type CheckTokenInterface } from "./methods/check-token.js";
|
||||
import { type ResetTokenInterface } from "./methods/reset-token.js";
|
||||
import { type RefreshTokenInterface } from "./methods/refresh-token.js";
|
||||
import { type ScopeTokenInterface } from "./methods/scope-token.js";
|
||||
import { type DeleteTokenInterface } from "./methods/delete-token.js";
|
||||
import { type DeleteAuthorizationInterface } from "./methods/delete-authorization.js";
|
||||
import type { AddEventHandler, ClientType, ClientTypeFromOptions, ConstructorOptions, OctokitTypeFromOptions, Options } from "./types.js";
|
||||
export type { HandlerOptions, OctokitRequest, OctokitResponse, } from "./middleware/types.js";
|
||||
export { handleRequest } from "./middleware/handle-request.js";
|
||||
export { unknownRouteResponse } from "./middleware/unknown-route-response.js";
|
||||
export { createNodeMiddleware } from "./middleware/node/index.js";
|
||||
export { sendResponse as sendNodeResponse } from "./middleware/node/send-response.js";
|
||||
export { createWebWorkerHandler } from "./middleware/web-worker/index.js";
|
||||
export { createAWSLambdaAPIGatewayV2Handler } from "./middleware/aws-lambda/api-gateway-v2.js";
|
||||
export type { GetUserOctokitWithStateInterface } from "./methods/get-user-octokit.js";
|
||||
export type { GetWebFlowAuthorizationUrlInterface } from "./methods/get-web-flow-authorization-url.js";
|
||||
export type { CreateTokenInterface } from "./methods/create-token.js";
|
||||
export type { CheckTokenInterface } from "./methods/check-token.js";
|
||||
export type { ResetTokenInterface } from "./methods/reset-token.js";
|
||||
export type { RefreshTokenInterface } from "./methods/refresh-token.js";
|
||||
export type { ScopeTokenInterface } from "./methods/scope-token.js";
|
||||
export type { DeleteTokenInterface } from "./methods/delete-token.js";
|
||||
export type { DeleteAuthorizationInterface } from "./methods/delete-authorization.js";
|
||||
export type { AddEventHandler, ClientType, ClientTypeFromOptions, ConstructorOptions, OctokitTypeFromOptions, Options, } from "./types.js";
|
||||
type Constructor<T> = new (...args: any[]) => T;
|
||||
export declare class OAuthApp<TOptions extends Options<ClientType> = Options<"oauth-app">> {
|
||||
static VERSION: string;
|
||||
static defaults<TDefaults extends Options<ClientType>, S extends Constructor<OAuthApp<TDefaults>>>(this: S, defaults: TDefaults): ({
|
||||
new (...args: any[]): {
|
||||
type: ClientTypeFromOptions<TDefaults>;
|
||||
on: AddEventHandler<TDefaults>;
|
||||
octokit: OctokitTypeFromOptions<TDefaults>;
|
||||
getUserOctokit: GetUserOctokitWithStateInterface<ClientTypeFromOptions<TDefaults>>;
|
||||
getWebFlowAuthorizationUrl: GetWebFlowAuthorizationUrlInterface<ClientTypeFromOptions<TDefaults>>;
|
||||
createToken: CreateTokenInterface<ClientTypeFromOptions<TDefaults>>;
|
||||
checkToken: CheckTokenInterface<ClientTypeFromOptions<TDefaults>>;
|
||||
resetToken: ResetTokenInterface<ClientTypeFromOptions<TDefaults>>;
|
||||
refreshToken: RefreshTokenInterface;
|
||||
scopeToken: ScopeTokenInterface;
|
||||
deleteToken: DeleteTokenInterface;
|
||||
deleteAuthorization: DeleteAuthorizationInterface;
|
||||
};
|
||||
} & S) & typeof this;
|
||||
constructor(options: ConstructorOptions<TOptions>);
|
||||
type: ClientTypeFromOptions<TOptions>;
|
||||
on: AddEventHandler<TOptions>;
|
||||
octokit: OctokitTypeFromOptions<TOptions>;
|
||||
getUserOctokit: GetUserOctokitWithStateInterface<ClientTypeFromOptions<TOptions>>;
|
||||
getWebFlowAuthorizationUrl: GetWebFlowAuthorizationUrlInterface<ClientTypeFromOptions<TOptions>>;
|
||||
createToken: CreateTokenInterface<ClientTypeFromOptions<TOptions>>;
|
||||
checkToken: CheckTokenInterface<ClientTypeFromOptions<TOptions>>;
|
||||
resetToken: ResetTokenInterface<ClientTypeFromOptions<TOptions>>;
|
||||
refreshToken: RefreshTokenInterface;
|
||||
scopeToken: ScopeTokenInterface;
|
||||
deleteToken: DeleteTokenInterface;
|
||||
deleteAuthorization: DeleteAuthorizationInterface;
|
||||
}
|
||||
14
node_modules/@octokit/oauth-app/dist-types/methods/check-token.d.ts
generated
vendored
Normal file
14
node_modules/@octokit/oauth-app/dist-types/methods/check-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { ClientType, State } from "../types.js";
|
||||
export type CheckTokenOptions = {
|
||||
token: string;
|
||||
};
|
||||
export declare function checkTokenWithState(state: State, options: CheckTokenOptions): Promise<any>;
|
||||
export interface CheckTokenInterface<TClientType extends ClientType> {
|
||||
(options: CheckTokenOptions): (TClientType extends "oauth-app" ? Promise<OAuthMethods.CheckTokenOAuthAppResponse> : Promise<OAuthMethods.CheckTokenGitHubAppResponse>) & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
};
|
||||
}
|
||||
20
node_modules/@octokit/oauth-app/dist-types/methods/create-token.d.ts
generated
vendored
Normal file
20
node_modules/@octokit/oauth-app/dist-types/methods/create-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
import type { ClientType, GithubAppUserAuthenticationWithOptionalExpiration, State } from "../types.js";
|
||||
export type CreateTokenWebFlowOptions = Omit<OAuthAppAuth.WebFlowAuthOptions, "type">;
|
||||
export type CreateTokenOAuthAppDeviceFlowOptions = Omit<OAuthAppAuth.OAuthAppDeviceFlowAuthOptions, "type">;
|
||||
export type CreateTokenGitHubAppDeviceFlowOptions = Omit<OAuthAppAuth.GitHubAppDeviceFlowAuthOptions, "type">;
|
||||
export declare function createTokenWithState(state: State, options: CreateTokenWebFlowOptions | CreateTokenOAuthAppDeviceFlowOptions | CreateTokenGitHubAppDeviceFlowOptions): Promise<{
|
||||
authentication: OAuthAppAuth.OAuthAppUserAuthentication | OAuthAppAuth.GitHubAppUserAuthentication | OAuthAppAuth.GitHubAppUserAuthenticationWithExpiration;
|
||||
}>;
|
||||
export interface CreateTokenInterface<TClientType extends ClientType> {
|
||||
(options: CreateTokenWebFlowOptions): TClientType extends "oauth-app" ? Promise<{
|
||||
authentication: OAuthAppAuth.OAuthAppUserAuthentication;
|
||||
}> : Promise<{
|
||||
authentication: GithubAppUserAuthenticationWithOptionalExpiration;
|
||||
}>;
|
||||
(options: TClientType extends "oauth-app" ? CreateTokenOAuthAppDeviceFlowOptions : CreateTokenGitHubAppDeviceFlowOptions): TClientType extends "oauth-app" ? Promise<{
|
||||
authentication: OAuthAppAuth.OAuthAppUserAuthentication;
|
||||
}> : Promise<{
|
||||
authentication: GithubAppUserAuthenticationWithOptionalExpiration;
|
||||
}>;
|
||||
}
|
||||
9
node_modules/@octokit/oauth-app/dist-types/methods/delete-authorization.d.ts
generated
vendored
Normal file
9
node_modules/@octokit/oauth-app/dist-types/methods/delete-authorization.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { State } from "../types.js";
|
||||
export type DeleteAuthorizationOptions = {
|
||||
token: string;
|
||||
};
|
||||
export declare function deleteAuthorizationWithState(state: State, options: DeleteAuthorizationOptions): Promise<OAuthMethods.DeleteAuthorizationResponse>;
|
||||
export interface DeleteAuthorizationInterface {
|
||||
(options: DeleteAuthorizationOptions): Promise<OAuthMethods.DeleteAuthorizationResponse>;
|
||||
}
|
||||
9
node_modules/@octokit/oauth-app/dist-types/methods/delete-token.d.ts
generated
vendored
Normal file
9
node_modules/@octokit/oauth-app/dist-types/methods/delete-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { State } from "../types.js";
|
||||
export type DeleteTokenOptions = {
|
||||
token: string;
|
||||
};
|
||||
export declare function deleteTokenWithState(state: State, options: DeleteTokenOptions): Promise<OAuthMethods.DeleteTokenResponse>;
|
||||
export interface DeleteTokenInterface {
|
||||
(options: DeleteTokenOptions): Promise<OAuthMethods.DeleteTokenResponse>;
|
||||
}
|
||||
1
node_modules/@octokit/oauth-app/dist-types/methods/get-oauth-client-code.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/oauth-app/dist-types/methods/get-oauth-client-code.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare function getOAuthClientCode(): string;
|
||||
10
node_modules/@octokit/oauth-app/dist-types/methods/get-user-octokit.d.ts
generated
vendored
Normal file
10
node_modules/@octokit/oauth-app/dist-types/methods/get-user-octokit.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import type { OAuthAppStrategyOptionsWebFlow, OAuthAppStrategyOptionsDeviceFlow, OAuthAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsWebFlow, GitHubAppStrategyOptionsDeviceFlow, GitHubAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthenticationWithExpiration } from "@octokit/auth-oauth-user";
|
||||
import type { State, OctokitInstance, ClientType } from "../types.js";
|
||||
type StateOptions = "clientType" | "clientId" | "clientSecret" | "request";
|
||||
export type GetUserOctokitOAuthAppOptions = Omit<OAuthAppStrategyOptionsWebFlow, StateOptions> | Omit<OAuthAppStrategyOptionsDeviceFlow, StateOptions> | Omit<OAuthAppStrategyOptionsExistingAuthentication, StateOptions>;
|
||||
export type GetUserOctokitGitHubAppOptions = Omit<GitHubAppStrategyOptionsWebFlow, StateOptions> | Omit<GitHubAppStrategyOptionsDeviceFlow, StateOptions> | Omit<GitHubAppStrategyOptionsExistingAuthentication, StateOptions> | Omit<GitHubAppStrategyOptionsExistingAuthenticationWithExpiration, StateOptions>;
|
||||
export declare function getUserOctokitWithState(state: State, options: GetUserOctokitOAuthAppOptions | GetUserOctokitGitHubAppOptions): Promise<import("@octokit/core").Octokit>;
|
||||
export interface GetUserOctokitWithStateInterface<TClientType extends ClientType> {
|
||||
(options: TClientType extends "oauth-app" ? GetUserOctokitOAuthAppOptions : GetUserOctokitGitHubAppOptions): Promise<OctokitInstance>;
|
||||
}
|
||||
export {};
|
||||
10
node_modules/@octokit/oauth-app/dist-types/methods/get-web-flow-authorization-url.d.ts
generated
vendored
Normal file
10
node_modules/@octokit/oauth-app/dist-types/methods/get-web-flow-authorization-url.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { ClientType, State } from "../types.js";
|
||||
type StateOptions = "clientType" | "clientId" | "clientSecret" | "request";
|
||||
export type GetWebFlowAuthorizationUrlOAuthAppOptions = Omit<OAuthMethods.GetWebFlowAuthorizationUrlOAuthAppOptions, StateOptions>;
|
||||
export type GetWebFlowAuthorizationUrlGitHubAppOptions = Omit<OAuthMethods.GetWebFlowAuthorizationUrlGitHubAppOptions, StateOptions>;
|
||||
export declare function getWebFlowAuthorizationUrlWithState(state: State, options: any): any;
|
||||
export interface GetWebFlowAuthorizationUrlInterface<TClientType extends ClientType> {
|
||||
(options: TClientType extends "oauth-app" ? GetWebFlowAuthorizationUrlOAuthAppOptions : GetWebFlowAuthorizationUrlGitHubAppOptions): TClientType extends "oauth-app" ? OAuthMethods.GetWebFlowAuthorizationUrlOAuthAppResult : OAuthMethods.GetWebFlowAuthorizationUrlGitHubAppResult;
|
||||
}
|
||||
export {};
|
||||
19
node_modules/@octokit/oauth-app/dist-types/methods/refresh-token.d.ts
generated
vendored
Normal file
19
node_modules/@octokit/oauth-app/dist-types/methods/refresh-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { State } from "../types.js";
|
||||
export type RefreshTokenOptions = {
|
||||
refreshToken: string;
|
||||
};
|
||||
export declare function refreshTokenWithState(state: State, options: RefreshTokenOptions): Promise<OAuthMethods.RefreshTokenResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
export interface RefreshTokenInterface {
|
||||
(options: RefreshTokenOptions): Promise<OAuthMethods.RefreshTokenResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
}
|
||||
24
node_modules/@octokit/oauth-app/dist-types/methods/reset-token.d.ts
generated
vendored
Normal file
24
node_modules/@octokit/oauth-app/dist-types/methods/reset-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { ClientType, State } from "../types.js";
|
||||
export type ResetTokenOptions = {
|
||||
token: string;
|
||||
};
|
||||
export declare function resetTokenWithState(state: State, options: ResetTokenOptions): Promise<(OAuthMethods.ResetTokenOAuthAppResponse | OAuthMethods.ResetTokenGitHubAppResponse) & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
export interface ResetTokenInterface<TClientType extends ClientType> {
|
||||
(options: ResetTokenOptions): TClientType extends "oauth-app" ? Promise<OAuthMethods.ResetTokenOAuthAppResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}> : Promise<OAuthMethods.ResetTokenGitHubAppResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
}
|
||||
19
node_modules/@octokit/oauth-app/dist-types/methods/scope-token.d.ts
generated
vendored
Normal file
19
node_modules/@octokit/oauth-app/dist-types/methods/scope-token.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import type { State } from "../types.js";
|
||||
type StateOptions = "clientType" | "clientId" | "clientSecret" | "request";
|
||||
export type ScopeTokenOptions = Omit<OAuthMethods.ScopeTokenOptions, StateOptions>;
|
||||
export declare function scopeTokenWithState(state: State, options: ScopeTokenOptions): Promise<OAuthMethods.ScopeTokenResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
export interface ScopeTokenInterface {
|
||||
(options: ScopeTokenOptions): Promise<OAuthMethods.ScopeTokenResponse & {
|
||||
authentication: {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
};
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
3
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2-parse-request.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2-parse-request.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import type { OctokitRequest } from "../types.js";
|
||||
import type { APIGatewayProxyEventV2 } from "aws-lambda";
|
||||
export declare function parseRequest(request: APIGatewayProxyEventV2): OctokitRequest;
|
||||
3
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2-send-response.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2-send-response.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import type { OctokitResponse } from "../types.js";
|
||||
import type { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
|
||||
export declare function sendResponse(octokitResponse: OctokitResponse): APIGatewayProxyStructuredResultV2;
|
||||
5
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2.d.ts
generated
vendored
Normal file
5
node_modules/@octokit/oauth-app/dist-types/middleware/aws-lambda/api-gateway-v2.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import type { HandlerOptions } from "../types.js";
|
||||
import type { OAuthApp } from "../../index.js";
|
||||
import type { ClientType, Options } from "../../types.js";
|
||||
import type { APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2 } from "aws-lambda";
|
||||
export declare function createAWSLambdaAPIGatewayV2Handler(app: OAuthApp<Options<ClientType>>, options?: HandlerOptions): (event: APIGatewayProxyEventV2) => Promise<APIGatewayProxyStructuredResultV2 | undefined>;
|
||||
4
node_modules/@octokit/oauth-app/dist-types/middleware/handle-request.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/dist-types/middleware/handle-request.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { OAuthApp } from "../index.js";
|
||||
import type { HandlerOptions, OctokitRequest, OctokitResponse } from "./types.js";
|
||||
import type { ClientType, Options } from "../types.js";
|
||||
export declare function handleRequest(app: OAuthApp<Options<ClientType>>, { pathPrefix }: HandlerOptions, request: OctokitRequest): Promise<OctokitResponse | undefined>;
|
||||
7
node_modules/@octokit/oauth-app/dist-types/middleware/node/index.d.ts
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/dist-types/middleware/node/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
type IncomingMessage = any;
|
||||
type ServerResponse = any;
|
||||
import type { OAuthApp } from "../../index.js";
|
||||
import type { HandlerOptions } from "../types.js";
|
||||
import type { ClientType, Options } from "../../types.js";
|
||||
export declare function createNodeMiddleware(app: OAuthApp<Options<ClientType>>, options?: HandlerOptions): (request: IncomingMessage, response: ServerResponse, next?: Function) => Promise<boolean>;
|
||||
export {};
|
||||
4
node_modules/@octokit/oauth-app/dist-types/middleware/node/parse-request.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/dist-types/middleware/node/parse-request.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
type IncomingMessage = any;
|
||||
import type { OctokitRequest } from "../types.js";
|
||||
export declare function parseRequest(request: IncomingMessage): OctokitRequest;
|
||||
export {};
|
||||
4
node_modules/@octokit/oauth-app/dist-types/middleware/node/send-response.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/dist-types/middleware/node/send-response.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
type ServerResponse = any;
|
||||
import type { OctokitResponse } from "../types.js";
|
||||
export declare function sendResponse(octokitResponse: OctokitResponse, response: ServerResponse): void;
|
||||
export {};
|
||||
14
node_modules/@octokit/oauth-app/dist-types/middleware/types.d.ts
generated
vendored
Normal file
14
node_modules/@octokit/oauth-app/dist-types/middleware/types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export type OctokitRequest = {
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Record<string, string>;
|
||||
text: () => Promise<string>;
|
||||
};
|
||||
export type OctokitResponse = {
|
||||
status: number;
|
||||
headers?: Record<string, string>;
|
||||
text?: string;
|
||||
};
|
||||
export type HandlerOptions = {
|
||||
pathPrefix?: string;
|
||||
};
|
||||
8
node_modules/@octokit/oauth-app/dist-types/middleware/unknown-route-response.d.ts
generated
vendored
Normal file
8
node_modules/@octokit/oauth-app/dist-types/middleware/unknown-route-response.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import type { OctokitRequest } from "./types.js";
|
||||
export declare function unknownRouteResponse(request: OctokitRequest): {
|
||||
status: number;
|
||||
headers: {
|
||||
"content-type": string;
|
||||
};
|
||||
text: string;
|
||||
};
|
||||
4
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/index.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import type { OAuthApp } from "../../index.js";
|
||||
import type { HandlerOptions } from "../types.js";
|
||||
import type { ClientType, Options } from "../../types.js";
|
||||
export declare function createWebWorkerHandler<T extends Options<ClientType>>(app: OAuthApp<T>, options?: HandlerOptions): (request: Request) => Promise<Response | undefined>;
|
||||
2
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/parse-request.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/parse-request.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { OctokitRequest } from "../types.js";
|
||||
export declare function parseRequest(request: Request): OctokitRequest;
|
||||
2
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/send-response.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/dist-types/middleware/web-worker/send-response.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { OctokitResponse } from "../types.js";
|
||||
export declare function sendResponse(octokitResponse: OctokitResponse): Response;
|
||||
2
node_modules/@octokit/oauth-app/dist-types/oauth-app-octokit.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/dist-types/oauth-app-octokit.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { Octokit } from "@octokit/core";
|
||||
export declare const OAuthAppOctokit: typeof Octokit;
|
||||
68
node_modules/@octokit/oauth-app/dist-types/types.d.ts
generated
vendored
Normal file
68
node_modules/@octokit/oauth-app/dist-types/types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import type { Octokit } from "@octokit/core";
|
||||
import type { OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "@octokit/auth-oauth-app";
|
||||
import type { OAuthAppOctokit } from "./oauth-app-octokit.js";
|
||||
export type ClientType = "oauth-app" | "github-app";
|
||||
export type OAuthAppOctokitClassType = typeof OAuthAppOctokit;
|
||||
export type GithubAppUserAuthenticationWithOptionalExpiration = GitHubAppUserAuthentication & Partial<GitHubAppUserAuthenticationWithExpiration>;
|
||||
export type Scope = string;
|
||||
export type ClientId = string;
|
||||
export type ClientSecret = string;
|
||||
export type Token = string;
|
||||
export type EventName = "token" | "authorization";
|
||||
export type ActionName = "created" | "reset" | "deleted" | "refreshed" | "scoped";
|
||||
export type EventAndActionName = "token" | "token.created" | "token.reset" | "token.refreshed" | "token.scoped" | "token.deleted" | "authorization" | "authorization.deleted";
|
||||
type CommonOptions<TOctokit extends OAuthAppOctokitClassType> = {
|
||||
clientId?: ClientId;
|
||||
clientSecret?: ClientSecret;
|
||||
allowSignup?: boolean;
|
||||
baseUrl?: string;
|
||||
redirectUrl?: string;
|
||||
log?: typeof console;
|
||||
Octokit?: TOctokit;
|
||||
};
|
||||
export type Options<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType = OAuthAppOctokitClassType> = TClientType extends "oauth-app" ? CommonOptions<TOctokit> & {
|
||||
clientType?: TClientType;
|
||||
defaultScopes?: Scope[];
|
||||
} : CommonOptions<TOctokit> & {
|
||||
clientType?: TClientType;
|
||||
};
|
||||
export type ConstructorOptions<TOptions extends Options<ClientType>> = TOptions & {
|
||||
clientId: ClientId;
|
||||
clientSecret: ClientSecret;
|
||||
};
|
||||
export type OctokitTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["Octokit"] extends typeof Octokit ? InstanceType<TOptions["Octokit"]> : Octokit;
|
||||
export type OctokitClassTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["Octokit"] extends typeof Octokit ? TOptions["Octokit"] : typeof Octokit;
|
||||
export type ClientTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["clientType"] extends "github-app" ? "github-app" : "oauth-app";
|
||||
export type OctokitInstance = InstanceType<OAuthAppOctokitClassType>;
|
||||
export type State = {
|
||||
clientType: ClientType;
|
||||
clientId: ClientId;
|
||||
clientSecret: ClientSecret;
|
||||
defaultScopes: Scope[];
|
||||
allowSignup?: boolean | undefined;
|
||||
baseUrl?: string | undefined;
|
||||
redirectUrl?: string | undefined;
|
||||
log?: typeof console | undefined;
|
||||
Octokit: OAuthAppOctokitClassType;
|
||||
octokit: OctokitInstance;
|
||||
eventHandlers: {
|
||||
[key: string]: EventHandler<Options<ClientType>>[];
|
||||
};
|
||||
};
|
||||
export type EventHandlerContext<TOptions extends Options<ClientType>> = ClientTypeFromOptions<TOptions> extends "oauth-app" ? {
|
||||
name: EventName;
|
||||
action: ActionName;
|
||||
token: Token;
|
||||
scopes?: Scope[];
|
||||
octokit: OctokitTypeFromOptions<TOptions>;
|
||||
authentication?: OAuthAppUserAuthentication | GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration;
|
||||
} : {
|
||||
name: EventName;
|
||||
action: ActionName;
|
||||
token: Token;
|
||||
octokit: OctokitTypeFromOptions<TOptions>;
|
||||
authentication?: GithubAppUserAuthenticationWithOptionalExpiration;
|
||||
};
|
||||
export type EventHandler<TOptions extends Options<ClientType>> = (context: EventHandlerContext<TOptions>) => void;
|
||||
export type AddEventHandler<TOptions extends Options<ClientType>> = (eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<TOptions>) => void;
|
||||
export {};
|
||||
1
node_modules/@octokit/oauth-app/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/oauth-app/dist-types/version.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const VERSION = "7.1.6";
|
||||
21
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/oauth-app/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/oauth-app/node_modules/@octokit/auth-token/README.md
generated
vendored
Normal file
284
node_modules/@octokit/oauth-app/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/oauth-app/node_modules/@octokit/auth-token/dist-bundle/index.js
generated
vendored
Normal file
55
node_modules/@octokit/oauth-app/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/oauth-app/node_modules/@octokit/auth-token/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/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": []
|
||||
}
|
||||
15
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/auth.js
generated
vendored
Normal file
15
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/auth.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { isJWT } from "./is-jwt.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
|
||||
};
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/hook.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/hook.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { withAuthorizationPrefix } from "./with-authorization-prefix.js";
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
19
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/index.js
generated
vendored
Normal file
19
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
const 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/oauth-app/node_modules/@octokit/auth-token/dist-src/is-jwt.js
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/is-jwt.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const b64url = "(?:[a-zA-Z0-9_-]+)";
|
||||
const sep = "\\.";
|
||||
const jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
||||
const isJWT = jwtRE.test.bind(jwtRE);
|
||||
export {
|
||||
isJWT
|
||||
};
|
||||
9
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
generated
vendored
Normal file
9
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
return `token ${token}`;
|
||||
}
|
||||
export {
|
||||
withAuthorizationPrefix
|
||||
};
|
||||
2
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/auth.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/auth.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { Token, Authentication } from "./types.js";
|
||||
export declare function auth(token: Token): Promise<Authentication>;
|
||||
2
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/hook.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/hook.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import type { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route, Token } from "./types.js";
|
||||
export declare function hook(token: Token, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
||||
7
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/index.d.ts
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import type { StrategyInterface, Token, Authentication } from "./types.js";
|
||||
export type Types = {
|
||||
StrategyOptions: Token;
|
||||
AuthOptions: never;
|
||||
Authentication: Authentication;
|
||||
};
|
||||
export declare const createTokenAuth: StrategyInterface;
|
||||
1
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/is-jwt.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/is-jwt.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const isJWT: (string: string) => boolean;
|
||||
33
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/types.d.ts
generated
vendored
Normal file
33
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import type * as OctokitTypes from "@octokit/types";
|
||||
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
||||
export type StrategyInterface = OctokitTypes.StrategyInterface<[
|
||||
Token
|
||||
], [
|
||||
], Authentication>;
|
||||
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
||||
export type EndpointOptions = OctokitTypes.EndpointOptions;
|
||||
export type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export type RequestInterface = OctokitTypes.RequestInterface;
|
||||
export type Route = OctokitTypes.Route;
|
||||
export type Token = string;
|
||||
export type OAuthTokenAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
token: Token;
|
||||
};
|
||||
export type InstallationTokenAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "installation";
|
||||
token: Token;
|
||||
};
|
||||
export type AppAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "app";
|
||||
token: Token;
|
||||
};
|
||||
export type UserToServerAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "user-to-server";
|
||||
token: Token;
|
||||
};
|
||||
export type Authentication = OAuthTokenAuthentication | InstallationTokenAuthentication | AppAuthentication | UserToServerAuthentication;
|
||||
6
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
generated
vendored
Normal file
6
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
export declare function withAuthorizationPrefix(token: string): string;
|
||||
51
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/package.json
generated
vendored
Normal file
51
node_modules/@octokit/oauth-app/node_modules/@octokit/auth-token/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "@octokit/auth-token",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "5.1.2",
|
||||
"description": "GitHub API token authentication for browsers and Node.js",
|
||||
"repository": "github:octokit/auth-token.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@octokit/request": "^9.0.0",
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@octokit/types": "^13.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"esbuild": "^0.24.0",
|
||||
"fetch-mock": "^11.0.0",
|
||||
"glob": "^11.0.0",
|
||||
"prettier": "3.4.2",
|
||||
"semantic-release": "^24.0.0",
|
||||
"typescript": "^5.3.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./dist-types/index.d.ts"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
21
node_modules/@octokit/oauth-app/node_modules/@octokit/core/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/oauth-app/node_modules/@octokit/core/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.
|
||||
457
node_modules/@octokit/oauth-app/node_modules/@octokit/core/README.md
generated
vendored
Normal file
457
node_modules/@octokit/oauth-app/node_modules/@octokit/core/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,457 @@
|
|||
# core.js
|
||||
|
||||
> Extendable client for GitHub's REST & GraphQL APIs
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/core)
|
||||
[](https://github.com/octokit/core.js/actions?query=workflow%3ATest+branch%3Amain)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [REST API example](#rest-api-example)
|
||||
- [GraphQL example](#graphql-example)
|
||||
- [Options](#options)
|
||||
- [Defaults](#defaults)
|
||||
- [Authentication](#authentication)
|
||||
- [Logging](#logging)
|
||||
- [Hooks](#hooks)
|
||||
- [Plugins](#plugins)
|
||||
- [Build your own Octokit with Plugins and Defaults](#build-your-own-octokit-with-plugins-and-defaults)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
If you need a minimalistic library to utilize GitHub's [REST API](https://developer.github.com/v3/) and [GraphQL API](https://developer.github.com/v4/) which you can extend with plugins as needed, then `@octokit/core` is a great starting point.
|
||||
|
||||
If you don't need the Plugin API then using [`@octokit/request`](https://github.com/octokit/request.js/) or [`@octokit/graphql`](https://github.com/octokit/graphql.js/) directly is a good alternative.
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/core</code> directly from <a href="https://esm.sh">esm.sh</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { Octokit } from "https://esm.sh/@octokit/core";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/core</code>
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json`. See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
|
||||
|
||||
### REST API example
|
||||
|
||||
```js
|
||||
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
|
||||
const octokit = new Octokit({ auth: `personal-access-token123` });
|
||||
|
||||
const response = await octokit.request("GET /orgs/{org}/repos", {
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
See [`@octokit/request`](https://github.com/octokit/request.js) for full documentation of the `.request` method.
|
||||
|
||||
### GraphQL example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({ auth: `secret123` });
|
||||
|
||||
const response = await octokit.graphql(
|
||||
`query ($login: String!) {
|
||||
organization(login: $login) {
|
||||
repositories(privacy: PRIVATE) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
{ login: "octokit" },
|
||||
);
|
||||
```
|
||||
|
||||
See [`@octokit/graphql`](https://github.com/octokit/graphql.js) for full documentation of the `.graphql` method.
|
||||
|
||||
## Options
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
name
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.authStrategy</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Function<code>
|
||||
</td>
|
||||
<td>
|
||||
Defaults to <a href="https://github.com/octokit/auth-token.js#readme"><code>@octokit/auth-token</code></a>. See <a href="#authentication">Authentication</a> below for examples.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.auth</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code> or <code>Object</code>
|
||||
</td>
|
||||
<td>
|
||||
See <a href="#authentication">Authentication</a> below for examples.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
baseUrl: "https://github.acme-inc.com/api/v3",
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Array of Strings</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Some REST API endpoints require preview headers to be set, or enable
|
||||
additional features. Preview headers can be set on a per-request basis, e.g.
|
||||
|
||||
```js
|
||||
octokit.request("POST /repos/{owner}/{repo}/pulls", {
|
||||
mediaType: {
|
||||
previews: ["shadow-cat"],
|
||||
},
|
||||
owner,
|
||||
repo,
|
||||
title: "My pull request",
|
||||
base: "main",
|
||||
head: "my-feature",
|
||||
draft: true,
|
||||
});
|
||||
```
|
||||
|
||||
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
previews: ["shadow-cat"],
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.request</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Object</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Set a default request timeout (`options.request.timeout`) or an [`http(s).Agent`](https://nodejs.org/api/http.html#http_class_http_agent) e.g. for proxy usage (Node only, `options.request.agent`).
|
||||
|
||||
There are more `options.request.*` options, see [`@octokit/request` options](https://github.com/octokit/request.js#request). `options.request` can also be set on a per-request basis.
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.timeZone</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Sets the `Time-Zone` header which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
timeZone: "America/Los_Angeles",
|
||||
});
|
||||
```
|
||||
|
||||
The time zone header will determine the timezone used for generating the timestamp when creating commits. See [GitHub's Timezones documentation](https://developer.github.com/v3/#timezones).
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.userAgent</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
A custom user agent string for your app or library. Example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
userAgent: "my-app/v1.2.3",
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Defaults
|
||||
|
||||
You can create a new Octokit class with customized default options.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults({
|
||||
auth: "personal-access-token123",
|
||||
baseUrl: "https://github.acme-inc.com/api/v3",
|
||||
userAgent: "my-app/v1.2.3",
|
||||
});
|
||||
const octokit1 = new MyOctokit();
|
||||
const octokit2 = new MyOctokit();
|
||||
```
|
||||
|
||||
If you pass additional options to your new constructor, the options will be merged shallowly.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults({
|
||||
foo: {
|
||||
opt1: 1,
|
||||
},
|
||||
});
|
||||
const octokit = new MyOctokit({
|
||||
foo: {
|
||||
opt2: 1,
|
||||
},
|
||||
});
|
||||
// options will be { foo: { opt2: 1 }}
|
||||
```
|
||||
|
||||
If you need a deep or conditional merge, you can pass a function instead.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults((options) => {
|
||||
return {
|
||||
foo: Object.assign({}, options.foo, { opt1: 1 }),
|
||||
};
|
||||
});
|
||||
const octokit = new MyOctokit({
|
||||
foo: { opt2: 1 },
|
||||
});
|
||||
// options will be { foo: { opt1: 1, opt2: 1 }}
|
||||
```
|
||||
|
||||
Be careful about mutating the `options` object in the `Octokit.defaults` callback, as it can have unforeseen consequences.
|
||||
|
||||
## Authentication
|
||||
|
||||
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://developer.github.com/v3/#rate-limiting).
|
||||
|
||||
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). Pass in a token using `options.auth`. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The `Authorization` header will be set according to the type of token.
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: "mypersonalaccesstoken123",
|
||||
});
|
||||
|
||||
const { data } = await octokit.request("/user");
|
||||
```
|
||||
|
||||
To use a different authentication strategy, set `options.authStrategy`. A list of authentication strategies is available at [octokit/authentication-strategies.js](https://github.com/octokit/authentication-strategies.js/#readme).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
|
||||
const appOctokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
auth: {
|
||||
appId: 123,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
const { data } = await appOctokit.request("/app");
|
||||
```
|
||||
|
||||
The `.auth()` method returned by the current authentication strategy can be accessed at `octokit.auth()`. Example
|
||||
|
||||
```js
|
||||
const { token } = await appOctokit.auth({
|
||||
type: "installation",
|
||||
installationId: 123,
|
||||
});
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
||||
There are four built-in log methods
|
||||
|
||||
1. `octokit.log.debug(message[, additionalInfo])`
|
||||
1. `octokit.log.info(message[, additionalInfo])`
|
||||
1. `octokit.log.warn(message[, additionalInfo])`
|
||||
1. `octokit.log.error(message[, additionalInfo])`
|
||||
|
||||
They can be configured using the [`log` client option](client-options). By default, `octokit.log.debug()` and `octokit.log.info()` are no-ops, while the other two call `console.warn()` and `console.error()` respectively.
|
||||
|
||||
This is useful if you build reusable [plugins](#plugins).
|
||||
|
||||
If you would like to make the log level configurable using an environment variable or external option, we recommend the [console-log-level](https://github.com/watson/console-log-level) package. Example
|
||||
|
||||
```js
|
||||
import consoleLogLevel from "console-log-level";
|
||||
const octokit = new Octokit({
|
||||
log: consoleLogLevel({ level: "info" }),
|
||||
});
|
||||
```
|
||||
|
||||
## Hooks
|
||||
|
||||
You can customize Octokit's request lifecycle with hooks.
|
||||
|
||||
```js
|
||||
octokit.hook.before("request", async (options) => {
|
||||
validate(options);
|
||||
});
|
||||
octokit.hook.after("request", async (response, options) => {
|
||||
console.log(`${options.method} ${options.url}: ${response.status}`);
|
||||
});
|
||||
octokit.hook.error("request", async (error, options) => {
|
||||
if (error.status === 304) {
|
||||
return findInCache(error.response.headers.etag);
|
||||
}
|
||||
|
||||
throw error;
|
||||
});
|
||||
octokit.hook.wrap("request", async (request, options) => {
|
||||
// add logic before, after, catch errors or replace the request altogether
|
||||
return request(options);
|
||||
});
|
||||
```
|
||||
|
||||
See [before-after-hook](https://github.com/gr2m/before-after-hook#readme) for more documentation on hooks.
|
||||
|
||||
## Plugins
|
||||
|
||||
Octokit’s functionality can be extended using plugins. The `Octokit.plugin()` method accepts a plugin (or many) and returns a new constructor.
|
||||
|
||||
A plugin is a function which gets two arguments:
|
||||
|
||||
1. the current instance
|
||||
2. the options passed to the constructor.
|
||||
|
||||
In order to extend `octokit`'s API, the plugin must return an object with the new methods. Please refrain from adding methods directly to the `octokit` instance, especialy if you depend on keys that do not exist in `@octokit/core`, such as `octokit.rest`.
|
||||
|
||||
```js
|
||||
// index.js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import myPlugin from "./lib/my-plugin.js";
|
||||
import octokitPluginExample from "octokit-plugin-example";
|
||||
const MyOctokit = Octokit.plugin(
|
||||
myPlugin,
|
||||
octokitPluginExample
|
||||
);
|
||||
|
||||
const octokit = new MyOctokit({ greeting: "Moin moin" });
|
||||
octokit.helloWorld(); // logs "Moin moin, world!"
|
||||
octokit.request("GET /"); // logs "GET / - 200 in 123ms"
|
||||
|
||||
// lib/my-plugin.js
|
||||
const plugin = (octokit, options = { greeting: "Hello" }) => {
|
||||
// hook into the request lifecycle
|
||||
octokit.hook.wrap("request", async (request, options) => {
|
||||
const time = Date.now();
|
||||
const response = await request(options);
|
||||
console.log(
|
||||
`${options.method} ${options.url} – ${response.status} in ${Date.now() -
|
||||
time}ms`
|
||||
);
|
||||
return response;
|
||||
});
|
||||
|
||||
// add a custom method
|
||||
return {
|
||||
helloWorld: () => console.log(`${options.greeting}, world!`);
|
||||
}
|
||||
};
|
||||
export default plugin;
|
||||
```
|
||||
|
||||
## Build your own Octokit with Plugins and Defaults
|
||||
|
||||
You can build your own Octokit class with preset default options and plugins. In fact, this is mostly how the `@octokit/<context>` modules work, such as [`@octokit/action`](https://github.com/octokit/action.js):
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { throttling } from "@octokit/plugin-throttling";
|
||||
import { retry } from "@octokit/plugin-retry";
|
||||
import { createActionAuth } from "@octokit/auth-action";
|
||||
const MyActionOctokit = Octokit.plugin(
|
||||
paginateRest,
|
||||
throttling,
|
||||
retry,
|
||||
).defaults({
|
||||
throttle: {
|
||||
onAbuseLimit: (retryAfter, options) => {
|
||||
/* ... */
|
||||
},
|
||||
onRateLimit: (retryAfter, options) => {
|
||||
/* ... */
|
||||
},
|
||||
},
|
||||
authStrategy: createActionAuth,
|
||||
userAgent: `my-octokit-action/v1.2.3`,
|
||||
});
|
||||
|
||||
const octokit = new MyActionOctokit();
|
||||
const installations = await octokit.paginate("GET /app/installations");
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
134
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-src/index.js
generated
vendored
Normal file
134
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
import { getUserAgent } from "universal-user-agent";
|
||||
import Hook from "before-after-hook";
|
||||
import { request } from "@octokit/request";
|
||||
import { withCustomRequest } from "@octokit/graphql";
|
||||
import { createTokenAuth } from "@octokit/auth-token";
|
||||
import { VERSION } from "./version.js";
|
||||
const noop = () => {
|
||||
};
|
||||
const consoleWarn = console.warn.bind(console);
|
||||
const consoleError = console.error.bind(console);
|
||||
const userAgentTrail = `octokit-core.js/${VERSION} ${getUserAgent()}`;
|
||||
class Octokit {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const OctokitWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
const options = args[0] || {};
|
||||
if (typeof defaults === "function") {
|
||||
super(defaults(options));
|
||||
return;
|
||||
}
|
||||
super(
|
||||
Object.assign(
|
||||
{},
|
||||
defaults,
|
||||
options,
|
||||
options.userAgent && defaults.userAgent ? {
|
||||
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
||||
} : null
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
return OctokitWithDefaults;
|
||||
}
|
||||
static plugins = [];
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
static plugin(...newPlugins) {
|
||||
const currentPlugins = this.plugins;
|
||||
const NewOctokit = class extends this {
|
||||
static plugins = currentPlugins.concat(
|
||||
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
||||
);
|
||||
};
|
||||
return NewOctokit;
|
||||
}
|
||||
constructor(options = {}) {
|
||||
const hook = new Hook.Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
// @ts-ignore internal usage only, no need to type
|
||||
hook: hook.bind(null, "request")
|
||||
}),
|
||||
mediaType: {
|
||||
previews: [],
|
||||
format: ""
|
||||
}
|
||||
};
|
||||
requestDefaults.headers["user-agent"] = options.userAgent ? `${options.userAgent} ${userAgentTrail}` : userAgentTrail;
|
||||
if (options.baseUrl) {
|
||||
requestDefaults.baseUrl = options.baseUrl;
|
||||
}
|
||||
if (options.previews) {
|
||||
requestDefaults.mediaType.previews = options.previews;
|
||||
}
|
||||
if (options.timeZone) {
|
||||
requestDefaults.headers["time-zone"] = options.timeZone;
|
||||
}
|
||||
this.request = request.defaults(requestDefaults);
|
||||
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
||||
this.log = Object.assign(
|
||||
{
|
||||
debug: noop,
|
||||
info: noop,
|
||||
warn: consoleWarn,
|
||||
error: consoleError
|
||||
},
|
||||
options.log
|
||||
);
|
||||
this.hook = hook;
|
||||
if (!options.authStrategy) {
|
||||
if (!options.auth) {
|
||||
this.auth = async () => ({
|
||||
type: "unauthenticated"
|
||||
});
|
||||
} else {
|
||||
const auth = createTokenAuth(options.auth);
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
} else {
|
||||
const { authStrategy, ...otherOptions } = options;
|
||||
const auth = authStrategy(
|
||||
Object.assign(
|
||||
{
|
||||
request: this.request,
|
||||
log: this.log,
|
||||
// we pass the current octokit instance as well as its constructor options
|
||||
// to allow for authentication strategies that return a new octokit instance
|
||||
// that shares the same internal state as the current one. The original
|
||||
// requirement for this was the "event-octokit" authentication strategy
|
||||
// of https://github.com/probot/octokit-auth-probot.
|
||||
octokit: this,
|
||||
octokitOptions: otherOptions
|
||||
},
|
||||
options.auth
|
||||
)
|
||||
);
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
const classConstructor = this.constructor;
|
||||
for (let i = 0; i < classConstructor.plugins.length; ++i) {
|
||||
Object.assign(this, classConstructor.plugins[i](this, options));
|
||||
}
|
||||
}
|
||||
// assigned during constructor
|
||||
request;
|
||||
graphql;
|
||||
log;
|
||||
hook;
|
||||
// TODO: type `octokit.auth` based on passed options.authStrategy
|
||||
auth;
|
||||
}
|
||||
export {
|
||||
Octokit
|
||||
};
|
||||
4
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-src/version.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
const VERSION = "6.1.4";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
31
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/index.d.ts
generated
vendored
Normal file
31
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { HookCollection } from "before-after-hook";
|
||||
import { request } from "@octokit/request";
|
||||
import { type graphql } from "@octokit/graphql";
|
||||
import type { Constructor, Hooks, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types.js";
|
||||
export type { OctokitOptions } from "./types.js";
|
||||
export declare class Octokit {
|
||||
static VERSION: string;
|
||||
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions | Function): S;
|
||||
static plugins: OctokitPlugin[];
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
static plugin<S extends Constructor<any> & {
|
||||
plugins: any[];
|
||||
}, T extends OctokitPlugin[]>(this: S, ...newPlugins: T): S & Constructor<UnionToIntersection<ReturnTypeOf<T>>>;
|
||||
constructor(options?: OctokitOptions);
|
||||
request: typeof request;
|
||||
graphql: typeof graphql;
|
||||
log: {
|
||||
debug: (message: string, additionalInfo?: object) => any;
|
||||
info: (message: string, additionalInfo?: object) => any;
|
||||
warn: (message: string, additionalInfo?: object) => any;
|
||||
error: (message: string, additionalInfo?: object) => any;
|
||||
[key: string]: any;
|
||||
};
|
||||
hook: HookCollection<Hooks>;
|
||||
auth: (...args: unknown[]) => Promise<unknown>;
|
||||
}
|
||||
44
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/types.d.ts
generated
vendored
Normal file
44
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import type * as OctokitTypes from "@octokit/types";
|
||||
import type { RequestError } from "@octokit/request-error";
|
||||
import type { Octokit } from "./index.js";
|
||||
export type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export interface OctokitOptions {
|
||||
authStrategy?: any;
|
||||
auth?: any;
|
||||
userAgent?: string;
|
||||
previews?: string[];
|
||||
baseUrl?: string;
|
||||
log?: {
|
||||
debug: (message: string) => unknown;
|
||||
info: (message: string) => unknown;
|
||||
warn: (message: string) => unknown;
|
||||
error: (message: string) => unknown;
|
||||
};
|
||||
request?: OctokitTypes.RequestRequestOptions;
|
||||
timeZone?: string;
|
||||
[option: string]: any;
|
||||
}
|
||||
export type Constructor<T> = new (...args: any[]) => T;
|
||||
export type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction ? ReturnType<T> : T extends AnyFunction[] ? UnionToIntersection<Exclude<ReturnType<T[number]>, void>> : never;
|
||||
/**
|
||||
* @author https://stackoverflow.com/users/2887218/jcalz
|
||||
* @see https://stackoverflow.com/a/50375286/10325032
|
||||
*/
|
||||
export type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
|
||||
type AnyFunction = (...args: any) => any;
|
||||
export type OctokitPlugin = (octokit: Octokit, options: OctokitOptions) => {
|
||||
[key: string]: any;
|
||||
} | void;
|
||||
export type Hooks = {
|
||||
request: {
|
||||
Options: Required<OctokitTypes.EndpointDefaults>;
|
||||
Result: OctokitTypes.OctokitResponse<any>;
|
||||
Error: RequestError | Error;
|
||||
};
|
||||
[key: string]: {
|
||||
Options: unknown;
|
||||
Result: unknown;
|
||||
Error: unknown;
|
||||
};
|
||||
};
|
||||
export {};
|
||||
1
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/oauth-app/node_modules/@octokit/core/dist-types/version.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const VERSION = "6.1.4";
|
||||
69
node_modules/@octokit/oauth-app/node_modules/@octokit/core/package.json
generated
vendored
Normal file
69
node_modules/@octokit/oauth-app/node_modules/@octokit/core/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "@octokit/core",
|
||||
"version": "6.1.4",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"description": "Extendable client for GitHub's REST & GraphQL APIs",
|
||||
"repository": "github:octokit/core.js",
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^5.0.0",
|
||||
"@octokit/graphql": "^8.1.2",
|
||||
"@octokit/request": "^9.2.1",
|
||||
"@octokit/request-error": "^6.1.7",
|
||||
"@octokit/types": "^13.6.2",
|
||||
"before-after-hook": "^3.0.2",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/auth-action": "^5.0.0",
|
||||
"@octokit/auth-app": "^7.0.0",
|
||||
"@octokit/auth-oauth-app": "^8.0.0",
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@sinonjs/fake-timers": "^14.0.0",
|
||||
"@types/lolex": "^5.1.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/sinonjs__fake-timers": "^8.1.5",
|
||||
"@vitest/coverage-v8": "^3.0.5",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^12.0.0",
|
||||
"glob": "^11.0.0",
|
||||
"prettier": "3.4.2",
|
||||
"proxy": "^2.0.0",
|
||||
"semantic-release": "^24.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"undici": "^6.0.0",
|
||||
"vitest": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-src/index.js",
|
||||
"default": "./dist-src/index.js"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./dist-types/types.d.ts"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
21
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/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.
|
||||
412
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/README.md
generated
vendored
Normal file
412
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
# endpoint.js
|
||||
|
||||
> Turns GitHub REST API endpoints into generic request options
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/endpoint)
|
||||
[](https://github.com/octokit/endpoint.js/actions/workflows/test.yml?query=branch%3Amain)
|
||||
|
||||
`@octokit/endpoint` combines [GitHub REST API routes](https://developer.github.com/v3/) with your parameters and turns them into generic request options that can be used in any request library.
|
||||
|
||||
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [API](#api)
|
||||
- [`endpoint(route, options)` or `endpoint(options)`](#endpointroute-options-or-endpointoptions)
|
||||
- [`endpoint.defaults()`](#endpointdefaults)
|
||||
- [`endpoint.DEFAULTS`](#endpointdefaults)
|
||||
- [`endpoint.merge(route, options)` or `endpoint.merge(options)`](#endpointmergeroute-options-or-endpointmergeoptions)
|
||||
- [`endpoint.parse()`](#endpointparse)
|
||||
- [Special cases](#special-cases)
|
||||
- [The `data` parameter – set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
|
||||
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/endpoint</code> directly from <a href="https://esm.sh">esm.sh</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { endpoint } from "https://esm.sh/@octokit/endpoint";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/endpoint</code>
|
||||
|
||||
```js
|
||||
import { endpoint } from "@octokit/endpoint";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Example for [List organization repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
||||
|
||||
```js
|
||||
const requestOptions = endpoint("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
The resulting `requestOptions` looks as follows
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "GET",
|
||||
"url": "https://api.github.com/orgs/octokit/repos?type=private",
|
||||
"headers": {
|
||||
"accept": "application/vnd.github.v3+json",
|
||||
"authorization": "token 0000000000000000000000000000000000000001",
|
||||
"user-agent": "octokit/endpoint.js v1.2.3"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can pass `requestOptions` to common request libraries
|
||||
|
||||
```js
|
||||
const { url, ...options } = requestOptions;
|
||||
// using with fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
fetch(url, options);
|
||||
// using with request (https://github.com/request/request)
|
||||
request(requestOptions);
|
||||
// using with got (https://github.com/sindresorhus/got)
|
||||
got[options.method](url, options);
|
||||
// using with axios
|
||||
axios(requestOptions);
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json`. See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
|
||||
|
||||
## API
|
||||
|
||||
### `endpoint(route, options)` or `endpoint(options)`
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
name
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>route</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
If set, it has to be a string consisting of URL and the request method, e.g., <code>GET /orgs/{org}</code>. If it’s set to a URL, only the method defaults to <code>GET</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.method</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required unless <code>route</code> is set.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>. <em>Defaults to <code>GET</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.url</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required unless <code>route</code> is set.</strong> A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
||||
e.g., <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<em>Defaults to <code>https://api.github.com</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.headers</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Custom headers. Passed headers are merged with defaults:<br>
|
||||
<em><code>headers['user-agent']</code> defaults to <code>octokit-endpoint.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
||||
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code></em>.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.mediaType.format</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Media type param, such as <code>raw</code>, <code>diff</code>, or <code>text+json</code>. See <a href="https://developer.github.com/v3/media/">Media Types</a>. Setting <code>options.mediaType.format</code> will amend the <code>headers.accept</code> value.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.data</code>
|
||||
</th>
|
||||
<td>
|
||||
Any
|
||||
</td>
|
||||
<td>
|
||||
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The <code>data</code> parameter"</a> below.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.request</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Pass custom meta information for the request. The <code>request</code> object will be returned as is.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
All other options will be passed depending on the `method` and `url` options.
|
||||
|
||||
1. If the option key has a placeholder in the `url`, it will be used as the replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`.
|
||||
2. If the `method` is `GET` or `HEAD`, the option is passed as a query parameter.
|
||||
3. Otherwise, the parameter is passed in the request body as a JSON key.
|
||||
|
||||
**Result**
|
||||
|
||||
`endpoint()` is a synchronous method and returns an object with the following keys:
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
key
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th><code>method</code></th>
|
||||
<td>String</td>
|
||||
<td>The http method. Always lowercase.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>url</code></th>
|
||||
<td>String</td>
|
||||
<td>The url with placeholders replaced with passed parameters.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>headers</code></th>
|
||||
<td>Object</td>
|
||||
<td>All header names are lowercased.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>body</code></th>
|
||||
<td>Any</td>
|
||||
<td>The request body if one is present. Only for <code>PATCH</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code> requests.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>request</code></th>
|
||||
<td>Object</td>
|
||||
<td>Request meta option, it will be returned as it was passed into <code>endpoint()</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### `endpoint.defaults()`
|
||||
|
||||
Override or set default options. Example:
|
||||
|
||||
```js
|
||||
const request = require("request");
|
||||
const myEndpoint = require("@octokit/endpoint").defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-project",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
request(myEndpoint(`GET /orgs/{org}/repos`));
|
||||
```
|
||||
|
||||
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
||||
|
||||
```js
|
||||
const myProjectEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
const myProjectEndpointWithAuth = myProjectEndpoint.defaults({
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`myProjectEndpointWithAuth` now defaults the `baseUrl`, `headers['user-agent']`,
|
||||
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
||||
by the global default.
|
||||
|
||||
### `endpoint.DEFAULTS`
|
||||
|
||||
The current default options.
|
||||
|
||||
```js
|
||||
endpoint.DEFAULTS.baseUrl; // https://api.github.com
|
||||
const myEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
});
|
||||
myEndpoint.DEFAULTS.baseUrl; // https://github-enterprise.acme-inc.com/api/v3
|
||||
```
|
||||
|
||||
### `endpoint.merge(route, options)` or `endpoint.merge(options)`
|
||||
|
||||
Get the defaulted endpoint options, but without parsing them into request options:
|
||||
|
||||
```js
|
||||
const myProjectEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
myProjectEndpoint.merge("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-secret-project",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// {
|
||||
// baseUrl: 'https://github-enterprise.acme-inc.com/api/v3',
|
||||
// method: 'GET',
|
||||
// url: '/orgs/{org}/repos',
|
||||
// headers: {
|
||||
// accept: 'application/vnd.github.v3+json',
|
||||
// authorization: `token 0000000000000000000000000000000000000001`,
|
||||
// 'user-agent': 'myApp/1.2.3'
|
||||
// },
|
||||
// org: 'my-secret-project',
|
||||
// type: 'private'
|
||||
// }
|
||||
```
|
||||
|
||||
### `endpoint.parse()`
|
||||
|
||||
Stateless method to turn endpoint options into request options. Calling
|
||||
`endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
|
||||
|
||||
## Special cases
|
||||
|
||||
<a name="data-parameter"></a>
|
||||
|
||||
### The `data` parameter – set request body directly
|
||||
|
||||
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead, the request body needs to be set directly. In these cases, set the `data` parameter.
|
||||
|
||||
```js
|
||||
const options = endpoint("POST /markdown/raw", {
|
||||
data: "Hello world github/linguist#1 **cool**, and #1!",
|
||||
headers: {
|
||||
accept: "text/html;charset=utf-8",
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
// options is
|
||||
// {
|
||||
// method: 'post',
|
||||
// url: 'https://api.github.com/markdown/raw',
|
||||
// headers: {
|
||||
// accept: 'text/html;charset=utf-8',
|
||||
// 'content-type': 'text/plain',
|
||||
// 'user-agent': userAgent
|
||||
// },
|
||||
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
||||
// }
|
||||
```
|
||||
|
||||
### Set parameters for both the URL/query and the request body
|
||||
|
||||
There are API endpoints that accept both query parameters as well as a body. In that case, you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
endpoint(
|
||||
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
||||
{
|
||||
name: "example.zip",
|
||||
label: "short description",
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
"content-length": 14,
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
data: "Hello, world!",
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
346
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-bundle/index.js
generated
vendored
Normal file
346
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-bundle/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
// pkg/dist-src/defaults.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "0.0.0-development";
|
||||
|
||||
// pkg/dist-src/defaults.js
|
||||
var userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
||||
var DEFAULTS = {
|
||||
method: "GET",
|
||||
baseUrl: "https://api.github.com",
|
||||
headers: {
|
||||
accept: "application/vnd.github.v3+json",
|
||||
"user-agent": userAgent
|
||||
},
|
||||
mediaType: {
|
||||
format: ""
|
||||
}
|
||||
};
|
||||
|
||||
// pkg/dist-src/util/lowercase-keys.js
|
||||
function lowercaseKeys(object) {
|
||||
if (!object) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(object).reduce((newObj, key) => {
|
||||
newObj[key.toLowerCase()] = object[key];
|
||||
return newObj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/is-plain-object.js
|
||||
function isPlainObject(value) {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
||||
const proto = Object.getPrototypeOf(value);
|
||||
if (proto === null) return true;
|
||||
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
||||
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/merge-deep.js
|
||||
function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach((key) => {
|
||||
if (isPlainObject(options[key])) {
|
||||
if (!(key in defaults)) Object.assign(result, { [key]: options[key] });
|
||||
else result[key] = mergeDeep(defaults[key], options[key]);
|
||||
} else {
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/remove-undefined-properties.js
|
||||
function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === void 0) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// pkg/dist-src/merge.js
|
||||
function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
options = Object.assign(url ? { method, url } : { url: method }, options);
|
||||
} else {
|
||||
options = Object.assign({}, route);
|
||||
}
|
||||
options.headers = lowercaseKeys(options.headers);
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options);
|
||||
if (options.url === "/graphql") {
|
||||
if (defaults && defaults.mediaType.previews?.length) {
|
||||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(
|
||||
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
||||
).concat(mergedOptions.mediaType.previews);
|
||||
}
|
||||
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
||||
}
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/add-query-parameters.js
|
||||
function addQueryParameters(url, parameters) {
|
||||
const separator = /\?/.test(url) ? "&" : "?";
|
||||
const names = Object.keys(parameters);
|
||||
if (names.length === 0) {
|
||||
return url;
|
||||
}
|
||||
return url + separator + names.map((name) => {
|
||||
if (name === "q") {
|
||||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
||||
}
|
||||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||
}).join("&");
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/extract-url-variable-names.js
|
||||
var urlVariableRegex = /\{[^{}}]+\}/g;
|
||||
function removeNonChars(variableName) {
|
||||
return variableName.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g, "").split(/,/);
|
||||
}
|
||||
function extractUrlVariableNames(url) {
|
||||
const matches = url.match(urlVariableRegex);
|
||||
if (!matches) {
|
||||
return [];
|
||||
}
|
||||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/omit.js
|
||||
function omit(object, keysToOmit) {
|
||||
const result = { __proto__: null };
|
||||
for (const key of Object.keys(object)) {
|
||||
if (keysToOmit.indexOf(key) === -1) {
|
||||
result[key] = object[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// pkg/dist-src/util/url-template.js
|
||||
function encodeReserved(str) {
|
||||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
||||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||||
}
|
||||
return part;
|
||||
}).join("");
|
||||
}
|
||||
function encodeUnreserved(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
function encodeValue(operator, value, key) {
|
||||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
||||
if (key) {
|
||||
return encodeUnreserved(key) + "=" + value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
function isDefined(value) {
|
||||
return value !== void 0 && value !== null;
|
||||
}
|
||||
function isKeyOperator(operator) {
|
||||
return operator === ";" || operator === "&" || operator === "?";
|
||||
}
|
||||
function getValues(context, operator, key, modifier) {
|
||||
var value = context[key], result = [];
|
||||
if (isDefined(value) && value !== "") {
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
value = value.toString();
|
||||
if (modifier && modifier !== "*") {
|
||||
value = value.substring(0, parseInt(modifier, 10));
|
||||
}
|
||||
result.push(
|
||||
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
||||
);
|
||||
} else {
|
||||
if (modifier === "*") {
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function(value2) {
|
||||
result.push(
|
||||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
||||
);
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function(k) {
|
||||
if (isDefined(value[k])) {
|
||||
result.push(encodeValue(operator, value[k], k));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const tmp = [];
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function(value2) {
|
||||
tmp.push(encodeValue(operator, value2));
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function(k) {
|
||||
if (isDefined(value[k])) {
|
||||
tmp.push(encodeUnreserved(k));
|
||||
tmp.push(encodeValue(operator, value[k].toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isKeyOperator(operator)) {
|
||||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||||
} else if (tmp.length !== 0) {
|
||||
result.push(tmp.join(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (operator === ";") {
|
||||
if (isDefined(value)) {
|
||||
result.push(encodeUnreserved(key));
|
||||
}
|
||||
} else if (value === "" && (operator === "&" || operator === "?")) {
|
||||
result.push(encodeUnreserved(key) + "=");
|
||||
} else if (value === "") {
|
||||
result.push("");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function parseUrl(template) {
|
||||
return {
|
||||
expand: expand.bind(null, template)
|
||||
};
|
||||
}
|
||||
function expand(template, context) {
|
||||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||||
template = template.replace(
|
||||
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
||||
function(_, expression, literal) {
|
||||
if (expression) {
|
||||
let operator = "";
|
||||
const values = [];
|
||||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||||
operator = expression.charAt(0);
|
||||
expression = expression.substr(1);
|
||||
}
|
||||
expression.split(/,/g).forEach(function(variable) {
|
||||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||||
});
|
||||
if (operator && operator !== "+") {
|
||||
var separator = ",";
|
||||
if (operator === "?") {
|
||||
separator = "&";
|
||||
} else if (operator !== "#") {
|
||||
separator = operator;
|
||||
}
|
||||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||||
} else {
|
||||
return values.join(",");
|
||||
}
|
||||
} else {
|
||||
return encodeReserved(literal);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (template === "/") {
|
||||
return template;
|
||||
} else {
|
||||
return template.replace(/\/$/, "");
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/parse.js
|
||||
function parse(options) {
|
||||
let method = options.method.toUpperCase();
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"mediaType"
|
||||
]);
|
||||
const urlVariableNames = extractUrlVariableNames(url);
|
||||
url = parseUrl(url).expand(parameters);
|
||||
if (!/^http/.test(url)) {
|
||||
url = options.baseUrl + url;
|
||||
}
|
||||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
headers.accept = headers.accept.split(/,/).map(
|
||||
(format) => format.replace(
|
||||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
||||
`application/vnd$1$2.${options.mediaType.format}`
|
||||
)
|
||||
).join(",");
|
||||
}
|
||||
if (url.endsWith("/graphql")) {
|
||||
if (options.mediaType.previews?.length) {
|
||||
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g) || [];
|
||||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
||||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
||||
return `application/vnd.github.${preview}-preview${format}`;
|
||||
}).join(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (["GET", "HEAD"].includes(method)) {
|
||||
url = addQueryParameters(url, remainingParameters);
|
||||
} else {
|
||||
if ("data" in remainingParameters) {
|
||||
body = remainingParameters.data;
|
||||
} else {
|
||||
if (Object.keys(remainingParameters).length) {
|
||||
body = remainingParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||
headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||
body = "";
|
||||
}
|
||||
return Object.assign(
|
||||
{ method, url, headers },
|
||||
typeof body !== "undefined" ? { body } : null,
|
||||
options.request ? { request: options.request } : null
|
||||
);
|
||||
}
|
||||
|
||||
// pkg/dist-src/endpoint-with-defaults.js
|
||||
function endpointWithDefaults(defaults, route, options) {
|
||||
return parse(merge(defaults, route, options));
|
||||
}
|
||||
|
||||
// pkg/dist-src/with-defaults.js
|
||||
function withDefaults(oldDefaults, newDefaults) {
|
||||
const DEFAULTS2 = merge(oldDefaults, newDefaults);
|
||||
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
|
||||
return Object.assign(endpoint2, {
|
||||
DEFAULTS: DEFAULTS2,
|
||||
defaults: withDefaults.bind(null, DEFAULTS2),
|
||||
merge: merge.bind(null, DEFAULTS2),
|
||||
parse
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var endpoint = withDefaults(null, DEFAULTS);
|
||||
export {
|
||||
endpoint
|
||||
};
|
||||
7
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-bundle/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-bundle/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/defaults.js
generated
vendored
Normal file
17
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/defaults.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version.js";
|
||||
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
||||
const DEFAULTS = {
|
||||
method: "GET",
|
||||
baseUrl: "https://api.github.com",
|
||||
headers: {
|
||||
accept: "application/vnd.github.v3+json",
|
||||
"user-agent": userAgent
|
||||
},
|
||||
mediaType: {
|
||||
format: ""
|
||||
}
|
||||
};
|
||||
export {
|
||||
DEFAULTS
|
||||
};
|
||||
9
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
generated
vendored
Normal file
9
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { DEFAULTS } from "./defaults.js";
|
||||
import { merge } from "./merge.js";
|
||||
import { parse } from "./parse.js";
|
||||
function endpointWithDefaults(defaults, route, options) {
|
||||
return parse(merge(defaults, route, options));
|
||||
}
|
||||
export {
|
||||
endpointWithDefaults
|
||||
};
|
||||
6
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/index.js
generated
vendored
Normal file
6
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { withDefaults } from "./with-defaults.js";
|
||||
import { DEFAULTS } from "./defaults.js";
|
||||
const endpoint = withDefaults(null, DEFAULTS);
|
||||
export {
|
||||
endpoint
|
||||
};
|
||||
27
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/merge.js
generated
vendored
Normal file
27
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/merge.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { lowercaseKeys } from "./util/lowercase-keys.js";
|
||||
import { mergeDeep } from "./util/merge-deep.js";
|
||||
import { removeUndefinedProperties } from "./util/remove-undefined-properties.js";
|
||||
function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
options = Object.assign(url ? { method, url } : { url: method }, options);
|
||||
} else {
|
||||
options = Object.assign({}, route);
|
||||
}
|
||||
options.headers = lowercaseKeys(options.headers);
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options);
|
||||
if (options.url === "/graphql") {
|
||||
if (defaults && defaults.mediaType.previews?.length) {
|
||||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(
|
||||
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
||||
).concat(mergedOptions.mediaType.previews);
|
||||
}
|
||||
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
||||
}
|
||||
return mergedOptions;
|
||||
}
|
||||
export {
|
||||
merge
|
||||
};
|
||||
70
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/parse.js
generated
vendored
Normal file
70
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/parse.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { addQueryParameters } from "./util/add-query-parameters.js";
|
||||
import { extractUrlVariableNames } from "./util/extract-url-variable-names.js";
|
||||
import { omit } from "./util/omit.js";
|
||||
import { parseUrl } from "./util/url-template.js";
|
||||
function parse(options) {
|
||||
let method = options.method.toUpperCase();
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"mediaType"
|
||||
]);
|
||||
const urlVariableNames = extractUrlVariableNames(url);
|
||||
url = parseUrl(url).expand(parameters);
|
||||
if (!/^http/.test(url)) {
|
||||
url = options.baseUrl + url;
|
||||
}
|
||||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
headers.accept = headers.accept.split(/,/).map(
|
||||
(format) => format.replace(
|
||||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
||||
`application/vnd$1$2.${options.mediaType.format}`
|
||||
)
|
||||
).join(",");
|
||||
}
|
||||
if (url.endsWith("/graphql")) {
|
||||
if (options.mediaType.previews?.length) {
|
||||
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g) || [];
|
||||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
||||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
||||
return `application/vnd.github.${preview}-preview${format}`;
|
||||
}).join(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (["GET", "HEAD"].includes(method)) {
|
||||
url = addQueryParameters(url, remainingParameters);
|
||||
} else {
|
||||
if ("data" in remainingParameters) {
|
||||
body = remainingParameters.data;
|
||||
} else {
|
||||
if (Object.keys(remainingParameters).length) {
|
||||
body = remainingParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||
headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||
body = "";
|
||||
}
|
||||
return Object.assign(
|
||||
{ method, url, headers },
|
||||
typeof body !== "undefined" ? { body } : null,
|
||||
options.request ? { request: options.request } : null
|
||||
);
|
||||
}
|
||||
export {
|
||||
parse
|
||||
};
|
||||
16
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
generated
vendored
Normal file
16
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function addQueryParameters(url, parameters) {
|
||||
const separator = /\?/.test(url) ? "&" : "?";
|
||||
const names = Object.keys(parameters);
|
||||
if (names.length === 0) {
|
||||
return url;
|
||||
}
|
||||
return url + separator + names.map((name) => {
|
||||
if (name === "q") {
|
||||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
||||
}
|
||||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||
}).join("&");
|
||||
}
|
||||
export {
|
||||
addQueryParameters
|
||||
};
|
||||
14
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
generated
vendored
Normal file
14
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const urlVariableRegex = /\{[^{}}]+\}/g;
|
||||
function removeNonChars(variableName) {
|
||||
return variableName.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g, "").split(/,/);
|
||||
}
|
||||
function extractUrlVariableNames(url) {
|
||||
const matches = url.match(urlVariableRegex);
|
||||
if (!matches) {
|
||||
return [];
|
||||
}
|
||||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||||
}
|
||||
export {
|
||||
extractUrlVariableNames
|
||||
};
|
||||
11
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/is-plain-object.js
generated
vendored
Normal file
11
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/is-plain-object.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function isPlainObject(value) {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
||||
const proto = Object.getPrototypeOf(value);
|
||||
if (proto === null) return true;
|
||||
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
||||
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
||||
}
|
||||
export {
|
||||
isPlainObject
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function lowercaseKeys(object) {
|
||||
if (!object) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(object).reduce((newObj, key) => {
|
||||
newObj[key.toLowerCase()] = object[key];
|
||||
return newObj;
|
||||
}, {});
|
||||
}
|
||||
export {
|
||||
lowercaseKeys
|
||||
};
|
||||
16
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
generated
vendored
Normal file
16
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { isPlainObject } from "./is-plain-object.js";
|
||||
function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach((key) => {
|
||||
if (isPlainObject(options[key])) {
|
||||
if (!(key in defaults)) Object.assign(result, { [key]: options[key] });
|
||||
else result[key] = mergeDeep(defaults[key], options[key]);
|
||||
} else {
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
export {
|
||||
mergeDeep
|
||||
};
|
||||
12
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/omit.js
generated
vendored
Normal file
12
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/omit.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function omit(object, keysToOmit) {
|
||||
const result = { __proto__: null };
|
||||
for (const key of Object.keys(object)) {
|
||||
if (keysToOmit.indexOf(key) === -1) {
|
||||
result[key] = object[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export {
|
||||
omit
|
||||
};
|
||||
11
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js
generated
vendored
Normal file
11
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === void 0) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
export {
|
||||
removeUndefinedProperties
|
||||
};
|
||||
133
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/url-template.js
generated
vendored
Normal file
133
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/util/url-template.js
generated
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
function encodeReserved(str) {
|
||||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
||||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||||
}
|
||||
return part;
|
||||
}).join("");
|
||||
}
|
||||
function encodeUnreserved(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
function encodeValue(operator, value, key) {
|
||||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
||||
if (key) {
|
||||
return encodeUnreserved(key) + "=" + value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
function isDefined(value) {
|
||||
return value !== void 0 && value !== null;
|
||||
}
|
||||
function isKeyOperator(operator) {
|
||||
return operator === ";" || operator === "&" || operator === "?";
|
||||
}
|
||||
function getValues(context, operator, key, modifier) {
|
||||
var value = context[key], result = [];
|
||||
if (isDefined(value) && value !== "") {
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
value = value.toString();
|
||||
if (modifier && modifier !== "*") {
|
||||
value = value.substring(0, parseInt(modifier, 10));
|
||||
}
|
||||
result.push(
|
||||
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
||||
);
|
||||
} else {
|
||||
if (modifier === "*") {
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function(value2) {
|
||||
result.push(
|
||||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
||||
);
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function(k) {
|
||||
if (isDefined(value[k])) {
|
||||
result.push(encodeValue(operator, value[k], k));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const tmp = [];
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function(value2) {
|
||||
tmp.push(encodeValue(operator, value2));
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function(k) {
|
||||
if (isDefined(value[k])) {
|
||||
tmp.push(encodeUnreserved(k));
|
||||
tmp.push(encodeValue(operator, value[k].toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isKeyOperator(operator)) {
|
||||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||||
} else if (tmp.length !== 0) {
|
||||
result.push(tmp.join(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (operator === ";") {
|
||||
if (isDefined(value)) {
|
||||
result.push(encodeUnreserved(key));
|
||||
}
|
||||
} else if (value === "" && (operator === "&" || operator === "?")) {
|
||||
result.push(encodeUnreserved(key) + "=");
|
||||
} else if (value === "") {
|
||||
result.push("");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function parseUrl(template) {
|
||||
return {
|
||||
expand: expand.bind(null, template)
|
||||
};
|
||||
}
|
||||
function expand(template, context) {
|
||||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||||
template = template.replace(
|
||||
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
||||
function(_, expression, literal) {
|
||||
if (expression) {
|
||||
let operator = "";
|
||||
const values = [];
|
||||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||||
operator = expression.charAt(0);
|
||||
expression = expression.substr(1);
|
||||
}
|
||||
expression.split(/,/g).forEach(function(variable) {
|
||||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||||
});
|
||||
if (operator && operator !== "+") {
|
||||
var separator = ",";
|
||||
if (operator === "?") {
|
||||
separator = "&";
|
||||
} else if (operator !== "#") {
|
||||
separator = operator;
|
||||
}
|
||||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||||
} else {
|
||||
return values.join(",");
|
||||
}
|
||||
} else {
|
||||
return encodeReserved(literal);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (template === "/") {
|
||||
return template;
|
||||
} else {
|
||||
return template.replace(/\/$/, "");
|
||||
}
|
||||
}
|
||||
export {
|
||||
parseUrl
|
||||
};
|
||||
4
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/oauth-app/node_modules/@octokit/endpoint/dist-src/version.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
const VERSION = "10.1.3";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue