From d88dee9a834483036a3d4664e2851dabca281fbc Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 10 Dec 2018 17:47:47 +0100 Subject: [PATCH 1/4] Restrict sending messages in a pad chat to editors only --- www/common/common-hash.js | 1 + www/common/common-messenger.js | 58 +++++++++++++++++++++++++-------- www/common/outer/async-store.js | 3 ++ www/common/outer/cursor.js | 3 +- www/common/sframe-common.js | 7 ++-- www/common/toolbar3.js | 2 +- www/contacts/messenger-ui.js | 7 ++-- 7 files changed, 59 insertions(+), 22 deletions(-) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index d5066b757..e089852cc 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -12,6 +12,7 @@ define([ var hexToBase64 = Util.hexToBase64; var base64ToHex = Util.base64ToHex; Hash.encodeBase64 = Nacl.util.encodeBase64; + Hash.decodeBase64 = Nacl.util.decodeBase64; // This implementation must match that on the server // it's used for a checksum diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 081cd311f..b400d1dae 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -26,6 +26,15 @@ define([ return JSON.parse(JSON.stringify(o)); }; + var convertToUint8 = function (obj) { + var l = Object.keys(obj).length; + var u = new Uint8Array(l); + for (var i = 0; i Date: Tue, 11 Dec 2018 10:52:11 +0100 Subject: [PATCH 2/4] Delete validateKey in the messenger memory when we leave the channel --- www/common/common-messenger.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index b400d1dae..f6c69f677 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -959,6 +959,7 @@ define([ messenger.leavePad = function (padChan) { // Leave chat and prevent reconnect when we leave a pad + delete validateKeys[padchan]; Object.keys(channels).some(function (chatChan) { var channel = channels[chatChan]; if (channel.padChan !== padChan) { return; } From fb5ad34299b3260346c52fdf98435698ea980ad8 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 11 Dec 2018 10:57:43 +0100 Subject: [PATCH 3/4] Fix typo... --- www/common/common-messenger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index f6c69f677..b8ea783a5 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -959,7 +959,7 @@ define([ messenger.leavePad = function (padChan) { // Leave chat and prevent reconnect when we leave a pad - delete validateKeys[padchan]; + delete validateKeys[padChan]; Object.keys(channels).some(function (chatChan) { var channel = channels[chatChan]; if (channel.padChan !== padChan) { return; } From 489a99c5c46ae83f9fb9a75e514c3176d332e8fc Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 11 Dec 2018 13:35:00 +0100 Subject: [PATCH 4/4] Don't delete the old chat for now --- www/common/sframe-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 0d631edb7..3c5d47c52 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -173,7 +173,7 @@ define([ }; funcs.openPadChat = function (saveChanges) { var md = JSON.parse(JSON.stringify(ctx.metadataMgr.getMetadata())); - if (md.chat) { delete md.chat; } // Old channel without signing key + //if (md.chat) { delete md.chat; } // Old channel without signing key var channel = md.chat2 || Hash.createChannelId(); if (!md.chat2) { md.chat2 = channel;