|
|
@@ -10,7 +10,6 @@ let memoryCache = {};
|
|
|
|
|
|
// Function to decrypt a file and store its content in memory
|
|
|
function decryptFile(filePath) {
|
|
|
- // console.log(`Decrypting: ${filePath}`);
|
|
|
const fileContent = fs.readFileSync(filePath);
|
|
|
const iv = fileContent.slice(0, 16); // Extract IV
|
|
|
const encrypted = fileContent.slice(16); // Extract encrypted data
|
|
|
@@ -18,7 +17,6 @@ function decryptFile(filePath) {
|
|
|
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
|
const relativePath = path.relative(process.resourcesPath, filePath).replace(/\\/g, '/');
|
|
|
memoryCache[relativePath] = decrypted;
|
|
|
- // console.log(`Decrypted: ${filePath}, content: ${decrypted.slice(0, 100)}`);
|
|
|
}
|
|
|
|
|
|
// Recursively decrypt files in a directory and store their content in memory
|
|
|
@@ -26,7 +24,6 @@ function decryptDirectory(directoryPath) {
|
|
|
const files = fs.readdirSync(directoryPath);
|
|
|
files.forEach(file => {
|
|
|
const fullPath = path.join(directoryPath, file);
|
|
|
- // console.log(`Processing: ${fullPath}`);
|
|
|
if (fs.lstatSync(fullPath).isDirectory()) {
|
|
|
decryptDirectory(fullPath);
|
|
|
} else {
|
|
|
@@ -37,17 +34,15 @@ function decryptDirectory(directoryPath) {
|
|
|
|
|
|
function createWindow() {
|
|
|
const directoryToDecrypt = path.join(process.resourcesPath, 'app.asar', 'static');
|
|
|
- // console.log(`Decrypting directory: ${directoryToDecrypt}`);
|
|
|
decryptDirectory(directoryToDecrypt);
|
|
|
|
|
|
// Load index.html into memory
|
|
|
const indexPath = path.join(process.resourcesPath, 'app.asar', 'index.html');
|
|
|
const indexRelativePath = path.relative(process.resourcesPath, indexPath).replace(/\\/g, '/');
|
|
|
memoryCache[indexRelativePath] = fs.readFileSync(indexPath);
|
|
|
- // console.log(`index: ${indexRelativePath}, content: ${memoryCache[indexRelativePath].slice(0, 100)}`);
|
|
|
|
|
|
// Register a custom protocol to serve content from memory
|
|
|
- protocol.interceptBufferProtocol('file', (request, callback) => {
|
|
|
+ protocol.registerBufferProtocol('file', (request, callback) => {
|
|
|
const url = request.url.substr(7); // Remove 'file://' prefix
|
|
|
const relativePath = path.relative(process.resourcesPath, url).replace(/\\/g, '/');
|
|
|
console.log(`Intercepting request for: ${relativePath}`);
|