apm
apm copied to clipboard
Sandboxing the renderer process
Since Election 20.0.0, renderers are sandboxed by default. So, we have to think of sandboxing the renderer process.
Reference
https://zenn.dev/sprout2000/books/6f6a0bf2fd301c/viewer/13319 https://developer.mamezou-tech.com/blogs/2022/08/03/electron-renderer-process-sandboxed/
The fs-extra, os and electron->shell referenced by preload.ts are affected.
It is necessary to refactor the lib folder into two folders, one for the main process and one for the renderer process.
Related to this PR, the idea of #317 may be helpful.
If we do this, we can't use electron-log until the feature(https://github.com/megahertz/electron-log/issues/267) is added.
And, there is some problem to do this...
When I use import, the preload script use __dirname and causes an error...
I think webpack causes this problem but I don't know anymore......
- https://github.com/electron/forge/issues/2931
- https://github.com/electron/forge/issues/2939
In electron/forge#2931, a new issue was created and I might find a suggestion in a pull request.
- https://github.com/electron/forge/issues/3055
- https://github.com/electron/forge/pull/3060
I might find the cause.
The cache of webpack-asset-relocator-loader might be the cause.
I change not to run initAssetCache for the renderer process, then the preload script works fine.
But I don't know whether this is the correct fix......
Note: https://code.visualstudio.com/blogs/2022/11/28/vscode-sandbox
electron-log v5 (it's beta now) will support the sandbox of the renderer process.
https://github.com/megahertz/electron-log