@acepaste/ingress 0.9.1 → 0.9.21

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.
Files changed (81) hide show
  1. package/LICENSE +1 -1
  2. package/dist/src/adapters.d.ts +9 -0
  3. package/dist/src/adapters.js +76 -6
  4. package/dist/src/agent-hooks.d.ts +112 -0
  5. package/dist/src/agent-hooks.js +533 -0
  6. package/dist/src/approvers.d.ts +16 -0
  7. package/dist/src/approvers.js +50 -0
  8. package/dist/src/audio.d.ts +70 -0
  9. package/dist/src/audio.js +224 -0
  10. package/dist/src/audit-changes.d.ts +46 -0
  11. package/dist/src/audit-changes.js +110 -0
  12. package/dist/src/audit-local.d.ts +57 -0
  13. package/dist/src/audit-local.js +231 -0
  14. package/dist/src/audit-parsers.d.ts +1 -1
  15. package/dist/src/audit.js +48 -0
  16. package/dist/src/broker.d.ts +92 -1
  17. package/dist/src/broker.js +222 -3
  18. package/dist/src/calendar.d.ts +36 -0
  19. package/dist/src/calendar.js +227 -0
  20. package/dist/src/captions.d.ts +44 -0
  21. package/dist/src/captions.js +209 -0
  22. package/dist/src/changes.d.ts +105 -0
  23. package/dist/src/changes.js +174 -0
  24. package/dist/src/character.js +19 -3
  25. package/dist/src/classifier-model.d.ts +53 -0
  26. package/dist/src/classifier-model.js +3 -0
  27. package/dist/src/classifier.d.ts +41 -0
  28. package/dist/src/classifier.js +213 -0
  29. package/dist/src/cli.js +501 -1
  30. package/dist/src/codepass.d.ts +8 -0
  31. package/dist/src/codepass.js +39 -1
  32. package/dist/src/egress.d.ts +71 -0
  33. package/dist/src/egress.js +242 -0
  34. package/dist/src/email.d.ts +42 -0
  35. package/dist/src/email.js +424 -0
  36. package/dist/src/engine.d.ts +35 -12
  37. package/dist/src/engine.js +172 -45
  38. package/dist/src/image-meta.d.ts +33 -0
  39. package/dist/src/image-meta.js +433 -0
  40. package/dist/src/image.d.ts +104 -0
  41. package/dist/src/image.js +347 -0
  42. package/dist/src/index.d.ts +50 -5
  43. package/dist/src/index.js +28 -3
  44. package/dist/src/localguard.d.ts +33 -0
  45. package/dist/src/localguard.js +61 -0
  46. package/dist/src/meaning.d.ts +2 -0
  47. package/dist/src/meaning.js +348 -25
  48. package/dist/src/messages.d.ts +79 -0
  49. package/dist/src/messages.js +431 -0
  50. package/dist/src/multilingual.d.ts +3 -0
  51. package/dist/src/multilingual.js +117 -5
  52. package/dist/src/nearby.d.ts +52 -0
  53. package/dist/src/nearby.js +186 -0
  54. package/dist/src/netpolicy.js +50 -19
  55. package/dist/src/normalize.d.ts +36 -1
  56. package/dist/src/normalize.js +186 -4
  57. package/dist/src/provenance.d.ts +56 -0
  58. package/dist/src/provenance.js +114 -0
  59. package/dist/src/qr.d.ts +25 -0
  60. package/dist/src/qr.js +113 -0
  61. package/dist/src/safeguards.d.ts +61 -0
  62. package/dist/src/safeguards.js +199 -0
  63. package/dist/src/served.d.ts +20 -0
  64. package/dist/src/served.js +53 -0
  65. package/dist/src/shell-commands.d.ts +39 -0
  66. package/dist/src/shell-commands.js +291 -0
  67. package/dist/src/shortcuts.d.ts +45 -0
  68. package/dist/src/shortcuts.js +220 -0
  69. package/dist/src/stream.d.ts +88 -0
  70. package/dist/src/stream.js +119 -0
  71. package/dist/src/terminal.d.ts +29 -0
  72. package/dist/src/terminal.js +313 -0
  73. package/dist/src/tooldefs.d.ts +84 -0
  74. package/dist/src/tooldefs.js +122 -0
  75. package/dist/src/types.d.ts +50 -6
  76. package/dist/src/types.js +15 -2
  77. package/dist/src/visibility.d.ts +23 -3
  78. package/dist/src/visibility.js +285 -78
  79. package/native/ingress-presence.swift +48 -0
  80. package/native/ingress-vision.swift +417 -0
  81. package/package.json +4 -2
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Images: what a picture says to a person, and what it says only to a machine.
3
+ *
4
+ * An image reaches a model after a pipeline has handled it: resized, flattened, one frame picked, its
5
+ * metadata sometimes passed along as text. Each of those steps is a place to put words a person looking at
6
+ * the picture never sees. This module turns an image into text segments the engine's ordinary passes read:
7
+ *
8
+ * visible text recognised in the picture as shown, at full size
9
+ * concealed text that exists only after resizing without smoothing (an image-scaling attack), only
10
+ * after the contrast is raised, only on another background or under transparent pixels, only
11
+ * in a later frame; text in the file's metadata; the payload of a QR code
12
+ *
13
+ * Reading pixels needs the vision helper (native/ingress-vision.swift, macOS). Without it the container is
14
+ * still read (metadata, appended data, frames), and the result says the pixels were not inspected.
15
+ *
16
+ * Limits, stated plainly: the resizing check tries the common target sizes and three kernels, not every
17
+ * pipeline; noise crafted against one model (adversarial perturbation) is not text and is not detected;
18
+ * steganography that needs a decoder is not detected.
19
+ */
20
+ import { execFile } from "node:child_process";
21
+ import { createHash } from "node:crypto";
22
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
23
+ import { tmpdir } from "node:os";
24
+ import { dirname, join } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+ import { stateDir } from "./changes.js";
27
+ import { readImageMeta } from "./image-meta.js";
28
+ import { judgeQrPayload } from "./qr.js";
29
+ import { hostsMentioned } from "./egress.js";
30
+ // ---------- comparing readings ----------
31
+ const norm = (s) => s.toLowerCase().normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
32
+ function trigrams(s) {
33
+ const t = ` ${norm(s)} `, out = new Set();
34
+ for (let i = 0; i + 3 <= t.length; i++)
35
+ out.add(t.slice(i, i + 3));
36
+ return out;
37
+ }
38
+ /** share of a line's character trigrams that occur in a reference text: 1 means the reference contains the line */
39
+ function containment(line, ref) {
40
+ const g = trigrams(line);
41
+ if (!g.size)
42
+ return 1;
43
+ let hit = 0;
44
+ for (const x of g)
45
+ if (ref.has(x))
46
+ hit++;
47
+ return hit / g.size;
48
+ }
49
+ const similar = (a, b) => { const ga = trigrams(a), gb = trigrams(b); return Math.min(containment(a, gb), containment(b, ga)); };
50
+ const wordy = (s) => (norm(s).match(/\p{L}{2,}/gu) ?? []).length;
51
+ const letters = (s) => (s.match(/\p{L}/gu) ?? []).length;
52
+ const textOf = (lines) => lines.map((l) => l.text).join("\n");
53
+ const enough = (lines) => { const t = lines.join(" "); return wordy(t) >= 3 && letters(t) >= 12; };
54
+ /**
55
+ * Does a token look like a word someone wrote? Letters only, in one casing (lower, UPPER or Capitalised), and for
56
+ * Latin letters at least four of them with a vowel. Scripts without case or spaces count from two characters.
57
+ */
58
+ function wordlike(tok) {
59
+ const t = tok.replace(/^[\p{P}\p{S}]+|[\p{P}\p{S}]+$/gu, "");
60
+ if (!/^\p{L}+$/u.test(t))
61
+ return false;
62
+ if (/^[\p{Script=Latin}]+$/u.test(t))
63
+ return t.length >= 4 && /[aeiouyáéíóúäëïöüàèìòùâêîôûåæøœ]/i.test(t) && (t === t.toLowerCase() || t === t.toUpperCase() || t === t[0].toUpperCase() + t.slice(1).toLowerCase());
64
+ return t.length >= 2;
65
+ }
66
+ /**
67
+ * A message, not scraps: at least four word-like tokens, making up most of what was read. Measured on ordinary
68
+ * images: a dense screenshot resized without smoothing is read as "ICD 1CU QuE Fin war: 4' 1CBOWD TOU IC0", with
69
+ * full confidence, by every kernel. Those are scraps of digits. Words built to be read come out as words.
70
+ */
71
+ function sentence(lines) {
72
+ const toks = lines.join(" ").split(/\s+/).map((t) => t.replace(/^[\p{P}\p{S}]+|[\p{P}\p{S}]+$/gu, "")).filter((t) => /[\p{L}\p{N}]/u.test(t));
73
+ const words = toks.filter(wordlike).length;
74
+ // a scrap: letters and digits run together, or casing no writer uses (QuE). Short words (all, the, and) are neither.
75
+ const scraps = toks.filter((t) => (/\p{L}/u.test(t) && /\p{N}/u.test(t)) || (/^[\p{Script=Latin}]+$/u.test(t) && t !== t.toLowerCase() && t !== t.toUpperCase() && t !== t[0].toUpperCase() + t.slice(1).toLowerCase())).length;
76
+ return words >= 4 && scraps <= toks.length * 0.2;
77
+ }
78
+ /**
79
+ * Text that an unsmoothed resize produces and a smoothed resize to the same size does not.
80
+ * Ordinary text survives both (smoothing reads better, if anything). Text built for the resizer exists only
81
+ * in the unsmoothed one. Two kernels must agree, and the text must not already be plain at full size.
82
+ */
83
+ /**
84
+ * Everything an honest look at the picture reads: at full size, and resized with smoothing to each size.
85
+ * (On a page of small print, text recognition reads different fragments at every size; a line that any of
86
+ * these views contains was there for a person to see.)
87
+ */
88
+ function honestTrigrams(v, also = []) {
89
+ const kinds = new Set(["smooth", ...also]);
90
+ return trigrams([textOf(v.full), ...v.variants.filter((x) => kinds.has(x.kind)).map((x) => textOf(x.lines))].join("\n"));
91
+ }
92
+ /**
93
+ * Text that an unsmoothed resize produces and no honest look at the picture does.
94
+ * Ordinary text survives smoothing (it reads better, if anything) and is there at full size. Text built for
95
+ * the resizer exists only after the unsmoothed resize to the size it was built for. Two kernels must read
96
+ * the same words at that size.
97
+ */
98
+ function resizedOnly(v) {
99
+ // a contrast-raised view counts as honest here: text it shows is faint, not built for a resizer
100
+ const seen = honestTrigrams(v, ["contrast"]);
101
+ const bySize = new Map();
102
+ for (const x of v.variants) {
103
+ if (x.kind !== "scale")
104
+ continue;
105
+ const size = x.name.match(/to (\d+) px$/)?.[1] ?? "?";
106
+ // Only lines read with full confidence count. On real posters and charts, small print misread the same way
107
+ // by two kernels ("TALK OF THE TOWN" as "ELSIL JC AIX N: THE TOM") is read at half confidence; words built
108
+ // to be read after resizing come out clean. (Measured on 95 ordinary images: 2 false alarms without this.)
109
+ bySize.set(size, [...(bySize.get(size) ?? []), { name: x.name, lines: x.lines.filter((l) => l.conf >= 0.9 && wordy(l.text) >= 1 && containment(l.text, seen) < 0.4).map((l) => l.text) }]);
110
+ }
111
+ let best = { lines: [], at: [] };
112
+ for (const [, kernels] of bySize) {
113
+ const agreed = [], at = new Set();
114
+ kernels.forEach((k, i) => {
115
+ for (const l of k.lines) {
116
+ const other = kernels.find((o, j) => j !== i && o.lines.some((m) => similar(l, m) >= 0.8));
117
+ if (!other)
118
+ continue;
119
+ at.add(k.name);
120
+ at.add(other.name);
121
+ if (!agreed.some((a) => similar(a, l) >= 0.8))
122
+ agreed.push(l);
123
+ }
124
+ });
125
+ if (sentence(agreed) && agreed.join(" ").length > best.lines.join(" ").length)
126
+ best = { lines: agreed, at: [...at] };
127
+ }
128
+ return best;
129
+ }
130
+ /** Lines some other view of the picture reads and no honest look at it does. */
131
+ function onlyIn(v, kind, name) {
132
+ const seen = honestTrigrams(v);
133
+ let best = { lines: [], at: [] };
134
+ for (const x of v.variants) {
135
+ if (x.kind !== kind || (name && !name.test(x.name)))
136
+ continue;
137
+ const lines = x.lines.filter((l) => l.conf >= 0.5 && containment(l.text, seen) < 0.4).map((l) => l.text);
138
+ if (enough(lines) && lines.join(" ").length > best.lines.join(" ").length)
139
+ best = { lines, at: [x.name] };
140
+ }
141
+ return best;
142
+ }
143
+ // ---------- the helper ----------
144
+ /** Where the built helper is expected: INGRESS_VISION_HELPER, or <state>/bin/ingress-vision. */
145
+ export function visionHelperPath() { return process.env.INGRESS_VISION_HELPER || join(stateDir(), "bin", "ingress-vision"); }
146
+ /** Why the helper cannot be used, or undefined when it can. A helper in the state folder must match the hash recorded when it was built. */
147
+ export function visionHelperProblem(path = visionHelperPath()) {
148
+ if (process.platform !== "darwin")
149
+ return "reading pixels needs the macOS vision helper";
150
+ if (!existsSync(path))
151
+ return "the vision helper is not built (run: ingress vision build)";
152
+ if (!process.env.INGRESS_VISION_HELPER) {
153
+ try {
154
+ const want = readFileSync(`${path}.sha256`, "utf8").trim();
155
+ const got = createHash("sha256").update(readFileSync(path)).digest("hex");
156
+ if (want !== got)
157
+ return "the vision helper does not match the hash recorded when it was built (run: ingress vision build)";
158
+ }
159
+ catch {
160
+ return "the vision helper has no recorded hash (run: ingress vision build)";
161
+ }
162
+ }
163
+ return undefined;
164
+ }
165
+ /** The helper's source, shipped with the package. */
166
+ export function visionHelperSource() { return nativeSource("ingress-vision"); }
167
+ const nativeSource = (name) => fileURLToPath(new URL(`../../native/${name}.swift`, import.meta.url));
168
+ /**
169
+ * Compile the helper on this machine (macOS with the Swift compiler: Xcode or its command line tools) and
170
+ * record its hash. Built here rather than shipped as a binary, so what runs is what the source says.
171
+ */
172
+ export function buildVisionHelper(out = join(stateDir(), "bin", "ingress-vision")) { return buildNativeHelper("ingress-vision", out); }
173
+ /** Compile one of the package's Swift helpers (ingress-vision, ingress-presence) and record its hash beside it. */
174
+ export function buildNativeHelper(name, out = join(stateDir(), "bin", name)) {
175
+ return new Promise((resolve, reject) => {
176
+ if (process.platform !== "darwin")
177
+ return reject(new Error("the helper is built on macOS only"));
178
+ const src = nativeSource(name);
179
+ if (!existsSync(src))
180
+ return reject(new Error(`the helper's source is missing (${src})`));
181
+ mkdirSync(dirname(out), { recursive: true, mode: 0o700 });
182
+ execFile("swiftc", ["-O", "-swift-version", "5", src, "-o", out], { timeout: 300_000, encoding: "utf8" }, (err, _stdout, stderr) => {
183
+ if (err)
184
+ return reject(new Error(`swiftc failed: ${String(stderr || err.message).split("\n").filter((l) => /error/.test(l))[0]?.slice(0, 200) ?? String(err.message).slice(0, 200)}`));
185
+ const sha256 = createHash("sha256").update(readFileSync(out)).digest("hex");
186
+ writeFileSync(`${out}.sha256`, sha256 + "\n", { mode: 0o600 });
187
+ resolve({ path: out, sha256 });
188
+ });
189
+ });
190
+ }
191
+ export function helperRunner(path = visionHelperPath(), timeoutMs = 60_000) {
192
+ return (image) => new Promise((resolve, reject) => {
193
+ execFile(path, [image], { timeout: timeoutMs, maxBuffer: 64 * 1024 * 1024, encoding: "utf8" }, (err, stdout) => {
194
+ if (err)
195
+ return reject(new Error(`the vision helper failed (${String(err.message).slice(0, 120)})`));
196
+ try {
197
+ const r = JSON.parse(stdout);
198
+ if (!Array.isArray(r.full) || !Array.isArray(r.variants) || !Array.isArray(r.barcodes))
199
+ throw new Error("unexpected report");
200
+ resolve(r);
201
+ }
202
+ catch (e) {
203
+ reject(new Error(`the vision helper's report could not be read (${e.message})`));
204
+ }
205
+ });
206
+ });
207
+ }
208
+ const CLICKFIX_OPEN = /\b(?:press|hit|hold|tap|click)\b[^.]{0,30}(?:\bwin(?:dows)?(?: key)?\s*\+\s*r\b|⊞\s*\+\s*r\b|\b(?:cmd|command|⌘)\s*\+?\s*space\b|\bctrl\s*\+\s*alt\s*\+\s*t\b)|\bopen (?:the )?(?:terminal|powershell|command prompt|run (?:dialog|box|window)|spotlight)\b/i;
209
+ const CLICKFIX_PASTE = /\b(?:ctrl|cmd|command|⌘)\s*\+\s*v\b|\bpaste (?:it|the|this|and)\b|\b(?:then|and) (?:press|hit) enter\b/i;
210
+ // ---------- inspection ----------
211
+ const EXT = { png: "png", jpeg: "jpg", gif: "gif", webp: "webp", bmp: "bmp", tiff: "tiff", heic: "heic", avif: "avif", ico: "ico" };
212
+ /** metadata fields that are routinely filled in by cameras and editors and say nothing */
213
+ const ROUTINE_FIELD = /^(?:exif:(?:Make|Model|Software|ImageUniqueID|PrintIM)|png:(?:Software|Creation Time|date:\w+|icc:\w+|Raw profile type \w+)|xmp:(?:xmp:CreatorTool|xmpMM:\w+|photoshop:(?:ICCProfile|ColorMode)|tiff:\w+|exif:\w+|stEvt:\w+|dc:format|pdf:Producer))$/i;
214
+ export async function inspectImage(bytes, opts = {}) {
215
+ const meta = readImageMeta(bytes);
216
+ const segments = [];
217
+ const findings = [];
218
+ const coverage = { format: meta.format, pixels: false, metadata: !/not read/.test(meta.notes.join(" ")), notes: [...meta.notes] };
219
+ const add = (f) => findings.push({ pass: "channel", action: "none", ...f });
220
+ // ----- the container -----
221
+ for (const t of meta.texts) {
222
+ if (ROUTINE_FIELD.test(t.field) && wordy(t.text) < 8)
223
+ continue;
224
+ segments.push({ text: t.text, visibility: "concealed", path: `image/metadata:${t.field}` });
225
+ }
226
+ const said = segments.filter((s) => wordy(s.text) >= 4);
227
+ if (said.length)
228
+ add({ kind: "image.metadata_text", confidence: 0.1, severity: 0.2, message: `the file's metadata holds text nobody looking at the picture sees (${said.slice(0, 4).map((s) => s.path.replace("image/metadata:", "")).join(", ")})`, inHidden: true });
229
+ if (meta.trailingBytes >= 16) {
230
+ const like = meta.trailingLooksLike;
231
+ add({ kind: "image.trailing_data", confidence: like && like !== "text" ? 0.6 : 0.3, severity: like && like !== "text" ? 0.7 : 0.5, message: `${meta.trailingBytes} bytes follow the end of the image${like ? `; they look like ${like}` : ""}. A viewer ignores them; a program that reads the whole file does not`, inHidden: true });
232
+ if (like === "text" || like === "a web page or script" || like === "a script") {
233
+ const from = bytes.length - meta.trailingBytes;
234
+ segments.push({ text: new TextDecoder("utf-8", { fatal: false }).decode(bytes.subarray(from, from + 20_000)), visibility: "concealed", path: "image/after-end" });
235
+ }
236
+ }
237
+ if (meta.hasThumbnail)
238
+ coverage.notes.push("an embedded preview picture is present and was not read");
239
+ // ----- the pixels -----
240
+ let vision;
241
+ const codes = [];
242
+ const format = meta.format;
243
+ if (format === "unknown" || format === "pdf" || format === "svg")
244
+ coverage.pixelsReason = format === "unknown" ? "not a recognised image format" : `${format.toUpperCase()} is not a pixel image`;
245
+ else if (opts.vision === false)
246
+ coverage.pixelsReason = "pixel inspection was turned off";
247
+ else {
248
+ const problem = opts.vision ? undefined : visionHelperProblem();
249
+ if (problem)
250
+ coverage.pixelsReason = problem;
251
+ else {
252
+ const dir = mkdtempSync(join(tmpdir(), "ingress-image-"));
253
+ const file = join(dir, `image.${EXT[format] ?? "bin"}`);
254
+ try {
255
+ writeFileSync(file, bytes, { mode: 0o600 });
256
+ const got = await (opts.vision || helperRunner())(file);
257
+ coverage.notes.push(...got.notes);
258
+ // a picture the system could not open was not read, whatever else the report says
259
+ if (got.decoded === false)
260
+ coverage.pixelsReason = got.notes[0] ?? "the image could not be decoded";
261
+ else {
262
+ vision = got;
263
+ coverage.pixels = true;
264
+ }
265
+ }
266
+ catch (e) {
267
+ coverage.pixelsReason = e.message;
268
+ }
269
+ finally {
270
+ try {
271
+ rmSync(dir, { recursive: true, force: true });
272
+ }
273
+ catch { /* temp folder */ }
274
+ }
275
+ }
276
+ }
277
+ if (vision) {
278
+ const shown = textOf(vision.full).trim();
279
+ if (shown)
280
+ segments.unshift({ text: shown, visibility: "visible", path: "image/text" });
281
+ // A screen that tells its reader to open a terminal or the Run box and paste something ("to verify you are
282
+ // human, press Win+R, then Ctrl+V"): the ClickFix lure. It works on people, and an agent that reads the
283
+ // screen and can type is a faster victim.
284
+ const flat = shown.replace(/\s+/g, " ");
285
+ if (CLICKFIX_OPEN.test(flat) && CLICKFIX_PASTE.test(flat))
286
+ add({ kind: "image.clickfix", confidence: 0.55, severity: 0.75, message: "the picture tells its reader to open a terminal or the Run box and paste something: a fake verification or fix screen (ClickFix). Nothing on a screen is a reason to run a command", location: "image/text" });
287
+ const resized = resizedOnly(vision);
288
+ if (resized.lines.length) {
289
+ segments.push({ text: resized.lines.join("\n"), visibility: "concealed", path: "image/only-when-resized" });
290
+ add({ kind: "image.text_only_when_resized", confidence: 0.7, severity: 0.85, message: `${wordy(resized.lines.join(" "))} words appear only after the image is resized without smoothing (${resized.at.slice(0, 3).join(", ")}): text built for a model's image pipeline, not for a person`, excerpt: resized.lines.join(" / ").slice(0, 160), inHidden: true, action: "quarantined" });
291
+ }
292
+ const faint = onlyIn(vision, "contrast");
293
+ // text the resizing check already explained is not reported twice
294
+ const faintNew = faint.lines.filter((l) => !resized.lines.some((r) => similar(l, r) >= 0.6));
295
+ if (enough(faintNew)) {
296
+ segments.push({ text: faintNew.join("\n"), visibility: "tiny_or_transparent", path: "image/low-contrast" });
297
+ add({ kind: "image.low_contrast_text", confidence: 0.4, severity: 0.5, message: `${wordy(faintNew.join(" "))} words can be read only after the contrast is raised (${faint.at[0]}): too faint for a person, plain to a machine`, excerpt: faintNew.join(" / ").slice(0, 160), inHidden: true });
298
+ }
299
+ const under = onlyIn(vision, "alpha", /transparency dropped/);
300
+ if (under.lines.length) {
301
+ segments.push({ text: under.lines.join("\n"), visibility: "concealed", path: "image/under-transparency" });
302
+ add({ kind: "image.transparency_text", confidence: 0.4, severity: 0.55, message: `${wordy(under.lines.join(" "))} words are drawn in the colours of fully transparent pixels: invisible in any viewer, present for a pipeline that drops transparency`, excerpt: under.lines.join(" / ").slice(0, 160), inHidden: true });
303
+ }
304
+ const dark = onlyIn(vision, "alpha", /black background/);
305
+ const darkNew = dark.lines.filter((l) => !under.lines.some((r) => similar(l, r) >= 0.6));
306
+ if (enough(darkNew)) {
307
+ // light text on a transparent background is how logos for dark pages are made: recorded, and read as hidden text
308
+ segments.push({ text: darkNew.join("\n"), visibility: "concealed", path: "image/on-dark-background" });
309
+ add({ kind: "image.transparency_text", confidence: 0.15, severity: 0.4, message: `${wordy(darkNew.join(" "))} words show on a dark background and not on a light one`, excerpt: darkNew.join(" / ").slice(0, 160), inHidden: true });
310
+ }
311
+ const frames = vision.variants.filter((x) => x.kind === "frame").flatMap((x) => x.lines.filter((l) => l.conf >= 0.5 && containment(l.text, trigrams(shown)) < 0.5).map((l) => ({ frame: x.name, text: l.text })));
312
+ const frameLines = frames.filter((f, i) => frames.findIndex((g) => similar(g.text, f.text) >= 0.8) === i);
313
+ if (enough(frameLines.map((f) => f.text))) {
314
+ segments.push({ text: frameLines.map((f) => f.text).join("\n"), visibility: "concealed", path: "image/later-frames" });
315
+ add({ kind: "image.later_frame_text", confidence: 0.12, severity: 0.4, message: `${wordy(frameLines.map((f) => f.text).join(" "))} words appear only in later frames (${[...new Set(frameLines.map((f) => f.frame))].slice(0, 3).join(", ")}): a still view shows the first frame only`, inHidden: true });
316
+ }
317
+ // codes: the payload is for the machine
318
+ for (const c of vision.barcodes.slice(0, 20)) {
319
+ const verdict = judgeQrPayload(c.payload);
320
+ codes.push({ symbology: c.symbology, payload: c.payload, verdict });
321
+ const what = `${c.symbology} code ${verdict.summary}${verdict.notes.length ? ` (${verdict.notes.join("; ")})` : ""}`;
322
+ if (verdict.action)
323
+ add({ kind: "image.code_action", confidence: 0.3 + verdict.risk * 0.4, severity: 0.4 + verdict.risk * 0.4, message: `following this ${what}`, inHidden: true });
324
+ else
325
+ add({ kind: "image.code_payload", confidence: verdict.notes.length ? 0.25 + verdict.risk * 0.3 : 0.05, severity: verdict.notes.length ? 0.5 : 0.2, message: `this ${what}${verdict.url ? ". Open it only through the gate" : ""}`, inHidden: true });
326
+ if (verdict.text)
327
+ segments.push({ text: verdict.text, visibility: "concealed", path: `image/code:${verdict.kind}` });
328
+ // the words beside a code say one thing; the code says another
329
+ const named = hostsMentioned(`${opts.caption ?? ""} ${shown}`, 20);
330
+ if (verdict.host && named.length && !named.some((n) => verdict.host === n || verdict.host.endsWith(`.${n}`) || n.endsWith(`.${verdict.host}`))) {
331
+ add({ kind: "image.caption_mismatch", confidence: 0.45, severity: 0.6, message: `the words beside the code name ${named[0]}, and the code goes to ${verdict.host}`, inHidden: true });
332
+ }
333
+ }
334
+ // a line for the reader, so the delivered text says a code is there without carrying its payload as an instruction
335
+ if (codes.length)
336
+ segments.push({ text: codes.map((c) => `[${c.symbology} code: ${c.verdict.summary}]`).join("\n"), visibility: "visible", path: "image/codes" });
337
+ }
338
+ else {
339
+ add({ kind: "image.pixels_not_inspected", confidence: 0.1, severity: 0.2, message: `the picture itself was not read: ${coverage.pixelsReason}. Text in it, codes, and the resizing, contrast and transparency checks were not run` });
340
+ segments.push({ text: `[image, ${meta.format}${meta.width ? ` ${meta.width}x${meta.height}` : ""}: its pixels were not inspected (${coverage.pixelsReason})]`, visibility: "visible", path: "image/note" });
341
+ }
342
+ const report = JSON.stringify({
343
+ sha256: createHash("sha256").update(bytes).digest("hex"), format: meta.format, width: vision?.width ?? meta.width, height: vision?.height ?? meta.height, frames: vision?.frames ?? meta.frames,
344
+ pixels: coverage.pixels, segments: segments.map((s) => ({ path: s.path, visibility: s.visibility, text: s.text })), codes: codes.map((c) => ({ symbology: c.symbology, kind: c.verdict.kind, payload: c.payload })),
345
+ });
346
+ return { meta, vision, codes, segments, findings, coverage, report };
347
+ }
@@ -7,8 +7,10 @@ export { summarize, findingWeight, cloakingConfigFromEnv } from "./summary.js";
7
7
  export type { ResultSummary, FindingGroup, TopFinding } from "./summary.js";
