MCPcopy
hub / github.com/larksuite/cli / getExpectedChecksum

Function getExpectedChecksum

scripts/install.js:263–286  ·  view source on GitHub ↗
(archiveName, checksumsDir)

Source from the content-addressed store, hash-verified

261}
262
263function getExpectedChecksum(archiveName, checksumsDir) {
264 const dir = checksumsDir || path.join(__dirname, "..");
265 const checksumsPath = path.join(dir, "checksums.txt");
266
267 if (!fs.existsSync(checksumsPath)) {
268 console.error(
269 "[WARN] checksums.txt not found, skipping checksum verification"
270 );
271 return null;
272 }
273
274 const content = fs.readFileSync(checksumsPath, "utf8");
275 for (const line of content.split("\n")) {
276 const trimmed = line.trim();
277 if (!trimmed) continue;
278 const idx = trimmed.indexOf(" ");
279 if (idx === -1) continue;
280 const hash = trimmed.slice(0, idx);
281 const name = trimmed.slice(idx + 2);
282 if (name === archiveName) return hash;
283 }
284
285 throw new Error(`Checksum entry not found for ${archiveName}`);
286}
287
288function verifyChecksum(archivePath, expectedHash) {
289 if (expectedHash === null) return;

Callers 2

installFunction · 0.85
install.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected