/** * Represents an obfuscation rule that can be applied to harvested payloads * @typedef {object} ObfuscationRule * @property {string|RegExp} regex The regular expression to match against in the payload * @property {string} [replacement] The string to replace the matched regex with * @property {string[]} [eventFilter] An optional list of event types to which this rule should be applied. If not provided, or an empty array, the rule will be applied to all events. */ /** * Represents an obfuscation rule validation state * @typedef {object} ObfuscationRuleValidation * @property {ObfuscationRule} rule The original rule validated * @property {boolean} isValid Whether the rule is valid * @property {object} errors Validation errors * @property {boolean} errors.regexMissingDetected Whether the regex is missing * @property {boolean} errors.invalidRegexDetected Whether the regex is invalid * @property {boolean} errors.invalidReplacementDetected Whether the replacement is invalid */ export class Obfuscator { /** * @param {Object} agentRef - Reference to the agent instance * @param {string} [eventType] - Optional event type this obfuscator instance handles. * If provided, only rules matching this event type (or rules with no eventFilter) will be applied. */ constructor(agentRef: Object, eventType?: string); agentRef: Object; eventType: string | undefined; warnedRegexMissing: boolean; warnedInvalidRegex: boolean; warnedInvalidReplacement: boolean; get obfuscateConfigRules(): any; /** * Applies all valid obfuscation rules to the provided input string * @param {string} input String to obfuscate * @returns {string} */ obfuscateString(input: string): string; /** * Traverses an object and obfuscates all string properties. * This instance will only apply rules that match its configured event type (if any). * For features with mixed event types in their payloads (like generic_events), this will * traverse the object and check each object's eventType property against the rules. * @param {Object|Array} obj - The object or array to traverse * @returns {Object|Array} The modified object */ traverseAndObfuscateEvents(obj: Object | any[]): Object | any[]; /** * Validates an obfuscation rule and provides errors if any are found. * @param {ObfuscationRule} rule The rule to validate * @returns {ObfuscationRuleValidation} The validation state of the rule */ validateObfuscationRule(rule: ObfuscationRule): ObfuscationRuleValidation; #private; } /** * Represents an obfuscation rule that can be applied to harvested payloads */ export type ObfuscationRule = { /** * The regular expression to match against in the payload */ regex: string | RegExp; /** * The string to replace the matched regex with */ replacement?: string | undefined; /** * An optional list of event types to which this rule should be applied. If not provided, or an empty array, the rule will be applied to all events. */ eventFilter?: string[] | undefined; }; /** * Represents an obfuscation rule validation state */ export type ObfuscationRuleValidation = { /** * The original rule validated */ rule: ObfuscationRule; /** * Whether the rule is valid */ isValid: boolean; /** * Validation errors */ errors: { regexMissingDetected: boolean; invalidRegexDetected: boolean; invalidReplacementDetected: boolean; }; }; //# sourceMappingURL=obfuscate.d.ts.map