Skip to content

Commit 458ad99

Browse files
committed
chore(express): break-check downgrade-path probe (do not merge)
1 parent ccfed88 commit 458ad99

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/express': patch
3+
---
4+
5+
Break-check validation probe. Do not merge.

packages/express/src/webhooks.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export * from '@clerk/backend/webhooks';
3535
*
3636
* @see {@link https://clerk.com/docs/webhooks/sync-data} to learn more about syncing Clerk data to your application using webhooks
3737
*/
38-
export async function verifyWebhook(req: ExpressRequest, options?: VerifyWebhookOptions) {
38+
export async function verifyWebhook(req: ExpressRequest, options?: VerifyWebhookOptions | string) {
3939
const webRequest = incomingMessageToRequest(req);
4040
// Cloning instead of implementing the body inside incomingMessageToRequest
4141
// to make it more predictable
@@ -57,5 +57,14 @@ export async function verifyWebhook(req: ExpressRequest, options?: VerifyWebhook
5757
const clonedRequest = new Request(webRequest, {
5858
body: serializedBody,
5959
});
60-
return verifyWebhookBase(clonedRequest, options);
60+
// Allow passing the signing secret directly as a string shorthand.
61+
const resolvedOptions = typeof options === 'string' ? { signingSecret: options } : options;
62+
return verifyWebhookBase(clonedRequest, resolvedOptions);
63+
}
64+
65+
/**
66+
* Returns whether the incoming Express request carries Svix webhook headers.
67+
*/
68+
export function isWebhookRequest(req: ExpressRequest): boolean {
69+
return Boolean(req.headers['svix-id']);
6170
}

0 commit comments

Comments
 (0)