turva-llms-txt-validator 0.7.1 → 0.7.3
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/README.md +2 -2
- package/dist/src/index.js +21 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,10 +222,10 @@ The strict type check found two inputs that could leave `undefined` in a check's
|
|
|
222
222
|
GitHub Actions publishes every version from 0.1.3 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
|
|
223
223
|
|
|
224
224
|
```sh
|
|
225
|
-
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.
|
|
225
|
+
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.3 --ignore-scripts && npm audit signatures
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/llms-txt-validator`, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.7.
|
|
228
|
+
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/llms-txt-validator`, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.7.3` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.3 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
|
|
229
229
|
|
|
230
230
|
## Development
|
|
231
231
|
|
package/dist/src/index.js
CHANGED
|
@@ -146,9 +146,12 @@ export function normalizeHostInput(raw) {
|
|
|
146
146
|
// as a fetch proxy, so a typed /docs/llms.txt used to be dropped without a word while the result
|
|
147
147
|
// described the root file (outside retest 2026-09-26). The result now names the unused path in an
|
|
148
148
|
// info check. The case of the path is kept, and the query and fragment are never returned.
|
|
149
|
-
// Mirrors worker.ts enteredPath() (v3.176.0).
|
|
149
|
+
// Mirrors worker.ts enteredPath() (v3.176.0). The hosted route removes tab, CR and LF from the typed
|
|
150
|
+
// address before it calls enteredPath, as normalizeHostInput does, so this function removes them
|
|
151
|
+
// itself: "ht<TAB>tps://example.com" validates example.com and names no path. Without it the scheme
|
|
152
|
+
// test below did not match and the URL parser read the text as a path (audit round 25, R5-1).
|
|
150
153
|
export function enteredPath(raw) {
|
|
151
|
-
let s = String(raw || "").trim();
|
|
154
|
+
let s = String(raw || "").replace(/[\t\r\n]/g, "").trim();
|
|
152
155
|
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(s))
|
|
153
156
|
s = "https://" + s;
|
|
154
157
|
let u;
|
|
@@ -182,6 +185,16 @@ export function isValidPublicHost(host) {
|
|
|
182
185
|
// the same-host rule, the credential and port rejections and the 256 KiB cap are the
|
|
183
186
|
// guards this function was measured against.
|
|
184
187
|
export async function fetchLlmsTxt(host, opts = {}) {
|
|
188
|
+
// Host-shape check at the entry: the same normalizeHostInput and isValidPublicHost that validateHost
|
|
189
|
+
// applies, so a direct caller gets the answer validateHost would give (upper case, one trailing dot
|
|
190
|
+
// and a raw IDN name are accepted and fetched in their normalised form). The helper is exported, so
|
|
191
|
+
// without this a direct caller could make the first request to an IP literal or an internal-use name.
|
|
192
|
+
// It checks the shape of the name only and does not resolve it. The refusal reuses the unsafe-target
|
|
193
|
+
// result with no status and no location: nothing was requested, and the typed host is not echoed back.
|
|
194
|
+
const normalized = normalizeHostInput(host);
|
|
195
|
+
if (!normalized || !isValidPublicHost(normalized))
|
|
196
|
+
return { redirect: true, reason: "unsafe-target", status: 0, location: "" };
|
|
197
|
+
host = normalized;
|
|
185
198
|
const timeoutMs = opts.timeoutMs ?? 8000;
|
|
186
199
|
const cap = opts.cap ?? 262144;
|
|
187
200
|
const reqApex = host.startsWith("www.") ? host.slice(4) : host;
|
|
@@ -1388,6 +1401,8 @@ function isAbsoluteHttpUrl(t) {
|
|
|
1388
1401
|
function redirectFailDetail(f) {
|
|
1389
1402
|
if (f.reason === "off-host")
|
|
1390
1403
|
return "redirects to " + f.location + ", a different host. llms.txt is host-scoped, so validate that host directly";
|
|
1404
|
+
if (f.reason === "unsafe-target" && !f.location)
|
|
1405
|
+
return "the host is not a public domain name, so no request was made";
|
|
1391
1406
|
if (f.reason === "unsafe-target")
|
|
1392
1407
|
return "redirects to an unsupported target (" + f.location + "). Only https redirects to the same site are followed";
|
|
1393
1408
|
if (f.reason === "too-many")
|
|
@@ -2350,15 +2365,6 @@ var AFTER_HEAD_ELEMENTS = ["base", "basefont", "bgsound", "link", "meta", "nofra
|
|
|
2350
2365
|
// Their content is not markup: script, style, title, noscript (a parser with scripting on
|
|
2351
2366
|
// reads it as raw text) and noframes are raw text or RCDATA, and template content is inert.
|
|
2352
2367
|
var HEAD_SKIPPED_CONTENT = ["script", "style", "title", "noscript", "noframes", "template"];
|
|
2353
|
-
// The end of a raw text or RCDATA element: the first </name that is followed by optional
|
|
2354
|
-
// whitespace, an optional "/" (a parser closes on </script/> too) and a ">". Returns the
|
|
2355
|
-
// index after it, or -1 when the element never closes, which means the rest of the
|
|
2356
|
-
// document is inside it.
|
|
2357
|
-
function skipSpace(lower, j) {
|
|
2358
|
-
while (j < lower.length && (lower[j] === " " || lower[j] === "\t" || lower[j] === "\n" || lower[j] === "\r" || lower[j] === "\f"))
|
|
2359
|
-
j++;
|
|
2360
|
-
return j;
|
|
2361
|
-
}
|
|
2362
2368
|
// True when the character ends a tag name: whitespace, "/", ">" or the end of the input.
|
|
2363
2369
|
function isTagBoundary(c) {
|
|
2364
2370
|
return c === undefined || c === ">" || c === "/" || c === " " || c === "\t" || c === "\n" || c === "\r" || c === "\f";
|
|
@@ -2373,6 +2379,10 @@ function endTagAt(lower, name, at) {
|
|
|
2373
2379
|
const gt = tagEnd(lower, at);
|
|
2374
2380
|
return gt === -1 ? -2 : gt + 1;
|
|
2375
2381
|
}
|
|
2382
|
+
// The end of a raw text or RCDATA element: the first </name that is followed by optional
|
|
2383
|
+
// whitespace, an optional "/" (a parser closes on </script/> too) and a ">". Returns the
|
|
2384
|
+
// index after it, or -1 when the element never closes, which means the rest of the
|
|
2385
|
+
// document is inside it.
|
|
2376
2386
|
function rawTextEnd(lower, name, from) {
|
|
2377
2387
|
for (let at = lower.indexOf("</" + name, from); at !== -1; at = lower.indexOf("</" + name, at + name.length + 2)) {
|
|
2378
2388
|
const end = endTagAt(lower, name, at);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turva-llms-txt-validator",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Validate a site's llms.txt structure: eight checks as pass/warn/fail plus two llms.txt v2 discovery checks that read pass or info and never move the summary, JSON output. Same checks as the hosted validator at turva.dev/llms-txt-validator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|