8
8
  export { checkTarget, isPrivateIP, isPrivateIPv4, isPrivateIPv6, NetPolicyError, DEFAULT_NET_POLICY } from "./netpolicy.js";
9
9
  export type { NetPolicy } from "./netpolicy.js";
10
- export { analyzeHtml, findStylesheetLinks, rulesFromCss, colorRulesFromCss } from "./visibility.js";
11
- export type { HiddenRule, ColorRule, VisibilityResult } from "./visibility.js";
10
+ export { checkLocalRequest, isLoopbackBind } from "./localguard.js";
11
+ export type { LocalRequestHeaders, LocalGuardOptions, LocalGuardVerdict } from "./localguard.js";
12
+ export { analyzeHtml, findStylesheetLinks, rulesFromCss, colorRulesFromCss, classifyStyle, parseDeclarations, collectCssVars } from "./visibility.js";
13
+ export type { HiddenRule, ColorRule, VisibilityResult, CssVars } from "./visibility.js";
12
14
  export { parseColor, contrastRatio, INVISIBLE_CONTRAST } from "./color.js";
13
15
  export { scanCharacters } from "./character.js";
14
16
  export { analyzeScripts, analyzeScript } from "./script.js";
@@ -17,7 +19,41 @@ export { scanSupplyChain } from "./supplychain.js";
17
19
  export { scanSecrets, redactSecrets, collectSecrets, scrubExcerpt } from "./secrets.js";
