Skip to content

Latest commit

 

History

History
45 lines (38 loc) · 3.1 KB

README.md

File metadata and controls

45 lines (38 loc) · 3.1 KB

Json LD Processing Library

This package implements the JSON-LD Processing algorithms 1.1 and the URDNA2015 Canonicalization algorithm in pure Dart.

Important Note: This package is work-in-progress. Not all algorithms are implemented for now and not everything works perfect (See Implementation Status). But in general it works.

Usage

Map<String, dynamic> input = {}; //a valid Json-ld document
//expansion
var expanded = await JsonLdProcessor.expand(input);
//flattening
var flattened = await JsonLdProcessor.flatten(input);
//toRdf
var rdf = await JsonLdProcessor.toRdf(input);
//normalize (URDNA2015) with additional options
var normalized = await JsonLdProcessor.normalize(input, options: JsonLdOptions(safeMode: true));

SafeMode Option

As the implementor of the normalization algorithms URDNA2015 and URGNA2012 in java showed in his repo, using json-ld and normalization for signing there are some security flaws. In some cases the documents could be manipulated and the signatures stays correct. One reasons for this can be found in the expansion algorithm. If a property of the input document can't be expanded to an IRI or keyword, it is dropped and so not included in the normalized dataset.To be able to throw an exception in this case, there is a safeMode option. It is default set to false. But if it is true, the exception is thrown. If not, the property is dropped as standardized. I recommend setting it to true, if you normalize a json-ld document before signing.

Note: The idea introducing this option is borrowed from the JavaScript implementation which powers the JSON-LD Playground as well. This option is not part of the standard yet.

Implementation Status and Test Coverage

Algorithm Tests passed Tests failed Notes
expand 363 8
flatten 55 1 one failed, because of missing compaction algorithm
compact 94 149 needs bugfixing
fromRdf 0 0 not implemented yet
toRdf 406 30 rdfDirection option is not implemented yet
normalize 62 1

Run tests

The test data is taken from here for json-ld api test and here for normalization tests. Therefore you need to clone these two repos next to this, if you would like to run the tests.

Future Plans

  • remove bugs
  • implement Compaction and fromRdf
  • support framing