@kanadi/core
Version:
Multi-Layer CAPTCHA Framework with customizable validators and challenge bundles
55 lines (41 loc) • 1.55 kB
text/typescript
import { BanClient, type BanOptions } from "./ban-client";
class BanAPI {
private static client: BanClient | null = null;
private static getClient(): BanClient {
if (!this.client) {
this.client = new BanClient();
}
return this.client;
}
static async IP(ip: string, options: BanOptions): Promise<void> {
await this.getClient().banIP(ip, options);
}
static async ASN(asn: string, options: BanOptions): Promise<{ banned: number; prefixes: string[] }> {
return await this.getClient().banASN(asn, options);
}
static async Device(deviceId: string, options: BanOptions): Promise<void> {
await this.getClient().banDevice(deviceId, options);
}
static async User(userId: string, options: BanOptions): Promise<void> {
await this.getClient().banUser(userId, options);
}
static async Fingerprint(fingerprint: string, options: BanOptions): Promise<void> {
await this.getClient().banFingerprint(fingerprint, options);
}
static async Session(sessionId: string, options: BanOptions): Promise<void> {
await this.getClient().banSession(sessionId, options);
}
static async Check(entityType: string, entityId: string) {
return await this.getClient().checkBan(entityType, entityId);
}
static async Remove(entityType: string, entityId: string): Promise<void> {
await this.getClient().removeBan(entityType, entityId);
}
static async List(limit?: number) {
return await this.getClient().listActiveBans(limit);
}
static async Stats() {
return await this.getClient().getStats();
}
}
export { BanAPI as Ban };