diff --git a/README.md b/README.md index 7a8177e..f91b9b4 100644 --- a/README.md +++ b/README.md @@ -953,6 +953,10 @@ Use it to parse and validate [Seam webhook events](https://docs.seam.co/latest/d Refer to the [Svix docs on Consuming Webhooks](https://docs.svix.com/receiving/introduction) for an in-depth guide on best-practices for handling webhooks in your application. +`new SeamWebhook()` reads `SEAM_WEBHOOK_SECRET` when set. +Otherwise, pass your webhook signing secret explicitly with `new SeamWebhook(secret)`. +An explicit secret takes precedence over the environment variable. + Verification failures throw Svix's `WebhookVerificationError`, re-exported as `SeamWebhookVerificationError`. A payload that is correctly signed but unreadable throws a `SeamInvalidWebhookPayloadError`. @@ -960,6 +964,9 @@ A payload that is correctly signed but unreadable throws a `SeamInvalidWebhookPa ```js import { isSeamInvalidWebhookPayloadError, SeamWebhook } from 'seam' +const webhook = new SeamWebhook(secret) +let data + try { data = webhook.verify(req.body, req.headers) } catch (err) { @@ -976,15 +983,13 @@ try { > see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how). ```js -import { env } from 'node:process' - import { SeamWebhook } from 'seam' import express from 'express' import bodyParser from 'body-parser' const app = express() -const webhook = new SeamWebhook(env.SEAM_WEBHOOK_SECRET) +const webhook = new SeamWebhook() // Uses SEAM_WEBHOOK_SECRET. app.post( '/webhook', diff --git a/package-lock.json b/package-lock.json index 99fa5eb..e3a8f39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "license": "MIT", "dependencies": { "@seamapi/cli": "0.60.0", - "@seamapi/http": "2.52.0", - "@seamapi/webhook": "1.5.0" + "@seamapi/http": "2.53.0", + "@seamapi/webhook": "1.6.0" }, "bin": { "seam": "bin/seam.js" @@ -2474,9 +2474,9 @@ } }, "node_modules/@seamapi/http": { - "version": "2.52.0", - "resolved": "https://registry.npmjs.org/@seamapi/http/-/http-2.52.0.tgz", - "integrity": "sha512-efEdm5iHi0AM1eH3abvzav4ODZJ3ZaKKO6A4ty4dsrEbQ606hY1YWltwygJ7JMgIa4XsuV2qtvyoE1o+XcsGKA==", + "version": "2.53.0", + "resolved": "https://registry.npmjs.org/@seamapi/http/-/http-2.53.0.tgz", + "integrity": "sha512-7xLdWJwNP1gD1QBErY2LhyHdtXlyK+C2RBY/7KELPt36hWMI5fozpW5zAs1ry3lztNY+ohhnY6T+vNWjXDDJcw==", "license": "MIT", "dependencies": { "@seamapi/url-search-params-serializer": "^3.0.3", @@ -2499,9 +2499,9 @@ } }, "node_modules/@seamapi/webhook": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@seamapi/webhook/-/webhook-1.5.0.tgz", - "integrity": "sha512-Q58gxOg+Pe9cOzz5GoUKOJRo1TS5lEoIzQto7JlTl61/ztfY0nxrb428Q0lnE95djWrdfgCA7xQZQe7OZDhZ4Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@seamapi/webhook/-/webhook-1.6.0.tgz", + "integrity": "sha512-d9abACVWZMRuVxZ9q5yYqZ7q8EtEGyI/BP0J6bBtimKAIWjbSPb1rTaUDHm9i4YlTwkH6B9REEJ/VzzfjMHMbA==", "license": "MIT", "dependencies": { "svix": "^1.15.0" diff --git a/package.json b/package.json index 76da7bd..531cb0a 100644 --- a/package.json +++ b/package.json @@ -76,8 +76,8 @@ "packageManager": "npm@11.19.0", "dependencies": { "@seamapi/cli": "0.60.0", - "@seamapi/http": "2.52.0", - "@seamapi/webhook": "1.5.0" + "@seamapi/http": "2.53.0", + "@seamapi/webhook": "1.6.0" }, "devDependencies": { "@types/node": "^24.10.9",