mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-05-09 00:22:36 +00:00
Add auth support (#21)
* Updates * Update * Update * Update * Update * Yarn sometimes prefers npmrc, so use same token * Description * Update readme * Feedback * Add type * new toolkit and scoped registries * npmrc in RUNNER_TEMP * Dont always auth * Try exporting blank token * Get auth working for now pending runner changes * Fix string interpolation for auth token. * Don't export both userconfigs * Update authutil.js * Add single quotes for authString * Fix the registry string. * Use userconfig and append trailing slash * Keep in root of repo * Try just adding auth token * Remove auth token * Try changes again * Add tests * Npm and GPR samples * Add types
This commit is contained in:
parent
0675b87d74
commit
78148dae50
391 changed files with 79848 additions and 43 deletions
39
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
Normal file
39
node_modules/@octokit/rest/plugins/authentication-deprecated/request-error.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
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