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

@spacetimedb/crypto

v0.1.0

Published

Deterministic hashing, encoding, and webhook-signature helpers for SpacetimeDB TypeScript modules.

Readme

@spacetimedb/crypto

Hash data, create HMAC signatures, and verify webhook signatures in SpacetimeDB. The package also includes byte comparison and hex and base64 conversion helpers.

Install

npm install @spacetimedb/crypto

Verify a webhook

In your HTTP handler, verify a Stripe webhook with the raw request body and the module's timestamp:

import { SyncResponse } from 'spacetimedb/server';
import { verifyStripeSignature } from '@spacetimedb/crypto';

const result = verifyStripeSignature({
  rawBody,
  signatureHeader: request.headers.get('stripe-signature') ?? '',
  secret: webhookSecret,
  nowSeconds: Number(ctx.timestamp.microsSinceUnixEpoch / 1_000_000n),
});
if (!result.ok) {
  return new SyncResponse(result.reason, { status: 400 });
}

Verify the raw webhook body before parsing it. Store webhook secrets in private tables and keep them out of public rows and procedure results.

API

  • sha256(data) and hmacSha256(key, message) return Uint8Array digests.
  • timingSafeEqual(a, b) compares every byte in equal-length arrays.
  • hexToBytes, bytesToHex, and base64ToBytes convert common encodings. Base64 accepts canonical padded or unpadded standard encoding and rejects whitespace, misplaced padding, invalid lengths, and non-canonical pad bits.
  • verifyStripeSignature(options) verifies Stripe's v1 signature format.
  • verifySvixSignature(options) verifies Svix-compatible signatures, including Resend webhooks.
  • verifyGithubSignature(options) verifies GitHub's SHA-256 webhook signature.

The verifiers return { ok: true } or { ok: false, reason }, with these errors codes:

| Code | Meaning | | ------------------------------------ | ------------------------------------------------------ | | crypto.missing_signature | The header has no timestamp or no supported signature. | | crypto.invalid_timestamp | The signed timestamp is not an integer. | | crypto.timestamp_outside_tolerance | The timestamp is outside toleranceSeconds. | | crypto.invalid_secret | The Svix secret is not valid base64. | | crypto.signature_mismatch | No signature matches the body and secret. |

Package entrypoints:

  • @spacetimedb/crypto exports hashing, encoding, comparison, and vendor verification helpers.
  • @spacetimedb/crypto/vendors is the focused webhook-verification entrypoint.

Testing

pnpm test
pnpm run lint

Tests use published vendor vectors and local fixtures; no network is required.

License

Apache-2.0. See the license.