Add node modules and package files

This commit is contained in:
Rachael Sewell
2019-09-06 15:17:38 -07:00
parent e84489cd02
commit 714607abe9
165 changed files with 2227 additions and 4644 deletions

View File

@@ -6,13 +6,13 @@ const withAuthorizationPrefix = require('./with-authorization-prefix')
function authenticationBeforeRequest (state, options) {
if (typeof state.auth === 'string') {
options.headers['authorization'] = withAuthorizationPrefix(state.auth)
options.headers.authorization = withAuthorizationPrefix(state.auth)
// https://developer.github.com/v3/previews/#integrations
if (/^bearer /i.test(state.auth) && !/machine-man/.test(options.headers['accept'])) {
const acceptHeaders = options.headers['accept'].split(',')
if (/^bearer /i.test(state.auth) && !/machine-man/.test(options.headers.accept)) {
const acceptHeaders = options.headers.accept.split(',')
.concat('application/vnd.github.machine-man-preview+json')
options.headers['accept'] = acceptHeaders.filter(Boolean).join(',')
options.headers.accept = acceptHeaders.filter(Boolean).join(',')
}
return
@@ -20,7 +20,7 @@ function authenticationBeforeRequest (state, options) {
if (state.auth.username) {
const hash = btoa(`${state.auth.username}:${state.auth.password}`)
options.headers['authorization'] = `Basic ${hash}`
options.headers.authorization = `Basic ${hash}`
if (state.otp) {
options.headers['x-github-otp'] = state.otp
}
@@ -40,7 +40,7 @@ function authenticationBeforeRequest (state, options) {
// as well as "/applications/123/tokens/token456"
if (/\/applications\/:?[\w_]+\/tokens\/:?[\w_]+($|\?)/.test(options.url)) {
const hash = btoa(`${state.auth.clientId}:${state.auth.clientSecret}`)
options.headers['authorization'] = `Basic ${hash}`
options.headers.authorization = `Basic ${hash}`
return
}
@@ -56,6 +56,6 @@ function authenticationBeforeRequest (state, options) {
})
.then((authorization) => {
options.headers['authorization'] = withAuthorizationPrefix(authorization)
options.headers.authorization = withAuthorizationPrefix(authorization)
})
}