Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@socketsupply/json-store
Advanced tools
Socket Supply Runtime plugin: JSON-based storage (file-system) with localStorage-compatible API
JSONStore
(Socket Supply Module)Provides simple key-val storage of JSON-compatiable values, backed by the device's filesystem (via Socket Supply's runtime fs
module).
This module provides an API that's similar to the browser localStorage
API, except that it operates asynchronously (because of the underlying file system operation asynchrony). Other than the use of promises (await
, etc), it should be familiar if you've worked with localStorage
before.
One additional important difference between JSONStore
and localStorage
: non-primitive (object) values are automatically JSON serialized/de-serialized; the whole data store is serialized to a JSON string, written to a text file (./.store.json
).
As such, JSONStore.setItem('customer', { id: 123, name: '..' })
works without needing to first serialize the object value with JSON.stringify(..)
. Likewise, JSONStore.getItem('customer')
will return the already deserialized object, without needing to use JSON.parse(..)
.
getItem(name)
: returns a promise for the value (if any) in the store that's associated with name
property name (string); resolves to undefined
if not found
setItem(name, value)
: sets a value
value (JSON-compatible) at the name
property in the store; returns a promise, with true
on success or false
otherwise
removeItem(name)
: removes the property named name
(if any) from the store; returns a promise, with true
on success or false
otherwise
clear()
: removes all entries from the store; returns a promise, with true
on success or false
otherwise
import JSONStore from `@socketsupply/json-store`
JSONStore.setItem('zipcode', 78739) // Promise<true>
JSONStore.getItem('zipcode') // Promise<78739>
JSONStore.removeItem('zipecode') // Promise<true>
JSONStore.getItem('zipcode') // Promise<undefined>
JSONStore.setItem('customer', { id: 123, name: 'Kyle' }) // Promise<true>
JSONStore.getItem('customer') // Promise<{ id: 123, name: 'Kyle' }>
JSONStore.clear() // Promise<true>
This module is provided in ES6-compatible ESM. It exports both a default export of the JSONStore
object, as shown above, as well as each API member (setItem(..)
, getItem(..)
, etc) as a named export.
All code and documentation are (c) 2023 Socket Supply Co and released under the MIT License. A copy of the MIT License is also included.
FAQs
Socket Supply Runtime plugin: JSON-based storage (file-system) with localStorage-compatible API
We found that @socketsupply/json-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.