import { type SimpleWebAuthnLogger } from '../../helpers/logging.js'; import { MDSCache } from './mdsCache.js'; import { ServiceStateTracker } from './serviceStateTracker.js'; /** * Functionality shared by services that download, cache, and refresh metadata from FIDO * Alliance-style metadata servers (MDS and Convenience MDS.) Subclasses are responsible for * parsing and caching what a server returns. */ export declare abstract class BaseMDSService { protected readonly serviceName: string; protected readonly metadataCache: MDSCache; protected state: ServiceStateTracker; protected logger: Required; /** How many hours to wait to check a server again when it has nothing new to download */ protected readonly defaultRefreshDelayHours = 24; /** How many hours to wait to retry a _failed_ attempt to refresh a server */ protected readonly defaultRetryDelayHours = 3; /** Abort downloads that take longer than this many milliseconds. No limit if left `undefined` */ protected readonly downloadTimeoutMS = 10000; /** * @param serviceName Used in logs, e.g. `"MetadataService"` */ constructor(serviceName: string); /** * Download from the server at `url` (if it has something newer than serial `no`) and cache the * result. Returns the number of entries cached, or `undefined` if nothing was cached (e.g. the * server had nothing new, or responded unsuccessfully.) */ protected abstract downloadAndCache(url: string, no: number): Promise; /** * Called when refreshing a server throws. Implementations can recover from the error (e.g. by * delaying the next refresh) or rethrow it so that lookups depending on the refresh fail. */ protected abstract handleRefreshFailure(url: string, err: unknown): void; /** * Reset the service and move it to the `REFRESHING` state. Call this at the start of * `initialize()`. */ protected beginInitialize(logger?: SimpleWebAuthnLogger): void; /** * Download and cache from each server. A server is only registered for refreshes once data from * it has been cached. One that can't be reached, or that doesn't respond with data, is skipped * so it can't cause lookups of other metadata to fail. * * Returns the number of servers entries were cached from. */ protected initializeServers(mdsServers?: string[]): Promise; /** * Log how much was cached and report the service as ready. Call this at the end of * `initialize()`. */ protected finishInitialize(numLocalFiles?: number, numServers?: number): void; /** * Request data from a server, with a query param that can short-circuit the download if the * latest version is already cached. `no` is the serial number of the last data cached from this * server. * * Returns `undefined` if the server responded with anything other than data, in which case the * next refresh will have been delayed. * * See https://fidoalliance.org/specs/mds/fido-metadata-service-v3.1-ps-20250521.html#sctn-mds-blob-proc-rules */ protected fetchFromServer(url: string, no: number): Promise; /** * Refresh every server whose `nextUpdate` has passed */ protected refreshStaleServers(): Promise; /** * Refresh a single server, subscribing to the refresh already in flight if there is one. * Failures are passed to `handleRefreshFailure()`. */ private serverRefreshes; private refreshServer; /** * Delay the next refresh attempt of this server by the specified number of hours */ protected delayNextRefresh(url: string, numHours: number): void; } //# sourceMappingURL=baseMDSService.d.ts.map