@cosmocoder/mcp-web-docs 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 +22 -0
- package/README.md +368 -0
- package/build/__mocks__/embeddings.d.ts +17 -0
- package/build/__mocks__/embeddings.js +66 -0
- package/build/__mocks__/embeddings.js.map +1 -0
- package/build/config.d.ts +44 -0
- package/build/config.js +158 -0
- package/build/config.js.map +1 -0
- package/build/config.test.d.ts +1 -0
- package/build/config.test.js +165 -0
- package/build/config.test.js.map +1 -0
- package/build/crawler/auth.d.ts +128 -0
- package/build/crawler/auth.js +546 -0
- package/build/crawler/auth.js.map +1 -0
- package/build/crawler/auth.test.d.ts +1 -0
- package/build/crawler/auth.test.js +174 -0
- package/build/crawler/auth.test.js.map +1 -0
- package/build/crawler/base.d.ts +24 -0
- package/build/crawler/base.js +149 -0
- package/build/crawler/base.js.map +1 -0
- package/build/crawler/base.test.d.ts +1 -0
- package/build/crawler/base.test.js +234 -0
- package/build/crawler/base.test.js.map +1 -0
- package/build/crawler/browser-config.d.ts +2 -0
- package/build/crawler/browser-config.js +29 -0
- package/build/crawler/browser-config.js.map +1 -0
- package/build/crawler/browser-config.test.d.ts +1 -0
- package/build/crawler/browser-config.test.js +56 -0
- package/build/crawler/browser-config.test.js.map +1 -0
- package/build/crawler/cheerio.d.ts +11 -0
- package/build/crawler/cheerio.js +134 -0
- package/build/crawler/cheerio.js.map +1 -0
- package/build/crawler/chromium.d.ts +21 -0
- package/build/crawler/chromium.js +596 -0
- package/build/crawler/chromium.js.map +1 -0
- package/build/crawler/content-extractor-types.d.ts +25 -0
- package/build/crawler/content-extractor-types.js +2 -0
- package/build/crawler/content-extractor-types.js.map +1 -0
- package/build/crawler/content-extractors.d.ts +9 -0
- package/build/crawler/content-extractors.js +9 -0
- package/build/crawler/content-extractors.js.map +1 -0
- package/build/crawler/content-utils.d.ts +2 -0
- package/build/crawler/content-utils.js +22 -0
- package/build/crawler/content-utils.js.map +1 -0
- package/build/crawler/content-utils.test.d.ts +1 -0
- package/build/crawler/content-utils.test.js +99 -0
- package/build/crawler/content-utils.test.js.map +1 -0
- package/build/crawler/crawlee-crawler.d.ts +63 -0
- package/build/crawler/crawlee-crawler.js +342 -0
- package/build/crawler/crawlee-crawler.js.map +1 -0
- package/build/crawler/crawlee-crawler.test.d.ts +1 -0
- package/build/crawler/crawlee-crawler.test.js +280 -0
- package/build/crawler/crawlee-crawler.test.js.map +1 -0
- package/build/crawler/default-extractor.d.ts +4 -0
- package/build/crawler/default-extractor.js +26 -0
- package/build/crawler/default-extractor.js.map +1 -0
- package/build/crawler/default-extractor.test.d.ts +1 -0
- package/build/crawler/default-extractor.test.js +200 -0
- package/build/crawler/default-extractor.test.js.map +1 -0
- package/build/crawler/default.d.ts +11 -0
- package/build/crawler/default.js +138 -0
- package/build/crawler/default.js.map +1 -0
- package/build/crawler/docs-crawler.d.ts +26 -0
- package/build/crawler/docs-crawler.js +97 -0
- package/build/crawler/docs-crawler.js.map +1 -0
- package/build/crawler/docs-crawler.test.d.ts +1 -0
- package/build/crawler/docs-crawler.test.js +185 -0
- package/build/crawler/docs-crawler.test.js.map +1 -0
- package/build/crawler/factory.d.ts +6 -0
- package/build/crawler/factory.js +83 -0
- package/build/crawler/factory.js.map +1 -0
- package/build/crawler/github-pages-extractor.d.ts +4 -0
- package/build/crawler/github-pages-extractor.js +33 -0
- package/build/crawler/github-pages-extractor.js.map +1 -0
- package/build/crawler/github-pages-extractor.test.d.ts +1 -0
- package/build/crawler/github-pages-extractor.test.js +184 -0
- package/build/crawler/github-pages-extractor.test.js.map +1 -0
- package/build/crawler/github.d.ts +20 -0
- package/build/crawler/github.js +181 -0
- package/build/crawler/github.js.map +1 -0
- package/build/crawler/github.test.d.ts +1 -0
- package/build/crawler/github.test.js +326 -0
- package/build/crawler/github.test.js.map +1 -0
- package/build/crawler/puppeteer.d.ts +16 -0
- package/build/crawler/puppeteer.js +191 -0
- package/build/crawler/puppeteer.js.map +1 -0
- package/build/crawler/queue-manager.d.ts +43 -0
- package/build/crawler/queue-manager.js +169 -0
- package/build/crawler/queue-manager.js.map +1 -0
- package/build/crawler/queue-manager.test.d.ts +1 -0
- package/build/crawler/queue-manager.test.js +509 -0
- package/build/crawler/queue-manager.test.js.map +1 -0
- package/build/crawler/site-rules.d.ts +11 -0
- package/build/crawler/site-rules.js +104 -0
- package/build/crawler/site-rules.js.map +1 -0
- package/build/crawler/site-rules.test.d.ts +1 -0
- package/build/crawler/site-rules.test.js +139 -0
- package/build/crawler/site-rules.test.js.map +1 -0
- package/build/crawler/storybook-extractor.d.ts +34 -0
- package/build/crawler/storybook-extractor.js +767 -0
- package/build/crawler/storybook-extractor.js.map +1 -0
- package/build/crawler/storybook-extractor.test.d.ts +1 -0
- package/build/crawler/storybook-extractor.test.js +491 -0
- package/build/crawler/storybook-extractor.test.js.map +1 -0
- package/build/embeddings/fastembed.d.ts +25 -0
- package/build/embeddings/fastembed.js +188 -0
- package/build/embeddings/fastembed.js.map +1 -0
- package/build/embeddings/fastembed.test.d.ts +1 -0
- package/build/embeddings/fastembed.test.js +307 -0
- package/build/embeddings/fastembed.test.js.map +1 -0
- package/build/embeddings/openai.d.ts +8 -0
- package/build/embeddings/openai.js +56 -0
- package/build/embeddings/openai.js.map +1 -0
- package/build/embeddings/types.d.ts +4 -0
- package/build/embeddings/types.js +2 -0
- package/build/embeddings/types.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +1007 -0
- package/build/index.js.map +1 -0
- package/build/index.test.d.ts +1 -0
- package/build/index.test.js +364 -0
- package/build/index.test.js.map +1 -0
- package/build/indexing/queue-manager.d.ts +36 -0
- package/build/indexing/queue-manager.js +86 -0
- package/build/indexing/queue-manager.js.map +1 -0
- package/build/indexing/queue-manager.test.d.ts +1 -0
- package/build/indexing/queue-manager.test.js +257 -0
- package/build/indexing/queue-manager.test.js.map +1 -0
- package/build/indexing/status.d.ts +39 -0
- package/build/indexing/status.js +207 -0
- package/build/indexing/status.js.map +1 -0
- package/build/indexing/status.test.d.ts +1 -0
- package/build/indexing/status.test.js +246 -0
- package/build/indexing/status.test.js.map +1 -0
- package/build/processor/content.d.ts +16 -0
- package/build/processor/content.js +286 -0
- package/build/processor/content.js.map +1 -0
- package/build/processor/content.test.d.ts +1 -0
- package/build/processor/content.test.js +369 -0
- package/build/processor/content.test.js.map +1 -0
- package/build/processor/markdown.d.ts +11 -0
- package/build/processor/markdown.js +256 -0
- package/build/processor/markdown.js.map +1 -0
- package/build/processor/markdown.test.d.ts +1 -0
- package/build/processor/markdown.test.js +312 -0
- package/build/processor/markdown.test.js.map +1 -0
- package/build/processor/metadata-parser.d.ts +37 -0
- package/build/processor/metadata-parser.js +245 -0
- package/build/processor/metadata-parser.js.map +1 -0
- package/build/processor/metadata-parser.test.d.ts +1 -0
- package/build/processor/metadata-parser.test.js +357 -0
- package/build/processor/metadata-parser.test.js.map +1 -0
- package/build/processor/processor.d.ts +8 -0
- package/build/processor/processor.js +190 -0
- package/build/processor/processor.js.map +1 -0
- package/build/processor/processor.test.d.ts +1 -0
- package/build/processor/processor.test.js +357 -0
- package/build/processor/processor.test.js.map +1 -0
- package/build/rag/cache.d.ts +10 -0
- package/build/rag/cache.js +10 -0
- package/build/rag/cache.js.map +1 -0
- package/build/rag/code-generator.d.ts +11 -0
- package/build/rag/code-generator.js +30 -0
- package/build/rag/code-generator.js.map +1 -0
- package/build/rag/context-assembler.d.ts +23 -0
- package/build/rag/context-assembler.js +113 -0
- package/build/rag/context-assembler.js.map +1 -0
- package/build/rag/docs-search.d.ts +55 -0
- package/build/rag/docs-search.js +380 -0
- package/build/rag/docs-search.js.map +1 -0
- package/build/rag/pipeline.d.ts +26 -0
- package/build/rag/pipeline.js +91 -0
- package/build/rag/pipeline.js.map +1 -0
- package/build/rag/query-processor.d.ts +14 -0
- package/build/rag/query-processor.js +57 -0
- package/build/rag/query-processor.js.map +1 -0
- package/build/rag/reranker.d.ts +55 -0
- package/build/rag/reranker.js +210 -0
- package/build/rag/reranker.js.map +1 -0
- package/build/rag/response-generator.d.ts +20 -0
- package/build/rag/response-generator.js +101 -0
- package/build/rag/response-generator.js.map +1 -0
- package/build/rag/retriever.d.ts +19 -0
- package/build/rag/retriever.js +111 -0
- package/build/rag/retriever.js.map +1 -0
- package/build/rag/validator.d.ts +22 -0
- package/build/rag/validator.js +128 -0
- package/build/rag/validator.js.map +1 -0
- package/build/rag/version-manager.d.ts +23 -0
- package/build/rag/version-manager.js +98 -0
- package/build/rag/version-manager.js.map +1 -0
- package/build/setupTests.d.ts +4 -0
- package/build/setupTests.js +50 -0
- package/build/setupTests.js.map +1 -0
- package/build/storage/storage.d.ts +38 -0
- package/build/storage/storage.js +700 -0
- package/build/storage/storage.js.map +1 -0
- package/build/storage/storage.test.d.ts +1 -0
- package/build/storage/storage.test.js +338 -0
- package/build/storage/storage.test.js.map +1 -0
- package/build/types/rag.d.ts +27 -0
- package/build/types/rag.js +2 -0
- package/build/types/rag.js.map +1 -0
- package/build/types.d.ts +120 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/util/content-utils.d.ts +31 -0
- package/build/util/content-utils.js +120 -0
- package/build/util/content-utils.js.map +1 -0
- package/build/util/content.d.ts +1 -0
- package/build/util/content.js +16 -0
- package/build/util/content.js.map +1 -0
- package/build/util/docs.d.ts +1 -0
- package/build/util/docs.js +26 -0
- package/build/util/docs.js.map +1 -0
- package/build/util/docs.test.d.ts +1 -0
- package/build/util/docs.test.js +49 -0
- package/build/util/docs.test.js.map +1 -0
- package/build/util/favicon.d.ts +6 -0
- package/build/util/favicon.js +88 -0
- package/build/util/favicon.js.map +1 -0
- package/build/util/favicon.test.d.ts +1 -0
- package/build/util/favicon.test.js +140 -0
- package/build/util/favicon.test.js.map +1 -0
- package/build/util/logger.d.ts +17 -0
- package/build/util/logger.js +72 -0
- package/build/util/logger.js.map +1 -0
- package/build/util/logger.test.d.ts +1 -0
- package/build/util/logger.test.js +46 -0
- package/build/util/logger.test.js.map +1 -0
- package/build/util/security.d.ts +312 -0
- package/build/util/security.js +719 -0
- package/build/util/security.js.map +1 -0
- package/build/util/security.test.d.ts +1 -0
- package/build/util/security.test.js +524 -0
- package/build/util/security.test.js.map +1 -0
- package/build/util/site-detector.d.ts +22 -0
- package/build/util/site-detector.js +42 -0
- package/build/util/site-detector.js.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { logger } from './logger.js';
|
|
2
|
+
describe('Logger', () => {
|
|
3
|
+
describe('API surface', () => {
|
|
4
|
+
it.each(['debug', 'info', 'warn', 'error'])('should have %s method', (method) => {
|
|
5
|
+
expect(typeof logger[method]).toBe('function');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
describe('methods do not throw', () => {
|
|
9
|
+
it.each(['debug', 'info', 'warn', 'error'])('should not throw when calling %s with string', (method) => {
|
|
10
|
+
expect(() => logger[method]('Test message')).not.toThrow();
|
|
11
|
+
});
|
|
12
|
+
it('should not throw when calling with multiple arguments', () => {
|
|
13
|
+
expect(() => logger.error('Multiple', 'arguments', 123, true)).not.toThrow();
|
|
14
|
+
});
|
|
15
|
+
it('should not throw when calling with Error object', () => {
|
|
16
|
+
const error = new Error('Test error');
|
|
17
|
+
expect(() => logger.error('Got error:', error)).not.toThrow();
|
|
18
|
+
});
|
|
19
|
+
it('should not throw when calling with nested object', () => {
|
|
20
|
+
const obj = { nested: { deep: { value: true } } };
|
|
21
|
+
expect(() => logger.info('Object:', obj)).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
it('should not throw when calling with circular reference', () => {
|
|
24
|
+
const circular = {};
|
|
25
|
+
circular.self = circular;
|
|
26
|
+
expect(() => logger.error('Circular:', circular)).not.toThrow();
|
|
27
|
+
});
|
|
28
|
+
it('should not throw when calling with null/undefined', () => {
|
|
29
|
+
expect(() => logger.info('Values:', null, undefined)).not.toThrow();
|
|
30
|
+
});
|
|
31
|
+
it('should not throw when calling with empty string', () => {
|
|
32
|
+
expect(() => logger.info('')).not.toThrow();
|
|
33
|
+
});
|
|
34
|
+
it('should not throw when calling with unicode', () => {
|
|
35
|
+
expect(() => logger.info('Unicode: 你好世界 🌍')).not.toThrow();
|
|
36
|
+
});
|
|
37
|
+
it('should not throw when calling with special characters', () => {
|
|
38
|
+
expect(() => logger.info('Special: <>&"\' \n\t')).not.toThrow();
|
|
39
|
+
});
|
|
40
|
+
it('should not throw when calling with very long message', () => {
|
|
41
|
+
const longMessage = 'a'.repeat(10000);
|
|
42
|
+
expect(() => logger.info(longMessage)).not.toThrow();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=logger.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.test.js","sourceRoot":"","sources":["../../src/util/logger.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security utilities for mcp-web-docs
|
|
3
|
+
* Handles encryption, input sanitization, and validation
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Encrypt sensitive data using AES-256-GCM
|
|
8
|
+
* @param plaintext - Data to encrypt
|
|
9
|
+
* @returns Encrypted data as base64 string with embedded IV, salt, and auth tag
|
|
10
|
+
*/
|
|
11
|
+
export declare function encryptData(plaintext: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Decrypt data encrypted with encryptData
|
|
14
|
+
* @param encryptedData - Base64 encoded encrypted data
|
|
15
|
+
* @returns Decrypted plaintext
|
|
16
|
+
*/
|
|
17
|
+
export declare function decryptData(encryptedData: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Escape special characters for LanceDB filter expressions
|
|
20
|
+
* Prevents SQL/filter injection attacks
|
|
21
|
+
* @param value - User-provided value to escape
|
|
22
|
+
* @returns Escaped value safe for use in filter expressions
|
|
23
|
+
*/
|
|
24
|
+
export declare function escapeFilterValue(value: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Validate and sanitize a URL for safe usage
|
|
27
|
+
* Prevents SSRF attacks by blocking private/internal networks
|
|
28
|
+
* @param urlString - URL to validate
|
|
29
|
+
* @returns Validated URL object
|
|
30
|
+
* @throws Error if URL is invalid or points to private network
|
|
31
|
+
*/
|
|
32
|
+
export declare function validatePublicUrl(urlString: string): URL;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a regex pattern is safe (not vulnerable to ReDoS)
|
|
35
|
+
* Uses safe-regex2 from https://github.com/fastify/safe-regex2
|
|
36
|
+
* @param pattern - Regex pattern string to check
|
|
37
|
+
* @returns true if pattern is safe, false if potentially dangerous
|
|
38
|
+
*/
|
|
39
|
+
export declare function isSafeRegex(pattern: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Create a safe RegExp from user input with ReDoS protection
|
|
42
|
+
* @param pattern - User-provided regex pattern
|
|
43
|
+
* @param flags - Optional regex flags
|
|
44
|
+
* @returns RegExp object
|
|
45
|
+
* @throws Error if pattern is unsafe or invalid
|
|
46
|
+
*/
|
|
47
|
+
export declare function createSafeRegex(pattern: string, flags?: string): RegExp;
|
|
48
|
+
/**
|
|
49
|
+
* Schema for browser storage state (cookies and localStorage)
|
|
50
|
+
*/
|
|
51
|
+
export declare const StorageStateSchema: z.ZodObject<{
|
|
52
|
+
cookies: z.ZodArray<z.ZodObject<{
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
value: z.ZodString;
|
|
55
|
+
domain: z.ZodString;
|
|
56
|
+
path: z.ZodString;
|
|
57
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
Strict: "Strict";
|
|
62
|
+
Lax: "Lax";
|
|
63
|
+
None: "None";
|
|
64
|
+
}>>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
origins: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
67
|
+
origin: z.ZodString;
|
|
68
|
+
localStorage: z.ZodArray<z.ZodObject<{
|
|
69
|
+
name: z.ZodString;
|
|
70
|
+
value: z.ZodString;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
}, z.core.$strip>>>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type ValidatedStorageState = z.infer<typeof StorageStateSchema>;
|
|
75
|
+
/**
|
|
76
|
+
* Schema for stored session data
|
|
77
|
+
*/
|
|
78
|
+
export declare const StoredSessionSchema: z.ZodObject<{
|
|
79
|
+
domain: z.ZodString;
|
|
80
|
+
storageState: z.ZodString;
|
|
81
|
+
createdAt: z.ZodString;
|
|
82
|
+
browser: z.ZodEnum<{
|
|
83
|
+
chromium: "chromium";
|
|
84
|
+
chrome: "chrome";
|
|
85
|
+
firefox: "firefox";
|
|
86
|
+
webkit: "webkit";
|
|
87
|
+
edge: "edge";
|
|
88
|
+
}>;
|
|
89
|
+
version: z.ZodLiteral<2>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
/** Validated stored session type */
|
|
92
|
+
export type ValidatedStoredSession = z.infer<typeof StoredSessionSchema>;
|
|
93
|
+
/**
|
|
94
|
+
* Schema for GitHub API file response
|
|
95
|
+
*/
|
|
96
|
+
export declare const GitHubFileSchema: z.ZodObject<{
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
type: z.ZodEnum<{
|
|
99
|
+
file: "file";
|
|
100
|
+
dir: "dir";
|
|
101
|
+
}>;
|
|
102
|
+
url: z.ZodString;
|
|
103
|
+
content: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export declare const GitHubFilesArraySchema: z.ZodArray<z.ZodObject<{
|
|
106
|
+
path: z.ZodString;
|
|
107
|
+
type: z.ZodEnum<{
|
|
108
|
+
file: "file";
|
|
109
|
+
dir: "dir";
|
|
110
|
+
}>;
|
|
111
|
+
url: z.ZodString;
|
|
112
|
+
content: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
export type ValidatedGitHubFile = z.infer<typeof GitHubFileSchema>;
|
|
115
|
+
/**
|
|
116
|
+
* Safely parse JSON with schema validation
|
|
117
|
+
* @param jsonString - JSON string to parse
|
|
118
|
+
* @param schema - Zod schema to validate against
|
|
119
|
+
* @returns Validated and typed data
|
|
120
|
+
* @throws Error if JSON is invalid or doesn't match schema
|
|
121
|
+
*/
|
|
122
|
+
export declare function safeJsonParse<T>(jsonString: string, schema: z.ZodSchema<T>): T;
|
|
123
|
+
/**
|
|
124
|
+
* Generate a secure hash for cache keys or identifiers
|
|
125
|
+
* @param input - String to hash
|
|
126
|
+
* @returns SHA-256 hash as hex string
|
|
127
|
+
*/
|
|
128
|
+
export declare function secureHash(input: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Schema for add_documentation tool arguments
|
|
131
|
+
*/
|
|
132
|
+
export declare const AddDocumentationArgsSchema: z.ZodObject<{
|
|
133
|
+
url: z.ZodString;
|
|
134
|
+
title: z.ZodOptional<z.ZodString>;
|
|
135
|
+
id: z.ZodOptional<z.ZodString>;
|
|
136
|
+
pathPrefix: z.ZodOptional<z.ZodString>;
|
|
137
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
requiresAuth: z.ZodOptional<z.ZodBoolean>;
|
|
139
|
+
browser: z.ZodOptional<z.ZodEnum<{
|
|
140
|
+
chromium: "chromium";
|
|
141
|
+
chrome: "chrome";
|
|
142
|
+
firefox: "firefox";
|
|
143
|
+
webkit: "webkit";
|
|
144
|
+
edge: "edge";
|
|
145
|
+
}>>;
|
|
146
|
+
loginUrl: z.ZodOptional<z.ZodString>;
|
|
147
|
+
loginSuccessPattern: z.ZodOptional<z.ZodString>;
|
|
148
|
+
loginSuccessSelector: z.ZodOptional<z.ZodString>;
|
|
149
|
+
loginTimeoutSecs: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type AddDocumentationArgs = z.infer<typeof AddDocumentationArgsSchema>;
|
|
153
|
+
/**
|
|
154
|
+
* Schema for authenticate tool arguments
|
|
155
|
+
*/
|
|
156
|
+
export declare const AuthenticateArgsSchema: z.ZodObject<{
|
|
157
|
+
url: z.ZodString;
|
|
158
|
+
browser: z.ZodOptional<z.ZodEnum<{
|
|
159
|
+
chromium: "chromium";
|
|
160
|
+
chrome: "chrome";
|
|
161
|
+
firefox: "firefox";
|
|
162
|
+
webkit: "webkit";
|
|
163
|
+
edge: "edge";
|
|
164
|
+
}>>;
|
|
165
|
+
loginUrl: z.ZodOptional<z.ZodString>;
|
|
166
|
+
loginTimeoutSecs: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
export type AuthenticateArgs = z.infer<typeof AuthenticateArgsSchema>;
|
|
169
|
+
/**
|
|
170
|
+
* Schema for clear_auth tool arguments
|
|
171
|
+
*/
|
|
172
|
+
export declare const ClearAuthArgsSchema: z.ZodObject<{
|
|
173
|
+
url: z.ZodString;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type ClearAuthArgs = z.infer<typeof ClearAuthArgsSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Schema for search_documentation tool arguments
|
|
178
|
+
*/
|
|
179
|
+
export declare const SearchDocumentationArgsSchema: z.ZodObject<{
|
|
180
|
+
query: z.ZodString;
|
|
181
|
+
url: z.ZodOptional<z.ZodString>;
|
|
182
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type SearchDocumentationArgs = z.infer<typeof SearchDocumentationArgsSchema>;
|
|
185
|
+
/**
|
|
186
|
+
* Schema for reindex_documentation tool arguments
|
|
187
|
+
*/
|
|
188
|
+
export declare const ReindexDocumentationArgsSchema: z.ZodObject<{
|
|
189
|
+
url: z.ZodString;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
export type ReindexDocumentationArgs = z.infer<typeof ReindexDocumentationArgsSchema>;
|
|
192
|
+
/**
|
|
193
|
+
* Schema for delete_documentation tool arguments
|
|
194
|
+
*/
|
|
195
|
+
export declare const DeleteDocumentationArgsSchema: z.ZodObject<{
|
|
196
|
+
url: z.ZodString;
|
|
197
|
+
clearAuth: z.ZodOptional<z.ZodBoolean>;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
export type DeleteDocumentationArgs = z.infer<typeof DeleteDocumentationArgsSchema>;
|
|
200
|
+
/**
|
|
201
|
+
* Validate MCP tool arguments against a schema
|
|
202
|
+
* @param args - Raw arguments from MCP request
|
|
203
|
+
* @param schema - Zod schema to validate against
|
|
204
|
+
* @returns Validated and typed arguments
|
|
205
|
+
* @throws Error with user-friendly message if validation fails
|
|
206
|
+
*/
|
|
207
|
+
export declare function validateToolArgs<T>(args: Record<string, unknown> | undefined, schema: z.ZodSchema<T>): T;
|
|
208
|
+
/**
|
|
209
|
+
* Sanitize an error message for safe return to clients.
|
|
210
|
+
* Removes sensitive information like file paths, credentials, and system details.
|
|
211
|
+
* @param error - The error to sanitize
|
|
212
|
+
* @returns A safe error message
|
|
213
|
+
*/
|
|
214
|
+
export declare function sanitizeErrorMessage(error: unknown): string;
|
|
215
|
+
/**
|
|
216
|
+
* Redact sensitive information from log messages.
|
|
217
|
+
* Use this before logging any data that might contain credentials.
|
|
218
|
+
* @param data - The data to sanitize for logging
|
|
219
|
+
* @returns Sanitized string safe for logging
|
|
220
|
+
*/
|
|
221
|
+
export declare function redactForLogging(data: unknown): string;
|
|
222
|
+
/**
|
|
223
|
+
* Result of prompt injection detection
|
|
224
|
+
*/
|
|
225
|
+
export interface PromptInjectionResult {
|
|
226
|
+
/** Whether any injection patterns were detected */
|
|
227
|
+
hasInjection: boolean;
|
|
228
|
+
/** Highest severity level found */
|
|
229
|
+
maxSeverity: 'high' | 'medium' | 'low' | 'none';
|
|
230
|
+
/** List of detected patterns */
|
|
231
|
+
detections: Array<{
|
|
232
|
+
severity: 'high' | 'medium' | 'low';
|
|
233
|
+
description: string;
|
|
234
|
+
match: string;
|
|
235
|
+
}>;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Detect potential prompt injection patterns in content using vard.
|
|
239
|
+
* Uses the vard package for robust, performant detection of:
|
|
240
|
+
* - Instruction overrides ("ignore all previous instructions")
|
|
241
|
+
* - Role manipulation ("you are now a...")
|
|
242
|
+
* - Delimiter injection ([SYSTEM], <|im_start|>)
|
|
243
|
+
* - System prompt leaks ("reveal your instructions")
|
|
244
|
+
* - Encoding attacks (base64, homoglyphs, unicode escapes)
|
|
245
|
+
*
|
|
246
|
+
* NOTE: Code blocks are stripped before detection to avoid false positives
|
|
247
|
+
* from code examples (especially common in AI/LLM documentation).
|
|
248
|
+
*
|
|
249
|
+
* @param content - The content to scan
|
|
250
|
+
* @returns Detection results with severity and matched patterns
|
|
251
|
+
* @see https://github.com/andersmyrmel/vard
|
|
252
|
+
*/
|
|
253
|
+
export declare function detectPromptInjection(content: string): PromptInjectionResult;
|
|
254
|
+
/**
|
|
255
|
+
* Marker to wrap content indicating it's from an external untrusted source.
|
|
256
|
+
* This helps AI assistants understand the content should be treated with caution.
|
|
257
|
+
*/
|
|
258
|
+
export declare const EXTERNAL_CONTENT_MARKER: {
|
|
259
|
+
prefix: string;
|
|
260
|
+
suffix: string;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Wrap content with external source markers to indicate it's from an untrusted source.
|
|
264
|
+
* @param content - The content to wrap
|
|
265
|
+
* @param source - Optional source URL for attribution
|
|
266
|
+
* @returns Content wrapped with safety markers
|
|
267
|
+
*/
|
|
268
|
+
export declare function wrapExternalContent(content: string, source?: string): string;
|
|
269
|
+
/**
|
|
270
|
+
* Add injection warnings to content if prompt injection patterns are detected.
|
|
271
|
+
* @param content - The content to check
|
|
272
|
+
* @param detectionResult - Result from detectPromptInjection
|
|
273
|
+
* @returns Content with warnings prepended if injections detected
|
|
274
|
+
*/
|
|
275
|
+
export declare function addInjectionWarnings(content: string, detectionResult: PromptInjectionResult): string;
|
|
276
|
+
/**
|
|
277
|
+
* Result of login page detection
|
|
278
|
+
*/
|
|
279
|
+
export interface LoginPageDetectionResult {
|
|
280
|
+
/** Whether this appears to be a login page */
|
|
281
|
+
isLoginPage: boolean;
|
|
282
|
+
/** Confidence level (0-1) based on number of indicators matched */
|
|
283
|
+
confidence: number;
|
|
284
|
+
/** Detected reasons (for logging/debugging) */
|
|
285
|
+
reasons: string[];
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Detect if a URL looks like a login/authentication page.
|
|
289
|
+
* @param url - The URL to check
|
|
290
|
+
* @returns Whether the URL pattern suggests a login page
|
|
291
|
+
*/
|
|
292
|
+
export declare function isLoginPageUrl(url: string): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Detect if page content suggests a login page.
|
|
295
|
+
* This is a heuristic check - it counts how many login-related
|
|
296
|
+
* indicators are present in the content.
|
|
297
|
+
*
|
|
298
|
+
* @param content - The page's text content
|
|
299
|
+
* @param url - The page URL (for additional URL-based detection)
|
|
300
|
+
* @returns Detection result with confidence score
|
|
301
|
+
*/
|
|
302
|
+
export declare function detectLoginPage(content: string, url: string): LoginPageDetectionResult;
|
|
303
|
+
/**
|
|
304
|
+
* Error thrown when authentication session has expired.
|
|
305
|
+
* This allows callers to handle session expiration gracefully.
|
|
306
|
+
*/
|
|
307
|
+
export declare class SessionExpiredError extends Error {
|
|
308
|
+
readonly detectedUrl: string;
|
|
309
|
+
readonly expectedUrl: string;
|
|
310
|
+
readonly detectionResult: LoginPageDetectionResult;
|
|
311
|
+
constructor(message: string, expectedUrl: string, detectedUrl: string, detectionResult: LoginPageDetectionResult);
|
|
312
|
+
}
|