Open-Attestation / open-attestation

Meta framework for providing digital provenance and integrity to documents.
https://openattestation.com
Apache License 2.0
54 stars 18 forks source link

W3C a test suite #61

Open Nebulis opened 4 years ago

Nebulis commented 4 years ago

Current Behavior

Generating a VC using OpenAttestation is not compatible with the W3C standard

Expected Behavior

OpenAttestation MUST generate valid W3C VC.

Proposal

The goal is to make OpenAttestation be able to generate valid W3C VC using the W3C VC test suite.

In order to support this multiple issues have already been created in this repository and in open-attestation-cli repository.

The goal of this issue is to focus only on the validation of the input data. Most of the test ran by the test suite provide a credential as input and ensure that the output is either a valid VC or an error.

In this issue we will focus on the following tests suite:

Note 1: this issue will focus on VC only and will ignore VP tests Note 2: it is for the moment unclear how we should handle JSON-LD. As per the test suite, we should throw error when we encounter properties not describe by the data. However the validation is quite slow. We will keep the validation for the moment but further inspection will be needed. Example to validate JSON-LD:

import { compact } from "jsonld";
compact(credential, "https://w3id.org/security/v2", {
  expansionMap: info => {
    if (info.unmappedProperty) {
      throw new Error(
        'The property "' + info.unmappedProperty + '" in the input ' + "was not defined in the context."
      );
    }
  }
});