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

insite-client

v2.4.0

Published

Client-side inSite SDK — WebSocket, auth, subscriptions, file transfers

Downloads

268

Readme

insite-client

Client-side inSite SDK — WebSocket, auth, subscriptions, file transfers. Single entry point for connecting to an inSite server.

Part of inSite — built on insite-ws, insite-cookie, insite-users-client, insite-subscriptions-client, insite-ws-transfers.

Installation

npm install insite-client

Or:

bun add insite-client

Quick Start

import { InSite } from "insite-client";

// Sync — returns InSite immediately, init runs in background
const inSite = InSite.init({
	ws: { url: "wss://your-server.example.com" }
});

inSite.on("ready", () => {
	console.log("Connected");
});

// Async — returns Promise that resolves when ready
const inSite = await InSite.init(
	{ ws: { url: "wss://your-server.example.com" } },
	true
);

API Reference

Exports

| Export | Type | Description | |--------|------|-------------| | InSite | class | Main facade class | | Options<AS> | type | Client options | | AbilitiesSchema, AbilitySchema, AbilityParamSchema, Abilities, ScanAbilitySchemas | type | From insite-common | | CookieSetter, CookieOptions | class/type | From insite-cookie | | Subscription, SubscriptionGroup, SubscriptionGroupItem, SubscriptionArray, SubscriptionMap, SubscriptionObject, SubscriptionMapWithSubscription, SubscriptionObjectWithSubscription | class | From insite-subscriptions-client | | Updated, Definition, SubscriptionType, SubscriptionGroupOptions, SubscriptionGroupTarget | type | From insite-subscriptions-client | | UsersSubscriptionGroup, UsersSubscriptionGroupOptions | class/type | From insite-users-client | | CurrentUser, Org, Orgs, OrgsExtended, Role, Roles, User, Users, UsersExtended | type | From insite-users-client | | IncomingTransport, OutgoingTransport, IncomingTransfer, OutgoingTransfer, WithTransfer, WithOnTransfer, IncomingTransportOptions, arrayBufferToBase64 | — | From insite-ws-transfers | | WS, WSOptions | class/type | From insite-ws |

InSite

| Member | Description | |--------|-------------| | new InSite(options?) | Constructor, optionally calls init | | InSite.init(options?, asPromise?) | Static factory, returns InSite or Promise<InSite> | | ws | WS instance (with transfer/onTransfer when transports enabled) | | incomingTransport | IncomingTransport (when ws.incomingTransport: true) | | outgoingTransport | OutgoingTransport (when ws.outgoingTransport: true) | | cookie | CookieSetter (when cookie not null) | | usersSubscriptionGroup | UsersSubscriptionGroup (when users + not public) | | user | CurrentUser \| null (when users) | | users | Users \| UsersExtended | | orgs | Orgs \| OrgsExtended | | roles | Roles | | isLoggedIn | boolean | | login(email, password) | Promise (when users) | | logout() | Promise (when users) | | isReady | boolean | | whenReady() | StatefulPromise<this> | | Events | ready, login, logout |

Options

Options<AS> where AS extends AbilitiesSchema.

| Property | Type | Description | |----------|------|-------------| | ws | WSOptions & { subscriptions?, incomingTransport?, outgoingTransport? } | WebSocket config. Set subscriptions: true for pub/sub. Set incomingTransport / outgoingTransport for file transfers. | | cookie | CookieOptions \| null | Cookie auth. Use {} to enable, null to disable. | | users | { abilities?: AS } \| null | Users/orgs/roles. Use {} to enable, null to disable. | | public | boolean | When true with users, only user is loaded (no orgs, roles, users list). |

WS

WebSocket client with auto-reconnect and request/response.

Properties: url, name, protocols, reconnectAfter, signal, connectionQuality, webSocket, state, isConnecting, isOpen, isClosed, closedWith

Methods: open(), close(), send(), sendMessage(), sendRequest(), addRequestListener(), removeRequestListener(), destroy()

Events: connecting, open, close, message, message:${kind}, error, connection-quality-change, server-change, responsive, unresponsive, destroy

CookieSetter

Sets auth cookie via XHR when server sends a token.

constructor(ws: WS, options?: {
	method?: "GET" | "POST";
	url?: string;
	onload?: (this: XMLHttpRequest, event: ProgressEvent) => unknown;
	onerror?: (this: XMLHttpRequest, event: ProgressEvent) => unknown;
})

Subscription

Low-level subscription to server publications. Use Subscription.bindTo(ws) before creating instances.

Subscription.bindTo(ws);

const sub = new Subscription(
	"object",           // type: "array" | "map" | "object"
	"user",             // publicationName
	[ true ],           // args
	(user) => { ... },  // handler
	true                // immediately (default: true)
);

sub.start();   // (re)subscribe
sub.cancel();  // unsubscribe

IncomingTransport

Handles incoming file/data transfers. Adds onTransfer() and onceTransfer() to WS when enabled.

Properties: sizeLimit

Methods: on(), once(), off(), addTransferListener(), removeTransferListener()

OutgoingTransport

Handles outgoing file/data transfers. Adds transfer() to WS when enabled.

ws.transfer("avatar", {
	data: file,
	onProgress: (transfer) => { ... },
	onEnd: (transfer) => { ... }
});

UsersSubscriptionGroup

Subscription group for users, orgs, roles. Extends SubscriptionGroup.

Methods: extend() — load roles and extended user/org data; unextend() — detach extended subscriptions

Usage Examples

Minimal — WebSocket only:

InSite.init({ ws: { url: "wss://..." } });

With auth (public portal — current user only):

InSite.init({
	ws: { url: "wss://...", subscriptions: true },
	cookie: {},
	users: {},
	public: true
});

With auth (admin — full users/orgs/roles):

InSite.init({
	ws: { url: "wss://...", subscriptions: true },
	cookie: {},
	users: {}
});

With file transfers:

InSite.init({
	ws: {
		url: "wss://...",
		incomingTransport: true,
		outgoingTransport: true
	}
});

Use cases: Public portal — public: true, user only. Admin panel — users: {}, full UsersSubscriptionGroup. File uploads — outgoingTransport: true, ws.transfer(kind, props).

Related

License

MIT