VerificationMethod.fromJson constructor

VerificationMethod.fromJson(
  1. dynamic jsonObject
)

Implementation

VerificationMethod.fromJson(dynamic jsonObject) {
  var method = credentialToMap(jsonObject);
  if (method.containsKey('id')) {
    id = method['id'];
  } else {
    throw FormatException('id property is needed in Verification Method');
  }
  if (method.containsKey('type')) {
    type = method['type'];
  } else {
    throw FormatException('type property is needed in Verification Method');
  }
  if (method.containsKey('controller')) {
    controller = method['controller'];
  } else {
    throw FormatException(
        'controller property is needed in Verification Method');
  }
  publicKeyJwk = method['publicKeyJwk'];
  publicKeyMultibase = method['publicKeyMultibase'];

  if (publicKeyJwk == null && publicKeyMultibase == null) {
    throw Exception(
        'Verification Method must have an entry for a public key');
  }
}