/** * Autocapture Utilities * * Utility functions for DOM element handling, sensitive data detection, * and text extraction. Privacy-first approach with comprehensive filtering. */ import { AutocaptureConfig, Properties } from "./autocapture-types"; export declare function isElementNode(el: Node | null): el is Element; export declare function isTextNode(el: Node | EventTarget | null): el is Text; export declare function isTag(el: Element | null | undefined, tag: string): boolean; export declare function isDocumentFragment(el: Node | ParentNode | null): el is DocumentFragment; export declare function splitClassString(s: string): string[]; /** * Get the className of an element, accounting for edge cases where element.className is an object */ export declare function getClassNames(el: Element): string[]; /** * Make text safe for capture by filtering sensitive values and normalizing */ export declare function makeSafeText(s: string | null | undefined): string | null; /** * Get the direct text content of an element, protecting against sensitive data collection. */ export declare function getSafeText(el: Element): string; /** * Get nested span text recursively */ export declare function getNestedSpanText(target: Element): string; /** * Get text from element and its nested span children */ export declare function getDirectAndNestedSpanText(target: Element): string; export declare function getEventTarget(e: Event): Element | null; export declare function previousElementSibling(el: Element): Element | null; export declare function getParentElement(curEl: Element): Element | false; /** * Whether the current page URL passes autocapture url allow/ignore lists. */ export declare function isAutocaptureUrlAllowed(autocaptureConfig: AutocaptureConfig | undefined): boolean; /** * Check whether a string value should be captured or if it may contain sensitive data */ export declare function shouldCaptureValue(value: string, anchorRegexes?: boolean): boolean; /** * Check whether an attribute name is an Angular style attr */ export declare function isAngularStyleAttr(attributeName: string): boolean; /** * Check whether a DOM element should be captured or if it may contain sensitive data */ export declare function shouldCaptureElement(el: Element): boolean; /** * Check whether a DOM element is 'sensitive' and we should only capture limited data */ export declare function isSensitiveElement(el: Element): boolean; /** * Get safe value for change events on form elements. * Returns value for non-sensitive elements (checkbox, radio, select). * Never returns values for text inputs, password fields, or textareas. */ /** * Result of capturing input value from a form element. */ export interface InputValueResult { /** The actual form value (option value, checked state, or input value) */ $el_value?: string; /** Human-readable text (option text, label text) - what the user sees */ $selected_text?: string; } /** * Get the value from an input element if it's safe to capture. * This follows the same protection patterns as element/value filtering: * - Skips password fields * - Skips fields with sensitive names (cc, pass, ssn, etc.) * - Filters out credit card and SSN patterns from values * - Respects vt-sensitive and vt-no-capture classes * * Returns both $el_value (actual value) and $selected_text (human-readable text). * Use cases: tracking search keywords, filter selections, etc. */ export declare function getInputValue(el: Element): InputValueResult | null; /** * Why a DOM event was rejected by `shouldCaptureDomEvent`. Surfaced through * the rich variant `evaluateDomEventCapture` so the caller can produce a * useful debug log instead of a silent skip. */ export type DomEventRejectReason = "no_window" | "no_element" | "html_element" | "url_allowlist_miss" | "url_ignorelist_hit" | "dom_event_not_allowed" | "element_allowlist_miss" | "css_selector_allowlist_miss" | "css_selector_ignorelist_hit" | "tag_html" | "form_event_not_allowed" | "input_event_not_allowed" | "tag_not_capturable"; export interface DomEventEvaluation { /** True when the event passes every filter and should be captured. */ capture: boolean; /** Why we rejected the event. Undefined when `capture` is true. */ reason?: DomEventRejectReason; } /** * Rich variant of {@link shouldCaptureDomEvent} that also returns the * rejection reason. Use this from places that want to debug-log why an * event was skipped (e.g. the Autocapture trace log). */ export declare function evaluateDomEventCapture(el: Element, event: Event, autocaptureConfig?: AutocaptureConfig | undefined, captureOnAnyElement?: boolean, allowedEventTypes?: string[]): DomEventEvaluation; /** * Boolean wrapper around {@link evaluateDomEventCapture} kept for any * callers that don't need the rejection reason. */ export declare function shouldCaptureDomEvent(el: Element, event: Event, autocaptureConfig?: AutocaptureConfig | undefined, captureOnAnyElement?: boolean, allowedEventTypes?: string[]): boolean; export declare function getPropertiesFromElement(elem: Element, maskAllAttributes: boolean, maskText: boolean, elementAttributeIgnorelist: string[] | undefined): Properties; export declare function getAugmentPropertiesFromElement(elem: Element): Properties; export declare function getElementsChainString(elements: Properties[]): string; export declare function getDefaultProperties(eventType: string): Properties;