
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
cooky
is a lightweight library that is used as a wrapper around the native JS cookie handling system.
It encapsulates all necessary methods in an handy object instead of using document.cookie
in that fancily strange manner (aka document.cookie = "mynewcookie=pingas"
to add a cookie and document.cookie
to get the whole cookie string).
First, download the library either from github or npm (npm i -S cooky
).
Then import/load it :
//es >= 6
import { Cooky } from "cooky"
//node
const { Cooky } = require("cooky");
<!-- as a script tag -->
<!DOCTYPE html>
<html>
<head>
<!-- [...] -->
<script src="path/to/cooky.js"></script>
</head>
<body>
<!-- [...] -->
</body>
</html>
Then you'll be able to use it (either as cooky.Cooky
or Cooky
for in-browser use).
Cooky.has(name : String)
Determines whether or not there's a cookie associated to the given name.
Warning: Throws an error if name
is not a String
Cooky.getAll()
Retrieves the cookies as an array of objects that follow the following pattern:
{
name: String,
value: String
}
Warning: Throws an error if there has been a problem while parsing the cookie string.
Cooky.getAllAsObject()
Retrieves the cookies, but instead of returning an array of object, it returns an objects that has the names of the cookies as keys and their respective values as values.
Cooky.getAllAsMap()
Retrieves the cookies just like getAllAsObject
but send back a Map
insted of a regular Object
(only if available, otherwise it would throw an error).
Cooky.get(name : String)
Retrieves the cookie that has name
as its name.
Warning: Will throw an exception if name
is not a String
.
Cooky.set(name : String, value : String)
Creates a new cookie that corresponds to name=value;
NB: You can chain set
Since the source code of cooky
was written using ES6+ syntax and transpiled using babel
and its preset env
with default settings, the compatibilities are the one you obtain from transpiling using env
with its default settings.
In version 2.1.0, the cookie parsing algorithm has been revisited to allow parsing of object-like cookies and use of decodeURIComponent
for some backend technologies.
FAQs
A lightweight library that allows you to manage simple cookies in JS
The npm package cooky receives a total of 0 weekly downloads. As such, cooky popularity was classified as not popular.
We found that cooky 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.