You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
484 B
JavaScript
22 lines
484 B
JavaScript
module.exports = authenticationPlugin
|
|
|
|
const beforeRequest = require('./before-request')
|
|
const requestError = require('./request-error')
|
|
const validate = require('./validate')
|
|
|
|
function authenticationPlugin (octokit, options) {
|
|
if (!options.auth) {
|
|
return
|
|
}
|
|
|
|
validate(options.auth)
|
|
|
|
const state = {
|
|
octokit,
|
|
auth: options.auth
|
|
}
|
|
|
|
octokit.hook.before('request', beforeRequest.bind(null, state))
|
|
octokit.hook.error('request', requestError.bind(null, state))
|
|
}
|