sync-wip
This commit is contained in:
parent
be722d5474
commit
7cd204cad2
|
@ -92,11 +92,11 @@ pub enum Mentions {
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum FeedTypedContent {
|
pub enum TypedMessage {
|
||||||
#[serde(rename = "pub")]
|
#[serde(rename = "pub")]
|
||||||
Pub { address: Option<PubAddress> },
|
Pub { address: Option<PubAddress> },
|
||||||
#[serde(rename = "post")]
|
#[serde(rename = "post")]
|
||||||
Post,
|
Post { post: Post },
|
||||||
#[serde(rename = "contact")]
|
#[serde(rename = "contact")]
|
||||||
Contact {
|
Contact {
|
||||||
contact: Option<SsbId>,
|
contact: Option<SsbId>,
|
||||||
|
|
|
@ -5,3 +5,5 @@ pub use error::{Error, Result};
|
||||||
pub use sodium::{
|
pub use sodium::{
|
||||||
ToSodiumObject, ToSsbId, CURVE_ED25519_SUFFIX, ED25519_SIGNATURE_SUFFIX, SHA256_SUFFIX,
|
ToSodiumObject, ToSsbId, CURVE_ED25519_SUFFIX, ED25519_SIGNATURE_SUFFIX, SHA256_SUFFIX,
|
||||||
};
|
};
|
||||||
|
pub use sodiumoxide::crypto::hash::sha256 as sha256;
|
||||||
|
pub use sodiumoxide::crypto::sign::ed25519 as ed25519;
|
|
@ -10,6 +10,7 @@ pub const SHA256_SUFFIX: &str = ".sha256";
|
||||||
|
|
||||||
pub trait ToSodiumObject {
|
pub trait ToSodiumObject {
|
||||||
fn to_ed25519_pk(&self) -> Result<ed25519::PublicKey>;
|
fn to_ed25519_pk(&self) -> Result<ed25519::PublicKey>;
|
||||||
|
fn to_ed25519_pk_no_suffix(&self) -> Result<ed25519::PublicKey>;
|
||||||
fn to_ed25519_sk(&self) -> Result<ed25519::SecretKey>;
|
fn to_ed25519_sk(&self) -> Result<ed25519::SecretKey>;
|
||||||
fn to_ed25519_sk_no_suffix(&self) -> Result<ed25519::SecretKey>;
|
fn to_ed25519_sk_no_suffix(&self) -> Result<ed25519::SecretKey>;
|
||||||
fn to_ed25519_signature(&self) -> Result<ed25519::Signature>;
|
fn to_ed25519_signature(&self) -> Result<ed25519::Signature>;
|
||||||
|
@ -43,6 +44,12 @@ impl ToSodiumObject for str {
|
||||||
|
|
||||||
ed25519::PublicKey::from_slice(&bytes).ok_or_else(|| Error::BadPublicKey)
|
ed25519::PublicKey::from_slice(&bytes).ok_or_else(|| Error::BadPublicKey)
|
||||||
}
|
}
|
||||||
|
fn to_ed25519_pk_no_suffix(self: &str) -> Result<ed25519::PublicKey> {
|
||||||
|
|
||||||
|
let bytes = base64::decode(&self)?;
|
||||||
|
|
||||||
|
ed25519::PublicKey::from_slice(&bytes).ok_or_else(|| Error::BadPublicKey)
|
||||||
|
}
|
||||||
|
|
||||||
fn to_ed25519_sk(self: &str) -> Result<ed25519::SecretKey> {
|
fn to_ed25519_sk(self: &str) -> Result<ed25519::SecretKey> {
|
||||||
if !self.ends_with(CURVE_ED25519_SUFFIX) {
|
if !self.ends_with(CURVE_ED25519_SUFFIX) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl Header {
|
||||||
1 => BodyType::UTF8,
|
1 => BodyType::UTF8,
|
||||||
2 => BodyType::JSON,
|
2 => BodyType::JSON,
|
||||||
_ => {
|
_ => {
|
||||||
warn!("rare message: {}", String::from_utf8_lossy(bytes));
|
warn!(target: "ssb", "rare message: {}", String::from_utf8_lossy(bytes));
|
||||||
return Err(Error::InvalidBodyType(body_type_value));
|
return Err(Error::InvalidBodyType(body_type_value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue