diff --git a/README.md b/README.md index 358c715..4e21359 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ Skip the connect dialog entirely and drop visitors straight into a TeamSpeak ser Add a `connect` parameter to your instance's URL and send that link out — in a Discord post, a landing page button, a QR code, wherever: ``` -https://your-instance/?connect=voice.example.com&nickname=Guest&channel=Lobby&token=abc123 +https://your-instance/?connect=voice.example.com&nickname=Guest&channel=Lobby#token=abc123 ``` | Parameter | Required | What it does | @@ -301,7 +301,7 @@ https://your-instance/?connect=voice.example.com&nickname=Guest&channel=Lobby&to | `connect` | yes | Server address to join, `host` or `host:port` | | `nickname` | no | Nickname to connect with — omit it and the visitor gets an auto-generated `Guest-XXXX` | | `channel` | no | Default channel to join | -| `token` | no | Server/channel privilege key, if the target requires one | +| `token` | no | Server/channel privilege key, if the target requires one. Put it after `#` (as above) so it never reaches server logs or `Referer` headers; `?token=` still works too | This works on **any** deployment — no rebuild, no configuration. WebSpeak3 connects as soon as the page loads and immediately strips these parameters from the address bar, so refreshing the tab (or someone screenshotting/forwarding the URL later) won't silently reconnect off a stale link. diff --git a/web/src/App.tsx b/web/src/App.tsx index 5aa226f..01692f0 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -137,17 +137,25 @@ const IS_OWN_HOSTED_INSTANCE = !DEMO_MODE && OWN_HOSTED_HOSTNAMES.has(window.loc // reconnect off a stale link sitting in the address bar or browser history. const AUTO_CONNECT_FROM_URL = (() => { const params = new URLSearchParams(window.location.search); + // The token may also sit in the fragment (#token=...), which - unlike the + // query - never reaches server logs or Referer headers. + const hashParams = new URLSearchParams(window.location.hash.slice(1)); const connectHost = params.get("connect"); if (!connectHost) return null; const target = { host: connectHost, nickname: params.get("nickname") || undefined, defaultChannel: params.get("channel") || undefined, - privilegeKey: params.get("token") || undefined, + privilegeKey: hashParams.get("token") || params.get("token") || undefined, }; for (const key of ["connect", "nickname", "channel", "token"]) params.delete(key); + let hash = window.location.hash; + if (hashParams.has("token")) { + hashParams.delete("token"); + hash = hashParams.size ? `#${hashParams}` : ""; + } const rest = params.toString(); - window.history.replaceState(null, "", window.location.pathname + (rest ? `?${rest}` : "") + window.location.hash); + window.history.replaceState(null, "", window.location.pathname + (rest ? `?${rest}` : "") + hash); return target; })(); @@ -184,7 +192,9 @@ function hasAcceptedToS(): boolean { const LAST_HOST_KEY = "webspeak3:last-host"; const LAST_NICKNAME_KEY = "webspeak3:last-nickname"; -const LAST_PRIVILEGE_KEY = "webspeak3:last-privilege-key"; +// Privilege keys are one-shot grants, so they're no longer remembered across +// reloads; drop what older versions stored in plain text. +localStorage.removeItem("webspeak3:last-privilege-key"); const LAST_SERVER_TYPE_KEY = "webspeak3:last-server-type"; type ServerType = "teamspeak" | "teaspeak" | "auto"; @@ -715,15 +725,19 @@ function triggerBrowserDownload(filename: string, base64Data: string): void { const binary = atob(base64Data); const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i); - const blob = new Blob([bytes]); + downloadBlob(new Blob([bytes]), filename); +} + +function downloadBlob(blob: Blob, filename: string) { const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); + a.remove(); + // Revoking right after click() can cancel the download in some browsers. + setTimeout(() => URL.revokeObjectURL(url), 60_000); } function formatDurationSecs(totalSeconds: number): string { @@ -874,7 +888,6 @@ function ChannelTree({ onSelectItem, onSwitchChannel, onOpenPrivateChat, - onPokeClient, onMoveClient, onClientContextMenu, onChannelContextMenu, @@ -893,7 +906,6 @@ function ChannelTree({ onSelectItem: (item: SelectedItem) => void; onSwitchChannel: (channelId: number) => void; onOpenPrivateChat: (clientId: number, clientName: string) => void; - onPokeClient: (clientId: number, clientName: string) => void; onMoveClient: (clientId: number, channelId: number) => void; onClientContextMenu: (e: React.MouseEvent, clientId: number, clientName: string, isSelf: boolean) => void; onChannelContextMenu: (e: React.MouseEvent, channelId: number, channelName: string) => void; @@ -989,7 +1001,7 @@ function ChannelTree({ className={`ts-tree-expander${hasChildren ? "" : " ts-tree-expander-empty"}${ isCollapsed ? " ts-tree-expander-collapsed" : "" }`} - aria-label={isCollapsed ? "aufklappen" : "zuklappen"} + aria-label={isCollapsed ? t("tree.expand") : t("tree.collapse")} tabIndex={-1} onMouseDown={(e) => { // Keep focus on the row so a nearby double-click still joins. @@ -1131,7 +1143,6 @@ function ChannelTree({ onSelectItem={onSelectItem} onSwitchChannel={onSwitchChannel} onOpenPrivateChat={onOpenPrivateChat} - onPokeClient={onPokeClient} onMoveClient={onMoveClient} onClientContextMenu={onClientContextMenu} onChannelContextMenu={onChannelContextMenu} @@ -1498,7 +1509,7 @@ function ConnectDialog({