UNPKG

token-guardian

Version:

A comprehensive solution for protecting and managing API tokens and secrets

33 lines (32 loc) 1.1 kB
import { ScanResult } from '../interfaces/ScanResult'; import { TokenPattern } from '../interfaces/TokenPattern'; import { Logger } from '../utils/Logger'; /** * Scanner that detects potential tokens and secrets in strings */ export declare class PatternScanner { private patterns; private logger; constructor(patterns?: TokenPattern[], logger?: Logger); /** * Scans a string for potential tokens or secrets * @param content The string to scan * @param filepath The file path of the scanned content * @returns Results of the scan */ scan(content: string, filepath: string): ScanResult[]; /** * Calculates Shannon entropy of a string * @param str The string to calculate entropy for * @returns Entropy value */ private calculateEntropy; /** * Gets the line number for a position in text * @param text The text to search in * @param position The position to find the line number for * @returns The line number (1-based) */ private getLineNumber; addPattern(pattern: TokenPattern): void; }