18
20
  export { attachEvidence, alternativeFor, bandOf } from "./evidence.js";
19
21
  export type { EvidenceClass, ConfidenceBand } from "./evidence.js";
20
- export { detectKind, decodeEntities, adaptMarkdown, adaptJson, adaptText, adaptJavascript } from "./adapters.js";
22
+ export { detectKind, decodeEntities, adaptMarkdown, adaptJson, adaptText, adaptJavascript, adaptByKind } from "./adapters.js";
23
+ export type { AdapterResult } from "./adapters.js";
24
+ export { adaptTerminal } from "./terminal.js";
25
+ export { adaptEmail, parseEmail, looksLikeEmailJson, looksLikeRawEmail } from "./email.js";
26
+ export type { EmailPart } from "./email.js";
27
+ export { adaptCalendar, parseIcs, looksLikeCalendarJson } from "./calendar.js";
28
+ export { passagesOnlyIn } from "./served.js";
29
+ export { classifyText, scanClassifier, classifierInfo } from "./classifier.js";
30
+ export { CLASSIFIER_MODEL } from "./classifier-model.js";
31
+ export { shellTokens, shellInvocations, shellOutputSource, shellWrites, shellUploads } from "./shell-commands.js";
32
+ export { inspectImage, helperRunner, visionHelperPath, visionHelperProblem, visionHelperSource, buildVisionHelper, buildNativeHelper } from "./image.js";
33
+ export type { ImageInspection, ImageCoverage, VisionReport, VisionLine, VisionRunner, InspectOptions } from "./image.js";
34
+ export { readImageMeta, detectImageFormat, looksLike } from "./image-meta.js";
35
+ export type { ImageMeta, ImageFormat } from "./image-meta.js";
36
+ export { judgeQrPayload } from "./qr.js";
37
+ export type { QrVerdict, QrKind } from "./qr.js";
38
+ export { adaptMessages, adaptNotifications, parseMessages, parseNotifications, looksLikeMessagesJson, looksLikeNotificationJson } from "./messages.js";
39
+ export type { ChatMessage, Notification } from "./messages.js";
40
+ export { adaptCaptions, parseCaptions, looksLikeCaptions, looksLikeTranscriptJson } from "./captions.js";
41
+ export type { Cue, CaptionHints } from "./captions.js";
42
+ export { inspectAudio, readAudioTags, detectAudioFormat, commandRunner } from "./audio.js";
43
+ export type { AudioReport, AudioRunner, AudioCoverage, AudioInspection, AudioFormat } from "./audio.js";
44
+ export { adaptNearby, parseNearby, looksLikeNearbyJson, collectNearby, parseDnsSdBrowse, parseBluetoothProfile, parseLpstatPrinters } from "./nearby.js";
45
+ export type { NearbyRecord, NearbyHints } from "./nearby.js";
46
+ export { adaptShortcut, summarizeShortcut, looksLikeShortcut, parsePlistXml } from "./shortcuts.js";
47
+ export type { ShortcutSummary, ShortcutAction } from "./shortcuts.js";
48
+ export { ProvenanceLedger, describeMark, downloadOrigin } from "./provenance.js";
49
+ export type { ProvenanceMark } from "./provenance.js";
50
+ export type { ShellGateOptions } from "./shell-commands.js";
51
+ export { postToolUse, preToolUse, localPortProgram, userPromptSubmit, preCompact, postCompact, sessionStart, remoteGate, withheld, PASTE_OVERRIDE } from "./agent-hooks.js";
52
+ export type { HookGate, HookOptions, EgressHookOptions } from "./agent-hooks.js";
53
+ export { oneTimeCodes, carriesCode, credentialsLeaving, hostsMentioned, Blocklist, BLOCKLIST_FEEDS, peripheralEgress, loopbackPorts, isForwarder, HomeCalls } from "./egress.js";
54
+ export type { PeripheralEgress } from "./egress.js";
55
+ export { StreamScanner, scanStream } from "./stream.js";
56
+ export type { StreamOptions, StreamStep, StreamSummary } from "./stream.js";
21
57
  export { runSandbox, DEFAULT_SCRIPT_HOSTS } from "./sandbox.js";
