export type SecretStatus = "ok" | "expiring" | "expired"; /** Computes status + days-left for a secret, matching Sloth Manager's original semantics. */ export function computeSecretStatus( expiryDate: string, warnDays: number, now: Date = new Date(), ): { status: SecretStatus; daysLeft: number } { const expiry = new Date(`${expiryDate}T00:00:00Z`); const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())); const daysLeft = Math.round((expiry.getTime() - today.getTime()) / (1000 * 60 * 60 * 24)); let status: SecretStatus; if (daysLeft < 0) status = "expired"; else if (daysLeft <= warnDays) status = "expiring"; else status = "ok"; return { status, daysLeft }; }