mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-06-29 14:46:03 +00:00
node_modules
This commit is contained in:
parent
5e3f23f92c
commit
806116bda4
734 changed files with 224451 additions and 0 deletions
52
node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js
generated
vendored
Normal file
52
node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
module.exports = authenticate;
|
||||
|
||||
const { Deprecation } = require("deprecation");
|
||||
const once = require("once");
|
||||
|
||||
const deprecateAuthenticate = once((log, deprecation) => log.warn(deprecation));
|
||||
|
||||
function authenticate(state, options) {
|
||||
deprecateAuthenticate(
|
||||
state.octokit.log,
|
||||
new Deprecation(
|
||||
'[@octokit/rest] octokit.authenticate() is deprecated. Use "auth" constructor option instead.'
|
||||
)
|
||||
);
|
||||
|
||||
if (!options) {
|
||||
state.auth = false;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (options.type) {
|
||||
case "basic":
|
||||
if (!options.username || !options.password) {
|
||||
throw new Error(
|
||||
"Basic authentication requires both a username and password to be set"
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case "oauth":
|
||||
if (!options.token && !(options.key && options.secret)) {
|
||||
throw new Error(
|
||||
"OAuth2 authentication requires a token or key & secret to be set"
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case "token":
|
||||
case "app":
|
||||
if (!options.token) {
|
||||
throw new Error("Token authentication requires a token to be set");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(
|
||||
"Invalid authentication type, must be 'basic', 'oauth', 'token' or 'app'"
|
||||
);
|
||||
}
|
||||
|
||||
state.auth = options;
|
||||
}
|
43
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
Normal file
43
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
module.exports = authenticationBeforeRequest;
|
||||
|
||||
const btoa = require("btoa-lite");
|
||||
const uniq = require("lodash.uniq");
|
||||
|
||||
function authenticationBeforeRequest(state, options) {
|
||||
if (!state.auth.type) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === "basic") {
|
||||
const hash = btoa(`${state.auth.username}:${state.auth.password}`);
|
||||
options.headers.authorization = `Basic ${hash}`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === "token") {
|
||||
options.headers.authorization = `token ${state.auth.token}`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === "app") {
|
||||
options.headers.authorization = `Bearer ${state.auth.token}`;
|
||||
const acceptHeaders = options.headers.accept
|
||||
.split(",")
|
||||
.concat("application/vnd.github.machine-man-preview+json");
|
||||
options.headers.accept = uniq(acceptHeaders)
|
||||
.filter(Boolean)
|
||||
.join(",");
|
||||
return;
|
||||
}
|
||||
|
||||
options.url += options.url.indexOf("?") === -1 ? "?" : "&";
|
||||
|
||||
if (state.auth.token) {
|
||||
options.url += `access_token=${encodeURIComponent(state.auth.token)}`;
|
||||
return;
|
||||
}
|
||||
|
||||
const key = encodeURIComponent(state.auth.key);
|
||||
const secret = encodeURIComponent(state.auth.secret);
|
||||
options.url += `client_id=${key}&client_secret=${secret}`;
|
||||
}
|
31
node_modules/@octokit/rest/plugins/authentication-deprecated/index.js
generated
vendored
Normal file
31
node_modules/@octokit/rest/plugins/authentication-deprecated/index.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
module.exports = authenticationPlugin;
|
||||
|
||||
const { Deprecation } = require("deprecation");
|
||||
const once = require("once");
|
||||
|
||||
const deprecateAuthenticate = once((log, deprecation) => log.warn(deprecation));
|
||||
|
||||
const authenticate = require("./authenticate");
|
||||
const beforeRequest = require("./before-request");
|
||||
const requestError = require("./request-error");
|
||||
|
||||
function authenticationPlugin(octokit, options) {
|
||||
if (options.auth) {
|
||||
octokit.authenticate = () => {
|
||||
deprecateAuthenticate(
|
||||
octokit.log,
|
||||
new Deprecation(
|
||||
'[@octokit/rest] octokit.authenticate() is deprecated and has no effect when "auth" option is set on Octokit constructor'
|
||||
)
|
||||
);
|
||||
};
|
||||
return;
|
||||
}
|
||||
const state = {
|
||||
octokit,
|
||||
auth: false
|
||||
};
|
||||
octokit.authenticate = authenticate.bind(null, state);
|
||||
octokit.hook.before("request", beforeRequest.bind(null, state));
|
||||
octokit.hook.error("request", requestError.bind(null, state));
|
||||
}
|
55
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
Normal file
55
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
module.exports = authenticationRequestError;
|
||||
|
||||
const { RequestError } = require("@octokit/request-error");
|
||||
|
||||
function authenticationRequestError(state, error, options) {
|
||||
/* istanbul ignore next */
|
||||
if (!error.headers) throw error;
|
||||
|
||||
const otpRequired = /required/.test(error.headers["x-github-otp"] || "");
|
||||
// handle "2FA required" error only
|
||||
if (error.status !== 401 || !otpRequired) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (
|
||||
error.status === 401 &&
|
||||
otpRequired &&
|
||||
error.request &&
|
||||
error.request.headers["x-github-otp"]
|
||||
) {
|
||||
throw new RequestError(
|
||||
"Invalid one-time password for two-factor authentication",
|
||||
401,
|
||||
{
|
||||
headers: error.headers,
|
||||
request: options
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof state.auth.on2fa !== "function") {
|
||||
throw new RequestError(
|
||||
"2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication",
|
||||
401,
|
||||
{
|
||||
headers: error.headers,
|
||||
request: options
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
return state.auth.on2fa();
|
||||
})
|
||||
.then(oneTimePassword => {
|
||||
const newOptions = Object.assign(options, {
|
||||
headers: Object.assign(
|
||||
{ "x-github-otp": oneTimePassword },
|
||||
options.headers
|
||||
)
|
||||
});
|
||||
return state.octokit.request(newOptions);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue