mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-24 08:17:52 -05:00
Compare commits
5 commits
cf8e54c4f1
...
ffad0afbd0
Author | SHA1 | Date | |
---|---|---|---|
|
ffad0afbd0 | ||
|
590dc33fed | ||
|
89de052d44 | ||
|
5bebac3662 | ||
|
cd8f06e3ee |
7 changed files with 22 additions and 16 deletions
|
@ -1,5 +1,8 @@
|
|||
# History
|
||||
|
||||
## 1.50.0
|
||||
* [1.21 Support (#1342)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/5bebac36620d8f8ec256d19483e20e643d63de2a) (thanks @GroobleDierne)
|
||||
|
||||
## 1.49.0
|
||||
* [support 1.20.6 (#1338)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/0b0012d60f0f1648be5ff705e7694bb1cd4ec37c) (thanks @rom1504)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
|
|||
|
||||
* Supports Minecraft PC version 1.7.10, 1.8.8, 1.9 (15w40b, 1.9, 1.9.1-pre2, 1.9.2, 1.9.4),
|
||||
1.10 (16w20a, 1.10-pre1, 1.10, 1.10.1, 1.10.2), 1.11 (16w35a, 1.11, 1.11.2), 1.12 (17w15a, 17w18b, 1.12-pre4, 1.12, 1.12.1, 1.12.2), and 1.13 (17w50a, 1.13, 1.13.1, 1.13.2-pre1, 1.13.2-pre2, 1.13.2), 1.14 (1.14, 1.14.1, 1.14.3, 1.14.4)
|
||||
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6)
|
||||
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6, 1.21.1)
|
||||
* Parses all packets and emits events with packet fields as JavaScript
|
||||
objects.
|
||||
* Send a packet by supplying fields as a JavaScript object.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-protocol",
|
||||
"version": "1.49.0",
|
||||
"version": "1.50.0",
|
||||
"description": "Parse and serialize minecraft packets, plus authentication and encryption.",
|
||||
"main": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
|
@ -33,7 +33,7 @@
|
|||
},
|
||||
"browser": "src/browser.js",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.2.1",
|
||||
"@types/node": "^22.7.9",
|
||||
"espower-loader": "^1.0.0",
|
||||
"intelli-espower-loader": "^1.0.0",
|
||||
"minecraft-packets": "^1.1.5",
|
||||
|
@ -52,7 +52,7 @@
|
|||
"endian-toggle": "^0.0.0",
|
||||
"lodash.get": "^4.1.2",
|
||||
"lodash.merge": "^4.3.0",
|
||||
"minecraft-data": "^3.75.0",
|
||||
"minecraft-data": "^3.78.0",
|
||||
"minecraft-folder-path": "^1.2.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-rsa": "^0.4.2",
|
||||
|
|
|
@ -7,6 +7,7 @@ const chatPlugin = require('./chat')
|
|||
const { concat } = require('../transforms/binaryStream')
|
||||
const { mojangPublicKeyPem } = require('./constants')
|
||||
const debug = require('debug')('minecraft-protocol')
|
||||
const NodeRSA = require('node-rsa')
|
||||
|
||||
module.exports = function (client, server, options) {
|
||||
const mojangPubKey = crypto.createPublicKey(mojangPublicKeyPem)
|
||||
|
@ -106,6 +107,9 @@ module.exports = function (client, server, options) {
|
|||
}
|
||||
}
|
||||
|
||||
const keyRsa = new NodeRSA(server.serverKey.exportKey('pkcs1'), 'private', { encryptionScheme: 'pkcs1' })
|
||||
keyRsa.setOptions({ environment: 'browser' })
|
||||
|
||||
if (packet.hasVerifyToken === false) {
|
||||
// 1.19, hasVerifyToken is set and equal to false IF chat signing is enabled
|
||||
// This is the default action starting in 1.19.1.
|
||||
|
@ -117,10 +121,7 @@ module.exports = function (client, server, options) {
|
|||
} else {
|
||||
const encryptedToken = packet.hasVerifyToken ? packet.crypto.verifyToken : packet.verifyToken
|
||||
try {
|
||||
const decryptedToken = crypto.privateDecrypt({
|
||||
key: server.serverKey.exportKey(),
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING
|
||||
}, encryptedToken)
|
||||
const decryptedToken = keyRsa.decrypt(encryptedToken)
|
||||
|
||||
if (!client.verifyToken.equals(decryptedToken)) {
|
||||
client.end('DidNotEncryptVerifyTokenProperly')
|
||||
|
@ -131,13 +132,9 @@ module.exports = function (client, server, options) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
let sharedSecret
|
||||
try {
|
||||
sharedSecret = crypto.privateDecrypt({
|
||||
key: server.serverKey.exportKey(),
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING
|
||||
}, packet.sharedSecret)
|
||||
sharedSecret = keyRsa.decrypt(packet.sharedSecret)
|
||||
} catch (e) {
|
||||
client.end('DidNotEncryptVerifyTokenProperly')
|
||||
return
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
defaultVersion: '1.20.6',
|
||||
supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6']
|
||||
defaultVersion: '1.21.1',
|
||||
supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1']
|
||||
}
|
||||
|
|
|
@ -135,6 +135,9 @@ const values = {
|
|||
delete results['..']
|
||||
return results
|
||||
},
|
||||
vec2f: {
|
||||
x: 0, y: 0
|
||||
},
|
||||
vec3f: {
|
||||
x: 0, y: 0, z: 0
|
||||
},
|
||||
|
@ -153,6 +156,9 @@ const values = {
|
|||
SlotComponent: {
|
||||
type: 'hide_tooltip'
|
||||
},
|
||||
ChatTypes: {
|
||||
registryIndex: 1
|
||||
},
|
||||
SlotComponentType: 0,
|
||||
nbt: nbtValue,
|
||||
optionalNbt: nbtValue,
|
||||
|
|
|
@ -83,7 +83,7 @@ for (const supportedVersion of mc.supportedVersions) {
|
|||
plainMessage: message,
|
||||
signedChatContent: '',
|
||||
unsignedChatContent: JSON.stringify({ text: message }),
|
||||
type: 0,
|
||||
type: mcData.supportFeature('incrementedChatType') ? { registryIndex: 1 } : 0,
|
||||
senderUuid: 'd3527a0b-bc03-45d5-a878-2aafdd8c8a43', // random
|
||||
senderName: JSON.stringify({ text: sender }),
|
||||
senderTeam: undefined,
|
||||
|
|
Loading…
Reference in a new issue