From dfc28173a54e7375c48e01be7033d9ff0020fcbb Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Wed, 1 Mar 2023 18:20:45 +0100 Subject: [PATCH] feat: Make ENCRYPT and VERIFY buttons optional For now, these functions will be hardcoded off until a decent opt-in solution is found. --- src/routes/profile.js | 44 ++++++++++++++++++++++++++----- views/profile.pug | 60 ++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 33 deletions(-) diff --git a/src/routes/profile.js b/src/routes/profile.js index b4e0049..c7040d4 100644 --- a/src/routes/profile.js +++ b/src/routes/profile.js @@ -42,42 +42,74 @@ router.post('/sig', bodyParser, async (req, res) => { const data = await generateSignatureProfile(req.body.signature) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data, isSignature: true, signature: req.body.signature }) + res.render('profile', { + title, + data, + isSignature: true, + signature: req.body.signature, + enable_message_encryption: false, + enable_signature_verification: false + }) }) router.get('/wkd/:id', async (req, res) => { const data = await generateWKDProfile(req.params.id) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data }) + res.render('profile', { + title, + data, + enable_message_encryption: false, + enable_signature_verification: false + }) }) router.get('/hkp/:id', async (req, res) => { const data = await generateHKPProfile(req.params.id) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data }) + res.render('profile', { + title, + data, + enable_message_encryption: false, + enable_signature_verification: false + }) }) router.get('/hkp/:server/:id', async (req, res) => { const data = await generateHKPProfile(req.params.id, req.params.server) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data }) + res.render('profile', { + title, + data, + enable_message_encryption: false, + enable_signature_verification: false + }) }) router.get('/keybase/:username/:fingerprint', async (req, res) => { const data = await generateKeybaseProfile(req.params.username, req.params.fingerprint) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data }) + res.render('profile', { + title, + data, + enable_message_encryption: false, + enable_signature_verification: false + }) }) router.get('/:id', async (req, res) => { const data = await generateAutoProfile(req.params.id) const title = utils.generatePageTitle('profile', data) res.set('ariadne-identity-proof', data.keyData.openpgp4fpr) - res.render('profile', { title, data }) + res.render('profile', { + title, + data, + enable_message_encryption: false, + enable_signature_verification: false + }) }) export default router diff --git a/views/profile.pug b/views/profile.pug index dfd89ef..64e4fcc 100644 --- a/views/profile.pug +++ b/views/profile.pug @@ -62,31 +62,33 @@ block content noscript p Keyoxide requires JavaScript to function. - dialog#dialog--encryptMessage - div - form(method='post') - label(for="encryptionInput") Message to encrypt - textarea#encryptionInput.input(name='message') - input.no-margin(type='submit' name='submit' value='ENCRYPT MESSAGE') - br - br - label(for="encryptionOutput") Encryption result - textarea#encryptionOutput.output(name='message' placeholder='Waiting for input' readonly) - form(method="dialog") - input(type="submit" value="Close") + if (enable_message_encryption) + dialog#dialog--encryptMessage + div + form(method='post') + label(for="encryptionInput") Message to encrypt + textarea#encryptionInput.input(name='message') + input.no-margin(type='submit' name='submit' value='ENCRYPT MESSAGE') + br + br + label(for="encryptionOutput") Encryption result + textarea#encryptionOutput.output(name='message' placeholder='Waiting for input' readonly) + form(method="dialog") + input(type="submit" value="Close") - dialog#dialog--verifySignature - div - form(method='post') - label(for="sigVerInput") Signature - textarea#sigVerInput.input(name='signature') - input.no-margin(type='submit' name='submit' value='VERIFY SIGNATURE') - br - br - label(for="sigVerOutput") Verification result - textarea#sigVerOutput.output(name='message' placeholder='Waiting for input' readonly) - form(method="dialog") - input(type="submit" value="Close") + if (enable_signature_verification) + dialog#dialog--verifySignature + div + form(method='post') + label(for="sigVerInput") Signature + textarea#sigVerInput.input(name='signature') + input.no-margin(type='submit' name='submit' value='VERIFY SIGNATURE') + br + br + label(for="sigVerOutput") Verification result + textarea#sigVerOutput.output(name='message' placeholder='Waiting for input' readonly) + form(method="dialog") + input(type="submit" value="Close") dialog#dialog--qr div @@ -109,9 +111,13 @@ block content img#profileAvatar.u-logo(src=data.extra.avatarURL alt="avatar") p#profileName.p-name= data.keyData.users[data.keyData.primaryUserIndex].userData.name - .button-wrapper - button(onClick="document.querySelector('#dialog--encryptMessage').showModal();") Encrypt message - button(onClick="document.querySelector('#dialog--verifySignature').showModal();") Verify signature + + if (enable_message_encryption || enable_signature_verification) + .button-wrapper + if (enable_message_encryption) + button(onClick="document.querySelector('#dialog--encryptMessage').showModal();") Encrypt message + if (enable_signature_verification) + button(onClick="document.querySelector('#dialog--verifySignature').showModal();") Verify signature #profileProofs.card.card--transparent h2 Key