milieu-cli 0.3.2 → 0.4.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.
Files changed (330) hide show
  1. package/README.md +177 -76
  2. package/dist/bridges/context/agents-json.d.ts +0 -1
  3. package/dist/bridges/context/agents-json.js +21 -12
  4. package/dist/bridges/context/auth-clarity.d.ts +0 -1
  5. package/dist/bridges/context/auth-clarity.js +11 -9
  6. package/dist/bridges/context/auth-legibility.d.ts +2 -2
  7. package/dist/bridges/context/auth-legibility.js +67 -60
  8. package/dist/bridges/context/index.d.ts +1 -2
  9. package/dist/bridges/context/index.js +19 -40
  10. package/dist/bridges/context/oauth-metadata.d.ts +14 -0
  11. package/dist/bridges/context/oauth-metadata.js +127 -0
  12. package/dist/bridges/context/probe.d.ts +33 -0
  13. package/dist/bridges/context/probe.js +157 -0
  14. package/dist/bridges/context/rate-limits.d.ts +5 -2
  15. package/dist/bridges/context/rate-limits.js +27 -51
  16. package/dist/bridges/context/tos-contact.d.ts +13 -4
  17. package/dist/bridges/context/tos-contact.js +108 -46
  18. package/dist/bridges/context/versioning.d.ts +1 -2
  19. package/dist/bridges/context/versioning.js +42 -7
  20. package/dist/bridges/index.d.ts +0 -1
  21. package/dist/bridges/index.js +0 -1
  22. package/dist/bridges/reachability/crawler-policy.d.ts +30 -10
  23. package/dist/bridges/reachability/crawler-policy.js +41 -56
  24. package/dist/bridges/reachability/http-status.d.ts +3 -2
  25. package/dist/bridges/reachability/http-status.js +18 -3
  26. package/dist/bridges/reachability/https-check.d.ts +2 -2
  27. package/dist/bridges/reachability/https-check.js +6 -3
  28. package/dist/bridges/reachability/index.d.ts +1 -2
  29. package/dist/bridges/reachability/index.js +34 -43
  30. package/dist/bridges/reachability/meta-robots.d.ts +0 -13
  31. package/dist/bridges/reachability/meta-robots.js +89 -101
  32. package/dist/bridges/reachability/robots-parser.d.ts +7 -7
  33. package/dist/bridges/reachability/robots-parser.js +65 -15
  34. package/dist/bridges/reachability/robots-txt.d.ts +4 -2
  35. package/dist/bridges/reachability/robots-txt.js +33 -60
  36. package/dist/bridges/schema/descriptions.d.ts +2 -2
  37. package/dist/bridges/schema/descriptions.js +79 -44
  38. package/dist/bridges/schema/error-schemas.d.ts +2 -2
  39. package/dist/bridges/schema/error-schemas.js +31 -18
  40. package/dist/bridges/schema/index.d.ts +2 -2
  41. package/dist/bridges/schema/index.js +48 -30
  42. package/dist/bridges/schema/oas-types.d.ts +65 -26
  43. package/dist/bridges/schema/oas-types.js +37 -7
  44. package/dist/bridges/schema/operation-ids.d.ts +2 -2
  45. package/dist/bridges/schema/operation-ids.js +2 -3
  46. package/dist/bridges/schema/required-fields.d.ts +2 -2
  47. package/dist/bridges/schema/required-fields.js +12 -10
  48. package/dist/bridges/schema/schema-sources.d.ts +19 -0
  49. package/dist/bridges/schema/schema-sources.js +182 -0
  50. package/dist/bridges/schema/schema-types.d.ts +2 -2
  51. package/dist/bridges/schema/schema-types.js +20 -21
  52. package/dist/bridges/separation/api-presence.d.ts +3 -15
  53. package/dist/bridges/separation/api-presence.js +34 -85
  54. package/dist/bridges/separation/developer-docs.d.ts +6 -18
  55. package/dist/bridges/separation/developer-docs.js +100 -99
  56. package/dist/bridges/separation/docs-discovery.d.ts +28 -0
  57. package/dist/bridges/separation/docs-discovery.js +95 -0
  58. package/dist/bridges/separation/evidence-summary.d.ts +2 -0
  59. package/dist/bridges/separation/evidence-summary.js +67 -0
  60. package/dist/bridges/separation/index.d.ts +2 -19
  61. package/dist/bridges/separation/index.js +35 -39
  62. package/dist/bridges/separation/published-routes.d.ts +69 -0
  63. package/dist/bridges/separation/published-routes.js +271 -0
  64. package/dist/bridges/separation/sdk-references.d.ts +8 -3
  65. package/dist/bridges/separation/sdk-references.js +86 -61
  66. package/dist/bridges/separation/webhook-support.d.ts +3 -23
  67. package/dist/bridges/separation/webhook-support.js +61 -162
  68. package/dist/bridges/standards/a2a-agent-card.d.ts +0 -1
  69. package/dist/bridges/standards/a2a-agent-card.js +24 -9
  70. package/dist/bridges/standards/graphql.d.ts +3 -4
  71. package/dist/bridges/standards/graphql.js +70 -66
  72. package/dist/bridges/standards/index.d.ts +1 -2
  73. package/dist/bridges/standards/index.js +57 -47
  74. package/dist/bridges/standards/json-ld.d.ts +25 -11
  75. package/dist/bridges/standards/json-ld.js +114 -56
  76. package/dist/bridges/standards/llms-txt.d.ts +4 -2
  77. package/dist/bridges/standards/llms-txt.js +46 -32
  78. package/dist/bridges/standards/markdown-negotiation.d.ts +4 -1
  79. package/dist/bridges/standards/markdown-negotiation.js +16 -11
  80. package/dist/bridges/standards/mcp.d.ts +3 -12
  81. package/dist/bridges/standards/mcp.js +89 -132
  82. package/dist/bridges/standards/openapi.d.ts +7 -15
  83. package/dist/bridges/standards/openapi.js +657 -207
  84. package/dist/bridges/standards/probe-evidence.d.ts +30 -0
  85. package/dist/bridges/standards/probe-evidence.js +90 -0
  86. package/dist/bridges/standards/schema-org.d.ts +15 -9
  87. package/dist/bridges/standards/schema-org.js +38 -64
  88. package/dist/bridges/standards/sitemap.d.ts +2 -3
  89. package/dist/bridges/standards/sitemap.js +161 -169
  90. package/dist/bridges/standards/well-known.d.ts +3 -7
  91. package/dist/bridges/standards/well-known.js +28 -12
  92. package/dist/cli/index.d.ts +1 -1
  93. package/dist/cli/index.js +107 -22
  94. package/dist/cli/journey-commands.d.ts +3 -0
  95. package/dist/cli/journey-commands.js +35 -0
  96. package/dist/cli/read-report.d.ts +2 -0
  97. package/dist/cli/read-report.js +11 -0
  98. package/dist/core/bridge-output.d.ts +11 -0
  99. package/dist/core/bridge-output.js +86 -0
  100. package/dist/core/bridge-session.d.ts +28 -0
  101. package/dist/core/bridge-session.js +58 -0
  102. package/dist/core/bridge-worker.d.ts +1 -0
  103. package/dist/core/bridge-worker.js +66 -0
  104. package/dist/core/diff.d.ts +79 -0
  105. package/dist/core/diff.js +499 -0
  106. package/dist/core/explanations.d.ts +1 -3
  107. package/dist/core/explanations.js +36 -59
  108. package/dist/core/index.d.ts +4 -2
  109. package/dist/core/index.js +2 -3
  110. package/dist/core/scan-options.d.ts +0 -1
  111. package/dist/core/scan-options.js +14 -6
  112. package/dist/core/scan.d.ts +0 -1
  113. package/dist/core/scan.js +91 -41
  114. package/dist/core/scoring.d.ts +6 -0
  115. package/dist/core/scoring.js +27 -0
  116. package/dist/core/types.d.ts +97 -61
  117. package/dist/core/types.js +9 -3
  118. package/dist/core/validate-report.d.ts +5 -0
  119. package/dist/core/validate-report.js +95 -0
  120. package/dist/core/version.d.ts +0 -1
  121. package/dist/core/version.js +0 -1
  122. package/dist/index.d.ts +0 -1
  123. package/dist/index.js +0 -1
  124. package/dist/journey/body-worker.d.ts +27 -0
  125. package/dist/journey/body-worker.js +140 -0
  126. package/dist/journey/case.d.ts +74 -0
  127. package/dist/journey/case.js +187 -0
  128. package/dist/journey/cli.d.ts +14 -0
  129. package/dist/journey/cli.js +226 -0
  130. package/dist/journey/compare.d.ts +43 -0
  131. package/dist/journey/compare.js +83 -0
  132. package/dist/journey/contracts.d.ts +143 -0
  133. package/dist/journey/contracts.js +37 -0
  134. package/dist/journey/decision.d.ts +72 -0
  135. package/dist/journey/decision.js +121 -0
  136. package/dist/journey/demo.d.ts +36 -0
  137. package/dist/journey/demo.js +137 -0
  138. package/dist/journey/document.d.ts +8 -0
  139. package/dist/journey/document.js +113 -0
  140. package/dist/journey/excerpt.d.ts +6 -0
  141. package/dist/journey/excerpt.js +54 -0
  142. package/dist/journey/name-guidance.d.ts +2 -0
  143. package/dist/journey/name-guidance.js +41 -0
  144. package/dist/journey/providers.d.ts +34 -0
  145. package/dist/journey/providers.js +197 -0
  146. package/dist/journey/report-validation.d.ts +3 -0
  147. package/dist/journey/report-validation.js +457 -0
  148. package/dist/journey/runner.d.ts +12 -0
  149. package/dist/journey/runner.js +321 -0
  150. package/dist/journey/scope.d.ts +8 -0
  151. package/dist/journey/scope.js +50 -0
  152. package/dist/journey/transport.d.ts +3 -0
  153. package/dist/journey/transport.js +45 -0
  154. package/dist/journey/verify.d.ts +21 -0
  155. package/dist/journey/verify.js +213 -0
  156. package/dist/render/colors.d.ts +6 -7
  157. package/dist/render/colors.js +16 -25
  158. package/dist/render/discovery-guidance.d.ts +3 -0
  159. package/dist/render/discovery-guidance.js +66 -0
  160. package/dist/render/format-bridge.d.ts +1 -2
  161. package/dist/render/format-bridge.js +22 -17
  162. package/dist/render/format-diff.d.ts +2 -0
  163. package/dist/render/format-diff.js +169 -0
  164. package/dist/render/format-scan.d.ts +0 -1
  165. package/dist/render/format-scan.js +6 -4
  166. package/dist/render/format-verbose.d.ts +0 -1
  167. package/dist/render/format-verbose.js +7 -4
  168. package/dist/render/index.d.ts +0 -1
  169. package/dist/render/index.js +1 -2
  170. package/dist/render/oauth-observations.d.ts +4 -0
  171. package/dist/render/oauth-observations.js +27 -0
  172. package/dist/render/progress-bar.d.ts +1 -2
  173. package/dist/render/progress-bar.js +8 -6
  174. package/dist/render/robots-inventory.d.ts +3 -0
  175. package/dist/render/robots-inventory.js +38 -0
  176. package/dist/render/symbols.d.ts +4 -10
  177. package/dist/render/symbols.js +15 -17
  178. package/dist/render/terminal-text.d.ts +1 -3
  179. package/dist/render/terminal-text.js +1 -5
  180. package/dist/utils/analysis-worker-entry.d.ts +3 -0
  181. package/dist/utils/analysis-worker-entry.js +12 -0
  182. package/dist/utils/analysis-worker.d.ts +12 -0
  183. package/dist/utils/analysis-worker.js +54 -0
  184. package/dist/utils/html.d.ts +39 -0
  185. package/dist/utils/html.js +261 -0
  186. package/dist/utils/http-client.d.ts +24 -17
  187. package/dist/utils/http-client.js +166 -200
  188. package/dist/utils/http-types.d.ts +43 -0
  189. package/dist/utils/http-types.js +11 -0
  190. package/dist/utils/index.d.ts +0 -1
  191. package/dist/utils/index.js +0 -1
  192. package/dist/utils/package-registry.d.ts +11 -0
  193. package/dist/utils/package-registry.js +69 -0
  194. package/dist/utils/read-json-file.d.ts +3 -0
  195. package/dist/utils/read-json-file.js +41 -0
  196. package/dist/utils/record.d.ts +1 -0
  197. package/dist/utils/record.js +3 -0
  198. package/dist/utils/response-body.d.ts +7 -0
  199. package/dist/utils/response-body.js +71 -0
  200. package/dist/utils/ssrf.d.ts +11 -15
  201. package/dist/utils/ssrf.js +80 -44
  202. package/dist/utils/terminal-text.d.ts +2 -0
  203. package/dist/utils/terminal-text.js +4 -0
  204. package/dist/utils/url.d.ts +29 -1
  205. package/dist/utils/url.js +147 -17
  206. package/docs/examples/onboarding/account-claim.json +25 -0
  207. package/docs/examples/onboarding/pages/account-claim.html +3 -0
  208. package/docs/examples/onboarding/pages/production-activation.html +3 -0
  209. package/docs/examples/onboarding/pages/test-credential.html +3 -0
  210. package/docs/examples/onboarding/production-activation.json +25 -0
  211. package/docs/examples/onboarding/test-credential.json +25 -0
  212. package/docs/journey-qualification.md +46 -0
  213. package/docs/journeys.md +83 -0
  214. package/package.json +28 -8
  215. package/dist/bridges/context/agents-json.d.ts.map +0 -1
  216. package/dist/bridges/context/agents-json.js.map +0 -1
  217. package/dist/bridges/context/auth-clarity.d.ts.map +0 -1
  218. package/dist/bridges/context/auth-clarity.js.map +0 -1
  219. package/dist/bridges/context/auth-legibility.d.ts.map +0 -1
  220. package/dist/bridges/context/auth-legibility.js.map +0 -1
  221. package/dist/bridges/context/index.d.ts.map +0 -1
  222. package/dist/bridges/context/index.js.map +0 -1
  223. package/dist/bridges/context/rate-limits.d.ts.map +0 -1
  224. package/dist/bridges/context/rate-limits.js.map +0 -1
  225. package/dist/bridges/context/tos-contact.d.ts.map +0 -1
  226. package/dist/bridges/context/tos-contact.js.map +0 -1
  227. package/dist/bridges/context/versioning.d.ts.map +0 -1
  228. package/dist/bridges/context/versioning.js.map +0 -1
  229. package/dist/bridges/index.d.ts.map +0 -1
  230. package/dist/bridges/index.js.map +0 -1
  231. package/dist/bridges/reachability/crawler-policy.d.ts.map +0 -1
  232. package/dist/bridges/reachability/crawler-policy.js.map +0 -1
  233. package/dist/bridges/reachability/http-status.d.ts.map +0 -1
  234. package/dist/bridges/reachability/http-status.js.map +0 -1
  235. package/dist/bridges/reachability/https-check.d.ts.map +0 -1
  236. package/dist/bridges/reachability/https-check.js.map +0 -1
  237. package/dist/bridges/reachability/index.d.ts.map +0 -1
  238. package/dist/bridges/reachability/index.js.map +0 -1
  239. package/dist/bridges/reachability/meta-robots.d.ts.map +0 -1
  240. package/dist/bridges/reachability/meta-robots.js.map +0 -1
  241. package/dist/bridges/reachability/robots-parser.d.ts.map +0 -1
  242. package/dist/bridges/reachability/robots-parser.js.map +0 -1
  243. package/dist/bridges/reachability/robots-txt.d.ts.map +0 -1
  244. package/dist/bridges/reachability/robots-txt.js.map +0 -1
  245. package/dist/bridges/schema/descriptions.d.ts.map +0 -1
  246. package/dist/bridges/schema/descriptions.js.map +0 -1
  247. package/dist/bridges/schema/error-schemas.d.ts.map +0 -1
  248. package/dist/bridges/schema/error-schemas.js.map +0 -1
  249. package/dist/bridges/schema/index.d.ts.map +0 -1
  250. package/dist/bridges/schema/index.js.map +0 -1
  251. package/dist/bridges/schema/oas-types.d.ts.map +0 -1
  252. package/dist/bridges/schema/oas-types.js.map +0 -1
  253. package/dist/bridges/schema/operation-ids.d.ts.map +0 -1
  254. package/dist/bridges/schema/operation-ids.js.map +0 -1
  255. package/dist/bridges/schema/required-fields.d.ts.map +0 -1
  256. package/dist/bridges/schema/required-fields.js.map +0 -1
  257. package/dist/bridges/schema/schema-types.d.ts.map +0 -1
  258. package/dist/bridges/schema/schema-types.js.map +0 -1
  259. package/dist/bridges/separation/api-presence.d.ts.map +0 -1
  260. package/dist/bridges/separation/api-presence.js.map +0 -1
  261. package/dist/bridges/separation/developer-docs.d.ts.map +0 -1
  262. package/dist/bridges/separation/developer-docs.js.map +0 -1
  263. package/dist/bridges/separation/index.d.ts.map +0 -1
  264. package/dist/bridges/separation/index.js.map +0 -1
  265. package/dist/bridges/separation/sdk-references.d.ts.map +0 -1
  266. package/dist/bridges/separation/sdk-references.js.map +0 -1
  267. package/dist/bridges/separation/webhook-support.d.ts.map +0 -1
  268. package/dist/bridges/separation/webhook-support.js.map +0 -1
  269. package/dist/bridges/standards/a2a-agent-card.d.ts.map +0 -1
  270. package/dist/bridges/standards/a2a-agent-card.js.map +0 -1
  271. package/dist/bridges/standards/graphql.d.ts.map +0 -1
  272. package/dist/bridges/standards/graphql.js.map +0 -1
  273. package/dist/bridges/standards/index.d.ts.map +0 -1
  274. package/dist/bridges/standards/index.js.map +0 -1
  275. package/dist/bridges/standards/json-ld.d.ts.map +0 -1
  276. package/dist/bridges/standards/json-ld.js.map +0 -1
  277. package/dist/bridges/standards/llms-txt.d.ts.map +0 -1
  278. package/dist/bridges/standards/llms-txt.js.map +0 -1
  279. package/dist/bridges/standards/markdown-negotiation.d.ts.map +0 -1
  280. package/dist/bridges/standards/markdown-negotiation.js.map +0 -1
  281. package/dist/bridges/standards/mcp.d.ts.map +0 -1
  282. package/dist/bridges/standards/mcp.js.map +0 -1
  283. package/dist/bridges/standards/openapi.d.ts.map +0 -1
  284. package/dist/bridges/standards/openapi.js.map +0 -1
  285. package/dist/bridges/standards/schema-org.d.ts.map +0 -1
  286. package/dist/bridges/standards/schema-org.js.map +0 -1
  287. package/dist/bridges/standards/sitemap.d.ts.map +0 -1
  288. package/dist/bridges/standards/sitemap.js.map +0 -1
  289. package/dist/bridges/standards/well-known.d.ts.map +0 -1
  290. package/dist/bridges/standards/well-known.js.map +0 -1
  291. package/dist/cli/index.d.ts.map +0 -1
  292. package/dist/cli/index.js.map +0 -1
  293. package/dist/core/explanations.d.ts.map +0 -1
  294. package/dist/core/explanations.js.map +0 -1
  295. package/dist/core/index.d.ts.map +0 -1
  296. package/dist/core/index.js.map +0 -1
  297. package/dist/core/scan-options.d.ts.map +0 -1
  298. package/dist/core/scan-options.js.map +0 -1
  299. package/dist/core/scan.d.ts.map +0 -1
  300. package/dist/core/scan.js.map +0 -1
  301. package/dist/core/types.d.ts.map +0 -1
  302. package/dist/core/types.js.map +0 -1
  303. package/dist/core/version.d.ts.map +0 -1
  304. package/dist/core/version.js.map +0 -1
  305. package/dist/index.d.ts.map +0 -1
  306. package/dist/index.js.map +0 -1
  307. package/dist/render/colors.d.ts.map +0 -1
  308. package/dist/render/colors.js.map +0 -1
  309. package/dist/render/format-bridge.d.ts.map +0 -1
  310. package/dist/render/format-bridge.js.map +0 -1
  311. package/dist/render/format-scan.d.ts.map +0 -1
  312. package/dist/render/format-scan.js.map +0 -1
  313. package/dist/render/format-verbose.d.ts.map +0 -1
  314. package/dist/render/format-verbose.js.map +0 -1
  315. package/dist/render/index.d.ts.map +0 -1
  316. package/dist/render/index.js.map +0 -1
  317. package/dist/render/progress-bar.d.ts.map +0 -1
  318. package/dist/render/progress-bar.js.map +0 -1
  319. package/dist/render/symbols.d.ts.map +0 -1
  320. package/dist/render/symbols.js.map +0 -1
  321. package/dist/render/terminal-text.d.ts.map +0 -1
  322. package/dist/render/terminal-text.js.map +0 -1
  323. package/dist/utils/http-client.d.ts.map +0 -1
  324. package/dist/utils/http-client.js.map +0 -1
  325. package/dist/utils/index.d.ts.map +0 -1
  326. package/dist/utils/index.js.map +0 -1
  327. package/dist/utils/ssrf.d.ts.map +0 -1
  328. package/dist/utils/ssrf.js.map +0 -1
  329. package/dist/utils/url.d.ts.map +0 -1
  330. package/dist/utils/url.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ import type { HttpResponse, SharedState } from "../../core/types.js";
