Forked from vegantostada/signal-password-helper.js
Created
September 22, 2024 09:09
-
-
Save solareon/68ace355ad4db7d7cb546fed9d4eb0ae 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