diff --git a/src/app/panel/page.tsx b/src/app/panel/page.tsx index 9e4dae8..ebde6df 100644 --- a/src/app/panel/page.tsx +++ b/src/app/panel/page.tsx @@ -441,6 +441,11 @@ function ConnectBar({ daemon }: { daemon: UseDaemonResult }) { const [urlInput, setUrlInput] = useState("") const [tokenInput, setTokenInput] = useState("") const [copied, setCopied] = useState(false) + const [shareOpen, setShareOpen] = useState(false) + // Opt-in — a copied link with the token embedded grants full access to + // whoever opens it (agentproto/ts#1398: a remote daemon in bearer mode + // requires this exact token on every route), so it defaults off. + const [includeToken, setIncludeToken] = useState(false) const submit = () => { if (!urlInput.trim()) return @@ -450,12 +455,18 @@ function ConnectBar({ daemon }: { daemon: UseDaemonResult }) { setTokenInput("") } - // Shareable deep-link: the tunnel wss origin, no token (auth rides the - // trusted panel Origin). Opening it on another machine auto-connects. + // Shareable deep-link: the fragment form (`#daemon=&token=`) — fragments + // never reach a server (no Referer, no access/proxy log, no CDN cache + // key), unlike the legacy `?daemon=&token=` query-string form this panel + // still accepts for back-compat. The token is only embedded when + // `includeToken` is explicitly checked; without it, whoever opens the + // link still needs to paste the token in themselves via "connect ▾". const shareLink = (): string => { if (typeof window === "undefined" || !daemon.url) return "" const wss = daemon.url.replace(/^http/, "ws") - return `${window.location.origin}/panel?daemon=${encodeURIComponent(wss)}` + const params = new URLSearchParams({ daemon: wss }) + if (includeToken && daemon.token) params.set("token", daemon.token) + return `${window.location.origin}/panel#${params.toString()}` } const copyLink = async () => { @@ -464,6 +475,7 @@ function ConnectBar({ daemon }: { daemon: UseDaemonResult }) { try { await navigator.clipboard.writeText(link) setCopied(true) + setShareOpen(false) setTimeout(() => setCopied(false), 1500) } catch { /* clipboard blocked — ignore */ @@ -535,9 +547,67 @@ function ConnectBar({ daemon }: { daemon: UseDaemonResult }) { )} {daemon.remote && ( - +
+ + {shareOpen && ( +
+ +
+ {daemon.token + ? includeToken + ? "Anyone with this link gets full access to this daemon — share it only with someone you trust." + : "Without the token, whoever opens this link must paste it in themselves via “connect”." + : "This connection has no token to embed."} +
+ +
+ )} +
)} {daemon.remote && (