Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO: Fix circular dependencies core -> configuration -> rpc -> core
import configuration from 'api/configuration';
import { LoadSettings, UpdateSettings } from 'api/settings';
const statusdelay = 1000;
var prevCoreProcess = 0;
var coreprocess = null;
var responding = false;
var user = 'rpcserver';
//Generate automatic daemon password from machines hardware info
var secret = 'secret';
if (process.platform === 'darwin') {
secret = process.env.USER + process.env.HOME + process.env.SHELL;
} else {
secret = JSON.stringify(macaddress.networkInterfaces(), null, 2);
}
var password = crypto
.createHmac('sha256', secret)
.update('pass')
.digest('hex');
var port = '9336';
var ip = '127.0.0.1';
var host = 'http://' + ip + ':' + port;
var verbose = '2'; // <--Lower to 0 after beta ends
// console.log(process.env.APPDATA);configuration.GetAppDataDirectory();
console.log('core', process.env.HOME);
//Set data directory by OS for automatic daemon mode
// SetCoreParameters: Get the path to local resources for the application (depending on running packaged vs via npm start)
* Settings functionalities that can be used by both
* renderer process and main process code
*/
import path from 'path';
import crypto from 'crypto';
import macaddress from 'macaddress';
import { homeDir, settingsFilePath, defaultCoreDataDir } from 'consts/paths';
import { readJson, writeJson } from 'utils/json';
const defaultBackupDir = path.join(homeDir, '/NexusBackups');
const secret =
process.platform === 'darwin'
? process.env.USER + process.env.HOME + process.env.SHELL
: JSON.stringify(macaddress.networkInterfaces(), null, 2);
const defaultPassword = crypto
.createHmac('sha256', secret)
.update('pass')
.digest('hex');
export const defaultSettings = {
// App
locale: null,
minimizeOnClose: false,
autoUpdate: true,
sendUsageData: true,
fiatCurrency: 'USD',
minConfirmations: 3,
backupDirectory: defaultBackupDir,
devMode: false,
verifyModuleSource: true,
import crypto from 'crypto';
import macaddress from 'macaddress';
import config from 'api/configuration';
import normalizePath from 'utils/normalizePath';
const settingsFileName = 'settings.json';
const defaultBackupDir = normalizePath(config.GetHomeDir() + '/NexusBackups');
const secret =
process.platform === 'darwin'
? process.env.USER + process.env.HOME + process.env.SHELL
: JSON.stringify(macaddress.networkInterfaces(), null, 2);
const defaultPassword = crypto
.createHmac('sha256', secret)
.update('pass')
.digest('hex');
export const defaultSettings = {
// App
locale: 'en',
minimizeOnClose: false,
autoUpdate: true,
sendUsageData: true,
fiatCurrency: 'USD',
minConfirmations: 3,
backupDirectory: defaultBackupDir,
devMode: false,
overviewDisplay: 'standard',
.split('');
for (let index = 0; index < ranByte.length; index++) {
const element = ranByte[index];
if (index % 2) {
randomNumbers[0] += element.charCodeAt(0);
} else {
randomNumbers[1] += element.charCodeAt(0);
}
}
randomNumbers[0] = parseInt(randomNumbers[0]);
randomNumbers[1] = parseInt(randomNumbers[1]);
const randomValue = randomNumbers[0] * randomNumbers[1];
const secret =
process.platform === 'darwin'
? process.env.USER + process.env.HOME + process.env.SHELL + randomValue
: JSON.stringify(macaddress.networkInterfaces(), null, 2) + randomValue;
return crypto
.createHmac('sha256', secret)
.update('pass')
.digest('hex');
}
function setpassword() {
let secret = 'secret';
if (process.platform === 'darwin') {
secret = process.env.USER + process.env.HOME + process.env.SHELL;
} else {
secret = JSON.stringify(macaddress.networkInterfaces(), null, 2);
}
return (
nexusconfig.password ||
crypto
.createHmac('sha256', secret)
.update('pass')
.digest('hex')
);
}
var generateMachineID = function(){
var macNums = macaddress.networkInterfaces();
var unique = '';
_.forOwn(macNums, function(val){
if (val.mac) {
unique += val.mac;
} else if (val.ipv4) {
unique += val.ipv4;
}
});
return 'host-' + crypto.createHash('md5').update(unique).digest('hex').slice(0, 5);
};