Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
redux-persist-cookie-storage
Advanced tools
Redux Persist storage adapter for cookies. Works in the browser and in Node.js with cookie-parser output. This makes it suitable for universal / isomorphic applications.
npm install --save redux-persist-cookie-storage
import { persistStore, autoRehydrate } from 'redux-persist'
import CookieStorage from 'redux-persist-cookie-storage'
const store = createStore(reducer, undefined, autoRehydrate())
// By default, session cookies are used
persistStore(store, { storage: new CookieStorage() })
// Expiration time can be set via options
persistStore(store, { storage: new CookieStorage({
expiration: {
'default': 365 * 86400 // Cookies expire after one year
}
})
})
// Default expiration time can be overridden for specific parts of the store:
persistStore(store, { storage: new CookieStorage({
expiration: {
'default': null, // Session cookies used by default
'storeKey': 600 // State in key `storeKey` expires after 10 minutes
}
})
})
// Read-only mode: Use plain object output of cookie parser
import { persistStore, autoRehydrate } from 'redux-persist'
import CookieStorage from 'redux-persist-cookie-storage'
import cookieParser from 'cookie-parser'
const app = new Express()
app.use(cookieParser())
app.use((req, res) => {
const store = createStore(reducer, undefined, autoRehydrate())
const cookies = req.cookies
persistStore(store, { storage: new CookieStorage({ cookies }) })
})
// Read-write mode: Use actual cookie jar implementation
import { persistStore, autoRehydrate } from 'redux-persist'
import CookieStorage from 'redux-persist-cookie-storage'
import Cookies from 'cookies'
const app = new Express()
app.use(Cookies.express())
app.use((req, res) => {
const store = createStore(reducer, undefined, autoRehydrate())
const cookies = new Cookies(req, res)
persistStore(store, { storage: new CookieStorage({ cookies }) })
})
N.B.: Custom expiration times are not supported server-side at the moment.
npm test
FAQs
redux-persist storage adapter for cookies
The npm package redux-persist-cookie-storage receives a total of 2,741 weekly downloads. As such, redux-persist-cookie-storage popularity was classified as popular.
We found that redux-persist-cookie-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.