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.2.2 to 1.3.0

77

dist/envHelper.js

@@ -10,19 +10,18 @@ "use strict";

/**
* Function to get data from .env
* Function to get SECURE_LOCAL_STORAGE_HASH_KEY
* @returns
*/
var getEnvValue = function getEnvValue(key) {
var getHashKey = function getHashKey() {
var value = null;
if (typeof Cypress != "undefined") {
SUPPORTED_PREFIX.forEach(function (keyPrefix) {
value = Cypress.env(keyPrefix + key) || value;
if (value) return value;
});
} else if (typeof process.env != "undefined") {
SUPPORTED_PREFIX.forEach(function (keyPrefix) {
value = process.env[keyPrefix + key] || value;
if (value) return value;
});
} else {
console.warn("react-secure-storage : process is not defined! Just a warning!");
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_HASH_KEY");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_HASH_KEY || process.env.REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.VITE_SECURE_LOCAL_STORAGE_HASH_KEY;
} else {
console.warn("react-secure-storage : process is not defined! Just a warning!");
}
} catch (ex) {
return null;
}

@@ -32,7 +31,55 @@

};
/**
* Function to get SECURE_LOCAL_STORAGE_PREFIX
* @returns
*/
var getStoragePrefix = function getStoragePrefix() {
var value = null;
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_PREFIX");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_PREFIX || process.env.REACT_APP_SECURE_LOCAL_STORAGE_PREFIX || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX || process.env.VITE_SECURE_LOCAL_STORAGE_PREFIX;
} else {
console.warn("react-secure-storage : process is not defined! Just a warning!");
}
} catch (ex) {
return null;
}
return value;
};
/**
* Function to get SECURE_LOCAL_STORAGE_DISABLED_KEYS
* @returns
*/
var getDisabledKeys = function getDisabledKeys() {
var value = null;
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS;
} else {
console.warn("react-secure-storage : process is not defined! Just a warning!");
}
} catch (ex) {
return null;
}
return value;
};
var envHelper = {
getEnvValue: getEnvValue
getHashKey: getHashKey,
getStoragePrefix: getStoragePrefix,
getDisabledKeys: getDisabledKeys
};
var _default = envHelper;
exports.default = _default;

2

dist/fingerprint.js

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

