libQuotient
A Qt library for building matrix clients
cross_signing.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/csapi/definitions/auth_data.h>
6 #include <Quotient/csapi/definitions/cross_signing_key.h>
7 
8 #include <Quotient/jobs/basejob.h>
9 
10 namespace Quotient {
11 
12 //! \brief Upload cross-signing keys.
13 //!
14 //! Publishes cross-signing keys for the user.
15 //!
16 //! This API endpoint uses the [User-Interactive Authentication
17 //! API](/client-server-api/#user-interactive-authentication-api).
18 //!
19 //! User-Interactive Authentication MUST be performed, except in these cases:
20 //! - there is no existing cross-signing master key uploaded to the homeserver, OR
21 //! - there is an existing cross-signing master key and it exactly matches the
22 //! cross-signing master key provided in the request body. If there are any additional
23 //! keys provided in the request (self-signing key, user-signing key) they MUST also
24 //! match the existing keys stored on the server. In other words, the request contains
25 //! no new keys.
26 //!
27 //! This allows clients to freely upload one set of keys, but not modify/overwrite keys if
28 //! they already exist. Allowing clients to upload the same set of keys more than once
29 //! makes this endpoint idempotent in the case where the response is lost over the network,
30 //! which would otherwise cause a UIA challenge upon retry.
31 class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob {
32 public:
33  //! \param masterKey
34  //! Optional. The user\'s master key.
35  //!
36  //! \param selfSigningKey
37  //! Optional. The user\'s self-signing key. Must be signed by
38  //! the accompanying master key, or by the user\'s most recently
39  //! uploaded master key if no master key is included in the
40  //! request.
41  //!
42  //! \param userSigningKey
43  //! Optional. The user\'s user-signing key. Must be signed by
44  //! the accompanying master key, or by the user\'s most recently
45  //! uploaded master key if no master key is included in the
46  //! request.
47  //!
48  //! \param auth
49  //! Additional authentication information for the
50  //! user-interactive authentication API.
51  explicit UploadCrossSigningKeysJob(
52  const std::optional<CrossSigningKey>& masterKey = std::nullopt,
53  const std::optional<CrossSigningKey>& selfSigningKey = std::nullopt,
54  const std::optional<CrossSigningKey>& userSigningKey = std::nullopt,
55  const std::optional<AuthenticationData>& auth = std::nullopt);
56 };
57 
58 //! \brief Upload cross-signing signatures.
59 //!
60 //! Publishes cross-signing signatures for the user.
61 //!
62 //! The signed JSON object must match the key previously uploaded or
63 //! retrieved for the given key ID, with the exception of the `signatures`
64 //! property, which contains the new signature(s) to add.
65 class QUOTIENT_API UploadCrossSigningSignaturesJob : public BaseJob {
66 public:
67  //! \param signatures
68  //! A map from user ID to key ID to signed JSON objects containing the
69  //! signatures to be published.
70  explicit UploadCrossSigningSignaturesJob(
71  const QHash<UserId, QHash<QString, QJsonObject>>& signatures);
72 
73  // Result properties
74 
75  //! A map from user ID to key ID to an error for any signatures
76  //! that failed. If a signature was invalid, the `errcode` will
77  //! be set to `M_INVALID_SIGNATURE`.
78  QHash<UserId, QHash<QString, QJsonObject>> failures() const
79  {
80  return loadFromJson<QHash<UserId, QHash<QString, QJsonObject>>>("failures"_L1);
81  }
82 };
83 
84 inline auto collectResponse(const UploadCrossSigningSignaturesJob* job) { return job->failures(); }
85 
86 } // namespace Quotient