File size: 3,265 Bytes
9e0adec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>GHOST DROP</title>
<style>
body{margin:0;background:#05070d;color:#e8f0ff;font:16px system-ui;padding:16px;max-width:640px;margin:auto}
h1{letter-spacing:3px;font-size:20px}textarea{width:100%;height:140px;box-sizing:border-box;background:#0b1222;color:#fff;border:1px solid #2b3d63;border-radius:10px;padding:10px;font-size:16px}
input[type=range]{width:100%;accent-color:#ff3b3b}.ends{display:flex;justify-content:space-between;font-size:12px;opacity:.7}
#lvl{text-align:center;font-weight:700;margin:6px 0 14px}
button{width:100%;padding:14px;font-size:17px;border:0;border-radius:10px;margin:6px 0;cursor:pointer}
#go{background:#2e7dff;color:#fff}#kill{background:#ff3b3b;color:#fff}
#out{word-break:break-all;background:#0b1222;padding:10px;border-radius:10px;margin-top:10px;font-size:13px}
#out a{color:#7fc4ff}
</style></head><body>
<h1>👻 GHOST DROP</h1>
<textarea id="msg" placeholder="what are you sending?"></textarea>
<div class="ends"><span>🚀 FULL SEND</span><span>👻 FULL GHOST</span></div>
<input id="s" type="range" min="0" max="7" value="3">
<div id="lvl"></div>
<button id="go">Make mirror link</button>
<button id="kill">👻 Ghost it now</button>
<div id="out">Nothing sent yet.</div>
<script>
const L=[["Full send · never expires",0,0],["30 days",2592000,0],["7 days",604800,0],["1 day",86400,0],["1 hour",3600,0],["10 minutes",600,0],["1 minute",60,0],["Full ghost · one look, then gone",0,1]];
const s=document.getElementById('s'),lvl=document.getElementById('lvl');
const show=()=>lvl.textContent=L[s.value][0];s.oninput=show;show();
const b64=u=>btoa(String.fromCharCode(...new Uint8Array(u))).replace(/\+/g,'-').replace(/\//g,'_').replace(/=+$/,'');
const unb=t=>Uint8Array.from(atob(t.replace(/-/g,'+').replace(/_/g,'/')+'==='.slice((t.length+3)%4)),c=>c.charCodeAt(0));
let last=null;
document.getElementById('go').onclick=async()=>{
 const m=document.getElementById('msg').value;if(!m)return;
 const [,ttl,burn]=L[s.value];
 const r=await (await fetch('../api/key',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({ttl,burn:!!burn})})).json();
 const k=await crypto.subtle.importKey('raw',(await crypto.subtle.digest('SHA-256',unb(r.key))),'AES-GCM',false,['encrypt']);
 const iv=crypto.getRandomValues(new Uint8Array(12));
 const ct=await crypto.subtle.encrypt({name:'AES-GCM',iv},k,new TextEncoder().encode(m));
 const link=location.origin+'/drop/view.html#'+r.id+'.'+b64(iv)+'.'+b64(ct);
 last=r;localStorage.setItem('ghost_'+r.id,r.owner);
 document.getElementById('out').innerHTML=`<b>${L[s.value][0]}</b><br><a href="${link}" target=_blank>${link}</a><br><small>The message rides in the link, locked. The key stays here. Ghost it and every copy goes dead.</small>`;
 navigator.clipboard&&navigator.clipboard.writeText(link);
};
document.getElementById('kill').onclick=async()=>{
 if(!last)return alert('Nothing to ghost on this device yet.');
 const r=await fetch(`../api/key/${last.id}?owner=${last.owner}`,{method:'DELETE'});
 document.getElementById('out').innerHTML=r.ok?'👻 Ghosted. That link is dead everywhere.':'Already gone.';
};
</script></body></html>