First upload version 0.0.1
This commit is contained in:
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-app/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
1430
node_modules/@octokit/auth-app/README.md
generated
vendored
Normal file
1430
node_modules/@octokit/auth-app/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
490
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
Normal file
490
node_modules/@octokit/auth-app/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,490 @@
|
||||
// pkg/dist-src/index.js
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as defaultRequest } from "@octokit/request";
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
|
||||
// pkg/dist-src/get-app-authentication.js
|
||||
import githubAppJwt from "universal-github-app-jwt";
|
||||
async function getAppAuthentication({
|
||||
appId,
|
||||
privateKey,
|
||||
timeDifference,
|
||||
createJwt
|
||||
}) {
|
||||
try {
|
||||
if (createJwt) {
|
||||
const { jwt, expiresAt } = await createJwt(appId, timeDifference);
|
||||
return {
|
||||
type: "app",
|
||||
token: jwt,
|
||||
appId,
|
||||
expiresAt
|
||||
};
|
||||
}
|
||||
const authOptions = {
|
||||
id: appId,
|
||||
privateKey
|
||||
};
|
||||
if (timeDifference) {
|
||||
Object.assign(authOptions, {
|
||||
now: Math.floor(Date.now() / 1e3) + timeDifference
|
||||
});
|
||||
}
|
||||
const appAuthentication = await githubAppJwt(authOptions);
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString()
|
||||
};
|
||||
} catch (error) {
|
||||
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
throw new Error(
|
||||
"The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"
|
||||
);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/cache.js
|
||||
import { Lru } from "toad-cache";
|
||||
function getCache() {
|
||||
return new Lru(
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
15e3,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
1e3 * 60 * 59
|
||||
);
|
||||
}
|
||||
async function get(cache, options) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
const result = await cache.get(cacheKey);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const [
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissionsString,
|
||||
singleFileName
|
||||
] = result.split("|");
|
||||
const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions2[string.slice(0, -1)] = "write";
|
||||
} else {
|
||||
permissions2[string] = "read";
|
||||
}
|
||||
return permissions2;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection
|
||||
};
|
||||
}
|
||||
async function set(cache, options, data) {
|
||||
const key = optionsToCacheKey(options);
|
||||
const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(
|
||||
(name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`
|
||||
).join(",");
|
||||
const value = [
|
||||
data.token,
|
||||
data.createdAt,
|
||||
data.expiresAt,
|
||||
data.repositorySelection,
|
||||
permissionsString,
|
||||
data.singleFileName
|
||||
].join("|");
|
||||
await cache.set(key, value);
|
||||
}
|
||||
function optionsToCacheKey({
|
||||
installationId,
|
||||
permissions = {},
|
||||
repositoryIds = [],
|
||||
repositoryNames = []
|
||||
}) {
|
||||
const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(",");
|
||||
const repositoryIdsString = repositoryIds.sort().join(",");
|
||||
const repositoryNamesString = repositoryNames.join(",");
|
||||
return [
|
||||
installationId,
|
||||
repositoryIdsString,
|
||||
repositoryNamesString,
|
||||
permissionsString
|
||||
].filter(Boolean).join("|");
|
||||
}
|
||||
|
||||
// pkg/dist-src/to-token-authentication.js
|
||||
function toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
}) {
|
||||
return Object.assign(
|
||||
{
|
||||
type: "token",
|
||||
tokenType: "installation",
|
||||
token,
|
||||
installationId,
|
||||
permissions,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection
|
||||
},
|
||||
repositoryIds ? { repositoryIds } : null,
|
||||
repositoryNames ? { repositoryNames } : null,
|
||||
singleFileName ? { singleFileName } : null
|
||||
);
|
||||
}
|
||||
|
||||
// pkg/dist-src/get-installation-authentication.js
|
||||
async function getInstallationAuthentication(state, options, customRequest) {
|
||||
const installationId = Number(options.installationId || state.installationId);
|
||||
if (!installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId option is required for installation authentication."
|
||||
);
|
||||
}
|
||||
if (options.factory) {
|
||||
const { type, factory, oauthApp, ...factoryAuthOptions } = {
|
||||
...state,
|
||||
...options
|
||||
};
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const request = customRequest || state.request;
|
||||
return getInstallationAuthenticationConcurrently(
|
||||
state,
|
||||
{ ...options, installationId },
|
||||
request
|
||||
);
|
||||
}
|
||||
var pendingPromises = /* @__PURE__ */ new Map();
|
||||
function getInstallationAuthenticationConcurrently(state, options, request) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
if (pendingPromises.has(cacheKey)) {
|
||||
return pendingPromises.get(cacheKey);
|
||||
}
|
||||
const promise = getInstallationAuthenticationImpl(
|
||||
state,
|
||||
options,
|
||||
request
|
||||
).finally(() => pendingPromises.delete(cacheKey));
|
||||
pendingPromises.set(cacheKey, promise);
|
||||
return promise;
|
||||
}
|
||||
async function getInstallationAuthenticationImpl(state, options, request) {
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, options);
|
||||
if (result) {
|
||||
const {
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2,
|
||||
repositorySelection: repositorySelection2
|
||||
} = result;
|
||||
return toTokenAuthentication({
|
||||
installationId: options.installationId,
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositorySelection: repositorySelection2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const payload = {
|
||||
installation_id: options.installationId,
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`
|
||||
}
|
||||
};
|
||||
if (options.repositoryIds) {
|
||||
Object.assign(payload, { repository_ids: options.repositoryIds });
|
||||
}
|
||||
if (options.repositoryNames) {
|
||||
Object.assign(payload, {
|
||||
repositories: options.repositoryNames
|
||||
});
|
||||
}
|
||||
if (options.permissions) {
|
||||
Object.assign(payload, { permissions: options.permissions });
|
||||
}
|
||||
const {
|
||||
data: {
|
||||
token,
|
||||
expires_at: expiresAt,
|
||||
repositories,
|
||||
permissions: permissionsOptional,
|
||||
repository_selection: repositorySelectionOptional,
|
||||
single_file: singleFileName
|
||||
}
|
||||
} = await request(
|
||||
"POST /app/installations/{installation_id}/access_tokens",
|
||||
payload
|
||||
);
|
||||
const permissions = permissionsOptional || {};
|
||||
const repositorySelection = repositorySelectionOptional || "all";
|
||||
const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0;
|
||||
const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0;
|
||||
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
||||
const cacheOptions = {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(payload, { singleFileName });
|
||||
}
|
||||
await set(state.cache, options, cacheOptions);
|
||||
const cacheData = {
|
||||
installationId: options.installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(cacheData, { singleFileName });
|
||||
}
|
||||
return toTokenAuthentication(cacheData);
|
||||
}
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
authOptions;
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation"
|
||||
});
|
||||
case "oauth-user":
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
|
||||
// pkg/dist-src/requires-app-auth.js
|
||||
var PATHS = [
|
||||
"/app",
|
||||
"/app/hook/config",
|
||||
"/app/hook/deliveries",
|
||||
"/app/hook/deliveries/{delivery_id}",
|
||||
"/app/hook/deliveries/{delivery_id}/attempts",
|
||||
"/app/installations",
|
||||
"/app/installations/{installation_id}",
|
||||
"/app/installations/{installation_id}/access_tokens",
|
||||
"/app/installations/{installation_id}/suspended",
|
||||
"/app/installation-requests",
|
||||
"/marketplace_listing/accounts/{account_id}",
|
||||
"/marketplace_listing/plan",
|
||||
"/marketplace_listing/plans",
|
||||
"/marketplace_listing/plans/{plan_id}/accounts",
|
||||
"/marketplace_listing/stubbed/accounts/{account_id}",
|
||||
"/marketplace_listing/stubbed/plan",
|
||||
"/marketplace_listing/stubbed/plans",
|
||||
"/marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
||||
"/orgs/{org}/installation",
|
||||
"/repos/{owner}/{repo}/installation",
|
||||
"/users/{username}/installation",
|
||||
"/enterprises/{enterprise}/installation"
|
||||
];
|
||||
function routeMatcher(paths) {
|
||||
const regexes = paths.map(
|
||||
(p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
|
||||
);
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`;
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
var REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url.split("?")[0]);
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
var FIVE_SECONDS_IN_MS = 5 * 1e3;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(
|
||||
/'Expiration time' claim \('exp'\) is too far in the future/
|
||||
) || error.message.match(
|
||||
/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/
|
||||
) || error.message.match(
|
||||
/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/
|
||||
));
|
||||
}
|
||||
async function hook(state, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
const url = endpoint.url;
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token: token2 } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token2}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
} catch (error) {
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor(
|
||||
(Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3
|
||||
);
|
||||
state.log.warn(error.message);
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`
|
||||
);
|
||||
const { token: token3 } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token3}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (requiresBasicAuth(url)) {
|
||||
const authentication = await state.oauthApp({ type: "oauth-app" });
|
||||
endpoint.headers.authorization = authentication.headers.authorization;
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token, createdAt } = await getInstallationAuthentication(
|
||||
state,
|
||||
// @ts-expect-error TBD
|
||||
{},
|
||||
request.defaults({ baseUrl: endpoint.baseUrl })
|
||||
);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(
|
||||
state,
|
||||
request,
|
||||
endpoint,
|
||||
createdAt
|
||||
);
|
||||
}
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +/* @__PURE__ */ new Date() - +new Date(createdAt);
|
||||
try {
|
||||
return await request(options);
|
||||
} catch (error) {
|
||||
if (error.status !== 401) {
|
||||
throw error;
|
||||
}
|
||||
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
||||
if (retries > 0) {
|
||||
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
++retries;
|
||||
const awaitTime = retries * 1e3;
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "8.2.0";
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!options.privateKey && !options.createJwt) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
} else if (options.privateKey && options.createJwt) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] privateKey and createJwt options are mutually exclusive"
|
||||
);
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId is set to a falsy value"
|
||||
);
|
||||
}
|
||||
const log = options.log || {};
|
||||
if (typeof log.warn !== "function") {
|
||||
log.warn = console.warn.bind(console);
|
||||
}
|
||||
const request = options.request || defaultRequest.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-app.js/${VERSION} ${getUserAgent()}`
|
||||
}
|
||||
});
|
||||
const state = Object.assign(
|
||||
{
|
||||
request,
|
||||
cache: getCache()
|
||||
},
|
||||
options,
|
||||
options.installationId ? { installationId: Number(options.installationId) } : {},
|
||||
{
|
||||
log,
|
||||
oauthApp: createOAuthAppAuth({
|
||||
clientType: "github-app",
|
||||
clientId: options.clientId || "",
|
||||
clientSecret: options.clientSecret || "",
|
||||
request
|
||||
})
|
||||
}
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createAppAuth,
|
||||
createOAuthUserAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-app/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
23
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
Normal file
23
node_modules/@octokit/auth-app/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication.js";
|
||||
async function auth(state, authOptions) {
|
||||
switch (authOptions.type) {
|
||||
case "app":
|
||||
return getAppAuthentication(state);
|
||||
case "oauth-app":
|
||||
return state.oauthApp({ type: "oauth-app" });
|
||||
case "installation":
|
||||
authOptions;
|
||||
return getInstallationAuthentication(state, {
|
||||
...authOptions,
|
||||
type: "installation"
|
||||
});
|
||||
case "oauth-user":
|
||||
return state.oauthApp(authOptions);
|
||||
default:
|
||||
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
||||
}
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
79
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
Normal file
79
node_modules/@octokit/auth-app/dist-src/cache.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Lru } from "toad-cache";
|
||||
function getCache() {
|
||||
return new Lru(
|
||||
// cache max. 15000 tokens, that will use less than 10mb memory
|
||||
15e3,
|
||||
// Cache for 1 minute less than GitHub expiry
|
||||
1e3 * 60 * 59
|
||||
);
|
||||
}
|
||||
async function get(cache, options) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
const result = await cache.get(cacheKey);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const [
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissionsString,
|
||||
singleFileName
|
||||
] = result.split("|");
|
||||
const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => {
|
||||
if (/!$/.test(string)) {
|
||||
permissions2[string.slice(0, -1)] = "write";
|
||||
} else {
|
||||
permissions2[string] = "read";
|
||||
}
|
||||
return permissions2;
|
||||
}, {});
|
||||
return {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
permissions,
|
||||
repositoryIds: options.repositoryIds,
|
||||
repositoryNames: options.repositoryNames,
|
||||
singleFileName,
|
||||
repositorySelection
|
||||
};
|
||||
}
|
||||
async function set(cache, options, data) {
|
||||
const key = optionsToCacheKey(options);
|
||||
const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(
|
||||
(name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`
|
||||
).join(",");
|
||||
const value = [
|
||||
data.token,
|
||||
data.createdAt,
|
||||
data.expiresAt,
|
||||
data.repositorySelection,
|
||||
permissionsString,
|
||||
data.singleFileName
|
||||
].join("|");
|
||||
await cache.set(key, value);
|
||||
}
|
||||
function optionsToCacheKey({
|
||||
installationId,
|
||||
permissions = {},
|
||||
repositoryIds = [],
|
||||
repositoryNames = []
|
||||
}) {
|
||||
const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(",");
|
||||
const repositoryIdsString = repositoryIds.sort().join(",");
|
||||
const repositoryNamesString = repositoryNames.join(",");
|
||||
return [
|
||||
installationId,
|
||||
repositoryIdsString,
|
||||
repositoryNamesString,
|
||||
permissionsString
|
||||
].filter(Boolean).join("|");
|
||||
}
|
||||
export {
|
||||
get,
|
||||
getCache,
|
||||
optionsToCacheKey,
|
||||
set
|
||||
};
|
||||
46
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
Normal file
46
node_modules/@octokit/auth-app/dist-src/get-app-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import githubAppJwt from "universal-github-app-jwt";
|
||||
async function getAppAuthentication({
|
||||
appId,
|
||||
privateKey,
|
||||
timeDifference,
|
||||
createJwt
|
||||
}) {
|
||||
try {
|
||||
if (createJwt) {
|
||||
const { jwt, expiresAt } = await createJwt(appId, timeDifference);
|
||||
return {
|
||||
type: "app",
|
||||
token: jwt,
|
||||
appId,
|
||||
expiresAt
|
||||
};
|
||||
}
|
||||
const authOptions = {
|
||||
id: appId,
|
||||
privateKey
|
||||
};
|
||||
if (timeDifference) {
|
||||
Object.assign(authOptions, {
|
||||
now: Math.floor(Date.now() / 1e3) + timeDifference
|
||||
});
|
||||
}
|
||||
const appAuthentication = await githubAppJwt(authOptions);
|
||||
return {
|
||||
type: "app",
|
||||
token: appAuthentication.token,
|
||||
appId: appAuthentication.appId,
|
||||
expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString()
|
||||
};
|
||||
} catch (error) {
|
||||
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
throw new Error(
|
||||
"The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"
|
||||
);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
getAppAuthentication
|
||||
};
|
||||
135
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
Normal file
135
node_modules/@octokit/auth-app/dist-src/get-installation-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
import { get, optionsToCacheKey, set } from "./cache.js";
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { toTokenAuthentication } from "./to-token-authentication.js";
|
||||
async function getInstallationAuthentication(state, options, customRequest) {
|
||||
const installationId = Number(options.installationId || state.installationId);
|
||||
if (!installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId option is required for installation authentication."
|
||||
);
|
||||
}
|
||||
if (options.factory) {
|
||||
const { type, factory, oauthApp, ...factoryAuthOptions } = {
|
||||
...state,
|
||||
...options
|
||||
};
|
||||
return factory(factoryAuthOptions);
|
||||
}
|
||||
const request = customRequest || state.request;
|
||||
return getInstallationAuthenticationConcurrently(
|
||||
state,
|
||||
{ ...options, installationId },
|
||||
request
|
||||
);
|
||||
}
|
||||
const pendingPromises = /* @__PURE__ */ new Map();
|
||||
function getInstallationAuthenticationConcurrently(state, options, request) {
|
||||
const cacheKey = optionsToCacheKey(options);
|
||||
if (pendingPromises.has(cacheKey)) {
|
||||
return pendingPromises.get(cacheKey);
|
||||
}
|
||||
const promise = getInstallationAuthenticationImpl(
|
||||
state,
|
||||
options,
|
||||
request
|
||||
).finally(() => pendingPromises.delete(cacheKey));
|
||||
pendingPromises.set(cacheKey, promise);
|
||||
return promise;
|
||||
}
|
||||
async function getInstallationAuthenticationImpl(state, options, request) {
|
||||
if (!options.refresh) {
|
||||
const result = await get(state.cache, options);
|
||||
if (result) {
|
||||
const {
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2,
|
||||
repositorySelection: repositorySelection2
|
||||
} = result;
|
||||
return toTokenAuthentication({
|
||||
installationId: options.installationId,
|
||||
token: token2,
|
||||
createdAt: createdAt2,
|
||||
expiresAt: expiresAt2,
|
||||
permissions: permissions2,
|
||||
repositorySelection: repositorySelection2,
|
||||
repositoryIds: repositoryIds2,
|
||||
repositoryNames: repositoryNames2,
|
||||
singleFileName: singleFileName2
|
||||
});
|
||||
}
|
||||
}
|
||||
const appAuthentication = await getAppAuthentication(state);
|
||||
const payload = {
|
||||
installation_id: options.installationId,
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
},
|
||||
headers: {
|
||||
authorization: `bearer ${appAuthentication.token}`
|
||||
}
|
||||
};
|
||||
if (options.repositoryIds) {
|
||||
Object.assign(payload, { repository_ids: options.repositoryIds });
|
||||
}
|
||||
if (options.repositoryNames) {
|
||||
Object.assign(payload, {
|
||||
repositories: options.repositoryNames
|
||||
});
|
||||
}
|
||||
if (options.permissions) {
|
||||
Object.assign(payload, { permissions: options.permissions });
|
||||
}
|
||||
const {
|
||||
data: {
|
||||
token,
|
||||
expires_at: expiresAt,
|
||||
repositories,
|
||||
permissions: permissionsOptional,
|
||||
repository_selection: repositorySelectionOptional,
|
||||
single_file: singleFileName
|
||||
}
|
||||
} = await request(
|
||||
"POST /app/installations/{installation_id}/access_tokens",
|
||||
payload
|
||||
);
|
||||
const permissions = permissionsOptional || {};
|
||||
const repositorySelection = repositorySelectionOptional || "all";
|
||||
const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0;
|
||||
const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0;
|
||||
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
||||
const cacheOptions = {
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(payload, { singleFileName });
|
||||
}
|
||||
await set(state.cache, options, cacheOptions);
|
||||
const cacheData = {
|
||||
installationId: options.installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames
|
||||
};
|
||||
if (singleFileName) {
|
||||
Object.assign(cacheData, { singleFileName });
|
||||
}
|
||||
return toTokenAuthentication(cacheData);
|
||||
}
|
||||
export {
|
||||
getInstallationAuthentication
|
||||
};
|
||||
95
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
Normal file
95
node_modules/@octokit/auth-app/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import { getAppAuthentication } from "./get-app-authentication.js";
|
||||
import { getInstallationAuthentication } from "./get-installation-authentication.js";
|
||||
import { requiresAppAuth } from "./requires-app-auth.js";
|
||||
const FIVE_SECONDS_IN_MS = 5 * 1e3;
|
||||
function isNotTimeSkewError(error) {
|
||||
return !(error.message.match(
|
||||
/'Expiration time' claim \('exp'\) is too far in the future/
|
||||
) || error.message.match(
|
||||
/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/
|
||||
) || error.message.match(
|
||||
/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/
|
||||
));
|
||||
}
|
||||
async function hook(state, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
const url = endpoint.url;
|
||||
if (/\/login\/oauth\/access_token$/.test(url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
||||
const { token: token2 } = await getAppAuthentication(state);
|
||||
endpoint.headers.authorization = `bearer ${token2}`;
|
||||
let response;
|
||||
try {
|
||||
response = await request(endpoint);
|
||||
} catch (error) {
|
||||
if (isNotTimeSkewError(error)) {
|
||||
throw error;
|
||||
}
|
||||
if (typeof error.response.headers.date === "undefined") {
|
||||
throw error;
|
||||
}
|
||||
const diff = Math.floor(
|
||||
(Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3
|
||||
);
|
||||
state.log.warn(error.message);
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`
|
||||
);
|
||||
const { token: token3 } = await getAppAuthentication({
|
||||
...state,
|
||||
timeDifference: diff
|
||||
});
|
||||
endpoint.headers.authorization = `bearer ${token3}`;
|
||||
return request(endpoint);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (requiresBasicAuth(url)) {
|
||||
const authentication = await state.oauthApp({ type: "oauth-app" });
|
||||
endpoint.headers.authorization = authentication.headers.authorization;
|
||||
return request(endpoint);
|
||||
}
|
||||
const { token, createdAt } = await getInstallationAuthentication(
|
||||
state,
|
||||
// @ts-expect-error TBD
|
||||
{},
|
||||
request.defaults({ baseUrl: endpoint.baseUrl })
|
||||
);
|
||||
endpoint.headers.authorization = `token ${token}`;
|
||||
return sendRequestWithRetries(
|
||||
state,
|
||||
request,
|
||||
endpoint,
|
||||
createdAt
|
||||
);
|
||||
}
|
||||
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
||||
const timeSinceTokenCreationInMs = +/* @__PURE__ */ new Date() - +new Date(createdAt);
|
||||
try {
|
||||
return await request(options);
|
||||
} catch (error) {
|
||||
if (error.status !== 401) {
|
||||
throw error;
|
||||
}
|
||||
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
||||
if (retries > 0) {
|
||||
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
++retries;
|
||||
const awaitTime = retries * 1e3;
|
||||
state.log.warn(
|
||||
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
||||
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
||||
}
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
58
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
Normal file
58
node_modules/@octokit/auth-app/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { request as defaultRequest } from "@octokit/request";
|
||||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
import { getCache } from "./cache.js";
|
||||
import { VERSION } from "./version.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
function createAppAuth(options) {
|
||||
if (!options.appId) {
|
||||
throw new Error("[@octokit/auth-app] appId option is required");
|
||||
}
|
||||
if (!options.privateKey && !options.createJwt) {
|
||||
throw new Error("[@octokit/auth-app] privateKey option is required");
|
||||
} else if (options.privateKey && options.createJwt) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] privateKey and createJwt options are mutually exclusive"
|
||||
);
|
||||
}
|
||||
if ("installationId" in options && !options.installationId) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-app] installationId is set to a falsy value"
|
||||
);
|
||||
}
|
||||
const log = options.log || {};
|
||||
if (typeof log.warn !== "function") {
|
||||
log.warn = console.warn.bind(console);
|
||||
}
|
||||
const request = options.request || defaultRequest.defaults({
|
||||
headers: {
|
||||
"user-agent": `octokit-auth-app.js/${VERSION} ${getUserAgent()}`
|
||||
}
|
||||
});
|
||||
const state = Object.assign(
|
||||
{
|
||||
request,
|
||||
cache: getCache()
|
||||
},
|
||||
options,
|
||||
options.installationId ? { installationId: Number(options.installationId) } : {},
|
||||
{
|
||||
log,
|
||||
oauthApp: createOAuthAppAuth({
|
||||
clientType: "github-app",
|
||||
clientId: options.clientId || "",
|
||||
clientSecret: options.clientSecret || "",
|
||||
request
|
||||
})
|
||||
}
|
||||
);
|
||||
return Object.assign(auth.bind(null, state), {
|
||||
hook: hook.bind(null, state)
|
||||
});
|
||||
}
|
||||
export {
|
||||
createAppAuth,
|
||||
createOAuthUserAuth
|
||||
};
|
||||
38
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
Normal file
38
node_modules/@octokit/auth-app/dist-src/requires-app-auth.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
const PATHS = [
|
||||
"/app",
|
||||
"/app/hook/config",
|
||||
"/app/hook/deliveries",
|
||||
"/app/hook/deliveries/{delivery_id}",
|
||||
"/app/hook/deliveries/{delivery_id}/attempts",
|
||||
"/app/installations",
|
||||
"/app/installations/{installation_id}",
|
||||
"/app/installations/{installation_id}/access_tokens",
|
||||
"/app/installations/{installation_id}/suspended",
|
||||
"/app/installation-requests",
|
||||
"/marketplace_listing/accounts/{account_id}",
|
||||
"/marketplace_listing/plan",
|
||||
"/marketplace_listing/plans",
|
||||
"/marketplace_listing/plans/{plan_id}/accounts",
|
||||
"/marketplace_listing/stubbed/accounts/{account_id}",
|
||||
"/marketplace_listing/stubbed/plan",
|
||||
"/marketplace_listing/stubbed/plans",
|
||||
"/marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
||||
"/orgs/{org}/installation",
|
||||
"/repos/{owner}/{repo}/installation",
|
||||
"/users/{username}/installation",
|
||||
"/enterprises/{enterprise}/installation"
|
||||
];
|
||||
function routeMatcher(paths) {
|
||||
const regexes = paths.map(
|
||||
(p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
|
||||
);
|
||||
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`;
|
||||
return new RegExp(regex, "i");
|
||||
}
|
||||
const REGEX = routeMatcher(PATHS);
|
||||
function requiresAppAuth(url) {
|
||||
return !!url && REGEX.test(url.split("?")[0]);
|
||||
}
|
||||
export {
|
||||
requiresAppAuth
|
||||
};
|
||||
30
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
Normal file
30
node_modules/@octokit/auth-app/dist-src/to-token-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
function toTokenAuthentication({
|
||||
installationId,
|
||||
token,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection,
|
||||
permissions,
|
||||
repositoryIds,
|
||||
repositoryNames,
|
||||
singleFileName
|
||||
}) {
|
||||
return Object.assign(
|
||||
{
|
||||
type: "token",
|
||||
tokenType: "installation",
|
||||
token,
|
||||
installationId,
|
||||
permissions,
|
||||
createdAt,
|
||||
expiresAt,
|
||||
repositorySelection
|
||||
},
|
||||
repositoryIds ? { repositoryIds } : null,
|
||||
repositoryNames ? { repositoryNames } : null,
|
||||
singleFileName ? { singleFileName } : null
|
||||
);
|
||||
}
|
||||
export {
|
||||
toTokenAuthentication
|
||||
};
|
||||
4
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
Normal file
4
node_modules/@octokit/auth-app/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const VERSION = "8.2.0";
|
||||
export {
|
||||
VERSION
|
||||
};
|
||||
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
Normal file
20
node_modules/@octokit/auth-app/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
import type { State, AppAuthOptions, AppAuthentication, OAuthAppAuthentication, OAuthAppAuthOptions, InstallationAuthOptions, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions } from "./types.js";
|
||||
/** GitHub App authentication */
|
||||
export declare function auth(state: State, authOptions: AppAuthOptions): Promise<AppAuthentication>;
|
||||
/** OAuth App authentication */
|
||||
export declare function auth(state: State, authOptions: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
/** Installation authentication */
|
||||
export declare function auth(state: State, authOptions: InstallationAuthOptions): Promise<InstallationAccessTokenAuthentication>;
|
||||
/** User Authentication via OAuth web flow */
|
||||
export declare function auth(state: State, authOptions: OAuthWebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
/** GitHub App Web flow with `factory` option */
|
||||
export declare function auth<T = unknown>(state: State, authOptions: OAuthWebFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
/** User Authentication via OAuth Device flow */
|
||||
export declare function auth(state: State, authOptions: OAuthDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
/** GitHub App Device flow with `factory` option */
|
||||
export declare function auth<T = unknown>(state: State, authOptions: OAuthDeviceFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
6
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
Normal file
6
node_modules/@octokit/auth-app/dist-types/cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Lru } from "toad-cache";
|
||||
import type { CacheableInstallationAuthOptions, Cache, CacheData, InstallationAccessTokenData } from "./types.js";
|
||||
export declare function getCache(): Lru<string>;
|
||||
export declare function get(cache: Cache, options: CacheableInstallationAuthOptions): Promise<InstallationAccessTokenData | void>;
|
||||
export declare function set(cache: Cache, options: CacheableInstallationAuthOptions, data: CacheData): Promise<void>;
|
||||
export declare function optionsToCacheKey({ installationId, permissions, repositoryIds, repositoryNames, }: CacheableInstallationAuthOptions): string;
|
||||
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/auth-app/dist-types/get-app-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { AppAuthentication, State } from "./types.js";
|
||||
export declare function getAppAuthentication({ appId, privateKey, timeDifference, createJwt, }: State & {
|
||||
timeDifference?: number | undefined;
|
||||
}): Promise<AppAuthentication>;
|
||||
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-app/dist-types/get-installation-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { InstallationAuthOptions, InstallationAccessTokenAuthentication, RequestInterface, State } from "./types.js";
|
||||
export declare function getInstallationAuthentication(state: State, options: InstallationAuthOptions, customRequest?: RequestInterface): Promise<InstallationAccessTokenAuthentication>;
|
||||
2
node_modules/@octokit/auth-app/dist-types/hook.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-app/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { AnyResponse, EndpointOptions, RequestParameters, RequestInterface, Route, State } from "./types.js";
|
||||
export declare function hook(state: State, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
||||
4
node_modules/@octokit/auth-app/dist-types/index.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/auth-app/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { AuthInterface, StrategyOptions } from "./types.js";
|
||||
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
export type { StrategyOptions, AppAuthOptions, OAuthAppAuthOptions, InstallationAuthOptions, OAuthWebFlowAuthOptions, OAuthDeviceFlowAuthOptions, Authentication, AppAuthentication, OAuthAppAuthentication, InstallationAccessTokenAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, } from "./types.js";
|
||||
export declare function createAppAuth(options: StrategyOptions): AuthInterface;
|
||||
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-app/dist-types/requires-app-auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function requiresAppAuth(url: string | undefined): Boolean;
|
||||
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-app/dist-types/to-token-authentication.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { CacheData, InstallationAccessTokenAuthentication, WithInstallationId } from "./types.js";
|
||||
export declare function toTokenAuthentication({ installationId, token, createdAt, expiresAt, repositorySelection, permissions, repositoryIds, repositoryNames, singleFileName, }: CacheData & WithInstallationId): InstallationAccessTokenAuthentication;
|
||||
136
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
Normal file
136
node_modules/@octokit/auth-app/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
import type * as OctokitTypes from "@octokit/types";
|
||||
import type { Lru } from "toad-cache";
|
||||
import type * as OAuthAppAuth from "@octokit/auth-oauth-app";
|
||||
type OAuthStrategyOptions = {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
};
|
||||
type AppAuthStrategyOptions = {
|
||||
privateKey: string;
|
||||
};
|
||||
type AppAuthJwtSigningStrategyOptions = {
|
||||
createJwt: (clientIdOrAppId: string | number, timeDifference?: number | undefined) => Promise<{
|
||||
jwt: string;
|
||||
expiresAt: string;
|
||||
}>;
|
||||
};
|
||||
type CommonStrategyOptions = {
|
||||
appId: number | string;
|
||||
installationId?: number | string;
|
||||
request?: OctokitTypes.RequestInterface;
|
||||
cache?: Cache;
|
||||
log?: {
|
||||
warn: (message: string, additionalInfo?: object) => any;
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
export type StrategyOptions = OAuthStrategyOptions & CommonStrategyOptions & (AppAuthStrategyOptions | AppAuthJwtSigningStrategyOptions) & Record<string, unknown>;
|
||||
export type AppAuthOptions = Partial<AppAuthJwtSigningStrategyOptions> & {
|
||||
type: "app";
|
||||
};
|
||||
/**
|
||||
Users SHOULD only enter repositoryIds || repositoryNames.
|
||||
However, this module still passes both to the backend API to
|
||||
let the API decide how to handle the logic. We just throw the
|
||||
response back to the client making the request.
|
||||
**/
|
||||
export type InstallationAuthOptions = {
|
||||
type: "installation";
|
||||
installationId?: number | string;
|
||||
repositoryIds?: number[];
|
||||
repositoryNames?: string[];
|
||||
permissions?: Permissions;
|
||||
refresh?: boolean;
|
||||
factory?: never;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export type InstallationAuthOptionsWithFactory<T> = {
|
||||
type: "installation";
|
||||
installationId?: number | string;
|
||||
repositoryIds?: number[];
|
||||
repositoryNames?: string[];
|
||||
permissions?: Permissions;
|
||||
refresh?: boolean;
|
||||
factory: FactoryInstallation<T>;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export type CacheableInstallationAuthOptions = InstallationAuthOptions & {
|
||||
installationId: number;
|
||||
};
|
||||
export type OAuthAppAuthOptions = OAuthAppAuth.AppAuthOptions;
|
||||
export type OAuthWebFlowAuthOptions = OAuthAppAuth.WebFlowAuthOptions;
|
||||
export type OAuthDeviceFlowAuthOptions = OAuthAppAuth.GitHubAppDeviceFlowAuthOptions;
|
||||
export type Authentication = AppAuthentication | OAuthAppAuthentication | InstallationAccessTokenAuthentication | GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration;
|
||||
export type FactoryInstallationOptions = StrategyOptions & Omit<InstallationAuthOptions, "type">;
|
||||
export interface FactoryInstallation<T> {
|
||||
(options: FactoryInstallationOptions): T;
|
||||
}
|
||||
export interface AuthInterface {
|
||||
(options: AppAuthOptions | AppAuthJwtSigningStrategyOptions): Promise<AppAuthentication>;
|
||||
(options: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
||||
(options: InstallationAuthOptions): Promise<InstallationAccessTokenAuthentication>;
|
||||
<T = unknown>(options: InstallationAuthOptionsWithFactory<T>): Promise<T>;
|
||||
(options: OAuthWebFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
(options: OAuthDeviceFlowAuthOptions): Promise<GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration>;
|
||||
<T = unknown>(options: OAuthWebFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubWebFlow<T>;
|
||||
}): Promise<T>;
|
||||
<T = unknown>(options: OAuthDeviceFlowAuthOptions & {
|
||||
factory: OAuthAppAuth.FactoryGitHubDeviceFlow<T>;
|
||||
}): Promise<T>;
|
||||
hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
||||
}
|
||||
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
||||
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
||||
export type EndpointOptions = OctokitTypes.EndpointOptions;
|
||||
export type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export type Route = OctokitTypes.Route;
|
||||
export type RequestInterface = OctokitTypes.RequestInterface;
|
||||
export type Cache = Lru<string> | {
|
||||
get: (key: string) => string | Promise<string>;
|
||||
set: (key: string, value: string) => any;
|
||||
};
|
||||
export type APP_TYPE = "app";
|
||||
export type TOKEN_TYPE = "token";
|
||||
export type INSTALLATION_TOKEN_TYPE = "installation";
|
||||
export type OAUTH_TOKEN_TYPE = "oauth";
|
||||
export type REPOSITORY_SELECTION = "all" | "selected";
|
||||
export type JWT = string;
|
||||
export type ACCESS_TOKEN = string;
|
||||
export type UTC_TIMESTAMP = string;
|
||||
export type AppAuthentication = {
|
||||
type: APP_TYPE;
|
||||
token: JWT;
|
||||
appId: number | string;
|
||||
expiresAt: string;
|
||||
};
|
||||
export type InstallationAccessTokenData = {
|
||||
token: ACCESS_TOKEN;
|
||||
createdAt: UTC_TIMESTAMP;
|
||||
expiresAt: UTC_TIMESTAMP;
|
||||
permissions: Permissions;
|
||||
repositorySelection: REPOSITORY_SELECTION;
|
||||
repositoryIds?: number[] | undefined;
|
||||
repositoryNames?: string[] | undefined;
|
||||
singleFileName?: string | undefined;
|
||||
};
|
||||
export type CacheData = InstallationAccessTokenData;
|
||||
export type InstallationAccessTokenAuthentication = InstallationAccessTokenData & {
|
||||
type: TOKEN_TYPE;
|
||||
tokenType: INSTALLATION_TOKEN_TYPE;
|
||||
installationId: number;
|
||||
};
|
||||
export type OAuthAppAuthentication = OAuthAppAuth.AppAuthentication;
|
||||
export type GitHubAppUserAuthentication = OAuthAppAuth.GitHubAppUserAuthentication;
|
||||
export type GitHubAppUserAuthenticationWithExpiration = OAuthAppAuth.GitHubAppUserAuthenticationWithExpiration;
|
||||
export type FactoryOptions = Required<Omit<StrategyOptions, keyof State>> & State;
|
||||
export type Permissions = Record<string, string>;
|
||||
export type WithInstallationId = {
|
||||
installationId: number;
|
||||
};
|
||||
export type State = Required<Omit<CommonStrategyOptions, "installationId">> & Pick<Partial<AppAuthStrategyOptions>, "privateKey"> & Pick<Partial<AppAuthJwtSigningStrategyOptions>, "createJwt"> & {
|
||||
installationId?: number;
|
||||
} & OAuthStrategyOptions & {
|
||||
oauthApp: OAuthAppAuth.GitHubAuthInterface;
|
||||
};
|
||||
export {};
|
||||
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/auth-app/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "8.2.0";
|
||||
59
node_modules/@octokit/auth-app/package.json
generated
vendored
Normal file
59
node_modules/@octokit/auth-app/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "@octokit/auth-app",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "8.2.0",
|
||||
"description": "GitHub App authentication for JavaScript",
|
||||
"repository": "github:octokit/auth-app.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-oauth-app": "^9.0.3",
|
||||
"@octokit/auth-oauth-user": "^6.0.2",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"toad-cache": "^3.7.0",
|
||||
"universal-github-app-jwt": "^2.2.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"@vitest/ui": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^11.0.0",
|
||||
"prettier": "3.6.2",
|
||||
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
||||
"tinyglobby": "^0.2.13",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"main": "dist-node/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js",
|
||||
"default": "./dist-node/index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
Reference in New Issue
Block a user