diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index ea4ed9f3..00000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(mkdir:*)", - "Bash(npm run dev:*)", - "Bash(rm:*)", - "Bash(npm install:*)", - "Bash(pkill:*)", - "Bash(true)", - "Bash(grep:*)", - "Bash(npm run server:*)", - "Bash(curl:*)", - "Bash(timeout:*)", - "Bash(git init:*)", - "Bash(git add:*)", - "Bash(gh repo create:*)", - "Bash(gh auth:*)", - "Bash(kill:*)", - "Bash(chmod:*)", - "Bash(npm run kill-port:*)", - "Bash(git push:*)", - "Bash(git merge:*)", - "Bash(git rebase:*)", - "Bash(gh pr:*)" - ], - "deny": [] - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index d0015328..7dfb6e47 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,6 @@ sessions/ # Python (if any scripts) __pycache__/ *.py[cod] -*$py.class \ No newline at end of file +*$py.class +# Claude Code local settings (machine-specific permissions) +.claude/settings.local.json diff --git a/client/index.html b/client/index.html index a747158e..44ae045a 100644 --- a/client/index.html +++ b/client/index.html @@ -2,7 +2,7 @@ - + Beacon diff --git a/client/public/favicon.svg b/client/public/favicon.svg new file mode 100644 index 00000000..a784c658 --- /dev/null +++ b/client/public/favicon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/client/src/App.jsx b/client/src/App.jsx index ce09af6f..9cf0c597 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -25,12 +25,11 @@ function ProtectedRoute({ children }) { if (loading) { return ( -
-
-
- +
+
+
-

+

Lighting the beacon…

@@ -53,19 +52,16 @@ class ErrorBoundary extends React.Component { render() { if (this.state.hasError) { return ( -
-
-
- +
+
+
+
-

Critical System Error

-

{this.state.error?.message || 'Kernel panic detected.'}

-
diff --git a/client/src/components/Appearance.jsx b/client/src/components/Appearance.jsx index 14a084e2..2e2f6795 100644 --- a/client/src/components/Appearance.jsx +++ b/client/src/components/Appearance.jsx @@ -1,10 +1,10 @@ import { useState, useEffect } from 'react' import { useTheme } from '../context/ThemeContext' import { TOKENS } from '../lib/themes' -import { Sparkles, SlidersHorizontal, Code2, Sun, Moon, Check, Copy, AlertTriangle, Zap, Save, Undo2 } from 'lucide-react' +import { Palette, SlidersHorizontal, Code2, Sun, Moon, Check, Copy, AlertTriangle, Zap, Save, Undo2 } from 'lucide-react' const MODES = [ - { id: 'easy', label: 'Easy', icon: Sparkles, hint: 'Presets & basics' }, + { id: 'easy', label: 'Easy', icon: Palette, hint: 'Presets & basics' }, { id: 'advanced', label: 'Advanced', icon: SlidersHorizontal, hint: 'Fine-tune tokens' }, { id: 'tinkerer', label: 'Tinkerer', icon: Code2, hint: 'Full control' }, ] diff --git a/client/src/components/FileShare.jsx b/client/src/components/FileShare.jsx index 75e53372..d6482ff7 100644 --- a/client/src/components/FileShare.jsx +++ b/client/src/components/FileShare.jsx @@ -31,20 +31,20 @@ export default function FileShare() { return (
-
+
-
+
-

P2P File Transfer

-

Encrypted direct browser-to-browser pipe · resumable

+

P2P File Transfer

+

Encrypted direct browser-to-browser pipe · resumable

{mode !== 'idle' && (
{/* Selected File List / Progress */} -
-
- Sending - {selectedFiles.length} file(s) +
+
+ Sending + {selectedFiles.length} file(s)
{selectedFiles.map((file, i) => { const progress = uploadProgress[file.name] || 0 return ( -
+
- +
-

{file.name}

-

{formatFileSize(file.size)}

+

{file.name}

+

{formatFileSize(file.size)}

{progress > 0 && ( - {progress}% + {progress}% )}
{progress > 0 && ( -
+
)} @@ -197,22 +199,22 @@ export default function FileShare() { className="space-y-6" > {/* Connection coordinates header */} -
+
-

Share code

-

{shareCode}

+

Share code

+

{shareCode}

-
+
Connected
{receiverStatus === 'error' && ( -
- +
+
-

Connection failed

-

+

Connection failed

+

{joinError || "Couldn't establish a direct connection. The sender may be offline, or the network is too restrictive."}

@@ -220,35 +222,35 @@ export default function FileShare() { )} {receiverStatus === 'connecting' && ( -
- -

Connecting to the sender…

-

Setting up a direct connection

+
+ +

Connecting to the sender…

+

Setting up a direct connection

)} {receiverStatus === 'ready' && pendingFiles.length > 0 && ( -
+
-

Files ready

-

Accept to start downloading

+

Files ready

+

Accept to start downloading

{pendingFiles.map((file, i) => ( -
+
- - {file.name} + + {file.name}
- {formatFileSize(file.size)} + {formatFileSize(file.size)}
))}
{selectedFile && ( -
+
-

{selectedFile.name}

-

{formatFileSize(selectedFile.size)}

+

{selectedFile.name}

+

{formatFileSize(selectedFile.size)}

- +
{!isSharing && ( @@ -166,15 +166,15 @@ export default function VideoFileSharing({ socket, roomId, isHost, onVideoReady, {isSharing && (
-
- -

+

+ +

{status === 'streaming' ? 'Streaming to the party' : 'Ready — waiting for others'}

@@ -184,30 +184,30 @@ export default function VideoFileSharing({ socket, roomId, isHost, onVideoReady, )}
) : isHost ? ( -
- -

+

+ +

Switch to "File" mode
to share a video

) : (
{participantStatus === 'idle' && ( -
- -

+

+ +

Waiting for the host to share a video…

)} {participantStatus === 'pending' && pendingFileInfo && ( -
- -

The host wants to share a video

-
-

{pendingFileInfo.name}

-

{formatFileSize(pendingFileInfo.size)}

+
+ +

The host wants to share a video

+
+

{pendingFileInfo.name}

+

{formatFileSize(pendingFileInfo.size)}

@@ -217,16 +217,16 @@ Switch to "File" mode
to share a video )} {participantStatus === 'connecting' && ( -
-
+
+

Connecting…

)} {participantStatus === 'ready' && (
- -

+ +

Streaming — playing now

@@ -234,9 +234,9 @@ Streaming — playing now {participantStatus === 'error' && (
- -

Couldn't connect

-

The direct connection couldn't be established. This can happen on restrictive networks.

+ +

Couldn't connect

+

The direct connection couldn't be established. This can happen on restrictive networks.

{pendingHostId && ( @@ -248,10 +248,10 @@ Streaming — playing now
)} -
-

+

+

Encrypted peer-to-peer · starts playing as it streams
- MP4, WebM, MOV + MP4, WebM, MOV

diff --git a/client/src/components/VoicePanel.jsx b/client/src/components/VoicePanel.jsx index abbfbc30..15a9f9bd 100644 --- a/client/src/components/VoicePanel.jsx +++ b/client/src/components/VoicePanel.jsx @@ -15,11 +15,11 @@ export default function VoicePanel({ socket, roomId }) { const peerEntries = Object.entries(peers) return ( -
+
- - + + {joined ? peerEntries.length === 0 ? 'Voice: alone in here' @@ -33,7 +33,7 @@ export default function VoicePanel({ socket, roomId }) { @@ -59,7 +59,7 @@ export default function VoicePanel({ socket, roomId }) {
{joined && peerEntries.length > 0 && ( -
+
{peerEntries.filter(([, p]) => p.stream).length} connected
)} diff --git a/client/src/index.css b/client/src/index.css index d229aba5..160f76d8 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -11,21 +11,21 @@ @layer base { :root { - /* Crystal (dark) defaults — match PRESETS.crystal so first paint is right. */ + /* Crystal (dark) defaults — match PRESETS.crystal so first paint is right. + Night-sky neutrals; the coral accent is the light in the dark. */ --accent: 242 126 114; /* coral #f27e72 — the guiding light */ - --accent-2: 139 110 209; /* crystal violet */ - --bg-primary: #0E0A1A; /* night */ - --bg-secondary: #1A1233; /* background glow */ - --surface: #1A1330; - --surface-raised: #241A3D; - --text-primary: #F3EEFF; - --text-secondary: #A99FC9; - --radius: 16px; - --glow-strength: 0.5; + --accent-2: 122 148 187; /* muted sapphire */ + --bg-primary: #10131A; /* night */ + --bg-secondary: #171C26; + --surface: #161A23; + --surface-raised: #1D222E; + --text-primary: #EDEFF3; + --text-secondary: #929BAD; + --radius: 10px; + --glow-strength: 0.25; /* Derived */ --border: rgba(255, 255, 255, 0.08); - --glass-bg: color-mix(in srgb, var(--surface) 72%, transparent); } * { @@ -36,10 +36,9 @@ background-color: var(--bg-primary); color: var(--text-primary); @apply antialiased font-sans; - /* The beacon: warm light blooming from below, crystal glow from above. */ + /* A single faint warm cast low on the page — the light on the horizon. */ background-image: - radial-gradient(60rem 60rem at 85% -10%, rgb(var(--accent-2) / 0.16), transparent 60%), - radial-gradient(50rem 50rem at 10% 110%, rgb(var(--accent) / 0.14), transparent 55%); + radial-gradient(55rem 40rem at 50% 115%, rgb(var(--accent) / 0.07), transparent 60%); background-attachment: fixed; overflow-x: hidden; } @@ -47,34 +46,22 @@ ::-webkit-scrollbar { width: 7px; height: 7px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { - background: rgb(var(--accent-2) / 0.3); + background: rgba(255, 255, 255, 0.14); border-radius: 9999px; } - ::-webkit-scrollbar-thumb:hover { background: rgb(var(--accent-2) / 0.5); } + ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); } ::selection { background: rgb(var(--accent) / 0.3); color: var(--text-primary); } } @layer components { + /* Kept the historical name; it's a plain card now (solid, bordered). */ .glass-card { - background: var(--glass-bg); - backdrop-filter: blur(18px); - -webkit-backdrop-filter: blur(18px); + background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); - box-shadow: 0 8px 40px -8px rgba(0, 0, 0, 0.45); - @apply transition-all duration-300; - } - - /* Ambient glowing orbs (decorative). */ - .orb { - position: absolute; - border-radius: 50%; - filter: blur(120px); - z-index: 0; - pointer-events: none; - opacity: var(--glow-strength); - animation: float 22s infinite alternate ease-in-out; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); + @apply transition-colors duration-200; } .btn { @@ -85,14 +72,14 @@ } .btn:focus-visible { box-shadow: 0 0 0 3px rgb(var(--accent) / 0.35); } - /* The light: coral, with a glow that scales to the user's glow setting. */ + /* The light: flat coral. Glow only if the user turns it up. */ .btn-primary { - background: linear-gradient(135deg, rgb(var(--accent)) 0%, rgb(var(--accent) / 0.85) 100%); + background: rgb(var(--accent)); color: #1a0f0d; - box-shadow: 0 6px 24px -6px rgb(var(--accent) / calc(var(--glow-strength) * 0.9)); - @apply font-extrabold; + box-shadow: 0 4px 16px -6px rgb(var(--accent) / var(--glow-strength)); + @apply font-bold; } - .btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 32px -6px rgb(var(--accent) / var(--glow-strength)); } + .btn-primary:hover { filter: brightness(1.06); } .btn-secondary { background: var(--surface-raised); @@ -126,30 +113,20 @@ .nav-item.active::before { content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); - width: 4px; height: 60%; border-radius: 9999px; + width: 3px; height: 60%; border-radius: 9999px; background: rgb(var(--accent)); - box-shadow: 0 0 12px rgb(var(--accent) / 0.9); } - /* The beacon mark — a glowing crystal. */ + /* The beacon mark — the one place the light gets to shine. */ .beacon-mark { - background: linear-gradient(140deg, rgb(var(--accent)) 0%, rgb(var(--accent-2)) 100%); - box-shadow: 0 0 20px -2px rgb(var(--accent) / var(--glow-strength)); + background: rgb(var(--accent)); + box-shadow: 0 0 16px -2px rgb(var(--accent) / var(--glow-strength)); } } @layer utilities { - .text-gradient { - background: linear-gradient(120deg, rgb(var(--accent)), rgb(var(--accent-2))); - -webkit-background-clip: text; background-clip: text; color: transparent; - } - .beacon-glow { box-shadow: 0 0 32px -6px rgb(var(--accent) / var(--glow-strength)); } -} - -@keyframes float { - 0% { transform: translate(0, 0) scale(1); } - 50% { transform: translate(28px, -44px) scale(1.08); } - 100% { transform: translate(-18px, 18px) scale(0.96); } + .text-accent { color: rgb(var(--accent)); } + .beacon-glow { box-shadow: 0 0 24px -6px rgb(var(--accent) / var(--glow-strength)); } } @keyframes beacon-pulse { diff --git a/client/src/lib/themes.js b/client/src/lib/themes.js index af1ef093..bb595bf4 100644 --- a/client/src/lib/themes.js +++ b/client/src/lib/themes.js @@ -29,31 +29,31 @@ export const PRESETS = { mode: 'dark', tokens: { '--accent': '242 126 114', // coral #f27e72 — the guiding light - '--accent-2': '139 110 209', // lifted crystal violet - '--bg-primary': '#0E0A1A', - '--bg-secondary': '#1A1233', - '--surface': '#1A1330', - '--surface-raised': '#241A3D', - '--text-primary': '#F3EEFF', - '--text-secondary': '#A99FC9', - '--radius': '16px', - '--glow-strength': '0.5', + '--accent-2': '122 148 187', // muted sapphire + '--bg-primary': '#10131A', + '--bg-secondary': '#171C26', + '--surface': '#161A23', + '--surface-raised': '#1D222E', + '--text-primary': '#EDEFF3', + '--text-secondary': '#929BAD', + '--radius': '10px', + '--glow-strength': '0.25', }, }, midnight: { label: 'Midnight', mode: 'dark', tokens: { - '--accent': '139 110 209', // violet-forward - '--accent-2': '99 102 241', - '--bg-primary': '#0A0A14', - '--bg-secondary': '#14122B', - '--surface': '#15152A', - '--surface-raised': '#1F1F3D', - '--text-primary': '#EDEFFF', - '--text-secondary': '#8E92B8', - '--radius': '12px', - '--glow-strength': '0.4', + '--accent': '124 156 205', // sapphire-forward + '--accent-2': '92 112 148', + '--bg-primary': '#0C0F16', + '--bg-secondary': '#121724', + '--surface': '#111622', + '--surface-raised': '#18202F', + '--text-primary': '#E9EDF5', + '--text-secondary': '#8791A6', + '--radius': '8px', + '--glow-strength': '0.2', }, }, ember: { @@ -61,31 +61,31 @@ export const PRESETS = { mode: 'dark', tokens: { '--accent': '247 126 114', // warmer coral - '--accent-2': '245 166 35', // amber - '--bg-primary': '#140C12', - '--bg-secondary': '#27141C', - '--surface': '#1F141C', - '--surface-raised': '#2C1D27', - '--text-primary': '#FBEFEA', - '--text-secondary': '#C4A79E', - '--radius': '20px', - '--glow-strength': '0.65', + '--accent-2': '215 158 74', // lantern amber + '--bg-primary': '#15100E', + '--bg-secondary': '#201714', + '--surface': '#1C1512', + '--surface-raised': '#251C18', + '--text-primary': '#F5EEE9', + '--text-secondary': '#B3A296', + '--radius': '12px', + '--glow-strength': '0.4', }, }, daylight: { label: 'Daylight', mode: 'light', tokens: { - '--accent': '232 90 76', // coral that reads on light - '--accent-2': '109 79 160', - '--bg-primary': '#FAF8FF', - '--bg-secondary': '#EEE8FB', + '--accent': '224 82 68', // coral that reads on light + '--accent-2': '86 110 146', + '--bg-primary': '#F7F7F5', + '--bg-secondary': '#EDEDEA', '--surface': '#FFFFFF', - '--surface-raised': '#F5F1FE', - '--text-primary': '#1E1633', - '--text-secondary': '#6B6385', - '--radius': '16px', - '--glow-strength': '0.25', + '--surface-raised': '#F1F1EE', + '--text-primary': '#22252B', + '--text-secondary': '#6A7180', + '--radius': '10px', + '--glow-strength': '0.1', }, }, } diff --git a/client/src/pages/Files.jsx b/client/src/pages/Files.jsx index 2cccd742..891314f1 100644 --- a/client/src/pages/Files.jsx +++ b/client/src/pages/Files.jsx @@ -8,7 +8,7 @@ export default function Files() {

- Send a file + Send a file

Files stream directly browser-to-browser — nothing is stored on a server, and interrupted transfers pick up where they left off. diff --git a/client/src/pages/Home.jsx b/client/src/pages/Home.jsx index 1ce01fe4..a6f526a6 100644 --- a/client/src/pages/Home.jsx +++ b/client/src/pages/Home.jsx @@ -1,6 +1,6 @@ import { useAuth } from '../context/AuthContext' import Launcher from '../components/Launcher' -import { Sparkles, Tv, FolderUp, MessageSquare } from 'lucide-react' +import { Tv, FolderUp, MessageSquare } from 'lucide-react' export default function Home() { const { user } = useAuth() @@ -8,12 +8,11 @@ export default function Home() { return (

-
- Welcome back, {user?.username} -
+

+ Welcome back, {user?.username} +

- Watch, share, and
hang out — together. + Watch, share, and
hang out — together.

Start something new, or paste a code a friend sent you. No downloads, no account needed. diff --git a/client/tailwind.config.js b/client/tailwind.config.js index 9e7787ad..d3208282 100644 --- a/client/tailwind.config.js +++ b/client/tailwind.config.js @@ -6,17 +6,7 @@ export default { "./src/**/*.{js,ts,jsx,tsx}", ], theme: { - extend: { - colors: { - primary: { - 50: '#eff6ff', - 400: '#60a5fa', - 500: '#3b82f6', - 600: '#2563eb', - 700: '#1d4ed8', - } - } - }, + extend: {}, }, plugins: [], } \ No newline at end of file diff --git a/tests/e2e/hostile-peer.spec.ts b/tests/e2e/hostile-peer.spec.ts new file mode 100644 index 00000000..ff6c8d89 --- /dev/null +++ b/tests/e2e/hostile-peer.spec.ts @@ -0,0 +1,126 @@ +import { test, expect } from '@playwright/test' + +// Regression tests for the receiver-side defenses against a hostile sending +// peer (see the P2P hardening in client/src/lib/p2p/transfer.js and +// streaming.js). Each test drives the REAL receiver with a hand-rolled +// malicious sender over a loopback RTCPeerConnection pair — no UI — and +// asserts the receiver rejects the abuse instead of acting on it. + +test('receiver rejects a manifest whose chunk geometry does not match its size', async ({ page }) => { + await page.goto('/') + + const outcome = await page.evaluate(async () => { + const { createReceiver } = await import('/src/lib/p2p/transfer.js') + + const a = new RTCPeerConnection() + const b = new RTCPeerConnection() + a.onicecandidate = (e) => e.candidate && b.addIceCandidate(e.candidate) + b.onicecandidate = (e) => e.candidate && a.addIceCandidate(e.candidate) + const sendCh = a.createDataChannel('transfer') + const remote: Promise = new Promise((res) => { b.ondatachannel = (e) => res(e.channel) }) + await a.setLocalDescription() + await b.setRemoteDescription(a.localDescription!) + await b.setLocalDescription() + await a.setRemoteDescription(b.localDescription!) + const recvCh = await remote + await new Promise((res) => { sendCh.readyState === 'open' ? res() : (sendCh.onopen = () => res()) }) + + let errored = false + let resumeSeen = false + recvCh.onmessage = (e) => { if (typeof e.data === 'string' && JSON.parse(e.data).t === 'resume') resumeSeen = true } + + const transferId = 'mal-manifest' + createReceiver({ + channel: recvCh, + transferId, + onError: () => { errored = true }, + }) + + // A tiny file (1 chunk) but a totalChunks claiming 1,000,000 — the geometry + // an attacker would use to write chunks at huge offsets. + sendCh.send(JSON.stringify({ + t: 'manifest', id: transferId, + files: [{ i: 0, name: 'evil.bin', size: 100, type: 'application/octet-stream', chunkSize: 65536, totalChunks: 1_000_000 }], + })) + await new Promise((r) => setTimeout(r, 300)) + a.close(); b.close() + return { errored, resumeSeen } + }) + + expect(outcome.errored).toBe(true) // receiver flagged the manifest + expect(outcome.resumeSeen).toBe(false) // and never answered with a resume (never allocated a store) +}) + +test('receiver drops a chunk written past the declared totalChunks', async ({ page }) => { + await page.goto('/') + + const outcome = await page.evaluate(async () => { + const { createReceiver, cleanupTransfer, CHUNK_SIZE } = await import('/src/lib/p2p/transfer.js') + + const a = new RTCPeerConnection() + const b = new RTCPeerConnection() + a.onicecandidate = (e) => e.candidate && b.addIceCandidate(e.candidate) + b.onicecandidate = (e) => e.candidate && a.addIceCandidate(e.candidate) + const sendCh = a.createDataChannel('transfer') + sendCh.binaryType = 'arraybuffer' + const remote: Promise = new Promise((res) => { b.ondatachannel = (e) => res(e.channel) }) + await a.setLocalDescription() + await b.setRemoteDescription(a.localDescription!) + await b.setLocalDescription() + await a.setRemoteDescription(b.localDescription!) + const recvCh = await remote + await new Promise((res) => { sendCh.readyState === 'open' ? res() : (sendCh.onopen = () => res()) }) + + const transferId = 'mal-oob-' + Math.random().toString(36).slice(2) + // A legitimate 2-chunk file. + const size = CHUNK_SIZE + 100 + const totalChunks = 2 + let completedSize = -1 + let errored = false + let errMsg = '' + let done = false + + await new Promise((resolve) => { + createReceiver({ + channel: recvCh, + transferId, + onFileComplete: (file: File) => { completedSize = file.size; done = true; resolve() }, + // Ignore the channel-close error that fires after we tear the pair down. + onError: (e: Error) => { if (done) return; errored = true; errMsg = String(e?.message ?? e); resolve() }, + }) + + // createReceiver owns recvCh.onmessage; we only drive the sender side. + sendCh.onmessage = (e) => { + if (typeof e.data !== 'string') return + const msg = JSON.parse(e.data) + if (msg.t !== 'resume') return + // Send an out-of-range chunk FIRST (index 999 » totalChunks) — must be ignored. + const oob = new Uint8Array(8 + 10) + new DataView(oob.buffer).setUint32(0, 0, true) + new DataView(oob.buffer).setUint32(4, 999, true) + sendCh.send(oob) + // Then the two real chunks in order. + for (let i = 0; i < totalChunks; i++) { + const bytes = i === 0 ? CHUNK_SIZE : 100 + const frame = new Uint8Array(8 + bytes) + const dv = new DataView(frame.buffer) + dv.setUint32(0, 0, true) + dv.setUint32(4, i, true) + sendCh.send(frame) + } + } + sendCh.send(JSON.stringify({ + t: 'manifest', id: transferId, + files: [{ i: 0, name: 'ok.bin', size, type: 'application/octet-stream', chunkSize: CHUNK_SIZE, totalChunks }], + })) + }) + + a.close(); b.close() + await cleanupTransfer(transferId).catch(() => {}) + return { completedSize, size, errored, errMsg } + }) + + // The out-of-range chunk was ignored; the file still completes at its true size. + expect(outcome.errored, `unexpected error: ${outcome.errMsg}`).toBe(false) + expect(outcome.completedSize).toBe(outcome.size) +})