Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ version = "0.18.0"
[dependencies.matrix-sdk]
version = "0.18.0"
default-features = false
features = ["e2e-encryption", "socks", "sqlite", "sso-login"]
features = ["e2e-encryption", "socks", "sqlite", "sso-login", "qrcode"]

[dependencies.matrix-sdk-crypto]
version = "0.18.0"
Expand Down
2 changes: 2 additions & 0 deletions docs/iamb.1
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Import and decrypt keys from
View a list of ongoing E2EE verifications.
.It Sy ":verify accept [key]"
Accept a verification request.
.It Sy ":verify emoji [key]"
Transition a request to use interactive emoji verification.
.It Sy ":verify cancel [key]"
Cancel an in-progress verification.
.It Sy ":verify confirm [key]"
Expand Down
15 changes: 6 additions & 9 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::time::{Duration, Instant};

use emojis::Emoji;

use matrix_sdk::encryption::verification::VerificationRequest;
use ratatui::{
buffer::Buffer,
layout::{Alignment, Rect},
Expand All @@ -31,7 +32,6 @@ use url::Url;

use matrix_sdk::{
RoomState as MatrixRoomState,
encryption::verification::SasVerification,
room::Room as MatrixRoom,
ruma::{
EventId,
Expand Down Expand Up @@ -139,6 +139,9 @@ pub enum VerifyAction {

/// Reject an in-progress verification due to mismatched Emoji.
Mismatch,

/// Start an interactive (SAS) emoji verification
Emoji,
}

/// An action taken against the currently selected message.
Expand Down Expand Up @@ -1839,7 +1842,8 @@ pub struct ChatStore {
pub presences: CompletionMap<OwnedUserId, PresenceState>,

/// In-progress and completed verifications.
pub verifications: CompletionMap<String, SasVerification>,
/// The map key is the `flow_id`.
pub verifications: CompletionMap<String, VerificationRequest>,

/// Settings for the current profile loaded from config file.
pub settings: ApplicationSettings,
Expand Down Expand Up @@ -1927,13 +1931,6 @@ impl ChatStore {
pub fn set_room_name(&mut self, room_id: &RoomId, name: &str) {
self.rooms.get_or_default(room_id.to_owned()).name = name.to_string().into();
}

/// Insert a new E2EE verification.
pub fn insert_sas(&mut self, sas: SasVerification) {
let key = format!("{}/{}", sas.other_user_id(), sas.other_device().device_id());

self.verifications.insert(key, sas);
}
}

impl ApplicationStore for ChatStore {}
Expand Down
1 change: 1 addition & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
"cancel" => VerifyAction::Cancel,
"confirm" => VerifyAction::Confirm,
"mismatch" => VerifyAction::Mismatch,
"emoji" => VerifyAction::Emoji,
"request" => {
let iact = IambAction::VerifyRequest(args.remove(1));
let step = CommandStep::Continue(iact.into(), ctx.context.clone());
Expand Down
9 changes: 8 additions & 1 deletion src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,14 @@ fn complete_iamb_keys(

/// Tab completion for `:verify`
fn complete_iamb_verify(args: Vec<String>, store: &ChatStore) -> Vec<String> {
let subcmds = ["request", "accept", "confirm", "cancel", "missmatch"];
let subcmds = [
"request",
"accept",
"confirm",
"cancel",
"missmatch",
"emoji",
];
match args.len() {
1 => complete_choices(&args[0], &subcmds),
2 if args[0] == "request" => complete_users(&args[1], store),
Expand Down
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{Duration, Instant};

use clap::{CommandFactory, Parser};
use matrix_sdk::ruma::OwnedUserId;
use matrix_sdk::ruma::UserId;
use matrix_sdk::ruma::api::error::ErrorKind;
use matrix_sdk::ruma::profile::{ProfileFieldName, ProfileFieldValue};
use matrix_sdk_crypto::encrypt_room_key_export;
Expand Down Expand Up @@ -87,6 +87,7 @@ mod worker;

#[cfg(test)]
mod tests;
mod verifications;

use crate::{
base::{
Expand Down Expand Up @@ -621,19 +622,15 @@ impl Application {
None
},

IambAction::Verify(act, user_dev) => {
if let Some(sas) = store.application.verifications.get(&user_dev) {
self.worker.verify(act, sas.clone())?
} else {
return Err(IambError::InvalidVerificationId(user_dev).into());
}
IambAction::Verify(act, flow_id) => {
return verifications::iamb_verify(act, flow_id, store).await;
},
IambAction::VerifyRequest(user_id) => {
if let Ok(user_id) = OwnedUserId::try_from(user_id.as_str()) {
self.worker.verify_request(user_id)?
} else {
let Ok(user_id) = <&UserId>::try_from(user_id.as_str()) else {
return Err(IambError::InvalidUserId(user_id).into());
}
};

return verifications::iamb_verify_request(user_id, store).await;
},
};

Expand Down
Loading
Loading