2
+ export { isRecord } from "../../utils/record.js";
3
+ /** A denied, transient, or incomplete read cannot establish absence. */
4
+ export declare function unmeasured(response: HttpResponse): boolean;
5
+ export declare function authDenied(response: HttpResponse): boolean;
6
+ /** A conventional path behind a site-wide authentication gate proves nothing about the endpoint. */
7
+ export declare function missingControl(response: HttpResponse): boolean;
8
+ /**
9
+ * Source for `word` as JSON.parse or js-yaml can read it from a string: each character literal or as a \x, \u or
10
+ * \U escape, with any number of YAML escaped line breaks between characters. js-yaml keeps only the low 16 bits of
11
+ * a \U escape whose first digit is 8 or above, and drops the blank lines that follow an escaped line break. A body
12
+ * with no match cannot hold the word, so it need not be parsed to look for it. ASCII words only.
13
+ */
14
+ export declare function spelledWord(word: string, ignoreCase?: boolean): string;
15
+ /**
16
+ * Objects and arrays one JSON body may open and still be parsed. V8 keeps the keys of an object that are whole
17
+ * numbers apart from its other keys: in a list as long as the highest of them when that is under 36 entries a key,
18
+ * and in a table otherwise. A list counts by its length, 16 entries to a container, and a table as one container.
19
+ * Parsed, the most a body within the response limit holds at this bound is about 72 MB, over half a bridge's heap.
20
+ */
21
+ export declare const JSON_MAX_CONTAINERS = 250000;
22
+ /** What readJson returns for a body past that bound, which no check can tell from a body it could not read. */
23
+ export declare const OVERSIZED: unique symbol;
24
+ /**
25
+ * JSON.parse for a response body, behind a count of the containers it opens. JSON.parse builds every value before
26
+ * it returns or throws, and a body of `{}` repeated holds twenty times its size: within the response limit, more
27
+ * than a bridge's heap. A caller that holds as much already gives the length of the longest body it can add.
28
+ */
29
+ export declare function readJson(body: string, maxLength?: number): unknown;
30
+ export declare function incompleteHomepage(shared: SharedState): boolean;
@@ -0,0 +1,90 @@
1
+ export { isRecord } from "../../utils/record.js";
2
+ /** A denied, transient, or incomplete read cannot establish absence. */
3
+ export function unmeasured(response) {
4
+ if (response.ok)
5
+ return response.bodyIncomplete === true || response.status === 206 || response.headers["content-range"] !== undefined;
6
+ const status = response.response?.status ?? response.error.statusCode;
7
+ return response.error.kind !== "http_error" || !status || status === 401 || status === 403 ||
8
+ status === 408 || status === 429 || status >= 500;
9
+ }
10
+ export function authDenied(response) {
11
+ return !response.ok && response.error.kind === "http_error" &&
12
+ (response.error.statusCode === 401 || response.error.statusCode === 403);
13
+ }
14
+ /** A conventional path behind a site-wide authentication gate proves nothing about the endpoint. */
15
+ export function missingControl(response) {
16
+ return !response.ok && response.error.kind === "http_error" &&
17
+ (response.error.statusCode === 404 || response.error.statusCode === 410);
18
+ }
19
+ /**
20
+ * Source for `word` as JSON.parse or js-yaml can read it from a string: each character literal or as a \x, \u or
21
+ * \U escape, with any number of YAML escaped line breaks between characters. js-yaml keeps only the low 16 bits of
22
+ * a \U escape whose first digit is 8 or above, and drops the blank lines that follow an escaped line break. A body
23
+ * with no match cannot hold the word, so it need not be parsed to look for it. ASCII words only.
24
+ */
25
+ export function spelledWord(word, ignoreCase = false) {
26
+ const hex = (c) => c.charCodeAt(0).toString(16).padStart(2, "0").replace(/[a-f]/g, d => `[${d}${d.toUpperCase()}]`);
27
+ const char = (c) => [...new Set(ignoreCase ? [c.toLowerCase(), c.toUpperCase()] : [c])]
28
+ .map(form => `${form}|\\\\(?:x|u00|U(?:000000|[89a-fA-F][0-9a-fA-F]{3}00))${hex(form)}`).join("|");
29
+ return [...word].map(c => `(?:${char(c)})`).join("(?:\\\\[\\r\\n][ \\t\\r\\n]*)*");
30
+ }
31
+ /**
32
+ * Objects and arrays one JSON body may open and still be parsed. V8 keeps the keys of an object that are whole
33
+ * numbers apart from its other keys: in a list as long as the highest of them when that is under 36 entries a key,
34
+ * and in a table otherwise. A list counts by its length, 16 entries to a container, and a table as one container.
35
+ * Parsed, the most a body within the response limit holds at this bound is about 72 MB, over half a bridge's heap.
36
+ */
37
+ export const JSON_MAX_CONTAINERS = 250_000;
38
+ /** What readJson returns for a body past that bound, which no check can tell from a body it could not read. */
39
+ export const OVERSIZED = Symbol("oversized JSON");
40
+ const KEY_END = /\s*:/y;
41
+ /**
42
+ * JSON.parse for a response body, behind a count of the containers it opens. JSON.parse builds every value before
43
+ * it returns or throws, and a body of `{}` repeated holds twenty times its size: within the response limit, more
44
+ * than a bridge's heap. A caller that holds as much already gives the length of the longest body it can add.
45
+ */
46
+ export function readJson(body, maxLength = Infinity) {
47
+ if (body.length > maxLength)
48
+ return OVERSIZED;
49
+ // In sixteenths of a container.
50
+ let weight = 0;
51
+ // For the container open at each depth: how many of its keys are whole numbers, and the highest of them.
52
+ const counts = [0], tops = [0];
53
+ for (let i = 0; i < body.length; i++) {
54
+ let code = body.charCodeAt(i);
55
+ if (code === 34) {
56
+ // To the closing quote. Text that is not JSON stops the parser where it stops being JSON, with no more built than counted.
57
+ let index = 0, digits = 0;
58
+ for (i++; i < body.length && (code = body.charCodeAt(i)) !== 34; i++) {
59
+ // A digit written as an escape is the same key to V8.
60
+ if (code === 92)
61
+ code = body.startsWith("u003", ++i) ? body.charCodeAt(i += 4) : 0;
62
+ // Up to ten digits with no leading zero: what V8 keeps as an index.
63
+ if (digits >= 0 && digits < 10 && code >= 48 && code <= 57 && (!digits || index))
64
+ index = index * 10 + code - 48, digits++;
65
+ else
66
+ digits = -1;
67
+ }
68
+ if (digits > 0 && (KEY_END.lastIndex = i + 1, KEY_END.test(body))) {
69
+ counts[counts.length - 1]++;
70
+ tops[tops.length - 1] = Math.max(tops[tops.length - 1], index);
71
+ }
72
+ }
73
+ else if (code === 123 || code === 91) {
74
+ weight += 16;
75
+ counts.push(0);
76
+ tops.push(0);
77
+ }
78
+ else if ((code === 125 || code === 93) && counts.length > 1) {
79
+ const count = counts.pop(), length = tops.pop() + 1;
80
+ if (count)
81
+ weight += length < 36 * count ? length : 16;
82
+ }
83
+ if (weight > JSON_MAX_CONTAINERS * 16)
84
+ return OVERSIZED;
85
+ }
86
+ return JSON.parse(body);
87
+ }
88
+ export function incompleteHomepage(shared) {
89
+ return shared.pageBody === undefined || (!!shared.pageResponse && unmeasured(shared.pageResponse));
90
+ }
@@ -1,12 +1,18 @@
1
+ import type { DefaultTreeAdapterTypes } from "parse5";
1
2
  import type { Check } from "../../core/types.js";
