atSignIsActivated function

Future<bool> atSignIsActivated(
  1. AtClient atClient,
  2. String atSign
)

Checks if the provided atSign's atServer has been properly activated with a public RSA key. atClient must be authenticated atSign is the atSign to check Returns true, if the atSign's cloud secondary server has an existing public:publickey@ in their server, Returns false, if the atSign's cloud secondary exists, but does not have an existing public:publickey@ Throws AtClientException if the cloud secondary is invalid or not reachable

Implementation

Future<bool> atSignIsActivated(final AtClient atClient, String atSign) async {
  final Metadata metadata = Metadata()
    ..isPublic = true
    ..namespaceAware = false;

  final AtKey publicKey = AtKey()
    ..sharedBy = atSign
    ..key = 'publickey'
    ..metadata = metadata;

  try {
    await atClient.get(publicKey);
    return true;
  } catch (e) {
    if (e is AtKeyNotFoundException ||
        (e is AtClientException &&
            e.message.contains("public:publickey") &&
            e.message.contains("does not exist in keystore"))) {
      return false;
    }
    rethrow;
  }
}