
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
webext-storage
Advanced tools
A more usable typed storage API for Web Extensions
Sponsored by PixieBrix :tada:
chrome.storage.local.get()
is very inconvenient to use and it's not type-safe. This module provides a better API:
const options = new StorageItem<Record<string, string>>('user-options');
const value = await options.get(); // The type is `Record<string, string> | undefined`
await options.set({color: 'red'}) // Type-checked
options.onChanged(newValue => {
console.log('New options', newValue)
});
item.get()
returns the raw value instead of an objectget
and set
operation is type-safedefaultValue
, the return type will not be | undefined
.set(undefined)
will unset the value instead of the call being ignoredonChanged
example speaks for itselfNow compare it to the native API:
const storage = await chrome.storage.local.get('user-options');
const value = storage['user-options']; // The type is `any`
await chrome.storage.local.set({['user-options']: {color: 'red'}}); // Not type-checked
chrome.storage.onChanged.addListener((storageArea, change) => {
if (storageArea === 'local' && change['user-options']) { // Repetitive
console.log('New options', change['user-options'].newValue)
}
});
npm install webext-storage
Or download the standalone bundle to include in your manifest.json
.
The package exports two classes:
new Map()
Support:
storage
or unlimitedStorage
MIT © Federico Brigante
FAQs
A more usable typed storage API for Web Extensions
The npm package webext-storage receives a total of 3,845 weekly downloads. As such, webext-storage popularity was classified as popular.
We found that webext-storage 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
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.