Last active
February 11, 2025 11:52
-
-
Save vegantostada/a535f878056078a6659e98a4e33f25f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, safeStorage } = require('electron'); | |
const { join } = require('node:path'); | |
const { readFileSync, writeFileSync } = require('node:fs'); | |
const folder = join(app.getPath('appData'), 'Signal'); | |
app.setPath('userData', folder); | |
app.setName('Signal'); | |
app.on('ready', () => { | |
const configPath = join(folder, 'config.json'); | |
const json = readFileSync(configPath, 'utf8'); | |
// Save backup | |
writeFileSync(join(folder, 'config.json.bak'), json); | |
const config = JSON.parse(json); | |
if (!config.encryptedKey) { | |
console.error('Already decrypted'); | |
app.quit(1); | |
return; | |
} | |
const encryptedKey = Buffer.from(config.encryptedKey, 'hex'); | |
const decrypted = safeStorage.decryptString(encryptedKey); | |
const newConfig = { | |
...config, | |
encryptedKey: undefined, | |
key: decrypted, | |
}; | |
const newJson = JSON.stringify(newConfig, null, 2); | |
writeFileSync(configPath, newJson); | |
console.log('Success'); | |
app.quit(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment