Categorygithub.com/ReidAnderson/gomatrixserverlib
modulepackage
0.0.0-20210115060137-7ba798a1ded2
Repository: https://github.com/reidanderson/gomatrixserverlib.git
Documentation: pkg.go.dev

# README

gomatrixserverlib

GoDoc

Go library for common functions needed by matrix servers. This library assumes Go 1.10+.

# Packages

No description provided by the author

# Functions

Allowed checks whether an event is allowed by the auth events.
AsTimestamp turns a time.Time into a millisecond posix timestamp.
CanonicalJSON re-encodes the JSON in a canonical encoding.
CanonicalJSONAssumeValid is the same as CanonicalJSON, but assumes the input is valid JSON.
CheckKeys checks the keys returned from a server to make sure they are valid.
CompactJSON makes the encoded JSON as small as possible by removing whitespace and unneeded unicode escapes.
DefaultEventFilter returns the default event filter used by the Matrix server if no filter is provided in the request.
DefaultFilter returns the default filter used by the Matrix server if no filter is provided in the request.
DefaultRoomEventFilter returns the default room event filter used by the Matrix server if no filter is provided in the request.
DefaultStateFilter returns the default state event filter used by the Matrix server if no filter is provided in the request.
Returns a gomatrixserverlib.BadJSONError if the canonical JSON fails enforced checks or if JSON validation fails.
HeaderedReverseTopologicalOrdering takes a set of input events and sorts them using Kahn's algorithm in order to topologically order them.
ToClientEvent converts a single server event to a client event.
ToClientEvents converts server events to client events.
IsValidCertificate checks if the given x509 certificate can be verified using system root CAs and an optional pool of intermediate CAs.
ListKeyIDs lists the key IDs a given entity has signed a message with.
LookupWellKnown looks up a well-known record for a matrix server.
NewAuthEvents returns an AuthEventProvider backed by the given events.
NewClient makes a new Client (with default timeout).
NewClientWithTieout makes a new Client (with specified timeout).
NewClientWithTransport makes a new Client with an existing transport.
NewClientWithTransportTimeout makes a new Client with a specified request timeout.
NewCreateContentFromAuthEvents loads the create event content from the create event in the auth events.
NewEventFromTrustedJSON loads a new event from some JSON that must be valid.
NewEventFromTrustedJSONWithEventID loads a new event from some JSON that must be valid and that the event ID is already known.
NewEventFromUntrustedJSON loads a new event from some JSON that may be invalid.
NewEventsLoader returns a new events loader.
NewFederationClient makes a new FederationClient.
NewFederationClientWithTimeout makes a new FederationClient.
NewFederationClientWithTransport makes a new FederationClient with a custom transport.
NewFederationRequest creates a matrix request.
No description provided by the author
NewInviteV2StrippedState creates a stripped state event from a regular state event.
NewJoinRuleContentFromAuthEvents loads the join rule content from the join rules event in the auth event.
NewMemberContentFromAuthEvents loads the member content from the member event for the user ID in the auth events.
NewMemberContentFromEvent parse the member content from an event.
NewMSC2836EventRelationshipsRequest creates a new MSC2836 /event_relationships request with defaults set.
NewPowerLevelContentFromAuthEvents loads the power level content from the power level event in the auth events or returns the default values if there is no power level event.
NewPowerLevelContentFromEvent loads the power level content from an event.
NewThirdPartyInviteContentFromAuthEvents loads the third party invite content from the third party invite event for the state key (token) in the auth events.
ParseAndValidateServerName splits a ServerName into a host and port part, and checks that it is a valid server name according to the spec.
RawJSONFromResult extracts the raw JSON bytes pointed to by result.
RequestBackfill implements the server logic for making backfill requests to other servers.
ResolveConflicts performs state resolution on the input events, returning the resolved state.
ResolveServer implements the server name resolution algorithm described at https://matrix.org/docs/spec/server_server/r0.1.1.html#resolving-server-names Returns a slice of ResolutionResult that can be used to send a federation request to the server using a given server name.
ResolveStateConflicts takes a list of state events with conflicting state keys and works out which event should be used for each state event.
ResolveStateConflicts takes a list of state events with conflicting state keys and works out which event should be used for each state event.
ReverseTopologicalOrdering takes a set of input events and sorts them using Kahn's algorithm in order to topologically order them.
RoomVersions returns information about room versions currently implemented by this commit of gomatrixserverlib.
SignJSON signs a JSON object returning a copy signed with the given key.
SortJSON reencodes the JSON with the object keys sorted by lexicographically by codepoint.
SplitID splits a matrix ID into a local part and a server name.
StableRoomVersions returns a map of descriptions for room versions that are marked as stable.
StateNeededForAuth returns the event types and state_keys needed to authenticate an event.
StateNeededForEventBuilder returns the event types and state_keys needed to authenticate the event being built.
SupportedRoomVersions returns a map of descriptions for room versions that are marked as supported.
ToClientEvent converts a single server event to a client event.
ToClientEvents converts server events to client events.
UnwrapEventHeaders unwraps an array of headered events.
VerifyAllEventSignatures checks that each event in a list of events has valid signatures from the server that sent it.
VerifyAuthRulesAtState will check that the auth_events in the given event are valid at the state of the room before that event.
VerifyEventAuthChain will verify that the event is allowed according to its auth_events, and then recursively verify each of those auth_events.
VerifyEventSignatures checks that each event in a list of events has valid signatures from the server that sent it.
VerifyHTTPRequest extracts and verifies the contents of a net/http.Request.
VerifyJSON checks that the entity has signed the message using a particular key.

