MCPcopy
hub / github.com/nodejs/corepack / fetchLatestStableVersion

Function fetchLatestStableVersion

sources/npmRegistryUtils.ts:70–92  ·  view source on GitHub ↗
(packageName: string)

Source from the content-addressed store, hash-verified

68}
69
70export async function fetchLatestStableVersion(packageName: string) {
71 const metadata = await fetchAsJson(packageName, `latest`);
72
73 const {version, dist: {integrity, signatures, shasum}} = metadata;
74
75 if (!shouldSkipIntegrityCheck()) {
76 try {
77 verifySignature({
78 packageName, version,
79 integrity, signatures,
80 });
81 } catch (cause) {
82 // TODO: consider switching to `UsageError` when https://github.com/arcanis/clipanion/issues/157 is fixed
83 throw new Error(`Corepack cannot download the latest stable version of ${packageName}; you can disable signature verification by setting COREPACK_INTEGRITY_CHECK to 0 in your env, or instruct Corepack to use the latest stable release known by this version of Corepack by setting COREPACK_USE_LATEST to 0`, {cause});
84 }
85 }
86
87 return `${version}+${
88 integrity ?
89 `sha512.${Buffer.from(integrity.slice(7), `base64`).toString(`hex`)}` :
90 `sha1.${shasum}`
91 }`;
92}
93
94export async function fetchAvailableTags(packageName: string) {
95 const metadata = await fetchAsJson(packageName);

Callers

nothing calls this directly

Calls 3

shouldSkipIntegrityCheckFunction · 0.90
verifySignatureFunction · 0.85
fetchAsJsonFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…