Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
structured-headers
Advanced tools
Implementation of draft-ietf-httpbis-header-structure, structured headers for HTTP.
This library is a parser and serializer for the structured headers specification. Currently it's still a draft, so this package is also in alpha until the specification stabilizes as a RFC.
Using npm:
npm install structured-headers
The following are examples of item
headers:
Parsed as string
# Parsed into string
Header: "foo"
Header: bar
# Parsed into number
Header: 5
Header: -10
Header: 5.01415
# Parsed into boolean
Header: ?T
Header: ?F
To parse these header values, use parseItem
:
const sh = require('structured-headers');
console.log(sh.parseItem(header));
Lists contain items separated by comma Here's an example
Header: 5, "foo", bar, ?T
To parse these:
const sh = require('structured-headers');
console.log(sh.parseList(header));
This will result in the following object:
[
{value: 5, parameters: {}},
{value: 'foo', parameters: {}},
{value: 'bar', parameters: {}},
{value: true, parameters: {}},
]
This is an example of a more complex list:
Header: "foo"; param=1, "bar", ("sublistA", "sublistB")
Parsing this list will result in:
[
{value: 'foo', parameters: {param: 1}},
{value: 'bar', parameters: {}},
{value: ['sublistA', 'sublistB'], parameters: {}},
]
A dictionary is a key->value object. Examples:
Example: foo: "Bar"; baz: 5
Dictionary keys can be any item. This is parsed with:
const sh = require('structured-headers');
console.log(sh.parseDictionary(header));
The output for this is the following object:
{
foo: { value: 'bar', parameters: {} },
baz: { value: 5, parameters: {} },
}
The serialiser functions work the exact same way, but in opposite direction. They all return strings.
const sh = require('structured-headers');
// Returns "foo", "bar"
sh.serializeList([
{value: 'foo'},
{value: 'bar'}
]);
// Returns a=1, b=?0
sh.serializeDictionary({
a: { value: 1},
b: { value: false},
});
// Returns 42
sh.serializeItem(42);
// Returns 5.5
sh.serializeItem(5.5);
// Returns "hello world"
sh.serializeItem("hello world");
// Returns ?1
sh.serializeItem(true);
// Returns a base-64 representation like: *aGVsbG8=*
sh.serializeItem(Buffer.from('hello'))
There is a minified version of this library in the browser/
directory. This minified
file will expose a global variable called 'structuredHeader' which contains the rest
of the api.
FAQs
Implementation of Structured Field Values for HTTP (RFC9651, RFC8941)
The npm package structured-headers receives a total of 566,543 weekly downloads. As such, structured-headers popularity was classified as popular.
We found that structured-headers 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.