Authentication
import { createHmac, timingSafeEqual } from "crypto"
const expectedSignature = req.headers["x-webhook-signature"]
const algorithm = "sha256"
const signatureKey = "your_signature_key"
const message = JSON.stringify(req.body)
const computedSignature = createHmac(algorithm, signatureKey)
.update(message)
.digest("hex")
.toUpperCase()
const isValid = timingSafeEqual(
Buffer.from(expectedSignature),
Buffer.from(computedSignature)
)Last updated
Was this helpful?

