Skip to content

Commit

Permalink
Make verifyAndReceive accept a string name.
Browse files Browse the repository at this point in the history
As naturally comes from the relevant HTTP header.
  • Loading branch information
jyasskin committed Sep 20, 2024
1 parent 6531c97 commit 079e3fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/middleware/node/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// see https://github.com/octokit/octokit.js/issues/2075#issuecomment-817361886
import type { IncomingMessage, ServerResponse } from "node:http";

import type { WebhookEventName } from "../../generated/webhook-identifiers.js";

import type { Webhooks } from "../../index.js";
import type { WebhookEventHandlerError } from "../../types.js";
import type { MiddlewareOptions } from "./types.js";
Expand Down Expand Up @@ -75,7 +73,7 @@ export async function middleware(
return true;
}

const eventName = request.headers["x-github-event"] as WebhookEventName;
const eventName = request.headers["x-github-event"] as string;
const signatureSHA256 = request.headers["x-hub-signature-256"] as string;
const id = request.headers["x-github-delivery"] as string;

Expand All @@ -95,7 +93,7 @@ export async function middleware(

await webhooks.verifyAndReceive({
id: id,
name: eventName as any,
name: eventName,
payload,
signature: signatureSHA256,
});
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type EmitterWebhookEvent<

export type EmitterWebhookEventWithStringPayloadAndSignature = {
id: string;
name: WebhookEventName;
name: string;
payload: string;
signature: string;
};
Expand Down

0 comments on commit 079e3fc

Please sign in to comment.