import { type PathCtx } from '../config/paths.js'; /** * A record of everything that has happened to your logins. * * Losing a login is the most annoying thing this tool can do to you, and until * now it left no trace: a login simply stopped working and the only clue was * being asked to sign in again. This is the trail, so "why did I have to sign in * again?" has an answer instead of a shrug. * * Never contains tokens. Only what happened, to which account, and when. */ export type CredentialEventKind = /** A token was renewed (the old one stops working at that moment). */ 'renewed' /** Renewal was refused for good: this account has to be signed in again. */ | 'needs-login' /** Renewal failed for a reason that may pass (offline, server error). */ | 'renew-failed' /** A credential was written into a profile. */ | 'installed' /** A credential was NOT written, because writing it would have done harm. */ | 'refused' /** A previous credential was put back after something went wrong. */ | 'rolled-back' /** The session was found signed out (a credential with no login in it). */ | 'signed-out'; export interface CredentialEvent { /** When this happened, or when it last happened if it repeated. */ at: number; account: string; kind: CredentialEventKind; detail?: string; /** * How many times in a row the same thing was recorded. Absent means once. * Only ever produced when READING: every occurrence stays in the file, since * this is an audit trail and nothing about it is rewritten. */ count?: number; } /** * Record one credential event. Never throws: logging must not break a swap. * * `count` is deliberately not accepted, and the written record is built field by * field rather than by spreading the caller's object. A count in this file would * be a lie: it is a READ-time summary of how many physical records repeated, so * persisting one would make two records display as many, and an audit trail that * overstates what happened is worse than no trail. */ export declare function logCredentialEvent(event: Omit & { at?: number; }, c?: PathCtx): void; /** The most recent events, oldest first. Unreadable lines are skipped. */ export declare function readCredentialEvents(limit?: number, c?: PathCtx): CredentialEvent[];