# Constants

Ban is the string constant "ban".
prev_events and auth_events as event references.
prev_events and auth_events as string array of event IDs.
randomised.
base64-encoded hash of event.
URL-safe base64-encoded hash of event.
Event validation errors.
FormatAll will include all client event keys.
FormatSync will include only the event keys required by the /sync API.
Invite is the string constant "invite".
Join is the string constant "join".
Leave is the string constant "leave".
MDeviceListUpdate https://matrix.org/docs/spec/server_server/latest#m-device-list-update-schema.
MDirectToDevice https://matrix.org/docs/spec/server_server/r0.1.3#send-to-device-messaging.
MReceipt https://matrix.org/docs/spec/server_server/r0.1.4#receipts.
MRoomAliases https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-aliases.
MRoomCanonicalAlias https://matrix.org/docs/spec/client_server/r0.6.0#m-room-canonical-alias.
MRoomCreate https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-create.
MRoomHistoryVisibility https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-history-visibility.
MRoomJoinRules https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-join-rules.
MRoomMember https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-member.
MRoomName https://matrix.org/docs/spec/client_server/r0.6.0#m-room-name.
MRoomPowerLevels https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-power-levels.
MRoomRedaction https://matrix.org/docs/spec/client_server/r0.2.0.html#id21.
MRoomThirdPartyInvite https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-third-party-invite.
MTyping https://matrix.org/docs/spec/client_server/r0.3.0.html#m-typing.
NOTSPEC: Peek is the string constant "peek" (MSC2753, used as the label in the sync block).
Public is the string constant "public".
PublicKeyNotExpired is a magic value for PublicKeyLookupResult.ExpiredTS: it indicates that this is an active key which has not yet expired.
PublicKeyNotValid is a magic value for PublicKeyLookupResult.ValidUntilTS: it is used when we don't have a validity period for this key.
default algorithm.
no special meaning for m.room.aliases.
Room version constants.
Room version constants.
Room version constants.
Room version constants.
Room version constants.
Room version constants.
state resolution v1.
state resolution v2.
Sort events by prev_events or auth_events.
Sort events by prev_events or auth_events.

# Variables

No description provided by the author

# Structs

ApplicationServiceTransaction is the transaction that is sent off to an application service.
AuthEvents is an implementation of AuthEventProvider backed by a map.
No description provided by the author
A Client makes request to the federation listeners of matrix homeservers.
ClientEvent is an event which is fit for consumption by clients, in accordance with the specification.
CreateContent is the JSON content of a m.room.create event along with the top level keys needed for auth.
DeviceKeys as per https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query.
DeviceListUpdateEvent is https://matrix.org/docs/spec/server_server/latest#m-device-list-update-schema.
A DirectKeyFetcher fetches keys directly from a server.
Ed25519Checks are the checks that are applied to Ed25519 keys in ServerKey responses.
EDU represents a EDU received via federation https://matrix.org/docs/spec/server_server/unstable.html#edus.
An Event is a matrix event.
An EventBuilder is used to build a new event.
EventFilter is used to define filtering rules for events.
HeaderedEventHeader contains header fields for an event that contains additional metadata, e.g.
EventLoadResult is the result of loading and verifying an event in the EventsLoader.
An EventReference is a reference to a matrix event.
EventsLoader loads untrusted events and verifies them.
EventValidationError is returned if there is a problem validating an event.
FederatedStateProvider is an implementation of StateProvider which solely uses federation requests to retrieve events.
A FederationClient is a matrix federation client that adds "Authorization: X-Matrix" headers to requests that need ed25519 signatures.
A FederationRequest is a request to send to a remote server or a request received from a remote server.
Filter is used by clients to specify how the server should filter responses to e.g.
HeaderedEvent is a wrapper around an Event that contains information about the room version.
HistoryVisibilityContent is the JSON content of a m.room.history_visibility event.
InviteV2Request is used in the body of a /_matrix/federation/v2/invite request.
InviteV2StrippedState is a cut-down set of fields from room state events that allow the invited server to identify the room.
JoinRuleContent is the JSON content of a m.room.join_rules event needed for auth checks.
KeyChecks are the checks that should be applied to ServerKey responses.
A KeyRing stores keys for matrix servers and provides methods for verifying JSON messages.
MemberContent is the JSON content of a m.room.member event needed for auth checks.
MemberThirdPartyInvite is the "Invite" structure defined at http://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-member.
MemberThirdPartyInviteSigned is the "signed" structure defined at http://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-member.
MissingAuthEventError refers to a situation where one of the auth event for a given event was not found.
MissingEvents represents a request for missing events.
MSC2836EventRelationshipsRequest is a request to /event_relationships from https://github.com/matrix-org/matrix-doc/blob/kegan/msc/threading/proposals/2836-threading.md.
MSC2836EventRelationshipsResponse is a response to /event_relationships from https://github.com/matrix-org/matrix-doc/blob/kegan/msc/threading/proposals/2836-threading.md.
A NotAllowed error is returned if an event does not pass the auth checks.
An OldVerifyKey is an old ed25519 public key that is no longer valid.
A PDUResult is the result of processing a matrix room event.
A PerspectiveKeyFetcher fetches server keys from a single perspective server.
PowerLevelContent is the JSON content of a m.room.power_levels event needed for auth checks.
PreviousRoom is the "Previous Room" structure defined at https://matrix.org/docs/spec/client_server/r0.5.0#m-room-create.
PublicKey is the "PublicKeys" structure defined at https://matrix.org/docs/spec/client_server/r0.5.0#m-room-third-party-invite.
A PublicKeyLookupRequest is a request for a public key with a particular key ID.
A PublicKeyLookupResult is the result of looking up a server signing key.
No description provided by the author
No description provided by the author
PublicRoom stores the info of a room returned by GET /_matrix/federation/v1/publicRooms.
ResolutionResult is a result of looking up a Matrix homeserver according to the federation specification.
RespClaimKeys is the response for https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-claim.
A RespDirectory is the content of a response to GET /_matrix/federation/v1/query/directory This is returned when looking up a room alias from a remote server.
A RespEventAuth is the content of a response to GET /_matrix/federation/v1/event_auth/{roomID}/{eventID}.
RespInvite is the content of a response to PUT /_matrix/federation/v1/invite/{roomID}/{eventID}.
RespInvite is the content of a response to PUT /_matrix/federation/v2/invite/{roomID}/{eventID}.
A RespMakeJoin is the content of a response to GET /_matrix/federation/v2/make_join/{roomID}/{userID}.
A RespMakeLeave is the content of a response to GET /_matrix/federation/v2/make_leave/{roomID}/{userID}.
A RespMissingEvents is the content of a response to GET /_matrix/federation/v1/get_missing_events/{roomID}.
A RespPeek is the content of a response to GET /_matrix/federation/v1/peek/{roomID}/{peekID}.
RespProfile is the content of a response to GET /_matrix/federation/v1/query/profile.
RespPublicRooms is the content of a response to GET /_matrix/federation/v1/publicRooms.
RespQueryKeys is the response for https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query.
A RespSend is the content of a response to PUT /_matrix/federation/v1/send/{txnID}/.
A RespSendJoin is the content of a response to PUT /_matrix/federation/v2/send_join/{roomID}/{eventID}.
A RespState is the content of a response to GET /_matrix/federation/v1/state/{roomID}/{eventID}.
A RespStateIDs is the content of a response to GET /_matrix/federation/v1/state_ids/{roomID}/{eventID}.
RespUserDevice are embedded in RespUserDevices https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid.
RespUserDeviceKeys are embedded in RespUserDevice https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid.
RespUserDevices contains a response to /_matrix/federation/v1/user/devices/{userID} https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid.
RoomEventFilter is used to define filtering rules for events in rooms.
RoomFilter is used to define filtering rules for room-related events.
RoomVersionDescription contains information about a given room version, e.g.
SelfDestructContent is the JSON content of a org.matrix.self_destruct and org.matrix.self_destruct_after event.
No description provided by the author
ServerKeyFields are the parsed JSON contents of the ed25519 signing keys published by a matrix server.
ServerKeys are the ed25519 signing keys published by a matrix server.
StateFilter is used to define filtering rules for state events.
A StateKeyTuple is the combination of an event type and an event state key.
StateNeeded lists the event types and state_keys needed to authenticate an event.
ThirdPartyInviteContent is the JSON content of a m.room.third_party_invite event needed for auth checks.
No description provided by the author
A Transaction is used to push data from one matrix server to another matrix server.
No description provided by the author
UnsupportedRoomVersionError occurs when a call has been made with a room version that is not supported by this version of gomatrixserverlib.
UserInfo represents information about a user.
A VerifyJSONRequest is a request to check for a signature on a JSON message.
A VerifyJSONResult is the result of checking the signature of a JSON message.
A VerifyKey is a ed25519 public key for a server.
A Version is a struct that matches the version response from a Matrix homeserver.
WellKnownResult is the result of looking up a matrix server's well-known file.

