|
libkazv
|
A stateful tracker for all verification processes. More...
#include <verification-tracker.hpp>
Classes | |
| struct | PendingEventDesc |
Public Types | |
| using | PendingEvents = immer::flex_vector< PendingEventDesc > |
Public Member Functions | |
| VerificationTracker (VerificationUtils::DeviceIdentity identity) | |
| PendingEvents | requestOutgoingToDevice (VerificationUtils::DeviceIdentity theirIdentity, Timestamp now) |
| Request an outgoing verification for a device using to-device message. | |
| PendingEvents | processIncoming (Timestamp now, EventList toDevice) |
| Process incoming verification events. | |
| void | setTheirIdentity (VerificationUtils::DeviceIdentity theirId) |
| Set the key(s) for the other party in a process. | |
| void | collect (Timestamp now) |
| Clean up all expired verification processes. | |
| PendingEvents | userReady (std::string userId, std::string deviceId) |
| Mark ourselves ready for a process. | |
| PendingEvents | userCancel (std::string userId, std::string deviceId) |
| Cancel a verification process. | |
| PendingEvents | userConfirmMatch (std::string userId, std::string deviceId) |
| Confirm an sas match for a process. | |
| PendingEvents | userDenyMatch (std::string userId, std::string deviceId) |
| Deny an sas match for a process. | |
Static Public Member Functions | |
| static bool | isVerificationEvent (const Event &e) |
| Check if the event is an verification event. | |
Public Attributes | |
| VerificationUtils::DeviceIdentity | identity |
| std::unordered_map< std::string, std::unordered_map< std::string, VerificationProcess > > | processes |
| VerificationTrackerModel | model |
The model that library user should subscribe to using lager::sensor. | |
A stateful tracker for all verification processes.
If you subscribe to the model attribute of this class using lager::sensor, you should call lager::commit() on the sensor each time you execute a change function.
this will not modify itself unless you execute a change function.
This class is not thread-safe, and you should serialize all function calls on one object.
Unfortunately, the producer of the model cannot be made a value type, because how vodozemac dictates the no-copy nature of Sas. This sadly means that we cannot continue with a verification process if the program has been closed.
| using Kazv::VerificationTracker::PendingEvents = immer::flex_vector<PendingEventDesc> |
| Kazv::VerificationTracker::VerificationTracker | ( | VerificationUtils::DeviceIdentity | identity | ) |
| void Kazv::VerificationTracker::collect | ( | Timestamp | now | ) |
Clean up all expired verification processes.
|
static |
Check if the event is an verification event.
When you receive an event from sync, you should call this function after decrypting it. If it returns true, you should then call processIncoming().
Process incoming verification events.
| auto Kazv::VerificationTracker::requestOutgoingToDevice | ( | VerificationUtils::DeviceIdentity | theirIdentity, |
| Timestamp | now | ||
| ) |
Request an outgoing verification for a device using to-device message.
After this function returns, model will contain a new process. model.processes will contain the created process p with p.theirUserId == theirIdentity.userId && p.theirDeviceId == theirIdentity.theirDeviceId.
| void Kazv::VerificationTracker::setTheirIdentity | ( | VerificationUtils::DeviceIdentity | theirId | ) |
Set the key(s) for the other party in a process.
When there is a process in the model with a ProcessTheyRequested state, you should, after the user is ready for the incoming request, fetch their device keys and call this function.
| auto Kazv::VerificationTracker::userCancel | ( | std::string | userId, |
| std::string | deviceId | ||
| ) |
Cancel a verification process.
| auto Kazv::VerificationTracker::userConfirmMatch | ( | std::string | userId, |
| std::string | deviceId | ||
| ) |
Confirm an sas match for a process.
| auto Kazv::VerificationTracker::userDenyMatch | ( | std::string | userId, |
| std::string | deviceId | ||
| ) |
Deny an sas match for a process.
| auto Kazv::VerificationTracker::userReady | ( | std::string | userId, |
| std::string | deviceId | ||
| ) |
Mark ourselves ready for a process.
| VerificationUtils::DeviceIdentity Kazv::VerificationTracker::identity |
| VerificationTrackerModel Kazv::VerificationTracker::model |
The model that library user should subscribe to using lager::sensor.
| std::unordered_map< std::string , std::unordered_map< std::string , VerificationProcess > > Kazv::VerificationTracker::processes |