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

@connect4/contracts

v4.3.3

Published

Versioned Connect4 protocol contracts for native WebSocket clients and backend.

Readme

@connect4/contracts

Versioned public protocol contracts shared by Connect4 clients and backend.

The protocol version in this release is 4. Version 4 uses one authoritative game snapshot, removes duplicated viewer-specific fields, and adds the game:surrender command.

Contents

  • Native WebSocket event names and protocol version.
  • Client-to-server and server-to-client typed event maps.
  • Generic typed message envelopes.
  • Zod schemas for runtime validation.
  • HTTP authentication-session request and response schemas.
  • Public protocol enums and error codes.
  • Bot strategy values shared by matchmaking and gameplay (REMOTE_MINIMAX, REMOTE_ALPHAGO, and REMOTE_MCTS). All bot computation runs in BotConnect4Live.

This package contains no NestJS code, persistence model, repository, business logic, or frontend-specific implementation.

Usage

Install the package together with Zod:

npm install @connect4/contracts zod
import {
  GameMovePayloadSchema,
  WsEvent,
  type ClientMessage,
} from '@connect4/contracts';

const message: ClientMessage<typeof WsEvent.GameMove> = {
  version: '4',
  event: WsEvent.GameMove,
  data: {
    gameId: 'game-id',
    column: 3,
    stateVersion: 0,
  },
};

GameMovePayloadSchema.parse(message.data);

matchmaking:matched contains the game id, mode, and both player profiles. game:state is the authoritative reconnectable snapshot. The client derives its own disc and opponent from players using the authenticated user id. game:finished is a terminal notification; result:state carries the complete result records for both players.

All current bot profiles are computed by the backend BotConnect4Live service. Clients never calculate or submit a bot move.

To surrender, send game:surrender with { gameId }. The server emits the same terminal flow as other endgame reasons.

To load the authenticated player's recent matches, send history:get with {}. The server replies with history:state and at most the 10 most recent completed games. This is a compact summary; replay details remain a separate permission-controlled operation.

leaderboard:get accepts page: 1 or page: 2. The two pages cover at most the top 50 entries (20 entries on page 1 and 30 entries on page 2).

The package follows semantic versioning. Protocol breaking changes require a major version.

Authentication session

Clients create a game session through one HTTP endpoint, POST /auth/session. The request is a strict discriminated union on provider: GUEST accepts an installation id and an optional rotated guest session credential; CRAZYGAMES accepts the platform JWT; and TIKTOK accepts the temporary silent-login code. The response always returns a short-lived internal access token for the WebSocket auth:login command. Only a GUEST response includes the next opaque guest session credential.

import {
  AuthenticationSessionRequestSchema,
  AuthenticationSessionResponseSchema,
} from '@connect4/contracts';

Platform credentials are never valid WebSocket credentials. Each client validates the response before using its internal access token for the existing WebSocket authentication flow.

Cocos Creator runtime

Cocos Creator 2.4 clients must import the runtime-safe core entry:

import { WsEvent, createClientMessage } from '@connect4/contracts/core';

The core entry contains protocol constants, enums, payload types, and envelope helpers. It has no Zod runtime dependency. The package root remains the backend entry and includes Zod schemas for runtime validation.

The package also ships a CommonJS-compatible dist/core.js artifact because Cocos Creator 2.4's quick compiler resolves the file path directly instead of applying npm exports conditions. Modern ESM consumers continue to use the ESM core export automatically.