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.
localstorage-vcs
Advanced tools
As usage of localStorage
evolves over time, particular meaning of keys in the storage may change
it's shape or meaning. That may result in inconsistent state of an application. localstorage-vcs
let's you track versions of localStorage
and enables you to programmatically manage changes of stored data,
so localStorage is always up to date.
Localstorage script exposes a single function, that will run each time your client code gets executed in the browser. This function will mutate localStorage based on a configuration that gets passed into the function as it's only argument.
config.version
: stringThis property notes current version of localStorage that the application expects. Any string
will qualify as
a valid version, as long as it is unique in reference to previously used versions.
Since this property is used to determinate whether localStorage mutation should be executed, it is advised to set it manually only when localStorage changes it's shape.
Note: version will be kept in localStorage under LOCAL_STORAGE_VERSION
key
Bad practice
Good practice
config.removeAll
: booleanIf set true
each time version changes, every key on localStorage
will be removed via localStorage.clear()
method.
Beware that this set to true will have priority over other below methods.
Example:
const config = {
version: '1',
removeAll: true
}
config.remove
: string[]Collection of keys on localStorage
that should be removed after version changes.
A key refers to localStorage.getItem(key)
Beware that key present in this array will not be migrated even if specified in below option
Example:
const config = {
version: '1',
remove: ['someKey1', 'someKey2']
}
config.migrations
Migrations
Migration
is represented as an array of length of 2.Migration
is a reference to version, that triggers migration functions.Migration
is an object
that has localStorage
keys, as properties and functions
as valesMigration function
Example:
const config = {
version: '2',
migrations: [
['1', { someKey: oldKey => `${oldKey}_v1` }],
['2', { someKey: oldKey => oldKey.replace('_v1', '_v2') }],
]
}
type Key = string;
type Version = string;
type MigrationFunction = (oldKey: Key | null) => Key;
interface IMigrationKeys {
[key: string]: MigrationFunction
}
type Migration = [Version, IMigrationKeys]
export interface IConfig {
migrations?: Migration[],
removeAll?: boolean,
remove?: Key[],
version: Version
}
FAQs
Library that will keep your localStorage predictable.
The npm package localstorage-vcs receives a total of 202 weekly downloads. As such, localstorage-vcs popularity was classified as not popular.
We found that localstorage-vcs 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’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.