@octokit/webhooks
Advanced tools
Comparing version 11.0.0-beta.7 to 11.0.0-beta.8
@@ -1,13 +0,46 @@ | ||
'use strict'; | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
// pkg/dist-src/index.js | ||
var dist_src_exports = {}; | ||
__export(dist_src_exports, { | ||
Webhooks: () => Webhooks, | ||
createEventHandler: () => createEventHandler, | ||
createNodeMiddleware: () => createNodeMiddleware, | ||
emitterEventNames: () => emitterEventNames | ||
}); | ||
module.exports = __toCommonJS(dist_src_exports); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var AggregateError = _interopDefault(require('aggregate-error')); | ||
var webhooksMethods = require('@octokit/webhooks-methods'); | ||
const createLogger = logger => ({ | ||
debug: () => {}, | ||
info: () => {}, | ||
// pkg/dist-src/createLogger.js | ||
var createLogger = (logger) => ({ | ||
debug: () => { | ||
}, | ||
info: () => { | ||
}, | ||
warn: console.warn.bind(console), | ||
@@ -18,6 +51,265 @@ error: console.error.bind(console), | ||
// THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY | ||
// make edits in scripts/generate-types.ts | ||
const emitterEventNames = ["branch_protection_rule", "branch_protection_rule.created", "branch_protection_rule.deleted", "branch_protection_rule.edited", "check_run", "check_run.completed", "check_run.created", "check_run.requested_action", "check_run.rerequested", "check_suite", "check_suite.completed", "check_suite.requested", "check_suite.rerequested", "code_scanning_alert", "code_scanning_alert.appeared_in_branch", "code_scanning_alert.closed_by_user", "code_scanning_alert.created", "code_scanning_alert.fixed", "code_scanning_alert.reopened", "code_scanning_alert.reopened_by_user", "commit_comment", "commit_comment.created", "create", "delete", "dependabot_alert", "dependabot_alert.created", "dependabot_alert.dismissed", "dependabot_alert.fixed", "dependabot_alert.reintroduced", "dependabot_alert.reopened", "deploy_key", "deploy_key.created", "deploy_key.deleted", "deployment", "deployment.created", "deployment_status", "deployment_status.created", "discussion", "discussion.answered", "discussion.category_changed", "discussion.created", "discussion.deleted", "discussion.edited", "discussion.labeled", "discussion.locked", "discussion.pinned", "discussion.transferred", "discussion.unanswered", "discussion.unlabeled", "discussion.unlocked", "discussion.unpinned", "discussion_comment", "discussion_comment.created", "discussion_comment.deleted", "discussion_comment.edited", "fork", "github_app_authorization", "github_app_authorization.revoked", "gollum", "installation", "installation.created", "installation.deleted", "installation.new_permissions_accepted", "installation.suspend", "installation.unsuspend", "installation_repositories", "installation_repositories.added", "installation_repositories.removed", "installation_target", "installation_target.renamed", "issue_comment", "issue_comment.created", "issue_comment.deleted", "issue_comment.edited", "issues", "issues.assigned", "issues.closed", "issues.deleted", "issues.demilestoned", "issues.edited", "issues.labeled", "issues.locked", "issues.milestoned", "issues.opened", "issues.pinned", "issues.reopened", "issues.transferred", "issues.unassigned", "issues.unlabeled", "issues.unlocked", "issues.unpinned", "label", "label.created", "label.deleted", "label.edited", "marketplace_purchase", "marketplace_purchase.cancelled", "marketplace_purchase.changed", "marketplace_purchase.pending_change", "marketplace_purchase.pending_change_cancelled", "marketplace_purchase.purchased", "member", "member.added", "member.edited", "member.removed", "membership", "membership.added", "membership.removed", "merge_group", "merge_group.checks_requested", "meta", "meta.deleted", "milestone", "milestone.closed", "milestone.created", "milestone.deleted", "milestone.edited", "milestone.opened", "org_block", "org_block.blocked", "org_block.unblocked", "organization", "organization.deleted", "organization.member_added", "organization.member_invited", "organization.member_removed", "organization.renamed", "package", "package.published", "package.updated", "page_build", "ping", "project", "project.closed", "project.created", "project.deleted", "project.edited", "project.reopened", "project_card", "project_card.converted", "project_card.created", "project_card.deleted", "project_card.edited", "project_card.moved", "project_column", "project_column.created", "project_column.deleted", "project_column.edited", "project_column.moved", "projects_v2_item", "projects_v2_item.archived", "projects_v2_item.converted", "projects_v2_item.created", "projects_v2_item.deleted", "projects_v2_item.edited", "projects_v2_item.reordered", "projects_v2_item.restored", "public", "pull_request", "pull_request.assigned", "pull_request.auto_merge_disabled", "pull_request.auto_merge_enabled", "pull_request.closed", "pull_request.converted_to_draft", "pull_request.dequeued", "pull_request.edited", "pull_request.labeled", "pull_request.locked", "pull_request.opened", "pull_request.queued", "pull_request.ready_for_review", "pull_request.reopened", "pull_request.review_request_removed", "pull_request.review_requested", "pull_request.synchronize", "pull_request.unassigned", "pull_request.unlabeled", "pull_request.unlocked", "pull_request_review", "pull_request_review.dismissed", "pull_request_review.edited", "pull_request_review.submitted", "pull_request_review_comment", "pull_request_review_comment.created", "pull_request_review_comment.deleted", "pull_request_review_comment.edited", "pull_request_review_thread", "pull_request_review_thread.resolved", "pull_request_review_thread.unresolved", "push", "registry_package", "registry_package.published", "registry_package.updated", "release", "release.created", "release.deleted", "release.edited", "release.prereleased", "release.published", "release.released", "release.unpublished", "repository", "repository.archived", "repository.created", "repository.deleted", "repository.edited", "repository.privatized", "repository.publicized", "repository.renamed", "repository.transferred", "repository.unarchived", "repository_dispatch", "repository_import", "repository_vulnerability_alert", "repository_vulnerability_alert.create", "repository_vulnerability_alert.dismiss", "repository_vulnerability_alert.reopen", "repository_vulnerability_alert.resolve", "secret_scanning_alert", "secret_scanning_alert.created", "secret_scanning_alert.reopened", "secret_scanning_alert.resolved", "security_advisory", "security_advisory.performed", "security_advisory.published", "security_advisory.updated", "security_advisory.withdrawn", "sponsorship", "sponsorship.cancelled", "sponsorship.created", "sponsorship.edited", "sponsorship.pending_cancellation", "sponsorship.pending_tier_change", "sponsorship.tier_changed", "star", "star.created", "star.deleted", "status", "team", "team.added_to_repository", "team.created", "team.deleted", "team.edited", "team.removed_from_repository", "team_add", "watch", "watch.started", "workflow_dispatch", "workflow_job", "workflow_job.completed", "workflow_job.in_progress", "workflow_job.queued", "workflow_run", "workflow_run.completed", "workflow_run.in_progress", "workflow_run.requested"]; | ||
// pkg/dist-src/generated/webhook-names.js | ||
var emitterEventNames = [ | ||
"branch_protection_rule", | ||
"branch_protection_rule.created", | ||
"branch_protection_rule.deleted", | ||
"branch_protection_rule.edited", | ||
"check_run", | ||
"check_run.completed", | ||
"check_run.created", | ||
"check_run.requested_action", | ||
"check_run.rerequested", | ||
"check_suite", | ||
"check_suite.completed", | ||
"check_suite.requested", | ||
"check_suite.rerequested", | ||
"code_scanning_alert", | ||
"code_scanning_alert.appeared_in_branch", | ||
"code_scanning_alert.closed_by_user", | ||
"code_scanning_alert.created", | ||
"code_scanning_alert.fixed", | ||
"code_scanning_alert.reopened", | ||
"code_scanning_alert.reopened_by_user", | ||
"commit_comment", | ||
"commit_comment.created", | ||
"create", | ||
"delete", | ||
"dependabot_alert", | ||
"dependabot_alert.created", | ||
"dependabot_alert.dismissed", | ||
"dependabot_alert.fixed", | ||
"dependabot_alert.reintroduced", | ||
"dependabot_alert.reopened", | ||
"deploy_key", | ||
"deploy_key.created", | ||
"deploy_key.deleted", | ||
"deployment", | ||
"deployment.created", | ||
"deployment_status", | ||
"deployment_status.created", | ||
"discussion", | ||
"discussion.answered", | ||
"discussion.category_changed", | ||
"discussion.created", | ||
"discussion.deleted", | ||
"discussion.edited", | ||
"discussion.labeled", | ||
"discussion.locked", | ||
"discussion.pinned", | ||
"discussion.transferred", | ||
"discussion.unanswered", | ||
"discussion.unlabeled", | ||
"discussion.unlocked", | ||
"discussion.unpinned", | ||
"discussion_comment", | ||
"discussion_comment.created", | ||
"discussion_comment.deleted", | ||
"discussion_comment.edited", | ||
"fork", | ||
"github_app_authorization", | ||
"github_app_authorization.revoked", | ||
"gollum", | ||
"installation", | ||
"installation.created", | ||
"installation.deleted", | ||
"installation.new_permissions_accepted", | ||
"installation.suspend", | ||
"installation.unsuspend", | ||
"installation_repositories", | ||
"installation_repositories.added", | ||
"installation_repositories.removed", | ||
"installation_target", | ||
"installation_target.renamed", | ||
"issue_comment", | ||
"issue_comment.created", | ||
"issue_comment.deleted", | ||
"issue_comment.edited", | ||
"issues", | ||
"issues.assigned", | ||
"issues.closed", | ||
"issues.deleted", | ||
"issues.demilestoned", | ||
"issues.edited", | ||
"issues.labeled", | ||
"issues.locked", | ||
"issues.milestoned", | ||
"issues.opened", | ||
"issues.pinned", | ||
"issues.reopened", | ||
"issues.transferred", | ||
"issues.unassigned", | ||
"issues.unlabeled", | ||
"issues.unlocked", | ||
"issues.unpinned", | ||
"label", | ||
"label.created", | ||
"label.deleted", | ||
"label.edited", | ||
"marketplace_purchase", | ||
"marketplace_purchase.cancelled", | ||
"marketplace_purchase.changed", | ||
"marketplace_purchase.pending_change", | ||
"marketplace_purchase.pending_change_cancelled", | ||
"marketplace_purchase.purchased", | ||
"member", | ||
"member.added", | ||
"member.edited", | ||
"member.removed", | ||
"membership", | ||
"membership.added", | ||
"membership.removed", | ||
"merge_group", | ||
"merge_group.checks_requested", | ||
"meta", | ||
"meta.deleted", | ||
"milestone", | ||
"milestone.closed", | ||
"milestone.created", | ||
"milestone.deleted", | ||
"milestone.edited", | ||
"milestone.opened", | ||
"org_block", | ||
"org_block.blocked", | ||
"org_block.unblocked", | ||
"organization", | ||
"organization.deleted", | ||
"organization.member_added", | ||
"organization.member_invited", | ||
"organization.member_removed", | ||
"organization.renamed", | ||
"package", | ||
"package.published", | ||
"package.updated", | ||
"page_build", | ||
"ping", | ||
"project", | ||
"project.closed", | ||
"project.created", | ||
"project.deleted", | ||
"project.edited", | ||
"project.reopened", | ||
"project_card", | ||
"project_card.converted", | ||
"project_card.created", | ||
"project_card.deleted", | ||
"project_card.edited", | ||
"project_card.moved", | ||
"project_column", | ||
"project_column.created", | ||
"project_column.deleted", | ||
"project_column.edited", | ||
"project_column.moved", | ||
"projects_v2_item", | ||
"projects_v2_item.archived", | ||
"projects_v2_item.converted", | ||
"projects_v2_item.created", | ||
"projects_v2_item.deleted", | ||
"projects_v2_item.edited", | ||
"projects_v2_item.reordered", | ||
"projects_v2_item.restored", | ||
"public", | ||
"pull_request", | ||
"pull_request.assigned", | ||
"pull_request.auto_merge_disabled", | ||
"pull_request.auto_merge_enabled", | ||
"pull_request.closed", | ||
"pull_request.converted_to_draft", | ||
"pull_request.demilestoned", | ||
"pull_request.dequeued", | ||
"pull_request.edited", | ||
"pull_request.labeled", | ||
"pull_request.locked", | ||
"pull_request.milestoned", | ||
"pull_request.opened", | ||
"pull_request.queued", | ||
"pull_request.ready_for_review", | ||
"pull_request.reopened", | ||
"pull_request.review_request_removed", | ||
"pull_request.review_requested", | ||
"pull_request.synchronize", | ||
"pull_request.unassigned", | ||
"pull_request.unlabeled", | ||
"pull_request.unlocked", | ||
"pull_request_review", | ||
"pull_request_review.dismissed", | ||
"pull_request_review.edited", | ||
"pull_request_review.submitted", | ||
"pull_request_review_comment", | ||
"pull_request_review_comment.created", | ||
"pull_request_review_comment.deleted", | ||
"pull_request_review_comment.edited", | ||
"pull_request_review_thread", | ||
"pull_request_review_thread.resolved", | ||
"pull_request_review_thread.unresolved", | ||
"push", | ||
"registry_package", | ||
"registry_package.published", | ||
"registry_package.updated", | ||
"release", | ||
"release.created", | ||
"release.deleted", | ||
"release.edited", | ||
"release.prereleased", | ||
"release.published", | ||
"release.released", | ||
"release.unpublished", | ||
"repository", | ||
"repository.archived", | ||
"repository.created", | ||
"repository.deleted", | ||
"repository.edited", | ||
"repository.privatized", | ||
"repository.publicized", | ||
"repository.renamed", | ||
"repository.transferred", | ||
"repository.unarchived", | ||
"repository_dispatch", | ||
"repository_import", | ||
"repository_vulnerability_alert", | ||
"repository_vulnerability_alert.create", | ||
"repository_vulnerability_alert.dismiss", | ||
"repository_vulnerability_alert.reopen", | ||
"repository_vulnerability_alert.resolve", | ||
"secret_scanning_alert", | ||
"secret_scanning_alert.created", | ||
"secret_scanning_alert.reopened", | ||
"secret_scanning_alert.resolved", | ||
"security_advisory", | ||
"security_advisory.performed", | ||
"security_advisory.published", | ||
"security_advisory.updated", | ||
"security_advisory.withdrawn", | ||
"sponsorship", | ||
"sponsorship.cancelled", | ||
"sponsorship.created", | ||
"sponsorship.edited", | ||
"sponsorship.pending_cancellation", | ||
"sponsorship.pending_tier_change", | ||
"sponsorship.tier_changed", | ||
"star", | ||
"star.created", | ||
"star.deleted", | ||
"status", | ||
"team", | ||
"team.added_to_repository", | ||
"team.created", | ||
"team.deleted", | ||
"team.edited", | ||
"team.removed_from_repository", | ||
"team_add", | ||
"watch", | ||
"watch.started", | ||
"workflow_dispatch", | ||
"workflow_job", | ||
"workflow_job.completed", | ||
"workflow_job.in_progress", | ||
"workflow_job.queued", | ||
"workflow_run", | ||
"workflow_run.completed", | ||
"workflow_run.in_progress", | ||
"workflow_run.requested" | ||
]; | ||
// pkg/dist-src/event-handler/on.js | ||
function handleEventHandlers(state, webhookName, handler) { | ||
@@ -31,3 +323,5 @@ if (!state.hooks[webhookName]) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach(webhookName => receiverOn(state, webhookName, handler)); | ||
webhookNameOrNames.forEach( | ||
(webhookName) => receiverOn(state, webhookName, handler) | ||
); | ||
return; | ||
@@ -41,3 +335,5 @@ } | ||
if (!emitterEventNames.includes(webhookNameOrNames)) { | ||
state.log.warn(`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`); | ||
state.log.warn( | ||
`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)` | ||
); | ||
} | ||
@@ -53,5 +349,6 @@ handleEventHandlers(state, webhookNameOrNames, handler); | ||
// Errors thrown or rejected Promises in "error" event handlers are not handled | ||
// as they are in the webhook event handlers. If errors occur, we log a | ||
// "Fatal: Error occurred" message to stdout | ||
// pkg/dist-src/event-handler/receive.js | ||
var import_aggregate_error = __toESM(require("aggregate-error")); | ||
// pkg/dist-src/event-handler/wrap-error-handler.js | ||
function wrapErrorHandler(handler, error) { | ||
@@ -61,10 +358,10 @@ let returnValue; | ||
returnValue = handler(error); | ||
} catch (error) { | ||
} catch (error2) { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
console.log(error2); | ||
} | ||
if (returnValue && returnValue.catch) { | ||
returnValue.catch(error => { | ||
returnValue.catch((error2) => { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
console.log(error2); | ||
}); | ||
@@ -74,3 +371,3 @@ } | ||
// @ts-ignore to address #245 | ||
// pkg/dist-src/event-handler/receive.js | ||
function getHooks(state, eventPayloadAction, eventName) { | ||
@@ -83,21 +380,23 @@ const hooks = [state.hooks[eventName], state.hooks["*"]]; | ||
} | ||
// main handler function | ||
function receiverHandle(state, event) { | ||
const errorHandlers = state.hooks.error || []; | ||
if (event instanceof Error) { | ||
const error = Object.assign(new AggregateError([event]), { | ||
const error = Object.assign(new import_aggregate_error.default([event]), { | ||
event, | ||
errors: [event] | ||
}); | ||
errorHandlers.forEach(handler => wrapErrorHandler(handler, error)); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
return Promise.reject(error); | ||
} | ||
if (!event || !event.name) { | ||
throw new AggregateError(["Event name not passed"]); | ||
throw new import_aggregate_error.default(["Event name not passed"]); | ||
} | ||
if (!event.payload) { | ||
throw new AggregateError(["Event payload not passed"]); | ||
throw new import_aggregate_error.default(["Event payload not passed"]); | ||
} | ||
// flatten arrays of event listeners and remove undefined values | ||
const hooks = getHooks(state, "action" in event.payload ? event.payload.action : null, event.name); | ||
const hooks = getHooks( | ||
state, | ||
"action" in event.payload ? event.payload.action : null, | ||
event.name | ||
); | ||
if (hooks.length === 0) { | ||
@@ -107,3 +406,3 @@ return Promise.resolve(); | ||
const errors = []; | ||
const promises = hooks.map(handler => { | ||
const promises = hooks.map((handler) => { | ||
let promise = Promise.resolve(event); | ||
@@ -113,7 +412,5 @@ if (state.transform) { | ||
} | ||
return promise.then(event => { | ||
return handler(event); | ||
}).catch(error => errors.push(Object.assign(error, { | ||
event | ||
}))); | ||
return promise.then((event2) => { | ||
return handler(event2); | ||
}).catch((error) => errors.push(Object.assign(error, { event }))); | ||
}); | ||
@@ -124,3 +421,3 @@ return Promise.all(promises).then(() => { | ||
} | ||
const error = new AggregateError(errors); | ||
const error = new import_aggregate_error.default(errors); | ||
Object.assign(error, { | ||
@@ -130,3 +427,3 @@ event, | ||
}); | ||
errorHandlers.forEach(handler => wrapErrorHandler(handler, error)); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
throw error; | ||
@@ -136,5 +433,8 @@ }); | ||
// pkg/dist-src/event-handler/remove-listener.js | ||
function removeListener(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach(webhookName => removeListener(state, webhookName, handler)); | ||
webhookNameOrNames.forEach( | ||
(webhookName) => removeListener(state, webhookName, handler) | ||
); | ||
return; | ||
@@ -145,4 +445,2 @@ } | ||
} | ||
// remove last hook that has been added, that way | ||
// it behaves the same as removeListener | ||
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { | ||
@@ -156,2 +454,3 @@ if (state.hooks[webhookNameOrNames][i] === handler) { | ||
// pkg/dist-src/event-handler/index.js | ||
function createEventHandler(options) { | ||
@@ -174,11 +473,20 @@ const state = { | ||
// pkg/dist-src/index.js | ||
var import_webhooks_methods2 = require("@octokit/webhooks-methods"); | ||
// pkg/dist-src/verify-and-receive.js | ||
var import_webhooks_methods = require("@octokit/webhooks-methods"); | ||
async function verifyAndReceive(state, event) { | ||
// verify will validate that the secret is not undefined | ||
const matchesSignature = await webhooksMethods.verify(state.secret, event.payload, event.signature); | ||
const matchesSignature = await (0, import_webhooks_methods.verify)( | ||
state.secret, | ||
event.payload, | ||
event.signature | ||
); | ||
if (!matchesSignature) { | ||
const error = new Error("[@octokit/webhooks] signature does not match event payload and secret"); | ||
return state.eventHandler.receive(Object.assign(error, { | ||
event, | ||
status: 400 | ||
})); | ||
const error = new Error( | ||
"[@octokit/webhooks] signature does not match event payload and secret" | ||
); | ||
return state.eventHandler.receive( | ||
Object.assign(error, { event, status: 400 }) | ||
); | ||
} | ||
@@ -192,22 +500,24 @@ return state.eventHandler.receive({ | ||
const WEBHOOK_HEADERS = ["x-github-event", "x-hub-signature-256", "x-github-delivery"]; | ||
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers | ||
// pkg/dist-src/middleware/node/get-missing-headers.js | ||
var WEBHOOK_HEADERS = [ | ||
"x-github-event", | ||
"x-hub-signature-256", | ||
"x-github-delivery" | ||
]; | ||
function getMissingHeaders(request) { | ||
return WEBHOOK_HEADERS.filter(header => !(header in request.headers)); | ||
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); | ||
} | ||
// @ts-ignore to address #245 | ||
// pkg/dist-src/middleware/node/get-payload.js | ||
var import_aggregate_error2 = __toESM(require("aggregate-error")); | ||
function getPayload(request) { | ||
// If request.body already exists we can stop here | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) return Promise.resolve(request.body); | ||
if (request.body) | ||
return Promise.resolve(request.body); | ||
return new Promise((resolve, reject) => { | ||
let data = ""; | ||
request.setEncoding("utf8"); | ||
// istanbul ignore next | ||
request.on("error", error => reject(new AggregateError([error]))); | ||
request.on("data", chunk => data += chunk); | ||
request.on("error", (error) => reject(new import_aggregate_error2.default([error]))); | ||
request.on("data", (chunk) => data += chunk); | ||
request.on("end", () => { | ||
try { | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
@@ -218,3 +528,3 @@ resolve(data); | ||
error.status = 400; | ||
reject(new AggregateError([error])); | ||
reject(new import_aggregate_error2.default([error])); | ||
} | ||
@@ -225,2 +535,3 @@ }); | ||
// pkg/dist-src/middleware/node/on-unhandled-request-default.js | ||
function onUnhandledRequestDefault(request, response) { | ||
@@ -230,7 +541,10 @@ response.writeHead(404, { | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}` | ||
})); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}` | ||
}) | ||
); | ||
} | ||
// pkg/dist-src/middleware/node/middleware.js | ||
async function middleware(webhooks, options, request, response, next) { | ||
@@ -244,9 +558,11 @@ let pathname; | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}` | ||
})); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}` | ||
}) | ||
); | ||
return true; | ||
} | ||
if (pathname !== options.path) { | ||
next === null || next === void 0 ? void 0 : next(); | ||
next == null ? void 0 : next(); | ||
return false; | ||
@@ -257,5 +573,2 @@ } else if (request.method !== "POST") { | ||
} | ||
// Check if the Content-Type header is `application/json` and allow for charset to be specified in it | ||
// Otherwise, return a 415 Unsupported Media Type error | ||
// See https://github.com/octokit/webhooks.js/issues/158 | ||
if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) { | ||
@@ -266,5 +579,7 @@ response.writeHead(415, { | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"` | ||
})); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"` | ||
}) | ||
); | ||
return true; | ||
@@ -277,5 +592,7 @@ } | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}` | ||
})); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}` | ||
}) | ||
); | ||
return true; | ||
@@ -287,4 +604,2 @@ } | ||
options.log.debug(`${eventName} event received (id: ${id})`); | ||
// GitHub will abort the request if it does not receive a response within 10s | ||
// See https://github.com/octokit/webhooks.js/issues/185 | ||
let didTimeout = false; | ||
@@ -295,7 +610,7 @@ const timeout = setTimeout(() => { | ||
response.end("still processing\n"); | ||
}, 9000).unref(); | ||
}, 9e3).unref(); | ||
try { | ||
const payload = await getPayload(request); | ||
await webhooks.verifyAndReceive({ | ||
id: id, | ||
id, | ||
name: eventName, | ||
@@ -306,3 +621,4 @@ payload, | ||
clearTimeout(timeout); | ||
if (didTimeout) return true; | ||
if (didTimeout) | ||
return true; | ||
response.end("ok\n"); | ||
@@ -312,3 +628,4 @@ return true; | ||
clearTimeout(timeout); | ||
if (didTimeout) return true; | ||
if (didTimeout) | ||
return true; | ||
const err = Array.from(error)[0]; | ||
@@ -318,5 +635,7 @@ const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred"; | ||
options.log.error(error); | ||
response.end(JSON.stringify({ | ||
error: errorMessage | ||
})); | ||
response.end( | ||
JSON.stringify({ | ||
error: errorMessage | ||
}) | ||
); | ||
return true; | ||
@@ -326,2 +645,3 @@ } | ||
// pkg/dist-src/middleware/node/index.js | ||
function createNodeMiddleware(webhooks, { | ||
@@ -337,4 +657,4 @@ path = "/api/github/webhooks", | ||
// U holds the return value of `transform` function in Options | ||
class Webhooks { | ||
// pkg/dist-src/index.js | ||
var Webhooks = class { | ||
constructor(options) { | ||
@@ -350,4 +670,4 @@ if (!options || !options.secret) { | ||
}; | ||
this.sign = webhooksMethods.sign.bind(null, options.secret); | ||
this.verify = webhooksMethods.verify.bind(null, options.secret); | ||
this.sign = import_webhooks_methods2.sign.bind(null, options.secret); | ||
this.verify = import_webhooks_methods2.verify.bind(null, options.secret); | ||
this.on = state.eventHandler.on; | ||
@@ -360,8 +680,9 @@ this.onAny = state.eventHandler.onAny; | ||
} | ||
} | ||
exports.Webhooks = Webhooks; | ||
exports.createEventHandler = createEventHandler; | ||
exports.createNodeMiddleware = createNodeMiddleware; | ||
exports.emitterEventNames = emitterEventNames; | ||
//# sourceMappingURL=index.js.map | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Webhooks, | ||
createEventHandler, | ||
createNodeMiddleware, | ||
emitterEventNames | ||
}); |
@@ -1,7 +0,12 @@ | ||
export const createLogger = (logger) => ({ | ||
debug: () => { }, | ||
info: () => { }, | ||
warn: console.warn.bind(console), | ||
error: console.error.bind(console), | ||
...logger, | ||
const createLogger = (logger) => ({ | ||
debug: () => { | ||
}, | ||
info: () => { | ||
}, | ||
warn: console.warn.bind(console), | ||
error: console.error.bind(console), | ||
...logger | ||
}); | ||
export { | ||
createLogger | ||
}; |
import { createLogger } from "../createLogger"; | ||
import { receiverOn as on, receiverOnAny as onAny, receiverOnError as onError, } from "./on"; | ||
import { | ||
receiverOn as on, | ||
receiverOnAny as onAny, | ||
receiverOnError as onError | ||
} from "./on"; | ||
import { receiverHandle as receive } from "./receive"; | ||
import { removeListener } from "./remove-listener"; | ||
export function createEventHandler(options) { | ||
const state = { | ||
hooks: {}, | ||
log: createLogger(options && options.log), | ||
}; | ||
if (options && options.transform) { | ||
state.transform = options.transform; | ||
} | ||
return { | ||
on: on.bind(null, state), | ||
onAny: onAny.bind(null, state), | ||
onError: onError.bind(null, state), | ||
removeListener: removeListener.bind(null, state), | ||
receive: receive.bind(null, state), | ||
}; | ||
function createEventHandler(options) { | ||
const state = { | ||
hooks: {}, | ||
log: createLogger(options && options.log) | ||
}; | ||
if (options && options.transform) { | ||
state.transform = options.transform; | ||
} | ||
return { | ||
on: on.bind(null, state), | ||
onAny: onAny.bind(null, state), | ||
onError: onError.bind(null, state), | ||
removeListener: removeListener.bind(null, state), | ||
receive: receive.bind(null, state) | ||
}; | ||
} | ||
export { | ||
createEventHandler | ||
}; |
import { emitterEventNames } from "../generated/webhook-names"; | ||
function handleEventHandlers(state, webhookName, handler) { | ||
if (!state.hooks[webhookName]) { | ||
state.hooks[webhookName] = []; | ||
} | ||
state.hooks[webhookName].push(handler); | ||
if (!state.hooks[webhookName]) { | ||
state.hooks[webhookName] = []; | ||
} | ||
state.hooks[webhookName].push(handler); | ||
} | ||
export function receiverOn(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach((webhookName) => receiverOn(state, webhookName, handler)); | ||
return; | ||
} | ||
if (["*", "error"].includes(webhookNameOrNames)) { | ||
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; | ||
const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; | ||
throw new Error(message); | ||
} | ||
if (!emitterEventNames.includes(webhookNameOrNames)) { | ||
state.log.warn(`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`); | ||
} | ||
handleEventHandlers(state, webhookNameOrNames, handler); | ||
function receiverOn(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach( | ||
(webhookName) => receiverOn(state, webhookName, handler) | ||
); | ||
return; | ||
} | ||
if (["*", "error"].includes(webhookNameOrNames)) { | ||
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; | ||
const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; | ||
throw new Error(message); | ||
} | ||
if (!emitterEventNames.includes(webhookNameOrNames)) { | ||
state.log.warn( | ||
`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)` | ||
); | ||
} | ||
handleEventHandlers(state, webhookNameOrNames, handler); | ||
} | ||
export function receiverOnAny(state, handler) { | ||
handleEventHandlers(state, "*", handler); | ||
function receiverOnAny(state, handler) { | ||
handleEventHandlers(state, "*", handler); | ||
} | ||
export function receiverOnError(state, handler) { | ||
handleEventHandlers(state, "error", handler); | ||
function receiverOnError(state, handler) { | ||
handleEventHandlers(state, "error", handler); | ||
} | ||
export { | ||
receiverOn, | ||
receiverOnAny, | ||
receiverOnError | ||
}; |
@@ -1,57 +0,59 @@ | ||
// @ts-ignore to address #245 | ||
import AggregateError from "aggregate-error"; | ||
import { wrapErrorHandler } from "./wrap-error-handler"; | ||
function getHooks(state, eventPayloadAction, eventName) { | ||
const hooks = [state.hooks[eventName], state.hooks["*"]]; | ||
if (eventPayloadAction) { | ||
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); | ||
} | ||
return [].concat(...hooks.filter(Boolean)); | ||
const hooks = [state.hooks[eventName], state.hooks["*"]]; | ||
if (eventPayloadAction) { | ||
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); | ||
} | ||
return [].concat(...hooks.filter(Boolean)); | ||
} | ||
// main handler function | ||
export function receiverHandle(state, event) { | ||
const errorHandlers = state.hooks.error || []; | ||
if (event instanceof Error) { | ||
const error = Object.assign(new AggregateError([event]), { | ||
event, | ||
errors: [event], | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
return Promise.reject(error); | ||
function receiverHandle(state, event) { | ||
const errorHandlers = state.hooks.error || []; | ||
if (event instanceof Error) { | ||
const error = Object.assign(new AggregateError([event]), { | ||
event, | ||
errors: [event] | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
return Promise.reject(error); | ||
} | ||
if (!event || !event.name) { | ||
throw new AggregateError(["Event name not passed"]); | ||
} | ||
if (!event.payload) { | ||
throw new AggregateError(["Event payload not passed"]); | ||
} | ||
const hooks = getHooks( | ||
state, | ||
"action" in event.payload ? event.payload.action : null, | ||
event.name | ||
); | ||
if (hooks.length === 0) { | ||
return Promise.resolve(); | ||
} | ||
const errors = []; | ||
const promises = hooks.map((handler) => { | ||
let promise = Promise.resolve(event); | ||
if (state.transform) { | ||
promise = promise.then(state.transform); | ||
} | ||
if (!event || !event.name) { | ||
throw new AggregateError(["Event name not passed"]); | ||
return promise.then((event2) => { | ||
return handler(event2); | ||
}).catch((error) => errors.push(Object.assign(error, { event }))); | ||
}); | ||
return Promise.all(promises).then(() => { | ||
if (errors.length === 0) { | ||
return; | ||
} | ||
if (!event.payload) { | ||
throw new AggregateError(["Event payload not passed"]); | ||
} | ||
// flatten arrays of event listeners and remove undefined values | ||
const hooks = getHooks(state, "action" in event.payload ? event.payload.action : null, event.name); | ||
if (hooks.length === 0) { | ||
return Promise.resolve(); | ||
} | ||
const errors = []; | ||
const promises = hooks.map((handler) => { | ||
let promise = Promise.resolve(event); | ||
if (state.transform) { | ||
promise = promise.then(state.transform); | ||
} | ||
return promise | ||
.then((event) => { | ||
return handler(event); | ||
}) | ||
.catch((error) => errors.push(Object.assign(error, { event }))); | ||
const error = new AggregateError(errors); | ||
Object.assign(error, { | ||
event, | ||
errors | ||
}); | ||
return Promise.all(promises).then(() => { | ||
if (errors.length === 0) { | ||
return; | ||
} | ||
const error = new AggregateError(errors); | ||
Object.assign(error, { | ||
event, | ||
errors, | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
throw error; | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
throw error; | ||
}); | ||
} | ||
export { | ||
receiverHandle | ||
}; |
@@ -1,17 +0,20 @@ | ||
export function removeListener(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach((webhookName) => removeListener(state, webhookName, handler)); | ||
return; | ||
function removeListener(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach( | ||
(webhookName) => removeListener(state, webhookName, handler) | ||
); | ||
return; | ||
} | ||
if (!state.hooks[webhookNameOrNames]) { | ||
return; | ||
} | ||
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { | ||
if (state.hooks[webhookNameOrNames][i] === handler) { | ||
state.hooks[webhookNameOrNames].splice(i, 1); | ||
return; | ||
} | ||
if (!state.hooks[webhookNameOrNames]) { | ||
return; | ||
} | ||
// remove last hook that has been added, that way | ||
// it behaves the same as removeListener | ||
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { | ||
if (state.hooks[webhookNameOrNames][i] === handler) { | ||
state.hooks[webhookNameOrNames].splice(i, 1); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
export { | ||
removeListener | ||
}; |
@@ -1,19 +0,18 @@ | ||
// Errors thrown or rejected Promises in "error" event handlers are not handled | ||
// as they are in the webhook event handlers. If errors occur, we log a | ||
// "Fatal: Error occurred" message to stdout | ||
export function wrapErrorHandler(handler, error) { | ||
let returnValue; | ||
try { | ||
returnValue = handler(error); | ||
} | ||
catch (error) { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
} | ||
if (returnValue && returnValue.catch) { | ||
returnValue.catch((error) => { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
}); | ||
} | ||
function wrapErrorHandler(handler, error) { | ||
let returnValue; | ||
try { | ||
returnValue = handler(error); | ||
} catch (error2) { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error2); | ||
} | ||
if (returnValue && returnValue.catch) { | ||
returnValue.catch((error2) => { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error2); | ||
}); | ||
} | ||
} | ||
export { | ||
wrapErrorHandler | ||
}; |
@@ -1,260 +0,263 @@ | ||
// THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY | ||
// make edits in scripts/generate-types.ts | ||
export const emitterEventNames = [ | ||
"branch_protection_rule", | ||
"branch_protection_rule.created", | ||
"branch_protection_rule.deleted", | ||
"branch_protection_rule.edited", | ||
"check_run", | ||
"check_run.completed", | ||
"check_run.created", | ||
"check_run.requested_action", | ||
"check_run.rerequested", | ||
"check_suite", | ||
"check_suite.completed", | ||
"check_suite.requested", | ||
"check_suite.rerequested", | ||
"code_scanning_alert", | ||
"code_scanning_alert.appeared_in_branch", | ||
"code_scanning_alert.closed_by_user", | ||
"code_scanning_alert.created", | ||
"code_scanning_alert.fixed", | ||
"code_scanning_alert.reopened", | ||
"code_scanning_alert.reopened_by_user", | ||
"commit_comment", | ||
"commit_comment.created", | ||
"create", | ||
"delete", | ||
"dependabot_alert", | ||
"dependabot_alert.created", | ||
"dependabot_alert.dismissed", | ||
"dependabot_alert.fixed", | ||
"dependabot_alert.reintroduced", | ||
"dependabot_alert.reopened", | ||
"deploy_key", | ||
"deploy_key.created", | ||
"deploy_key.deleted", | ||
"deployment", | ||
"deployment.created", | ||
"deployment_status", | ||
"deployment_status.created", | ||
"discussion", | ||
"discussion.answered", | ||
"discussion.category_changed", | ||
"discussion.created", | ||
"discussion.deleted", | ||
"discussion.edited", | ||
"discussion.labeled", | ||
"discussion.locked", | ||
"discussion.pinned", | ||
"discussion.transferred", | ||
"discussion.unanswered", | ||
"discussion.unlabeled", | ||
"discussion.unlocked", | ||
"discussion.unpinned", | ||
"discussion_comment", | ||
"discussion_comment.created", | ||
"discussion_comment.deleted", | ||
"discussion_comment.edited", | ||
"fork", | ||
"github_app_authorization", | ||
"github_app_authorization.revoked", | ||
"gollum", | ||
"installation", | ||
"installation.created", | ||
"installation.deleted", | ||
"installation.new_permissions_accepted", | ||
"installation.suspend", | ||
"installation.unsuspend", | ||
"installation_repositories", | ||
"installation_repositories.added", | ||
"installation_repositories.removed", | ||
"installation_target", | ||
"installation_target.renamed", | ||
"issue_comment", | ||
"issue_comment.created", | ||
"issue_comment.deleted", | ||
"issue_comment.edited", | ||
"issues", | ||
"issues.assigned", | ||
"issues.closed", | ||
"issues.deleted", | ||
"issues.demilestoned", | ||
"issues.edited", | ||
"issues.labeled", | ||
"issues.locked", | ||
"issues.milestoned", | ||
"issues.opened", | ||
"issues.pinned", | ||
"issues.reopened", | ||
"issues.transferred", | ||
"issues.unassigned", | ||
"issues.unlabeled", | ||
"issues.unlocked", | ||
"issues.unpinned", | ||
"label", | ||
"label.created", | ||
"label.deleted", | ||
"label.edited", | ||
"marketplace_purchase", | ||
"marketplace_purchase.cancelled", | ||
"marketplace_purchase.changed", | ||
"marketplace_purchase.pending_change", | ||
"marketplace_purchase.pending_change_cancelled", | ||
"marketplace_purchase.purchased", | ||
"member", | ||
"member.added", | ||
"member.edited", | ||
"member.removed", | ||
"membership", | ||
"membership.added", | ||
"membership.removed", | ||
"merge_group", | ||
"merge_group.checks_requested", | ||
"meta", | ||
"meta.deleted", | ||
"milestone", | ||
"milestone.closed", | ||
"milestone.created", | ||
"milestone.deleted", | ||
"milestone.edited", | ||
"milestone.opened", | ||
"org_block", | ||
"org_block.blocked", | ||
"org_block.unblocked", | ||
"organization", | ||
"organization.deleted", | ||
"organization.member_added", | ||
"organization.member_invited", | ||
"organization.member_removed", | ||
"organization.renamed", | ||
"package", | ||
"package.published", | ||
"package.updated", | ||
"page_build", | ||
"ping", | ||
"project", | ||
"project.closed", | ||
"project.created", | ||
"project.deleted", | ||
"project.edited", | ||
"project.reopened", | ||
"project_card", | ||
"project_card.converted", | ||
"project_card.created", | ||
"project_card.deleted", | ||
"project_card.edited", | ||
"project_card.moved", | ||
"project_column", | ||
"project_column.created", | ||
"project_column.deleted", | ||
"project_column.edited", | ||
"project_column.moved", | ||
"projects_v2_item", | ||
"projects_v2_item.archived", | ||
"projects_v2_item.converted", | ||
"projects_v2_item.created", | ||
"projects_v2_item.deleted", | ||
"projects_v2_item.edited", | ||
"projects_v2_item.reordered", | ||
"projects_v2_item.restored", | ||
"public", | ||
"pull_request", | ||
"pull_request.assigned", | ||
"pull_request.auto_merge_disabled", | ||
"pull_request.auto_merge_enabled", | ||
"pull_request.closed", | ||
"pull_request.converted_to_draft", | ||
"pull_request.dequeued", | ||
"pull_request.edited", | ||
"pull_request.labeled", | ||
"pull_request.locked", | ||
"pull_request.opened", | ||
"pull_request.queued", | ||
"pull_request.ready_for_review", | ||
"pull_request.reopened", | ||
"pull_request.review_request_removed", | ||
"pull_request.review_requested", | ||
"pull_request.synchronize", | ||
"pull_request.unassigned", | ||
"pull_request.unlabeled", | ||
"pull_request.unlocked", | ||
"pull_request_review", | ||
"pull_request_review.dismissed", | ||
"pull_request_review.edited", | ||
"pull_request_review.submitted", | ||
"pull_request_review_comment", | ||
"pull_request_review_comment.created", | ||
"pull_request_review_comment.deleted", | ||
"pull_request_review_comment.edited", | ||
"pull_request_review_thread", | ||
"pull_request_review_thread.resolved", | ||
"pull_request_review_thread.unresolved", | ||
"push", | ||
"registry_package", | ||
"registry_package.published", | ||
"registry_package.updated", | ||
"release", | ||
"release.created", | ||
"release.deleted", | ||
"release.edited", | ||
"release.prereleased", | ||
"release.published", | ||
"release.released", | ||
"release.unpublished", | ||
"repository", | ||
"repository.archived", | ||
"repository.created", | ||
"repository.deleted", | ||
"repository.edited", | ||
"repository.privatized", | ||
"repository.publicized", | ||
"repository.renamed", | ||
"repository.transferred", | ||
"repository.unarchived", | ||
"repository_dispatch", | ||
"repository_import", | ||
"repository_vulnerability_alert", | ||
"repository_vulnerability_alert.create", | ||
"repository_vulnerability_alert.dismiss", | ||
"repository_vulnerability_alert.reopen", | ||
"repository_vulnerability_alert.resolve", | ||
"secret_scanning_alert", | ||
"secret_scanning_alert.created", | ||
"secret_scanning_alert.reopened", | ||
"secret_scanning_alert.resolved", | ||
"security_advisory", | ||
"security_advisory.performed", | ||
"security_advisory.published", | ||
"security_advisory.updated", | ||
"security_advisory.withdrawn", | ||
"sponsorship", | ||
"sponsorship.cancelled", | ||
"sponsorship.created", | ||
"sponsorship.edited", | ||
"sponsorship.pending_cancellation", | ||
"sponsorship.pending_tier_change", | ||
"sponsorship.tier_changed", | ||
"star", | ||
"star.created", | ||
"star.deleted", | ||
"status", | ||
"team", | ||
"team.added_to_repository", | ||
"team.created", | ||
"team.deleted", | ||
"team.edited", | ||
"team.removed_from_repository", | ||
"team_add", | ||
"watch", | ||
"watch.started", | ||
"workflow_dispatch", | ||
"workflow_job", | ||
"workflow_job.completed", | ||
"workflow_job.in_progress", | ||
"workflow_job.queued", | ||
"workflow_run", | ||
"workflow_run.completed", | ||
"workflow_run.in_progress", | ||
"workflow_run.requested", | ||
const emitterEventNames = [ | ||
"branch_protection_rule", | ||
"branch_protection_rule.created", | ||
"branch_protection_rule.deleted", | ||
"branch_protection_rule.edited", | ||
"check_run", | ||
"check_run.completed", | ||
"check_run.created", | ||
"check_run.requested_action", | ||
"check_run.rerequested", | ||
"check_suite", | ||
"check_suite.completed", | ||
"check_suite.requested", | ||
"check_suite.rerequested", | ||
"code_scanning_alert", | ||
"code_scanning_alert.appeared_in_branch", | ||
"code_scanning_alert.closed_by_user", | ||
"code_scanning_alert.created", | ||
"code_scanning_alert.fixed", | ||
"code_scanning_alert.reopened", | ||
"code_scanning_alert.reopened_by_user", | ||
"commit_comment", | ||
"commit_comment.created", | ||
"create", | ||
"delete", | ||
"dependabot_alert", | ||
"dependabot_alert.created", | ||
"dependabot_alert.dismissed", | ||
"dependabot_alert.fixed", | ||
"dependabot_alert.reintroduced", | ||
"dependabot_alert.reopened", | ||
"deploy_key", | ||
"deploy_key.created", | ||
"deploy_key.deleted", | ||
"deployment", | ||
"deployment.created", | ||
"deployment_status", | ||
"deployment_status.created", | ||
"discussion", | ||
"discussion.answered", | ||
"discussion.category_changed", | ||
"discussion.created", | ||
"discussion.deleted", | ||
"discussion.edited", | ||
"discussion.labeled", | ||
"discussion.locked", | ||
"discussion.pinned", | ||
"discussion.transferred", | ||
"discussion.unanswered", | ||
"discussion.unlabeled", | ||
"discussion.unlocked", | ||
"discussion.unpinned", | ||
"discussion_comment", | ||
"discussion_comment.created", | ||
"discussion_comment.deleted", | ||
"discussion_comment.edited", | ||
"fork", | ||
"github_app_authorization", | ||
"github_app_authorization.revoked", | ||
"gollum", | ||
"installation", | ||
"installation.created", | ||
"installation.deleted", | ||
"installation.new_permissions_accepted", | ||
"installation.suspend", | ||
"installation.unsuspend", | ||
"installation_repositories", | ||
"installation_repositories.added", | ||
"installation_repositories.removed", | ||
"installation_target", | ||
"installation_target.renamed", | ||
"issue_comment", | ||
"issue_comment.created", | ||
"issue_comment.deleted", | ||
"issue_comment.edited", | ||
"issues", | ||
"issues.assigned", | ||
"issues.closed", | ||
"issues.deleted", | ||
"issues.demilestoned", | ||
"issues.edited", | ||
"issues.labeled", | ||
"issues.locked", | ||
"issues.milestoned", | ||
"issues.opened", | ||
"issues.pinned", | ||
"issues.reopened", | ||
"issues.transferred", | ||
"issues.unassigned", | ||
"issues.unlabeled", | ||
"issues.unlocked", | ||
"issues.unpinned", | ||
"label", | ||
"label.created", | ||
"label.deleted", | ||
"label.edited", | ||
"marketplace_purchase", | ||
"marketplace_purchase.cancelled", | ||
"marketplace_purchase.changed", | ||
"marketplace_purchase.pending_change", | ||
"marketplace_purchase.pending_change_cancelled", | ||
"marketplace_purchase.purchased", | ||
"member", | ||
"member.added", | ||
"member.edited", | ||
"member.removed", | ||
"membership", | ||
"membership.added", | ||
"membership.removed", | ||
"merge_group", | ||
"merge_group.checks_requested", | ||
"meta", | ||
"meta.deleted", | ||
"milestone", | ||
"milestone.closed", | ||
"milestone.created", | ||
"milestone.deleted", | ||
"milestone.edited", | ||
"milestone.opened", | ||
"org_block", | ||
"org_block.blocked", | ||
"org_block.unblocked", | ||
"organization", | ||
"organization.deleted", | ||
"organization.member_added", | ||
"organization.member_invited", | ||
"organization.member_removed", | ||
"organization.renamed", | ||
"package", | ||
"package.published", | ||
"package.updated", | ||
"page_build", | ||
"ping", | ||
"project", | ||
"project.closed", | ||
"project.created", | ||
"project.deleted", | ||
"project.edited", | ||
"project.reopened", | ||
"project_card", | ||
"project_card.converted", | ||
"project_card.created", | ||
"project_card.deleted", | ||
"project_card.edited", | ||
"project_card.moved", | ||
"project_column", | ||
"project_column.created", | ||
"project_column.deleted", | ||
"project_column.edited", | ||
"project_column.moved", | ||
"projects_v2_item", | ||
"projects_v2_item.archived", | ||
"projects_v2_item.converted", | ||
"projects_v2_item.created", | ||
"projects_v2_item.deleted", | ||
"projects_v2_item.edited", | ||
"projects_v2_item.reordered", | ||
"projects_v2_item.restored", | ||
"public", | ||
"pull_request", | ||
"pull_request.assigned", | ||
"pull_request.auto_merge_disabled", | ||
"pull_request.auto_merge_enabled", | ||
"pull_request.closed", | ||
"pull_request.converted_to_draft", | ||
"pull_request.demilestoned", | ||
"pull_request.dequeued", | ||
"pull_request.edited", | ||
"pull_request.labeled", | ||
"pull_request.locked", | ||
"pull_request.milestoned", | ||
"pull_request.opened", | ||
"pull_request.queued", | ||
"pull_request.ready_for_review", | ||
"pull_request.reopened", | ||
"pull_request.review_request_removed", | ||
"pull_request.review_requested", | ||
"pull_request.synchronize", | ||
"pull_request.unassigned", | ||
"pull_request.unlabeled", | ||
"pull_request.unlocked", | ||
"pull_request_review", | ||
"pull_request_review.dismissed", | ||
"pull_request_review.edited", | ||
"pull_request_review.submitted", | ||
"pull_request_review_comment", | ||
"pull_request_review_comment.created", | ||
"pull_request_review_comment.deleted", | ||
"pull_request_review_comment.edited", | ||
"pull_request_review_thread", | ||
"pull_request_review_thread.resolved", | ||
"pull_request_review_thread.unresolved", | ||
"push", | ||
"registry_package", | ||
"registry_package.published", | ||
"registry_package.updated", | ||
"release", | ||
"release.created", | ||
"release.deleted", | ||
"release.edited", | ||
"release.prereleased", | ||
"release.published", | ||
"release.released", | ||
"release.unpublished", | ||
"repository", | ||
"repository.archived", | ||
"repository.created", | ||
"repository.deleted", | ||
"repository.edited", | ||
"repository.privatized", | ||
"repository.publicized", | ||
"repository.renamed", | ||
"repository.transferred", | ||
"repository.unarchived", | ||
"repository_dispatch", | ||
"repository_import", | ||
"repository_vulnerability_alert", | ||
"repository_vulnerability_alert.create", | ||
"repository_vulnerability_alert.dismiss", | ||
"repository_vulnerability_alert.reopen", | ||
"repository_vulnerability_alert.resolve", | ||
"secret_scanning_alert", | ||
"secret_scanning_alert.created", | ||
"secret_scanning_alert.reopened", | ||
"secret_scanning_alert.resolved", | ||
"security_advisory", | ||
"security_advisory.performed", | ||
"security_advisory.published", | ||
"security_advisory.updated", | ||
"security_advisory.withdrawn", | ||
"sponsorship", | ||
"sponsorship.cancelled", | ||
"sponsorship.created", | ||
"sponsorship.edited", | ||
"sponsorship.pending_cancellation", | ||
"sponsorship.pending_tier_change", | ||
"sponsorship.tier_changed", | ||
"star", | ||
"star.created", | ||
"star.deleted", | ||
"status", | ||
"team", | ||
"team.added_to_repository", | ||
"team.created", | ||
"team.deleted", | ||
"team.edited", | ||
"team.removed_from_repository", | ||
"team_add", | ||
"watch", | ||
"watch.started", | ||
"workflow_dispatch", | ||
"workflow_job", | ||
"workflow_job.completed", | ||
"workflow_job.in_progress", | ||
"workflow_job.queued", | ||
"workflow_run", | ||
"workflow_run.completed", | ||
"workflow_run.in_progress", | ||
"workflow_run.requested" | ||
]; | ||
export { | ||
emitterEventNames | ||
}; |
@@ -5,26 +5,30 @@ import { createLogger } from "./createLogger"; | ||
import { verifyAndReceive } from "./verify-and-receive"; | ||
export { createNodeMiddleware } from "./middleware/node/index"; | ||
export { emitterEventNames } from "./generated/webhook-names"; | ||
// U holds the return value of `transform` function in Options | ||
import { createNodeMiddleware } from "./middleware/node/index"; | ||
import { emitterEventNames } from "./generated/webhook-names"; | ||
class Webhooks { | ||
constructor(options) { | ||
if (!options || !options.secret) { | ||
throw new Error("[@octokit/webhooks] options.secret required"); | ||
} | ||
const state = { | ||
eventHandler: createEventHandler(options), | ||
secret: options.secret, | ||
hooks: {}, | ||
log: createLogger(options.log), | ||
}; | ||
this.sign = sign.bind(null, options.secret); | ||
this.verify = verify.bind(null, options.secret); | ||
this.on = state.eventHandler.on; | ||
this.onAny = state.eventHandler.onAny; | ||
this.onError = state.eventHandler.onError; | ||
this.removeListener = state.eventHandler.removeListener; | ||
this.receive = state.eventHandler.receive; | ||
this.verifyAndReceive = verifyAndReceive.bind(null, state); | ||
constructor(options) { | ||
if (!options || !options.secret) { | ||
throw new Error("[@octokit/webhooks] options.secret required"); | ||
} | ||
const state = { | ||
eventHandler: createEventHandler(options), | ||
secret: options.secret, | ||
hooks: {}, | ||
log: createLogger(options.log) | ||
}; | ||
this.sign = sign.bind(null, options.secret); | ||
this.verify = verify.bind(null, options.secret); | ||
this.on = state.eventHandler.on; | ||
this.onAny = state.eventHandler.onAny; | ||
this.onError = state.eventHandler.onError; | ||
this.removeListener = state.eventHandler.removeListener; | ||
this.receive = state.eventHandler.receive; | ||
this.verifyAndReceive = verifyAndReceive.bind(null, state); | ||
} | ||
} | ||
export { createEventHandler, Webhooks, }; | ||
export { | ||
Webhooks, | ||
createEventHandler, | ||
createNodeMiddleware, | ||
emitterEventNames | ||
}; |
const WEBHOOK_HEADERS = [ | ||
"x-github-event", | ||
"x-hub-signature-256", | ||
"x-github-delivery", | ||
"x-github-event", | ||
"x-hub-signature-256", | ||
"x-github-delivery" | ||
]; | ||
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers | ||
export function getMissingHeaders(request) { | ||
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); | ||
function getMissingHeaders(request) { | ||
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); | ||
} | ||
export { | ||
getMissingHeaders | ||
}; |
@@ -1,27 +0,24 @@ | ||
// @ts-ignore to address #245 | ||
import AggregateError from "aggregate-error"; | ||
export function getPayload(request) { | ||
// If request.body already exists we can stop here | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) | ||
return Promise.resolve(request.body); | ||
return new Promise((resolve, reject) => { | ||
let data = ""; | ||
request.setEncoding("utf8"); | ||
// istanbul ignore next | ||
request.on("error", (error) => reject(new AggregateError([error]))); | ||
request.on("data", (chunk) => (data += chunk)); | ||
request.on("end", () => { | ||
try { | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
resolve(data); | ||
} | ||
catch (error) { | ||
error.message = "Invalid JSON"; | ||
error.status = 400; | ||
reject(new AggregateError([error])); | ||
} | ||
}); | ||
function getPayload(request) { | ||
if (request.body) | ||
return Promise.resolve(request.body); | ||
return new Promise((resolve, reject) => { | ||
let data = ""; | ||
request.setEncoding("utf8"); | ||
request.on("error", (error) => reject(new AggregateError([error]))); | ||
request.on("data", (chunk) => data += chunk); | ||
request.on("end", () => { | ||
try { | ||
JSON.parse(data); | ||
resolve(data); | ||
} catch (error) { | ||
error.message = "Invalid JSON"; | ||
error.status = 400; | ||
reject(new AggregateError([error])); | ||
} | ||
}); | ||
}); | ||
} | ||
export { | ||
getPayload | ||
}; |
import { createLogger } from "../../createLogger"; | ||
import { middleware } from "./middleware"; | ||
export function createNodeMiddleware(webhooks, { path = "/api/github/webhooks", log = createLogger(), } = {}) { | ||
return middleware.bind(null, webhooks, { | ||
path, | ||
log, | ||
}); | ||
function createNodeMiddleware(webhooks, { | ||
path = "/api/github/webhooks", | ||
log = createLogger() | ||
} = {}) { | ||
return middleware.bind(null, webhooks, { | ||
path, | ||
log | ||
}); | ||
} | ||
export { | ||
createNodeMiddleware | ||
}; |
import { getMissingHeaders } from "./get-missing-headers"; | ||
import { getPayload } from "./get-payload"; | ||
import { onUnhandledRequestDefault } from "./on-unhandled-request-default"; | ||
export async function middleware(webhooks, options, request, response, next) { | ||
let pathname; | ||
try { | ||
pathname = new URL(request.url, "http://localhost").pathname; | ||
} | ||
catch (error) { | ||
response.writeHead(422, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}`, | ||
})); | ||
return true; | ||
} | ||
if (pathname !== options.path) { | ||
next?.(); | ||
return false; | ||
} | ||
else if (request.method !== "POST") { | ||
onUnhandledRequestDefault(request, response); | ||
return true; | ||
} | ||
// Check if the Content-Type header is `application/json` and allow for charset to be specified in it | ||
// Otherwise, return a 415 Unsupported Media Type error | ||
// See https://github.com/octokit/webhooks.js/issues/158 | ||
if (!request.headers["content-type"] || | ||
!request.headers["content-type"].startsWith("application/json")) { | ||
response.writeHead(415, { | ||
"content-type": "application/json", | ||
accept: "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"`, | ||
})); | ||
return true; | ||
} | ||
const missingHeaders = getMissingHeaders(request).join(", "); | ||
if (missingHeaders) { | ||
response.writeHead(400, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}`, | ||
})); | ||
return true; | ||
} | ||
const eventName = request.headers["x-github-event"]; | ||
const signatureSHA256 = request.headers["x-hub-signature-256"]; | ||
const id = request.headers["x-github-delivery"]; | ||
options.log.debug(`${eventName} event received (id: ${id})`); | ||
// GitHub will abort the request if it does not receive a response within 10s | ||
// See https://github.com/octokit/webhooks.js/issues/185 | ||
let didTimeout = false; | ||
const timeout = setTimeout(() => { | ||
didTimeout = true; | ||
response.statusCode = 202; | ||
response.end("still processing\n"); | ||
}, 9000).unref(); | ||
try { | ||
const payload = await getPayload(request); | ||
await webhooks.verifyAndReceive({ | ||
id: id, | ||
name: eventName, | ||
payload, | ||
signature: signatureSHA256, | ||
}); | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
response.end("ok\n"); | ||
return true; | ||
} | ||
catch (error) { | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
const err = Array.from(error)[0]; | ||
const errorMessage = err.message | ||
? `${err.name}: ${err.message}` | ||
: "Error: An Unspecified error occurred"; | ||
response.statusCode = typeof err.status !== "undefined" ? err.status : 500; | ||
options.log.error(error); | ||
response.end(JSON.stringify({ | ||
error: errorMessage, | ||
})); | ||
return true; | ||
} | ||
async function middleware(webhooks, options, request, response, next) { | ||
let pathname; | ||
try { | ||
pathname = new URL(request.url, "http://localhost").pathname; | ||
} catch (error) { | ||
response.writeHead(422, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}` | ||
}) | ||
); | ||
return true; | ||
} | ||
if (pathname !== options.path) { | ||
next?.(); | ||
return false; | ||
} else if (request.method !== "POST") { | ||
onUnhandledRequestDefault(request, response); | ||
return true; | ||
} | ||
if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) { | ||
response.writeHead(415, { | ||
"content-type": "application/json", | ||
accept: "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"` | ||
}) | ||
); | ||
return true; | ||
} | ||
const missingHeaders = getMissingHeaders(request).join(", "); | ||
if (missingHeaders) { | ||
response.writeHead(400, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}` | ||
}) | ||
); | ||
return true; | ||
} | ||
const eventName = request.headers["x-github-event"]; | ||
const signatureSHA256 = request.headers["x-hub-signature-256"]; | ||
const id = request.headers["x-github-delivery"]; | ||
options.log.debug(`${eventName} event received (id: ${id})`); | ||
let didTimeout = false; | ||
const timeout = setTimeout(() => { | ||
didTimeout = true; | ||
response.statusCode = 202; | ||
response.end("still processing\n"); | ||
}, 9e3).unref(); | ||
try { | ||
const payload = await getPayload(request); | ||
await webhooks.verifyAndReceive({ | ||
id, | ||
name: eventName, | ||
payload, | ||
signature: signatureSHA256 | ||
}); | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
response.end("ok\n"); | ||
return true; | ||
} catch (error) { | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
const err = Array.from(error)[0]; | ||
const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred"; | ||
response.statusCode = typeof err.status !== "undefined" ? err.status : 500; | ||
options.log.error(error); | ||
response.end( | ||
JSON.stringify({ | ||
error: errorMessage | ||
}) | ||
); | ||
return true; | ||
} | ||
} | ||
export { | ||
middleware | ||
}; |
@@ -1,8 +0,13 @@ | ||
export function onUnhandledRequestDefault(request, response) { | ||
response.writeHead(404, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}`, | ||
})); | ||
function onUnhandledRequestDefault(request, response) { | ||
response.writeHead(404, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}` | ||
}) | ||
); | ||
} | ||
export { | ||
onUnhandledRequestDefault | ||
}; |
import { verify } from "@octokit/webhooks-methods"; | ||
export async function verifyAndReceive(state, event) { | ||
// verify will validate that the secret is not undefined | ||
const matchesSignature = await verify(state.secret, event.payload, event.signature); | ||
if (!matchesSignature) { | ||
const error = new Error("[@octokit/webhooks] signature does not match event payload and secret"); | ||
return state.eventHandler.receive(Object.assign(error, { event, status: 400 })); | ||
} | ||
return state.eventHandler.receive({ | ||
id: event.id, | ||
name: event.name, | ||
payload: JSON.parse(event.payload), | ||
}); | ||
async function verifyAndReceive(state, event) { | ||
const matchesSignature = await verify( | ||
state.secret, | ||
event.payload, | ||
event.signature | ||
); | ||
if (!matchesSignature) { | ||
const error = new Error( | ||
"[@octokit/webhooks] signature does not match event payload and secret" | ||
); | ||
return state.eventHandler.receive( | ||
Object.assign(error, { event, status: 400 }) | ||
); | ||
} | ||
return state.eventHandler.receive({ | ||
id: event.id, | ||
name: event.name, | ||
payload: JSON.parse(event.payload) | ||
}); | ||
} | ||
export { | ||
verifyAndReceive | ||
}; |
@@ -1,4 +0,4 @@ | ||
import { EmitterWebhookEvent, EmitterWebhookEventName, State, WebhookEventHandlerError } from "../types"; | ||
import type { EmitterWebhookEvent, EmitterWebhookEventName, State, WebhookEventHandlerError } from "../types"; | ||
export declare function receiverOn(state: State, webhookNameOrNames: EmitterWebhookEventName | EmitterWebhookEventName[], handler: Function): void; | ||
export declare function receiverOnAny(state: State, handler: (event: EmitterWebhookEvent) => any): void; | ||
export declare function receiverOnError(state: State, handler: (event: WebhookEventHandlerError) => any): void; |
@@ -1,2 +0,2 @@ | ||
import { EmitterWebhookEventName, State } from "../types"; | ||
import type { EmitterWebhookEventName, State } from "../types"; | ||
export declare function removeListener(state: State, webhookNameOrNames: "*" | EmitterWebhookEventName | EmitterWebhookEventName[], handler: Function): void; |
@@ -1,1 +0,1 @@ | ||
export declare const emitterEventNames: readonly ["branch_protection_rule", "branch_protection_rule.created", "branch_protection_rule.deleted", "branch_protection_rule.edited", "check_run", "check_run.completed", "check_run.created", "check_run.requested_action", "check_run.rerequested", "check_suite", "check_suite.completed", "check_suite.requested", "check_suite.rerequested", "code_scanning_alert", "code_scanning_alert.appeared_in_branch", "code_scanning_alert.closed_by_user", "code_scanning_alert.created", "code_scanning_alert.fixed", "code_scanning_alert.reopened", "code_scanning_alert.reopened_by_user", "commit_comment", "commit_comment.created", "create", "delete", "dependabot_alert", "dependabot_alert.created", "dependabot_alert.dismissed", "dependabot_alert.fixed", "dependabot_alert.reintroduced", "dependabot_alert.reopened", "deploy_key", "deploy_key.created", "deploy_key.deleted", "deployment", "deployment.created", "deployment_status", "deployment_status.created", "discussion", "discussion.answered", "discussion.category_changed", "discussion.created", "discussion.deleted", "discussion.edited", "discussion.labeled", "discussion.locked", "discussion.pinned", "discussion.transferred", "discussion.unanswered", "discussion.unlabeled", "discussion.unlocked", "discussion.unpinned", "discussion_comment", "discussion_comment.created", "discussion_comment.deleted", "discussion_comment.edited", "fork", "github_app_authorization", "github_app_authorization.revoked", "gollum", "installation", "installation.created", "installation.deleted", "installation.new_permissions_accepted", "installation.suspend", "installation.unsuspend", "installation_repositories", "installation_repositories.added", "installation_repositories.removed", "installation_target", "installation_target.renamed", "issue_comment", "issue_comment.created", "issue_comment.deleted", "issue_comment.edited", "issues", "issues.assigned", "issues.closed", "issues.deleted", "issues.demilestoned", "issues.edited", "issues.labeled", "issues.locked", "issues.milestoned", "issues.opened", "issues.pinned", "issues.reopened", "issues.transferred", "issues.unassigned", "issues.unlabeled", "issues.unlocked", "issues.unpinned", "label", "label.created", "label.deleted", "label.edited", "marketplace_purchase", "marketplace_purchase.cancelled", "marketplace_purchase.changed", "marketplace_purchase.pending_change", "marketplace_purchase.pending_change_cancelled", "marketplace_purchase.purchased", "member", "member.added", "member.edited", "member.removed", "membership", "membership.added", "membership.removed", "merge_group", "merge_group.checks_requested", "meta", "meta.deleted", "milestone", "milestone.closed", "milestone.created", "milestone.deleted", "milestone.edited", "milestone.opened", "org_block", "org_block.blocked", "org_block.unblocked", "organization", "organization.deleted", "organization.member_added", "organization.member_invited", "organization.member_removed", "organization.renamed", "package", "package.published", "package.updated", "page_build", "ping", "project", "project.closed", "project.created", "project.deleted", "project.edited", "project.reopened", "project_card", "project_card.converted", "project_card.created", "project_card.deleted", "project_card.edited", "project_card.moved", "project_column", "project_column.created", "project_column.deleted", "project_column.edited", "project_column.moved", "projects_v2_item", "projects_v2_item.archived", "projects_v2_item.converted", "projects_v2_item.created", "projects_v2_item.deleted", "projects_v2_item.edited", "projects_v2_item.reordered", "projects_v2_item.restored", "public", "pull_request", "pull_request.assigned", "pull_request.auto_merge_disabled", "pull_request.auto_merge_enabled", "pull_request.closed", "pull_request.converted_to_draft", "pull_request.dequeued", "pull_request.edited", "pull_request.labeled", "pull_request.locked", "pull_request.opened", "pull_request.queued", "pull_request.ready_for_review", "pull_request.reopened", "pull_request.review_request_removed", "pull_request.review_requested", "pull_request.synchronize", "pull_request.unassigned", "pull_request.unlabeled", "pull_request.unlocked", "pull_request_review", "pull_request_review.dismissed", "pull_request_review.edited", "pull_request_review.submitted", "pull_request_review_comment", "pull_request_review_comment.created", "pull_request_review_comment.deleted", "pull_request_review_comment.edited", "pull_request_review_thread", "pull_request_review_thread.resolved", "pull_request_review_thread.unresolved", "push", "registry_package", "registry_package.published", "registry_package.updated", "release", "release.created", "release.deleted", "release.edited", "release.prereleased", "release.published", "release.released", "release.unpublished", "repository", "repository.archived", "repository.created", "repository.deleted", "repository.edited", "repository.privatized", "repository.publicized", "repository.renamed", "repository.transferred", "repository.unarchived", "repository_dispatch", "repository_import", "repository_vulnerability_alert", "repository_vulnerability_alert.create", "repository_vulnerability_alert.dismiss", "repository_vulnerability_alert.reopen", "repository_vulnerability_alert.resolve", "secret_scanning_alert", "secret_scanning_alert.created", "secret_scanning_alert.reopened", "secret_scanning_alert.resolved", "security_advisory", "security_advisory.performed", "security_advisory.published", "security_advisory.updated", "security_advisory.withdrawn", "sponsorship", "sponsorship.cancelled", "sponsorship.created", "sponsorship.edited", "sponsorship.pending_cancellation", "sponsorship.pending_tier_change", "sponsorship.tier_changed", "star", "star.created", "star.deleted", "status", "team", "team.added_to_repository", "team.created", "team.deleted", "team.edited", "team.removed_from_repository", "team_add", "watch", "watch.started", "workflow_dispatch", "workflow_job", "workflow_job.completed", "workflow_job.in_progress", "workflow_job.queued", "workflow_run", "workflow_run.completed", "workflow_run.in_progress", "workflow_run.requested"]; | ||
export declare const emitterEventNames: readonly ["branch_protection_rule", "branch_protection_rule.created", "branch_protection_rule.deleted", "branch_protection_rule.edited", "check_run", "check_run.completed", "check_run.created", "check_run.requested_action", "check_run.rerequested", "check_suite", "check_suite.completed", "check_suite.requested", "check_suite.rerequested", "code_scanning_alert", "code_scanning_alert.appeared_in_branch", "code_scanning_alert.closed_by_user", "code_scanning_alert.created", "code_scanning_alert.fixed", "code_scanning_alert.reopened", "code_scanning_alert.reopened_by_user", "commit_comment", "commit_comment.created", "create", "delete", "dependabot_alert", "dependabot_alert.created", "dependabot_alert.dismissed", "dependabot_alert.fixed", "dependabot_alert.reintroduced", "dependabot_alert.reopened", "deploy_key", "deploy_key.created", "deploy_key.deleted", "deployment", "deployment.created", "deployment_status", "deployment_status.created", "discussion", "discussion.answered", "discussion.category_changed", "discussion.created", "discussion.deleted", "discussion.edited", "discussion.labeled", "discussion.locked", "discussion.pinned", "discussion.transferred", "discussion.unanswered", "discussion.unlabeled", "discussion.unlocked", "discussion.unpinned", "discussion_comment", "discussion_comment.created", "discussion_comment.deleted", "discussion_comment.edited", "fork", "github_app_authorization", "github_app_authorization.revoked", "gollum", "installation", "installation.created", "installation.deleted", "installation.new_permissions_accepted", "installation.suspend", "installation.unsuspend", "installation_repositories", "installation_repositories.added", "installation_repositories.removed", "installation_target", "installation_target.renamed", "issue_comment", "issue_comment.created", "issue_comment.deleted", "issue_comment.edited", "issues", "issues.assigned", "issues.closed", "issues.deleted", "issues.demilestoned", "issues.edited", "issues.labeled", "issues.locked", "issues.milestoned", "issues.opened", "issues.pinned", "issues.reopened", "issues.transferred", "issues.unassigned", "issues.unlabeled", "issues.unlocked", "issues.unpinned", "label", "label.created", "label.deleted", "label.edited", "marketplace_purchase", "marketplace_purchase.cancelled", "marketplace_purchase.changed", "marketplace_purchase.pending_change", "marketplace_purchase.pending_change_cancelled", "marketplace_purchase.purchased", "member", "member.added", "member.edited", "member.removed", "membership", "membership.added", "membership.removed", "merge_group", "merge_group.checks_requested", "meta", "meta.deleted", "milestone", "milestone.closed", "milestone.created", "milestone.deleted", "milestone.edited", "milestone.opened", "org_block", "org_block.blocked", "org_block.unblocked", "organization", "organization.deleted", "organization.member_added", "organization.member_invited", "organization.member_removed", "organization.renamed", "package", "package.published", "package.updated", "page_build", "ping", "project", "project.closed", "project.created", "project.deleted", "project.edited", "project.reopened", "project_card", "project_card.converted", "project_card.created", "project_card.deleted", "project_card.edited", "project_card.moved", "project_column", "project_column.created", "project_column.deleted", "project_column.edited", "project_column.moved", "projects_v2_item", "projects_v2_item.archived", "projects_v2_item.converted", "projects_v2_item.created", "projects_v2_item.deleted", "projects_v2_item.edited", "projects_v2_item.reordered", "projects_v2_item.restored", "public", "pull_request", "pull_request.assigned", "pull_request.auto_merge_disabled", "pull_request.auto_merge_enabled", "pull_request.closed", "pull_request.converted_to_draft", "pull_request.demilestoned", "pull_request.dequeued", "pull_request.edited", "pull_request.labeled", "pull_request.locked", "pull_request.milestoned", "pull_request.opened", "pull_request.queued", "pull_request.ready_for_review", "pull_request.reopened", "pull_request.review_request_removed", "pull_request.review_requested", "pull_request.synchronize", "pull_request.unassigned", "pull_request.unlabeled", "pull_request.unlocked", "pull_request_review", "pull_request_review.dismissed", "pull_request_review.edited", "pull_request_review.submitted", "pull_request_review_comment", "pull_request_review_comment.created", "pull_request_review_comment.deleted", "pull_request_review_comment.edited", "pull_request_review_thread", "pull_request_review_thread.resolved", "pull_request_review_thread.unresolved", "push", "registry_package", "registry_package.published", "registry_package.updated", "release", "release.created", "release.deleted", "release.edited", "release.prereleased", "release.published", "release.released", "release.unpublished", "repository", "repository.archived", "repository.created", "repository.deleted", "repository.edited", "repository.privatized", "repository.publicized", "repository.renamed", "repository.transferred", "repository.unarchived", "repository_dispatch", "repository_import", "repository_vulnerability_alert", "repository_vulnerability_alert.create", "repository_vulnerability_alert.dismiss", "repository_vulnerability_alert.reopen", "repository_vulnerability_alert.resolve", "secret_scanning_alert", "secret_scanning_alert.created", "secret_scanning_alert.reopened", "secret_scanning_alert.resolved", "security_advisory", "security_advisory.performed", "security_advisory.published", "security_advisory.updated", "security_advisory.withdrawn", "sponsorship", "sponsorship.cancelled", "sponsorship.created", "sponsorship.edited", "sponsorship.pending_cancellation", "sponsorship.pending_tier_change", "sponsorship.tier_changed", "star", "star.created", "star.deleted", "status", "team", "team.added_to_repository", "team.created", "team.deleted", "team.edited", "team.removed_from_repository", "team_add", "watch", "watch.started", "workflow_dispatch", "workflow_job", "workflow_job.completed", "workflow_job.in_progress", "workflow_job.queued", "workflow_run", "workflow_run.completed", "workflow_run.in_progress", "workflow_run.requested"]; |
import { createEventHandler } from "./event-handler/index"; | ||
import { EmitterWebhookEvent, EmitterWebhookEventName, HandlerFunction, RemoveHandlerFunction, Options, WebhookError, WebhookEventHandlerError, EmitterWebhookEventWithStringPayloadAndSignature } from "./types"; | ||
import type { EmitterWebhookEvent, EmitterWebhookEventName, HandlerFunction, RemoveHandlerFunction, Options, WebhookError, WebhookEventHandlerError, EmitterWebhookEventWithStringPayloadAndSignature } from "./types"; | ||
export { createNodeMiddleware } from "./middleware/node/index"; | ||
@@ -18,2 +18,2 @@ export { emitterEventNames } from "./generated/webhook-names"; | ||
} | ||
export { createEventHandler, Webhooks, EmitterWebhookEvent, EmitterWebhookEventName, WebhookError, }; | ||
export { createEventHandler, Webhooks, type EmitterWebhookEvent, type EmitterWebhookEventName, type WebhookError, }; |
@@ -1,3 +0,3 @@ | ||
import { Webhooks } from "../../index"; | ||
import { MiddlewareOptions } from "./types"; | ||
import type { Webhooks } from "../../index"; | ||
import type { MiddlewareOptions } from "./types"; | ||
export declare function createNodeMiddleware(webhooks: Webhooks, { path, log, }?: MiddlewareOptions): (request: any, response: any, next?: Function | undefined) => Promise<boolean>; |
type IncomingMessage = any; | ||
type ServerResponse = any; | ||
import { Webhooks } from "../../index"; | ||
import { MiddlewareOptions } from "./types"; | ||
import type { Webhooks } from "../../index"; | ||
import type { MiddlewareOptions } from "./types"; | ||
export declare function middleware(webhooks: Webhooks, options: Required<MiddlewareOptions>, request: IncomingMessage, response: ServerResponse, next?: Function): Promise<boolean>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { Logger } from "../../createLogger"; | ||
import type { Logger } from "../../createLogger"; | ||
export type MiddlewareOptions = { | ||
@@ -3,0 +3,0 @@ path?: string; |
@@ -1,4 +0,4 @@ | ||
import { RequestError } from "@octokit/request-error"; | ||
import type { RequestError } from "@octokit/request-error"; | ||
import type { WebhookEventMap, WebhookEventName } from "@octokit/webhooks-types"; | ||
import { Logger } from "./createLogger"; | ||
import type { Logger } from "./createLogger"; | ||
import type { emitterEventNames } from "./generated/webhook-names"; | ||
@@ -5,0 +5,0 @@ export type EmitterWebhookEventName = (typeof emitterEventNames)[number]; |
@@ -1,4 +0,4 @@ | ||
import { EmitterWebhookEventWithStringPayloadAndSignature, State } from "./types"; | ||
import type { EmitterWebhookEventWithStringPayloadAndSignature, State } from "./types"; | ||
export declare function verifyAndReceive(state: State & { | ||
secret: string; | ||
}, event: EmitterWebhookEventWithStringPayloadAndSignature): Promise<any>; |
@@ -1,592 +0,616 @@ | ||
import AggregateError from 'aggregate-error'; | ||
import { verify, sign } from '@octokit/webhooks-methods'; | ||
const createLogger = (logger) => ({ | ||
debug: () => { }, | ||
info: () => { }, | ||
warn: console.warn.bind(console), | ||
error: console.error.bind(console), | ||
...logger, | ||
// pkg/dist-src/createLogger.js | ||
var createLogger = (logger) => ({ | ||
debug: () => { | ||
}, | ||
info: () => { | ||
}, | ||
warn: console.warn.bind(console), | ||
error: console.error.bind(console), | ||
...logger | ||
}); | ||
// THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY | ||
// make edits in scripts/generate-types.ts | ||
const emitterEventNames = [ | ||
"branch_protection_rule", | ||
"branch_protection_rule.created", | ||
"branch_protection_rule.deleted", | ||
"branch_protection_rule.edited", | ||
"check_run", | ||
"check_run.completed", | ||
"check_run.created", | ||
"check_run.requested_action", | ||
"check_run.rerequested", | ||
"check_suite", | ||
"check_suite.completed", | ||
"check_suite.requested", | ||
"check_suite.rerequested", | ||
"code_scanning_alert", | ||
"code_scanning_alert.appeared_in_branch", | ||
"code_scanning_alert.closed_by_user", | ||
"code_scanning_alert.created", | ||
"code_scanning_alert.fixed", | ||
"code_scanning_alert.reopened", | ||
"code_scanning_alert.reopened_by_user", | ||
"commit_comment", | ||
"commit_comment.created", | ||
"create", | ||
"delete", | ||
"dependabot_alert", | ||
"dependabot_alert.created", | ||
"dependabot_alert.dismissed", | ||
"dependabot_alert.fixed", | ||
"dependabot_alert.reintroduced", | ||
"dependabot_alert.reopened", | ||
"deploy_key", | ||
"deploy_key.created", | ||
"deploy_key.deleted", | ||
"deployment", | ||
"deployment.created", | ||
"deployment_status", | ||
"deployment_status.created", | ||
"discussion", | ||
"discussion.answered", | ||
"discussion.category_changed", | ||
"discussion.created", | ||
"discussion.deleted", | ||
"discussion.edited", | ||
"discussion.labeled", | ||
"discussion.locked", | ||
"discussion.pinned", | ||
"discussion.transferred", | ||
"discussion.unanswered", | ||
"discussion.unlabeled", | ||
"discussion.unlocked", | ||
"discussion.unpinned", | ||
"discussion_comment", | ||
"discussion_comment.created", | ||
"discussion_comment.deleted", | ||
"discussion_comment.edited", | ||
"fork", | ||
"github_app_authorization", | ||
"github_app_authorization.revoked", | ||
"gollum", | ||
"installation", | ||
"installation.created", | ||
"installation.deleted", | ||
"installation.new_permissions_accepted", | ||
"installation.suspend", | ||
"installation.unsuspend", | ||
"installation_repositories", | ||
"installation_repositories.added", | ||
"installation_repositories.removed", | ||
"installation_target", | ||
"installation_target.renamed", | ||
"issue_comment", | ||
"issue_comment.created", | ||
"issue_comment.deleted", | ||
"issue_comment.edited", | ||
"issues", | ||
"issues.assigned", | ||
"issues.closed", | ||
"issues.deleted", | ||
"issues.demilestoned", | ||
"issues.edited", | ||
"issues.labeled", | ||
"issues.locked", | ||
"issues.milestoned", | ||
"issues.opened", | ||
"issues.pinned", | ||
"issues.reopened", | ||
"issues.transferred", | ||
"issues.unassigned", | ||
"issues.unlabeled", | ||
"issues.unlocked", | ||
"issues.unpinned", | ||
"label", | ||
"label.created", | ||
"label.deleted", | ||
"label.edited", | ||
"marketplace_purchase", | ||
"marketplace_purchase.cancelled", | ||
"marketplace_purchase.changed", | ||
"marketplace_purchase.pending_change", | ||
"marketplace_purchase.pending_change_cancelled", | ||
"marketplace_purchase.purchased", | ||
"member", | ||
"member.added", | ||
"member.edited", | ||
"member.removed", | ||
"membership", | ||
"membership.added", | ||
"membership.removed", | ||
"merge_group", | ||
"merge_group.checks_requested", | ||
"meta", | ||
"meta.deleted", | ||
"milestone", | ||
"milestone.closed", | ||
"milestone.created", | ||
"milestone.deleted", | ||
"milestone.edited", | ||
"milestone.opened", | ||
"org_block", | ||
"org_block.blocked", | ||
"org_block.unblocked", | ||
"organization", | ||
"organization.deleted", | ||
"organization.member_added", | ||
"organization.member_invited", | ||
"organization.member_removed", | ||
"organization.renamed", | ||
"package", | ||
"package.published", | ||
"package.updated", | ||
"page_build", | ||
"ping", | ||
"project", | ||
"project.closed", | ||
"project.created", | ||
"project.deleted", | ||
"project.edited", | ||
"project.reopened", | ||
"project_card", | ||
"project_card.converted", | ||
"project_card.created", | ||
"project_card.deleted", | ||
"project_card.edited", | ||
"project_card.moved", | ||
"project_column", | ||
"project_column.created", | ||
"project_column.deleted", | ||
"project_column.edited", | ||
"project_column.moved", | ||
"projects_v2_item", | ||
"projects_v2_item.archived", | ||
"projects_v2_item.converted", | ||
"projects_v2_item.created", | ||
"projects_v2_item.deleted", | ||
"projects_v2_item.edited", | ||
"projects_v2_item.reordered", | ||
"projects_v2_item.restored", | ||
"public", | ||
"pull_request", | ||
"pull_request.assigned", | ||
"pull_request.auto_merge_disabled", | ||
"pull_request.auto_merge_enabled", | ||
"pull_request.closed", | ||
"pull_request.converted_to_draft", | ||
"pull_request.dequeued", | ||
"pull_request.edited", | ||
"pull_request.labeled", | ||
"pull_request.locked", | ||
"pull_request.opened", | ||
"pull_request.queued", | ||
"pull_request.ready_for_review", | ||
"pull_request.reopened", | ||
"pull_request.review_request_removed", | ||
"pull_request.review_requested", | ||
"pull_request.synchronize", | ||
"pull_request.unassigned", | ||
"pull_request.unlabeled", | ||
"pull_request.unlocked", | ||
"pull_request_review", | ||
"pull_request_review.dismissed", | ||
"pull_request_review.edited", | ||
"pull_request_review.submitted", | ||
"pull_request_review_comment", | ||
"pull_request_review_comment.created", | ||
"pull_request_review_comment.deleted", | ||
"pull_request_review_comment.edited", | ||
"pull_request_review_thread", | ||
"pull_request_review_thread.resolved", | ||
"pull_request_review_thread.unresolved", | ||
"push", | ||
"registry_package", | ||
"registry_package.published", | ||
"registry_package.updated", | ||
"release", | ||
"release.created", | ||
"release.deleted", | ||
"release.edited", | ||
"release.prereleased", | ||
"release.published", | ||
"release.released", | ||
"release.unpublished", | ||
"repository", | ||
"repository.archived", | ||
"repository.created", | ||
"repository.deleted", | ||
"repository.edited", | ||
"repository.privatized", | ||
"repository.publicized", | ||
"repository.renamed", | ||
"repository.transferred", | ||
"repository.unarchived", | ||
"repository_dispatch", | ||
"repository_import", | ||
"repository_vulnerability_alert", | ||
"repository_vulnerability_alert.create", | ||
"repository_vulnerability_alert.dismiss", | ||
"repository_vulnerability_alert.reopen", | ||
"repository_vulnerability_alert.resolve", | ||
"secret_scanning_alert", | ||
"secret_scanning_alert.created", | ||
"secret_scanning_alert.reopened", | ||
"secret_scanning_alert.resolved", | ||
"security_advisory", | ||
"security_advisory.performed", | ||
"security_advisory.published", | ||
"security_advisory.updated", | ||
"security_advisory.withdrawn", | ||
"sponsorship", | ||
"sponsorship.cancelled", | ||
"sponsorship.created", | ||
"sponsorship.edited", | ||
"sponsorship.pending_cancellation", | ||
"sponsorship.pending_tier_change", | ||
"sponsorship.tier_changed", | ||
"star", | ||
"star.created", | ||
"star.deleted", | ||
"status", | ||
"team", | ||
"team.added_to_repository", | ||
"team.created", | ||
"team.deleted", | ||
"team.edited", | ||
"team.removed_from_repository", | ||
"team_add", | ||
"watch", | ||
"watch.started", | ||
"workflow_dispatch", | ||
"workflow_job", | ||
"workflow_job.completed", | ||
"workflow_job.in_progress", | ||
"workflow_job.queued", | ||
"workflow_run", | ||
"workflow_run.completed", | ||
"workflow_run.in_progress", | ||
"workflow_run.requested", | ||
// pkg/dist-src/generated/webhook-names.js | ||
var emitterEventNames = [ | ||
"branch_protection_rule", | ||
"branch_protection_rule.created", | ||
"branch_protection_rule.deleted", | ||
"branch_protection_rule.edited", | ||
"check_run", | ||
"check_run.completed", | ||
"check_run.created", | ||
"check_run.requested_action", | ||
"check_run.rerequested", | ||
"check_suite", | ||
"check_suite.completed", | ||
"check_suite.requested", | ||
"check_suite.rerequested", | ||
"code_scanning_alert", | ||
"code_scanning_alert.appeared_in_branch", | ||
"code_scanning_alert.closed_by_user", | ||
"code_scanning_alert.created", | ||
"code_scanning_alert.fixed", | ||
"code_scanning_alert.reopened", | ||
"code_scanning_alert.reopened_by_user", | ||
"commit_comment", | ||
"commit_comment.created", | ||
"create", | ||
"delete", | ||
"dependabot_alert", | ||
"dependabot_alert.created", | ||
"dependabot_alert.dismissed", | ||
"dependabot_alert.fixed", | ||
"dependabot_alert.reintroduced", | ||
"dependabot_alert.reopened", | ||
"deploy_key", | ||
"deploy_key.created", | ||
"deploy_key.deleted", | ||
"deployment", | ||
"deployment.created", | ||
"deployment_status", | ||
"deployment_status.created", | ||
"discussion", | ||
"discussion.answered", | ||
"discussion.category_changed", | ||
"discussion.created", | ||
"discussion.deleted", | ||
"discussion.edited", | ||
"discussion.labeled", | ||
"discussion.locked", | ||
"discussion.pinned", | ||
"discussion.transferred", | ||
"discussion.unanswered", | ||
"discussion.unlabeled", | ||
"discussion.unlocked", | ||
"discussion.unpinned", | ||
"discussion_comment", | ||
"discussion_comment.created", | ||
"discussion_comment.deleted", | ||
"discussion_comment.edited", | ||
"fork", | ||
"github_app_authorization", | ||
"github_app_authorization.revoked", | ||
"gollum", | ||
"installation", | ||
"installation.created", | ||
"installation.deleted", | ||
"installation.new_permissions_accepted", | ||
"installation.suspend", | ||
"installation.unsuspend", | ||
"installation_repositories", | ||
"installation_repositories.added", | ||
"installation_repositories.removed", | ||
"installation_target", | ||
"installation_target.renamed", | ||
"issue_comment", | ||
"issue_comment.created", | ||
"issue_comment.deleted", | ||
"issue_comment.edited", | ||
"issues", | ||
"issues.assigned", | ||
"issues.closed", | ||
"issues.deleted", | ||
"issues.demilestoned", | ||
"issues.edited", | ||
"issues.labeled", | ||
"issues.locked", | ||
"issues.milestoned", | ||
"issues.opened", | ||
"issues.pinned", | ||
"issues.reopened", | ||
"issues.transferred", | ||
"issues.unassigned", | ||
"issues.unlabeled", | ||
"issues.unlocked", | ||
"issues.unpinned", | ||
"label", | ||
"label.created", | ||
"label.deleted", | ||
"label.edited", | ||
"marketplace_purchase", | ||
"marketplace_purchase.cancelled", | ||
"marketplace_purchase.changed", | ||
"marketplace_purchase.pending_change", | ||
"marketplace_purchase.pending_change_cancelled", | ||
"marketplace_purchase.purchased", | ||
"member", | ||
"member.added", | ||
"member.edited", | ||
"member.removed", | ||
"membership", | ||
"membership.added", | ||
"membership.removed", | ||
"merge_group", | ||
"merge_group.checks_requested", | ||
"meta", | ||
"meta.deleted", | ||
"milestone", | ||
"milestone.closed", | ||
"milestone.created", | ||
"milestone.deleted", | ||
"milestone.edited", | ||
"milestone.opened", | ||
"org_block", | ||
"org_block.blocked", | ||
"org_block.unblocked", | ||
"organization", | ||
"organization.deleted", | ||
"organization.member_added", | ||
"organization.member_invited", | ||
"organization.member_removed", | ||
"organization.renamed", | ||
"package", | ||
"package.published", | ||
"package.updated", | ||
"page_build", | ||
"ping", | ||
"project", | ||
"project.closed", | ||
"project.created", | ||
"project.deleted", | ||
"project.edited", | ||
"project.reopened", | ||
"project_card", | ||
"project_card.converted", | ||
"project_card.created", | ||
"project_card.deleted", | ||
"project_card.edited", | ||
"project_card.moved", | ||
"project_column", | ||
"project_column.created", | ||
"project_column.deleted", | ||
"project_column.edited", | ||
"project_column.moved", | ||
"projects_v2_item", | ||
"projects_v2_item.archived", | ||
"projects_v2_item.converted", | ||
"projects_v2_item.created", | ||
"projects_v2_item.deleted", | ||
"projects_v2_item.edited", | ||
"projects_v2_item.reordered", | ||
"projects_v2_item.restored", | ||
"public", | ||
"pull_request", | ||
"pull_request.assigned", | ||
"pull_request.auto_merge_disabled", | ||
"pull_request.auto_merge_enabled", | ||
"pull_request.closed", | ||
"pull_request.converted_to_draft", | ||
"pull_request.demilestoned", | ||
"pull_request.dequeued", | ||
"pull_request.edited", | ||
"pull_request.labeled", | ||
"pull_request.locked", | ||
"pull_request.milestoned", | ||
"pull_request.opened", | ||
"pull_request.queued", | ||
"pull_request.ready_for_review", | ||
"pull_request.reopened", | ||
"pull_request.review_request_removed", | ||
"pull_request.review_requested", | ||
"pull_request.synchronize", | ||
"pull_request.unassigned", | ||
"pull_request.unlabeled", | ||
"pull_request.unlocked", | ||
"pull_request_review", | ||
"pull_request_review.dismissed", | ||
"pull_request_review.edited", | ||
"pull_request_review.submitted", | ||
"pull_request_review_comment", | ||
"pull_request_review_comment.created", | ||
"pull_request_review_comment.deleted", | ||
"pull_request_review_comment.edited", | ||
"pull_request_review_thread", | ||
"pull_request_review_thread.resolved", | ||
"pull_request_review_thread.unresolved", | ||
"push", | ||
"registry_package", | ||
"registry_package.published", | ||
"registry_package.updated", | ||
"release", | ||
"release.created", | ||
"release.deleted", | ||
"release.edited", | ||
"release.prereleased", | ||
"release.published", | ||
"release.released", | ||
"release.unpublished", | ||
"repository", | ||
"repository.archived", | ||
"repository.created", | ||
"repository.deleted", | ||
"repository.edited", | ||
"repository.privatized", | ||
"repository.publicized", | ||
"repository.renamed", | ||
"repository.transferred", | ||
"repository.unarchived", | ||
"repository_dispatch", | ||
"repository_import", | ||
"repository_vulnerability_alert", | ||
"repository_vulnerability_alert.create", | ||
"repository_vulnerability_alert.dismiss", | ||
"repository_vulnerability_alert.reopen", | ||
"repository_vulnerability_alert.resolve", | ||
"secret_scanning_alert", | ||
"secret_scanning_alert.created", | ||
"secret_scanning_alert.reopened", | ||
"secret_scanning_alert.resolved", | ||
"security_advisory", | ||
"security_advisory.performed", | ||
"security_advisory.published", | ||
"security_advisory.updated", | ||
"security_advisory.withdrawn", | ||
"sponsorship", | ||
"sponsorship.cancelled", | ||
"sponsorship.created", | ||
"sponsorship.edited", | ||
"sponsorship.pending_cancellation", | ||
"sponsorship.pending_tier_change", | ||
"sponsorship.tier_changed", | ||
"star", | ||
"star.created", | ||
"star.deleted", | ||
"status", | ||
"team", | ||
"team.added_to_repository", | ||
"team.created", | ||
"team.deleted", | ||
"team.edited", | ||
"team.removed_from_repository", | ||
"team_add", | ||
"watch", | ||
"watch.started", | ||
"workflow_dispatch", | ||
"workflow_job", | ||
"workflow_job.completed", | ||
"workflow_job.in_progress", | ||
"workflow_job.queued", | ||
"workflow_run", | ||
"workflow_run.completed", | ||
"workflow_run.in_progress", | ||
"workflow_run.requested" | ||
]; | ||
// pkg/dist-src/event-handler/on.js | ||
function handleEventHandlers(state, webhookName, handler) { | ||
if (!state.hooks[webhookName]) { | ||
state.hooks[webhookName] = []; | ||
} | ||
state.hooks[webhookName].push(handler); | ||
if (!state.hooks[webhookName]) { | ||
state.hooks[webhookName] = []; | ||
} | ||
state.hooks[webhookName].push(handler); | ||
} | ||
function receiverOn(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach((webhookName) => receiverOn(state, webhookName, handler)); | ||
return; | ||
} | ||
if (["*", "error"].includes(webhookNameOrNames)) { | ||
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; | ||
const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; | ||
throw new Error(message); | ||
} | ||
if (!emitterEventNames.includes(webhookNameOrNames)) { | ||
state.log.warn(`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`); | ||
} | ||
handleEventHandlers(state, webhookNameOrNames, handler); | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach( | ||
(webhookName) => receiverOn(state, webhookName, handler) | ||
); | ||
return; | ||
} | ||
if (["*", "error"].includes(webhookNameOrNames)) { | ||
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames; | ||
const message = `Using the "${webhookNameOrNames}" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.on${webhookName.charAt(0).toUpperCase() + webhookName.slice(1)}() method instead`; | ||
throw new Error(message); | ||
} | ||
if (!emitterEventNames.includes(webhookNameOrNames)) { | ||
state.log.warn( | ||
`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)` | ||
); | ||
} | ||
handleEventHandlers(state, webhookNameOrNames, handler); | ||
} | ||
function receiverOnAny(state, handler) { | ||
handleEventHandlers(state, "*", handler); | ||
handleEventHandlers(state, "*", handler); | ||
} | ||
function receiverOnError(state, handler) { | ||
handleEventHandlers(state, "error", handler); | ||
handleEventHandlers(state, "error", handler); | ||
} | ||
// Errors thrown or rejected Promises in "error" event handlers are not handled | ||
// as they are in the webhook event handlers. If errors occur, we log a | ||
// "Fatal: Error occurred" message to stdout | ||
// pkg/dist-src/event-handler/receive.js | ||
import AggregateError from "aggregate-error"; | ||
// pkg/dist-src/event-handler/wrap-error-handler.js | ||
function wrapErrorHandler(handler, error) { | ||
let returnValue; | ||
try { | ||
returnValue = handler(error); | ||
} | ||
catch (error) { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
} | ||
if (returnValue && returnValue.catch) { | ||
returnValue.catch((error) => { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error); | ||
}); | ||
} | ||
let returnValue; | ||
try { | ||
returnValue = handler(error); | ||
} catch (error2) { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error2); | ||
} | ||
if (returnValue && returnValue.catch) { | ||
returnValue.catch((error2) => { | ||
console.log('FATAL: Error occurred in "error" event handler'); | ||
console.log(error2); | ||
}); | ||
} | ||
} | ||
// @ts-ignore to address #245 | ||
// pkg/dist-src/event-handler/receive.js | ||
function getHooks(state, eventPayloadAction, eventName) { | ||
const hooks = [state.hooks[eventName], state.hooks["*"]]; | ||
if (eventPayloadAction) { | ||
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); | ||
} | ||
return [].concat(...hooks.filter(Boolean)); | ||
const hooks = [state.hooks[eventName], state.hooks["*"]]; | ||
if (eventPayloadAction) { | ||
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]); | ||
} | ||
return [].concat(...hooks.filter(Boolean)); | ||
} | ||
// main handler function | ||
function receiverHandle(state, event) { | ||
const errorHandlers = state.hooks.error || []; | ||
if (event instanceof Error) { | ||
const error = Object.assign(new AggregateError([event]), { | ||
event, | ||
errors: [event], | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
return Promise.reject(error); | ||
const errorHandlers = state.hooks.error || []; | ||
if (event instanceof Error) { | ||
const error = Object.assign(new AggregateError([event]), { | ||
event, | ||
errors: [event] | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
return Promise.reject(error); | ||
} | ||
if (!event || !event.name) { | ||
throw new AggregateError(["Event name not passed"]); | ||
} | ||
if (!event.payload) { | ||
throw new AggregateError(["Event payload not passed"]); | ||
} | ||
const hooks = getHooks( | ||
state, | ||
"action" in event.payload ? event.payload.action : null, | ||
event.name | ||
); | ||
if (hooks.length === 0) { | ||
return Promise.resolve(); | ||
} | ||
const errors = []; | ||
const promises = hooks.map((handler) => { | ||
let promise = Promise.resolve(event); | ||
if (state.transform) { | ||
promise = promise.then(state.transform); | ||
} | ||
if (!event || !event.name) { | ||
throw new AggregateError(["Event name not passed"]); | ||
return promise.then((event2) => { | ||
return handler(event2); | ||
}).catch((error) => errors.push(Object.assign(error, { event }))); | ||
}); | ||
return Promise.all(promises).then(() => { | ||
if (errors.length === 0) { | ||
return; | ||
} | ||
if (!event.payload) { | ||
throw new AggregateError(["Event payload not passed"]); | ||
} | ||
// flatten arrays of event listeners and remove undefined values | ||
const hooks = getHooks(state, "action" in event.payload ? event.payload.action : null, event.name); | ||
if (hooks.length === 0) { | ||
return Promise.resolve(); | ||
} | ||
const errors = []; | ||
const promises = hooks.map((handler) => { | ||
let promise = Promise.resolve(event); | ||
if (state.transform) { | ||
promise = promise.then(state.transform); | ||
} | ||
return promise | ||
.then((event) => { | ||
return handler(event); | ||
}) | ||
.catch((error) => errors.push(Object.assign(error, { event }))); | ||
const error = new AggregateError(errors); | ||
Object.assign(error, { | ||
event, | ||
errors | ||
}); | ||
return Promise.all(promises).then(() => { | ||
if (errors.length === 0) { | ||
return; | ||
} | ||
const error = new AggregateError(errors); | ||
Object.assign(error, { | ||
event, | ||
errors, | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
throw error; | ||
}); | ||
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error)); | ||
throw error; | ||
}); | ||
} | ||
// pkg/dist-src/event-handler/remove-listener.js | ||
function removeListener(state, webhookNameOrNames, handler) { | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach((webhookName) => removeListener(state, webhookName, handler)); | ||
return; | ||
if (Array.isArray(webhookNameOrNames)) { | ||
webhookNameOrNames.forEach( | ||
(webhookName) => removeListener(state, webhookName, handler) | ||
); | ||
return; | ||
} | ||
if (!state.hooks[webhookNameOrNames]) { | ||
return; | ||
} | ||
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { | ||
if (state.hooks[webhookNameOrNames][i] === handler) { | ||
state.hooks[webhookNameOrNames].splice(i, 1); | ||
return; | ||
} | ||
if (!state.hooks[webhookNameOrNames]) { | ||
return; | ||
} | ||
// remove last hook that has been added, that way | ||
// it behaves the same as removeListener | ||
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { | ||
if (state.hooks[webhookNameOrNames][i] === handler) { | ||
state.hooks[webhookNameOrNames].splice(i, 1); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
// pkg/dist-src/event-handler/index.js | ||
function createEventHandler(options) { | ||
const state = { | ||
hooks: {}, | ||
log: createLogger(options && options.log), | ||
}; | ||
if (options && options.transform) { | ||
state.transform = options.transform; | ||
} | ||
return { | ||
on: receiverOn.bind(null, state), | ||
onAny: receiverOnAny.bind(null, state), | ||
onError: receiverOnError.bind(null, state), | ||
removeListener: removeListener.bind(null, state), | ||
receive: receiverHandle.bind(null, state), | ||
}; | ||
const state = { | ||
hooks: {}, | ||
log: createLogger(options && options.log) | ||
}; | ||
if (options && options.transform) { | ||
state.transform = options.transform; | ||
} | ||
return { | ||
on: receiverOn.bind(null, state), | ||
onAny: receiverOnAny.bind(null, state), | ||
onError: receiverOnError.bind(null, state), | ||
removeListener: removeListener.bind(null, state), | ||
receive: receiverHandle.bind(null, state) | ||
}; | ||
} | ||
// pkg/dist-src/index.js | ||
import { sign, verify as verify2 } from "@octokit/webhooks-methods"; | ||
// pkg/dist-src/verify-and-receive.js | ||
import { verify } from "@octokit/webhooks-methods"; | ||
async function verifyAndReceive(state, event) { | ||
// verify will validate that the secret is not undefined | ||
const matchesSignature = await verify(state.secret, event.payload, event.signature); | ||
if (!matchesSignature) { | ||
const error = new Error("[@octokit/webhooks] signature does not match event payload and secret"); | ||
return state.eventHandler.receive(Object.assign(error, { event, status: 400 })); | ||
} | ||
return state.eventHandler.receive({ | ||
id: event.id, | ||
name: event.name, | ||
payload: JSON.parse(event.payload), | ||
}); | ||
const matchesSignature = await verify( | ||
state.secret, | ||
event.payload, | ||
event.signature | ||
); | ||
if (!matchesSignature) { | ||
const error = new Error( | ||
"[@octokit/webhooks] signature does not match event payload and secret" | ||
); | ||
return state.eventHandler.receive( | ||
Object.assign(error, { event, status: 400 }) | ||
); | ||
} | ||
return state.eventHandler.receive({ | ||
id: event.id, | ||
name: event.name, | ||
payload: JSON.parse(event.payload) | ||
}); | ||
} | ||
const WEBHOOK_HEADERS = [ | ||
"x-github-event", | ||
"x-hub-signature-256", | ||
"x-github-delivery", | ||
// pkg/dist-src/middleware/node/get-missing-headers.js | ||
var WEBHOOK_HEADERS = [ | ||
"x-github-event", | ||
"x-hub-signature-256", | ||
"x-github-delivery" | ||
]; | ||
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers | ||
function getMissingHeaders(request) { | ||
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); | ||
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers)); | ||
} | ||
// @ts-ignore to address #245 | ||
// pkg/dist-src/middleware/node/get-payload.js | ||
import AggregateError2 from "aggregate-error"; | ||
function getPayload(request) { | ||
// If request.body already exists we can stop here | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) | ||
return Promise.resolve(request.body); | ||
return new Promise((resolve, reject) => { | ||
let data = ""; | ||
request.setEncoding("utf8"); | ||
// istanbul ignore next | ||
request.on("error", (error) => reject(new AggregateError([error]))); | ||
request.on("data", (chunk) => (data += chunk)); | ||
request.on("end", () => { | ||
try { | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
resolve(data); | ||
} | ||
catch (error) { | ||
error.message = "Invalid JSON"; | ||
error.status = 400; | ||
reject(new AggregateError([error])); | ||
} | ||
}); | ||
if (request.body) | ||
return Promise.resolve(request.body); | ||
return new Promise((resolve, reject) => { | ||
let data = ""; | ||
request.setEncoding("utf8"); | ||
request.on("error", (error) => reject(new AggregateError2([error]))); | ||
request.on("data", (chunk) => data += chunk); | ||
request.on("end", () => { | ||
try { | ||
JSON.parse(data); | ||
resolve(data); | ||
} catch (error) { | ||
error.message = "Invalid JSON"; | ||
error.status = 400; | ||
reject(new AggregateError2([error])); | ||
} | ||
}); | ||
}); | ||
} | ||
// pkg/dist-src/middleware/node/on-unhandled-request-default.js | ||
function onUnhandledRequestDefault(request, response) { | ||
response.writeHead(404, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}`, | ||
})); | ||
response.writeHead(404, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unknown route: ${request.method} ${request.url}` | ||
}) | ||
); | ||
} | ||
// pkg/dist-src/middleware/node/middleware.js | ||
async function middleware(webhooks, options, request, response, next) { | ||
let pathname; | ||
try { | ||
pathname = new URL(request.url, "http://localhost").pathname; | ||
} | ||
catch (error) { | ||
response.writeHead(422, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}`, | ||
})); | ||
return true; | ||
} | ||
if (pathname !== options.path) { | ||
next?.(); | ||
return false; | ||
} | ||
else if (request.method !== "POST") { | ||
onUnhandledRequestDefault(request, response); | ||
return true; | ||
} | ||
// Check if the Content-Type header is `application/json` and allow for charset to be specified in it | ||
// Otherwise, return a 415 Unsupported Media Type error | ||
// See https://github.com/octokit/webhooks.js/issues/158 | ||
if (!request.headers["content-type"] || | ||
!request.headers["content-type"].startsWith("application/json")) { | ||
response.writeHead(415, { | ||
"content-type": "application/json", | ||
accept: "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"`, | ||
})); | ||
return true; | ||
} | ||
const missingHeaders = getMissingHeaders(request).join(", "); | ||
if (missingHeaders) { | ||
response.writeHead(400, { | ||
"content-type": "application/json", | ||
}); | ||
response.end(JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}`, | ||
})); | ||
return true; | ||
} | ||
const eventName = request.headers["x-github-event"]; | ||
const signatureSHA256 = request.headers["x-hub-signature-256"]; | ||
const id = request.headers["x-github-delivery"]; | ||
options.log.debug(`${eventName} event received (id: ${id})`); | ||
// GitHub will abort the request if it does not receive a response within 10s | ||
// See https://github.com/octokit/webhooks.js/issues/185 | ||
let didTimeout = false; | ||
const timeout = setTimeout(() => { | ||
didTimeout = true; | ||
response.statusCode = 202; | ||
response.end("still processing\n"); | ||
}, 9000).unref(); | ||
try { | ||
const payload = await getPayload(request); | ||
await webhooks.verifyAndReceive({ | ||
id: id, | ||
name: eventName, | ||
payload, | ||
signature: signatureSHA256, | ||
}); | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
response.end("ok\n"); | ||
return true; | ||
} | ||
catch (error) { | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
const err = Array.from(error)[0]; | ||
const errorMessage = err.message | ||
? `${err.name}: ${err.message}` | ||
: "Error: An Unspecified error occurred"; | ||
response.statusCode = typeof err.status !== "undefined" ? err.status : 500; | ||
options.log.error(error); | ||
response.end(JSON.stringify({ | ||
error: errorMessage, | ||
})); | ||
return true; | ||
} | ||
let pathname; | ||
try { | ||
pathname = new URL(request.url, "http://localhost").pathname; | ||
} catch (error) { | ||
response.writeHead(422, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Request URL could not be parsed: ${request.url}` | ||
}) | ||
); | ||
return true; | ||
} | ||
if (pathname !== options.path) { | ||
next?.(); | ||
return false; | ||
} else if (request.method !== "POST") { | ||
onUnhandledRequestDefault(request, response); | ||
return true; | ||
} | ||
if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) { | ||
response.writeHead(415, { | ||
"content-type": "application/json", | ||
accept: "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Unsupported "Content-Type" header value. Must be "application/json"` | ||
}) | ||
); | ||
return true; | ||
} | ||
const missingHeaders = getMissingHeaders(request).join(", "); | ||
if (missingHeaders) { | ||
response.writeHead(400, { | ||
"content-type": "application/json" | ||
}); | ||
response.end( | ||
JSON.stringify({ | ||
error: `Required headers missing: ${missingHeaders}` | ||
}) | ||
); | ||
return true; | ||
} | ||
const eventName = request.headers["x-github-event"]; | ||
const signatureSHA256 = request.headers["x-hub-signature-256"]; | ||
const id = request.headers["x-github-delivery"]; | ||
options.log.debug(`${eventName} event received (id: ${id})`); | ||
let didTimeout = false; | ||
const timeout = setTimeout(() => { | ||
didTimeout = true; | ||
response.statusCode = 202; | ||
response.end("still processing\n"); | ||
}, 9e3).unref(); | ||
try { | ||
const payload = await getPayload(request); | ||
await webhooks.verifyAndReceive({ | ||
id, | ||
name: eventName, | ||
payload, | ||
signature: signatureSHA256 | ||
}); | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
response.end("ok\n"); | ||
return true; | ||
} catch (error) { | ||
clearTimeout(timeout); | ||
if (didTimeout) | ||
return true; | ||
const err = Array.from(error)[0]; | ||
const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred"; | ||
response.statusCode = typeof err.status !== "undefined" ? err.status : 500; | ||
options.log.error(error); | ||
response.end( | ||
JSON.stringify({ | ||
error: errorMessage | ||
}) | ||
); | ||
return true; | ||
} | ||
} | ||
function createNodeMiddleware(webhooks, { path = "/api/github/webhooks", log = createLogger(), } = {}) { | ||
return middleware.bind(null, webhooks, { | ||
path, | ||
log, | ||
}); | ||
// pkg/dist-src/middleware/node/index.js | ||
function createNodeMiddleware(webhooks, { | ||
path = "/api/github/webhooks", | ||
log = createLogger() | ||
} = {}) { | ||
return middleware.bind(null, webhooks, { | ||
path, | ||
log | ||
}); | ||
} | ||
// U holds the return value of `transform` function in Options | ||
class Webhooks { | ||
constructor(options) { | ||
if (!options || !options.secret) { | ||
throw new Error("[@octokit/webhooks] options.secret required"); | ||
} | ||
const state = { | ||
eventHandler: createEventHandler(options), | ||
secret: options.secret, | ||
hooks: {}, | ||
log: createLogger(options.log), | ||
}; | ||
this.sign = sign.bind(null, options.secret); | ||
this.verify = verify.bind(null, options.secret); | ||
this.on = state.eventHandler.on; | ||
this.onAny = state.eventHandler.onAny; | ||
this.onError = state.eventHandler.onError; | ||
this.removeListener = state.eventHandler.removeListener; | ||
this.receive = state.eventHandler.receive; | ||
this.verifyAndReceive = verifyAndReceive.bind(null, state); | ||
// pkg/dist-src/index.js | ||
var Webhooks = class { | ||
constructor(options) { | ||
if (!options || !options.secret) { | ||
throw new Error("[@octokit/webhooks] options.secret required"); | ||
} | ||
} | ||
export { Webhooks, createEventHandler, createNodeMiddleware, emitterEventNames }; | ||
//# sourceMappingURL=index.js.map | ||
const state = { | ||
eventHandler: createEventHandler(options), | ||
secret: options.secret, | ||
hooks: {}, | ||
log: createLogger(options.log) | ||
}; | ||
this.sign = sign.bind(null, options.secret); | ||
this.verify = verify2.bind(null, options.secret); | ||
this.on = state.eventHandler.on; | ||
this.onAny = state.eventHandler.onAny; | ||
this.onError = state.eventHandler.onError; | ||
this.removeListener = state.eventHandler.removeListener; | ||
this.receive = state.eventHandler.receive; | ||
this.verifyAndReceive = verifyAndReceive.bind(null, state); | ||
} | ||
}; | ||
export { | ||
Webhooks, | ||
createEventHandler, | ||
createNodeMiddleware, | ||
emitterEventNames | ||
}; |
{ | ||
"name": "@octokit/webhooks", | ||
"version": "11.0.0-beta.8", | ||
"description": "GitHub webhook events toolset for Node.js", | ||
"version": "11.0.0-beta.7", | ||
"license": "MIT", | ||
"files": [ | ||
"dist-*/", | ||
"bin/" | ||
], | ||
"source": "dist-src/index.js", | ||
"types": "dist-types/index.d.ts", | ||
"main": "dist-node/index.js", | ||
"module": "dist-web/index.js", | ||
"pika": true, | ||
"sideEffects": false, | ||
"keywords": [], | ||
"repository": "github:octokit/webhooks.js", | ||
"license": "MIT", | ||
"author": "Gregor Martynus (https://twitter.com/gr2m)", | ||
"dependencies": { | ||
"@octokit/request-error": "^3.0.0", | ||
"@octokit/webhooks-methods": "^3.0.0", | ||
"@octokit/webhooks-types": "6.10.0", | ||
"@octokit/webhooks-types": "6.11.0", | ||
"aggregate-error": "^3.1.0" | ||
@@ -27,7 +18,3 @@ }, | ||
"@octokit/tsconfig": "^1.0.1", | ||
"@octokit/webhooks-schemas": "6.10.0", | ||
"@pika/pack": "^0.3.7", | ||
"@pika/plugin-build-node": "^0.9.2", | ||
"@pika/plugin-build-web": "^0.9.2", | ||
"@pika/plugin-ts-standard-pkg": "^0.9.2", | ||
"@octokit/webhooks-schemas": "6.11.0", | ||
"@types/jest": "^29.0.0", | ||
@@ -39,10 +26,12 @@ "@types/json-schema": "^7.0.7", | ||
"axios": "^1.0.0", | ||
"esbuild": "^0.17.11", | ||
"express": "^4.17.1", | ||
"glob": "^9.2.1", | ||
"jest": "^29.0.0", | ||
"node-fetch": "^2.6.7", | ||
"prettier": "2.8.3", | ||
"prettier": "2.8.7", | ||
"prettier-plugin-packagejson": "^2.2.9", | ||
"ts-jest": "^29.0.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.1.5" | ||
"typescript": "^5.0.0" | ||
}, | ||
@@ -54,3 +43,12 @@ "engines": { | ||
"access": "public" | ||
} | ||
}, | ||
"files": [ | ||
"dist-*/**", | ||
"bin/**" | ||
], | ||
"main": "dist-node/index.js", | ||
"module": "dist-web/index.js", | ||
"types": "dist-types/index.d.ts", | ||
"source": "dist-src/index.js", | ||
"sideEffects": false | ||
} |
124
README.md
@@ -620,64 +620,64 @@ # @octokit/webhooks | ||
| Event | Actions | | ||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| [`branch_protection_rule`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule) | `created`<br>`deleted`<br>`edited` | | ||
| [`check_run`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_run) | `completed`<br>`created`<br>`requested_action`<br>`rerequested` | | ||
| [`check_suite`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_suite) | `completed`<br>`requested`<br>`rerequested` | | ||
| [`code_scanning_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert) | `appeared_in_branch`<br>`closed_by_user`<br>`created`<br>`fixed`<br>`reopened`<br>`reopened_by_user` | | ||
| [`commit_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#commit_comment) | `created` | | ||
| [`create`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create) | | | ||
| [`delete`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delete) | | | ||
| [`dependabot_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#dependabot_alert) | `created`<br>`dismissed`<br>`fixed`<br>`reintroduced`<br>`reopened` | | ||
| [`deploy_key`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deploy_key) | `created`<br>`deleted` | | ||
| [`deployment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment) | `created` | | ||
| [`deployment_status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_status) | `created` | | ||
| [`discussion`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion) | `answered`<br>`category_changed`<br>`created`<br>`deleted`<br>`edited`<br>`labeled`<br>`locked`<br>`pinned`<br>`transferred`<br>`unanswered`<br>`unlabeled`<br>`unlocked`<br>`unpinned` | | ||
| [`discussion_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`fork`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#fork) | | | ||
| [`github_app_authorization`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#github_app_authorization) | `revoked` | | ||
| [`gollum`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#gollum) | | | ||
| [`installation`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation) | `created`<br>`deleted`<br>`new_permissions_accepted`<br>`suspend`<br>`unsuspend` | | ||
| [`installation_repositories`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_repositories) | `added`<br>`removed` | | ||
| [`installation_target`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target) | `renamed` | | ||
| [`issue_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`issues`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issues) | `assigned`<br>`closed`<br>`deleted`<br>`demilestoned`<br>`edited`<br>`labeled`<br>`locked`<br>`milestoned`<br>`opened`<br>`pinned`<br>`reopened`<br>`transferred`<br>`unassigned`<br>`unlabeled`<br>`unlocked`<br>`unpinned` | | ||
| [`label`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#label) | `created`<br>`deleted`<br>`edited` | | ||
| [`marketplace_purchase`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#marketplace_purchase) | `cancelled`<br>`changed`<br>`pending_change`<br>`pending_change_cancelled`<br>`purchased` | | ||
| [`member`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#member) | `added`<br>`edited`<br>`removed` | | ||
| [`membership`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#membership) | `added`<br>`removed` | | ||
| [`merge_group`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#merge_group) | `checks_requested` | | ||
| [`meta`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#meta) | `deleted` | | ||
| [`milestone`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#milestone) | `closed`<br>`created`<br>`deleted`<br>`edited`<br>`opened` | | ||
| [`org_block`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#org_block) | `blocked`<br>`unblocked` | | ||
| [`organization`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#organization) | `deleted`<br>`member_added`<br>`member_invited`<br>`member_removed`<br>`renamed` | | ||
| [`package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#package) | `published`<br>`updated` | | ||
| [`page_build`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#page_build) | | | ||
| [`ping`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#ping) | | | ||
| [`project`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project) | `closed`<br>`created`<br>`deleted`<br>`edited`<br>`reopened` | | ||
| [`project_card`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project_card) | `converted`<br>`created`<br>`deleted`<br>`edited`<br>`moved` | | ||
| [`project_column`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project_column) | `created`<br>`deleted`<br>`edited`<br>`moved` | | ||
| [`projects_v2_item`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2_item) | `archived`<br>`converted`<br>`created`<br>`deleted`<br>`edited`<br>`reordered`<br>`restored` | | ||
| [`public`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#public) | | | ||
| [`pull_request`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request) | `assigned`<br>`auto_merge_disabled`<br>`auto_merge_enabled`<br>`closed`<br>`converted_to_draft`<br>`dequeued`<br>`edited`<br>`labeled`<br>`locked`<br>`opened`<br>`queued`<br>`ready_for_review`<br>`reopened`<br>`review_request_removed`<br>`review_requested`<br>`synchronize`<br>`unassigned`<br>`unlabeled`<br>`unlocked` | | ||
| [`pull_request_review`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review) | `dismissed`<br>`edited`<br>`submitted` | | ||
| [`pull_request_review_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`pull_request_review_thread`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review_thread) | `resolved`<br>`unresolved` | | ||
| [`push`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push) | | | ||
| [`registry_package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#registry_package) | `published`<br>`updated` | | ||
| [`release`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release) | `created`<br>`deleted`<br>`edited`<br>`prereleased`<br>`published`<br>`released`<br>`unpublished` | | ||
| [`repository`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository) | `archived`<br>`created`<br>`deleted`<br>`edited`<br>`privatized`<br>`publicized`<br>`renamed`<br>`transferred`<br>`unarchived` | | ||
| [`repository_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_dispatch) | | | ||
| [`repository_import`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import) | | | ||
| [`repository_vulnerability_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_vulnerability_alert) | `create`<br>`dismiss`<br>`reopen`<br>`resolve` | | ||
| [`secret_scanning_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#secret_scanning_alert) | `created`<br>`reopened`<br>`resolved` | | ||
| [`security_advisory`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory) | `performed`<br>`published`<br>`updated`<br>`withdrawn` | | ||
| [`sponsorship`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#sponsorship) | `cancelled`<br>`created`<br>`edited`<br>`pending_cancellation`<br>`pending_tier_change`<br>`tier_changed` | | ||
| [`star`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star) | `created`<br>`deleted` | | ||
| [`status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status) | | | ||
| [`team`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team) | `added_to_repository`<br>`created`<br>`deleted`<br>`edited`<br>`removed_from_repository` | | ||
| [`team_add`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team_add) | | | ||
| [`watch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#watch) | `started` | | ||
| [`workflow_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch) | | | ||
| [`workflow_job`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job) | `completed`<br>`in_progress`<br>`queued` | | ||
| [`workflow_run`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run) | `completed`<br>`in_progress`<br>`requested` | | ||
| Event | Actions | | ||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| [`branch_protection_rule`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule) | `created`<br>`deleted`<br>`edited` | | ||
| [`check_run`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_run) | `completed`<br>`created`<br>`requested_action`<br>`rerequested` | | ||
| [`check_suite`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_suite) | `completed`<br>`requested`<br>`rerequested` | | ||
| [`code_scanning_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert) | `appeared_in_branch`<br>`closed_by_user`<br>`created`<br>`fixed`<br>`reopened`<br>`reopened_by_user` | | ||
| [`commit_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#commit_comment) | `created` | | ||
| [`create`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create) | | | ||
| [`delete`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delete) | | | ||
| [`dependabot_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#dependabot_alert) | `created`<br>`dismissed`<br>`fixed`<br>`reintroduced`<br>`reopened` | | ||
| [`deploy_key`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deploy_key) | `created`<br>`deleted` | | ||
| [`deployment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment) | `created` | | ||
| [`deployment_status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_status) | `created` | | ||
| [`discussion`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion) | `answered`<br>`category_changed`<br>`created`<br>`deleted`<br>`edited`<br>`labeled`<br>`locked`<br>`pinned`<br>`transferred`<br>`unanswered`<br>`unlabeled`<br>`unlocked`<br>`unpinned` | | ||
| [`discussion_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`fork`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#fork) | | | ||
| [`github_app_authorization`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#github_app_authorization) | `revoked` | | ||
| [`gollum`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#gollum) | | | ||
| [`installation`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation) | `created`<br>`deleted`<br>`new_permissions_accepted`<br>`suspend`<br>`unsuspend` | | ||
| [`installation_repositories`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_repositories) | `added`<br>`removed` | | ||
| [`installation_target`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target) | `renamed` | | ||
| [`issue_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`issues`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issues) | `assigned`<br>`closed`<br>`deleted`<br>`demilestoned`<br>`edited`<br>`labeled`<br>`locked`<br>`milestoned`<br>`opened`<br>`pinned`<br>`reopened`<br>`transferred`<br>`unassigned`<br>`unlabeled`<br>`unlocked`<br>`unpinned` | | ||
| [`label`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#label) | `created`<br>`deleted`<br>`edited` | | ||
| [`marketplace_purchase`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#marketplace_purchase) | `cancelled`<br>`changed`<br>`pending_change`<br>`pending_change_cancelled`<br>`purchased` | | ||
| [`member`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#member) | `added`<br>`edited`<br>`removed` | | ||
| [`membership`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#membership) | `added`<br>`removed` | | ||
| [`merge_group`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#merge_group) | `checks_requested` | | ||
| [`meta`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#meta) | `deleted` | | ||
| [`milestone`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#milestone) | `closed`<br>`created`<br>`deleted`<br>`edited`<br>`opened` | | ||
| [`org_block`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#org_block) | `blocked`<br>`unblocked` | | ||
| [`organization`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#organization) | `deleted`<br>`member_added`<br>`member_invited`<br>`member_removed`<br>`renamed` | | ||
| [`package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#package) | `published`<br>`updated` | | ||
| [`page_build`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#page_build) | | | ||
| [`ping`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#ping) | | | ||
| [`project`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project) | `closed`<br>`created`<br>`deleted`<br>`edited`<br>`reopened` | | ||
| [`project_card`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project_card) | `converted`<br>`created`<br>`deleted`<br>`edited`<br>`moved` | | ||
| [`project_column`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#project_column) | `created`<br>`deleted`<br>`edited`<br>`moved` | | ||
| [`projects_v2_item`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2_item) | `archived`<br>`converted`<br>`created`<br>`deleted`<br>`edited`<br>`reordered`<br>`restored` | | ||
| [`public`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#public) | | | ||
| [`pull_request`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request) | `assigned`<br>`auto_merge_disabled`<br>`auto_merge_enabled`<br>`closed`<br>`converted_to_draft`<br>`demilestoned`<br>`dequeued`<br>`edited`<br>`labeled`<br>`locked`<br>`milestoned`<br>`opened`<br>`queued`<br>`ready_for_review`<br>`reopened`<br>`review_request_removed`<br>`review_requested`<br>`synchronize`<br>`unassigned`<br>`unlabeled`<br>`unlocked` | | ||
| [`pull_request_review`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review) | `dismissed`<br>`edited`<br>`submitted` | | ||
| [`pull_request_review_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review_comment) | `created`<br>`deleted`<br>`edited` | | ||
| [`pull_request_review_thread`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review_thread) | `resolved`<br>`unresolved` | | ||
| [`push`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push) | | | ||
| [`registry_package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#registry_package) | `published`<br>`updated` | | ||
| [`release`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release) | `created`<br>`deleted`<br>`edited`<br>`prereleased`<br>`published`<br>`released`<br>`unpublished` | | ||
| [`repository`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository) | `archived`<br>`created`<br>`deleted`<br>`edited`<br>`privatized`<br>`publicized`<br>`renamed`<br>`transferred`<br>`unarchived` | | ||
| [`repository_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_dispatch) | | | ||
| [`repository_import`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import) | | | ||
| [`repository_vulnerability_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_vulnerability_alert) | `create`<br>`dismiss`<br>`reopen`<br>`resolve` | | ||
| [`secret_scanning_alert`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#secret_scanning_alert) | `created`<br>`reopened`<br>`resolved` | | ||
| [`security_advisory`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory) | `performed`<br>`published`<br>`updated`<br>`withdrawn` | | ||
| [`sponsorship`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#sponsorship) | `cancelled`<br>`created`<br>`edited`<br>`pending_cancellation`<br>`pending_tier_change`<br>`tier_changed` | | ||
| [`star`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star) | `created`<br>`deleted` | | ||
| [`status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status) | | | ||
| [`team`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team) | `added_to_repository`<br>`created`<br>`deleted`<br>`edited`<br>`removed_from_repository` | | ||
| [`team_add`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team_add) | | | ||
| [`watch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#watch) | `started` | | ||
| [`workflow_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch) | | | ||
| [`workflow_job`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job) | `completed`<br>`in_progress`<br>`queued` | | ||
| [`workflow_run`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run) | `completed`<br>`in_progress`<br>`requested` | | ||
@@ -684,0 +684,0 @@ <!-- /autogenerated via scripts/generate-types.ts --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
19
2041
1
178378
37
+ Added@octokit/webhooks-types@6.11.0(transitive)
- Removed@octokit/webhooks-types@6.10.0(transitive)