Build a secrets provenance tracker: creation, rotation, and consumers.
- User
Build a secrets provenance tracker: creation, rotation, and consumers.
- Assistant
Build a secrets provenance tracker: creation, rotation, and consumers.
Here's a thinking process that leads to the suggested solution:
Analyze the Request:
Conceptualize the Application:
Visual Design & CSS (Tailwind + Custom):
#050505 (deep black). Primary Cyan #00f3ff. Secondary Magenta #ff00ff. Tertiary Amber #ffcc00 (for warnings).family-mono (Courier Prime or JetBrains Mono if available via Google Fonts). I'll import 'JetBrains Mono'.#00f3ff with low opacity, plus hover effects.box-shadow: 0 0 10px #00f3ff.pointer-events-none overlay with a repeating linear gradient.::before and ::after pseudo-elements on section headers to create brackets.Implementation Steps:
Step 1: HTML Structure:
<!DOCTYPE html><head>: Tailwind CDN, Google Fonts, Custom <style> for specific effects (scanlines, brackets, glitch).<body>: Layout container (grid/flex).Step 2: Mock Data Generation:
Step 3: Building the "Secrets Inventory" View (The Table):
Step 4: Building the "Consumer Graph" View (Canvas):
Step 5: Building the "Rotation Scheduler" (Timeline):
Step 6: Interaction Logic (JS):
requestAnimationFrame).Refining the Cyberpunk Aesthetics (The "FUI" Touch):
corner-decoration divs at screen corners.border-[1px].Drafting the Code (Mental or Scratchpad):
.clip-text { ... position relative; overflow: hidden; ... }
.clip-text::after { content: attr(data-text); ... mix-blend-mode: exclusion; ... }
const secrets = [
{ id: '0001', name: 'API_GALACTIC_DB', type: 'Token', status: 'active', created: '2077-01-01', expires: '2077-04-01', consumers: ['Service-A', 'Bot-2'] },
...
];
Writing the Final Code (Iterative refinement):
flex-1.<table> with heavy Tailwind classes for borders and colors.NetworkGraph.draw() method clears canvas, draws lines, draws circles.swtichTab('inventory'), switchTab('network'), switchTab('timeline').showToast(msg, type) appends a div to a fixed container and removes it after N seconds.Polish & "Professional" touches:
Self-Correction/Review during drafting:
width/height attributes based on devicePixelRatio.Final Code Assembly:
<style>), JS (in <script>).ui-avatars or use a CSS shape). I'll use a CSS-styled initials box for the avatar to avoid external dependencies failing.Output Generation: (Proceeding to generate the HTML string).
(Self-Correction during coding the "Decoding" effect): I need a reliable way to randomize characters. I'll use a set of "techy" characters like 01XYZ!@#$.
(Self-Correction during Canvas Animation): Make sure to stop the animation loop when switching tabs to save resources, or just keep it running but the canvas is hidden. Better: Only render the visible one. I'll add a isVisible flag to the loop.
Let's write the code. Here is the complete, single-file HTML solution for the Secrets Provenance Tracker.
This application, codenamed "NEXUS-7", implements a full HUD-style interface. It features an interactive inventory table, a dynamic "Consumer Network" graph using the Canvas API, a rotation timeline, and a cornel-bracket UI framework with a decoding text engine.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEXUS-7 | Secret Provenance Tracker</title>
<!-- Tailwind CSS (CDN) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts: JetBrains Mono -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700;800&display=swap" rel="stylesheet">
<!-- Config & Custom Styles -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
nexus: {
bg: '#050505',
primary: '#00f3ff', // Cyan
secondary: '#ff00ff', // Magenta
tertiary: '#ffcc00', // Amber
dark: '#0a0a0a',
gray: '#1a1a1a',
dim: 'rgba(0, 243, 255, 0.1)'
}
},
fontFamily: {
mono: ['"JetBrains Mono"', 'monospace'],
},
boxShadow: {
'neon-cyan': '0 0 10px rgba(0, 243, 255, 0.5), 0 0 4px rgba(0, 243, 255, 0.3)',
'neon-magenta': '0 0 10px rgba(255, 0, 255, 0.5), 0 0 4px rgba(255, 0, 255, 0.3)',
}
}
}
}
</script>
<style>
body {
background-color: #050505;
color: #e0e0e0;
overflow: hidden; /* App-like feel */
}
/* Scanline Overlay */
.scanlines {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
background-size: 100% 2px, 3px 100%;
pointer-events: none;
z-index: 9999;
}
/* UI Corner Brackets */
.corner-bracket {
position: absolute;
width: 12px;
height: 12px;
border: 2px solid #00f3ff;
transition: all 0.3s ease;
}
.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.br { bottom: -2px; right: -2px; border-left: none; border-top: none; }
.panel:hover .corner-bracket {
box-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
width: 16px;
height: 16px;
}
/* Selection & Scrollbar */
::selection { background: rgba(0, 243, 255, 0.3); color: #fff; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border: 1px solid #333; }
::-webkit-scrollbar-thumb:hover { background: #00f3ff; }
/* Glitch Animation utility */
@keyframes glitch-skew {
0% { transform: skew(0deg); }
20% { transform: skew(-2deg); }
40% { transform: skew(2deg); }
60% { transform: skew(-1deg); }
80% { transform: skew(1deg); }
100% { transform: skew(0deg); }
}
.glitch-hover:hover {
animation: glitch-skew 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
text-shadow: -1px 0 #ff00ff, 1px 0 #00f3ff;
}
/* Utility for decoding text style */
.data-text {
font-family: 'JetBrains Mono', monospace;
letter-spacing: 0.05em;
}
/* CRT Flicker */
@keyframes flicker {
0% { opacity: 0.97; }
5% { opacity: 0.95; }
10% { opacity: 0.9; }
15% { opacity: 0.95; }
20% { opacity: 0.99; }
50% { opacity: 0.95; }
80% { opacity: 0.9; }
100% { opacity: 0.97; }
}
.crt-flicker {
animation: flicker 0.15s infinite;
}
</style>
</head>
<body class="antialiased h-screen w-screen flex flex-col font-mono text-sm">
<!-- Scanline Overlay -->
<div class="scanlines"></div>
<!-- Header -->
<header class="h-16 border-b border-nexus-primary/30 bg-nexus-bg/90 flex items-center justify-between px-6 relative z-50">
<div class="flex items-center gap-4">
<!-- Logo / System Name -->
<div class="flex flex-col">
<h1 class="text-lg font-bold tracking-widest text-nexus-primary uppercase glitch-hover cursor-default">
NEXUS-7
</h1>
<span class="text-[10px] text-nexus-secondary/70">SECRET PROVENANCE TRACKER</span>
</div>
<div class="h-8 w-px bg-nexus-primary/50 mx-2"></div>
<div class="text-xs text-nexus-primary/80 flex flex-col justify-center">
<span id="sys-clock" class="crt-flicker">00:00:00:00</span>
<span class="text-[10px] text-nexus-dim">UTC / MSEC</span>
</div>
</div>
<div class="flex items-center gap-6">
<!-- Connection Status -->
<div class="flex items-center gap-2">
<div class="w-2 h-2 rounded-full bg-nexus-primary animate-pulse shadow-neon-cyan"></div>
<span class="text-xs text-nexus-primary">UPLINK SECURE</span>
</div>
<!-- User Profile (CSS generated avatar) -->
<div class="flex items-center gap-3 border border-nexus-dim p-1 rounded bg-nexus-dark hover:bg-nexus-gray transition-colors cursor-pointer">
<div class="w-8 h-8 bg-nexus-secondary/20 border border-nexus-secondary flex items-center justify-center text-xs font-bold text-nexus-secondary">
JS
</div>
<div class="flex flex-col">
<span class="text-sm font-bold text-white">J. Smith</span>
<span class="text-[10px] text-nexus-dim">Level 5 Clearance</span>
</div>
</div>
</div>
</header>
<!-- Main Layout -->
<div class="flex flex-1 overflow-hidden">
<!-- Sidebar Navigation -->
<nav class="w-64 border-r border-nexus-dim bg-nexus-bg/80 flex flex-col py-6 relative z-40">
<div class="px-6 space-y-1">
<button class="nav-btn w-full text-left px-4 py-3 border border-transparent text-nexus-dim hover:text-nexus-primary hover:bg-nexus-dim/10 transition-all rounded relative group overflow-hidden" data-target="inventory">
<span class="relative z-10 font-bold tracking-wider">INVENTORY</span>
<div class="absolute left-0 top-0 h-full w-1 bg-nexus-primary transform -translate-x-full group-hover:translate-x-0 transition-transform"></div>
</button>
<button class="nav-btn w-full text-left px-4 py-3 border border-transparent text-nexus-dim hover:text-nexus-primary hover:bg-nexus-dim/10 transition-all rounded relative group overflow-hidden" data-target="network">
<span class="relative z-10 font-bold tracking-wider">CONSUMER MAP</span>
<div class="absolute left-0 top-0 h-full w-1 bg-nexus-primary transform -translate-x-full group-hover:translate-x-0 transition-transform"></div>
</button>
<button class="nav-btn w-full text-left px-4 py-3 border border-transparent text-nexus-dim hover:text-nexus-primary hover:bg-nexus-dim/10 transition-all rounded relative group overflow-hidden" data-target="timeline">
<span class="relative z-10 font-bold tracking-wider">ROTATION TIMELINE</span>
<div class="absolute left-0 top-0 h-full w-1 bg-nexus-primary transform -translate-x-full group-hover:translate-x-0 transition-transform"></div>
</button>
<button class="nav-btn w-full text-left px-4 py-3 border border-transparent text-nexus-dim hover:text-nexus-primary hover:bg-nexus-dim/10 transition-all rounded relative group overflow-hidden" data-target="audit">
<span class="relative z-10 font-bold tracking-wider">AUDIT LOG</span>
<div class="absolute left-0 top-0 h-full w-1 bg-nexus-primary transform -translate-x-full group-hover:translate-x-0 transition-transform"></div>
</button>
</div>
<div class="mt-auto px-6">
<div class="text-xs text-nexus-dim mb-2 border-b border-nexus-dim/30 pb-2">SYSTEM INFO</div>
<div class="flex justify-between text-xs mb-1">
<span>CORE LOAD</span>
<span class="text-nexus-primary">42%</span>
</div>
<div class="w-full h-1 bg-nexus-dark border border-nexus-dim/30 mt-1">
<div class="h-full bg-nexus-primary animate-pulse" style="width: 42%"></div>
</div>
<div class="flex justify-between text-xs mt-3 mb-1">
<span>MEMORY</span>
<span class="text-nexus-secondary">12TB / 64TB</span>
</div>
</div>
</nav>
<!-- Content Area -->
<main class="flex-1 relative p-6 bg-nexus-bg overflow-auto">
<!-- Decorative Grid Background -->
<div class="absolute inset-0 pointer-events-none z-0 opacity-10"
style="background-image: linear-gradient(#00f3ff 1px, transparent 1px), linear-gradient(90deg, #00f3ff 1px, transparent 1px); background-size: 40px 40px;">
</div>
<!-- Content Container -->
<div id="content-area" class="relative z-10">
<!-- Views will be injected here via JS -->
</div>
</main>
</div>
<!-- Toast Container -->
<div id="toast-container" class="fixed bottom-8 right-8 z-[10000] flex flex-col gap-2 pointer-events-none"></div>
<!-- Scripts -->
<script>
// ==========================================
// MOCK DATA GENERATION
// ==========================================
const CONSUMERS = [
'Auth-Service-01', 'Gateway-Edge', 'Analytics-Batch', 'Legacy-ERP',
'Mobile-App-v2', 'Invoice-Gen', 'Watchdog-Alert', 'Backup-Node',
'Dev-Environment', 'Payment-Gateway', 'CRM-Core', 'Public-API'
];
const TYPES = ['API_KEY', 'DATABASE_PASSWORD', 'JWT_SIGNING', 'ENCRYPTION_KEY', 'WEBHOOK_SECRET'];
function generateSecrets(count) {
const secrets = [];
const now = new Date();
for (let i = 0; i < count; i++) {
const id = `SEC-${1000 + i}`;
const type = TYPES[Math.floor(Math.random() * TYPES.length)];
const created = new Date(now.getTime() - Math.floor(Math.random() * 1000 * 60 * 60 * 24 * 365));
// Rotation is every 30-90 days
const rotationDays = 30 + Math.floor(Math.random() * 60);
const expires = new Date(created.getTime() + rotationDays * 24 * 60 * 60 * 1000);
// Assign random 2-4 consumers
const consumerCount = Math.floor(Math.random() * 3) + 2;
const shuffled = [...CONSUMERS].sort(() => 0.5 - Math.random());
const consumers = shuffled.slice(0, consumerCount);
// Determine status
let status = 'ACTIVE';
if (expires < now) status = 'EXPIRED';
else if (expires < new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000)) status = 'WARNING';
secrets.push({
id,
type,
name: `[${type.split('_')[0]}]_${String.fromCharCode(65+i)}_GLOBAL`,
created,
expires,
rotationScheduleDays: rotationDays,
status,
owner: `User_${Math.floor(Math.random()*100)}`,
consumers
});
}
return secrets;
}
const store = {
secrets: generateSecrets(15),
logs: []
};
// Generate some initial logs
store.logs = store.secrets.map(s => ({
timestamp: s.created,
level: s.status === 'ACTIVE' ? 'INFO' : 'WARN',
message: `Secret ${s.id} provisioned for ${s.consumers.length} consumers.`
}));
// ==========================================
// UI FRAMEWORK & UTILITIES
// ==========================================
const contentArea = document.getElementById('content-area');
const navBtns = document.querySelectorAll('.nav-btn');
// Clock Update
function updateClock() {
const now = new Date();
const timeStr = now.toISOString().split('T')[1].replace('Z', '').replace(/\.\d+/, '') + `:${now.getMilliseconds().toString().padStart(3, '0').slice(0, 2)}`;
document.getElementById('sys-clock').textContent = timeStr.toUpperCase();
}
setInterval(updateClock, 40);
updateClock();
// Scramble Text Animation (Classic Decoding)
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$#@&%';
function scrambleText(element, finalText, duration = 800) {
let start = 0;
const fps = 60;
const totalFrames = (duration / 1000) * fps;
function frame() {
start++;
let output = '';
// How much of the final text is revealed? (cubic ease out)
const progress = Math.min(start / totalFrames, 1);
const eased = 1 - Math.pow(1 - progress, 3);
const visibleLength = Math.floor(finalText.length * eased);
for (let i = 0; i < finalText.length; i++) {
if (i < visibleLength) {
output += finalText[i];
} else {
output += chars[Math.floor(Math.random() * chars.length)];
}
}
element.textContent = output;
if (start < totalFrames) {
requestAnimationFrame(frame);
} else {
element.textContent = finalText;
}
}
frame();
}
// Toast Notification System
function showToast(message, type = 'info') {
const container = document.getElementById('toast-container');
const toast = document.createElement('div');
const colors = {
info: 'border-nexus-primary text-nexus-primary',
success: 'border-green-500 text-green-500',
warn: 'border-nexus-tertiary text-nexus-tertiary',
error: 'border-red-500 text-red-500'
};
const bgcolors = {
info: 'bg-nexus-primary/10',
success: 'bg-green-500/10',
warn: 'bg-nexus-tertiary/10',
error: 'bg-red-500/10'
};
toast.className = `pointer-events-auto px-4 py-2 border-l-4 ${colors[type]} ${bgcolors[type]} bg-nexus-bg/90 shadow-neon-cyan/30 text-xs font-mono flex items-center justify-between gap-4 min-w-[300px] cursor-pointer hover:bg-nexus-dark backdrop-blur-sm`;
toast.innerHTML = `
<div class="flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-current"></span>
<span>${message}</span>
</div>
<span class="text-nexus-dim text-[10px]">${new Date().toLocaleTimeString()}</span>
`;
container.appendChild(toast);
toast.addEventListener('click', () => toast.remove());
// Auto remove
setTimeout(() => {
toast.style.opacity = '0';
toast.style.transform = 'translateX(20px)';
setTimeout(() => toast.remove(), 300);
}, 5000);
}
// ==========================================
// VIEW MODULES
// ==========================================
// 1. INVENTORY VIEW (Table)
function renderInventory() {
const tableHTML = `
<div class="panel border border-nexus-primary/20 bg-nexus-bg relative mb-4">
<div class="corner-bracket tl"></div><div class="corner-bracket tr"></div>
<div class="corner-bracket bl"></div><div class="corner-bracket br"></div>
<div class="p-4 border-b border-nexus-dim/30 flex justify-between items-center">
<div>
<h2 class="text-lg font-bold text-nexus-primary tracking-widest">SECRET INDEX</h2>
<div class="text-xs text-nexus-dim mt-1">REGISTERED SECRET IDENTIFIERS: ${store.secrets.length}</div>
</div>
<button onclick="rotateRandomSecret()" class="group relative px-4 py-2 bg-nexus-dark border border-nexus-primary text-nexus-primary text-xs font-bold hover:bg-nexus-primary hover:text-black transition-all overflow-hidden shadow-neon-cyan">
<span class="relative z-10">>> ROTATE SELECTED</span>
<div class="absolute inset-0 h-full w-full bg-gradient-to-r from-transparent via-nexus-primary/20 to-transparent -translate-x-full group-hover:animate-[shimmer_1s_infinite]"></div>
</button>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="text-xs text-nexus-dim border-b border-nexus-dim/50 bg-nexus-dark/50">
<th class="p-3 font-bold">STATUS</th>
<th class="p-3 font-bold">ID</th>
<th class="p-3 font-bold">TYPE</th>
<th class="p-3 font-bold">CONSUMERS</th>
<th class="p-3 font-bold">CREATED</th>
<th class="p-3 font-bold">EXPIRES</th>
<th class="p-3 font-bold text-right">ACTION</th>
</tr>
</thead>
<tbody class="text-sm">
${store.secrets.map(sec => {
let statusColor = sec.status === 'ACTIVE' ? 'text-nexus-primary border-nexus-primary' :
sec.status === 'WARNING' ? 'text-nexus-tertiary border-nexus-tertiary' :
'text-red-500 border-red-500';
let statusBg = sec.status === 'ACTIVE' ? 'bg-nexus-primary/10' :
sec.status === 'WARNING' ? 'bg-nexus-tertiary/10' :
'bg-red-500/10';
return `
<tr class="group hover:bg-nexus-dim/5 transition-colors border-b border-nexus-dim/20">
<td class="p-3">
<span class="${statusColor} border px-2 py-0.5 text-xs font-bold uppercase shadow-sm shadow-${sec.status === 'ACTIVE' ? 'nexus-cyan' : sec.status==='WARNING'?'amber':'red'}-500/20">
${sec.status}
</span>
</td>
<td class="p-3 font-mono text-xs text-nexus-dim">${sec.id}</td>
<td class="p-3 font-bold text-white">${sec.name}</td>
<td class="p-3">
<div class="flex flex-wrap gap-1">
${sec.consumers.map(c => `<span class="px-1 py-0.5 bg-nexus-gray border border-nexus-dim/30 text-[10px] text-nexus-secondary/80 rounded">${c}</span>`).join('')}
</div>
</td>
<td class="p-3 font-mono text-xs text-nexus-dim" data-decoding="${sec.created.toISOString()}"></td>
<td class="p-3 font-mono text-xs text-nexus-dim" data-decoding="${sec.expires.toISOString()}"></td>
<td class="p-3 text-right">
<button onclick="triggerRotation('${sec.id}')" class="text-xs border border-nexus-dim text-nexus-dim hover:border-nexus-primary hover:text-nexus-primary bg-nexus-dark p-1 px-2 transition-colors">
ROTATE
</button>
</td>
</tr>
`}).join('')}
</tbody>
</table>
</div>
</div>
`;
return tableHTML;
}
// 2. NETWORK / PROVENANCE VIEW (Canvas)
class NetworkGraph {
constructor(canvasId) {
this.canvas = document.getElementById(canvasId);
this.ctx = this.canvas.getContext('2d');
this.nodes = [];
this.links = [];
this.width = this.canvas.offsetWidth;
this.height = this.canvas.offsetHeight;
this.mouse = { x: -1, y: -1 };
this.initData();
this.resize();
window.addEventListener('resize', () => this.resize());
this.canvas.addEventListener('mousemove', (e) => {
const rect = this.canvas.getBoundingClientRect();
this.mouse.x = e.clientX - rect.left;
this.mouse.y = e.clientY - rect.top;
});
this.animate = this.animate.bind(this);
requestAnimationFrame(this.animate);
}
initData() {
const secrets = store.secrets;
// Add Secret Nodes (Blue)
secrets.forEach((s, i) => {
this.nodes.push({
x: Math.random() * this.width,
y: Math.random() * this.height,
vx: (Math.random() - 0.5) * 0.5,
vy: (Math.random() - 0.5) * 0.5,
radius: 12,
label: s.id,
type: 'secret',
color: '#00f3ff',
secret: s
});
});
// Add Consumer Nodes (Magenta)
const allConsumers = [...new Set(store.secrets.flatMap(s => s.consumers))];
allConsumers.forEach(c => {
this.nodes.push({
x: Math.random() * this.width,
y: Math.random() * this.height,
vx: (Math.random() - 0.5) * 0.5,
vy: (Math.random() - 0.5) * 0.5,
radius: 8,
label: c,
type: 'consumer',
color: '#ff00ff'
});
});
// Create Links
store.secrets.forEach(s => {
const secretNode = this.nodes.find(n => n.type === 'secret' && n.secret.id === s.id);
s.consumers.forEach(c => {
const consumerNode = this.nodes.find(n => n.type === 'consumer' && n.label === c);
if (secretNode && consumerNode) {
this.links.push({
source: secretNode,
target: consumerNode,
opacity: 0.2
});
}
});
});
}
resize() {
const parent = this.canvas.parentElement;
this.canvas.width = parent.clientWidth;
this.canvas.height = parent.clientHeight; // Fixed height for graph
this.width = this.canvas.width;
this.height = this.canvas.height;
}
update() {
// Simple physics
this.nodes.forEach(node => {
node.x += node.vx;
node.y += node.vy;
// Bounce
if (node.x < 20 || node.x > this.width - 20) node.vx *= -1;
if (node.y < 20 || node.y > this.height - 20) node.vy *= -1;
});
// mouse hover repel/effect
this.nodes.forEach(node => {
const dx = this.mouse.x - node.x;
const dy = this.mouse.y - node.y;
const dist = Math.sqrt(dx*dx + dy*dy);
if (dist < 50) {
const force = (50 - dist) / 50;
node.x -= dx * force * 0.05;
node.y -= dy * force * 0.05;
}
});
}
draw() {
this.ctx.clearRect(0, 0, this.width, this.height);
// Draw Links
this.links.forEach(link => {
this.ctx.beginPath();
this.ctx.moveTo(link.source.x, link.source.y);
this.ctx.lineTo(link.target.x, link.target.y);
this.ctx.strokeStyle = `rgba(255, 0, 255, ${this.links.indexOf(link) % 2 === 0 ? 0.1 : 0.4})`; // varied opacity
this.ctx.lineWidth = 1;
this.ctx.stroke();
});
// Draw Nodes
this.nodes.forEach(node => {
// Pulsing glow
const pulse = 1 + Math.sin(Date.now() / 200) * 0.2;
this.ctx.beginPath();
this.ctx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
this.ctx.fillStyle = 'rgba(5, 5, 5, 0.8)';
this.ctx.fill();
this.ctx.lineWidth = 2;
this.ctx.strokeStyle = node.color;
this.ctx.shadowColor = node.color;
this.ctx.shadowBlur = 10 * pulse;
this.ctx.stroke();
this.ctx.shadowBlur = 0;
// Label
this.ctx.fillStyle = '#fff';
this.ctx.font = '10px JetBrains Mono';
this.ctx.textAlign = 'center';
this.ctx.fillText(node.label, node.x, node.y + node.radius + 12);
// Connection count if secret
if (node.type === 'secret') {
this.ctx.fillStyle = '#fff';
this.ctx.font = '10px JetBrains Mono';
this.ctx.fillText(`(${node.secret.consumers.length})`, node.x, node.y + 4);
}
});
}
animate() {
this.update();
this.draw();
requestAnimationFrame(this.animate);
}
}
let networkGraphInstance = null;
// 3. TIMELINE VIEW (Canvas)
class TimelineGraph {
constructor(canvasId) {
this.canvas = document.getElementById(canvasId);
this.ctx = this.canvas.getContext('2d');
this.width = this.canvas.offsetWidth;
this.height = this.canvas.offsetHeight;
this.padding = 60;
this.now = new Date();
this.scrollOffset = 0;
this.targetScrollOffset = 0;
this.resize();
window.addEventListener('resize', () => this.resize());
// Basic scroll listener (for simulation)
this.canvas.parentElement.addEventListener('wheel', (e) => {
this.targetScrollOffset += e.deltaY * 2;
this.targetScrollOffset = Math.max(0, Math.min(this.targetScrollOffset, 1000));
});
this.animate = this.animate.bind(this);
requestAnimationFrame(this.animate);
}
resize() {
this.canvas.width = this.canvas.parentElement.clientWidth;
this.canvas.height = 400; // Fixed height
this.width = this.canvas.width;
this.height = this.canvas.height;
}
drawGrid(ctx, w, h) {
ctx.strokeStyle = 'rgba(0, 243, 255, 0.1)';
ctx.lineWidth = 1;
const step = 40;
for(let x=0; x<w; x+=step) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
for(let y=0; y<h; y+=step) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(w, y);
ctx.stroke();
}
}
animate() {
this.ctx.clearRect(0, 0, this.width, this.height);
this.ctx.save();
this.drawGrid(this.ctx, this.width, this.height);
// Smooth scroll
this.scrollOffset += (this.targetScrollOffset - this.scrollOffset) * 0.1;
const timelineY = 100 + this.scrollOffset;
const nowLineX = this.width / 2;
this.ctx.font = '10px JetBrains Mono';
this.ctx.fillStyle = '#00f3ff';
this.ctx.fillText(`CURRENT T-0 (${(this.now).toISOString().split('T')[0]})`, nowLineX, 30);
// Draw NOW line
this.ctx.beginPath();
this.ctx.moveTo(nowLineX, 50);
this.ctx.lineTo(nowLineX, this.height);
this.ctx.strokeStyle = '#ff00ff';
this.ctx.lineWidth = 2;
this.ctx.setLineDash([5, 5]);
this.ctx.stroke();
this.ctx.setLineDash([]);
// Draw Secrets as bars on the timeline
store.secrets.forEach((s, i) => {
const createdMS = s.created - this.now;
const expiresMS = s.expires - this.now;
// Convert time to pixels (assume 1 day = 20px, future = right, past = left)
const pxPerDay = 10;
const startX = nowLineX + (createdMS / (1000*60*60*24)) * pxPerDay;
const endX = nowLineX + (expiresMS / (1000*60*60*24)) * pxPerDay;
const barY = timelineY + (i % 5) * 30; // Stack a few
// Only draw if within viewport
if (startX > -200 && endX < this.width + 200) {
const isActive = s.status === 'ACTIVE';
const isWarn = s.status === 'WARNING';
// Bar
this.ctx.fillStyle = isActive ? 'rgba(0, 243, 255, 0.3)' : isWarn ? 'rgba(255, 204, 0, 0.3)' : 'rgba(255, 0, 0, 0.2)';
this.ctx.fillRect(startX, barY, endX - startX, 16);
this.ctx.strokeStyle = isActive ? '#00f3ff' : isWarn ? '#ffcc00' : '#ff0000';
this.ctx.strokeRect(startX, barY, endX - startX, 16);
// Label
this.ctx.fillStyle = '#fff';
this.ctx.fillText(s.id + ' (' + s.name + ')', startX, barY - 5);
}
});
this.ctx.restore();
requestAnimationFrame(this.animate);
}
}
let timelineInstance = null;
// 4. AUDIT LOG VIEW
function renderAudit() {
const logs = store.logs.reverse(); // newest first
return `
<div class="panel border border-nexus-primary/20 bg-nexus-bg relative">
<div class="corner-bracket tl"></div><div class="corner-bracket tr"></div>
<div class="corner-bracket bl"></div><div class="corner-bracket br"></div>
<div class="p-4 border-b border-nexus-dim/30">
<h2 class="text-lg font-bold text-nexus-primary tracking-widest">AUDIT LOG</h2>
</div>
<div class="p-4 h-[500px] overflow-y-auto">
<ul class="space-y-2 border-l border-nexus-dim/30 pl-4">
${logs.map(log => `
<li class="relative group">
<span class="absolute -left-[9px] top-2 w-2 h-2 rounded-full bg-nexus-primary group-hover:bg-nexus-secondary transition-colors"></span>
<div class="flex justify-between text-xs mb-1">
<span class="text-nexus-dim font-mono">[${log.timestamp.toISOString()}]</span>
<span class="${log.level === 'WARN' ? 'text-nexus-tertiary' : 'text-nexus-primary'} font-bold">${log.level}</span>
</div>
<div class="text-sm text-gray-300">${log.message}</div>
</li>
`).join('')}
</ul>
</div>
</div>
`;
}
// ==========================================
// APPLICATION LOGIC
// ==========================================
function initApp() {
// Render default view
switchTab('inventory');
// Boot scramble
setTimeout(() => {
document.querySelectorAll('[data-decoding]').forEach(el => {
scrambleText(el, el.getAttribute('data-decoding').split('T')[0].replace(/-/g, '/'), 1500);
});
}, 500);
}
function switchTab(targetId) {
// Update Nav UI
navBtns.forEach(btn => {
if (btn.getAttribute('data-target') === targetId) {
btn.classList.add('bg-nexus-primary/10', 'text-nexus-primary', 'border-l-nexus-primary');
btn.querySelector('.relative.z-10').classList.add('text-nexus-primary');
} else {
btn.classList.remove('bg-nexus-primary/10', 'text-nexus-primary', 'border-l-nexus-primary');
btn.querySelector('.relative.z-10').classList.remove('text-nexus-primary');
}
});
// Render Content
contentArea.innerHTML = ''; // clear
// Apply small decoding fade-in
contentArea.style.opacity = 0;
setTimeout(() => {
let html = '';
switch(targetId) {
case 'inventory':
html = renderInventory();
break;
case 'network':
html = `
<div id="network-container" class="panel border border-nexus-primary/20 bg-nexus-bg relative h-[500px]">
<div class="corner-bracket tl"></div><div class="corner-bracket tr"></div>
<div class="corner-bracket bl"></div><div class="corner-bracket br"></div>
<div class="absolute top-6 left-6">
<h2 class="text-lg font-bold text-nexus-primary tracking-widest">PROVENANCE NETWORK</h2>
<div class="text-xs text-nexus-secondary mt-1">LIVE CONNECTION MAP</div>
</div>
<canvas id="network-canvas" class="absolute inset-0 w-full h-full z-0"></canvas>
</div>`;
break;
case 'timeline':
html = `
<div id="timeline-container" class="panel border border-nexus-primary/20 bg-nexus-bg relative h-[500px]">
<div class="corner-bracket tl"></div><div class="corner-bracket tr"></div>
<div class="corner-bracket bl"></div><div class="corner-bracket br"></div>
<div class="absolute top-6 left-6">
<h2 class="text-lg font-bold text-nexus-primary tracking-widest">ROTATION TIMELINE</h2>
<div class="text-xs text-nexus-secondary mt-1">SCROLL TO SHIFT TIME FRAME</div>
</div>
<canvas id="timeline-canvas" class="absolute inset-0 w-full h-full z-0"></canvas>
</div>`;
break;
case 'audit':
html = renderAudit();
break;
}
contentArea.innerHTML = html;
contentArea.style.opacity = 1;
// Init Canvas instances if needed
if (targetId === 'network') {
networkGraphInstance = new NetworkGraph('network-canvas');
} else if (targetId === 'timeline') {
timelineInstance = new TimelineGraph('timeline-canvas');
}
// Re-run decoding for new elements rendered in Inventory
if (targetId === 'inventory') {
requestAnimationFrame(() => {
document.querySelectorAll('[data-decoding]').forEach(el => {
scrollText(el, el.getAttribute('data-decoding').split('T')[0].replace(/-/g, '/'), 1000);
});
});
}
}, 100);
}
// Helper to animate text scroll (simpler for table)
function scrollText(el, finalText, duration) {
if(!el) return;
let start = 0;
const frames = (duration/1000)*60;
function animate() {
start++;
const progress = Math.min(start/frames, 1);
if(progress === 1) { el.textContent = finalText; return; }
// Show partial
const visible = Math.floor(finalText.length * progress);
el.textContent = finalText.substring(0, visible) + chars.substring(0, (finalText.length-visible)%chars.length).padEnd(finalText.length-visible, 'X').substring(0, finalText.length-visible);
el.textContent = finalText.substring(0, visible).padEnd(finalText.length, chars[Math.floor(Math.random()*chars.length)]);
requestAnimationFrame(animate);
}
animate();
}
// Navigation Event Listeners
navBtns.forEach(btn => {
btn.addEventListener('click', (e) => {
const target = btn.getAttribute('data-target');
switchTab(target);
});
});
// ==========================================
// ACTIONS (Simulation)
// ==========================================
window.triggerRotation = function(secretId) {
const secret = store.secrets.find(s => s.id === secretId);
if (secret) {
// Simulate rotation process
showToast(`Initiating rotation sequence for ${secretId}...`, 'info');
setTimeout(() => {
// Update dates
const oldExpires = secret.expires;
secret.created = new Date();
secret.expires = new Date(secret.created.getTime() + secret.rotationScheduleDays * 24 * 60 * 60 * 1000);
secret.status = 'ACTIVE';
// Log
store.logs.push({
timestamp: new Date(),
level: 'INFO',
message: `Secret ${secretId} rotated. Validity extended.`
});
showToast(`${secretId} rotation complete. New expiry set.`, 'success');
// Refresh view if on inventory
if (contentArea.querySelector('table')) {
switchTab('inventory');
} else if (contentArea.querySelector('#network-canvas')) {
networkGraphInstance.initData(); // Rebuild nodes to reflect changes (though visuals mostly same)
}
}, 1500);
}
};
window.rotateRandomSecret = function() {
const random = store.secrets[Math.floor(Math.random() * store.secrets.length)];
triggerRotation(random.id);
};
// ==========================================
// BOOT
// ==========================================
window.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>