diff --git a/daemon.py b/daemon.py index 43062572d..6b8c61a40 100644 --- a/daemon.py +++ b/daemon.py @@ -29,6 +29,8 @@ from webfinger import webfingerUpdate from mastoapiv1 import mastoApiV1Response from metadata import metaDataNodeInfo from metadata import metadataCustomEmoji +from enigma import getEnigmaPubKey +from enigma import setEnigmaPubKey from pgp import getEmailAddress from pgp import setEmailAddress from pgp import getPGPpubKey @@ -5379,6 +5381,18 @@ class PubServer(BaseHTTPRequestHandler): setCwtchAddress(actorJson, '') actorChanged = True + # change Enigma public key + currentEnigmaPubKey = getEnigmaPubKey(actorJson) + if fields.get('enigmapubkey'): + if fields['enigmapubkey'] != currentEnigmaPubKey: + setEnigmaPubKey(actorJson, + fields['enigmapubkey']) + actorChanged = True + else: + if currentEnigmaPubKey: + setEnigmaPubKey(actorJson, '') + actorChanged = True + # change PGP public key currentPGPpubKey = getPGPpubKey(actorJson) if fields.get('pgp'): @@ -7039,6 +7053,7 @@ class PubServer(BaseHTTPRequestHandler): isGroup = False donateUrl = None websiteUrl = None + EnigmaPubKey = None PGPpubKey = None PGPfingerprint = None xmppAddress = None @@ -7076,6 +7091,7 @@ class PubServer(BaseHTTPRequestHandler): jamiAddress = getJamiAddress(actorJson) cwtchAddress = getCwtchAddress(actorJson) emailAddress = getEmailAddress(actorJson) + EnigmaPubKey = getEnigmaPubKey(actorJson) PGPpubKey = getPGPpubKey(actorJson) PGPfingerprint = getPGPfingerprint(actorJson) if actorJson.get('alsoKnownAs'): @@ -7110,6 +7126,7 @@ class PubServer(BaseHTTPRequestHandler): ssbAddress, blogAddress, toxAddress, briarAddress, jamiAddress, cwtchAddress, + EnigmaPubKey, PGPpubKey, PGPfingerprint, emailAddress, self.server.dormantMonths, diff --git a/enigma.py b/enigma.py new file mode 100644 index 000000000..ee782719b --- /dev/null +++ b/enigma.py @@ -0,0 +1,74 @@ +__filename__ = "enigma.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.2.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@libreserver.org" +__status__ = "Production" +__module_group__ = "Profile Metadata" + + +def getEnigmaPubKey(actorJson: {}) -> str: + """Returns Enigma public key for the given actor + """ + if not actorJson.get('attachment'): + return '' + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue['name'].lower().startswith('enigma'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue.get('value'): + continue + if propertyValue['type'] != 'PropertyValue': + continue + return propertyValue['value'] + return '' + + +def setEnigmaPubKey(actorJson: {}, enigmaPubKey: str) -> None: + """Sets a Enigma public key for the given actor + """ + removeKey = False + if not enigmaPubKey: + removeKey = True + + if not actorJson.get('attachment'): + actorJson['attachment'] = [] + + # remove any existing value + propertyFound = None + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower().startswith('enigma'): + continue + propertyFound = propertyValue + break + if propertyFound: + actorJson['attachment'].remove(propertyValue) + if removeKey: + return + + for propertyValue in actorJson['attachment']: + if not propertyValue.get('name'): + continue + if not propertyValue.get('type'): + continue + if not propertyValue['name'].lower().startswith('enigma'): + continue + if propertyValue['type'] != 'PropertyValue': + continue + propertyValue['value'] = enigmaPubKey + return + + newenigmaPubKey = { + "name": "Enigma", + "type": "PropertyValue", + "value": enigmaPubKey + } + actorJson['attachment'].append(newenigmaPubKey) diff --git a/translations/ar.json b/translations/ar.json index 939b0004c..ed7d8aeb7 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -500,5 +500,6 @@ "New feed URL": "موجز جديد URL", "New link title and URL": "عنوان الارتباط الجديد وعنوان URL", "Theme Designer": "مصمم المظهر", - "Reset": "إعادة ضبط" + "Reset": "إعادة ضبط", + "Encryption Keys": "مفاتيح التشفير" } diff --git a/translations/ca.json b/translations/ca.json index 97083eb75..1ffae3edb 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -500,5 +500,6 @@ "New feed URL": "URL de feed nou", "New link title and URL": "Títol i URL de l'enllaç nous", "Theme Designer": "Dissenyador temàtic", - "Reset": "Restableix" + "Reset": "Restableix", + "Encryption Keys": "Claus de xifratge" } diff --git a/translations/cy.json b/translations/cy.json index e6059f4db..c40c5f380 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -500,5 +500,6 @@ "New feed URL": "URL porthiant newydd", "New link title and URL": "Teitl dolen ac URL newydd", "Theme Designer": "Dylunydd Thema", - "Reset": "Ail gychwyn" + "Reset": "Ail gychwyn", + "Encryption Keys": "Allweddi Amgryptio" } diff --git a/translations/de.json b/translations/de.json index dbd21fb9e..5061a4b95 100644 --- a/translations/de.json +++ b/translations/de.json @@ -500,5 +500,6 @@ "New feed URL": "Neue Feed-URL", "New link title and URL": "Neuer Linktitel und URL", "Theme Designer": "Themendesigner", - "Reset": "Zurücksetzen" + "Reset": "Zurücksetzen", + "Encryption Keys": "Verschlüsselungsschlüssel" } diff --git a/translations/en.json b/translations/en.json index b670f135b..9f655e1f0 100644 --- a/translations/en.json +++ b/translations/en.json @@ -500,5 +500,6 @@ "New feed URL": "New feed URL", "New link title and URL": "New link title and URL", "Theme Designer": "Theme Designer", - "Reset": "Reset" + "Reset": "Reset", + "Encryption Keys": "Encryption Keys" } diff --git a/translations/es.json b/translations/es.json index a8a793b12..dc9d6c9a5 100644 --- a/translations/es.json +++ b/translations/es.json @@ -500,5 +500,6 @@ "New feed URL": "URL de nuevo feed", "New link title and URL": "Nuevo título de enlace y URL", "Theme Designer": "Diseñadora de temas", - "Reset": "Reiniciar" + "Reset": "Reiniciar", + "Encryption Keys": "Claves de cifrado" } diff --git a/translations/fr.json b/translations/fr.json index 67f351fdb..43811a0fb 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -500,5 +500,6 @@ "New feed URL": "Nouvelle URL de flux", "New link title and URL": "Nouveau titre et URL du lien", "Theme Designer": "Concepteur de thème", - "Reset": "Réinitialiser" + "Reset": "Réinitialiser", + "Encryption Keys": "Clés de cryptage" } diff --git a/translations/ga.json b/translations/ga.json index 6c6068dc1..17bfe2c57 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -500,5 +500,6 @@ "New feed URL": "URL beathaithe nua", "New link title and URL": "Teideal nasc nua agus URL", "Theme Designer": "Dearthóir Téama", - "Reset": "Athshocraigh" + "Reset": "Athshocraigh", + "Encryption Keys": "Eochracha Criptithe" } diff --git a/translations/hi.json b/translations/hi.json index 16cd2920e..e022e00a3 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -500,5 +500,6 @@ "New feed URL": "नया फ़ीड URL", "New link title and URL": "नया लिंक शीर्षक और URL", "Theme Designer": "थीम डिजाइनर", - "Reset": "रीसेट" + "Reset": "रीसेट", + "Encryption Keys": "एन्क्रिप्शन कुंजी" } diff --git a/translations/it.json b/translations/it.json index 39bbeabe3..421cab2d8 100644 --- a/translations/it.json +++ b/translations/it.json @@ -500,5 +500,6 @@ "New feed URL": "Nuovo URL del feed", "New link title and URL": "Nuovo titolo e URL del collegamento", "Theme Designer": "Progettista di temi", - "Reset": "Ripristina" + "Reset": "Ripristina", + "Encryption Keys": "Chiavi di crittografia" } diff --git a/translations/ja.json b/translations/ja.json index c2734f6e4..69afffeca 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -500,5 +500,6 @@ "New feed URL": "新しいフィードURL", "New link title and URL": "新しいリンクのタイトルとURL", "Theme Designer": "テーマデザイナー", - "Reset": "リセット" + "Reset": "リセット", + "Encryption Keys": "暗号化キー" } diff --git a/translations/ku.json b/translations/ku.json index c5b1b5458..bba24d3cb 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -500,5 +500,6 @@ "New feed URL": "URL-ya feed nû", "New link title and URL": "Sernav û URL-ya girêdana nû", "Theme Designer": "Theme Designer", - "Reset": "Reset" + "Reset": "Reset", + "Encryption Keys": "Bişkojkên Şîfrekirinê" } diff --git a/translations/oc.json b/translations/oc.json index 62b17aee9..596f734cc 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -496,5 +496,6 @@ "New feed URL": "New feed URL", "New link title and URL": "New link title and URL", "Theme Designer": "Theme Designer", - "Reset": "Reset" + "Reset": "Reset", + "Encryption Keys": "Encryption Keys" } diff --git a/translations/pt.json b/translations/pt.json index 6c99c9813..ab313aa5e 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -500,5 +500,6 @@ "New feed URL": "Novo URL de feed", "New link title and URL": "Novo título e URL do link", "Theme Designer": "Designer de Tema", - "Reset": "Redefinir" + "Reset": "Redefinir", + "Encryption Keys": "Chaves de criptografia" } diff --git a/translations/ru.json b/translations/ru.json index 6dbd3070b..5067f89d9 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -500,5 +500,6 @@ "New feed URL": "URL нового канала", "New link title and URL": "Новое название ссылки и URL", "Theme Designer": "Дизайнер тем", - "Reset": "Сброс настроек" + "Reset": "Сброс настроек", + "Encryption Keys": "Ключи шифрования" } diff --git a/translations/sw.json b/translations/sw.json index 75bb2aa74..966993c1f 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -500,5 +500,6 @@ "New feed URL": "URL mpya ya mipasho", "New link title and URL": "Kichwa kipya cha kiungo na URL", "Theme Designer": "Mbuni wa Mandhari", - "Reset": "Weka upya" + "Reset": "Weka upya", + "Encryption Keys": "Vifunguo vya Usimbaji" } diff --git a/translations/zh.json b/translations/zh.json index 3e2dfdf13..cc0422b86 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -500,5 +500,6 @@ "New feed URL": "新供稿网址", "New link title and URL": "新链接标题和 URL", "Theme Designer": "主题设计师", - "Reset": "重启" + "Reset": "重启", + "Encryption Keys": "加密密钥" } diff --git a/webapp_person_options.py b/webapp_person_options.py index 0cc572040..6c61c7daa 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -49,6 +49,7 @@ def htmlPersonOptions(defaultTimeline: str, briarAddress: str, jamiAddress: str, cwtchAddress: str, + EnigmaPubKey: str, PGPpubKey: str, PGPfingerprint: str, emailAddress: str, @@ -226,6 +227,9 @@ def htmlPersonOptions(defaultTimeline: str, if cwtchAddress: optionsStr += \ '

