From d070ed0864a89e5d377793a66093de6685e9b9fc Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Wed, 22 Jul 2020 14:34:52 +0200 Subject: [PATCH] Reorder XMPP proof --- assets/scripts.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/assets/scripts.js b/assets/scripts.js index bf3574b..e022f74 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -386,6 +386,29 @@ async function verifyProof(url, fingerprint) { return output; } } + // XMPP + if (/^xmpp:/.test(url)) { + output.type = "xmpp"; + console.log(url); + match = url.match(/xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/); + console.log(match); + output.display = `${match[1]}@${match[2]}`; + output.proofUrl = `https://xmpp-vcard.keyoxide.org/api/vcard/${output.display}/DESC`; + try { + response = await fetch(output.proofUrl); + 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; + } + } // Twitter if (/^https:\/\/twitter.com/.test(url)) { output.type = "twitter"; @@ -532,29 +555,6 @@ async function verifyProof(url, fingerprint) { return output; } } - // XMPP - if (/^xmpp:/.test(url)) { - output.type = "xmpp"; - console.log(url); - match = url.match(/xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/); - console.log(match); - output.display = `${match[1]}@${match[2]}`; - output.proofUrl = `https://xmpp-vcard.keyoxide.org/api/vcard/${output.display}/DESC`; - try { - response = await fetch(output.proofUrl); - 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 try {