@detiq/crawler 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessibility-auditor.js +74 -54
- package/dist/ai-login.js +249 -227
- package/dist/auth-token-rotator.js +67 -57
- package/dist/auth.js +336 -299
- package/dist/browser-extension.js +142 -104
- package/dist/captcha-solver.js +125 -98
- package/dist/color-contrast.js +89 -77
- package/dist/content-chunker.js +126 -126
- package/dist/content-dedup.js +71 -54
- package/dist/cookie-consent.js +83 -68
- package/dist/cookie-jar.js +60 -53
- package/dist/crawler.js +5345 -4486
- package/dist/custom-js-injector.js +61 -45
- package/dist/dark-mode-capture.js +81 -67
- package/dist/dead-link-detector.js +55 -47
- package/dist/element-hash.js +12 -8
- package/dist/email-otp.js +195 -154
- package/dist/engine-router.js +98 -87
- package/dist/export/bulk-export.js +55 -70
- package/dist/export/vector-export.js +105 -77
- package/dist/extractors/advanced.d.ts +10 -0
- package/dist/extractors/advanced.js +266 -249
- package/dist/extractors/artifact-envelope.js +58 -59
- package/dist/failure-analysis-agent.js +33 -37
- package/dist/feature-flag-detector.js +66 -51
- package/dist/form-detector.js +75 -55
- package/dist/frontier.js +101 -76
- package/dist/gap-pass.js +89 -68
- package/dist/graphql-detector.js +72 -62
- package/dist/http-engine.js +330 -282
- package/dist/incremental-diff.js +87 -54
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -63
- package/dist/index.js.map +2 -2
- package/dist/input-fuzzer.js +97 -93
- package/dist/interactive-probe.d.ts +36 -0
- package/dist/interactive-probe.js +827 -715
- package/dist/job-queue.js +2169 -2151
- package/dist/js-coverage.js +56 -52
- package/dist/js-router-detector.js +117 -86
- package/dist/language-detector.js +63 -51
- package/dist/link-classifier.js +50 -32
- package/dist/live-view.js +108 -91
- package/dist/locator-extractor.d.ts +37 -0
- package/dist/locator-extractor.js +199 -0
- package/dist/locator-extractor.js.map +7 -0
- package/dist/logger.js +7 -9
- package/dist/markdown-extract.js +61 -48
- package/dist/native-crawler.js +946 -780
- package/dist/network-observer.js +156 -135
- package/dist/network-throttle.js +40 -29
- package/dist/openapi-generator.js +92 -77
- package/dist/pdf-extractor.js +90 -72
- package/dist/performance-metrics.js +102 -80
- package/dist/phash.js +144 -125
- package/dist/pii-scrubber.js +68 -65
- package/dist/playwright-recorder.js +58 -70
- package/dist/policies/crawl-safety.js +34 -31
- package/dist/profiles/domain-profile.js +125 -130
- package/dist/proxy.js +172 -146
- package/dist/rate-limiter.js +65 -58
- package/dist/redirect-tracker.js +64 -60
- package/dist/redis-frontier.js +136 -116
- package/dist/redis-queue.js +144 -157
- package/dist/response-cache.js +140 -127
- package/dist/responsive-detector.js +46 -42
- package/dist/retry-policy.js +50 -46
- package/dist/robots-txt.js +83 -69
- package/dist/screen-reader.js +70 -45
- package/dist/screenshot-masker.js +77 -59
- package/dist/seo-checker.js +107 -88
- package/dist/session-capture.js +212 -192
- package/dist/session-export.js +133 -107
- package/dist/sitemap-writer.js +41 -38
- package/dist/sitemap.js +202 -141
- package/dist/skyvern.js +148 -123
- package/dist/sqs-queue.js +42 -42
- package/dist/sso-token.js +90 -74
- package/dist/stealth/human-behavior.js +173 -156
- package/dist/telemetry.js +82 -68
- package/dist/test-executor.js +335 -309
- package/dist/tls-fingerprint.js +88 -77
- package/dist/url-pattern-completer.js +90 -71
- package/dist/visual-diff-verdict.js +38 -23
- package/dist/webhook-notifier.js +69 -71
- package/dist/websocket-detector.js +68 -56
- package/dist/worker.js +38 -29
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/locator-extractor.ts +226 -0
- package/types/index.d.ts +2 -0
- package/types/locator-extractor.d.ts +37 -0
|
@@ -1,50 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Custom JS injector — run user-provided JavaScript in the context of each crawled page.
|
|
3
|
+
*
|
|
4
|
+
* Use cases:
|
|
5
|
+
* - Extract custom data points not captured by standard extractors
|
|
6
|
+
* - Set localStorage/sessionStorage values before crawl
|
|
7
|
+
* - Override fetch() to intercept API calls
|
|
8
|
+
* - Simulate user events (keydown, focus, etc.)
|
|
9
|
+
* - Bypass specific anti-bot checks
|
|
10
|
+
*
|
|
11
|
+
* Security: scripts run in the page context (sandboxed by Chromium's renderer).
|
|
12
|
+
* They cannot access the Node.js process or file system.
|
|
13
|
+
* ZeTa validates scripts are strings before injection.
|
|
14
|
+
*/
|
|
15
|
+
export async function injectCustomJs(page, opts) {
|
|
16
|
+
const result = {
|
|
17
|
+
initScriptApplied: false,
|
|
18
|
+
postLoadResult: null,
|
|
19
|
+
storageSet: false,
|
|
20
|
+
cookiesSet: 0,
|
|
21
|
+
};
|
|
22
|
+
// Set cookies via Playwright context
|
|
23
|
+
if (opts.cookies?.length) {
|
|
24
|
+
try {
|
|
25
|
+
await page.context().addCookies(opts.cookies.map(c => ({ name: c.name, value: c.value, domain: c.domain ?? '', path: c.path ?? '/', url: page.url() || undefined })));
|
|
26
|
+
result.cookiesSet = opts.cookies.length;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
result.error = `Cookie injection failed: ${e.message}`;
|
|
30
|
+
}
|
|
16
31
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
// Init script (runs before page load on every navigation)
|
|
33
|
+
if (opts.initScript || opts.localStorage || opts.sessionStorage) {
|
|
34
|
+
const storageSetup = [
|
|
35
|
+
opts.localStorage ? `Object.entries(${JSON.stringify(opts.localStorage)}).forEach(([k,v])=>localStorage.setItem(k,v));` : '',
|
|
36
|
+
opts.sessionStorage ? `Object.entries(${JSON.stringify(opts.sessionStorage)}).forEach(([k,v])=>sessionStorage.setItem(k,v));` : '',
|
|
37
|
+
].filter(Boolean).join('\n');
|
|
38
|
+
const combinedInit = [storageSetup, opts.initScript ?? ''].filter(Boolean).join('\n');
|
|
39
|
+
try {
|
|
40
|
+
await page.addInitScript(combinedInit);
|
|
41
|
+
result.initScriptApplied = true;
|
|
42
|
+
result.storageSet = !!(opts.localStorage || opts.sessionStorage);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
result.error = `Init script failed: ${e.message}`;
|
|
46
|
+
}
|
|
30
47
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
// Post-load script (runs after navigation)
|
|
49
|
+
if (opts.postLoadScript) {
|
|
50
|
+
try {
|
|
51
|
+
result.postLoadResult = await page.evaluate(opts.postLoadScript);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
result.error = `Post-load script failed: ${e.message}`;
|
|
55
|
+
}
|
|
37
56
|
}
|
|
38
|
-
|
|
39
|
-
return result;
|
|
57
|
+
return result;
|
|
40
58
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
/** Safe string validator — ensures script is a string, not an object/function reference */
|
|
60
|
+
export function validateScript(script) {
|
|
61
|
+
if (typeof script !== 'string')
|
|
62
|
+
throw new Error('Script must be a string');
|
|
63
|
+
if (script.length > 50_000)
|
|
64
|
+
throw new Error('Script too large (>50KB)');
|
|
65
|
+
return script;
|
|
45
66
|
}
|
|
46
|
-
export {
|
|
47
|
-
injectCustomJs,
|
|
48
|
-
validateScript
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=custom-js-injector.js.map
|
|
@@ -1,75 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dark mode capture — screenshot pages in both light and dark color schemes.
|
|
3
|
+
*
|
|
4
|
+
* Uses Playwright's page.emulateMedia({ colorScheme: 'dark' }) to force dark mode,
|
|
5
|
+
* then captures a screenshot. Compares with light mode to determine if dark mode
|
|
6
|
+
* is supported (significant visual difference).
|
|
7
|
+
*
|
|
8
|
+
* Also detects prefers-color-scheme media query support in CSS.
|
|
9
|
+
*/
|
|
1
10
|
async function getBackgroundColor(page) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
try {
|
|
12
|
+
return await page.evaluate(() => {
|
|
13
|
+
const body = document.body;
|
|
14
|
+
return window.getComputedStyle(body).backgroundColor;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return 'unknown';
|
|
19
|
+
}
|
|
10
20
|
}
|
|
11
21
|
function colorsAreDifferent(a, b) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (a === b)
|
|
23
|
+
return false;
|
|
24
|
+
if (a === 'unknown' || b === 'unknown')
|
|
25
|
+
return false;
|
|
26
|
+
// Parse rgb(r, g, b) and compare luminance
|
|
27
|
+
const parse = (c) => {
|
|
28
|
+
const m = c.match(/\d+/g);
|
|
29
|
+
return m ? m.map(Number) : [0, 0, 0];
|
|
30
|
+
};
|
|
31
|
+
const [ar, ag, ab] = parse(a);
|
|
32
|
+
const [br, bg, bb] = parse(b);
|
|
33
|
+
const lumA = 0.299 * ar + 0.587 * ag + 0.114 * ab;
|
|
34
|
+
const lumB = 0.299 * br + 0.587 * bg + 0.114 * bb;
|
|
35
|
+
return Math.abs(lumA - lumB) > 30; // significant luminance difference
|
|
23
36
|
}
|
|
24
37
|
async function hasCssDarkModeSupport(page) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
try {
|
|
39
|
+
return await page.evaluate(() => {
|
|
40
|
+
const sheets = Array.from(document.styleSheets);
|
|
41
|
+
for (const sheet of sheets) {
|
|
42
|
+
try {
|
|
43
|
+
const rules = Array.from(sheet.cssRules ?? []);
|
|
44
|
+
for (const rule of rules) {
|
|
45
|
+
if (rule instanceof CSSMediaRule && rule.conditionText?.includes('prefers-color-scheme')) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch { /* cross-origin stylesheet — skip */ }
|
|
34
51
|
}
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
} catch {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
44
58
|
}
|
|
45
|
-
async function captureDarkMode(page, url, opts = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
export async function captureDarkMode(page, url, opts = {}) {
|
|
60
|
+
const capturedAt = new Date().toISOString();
|
|
61
|
+
const { takeScreenshots = false } = opts;
|
|
62
|
+
// Light mode
|
|
63
|
+
await page.emulateMedia({ colorScheme: 'light' }).catch(() => { });
|
|
64
|
+
const backgroundColorLight = await getBackgroundColor(page);
|
|
65
|
+
const hasCssDark = await hasCssDarkModeSupport(page);
|
|
66
|
+
const lightScreenshot = takeScreenshots
|
|
67
|
+
? await page.screenshot({ type: 'jpeg', quality: 60 }).catch(() => undefined)
|
|
68
|
+
: undefined;
|
|
69
|
+
// Dark mode
|
|
70
|
+
await page.emulateMedia({ colorScheme: 'dark' }).catch(() => { });
|
|
71
|
+
await page.waitForTimeout(300); // allow CSS transitions
|
|
72
|
+
const backgroundColorDark = await getBackgroundColor(page);
|
|
73
|
+
const darkScreenshot = takeScreenshots
|
|
74
|
+
? await page.screenshot({ type: 'jpeg', quality: 60 }).catch(() => undefined)
|
|
75
|
+
: undefined;
|
|
76
|
+
// Restore light mode
|
|
77
|
+
await page.emulateMedia({ colorScheme: 'light' }).catch(() => { });
|
|
78
|
+
const hasDarkMode = colorsAreDifferent(backgroundColorLight, backgroundColorDark) || hasCssDark;
|
|
79
|
+
return {
|
|
80
|
+
url,
|
|
81
|
+
lightScreenshot,
|
|
82
|
+
darkScreenshot,
|
|
83
|
+
hasDarkMode,
|
|
84
|
+
hasCssDarkMode: hasCssDark,
|
|
85
|
+
backgroundColorLight,
|
|
86
|
+
backgroundColorDark,
|
|
87
|
+
capturedAt,
|
|
88
|
+
};
|
|
71
89
|
}
|
|
72
|
-
export {
|
|
73
|
-
captureDarkMode
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=dark-mode-capture.js.map
|
|
@@ -1,50 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Dead link detector — tracks broken links discovered during crawl.
|
|
3
|
+
*
|
|
4
|
+
* A "dead link" is a URL that:
|
|
5
|
+
* - Returns 404, 410, or other 4xx/5xx responses
|
|
6
|
+
* - Times out after maxRetries
|
|
7
|
+
* - Redirects to an error page (detected by title heuristic)
|
|
8
|
+
*
|
|
9
|
+
* Results: list of broken links with source page, status code, and anchor text.
|
|
10
|
+
* Used for: SEO audit export, test report enrichment.
|
|
11
|
+
*/
|
|
12
|
+
export class DeadLinkTracker {
|
|
13
|
+
deadLinks = [];
|
|
14
|
+
checked = new Map(); // url → statusCode
|
|
15
|
+
record(url, statusCode, source) {
|
|
16
|
+
if (this.checked.has(url))
|
|
17
|
+
return;
|
|
18
|
+
this.checked.set(url, statusCode);
|
|
19
|
+
if (statusCode >= 400) {
|
|
20
|
+
this.deadLinks.push({
|
|
21
|
+
url,
|
|
22
|
+
statusCode,
|
|
23
|
+
sourceUrl: source?.sourceUrl,
|
|
24
|
+
anchorText: source?.anchorText,
|
|
25
|
+
checkedAt: new Date().toISOString(),
|
|
26
|
+
reason: statusCode === 0 ? 'timeout' : 'http-error',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
17
29
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
recordTimeout(url, sourceUrl) {
|
|
31
|
+
if (this.checked.has(url))
|
|
32
|
+
return;
|
|
33
|
+
this.checked.set(url, 0);
|
|
34
|
+
this.deadLinks.push({ url, statusCode: 0, sourceUrl, checkedAt: new Date().toISOString(), reason: 'timeout' });
|
|
35
|
+
}
|
|
36
|
+
getDeadLinks() {
|
|
37
|
+
return [...this.deadLinks];
|
|
38
|
+
}
|
|
39
|
+
isKnownBroken(url) {
|
|
40
|
+
const code = this.checked.get(url);
|
|
41
|
+
return code !== undefined && code >= 400;
|
|
42
|
+
}
|
|
43
|
+
stats() {
|
|
44
|
+
return {
|
|
45
|
+
total: this.deadLinks.length,
|
|
46
|
+
by404: this.deadLinks.filter(l => l.statusCode === 404).length,
|
|
47
|
+
by5xx: this.deadLinks.filter(l => l.statusCode >= 500).length,
|
|
48
|
+
byTimeout: this.deadLinks.filter(l => l.reason === 'timeout').length,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
toCsv() {
|
|
52
|
+
const rows = [['URL', 'Status', 'Source URL', 'Anchor Text', 'Checked At']];
|
|
53
|
+
for (const l of this.deadLinks) {
|
|
54
|
+
rows.push([l.url, String(l.statusCode), l.sourceUrl ?? '', l.anchorText ?? '', l.checkedAt]);
|
|
55
|
+
}
|
|
56
|
+
return rows.map(r => r.map(c => `"${c.replace(/"/g, '""')}"`).join(',')).join('\n');
|
|
43
57
|
}
|
|
44
|
-
return rows.map((r) => r.map((c) => `"${c.replace(/"/g, '""')}"`).join(",")).join("\n");
|
|
45
|
-
}
|
|
46
58
|
}
|
|
47
|
-
export {
|
|
48
|
-
DeadLinkTracker
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=dead-link-detector.js.map
|
package/dist/element-hash.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { createHash } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a stable fingerprint of a screen's element set.
|
|
4
|
+
* Sorted so insertion-order changes (React re-renders) don't produce false positives.
|
|
5
|
+
* Returns first 16 hex chars of SHA-256.
|
|
6
|
+
*/
|
|
7
|
+
export function computeElementHash(elements) {
|
|
8
|
+
const pairs = elements
|
|
9
|
+
.map((e) => `${e.role.toLowerCase()}:${e.meaning.toLowerCase().trim()}`)
|
|
10
|
+
.sort()
|
|
11
|
+
.join('|');
|
|
12
|
+
return createHash('sha256').update(pairs).digest('hex').slice(0, 16);
|
|
5
13
|
}
|
|
6
|
-
export {
|
|
7
|
-
computeElementHash
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=element-hash.js.map
|