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 🙏

© 2024 – Pkg Stats / Ryan Hefner

communityid

v2.1.0

Published

An implementation of the open Community ID flow tuple hashing standard

Downloads

12

Readme

communityid-js

This package provides a JavaScript implementation of the open Community ID flow tuple hashing standard.

It targets Node 18 and newer and has no additional dependencies.

Tests

Installation

This package is available via NPM, therefore:

$ npm install -g communityid

To install locally from a git clone, you can also use npm, e.g. by saying

$ npm install /path/to/the/clone

The package works with local or global installation. It ships with an executable to provide command-line Community ID calculation (see below), for which global installation is recommended.

Usage

The API is very simple:

const communityid = require('communityid');

console.log(communityid.calc('tcp', '127.0.0.1', '10.0.0.1', 1234, 80));

This will print "1:mgRgpIZSu0KHDp/QrtcWZpkJpMU=". For details on the arguments and their types, please see the calc function's docstring. Seeding is supported, and base64 encoding can optionally be disabled. In case of problems with the input arguments, the function returns null and reports an error message through the package's communityid.error() function, which defaults to console.error().

The package includes a sample application, community-id, which calculates the ID for given flow tuples. See its --help output for details. An example:

$ community-id tcp 10.0.0.1 10.0.0.2 10 20
1:9j2Dzwrw7T9E+IZi4b4IVT66HBI=

For troubleshooting, the communityid.calc() implementation can report the hashed data to stderr. To enable, set (or add) the communityid debug stream in your NODE_DEBUG environment variable:

$ NODE_DEBUG=communityid community-id tcp 10.0.0.1 10.0.0.2 10 20
COMMUNITYID 1182249:    seed 00:00
COMMUNITYID 1182249:   saddr 0a:00:00:01
COMMUNITYID 1182249:   daddr 0a:00:00:02
COMMUNITYID 1182249:   proto 06
COMMUNITYID 1182249: padding 00
COMMUNITYID 1182249:   sport 00:0a
COMMUNITYID 1182249:   dport 00:14
1:9j2Dzwrw7T9E+IZi4b4IVT66HBI=

Testing

The package includes a testsuite in the test folder, via Node's test runner. To execute, run the following from the toplevel or the test folder:

$ node --test
✔ icmp 1 (3.838516ms)
✔ icmp 2 (0.338138ms)
✔ icmp 3 (0.446812ms)
...

Browser support

The package currently does not support browser-side operation. Contributions very welcome!