New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yggdrasil

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yggdrasil - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

102

lib/index.js
/* jshint node: true */
"use strict";
var crypto = require('crypto');
var assert = require('assert');
var request = require('request');

@@ -7,3 +9,3 @@ var uuid = require('uuid');

module.exports = function Yggdrasil (con) {
var k = function Yggdrasil (con) {
var config = {

@@ -118,2 +120,98 @@ host : con.host || "https://authserver.mojang.com" //Allow for a custom auth server

return r;
};
};
k.server = function Server(con) {
var config = {
host : con.host || "https://sessionserver.mojang.com" //Allow for a custom auth server
};
var request = require('request').defaults({
headers: {
"User-Agent" : "node-yggdrasil/" + version,
"Content-Type" : "application/json"
}
});
var r = {};
r._call = function (path, data, cb) {
request({
method: 'POST',
uri: config.host + "/" + path,
json: data
}, function (err, resp, body) {
if (body && body.error) {
var out = body.errorMessage;
out.status = resp.statusCode;
cb(out);
} else {
cb(err, body);
}
});
};
/**
* Java's annoying hashing method.
* All credit to andrewrk
* https://gist.github.com/andrewrk/4425843
*/
function performTwosCompliment(buffer) {
var carry = true;
var i, newByte, value;
for (i = buffer.length - 1; i >= 0; --i) {
value = buffer.readUInt8(i);
newByte = ~value & 0xff;
if (carry) {
carry = newByte === 0xff;
buffer.writeUInt8(newByte + 1, i);
} else {
buffer.writeUInt8(newByte, i);
}
}
}
r.mcHexDigest = function mcHexDigest(str) {
var hash = new Buffer(crypto.createHash('sha1').update(str).digest(), 'binary');
// check for negative hashes
var negative = hash.readInt8(0) < 0;
if (negative) performTwosCompliment(hash);
var digest = hash.toString('hex');
// trim leading zeroes
digest = digest.replace(/^0+/g, '');
if (negative) digest = '-' + digest;
return digest;
};
r.join = function (token, profile, serverid, sharedsecret, serverkey, cb) {
r._call('session/minecraft/join', {
"accessToken": token,
"selectedProfile": profile,
"serverId": r.mcHexDigest(serverid + sharedsecret + serverkey)
}, function(err, data) {
cb(err, data);
});
};
r.hasJoined = function (username, serverid, sharedsecret, serverkey, cb) {
var hash = r.mcHexDigest(serverid + sharedsecret + serverkey);
request({
method: 'GET',
uri: config.host + '/session/minecraft/hasJoined?username='+username+'&serverId='+hash
}, function (err, resp, body) {
if (body && body.error) {
var out = body.errorMessage;
out.status = resp.statusCode;
cb(out);
} else {
cb(err, body);
}
});
};
return r;
};
module.exports = k;

4

package.json
{
"name": "yggdrasil",
"version": "0.0.2",
"author": "Nodejitsu <zeke@zekesonxx.com>",
"version": "0.0.3",
"author": "Zeke Sonxx <zeke@zekesonxx.com>",
"description": "Mojang authentication (Yggdrasil) client",

@@ -6,0 +6,0 @@ "scripts": {

@@ -0,0 +0,0 @@ # yggdrasil

@@ -0,0 +0,0 @@ /* jshint node: true, expr: true */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc