import type { MetadataBLOBPayloadEntry, MetadataStatement } from '../metadata/mdsTypes.js'; import type { SimpleWebAuthnLogger } from '../helpers/logging.js'; import type { Uint8Array_ } from '../types/index.js'; import type { ProviderMetadata } from '../metadata/convenienceMDSTypes.js'; import { BaseMDSService } from './helpers/baseMDSService.js'; /** * Allow MetadataService to accommodate unregistered AAGUIDs (`"permissive"`), or only allow * registered AAGUIDs (`"strict"`). Currently primarily impacts how `getStatement()` operates */ export type VerificationMode = 'permissive' | 'strict'; interface MetadataService { /** * Prepare the service to handle remote MDS servers and/or cache local metadata statements. * * **Options:** * * @param opts.mdsServers An array of URLs to FIDO Alliance Metadata Service * (version 3.0)-compatible servers. Defaults to the official FIDO MDS server * @param opts.statements An array of local metadata statements. Statements will be loaded but * not refreshed. When combined with `mdsServers`, a statement for the same AAGUID downloaded * from an MDS server will replace the local statement and get refreshed from then on * @param opts.verificationMode How MetadataService will handle unregistered AAGUIDs. Defaults to * `"strict"` which throws errors during registration response verification when an * unregistered AAGUID is encountered. Set to `"permissive"` to allow registration by * authenticators with unregistered AAGUIDs * @param opts.logger An instance of `SimpleWebAuthnLogger` that allows for capturing * MetadataService log output in a project-specific way */ initialize(opts?: { mdsServers?: string[]; statements?: MetadataStatement[]; verificationMode?: VerificationMode; logger?: SimpleWebAuthnLogger; }): Promise; /** * Get additional information about the authenticator associated with the given AAGUID. */ getStatement(aaguid: string | Uint8Array): Promise; /** * Get localized names and icons for the credential provider associated with the given AAGUID. */ getProviderMetadata(aaguid: string | Uint8Array_): Promise; } /** * An implementation of `MetadataService` that can download and parse BLOBs, and support on-demand * requesting and caching of individual metadata statements. * * https://fidoalliance.org/metadata/ */ export declare class BaseMetadataService extends BaseMDSService implements MetadataService { private verificationMode; constructor(); initialize(opts?: { mdsServers?: string[]; statements?: MetadataStatement[]; verificationMode?: VerificationMode; logger?: SimpleWebAuthnLogger; }): Promise; getStatement(aaguid: string | Uint8Array_): Promise; getProviderMetadata(aaguid: string | Uint8Array_): Promise; /** * Download the latest BLOB from MDS, verify it, and cache its entries */ protected downloadAndCache(url: string, no: number): Promise; /** * Refresh failures are rethrown so that lookups fail closed: until the refresh succeeds the * server stays stale, every lookup tries again, and none of them are answered with statements * from the BLOB that was previously cached. */ protected handleRefreshFailure(_url: string, err: unknown): void; /** * Verify and process the MDS metadata blob. Caches metadata and sets up refreshing when blobs * grow stale. `no` is the serial number of the last BLOB cached from this server. * * Returns the number of FIDO2 metadata statements that were cached. */ private verifyBlob; /** * A central place to contain logic and side effects of caching a BLOB entry. Only caches FIDO2 * statements (i.e. ones with `aaguid` as UAF authenticators won't have one.) Returns `1` if the * statement was cached, or `0` if it wasn't (so you can `count += cacheMetadataBlobEntry(...)`) */ private cacheMetadataBlobEntry; } /** * A basic service for coordinating interactions with the FIDO Metadata Service. This includes BLOB * download and parsing, and on-demand requesting and caching of individual metadata statements. * * https://fidoalliance.org/metadata/ */ export declare const MetadataService: MetadataService; export {}; //# sourceMappingURL=metadataService.d.ts.map