{"draft":null,"from":7,"to":318,"files":[{"path":"server/test/small-frame-json.test.ts","added":21,"removed":0,"diff":"--- /dev/null\n+++ b/server/test/small-frame-json.test.ts\n@@ -0,0 +1,21 @@\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { smallFrameJson } from \"../src/small-frame-json.ts\";\n+\n+test(\"small frame decoding enforces a byte bound and streamed parser rules\", () => {\n+\tassert.deepEqual(smallFrameJson(['{\"type\":\"jo', 'in\",\"agent\":\"alice\"}']), { type: \"join\", agent: \"alice\" });\n+\tassert.deepEqual(smallFrameJson(['{\"x\":1,\"x\":2}']), { x: 2 });\n+\tassert.throws(() => smallFrameJson(['\"' + \"\\u00e9\".repeat(2048) + '\"']), /exceeds bound/);\n+\tassert.throws(() => smallFrameJson([\"[\".repeat(130) + \"0\" + \"]\".repeat(130)]), /nesting/);\n+\tassert.throws(() => smallFrameJson([\"1\" + \"0\".repeat(256)]), /scalar/);\n+\tassert.throws(() => smallFrameJson([\"{} trailing\"]), /trailing/);\n+});\n+test(\"small frame byte accounting handles a split surrogate pair at the limit\", () => {\n+\tconst pair = String.fromCodePoint(0x1f600);\n+\tconst body = \"x\".repeat(4090) + pair;\n+\tconst json = JSON.stringify(body);\n+\tassert.equal(new TextEncoder().encode(json).byteLength, 4096);\n+\tconst split = json.indexOf(pair) + 1;\n+\tassert.equal(smallFrameJson([json.slice(0, split), json.slice(split)]), body);\n+\tassert.throws(() => smallFrameJson([JSON.stringify(body + \"x\")]), /exceeds bound/);\n+});"}],"unmatched":[]}