npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cm-email-gateway/email-webhook-verification

v1.0.1

Published

SDK for verifying CM Email webhook signatures

Readme

@cm-email-gateway/email-webhook-verification

Node.js/TypeScript SDK for verifying CM Email webhook signatures.

Installation

npm install @cm-email-gateway/email-webhook-verification

Or with yarn:

yarn add @cm-email-gateway/email-webhook-verification

Requirements

  • Node.js 16.0.0 or later

Usage

import { WebhookValidator } from '@cm-email-gateway/email-webhook-verification';

// Initialize the validator with your secret key
const validator = new WebhookValidator({
  secretKey: 'your-secret-key',
});

// Or with custom tolerance (default is 300 seconds)
const validator = new WebhookValidator({
  secretKey: 'your-secret-key',
  toleranceInSeconds: 600,
});

// Extract headers from the incoming webhook request
const headers = {
  'svix-id': req.headers['svix-id'],
  'svix-timestamp': req.headers['svix-timestamp'],
  'svix-signature': req.headers['svix-signature'],
};

// Get the raw request body
const payload = req.body; // raw string body

// Verify and parse the webhook payload
try {
  const data = validator.verify<YourWebhookType>(payload, headers);
  // Process the verified webhook data
} catch (error) {
  if (error instanceof MissingHeadersError) {
    // Required headers are missing
  } else if (error instanceof InvalidTimestampError) {
    // Timestamp format is invalid
  } else if (error instanceof TimestampExpiredError) {
    // Webhook timestamp is outside the allowed tolerance window
  } else if (error instanceof InvalidSignatureError) {
    // Signature verification failed
  }
}

Express.js Example

import express from 'express';
import { WebhookValidator, WebhookVerificationError } from '@cm-email-gateway/email-webhook-verification';

const app = express();
app.use(express.raw({ type: 'application/json' }));

const validator = new WebhookValidator({
  secretKey: process.env.WEBHOOK_SECRET_KEY!,
});

app.post('/webhook', (req, res) => {
  try {
    const data = validator.verify(req.body.toString(), req.headers);
    // Process webhook
    res.status(200).send('OK');
  } catch (error) {
    if (error instanceof WebhookVerificationError) {
      res.status(401).send('Unauthorized');
    } else {
      res.status(500).send('Internal Server Error');
    }
  }
});

API

WebhookValidator

Constructor Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | secretKey | string | required | Your webhook secret key | | toleranceInSeconds | number | 300 | Maximum age of webhook in seconds |

Methods

  • verify<T>(payload: string, headers: WebhookHeaders): T - Verifies the webhook signature and returns the parsed payload

Errors

| Error | Description | |-------|-------------| | MissingHeadersError | One or more required headers (svix-id, svix-timestamp, svix-signature) are missing | | InvalidTimestampError | The timestamp header is not a valid format | | TimestampExpiredError | The webhook timestamp is outside the allowed tolerance window | | InvalidSignatureError | The signature does not match the expected value |

All errors extend WebhookVerificationError.

License

MIT License - see LICENSE for details.