You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@tufjs/canonical-json

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tufjs/canonical-json

OLPC JSON canonicalization


Version published
Maintainers
2
Created

Package description

What is @tufjs/canonical-json?

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.

What are @tufjs/canonical-json's main functionalities?

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}'

Other packages similar to @tufjs/canonical-json

Readme

Source

@tufjs/canonical-json

JSON canonicalization compliant with the OLPC Canonical JSON specification.

Why

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.

Installation

npm install @tufjs/canonical-json

Usage

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"}

Keywords

FAQs

Package last updated on 17 Aug 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc