Socket
Socket
Sign inDemoInstall

react-secure-storage

Package Overview
Dependencies
2
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.3.1

4

dist/encryption.js

@@ -57,5 +57,7 @@ "use strict";

try {
var _bytes$toString;
var bytes = _aes.default.decrypt(value, this.secureKey);
return bytes.toString(_encUtf.default) || null;
return (_bytes$toString = bytes.toString(_encUtf.default)) !== null && _bytes$toString !== void 0 ? _bytes$toString : null;
} catch (ex) {

@@ -62,0 +64,0 @@ return null;

@@ -64,3 +64,3 @@ "use strict";

* @param key to be added
* @param value value to be added
* @param value value to be added `use JSON.stringify(value) or value.toString() to save any other data type`
*/

@@ -72,8 +72,10 @@

value: function setItem(key, value) {
var parsedValue = _typeof(value) === "object" ? JSON.stringify(value) : value + "";
var parsedKeyLocal = getLocalKey(key, value);
var parsedKey = KEY_PREFIX + key;
if (key != null) this._localStorageItems[parsedKey] = value;
var encrypt = new _encryption.default();
localStorage.setItem(parsedKeyLocal, encrypt.encrypt(parsedValue));
if (value === null || value === undefined) this.removeItem(key);else {
var parsedValue = _typeof(value) === "object" ? JSON.stringify(value) : value + "";
var parsedKeyLocal = getLocalKey(key, value);
var parsedKey = KEY_PREFIX + key;
if (key != null) this._localStorageItems[parsedKey] = value;
var encrypt = new _encryption.default();
localStorage.setItem(parsedKeyLocal, encrypt.encrypt(parsedValue));
}
}

@@ -89,4 +91,6 @@ /**

value: function getItem(key) {
var _this$_localStorageIt;
var parsedKey = KEY_PREFIX + key;
return this._localStorageItems[parsedKey] || null;
return (_this$_localStorageIt = this._localStorageItems[parsedKey]) !== null && _this$_localStorageIt !== void 0 ? _this$_localStorageIt : null;
}

@@ -93,0 +97,0 @@ /**

@@ -54,7 +54,17 @@ "use strict";

case "j":
parsedValue = JSON.parse(decryptedValue);
try {
parsedValue = JSON.parse(decryptedValue);
} catch (ex) {
parsedValue = null;
}
break;
case "n":
parsedValue = Number(decryptedValue);
try {
parsedValue = Number(decryptedValue);
} catch (ex) {
parsedValue = null;
}
break;

@@ -61,0 +71,0 @@

{
"name": "react-secure-storage",
"version": "1.3.0",
"version": "1.3.1",
"description": "This libraries is used to securely store data in local storage",

@@ -5,0 +5,0 @@ "author": "Sushin Pv",

@@ -155,8 +155,10 @@ [![npm](https://img.shields.io/npm/v/react-secure-storage.svg)](https://www.npmjs.com/package/react-secure-storage) [![downloads](https://img.shields.io/npm/dm/react-secure-storage.svg)](http://npm-stat.com/charts.html?package=react-secure-storage)

## Whats new in 1.2.1?
## Whats new in 1.3.1?
Added support for Vite and Next.js environment variables
Regular bug fixes and https://github.com/sushinpv/react-secure-storage/issues/39 is resolved
## Whats new | Previous?
Added support for Vite and Next.js environment variables
Now you can disable individual fingerprint generation properties, This is discussed in the following enhancement https://github.com/sushinpv/react-secure-storage/issues/14

@@ -163,0 +165,0 @@

@@ -32,3 +32,3 @@ import Utf8 from "crypto-js/enc-utf8";

var bytes = AES.decrypt(value, this.secureKey);
return bytes.toString(Utf8) || null;
return bytes.toString(Utf8) ?? null;
} catch (ex) {

@@ -35,0 +35,0 @@ return null;

@@ -41,11 +41,14 @@ import { LocalStorageItem } from "./coreTypes";

* @param key to be added
* @param value value to be added
* @param value value to be added `use JSON.stringify(value) or value.toString() to save any other data type`
*/
setItem(key: string, value: string | object | number | boolean) {
let parsedValue = typeof value === "object" ? JSON.stringify(value) : value + "";
let parsedKeyLocal = getLocalKey(key, value);
let parsedKey = KEY_PREFIX + key;
if (key != null) this._localStorageItems[parsedKey] = value;
const encrypt = new EncryptionService();
localStorage.setItem(parsedKeyLocal, encrypt.encrypt(parsedValue));
if (value === null || value === undefined) this.removeItem(key);
else {
let parsedValue = typeof value === "object" ? JSON.stringify(value) : value + "";
let parsedKeyLocal = getLocalKey(key, value);
let parsedKey = KEY_PREFIX + key;
if (key != null) this._localStorageItems[parsedKey] = value;
const encrypt = new EncryptionService();
localStorage.setItem(parsedKeyLocal, encrypt.encrypt(parsedValue));
}
}

@@ -60,3 +63,3 @@

let parsedKey = KEY_PREFIX + key;
return this._localStorageItems[parsedKey] || null;
return this._localStorageItems[parsedKey] ?? null;
}

@@ -63,0 +66,0 @@

@@ -27,6 +27,14 @@ import { LocalStorageItem } from "./coreTypes";

case "j":
parsedValue = JSON.parse(decryptedValue);
try {
parsedValue = JSON.parse(decryptedValue);
} catch (ex) {
parsedValue = null;
}
break;
case "n":
parsedValue = Number(decryptedValue);
try {
parsedValue = Number(decryptedValue);
} catch (ex) {
parsedValue = null;
}
break;

@@ -33,0 +41,0 @@ default:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc