slate: removes electron vulunerabilities

This commit is contained in:
@wwwjim 2020-11-25 10:13:24 -08:00
parent 021a0a4354
commit 0378ec0938
6 changed files with 1 additions and 9130 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +0,0 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require("electron");
const path = require("path");
const fs = require("fs-extra");
// NOTE(colin): use NEXTJS Production build
if (process.env.NODE_ENV == undefined) process.env.NODE_ENV = "production";
// NOTE(colin): allow API connection
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED == undefined)
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
function bootServer() {
// TODO(colin): Spin up server on a child process
// const { fork } = require('child_process');
// const ps = fork(path.join(__dirname, '../', 'index.js'));
require(path.join(__dirname, "../", "index.js"));
// console.log("server running");
}
function fileOverrides() {
fs.copy(
path.join(__dirname, "./google-protobuf.js"),
path.join(__dirname, "../node_modules/google-protbuf/google-protobuf.js"),
(err) => {
if (err) throw err;
console.log("google-protobuf.js was copied to node_modules folder");
}
);
}
// require(path.join(__dirname, "../nodedistribution/", "main.js"));
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true,
experimentalFeatures: true,
},
});
// Open the DevTools.
mainWindow.webContents.openDevTools();
// and load the index.html of the app.
// TODO(jim):
// We shouldn't hardcode this port.
mainWindow.loadURL("http://localhost:1337/_");
console.log("window created");
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
fileOverrides();
bootServer();
createWindow();
app.on("activate", function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

View File

@ -1,12 +0,0 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener("DOMContentLoaded", () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector);
if (element) element.innerText = text;
};
for (const type of ["chrome", "node", "electron"]) {
replaceText(`${type}-version`, process.versions[type]);
}
});

View File

@ -1,6 +0,0 @@
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.

View File

@ -1,5 +1,6 @@
const path = require("path");
const dirPath = path.join(__dirname);
require("@babel/register")({
presets: [
[require.resolve("@babel/preset-env")],
@ -14,7 +15,6 @@ require("@babel/register")({
],
],
plugins: [
[require.resolve("@babel/plugin-transform-runtime")],
[
require.resolve("babel-plugin-module-resolver"),
{

View File

@ -10,33 +10,17 @@
"scripts": {
"dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 node . --unhandled-rejections=strict --max-old-space-size=8192",
"start": "NODE_ENV=production node . --unhandled-rejections=strict --max-old-space-size=8192",
"build-delete": "rm -rf .next && rm -rf dist/mac",
"build": "NODE_ENV=production next build",
"build-system": "rollup -c",
"electron-dev": "NODE_ENV=development electron ./electron/main.js ",
"electron-prod": "NODE_ENV=production next build && electron-builder --dir",
"scripts": "NODE_TLS_REJECT_UNAUTHORIZED=0 node --max-old-space-size=8192 ./scripts",
"www-setup-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts setup-database",
"www-seed-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts seed-database"
},
"build": {
"appId": "com.slate",
"productName": "slate",
"mac": {
"icon": " build/icon.icns",
"asar": "false"
},
"extraMetadata": {
"main": "./electron/main.js"
}
},
"repository": "filecoin-project/slate",
"dependencies": {
"@babel/core": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.5",
"@emotion/babel-preset-css-prop": "10.1.0",
"@emotion/core": "10.1.1",
"@glif/filecoin-number": "^1.0.0-beta.5",
@ -70,7 +54,6 @@
"react-blurhash": "github:zeroxme/react-blurhash#master",
"react-dom": "^16.12.0",
"react-draggable": "^4.4.3",
"regenerator-runtime": "^0.13.7",
"remark-emoji": "^2.1.0",
"remark-gfm": "^1.0.0",
"remark-linkify-regex": "^1.0.0",
@ -85,8 +68,6 @@
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.1.0",
"electron": "^9.0.5",
"electron-builder": "^22.7.0",
"rollup": "^2.18.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",