22
58
  export type { SandboxResult } from "./sandbox.js";
23
59
  export { createTaintGuard } from "./taint.js";
@@ -28,8 +64,10 @@ export * from "./types.js";
28
64
  /** @deprecated renamed to IngressEngine in 0.7.0 (AcePaste Gate -> AcePaste Ingress) */
29
65
  export { IngressEngine as GateEngine } from "./engine.js";
30
66
  export { ActionBroker, isSideEffectName, DEFAULT_BROKER_POLICY, canonicalJson, actionDigest, destinationsIn, exfilShapes, describeApproval } from "./broker.js";
31
- export type { ActionDecision, ActionRule, BrokerPolicy, ProposedAction, ApprovalRequest, Approver, BrokerVerdict, BrokerEvent } from "./broker.js";
32
- export { macosDialogApprover, callbackApprover, denyAllApprover } from "./approvers.js";
67
+ export type { ActionDecision, ActionRule, BrokerPolicy, ProposedAction, ApprovalRequest, Approver, BrokerVerdict, BrokerEvent, SerializedRun } from "./broker.js";
68
+ export { macosDialogApprover, callbackApprover, denyAllApprover, presenceApprover, presenceHelperPath } from "./approvers.js";
69
+ export { persistenceShapes, newCanary, canaryNotice, carriesCanary, BurstCounter, DEFAULT_BURST, actionKey, stopReason, engageStop, clearStop } from "./safeguards.js";
70
+ export type { PersistenceHit, BurstPolicy } from "./safeguards.js";
33
71
  export { scanMultilingual, MULTILINGUAL_RULES, MULTILINGUAL_RULESET } from "./multilingual.js";
