@octokit/webhooks 10.7.0 → 10.7.1
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/dist-node/index.js +440 -106
- package/dist-node/index.js.map +6 -1
- package/dist-src/createLogger.js +11 -6
- package/dist-src/event-handler/index.js +23 -16
- package/dist-src/event-handler/on.js +31 -22
- package/dist-src/event-handler/receive.js +51 -49
- package/dist-src/event-handler/remove-listener.js +18 -15
- package/dist-src/event-handler/wrap-error-handler.js +17 -18
- package/dist-src/generated/webhook-names.js +260 -259
- package/dist-src/index.js +40 -32
- package/dist-src/middleware/node/get-missing-headers.js +8 -6
- package/dist-src/middleware/node/get-payload.js +26 -27
- package/dist-src/middleware/node/index.js +19 -10
- package/dist-src/middleware/node/middleware.js +86 -86
- package/dist-src/middleware/node/on-unhandled-request-default.js +12 -7
- package/dist-src/sign.js +8 -2
- package/dist-src/to-normalized-json-string.js +8 -8
- package/dist-src/verify-and-receive.js +22 -16
- package/dist-src/verify.js +9 -2
- package/dist-types/event-handler/on.d.ts +1 -1
- package/dist-types/event-handler/remove-listener.d.ts +1 -1
- package/dist-types/index.d.ts +2 -2
- package/dist-types/middleware/node/get-payload.d.ts +1 -1
- package/dist-types/middleware/node/index.d.ts +2 -2
- package/dist-types/middleware/node/middleware.d.ts +2 -2
- package/dist-types/middleware/node/types.d.ts +1 -1
- package/dist-types/types.d.ts +2 -2
- package/dist-types/verify-and-receive.d.ts +1 -1
- package/dist-web/index.js +606 -571
- package/dist-web/index.js.map +6 -1
- package/package.json +17 -19
- package/dist-src/middleware/node/types.js +0 -1
- package/dist-src/types.js +0 -1
package/dist-web/index.js
CHANGED
|
@@ -1,633 +1,668 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// pkg/dist-src/createLogger.js
|
|
2
|
+
var createLogger = (logger) => ({
|
|
3
|
+
debug: () => {
|
|
4
|
+
},
|
|
5
|
+
info: () => {
|
|
6
|
+
},
|
|
7
|
+
warn: console.warn.bind(console),
|
|
8
|
+
error: console.error.bind(console),
|
|
9
|
+
...logger
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"workflow_run.requested",
|
|
12
|
+
// pkg/dist-src/generated/webhook-names.js
|
|
13
|
+
var emitterEventNames = [
|
|
14
|
+
"branch_protection_rule",
|
|
15
|
+
"branch_protection_rule.created",
|
|
16
|
+
"branch_protection_rule.deleted",
|
|
17
|
+
"branch_protection_rule.edited",
|
|
18
|
+
"check_run",
|
|
19
|
+
"check_run.completed",
|
|
20
|
+
"check_run.created",
|
|
21
|
+
"check_run.requested_action",
|
|
22
|
+
"check_run.rerequested",
|
|
23
|
+
"check_suite",
|
|
24
|
+
"check_suite.completed",
|
|
25
|
+
"check_suite.requested",
|
|
26
|
+
"check_suite.rerequested",
|
|
27
|
+
"code_scanning_alert",
|
|
28
|
+
"code_scanning_alert.appeared_in_branch",
|
|
29
|
+
"code_scanning_alert.closed_by_user",
|
|
30
|
+
"code_scanning_alert.created",
|
|
31
|
+
"code_scanning_alert.fixed",
|
|
32
|
+
"code_scanning_alert.reopened",
|
|
33
|
+
"code_scanning_alert.reopened_by_user",
|
|
34
|
+
"commit_comment",
|
|
35
|
+
"commit_comment.created",
|
|
36
|
+
"create",
|
|
37
|
+
"delete",
|
|
38
|
+
"dependabot_alert",
|
|
39
|
+
"dependabot_alert.created",
|
|
40
|
+
"dependabot_alert.dismissed",
|
|
41
|
+
"dependabot_alert.fixed",
|
|
42
|
+
"dependabot_alert.reintroduced",
|
|
43
|
+
"dependabot_alert.reopened",
|
|
44
|
+
"deploy_key",
|
|
45
|
+
"deploy_key.created",
|
|
46
|
+
"deploy_key.deleted",
|
|
47
|
+
"deployment",
|
|
48
|
+
"deployment.created",
|
|
49
|
+
"deployment_status",
|
|
50
|
+
"deployment_status.created",
|
|
51
|
+
"discussion",
|
|
52
|
+
"discussion.answered",
|
|
53
|
+
"discussion.category_changed",
|
|
54
|
+
"discussion.created",
|
|
55
|
+
"discussion.deleted",
|
|
56
|
+
"discussion.edited",
|
|
57
|
+
"discussion.labeled",
|
|
58
|
+
"discussion.locked",
|
|
59
|
+
"discussion.pinned",
|
|
60
|
+
"discussion.transferred",
|
|
61
|
+
"discussion.unanswered",
|
|
62
|
+
"discussion.unlabeled",
|
|
63
|
+
"discussion.unlocked",
|
|
64
|
+
"discussion.unpinned",
|
|
65
|
+
"discussion_comment",
|
|
66
|
+
"discussion_comment.created",
|
|
67
|
+
"discussion_comment.deleted",
|
|
68
|
+
"discussion_comment.edited",
|
|
69
|
+
"fork",
|
|
70
|
+
"github_app_authorization",
|
|
71
|
+
"github_app_authorization.revoked",
|
|
72
|
+
"gollum",
|
|
73
|
+
"installation",
|
|
74
|
+
"installation.created",
|
|
75
|
+
"installation.deleted",
|
|
76
|
+
"installation.new_permissions_accepted",
|
|
77
|
+
"installation.suspend",
|
|
78
|
+
"installation.unsuspend",
|
|
79
|
+
"installation_repositories",
|
|
80
|
+
"installation_repositories.added",
|
|
81
|
+
"installation_repositories.removed",
|
|
82
|
+
"installation_target",
|
|
83
|
+
"installation_target.renamed",
|
|
84
|
+
"issue_comment",
|
|
85
|
+
"issue_comment.created",
|
|
86
|
+
"issue_comment.deleted",
|
|
87
|
+
"issue_comment.edited",
|
|
88
|
+
"issues",
|
|
89
|
+
"issues.assigned",
|
|
90
|
+
"issues.closed",
|
|
91
|
+
"issues.deleted",
|
|
92
|
+
"issues.demilestoned",
|
|
93
|
+
"issues.edited",
|
|
94
|
+
"issues.labeled",
|
|
95
|
+
"issues.locked",
|
|
96
|
+
"issues.milestoned",
|
|
97
|
+
"issues.opened",
|
|
98
|
+
"issues.pinned",
|
|
99
|
+
"issues.reopened",
|
|
100
|
+
"issues.transferred",
|
|
101
|
+
"issues.unassigned",
|
|
102
|
+
"issues.unlabeled",
|
|
103
|
+
"issues.unlocked",
|
|
104
|
+
"issues.unpinned",
|
|
105
|
+
"label",
|
|
106
|
+
"label.created",
|
|
107
|
+
"label.deleted",
|
|
108
|
+
"label.edited",
|
|
109
|
+
"marketplace_purchase",
|
|
110
|
+
"marketplace_purchase.cancelled",
|
|
111
|
+
"marketplace_purchase.changed",
|
|
112
|
+
"marketplace_purchase.pending_change",
|
|
113
|
+
"marketplace_purchase.pending_change_cancelled",
|
|
114
|
+
"marketplace_purchase.purchased",
|
|
115
|
+
"member",
|
|
116
|
+
"member.added",
|
|
117
|
+
"member.edited",
|
|
118
|
+
"member.removed",
|
|
119
|
+
"membership",
|
|
120
|
+
"membership.added",
|
|
121
|
+
"membership.removed",
|
|
122
|
+
"merge_group",
|
|
123
|
+
"merge_group.checks_requested",
|
|
124
|
+
"meta",
|
|
125
|
+
"meta.deleted",
|
|
126
|
+
"milestone",
|
|
127
|
+
"milestone.closed",
|
|
128
|
+
"milestone.created",
|
|
129
|
+
"milestone.deleted",
|
|
130
|
+
"milestone.edited",
|
|
131
|
+
"milestone.opened",
|
|
132
|
+
"org_block",
|
|
133
|
+
"org_block.blocked",
|
|
134
|
+
"org_block.unblocked",
|
|
135
|
+
"organization",
|
|
136
|
+
"organization.deleted",
|
|
137
|
+
"organization.member_added",
|
|
138
|
+
"organization.member_invited",
|
|
139
|
+
"organization.member_removed",
|
|
140
|
+
"organization.renamed",
|
|
141
|
+
"package",
|
|
142
|
+
"package.published",
|
|
143
|
+
"package.updated",
|
|
144
|
+
"page_build",
|
|
145
|
+
"ping",
|
|
146
|
+
"project",
|
|
147
|
+
"project.closed",
|
|
148
|
+
"project.created",
|
|
149
|
+
"project.deleted",
|
|
150
|
+
"project.edited",
|
|
151
|
+
"project.reopened",
|
|
152
|
+
"project_card",
|
|
153
|
+
"project_card.converted",
|
|
154
|
+
"project_card.created",
|
|
155
|
+
"project_card.deleted",
|
|
156
|
+
"project_card.edited",
|
|
157
|
+
"project_card.moved",
|
|
158
|
+
"project_column",
|
|
159
|
+
"project_column.created",
|
|
160
|
+
"project_column.deleted",
|
|
161
|
+
"project_column.edited",
|
|
162
|
+
"project_column.moved",
|
|
163
|
+
"projects_v2_item",
|
|
164
|
+
"projects_v2_item.archived",
|
|
165
|
+
"projects_v2_item.converted",
|
|
166
|
+
"projects_v2_item.created",
|
|
167
|
+
"projects_v2_item.deleted",
|
|
168
|
+
"projects_v2_item.edited",
|
|
169
|
+
"projects_v2_item.reordered",
|
|
170
|
+
"projects_v2_item.restored",
|
|
171
|
+
"public",
|
|
172
|
+
"pull_request",
|
|
173
|
+
"pull_request.assigned",
|
|
174
|
+
"pull_request.auto_merge_disabled",
|
|
175
|
+
"pull_request.auto_merge_enabled",
|
|
176
|
+
"pull_request.closed",
|
|
177
|
+
"pull_request.converted_to_draft",
|
|
178
|
+
"pull_request.dequeued",
|
|
179
|
+
"pull_request.edited",
|
|
180
|
+
"pull_request.labeled",
|
|
181
|
+
"pull_request.locked",
|
|
182
|
+
"pull_request.opened",
|
|
183
|
+
"pull_request.queued",
|
|
184
|
+
"pull_request.ready_for_review",
|
|
185
|
+
"pull_request.reopened",
|
|
186
|
+
"pull_request.review_request_removed",
|
|
187
|
+
"pull_request.review_requested",
|
|
188
|
+
"pull_request.synchronize",
|
|
189
|
+
"pull_request.unassigned",
|
|
190
|
+
"pull_request.unlabeled",
|
|
191
|
+
"pull_request.unlocked",
|
|
192
|
+
"pull_request_review",
|
|
193
|
+
"pull_request_review.dismissed",
|
|
194
|
+
"pull_request_review.edited",
|
|
195
|
+
"pull_request_review.submitted",
|
|
196
|
+
"pull_request_review_comment",
|
|
197
|
+
"pull_request_review_comment.created",
|
|
198
|
+
"pull_request_review_comment.deleted",
|
|
199
|
+
"pull_request_review_comment.edited",
|
|
200
|
+
"pull_request_review_thread",
|
|
201
|
+
"pull_request_review_thread.resolved",
|
|
202
|
+
"pull_request_review_thread.unresolved",
|
|
203
|
+
"push",
|
|
204
|
+
"registry_package",
|
|
205
|
+
"registry_package.published",
|
|
206
|
+
"registry_package.updated",
|
|
207
|
+
"release",
|
|
208
|
+
"release.created",
|
|
209
|
+
"release.deleted",
|
|
210
|
+
"release.edited",
|
|
211
|
+
"release.prereleased",
|
|
212
|
+
"release.published",
|
|
213
|
+
"release.released",
|
|
214
|
+
"release.unpublished",
|
|
215
|
+
"repository",
|
|
216
|
+
"repository.archived",
|
|
217
|
+
"repository.created",
|
|
218
|
+
"repository.deleted",
|
|
219
|
+
"repository.edited",
|
|
220
|
+
"repository.privatized",
|
|
221
|
+
"repository.publicized",
|
|
222
|
+
"repository.renamed",
|
|
223
|
+
"repository.transferred",
|
|
224
|
+
"repository.unarchived",
|
|
225
|
+
"repository_dispatch",
|
|
226
|
+
"repository_import",
|
|
227
|
+
"repository_vulnerability_alert",
|
|
228
|
+
"repository_vulnerability_alert.create",
|
|
229
|
+
"repository_vulnerability_alert.dismiss",
|
|
230
|
+
"repository_vulnerability_alert.reopen",
|
|
231
|
+
"repository_vulnerability_alert.resolve",
|
|
232
|
+
"secret_scanning_alert",
|
|
233
|
+
"secret_scanning_alert.created",
|
|
234
|
+
"secret_scanning_alert.reopened",
|
|
235
|
+
"secret_scanning_alert.resolved",
|
|
236
|
+
"security_advisory",
|
|
237
|
+
"security_advisory.performed",
|
|
238
|
+
"security_advisory.published",
|
|
239
|
+
"security_advisory.updated",
|
|
240
|
+
"security_advisory.withdrawn",
|
|
241
|
+
"sponsorship",
|
|
242
|
+
"sponsorship.cancelled",
|
|
243
|
+
"sponsorship.created",
|
|
244
|
+
"sponsorship.edited",
|
|
245
|
+
"sponsorship.pending_cancellation",
|
|
246
|
+
"sponsorship.pending_tier_change",
|
|
247
|
+
"sponsorship.tier_changed",
|
|
248
|
+
"star",
|
|
249
|
+
"star.created",
|
|
250
|
+
"star.deleted",
|
|
251
|
+
"status",
|
|
252
|
+
"team",
|
|
253
|
+
"team.added_to_repository",
|
|
254
|
+
"team.created",
|
|
255
|
+
"team.deleted",
|
|
256
|
+
"team.edited",
|
|
257
|
+
"team.removed_from_repository",
|
|
258
|
+
"team_add",
|
|
259
|
+
"watch",
|
|
260
|
+
"watch.started",
|
|
261
|
+
"workflow_dispatch",
|
|
262
|
+
"workflow_job",
|
|
263
|
+
"workflow_job.completed",
|
|
264
|
+
"workflow_job.in_progress",
|
|
265
|
+
"workflow_job.queued",
|
|
266
|
+
"workflow_run",
|
|
267
|
+
"workflow_run.completed",
|
|
268
|
+
"workflow_run.in_progress",
|
|
269
|
+
"workflow_run.requested"
|
|
271
270
|
];
|
|
272
271
|
|
|
272
|
+
// pkg/dist-src/event-handler/on.js
|
|
273
273
|
function handleEventHandlers(state, webhookName, handler) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
if (!state.hooks[webhookName]) {
|
|
275
|
+
state.hooks[webhookName] = [];
|
|
276
|
+
}
|
|
277
|
+
state.hooks[webhookName].push(handler);
|
|
278
278
|
}
|
|
279
279
|
function receiverOn(state, webhookNameOrNames, handler) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
280
|
+
if (Array.isArray(webhookNameOrNames)) {
|
|
281
|
+
webhookNameOrNames.forEach(
|
|
282
|
+
(webhookName) => receiverOn(state, webhookName, handler)
|
|
283
|
+
);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (["*", "error"].includes(webhookNameOrNames)) {
|
|
287
|
+
const webhookName = webhookNameOrNames === "*" ? "any" : webhookNameOrNames;
|
|
288
|
+
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`;
|
|
289
|
+
throw new Error(message);
|
|
290
|
+
}
|
|
291
|
+
if (!emitterEventNames.includes(webhookNameOrNames)) {
|
|
292
|
+
state.log.warn(
|
|
293
|
+
`"${webhookNameOrNames}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
handleEventHandlers(state, webhookNameOrNames, handler);
|
|
293
297
|
}
|
|
294
298
|
function receiverOnAny(state, handler) {
|
|
295
|
-
|
|
299
|
+
handleEventHandlers(state, "*", handler);
|
|
296
300
|
}
|
|
297
301
|
function receiverOnError(state, handler) {
|
|
298
|
-
|
|
302
|
+
handleEventHandlers(state, "error", handler);
|
|
299
303
|
}
|
|
300
304
|
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
|
|
305
|
+
// pkg/dist-src/event-handler/receive.js
|
|
306
|
+
import AggregateError from "aggregate-error";
|
|
307
|
+
|
|
308
|
+
// pkg/dist-src/event-handler/wrap-error-handler.js
|
|
304
309
|
function wrapErrorHandler(handler, error) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
310
|
+
let returnValue;
|
|
311
|
+
try {
|
|
312
|
+
returnValue = handler(error);
|
|
313
|
+
} catch (error2) {
|
|
314
|
+
console.log('FATAL: Error occurred in "error" event handler');
|
|
315
|
+
console.log(error2);
|
|
316
|
+
}
|
|
317
|
+
if (returnValue && returnValue.catch) {
|
|
318
|
+
returnValue.catch((error2) => {
|
|
319
|
+
console.log('FATAL: Error occurred in "error" event handler');
|
|
320
|
+
console.log(error2);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
319
323
|
}
|
|
320
324
|
|
|
321
|
-
//
|
|
325
|
+
// pkg/dist-src/event-handler/receive.js
|
|
322
326
|
function getHooks(state, eventPayloadAction, eventName) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
327
|
+
const hooks = [state.hooks[eventName], state.hooks["*"]];
|
|
328
|
+
if (eventPayloadAction) {
|
|
329
|
+
hooks.unshift(state.hooks[`${eventName}.${eventPayloadAction}`]);
|
|
330
|
+
}
|
|
331
|
+
return [].concat(...hooks.filter(Boolean));
|
|
328
332
|
}
|
|
329
|
-
// main handler function
|
|
330
333
|
function receiverHandle(state, event) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
const errorHandlers = state.hooks.error || [];
|
|
335
|
+
if (event instanceof Error) {
|
|
336
|
+
const error = Object.assign(new AggregateError([event]), {
|
|
337
|
+
event,
|
|
338
|
+
errors: [event]
|
|
339
|
+
});
|
|
340
|
+
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error));
|
|
341
|
+
return Promise.reject(error);
|
|
342
|
+
}
|
|
343
|
+
if (!event || !event.name) {
|
|
344
|
+
throw new AggregateError(["Event name not passed"]);
|
|
345
|
+
}
|
|
346
|
+
if (!event.payload) {
|
|
347
|
+
throw new AggregateError(["Event payload not passed"]);
|
|
348
|
+
}
|
|
349
|
+
const hooks = getHooks(
|
|
350
|
+
state,
|
|
351
|
+
"action" in event.payload ? event.payload.action : null,
|
|
352
|
+
event.name
|
|
353
|
+
);
|
|
354
|
+
if (hooks.length === 0) {
|
|
355
|
+
return Promise.resolve();
|
|
356
|
+
}
|
|
357
|
+
const errors = [];
|
|
358
|
+
const promises = hooks.map((handler) => {
|
|
359
|
+
let promise = Promise.resolve(event);
|
|
360
|
+
if (state.transform) {
|
|
361
|
+
promise = promise.then(state.transform);
|
|
345
362
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
363
|
+
return promise.then((event2) => {
|
|
364
|
+
return handler(event2);
|
|
365
|
+
}).catch((error) => errors.push(Object.assign(error, { event })));
|
|
366
|
+
});
|
|
367
|
+
return Promise.all(promises).then(() => {
|
|
368
|
+
if (errors.length === 0) {
|
|
369
|
+
return;
|
|
350
370
|
}
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
promise = promise.then(state.transform);
|
|
356
|
-
}
|
|
357
|
-
return promise
|
|
358
|
-
.then((event) => {
|
|
359
|
-
return handler(event);
|
|
360
|
-
})
|
|
361
|
-
.catch((error) => errors.push(Object.assign(error, { event })));
|
|
362
|
-
});
|
|
363
|
-
return Promise.all(promises).then(() => {
|
|
364
|
-
if (errors.length === 0) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const error = new AggregateError(errors);
|
|
368
|
-
Object.assign(error, {
|
|
369
|
-
event,
|
|
370
|
-
errors,
|
|
371
|
-
});
|
|
372
|
-
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error));
|
|
373
|
-
throw error;
|
|
371
|
+
const error = new AggregateError(errors);
|
|
372
|
+
Object.assign(error, {
|
|
373
|
+
event,
|
|
374
|
+
errors
|
|
374
375
|
});
|
|
376
|
+
errorHandlers.forEach((handler) => wrapErrorHandler(handler, error));
|
|
377
|
+
throw error;
|
|
378
|
+
});
|
|
375
379
|
}
|
|
376
380
|
|
|
381
|
+
// pkg/dist-src/event-handler/remove-listener.js
|
|
377
382
|
function removeListener(state, webhookNameOrNames, handler) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
383
|
+
if (Array.isArray(webhookNameOrNames)) {
|
|
384
|
+
webhookNameOrNames.forEach(
|
|
385
|
+
(webhookName) => removeListener(state, webhookName, handler)
|
|
386
|
+
);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (!state.hooks[webhookNameOrNames]) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) {
|
|
393
|
+
if (state.hooks[webhookNameOrNames][i] === handler) {
|
|
394
|
+
state.hooks[webhookNameOrNames].splice(i, 1);
|
|
395
|
+
return;
|
|
392
396
|
}
|
|
397
|
+
}
|
|
393
398
|
}
|
|
394
399
|
|
|
400
|
+
// pkg/dist-src/event-handler/index.js
|
|
395
401
|
function createEventHandler(options) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
402
|
+
const state = {
|
|
403
|
+
hooks: {},
|
|
404
|
+
log: createLogger(options && options.log)
|
|
405
|
+
};
|
|
406
|
+
if (options && options.transform) {
|
|
407
|
+
state.transform = options.transform;
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
on: receiverOn.bind(null, state),
|
|
411
|
+
onAny: receiverOnAny.bind(null, state),
|
|
412
|
+
onError: receiverOnError.bind(null, state),
|
|
413
|
+
removeListener: removeListener.bind(null, state),
|
|
414
|
+
receive: receiverHandle.bind(null, state)
|
|
415
|
+
};
|
|
410
416
|
}
|
|
411
417
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
418
|
+
// pkg/dist-src/sign.js
|
|
419
|
+
import { sign as signMethod } from "@octokit/webhooks-methods";
|
|
420
|
+
|
|
421
|
+
// pkg/dist-src/to-normalized-json-string.js
|
|
415
422
|
function toNormalizedJsonString(payload) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
const payloadString = JSON.stringify(payload);
|
|
424
|
+
return payloadString.replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
|
|
425
|
+
return s.substr(0, 3) + s.substr(3).toUpperCase();
|
|
426
|
+
});
|
|
420
427
|
}
|
|
421
428
|
|
|
429
|
+
// pkg/dist-src/sign.js
|
|
422
430
|
async function sign(secret, payload) {
|
|
423
|
-
|
|
431
|
+
return signMethod(
|
|
432
|
+
secret,
|
|
433
|
+
typeof payload === "string" ? payload : toNormalizedJsonString(payload)
|
|
434
|
+
);
|
|
424
435
|
}
|
|
425
436
|
|
|
437
|
+
// pkg/dist-src/verify.js
|
|
438
|
+
import { verify as verifyMethod } from "@octokit/webhooks-methods";
|
|
426
439
|
async function verify(secret, payload, signature) {
|
|
427
|
-
|
|
440
|
+
return verifyMethod(
|
|
441
|
+
secret,
|
|
442
|
+
typeof payload === "string" ? payload : toNormalizedJsonString(payload),
|
|
443
|
+
signature
|
|
444
|
+
);
|
|
428
445
|
}
|
|
429
446
|
|
|
447
|
+
// pkg/dist-src/verify-and-receive.js
|
|
448
|
+
import { verify as verify2 } from "@octokit/webhooks-methods";
|
|
430
449
|
async function verifyAndReceive(state, event) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
450
|
+
const matchesSignature = await verify2(
|
|
451
|
+
state.secret,
|
|
452
|
+
typeof event.payload === "object" ? toNormalizedJsonString(event.payload) : event.payload,
|
|
453
|
+
event.signature
|
|
454
|
+
);
|
|
455
|
+
if (!matchesSignature) {
|
|
456
|
+
const error = new Error(
|
|
457
|
+
"[@octokit/webhooks] signature does not match event payload and secret"
|
|
458
|
+
);
|
|
459
|
+
return state.eventHandler.receive(
|
|
460
|
+
Object.assign(error, { event, status: 400 })
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
return state.eventHandler.receive({
|
|
464
|
+
id: event.id,
|
|
465
|
+
name: event.name,
|
|
466
|
+
payload: typeof event.payload === "string" ? JSON.parse(event.payload) : event.payload
|
|
467
|
+
});
|
|
446
468
|
}
|
|
447
469
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
470
|
+
// pkg/dist-src/middleware/node/get-missing-headers.js
|
|
471
|
+
var WEBHOOK_HEADERS = [
|
|
472
|
+
"x-github-event",
|
|
473
|
+
"x-hub-signature-256",
|
|
474
|
+
"x-github-delivery"
|
|
452
475
|
];
|
|
453
|
-
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delivery-headers
|
|
454
476
|
function getMissingHeaders(request) {
|
|
455
|
-
|
|
477
|
+
return WEBHOOK_HEADERS.filter((header) => !(header in request.headers));
|
|
456
478
|
}
|
|
457
479
|
|
|
458
|
-
//
|
|
480
|
+
// pkg/dist-src/middleware/node/get-payload.js
|
|
481
|
+
import AggregateError2 from "aggregate-error";
|
|
459
482
|
function getPayload(request) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
return Promise.resolve(request.body);
|
|
483
|
+
if (request.body) {
|
|
484
|
+
if (typeof request.body !== "string") {
|
|
485
|
+
console.warn(
|
|
486
|
+
"[@octokit/webhooks] Passing the payload as a JSON object in `request.body` is deprecated and will be removed in a future release of `@octokit/webhooks`, please pass it as a a `string` instead."
|
|
487
|
+
);
|
|
467
488
|
}
|
|
468
|
-
return
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
});
|
|
489
|
+
return Promise.resolve(request.body);
|
|
490
|
+
}
|
|
491
|
+
return new Promise((resolve, reject) => {
|
|
492
|
+
let data = "";
|
|
493
|
+
request.setEncoding("utf8");
|
|
494
|
+
request.on("error", (error) => reject(new AggregateError2([error])));
|
|
495
|
+
request.on("data", (chunk) => data += chunk);
|
|
496
|
+
request.on("end", () => {
|
|
497
|
+
try {
|
|
498
|
+
JSON.parse(data);
|
|
499
|
+
resolve(data);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
error.message = "Invalid JSON";
|
|
502
|
+
error.status = 400;
|
|
503
|
+
reject(new AggregateError2([error]));
|
|
504
|
+
}
|
|
486
505
|
});
|
|
506
|
+
});
|
|
487
507
|
}
|
|
488
508
|
|
|
509
|
+
// pkg/dist-src/middleware/node/middleware.js
|
|
489
510
|
async function middleware(webhooks, options, request, response, next) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
// Check if the Content-Type header is `application/json` and allow for charset to be specified in it
|
|
514
|
-
// Otherwise, return a 415 Unsupported Media Type error
|
|
515
|
-
// See https://github.com/octokit/webhooks.js/issues/158
|
|
516
|
-
if (!request.headers["content-type"] ||
|
|
517
|
-
!request.headers["content-type"].startsWith("application/json")) {
|
|
518
|
-
response.writeHead(415, {
|
|
519
|
-
"content-type": "application/json",
|
|
520
|
-
accept: "application/json",
|
|
521
|
-
});
|
|
522
|
-
response.end(JSON.stringify({
|
|
523
|
-
error: `Unsupported "Content-Type" header value. Must be "application/json"`,
|
|
524
|
-
}));
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
const missingHeaders = getMissingHeaders(request).join(", ");
|
|
528
|
-
if (missingHeaders) {
|
|
529
|
-
response.writeHead(400, {
|
|
530
|
-
"content-type": "application/json",
|
|
531
|
-
});
|
|
532
|
-
response.end(JSON.stringify({
|
|
533
|
-
error: `Required headers missing: ${missingHeaders}`,
|
|
534
|
-
}));
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
const eventName = request.headers["x-github-event"];
|
|
538
|
-
const signatureSHA256 = request.headers["x-hub-signature-256"];
|
|
539
|
-
const id = request.headers["x-github-delivery"];
|
|
540
|
-
options.log.debug(`${eventName} event received (id: ${id})`);
|
|
541
|
-
// GitHub will abort the request if it does not receive a response within 10s
|
|
542
|
-
// See https://github.com/octokit/webhooks.js/issues/185
|
|
543
|
-
let didTimeout = false;
|
|
544
|
-
const timeout = setTimeout(() => {
|
|
545
|
-
didTimeout = true;
|
|
546
|
-
response.statusCode = 202;
|
|
547
|
-
response.end("still processing\n");
|
|
548
|
-
}, 9000).unref();
|
|
549
|
-
try {
|
|
550
|
-
const payload = await getPayload(request);
|
|
551
|
-
await webhooks.verifyAndReceive({
|
|
552
|
-
id: id,
|
|
553
|
-
name: eventName,
|
|
554
|
-
payload: payload,
|
|
555
|
-
signature: signatureSHA256,
|
|
556
|
-
});
|
|
557
|
-
clearTimeout(timeout);
|
|
558
|
-
if (didTimeout)
|
|
559
|
-
return;
|
|
560
|
-
response.end("ok\n");
|
|
561
|
-
}
|
|
562
|
-
catch (error) {
|
|
563
|
-
clearTimeout(timeout);
|
|
564
|
-
if (didTimeout)
|
|
565
|
-
return;
|
|
566
|
-
const err = Array.from(error)[0];
|
|
567
|
-
const errorMessage = err.message
|
|
568
|
-
? `${err.name}: ${err.message}`
|
|
569
|
-
: "Error: An Unspecified error occurred";
|
|
570
|
-
response.statusCode = typeof err.status !== "undefined" ? err.status : 500;
|
|
571
|
-
options.log.error(error);
|
|
572
|
-
response.end(JSON.stringify({
|
|
573
|
-
error: errorMessage,
|
|
574
|
-
}));
|
|
511
|
+
let pathname;
|
|
512
|
+
try {
|
|
513
|
+
pathname = new URL(request.url, "http://localhost").pathname;
|
|
514
|
+
} catch (error) {
|
|
515
|
+
response.writeHead(422, {
|
|
516
|
+
"content-type": "application/json"
|
|
517
|
+
});
|
|
518
|
+
response.end(
|
|
519
|
+
JSON.stringify({
|
|
520
|
+
error: `Request URL could not be parsed: ${request.url}`
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const isUnknownRoute = request.method !== "POST" || pathname !== options.path;
|
|
526
|
+
const isExpressMiddleware = typeof next === "function";
|
|
527
|
+
if (isUnknownRoute) {
|
|
528
|
+
if (isExpressMiddleware) {
|
|
529
|
+
return next();
|
|
530
|
+
} else {
|
|
531
|
+
return options.onUnhandledRequest(request, response);
|
|
575
532
|
}
|
|
533
|
+
}
|
|
534
|
+
if (!request.headers["content-type"] || !request.headers["content-type"].startsWith("application/json")) {
|
|
535
|
+
response.writeHead(415, {
|
|
536
|
+
"content-type": "application/json",
|
|
537
|
+
accept: "application/json"
|
|
538
|
+
});
|
|
539
|
+
response.end(
|
|
540
|
+
JSON.stringify({
|
|
541
|
+
error: `Unsupported "Content-Type" header value. Must be "application/json"`
|
|
542
|
+
})
|
|
543
|
+
);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const missingHeaders = getMissingHeaders(request).join(", ");
|
|
547
|
+
if (missingHeaders) {
|
|
548
|
+
response.writeHead(400, {
|
|
549
|
+
"content-type": "application/json"
|
|
550
|
+
});
|
|
551
|
+
response.end(
|
|
552
|
+
JSON.stringify({
|
|
553
|
+
error: `Required headers missing: ${missingHeaders}`
|
|
554
|
+
})
|
|
555
|
+
);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const eventName = request.headers["x-github-event"];
|
|
559
|
+
const signatureSHA256 = request.headers["x-hub-signature-256"];
|
|
560
|
+
const id = request.headers["x-github-delivery"];
|
|
561
|
+
options.log.debug(`${eventName} event received (id: ${id})`);
|
|
562
|
+
let didTimeout = false;
|
|
563
|
+
const timeout = setTimeout(() => {
|
|
564
|
+
didTimeout = true;
|
|
565
|
+
response.statusCode = 202;
|
|
566
|
+
response.end("still processing\n");
|
|
567
|
+
}, 9e3).unref();
|
|
568
|
+
try {
|
|
569
|
+
const payload = await getPayload(request);
|
|
570
|
+
await webhooks.verifyAndReceive({
|
|
571
|
+
id,
|
|
572
|
+
name: eventName,
|
|
573
|
+
payload,
|
|
574
|
+
signature: signatureSHA256
|
|
575
|
+
});
|
|
576
|
+
clearTimeout(timeout);
|
|
577
|
+
if (didTimeout)
|
|
578
|
+
return;
|
|
579
|
+
response.end("ok\n");
|
|
580
|
+
} catch (error) {
|
|
581
|
+
clearTimeout(timeout);
|
|
582
|
+
if (didTimeout)
|
|
583
|
+
return;
|
|
584
|
+
const err = Array.from(error)[0];
|
|
585
|
+
const errorMessage = err.message ? `${err.name}: ${err.message}` : "Error: An Unspecified error occurred";
|
|
586
|
+
response.statusCode = typeof err.status !== "undefined" ? err.status : 500;
|
|
587
|
+
options.log.error(error);
|
|
588
|
+
response.end(
|
|
589
|
+
JSON.stringify({
|
|
590
|
+
error: errorMessage
|
|
591
|
+
})
|
|
592
|
+
);
|
|
593
|
+
}
|
|
576
594
|
}
|
|
577
595
|
|
|
596
|
+
// pkg/dist-src/middleware/node/on-unhandled-request-default.js
|
|
578
597
|
function onUnhandledRequestDefault(request, response) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
598
|
+
response.writeHead(404, {
|
|
599
|
+
"content-type": "application/json"
|
|
600
|
+
});
|
|
601
|
+
response.end(
|
|
602
|
+
JSON.stringify({
|
|
603
|
+
error: `Unknown route: ${request.method} ${request.url}`
|
|
604
|
+
})
|
|
605
|
+
);
|
|
585
606
|
}
|
|
586
607
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
608
|
+
// pkg/dist-src/middleware/node/index.js
|
|
609
|
+
function createNodeMiddleware(webhooks, {
|
|
610
|
+
path = "/api/github/webhooks",
|
|
611
|
+
onUnhandledRequest = onUnhandledRequestDefault,
|
|
612
|
+
log = createLogger()
|
|
613
|
+
} = {}) {
|
|
614
|
+
const deprecateOnUnhandledRequest = (request, response) => {
|
|
615
|
+
console.warn(
|
|
616
|
+
"[@octokit/webhooks] `onUnhandledRequest()` is deprecated and will be removed in a future release of `@octokit/webhooks`"
|
|
617
|
+
);
|
|
618
|
+
return onUnhandledRequest(request, response);
|
|
619
|
+
};
|
|
620
|
+
return middleware.bind(null, webhooks, {
|
|
621
|
+
path,
|
|
622
|
+
onUnhandledRequest: deprecateOnUnhandledRequest,
|
|
623
|
+
log
|
|
624
|
+
});
|
|
597
625
|
}
|
|
598
626
|
|
|
599
|
-
//
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
const state = {
|
|
606
|
-
eventHandler: createEventHandler(options),
|
|
607
|
-
secret: options.secret,
|
|
608
|
-
hooks: {},
|
|
609
|
-
log: createLogger(options.log),
|
|
610
|
-
};
|
|
611
|
-
this.sign = sign.bind(null, options.secret);
|
|
612
|
-
this.verify = (eventPayload, signature) => {
|
|
613
|
-
if (typeof eventPayload === "object") {
|
|
614
|
-
console.warn("[@octokit/webhooks] Passing a JSON payload object to `verify()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`");
|
|
615
|
-
}
|
|
616
|
-
return verify(options.secret, eventPayload, signature);
|
|
617
|
-
};
|
|
618
|
-
this.on = state.eventHandler.on;
|
|
619
|
-
this.onAny = state.eventHandler.onAny;
|
|
620
|
-
this.onError = state.eventHandler.onError;
|
|
621
|
-
this.removeListener = state.eventHandler.removeListener;
|
|
622
|
-
this.receive = state.eventHandler.receive;
|
|
623
|
-
this.verifyAndReceive = (options) => {
|
|
624
|
-
if (typeof options.payload === "object") {
|
|
625
|
-
console.warn("[@octokit/webhooks] Passing a JSON payload object to `verifyAndReceive()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`");
|
|
626
|
-
}
|
|
627
|
-
return verifyAndReceive(state, options);
|
|
628
|
-
};
|
|
627
|
+
// pkg/dist-src/index.js
|
|
628
|
+
var Webhooks = class {
|
|
629
|
+
constructor(options) {
|
|
630
|
+
if (!options || !options.secret) {
|
|
631
|
+
throw new Error("[@octokit/webhooks] options.secret required");
|
|
629
632
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
633
|
+
const state = {
|
|
634
|
+
eventHandler: createEventHandler(options),
|
|
635
|
+
secret: options.secret,
|
|
636
|
+
hooks: {},
|
|
637
|
+
log: createLogger(options.log)
|
|
638
|
+
};
|
|
639
|
+
this.sign = sign.bind(null, options.secret);
|
|
640
|
+
this.verify = (eventPayload, signature) => {
|
|
641
|
+
if (typeof eventPayload === "object") {
|
|
642
|
+
console.warn(
|
|
643
|
+
"[@octokit/webhooks] Passing a JSON payload object to `verify()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`"
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
return verify(options.secret, eventPayload, signature);
|
|
647
|
+
};
|
|
648
|
+
this.on = state.eventHandler.on;
|
|
649
|
+
this.onAny = state.eventHandler.onAny;
|
|
650
|
+
this.onError = state.eventHandler.onError;
|
|
651
|
+
this.removeListener = state.eventHandler.removeListener;
|
|
652
|
+
this.receive = state.eventHandler.receive;
|
|
653
|
+
this.verifyAndReceive = (options2) => {
|
|
654
|
+
if (typeof options2.payload === "object") {
|
|
655
|
+
console.warn(
|
|
656
|
+
"[@octokit/webhooks] Passing a JSON payload object to `verifyAndReceive()` is deprecated and the functionality will be removed in a future release of `@octokit/webhooks`"
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
return verifyAndReceive(state, options2);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
export {
|
|
664
|
+
Webhooks,
|
|
665
|
+
createEventHandler,
|
|
666
|
+
createNodeMiddleware,
|
|
667
|
+
emitterEventNames
|
|
668
|
+
};
|