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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@fiveminutes-io/five-minute-chat-contracts

v1.8.1

Published

Five Minute Chat is a SaaS chat service that is very quick to get started with and leverage in your game or app project. This library contains TypeScript interface types for connecting to the Five Minute Chat backends.

Readme

FiveMinutes Chat Client Types

This package provides TypeScript class definitions and helper types for interacting with the FiveMinutes Chat SignalR interface. It includes all necessary message contracts, enums, and data models required to perform a full authentication handshake and exchange chat messages.

Installation

npm install @fiveminutes-io/five-minute-chat-contracts

Features

  • Strict Typing: Full TypeScript definitions for all Request (Client...) and Response (Server...) objects.
  • Serialization Helpers: All classes include a pre-configured $type property (e.g., FiveMinutes.Model.Messages.Client.ClientChatMessage, Gateway.Contracts) to ensure correct polymorphic deserialization on the server.
  • Enums: Strongly typed enums for EventType, Language, UserType, etc.

Usage

Connecting with SignalR

The library is designed to be used in conjunction with @microsoft/signalr. Because the backend uses a polymorphic message pattern, messages are sent as serialized JSON strings via a single hub method (GenericText) and received via a single event (Generic).

1. Setup Connection

import * as signalR from "@microsoft/signalr";
import { 
  ClientCredentialsResponse, 
  ClientUserInfoResponse,
  ServerWelcome,
  ServerCredentialsRequest,
  ServerUserInfoRequest 
} from "@fiveminutes-io/five-minute-chat-contracts";

// Initialize SignalR Connection
const connection = new signalR.HubConnectionBuilder()
    .withUrl("https://signalr.fiveminutes.cloud/signalr")
    .withAutomaticReconnect()
    .build();

2. Handle Incoming Messages

Incoming messages arrive on the "Generic" channel. You must inspect the $type property to determine how to cast and handle the message.

connection.on("Generic", async (message: any) => {
    const typeString = message.$type as string;
    const className = typeString.split(',')[0].split('.').pop();

    switch (className) {
        case "ServerCredentialsRequest":
            // Handle auth challenge
            const credentialsResponse = new ClientCredentialsResponse();
            credentialsResponse.ApplicationId = "YOUR_APP_ID";
            credentialsResponse.ApplicationSecret = "YOUR_SECRET";
            
            // Send response serialized as JSON
            await connection.invoke("GenericText", JSON.stringify(credentialsResponse));
            break;

        case "ServerUserInfoRequest":
            // Handle user info request
            const userResponse = new ClientUserInfoResponse();
            userResponse.UniqueUserId = crypto.randomUUID();
            userResponse.Username = "MyUsername";
            
            await connection.invoke("GenericText", JSON.stringify(userResponse));
            break;

        case "ServerWelcome":
            const welcomeMsg = message as ServerWelcome;
            console.log(`Login successful! Display ID: ${welcomeMsg.DisplayId}`);
            break;
            
        case "ServerChatMessage":
            console.log("New chat message:", message.Content);
            break;

        default:
            console.warn("Unknown message type:", className);
    }
});

3. Send Messages

To send messages (like chat messages or commands), create an instance of the class and send it via GenericText as a JSON string.

import { ClientChatMessage } from "@fiveminutes-io/five-minute-chat-contracts";

const chatMsg = new ClientChatMessage();
chatMsg.ChannelName = "Global";
chatMsg.Content = "Hello World!";

await connection.invoke("GenericText", JSON.stringify(chatMsg));

Build & Test

To build the package locally:

npm run build