LinkedDataProof.fromJson constructor

LinkedDataProof.fromJson(
  1. dynamic jsonObject
)

Implementation

LinkedDataProof.fromJson(dynamic jsonObject) {
  var proof = credentialToMap(jsonObject);
  if (proof.containsKey('type')) {
    type = proof['type'];
  } else {
    throw FormatException('Type property is needed in proof object');
  }

  if (proof.containsKey('proofPurpose')) {
    proofPurpose = proof['proofPurpose'];
  } else {
    throw FormatException('proofPurpose property is needed in proof object');
  }

  if (proof.containsKey('verificationMethod')) {
    verificationMethod = proof['verificationMethod'];
  } else {
    throw FormatException('verification Method is needed in proof object');
  }

  if (proof.containsKey('created')) {
    created = DateTime.parse(proof['created']);
  } else {
    throw FormatException('created is needed in proof object');
  }

  proofValue = proof['proofValue'];
  jws = proof['jws'];
  if (jws == null && proofValue == null) {
    throw FormatException('one of proofValue or jws must be present');
  }

  domain = proof['domain'];
  challenge = proof['challenge'];

  _originalDoc = proof;
}