
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
typed-local-store
Advanced tools
A zero-dependency wrapper to provide type safe access to the localStorage and sessionStorage.
npm install typed-local-store
# or
yarn add typed-local-store
Create a schema of your desired storage structure:
interface Schema {
counter: number;
message: string;
user: {
id: string;
name: string;
email: string;
isAdmin: boolean;
};
posts: string[];
}
Then create your storage using the defined schema:
import TypedLocalStore from 'typed-local-store';
const typedStorage = new TypedLocalStore<Schema>();
The API of typed-local-store mimics the Web Storage API. This allows for a easy transition from using localStorage
directly to using TypedLocalStore
. |
The constructor can receive a options object to configure the store.
Property | Required | Default | Description |
---|---|---|---|
storage: string | No | 'localStorage' | Choose the storage type, "localStorage" or "sessionStorage" |
fallbackStorage: Storage | No | undefined | Provide a fallback storage in case localStorage and or SessionStorage are not available |
ignoreMissingStorage: boolean | No | false | Prevent error to be thrown when no storage is present. |
The getItem
method has three retrieval modes, whereas 'fail'
is the default mode
Mode | Description |
---|---|
'fail' | If a something to be restored from the store can not be parsed by JSON.parse a error is thrown |
'raw' | If parsing of the retrieval value fails, the unparsed value is returned |
'safe' | If parsing of the retrieval value fails, null is returned |
Sometimes it is desireable to not rely on the browser API ( e.g. in case of SSR). This package ships a in-memory replacement for the Web Storage API which can be used in places where the browser API is not present. It can be used alone or passed to the TypedLocalStore via the fallbackStorage
option:
import TypedLocalStore, { MemoryStorage } from 'typed-local-store';
const memoryStorage = new MemoryStorage();
const typedStorage = new TypedLocalStore<Schema>({
fallbackStorage: memoryStorage,
});
Interested in contributing? Great!
To fix a bug or add a feature, follow these steps:
git checkout -b your-branch
)git commit -am 'feat: fantastic feature'
)git push origin your-branch
)The required packages to start development can be installed with
npm install
# or
yarn install
The tests can be run with
npm run test
# or
yarn test
FAQs
A type wrapper for the store api
The npm package typed-local-store receives a total of 488 weekly downloads. As such, typed-local-store popularity was classified as not popular.
We found that typed-local-store 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.