@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
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/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,292 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Attachment Validator
|
|
3
|
-
* Validates file attachments for security and size constraints
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = path.dirname(__filename);
|
|
11
|
-
|
|
12
|
-
// Constants
|
|
13
|
-
const SIZE_LIMITS = {
|
|
14
|
-
content: 1024 * 1024, // 1MB for content mode
|
|
15
|
-
reference: Number.MAX_VALUE // No limit for reference mode (just metadata)
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const SIZE_WARNING_THRESHOLD = {
|
|
19
|
-
yellow: 100 * 1024, // 100KB
|
|
20
|
-
red: 1024 * 1024 // 1MB
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const BLOCKED_EXTENSIONS = [
|
|
24
|
-
'.exe', '.dll', '.so', '.dylib',
|
|
25
|
-
'.sh', '.bat', '.cmd', '.ps1',
|
|
26
|
-
'.app', '.dmg', '.deb', '.rpm',
|
|
27
|
-
'.msi', '.pkg', '.apk', '.jar'
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const SUPPORTED_TEXT_EXTENSIONS = [
|
|
31
|
-
'.txt', '.md', '.js', '.jsx', '.ts', '.tsx',
|
|
32
|
-
'.json', '.xml', '.html', '.css', '.scss',
|
|
33
|
-
'.py', '.java', '.cpp', '.c', '.h',
|
|
34
|
-
'.go', '.rs', '.rb', '.php', '.sh',
|
|
35
|
-
'.yml', '.yaml', '.toml', '.env',
|
|
36
|
-
'.log', '.sql', '.vue', '.svelte'
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
const SUPPORTED_IMAGE_EXTENSIONS = [
|
|
40
|
-
'.jpg', '.jpeg', '.png', '.gif',
|
|
41
|
-
'.webp', '.bmp', '.svg'
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const SUPPORTED_PDF_EXTENSIONS = ['.pdf'];
|
|
45
|
-
|
|
46
|
-
class AttachmentValidator {
|
|
47
|
-
constructor(config = {}, logger = null) {
|
|
48
|
-
this.config = config;
|
|
49
|
-
this.logger = logger;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Validate file size
|
|
54
|
-
* @param {number} size - File size in bytes
|
|
55
|
-
* @param {string} mode - 'content' or 'reference'
|
|
56
|
-
* @returns {Object} { valid: boolean, error?: string, warning?: string, level?: string }
|
|
57
|
-
*/
|
|
58
|
-
validateSize(size, mode = 'content') {
|
|
59
|
-
const limit = SIZE_LIMITS[mode];
|
|
60
|
-
|
|
61
|
-
if (size > limit) {
|
|
62
|
-
return {
|
|
63
|
-
valid: false,
|
|
64
|
-
error: `File size (${this.formatBytes(size)}) exceeds ${mode} mode limit (${this.formatBytes(limit)})`
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Check warning thresholds
|
|
69
|
-
if (mode === 'content') {
|
|
70
|
-
if (size > SIZE_WARNING_THRESHOLD.red) {
|
|
71
|
-
return {
|
|
72
|
-
valid: true,
|
|
73
|
-
warning: `This file is large (${this.formatBytes(size)}) and will consume significant tokens`,
|
|
74
|
-
level: 'red'
|
|
75
|
-
};
|
|
76
|
-
} else if (size > SIZE_WARNING_THRESHOLD.yellow) {
|
|
77
|
-
return {
|
|
78
|
-
valid: true,
|
|
79
|
-
warning: `This file is moderately large (${this.formatBytes(size)})`,
|
|
80
|
-
level: 'yellow'
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return { valid: true, level: 'green' };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Validate file type (block executables)
|
|
90
|
-
* @param {string} fileName - File name
|
|
91
|
-
* @returns {Object} { valid: boolean, error?: string }
|
|
92
|
-
*/
|
|
93
|
-
validateFileType(fileName) {
|
|
94
|
-
const ext = path.extname(fileName).toLowerCase();
|
|
95
|
-
|
|
96
|
-
if (this.isExecutable(fileName)) {
|
|
97
|
-
return {
|
|
98
|
-
valid: false,
|
|
99
|
-
error: `Executable files (${ext}) are not allowed for security reasons`
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return { valid: true };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Check if file is executable
|
|
108
|
-
* @param {string} fileName - File name
|
|
109
|
-
* @returns {boolean}
|
|
110
|
-
*/
|
|
111
|
-
isExecutable(fileName) {
|
|
112
|
-
const ext = path.extname(fileName).toLowerCase();
|
|
113
|
-
return BLOCKED_EXTENSIONS.includes(ext);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Validate file path (for reference mode)
|
|
118
|
-
* @param {string} filePath - File path
|
|
119
|
-
* @returns {Object} { valid: boolean, error?: string }
|
|
120
|
-
*/
|
|
121
|
-
validatePath(filePath) {
|
|
122
|
-
// Check for directory traversal attempts
|
|
123
|
-
const normalizedPath = path.normalize(filePath);
|
|
124
|
-
|
|
125
|
-
if (normalizedPath.includes('..')) {
|
|
126
|
-
return {
|
|
127
|
-
valid: false,
|
|
128
|
-
error: 'Directory traversal is not allowed'
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Check for absolute paths to system directories (Unix)
|
|
133
|
-
const systemDirs = ['/etc', '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/sys', '/proc'];
|
|
134
|
-
if (systemDirs.some(dir => normalizedPath.startsWith(dir))) {
|
|
135
|
-
return {
|
|
136
|
-
valid: false,
|
|
137
|
-
error: 'Access to system directories is not allowed'
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Check for Windows system directories
|
|
142
|
-
const winSystemDirs = ['C:\\Windows', 'C:\\Program Files', 'C:\\Program Files (x86)'];
|
|
143
|
-
if (winSystemDirs.some(dir => normalizedPath.startsWith(dir))) {
|
|
144
|
-
return {
|
|
145
|
-
valid: false,
|
|
146
|
-
error: 'Access to system directories is not allowed'
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return { valid: true };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Get content type from file extension
|
|
155
|
-
* @param {string} fileName - File name
|
|
156
|
-
* @returns {string} - 'text' | 'image' | 'pdf' | 'binary'
|
|
157
|
-
*/
|
|
158
|
-
getContentType(fileName) {
|
|
159
|
-
const ext = path.extname(fileName).toLowerCase();
|
|
160
|
-
|
|
161
|
-
if (SUPPORTED_TEXT_EXTENSIONS.includes(ext)) {
|
|
162
|
-
return 'text';
|
|
163
|
-
}
|
|
164
|
-
if (SUPPORTED_IMAGE_EXTENSIONS.includes(ext)) {
|
|
165
|
-
return 'image';
|
|
166
|
-
}
|
|
167
|
-
if (SUPPORTED_PDF_EXTENSIONS.includes(ext)) {
|
|
168
|
-
return 'pdf';
|
|
169
|
-
}
|
|
170
|
-
return 'binary';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Check if file type is supported
|
|
175
|
-
* @param {string} fileName - File name
|
|
176
|
-
* @returns {boolean}
|
|
177
|
-
*/
|
|
178
|
-
isSupported(fileName) {
|
|
179
|
-
const contentType = this.getContentType(fileName);
|
|
180
|
-
return contentType !== 'binary';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Validate all aspects of an attachment
|
|
185
|
-
* @param {Object} options
|
|
186
|
-
* @param {string} options.fileName - File name
|
|
187
|
-
* @param {number} options.size - File size in bytes
|
|
188
|
-
* @param {string} options.mode - 'content' or 'reference'
|
|
189
|
-
* @param {string} options.path - File path (for reference mode)
|
|
190
|
-
* @returns {Object} { valid: boolean, errors: string[], warnings: string[], sizeLevel: string }
|
|
191
|
-
*/
|
|
192
|
-
validate({ fileName, size, mode = 'content', path: filePath = null }) {
|
|
193
|
-
const errors = [];
|
|
194
|
-
const warnings = [];
|
|
195
|
-
let sizeLevel = 'green';
|
|
196
|
-
|
|
197
|
-
// Validate file type
|
|
198
|
-
const typeValidation = this.validateFileType(fileName);
|
|
199
|
-
if (!typeValidation.valid) {
|
|
200
|
-
errors.push(typeValidation.error);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Validate size
|
|
204
|
-
const sizeValidation = this.validateSize(size, mode);
|
|
205
|
-
if (!sizeValidation.valid) {
|
|
206
|
-
errors.push(sizeValidation.error);
|
|
207
|
-
} else if (sizeValidation.warning) {
|
|
208
|
-
warnings.push(sizeValidation.warning);
|
|
209
|
-
sizeLevel = sizeValidation.level;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Validate path (reference mode only)
|
|
213
|
-
if (mode === 'reference' && filePath) {
|
|
214
|
-
const pathValidation = this.validatePath(filePath);
|
|
215
|
-
if (!pathValidation.valid) {
|
|
216
|
-
errors.push(pathValidation.error);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Check if file type is supported
|
|
221
|
-
if (!this.isSupported(fileName)) {
|
|
222
|
-
warnings.push(`File type may not be fully supported (${path.extname(fileName)})`);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
valid: errors.length === 0,
|
|
227
|
-
errors,
|
|
228
|
-
warnings,
|
|
229
|
-
sizeLevel
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Format bytes to human-readable string
|
|
235
|
-
* @param {number} bytes
|
|
236
|
-
* @returns {string}
|
|
237
|
-
*/
|
|
238
|
-
formatBytes(bytes) {
|
|
239
|
-
if (bytes === 0) return '0 Bytes';
|
|
240
|
-
const k = 1024;
|
|
241
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
242
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
243
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Get MIME type from file extension
|
|
248
|
-
* @param {string} fileName - File name
|
|
249
|
-
* @returns {string}
|
|
250
|
-
*/
|
|
251
|
-
getMimeType(fileName) {
|
|
252
|
-
const ext = path.extname(fileName).toLowerCase();
|
|
253
|
-
const mimeTypes = {
|
|
254
|
-
// Text
|
|
255
|
-
'.txt': 'text/plain',
|
|
256
|
-
'.md': 'text/markdown',
|
|
257
|
-
'.json': 'application/json',
|
|
258
|
-
'.xml': 'application/xml',
|
|
259
|
-
'.html': 'text/html',
|
|
260
|
-
'.css': 'text/css',
|
|
261
|
-
'.js': 'text/javascript',
|
|
262
|
-
'.jsx': 'text/javascript',
|
|
263
|
-
'.ts': 'text/typescript',
|
|
264
|
-
'.tsx': 'text/typescript',
|
|
265
|
-
'.py': 'text/x-python',
|
|
266
|
-
'.java': 'text/x-java',
|
|
267
|
-
'.cpp': 'text/x-c++',
|
|
268
|
-
'.c': 'text/x-c',
|
|
269
|
-
'.yml': 'text/yaml',
|
|
270
|
-
'.yaml': 'text/yaml',
|
|
271
|
-
|
|
272
|
-
// Images
|
|
273
|
-
'.jpg': 'image/jpeg',
|
|
274
|
-
'.jpeg': 'image/jpeg',
|
|
275
|
-
'.png': 'image/png',
|
|
276
|
-
'.gif': 'image/gif',
|
|
277
|
-
'.webp': 'image/webp',
|
|
278
|
-
'.bmp': 'image/bmp',
|
|
279
|
-
'.svg': 'image/svg+xml',
|
|
280
|
-
|
|
281
|
-
// PDF
|
|
282
|
-
'.pdf': 'application/pdf',
|
|
283
|
-
|
|
284
|
-
// Default
|
|
285
|
-
'default': 'application/octet-stream'
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
return mimeTypes[ext] || mimeTypes['default'];
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export default AttachmentValidator;
|
|
1
|
+
const a0_0x138957=a0_0x2698;(function(_0x3b4ecc,_0xe3bb92){const _0x34640d=a0_0x2698,_0x4d799b=_0x3b4ecc();while(!![]){try{const _0x348625=-parseInt(_0x34640d(0xd7))/0x1+parseInt(_0x34640d(0xe3))/0x2+-parseInt(_0x34640d(0xe5))/0x3+-parseInt(_0x34640d(0xda))/0x4+-parseInt(_0x34640d(0xbb))/0x5+parseInt(_0x34640d(0xd3))/0x6+parseInt(_0x34640d(0xe4))/0x7*(parseInt(_0x34640d(0xff))/0x8);if(_0x348625===_0xe3bb92)break;else _0x4d799b['push'](_0x4d799b['shift']());}catch(_0xae0046){_0x4d799b['push'](_0x4d799b['shift']());}}}(a0_0x2d76,0x4b752));import a0_0x2ecf83 from'path';import{fileURLToPath}from'url';const __filename=fileURLToPath(import.meta.url),__dirname=a0_0x2ecf83['dirname'](__filename),SIZE_LIMITS={'content':0x400*0x400,'reference':Number[a0_0x138957(0xc4)]},SIZE_WARNING_THRESHOLD={'yellow':0x64*0x400,'red':0x400*0x400},BLOCKED_EXTENSIONS=['.exe','.dll',a0_0x138957(0xe9),'.dylib','.sh',a0_0x138957(0xf4),'.cmd','.ps1','.app','.dmg',a0_0x138957(0x100),a0_0x138957(0xfc),a0_0x138957(0xe0),'.pkg','.apk','.jar'],SUPPORTED_TEXT_EXTENSIONS=['.txt',a0_0x138957(0xec),a0_0x138957(0xc8),a0_0x138957(0xeb),'.ts',a0_0x138957(0x106),a0_0x138957(0xcd),'.xml','.html',a0_0x138957(0xc6),'.scss','.py','.java',a0_0x138957(0xcb),'.c','.h',a0_0x138957(0xdf),'.rs','.rb',a0_0x138957(0xf0),'.sh','.yml','.yaml','.toml',a0_0x138957(0xe2),'.log',a0_0x138957(0xbd),'.vue','.svelte'],SUPPORTED_IMAGE_EXTENSIONS=[a0_0x138957(0xdd),a0_0x138957(0xd0),'.png',a0_0x138957(0xc3),'.webp','.bmp',a0_0x138957(0xf7)],SUPPORTED_PDF_EXTENSIONS=['.pdf'];function a0_0x2d76(){const _0x48b940=['Dgv4Dc94lwmRkW','lMnWCa','qZPCuhjVz3jHBsbgAwXLCYaOEdG2kq','lMPZB24','yxbWBgLJyxrPB24VB2n0zxqTC3rYzwfT','Bg9N','lMPWzwC','yMLUyxj5','zxH0BMfTzq','ndCWodu2uhzAywzl','Dgv4Dc9ODg1S','CgrM','yxbWBgLJyxrPB24VANnVBG','mteWode1sxbgzu9A','zM9YBwf0qNL0zxm','AxnfEgvJDxrHyMXL','mtq3odKZnNjMAw1WyG','qwnJzxnZihrVihn5C3rLBsbKAxjLy3rVCMLLCYbPCYbUB3qGywXSB3DLza','BM9YBwfSAxPL','lMPWzW','rMLSzsbZAxPLicG','lMDV','lM1ZAq','C29Tzq','lMvUDG','nJGZoduWAfvSrhLv','ndiZmJi3DLb5zKDW','mtqXmJyWmvnfD3bPqG','DMfSAwrHDgvtAxPL','Bg9Nz2vY','yxbWBgLJyxrPB24VCgrM','lNnV','l3n5CW','lMPZEa','lM1K','ksbHCMuGBM90igfSBg93zwqGzM9YihnLy3vYAxr5ihjLyxnVBNm','Aw1Hz2uVCg5N','y29UzMLN','lNbOCa','EwvSBg93','ksbHBMqGD2LSBcbJB25ZDw1LihnPz25PzMLJyw50ihrVA2vUCW','l2v0yW','lMjHDa','CMvK','Dgv4Dc94lwm','lNn2zW','qZPCuhjVz3jHBsbgAwXLCW','D2fYBMLUzW','ChvZAa','Aw1Hz2u','lNjWBq','z3jLzw4','z2v0q29UDgvUDfr5Cgu','mtyWuezjrNv5','lMrLyG','Dg9mB3DLCKnHC2u','y29UDgvUDa','Dgv4Dc94lwPHDMe','AxntDxbWB3j0zwq','zMXVB3i','lNrZEa','Aw1Hz2uVz2LM','zxjYB3i','DMfSAwq','mtG0nty1nvfTEMfozG','Aw1Hz2uVANbLzW','lNnXBa','DMfSAwrHDgu','mcbcExrLCW','vgHPCYbMAwXLigLZig1VzgvYyxrLBhKGBgfYz2uGka','ksbLEgnLzwrZia','vgHPCYbMAwXLigLZigXHCMDLicG','lMDPzG','tufyx1zbtfvf','Aw5JBhvKzxm','lMnZCW','Dgv4Dc9WBgfPBG','lMPZ','z2v0twLTzvr5Cgu'];a0_0x2d76=function(){return _0x48b940;};return a0_0x2d76();}function a0_0x2698(_0x4ad044,_0x867ed6){_0x4ad044=_0x4ad044-0xb8;const _0x2d7674=a0_0x2d76();let _0x269888=_0x2d7674[_0x4ad044];if(a0_0x2698['SKSmbE']===undefined){var _0x4feb91=function(_0x1b047a){const _0x504098='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2ecf83='',_0x10a2c6='';for(let _0x4e6e6c=0x0,_0x3b02ca,_0x17a2f9,_0x2b212a=0x0;_0x17a2f9=_0x1b047a['charAt'](_0x2b212a++);~_0x17a2f9&&(_0x3b02ca=_0x4e6e6c%0x4?_0x3b02ca*0x40+_0x17a2f9:_0x17a2f9,_0x4e6e6c++%0x4)?_0x2ecf83+=String['fromCharCode'](0xff&_0x3b02ca>>(-0x2*_0x4e6e6c&0x6)):0x0){_0x17a2f9=_0x504098['indexOf'](_0x17a2f9);}for(let _0x11140d=0x0,_0x3970d4=_0x2ecf83['length'];_0x11140d<_0x3970d4;_0x11140d++){_0x10a2c6+='%'+('00'+_0x2ecf83['charCodeAt'](_0x11140d)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x10a2c6);};a0_0x2698['ASbMtl']=_0x4feb91,a0_0x2698['LyUsCz']={},a0_0x2698['SKSmbE']=!![];}const _0x2d0f8d=_0x2d7674[0x0],_0x57f8bb=_0x4ad044+_0x2d0f8d,_0x36e41e=a0_0x2698['LyUsCz'][_0x57f8bb];return!_0x36e41e?(_0x269888=a0_0x2698['ASbMtl'](_0x269888),a0_0x2698['LyUsCz'][_0x57f8bb]=_0x269888):_0x269888=_0x36e41e,_0x269888;}class AttachmentValidator{constructor(_0x10a2c6={},_0x4e6e6c=null){const _0x4e9205=a0_0x138957;this[_0x4e9205(0xef)]=_0x10a2c6,this[_0x4e9205(0xe7)]=_0x4e6e6c;}[a0_0x138957(0xe6)](_0x3b02ca,_0x17a2f9='content'){const _0x3f0495=a0_0x138957,_0x2b212a=SIZE_LIMITS[_0x17a2f9];if(_0x3b02ca>_0x2b212a)return{'valid':![],'error':_0x3f0495(0xde)+this[_0x3f0495(0xd8)](_0x3b02ca)+_0x3f0495(0xc1)+_0x17a2f9+'\x20mode\x20limit\x20('+this[_0x3f0495(0xd8)](_0x2b212a)+')'};if(_0x17a2f9==='content'){if(_0x3b02ca>SIZE_WARNING_THRESHOLD[_0x3f0495(0xf5)])return{'valid':!![],'warning':_0x3f0495(0xc2)+this[_0x3f0495(0xd8)](_0x3b02ca)+_0x3f0495(0xf2),'level':'red'};else{if(_0x3b02ca>SIZE_WARNING_THRESHOLD[_0x3f0495(0xf1)])return{'valid':!![],'warning':_0x3f0495(0xc0)+this['formatBytes'](_0x3b02ca)+')','level':_0x3f0495(0xf1)};}}return{'valid':!![],'level':_0x3f0495(0xfd)};}['validateFileType'](_0x11140d){const _0xcfd6eb=a0_0x138957,_0x3970d4=a0_0x2ecf83[_0xcfd6eb(0xd2)](_0x11140d)['toLowerCase']();if(this[_0xcfd6eb(0xd9)](_0x11140d))return{'valid':![],'error':'Executable\x20files\x20('+_0x3970d4+_0xcfd6eb(0xed)};return{'valid':!![]};}[a0_0x138957(0xd9)](_0x23f0ee){const _0x574544=a0_0x138957,_0x4c906e=a0_0x2ecf83[_0x574544(0xd2)](_0x23f0ee)['toLowerCase']();return BLOCKED_EXTENSIONS['includes'](_0x4c906e);}['validatePath'](_0x21b705){const _0x2d4953=a0_0x138957,_0xf284b5=a0_0x2ecf83[_0x2d4953(0xdc)](_0x21b705);if(_0xf284b5['includes']('..'))return{'valid':![],'error':'Directory\x20traversal\x20is\x20not\x20allowed'};const _0xc31d44=[_0x2d4953(0xf3),'/bin','/sbin','/usr/bin','/usr/sbin',_0x2d4953(0xea),'/proc'];if(_0xc31d44['some'](_0x1688ca=>_0xf284b5['startsWith'](_0x1688ca)))return{'valid':![],'error':_0x2d4953(0xdb)};const _0x2b9e9=['C:\x5cWindows',_0x2d4953(0xf8),_0x2d4953(0xcc)];if(_0x2b9e9[_0x2d4953(0xe1)](_0x5453ad=>_0xf284b5['startsWith'](_0x5453ad)))return{'valid':![],'error':'Access\x20to\x20system\x20directories\x20is\x20not\x20allowed'};return{'valid':!![]};}[a0_0x138957(0xfe)](_0x8ee899){const _0x14974d=a0_0x138957,_0x2a00af=a0_0x2ecf83[_0x14974d(0xd2)](_0x8ee899)[_0x14974d(0x101)]();if(SUPPORTED_TEXT_EXTENSIONS['includes'](_0x2a00af))return'text';if(SUPPORTED_IMAGE_EXTENSIONS[_0x14974d(0xc5)](_0x2a00af))return _0x14974d(0xfb);if(SUPPORTED_PDF_EXTENSIONS[_0x14974d(0xc5)](_0x2a00af))return _0x14974d(0xd5);return _0x14974d(0xd1);}[a0_0x138957(0x104)](_0x50be4a){const _0x5e04f9=a0_0x138957,_0x3f18a2=this[_0x5e04f9(0xfe)](_0x50be4a);return _0x3f18a2!=='binary';}[a0_0x138957(0xbe)]({fileName:_0x2cf3d0,size:_0x5df525,mode:mode=a0_0x138957(0x102),path:_0x13cf46=null}){const _0x176346=a0_0x138957,_0x32d68e=[],_0x1d2d2a=[];let _0x5e037d=_0x176346(0xfd);const _0x40c1d1=this['validateFileType'](_0x2cf3d0);!_0x40c1d1['valid']&&_0x32d68e[_0x176346(0xfa)](_0x40c1d1['error']);const _0x2bb4c9=this[_0x176346(0xe6)](_0x5df525,mode);if(!_0x2bb4c9['valid'])_0x32d68e['push'](_0x2bb4c9['error']);else _0x2bb4c9['warning']&&(_0x1d2d2a['push'](_0x2bb4c9[_0x176346(0xf9)]),_0x5e037d=_0x2bb4c9['level']);if(mode==='reference'&&_0x13cf46){const _0x3395b4=this['validatePath'](_0x13cf46);!_0x3395b4[_0x176346(0xba)]&&_0x32d68e[_0x176346(0xfa)](_0x3395b4[_0x176346(0xb9)]);}return!this[_0x176346(0x104)](_0x2cf3d0)&&_0x1d2d2a['push']('File\x20type\x20may\x20not\x20be\x20fully\x20supported\x20('+a0_0x2ecf83['extname'](_0x2cf3d0)+')'),{'valid':_0x32d68e['length']===0x0,'errors':_0x32d68e,'warnings':_0x1d2d2a,'sizeLevel':_0x5e037d};}[a0_0x138957(0xd8)](_0x2d4cc9){const _0x738bf3=a0_0x138957;if(_0x2d4cc9===0x0)return _0x738bf3(0xbf);const _0x2e52a4=0x400,_0x192e12=['Bytes','KB','MB','GB'],_0x8e911c=Math[_0x738bf3(0x105)](Math['log'](_0x2d4cc9)/Math[_0x738bf3(0xcf)](_0x2e52a4));return parseFloat((_0x2d4cc9/Math['pow'](_0x2e52a4,_0x8e911c))['toFixed'](0x2))+'\x20'+_0x192e12[_0x8e911c];}[a0_0x138957(0xc9)](_0x82972e){const _0x4feda6=a0_0x138957,_0xe20c76=a0_0x2ecf83['extname'](_0x82972e)[_0x4feda6(0x101)](),_0x549fa5={'.txt':_0x4feda6(0xc7),'.md':'text/markdown','.json':_0x4feda6(0xd6),'.xml':'application/xml','.html':_0x4feda6(0xd4),'.css':'text/css','.js':'text/javascript','.jsx':'text/javascript','.ts':'text/typescript','.tsx':'text/typescript','.py':'text/x-python','.java':_0x4feda6(0x103),'.cpp':_0x4feda6(0xca),'.c':_0x4feda6(0xf6),'.yml':'text/yaml','.yaml':'text/yaml','.jpg':_0x4feda6(0xbc),'.jpeg':_0x4feda6(0xbc),'.png':_0x4feda6(0xee),'.gif':_0x4feda6(0xb8),'.webp':'image/webp','.bmp':'image/bmp','.svg':'image/svg+xml','.pdf':_0x4feda6(0xe8),'default':_0x4feda6(0xce)};return _0x549fa5[_0xe20c76]||_0x549fa5['default'];}}export default AttachmentValidator;
|