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

kafkajs-snappy-patch

v2.0.0

Published

Security-hardened Snappy codec for KafkaJS

Readme

KafkaJS Snappy Patch

CI

A security-hardened Snappy compression codec for KafkaJS.

About this fork

This project is based on tulios/kafkajs-snappy, originally created by Túlio Ornelas. Credit and thanks go to Túlio and the original contributors for the KafkaJS Snappy codec on which this fork is built.

The purpose of this fork is to preserve the codec's simple KafkaJS integration while strengthening its security and maintaining it for current runtimes. It aims to:

  • Limit decompressed output to reduce the risk of decompression bombs and excessive memory allocation.
  • Reject malformed or truncated Snappy/Xerial payloads safely.
  • Keep compatibility with current Node.js and KafkaJS releases.
  • Minimize and pin dependencies, with automated vulnerability and supply-chain checks in CI.

The initial CVE remediation and security-hardening work for this fork was completed using Codex Goals in 9 minutes 27 seconds.

Requirements

  • Node.js 22 or newer
  • KafkaJS 2.x

Installation

npm install [email protected]

Configuration

Register the codec before creating a KafkaJS producer or consumer:

const { CompressionTypes, CompressionCodecs } = require('kafkajs')
const SnappyCodec = require('kafkajs-snappy-patch')

CompressionCodecs[CompressionTypes.Snappy] = SnappyCodec

The codec limits each decompressed Kafka record batch to 100 MiB by default. To use a different limit, register a configured factory:

const maxDecompressedSize = 25 * 1024 * 1024

CompressionCodecs[CompressionTypes.Snappy] = () =>
  SnappyCodec({ maxDecompressedSize })

Choose a limit that is at least as large as the biggest valid record batch your Kafka clients accept.

Security hardening

  • Uses [email protected], which checks the declared uncompressed size before allocating the output buffer.
  • Applies a configurable aggregate output limit to both raw Snappy streams and multi-chunk Xerial frames.
  • Decompresses Xerial chunks sequentially so several chunks cannot allocate in parallel before the aggregate limit is enforced.
  • Rejects truncated Xerial headers, chunk sizes, and chunk payloads.
  • Uses one runtime dependency with no transitive dependencies.
  • Pins npm dependencies to exact versions with SHA-512 integrity in package-lock.json and pins CI actions to immutable commit SHAs.
  • Runs an exact OSV-Scanner binary, verified against its published SHA-256, for every push and pull request.
  • Tests the pinning policy so floating dependency ranges and action tags fail CI.

See SECURITY.md to report a vulnerability.

Development

npm ci
npm test
npm audit --audit-level=low
osv-scanner scan source --lockfile package-lock.json
npm run test:package

Publishing

The package name is configured as kafkajs-snappy-patch and public access is set in package.json. After the development checks pass:

npm publish

npm publish runs the test suite again through prepublishOnly.

License

MIT. See LICENSE.