Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
redux-persist-filesystem-storage
Advanced tools
Redux persist adaptor for React Native filesystem storage
Storage adaptor to use react-native-blob-util with redux-persist, by implementing the needed methods: setItem
, getItem
, removeItem
, getAllKeys
and clear
.
This storage can be used on Android to prevent issues with the storage limitations in the RN AsyncStorage implementation. (See redux-persist#199, redux-persist#284)
Please note: v2 of this library supports React Native 0.60 and above only. If you are using React Native 0.59 and below, please use v1.x.
yarn add redux-persist-filesystem-storage
or, for React Native 0.59 and below:
yarn add redux-persist-filesystem-storage@1
Then, as react-native-blob-util is a dependency of this project, it will also need setting up as its their installation docs.
Simply use 'FilesystemStorage' as the storage option in the redux-persist config.
import FilesystemStorage from 'redux-persist-filesystem-storage'
...
const persistConfig = {
key: 'root',
storage: FilesystemStorage,
}
...
import FilesystemStorage from 'redux-persist-filesystem-storage'
...
// These are all the config options, with their default values
FilesystemStorage.config({
storagePath: `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`,
encoding: "utf8",
toFileName: (name: string) => name.split(":").join("-"),
fromFileName: (name: string) => name.split("-").join(":"),
});
const persistConfig = {
key: 'root',
storage: FilesystemStorage,
toFileName: (name: string) => name.split(":").join("-"),
fromFileName: (name: string) => name.split("-").join(":")
}
...
Using redux-persist V5?
Redux-Persist v5 migrate from one storage system to another
Using redux-persist V4?
the snippet below lets you migrate redux data previously stored in
AsyncStorage
to redux-persist-filesystem-storage
.
NOTE This snippet lets you migrate healthy data. It will not restore
data if it is already hit limits of AsyncStorage
import { persistStore, getStoredState } from 'redux-persist'
import FilesystemStorage from 'redux-persist-filesystem-storage'
import { AsyncStorage } from 'react-native'
import _ from 'lodash'
import { createStore } from 'redux'
const store = createStore(...)
// create persistor for `redux-persist-filesystem-storage`
const fsPersistor = persistStore(
store,
{ storage: FilesystemStorage },
async (fsError, fsResult) => {
if (_.isEmpty(fsResult)) {
// if state from fs storage is empty try to read state from previous storage
try {
const asyncState = await getStoredState({ storage: AsyncStorage })
if (!_.isEmpty(asyncState)) {
// if data exists in `AsyncStorage` - rehydrate fs persistor with it
fsPersistor.rehydrate(asyncState, { serial: false })
}
} catch (getStateError) {
console.warn("getStoredState error", getStateError)
}
}
}
)
FAQs
Redux persist adaptor for React Native filesystem storage
The npm package redux-persist-filesystem-storage receives a total of 7,158 weekly downloads. As such, redux-persist-filesystem-storage popularity was classified as popular.
We found that redux-persist-filesystem-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.