Class AuthRules
The authorization rules of room versions 10, 11 and 12: whether an event is allowed given the state it depends on.
Inherited Members
Namespace: Uniform.Matrix.Protocol.Server
Assembly: Uniform.Matrix.Protocol.Server.dll
Syntax
public static class AuthRules
Remarks
The caller supplies the state: an event's auth_events when receiving it, or the room's current state when creating it. State events carry their event_id, which v4+ event formats otherwise leave out, as the creator's first join is checked against the create event's ID. Rule numbers follow the spec.
Methods
| Edit this page View SourceCheck(JsonObject, RoomVersion, IReadOnlyDictionary<(string Type, string StateKey), JsonObject>, Func<JsonObject, string, bool>?)
Return null when pdu is allowed, or why it is rejected.
Declaration
public static string? Check(JsonObject pdu, RoomVersion version, IReadOnlyDictionary<(string Type, string StateKey), JsonObject> state, Func<JsonObject, string, bool>? isSignedByServer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | pdu | The event. |
| RoomVersion | version | Room version. |
| IReadOnlyDictionary<(string Type, string StateKey), JsonObject> | state | Auth state by type and state key. |
| Func<JsonObject, string, bool> | isSignedByServer | Returns whether the event is validly signed by a server, for restricted joins. |
Returns
| Type | Description |
|---|---|
| string |
CheckAuthChains(RoomVersion, IReadOnlyDictionary<string, JsonObject>)
Return the IDs of events that the rules allow against their own auth_events, each of which must be among them and allowed too; for state and auth chains received from another server, whose signatures were checked.
Declaration
public static HashSet<string> CheckAuthChains(RoomVersion version, IReadOnlyDictionary<string, JsonObject> events)
Parameters
| Type | Name | Description |
|---|---|---|
| RoomVersion | version | Room version. |
| IReadOnlyDictionary<string, JsonObject> | events | Events by ID, without |
Returns
| Type | Description |
|---|---|
| HashSet<string> |
Creators(JsonObject)
Return the creators of a version 12 room: the create event's sender and its additional_creators.
Declaration
public static IReadOnlyCollection<string> Creators(JsonObject create)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | create |
Returns
| Type | Description |
|---|---|
| IReadOnlyCollection<string> |