Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make verifyAndReceive accept a string name. #1056

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading