From 0d69bd4975cc2efb6e816a95d2956789d536cb86 Mon Sep 17 00:00:00 2001 From: starsstreaming <2946843254lw@gmail.com> Date: Thu, 30 Jul 2026 10:02:43 +0800 Subject: [PATCH] raise video import limit to 800 MiB --- docs/media-contract.md | 2 +- packages/core/src/constants.ts | 2 +- packages/core/test/media-validation.test.js | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/media-contract.md b/docs/media-contract.md index eacab70..b6f7afc 100644 --- a/docs/media-contract.md +++ b/docs/media-contract.md @@ -57,7 +57,7 @@ Rules: | Extension | `.mp4` only | | Type | regular file after `lstat` + `realpath` | | Symlink / reparse | rejected | -| Size | `1 byte … 500 MiB` | +| Size | `1 byte … 800 MiB` | | Container | first ISO-BMFF box size sane and type `ftyp` | | Companion image | required | diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index 47448b1..92aad99 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -3,7 +3,7 @@ export const SCHEMA_ID = "beauticode.background/v1" as const; // Images are embedded into one CDP Runtime.evaluate payload. Keep validation // and injection limits identical so an accepted import is always publishable. export const MAX_IMAGE_BYTES = 18 * 1024 * 1024; -export const MAX_VIDEO_BYTES = 500 * 1024 * 1024; +export const MAX_VIDEO_BYTES = 800 * 1024 * 1024; /** * Max raw media bytes embedded as a data: URL inside one CDP evaluate. diff --git a/packages/core/test/media-validation.test.js b/packages/core/test/media-validation.test.js index 7b10c25..83ab402 100644 --- a/packages/core/test/media-validation.test.js +++ b/packages/core/test/media-validation.test.js @@ -3,6 +3,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import test from "node:test"; +import { MAX_VIDEO_BYTES } from "../dist/constants.js"; import { assertSafeBasename, isMp4Container, @@ -77,6 +78,23 @@ test("validateVideoFile enforces extension, size, ftyp, no symlink", async () => } }); +test("validateVideoFile defaults to an 800 MiB limit", async () => { + assert.equal(MAX_VIDEO_BYTES, 800 * 1024 * 1024); + + const root = await fs.mkdtemp(path.join(os.tmpdir(), "bc-video-limit-")); + try { + const oversized = path.join(root, "oversized.mp4"); + await fs.writeFile(oversized, mp4Fixture()); + await fs.truncate(oversized, MAX_VIDEO_BYTES + 1); + await assert.rejects( + () => validateVideoFile(oversized), + /no larger than 838860800 bytes/, + ); + } finally { + await fs.rm(root, { recursive: true, force: true }); + } +}); + test("validateImageFile checks magic bytes", async () => { const root = await fs.mkdtemp(path.join(os.tmpdir(), "bc-img-")); try {