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

chatty-sdk

v1.2.0

Published

Chatty Chat Application SDK

Readme

chatty-sdk

Shared client SDK for the Chatty instant messaging platform. Provides REST API calls and Socket.IO real-time communication.

Installation

npm install chatty-sdk

Quick Start

The SDK supports both synchronous (browser localStorage) and asynchronous (React Native SecureStore) initialization.

Browser (sync)

import {
    ChattyClient,
    ChattyClientConfig,
    DEFAULT_CLIENT_CONFIG,
    ConstructClient,
} from 'chatty-sdk';

// 1. Prepare storage adapters
const setter = (key: string, value: string) => localStorage.setItem(key, value);
const getter = (key: string) => localStorage.getItem(key);
const remover = (key: string) => localStorage.removeItem(key);

// 2. Create config (optional, falls back to DEFAULT_CLIENT_CONFIG)
const config = new ChattyClientConfig(false, 'your-server.com');

// 3. Initialize client
const client = new ChattyClient(config ?? DEFAULT_CLIENT_CONFIG)
    .initClient(setter, getter, remover);

// 4. Build sub-APIs
const { auth, users, friends, conversations, messages, blocks, files } =
    ConstructClient(client);

React Native / Expo (async)

import * as SecureStore from 'expo-secure-store';

const setter = async (key: string, value: string) =>
    await SecureStore.setItemAsync(key, value);
const getter = async (key: string) =>
    await SecureStore.getItemAsync(key);
const remover = async (key: string) =>
    await SecureStore.deleteItemAsync(key);

const config = new ChattyClientConfig(false, 'your-server.com');
const client = await new ChattyClient(config ?? DEFAULT_CLIENT_CONFIG)
    .initClientAsync(setter, getter, remover);

const { auth, users, friends, conversations, messages, blocks, files } =
    ConstructClient(client);

Authentication

// Login
const res = await auth.login('username', 'password');
const { accessToken, refreshToken, user } = res.data.data;

// Persist tokens (sync mode)
client.setTokens(accessToken, refreshToken, setter);
// Async mode
await client.setTokensAsync(accessToken, refreshToken, setter);

// Logout
client.clearTokens(remover);
// Async mode
await client.clearTokensAsync(remover);

// Auth expired callback (e.g. password changed → forced logout)
client.setOnAuthExpired(() => {
    // Perform logout logic
});

The SDK automatically attaches the Authorization header to all requests and refreshes tokens on 401 responses via an axios interceptor.

Socket.IO

import { ChattySocket } from 'chatty-sdk';

const socket = new ChattySocket();

// Connect (after login)
socket.connect(
    { accessToken, refreshToken },
    client.config.getSocket()
);

// Events
socket.onMessage((msg) => { /* incoming message */ });
socket.onFriendRequest((req) => { /* friend request received */ });
socket.onUserOnline((userId) => { /* friend came online */ });
socket.onForceDisconnect(() => { /* password changed, forced offline */ });

// Send a message
socket.sendMessage({
    receiver_id: 2,
    type: 'text',
    content: 'Hello!',
});

// Disconnect
socket.disconnect();

API Reference

| Module | Methods | |--------|---------| | auth | login, register, refreshToken, changePassword | | users | getMyProfile, updateProfile, getMyPrivacy, updatePrivacy, searchUsers, getUserProfile | | friends | sendFriendRequest, getFriendRequests, handleFriendRequest, getFriends, deleteFriend, generateAddCode, verifyAddCode | | conversations | getConversations | | messages | getMessages | | blocks | blockUser, getBlocks, unblockUser | | files | uploadFile, getFileUrl, getAuthHeaders | | system | getHealth, getMotd |

ChattyClientConfig

new ChattyClientConfig(useHttps: boolean, endpoint: string)

// Examples
new ChattyClientConfig(false, 'localhost')       // http://localhost:5637
new ChattyClientConfig(true, 'api.example.com')   // https://api.example.com:5637

The server API runs on port 5637 by default. we are not planned to make this changeable yet...