From 62e791fd3589d474e7d912f8f0bccdb55caacbf8 Mon Sep 17 00:00:00 2001 From: Christopher Huemmer Date: Sat, 14 Jan 2023 11:53:59 +0100 Subject: [PATCH] fixes issue with decryption --- app/services/yahooService.js | 14 ++++++++++---- package.json | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/services/yahooService.js b/app/services/yahooService.js index 6801cc5..a4e7543 100644 --- a/app/services/yahooService.js +++ b/app/services/yahooService.js @@ -132,14 +132,20 @@ function getHistoricalPrices(ticker, options) { // Helper functions function getDecryptedBody(dataStore) { - let _cs = dataStore._cs - let _cr = dataStore._cr + let pwKey = Object.keys(dataStore)[2]; + var password = dataStore[pwKey]; + stores = dataStore.context.dispatcher.stores - var key = CryptoJS.algo.PBKDF2.create({ keySize: 8 }).compute(_cs, JSON.parse(_cr)).toString(); - var plaintext = CryptoJS.AES.decrypt(stores, key); + var plaintext = CryptoJS.AES.decrypt(stores, password); return JSON.parse(decodeURIComponent(escape(CryptoJS.enc.Latin1.stringify(plaintext)))); } +function getJsonLastElement(json) +{ + let len = json.length + return json[len - 1] +} + function getDataStoreAsJson(body) { return JSON.parse("{"+body.split(regex)[1]+"}") } diff --git a/package.json b/package.json index 030a145..3c7cca5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "terminal-stocks", - "version": "1.0.11", + "version": "1.0.12", "description": "Fetch stock price information on terminal", "main": "index.js", "bin": {