From 3f27bc8c9f87436c4c1a1aab98ee32f3d8eec09f Mon Sep 17 00:00:00 2001 From: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:04:01 +0000 Subject: [PATCH 1/4] Add a failing test --- tests/browser/02_ops.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/browser/02_ops.js b/tests/browser/02_ops.js index d0b89c3e2..09d6b77d1 100644 --- a/tests/browser/02_ops.js +++ b/tests/browser/02_ops.js @@ -206,6 +206,7 @@ module.exports = { testOpHtml(browser, "Index of Coincidence", "test input", "", /Index of Coincidence: 0.08333333333333333/); testOpImage(browser, "Invert Image", "files/Hitchhikers_Guide.jpeg"); // testOp(browser, "JPath expression", "test input", "test_output"); + testOp(browser, "Jq", "{a:1}", "1", [".a"]); testOpHtml(browser, "JSON Beautify", "{a:1}", ".json-dict .json-literal", "1"); // testOp(browser, "JSON Minify", "test input", "test_output"); // testOp(browser, "JSON to CSV", "test input", "test_output"); From 36b562578d8a8dd2928fbd5c69e1cc57e24f6ae8 Mon Sep 17 00:00:00 2001 From: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:19:51 +0000 Subject: [PATCH 2/4] Modify input/output to make Jq test pass in older versions, and add an "Avro to JSON" test --- tests/browser/02_ops.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/browser/02_ops.js b/tests/browser/02_ops.js index 09d6b77d1..dde84f682 100644 --- a/tests/browser/02_ops.js +++ b/tests/browser/02_ops.js @@ -50,6 +50,14 @@ module.exports = { testOp(browser, "Analyse hash", "0123456789abcdef", /CRC-64/); testOp(browser, "Atbash Cipher", "test input", "gvhg rmkfg"); // testOp(browser, "Avro to JSON", "test input", "test_output"); + testOp(browser, + [ + "From Hex", "Avro to JSON" + ], + "4f626a0104166176726f2e736368656d6196017b2274797065223a227265636f7264222c226e616d65223a22736d616c6c222c226669656c6473223a5b7b226e616d65223a226e616d65222c2274797065223a22737472696e67227d5d7d146176726f2e636f646563086e756c6c004e0247632e3702e5b75cdab9a62f1541020e0c6d796e616d654e0247632e3702e5b75cdab9a62f1541", + '{"name":"myname"}\n', + [[], [false]] + ); testOp(browser, "BLAKE2b", "test input", "33ebdc8f38177f3f3f334eeb117a84e11f061bbca4db6b8923e5cec85103f59f415551a5d5a933fdb6305dc7bf84671c2540b463dbfa08ee1895cfaa5bd780b5", ["512", "Hex", { "option": "UTF8", "string": "pass" }]); testOp(browser, "BLAKE2s", "test input", "defe73d61dfa6e5807e4f9643e159a09ccda6be3c26dcd65f8a9bb38bfc973a7", ["256", "Hex", { "option": "UTF8", "string": "pass" }]); testOp(browser, "BSON deserialise", "\u0011\u0000\u0000\u0000\u0002a\u0000\u0005\u0000\u0000\u0000test\u0000\u0000", '{\u000A "a": "test"\u000A}'); @@ -206,7 +214,7 @@ module.exports = { testOpHtml(browser, "Index of Coincidence", "test input", "", /Index of Coincidence: 0.08333333333333333/); testOpImage(browser, "Invert Image", "files/Hitchhikers_Guide.jpeg"); // testOp(browser, "JPath expression", "test input", "test_output"); - testOp(browser, "Jq", "{a:1}", "1", [".a"]); + testOp(browser, "Jq", '{"a":{"b":1}}', '{"b":1}', [".a"]); testOpHtml(browser, "JSON Beautify", "{a:1}", ".json-dict .json-literal", "1"); // testOp(browser, "JSON Minify", "test input", "test_output"); // testOp(browser, "JSON to CSV", "test input", "test_output"); From 056b3183b95cfbb6e3f937883b6fce80811a7eb7 Mon Sep 17 00:00:00 2001 From: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:57:52 +0000 Subject: [PATCH 3/4] Revert jq-web to 0.5.1 to fix #2209 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index a6cd3a5af..4b0a74d8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,7 @@ "highlight.js": "^11.11.1", "ieee754": "^1.2.1", "jimp": "^1.6.0", - "jq-web": "^0.6.2", + "jq-web": "^0.5.1", "jquery": "3.7.1", "js-sha3": "^0.9.3", "jsesc": "^3.1.0", @@ -12240,9 +12240,9 @@ "license": "BSD-3-Clause" }, "node_modules/jq-web": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.6.2.tgz", - "integrity": "sha512-+7XvjBYwTx4vP5PYkf6Q6orubO/v+UgMU6By1GritrmShr9QpT3UKa4ANzXWQfhdqtBnQYXsm7ZNbdIHT6tYpQ==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.5.1.tgz", + "integrity": "sha512-3Fa3E6g3U1O1j46ljy0EM10yRr4txzILga8J7bqOG8F89gZ6Lilz82WG9z6TItWpYEO0YGa4W8yFGj+NMM1xqQ==", "license": "ISC" }, "node_modules/jquery": { diff --git a/package.json b/package.json index b3d695eae..fbdade45a 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "highlight.js": "^11.11.1", "ieee754": "^1.2.1", "jimp": "^1.6.0", - "jq-web": "^0.6.2", + "jq-web": "^0.5.1", "jquery": "3.7.1", "js-sha3": "^0.9.3", "jsesc": "^3.1.0", From f4ca59dcdcfd5dc5fa0e270850b172eaca7f8aba Mon Sep 17 00:00:00 2001 From: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> Date: Fri, 13 Mar 2026 16:07:00 +0000 Subject: [PATCH 4/4] Revert "fix: `jq-web` -> `jq-wasm`, includes `jq` version `1.8.1` (#2223)" This reverts commit 0c6454e10cea224f48d263bd4c22fb2d83db714d. --- package-lock.json | 6 ------ package.json | 1 - src/core/operations/Jq.mjs | 21 +++++++++++---------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 073fd5e16..b4b293e2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,6 @@ "ieee754": "^1.2.1", "jimp": "^1.6.0", "jq-web": "^0.5.1", - "jq-wasm": "^1.1.0-jq-1.8.1", "jquery": "3.7.1", "js-sha3": "^0.9.3", "jsesc": "^3.1.0", @@ -12164,11 +12163,6 @@ "resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.5.1.tgz", "integrity": "sha512-3Fa3E6g3U1O1j46ljy0EM10yRr4txzILga8J7bqOG8F89gZ6Lilz82WG9z6TItWpYEO0YGa4W8yFGj+NMM1xqQ==", "license": "ISC" - "node_modules/jq-wasm": { - "version": "1.1.0-jq-1.8.1", - "resolved": "https://registry.npmjs.org/jq-wasm/-/jq-wasm-1.1.0-jq-1.8.1.tgz", - "integrity": "sha512-lWfu34lpDFIygOYcL5TzxhZIApDR9iR5XywcVoyUAZ6jlQrj8HKHOKeCcHgUm2dE9RVdbP3eqNAKGLuj+k4seQ==", - "license": "MIT" }, "node_modules/jquery": { "version": "3.7.1", diff --git a/package.json b/package.json index c34432d10..2948556e8 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,6 @@ "ieee754": "^1.2.1", "jimp": "^1.6.0", "jq-web": "^0.5.1", - "jq-wasm": "^1.1.0-jq-1.8.1", "jquery": "3.7.1", "js-sha3": "^0.9.3", "jsesc": "^3.1.0", diff --git a/src/core/operations/Jq.mjs b/src/core/operations/Jq.mjs index 4584d1a98..c1e02b34b 100644 --- a/src/core/operations/Jq.mjs +++ b/src/core/operations/Jq.mjs @@ -6,7 +6,7 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import * as jq from "jq-wasm"; +import jq from "jq-web"; /** * jq operation @@ -40,15 +40,16 @@ class Jq extends Operation { * @returns {string} */ run(input, args) { - return (async () => { - const [query] = args; - try { - const result = await jq.json(input, query); - return JSON.stringify(result); - } catch (err) { - throw new OperationError(`Invalid jq expression: ${err.message}`); - } - })(); + const [query] = args; + let result; + + try { + result = jq.json(input, query); + } catch (err) { + throw new OperationError(`Invalid jq expression: ${err.message}`); + } + + return JSON.stringify(result); } }