UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

126 lines (125 loc) 5.67 kB
import IStorage from "./../storage/IStorage"; import ILocalUtilities, { Platform } from "../core/ILocalUtilities"; import IConversionSettings from "../core/IConversionSettings"; /** * Ports that should never be used for MCTools HTTP servers. * * This list includes: * 1. Browser-blocked ports - Chrome/Firefox/Safari block these for security (ERR_UNSAFE_PORT) * See: https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc * * 2. Security-sensitive service ports - commonly targeted for attacks or conflicts: * - Database ports (Redis, etc.) - targeted for data theft * - IRC ports - used by botnets and C&C servers * - Other commonly exploited services */ export declare const UNSAFE_PORTS: ReadonlySet<number>; export default class LocalUtilities implements ILocalUtilities { #private; /** * Resolves the root directory of the @minecraft/bedrock-schemas package. * Forms and schemas are served directly from this package at runtime * rather than being copied into the build output. */ static get bedrockSchemasRoot(): string | undefined; /** * Get the data directory override from MCTOOLS_DATA_DIR environment variable. * This is primarily used for Docker containers where data should be stored * in a volume-mounted directory like /data. */ static get dataDirectoryOverride(): string | undefined; /** * Check if MCTOOLS_I_ACCEPT_EULA_AT_MINECRAFTDOTNETSLASHEULA environment variable is set to "true". * Used for non-interactive EULA acceptance in Docker containers. * The long name is intentional to ensure users explicitly acknowledge the EULA. */ static get eulaAcceptedViaEnvironment(): boolean; get basePathAdjust(): string | undefined; set basePathAdjust(pathAdjust: string | undefined); get platform(): Platform; get productNameSeed(): string; setProductNameSeed(newSeed: string): void; get userDataPath(): string; get localAppDataPath(): string; get roamingAppDataPath(): string; get localReleaseServerLogPath(): string; get localPreviewServerLogPath(): string; get minecraftPath(): string; get minecraftPreviewPath(): string; get minecraftUwpPath(): string; get minecraftPreviewUwpPath(): string; get testWorkingPath(): string; get cliWorkingPath(): string; get serverWorkingPath(): string; get worldsWorkingPath(): string; get serversPath(): string; get sourceServersPath(): string; get packCachePath(): string; get envPrefsPath(): string; generateCryptoRandomNumber(toVal: number): number; generateUuid(): string; validateFolderPath(path: string): void; countChar(source: string, find: string): number; ensureStartsWithSlash(pathSegment: string): string; ensureEndsWithSlash(pathSegment: string): string; ensureStartsWithBackSlash(pathSegment: string): string; ensureEndsWithBackSlash(pathSegment: string): string; getFullPath(relativePath: string): string; createStorage(path: string): IStorage | null; readJsonFile(path: string): Promise<object | null>; processConversion(conversionSettings: IConversionSettings): Promise<boolean>; /** * Check if a port is available for use. * @param port The port number to check * @param host The host to check (default: localhost) * @returns Promise that resolves to true if the port is available, false otherwise */ static isPortAvailable(port: number, host?: string): Promise<boolean>; /** * Find an available port within a given range. * @param startPort The starting port of the range (inclusive) * @param endPort The ending port of the range (inclusive) * @param host The host to check (default: localhost) * @returns Promise that resolves to an available port, or undefined if none found */ static findAvailablePort(startPort: number, endPort: number, host?: string): Promise<number | undefined>; /** * Get a random port within a range, excluding browser-unsafe ports. * This is a synchronous function that doesn't check if the port is available. * Use findAvailablePort() if you need to verify the port is not in use. * * @param startPort The starting port of the range (inclusive) * @param endPort The ending port of the range (inclusive) * @returns A random port in the range that is not in the UNSAFE_PORTS list */ static getRandomSafePort(startPort: number, endPort: number): number; /** * Verifies the Authenticode digital signature of a Windows executable. * Uses PowerShell's Get-AuthenticodeSignature cmdlet, which is built into * every modern Windows and requires no native Node.js addons. * * @param exePath Absolute path to the executable to verify * @returns Promise with verification result including validity, signer, and Microsoft check */ static verifyAuthenticodeSignature(exePath: string): Promise<{ isValid: boolean; status: string; signer?: string; error?: string; isMicrosoftSigned?: boolean; }>; /** * Decode PNG image data using pngjs. * This is a Node.js-specific implementation that uses native modules. */ decodePng(data: Uint8Array): { width: number; height: number; pixels: Uint8Array; } | undefined; /** * Encode RGBA pixel data to PNG format using pngjs. * This is a Node.js-specific implementation that uses native modules. */ encodeToPng(pixels: Uint8Array, width: number, height: number): Uint8Array | undefined; }