use std::ops::Deref;
use futures_util::StreamExt;
use gtk::{
gdk, glib,
glib::{clone, closure_local},
prelude::*,
subclass::prelude::*,
};
use matrix_sdk::encryption::verification::{
CancelInfo, Emoji, QrVerification, QrVerificationData, QrVerificationState, SasState,
SasVerification, Verification, VerificationRequest, VerificationRequestState,
};
use qrcode::QrCode;
use ruma::{
events::key::verification::{cancel::CancelCode, VerificationMethod, REQUEST_RECEIVED_TIMEOUT},
OwnedDeviceId,
};
use tracing::{debug, error};
use super::{load_supported_verification_methods, VerificationKey};
use crate::{
contrib::Camera,
prelude::*,
session::model::{Member, Membership, Room, Session, User},
spawn, spawn_tokio,
utils::BoundConstructOnlyObject,
};
#[derive(Clone, Debug, glib::Boxed)]
#[boxed_type(name = "BoxedVerificationRequest")]
pub struct BoxedVerificationRequest(pub VerificationRequest);
impl Deref for BoxedVerificationRequest {
type Target = VerificationRequest;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[glib::flags(name = "VerificationSupportedMethods")]
pub enum VerificationSupportedMethods {
SAS = 0b00000001,
QR_SHOW = 0b00000010,
QR_SCAN = 0b00000100,
}
impl<'a> From<&'a [VerificationMethod]> for VerificationSupportedMethods {
fn from(methods: &'a [VerificationMethod]) -> Self {
let mut result = Self::empty();
for method in methods {
match method {
VerificationMethod::SasV1 => result.insert(Self::SAS),
VerificationMethod::QrCodeScanV1 => result.insert(Self::QR_SCAN),
VerificationMethod::QrCodeShowV1 => result.insert(Self::QR_SHOW),
_ => {}
}
}
result
}
}
impl Default for VerificationSupportedMethods {
fn default() -> Self {
Self::empty()
}
}
#[derive(Debug, Default, Eq, PartialEq, Clone, Copy, glib::Enum)]
#[repr(u32)]
#[enum_type(name = "VerificationState")]
pub enum VerificationState {
#[default]
Created,
Requested,
NoSupportedMethods,
Ready,
SasConfirm,
QrScan,
QrScanned,
QrConfirm,
Done,
Cancelled,
Dismissed,
RoomLeft,
Error,
}
mod imp {
use std::{
cell::{Cell, OnceCell, RefCell},
marker::PhantomData,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
#[derive(Default, glib::Properties)]
#[properties(wrapper_type = super::IdentityVerification)]
pub struct IdentityVerification {
#[property(set = Self::set_request, construct_only)]
pub request: OnceCell<BoxedVerificationRequest>,
pub request_changes_abort_handle: RefCell<Option<tokio::task::AbortHandle>>,
pub verification: RefCell<Option<Verification>>,
pub verification_changes_abort_handle: RefCell<Option<tokio::task::AbortHandle>>,
#[property(get, set = Self::set_user, construct_only)]
pub user: BoundConstructOnlyObject<User>,
#[property(get, set = Self::set_room, construct_only)]
pub room: glib::WeakRef<Room>,
membership_handler: RefCell<Option<glib::SignalHandlerId>>,
#[property(get, set = Self::set_state, construct_only, builder(VerificationState::default()))]
pub state: Cell<VerificationState>,
#[property(get)]
pub was_accepted: Cell<bool>,
#[property(get = Self::is_finished)]
is_finished: PhantomData<bool>,
#[property(get = Self::supported_methods, type = VerificationSupportedMethods)]
pub supported_methods: RefCell<Vec<VerificationMethod>>,
#[property(get = Self::flow_id)]
flow_id: PhantomData<String>,
#[property(get)]
pub received_time: OnceCell<glib::DateTime>,
pub received_timeout_source: RefCell<Option<glib::SourceId>>,
#[property(get = Self::display_name)]
display_name: PhantomData<String>,
pub qr_code: RefCell<Option<QrCode>>,
#[property(get)]
pub camera_paintable: RefCell<Option<gdk::Paintable>>,
#[property(get, set = Self::set_was_viewed, explicit_notify)]
pub was_viewed: Cell<bool>,
}
#[glib::object_subclass]
impl ObjectSubclass for IdentityVerification {
const NAME: &'static str = "IdentityVerification";
type Type = super::IdentityVerification;
}
#[glib::derived_properties]
impl ObjectImpl for IdentityVerification {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
vec![
Signal::builder("sas-data-changed").build(),
Signal::builder("cancel-info-changed").build(),
Signal::builder("replaced")
.param_types([super::IdentityVerification::static_type()])
.build(),
Signal::builder("done").return_type::<bool>().build(),
Signal::builder("dismiss").build(),
Signal::builder("remove-from-list").build(),
]
});
SIGNALS.as_ref()
}
fn dispose(&self) {
let obj = self.obj();
if let Some(handler) = self.membership_handler.take() {
if let Some(room) = self.room.upgrade() {
room.own_member().disconnect(handler);
}
}
if let Some(handle) = self.request_changes_abort_handle.take() {
handle.abort();
}
if let Some(handle) = self.verification_changes_abort_handle.take() {
handle.abort();
}
if let Some(source) = self.received_timeout_source.take() {
source.remove();
}
let request = obj.request().clone();
if !request.is_done() && !request.is_passive() && !request.is_cancelled() {
spawn_tokio!(async move {
if let Err(error) = request.cancel().await {
error!("Could not cancel verification request on dispose: {error}");
}
});
}
}
}
impl IdentityVerification {
fn set_request(&self, request: BoxedVerificationRequest) {
self.request.set(request.clone()).unwrap();
let Ok(datetime) = glib::DateTime::now_local() else {
error!("Could not get current GDateTime");
return;
};
if matches!(request.state(), VerificationRequestState::Requested { .. }) {
let source_id = glib::timeout_add_local_once(
REQUEST_RECEIVED_TIMEOUT,
clone!(
#[weak(rename_to = imp)]
self,
move || {
imp.received_timeout_source.take();
imp.set_state(VerificationState::Dismissed);
imp.obj().dismiss();
}
),
);
self.received_timeout_source.replace(Some(source_id));
}
self.received_time.set(datetime).unwrap();
}
fn set_user(&self, user: User) {
let mut handlers = Vec::new();
if user.is::<Member>() {
let obj = self.obj();
let display_name_handler = user.connect_display_name_notify(clone!(
#[weak]
obj,
move |_| {
obj.notify_display_name();
}
));
handlers.push(display_name_handler);
}
self.user.set(user, handlers);
}
fn set_room(&self, room: Option<&Room>) {
let Some(room) = room else {
return;
};
let handler = room.own_member().connect_membership_notify(clone!(
#[weak(rename_to = imp)]
self,
move |own_member| {
if matches!(own_member.membership(), Membership::Leave | Membership::Ban) {
imp.set_state(VerificationState::RoomLeft);
if let Some(handler) = imp.membership_handler.take() {
own_member.disconnect(handler);
}
}
}
));
self.membership_handler.replace(Some(handler));
self.room.set(Some(room));
}
pub fn set_state(&self, state: VerificationState) {
if self.state.get() == state {
return;
}
let obj = self.obj();
if state == VerificationState::Done {
let ret = obj.emit_by_name::<bool>("done", &[]);
if glib::Propagation::from(ret).is_stop() {
return;
}
}
self.state.set(state);
obj.notify_state();
if self.is_finished() {
obj.notify_is_finished();
}
}
fn is_finished(&self) -> bool {
matches!(
self.state.get(),
VerificationState::Cancelled
| VerificationState::Dismissed
| VerificationState::Done
| VerificationState::Error
| VerificationState::RoomLeft
)
}
fn supported_methods(&self) -> VerificationSupportedMethods {
self.supported_methods.borrow().as_slice().into()
}
fn display_name(&self) -> String {
let user = self.user.obj();
if !user.is_own_user() {
user.display_name()
} else {
"Login Request".to_string()
}
}
fn flow_id(&self) -> String {
self.request.get().unwrap().flow_id().to_owned()
}
fn set_was_viewed(&self, was_viewed: bool) {
if !was_viewed {
return;
}
self.was_viewed.set(was_viewed);
self.obj().notify_was_viewed();
}
}
}
glib::wrapper! {
pub struct IdentityVerification(ObjectSubclass<imp::IdentityVerification>);
}
impl IdentityVerification {
pub async fn new(request: VerificationRequest, user: &User, room: Option<&Room>) -> Self {
let obj = glib::Object::builder::<Self>()
.property("request", BoxedVerificationRequest(request))
.property("user", user)
.property("room", room)
.build();
obj.init().await;
obj
}
pub fn session(&self) -> Session {
self.user().session()
}
fn request(&self) -> &VerificationRequest {
self.imp().request.get().unwrap()
}
pub fn key(&self) -> VerificationKey {
VerificationKey::from_request(self.request())
}
pub fn is_self_verification(&self) -> bool {
self.request().is_self_verification()
}
pub fn other_device_id(&self) -> Option<OwnedDeviceId> {
let verification = match self.request().state() {
VerificationRequestState::Requested {
other_device_id, ..
}
| VerificationRequestState::Ready {
other_device_id, ..
} => return Some(other_device_id),
VerificationRequestState::Transitioned { verification } => verification,
VerificationRequestState::Created { .. }
| VerificationRequestState::Done
| VerificationRequestState::Cancelled(_) => return None,
};
match verification {
Verification::SasV1(sas) => Some(sas.other_device().device_id().to_owned()),
Verification::QrV1(qr) => Some(qr.other_device().device_id().to_owned()),
_ => None,
}
}
fn set_was_accepted(&self, was_accepted: bool) {
if !was_accepted || self.was_accepted() {
return;
}
self.imp().was_accepted.set(true);
self.notify_was_accepted();
}
pub fn cancel_info(&self) -> Option<CancelInfo> {
self.request().cancel_info()
}
async fn init(&self) {
let request = self.request();
let obj_weak = glib::SendWeakRef::from(self.downgrade());
let fut = request.changes().for_each(move |state| {
let obj_weak = obj_weak.clone();
async move {
let ctx = glib::MainContext::default();
ctx.spawn(async move {
spawn!(async move {
if let Some(obj) = obj_weak.upgrade() {
obj.handle_request_state(state).await;
}
});
});
}
});
let handle = spawn_tokio!(fut).abort_handle();
self.imp()
.request_changes_abort_handle
.replace(Some(handle));
let state = request.state();
self.handle_request_state(state).await;
}
async fn handle_request_state(&self, state: VerificationRequestState) {
let imp = self.imp();
let request = self.request();
if !matches!(state, VerificationRequestState::Requested { .. }) {
if let Some(source) = imp.received_timeout_source.take() {
source.remove();
}
}
if !matches!(
state,
VerificationRequestState::Created { .. } | VerificationRequestState::Requested { .. }
) {
self.set_was_accepted(true);
}
match state {
VerificationRequestState::Created { .. } => {}
VerificationRequestState::Requested { their_methods, .. } => {
let our_methods = load_supported_verification_methods().await;
let supported_methods = intersect_methods(our_methods, their_methods);
if supported_methods.is_empty() {
imp.set_state(VerificationState::NoSupportedMethods);
} else {
imp.set_state(VerificationState::Requested);
}
}
VerificationRequestState::Ready {
their_methods,
our_methods,
..
} => {
let mut supported_methods = intersect_methods(our_methods, their_methods);
let reciprocate_idx = supported_methods
.iter()
.enumerate()
.find_map(|(idx, m)| (*m == VerificationMethod::ReciprocateV1).then_some(idx));
if let Some(idx) = reciprocate_idx {
supported_methods.remove(idx);
}
let show_qr_idx = supported_methods
.iter()
.enumerate()
.find_map(|(idx, m)| (*m == VerificationMethod::QrCodeShowV1).then_some(idx));
if let Some(idx) = show_qr_idx {
if !self.load_qr_code().await {
supported_methods.remove(idx);
}
}
if supported_methods.is_empty() {
error!("Invalid verification: no methods are supported by both sessions, cancelling…");
if self.cancel().await.is_err() {
imp.set_state(VerificationState::NoSupportedMethods);
}
} else {
self.set_supported_methods(supported_methods.clone());
if supported_methods.len() == 1
&& !request.we_started()
&& supported_methods[0] == VerificationMethod::SasV1
{
if self.start_sas().await.is_ok() {
return;
}
}
imp.set_state(VerificationState::Ready);
}
}
VerificationRequestState::Transitioned { verification } => {
self.set_verification(verification).await;
}
VerificationRequestState::Done => {
imp.set_state(VerificationState::Done);
}
VerificationRequestState::Cancelled(info) => self.handle_cancelled_state(info),
}
}
fn handle_cancelled_state(&self, cancel_info: CancelInfo) {
debug!("Verification was cancelled: {cancel_info:?}");
let cancel_code = cancel_info.cancel_code();
if cancel_info.cancelled_by_us() && *cancel_code == CancelCode::User {
return;
}
if *cancel_code == CancelCode::Accepted && !self.was_viewed() {
self.dismiss();
return;
}
self.emit_by_name::<()>("cancel-info-changed", &[]);
self.imp().set_state(VerificationState::Cancelled);
}
pub async fn cancel(&self) -> Result<(), matrix_sdk::Error> {
let request = self.request().clone();
if request.is_done() || request.is_passive() || request.is_cancelled() {
return Err(matrix_sdk::Error::UnknownError(
"Cannot cancel request that is already finished".into(),
));
}
let handle = spawn_tokio!(async move { request.cancel().await });
match handle.await.unwrap() {
Ok(()) => {
self.dismiss();
Ok(())
}
Err(error) => {
error!("Could not cancel verification request: {error}");
Err(error)
}
}
}
pub async fn accept(&self) -> Result<(), ()> {
let request = self.request().clone();
let VerificationRequestState::Requested { their_methods, .. } = request.state() else {
error!("Cannot accept verification that is not in the requested state");
return Err(());
};
let our_methods = load_supported_verification_methods().await;
let methods = intersect_methods(our_methods, their_methods);
let handle = spawn_tokio!(async move { request.accept_with_methods(methods).await });
match handle.await.unwrap() {
Ok(()) => Ok(()),
Err(error) => {
error!("Could not accept verification request: {error}");
Err(())
}
}
}
fn set_supported_methods(&self, supported_methods: Vec<VerificationMethod>) {
let imp = self.imp();
if *imp.supported_methods.borrow() == supported_methods {
return;
}
imp.supported_methods.replace(supported_methods);
self.notify_supported_methods();
}
pub fn choose_method(&self) {
self.imp().set_state(VerificationState::Ready);
}
async fn set_verification(&self, verification: Verification) {
let imp = self.imp();
if let Some(handle) = imp.verification_changes_abort_handle.take() {
handle.abort();
};
let obj_weak = glib::SendWeakRef::from(self.downgrade());
let handle = match &verification {
Verification::SasV1(sas_verification) => {
let fut = sas_verification.changes().for_each(move |state| {
let obj_weak = obj_weak.clone();
async move {
let ctx = glib::MainContext::default();
ctx.spawn(async move {
spawn!(async move {
if let Some(obj) = obj_weak.upgrade() {
obj.handle_sas_verification_state(state).await;
}
});
});
}
});
spawn_tokio!(fut).abort_handle()
}
Verification::QrV1(qr_verification) => {
let fut = qr_verification.changes().for_each(move |state| {
let obj_weak = obj_weak.clone();
async move {
let ctx = glib::MainContext::default();
ctx.spawn(async move {
spawn!(async move {
if let Some(obj) = obj_weak.upgrade() {
obj.handle_qr_verification_state(state);
}
});
});
}
});
spawn_tokio!(fut).abort_handle()
}
_ => {
error!("We only support SAS and QR verification");
imp.set_state(VerificationState::Error);
return;
}
};
imp.verification.replace(Some(verification.clone()));
imp.verification_changes_abort_handle.replace(Some(handle));
match verification {
Verification::SasV1(sas_verification) => {
self.handle_sas_verification_state(sas_verification.state())
.await;
}
Verification::QrV1(qr_verification) => {
self.handle_qr_verification_state(qr_verification.state())
}
_ => unreachable!(),
}
}
fn handle_qr_verification_state(&self, state: QrVerificationState) {
let imp = self.imp();
match state {
QrVerificationState::Started => {}
QrVerificationState::Scanned => imp.set_state(VerificationState::QrConfirm),
QrVerificationState::Confirmed => {}
QrVerificationState::Reciprocated => {}
QrVerificationState::Done { .. } => imp.set_state(VerificationState::Done),
QrVerificationState::Cancelled(info) => self.handle_cancelled_state(info),
}
}
fn qr_verification(&self) -> Option<QrVerification> {
match self.imp().verification.borrow().as_ref()? {
Verification::QrV1(v) => Some(v.clone()),
_ => None,
}
}
async fn handle_sas_verification_state(&self, state: SasState) {
let Some(sas_verification) = self.sas_verification() else {
return;
};
let imp = self.imp();
match state {
SasState::Created { .. } => {}
SasState::Started { .. } => {
let handle = spawn_tokio!(async move { sas_verification.accept().await });
if let Err(error) = handle.await.unwrap() {
error!("Could not accept SAS verification: {error}");
imp.set_state(VerificationState::Error);
}
}
SasState::Accepted { .. } => {}
SasState::KeysExchanged { .. } => {
self.emit_by_name::<()>("sas-data-changed", &[]);
imp.set_state(VerificationState::SasConfirm);
}
SasState::Confirmed => {}
SasState::Done { .. } => imp.set_state(VerificationState::Done),
SasState::Cancelled(info) => self.handle_cancelled_state(info),
}
}
fn sas_verification(&self) -> Option<SasVerification> {
match self.imp().verification.borrow().as_ref()? {
Verification::SasV1(v) => Some(v.clone()),
_ => None,
}
}
pub fn sas_supports_emoji(&self) -> bool {
match self.imp().verification.borrow().as_ref() {
Some(Verification::SasV1(v)) => v.supports_emoji(),
_ => false,
}
}
pub fn sas_emoji(&self) -> Option<[Emoji; 7]> {
match self.imp().verification.borrow().as_ref()? {
Verification::SasV1(v) => v.emoji(),
_ => None,
}
}
pub fn sas_decimals(&self) -> Option<(u16, u16, u16)> {
match self.imp().verification.borrow().as_ref()? {
Verification::SasV1(v) => v.decimals(),
_ => None,
}
}
async fn load_qr_code(&self) -> bool {
let request = self.request().clone();
let handle = spawn_tokio!(async move { request.generate_qr_code().await });
let qr_verification = match handle.await.unwrap() {
Ok(Some(qr_verification)) => qr_verification,
Ok(None) => {
error!("Could not start QR verification generation: unknown reason");
return false;
}
Err(error) => {
error!("Could not start QR verification generation: {error}");
return false;
}
};
match qr_verification.to_qr_code() {
Ok(qr_code) => {
self.imp().qr_code.replace(Some(qr_code));
true
}
Err(error) => {
error!("Could not generate verification QR code: {error}");
false
}
}
}
pub fn qr_code(&self) -> Option<QrCode> {
self.imp().qr_code.borrow().clone()
}
pub fn has_qr_code(&self) -> bool {
self.imp().qr_code.borrow().is_some()
}
pub async fn start_qr_code_scan(&self) -> Result<(), ()> {
let imp = self.imp();
match Camera::default().paintable().await {
Some(paintable) => {
imp.camera_paintable.replace(Some(paintable.upcast()));
self.notify_camera_paintable();
imp.set_state(VerificationState::QrScan);
Ok(())
}
None => Err(()),
}
}
pub async fn qr_code_scanned(&self, data: QrVerificationData) -> Result<(), ()> {
self.imp().set_state(VerificationState::QrScanned);
let request = self.request().clone();
let handle = spawn_tokio!(async move { request.scan_qr_code(data).await });
match handle.await.unwrap() {
Ok(Some(_)) => Ok(()),
Ok(None) => {
error!("Could not validate scanned verification QR code: unknown reason");
Err(())
}
Err(error) => {
error!("Could not validate scanned verification QR code: {error}");
Err(())
}
}
}
pub async fn confirm_qr_code_scanned(&self) -> Result<(), ()> {
let Some(qr_verification) = self.qr_verification() else {
error!("Cannot confirm QR Code scan without an ongoing QR verification");
return Err(());
};
let handle = spawn_tokio!(async move { qr_verification.confirm().await });
match handle.await.unwrap() {
Ok(()) => Ok(()),
Err(error) => {
error!("Could not confirm scanned verification QR code: {error}");
Err(())
}
}
}
pub async fn start_sas(&self) -> Result<(), ()> {
let request = self.request().clone();
let handle = spawn_tokio!(async move { request.start_sas().await });
match handle.await.unwrap() {
Ok(Some(_)) => Ok(()),
Ok(None) => {
error!("Could not start SAS verification: unknown reason");
Err(())
}
Err(error) => {
error!("Could not start SAS verification: {error}");
Err(())
}
}
}
pub async fn sas_mismatch(&self) -> Result<(), ()> {
let Some(sas_verification) = self.sas_verification() else {
error!("Cannot send SAS mismatch without an ongoing SAS verification");
return Err(());
};
let handle = spawn_tokio!(async move { sas_verification.mismatch().await });
match handle.await.unwrap() {
Ok(()) => Ok(()),
Err(error) => {
error!("Could not send SAS verification mismatch: {error}");
Err(())
}
}
}
pub async fn sas_match(&self) -> Result<(), ()> {
let Some(sas_verification) = self.sas_verification() else {
error!("Cannot send SAS match without an ongoing SAS verification");
return Err(());
};
let handle = spawn_tokio!(async move { sas_verification.confirm().await });
match handle.await.unwrap() {
Ok(()) => Ok(()),
Err(error) => {
error!("Could not send SAS verification match: {error}");
Err(())
}
}
}
pub async fn restart(&self) -> Result<Self, ()> {
let user = self.user();
let verification_list = user.session().verification_list();
let new_user = (!self.is_self_verification()).then_some(user);
let new_verification = verification_list.create(new_user).await?;
self.emit_by_name::<()>("replaced", &[&new_verification]);
if self.cancel().await.is_err() {
self.dismiss();
}
Ok(new_verification)
}
pub fn dismiss(&self) {
self.remove_from_list();
self.emit_by_name::<()>("dismiss", &[]);
}
pub fn remove_from_list(&self) {
self.emit_by_name::<()>("remove-from-list", &[]);
}
pub fn connect_sas_data_changed<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"sas-data-changed",
true,
closure_local!(move |obj: Self| {
f(&obj);
}),
)
}
pub fn connect_cancel_info_changed<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> glib::SignalHandlerId {
self.connect_closure(
"cancel-info-changed",
true,
closure_local!(move |obj: Self| {
f(&obj);
}),
)
}
pub fn connect_replaced<F: Fn(&Self, &Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"replaced",
true,
closure_local!(move |obj: Self, new_verification: Self| {
f(&obj, &new_verification);
}),
)
}
pub fn connect_done<F: Fn(&Self) -> glib::Propagation + 'static>(
&self,
f: F,
) -> glib::SignalHandlerId {
self.connect_closure(
"done",
true,
closure_local!(move |obj: Self| {
let ret = f(&obj);
if ret.is_stop() {
obj.stop_signal_emission_by_name("done");
}
bool::from(ret)
}),
)
}
pub fn connect_dismiss<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"dismiss",
true,
closure_local!(move |obj: Self| {
f(&obj);
}),
)
}
pub(super) fn connect_remove_from_list<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> glib::SignalHandlerId {
self.connect_closure(
"remove-from-list",
true,
closure_local!(move |obj: Self| {
f(&obj);
}),
)
}
}
fn intersect_methods(
our_methods: Vec<VerificationMethod>,
their_methods: Vec<VerificationMethod>,
) -> Vec<VerificationMethod> {
let mut supported_methods = our_methods;
supported_methods.retain(|m| match m {
VerificationMethod::SasV1 => their_methods.contains(&VerificationMethod::SasV1),
VerificationMethod::QrCodeScanV1 => {
their_methods.contains(&VerificationMethod::QrCodeShowV1)
&& their_methods.contains(&VerificationMethod::ReciprocateV1)
}
VerificationMethod::QrCodeShowV1 => {
their_methods.contains(&VerificationMethod::QrCodeScanV1)
&& their_methods.contains(&VerificationMethod::ReciprocateV1)
}
VerificationMethod::ReciprocateV1 => {
(their_methods.contains(&VerificationMethod::QrCodeShowV1)
|| their_methods.contains(&VerificationMethod::QrCodeScanV1))
&& their_methods.contains(&VerificationMethod::ReciprocateV1)
}
_ => false,
});
supported_methods
}