getKeys method

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

Get all the keys stored in user's secondary in string 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<String>> getKeys(
    {String? regex,
    String? sharedBy,
    String? sharedWith,
    bool isDedicated = false}) async {
  var builder = ScanVerbBuilder()
    ..sharedWith = sharedWith
    ..sharedBy = sharedBy
    ..regex = regex
    ..auth = true;
  var secondary = getSecondary(isDedicated: isDedicated);
  var scanResult = await secondary.executeVerb(builder);
  if (isDedicated && (secondary is RemoteSecondary)) {
    await secondary.atLookUp.connection!.close();
  }
  scanResult = _formatResult(scanResult);
  var result = [];
  if (scanResult != null && scanResult.isNotEmpty) {
    result = List<String>.from(jsonDecode(scanResult));
  }
  return result as FutureOr<List<String>>;
}