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