From 7056475e17d463c0be886a8d7bbbfede703a8615 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 7 Oct 2020 23:18:54 +0000 Subject: [PATCH] ensure posts are posts and not other blocks --- hush-hush.js | 6 +++++- powworker.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hush-hush.js b/hush-hush.js index a6b631c..d796cc6 100644 --- a/hush-hush.js +++ b/hush-hush.js @@ -139,7 +139,11 @@ async function findMessages(){ document.getElementById('memUsage').innerText = getReadableFileSizeString(current + ((basicTextEncoder.encode(data)).length + block.length)) } try{ - let metadata = JSON.parse(d.split("\n")[0]) + var metadata = JSON.parse(d.split("\n")[0]) + // Make sure the block is an actual post so nodes can't send us stuff unrelated to dapp + if (JSON.parse(metadata['meta'])['type'] !== 'kic'){ + throw new Error("Not correct block type: " + block) + } } catch(e){ console.debug(e) diff --git a/powworker.js b/powworker.js index 28b2271..d040792 100644 --- a/powworker.js +++ b/powworker.js @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importScripts("onionr-jspow/index.js") +importScripts("jspow/index.js") importScripts("sha3.js") self.addEventListener('message', function(e) {