From d42b6fee66d587aba5b2019b2b33f8aaa718722f Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 30 Jun 2020 12:42:47 +0200 Subject: [PATCH] Add support for lobste.rs proofs --- assets/scripts.js | 23 +++++++++++++++++++++++ server/verifyLobsters.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 server/verifyLobsters.php diff --git a/assets/scripts.js b/assets/scripts.js index 4a5918d..45ed3e0 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -413,6 +413,29 @@ async function verifyProof(url, fingerprint) { return output; } } + // Lobsters + if (/^https:\/\/lobste.rs/.test(url)) { + output.type = "lobsters"; + match = url.match(/https:\/\/lobste.rs\/u\/(.*)/); + output.display = match[1]; + output.proofUrlFetch = `/server/verifyLobsters.php?user=${match[1]}&fp=${fingerprint}`; + try { + response = await fetch(output.proofUrlFetch, { + headers: { + Accept: 'application/json' + }, + credentials: 'omit' + }); + if (!response.ok) { + throw new Error('Response failed: ' + response.status); + } + json = await response.json(); + output.isVerified = json.verified; + } catch (e) { + } finally { + return output; + } + } // XMPP if (/^xmpp:/.test(url)) { output.type = "xmpp"; diff --git a/server/verifyLobsters.php b/server/verifyLobsters.php new file mode 100644 index 0000000..96f1212 --- /dev/null +++ b/server/verifyLobsters.php @@ -0,0 +1,29 @@ +