uploadCrossSigningKeys method

Future<void> uploadCrossSigningKeys({
  1. AuthenticationData? auth,
  2. SDNCrossSigningKey? masterKey,
  3. SDNCrossSigningKey? selfSigningKey,
  4. SDNCrossSigningKey? userSigningKey,
})
inherited

Publishes cross-signing keys for the user.

This API endpoint uses the User-Interactive Authentication API.

auth Additional authentication information for the user-interactive authentication API.

masterKey Optional. The user's master key.

selfSigningKey Optional. The user's self-signing key. Must be signed by the accompanying master key, or by the user's most recently uploaded master key if no master key is included in the request.

userSigningKey Optional. The user's user-signing key. Must be signed by the accompanying master key, or by the user's most recently uploaded master key if no master key is included in the request.

Implementation

Future<void> uploadCrossSigningKeys(
    {AuthenticationData? auth,
    SDNCrossSigningKey? masterKey,
    SDNCrossSigningKey? selfSigningKey,
    SDNCrossSigningKey? userSigningKey}) async {
  final requestUri = Uri(path: '_api/client/v3/keys/device_signing/upload');
  final request = Request('POST', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  request.headers['content-type'] = 'application/json';
  request.bodyBytes = utf8.encode(jsonEncode({
    if (auth != null) 'auth': auth.toJson(),
    if (masterKey != null) 'master_key': masterKey.toJson(),
    if (selfSigningKey != null) 'self_signing_key': selfSigningKey.toJson(),
    if (userSigningKey != null) 'user_signing_key': userSigningKey.toJson(),
  }));
  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 ignore(json);
}