@octokit/webhooks 11.0.0-beta.1 → 11.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -61
- package/dist-node/index.js +27 -50
- package/dist-node/index.js.map +1 -1
- package/dist-src/generated/webhook-names.js +12 -0
- package/dist-src/index.js +12 -2
- package/dist-src/to-normalized-json-string.js +1 -1
- package/dist-types/generated/webhook-names.d.ts +1 -1
- package/dist-types/index.d.ts +12 -2
- package/dist-types/middleware/node/get-missing-headers.d.ts +1 -1
- package/dist-types/middleware/node/get-payload.d.ts +1 -1
- package/dist-types/middleware/node/middleware.d.ts +2 -2
- package/dist-types/middleware/node/on-unhandled-request-default.d.ts +2 -2
- package/dist-types/middleware/node/types.d.ts +1 -1
- package/dist-types/to-normalized-json-string.d.ts +1 -1
- package/dist-types/types.d.ts +10 -9
- package/dist-web/index.js +25 -3
- package/dist-web/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ webhooks.verify(eventPayload, signature);
|
|
|
191
191
|
eventPayload
|
|
192
192
|
</code>
|
|
193
193
|
<em>
|
|
194
|
-
(Object or String)
|
|
194
|
+
(Object [deprecated] or String)
|
|
195
195
|
</em>
|
|
196
196
|
</td>
|
|
197
197
|
<td>
|
|
@@ -262,7 +262,7 @@ webhooks.verifyAndReceive({ id, name, payload, signature });
|
|
|
262
262
|
payload
|
|
263
263
|
</code>
|
|
264
264
|
<em>
|
|
265
|
-
Object or String
|
|
265
|
+
Object (deprecated) or String
|
|
266
266
|
</em>
|
|
267
267
|
</td>
|
|
268
268
|
<td>
|
|
@@ -617,65 +617,67 @@ If there are actions for a webhook, events are emitted for both, the webhook nam
|
|
|
617
617
|
|
|
618
618
|
<!-- autogenerated via scripts/generate-types.ts -->
|
|
619
619
|
|
|
620
|
-
| Event | Actions
|
|
621
|
-
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
622
|
-
| [`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`
|
|
623
|
-
| [`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`
|
|
624
|
-
| [`check_suite`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_suite) | `completed`<br>`requested`<br>`rerequested`
|
|
625
|
-
| [`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`
|
|
626
|
-
| [`commit_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#commit_comment) | `created`
|
|
627
|
-
| [`create`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create) |
|
|
628
|
-
| [`delete`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delete) |
|
|
629
|
-
| [`
|
|
630
|
-
| [`
|
|
631
|
-
| [`
|
|
632
|
-
| [`
|
|
633
|
-
| [`
|
|
634
|
-
| [`
|
|
635
|
-
| [`
|
|
636
|
-
| [`
|
|
637
|
-
| [`
|
|
638
|
-
| [`
|
|
639
|
-
| [`
|
|
640
|
-
| [`
|
|
641
|
-
| [`
|
|
642
|
-
| [`
|
|
643
|
-
| [`
|
|
644
|
-
| [`
|
|
645
|
-
| [`
|
|
646
|
-
| [`
|
|
647
|
-
| [`
|
|
648
|
-
| [`
|
|
649
|
-
| [`
|
|
650
|
-
| [`
|
|
651
|
-
| [`
|
|
652
|
-
| [`
|
|
653
|
-
| [`
|
|
654
|
-
| [`
|
|
655
|
-
| [`
|
|
656
|
-
| [`
|
|
657
|
-
| [`
|
|
658
|
-
| [`
|
|
659
|
-
| [`
|
|
660
|
-
| [`
|
|
661
|
-
| [`
|
|
662
|
-
| [`
|
|
663
|
-
| [`
|
|
664
|
-
| [`
|
|
665
|
-
| [`
|
|
666
|
-
| [`
|
|
667
|
-
| [`
|
|
668
|
-
| [`
|
|
669
|
-
| [`
|
|
670
|
-
| [`
|
|
671
|
-
| [`
|
|
672
|
-
| [`
|
|
673
|
-
| [`
|
|
674
|
-
| [`
|
|
675
|
-
| [`
|
|
676
|
-
| [`
|
|
677
|
-
| [`
|
|
678
|
-
| [`
|
|
620
|
+
| Event | Actions |
|
|
621
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
622
|
+
| [`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` |
|
|
623
|
+
| [`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` |
|
|
624
|
+
| [`check_suite`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_suite) | `completed`<br>`requested`<br>`rerequested` |
|
|
625
|
+
| [`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` |
|
|
626
|
+
| [`commit_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#commit_comment) | `created` |
|
|
627
|
+
| [`create`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create) | |
|
|
628
|
+
| [`delete`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delete) | |
|
|
629
|
+
| [`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` |
|
|
630
|
+
| [`deploy_key`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deploy_key) | `created`<br>`deleted` |
|
|
631
|
+
| [`deployment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment) | `created` |
|
|
632
|
+
| [`deployment_status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_status) | `created` |
|
|
633
|
+
| [`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` |
|
|
634
|
+
| [`discussion_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion_comment) | `created`<br>`deleted`<br>`edited` |
|
|
635
|
+
| [`fork`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#fork) | |
|
|
636
|
+
| [`github_app_authorization`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#github_app_authorization) | `revoked` |
|
|
637
|
+
| [`gollum`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#gollum) | |
|
|
638
|
+
| [`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` |
|
|
639
|
+
| [`installation_repositories`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_repositories) | `added`<br>`removed` |
|
|
640
|
+
| [`issue_comment`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment) | `created`<br>`deleted`<br>`edited` |
|
|
641
|
+
| [`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` |
|
|
642
|
+
| [`label`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#label) | `created`<br>`deleted`<br>`edited` |
|
|
643
|
+
| [`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` |
|
|
644
|
+
| [`member`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#member) | `added`<br>`edited`<br>`removed` |
|
|
645
|
+
| [`membership`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#membership) | `added`<br>`removed` |
|
|
646
|
+
| [`merge_group`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#merge_group) | `checks_requested` |
|
|
647
|
+
| [`meta`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#meta) | `deleted` |
|
|
648
|
+
| [`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` |
|
|
649
|
+
| [`org_block`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#org_block) | `blocked`<br>`unblocked` |
|
|
650
|
+
| [`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` |
|
|
651
|
+
| [`package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#package) | `published`<br>`updated` |
|
|
652
|
+
| [`page_build`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#page_build) | |
|
|
653
|
+
| [`ping`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#ping) | |
|
|
654
|
+
| [`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` |
|
|
655
|
+
| [`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` |
|
|
656
|
+
| [`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` |
|
|
657
|
+
| [`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` |
|
|
658
|
+
| [`public`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#public) | |
|
|
659
|
+
| [`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` |
|
|
660
|
+
| [`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` |
|
|
661
|
+
| [`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` |
|
|
662
|
+
| [`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` |
|
|
663
|
+
| [`push`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push) | |
|
|
664
|
+
| [`registry_package`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#registry_package) | `published`<br>`updated` |
|
|
665
|
+
| [`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` |
|
|
666
|
+
| [`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` |
|
|
667
|
+
| [`repository_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_dispatch) | |
|
|
668
|
+
| [`repository_import`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import) | |
|
|
669
|
+
| [`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` |
|
|
670
|
+
| [`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` |
|
|
671
|
+
| [`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` |
|
|
672
|
+
| [`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` |
|
|
673
|
+
| [`star`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star) | `created`<br>`deleted` |
|
|
674
|
+
| [`status`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status) | |
|
|
675
|
+
| [`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` |
|
|
676
|
+
| [`team_add`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team_add) | |
|
|
677
|
+
| [`watch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#watch) | `started` |
|
|
678
|
+
| [`workflow_dispatch`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch) | |
|
|
679
|
+
| [`workflow_job`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job) | `completed`<br>`in_progress`<br>`queued` |
|
|
680
|
+
| [`workflow_run`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run) | `completed`<br>`in_progress`<br>`requested` |
|
|
679
681
|
|
|
680
682
|
<!-- /autogenerated via scripts/generate-types.ts -->
|
|
681
683
|
|
package/dist-node/index.js
CHANGED
|
@@ -17,32 +17,27 @@ const createLogger = logger => ({
|
|
|
17
17
|
|
|
18
18
|
// THIS FILE IS GENERATED - DO NOT EDIT DIRECTLY
|
|
19
19
|
// make edits in scripts/generate-types.ts
|
|
20
|
-
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", "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", "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.edited", "pull_request.labeled", "pull_request.locked", "pull_request.opened", "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", "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.requested"];
|
|
20
|
+
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", "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"];
|
|
21
21
|
|
|
22
22
|
function handleEventHandlers(state, webhookName, handler) {
|
|
23
23
|
if (!state.hooks[webhookName]) {
|
|
24
24
|
state.hooks[webhookName] = [];
|
|
25
25
|
}
|
|
26
|
-
|
|
27
26
|
state.hooks[webhookName].push(handler);
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
function receiverOn(state, webhookNameOrNames, handler) {
|
|
31
29
|
if (Array.isArray(webhookNameOrNames)) {
|
|
32
30
|
webhookNameOrNames.forEach(webhookName => receiverOn(state, webhookName, handler));
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
if (["*", "error"].includes(webhookNameOrNames)) {
|
|
37
34
|
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames;
|
|
38
35
|
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`;
|
|
39
36
|
throw new Error(message);
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
if (!emitterEventNames.includes(webhookNameOrNames)) {
|
|
43
39
|
state.log.warn(`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`);
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
handleEventHandlers(state, webhookNameOrNames, handler);
|
|
47
42
|
}
|
|
48
43
|
function receiverOnAny(state, handler) {
|
|
@@ -57,14 +52,12 @@ function receiverOnError(state, handler) {
|
|
|
57
52
|
// "Fatal: Error occurred" message to stdout
|
|
58
53
|
function wrapErrorHandler(handler, error) {
|
|
59
54
|
let returnValue;
|
|
60
|
-
|
|
61
55
|
try {
|
|
62
56
|
returnValue = handler(error);
|
|
63
57
|
} catch (error) {
|
|
64
58
|
console.log('FATAL: Error occurred in "error" event handler');
|
|
65
59
|
console.log(error);
|
|
66
60
|
}
|
|
67
|
-
|
|
68
61
|
if (returnValue && returnValue.catch) {
|
|
69
62
|
returnValue.catch(error => {
|
|
70
63
|
console.log('FATAL: Error occurred in "error" event handler');
|
|
@@ -74,21 +67,16 @@ function wrapErrorHandler(handler, error) {
|
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
// @ts-ignore to address #245
|
|
77
|
-
|
|
78
70
|
function getHooks(state, eventPayloadAction, eventName) {
|
|
79
71
|
const hooks = [state.hooks[eventName], state.hooks["*"]];
|
|
80
|
-
|
|
81
72
|
if (eventPayloadAction) {
|
|
82
73
|
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]);
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
return [].concat(...hooks.filter(Boolean));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
}
|
|
77
|
+
// main handler function
|
|
89
78
|
function receiverHandle(state, event) {
|
|
90
79
|
const errorHandlers = state.hooks.error || [];
|
|
91
|
-
|
|
92
80
|
if (event instanceof Error) {
|
|
93
81
|
const error = Object.assign(new AggregateError([event]), {
|
|
94
82
|
event,
|
|
@@ -97,30 +85,23 @@ function receiverHandle(state, event) {
|
|
|
97
85
|
errorHandlers.forEach(handler => wrapErrorHandler(handler, error));
|
|
98
86
|
return Promise.reject(error);
|
|
99
87
|
}
|
|
100
|
-
|
|
101
88
|
if (!event || !event.name) {
|
|
102
89
|
throw new AggregateError(["Event name not passed"]);
|
|
103
90
|
}
|
|
104
|
-
|
|
105
91
|
if (!event.payload) {
|
|
106
92
|
throw new AggregateError(["Event payload not passed"]);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
93
|
+
}
|
|
94
|
+
// flatten arrays of event listeners and remove undefined values
|
|
110
95
|
const hooks = getHooks(state, "action" in event.payload ? event.payload.action : null, event.name);
|
|
111
|
-
|
|
112
96
|
if (hooks.length === 0) {
|
|
113
97
|
return Promise.resolve();
|
|
114
98
|
}
|
|
115
|
-
|
|
116
99
|
const errors = [];
|
|
117
100
|
const promises = hooks.map(handler => {
|
|
118
101
|
let promise = Promise.resolve(event);
|
|
119
|
-
|
|
120
102
|
if (state.transform) {
|
|
121
103
|
promise = promise.then(state.transform);
|
|
122
104
|
}
|
|
123
|
-
|
|
124
105
|
return promise.then(event => {
|
|
125
106
|
return handler(event);
|
|
126
107
|
}).catch(error => errors.push(Object.assign(error, {
|
|
@@ -131,7 +112,6 @@ function receiverHandle(state, event) {
|
|
|
131
112
|
if (errors.length === 0) {
|
|
132
113
|
return;
|
|
133
114
|
}
|
|
134
|
-
|
|
135
115
|
const error = new AggregateError(errors);
|
|
136
116
|
Object.assign(error, {
|
|
137
117
|
event,
|
|
@@ -147,13 +127,11 @@ function removeListener(state, webhookNameOrNames, handler) {
|
|
|
147
127
|
webhookNameOrNames.forEach(webhookName => removeListener(state, webhookName, handler));
|
|
148
128
|
return;
|
|
149
129
|
}
|
|
150
|
-
|
|
151
130
|
if (!state.hooks[webhookNameOrNames]) {
|
|
152
131
|
return;
|
|
153
|
-
}
|
|
132
|
+
}
|
|
133
|
+
// remove last hook that has been added, that way
|
|
154
134
|
// it behaves the same as removeListener
|
|
155
|
-
|
|
156
|
-
|
|
157
135
|
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) {
|
|
158
136
|
if (state.hooks[webhookNameOrNames][i] === handler) {
|
|
159
137
|
state.hooks[webhookNameOrNames].splice(i, 1);
|
|
@@ -167,11 +145,9 @@ function createEventHandler(options) {
|
|
|
167
145
|
hooks: {},
|
|
168
146
|
log: createLogger(options && options.log)
|
|
169
147
|
};
|
|
170
|
-
|
|
171
148
|
if (options && options.transform) {
|
|
172
149
|
state.transform = options.transform;
|
|
173
150
|
}
|
|
174
|
-
|
|
175
151
|
return {
|
|
176
152
|
on: receiverOn.bind(null, state),
|
|
177
153
|
onAny: receiverOnAny.bind(null, state),
|
|
@@ -182,7 +158,7 @@ function createEventHandler(options) {
|
|
|
182
158
|
}
|
|
183
159
|
|
|
184
160
|
/**
|
|
185
|
-
* GitHub sends its JSON with
|
|
161
|
+
* GitHub sends its JSON with no indentation and no line break at the end
|
|
186
162
|
*/
|
|
187
163
|
function toNormalizedJsonString(payload) {
|
|
188
164
|
const payloadString = JSON.stringify(payload);
|
|
@@ -202,7 +178,6 @@ async function verify(secret, payload, signature) {
|
|
|
202
178
|
async function verifyAndReceive(state, event) {
|
|
203
179
|
// verify will validate that the secret is not undefined
|
|
204
180
|
const matchesSignature = await webhooksMethods.verify(state.secret, typeof event.payload === "object" ? toNormalizedJsonString(event.payload) : event.payload, event.signature);
|
|
205
|
-
|
|
206
181
|
if (!matchesSignature) {
|
|
207
182
|
const error = new Error("[@octokit/webhooks] signature does not match event payload and secret");
|
|
208
183
|
return state.eventHandler.receive(Object.assign(error, {
|
|
@@ -210,7 +185,6 @@ async function verifyAndReceive(state, event) {
|
|
|
210
185
|
status: 400
|
|
211
186
|
}));
|
|
212
187
|
}
|
|
213
|
-
|
|
214
188
|
return state.eventHandler.receive({
|
|
215
189
|
id: event.id,
|
|
216
190
|
name: event.name,
|
|
@@ -218,8 +192,8 @@ async function verifyAndReceive(state, event) {
|
|
|
218
192
|
});
|
|
219
193
|
}
|
|
220
194
|
|
|
221
|
-
const WEBHOOK_HEADERS = ["x-github-event", "x-hub-signature-256", "x-github-delivery"];
|
|
222
|
-
|
|
195
|
+
const WEBHOOK_HEADERS = ["x-github-event", "x-hub-signature-256", "x-github-delivery"];
|
|
196
|
+
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers
|
|
223
197
|
function getMissingHeaders(request) {
|
|
224
198
|
return WEBHOOK_HEADERS.filter(header => !(header in request.headers));
|
|
225
199
|
}
|
|
@@ -231,8 +205,8 @@ function getPayload(request) {
|
|
|
231
205
|
if (request.body) return Promise.resolve(request.body);
|
|
232
206
|
return new Promise((resolve, reject) => {
|
|
233
207
|
let data = "";
|
|
234
|
-
request.setEncoding("utf8");
|
|
235
|
-
|
|
208
|
+
request.setEncoding("utf8");
|
|
209
|
+
// istanbul ignore next
|
|
236
210
|
request.on("error", error => reject(new AggregateError([error])));
|
|
237
211
|
request.on("data", chunk => data += chunk);
|
|
238
212
|
request.on("end", () => {
|
|
@@ -258,7 +232,6 @@ function onUnhandledRequestDefault(request, response) {
|
|
|
258
232
|
|
|
259
233
|
async function middleware(webhooks, options, request, response, next) {
|
|
260
234
|
let pathname;
|
|
261
|
-
|
|
262
235
|
try {
|
|
263
236
|
pathname = new URL(request.url, "http://localhost").pathname;
|
|
264
237
|
} catch (error) {
|
|
@@ -270,7 +243,6 @@ async function middleware(webhooks, options, request, response, next) {
|
|
|
270
243
|
}));
|
|
271
244
|
return true;
|
|
272
245
|
}
|
|
273
|
-
|
|
274
246
|
if (pathname !== options.path) {
|
|
275
247
|
next === null || next === void 0 ? void 0 : next();
|
|
276
248
|
return false;
|
|
@@ -278,9 +250,7 @@ async function middleware(webhooks, options, request, response, next) {
|
|
|
278
250
|
onUnhandledRequestDefault(request, response);
|
|
279
251
|
return true;
|
|
280
252
|
}
|
|
281
|
-
|
|
282
253
|
const missingHeaders = getMissingHeaders(request).join(", ");
|
|
283
|
-
|
|
284
254
|
if (missingHeaders) {
|
|
285
255
|
response.writeHead(400, {
|
|
286
256
|
"content-type": "application/json"
|
|
@@ -290,20 +260,18 @@ async function middleware(webhooks, options, request, response, next) {
|
|
|
290
260
|
}));
|
|
291
261
|
return true;
|
|
292
262
|
}
|
|
293
|
-
|
|
294
263
|
const eventName = request.headers["x-github-event"];
|
|
295
264
|
const signatureSHA256 = request.headers["x-hub-signature-256"];
|
|
296
265
|
const id = request.headers["x-github-delivery"];
|
|
297
|
-
options.log.debug(`${eventName} event received (id: ${id})`);
|
|
266
|
+
options.log.debug(`${eventName} event received (id: ${id})`);
|
|
267
|
+
// GitHub will abort the request if it does not receive a response within 10s
|
|
298
268
|
// See https://github.com/octokit/webhooks.js/issues/185
|
|
299
|
-
|
|
300
269
|
let didTimeout = false;
|
|
301
270
|
const timeout = setTimeout(() => {
|
|
302
271
|
didTimeout = true;
|
|
303
272
|
response.statusCode = 202;
|
|
304
273
|
response.end("still processing\n");
|
|
305
274
|
}, 9000).unref();
|
|
306
|
-
|
|
307
275
|
try {
|
|
308
276
|
const payload = await getPayload(request);
|
|
309
277
|
await webhooks.verifyAndReceive({
|
|
@@ -340,12 +308,12 @@ function createNodeMiddleware(webhooks, {
|
|
|
340
308
|
});
|
|
341
309
|
}
|
|
342
310
|
|
|
311
|
+
// U holds the return value of `transform` function in Options
|
|
343
312
|
class Webhooks {
|
|
344
313
|
constructor(options) {
|
|
345
314
|
if (!options || !options.secret) {
|
|
346
315
|
throw new Error("[@octokit/webhooks] options.secret required");
|
|
347
316
|
}
|
|
348
|
-
|
|
349
317
|
const state = {
|
|
350
318
|
eventHandler: createEventHandler(options),
|
|
351
319
|
secret: options.secret,
|
|
@@ -353,15 +321,24 @@ class Webhooks {
|
|
|
353
321
|
log: createLogger(options.log)
|
|
354
322
|
};
|
|
355
323
|
this.sign = sign.bind(null, options.secret);
|
|
356
|
-
this.verify =
|
|
324
|
+
this.verify = (eventPayload, signature) => {
|
|
325
|
+
if (typeof eventPayload === "object") {
|
|
326
|
+
console.error("[@octokit/webhooks] Passing a JSON payload object to `verify()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`");
|
|
327
|
+
}
|
|
328
|
+
return verify(options.secret, eventPayload, signature);
|
|
329
|
+
};
|
|
357
330
|
this.on = state.eventHandler.on;
|
|
358
331
|
this.onAny = state.eventHandler.onAny;
|
|
359
332
|
this.onError = state.eventHandler.onError;
|
|
360
333
|
this.removeListener = state.eventHandler.removeListener;
|
|
361
334
|
this.receive = state.eventHandler.receive;
|
|
362
|
-
this.verifyAndReceive =
|
|
335
|
+
this.verifyAndReceive = options => {
|
|
336
|
+
if (typeof options.payload === "object") {
|
|
337
|
+
console.error("[@octokit/webhooks] Passing a JSON payload object to `verifyAndReceive()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`");
|
|
338
|
+
}
|
|
339
|
+
return verifyAndReceive(state, options);
|
|
340
|
+
};
|
|
363
341
|
}
|
|
364
|
-
|
|
365
342
|
}
|
|
366
343
|
|
|
367
344
|
exports.Webhooks = Webhooks;
|