Commit 6467175e authored by Eriksson Monteiro's avatar Eriksson Monteiro

update tangled browser ui

parent 8b952e86
This diff is collapsed.
const CONST_VALUE_DEFAULT = { const CONST_VALUE_DEFAULT = {
'MODE_DEBUG' : false, 'MODE_DEBUG' : false,
'MODE_TEST_NETWORK' : true, 'MODE_TEST_NETWORK' : false,
'NODE_MILLIX_BUILD_DATE' : 1660820789, 'NODE_MILLIX_BUILD_DATE' : 1660831931,
'NODE_MILLIX_VERSION' : '1.20.4-testnet', 'NODE_MILLIX_VERSION' : '1.20.4',
'DATA_BASE_DIR_MAIN_NETWORK': './millix-tangled-testnet', 'DATA_BASE_DIR_MAIN_NETWORK': './millix',
'DATA_BASE_DIR_TEST_NETWORK': './millix-tangled-testnet', 'DATA_BASE_DIR_TEST_NETWORK': './millix-testnet',
'DEBUG_LOG_FILTER' : [] 'DEBUG_LOG_FILTER' : [],
'NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK': 6000,
'NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK': 8000,
'NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK': 6001,
'NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK': 8001,
'CONSENSUS_ROUND_NODE_COUNT' : 12,
'CONSENSUS_ROUND_VALIDATION_REQUIRED': 3,
'CONSENSUS_ROUND_VALIDATION_MAX' : 3,
'CONSENSUS_ROUND_NOT_FOUND_MAX' : 3,
'CONSENSUS_ROUND_DOUBLE_SPEND_MAX' : 3,
'CONSENSUS_VALIDATION_WAIT_TIME_MAX': 15 * 1000
}; };
let environment; let environment;
...@@ -40,10 +53,10 @@ export const NODE_PORT_MAIN_NETWORK = 10000; ...@@ -40,10 +53,10 @@ export const NODE_PORT_MAIN_NETWORK = 10000;
export const NODE_PORT_TEST_NETWORK = 30000; export const NODE_PORT_TEST_NETWORK = 30000;
export const NODE_PORT_DISCOVERY_TEST_NETWORK = 4000; export const NODE_PORT_DISCOVERY_TEST_NETWORK = 4000;
export const NODE_PORT_DISCOVERY_MAIN_NETWORK = 2000; export const NODE_PORT_DISCOVERY_MAIN_NETWORK = 2000;
export const NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK = 6000; export const NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK = getConstValue('NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK');
export const NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK = 8000; export const NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK = getConstValue('NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK');
export const NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK = 6001; export const NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK = getConstValue('NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK');
export const NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK = 8001; export const NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK = getConstValue('NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK');
export const NODE_PORT_STORAGE_RECEIVER = MODE_TEST_NETWORK ? NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK : NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK; export const NODE_PORT_STORAGE_RECEIVER = MODE_TEST_NETWORK ? NODE_PORT_STORAGE_RECEIVER_TEST_NETWORK : NODE_PORT_STORAGE_RECEIVER_MAIN_NETWORK;
export const NODE_PORT_STORAGE_PROVIDER = MODE_TEST_NETWORK ? NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK : NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK; export const NODE_PORT_STORAGE_PROVIDER = MODE_TEST_NETWORK ? NODE_PORT_STORAGE_PROVIDER_TEST_NETWORK : NODE_PORT_STORAGE_PROVIDER_MAIN_NETWORK;
export const NODE_PORT_DISCOVERY = MODE_TEST_NETWORK ? NODE_PORT_DISCOVERY_TEST_NETWORK : NODE_PORT_DISCOVERY_MAIN_NETWORK; export const NODE_PORT_DISCOVERY = MODE_TEST_NETWORK ? NODE_PORT_DISCOVERY_TEST_NETWORK : NODE_PORT_DISCOVERY_MAIN_NETWORK;
...@@ -757,14 +770,14 @@ export const NODE_CONNECTION_INBOUND_WHITELIST = []; ...@@ -757,14 +770,14 @@ export const NODE_CONNECTION_INBOUND_WHITELIST = [];
export const NODE_CONNECTION_OUTBOUND_WHITELIST = []; export const NODE_CONNECTION_OUTBOUND_WHITELIST = [];
export const NODE_CONNECTION_STATIC = []; export const NODE_CONNECTION_STATIC = [];
export const NODE_INITIAL_LIST = MODE_TEST_NETWORK ? NODE_INITIAL_LIST_TEST_NETWORK : NODE_INITIAL_LIST_MAIN_NETWORK; export const NODE_INITIAL_LIST = MODE_TEST_NETWORK ? NODE_INITIAL_LIST_TEST_NETWORK : NODE_INITIAL_LIST_MAIN_NETWORK;
export const CONSENSUS_ROUND_NODE_COUNT = 2; export const CONSENSUS_ROUND_NODE_COUNT = getConstValue('CONSENSUS_ROUND_NODE_COUNT');
export const CONSENSUS_ROUND_VALIDATION_REQUIRED = 1; export const CONSENSUS_ROUND_VALIDATION_REQUIRED = getConstValue('CONSENSUS_ROUND_VALIDATION_REQUIRED');
export const CONSENSUS_ROUND_VALIDATION_MAX = 3; export const CONSENSUS_ROUND_VALIDATION_MAX = getConstValue('CONSENSUS_ROUND_VALIDATION_MAX');
export const CONSENSUS_ROUND_NOT_FOUND_MAX = 3; export const CONSENSUS_ROUND_NOT_FOUND_MAX = getConstValue('CONSENSUS_ROUND_NOT_FOUND_MAX');
export const CONSENSUS_ROUND_DOUBLE_SPEND_MAX = 3; export const CONSENSUS_ROUND_DOUBLE_SPEND_MAX = getConstValue('CONSENSUS_ROUND_DOUBLE_SPEND_MAX');
export const CONSENSUS_VALIDATION_DEPTH_MAX = 50; export const CONSENSUS_VALIDATION_DEPTH_MAX = 50;
export const CONSENSUS_VALIDATION_REQUEST_DEPTH_MAX = 100; export const CONSENSUS_VALIDATION_REQUEST_DEPTH_MAX = 100;
export const CONSENSUS_VALIDATION_WAIT_TIME_MAX = 15 * 1000; export const CONSENSUS_VALIDATION_WAIT_TIME_MAX = getConstValue('CONSENSUS_VALIDATION_WAIT_TIME_MAX');
export const CONSENSUS_VALIDATION_RETRY_WAIT_TIME = 10 * 1000; export const CONSENSUS_VALIDATION_RETRY_WAIT_TIME = 10 * 1000;
export const CONSENSUS_VALIDATION_PARALLEL_PROCESS_MAX = 2; export const CONSENSUS_VALIDATION_PARALLEL_PROCESS_MAX = 2;
export const CONSENSUS_VALIDATION_PARALLEL_REQUEST_MAX = 2; export const CONSENSUS_VALIDATION_PARALLEL_REQUEST_MAX = 2;
......
...@@ -254,30 +254,32 @@ class FileManager { ...@@ -254,30 +254,32 @@ class FileManager {
} }
getBufferByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey = null) { getBufferByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey = null) {
return this.getAttributesByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey).then(([attributes, data]) => { return this.getAttributesByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey).then(([attributes, data]) => this.getDecryptedBuffer(attributes, data, attributeTypeId, fileHash, fileKey));
for (const attribute of attributes) { }
attribute.value = JSON.parse(attribute.value);
if (attribute.attribute_type_id === this.normalizationRepository.get('transaction_output_metadata')) {
const file = _.find(attribute.value.file_list, file => file.hash === fileHash);
if (!file) {
return Promise.reject('file_not_found');
}
const key = fileKey ? Buffer.from(fileKey, 'hex') : file.key || file[wallet.defaultKeyIdentifier]?.key; getDecryptedBuffer(attributes, transactionData, attributeTypeId, fileHash, fileKey = null) {
for (const attribute of attributes) {
attribute.value = JSON.parse(attribute.value);
if (attribute.attribute_type_id === this.normalizationRepository.get('transaction_output_metadata')) {
const file = _.find(attribute.value.file_list, file => file.hash === fileHash);
if (!file) {
return Promise.reject('file_not_found');
}
if (!key) { const key = fileKey ? Buffer.from(fileKey, 'hex') : file.key || file[wallet.defaultKeyIdentifier]?.key;
return Promise.reject('decrypt_key_not_found');
}
const dataType = file.type || 'json'; if (!key) {
return this.decryptFile(data.address_key_identifier_from, data.transaction_date, data.transaction_id, file.hash, key, !!fileKey || file.public).then(fileData => ({ return Promise.reject('decrypt_key_not_found');
file_data: fileData,
mime_type: file.mime_type,
data_type: dataType
}));
} }
const dataType = file.type || 'json';
return this.decryptFile(transactionData.address_key_identifier_from, transactionData.transaction_date, transactionData.transaction_id, file.hash, key, !!fileKey || file.public).then(fileData => ({
file_data : fileData,
mime_type : file.mime_type,
data_type : dataType
}));
} }
}); }
} }
getBufferMetaByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey = null) { getBufferMetaByTransactionAndFileHash(transactionId, addressKeyIdentifier, attributeTypeId, fileHash, fileKey = null) {
...@@ -321,7 +323,7 @@ class FileManager { ...@@ -321,7 +323,7 @@ class FileManager {
}); });
}).then(attributes => { }).then(attributes => {
for (const attribute of attributes) { for (const attribute of attributes) {
if (attribute.attribute_type_id === this.normalizationRepository.get('transaction_output_metadata')) { if (attribute.attribute_type_id === database.getRepository('normalization').get('transaction_output_metadata')) {
attribute.value = JSON.parse(attribute.value); attribute.value = JSON.parse(attribute.value);
const file = _.find(attribute.value.file_list, file => file.hash === fileHash); const file = _.find(attribute.value.file_list, file => file.hash === fileHash);
if (!file) { if (!file) {
...@@ -468,9 +470,10 @@ class FileManager { ...@@ -468,9 +470,10 @@ class FileManager {
if (file.type.endsWith('_meta') && file.name.endsWith('_meta')) { if (file.type.endsWith('_meta') && file.name.endsWith('_meta')) {
const dataFileName = file.name.substring(0, file.name.length - 5); const dataFileName = file.name.substring(0, file.name.length - 5);
keySet[file.name] = keySet[dataFileName]; keySet[file.name] = keySet[dataFileName];
fileCipher = crypto.createCipher('aes-256-cbc', keySet[file.name]); fileCipher = crypto.createCipher('aes-256-cbc', keySet[file.name]);
} else { }
else {
fileCipher = crypto.createCipher('aes-256-cbc', keySet[file.name]); fileCipher = crypto.createCipher('aes-256-cbc', keySet[file.name]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment