SEARCH-116-GCM

1. Fixed userData path issue
This commit is contained in:
Keerthi Niranjan 2017-08-22 12:45:06 +05:30 committed by Keerthi Niranjan
parent b36b546c3d
commit 8c1c599699
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,8 @@ let validateAndConvertKey = function(key) {
if (key && key instanceof Buffer && key.length === KEY_LENGTH) {
return key;
} else if (key && typeof key === 'string') {
// This is for temporary purpose only. Will be retrieving the key from the backend
// Todo: remove node-forge
let md = forge.md.sha256.create();
md.update(key);
let bufKey = new Buffer(bits2b64(md.digest().getBytes()), keyEncoding);

View File

@ -26,6 +26,7 @@ class Crypto {
this.indexDataFolder = INDEX_DATA_FOLDER + '_' + userId + '_' + INDEX_VERSION;
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;
@ -82,7 +83,7 @@ class Crypto {
zipArchive.pipe(output);
zipArchive.directory(this.indexDataFolder);
zipArchive.directory(this.indexDataFolder + '/', false);
zipArchive.finalize((err) => {
if (err) {
@ -136,7 +137,7 @@ class Crypto {
});
let extractZip = () => {
extract(`${this.dump}/decrypted.zip`, {dir: TEMPORARY_PATH}, (err) => {
extract(`${this.dump}/decrypted.zip`, {dir: `${this.extractToPath}`}, (err) => {
if (err) {
reject(new Error(err));
}