@kodelyth/diffs 2026.5.42 → 2026.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -2
- package/api.ts +0 -10
- package/assets/viewer-runtime.js +0 -21390
- package/index.ts +0 -11
- package/runtime-api.ts +0 -1
- package/src/browser.test.ts +0 -686
- package/src/browser.ts +0 -564
- package/src/config.test.ts +0 -573
- package/src/config.ts +0 -443
- package/src/http.ts +0 -324
- package/src/language-hints.test.ts +0 -156
- package/src/language-hints.ts +0 -117
- package/src/manifest.test.ts +0 -16
- package/src/pierre-themes.ts +0 -59
- package/src/plugin.ts +0 -67
- package/src/prompt-guidance.ts +0 -7
- package/src/render-target.test.ts +0 -132
- package/src/render.test.ts +0 -219
- package/src/render.ts +0 -557
- package/src/store.test.ts +0 -462
- package/src/store.ts +0 -387
- package/src/test-helpers.ts +0 -30
- package/src/tool-render-output.test.ts +0 -107
- package/src/tool.test.ts +0 -646
- package/src/tool.ts +0 -547
- package/src/types.ts +0 -127
- package/src/url.ts +0 -60
- package/src/viewer-assets.ts +0 -103
- package/src/viewer-client.ts +0 -353
- package/src/viewer-payload.ts +0 -94
- package/tsconfig.json +0 -16
package/src/store.test.ts
DELETED
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import type { IncomingMessage } from "node:http";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { createMockServerResponse } from "klaw/plugin-sdk/test-env";
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import { createDiffsHttpHandler } from "./http.js";
|
|
7
|
-
import { DiffArtifactStore } from "./store.js";
|
|
8
|
-
import { createDiffStoreHarness } from "./test-helpers.js";
|
|
9
|
-
|
|
10
|
-
describe("DiffArtifactStore", () => {
|
|
11
|
-
let rootDir: string;
|
|
12
|
-
let store: DiffArtifactStore;
|
|
13
|
-
let cleanupRootDir: () => Promise<void>;
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
({
|
|
17
|
-
rootDir,
|
|
18
|
-
store,
|
|
19
|
-
cleanup: cleanupRootDir,
|
|
20
|
-
} = await createDiffStoreHarness("klaw-diffs-store-"));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
afterEach(async () => {
|
|
24
|
-
vi.useRealTimers();
|
|
25
|
-
await cleanupRootDir();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("creates and retrieves an artifact", async () => {
|
|
29
|
-
const artifact = await store.createArtifact({
|
|
30
|
-
html: "<html>demo</html>",
|
|
31
|
-
title: "Demo",
|
|
32
|
-
inputKind: "before_after",
|
|
33
|
-
fileCount: 1,
|
|
34
|
-
context: {
|
|
35
|
-
agentId: "main",
|
|
36
|
-
sessionId: "session-123",
|
|
37
|
-
messageChannel: "discord",
|
|
38
|
-
agentAccountId: "default",
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const loaded = await store.getArtifact(artifact.id, artifact.token);
|
|
43
|
-
expect(loaded?.id).toBe(artifact.id);
|
|
44
|
-
expect(loaded?.context).toEqual({
|
|
45
|
-
agentId: "main",
|
|
46
|
-
sessionId: "session-123",
|
|
47
|
-
messageChannel: "discord",
|
|
48
|
-
agentAccountId: "default",
|
|
49
|
-
});
|
|
50
|
-
expect(await store.readHtml(artifact.id)).toBe("<html>demo</html>");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("expires artifacts after the ttl", async () => {
|
|
54
|
-
vi.useFakeTimers();
|
|
55
|
-
const now = new Date("2026-02-27T16:00:00Z");
|
|
56
|
-
vi.setSystemTime(now);
|
|
57
|
-
|
|
58
|
-
const artifact = await store.createArtifact({
|
|
59
|
-
html: "<html>demo</html>",
|
|
60
|
-
title: "Demo",
|
|
61
|
-
inputKind: "patch",
|
|
62
|
-
fileCount: 2,
|
|
63
|
-
ttlMs: 1_000,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
vi.setSystemTime(new Date(now.getTime() + 2_000));
|
|
67
|
-
const loaded = await store.getArtifact(artifact.id, artifact.token);
|
|
68
|
-
expect(loaded).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("updates the stored file path", async () => {
|
|
72
|
-
const artifact = await store.createArtifact({
|
|
73
|
-
html: "<html>demo</html>",
|
|
74
|
-
title: "Demo",
|
|
75
|
-
inputKind: "before_after",
|
|
76
|
-
fileCount: 1,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const filePath = store.allocateFilePath(artifact.id);
|
|
80
|
-
const updated = await store.updateFilePath(artifact.id, filePath);
|
|
81
|
-
expect(updated.filePath).toBe(filePath);
|
|
82
|
-
expect(updated.imagePath).toBe(filePath);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("rejects file paths that escape the store root", async () => {
|
|
86
|
-
const artifact = await store.createArtifact({
|
|
87
|
-
html: "<html>demo</html>",
|
|
88
|
-
title: "Demo",
|
|
89
|
-
inputKind: "before_after",
|
|
90
|
-
fileCount: 1,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
await expect(store.updateFilePath(artifact.id, "../outside.png")).rejects.toThrow(
|
|
94
|
-
"escapes store root",
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("rejects tampered html metadata paths outside the store root", async () => {
|
|
99
|
-
const artifact = await store.createArtifact({
|
|
100
|
-
html: "<html>demo</html>",
|
|
101
|
-
title: "Demo",
|
|
102
|
-
inputKind: "before_after",
|
|
103
|
-
fileCount: 1,
|
|
104
|
-
});
|
|
105
|
-
const metaPath = path.join(rootDir, artifact.id, "meta.json");
|
|
106
|
-
const rawMeta = await fs.readFile(metaPath, "utf8");
|
|
107
|
-
const meta = JSON.parse(rawMeta) as { htmlPath: string };
|
|
108
|
-
meta.htmlPath = "../outside.html";
|
|
109
|
-
await fs.writeFile(metaPath, JSON.stringify(meta), "utf8");
|
|
110
|
-
|
|
111
|
-
await expect(store.readHtml(artifact.id)).rejects.toThrow("escapes store root");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("creates standalone file artifacts with managed metadata", async () => {
|
|
115
|
-
const standalone = await store.createStandaloneFileArtifact({
|
|
116
|
-
context: {
|
|
117
|
-
agentId: "main",
|
|
118
|
-
sessionId: "session-123",
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
expect(standalone.filePath).toMatch(/preview\.png$/);
|
|
122
|
-
expect(standalone.filePath).toContain(rootDir);
|
|
123
|
-
expect(Date.parse(standalone.expiresAt)).toBeGreaterThan(Date.now());
|
|
124
|
-
expect(standalone.context).toEqual({
|
|
125
|
-
agentId: "main",
|
|
126
|
-
sessionId: "session-123",
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("expires standalone file artifacts using ttl metadata", async () => {
|
|
131
|
-
vi.useFakeTimers();
|
|
132
|
-
const now = new Date("2026-02-27T16:00:00Z");
|
|
133
|
-
vi.setSystemTime(now);
|
|
134
|
-
|
|
135
|
-
const standalone = await store.createStandaloneFileArtifact({
|
|
136
|
-
format: "png",
|
|
137
|
-
ttlMs: 1_000,
|
|
138
|
-
});
|
|
139
|
-
await fs.writeFile(standalone.filePath, Buffer.from("png"));
|
|
140
|
-
|
|
141
|
-
vi.setSystemTime(new Date(now.getTime() + 2_000));
|
|
142
|
-
await store.cleanupExpired();
|
|
143
|
-
|
|
144
|
-
const error = await fs.stat(path.dirname(standalone.filePath)).then(
|
|
145
|
-
() => undefined,
|
|
146
|
-
(statError: unknown) => statError,
|
|
147
|
-
);
|
|
148
|
-
expect(error).toBeInstanceOf(Error);
|
|
149
|
-
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("supports image path aliases for backward compatibility", async () => {
|
|
153
|
-
const artifact = await store.createArtifact({
|
|
154
|
-
html: "<html>demo</html>",
|
|
155
|
-
title: "Demo",
|
|
156
|
-
inputKind: "before_after",
|
|
157
|
-
fileCount: 1,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const imagePath = store.allocateImagePath(artifact.id, "pdf");
|
|
161
|
-
expect(imagePath).toMatch(/preview\.pdf$/);
|
|
162
|
-
const standalone = await store.createStandaloneFileArtifact();
|
|
163
|
-
expect(standalone.filePath).toMatch(/preview\.png$/);
|
|
164
|
-
|
|
165
|
-
const updated = await store.updateImagePath(artifact.id, imagePath);
|
|
166
|
-
expect(updated.filePath).toBe(imagePath);
|
|
167
|
-
expect(updated.imagePath).toBe(imagePath);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("allocates PDF file paths when format is pdf", async () => {
|
|
171
|
-
const artifact = await store.createArtifact({
|
|
172
|
-
html: "<html>demo</html>",
|
|
173
|
-
title: "Demo",
|
|
174
|
-
inputKind: "before_after",
|
|
175
|
-
fileCount: 1,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const artifactPdf = store.allocateFilePath(artifact.id, "pdf");
|
|
179
|
-
const standalonePdf = await store.createStandaloneFileArtifact({ format: "pdf" });
|
|
180
|
-
expect(artifactPdf).toMatch(/preview\.pdf$/);
|
|
181
|
-
expect(standalonePdf.filePath).toMatch(/preview\.pdf$/);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("throttles cleanup sweeps across repeated artifact creation", async () => {
|
|
185
|
-
vi.useFakeTimers();
|
|
186
|
-
const now = new Date("2026-02-27T16:00:00Z");
|
|
187
|
-
vi.setSystemTime(now);
|
|
188
|
-
store = new DiffArtifactStore({
|
|
189
|
-
rootDir,
|
|
190
|
-
cleanupIntervalMs: 60_000,
|
|
191
|
-
});
|
|
192
|
-
const cleanupSpy = vi.spyOn(store, "cleanupExpired").mockResolvedValue();
|
|
193
|
-
|
|
194
|
-
await store.createArtifact({
|
|
195
|
-
html: "<html>one</html>",
|
|
196
|
-
title: "One",
|
|
197
|
-
inputKind: "before_after",
|
|
198
|
-
fileCount: 1,
|
|
199
|
-
});
|
|
200
|
-
await store.createArtifact({
|
|
201
|
-
html: "<html>two</html>",
|
|
202
|
-
title: "Two",
|
|
203
|
-
inputKind: "before_after",
|
|
204
|
-
fileCount: 1,
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
expect(cleanupSpy).toHaveBeenCalledTimes(1);
|
|
208
|
-
|
|
209
|
-
vi.setSystemTime(new Date(now.getTime() + 61_000));
|
|
210
|
-
await store.createArtifact({
|
|
211
|
-
html: "<html>three</html>",
|
|
212
|
-
title: "Three",
|
|
213
|
-
inputKind: "before_after",
|
|
214
|
-
fileCount: 1,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
expect(cleanupSpy).toHaveBeenCalledTimes(2);
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
describe("createDiffsHttpHandler", () => {
|
|
222
|
-
let store: DiffArtifactStore;
|
|
223
|
-
let cleanupRootDir: () => Promise<void>;
|
|
224
|
-
|
|
225
|
-
async function handleLocalGet(url: string) {
|
|
226
|
-
const handler = createDiffsHttpHandler({ store });
|
|
227
|
-
const res = createMockServerResponse();
|
|
228
|
-
const handled = await handler(
|
|
229
|
-
localReq({
|
|
230
|
-
method: "GET",
|
|
231
|
-
url,
|
|
232
|
-
}),
|
|
233
|
-
res,
|
|
234
|
-
);
|
|
235
|
-
return { handled, res };
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
beforeEach(async () => {
|
|
239
|
-
({ store, cleanup: cleanupRootDir } = await createDiffStoreHarness("klaw-diffs-http-"));
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
afterEach(async () => {
|
|
243
|
-
await cleanupRootDir();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it("serves a stored diff document", async () => {
|
|
247
|
-
const artifact = await createViewerArtifact(store);
|
|
248
|
-
const { handled, res } = await handleLocalGet(artifact.viewerPath);
|
|
249
|
-
|
|
250
|
-
expect(handled).toBe(true);
|
|
251
|
-
expect(res.statusCode).toBe(200);
|
|
252
|
-
expect(res.body).toBe("<html>viewer</html>");
|
|
253
|
-
expect(res.getHeader("content-security-policy")).toContain("default-src 'none'");
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it("rejects invalid tokens", async () => {
|
|
257
|
-
const artifact = await createViewerArtifact(store);
|
|
258
|
-
const { handled, res } = await handleLocalGet(
|
|
259
|
-
artifact.viewerPath.replace(artifact.token, "bad-token"),
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
expect(handled).toBe(true);
|
|
263
|
-
expect(res.statusCode).toBe(404);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it("rejects malformed artifact ids before reading from disk", async () => {
|
|
267
|
-
const handler = createDiffsHttpHandler({ store });
|
|
268
|
-
const res = createMockServerResponse();
|
|
269
|
-
const handled = await handler(
|
|
270
|
-
localReq({
|
|
271
|
-
method: "GET",
|
|
272
|
-
url: "/plugins/diffs/view/not-a-real-id/not-a-real-token",
|
|
273
|
-
}),
|
|
274
|
-
res,
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
expect(handled).toBe(true);
|
|
278
|
-
expect(res.statusCode).toBe(404);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("serves the shared viewer asset", async () => {
|
|
282
|
-
const handler = createDiffsHttpHandler({ store });
|
|
283
|
-
const res = createMockServerResponse();
|
|
284
|
-
const handled = await handler(
|
|
285
|
-
localReq({
|
|
286
|
-
method: "GET",
|
|
287
|
-
url: "/plugins/diffs/assets/viewer.js",
|
|
288
|
-
}),
|
|
289
|
-
res,
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
expect(handled).toBe(true);
|
|
293
|
-
expect(res.statusCode).toBe(200);
|
|
294
|
-
expect(String(res.body)).toContain("./viewer-runtime.js?v=");
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("serves the shared viewer runtime asset", async () => {
|
|
298
|
-
const handler = createDiffsHttpHandler({ store });
|
|
299
|
-
const res = createMockServerResponse();
|
|
300
|
-
const handled = await handler(
|
|
301
|
-
localReq({
|
|
302
|
-
method: "GET",
|
|
303
|
-
url: "/plugins/diffs/assets/viewer-runtime.js",
|
|
304
|
-
}),
|
|
305
|
-
res,
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
expect(handled).toBe(true);
|
|
309
|
-
expect(res.statusCode).toBe(200);
|
|
310
|
-
expect(String(res.body)).toContain("klawDiffsReady");
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it.each([
|
|
314
|
-
{
|
|
315
|
-
name: "allows direct loopback viewer access by default",
|
|
316
|
-
request: localReq,
|
|
317
|
-
allowRemoteViewer: false,
|
|
318
|
-
expectedStatusCode: 200,
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
name: "allows ipv4-mapped ipv6 loopback viewer access by default",
|
|
322
|
-
request: ipv4MappedLoopbackReq,
|
|
323
|
-
allowRemoteViewer: false,
|
|
324
|
-
expectedStatusCode: 200,
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
name: "blocks non-loopback viewer access by default",
|
|
328
|
-
request: remoteReq,
|
|
329
|
-
allowRemoteViewer: false,
|
|
330
|
-
expectedStatusCode: 404,
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
name: "blocks loopback requests that carry proxy forwarding headers by default",
|
|
334
|
-
request: localReq,
|
|
335
|
-
headers: { "x-forwarded-for": "203.0.113.10" },
|
|
336
|
-
allowRemoteViewer: false,
|
|
337
|
-
expectedStatusCode: 404,
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
name: "blocks trusted-proxy loopback requests without client-origin headers by default",
|
|
341
|
-
request: localReq,
|
|
342
|
-
trustedProxies: ["127.0.0.1"],
|
|
343
|
-
allowRemoteViewer: false,
|
|
344
|
-
expectedStatusCode: 404,
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
name: "blocks proxied loopback requests when trusted proxies are configured",
|
|
348
|
-
request: localReq,
|
|
349
|
-
headers: { "x-forwarded-for": "203.0.113.10" },
|
|
350
|
-
trustedProxies: ["127.0.0.1"],
|
|
351
|
-
allowRemoteViewer: false,
|
|
352
|
-
expectedStatusCode: 404,
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
name: "allows remote access when allowRemoteViewer is enabled",
|
|
356
|
-
request: remoteReq,
|
|
357
|
-
allowRemoteViewer: true,
|
|
358
|
-
expectedStatusCode: 200,
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
name: "allows proxied loopback requests when allowRemoteViewer is enabled",
|
|
362
|
-
request: localReq,
|
|
363
|
-
headers: { "x-forwarded-for": "203.0.113.10" },
|
|
364
|
-
trustedProxies: ["127.0.0.1"],
|
|
365
|
-
allowRemoteViewer: true,
|
|
366
|
-
expectedStatusCode: 200,
|
|
367
|
-
},
|
|
368
|
-
])(
|
|
369
|
-
"$name",
|
|
370
|
-
async ({ request, headers, trustedProxies, allowRemoteViewer, expectedStatusCode }) => {
|
|
371
|
-
const artifact = await createViewerArtifact(store);
|
|
372
|
-
|
|
373
|
-
const handler = createDiffsHttpHandler({ store, allowRemoteViewer, trustedProxies });
|
|
374
|
-
const res = createMockServerResponse();
|
|
375
|
-
const handled = await handler(
|
|
376
|
-
request({
|
|
377
|
-
method: "GET",
|
|
378
|
-
url: artifact.viewerPath,
|
|
379
|
-
headers,
|
|
380
|
-
}),
|
|
381
|
-
res,
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
expect(handled).toBe(true);
|
|
385
|
-
expect(res.statusCode).toBe(expectedStatusCode);
|
|
386
|
-
if (expectedStatusCode === 200) {
|
|
387
|
-
expect(res.body).toBe("<html>viewer</html>");
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
it("rate-limits repeated remote misses", async () => {
|
|
393
|
-
const handler = createDiffsHttpHandler({ store, allowRemoteViewer: true });
|
|
394
|
-
|
|
395
|
-
for (let i = 0; i < 40; i++) {
|
|
396
|
-
const miss = createMockServerResponse();
|
|
397
|
-
await handler(
|
|
398
|
-
remoteReq({
|
|
399
|
-
method: "GET",
|
|
400
|
-
url: "/plugins/diffs/view/aaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
401
|
-
}),
|
|
402
|
-
miss,
|
|
403
|
-
);
|
|
404
|
-
expect(miss.statusCode).toBe(404);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const limited = createMockServerResponse();
|
|
408
|
-
await handler(
|
|
409
|
-
remoteReq({
|
|
410
|
-
method: "GET",
|
|
411
|
-
url: "/plugins/diffs/view/aaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
412
|
-
}),
|
|
413
|
-
limited,
|
|
414
|
-
);
|
|
415
|
-
expect(limited.statusCode).toBe(429);
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
async function createViewerArtifact(store: DiffArtifactStore) {
|
|
420
|
-
return await store.createArtifact({
|
|
421
|
-
html: "<html>viewer</html>",
|
|
422
|
-
title: "Demo",
|
|
423
|
-
inputKind: "before_after",
|
|
424
|
-
fileCount: 1,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
function localReq(input: {
|
|
429
|
-
method: string;
|
|
430
|
-
url: string;
|
|
431
|
-
headers?: Record<string, string>;
|
|
432
|
-
}): IncomingMessage {
|
|
433
|
-
return {
|
|
434
|
-
...input,
|
|
435
|
-
headers: input.headers ?? {},
|
|
436
|
-
socket: { remoteAddress: "127.0.0.1" },
|
|
437
|
-
} as unknown as IncomingMessage;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function remoteReq(input: {
|
|
441
|
-
method: string;
|
|
442
|
-
url: string;
|
|
443
|
-
headers?: Record<string, string>;
|
|
444
|
-
}): IncomingMessage {
|
|
445
|
-
return {
|
|
446
|
-
...input,
|
|
447
|
-
headers: input.headers ?? {},
|
|
448
|
-
socket: { remoteAddress: "203.0.113.10" },
|
|
449
|
-
} as unknown as IncomingMessage;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function ipv4MappedLoopbackReq(input: {
|
|
453
|
-
method: string;
|
|
454
|
-
url: string;
|
|
455
|
-
headers?: Record<string, string>;
|
|
456
|
-
}): IncomingMessage {
|
|
457
|
-
return {
|
|
458
|
-
...input,
|
|
459
|
-
headers: input.headers ?? {},
|
|
460
|
-
socket: { remoteAddress: "::ffff:127.0.0.1" },
|
|
461
|
-
} as unknown as IncomingMessage;
|
|
462
|
-
}
|