mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-13 05:37:21 -05:00
remove obfuscation, fix UI scroll stutters, and fix dynamic config loading in updater
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const JavaScriptObfuscator = require('javascript-obfuscator');
|
||||
const AdmZip = require('adm-zip');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
@@ -73,23 +72,6 @@ function cleanBuildDir() {
|
||||
fs.mkdirSync(BUILD_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
function obfuscateFile(filePath, isEsm = false) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
const result = JavaScriptObfuscator.obfuscate(content, {
|
||||
compact: true,
|
||||
controlFlowFlattening: false,
|
||||
deadCodeInjection: false,
|
||||
debugProtection: false,
|
||||
numbersToExpressions: false,
|
||||
simplify: true,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 0.4,
|
||||
stringArrayEncoding: [],
|
||||
module: isEsm
|
||||
});
|
||||
fs.writeFileSync(filePath, result.getObfuscatedCode(), 'utf8');
|
||||
}
|
||||
|
||||
function encryptCredentialsFile() {
|
||||
const CryptoUtils = require('./crypto-utils');
|
||||
|
||||
@@ -170,13 +152,6 @@ function processFolder(src, dest) {
|
||||
if (pkg.type === 'module') isEsm = true;
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
for (const filePath of jsFiles) {
|
||||
try {
|
||||
obfuscateFile(filePath, isEsm);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFileChecksum(filePath) {
|
||||
|
||||
26
main.js
26
main.js
@@ -99,8 +99,21 @@ process.on('unhandledRejection', (reason) => {
|
||||
sendToTauri('error', { message: reason && reason.message ? reason.message : String(reason) });
|
||||
});
|
||||
|
||||
const envConfig = JSON.parse(fs.readFileSync(path.join(__dirname, 'config/env.json'), 'utf8'));
|
||||
const replacementsConfig = JSON.parse(fs.readFileSync(path.join(__dirname, 'config/replacements.json'), 'utf8'));
|
||||
function getEnvConfig() {
|
||||
try {
|
||||
const appPath = path.join(APPDATA_DIR, 'config/env.json');
|
||||
if (fs.existsSync(appPath)) return JSON.parse(fs.readFileSync(appPath, 'utf8'));
|
||||
return JSON.parse(fs.readFileSync(path.join(__dirname, 'config/env.json'), 'utf8'));
|
||||
} catch (e) { return {}; }
|
||||
}
|
||||
|
||||
function getReplacementsConfig() {
|
||||
try {
|
||||
const appPath = path.join(APPDATA_DIR, 'config/replacements.json');
|
||||
if (fs.existsSync(appPath)) return JSON.parse(fs.readFileSync(appPath, 'utf8'));
|
||||
return JSON.parse(fs.readFileSync(path.join(__dirname, 'config/replacements.json'), 'utf8'));
|
||||
} catch (e) { return {}; }
|
||||
}
|
||||
|
||||
const updateClient = new UpdateClient(APPDATA_DIR);
|
||||
|
||||
@@ -109,7 +122,7 @@ async function start() {
|
||||
sendToTauri('status', { message: 'Loading core configuration files...' });
|
||||
|
||||
const patcher = new Patcher(APPDATA_DIR);
|
||||
serviceManager = new ServiceManager(APPDATA_DIR, envConfig);
|
||||
serviceManager = new ServiceManager(APPDATA_DIR, getEnvConfig());
|
||||
|
||||
const installBuild = async (release) => {
|
||||
const tempZipPath = path.join(APPDATA_DIR, 'download-temp.zip');
|
||||
@@ -145,12 +158,14 @@ async function start() {
|
||||
|
||||
debugLog('Extraction complete. Applying patches...');
|
||||
sendToTauri('status', { message: 'Applying configuration patches...' });
|
||||
patcher.applyPatches(replacementsConfig);
|
||||
patcher.applyPatches(getReplacementsConfig());
|
||||
|
||||
sendToTauri('status', { message: 'Migrating security credentials...' });
|
||||
patcher.bridgeCredentials(serviceManager.credentialManager);
|
||||
patcher.saveCurrentVersion(release.version, release.sha256);
|
||||
|
||||
serviceManager.envConfig = getEnvConfig();
|
||||
|
||||
if (fs.existsSync(tempZipPath)) {
|
||||
fs.unlinkSync(tempZipPath);
|
||||
}
|
||||
@@ -244,9 +259,10 @@ async function start() {
|
||||
sendToTauri('status', { message: 'Extracting local baseline payload...' });
|
||||
patcher.purgeOldCode();
|
||||
patcher.extractZipPayload(localZip);
|
||||
patcher.applyPatches(replacementsConfig);
|
||||
patcher.applyPatches(getReplacementsConfig());
|
||||
patcher.bridgeCredentials(serviceManager.credentialManager);
|
||||
patcher.saveCurrentVersion("1.0.0");
|
||||
serviceManager.envConfig = getEnvConfig();
|
||||
debugLog("Local payload extracted successfully.");
|
||||
} else {
|
||||
debugLog("No local payload found!");
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "^2.0.0",
|
||||
"javascript-obfuscator": "^4.1.0"
|
||||
"@tauri-apps/cli": "^2.0.0"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.vyla.home",
|
||||
@@ -55,4 +54,4 @@
|
||||
"installerHeaderIcon": "build/icon.ico"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
patcher.js
38
patcher.js
@@ -2,7 +2,6 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const AdmZip = require('adm-zip');
|
||||
const JavaScriptObfuscator = require('javascript-obfuscator');
|
||||
const CryptoUtils = require('./crypto-utils');
|
||||
|
||||
class Patcher {
|
||||
@@ -141,43 +140,6 @@ class Patcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (ext === '.js') {
|
||||
try {
|
||||
content = JavaScriptObfuscator.obfuscate(content, {
|
||||
compact: true,
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 1,
|
||||
deadCodeInjection: true,
|
||||
deadCodeInjectionThreshold: 0.4,
|
||||
debugProtection: false,
|
||||
disableConsoleOutput: false,
|
||||
identifierNamesGenerator: 'hexadecimal',
|
||||
log: false,
|
||||
numbersToExpressions: true,
|
||||
renameGlobals: false,
|
||||
selfDefending: true,
|
||||
simplify: true,
|
||||
splitStrings: true,
|
||||
splitStringsChunkLength: 5,
|
||||
stringArray: true,
|
||||
stringArrayCallsTransform: true,
|
||||
stringArrayCallsTransformThreshold: 1,
|
||||
stringArrayEncoding: ['rc4'],
|
||||
stringArrayIndexShift: true,
|
||||
stringArrayRotate: true,
|
||||
stringArrayShuffle: true,
|
||||
stringArrayWrappersCount: 5,
|
||||
stringArrayWrappersChainedCalls: true,
|
||||
stringArrayWrappersParametersMaxCount: 5,
|
||||
stringArrayWrappersType: 'function',
|
||||
stringArrayThreshold: 1,
|
||||
transformObjectKeys: true,
|
||||
unicodeEscapeSequence: false
|
||||
}).getObfuscatedCode();
|
||||
modified = true;
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(fullPath, content, 'utf8');
|
||||
}
|
||||
|
||||
@@ -196,17 +196,6 @@ const LINK_HANDLER_SCRIPT: &str = r##"
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = `
|
||||
#vyla-nav-filter-svg {
|
||||
position: fixed !important;
|
||||
top: 0 !important;
|
||||
left: 0 !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
pointer-events: none !important;
|
||||
opacity: 0 !important;
|
||||
z-index: -1 !important;
|
||||
}
|
||||
|
||||
#vyla-floating-nav {
|
||||
position: fixed !important;
|
||||
top: 12px !important;
|
||||
@@ -218,7 +207,7 @@ const LINK_HANDLER_SCRIPT: &str = r##"
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
background: rgba(255, 255, 255, 0.04) !important;
|
||||
backdrop-filter: url(#vyla-glass-filter) blur(16px) saturate(1.8) contrast(1.1) !important;
|
||||
backdrop-filter: blur(16px) saturate(1.8) contrast(1.1) !important;
|
||||
-webkit-backdrop-filter: blur(16px) saturate(1.8) contrast(1.1) !important;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45) !important;
|
||||
transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), padding 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
|
||||
@@ -365,26 +354,6 @@ const LINK_HANDLER_SCRIPT: &str = r##"
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
const filterSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
filterSvg.id = 'vyla-nav-filter-svg';
|
||||
filterSvg.innerHTML = `
|
||||
<defs>
|
||||
<filter id="vyla-glass-filter" color-interpolation-filters="sRGB" x="0%" y="0%" width="100%" height="100%">
|
||||
<feImage id="vyla-nav-fe-img" x="0" y="0" width="100%" height="100%" preserveAspectRatio="none" result="map" />
|
||||
<feDisplacementMap id="vyla-nav-red" in="SourceGraphic" in2="map" result="dispRed" />
|
||||
<feColorMatrix in="dispRed" type="matrix" values="1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0" result="red" />
|
||||
<feDisplacementMap id="vyla-nav-green" in="SourceGraphic" in2="map" result="dispGreen" />
|
||||
<feColorMatrix in="dispGreen" type="matrix" values="0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0" result="green" />
|
||||
<feDisplacementMap id="vyla-nav-blue" in="SourceGraphic" in2="map" result="dispBlue" />
|
||||
<feColorMatrix in="dispBlue" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0" result="blue" />
|
||||
<feBlend in="red" in2="green" mode="screen" result="rg" />
|
||||
<feBlend in="rg" in2="blue" mode="screen" result="output" />
|
||||
<feGaussianBlur in="output" stdDeviation="0.8" />
|
||||
</filter>
|
||||
</defs>
|
||||
`;
|
||||
document.body.appendChild(filterSvg);
|
||||
|
||||
const nav = document.createElement('div');
|
||||
nav.id = 'vyla-floating-nav';
|
||||
nav.innerHTML = `
|
||||
@@ -417,54 +386,6 @@ const LINK_HANDLER_SCRIPT: &str = r##"
|
||||
};
|
||||
}
|
||||
|
||||
const feImage = document.getElementById('vyla-nav-fe-img');
|
||||
const redChannel = document.getElementById('vyla-nav-red');
|
||||
const greenChannel = document.getElementById('vyla-nav-green');
|
||||
const blueChannel = document.getElementById('vyla-nav-blue');
|
||||
|
||||
function generateNavMap() {
|
||||
const rect = nav.getBoundingClientRect();
|
||||
const w = Math.round(rect.width) || 42;
|
||||
const h = Math.round(rect.height) || 42;
|
||||
const edgeSize = Math.min(w, h) * 0.08;
|
||||
const svgContent = `
|
||||
<svg viewBox="0 0 ${w} ${h}" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="vyla-nav-red-g" x1="100%" y1="0%" x2="0%" y2="0%">
|
||||
<stop offset="0%" stop-color="#000000" stop-opacity="0"/>
|
||||
<stop offset="100%" stop-color="red"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="vyla-nav-blue-g" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#000000" stop-opacity="0"/>
|
||||
<stop offset="100%" stop-color="blue"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="${w}" height="${h}" fill="black"/>
|
||||
<rect width="${w}" height="${h}" rx="9999" fill="url(#vyla-nav-red-g)"/>
|
||||
<rect width="${w}" height="${h}" rx="9999" fill="url(#vyla-nav-blue-g)" style="mix-blend-mode: screen;"/>
|
||||
<rect x="${edgeSize}" y="${edgeSize}" width="${w - edgeSize * 2}" height="${h - edgeSize * 2}" rx="9999" fill="rgba(255,255,255,0.4)" style="filter: blur(4px);"/>
|
||||
</svg>
|
||||
`;
|
||||
return "data:image/svg+xml," + encodeURIComponent(svgContent);
|
||||
}
|
||||
|
||||
function updateNavGlass() {
|
||||
if (!feImage) return;
|
||||
feImage.setAttribute("href", generateNavMap());
|
||||
const distortionScale = -180;
|
||||
redChannel.setAttribute("scale", distortionScale - 10);
|
||||
greenChannel.setAttribute("scale", distortionScale);
|
||||
blueChannel.setAttribute("scale", distortionScale + 10);
|
||||
[redChannel, greenChannel, blueChannel].forEach((ch) => {
|
||||
ch.setAttribute("xChannelSelector", "R");
|
||||
ch.setAttribute("yChannelSelector", "G");
|
||||
});
|
||||
}
|
||||
|
||||
updateNavGlass();
|
||||
const obs = new ResizeObserver(() => setTimeout(updateNavGlass, 0));
|
||||
obs.observe(nav);
|
||||
|
||||
const tb = document.createElement('div');
|
||||
tb.id = 'tauri-custom-titlebar';
|
||||
tb.innerHTML = `
|
||||
@@ -610,7 +531,7 @@ fn main() {
|
||||
get_logo_base64
|
||||
])
|
||||
.manage(NodeServices(Mutex::new(None)))
|
||||
.setup(|app| {
|
||||
.setup(|app| {
|
||||
debug_log("Tauri setup started");
|
||||
let app_data = app.path().app_data_dir().unwrap_or_default();
|
||||
let app_data_str = clean_path(&app_data);
|
||||
@@ -619,7 +540,7 @@ fn main() {
|
||||
.title("Vyla Home")
|
||||
.inner_size(1280.0, 800.0)
|
||||
.decorations(false)
|
||||
.transparent(true)
|
||||
.transparent(false)
|
||||
.resizable(true)
|
||||
.devtools(cfg!(debug_assertions))
|
||||
.initialization_script("window.__VYLA_WINDOW_LABEL = 'main';")
|
||||
|
||||
Reference in New Issue
Block a user