libkazv
keys.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "basejob.hpp"
10 
11 namespace Kazv::Api {
12 
17 class UploadKeysJob : public BaseJob {
18 public:
19 
20 
21 
22 class JobResponse : public Response
23 {
24 
25 public:
27  bool success() const;
28 
29  // Result properties
30 
31 
32 
33 
38 immer::map<std::string, int> oneTimeKeyCounts() const;
39 
40 };
41  static constexpr auto needsAuth() {
42  return true
43  ;
44  }
45 
46 
47 // Construction/destruction
48 
78  explicit UploadKeysJob(std::string serverUrl
79  , std::string _accessToken
80  ,
81  std::optional<DeviceKeys> deviceKeys = std::nullopt, JsonWrap oneTimeKeys = {}, JsonWrap fallbackKeys = {}
82  );
83 
84 
85  static BaseJob::Query buildQuery(
86  );
87 
88  static BaseJob::Body buildBody(std::optional<DeviceKeys> deviceKeys, JsonWrap oneTimeKeys, JsonWrap fallbackKeys);
89 
90 
91 
92 
93 
94  UploadKeysJob withData(JsonWrap j) &&;
95  UploadKeysJob withData(JsonWrap j) const &;
96  };
98  }
99  namespace nlohmann
100  {
101  using namespace Kazv;
102  using namespace Kazv::Api;
103 
104  }
105 
106  namespace Kazv::Api
107  {
108 
113 class QueryKeysJob : public BaseJob {
114 public:
115  // Inner data structures
116 
121  {
123  std::optional<std::string> deviceDisplayName;
124 
125  };
126 
129  DeviceKeys
130  {
134  std::optional<UnsignedDeviceInfo> unsignedData;
135 
136  };
137 
138 
139 
140 class JobResponse : public Response
141 {
142 
143 public:
145  bool success() const;
146 
147  // Result properties
148 
149 
150 
151 
159 immer::map<std::string, JsonWrap> failures() const;
160 
161 
167 immer::map<std::string, immer::map<std::string, DeviceInformation>> deviceKeys() const;
168 
169 
176 immer::map<std::string, CrossSigningKey> masterKeys() const;
177 
178 
183 immer::map<std::string, CrossSigningKey> selfSigningKeys() const;
184 
185 
191 immer::map<std::string, CrossSigningKey> userSigningKeys() const;
192 
193 };
194  static constexpr auto needsAuth() {
195  return true
196  ;
197  }
198 
199 
200 // Construction/destruction
201 
219  explicit QueryKeysJob(std::string serverUrl
220  , std::string _accessToken
221  ,
222  immer::map<std::string, immer::array<std::string>> deviceKeys , std::optional<int> timeout = std::nullopt, std::optional<std::string> token = std::nullopt
223  );
224 
225 
226  static BaseJob::Query buildQuery(
227  );
228 
229  static BaseJob::Body buildBody(immer::map<std::string, immer::array<std::string>> deviceKeys, std::optional<int> timeout, std::optional<std::string> token);
230 
231 
232 
233 
234 
235  QueryKeysJob withData(JsonWrap j) &&;
236  QueryKeysJob withData(JsonWrap j) const &;
237  };
239  }
240  namespace nlohmann
241  {
242  using namespace Kazv;
243  using namespace Kazv::Api;
244  template<>
245  struct adl_serializer<QueryKeysJob::UnsignedDeviceInfo> {
246 
247  static void to_json(json& jo, const QueryKeysJob::UnsignedDeviceInfo &pod)
248  {
249  if (! jo.is_object()) { jo = json::object(); }
250 
251 
252 
253  addToJsonIfNeeded(jo, "device_display_name"s, pod.deviceDisplayName);
254  }
255 
256  static void from_json(const json &jo, QueryKeysJob::UnsignedDeviceInfo& result)
257  {
258 
259  if (jo.contains("device_display_name"s)) {
260  result.deviceDisplayName = jo.at("device_display_name"s);
261  }
262 
263  }
264 
265 };
266  template<>
267  struct adl_serializer<QueryKeysJob::DeviceInformation> {
268 
269  static void to_json(json& jo, const QueryKeysJob::DeviceInformation &pod)
270  {
271  if (! jo.is_object()) { jo = json::object(); }
272  jo = static_cast<const DeviceKeys &>(pod);
273  //nlohmann::to_json(jo, static_cast<const DeviceKeys &>(pod));
274 
275 
276  addToJsonIfNeeded(jo, "unsigned"s, pod.unsignedData);
277  }
278 
279  static void from_json(const json &jo, QueryKeysJob::DeviceInformation& result)
280  {
281  static_cast<DeviceKeys &>(result) = jo;
282  //nlohmann::from_json(jo, static_cast<const DeviceKeys &>(result));
283  if (jo.contains("unsigned"s)) {
284  result.unsignedData = jo.at("unsigned"s);
285  }
286 
287  }
288 
289 };
290  }
291 
292  namespace Kazv::Api
293  {
294 
299 class ClaimKeysJob : public BaseJob {
300 public:
301 
302 
303 
304 class JobResponse : public Response
305 {
306 
307 public:
309  bool success() const;
310 
311  // Result properties
312 
313 
314 
315 
323 immer::map<std::string, JsonWrap> failures() const;
324 
325 
334 immer::map<std::string, immer::map<std::string, JsonWrap>> oneTimeKeys() const;
335 
336 };
337  static constexpr auto needsAuth() {
338  return true
339  ;
340  }
341 
342 
343 // Construction/destruction
344 
355  explicit ClaimKeysJob(std::string serverUrl
356  , std::string _accessToken
357  ,
358  immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys , std::optional<int> timeout = std::nullopt
359  );
360 
361 
362  static BaseJob::Query buildQuery(
363  );
364 
365  static BaseJob::Body buildBody(immer::map<std::string, immer::map<std::string, std::string>> oneTimeKeys, std::optional<int> timeout);
366 
367 
368 
369 
370 
371  ClaimKeysJob withData(JsonWrap j) &&;
372  ClaimKeysJob withData(JsonWrap j) const &;
373  };
375  }
376  namespace nlohmann
377  {
378  using namespace Kazv;
379  using namespace Kazv::Api;
380 
381  }
382 
383  namespace Kazv::Api
384  {
385 
398 class GetKeysChangesJob : public BaseJob {
399 public:
400 
401 
402 
403 class JobResponse : public Response
404 {
405 
406 public:
408  bool success() const;
409 
410  // Result properties
411 
412 
413 
414 
417 immer::array<std::string> changed() const;
418 
419 
423 immer::array<std::string> left() const;
424 
425 };
426  static constexpr auto needsAuth() {
427  return true
428  ;
429  }
430 
431 
432 // Construction/destruction
433 
449  explicit GetKeysChangesJob(std::string serverUrl
450  , std::string _accessToken
451  ,
452  std::string from , std::string to
453  );
454 
455 
456  static BaseJob::Query buildQuery(
457  std::string from, std::string to);
458 
459  static BaseJob::Body buildBody(std::string from, std::string to);
460 
461 
462 
463 
464 
465  GetKeysChangesJob withData(JsonWrap j) &&;
466  GetKeysChangesJob withData(JsonWrap j) const &;
467  };
469  }
470  namespace nlohmann
471  {
472  using namespace Kazv;
473  using namespace Kazv::Api;
474 
475  }
476 
477  namespace Kazv::Api
478  {
479 
480 } // namespace Kazv::Api
Definition: keys.hpp:305
Claim one-time encryption keys.
Definition: keys.hpp:299
static constexpr auto needsAuth()
Definition: keys.hpp:337
Query users with recent device key updates.
Definition: keys.hpp:398
static constexpr auto needsAuth()
Definition: keys.hpp:426
Definition: keys.hpp:141
Download device identity keys.
Definition: keys.hpp:113
static constexpr auto needsAuth()
Definition: keys.hpp:194
JobResponse(Response r)
Definition: keys.cpp:77
bool success() const
Definition: keys.cpp:80
immer::map< std::string, int > oneTimeKeyCounts() const
For each key algorithm, the number of unclaimed one-time keys of that type currently held on the serv...
Definition: keys.cpp:91
Upload end-to-end encryption keys.
Definition: keys.hpp:17
static BaseJob::Body buildBody(std::optional< DeviceKeys > deviceKeys, JsonWrap oneTimeKeys, JsonWrap fallbackKeys)
Definition: keys.cpp:21
static constexpr auto needsAuth()
Definition: keys.hpp:41
UploadKeysJob withData(JsonWrap j) &&
Definition: keys.cpp:63
UploadKeysJob(std::string serverUrl, std::string _accessToken, std::optional< DeviceKeys > deviceKeys=std::nullopt, JsonWrap oneTimeKeys={}, JsonWrap fallbackKeys={})
Upload end-to-end encryption keys.
Definition: keys.cpp:43
static BaseJob::Query buildQuery()
Definition: keys.cpp:13
Definition: basejob.hpp:91
Definition: basejob.hpp:77
::Kazv::Body Body
Definition: basejob.hpp:100
Definition: jsonwrap.hpp:23
Definition: location.hpp:10
Definition: location.hpp:10
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
nlohmann::json json
Definition: jsonwrap.hpp:20
Definition: location.hpp:27
Device identity keys.
Definition: device_keys.hpp:13
Returns the current devices and identity keys for the given users.
Definition: keys.hpp:130
std::optional< UnsignedDeviceInfo > unsignedData
Additional data added to the device key information by intermediate servers, and not covered by the s...
Definition: keys.hpp:134
Additional data added to the device key information by intermediate servers, and not covered by the s...
Definition: keys.hpp:121
std::optional< std::string > deviceDisplayName
The display name which the user set on the device.
Definition: keys.hpp:123
Definition: basejob.hpp:50
static void to_json(json &jo, const QueryKeysJob::DeviceInformation &pod)
Definition: keys.hpp:269
static void from_json(const json &jo, QueryKeysJob::DeviceInformation &result)
Definition: keys.hpp:279
static void to_json(json &jo, const QueryKeysJob::UnsignedDeviceInfo &pod)
Definition: keys.hpp:247
static void from_json(const json &jo, QueryKeysJob::UnsignedDeviceInfo &result)
Definition: keys.hpp:256