diff --git a/flake.nix b/flake.nix index b4909ff..59cf751 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,6 @@ text = '' set -euo pipefail export npm_config_cache="$PWD/.npm-cache" - [ -f .env ] && set -a && . ./.env && set +a if [ -f package-lock.json ]; then cmd=ci; else cmd=install; fi echo "→ npm $cmd (nix run)" ${node}/bin/npm "$cmd" diff --git a/src/ts/Redaction/Redactor.ts b/src/ts/Redaction/Redactor.ts index 5fa2381..cfbfcbb 100644 --- a/src/ts/Redaction/Redactor.ts +++ b/src/ts/Redaction/Redactor.ts @@ -1,21 +1,30 @@ -import PocketBase from "pocketbase"; import { parseProfile, type Profile } from "./Profile"; -const PUBLIC_POCKET_URL = "https://pocket.deprived.dev/"; - -let pb = new PocketBase(PUBLIC_POCKET_URL); class Redactor { async TryGetUnredacter(): Promise { - const url = - 'https://pocket.deprived.dev/api/collections/redacted_content/records?page=1&perPage=1&filter=plain_id="redacted_json"&skipTotal=1'; + const key = localStorage.getItem("key"); + if (!key) throw new Error("Missing key"); + + const hashResJson = await ( + await fetch("http://api.deprived.dev/unredact", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ key: "balls" }), + }) + ).json(); + + const unredactHash = hashResJson.response; + console.log('Trying unredact hash: "' + unredactHash + '"'); + + const url = `https://pocket.deprived.dev/api/files/redacted_content/${unredactHash}/redacted_cv_info_ha08bbn520.json`; + const res = await fetch(url, { - body: localStorage.getItem("key"), method: "GET", + headers: { Accept: "application/json" }, }); + if (!res.ok) throw new Error(`HTTP ${res.status}`); - console.log(res); const data = await res.json(); - console.log(data); const item = data?.items?.[0]; const raw = JSON.parse(item.file); return parseProfile(raw);