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

@frayit/sdk

v1.2.0

Published

Official Frayit SDK for chat and voice services with behavioral risk detection.

Readme

@frayit/sdk

Official TypeScript SDK for Frayit chat moderation and voice services.

Server-side only for credentialed APIs. Do not expose clientId and clientSecret in browser bundles or game clients.

Install

npm install @frayit/sdk

Initialize

import { FrayitClient } from "@frayit/sdk"

const client = new FrayitClient({
  clientId: process.env.FRAYIT_CLIENT_ID!,
  clientSecret: process.env.FRAYIT_CLIENT_SECRET!,
  baseUrl: process.env.FRAYIT_BASE_URL!,
  voiceTimeoutMs: 1500,
})

await client.initialize()

Call initialize() once at service startup.

Chat APIs

evaluateChat

const result = await client.evaluateChat({
  player_id: "player-123",
  session_id: "session-1",
  channel_id: "global",
  message: "hello world",
})

sendMessage

const result = await client.sendMessage({
  player_id: "player-123",
  session_id: "session-1",
  channel_id: "global",
  message: "gg wp",
})

connectChat (Managed mode only)

const channel = await client.connectChat("player-123", "global", {
  onMessage: (event) => console.log(event),
  onError: (error) => console.error(error),
})

await channel.disconnect()

Voice Backend APIs

Use these from your studio backend to issue LiveKit access and manage room state.

Join voice channel

const join = await client.joinVoiceChannel({
  channel_id: "team-red",
  player_id: "player-123",
  session_id: "session-1",
  max_participants: 8,
})

console.log(join.livekit_url, join.livekit_token)

Server mute or unmute player

await client.setServerMute({
  channel_id: "team-red",
  player_id: "player-123",
  muted: true,
})

Get room state

const room = await client.getVoiceRoomState("team-red")
console.log(room.participant_count, room.participants)

Leave and close room

await client.leaveVoiceChannel({
  channel_id: "team-red",
  player_id: "player-123",
})

await client.closeVoiceChannel("team-red")

Client-Side Voice State Helpers

These helpers are local state only. They do not call network APIs.

client.setSelfMuted(true)
client.setSelfDeafened(false)
client.setPeerMutedLocally("player-456", true)

const canPlay = client.shouldPlayPeerAudio("player-456")
const isSelfMuted = client.isSelfMuted
const muteMap = client.getPeerMuteMapSnapshot()

Production Architecture for Voice

  1. Your backend calls joinVoiceChannel.
  2. Backend sends only livekit_url and livekit_token to the game client.
  3. Game client connects directly to LiveKit.
  4. Backend uses setServerMute, getVoiceRoomState, leaveVoiceChannel, and closeVoiceChannel for control and moderation.

Config Options

| Option | Default | Description | |---|---|---| | chatTimeoutMs | 100 | Timeout for evaluateChat and sendMessage. | | voiceTimeoutMs | 1500 | Timeout for voice APIs (join, leave, close, room, mute). | | tokenRequestTimeoutMs | 5000 | Timeout for token endpoint. | | tokenPrefetchWindowMs | 1800000 | Refresh token this many ms before expiry. | | idleRefreshCheckIntervalMs | 30000 | Periodic background refresh check interval. | | tokenFailureBackoffMs | 20000 | Backoff after failed refresh when token still valid. | | maxRetries | 2 | Retry count for transient failures. | | retryBaseDelayMs | 200 | Exponential backoff base delay. | | circuitBreakerFailureThreshold | 5 | Consecutive failures before circuit opens (chat APIs). | | circuitBreakerOpenDurationMs | 20000 | Open-state duration before half-open probe. |

Fail-Open Behavior (Chat APIs)

When Frayit is unreachable, evaluateChat() and sendMessage() return fail-open results so gameplay is not blocked.

Dispose

client.dispose()