From b66c9aa08052859fb2e3075a3d6c6f84a84e77f1 Mon Sep 17 00:00:00 2001 From: SuperGamerTron <45374546+SuperGamerTron@users.noreply.github.com> Date: Wed, 25 Mar 2026 13:51:27 -0600 Subject: [PATCH 1/7] Backport velocity field changes from 1.21.9+ to older versions (#1467) * Add vec3i16 type to packetTest.js * Update ci.yml * Update ci.yml Removed outdated command to clone minecraft-data repository. --------- Co-authored-by: extremeheat --- test/packetTest.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/packetTest.js b/test/packetTest.js index d4074f66..a5d7e918 100644 --- a/test/packetTest.js +++ b/test/packetTest.js @@ -232,6 +232,9 @@ const values = { vec3i: { x: 0, y: 0, z: 0 }, + vec3i16: { + x: 0, y: 0, z: 0 + }, count: 1, // TODO : might want to set this to a correct value bool: true, f64: 99999.2222, From a6ffb34dd706d5f5aad15e333afee3eaab385a9a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:52:55 +0000 Subject: [PATCH 2/7] Release 1.64.1 --- docs/HISTORY.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.md b/docs/HISTORY.md index 6bb8a1fa..a2f0913c 100644 --- a/docs/HISTORY.md +++ b/docs/HISTORY.md @@ -1,5 +1,8 @@ # History +## 1.64.1 +* [Backport velocity field changes from 1.21.9+ to older versions (#1467)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/b66c9aa08052859fb2e3075a3d6c6f84a84e77f1) (thanks @SuperGamerTron) + ## 1.64.0 * [🎈 1.21.11 (#1457)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/77f4167d93a70322f2963c3c81586c8fe0c6c299) (thanks @rom1504bot) diff --git a/package.json b/package.json index f93c3183..c01362e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-protocol", - "version": "1.64.0", + "version": "1.64.1", "description": "Parse and serialize minecraft packets, plus authentication and encryption.", "main": "src/index.js", "types": "src/index.d.ts", From f87f9d5b35888be3bccece3edf5761183cf916a4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 28 Mar 2026 10:02:06 -0700 Subject: [PATCH 3/7] Switch to trusted publishing via OIDC (#1471) - Add id-token: write permission for OIDC trusted publishing - Use Node 24 (ships npm 11.11.0, trusted publishing requires >=11.5.1) - Add registry-url for OIDC auth flow - Upgrade JS-DevTools/npm-publish from v1 to v4 - Remove NPM_AUTH_TOKEN (no longer needed) Co-authored-by: rom1504 Co-authored-by: Claude Opus 4.6 (1M context) --- .github/workflows/npm-publish.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f5e18ab9..9137536b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -3,6 +3,9 @@ on: push: branches: - master # Change this to your default branch +permissions: + id-token: write + contents: write jobs: npm-publish: name: npm-publish @@ -13,11 +16,10 @@ jobs: - name: Set up Node.js uses: actions/setup-node@master with: - node-version: 22.0.0 + node-version: 24 + registry-url: 'https://registry.npmjs.org' - id: publish - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_AUTH_TOKEN }} + uses: JS-DevTools/npm-publish@v4 - name: Create Release if: steps.publish.outputs.type != 'none' id: create_release From 9bc871da00a82058ad68f7fb6fd661c268f6a7a9 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 28 Mar 2026 10:20:32 -0700 Subject: [PATCH 4/7] Fix publish condition for npm-publish v4 (#1472) npm-publish v4 outputs empty string (not 'none') when version is unchanged. The old condition != 'none' was always true, causing Create Release to run and fail on every non-release commit. Co-authored-by: rom1504 Co-authored-by: Claude Opus 4.6 (1M context) --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 9137536b..e694d60c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -21,7 +21,7 @@ jobs: - id: publish uses: JS-DevTools/npm-publish@v4 - name: Create Release - if: steps.publish.outputs.type != 'none' + if: ${{ steps.publish.outputs.type }} id: create_release uses: actions/create-release@v1 env: From 8008fe065787d50c7ab490cb0a503cb9200043fe Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sun, 29 Mar 2026 17:42:28 -0700 Subject: [PATCH 5/7] Update CI to Node 24 (#1473) Co-authored-by: rom1504 Co-authored-by: Claude Opus 4.6 (1M context) --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 408636fc..fa9c970a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js 22.x + - name: Use Node.js 24.x uses: actions/setup-node@v1.4.4 with: - node-version: 22.x + node-version: 24.x - run: npm i && npm run lint PrepareSupportedVersions: runs-on: ubuntu-latest @@ -25,10 +25,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 22.x + - name: Use Node.js 24.x uses: actions/setup-node@v1.4.4 with: - node-version: 22.x + node-version: 24.x - id: set-matrix run: | node -e " @@ -44,10 +44,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 22.x + - name: Use Node.js 24.x uses: actions/setup-node@v1 with: - node-version: 22.x + node-version: 24.x - name: Setup Java JDK uses: actions/setup-java@v1.4.3 with: From dfecf1e9e449ed1d75d14f7fd146257edf0a207e Mon Sep 17 00:00:00 2001 From: rom1504bot Date: Mon, 30 Mar 2026 03:01:41 +0200 Subject: [PATCH 6/7] Release 1.65.0 (#1474) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- docs/HISTORY.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.md b/docs/HISTORY.md index a2f0913c..151647c3 100644 --- a/docs/HISTORY.md +++ b/docs/HISTORY.md @@ -1,5 +1,10 @@ # History +## 1.65.0 +* [Update CI to Node 24 (#1473)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/8008fe065787d50c7ab490cb0a503cb9200043fe) (thanks @rom1504) +* [Fix publish condition for npm-publish v4 (#1472)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/9bc871da00a82058ad68f7fb6fd661c268f6a7a9) (thanks @rom1504) +* [Switch to trusted publishing via OIDC (#1471)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/f87f9d5b35888be3bccece3edf5761183cf916a4) (thanks @rom1504) + ## 1.64.1 * [Backport velocity field changes from 1.21.9+ to older versions (#1467)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/b66c9aa08052859fb2e3075a3d6c6f84a84e77f1) (thanks @SuperGamerTron) diff --git a/package.json b/package.json index c01362e1..acb2b5aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-protocol", - "version": "1.64.1", + "version": "1.65.0", "description": "Parse and serialize minecraft packets, plus authentication and encryption.", "main": "src/index.js", "types": "src/index.d.ts", From b11d122a920f1eb1a53fa0f89ce829c16d60a6be Mon Sep 17 00:00:00 2001 From: Mik <29287456+Mikulasz12@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:31:59 +0100 Subject: [PATCH 7/7] Add 26.1 compatibility support --- package.json | 4 +-- src/client/chat.js | 32 +++++++++++++------- test/declareCommandsTest.js | 58 +++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 test/declareCommandsTest.js diff --git a/package.json b/package.json index acb2b5aa..5a00ce54 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,11 @@ "debug": "^4.3.2", "endian-toggle": "^0.0.0", "lodash.merge": "^4.3.0", - "minecraft-data": "^3.78.0", + "minecraft-data": "^3.109.0", "minecraft-folder-path": "^1.2.0", "node-fetch": "^2.6.1", "node-rsa": "^0.4.2", - "prismarine-auth": "^2.2.0", + "prismarine-auth": "^3.1.1", "prismarine-chat": "^1.10.0", "prismarine-nbt": "^2.5.0", "prismarine-realms": "^1.2.0", diff --git a/src/client/chat.js b/src/client/chat.js index 00218709..9327f3ef 100644 --- a/src/client/chat.js +++ b/src/client/chat.js @@ -302,20 +302,30 @@ module.exports = function (client, options) { const sliceIndexForMessage = {} client.on('declare_commands', (packet) => { + // Defensive guard: command data comes from the network and may be malformed or partially decoded. + if (!Array.isArray(packet?.nodes) || !Array.isArray(packet.nodes[0]?.children)) { + return + } + const nodes = packet.nodes + function visit (node, commandName, depth = 0) { + if (!node || !node.extraNodeData) return + + const { name, parser } = node.extraNodeData + if (parser === 'minecraft:message') { + sliceIndexForMessage[commandName] = [name, depth] + } + + for (const childIndex of node.children || []) { + visit(nodes[childIndex], commandName, depth + 1) + } + } + for (const commandNode of nodes[0].children) { const node = nodes[commandNode] - const commandName = node.extraNodeData.name - function visit (node, depth = 0) { - const name = node.extraNodeData.name - if (node.extraNodeData.parser === 'minecraft:message') { - sliceIndexForMessage[commandName] = [name, depth] - } - for (const child of node.children) { - visit(nodes[child], depth + 1) - } - } - visit(node, 0) + const commandName = node?.extraNodeData?.name + if (!commandName) continue + visit(node, commandName, 0) } }) diff --git a/test/declareCommandsTest.js b/test/declareCommandsTest.js new file mode 100644 index 00000000..ddba6172 --- /dev/null +++ b/test/declareCommandsTest.js @@ -0,0 +1,58 @@ +/* eslint-env mocha */ + +const assert = require('assert') +const EventEmitter = require('events') +const minecraftDataPath = require.resolve('minecraft-data') +const injectChatPlugin = require('../src/client/chat') + +describe('declare_commands handling', () => { + let originalMinecraftData + + beforeEach(() => { + originalMinecraftData = require.cache[minecraftDataPath]?.exports + require.cache[minecraftDataPath] = { + exports: () => ({ + supportFeature (feature) { + return feature === 'useChatSessions' || feature === 'seperateSignedChatCommandPacket' + } + }) + } + }) + + afterEach(() => { + if (originalMinecraftData) { + require.cache[minecraftDataPath] = { exports: originalMinecraftData } + } else { + delete require.cache[minecraftDataPath] + } + }) + + it('tracks message arguments from structured declare_commands nodes', () => { + const client = new EventEmitter() + client.version = '26.1' + client.verifyMessage = () => true + client.profileKeys = true + client._session = { uuid: '00000000-0000-0000-0000-000000000000' } + + const writes = [] + client.write = (name, data) => writes.push({ name, data }) + + injectChatPlugin(client, {}) + client.signMessage = () => Buffer.from([1]) + + client.emit('declare_commands', { + nodes: [ + { children: [1] }, + { children: [2], extraNodeData: { name: 'msg' } }, + { children: [], extraNodeData: { name: 'message', parser: 'minecraft:message' } } + ] + }) + + client._signedChat('/msg hello there', { timestamp: 1n, salt: 1n }) + + assert.strictEqual(writes.length, 1) + assert.strictEqual(writes[0].name, 'chat_command_signed') + assert.deepStrictEqual(writes[0].data.argumentSignatures.map(sig => sig.argumentName), ['message']) + }) + +})