install @octokit/rest

This commit is contained in:
Luis Fernando Molina committed 2018-02-25 19:00:40 +01:00
1 parent 39d9c0de99
commit e44c6cb357
1145 files changed
+67878 -1

No files matched your search

@@ -0,0 +1,37 @@
module.exports = authenticationBeforeRequest
function authenticationBeforeRequest (state, options) {
if (!state.auth.type) {
return
}
if (state.auth.type === 'basic') {
const hash = Buffer.from(
`${state.auth.username}:${state.auth.password}`, 'ascii'
).toString('base64')
options.headers['authorization'] = `Basic ${hash}`
return
}
if (state.auth.type === 'token') {
options.headers['authorization'] = `token ${state.auth.token}`
return
}
if (state.auth.type === 'integration') {
options.headers['authorization'] = `Bearer ${state.auth.token}`
options.headers['accept'] = 'application/vnd.github.machine-man-preview+json'
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}`
}