Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f096401
fix(cli): a subfolder of an imported project keeps its received-files…
michaelwang11394 Nov 14, 2026
4f0af2b
fix(cli): a received file counts under any spelling of the same file …
michaelwang11394 Nov 14, 2026
740be08
fix(cli): cloud render prepares only the GIFs staging kept
michaelwang11394 Nov 14, 2026
31fb585
fix(cli,studio-server): never hand a playlist named as media to ffmpeg
michaelwang11394 Nov 14, 2026
a2abe22
fix(studio-server): catch playlists with control bytes, and keep them…
michaelwang11394 Nov 14, 2026
cc51344
fix(cli): a parent folder's state the CLI cannot read never marks a p…
michaelwang11394 Nov 14, 2026
2337666
fix(cli): a drive that reports no file ids matches no received file b…
michaelwang11394 Nov 14, 2026
0e6a871
refactor(studio-server): read a media file's first bytes with a read …
michaelwang11394 Nov 14, 2026
ce688c4
chore(studio-server): raise the packed size budget for the media play…
michaelwang11394 Nov 14, 2026
6ba3835
fix(cli,studio-server): open media only through self-contained media …
michaelwang11394 Nov 14, 2026
dc3c265
fix(cli,studio-server): keep media probe argv flat, and expect the de…
michaelwang11394 Nov 15, 2026
cbd6122
fix(cli): play and present answer only local host names and allowed h…
michaelwang11394 Nov 15, 2026
d08156d
fix(cli): a local render of a received composition leaves out files o…
michaelwang11394 Nov 15, 2026
6c9ae0b
fix(cli): received-render scan reads safely and treats an unreadable …
michaelwang11394 Nov 15, 2026
73cb36a
fix(cli): the studio render of a received composition leaves out file…
michaelwang11394 Nov 15, 2026
7f28c39
Merge remote-tracking branch 'origin/main' into sec-hf6-1114
michaelwang11394 Nov 15, 2026
d15a5b2
chore(cli): name the unreadable received-files record helper without …
michaelwang11394 Nov 15, 2026
f454138
fix(cli): local render refuses outside files when any composition it …
michaelwang11394 Nov 15, 2026
12b6542
fix(cli): decide a received render from the files the compiler reads
michaelwang11394 Nov 15, 2026
fda9855
fix(cli,producer): decide a received render with the render compiler'…
michaelwang11394 Nov 15, 2026
2f94932
fix(cli): refuse outside files in a local render whenever the project…
michaelwang11394 Nov 15, 2026
705ec5b
fix(cli): refuse outside files only when a received file can load oth…
michaelwang11394 Nov 15, 2026
c130e33
fix(cli): keep outside files only when every received file is positiv…
michaelwang11394 Nov 15, 2026
33ec87b
fix(producer,core): a sub-composition must be an .html file
michaelwang11394 Nov 15, 2026
e1d49a2
fix(producer,cli): the render and static file servers forbid type sni…
michaelwang11394 Nov 15, 2026
eb47e27
test(cli): a received media file in a composition slot is refused as …
michaelwang11394 Nov 15, 2026
b290d77
Merge remote-tracking branch 'origin/main' into sec-hf6-1114
michaelwang11394 Nov 15, 2026
7e8f156
test(cli): an empty nested received-files record cannot hide an outer…
michaelwang11394 Nov 15, 2026
0638f94
fix(cli): a received media file reached under another name refuses ou…
michaelwang11394 Nov 15, 2026
df19490
fix(cli): compare received files by link target and keep outside file…
michaelwang11394 Nov 15, 2026
70147ba
Merge remote-tracking branch 'origin/main' into sec-hf6-1114
michaelwang11394 Nov 15, 2026
c511869
chore: raise the producer unpacked size budget for the composition fi…
michaelwang11394 Nov 15, 2026
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
20 changes: 20 additions & 0 deletions docs/packages/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,15 @@ the CLI itself, or when you set `HYPERFRAMES_LOCAL_STUDIO=1`; a Studio in the
project's own `node_modules` is not used otherwise.
`--background` works with the embedded server only.

The preview server answers only the host names it serves. To open it through
a tunnel, Codespaces or a reverse proxy, name that host in
`HYPERFRAMES_PREVIEW_ALLOWED_HOSTS` (comma separated). A refused request
answers 403 with the host named and this variable as the fix:

```bash
HYPERFRAMES_PREVIEW_ALLOWED_HOSTS=demo.tunnels.example hyperframes preview
```

The CLI ships GSAP, CustomEase, and MotionPathPlugin, so the GSAP scripts
Studio adds to previews load from the preview server itself, not from jsDelivr.
To use your own mirror instead, set `HYPERFRAMES_GSAP_BASE_URL` before starting
Expand Down Expand Up @@ -1105,6 +1114,17 @@ npx hyperframes present [dir] --port 3004
editor, just playback. Same flags, `--port` defaults to 3003, plus `--proxy` /
`--no-proxy`.

