@2stars/video-js
v0.5.1
Published
2Stars WebRTC + messaging core JavaScript SDK. Powers @2stars/video-react and direct browser integrations.
Readme
@2stars/video-js
Core JavaScript SDK for the 2Stars Video Platform — real-time video, voice, and end-to-end encrypted messaging delivered as a hosted API. Powers @2stars/video-react but works standalone for vanilla JS / TS / framework-of-your-choice integrations.
import { StarsClient } from '@2stars/video-js';
const client = new StarsClient();
await client.connect(participantToken);
const room = await client.joinRoom(roomCode);
room.on('peer-joined', (peer) => renderTile(peer));
room.on('peer-left', (peer) => removeTile(peer));
room.on('message', (msg) => renderMessage(msg));
await room.publishCamera();
await room.publishMic();Install
npm install @2stars/video-js mediasoup-client socket.io-clientmediasoup-client and socket.io-client are peer dependencies — your app pins the major version.
Auth
You authenticate with a short-lived participant token minted server-side from your 2Stars API key. Never embed your API key in browser code.
// Backend (Node)
const res = await fetch('https://api.2stars.io/video/v1/tokens', {
method: 'POST',
headers: { authorization: 'Bearer hbs_live_…', 'content-type': 'application/json' },
body: JSON.stringify({ roomCode, participantId, displayName, ttlSeconds: 3600 }),
});
const { token } = await res.json();
// Send `token` to the browser.Modules
| Import | What it gives you |
|---|---|
| StarsClient (default) | Connection + room lifecycle + signaling |
| Room | Active room — peers, publish/subscribe, messages |
| Peer | Remote peer — audio/video streams, metadata |
| Message | E2E-encrypted chat message |
| @2stars/video-js/HebbsClient | High-level wrapper (one-call demos, auto-token) |
| Whiteboard, WhiteboardEditor | AI-generated SVG whiteboards |
| Transcription | Live speech-to-text |
| AIParticipant | AI participant ("Hebbs") chat + voice |
| VideoProcessor, AvatarRenderer, AutoFrameProcessor | Background blur, avatar mode, auto-frame |
| WakeWord, WakeWordMatcher | "Hey Hebbs" wake-word detection |
Features
- Adaptive routing: 2-person calls run P2P; 3+ auto-upgrades to SFU; satellite-pipe rooms for global distribution.
- Recording: server-managed MP4 / WebM / HLS / WAV / OGG via
/video/v1/rooms/{code}/recording/*. - HLS broadcasting: viewer-token-gated playback for unlimited audiences.
- End-to-end encryption: SFrame on the media plane, E2E-encrypted chat messages.
- AI in-call: transcription, translation (text + voice), summaries, intelligence, fact-check, correction.
- Virtual backgrounds: MediaPipe-based blur + AI background swap.
- Moderation: kick / mute / ban / lock rooms.
Companion SDKs
@2stars/video-react— React Provider + 25 hooks built on this SDKcom.github.2stars-io:video-android— Android client@2stars/verifai-web— VerifAI device-trust SDK for browsers- OpenAPI spec — generate a client in any language
License
MIT — see LICENSE.
