Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
local-storage-fallback
Advanced tools
Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)
Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)
$ npm install local-storage-fallback
import storage from 'local-storage-fallback' // if you use es6 or typescript
// use object destructuring when using require()
// const {storage} = require('local-storage-fallback')
// Use storage directly
storage.setItem('foo', 'bar');
storage.getItem('foo'); // bar
// Or shim window.localStorage
if (!('localStorage' in window)) {
window.localStorage = storage;
}
<script src="https://unpkg.com/local-storage-fallback/lib/dist.min.js"></script>
<script>
window.localStorageFallback.setItem('foo', 'bar')
</script>
With browser settings like "Private Browsing" it has become a problem to rely on a working window.localStorage
, even in newer browsers. Even though it may exist, it will throw exceptions when trying to use setItem
or getItem
. This module will run appropriate checks to see what browser storage mechanism might be available, and then expose it. It uses the same API as localStorage
so it should work as a drop-in replacement in most cases.
CookieStorage
has storage limits. Be careful here.MemoryStorage
will not persist between page loads. This is more or less a stop-gap to prevent page crashes, but may be sufficient for websites that don't do full page loads.FAQs
Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)
The npm package local-storage-fallback receives a total of 29,132 weekly downloads. As such, local-storage-fallback popularity was classified as popular.
We found that local-storage-fallback demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.