@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.
Files changed (92) hide show
  1. package/dist/accessibility-auditor.js +74 -54
  2. package/dist/ai-login.js +249 -227
  3. package/dist/auth-token-rotator.js +67 -57
  4. package/dist/auth.js +336 -299
  5. package/dist/browser-extension.js +142 -104
  6. package/dist/captcha-solver.js +125 -98
  7. package/dist/color-contrast.js +89 -77
  8. package/dist/content-chunker.js +126 -126
  9. package/dist/content-dedup.js +71 -54
  10. package/dist/cookie-consent.js +83 -68
  11. package/dist/cookie-jar.js +60 -53
  12. package/dist/crawler.js +5345 -4486
  13. package/dist/custom-js-injector.js +61 -45
  14. package/dist/dark-mode-capture.js +81 -67
  15. package/dist/dead-link-detector.js +55 -47
  16. package/dist/element-hash.js +12 -8
  17. package/dist/email-otp.js +195 -154
  18. package/dist/engine-router.js +98 -87
  19. package/dist/export/bulk-export.js +55 -70
  20. package/dist/export/vector-export.js +105 -77
  21. package/dist/extractors/advanced.d.ts +10 -0
  22. package/dist/extractors/advanced.js +266 -249
  23. package/dist/extractors/artifact-envelope.js +58 -59
  24. package/dist/failure-analysis-agent.js +33 -37
  25. package/dist/feature-flag-detector.js +66 -51
  26. package/dist/form-detector.js +75 -55
  27. package/dist/frontier.js +101 -76
  28. package/dist/gap-pass.js +89 -68
  29. package/dist/graphql-detector.js +72 -62
  30. package/dist/http-engine.js +330 -282
  31. package/dist/incremental-diff.js +87 -54
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +28 -63
  34. package/dist/index.js.map +2 -2
  35. package/dist/input-fuzzer.js +97 -93
  36. package/dist/interactive-probe.d.ts +36 -0
  37. package/dist/interactive-probe.js +827 -715
  38. package/dist/job-queue.js +2169 -2151
  39. package/dist/js-coverage.js +56 -52
  40. package/dist/js-router-detector.js +117 -86
  41. package/dist/language-detector.js +63 -51
  42. package/dist/link-classifier.js +50 -32
  43. package/dist/live-view.js +108 -91
  44. package/dist/locator-extractor.d.ts +37 -0
  45. package/dist/locator-extractor.js +199 -0
  46. package/dist/locator-extractor.js.map +7 -0
  47. package/dist/logger.js +7 -9
  48. package/dist/markdown-extract.js +61 -48
  49. package/dist/native-crawler.js +946 -780
  50. package/dist/network-observer.js +156 -135
  51. package/dist/network-throttle.js +40 -29
  52. package/dist/openapi-generator.js +92 -77
  53. package/dist/pdf-extractor.js +90 -72
  54. package/dist/performance-metrics.js +102 -80
  55. package/dist/phash.js +144 -125
  56. package/dist/pii-scrubber.js +68 -65
  57. package/dist/playwright-recorder.js +58 -70
  58. package/dist/policies/crawl-safety.js +34 -31
  59. package/dist/profiles/domain-profile.js +125 -130
  60. package/dist/proxy.js +172 -146
  61. package/dist/rate-limiter.js +65 -58
  62. package/dist/redirect-tracker.js +64 -60
  63. package/dist/redis-frontier.js +136 -116
  64. package/dist/redis-queue.js +144 -157
  65. package/dist/response-cache.js +140 -127
  66. package/dist/responsive-detector.js +46 -42
  67. package/dist/retry-policy.js +50 -46
  68. package/dist/robots-txt.js +83 -69
  69. package/dist/screen-reader.js +70 -45
  70. package/dist/screenshot-masker.js +77 -59
  71. package/dist/seo-checker.js +107 -88
  72. package/dist/session-capture.js +212 -192
  73. package/dist/session-export.js +133 -107
  74. package/dist/sitemap-writer.js +41 -38
  75. package/dist/sitemap.js +202 -141
  76. package/dist/skyvern.js +148 -123
  77. package/dist/sqs-queue.js +42 -42
  78. package/dist/sso-token.js +90 -74
  79. package/dist/stealth/human-behavior.js +173 -156
  80. package/dist/telemetry.js +82 -68
  81. package/dist/test-executor.js +335 -309
  82. package/dist/tls-fingerprint.js +88 -77
  83. package/dist/url-pattern-completer.js +90 -71
  84. package/dist/visual-diff-verdict.js +38 -23
  85. package/dist/webhook-notifier.js +69 -71
  86. package/dist/websocket-detector.js +68 -56
  87. package/dist/worker.js +38 -29
  88. package/package.json +1 -1
  89. package/src/index.ts +2 -0
  90. package/src/locator-extractor.ts +226 -0
  91. package/types/index.d.ts +2 -0
  92. package/types/locator-extractor.d.ts +37 -0
