uploadCrossSigningSignatures method
Publishes cross-signing signatures for the user.
The signed JSON object must match the key previously uploaded or
retrieved for the given key ID, with the exception of the signatures
property, which contains the new signature(s) to add.
body A map from user ID to key ID to signed JSON objects containing 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?>>> body,
) async {
final requestUri = Uri(path: '_matrix/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(
body.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']);
}