feat(rust): add check_origin fucntion for local_message check
-use crate::Identity;
+use crate::{Identity, ProfileIdentifier};
use async_trait::async_trait;
-use ockam_core::{Address, Result, Route};
+use ockam_core::{Address, Message, Result, Route, Routed};
use ockam_node::Context;
use ockam_vault_sync_core::VaultSync;
@@ -62,6 +62,19 @@ impl<P: Identity + Clone> SecureChannelTrait for P {
}
}
+// TODO: rename
+pub fn check_message_origin<T: Message>(
+ msg: &Routed<T>,
+ their_profile_id: &ProfileIdentifier,
+) -> Result<bool> {
+ let local_msg = msg.local_message();
+ let local_info = LocalInfo::decode(local_msg.local_info())?;
+
+ let res = local_info.their_profile_id() == their_profile_id;
+
+ Ok(res)
+}
+
#[cfg(test)]
mod test {
/* use super::*;
