Lessen logging, fix JWT param

This commit is contained in:
extremeheat 2021-04-14 07:42:36 -04:00
commit 8663247a2a
4 changed files with 6 additions and 7 deletions

View file

@ -1,5 +1,6 @@
const JWT = require('jsonwebtoken')
const constants = require('./constants')
const debug = require('debug')('minecraft-protocol')
module.exports = (client, server, options) => {
// Refer to the docs:
@ -19,14 +20,14 @@ module.exports = (client, server, options) => {
let finalKey = null
// console.log(pubKey)
for (const token of chain) {
const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' })
const decoded = JWT.verify(token, pubKey, { algorithms: ['ES384'] })
// console.log('Decoded', decoded)
// Check if signed by Mojang key
const x5u = getX5U(token)
if (x5u === constants.PUBLIC_KEY && !data.extraData?.XUID) {
// didVerify = true
console.log('verified with mojang key!', x5u)
debug('Verified client with mojang key', x5u)
}
// TODO: Handle `didVerify` = false
@ -41,7 +42,7 @@ module.exports = (client, server, options) => {
function verifySkin (publicKey, token) {
const pubKey = mcPubKeyToPem(publicKey)
const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' })
const decoded = JWT.verify(token, pubKey, { algorithms: ['ES384'] })
return decoded
}

View file

@ -244,7 +244,7 @@ class MinecraftTokenManager {
const token = this.cache.mca
debug('[mc] token cache', this.cache)
if (!token) return
console.log('TOKEN', token)
debug('Auth token', token)
const jwt = token.chain[0]
const [header, payload, signature] = jwt.split('.').map(k => Buffer.from(k, 'base64')) // eslint-disable-line

View file

@ -38,10 +38,8 @@ class BatchPacket {
encode () {
const buf = this.stream.getBuffer()
console.log('Encoding payload', buf)
const def = Zlib.deflateRawSync(buf, { level: this.compressionLevel })
const ret = Buffer.concat([Buffer.from([0xfe]), def])
console.log('Compressed', ret)
return ret
}

View file

@ -57,7 +57,7 @@ class Player extends Connection {
// TODO: disconnect user
throw new Error('Failed to verify user')
}
console.log('Verified user', 'got pub key', key, userData)
debug('Verified user pub key', key, userData)
this.emit('login', { user: userData.extraData }) // emit events for user
this.emit('server.client_handshake', { key }) // internal so we start encryption