uploadKeys method

Future<Map<String, int>> uploadKeys({
  1. SDNDeviceKeys? deviceKeys,
  2. Map<String, Object?>? oneTimeKeys,
  3. Map<String, Object?>? fallbackKeys,
})

Publishes end-to-end encryption keys for the device. https://sdn.org/docs/spec/client_server/r0.6.1#post-sdn-client-r0-keys-query

Implementation

Future<Map<String, int>> uploadKeys(
    {SDNDeviceKeys? deviceKeys,
    Map<String, Object?>? oneTimeKeys,
    Map<String, Object?>? fallbackKeys}) async {
  final response = await request(
    RequestType.POST,
    '/client/v3/keys/upload',
    data: {
      if (deviceKeys != null) 'device_keys': deviceKeys.toJson(),
      if (oneTimeKeys != null) 'one_time_keys': oneTimeKeys,
      if (fallbackKeys != null) ...{
        'fallback_keys': fallbackKeys,
        'org.sdn.msc2732.fallback_keys': fallbackKeys,
      },
    },
  );
  return Map<String, int>.from(response['one_time_key_counts'] as Map);
}