Documentation
¶
Index ¶
- func SendToDeviceRoomID(key olm.Curve25519) mat.RoomID
- func SplitAlgorithmKeyID(algorithmKeyID string) (string, string)
- type Ciphertext
- type Client
- func (cli *Client) DeviceKeysUpload() error
- func (cli *Client) SendImage(roomID, body, url string) (*mat.RespSendEvent, error)
- func (cli *Client) SendMegolmOutKey(device *Device, roomID mat.RoomID, session *olm.OutboundGroupSession) error
- func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON interface{}) (*mat.RespSendEvent, error)
- func (cli *Client) SendNotice(roomID, text string) (*mat.RespSendEvent, error)
- func (cli *Client) SendText(roomID, text string) (*mat.RespSendEvent, error)
- func (cli *Client) SendVideo(roomID, body, url string) (*mat.RespSendEvent, error)
- func (cli *Client) SetRoomEncryption(roomID string, encryptionAlg olm.Algorithm) error
- func (cli *Client) SetRoomEncryptionMegolm(roomID string) error
- func (cli *Client) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence string) (resp *RespSync, err error)
- func (cli *Client) UserDevice(userID mat.UserID, deviceKey olm.Curve25519) (*Device, error)
- func (cli *Client) UserDevices(userID mat.UserID) (*UserDevices, error)
- type Container
- func (c *Container) Close()
- func (c *Container) ForEachRoom(fn func(rID mat.RoomID, r *Room) error) (err error)
- func (c *Container) ForEachUser(fn func(uID mat.UserID, ud *UserDevices) error) (err error)
- func (c *Container) NewRoom(roomID mat.RoomID) *Room
- func (c *Container) Room(roomID mat.RoomID) (room *Room)
- type ContentRoomMember
- type CryptoDB
- func (cdb *CryptoDB) AddMyUserMyDevice(userID mat.UserID, deviceID mat.DeviceID) error
- func (cdb *CryptoDB) AddUser(userID mat.UserID) error
- func (cdb *CryptoDB) AddUserDevice(userID mat.UserID, deviceID mat.DeviceID) error
- func (cdb *CryptoDB) Close()
- func (cdb *CryptoDB) ExistsOlmAccount(userID mat.UserID, deviceID mat.DeviceID) bool
- func (cdb *CryptoDB) LoadAllUserDevices() (map[mat.UserID]*UserDevices, error)
- func (cdb *CryptoDB) LoadMapSessionsID() (*RoomsSessionsID, error)
- func (cdb *CryptoDB) LoadMyUserDevice(userID mat.UserID) (*MyUserDevice, error)
- func (cdb *CryptoDB) LoadRooms() (map[mat.RoomID]*Room, error)
- func (cdb *CryptoDB) SetSharedMegolmOutKey(userID mat.UserID, deviceID mat.DeviceID, sessionID olm.SessionID) error
- func (cdb *CryptoDB) StoreMegolmInSession(userID mat.UserID, deviceID mat.DeviceID, ...) error
- func (cdb *CryptoDB) StoreMegolmInSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519, ...) error
- func (cdb *CryptoDB) StoreMegolmOutSession(userID mat.UserID, deviceID mat.DeviceID, ...) error
- func (cdb *CryptoDB) StoreOlmAccount(userID mat.UserID, deviceID mat.DeviceID, olmAccount *olm.Account) error
- func (cdb *CryptoDB) StoreOlmSession(userID mat.UserID, deviceID mat.DeviceID, olmSession *olm.Session) error
- func (cdb *CryptoDB) StoreOlmSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519, ...) error
- func (cdb *CryptoDB) StorePubKeys(userID mat.UserID, deviceID mat.DeviceID, ed25519 olm.Ed25519, ...) error
- func (cdb *CryptoDB) StoreRoomEncryptionAlg(roomID mat.RoomID, encryptionAlg olm.Algorithm) error
- type Databaser
- type DecryptedEvent
- type Device
- type Event
- type Logger
- type MegolmMsg
- type Membership
- type MyDevice
- type MyUserDevice
- type OlmMsg
- type RespSync
- type Room
- type RoomKey
- type RoomsSessionsID
- type SendEncEventError
- type SendEncEventErrors
- type SendToDeviceEvent
- type SessionTriplet
- type SessionsID
- type SignedKey
- type User
- type UserDevices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendToDeviceRoomID ¶
func SendToDeviceRoomID(key olm.Curve25519) mat.RoomID
func SplitAlgorithmKeyID ¶
Types ¶
type Ciphertext ¶
TODO: Delete this
type Client ¶
func (*Client) DeviceKeysUpload ¶
TODO: Track how many unused keys are in the server, and find a mechanism to update them if necessary
func (*Client) SendImage ¶
func (cli *Client) SendImage(roomID, body, url string) (*mat.RespSendEvent, error)
SendImage sends an m.room.message event into the given room with a msgtype of m.image See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
func (*Client) SendMegolmOutKey ¶
func (*Client) SendMessageEvent ¶
func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON interface{}) (*mat.RespSendEvent, error)
SendMessageEvent sends a message event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendNotice ¶
func (cli *Client) SendNotice(roomID, text string) (*mat.RespSendEvent, error)
SendNotice sends an m.room.message event into the given room with a msgtype of m.notice See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice
func (*Client) SendText ¶
func (cli *Client) SendText(roomID, text string) (*mat.RespSendEvent, error)
SendText sends an m.room.message event into the given room with a msgtype of m.text See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text
func (*Client) SendVideo ¶
func (cli *Client) SendVideo(roomID, body, url string) (*mat.RespSendEvent, error)
SendVideo sends an m.room.message event into the given room with a msgtype of m.video See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-video
func (*Client) SetRoomEncryption ¶
SetRoomEncryption sends the event to set the encryption Algorithm of the room and sets it in the internal state.
func (*Client) SetRoomEncryptionMegolm ¶
SetRoomEncryptionMegolm calls SetRoomEncryption with the Megolm algorithm, which is the most common one for rooms.
func (*Client) SyncRequest ¶
func (cli *Client) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence string) (resp *RespSync, err error)
SyncRequest makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync
func (*Client) UserDevice ¶
func (*Client) UserDevices ¶
func (cli *Client) UserDevices(userID mat.UserID) (*UserDevices, error)
type Container ¶
type Container struct {
Me *MyUserDevice
// contains filtered or unexported fields
}
Container contains data structures that are completely or partly permanent (backed by a data base).
func LoadContainer ¶
LoadContainer loads the Container datastructure. It sets up the database and loads its contents into the rest of the datastructure.
func (*Container) ForEachRoom ¶
func (*Container) ForEachUser ¶
type ContentRoomMember ¶
type CryptoDB ¶
type CryptoDB struct {
// contains filtered or unexported fields
}
func OpenCryptoDB ¶
OpenCryptoDB opens the DB and initializes the /crypto bucket if necessary
func (*CryptoDB) AddMyUserMyDevice ¶
AddMyUserMyDevice adds /crypto_me/<userID>/<deviceID>/megolm_out/ buckets
func (*CryptoDB) AddUserDevice ¶
AddUserDevice adds /crypto_users/<userID>/devices/<deviceID>/{olm,megolm_in,shared_megolm}/ buckets
func (*CryptoDB) ExistsOlmAccount ¶
ExistsOlmAccount checks if an olm.Account exists at /crypto_me/<userID>/<deviceID>/
func (*CryptoDB) LoadAllUserDevices ¶
func (cdb *CryptoDB) LoadAllUserDevices() (map[mat.UserID]*UserDevices, error)
LoadAllUserDevices loads all the UserDevices from /crypto_users/
func (*CryptoDB) LoadMapSessionsID ¶
func (cdb *CryptoDB) LoadMapSessionsID() (*RoomsSessionsID, error)
LoadMapSessionsID loads all the RoomsSessionsID at /crypto_sessions_id/
func (*CryptoDB) LoadMyUserDevice ¶
func (cdb *CryptoDB) LoadMyUserDevice(userID mat.UserID) (*MyUserDevice, error)
LoadMyUserDevice loads the MyUserDevice at /crypto_me/<userID>/
func (*CryptoDB) SetSharedMegolmOutKey ¶
func (*CryptoDB) StoreMegolmInSession ¶
func (cdb *CryptoDB) StoreMegolmInSession(userID mat.UserID, deviceID mat.DeviceID, megolmInSession *olm.InboundGroupSession) error
StoreMegolmInSession stores an olm.InboundGroupSession at /crypto_users/<userID>/devices/<deviceID>/megolm_in/<megolmInSession.ID>
func (*CryptoDB) StoreMegolmInSessionID ¶
func (cdb *CryptoDB) StoreMegolmInSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519, sessionID olm.SessionID) error
StoreMegolmInSessionID stores an olm.Account at /crypto_sessions_id/SessionTriplet{roomID,userID,deviceID}/megolm_session_id
func (*CryptoDB) StoreMegolmOutSession ¶
func (cdb *CryptoDB) StoreMegolmOutSession(userID mat.UserID, deviceID mat.DeviceID, megolmOutSession *olm.OutboundGroupSession) error
StoreMegolmOutSession stores an olm.OutboundGroupSession at /crypto_me/<userID>/<deviceID>/megolm_out/<megolmOutSession.ID>
func (*CryptoDB) StoreOlmAccount ¶
func (cdb *CryptoDB) StoreOlmAccount(userID mat.UserID, deviceID mat.DeviceID, olmAccount *olm.Account) error
StoreOlmAccount stores an olm.Account at /crypto_me/<userID>/<deviceID>/
func (*CryptoDB) StoreOlmSession ¶
func (cdb *CryptoDB) StoreOlmSession(userID mat.UserID, deviceID mat.DeviceID, olmSession *olm.Session) error
StoreOlmSession stores an olm.Session at /crypto_users/<userID>/devices/<deviceID>/olm/<olmSession.ID>
func (*CryptoDB) StoreOlmSessionID ¶
func (cdb *CryptoDB) StoreOlmSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519, sessionID olm.SessionID) error
StoreOlmSessionID stores an olm SessionID at /crypto_sessions_id/SessionTriplet{roomID,userID,deviceID}/olm_session_id
type Databaser ¶
type Databaser interface {
Close()
AddUser(userID mat.UserID) error
AddUserDevice(userID mat.UserID, deviceID mat.DeviceID) error
AddMyUserMyDevice(userID mat.UserID, deviceID mat.DeviceID) error
StorePubKeys(userID mat.UserID, deviceID mat.DeviceID,
ed25519 olm.Ed25519, curve25519 olm.Curve25519) error
StoreOlmSession(userID mat.UserID, deviceID mat.DeviceID,
olmSession *olm.Session) error
StoreMegolmInSession(userID mat.UserID, deviceID mat.DeviceID,
megolmInSession *olm.InboundGroupSession) error
sessionID olm.SessionID) error
StoreMegolmOutSession(userID mat.UserID, deviceID mat.DeviceID,
megolmOutSession *olm.OutboundGroupSession) error
LoadAllUserDevices() (map[mat.UserID]*UserDevices, error)
LoadMyUserDevice(userID mat.UserID) (*MyUserDevice, error)
ExistsOlmAccount(userID mat.UserID, deviceID mat.DeviceID) bool
StoreOlmAccount(userID mat.UserID, deviceID mat.DeviceID, olmAccount *olm.Account) error
StoreOlmSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519,
sessionID olm.SessionID) error
StoreMegolmInSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519,
sessionID olm.SessionID) error
LoadMapSessionsID() (*RoomsSessionsID, error)
LoadRooms() (map[mat.RoomID]*Room, error)
StoreRoomEncryptionAlg(roomID mat.RoomID, encryptionAlg olm.Algorithm) error
}
type DecryptedEvent ¶
type Device ¶
type Device struct {
//OneTimeKey string // IdentityKey
OlmSessions map[olm.SessionID]*olm.Session
MegolmInSessions map[olm.SessionID]*olm.InboundGroupSession
// contains filtered or unexported fields
}
func (*Device) Curve25519 ¶
func (d *Device) Curve25519() olm.Curve25519
type Event ¶
type Event struct {
mat.Event
Decrypted *DecryptedEvent `json:"-"`
}
Event represents a single Matrix event.
type Membership ¶
type Membership int
const ( MemInvite Membership = iota MemJoin Membership = iota MemLeave Membership = iota MemBan Membership = iota MembershipLen Membership = iota )
type MyUserDevice ¶
type OlmMsg ¶
type OlmMsg struct {
Algorithm olm.Algorithm `json:"algorithm"`
SenderKey olm.Curve25519 `json:"sender_key"`
Ciphertext map[olm.Curve25519]struct {
Type olm.MsgType `json:"type"`
Body string `json:"body"`
} `json:"ciphertext"`
}
type RespSync ¶
type RespSync struct {
NextBatch string `json:"next_batch"`
AccountData struct {
Events []Event `json:"events"`
} `json:"account_data"`
Presence struct {
Events []Event `json:"events"`
} `json:"presence"`
Rooms struct {
Leave map[string]struct {
State struct {
Events []Event `json:"events"`
} `json:"state"`
Timeline struct {
Events []Event `json:"events"`
Limited bool `json:"limited"`
PrevBatch string `json:"prev_batch"`
} `json:"timeline"`
} `json:"leave"`
Join map[string]struct {
State struct {
Events []Event `json:"events"`
} `json:"state"`
Timeline struct {
Events []Event `json:"events"`
Limited bool `json:"limited"`
PrevBatch string `json:"prev_batch"`
} `json:"timeline"`
} `json:"join"`
Invite map[string]struct {
State struct {
Events []Event
} `json:"invite_state"`
} `json:"invite"`
} `json:"rooms"`
ToDevice struct {
Events []SendToDeviceEvent `json:"events"`
} `json:"to_device"`
}
RespSync is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
func (*Room) ForEachUser ¶
func (*Room) SetUserMembership ¶
func (r *Room) SetUserMembership(userID mat.UserID, mem Membership)
type RoomKey ¶
type RoomKey struct {
// OlmSenderKey is filled when this event is obtained through the
// decryption of an m.room.encrypted event.
OlmSenderKey olm.Curve25519
Algorithm olm.Algorithm `json:"algorithm"`
RoomID mat.RoomID `json:"room_id"`
SessionID olm.SessionID `json:"session_id"`
SessionKey string `json:"session_key"`
}
type RoomsSessionsID ¶
type RoomsSessionsID struct {
Sessions map[SessionTriplet]*SessionsID
}
RoomsSessionsID maps (RoomID, UserID, Curve25519) to (olmSessionID, megolmInSessionID)
func (*RoomsSessionsID) GetOlmSessionID ¶
func (rs *RoomsSessionsID) GetOlmSessionID(roomID mat.RoomID, userID mat.UserID, key olm.Curve25519) olm.SessionID
type SendEncEventError ¶
type SendEncEventError struct {
UserID mat.UserID
DeviceID mat.DeviceID
//Content interface{}
Err error
}
func (*SendEncEventError) Error ¶
func (err *SendEncEventError) Error() string
type SendEncEventErrors ¶
type SendEncEventErrors []SendEncEventError
func (SendEncEventErrors) Error ¶
func (errs SendEncEventErrors) Error() string
type SendToDeviceEvent ¶
type SendToDeviceEvent struct {
mat.SendToDeviceEvent
Decrypted *DecryptedEvent `json:"-"`
}
SendToDeviceEvent represents an event received through the send-to-device API: https://matrix.org/speculator/spec/drafts%2Fe2e/client_server/unstable.html#extensions-to-sync
type SessionTriplet ¶
type SessionsID ¶
type SessionsID struct {
// contains filtered or unexported fields
}
type SignedKey ¶
type SignedKey struct {
Key olm.Curve25519 `json:"key"`
Signatures map[string]map[string]string `json:"signatures"`
}
type UserDevices ¶
type UserDevices struct {
Devices map[olm.Curve25519]*Device
DevicesByID map[mat.DeviceID]*Device
// contains filtered or unexported fields
}
func NewUserDevices ¶
func NewUserDevices(userID mat.UserID) *UserDevices
func (*UserDevices) ForEach ¶
func (ud *UserDevices) ForEach(fn func(k olm.Curve25519, d *Device) error) (err error)
func (*UserDevices) ID ¶
func (ud *UserDevices) ID() mat.UserID