mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-15 16:31:12 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
60
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
60
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
|
@ -1,39 +1,55 @@
|
|||
module.exports = authenticationRequestError
|
||||
module.exports = authenticationRequestError;
|
||||
|
||||
const { RequestError } = require('@octokit/request-error')
|
||||
const { RequestError } = require("@octokit/request-error");
|
||||
|
||||
function authenticationRequestError (state, error, options) {
|
||||
function authenticationRequestError(state, error, options) {
|
||||
/* istanbul ignore next */
|
||||
if (!error.headers) throw error
|
||||
if (!error.headers) throw error;
|
||||
|
||||
const otpRequired = /required/.test(error.headers['x-github-otp'] || '')
|
||||
const otpRequired = /required/.test(error.headers["x-github-otp"] || "");
|
||||
// handle "2FA required" error only
|
||||
if (error.status !== 401 || !otpRequired) {
|
||||
throw error
|
||||
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 (
|
||||
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
|
||||
})
|
||||
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()
|
||||
return state.auth.on2fa();
|
||||
})
|
||||
.then((oneTimePassword) => {
|
||||
.then(oneTimePassword => {
|
||||
const newOptions = Object.assign(options, {
|
||||
headers: Object.assign({ 'x-github-otp': oneTimePassword }, options.headers)
|
||||
})
|
||||
return state.octokit.request(newOptions)
|
||||
})
|
||||
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