| 320 | } |
| 321 | |
| 322 | function parseExpectedChecksum(manifest, archiveName) { |
| 323 | let expected = null; |
| 324 | for (const line of manifest.split('\n')) { |
| 325 | const fields = line.trim().split(/\s+/); |
| 326 | if (fields.length < 2) continue; |
| 327 | if (fields[1] !== archiveName && fields[1] !== `*${archiveName}`) continue; |
| 328 | |
| 329 | const digest = fields[0].toLowerCase(); |
| 330 | if (!/^[0-9a-f]{64}$/.test(digest)) { |
| 331 | throw new Error(`Invalid SHA-256 checksum for ${archiveName}`); |
| 332 | } |
| 333 | if (expected !== null && expected !== digest) { |
| 334 | throw new Error(`Conflicting SHA-256 checksums for ${archiveName}`); |
| 335 | } |
| 336 | expected = digest; |
| 337 | } |
| 338 | if (expected === null) { |
| 339 | throw new Error(`No checksum for ${archiveName} in checksums.txt`); |
| 340 | } |
| 341 | return expected; |
| 342 | } |
| 343 | |
| 344 | function verifyCandidate(candidatePath) { |
| 345 | execFileSync(candidatePath, ['--version'], { |