UNPKG

recoder-code

Version:

Complete AI-powered development platform with ML model training, plugin registry, real-time collaboration, monitoring, infrastructure automation, and enterprise deployment capabilities

76 lines (75 loc) 2.02 kB
/** * ApiKey Entity * Manages API keys for authentication and access control */ import { User } from './User'; export declare enum ApiKeyScope { READ = "read", WRITE = "write", ADMIN = "admin", PUBLISH = "publish", UNPUBLISH = "unpublish", DEPRECATE = "deprecate" } export declare enum ApiKeyStatus { ACTIVE = "active", REVOKED = "revoked", EXPIRED = "expired", SUSPENDED = "suspended" } export declare class ApiKey { id: string; name: string; key_hash: string; key_prefix: string; scopes: ApiKeyScope[]; status: ApiKeyStatus; description?: string; restrictions: { ip_whitelist?: string[]; package_patterns?: string[]; rate_limit?: { requests: number; window: number; }; }; expires_at?: Date; last_used?: Date; last_used_ip?: string; usage_count: number; usage_stats: { daily_usage: Record<string, number>; weekly_usage: Record<string, number>; monthly_usage: Record<string, number>; }; created_at: Date; updated_at: Date; revoked_at?: Date; revocation_reason?: string; user: User; user_id: string; static generateKey(): { key: string; hash: string; prefix: string; }; static hashKey(key: string): string; hasScope(scope: ApiKeyScope): boolean; hasScopes(scopes: ApiKeyScope[]): boolean; isExpired(): boolean; isActive(): boolean; canAccessPackage(packageName: string): boolean; isIpAllowed(ip: string): boolean; recordUsage(ip?: string): void; revoke(reason?: string): void; suspend(): void; activate(): void; extend(newExpiryDate: Date): void; addScope(scope: ApiKeyScope): void; removeScope(scope: ApiKeyScope): void; setRestrictions(restrictions: ApiKey['restrictions']): void; getDailyUsage(days?: number): Record<string, number>; isRateLimited(): boolean; toSafeFormat(): any; toDetailedFormat(): any; }