UNPKG

reporting-api

Version:

Roll your own Reporting API collector. Supports CSP, COEP, COOP, Document-Policy, Crash reports, Deprecation reports, Intervention reports and Network Error Logging

48 lines (47 loc) 1.71 kB
import { Request, Response, NextFunction } from 'express'; interface ReportingHeadersConfig { /** * The reporting group name to use. Set to avoid collision with existing Reporting API usage. * * If `enableDefaultReporters` is set, this group name will always be set to `default` * @default "reporter" */ reportingGroup?: string; /** * Add a `default` reporter group to receive Deprecation, Crash and Intervention reports */ enableDefaultReporters?: boolean; /** * Enable `NEL` (Network Error Logging) * * Uses Reporting API v0 `Report-To` header as the Reporting API v1 doesn't support * Network Error Logging. See https://developer.chrome.com/blog/reporting-api-migration#network_error_logging */ enableNetworkErrorLogging?: boolean | { success_fraction?: number; failure_fraction?: number; include_subdomains?: boolean; }; /** * Report version */ version?: string | number; } /** * Adds reporting to all existing headers and sets the `Reporting-Endpoints` header * * Headers that support the Reporting API `report-to` directive: * * - Content-Security-Policy * - Content-Security-Policy-Report-Only * - Permissions-Policy * - Permissions-Policy-Report-Only * - Cross-Origin-Opener-Policy * - Cross-Origin-Opener-Policy-Report-Only * - Cross-Origin-Embedder-Policy * - Cross-Origin-Embedder-Policy-Report-Only * * @param reportingUrl The pathname or full URL for the reporting endpoint */ export declare function setupReportingHeaders(reportingUrl: string, config?: ReportingHeadersConfig): (req: Request, res: Response, next?: NextFunction) => void; export {};