@@ -1,61 +1,94 @@
1
- function hashContent(text) {
2
- let h1 = 5381;
3
- let h2 = 52711;
4
- for (let i = 0; i < text.length; i++) {
5
- const c = text.charCodeAt(i);
6
- h1 = (Math.imul(h1, 33) ^ c) >>> 0;
7
- h2 = (Math.imul(h2, 31) ^ c) >>> 0;
8
- }
9
- return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
1
+ /**
2
+ * Incremental crawl diff — compute stable content hashes and skip unchanged screens.
3
+ *
4
+ * Each crawled page gets a content fingerprint (murmurhash-free, pure JS).
5
+ * On the next crawl of the same project, pages with the same fingerprint are
6
+ * marked SKIPPED instead of re-processed, drastically reducing crawl time and
7
+ * LLM token spend for sites with mostly-static content.
8
+ *
9
+ * Design: "same content hash" means the meaningful text hasn't changed.
10
+ * Layout/CSS/JS changes that don't affect visible text are ignored intentionally.
11
+ */
12
+ /**
13
+ * Compute a stable 64-bit-ish hash from text content.
14
+ * djb2 variant — fast, no deps, collision-resistant enough for content fingerprinting.
15
+ */
16
+ export function hashContent(text) {
17
+ let h1 = 5381;
18
+ let h2 = 52711;
19
+ for (let i = 0; i < text.length; i++) {
20
+ const c = text.charCodeAt(i);
21
+ h1 = (Math.imul(h1, 33) ^ c) >>> 0;
22
+ h2 = (Math.imul(h2, 31) ^ c) >>> 0;
23
+ }
24
+ return (h1 >>> 0).toString(16).padStart(8, '0') + (h2 >>> 0).toString(16).padStart(8, '0');
10
25
  }
11
- function normalizeText(text) {
12
- return text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0).join("\n");
26
+ /**
27
+ * Normalize text before hashing — strips whitespace-only lines, trims each line,
28
+ * collapses runs of blank lines. Makes hash stable across minor formatting changes.
29
+ */
30
+ export function normalizeText(text) {
31
+ return text
32
+ .split('\n')
33
+ .map(l => l.trim())
34
+ .filter(l => l.length > 0)
35
+ .join('\n');
13
36
  }
14
- function computeContentHash(url, markdownText) {
15
- const normalized = normalizeText(markdownText);
16
- return {
17
- url,
18
- hash: hashContent(normalized),
19
- textLength: normalized.length,
20
- computedAt: (/* @__PURE__ */ new Date()).toISOString()
21
- };
37
+ export function computeContentHash(url, markdownText) {
38
+ const normalized = normalizeText(markdownText);
39
+ return {
40
+ url,
41
+ hash: hashContent(normalized),
42
+ textLength: normalized.length,
43
+ computedAt: new Date().toISOString(),
44
+ };
22
45
  }
23
- function diffContent(url, currentMarkdown, priorHashes) {
24
- const current = computeContentHash(url, currentMarkdown);
25
- const prior = priorHashes.get(url);
26
- if (!prior) {
27
- return { url, changed: true, currentHash: current.hash, reason: "new" };
28
- }
29
- if (prior === current.hash) {
30
- return { url, changed: false, previousHash: prior, currentHash: current.hash, reason: "unchanged" };
31
- }
32
- return { url, changed: true, previousHash: prior, currentHash: current.hash, reason: "changed" };
46
+ /**
47
+ * Compare a page's current content against prior hashes.
48
+ * Returns { changed: false } for unchanged pages — caller should skip re-processing.
49
+ */
50
+ export function diffContent(url, currentMarkdown, priorHashes) {
51
+ const current = computeContentHash(url, currentMarkdown);
52
+ const prior = priorHashes.get(url);
53
+ if (!prior) {
54
+ return { url, changed: true, currentHash: current.hash, reason: 'new' };
55
+ }
56
+ if (prior === current.hash) {
57
+ return { url, changed: false, previousHash: prior, currentHash: current.hash, reason: 'unchanged' };
58
+ }
59
+ return { url, changed: true, previousHash: prior, currentHash: current.hash, reason: 'changed' };
33
60
  }
34
- function buildPriorHashMap(screenRecords) {
35
- const map = /* @__PURE__ */ new Map();
36
- for (const s of screenRecords) {
37
- if (s.url && s.elementHash) map.set(s.url, s.elementHash);
38
- }
39
- return map;
61
+ /**
62
+ * Build a hash map from prior screen records (from DB query result).
63
+ * screenRecords: Array<{ url: string; elementHash?: string | null }>
64
+ */
65
+ export function buildPriorHashMap(screenRecords) {
66
+ const map = new Map();
67
+ for (const s of screenRecords) {
68
+ if (s.url && s.elementHash)
69
+ map.set(s.url, s.elementHash);
70
+ }
71
+ return map;
40
72
  }
41
- function partitionByChange(urls, priorHashes) {
42
- const toProcess = [];
43
- const toSkip = [];
44
- for (const url of urls) {
45
- if (priorHashes.has(url)) {
46
- toProcess.push(url);
47
- } else {
48
- toProcess.push(url);
73
+ /**
74
+ * Filter a batch of discovered URLs against prior hashes.
75
+ * Returns { toProcess, toSkip } — caller enqueues toProcess, logs toSkip count.
76
+ *
77
+ * Note: filtering at URL level only works if the prior crawl already visited the URL.
78
+ * For new URLs, they're always in toProcess.
79
+ */
80
+ export function partitionByChange(urls, priorHashes) {
81
+ const toProcess = [];
82
+ const toSkip = [];
83
+ for (const url of urls) {
84
+ if (priorHashes.has(url)) {
85
+ // Can't know if changed without fetching — still needs fetch, but hash after fetch
86
+ // will determine skip. Include all — hash check happens post-fetch.
87
+ toProcess.push(url);
88
+ }
89
+ else {
90
+ toProcess.push(url);
91
+ }
49
92
  }
50
- }
51
- return { toProcess, toSkip };
93
+ return { toProcess, toSkip };
52
94
  }
53
- export {
54
- buildPriorHashMap,
55
- computeContentHash,
56
- diffContent,
57
- hashContent,
58
- normalizeText,
59
- partitionByChange
60
- };
61
- //# sourceMappingURL=incremental-diff.js.map
package/dist/index.d.ts CHANGED
@@ -35,3 +35,5 @@ export { startSpan, endSpan, withSpan, increment, flushMetrics } from './telemet
35
35
  export type { Span, FinishedSpan } from './telemetry.js';
36
36
  export { analyzeFailure } from './failure-analysis-agent.js';
37
37
  export type { FailureContext } from './failure-analysis-agent.js';
38
+ export { elementToPlaywrightLocator, elementsToPlaywrightLocators, formatLocatorsForPrompt } from './locator-extractor.js';
39
+ export type { PlaywrightLocator } from './locator-extractor.js';
package/dist/index.js CHANGED
@@ -1,63 +1,28 @@
1
- export * from "./crawler.js";
2
- export * from "./visual-diff-verdict.js";
3
- export * from "./auth.js";
4
- export * from "./screen-reader.js";
5
- export * from "./job-queue.js";
6
- import { startSqsWorker } from "./sqs-queue.js";
7
- export * from "./session-capture.js";
8
- export * from "./session-export.js";
9
- export * from "./test-executor.js";
10
- import { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from "./live-view.js";
11
- import { waitForEmailOTP, getInboxEmail } from "./email-otp.js";
12
- import { getSsoToken, getSsoClientCredentialsToken } from "./sso-token.js";
13
- export * from "./engine-router.js";
14
- export * from "./profiles/domain-profile.js";
15
- export * from "./policies/crawl-safety.js";
16
- export * from "./extractors/artifact-envelope.js";
17
- export * from "./network-observer.js";
18
- import { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from "./tls-fingerprint.js";
19
- import { prepareExtensionProfile, adBlockerProfile } from "./browser-extension.js";
20
- import { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from "./redis-queue.js";
21
- import { discoverProjectUrls, discoverSitemapUrls } from "./sitemap.js";
22
- import { httpCrawl } from "./http-engine.js";
23
- import { extractMarkdown } from "./markdown-extract.js";
24
- import { TieredProxyManager } from "./proxy.js";
25
- import { RedisCrawlFrontier, isRedisFrontierEnabled } from "./redis-frontier.js";
26
- import { startSpan, endSpan, withSpan, increment, flushMetrics } from "./telemetry.js";
27
- import { analyzeFailure } from "./failure-analysis-agent.js";
28
- export {
29
- CHROME_TLS_HEADERS,
30
- RedisCrawlFrontier,
31
- TieredProxyManager,
32
- adBlockerProfile,
33
- analyzeFailure,
34
- chromeTlsAgent,
35
- closeLiveView,
36
- completeLiveView,
37
- createChromeTlsAgent,
38
- createRedisQueue,
39
- discoverProjectUrls,
40
- discoverSitemapUrls,
41
- endSpan,
42
- extractMarkdown,
43
- flushMetrics,
44
- getFrame,
45
- getInboxEmail,
46
- getSsoClientCredentialsToken,
47
- getSsoToken,
48
- httpCrawl,
49
- increment,
50
- isRedisFrontierEnabled,
51
- isRedisQueueEnabled,
52
- liveViewNavigate,
53
- maybeCreateRedisQueue,
54
- prepareExtensionProfile,
55
- probeTlsFingerprint,
56
- sendInput,
57
- startLiveView,
58
- startSpan,
59
- startSqsWorker,
60
- waitForEmailOTP,
61
- withSpan
62
- };
63
- //# sourceMappingURL=index.js.map
1
+ export * from './crawler.js';
2
+ export * from './visual-diff-verdict.js';
3
+ export * from './auth.js';
4
+ export * from './screen-reader.js';
5
+ export * from './job-queue.js';
6
+ export { startSqsWorker } from './sqs-queue.js';
7
+ export * from './session-capture.js';
8
+ export * from './session-export.js';
9
+ export * from './test-executor.js';
10
+ export { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from './live-view.js';
11
+ export { waitForEmailOTP, getInboxEmail } from './email-otp.js';
12
+ export { getSsoToken, getSsoClientCredentialsToken } from './sso-token.js';
13
+ export * from './engine-router.js';
14
+ export * from './profiles/domain-profile.js';
15
+ export * from './policies/crawl-safety.js';
16
+ export * from './extractors/artifact-envelope.js';
17
+ export * from './network-observer.js';
18
+ export { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from './tls-fingerprint.js';
19
+ export { prepareExtensionProfile, adBlockerProfile } from './browser-extension.js';
20
+ export { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from './redis-queue.js';
21
+ export { discoverProjectUrls, discoverSitemapUrls } from './sitemap.js';
22
+ export { httpCrawl } from './http-engine.js';
23
+ export { extractMarkdown } from './markdown-extract.js';
24
+ export { TieredProxyManager } from './proxy.js';
25
+ export { RedisCrawlFrontier, isRedisFrontierEnabled } from './redis-frontier.js';
26
+ export { startSpan, endSpan, withSpan, increment, flushMetrics } from './telemetry.js';
27
+ export { analyzeFailure } from './failure-analysis-agent.js';
28
+ export { elementToPlaywrightLocator, elementsToPlaywrightLocators, formatLocatorsForPrompt } from './locator-extractor.js';
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["export * from './crawler.js';\nexport * from './visual-diff-verdict.js';\nexport * from './auth.js';\nexport * from './screen-reader.js';\nexport * from './job-queue.js';\nexport { startSqsWorker } from './sqs-queue.js';\nexport * from './session-capture.js';\nexport * from './session-export.js';\nexport * from './test-executor.js';\nexport { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from './live-view.js';\nexport { waitForEmailOTP, getInboxEmail } from './email-otp.js';\nexport { getSsoToken, getSsoClientCredentialsToken } from './sso-token.js';\nexport type { SsoConfig, SsoProvider } from './sso-token.js';\nexport * from './engine-router.js';\nexport * from './profiles/domain-profile.js';\nexport * from './policies/crawl-safety.js';\nexport * from './extractors/artifact-envelope.js';\nexport * from './network-observer.js';\nexport { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from './tls-fingerprint.js';\nexport type { TlsFingerprintOptions } from './tls-fingerprint.js';\nexport { prepareExtensionProfile, adBlockerProfile } from './browser-extension.js';\nexport type { ExtensionSource, ExtensionProfile } from './browser-extension.js';\nexport { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from './redis-queue.js';\nexport type { RedisQueueJob, RedisQueueClient } from './redis-queue.js';\nexport { discoverProjectUrls, discoverSitemapUrls } from './sitemap.js';\nexport type { UrlCandidate } from './sitemap.js';\nexport { httpCrawl } from './http-engine.js';\nexport { extractMarkdown } from './markdown-extract.js';\nexport type { ExtractedMarkdown } from './markdown-extract.js';\nexport type { HttpScreen, HttpCrawlOpts, HttpCrawlResult, HttpOutputFormat } from './http-engine.js';\nexport { TieredProxyManager } from './proxy.js';\nexport type { ProxyTier, ProxyTierConfig } from './proxy.js';\nexport { RedisCrawlFrontier, isRedisFrontierEnabled } from './redis-frontier.js';\nexport { startSpan, endSpan, withSpan, increment, flushMetrics } from './telemetry.js';\nexport type { Span, FinishedSpan } from './telemetry.js';\nexport { analyzeFailure } from './failure-analysis-agent.js';\nexport type { FailureContext } from './failure-analysis-agent.js';\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB;AAC/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe,UAAU,kBAAkB,kBAAkB,eAAe,iBAAiB;AACtG,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,aAAa,oCAAoC;AAE1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB,qBAAqB,gBAAgB,0BAA0B;AAE9F,SAAS,yBAAyB,wBAAwB;AAE1D,SAAS,kBAAkB,uBAAuB,2BAA2B;AAE7E,SAAS,qBAAqB,2BAA2B;AAEzD,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAGhC,SAAS,0BAA0B;AAEnC,SAAS,oBAAoB,8BAA8B;AAC3D,SAAS,WAAW,SAAS,UAAU,WAAW,oBAAoB;AAEtE,SAAS,sBAAsB;",
4
+ "sourcesContent": ["export * from './crawler.js';\nexport * from './visual-diff-verdict.js';\nexport * from './auth.js';\nexport * from './screen-reader.js';\nexport * from './job-queue.js';\nexport { startSqsWorker } from './sqs-queue.js';\nexport * from './session-capture.js';\nexport * from './session-export.js';\nexport * from './test-executor.js';\nexport { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from './live-view.js';\nexport { waitForEmailOTP, getInboxEmail } from './email-otp.js';\nexport { getSsoToken, getSsoClientCredentialsToken } from './sso-token.js';\nexport type { SsoConfig, SsoProvider } from './sso-token.js';\nexport * from './engine-router.js';\nexport * from './profiles/domain-profile.js';\nexport * from './policies/crawl-safety.js';\nexport * from './extractors/artifact-envelope.js';\nexport * from './network-observer.js';\nexport { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from './tls-fingerprint.js';\nexport type { TlsFingerprintOptions } from './tls-fingerprint.js';\nexport { prepareExtensionProfile, adBlockerProfile } from './browser-extension.js';\nexport type { ExtensionSource, ExtensionProfile } from './browser-extension.js';\nexport { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from './redis-queue.js';\nexport type { RedisQueueJob, RedisQueueClient } from './redis-queue.js';\nexport { discoverProjectUrls, discoverSitemapUrls } from './sitemap.js';\nexport type { UrlCandidate } from './sitemap.js';\nexport { httpCrawl } from './http-engine.js';\nexport { extractMarkdown } from './markdown-extract.js';\nexport type { ExtractedMarkdown } from './markdown-extract.js';\nexport type { HttpScreen, HttpCrawlOpts, HttpCrawlResult, HttpOutputFormat } from './http-engine.js';\nexport { TieredProxyManager } from './proxy.js';\nexport type { ProxyTier, ProxyTierConfig } from './proxy.js';\nexport { RedisCrawlFrontier, isRedisFrontierEnabled } from './redis-frontier.js';\nexport { startSpan, endSpan, withSpan, increment, flushMetrics } from './telemetry.js';\nexport type { Span, FinishedSpan } from './telemetry.js';\nexport { analyzeFailure } from './failure-analysis-agent.js';\nexport type { FailureContext } from './failure-analysis-agent.js';\nexport { elementToPlaywrightLocator, elementsToPlaywrightLocators, formatLocatorsForPrompt } from './locator-extractor.js';\nexport type { PlaywrightLocator } from './locator-extractor.js';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB;AAC/B,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe,UAAU,kBAAkB,kBAAkB,eAAe,iBAAiB;AACtG,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,aAAa,oCAAoC;AAE1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,sBAAsB,qBAAqB,gBAAgB,0BAA0B;AAE9F,SAAS,yBAAyB,wBAAwB;AAE1D,SAAS,kBAAkB,uBAAuB,2BAA2B;AAE7E,SAAS,qBAAqB,2BAA2B;AAEzD,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAGhC,SAAS,0BAA0B;AAEnC,SAAS,oBAAoB,8BAA8B;AAC3D,SAAS,WAAW,SAAS,UAAU,WAAW,oBAAoB;AAEtE,SAAS,sBAAsB;AAE/B,SAAS,4BAA4B,8BAA8B,+BAA+B;",
6
6
  "names": []
7
7
  }
@@ -1,105 +1,109 @@
1
- const LOREM = "Lorem ipsum dolor sit amet consectetur adipiscing elit";
1
+ /**
2
+ * Input fuzzer — generate test data for form fields.
3
+ *
4
+ * For each field type, produces a set of test values covering:
5
+ * - Happy path (valid, normal input)
6
+ * - Boundary (min/max length, min/max value)
7
+ * - Edge cases (empty, very long, special chars, SQL injection probe, XSS probe)
8
+ * - Type-invalid (wrong type for the field)
9
+ *
10
+ * This feeds ZeTa's test generator to automatically create form validation tests.
11
+ * Values are safe probes (NOT actual exploits) — they test whether the app
12
+ * properly rejects/accepts boundary inputs.
13
+ */
14
+ const LOREM = 'Lorem ipsum dolor sit amet consectetur adipiscing elit';
2
15
  function generateEmailCases() {
3
- return [
4
- { label: "valid email", value: "test@example.com", expectedValid: true, category: "happy" },
5
- { label: "email with plus", value: "test+tag@example.com", expectedValid: true, category: "happy" },
6
- { label: "missing @", value: "notanemail.com", expectedValid: false, category: "invalid" },
7
- { label: "missing domain", value: "test@", expectedValid: false, category: "invalid" },
8
- { label: "empty", value: "", expectedValid: false, category: "edge" },
9
- { label: "very long email", value: "a".repeat(100) + "@example.com", expectedValid: false, category: "boundary" },
10
- { label: "special chars", value: "test<script>@example.com", expectedValid: false, category: "edge" }
11
- ];
16
+ return [
17
+ { label: 'valid email', value: 'test@example.com', expectedValid: true, category: 'happy' },
18
+ { label: 'email with plus', value: 'test+tag@example.com', expectedValid: true, category: 'happy' },
19
+ { label: 'missing @', value: 'notanemail.com', expectedValid: false, category: 'invalid' },
20
+ { label: 'missing domain', value: 'test@', expectedValid: false, category: 'invalid' },
21
+ { label: 'empty', value: '', expectedValid: false, category: 'edge' },
22
+ { label: 'very long email', value: 'a'.repeat(100) + '@example.com', expectedValid: false, category: 'boundary' },
23
+ { label: 'special chars', value: 'test<script>@example.com', expectedValid: false, category: 'edge' },
24
+ ];
12
25
  }
13
26
  function generatePasswordCases(minLength, maxLength) {
14
- const min = minLength ?? 8;
15
- const max = maxLength ?? 128;
16
- return [
17
- { label: "valid password", value: "ValidP@ss1", expectedValid: true, category: "happy" },
18
- { label: "minimum length", value: "A".repeat(min), expectedValid: true, category: "boundary" },
19
- { label: "below minimum", value: "A".repeat(Math.max(1, min - 1)), expectedValid: false, category: "boundary" },
20
- { label: "max length", value: "Aa1!".repeat(Math.ceil(max / 4)).slice(0, max), expectedValid: true, category: "boundary" },
21
- { label: "empty", value: "", expectedValid: false, category: "edge" },
22
- { label: "spaces only", value: " ", expectedValid: false, category: "edge" }
23
- ];
27
+ const min = minLength ?? 8;
28
+ const max = maxLength ?? 128;
29
+ return [
30
+ { label: 'valid password', value: 'ValidP@ss1', expectedValid: true, category: 'happy' },
31
+ { label: 'minimum length', value: 'A'.repeat(min), expectedValid: true, category: 'boundary' },
32
+ { label: 'below minimum', value: 'A'.repeat(Math.max(1, min - 1)), expectedValid: false, category: 'boundary' },
33
+ { label: 'max length', value: 'Aa1!'.repeat(Math.ceil(max / 4)).slice(0, max), expectedValid: true, category: 'boundary' },
34
+ { label: 'empty', value: '', expectedValid: false, category: 'edge' },
35
+ { label: 'spaces only', value: ' ', expectedValid: false, category: 'edge' },
36
+ ];
24
37
  }
25
38
  function generateTextCases(minLength, maxLength, required) {
26
- const cases = [
27
- { label: "typical text", value: "Test Input Value", expectedValid: true, category: "happy" },
28
- { label: "single char", value: "A", expectedValid: !minLength || minLength <= 1, category: "boundary" },
29
- { label: "empty", value: "", expectedValid: !required, category: "edge" },
30
- { label: "spaces only", value: " ", expectedValid: !required, category: "edge" },
31
- { label: "very long text", value: LOREM.repeat(20), expectedValid: !maxLength || maxLength > LOREM.length * 20, category: "boundary" },
32
- { label: "unicode", value: "\u65E5\u672C\u8A9E\u30C6\u30B9\u30C8 \xDCn\xEFc\xF6d\xE9 Emojitest \u{1F389}", expectedValid: true, category: "edge" },
33
- { label: "HTML special chars", value: "<script>alert(1)</script>", expectedValid: true, category: "edge" },
34
- { label: "SQL probe", value: "' OR '1'='1", expectedValid: true, category: "edge" }
35
- ];
36
- if (minLength) cases.push({ label: `below min (${minLength})`, value: "x".repeat(Math.max(0, minLength - 1)), expectedValid: false, category: "boundary" });
37
- if (maxLength) cases.push({ label: `above max (${maxLength})`, value: "x".repeat(maxLength + 1), expectedValid: false, category: "boundary" });
38
- return cases;
39
+ const cases = [
40
+ { label: 'typical text', value: 'Test Input Value', expectedValid: true, category: 'happy' },
41
+ { label: 'single char', value: 'A', expectedValid: !minLength || minLength <= 1, category: 'boundary' },
42
+ { label: 'empty', value: '', expectedValid: !required, category: 'edge' },
43
+ { label: 'spaces only', value: ' ', expectedValid: !required, category: 'edge' },
44
+ { label: 'very long text', value: LOREM.repeat(20), expectedValid: !maxLength || maxLength > LOREM.length * 20, category: 'boundary' },
45
+ { label: 'unicode', value: '日本語テスト Ünïcödé Emojitest 🎉', expectedValid: true, category: 'edge' },
46
+ { label: 'HTML special chars', value: '<script>alert(1)</script>', expectedValid: true, category: 'edge' },
47
+ { label: 'SQL probe', value: "' OR '1'='1", expectedValid: true, category: 'edge' },
48
+ ];
49
+ if (minLength)
50
+ cases.push({ label: `below min (${minLength})`, value: 'x'.repeat(Math.max(0, minLength - 1)), expectedValid: false, category: 'boundary' });
51
+ if (maxLength)
52
+ cases.push({ label: `above max (${maxLength})`, value: 'x'.repeat(maxLength + 1), expectedValid: false, category: 'boundary' });
53
+ return cases;
39
54
  }
40
55
  function generateNumberCases(min, max) {
41
- const minN = min !== void 0 ? parseFloat(min) : void 0;
42
- const maxN = max !== void 0 ? parseFloat(max) : void 0;
43
- return [
44
- { label: "valid number", value: "42", expectedValid: true, category: "happy" },
45
- { label: "zero", value: "0", expectedValid: minN === void 0 || minN <= 0, category: "boundary" },
46
- { label: "negative", value: "-1", expectedValid: minN === void 0 || minN < 0, category: "boundary" },
47
- { label: "decimal", value: "3.14", expectedValid: true, category: "happy" },
48
- { label: "text as number", value: "notanumber", expectedValid: false, category: "invalid" },
49
- { label: "empty", value: "", expectedValid: false, category: "edge" },
50
- ...minN !== void 0 ? [{ label: `below min (${min})`, value: String(minN - 1), expectedValid: false, category: "boundary" }] : [],
51
- ...maxN !== void 0 ? [{ label: `above max (${max})`, value: String(maxN + 1), expectedValid: false, category: "boundary" }] : []
52
- ];
56
+ const minN = min !== undefined ? parseFloat(min) : undefined;
57
+ const maxN = max !== undefined ? parseFloat(max) : undefined;
58
+ return [
59
+ { label: 'valid number', value: '42', expectedValid: true, category: 'happy' },
60
+ { label: 'zero', value: '0', expectedValid: minN === undefined || minN <= 0, category: 'boundary' },
61
+ { label: 'negative', value: '-1', expectedValid: minN === undefined || minN < 0, category: 'boundary' },
62
+ { label: 'decimal', value: '3.14', expectedValid: true, category: 'happy' },
63
+ { label: 'text as number', value: 'notanumber', expectedValid: false, category: 'invalid' },
64
+ { label: 'empty', value: '', expectedValid: false, category: 'edge' },
65
+ ...(minN !== undefined ? [{ label: `below min (${min})`, value: String(minN - 1), expectedValid: false, category: 'boundary' }] : []),
66
+ ...(maxN !== undefined ? [{ label: `above max (${max})`, value: String(maxN + 1), expectedValid: false, category: 'boundary' }] : []),
67
+ ];
53
68
  }
54
69
  function generateSelectCases(options) {
55
- if (!options?.length) return [{ label: "first option", value: "", expectedValid: true, category: "happy" }];
56
- return [
57
- { label: `first option (${options[0]})`, value: options[0], expectedValid: true, category: "happy" },
58
- { label: "invalid option", value: "__INVALID_OPTION__", expectedValid: false, category: "invalid" },
59
- { label: "empty selection", value: "", expectedValid: false, category: "edge" },
60
- ...options.length > 1 ? [{ label: `last option (${options[options.length - 1]})`, value: options[options.length - 1], expectedValid: true, category: "happy" }] : []
61
- ];
70
+ if (!options?.length)
71
+ return [{ label: 'first option', value: '', expectedValid: true, category: 'happy' }];
72
+ return [
73
+ { label: `first option (${options[0]})`, value: options[0], expectedValid: true, category: 'happy' },
74
+ { label: 'invalid option', value: '__INVALID_OPTION__', expectedValid: false, category: 'invalid' },
75
+ { label: 'empty selection', value: '', expectedValid: false, category: 'edge' },
76
+ ...(options.length > 1 ? [{ label: `last option (${options[options.length - 1]})`, value: options[options.length - 1], expectedValid: true, category: 'happy' }] : []),
77
+ ];
62
78
  }
63
- function generateFieldCases(field) {
64
- switch (field.type) {
65
- case "email":
66
- return generateEmailCases();
67
- case "password":
68
- return generatePasswordCases(field.minLength, field.maxLength);
69
- case "number":
70
- return generateNumberCases(field.min, field.max);
71
- case "select":
72
- return generateSelectCases(field.options);
73
- case "checkbox":
74
- return [
75
- { label: "checked", value: "true", expectedValid: true, category: "happy" },
76
- { label: "unchecked", value: "false", expectedValid: !field.required, category: field.required ? "invalid" : "happy" }
77
- ];
78
- case "date":
79
- return [
80
- { label: "valid date", value: "2026-01-15", expectedValid: true, category: "happy" },
81
- { label: "invalid date", value: "9999-99-99", expectedValid: false, category: "invalid" },
82
- { label: "empty", value: "", expectedValid: !field.required, category: "edge" }
83
- ];
84
- case "url":
85
- return [
86
- { label: "valid URL", value: "https://example.com", expectedValid: true, category: "happy" },
87
- { label: "missing protocol", value: "example.com", expectedValid: false, category: "invalid" },
88
- { label: "empty", value: "", expectedValid: !field.required, category: "edge" }
89
- ];
90
- default:
91
- return generateTextCases(field.minLength, field.maxLength, field.required);
92
- }
79
+ export function generateFieldCases(field) {
80
+ switch (field.type) {
81
+ case 'email': return generateEmailCases();
82
+ case 'password': return generatePasswordCases(field.minLength, field.maxLength);
83
+ case 'number': return generateNumberCases(field.min, field.max);
84
+ case 'select': return generateSelectCases(field.options);
85
+ case 'checkbox': return [
86
+ { label: 'checked', value: 'true', expectedValid: true, category: 'happy' },
87
+ { label: 'unchecked', value: 'false', expectedValid: !field.required, category: field.required ? 'invalid' : 'happy' },
88
+ ];
89
+ case 'date': return [
90
+ { label: 'valid date', value: '2026-01-15', expectedValid: true, category: 'happy' },
91
+ { label: 'invalid date', value: '9999-99-99', expectedValid: false, category: 'invalid' },
92
+ { label: 'empty', value: '', expectedValid: !field.required, category: 'edge' },
93
+ ];
94
+ case 'url': return [
95
+ { label: 'valid URL', value: 'https://example.com', expectedValid: true, category: 'happy' },
96
+ { label: 'missing protocol', value: 'example.com', expectedValid: false, category: 'invalid' },
97
+ { label: 'empty', value: '', expectedValid: !field.required, category: 'edge' },
98
+ ];
99
+ default:
100
+ return generateTextCases(field.minLength, field.maxLength, field.required);
101
+ }
93
102
  }
94
- function fuzzForm(form) {
95
- return {
96
- formIndex: form.index,
97
- purpose: form.purpose,
98
- fieldCases: form.fields.map((field) => ({ field, cases: generateFieldCases(field) }))
99
- };
103
+ export function fuzzForm(form) {
104
+ return {
105
+ formIndex: form.index,
106
+ purpose: form.purpose,
107
+ fieldCases: form.fields.map(field => ({ field, cases: generateFieldCases(field) })),
108
+ };
100
109
  }
101
- export {
102
- fuzzForm,
103
- generateFieldCases
104
- };
105
- //# sourceMappingURL=input-fuzzer.js.map
@@ -43,6 +43,35 @@ export interface ConditionalReveal {
43
43
  triggerValue: string;
44
44
  revealedText: string;
45
45
  }
46
+ export interface TooltipCapture {
47
+ triggerLabel: string;
48
+ tooltipText: string;
49
+ }
50
+ export interface TabPanelCapture {
51
+ tabLabel: string;
52
+ panelContent: string;
53
+ panelHeading?: string;
54
+ }
55
+ export interface CarouselSlide {
56
+ slideIndex: number;
57
+ heading?: string;
58
+ content: string;
59
+ }
60
+ export interface WizardStep {
61
+ stepIndex: number;
62
+ stepLabel?: string;
63
+ content: string;
64
+ fields: string[];
65
+ }
66
+ export interface FocusTrapResult {
67
+ modalTrigger: string;
68
+ focusTrapped: boolean;
69
+ sampledFocused: string[];
70
+ }
71
+ export interface ContextMenuCapture {
72
+ trigger: string;
73
+ items: string[];
74
+ }
46
75
  export interface ProbeResult {
47
76
  screenId: string;
48
77
  url: string;
@@ -51,6 +80,13 @@ export interface ProbeResult {
51
80
  modals: ModalObservation[];
52
81
  conditionals: ConditionalReveal[];
53
82
  loadingPatterns: string[];
83
+ tooltips?: TooltipCapture[];
84
+ tabPanels?: TabPanelCapture[];
85
+ carouselSlides?: CarouselSlide[];
86
+ wizardSteps?: WizardStep[];
87
+ focusTraps?: FocusTrapResult[];
88
+ skipNavIssues?: string[];
89
+ contextMenus?: ContextMenuCapture[];
54
90
  }
55
91
  /**
56
92
  * Run interactive probing on a single screen page.