nehonix-uri-processor
Version:
A powerful URI processor for encoding, decoding, and analyzing URI data securely.
185 lines • 6.67 kB
TypeScript
import { DecodeResult, EncodingDetectionResult, ENC_TYPE, DEC_FEATURE_TYPE, UriHandlerInterface } from "../types";
declare class NDS {
private static throwError;
private static default_checkurl_opt;
static detectMixedEncodings(input: string): string[];
/**
* Automatically detects and decodes a URI based on the detected encoding type
* @param input The URI string to decode
* @returns The decoded string according to the most probable encoding type
*/
static detectAndDecode(input: string): DecodeResult;
static decodeJWT(input: string): string;
/**
* Decodes percent encoding (URL)
*/
static decodePercentEncoding(input: string): string;
/**
// * Decodes double percent encoding
// */
/**
* Decodes hexadecimal encoding
*/
/**
* Fix 1: Proper hex string decoding implementation
*/
static decodeHex(input: string): string;
/**
* Decodes Unicode encoding
*/
static decodeUnicode(input: string): string;
/**
* Decodes HTML entities
*/
static decodeHTMLEntities(input: string): string;
/**
* Decodes punycode
* Note: Requires the 'punycode' library
*/
static decodePunycode(input: string): string;
/**
* Automatically detects the encoding type(s) of a string (URI or raw text)
* @param input The string to analyze
* @param depth Internal recursion depth (default: 0)
* @returns An object with detected types, confidence scores and the most likely one
*/
static detectEncoding(input: string, depth?: number): EncodingDetectionResult;
/**
* Attempts to decode parts of a string that appear to be encoded
* @param input The potentially partially encoded string
* @param encodingType The encoding type to try
* @returns Object indicating success and decoded parts
*/
static tryPartialDecode(input: string, encodingType: ENC_TYPE): {
success: boolean;
decoded?: string;
};
/**
* Helper function to detect nested encodings
* @param input The string to analyze
* @param depth Current recursion depth
* @returns Information about detected nested encodings
*/
static detectNestedEncoding(input: string, depth?: number): {
isNested: boolean;
outerType?: ENC_TYPE | "mixedEncoding";
innerType?: ENC_TYPE | "mixedEncoding";
confidenceScore: number;
};
/**
* Decodes ROT13 encoded text
*/
static decodeRot13(input: string): string;
/**
* Decodes Base32 encoded text
*/
static decodeBase32(input: string): string;
/**
* Decodes URL-safe Base64 encoded text
*/
static decodeUrlSafeBase64(input: string): string;
/**
* Decodes JavaScript escape sequences
*/
static decodeJsEscape(input: string): string;
static decodeCharacterEscapes(input: string): string;
/**
* Decodes CSS escape sequences
*/
static decodeCssEscape(input: string): string;
/**
* Decodes UTF-7 encoded text
*/
static decodeUtf7(input: string): string;
/**
* Decodes Quoted-Printable encoded text
*/
static decodeQuotedPrintable(input: string): string;
/**
* Decodes decimal HTML entity encoded text
*/
static decodeDecimalHtmlEntity(input: string): string;
/**
* Decodes ASCII hex encoded text (where ASCII values are represented as hex)
*/
static decodeAsciiHex(input: string): string;
/**
* Decodes ASCII octal encoded text
*/
static decodeAsciiOct(input: string): string;
/**
* Auto-detects encoding and recursively decodes until plaintext
* @param input The encoded string
* @param maxIterations Maximum number of decoding iterations to prevent infinite loops
* @returns Fully decoded plaintext
*/
static decodeAnyToPlaintext(input: string, opt?: UriHandlerInterface): DecodeResult;
private static handleUriParameters;
/**
* Decodes a string based on the specified encoding type
* @param input The string to decode
* @param encodingType The encoding type to use for decoding
* @returns The decoded string
*/
static decodeSingle(input: string, encodingType: ENC_TYPE | "mixedEncoding" | "plainText"): string;
/**
* Decodes a partially encoded string, preserving non-encoded parts
* @param input The partially encoded string
* @param baseEncodingType The base encoding type (without "partial" prefix)
* @returns The decoded string with non-encoded parts preserved
*/
static decodePartial(input: string, baseEncodingType: ENC_TYPE): string;
/**
* Attempts to decode a string with mixed encoding types
* @param input The string with mixed encodings
* @returns The decoded string
*/
static decodeMixed(input: string): string;
/**
* Decodes double percent encoding (e.g., %2520 -> %20 -> space)
* @param input The double percent-encoded string
* @returns The decoded string
*/
static decodeDoublePercentEncoding(input: string): string;
/**
* Tries various decoding strategies to find the best result
* @param input The encoded string
* @returns The best decoded result
*/
static smartDecode(input: string): string;
/**
* Enhanced URL parameter extraction and decoding
* @param url The URL string to process
* @returns URL with decoded parameters
*/
static decodeUrlParameters(url: string): string;
static decodeMixedContent(input: string): string;
static detectAndHandleRawHexUrl(input: string): string;
/**
* Decodes a raw hexadecimal string (without prefixes)
* @param input The hexadecimal string to decode
* @returns The decoded string
*/
static decodeRawHex(input: string): string;
/**
* Main decode method with improved error handling
*/
static decode(props: {
input: string;
encodingType: ENC_TYPE | DEC_FEATURE_TYPE;
maxRecursionDepth?: number;
opt?: {
throwError?: boolean;
};
}): string;
/**
* Asynchronously decodes any encoded text to plaintext
* @param input The encoded string to decode
* @param opt Optional configuration for the decoding process
* @returns A Promise that resolves to the DecodeResult containing the decoded string
*/
static asyncDecodeAnyToPlainText(input: string, opt?: UriHandlerInterface): Promise<DecodeResult>;
}
export { NDS as NehonixDecService };
export default NDS;
//# sourceMappingURL=NehonixDec.service.d.ts.map