Both listen on every network interface, so a phone or another computer on your
network can open them at this machine's LAN address or `.local` name. They
answer `localhost`, loopback addresses, and this machine's own addresses and
names. Any other host name, such as a tunnel, Codespaces or a reverse proxy,
gets a 403 until you name it in `HYPERFRAMES_PREVIEW_ALLOWED_HOSTS`, the same
setting `preview` uses:

```bash
HYPERFRAMES_PREVIEW_ALLOWED_HOSTS=demo.tunnels.example hyperframes present
```

### `publish`

For new video reviews, use [`share`](#share). Legacy source publishing stays
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
resolveRuntimePath,
resolvePlayerPath,
listenOnFreePort,
refuseUnknownHosts,
injectRuntime,
injectMediaCodecMap,
buildRangeResponse,
Expand Down Expand Up @@ -145,6 +146,7 @@ export default defineCommand({
const { createAdaptorServer } = await import("@hono/node-server");

const app = new Hono();
refuseUnknownHosts(app);

// Serve the player JS
app.get("/player.js", (ctx) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/present.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
resolvePlayerPath,
resolveSlideshowPath,
listenOnFreePort,
refuseUnknownHosts,
assetContentType,
} from "../utils/compositionServer.js";
import { isPrivateCompositionFile } from "../utils/privateProjectFile.js";
Expand Down Expand Up @@ -123,6 +124,7 @@ export default defineCommand({
const { createAdaptorServer } = await import("@hono/node-server");

const app = new Hono();
refuseUnknownHosts(app);

app.get("/player.js", (ctx) =>
ctx.body(readFileSync(playerPath, "utf-8"), 200, {
Expand Down
50 changes: 48 additions & 2 deletions packages/cli/src/commands/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ vi.mock("../utils/producer.js", () => ({
}),
),
renderConfigFromRequest: vi.fn(
(request: { options: Record<string, unknown> }, runtime: { logger?: unknown }) => {
(
request: { options: Record<string, unknown> },
runtime: { logger?: unknown; allowOutsideProjectAssets?: boolean },
) => {
const { engineConfig, ...options } = request.options;
return { ...options, producerConfig: engineConfig, logger: runtime.logger };
return {
...options,
producerConfig: engineConfig,
logger: runtime.logger,
allowOutsideProjectAssets: runtime.allowOutsideProjectAssets,
};
},
),
createRenderJob: vi.fn((config: Record<string, unknown>) => {
Expand Down Expand Up @@ -580,6 +588,44 @@ describe("renderLocal browser GPU config", () => {
warn.mockRestore();
});

it.each([
{ name: "a received entry", files: ["index.html"], allowed: false },
{ name: "a record listing only an image", files: ["assets/in.png"], allowed: true },
{ name: "a record listing a received stylesheet", files: ["style.css"], allowed: false },
{ name: "a record listing no files", files: [], allowed: true },
{ name: "no received-files record", files: undefined, allowed: true },
])("brings in outside files for $name: $allowed", async ({ files, allowed }) => {
const projectDir = mkdtempSync(join(tmpdir(), "hf-render-received-"));
writeFileSync(join(projectDir, "index.html"), "<div></div>");
mkdirSync(join(projectDir, "assets"));
writeFileSync(
join(projectDir, "assets", "in.png"),
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
);
if (files) {
mkdirSync(join(projectDir, ".hyperframes"));
writeFileSync(
join(projectDir, ".hyperframes", "received-files.json"),
JSON.stringify({ files }),
);
}
try {
await renderLocal(projectDir, join(projectDir, "out.mp4"), {
fps: { num: 30, den: 1 },
quality: "standard",
format: "mp4",
gpu: false,
browserGpuMode: "software",
hdrMode: "auto",
quiet: true,
throwOnError: true,
});
expect(producerState.createdJobs.at(-1)?.allowOutsideProjectAssets).toBe(allowed);
} finally {
rmSync(projectDir, { recursive: true, force: true });
}
});

it("cleans orphaned browser trees before starting a local render", async () => {
orphanCleanupState.killed = 1;

Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/commands/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { freemem, tmpdir } from "node:os";
import { resolve, dirname, join, basename } from "node:path";
import { execFileSync, spawn } from "node:child_process";
import { loadProducer } from "../utils/producer.js";
import { outsideAssetsAllowed } from "../utils/receivedRender.js";
import { c } from "../ui/colors.js";
import { desktopHint } from "../utils/desktopApp.js";
import {
Expand Down Expand Up @@ -1148,6 +1149,9 @@ async function executeLocalRender(
process.env.HYPERFRAMES_GSAP_VENDOR_DIR = gsapVendorDir;
}
const producer = await loadProducer();
const allowOutsideProjectAssets = outsideAssetsAllowed(projectDir, options.entryFile, (line) =>
console.warn(c.warn(` ${line}`)),
);
const deParallelRouterActive =
options.manageDeParallelRouterBreaker === true
? applyDeParallelRouterCircuitBreaker(options.quiet)
Expand Down Expand Up @@ -1227,10 +1231,11 @@ async function executeLocalRender(
startTime,
cpu,
signal: cancellation.signal,
allowOutsideProjectAssets,
});
}
const job = producer.createRenderJob(
producer.renderConfigFromRequest(request, { logger, allowOutsideProjectAssets: true }),
producer.renderConfigFromRequest(request, { logger, allowOutsideProjectAssets }),
);

const onProgress = options.quiet
Expand Down Expand Up @@ -1348,6 +1353,7 @@ async function renderRange(input: {
startTime: number;
cpu: RenderCpuSampler;
signal: AbortSignal;
allowOutsideProjectAssets: boolean;
}): Promise<SingleRenderResult> {
const { producer, options } = input;
let framesEncoded = 0;
Expand All @@ -1362,7 +1368,7 @@ async function renderRange(input: {
config,
input.range,
input.outputPath,
{ allowOutsideProjectAssets: true },
{ allowOutsideProjectAssets: input.allowOutsideProjectAssets },
);
framesEncoded = spanResult.framesEncoded;
reference = producer.referenceBackgroundResult(spanResult[producer.REFERENCE_BACKGROUND_FIELD]);
Expand Down
54 changes: 52 additions & 2 deletions packages/cli/src/server/studioServer.renderBrowser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { mkdtempSync, rmSync } from "node:fs";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createStudioServer, type StudioServer } from "./studioServer.js";
Expand Down Expand Up @@ -43,9 +43,19 @@ afterEach(() => {
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
});

function startStudioRender(extra: Record<string, unknown> = {}) {
function startStudioRender(extra: Record<string, unknown> = {}, receivedFiles?: string[]) {
const dir = mkdtempSync(join(tmpdir(), "hf-studio-render-browser-"));
dirs.push(dir);
writeFileSync(join(dir, "index.html"), `<div data-composition-src="scene.html"></div>`);
writeFileSync(join(dir, "scene.html"), "<div></div>");
writeFileSync(join(dir, "other.html"), "<div></div>");
if (receivedFiles) {
mkdirSync(join(dir, ".hyperframes"));
writeFileSync(
join(dir, ".hyperframes", "received-files.json"),
JSON.stringify({ files: receivedFiles }),
);
}
server = createStudioServer({ projectDir: dir });
return server.adapter.startRender({
project: { dir, id: "p", title: "p" },
Expand Down Expand Up @@ -137,3 +147,43 @@ describe("Studio render motion blur", () => {
);
});
});

describe("Studio render of a received composition", () => {
it.each([
{ name: "a received entry", extra: {}, files: ["index.html"], allowed: false },
{
name: "a received composition picked to render",
extra: { composition: "scene.html" },
files: ["scene.html"],
allowed: false,
},
{
name: "the person's own entry playing a received composition",
extra: {},
files: ["scene.html"],
allowed: false,
},
{
name: "a record listing a file the render never opens",
extra: {},
files: ["other.html"],
allowed: false,
},
{ name: "a record listing no files", extra: {}, files: [], allowed: true },
{ name: "no received-files record", extra: {}, files: undefined, allowed: true },
])("brings in outside files for $name: $allowed", async ({ extra, files, allowed }) => {
mocks.resolveRenderBrowser.mockResolvedValue({
executablePath: "/opt/chrome",
source: "cache",
});

startStudioRender(extra, files);
await vi.waitFor(() => expect(mocks.createRenderJob).toHaveBeenCalledTimes(1), {
timeout: 10_000,
});

expect(mocks.createRenderJob).toHaveBeenCalledWith(
expect.objectContaining({ allowOutsideProjectAssets: allowed }),
);
});
});
8 changes: 7 additions & 1 deletion packages/cli/src/server/studioServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from "@hyperframes/studio-server/request-identity";
import { mountShareRoutes } from "./shareRoutes.js";
import { isDevMode } from "../utils/env.js";
import { outsideAssetsAllowed } from "../utils/receivedRender.js";
import { insideHostApp } from "../utils/desktopApp.js";
import { runRenderSetupWorker } from "../utils/cancellableProcess.js";
import { acquireRenderLock, describeRenderLockHolder } from "../utils/renderLock.js";
Expand Down Expand Up @@ -667,6 +668,11 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
process.env.PRODUCER_HEADLESS_SHELL_PATH = browser.executablePath;
}

const allowOutsideProjectAssets = outsideAssetsAllowed(
opts.project.dir,
opts.composition,
(line) => console.warn(`[studio] ${line}`),
);
const manifestContent = readStudioManualEditManifestContent(opts.project.dir);
const manualEditsRenderScript = createStudioManualEditsRenderBodyScript(manifestContent);
const job = createRenderJob({
Expand All @@ -683,7 +689,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
...encoderJobOptions(opts),
...(opts.useGpu ? { useGpu: true } : {}),
...(opts.pageMotionBlur ? { pageMotionBlur: opts.pageMotionBlur } : {}),
allowOutsideProjectAssets: true,
allowOutsideProjectAssets,
});
renderJob = job;
const onProgress = (j: { progress: number; currentStage?: string }) => {
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/utils/compositionEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { errorBox } from "../ui/format.js";
import { failUsage } from "./commandResult.js";

export type CompositionEntryParseError = {
kind: "outside-project" | "not-found" | "not-a-file";
kind: "outside-project" | "not-found" | "not-a-file" | "not-html";
entryFile: string;
entryPath: string;
projectDir: string;
Expand Down Expand Up @@ -56,6 +56,7 @@ export function parseCompositionEntryArg(
// A directory would pass existsSync downstream and fail with EISDIR in the producer.
return fail("not-a-file");
}
if (!/\.html?$/i.test(entryPath)) return fail("not-html");
return { ok: true, value: relativeEntry.split(sep).join("/") };
}

Expand Down Expand Up @@ -92,6 +93,12 @@ export function compositionEntryErrorMessage(error: CompositionEntryParseError):
message: `${resolved}, a directory, not an .html file (project directory ${error.projectDir}).`,
hint: "Pass a path to a .html file (e.g. compositions/intro.html), or omit --composition to render index.html.",
};
case "not-html":
return {
title: "Invalid composition path",
message: `${resolved}, which is not an .html file, so it is refused.`,
hint: "Pass a path to a .html or .htm file (e.g. compositions/intro.html).",
};
}
}

Expand Down
63 changes: 61 additions & 2 deletions packages/cli/src/utils/compositionServer.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { afterEach, describe, expect, it } from "vitest";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { hostname, networkInterfaces, tmpdir } from "node:os";
import { join } from "node:path";
import { buildRangeResponse } from "./compositionServer.js";
import { Hono } from "hono";
import { buildRangeResponse, refuseUnknownHosts } from "./compositionServer.js";

const TAGGED_PNG = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGNJQ1ABAQABlXPCVgAAAAxJREFUeJxj0NfXBwABHgCOTp25kgAAAABJRU5ErkJggg==",
Expand Down Expand Up @@ -30,3 +31,61 @@ describe("buildRangeResponse colour-tagged PNGs", () => {
expect(res.headers.get("content-length")).toBe(String(body.length));
});
});

describe("refuseUnknownHosts", () => {
const ENV = "HYPERFRAMES_PREVIEW_ALLOWED_HOSTS";

afterEach(() => {
delete process.env[ENV];
});

function guardedApp(): Hono {
const app = new Hono();
refuseUnknownHosts(app);
app.get("/composition/*", (c) => c.text("project file"));
return app;
}

function get(app: Hono, host: string): Promise<Response> {
return Promise.resolve(app.request("/composition/package.json", { headers: { host } }));
}

function lanAddress(): string | undefined {
for (const entries of Object.values(networkInterfaces())) {
for (const entry of entries ?? []) {
if (entry.family === "IPv4" && !entry.internal) return entry.address;
}
}
return undefined;
}

it("answers localhost and loopback addresses", async () => {
const app = guardedApp();
for (const host of ["localhost:3003", "127.0.0.1:3003", "[::1]:3003"]) {
expect((await get(app, host)).status, host).toBe(200);
}
});

it("answers this machine's LAN address and .local name, so another device can open it", async () => {
const app = guardedApp();
const lan = lanAddress();
if (lan) expect((await get(app, `${lan}:3003`)).status).toBe(200);
const short = hostname().toLowerCase().split(".")[0];
if (short) expect((await get(app, `${short}.local:3003`)).status).toBe(200);
});

it("refuses any other host name and names the setting that allows it", async () => {
const res = await get(guardedApp(), "rebound.example:3003");
expect(res.status).toBe(403);
const text = await res.text();
expect(text).not.toContain("project file");
expect(text).toContain(`${ENV}=rebound.example:3003`);
});

it("answers a host named in HYPERFRAMES_PREVIEW_ALLOWED_HOSTS", async () => {
process.env[ENV] = "other.example, demo.tunnels.example";
const res = await get(guardedApp(), "demo.tunnels.example");
expect(res.status).toBe(200);
expect(await res.text()).toBe("project file");
});
});
Loading
Loading