
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@tufjs/canonical-json
Advanced tools
The @tufjs/canonical-json npm package is designed for creating JSON strings in a canonical format. This is particularly useful in scenarios where consistent byte representations of JSON objects are necessary, such as cryptographic operations or when comparing JSON data structures without regard to non-significant differences like whitespace or key ordering.
Canonicalization of JSON objects
This feature allows the conversion of JavaScript objects into a canonical JSON string format, ensuring consistent ordering of object keys and formatting.
const canonicalJson = require('@tufjs/canonical-json');
const obj = { b: 1, a: 2 };
const canonicalObjStr = canonicalJson.stringify(obj);
// canonicalObjStr will be '{"a":2,"b":1}'
Similar to @tufjs/canonical-json, json-stable-stringify offers functionality for producing deterministic JSON strings by sorting the keys. It allows for custom comparison functions, which provides flexibility in how the canonicalization is performed compared to @tufjs/canonical-json.
This package also aims to provide a way to generate canonical JSON strings. It's similar in purpose to @tufjs/canonical-json but is a different implementation. The choice between the two might come down to specific project dependencies or personal preference for one API over the other.
JSON canonicalization compliant with the OLPC Canonical JSON specification.
If you're looking for RFC 8785 compliant JSON canonicalization there are any number of libraries to choose from. You should only select this library if you know that you specifically need support for the OLPC-style of canonicalization.
One reason you might chose OLPC compliance is for interoperability with The Update Framework which specifically calls out OLPC as the canonicalization standard for computing signatures over TUF metadata.
The canonicalized strings generated by this library are compatible with those generated by the Python-based securesystemslib library and the Go-based go-securesystemslib library.
npm install @tufjs/canonical-json
const json = require('@tufjs/canonical-json')
const obj = {
bool: true,
num: 42,
ary: [1, 2, 3],
str: "foo\\bar"
}
console.log(json.canonicalize(obj))
// output: {"ary":[1,2,3],"bool":true,"num":42,"str":"foo\\bar"}
FAQs
OLPC JSON canonicalization
The npm package @tufjs/canonical-json receives a total of 5,687,779 weekly downloads. As such, @tufjs/canonical-json popularity was classified as popular.
We found that @tufjs/canonical-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.