Support multi-screenshot calibration and cached shop context

This commit is contained in:
2026-08-11 17:43:32 +03:00
parent f87a65bb04
commit cf1cb41f04
8 changed files with 507 additions and 84 deletions
+10 -1
View File
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
import { forwardMarketBatch } from "../vite.config.js";
import { forwardMarketBatch, rejectNonLocalRequest } from "../vite.config.js";
test("keeps the import token in the local server-side forwarder", async () => {
let forwarded;
@@ -19,3 +19,12 @@ test("keeps the import token in the local server-side forwarder", async () => {
assert.equal(forwarded.init.body, '{"batchId":"one"}');
assert.equal((await forwardMarketBatch("{}", {})).status, 503);
});
test("rejects cross-site and non-JSON calls before using the import token", () => {
assert.equal(
rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "http://127.0.0.1:5173", "content-type": "application/json" } }),
null,
);
assert.equal(rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "https://evil.example", "content-type": "application/json" } }), 403);
assert.equal(rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "http://127.0.0.1:5173", "content-type": "text/plain" } }), 415);
});