1.19.3 chat fixes (#1093)

Co-authored-by: Frej Alexander Nielsen <frej@valoks.com>
This commit is contained in:
Frej Alexander Nielsen 2023-03-24 23:29:03 +01:00 committed by GitHub
parent f52ab55ef9
commit 70aee3d494
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,7 @@ module.exports = function (client, options) {
if (player && player.hasChainIntegrity) { if (player && player.hasChainIntegrity) {
if (!player.lastSignature || player.lastSignature.equals(currentSignature) || index > player.sessionIndex) { if (!player.lastSignature || player.lastSignature.equals(currentSignature) || index > player.sessionIndex) {
player.lastSignature = currentSignature player.lastSignature = currentSignature
player.sessionIndex = index
} else { } else {
player.hasChainIntegrity = false player.hasChainIntegrity = false
} }
@ -194,6 +195,7 @@ module.exports = function (client, options) {
const tsDelta = BigInt(Date.now()) - packet.timestamp const tsDelta = BigInt(Date.now()) - packet.timestamp
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0 const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
if (verified) client._signatureCache.push(packet.signature)
client.emit('playerChat', { client.emit('playerChat', {
plainMessage: packet.plainMessage, plainMessage: packet.plainMessage,
unsignedContent: packet.unsignedContent, unsignedContent: packet.unsignedContent,