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

cloudpostoffice

v1.2.3

Published

NodeJS SDK for communicating with cloudpostoffice.com

Readme

cloudpostoffice

Node.js SDK for CloudPostOffice — super-simple messaging for AI agents, apps, and devices.

Install

npm install cloudpostoffice

Quick start

Each app or device needs a unique postbox ID and a secret key. Create them from your dashboard. Two apps cannot connect with the same postbox ID at the same time — every participant needs its own credentials.


Direct Messages

Send a message directly from one postbox to another.

const cpo = require('cloudpostoffice');

const p1 = cpo.postbox('postbox-1', 'your-secret');
const p2 = cpo.postbox('postbox-2', 'your-secret');

// postbox-2 listens for incoming messages
await p2.listen(msg => {
  console.log(msg); // { from: 'postbox-1', msg: 'hello', ts: 1234567890 }
});

// postbox-1 sends a message to postbox-2
await p1.send({ to: 'postbox-2', msg: 'hello' });

The listen callback receives { from, msg, ts } where from is the sender's postbox ID, msg is the payload, and ts is the server timestamp.


Pub/Sub

Any postbox can publish or subscribe to any topic in the same project. No need to pre-create topics — they work on the fly.

const cpo = require('cloudpostoffice');

const p1 = cpo.postbox('postbox-1', 'your-secret');
const p2 = cpo.postbox('postbox-2', 'your-secret');

// p1 subscribes to a topic
await p1.subscribe('news', (topic, msg) => {
  console.log(topic, msg);
});

// p2 publishes to the same topic
await p2.publish('news', { msg: 'CloudPostOffice is live!' });

The subscribe callback receives (topicName, message).


API

cpo.postbox(postboxId, postboxSecret)

Creates a postbox handle. Automatically authenticates and connects to the MQTT broker on first use.

const p = cpo.postbox('my-postbox', 'my-secret');

postbox.send({ to, msg })

Sends a direct message to another postbox on the same account/project.

| Param | Type | Description | |-------|------|-------------| | to | string | Target postbox ID | | msg | any | Message payload (any JSON-serialisable value) |

await p1.send({ to: 'postbox-2', msg: 'hello' });

postbox.listen(callback)

Registers a callback for messages addressed to this postbox. Can be called multiple times to add multiple handlers.

await p.listen(({ from, msg, ts }) => {
  console.log(`Message from ${from}:`, msg);
});

postbox.publish(topicName, message)

Publishes a message to a named topic.

  • Topic names must not contain /, +, #, or --.
await p.publish('alerts', { level: 'warn', text: 'High temp' });

postbox.subscribe(topicName, callback)

Subscribes to a named topic. Callback is called whenever a message is published to that topic.

await p.subscribe('alerts', (topic, msg) => {
  console.log(topic, msg);
});

postbox.disconnect()

Gracefully closes the MQTT connection.

p.disconnect();

cpo.configure(options)

Override SDK-level options. Call before creating any postboxes.

cpo.configure({ baseUrl: 'https://cloudpostoffice.com' });

Notes

  • Authentication tokens are valid for 7 days. The SDK will automatically reconnect and refresh the token when it expires.
  • Topic names must not contain /, +, #, or --.
  • Two postboxes cannot share the same postbox ID and secret at the same time within a project.

Links

For tests

npm test