resolveKeyIds method
Resolve all keys given by their ids to their VerificationMethod from verification method section
Implementation
DidDocument resolveKeyIds() {
if (verificationMethod == null || verificationMethod!.isEmpty) {
return this;
}
var newDdo = DidDocument(
id: id,
context: context,
controller: controller,
alsoKnownAs: alsoKnownAs,
service: service,
verificationMethod: verificationMethod);
Map<String, VerificationMethod> veriMap = {};
for (var v in verificationMethod!) {
veriMap[v.id] = v;
if (v.id.contains('#')) {
var s = v.id.split('#');
if (s.length == 2) {
veriMap[s[1]] = v;
veriMap['#${s[1]}'] = v;
}
}
}
if (assertionMethod != null && assertionMethod!.isNotEmpty) {
newDdo.assertionMethod = _resolveIds(veriMap, assertionMethod!);
}
if (keyAgreement != null && keyAgreement!.isNotEmpty) {
newDdo.keyAgreement = _resolveIds(veriMap, keyAgreement!);
}
if (authentication != null && authentication!.isNotEmpty) {
newDdo.authentication = _resolveIds(veriMap, authentication!);
}
if (capabilityInvocation != null && capabilityInvocation!.isNotEmpty) {
newDdo.capabilityInvocation = _resolveIds(veriMap, capabilityInvocation!);
}
if (capabilityDelegation != null && capabilityDelegation!.isNotEmpty) {
newDdo.capabilityDelegation = _resolveIds(veriMap, capabilityDelegation!);
}
return newDdo;
}