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

socketxp-ws-client

v0.0.2

Published

SocketXP websocket client library for subscribing and receiving webhook notifications from online applications.

Readme

Problem

Rest APIs leveraging HTTP protocol is the modern way of communicating between applications over the internet. Applications can communicate using a pull method or a push method. The pull method is inefficient in that, the receiver application needs to continuously poll the sender application for any updates or notifications that awaits to be communicated. The push method is efficient in that the receiver application registers a REST API with the sender application. Whenever there is an update or notification that needs to be sent to the receiver application, the sender invokes the registered REST API with appropriate data. This push method of REST API communication between applications is also called as webhooks.

The problem with communicating using webhook push notifications is that some applications are online with public IP, while some are behind firewalls and NAT without any public IP. Sometimes the application doesn't have an HTTP server implementation at all to handle the REST API.

Solution

SocketXP WebSocket Client allows applications to receive webhooks without public IP, re-configuring NAT/firewall or even having a web server in the first place. It does this by creating a sercure WebSocket tunnel (SSL/TLS connection) to the SocketXP Cloud Gateway( an online reverse proxy tunneling gateway run as a freemium SaaS service). SocketXP Cloud Gateway creates an unique public HTTP endpoint (URL) for each user. The user can use this public HTTP endpoint (URL) to register with any online webhook sender applications. The user application(webhook receiver), running in the local network behind firewall and NAT, could integrate with the SocketXP WebSocket Client library to receive the webhook notifications. The user application need not implement any HTTP server to receive the webhook notifications.

Installation

npm i socketxp-ws-client

Usage

To start using this library:

  1. Retrieve your auth token from SocketXP portal. You will need to supply them to the library.
  2. Create a SocketXP webhook relay tunnel named 'nodered' and check what input URL did you get (should be something like: https://webhooks.socketxp.com/...). Input URL will be your own webhook inbox that you can supply to any sender application to send webhooks or any HTTP requests to.
  3. Import the library into your application:
var ws = require(`socketxp-ws-client`);

// handler function has to accept a JSON string and parse on its own
var handler = function (data) {
    console.log(data)
}

// create a client with specified authtoken from https://portal.socketxp.com/#/authtokens and any webhook tunnels that
// can be created here https://portal.socketxp.com/#/tunnels. Handler function is called whenever there's a new message
var client = new ws.SocketXPClient('your-auth-token', ['tunnel-1', 'tunnel-2'], handler)

// connect starts a websocket connection to SocketXP Cloud Gateway 
client.connect();

Example application

Set token as an environment variable:

export SOCKETXP_TOKEN=[YOUR AUTH TOKEN]
// app.js
var ws = require(`socketxp-ws-client`);

var authtoken = process.env.SOCKETXP_TOKEN;

var handler = function (data) {
    console.log(data)
}

var socketxp = function () {    
    var client = new ws.SocketXPClient(authtoken, ['nodered'], handler)
    client.connect();

    // do some work

    // disconnect whenever connection is no longer needed
   client.disconnect();
}

socketxp();

To run it:

node app.js

Now, whenever webhooks are sent to your public endpoint https://webhooks.socketxp.com/<webhook-tunnel-name>, they will be received inside your application. You can subscribe to multiple webhook tunnels. Each message will have a JSON string in the following format that you can parse:

{
  "type": "webhook",             // event type
  "meta": {                      // webhook tunnels, input and output information 
    "webhook_tunnel_name": "my-webhook-tunnel-name",                                
    "input_name": "https://webhook.socketxp.com/my-webhook-tunnel-name",
    "output_destination": "http://localhost:8080"
  },
  "headers": {                   // request headers
    "Content-Type": [
      "application/json"
    ]
  },
  "query": "foo=bar",            // query (ie: /some-path?foo=bar)
  "body": "{\"hello\": \"world\"}", // request body
  "method": "POST"                // request method
}