/** * Token Status UI - Standalone * Displays token statuses, expiration times, last 4 digits */ class TokenStatusUI { private container: HTMLElement | null = null; private refreshInterval: number | null = null; /** * Create and show token status UI */ create(containerId: string = 'app'): void { this.container = document.getElementById(containerId); if (!this.container) { console.error('[TokenUI] Container not found:', containerId); return; } this.render(); // Refresh UI every second to update expiration countdown this.refreshInterval = window.setInterval(() => { this.render(); }, 1000); } /** * Render token status UI */ private render(): void { if (!this.container) return; const state = this.getState(); const pbStatus = state.pbUser.active ? '✓ Active' : '✗ Inactive'; const pbStatusColor = state.pbUser.active ? '#10b981' : '#ef4444'; const graphStatus = state.graphUser.active ? '✓ Active' : '○ Not Required'; const graphStatusColor = state.graphUser.active ? '#10b981' : '#6b7280'; this.container.innerHTML = `
User: ${state.userDisplayName}
Token: ...${state.pbUser.lastFour}
Expires in: ${state.pbUser.expiresIn}
Token: ...${state.graphUser.lastFour}
Expires in: ${state.graphUser.expiresIn}
` : `Graph token is optional. Login proceeded without it.
`}