getDidFromDidConfiguration function

Future<List<String>> getDidFromDidConfiguration(
  1. String url
)

Implementation

Future<List<String>> getDidFromDidConfiguration(String url) async {
  List<String> didsInConfig = [];
  var uri = Uri.parse(url);
  print('https://${uri.host}/.well-known/did-configuration');
  try {
    var res = await http
        .get(Uri.parse('https://${uri.host}/.well-known/did-configuration'))
        .timeout(Duration(seconds: 30));
    if (res.statusCode == 200) {
      var entries = jsonDecode(res.body);
      List<dynamic> dids = entries['entries'];
      await Future.forEach(dids, (dynamic element) async {
        var jwt = element['jwt'];
        var did = element['did'];
        print(did);
        var verified = await verifyStringSignature(jwt, expectedDid: did);
        print(verified);
        if (verified) didsInConfig.add(did);
      });
    }
  } catch (e) {
    throw Exception('Error occurred during fetch of did-configuration: $e');
  }
  return didsInConfig;
}