Bug Fixed Network

This commit is contained in:
Luis Fernando Molina committed 2021-10-22 14:47:01 +02:00
1 parent 1326aed521
commit 5712193f72
8 files changed
+26 -21

No files matched your search

+4 -4
View File
@@ -43,7 +43,7 @@ exports.newDesktopApp = function newDesktopApp() {
*/
queryMessage = {
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILES,
emitterUserProfileId: SA.secrets.map.get('Social Trading Desktop').userProfileId,
emitterUserProfileId: SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId,
initialIndex: 'Last',
amountRequested: 10,
direction: 'Past'
@@ -72,7 +72,7 @@ exports.newDesktopApp = function newDesktopApp() {
let eventMessage = {
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
eventType: SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE,
emitterUserProfileId: SA.secrets.map.get('Social Trading Desktop').userProfileId,
emitterUserProfileId: SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId,
targetUserProfileId: profile.userProfileId
}
@@ -97,8 +97,8 @@ exports.newDesktopApp = function newDesktopApp() {
*/
queryMessage = {
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS,
emitterUserProfileId: SA.secrets.map.get('Social Trading Desktop').userProfileId,
targetUserProfileId: SA.secrets.map.get('Social Trading Desktop').userProfileId
emitterUserProfileId: SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId,
targetUserProfileId: SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId
}
query = {
+2 -3
View File
@@ -51,17 +51,16 @@ exports.newDesktopRoot = function newDesktopRoot() {
simpleGit: require('simple-git'),
nodeFetch: require('node-fetch')
}
/*
Setting up Secrets.
*/
SA.secrets = {
array: require('./My-Secrets/Secrets.json'),
array: require('./My-Secrets/Secrets.json').secrets,
map: new Map()
}
for (let i = 0; i < SA.secrets.array.length; i++) {
let secret = SA.secrets.array[i]
SA.secrets.map.set (secret.codeName, secret)
SA.secrets.map.set (secret.signingAccountChildCodeName, secret)
}
run()
+6 -1
View File
@@ -25,7 +25,12 @@ exports.newEnvironment = function () {
PATH_TO_DESKTOP: './Desktop',
PATH_TO_DEFAULT_WORKSPACE: path.join(basePath, './Projects/Foundations/Plugins/Workspaces'),
PATH_TO_MY_WORKSPACES: path.join(basePath, './Platform/My-Workspaces'),
PATH_TO_FONTS: path.join(basePath, './Platform/WebServer/Fonts')
PATH_TO_FONTS: path.join(basePath, './Platform/WebServer/Fonts'),
DESKTOP_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-1',
MOBILE_APP_SIGNING_ACCOUNT: 'Social-Trading-Mobile-App-1',
SERVER_APP_SIGNING_ACCOUNT: 'Social-Trading-Server-App-1',
PLATFORM_APP_SIGNING_ACCOUNT: 'Algo-Traders-Platform-1',
P2P_NETWORK_NODE_SIGNING_ACCOUNT: 'P2P-Network-Node-1',
}
if (process.env.PORTABLE_EXECUTABLE_DIR) {
+2 -2
View File
@@ -52,12 +52,12 @@ exports.newNetworkRoot = function newNetworkRoot() {
Setting up Secrets.
*/
SA.secrets = {
array: require('./My-Secrets/Secrets.json'),
array: require('./My-Secrets/Secrets.json').secrets,
map: new Map()
}
for (let i = 0; i < SA.secrets.array.length; i++) {
let secret = SA.secrets.array[i]
SA.secrets.map.set(secret.codeName, secret)
SA.secrets.map.set(secret.signingAccountChildCodeName, secret)
}
NT.app = require('./Network/NetwokNode.js').newNetworkNode()
@@ -252,11 +252,11 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
*/
let signedMessage = {
callerProfileHandle: messageHeader.callerProfileHandle,
calledProfileHandle: SA.secrets.map.get('P2P Network Node').githubUsername,
calledProfileHandle: SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).userProfileHandle,
callerTimestamp: messageHeader.callerTimestamp,
calledTimestamp: calledTimestamp
}
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get('P2P Network Node').privateKey)
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).privateKey)
let response = {
result: 'Ok',
@@ -345,7 +345,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
We will check that the signature includes this Network Node handle, to avoid
man in the middle attackts.
*/
if (signedMessage.calledProfileHandle !== SA.secrets.map.get('P2P Network Node').githubUsername) {
if (signedMessage.calledProfileHandle !== SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).userProfileHandle) {
let response = {
result: 'Error',
message: 'calledProfileHandle Does Not Match This Network Node Handle.'
@@ -415,6 +415,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
}
function removeCaller(caller) {
if (caller === undefined) { return }
thisObject.callersMap.delete(caller.socket.id)
@@ -86,7 +86,7 @@ exports.newNetworkModulesWebSocketsNetworkClient = function newNetworkModulesWeb
let message = {
messageType: 'Handshake',
callerRole: 'Network Node',
callerProfileHandle: SA.secrets.map.get('Social Trading Desktop').githubUsername,
callerProfileHandle: SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).userProfileHandle,
callerTimestamp: callerTimestamp,
step: 'One'
}
@@ -147,7 +147,7 @@ exports.newNetworkModulesWebSocketsNetworkClient = function newNetworkModulesWeb
We will check that the profile handle we sent to the Network Node, is returned at the
signed message, to avoid man in the middle attackts.
*/
if (signedMessage.callerProfileHandle !== SA.secrets.map.get('Social Trading Desktop').githubUsername) {
if (signedMessage.callerProfileHandle !== SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).userProfileHandle) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node callerProfileHandle does not match my own userProfileHandle.')
reject()
return
@@ -177,7 +177,7 @@ exports.newNetworkModulesWebSocketsNetworkClient = function newNetworkModulesWeb
*/
socketClient.onmessage = socketMessage => { stepTwoResponse(socketMessage) }
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get('Social Trading Desktop').privateKey)
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get(global.env.P2P_NETWORK_NODE_SIGNING_ACCOUNT).privateKey)
let message = {
messageType: 'Handshake',
@@ -86,7 +86,7 @@ exports.newNetworkModulesWebSocketsAppClient = function newNetworkModulesWebSock
let message = {
messageType: 'Handshake',
callerRole: 'Network Client',
callerProfileHandle: SA.secrets.map.get('Social Trading Desktop').githubUsername,
callerProfileHandle: SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileHandle,
callerTimestamp: callerTimestamp,
step: 'One'
}
@@ -147,7 +147,7 @@ exports.newNetworkModulesWebSocketsAppClient = function newNetworkModulesWebSock
We will check that the profile handle we sent to the Network Node, is returned at the
signed message, to avoid man in the middle attackts.
*/
if (signedMessage.callerProfileHandle !== SA.secrets.map.get('Social Trading Desktop').githubUsername) {
if (signedMessage.callerProfileHandle !== SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileHandle) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node callerProfileHandle does not match my own userProfileHandle.')
reject()
return
@@ -177,7 +177,7 @@ exports.newNetworkModulesWebSocketsAppClient = function newNetworkModulesWebSock
*/
socketClient.onmessage = socketMessage => { stepTwoResponse(socketMessage) }
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get('Social Trading Desktop').privateKey)
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileHandle)
let message = {
messageType: 'Handshake',
@@ -47,7 +47,7 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule
}
return JSON.stringify(response)
}
queryMessage.emitterUserProfileId = SA.secrets.map.get('Social Trading Desktop').userProfileId
queryMessage.emitterUserProfileId = SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId
messageHeader.queryMessage = JSON.stringify(queryMessage)
let response
@@ -126,7 +126,7 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule
eventMessage.postText = undefined
}
eventMessage.emitterUserProfileId = SA.secrets.map.get('Social Trading Desktop').userProfileId
eventMessage.emitterUserProfileId = SA.secrets.map.get(global.env.DESKTOP_APP_SIGNING_ACCOUNT).userProfileId
messageHeader.eventMessage = JSON.stringify(eventMessage)
let response = {