use std::collections::BTreeMap;
use ruma_common::{
serde::Base64, MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
};
use serde::{Deserialize, Serialize};
pub mod discover_homeserver;
pub mod get_remote_server_keys;
pub mod get_remote_server_keys_batch;
pub mod get_server_keys;
pub mod get_server_version;
#[cfg(feature = "unstable-msc3723")]
pub mod get_server_versions;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct VerifyKey {
pub key: Base64,
}
impl VerifyKey {
pub fn new(key: Base64) -> Self {
Self { key }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct OldVerifyKey {
pub expired_ts: MilliSecondsSinceUnixEpoch,
pub key: Base64,
}
impl OldVerifyKey {
pub fn new(expired_ts: MilliSecondsSinceUnixEpoch, key: Base64) -> Self {
Self { expired_ts, key }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ServerSigningKeys {
pub server_name: OwnedServerName,
pub verify_keys: BTreeMap<OwnedServerSigningKeyId, VerifyKey>,
pub old_verify_keys: BTreeMap<OwnedServerSigningKeyId, OldVerifyKey>,
pub signatures: BTreeMap<OwnedServerName, BTreeMap<OwnedServerSigningKeyId, String>>,
pub valid_until_ts: MilliSecondsSinceUnixEpoch,
}
impl ServerSigningKeys {
pub fn new(server_name: OwnedServerName, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self {
Self {
server_name,
verify_keys: BTreeMap::new(),
old_verify_keys: BTreeMap::new(),
signatures: BTreeMap::new(),
valid_until_ts,
}
}
}