
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
TypeScript port of Blizzard's s2protocol for parsing StarCraft II replay files
TypeScript port of Blizzard's s2protocol library for parsing StarCraft II replay files. Designed to work with Bun.
bun add s2protocol-ts
The package includes mpyqjs2 as a dependency for reading .SC2Replay (MPQ archive) files.
import { latest, build, decodeString, toJsonSafe } from 's2protocol-ts';
// Get the latest protocol
const protocol = latest();
// Or get a specific protocol version
const protocol95299 = build(95299);
// Decode replay header (from MPQ archive user data)
const header = protocol.decode_replay_header(headerContents);
console.log('Base build:', header.m_version.m_baseBuild);
// Decode game details
const details = protocol.decode_replay_details(detailsContents);
console.log('Map:', decodeString(details.m_title));
// Decode game events
for (const event of protocol.decode_replay_game_events(gameEventsContents)) {
console.log(event._event, event._gameloop);
}
// Decode tracker events
for (const event of protocol.decode_replay_tracker_events(trackerContents)) {
console.log(event._event);
}
// Convert to JSON-safe format (Uint8Array -> string, BigInt -> string)
const jsonSafe = toJsonSafe(details);
console.log(JSON.stringify(jsonSafe, null, 2));
SC2Replay files are MPQ archives. The package includes mpyqjs2 for reading them:
const mpyqjs = require('mpyqjs2/mpyq.js');
import { latest, build, processDetailsData } from 's2protocol-ts';
// Open replay file
const archive = new mpyqjs.MPQArchive('replay.SC2Replay');
// Read header using latest protocol
const headerContents = new Uint8Array(archive.header.user_data_header.content);
const header = latest().decode_replay_header(headerContents);
// Get correct protocol for this replay
const protocol = build(header.m_version.m_baseBuild);
// Read and decode details
const detailsContents = new Uint8Array(archive.readFile('replay.details'));
let details = protocol.decode_replay_details(detailsContents);
// Convert cache handles to URLs
details = processDetailsData(details);
console.log('Cache handles:', details.m_cacheHandles);
# Show available options
bun run ./src/cli.ts --help
# Print replay header
bun run ./src/cli.ts --header replay.SC2Replay
# Print game details
bun run ./src/cli.ts --details replay.SC2Replay
# Print all game events
bun run ./src/cli.ts --gameevents replay.SC2Replay
# Print tracker events as JSON
bun run ./src/cli.ts --trackerevents --json replay.SC2Replay
# Print everything
bun run ./src/cli.ts --all replay.SC2Replay
# List supported protocol versions
bun run ./src/cli.ts --versions
latest() - Get the latest protocol modulebuild(version: number) - Get a specific protocol versionlistAll() - List all supported protocol versionsisSupported(version: number) - Check if a version is supportedEach protocol module provides:
decode_replay_header(contents) - Decode replay headerdecode_replay_details(contents) - Decode game detailsdecode_replay_initdata(contents) - Decode init datadecode_replay_game_events(contents) - Generator for game eventsdecode_replay_message_events(contents) - Generator for message eventsdecode_replay_tracker_events(contents) - Generator for tracker eventsdecode_replay_attributes_events(contents) - Decode attributescacheHandleUri(handle) - Convert cache handle to URLprocessDetailsData(details) - Process details with cache handle URLsprocessInitData(initdata) - Process init data with cache handle URLsprocessScopeAttributes(scopes, callback) - Process attributesdecodeString(data) - Decode Uint8Array as UTF-8 stringtoJsonSafe(obj) - Convert to JSON-safe formatBitPackedBuffer - Low-level bit buffer readingBitPackedDecoder - Bit-packed protocol decoderVersionedDecoder - Versioned protocol decoder (with skip markers)BitPackedWriteBuffer - Low-level bit buffer writingBitPackedEncoder - Bit-packed protocol encoderVersionedEncoder - Versioned protocol encoderGame attribute constants are exported from attributes:
import { attributes } from 's2protocol-ts';
console.log(attributes.RACE); // 3001
console.log(attributes.GAME_SPEED); // 3000
This package includes all 89 protocol versions from build 15405 to 95299, covering StarCraft II replays from all game versions:
Protocol versions are automatically selected based on the replay's base build number. Use listAll() to see all supported versions or isSupported(version) to check if a specific version is available.
MIT License - Based on code copyright (c) 2013-2017 Blizzard Entertainment
Original Python implementation by Blizzard Entertainment. TypeScript port designed for Bun runtime.
FAQs
TypeScript port of Blizzard's s2protocol for parsing StarCraft II replay files
The npm package s2protocol receives a total of 101 weekly downloads. As such, s2protocol popularity was classified as not popular.
We found that s2protocol demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.