Reorder XMPP proof

This commit is contained in:
Yarmo Mackenbach 2020-07-22 14:34:52 +02:00
parent 922738238b
commit d070ed0864

View file

@ -386,6 +386,29 @@ async function verifyProof(url, fingerprint) {
return output; 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 // Twitter
if (/^https:\/\/twitter.com/.test(url)) { if (/^https:\/\/twitter.com/.test(url)) {
output.type = "twitter"; output.type = "twitter";
@ -532,29 +555,6 @@ async function verifyProof(url, fingerprint) {
return output; 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 // Catchall
// Fediverse // Fediverse
try { try {