3a6c80558d
A punktfunk-plugin-* package that scans ROM directories, maps them to emulators, fetches box art, and reconciles them into the host game library under provider id `rom-manager` — with a console-hosted web UI. Engine (pure, unit-tested core): - Table-driven platform registry (~25 consoles) + emulator registry with best-effort per-OS detection (PATH / Flatpak / known paths) and RetroArch core discovery. - Scanner with disc folding (m3u/cue/gdi), archive gating, excludes. - No-Intro title parsing + optional per-platform region dedupe. - Security-critical quoting seam: POSIX single-quote + Windows double-quote with hostile-name refusal; ROM filenames never reach a shell un-quoted. - Pure desired-state reconcile (stable external_ids, scale guard, fingerprint skip) → full-replace PUT /library/provider/rom-manager. Box art (like Steam ROM Manager): SteamGridDB primary (portrait/hero/logo/ header, fuzzy match, operator API key) behind a provider seam, with keyless libretro-thumbnails as the zero-setup fallback (`auto` default). UI: console-hosted via the SDK `servePluginUi` (zero plugin-side auth) with a plugin-local REST/SSE API and a self-contained React SPA (Setup / Emulators / Games / Sync). Standalone password-gated fallback for host-only installs. CLI: scan / detect / preview / sync / uninstall / set-password. 48 engine tests, typecheck + biome clean, SPA builds. Verified end-to-end: scan → detect → reconcile PUT, fingerprint idempotence, and the standalone UI serving SPA + REST. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
// scrypt password hashing for the standalone fallback UI (design §9/§10.2). Format:
|
|
// `scrypt$<saltB64url>$<hashB64url>`. Verification is constant-time. Only used by the standalone
|
|
// server; the console-hosted path has no password of its own.
|
|
|
|
import { randomBytes, scryptSync, timingSafeEqual } from "node:crypto";
|
|
|
|
const KEYLEN = 32;
|
|
|
|
/** Hash a password for storage in `config.ui.passwordHash`. */
|
|
export const hashPassword = (password: string): string => {
|
|
const salt = randomBytes(16);
|
|
const hash = scryptSync(password, salt, KEYLEN);
|
|
return `scrypt$${salt.toString("base64url")}$${hash.toString("base64url")}`;
|
|
};
|
|
|
|
/** Constant-time verify a password against a stored `scrypt$...` hash. */
|
|
export const verifyPassword = (password: string, stored: string): boolean => {
|
|
const parts = stored.split("$");
|
|
if (parts.length !== 3 || parts[0] !== "scrypt" || !parts[1] || !parts[2])
|
|
return false;
|
|
const salt = Buffer.from(parts[1], "base64url");
|
|
const expected = Buffer.from(parts[2], "base64url");
|
|
let actual: Buffer;
|
|
try {
|
|
actual = scryptSync(password, salt, expected.length);
|
|
} catch {
|
|
return false;
|
|
}
|
|
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
};
|