Skip to main content

Module policy_server

Module policy_server 

Source

Re-exportsΒ§

use std::collections::BTreeMap; πŸ”’
use std::time::Duration; πŸ”’
use std::time::SystemTime; πŸ”’
use std::time::UNIX_EPOCH; πŸ”’
use http::StatusCode; πŸ”’
use ruma::CanonicalJsonObject; πŸ”’
use ruma::CanonicalJsonValue; πŸ”’
use ruma::EventId; πŸ”’
use ruma::OwnedServerName; πŸ”’
use ruma::RoomId; πŸ”’
use ruma::RoomVersionId; πŸ”’
use ruma::ServerName; πŸ”’
use ruma::SigningKeyAlgorithm; πŸ”’
use ruma::api::error::ErrorKind; πŸ”’
use ruma::api::error::RetryAfter; πŸ”’
use ruma::api::federation::policy::sign_event::v1 as sign_event; πŸ”’
use ruma::events::StateEventType; πŸ”’
use ruma::events::room::policy::POLICY_SERVER_ED25519_SIGNING_KEY_ID; πŸ”’
use ruma::events::room::policy::RoomPolicyEventContent; πŸ”’
use ruma::serde::Base64; πŸ”’
use ruma::signatures::to_canonical_json_string_for_signing; πŸ”’
use ruma::signatures::verify_canonical_json_bytes; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use serde_json::value::to_raw_value; πŸ”’
use tuwunel_core::Err; πŸ”’
use tuwunel_core::Result; πŸ”’
use tuwunel_core::at; πŸ”’
use tuwunel_core::debug; πŸ”’
use tuwunel_core::debug; πŸ”’
use tuwunel_core::implement; πŸ”’
use tuwunel_core::trace; πŸ”’
use tuwunel_core::utils::BoolExt as _; πŸ”’
use tuwunel_core::utils::time::now_secs; πŸ”’
use tuwunel_core::warn; πŸ”’
use tuwunel_database::Cbor; πŸ”’
use tuwunel_database::Deserialized; πŸ”’
use tuwunel_matrix::Event; πŸ”’
use tuwunel_matrix::pdu::into_outgoing_federation; πŸ”’
use tuwunel_matrix::room_version::rules as room_version_rules; πŸ”’

StructsΒ§

UnstablePolicyContent πŸ”’
Lenient deserialiser that accepts either the stable public_keys: { ed25519: ... } shape or the MSC4284 unstable singular public_key: <ed25519> shape, and folds the latter into the former.

EnumsΒ§

FetchOutcome πŸ”’
Outcome of a /sign round-trip to the policy server.
PolicyCheck
Outcome of an inbound policy-server signature check.
PolicySigState πŸ”’
Persisted per-event policy-server outcome in eventid_policysigstate. Absence of a row means β€œno prior decision recorded; proceed with /sign”.

ConstantsΒ§

POLICY_REFUSAL_TTL πŸ”’
UNSTABLE_POLICY_TYPE πŸ”’
MSC4284 unstable state event type. The merged spec stabilised this to m.room.policy, but the reference policy server (and Element’s default deployments as of 2026-05) still write the unstable type with the singular public_key field; reading both keeps the gate live for those rooms.

FunctionsΒ§

check_policy_signature πŸ”’
classify_fetch_error πŸ”’
current_policy_state πŸ”’
extract_policy_signature πŸ”’
insert_policy_signature πŸ”’
is_policy_state_event πŸ”’
parse_rate_limit πŸ”’