hayai-db
Version:
⚡ Instantly create and manage local databases with one command
109 lines (108 loc) • 3.17 kB
TypeScript
export interface SecurityCredentials {
username: string;
password: string;
database?: string;
encrypted: boolean;
createdAt: string;
lastUsed?: string;
}
export interface SecurityPolicy {
requireAuthentication: boolean;
allowCrossEngineOperations: boolean;
enableNetworkIsolation: boolean;
auditOperations: boolean;
maxOperationsPerHour: number;
allowedOperations: string[];
}
export interface AuditLog {
timestamp: string;
operation: string;
source: string;
target: string;
user: string;
success: boolean;
error?: string;
ipAddress?: string;
}
export declare class SecurityManager {
private static instance;
private readonly encryptionKey;
private readonly credentialsPath;
private readonly auditLogPath;
private readonly securityPolicyPath;
private operationCounts;
private constructor();
static getInstance(): SecurityManager;
/**
* Generates or retrieves unique encryption key per installation
*/
private getOrCreateEncryptionKey;
/**
* Encrypts sensitive data
*/
private encrypt;
/**
* Decrypts sensitive data
*/
private decrypt;
/**
* Generates secure random password
*/
generateSecurePassword(length?: number): string;
/**
* Stores credentials securely
*/
storeCredentials(instanceName: string, credentials: Omit<SecurityCredentials, 'encrypted' | 'createdAt'>): Promise<void>;
/**
* Retrieves credentials securely
*/
getCredentials(instanceName: string): Promise<SecurityCredentials | null>;
/**
* Validates if operation is allowed
*/
validateOperation(operation: string, sourceInstance: string, targetInstance?: string, user?: string): Promise<{
allowed: boolean;
reason?: string;
}>;
/**
* Creates network isolation for operation
*/
createNetworkIsolation(): Promise<string>;
/**
* Connects containers to isolated network
*/
connectToNetwork(networkName: string, containerName: string): Promise<void>;
/**
* Removes isolated network after operation
*/
cleanupNetwork(networkName: string): Promise<void>;
/**
* Records operation in audit log
*/
auditLog(log: AuditLog): Promise<void>;
/**
* Gets security policy
*/
getSecurityPolicy(): Promise<SecurityPolicy>;
/**
* Saves security policy
*/
saveSecurityPolicy(policy: SecurityPolicy): Promise<void>;
/**
* Creates secure credentials for new instance
*/
createSecureCredentials(instanceName: string, engine: string): Promise<SecurityCredentials>;
/**
* Executes secure command with credentials
*/
executeSecureCommand(command: string[], instanceName: string, operation: string): Promise<string>;
/**
* Executes command with secure environment variables
*/
private runSecureCommand;
/**
* Validates data integrity after operation
*/
validateDataIntegrity(instanceName: string, engine: string): Promise<boolean>;
}
export declare const getSecurityManager: () => SecurityManager;