Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@tufjs/canonical-json
Advanced tools
Package description
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.
Readme
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 3,672,055 weekly downloads. As such, @tufjs/canonical-json popularity was classified as popular.
We found that @tufjs/canonical-json demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.