A set of Rust crates for interacting with the Matrix chat network.

Overview

Ruma – Your home in Matrix.

A set of Rust crates (libraries) for interacting with the Matrix chat network.

websitechatdocumentation (unstable)

Getting started

If you want to build a Matrix client or bot, have a look at matrix-rust-sdk. It builds on Ruma and includes handling of state storage, end-to-end encryption and many other useful things.

For homeservers, bridges and harder-to-categorize software that works with Matrix, you're at the right place. To get started, add ruma to your dependencies:

# crates.io release
ruma = { version = "0.3.0", features = ["..."] }
# git dependency
ruma = { git = "https://github.com/ruma/ruma", branch = "main", features = ["..."] }

ruma re-exports all of the other crates, so you don't have to worry about them. Check out the documentation on docs.rs (or on docs.ruma.io if you use use the git dependency).

Status

As of 2021-02-10, we support all events and REST endpoints the latest released versions of the various Matrix APIs. Various changes from the unstable version of the specifications and some MSCs are also implemented, gated behind the unstable-pre-spec Cargo feature.

Contributing

See CONTRIBUTING.md.

Minimum Rust version

Ruma currently requires Rust 1.55. In general, we will never require beta or nightly for crates.io releases of our crates, and we will try to avoid releasing crates that depend on features that were only just stabilized.

ruma-signatures is an exception: It uses cryptographic libraries that often use relatively new features and that we don't want to use outdated versions of. It is guaranteed to work with whatever is the latest stable version though.

License

MIT

