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

@gamerstake/game-platform-sdk

v1.0.6

Published

SDK for communicating with GameStake platform

Readme

GamerStake Platform SDK

SDK for communicating with the GamerStake platform from your game servers.

Installation

npm install @gamerstake/game-platform-sdk
# or
yarn add @gamerstake/game-platform-sdk
# or
pnpm install @gamerstake/game-platform-sdk

Quick Start

import { GameSDK } from '@gamerstake/game-platform-sdk';

const sdk = new GameSDK({
  apiKey: process.env.GAME_API_KEY!,
  environment: 'production', // 'development', 'staging', or 'production'
  debug: false,
});

// Start match (this initializes match tracking for this SDK instance)
const matchInfo = await sdk.reportMatchStart(matchId);

// Validate player token (with automatic input validation)
const player = await sdk.validatePlayerToken(token);

// Report player join (with automatic validation)
await sdk.reportPlayerJoin(matchId, player.id);

// Report match result (with automatic validation)
await sdk.reportMatchResult(matchId, {
  players: [
    { id: 'player1', score: 100, isWinner: true },
    { id: 'player2', score: 50, isWinner: false }
  ]
});

API Reference

Main Methods

  • reportMatchStart(matchId) - Reports match has started (returns match info, initializes single match tracking)
  • validatePlayerToken(token) - Validates JWT token and returns player identity
  • reportPlayerJoin(matchId, playerId) - Reports player joined the match
  • reportMatchResult(matchId, result) - Reports final match result
  • reportMatchError(matchId, reason) - Reports match error
  • clearCurrentMatch() - Clears the current match (useful for testing)
  • isInitialized() - Check if the SDK is properly initialized

Convenience Accessors

The SDK provides convenient access to services through getters:

// Access auth service
const player = await sdk.auth.validatePlayer(token);

// Access match service with additional methods
const matchInfo = await sdk.matches.getInfo(matchId);
const matchStatus = await sdk.matches.start(matchId);
const result = await sdk.matches.finish(matchId, result);
const cancelled = await sdk.matches.cancel(matchId);

Error Handling

The SDK uses a structured error hierarchy:

  • ConfigurationError - Configuration and initialization errors
  • AuthenticationError - Token validation errors
  • MatchSDKError - Match operation errors
  • NetworkError - HTTP/Network communication errors
  • ValidationError - Input validation errors

Input Validation

All public methods automatically validate their inputs:

  • Match IDs: Must be non-empty strings, max 100 chars, alphanumeric + hyphens/underscores
  • Player IDs: Must be non-empty strings, max 100 chars
  • JWT Tokens: Must be valid JWT format (3 base64 parts separated by dots)
  • Match Results: Must have valid players array with player objects containing id, score, and isWinner properties
  • Error Reasons: Must be non-empty strings, max 500 chars

You can also use the Validator class directly for custom validation needs.

Configuration

The SDK supports three environments:

  • development - Local development (http://localhost:3000)
  • staging - Staging environment (https://dev-api.gamerstake.io)
  • production - Production environment (https://api.gamerstake.com)

Important: Debug mode is automatically disabled in production environment for security.

Types

  • PlayerIdentity - Player information from validated token (id, username, email?)
  • MatchInfo - Match rules and expected players
  • MatchResult - Match outcome with players array containing scores and winners
  • MatchError - Error information for failed matches
  • CurrentMatchInfo - Current match state tracking (from MatchManager)
  • EnvironmentConfig - Environment-specific configuration
  • GameSDKConfig - SDK initialization configuration

Security Notes

  • SDK enforces JWT verification with platform's public key
  • You must not skip steps - platform rejects out-of-order calls
  • Funds are handled only by the platform - game servers cannot touch balances
  • Debug mode is automatically disabled in production environment
  • API keys are validated during initialization (minimum 10 characters)

Match State Management

The SDK includes a built-in MatchManager that tracks the current match state:

  • NOT_STARTED - Initial state
  • IN_PROGRESS - Match is active and players can join
  • FINISHED - Match completed successfully
  • ERROR - Match encountered an error

The SDK enforces proper match flow - you cannot start a new match while one is active, and you must clear the current match before starting a new one.

Version History

  • v1.0.4 - Current version with updated documentation
  • v1.0.3 - Version with enhanced match management and validation
  • v1.0.0 - Initial release with core functionality