Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@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 3,150,788 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.