getAtKeys method

  1. @override
Future<List<AtKey>> getAtKeys({
  1. String? regex,
  2. String? sharedBy,
  3. String? sharedWith,
  4. bool showHiddenKeys = false,
})
override

Get all the keys stored in user's secondary in AtKey format. If regex is specified only matching keys are returned. If sharedBy is specified, then gets the keys from sharedBy user shared with current atClient user. If sharedWith is specified, then gets the keys shared to sharedWith user from the current atClient user.

e.g alice is the current atsign
 scan
  getKeys();
 scan .persona
  getKeys(regex:'.persona');
 scan:@bob
  getKeys(sharedBy:'@bob');

Implementation

@override
Future<List<AtKey>> getAtKeys(
    {String? regex,
    String? sharedBy,
    String? sharedWith,
    bool showHiddenKeys = false}) async {
  var getKeysResult = await getKeys(
      regex: regex,
      sharedBy: sharedBy,
      sharedWith: sharedWith,
      showHiddenKeys: showHiddenKeys);
  var result = <AtKey>[];
  if (getKeysResult.isNotEmpty) {
    for (var key in getKeysResult) {
      try {
        result.add(AtKey.fromString(key));
      } on InvalidSyntaxException {
        _logger.severe('$key is not a well-formed key');
      } on Exception catch (e) {
        _logger.severe(
            'Exception occurred: ${e.toString()}. Unable to form key $key');
      }
    }
  }
  return result;
}