First upload version 0.0.1
This commit is contained in:
49
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
Normal file
49
node_modules/@octokit/app/dist-src/webhooks.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
import { Webhooks } from "@octokit/webhooks";
|
||||
function webhooks(appOctokit, options) {
|
||||
return new Webhooks({
|
||||
secret: options.secret,
|
||||
transform: async (event) => {
|
||||
if (!("installation" in event.payload) || typeof event.payload.installation !== "object") {
|
||||
const octokit2 = new appOctokit.constructor({
|
||||
authStrategy: createUnauthenticatedAuth,
|
||||
auth: {
|
||||
reason: `"installation" key missing in webhook event payload`
|
||||
}
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit: octokit2
|
||||
};
|
||||
}
|
||||
const installationId = event.payload.installation.id;
|
||||
const octokit = await appOctokit.auth({
|
||||
type: "installation",
|
||||
installationId,
|
||||
factory(auth) {
|
||||
return new auth.octokit.constructor({
|
||||
...auth.octokitOptions,
|
||||
authStrategy: createAppAuth,
|
||||
...{
|
||||
auth: {
|
||||
...auth,
|
||||
installationId
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
octokit.hook.before("request", (options2) => {
|
||||
options2.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
return {
|
||||
...event,
|
||||
octokit
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
export {
|
||||
webhooks
|
||||
};
|
||||
Reference in New Issue
Block a user