libkazv
Loading...
Searching...
No Matches
Kazv::VerificationTracker Struct Reference

A stateful tracker for all verification processes. More...

#include <verification-tracker.hpp>

Collaboration diagram for Kazv::VerificationTracker:

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.
 

Detailed Description

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.

Member Typedef Documentation

◆ PendingEvents

Constructor & Destructor Documentation

◆ VerificationTracker()

Kazv::VerificationTracker::VerificationTracker ( VerificationUtils::DeviceIdentity  identity)

Member Function Documentation

◆ collect()

void Kazv::VerificationTracker::collect ( Timestamp  now)

Clean up all expired verification processes.

◆ isVerificationEvent()

bool Kazv::VerificationTracker::isVerificationEvent ( const Event e)
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().

◆ processIncoming()

auto Kazv::VerificationTracker::processIncoming ( Timestamp  now,
EventList  toDevice 
)

Process incoming verification events.

◆ requestOutgoingToDevice()

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.

◆ setTheirIdentity()

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.

◆ userCancel()

auto Kazv::VerificationTracker::userCancel ( std::string  userId,
std::string  deviceId 
)

Cancel a verification process.

◆ userConfirmMatch()

auto Kazv::VerificationTracker::userConfirmMatch ( std::string  userId,
std::string  deviceId 
)

Confirm an sas match for a process.

◆ userDenyMatch()

auto Kazv::VerificationTracker::userDenyMatch ( std::string  userId,
std::string  deviceId 
)

Deny an sas match for a process.

◆ userReady()

auto Kazv::VerificationTracker::userReady ( std::string  userId,
std::string  deviceId 
)

Mark ourselves ready for a process.

Member Data Documentation

◆ identity

VerificationUtils::DeviceIdentity Kazv::VerificationTracker::identity

◆ model

VerificationTrackerModel Kazv::VerificationTracker::model

The model that library user should subscribe to using lager::sensor.

◆ processes

std::unordered_map< std::string , std::unordered_map< std::string , VerificationProcess > > Kazv::VerificationTracker::processes

The documentation for this struct was generated from the following files: