mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 17:31:36 -06:00
SEARCH-154 & SEARCH-116
1. Hardcoded the key and userId for now
This commit is contained in:
parent
1f2939545b
commit
8d73e930ed
@ -99,7 +99,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var search = new ssf.Search("testUser1");
|
||||
var search = new ssf.Search("user_data");
|
||||
var buttonEl = document.getElementById('search');
|
||||
var merge = document.getElementById('merge');
|
||||
var buttonIndex = document.getElementById('index');
|
||||
|
@ -27,7 +27,6 @@ class Crypto {
|
||||
this.permanentIndexFolderName = 'search_index_' + userId + '_' + INDEX_VERSION;
|
||||
this.dump = TEMPORARY_PATH;
|
||||
this.extractToPath = `${TEMPORARY_PATH}/data/${this.permanentIndexFolderName}`;
|
||||
this.key = "XrwVgWR4czB1a9scwvgRUNbXiN3W0oWq7oUBenyq7bo="; // temporary only
|
||||
this.encryptedIndex = `${INDEX_DATA_FOLDER + '_' + userId + '_' + INDEX_VERSION}.enc`;
|
||||
this.zipErrored = false;
|
||||
}
|
||||
@ -37,7 +36,7 @@ class Crypto {
|
||||
* removing the data folder and the dump files
|
||||
* @returns {Promise}
|
||||
*/
|
||||
encryption() {
|
||||
encryption(key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (!fs.existsSync(this.indexDataFolder)){
|
||||
@ -60,7 +59,7 @@ class Crypto {
|
||||
const input = fs.createReadStream(`${this.dump}/${this.permanentIndexFolderName}.zip`);
|
||||
const outputEncryption = fs.createWriteStream(this.encryptedIndex);
|
||||
let config = {
|
||||
key: this.key
|
||||
key: key
|
||||
};
|
||||
const encrypt = crypto.encrypt(config);
|
||||
|
||||
@ -99,7 +98,7 @@ class Crypto {
|
||||
* removing the .enc file and the dump files
|
||||
* @returns {Promise}
|
||||
*/
|
||||
decryption() {
|
||||
decryption(key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (!fs.existsSync(this.encryptedIndex)){
|
||||
@ -111,7 +110,7 @@ class Crypto {
|
||||
const input = fs.createReadStream(this.encryptedIndex);
|
||||
const output = fs.createWriteStream(`${this.dump}/decrypted.zip`);
|
||||
let config = {
|
||||
key: this.key
|
||||
key: key
|
||||
};
|
||||
const decrypt = crypto.decrypt(config);
|
||||
|
||||
|
17
js/main.js
17
js/main.js
@ -71,19 +71,6 @@ if (isMac) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for demo purpose only
|
||||
* will be removing this after implementing
|
||||
* in the client-app
|
||||
*/
|
||||
crypto.decryption()
|
||||
.then(function () {
|
||||
// will be handling after implementing client app
|
||||
})
|
||||
.catch(function () {
|
||||
// will be handling after implementing client app
|
||||
});
|
||||
|
||||
/**
|
||||
* This method will be called when Electron has finished
|
||||
* initialization and is ready to create browser windows.
|
||||
@ -111,7 +98,9 @@ app.on('will-quit', function (e) {
|
||||
* will be removing this after implementing
|
||||
* in client-app
|
||||
*/
|
||||
crypto.encryption()
|
||||
// Will be handling this in SEARCH-206
|
||||
let key = "XrwVgWR4czB1a9scwvgRUNbXiN3W0oWq7oUBenyq7bo="; // temporary only
|
||||
crypto.encryption(key)
|
||||
.then(function () {
|
||||
// will be handling after implementing in client app
|
||||
app.exit();
|
||||
|
@ -12,6 +12,10 @@ const isMac = require('../utils/misc.js').isMac;
|
||||
// Search library
|
||||
const libSymphonySearch = require('./searchLibrary');
|
||||
|
||||
// Crypto Library
|
||||
const Cryotp = require('../cryptoLib');
|
||||
const crypto = new Cryotp();
|
||||
|
||||
// Path for the exec file and the user data folder
|
||||
const userData = path.join(app.getPath('userData'));
|
||||
const execPath = path.dirname(app.getPath('exe'));
|
||||
@ -48,14 +52,24 @@ class Search {
|
||||
*/
|
||||
constructor(userId) {
|
||||
this.isInitialized = false;
|
||||
this.userId = userId;
|
||||
this.userId = 'user_data';
|
||||
// Will be handling this in SEARCH-206
|
||||
this.key = "XrwVgWR4czB1a9scwvgRUNbXiN3W0oWq7oUBenyq7bo="; // temporary only
|
||||
this.startIndexingFromDate = (new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR).toString();
|
||||
this.indexFolderName = INDEX_PREFIX + '_' + userId + '_' + INDEX_VERSION;
|
||||
this.dataFolder = INDEX_DATA_FOLDER;
|
||||
this.realTimeIndex = TEMP_REAL_TIME_INDEX;
|
||||
this.batchIndex = TEMP_BATCH_INDEX_FOLDER;
|
||||
this.messageData = [];
|
||||
this.init();
|
||||
this.decryptAndInit();
|
||||
}
|
||||
|
||||
decryptAndInit() {
|
||||
crypto.decryption(this.key).then(() => {
|
||||
this.init();
|
||||
}).catch(() => {
|
||||
this.init();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user