/** * Reporting API Handler * * P1 - Reporting API and Reporting Observer management * * Supports: * - Reporting API header parsing * - Reporting Observer setup * - Report collection (CSP, COOP/COEP, etc.) * - Report analysis and categorization * - Reporting endpoint monitoring * * @see https://developer.mozilla.org/en-US/docs/Web/API/Reporting_API */ export type ReportType = 'csp-violation' | 'permissions-policy-violation' | 'intervention' | 'deprecation' | 'network-error' | 'crash'; export interface Report { /** Report type */ type: ReportType; /** Report URL (where it was generated) */ url: string; /** Report body (type-specific) */ body: Record; /** Report timestamp */ timestamp: number; /** Report ID (for deduplication) */ id: string; } export interface CSPViolationReport extends Report { type: 'csp-violation'; body: { /** Violated directive */ directive: string; /** Blocked resource */ blockedURL?: string; /** Original policy */ policy?: string; /** Source file */ sourceFile?: string; /** Line number */ lineNumber?: number; /** Column number */ columnNumber?: number; /** Disposition */ disposition?: 'report' | 'enforce'; }; } export interface PermissionsPolicyViolationReport extends Report { type: 'permissions-policy-violation'; body: { /** Violated feature */ feature: string; /** Source file */ sourceFile?: string; /** Line number */ lineNumber?: number; /** Column number */ columnNumber?: number; }; } export interface InterventionReport extends Report { type: 'intervention'; body: { /** Intervention reason */ reason?: string; }; } export interface DeprecationReport extends Report { type: 'deprecation'; body: { /** Deprecated feature */ id?: string; /** Expected removal date */ anticipatedRemoval?: string; /** Message */ message?: string; }; } export interface ReportingEndpoint { /** Endpoint name */ name: string; /** Endpoint URL */ url: string; /** Priority */ priority?: number; /** Weight for load balancing */ weight?: number; } export interface ReportingAPIConfig { /** Report-To header value */ reportTo: string | null; /** Reporting endpoints */ endpoints: ReportingEndpoint[]; /** Reporting-Endpoints header value */ reportingEndpoints: string | null; } export interface ReportingSummary { /** Total reports collected */ totalReports: number; /** Reports by type */ reportsByType: Record; /** CSP violations */ cspViolations: CSPViolationReport[]; /** Permissions policy violations */ permissionsViolations: PermissionsPolicyViolationReport[]; /** Interventions */ interventions: InterventionReport[]; /** Deprecations */ deprecations: DeprecationReport[]; /** Most common issues */ commonIssues: Array<{ type: string; count: number; description: string; }>; } /** * Reporting API Handler class */ export declare class ReportingAPIHandler { private page; private reports; private observerInstalled; constructor(page: any); /** * Check if Reporting Observer is supported */ isSupported(): Promise; /** * Get Reporting API headers */ getReportingHeaders(): Promise; /** * Install Reporting Observer */ installObserver(options?: { buffered?: boolean; types?: ReportType[]; }): Promise; /** * Get all collected reports */ getReports(): Promise; /** * Get reports by type */ getReportsByType(type: ReportType): Promise; /** * Get CSP violation reports */ getCSPViolations(): Promise; /** * Get permissions policy violation reports */ getPermissionsPolicyViolations(): Promise; /** * Get intervention reports */ getInterventions(): Promise; /** * Get deprecation reports */ getDeprecations(): Promise; /** * Generate reporting summary */ getSummary(): Promise; /** * Clear all collected reports */ clearReports(): Promise; /** * Wait for new reports */ waitForNewReports(timeout?: number): Promise; /** * Generate mock report (for testing) */ generateMockReport(type: ReportType, body: Record): Promise; /** * Analyze CSP violations for patterns */ analyzeCSPViolations(): Promise<{ total: number; byDirective: Record; byBlockedURL: Record; recommendations: string[]; }>; /** * Check for critical issues */ checkCriticalIssues(): Promise<{ hasCriticalIssues: boolean; issues: string[]; }>; /** * Export reports as JSON */ exportReports(): Promise; /** * Get Reporting API documentation */ getDocumentation(): { overview: string; url: string; reportTypes: Record; }; } /** * Factory function to create Reporting API Handler */ export declare function createReportingAPIHandler(page: any): ReportingAPIHandler; export default ReportingAPIHandler;