Skip to content

๐ŸŽฎ Comprehensive Node.js implementation of Minecraft Votifier protocol (v1 & v2) with robust RSA key support, Java server compatibility, and beautiful web testing interface โšก

License

Notifications You must be signed in to change notification settings

speaway/nodejs-votifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Node.js Votifier

License: MIT Node.js Version

A comprehensive Node.js implementation of the Minecraft Votifier protocol with full support for both v1 (RSA) and v2 (HMAC-SHA256) protocols. Features robust RSA key format support and full compatibility with Java-based Votifier servers like VotifierPlus.

โœจ Features

  • ๐Ÿš€ Complete Protocol Support: Both Votifier v1 and v2 implementations
  • ๐Ÿ” Robust RSA Key Parsing: Supports SPKI, PKCS#1, base64, XML, and hex formats
  • ๐Ÿค Java Server Compatible: Tested with VotifierPlus and other Java implementations
  • ๐ŸŒ Web Testing Interface: Beautiful dark-themed web UI for testing votes
  • ๐Ÿ“ฆ Zero Dependencies: Pure Node.js implementation (web tester uses Express)
  • ๐Ÿงช Comprehensive Tests: Full test suite with real-world scenarios
  • ๐Ÿ“š Rich Documentation: Complete examples and API documentation

๐Ÿš€ Quick Start

Installation

git clone https://github.com/yourusername/nodejs-votifier.git
cd nodejs-votifier

Basic Usage

const { newV1Client, newV2Client, newVote } = require('./nodejs-votifier');

// Create a vote
const vote = newVote('MyService', 'PlayerName', '127.0.0.1');

// V1 Client (RSA)
const v1Client = newV1Client('localhost:8192', publicKey);
await v1Client.sendVote(vote);

// V2 Client (HMAC-SHA256)  
const v2Client = newV2Client('localhost:8192', 'secret-token');
await v2Client.sendVote(vote);

๐Ÿ“ Project Structure

nodejs-votifier/
โ”œโ”€โ”€ lib/                 # Core library
โ”‚   โ”œโ”€โ”€ index.js        # Main exports
โ”‚   โ”œโ”€โ”€ vote.js         # Vote class
โ”‚   โ”œโ”€โ”€ protocol-v1.js  # V1 protocol implementation
โ”‚   โ”œโ”€โ”€ protocol-v2.js  # V2 protocol implementation
โ”‚   โ”œโ”€โ”€ v1-client.js    # V1 client
โ”‚   โ”œโ”€โ”€ v2-client.js    # V2 client
โ”‚   โ”œโ”€โ”€ server.js       # Votifier server
โ”‚   โ””โ”€โ”€ utils.js        # Utility functions
โ”œโ”€โ”€ examples/           # Usage examples
โ”œโ”€โ”€ test/              # Test suite
โ””โ”€โ”€ README.md

votifier-web-tester/   # Web testing interface
โ”œโ”€โ”€ server.js          # Express.js backend
โ”œโ”€โ”€ public/           # Frontend assets
โ””โ”€โ”€ package.json

๐ŸŽฏ Examples

Running Examples

# Start example server
npm run example-server

# Test V1 client
npm run example-client-v1

# Test V2 client  
npm run example-client-v2

V1 Protocol Example

const { newV1Client, newVote } = require('./lib');

const publicKey = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
-----END PUBLIC KEY-----`;

const client = newV1Client('localhost:8192', publicKey);
const vote = newVote('WebTester', 'TestUser', '127.0.0.1');

try {
    await client.sendVote(vote);
    console.log('โœ… Vote sent successfully!');
} catch (error) {
    console.error('โŒ Vote failed:', error.message);
}

V2 Protocol Example

const { newV2Client, newVote } = require('./lib');

const client = newV2Client('localhost:8192', 'your-secret-token');
const vote = newVote('WebTester', 'TestUser', '127.0.0.1');

try {
    await client.sendVote(vote);
    console.log('โœ… Vote sent successfully!');
} catch (error) {
    console.error('โŒ Vote failed:', error.message);
}

๐ŸŒ Web Testing Interface

Launch the beautiful web testing interface:

cd votifier-web-tester
npm install
npm start

Visit http://localhost:3000 to access the testing interface with:

  • ๐ŸŽจ Modern Dark Theme: Beautiful, responsive design
  • ๐Ÿ”„ Protocol Switching: Easy V1/V2 protocol selection
  • ๐Ÿ“ Smart Forms: Auto-validation and error handling
  • โšก Real-time Testing: Instant feedback and results
  • ๐Ÿ”ง RSA Key Generation: Built-in key pair generator

๐Ÿงช Testing

Run the comprehensive test suite:

npm test

๐Ÿ”ง RSA Key Format Support

This library automatically detects and supports multiple RSA key formats:

  • SPKI: Standard -----BEGIN PUBLIC KEY----- format
  • PKCS#1: -----BEGIN RSA PUBLIC KEY----- format
  • Base64: Raw base64 encoded keys
  • XML: <RSAKeyValue> XML format
  • Hex: Hexadecimal encoded keys

๐Ÿค Java Server Compatibility

Fully tested and compatible with:

  • โœ… VotifierPlus (Bukkit/Spigot/Paper)
  • โœ… Votifier (Original Bukkit plugin)
  • โœ… NuVotifier (BungeeCord)
  • โœ… Custom Java implementations

๐Ÿ“š API Reference

Vote Class

const vote = newVote(serviceName, username, address, timestamp);
// Creates a new vote instance

V1Client

const client = newV1Client(address, publicKey);
await client.sendVote(vote);

V2Client

const client = newV2Client(address, token);
await client.sendVote(vote);

Server

const server = newVotifierServer(port, privateKey, tokens);
server.listen();

๐Ÿšจ Troubleshooting

Common Issues

RSA Key Format Error

Error: Failed to parse RSA public key
  • Solution: Use the robust key parsing - supports multiple formats automatically

V2 Connection Closed

Error: Connection closed before receiving response
  • Solution: This may be normal - some servers close connection after successful vote

V2 Signature Invalid

Error: signature invalid  
  • Solution: Verify your token matches the server configuration exactly

๐Ÿค” Why This Library?

  • ๐Ÿ—๏ธ Production Ready: Thoroughly tested with real Minecraft servers
  • ๐Ÿ”„ Protocol Complete: Full v1 and v2 support with all features
  • ๐Ÿ› ๏ธ Developer Friendly: Rich examples, documentation, and error handling
  • ๐ŸŽฏ Java Compatible: Works seamlessly with existing Java servers
  • ๐Ÿš€ Modern Node.js: Clean async/await API with Promise support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Credits

Ported from the excellent go-votifier library. Special thanks to the original authors and the Minecraft community for their contributions to the Votifier protocol.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Made with โค๏ธ for the Minecraft community

About

๐ŸŽฎ Comprehensive Node.js implementation of Minecraft Votifier protocol (v1 & v2) with robust RSA key support, Java server compatibility, and beautiful web testing interface โšก

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published