Added dev.to identity proof

This commit is contained in:
Yarmo Mackenbach 2020-07-16 12:42:09 +02:00
parent 8debc6de92
commit e50a137f89
2 changed files with 24 additions and 0 deletions

View file

@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.2.1] - 2020-07-16 ## [0.2.1] - 2020-07-16
### Added
- dev.to identity proof
### Fixed ### Fixed
- Make www optional for reddit regex - Make www optional for reddit regex

View file

@ -433,6 +433,28 @@ async function verifyProof(url, fingerprint) {
return output; 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 // Reddit
if (/^https:\/\/(?:www\.)?reddit\.com\/user/.test(url)) { if (/^https:\/\/(?:www\.)?reddit\.com\/user/.test(url)) {
output.type = "reddit"; output.type = "reddit";