UNPKG

pheonix-pkg-plugin

Version:

Webpack Plugin For the Newer NodeJS v22.9.0 Single Executable Bundling Process Provided By Johnathan Edward Brown! Now includes a Simple Runtime Script Integrity Check! Using SEA assets! With a Binary Tamper Proof Included!

22 lines (18 loc) 794 B
const fs = require('fs'); const path = require('path'); const crypto = require('crypto'); function verifyBinaryIntegrity() { const binaryPath = process.execPath; const binaryContent = fs.readFileSync(binaryPath); const currentHash = crypto.createHash('sha256').update(binaryContent).digest('hex'); const hashFilePath = path.resolve(__dirname, path.basename(binaryPath) + '-hash.txt'); const storedHash = fs.readFileSync(hashFilePath, 'utf8').trim(); if (currentHash !== storedHash) { const hashFilePath = path.resolve(__dirname, 'hash.txt'); const storedHash = fs.readFileSync(hashFilePath, 'utf8').trim(); if (currentHash !== storedHash) { throw new Error('Binary integrity check failed!'); } } } verifyBinaryIntegrity();