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

@desolint/socket-shared

v0.0.1

Published

Shared Socket.IO contract types and constants for Desol Int. projects

Downloads

105

Readme

@desolint/socket-shared

Contract types and the one constant @desolint/socket-server and @desolint/socket-client must agree on. Zero runtime dependencies — no socket.io, no React — so importing it into a browser bundle pulls in nothing.

Anything only one side reads lives in that side's package, not here.

Requirements

No runtime dependencies and no peer dependencies — this package is types plus one constant, so it imposes no version constraints of its own.

Install

You normally do not install this package directly. It is a pinned dependency of @desolint/socket-server and @desolint/socket-client, and both re-export everything it exposes — so installing either one gives you these types automatically.

Install it directly only if you consume the contract without either side (a shared types package of your own, for example):

npm install @desolint/socket-shared

It has no dependencies and no peer dependencies.

The contract

Backend and frontend are separate repos, so each project keeps a copy of the contract in both. All three type arguments are the project's, including the socket.data shape — there's no preset that fixes it:

export type AppContract = SocketContract<
  {ping: (n: number) => void}, // clientToServer
  {message: (text: string) => void}, // serverToClient
  {userId: string; tenantId: string} // socket.data
>;

Both packages take this as a type argument, giving checked event names and payloads on each side. Whatever the server's authenticate returns must match the third argument — that pairing is the only thing keeping socket.data honest, since nothing validates it at runtime.

There is deliberately no DesolContract / DesolSocketData. An earlier version shipped both, fixing socket.data to {userId, organizationId} for every project; multi-tenancy is a product model, not a transport concern.

AUTH_FAILED_MESSAGE

The reason this package exists rather than being folded into the other two.

The server throws it from authenticate; the client matches on it (via isAuthFailure) to stop reconnecting. Without a shared value, the client can't tell "server is down, keep retrying" from "this cookie will never be accepted" — and since the default is reconnectionAttempts: Infinity, the latter means hammering the server forever after logout.

It is a pinned regular dependency of both packages, so a consumer cannot resolve two different versions of it — see the root README's Versioning section.

API

TypesSocketContract, EventMap, ClientToServer, ServerToClient, SocketDataOf, EventPayload, ServerEvent, ServerPayload, ClientEvent, ClientPayload.

ValuesAUTH_FAILED_MESSAGE, isAuthFailure({error}).

ServerEvent/ServerPayload type a server→client handler; ClientEvent/ClientPayload do the same for a client→server one (used for acknowledgements).

DEFAULT_CLIENT_OPTIONS moved to @desolint/socket-client — only the client reads it, so it was never something the two sides had to agree on.

Development

npm install        # install dependencies (from the repo root)
npm run build      # build all three packages
npm test           # type-check + jest
npm run lint       # eslint

This package is part of the package-socket-io workspaces monorepo — run the commands from the repository root, not this directory.


License

MIT © Desolint — see LICENSE.

Free to use, modify and redistribute, commercially or otherwise. Provided "as is", without warranty or liability of any kind.