uploadCrossSigningSignatures method

Future<Map<String, Map<String, Map<String, Object?>>>?> uploadCrossSigningSignatures(
  1. Map<String, Map<String, Map<String, Object?>>> signatures
)
inherited

Publishes cross-signing signatures for the user. The request body is a map from user ID to key ID to signed JSON object.

signatures The signatures to be published.

returns failures: A map from user ID to key ID to an error for any signatures that failed. If a signature was invalid, the errcode will be set to M_INVALID_SIGNATURE.

Implementation

Future<Map<String, Map<String, Map<String, Object?>>>?>
    uploadCrossSigningSignatures(
        Map<String, Map<String, Map<String, Object?>>> signatures) async {
  final requestUri = Uri(path: '_api/client/v3/keys/signatures/upload');
  final request = Request('POST', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  request.headers['content-type'] = 'application/json';
  request.bodyBytes = utf8.encode(jsonEncode(signatures
      .map((k, v) => MapEntry(k, v.map((k, v) => MapEntry(k, v))))));
  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 ((v) => v != null
      ? (v as Map<String, Object?>).map((k, v) => MapEntry(
          k,
          (v as Map<String, Object?>)
              .map((k, v) => MapEntry(k, v as Map<String, Object?>))))
      : null)(json['failures']);
}