Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mattgd
Copy link
Contributor

@mattgd mattgd commented Jul 11, 2025

Description

Type constructEvent payload parameter as Record<string, unknown>.

Example usage:

app.post("/webhooks", async (request, response) => {
  const payload = request.body;
  const sigHeader = request.headers["workos-signature"] as string;

  const webhook = await workosClient.webhooks.constructEvent({
    payload,
    sigHeader,
    secret: WEBHOOK_SECRET,
  });

  const data = webhook.data;

  // Verify the signature and process the event
  response.status(200).end();
});

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@mattgd mattgd requested a review from nicknisi July 11, 2025 13:39
@mattgd mattgd self-assigned this Jul 11, 2025
@mattgd mattgd requested a review from a team as a code owner July 11, 2025 13:39
@linear
Copy link

linear bot commented Jul 11, 2025

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Modified the type signature of the constructEvent method's payload parameter in src/webhooks/webhooks.ts to improve type safety for webhook handling.

  • Changed payload type from unknown to Record<string, unknown> for better type safety and autocomplete support
  • Caution: Implementation uses unsafe type assertion (unknown as EventResponse) which could lead to runtime errors if payload structure doesn't match
  • Consider implementing runtime validation to ensure payload matches EventResponse type before assertion

1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Comment on lines 69 to 72
constructor(
readonly key?: string,
readonly options: WorkOSOptions = {},
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why CI was giving me a formatter error for this.

@mattgd mattgd merged commit 39ab2f2 into version-8 Jul 11, 2025
7 checks passed
@mattgd mattgd deleted the feature/ent-3465-node-sdk-workoswebhooksconstructevent-type-should-only branch July 11, 2025 13:56
@stacurry stacurry mentioned this pull request Jul 16, 2025
stacurry added a commit that referenced this pull request Jul 16, 2025
## Description
version bump that includes:
- #1307
- #1308

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
nicknisi pushed a commit that referenced this pull request Jul 17, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Aug 5, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Aug 7, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Aug 19, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Aug 25, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Aug 28, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Sep 23, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Oct 2, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Oct 13, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Oct 28, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Nov 6, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Nov 24, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Dec 2, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Dec 4, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Dec 4, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Dec 16, 2025
Type constructEvent payload parameter as Record<string, unknown>.
nicknisi pushed a commit that referenced this pull request Dec 22, 2025
Type constructEvent payload parameter as Record<string, unknown>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants