diff --git a/ruma-client-api/src/r0/membership.rs b/ruma-client-api/src/r0/membership.rs index e41e35c6..a64ac0ce 100644 --- a/ruma-client-api/src/r0/membership.rs +++ b/ruma-client-api/src/r0/membership.rs @@ -15,7 +15,7 @@ pub mod unban_user; use std::collections::BTreeMap; use ruma_common::{thirdparty::Medium, Outgoing}; -use ruma_identifiers::{ServerNameBox, SigningKeyId}; +use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use serde::Serialize; /// A signature of an `m.third_party_invite` token to prove that this user owns a third party @@ -32,7 +32,7 @@ pub struct ThirdPartySigned<'a> { pub token: &'a str, /// A signatures object containing a signature of the entire signed object. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, } /// Represents third party IDs to invite to the room. diff --git a/ruma-events/src/pdu.rs b/ruma-events/src/pdu.rs index f71b510e..ad339c08 100644 --- a/ruma-events/src/pdu.rs +++ b/ruma-events/src/pdu.rs @@ -12,7 +12,7 @@ use std::{collections::BTreeMap, time::SystemTime}; use js_int::UInt; use ruma_events::EventType; -use ruma_identifiers::{EventId, RoomId, ServerNameBox, SigningKeyId, UserId}; +use ruma_identifiers::{EventId, RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; @@ -86,7 +86,7 @@ pub struct RoomV1Pdu { pub hashes: EventHash, /// Signatures for the PDU. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, } /// A 'persistent data unit' (event) for room versions 3 and beyond. @@ -143,7 +143,7 @@ pub struct RoomV3Pdu { pub hashes: EventHash, /// Signatures for the PDU. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, } /// PDU type without event and room IDs. @@ -220,7 +220,7 @@ pub struct RoomV1PduStub { pub hashes: EventHash, /// Signatures for the PDU. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, } impl RoomV1PduStub { @@ -298,7 +298,7 @@ pub struct RoomV3PduStub { pub hashes: EventHash, /// Signatures for the PDU. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, } impl RoomV3PduStub { diff --git a/ruma-events/src/room/member.rs b/ruma-events/src/room/member.rs index dd3d68b2..0a68f6b2 100644 --- a/ruma-events/src/room/member.rs +++ b/ruma-events/src/room/member.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use ruma_common::StringEnum; use ruma_events_macros::StateEventContent; -use ruma_identifiers::{ServerNameBox, SigningKeyId, UserId}; +use ruma_identifiers::{ServerNameBox, ServerSigningKeyId, UserId}; use serde::{Deserialize, Serialize}; use crate::{StateEvent, StrippedStateEvent, SyncStateEvent}; @@ -109,7 +109,7 @@ pub struct SignedContent { /// A single signature from the verifying server, in the format specified by the Signing Events /// section of the server-server API. - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, /// The token property of the containing third_party_invite object. pub token: String, diff --git a/ruma-federation-api/src/discovery.rs b/ruma-federation-api/src/discovery.rs index c43f87f9..65a91692 100644 --- a/ruma-federation-api/src/discovery.rs +++ b/ruma-federation-api/src/discovery.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, time::SystemTime}; -use ruma_identifiers::{ServerNameBox, SigningKeyId}; +use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use serde::{Deserialize, Serialize}; pub mod discover_homeserver; @@ -54,14 +54,14 @@ pub struct SigningKey { pub server_name: ServerNameBox, /// Public keys of the homeserver for verifying digital signatures. - pub verify_keys: BTreeMap, + pub verify_keys: BTreeMap, /// Public keys that the homeserver used to use and when it stopped using them. - pub old_verify_keys: BTreeMap, + pub old_verify_keys: BTreeMap, /// Digital signatures of this object signed using the verify_keys. Map of /// server name to keys by key ID - pub signatures: BTreeMap>, + pub signatures: BTreeMap>, /// Timestamp when the keys should be refreshed. This field MUST be ignored in room /// versions 1, 2, 3, and 4. diff --git a/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs b/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs index 3fce3a8e..d39da56a 100644 --- a/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs +++ b/ruma-federation-api/src/discovery/get_remote_server_keys_batch/v2.rs @@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::SystemTime}; use crate::discovery::SigningKey; use ruma_api::ruma_api; -use ruma_identifiers::{ServerNameBox, SigningKeyId}; +use ruma_identifiers::{ServerNameBox, ServerSigningKeyId}; use serde::{Deserialize, Serialize}; ruma_api! { @@ -28,7 +28,7 @@ ruma_api! { /// The notary server may return multiple keys regardless of the Key IDs /// given. #[ruma_api(body)] - pub server_keys: BTreeMap>, + pub server_keys: BTreeMap>, /// A millisecond POSIX timestamp in milliseconds indicating when the /// returned certificates will need to be valid until to be useful to @@ -50,7 +50,7 @@ ruma_api! { impl Request { /// Creates a new `Request` with the given query criteria and `minimum_valid_until` timestamp. pub fn new( - server_keys: BTreeMap>, + server_keys: BTreeMap>, minimum_valid_until_ts: SystemTime, ) -> Self { Self { server_keys, minimum_valid_until_ts } diff --git a/ruma-federation-api/src/thirdparty/bind_callback/v1.rs b/ruma-federation-api/src/thirdparty/bind_callback/v1.rs index 14fe9f2c..ecb86592 100644 --- a/ruma-federation-api/src/thirdparty/bind_callback/v1.rs +++ b/ruma-federation-api/src/thirdparty/bind_callback/v1.rs @@ -2,7 +2,7 @@ use ruma_api::ruma_api; use ruma_common::thirdparty::Medium; -use ruma_identifiers::{RoomId, ServerNameBox, SigningKeyId, UserId}; +use ruma_identifiers::{RoomId, ServerNameBox, ServerSigningKeyId, UserId}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -61,7 +61,7 @@ pub struct ThirdPartyInvite { pub sender: UserId, /// Signature from the identity server using a long-term private key. - pub signed: BTreeMap>, + pub signed: BTreeMap>, } impl ThirdPartyInvite { @@ -71,7 +71,7 @@ impl ThirdPartyInvite { mxid: UserId, room_id: RoomId, sender: UserId, - signed: BTreeMap>, + signed: BTreeMap>, ) -> Self { Self { medium: Medium::Email, address, mxid, room_id, sender, signed } } diff --git a/ruma-identifiers-macros/src/lib.rs b/ruma-identifiers-macros/src/lib.rs index be28e840..211904ed 100644 --- a/ruma-identifiers-macros/src/lib.rs +++ b/ruma-identifiers-macros/src/lib.rs @@ -88,7 +88,7 @@ pub fn server_key_id(input: TokenStream) -> TokenStream { assert!(signing_key_id::validate(&id.value()).is_ok(), "Invalid server_key_id"); let output = quote! { - <#dollar_crate::SigningKeyId as ::std::convert::TryFrom<&str>>::try_from(#id).unwrap() + <#dollar_crate::ServerSigningKeyId as ::std::convert::TryFrom<&str>>::try_from(#id).unwrap() }; output.into() @@ -114,7 +114,7 @@ pub fn signing_key_id(input: TokenStream) -> TokenStream { assert!(signing_key_id::validate(&id.value()).is_ok(), "Invalid signing_key_id"); let output = quote! { - <#dollar_crate::SigningKeyId as ::std::convert::TryFrom<&str>>::try_from(#id).unwrap() + <#dollar_crate::ServerSigningKeyId as ::std::convert::TryFrom<&str>>::try_from(#id).unwrap() }; output.into() diff --git a/ruma-identifiers/CHANGELOG.md b/ruma-identifiers/CHANGELOG.md index 65b551ef..86b186ae 100644 --- a/ruma-identifiers/CHANGELOG.md +++ b/ruma-identifiers/CHANGELOG.md @@ -5,7 +5,8 @@ Breaking changes: * Update strum dependency to 0.19 * Remove deprecated constructors * Remove deprecated `is_` methods -* Rename `ServerKeyId` to `SigningKeyId` +* Rename `ServerKeyAlgorithm` to `SigningKeyAlgorithm` +* Rename `ServerKeyId` to `ServerSigningKeyId` Improvements: diff --git a/ruma-identifiers/src/lib.rs b/ruma-identifiers/src/lib.rs index 6ae49988..01eb77c2 100644 --- a/ruma-identifiers/src/lib.rs +++ b/ruma-identifiers/src/lib.rs @@ -29,7 +29,7 @@ pub use crate::{ room_id_or_room_alias_id::RoomIdOrAliasId, room_version_id::RoomVersionId, server_name::{ServerName, ServerNameBox}, - signing_key_id::SigningKeyId, + signing_key_id::ServerSigningKeyId, user_id::UserId, }; #[doc(inline)] @@ -137,7 +137,7 @@ macro_rules! room_version_id { }; } -/// Compile-time checked `SigningKeyId` construction. +/// Compile-time checked `ServerSigningKeyId` construction. #[macro_export] macro_rules! server_key_id { ($s:literal) => { diff --git a/ruma-identifiers/src/signing_key_id.rs b/ruma-identifiers/src/signing_key_id.rs index e66aa72f..9319fac0 100644 --- a/ruma-identifiers/src/signing_key_id.rs +++ b/ruma-identifiers/src/signing_key_id.rs @@ -6,13 +6,13 @@ use ruma_identifiers_validation::{crypto_algorithms::SigningKeyAlgorithm, Error} /// Key identifiers used for homeserver signing keys. #[derive(Clone, Debug)] -pub struct SigningKeyId { +pub struct ServerSigningKeyId { full_id: Box, colon_idx: NonZeroU8, } -impl SigningKeyId { - /// Create a `SigningKeyId` from a `SigningKeyAlgorithm` and a `ServerId`. +impl ServerSigningKeyId { + /// Create a `ServerSigningKeyId` from a `SigningKeyAlgorithm` and a `ServerId`. pub fn from_parts(algorithm: SigningKeyAlgorithm, version: &str) -> Self { let algorithm: &str = algorithm.as_ref(); @@ -25,7 +25,7 @@ impl SigningKeyId { NonZeroU8::new(algorithm.len().try_into().expect("no algorithm name len > 255")) .expect("no empty algorithm name"); - SigningKeyId { full_id: res.into(), colon_idx } + ServerSigningKeyId { full_id: res.into(), colon_idx } } /// Returns key algorithm of the server key ID. @@ -39,15 +39,15 @@ impl SigningKeyId { } } -fn try_from(key_id: S) -> Result +fn try_from(key_id: S) -> Result where S: AsRef + Into>, { let colon_idx = ruma_identifiers_validation::signing_key_id::validate(key_id.as_ref())?; - Ok(SigningKeyId { full_id: key_id.into(), colon_idx }) + Ok(ServerSigningKeyId { full_id: key_id.into(), colon_idx }) } -common_impls!(SigningKeyId, try_from, "Key ID with algorithm and version"); +common_impls!(ServerSigningKeyId, try_from, "Key ID with algorithm and version"); #[cfg(test)] mod tests { @@ -56,7 +56,7 @@ mod tests { #[cfg(feature = "serde")] use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; - use crate::{Error, SigningKeyId}; + use crate::{Error, ServerSigningKeyId}; #[cfg(feature = "serde")] use ruma_identifiers_validation::crypto_algorithms::SigningKeyAlgorithm; @@ -64,7 +64,7 @@ mod tests { #[cfg(feature = "serde")] #[test] fn deserialize_id() { - let server_key_id: SigningKeyId = from_json_value(json!("ed25519:Abc_1")).unwrap(); + let server_key_id: ServerSigningKeyId = from_json_value(json!("ed25519:Abc_1")).unwrap(); assert_eq!(server_key_id.algorithm(), SigningKeyAlgorithm::Ed25519); assert_eq!(server_key_id.version(), "Abc_1"); } @@ -72,19 +72,23 @@ mod tests { #[cfg(feature = "serde")] #[test] fn serialize_id() { - let server_key_id: SigningKeyId = SigningKeyId::try_from("ed25519:abc123").unwrap(); + let server_key_id: ServerSigningKeyId = + ServerSigningKeyId::try_from("ed25519:abc123").unwrap(); assert_eq!(to_json_value(&server_key_id).unwrap(), json!("ed25519:abc123")); } #[test] fn invalid_version_characters() { - assert_eq!(SigningKeyId::try_from("ed25519:Abc-1").unwrap_err(), Error::InvalidCharacters); + assert_eq!( + ServerSigningKeyId::try_from("ed25519:Abc-1").unwrap_err(), + Error::InvalidCharacters + ); } #[test] fn invalid_key_algorithm() { assert_eq!( - SigningKeyId::try_from("signed_curve25519:Abc-1").unwrap_err(), + ServerSigningKeyId::try_from("signed_curve25519:Abc-1").unwrap_err(), Error::UnknownKeyAlgorithm, ); } @@ -92,7 +96,7 @@ mod tests { #[test] fn missing_delimiter() { assert_eq!( - SigningKeyId::try_from("ed25519|Abc_1").unwrap_err(), + ServerSigningKeyId::try_from("ed25519|Abc_1").unwrap_err(), Error::MissingSigningKeyDelimiter, ); } diff --git a/ruma/src/lib.rs b/ruma/src/lib.rs index 30718cdc..b1437cac 100644 --- a/ruma/src/lib.rs +++ b/ruma/src/lib.rs @@ -27,7 +27,7 @@ pub use ruma_serde as serde; pub use ruma_identifiers::{ device_id, device_key_id, event_id, room_alias_id, room_id, room_version_id, server_key_id, server_name, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, EventId, RoomAliasId, RoomId, - RoomIdOrAliasId, RoomVersionId, ServerName, SigningKeyAlgorithm, SigningKeyId, UserId, + RoomIdOrAliasId, RoomVersionId, ServerName, ServerSigningKeyId, SigningKeyAlgorithm, UserId, }; #[cfg(feature = "ruma-events")]