Gathering detailed insights and metrics for redux-persist-sensitive-storage
Gathering detailed insights and metrics for redux-persist-sensitive-storage
Gathering detailed insights and metrics for redux-persist-sensitive-storage
Gathering detailed insights and metrics for redux-persist-sensitive-storage
npm install redux-persist-sensitive-storage
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
248 Stars
23 Commits
34 Forks
15 Watching
1 Branches
6 Contributors
Updated on 09 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
22.1%
2,487
Compared to previous day
Last week
9.5%
12,100
Compared to previous week
Last month
57.7%
45,331
Compared to previous month
Last year
-16.7%
344,119
Compared to previous year
2
Storage engine to use react-native-sensitive-info with redux-persist.
react-native-sensitive-info manages all data stored in Android Shared Preferences and iOS Keychain.
NOTE: Android Shared Preferences are not secure, but there is a branch of react-native-sensitive-info that uses the Android keystore instead of shared preferences. You can use that branch with redux-persist-sensitive-storage if you prefer.
You can install this package using either yarn
or npm
. You will also need to install and link react-native-sensitive-info.
Using Yarn:
yarn add redux-persist-sensitive-storage react-native-sensitive-info
react-native link react-native-sensitive-info
Using npm:
npm install --save redux-persist-sensitive-storage react-native-sensitive-info
react-native link react-native-sensitive-info
To use redux-persist-sensitive-storage, create a sensitive storage instance using createSensitiveStorage
and then
configure redux-persist according to its documentation using your instance as the storage argument in the configuration.
createSensitiveStorage
takes an optional set of configuration options. These are used to configure the keychain service (iOS) and shared preferences name (Android) that react-native-sensitive-info uses. See their documentation for more information.
1import { compose, applyMiddleware, createStore } from "redux"; 2import { persistStore, persistCombineReducers } from "redux-persist"; 3import createSensitiveStorage from "redux-persist-sensitive-storage"; 4import reducers from "./reducers"; // where reducers is an object of reducers 5 6const storage = createSensitiveStorage({ 7 keychainService: "myKeychain", 8 sharedPreferencesName: "mySharedPrefs" 9}); 10 11const config = { 12 key: "root", 13 storage, 14}; 15 16const reducer = persistCombineReducers(config, reducers); 17 18function configureStore () { 19 // ... 20 let store = createStore(reducer); 21 let persistor = persistStore(store); 22 23 return { persistor, store }; 24}
You may want to only persist some keys in secure storage, and persist other parts of your state in local storage. If that's the case, you can use redux-persist's Nested Persists support. Your configuration might look something like this:
1import { AsyncStorage } from "react-native"; 2import { combineReducers } from "redux"; 3import { persistReducer } from "redux-persist"; 4import createSensitiveStorage from "redux-persist-sensitive-storage"; 5 6import { mainReducer, tokenReducer } from "./reducers"; 7 8const sensitiveStorage = createSensitiveStorage({ 9 keychainService: "myKeychain", 10 sharedPreferencesName: "mySharedPrefs" 11}); 12 13const mainPersistConfig = { 14 key: "main", 15 storage: AsyncStorage, 16 blacklist: ["someEphemeralKey"] 17}; 18 19const tokenPersistConfig = { 20 key: "token", 21 storage: sensitiveStorage 22}; 23 24let rootReducer = combineReducers({ 25 main: persistReducer(mainPersistConfig, mainReducer), 26 token: persistReducer(tokenPersistConfig, tokenReducer) 27});
Modify the persistStore
call as follows:
1import createSensitiveStorage from "redux-persist-sensitive-storage";
2
3// ...
4
5persistStore(store, { storage: createSensitiveStorage(options) });
Here is a more complete example:
1import { compose, applyMiddleware, createStore } from "redux";
2import { persistStore, autoRehydrate } from "redux-persist";
3import createSensitiveStorage from "redux-persist-sensitive-storage";
4
5const store = createStore(
6 reducer,
7 compose(
8 applyMiddleware(...),
9 autoRehydrate()
10 )
11);
12
13persistStore(store, {
14 storage: createSensitiveStorage({
15 keychainService: "myKeychain",
16 sharedPreferencesName: "mySharedPrefs"
17 });
18);
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/11 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
90 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Moreredux-persist
persist and rehydrate redux stores
redux-persist-filesystem-storage
Redux persist adaptor for React Native filesystem storage
redux-persist-webextension-storage
WebExtension Storage engine for redux-persist
redux-persist-indexeddb-storage
Redux Persist storage engine using Indexeddb