UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

43 lines (42 loc) 2.03 kB
import * as http from "http"; import { ServerPermissionLevel } from "./IAuthenticationToken"; export default class HttpUtilities { /** * Creates a short, human-readable request description for logging. * Format: [HH:MM:SS] [usr:AABBCC] METHOD /path: * Or with token: [HH:MM:SS] [usr:AABBCCDDEE] METHOD /path: * @param req The HTTP request * @param clientIp The client IP address (used to generate user thumbprint) * @param tokenThumb Optional 4-char token thumbprint to append for authenticated users */ static getShortReqDescription(req: http.IncomingMessage, clientIp?: string, tokenThumb?: string): string; /** * Creates a 6-character thumbprint from an IP address or token for session identification. * * NOTE: This is NOT password hashing - it creates a short visual identifier for display/logging. * SHA-256 is appropriate here as we only need a collision-resistant fingerprint. */ static getThumbprint(value: string): string; /** * Creates a 4-character thumbprint from an identifier for appending to user identification in logs. * * NOTE: This is NOT password hashing - it creates a short visual identifier for display/logging. * SHA-256 is appropriate here as we only need a collision-resistant fingerprint, not a secure * password hash. Actual authentication uses AES-GCM encryption, not this thumbprint. * * @param identifier A unique session identifier (NOT a password) to create a thumbprint from */ static getTokenThumbprint(identifier: string): string; /** * Checks if an IP address is a local/loopback address. */ static isLocalIp(clientIp: string): boolean; /** * Formats a client IP address for display, with friendly names for local addresses. */ static formatClientIp(clientIp: string): string; /** * Returns a human-readable name for a server permission level. */ static getPermissionLevelName(level: ServerPermissionLevel): string; }