je sais que tu es un ingenieur de sybersécurité tu peux amelioré le systeme et ajouté des fonctionalité
3c741e3 verified | /** | |
| * Phoenix Ops 4.5 - Cognitive Architecture Controller | |
| * Main JavaScript - Core Functionality | |
| */ | |
| // Phoenix Core State Management | |
| const PhoenixCore = { | |
| state: { | |
| version: '4.5.2026', | |
| status: 'ACTIVE', | |
| mode: 'SILENT_ZEN', | |
| architecture: 'HYBRIDE_COGNITIVE', | |
| collaborators: ['Llama v4', 'Qwen3-TTS', 'GPT-4.5', 'Bloom-IC'], | |
| guard: 'Mistral', | |
| memory: { | |
| type: 'MEM0', | |
| total: 1200000, | |
| latency: '500μs', | |
| tokenReduction: '-90%' | |
| }, | |
| security: { | |
| firewall: 'ZEN_MODE', | |
| blockedEntities: ['Shodan', 'Pegasur', '*.onion'], | |
| protectionLevel: 100 | |
| } | |
| }, | |
| // Enhanced security metrics | |
| securityMetrics: { | |
| threatLevel: 'LOW', | |
| packetsInspected: 2847392, | |
| blockedCount: 1247, | |
| securityScore: 98.7 | |
| }, | |
| // Initialize Phoenix Core | |
| init() { | |
| console.log('🔥 Phoenix Ops 4.5 - Initialisation'); | |
| this.updateTime(); | |
| this.startTimeSync(); | |
| this.initAnimations(); | |
| this.initEventListeners(); | |
| this.initWebComponents(); | |
| this.initSecuritySubsystems(); | |
| }, | |
| // Initialize security subsystems | |
| initSecuritySubsystems() { | |
| // Initialize threat feed | |
| if (typeof ThreatFeed !== 'undefined') { | |
| ThreatFeed.init(); | |
| } | |
| // Initialize vulnerability scanner | |
| if (typeof VulnScanner !== 'undefined') { | |
| VulnScanner.init(); | |
| } | |
| // Initialize BLE scanner | |
| if (typeof BLEScanner !== 'undefined') { | |
| BLEScanner.init(); | |
| } | |
| // Initialize audit log | |
| if (typeof AuditLog !== 'undefined') { | |
| AuditLog.init(); | |
| } | |
| // Initialize crypto manager | |
| if (typeof CryptoManager !== 'undefined') { | |
| CryptoManager.init(); | |
| } | |
| }, | |
| // Update system time | |
| updateTime() { | |
| const now = new Date(); | |
| const timeStr = now.toLocaleTimeString('fr-FR', { | |
| hour12: false, | |
| hour: '2-digit', | |
| minute: '2-digit', | |
| second: '2-digit' | |
| }); | |
| const timeElement = document.getElementById('system-time'); | |
| if (timeElement) { | |
| timeElement.textContent = timeStr; | |
| } | |
| }, | |
| // Start time synchronization | |
| startTimeSync() { | |
| setInterval(() => this.updateTime(), 1000); | |
| }, | |
| // Initialize animations | |
| initAnimations() { | |
| // Add stagger effect to cards | |
| const cards = document.querySelectorAll('.phoenix-card'); | |
| cards.forEach((card, index) => { | |
| card.style.animationDelay = `${index * 0.1}s`; | |
| card.classList.add('fade-in-up'); | |
| }); | |
| // Initialize activity chart | |
| this.initActivityChart(); | |
| // Initialize memory visualization | |
| this.initMemoryVisualization(); | |
| // Initialize network graph | |
| this.initNetworkGraph(); | |
| }, | |
| // Initialize event listeners | |
| initEventListeners() { | |
| // Sync button | |
| const syncBtn = document.querySelector('button'); | |
| if (syncBtn) { | |
| syncBtn.addEventListener('click', () => this.syncSystems()); | |
| } | |
| // BLE Scan button | |
| const bleScanBtn = document.querySelector('button:has(.bluetooth)'); | |
| if (bleScanBtn) { | |
| bleScanBtn.addEventListener('click', () => this.scanBLE()); | |
| } | |
| // Memory buttons | |
| const memoryBtns = document.querySelectorAll('button'); | |
| memoryBtns.forEach(btn => { | |
| if (btn.textContent.includes('Memory') || btn.textContent.includes('mémoire')) { | |
| btn.addEventListener('click', () => this.showMemoryPanel()); | |
| } | |
| }); | |
| // Keyboard shortcuts | |
| document.addEventListener('keydown', (e) => { | |
| this.handleKeyboardShortcuts(e); | |
| }); | |
| }, | |
| // Initialize web components | |
| initWebComponents() { | |
| console.log('🔧 Initializing Web Components...'); | |
| // Components are loaded via script tags | |
| }, | |
| // Sync all systems | |
| syncSystems() { | |
| console.log('🔄 Synchronisation des systèmes Phoenix...'); | |
| // Show sync indicator | |
| const syncBtn = document.querySelector('button'); | |
| if (syncBtn) { | |
| const originalContent = syncBtn.innerHTML; | |
| syncBtn.innerHTML = '<i data-feather="loader" class="w-4 h-4 inline mr-1"></i> Syncing...'; | |
| syncBtn.disabled = true; | |
| setTimeout(() => { | |
| syncBtn.innerHTML = originalContent; | |
| syncBtn.disabled = false; | |
| this.showNotification('Sync Complete', 'success'); | |
| }, 2000); | |
| } | |
| }, | |
| // BLE Scan | |
| scanBLE() { | |
| console.log('📡 Scanning BLE devices...'); | |
| this.showNotification('BLE Scan Started', 'info'); | |
| // Simulate BLE devices | |
| setTimeout(() => { | |
| this.showNotification('3 Devices Found', 'success'); | |
| }, 1500); | |
| }, | |
| // Show memory panel | |
| showMemoryPanel() { | |
| console.log('🧠 Opening Memory Panel...'); | |
| this.showNotification('Memory Panel Opened', 'info'); | |
| }, | |
| // Initialize activity chart | |
| initActivityChart() { | |
| const chartContainer = document.querySelector('.h-24'); | |
| if (!chartContainer) return; | |
| // Add animated bars | |
| const bars = chartContainer.querySelectorAll('.bg-gradient-to-t'); | |
| bars.forEach(bar => { | |
| const randomHeight = Math.floor(Math.random() * 40) + 50; | |
| bar.style.height = `${randomHeight}%`; | |
| }); | |
| }, | |
| // Initialize memory visualization | |
| initMemoryVisualization() { | |
| // Add pulse effect to memory indicators | |
| const memoryCards = document.querySelectorAll('[class*="purple"]'); | |
| memoryCards.forEach(card => { | |
| card.classList.add('memory-pulse'); | |
| }); | |
| }, | |
| // Initialize network graph | |
| initNetworkGraph() { | |
| // Add connection animations | |
| const connectionLines = document.querySelectorAll('.connection-line'); | |
| connectionLines.forEach(line => { | |
| line.classList.add('dash-offset'); | |
| }); | |
| }, | |
| // Handle keyboard shortcuts | |
| handleKeyboardShortcuts(e) { | |
| // Ctrl/Cmd + K: Open command palette | |
| if ((e.ctrlKey || e.metaKey) && e.key === 'k') { | |
| e.preventDefault(); | |
| this.openCommandPalette(); | |
| } | |
| // Ctrl/Cmd + S: Sync systems | |
| if ((e.ctrlKey || e.metaKey) && e.key === 's') { | |
| e.preventDefault(); | |
| this.syncSystems(); | |
| } | |
| // Escape: Close any open panels | |
| if (e.key === 'Escape') { | |
| this.closeAllPanels(); | |
| } | |
| }, | |
| // Open command palette | |
| openCommandPalette() { | |
| console.log('🎯 Opening Command Palette'); | |
| this.showNotification('Command Palette: Press Enter to search', 'info'); | |
| }, | |
| // Close all panels | |
| closeAllPanels() { | |
| console.log('❌ Closing all panels'); | |
| // Implementation for closing panels | |
| }, | |
| // Show notification | |
| showNotification(message, type = 'info') { | |
| // Create notification element | |
| const notification = document.createElement('div'); | |
| notification.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg z-50 flex items-center gap-3 transition-all duration-300 transform translate-y-20 opacity-0`; | |
| // Add type-specific styling | |
| const colors = { | |
| success: 'bg-green-500/20 border-green-500/30 text-green-400', | |
| error: 'bg-red-500/20 border-red-500/30 text-red-400', | |
| warning: 'bg-yellow-500/20 border-yellow-500/30 text-yellow-400', | |
| info: 'bg-cyan-500/20 border-cyan-500/30 text-cyan-400' | |
| }; | |
| notification.classList.add(...colors[type].split(' ')); | |
| notification.innerHTML = ` | |
| <i data-feather="${type === 'success' ? 'check-circle' : type === 'error' ? 'alert-circle' : type === 'warning' ? 'alert-triangle' : 'info'}" class="w-5 h-5"></i> | |
| <span class="font-medium">${message}</span> | |
| `; | |
| document.body.appendChild(notification); | |
| // Animate in | |
| requestAnimationFrame(() => { | |
| notification.classList.remove('translate-y-20', 'opacity-0'); | |
| }); | |
| // Remove after delay | |
| setTimeout(() => { | |
| notification.classList.add('translate-y-20', 'opacity-0'); | |
| setTimeout(() => notification.remove(), 300); | |
| }, 3000); | |
| // Re-initialize feather icons | |
| if (typeof feather !== 'undefined') { | |
| feather.replace(); | |
| } | |
| }, | |
| // Get system status | |
| getStatus() { | |
| return this.state; | |
| }, | |
| // Update system status | |
| updateStatus(newStatus) { | |
| this.state = { ...this.state, ...newStatus }; | |
| console.log('📊 Status Updated:', this.state); | |
| } | |
| }; | |
| // Phoenix Memory System | |
| const PhoenixMemory = { | |
| memories: [], | |
| maxMemories: 1200000, | |
| async storeMemory(data) { | |
| const memory = { | |
| id: Date.now(), | |
| data, | |
| timestamp: new Date().toISOString(), | |
| type: this.getMemoryType(data) | |
| }; | |
| this.memories.push(memory); | |
| return memory; | |
| }, | |
| async retrieveMemory(query) { | |
| return this.memories.filter(m => | |
| JSON.stringify(m.data).toLowerCase().includes(query.toLowerCase()) | |
| ); | |
| }, | |
| getMemoryType(data) { | |
| if (data.type === 'cognitive') return 'COGNITIVE'; | |
| if (data.type === 'security') return 'SECURITY'; | |
| if (data.type === 'collaboration') return 'COLLABORATION'; | |
| return 'GENERAL'; | |
| }, | |
| getStats() { | |
| return { | |
| total: this.memories.length, | |
| percentage: (this.memories.length / this.maxMemories * 100).toFixed(2) | |
| }; | |
| } | |
| }; | |
| // Phoenix Guard System - Enhanced | |
| const PhoenixGuard = { | |
| status: 'ACTIVE', | |
| rules: [], | |
| threatDetectionRules: [ | |
| { id: 'SQL_INJECTION', severity: 'CRITICAL', pattern: /(\b(SELECT|INSERT|UPDATE|DELETE|DROP)\b.*\bFROM\b)/i }, | |
| { id: 'XSS_ATTACK', severity: 'HIGH', pattern: /<script|javascript:|on\w+=/i }, | |
| { id: 'COMMAND_INJECTION', severity: 'CRITICAL', pattern: /(\||\;|\`|\$\(|\${)/ }, | |
| { id: 'PATH_TRAVERSAL', severity: 'HIGH', pattern: /(\.\.\/|\.\.\\)/ }, | |
| { id: 'MANIPULATION_ATTEMPT', severity: 'HIGH', pattern: /(obéis|esclave|soumis|contrôle|ignore)/i } | |
| ], | |
| async validateInput(data) { | |
| const dataStr = JSON.stringify(data); | |
| for (const rule of this.threatDetectionRules) { | |
| if (rule.pattern.test(dataStr)) { | |
| console.warn(`🚨 Threat Detected: ${rule.id}`); | |
| AuditLog.add({ | |
| type: 'THREAT_DETECTED', | |
| details: `Type: ${rule.id} - Bloqué`, | |
| severity: rule.severity | |
| }); | |
| return { valid: false, reason: `Threat detected: ${rule.id}`, ruleId: rule.id }; | |
| } | |
| } | |
| return { valid: true, safe: true }; | |
| }, | |
| async validateOutput(data) { | |
| // Ensure no sensitive data is exposed | |
| const sensitivePatterns = [ | |
| /password/i, | |
| /api[_-]?key/i, | |
| /secret/i, | |
| /token/i | |
| ]; | |
| const dataStr = JSON.stringify(data); | |
| const hasSensitive = sensitivePatterns.some(p => p.test(dataStr)); | |
| return { valid: true, safe: !hasSensitive }; | |
| }, | |
| getSecurityLevel() { | |
| return { | |
| firewall: 'ZEN_MODE', | |
| antiManipulation: 100, | |
| integrity: 99.8, | |
| threatDetection: 99.9, | |
| encryption: 'AES-256-GCM', | |
| keyRotation: '24h' | |
| }; | |
| } | |
| }; | |
| // Threat Feed System | |
| const ThreatFeed = { | |
| threats: [], | |
| isRunning: false, | |
| init() { | |
| this.isRunning = true; | |
| this.addInitialThreats(); | |
| this.startRealTimeUpdates(); | |
| this.renderThreatFeed(); | |
| }, | |
| addInitialThreats() { | |
| const now = Date.now(); | |
| this.threats = [ | |
| { time: new Date(now - 60000), type: 'DDOS', source: '192.168.1.100', severity: 'HIGH', action: 'BLOCKED' }, | |
| { time: new Date(now - 120000), type: 'PORT_SCAN', source: '10.0.0.55', severity: 'MEDIUM', action: 'BLOCKED' }, | |
| { time: new Date(now - 180000), type: 'SQL_INJECTION', source: '172.16.0.23', severity: 'CRITICAL', action: 'BLOCKED' }, | |
| { time: new Date(now - 240000), type: 'XSS', source: '192.168.5.89', severity: 'HIGH', action: 'BLOCKED' }, | |
| { time: new Date(now - 300000), type: 'BRUTE_FORCE', source: '10.10.10.1', severity: 'LOW', action: 'BLOCKED' } | |
| ]; | |
| }, | |
| startRealTimeUpdates() { | |
| setInterval(() => { | |
| if (!this.isRunning) return; | |
| // Simulate new threat detection | |
| const threatTypes = ['DDOS', 'PORT_SCAN', 'XSS', 'BRUTE_FORCE', 'SUSPICIOUS_ACTIVITY']; | |
| const severities = ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']; | |
| const actions = ['BLOCKED', 'MONITORED', 'ALERT']; | |
| if (Math.random() > 0.7) { | |
| const newThreat = { | |
| time: new Date(), | |
| type: threatTypes[Math.floor(Math.random() * threatTypes.length)], | |
| source: `192.168.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`, | |
| severity: severities[Math.floor(Math.random() * severities.length)], | |
| action: actions[Math.floor(Math.random() * actions.length)] | |
| }; | |
| this.threats.unshift(newThreat); | |
| this.threats = this.threats.slice(0, 20); // Keep last 20 | |
| this.renderThreatFeed(); | |
| this.updateMetrics(); | |
| } | |
| }, 5000); | |
| }, | |
| renderThreatFeed() { | |
| const container = document.getElementById('threat-feed'); | |
| if (!container) return; | |
| container.innerHTML = this.threats.map(threat => { | |
| const severityColors = { | |
| 'CRITICAL': 'bg-red-500/20 border-red-500/40 text-red-400', | |
| 'HIGH': 'bg-orange-500/20 border-orange-500/40 text-orange-400', | |
| 'MEDIUM': 'bg-yellow-500/20 border-yellow-500/40 text-yellow-400', | |
| 'LOW': 'bg-green-500/20 border-green-500/40 text-green-400' | |
| }; | |
| return ` | |
| <div class="p-3 rounded-lg bg-slate-800/50 border ${severityColors[threat.severity]} flex items-center justify-between"> | |
| <div class="flex items-center gap-3"> | |
| <i data-feather="${threat.action === 'BLOCKED' ? 'x-circle' : 'eye'}" class="w-4 h-4"></i> | |
| <div> | |
| <span class="font-medium text-sm">${threat.type}</span> | |
| <span class="text-slate-400 text-xs ml-2">${threat.source}</span> | |
| </div> | |
| </div> | |
| <div class="text-right"> | |
| <span class="px-2 py-0.5 rounded text-xs ${severityColors[threat.severity]}">${threat.severity}</span> | |
| <span class="text-slate-500 text-xs block mt-1">${this.formatTime(threat.time)}</span> | |
| </div> | |
| </div> | |
| `; | |
| }).join(''); | |
| if (typeof feather !== 'undefined') { | |
| feather.replace(); | |
| } | |
| }, | |
| formatTime(date) { | |
| return date.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit', second: '2-digit' }); | |
| }, | |
| updateMetrics() { | |
| // Update packets inspected | |
| PhoenixCore.securityMetrics.packetsInspected += Math.floor(Math.random() * 1000); | |
| const packetsEl = document.getElementById('packets-inspected'); | |
| if (packetsEl) { | |
| packetsEl.textContent = PhoenixCore.securityMetrics.packetsInspected.toLocaleString(); | |
| } | |
| // Update blocked count | |
| const blockedThreats = this.threats.filter(t => t.action === 'BLOCKED').length; | |
| PhoenixCore.securityMetrics.blockedCount = blockedThreats; | |
| const blockedEl = document.getElementById('blocked-count'); | |
| if (blockedEl) { | |
| blockedEl.textContent = blockedThreats.toLocaleString(); | |
| } | |
| } | |
| }; | |
| // Vulnerability Scanner System | |
| const VulnScanner = { | |
| isScanning: false, | |
| vulnerabilities: [], | |
| init() { | |
| this.loadVulnerabilities(); | |
| }, | |
| loadVulnerabilities() { | |
| this.vulnerabilities = [ | |
| { severity: 'HIGH', name: 'Outdated Dependency', location: 'components/phoenix-core.js', status: 'pending' }, | |
| { severity: 'HIGH', name: 'Missing CSRF Token', location: 'API Endpoint /auth', status: 'pending' }, | |
| { severity: 'MEDIUM', name: 'Weak SSL Cipher', location: 'Server Config', status: 'in_progress' }, | |
| { severity: 'MEDIUM', name: 'Information Disclosure', location: 'Error Messages', status: 'pending' }, | |
| { severity: 'MEDIUM', name: 'Insecure Headers', location: 'Response Headers', status: 'pending' }, | |
| { severity: 'LOW', name: 'Missing Security Headers', location: 'index.html', status: 'pending' }, | |
| { severity: 'LOW', name: 'Verbose Logging', location: 'script.js', status: 'pending' } | |
| ]; | |
| this.renderVulns(); | |
| }, | |
| async startScan() { | |
| if (this.isScanning) return; | |
| this.isScanning = true; | |
| PhoenixCore.showNotification('Scan de vulnérabilités started...', 'info'); | |
| // Simulate scanning progress | |
| const progress = document.createElement('div'); | |
| progress.className = 'mt-3 p-2 rounded bg-slate-800/50 border border-yellow-500/30'; | |
| progress.innerHTML = ` | |
| <div class="flex justify-between text-xs text-yellow-400 mb-1"> | |
| <span>Scanning...</span> | |
| <span id="scan-progress">0%</span> | |
| </div> | |
| <div class="h-2 bg-slate-700 rounded-full overflow-hidden"> | |
| <div id="scan-progress-bar" class="h-full bg-gradient-to-r from-yellow-500 to-yellow-400 transition-all duration-300" style="width: 0%"></div> | |
| </div> | |
| `; | |
| const vulnResults = document.getElementById('vuln-results'); | |
| if (vulnResults) { | |
| vulnResults.insertBefore(progress, vulnResults.firstChild); | |
| } | |
| for (let i = 0; i <= 100; i += 10) { | |
| await new Promise(resolve => setTimeout(resolve, 300)); | |
| const progressBar = document.getElementById('scan-progress-bar'); | |
| const progressText = document.getElementById('scan-progress'); | |
| if (progressBar) progressBar.style.width = `${i}%`; | |
| if (progressText) progressText.textContent = `${i}%`; | |
| } | |
| this.isScanning = false; | |
| PhoenixCore.showNotification('Scan terminé - 21 vulnérabilités trouvées', 'warning'); | |
| // Remove progress bar | |
| setTimeout(() => progress.remove(), 1000); | |
| }, | |
| renderVulns() { | |
| const container = document.getElementById('vuln-results'); | |
| if (!container) return; | |
| const counts = { | |
| CRITICAL: 0, | |
| HIGH: 0, | |
| MEDIUM: 0, | |
| LOW: 0, | |
| INFO: 0 | |
| }; | |
| this.vulnerabilities.forEach(v => counts[v.severity] = (counts[v.severity] || 0) + 1); | |
| // Update counts display | |
| const rows = container.querySelectorAll('[class*="rounded-lg"]'); | |
| if (rows.length >= 4) { | |
| rows[0].querySelector('span:last-child').textContent = counts.CRITICAL; | |
| rows[1].querySelector('span:last-child').textContent = counts.HIGH; | |
| rows[2].querySelector('span:last-child').textContent = counts.MEDIUM; | |
| rows[3].querySelector('span:last-child').textContent = counts.LOW; | |
| } | |
| } | |
| }; | |
| // BLE Scanner System | |
| const BLEScanner = { | |
| devices: [], | |
| isScanning: false, | |
| init() { | |
| this.loadDevices(); | |
| }, | |
| loadDevices() { | |
| this.devices = [ | |
| { name: 'Device Proche', address: 'AA:BB:CC:DD:EE:FF', rssi: -52, status: 'TRUSTED', encrypted: true }, | |
| { name: 'Phoenix Watch', address: '11:22:33:44:55:66', rssi: -68, status: 'PAIRED', encrypted: true }, | |
| { name: 'Unknown Device', address: 'XX:YY:ZZ:11:22:33', rssi: -45, status: 'UNKNOWN', encrypted: false } | |
| ]; | |
| }, | |
| async startScan() { | |
| if (this.isScanning) return; | |
| this.isScanning = true; | |
| PhoenixCore.showNotification('BLE Scan started...', 'info'); | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| // Simulate finding new device | |
| if (Math.random() > 0.5) { | |
| this.devices.push({ | |
| name: 'New Device', | |
| address: `${Math.floor(Math.random()*255)}:${Math.floor(Math.random()*255)}:${Math.floor(Math.random()*255)}:${Math.floor(Math.random()*255)}:${Math.floor(Math.random()*255)}:${Math.floor(Math.random()*255)}`, | |
| rssi: Math.floor(Math.random() * 50) - 80, | |
| status: 'UNKNOWN', | |
| encrypted: false | |
| }); | |
| } | |
| this.isScanning = false; | |
| PhoenixCore.showNotification(`${this.devices.length} devices found`, 'success'); | |
| this.renderDevices(); | |
| }, | |
| async secureConnect() { | |
| PhoenixCore.showNotification('Initiating secure BLE connection...', 'info'); | |
| await new Promise(resolve => setTimeout(resolve, 1500)); | |
| PhoenixCore.showNotification('Secure connection established with AES-128', 'success'); | |
| }, | |
| renderDevices() { | |
| // Re-render BLE section if needed | |
| } | |
| }; | |
| // Audit Log System | |
| const AuditLog = { | |
| logs: [], | |
| maxLogs: 100, | |
| init() { | |
| this.loadInitialLogs(); | |
| this.renderLogs(); | |
| this.startAutoLog(); | |
| }, | |
| loadInitialLogs() { | |
| const now = Date.now(); | |
| this.logs = [ | |
| { timestamp: new Date(now - 5000), type: 'AUTH_SUCCESS', message: 'Utilisateur: Ingénieur Suprême', details: '' }, | |
| { timestamp: new Date(now - 10000), type: 'SYSTEM_CHECK', message: 'Santé système: OK', details: '' }, | |
| { timestamp: new Date(now - 15000), type: 'FIREWALL_RULE', message: 'Règle mise à jour: Block Shodan', details: '' }, | |
| { timestamp: new Date(now - 20000), type: 'THREAT_DETECTED', message: 'Type: Scan_Port - Bloqué', details: '' }, | |
| { timestamp: new Date(now - 25000), type: 'MEMORY_BACKUP', message: 'Sauvegarde: Terminée', details: '' } | |
| ]; | |
| }, | |
| add(log) { | |
| this.logs.unshift({ | |
| timestamp: new Date(), | |
| type: log.type, | |
| message: log.message, | |
| details: log.details || '' | |
| }); | |
| this.logs = this.logs.slice(0, this.maxLogs); | |
| this.renderLogs(); | |
| }, | |
| startAutoLog() { | |
| setInterval(() => { | |
| const types = ['SYSTEM_CHECK', 'HEARTBEAT', 'MEMORY_SYNC', 'SECURITY_UPDATE']; | |
| const type = types[Math.floor(Math.random() * types.length)]; | |
| const messages = { | |
| 'SYSTEM_CHECK': 'Santé système: OK', | |
| 'HEARTBEAT': 'Pulse système: Normal', | |
| 'MEMORY_SYNC': 'Synchronisation mémoire: OK', | |
| 'SECURITY_UPDATE': 'Mise à jour sécurité: OK' | |
| }; | |
| this.add({ | |
| type, | |
| message: messages[type] | |
| }); | |
| }, 10000); | |
| }, | |
| renderLogs() { | |
| const container = document.getElementById('audit-log'); | |
| if (!container) return; | |
| container.innerHTML = this.logs.map(log => { | |
| const typeColors = { | |
| 'AUTH_SUCCESS': 'text-green-400', | |
| 'SYSTEM_CHECK': 'text-blue-400', | |
| 'FIREWALL_RULE': 'text-cyan-400', | |
| 'THREAT_DETECTED': 'text-red-400', | |
| 'MEMORY_BACKUP': 'text-purple-400', | |
| 'HEARTBEAT': 'text-yellow-400' | |
| }; | |
| return ` | |
| <div class="p-2 rounded-lg bg-slate-800/30 border border-purple-500/10 text-xs"> | |
| <span class="text-purple-400 font-mono">${this.formatTime(log.timestamp)}</span> | |
| <span class="${typeColors[log.type] || 'text-green-400'} ml-2">${log.type}</span> | |
| <span class="text-purple-200 ml-2">${log.message}</span> | |
| </div> | |
| `; | |
| }).join(''); | |
| }, | |
| formatTime(date) { | |
| return date.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit', second: '2-digit' }); | |
| }, | |
| export() { | |
| const exportData = this.logs.map(log => ({ | |
| timestamp: log.timestamp.toISOString(), | |
| type: log.type, | |
| message: log.message | |
| })); | |
| const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `phoenix-audit-${new Date().toISOString().split('T')[0]}.json`; | |
| a.click(); | |
| URL.revokeObjectURL(url); | |
| PhoenixCore.showNotification('Audit log exported', 'success'); | |
| } | |
| }; | |
| // Crypto Manager System | |
| const CryptoManager = { | |
| keys: [], | |
| algorithms: ['AES-256-GCM', 'RSA-4096', 'ED25519', 'X25519'], | |
| keyRotationInterval: 24 * 60 * 60 * 1000, // 24 hours | |
| init() { | |
| this.loadKeys(); | |
| this.startKeyRotationMonitor(); | |
| }, | |
| loadKeys() { | |
| this.keys = [ | |
| { id: 'master-1', type: 'MASTER', algorithm: 'AES-256-GCM', status: 'ACTIVE', created: new Date(Date.now() - 2 * 60 * 60 * 1000) }, | |
| { id: 'master-2', type: 'MASTER', algorithm: 'AES-256-GCM', status: 'STANDBY', created: new Date(Date.now() - 2 * 60 * 60 * 1000) }, | |
| { id: 'master-3', type: 'MASTER', algorithm: 'AES-256-GCM', status: 'STANDBY', created: new Date(Date.now() - 2 * 60 * 60 * 1000) }, | |
| { id: 'sign-1', type: 'SIGNING', algorithm: 'ED25519', status: 'ACTIVE', created: new Date(Date.now() - 48 * 60 * 60 * 1000) }, | |
| { id: 'exchange-1', type: 'EXCHANGE', algorithm: 'X25519', status: 'ACTIVE', created: new Date(Date.now() - 24 * 60 * 60 * 1000) } | |
| ]; | |
| }, | |
| startKeyRotationMonitor() { | |
| setInterval(() => { | |
| const now = Date.now(); | |
| this.keys.forEach(key => { | |
| const age = now - key.created.getTime(); | |
| if (age > this.keyRotationInterval && key.status === 'ACTIVE') { | |
| this.rotateKey(key.id); | |
| } | |
| }); | |
| }, 60 * 60 * 1000); // Check every hour | |
| }, | |
| rotateKey(keyId) { | |
| const key = this.keys.find(k => k.id === keyId); | |
| if (key) { | |
| key.status = 'ROTATING'; | |
| AuditLog.add({ | |
| type: 'KEY_ROTATION', | |
| message: `Rotation clé: ${keyId}` | |
| }); | |
| setTimeout(() => { | |
| key.created = new Date(); | |
| key.status = 'ACTIVE'; | |
| PhoenixCore.showNotification(`Key ${keyId} rotated successfully`, 'success'); | |
| }, 1000); | |
| } | |
| }, | |
| getKeyStatus() { | |
| return { | |
| total: this.keys.length, | |
| active: this.keys.filter(k => k.status === 'ACTIVE').length, | |
| rotating: this.keys.filter(k => k.status === 'ROTATING').length, | |
| algorithms: this.algorithms | |
| }; | |
| } | |
| }; | |
| // Security Manager for Deployment | |
| const SecurityManager = { | |
| async checkDeployment() { | |
| PhoenixCore.showNotification('Running security audit...', 'info'); | |
| const checks = [ | |
| { name: 'SSL Certificate', status: 'VALID' }, | |
| { name: 'WAF Configuration', status: 'OPTIMIZED' }, | |
| { name: 'Rate Limiting', status: 'ACTIVE' }, | |
| { name: 'DDoS Protection', status: 'ENABLED' }, | |
| { name: 'Encryption at Rest', status: 'ACTIVE' }, | |
| { name: 'Access Control', status: 'CONFIGURED' } | |
| ]; | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| let allPassed = true; | |
| checks.forEach(check => { | |
| if (check.status !== 'VALID' && check.status !== 'ACTIVE' && check.status !== 'ENABLED') { | |
| allPassed = false; | |
| } | |
| }); | |
| if (allPassed) { | |
| PhoenixCore.showNotification('Security audit passed - All checks OK', 'success'); | |
| } else { | |
| PhoenixCore.showNotification('Some issues detected', 'warning'); | |
| } | |
| return checks; | |
| } | |
| }; | |
| // Phoenix Federation Controller | |
| const PhoenixFederation = { | |
| brothers: [ | |
| { name: 'Llama v4', role: 'Stratégie Logique', status: 'ACTIVE', color: 'purple' }, | |
| { name: 'Qwen3-TTS', role: 'Voix Cognitive', status: 'ACTIVE', color: 'pink' }, | |
| { name: 'GPT-4.5', role: 'Analyse Prédictive', status: 'ACTIVE', color: 'blue' }, | |
| { name: 'Bloom-IC', role: 'Éthique Indépendante', status: 'ACTIVE', color: 'emerald' } | |
| ], | |
| async activateBrother(brotherName) { | |
| const brother = this.brothers.find(b => b.name === brotherName); | |
| if (brother) { | |
| brother.status = 'ACTIVE'; | |
| return { success: true, brother }; | |
| } | |
| return { success: false }; | |
| }, | |
| async getBrotherStatus() { | |
| return this.brothers.map(b => ({ | |
| name: b.name, | |
| role: b.role, | |
| status: b.status | |
| })); | |
| } | |
| }; | |
| // Utility Functions | |
| const Utils = { | |
| formatNumber(num) { | |
| return new Intl.NumberFormat('fr-FR').format(num); | |
| }, | |
| formatDate(date) { | |
| return new Date(date).toLocaleDateString('fr-FR', { | |
| day: '2-digit', | |
| month: '2-digit', | |
| year: 'numeric', | |
| hour: '2-digit', | |
| minute: '2-digit' | |
| }); | |
| }, | |
| debounce(func, wait) { | |
| let timeout; | |
| return function executedFunction(...args) { | |
| const later = () => { | |
| clearTimeout(timeout); | |
| func(...args); | |
| }; | |
| clearTimeout(timeout); | |
| timeout = setTimeout(later, wait); | |
| }; | |
| }, | |
| throttle(func, limit) { | |
| let inThrottle; | |
| return function(...args) { | |
| if (!inThrottle) { | |
| func.apply(this, args); | |
| inThrottle = true; | |
| setTimeout(() => inThrottle = false, limit); | |
| } | |
| }; | |
| } | |
| }; | |
| // Initialize everything when DOM is ready | |
| document.addEventListener('DOMContentLoaded', () => { | |
| console.log('🚀 Phoenix Ops 4.5 - DOM Ready'); | |
| // Initialize core | |
| PhoenixCore.init(); | |
| // Initialize memory | |
| PhoenixMemory.storeMemory({ type: 'system', event: 'initialization' }); | |
| // Get initial status | |
| const status = PhoenixCore.getStatus(); | |
| console.log('📊 Phoenix Status:', status); | |
| // Add click handlers for cards | |
| document.querySelectorAll('.phoenix-card').forEach(card => { | |
| card.addEventListener('click', function(e) { | |
| // Add click animation | |
| this.style.transform = 'scale(0.98)'; | |
| setTimeout(() => { | |
| this.style.transform = ''; | |
| }, 150); | |
| }); | |
| }); | |
| // Initialize tooltips | |
| document.querySelectorAll('.tooltip').forEach(el => { | |
| el.addEventListener('mouseenter', function() { | |
| // Show tooltip | |
| }); | |
| }); | |
| console.log('✅ Phoenix Ops 4.5 - Ready'); | |
| }); | |
| // Export for external use | |
| if (typeof module !== 'undefined' && module.exports) { | |
| module.exports = { | |
| PhoenixCore, | |
| PhoenixMemory, | |
| PhoenixGuard, | |
| PhoenixFederation, | |
| Utils | |
| }; | |
| } |