mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(producer): build the render job before taking a render slot A request whose options fail the strict render-request validator now gets a 400 on both the blocking and streaming routes, and its inline project directory is removed. Validate workers up front like the other overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(producer): write compiled sub-compositions only inside the compiled directory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): keep media work files inside their directory for any element id Map a media element id to one plain path segment before it names a frame directory or an intermediate audio file. Ids that already are one plain segment map to themselves, so existing paths stay the same; the producer and the distributed plan derive the same segment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): listen on loopback by default in the engine file server The file server feeds the co-located capture browser, which loads it from localhost. A caller that wants another interface passes hostname. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(producer): refuse cross-origin browser posts to the standalone render server A web page on another origin can no longer start a render or lint through the server's POST routes. Requests without an Origin header (CLI tools, server-to-server callers) and same-origin pages are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(engine): trim comments on the media path segment and file server host Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(producer): trust the browser's Sec-Fetch-Site verdict for render server posts A same-origin page behind a reverse proxy that rewrites the Host header sent an Origin that no longer matched Host, so the cross-origin guard refused it. The guard now uses Sec-Fetch-Site when the browser sends it and falls back to the Origin and Host comparison only for browsers that do not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): keep generated media path names apart from plain ids and within filename limits A plain media id that already ends like a generated name now takes the hashed branch too, so it can no longer share frame folders or audio work files with the unsafe id that produced that name. The readable part of a generated name is capped at 64 UTF-8 bytes before the digest, so long or multibyte ids that contain separators stay within the 255-byte filename limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { networkInterfaces, tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { createFileServer } from "./fileServer.js";
|
|
|
|
describe("file server media responses", () => {
|
|
it.each([
|
|
["avif", "image/avif"],
|
|
["flac", "audio/flac"],
|
|
["M4A", "audio/mp4"],
|
|
["mov", "video/quicktime"],
|
|
["ico", "image/vnd.microsoft.icon"],
|
|
])("serves .%s with its content type and unchanged bytes", async (ext, type) => {
|
|
const projectDir = mkdtempSync(join(tmpdir(), "hf-engine-media-type-"));
|
|
const bytes = new Uint8Array([0, 255, 128, 64, 32]);
|
|
try {
|
|
writeFileSync(join(projectDir, `asset.${ext}`), bytes);
|
|
const server = await createFileServer({ projectDir });
|
|
try {
|
|
const response = await fetch(`${server.url}/asset.${ext}`);
|
|
expect(response.status).toBe(200);
|
|
expect(response.headers.get("content-type")).toBe(type);
|
|
expect(new Uint8Array(await response.arrayBuffer())).toEqual(bytes);
|
|
} finally {
|
|
server.close();
|
|
}
|
|
} finally {
|
|
rmSync(projectDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
function firstExternalIpv4(): string | undefined {
|
|
return Object.values(networkInterfaces())
|
|
.flat()
|
|
.find((address) => address?.family === "IPv4" && !address.internal)?.address;
|
|
}
|
|
|
|
describe("file server listener", () => {
|
|
it("answers on loopback and not on another interface", async () => {
|
|
const projectDir = mkdtempSync(join(tmpdir(), "hf-engine-bind-"));
|
|
try {
|
|
writeFileSync(join(projectDir, "index.html"), "<html></html>");
|
|
const server = await createFileServer({ projectDir });
|
|
try {
|
|
expect((await fetch(`${server.url}/index.html`)).status).toBe(200);
|
|
expect((await fetch(`http://127.0.0.1:${server.port}/index.html`)).status).toBe(200);
|
|
const external = firstExternalIpv4();
|
|
if (external) {
|
|
const remote = fetch(`http://${external}:${server.port}/index.html`, {
|
|
signal: AbortSignal.timeout(1_000),
|
|
});
|
|
await expect(remote).rejects.toThrow();
|
|
}
|
|
} finally {
|
|
server.close();
|
|
}
|
|
} finally {
|
|
rmSync(projectDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|