Skip to content

Conversation

@wolfy1339
Copy link
Member

This method is almost identical to verifyAndReceive(), the difference being that this function won't trigger the event handler, so it can be executed at a later time.

Fixes #379

Resolves #ISSUE_NUMBER


Before the change?

  • Users could not simply get an EmitterWebhookEvent object, the included functions would fire the event handler for webhook events

After the change?

  • Users can now get an EmitterWebhookEvent object without the event handler being utilised. This is especially useful for serverless platforms

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

This method is almost identical to `verifyAndReceive()`, the difference being that this function won't trigger the event handler, so it can be executed at a later time.

Fixes #379
@wolfy1339 wolfy1339 added the Type: Feature New feature or request label Jun 4, 2025
@wolfy1339 wolfy1339 requested a review from G-Rath June 4, 2025 20:34
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339 wolfy1339 requested a review from gr2m June 4, 2025 20:34
@github-project-automation github-project-automation bot moved this to 🆕 Triage in 🧰 Octokit Active Jun 4, 2025
@G-Rath
Copy link
Member

G-Rath commented Jun 4, 2025

wow blast from the past! I'd forgotten about this, which hopefully shows we've all done good work in our code since I do still have lambdas consuming GH events that I've obviously not had to think about in 5 years 😄

I'm not sure though how useful this actually is especially as it doesn't seem like there's been a lot of request for it (but I could easily be wrong there) - looking at my code, I think this would be replacing this custom function:

export const getEvent = async (event: ApiEvent): Promise<GithubEvent> => {
  const rawBody = event.body ?? '{}';
  const signature = event.headers['X-Hub-Signature-256'] ?? '';
  const name = event.headers['X-GitHub-Event'];
  const { GH_WEBHOOK_SECRET } = process.env;

  if ((await verify(GH_WEBHOOK_SECRET, rawBody, signature)) && name) {
    const payload = JSON.parse(rawBody) as GithubEvent['payload'];

    return { name, payload } as GithubEvent;
  }

  throw new Error('event did not come from github');
};

which is pretty small and contained whereas this addition is twice the size - having said that, I'm pretty sure we could easily have verifyAndReceive use this function too which would cut most of the additional size to the package and make it a lot easier to justify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New feature or request

Projects

Status: 🆕 Triage

Development

Successfully merging this pull request may close these issues.

webhooks.verifyAndParse and standalone verifyAndParse method

2 participants