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

webchat-client-sdk

v0.0.6

Published

Client sdk to help integration with WebChat tool

Readme

Web Chat Client SDK

A small client SDK to connect frontend applications to the Web Chat WebSocket server (v3 protocol). Your app is responsible for issuing the JWT token (using the same secret as the server); the SDK connects with that token and exposes events and sendMessage.

Install

npm install webchat-client-sdk

Usage

Obtain a JWT from your backend (signed with the same WEBCHAT_JWT_SECRET as the Web Chat server), then connect and subscribe to events:

import { connectWebChat } from "webchat-client-sdk";

const wc = await connectWebChat({
  url: "wss://your-host/chat/ws",
  token: "eyJhbGc...", // JWT from your backend
});

wc.on("aicw-start-typing", () => {
  console.log("AICW is typing…");
});
wc.on("aicw-end-typing", () => {
  console.log("AICW stopped typing.");
});
wc.on("aicw-message", (msg: string) => {
  console.log(`AICW: ${msg}`);
});
wc.on("user-message", (msg: string) => {
  console.log(`USER: ${msg}`);
});

await wc.sendMessage("Hi there");
// … later
wc.disconnect();

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | url | string | required | Full WebSocket URL (e.g. wss://host/chat/ws). | | token | string | required | JWT token. Your backend must sign it with the same secret as the server. | | timezone | string | "UTC" | IANA timezone (e.g. America/New_York). | | keepaliveIntervalMs | number | 45000 | Send ping every N ms. Set to 0 to disable. |

Events

  • aicw-start-typing — Server started composing a response.
  • aicw-end-typing — Server finished composing.
  • aicw-message — AI message text (handler receives string).
  • user-message — User message (e.g. echo/broadcast; handler receives string).

Methods

  • sendMessage(content: string) — Send a user message to the server.
  • disconnect() — Close the WebSocket.

Token

The SDK does not sign or verify JWTs. Your backend (or token endpoint) must:

  1. Use the same secret as the Web Chat server (WEBCHAT_JWT_SECRET).
  2. Issue a JWT with at least sid (session id), exp, and iat).

The frontend gets the token (e.g. from POST /chat/token with email, or from a login redirect with ?token=...) and passes it to connectWebChat({ url, token }).

Protocol

This SDK implements the v3 WebSocket protocol: subprotocols atlas-web-chat.v3 and jwt.<token>, and the event set user-message, aicw-message, aicw-start-typing, aicw-end-typing, plus optional ping/pong keepalive.

Requirements

  • Environment with WebSocket (browser or Node 18+).
  • JWT token issued by your backend with the same secret as the server.

platform-jumaross-webchat-sdk