({ filePath, crypto, fs, expectedHash, errorMessage })
| 128 | } |
| 129 | |
| 130 | function validateFile ({ filePath, crypto, fs, expectedHash, errorMessage }) { |
| 131 | const hash = crypto.createHmac('md5', 'HMAC_SECRET').update(fs.readFileSync(filePath, 'utf8')).digest('hex') |
| 132 | |
| 133 | if (hash !== expectedHash) { |
| 134 | console.error(errorMessage) |
| 135 | throw new Error(integrityErrorMessage) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | // eslint-disable-next-line @typescript-eslint/no-unused-vars -- binary-sources.js embeds this file as text and calls integrityCheck from there |
| 140 | function integrityCheck (options) { |
no test coverage detected