getWellknownPolicy method

Future<PublicKeys> getWellknownPolicy()

Gets public key information for a Policy Server.

NOTE: Like the well-known discovery URI, this endpoint should be accessed with the hostname of the Policy Server's server name by making a GET request to https://hostname/.well-known/matrix/policy_server.

Note that this endpoint is not necessarily handled by the homeserver or Policy Server. It may be served by another webserver.

returns public_keys: The unpadded base64-encoded public keys for the Policy Server. MUST contain at least ed25519.

Implementation

Future<PublicKeys> getWellknownPolicy() async {
  final requestUri = Uri(path: '.well-known/matrix/policy_server');
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  final response = await httpClient.send(request);
  final responseBody = await response.stream.toBytes();
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final responseString = utf8.decode(responseBody);
  final json = jsonDecode(responseString);
  return PublicKeys.fromJson(json['public_keys'] as Map<String, Object?>);
}