Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data;
if (!this.utils.is(key)) {
this.utils.warn(this.WarningEnum.KEY_NOT_PROVIDED);
return jsonData;
}
data = this.getDataFromLocalStorage(key);
if (!data) {
return jsonData;
}
deCompressedData = data; // saves else
if (this._isCompression || isAllKeysData) { // meta data always compressed
deCompressedData = LZString.decompressFromUTF16(data);
}
decodedData = deCompressedData; // saves else
if (this._isBase64 || isAllKeysData) { // meta data always Base64
decodedData = Base64.decode(deCompressedData);
} else {
this.getEncryptionSecret(key);
if (this._isAES) {
bytes = AES.decrypt(deCompressedData.toString(), this.utils.encryptionSecret);
} else if (this._isDES) {
bytes = DES.decrypt(deCompressedData.toString(), this.utils.encryptionSecret);
} else if (this._isRabbit) {
bytes = RABBIT.decrypt(deCompressedData.toString(), this.utils.encryptionSecret);
} else if (this._isRC4) {
bytes = RC4.decrypt(deCompressedData.toString(), this.utils.encryptionSecret);
}
function handleData(msgData) {
switch (msgData.type) {
case 'COMPRESS':
return LZString.compress(msgData.strToHandle);
case 'DECOMPRESS':
return LZString.decompress(msgData.strToHandle);
case 'COMPRESS_UTF16':
// tslint:disable-next-line
return LZString['compressToUTF16'](msgData.strToHandle);
case 'DECOMPRESS_UTF16':
// tslint:disable-next-line
return LZString['decompressFromUTF16'](msgData.strToHandle);
}
}