Bound native media preview capabilities and source range reads

This commit is contained in:
karl committed 2026-10-13 14:22:19 +02:00
1 parent 4b0b5ebfd9
commit 370db7e791
13 files changed
+834 -46

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import test from "node:test";
import assert from "node:assert/strict";
import { nativePreviewToken } from "../src/media-access.ts";
test("native preview accepts only opaque grants, never paths or destinations", () => {
const token = "a123456789abcdef0123456789abcdef";
assert.equal(nativePreviewToken(token), token);
for (const value of [
"C:/Users/karl/photo.jpg",
"/home/user/video.mp4",
"https://example.com/media",
"../" + token,
token + "?file=secret",
"%2f" + token,
"",
token.toUpperCase(),
]) {
assert.throws(() => nativePreviewToken(value), /preview access/);
}
});