First upload version 0.0.1
This commit is contained in:
27
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
Normal file
27
node_modules/@octokit/auth-oauth-app/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
|
||||
async function hook(state, request, route, parameters) {
|
||||
let endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
||||
return request(endpoint);
|
||||
}
|
||||
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
|
||||
throw new Error(
|
||||
`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`
|
||||
);
|
||||
}
|
||||
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
||||
endpoint.headers.authorization = `basic ${credentials}`;
|
||||
try {
|
||||
return await request(endpoint);
|
||||
} catch (error) {
|
||||
if (error.status !== 401) throw error;
|
||||
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
Reference in New Issue
Block a user