Cwtch: ' + removeHtml(cwtchAddress) + '

\n' + if EnigmaPubKey: + optionsStr += \ + '

Enigma: ' + removeHtml(EnigmaPubKey) + '

\n' if PGPfingerprint: optionsStr += '

PGP: ' + \ removeHtml(PGPfingerprint).replace('\n', '
') + '

\n' diff --git a/webapp_profile.py b/webapp_profile.py index 241188ece..9da17967f 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -47,6 +47,7 @@ from ssb import getSSBAddress from pgp import getEmailAddress from pgp import getPGPfingerprint from pgp import getPGPpubKey +from enigma import getEnigmaPubKey from tox import getToxAddress from briar import getBriarAddress from jami import getJamiAddress @@ -631,6 +632,7 @@ def htmlProfile(signingPrivateKeyPem: str, donateUrl = getDonationUrl(profileJson) websiteUrl = getWebsite(profileJson, translate) blogAddress = getBlogAddress(profileJson) + EnigmaPubKey = getEnigmaPubKey(profileJson) PGPpubKey = getPGPpubKey(profileJson) PGPfingerprint = getPGPfingerprint(profileJson) emailAddress = getEmailAddress(profileJson) @@ -643,7 +645,7 @@ def htmlProfile(signingPrivateKeyPem: str, cwtchAddress = getCwtchAddress(profileJson) if donateUrl or websiteUrl or xmppAddress or matrixAddress or \ ssbAddress or toxAddress or briarAddress or \ - jamiAddress or cwtchAddress or PGPpubKey or \ + jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \ PGPfingerprint or emailAddress: donateSection = '
\n' donateSection += '
\n' @@ -696,6 +698,10 @@ def htmlProfile(signingPrivateKeyPem: str, donateSection += \ '

