mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-23 07:19:28 -07:00
Merge pull request 'Verify Twitter without an API key' (#25) from Supernova/fork-keyoxide:v2verifyTweet into dev
Reviewed-on: https://codeberg.org/keyoxide/web/pulls/25
This commit is contained in:
commit
fb080a7de9
3 changed files with 8 additions and 1 deletions
|
@ -64,6 +64,7 @@ router.get('/verify/proxy', [
|
||||||
|
|
||||||
router.get('/verify/twitter', [
|
router.get('/verify/twitter', [
|
||||||
query('tweetId').isInt().exists(),
|
query('tweetId').isInt().exists(),
|
||||||
|
query('account').exists(),
|
||||||
query('fingerprint').isHexadecimal().exists()
|
query('fingerprint').isHexadecimal().exists()
|
||||||
], async function(req, res) {
|
], async function(req, res) {
|
||||||
const errors = validationResult(req);
|
const errors = validationResult(req);
|
||||||
|
@ -73,6 +74,7 @@ router.get('/verify/twitter', [
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
tweetId: req.query.tweetId,
|
tweetId: req.query.tweetId,
|
||||||
|
account: req.query.account,
|
||||||
fingerprint: req.query.fingerprint
|
fingerprint: req.query.fingerprint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,11 @@ const Twitter = async (params) => {
|
||||||
|
|
||||||
let twitter_api_auth = process.env.TWITTER_API_AUTH;
|
let twitter_api_auth = process.env.TWITTER_API_AUTH;
|
||||||
if (!twitter_api_auth) {
|
if (!twitter_api_auth) {
|
||||||
res.errors.push("No Twitter API auth token provided");
|
let proofUrl = `https://mobile.twitter.com/${res.params.account}/status/${res.params.tweetId}`;
|
||||||
|
let re = new RegExp(`[Verifying my OpenPGP key: openpgp4fpr:${res.params.fingerprint}]`, "gi");
|
||||||
|
const get = bent('GET');
|
||||||
|
const obj = await get(proofUrl);
|
||||||
|
res.isVerified = re.test(obj.data);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -484,6 +484,7 @@ async function verifyProof(url, fingerprint) {
|
||||||
output.url = `https://twitter.com/${match[1]}`;
|
output.url = `https://twitter.com/${match[1]}`;
|
||||||
output.proofUrlFetch = `/server/verify/twitter
|
output.proofUrlFetch = `/server/verify/twitter
|
||||||
?tweetId=${encodeURIComponent(match[2])}
|
?tweetId=${encodeURIComponent(match[2])}
|
||||||
|
&account=${encodeURIComponent(match[1])}
|
||||||
&fingerprint=${fingerprint}`;
|
&fingerprint=${fingerprint}`;
|
||||||
try {
|
try {
|
||||||
response = await fetch(output.proofUrlFetch);
|
response = await fetch(output.proofUrlFetch);
|
||||||
|
|
Loading…
Reference in a new issue