From 448aaf3b4df0c29a1e9677ce9fedfa609e3f3804 Mon Sep 17 00:00:00 2001
From: Yarmo Mackenbach <yarmo@qivro.xyz>
Date: Sat, 18 Jul 2020 20:50:50 +0200
Subject: [PATCH] Add XMPP proofs

---
 assets/scripts.js | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/assets/scripts.js b/assets/scripts.js
index bd400ee..94f5ac1 100644
--- a/assets/scripts.js
+++ b/assets/scripts.js
@@ -537,6 +537,21 @@ async function verifyProof(url, fingerprint) {
         output.type = "xmpp";
         match = url.match(/xmpp:(.*)@(.*)/);
         output.display = `${match[1]}@${match[2]}`;
+        output.proofUrlFetch = `https://xmpp-vcard.keyoxide.org/api/vcard/${output.display}/DESC`;
+        try {
+            response = await fetch(output.proofUrlFetch);
+            if (!response.ok) {
+                throw new Error('Response failed: ' + response.status);
+            }
+            json = await response.json();
+            reVerify = new RegExp(`[Verifying my OpenPGP key: openpgp4fpr:${fingerprint}]`, 'i');
+            if (reVerify.test(json)) {
+                output.isVerified = true;
+            }
+        } catch (e) {
+        } finally {
+            return output;
+        }
     }
     // Catchall
     // Fediverse