UNPKG

@kya-os/agentshield-nextjs

Version:

Next.js middleware for AgentShield AI agent detection

44 lines (42 loc) 1.23 kB
/** * Wrapper for EdgeAgentDetector to match AgentDetector interface * This allows the middleware to work with EdgeAgentDetector in Edge Runtime * * This is a self-contained implementation to avoid import resolution issues * Includes proper Ed25519 signature verification for ChatGPT and other agents */ type DetectionInput = { userAgent?: string; ip?: string; ipAddress?: string; headers?: Record<string, string>; url?: string; method?: string; timestamp?: Date; }; type DetectionResult = { isAgent: boolean; confidence: number; detectedAgent?: { type: string; name: string; }; reasons: string[]; verificationMethod?: string; forgeabilityRisk?: 'low' | 'medium' | 'high'; timestamp: Date; }; type EventHandler = (...args: any[]) => void; /** * Wrapper that provides event emitter functionality */ declare class EdgeAgentDetectorWrapper { private detector; private events; constructor(_config?: any); analyze(input: DetectionInput): Promise<DetectionResult>; on(event: string, handler: EventHandler): void; emit(event: string, ...args: any[]): void; init(): Promise<void>; } export { EdgeAgentDetectorWrapper };