1
1
diff --git a/src/client/chat.js b/src/client/chat.js
2
- index 8d0869b150681574ad19292a026cce9f67a137ee..2efa2e6600f017b566155974cb9fb1856fa582f9 100644
2
+ index a50f4b988ad9fb29d5eb9e1633b498615aa9cd28..b8b819eef0762a77d9db5c0fb06be648303628c7 100644
3
3
--- a/src/client/chat.js
4
4
+++ b/src/client/chat.js
5
- @@ -109 ,7 +109 ,7 @@ module.exports = function (client, options) {
5
+ @@ -110 ,7 +110 ,7 @@ module.exports = function (client, options) {
6
6
for (const player of packet.data) {
7
7
if (player.chatSession) {
8
8
client._players[player.uuid] = {
@@ -11,43 +11,43 @@ index 8d0869b150681574ad19292a026cce9f67a137ee..2efa2e6600f017b566155974cb9fb185
11
11
publicKeyDER: player.chatSession.publicKey.keyBytes,
12
12
sessionUuid: player.chatSession.uuid
13
13
}
14
- @@ -119 ,7 +119 ,7 @@ module.exports = function (client, options) {
15
-
14
+ @@ -120 ,7 +120 ,7 @@ module.exports = function (client, options) {
15
+
16
16
if (player.crypto) {
17
17
client._players[player.uuid] = {
18
18
- publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
19
19
+ // publicKey: crypto.createPublicKey({ key: player.crypto.publicKey, format: 'der', type: 'spki' }),
20
20
publicKeyDER: player.crypto.publicKey,
21
21
signature: player.crypto.signature,
22
22
displayName: player.displayName || player.name
23
- @@ -189 ,7 +189 ,7 @@ module.exports = function (client, options) {
23
+ @@ -190 ,7 +190 ,7 @@ module.exports = function (client, options) {
24
24
if (mcData.supportFeature('useChatSessions')) {
25
25
const tsDelta = BigInt(Date.now()) - packet.timestamp
26
26
const expired = !packet.timestamp || tsDelta > messageExpireTime || tsDelta < 0
27
27
- const verified = !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
28
28
+ const verified = false && !packet.unsignedChatContent && updateAndValidateSession(packet.senderUuid, packet.plainMessage, packet.signature, packet.index, packet.previousMessages, packet.salt, packet.timestamp) && !expired
29
29
if (verified) client._signatureCache.push(packet.signature)
30
30
client.emit('playerChat', {
31
- plainMessage : packet.plainMessage ,
32
- @@ -354 ,7 +354 ,7 @@ module.exports = function (client, options) {
31
+ globalIndex : packet.globalIndex ,
32
+ @@ -356 ,7 +356 ,7 @@ module.exports = function (client, options) {
33
33
}
34
34
}
35
-
35
+
36
36
- client._signedChat = (message, options = {}) => {
37
37
+ client._signedChat = async (message, options = {}) => {
38
38
options.timestamp = options.timestamp || BigInt(Date.now())
39
39
options.salt = options.salt || 1n
40
-
41
- @@ -396 ,7 +396 ,7 @@ module.exports = function (client, options) {
40
+
41
+ @@ -401 ,7 +401 ,7 @@ module.exports = function (client, options) {
42
42
message,
43
43
timestamp: options.timestamp,
44
44
salt: options.salt,
45
45
- signature: (client.profileKeys && client._session) ? client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
46
46
+ signature: (client.profileKeys && client._session) ? await client.signMessage(message, options.timestamp, options.salt, undefined, acknowledgements) : undefined,
47
47
offset: client._lastSeenMessages.pending,
48
+ checksum: computeChatChecksum(client._lastSeenMessages), // 1.21.5+
48
49
acknowledged
49
- })
50
- @@ -410,7 +410,7 @@ module.exports = function (client, options) {
50
+ @@ -416,7 +416,7 @@ module.exports = function (client, options) {
51
51
message,
52
52
timestamp: options.timestamp,
53
53
salt: options.salt,
@@ -57,7 +57,7 @@ index 8d0869b150681574ad19292a026cce9f67a137ee..2efa2e6600f017b566155974cb9fb185
57
57
previousMessages: client._lastSeenMessages.map((e) => ({
58
58
messageSender: e.sender,
59
59
diff --git a/src/client/encrypt.js b/src/client/encrypt.js
60
- index b9d21bab9faccd5dbf1975fc423fc55c73e906c5..99ffd76527b410e3a393181beb260108f4c63536 100644
60
+ index 63cc2bd9615100bd2fd63dfe14c094aa6b8cd1c9..36df57d1196af9761d920fa285ac48f85410eaef 100644
61
61
--- a/src/client/encrypt.js
62
62
+++ b/src/client/encrypt.js
63
63
@@ -25,7 +25,11 @@ module.exports = function (client, options) {
@@ -71,7 +71,7 @@ index b9d21bab9faccd5dbf1975fc423fc55c73e906c5..99ffd76527b410e3a393181beb260108
71
71
+ // clearTimeout(loginTimeout)
72
72
+ // })
73
73
}
74
-
74
+
75
75
function onJoinServerResponse (err) {
76
76
diff --git a/src/client/play.js b/src/client/play.js
77
77
index 559607f34e9a5b2b7809423f8ca4cd6746b60225..4dc1c3139438cc2729b05c57e57bd00252728f8a 100644
@@ -87,27 +87,10 @@ index 559607f34e9a5b2b7809423f8ca4cd6746b60225..4dc1c3139438cc2729b05c57e57bd002
87
87
})
88
88
// Server should send finish_configuration on its own right after sending the client a dimension codec
89
89
diff --git a/src/client.js b/src/client.js
90
- index 5c7a62b013daa69be91ec9e763b1f48ffe96ffa6..174d42a77740a937afcb106e1f39a9ee824a24b9 100644
90
+ index e369e77d055ba919e8f9da7b8e8b5dc879c74cf4..11c6bff299f1186ab1ecb6744f53ff0c648ab192 100644
91
91
--- a/src/client.js
92
92
+++ b/src/client.js
93
- @@ -89,10 +89,12 @@ class Client extends EventEmitter {
94
- parsed.metadata.name = parsed.data.name
95
- parsed.data = parsed.data.params
96
- parsed.metadata.state = state
97
- - debug('read packet ' + state + '.' + parsed.metadata.name)
98
- - if (debug.enabled) {
99
- - const s = JSON.stringify(parsed.data, null, 2)
100
- - debug(s && s.length > 10000 ? parsed.data : s)
101
- + if (!globalThis.excludeCommunicationDebugEvents?.includes(parsed.metadata.name)) {
102
- + debug('read packet ' + state + '.' + parsed.metadata.name)
103
- + if (debug.enabled) {
104
- + const s = JSON.stringify(parsed.data, null, 2)
105
- + debug(s && s.length > 10000 ? parsed.data : s)
106
- + }
107
- }
108
- if (this._hasBundlePacket && parsed.metadata.name === 'bundle_delimiter') {
109
- if (this._mcBundle.length) { // End bundle
110
- @@ -110,7 +112,13 @@ class Client extends EventEmitter {
93
+ @@ -111,7 +111,13 @@ class Client extends EventEmitter {
111
94
this._hasBundlePacket = false
112
95
}
113
96
} else {
@@ -122,9 +105,9 @@ index 5c7a62b013daa69be91ec9e763b1f48ffe96ffa6..174d42a77740a937afcb106e1f39a9ee
122
105
}
123
106
})
124
107
}
125
- @@ -168 ,7 +176 ,10 @@ class Client extends EventEmitter {
108
+ @@ -169 ,7 +175 ,10 @@ class Client extends EventEmitter {
126
109
}
127
-
110
+
128
111
const onFatalError = (err) => {
129
112
- this.emit('error', err)
130
113
+ // todo find out what is trying to write after client disconnect
@@ -133,8 +116,8 @@ index 5c7a62b013daa69be91ec9e763b1f48ffe96ffa6..174d42a77740a937afcb106e1f39a9ee
133
116
+ }
134
117
endSocket()
135
118
}
136
-
137
- @@ -197 ,6 +208 ,8 @@ class Client extends EventEmitter {
119
+
120
+ @@ -198 ,6 +207 ,8 @@ class Client extends EventEmitter {
138
121
serializer -> framer -> socket -> splitter -> deserializer */
139
122
if (this.serializer) {
140
123
this.serializer.end()
@@ -143,17 +126,48 @@ index 5c7a62b013daa69be91ec9e763b1f48ffe96ffa6..174d42a77740a937afcb106e1f39a9ee
143
126
} else {
144
127
if (this.socket) this.socket.end()
145
128
}
146
- @@ -238,8 +251,11 @@ class Client extends EventEmitter {
147
-
148
- write (name, params) {
149
- if (!this.serializer.writable) { return }
150
- - debug('writing packet ' + this.state + '.' + name)
151
- - debug(params)
152
- + if (!globalThis.excludeCommunicationDebugEvents?.includes(name)) {
153
- + debug(`[${this.state}] from ${this.isServer ? 'server' : 'client'}: ` + name)
154
- + debug(params)
155
- + }
129
+ @@ -243,6 +254,7 @@ class Client extends EventEmitter {
130
+ debug('writing packet ' + this.state + '.' + name)
131
+ debug(params)
132
+ }
156
133
+ this.emit('writePacket', name, params)
157
134
this.serializer.write({ name, params })
158
135
}
159
-
136
+
137
+ diff --git a/src/client.js.rej b/src/client.js.rej
138
+ new file mode 100644
139
+ index 0000000000000000000000000000000000000000..1101e2477adfdc004381b78e7d70953dacb7b484
140
+ --- /dev/null
141
+ +++ b/src/client.js.rej
142
+ @@ -0,0 +1,31 @@
143
+ + @@ -89,10 +89,12 @@
144
+ + parsed.metadata.name = parsed.data.name
145
+ + parsed.data = parsed.data.params
146
+ + parsed.metadata.state = state
147
+ + - debug('read packet ' + state + '.' + parsed.metadata.name)
148
+ + - if (debug.enabled) {
149
+ + - const s = JSON.stringify(parsed.data, null, 2)
150
+ + - debug(s && s.length > 10000 ? parsed.data : s)
151
+ + + if (!globalThis.excludeCommunicationDebugEvents?.includes(parsed.metadata.name)) {
152
+ + + debug('read packet ' + state + '.' + parsed.metadata.name)
153
+ + + if (debug.enabled) {
154
+ + + const s = JSON.stringify(parsed.data, null, 2)
155
+ + + debug(s && s.length > 10000 ? parsed.data : s)
156
+ + + }
157
+ + }
158
+ + if (this._hasBundlePacket && parsed.metadata.name === 'bundle_delimiter') {
159
+ + if (this._mcBundle.length) { // End bundle
160
+ + @@ -239,8 +252,11 @@
161
+ +
162
+ + write (name, params) {
163
+ + if (!this.serializer.writable) { return }
164
+ + - debug('writing packet ' + this.state + '.' + name)
165
+ + - debug(params)
166
+ + + if (!globalThis.excludeCommunicationDebugEvents?.includes(name)) {
167
+ + + debug(`[${this.state}] from ${this.isServer ? 'server' : 'client'}: ` + name)
168
+ + + debug(params)
169
+ + + }
170
+ + + this.emit('writePacket', name, params)
171
+ + this.serializer.write({ name, params })
172
+ + }
173
+ +
0 commit comments