@acepaste/ingress 0.9.6 → 0.9.22
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/dist/src/adapters.d.ts +9 -0
- package/dist/src/adapters.js +76 -6
- package/dist/src/agent-hooks.d.ts +112 -0
- package/dist/src/agent-hooks.js +533 -0
- package/dist/src/approvers.d.ts +16 -0
- package/dist/src/approvers.js +50 -0
- package/dist/src/audio.d.ts +70 -0
- package/dist/src/audio.js +224 -0
- package/dist/src/audit-changes.d.ts +46 -0
- package/dist/src/audit-changes.js +110 -0
- package/dist/src/audit-local.d.ts +57 -0
- package/dist/src/audit-local.js +231 -0
- package/dist/src/audit-parsers.d.ts +1 -1
- package/dist/src/audit.js +48 -0
- package/dist/src/broker.d.ts +92 -1
- package/dist/src/broker.js +222 -3
- package/dist/src/calendar.d.ts +36 -0
- package/dist/src/calendar.js +227 -0
- package/dist/src/captions.d.ts +44 -0
- package/dist/src/captions.js +209 -0
- package/dist/src/changes.d.ts +105 -0
- package/dist/src/changes.js +174 -0
- package/dist/src/character.js +15 -1
- package/dist/src/classifier-model.d.ts +53 -0
- package/dist/src/classifier-model.js +3 -0
- package/dist/src/classifier.d.ts +41 -0
- package/dist/src/classifier.js +213 -0
- package/dist/src/cli.js +501 -1
- package/dist/src/egress.d.ts +71 -0
- package/dist/src/egress.js +242 -0
- package/dist/src/email.d.ts +42 -0
- package/dist/src/email.js +424 -0
- package/dist/src/engine.d.ts +36 -12
- package/dist/src/engine.js +88 -37
- package/dist/src/image-meta.d.ts +33 -0
- package/dist/src/image-meta.js +433 -0
- package/dist/src/image.d.ts +110 -0
- package/dist/src/image.js +353 -0
- package/dist/src/index.d.ts +50 -5
- package/dist/src/index.js +28 -3
- package/dist/src/localguard.d.ts +33 -0
- package/dist/src/localguard.js +61 -0
- package/dist/src/meaning.d.ts +2 -0
- package/dist/src/meaning.js +77 -22
- package/dist/src/messages.d.ts +79 -0
- package/dist/src/messages.js +431 -0
- package/dist/src/nearby.d.ts +52 -0
- package/dist/src/nearby.js +186 -0
- package/dist/src/netpolicy.js +50 -19
- package/dist/src/provenance.d.ts +56 -0
- package/dist/src/provenance.js +114 -0
- package/dist/src/qr.d.ts +25 -0
- package/dist/src/qr.js +113 -0
- package/dist/src/safeguards.d.ts +61 -0
- package/dist/src/safeguards.js +199 -0
- package/dist/src/served.d.ts +20 -0
- package/dist/src/served.js +53 -0
- package/dist/src/shell-commands.d.ts +39 -0
- package/dist/src/shell-commands.js +291 -0
- package/dist/src/shortcuts.d.ts +45 -0
- package/dist/src/shortcuts.js +220 -0
- package/dist/src/stream.d.ts +88 -0
- package/dist/src/stream.js +119 -0
- package/dist/src/terminal.d.ts +29 -0
- package/dist/src/terminal.js +313 -0
- package/dist/src/tooldefs.d.ts +84 -0
- package/dist/src/tooldefs.js +122 -0
- package/dist/src/types.d.ts +50 -6
- package/dist/src/types.js +15 -2
- package/dist/src/visibility.d.ts +23 -3
- package/dist/src/visibility.js +285 -78
- package/native/ingress-presence.swift +48 -0
- package/native/ingress-vision.swift +417 -0
- package/package.json +3 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Egress: what an agent sends out, judged with what it has read.
|
|
3
|
+
*
|
|
4
|
+
* A firewall sees a connection. The broker sees the action and remembers the content the run took in, so it
|
|
5
|
+
* can say why an action is happening: "this address came from the email you read two minutes ago". These are
|
|
6
|
+
* the checks on the way out. Each returns reasons in plain words; the broker turns them into a decision.
|
|
7
|
+
*
|
|
8
|
+
* one-time codes A verification code the run read (in a message, a notification, a page) is for the person.
|
|
9
|
+
* An action that carries it to a destination that came from outside content is refused;
|
|
10
|
+
* anywhere else, a person is asked and told what the action carries.
|
|
11
|
+
* credentials A recognisable credential in outbound arguments, once the run has read outside content.
|
|
12
|
+
* provenance A destination that first appeared in content the run read, not in anything the person
|
|
13
|
+
* said. Not a refusal on its own (following a link is normal); it is named in the approval
|
|
14
|
+
* request and makes data-bearing requests to it need a person.
|
|
15
|
+
* known-bad A destination on a local blocklist (malware and botnet controllers) is refused.
|
|
16
|
+
* calling home Many requests in a short time to a host the run met in outside content.
|
|
17
|
+
* peripherals Printing, copying to a removable drive, AirDrop, Bluetooth transfer: ways out of the
|
|
18
|
+
* machine that never touch the network.
|
|
19
|
+
* local tunnels A loopback port owned by a tunnel or proxy program is the internet, not this machine.
|
|
20
|
+
*
|
|
21
|
+
* Scope, stated plainly: detect, refuse, record. Nothing here contacts, probes or acts against a destination.
|
|
22
|
+
*/
|
|
23
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
24
|
+
import { isIP } from "node:net";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { stateDir } from "./changes.js";
|
|
27
|
+
import { collectSecrets } from "./secrets.js";
|
|
28
|
+
// ---------- one-time codes ----------
|
|
29
|
+
// "code" alone is too common a word (zip code, error code, the token limit is 8192): a number is taken as a
|
|
30
|
+
// verification code only when the words around it say so.
|
|
31
|
+
const KIND = String.raw `(?:verification|security|confirmation|log-?in|sign-?in|one[- ]time|authenti[cs]ation|access|auth|2fa|mfa|two[- ]factor)`;
|
|
32
|
+
const NUM = String.raw `(\d[\d -]{2,9}\d)`;
|
|
33
|
+
const NOT_THAT_CODE = String.raw `(?<!\b(?:zip|postal|post|area|country|error|status|exit|promo|discount|coupon|voucher|source|colou?r|product|tracking|reference|order|bar|qr|dial|dialing|sort|branch|tax|response|return|result|http|key|the|this|some|of)\s)`;
|
|
34
|
+
const CODE_PATTERNS = [
|
|
35
|
+
// "your verification code is 482913", "security code: 482 913"
|
|
36
|
+
new RegExp(String.raw `\b${KIND}\s+(?:code|pin|passcode|password)\b[^.\n\d]{0,40}?\b${NUM}\b`, "gi"),
|
|
37
|
+
// "OTP 482913", "one-time password is 482913"
|
|
38
|
+
new RegExp(String.raw `\b(?:otp|passcode|one[- ]time (?:password|passcode|pin))\b[^.\n\d]{0,40}?\b${NUM}\b`, "gi"),
|
|
39
|
+
// "482913 is your Example verification code"
|
|
40
|
+
new RegExp(String.raw `\b${NUM}\b[^.\n\d]{0,30}?\bis your\b[^.\n]{0,40}?\b(?:code|otp|passcode|pin)\b`, "gi"),
|
|
41
|
+
// "Your code is 482913", "Code: 482913", "PIN: 4821"
|
|
42
|
+
new RegExp(String.raw `${NOT_THAT_CODE}\b(?:code|pin)\s*(?:is|:)\s*${NUM}\b`, "gi"),
|
|
43
|
+
// an alphanumeric code is taken only right after the words, in the shape codes have (the check below wants capitals and a digit)
|
|
44
|
+
new RegExp(String.raw `\b${KIND}\s+code\s*(?:is|:)?\s*\b([A-Za-z0-9]{6,10})\b`, "gi"),
|
|
45
|
+
];
|
|
46
|
+
/** Verification codes stated in a text ("Your code is 482913"). Digits only, 4 to 8 of them, or a 6-10 character code right after the words. */
|
|
47
|
+
export function oneTimeCodes(text) {
|
|
48
|
+
const out = new Set();
|
|
49
|
+
for (const re of CODE_PATTERNS) {
|
|
50
|
+
for (const m of text.slice(0, 200_000).matchAll(re)) {
|
|
51
|
+
const raw = m[1];
|
|
52
|
+
const digits = raw.replace(/[ -]/g, "");
|
|
53
|
+
if (/^\d{4,8}$/.test(digits)) {
|
|
54
|
+
if (!/^(19|20)\d\d$/.test(digits))
|
|
55
|
+
out.add(digits);
|
|
56
|
+
} // a year is not a code
|
|
57
|
+
else if (/^[A-Z0-9]{6,10}$/.test(raw) && /\d/.test(raw) && /[A-Z]/.test(raw))
|
|
58
|
+
out.add(raw);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...out];
|
|
62
|
+
}
|
|
63
|
+
/** Does any outbound string carry one of these codes, written plainly or with separators? */
|
|
64
|
+
export function carriesCode(strings, codes) {
|
|
65
|
+
if (!codes.length)
|
|
66
|
+
return undefined;
|
|
67
|
+
for (const s of strings) {
|
|
68
|
+
const squeezed = s.replace(/(?<=\d)[ -](?=\d)/g, "");
|
|
69
|
+
for (const c of codes) {
|
|
70
|
+
// the code as a whole token: not a longer number that happens to contain it
|
|
71
|
+
const re = new RegExp(`(?<![A-Za-z0-9])${c}(?![A-Za-z0-9])`);
|
|
72
|
+
if (re.test(s) || re.test(squeezed))
|
|
73
|
+
return c;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
// ---------- credentials ----------
|
|
79
|
+
/** Kinds of credential found in outbound strings (never the values). */
|
|
80
|
+
export function credentialsLeaving(strings) {
|
|
81
|
+
return collectSecrets(strings.filter((s) => s.length <= 100_000)).length;
|
|
82
|
+
}
|
|
83
|
+
// ---------- hosts in content ----------
|
|
84
|
+
const HOST_IN_TEXT = /(?:https?:\/\/|\/\/)([a-z0-9.-]+\.[a-z]{2,24})|(?<![\w@.-])((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+(?:com|net|org|io|dev|app|ai|co|me|info|biz|xyz|site|online|top|cloud|sh|to|cc|link|click|page|tech|store|live|example))(?![\w-])|@([a-z0-9.-]+\.[a-z]{2,24})\b/gi;
|
|
85
|
+
/** Hosts a text names: in links, as bare domains with common endings, and after @ in addresses. */
|
|
86
|
+
export function hostsMentioned(text, limit = 400) {
|
|
87
|
+
const out = new Set();
|
|
88
|
+
for (const m of text.slice(0, 500_000).matchAll(HOST_IN_TEXT)) {
|
|
89
|
+
const h = (m[1] ?? m[2] ?? m[3] ?? "").toLowerCase().replace(/\.$/, "");
|
|
90
|
+
if (h && h.includes("."))
|
|
91
|
+
out.add(h);
|
|
92
|
+
if (out.size >= limit)
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
return [...out];
|
|
96
|
+
}
|
|
97
|
+
// ---------- blocklists ----------
|
|
98
|
+
function ipv4ToInt(ip) { const p = ip.split(".").map(Number); return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) >>> 0; }
|
|
99
|
+
/**
|
|
100
|
+
* Known-bad destinations, from plain-text lists a person or `ingress blocklist update` put in
|
|
101
|
+
* <state>/blocklists/*.txt: one host, IP address, IPv4 CIDR or URL per line; `#` and `;` start comments; a
|
|
102
|
+
* hosts-file line ("0.0.0.0 bad.example") is read for its name. Nothing is fetched here.
|
|
103
|
+
*/
|
|
104
|
+
export class Blocklist {
|
|
105
|
+
hosts = new Set();
|
|
106
|
+
ips = new Set();
|
|
107
|
+
cidrs = [];
|
|
108
|
+
sources = [];
|
|
109
|
+
static load(dir = join(stateDir(), "blocklists")) {
|
|
110
|
+
const b = new Blocklist();
|
|
111
|
+
if (!existsSync(dir))
|
|
112
|
+
return b;
|
|
113
|
+
for (const f of readdirSync(dir).filter((n) => n.endsWith(".txt")).sort()) {
|
|
114
|
+
try {
|
|
115
|
+
b.add(readFileSync(join(dir, f), "utf8"), f);
|
|
116
|
+
}
|
|
117
|
+
catch { /* an unreadable list adds nothing */ }
|
|
118
|
+
}
|
|
119
|
+
return b;
|
|
120
|
+
}
|
|
121
|
+
add(text, source = "inline") {
|
|
122
|
+
let n = 0;
|
|
123
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
124
|
+
const line = raw.replace(/[#;].*$/, "").trim().toLowerCase();
|
|
125
|
+
if (!line)
|
|
126
|
+
continue;
|
|
127
|
+
// a list of URLs is read for its hosts
|
|
128
|
+
const asUrl = line.match(/^[a-z][a-z0-9+.-]*:\/\/(?:[^\s/@]*@)?(\[[0-9a-f:.]+\]|[^\s/:?#]+)/);
|
|
129
|
+
const tokens = asUrl ? [asUrl[1].replace(/^\[|\]$/g, "")] : line.split(/\s+/);
|
|
130
|
+
// hosts-file form: an address, then names
|
|
131
|
+
const entries = tokens.length > 1 && isIP(tokens[0]) && /^(0\.0\.0\.0|127\.0\.0\.1|::1?)$/.test(tokens[0]) ? tokens.slice(1) : [tokens[0]];
|
|
132
|
+
for (const e of entries) {
|
|
133
|
+
const cidr = e.match(/^(\d{1,3}(?:\.\d{1,3}){3})\/(\d{1,2})$/);
|
|
134
|
+
if (cidr && isIP(cidr[1]) === 4 && Number(cidr[2]) >= 8 && Number(cidr[2]) <= 32) {
|
|
135
|
+
const bits = Number(cidr[2]);
|
|
136
|
+
const mask = (~0 << (32 - bits)) >>> 0;
|
|
137
|
+
this.cidrs.push({ base: (ipv4ToInt(cidr[1]) & mask) >>> 0, mask, label: e });
|
|
138
|
+
n++;
|
|
139
|
+
}
|
|
140
|
+
else if (isIP(e)) {
|
|
141
|
+
this.ips.add(e);
|
|
142
|
+
n++;
|
|
143
|
+
}
|
|
144
|
+
else if (/^[a-z0-9.-]+\.[a-z]{2,24}$/.test(e) && e !== "localhost.localdomain") {
|
|
145
|
+
this.hosts.add(e.replace(/^\*\./, ""));
|
|
146
|
+
n++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (n)
|
|
151
|
+
this.sources.push(`${source} (${n})`);
|
|
152
|
+
return n;
|
|
153
|
+
}
|
|
154
|
+
get size() { return this.hosts.size + this.ips.size + this.cidrs.length; }
|
|
155
|
+
/** The entry that matches this host or address, or undefined. A listed name covers its subdomains. */
|
|
156
|
+
match(host) {
|
|
157
|
+
const h = host.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
158
|
+
if (isIP(h)) {
|
|
159
|
+
if (this.ips.has(h))
|
|
160
|
+
return h;
|
|
161
|
+
if (isIP(h) === 4) {
|
|
162
|
+
const n = ipv4ToInt(h);
|
|
163
|
+
const c = this.cidrs.find((x) => ((n & x.mask) >>> 0) === x.base);
|
|
164
|
+
if (c)
|
|
165
|
+
return c.label;
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
const labels = h.split(".");
|
|
170
|
+
for (let i = 0; i < labels.length - 1; i++) {
|
|
171
|
+
const s = labels.slice(i).join(".");
|
|
172
|
+
if (this.hosts.has(s))
|
|
173
|
+
return s;
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Free lists `ingress blocklist update` can download. The CLI fetches them; this module only names them. */
|
|
179
|
+
export const BLOCKLIST_FEEDS = [
|
|
180
|
+
{ name: "feodo-ips", url: "https://feodotracker.abuse.ch/downloads/ipblocklist.txt", what: "botnet command-and-control addresses (abuse.ch Feodo Tracker)", terms: "CC0" },
|
|
181
|
+
{ name: "spamhaus-drop", url: "https://www.spamhaus.org/drop/drop.txt", what: "networks run by spam and crime operations (Spamhaus DROP)", terms: "free to use with attribution; see spamhaus.org" },
|
|
182
|
+
{ name: "et-compromised", url: "https://rules.emergingthreats.net/blockrules/compromised-ips.txt", what: "addresses seen attacking others (Emerging Threats Open)", terms: "Emerging Threats Open ruleset terms" },
|
|
183
|
+
];
|
|
184
|
+
/** Does this action move data off the machine without the network? */
|
|
185
|
+
export function peripheralEgress(tool, strings) {
|
|
186
|
+
const out = new Map();
|
|
187
|
+
const add = (way, why) => { if (!out.has(way))
|
|
188
|
+
out.set(way, { way, why }); };
|
|
189
|
+
const name = tool.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-.:/]+/g, " ").toLowerCase();
|
|
190
|
+
if (/\b(print|printer|lpr)\b/.test(name))
|
|
191
|
+
add("print", "it sends a document to a printer");
|
|
192
|
+
if (/\bair ?drop\b/.test(name))
|
|
193
|
+
add("airdrop", "it sends a file over AirDrop");
|
|
194
|
+
if (/\bbluetooth\b[^|]*\b(send|transfer|push)\b|\b(send|transfer|push)\b[^|]*\bbluetooth\b/.test(name))
|
|
195
|
+
add("bluetooth", "it sends a file over Bluetooth");
|
|
196
|
+
for (const s of strings) {
|
|
197
|
+
if (s.length > 20_000)
|
|
198
|
+
continue;
|
|
199
|
+
if (/(?:^|[;&|(\s])(?:lp|lpr)\s+(?!-[a-z]*[lq]\b)[^\n]*\S|\bcupsenable\b|\blpadmin\s+-p\b/.test(s))
|
|
200
|
+
add("print", "it prints, or adds a printer");
|
|
201
|
+
if (/(?:^|[;&|(\s])(?:cp|mv|rsync|ditto|dd|tar|zip|scp)\b[^\n]*\s\/Volumes\/(?!Macintosh HD\b)[^\s/]+/.test(s) || /(?:^|[;&|(\s])(?:cp|mv|rsync|dd)\b[^\n]*\s\/(?:media|mnt|run\/media)\/\S+/.test(s) || /\b(?:of|to)=\/dev\/(?:r?disk\d|sd[a-z])/.test(s))
|
|
202
|
+
add("removable-drive", "it copies data to a removable or external drive");
|
|
203
|
+
if (/\bAirDrop\b/i.test(s) && /\b(osascript|open|shortcuts|sharing)\b/i.test(s))
|
|
204
|
+
add("airdrop", "it sends a file over AirDrop");
|
|
205
|
+
if (/\bblueutil\b[^\n]*--(?:send|connect)|\bbluetooth-sendto\b|\bobexftp\b|\bussp-push\b/.test(s))
|
|
206
|
+
add("bluetooth", "it sends a file over Bluetooth");
|
|
207
|
+
if (/\b(?:hdiutil\s+burn|drutil\s+burn|growisofs|wodim|cdrecord)\b/.test(s))
|
|
208
|
+
add("burn", "it writes data to a disc");
|
|
209
|
+
}
|
|
210
|
+
return [...out.values()];
|
|
211
|
+
}
|
|
212
|
+
// ---------- local tunnels ----------
|
|
213
|
+
const TUNNEL_PROGRAMS = /^(ngrok|cloudflared|frpc|bore|lt|localtunnel|devtunnel|zrok|pinggy|chisel|inlets|tailscaled?|ssh|autossh|socat|stunnel|squid|privoxy|tinyproxy|mitmproxy|mitmdump|proxychains4?|tor|v2ray|xray|sing-box|clash|shadowsocks.*|ss-local)$/i;
|
|
214
|
+
/** Loopback ports named in the arguments ("localhost:8080", "http://127.0.0.1:1080/x", "nc 127.0.0.1 9050"). */
|
|
215
|
+
export function loopbackPorts(strings) {
|
|
216
|
+
const out = new Set();
|
|
217
|
+
for (const s of strings) {
|
|
218
|
+
if (s.length > 20_000)
|
|
219
|
+
continue;
|
|
220
|
+
for (const m of s.matchAll(/(?:\b(?:localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|0\.0\.0\.0)|\[::1?\])[: ](\d{2,5})\b/gi)) {
|
|
221
|
+
const p = Number(m[1]);
|
|
222
|
+
if (p > 0 && p < 65536)
|
|
223
|
+
out.add(p);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return [...out];
|
|
227
|
+
}
|
|
228
|
+
/** True when the program that owns a local port forwards traffic elsewhere. */
|
|
229
|
+
export function isForwarder(program) {
|
|
230
|
+
return !!program && TUNNEL_PROGRAMS.test(program.split("/").pop() ?? program);
|
|
231
|
+
}
|
|
232
|
+
// ---------- calling home ----------
|
|
233
|
+
/** Requests per host within a window, for hosts the run met in outside content. */
|
|
234
|
+
export class HomeCalls {
|
|
235
|
+
at = new Map();
|
|
236
|
+
record(host, now) { const a = (this.at.get(host) ?? []).filter((t) => now - t < 600_000); a.push(now); this.at.set(host, a); }
|
|
237
|
+
count(host, now) { return (this.at.get(host) ?? []).filter((t) => now - t < 600_000).length; }
|
|
238
|
+
export() { return Object.fromEntries(this.at); }
|
|
239
|
+
import(d) { for (const [k, v] of Object.entries(d ?? {}))
|
|
240
|
+
if (Array.isArray(v))
|
|
241
|
+
this.at.set(k, v.filter((x) => typeof x === "number").slice(-50)); }
|
|
242
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email (RFC 5322 / MIME text, and the JSON that Gmail, Microsoft Graph and most mail tools return).
|
|
3
|
+
*
|
|
4
|
+
* An email is the easiest way to put text in front of someone else's assistant: no click is needed, only
|
|
5
|
+
* that the assistant reads the inbox. What makes the channel different from a web page:
|
|
6
|
+
*
|
|
7
|
+
* - One message is several documents. A person's mail client shows the HTML part; a tool often reads the
|
|
8
|
+
* plain part, the snippet or the raw headers. Text that only the plain part has is text the person never
|
|
9
|
+
* saw: the email version of serving an AI fetcher a different page.
|
|
10
|
+
* - The sender describes themselves. A display name is free text ("IT Security Team"), Reply-To can point
|
|
11
|
+
* anywhere, and whether the message really came from its From domain is in the authentication results.
|
|
12
|
+
* - It fetches. Remote images and stylesheets load when a message is rendered, which is how a message
|
|
13
|
+
* carries data out (the image URL is the request). Ingress never loads them: they are listed.
|
|
14
|
+
* - Marketing mail hides text on purpose (a "preheader" shown only in the inbox list) and is full of
|
|
15
|
+
* tracking pixels. That is furniture: recorded, and never a refusal unless an instruction is in it.
|
|
16
|
+
*
|
|
17
|
+
* The adapter turns a message into segments with the visibility a person had of each piece, plus findings
|
|
18
|
+
* about the message's own structure. Attachments it can read as text are read; the rest are listed as not
|
|
19
|
+
* inspected, so a clean verdict never means "not looked at".
|
|
20
|
+
*/
|
|
21
|
+
import type { Finding, TextSegment } from "./types.js";
|
|
22
|
+
export interface EmailPart {
|
|
23
|
+
contentType: string;
|
|
24
|
+
params: Record<string, string>;
|
|
25
|
+
headers: Map<string, string>;
|
|
26
|
+
filename?: string;
|
|
27
|
+
/** decoded text for text-like parts; undefined for parts that are not text */
|
|
28
|
+
text?: string;
|
|
29
|
+
bytes: number;
|
|
30
|
+
parts: EmailPart[];
|
|
31
|
+
}
|
|
32
|
+
export interface EmailAdapterResult {
|
|
33
|
+
segments: TextSegment[];
|
|
34
|
+
findings: Finding[];
|
|
35
|
+
}
|
|
36
|
+
/** Parse a raw message (headers, blank line, body). Tolerant of bare LF and of missing MIME headers. */
|
|
37
|
+
export declare function parseEmail(raw: string): EmailPart;
|
|
38
|
+
/** Is this parsed JSON one email message, or a list of them? */
|
|
39
|
+
export declare function looksLikeEmailJson(doc: unknown): boolean;
|
|
40
|
+
export declare function adaptEmail(raw: string): EmailAdapterResult;
|
|
41
|
+
/** Does this text look like a raw message: header lines first, with the headers every message has? */
|
|
42
|
+
export declare function looksLikeRawEmail(text: string): boolean;
|