From e50a137f8913a98daccf3ab23c33c7091935f66a Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 16 Jul 2020 12:42:09 +0200 Subject: [PATCH] Added dev.to identity proof --- CHANGELOG.md | 2 ++ assets/scripts.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63936f1..f131985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [0.2.1] - 2020-07-16 +### Added +- dev.to identity proof ### Fixed - Make www optional for reddit regex diff --git a/assets/scripts.js b/assets/scripts.js index ee2e5d7..4674b64 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -433,6 +433,28 @@ async function verifyProof(url, fingerprint) { return output; } } + // dev.to + if (/^https:\/\/dev\.to\//.test(url)) { + output.type = "dev.to"; + match = url.match(/https:\/\/dev\.to\/(.*)\/(.*)/); + output.display = match[1]; + output.url = `https://dev.to/${match[1]}`; + output.proofUrlFetch = `https://dev.to/api/articles/${match[1]}/${match[2]}`; + 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.body_markdown)) { + output.isVerified = true; + } + } catch (e) { + } finally { + return output; + } + } // Reddit if (/^https:\/\/(?:www\.)?reddit\.com\/user/.test(url)) { output.type = "reddit";