mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-11-24 12:21:04 -05:00
78148dae50
* 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
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
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
|
|
}
|