-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify-github.js
34 lines (28 loc) · 1.13 KB
/
verify-github.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as puppeteer from "puppeteer";
export const verifyGitHub = async (verificationPackage) => {
const [gitHubAccount, proofUrl, anotherAccount] = verificationPackage;
const [username] = gitHubAccount.split("/");
const [anotherUsername] = anotherAccount.split("/");
if (proofUrl.indexOf("https://github.com") !== 0) {
console.log(`Invalid proof URL for GitHub: "${proofUrl}".`);
return false;
}
console.log(
`Processing connection "${anotherAccount}" <=> "${gitHubAccount}" with proof: ${proofUrl}`
);
console.log(`Browser launching...`);
const browser = await puppeteer.launch({
headless: "new",
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
const page = await browser.newPage();
console.log(`Browser launched.`);
await page.goto(proofUrl, { waitUntil: "networkidle2", timeout: 60000 });
let title = await page.title();
title = title.toLowerCase();
console.log(`Downloaded page "${title}".`);
return (
title.indexOf(username.toLowerCase()) !== -1 &&
title.indexOf(anotherUsername.toLowerCase()) !== -1
);
};