@rebilder/agent-readability 0.4.0 → 0.5.0

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.
@@ -119,6 +119,9 @@ function classifyIpv6Groups(groups) {
119
119
  const allZeroThrough = (upTo) => groups.slice(0, upTo).every((x) => x === 0);
120
120
  if (groups.every((x) => x === 0)) return v6("unspecified (::)", true);
121
121
  if (allZeroThrough(7) && g(7) === 1) return v6("loopback (::1)", true);
122
+ if (allZeroThrough(4) && g(4) === 65535 && g(5) === 0) {
123
+ return v6("IPv4-translated (::ffff:0:0:0/96)", true);
124
+ }
122
125
  if (allZeroThrough(5) && g(5) === 65535) {
123
126
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
124
127
  return v6(`IPv4-mapped \u2192 ${inner.label}`, inner.reserved);
@@ -127,10 +130,16 @@ function classifyIpv6Groups(groups) {
127
130
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
128
131
  return v6(`IPv4-compatible \u2192 ${inner.label}`, true);
129
132
  }
133
+ if (g(0) === 100 && g(1) === 65435 && g(2) === 1) {
134
+ return v6("NAT64 local-use (64:ff9b:1::/48)", true);
135
+ }
130
136
  if (g(0) === 100 && g(1) === 65435 && g(2) === 0 && g(3) === 0 && g(4) === 0 && g(5) === 0) {
131
137
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
132
138
  return v6(`NAT64 64:ff9b::/96 \u2192 ${inner.label}`, inner.reserved);
133
139
  }
140
+ if (g(0) === 8193 && g(1) === 0) {
141
+ return v6("Teredo (2001::/32)", true);
142
+ }
134
143
  if (g(0) === 8194) {
135
144
  const inner = classifyIpv4Octets(embeddedV4(g(1), g(2)));
136
145
  return v6(`6to4 2002::/16 \u2192 ${inner.label}`, inner.reserved);
@@ -140,6 +149,7 @@ function classifyIpv6Groups(groups) {
140
149
  if (g(0) === 8193 && g(1) === 3512) return v6("documentation (2001:db8::/32)", true);
141
150
  if ((g(0) & 65024) === 64512) return v6("unique local (fc00::/7)", true);
142
151
  if ((g(0) & 65472) === 65152) return v6("link-local (fe80::/10)", true);
152
+ if ((g(0) & 65472) === 65216) return v6("site-local (fec0::/10)", true);
143
153
  if ((g(0) & 65280) === 65280) return v6("multicast (ff00::/8)", true);
144
154
  return v6("public", false);
145
155
  }
@@ -182,8 +192,10 @@ function guardUrl(input, policy) {
182
192
  if (url.username !== "" || url.password !== "") {
183
193
  return { ok: false, reason: "URLs with embedded credentials cannot be fetched." };
184
194
  }
185
- let hostname = url.hostname.toLowerCase();
186
- if (hostname.endsWith(".") && hostname.length > 1) hostname = hostname.slice(0, -1);
195
+ const hostname = url.hostname.toLowerCase().replace(/\.+$/, "");
196
+ if (hostname === "") {
197
+ return { ok: false, reason: "That URL has no hostname." };
198
+ }
187
199
  const permissive = allowsPrivateHosts(policy.hostPolicy);
188
200
  if (!permissive && (hostname === "localhost" || hostname.endsWith(".localhost"))) {
189
201
  return { ok: false, reason: "localhost cannot be fetched." };
@@ -986,10 +998,9 @@ function parseStartTag(html, start) {
986
998
  }
987
999
  return { tag, attrs, selfClosing, end: i };
988
1000
  }
989
- function findRawTextEnd(html, from, tag) {
1001
+ function findRawTextEnd(lowerHtml, from, tag) {
990
1002
  const needle = `</${tag}`;
991
- const lower = html.toLowerCase();
992
- const at = lower.indexOf(needle, from);
1003
+ const at = lowerHtml.indexOf(needle, from);
993
1004
  return at === -1 ? -1 : at;
994
1005
  }
995
1006
  function ownExclusion(tag, attrs) {
@@ -1053,6 +1064,7 @@ function tokenizeHtml(html) {
1053
1064
  };
1054
1065
  let i = 0;
1055
1066
  let textStart = 0;
1067
+ let lowerHtml = null;
1056
1068
  while (i < html.length) {
1057
1069
  const lt = html.indexOf("<", i);
1058
1070
  if (lt === -1) break;
@@ -1104,7 +1116,8 @@ function tokenizeHtml(html) {
1104
1116
  const isRcdata = RCDATA_ELEMENTS.has(parsed.tag);
1105
1117
  if (isRawText || isRcdata) {
1106
1118
  const contentStart = i;
1107
- const close = findRawTextEnd(html, contentStart, parsed.tag);
1119
+ lowerHtml ??= html.toLowerCase();
1120
+ const close = findRawTextEnd(lowerHtml, contentStart, parsed.tag);
1108
1121
  const contentEnd = close === -1 ? html.length : close;
1109
1122
  if (contentEnd > contentStart) {
1110
1123
  const wasTop = stack.length;
@@ -1336,7 +1349,10 @@ function parseRobots(text) {
1336
1349
  else current.disallow.push(value);
1337
1350
  continue;
1338
1351
  }
1339
- if (field === "crawl-delay" || field === "host" || field === "clean-param") continue;
1352
+ if (field === "crawl-delay" || field === "host" || field === "clean-param" || field === "content-signal") {
1353
+ if (field === "content-signal" && current !== null) openingGroup = false;
1354
+ continue;
1355
+ }
1340
1356
  malformedLines++;
1341
1357
  }
1342
1358
  return { groups, sitemaps, malformedLines, orphanRules };
@@ -1679,6 +1695,82 @@ function markdownAlternateTarget(agent, browser, origin) {
1679
1695
  return null;
1680
1696
  }
1681
1697
 
1698
+ // src/site-signals.ts
1699
+ var BODY_SCAN_CHARS = 256 * 1024;
1700
+ function headerValues(input, name) {
1701
+ const direct = input.headers[name];
1702
+ if (direct !== void 0) return direct.map((value) => value.toLowerCase());
1703
+ const target = name.toLowerCase();
1704
+ const out = [];
1705
+ for (const [key, values] of Object.entries(input.headers)) {
1706
+ if (key.toLowerCase() === target) {
1707
+ for (const value of values) out.push(value.toLowerCase());
1708
+ }
1709
+ }
1710
+ return out;
1711
+ }
1712
+ function hasToken(values, token) {
1713
+ return values.some(
1714
+ (value) => value.split(",").map((part) => part.trim()).includes(token)
1715
+ );
1716
+ }
1717
+ function isRobotsTxtTarget(input) {
1718
+ for (const raw of [input.requestedUrl, input.finalUrl]) {
1719
+ if (typeof raw !== "string" || raw.length === 0) continue;
1720
+ try {
1721
+ if (new URL(raw).pathname.toLowerCase() === "/robots.txt") return true;
1722
+ } catch {
1723
+ const path = (raw.split("#")[0]?.split("?")[0] ?? "").toLowerCase();
1724
+ if (path === "/robots.txt" || path.endsWith("/robots.txt")) return true;
1725
+ }
1726
+ }
1727
+ return false;
1728
+ }
1729
+ function detectEdgeChallenge(input) {
1730
+ const status = input.status;
1731
+ const body = typeof input.body === "string" ? input.body.slice(0, BODY_SCAN_CHARS) : "";
1732
+ const server = headerValues(input, "server");
1733
+ const contentTypes = headerValues(input, "content-type");
1734
+ const isHtmlContent = contentTypes.some(
1735
+ (value) => value.includes("text/html") || value.includes("application/xhtml+xml")
1736
+ );
1737
+ const lowerBodyHead = body.slice(0, 4096).toLowerCase();
1738
+ const isPlainTextWithoutMarkup = contentTypes.some((value) => value.includes("text/plain")) && !lowerBodyHead.includes("<html") && !lowerBodyHead.includes("<script") && !lowerBodyHead.includes("<!doctype html");
1739
+ const isRobotsHtmlChallenge = isRobotsTxtTarget(input) && isHtmlContent;
1740
+ if (hasToken(headerValues(input, "cf-mitigated"), "challenge")) {
1741
+ return { vendor: "cloudflare", signal: "cf-mitigated: challenge", status };
1742
+ }
1743
+ if ((status === 403 || status === 429 || status === 503 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("cloudflare")) && body.includes("/cdn-cgi/challenge-platform/")) {
1744
+ return { vendor: "cloudflare", signal: "Cloudflare challenge page", status };
1745
+ }
1746
+ if (hasToken(headerValues(input, "x-vercel-mitigated"), "challenge")) {
1747
+ return { vendor: "vercel", signal: "x-vercel-mitigated: challenge", status };
1748
+ }
1749
+ if ((status < 200 || status >= 300 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("vercel")) && body.includes("Vercel Security Checkpoint")) {
1750
+ return { vendor: "vercel", signal: "Vercel Security Checkpoint page", status };
1751
+ }
1752
+ if ((status === 401 || status === 403) && headerValues(input, "x-datadome").length > 0) {
1753
+ return { vendor: "datadome", signal: `x-datadome with HTTP ${status}`, status };
1754
+ }
1755
+ if ((status === 403 || status === 429 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && body.includes("px-captcha") && body.includes("_pxAppId")) {
1756
+ return { vendor: "human", signal: "HUMAN block page", status };
1757
+ }
1758
+ return null;
1759
+ }
1760
+ var DETAIL_PREFIX = "edge-challenge";
1761
+ function challengeDetail(challenge) {
1762
+ return `${DETAIL_PREFIX}; vendor=${challenge.vendor}; status=${challenge.status}; signal=${challenge.signal.slice(0, 120)}`;
1763
+ }
1764
+ new Set(
1765
+ [
1766
+ ...DEFAULT_RULESET.audienceTokens.assistant,
1767
+ ...DEFAULT_RULESET.audienceTokens.training,
1768
+ ...DEFAULT_RULESET.audienceTokens.search,
1769
+ "googlebot",
1770
+ "bingbot"
1771
+ ].map((token) => token.toLowerCase())
1772
+ );
1773
+
1682
1774
  // src/probe/limiter.ts
1683
1775
  var ProbeBudgetExceededError = class extends Error {
1684
1776
  budget;
@@ -1986,6 +2078,16 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
1986
2078
  };
1987
2079
  }
1988
2080
  };
2081
+ const runPage = async (href, headers) => {
2082
+ const record = await run(href, headers);
2083
+ if (!record.result.ok) return record;
2084
+ const challenge = detectEdgeChallenge(record.result.capture);
2085
+ if (challenge === null) return record;
2086
+ return {
2087
+ requestHeaders: headers,
2088
+ result: { ok: false, error: "challenge", detail: challengeDetail(challenge) }
2089
+ };
2090
+ };
1989
2091
  const evidenceOf = (probes) => ({
1990
2092
  ok: true,
1991
2093
  evidence: {
@@ -2030,8 +2132,8 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
2030
2132
  wellKnownUcp: null
2031
2133
  });
2032
2134
  }
2033
- const agent = await run(url.toString(), agentHeaders);
2034
- const browser = await run(url.toString(), browserHeaders);
2135
+ const agent = await runPage(url.toString(), agentHeaders);
2136
+ const browser = await runPage(url.toString(), browserHeaders);
2035
2137
  const linked = markdownAlternateTarget(
2036
2138
  agent.result.ok ? agent.result.capture : null,
2037
2139
  browser.result.ok ? browser.result.capture : null,
@@ -2040,7 +2142,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
2040
2142
  let markdownAlternate = null;
2041
2143
  if (linked !== null) {
2042
2144
  const rule = disallowedFor(new URL(linked).pathname);
2043
- markdownAlternate = rule !== null ? skipped(agentHeaders, `robots.txt disallows ${ARS_ROBOTS_TOKEN} for ${linked}`) : await run(linked, agentHeaders);
2145
+ markdownAlternate = rule !== null ? skipped(agentHeaders, `robots.txt disallows ${ARS_ROBOTS_TOKEN} for ${linked}`) : await runPage(linked, agentHeaders);
2044
2146
  }
2045
2147
  const fetchAsset = async (path) => {
2046
2148
  const rule = disallowedFor(path);
@@ -1,5 +1,5 @@
1
1
  import { Limiter, ProbePolicy, ProbeOptions, ProbeOutcome } from './index.cjs';
2
- import { c as ArsRuleset } from '../robots-policy-BeffrTf0.cjs';
2
+ import { c as ArsRuleset } from '../robots-policy-C7cfPpu2.cjs';
3
3
 
4
4
  /**
5
5
  * probe/local.ts — `"./probe/local"`. Private hosts and plain http, and NOTHING
@@ -1,5 +1,5 @@
1
1
  import { Limiter, ProbePolicy, ProbeOptions, ProbeOutcome } from './index.js';
2
- import { c as ArsRuleset } from '../robots-policy-BeffrTf0.js';
2
+ import { c as ArsRuleset } from '../robots-policy-C7cfPpu2.js';
3
3
 
4
4
  /**
5
5
  * probe/local.ts — `"./probe/local"`. Private hosts and plain http, and NOTHING
@@ -96,6 +96,9 @@ function classifyIpv6Groups(groups) {
96
96
  const allZeroThrough = (upTo) => groups.slice(0, upTo).every((x) => x === 0);
97
97
  if (groups.every((x) => x === 0)) return v6("unspecified (::)", true);
98
98
  if (allZeroThrough(7) && g(7) === 1) return v6("loopback (::1)", true);
99
+ if (allZeroThrough(4) && g(4) === 65535 && g(5) === 0) {
100
+ return v6("IPv4-translated (::ffff:0:0:0/96)", true);
101
+ }
99
102
  if (allZeroThrough(5) && g(5) === 65535) {
100
103
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
101
104
  return v6(`IPv4-mapped \u2192 ${inner.label}`, inner.reserved);
@@ -104,10 +107,16 @@ function classifyIpv6Groups(groups) {
104
107
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
105
108
  return v6(`IPv4-compatible \u2192 ${inner.label}`, true);
106
109
  }
110
+ if (g(0) === 100 && g(1) === 65435 && g(2) === 1) {
111
+ return v6("NAT64 local-use (64:ff9b:1::/48)", true);
112
+ }
107
113
  if (g(0) === 100 && g(1) === 65435 && g(2) === 0 && g(3) === 0 && g(4) === 0 && g(5) === 0) {
108
114
  const inner = classifyIpv4Octets(embeddedV4(g(6), g(7)));
109
115
  return v6(`NAT64 64:ff9b::/96 \u2192 ${inner.label}`, inner.reserved);
110
116
  }
117
+ if (g(0) === 8193 && g(1) === 0) {
118
+ return v6("Teredo (2001::/32)", true);
119
+ }
111
120
  if (g(0) === 8194) {
112
121
  const inner = classifyIpv4Octets(embeddedV4(g(1), g(2)));
113
122
  return v6(`6to4 2002::/16 \u2192 ${inner.label}`, inner.reserved);
@@ -117,6 +126,7 @@ function classifyIpv6Groups(groups) {
117
126
  if (g(0) === 8193 && g(1) === 3512) return v6("documentation (2001:db8::/32)", true);
118
127
  if ((g(0) & 65024) === 64512) return v6("unique local (fc00::/7)", true);
119
128
  if ((g(0) & 65472) === 65152) return v6("link-local (fe80::/10)", true);
129
+ if ((g(0) & 65472) === 65216) return v6("site-local (fec0::/10)", true);
120
130
  if ((g(0) & 65280) === 65280) return v6("multicast (ff00::/8)", true);
121
131
  return v6("public", false);
122
132
  }
@@ -159,8 +169,10 @@ function guardUrl(input, policy) {
159
169
  if (url.username !== "" || url.password !== "") {
160
170
  return { ok: false, reason: "URLs with embedded credentials cannot be fetched." };
161
171
  }
162
- let hostname = url.hostname.toLowerCase();
163
- if (hostname.endsWith(".") && hostname.length > 1) hostname = hostname.slice(0, -1);
172
+ const hostname = url.hostname.toLowerCase().replace(/\.+$/, "");
173
+ if (hostname === "") {
174
+ return { ok: false, reason: "That URL has no hostname." };
175
+ }
164
176
  const permissive = allowsPrivateHosts(policy.hostPolicy);
165
177
  if (!permissive && (hostname === "localhost" || hostname.endsWith(".localhost"))) {
166
178
  return { ok: false, reason: "localhost cannot be fetched." };
@@ -963,10 +975,9 @@ function parseStartTag(html, start) {
963
975
  }
964
976
  return { tag, attrs, selfClosing, end: i };
965
977
  }
966
- function findRawTextEnd(html, from, tag) {
978
+ function findRawTextEnd(lowerHtml, from, tag) {
967
979
  const needle = `</${tag}`;
968
- const lower = html.toLowerCase();
969
- const at = lower.indexOf(needle, from);
980
+ const at = lowerHtml.indexOf(needle, from);
970
981
  return at === -1 ? -1 : at;
971
982
  }
972
983
  function ownExclusion(tag, attrs) {
@@ -1030,6 +1041,7 @@ function tokenizeHtml(html) {
1030
1041
  };
1031
1042
  let i = 0;
1032
1043
  let textStart = 0;
1044
+ let lowerHtml = null;
1033
1045
  while (i < html.length) {
1034
1046
  const lt = html.indexOf("<", i);
1035
1047
  if (lt === -1) break;
@@ -1081,7 +1093,8 @@ function tokenizeHtml(html) {
1081
1093
  const isRcdata = RCDATA_ELEMENTS.has(parsed.tag);
1082
1094
  if (isRawText || isRcdata) {
1083
1095
  const contentStart = i;
1084
- const close = findRawTextEnd(html, contentStart, parsed.tag);
1096
+ lowerHtml ??= html.toLowerCase();
1097
+ const close = findRawTextEnd(lowerHtml, contentStart, parsed.tag);
1085
1098
  const contentEnd = close === -1 ? html.length : close;
1086
1099
  if (contentEnd > contentStart) {
1087
1100
  const wasTop = stack.length;
@@ -1313,7 +1326,10 @@ function parseRobots(text) {
1313
1326
  else current.disallow.push(value);
1314
1327
  continue;
1315
1328
  }
1316
- if (field === "crawl-delay" || field === "host" || field === "clean-param") continue;
1329
+ if (field === "crawl-delay" || field === "host" || field === "clean-param" || field === "content-signal") {
1330
+ if (field === "content-signal" && current !== null) openingGroup = false;
1331
+ continue;
1332
+ }
1317
1333
  malformedLines++;
1318
1334
  }
1319
1335
  return { groups, sitemaps, malformedLines, orphanRules };
@@ -1656,6 +1672,82 @@ function markdownAlternateTarget(agent, browser, origin) {
1656
1672
  return null;
1657
1673
  }
1658
1674
 
1675
+ // src/site-signals.ts
1676
+ var BODY_SCAN_CHARS = 256 * 1024;
1677
+ function headerValues(input, name) {
1678
+ const direct = input.headers[name];
1679
+ if (direct !== void 0) return direct.map((value) => value.toLowerCase());
1680
+ const target = name.toLowerCase();
1681
+ const out = [];
1682
+ for (const [key, values] of Object.entries(input.headers)) {
1683
+ if (key.toLowerCase() === target) {
1684
+ for (const value of values) out.push(value.toLowerCase());
1685
+ }
1686
+ }
1687
+ return out;
1688
+ }
1689
+ function hasToken(values, token) {
1690
+ return values.some(
1691
+ (value) => value.split(",").map((part) => part.trim()).includes(token)
1692
+ );
1693
+ }
1694
+ function isRobotsTxtTarget(input) {
1695
+ for (const raw of [input.requestedUrl, input.finalUrl]) {
1696
+ if (typeof raw !== "string" || raw.length === 0) continue;
1697
+ try {
1698
+ if (new URL(raw).pathname.toLowerCase() === "/robots.txt") return true;
1699
+ } catch {
1700
+ const path = (raw.split("#")[0]?.split("?")[0] ?? "").toLowerCase();
1701
+ if (path === "/robots.txt" || path.endsWith("/robots.txt")) return true;
1702
+ }
1703
+ }
1704
+ return false;
1705
+ }
1706
+ function detectEdgeChallenge(input) {
1707
+ const status = input.status;
1708
+ const body = typeof input.body === "string" ? input.body.slice(0, BODY_SCAN_CHARS) : "";
1709
+ const server = headerValues(input, "server");
1710
+ const contentTypes = headerValues(input, "content-type");
1711
+ const isHtmlContent = contentTypes.some(
1712
+ (value) => value.includes("text/html") || value.includes("application/xhtml+xml")
1713
+ );
1714
+ const lowerBodyHead = body.slice(0, 4096).toLowerCase();
1715
+ const isPlainTextWithoutMarkup = contentTypes.some((value) => value.includes("text/plain")) && !lowerBodyHead.includes("<html") && !lowerBodyHead.includes("<script") && !lowerBodyHead.includes("<!doctype html");
1716
+ const isRobotsHtmlChallenge = isRobotsTxtTarget(input) && isHtmlContent;
1717
+ if (hasToken(headerValues(input, "cf-mitigated"), "challenge")) {
1718
+ return { vendor: "cloudflare", signal: "cf-mitigated: challenge", status };
1719
+ }
1720
+ if ((status === 403 || status === 429 || status === 503 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("cloudflare")) && body.includes("/cdn-cgi/challenge-platform/")) {
1721
+ return { vendor: "cloudflare", signal: "Cloudflare challenge page", status };
1722
+ }
1723
+ if (hasToken(headerValues(input, "x-vercel-mitigated"), "challenge")) {
1724
+ return { vendor: "vercel", signal: "x-vercel-mitigated: challenge", status };
1725
+ }
1726
+ if ((status < 200 || status >= 300 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("vercel")) && body.includes("Vercel Security Checkpoint")) {
1727
+ return { vendor: "vercel", signal: "Vercel Security Checkpoint page", status };
1728
+ }
1729
+ if ((status === 401 || status === 403) && headerValues(input, "x-datadome").length > 0) {
1730
+ return { vendor: "datadome", signal: `x-datadome with HTTP ${status}`, status };
1731
+ }
1732
+ if ((status === 403 || status === 429 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && body.includes("px-captcha") && body.includes("_pxAppId")) {
1733
+ return { vendor: "human", signal: "HUMAN block page", status };
1734
+ }
1735
+ return null;
1736
+ }
1737
+ var DETAIL_PREFIX = "edge-challenge";
1738
+ function challengeDetail(challenge) {
1739
+ return `${DETAIL_PREFIX}; vendor=${challenge.vendor}; status=${challenge.status}; signal=${challenge.signal.slice(0, 120)}`;
1740
+ }
1741
+ new Set(
1742
+ [
1743
+ ...DEFAULT_RULESET.audienceTokens.assistant,
1744
+ ...DEFAULT_RULESET.audienceTokens.training,
1745
+ ...DEFAULT_RULESET.audienceTokens.search,
1746
+ "googlebot",
1747
+ "bingbot"
1748
+ ].map((token) => token.toLowerCase())
1749
+ );
1750
+
1659
1751
  // src/probe/limiter.ts
1660
1752
  var ProbeBudgetExceededError = class extends Error {
1661
1753
  budget;
@@ -1963,6 +2055,16 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
1963
2055
  };
1964
2056
  }
1965
2057
  };
2058
+ const runPage = async (href, headers) => {
2059
+ const record = await run(href, headers);
2060
+ if (!record.result.ok) return record;
2061
+ const challenge = detectEdgeChallenge(record.result.capture);
2062
+ if (challenge === null) return record;
2063
+ return {
2064
+ requestHeaders: headers,
2065
+ result: { ok: false, error: "challenge", detail: challengeDetail(challenge) }
2066
+ };
2067
+ };
1966
2068
  const evidenceOf = (probes) => ({
1967
2069
  ok: true,
1968
2070
  evidence: {
@@ -2007,8 +2109,8 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
2007
2109
  wellKnownUcp: null
2008
2110
  });
2009
2111
  }
2010
- const agent = await run(url.toString(), agentHeaders);
2011
- const browser = await run(url.toString(), browserHeaders);
2112
+ const agent = await runPage(url.toString(), agentHeaders);
2113
+ const browser = await runPage(url.toString(), browserHeaders);
2012
2114
  const linked = markdownAlternateTarget(
2013
2115
  agent.result.ok ? agent.result.capture : null,
2014
2116
  browser.result.ok ? browser.result.capture : null,
@@ -2017,7 +2119,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
2017
2119
  let markdownAlternate = null;
2018
2120
  if (linked !== null) {
2019
2121
  const rule = disallowedFor(new URL(linked).pathname);
2020
- markdownAlternate = rule !== null ? skipped(agentHeaders, `robots.txt disallows ${ARS_ROBOTS_TOKEN} for ${linked}`) : await run(linked, agentHeaders);
2122
+ markdownAlternate = rule !== null ? skipped(agentHeaders, `robots.txt disallows ${ARS_ROBOTS_TOKEN} for ${linked}`) : await runPage(linked, agentHeaders);
2021
2123
  }
2022
2124
  const fetchAsset = async (path) => {
2023
2125
  const rule = disallowedFor(path);