Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtClient: Add useRemote (or similar option name) to atClient.getKeys/.getAtKeys #1156

Open
XavierChanth opened this issue Oct 31, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@XavierChanth
Copy link
Member

Is your feature request related to a problem? Please describe.

SSH No Ports requires that we fetch the keys from remote (since we intentionally do not have a local store for ssh no ports), but there are no client options that support scanning directly from remote.

Right now the workaround is to manually build a scan verb:

Future<List<AtKey>> _getAtKeysRemote(
      {String? regex,
      String? sharedBy,
      String? sharedWith,
      bool showHiddenKeys = false}) async {
    var builder = ScanVerbBuilder()
      ..sharedWith = sharedWith
      ..sharedBy = sharedBy
      ..regex = regex
      ..showHiddenKeys = showHiddenKeys
      ..auth = true;
    var scanResult = await atClient.getRemoteSecondary()?.executeVerb(builder);
    scanResult = scanResult?.replaceFirst('data:', '') ?? '';
    var result = <AtKey?>[];
    if (scanResult.isNotEmpty) {
      result = List<String>.from(jsonDecode(scanResult)).map((key) {
        try {
          return 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');
        }
      }).toList();
    }
    result.removeWhere((element) => element == null);
    return result.cast<AtKey>();
  }

Describe the solution you'd like

Add an options object which contains something similar to atClient.get's byPassCache option or atClient.put's useRemoteAtServer option.

Describe alternatives you've considered

No response

Additional context

No response

@XavierChanth
Copy link
Member Author

Please note that this item is not urgent (probably only a p2 or p3), since the above workaround works perfectly fine for the time being. However it would be helpful to eventually add a feature like this, hence the ticket.

@gkc gkc changed the title Add useRemote (or similar option name) to atClient.getKeys/.getAtKeys AtClient: Add useRemote (or similar option name) to atClient.getKeys/.getAtKeys Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants