Post-migration edits

pull/9/head
Matteo Cargnelutti 2022-11-22 14:35:18 -05:00
rodzic 39e704b557
commit aaeb7f523d
7 zmienionych plików z 9 dodań i 93 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ jobs:
build:
runs-on: ubuntu-20.04
# don't run on pushes to forks
if: github.repository == 'harvard-lil/archive.social'
if: github.repository == 'harvard-lil/thread-keeper'
steps:
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

Wyświetl plik

@ -64,11 +64,11 @@ checkPdfDialog.querySelector("button").addEventListener("click", async(e) => {
switch (response.status) {
case 200:
output.value += `This hash is CONFIRMED to be present in archive.social's logs.\n`;
output.value += `This hash is CONFIRMED to be present in the logs.\n`;
break;
case 404:
output.value += `This hash was NOT FOUND in archive.social's logs.\n`;
output.value += `This hash was NOT FOUND in the logs.\n`;
break;
default:

Wyświetl plik

@ -42,87 +42,3 @@ if (formErrorDialog) {
formErrorDialog.close();
})
}
//------------------------------------------------------------------------------
// "check-pdf" dialog logic
//------------------------------------------------------------------------------
const checkPdfDialog = document.querySelector("dialog#check-pdf");
// Open / close based on hash
window.addEventListener('hashchange', (event) => {
const newURL = new URL(event.newURL);
const oldURL = new URL(event.oldURL);
if (newURL.hash === "#check-pdf") {
checkPdfDialog.showModal();
}
if (oldURL.hash === "#check-pdf" && oldURL !== newURL) {
checkPdfDialog.close();
}
});
// Open on load if hash already present
if (window.location.hash === "#check-pdf") {
checkPdfDialog.showModal();
}
// Clear output on file change
checkPdfDialog.querySelector("input").addEventListener("change", () => {
checkPdfDialog.querySelector("textarea").value = `Click on "Check" to proceed.\n`;
});
// Check file on click on "Check"
checkPdfDialog.querySelector("button").addEventListener("click", async(e) => {
let hash = "";
const output = checkPdfDialog.querySelector("textarea");
output.value = "";
try {
const data = await checkPdfDialog.querySelector("input[type='file']").files[0].arrayBuffer();
// Generate hash and convert it to hex and then base 64.
// Was of tremendous help: https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript
hash = await (async() => {
const hash = await crypto.subtle.digest('SHA-512', data);
const walkable = Array.from(new Uint8Array(hash));
const toHex = walkable.map((b) => b.toString(16).padStart(2, "0")).join("");
return btoa(
toHex
.match(/\w{2}/g)
.map(function (a) {
return String.fromCharCode(parseInt(a, 16));
})
.join("")
);
})();
}
catch(err) {
output.value = `Could not calculate hash of the file selected, if any.\n`;
}
try {
const response = await fetch(`/api/v1/hashes/check/${encodeURIComponent(hash)}`);
output.value += `SHA-512 hash\n---${hash}\n---\n`;
switch (response.status) {
case 200:
output.value += `This hash is CONFIRMED to be present in archive.social's logs.\n`;
break;
case 404:
output.value += `This hash was NOT FOUND in archive.social's logs.\n`;
break;
default:
throw new Error(response.status);
break;
}
}
catch(err) {
console.log(`/api/v1/hashes/check/<hash> responded with HTTP ${err}`);
output.value += `An error occurred while trying to verify file.`;
}
});

Wyświetl plik

@ -150,10 +150,10 @@ export class TwitterCapture {
// Remove extraneous page, add metadata
try {
editablePDF.setTitle(`Capture of ${this.url} by archive.social on ${new Date().toISOString()}`);
editablePDF.setTitle(`Capture of ${this.url} by thread-keeper on ${new Date().toISOString()}`);
editablePDF.setCreationDate(new Date());
editablePDF.setModificationDate(new Date());
editablePDF.setProducer("archive.social");
editablePDF.setProducer("thread-keeper");
editablePDF.removePage(1);
}
catch {

4
package-lock.json wygenerowano
Wyświetl plik

@ -1,11 +1,11 @@
{
"name": "archive.social",
"name": "thread-keeper",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "archive.social",
"name": "thread-keeper",
"version": "0.0.1",
"hasInstallScript": true,
"license": "ISC",

Wyświetl plik

@ -79,7 +79,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/harvard-lil/archive.social.git"
"url": "git+https://github.com/harvard-lil/thread-keeper.git"
},
"author": "",
"license": "ISC",

Wyświetl plik

@ -1,3 +1,3 @@
# [DEV ONLY] Generates a local key pair that can be used for signing PDFs.
# Will be saved under ../app/certs.
openssl req -x509 -newkey rsa:4096 -keyout ../certs/key.pem -out ../certs/cert.pem -days 3650 -nodes -subj /CN="archive.social DEV";
openssl req -x509 -newkey rsa:4096 -keyout ../certs/key.pem -out ../certs/cert.pem -days 3650 -nodes -subj /CN="thread-keeper DEV";