@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
50 lines (49 loc) • 1.91 kB
TypeScript
import IFile from "./IFile";
import IFolder from "./IFolder";
/**
* Maximum number of files allowed in shared content
*/
export declare const MAX_SHARED_FILES = 100;
/**
* Maximum total size of shared content in bytes (1MB)
*/
export declare const MAX_SHARED_TOTAL_SIZE: number;
/**
* Allowed path patterns for shareable content.
* Only files within these paths can be shared.
*/
export declare const ALLOWED_SHARE_PATHS: RegExp[];
/**
* Dangerous code patterns that should not be allowed in shared TypeScript/JavaScript files.
* These patterns could enable code execution, file system access, or other security risks.
*/
export declare const DANGEROUS_CODE_PATTERNS: {
pattern: RegExp;
description: string;
}[];
export declare class BasicValidators {
private static contentMatcher;
/**
* Checks if a file's content contains dangerous code patterns that could pose security risks.
* This is used to validate shared TypeScript/JavaScript files.
* @param content The file content to check
* @returns An object with isUnsafe boolean and matched patterns, or undefined if safe
*/
static hasUnsafeCodePatterns(content: string): {
isUnsafe: boolean;
matches: string[];
} | undefined;
/**
* Validates if a file path is within the allowed shareable paths.
* @param filePath The storage-relative path to validate
* @returns true if the path is allowed for sharing, false otherwise
*/
static isPathAllowedForSharing(filePath: string): boolean;
static isFolderSharingValid(folder: IFolder, isChildFolder?: boolean, stats?: {
fileCount: number;
totalSize: number;
}): Promise<string | undefined>;
static isFileNameOKForSharing(fileName: string): boolean;
static isFolderNameOKForSharing(folderName: string): boolean;
static hasStrongLanguageContent(file: IFile): Promise<string>;
}