Cwtch:

\n' + if EnigmaPubKey: + donateSection += \ + '

Enigma:

\n' if PGPfingerprint: donateSection += \ '

PGP: ' + \ @@ -1851,8 +1857,6 @@ def _htmlEditProfileContactInfo(nickname: str, briarAddress: str, jamiAddress: str, cwtchAddress: str, - PGPfingerprint: str, - PGPpubKey: str, translate: {}) -> str: """Contact Information section of edit profile screen """ @@ -1869,15 +1873,32 @@ def _htmlEditProfileContactInfo(nickname: str, editProfileForm += editTextField('Briar', 'briarAddress', briarAddress) editProfileForm += editTextField('Jami', 'jamiAddress', jamiAddress) editProfileForm += editTextField('Cwtch', 'cwtchAddress', cwtchAddress) + editProfileForm += \ + '
\n' + + editProfileForm += endEditSection() + return editProfileForm + + +def _htmlEditProfileEncryptionKeys(PGPfingerprint: str, + PGPpubKey: str, + EnigmaPubKey: str, + translate: {}) -> str: + """Contact Information section of edit profile screen + """ + editProfileForm = beginEditSection(translate['Encryption Keys']) + + enigmaUrl = 'https://github.com/enigma-reloaded/enigma-reloaded' + editProfileForm += \ + editTextField('Enigma', + 'enigmapubkey', EnigmaPubKey) editProfileForm += editTextField(translate['PGP Fingerprint'], 'openpgp', PGPfingerprint) editProfileForm += \ editTextArea(translate['PGP'], 'pgp', PGPpubKey, 600, '-----BEGIN PGP PUBLIC KEY BLOCK-----', False) - editProfileForm += \ - '
\n' editProfileForm += endEditSection() return editProfileForm @@ -2079,7 +2100,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, notifyLikes = notifyReactions = '' hideLikeButton = hideReactionButton = mediaInstanceStr = '' blogsInstanceStr = newsInstanceStr = movedTo = twitterStr = '' - bioStr = donateUrl = websiteUrl = emailAddress = PGPpubKey = '' + bioStr = donateUrl = websiteUrl = emailAddress = '' + PGPpubKey = EnigmaPubKey = '' PGPfingerprint = xmppAddress = matrixAddress = '' ssbAddress = blogAddress = toxAddress = jamiAddress = '' cwtchAddress = briarAddress = manuallyApprovesFollowers = '' @@ -2099,6 +2121,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, jamiAddress = getJamiAddress(actorJson) cwtchAddress = getCwtchAddress(actorJson) emailAddress = getEmailAddress(actorJson) + EnigmaPubKey = getEnigmaPubKey(actorJson) PGPpubKey = getPGPpubKey(actorJson) PGPfingerprint = getPGPfingerprint(actorJson) if actorJson.get('name'): @@ -2239,8 +2262,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, xmppAddress, matrixAddress, ssbAddress, toxAddress, briarAddress, jamiAddress, - cwtchAddress, PGPfingerprint, - PGPpubKey, translate) + cwtchAddress, translate) + + # Encryption Keys + editProfileForm += \ + _htmlEditProfileEncryptionKeys(PGPfingerprint, + PGPpubKey, EnigmaPubKey, translate) # Customize images and banners editProfileForm += _htmlEditProfileBackground(newsInstance, translate)