UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

21 lines (20 loc) 1.4 kB
import type { Agent } from "../Agent"; import { OperationKind } from "../api/Event"; import { getContext } from "../Context"; import type { InterceptorResult } from "./InterceptorResult"; import type { PartialWrapPackageInfo } from "./WrapPackageInfo"; export type InspectArgsInterceptor = (args: unknown[], agent: Agent, subject: unknown) => InterceptorResult | void; export type ModifyArgsInterceptor = (args: unknown[], agent: Agent, subject: unknown) => unknown[]; export type ModifyReturnValueInterceptor = (args: unknown[], returnValue: unknown, agent: Agent, subject: unknown) => unknown; export type InterceptorObject = { inspectArgs?: InspectArgsInterceptor; modifyArgs?: ModifyArgsInterceptor; modifyReturnValue?: ModifyReturnValueInterceptor; kind: OperationKind | undefined; }; /** * Wraps a function with the provided interceptors. * If the function is not part of an object, like default exports, pass undefined as methodName and the function as subject. */ export declare function wrapExport(subject: unknown, methodName: string | undefined, pkgInfo: PartialWrapPackageInfo, interceptors: InterceptorObject): Function | undefined; export declare function inspectArgs(args: unknown[], interceptor: InspectArgsInterceptor, context: ReturnType<typeof getContext>, agent: Agent, pkgInfo: PartialWrapPackageInfo, methodName: string, kind: OperationKind | undefined): void;