Giter Club home page Giter Club logo

json_ld_procossor's Introduction

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

json_ld_procossor's People

Contributors

saotto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.