UNPKG

@octokit/webhooks

Version:

GitHub webhook events toolset for Node.js

1 lines 38.2 kB
{"version":3,"file":"index.js","sources":["../dist-src/createLogger.js","../dist-src/generated/webhook-names.js","../dist-src/event-handler/on.js","../dist-src/event-handler/wrap-error-handler.js","../dist-src/event-handler/receive.js","../dist-src/event-handler/remove-listener.js","../dist-src/event-handler/index.js","../dist-src/to-normalized-json-string.js","../dist-src/sign.js","../dist-src/verify.js","../dist-src/verify-and-receive.js","../dist-src/middleware/node/get-missing-headers.js","../dist-src/middleware/node/get-payload.js","../dist-src/middleware/node/middleware.js","../dist-src/middleware/node/on-unhandled-request-default.js","../dist-src/middleware/node/index.js","../dist-src/index.js"],"sourcesContent":["export const createLogger = (logger) => ({\n debug: () => { },\n info: () => { },\n warn: console.warn.bind(console),\n error: console.error.bind(console),\n ...logger,\n});\n","// THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY\n// make edits in scripts/generate-types.ts\nexport const emitterEventNames = [\n \"branch_protection_rule\",\n \"branch_protection_rule.created\",\n \"branch_protection_rule.deleted\",\n \"branch_protection_rule.edited\",\n \"check_run\",\n \"check_run.completed\",\n \"check_run.created\",\n \"check_run.requested_action\",\n \"check_run.rerequested\",\n \"check_suite\",\n \"check_suite.completed\",\n \"check_suite.requested\",\n \"check_suite.rerequested\",\n \"code_scanning_alert\",\n \"code_scanning_alert.appeared_in_branch\",\n \"code_scanning_alert.closed_by_user\",\n \"code_scanning_alert.created\",\n \"code_scanning_alert.fixed\",\n \"code_scanning_alert.reopened\",\n \"code_scanning_alert.reopened_by_user\",\n \"commit_comment\",\n \"commit_comment.created\",\n \"create\",\n \"delete\",\n \"deploy_key\",\n \"deploy_key.created\",\n \"deploy_key.deleted\",\n \"deployment\",\n \"deployment.created\",\n \"deployment_status\",\n \"deployment_status.created\",\n \"discussion\",\n \"discussion.answered\",\n \"discussion.category_changed\",\n \"discussion.created\",\n \"discussion.deleted\",\n \"discussion.edited\",\n \"discussion.labeled\",\n \"discussion.locked\",\n \"discussion.pinned\",\n \"discussion.transferred\",\n \"discussion.unanswered\",\n \"discussion.unlabeled\",\n \"discussion.unlocked\",\n \"discussion.unpinned\",\n \"discussion_comment\",\n \"discussion_comment.created\",\n \"discussion_comment.deleted\",\n \"discussion_comment.edited\",\n \"fork\",\n \"github_app_authorization\",\n \"github_app_authorization.revoked\",\n \"gollum\",\n \"installation\",\n \"installation.created\",\n \"installation.deleted\",\n \"installation.new_permissions_accepted\",\n \"installation.suspend\",\n \"installation.unsuspend\",\n \"installation_repositories\",\n \"installation_repositories.added\",\n \"installation_repositories.removed\",\n \"issue_comment\",\n \"issue_comment.created\",\n \"issue_comment.deleted\",\n \"issue_comment.edited\",\n \"issues\",\n \"issues.assigned\",\n \"issues.closed\",\n \"issues.deleted\",\n \"issues.demilestoned\",\n \"issues.edited\",\n \"issues.labeled\",\n \"issues.locked\",\n \"issues.milestoned\",\n \"issues.opened\",\n \"issues.pinned\",\n \"issues.reopened\",\n \"issues.transferred\",\n \"issues.unassigned\",\n \"issues.unlabeled\",\n \"issues.unlocked\",\n \"issues.unpinned\",\n \"label\",\n \"label.created\",\n \"label.deleted\",\n \"label.edited\",\n \"marketplace_purchase\",\n \"marketplace_purchase.cancelled\",\n \"marketplace_purchase.changed\",\n \"marketplace_purchase.pending_change\",\n \"marketplace_purchase.pending_change_cancelled\",\n \"marketplace_purchase.purchased\",\n \"member\",\n \"member.added\",\n \"member.edited\",\n \"member.removed\",\n \"membership\",\n \"membership.added\",\n \"membership.removed\",\n \"meta\",\n \"meta.deleted\",\n \"milestone\",\n \"milestone.closed\",\n \"milestone.created\",\n \"milestone.deleted\",\n \"milestone.edited\",\n \"milestone.opened\",\n \"org_block\",\n \"org_block.blocked\",\n \"org_block.unblocked\",\n \"organization\",\n \"organization.deleted\",\n \"organization.member_added\",\n \"organization.member_invited\",\n \"organization.member_removed\",\n \"organization.renamed\",\n \"package\",\n \"package.published\",\n \"package.updated\",\n \"page_build\",\n \"ping\",\n \"project\",\n \"project.closed\",\n \"project.created\",\n \"project.deleted\",\n \"project.edited\",\n \"project.reopened\",\n \"project_card\",\n \"project_card.converted\",\n \"project_card.created\",\n \"project_card.deleted\",\n \"project_card.edited\",\n \"project_card.moved\",\n \"project_column\",\n \"project_column.created\",\n \"project_column.deleted\",\n \"project_column.edited\",\n \"project_column.moved\",\n \"projects_v2_item\",\n \"projects_v2_item.archived\",\n \"projects_v2_item.converted\",\n \"projects_v2_item.created\",\n \"projects_v2_item.deleted\",\n \"projects_v2_item.edited\",\n \"projects_v2_item.reordered\",\n \"projects_v2_item.restored\",\n \"public\",\n \"pull_request\",\n \"pull_request.assigned\",\n \"pull_request.auto_merge_disabled\",\n \"pull_request.auto_merge_enabled\",\n \"pull_request.closed\",\n \"pull_request.converted_to_draft\",\n \"pull_request.edited\",\n \"pull_request.labeled\",\n \"pull_request.locked\",\n \"pull_request.opened\",\n \"pull_request.ready_for_review\",\n \"pull_request.reopened\",\n \"pull_request.review_request_removed\",\n \"pull_request.review_requested\",\n \"pull_request.synchronize\",\n \"pull_request.unassigned\",\n \"pull_request.unlabeled\",\n \"pull_request.unlocked\",\n \"pull_request_review\",\n \"pull_request_review.dismissed\",\n \"pull_request_review.edited\",\n \"pull_request_review.submitted\",\n \"pull_request_review_comment\",\n \"pull_request_review_comment.created\",\n \"pull_request_review_comment.deleted\",\n \"pull_request_review_comment.edited\",\n \"pull_request_review_thread\",\n \"pull_request_review_thread.resolved\",\n \"pull_request_review_thread.unresolved\",\n \"push\",\n \"release\",\n \"release.created\",\n \"release.deleted\",\n \"release.edited\",\n \"release.prereleased\",\n \"release.published\",\n \"release.released\",\n \"release.unpublished\",\n \"repository\",\n \"repository.archived\",\n \"repository.created\",\n \"repository.deleted\",\n \"repository.edited\",\n \"repository.privatized\",\n \"repository.publicized\",\n \"repository.renamed\",\n \"repository.transferred\",\n \"repository.unarchived\",\n \"repository_dispatch\",\n \"repository_import\",\n \"repository_vulnerability_alert\",\n \"repository_vulnerability_alert.create\",\n \"repository_vulnerability_alert.dismiss\",\n \"repository_vulnerability_alert.reopen\",\n \"repository_vulnerability_alert.resolve\",\n \"secret_scanning_alert\",\n \"secret_scanning_alert.created\",\n \"secret_scanning_alert.reopened\",\n \"secret_scanning_alert.resolved\",\n \"security_advisory\",\n \"security_advisory.performed\",\n \"security_advisory.published\",\n \"security_advisory.updated\",\n \"security_advisory.withdrawn\",\n \"sponsorship\",\n \"sponsorship.cancelled\",\n \"sponsorship.created\",\n \"sponsorship.edited\",\n \"sponsorship.pending_cancellation\",\n \"sponsorship.pending_tier_change\",\n \"sponsorship.tier_changed\",\n \"star\",\n \"star.created\",\n \"star.deleted\",\n \"status\",\n \"team\",\n \"team.added_to_repository\",\n \"team.created\",\n \"team.deleted\",\n \"team.edited\",\n \"team.removed_from_repository\",\n \"team_add\",\n \"watch\",\n \"watch.started\",\n \"workflow_dispatch\",\n \"workflow_job\",\n \"workflow_job.completed\",\n \"workflow_job.in_progress\",\n \"workflow_job.queued\",\n \"workflow_run\",\n \"workflow_run.completed\",\n \"workflow_run.requested\",\n];\n","import { emitterEventNames } from \"../generated/webhook-names\";\nfunction handleEventHandlers(state, webhookName, handler) {\n if (!state.hooks[webhookName]) {\n state.hooks[webhookName] = [];\n }\n state.hooks[webhookName].push(handler);\n}\nexport function receiverOn(state, webhookNameOrNames, handler) {\n if (Array.isArray(webhookNameOrNames)) {\n webhookNameOrNames.forEach((webhookName) => receiverOn(state, webhookName, handler));\n return;\n }\n if ([\"*\", \"error\"].includes(webhookNameOrNames)) {\n const webhookName = webhookNameOrNames === \"*\" ? \"any\" : webhookNameOrNames;\n 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`;\n throw new Error(message);\n }\n if (!emitterEventNames.includes(webhookNameOrNames)) {\n state.log.warn(`\"${webhookNameOrNames}\" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`);\n }\n handleEventHandlers(state, webhookNameOrNames, handler);\n}\nexport function receiverOnAny(state, handler) {\n handleEventHandlers(state, \"*\", handler);\n}\nexport function receiverOnError(state, handler) {\n handleEventHandlers(state, \"error\", handler);\n}\n","// Errors thrown or rejected Promises in \"error\" event handlers are not handled\n// as they are in the webhook event handlers. If errors occur, we log a\n// \"Fatal: Error occurred\" message to stdout\nexport function wrapErrorHandler(handler, error) {\n let returnValue;\n try {\n returnValue = handler(error);\n }\n catch (error) {\n console.log('FATAL: Error occurred in \"error\" event handler');\n console.log(error);\n }\n if (returnValue && returnValue.catch) {\n returnValue.catch((error) => {\n console.log('FATAL: Error occurred in \"error\" event handler');\n console.log(error);\n });\n }\n}\n","// @ts-ignore to address #245\nimport AggregateError from \"aggregate-error\";\nimport { wrapErrorHandler } from \"./wrap-error-handler\";\nfunction getHooks(state, eventPayloadAction, eventName) {\n const hooks = [state.hooks[eventName], state.hooks[\"*\"]];\n if (eventPayloadAction) {\n hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]);\n }\n return [].concat(...hooks.filter(Boolean));\n}\n// main handler function\nexport function receiverHandle(state, event) {\n const errorHandlers = state.hooks.error || [];\n if (event instanceof Error) {\n const error = Object.assign(new AggregateError([event]), {\n event,\n errors: [event],\n });\n errorHandlers.forEach((handler) => wrapErrorHandler(handler, error));\n return Promise.reject(error);\n }\n if (!event || !event.name) {\n throw new AggregateError([\"Event name not passed\"]);\n }\n if (!event.payload) {\n throw new AggregateError([\"Event payload not passed\"]);\n }\n // flatten arrays of event listeners and remove undefined values\n const hooks = getHooks(state, \"action\" in event.payload ? event.payload.action : null, event.name);\n if (hooks.length === 0) {\n return Promise.resolve();\n }\n const errors = [];\n const promises = hooks.map((handler) => {\n let promise = Promise.resolve(event);\n if (state.transform) {\n promise = promise.then(state.transform);\n }\n return promise\n .then((event) => {\n return handler(event);\n })\n .catch((error) => errors.push(Object.assign(error, { event })));\n });\n return Promise.all(promises).then(() => {\n if (errors.length === 0) {\n return;\n }\n const error = new AggregateError(errors);\n Object.assign(error, {\n event,\n errors,\n });\n errorHandlers.forEach((handler) => wrapErrorHandler(handler, error));\n throw error;\n });\n}\n","export function removeListener(state, webhookNameOrNames, handler) {\n if (Array.isArray(webhookNameOrNames)) {\n webhookNameOrNames.forEach((webhookName) => removeListener(state, webhookName, handler));\n return;\n }\n if (!state.hooks[webhookNameOrNames]) {\n return;\n }\n // remove last hook that has been added, that way\n // it behaves the same as removeListener\n for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) {\n if (state.hooks[webhookNameOrNames][i] === handler) {\n state.hooks[webhookNameOrNames].splice(i, 1);\n return;\n }\n }\n}\n","import { createLogger } from \"../createLogger\";\nimport { receiverOn as on, receiverOnAny as onAny, receiverOnError as onError, } from \"./on\";\nimport { receiverHandle as receive } from \"./receive\";\nimport { removeListener } from \"./remove-listener\";\nexport function createEventHandler(options) {\n const state = {\n hooks: {},\n log: createLogger(options && options.log),\n };\n if (options && options.transform) {\n state.transform = options.transform;\n }\n return {\n on: on.bind(null, state),\n onAny: onAny.bind(null, state),\n onError: onError.bind(null, state),\n removeListener: removeListener.bind(null, state),\n receive: receive.bind(null, state),\n };\n}\n","/**\n * GitHub sends its JSON with an indentation of 2 spaces and a line break at the end\n */\nexport function toNormalizedJsonString(payload) {\n const payloadString = JSON.stringify(payload);\n return payloadString.replace(/[^\\\\]\\\\u[\\da-f]{4}/g, (s) => {\n return s.substr(0, 3) + s.substr(3).toUpperCase();\n });\n}\n","import { sign as signMethod } from \"@octokit/webhooks-methods\";\nimport { toNormalizedJsonString } from \"./to-normalized-json-string\";\nexport async function sign(secret, payload) {\n return signMethod(secret, typeof payload === \"string\" ? payload : toNormalizedJsonString(payload));\n}\n","import { verify as verifyMethod } from \"@octokit/webhooks-methods\";\nimport { toNormalizedJsonString } from \"./to-normalized-json-string\";\nexport async function verify(secret, payload, signature) {\n return verifyMethod(secret, typeof payload === \"string\" ? payload : toNormalizedJsonString(payload), signature);\n}\n","import { verify } from \"@octokit/webhooks-methods\";\nimport { toNormalizedJsonString } from \"./to-normalized-json-string\";\nexport async function verifyAndReceive(state, event) {\n // verify will validate that the secret is not undefined\n const matchesSignature = await verify(state.secret, typeof event.payload === \"object\"\n ? toNormalizedJsonString(event.payload)\n : event.payload, event.signature);\n if (!matchesSignature) {\n const error = new Error(\"[@octokit/webhooks] signature does not match event payload and secret\");\n return state.eventHandler.receive(Object.assign(error, { event, status: 400 }));\n }\n return state.eventHandler.receive({\n id: event.id,\n name: event.name,\n payload: typeof event.payload === \"string\"\n ? JSON.parse(event.payload)\n : event.payload,\n });\n}\n","const WEBHOOK_HEADERS = [\n \"x-github-event\",\n \"x-hub-signature-256\",\n \"x-github-delivery\",\n];\n// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers\nexport function getMissingHeaders(request) {\n return WEBHOOK_HEADERS.filter((header) => !(header in request.headers));\n}\n","// @ts-ignore to address #245\nimport AggregateError from \"aggregate-error\";\nexport function getPayload(request) {\n // If request.body already exists we can stop here\n // See https://github.com/octokit/webhooks.js/pull/23\n if (request.body)\n return Promise.resolve(request.body);\n return new Promise((resolve, reject) => {\n let data = \"\";\n request.setEncoding(\"utf8\");\n // istanbul ignore next\n request.on(\"error\", (error) => reject(new AggregateError([error])));\n request.on(\"data\", (chunk) => (data += chunk));\n request.on(\"end\", () => {\n try {\n resolve(JSON.parse(data));\n }\n catch (error) {\n error.message = \"Invalid JSON\";\n error.status = 400;\n reject(new AggregateError([error]));\n }\n });\n });\n}\n","import { getMissingHeaders } from \"./get-missing-headers\";\nimport { getPayload } from \"./get-payload\";\nexport async function middleware(webhooks, options, request, response, next) {\n let pathname;\n try {\n pathname = new URL(request.url, \"http://localhost\").pathname;\n }\n catch (error) {\n response.writeHead(422, {\n \"content-type\": \"application/json\",\n });\n response.end(JSON.stringify({\n error: `Request URL could not be parsed: ${request.url}`,\n }));\n return;\n }\n const isUnknownRoute = request.method !== \"POST\" || pathname !== options.path;\n const isExpressMiddleware = typeof next === \"function\";\n if (isUnknownRoute) {\n if (isExpressMiddleware) {\n return next();\n }\n else {\n return options.onUnhandledRequest(request, response);\n }\n }\n const missingHeaders = getMissingHeaders(request).join(\", \");\n if (missingHeaders) {\n response.writeHead(400, {\n \"content-type\": \"application/json\",\n });\n response.end(JSON.stringify({\n error: `Required headers missing: ${missingHeaders}`,\n }));\n return;\n }\n const eventName = request.headers[\"x-github-event\"];\n const signatureSHA256 = request.headers[\"x-hub-signature-256\"];\n const id = request.headers[\"x-github-delivery\"];\n options.log.debug(`${eventName} event received (id: ${id})`);\n // GitHub will abort the request if it does not receive a response within 10s\n // See https://github.com/octokit/webhooks.js/issues/185\n let didTimeout = false;\n const timeout = setTimeout(() => {\n didTimeout = true;\n response.statusCode = 202;\n response.end(\"still processing\\n\");\n }, 9000).unref();\n try {\n const payload = await getPayload(request);\n await webhooks.verifyAndReceive({\n id: id,\n name: eventName,\n payload: payload,\n signature: signatureSHA256,\n });\n clearTimeout(timeout);\n if (didTimeout)\n return;\n response.end(\"ok\\n\");\n }\n catch (error) {\n clearTimeout(timeout);\n if (didTimeout)\n return;\n const statusCode = Array.from(error)[0].status;\n response.statusCode = typeof statusCode !== \"undefined\" ? statusCode : 500;\n response.end(String(error));\n }\n}\n","export function onUnhandledRequestDefault(request, response) {\n response.writeHead(404, {\n \"content-type\": \"application/json\",\n });\n response.end(JSON.stringify({\n error: `Unknown route: ${request.method} ${request.url}`,\n }));\n}\n","import { createLogger } from \"../../createLogger\";\nimport { middleware } from \"./middleware\";\nimport { onUnhandledRequestDefault } from \"./on-unhandled-request-default\";\nexport function createNodeMiddleware(webhooks, { path = \"/api/github/webhooks\", onUnhandledRequest = onUnhandledRequestDefault, log = createLogger(), } = {}) {\n return middleware.bind(null, webhooks, {\n path,\n onUnhandledRequest,\n log,\n });\n}\n","import { createLogger } from \"./createLogger\";\nimport { createEventHandler } from \"./event-handler/index\";\nimport { sign } from \"./sign\";\nimport { verify } from \"./verify\";\nimport { verifyAndReceive } from \"./verify-and-receive\";\nexport { createNodeMiddleware } from \"./middleware/node/index\";\nexport { emitterEventNames } from \"./generated/webhook-names\";\n// U holds the return value of `transform` function in Options\nclass Webhooks {\n constructor(options) {\n if (!options || !options.secret) {\n throw new Error(\"[@octokit/webhooks] options.secret required\");\n }\n const state = {\n eventHandler: createEventHandler(options),\n secret: options.secret,\n hooks: {},\n log: createLogger(options.log),\n };\n this.sign = sign.bind(null, options.secret);\n this.verify = verify.bind(null, options.secret);\n this.on = state.eventHandler.on;\n this.onAny = state.eventHandler.onAny;\n this.onError = state.eventHandler.onError;\n this.removeListener = state.eventHandler.removeListener;\n this.receive = state.eventHandler.receive;\n this.verifyAndReceive = verifyAndReceive.bind(null, state);\n }\n}\nexport { createEventHandler, Webhooks, };\n"],"names":["createLogger","logger","debug","info","warn","console","bind","error","emitterEventNames","handleEventHandlers","state","webhookName","handler","hooks","push","receiverOn","webhookNameOrNames","Array","isArray","forEach","includes","message","charAt","toUpperCase","slice","Error","log","receiverOnAny","receiverOnError","wrapErrorHandler","returnValue","catch","getHooks","eventPayloadAction","eventName","unshift","concat","filter","Boolean","receiverHandle","event","errorHandlers","Object","assign","AggregateError","errors","Promise","reject","name","payload","action","length","resolve","promises","map","promise","transform","then","all","removeListener","i","splice","createEventHandler","options","on","onAny","onError","receive","toNormalizedJsonString","payloadString","JSON","stringify","replace","s","substr","sign","secret","signMethod","verify","signature","verifyMethod","verifyAndReceive","matchesSignature","eventHandler","status","id","parse","WEBHOOK_HEADERS","getMissingHeaders","request","header","headers","getPayload","body","data","setEncoding","chunk","middleware","webhooks","response","next","pathname","URL","url","writeHead","end","isUnknownRoute","method","path","isExpressMiddleware","onUnhandledRequest","missingHeaders","join","signatureSHA256","didTimeout","timeout","setTimeout","statusCode","unref","clearTimeout","from","String","onUnhandledRequestDefault","createNodeMiddleware","Webhooks","constructor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAMA,YAAY,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