UNPKG

apx-toolkit

Version:

Automatically discover APIs and generate complete integration packages: code in 12 languages, TypeScript types, test suites, SDK packages, API documentation, mock servers, performance reports, and contract tests. Saves 2-4 weeks of work in seconds.

57 lines 2 kB
/** * Security utilities for APX Toolkit * Provides path sanitization and input validation */ /** * Sanitizes a file path to prevent directory traversal attacks * Ensures the resolved path stays within the base directory * * @param userPath - User-provided path (may be relative or contain ..) * @param baseDir - Base directory to resolve paths relative to * @returns Sanitized absolute path * @throws Error if path traversal is detected */ export declare function sanitizePath(userPath: string, baseDir: string): string; /** * Validates URL to ensure it's safe to request * * @param urlString - URL to validate * @param allowLocalhost - Whether to allow localhost URLs (default: false) * @returns Validated URL object * @throws Error if URL is invalid or unsafe */ export declare function validateURL(urlString: string, allowLocalhost?: boolean): URL; /** * Sanitizes log data to remove sensitive information * * @param data - Data object to sanitize * @param sensitiveKeys - Keys to redact (default: common sensitive keys) * @returns Sanitized data object */ export declare function sanitizeLogData(data: any, sensitiveKeys?: string[]): any; /** * Validates input size limits * * @param input - Input string to validate * @param maxSize - Maximum size in bytes * @param fieldName - Name of the field for error messages * @throws Error if input exceeds size limit */ export declare function validateInputSize(input: string, maxSize: number, fieldName: string): void; /** * Constants for input size limits */ export declare const INPUT_LIMITS: { readonly MAX_URL_LENGTH: 2048; readonly MAX_HEADER_SIZE: 8192; readonly MAX_BODY_SIZE: 10485760; readonly MAX_FILENAME_LENGTH: 255; }; /** * Sanitizes a filename to prevent directory traversal and invalid characters * * @param filename - Filename to sanitize * @returns Sanitized filename */ export declare function sanitizeFilename(filename: string): string; //# sourceMappingURL=security.d.ts.map