hushdrop-mcp 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hushdrop-mcp",
3
- "version": "0.3.3",
4
- "description": "Open-source artifact sharing \u2014 publish HTML/Markdown/files as branded, password-protected, zero-knowledge links on your own domain, from any AI agent. CLI + MCP server. The open-source, self-hosted Stacktree alternative.",
3
+ "version": "0.4.0",
4
+ "description": "Turn anything your AI agent builds into a password-locked link: reports, dashboards, prototypes, Markdown or files. MCP server for Claude Code, Cursor, Codex and more.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "hush": "./drop.mjs",
@@ -13,6 +13,10 @@
13
13
  "drop.mjs",
14
14
  "mcp.mjs",
15
15
  "install.mjs",
16
+ "protect.mjs",
17
+ "site.mjs",
18
+ "comment-widget.mjs",
19
+ "read-beacon.mjs",
16
20
  "brand/",
17
21
  "SKILL.md",
18
22
  "SETUP.md"
package/protect.mjs ADDED
@@ -0,0 +1,26 @@
1
+ // View-only mode for a drop (Pro). Deterrents, not DRM: no text selection, no right-click,
2
+ // copy, save, print or view-source shortcuts; the page blurs while the window is in the
3
+ // background (where most capture tools take over), and a tiled watermark carries the
4
+ // viewer's email when the lead gate knows it, otherwise "Confidential". Someone can still
5
+ // photograph the screen; the watermark is what makes a leak traceable.
6
+ // The edge injects it into unlocked drops; the CLI bakes it into locked ones (--protect).
7
+ // Plain inline CSS + JS, fits the drop CSP.
8
+ const esc = (s) => String(s).replace(/[<>&"'\\]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0"));
9
+
10
+ export function protectSnippet(mark = null) {
11
+ const text = esc(mark || "Confidential");
12
+ return `<style id="hd-protect">html,body{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}img,video{-webkit-user-drag:none;pointer-events:none}
13
+ .hd-wm{position:fixed;inset:-50%;z-index:2147483640;pointer-events:none;display:flex;flex-wrap:wrap;align-content:space-around;justify-content:space-around;gap:90px 120px;transform:rotate(-24deg);opacity:.11;font:600 15px system-ui,sans-serif;color:#777;white-space:nowrap}
14
+ .hd-blur body>*:not(.hd-wm){filter:blur(18px)!important}
15
+ @media print{body *{display:none!important}body::after{content:"This page is view-only.";display:block;font:16px system-ui,sans-serif;padding:40px}}</style>
16
+ <script>(function(){var T="${text}",d=document,w=d.createElement("div");w.className="hd-wm";w.setAttribute("aria-hidden","true");
17
+ var t=T+" \\u00b7 "+new Date().toISOString().slice(0,10);for(var i=0;i<120;i++){var s=d.createElement("span");s.textContent=t;w.appendChild(s)}
18
+ function add(){if(d.body&&!d.querySelector(".hd-wm"))d.body.appendChild(w)}add();d.addEventListener("DOMContentLoaded",add);
19
+ ["contextmenu","copy","cut","dragstart","selectstart"].forEach(function(e){d.addEventListener(e,function(ev){ev.preventDefault()},true)});
20
+ d.addEventListener("keydown",function(e){var k=(e.key||"").toLowerCase(),m=e.ctrlKey||e.metaKey;var one=k.length===1;if((m&&one&&"spcu".indexOf(k)>-1)||(m&&e.shiftKey&&one&&"ic45".indexOf(k)>-1)||k==="printscreen"||k==="f12"){e.preventDefault();e.stopPropagation();if(k==="printscreen")try{navigator.clipboard.writeText("")}catch(x){}}},true);
21
+ function blur(on){d.documentElement.classList.toggle("hd-blur",on)}
22
+ window.addEventListener("blur",function(){blur(true)});window.addEventListener("focus",function(){blur(false)});
23
+ d.addEventListener("visibilitychange",function(){blur(d.visibilityState!=="visible")});
24
+ window.addEventListener("beforeprint",function(){blur(true)});window.addEventListener("afterprint",function(){blur(false)});
25
+ })();</script>`;
26
+ }
@@ -0,0 +1,17 @@
1
+ // Reading-depth beacon for hosted drops: visible time on page, furthest scroll %, and
2
+ // which headings the reader scrolled to (or past). Sent with sendBeacon when the page is hidden. No
3
+ // cookies, no ids beyond a random per-view key. The edge injects it into unlocked
4
+ // drops; the CLI bakes it into locked ones before encryption. ASCII-only output.
5
+ export function readBeacon() {
6
+ return `<script>(function(){try{
7
+ var P=location.pathname.split("/").filter(Boolean),D=P.slice(0,2).join("/");if(P.length<2||P[0]==="u")return;
8
+ var id=Math.random().toString(36).slice(2)+Date.now().toString(36),t=0,last=Date.now(),vis=!document.hidden,depth=0,seen=[],done={};
9
+ function tick(){var n=Date.now();if(vis)t+=n-last;last=n}
10
+ var H=null;function heads(){if(!H){H=[].slice.call(document.querySelectorAll("h1,h2,h3,section[id],[data-section]"),0,80)}return H}
11
+ function sc(){var h=document.documentElement,b=document.body,full=Math.max(h.scrollHeight,b?b.scrollHeight:0),v=window.innerHeight,y=window.scrollY||h.scrollTop;var d=full<=v?100:Math.round((y+v)/full*100);if(d>depth)depth=Math.min(100,d);
12
+ heads().forEach(function(el){if(seen.length>=40||el.getBoundingClientRect().top>v)return;var k=(el.textContent||"").trim().replace(/\\s+/g," ").slice(0,60);if(k&&!done[k]){done[k]=1;seen.push(k)}})}
13
+ function send(){tick();sc();if(t<1000)return;var body=JSON.stringify({id:id,s:Math.round(t/1000),d:depth,h:seen});try{navigator.sendBeacon("/api/read?drop="+encodeURIComponent(D),new Blob([body],{type:"text/plain"}))}catch(e){}}
14
+ addEventListener("scroll",sc,{passive:true});document.addEventListener("visibilitychange",function(){tick();vis=!document.hidden;if(document.hidden)send()});addEventListener("pagehide",send);
15
+ if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",sc);else sc()
16
+ }catch(e){}})();</script>`;
17
+ }
package/site.mjs ADDED
@@ -0,0 +1,60 @@
1
+ // Turn a folder OR a .zip into a normalized static-site upload list, and build the
2
+ // PBKDF2 password verifier. No network, no CLI side effects — safe to unit-test.
3
+ import { readFile, readdir, stat } from "node:fs/promises";
4
+ import { join, relative, sep, extname } from "node:path";
5
+
6
+ export const VERIFIER_PARAMS = { algo: "PBKDF2-SHA256", iters: 100000, keylen: 32, saltlen: 16 };
7
+
8
+ const SKIP_DIRS = new Set([".git", "node_modules"]);
9
+
10
+ async function walkDir(dir, base = dir) {
11
+ const out = [];
12
+ for (const e of await readdir(dir, { withFileTypes: true })) {
13
+ if (e.isDirectory()) {
14
+ if (!SKIP_DIRS.has(e.name)) out.push(...(await walkDir(join(dir, e.name), base)));
15
+ } else if (e.isFile() && e.name !== ".hush.json") {
16
+ const abs = join(dir, e.name);
17
+ out.push({ rel: relative(base, abs).split(sep).join("/"), data: await readFile(abs) });
18
+ }
19
+ }
20
+ return out;
21
+ }
22
+
23
+ // loadZip: () => Promise<AdmZipCtor>, injected so the CLI can auto-install adm-zip.
24
+ export async function collectSiteFiles(input, { loadZip = async () => (await import("adm-zip")).default } = {}) {
25
+ const st = await stat(input);
26
+ let files;
27
+ if (st.isDirectory()) {
28
+ files = await walkDir(input);
29
+ } else if (extname(input).toLowerCase() === ".zip") {
30
+ const AdmZip = await loadZip();
31
+ const entries = new AdmZip(input).getEntries().filter((e) => !e.isDirectory);
32
+ const index = entries
33
+ .filter((e) => /(^|\/)index\.html?$/i.test(e.entryName))
34
+ .sort((a, b) => a.entryName.split("/").length - b.entryName.split("/").length)[0];
35
+ const top = index && index.entryName.includes("/")
36
+ ? index.entryName.slice(0, index.entryName.indexOf("/") + 1) : "";
37
+ files = [];
38
+ for (const e of entries) {
39
+ const rel = top && e.entryName.startsWith(top) ? e.entryName.slice(top.length) : e.entryName;
40
+ if (!rel || rel.startsWith("..") || rel === ".hush.json") continue;
41
+ files.push({ rel, data: e.getData() });
42
+ }
43
+ } else {
44
+ throw new Error("not a directory or .zip");
45
+ }
46
+ const idx = files.find((f) => /^index\.html?$/i.test(f.rel));
47
+ if (!idx) throw new Error("no index.html at the site root");
48
+ return { files, indexRel: idx.rel };
49
+ }
50
+
51
+ export async function makeVerifier(password, brand) {
52
+ const enc = new TextEncoder();
53
+ const salt = crypto.getRandomValues(new Uint8Array(VERIFIER_PARAMS.saltlen));
54
+ const key = await crypto.subtle.importKey("raw", enc.encode(String(password)), "PBKDF2", false, ["deriveBits"]);
55
+ const bits = new Uint8Array(await crypto.subtle.deriveBits(
56
+ { name: "PBKDF2", salt, iterations: VERIFIER_PARAMS.iters, hash: "SHA-256" },
57
+ key, VERIFIER_PARAMS.keylen * 8));
58
+ const b64 = (u8) => Buffer.from(u8).toString("base64");
59
+ return { v: 1, algo: VERIFIER_PARAMS.algo, iters: VERIFIER_PARAMS.iters, salt: b64(salt), hash: b64(bits), brand: brand || null };
60
+ }