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

rapt-cipher

v0.1.1

Published

Redis-based message-passing framework for node.js.

Downloads

6

Readme

Cipher

A redis-based message-passing framework for node.js.

Status

Cipher is actively under development. As this is early-release software, it should only be used with caution in production environments.

Contributors

Originally created by Max Seiden.

Currently maintained by Jamie Pitts.

Requirements

Cipher requires redis 2.x and node.js.

Installation

npm install rapt-cipher

Overview

Cipher allows a realtime communications system to be created among a group of node servers. For example, web servers and websocket servers can send messsages to a group of data processing nodes, and vice-versa.

Each message is addressed with a namespace, node id, and optional tenent id enabling cipher to route it to the appropriate instance.

In each server, a message handler is defined for a particular route. This allows many different kinds of messages to be transmitted and handled.

Initializing Cipher

Each initialized cipher (a cipherer) represents an individual service that is reachable by the cipher network. In this example, a cipher is configured for a websocket service:

var Cipher = require('cipher'),
    Winston = require('winston');

var logger = new (Winston.Logger) ({ });
logger.add(Winston.transports.Console); 

var cipherer = Cipher.init({
  namespace: 'ws',
  nid: 0,
  logger: logger,
  log: function (message, attr) {
    logger.log(attr.level, message, attr);
  },
  redis: {
    host: '127.0.0.1', port: 6379, options: {}
  }
});

cipherer.tenentHandler = function tenentHandler(recipient, cb) {
  get_recipient_from_db(recipient.tid, function (recipient_obj) {
    cb(null, recipient_obj);
  });
  // cb(); // if there is to be no lookup
}

Required components of a cipher initialization:

The namespace and node id for that service.

A redis config so that the cipherer may use redis to listen for, transmit, or broadcast messages.

A Winston logger, as well as a custom log function (both optional).

Lastly, a tenentHandler function must also be defined when initializing cipher. This is a convenience function to enable your application to perform lookups relating to the message recipient. If you have no lookup to perform, just call the callback with no parameters.

Creating A Message Handler

All messages coming in to a cipherer will be routed to the appropriate handler function. The following example might be defined in the websocket service (having namespace=ws and nid=0) after initializing cipher:

cipherer.onTransmit("world.hello", function (origin, tenent, payload) {
  console.log('world.hello called from ', origin);
  console.log('world.hello sent to ', tenent.id);
  console.log('payload: ', payload);

  // ... code to emit the message to the appropriate ws client ... //

});

Sending A Message

In another service having its own initialized cipherer (perhaps a game worker), the following might be used to send a message to the websocket service (having namespace=ws and nid=0):

cipherer.transmit("world.hello",
  {chat: 'Hello!'},
  {namespace: 'ws', nid: 0, tid: 1234567890}, // send this to the ws node having nid=0
)

Cipher Message Format

A cipher message contains a payload and a recipient:

var msg = {
    payload: {
        "chat":"Hello, World!"
    },
    recipient: {
        "ns":"ws", 
        "nid":0, 
        "tid":"1234567890"
    }
};

The payload is for use in your application and will not be processed or acted upon by cipher.

The recipient enables the message to reach an individual running service with the additional ability to target a particular user or object. Services of a certain type are identified by a namespace, for example: web, ws, or worker. An integer is used for the node id, representing each running instance of a service type.

For example, cipher messages to two different websocket services might be addressed with: {"ns":"ws","nid":0} and {"ns":"ws","nid":1}. Additionally, the tenent id can be used to address a particular user or object with: {"ns":"ws", "nid":0, "tid":"1234567890"}.

A Conceptual Use Case

The current maintainer created a helpful use case document illustrating how cipher can be used to develop and deploy a multiplayer game: docs/USE_CASE.md

Developer Notes

The current maintainer created some notes while preparing rapt-cipher for release: docs/NOTES.md

Example Apps

See the chit-chat example web application (located in the examples directory), as well as the README. This basic examples demonstrates a simple cipher network featuring two web servers.