# Interfaces

AuthEventProvider provides auth_events for the authentication checks.
BackfillClient contains the necessary functions from the federation client to perform a backfill request from another homeserver.
BackfillRequester contains the necessary functions to perform backfill requests from one server to another.
No description provided by the author
A JSONVerifier is an object which can verify the signatures of JSON messages.
No description provided by the author
A KeyDatabase is a store for caching public keys.
A KeyFetcher is a way of fetching public keys in bulk.
StateProvider is capable of returning the room state at any point in time.

# Type aliases

AuthChainProvider returns the requested list of auth events.
A Base64Bytes is a string of bytes (not base64 encoded) that are base64 encoded when used in JSON.
No description provided by the author
EventFormat refers to the formatting of the event fields struct.
EventIDFormat refers to the formatting used to generate new event IDs.
A HexString is a string of bytes that are hex encoded when used in JSON.
A KeyID is the ID of a ed25519 key used to sign JSON.
RawJSON is a reimplementation of json.RawMessage that supports being used as a value type For example: jsonBytes, _ := json.Marshal(struct{ RawMessage json.RawMessage RawJSON RawJSON }{ json.RawMessage(`"Hello"`), RawJSON(`"World"`), }) Results in: {"RawMessage":"IkhlbGxvIg==","RawJSON":"World"} See https://play.golang.org/p/FzhKIJP8-I for a full example.
RedactionAlgorithm refers to the redaction algorithm used in a room version.
RoomVersion refers to the room version for a specific room.
A ServerName is the name a matrix homeserver is identified by.
StateResAlgorithm refers to a version of the state resolution algorithm.
A Timestamp is a millisecond posix timestamp.
TopologicalOrder represents how to sort a list of events, used primarily in ReverseTopologicalOrdering.
A TransactionID identifies a transaction sent by a matrix server to another matrix server.