cs2-inspect-lib
Version:
Enhanced CS2 Inspect URL library with full protobuf support, validation, and error handling
291 lines • 10.9 kB
TypeScript
/**
* CS2 Inspect URL Library - Enhanced Version
*
* A comprehensive TypeScript library for encoding and decoding CS2 inspect URLs
* with full protobuf support, validation, and error handling.
*/
export * from './types';
export * from "./weapon-paints";
export * from './errors';
export { Validator } from './validation';
export { ProtobufReader } from './protobuf-reader';
export { ProtobufWriter } from './protobuf-writer';
export { ProtobufReader as Protobuf } from './protobuf-reader';
export * from './url-analyzer';
export { SteamClient } from './steam-client';
export { SteamClientManager } from './steam-client-manager';
import { EconItem, CS2InspectConfig, AnalyzedInspectURL, SteamInspectResult } from './types';
/**
* Main CS2 Inspect URL API class
*/
export declare class CS2Inspect {
private config;
private urlAnalyzer;
private steamManager;
constructor(config?: CS2InspectConfig);
/**
* Creates an inspect URL from an EconItem
*
* @param item - The item data to encode
* @returns The generated inspect URL
*
* @example
* ```typescript
* const cs2 = new CS2Inspect();
* const item: EconItem = {
* defindex: WeaponType.AK_47,
* paintindex: 44, // Fire Serpent
* paintseed: 661,
* paintwear: 0.15
* };
* const url = cs2.createInspectUrl(item);
* ```
*/
createInspectUrl(item: EconItem): string;
/**
* Decodes a MASKED inspect URL into an EconItem (synchronous, offline)
*
* ⚠️ ONLY works with MASKED URLs (URLs containing encoded protobuf data)
* ❌ Does NOT work with UNMASKED URLs (market/inventory links) - use inspectItem() instead
*
* @param url - The MASKED inspect URL to decode
* @returns The decoded item data
* @throws Error if URL is unmasked or invalid
*
* @example
* ```typescript
* const cs2 = new CS2Inspect();
* // This works - masked URL with protobuf data
* const maskedUrl = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20001807A8...";
* const item = cs2.decodeMaskedUrl(maskedUrl);
*
* // This will throw an error - unmasked URL
* const unmaskedUrl = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198123456789A987654321D456789123";
* // cs2.decodeMaskedUrl(unmaskedUrl); // ❌ Throws error
* ```
*/
decodeMaskedUrl(url: string): EconItem;
/**
* Decodes a MASKED inspect URL into an EconItem (synchronous, offline)
*
* @deprecated Use decodeMaskedUrl() instead for clearer naming
* @param url - The MASKED inspect URL to decode
* @returns The decoded item data
*/
decodeInspectUrl(url: string): EconItem;
/**
* Analyzes an inspect URL structure
*
* @param url - The URL to analyze
* @returns Analyzed URL information
*/
analyzeUrl(url: string): AnalyzedInspectURL;
/**
* Validates an EconItem
*
* @param item - The item to validate
* @returns Validation result
*/
validateItem(item: any): import("./types").ValidationResult;
/**
* Validates an inspect URL
*
* @param url - The URL to validate
* @returns Validation result
*/
validateUrl(url: string): import("./types").ValidationResult;
/**
* Checks if a URL is a valid inspect URL
*
* @deprecated Use analyzeUrl() and check for errors instead, or use validateUrl() for detailed validation
* @param url - The URL to check
* @returns True if valid, false otherwise
*/
isValidUrl(url: string): boolean;
/**
* Normalizes an inspect URL to standard format
*
* @param url - The URL to normalize
* @returns Normalized URL
*/
normalizeUrl(url: string): string;
/**
* Gets basic URL information without full decoding
*
* @param url - The URL to analyze
* @returns Basic URL information
*/
getUrlInfo(url: string): {
type: "masked" | "unmasked" | "invalid";
isQuoted: boolean;
hasValidFormat: boolean;
estimatedSize?: number | undefined;
};
/**
* Inspects ANY inspect URL (both masked and unmasked) - Universal method
*
* ✅ Works with MASKED URLs (decoded offline using protobuf data)
* ✅ Works with UNMASKED URLs (fetched via Steam client)
* 🔄 Automatically detects URL type and uses appropriate method
*
* @param url - Any valid inspect URL (masked or unmasked)
* @returns Promise resolving to the decoded item data
* @throws Error if Steam client is required but not available
*
* @example
* ```typescript
* const cs2 = new CS2Inspect({
* steamClient: {
* enabled: true,
* username: 'your_username',
* password: 'your_password'
* }
* });
* await cs2.initializeSteamClient();
*
* // Works with masked URLs (offline)
* const maskedUrl = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20001807A8...";
* const maskedItem = await cs2.inspectItem(maskedUrl);
*
* // Works with unmasked URLs (via Steam client)
* const unmaskedUrl = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198123456789A987654321D456789123";
* const unmaskedItem = await cs2.inspectItem(unmaskedUrl);
* ```
*/
inspectItem(url: string): Promise<EconItem | SteamInspectResult>;
/**
* Inspects ANY inspect URL (both masked and unmasked) - Universal method
*
* @deprecated Use inspectItem() instead for clearer naming
* @param url - Any valid inspect URL (masked or unmasked)
* @returns Promise resolving to the decoded item data
*/
decodeInspectUrlAsync(url: string): Promise<EconItem | SteamInspectResult>;
/**
* Initialize Steam client for unmasked URL support
*
* @returns Promise that resolves when Steam client is ready
*/
initializeSteamClient(): Promise<void>;
/**
* Check if Steam client is available and ready
*
* @returns True if Steam client is ready for inspection
*/
isSteamClientReady(): boolean;
/**
* Get Steam client status and statistics
*
* @returns Steam client status information
*/
getSteamClientStats(): {
status: import("./types").SteamClientStatus;
queueLength: number;
isAvailable: boolean;
unmaskedSupport: boolean;
};
/**
* Check if a URL requires Steam client for inspection
*
* @param url - The URL to check
* @returns True if URL requires Steam client
*/
requiresSteamClient(url: string): boolean;
/**
* Disconnect Steam client
*/
disconnectSteamClient(): Promise<void>;
/**
* Updates the configuration
*
* @param newConfig - New configuration options
*/
updateConfig(newConfig: Partial<CS2InspectConfig>): void;
/**
* Gets current configuration
*
* @returns Current configuration
*/
getConfig(): Required<CS2InspectConfig>;
}
/**
* Static convenience functions for quick usage without instantiating the class
* These are optimized to avoid creating unnecessary instances
*/
/**
* Creates an inspect URL from an EconItem (convenience function)
*/
export declare function createInspectUrl(item: EconItem, config?: CS2InspectConfig): string;
/**
* Decodes a MASKED inspect URL into an EconItem (convenience function)
* ⚠️ ONLY works with MASKED URLs - use inspectItem() for universal support
*/
export declare function decodeMaskedUrl(url: string, config?: CS2InspectConfig): EconItem;
/**
* Decodes a MASKED inspect URL into an EconItem (convenience function)
* @deprecated Use decodeMaskedUrl() instead for clearer naming
*/
export declare function decodeInspectUrl(url: string, config?: CS2InspectConfig): EconItem;
/**
* Inspects ANY inspect URL (masked or unmasked) - Universal convenience function
* Automatically handles Steam client initialization if needed
*/
export declare function inspectItem(url: string, config?: CS2InspectConfig): Promise<EconItem | SteamInspectResult>;
/**
* Inspects ANY inspect URL (masked or unmasked) - Universal convenience function
* @deprecated Use inspectItem() instead for clearer naming
*/
export declare function decodeInspectUrlAsync(url: string, config?: CS2InspectConfig): Promise<EconItem | SteamInspectResult>;
/**
* Validates an EconItem (convenience function)
*/
export declare function validateItem(item: any): import("./types").ValidationResult;
/**
* Validates an inspect URL (convenience function)
*/
export declare function validateUrl(url: string): import("./types").ValidationResult;
/**
* Analyzes an inspect URL structure (static, optimized)
* ⚡ More efficient than creating a CS2Inspect instance
*/
export declare function analyzeUrl(url: string, config?: CS2InspectConfig): AnalyzedInspectURL;
/**
* Decodes masked protobuf data directly (static, fastest)
* ⚡ Direct access to ProtobufReader.decodeMaskedData
* 🔥 Use this for maximum performance with known hex data
*/
export declare function decodeMaskedData(hexData: string, config?: CS2InspectConfig): EconItem;
/**
* Checks if URL requires Steam client (static, optimized)
* ⚡ More efficient than creating a CS2Inspect instance
*/
export declare function requiresSteamClient(url: string, config?: CS2InspectConfig): boolean;
/**
* Normalizes an inspect URL to standard format (static, optimized)
* ⚡ More efficient than creating a CS2Inspect instance
*/
export declare function normalizeUrl(url: string, config?: CS2InspectConfig): string;
/**
* Quick URL validation check (static, optimized)
* ⚡ More efficient than creating a CS2Inspect instance
* 💡 Prefer analyzeUrl() for more detailed information
*/
export declare function isValidUrl(url: string, config?: CS2InspectConfig): boolean;
/**
* Default CS2Inspect instance for quick usage
*/
export declare const cs2inspect: CS2Inspect;
/**
* Version information
*/
export declare const VERSION = "3.0.6";
/**
* Library information
*/
export declare const LIBRARY_INFO: {
readonly name: "cs2-inspect-lib";
readonly version: "3.0.6";
readonly description: "Enhanced CS2 Inspect library with full protobuf support and Steam client integration";
readonly features: readonly ["Complete protobuf encoding/decoding", "Steam client integration for unmasked URLs", "Support for both masked and unmasked inspect URLs", "Input validation and error handling", "TypeScript support with comprehensive types", "Support for all CS2 item fields including new additions", "URL analysis and normalization", "Configurable validation and limits", "Queue system with rate limiting for Steam API calls"];
};
//# sourceMappingURL=index.d.ts.map