import type { CredentialRefreshLeaseFence, AuthCredentialStore } from "../auth/store.js"; import type { SqliteAuthCredentialStore } from "../auth/sqlite-credential-store.js"; import type { AuthCredential, DisabledCredentialSummary, OAuthCredential, OAuthRefreshReason, StoredAuthCredential, StoredCredentialBlock } from "../auth/types.js"; import type { OAuthCredentials } from "../registry/oauth/types.js"; import type { Provider } from "../types.js"; import type { ClientUsageIdentity, ObservedUsageEntry, UsageReport } from "../usage.js"; import { type RemoteAuthCredentialStore } from "./remote-store.js"; /** The two stores {@link HybridAuthCredentialStore} splits providers between. */ export interface HybridAuthCredentialStoreOptions { broker: RemoteAuthCredentialStore; local: SqliteAuthCredentialStore; } /** * {@link AuthCredentialStore} over a broker store plus the local SQLite store, * split by provider. Local providers (those `local` lists in * {@link SqliteAuthCredentialStore.listBrokerLocalProviders}) are read, written, * refreshed, and blocked in SQLite; the broker's rows for them are hidden. Every * other provider goes to the broker exactly as with * {@link RemoteAuthCredentialStore}, until an upload for it comes back unserved * ({@link AuthBrokerUnservedProviderError}): then the login is saved locally and * the provider becomes local. Logging out of a local provider's last login * returns it to the broker for the next login. * * Row ids share one number space: a local row carries its SQLite id negated, so * id-only calls (blocks, disables, refresh) route without a provider. * * Limits for local providers: tokens refresh in this process without the durable * cross-process refresh lease (the broker store has none to share), and usage * reports come only from the broker, so local providers report no usage. */ export declare class HybridAuthCredentialStore implements AuthCredentialStore { #private; constructor(opts: HybridAuthCredentialStoreOptions); close(): void; pollExternalChanges(): boolean; acknowledgeLocalChanges(): void; listAuthCredentials(provider?: string): StoredAuthCredential[]; refreshSnapshot(): Promise; listDisabledCredentials(provider?: string, signal?: AbortSignal): Promise; updateAuthCredential(id: number, credential: AuthCredential): void; deleteAuthCredential(id: number, disabledCause: string): Promise; tryDisableAuthCredentialIfMatches(id: number, expectedData: string, disabledCause: string, lease?: CredentialRefreshLeaseFence): boolean; tryUpdateAuthCredentialIfMatches(id: number, expectedData: string, credential: AuthCredential, lease?: CredentialRefreshLeaseFence): boolean; replaceAuthCredentials(provider: string, credentials: AuthCredential[]): Promise; upsertAuthCredential(provider: string, credential: AuthCredential): Promise; deleteAuthCredentials(provider: string, disabledCause: string): Promise; getCache(key: string): string | null; setCache(key: string, value: string, expiresAtSec: number): void; deleteCachePrefix(prefix: string): void; cleanExpiredCache(): void; getCredentialBlock(credentialId: number, providerKey: string, blockScope: string): number | undefined; getCredentialBlockScopes(credentialId: number, providerKey: string): ReadonlyMap; getCredentialBlockReconcileAfter(credentialId: number, providerKey: string, blockScope: string): number | undefined; upsertCredentialBlock(block: StoredCredentialBlock): void; deleteCredentialBlock(credentialId: number, providerKey: string, blockScope: string): void; deleteCredentialBlocks(credentialId: number): void; cleanExpiredCredentialBlocks(nowMs: number): void; listCredentialBlocks(credentialIds: readonly number[]): StoredCredentialBlock[]; recordObservedUsage(entries: ObservedUsageEntry[], client?: ClientUsageIdentity): void; invalidateUsageCache(provider?: string, signal?: AbortSignal): Promise; /** Local rows mint in this process with their real refresh token; broker rows refresh on the broker. */ refreshOAuthCredential(provider: Provider, credentialId: number, credential: OAuthCredential, signal?: AbortSignal, reason?: OAuthRefreshReason): Promise; prepareForRequest(credentialId: number, opts?: { signal?: AbortSignal; }): Promise; fetchUsageReports(signal?: AbortSignal, provider?: Provider): Promise; getUsageReport(provider: Provider, credential: OAuthCredential, signal?: AbortSignal): Promise; ingestUsageReport(provider: Provider, credential: OAuthCredential, report: UsageReport): boolean; markCredentialSuspect(credentialId: number, opts?: { signal?: AbortSignal; }): Promise; }