convertAllKeysToJwk method

DidDocument convertAllKeysToJwk()

If keys are given as multibase-keys convert to Json web keys (this format is widely used in this package)

Implementation

DidDocument convertAllKeysToJwk() {
  var newDdo = DidDocument(
      id: id,
      context: context,
      controller: controller,
      alsoKnownAs: alsoKnownAs,
      service: service);

  if (verificationMethod != null && verificationMethod!.isNotEmpty) {
    List<VerificationMethod> newVm = [];
    for (var entry in verificationMethod!) {
      newVm.add(entry.toPublicKeyJwk());
    }
    newDdo.verificationMethod = newVm;
  }
  if (assertionMethod != null && assertionMethod!.isNotEmpty) {
    newDdo.assertionMethod = _convertKeys(assertionMethod!);
  }
  if (keyAgreement != null && keyAgreement!.isNotEmpty) {
    newDdo.keyAgreement = _convertKeys(keyAgreement!);
  }
  if (authentication != null && authentication!.isNotEmpty) {
    newDdo.authentication = _convertKeys(authentication!);
  }
  if (capabilityInvocation != null && capabilityInvocation!.isNotEmpty) {
    newDdo.capabilityInvocation = _convertKeys(capabilityInvocation!);
  }
  if (capabilityDelegation != null && capabilityDelegation!.isNotEmpty) {
    newDdo.capabilityDelegation = _convertKeys(capabilityDelegation!);
  }
  return newDdo;
}