/** * SecurityPanel, diagnostics data provider for token scope and rotation audits. * * Wraps an `ApiTokenAuditor` and exposes a snapshot of the current audit state * for the diagnostics view. Consumers subscribe to change notifications and * call `getSnapshot()` to retrieve a fresh rendering-ready view. * * This panel is push-passive: it does not drive timers. Callers trigger audits * by calling `runAudit()`, typically on a schedule or on relevant events. */ import type { ApiTokenAuditor, TokenAuditReport, TokenAuditResult } from '../../../security/token-audit.js'; import type { ComponentConfig } from '../types.js'; /** * Point-in-time snapshot of token security audit state for diagnostics rendering. */ export interface SecurityPanelSnapshot { /** Whether the auditor is running in managed mode. */ managed: boolean; /** Total number of registered tokens. */ totalTokens: number; /** Per-token audit results (most recently audited set). */ results: TokenAuditResult[]; /** Token IDs blocked in managed mode. */ blocked: string[]; /** Token IDs with scope violations. */ scopeViolations: string[]; /** Token IDs with rotation warnings (approaching deadline). */ rotationWarnings: string[]; /** Token IDs with overdue rotation. */ rotationOverdue: string[]; /** Epoch ms when the last audit was run. null if no audit has been run yet. */ lastAuditAt: number | null; /** ISO 8601 timestamp of when this snapshot was captured. */ capturedAt: string; } /** * SecurityPanel, diagnostics data provider for token scope and rotation audits. * * @remarks * Instantiated by the diagnostics bootstrap (deferred wiring pattern, same as * OpsPanel and ForensicsDataPanel). The panel is constructed once during * bootstrap and wired to the application-level `ApiTokenAuditor` instance; * individual callers do not construct it directly. * * Usage: * ```ts * const auditor = new ApiTokenAuditor({ managed: true }); * const panel = new SecurityPanel(auditor); * * panel.subscribe(() => { * const snap = panel.getSnapshot(); * render(snap); * }); * * // Run audit (e.g. on schedule or event): * panel.runAudit(); * * // On cleanup: * panel.dispose(); * ``` */ export declare class SecurityPanel { private readonly _auditor; private readonly _config; private readonly _subscribers; private _lastReport; constructor(auditor: ApiTokenAuditor, config?: ComponentConfig); /** * Run a full audit of all registered tokens and notify subscribers. * Returns the report so callers can emit events or take action. */ runAudit(now?: number): TokenAuditReport; /** * getSnapshot, Returns the current security audit snapshot. * Returns an empty snapshot if no audit has been run yet. */ getSnapshot(): SecurityPanelSnapshot; /** * Register a callback invoked whenever the panel state changes. * @returns An unsubscribe function. */ subscribe(callback: () => void): () => void; /** * Release all subscriptions. */ dispose(): void; private _notify; } //# sourceMappingURL=security.d.ts.map