2
3
  /**
3
- * Check for Schema.org markup via JSON-LD vocabulary and Microdata attributes.
4
- *
5
- * Takes the JSON-LD Check result (from checkJsonLd) to avoid re-parsing HTML
6
- * for JSON-LD blocks. Also scans raw HTML for Microdata itemtype attributes
7
- * containing schema.org URLs.
8
- *
9
- * Pure function -- no HTTP calls.
4
+ * Each distinct itemtype attribute of a page. A formatting element left open is rebuilt in every later paragraph,
5
+ * and its copies add nothing to the types.
10
6
  */
11
- export declare function checkSchemaOrg(html: string, jsonLdCheck: Check): Check;
12
- //# sourceMappingURL=schema-org.d.ts.map
7
+ export declare function itemtypes(elements: Iterable<DefaultTreeAdapterTypes.Element>): string[];
8
+ /**
9
+ * Combine JSON-LD observations from all graph nodes with Microdata on the same document: the page, or the itemtype
10
+ * attributes read from it.
11
+ */
12
+ export declare function checkSchemaOrg(html: string | string[], jsonLdCheck: {
13
+ data?: {
14
+ schemaOrgTypes?: string[];
15
+ schemaOrgTypesTruncated?: boolean;
16
+ oversized?: true;
17
+ };
18
+ }): Check;
@@ -1,54 +1,48 @@
1
+ import { htmlElements } from "../../utils/html.js";
2
+ import { parseReference } from "../../utils/url.js";
3
+ import { addTypeName, schemaOrgUrl } from "./json-ld.js";
1
4
  /**
2
- * Check for Schema.org markup via JSON-LD vocabulary and Microdata attributes.
3
- *
4
- * Takes the JSON-LD Check result (from checkJsonLd) to avoid re-parsing HTML
5
- * for JSON-LD blocks. Also scans raw HTML for Microdata itemtype attributes
6
- * containing schema.org URLs.
7
- *
8
- * Pure function -- no HTTP calls.
5
+ * Each distinct itemtype attribute of a page. A formatting element left open is rebuilt in every later paragraph,
6
+ * and its copies add nothing to the types.
7
+ */
8
+ export function itemtypes(elements) {
9
+ const read = new Set();
10
+ for (const element of elements) {
11
+ const itemtype = element.attrs.find(attr => attr.name === "itemtype")?.value;
12
+ if (itemtype !== undefined)
13
+ read.add(itemtype);
14
+ }
15
+ return [...read];
16
+ }
17
+ /**
18
+ * Combine JSON-LD observations from all graph nodes with Microdata on the same document: the page, or the itemtype
19
+ * attributes read from it.
9
20
  */