var getFingerprint = function getFingerprint() {
var HASH_KEY_CUSTOM = _envHelper.default.getEnvValue("SECURE_LOCAL_STORAGE_HASH_KEY") || HASH_KEY;
var HASH_KEY_CUSTOM = _envHelper.default.getHashKey() || HASH_KEY;
if (typeof window === "undefined") return HASH_KEY_CUSTOM;

@@ -25,0 +25,0 @@ return _fingerprint.default.getFingerprint() + HASH_KEY_CUSTOM;

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

var getSecurePrefix = function getSecurePrefix() {
var KEY_PREFIX = _envHelper.default.getEnvValue("SECURE_LOCAL_STORAGE_PREFIX") || "@secure.";
var KEY_PREFIX = _envHelper.default.getStoragePrefix() || "@secure.";
if (!KEY_PREFIX.endsWith(".")) return KEY_PREFIX + ".";

@@ -46,3 +46,3 @@ return KEY_PREFIX;

var getDisabledKeys = function getDisabledKeys() {
var DISABLED_KEYS = _envHelper.default.getEnvValue("SECURE_LOCAL_STORAGE_DISABLED_KEYS") || "";
var DISABLED_KEYS = _envHelper.default.getDisabledKeys() || "";
if (DISABLED_KEYS === "") return [];

@@ -49,0 +49,0 @@ var allOptions = [FINGERPRINT_KEYS.USERAGENT, FINGERPRINT_KEYS.SCREEN_PRINT, FINGERPRINT_KEYS.PLUGINS, FINGERPRINT_KEYS.FONTS, FINGERPRINT_KEYS.LOCAL_STORAGE, FINGERPRINT_KEYS.SESSION_STORAGE, FINGERPRINT_KEYS.TIMEZONE, FINGERPRINT_KEYS.LANGUAGE, FINGERPRINT_KEYS.SYSTEM_LANGUAGE, FINGERPRINT_KEYS.COOKIE, FINGERPRINT_KEYS.CANVAS, FINGERPRINT_KEYS.HOSTNAME];

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

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

@@ -187,1 +187,5 @@ [![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)

Before creating the PR, Please make sure to remove the `react-scripts` from the `package.json`. and you are creating a production build for the library by running `yarn build:lib`
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=sushinpv/react-secure-storage&type=Date)](https://star-history.com/#sushinpv/react-secure-storage&Date)

@@ -6,27 +6,66 @@ const SUPPORTED_PREFIX = ["", "REACT_APP_", "NEXT_PUBLIC_", "VITE_"];

/**
* Function to get data from .env
* Function to get SECURE_LOCAL_STORAGE_HASH_KEY
* @returns
*/
const getEnvValue = (key: SECURE_LOCAL_STORAGE_KEYS) => {
const getHashKey = () => {
let value: string | null | undefined = null;
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_HASH_KEY");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_HASH_KEY || process.env.REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY || process.env.VITE_SECURE_LOCAL_STORAGE_HASH_KEY;
} else {
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
}
} catch (ex) {
return null;
}
return value;
};
if (typeof Cypress != "undefined") {
SUPPORTED_PREFIX.forEach((keyPrefix) => {
value = Cypress.env(keyPrefix + key) || value;
if (value) return value;
});
} else if (typeof process.env != "undefined") {
SUPPORTED_PREFIX.forEach((keyPrefix) => {
value = process.env[keyPrefix + key] || value;
if (value) return value;
});
} else {
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
/**
* Function to get SECURE_LOCAL_STORAGE_PREFIX
* @returns
*/
const getStoragePrefix = () => {
let value: string | null | undefined = null;
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_PREFIX");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_PREFIX || process.env.REACT_APP_SECURE_LOCAL_STORAGE_PREFIX || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX || process.env.VITE_SECURE_LOCAL_STORAGE_PREFIX;
} else {
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
}
} catch (ex) {
return null;
}
return value;
};
/**
* Function to get SECURE_LOCAL_STORAGE_DISABLED_KEYS
* @returns
*/
const getDisabledKeys = () => {
let value: string | null | undefined = null;
try {
if (typeof Cypress != "undefined") {
value = Cypress.env("SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS") || Cypress.env("VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS");
} else if (typeof process.env != "undefined") {
value = process.env.SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS || process.env.VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS;
} else {
console.warn(`react-secure-storage : process is not defined! Just a warning!`);
}
} catch (ex) {
return null;
}
return value;
};
const envHelper = {
getEnvValue,
getHashKey,
getStoragePrefix,
getDisabledKeys,
};
export default envHelper;

@@ -12,3 +12,3 @@ /* eslint-disable no-undef */

const getFingerprint = () => {
let HASH_KEY_CUSTOM = envHelper.getEnvValue("SECURE_LOCAL_STORAGE_HASH_KEY") || HASH_KEY;
let HASH_KEY_CUSTOM = envHelper.getHashKey() || HASH_KEY;

@@ -15,0 +15,0 @@ if (typeof window === "undefined") return HASH_KEY_CUSTOM;

@@ -8,3 +8,3 @@ import envHelper from "./envHelper";

export const getSecurePrefix = (): string => {
let KEY_PREFIX = envHelper.getEnvValue("SECURE_LOCAL_STORAGE_PREFIX") || "@secure.";
let KEY_PREFIX = envHelper.getStoragePrefix() || "@secure.";
if (!KEY_PREFIX.endsWith(".")) return KEY_PREFIX + ".";

@@ -34,3 +34,3 @@ return KEY_PREFIX;

export const getDisabledKeys = (): string[] => {
let DISABLED_KEYS = envHelper.getEnvValue("SECURE_LOCAL_STORAGE_DISABLED_KEYS") || "";
let DISABLED_KEYS = envHelper.getDisabledKeys() || "";
if (DISABLED_KEYS === "") return [];

@@ -37,0 +37,0 @@

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