Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ actually needs); reject everything else with 404. Add a regression test assertin

### H4 — Dependency vulnerabilities (43)

> **Status: fixed (#313), 2026-11-12.** `pnpm audit` reports no known
> vulnerabilities, prod and dev (the count had grown to 138, 79 in prod deps).
> Still open: the `pnpm audit --prod` CI gate. The text below describes the
> state at the assessment date.

`pnpm audit --prod` (2026-09-13): **3 low, 18 moderate, 22 high**. Notables:

| Package | Installed | Fixed in | Issue |
Expand Down
8 changes: 4 additions & 4 deletions docs/dlna.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Sink is empty — we don't render.

| Library | Role in tests | Notes |
|--------------------------|------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| `node-upnp` (devDep) | Real UPnP control point: device description + SOAP Browse | Quirk: `parseSOAPResponse` walks `Array.from(argumentList.argument)`, which silently returns `[]` for single-argument actions because fast-xml-parser emits an object (not an array) for a single child. Single-output SOAP actions come back as `{}`. Worked around with raw fetch. |
| In-file `ControlPoint` | UPnP control point: device description → control URL → SOAP action | Lives in `test/dlna-http.integration.test.ts`, built on `fetch` + `fast-xml-parser`. Replaced the unmaintained `node-upnp` (#313), whose `got` / `ip` / `fast-xml-parser` 3 deps carried unpatched advisories. |
| Node `dgram` (built-in) | SSDP M-SEARCH + reply parsing | Direct and reliable. No library needed. |
| Node `fetch` (built-in) | Raw HTTP for stream headers + LAN-gate assertions + single-output SOAP | Already in tree. |
| `better-sqlite3` (dep) | In-memory schema seeded with fixtures | Used by the `dlna-objects` unit tests only to *seed* `unified_*` rows; the service itself reads via `app.inject()`-driven Subsonic calls (#219). |
Expand Down Expand Up @@ -241,7 +241,7 @@ Run separately; require UDP multicast and a free UDP 1900 for the advertiser.
| File | Covers |
|---------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| `test/dlna-ssdp.integration.test.ts` | Boots `SsdpAdvertiser`. Raw-dgram M-SEARCH for `MediaServer:1` (asserts USN/LOCATION/CACHE-CONTROL/SERVER on the unicast 200). M-SEARCH for `ssdp:all` (asserts all five advertised targets reply). Boots a second advertiser and listens for `NTS: ssdp:byebye` after `stop()` (asserts all five targets emit byebye before the socket closes). |
| `test/dlna-http.integration.test.ts` | Boots full hub via `buildApp()` on a random loopback port. `node-upnp` drives device-description fetch + Browse + ConnectionManager:GetProtocolInfo. Raw fetch covers single-output SOAP actions, confirms `/dlna/stream/<id>` returns 404 (#218 — the relay route was deleted), and LAN-gate rejecting `x-forwarded-for` / `cf-connecting-ip`. |
| `test/dlna-http.integration.test.ts` | Boots full hub via `buildApp()` on a random loopback port. The in-file `ControlPoint` drives device-description fetch + Browse + ConnectionManager:GetProtocolInfo. Raw fetch covers single-output SOAP actions, confirms `/dlna/stream/<id>` returns 404 (#218 — the relay route was deleted), and LAN-gate rejecting `x-forwarded-for` / `cf-connecting-ip`. |
| `test/cast-token-stream.integration.test.ts` | #218 — end-to-end smoke that `buildStreamUrl` produces a URL whose bytes stream through Hub Subsonic; cross-track token rejection; getCoverArt refuses cast tokens. |

> **Test constraint:** `dlna-http.integration.test.ts` leaves the
Expand All @@ -257,7 +257,7 @@ Run separately; require UDP multicast and a free UDP 1900 for the advertiser.
### Driving a real-world DLNA server (ground truth)

To verify our DIDL-Lite shape matches what real servers emit, point the
same primitives (`dgram` + `node-upnp`) at the LAN. Recipe:
same primitives (`dgram` + the test `ControlPoint`) at the LAN. Recipe:

1. Send M-SEARCH with `ST: urn:schemas-upnp-org:device:MediaServer:1`.
2. For each responder, fetch the LOCATION and read `<manufacturer>` from
Expand All @@ -279,7 +279,7 @@ for artists / release groups.
Probe is not committed to the tree — it's a `node` one-shot. Reproduce
from the README of this file by combining the structure of
`test/dlna-ssdp.integration.test.ts` (raw M-SEARCH) and
`test/dlna-http.integration.test.ts` (node-upnp Browse).
`test/dlna-http.integration.test.ts` (`ControlPoint` Browse).

### CI smoke (optional)

Expand Down
3 changes: 3 additions & 0 deletions docs/pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@ Full flow: [authentication.md](authentication.md).
| `corepack` in the Dockerfile on Node 25+ | #292 | Node 25+ no longer bundles it, so `corepack enable` exits 127. Install pnpm with `npm install -g pnpm@x.y.z`, matching `packageManager` |
| Prebuild-bundling native dep (`better-sqlite3` 13+) | #292 | pnpm ignores `"gypfile": false` and runs an implicit `node-gyp rebuild` if the dep is in `onlyBuiltDependencies`. List it in `ignoredBuiltDependencies` instead |
| Building a test stack under the live image tag | #292/#310 | `docker-compose.yml` defaults the hub image to `ghcr.io/benders/poutine:latest`, the tag live hubs pull. A test `up --build` under that tag retags it, a later `up -d --no-build` on a live hub then runs the test build, and the untagged old image can be garbage-collected even while a container still runs it. `test/federation/run.sh` exports `POUTINE_IMAGE=poutine-federation-test:local` (override: `FEDERATION_TEST_IMAGE`); any new harness that builds from this compose file must set `POUTINE_IMAGE` too. A manual `docker compose up --build` / `pnpm hub:up` still retags `:latest` by design |
| Bumping deps without re-running `pnpm audit` | #313 | Advisories accumulate silently (138 between 2026-09 and 2026-11). `pnpm up -r` clears in-range ones; then `pnpm audit` must print `No known vulnerabilities found` (dev deps included). A transitive dep whose parent pins a vulnerable range goes in root `pnpm.overrides`, scoped `parent>dep`. An unmaintained dep with no patched release gets replaced, not overridden |
| Frontend tests importing `node:*` builtins | #313 | `tsconfig.app.json` `types` must list `node`. vitest 3 pulled `@types/node` in transitively; vitest 4 does not, and `tsc -b` then fails with TS2307 on `node:fs` in `src/**/*.test.ts` |
| `eslint-plugin-react-hooks` minor bumps | #313 | Minors add React Compiler rules as errors (7.1: `set-state-in-effect`, `immutability`, `preserve-manual-memoization`). Fix the code — derive initial state in a `useState` initializer, declare helpers before the effects that call them, memo on a hoisted local instead of `obj?.prop` — rather than pinning the plugin |
| `test:federation` on a host that also runs live hubs | #308 | Three extra hub + Navidrome stacks share the Docker VM's memory with everything else. On a 2 GB VM the kernel OOM-killed a live hub mid-run (exit 137; `unless-stopped` restarted it). Containers have no memory limit, so the victim is arbitrary. Give the VM headroom or run the suite elsewhere; afterwards check `docker events --filter event=oom` |
3 changes: 2 additions & 1 deletion docs/sonos.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ Run via `pnpm --filter hub test`.
### Driving a Sonos zone from the test process

Sonos zones speak the same UPnP profile other LAN servers do, so the same
control-point library used for the DLNA tests (`node-upnp`) drives Sonos
control point used for the DLNA tests (`ControlPoint` in
`test/dlna-http.integration.test.ts`) drives Sonos
just as well. There are no integration tests committed for this because the
Sonos casting *direction* (hub → device) is sufficiently covered by:

Expand Down
46 changes: 23 additions & 23 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@
"test:watch": "vitest"
},
"dependencies": {
"@tanstack/react-query": "^5.80.7",
"@tanstack/react-query": "^5.107.1",
"clsx": "^2.1.1",
"js-md5": "^0.8.3",
"lucide-react": "^0.525.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-router-dom": "^7.6.2",
"tailwind-merge": "^3.3.0",
"zustand": "^5.0.5"
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-router-dom": "^7.18.5",
"tailwind-merge": "^3.7.0",
"zustand": "^5.1.0"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@tailwindcss/vite": "^4.1.10",
"@testing-library/dom": "^10.4.1",
"@eslint/js": "^9.39.5",
"@tailwindcss/vite": "^4.3.5",
"@testing-library/dom": "^10.4.2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/node": "^26.6.5",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.1",
"eslint": "^9.39.4",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
"jsdom": "^29.0.2",
"tailwindcss": "^4.1.10",
"@testing-library/react": "^16.3.3",
"@types/node": "^26.6.6",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.3.0",
"eslint": "^9.39.5",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.5.7",
"globals": "^17.14.0",
"jsdom": "^29.1.1",
"tailwindcss": "^4.3.5",
"typescript": "~5.9.3",
"typescript-eslint": "^8.57.0",
"vite": "^8.0.1",
"vitest": "^3.2.4"
"typescript-eslint": "^8.72.2",
"vite": "^8.3.8",
"vitest": "^4.1.12"
}
}
5 changes: 3 additions & 2 deletions frontend/src/components/player/PlayerBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ export function PlayerBar() {
// Same fresh-salt-per-call hazard for artUrl(): without memoization the
// <img> src changes on every render and the browser re-fetches
// getCoverArt in a tight loop.
const currentCoverArt = currentTrack?.coverArt;
const currentArtUrl = useMemo(
() => (currentTrack?.coverArt ? artUrl(currentTrack.coverArt, 48) : null),
[currentTrack?.coverArt],
() => (currentCoverArt ? artUrl(currentCoverArt, 48) : null),
[currentCoverArt],
);
const streamed = currentTrack ? effectiveStream(currentTrack) : null;
const isTranscoded = streamed?.bitRateIsCap === true;
Expand Down
30 changes: 15 additions & 15 deletions frontend/src/lib/useDocumentTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ export function useDocumentTitle() {
}))
);

function updateTitle() {
const currentTrack = currentIndex >= 0 && currentIndex < queue.length
? queue[currentIndex]
: null;

if (currentTrack && isPlaying) {
// When playing: just "{artist} - {song}"
document.title = `${currentTrack.artist} - ${currentTrack.title}`;
} else {
// Not playing: "Poutine {instanceId}" or just "Poutine" as fallback
const instanceId = instanceIdRef.current;
document.title = instanceId ? `Poutine ${instanceId}` : "Poutine";
}
}

// Fetch instance info once on mount
useEffect(() => {
getInstanceInfo()
Expand All @@ -44,19 +59,4 @@ export function useDocumentTitle() {
updateTitle();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [queue, currentIndex, isPlaying]);

function updateTitle() {
const currentTrack = currentIndex >= 0 && currentIndex < queue.length
? queue[currentIndex]
: null;

if (currentTrack && isPlaying) {
// When playing: just "{artist} - {song}"
document.title = `${currentTrack.artist} - ${currentTrack.title}`;
} else {
// Not playing: "Poutine {instanceId}" or just "Poutine" as fallback
const instanceId = instanceIdRef.current;
document.title = instanceId ? `Poutine ${instanceId}` : "Poutine";
}
}
}
29 changes: 13 additions & 16 deletions frontend/src/pages/InvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ import { Disc3 } from "lucide-react";
* so it doesn't linger in browser history.
*/
export function InvitePage() {
const [token, setToken] = useState<string | null>(null);
// Read once at mount: the effect below strips the token from the address bar.
const [token] = useState<string | null>(
() => window.location.hash.replace(/^#/, "").trim() || null,
);
const [preview, setPreview] = useState<InvitePreview | null>(null);
const [checking, setChecking] = useState(true);
const [error, setError] = useState("");
const [checking, setChecking] = useState(token !== null);
const [error, setError] = useState(
token ? "" : "This invitation link is incomplete.",
);

const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
Expand All @@ -33,18 +38,10 @@ export function InvitePage() {
const navigate = useNavigate();

useEffect(() => {
const raw = window.location.hash.replace(/^#/, "").trim();
if (raw) {
// Drop the token from the address bar and history entry.
window.history.replaceState(null, "", window.location.pathname);
}
if (!raw) {
setError("This invitation link is incomplete.");
setChecking(false);
return;
}
setToken(raw);
previewInvite(raw)
if (!token) return;
// Drop the token from the address bar and history entry.
window.history.replaceState(null, "", window.location.pathname);
previewInvite(token)
.then((p) => {
setPreview(p);
setUsername(p.suggestedUsername ?? "");
Expand All @@ -53,7 +50,7 @@ export function InvitePage() {
setError(err instanceof Error ? err.message : "Invitation is not valid"),
)
.finally(() => setChecking(false));
}, []);
}, [token]);

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"types": ["vite/client", "node"],
"skipLibCheck": true,

/* Bundler mode */
Expand Down
4 changes: 2 additions & 2 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tailwindcss from "@tailwindcss/vite";
import path from "node:path";
import { readFileSync } from "node:fs";

const pkg = JSON.parse(readFileSync(path.resolve(__dirname, "package.json"), "utf-8")) as { version: string };
const pkg = JSON.parse(readFileSync(path.resolve(import.meta.dirname, "package.json"), "utf-8")) as { version: string };

export default defineConfig({
define: {
Expand All @@ -13,7 +13,7 @@ export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@": path.resolve(import.meta.dirname, "./src"),
},
},
server: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import react from "@vitejs/plugin-react";
import path from "node:path";
import { readFileSync } from "node:fs";

const pkg = JSON.parse(readFileSync(path.resolve(__dirname, "package.json"), "utf-8")) as { version: string };
const pkg = JSON.parse(readFileSync(path.resolve(import.meta.dirname, "package.json"), "utf-8")) as { version: string };

export default defineConfig({
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
plugins: [react()],
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
alias: { "@": path.resolve(import.meta.dirname, "./src") },
},
test: {
environment: "jsdom",
Expand Down
41 changes: 20 additions & 21 deletions hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@fastify/cookie": "^11.0.0",
"@fastify/cors": "^11.0.0",
"@fastify/static": "^9.1.0",
"better-sqlite3": "^13.0.3",
"fast-uri": "^3.1.2",
"fast-xml-parser": "^5.8.0",
"fastify": "^5.8.5",
"jose": "^6.0.11",
"newrelic": "^14.9.0",
"pino": "^9.6.0",
"sharp": "^0.35.3",
"undici": "^7.5.0",
"yaml": "^2.8.3",
"@fastify/cookie": "^11.1.5",
"@fastify/cors": "^11.4.2",
"@fastify/static": "^10.1.10",
"better-sqlite3": "^13.1.1",
"fast-uri": "^3.1.9",
"fast-xml-parser": "^5.12.0",
"fastify": "^5.12.8",
"jose": "^6.2.17",
"newrelic": "^14.12.0",
"pino": "^9.14.0",
"sharp": "^0.35.5",
"undici": "^7.30.2",
"yaml": "^2.9.1",
"yazl": "^3.3.1"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
"@eslint/js": "^9.39.5",
"@types/better-sqlite3": "^7.6.13",
"@types/node": "^26.6.5",
"@types/node": "^26.6.6",
"@types/yazl": "^3.3.1",
"eslint": "^9.21.0",
"node-upnp": "^1.3.0",
"tsx": "^4.19.0",
"typescript": "^5.8.0",
"typescript-eslint": "^8.30.0",
"vitest": "^3.1.0"
"eslint": "^9.39.5",
"tsx": "^4.23.15",
"typescript": "^5.9.3",
"typescript-eslint": "^8.72.2",
"vitest": "^4.1.12"
}
}
Loading
Loading