storage

package
v0.0.0-...-d5168a5 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRecipients returned when an empty list of recipients is provided
	ErrInvalidRecipients = errors.New("recipient list is empty")
	// ErrSessionNotFound session was not found for a given recipient and sender
	ErrSessionNotFound = errors.New("there is no existing session that matches the given sender and recipient")
	// ErrInvalidGroupMessageRecipient a received message is not intended for this identity
	ErrInvalidGroupMessageRecipient = errors.New("group message does not contain a recipient header for this identity")
	// ErrDecryptionFailed returned when a session failed to decrypt a message
	ErrDecryptionFailed = errors.New("session failed to decrypt message")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	StorageDir    string
	EncryptionKey string
	AccountID     string
	SyncInterval  time.Duration
	PKI           PKI
}

Config messaging configuration for connecting to self messaging

type PKI

type PKI interface {
	GetHistory(selfID string) ([]json.RawMessage, error)
	GetDeviceKey(selfID, deviceID string) ([]byte, error)
	SetDeviceKeys(selfID, deviceID string, pkb []byte) error
	ListDeviceKeys(selfID, deviceID string) ([]byte, error)
}

PKI the public key infrastructure provider used to retrieve and store keys

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Stoprage the default storage implementation based on sqlite

func New

func New(cfg *Config) (*Storage, error)

func (*Storage) AccountCreate

func (s *Storage) AccountCreate(inboxID string, secretKey ed25519.PrivateKey) error

func (*Storage) AccountExecute

func (s *Storage) AccountExecute(inboxID string, action func(account *selfcrypto.Account) error) error

AccountExecute executes an action on an account

func (*Storage) AccountOffset

func (s *Storage) AccountOffset(inboxID string) (int64, error)

AccountOffset returns the latest offset for an account that messages will be resumed from

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage connection

func (*Storage) Decrypt

func (s *Storage) Decrypt(from, to string, offset int64, ciphertext []byte) ([]byte, error)

func (*Storage) Encrypt

func (s *Storage) Encrypt(from string, to []string, plaintext []byte) ([]byte, error)

func (*Storage) SessionList

func (s *Storage) SessionList(asIdentifier string) ([]string, error)

func (*Storage) SessionPurge

func (s *Storage) SessionPurge(asIdentifier, withIdentifier string) error

Jump to

Keyboard shortcuts

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