(filePath, expectedHash)
| 115 | } |
| 116 | |
| 117 | async function verifyHash(filePath, expectedHash) { |
| 118 | const actualHash = await calculateSHA256(filePath) |
| 119 | |
| 120 | if (actualHash !== expectedHash) { |
| 121 | throw new Error( |
| 122 | `Hash mismatch!\n` + |
| 123 | `Expected: ${expectedHash}\n` + |
| 124 | `Got: ${actualHash}\n` + |
| 125 | `This could indicate a corrupted download or a security issue.` |
| 126 | ) |
| 127 | } |
| 128 | |
| 129 | return true |
| 130 | } |
| 131 | |
| 132 | function extractBinary(zipPath, binaryName, targetPath) { |
| 133 | const zip = new AdmZip(zipPath) |
no test coverage detected