mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
Verify Twitter without an API key
This commit is contained in:
parent
1758ee90f8
commit
f5cc278363
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,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