import { LRUCache } from 'lru-cache'; import type { DepID } from '@vltpkg/dep-id'; import type { PackageReportData, SecurityArchiveLike, SecurityArchiveRefreshOptions } from './types.ts'; export * from './types.ts'; export declare const targetSecurityRegisty = "https://registry.npmjs.org/"; export type JSONItemResponse = { namespace?: `@{string}`; name: string; version: string; score: { overall: number; license: number; maintenance: number; quality: number; supplyChain: number; vulnerability: number; }; }; export type DBReadEntry = { depID: string; now: number; report: string; start: number; ttl: number; }; export type DBWriteEntry = [string, string, number, number]; export type SecurityArchiveOptions = LRUCache.OptionsBase & { /** * Security archive does not supports a fetch-on-demand model. */ fetchMethod?: undefined; /** * An optional value for the path in which to store the sqlite db. */ path?: string; /** * Number of retries attempts to reach the remote security API. */ retries?: number; }; export declare const version: string; /** * A database of security information for given packages from a list of nodes. * * Using the SecurityArchive.refresh() method will update the local cache * with information from the socket.dev APIs or load from the local storage * if available. Information about package security is then available * using the SecurityArchive.get() method. */ export declare class SecurityArchive extends LRUCache implements SecurityArchiveLike { #private; /** * True if the refresh process was successful and report data is available * for all public registry packages from the initial list of nodes. */ ok: boolean; /** * Creates a new security archive instance and starts the refresh process. */ static start(options: SecurityArchiveOptions & SecurityArchiveRefreshOptions): Promise; /** * By default, limits to 100K entries in the in-memory archive. */ static get defaultMax(): number; /** * By default, entries are cached for 3 hours. */ static get defaultTtl(): number; constructor(options?: SecurityArchiveOptions); /** * Starts the security archive by providing an array of {@link NodeLike} instances, * its registry-based nodes are going to be used as valid potential entries. * * Any entry that is missing from the persisted cached values are going * to be requested in a batch-request to the remote socket.dev API. */ refresh({ nodes }: SecurityArchiveRefreshOptions): Promise; /** * Outputs the current in-memory cache as a JSON object. */ toJSON(): Record; }