MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / webhookHandler

Function webhookHandler

integrations/typeform/src/index.ts:295–339  ·  view source on GitHub ↗
(event: HandlerEvent<"HTTP">, logger: Logger)

Source from the content-addressed store, hash-verified

293}
294
295async function webhookHandler(event: HandlerEvent<"HTTP">, logger: Logger) {
296 logger.debug("[inside typeform integration] Handling typeform webhook handler");
297
298 const { rawEvent: request, source } = event;
299
300 if (!request.body) {
301 logger.debug("[inside typeform integration] No body found");
302
303 return;
304 }
305
306 const rawBody = await request.text();
307
308 const signature = request.headers.get("typeform-signature");
309
310 if (!signature) {
311 logger.debug("[inside typeform integration] No signature found");
312
313 return { events: [] };
314 }
315
316 const hash = createHmac("sha256", source.secret).update(rawBody).digest("base64");
317
318 const actualSig = `sha256=${hash}`;
319
320 if (signature !== actualSig) {
321 logger.debug("[inside typeform integration] Signature does not match, ignoring");
322
323 return { events: [] };
324 }
325
326 const payload = safeParseBody(rawBody);
327
328 return {
329 events: [
330 {
331 id: payload.event_id,
332 name: payload.event_type,
333 source: SOURCE,
334 payload,
335 context: {},
336 },
337 ],
338 };
339}
340
341function isWebhookData(data: any): data is GetWebhookResponse {
342 return typeof data === "object" && data !== null && typeof data.id === "string";

Callers

nothing calls this directly

Calls 5

safeParseBodyFunction · 0.90
debugMethod · 0.65
textMethod · 0.65
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…