redacted my info, into my database #1
2 changed files with 18 additions and 10 deletions
|
|
@ -19,7 +19,6 @@
|
||||||
text = ''
|
text = ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export npm_config_cache="$PWD/.npm-cache"
|
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
|
if [ -f package-lock.json ]; then cmd=ci; else cmd=install; fi
|
||||||
echo "→ npm $cmd (nix run)"
|
echo "→ npm $cmd (nix run)"
|
||||||
${node}/bin/npm "$cmd"
|
${node}/bin/npm "$cmd"
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,30 @@
|
||||||
import PocketBase from "pocketbase";
|
|
||||||
import { parseProfile, type Profile } from "./Profile";
|
import { parseProfile, type Profile } from "./Profile";
|
||||||
const PUBLIC_POCKET_URL = "https://pocket.deprived.dev/";
|
|
||||||
|
|
||||||
let pb = new PocketBase(PUBLIC_POCKET_URL);
|
|
||||||
|
|
||||||
class Redactor {
|
class Redactor {
|
||||||
async TryGetUnredacter(): Promise<Profile> {
|
async TryGetUnredacter(): Promise<Profile> {
|
||||||
const url =
|
const key = localStorage.getItem("key");
|
||||||
'https://pocket.deprived.dev/api/collections/redacted_content/records?page=1&perPage=1&filter=plain_id="redacted_json"&skipTotal=1';
|
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, {
|
const res = await fetch(url, {
|
||||||
body: localStorage.getItem("key"),
|
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
headers: { Accept: "application/json" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
console.log(res);
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
console.log(data);
|
|
||||||
const item = data?.items?.[0];
|
const item = data?.items?.[0];
|
||||||
const raw = JSON.parse(item.file);
|
const raw = JSON.parse(item.file);
|
||||||
return parseProfile(raw);
|
return parseProfile(raw);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue