getApkamPublicKey method

Future<String> getApkamPublicKey(
  1. String atSign,
  2. String enrollmentId
)
inherited

Fetch the APKAM public signing key which enrollmentId of atSign has published in its per-enrollment namespace. See ApkamSigning.publicSigningKeyUri.

Implementation

Future<String> getApkamPublicKey(String atSign, String enrollmentId) async {
  atSign = atSign.toAtsign();

  String? cached = lookupPubKey(atSign, enrollmentId);
  if (cached != null) return cached;

  var s = 'public:_apsk.$enrollmentId'
      '.${EnrollmentConstants.perEnrollmentApproved}'
      '$atSign';
  final AtValue av = await atClient.get(
    AtKey.fromString(s),
    getRequestOptions: GetRequestOptions()..useRemoteAtServer = true,
  );
  if (av.value is! String) {
    throw IllegalStateException('Value of $s is not a String');
  }

  cachePubKey(atSign, enrollmentId, av.value);

  return av.value;
}