[multi] Enable contextIsolation in main window #3492
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rebased on top of #3486This makes the final changes and switches on
contextIsolation
for the main window.contextIsolation
is a recommended security feature for electron apps which makes the vm that runs the preload script layer code completely independent from the vm that runs the ipc renderer code. This prevents UI code from modifying data stored in the preload layer.contextIsolation
is currently on by default in electron apps starting on version 12, but we had to turn it off due to the mixed usage of node and electron APIs across Decrediton's UI code. This PR finally completes the migrations necessary to turn it on and enable Decrediton to leverage the security features offered by it.The main change necessary to enable
contextIsolation
introduced by this PR is to change all calls in the wallet package that involve gRPC to use primitive jsObject
instances instead of the gRPC and protobuf class instances. This is necessary because the preload <-> renderer boundary conversion does not copy prototype definitions, only simple values.Care was taken to make the commits reasonably self-contained, so that reviewers can have an easier time reviewing the code changes.
Main changes in this PR:
import Promise
lines which are no longer necessary due to electron version natively suporting it.Object
instead ofElectronLoader
instances.getXXXX()
call to using the correspondingXXXX
field and modifying wallet functions to usetoObject()
to return the response data directly