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.
An ultra-light (373 bytes) library for working with cookies in JavaScript
An ultra-light library for working with cookies in JavaScript.
yarn add hardtack -E
# or
npm i hardtack -E
// Load the full library
import hardtack from 'hardtack';
// Load the necessary method
import get from 'hardtack/src/get';
import set from 'hardtack/src/set';
import remove from 'hardtack/src/remove';
hardtack.set('name', 'Ali', {
path: '/',
domain: 'gasymov.com',
maxAge: 31536000, // 1 year
samesite: 'lax'
});
hardtack.get(); // { name: 'Ali' };
hardtack.get('name'); // Ali;
hardtack.remove('name', {
path: '/',
domain: 'gasymov.com'
});
set(name: string, value: string, options)
Create a cookie
For example: '/'
, '/mydir'
If not specified, defaults to the current path of the current document location.
For example: example.com
or subdomain.example.com
If not specified, this defaults to the host portion of the current document location. Contrary to earlier specifications, leading dots in domain names are ignored, but browsers may decline to set the cookie containing such dots. If a domain is specified, subdomains are always included.
You can use options['max-age']
, the result will be the same.
Max age in seconds. For example: 60*60*24*365
or 31536000
for a year
Date in GMT format. See Date.toUTCString() for help formatting this value.
Cookie to only be transmitted over secure protocol as https.
SameSite prevents the browser from sending this cookie along with cross-site requests. Possible values for the flag are lax
or strict
.
More about the options of cookies on MDN.
get(name: string)
Get cookie value
remove(name: string, options)
Remove cookie. When you delete a cookie, you must pass the same options.path
and options.domain
that you passed when you created the cookie.
5.0.1 - 2021-01-02
FAQs
An ultra-light (373 bytes) library for working with cookies in JavaScript
We found that hardtack 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.