[Updt] MTP
This commit is contained in:
parent
b2068f62fb
commit
8a54a360ca
14 changed files with 57 additions and 57 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
|
@ -2707,7 +2707,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp"
|
name = "mtp"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mtp-client",
|
"mtp-client",
|
||||||
"mtp-codec",
|
"mtp-codec",
|
||||||
|
|
@ -2724,7 +2724,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-client"
|
name = "mtp-client"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mtp-codec",
|
"mtp-codec",
|
||||||
"mtp-common",
|
"mtp-common",
|
||||||
|
|
@ -2737,7 +2737,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-codec"
|
name = "mtp-codec"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
@ -2751,15 +2751,16 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-common"
|
name = "mtp-common"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"rand 0.10.2",
|
||||||
"thiserror 2.0.20",
|
"thiserror 2.0.20",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-core"
|
name = "mtp-core"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"mtp-codec",
|
"mtp-codec",
|
||||||
|
|
@ -2771,7 +2772,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-crypto"
|
name = "mtp-crypto"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|
@ -2794,7 +2795,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-files"
|
name = "mtp-files"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mtp-crypto",
|
"mtp-crypto",
|
||||||
"rand 0.10.2",
|
"rand 0.10.2",
|
||||||
|
|
@ -2805,7 +2806,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-h3"
|
name = "mtp-h3"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
@ -2822,7 +2823,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-host"
|
name = "mtp-host"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mtp-codec",
|
"mtp-codec",
|
||||||
"mtp-common",
|
"mtp-common",
|
||||||
|
|
@ -2839,7 +2840,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-native"
|
name = "mtp-native"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"mtp-codec",
|
"mtp-codec",
|
||||||
|
|
@ -2860,7 +2861,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-type-map"
|
name = "mtp-type-map"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
|
|
@ -2869,7 +2870,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mtp-webserver"
|
name = "mtp-webserver"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
|
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"h3",
|
"h3",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["client", "crypto"] }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["client", "crypto"] }
|
||||||
iota-connection = { path = "../iota-connection" }
|
iota-connection = { path = "../iota-connection" }
|
||||||
iota-logger = { path = "../iota-logger" }
|
iota-logger = { path = "../iota-logger" }
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ impl ClientConnection {
|
||||||
let sender_clone = Arc::clone(sender);
|
let sender_clone = Arc::clone(sender);
|
||||||
drop(sender_guard);
|
drop(sender_guard);
|
||||||
|
|
||||||
log_cv_out!(&cv);
|
log_cv_out!(cv);
|
||||||
|
|
||||||
if let Err(e) = sender_clone.send(cv).await {
|
if let Err(e) = sender_clone.send(cv).await {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git"}
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
|
|
||||||
futures = "*"
|
futures = "*"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iota-storage = { path = "../iota-storage" }
|
iota-storage = { path = "../iota-storage" }
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["crypto"] }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["crypto"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1.50.0", features = ["macros", "rt"] }
|
tokio = { version = "1.50.0", features = ["macros", "rt"] }
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,8 @@ pub fn apply_verified_relay_content(
|
||||||
let created_at = i64::try_from(context.created_at)
|
let created_at = i64::try_from(context.created_at)
|
||||||
.map_err(|_| "Relay creation time exceeds the local storage range".to_string())?;
|
.map_err(|_| "Relay creation time exceeds the local storage range".to_string())?;
|
||||||
|
|
||||||
match content.message_type.as_str() {
|
match content.message_type {
|
||||||
"MessageState" => {
|
CommunicationType::MessageState => {
|
||||||
let partner_id =
|
let partner_id =
|
||||||
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
|
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
|
||||||
.and_then(|value| i64::try_from(value).ok())
|
.and_then(|value| i64::try_from(value).ok())
|
||||||
|
|
@ -218,7 +218,7 @@ pub fn apply_verified_relay_content(
|
||||||
let _ = partner_id;
|
let _ = partner_id;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
"MessageSend" => {
|
CommunicationType::MessageSend => {
|
||||||
let message = relay_string(&content.content, DataType::Content, &context.type_map)
|
let message = relay_string(&content.content, DataType::Content, &context.type_map)
|
||||||
.ok_or_else(|| "Relay MessageSend is missing Content".to_string())?;
|
.ok_or_else(|| "Relay MessageSend is missing Content".to_string())?;
|
||||||
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
||||||
|
|
@ -288,7 +288,7 @@ pub fn apply_verified_relay_content(
|
||||||
.map_err(|error| error.to_string())?;
|
.map_err(|error| error.to_string())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
"MessageEdit" => {
|
CommunicationType::MessageEdit => {
|
||||||
let message = relay_string(&content.content, DataType::Content, &context.type_map)
|
let message = relay_string(&content.content, DataType::Content, &context.type_map)
|
||||||
.ok_or_else(|| "Relay MessageEdit is missing Content".to_string())?;
|
.ok_or_else(|| "Relay MessageEdit is missing Content".to_string())?;
|
||||||
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
||||||
|
|
@ -318,7 +318,7 @@ pub fn apply_verified_relay_content(
|
||||||
};
|
};
|
||||||
result.map_err(|error| error.to_string())
|
result.map_err(|error| error.to_string())
|
||||||
}
|
}
|
||||||
"MessageReactionAdd" | "MessageReactionRemove" => {
|
CommunicationType::MessageReactionAdd | CommunicationType::MessageReactionRemove => {
|
||||||
let reaction = relay_string(&content.content, DataType::Reaction, &context.type_map)
|
let reaction = relay_string(&content.content, DataType::Reaction, &context.type_map)
|
||||||
.filter(|value| !value.is_empty() && value.len() <= 64)
|
.filter(|value| !value.is_empty() && value.len() <= 64)
|
||||||
.ok_or_else(|| "Relay reaction is invalid".to_string())?;
|
.ok_or_else(|| "Relay reaction is invalid".to_string())?;
|
||||||
|
|
@ -330,7 +330,7 @@ pub fn apply_verified_relay_content(
|
||||||
} else {
|
} else {
|
||||||
sender_id
|
sender_id
|
||||||
};
|
};
|
||||||
let result = if content.message_type == "MessageReactionAdd" {
|
let result = if content.message_type == CommunicationType::MessageReactionAdd {
|
||||||
chat_files::add_reaction(
|
chat_files::add_reaction(
|
||||||
storage_owner,
|
storage_owner,
|
||||||
external_user,
|
external_user,
|
||||||
|
|
@ -349,7 +349,7 @@ pub fn apply_verified_relay_content(
|
||||||
};
|
};
|
||||||
result.map_err(|error| error.to_string())
|
result.map_err(|error| error.to_string())
|
||||||
}
|
}
|
||||||
"MessageDelete" | "MessageDeleteLive" => {
|
CommunicationType::MessageDelete | CommunicationType::MessageDeleteLive => {
|
||||||
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
|
||||||
.and_then(|value| i64::try_from(value).ok())
|
.and_then(|value| i64::try_from(value).ok())
|
||||||
.ok_or_else(|| "Relay MessageDeleteLive is missing SendTime".to_string())?;
|
.ok_or_else(|| "Relay MessageDeleteLive is missing SendTime".to_string())?;
|
||||||
|
|
@ -365,7 +365,7 @@ pub fn apply_verified_relay_content(
|
||||||
};
|
};
|
||||||
result.map_err(|error| error.to_string())
|
result.map_err(|error| error.to_string())
|
||||||
}
|
}
|
||||||
"SetChatSecret" => {
|
CommunicationType::SetChatSecret => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
|
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
|
||||||
.with_payload(content.content.clone());
|
.with_payload(content.content.clone());
|
||||||
let recipients = chat_secret_recipients(&frame)
|
let recipients = chat_secret_recipients(&frame)
|
||||||
|
|
@ -441,7 +441,7 @@ pub fn apply_verified_relay_content(
|
||||||
})
|
})
|
||||||
.map_err(|error| error.to_string())
|
.map_err(|error| error.to_string())
|
||||||
}
|
}
|
||||||
"AddConversation" => {
|
CommunicationType::AddConversation => {
|
||||||
let other_id =
|
let other_id =
|
||||||
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
|
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
|
||||||
.and_then(|value| i64::try_from(value).ok())
|
.and_then(|value| i64::try_from(value).ok())
|
||||||
|
|
@ -485,7 +485,7 @@ pub fn validate_outgoing_receipt_policy(
|
||||||
context: &VerifiedRelayContext,
|
context: &VerifiedRelayContext,
|
||||||
content: &VerifiedRelayContent,
|
content: &VerifiedRelayContent,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
if content.message_type != "MessageState" {
|
if content.message_type != CommunicationType::MessageState {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let state = relay_string(&content.content, DataType::MessageState, &context.type_map)
|
let state = relay_string(&content.content, DataType::MessageState, &context.type_map)
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ where
|
||||||
let context = VerifiedRelayContext {
|
let context = VerifiedRelayContext {
|
||||||
signer_id: metadata.signer_id(),
|
signer_id: metadata.signer_id(),
|
||||||
final_recipient_id: metadata.final_recipient_id(),
|
final_recipient_id: metadata.final_recipient_id(),
|
||||||
message_id: metadata.message_id().to_owned(),
|
message_id: metadata.message_id().to_string(),
|
||||||
created_at: metadata.created_at(),
|
created_at: metadata.created_at(),
|
||||||
type_map,
|
type_map,
|
||||||
};
|
};
|
||||||
|
|
@ -243,7 +243,7 @@ mod tests {
|
||||||
use mtp::codec::SealedRelayBuilder;
|
use mtp::codec::SealedRelayBuilder;
|
||||||
use mtp::crypto::{DualSigner, Ed25519Signer, Keyring};
|
use mtp::crypto::{DualSigner, Ed25519Signer, Keyring};
|
||||||
|
|
||||||
fn relay(message_id: &str) -> Result<(Keyring, Keyring, CommunicationValue), String> {
|
fn relay(message_id: u128) -> Result<(Keyring, Keyring, CommunicationValue), String> {
|
||||||
let signer_keyring = Keyring::generate();
|
let signer_keyring = Keyring::generate();
|
||||||
let recipient_keyring = Keyring::generate();
|
let recipient_keyring = Keyring::generate();
|
||||||
let signer = DualSigner::new(
|
let signer = DualSigner::new(
|
||||||
|
|
@ -253,7 +253,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.map_err(|error| error.to_string())?;
|
.map_err(|error| error.to_string())?;
|
||||||
let frame = SealedRelayBuilder::new(
|
let frame = SealedRelayBuilder::new(
|
||||||
"MessageSend",
|
mtp::codec::CommunicationType::MessageSend,
|
||||||
mtp::codec::DataValue::Str("payload".into()),
|
mtp::codec::DataValue::Str("payload".into()),
|
||||||
7,
|
7,
|
||||||
42,
|
42,
|
||||||
|
|
@ -273,7 +273,7 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn verifies_metadata_with_trusted_signing_key() -> Result<(), String> {
|
async fn verifies_metadata_with_trusted_signing_key() -> Result<(), String> {
|
||||||
let (signer, recipient, frame) = relay("accepted")?;
|
let (signer, recipient, frame) = relay(1)?;
|
||||||
let trusted_key = signer.public_key_bundle();
|
let trusted_key = signer.public_key_bundle();
|
||||||
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
|
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
|
||||||
(signer_id == 7)
|
(signer_id == 7)
|
||||||
|
|
@ -285,13 +285,13 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(verified.context.signer_id, 7);
|
assert_eq!(verified.context.signer_id, 7);
|
||||||
assert_eq!(verified.context.final_recipient_id, 42);
|
assert_eq!(verified.context.final_recipient_id, 42);
|
||||||
assert_eq!(verified.context.message_id, "accepted");
|
assert_eq!(verified.context.message_id, "1");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn content_validation_uses_final_recipient_id() -> Result<(), String> {
|
async fn content_validation_uses_final_recipient_id() -> Result<(), String> {
|
||||||
let (signer, recipient, frame) = relay("final-recipient")?;
|
let (signer, recipient, frame) = relay(2)?;
|
||||||
let trusted_key = signer.public_key_bundle();
|
let trusted_key = signer.public_key_bundle();
|
||||||
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
|
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
|
||||||
(signer_id == 7)
|
(signer_id == 7)
|
||||||
|
|
@ -309,7 +309,7 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn rejects_metadata_signed_by_untrusted_key() -> Result<(), String> {
|
async fn rejects_metadata_signed_by_untrusted_key() -> Result<(), String> {
|
||||||
let (_signer, recipient, frame) = relay("wrong-key")?;
|
let (_signer, recipient, frame) = relay(3)?;
|
||||||
let wrong_signer = Keyring::generate();
|
let wrong_signer = Keyring::generate();
|
||||||
let trusted_key = wrong_signer.public_key_bundle();
|
let trusted_key = wrong_signer.public_key_bundle();
|
||||||
let result = verify_relay_metadata(&frame, 99, &recipient, move |_| async move {
|
let result = verify_relay_metadata(&frame, 99, &recipient, move |_| async move {
|
||||||
|
|
@ -328,7 +328,7 @@ mod tests {
|
||||||
let signer = Ed25519Signer::new(&signer_keyring.sig_cl_secret_key)
|
let signer = Ed25519Signer::new(&signer_keyring.sig_cl_secret_key)
|
||||||
.map_err(|error| error.to_string())?;
|
.map_err(|error| error.to_string())?;
|
||||||
let frame = SealedRelayBuilder::new(
|
let frame = SealedRelayBuilder::new(
|
||||||
"MessageSend",
|
mtp::codec::CommunicationType::MessageSend,
|
||||||
mtp::codec::DataValue::Str("payload".into()),
|
mtp::codec::DataValue::Str("payload".into()),
|
||||||
7,
|
7,
|
||||||
42,
|
42,
|
||||||
|
|
@ -337,7 +337,7 @@ mod tests {
|
||||||
.ok_or("invalid test target")?,
|
.ok_or("invalid test target")?,
|
||||||
&signer,
|
&signer,
|
||||||
)
|
)
|
||||||
.message_id("classical-only")
|
.message_id(7_u128)
|
||||||
.created_at(123)
|
.created_at(123)
|
||||||
.metadata_recipients(vec![recipient_keyring.public_key_bundle()])
|
.metadata_recipients(vec![recipient_keyring.public_key_bundle()])
|
||||||
.content_recipients(vec![recipient_keyring.public_key_bundle()])
|
.content_recipients(vec![recipient_keyring.public_key_bundle()])
|
||||||
|
|
@ -355,7 +355,7 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn rejects_outer_sender_before_key_lookup() -> Result<(), String> {
|
async fn rejects_outer_sender_before_key_lookup() -> Result<(), String> {
|
||||||
let (_signer, recipient, frame) = relay("outer-sender")?;
|
let (_signer, recipient, frame) = relay(4)?;
|
||||||
let frame = frame.with_sender(501);
|
let frame = frame.with_sender(501);
|
||||||
let result = verify_relay_metadata(&frame, 99, &recipient, |_| async {
|
let result = verify_relay_metadata(&frame, 99, &recipient, |_| async {
|
||||||
Err(RelayValidationError::MissingSigningKeys(7))
|
Err(RelayValidationError::MissingSigningKeys(7))
|
||||||
|
|
@ -371,7 +371,7 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn verification_does_not_commit_replay_state() -> Result<(), String> {
|
async fn verification_does_not_commit_replay_state() -> Result<(), String> {
|
||||||
let (signer, recipient, frame) = relay("duplicate")?;
|
let (signer, recipient, frame) = relay(5)?;
|
||||||
let trusted_key = signer.public_key_bundle();
|
let trusted_key = signer.public_key_bundle();
|
||||||
|
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
|
|
@ -387,7 +387,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn forwarding_preserves_sealed_payload() -> Result<(), String> {
|
fn forwarding_preserves_sealed_payload() -> Result<(), String> {
|
||||||
let (_signer, _recipient, frame) = relay("forwarding")?;
|
let (_signer, _recipient, frame) = relay(6)?;
|
||||||
let forwarded = forward_verified_relay(&frame, RouteTarget::User(100))
|
let forwarded = forward_verified_relay(&frame, RouteTarget::User(100))
|
||||||
.map_err(|error| error.to_string())?;
|
.map_err(|error| error.to_string())?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ iota-storage = { path = "../iota-storage" }
|
||||||
iota-updater = { path = "../iota-updater" }
|
iota-updater = { path = "../iota-updater" }
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
omikron-connector = { path = "../omikron-connector" }
|
omikron-connector = { path = "../omikron-connector" }
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c" }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
sysinfo = "0.38.0"
|
sysinfo = "0.38.0"
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ iota-paths = { path = "../iota-paths" }
|
||||||
iota-state = { path = "../iota-state" }
|
iota-state = { path = "../iota-state" }
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
|
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c" }
|
||||||
|
|
||||||
ratatui = "0.30.0"
|
ratatui = "0.30.0"
|
||||||
json = "0.12.4"
|
json = "0.12.4"
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,7 @@ macro_rules! log_cv_in {
|
||||||
$crate::log_cv_internal("> ", &$cv, Some($kind))
|
$crate::log_cv_internal("> ", &$cv, Some($kind))
|
||||||
};
|
};
|
||||||
($cv:expr) => {
|
($cv:expr) => {
|
||||||
$crate::log_cv_internal("> ", &$cv, None)
|
$crate::log_cv_internal("> ", $cv, None)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -463,6 +463,6 @@ macro_rules! log_cv_out {
|
||||||
$crate::log_cv_internal("< ", &$cv, Some($kind))
|
$crate::log_cv_internal("< ", &$cv, Some($kind))
|
||||||
};
|
};
|
||||||
($cv:expr) => {
|
($cv:expr) => {
|
||||||
$crate::log_cv_internal("< ", &$cv, None)
|
$crate::log_cv_internal("< ", $cv, None)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iota-paths = { path = "../iota-paths" }
|
iota-paths = { path = "../iota-paths" }
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = [
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = [
|
||||||
"crypto"
|
"crypto"
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ iota-logger = { path = "../iota-logger" }
|
||||||
iota-state = { path = "../iota-state" }
|
iota-state = { path = "../iota-state" }
|
||||||
iota-storage = { path = "../iota-storage" }
|
iota-storage = { path = "../iota-storage" }
|
||||||
iota-util = { path = "../iota-util" }
|
iota-util = { path = "../iota-util" }
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = [
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = [
|
||||||
"client",
|
"client",
|
||||||
"crypto",
|
"crypto",
|
||||||
"files",
|
"files",
|
||||||
|
|
|
||||||
|
|
@ -947,7 +947,7 @@ impl OmikronConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_event_from_relay(
|
fn client_event_from_relay(
|
||||||
message_type: &str,
|
message_type: CommunicationType,
|
||||||
payload: &DataValue,
|
payload: &DataValue,
|
||||||
signer_id: u64,
|
signer_id: u64,
|
||||||
recipient_id: u64,
|
recipient_id: u64,
|
||||||
|
|
@ -958,7 +958,7 @@ impl OmikronConnection {
|
||||||
let event_id = next_client_event_id();
|
let event_id = next_client_event_id();
|
||||||
|
|
||||||
match message_type {
|
match message_type {
|
||||||
"MessageSend" => {
|
CommunicationType::MessageSend => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::MessageSend)
|
let frame = CommunicationValue::new(CommunicationType::MessageSend)
|
||||||
.with_payload(payload.clone());
|
.with_payload(payload.clone());
|
||||||
let content = frame.get_data(DataType::Content)?.clone();
|
let content = frame.get_data(DataType::Content)?.clone();
|
||||||
|
|
@ -986,7 +986,7 @@ impl OmikronConnection {
|
||||||
.add_typed_default(DataType::Message, typed_container(message)),
|
.add_typed_default(DataType::Message, typed_container(message)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"SetChatSecret" => {
|
CommunicationType::SetChatSecret => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
|
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
|
||||||
.with_payload(payload.clone());
|
.with_payload(payload.clone());
|
||||||
let chat_id = frame.get_data(DataType::ChatId)?.clone();
|
let chat_id = frame.get_data(DataType::ChatId)?.clone();
|
||||||
|
|
@ -1014,7 +1014,7 @@ impl OmikronConnection {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"MessageEdit" => {
|
CommunicationType::MessageEdit => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::MessageEdit)
|
let frame = CommunicationValue::new(CommunicationType::MessageEdit)
|
||||||
.with_payload(payload.clone());
|
.with_payload(payload.clone());
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -1037,9 +1037,8 @@ impl OmikronConnection {
|
||||||
.add_typed_default(DataType::ChatPartnerId, sender.clone()),
|
.add_typed_default(DataType::ChatPartnerId, sender.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"MessageReactionAdd" | "MessageReactionRemove" => {
|
CommunicationType::MessageReactionAdd | CommunicationType::MessageReactionRemove => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::MessageReactionAdd)
|
let frame = CommunicationValue::new(message_type).with_payload(payload.clone());
|
||||||
.with_payload(payload.clone());
|
|
||||||
Some(
|
Some(
|
||||||
CommunicationValue::new(CommunicationType::MessageReactionLive)
|
CommunicationValue::new(CommunicationType::MessageReactionLive)
|
||||||
.with_id(event_id)
|
.with_id(event_id)
|
||||||
|
|
@ -1057,11 +1056,11 @@ impl OmikronConnection {
|
||||||
.add_typed_default(DataType::SenderId, sender)
|
.add_typed_default(DataType::SenderId, sender)
|
||||||
.add_typed_default(
|
.add_typed_default(
|
||||||
DataType::Accepted,
|
DataType::Accepted,
|
||||||
DataValue::Bool(message_type == "MessageReactionAdd"),
|
DataValue::Bool(message_type == CommunicationType::MessageReactionAdd),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"MessageDelete" | "MessageDeleteLive" => {
|
CommunicationType::MessageDelete | CommunicationType::MessageDeleteLive => {
|
||||||
let frame = CommunicationValue::new(CommunicationType::MessageDelete)
|
let frame = CommunicationValue::new(CommunicationType::MessageDelete)
|
||||||
.with_payload(payload.clone());
|
.with_payload(payload.clone());
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -1076,7 +1075,7 @@ impl OmikronConnection {
|
||||||
.add_typed_default(DataType::ChatPartnerId, sender),
|
.add_typed_default(DataType::ChatPartnerId, sender),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"AddConversation" if recipient_id < signer_id => {
|
CommunicationType::AddConversation if recipient_id < signer_id => {
|
||||||
let chat_id = format!("{recipient_id}:{signer_id}");
|
let chat_id = format!("{recipient_id}:{signer_id}");
|
||||||
Some(
|
Some(
|
||||||
CommunicationValue::new(CommunicationType::ChatSecretForward)
|
CommunicationValue::new(CommunicationType::ChatSecretForward)
|
||||||
|
|
@ -1797,7 +1796,7 @@ impl OmikronConnection {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client_event = Self::client_event_from_relay(
|
client_event = Self::client_event_from_relay(
|
||||||
&content.message_type,
|
content.message_type,
|
||||||
&content.content,
|
&content.content,
|
||||||
verified.context.signer_id,
|
verified.context.signer_id,
|
||||||
destination,
|
destination,
|
||||||
|
|
@ -3187,7 +3186,7 @@ impl OmikronConnection {
|
||||||
let sender_clone = Arc::clone(sender);
|
let sender_clone = Arc::clone(sender);
|
||||||
drop(sender_guard);
|
drop(sender_guard);
|
||||||
|
|
||||||
log_cv_out!(&cv);
|
log_cv_out!(cv);
|
||||||
|
|
||||||
if let Err(e) = sender_clone.send(cv).await {
|
if let Err(e) = sender_clone.send(cv).await {
|
||||||
self.fail_all_waiting_tasks(format!(
|
self.fail_all_waiting_tasks(format!(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["web-server"] }
|
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["web-server"] }
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
http = "1"
|
http = "1"
|
||||||
iota-logger = { path = "../iota-logger" }
|
iota-logger = { path = "../iota-logger" }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue