
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@lweb-utils/storage
Advanced tools
本地存储相关工具函数
npm i @lweb-utils/storage --save
getCookie(name)
获取相应名称对应的cookie值。
name(string): cookie名称。
(string): cookie值,如果没有则返回空字符串''。
const value = getCookie('example');
setCookie(name, value, days, domain, path)
添加相应的cookie。
name(string): cookie名称。
value(string): cookie值。
days(number): cookie有效时间,单位为天。
domain(string): cookie域名。
path(string): cookie路径。
无
// 只有name和value
setCookie('example', 'abc');
// 存在过期时间,3天后过期
setCookie('example', 'abc', 3);
// 存在域名
setCookie('example', 'abc', 3, 'http://www.abc.com/');
// 在指定路径下有效
setCookie('example', 'abc', 3, 'http://www.abc.com/', '/path');
removeCookie(name)
删除相应的cookie。
name(string): cookie名称。
无
removeCookie('example');
getStorage(storage, key, isObject, defaultValue)
获取相应存储对象的值。存储对象要有setItem和getItem方法,比如localStorage
对象。
storage(Storage): 存储对象,应具备setItem和getItem方法。
key(string): 存储的key。
isObject(boolean): 存储的值是否为对象,如果为true,则会对值进行JSON.parse转换。
defaultValue(any): 默认值,获取的值不存在时返回该值。
(any): 获取存储对象对应key的值。
// 获取的值为字符串
const value = getStorage(localStorage, 'example');
// 获取的值为对象
const value = getStorage(localStorage, 'example', true);
// 获取的值不存在时取默认值default
const value = getStorage(localStorage, 'example', true, 'default');
setStorage(storage, key, value)
设置存储键值对。
storage(Storage): 存储对象,应具备setItem和getItem方法。
key(string): 存储的key。
value(any): 存储的值,如果为对象会转换成json字符串。
无
// 值为字符串
setStorage(localStorage, 'example', 'value');
// 值为对象,对象会被转换成字符串
setStorage(localStorage, 'example', { a: 1, b: 2 });
getLocalStorage(key, isObject, defaultValue)
获取localStorage的值。
key(string): localStorage的key。
isObject(boolean): 存储的值是否为对象,如果为true,则会对值进行JSON.parse转换。
defaultValue(any): 默认值,获取的值不存在时返回该值。
(any): 获取localStorage对应key的值。
// 获取的值为字符串
const value = getLocalStorage('example');
// 获取的值为对象
const value = getLocalStorage('example', true);
// 获取的值不存在时取默认值default
const value = getLocalStorage('example', true, 'default');
getSessionStorage(key, isObject, defaultValue)
获取sessionStorage的值。
key(string): sessionStorage的key。
isObject(boolean): 存储的值是否为对象,如果为true,则会对值进行JSON.parse转换。
defaultValue(any): 默认值,获取的值不存在时返回该值。
(any): 获取sessionStorage对应key的值。
// 获取的值为字符串
const value = getSessionStorage('example');
// 获取的值为对象
const value = getSessionStorage('example', true);
// 获取的值不存在时取默认值default
const value = getSessionStorage('example', true, 'default');
setLocalStorage(key, value)
设置localStorage键值对。
key(string): 存储的key。
value(any): 存储的值,如果为对象会转换成json字符串。
无
// 值为字符串
setLocalStorage('example', 'value');
// 值为对象,对象会被转换成字符串
setLocalStorage('example', { a: 1, b: 2 });
setSessionStorage(key, value)
设置sessionStorage键值对。
key(string): 存储的key。
value(any): 存储的值,如果为对象会转换成json字符串。
无
// 值为字符串
setSessionStorage('example', 'value');
// 值为对象,对象会被转换成字符串
setSessionStorage('example', { a: 1, b: 2 });
FAQs
@lweb-utils/storage
We found that @lweb-utils/storage 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.