mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-24 06:44:44 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
51
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
51
node_modules/@octokit/rest/plugins/authentication-deprecated/before-request.js
generated
vendored
|
@ -1,40 +1,43 @@
|
|||
module.exports = authenticationBeforeRequest
|
||||
module.exports = authenticationBeforeRequest;
|
||||
|
||||
const btoa = require('btoa-lite')
|
||||
const uniq = require('lodash.uniq')
|
||||
const btoa = require("btoa-lite");
|
||||
const uniq = require("lodash.uniq");
|
||||
|
||||
function authenticationBeforeRequest (state, options) {
|
||||
function authenticationBeforeRequest(state, options) {
|
||||
if (!state.auth.type) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === 'basic') {
|
||||
const hash = btoa(`${state.auth.username}:${state.auth.password}`)
|
||||
options.headers['authorization'] = `Basic ${hash}`
|
||||
return
|
||||
if (state.auth.type === "basic") {
|
||||
const hash = btoa(`${state.auth.username}:${state.auth.password}`);
|
||||
options.headers.authorization = `Basic ${hash}`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === 'token') {
|
||||
options.headers['authorization'] = `token ${state.auth.token}`
|
||||
return
|
||||
if (state.auth.type === "token") {
|
||||
options.headers.authorization = `token ${state.auth.token}`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.auth.type === 'app') {
|
||||
options.headers['authorization'] = `Bearer ${state.auth.token}`
|
||||
const acceptHeaders = options.headers['accept'].split(',')
|
||||
.concat('application/vnd.github.machine-man-preview+json')
|
||||
options.headers['accept'] = uniq(acceptHeaders).filter(Boolean).join(',')
|
||||
return
|
||||
if (state.auth.type === "app") {
|
||||
options.headers.authorization = `Bearer ${state.auth.token}`;
|
||||
const acceptHeaders = options.headers.accept
|
||||
.split(",")
|
||||
.concat("application/vnd.github.machine-man-preview+json");
|
||||
options.headers.accept = uniq(acceptHeaders)
|
||||
.filter(Boolean)
|
||||
.join(",");
|
||||
return;
|
||||
}
|
||||
|
||||
options.url += options.url.indexOf('?') === -1 ? '?' : '&'
|
||||
options.url += options.url.indexOf("?") === -1 ? "?" : "&";
|
||||
|
||||
if (state.auth.token) {
|
||||
options.url += `access_token=${encodeURIComponent(state.auth.token)}`
|
||||
return
|
||||
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}`
|
||||
const key = encodeURIComponent(state.auth.key);
|
||||
const secret = encodeURIComponent(state.auth.secret);
|
||||
options.url += `client_id=${key}&client_secret=${secret}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue