@apitap/core 1.0.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 +60 -0
- package/README.md +362 -0
- package/SKILL.md +270 -0
- package/dist/auth/crypto.d.ts +31 -0
- package/dist/auth/crypto.js +66 -0
- package/dist/auth/crypto.js.map +1 -0
- package/dist/auth/handoff.d.ts +29 -0
- package/dist/auth/handoff.js +180 -0
- package/dist/auth/handoff.js.map +1 -0
- package/dist/auth/manager.d.ts +46 -0
- package/dist/auth/manager.js +127 -0
- package/dist/auth/manager.js.map +1 -0
- package/dist/auth/oauth-refresh.d.ts +16 -0
- package/dist/auth/oauth-refresh.js +91 -0
- package/dist/auth/oauth-refresh.js.map +1 -0
- package/dist/auth/refresh.d.ts +43 -0
- package/dist/auth/refresh.js +217 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/capture/anti-bot.d.ts +15 -0
- package/dist/capture/anti-bot.js +43 -0
- package/dist/capture/anti-bot.js.map +1 -0
- package/dist/capture/blocklist.d.ts +6 -0
- package/dist/capture/blocklist.js +70 -0
- package/dist/capture/blocklist.js.map +1 -0
- package/dist/capture/body-diff.d.ts +8 -0
- package/dist/capture/body-diff.js +102 -0
- package/dist/capture/body-diff.js.map +1 -0
- package/dist/capture/body-variables.d.ts +13 -0
- package/dist/capture/body-variables.js +142 -0
- package/dist/capture/body-variables.js.map +1 -0
- package/dist/capture/domain.d.ts +8 -0
- package/dist/capture/domain.js +34 -0
- package/dist/capture/domain.js.map +1 -0
- package/dist/capture/entropy.d.ts +33 -0
- package/dist/capture/entropy.js +100 -0
- package/dist/capture/entropy.js.map +1 -0
- package/dist/capture/filter.d.ts +11 -0
- package/dist/capture/filter.js +49 -0
- package/dist/capture/filter.js.map +1 -0
- package/dist/capture/graphql.d.ts +21 -0
- package/dist/capture/graphql.js +99 -0
- package/dist/capture/graphql.js.map +1 -0
- package/dist/capture/idle.d.ts +23 -0
- package/dist/capture/idle.js +44 -0
- package/dist/capture/idle.js.map +1 -0
- package/dist/capture/monitor.d.ts +26 -0
- package/dist/capture/monitor.js +183 -0
- package/dist/capture/monitor.js.map +1 -0
- package/dist/capture/oauth-detector.d.ts +18 -0
- package/dist/capture/oauth-detector.js +96 -0
- package/dist/capture/oauth-detector.js.map +1 -0
- package/dist/capture/pagination.d.ts +9 -0
- package/dist/capture/pagination.js +40 -0
- package/dist/capture/pagination.js.map +1 -0
- package/dist/capture/parameterize.d.ts +17 -0
- package/dist/capture/parameterize.js +63 -0
- package/dist/capture/parameterize.js.map +1 -0
- package/dist/capture/scrubber.d.ts +5 -0
- package/dist/capture/scrubber.js +38 -0
- package/dist/capture/scrubber.js.map +1 -0
- package/dist/capture/session.d.ts +46 -0
- package/dist/capture/session.js +445 -0
- package/dist/capture/session.js.map +1 -0
- package/dist/capture/token-detector.d.ts +16 -0
- package/dist/capture/token-detector.js +62 -0
- package/dist/capture/token-detector.js.map +1 -0
- package/dist/capture/verifier.d.ts +17 -0
- package/dist/capture/verifier.js +147 -0
- package/dist/capture/verifier.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +930 -0
- package/dist/cli.js.map +1 -0
- package/dist/discovery/auth.d.ts +17 -0
- package/dist/discovery/auth.js +81 -0
- package/dist/discovery/auth.js.map +1 -0
- package/dist/discovery/fetch.d.ts +17 -0
- package/dist/discovery/fetch.js +59 -0
- package/dist/discovery/fetch.js.map +1 -0
- package/dist/discovery/frameworks.d.ts +11 -0
- package/dist/discovery/frameworks.js +249 -0
- package/dist/discovery/frameworks.js.map +1 -0
- package/dist/discovery/index.d.ts +21 -0
- package/dist/discovery/index.js +219 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/openapi.d.ts +13 -0
- package/dist/discovery/openapi.js +175 -0
- package/dist/discovery/openapi.js.map +1 -0
- package/dist/discovery/probes.d.ts +9 -0
- package/dist/discovery/probes.js +70 -0
- package/dist/discovery/probes.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect/report.d.ts +52 -0
- package/dist/inspect/report.js +191 -0
- package/dist/inspect/report.js.map +1 -0
- package/dist/mcp.d.ts +8 -0
- package/dist/mcp.js +526 -0
- package/dist/mcp.js.map +1 -0
- package/dist/orchestration/browse.d.ts +38 -0
- package/dist/orchestration/browse.js +198 -0
- package/dist/orchestration/browse.js.map +1 -0
- package/dist/orchestration/cache.d.ts +15 -0
- package/dist/orchestration/cache.js +24 -0
- package/dist/orchestration/cache.js.map +1 -0
- package/dist/plugin.d.ts +17 -0
- package/dist/plugin.js +158 -0
- package/dist/plugin.js.map +1 -0
- package/dist/read/decoders/deepwiki.d.ts +2 -0
- package/dist/read/decoders/deepwiki.js +148 -0
- package/dist/read/decoders/deepwiki.js.map +1 -0
- package/dist/read/decoders/grokipedia.d.ts +2 -0
- package/dist/read/decoders/grokipedia.js +210 -0
- package/dist/read/decoders/grokipedia.js.map +1 -0
- package/dist/read/decoders/hackernews.d.ts +2 -0
- package/dist/read/decoders/hackernews.js +168 -0
- package/dist/read/decoders/hackernews.js.map +1 -0
- package/dist/read/decoders/index.d.ts +2 -0
- package/dist/read/decoders/index.js +12 -0
- package/dist/read/decoders/index.js.map +1 -0
- package/dist/read/decoders/reddit.d.ts +2 -0
- package/dist/read/decoders/reddit.js +142 -0
- package/dist/read/decoders/reddit.js.map +1 -0
- package/dist/read/decoders/twitter.d.ts +12 -0
- package/dist/read/decoders/twitter.js +187 -0
- package/dist/read/decoders/twitter.js.map +1 -0
- package/dist/read/decoders/wikipedia.d.ts +2 -0
- package/dist/read/decoders/wikipedia.js +66 -0
- package/dist/read/decoders/wikipedia.js.map +1 -0
- package/dist/read/decoders/youtube.d.ts +2 -0
- package/dist/read/decoders/youtube.js +69 -0
- package/dist/read/decoders/youtube.js.map +1 -0
- package/dist/read/extract.d.ts +25 -0
- package/dist/read/extract.js +320 -0
- package/dist/read/extract.js.map +1 -0
- package/dist/read/index.d.ts +14 -0
- package/dist/read/index.js +66 -0
- package/dist/read/index.js.map +1 -0
- package/dist/read/peek.d.ts +9 -0
- package/dist/read/peek.js +137 -0
- package/dist/read/peek.js.map +1 -0
- package/dist/read/types.d.ts +44 -0
- package/dist/read/types.js +3 -0
- package/dist/read/types.js.map +1 -0
- package/dist/replay/engine.d.ts +53 -0
- package/dist/replay/engine.js +441 -0
- package/dist/replay/engine.js.map +1 -0
- package/dist/replay/truncate.d.ts +16 -0
- package/dist/replay/truncate.js +92 -0
- package/dist/replay/truncate.js.map +1 -0
- package/dist/serve.d.ts +31 -0
- package/dist/serve.js +149 -0
- package/dist/serve.js.map +1 -0
- package/dist/skill/generator.d.ts +44 -0
- package/dist/skill/generator.js +419 -0
- package/dist/skill/generator.js.map +1 -0
- package/dist/skill/importer.d.ts +26 -0
- package/dist/skill/importer.js +80 -0
- package/dist/skill/importer.js.map +1 -0
- package/dist/skill/search.d.ts +19 -0
- package/dist/skill/search.js +51 -0
- package/dist/skill/search.js.map +1 -0
- package/dist/skill/signing.d.ts +16 -0
- package/dist/skill/signing.js +34 -0
- package/dist/skill/signing.js.map +1 -0
- package/dist/skill/ssrf.d.ts +27 -0
- package/dist/skill/ssrf.js +210 -0
- package/dist/skill/ssrf.js.map +1 -0
- package/dist/skill/store.d.ts +7 -0
- package/dist/skill/store.js +93 -0
- package/dist/skill/store.js.map +1 -0
- package/dist/stats/report.d.ts +26 -0
- package/dist/stats/report.js +157 -0
- package/dist/stats/report.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
- package/src/auth/crypto.ts +92 -0
- package/src/auth/handoff.ts +229 -0
- package/src/auth/manager.ts +140 -0
- package/src/auth/oauth-refresh.ts +120 -0
- package/src/auth/refresh.ts +300 -0
- package/src/capture/anti-bot.ts +63 -0
- package/src/capture/blocklist.ts +75 -0
- package/src/capture/body-diff.ts +109 -0
- package/src/capture/body-variables.ts +156 -0
- package/src/capture/domain.ts +34 -0
- package/src/capture/entropy.ts +121 -0
- package/src/capture/filter.ts +56 -0
- package/src/capture/graphql.ts +124 -0
- package/src/capture/idle.ts +45 -0
- package/src/capture/monitor.ts +224 -0
- package/src/capture/oauth-detector.ts +106 -0
- package/src/capture/pagination.ts +49 -0
- package/src/capture/parameterize.ts +68 -0
- package/src/capture/scrubber.ts +49 -0
- package/src/capture/session.ts +502 -0
- package/src/capture/token-detector.ts +76 -0
- package/src/capture/verifier.ts +171 -0
- package/src/cli.ts +1031 -0
- package/src/discovery/auth.ts +99 -0
- package/src/discovery/fetch.ts +85 -0
- package/src/discovery/frameworks.ts +231 -0
- package/src/discovery/index.ts +256 -0
- package/src/discovery/openapi.ts +230 -0
- package/src/discovery/probes.ts +76 -0
- package/src/index.ts +26 -0
- package/src/inspect/report.ts +247 -0
- package/src/mcp.ts +618 -0
- package/src/orchestration/browse.ts +250 -0
- package/src/orchestration/cache.ts +37 -0
- package/src/plugin.ts +188 -0
- package/src/read/decoders/deepwiki.ts +180 -0
- package/src/read/decoders/grokipedia.ts +246 -0
- package/src/read/decoders/hackernews.ts +198 -0
- package/src/read/decoders/index.ts +15 -0
- package/src/read/decoders/reddit.ts +158 -0
- package/src/read/decoders/twitter.ts +211 -0
- package/src/read/decoders/wikipedia.ts +75 -0
- package/src/read/decoders/youtube.ts +75 -0
- package/src/read/extract.ts +396 -0
- package/src/read/index.ts +78 -0
- package/src/read/peek.ts +175 -0
- package/src/read/types.ts +37 -0
- package/src/replay/engine.ts +559 -0
- package/src/replay/truncate.ts +116 -0
- package/src/serve.ts +189 -0
- package/src/skill/generator.ts +473 -0
- package/src/skill/importer.ts +107 -0
- package/src/skill/search.ts +76 -0
- package/src/skill/signing.ts +36 -0
- package/src/skill/ssrf.ts +238 -0
- package/src/skill/store.ts +107 -0
- package/src/stats/report.ts +208 -0
- package/src/types.ts +233 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { validateUrl } from '../skill/ssrf.js';
|
|
2
|
+
import { safeFetch } from './fetch.js';
|
|
3
|
+
import { detectFrameworks } from './frameworks.js';
|
|
4
|
+
import { discoverSpecs, parseSpecToSkillFile } from './openapi.js';
|
|
5
|
+
import { probeApiPaths } from './probes.js';
|
|
6
|
+
import { detectAuthRequired } from './auth.js';
|
|
7
|
+
/**
|
|
8
|
+
* Run smart discovery on a URL to detect APIs without launching a browser.
|
|
9
|
+
*
|
|
10
|
+
* Flow:
|
|
11
|
+
* 1. SSRF validation
|
|
12
|
+
* 2. Fetch homepage HTML + headers
|
|
13
|
+
* 3. Run detection strategies in parallel:
|
|
14
|
+
* - Framework detection (from HTML/headers)
|
|
15
|
+
* - OpenAPI spec discovery (probe common paths)
|
|
16
|
+
* - Common API pattern probing
|
|
17
|
+
* 4. Synthesize results into a DiscoveryResult
|
|
18
|
+
*/
|
|
19
|
+
export async function discover(url, options = {}) {
|
|
20
|
+
const start = Date.now();
|
|
21
|
+
const fullUrl = url.startsWith('http') ? url : `https://${url}`;
|
|
22
|
+
// SSRF check
|
|
23
|
+
if (!options.skipSsrf) {
|
|
24
|
+
const ssrfResult = validateUrl(fullUrl);
|
|
25
|
+
if (!ssrfResult.safe) {
|
|
26
|
+
return {
|
|
27
|
+
confidence: 'none',
|
|
28
|
+
hints: [`SSRF blocked: ${ssrfResult.reason}`],
|
|
29
|
+
duration: Date.now() - start,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let domain;
|
|
34
|
+
let origin;
|
|
35
|
+
try {
|
|
36
|
+
const parsed = new URL(fullUrl);
|
|
37
|
+
domain = parsed.hostname;
|
|
38
|
+
origin = parsed.origin;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {
|
|
42
|
+
confidence: 'none',
|
|
43
|
+
hints: ['Invalid URL'],
|
|
44
|
+
duration: Date.now() - start,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Fetch homepage
|
|
48
|
+
const homepage = await safeFetch(fullUrl, { timeout: options.timeout ?? 10000, skipSsrf: options.skipSsrf });
|
|
49
|
+
if (!homepage) {
|
|
50
|
+
return {
|
|
51
|
+
confidence: 'none',
|
|
52
|
+
hints: ['Failed to fetch homepage — site may be down or blocking requests'],
|
|
53
|
+
duration: Date.now() - start,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const ssrfOpts = { skipSsrf: options.skipSsrf };
|
|
57
|
+
// Auth detection (runs on homepage HTML + headers)
|
|
58
|
+
const authResult = detectAuthRequired(homepage.body, fullUrl, homepage.headers);
|
|
59
|
+
const authFields = authResult.authRequired ? {
|
|
60
|
+
authRequired: true,
|
|
61
|
+
authSignals: authResult.signals,
|
|
62
|
+
...(authResult.loginUrl ? { loginUrl: authResult.loginUrl } : {}),
|
|
63
|
+
} : {};
|
|
64
|
+
// Run all detection strategies in parallel
|
|
65
|
+
const [frameworks, specs, probes] = await Promise.all([
|
|
66
|
+
options.skipFrameworks
|
|
67
|
+
? []
|
|
68
|
+
: detectFrameworks({ html: homepage.body, headers: homepage.headers, url: fullUrl }),
|
|
69
|
+
options.skipSpecs
|
|
70
|
+
? []
|
|
71
|
+
: discoverSpecs(origin, homepage.headers, ssrfOpts),
|
|
72
|
+
options.skipProbes
|
|
73
|
+
? []
|
|
74
|
+
: probeApiPaths(origin, ssrfOpts),
|
|
75
|
+
]);
|
|
76
|
+
const hints = [];
|
|
77
|
+
// Strategy 1: OpenAPI spec found → parse into skill file (highest confidence)
|
|
78
|
+
if (specs.length > 0) {
|
|
79
|
+
const bestSpec = specs[0];
|
|
80
|
+
const skillFile = await parseSpecToSkillFile(bestSpec.url, domain, origin, ssrfOpts);
|
|
81
|
+
if (skillFile && skillFile.endpoints.length > 0) {
|
|
82
|
+
hints.push(`OpenAPI spec found at ${bestSpec.url} (${bestSpec.version})`);
|
|
83
|
+
if (frameworks.length > 0)
|
|
84
|
+
hints.push(`Framework: ${frameworks.map(f => f.name).join(', ')}`);
|
|
85
|
+
addProbeHints(hints, probes);
|
|
86
|
+
return {
|
|
87
|
+
confidence: 'high',
|
|
88
|
+
skillFile,
|
|
89
|
+
hints,
|
|
90
|
+
frameworks: frameworks.length > 0 ? frameworks : undefined,
|
|
91
|
+
specs,
|
|
92
|
+
probes: probes.length > 0 ? probes : undefined,
|
|
93
|
+
duration: Date.now() - start,
|
|
94
|
+
...authFields,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Strategy 2: Framework detected → generate skeleton skill file
|
|
99
|
+
const highConfidence = frameworks.filter(f => f.confidence === 'high');
|
|
100
|
+
if (highConfidence.length > 0) {
|
|
101
|
+
const skillFile = buildFrameworkSkillFile(domain, origin, highConfidence);
|
|
102
|
+
hints.push(`Detected: ${highConfidence.map(f => f.name).join(', ')}`);
|
|
103
|
+
addProbeHints(hints, probes);
|
|
104
|
+
if (specs.length > 0)
|
|
105
|
+
hints.push(`Spec found but could not parse: ${specs.map(s => s.url).join(', ')}`);
|
|
106
|
+
return {
|
|
107
|
+
confidence: 'medium',
|
|
108
|
+
skillFile,
|
|
109
|
+
hints,
|
|
110
|
+
frameworks,
|
|
111
|
+
specs: specs.length > 0 ? specs : undefined,
|
|
112
|
+
probes: probes.length > 0 ? probes : undefined,
|
|
113
|
+
duration: Date.now() - start,
|
|
114
|
+
...authFields,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// Strategy 3: Medium-confidence framework or API probes found → hints only
|
|
118
|
+
const apiProbes = probes.filter(p => p.isApi);
|
|
119
|
+
const mediumFrameworks = frameworks.filter(f => f.confidence === 'medium');
|
|
120
|
+
if (mediumFrameworks.length > 0 || apiProbes.length > 0) {
|
|
121
|
+
if (mediumFrameworks.length > 0) {
|
|
122
|
+
const skillFile = buildFrameworkSkillFile(domain, origin, mediumFrameworks);
|
|
123
|
+
hints.push(`Possibly: ${mediumFrameworks.map(f => f.name).join(', ')}`);
|
|
124
|
+
addProbeHints(hints, probes);
|
|
125
|
+
return {
|
|
126
|
+
confidence: 'low',
|
|
127
|
+
skillFile,
|
|
128
|
+
hints,
|
|
129
|
+
frameworks,
|
|
130
|
+
probes: probes.length > 0 ? probes : undefined,
|
|
131
|
+
duration: Date.now() - start,
|
|
132
|
+
...authFields,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Only probes found
|
|
136
|
+
hints.push('API paths detected via probing');
|
|
137
|
+
addProbeHints(hints, probes);
|
|
138
|
+
return {
|
|
139
|
+
confidence: 'low',
|
|
140
|
+
hints,
|
|
141
|
+
frameworks: frameworks.length > 0 ? frameworks : undefined,
|
|
142
|
+
probes,
|
|
143
|
+
duration: Date.now() - start,
|
|
144
|
+
...authFields,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Nothing found
|
|
148
|
+
if (frameworks.length > 0) {
|
|
149
|
+
hints.push(`Low-confidence signals: ${frameworks.map(f => f.name).join(', ')}`);
|
|
150
|
+
}
|
|
151
|
+
hints.push('No API patterns detected — auto-capture recommended');
|
|
152
|
+
return {
|
|
153
|
+
confidence: 'none',
|
|
154
|
+
hints,
|
|
155
|
+
frameworks: frameworks.length > 0 ? frameworks : undefined,
|
|
156
|
+
probes: probes.length > 0 ? probes : undefined,
|
|
157
|
+
duration: Date.now() - start,
|
|
158
|
+
...authFields,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function addProbeHints(hints, probes) {
|
|
162
|
+
const apiProbes = probes.filter(p => p.isApi);
|
|
163
|
+
if (apiProbes.length > 0) {
|
|
164
|
+
hints.push(`API paths found: ${apiProbes.map(p => `${p.path} (${p.status})`).join(', ')}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Build a skeleton skill file from detected frameworks.
|
|
169
|
+
* Endpoints are unverified predictions — replayability is 'unknown'.
|
|
170
|
+
*/
|
|
171
|
+
function buildFrameworkSkillFile(domain, baseUrl, frameworks) {
|
|
172
|
+
const endpoints = [];
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
for (const framework of frameworks) {
|
|
175
|
+
for (const pattern of framework.apiPatterns) {
|
|
176
|
+
const key = `GET ${pattern}`;
|
|
177
|
+
if (seen.has(key))
|
|
178
|
+
continue;
|
|
179
|
+
seen.add(key);
|
|
180
|
+
const id = generateId('GET', pattern);
|
|
181
|
+
endpoints.push({
|
|
182
|
+
id,
|
|
183
|
+
method: 'GET',
|
|
184
|
+
path: pattern,
|
|
185
|
+
queryParams: {},
|
|
186
|
+
headers: {},
|
|
187
|
+
responseShape: { type: 'unknown' },
|
|
188
|
+
examples: {
|
|
189
|
+
request: { url: `${baseUrl}${pattern}`, headers: {} },
|
|
190
|
+
responsePreview: null,
|
|
191
|
+
},
|
|
192
|
+
replayability: {
|
|
193
|
+
tier: 'unknown',
|
|
194
|
+
verified: false,
|
|
195
|
+
signals: [`discovered-from-${framework.name.toLowerCase()}`],
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
version: '1.2',
|
|
202
|
+
domain,
|
|
203
|
+
capturedAt: new Date().toISOString(),
|
|
204
|
+
baseUrl,
|
|
205
|
+
endpoints,
|
|
206
|
+
metadata: {
|
|
207
|
+
captureCount: 0,
|
|
208
|
+
filteredCount: 0,
|
|
209
|
+
toolVersion: '1.0.0',
|
|
210
|
+
},
|
|
211
|
+
provenance: 'unsigned',
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function generateId(method, path) {
|
|
215
|
+
const segments = path.split('/').filter(s => s !== '' && !s.startsWith(':'));
|
|
216
|
+
const slug = segments.join('-').replace(/[^a-z0-9-]/gi, '').toLowerCase() || 'root';
|
|
217
|
+
return `${method.toLowerCase()}-${slug}`;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,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AE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC;IACpF,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SkillFile, DiscoveredSpec } from '../types.js';
|
|
2
|
+
export interface SpecDiscoveryOptions {
|
|
3
|
+
skipSsrf?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Check for API specs at common paths and in Link headers.
|
|
7
|
+
* Returns discovered specs with their URLs.
|
|
8
|
+
*/
|
|
9
|
+
export declare function discoverSpecs(baseUrl: string, homepageHeaders?: Record<string, string>, options?: SpecDiscoveryOptions): Promise<DiscoveredSpec[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse an OpenAPI/Swagger spec into a SkillFile.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseSpecToSkillFile(specUrl: string, domain: string, baseUrl: string, options?: SpecDiscoveryOptions): Promise<SkillFile | null>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { safeFetch } from './fetch.js';
|
|
2
|
+
/** Paths to check for API specs, in priority order */
|
|
3
|
+
const SPEC_PATHS = [
|
|
4
|
+
'/openapi.json',
|
|
5
|
+
'/swagger.json',
|
|
6
|
+
'/api-docs',
|
|
7
|
+
'/api/docs',
|
|
8
|
+
'/.well-known/openapi',
|
|
9
|
+
'/v1/openapi.json',
|
|
10
|
+
'/v2/openapi.json',
|
|
11
|
+
'/v3/openapi.json',
|
|
12
|
+
'/docs/api.json',
|
|
13
|
+
'/api/swagger.json',
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Check for API specs at common paths and in Link headers.
|
|
17
|
+
* Returns discovered specs with their URLs.
|
|
18
|
+
*/
|
|
19
|
+
export async function discoverSpecs(baseUrl, homepageHeaders, options = {}) {
|
|
20
|
+
const specs = [];
|
|
21
|
+
const origin = new URL(baseUrl).origin;
|
|
22
|
+
// Check Link header from homepage for rel="describedby"
|
|
23
|
+
if (homepageHeaders) {
|
|
24
|
+
const linkHeader = homepageHeaders['link'] || homepageHeaders['Link'];
|
|
25
|
+
if (linkHeader) {
|
|
26
|
+
const describedBy = parseLinkHeader(linkHeader, 'describedby');
|
|
27
|
+
if (describedBy) {
|
|
28
|
+
const specUrl = describedBy.startsWith('http') ? describedBy : `${origin}${describedBy}`;
|
|
29
|
+
const result = await tryFetchSpec(specUrl, options);
|
|
30
|
+
if (result)
|
|
31
|
+
specs.push(result);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Probe common spec paths in parallel
|
|
36
|
+
const checks = SPEC_PATHS.map(async (path) => {
|
|
37
|
+
const specUrl = `${origin}${path}`;
|
|
38
|
+
return tryFetchSpec(specUrl, options);
|
|
39
|
+
});
|
|
40
|
+
const results = await Promise.all(checks);
|
|
41
|
+
for (const result of results) {
|
|
42
|
+
if (result && !specs.some(s => s.url === result.url)) {
|
|
43
|
+
specs.push(result);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return specs;
|
|
47
|
+
}
|
|
48
|
+
async function tryFetchSpec(url, options = {}) {
|
|
49
|
+
const result = await safeFetch(url, { timeout: 5000, skipSsrf: options.skipSsrf });
|
|
50
|
+
if (!result || result.status !== 200)
|
|
51
|
+
return null;
|
|
52
|
+
// Must look like JSON
|
|
53
|
+
const ct = result.contentType.toLowerCase();
|
|
54
|
+
if (!ct.includes('json') && !ct.includes('yaml') && !ct.includes('text/plain'))
|
|
55
|
+
return null;
|
|
56
|
+
try {
|
|
57
|
+
const spec = JSON.parse(result.body);
|
|
58
|
+
if (spec.openapi || spec.swagger) {
|
|
59
|
+
const endpointCount = spec.paths ? Object.keys(spec.paths).reduce((sum, path) => {
|
|
60
|
+
return sum + Object.keys(spec.paths[path]).filter(m => ['get', 'post', 'put', 'patch', 'delete'].includes(m)).length;
|
|
61
|
+
}, 0) : 0;
|
|
62
|
+
return {
|
|
63
|
+
type: spec.openapi ? 'openapi' : 'swagger',
|
|
64
|
+
url,
|
|
65
|
+
version: spec.openapi || spec.swagger,
|
|
66
|
+
endpointCount,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Not valid JSON or not an API spec
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parse an OpenAPI/Swagger spec into a SkillFile.
|
|
77
|
+
*/
|
|
78
|
+
export async function parseSpecToSkillFile(specUrl, domain, baseUrl, options = {}) {
|
|
79
|
+
const result = await safeFetch(specUrl, { timeout: 10000, skipSsrf: options.skipSsrf });
|
|
80
|
+
if (!result || result.status !== 200)
|
|
81
|
+
return null;
|
|
82
|
+
let spec;
|
|
83
|
+
try {
|
|
84
|
+
spec = JSON.parse(result.body);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (!spec.paths)
|
|
90
|
+
return null;
|
|
91
|
+
// Determine API base URL
|
|
92
|
+
let apiBase = baseUrl;
|
|
93
|
+
if (spec.servers?.[0]?.url) {
|
|
94
|
+
const serverUrl = spec.servers[0].url;
|
|
95
|
+
apiBase = serverUrl.startsWith('http') ? serverUrl : `${baseUrl}${serverUrl}`;
|
|
96
|
+
}
|
|
97
|
+
else if (spec.host) {
|
|
98
|
+
const scheme = specUrl.startsWith('https') ? 'https' : 'http';
|
|
99
|
+
apiBase = `${scheme}://${spec.host}${spec.basePath || ''}`;
|
|
100
|
+
}
|
|
101
|
+
const endpoints = [];
|
|
102
|
+
for (const [path, methods] of Object.entries(spec.paths)) {
|
|
103
|
+
for (const [method, operation] of Object.entries(methods)) {
|
|
104
|
+
if (!['get', 'post', 'put', 'patch', 'delete'].includes(method))
|
|
105
|
+
continue;
|
|
106
|
+
const op = operation;
|
|
107
|
+
// Parameterize path: {id} → :id
|
|
108
|
+
const paramPath = path.replace(/\{([^}]+)\}/g, ':$1');
|
|
109
|
+
// Extract query params
|
|
110
|
+
const queryParams = {};
|
|
111
|
+
if (op.parameters) {
|
|
112
|
+
for (const param of op.parameters) {
|
|
113
|
+
if (param.in === 'query') {
|
|
114
|
+
queryParams[param.name] = {
|
|
115
|
+
type: param.schema?.type || 'string',
|
|
116
|
+
example: '',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Generate endpoint ID
|
|
122
|
+
const id = op.operationId
|
|
123
|
+
? method.toLowerCase() + '-' + op.operationId.replace(/[^a-z0-9]/gi, '-').toLowerCase()
|
|
124
|
+
: generateId(method, paramPath);
|
|
125
|
+
endpoints.push({
|
|
126
|
+
id,
|
|
127
|
+
method: method.toUpperCase(),
|
|
128
|
+
path: paramPath,
|
|
129
|
+
queryParams,
|
|
130
|
+
headers: {},
|
|
131
|
+
responseShape: { type: 'unknown' },
|
|
132
|
+
examples: {
|
|
133
|
+
request: { url: `${apiBase}${path}`, headers: {} },
|
|
134
|
+
responsePreview: null,
|
|
135
|
+
},
|
|
136
|
+
replayability: {
|
|
137
|
+
tier: 'unknown',
|
|
138
|
+
verified: false,
|
|
139
|
+
signals: ['discovered-from-spec'],
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (endpoints.length === 0)
|
|
145
|
+
return null;
|
|
146
|
+
return {
|
|
147
|
+
version: '1.2',
|
|
148
|
+
domain,
|
|
149
|
+
capturedAt: new Date().toISOString(),
|
|
150
|
+
baseUrl: apiBase,
|
|
151
|
+
endpoints,
|
|
152
|
+
metadata: {
|
|
153
|
+
captureCount: 0,
|
|
154
|
+
filteredCount: 0,
|
|
155
|
+
toolVersion: '1.0.0',
|
|
156
|
+
},
|
|
157
|
+
provenance: 'unsigned',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function generateId(method, path) {
|
|
161
|
+
const segments = path.split('/').filter(s => s !== '' && !s.startsWith(':'));
|
|
162
|
+
const slug = segments.join('-').replace(/[^a-z0-9-]/gi, '').toLowerCase() || 'root';
|
|
163
|
+
return `${method.toLowerCase()}-${slug}`;
|
|
164
|
+
}
|
|
165
|
+
function parseLinkHeader(header, rel) {
|
|
166
|
+
const parts = header.split(',');
|
|
167
|
+
for (const part of parts) {
|
|
168
|
+
const match = part.match(/<([^>]+)>.*rel\s*=\s*"?([^",;]+)"?/);
|
|
169
|
+
if (match && match[2].trim() === rel) {
|
|
170
|
+
return match[1];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../src/discovery/openapi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,sDAAsD;AACtD,MAAM,UAAU,GAAG;IACjB,eAAe;IACf,eAAe;IACf,WAAW;IACX,WAAW;IACX,sBAAsB;IACtB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,mBAAmB;CACpB,CAAC;AAiCF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,eAAwC,EACxC,UAAgC,EAAE;IAElC,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAEvC,wDAAwD;IACxD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC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eAAe,CAAC,MAAc,EAAE,GAAW;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC/D,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProbeResult } from '../types.js';
|
|
2
|
+
export interface ProbeOptions {
|
|
3
|
+
skipSsrf?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Probe common API paths with GET requests.
|
|
7
|
+
* Returns results for paths that respond with API-like content types.
|
|
8
|
+
*/
|
|
9
|
+
export declare function probeApiPaths(baseUrl: string, options?: ProbeOptions): Promise<ProbeResult[]>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { safeFetch } from './fetch.js';
|
|
2
|
+
/** Common API paths to probe */
|
|
3
|
+
const PROBE_PATHS = [
|
|
4
|
+
'/api/',
|
|
5
|
+
'/api/v1/',
|
|
6
|
+
'/api/v2/',
|
|
7
|
+
'/_api/',
|
|
8
|
+
'/rest/',
|
|
9
|
+
'/graphql',
|
|
10
|
+
'/gql',
|
|
11
|
+
'/api/graphql',
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Probe common API paths with GET requests.
|
|
15
|
+
* Returns results for paths that respond with API-like content types.
|
|
16
|
+
*/
|
|
17
|
+
export async function probeApiPaths(baseUrl, options = {}) {
|
|
18
|
+
const origin = new URL(baseUrl).origin;
|
|
19
|
+
const results = [];
|
|
20
|
+
const checks = PROBE_PATHS.map(async (path) => {
|
|
21
|
+
const url = `${origin}${path}`;
|
|
22
|
+
const result = await safeFetch(url, { timeout: 5000, method: 'GET', maxBodySize: 4096, skipSsrf: options.skipSsrf });
|
|
23
|
+
if (!result)
|
|
24
|
+
return null;
|
|
25
|
+
// Don't count redirects to login pages or error pages
|
|
26
|
+
if (result.status >= 400 && result.status !== 401 && result.status !== 403)
|
|
27
|
+
return null;
|
|
28
|
+
const ct = result.contentType.toLowerCase();
|
|
29
|
+
const isApi = isApiContentType(ct, result.body, result.status);
|
|
30
|
+
return {
|
|
31
|
+
method: 'GET',
|
|
32
|
+
path,
|
|
33
|
+
status: result.status,
|
|
34
|
+
contentType: result.contentType,
|
|
35
|
+
isApi,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const settled = await Promise.all(checks);
|
|
39
|
+
for (const result of settled) {
|
|
40
|
+
if (result)
|
|
41
|
+
results.push(result);
|
|
42
|
+
}
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
function isApiContentType(contentType, body, status) {
|
|
46
|
+
// JSON responses are API
|
|
47
|
+
if (contentType.includes('json'))
|
|
48
|
+
return true;
|
|
49
|
+
// XML/SOAP
|
|
50
|
+
if (contentType.includes('xml'))
|
|
51
|
+
return true;
|
|
52
|
+
// 401/403 at an API path means something is there (but needs auth)
|
|
53
|
+
if ((status === 401 || status === 403) && !contentType.includes('html'))
|
|
54
|
+
return true;
|
|
55
|
+
// GraphQL introspection response
|
|
56
|
+
if (body.includes('"data"') && body.includes('"__schema"'))
|
|
57
|
+
return true;
|
|
58
|
+
// Check if body looks like JSON even without proper content-type
|
|
59
|
+
if (body.trim().startsWith('{') || body.trim().startsWith('[')) {
|
|
60
|
+
try {
|
|
61
|
+
JSON.parse(body);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Not JSON
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=probes.js.map
|
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@ -0,0 +1,25 @@
|
|
|
1
|
+
export { capture, type CaptureOptions, type CaptureResult } from './capture/monitor.js';
|
|
2
|
+
export { shouldCapture } from './capture/filter.js';
|
|
3
|
+
export { isBlocklisted } from './capture/blocklist.js';
|
|
4
|
+
export { isDomainMatch } from './capture/domain.js';
|
|
5
|
+
export { scrubPII } from './capture/scrubber.js';
|
|
6
|
+
export { SkillGenerator } from './skill/generator.js';
|
|
7
|
+
export { writeSkillFile, readSkillFile, listSkillFiles } from './skill/store.js';
|
|
8
|
+
export { signSkillFile, verifySignature } from './skill/signing.js';
|
|
9
|
+
export { validateImport, importSkillFile } from './skill/importer.js';
|
|
10
|
+
export { validateUrl, validateSkillFileUrls, resolveAndValidateUrl, resolveAndValidateSkillFileUrls } from './skill/ssrf.js';
|
|
11
|
+
export { replayEndpoint, type ReplayResult } from './replay/engine.js';
|
|
12
|
+
export { peek, read, type PeekOptions, type ReadOptions } from './read/index.js';
|
|
13
|
+
export type { PeekResult, ReadResult, Decoder } from './read/types.js';
|
|
14
|
+
export { AuthManager, getMachineId } from './auth/manager.js';
|
|
15
|
+
export { parameterizePath, cleanFrameworkPath } from './capture/parameterize.js';
|
|
16
|
+
export { detectPagination } from './capture/pagination.js';
|
|
17
|
+
export { verifyEndpoints } from './capture/verifier.js';
|
|
18
|
+
export { IdleTracker } from './capture/idle.js';
|
|
19
|
+
export { isPathNoise } from './capture/filter.js';
|
|
20
|
+
export { searchSkills, type SearchResult, type SearchResponse } from './skill/search.js';
|
|
21
|
+
export { createPlugin, type Plugin, type ToolDefinition, type PluginOptions } from './plugin.js';
|
|
22
|
+
export { shannonEntropy, isLikelyToken, parseJwtClaims, type TokenClassification, type JwtClaims } from './capture/entropy.js';
|
|
23
|
+
export { isOAuthTokenRequest, type OAuthInfo } from './capture/oauth-detector.js';
|
|
24
|
+
export { CaptureSession, type SessionOptions, type InteractionAction } from './capture/session.js';
|
|
25
|
+
export type { SkillFile, SkillEndpoint, SkillSummary, CapturedExchange, StoredAuth, OAuthConfig, Replayability, PaginationInfo, PageSnapshot, PageElement, InteractionResult, FinishResult } from './types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export { capture } from './capture/monitor.js';
|
|
3
|
+
export { shouldCapture } from './capture/filter.js';
|
|
4
|
+
export { isBlocklisted } from './capture/blocklist.js';
|
|
5
|
+
export { isDomainMatch } from './capture/domain.js';
|
|
6
|
+
export { scrubPII } from './capture/scrubber.js';
|
|
7
|
+
export { SkillGenerator } from './skill/generator.js';
|
|
8
|
+
export { writeSkillFile, readSkillFile, listSkillFiles } from './skill/store.js';
|
|
9
|
+
export { signSkillFile, verifySignature } from './skill/signing.js';
|
|
10
|
+
export { validateImport, importSkillFile } from './skill/importer.js';
|
|
11
|
+
export { validateUrl, validateSkillFileUrls, resolveAndValidateUrl, resolveAndValidateSkillFileUrls } from './skill/ssrf.js';
|
|
12
|
+
export { replayEndpoint } from './replay/engine.js';
|
|
13
|
+
export { peek, read } from './read/index.js';
|
|
14
|
+
export { AuthManager, getMachineId } from './auth/manager.js';
|
|
15
|
+
export { parameterizePath, cleanFrameworkPath } from './capture/parameterize.js';
|
|
16
|
+
export { detectPagination } from './capture/pagination.js';
|
|
17
|
+
export { verifyEndpoints } from './capture/verifier.js';
|
|
18
|
+
export { IdleTracker } from './capture/idle.js';
|
|
19
|
+
export { isPathNoise } from './capture/filter.js';
|
|
20
|
+
export { searchSkills } from './skill/search.js';
|
|
21
|
+
export { createPlugin } from './plugin.js';
|
|
22
|
+
export { shannonEntropy, isLikelyToken, parseJwtClaims } from './capture/entropy.js';
|
|
23
|
+
export { isOAuthTokenRequest } from './capture/oauth-detector.js';
|
|
24
|
+
export { CaptureSession } from './capture/session.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;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C/H,OAAO,EAAE,mBAAmB,EAAkB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,cAAc,EAA+C,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SkillFile } from '../types.js';
|
|
2
|
+
import { type AntiBotSignal } from '../capture/anti-bot.js';
|
|
3
|
+
export interface InspectReport {
|
|
4
|
+
domain: string;
|
|
5
|
+
scanDuration: number;
|
|
6
|
+
totalRequests: number;
|
|
7
|
+
filteredRequests: number;
|
|
8
|
+
domBytes?: number;
|
|
9
|
+
endpoints: InspectEndpoint[];
|
|
10
|
+
antiBot: AntiBotSignal[];
|
|
11
|
+
summary: {
|
|
12
|
+
total: number;
|
|
13
|
+
replayable: number;
|
|
14
|
+
authRequired: number;
|
|
15
|
+
framework: string | null;
|
|
16
|
+
browserTokens: number;
|
|
17
|
+
replayTokens: number;
|
|
18
|
+
savingsPercent: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface InspectEndpoint {
|
|
22
|
+
method: string;
|
|
23
|
+
path: string;
|
|
24
|
+
tier: string;
|
|
25
|
+
auth: string;
|
|
26
|
+
responseBytes: number;
|
|
27
|
+
responseShape: {
|
|
28
|
+
type: string;
|
|
29
|
+
fields?: string[];
|
|
30
|
+
};
|
|
31
|
+
graphql: {
|
|
32
|
+
operations: string[];
|
|
33
|
+
} | null;
|
|
34
|
+
pagination: {
|
|
35
|
+
type: string;
|
|
36
|
+
paramName: string;
|
|
37
|
+
} | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build an inspect report from capture results.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildInspectReport(options: {
|
|
43
|
+
skills: Map<string, SkillFile>;
|
|
44
|
+
totalRequests: number;
|
|
45
|
+
filteredRequests: number;
|
|
46
|
+
duration: number;
|
|
47
|
+
domBytes?: number;
|
|
48
|
+
antiBotSignals: AntiBotSignal[];
|
|
49
|
+
targetDomain: string;
|
|
50
|
+
}): InspectReport;
|
|
51
|
+
export declare function formatInspectHuman(report: InspectReport): string;
|
|
52
|
+
export {};
|