powercord-org / powercord

A lightweight @discord client mod focused on simplicity and performance.
MIT License
1.2k stars 147 forks source link

override safeStorage related IPC call for Electron 13 #619

Closed SpencerSharkey closed 2 years ago

SpencerSharkey commented 2 years ago

Discord backported Electron's safeStorage API into their own build, which isn't availble for people using vanilla Electron 13 on linux.

This change gets the app launching again by overriding the event listener.

Original crash bug: image

Fixes #618 probably

cyyynthia commented 2 years ago

Checking against this constant is not the best idea, as it'd disable encryption everywhere including where it'd be supported. A more transparent way of dealing with it would be to append a mock safeStorage to the Electron export proxy in the main thread (where we inject the BrowserWindow) if safeStorage isn't present:

electron.safeStorage || { isEncryptionAvailable: () => false, encryptString: () => { throw new Error('Unavailable') }, decryptString: () => { throw new Error('Unavailable') } }
cyyynthia commented 2 years ago

I implemented my suggested fix in 19f06b4501a7522baf0f03320c9fbe6ab888116e, let me know if it does the trick

KurosakiHT commented 2 years ago

I implemented my suggested fix in 19f06b4, let me know if it does the trick

confirmed this fixed the problem

SpencerSharkey commented 2 years ago

discord added a null check around the safeStorage usage, so this isn’t relevant anymore