10
21
  export function checkSchemaOrg(html, jsonLdCheck) {
11
22
  const id = "schema_org";
12
23
  const label = "Schema.org Markup";
13
- const types = new Set();
14
- const sources = [];
15
- // Check JSON-LD blocks for schema.org @context
16
- if (jsonLdCheck.status === "pass" &&
17
- jsonLdCheck.data &&
18
- Array.isArray(jsonLdCheck.data.blocks)) {
19
- const blocks = jsonLdCheck.data.blocks;
20
- let foundSchemaOrg = false;
21
- for (const block of blocks) {
22
- if (isSchemaOrgContext(block.context)) {
23
- foundSchemaOrg = true;
24
- const typeNames = flattenType(block.type);
25
- for (const t of typeNames) {
26
- types.add(t);
27
- }
28
- }
24
+ const types = new Set(jsonLdCheck.data?.schemaOrgTypes ?? []);
25
+ const sources = types.size ? ["json-ld"] : [];
26
+ let truncated = jsonLdCheck.data?.schemaOrgTypesTruncated ?? false;
27
+ let microdata = false;
28
+ for (const itemtype of typeof html === "string" ? itemtypes(htmlElements(html)) : html) {
29
+ for (const token of itemtype.split(/\s+/)) {
30
+ const url = parseReference(token);
31
+ if (!url || !schemaOrgUrl(url) || url.search || url.hash)
32
+ continue;
33
+ const name = url.pathname.split("/").pop();
34
+ if (!name)
35
+ continue;
36
+ microdata = true;
37
+ if (!addTypeName(types, name))
38
+ truncated = true;
29
39
  }
30
- if (foundSchemaOrg) {
31
- sources.push("json-ld");
32
- }
33
- }
34
- // Check Microdata itemtype attributes for schema.org
35
- const microdataRegex = /itemtype=["'](https?:\/\/schema\.org\/[^"']+)["']/gi;
36
- let match;
37
- const microdataTypes = new Set();
38
- while ((match = microdataRegex.exec(html)) !== null) {
39
- const typeUrl = match[1];
40
- const typeName = typeUrl.split("/").pop();
41
- if (typeName)
42
- microdataTypes.add(typeName);
43
40
  }
44
- if (microdataTypes.size > 0) {
41
+ if (microdata)
45
42
  sources.push("microdata");
46
- for (const t of microdataTypes) {
47
- types.add(t);
48
- }
49
- }
50
43
  if (types.size === 0) {
51
- return {
44
+ // A JSON-LD block too large to parse may hold the types.
45
+ return jsonLdCheck.data?.oversized ? { id, label, status: "error", detail: "JSON-LD block too large to inspect" } : {
52
46
  id,
53
47
  label,
54
48
  status: "fail",
@@ -56,7 +50,7 @@ export function checkSchemaOrg(html, jsonLdCheck) {
56
50
  };
57
51
  }
58
52
  // Build detail string based on sources
59
- const typesStr = [...types].join(", ");
53
+ const typesStr = [...types].join(", ") + (truncated ? " (sample)" : "");
60
54
  let detail;
61
55
  if (sources.includes("json-ld") && sources.includes("microdata")) {
62
56
  detail = `Schema.org types found via JSON-LD and Microdata: ${typesStr}`;
@@ -72,26 +66,6 @@ export function checkSchemaOrg(html, jsonLdCheck) {
72
66
  label,
73
67
  status: "pass",
74
68
  detail,
75
- data: { types: [...types], sources },
69
+ data: { types: [...types], sources, ...(truncated && { truncated }) },
76
70
  };
77
71
  }
78
- /**
79
- * Check if a JSON-LD @context value references schema.org.
80
- */
81
- function isSchemaOrgContext(context) {
82
- const entries = Array.isArray(context) ? context : [context];
83
- return entries.some((entry) => {
84
- const value = typeof entry === "object" && entry !== null ? entry["@vocab"] : entry;
85
- if (typeof value !== "string")
86
- return false;
87
- const url = URL.parse(value);
88
- return (url?.protocol === "https:" || url?.protocol === "http:") && url.hostname === "schema.org";
89
- });
90
- }
91
- /**
92
- * Flatten a @type value to an array of type name strings.
93
- */
94
- function flattenType(type) {
95
- return Array.isArray(type) ? type : [type];
96
- }
97
- //# sourceMappingURL=schema-org.js.map
@@ -11,11 +11,10 @@ export interface SitemapResult {
11
11
  *
12
12
  * Detection strategy:
13
13
  * 1. Probe /sitemap.xml and /sitemap_index.xml
14
- * 2. Probe any sitemap URLs found in robots.txt (passed via robotsSitemapUrls)
14
+ * 2. Probe any sitemap URLs found in robots.txt (passed via robotsSitemapUrls; robotsSitemapsCut says the list may not be all of them)
15
15
  * 3. If a sitemap index is found, follow up to 3 child sitemaps
16
16
  * 4. Extract all URLs and filter API-relevant ones
17
17
  *
18
18
  * Returns discovered URLs for downstream use (OpenAPI candidate feeding).
19
19
  */
20
- export declare function checkSitemap(baseUrl: string, robotsSitemapUrls: string[], timeout?: number): Promise<SitemapResult>;
21
- //# sourceMappingURL=sitemap.d.ts.map
20
+ export declare function checkSitemap(baseUrl: string, robotsSitemapUrls: string[], timeout?: number, robotsSitemapsCut?: boolean): Promise<SitemapResult>;