diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b51b82..d49c629 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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' diff --git a/app/static/check.js b/app/static/check.js index 1ffedfe..824ef91 100644 --- a/app/static/check.js +++ b/app/static/check.js @@ -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: diff --git a/app/static/index.js b/app/static/index.js index f2507eb..576c26e 100644 --- a/app/static/index.js +++ b/app/static/index.js @@ -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/ responded with HTTP ${err}`); - output.value += `An error occurred while trying to verify file.`; - } -}); diff --git a/app/utils/TwitterCapture.js b/app/utils/TwitterCapture.js index f94ee2b..e33fc54 100644 --- a/app/utils/TwitterCapture.js +++ b/app/utils/TwitterCapture.js @@ -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 { diff --git a/package-lock.json b/package-lock.json index 7f9f074..f8e808a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 255b3e5..c04d8e8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/generate-dev-cert.sh b/scripts/generate-dev-cert.sh index 6b3ae0f..9fce46a 100755 --- a/scripts/generate-dev-cert.sh +++ b/scripts/generate-dev-cert.sh @@ -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"; \ No newline at end of file +openssl req -x509 -newkey rsa:4096 -keyout ../certs/key.pem -out ../certs/cert.pem -days 3650 -nodes -subj /CN="thread-keeper DEV"; \ No newline at end of file