UNPKG

lotus-sdk

Version:

Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem

52 lines 2.16 kB
import { EventEmitter } from 'events'; import { CORE_P2P_SECURITY_LIMITS, IProtocolValidator, CoreSecurityMetrics } from './types.js'; export declare class DHTAnnouncementRateLimiter { private lastAnnouncement; private announcementCount; canAnnounce(peerId: string, minInterval?: number): boolean; private incrementCount; getCount(peerId: string): number; cleanup(): void; } export declare class DHTResourceTracker { private peerResources; private peerResourcesByType; canAnnounceResource(peerId: string, resourceType: string, resourceId: string): boolean; removeResource(peerId: string, resourceType: string, resourceId: string): void; getResourceCount(peerId: string): number; getResourceCountByType(peerId: string, resourceType: string): number; } export declare class CorePeerBanManager extends EventEmitter { private blacklist; private tempBans; private warningCount; banPeer(peerId: string, reason: string): void; tempBanPeer(peerId: string, durationMs: number, reason: string): void; warnPeer(peerId: string, reason: string): void; isAllowed(peerId: string): boolean; unbanPeer(peerId: string): void; getBannedCount(): number; getWarningCount(): number; getBannedPeers(): string[]; } export declare class CoreSecurityManager extends EventEmitter { dhtRateLimiter: DHTAnnouncementRateLimiter; resourceTracker: DHTResourceTracker; peerBanManager: CorePeerBanManager; private protocolValidators; private metrics; private disableRateLimiting; private customLimits; constructor(config?: { disableRateLimiting?: boolean; customLimits?: Partial<typeof CORE_P2P_SECURITY_LIMITS>; }); registerProtocolValidator(protocolName: string, validator: IProtocolValidator): void; canAnnounceToDHT(peerId: string, resourceType: string, resourceId: string, data: unknown): Promise<boolean>; recordMessage(valid: boolean, oversized?: boolean): void; private _findValidatorForResourceType; cleanup(): void; getMetrics(): CoreSecurityMetrics; resetMetrics(): void; } //# sourceMappingURL=security.d.ts.map