Comments
  • Methods to test events against push rules

    Methods to test events against push rules

    Although in the spec push rules are only supposed to be handled by homeservers, clients generally need to support push rules to handle encrypted events.

    Seeing as this is needed by both clients and servers, I wonder if it makes sense to implement this directly in Ruma.

    area/push-rules help wanted 
    opened by zecakeh 40
  • Add support for redacted events

    Add support for redacted events

    This will require custom parsing, because the event type isn't changed when an event is redacted. Redacted events can be detected by checking for a redacted_because field.

    effort/medium area/events 
    opened by jplatte 32
  • get_pushrule::Response has incompatible PushRule type

    get_pushrule::Response has incompatible PushRule type

    ruma::api::client::r0::push::get_pushrule::Response takes a ruma::api::client::r0::push::PushRule, which is not compatible with any of the pushrule types defined in ruma::events::push_rules. IMO there should be an enum over all pushrule types and get_pushrule::Response returns that enum.

    effort/medium area/client-api area/push-rules 
    opened by timokoesters 20
  • Add more automated checks for our code style

    Add more automated checks for our code style

    We have had accidentally-private fields a bunch of times now, also mod.rs files have appeared a number of times after we initially moved away from them. I'd also like to enforce some other things, like how serde_json::Value should always be import-renamed to JsonValue. There might be existing tooling for some of this, but maybe it's also feasible to create new tooling for a few things.

    effort/hard 
    opened by jplatte 17
  • Make Signatures type generic over owner ID and key ID

    Make Signatures type generic over owner ID and key ID

    There are signatures that take UserId and DeviceKeyId and some that take ServerName and ServerKeyId Maybe we need to make the Signatures struct in ruma-signatures (forgot that existed) generic and provide Signatures<UserId, DeviceKeyId> and Signatures<ServerName, ServerKeyId>.

    We should also update all the fields that hold signatures to use this type rather than a BTreeMap.

    Dependent on matrix-org/matrix-spec-proposals#27.

    effort/medium area/signatures area/identifiers area/federation-api help wanted 
    opened by iinuwa 17
  • Ruma panics when SystemTime timestamp milliseconds are too high

    Ruma panics when SystemTime timestamp milliseconds are too high

    You should probably use checked_add

    Example which fails on my machine:

    _matrix/key/v2/server

    {"old_verify_keys":{"ed25519:a_YjQO":{"expired_ts":15159743990000,"key":"AYWls+cjEfl8R3u4mDSMX/MRhKXSgvjNgSruukDlHTU"}},"server_name":"half-shot.uk","signatures":{"half-shot.uk":{"ed25519:a_fBAF":"QJcEQVEK5E1pu4CW527z3+k6e/cY9Rmy5xj4RSeoL5P0cu+VICpa6P3vYmfLCNYuCQVFDlalVLCByfEKnv53CQ"}},"tls_fingerprints":[],"valid_until_ts":1617084632196,"verify_keys":{"ed25519:a_fBAF":{"key":"jIIoZEpAXY6GgNWybOc9GWHx11TBsNScGihLNx4KcaQ"}}}

    type/bug area/events help wanted 
    opened by timokoesters 16
  • Events should have attributes indicating the encryption state.

    Events should have attributes indicating the encryption state.

    Every room event might have been an encrypted event, e.g. a client will turn a m.room.encrypted event into a m.room.message event.

    Clients need to present some info about this to users. For example an event wasn't encrypted but is posted in an encrypted room, clients might want to decorate such an event with a warning.

    Clients will want to show:

    • If an event was encrypted or not
    • If an event is successfully verified or not
    • Let clients record the sender key coming from the m.room.encrypted event, so if the trust state of the device holding the key changes, clients can change the presented verification state of the event.

    I suggest we add an optional EncryptionInfo attribute to the events containing something like:

    struct EncryptionInfo {
        verified: bool,
        sender_key: String,
        device_id: String,
        session_id: String
    }
    

    Most of those attributes will come from the encrypted version of the event, the m.room.encrypted event. The lack of the EncryptionInfo would indicate that the event was unencrypted.

    effort/medium area/events 
    opened by poljar 16
  • Key verification events can be in the timeline as well.

    Key verification events can be in the timeline as well.

    Key verification events as per https://github.com/matrix-org/matrix-doc/pull/2241 will be sent out as normal room messages. This means they will contain a sender, event_id, origin_server_ts etc.

    Key verification events need to be updated to include those attributes.

    The affected event types are:

    • m.key.verification.accept
    • m.key.verification.cancel
    • m.key.verification.key
    • m.key.verification.mac
    • m.key.verification.request
    • m.key.verification.start
    effort/medium area/events 
    opened by poljar 16
  • Add allow to JoinRulesEventContent

    Add allow to JoinRulesEventContent

    Adds an allow field to JoinRulesEventContent according to MSC3083. I wanted to make AllowRule an enum like

    pub enum AllowRule {
        RoomMembership(RoomId)
    }
    

    But wasn't sure how to make that (de)serialize correctly.

    opened by agraven 14
  • Don't build criterion in CI

    Don't build criterion in CI

    It would be nice if criterion was not a regular dev-depenency that is built for tests since we only need it for benchmarks that we don't want to run on CI either way.

    The one way to do this I can come up with so far is moving benchmarks to a separate, workspace-excluded crate.

    effort/medium 
    opened by jplatte 14
  • WASM support for ruma-signatures

    WASM support for ruma-signatures

    Currently rings Ed25519 doesn't work for the WebAssembly target (https://github.com/briansmith/ring/issues/918), hence ruma-signature doesn't work on WASM either.

    area/signatures 
    opened by stoically 14
  • events: Update extensible events types

    events: Update extensible events types

    According to the latest rewrite of the MSCs.

    The unstable prefixes are now used everywhere, as recommended in MSC1767.

    A bunch of conversion methods between the legacy types and the new extensible events types have been removed to lighten the maintenance burden if/when this needs to be updated again, as they bring only little benefit.

    The naming of the types has been streamlined by using the ContentBlock suffix consistently when a type is defined as such. That also means that some of those types are newtype structs purely for the semantic meaning as a reusable block.

    It is recommended to review by file as it usually means reviewing by MSC. It might be easier than by commit, where some incomplete changes are done on event types when the content block types it depends on are changed too.


    Preview: https://pr-1440--ruma-docs.surge.sh

    opened by zecakeh 0
  • Allow `PushCondition` to deserialize from unknown `kind`

    Allow `PushCondition` to deserialize from unknown `kind`

    The deserialization of PushRulesEventContent can fail because of the implementation of MSC3931 by Synapse that adds a new condition org.matrix.msc3931.room_version_supports.

    We should add a hidden variant that allows to deserialize from unknown conditions. It should maybe keep all the data of the condition so clients can deserialize with a custom type if needed?

    An unknown rule never applies.

    effort/easy type/bug area/push-rules 
    opened by zecakeh 0
  • Remove Serialize implementation for ToDeviceEvent

    Remove Serialize implementation for ToDeviceEvent

    After #1404, we still have one *Event type that implements Serialize: ToDeviceEvent. Currently this is being used by matrix-rust-sdk, but I'm pretty sure there will be an easy enough way around that. Once it no longer relies on this impl, we should remove it (if only for consistency).

    effort/easy area/events blocked breaking change 
    opened by jplatte 0
  • feat: add support for unstable-msc3931/3932 style push conditions parsing

    feat: add support for unstable-msc3931/3932 style push conditions parsing

    Seeing

    :WARN :matrix_sdk_base::client:crates/matrix-sdk-base/src/client.rs:529:Failed to deserialize a global account data event error=Error("unknown variant `org.matrix.msc3931.room_version_supports`, expected one of `event_match`, `contains_display_name`, `room_member_count`, `sender_notification_permission`", line: 1, column: 1018)
    

    because the server sends 3931 field values we don't have support for yet. This PR adds support for it behind another unstable--flag. Not sure if we need/want to have another fallback support in case the flag is not activated.

    Closes #1431.


    Preview: https://pr-1405--ruma-docs.surge.sh

    opened by gnunicorn 2
  • Incorporate Matrix next version changes

    Incorporate Matrix next version changes

    Here is the current unstable spec changelog to follow our progress, to be updated regularly until the next release.

    To be sure we don't miss anything, ALL entries of the changelog (except the section about internal changes) should appear here in the same order and category. The ones that we have to implement should be linked to an issue and/or a PR or commit in this repository. If an extra step is necessary when the version is released (like moving it from an unstable feature flag), a subtask should be created. The ones that don't impact us should be struck.

    1.1 Client-Server API

    Backwards Compatible Changes

    • [x] ~~Add information on standard error responses for unknown endpoints/methods. (#1347)~~
    • [x] Add /rooms/<roomID>/timestamp_to_event endpoint, as per MSC3030. (#1366) #1427
      • [ ] Move out of unstable-msc3030

    Spec Clarifications

    • [x] ~~Clarify the power levels integer range. (#1169, #1355)~~
    • [x] Clarify that /context always returns event even if limit is zero. (#1239) #1402
    • [x] Clarify what fields are required when deleting a pusher (#1321) #1369
    • [x] ~~Improve the presentation of push rule kinds and actions. (#1348)~~
    • [x] ~~Add missing description to m.call.answer schema. (#1353)~~
    • [x] ~~Fix various typos throughout the specification. (#1363)~~
    • [x] ~~Move login API definitions to the right heading. (#1382)~~

    1.2 Server-Server API

    Breaking Changes

    • [x] Remove keyId from the server /keys endpoints, as per MSC3938. (#1350) #1435

    Backwards Compatible Changes

    • [x] ~~Add information on standard error responses for unknown endpoints/methods. (#1347)~~
    • [x] Add /timestamp_to_event/<roomID> endpoint, as per MSC3030. (#1366) #1427

    Spec Clarifications

    • [x] ~~Include examples inline instead of using a reference for invite endpoint definitions. (#1349)~~
    • [x] ~~Fix POST _matrix/federation/v1/user/keys/claim response schema. (#1351)~~
    • [x] ~~Correct the default invite level definition in the “Checks performed on receipt of a PDU” section. (#1371)~~
    • [x] ~~Clarify that CNAMEs are permissible for server names. (#1376)~~
    • [x] ~~Fix edu_type in EDU examples. (#1383)~~

    1.3 Application Service API

    Backwards Compatible Changes

    • [x] ~~Add information on standard error responses for unknown endpoints/methods. (#1347)~~

    1.4 Identity Service API

    Backwards Compatible Changes

    • [x] ~~Add information on standard error responses for unknown endpoints/methods. (#1347)~~

    1.5 Push Gateway API

    Backwards Compatible Changes

    • [x] ~~Add information on standard error responses for unknown endpoints/methods. (#1347)~~

    1.6 Room Versions

    No significant changes.

    1.7 Appendices

    No significant changes.

    effort/medium type/spec coverage 
    opened by zecakeh 0
Releases(ruma-common-0.10.5)
  • ruma-common-0.10.5(Oct 18, 2022)

  • ruma-client-api-0.15.3(Oct 18, 2022)

  • ruma-common-0.10.4(Oct 17, 2022)

  • ruma-client-api-0.15.2(Oct 17, 2022)

  • ruma-client-api-0.15.1(Sep 21, 2022)

    Improvements:

    • DeviceLists has moved from sync::sync_events::v3 to sync::sync_events
      • It is still available under the old location for backwards compatibility
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.7.4(Sep 21, 2022)

  • ruma-common-0.10.3(Sep 16, 2022)

  • ruma-common-0.10.2(Sep 16, 2022)

    Improvements:

    • Add relations accessors to event enum types:
      • AnyMessageLikeEvent and AnySyncMessageLikeEvent
      • AnyStateEvent and AnySyncStateEvent
      • AnyTimelineEvent and AnySyncTimelineEvent
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.7.3(Sep 16, 2022)

  • ruma-0.7.2(Sep 16, 2022)

  • ruma-common-0.10.1(Sep 14, 2022)

  • ruma-0.7.1(Sep 14, 2022)

  • ruma-state-res-0.8.0(Sep 12, 2022)

  • ruma-signatures-0.12.0(Sep 12, 2022)

  • ruma-push-gateway-api-0.6.0(Sep 12, 2022)

  • ruma-identity-service-api-0.6.0(Sep 12, 2022)

  • ruma-federation-api-0.6.0(Sep 12, 2022)

  • ruma-common-0.10.0(Sep 12, 2022)

    Bug fixes:

    Breaking changes:

    • Add user_id field to PushConditionRoomCtx
    • Remove PartialEq implementation on NotificationPowerLevels
    • Remove PartialEq implementation for events::call::SessionDescription
    • Use new events::call::AnswerSessionDescription for CallAnswerEventContent and OfferSessionDescription for CallInviteEventContent
    • Use new VoipVersionId and VoipId types for events::call events
    • Remove RoomName / OwnedRoomName and replace usages with str / String
    • Remove RoomMessageFeedbackEvent and associated types and variants according to MSC3582
    • Move CanonicalJson, CanonicalJsonObject and CanonicalJsonError out of the serde module and behind the cargo feature flag canonical-json
    • Make identifiers matrix URI constructors generic over owned parameters
      • Split RoomId matrix URI constructors between methods with and without routing
    • Allow to add routing servers to RoomId::matrix_to_event_uri()
    • Move receipt::ReceiptType to events::receipt
    • Make Clone as supertrait of api::OutgoingRequest
    • Rename Any[Sync]RoomEvent to Any[Sync]TimelineEvent
    • RoomMemberEvent and related types now have a custom unsigned type including the invite_room_state field, instead of the StateUnsigned type used by other state events

    Improvements:

    • All push rules are now considered to not apply to events sent by the user themselves
    • Change events::relation::BundledAnnotation to a struct instead of an enum
      • Remove BundledReaction
    • Add unstable support for polls (MSC3381)
    • Add unstable support for Improved Signalling for 1:1 VoIP (MSC2746)
    • Add support for knocking in events::room::member::MembershipChange
    • Add MatrixVersion::V1_3
    • Deprecate the sender_key and device_id fields for encrypted events (MSC3700)
    • Move the relations field of events::unsigned types out of unstable-msc2675
    • Deserialize stringified integers for power levels without the compat feature
    • Add JoinRule::KnockRestricted (MSC3787)
    • Add MatrixVersionId::V10 (MSC3604)
    • Add methods to sanitize messages according to the spec behind the unstable-sanitize feature
      • Can also remove rich reply fallbacks
    • Implement From<Owned*Id> for identifiers::matrix_uri::MatrixId
    • Add unstable default push rule to ignore room server ACLs events (MSC3786)
    • Add unstable support for private read receipts (MSC2285)
    • Add unstable support for filtering public rooms by room type (MSC3827)
    Source code(tar.gz)
    Source code(zip)
  • ruma-client-api-0.15.0(Sep 12, 2022)

    Breaking changes:

    • Export nothing from the crate if neither the client nor the server feature is active
      • This may partially be reverted in subsequent releases
    • UnreadNotificationsCount has moved from sync::sync_events::v3 to sync::sync_events
    • Remove PartialEq implementations for a number of types
      • If the lack of such an impl causes problems, please open a GitHub issue
    • Split uiaa::UserIdentifier::ThirdParty into two separate variants
    • Remove the from parameter from message::get_message_events::v3::Request's constructors
      • This affects new, backward and forward
      • Since backward and forward are equivalent to from_end and from_start, those are removed
      • A new method .from() was added to easily set this field after initial construction
    • receipt::create_receipt uses its own ReceiptType
    • Reorder parameters in {set_global_account_data, set_room_account_data}::Request::{new, new_raw}

    Improvements:

    • Add support for refresh tokens (MSC2918)
    • Add ErrorKind::{UnableToAuthorizeJoin, UnableToGrantJoin} encountered for restricted rooms
    • Add support for timestamp massaging (MSC3316)
    • Add support for querying relating events (MSC2675)
    • Move filter::RelationType to ruma_common::events::relations
    • Add unstable support for discovering an OpenID Connect server (MSC2965)
    • Add SpaceRoomJoinRule::KnockRestricted (MSC3787)
    • Add unstable support for private read receipts (MSC2285)
    • Add unstable support for API scope restriction (MSC2967)
    Source code(tar.gz)
    Source code(zip)
  • ruma-client-0.10.0(Sep 12, 2022)

  • ruma-appservice-api-0.7.0(Sep 12, 2022)

    Breaking changes:

    • Remove PartialEq implementation for Namespace
    • Remove push_events::v1::IncomingRequest::try_into_sync_response and the helper Cargo feature that was gating it
      • This API is no longer being used by the only known consumer
      • If you were using it, please let us know!
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.7.0(Sep 12, 2022)

  • ruma-common-0.9.3(Jun 1, 2022)

    Bug fixes:

    • Fix rich reply fallback generated by the convenience methods of RoomMessageEventContent
      • Fixes an incompatibility with Element Web
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.6.4(Jun 1, 2022)

    Bug fixes:

    • Fix rich reply fallback generated by the convenience methods of RoomMessageEventContent
      • Fixes an incompatibility with Element Web
    Source code(tar.gz)
    Source code(zip)
  • ruma-client-api-0.14.1(May 12, 2022)

  • ruma-0.6.3(May 12, 2022)

    Bug fixes:

    • Fix serialization and deserialization of events with a dynamic event_type

    Improvements:

    • Add From<&UserId> and From<&OwnedUserId> implementations for UserIdentifier
    • Add UserIdentifier::email constructor
    Source code(tar.gz)
    Source code(zip)
  • ruma-common-0.9.2(May 9, 2022)

  • ruma-common-0.9.1(May 6, 2022)

    Improvements:

    • Add StrippedPowerLevelsEvent::power_levels
    • Add (Sync)RoomMemberEvent::membership
    • Export events::room::member::Change
      • Prior to this, you couldn't actually do anything with the membership_change functions on various member event types
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.6.2(May 6, 2022)

    Improvements:

    • Add StrippedPowerLevelsEvent::power_levels
    • Add (Sync)RoomMemberEvent::membership
    • Export events::room::member::Change
      • Prior to this, you couldn't actually do anything with the membership_change functions on various member event types
    Source code(tar.gz)
    Source code(zip)
  • ruma-0.6.1(Apr 29, 2022)

Owner
Ruma
Your home in Matrix.
Ruma
A Matrix Server Stats bot

A bot running trough the matrix network to find all rooms.

Marcel 14 Dec 8, 2021
Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions.

Synthetic Network Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions. Dependenc

Daily 58 Dec 15, 2022
Examples of interacting with a Polkadot node using Rust

Examples of interacting with a Polkadot node Some examples of using JSON RPC to interact with a Polkadot node, working up to manually building and sub

Parity Technologies 15 Dec 21, 2022
A telnet chat server written in Rust, running on Lunatic.

Lunatic.chat A telnet chat server written in Rust, running on Lunatic. If you just would like to try it out, join the hosted version with: # US server

Lunatic 101 Jan 2, 2023
Basic chat example to demonstrate I/O and other rust features.

Basic chat Provides basic chat functions: create room send messages to room fetch room's messages Components STP - custom string transfer protocol lib

f3kilo 8 Jul 21, 2022
A Markov chain based Discord chat bot.

A Markov chain based Discord chat bot. Building It is recommended to use cargo.

Dominik Miedziński 1 Dec 26, 2021
Super simple tokio chat server for educational purposes.

achat A collection of simple modules which showcase simple use of tasks, channels, and other tokio primitives to implement simple networking applicati

Rafael Bachmann 2 Dec 29, 2022
An example of a common Wi-Fi set up scenario on ESP32 using Rust

UTC IoT fetcher This repo is an example of how to configure a Wi-Fi client on an ESP32-based IoT device using an external device connection to the int

Max Wase 4 Jan 19, 2023
A set of cryptographic primitives for building a multi-hop Proxy Re-encryption scheme, known as Transform Encryption.

recrypt A pure-Rust library that implements a set of cryptographic primitives for building a multi-hop Proxy Re-encryption scheme, known as Transform

IronCore Labs 122 Dec 30, 2022
Network simulation in Rust

netsim - A Rust library for network simulation and testing (currently linux-only). netsim is a crate for simulating networks for the sake of testing n

Andrew Cann 115 Dec 15, 2022
A Rust library for parsing the SOME/IP network protocol (without payload interpretation).

someip_parse A Rust library for parsing the SOME/IP network protocol (without payload interpretation). Usage Add the following to your Cargo.toml: [de

Julian Schmid 18 Oct 31, 2022
Common Rust Lightning Network types

Common Rust Lightning Network types Warning: while in a good state, this is still considered a preview version! There are some planned changes. This l

Martin Habovštiak 5 Nov 8, 2022
Network Block Storage server, written in Rust. Supports pluggable and chainable underlying storage

nbd-rs Disclaimer DO NEVER USE THIS FOR PRODUCTION Do not use this for any data that you cannot afford to lose any moment. Expect data loss, corruptio

Rainlab Inc 10 Sep 30, 2022
Reliable p2p network connections in Rust with NAT traversal

Reliable p2p network connections in Rust with NAT traversal. One of the most needed libraries for any server-less / decentralised projects

MaidSafe-Archive 948 Dec 20, 2022
Reliable p2p network connections in Rust with NAT traversal

Reliable p2p network connections in Rust with NAT traversal. One of the most needed libraries for any server-less, decentralised project.

MaidSafe-Archive 948 Dec 20, 2022
The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust.

netns-rs The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust. Changing namespaces requires elevated privileg

OpenAnolis Community 7 Dec 15, 2022
A private network system that uses WireGuard under the hood.

innernet A private network system that uses WireGuard under the hood. See the announcement blog post for a longer-winded explanation. innernet is simi

Tonari, Inc 4.1k Dec 29, 2022
A Curve-like AMM for Secret Network

A Curve-like AMM for Secret Network. Supports a varibale number of tokens with the same underlying value.

Enigma 16 Dec 11, 2022
A multi-protocol network relay

A multi-protocol network relay

zephyr 43 Dec 13, 2022