identity-service-api: Fix format of keys in store_invitation::v2::PublicKeys

According to a spec clarification

Co-authored-by: Jonas Platte <jplatte@element.io>
This commit is contained in:
Kévin Commaille 2023-05-24 11:04:36 +02:00 committed by GitHub
parent f45a09e958
commit 77454b70e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View File

@ -1,5 +1,10 @@
# [unreleased]
Breaking changes:
* Fix the format of the keys in `invitation::store_invitation::v2::PublicKeys` according to a spec
clarification
# 0.7.1
Improvements:

View File

@ -140,10 +140,10 @@ pub mod v2 {
#[allow(clippy::exhaustive_structs)]
pub struct PublicKeys {
/// The server's long-term public key.
pub server_key: String,
pub server_key: PublicKey,
/// The generated ephemeral public key.
pub ephemeral_key: String,
pub ephemeral_key: PublicKey,
}
impl<'de> Deserialize<'de> for PublicKeys {
@ -151,7 +151,7 @@ pub mod v2 {
where
D: serde::Deserializer<'de>,
{
let [server_key, ephemeral_key] = <[String; 2]>::deserialize(deserializer)?;
let [server_key, ephemeral_key] = <[PublicKey; 2]>::deserialize(deserializer)?;
Ok(Self { server_key, ephemeral_key })
}
@ -170,4 +170,23 @@ pub mod v2 {
seq.end()
}
}
/// A server's long-term or ephemeral public key.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PublicKey {
/// The public key, encoded using [unpadded Base64](https://spec.matrix.org/latest/appendices/#unpadded-base64).
pub public_key: String,
/// The URI of an endpoint where the validity of this key can be checked by passing it as a
/// `public_key` query parameter.
pub key_validity_url: String,
}
impl PublicKey {
/// Constructs a new `PublicKey` with the given encoded public key and key validity URL.
pub fn new(public_key: String, key_validity_url: String) -> Self {
Self { public_key, key_validity_url }
}
}
}