@aglyn/shared-util-email 1.0.0-beta.220 → 1.0.0-beta.222
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 +3 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/lib/email-media-src.d.ts +5 -1
- package/src/lib/email-media-src.js +49 -3
- package/src/lib/email-media-src.js.map +1 -1
- package/src/lib/email-render.js +6 -1
- package/src/lib/email-render.js.map +1 -1
- package/src/lib/hosted-page-screen.d.ts +12 -0
- package/src/lib/hosted-page-screen.js +16 -6
- package/src/lib/hosted-page-screen.js.map +1 -1
- package/src/lib/link-reputation.d.ts +144 -0
- package/src/lib/link-reputation.js +250 -0
- package/src/lib/link-reputation.js.map +1 -0
- package/src/lib/outbound-phishing-screen.d.ts +24 -0
- package/src/lib/outbound-phishing-screen.js +40 -2
- package/src/lib/outbound-phishing-screen.js.map +1 -1
- package/src/lib/outbound-screen-gate.d.ts +4 -3
- package/src/lib/outbound-screen-gate.js +20 -5
- package/src/lib/outbound-screen-gate.js.map +1 -1
- package/src/lib/system-email-catalog.js +103 -0
- package/src/lib/system-email-catalog.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/email/src/lib/link-reputation.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * LINK REPUTATION (AGL-3451): what the phishing screen asks about a host\n * nobody's rules can judge.\n *\n * The screen's own rules catch a page or a message that LOOKS like a lure —\n * a brand's lookalike host, a password field, a brand beside a sign-in. The\n * 2026-10-01 harvesters linked to `temps-juenes.com` and\n * `conservascaorvi.com`, which wear no brand at all, so nothing held them.\n * A host already known to be bad anywhere is caught here instead: every\n * FOREIGN host a page, an email or a redirect points at is looked up against\n * a reputation list (Google Web Risk), and a listed one is a\n * `web-risk-link` signal — STRONG, so it holds for every workspace.\n *\n * Split like the send seam's gate: the pure half lives here (which hosts are\n * foreign, how a listing becomes a signal), and the lookup — a network call\n * and a cache — is installed by `@aglyn/tenant-data-admin`\n * (`web-risk.ts`) through {@link setLinkReputationLookup}. Nothing installed\n * means nothing looked up.\n *\n * ## Not evidence when it fails\n *\n * A lookup that errors or times out says nothing about the host. It never\n * holds by itself; the lookup reports the host as unknown and logs a warning.\n *\n * ## The host, and — only when switched on — the path\n *\n * By default (`platformSettings/webRisk.lookupMode: 'host'`) the lookup sees\n * `https://<host>/` and nothing else. A host is enough to catch a domain\n * that exists to harvest, and it is the least a third party can be told.\n *\n * A phishing kit as often sits at a path on a compromised site that is\n * otherwise legitimate, which a host lookup reads as clean. In `'url'` mode\n * (AGL-3459) each link's address is looked up too, as\n * {@link normalizeReputationLink} reduces it: scheme, host and path. Never\n * the query string or the fragment, which is where a recipient's address\n * and a session's token live; never a `user:password@`; and the path stops\n * before any segment that carries an email address or an unrendered merge\n * tag. Sending paths makes Google a recipient for a new purpose, so the\n * switch is flipped only once the Subprocessors page names it.\n *\n * ## The budget\n *\n * One page, message or redirect asks about at most\n * {@link MAX_REPUTATION_HOSTS_PER_LOOKUP} hosts and, in `'url'` mode, at most\n * {@link MAX_REPUTATION_URLS_PER_LOOKUP} addresses, deduplicated and taken a\n * host at a time ({@link pickReputationUrls}), so a long list of links to\n * one site cannot crowd out the one link to another.\n *=========================================*/\n\nimport type { PhishingScreenSignal } from './outbound-phishing-screen'\nimport {\n isAnyOfficialBrandDomain,\n isCommonLinkDomain,\n registrableDomain,\n} from './outbound-phishing-screen'\n\n/** The threat lists a host is looked up against. */\nexport type LinkThreatType = 'SOCIAL_ENGINEERING' | 'MALWARE' | 'UNWANTED_SOFTWARE'\n\nexport const LINK_THREAT_TYPES: readonly LinkThreatType[] = [\n 'SOCIAL_ENGINEERING',\n 'MALWARE',\n 'UNWANTED_SOFTWARE',\n]\n\n/**\n * A host the list names, or one address on it, and what it names it for.\n * `url` is set when the listing is the address's, not the host's.\n */\nexport interface HostReputationHit {\n host: string\n threats: LinkThreatType[]\n /** The address the list names (scheme, host and path), when it is one page on a clean host. */\n url?: string\n}\n\n/** What one lookup answered, host by host and address by address. */\nexport interface LinkReputationAnswer {\n /** Hosts, and addresses, the list names. */\n hits: HostReputationHit[]\n /** Hosts and addresses the list does not name. */\n clean: string[]\n /** Hosts and addresses nobody could answer for: an error, a timeout, a switched-off lookup. */\n unknown: string[]\n}\n\nexport interface LinkReputationLookupOptions {\n /** How long the caller will wait, overall. */\n deadlineMs?: number\n /**\n * The links' addresses, as {@link normalizeReputationLink} reduced them —\n * looked up only in `'url'` mode, and only on the hosts asked about.\n */\n urls?: readonly string[]\n}\n\nexport type LinkReputationLookup = (\n hosts: readonly string[],\n options?: LinkReputationLookupOptions,\n) => Promise<LinkReputationAnswer>\n\n/** The most foreign hosts one page, message or redirect is looked up for. */\nexport const MAX_REPUTATION_HOSTS_PER_LOOKUP = 20\n/**\n * The most link addresses (path included) one page, message or redirect is\n * looked up for in `'url'` mode, beside its hosts (AGL-3459). With the hosts,\n * at most forty calls, all inside the same per-page deadline.\n */\nexport const MAX_REPUTATION_URLS_PER_LOOKUP = 20\n/**\n * The longest path an address keeps. Longer is cut back to the last `/`\n * within it, so what is looked up is still a path the link really starts\n * with — Web Risk lists a kit by its path prefix.\n */\nexport const MAX_REPUTATION_URL_PATH_LENGTH = 512\n\nlet installedLookup: LinkReputationLookup | null = null\n\n/** Installs the lookup. Called once, from `@aglyn/tenant-data-admin`. */\nexport function setLinkReputationLookup(lookup: LinkReputationLookup | null): void {\n installedLookup = lookup\n}\n\n/** The installed lookup, or null. */\nexport function getLinkReputationLookup(): LinkReputationLookup | null {\n return installedLookup\n}\n\n/** Test seam: forget any installed lookup. */\nexport function resetLinkReputationLookupForTests(): void {\n installedLookup = null\n}\n\nconst HOST_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)+$/\n\n/** A host as the lookup takes it, or null for anything that is not one. */\nexport function normalizeReputationHost(host: string): string | null {\n const value = String(host ?? '')\n .trim()\n .toLowerCase()\n .replace(/\\.+$/, '')\n return value.length <= 253 && HOST_PATTERN.test(value) ? value : null\n}\n\n/** A link reduced to what may be looked up: its host, and its address without query or fragment. */\nexport interface ReputationLink {\n host: string\n /** `scheme://host[:port]/path` — never a query string, a fragment or a `user:password@`. */\n url: string\n}\n\n/** A path segment that carries an email address, or a merge tag nobody has filled in. */\nconst PRIVATE_SEGMENT = /@|%40|\\{|%7b|\\}|%7d/i\n\n/**\n * A link reduced to what Web Risk may be asked about it (AGL-3459), or null\n * for anything that is not an `http(s)` link to a real host.\n *\n * - `www.…`, `//…` and a bare host are read as `https://`;\n * - the query string, the fragment and any `user:password@` are dropped —\n * that is where a recipient's address and a session's token live;\n * - the host is lowercased, a default port dropped, and `.` and `..`\n * segments resolved (WHATWG URL rules);\n * - the path stops before the first segment carrying an email address or an\n * unrendered merge tag, and is cut back to a `/` within\n * {@link MAX_REPUTATION_URL_PATH_LENGTH}.\n */\nexport function normalizeReputationLink(link: string): ReputationLink | null {\n let text = String(link ?? '').trim()\n if (!text) return null\n if (text.startsWith('//')) text = `https:${text}`\n else if (/^www\\./i.test(text)) text = `https://${text}`\n else if (/^[a-z][a-z0-9+.-]*:(?!\\d)/i.test(text)) {\n if (!/^https?:\\/\\//i.test(text)) return null\n } else text = `https://${text}`\n let parsed: URL\n try {\n parsed = new URL(text)\n } catch {\n return null\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') return null\n const host = normalizeReputationHost(parsed.hostname)\n if (!host) return null\n const kept: string[] = []\n for (const segment of parsed.pathname.split('/')) {\n if (PRIVATE_SEGMENT.test(segment)) {\n kept.push('')\n break\n }\n kept.push(segment)\n }\n let path = kept.join('/') || '/'\n if (path.length > MAX_REPUTATION_URL_PATH_LENGTH) {\n path = path.slice(0, path.lastIndexOf('/', MAX_REPUTATION_URL_PATH_LENGTH - 1) + 1)\n }\n const port = parsed.port ? `:${parsed.port}` : ''\n return { host, url: `${parsed.protocol}//${host}${port}${path}` }\n}\n\n/** Is this address a host's front door — nothing a host lookup did not already ask? */\nexport function isRootReputationUrl(url: string): boolean {\n return /^https?:\\/\\/[^/]+\\/$/.test(url)\n}\n\n/**\n * The addresses worth asking about beside `hosts`: those on one of them\n * whose path is more than `/`, each once, taken a host at a time — every\n * host's first address, then every host's second — up to `max`\n * ({@link MAX_REPUTATION_URLS_PER_LOOKUP}). A link that does not normalize\n * is skipped.\n */\nexport function pickReputationUrls(\n links: readonly string[],\n hosts: readonly string[],\n max: number = MAX_REPUTATION_URLS_PER_LOOKUP,\n): string[] {\n const byHost = new Map<string, string[]>(hosts.map((host) => [host, []]))\n const seen = new Set<string>()\n for (const raw of links) {\n const link = normalizeReputationLink(raw)\n if (!link || seen.has(link.url) || isRootReputationUrl(link.url)) continue\n const list = byHost.get(link.host)\n if (!list) continue\n seen.add(link.url)\n list.push(link.url)\n }\n const picked: string[] = []\n for (let round = 0; picked.length < max; round += 1) {\n const before = picked.length\n for (const list of byHost.values()) {\n if (round < list.length && picked.length < max) picked.push(list[round])\n }\n if (picked.length === before) break\n }\n return picked\n}\n\n/** The foreign hosts a set of links points at, and the addresses on them worth asking about. */\nexport interface ForeignReputationLinks {\n hosts: string[]\n urls: string[]\n}\n\n/**\n * {@link foreignHostsForReputation} over links — hosts or whole links — and\n * the addresses on those hosts ({@link pickReputationUrls}). The addresses\n * are only ever looked up in `'url'` mode; the lookup decides.\n */\nexport function foreignLinksForReputation(\n links: readonly string[],\n options: {\n ownDomains?: readonly (string | null | undefined)[]\n excludeDomains?: readonly (string | null | undefined)[]\n max?: number\n maxUrls?: number\n } = {},\n): ForeignReputationLinks {\n const parsed = links\n .map((link) => normalizeReputationLink(link))\n .filter((link): link is ReputationLink => Boolean(link))\n const hosts = foreignHostsForReputation(\n parsed.map((link) => link.host),\n options,\n )\n return { hosts, urls: pickReputationUrls(parsed.map((link) => link.url), hosts, options.maxUrls) }\n}\n\n/**\n * The hosts worth asking about: foreign ones. Not the workspace's own, not\n * a domain under one of `excludeDomains` (the platform's own), not a listed\n * brand's own domain and not a common social, maps or review link — those\n * are judged by the screen's rules, and asking about them would only spend\n * lookups. Deduplicated, in the order found, at most\n * {@link MAX_REPUTATION_HOSTS_PER_LOOKUP} unless `max` says otherwise.\n */\nexport function foreignHostsForReputation(\n hosts: readonly string[],\n options: {\n ownDomains?: readonly (string | null | undefined)[]\n excludeDomains?: readonly (string | null | undefined)[]\n max?: number\n } = {},\n): string[] {\n const under = (list: readonly (string | null | undefined)[] | undefined) =>\n (list ?? [])\n .map((domain) => normalizeReputationHost(String(domain ?? '')))\n .filter((domain): domain is string => Boolean(domain))\n const own = [...under(options.ownDomains), ...under(options.excludeDomains)]\n const max = options.max ?? MAX_REPUTATION_HOSTS_PER_LOOKUP\n const out: string[] = []\n for (const raw of hosts) {\n if (out.length >= max) break\n const host = normalizeReputationHost(raw)\n if (!host || out.includes(host)) continue\n if (own.some((domain) => host === domain || host.endsWith(`.${domain}`))) continue\n const registrable = registrableDomain(host)\n if (isAnyOfficialBrandDomain(registrable) || isCommonLinkDomain(registrable)) continue\n out.push(host)\n }\n return out\n}\n\n/** A listing, as the screen's signal. */\nexport function webRiskSignals(hits: readonly HostReputationHit[]): PhishingScreenSignal[] {\n return hits.map((hit) => ({\n code: 'web-risk-link' as const,\n host: hit.host,\n threats: [...new Set(hit.threats)].sort(),\n ...(hit.url ? { url: hit.url } : {}),\n }))\n}\n\n/**\n * Look the foreign links up through the installed lookup and answer the\n * signals they carry. `links` are hosts or whole links (`linkUrlsIn`): the\n * hosts are asked about, and their addresses too when the lookup is in\n * `'url'` mode. Nothing installed, nothing foreign, an error: no signals.\n * Never throws.\n */\nexport async function linkReputationSignals(\n links: readonly string[],\n options: {\n ownDomains?: readonly (string | null | undefined)[]\n excludeDomains?: readonly (string | null | undefined)[]\n deadlineMs?: number\n } = {},\n): Promise<PhishingScreenSignal[]> {\n const lookup = installedLookup\n if (!lookup) return []\n const foreign = foreignLinksForReputation(links, options)\n if (!foreign.hosts.length) return []\n try {\n const answer = await lookup(foreign.hosts, { deadlineMs: options.deadlineMs, urls: foreign.urls })\n return webRiskSignals(\n answer.hits.filter(\n (hit) => foreign.hosts.includes(hit.host) && (!hit.url || foreign.urls.includes(hit.url)),\n ),\n )\n } catch (error) {\n console.warn('[link-reputation] the lookup failed — no signal', error)\n return []\n }\n}\n"],"names":["isAnyOfficialBrandDomain","isCommonLinkDomain","registrableDomain","LINK_THREAT_TYPES","MAX_REPUTATION_HOSTS_PER_LOOKUP","MAX_REPUTATION_URLS_PER_LOOKUP","MAX_REPUTATION_URL_PATH_LENGTH","installedLookup","setLinkReputationLookup","lookup","getLinkReputationLookup","resetLinkReputationLookupForTests","HOST_PATTERN","normalizeReputationHost","host","value","String","trim","toLowerCase","replace","length","test","PRIVATE_SEGMENT","normalizeReputationLink","link","text","startsWith","parsed","URL","protocol","hostname","kept","segment","pathname","split","push","path","join","slice","lastIndexOf","port","url","isRootReputationUrl","pickReputationUrls","links","hosts","max","byHost","Map","map","seen","Set","raw","has","list","get","add","picked","round","before","values","foreignLinksForReputation","options","filter","Boolean","foreignHostsForReputation","urls","maxUrls","under","domain","own","ownDomains","excludeDomains","out","includes","some","endsWith","registrable","webRiskSignals","hits","hit","code","threats","sort","linkReputationSignals","foreign","answer","deadlineMs","error","console","warn"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA+C2C;A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AAOY,eACLQ,OAAOP,IAAI,CAAChB,MAAM,CAChB,CAACiB,MAAQK,QAAQxC,KAAK,CAAC6B,QAAQ,CAACM,IAAIlE,IAAI,KAAM,CAAA,CAACkE,IAAIvC,GAAG,IAAI4C,QAAQnB,IAAI,CAACQ,QAAQ,CAACM,IAAIvC,GAAG,CAAA;IAG7F,EAAE,OAAO+C,OAAO;QACdC,QAAQC,IAAI,CAAC,mDAAmDF;QAChE,OAAO,EAAE;IACX;AACF"}
|
|
@@ -158,6 +158,21 @@ export type PhishingScreenSignal = {
|
|
|
158
158
|
host: string;
|
|
159
159
|
lure: string;
|
|
160
160
|
place: 'fragment' | 'parameter';
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A link, embed, redirect or form action whose host Google Web Risk lists
|
|
164
|
+
* as phishing, malware or unwanted software (AGL-3451,
|
|
165
|
+
* `link-reputation.ts`). Strong: a harvester already known to be bad
|
|
166
|
+
* anywhere is bad whatever page or message surrounds it. `url` is set
|
|
167
|
+
* when the listing names one page on the host rather than the host
|
|
168
|
+
* (AGL-3459, `platformSettings/webRisk.lookupMode: 'url'`): the address
|
|
169
|
+
* as looked up, scheme, host and path, never a query string.
|
|
170
|
+
*/
|
|
171
|
+
| {
|
|
172
|
+
code: 'web-risk-link';
|
|
173
|
+
host: string;
|
|
174
|
+
threats: string[];
|
|
175
|
+
url?: string;
|
|
161
176
|
};
|
|
162
177
|
export interface PhishingScreenInput {
|
|
163
178
|
subject?: string | null;
|
|
@@ -241,6 +256,13 @@ export declare function lookalikeBrandForHost(host: string): PhishingScreenBrand
|
|
|
241
256
|
export declare function visibleTextOf(html: string | null | undefined): string;
|
|
242
257
|
/** The hosts every link in the text points at, lowercased. */
|
|
243
258
|
export declare function linkHostsIn(text: string): string[];
|
|
259
|
+
/**
|
|
260
|
+
* Every link in the text as written — `www.` read as `https://`, prose
|
|
261
|
+
* punctuation after it dropped — in the order found, each once. Query
|
|
262
|
+
* strings and fragments are still on them: read them through
|
|
263
|
+
* `normalizeReputationLink` (`link-reputation.ts`) before they go anywhere.
|
|
264
|
+
*/
|
|
265
|
+
export declare function linkUrlsIn(text: string): string[];
|
|
244
266
|
/** Lowercased alphanumerics only, so "Wells-Fargo Advisors" contains `wellsfargo`. */
|
|
245
267
|
declare function squash(text: string): string;
|
|
246
268
|
/** Is this brand the workspace's own, by name or by a domain it holds? */
|
|
@@ -259,6 +281,8 @@ export declare function isCommonLinkDomain(registrable: string): boolean;
|
|
|
259
281
|
export declare function screenOutboundEmail(input: PhishingScreenInput): PhishingScreenVerdict;
|
|
260
282
|
/** The brand's label for a stored id, for the staff surface. */
|
|
261
283
|
export declare function phishingScreenBrandLabel(id: string): string;
|
|
284
|
+
/** "phishing or social engineering and malware", from Web Risk's threat types. */
|
|
285
|
+
export declare function describeLinkThreats(threats: readonly string[]): string;
|
|
262
286
|
/** One line per signal, in words staff read on the review row. */
|
|
263
287
|
export declare function describePhishingScreenSignals(signals: readonly PhishingScreenSignal[]): string[];
|
|
264
288
|
/** A workspace younger than this many days has the soft rules applied. */
|
|
@@ -846,6 +846,22 @@ const URL_PATTERN = /\b(?:https?:\/\/|www\.)[^\s"'<>()\\[\]{}]+/gi;
|
|
|
846
846
|
...hosts
|
|
847
847
|
];
|
|
848
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Every link in the text as written — `www.` read as `https://`, prose
|
|
851
|
+
* punctuation after it dropped — in the order found, each once. Query
|
|
852
|
+
* strings and fragments are still on them: read them through
|
|
853
|
+
* `normalizeReputationLink` (`link-reputation.ts`) before they go anywhere.
|
|
854
|
+
*/ export function linkUrlsIn(text) {
|
|
855
|
+
var _decodeEntities_match;
|
|
856
|
+
const urls = new Set();
|
|
857
|
+
for (const match of (_decodeEntities_match = decodeEntities(String(text != null ? text : '')).match(URL_PATTERN)) != null ? _decodeEntities_match : []){
|
|
858
|
+
const url = match.replace(/[.,;:!]+$/, '');
|
|
859
|
+
urls.add(/^www\./i.test(url) ? `https://${url}` : url);
|
|
860
|
+
}
|
|
861
|
+
return [
|
|
862
|
+
...urls
|
|
863
|
+
];
|
|
864
|
+
}
|
|
849
865
|
/** Every link in the text, with what it carries after its path. */ function linkTargetsIn(text) {
|
|
850
866
|
var _decodeEntities_match;
|
|
851
867
|
const targets = [];
|
|
@@ -1062,6 +1078,21 @@ const ADDRESS_HOST_PATTERN = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\.[a-z0-9-]+)+)/gi;
|
|
|
1062
1078
|
var _PHISHING_SCREEN_BRANDS_find;
|
|
1063
1079
|
return (_ref = (_PHISHING_SCREEN_BRANDS_find = PHISHING_SCREEN_BRANDS.find((brand)=>brand.id === id)) == null ? void 0 : _PHISHING_SCREEN_BRANDS_find.label) != null ? _ref : id;
|
|
1064
1080
|
}
|
|
1081
|
+
/** Web Risk's threat types, in the words staff read (AGL-3451). */ const LINK_THREAT_WORDS = {
|
|
1082
|
+
SOCIAL_ENGINEERING: 'phishing or social engineering',
|
|
1083
|
+
MALWARE: 'malware',
|
|
1084
|
+
UNWANTED_SOFTWARE: 'unwanted software'
|
|
1085
|
+
};
|
|
1086
|
+
/** "phishing or social engineering and malware", from Web Risk's threat types. */ export function describeLinkThreats(threats) {
|
|
1087
|
+
const words = [
|
|
1088
|
+
...new Set(threats)
|
|
1089
|
+
].map((threat)=>{
|
|
1090
|
+
var _LINK_THREAT_WORDS_threat;
|
|
1091
|
+
return (_LINK_THREAT_WORDS_threat = LINK_THREAT_WORDS[threat]) != null ? _LINK_THREAT_WORDS_threat : threat.toLowerCase();
|
|
1092
|
+
});
|
|
1093
|
+
if (!words.length) return 'unsafe';
|
|
1094
|
+
return words.length === 1 ? words[0] : `${words.slice(0, -1).join(', ')} and ${words[words.length - 1]}`;
|
|
1095
|
+
}
|
|
1065
1096
|
/** One line per signal, in words staff read on the review row. */ export function describePhishingScreenSignals(signals) {
|
|
1066
1097
|
return signals.map((signal)=>{
|
|
1067
1098
|
const brand = 'brand' in signal ? phishingScreenBrandLabel(signal.brand) : '';
|
|
@@ -1084,6 +1115,9 @@ const ADDRESS_HOST_PATTERN = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\.[a-z0-9-]+)+)/gi;
|
|
|
1084
1115
|
return `Redirects ${signal.source}, a path that reads "${signal.lure}", off the site to ${signal.host}.`;
|
|
1085
1116
|
case 'recipient-prefill-link':
|
|
1086
1117
|
return `Links to ${signal.host} with the recipient's own address in the ${signal.place === 'fragment' ? 'fragment' : 'link'}, so a sign-in form there opens filled in, beside "${signal.lure}".`;
|
|
1118
|
+
case 'web-risk-link':
|
|
1119
|
+
var _signal_url;
|
|
1120
|
+
return `Links to ${(_signal_url = signal.url) != null ? _signal_url : signal.host}, which Google Web Risk lists as ${describeLinkThreats(signal.threats)}.`;
|
|
1087
1121
|
default:
|
|
1088
1122
|
return 'Phishing signal.';
|
|
1089
1123
|
}
|
|
@@ -1120,11 +1154,15 @@ const ADDRESS_HOST_PATTERN = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\.[a-z0-9-]+)+)/gi;
|
|
|
1120
1154
|
*
|
|
1121
1155
|
* A credential-harvest page (a password, card or one-time-code field that
|
|
1122
1156
|
* is not one of the platform's own sign-in or checkout elements) is STRONG:
|
|
1123
|
-
* see `hosted-page-screen.ts`.
|
|
1157
|
+
* see `hosted-page-screen.ts`. So is a link to a host Google Web Risk lists
|
|
1158
|
+
* (`web-risk-link`, `link-reputation.ts`): it holds for every workspace, and
|
|
1159
|
+
* an account-subdomain host does not soften it, because the listing names
|
|
1160
|
+
* that host itself.
|
|
1124
1161
|
*=========================================*/ /** A workspace younger than this many days has the soft rules applied. */ export const OUTBOUND_REVIEW_YOUNG_DAYS = 14;
|
|
1125
1162
|
/** The signal codes that hold for every workspace. */ export const STRONG_PHISHING_SIGNAL_CODES = new Set([
|
|
1126
1163
|
'lookalike-link',
|
|
1127
|
-
'credential-field'
|
|
1164
|
+
'credential-field',
|
|
1165
|
+
'web-risk-link'
|
|
1128
1166
|
]);
|
|
1129
1167
|
/**
|
|
1130
1168
|
* Hosts that give each customer an account subdomain named after the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/shared/util/email/src/lib/outbound-phishing-screen.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE OUTBOUND PHISHING SCREEN (AGL-3356).\n *\n * A fraud actor signed up, paid with a card that never met 3-D Secure, and\n * used a workspace to send two kinds of mail: a campaign of Booking.com-style\n * \"guest feedback regarding your property\" lures to hotels, and a workflow\n * that mailed \"Poshmark Order — one of the items from your Seller Account has\n * finally sold\", linking to `poshmark.id63835663.shop`.\n *\n * This module answers one question about a message a YOUNG workspace is\n * about to send: does its content carry a STRONG phishing signal? The caller\n * decides who is young and what happens to a positive answer — the answer is\n * a hold for staff review, never a drop.\n *\n * ## Conservative by construction\n *\n * A false positive costs a real merchant's first campaign a wait for a\n * human; a miss costs strangers their bank logins. Both are real, so only\n * four shapes hold, and each is one a legitimate merchant essentially never\n * produces:\n *\n * 1. **A lookalike link** — a link or reply address whose host carries a\n * brand's name without being the brand's own domain: the brand as a label\n * of an unrelated registrable domain (`poshmark.id63835663.shop`), hyphen-\n * joined to one (`paypal-secure.com`, `secure-paypal.net`), the brand's\n * real domain embedded in a longer host (`booking.com.guest-review.top`),\n * or leetspeak for it (`paypa1.com`). Holds on its own.\n * 2. **A brand in the sender's display name** that is not the workspace's\n * own name — mail that says it is FROM PayPal.\n * 3. **The three-part lure**: a brand named in the copy, AND credential or\n * account-action phrasing (\"verify your account\", \"has finally sold\",\n * \"feedback regarding your property\"), AND a link to a domain that is\n * neither the brand's, nor the workspace's, nor a common social or maps\n * link. Any two of the three are ordinary marketing — \"our book is on\n * Amazon\", \"sign in to your account\", a link to the shop — and pass.\n * 4. **A prefilled sign-in** (AGL-3453): account or password phrasing\n * (\"your password expires today\") beside a link to such a domain that\n * carries the reader's own address, so the harvester's form opens with\n * it filled in: `…/ss/c/…#victim@example.com`.\n *\n * Mentioning a brand, alone, never holds. Brands and lures are read from\n * what the reader SEES ({@link visibleTextOf}), never from the raw HTML, in\n * which a kit splits every letter with a tag; links are read from the raw\n * HTML, where an href lives.\n *\n * ## The brand list is small on purpose\n *\n * The brands phishing kits most often wear, plus the two in the incident, and\n * the file-share and mail-security names a document-share lure wears — a\n * \"Secure Document Access Portal\" under Proofpoint's or SharePoint's name\n * whose one button leaves for the kit (AGL-3447). A brand is added when it\n * has been seen impersonated, not because it is big: every entry is a set of\n * words that can now hold somebody's newsletter.\n * Each carries its REAL domains, so a link to the brand itself is never\n * suspicious, and host tokens chosen so a common word (`booking`, `apple`,\n * `outlook`, `box`, `adobe`) does not match an unrelated host by itself.\n *\n * Pure: no DNS, no store, no clock. Everything the caller knows about the\n * workspace arrives as input.\n *=========================================*/\n\n/** One brand the screen recognizes. */\nexport interface PhishingScreenBrand {\n /** Stable id, as stored on a hold. */\n id: string\n /** How staff read it. */\n label: string\n /** Copy that names the brand — subject, body, sender. Case-insensitive. */\n mention: RegExp\n /**\n * Host labels that name the brand. Matched against each dot-separated\n * label of a link's host, whole or hyphen-joined, after leetspeak is\n * folded — never as a bare substring, which is how `amazonaws` or\n * `bookingengine` would read as a brand.\n */\n hostTokens: readonly string[]\n /**\n * Registrable domains the brand genuinely links from. The FIRST is its\n * primary domain, the one a kit embeds in a longer host.\n */\n officialDomains: readonly string[]\n /**\n * The brand's name is an ordinary word (`apple`, `amazon`), so a host\n * label names the brand only when it IS the word — `apple.example.top` —\n * and never hyphen-joined or leet-folded, which `apple-orchard-farm.com`\n * would otherwise be.\n */\n wordToken?: boolean\n /**\n * Whether `<brand>.<country code>` (and `<brand>.co.<cc>`) is the brand's\n * too — true for the marketplaces that run a site per country.\n */\n countryDomains?: boolean\n /**\n * Registrable domains the brand runs but where OTHER people's content lives —\n * the platform's own tenant apex, where every site is `<name>.<apex>`. A\n * host there never wears the brand as a disguise, so the lookalike rule\n * skips it; but it is not the brand's own domain either, so a link to a\n * neighbor's site still counts as \"somewhere else\" to the lure rules, and a\n * workspace hosted there does not own the brand by being hosted there.\n */\n hostedDomains?: readonly string[]\n}\n\nexport const PHISHING_SCREEN_BRANDS: readonly PhishingScreenBrand[] = [\n {\n id: 'poshmark',\n label: 'Poshmark',\n mention: /\\bposhmark\\b/i,\n hostTokens: ['poshmark'],\n officialDomains: ['poshmark.com', 'posh.mk'],\n },\n {\n id: 'booking',\n label: 'Booking.com',\n // Never the bare word: \"booking\" is every hotel's and every salon's.\n mention: /\\bbooking\\.com\\b/i,\n hostTokens: ['bookingcom', 'booking-com'],\n officialDomains: ['booking.com', 'bstatic.com'],\n },\n {\n id: 'airbnb',\n label: 'Airbnb',\n mention: /\\bairbnb\\b/i,\n hostTokens: ['airbnb'],\n officialDomains: ['airbnb.com', 'abnb.me', 'muscache.com'],\n countryDomains: true,\n },\n {\n id: 'paypal',\n label: 'PayPal',\n mention: /\\bpay\\s?pal\\b/i,\n hostTokens: ['paypal'],\n officialDomains: ['paypal.com', 'paypal.me', 'paypalobjects.com'],\n countryDomains: true,\n },\n {\n id: 'amazon',\n label: 'Amazon',\n mention: /\\bamazon\\b/i,\n hostTokens: ['amazon', 'amzn'],\n wordToken: true,\n officialDomains: [\n 'amazon.com',\n 'amzn.to',\n 'amzn.com',\n 'amazonaws.com',\n 'media-amazon.com',\n 'ssl-images-amazon.com',\n ],\n countryDomains: true,\n },\n {\n id: 'apple',\n label: 'Apple',\n // The fruit is on every bakery's menu; the account is what gets phished.\n mention: /\\bapple\\s?(?:id|support|account)\\b|\\bicloud\\b|\\bitunes\\b/i,\n hostTokens: ['apple', 'appleid', 'icloud', 'itunes'],\n wordToken: true,\n officialDomains: ['apple.com', 'icloud.com', 'apple.co', 'itunes.com', 'me.com', 'mzstatic.com'],\n countryDomains: true,\n },\n {\n id: 'microsoft',\n label: 'Microsoft',\n // Outlook only as the product — \"our 2026 outlook\" is every advisor's\n // newsletter.\n mention:\n /\\bmicrosoft\\b|\\b(?:office|ms|m)\\s?365\\b|\\bonedrive\\b|\\bsharepoint\\b|\\boutlook(?:\\.com|\\s+(?:web\\s+app|web\\s+access|online|account|365))\\b/i,\n hostTokens: [\n 'microsoft',\n 'microsoft365',\n 'office365',\n 'office-365',\n 'outlook365',\n 'onedrive',\n 'sharepoint',\n 'microsoftonline',\n 'msonline',\n ],\n officialDomains: [\n 'microsoft.com',\n 'office.com',\n 'office365.com',\n 'microsoft365.com',\n 'live.com',\n 'outlook.com',\n 'microsoftonline.com',\n 'sharepoint.com',\n 'sharepointonline.com',\n 'onedrive.com',\n '1drv.ms',\n 'aka.ms',\n ],\n },\n {\n id: 'docusign',\n label: 'DocuSign',\n mention: /\\bdocu\\s?sign\\b/i,\n hostTokens: ['docusign'],\n officialDomains: ['docusign.com', 'docusign.net'],\n },\n {\n id: 'google',\n label: 'Google',\n // The account and the files, never the bare name: \"find us on Google\"\n // and \"Google Maps\" are on every shop's contact page.\n mention: /\\bgoogle\\s?(?:drive|docs?|sheets|slides|workspace|account)\\b|\\bgmail\\b|\\bg\\s?suite\\b/i,\n // The products and the account, never the bare name: Google runs\n // hyphenated hosts of its own that a page embeds, and a bare `google`\n // token would read each as its lookalike. `docs.google.com.<kit>` is\n // still read, by the primary-domain rule.\n hostTokens: [\n 'gmail',\n 'gsuite',\n 'googledocs',\n 'googledrive',\n 'google-docs',\n 'google-drive',\n 'google-workspace',\n 'google-account',\n 'google-login',\n 'google-mail',\n 'docs-google',\n 'drive-google',\n ],\n officialDomains: [\n 'google.com',\n 'goo.gl',\n 'g.co',\n 'g.page',\n 'forms.gle',\n 'gmail.com',\n 'googleapis.com',\n 'gstatic.com',\n 'googleusercontent.com',\n 'withgoogle.com',\n ],\n countryDomains: true,\n },\n {\n id: 'adobe',\n label: 'Adobe',\n // \"Adobe\" alone is a house, a grill and an inn across the Southwest;\n // the products are what a lure names.\n mention:\n /\\badobe\\s?(?:acrobat|sign|id|account|document\\s?cloud|reader|pdf|creative\\s?cloud)\\b|\\bacrobat\\s?(?:reader|sign|pro)\\b|\\bechosign\\b/i,\n hostTokens: ['adobe', 'adobeid', 'adobesign', 'adobeacrobat', 'echosign'],\n wordToken: true,\n officialDomains: [\n 'adobe.com',\n 'adobe.io',\n 'adobe.ly',\n 'adobelogin.com',\n 'adobesign.com',\n 'echosign.com',\n 'acrobat.com',\n 'typekit.net',\n 'adobedtm.com',\n ],\n },\n {\n id: 'dropbox',\n label: 'Dropbox',\n // One word only: a \"drop box\" is by every library's door.\n mention: /\\bdropbox\\b/i,\n hostTokens: ['dropbox'],\n officialDomains: ['dropbox.com', 'db.tt', 'dropboxusercontent.com', 'dropboxstatic.com', 'hellosign.com'],\n },\n {\n // Never the bare word, as an id either — `brandForSubdomainLabel` reads\n // ids as words, and \"box\" is every lunch box's and subscription box's.\n id: 'boxcom',\n label: 'Box',\n mention: /\\bbox\\.com\\b|\\bbox\\s+drive\\b/i,\n hostTokens: ['boxcom', 'box-com'],\n officialDomains: ['box.com', 'box.net', 'boxcdn.net', 'boxcloud.com'],\n },\n {\n id: 'wetransfer',\n label: 'WeTransfer',\n // One word only: \"we transfer\" is a moving company's sentence.\n mention: /\\bwetransfer\\b/i,\n hostTokens: ['wetransfer'],\n officialDomains: ['wetransfer.com', 'we.tl'],\n },\n {\n id: 'sharefile',\n label: 'ShareFile',\n mention: /\\bshare\\s?file\\b/i,\n hostTokens: ['sharefile'],\n officialDomains: ['sharefile.com', 'sharefile.eu', 'citrix.com'],\n },\n {\n // A secure-mail gateway's name is what makes a document lure read as\n // safe: \"Proofpoint Encryption for your sensitive documents\".\n id: 'proofpoint',\n label: 'Proofpoint',\n // One word only: a \"proof point\" is every pitch deck's.\n mention: /\\bproofpoint\\b/i,\n hostTokens: ['proofpoint'],\n officialDomains: ['proofpoint.com', 'urldefense.com', 'pphosted.com', 'ppe-hosted.com'],\n },\n {\n id: 'mimecast',\n label: 'Mimecast',\n mention: /\\bmimecast\\b/i,\n hostTokens: ['mimecast'],\n officialDomains: ['mimecast.com', 'mimecastprotect.com'],\n },\n {\n id: 'netflix',\n label: 'Netflix',\n mention: /\\bnetflix\\b/i,\n hostTokens: ['netflix'],\n officialDomains: ['netflix.com', 'nflxext.com', 'nflximg.net'],\n },\n {\n id: 'wellsfargo',\n label: 'Wells Fargo',\n mention: /\\bwells\\s?fargo\\b/i,\n hostTokens: ['wellsfargo', 'wells-fargo'],\n officialDomains: ['wellsfargo.com'],\n },\n {\n id: 'bankofamerica',\n label: 'Bank of America',\n mention: /\\bbank\\s+of\\s+america\\b/i,\n hostTokens: ['bankofamerica', 'bofa'],\n officialDomains: ['bankofamerica.com', 'bofa.com'],\n },\n {\n id: 'coinbase',\n label: 'Coinbase',\n mention: /\\bcoinbase\\b/i,\n hostTokens: ['coinbase'],\n officialDomains: ['coinbase.com'],\n },\n {\n id: 'usps',\n label: 'USPS',\n mention: /\\busps\\b/i,\n hostTokens: ['usps'],\n officialDomains: ['usps.com'],\n },\n {\n id: 'fedex',\n label: 'FedEx',\n mention: /\\bfed\\s?ex\\b/i,\n hostTokens: ['fedex'],\n officialDomains: ['fedex.com'],\n },\n {\n id: 'dhl',\n label: 'DHL',\n mention: /\\bdhl\\b/i,\n hostTokens: ['dhl'],\n officialDomains: ['dhl.com'],\n countryDomains: true,\n },\n {\n // The platform itself (AGL-3365). A marketplace listing, a page or an\n // email that wears the platform's name — \"Aglyn Support\", a link to\n // `aglyn-billing.com`, \"official Aglyn plugin\" — is the one impersonation\n // every customer is primed to trust. The workspace named for it (the\n // platform's own org) owns it by name, as any brand's own workspace does.\n id: 'aglyn',\n label: 'Aglyn',\n mention: /\\baglyn\\b/i,\n hostTokens: ['aglyn'],\n officialDomains: ['aglyn.com', 'aglyn.io', 'aglyn.dev'],\n hostedDomains: ['aglyn.app'],\n },\n]\n\n/**\n * Account and credential phrasing: the lure that asks the reader to DO\n * something with an account — verify it, confirm it, sign in to it.\n */\nexport const ACCOUNT_LURE_PATTERNS: readonly RegExp[] = [\n /\\bverify\\s+your\\s+(?:account|identity|information|details|payment|email)\\b/i,\n /\\bconfirm\\s+your\\s+(?:account|identity|details|payment|password|billing|information)\\b/i,\n /\\b(?:account|payment|card)\\s+(?:has\\s+been\\s+|is\\s+|was\\s+|will\\s+be\\s+)?(?:suspended|locked|limited|restricted|disabled|deactivated|terminated|on\\s+hold)\\b/i,\n /\\bunusual\\s+(?:sign[-\\s]?in|login|activity)\\b/i,\n /\\bupdate\\s+your\\s+(?:payment|billing|card|account)\\s*(?:details|information|method)?\\b/i,\n /\\b(?:sign|log)\\s?in\\s+to\\s+(?:your|view|confirm|claim|release)\\b/i,\n // \"Password Expired\", \"your password expires today\", \"will expire\".\n /\\bpassword\\s+(?:has\\s+|will\\s+)?expire/i,\n /\\bkeep\\s+(?:your|my|the)\\s+(?:current\\s+|active\\s+|existing\\s+|same\\s+)?password\\b/i,\n /\\bchange\\s+(?:your\\s+)?password\\s+settings?\\b/i,\n /\\bmailbox\\s+(?:storage\\s+|quota\\s+)?(?:is\\s+)?(?:almost\\s+|nearly\\s+)?(?:full|exceeded)\\b/i,\n /\\bsecurity\\s+alert\\b/i,\n]\n\n/**\n * Document-share phrasing (AGL-3447): the lure that says a file is waiting\n * behind a secure door — \"Secure Document Access Portal\", \"Continue to\n * Document\", \"shared a file with you\", \"encrypted message\". The credential\n * harvest is on the far side of the button, so these are the words the page\n * or the mail itself carries.\n */\nexport const DOCUMENT_SHARE_LURE_PATTERNS: readonly RegExp[] = [\n /\\b(?:document|invoice|agreement)s?\\s+(?:is\\s+|are\\s+)?(?:ready|waiting|pending)\\s+(?:for\\s+)?(?:your\\s+)?(?:review|signature|to\\s+sign)\\b/i,\n /\\b(?:view|access|open)\\s+(?:the\\s+|your\\s+)?secure\\s+(?:file|document|message)s?\\b/i,\n /\\bsecure\\s+(?:file|document|message)s?\\b/i,\n /\\bdocument\\s+access\\b/i,\n /\\baccess\\s+portal\\b/i,\n /\\b(?:continue|proceed)\\s+to\\s+(?:the\\s+|your\\s+)?(?:document|file)s?\\b/i,\n /\\bshared\\s+(?:a|an|the)\\s+(?:file|document|folder)\\s+with\\s+you\\b/i,\n /\\b(?:file|document|folder)s?\\s+(?:has\\s+been|have\\s+been|was|were)\\s+shared\\s+with\\s+you\\b/i,\n /\\bencrypted\\s+(?:message|document|file|email)s?\\b/i,\n]\n\n/**\n * Marketplace, booking and parcel phrasing: the lure that says a sale, a\n * guest or a delivery needs the reader. The incident's Poshmark and\n * Booking.com mail.\n */\nconst SALE_AND_PARCEL_LURE_PATTERNS: readonly RegExp[] = [\n /\\b(?:has|have)\\s+(?:finally\\s+)?sold\\b/i,\n /\\bseller\\s+account\\b/i,\n /\\b(?:guest|customer)\\s+(?:complaint|review|feedback)\\b/i,\n /\\bfeedback\\s+regarding\\s+your\\s+(?:property|listing|stay|booking|reservation)\\b/i,\n /\\bclaim\\s+your\\s+(?:refund|reward|prize|package|payment|funds)\\b/i,\n /\\b(?:delivery|shipment)\\s+(?:failed|attempt|suspended|on\\s+hold)\\b/i,\n /\\b(?:package|parcel)\\s+(?:is\\s+)?(?:on\\s+hold|held|awaiting|undeliverable)\\b/i,\n]\n\n/**\n * Every lure — the half of the three-part lure that asks the reader to act.\n * Only ever counted beside a brand AND a foreign link; alone, several of\n * these are ordinary transactional copy.\n */\nexport const PHISHING_LURE_PATTERNS: readonly RegExp[] = [\n ...ACCOUNT_LURE_PATTERNS,\n ...DOCUMENT_SHARE_LURE_PATTERNS,\n ...SALE_AND_PARCEL_LURE_PATTERNS,\n]\n\n/**\n * Link targets a merchant's mail ordinarily carries that are not theirs:\n * social profiles, maps, review sites, video. Counted as neither foreign nor\n * suspicious in the three-part lure, so \"leave us a review on Google\" with a\n * brand named elsewhere does not become a hold. Never consulted by the\n * lookalike check, which holds on the host's own shape.\n */\nconst COMMON_LINK_DOMAINS: ReadonlySet<string> = new Set([\n 'facebook.com',\n 'fb.com',\n 'instagram.com',\n 'x.com',\n 'twitter.com',\n 'linkedin.com',\n 'youtube.com',\n 'youtu.be',\n 'tiktok.com',\n 'pinterest.com',\n 'google.com',\n 'goo.gl',\n 'g.page',\n 'yelp.com',\n 'tripadvisor.com',\n 'wa.me',\n 'whatsapp.com',\n])\n\n/**\n * Two-label public suffixes, so `evil.co.uk` registers as `evil.co.uk` and\n * not as `co.uk`. Deliberately a short list of the ones mail actually\n * arrives from rather than the whole public suffix list: a suffix missing\n * here makes the registrable domain one label too short, which can only\n * widen what counts as \"the same domain\" for a link — never invent a brand\n * label that is not in the host.\n */\nconst TWO_LABEL_SUFFIXES: ReadonlySet<string> = new Set([\n 'co.uk', 'org.uk', 'ac.uk', 'gov.uk', 'me.uk',\n 'com.au', 'net.au', 'org.au',\n 'co.nz', 'co.jp', 'co.kr', 'co.in', 'co.za', 'co.il', 'co.id', 'co.th',\n 'com.br', 'com.mx', 'com.ar', 'com.tr', 'com.cn', 'com.hk', 'com.sg',\n 'com.tw', 'com.my', 'com.ph', 'com.co', 'com.pe', 'com.sa', 'com.eg',\n])\n\n/** A signal the screen found. */\nexport type PhishingScreenSignal =\n | { code: 'lookalike-link'; brand: string; host: string }\n | { code: 'brand-sender'; brand: string; fromName: string }\n | { code: 'brand-lure-link'; brand: string; lure: string; host: string }\n /**\n * A published page asks for a password, a card number or a one-time code\n * in a field that is not one of the platform's own sign-in or checkout\n * elements (`hosted-page-screen.ts`). Strong.\n */\n | { code: 'credential-field'; field: 'password' | 'card' | 'otp'; label: string }\n /**\n * A published page names a brand that is not the workspace's beside a\n * sign-in, verify or payment call to action (`hosted-page-screen.ts`).\n * Soft.\n */\n | { code: 'brand-action-page'; brand: string; action: string }\n /**\n * The same, read over the page as a WHOLE (AGL-3447): a brand that is not\n * the workspace's anywhere on a page that carries an account or\n * document-share lure anywhere, or whose call to action leaves the site\n * worded as one, and that links away (`hosted-page-screen.ts`). Soft.\n */\n | { code: 'brand-lure-page'; brand: string; lure: string; host: string }\n /**\n * A published page's call to action — its only one, or one worded as an\n * account or document action — sends visitors to a host that is not the\n * site's, a listed brand's or a common link, on a page that carries an\n * account or document-share lure (`hosted-page-screen.ts`, AGL-3447). No\n * brand needed. Soft.\n */\n | { code: 'offsite-action-page'; action: string; lure: string; host: string }\n /**\n * A site redirect whose path reads as an account or document-share lure\n * sends visitors to such a host (`screenSiteRedirect`, AGL-3447). Soft.\n */\n | { code: 'offsite-redirect'; source: string; lure: string; host: string }\n /**\n * Account or password phrasing beside a link elsewhere that carries the\n * reader's own address (AGL-3453). STRONG when the address is the whole\n * fragment (`#victim@example.com`), which only a landing page's script\n * reads; soft when it is a query parameter or part of a longer fragment.\n * The address itself is never stored.\n */\n | { code: 'recipient-prefill-link'; host: string; lure: string; place: 'fragment' | 'parameter' }\n\nexport interface PhishingScreenInput {\n subject?: string | null\n /** The display name in front of the sending address. */\n fromName?: string | null\n /**\n * The ADDRESS the message leaves from (AGL-3362) — a `From:` domain is a\n * link the recipient never has to click, so its host is read by the\n * lookalike rule exactly like a link's: mail from `support@paypa1.com` is\n * the disguise whoever sends it. Not an own domain for the lure's \"is this\n * elsewhere\" test either way; it only ever adds a lookalike signal.\n */\n fromAddress?: string | null\n replyTo?: string | readonly string[] | null\n preheader?: string | null\n /**\n * Everything else the recipient reads or clicks: the body, the plain-text\n * part, a design's nodes serialized — any string. Links are found by\n * shape, so a JSON-encoded design is as readable here as HTML.\n */\n bodies?: readonly (string | null | undefined)[]\n /**\n * The workspace's own names — org, site, subdomain. A brand in one of them\n * is the workspace's own, and `brand-sender` / `brand-lure-link` do not\n * fire for it. The lookalike check does not consult names: a workspace\n * NAMED \"Poshmark\" linking to `poshmark.id63835663.shop` is the incident.\n */\n ownNames?: readonly (string | null | undefined)[]\n /**\n * The workspace's own hosts — its subdomain on the tenant apex, custom\n * domain, sending domain. A link to one of them, or below one, is never\n * the \"somewhere else\" of a lure. Matched by host, never by registrable\n * domain: every site's subdomain shares the tenant apex, and a link to a\n * NEIGHBOR's site is somewhere else.\n *\n * Not an exemption from the lookalike check. A host shaped like\n * `paypal-secure.com` is a lookalike whoever attached it, and a workspace\n * that attached it has attached the disguise.\n */\n ownDomains?: readonly (string | null | undefined)[]\n}\n\nexport interface PhishingScreenVerdict {\n /** True when the message should be held for staff review. */\n hold: boolean\n signals: PhishingScreenSignal[]\n}\n\n/** The registrable domain of a host: `a.b.evil.co.uk` → `evil.co.uk`. */\nexport function registrableDomain(host: string): string {\n const labels = String(host ?? '')\n .toLowerCase()\n .replace(/\\.+$/, '')\n .split('.')\n .filter(Boolean)\n if (labels.length <= 2) return labels.join('.')\n const lastTwo = labels.slice(-2).join('.')\n return TWO_LABEL_SUFFIXES.has(lastTwo)\n ? labels.slice(-3).join('.')\n : lastTwo\n}\n\n/** `<label>.<suffix>` of a registrable domain, split once. */\nfunction splitRegistrable(registrable: string): { label: string; suffix: string } {\n const dot = registrable.indexOf('.')\n return dot < 0\n ? { label: registrable, suffix: '' }\n : { label: registrable.slice(0, dot), suffix: registrable.slice(dot + 1) }\n}\n\nfunction isOfficialDomain(brand: PhishingScreenBrand, registrable: string): boolean {\n if (brand.officialDomains.includes(registrable)) return true\n if (!brand.countryDomains) return false\n const base = splitRegistrable(brand.officialDomains[0]).label\n const { label, suffix } = splitRegistrable(registrable)\n return label === base && (/^[a-z]{2}$/.test(suffix) || TWO_LABEL_SUFFIXES.has(suffix))\n}\n\n/**\n * Is the workspace the brand itself, by DOMAIN: one of its own domains is\n * one of the brand's official ones (Aglyn's site on aglyn.com linking to\n * its own account on a video or help-desk vendor). Deliberately not by name — a workspace can call itself\n * \"Poshmark\", but it cannot serve on poshmark.com.\n */\nexport function isBrandsOwnDomain(\n brand: PhishingScreenBrand,\n ownRegistrables: ReadonlySet<string>,\n): boolean {\n return [...ownRegistrables].some((registrable) => isOfficialDomain(brand, registrable))\n}\n\n/** Every brand's real domains, for \"is this link just the brand itself\". */\nfunction isAnyOfficialDomain(registrable: string): boolean {\n return PHISHING_SCREEN_BRANDS.some((brand) => isOfficialDomain(brand, registrable))\n}\n\n/** Leetspeak folded, so `paypa1` reads as `paypal`. */\nfunction foldLeet(label: string): string {\n return label\n .replace(/0/g, 'o')\n .replace(/1/g, 'l')\n .replace(/3/g, 'e')\n .replace(/4/g, 'a')\n .replace(/5/g, 's')\n .replace(/7/g, 't')\n}\n\n/** Does one host label name the brand — whole, or hyphen-joined? */\nfunction labelNamesBrand(label: string, token: string, wordToken: boolean): boolean {\n if (wordToken) return label === token\n for (const candidate of new Set([label, foldLeet(label)])) {\n if (candidate === token) return true\n const parts = candidate.split('-')\n // A hyphen-joined token (`booking-com`) spans parts, so it is matched\n // as a run of parts rather than one of them.\n const tokenParts = token.split('-')\n for (let at = 0; at + tokenParts.length <= parts.length; at += 1) {\n if (tokenParts.every((part, offset) => parts[at + offset] === part)) {\n return true\n }\n }\n }\n return false\n}\n\n/**\n * Video and audio platforms whose account subdomains and embed URLs a page\n * or email plays media from: `player.vimeo.com`, `www.youtube.com/embed/…`.\n * A video plugin's own hosts are the plugin's to declare, not listed here. Anyone may embed or link media from these, so a\n * host on one is never a lookalike, whatever name its subdomain carries.\n */\nexport const MEDIA_EMBED_HOSTS: ReadonlySet<string> = new Set([\n 'vimeo.com', 'vimeocdn.com', 'youtube.com', 'youtu.be',\n 'youtube-nocookie.com', 'ytimg.com', 'loom.com', 'vidyard.com', 'brightcove.net',\n 'brightcove.com', 'jwplayer.com', 'jwpcdn.com', 'mux.com', 'cloudflarestream.com',\n 'videodelivery.net', 'dailymotion.com', 'twitch.tv', 'spotify.com', 'soundcloud.com',\n 'podbean.com', 'buzzsprout.com', 'simplecast.com', 'transistor.fm', 'anchor.fm',\n])\n\n/** The brand a host impersonates, or null. */\nexport function lookalikeBrandForHost(host: string): PhishingScreenBrand | null {\n const normalized = String(host ?? '').toLowerCase().replace(/\\.+$/, '')\n if (!normalized.includes('.')) return null\n const registrable = registrableDomain(normalized)\n if (MEDIA_EMBED_HOSTS.has(registrable)) return null\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (isOfficialDomain(brand, registrable)) continue\n if (brand.hostedDomains?.includes(registrable)) continue\n const labels = normalized.split('.')\n if (\n labels.some((label) =>\n brand.hostTokens.some((token) => labelNamesBrand(label, token, brand.wordToken === true)),\n )\n ) {\n return brand\n }\n // The brand's primary domain embedded in a longer, different one:\n // `booking.com.guest-review.top`, `paypal.com-secure.net`. Only the\n // primary: a short secondary (`me.com`, `aka.ms`) would match too much.\n const primary = brand.officialDomains[0]\n if (\n normalized.startsWith(`${primary}.`) ||\n normalized.startsWith(`${primary}-`) ||\n normalized.includes(`.${primary}.`) ||\n normalized.includes(`.${primary}-`)\n ) {\n return brand\n }\n }\n return null\n}\n\n/**\n * The few entity forms a phishing kit uses to keep a URL away from a naive\n * scanner (`.` for a dot, `&` inside a query). Decoded before links\n * are read; everything else is left alone.\n */\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&#x([0-9a-f]{1,6});/gi, (_, hex: string) => safeCodePoint(parseInt(hex, 16)))\n .replace(/&#(\\d{1,7});/g, (_, dec: string) => safeCodePoint(parseInt(dec, 10)))\n .replace(/&/gi, '&')\n}\n\nfunction safeCodePoint(value: number): string {\n return Number.isFinite(value) && value > 0 && value <= 0x10ffff\n ? String.fromCodePoint(value)\n : ''\n}\n\n/** Named entities a body uses for spacing, quoting and invisible splitting. */\nconst NAMED_ENTITIES: Record<string, string> = {\n nbsp: ' ',\n ensp: ' ',\n emsp: ' ',\n thinsp: ' ',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n shy: '',\n zwnj: '',\n zwj: '',\n}\n\n/*\n * Markup is read in single forward passes, never with a pattern that can\n * rescan to the end of the body from every `<`: the screen reads every\n * tenant message, and the tenant writes the body, so a million unclosed\n * `<` must cost a linear read.\n */\n/** An element whose contents a reader never sees: the start of its opening tag. */\nconst UNSEEN_ELEMENT_OPEN = /<(style|script|head|template)\\b/gi\n/** The name at the start of a tag that breaks a line or a block: a reader sees a gap there. */\nconst BREAKING_TAG_NAME =\n /^\\/?(?:br|p|div|li|ul|ol|tr|td|th|table|tbody|thead|h[1-6]|section|article|header|footer|blockquote|hr|center)\\b/i\n/** Characters that render as nothing, used to split a word for a scanner. */\nconst INVISIBLE_CHARACTERS = /[\\u00ad\\u200b-\\u200d\\u2060\\ufeff]/g\n\n/**\n * The text between the tags, joined with NO separator — or, with `breaks`,\n * with a space where a line or block breaks. A comment is dropped; a `<`\n * with no `>` after it is text.\n */\nfunction stripMarkup(html: string, breaks: boolean): string {\n let text = ''\n let at = 0\n while (at < html.length) {\n const open = html.indexOf('<', at)\n if (open < 0) return text + html.slice(at)\n text += html.slice(at, open)\n if (html.startsWith('<!--', open)) {\n const end = html.indexOf('-->', open + 4)\n if (end < 0) return text\n at = end + 3\n continue\n }\n const close = html.indexOf('>', open + 1)\n if (close < 0) return text + html.slice(open)\n if (breaks && BREAKING_TAG_NAME.test(html.slice(open + 1, Math.min(close, open + 12)))) text += ' '\n at = close + 1\n }\n return text\n}\n\n/** The markup with every unseen element and its contents taken out, in one pass. */\nfunction dropUnseenElements(html: string): string {\n const lower = html.toLowerCase()\n const open = new RegExp(UNSEEN_ELEMENT_OPEN.source, 'gi')\n let kept = ''\n let at = 0\n // Each search starts at or after the last; what it found (or that it found\n // nothing) still answers the next one, so no stretch is scanned twice.\n const found = new Map<string, number>()\n const find = (needle: string, from: number) => {\n const known = found.get(needle)\n if (known !== undefined && (known < 0 || known >= from)) return known\n const position = lower.indexOf(needle, from)\n found.set(needle, position)\n return position\n }\n for (let match = open.exec(html); match; match = open.exec(html)) {\n // No `>` after it: neither this nor anything later is a tag.\n const tagEnd = find('>', open.lastIndex)\n if (tagEnd < 0) break\n kept += `${html.slice(at, match.index)} `\n const name = match[1].toLowerCase()\n const close = find(`</${name}`, tagEnd + 1)\n // A head nobody closed ends where the body starts, as a browser reads it.\n const body = name === 'head' ? find('<body', tagEnd + 1) : -1\n if (body >= 0 && (close < 0 || body < close)) {\n at = body\n } else {\n const end = close < 0 ? -1 : find('>', close)\n // Never closed: only the opening tag goes, and what follows is still\n // read, so an unclosed `<style>` cannot hide the lure after it.\n at = end < 0 ? tagEnd + 1 : end + 1\n }\n open.lastIndex = at\n }\n return kept + html.slice(at)\n}\n\n/**\n * What a reader SEES in a body (AGL-3453): its text with the markup taken\n * out, the way a mail client or a browser draws it.\n *\n * A kit splits every letter of a brand and a lure with a tag —\n * `G<SPAN class=…>o<SPAN …>o…gle`, `P<SPAN …>a<SPAN …>s…word E<SPAN …>x…pired`\n * — so the raw HTML never contains the word a reader reads. Tags are\n * therefore removed with NO separator, which rejoins the letters; `<style>`,\n * `<script>` and `<head>` are dropped with their contents; comments and\n * zero-width characters are dropped; entities are decoded; whitespace is\n * collapsed. A second reading that puts a space where a line or block\n * breaks is added when it differs, so two words in two paragraphs are still\n * two words. Links are NOT read from this: an href lives inside a tag.\n */\nexport function visibleTextOf(html: string | null | undefined): string {\n const text = String(html ?? '')\n const source = text.includes('<') ? dropUnseenElements(text) : text\n const read = (breaks: boolean) =>\n decodeVisibleEntities(stripMarkup(source, breaks))\n .replace(INVISIBLE_CHARACTERS, '')\n .replace(/\\s+/g, ' ')\n .trim()\n const joined = read(false)\n const broken = read(true)\n return broken === joined ? joined : `${joined}\\n${broken}`\n}\n\n/** {@link decodeEntities}, after the named entities a body reads with. */\nfunction decodeVisibleEntities(text: string): string {\n return decodeEntities(\n text.replace(/&([a-z]{2,8});/gi, (entity, name: string) => NAMED_ENTITIES[name.toLowerCase()] ?? entity),\n )\n}\n\nconst URL_PATTERN = /\\b(?:https?:\\/\\/|www\\.)[^\\s\"'<>()\\\\[\\]{}]+/gi\n\n/** The hosts every link in the text points at, lowercased. */\nexport function linkHostsIn(text: string): string[] {\n const hosts = new Set<string>()\n for (const match of decodeEntities(String(text ?? '')).match(URL_PATTERN) ?? []) {\n let rest = match.replace(/^https?:\\/\\//i, '')\n rest = rest.split(/[/?#]/)[0]\n // `https://paypal.com@evil.top/` resolves to evil.top — and the part\n // before the `@` is exactly the disguise, so it is kept as a host too.\n const at = rest.lastIndexOf('@')\n const disguise = at >= 0 ? rest.slice(0, at) : ''\n rest = at >= 0 ? rest.slice(at + 1) : rest\n for (const candidate of [rest, disguise]) {\n const host = candidate.replace(/:\\d+$/, '').replace(/\\.+$/, '').toLowerCase()\n // A merge tag inside a URL is not a host anybody can visit yet.\n if (host && host.includes('.') && !host.includes('{') && !host.includes('%7b')) {\n hosts.add(host)\n }\n }\n }\n return [...hosts]\n}\n\n/** One link: the host it goes to, and its query and fragment, URL-decoded. */\ninterface LinkTarget {\n host: string\n query: string\n fragment: string\n}\n\n/** Every link in the text, with what it carries after its path. */\nfunction linkTargetsIn(text: string): LinkTarget[] {\n const targets: LinkTarget[] = []\n for (const match of decodeEntities(String(text ?? '')).match(URL_PATTERN) ?? []) {\n // The first host is where the browser goes; a userinfo disguise is not.\n const [host] = linkHostsIn(match)\n if (!host) continue\n const hash = match.indexOf('#')\n const beforeHash = hash < 0 ? match : match.slice(0, hash)\n const question = beforeHash.indexOf('?')\n targets.push({\n host,\n query: question < 0 ? '' : decodeUrlPart(beforeHash.slice(question + 1)),\n fragment: hash < 0 ? '' : decodeUrlPart(match.slice(hash + 1)),\n })\n }\n return targets\n}\n\nfunction decodeUrlPart(part: string): string {\n try {\n return decodeURIComponent(part)\n } catch {\n return part\n }\n}\n\nconst EMAIL_ADDRESS = /^[a-z0-9._%+-]+@[a-z0-9-]+(?:\\.[a-z0-9-]+)+$/i\nconst EMAIL_ADDRESS_IN_TEXT = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\\.[a-z0-9-]+)+)/gi\nconst BASE64_TEXT = /^[a-z0-9+/_-]{8,}={0,2}$/i\n\n/** A fragment read as base64, the other way a kit carries the address, or ''. */\nfunction base64Text(fragment: string): string {\n const decode = (globalThis as { atob?: (data: string) => string }).atob\n if (!decode || !BASE64_TEXT.test(fragment)) return ''\n try {\n return decode(fragment.replace(/-/g, '+').replace(/_/g, '/'))\n } catch {\n return ''\n }\n}\n\n/**\n * Where a link carries a reader's own address (AGL-3453), or null.\n *\n * - `fragment`: the WHOLE fragment is an address, plain or base64 —\n * `…#victim@example.com`. A fragment never reaches the server; the only\n * thing that reads it is the landing page's script, filling a sign-in\n * form so the reader sees their own address and types the password.\n * - `parameter`: an address that is not the workspace's own inside a query\n * or a longer fragment — `?email=victim@example.com`, a hash route's\n * `#/login?email=…`. Ordinary in a sign-up or a SaaS login link, so softer.\n */\nfunction prefilledAddressIn(\n target: LinkTarget,\n isOwnHost: (host: string) => boolean,\n): 'fragment' | 'parameter' | null {\n const fragment = target.fragment.trim()\n if (fragment && (EMAIL_ADDRESS.test(fragment) || EMAIL_ADDRESS.test(base64Text(fragment).trim()))) {\n return 'fragment'\n }\n for (const part of [target.query, target.fragment]) {\n // An address is short; a tracking token can be kilobytes of the\n // characters an address is made of, so only the head of one is read.\n if (!part.includes('@')) continue\n for (const match of part.slice(0, 4096).matchAll(EMAIL_ADDRESS_IN_TEXT)) {\n if (!isOwnHost(match[1].toLowerCase())) return 'parameter'\n }\n }\n return null\n}\n\nconst ADDRESS_HOST_PATTERN = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\\.[a-z0-9-]+)+)/gi\n\n/** The host of every email address in the text — a reply-to, a `mailto:`. */\nfunction addressHostsIn(text: string): string[] {\n const hosts = new Set<string>()\n for (const match of decodeEntities(String(text ?? '')).matchAll(ADDRESS_HOST_PATTERN)) {\n hosts.add(match[1].toLowerCase().replace(/\\.+$/, ''))\n }\n return [...hosts]\n}\n\n/** Lowercased alphanumerics only, so \"Wells-Fargo Advisors\" contains `wellsfargo`. */\nfunction squash(text: string): string {\n return text.toLowerCase().replace(/[^a-z0-9]/g, '')\n}\n\n/** Is this brand the workspace's own, by name or by a domain it holds? */\nfunction isOwnBrand(\n brand: PhishingScreenBrand,\n ownNames: string,\n ownRegistrables: ReadonlySet<string>,\n): boolean {\n const labels = [brand.id, squash(brand.label), ...brand.hostTokens.map(squash)]\n if (labels.some((label) => label && ownNames.includes(label))) return true\n return [...ownRegistrables].some((registrable) => isOfficialDomain(brand, registrable))\n}\n\n/*\n * The same judgements, for the other surfaces that read content with this\n * screen's data (`hosted-page-screen.ts`). Exported under these names rather\n * than copied, so a page and an email can never disagree about what a\n * brand's own domain is or whose brand a name is.\n */\n\n/** `squash`: lowercased alphanumerics, the form own-name matching reads. */\nexport const squashScreenText = squash\n/** Is this brand the workspace's own, by name (squashed) or by a domain it holds? */\nexport const isWorkspaceOwnBrand = isOwnBrand\n/** Is this registrable domain one of any listed brand's own? */\nexport const isAnyOfficialBrandDomain = isAnyOfficialDomain\n/** Is this registrable domain a social, maps or review link merchants ordinarily carry? */\nexport function isCommonLinkDomain(registrable: string): boolean {\n return COMMON_LINK_DOMAINS.has(registrable)\n}\n\n/**\n * Screen one outbound message. See the module header for what holds and why.\n */\nexport function screenOutboundEmail(input: PhishingScreenInput): PhishingScreenVerdict {\n const signals: PhishingScreenSignal[] = []\n const ownNames = squash((input.ownNames ?? []).filter(Boolean).join(' '))\n const ownHosts = (input.ownDomains ?? [])\n .map((domain) => String(domain ?? '').trim().toLowerCase().replace(/\\.+$/, ''))\n .filter((domain) => domain.includes('.'))\n const ownRegistrables = new Set(ownHosts.map(registrableDomain))\n const isOwnHost = (host: string) =>\n ownHosts.some((own) => host === own || host.endsWith(`.${own}`))\n\n const parts = [input.subject, input.preheader, ...(input.bodies ?? [])].filter(\n (part): part is string => typeof part === 'string' && part.length > 0,\n )\n // Links are read from the raw copy, where an href lives; brands and lures\n // from what a reader sees, where a tag cannot split a word (AGL-3453).\n const copy = parts.join('\\n')\n const visibleCopy = parts.map(visibleTextOf).join('\\n')\n const replyTo = Array.isArray(input.replyTo)\n ? input.replyTo.join(' ')\n : String(input.replyTo ?? '')\n const linkHosts = linkHostsIn(copy)\n\n // 1. A lookalike host, anywhere a recipient could click, write back, or\n // read as the sender.\n const seenLookalike = new Set<string>()\n const fromAddress = String(input.fromAddress ?? '')\n for (const host of [...linkHosts, ...addressHostsIn(`${copy}\\n${replyTo}\\n${fromAddress}`)]) {\n if (seenLookalike.has(host)) continue\n const brand = lookalikeBrandForHost(host)\n if (brand && !isBrandsOwnDomain(brand, ownRegistrables)) {\n seenLookalike.add(host)\n signals.push({ code: 'lookalike-link', brand: brand.id, host })\n }\n }\n\n // 2. A brand in the sender's display name that is not the workspace's.\n const fromName = String(input.fromName ?? '').trim()\n if (fromName) {\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (brand.mention.test(fromName) && !isOwnBrand(brand, ownNames, ownRegistrables)) {\n signals.push({ code: 'brand-sender', brand: brand.id, fromName: fromName.slice(0, 120) })\n }\n }\n }\n\n // 3. Brand + lure + a link to somewhere that is nobody's we know.\n const isElsewhere = (host: string) => {\n if (isOwnHost(host)) return false\n const registrable = registrableDomain(host)\n return !isAnyOfficialDomain(registrable) && !COMMON_LINK_DOMAINS.has(registrable)\n }\n const lure = PHISHING_LURE_PATTERNS.map((pattern) => visibleCopy.match(pattern)?.[0])\n .find(Boolean)\n if (lure) {\n const foreign = linkHosts.find(isElsewhere)\n if (foreign) {\n const namedInCopy = `${visibleCopy}\\n${fromName}`\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (brand.mention.test(namedInCopy) && !isOwnBrand(brand, ownNames, ownRegistrables)) {\n signals.push({\n code: 'brand-lure-link',\n brand: brand.id,\n lure: lure.slice(0, 120),\n host: foreign,\n })\n break\n }\n }\n }\n }\n\n // 4. An account lure beside a link elsewhere that carries the reader's own\n // address, filled in for the sign-in form at the far end (AGL-3453).\n const accountLure = ACCOUNT_LURE_PATTERNS.map((pattern) => visibleCopy.match(pattern)?.[0]).find(Boolean)\n if (accountLure) {\n let prefill: { host: string; place: 'fragment' | 'parameter' } | null = null\n for (const target of linkTargetsIn(copy)) {\n if (!isElsewhere(target.host)) continue\n const place = prefilledAddressIn(target, isOwnHost)\n if (place && (!prefill || (place === 'fragment' && prefill.place !== 'fragment'))) {\n prefill = { host: target.host, place }\n }\n }\n if (prefill) {\n signals.push({\n code: 'recipient-prefill-link',\n host: prefill.host,\n lure: accountLure.slice(0, 120),\n place: prefill.place,\n })\n }\n }\n\n return { hold: signals.length > 0, signals }\n}\n\n/** The brand's label for a stored id, for the staff surface. */\nexport function phishingScreenBrandLabel(id: string): string {\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.id === id)?.label ?? id\n}\n\n/** One line per signal, in words staff read on the review row. */\nexport function describePhishingScreenSignals(\n signals: readonly PhishingScreenSignal[],\n): string[] {\n return signals.map((signal) => {\n const brand = 'brand' in signal ? phishingScreenBrandLabel(signal.brand) : ''\n switch (signal.code) {\n case 'lookalike-link':\n return `Links to ${signal.host}, which wears the ${brand} name but is not ${brand}'s domain.`\n case 'brand-sender':\n return `Sends as \"${signal.fromName}\", naming ${brand}, which is not this workspace.`\n case 'brand-lure-link':\n return `Names ${brand}, asks the reader to act (\"${signal.lure}\"), and links to ${signal.host}.`\n case 'credential-field':\n return `Asks for a ${\n signal.field === 'card' ? 'card number' : signal.field === 'otp' ? 'one-time code' : 'password'\n } in its own field (\"${signal.label}\"), outside the platform's sign-in and checkout elements.`\n case 'brand-action-page':\n return `Names ${brand} beside a call to action (\"${signal.action}\"), and this workspace is not ${brand}.`\n case 'brand-lure-page':\n return `Names ${brand} on a page that asks visitors to act (\"${signal.lure}\") and links to ${signal.host}, and this workspace is not ${brand}.`\n case 'offsite-action-page':\n return `Its call to action (\"${signal.action}\") sends visitors off the site to ${signal.host}, on a page that reads \"${signal.lure}\".`\n case 'offsite-redirect':\n return `Redirects ${signal.source}, a path that reads \"${signal.lure}\", off the site to ${signal.host}.`\n case 'recipient-prefill-link':\n return `Links to ${signal.host} with the recipient's own address in the ${\n signal.place === 'fragment' ? 'fragment' : 'link'\n }, so a sign-in form there opens filled in, beside \"${signal.lure}\".`\n default:\n return 'Phishing signal.'\n }\n })\n}\n\n/*==========================================\n * RISK TIERS: who a signal holds for (AGL-3356, widened to every surface).\n *\n * The screen above finds signals; this decides which of them hold, the same\n * way on every surface that asks — an email at the send seam, a campaign\n * before it is claimed, a page at publish, a subdomain at creation.\n *\n * - STRONG: a lookalike host. A link to `poshmark.id63835663.shop` or\n * `paypa1.com` is a disguise whoever wears it and however old the\n * workspace is, so it holds for EVERY workspace, on every message and\n * page, transactional mail included. A merchant has no ordinary reason to\n * link to a host shaped like somebody else's brand.\n * - STRONG, too: account or password phrasing beside a link elsewhere whose\n * whole FRAGMENT is the reader's address (AGL-3453). A fragment never\n * reaches a server, so the address there is for the landing page's script\n * to fill a sign-in form with; a merchant's own reset mail links to its\n * own domain, and a SaaS login link puts the address in its query, which\n * is soft.\n * - SOFT: a brand in the sender name, the three-part lure, a brand's name\n * beside a sign-in or payment call to action on a page (in one element,\n * or anywhere on a page that carries a lure), a call to action or a\n * redirect that leaves the site beside account or document-share wording,\n * the reader's address in a query beside account phrasing.\n * Each is shaped like phishing but also like a clumsy legitimate message,\n * so they hold\n * only for a workspace in its first {@link OUTBOUND_REVIEW_YOUNG_DAYS}\n * days — the incident's window — and NEVER for mail the recipient's own\n * act made owed ({@link OutboundScreenPolicy.owed}).\n *\n * A credential-harvest page (a password, card or one-time-code field that\n * is not one of the platform's own sign-in or checkout elements) is STRONG:\n * see `hosted-page-screen.ts`.\n *=========================================*/\n\n/** A workspace younger than this many days has the soft rules applied. */\nexport const OUTBOUND_REVIEW_YOUNG_DAYS = 14\n\n/** Which tier a signal belongs to. */\nexport type PhishingSignalTier = 'strong' | 'soft'\n\n/** The signal codes that hold for every workspace. */\nexport const STRONG_PHISHING_SIGNAL_CODES: ReadonlySet<string> = new Set([\n 'lookalike-link',\n 'credential-field',\n])\n\n/**\n * Hosts that give each customer an account subdomain named after the\n * customer: `acme.zendesk.com` is Acme's own help desk. A brand's name there is usually the brand itself, so a\n * lookalike on one of these is SOFT — held for a young workspace, never a\n * takedown of an established one's page or mail. A lookalike on any other\n * host (`poshmark.id63835663.shop`) stays STRONG.\n */\nexport const ACCOUNT_SUBDOMAIN_HOSTS: ReadonlySet<string> = new Set([\n 'vimeo.com', 'vimeocdn.com', 'zendesk.com', 'freshdesk.com',\n 'helpscoutdocs.com', 'intercom.help', 'statuspage.io', 'atlassian.net', 'myshopify.com',\n 'squarespace.com', 'wixsite.com', 'webflow.io', 'hubspotpagebuilder.com', 'substack.com',\n 'typeform.com', 'calendly.com', 'gitbook.io', 'readme.io', 'notion.site', 'github.io',\n 'cloudfront.net', 'kajabi.com', 'thinkific.com', 'teachable.com', 'mailchimpsites.com',\n])\n\nexport function phishingSignalTier(signal: {\n code: string\n host?: string\n place?: string\n}): PhishingSignalTier {\n if (signal?.code === 'recipient-prefill-link') {\n return signal.place === 'fragment' ? 'strong' : 'soft'\n }\n if (!STRONG_PHISHING_SIGNAL_CODES.has(signal?.code)) return 'soft'\n if (\n signal.code === 'lookalike-link' &&\n typeof signal.host === 'string' &&\n ACCOUNT_SUBDOMAIN_HOSTS.has(registrableDomain(signal.host))\n ) {\n return 'soft'\n }\n return 'strong'\n}\n\n/** Is a workspace of this age (days, `null` = unreadable) screened by the soft rules? */\nexport function isYoungWorkspaceAge(ageDays: number | null | undefined): boolean {\n return typeof ageDays === 'number' && Number.isFinite(ageDays) && ageDays < OUTBOUND_REVIEW_YOUNG_DAYS\n}\n\nexport interface OutboundScreenPolicy {\n /**\n * The workspace's age in days, or `null` when its creation date cannot be\n * read — an org that predates the field, which is an EXISTING customer and\n * is not young.\n */\n ageDays: number | null\n /**\n * The recipient's own act made this message owed: a receipt for their\n * order, a confirmation of their booking, a reset of their password. The\n * soft rules never hold it. The lookalike rule still does — a receipt that\n * links to a Poshmark lookalike is the disguise, not the receipt.\n */\n owed?: boolean\n}\n\n/** The signals that HOLD under the tiers, for this workspace and message. */\nexport function signalsThatHold<T extends { code: string; host?: string }>(\n signals: readonly T[],\n policy: OutboundScreenPolicy,\n): T[] {\n const soft = isYoungWorkspaceAge(policy.ageDays) && !policy.owed\n return signals.filter((signal) => phishingSignalTier(signal) === 'strong' || soft)\n}\n\n/**\n * The same brand, lookalike and tier logic applied to a HOST NAME a workspace\n * asks for — a subdomain on the tenant apex, or a custom domain it attaches.\n *\n * Words a brand's impersonator hyphen-joins to its name. A subdomain that\n * joins a brand's word to one of these (`booking-review`, `apple-support`,\n * `amazon-account`) is the incident's shape even where the brand's word is\n * an ordinary one — which the lookalike rule alone deliberately lets pass,\n * so a salon can be `tanyas-booking` and a bakery `apple-pie-co`.\n */\nexport const BRAND_IMPERSONATION_WORDS: ReadonlySet<string> = new Set([\n 'account', 'accounts', 'auth', 'billing', 'help', 'helpdesk', 'id', 'login',\n 'logon', 'order', 'orders', 'pay', 'payment', 'payments', 'refund', 'resolution',\n 'review', 'reviews', 'secure', 'security', 'seller', 'service', 'signin',\n 'support', 'update', 'verify', 'verification', 'wallet',\n])\n\n/**\n * The brand a requested subdomain label wears, or null.\n *\n * Refused for EVERY workspace, at creation and at rename — the tier is\n * strong, because nothing is lost by asking a real bakery to pick\n * `apple-pie-co` instead of `apple-support`, and a brand's name on our apex\n * is a disguise that outlives every later screen. Two shapes:\n *\n * 1. the label is a lookalike host label ({@link lookalikeBrandForHost} on\n * `<label>.<apex>`): `poshmark`, `paypal-secure`, `paypa1`, `appleid`;\n * 2. a brand's word hyphen-joined to an impersonation word\n * ({@link BRAND_IMPERSONATION_WORDS}): `booking-review`, `apple-support`.\n */\nexport function brandForSubdomainLabel(\n label: string,\n apex = 'example.invalid',\n): PhishingScreenBrand | null {\n const normalized = String(label ?? '').trim().toLowerCase()\n if (!normalized) return null\n const byHost = lookalikeBrandForHost(`${normalized}.${apex}`)\n if (byHost) return byHost\n const parts = foldLeet(normalized).split('-').filter(Boolean)\n if (parts.length < 2 || !parts.some((part) => BRAND_IMPERSONATION_WORDS.has(part))) {\n return null\n }\n for (const brand of PHISHING_SCREEN_BRANDS) {\n const words = [brand.id, ...brand.hostTokens].filter((word) => !word.includes('-'))\n if (parts.some((part) => words.includes(part))) return brand\n }\n return null\n}\n\n/**\n * The platform's own entry in {@link PHISHING_SCREEN_BRANDS} (AGL-3365). A\n * workspace owns every other brand by carrying its name or domain; the\n * platform's is owned only by the platform's staff, because a workspace NAMED\n * for the platform is the cheapest disguise there is.\n */\nexport const PLATFORM_PHISHING_BRAND_ID = 'aglyn'\n\n/** The platform's brand entry. */\nexport function platformPhishingBrand(): PhishingScreenBrand {\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.id === PLATFORM_PHISHING_BRAND_ID) as PhishingScreenBrand\n}\n\n/**\n * Words that make a name claim to SPEAK FOR a brand rather than mention it:\n * \"PayPal Support\", \"Aglyn Official\", \"Apple ID Security Team\".\n */\nconst OFFICIAL_CLAIM_PATTERN =\n /\\b(?:official|staff|team|verified|certified|support|helpdesk|admin|administrator|security|billing|trust|safety|compliance|core|headquarters|hq)\\b/i\n\n/**\n * The brand a display NAME claims to speak for (AGL-3365), or null.\n *\n * For names a stranger reads as an identity — a marketplace publisher, a\n * listing's title — rather than copy. A name that merely mentions a brand\n * (\"Sync for PayPal\", \"Bookings for Airbnb hosts\") passes: that is how an\n * integration is named. A name that pairs the brand with a claim of\n * officialness (\"PayPal Support\", \"Aglyn Official Plugins\") is the disguise.\n */\nexport function brandClaimedByName(name: string): PhishingScreenBrand | null {\n const text = String(name ?? '')\n if (!text.trim() || !OFFICIAL_CLAIM_PATTERN.test(text)) return null\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.mention.test(text)) ?? null\n}\n"],"names":["PHISHING_SCREEN_BRANDS","id","label","mention","hostTokens","officialDomains","countryDomains","wordToken","hostedDomains","ACCOUNT_LURE_PATTERNS","DOCUMENT_SHARE_LURE_PATTERNS","SALE_AND_PARCEL_LURE_PATTERNS","PHISHING_LURE_PATTERNS","COMMON_LINK_DOMAINS","Set","TWO_LABEL_SUFFIXES","registrableDomain","host","labels","String","toLowerCase","replace","split","filter","Boolean","length","join","lastTwo","slice","has","splitRegistrable","registrable","dot","indexOf","suffix","isOfficialDomain","brand","includes","base","test","isBrandsOwnDomain","ownRegistrables","some","isAnyOfficialDomain","foldLeet","labelNamesBrand","token","candidate","parts","tokenParts","at","every","part","offset","MEDIA_EMBED_HOSTS","lookalikeBrandForHost","normalized","primary","startsWith","decodeEntities","text","_","hex","safeCodePoint","parseInt","dec","value","Number","isFinite","fromCodePoint","NAMED_ENTITIES","nbsp","ensp","emsp","thinsp","lt","gt","quot","apos","shy","zwnj","zwj","UNSEEN_ELEMENT_OPEN","BREAKING_TAG_NAME","INVISIBLE_CHARACTERS","stripMarkup","html","breaks","open","end","close","Math","min","dropUnseenElements","lower","RegExp","source","kept","found","Map","find","needle","from","known","get","undefined","position","set","match","exec","tagEnd","lastIndex","index","name","body","visibleTextOf","read","decodeVisibleEntities","trim","joined","broken","entity","URL_PATTERN","linkHostsIn","hosts","rest","lastIndexOf","disguise","add","linkTargetsIn","targets","hash","beforeHash","question","push","query","decodeUrlPart","fragment","decodeURIComponent","EMAIL_ADDRESS","EMAIL_ADDRESS_IN_TEXT","BASE64_TEXT","base64Text","decode","globalThis","atob","prefilledAddressIn","target","isOwnHost","matchAll","ADDRESS_HOST_PATTERN","addressHostsIn","squash","isOwnBrand","ownNames","map","squashScreenText","isWorkspaceOwnBrand","isAnyOfficialBrandDomain","isCommonLinkDomain","screenOutboundEmail","input","signals","ownHosts","ownDomains","domain","own","endsWith","subject","preheader","bodies","copy","visibleCopy","replyTo","Array","isArray","linkHosts","seenLookalike","fromAddress","code","fromName","isElsewhere","lure","pattern","foreign","namedInCopy","accountLure","prefill","place","hold","phishingScreenBrandLabel","describePhishingScreenSignals","signal","field","action","OUTBOUND_REVIEW_YOUNG_DAYS","STRONG_PHISHING_SIGNAL_CODES","ACCOUNT_SUBDOMAIN_HOSTS","phishingSignalTier","isYoungWorkspaceAge","ageDays","signalsThatHold","policy","soft","owed","BRAND_IMPERSONATION_WORDS","brandForSubdomainLabel","apex","byHost","words","word","PLATFORM_PHISHING_BRAND_ID","platformPhishingBrand","OFFICIAL_CLAIM_PATTERN","brandClaimedByName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA2D2C,GAE3C,qCAAqC,GA2CrC,OAAO,MAAMA,yBAAyD;IACpE;QACEC,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAW;QACxBC,iBAAiB;YAAC;YAAgB;SAAU;IAC9C;IACA;QACEJ,IAAI;QACJC,OAAO;QACP,qEAAqE;QACrEC,SAAS;QACTC,YAAY;YAAC;YAAc;SAAc;QACzCC,iBAAiB;YAAC;YAAe;SAAc;IACjD;IACA;QACEJ,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAS;QACtBC,iBAAiB;YAAC;YAAc;YAAW;SAAe;QAC1DC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAS;QACtBC,iBAAiB;YAAC;YAAc;YAAa;SAAoB;QACjEC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;YAAU;SAAO;QAC9BG,WAAW;QACXF,iBAAiB;YACf;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACP,yEAAyE;QACzEC,SAAS;QACTC,YAAY;YAAC;YAAS;YAAW;YAAU;SAAS;QACpDG,WAAW;QACXF,iBAAiB;YAAC;YAAa;YAAc;YAAY;YAAc;YAAU;SAAe;QAChGC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACP,sEAAsE;QACtE,cAAc;QACdC,SACE;QACFC,YAAY;YACV;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,iBAAiB;YACf;YACA;YACA;YACA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,OAAO;AACT;AAEA;;;;;CAKC,GACD,OAAO,MAAM+K,6BAA6B,QAAO;AAEjD,gCAAgC,GAChC,OAAO,SAASC;IACd,OAAOpN,uBAAuBoG,IAAI,CAAC,CAAChE,QAAUA,MAAMnC,EAAE,KAAKkN;AAC7D;AAEA;;;CAGC,GACD,MAAME,yBACJ;AAEF;;;;;;;;CAQC,GACD,OAAO,SAASC,mBAAmBrG,IAAY;QAGtCjH;IAFP,MAAM4D,OAAOzC,OAAO8F,eAAAA,OAAQ;IAC5B,IAAI,CAACrD,KAAK0D,IAAI,MAAM,CAAC+F,uBAAuB9K,IAAI,CAACqB,OAAO,OAAO;IAC/D,QAAO5D,+BAAAA,uBAAuBoG,IAAI,CAAC,CAAChE,QAAUA,MAAMjC,OAAO,CAACoC,IAAI,CAACqB,kBAA1D5D,+BAAoE;AAC7E"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/email/src/lib/outbound-phishing-screen.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE OUTBOUND PHISHING SCREEN (AGL-3356).\n *\n * A fraud actor signed up, paid with a card that never met 3-D Secure, and\n * used a workspace to send two kinds of mail: a campaign of Booking.com-style\n * \"guest feedback regarding your property\" lures to hotels, and a workflow\n * that mailed \"Poshmark Order — one of the items from your Seller Account has\n * finally sold\", linking to `poshmark.id63835663.shop`.\n *\n * This module answers one question about a message a YOUNG workspace is\n * about to send: does its content carry a STRONG phishing signal? The caller\n * decides who is young and what happens to a positive answer — the answer is\n * a hold for staff review, never a drop.\n *\n * ## Conservative by construction\n *\n * A false positive costs a real merchant's first campaign a wait for a\n * human; a miss costs strangers their bank logins. Both are real, so only\n * four shapes hold, and each is one a legitimate merchant essentially never\n * produces:\n *\n * 1. **A lookalike link** — a link or reply address whose host carries a\n * brand's name without being the brand's own domain: the brand as a label\n * of an unrelated registrable domain (`poshmark.id63835663.shop`), hyphen-\n * joined to one (`paypal-secure.com`, `secure-paypal.net`), the brand's\n * real domain embedded in a longer host (`booking.com.guest-review.top`),\n * or leetspeak for it (`paypa1.com`). Holds on its own.\n * 2. **A brand in the sender's display name** that is not the workspace's\n * own name — mail that says it is FROM PayPal.\n * 3. **The three-part lure**: a brand named in the copy, AND credential or\n * account-action phrasing (\"verify your account\", \"has finally sold\",\n * \"feedback regarding your property\"), AND a link to a domain that is\n * neither the brand's, nor the workspace's, nor a common social or maps\n * link. Any two of the three are ordinary marketing — \"our book is on\n * Amazon\", \"sign in to your account\", a link to the shop — and pass.\n * 4. **A prefilled sign-in** (AGL-3453): account or password phrasing\n * (\"your password expires today\") beside a link to such a domain that\n * carries the reader's own address, so the harvester's form opens with\n * it filled in: `…/ss/c/…#victim@example.com`.\n *\n * Mentioning a brand, alone, never holds. Brands and lures are read from\n * what the reader SEES ({@link visibleTextOf}), never from the raw HTML, in\n * which a kit splits every letter with a tag; links are read from the raw\n * HTML, where an href lives.\n *\n * ## The brand list is small on purpose\n *\n * The brands phishing kits most often wear, plus the two in the incident, and\n * the file-share and mail-security names a document-share lure wears — a\n * \"Secure Document Access Portal\" under Proofpoint's or SharePoint's name\n * whose one button leaves for the kit (AGL-3447). A brand is added when it\n * has been seen impersonated, not because it is big: every entry is a set of\n * words that can now hold somebody's newsletter.\n * Each carries its REAL domains, so a link to the brand itself is never\n * suspicious, and host tokens chosen so a common word (`booking`, `apple`,\n * `outlook`, `box`, `adobe`) does not match an unrelated host by itself.\n *\n * Pure: no DNS, no store, no clock. Everything the caller knows about the\n * workspace arrives as input.\n *=========================================*/\n\n/** One brand the screen recognizes. */\nexport interface PhishingScreenBrand {\n /** Stable id, as stored on a hold. */\n id: string\n /** How staff read it. */\n label: string\n /** Copy that names the brand — subject, body, sender. Case-insensitive. */\n mention: RegExp\n /**\n * Host labels that name the brand. Matched against each dot-separated\n * label of a link's host, whole or hyphen-joined, after leetspeak is\n * folded — never as a bare substring, which is how `amazonaws` or\n * `bookingengine` would read as a brand.\n */\n hostTokens: readonly string[]\n /**\n * Registrable domains the brand genuinely links from. The FIRST is its\n * primary domain, the one a kit embeds in a longer host.\n */\n officialDomains: readonly string[]\n /**\n * The brand's name is an ordinary word (`apple`, `amazon`), so a host\n * label names the brand only when it IS the word — `apple.example.top` —\n * and never hyphen-joined or leet-folded, which `apple-orchard-farm.com`\n * would otherwise be.\n */\n wordToken?: boolean\n /**\n * Whether `<brand>.<country code>` (and `<brand>.co.<cc>`) is the brand's\n * too — true for the marketplaces that run a site per country.\n */\n countryDomains?: boolean\n /**\n * Registrable domains the brand runs but where OTHER people's content lives —\n * the platform's own tenant apex, where every site is `<name>.<apex>`. A\n * host there never wears the brand as a disguise, so the lookalike rule\n * skips it; but it is not the brand's own domain either, so a link to a\n * neighbor's site still counts as \"somewhere else\" to the lure rules, and a\n * workspace hosted there does not own the brand by being hosted there.\n */\n hostedDomains?: readonly string[]\n}\n\nexport const PHISHING_SCREEN_BRANDS: readonly PhishingScreenBrand[] = [\n {\n id: 'poshmark',\n label: 'Poshmark',\n mention: /\\bposhmark\\b/i,\n hostTokens: ['poshmark'],\n officialDomains: ['poshmark.com', 'posh.mk'],\n },\n {\n id: 'booking',\n label: 'Booking.com',\n // Never the bare word: \"booking\" is every hotel's and every salon's.\n mention: /\\bbooking\\.com\\b/i,\n hostTokens: ['bookingcom', 'booking-com'],\n officialDomains: ['booking.com', 'bstatic.com'],\n },\n {\n id: 'airbnb',\n label: 'Airbnb',\n mention: /\\bairbnb\\b/i,\n hostTokens: ['airbnb'],\n officialDomains: ['airbnb.com', 'abnb.me', 'muscache.com'],\n countryDomains: true,\n },\n {\n id: 'paypal',\n label: 'PayPal',\n mention: /\\bpay\\s?pal\\b/i,\n hostTokens: ['paypal'],\n officialDomains: ['paypal.com', 'paypal.me', 'paypalobjects.com'],\n countryDomains: true,\n },\n {\n id: 'amazon',\n label: 'Amazon',\n mention: /\\bamazon\\b/i,\n hostTokens: ['amazon', 'amzn'],\n wordToken: true,\n officialDomains: [\n 'amazon.com',\n 'amzn.to',\n 'amzn.com',\n 'amazonaws.com',\n 'media-amazon.com',\n 'ssl-images-amazon.com',\n ],\n countryDomains: true,\n },\n {\n id: 'apple',\n label: 'Apple',\n // The fruit is on every bakery's menu; the account is what gets phished.\n mention: /\\bapple\\s?(?:id|support|account)\\b|\\bicloud\\b|\\bitunes\\b/i,\n hostTokens: ['apple', 'appleid', 'icloud', 'itunes'],\n wordToken: true,\n officialDomains: ['apple.com', 'icloud.com', 'apple.co', 'itunes.com', 'me.com', 'mzstatic.com'],\n countryDomains: true,\n },\n {\n id: 'microsoft',\n label: 'Microsoft',\n // Outlook only as the product — \"our 2026 outlook\" is every advisor's\n // newsletter.\n mention:\n /\\bmicrosoft\\b|\\b(?:office|ms|m)\\s?365\\b|\\bonedrive\\b|\\bsharepoint\\b|\\boutlook(?:\\.com|\\s+(?:web\\s+app|web\\s+access|online|account|365))\\b/i,\n hostTokens: [\n 'microsoft',\n 'microsoft365',\n 'office365',\n 'office-365',\n 'outlook365',\n 'onedrive',\n 'sharepoint',\n 'microsoftonline',\n 'msonline',\n ],\n officialDomains: [\n 'microsoft.com',\n 'office.com',\n 'office365.com',\n 'microsoft365.com',\n 'live.com',\n 'outlook.com',\n 'microsoftonline.com',\n 'sharepoint.com',\n 'sharepointonline.com',\n 'onedrive.com',\n '1drv.ms',\n 'aka.ms',\n ],\n },\n {\n id: 'docusign',\n label: 'DocuSign',\n mention: /\\bdocu\\s?sign\\b/i,\n hostTokens: ['docusign'],\n officialDomains: ['docusign.com', 'docusign.net'],\n },\n {\n id: 'google',\n label: 'Google',\n // The account and the files, never the bare name: \"find us on Google\"\n // and \"Google Maps\" are on every shop's contact page.\n mention: /\\bgoogle\\s?(?:drive|docs?|sheets|slides|workspace|account)\\b|\\bgmail\\b|\\bg\\s?suite\\b/i,\n // The products and the account, never the bare name: Google runs\n // hyphenated hosts of its own that a page embeds, and a bare `google`\n // token would read each as its lookalike. `docs.google.com.<kit>` is\n // still read, by the primary-domain rule.\n hostTokens: [\n 'gmail',\n 'gsuite',\n 'googledocs',\n 'googledrive',\n 'google-docs',\n 'google-drive',\n 'google-workspace',\n 'google-account',\n 'google-login',\n 'google-mail',\n 'docs-google',\n 'drive-google',\n ],\n officialDomains: [\n 'google.com',\n 'goo.gl',\n 'g.co',\n 'g.page',\n 'forms.gle',\n 'gmail.com',\n 'googleapis.com',\n 'gstatic.com',\n 'googleusercontent.com',\n 'withgoogle.com',\n ],\n countryDomains: true,\n },\n {\n id: 'adobe',\n label: 'Adobe',\n // \"Adobe\" alone is a house, a grill and an inn across the Southwest;\n // the products are what a lure names.\n mention:\n /\\badobe\\s?(?:acrobat|sign|id|account|document\\s?cloud|reader|pdf|creative\\s?cloud)\\b|\\bacrobat\\s?(?:reader|sign|pro)\\b|\\bechosign\\b/i,\n hostTokens: ['adobe', 'adobeid', 'adobesign', 'adobeacrobat', 'echosign'],\n wordToken: true,\n officialDomains: [\n 'adobe.com',\n 'adobe.io',\n 'adobe.ly',\n 'adobelogin.com',\n 'adobesign.com',\n 'echosign.com',\n 'acrobat.com',\n 'typekit.net',\n 'adobedtm.com',\n ],\n },\n {\n id: 'dropbox',\n label: 'Dropbox',\n // One word only: a \"drop box\" is by every library's door.\n mention: /\\bdropbox\\b/i,\n hostTokens: ['dropbox'],\n officialDomains: ['dropbox.com', 'db.tt', 'dropboxusercontent.com', 'dropboxstatic.com', 'hellosign.com'],\n },\n {\n // Never the bare word, as an id either — `brandForSubdomainLabel` reads\n // ids as words, and \"box\" is every lunch box's and subscription box's.\n id: 'boxcom',\n label: 'Box',\n mention: /\\bbox\\.com\\b|\\bbox\\s+drive\\b/i,\n hostTokens: ['boxcom', 'box-com'],\n officialDomains: ['box.com', 'box.net', 'boxcdn.net', 'boxcloud.com'],\n },\n {\n id: 'wetransfer',\n label: 'WeTransfer',\n // One word only: \"we transfer\" is a moving company's sentence.\n mention: /\\bwetransfer\\b/i,\n hostTokens: ['wetransfer'],\n officialDomains: ['wetransfer.com', 'we.tl'],\n },\n {\n id: 'sharefile',\n label: 'ShareFile',\n mention: /\\bshare\\s?file\\b/i,\n hostTokens: ['sharefile'],\n officialDomains: ['sharefile.com', 'sharefile.eu', 'citrix.com'],\n },\n {\n // A secure-mail gateway's name is what makes a document lure read as\n // safe: \"Proofpoint Encryption for your sensitive documents\".\n id: 'proofpoint',\n label: 'Proofpoint',\n // One word only: a \"proof point\" is every pitch deck's.\n mention: /\\bproofpoint\\b/i,\n hostTokens: ['proofpoint'],\n officialDomains: ['proofpoint.com', 'urldefense.com', 'pphosted.com', 'ppe-hosted.com'],\n },\n {\n id: 'mimecast',\n label: 'Mimecast',\n mention: /\\bmimecast\\b/i,\n hostTokens: ['mimecast'],\n officialDomains: ['mimecast.com', 'mimecastprotect.com'],\n },\n {\n id: 'netflix',\n label: 'Netflix',\n mention: /\\bnetflix\\b/i,\n hostTokens: ['netflix'],\n officialDomains: ['netflix.com', 'nflxext.com', 'nflximg.net'],\n },\n {\n id: 'wellsfargo',\n label: 'Wells Fargo',\n mention: /\\bwells\\s?fargo\\b/i,\n hostTokens: ['wellsfargo', 'wells-fargo'],\n officialDomains: ['wellsfargo.com'],\n },\n {\n id: 'bankofamerica',\n label: 'Bank of America',\n mention: /\\bbank\\s+of\\s+america\\b/i,\n hostTokens: ['bankofamerica', 'bofa'],\n officialDomains: ['bankofamerica.com', 'bofa.com'],\n },\n {\n id: 'coinbase',\n label: 'Coinbase',\n mention: /\\bcoinbase\\b/i,\n hostTokens: ['coinbase'],\n officialDomains: ['coinbase.com'],\n },\n {\n id: 'usps',\n label: 'USPS',\n mention: /\\busps\\b/i,\n hostTokens: ['usps'],\n officialDomains: ['usps.com'],\n },\n {\n id: 'fedex',\n label: 'FedEx',\n mention: /\\bfed\\s?ex\\b/i,\n hostTokens: ['fedex'],\n officialDomains: ['fedex.com'],\n },\n {\n id: 'dhl',\n label: 'DHL',\n mention: /\\bdhl\\b/i,\n hostTokens: ['dhl'],\n officialDomains: ['dhl.com'],\n countryDomains: true,\n },\n {\n // The platform itself (AGL-3365). A marketplace listing, a page or an\n // email that wears the platform's name — \"Aglyn Support\", a link to\n // `aglyn-billing.com`, \"official Aglyn plugin\" — is the one impersonation\n // every customer is primed to trust. The workspace named for it (the\n // platform's own org) owns it by name, as any brand's own workspace does.\n id: 'aglyn',\n label: 'Aglyn',\n mention: /\\baglyn\\b/i,\n hostTokens: ['aglyn'],\n officialDomains: ['aglyn.com', 'aglyn.io', 'aglyn.dev'],\n hostedDomains: ['aglyn.app'],\n },\n]\n\n/**\n * Account and credential phrasing: the lure that asks the reader to DO\n * something with an account — verify it, confirm it, sign in to it.\n */\nexport const ACCOUNT_LURE_PATTERNS: readonly RegExp[] = [\n /\\bverify\\s+your\\s+(?:account|identity|information|details|payment|email)\\b/i,\n /\\bconfirm\\s+your\\s+(?:account|identity|details|payment|password|billing|information)\\b/i,\n /\\b(?:account|payment|card)\\s+(?:has\\s+been\\s+|is\\s+|was\\s+|will\\s+be\\s+)?(?:suspended|locked|limited|restricted|disabled|deactivated|terminated|on\\s+hold)\\b/i,\n /\\bunusual\\s+(?:sign[-\\s]?in|login|activity)\\b/i,\n /\\bupdate\\s+your\\s+(?:payment|billing|card|account)\\s*(?:details|information|method)?\\b/i,\n /\\b(?:sign|log)\\s?in\\s+to\\s+(?:your|view|confirm|claim|release)\\b/i,\n // \"Password Expired\", \"your password expires today\", \"will expire\".\n /\\bpassword\\s+(?:has\\s+|will\\s+)?expire/i,\n /\\bkeep\\s+(?:your|my|the)\\s+(?:current\\s+|active\\s+|existing\\s+|same\\s+)?password\\b/i,\n /\\bchange\\s+(?:your\\s+)?password\\s+settings?\\b/i,\n /\\bmailbox\\s+(?:storage\\s+|quota\\s+)?(?:is\\s+)?(?:almost\\s+|nearly\\s+)?(?:full|exceeded)\\b/i,\n /\\bsecurity\\s+alert\\b/i,\n]\n\n/**\n * Document-share phrasing (AGL-3447): the lure that says a file is waiting\n * behind a secure door — \"Secure Document Access Portal\", \"Continue to\n * Document\", \"shared a file with you\", \"encrypted message\". The credential\n * harvest is on the far side of the button, so these are the words the page\n * or the mail itself carries.\n */\nexport const DOCUMENT_SHARE_LURE_PATTERNS: readonly RegExp[] = [\n /\\b(?:document|invoice|agreement)s?\\s+(?:is\\s+|are\\s+)?(?:ready|waiting|pending)\\s+(?:for\\s+)?(?:your\\s+)?(?:review|signature|to\\s+sign)\\b/i,\n /\\b(?:view|access|open)\\s+(?:the\\s+|your\\s+)?secure\\s+(?:file|document|message)s?\\b/i,\n /\\bsecure\\s+(?:file|document|message)s?\\b/i,\n /\\bdocument\\s+access\\b/i,\n /\\baccess\\s+portal\\b/i,\n /\\b(?:continue|proceed)\\s+to\\s+(?:the\\s+|your\\s+)?(?:document|file)s?\\b/i,\n /\\bshared\\s+(?:a|an|the)\\s+(?:file|document|folder)\\s+with\\s+you\\b/i,\n /\\b(?:file|document|folder)s?\\s+(?:has\\s+been|have\\s+been|was|were)\\s+shared\\s+with\\s+you\\b/i,\n /\\bencrypted\\s+(?:message|document|file|email)s?\\b/i,\n]\n\n/**\n * Marketplace, booking and parcel phrasing: the lure that says a sale, a\n * guest or a delivery needs the reader. The incident's Poshmark and\n * Booking.com mail.\n */\nconst SALE_AND_PARCEL_LURE_PATTERNS: readonly RegExp[] = [\n /\\b(?:has|have)\\s+(?:finally\\s+)?sold\\b/i,\n /\\bseller\\s+account\\b/i,\n /\\b(?:guest|customer)\\s+(?:complaint|review|feedback)\\b/i,\n /\\bfeedback\\s+regarding\\s+your\\s+(?:property|listing|stay|booking|reservation)\\b/i,\n /\\bclaim\\s+your\\s+(?:refund|reward|prize|package|payment|funds)\\b/i,\n /\\b(?:delivery|shipment)\\s+(?:failed|attempt|suspended|on\\s+hold)\\b/i,\n /\\b(?:package|parcel)\\s+(?:is\\s+)?(?:on\\s+hold|held|awaiting|undeliverable)\\b/i,\n]\n\n/**\n * Every lure — the half of the three-part lure that asks the reader to act.\n * Only ever counted beside a brand AND a foreign link; alone, several of\n * these are ordinary transactional copy.\n */\nexport const PHISHING_LURE_PATTERNS: readonly RegExp[] = [\n ...ACCOUNT_LURE_PATTERNS,\n ...DOCUMENT_SHARE_LURE_PATTERNS,\n ...SALE_AND_PARCEL_LURE_PATTERNS,\n]\n\n/**\n * Link targets a merchant's mail ordinarily carries that are not theirs:\n * social profiles, maps, review sites, video. Counted as neither foreign nor\n * suspicious in the three-part lure, so \"leave us a review on Google\" with a\n * brand named elsewhere does not become a hold. Never consulted by the\n * lookalike check, which holds on the host's own shape.\n */\nconst COMMON_LINK_DOMAINS: ReadonlySet<string> = new Set([\n 'facebook.com',\n 'fb.com',\n 'instagram.com',\n 'x.com',\n 'twitter.com',\n 'linkedin.com',\n 'youtube.com',\n 'youtu.be',\n 'tiktok.com',\n 'pinterest.com',\n 'google.com',\n 'goo.gl',\n 'g.page',\n 'yelp.com',\n 'tripadvisor.com',\n 'wa.me',\n 'whatsapp.com',\n])\n\n/**\n * Two-label public suffixes, so `evil.co.uk` registers as `evil.co.uk` and\n * not as `co.uk`. Deliberately a short list of the ones mail actually\n * arrives from rather than the whole public suffix list: a suffix missing\n * here makes the registrable domain one label too short, which can only\n * widen what counts as \"the same domain\" for a link — never invent a brand\n * label that is not in the host.\n */\nconst TWO_LABEL_SUFFIXES: ReadonlySet<string> = new Set([\n 'co.uk', 'org.uk', 'ac.uk', 'gov.uk', 'me.uk',\n 'com.au', 'net.au', 'org.au',\n 'co.nz', 'co.jp', 'co.kr', 'co.in', 'co.za', 'co.il', 'co.id', 'co.th',\n 'com.br', 'com.mx', 'com.ar', 'com.tr', 'com.cn', 'com.hk', 'com.sg',\n 'com.tw', 'com.my', 'com.ph', 'com.co', 'com.pe', 'com.sa', 'com.eg',\n])\n\n/** A signal the screen found. */\nexport type PhishingScreenSignal =\n | { code: 'lookalike-link'; brand: string; host: string }\n | { code: 'brand-sender'; brand: string; fromName: string }\n | { code: 'brand-lure-link'; brand: string; lure: string; host: string }\n /**\n * A published page asks for a password, a card number or a one-time code\n * in a field that is not one of the platform's own sign-in or checkout\n * elements (`hosted-page-screen.ts`). Strong.\n */\n | { code: 'credential-field'; field: 'password' | 'card' | 'otp'; label: string }\n /**\n * A published page names a brand that is not the workspace's beside a\n * sign-in, verify or payment call to action (`hosted-page-screen.ts`).\n * Soft.\n */\n | { code: 'brand-action-page'; brand: string; action: string }\n /**\n * The same, read over the page as a WHOLE (AGL-3447): a brand that is not\n * the workspace's anywhere on a page that carries an account or\n * document-share lure anywhere, or whose call to action leaves the site\n * worded as one, and that links away (`hosted-page-screen.ts`). Soft.\n */\n | { code: 'brand-lure-page'; brand: string; lure: string; host: string }\n /**\n * A published page's call to action — its only one, or one worded as an\n * account or document action — sends visitors to a host that is not the\n * site's, a listed brand's or a common link, on a page that carries an\n * account or document-share lure (`hosted-page-screen.ts`, AGL-3447). No\n * brand needed. Soft.\n */\n | { code: 'offsite-action-page'; action: string; lure: string; host: string }\n /**\n * A site redirect whose path reads as an account or document-share lure\n * sends visitors to such a host (`screenSiteRedirect`, AGL-3447). Soft.\n */\n | { code: 'offsite-redirect'; source: string; lure: string; host: string }\n /**\n * Account or password phrasing beside a link elsewhere that carries the\n * reader's own address (AGL-3453). STRONG when the address is the whole\n * fragment (`#victim@example.com`), which only a landing page's script\n * reads; soft when it is a query parameter or part of a longer fragment.\n * The address itself is never stored.\n */\n | { code: 'recipient-prefill-link'; host: string; lure: string; place: 'fragment' | 'parameter' }\n /**\n * A link, embed, redirect or form action whose host Google Web Risk lists\n * as phishing, malware or unwanted software (AGL-3451,\n * `link-reputation.ts`). Strong: a harvester already known to be bad\n * anywhere is bad whatever page or message surrounds it. `url` is set\n * when the listing names one page on the host rather than the host\n * (AGL-3459, `platformSettings/webRisk.lookupMode: 'url'`): the address\n * as looked up, scheme, host and path, never a query string.\n */\n | { code: 'web-risk-link'; host: string; threats: string[]; url?: string }\n\nexport interface PhishingScreenInput {\n subject?: string | null\n /** The display name in front of the sending address. */\n fromName?: string | null\n /**\n * The ADDRESS the message leaves from (AGL-3362) — a `From:` domain is a\n * link the recipient never has to click, so its host is read by the\n * lookalike rule exactly like a link's: mail from `support@paypa1.com` is\n * the disguise whoever sends it. Not an own domain for the lure's \"is this\n * elsewhere\" test either way; it only ever adds a lookalike signal.\n */\n fromAddress?: string | null\n replyTo?: string | readonly string[] | null\n preheader?: string | null\n /**\n * Everything else the recipient reads or clicks: the body, the plain-text\n * part, a design's nodes serialized — any string. Links are found by\n * shape, so a JSON-encoded design is as readable here as HTML.\n */\n bodies?: readonly (string | null | undefined)[]\n /**\n * The workspace's own names — org, site, subdomain. A brand in one of them\n * is the workspace's own, and `brand-sender` / `brand-lure-link` do not\n * fire for it. The lookalike check does not consult names: a workspace\n * NAMED \"Poshmark\" linking to `poshmark.id63835663.shop` is the incident.\n */\n ownNames?: readonly (string | null | undefined)[]\n /**\n * The workspace's own hosts — its subdomain on the tenant apex, custom\n * domain, sending domain. A link to one of them, or below one, is never\n * the \"somewhere else\" of a lure. Matched by host, never by registrable\n * domain: every site's subdomain shares the tenant apex, and a link to a\n * NEIGHBOR's site is somewhere else.\n *\n * Not an exemption from the lookalike check. A host shaped like\n * `paypal-secure.com` is a lookalike whoever attached it, and a workspace\n * that attached it has attached the disguise.\n */\n ownDomains?: readonly (string | null | undefined)[]\n}\n\nexport interface PhishingScreenVerdict {\n /** True when the message should be held for staff review. */\n hold: boolean\n signals: PhishingScreenSignal[]\n}\n\n/** The registrable domain of a host: `a.b.evil.co.uk` → `evil.co.uk`. */\nexport function registrableDomain(host: string): string {\n const labels = String(host ?? '')\n .toLowerCase()\n .replace(/\\.+$/, '')\n .split('.')\n .filter(Boolean)\n if (labels.length <= 2) return labels.join('.')\n const lastTwo = labels.slice(-2).join('.')\n return TWO_LABEL_SUFFIXES.has(lastTwo)\n ? labels.slice(-3).join('.')\n : lastTwo\n}\n\n/** `<label>.<suffix>` of a registrable domain, split once. */\nfunction splitRegistrable(registrable: string): { label: string; suffix: string } {\n const dot = registrable.indexOf('.')\n return dot < 0\n ? { label: registrable, suffix: '' }\n : { label: registrable.slice(0, dot), suffix: registrable.slice(dot + 1) }\n}\n\nfunction isOfficialDomain(brand: PhishingScreenBrand, registrable: string): boolean {\n if (brand.officialDomains.includes(registrable)) return true\n if (!brand.countryDomains) return false\n const base = splitRegistrable(brand.officialDomains[0]).label\n const { label, suffix } = splitRegistrable(registrable)\n return label === base && (/^[a-z]{2}$/.test(suffix) || TWO_LABEL_SUFFIXES.has(suffix))\n}\n\n/**\n * Is the workspace the brand itself, by DOMAIN: one of its own domains is\n * one of the brand's official ones (Aglyn's site on aglyn.com linking to\n * its own account on a video or help-desk vendor). Deliberately not by name — a workspace can call itself\n * \"Poshmark\", but it cannot serve on poshmark.com.\n */\nexport function isBrandsOwnDomain(\n brand: PhishingScreenBrand,\n ownRegistrables: ReadonlySet<string>,\n): boolean {\n return [...ownRegistrables].some((registrable) => isOfficialDomain(brand, registrable))\n}\n\n/** Every brand's real domains, for \"is this link just the brand itself\". */\nfunction isAnyOfficialDomain(registrable: string): boolean {\n return PHISHING_SCREEN_BRANDS.some((brand) => isOfficialDomain(brand, registrable))\n}\n\n/** Leetspeak folded, so `paypa1` reads as `paypal`. */\nfunction foldLeet(label: string): string {\n return label\n .replace(/0/g, 'o')\n .replace(/1/g, 'l')\n .replace(/3/g, 'e')\n .replace(/4/g, 'a')\n .replace(/5/g, 's')\n .replace(/7/g, 't')\n}\n\n/** Does one host label name the brand — whole, or hyphen-joined? */\nfunction labelNamesBrand(label: string, token: string, wordToken: boolean): boolean {\n if (wordToken) return label === token\n for (const candidate of new Set([label, foldLeet(label)])) {\n if (candidate === token) return true\n const parts = candidate.split('-')\n // A hyphen-joined token (`booking-com`) spans parts, so it is matched\n // as a run of parts rather than one of them.\n const tokenParts = token.split('-')\n for (let at = 0; at + tokenParts.length <= parts.length; at += 1) {\n if (tokenParts.every((part, offset) => parts[at + offset] === part)) {\n return true\n }\n }\n }\n return false\n}\n\n/**\n * Video and audio platforms whose account subdomains and embed URLs a page\n * or email plays media from: `player.vimeo.com`, `www.youtube.com/embed/…`.\n * A video plugin's own hosts are the plugin's to declare, not listed here. Anyone may embed or link media from these, so a\n * host on one is never a lookalike, whatever name its subdomain carries.\n */\nexport const MEDIA_EMBED_HOSTS: ReadonlySet<string> = new Set([\n 'vimeo.com', 'vimeocdn.com', 'youtube.com', 'youtu.be',\n 'youtube-nocookie.com', 'ytimg.com', 'loom.com', 'vidyard.com', 'brightcove.net',\n 'brightcove.com', 'jwplayer.com', 'jwpcdn.com', 'mux.com', 'cloudflarestream.com',\n 'videodelivery.net', 'dailymotion.com', 'twitch.tv', 'spotify.com', 'soundcloud.com',\n 'podbean.com', 'buzzsprout.com', 'simplecast.com', 'transistor.fm', 'anchor.fm',\n])\n\n/** The brand a host impersonates, or null. */\nexport function lookalikeBrandForHost(host: string): PhishingScreenBrand | null {\n const normalized = String(host ?? '').toLowerCase().replace(/\\.+$/, '')\n if (!normalized.includes('.')) return null\n const registrable = registrableDomain(normalized)\n if (MEDIA_EMBED_HOSTS.has(registrable)) return null\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (isOfficialDomain(brand, registrable)) continue\n if (brand.hostedDomains?.includes(registrable)) continue\n const labels = normalized.split('.')\n if (\n labels.some((label) =>\n brand.hostTokens.some((token) => labelNamesBrand(label, token, brand.wordToken === true)),\n )\n ) {\n return brand\n }\n // The brand's primary domain embedded in a longer, different one:\n // `booking.com.guest-review.top`, `paypal.com-secure.net`. Only the\n // primary: a short secondary (`me.com`, `aka.ms`) would match too much.\n const primary = brand.officialDomains[0]\n if (\n normalized.startsWith(`${primary}.`) ||\n normalized.startsWith(`${primary}-`) ||\n normalized.includes(`.${primary}.`) ||\n normalized.includes(`.${primary}-`)\n ) {\n return brand\n }\n }\n return null\n}\n\n/**\n * The few entity forms a phishing kit uses to keep a URL away from a naive\n * scanner (`.` for a dot, `&` inside a query). Decoded before links\n * are read; everything else is left alone.\n */\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&#x([0-9a-f]{1,6});/gi, (_, hex: string) => safeCodePoint(parseInt(hex, 16)))\n .replace(/&#(\\d{1,7});/g, (_, dec: string) => safeCodePoint(parseInt(dec, 10)))\n .replace(/&/gi, '&')\n}\n\nfunction safeCodePoint(value: number): string {\n return Number.isFinite(value) && value > 0 && value <= 0x10ffff\n ? String.fromCodePoint(value)\n : ''\n}\n\n/** Named entities a body uses for spacing, quoting and invisible splitting. */\nconst NAMED_ENTITIES: Record<string, string> = {\n nbsp: ' ',\n ensp: ' ',\n emsp: ' ',\n thinsp: ' ',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n shy: '',\n zwnj: '',\n zwj: '',\n}\n\n/*\n * Markup is read in single forward passes, never with a pattern that can\n * rescan to the end of the body from every `<`: the screen reads every\n * tenant message, and the tenant writes the body, so a million unclosed\n * `<` must cost a linear read.\n */\n/** An element whose contents a reader never sees: the start of its opening tag. */\nconst UNSEEN_ELEMENT_OPEN = /<(style|script|head|template)\\b/gi\n/** The name at the start of a tag that breaks a line or a block: a reader sees a gap there. */\nconst BREAKING_TAG_NAME =\n /^\\/?(?:br|p|div|li|ul|ol|tr|td|th|table|tbody|thead|h[1-6]|section|article|header|footer|blockquote|hr|center)\\b/i\n/** Characters that render as nothing, used to split a word for a scanner. */\nconst INVISIBLE_CHARACTERS = /[\\u00ad\\u200b-\\u200d\\u2060\\ufeff]/g\n\n/**\n * The text between the tags, joined with NO separator — or, with `breaks`,\n * with a space where a line or block breaks. A comment is dropped; a `<`\n * with no `>` after it is text.\n */\nfunction stripMarkup(html: string, breaks: boolean): string {\n let text = ''\n let at = 0\n while (at < html.length) {\n const open = html.indexOf('<', at)\n if (open < 0) return text + html.slice(at)\n text += html.slice(at, open)\n if (html.startsWith('<!--', open)) {\n const end = html.indexOf('-->', open + 4)\n if (end < 0) return text\n at = end + 3\n continue\n }\n const close = html.indexOf('>', open + 1)\n if (close < 0) return text + html.slice(open)\n if (breaks && BREAKING_TAG_NAME.test(html.slice(open + 1, Math.min(close, open + 12)))) text += ' '\n at = close + 1\n }\n return text\n}\n\n/** The markup with every unseen element and its contents taken out, in one pass. */\nfunction dropUnseenElements(html: string): string {\n const lower = html.toLowerCase()\n const open = new RegExp(UNSEEN_ELEMENT_OPEN.source, 'gi')\n let kept = ''\n let at = 0\n // Each search starts at or after the last; what it found (or that it found\n // nothing) still answers the next one, so no stretch is scanned twice.\n const found = new Map<string, number>()\n const find = (needle: string, from: number) => {\n const known = found.get(needle)\n if (known !== undefined && (known < 0 || known >= from)) return known\n const position = lower.indexOf(needle, from)\n found.set(needle, position)\n return position\n }\n for (let match = open.exec(html); match; match = open.exec(html)) {\n // No `>` after it: neither this nor anything later is a tag.\n const tagEnd = find('>', open.lastIndex)\n if (tagEnd < 0) break\n kept += `${html.slice(at, match.index)} `\n const name = match[1].toLowerCase()\n const close = find(`</${name}`, tagEnd + 1)\n // A head nobody closed ends where the body starts, as a browser reads it.\n const body = name === 'head' ? find('<body', tagEnd + 1) : -1\n if (body >= 0 && (close < 0 || body < close)) {\n at = body\n } else {\n const end = close < 0 ? -1 : find('>', close)\n // Never closed: only the opening tag goes, and what follows is still\n // read, so an unclosed `<style>` cannot hide the lure after it.\n at = end < 0 ? tagEnd + 1 : end + 1\n }\n open.lastIndex = at\n }\n return kept + html.slice(at)\n}\n\n/**\n * What a reader SEES in a body (AGL-3453): its text with the markup taken\n * out, the way a mail client or a browser draws it.\n *\n * A kit splits every letter of a brand and a lure with a tag —\n * `G<SPAN class=…>o<SPAN …>o…gle`, `P<SPAN …>a<SPAN …>s…word E<SPAN …>x…pired`\n * — so the raw HTML never contains the word a reader reads. Tags are\n * therefore removed with NO separator, which rejoins the letters; `<style>`,\n * `<script>` and `<head>` are dropped with their contents; comments and\n * zero-width characters are dropped; entities are decoded; whitespace is\n * collapsed. A second reading that puts a space where a line or block\n * breaks is added when it differs, so two words in two paragraphs are still\n * two words. Links are NOT read from this: an href lives inside a tag.\n */\nexport function visibleTextOf(html: string | null | undefined): string {\n const text = String(html ?? '')\n const source = text.includes('<') ? dropUnseenElements(text) : text\n const read = (breaks: boolean) =>\n decodeVisibleEntities(stripMarkup(source, breaks))\n .replace(INVISIBLE_CHARACTERS, '')\n .replace(/\\s+/g, ' ')\n .trim()\n const joined = read(false)\n const broken = read(true)\n return broken === joined ? joined : `${joined}\\n${broken}`\n}\n\n/** {@link decodeEntities}, after the named entities a body reads with. */\nfunction decodeVisibleEntities(text: string): string {\n return decodeEntities(\n text.replace(/&([a-z]{2,8});/gi, (entity, name: string) => NAMED_ENTITIES[name.toLowerCase()] ?? entity),\n )\n}\n\nconst URL_PATTERN = /\\b(?:https?:\\/\\/|www\\.)[^\\s\"'<>()\\\\[\\]{}]+/gi\n\n/** The hosts every link in the text points at, lowercased. */\nexport function linkHostsIn(text: string): string[] {\n const hosts = new Set<string>()\n for (const match of decodeEntities(String(text ?? '')).match(URL_PATTERN) ?? []) {\n let rest = match.replace(/^https?:\\/\\//i, '')\n rest = rest.split(/[/?#]/)[0]\n // `https://paypal.com@evil.top/` resolves to evil.top — and the part\n // before the `@` is exactly the disguise, so it is kept as a host too.\n const at = rest.lastIndexOf('@')\n const disguise = at >= 0 ? rest.slice(0, at) : ''\n rest = at >= 0 ? rest.slice(at + 1) : rest\n for (const candidate of [rest, disguise]) {\n const host = candidate.replace(/:\\d+$/, '').replace(/\\.+$/, '').toLowerCase()\n // A merge tag inside a URL is not a host anybody can visit yet.\n if (host && host.includes('.') && !host.includes('{') && !host.includes('%7b')) {\n hosts.add(host)\n }\n }\n }\n return [...hosts]\n}\n\n/**\n * Every link in the text as written — `www.` read as `https://`, prose\n * punctuation after it dropped — in the order found, each once. Query\n * strings and fragments are still on them: read them through\n * `normalizeReputationLink` (`link-reputation.ts`) before they go anywhere.\n */\nexport function linkUrlsIn(text: string): string[] {\n const urls = new Set<string>()\n for (const match of decodeEntities(String(text ?? '')).match(URL_PATTERN) ?? []) {\n const url = match.replace(/[.,;:!]+$/, '')\n urls.add(/^www\\./i.test(url) ? `https://${url}` : url)\n }\n return [...urls]\n}\n\n/** One link: the host it goes to, and its query and fragment, URL-decoded. */\ninterface LinkTarget {\n host: string\n query: string\n fragment: string\n}\n\n/** Every link in the text, with what it carries after its path. */\nfunction linkTargetsIn(text: string): LinkTarget[] {\n const targets: LinkTarget[] = []\n for (const match of decodeEntities(String(text ?? '')).match(URL_PATTERN) ?? []) {\n // The first host is where the browser goes; a userinfo disguise is not.\n const [host] = linkHostsIn(match)\n if (!host) continue\n const hash = match.indexOf('#')\n const beforeHash = hash < 0 ? match : match.slice(0, hash)\n const question = beforeHash.indexOf('?')\n targets.push({\n host,\n query: question < 0 ? '' : decodeUrlPart(beforeHash.slice(question + 1)),\n fragment: hash < 0 ? '' : decodeUrlPart(match.slice(hash + 1)),\n })\n }\n return targets\n}\n\nfunction decodeUrlPart(part: string): string {\n try {\n return decodeURIComponent(part)\n } catch {\n return part\n }\n}\n\nconst EMAIL_ADDRESS = /^[a-z0-9._%+-]+@[a-z0-9-]+(?:\\.[a-z0-9-]+)+$/i\nconst EMAIL_ADDRESS_IN_TEXT = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\\.[a-z0-9-]+)+)/gi\nconst BASE64_TEXT = /^[a-z0-9+/_-]{8,}={0,2}$/i\n\n/** A fragment read as base64, the other way a kit carries the address, or ''. */\nfunction base64Text(fragment: string): string {\n const decode = (globalThis as { atob?: (data: string) => string }).atob\n if (!decode || !BASE64_TEXT.test(fragment)) return ''\n try {\n return decode(fragment.replace(/-/g, '+').replace(/_/g, '/'))\n } catch {\n return ''\n }\n}\n\n/**\n * Where a link carries a reader's own address (AGL-3453), or null.\n *\n * - `fragment`: the WHOLE fragment is an address, plain or base64 —\n * `…#victim@example.com`. A fragment never reaches the server; the only\n * thing that reads it is the landing page's script, filling a sign-in\n * form so the reader sees their own address and types the password.\n * - `parameter`: an address that is not the workspace's own inside a query\n * or a longer fragment — `?email=victim@example.com`, a hash route's\n * `#/login?email=…`. Ordinary in a sign-up or a SaaS login link, so softer.\n */\nfunction prefilledAddressIn(\n target: LinkTarget,\n isOwnHost: (host: string) => boolean,\n): 'fragment' | 'parameter' | null {\n const fragment = target.fragment.trim()\n if (fragment && (EMAIL_ADDRESS.test(fragment) || EMAIL_ADDRESS.test(base64Text(fragment).trim()))) {\n return 'fragment'\n }\n for (const part of [target.query, target.fragment]) {\n // An address is short; a tracking token can be kilobytes of the\n // characters an address is made of, so only the head of one is read.\n if (!part.includes('@')) continue\n for (const match of part.slice(0, 4096).matchAll(EMAIL_ADDRESS_IN_TEXT)) {\n if (!isOwnHost(match[1].toLowerCase())) return 'parameter'\n }\n }\n return null\n}\n\nconst ADDRESS_HOST_PATTERN = /[a-z0-9._%+-]+@([a-z0-9-]+(?:\\.[a-z0-9-]+)+)/gi\n\n/** The host of every email address in the text — a reply-to, a `mailto:`. */\nfunction addressHostsIn(text: string): string[] {\n const hosts = new Set<string>()\n for (const match of decodeEntities(String(text ?? '')).matchAll(ADDRESS_HOST_PATTERN)) {\n hosts.add(match[1].toLowerCase().replace(/\\.+$/, ''))\n }\n return [...hosts]\n}\n\n/** Lowercased alphanumerics only, so \"Wells-Fargo Advisors\" contains `wellsfargo`. */\nfunction squash(text: string): string {\n return text.toLowerCase().replace(/[^a-z0-9]/g, '')\n}\n\n/** Is this brand the workspace's own, by name or by a domain it holds? */\nfunction isOwnBrand(\n brand: PhishingScreenBrand,\n ownNames: string,\n ownRegistrables: ReadonlySet<string>,\n): boolean {\n const labels = [brand.id, squash(brand.label), ...brand.hostTokens.map(squash)]\n if (labels.some((label) => label && ownNames.includes(label))) return true\n return [...ownRegistrables].some((registrable) => isOfficialDomain(brand, registrable))\n}\n\n/*\n * The same judgements, for the other surfaces that read content with this\n * screen's data (`hosted-page-screen.ts`). Exported under these names rather\n * than copied, so a page and an email can never disagree about what a\n * brand's own domain is or whose brand a name is.\n */\n\n/** `squash`: lowercased alphanumerics, the form own-name matching reads. */\nexport const squashScreenText = squash\n/** Is this brand the workspace's own, by name (squashed) or by a domain it holds? */\nexport const isWorkspaceOwnBrand = isOwnBrand\n/** Is this registrable domain one of any listed brand's own? */\nexport const isAnyOfficialBrandDomain = isAnyOfficialDomain\n/** Is this registrable domain a social, maps or review link merchants ordinarily carry? */\nexport function isCommonLinkDomain(registrable: string): boolean {\n return COMMON_LINK_DOMAINS.has(registrable)\n}\n\n/**\n * Screen one outbound message. See the module header for what holds and why.\n */\nexport function screenOutboundEmail(input: PhishingScreenInput): PhishingScreenVerdict {\n const signals: PhishingScreenSignal[] = []\n const ownNames = squash((input.ownNames ?? []).filter(Boolean).join(' '))\n const ownHosts = (input.ownDomains ?? [])\n .map((domain) => String(domain ?? '').trim().toLowerCase().replace(/\\.+$/, ''))\n .filter((domain) => domain.includes('.'))\n const ownRegistrables = new Set(ownHosts.map(registrableDomain))\n const isOwnHost = (host: string) =>\n ownHosts.some((own) => host === own || host.endsWith(`.${own}`))\n\n const parts = [input.subject, input.preheader, ...(input.bodies ?? [])].filter(\n (part): part is string => typeof part === 'string' && part.length > 0,\n )\n // Links are read from the raw copy, where an href lives; brands and lures\n // from what a reader sees, where a tag cannot split a word (AGL-3453).\n const copy = parts.join('\\n')\n const visibleCopy = parts.map(visibleTextOf).join('\\n')\n const replyTo = Array.isArray(input.replyTo)\n ? input.replyTo.join(' ')\n : String(input.replyTo ?? '')\n const linkHosts = linkHostsIn(copy)\n\n // 1. A lookalike host, anywhere a recipient could click, write back, or\n // read as the sender.\n const seenLookalike = new Set<string>()\n const fromAddress = String(input.fromAddress ?? '')\n for (const host of [...linkHosts, ...addressHostsIn(`${copy}\\n${replyTo}\\n${fromAddress}`)]) {\n if (seenLookalike.has(host)) continue\n const brand = lookalikeBrandForHost(host)\n if (brand && !isBrandsOwnDomain(brand, ownRegistrables)) {\n seenLookalike.add(host)\n signals.push({ code: 'lookalike-link', brand: brand.id, host })\n }\n }\n\n // 2. A brand in the sender's display name that is not the workspace's.\n const fromName = String(input.fromName ?? '').trim()\n if (fromName) {\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (brand.mention.test(fromName) && !isOwnBrand(brand, ownNames, ownRegistrables)) {\n signals.push({ code: 'brand-sender', brand: brand.id, fromName: fromName.slice(0, 120) })\n }\n }\n }\n\n // 3. Brand + lure + a link to somewhere that is nobody's we know.\n const isElsewhere = (host: string) => {\n if (isOwnHost(host)) return false\n const registrable = registrableDomain(host)\n return !isAnyOfficialDomain(registrable) && !COMMON_LINK_DOMAINS.has(registrable)\n }\n const lure = PHISHING_LURE_PATTERNS.map((pattern) => visibleCopy.match(pattern)?.[0])\n .find(Boolean)\n if (lure) {\n const foreign = linkHosts.find(isElsewhere)\n if (foreign) {\n const namedInCopy = `${visibleCopy}\\n${fromName}`\n for (const brand of PHISHING_SCREEN_BRANDS) {\n if (brand.mention.test(namedInCopy) && !isOwnBrand(brand, ownNames, ownRegistrables)) {\n signals.push({\n code: 'brand-lure-link',\n brand: brand.id,\n lure: lure.slice(0, 120),\n host: foreign,\n })\n break\n }\n }\n }\n }\n\n // 4. An account lure beside a link elsewhere that carries the reader's own\n // address, filled in for the sign-in form at the far end (AGL-3453).\n const accountLure = ACCOUNT_LURE_PATTERNS.map((pattern) => visibleCopy.match(pattern)?.[0]).find(Boolean)\n if (accountLure) {\n let prefill: { host: string; place: 'fragment' | 'parameter' } | null = null\n for (const target of linkTargetsIn(copy)) {\n if (!isElsewhere(target.host)) continue\n const place = prefilledAddressIn(target, isOwnHost)\n if (place && (!prefill || (place === 'fragment' && prefill.place !== 'fragment'))) {\n prefill = { host: target.host, place }\n }\n }\n if (prefill) {\n signals.push({\n code: 'recipient-prefill-link',\n host: prefill.host,\n lure: accountLure.slice(0, 120),\n place: prefill.place,\n })\n }\n }\n\n return { hold: signals.length > 0, signals }\n}\n\n/** The brand's label for a stored id, for the staff surface. */\nexport function phishingScreenBrandLabel(id: string): string {\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.id === id)?.label ?? id\n}\n\n/** Web Risk's threat types, in the words staff read (AGL-3451). */\nconst LINK_THREAT_WORDS: Record<string, string> = {\n SOCIAL_ENGINEERING: 'phishing or social engineering',\n MALWARE: 'malware',\n UNWANTED_SOFTWARE: 'unwanted software',\n}\n\n/** \"phishing or social engineering and malware\", from Web Risk's threat types. */\nexport function describeLinkThreats(threats: readonly string[]): string {\n const words = [...new Set(threats)].map((threat) => LINK_THREAT_WORDS[threat] ?? threat.toLowerCase())\n if (!words.length) return 'unsafe'\n return words.length === 1 ? words[0] : `${words.slice(0, -1).join(', ')} and ${words[words.length - 1]}`\n}\n\n/** One line per signal, in words staff read on the review row. */\nexport function describePhishingScreenSignals(\n signals: readonly PhishingScreenSignal[],\n): string[] {\n return signals.map((signal) => {\n const brand = 'brand' in signal ? phishingScreenBrandLabel(signal.brand) : ''\n switch (signal.code) {\n case 'lookalike-link':\n return `Links to ${signal.host}, which wears the ${brand} name but is not ${brand}'s domain.`\n case 'brand-sender':\n return `Sends as \"${signal.fromName}\", naming ${brand}, which is not this workspace.`\n case 'brand-lure-link':\n return `Names ${brand}, asks the reader to act (\"${signal.lure}\"), and links to ${signal.host}.`\n case 'credential-field':\n return `Asks for a ${\n signal.field === 'card' ? 'card number' : signal.field === 'otp' ? 'one-time code' : 'password'\n } in its own field (\"${signal.label}\"), outside the platform's sign-in and checkout elements.`\n case 'brand-action-page':\n return `Names ${brand} beside a call to action (\"${signal.action}\"), and this workspace is not ${brand}.`\n case 'brand-lure-page':\n return `Names ${brand} on a page that asks visitors to act (\"${signal.lure}\") and links to ${signal.host}, and this workspace is not ${brand}.`\n case 'offsite-action-page':\n return `Its call to action (\"${signal.action}\") sends visitors off the site to ${signal.host}, on a page that reads \"${signal.lure}\".`\n case 'offsite-redirect':\n return `Redirects ${signal.source}, a path that reads \"${signal.lure}\", off the site to ${signal.host}.`\n case 'recipient-prefill-link':\n return `Links to ${signal.host} with the recipient's own address in the ${\n signal.place === 'fragment' ? 'fragment' : 'link'\n }, so a sign-in form there opens filled in, beside \"${signal.lure}\".`\n case 'web-risk-link':\n return `Links to ${signal.url ?? signal.host}, which Google Web Risk lists as ${describeLinkThreats(signal.threats)}.`\n default:\n return 'Phishing signal.'\n }\n })\n}\n\n/*==========================================\n * RISK TIERS: who a signal holds for (AGL-3356, widened to every surface).\n *\n * The screen above finds signals; this decides which of them hold, the same\n * way on every surface that asks — an email at the send seam, a campaign\n * before it is claimed, a page at publish, a subdomain at creation.\n *\n * - STRONG: a lookalike host. A link to `poshmark.id63835663.shop` or\n * `paypa1.com` is a disguise whoever wears it and however old the\n * workspace is, so it holds for EVERY workspace, on every message and\n * page, transactional mail included. A merchant has no ordinary reason to\n * link to a host shaped like somebody else's brand.\n * - STRONG, too: account or password phrasing beside a link elsewhere whose\n * whole FRAGMENT is the reader's address (AGL-3453). A fragment never\n * reaches a server, so the address there is for the landing page's script\n * to fill a sign-in form with; a merchant's own reset mail links to its\n * own domain, and a SaaS login link puts the address in its query, which\n * is soft.\n * - SOFT: a brand in the sender name, the three-part lure, a brand's name\n * beside a sign-in or payment call to action on a page (in one element,\n * or anywhere on a page that carries a lure), a call to action or a\n * redirect that leaves the site beside account or document-share wording,\n * the reader's address in a query beside account phrasing.\n * Each is shaped like phishing but also like a clumsy legitimate message,\n * so they hold\n * only for a workspace in its first {@link OUTBOUND_REVIEW_YOUNG_DAYS}\n * days — the incident's window — and NEVER for mail the recipient's own\n * act made owed ({@link OutboundScreenPolicy.owed}).\n *\n * A credential-harvest page (a password, card or one-time-code field that\n * is not one of the platform's own sign-in or checkout elements) is STRONG:\n * see `hosted-page-screen.ts`. So is a link to a host Google Web Risk lists\n * (`web-risk-link`, `link-reputation.ts`): it holds for every workspace, and\n * an account-subdomain host does not soften it, because the listing names\n * that host itself.\n *=========================================*/\n\n/** A workspace younger than this many days has the soft rules applied. */\nexport const OUTBOUND_REVIEW_YOUNG_DAYS = 14\n\n/** Which tier a signal belongs to. */\nexport type PhishingSignalTier = 'strong' | 'soft'\n\n/** The signal codes that hold for every workspace. */\nexport const STRONG_PHISHING_SIGNAL_CODES: ReadonlySet<string> = new Set([\n 'lookalike-link',\n 'credential-field',\n 'web-risk-link',\n])\n\n/**\n * Hosts that give each customer an account subdomain named after the\n * customer: `acme.zendesk.com` is Acme's own help desk. A brand's name there is usually the brand itself, so a\n * lookalike on one of these is SOFT — held for a young workspace, never a\n * takedown of an established one's page or mail. A lookalike on any other\n * host (`poshmark.id63835663.shop`) stays STRONG.\n */\nexport const ACCOUNT_SUBDOMAIN_HOSTS: ReadonlySet<string> = new Set([\n 'vimeo.com', 'vimeocdn.com', 'zendesk.com', 'freshdesk.com',\n 'helpscoutdocs.com', 'intercom.help', 'statuspage.io', 'atlassian.net', 'myshopify.com',\n 'squarespace.com', 'wixsite.com', 'webflow.io', 'hubspotpagebuilder.com', 'substack.com',\n 'typeform.com', 'calendly.com', 'gitbook.io', 'readme.io', 'notion.site', 'github.io',\n 'cloudfront.net', 'kajabi.com', 'thinkific.com', 'teachable.com', 'mailchimpsites.com',\n])\n\nexport function phishingSignalTier(signal: {\n code: string\n host?: string\n place?: string\n}): PhishingSignalTier {\n if (signal?.code === 'recipient-prefill-link') {\n return signal.place === 'fragment' ? 'strong' : 'soft'\n }\n if (!STRONG_PHISHING_SIGNAL_CODES.has(signal?.code)) return 'soft'\n if (\n signal.code === 'lookalike-link' &&\n typeof signal.host === 'string' &&\n ACCOUNT_SUBDOMAIN_HOSTS.has(registrableDomain(signal.host))\n ) {\n return 'soft'\n }\n return 'strong'\n}\n\n/** Is a workspace of this age (days, `null` = unreadable) screened by the soft rules? */\nexport function isYoungWorkspaceAge(ageDays: number | null | undefined): boolean {\n return typeof ageDays === 'number' && Number.isFinite(ageDays) && ageDays < OUTBOUND_REVIEW_YOUNG_DAYS\n}\n\nexport interface OutboundScreenPolicy {\n /**\n * The workspace's age in days, or `null` when its creation date cannot be\n * read — an org that predates the field, which is an EXISTING customer and\n * is not young.\n */\n ageDays: number | null\n /**\n * The recipient's own act made this message owed: a receipt for their\n * order, a confirmation of their booking, a reset of their password. The\n * soft rules never hold it. The lookalike rule still does — a receipt that\n * links to a Poshmark lookalike is the disguise, not the receipt.\n */\n owed?: boolean\n}\n\n/** The signals that HOLD under the tiers, for this workspace and message. */\nexport function signalsThatHold<T extends { code: string; host?: string }>(\n signals: readonly T[],\n policy: OutboundScreenPolicy,\n): T[] {\n const soft = isYoungWorkspaceAge(policy.ageDays) && !policy.owed\n return signals.filter((signal) => phishingSignalTier(signal) === 'strong' || soft)\n}\n\n/**\n * The same brand, lookalike and tier logic applied to a HOST NAME a workspace\n * asks for — a subdomain on the tenant apex, or a custom domain it attaches.\n *\n * Words a brand's impersonator hyphen-joins to its name. A subdomain that\n * joins a brand's word to one of these (`booking-review`, `apple-support`,\n * `amazon-account`) is the incident's shape even where the brand's word is\n * an ordinary one — which the lookalike rule alone deliberately lets pass,\n * so a salon can be `tanyas-booking` and a bakery `apple-pie-co`.\n */\nexport const BRAND_IMPERSONATION_WORDS: ReadonlySet<string> = new Set([\n 'account', 'accounts', 'auth', 'billing', 'help', 'helpdesk', 'id', 'login',\n 'logon', 'order', 'orders', 'pay', 'payment', 'payments', 'refund', 'resolution',\n 'review', 'reviews', 'secure', 'security', 'seller', 'service', 'signin',\n 'support', 'update', 'verify', 'verification', 'wallet',\n])\n\n/**\n * The brand a requested subdomain label wears, or null.\n *\n * Refused for EVERY workspace, at creation and at rename — the tier is\n * strong, because nothing is lost by asking a real bakery to pick\n * `apple-pie-co` instead of `apple-support`, and a brand's name on our apex\n * is a disguise that outlives every later screen. Two shapes:\n *\n * 1. the label is a lookalike host label ({@link lookalikeBrandForHost} on\n * `<label>.<apex>`): `poshmark`, `paypal-secure`, `paypa1`, `appleid`;\n * 2. a brand's word hyphen-joined to an impersonation word\n * ({@link BRAND_IMPERSONATION_WORDS}): `booking-review`, `apple-support`.\n */\nexport function brandForSubdomainLabel(\n label: string,\n apex = 'example.invalid',\n): PhishingScreenBrand | null {\n const normalized = String(label ?? '').trim().toLowerCase()\n if (!normalized) return null\n const byHost = lookalikeBrandForHost(`${normalized}.${apex}`)\n if (byHost) return byHost\n const parts = foldLeet(normalized).split('-').filter(Boolean)\n if (parts.length < 2 || !parts.some((part) => BRAND_IMPERSONATION_WORDS.has(part))) {\n return null\n }\n for (const brand of PHISHING_SCREEN_BRANDS) {\n const words = [brand.id, ...brand.hostTokens].filter((word) => !word.includes('-'))\n if (parts.some((part) => words.includes(part))) return brand\n }\n return null\n}\n\n/**\n * The platform's own entry in {@link PHISHING_SCREEN_BRANDS} (AGL-3365). A\n * workspace owns every other brand by carrying its name or domain; the\n * platform's is owned only by the platform's staff, because a workspace NAMED\n * for the platform is the cheapest disguise there is.\n */\nexport const PLATFORM_PHISHING_BRAND_ID = 'aglyn'\n\n/** The platform's brand entry. */\nexport function platformPhishingBrand(): PhishingScreenBrand {\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.id === PLATFORM_PHISHING_BRAND_ID) as PhishingScreenBrand\n}\n\n/**\n * Words that make a name claim to SPEAK FOR a brand rather than mention it:\n * \"PayPal Support\", \"Aglyn Official\", \"Apple ID Security Team\".\n */\nconst OFFICIAL_CLAIM_PATTERN =\n /\\b(?:official|staff|team|verified|certified|support|helpdesk|admin|administrator|security|billing|trust|safety|compliance|core|headquarters|hq)\\b/i\n\n/**\n * The brand a display NAME claims to speak for (AGL-3365), or null.\n *\n * For names a stranger reads as an identity — a marketplace publisher, a\n * listing's title — rather than copy. A name that merely mentions a brand\n * (\"Sync for PayPal\", \"Bookings for Airbnb hosts\") passes: that is how an\n * integration is named. A name that pairs the brand with a claim of\n * officialness (\"PayPal Support\", \"Aglyn Official Plugins\") is the disguise.\n */\nexport function brandClaimedByName(name: string): PhishingScreenBrand | null {\n const text = String(name ?? '')\n if (!text.trim() || !OFFICIAL_CLAIM_PATTERN.test(text)) return null\n return PHISHING_SCREEN_BRANDS.find((brand) => brand.mention.test(text)) ?? null\n}\n"],"names":["PHISHING_SCREEN_BRANDS","id","label","mention","hostTokens","officialDomains","countryDomains","wordToken","hostedDomains","ACCOUNT_LURE_PATTERNS","DOCUMENT_SHARE_LURE_PATTERNS","SALE_AND_PARCEL_LURE_PATTERNS","PHISHING_LURE_PATTERNS","COMMON_LINK_DOMAINS","Set","TWO_LABEL_SUFFIXES","registrableDomain","host","labels","String","toLowerCase","replace","split","filter","Boolean","length","join","lastTwo","slice","has","splitRegistrable","registrable","dot","indexOf","suffix","isOfficialDomain","brand","includes","base","test","isBrandsOwnDomain","ownRegistrables","some","isAnyOfficialDomain","foldLeet","labelNamesBrand","token","candidate","parts","tokenParts","at","every","part","offset","MEDIA_EMBED_HOSTS","lookalikeBrandForHost","normalized","primary","startsWith","decodeEntities","text","_","hex","safeCodePoint","parseInt","dec","value","Number","isFinite","fromCodePoint","NAMED_ENTITIES","nbsp","ensp","emsp","thinsp","lt","gt","quot","apos","shy","zwnj","zwj","UNSEEN_ELEMENT_OPEN","BREAKING_TAG_NAME","INVISIBLE_CHARACTERS","stripMarkup","html","breaks","open","end","close","Math","min","dropUnseenElements","lower","RegExp","source","kept","found","Map","find","needle","from","known","get","undefined","position","set","match","exec","tagEnd","lastIndex","index","name","body","visibleTextOf","read","decodeVisibleEntities","trim","joined","broken","entity","URL_PATTERN","linkHostsIn","hosts","rest","lastIndexOf","disguise","add","linkUrlsIn","urls","url","linkTargetsIn","targets","hash","beforeHash","question","push","query","decodeUrlPart","fragment","decodeURIComponent","EMAIL_ADDRESS","EMAIL_ADDRESS_IN_TEXT","BASE64_TEXT","base64Text","decode","globalThis","atob","prefilledAddressIn","target","isOwnHost","matchAll","ADDRESS_HOST_PATTERN","addressHostsIn","squash","isOwnBrand","ownNames","map","squashScreenText","isWorkspaceOwnBrand","isAnyOfficialBrandDomain","isCommonLinkDomain","screenOutboundEmail","input","signals","ownHosts","ownDomains","domain","own","endsWith","subject","preheader","bodies","copy","visibleCopy","replyTo","Array","isArray","linkHosts","seenLookalike","fromAddress","code","fromName","isElsewhere","lure","pattern","foreign","namedInCopy","accountLure","prefill","place","hold","phishingScreenBrandLabel","LINK_THREAT_WORDS","SOCIAL_ENGINEERING","MALWARE","UNWANTED_SOFTWARE","describeLinkThreats","threats","words","threat","describePhishingScreenSignals","signal","field","action","OUTBOUND_REVIEW_YOUNG_DAYS","STRONG_PHISHING_SIGNAL_CODES","ACCOUNT_SUBDOMAIN_HOSTS","phishingSignalTier","isYoungWorkspaceAge","ageDays","signalsThatHold","policy","soft","owed","BRAND_IMPERSONATION_WORDS","brandForSubdomainLabel","apex","byHost","word","PLATFORM_PHISHING_BRAND_ID","platformPhishingBrand","OFFICIAL_CLAIM_PATTERN","brandClaimedByName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA2D2C,GAE3C,qCAAqC,GA2CrC,OAAO,MAAMA,yBAAyD;IACpE;QACEC,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAW;QACxBC,iBAAiB;YAAC;YAAgB;SAAU;IAC9C;IACA;QACEJ,IAAI;QACJC,OAAO;QACP,qEAAqE;QACrEC,SAAS;QACTC,YAAY;YAAC;YAAc;SAAc;QACzCC,iBAAiB;YAAC;YAAe;SAAc;IACjD;IACA;QACEJ,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAS;QACtBC,iBAAiB;YAAC;YAAc;YAAW;SAAe;QAC1DC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAS;QACtBC,iBAAiB;YAAC;YAAc;YAAa;SAAoB;QACjEC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;YAAU;SAAO;QAC9BG,WAAW;QACXF,iBAAiB;YACf;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACP,yEAAyE;QACzEC,SAAS;QACTC,YAAY;YAAC;YAAS;YAAW;YAAU;SAAS;QACpDG,WAAW;QACXF,iBAAiB;YAAC;YAAa;YAAc;YAAY;YAAc;YAAU;SAAe;QAChGC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACP,sEAAsE;QACtE,cAAc;QACdC,SACE;QACFC,YAAY;YACV;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,iBAAiB;YACf;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;IACH;IACA;QACEJ,IAAI;QACJC,OAAO;QACPC,SAAS;QACTC,YAAY;YAAC;SAAW;QACxBC,iBAAiB;YAAC;YAAgB;SAAe;IACnD;IACA;QACEJ,IAAI;QACJC,OAAO;QACP,sEAAsE;QACtE,sDAAsD;QACtDC,SAAS;QACT,iEAAiE;QACjE,sEAAsE;QACtE,qEAAqE;QACrE,0CAA0C;QAC1CC,YAAY;YACV;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,iBAAiB;YACf;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,gBAAgB;IAClB;IACA;QACEL,IAAI;QACJC,OAAO;QACP,qEAAqE;QACrE,sCAAsC;QACtCC,SACE;QACFC,YAAY;YAAC;YAAS;YAAW;YAAa;YAAgB;SAAW;QACzEG,WAAW;QACXF,iBAAiB;YACf;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;IACH;IACA;QACEJ,IAAI;QACJC,OAAO;QACP,0DAA0D;QAC1DC,SAAS;QACTC,YAAY;YAAC;SAAU;QACvBC,iBAAiB;YAAC;YAAe;YAAS;YAA0B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,KAAK,CAACuB,MAAMN,IAAI,CAAC,CAACU,OAASoK,0BAA0B3L,GAAG,CAACuB,QAAQ;QAClF,OAAO;IACT;IACA,KAAK,MAAMhB,SAASpC,uBAAwB;QAC1C,MAAMwM,QAAQ;YAACpK,MAAMnC,EAAE;eAAKmC,MAAMhC,UAAU;SAAC,CAACmB,MAAM,CAAC,CAACqM,OAAS,CAACA,KAAKvL,QAAQ,CAAC;QAC9E,IAAIW,MAAMN,IAAI,CAAC,CAACU,OAASoJ,MAAMnK,QAAQ,CAACe,QAAQ,OAAOhB;IACzD;IACA,OAAO;AACT;AAEA;;;;;CAKC,GACD,OAAO,MAAMyL,6BAA6B,QAAO;AAEjD,gCAAgC,GAChC,OAAO,SAASC;IACd,OAAO9N,uBAAuBoG,IAAI,CAAC,CAAChE,QAAUA,MAAMnC,EAAE,KAAK4N;AAC7D;AAEA;;;CAGC,GACD,MAAME,yBACJ;AAEF;;;;;;;;CAQC,GACD,OAAO,SAASC,mBAAmB/G,IAAY;QAGtCjH;IAFP,MAAM4D,OAAOzC,OAAO8F,eAAAA,OAAQ;IAC5B,IAAI,CAACrD,KAAK0D,IAAI,MAAM,CAACyG,uBAAuBxL,IAAI,CAACqB,OAAO,OAAO;IAC/D,QAAO5D,+BAAAA,uBAAuBoG,IAAI,CAAC,CAAChE,QAAUA,MAAMjC,OAAO,CAACoC,IAAI,CAACqB,kBAA1D5D,+BAAoE;AAC7E"}
|
|
@@ -79,9 +79,10 @@ export interface TenantMessageScreenRefusal {
|
|
|
79
79
|
detail: string;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Screen one tenant message: the pure screen,
|
|
83
|
-
*
|
|
84
|
-
*
|
|
82
|
+
* Screen one tenant message: the pure screen, the reputation of every
|
|
83
|
+
* foreign host it links to (AGL-3451), the tiers, then — only when a signal
|
|
84
|
+
* holds — the installed gate, which files or reads the review row. `null`
|
|
85
|
+
* when it may go.
|
|
85
86
|
*
|
|
86
87
|
* The ONE door for every transport. `sendEmail` asks it for every message a
|
|
87
88
|
* site sends through the platform's provider, and a sender on another
|