import { RateLimiter } from "../ratelimiting/RateLimiter"; import { ReportingAPI, ReportingAPIResponse } from "./api/ReportingAPI"; import { Token } from "./api/Token"; import { Kind } from "./Attack"; import { Endpoint } from "./Config"; import { Context } from "./Context"; import { Hostnames } from "./Hostnames"; import { InspectionStatistics } from "./InspectionStatistics"; import { Logger } from "./logger/Logger"; import { Routes } from "./Routes"; import { ServiceConfig } from "./ServiceConfig"; import { Source } from "./Source"; import { Users } from "./Users"; import { Wrapper } from "./Wrapper"; import { AIStatistics } from "./AIStatistics"; import { AttackWaveDetector } from "../vulnerabilities/attack-wave-detection/AttackWaveDetector"; import type { FetchListsAPI } from "./api/FetchListsAPI"; import { PendingEvents } from "./PendingEvents"; import type { IdorProtectionConfig } from "./IdorProtectionConfig"; type WrappedPackage = { version: string; supported: boolean; }; export declare class Agent { private block; private readonly logger; private readonly api; private readonly token; private readonly serverless; private readonly newInstrumentation; private readonly fetchListsAPI; private started; private sendHeartbeatEveryMS; private checkIfHeartbeatIsNeededEveryMS; private lastHeartbeat; private sentHeartbeatCounter; private interval; private preventedPrototypePollution; private incompatiblePackages; private wrappedPackages; private packages; private timeoutInMS; private hostnames; private users; private serviceConfig; private routes; private rateLimiter; private statistics; private aiStatistics; private middlewareInstalled; private attackLogger; private attackWaveDetector; private pendingEvents; private idorProtectionConfig; constructor(block: boolean, logger: Logger, api: ReportingAPI, token: Token | undefined, serverless: string | undefined, newInstrumentation: boolean | undefined, fetchListsAPI: FetchListsAPI); shouldBlock(): boolean; isServerless(): boolean; getHostnames(): Hostnames; getInspectionStatistics(): InspectionStatistics; getAIStatistics(): AIStatistics; setIdorProtectionConfig(config: IdorProtectionConfig): void; getIdorProtectionConfig(): IdorProtectionConfig | undefined; unableToPreventPrototypePollution(incompatiblePackages: Record): void; onPrototypePollutionPrevented(): void; /** * Reports to the API that this agent has started */ onStart(timeoutInMS?: number): Promise; checkForReportingAPIError(result: ReportingAPIResponse): void; onErrorThrownByInterceptor({ error, module, method, }: { error: Error; module: string; method: string; }): void; /** * This function gets called when an attack is detected, it reports this attack to the API */ onDetectedAttack({ module, operation, kind, blocked, source, request, stack, paths, metadata, payload, }: { module: string; operation: string; kind: Kind; blocked: boolean; source: Source | undefined; request: Context | undefined; stack: string; paths: string[]; metadata: Record; payload: unknown; }): void; /** * Sends a heartbeat via the API to the server (only when not in serverless mode) */ private heartbeat; getUsers(): Users; getConfig(): ServiceConfig; private updateServiceConfig; private sendHeartbeat; /** * Starts a heartbeat when not in serverless mode : Make contact with api every x seconds. */ private startHeartbeats; private updateBlockedLists; private startPollingForConfigChanges; private getHostname; private getAgentInfo; start(wrappers: Wrapper[]): void; onFailedToWrapMethod(module: string, name: string, error: Error): void; onFailedToWrapModule(module: string, error: Error): void; onPackageRequired(name: string, version: string): void; onPackageWrapped(name: string, details: WrappedPackage): void; onBuiltinWrapped(name: string): void; hasWebFrameworkLoaded(): boolean; onConnectHostname(hostname: string, port: number): void; onRouteExecute(context: Context): void; hasGraphQLSchema(method: string, path: string): boolean; onGraphQLSchema(method: string, path: string, schema: string): void; onGraphQLExecute(method: string, path: string, type: "query" | "mutation", topLevelFields: string[]): void; onRouteRateLimited(match: Endpoint): void; getRoutes(): Routes; log(message: string): void; flushStats(timeoutInMS: number): Promise; getPendingEvents(): PendingEvents; getRateLimiter(): RateLimiter; onMiddlewareExecuted(): void; isUsingNewInstrumentation(): boolean; private getHeartbeatInterval; getAttackWaveDetector(): AttackWaveDetector; /** * This function gets called when an attack wave is detected, it reports this attack wave to the API */ onDetectedAttackWave({ request }: { request: Context; }): void; shutdown(timeoutInMS?: number): Promise; } export {};