UNPKG

@sudowealth/schwab-api

Version:

TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety

82 lines (81 loc) 2.31 kB
/** * Secure logger for Schwab API client * Focuses on protecting authentication tokens and credentials */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; export interface LoggerConfig { enabled: boolean; level: LogLevel; } export declare class SecureLogger { private config; constructor(config?: Partial<LoggerConfig>); /** * Check if a string looks like a token */ private isLikelyToken; /** * Sanitize a value to remove sensitive information */ private sanitizeValue; /** * Sanitize error objects */ private sanitizeError; /** * Sanitize objects by checking field names */ private sanitizeObject; /** * Format log arguments for output */ private formatArgs; /** * Check if logging is allowed for the given level */ private shouldLog; debug(...args: any[]): void; info(...args: any[]): void; warn(...args: any[]): void; error(...args: any[]): void; /** * Log an error with additional context * This method provides structured error logging */ logError(message: string, error: unknown, context?: Record<string, any>): void; } /** * Create a logger instance for a specific module */ export declare function createLogger(moduleName: string): SecureLogger; export declare const logger: SecureLogger; /** * Sanitize a key for logging * Shows only the beginning and end of the key * * @param key The key to sanitize * @param options Sanitization options * @returns Sanitized key safe for logging */ export declare function sanitizeKeyForLog(key: string, options?: { maxLength?: number; }): string; /** * Sanitize an error object for safe logging * Removes sensitive data while preserving useful debugging information * * @param error The error to sanitize * @returns Sanitized error information */ export declare function sanitizeError(error: unknown): Record<string, any>; /** * Sanitize a token for logging * Shows only the beginning of the token and optionally its length * * @param token The token to sanitize * @param options Sanitization options * @returns Sanitized token safe for logging */ export declare function sanitizeTokenForLog(token: string, options?: { showLength?: boolean; }): string;