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

@foodshare/crypto-wasm

v1.3.1

Published

Cryptographic utilities for webhook verification and HMAC - WebAssembly build

Readme

@foodshare/crypto-wasm

Cryptographic utilities for webhook verification compiled to WebAssembly from Rust.

npm version License: MIT

Features

  • HMAC-SHA256/SHA1 - Generate HMAC signatures for webhook verification
  • Constant-Time Comparison - Secure signature verification resistant to timing attacks
  • Multiple Output Formats - Hex and Base64 encoding support
  • TypeScript Support - Full type definitions included

Installation

npm install @foodshare/crypto-wasm
# or
yarn add @foodshare/crypto-wasm
# or
pnpm add @foodshare/crypto-wasm

Usage

Initialization

import init, { hmac_sha256_hex, verify_webhook_sha256 } from '@foodshare/crypto-wasm';

// Initialize WASM module (required once)
await init();

Generate HMAC Signature

import init, { hmac_sha256_hex, hmac_sha1_hex } from '@foodshare/crypto-wasm';

await init();

// HMAC-SHA256 (most providers)
const signature = hmac_sha256_hex('your-secret-key', 'payload-to-sign');

// HMAC-SHA1 (GitHub webhooks)
const sha1Sig = hmac_sha1_hex('your-secret-key', 'payload-to-sign');

Verify Webhook Signatures

import init, { verify_webhook_sha256 } from '@foodshare/crypto-wasm';

await init();

function verifyStripeWebhook(payload: string, signature: string, secret: string): boolean {
  return verify_webhook_sha256(secret, payload, signature);
}

// Example: Stripe webhook verification
const isValid = verifyStripeWebhook(
  req.body,
  req.headers['stripe-signature'],
  process.env.STRIPE_WEBHOOK_SECRET
);

Base64 Output

import init, { hmac_sha256_base64 } from '@foodshare/crypto-wasm';

await init();

// Some providers expect Base64 signatures
const signature = hmac_sha256_base64('secret', 'message');

Constant-Time Comparison

import init, { constant_time_eq } from '@foodshare/crypto-wasm';

await init();

// Safe comparison resistant to timing attacks
const isEqual = constant_time_eq('signature1', 'signature2');

API Reference

hmac_sha256_hex(key, message): string

Generate HMAC-SHA256 signature as hex string.

hmac_sha256_base64(key, message): string

Generate HMAC-SHA256 signature as base64 string.

hmac_sha1_hex(key, message): string

Generate HMAC-SHA1 signature as hex string (for legacy providers).

verify_webhook_sha256(key, message, signature_hex): boolean

Verify a webhook signature using constant-time comparison.

verify_webhook_sha1(key, message, signature_hex): boolean

Verify SHA1 webhook signature (GitHub).

constant_time_eq(a, b): boolean

Constant-time string comparison.

Provider Examples

Stripe

const isValid = verify_webhook_sha256(
  process.env.STRIPE_SECRET,
  payload,
  signatureHeader
);

GitHub

// GitHub uses SHA1 with 'sha1=' prefix
const signature = req.headers['x-hub-signature'].replace('sha1=', '');
const isValid = verify_webhook_sha1(
  process.env.GITHUB_SECRET,
  payload,
  signature
);

Meta/Facebook

const signature = req.headers['x-hub-signature-256'].replace('sha256=', '');
const isValid = verify_webhook_sha256(
  process.env.META_SECRET,
  payload,
  signature
);

Security

  • All signature verification uses constant-time comparison to prevent timing attacks
  • Built with Rust's subtle crate for cryptographic operations
  • No external runtime dependencies in the WASM binary

Browser Support

Works in all modern browsers with WebAssembly support:

  • Chrome 57+
  • Firefox 52+
  • Safari 11+
  • Edge 16+

License

MIT License - see LICENSE for details.

Related