UNPKG

better-auth-abuse-detection

Version:

AI-powered abuse detection plugin for Better Auth - Detect and prevent account takeover attempts

65 lines (62 loc) 1.79 kB
import { BetterAuthPlugin } from 'better-auth'; interface AbuseDetectionOptions { strategies?: { credentialStuffing?: { enabled?: boolean; threshold?: number; windowMinutes?: number; }; velocityCheck?: { enabled?: boolean; maxSignIns?: number; windowMinutes?: number; }; impossibleTravel?: { enabled?: boolean; speedKmh?: number; }; deviceAnomaly?: { enabled?: boolean; requireKnownDevice?: boolean; }; behavioralAnalysis?: { enabled?: boolean; factors?: string[]; }; }; riskScoring?: { enabled?: boolean; blockThreshold?: number; challengeThreshold?: number; factors?: { newDevice?: number; newLocation?: number; vpnUsage?: number; failedAttempts?: number; [key: string]: number | undefined; }; }; actions?: { block?: { duration?: number; message?: string; }; challenge?: { types?: ("captcha" | "email" | "sms" | "totp")[]; }; notify?: { user?: boolean; admin?: boolean; }; }; ml?: { enabled?: boolean; modelUrl?: string; features?: string[]; }; onThreatDetected?: (threat: any) => Promise<void>; onAccountCompromised?: (user: any) => Promise<void>; onRiskScoreCalculated?: (score: number, factors: any) => Promise<void>; } declare function abuseDetection(options?: AbuseDetectionOptions): BetterAuthPlugin; export { type AbuseDetectionOptions, abuseDetection, abuseDetection as default };