Skip to content

A NodeJS library for validating Minecraft account information.

License

Notifications You must be signed in to change notification settings

medsouz/mcauth.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCAuth.js

A NodeJS library for validating Minecraft account information. Created for the serverside of Miney.

Installation

You can install using npm install mcauth.

Usage

hasPaid To check if a user has bought Minecraft you can use mcauth.hasPaid:

var mcauth = require("mcauth");
mcauth.hasPaid("medsouz", function(paid){
	if(paid){
		console.log(username + ' has purchased Minecraft!');
	}else{
		console.log(username + ' has not purchased Minecraft.');
	}
});

checkSessionId When a user connects to a server they use a string called a sessionId to connect, you can validate a sessionId using mcauth.checkSessionId:

var mcauth = require("mcauth");
mcauth.checkSessionId("medsouz", "-SessionId Here-", function(valid){
	if(valid){
		console.log('Login is valid');
	}else{
		console.log('Login is invalid');
	}
});

getMojangProfile Check a Minecraft username against Mojang's server. This allows you to get the player's UUID. The UUID should be used from now on for identification because coming with the Minecraft 1.8 update Mojang will allow the player to change their username.

var mcauth = require("mcauth");
mcauth.getMojangProfile("medsouz", function(profile) {
        console.log(profile.profiles[0].id);//Should output a80dfef48150469f878c0a4d2d8bff3f
});

getPlayerInformation This function takes a UUID and responds with a JSON object containing the player's current username and skin/cape information.

var mcauth = require("mcauth");
mcauth.getPlayerInformation("a80dfef48150469f878c0a4d2d8bff3f", function(info){
    console.log(info.name);//Should output medsouz
});

isNameValid To run a regexp check to make sure a username is a valid account name for Minecraft you can use mcauth.isNameValid:

var mcauth = require("mcauth");
mcauth.isNameValid("medsouz", function(valid){
    if(valid){
        console.log('Username is valid');
    }else{
        console.log('Username has an invalid length or contains invalid characters.');
    }
});

About

A NodeJS library for validating Minecraft account information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published