@detiq/crawler 1.1.8 → 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.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.js +28 -67
- package/dist/input-fuzzer.js +97 -93
- 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.js +187 -151
- 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
|
@@ -1,60 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket detection — intercepts WS connections opened during page crawl.
|
|
3
|
+
* Records connection URLs, message schemas, and message counts.
|
|
4
|
+
* This lets ZeTa discover real-time API contracts (chat, notifications, presence)
|
|
5
|
+
* that would be invisible to HTTP-only crawlers.
|
|
6
|
+
*/
|
|
1
7
|
function inferProtocol(sample) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const onCreated = (evt) => {
|
|
15
|
-
const { requestId, url, timestamp } = evt ?? {};
|
|
16
|
-
if (!requestId || !url) return;
|
|
17
|
-
connections.set(requestId, {
|
|
18
|
-
url,
|
|
19
|
-
framesSent: 0,
|
|
20
|
-
framesReceived: 0,
|
|
21
|
-
samples: [],
|
|
22
|
-
protocol: "unknown",
|
|
23
|
-
openedAt: new Date(timestamp * 1e3).toISOString()
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
const onFrame = (evt, direction) => {
|
|
27
|
-
const { requestId, response } = evt ?? {};
|
|
28
|
-
if (!requestId) return;
|
|
29
|
-
const conn = connections.get(requestId);
|
|
30
|
-
if (!conn) return;
|
|
31
|
-
if (direction === "sent") conn.framesSent++;
|
|
32
|
-
else conn.framesReceived++;
|
|
33
|
-
if (conn.samples.length < 10 && response?.payloadData) {
|
|
34
|
-
const payload = String(response.payloadData).slice(0, 500);
|
|
35
|
-
conn.samples.push({ direction, payload, ts: (/* @__PURE__ */ new Date()).toISOString() });
|
|
36
|
-
if (conn.protocol === "unknown") conn.protocol = inferProtocol(payload);
|
|
8
|
+
try {
|
|
9
|
+
const obj = JSON.parse(sample);
|
|
10
|
+
if (obj?.jsonrpc)
|
|
11
|
+
return 'json-rpc';
|
|
12
|
+
if (obj?.type === 'connection_init' || obj?.type === 'subscribe')
|
|
13
|
+
return 'graphql-ws';
|
|
14
|
+
if (typeof obj?.sid === 'string' || sample.startsWith('0{'))
|
|
15
|
+
return 'socket.io';
|
|
16
|
+
return 'json';
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return 'raw';
|
|
37
20
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
}
|
|
22
|
+
export function attachWebSocketDetector(cdpSession) {
|
|
23
|
+
const connections = new Map();
|
|
24
|
+
const onCreated = (evt) => {
|
|
25
|
+
const { requestId, url, timestamp } = evt ?? {};
|
|
26
|
+
if (!requestId || !url)
|
|
27
|
+
return;
|
|
28
|
+
connections.set(requestId, {
|
|
29
|
+
url,
|
|
30
|
+
framesSent: 0,
|
|
31
|
+
framesReceived: 0,
|
|
32
|
+
samples: [],
|
|
33
|
+
protocol: 'unknown',
|
|
34
|
+
openedAt: new Date(timestamp * 1000).toISOString(),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const onFrame = (evt, direction) => {
|
|
38
|
+
const { requestId, response } = evt ?? {};
|
|
39
|
+
if (!requestId)
|
|
40
|
+
return;
|
|
41
|
+
const conn = connections.get(requestId);
|
|
42
|
+
if (!conn)
|
|
43
|
+
return;
|
|
44
|
+
if (direction === 'sent')
|
|
45
|
+
conn.framesSent++;
|
|
46
|
+
else
|
|
47
|
+
conn.framesReceived++;
|
|
48
|
+
if (conn.samples.length < 10 && response?.payloadData) {
|
|
49
|
+
const payload = String(response.payloadData).slice(0, 500);
|
|
50
|
+
conn.samples.push({ direction, payload, ts: new Date().toISOString() });
|
|
51
|
+
if (conn.protocol === 'unknown')
|
|
52
|
+
conn.protocol = inferProtocol(payload);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const onSent = (evt) => onFrame(evt, 'sent');
|
|
56
|
+
const onReceived = (evt) => onFrame(evt, 'received');
|
|
57
|
+
if (cdpSession?.on) {
|
|
58
|
+
cdpSession.on('Network.webSocketCreated', onCreated);
|
|
59
|
+
cdpSession.on('Network.webSocketFrameSent', onSent);
|
|
60
|
+
cdpSession.on('Network.webSocketFrameReceived', onReceived);
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
return {
|
|
63
|
+
getConnections: () => [...connections.values()],
|
|
64
|
+
detach() {
|
|
65
|
+
if (cdpSession?.off) {
|
|
66
|
+
cdpSession.off('Network.webSocketCreated', onCreated);
|
|
67
|
+
cdpSession.off('Network.webSocketFrameSent', onSent);
|
|
68
|
+
cdpSession.off('Network.webSocketFrameReceived', onReceived);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
56
72
|
}
|
|
57
|
-
export {
|
|
58
|
-
attachWebSocketDetector
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=websocket-detector.js.map
|
package/dist/worker.js
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Standalone worker process entrypoint for a dedicated crawler/worker container,
|
|
3
|
+
* separate from the API server (see infrastructure/ecs-task-definitions/crawler.json).
|
|
4
|
+
*
|
|
5
|
+
* index.ts is a side-effect-free library barrel imported by @detiq/api — it must NOT
|
|
6
|
+
* start any background loop itself, or importing a single helper from @detiq/crawler
|
|
7
|
+
* would silently spin up a second worker inside the API process too. This file is
|
|
8
|
+
* the actual entrypoint that keeps a dedicated worker container's process alive and
|
|
9
|
+
* consuming jobs: `node dist/worker.js`.
|
|
10
|
+
*/
|
|
11
|
+
import { startJobWorkerLoop, processDataRetentionPurge } from './job-queue.js';
|
|
12
|
+
import { logger } from './logger.js';
|
|
3
13
|
async function main() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
logger.info('[worker] starting standalone crawler worker process');
|
|
15
|
+
// Durable DB-backed queue — claims every non-CRAWL job type, and CRAWL too when
|
|
16
|
+
// JOB_QUEUE_BACKEND isn't 'sqs'. Safe to run in many worker replicas at once.
|
|
17
|
+
startJobWorkerLoop();
|
|
18
|
+
// Daily data-retention purge: runs immediately on startup then every 24 h.
|
|
19
|
+
// Only runs in the dedicated worker container (this file), not in the API
|
|
20
|
+
// process, so there is exactly one purge sweep regardless of API replica count.
|
|
21
|
+
const runPurge = () => {
|
|
22
|
+
processDataRetentionPurge().catch((err) => {
|
|
23
|
+
logger.error({ err: String(err) }, '[worker] data-retention purge failed');
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
runPurge();
|
|
27
|
+
setInterval(runPurge, 24 * 60 * 60 * 1000);
|
|
28
|
+
// Optional: also consume the SQS transport for horizontally-scaled CRAWL fleets.
|
|
29
|
+
if (process.env.JOB_QUEUE_BACKEND === 'sqs') {
|
|
30
|
+
const { startSqsWorker } = await import('./sqs-queue.js');
|
|
31
|
+
startSqsWorker().catch((err) => {
|
|
32
|
+
logger.error({ err: String(err) }, '[worker] SQS worker crashed');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
20
36
|
}
|
|
21
|
-
process.on(
|
|
22
|
-
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
process.on("SIGINT", () => {
|
|
26
|
-
logger.info("[worker] SIGINT received, exiting");
|
|
27
|
-
process.exit(0);
|
|
28
|
-
});
|
|
37
|
+
process.on('SIGTERM', () => { logger.info('[worker] SIGTERM received, exiting'); process.exit(0); });
|
|
38
|
+
process.on('SIGINT', () => { logger.info('[worker] SIGINT received, exiting'); process.exit(0); });
|
|
29
39
|
main().catch((err) => {
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
logger.error({ err: String(err) }, '[worker] fatal startup error');
|
|
41
|
+
process.exit(1);
|
|
32
42
|
});
|
|
33
|
-
//# sourceMappingURL=worker.js.map
|