This commit is contained in:
odzugkoev
2026-03-01 17:10:03 -05:00
parent 7e0887c62d
commit 85cf732a61
19 changed files with 2284 additions and 32 deletions

View File

@@ -74,8 +74,7 @@ class ConfigManager {
try {
const value = database.getConfig(key);
// Decrypt token if it's the auth token
if (key === 'authToken' && value) {
if ((key === 'authToken' || key === 'previousAuthToken') && value) {
return this.decrypt(value);
}
@@ -88,8 +87,7 @@ class ConfigManager {
set(key, value) {
try {
// Encrypt token if it's the auth token
if (key === 'authToken' && value) {
if ((key === 'authToken' || key === 'previousAuthToken') && value) {
value = this.encrypt(value);
}
@@ -103,10 +101,12 @@ class ConfigManager {
try {
const config = database.getConfig();
// Decrypt auth token if present
if (config.authToken) {
config.authToken = this.decrypt(config.authToken);
}
if (config.previousAuthToken) {
config.previousAuthToken = this.decrypt(config.previousAuthToken);
}
return config;
} catch (error) {
@@ -117,10 +117,12 @@ class ConfigManager {
setMultiple(configObj) {
try {
// Encrypt auth token if present
if (configObj.authToken) {
configObj.authToken = this.encrypt(configObj.authToken);
}
if (configObj.previousAuthToken) {
configObj.previousAuthToken = this.encrypt(configObj.previousAuthToken);
}
database.setConfigMultiple(configObj);
} catch (error) {
@@ -149,6 +151,7 @@ class ConfigManager {
try {
this.set('authToken', '');
this.set('tokenExpiry', '');
this.set('previousAuthToken', '');
} catch (error) {
console.error('Failed to clear auth:', error.message);
}