mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 13:45:37 -04:00
Pass haveCredentials/accessToken between client/caseCorrect and client/encrypt
This commit is contained in:
parent
2f60088fdf
commit
bf5ce9e569
@ -3,10 +3,10 @@ var UUID = require('uuid-1345');
|
|||||||
|
|
||||||
module.exports = function(client, options) {
|
module.exports = function(client, options) {
|
||||||
var clientToken = options.clientToken || UUID.v4().toString();
|
var clientToken = options.clientToken || UUID.v4().toString();
|
||||||
var accessToken;
|
options.accessToken = null;
|
||||||
var haveCredentials = options.password != null || (clientToken != null && options.session != null);
|
options.haveCredentials = options.password != null || (clientToken != null && options.session != null);
|
||||||
|
|
||||||
if(haveCredentials) {
|
if(options.haveCredentials) {
|
||||||
// make a request to get the case-correct username before connecting.
|
// make a request to get the case-correct username before connecting.
|
||||||
var cb = function(err, session) {
|
var cb = function(err, session) {
|
||||||
if(err) {
|
if(err) {
|
||||||
@ -14,7 +14,7 @@ module.exports = function(client, options) {
|
|||||||
} else {
|
} else {
|
||||||
client.session = session;
|
client.session = session;
|
||||||
client.username = session.selectedProfile.name;
|
client.username = session.selectedProfile.name;
|
||||||
accessToken = session.accessToken;
|
options.accessToken = session.accessToken;
|
||||||
client.emit('session');
|
client.emit('session');
|
||||||
options.connect(client);
|
options.connect(client);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ module.exports = function(client, options) {
|
|||||||
client.end();
|
client.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(haveCredentials) {
|
if(options.haveCredentials) {
|
||||||
joinServerRequest(onJoinServerResponse);
|
joinServerRequest(onJoinServerResponse);
|
||||||
} else {
|
} else {
|
||||||
if(packet.serverId != '-') {
|
if(packet.serverId != '-') {
|
||||||
@ -35,7 +35,7 @@ module.exports = function(client, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function joinServerRequest(cb) {
|
function joinServerRequest(cb) {
|
||||||
yggserver.join(accessToken, client.session.selectedProfile.id,
|
yggserver.join(options.accessToken, client.session.selectedProfile.id,
|
||||||
packet.serverId, sharedSecret, packet.publicKey, cb);
|
packet.serverId, sharedSecret, packet.publicKey, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user