@keak/webmcp-core 0.1.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.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/config.d.ts +103 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/exporter/manifest.d.ts +6 -0
- package/dist/exporter/manifest.d.ts.map +1 -0
- package/dist/exporter/manifest.js +36 -0
- package/dist/exporter/manifest.js.map +1 -0
- package/dist/exporter/snippet.d.ts +7 -0
- package/dist/exporter/snippet.d.ts.map +1 -0
- package/dist/exporter/snippet.js +197 -0
- package/dist/exporter/snippet.js.map +1 -0
- package/dist/exporter/userscript.d.ts +6 -0
- package/dist/exporter/userscript.d.ts.map +1 -0
- package/dist/exporter/userscript.js +53 -0
- package/dist/exporter/userscript.js.map +1 -0
- package/dist/exporter/yaml.d.ts +6 -0
- package/dist/exporter/yaml.d.ts.map +1 -0
- package/dist/exporter/yaml.js +90 -0
- package/dist/exporter/yaml.js.map +1 -0
- package/dist/extractor/api-extractor.d.ts +3 -0
- package/dist/extractor/api-extractor.d.ts.map +1 -0
- package/dist/extractor/api-extractor.js +274 -0
- package/dist/extractor/api-extractor.js.map +1 -0
- package/dist/extractor/click-extractor.d.ts +3 -0
- package/dist/extractor/click-extractor.d.ts.map +1 -0
- package/dist/extractor/click-extractor.js +52 -0
- package/dist/extractor/click-extractor.js.map +1 -0
- package/dist/extractor/form-extractor.d.ts +3 -0
- package/dist/extractor/form-extractor.d.ts.map +1 -0
- package/dist/extractor/form-extractor.js +27 -0
- package/dist/extractor/form-extractor.js.map +1 -0
- package/dist/extractor/route-extractor.d.ts +3 -0
- package/dist/extractor/route-extractor.d.ts.map +1 -0
- package/dist/extractor/route-extractor.js +84 -0
- package/dist/extractor/route-extractor.js.map +1 -0
- package/dist/extractor/schema-inferrer.d.ts +4 -0
- package/dist/extractor/schema-inferrer.d.ts.map +1 -0
- package/dist/extractor/schema-inferrer.js +128 -0
- package/dist/extractor/schema-inferrer.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/linter/linter.d.ts +10 -0
- package/dist/linter/linter.d.ts.map +1 -0
- package/dist/linter/linter.js +39 -0
- package/dist/linter/linter.js.map +1 -0
- package/dist/linter/rules.d.ts +4 -0
- package/dist/linter/rules.d.ts.map +1 -0
- package/dist/linter/rules.js +111 -0
- package/dist/linter/rules.js.map +1 -0
- package/dist/scanner/browser.d.ts +14 -0
- package/dist/scanner/browser.d.ts.map +1 -0
- package/dist/scanner/browser.js +42 -0
- package/dist/scanner/browser.js.map +1 -0
- package/dist/scanner/crawler.d.ts +12 -0
- package/dist/scanner/crawler.d.ts.map +1 -0
- package/dist/scanner/crawler.js +80 -0
- package/dist/scanner/crawler.js.map +1 -0
- package/dist/scanner/dom-capture.d.ts +4 -0
- package/dist/scanner/dom-capture.d.ts.map +1 -0
- package/dist/scanner/dom-capture.js +148 -0
- package/dist/scanner/dom-capture.js.map +1 -0
- package/dist/scanner/network-capture.d.ts +8 -0
- package/dist/scanner/network-capture.d.ts.map +1 -0
- package/dist/scanner/network-capture.js +112 -0
- package/dist/scanner/network-capture.js.map +1 -0
- package/dist/scanner/screenshot.d.ts +3 -0
- package/dist/scanner/screenshot.d.ts.map +1 -0
- package/dist/scanner/screenshot.js +10 -0
- package/dist/scanner/screenshot.js.map +1 -0
- package/dist/synthesizer/clusterer.d.ts +7 -0
- package/dist/synthesizer/clusterer.d.ts.map +1 -0
- package/dist/synthesizer/clusterer.js +310 -0
- package/dist/synthesizer/clusterer.js.map +1 -0
- package/dist/synthesizer/describer.d.ts +3 -0
- package/dist/synthesizer/describer.d.ts.map +1 -0
- package/dist/synthesizer/describer.js +92 -0
- package/dist/synthesizer/describer.js.map +1 -0
- package/dist/synthesizer/llm-client.d.ts +7 -0
- package/dist/synthesizer/llm-client.d.ts.map +1 -0
- package/dist/synthesizer/llm-client.js +7 -0
- package/dist/synthesizer/llm-client.js.map +1 -0
- package/dist/synthesizer/namer.d.ts +3 -0
- package/dist/synthesizer/namer.d.ts.map +1 -0
- package/dist/synthesizer/namer.js +154 -0
- package/dist/synthesizer/namer.js.map +1 -0
- package/dist/synthesizer/safety-classifier.d.ts +3 -0
- package/dist/synthesizer/safety-classifier.d.ts.map +1 -0
- package/dist/synthesizer/safety-classifier.js +68 -0
- package/dist/synthesizer/safety-classifier.js.map +1 -0
- package/dist/synthesizer/schema-builder.d.ts +3 -0
- package/dist/synthesizer/schema-builder.d.ts.map +1 -0
- package/dist/synthesizer/schema-builder.js +99 -0
- package/dist/synthesizer/schema-builder.js.map +1 -0
- package/dist/types.d.ts +271 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/redact.d.ts +3 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +42 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/validation.d.ts +876 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +108 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.launchBrowser = launchBrowser;
|
|
4
|
+
const playwright_1 = require("playwright");
|
|
5
|
+
async function launchBrowser(config = {}) {
|
|
6
|
+
const launchOptions = {
|
|
7
|
+
headless: config.headless ?? false,
|
|
8
|
+
};
|
|
9
|
+
if (config.executablePath) {
|
|
10
|
+
launchOptions.executablePath = config.executablePath;
|
|
11
|
+
}
|
|
12
|
+
const browser = await playwright_1.chromium.launch(launchOptions);
|
|
13
|
+
const contextOptions = {
|
|
14
|
+
viewport: { width: 1440, height: 900 },
|
|
15
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
16
|
+
};
|
|
17
|
+
const context = await browser.newContext(contextOptions);
|
|
18
|
+
if (config.cookie) {
|
|
19
|
+
const cookies = parseCookieString(config.cookie);
|
|
20
|
+
if (cookies.length > 0) {
|
|
21
|
+
await context.addCookies(cookies);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const page = await context.newPage();
|
|
25
|
+
return { browser, context, page };
|
|
26
|
+
}
|
|
27
|
+
function parseCookieString(cookieString) {
|
|
28
|
+
return cookieString
|
|
29
|
+
.split(";")
|
|
30
|
+
.map((pair) => pair.trim())
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.map((pair) => {
|
|
33
|
+
const [name, ...rest] = pair.split("=");
|
|
34
|
+
return {
|
|
35
|
+
name: name.trim(),
|
|
36
|
+
value: rest.join("=").trim(),
|
|
37
|
+
domain: "", // Will be set from the page URL
|
|
38
|
+
path: "/",
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/scanner/browser.ts"],"names":[],"mappings":";;AAeA,sCA+BC;AA9CD,2CAAoF;AAe7E,KAAK,UAAU,aAAa,CACjC,SAAwB,EAAE;IAE1B,MAAM,aAAa,GAA4B;QAC7C,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;KACnC,CAAC;IAEF,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,aAAa,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IACvD,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,qBAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAErD,MAAM,cAAc,GAA4B;QAC9C,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE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
|
+
export interface PageVisit {
|
|
8
|
+
url: string;
|
|
9
|
+
depth: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function crawlSite(page: Page, startUrl: string, options: CrawlOptions): AsyncGenerator<PageVisit>;
|
|
12
|
+
//# sourceMappingURL=crawler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crawler.d.ts","sourceRoot":"","sources":["../../src/scanner/crawler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAuB,SAAS,CAC9B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,cAAc,CAAC,SAAS,CAAC,CAyC3B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crawlSite = crawlSite;
|
|
4
|
+
async function* crawlSite(page, startUrl, options) {
|
|
5
|
+
const visited = new Set();
|
|
6
|
+
const queue = [
|
|
7
|
+
{ url: normalizeUrl(startUrl), depth: 0 },
|
|
8
|
+
];
|
|
9
|
+
while (queue.length > 0) {
|
|
10
|
+
const current = queue.shift();
|
|
11
|
+
const normalized = normalizeUrl(current.url);
|
|
12
|
+
if (visited.has(normalized))
|
|
13
|
+
continue;
|
|
14
|
+
if (current.depth > options.depth)
|
|
15
|
+
continue;
|
|
16
|
+
visited.add(normalized);
|
|
17
|
+
try {
|
|
18
|
+
await page.goto(current.url, {
|
|
19
|
+
waitUntil: "domcontentloaded",
|
|
20
|
+
timeout: options.timeout,
|
|
21
|
+
});
|
|
22
|
+
await page.waitForLoadState("load").catch(() => { });
|
|
23
|
+
await page.waitForTimeout(2000);
|
|
24
|
+
yield { url: current.url, depth: current.depth };
|
|
25
|
+
if (current.depth < options.depth) {
|
|
26
|
+
const links = await discoverInternalLinks(page, startUrl, options.ignoreSelectors);
|
|
27
|
+
for (const link of links) {
|
|
28
|
+
const normalizedLink = normalizeUrl(link);
|
|
29
|
+
if (!visited.has(normalizedLink)) {
|
|
30
|
+
queue.push({ url: link, depth: current.depth + 1 });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
console.warn(` Warning: Failed to load ${current.url}: ${message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function discoverInternalLinks(page, baseUrl, ignoreSelectors) {
|
|
42
|
+
const baseOrigin = new URL(baseUrl).origin;
|
|
43
|
+
const ignoreSelectorsStr = JSON.stringify(ignoreSelectors);
|
|
44
|
+
return page.evaluate(({ origin, ignoreArr }) => {
|
|
45
|
+
const links = [];
|
|
46
|
+
const anchors = document.querySelectorAll("a[href]");
|
|
47
|
+
for (const anchor of anchors) {
|
|
48
|
+
const shouldIgnore = ignoreArr.some((sel) => anchor.matches(sel));
|
|
49
|
+
if (shouldIgnore)
|
|
50
|
+
continue;
|
|
51
|
+
const href = anchor.href;
|
|
52
|
+
try {
|
|
53
|
+
const url = new URL(href);
|
|
54
|
+
if (url.origin === origin && !url.hash) {
|
|
55
|
+
links.push(url.href);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Invalid URL, skip
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return [...new Set(links)];
|
|
63
|
+
}, { origin: baseOrigin, ignoreArr: JSON.parse(ignoreSelectorsStr) });
|
|
64
|
+
}
|
|
65
|
+
function normalizeUrl(url) {
|
|
66
|
+
try {
|
|
67
|
+
const parsed = new URL(url);
|
|
68
|
+
parsed.hash = "";
|
|
69
|
+
let path = parsed.pathname;
|
|
70
|
+
if (path.endsWith("/") && path !== "/") {
|
|
71
|
+
path = path.slice(0, -1);
|
|
72
|
+
}
|
|
73
|
+
parsed.pathname = path;
|
|
74
|
+
return parsed.toString();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return url;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=crawler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crawler.js","sourceRoot":"","sources":["../../src/scanner/crawler.ts"],"names":[],"mappings":";;AAaA,8BA6CC;AA7CM,KAAK,SAAS,CAAC,CAAC,SAAS,CAC9B,IAAU,EACV,QAAgB,EAChB,OAAqB;IAErB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAA0C;QACnD,EAAE,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KAC1C,CAAC;IAEF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAG,CAAC;QAC/B,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAE7C,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAS;QACtC,IAAI,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK;YAAE,SAAS;QAE5C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC3B,SAAS,EAAE,kBAAkB;gBAC7B,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;YAEH,MAAM,I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,CAAC;YACvC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-capture.d.ts","sourceRoot":"","sources":["../../src/scanner/dom-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAA0C,MAAM,aAAa,CAAC;AAEvF,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAqJjE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.captureDom = captureDom;
|
|
4
|
+
async function captureDom(page) {
|
|
5
|
+
const result = await page.evaluate(() => {
|
|
6
|
+
const forms = [];
|
|
7
|
+
document.querySelectorAll("form").forEach((form, formIndex) => {
|
|
8
|
+
const fields = [];
|
|
9
|
+
const formSelector = form.id
|
|
10
|
+
? `#${form.id}`
|
|
11
|
+
: `form:nth-of-type(${formIndex + 1})`;
|
|
12
|
+
form.querySelectorAll("input, select, textarea").forEach((el) => {
|
|
13
|
+
const input = el;
|
|
14
|
+
const name = input.name || input.id || "";
|
|
15
|
+
if (!name)
|
|
16
|
+
return;
|
|
17
|
+
let label;
|
|
18
|
+
const labelEl = form.querySelector(`label[for="${input.id}"]`);
|
|
19
|
+
if (labelEl) {
|
|
20
|
+
label = labelEl.textContent?.trim();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const parentLabel = input.closest("label");
|
|
24
|
+
if (parentLabel) {
|
|
25
|
+
label = parentLabel.textContent?.trim()?.replace(input.value, "").trim();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let type = "string";
|
|
29
|
+
if (el.tagName === "SELECT")
|
|
30
|
+
type = "enum";
|
|
31
|
+
else if (input.type === "number" || input.type === "range")
|
|
32
|
+
type = "number";
|
|
33
|
+
else if (input.type === "checkbox")
|
|
34
|
+
type = "boolean";
|
|
35
|
+
else if (input.type === "email")
|
|
36
|
+
type = "email";
|
|
37
|
+
else if (input.type === "tel")
|
|
38
|
+
type = "tel";
|
|
39
|
+
else if (input.type === "url")
|
|
40
|
+
type = "url";
|
|
41
|
+
else if (input.type === "date" || input.type === "datetime-local")
|
|
42
|
+
type = "date";
|
|
43
|
+
let options;
|
|
44
|
+
if (el.tagName === "SELECT") {
|
|
45
|
+
options = Array.from(el.options)
|
|
46
|
+
.filter((opt) => opt.value)
|
|
47
|
+
.map((opt) => opt.value);
|
|
48
|
+
}
|
|
49
|
+
fields.push({
|
|
50
|
+
name,
|
|
51
|
+
type,
|
|
52
|
+
required: input.required || input.hasAttribute("required"),
|
|
53
|
+
label,
|
|
54
|
+
placeholder: input.placeholder || undefined,
|
|
55
|
+
options,
|
|
56
|
+
pattern: input.pattern || undefined,
|
|
57
|
+
min: input.min ? Number(input.min) : undefined,
|
|
58
|
+
max: input.max ? Number(input.max) : undefined,
|
|
59
|
+
defaultValue: input.defaultValue || undefined,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const submitBtn = form.querySelector('button[type="submit"]') ||
|
|
63
|
+
form.querySelector('input[type="submit"]') ||
|
|
64
|
+
form.querySelector("button:not([type])");
|
|
65
|
+
const submitSelector = submitBtn
|
|
66
|
+
? submitBtn.id
|
|
67
|
+
? `#${submitBtn.id}`
|
|
68
|
+
: `${formSelector} button[type="submit"]`
|
|
69
|
+
: `${formSelector} button`;
|
|
70
|
+
const labels = [];
|
|
71
|
+
const ariaLabel = form.getAttribute("aria-label");
|
|
72
|
+
if (ariaLabel)
|
|
73
|
+
labels.push(ariaLabel);
|
|
74
|
+
const legend = form.querySelector("legend");
|
|
75
|
+
if (legend)
|
|
76
|
+
labels.push(legend.textContent?.trim() || "");
|
|
77
|
+
const prev = form.previousElementSibling;
|
|
78
|
+
if (prev && /^h[1-6]$/i.test(prev.tagName)) {
|
|
79
|
+
labels.push(prev.textContent?.trim() || "");
|
|
80
|
+
}
|
|
81
|
+
forms.push({
|
|
82
|
+
selector: formSelector,
|
|
83
|
+
id: form.id || undefined,
|
|
84
|
+
action: form.action || undefined,
|
|
85
|
+
method: (form.method || "GET").toUpperCase(),
|
|
86
|
+
fields,
|
|
87
|
+
submitSelector,
|
|
88
|
+
labels: labels.filter(Boolean),
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
const buttons = [];
|
|
92
|
+
document
|
|
93
|
+
.querySelectorAll("button, [role='button'], a.btn, a.button")
|
|
94
|
+
.forEach((el, idx) => {
|
|
95
|
+
const isInsideForm = !!el.closest("form");
|
|
96
|
+
const text = el.textContent?.trim() || "";
|
|
97
|
+
const ariaLabel = el.getAttribute("aria-label") || undefined;
|
|
98
|
+
if (!text && !ariaLabel)
|
|
99
|
+
return;
|
|
100
|
+
const selector = el.id
|
|
101
|
+
? `#${el.id}`
|
|
102
|
+
: `[data-webmcp-idx="${idx}"]`;
|
|
103
|
+
buttons.push({
|
|
104
|
+
selector,
|
|
105
|
+
text,
|
|
106
|
+
ariaLabel,
|
|
107
|
+
type: el.type || undefined,
|
|
108
|
+
isInsideForm,
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const links = [];
|
|
112
|
+
document.querySelectorAll("a[href]").forEach((el) => {
|
|
113
|
+
const anchor = el;
|
|
114
|
+
const text = anchor.textContent?.trim() || "";
|
|
115
|
+
const href = anchor.href;
|
|
116
|
+
const ariaLabel = anchor.getAttribute("aria-label") || undefined;
|
|
117
|
+
if (!text && !ariaLabel)
|
|
118
|
+
return;
|
|
119
|
+
let isInternal = false;
|
|
120
|
+
try {
|
|
121
|
+
isInternal = new URL(href).origin === window.location.origin;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
isInternal = true;
|
|
125
|
+
}
|
|
126
|
+
const selector = anchor.id
|
|
127
|
+
? `#${anchor.id}`
|
|
128
|
+
: `a[href="${anchor.getAttribute("href")}"]`;
|
|
129
|
+
links.push({
|
|
130
|
+
selector,
|
|
131
|
+
text,
|
|
132
|
+
href,
|
|
133
|
+
ariaLabel,
|
|
134
|
+
isInternal,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
url: window.location.href,
|
|
139
|
+
title: document.title,
|
|
140
|
+
forms,
|
|
141
|
+
buttons,
|
|
142
|
+
links,
|
|
143
|
+
timestamp: new Date().toISOString(),
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=dom-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-capture.js","sourceRoot":"","sources":["../../src/scanner/dom-capture.ts"],"names":[],"mappings":";;AAGA,gCAqJC;AArJM,KAAK,UAAU,UAAU,CAAC,IAAU;IACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;QACtC,MAAM,KAAK,GAAc,EAAE,CAAC;QAC5B,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;YAC5D,MAAM,MAAM,GAAgB,EAAE,CAAC;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE;gBAC1B,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE;gBACf,CAAC,CAAC,oBAAoB,SAAS,GAAG,CAAC,GAAG,CAAC;YAEzC,IAAI,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,E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C;YAED,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE;gBACxB,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,EAAE;gBACjB,CAAC,CAAC,WAAW,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;YAE/C,KAAK,CAAC,IAAI,CAAC;gBACT,QAAQ;gBACR,IAAI;gBACJ,IAAI;gBACJ,SAAS;gBACT,UAAU;aACX,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,KAAK;YACL,OAAO;YACP,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAqB,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Page } from "playwright";
|
|
2
|
+
import type { NetworkCall } from "../types.js";
|
|
3
|
+
export interface NetworkRecorder {
|
|
4
|
+
getCalls(): NetworkCall[];
|
|
5
|
+
stop(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createNetworkRecorder(page: Page, baseUrl: string): NetworkRecorder;
|
|
8
|
+
//# sourceMappingURL=network-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-capture.d.ts","sourceRoot":"","sources":["../../src/scanner/network-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,IAAI,WAAW,EAAE,CAAC;IAC1B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAoFlF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNetworkRecorder = createNetworkRecorder;
|
|
4
|
+
function createNetworkRecorder(page, baseUrl) {
|
|
5
|
+
const calls = [];
|
|
6
|
+
let active = true;
|
|
7
|
+
const baseHost = getBaseDomain(baseUrl);
|
|
8
|
+
const onResponse = async (response) => {
|
|
9
|
+
if (!active)
|
|
10
|
+
return;
|
|
11
|
+
const request = response.request();
|
|
12
|
+
const resourceType = request.resourceType();
|
|
13
|
+
if (resourceType !== "fetch" &&
|
|
14
|
+
resourceType !== "xhr" &&
|
|
15
|
+
resourceType !== "document") {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const url = request.url();
|
|
19
|
+
if (!isSameSite(url, baseHost))
|
|
20
|
+
return;
|
|
21
|
+
if (isStaticResource(url))
|
|
22
|
+
return;
|
|
23
|
+
const method = request.method();
|
|
24
|
+
const status = response.status();
|
|
25
|
+
let requestBodySample = undefined;
|
|
26
|
+
let responseBodySample = undefined;
|
|
27
|
+
let operationName;
|
|
28
|
+
let operationType = undefined;
|
|
29
|
+
try {
|
|
30
|
+
const postData = request.postData();
|
|
31
|
+
if (postData) {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(postData);
|
|
34
|
+
requestBodySample = parsed;
|
|
35
|
+
if (parsed.query && (parsed.operationName || parsed.variables !== undefined)) {
|
|
36
|
+
operationName = parsed.operationName;
|
|
37
|
+
operationType = parsed.query.trim().startsWith("mutation")
|
|
38
|
+
? "mutation"
|
|
39
|
+
: "query";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
requestBodySample = postData;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Request body not available
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const contentType = response.headers()["content-type"] || "";
|
|
52
|
+
if (contentType.includes("json")) {
|
|
53
|
+
const body = await response.json();
|
|
54
|
+
responseBodySample = body;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Response body not available
|
|
59
|
+
}
|
|
60
|
+
calls.push({
|
|
61
|
+
method,
|
|
62
|
+
url,
|
|
63
|
+
status,
|
|
64
|
+
requestBodySample,
|
|
65
|
+
responseBodySample,
|
|
66
|
+
operationName,
|
|
67
|
+
operationType,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
page.on("response", onResponse);
|
|
71
|
+
return {
|
|
72
|
+
getCalls: () => [...calls],
|
|
73
|
+
stop: () => {
|
|
74
|
+
active = false;
|
|
75
|
+
page.off("response", onResponse);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function getBaseDomain(url) {
|
|
80
|
+
try {
|
|
81
|
+
return new URL(url).hostname;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return url;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Matches exact hostname or any subdomain relationship
|
|
88
|
+
function isSameSite(requestUrl, baseHost) {
|
|
89
|
+
try {
|
|
90
|
+
const callHost = new URL(requestUrl).hostname;
|
|
91
|
+
return (callHost === baseHost ||
|
|
92
|
+
callHost.endsWith("." + baseHost) ||
|
|
93
|
+
baseHost.endsWith("." + callHost));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function isStaticResource(url) {
|
|
100
|
+
const staticExtensions = [
|
|
101
|
+
".js", ".css", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico",
|
|
102
|
+
".woff", ".woff2", ".ttf", ".eot", ".map",
|
|
103
|
+
];
|
|
104
|
+
try {
|
|
105
|
+
const path = new URL(url).pathname.toLowerCase();
|
|
106
|
+
return staticExtensions.some((ext) => path.endsWith(ext));
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=network-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-capture.js","sourceRoot":"","sources":["../../src/scanner/network-capture.ts"],"names":[],"mappings":";;AAQA,sDAoFC;AApFD,SAAgB,qBAAqB,CAAC,IAAU,EAAE,OAAe;IAC/D,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,KAAK,EAAE,QAAkB,EAAE,EAAE;QAC9C,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QAE5C,IACE,YAAY,KAAK,OAAO;YACxB,YAAY,KAAK,KAAK;YACtB,YAAY,KAAK,UAAU,EAC3B,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAE1B,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;YAAE,OAAO;QAEvC,IAAI,gBAAgB,CAAC,GAAG,CAAC;YAAE,OAAO;QAElC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAA2B,CAAC;QACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAEjC,IAAI,iBAAiB,GAAY,SAAS,CAAC;QAC3C,IAAI,kBAAkB,GAAY,SAAS,CAAC;QAC5C,IAAI,aAAiC,CAAC;QACtC,IAAI,aAAa,GAAiC,SAAS,CAAC;QAE5D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;Y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ACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/scanner/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.captureScreenshot = captureScreenshot;
|
|
4
|
+
async function captureScreenshot(page, outputPath) {
|
|
5
|
+
await page.screenshot({
|
|
6
|
+
path: outputPath,
|
|
7
|
+
fullPage: true,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/scanner/screenshot.ts"],"names":[],"mappings":";;AAEA,8CAQC;AARM,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,UAAkB;IAElB,MAAM,IAAI,CAAC,UAAU,CAAC;QACpB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Action, ToolSpec } from "../types.js";
|
|
2
|
+
export interface ClusterOptions {
|
|
3
|
+
minConfidence?: number;
|
|
4
|
+
domain?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function clusterActions(actions: Action[], options?: ClusterOptions): ToolSpec[];
|
|
7
|
+
//# sourceMappingURL=clusterer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clusterer.d.ts","sourceRoot":"","sources":["../../src/synthesizer/clusterer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EAKT,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,cAAmB,GAC3B,QAAQ,EAAE,CAiBZ"}
|