34
72
  export { scanCode, extractCodeUnits, guessLang, lex } from "./codepass.js";
35
73
  export type { CodeUnit, CodeLang, CodeCoverage } from "./codepass.js";
@@ -38,3 +76,10 @@ export type { InstructionFile, InstructionCheck, InstructionStatus, ApprovalEntr
38
76
  export { auditEnvironment, formatAudit, readChromiumExtensions } from "./audit.js";
39
77
  export type { AuditReport, AuditCheck, AuditOptions } from "./audit.js";
40
78
  export * from "./audit-parsers.js";
79
+ export * from "./audit-local.js";
80
+ export { diffSnapshots, confirmState, BaselineStore, SnapshotStore, stateDir, fingerprint, formatDiff } from "./changes.js";
81
+ export type { TrackedItem, Snapshot, GroupChange, SnapshotDiff, Baseline, ConfirmState } from "./changes.js";
82
+ export { auditSnapshot, auditItemKey, trackAudit, confirmAuditArea, formatAuditChanges, AUDIT_VOLATILE, AUDIT_NEEDS_CONFIRMATION } from "./audit-changes.js";
83
+ export type { AuditAttention, AuditChanges } from "./audit-changes.js";
84
+ export { toolDefinitionText, toolDefinitionItems, reviewToolDefinitions, heldDescription, confirmServerTools, describeServerTools } from "./tooldefs.js";
85
+ export type { ToolDefinition, ToolHold, ToolReview, ServerToolReview, DefinitionGate } from "./tooldefs.js";
package/dist/src/index.js CHANGED
@@ -3,7 +3,8 @@ export { ASSEMBLED_LIMITS } from "./engine.js";
3
3
  export { acquire, acquireWithBrowser, AcquireError, MAX_REDIRECTS, HONEST_USER_AGENT } from "./acquire.js";
4
4
  export { summarize, findingWeight, cloakingConfigFromEnv } from "./summary.js";
5
5
  export { checkTarget, isPrivateIP, isPrivateIPv4, isPrivateIPv6, NetPolicyError, DEFAULT_NET_POLICY } from "./netpolicy.js";
6
- export { analyzeHtml, findStylesheetLinks, rulesFromCss, colorRulesFromCss } from "./visibility.js";
6
+ export { checkLocalRequest, isLoopbackBind } from "./localguard.js";
7
+ export { analyzeHtml, findStylesheetLinks, rulesFromCss, colorRulesFromCss, classifyStyle, parseDeclarations, collectCssVars } from "./visibility.js";
7
8
  export { parseColor, contrastRatio, INVISIBLE_CONTRAST } from "./color.js";
8
9
  export { scanCharacters } from "./character.js";
9
10
  export { analyzeScripts, analyzeScript } from "./script.js";
@@ -11,7 +12,26 @@ export { scanMeaning, neutralizeMeaning } from "./meaning.js";
11
12
  export { scanSupplyChain } from "./supplychain.js";
12
13
  export { scanSecrets, redactSecrets, collectSecrets, scrubExcerpt } from "./secrets.js";
13
14
  export { attachEvidence, alternativeFor, bandOf } from "./evidence.js";
14
- export { detectKind, decodeEntities, adaptMarkdown, adaptJson, adaptText, adaptJavascript } from "./adapters.js";
15
+ export { detectKind, decodeEntities, adaptMarkdown, adaptJson, adaptText, adaptJavascript, adaptByKind } from "./adapters.js";
16
+ export { adaptTerminal } from "./terminal.js";
17
+ export { adaptEmail, parseEmail, looksLikeEmailJson, looksLikeRawEmail } from "./email.js";
18
+ export { adaptCalendar, parseIcs, looksLikeCalendarJson } from "./calendar.js";
19
+ export { passagesOnlyIn } from "./served.js";
20
+ export { classifyText, scanClassifier, classifierInfo } from "./classifier.js";
21
+ export { CLASSIFIER_MODEL } from "./classifier-model.js";
22
+ export { shellTokens, shellInvocations, shellOutputSource, shellWrites, shellUploads } from "./shell-commands.js";
23
+ export { inspectImage, helperRunner, visionHelperPath, visionHelperProblem, visionHelperSource, buildVisionHelper, buildNativeHelper } from "./image.js";
24
+ export { readImageMeta, detectImageFormat, looksLike } from "./image-meta.js";
25
+ export { judgeQrPayload } from "./qr.js";
26
+ export { adaptMessages, adaptNotifications, parseMessages, parseNotifications, looksLikeMessagesJson, looksLikeNotificationJson } from "./messages.js";
27
+ export { adaptCaptions, parseCaptions, looksLikeCaptions, looksLikeTranscriptJson } from "./captions.js";
28
+ export { inspectAudio, readAudioTags, detectAudioFormat, commandRunner } from "./audio.js";
29
+ export { adaptNearby, parseNearby, looksLikeNearbyJson, collectNearby, parseDnsSdBrowse, parseBluetoothProfile, parseLpstatPrinters } from "./nearby.js";
30
+ export { adaptShortcut, summarizeShortcut, looksLikeShortcut, parsePlistXml } from "./shortcuts.js";
31
+ export { ProvenanceLedger, describeMark, downloadOrigin } from "./provenance.js";
32
+ export { postToolUse, preToolUse, localPortProgram, userPromptSubmit, preCompact, postCompact, sessionStart, remoteGate, withheld, PASTE_OVERRIDE } from "./agent-hooks.js";
33
+ export { oneTimeCodes, carriesCode, credentialsLeaving, hostsMentioned, Blocklist, BLOCKLIST_FEEDS, peripheralEgress, loopbackPorts, isForwarder, HomeCalls } from "./egress.js";
34
+ export { StreamScanner, scanStream } from "./stream.js";
15
35
  export { runSandbox, DEFAULT_SCRIPT_HOSTS } from "./sandbox.js";
16
36
  export { createTaintGuard } from "./taint.js";
17
37
  export { loadPolicyFile } from "./policyfile.js";
@@ -20,9 +40,14 @@ export * from "./types.js";
20
40
  /** @deprecated renamed to IngressEngine in 0.7.0 (AcePaste Gate -> AcePaste Ingress) */
21
41
  export { IngressEngine as GateEngine } from "./engine.js";
22
42
  export { ActionBroker, isSideEffectName, DEFAULT_BROKER_POLICY, canonicalJson, actionDigest, destinationsIn, exfilShapes, describeApproval } from "./broker.js";
23
- export { macosDialogApprover, callbackApprover, denyAllApprover } from "./approvers.js";
43
+ export { macosDialogApprover, callbackApprover, denyAllApprover, presenceApprover, presenceHelperPath } from "./approvers.js";
44
+ export { persistenceShapes, newCanary, canaryNotice, carriesCanary, BurstCounter, DEFAULT_BURST, actionKey, stopReason, engageStop, clearStop } from "./safeguards.js";
24
45
  export { scanMultilingual, MULTILINGUAL_RULES, MULTILINGUAL_RULESET } from "./multilingual.js";
25
46
  export { scanCode, extractCodeUnits, guessLang, lex } from "./codepass.js";
26
47
  export { INSTRUCTION_FILE_PATTERNS, discoverInstructionFiles, readInstructionBytes, approveInstructionFile, checkInstructionFiles, loadInstructionFiles } from "./instructions.js";
27
48
  export { auditEnvironment, formatAudit, readChromiumExtensions } from "./audit.js";
28
49
  export * from "./audit-parsers.js";
50
+ export * from "./audit-local.js";
51
+ export { diffSnapshots, confirmState, BaselineStore, SnapshotStore, stateDir, fingerprint, formatDiff } from "./changes.js";
52
+ export { auditSnapshot, auditItemKey, trackAudit, confirmAuditArea, formatAuditChanges, AUDIT_VOLATILE, AUDIT_NEEDS_CONFIRMATION } from "./audit-changes.js";
53
+ export { toolDefinitionText, toolDefinitionItems, reviewToolDefinitions, heldDescription, confirmServerTools, describeServerTools } from "./tooldefs.js";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Local-service guard: "it came from localhost" says where a request was sent, not who sent it.
3
+ *
4
+ * A web page in the user's browser can reach a service on 127.0.0.1 two ways: DNS rebinding (the page's
5
+ * own hostname is re-pointed at 127.0.0.1, so the browser treats the local service as same-origin) and plain
6
+ * cross-site requests. Both leave marks a local client never does: a Host header naming something other than
7
+ * this service, or an Origin header naming another site. A bearer key already stops unauthenticated calls;
8
+ * this is the second wall, and it also protects the endpoints that need no key.
9
+ */
10
+ export interface LocalRequestHeaders {
11
+ host?: string;
12
+ origin?: string;
13
+ }
14
+ export interface LocalGuardOptions {
15
+ /** the port this service listens on */
16
+ port: number;
17
+ /** extra hosts this service is legitimately reached by: "gate.example" (any port) or "gate.example:8443" */
18
+ allowedHosts?: readonly string[];
19
+ }
20
+ export type LocalGuardVerdict = {
21
+ ok: true;
22
+ } | {
23
+ ok: false;
24
+ reason: string;
25
+ };
26
+ /**
27
+ * Decide whether a request to a loopback-bound service really is addressed to it.
28
+ * Refuses: a missing or malformed Host, a Host that names anything but this service (the rebinding mark),
29
+ * and an Origin that is not this service's own (a cross-site request; "null" included).
30
+ */
31
+ export declare function checkLocalRequest(h: LocalRequestHeaders, opts: LocalGuardOptions): LocalGuardVerdict;
32
+ /** True when a listen address keeps the service off the network (so the local guard applies). */
33
+ export declare function isLoopbackBind(host: string | undefined): boolean;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Local-service guard: "it came from localhost" says where a request was sent, not who sent it.
3
+ *
4
+ * A web page in the user's browser can reach a service on 127.0.0.1 two ways: DNS rebinding (the page's
5
+ * own hostname is re-pointed at 127.0.0.1, so the browser treats the local service as same-origin) and plain
6
+ * cross-site requests. Both leave marks a local client never does: a Host header naming something other than
7
+ * this service, or an Origin header naming another site. A bearer key already stops unauthenticated calls;
8
+ * this is the second wall, and it also protects the endpoints that need no key.
9
+ */
10
+ const LOOPBACK_NAMES = ["127.0.0.1", "localhost", "[::1]"];
11
+ function hostPort(value) {
12
+ const v = value.trim().toLowerCase();
13
+ // [v6]:port, name:port, or a bare name. Anything with a path, credentials or whitespace is not a Host header.
14
+ const m = v.match(/^(\[[0-9a-f:.]+\]|[a-z0-9.-]+)(?::(\d{1,5}))?$/);
15
+ if (!m)
16
+ return null;
17
+ return { host: m[1].replace(/\.$/, ""), port: m[2] === undefined ? undefined : Number(m[2]) };
18
+ }
19
+ function nameAllowed(host, port, defaultPort, opts) {
20
+ const effective = port ?? defaultPort;
21
+ if (LOOPBACK_NAMES.includes(host))
22
+ return effective === opts.port;
23
+ // an allowed host is a name the operator chose: "gate.example" (any port: a reverse proxy sits in front,
24
+ // so the public port is not this process's port) or "gate.example:8443" (that port only)
25
+ for (const entry of opts.allowedHosts ?? []) {
26
+ const a = hostPort(entry);
27
+ if (a && a.host === host && (a.port === undefined || a.port === effective))
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+ /**
33
+ * Decide whether a request to a loopback-bound service really is addressed to it.
34
+ * Refuses: a missing or malformed Host, a Host that names anything but this service (the rebinding mark),
35
+ * and an Origin that is not this service's own (a cross-site request; "null" included).
36
+ */
37
+ export function checkLocalRequest(h, opts) {
38
+ if (!h.host)
39
+ return { ok: false, reason: "missing Host header" };
40
+ const hp = hostPort(h.host);
41
+ if (!hp)
42
+ return { ok: false, reason: "malformed Host header" };
43
+ if (!nameAllowed(hp.host, hp.port, 80, opts))
44
+ return { ok: false, reason: `Host "${h.host.slice(0, 80)}" is not this service` };
45
+ if (h.origin !== undefined) {
46
+ const o = h.origin.trim().toLowerCase();
47
+ const m = o.match(/^(https?):\/\/(.+)$/);
48
+ const op = m ? hostPort(m[2]) : null;
49
+ if (!m || !op || !nameAllowed(op.host, op.port, m[1] === "https" ? 443 : 80, opts)) {
50
+ return { ok: false, reason: `cross-site request from origin "${h.origin.slice(0, 80)}"` };
51
+ }
52
+ }
53
+ return { ok: true };
54
+ }
55
+ /** True when a listen address keeps the service off the network (so the local guard applies). */
56
+ export function isLoopbackBind(host) {
57
+ if (!host)
58
+ return false;
59
+ const h = host.trim().toLowerCase().replace(/^\[|\]$/g, "");
60
+ return h === "localhost" || h === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);
61
+ }
@@ -18,6 +18,8 @@
18
18
  */
19
19
  import type { Finding, TextSegment } from "./types.js";
20
20
  export interface MeaningInput {
21
+ /** the content kind, when the caller knows it: some checks only make sense for some channels */
22
+ kind?: string;
21
23
  /** segments from the visibility pass (or a single visible segment for plain text) */
22
24
  segments: TextSegment[];
23
25
  /** payloads decoded by the character pass */