cryptohelper

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2024 License: MPL-2.0 Imports: 12 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSessionFound = crypto.NoSessionFound

Functions

This section is empty.

Types

type CryptoHelper

type CryptoHelper struct {
	DecryptErrorCallback func(*event.Event, error)

	LoginAs *mautrix.ReqLogin

	DBAccountID string
	// contains filtered or unexported fields
}

func NewCryptoHelper

func NewCryptoHelper(cli *mautrix.Client, pickleKey []byte, store any) (*CryptoHelper, error)

NewCryptoHelper creates a struct that helps a mautrix client struct with Matrix e2ee operations.

The client and pickle key are always required. Additionally, you must either: - Provide a crypto.Store here and set a StateStore in the client, or - Provide a dbutil.Database here to automatically create missing stores. - Provide a string here to use it as a path to a SQLite database, and then automatically create missing stores.

The same database may be shared across multiple clients, but note that doing that will allow all clients access to decryption keys received by any one of the clients. For that reason, the pickle key must also be same for all clients using the same database.

func (*CryptoHelper) Close

func (helper *CryptoHelper) Close() error

func (*CryptoHelper) Decrypt

func (helper *CryptoHelper) Decrypt(ctx context.Context, evt *event.Event) (*event.Event, error)

func (*CryptoHelper) Encrypt

func (helper *CryptoHelper) Encrypt(ctx context.Context, roomID id.RoomID, evtType event.Type, content any) (encrypted *event.EncryptedEventContent, err error)

func (*CryptoHelper) HandleEncrypted

func (helper *CryptoHelper) HandleEncrypted(ctx context.Context, evt *event.Event)

func (*CryptoHelper) Init

func (helper *CryptoHelper) Init(ctx context.Context) error

func (*CryptoHelper) Machine added in v0.15.1

func (helper *CryptoHelper) Machine() *crypto.OlmMachine

func (*CryptoHelper) RequestSession

func (helper *CryptoHelper) RequestSession(ctx context.Context, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, userID id.UserID, deviceID id.DeviceID)

func (*CryptoHelper) WaitForSession

func (helper *CryptoHelper) WaitForSession(ctx context.Context, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, timeout time.Duration) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL