Skip to content

Add webhook verification functionality for secure payload validation #7103

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

Merged
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
22 changes: 22 additions & 0 deletions .changeset/webhook-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"thirdweb": minor
---

Added webhook verification functionality to securely verify incoming webhooks from thirdweb. This includes:

- New `Webhook.parse` function to verify webhook signatures and timestamps
- Support for both `x-payload-signature` and `x-pay-signature` header formats
- Timestamp verification with configurable tolerance
- Version 2 webhook payload type support

Example usage:
```typescript
import { Webhook } from "thirdweb/bridge";

const webhook = await Webhook.parse(
payload,
headers,
secret,
300 // optional tolerance in seconds
);
```
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"thirdweb": "workspace:*",
"tiny-invariant": "^1.3.3",
"use-debounce": "^10.0.4",
"zod": "3.24.3"
"zod": "3.25.24"
},
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/playground-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"tailwind-merge": "^2.6.0",
"thirdweb": "workspace:*",
"use-debounce": "^10.0.4",
"zod": "3.24.3"
"zod": "3.25.24"
},
"devDependencies": {
"@types/node": "22.14.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"tailwindcss-animate": "^1.0.7",
"thirdweb": "workspace:*",
"tiny-invariant": "^1.3.3",
"zod": "3.24.3"
"zod": "3.25.24"
},
"devDependencies": {
"@next/eslint-plugin-next": "15.3.2",
Expand Down
14 changes: 4 additions & 10 deletions packages/service-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
},
"typesVersions": {
"*": {
"node": [
"./dist/types/node/index.d.ts"
],
"cf-worker": [
"./dist/types/cf-worker/index.d.ts"
]
"node": ["./dist/types/node/index.d.ts"],
"cf-worker": ["./dist/types/cf-worker/index.d.ts"]
}
},
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/pay",
Expand All @@ -40,14 +36,12 @@
"url": "https://github.com/thirdweb-dev/js/issues"
},
"author": "thirdweb eng <[email protected]>",
"files": [
"dist/"
],
"files": ["dist/"],
"sideEffects": false,
"dependencies": {
"@confluentinc/kafka-javascript": "1.3.0",
"aws4fetch": "1.0.20",
"zod": "3.24.3"
"zod": "3.25.24"
},
"devDependencies": {
"@cloudflare/workers-types": "4.20250520.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/thirdweb/.size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
"name": "thirdweb (esm)",
"path": "./dist/esm/exports/thirdweb.js",
"limit": "60 kB",
"limit": "65 kB",
"import": "*"
},
{
"name": "thirdweb (cjs)",
"path": "./dist/cjs/exports/thirdweb.js",
"limit": "350 kB"
"limit": "375 kB"
},
{
"name": "thirdweb (minimal + tree-shaking)",
Expand Down
87 changes: 24 additions & 63 deletions packages/thirdweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,66 +147,26 @@
},
"typesVersions": {
"*": {
"adapters/*": [
"./dist/types/exports/adapters/*.d.ts"
],
"auth": [
"./dist/types/exports/auth.d.ts"
],
"chains": [
"./dist/types/exports/chains.d.ts"
],
"contract": [
"./dist/types/exports/contract.d.ts"
],
"deploys": [
"./dist/types/exports/deploys.d.ts"
],
"event": [
"./dist/types/exports/event.d.ts"
],
"extensions/*": [
"./dist/types/exports/extensions/*.d.ts"
],
"pay": [
"./dist/types/exports/pay.d.ts"
],
"react": [
"./dist/types/exports/react.d.ts"
],
"react-native": [
"./dist/types/exports/react.native.d.ts"
],
"rpc": [
"./dist/types/exports/rpc.d.ts"
],
"storage": [
"./dist/types/exports/storage.d.ts"
],
"transaction": [
"./dist/types/exports/transaction.d.ts"
],
"utils": [
"./dist/types/exports/utils.d.ts"
],
"wallets": [
"./dist/types/exports/wallets.d.ts"
],
"wallets/*": [
"./dist/types/exports/wallets/*.d.ts"
],
"modules": [
"./dist/types/exports/modules.d.ts"
],
"social": [
"./dist/types/exports/social.d.ts"
],
"ai": [
"./dist/types/exports/ai.d.ts"
],
"bridge": [
"./dist/types/exports/bridge.d.ts"
]
"adapters/*": ["./dist/types/exports/adapters/*.d.ts"],
"auth": ["./dist/types/exports/auth.d.ts"],
"chains": ["./dist/types/exports/chains.d.ts"],
"contract": ["./dist/types/exports/contract.d.ts"],
"deploys": ["./dist/types/exports/deploys.d.ts"],
"event": ["./dist/types/exports/event.d.ts"],
"extensions/*": ["./dist/types/exports/extensions/*.d.ts"],
"pay": ["./dist/types/exports/pay.d.ts"],
"react": ["./dist/types/exports/react.d.ts"],
"react-native": ["./dist/types/exports/react.native.d.ts"],
"rpc": ["./dist/types/exports/rpc.d.ts"],
"storage": ["./dist/types/exports/storage.d.ts"],
"transaction": ["./dist/types/exports/transaction.d.ts"],
"utils": ["./dist/types/exports/utils.d.ts"],
"wallets": ["./dist/types/exports/wallets.d.ts"],
"wallets/*": ["./dist/types/exports/wallets/*.d.ts"],
"modules": ["./dist/types/exports/modules.d.ts"],
"social": ["./dist/types/exports/social.d.ts"],
"ai": ["./dist/types/exports/ai.d.ts"],
"bridge": ["./dist/types/exports/bridge.d.ts"]
}
},
"browser": {
Expand Down Expand Up @@ -251,7 +211,8 @@
"prompts": "2.4.2",
"toml": "3.0.0",
"uqr": "0.1.2",
"viem": "2.28.1"
"viem": "2.28.1",
"zod": "3.25.24"
},
"peerDependencies": {
"@aws-sdk/client-lambda": "^3",
Expand Down Expand Up @@ -324,7 +285,7 @@
"bench:compare": "bun run ./benchmarks/run.ts",
"bench": "vitest -c ./test/vitest.config.ts bench",
"format": "biome format ./src --write",
"lint": "knip && biome check ./src && tsc --project ./tsconfig.build.json --module esnext --noEmit",
"lint": "knip && biome check ./src && tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit",
"fix": "biome check ./src --fix",
"knip": "knip",
"build:generate": "bun scripts/generate/generate.ts",
Expand All @@ -335,7 +296,7 @@
"build": "pnpm clean && pnpm build:types && pnpm build:cjs && pnpm build:esm",
"build:cjs": "tsc --noCheck --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
"build:esm": "tsc --noCheck --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json",
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"build:types": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rimraf dist",
"size": "size-limit",
"test:watch": "vitest -c ./test/vitest.config.ts dev",
Expand Down
Loading
Loading