forked from Mirrors/keyoxide-web
Implement first GitLab proof logic
I've just hacked up a simple solution for GitLab proof. It's using a project (repository) as a proof method since it's the easiest to do with api. It's a very hacky solution and it relies on GitLab being able to find the project using search.
This commit is contained in:
parent
5dc8e85d02
commit
5df81166ed
1 changed files with 31 additions and 0 deletions
|
@ -615,6 +615,37 @@ async function verifyProof(url, fingerprint) {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// GitLab
|
||||||
|
if (/^https:\/\/gitlab.com/.test(url)) {
|
||||||
|
output.type = "gitlab";
|
||||||
|
match = url.match(/https:\/\/gitlab.com\/(.*)\/(.*)/);
|
||||||
|
output.display = match[1];
|
||||||
|
output.url = `https://gitlab.com/${match[1]}`;
|
||||||
|
output.proofUrlFetch = `https://gitlab.com/api/v4/projects?custom_attributes[search]=${match[1]}/${match[2]}&custom_attributes[search_namespaces]=true`;
|
||||||
|
try {
|
||||||
|
response = await fetch(output.proofUrlFetch, {
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json'
|
||||||
|
},
|
||||||
|
credentials: 'omit'
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Response failed: ' + response.status);
|
||||||
|
}
|
||||||
|
json = await response.json();
|
||||||
|
let project = json.find(proj => proj.web_url === url);
|
||||||
|
if (!project) {
|
||||||
|
throw new Error('No project at ' + url);
|
||||||
|
}
|
||||||
|
reVerify = new RegExp(`[Verifying my OpenPGP key: openpgp4fpr:${fingerprint}]`, 'i');
|
||||||
|
if (reVerify.test(project.descroption)) {
|
||||||
|
output.isVerified = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
} finally {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Lobsters
|
// Lobsters
|
||||||
if (/^https:\/\/lobste.rs/.test(url)) {
|
if (/^https:\/\/lobste.rs/.test(url)) {
|
||||||
output.type = "lobsters";
|
output.type = "lobsters";
|
||||||
|
|
Loading…
Reference in a new issue