snyk-nodejs-lockfile-parser
Version:
Generate a dep tree given a lockfile
22 lines (21 loc) • 993 B
TypeScript
/**
* Convert a lockfile `integrity` (SRI) string into `hash:<algorithm>` labels with
* lowercase-hex values. Returns an empty object (and debug-logs) when the value is absent
* or unparseable — never throws.
*/
export declare function hashLabelsFromIntegrity(integrity: string | undefined, nodeId: string): Record<string, string>;
/**
* Produce a `distribution:url` label from a lockfile `resolved` value when it is an
* http(s) tarball URL. `resolved` can also be a `file:`/workspace path for local deps;
* those are debug-logged and skipped.
*/
export declare function distributionUrlLabel(resolved: string | undefined, nodeId: string): Record<string, string>;
/**
* Build the full set of component-metadata labels (package hashes + distribution URL) for a
* node, sourced from its lockfile `integrity` / `resolved` values.
*/
export declare function getComponentMetadataLabels(node: {
id: string;
integrity?: string;
resolved?: string;
}): Record<string, string>;