From 06048fe442dc68fc2acbf61d4343680efd8a854a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 5 Feb 2019 17:20:36 -0600 Subject: [PATCH] added signature validity display to web ui mail --- onionr/api.py | 6 ++++++ onionr/static-data/www/mail/index.html | 4 +++- onionr/static-data/www/mail/mail.js | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/onionr/api.py b/onionr/api.py index 69f775c7..54adbc47 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -498,6 +498,12 @@ class API: except AttributeError: pass else: + validSig = False + signer = self._core._utils.bytesToStr(bl.signer) + print(signer, bl.isSigned(), self._core._utils.validatePubKey(signer), bl.isSigner(signer)) + if bl.isSigned() and self._core._utils.validatePubKey(signer) and bl.isSigner(signer): + validSig = True + bl.bheader['validSig'] = validSig bl.bheader['meta'] = '' retData = {'meta': bl.bheader, 'metadata': bl.bmetadata} return json.dumps(retData) diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index dd48b4f3..18b2ddfc 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -27,8 +27,10 @@
-
From: +
+ From:
+
diff --git a/onionr/static-data/www/mail/mail.js b/onionr/static-data/www/mail/mail.js index d39c0380..fa6a87f0 100755 --- a/onionr/static-data/www/mail/mail.js +++ b/onionr/static-data/www/mail/mail.js @@ -63,10 +63,22 @@ function loadInboxEntrys(bHash){ var senderInput = document.createElement('input') var subjectLine = document.createElement('span') var dateStr = document.createElement('span') + var validSig = document.createElement('span') var humanDate = new Date(0) var metadata = resp['metadata'] humanDate.setUTCSeconds(resp['meta']['time']) senderInput.value = httpGet('/getHumanReadable/' + resp['meta']['signer']) + alert(resp['meta']['validSig']) + if (resp['meta']['validSig']){ + validSig.innerText = 'Signature Validity: Good' + } + else{ + validSig.innerText = 'Signature Validity: Bad' + validSig.style.color = 'red'; + } + if (senderInput.value == ''){ + senderInput.value = 'Anonymous' + } bHashDisplay.innerText = bHash.substring(0, 10) entry.setAttribute('hash', bHash); senderInput.readOnly = true @@ -81,6 +93,7 @@ function loadInboxEntrys(bHash){ threadPart.appendChild(entry) entry.appendChild(bHashDisplay) entry.appendChild(senderInput) + entry.appendChild(validSig) entry.appendChild(subjectLine) entry.appendChild(dateStr) entry.classList.add('threadEntry')