store

package
v0.5.1-mod-1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeviceIDMustBeSet = errors.New("device aci_uuid must be known before accessing database")

ErrDeviceIDMustBeSet is the error returned by PutDevice if you try to save a device before knowing its ACI UUID.

Functions

This section is empty.

Types

type ContactStore

type ContactStore interface {
	LoadContact(ctx context.Context, theirUUID uuid.UUID) (*types.Contact, error)
	LoadContactByE164(ctx context.Context, e164 string) (*types.Contact, error)
	StoreContact(ctx context.Context, contact types.Contact) error
	AllContacts(ctx context.Context) ([]*types.Contact, error)
	UpdatePhone(ctx context.Context, theirUUID uuid.UUID, newE164 string) error
}

type Device

type Device struct {
	DeviceData

	// libsignalgo store interfaces
	PreKeyStore       libsignalgo.PreKeyStore
	SignedPreKeyStore libsignalgo.SignedPreKeyStore
	KyberPreKeyStore  libsignalgo.KyberPreKeyStore
	IdentityStore     libsignalgo.IdentityKeyStore
	SessionStore      libsignalgo.SessionStore
	SenderKeyStore    libsignalgo.SenderKeyStore

	// internal store interfaces
	PreKeyStoreExtras  PreKeyStoreExtras
	SessionStoreExtras SessionStoreExtras
	ProfileKeyStore    ProfileKeyStore
	GroupStore         GroupStore
	ContactStore       ContactStore
	DeviceStore        DeviceStore
}

Device is a wrapper for a signalmeow session, including device data, and interfaces for operating on the DB within the session.

func (*Device) ClearDeviceKeys

func (d *Device) ClearDeviceKeys(ctx context.Context) error

func (*Device) ClearPassword

func (d *Device) ClearPassword(ctx context.Context) error

func (*Device) DeleteDevice

func (d *Device) DeleteDevice(ctx context.Context) error

func (*Device) IsDeviceLoggedIn

func (d *Device) IsDeviceLoggedIn() bool

type DeviceData

type DeviceData struct {
	ACIIdentityKeyPair *libsignalgo.IdentityKeyPair
	PNIIdentityKeyPair *libsignalgo.IdentityKeyPair
	RegistrationID     int
	PNIRegistrationID  int
	ACI                uuid.UUID
	PNI                uuid.UUID
	DeviceID           int
	Number             string
	Password           string
}

func (*DeviceData) BasicAuthCreds

func (d *DeviceData) BasicAuthCreds() (string, string)

type DeviceStore

type DeviceStore interface {
	PutDevice(ctx context.Context, dd *DeviceData) error
	DeleteDevice(ctx context.Context, dd *DeviceData) error
	DeviceByACI(ctx context.Context, aci uuid.UUID) (*Device, error)
}

type GroupStore

type GroupStore interface {
	MasterKeyFromGroupIdentifier(ctx context.Context, groupID types.GroupIdentifier) (types.SerializedGroupMasterKey, error)
	StoreMasterKey(ctx context.Context, groupID types.GroupIdentifier, key types.SerializedGroupMasterKey) error
}

type PreKeyStoreExtras

type PreKeyStoreExtras interface {
	PreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.PreKeyRecord, error)
	SignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.SignedPreKeyRecord, error)
	KyberPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.KyberPreKeyRecord, error)
	SavePreKey(ctx context.Context, uuidKind types.UUIDKind, preKey *libsignalgo.PreKeyRecord, markUploaded bool) error
	SaveSignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKey *libsignalgo.SignedPreKeyRecord, markUploaded bool) error
	SaveKyberPreKey(ctx context.Context, uuidKind types.UUIDKind, preKey *libsignalgo.KyberPreKeyRecord, lastResort bool) error
	DeletePreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error
	DeleteSignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error
	DeleteKyberPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error
	GetNextPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)
	GetSignedNextPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)
	GetNextKyberPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)
	MarkPreKeysAsUploaded(ctx context.Context, uuidKind types.UUIDKind, upToID uint) error
	MarkSignedPreKeysAsUploaded(ctx context.Context, uuidKind types.UUIDKind, upToID uint) error
	IsKyberPreKeyLastResort(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (bool, error)
	AllPreKeys(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.PreKeyRecord, error)
	AllNormalKyberPreKeys(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.KyberPreKeyRecord, error)
	DeleteAllPreKeys(ctx context.Context) error
}

type ProfileKeyStore

type ProfileKeyStore interface {
	// LoadProfileKey loads the profile key for the given address.
	// If the address is not found, nil is returned.
	LoadProfileKey(ctx context.Context, theirACI uuid.UUID) (*libsignalgo.ProfileKey, error)
	StoreProfileKey(ctx context.Context, theirACI uuid.UUID, key libsignalgo.ProfileKey) error
	MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error)
}

type SQLStore

type SQLStore struct {
	*StoreContainer
	ACI uuid.UUID
}

SQLStore is basically a StoreContainer with an ACI UUID attached to it, reperesenting a store for a single user

func (*SQLStore) AllContacts

func (s *SQLStore) AllContacts(ctx context.Context) ([]*types.Contact, error)

func (*SQLStore) AllNormalKyberPreKeys

func (s *SQLStore) AllNormalKyberPreKeys(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.KyberPreKeyRecord, error)

func (*SQLStore) AllPreKeys

func (s *SQLStore) AllPreKeys(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.PreKeyRecord, error)

func (*SQLStore) AllSessionsForUUID

func (s *SQLStore) AllSessionsForUUID(ctx context.Context, theirUUID uuid.UUID) ([]*libsignalgo.Address, []*libsignalgo.SessionRecord, error)

func (*SQLStore) DeleteAllPreKeys

func (s *SQLStore) DeleteAllPreKeys(ctx context.Context) error

func (*SQLStore) DeleteKyberPreKey

func (s *SQLStore) DeleteKyberPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error

func (*SQLStore) DeletePreKey

func (s *SQLStore) DeletePreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error

func (*SQLStore) DeleteSignedPreKey

func (s *SQLStore) DeleteSignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) error

func (*SQLStore) GetIdentityKey

func (s *SQLStore) GetIdentityKey(ctx context.Context, address *libsignalgo.Address) (*libsignalgo.IdentityKey, error)

func (*SQLStore) GetIdentityKeyPair

func (s *SQLStore) GetIdentityKeyPair(ctx context.Context) (*libsignalgo.IdentityKeyPair, error)

func (*SQLStore) GetLocalRegistrationID

func (s *SQLStore) GetLocalRegistrationID(ctx context.Context) (uint32, error)

func (*SQLStore) GetNextKyberPreKeyID

func (s *SQLStore) GetNextKyberPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)

func (*SQLStore) GetNextPreKeyID

func (s *SQLStore) GetNextPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)

func (*SQLStore) GetSignedNextPreKeyID

func (s *SQLStore) GetSignedNextPreKeyID(ctx context.Context, uuidKind types.UUIDKind) (uint, error)

func (*SQLStore) IsKyberPreKeyLastResort

func (s *SQLStore) IsKyberPreKeyLastResort(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (bool, error)

func (*SQLStore) IsTrustedIdentity

func (s *SQLStore) IsTrustedIdentity(ctx context.Context, address *libsignalgo.Address, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection) (bool, error)

func (*SQLStore) KyberPreKey

func (s *SQLStore) KyberPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.KyberPreKeyRecord, error)

func (*SQLStore) LoadContact

func (s *SQLStore) LoadContact(ctx context.Context, theirUUID uuid.UUID) (*types.Contact, error)

func (*SQLStore) LoadContactByE164

func (s *SQLStore) LoadContactByE164(ctx context.Context, e164 string) (*types.Contact, error)

func (*SQLStore) LoadKyberPreKey

func (s *SQLStore) LoadKyberPreKey(ctx context.Context, id uint32) (*libsignalgo.KyberPreKeyRecord, error)

func (*SQLStore) LoadPreKey

func (s *SQLStore) LoadPreKey(ctx context.Context, id uint32) (*libsignalgo.PreKeyRecord, error)

func (*SQLStore) LoadProfileKey

func (s *SQLStore) LoadProfileKey(ctx context.Context, theirACI uuid.UUID) (*libsignalgo.ProfileKey, error)

func (*SQLStore) LoadSenderKey

func (s *SQLStore) LoadSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID) (*libsignalgo.SenderKeyRecord, error)

func (*SQLStore) LoadSession

func (s *SQLStore) LoadSession(ctx context.Context, address *libsignalgo.Address) (*libsignalgo.SessionRecord, error)

func (*SQLStore) LoadSignedPreKey

func (s *SQLStore) LoadSignedPreKey(ctx context.Context, id uint32) (*libsignalgo.SignedPreKeyRecord, error)

func (*SQLStore) MarkKyberPreKeyUsed

func (s *SQLStore) MarkKyberPreKeyUsed(ctx context.Context, id uint32) error

func (*SQLStore) MarkPreKeysAsUploaded

func (s *SQLStore) MarkPreKeysAsUploaded(ctx context.Context, uuidKind types.UUIDKind, upToID uint) error

func (*SQLStore) MarkSignedPreKeysAsUploaded

func (s *SQLStore) MarkSignedPreKeysAsUploaded(ctx context.Context, uuidKind types.UUIDKind, upToID uint) error

func (*SQLStore) MasterKeyFromGroupIdentifier

func (s *SQLStore) MasterKeyFromGroupIdentifier(ctx context.Context, groupID types.GroupIdentifier) (types.SerializedGroupMasterKey, error)

func (*SQLStore) MyProfileKey

func (s *SQLStore) MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error)

func (*SQLStore) PreKey

func (s *SQLStore) PreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.PreKeyRecord, error)

func (*SQLStore) RemoveAllSessions

func (s *SQLStore) RemoveAllSessions(ctx context.Context) error

func (*SQLStore) RemovePreKey

func (s *SQLStore) RemovePreKey(ctx context.Context, id uint32) error

func (*SQLStore) RemoveSession

func (s *SQLStore) RemoveSession(ctx context.Context, address *libsignalgo.Address) error

func (*SQLStore) RemoveSignedPreKey

func (s *SQLStore) RemoveSignedPreKey(ctx context.Context, id uint32) error

func (*SQLStore) SaveIdentityKey

func (s *SQLStore) SaveIdentityKey(ctx context.Context, address *libsignalgo.Address, identityKey *libsignalgo.IdentityKey) (bool, error)

func (*SQLStore) SaveKyberPreKey

func (s *SQLStore) SaveKyberPreKey(ctx context.Context, uuidKind types.UUIDKind, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord, lastResort bool) error

func (*SQLStore) SavePreKey

func (s *SQLStore) SavePreKey(ctx context.Context, uuidKind types.UUIDKind, preKey *libsignalgo.PreKeyRecord, markUploaded bool) error

func (*SQLStore) SaveSignedPreKey

func (s *SQLStore) SaveSignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKey *libsignalgo.SignedPreKeyRecord, markUploaded bool) error

func (*SQLStore) SignedPreKey

func (s *SQLStore) SignedPreKey(ctx context.Context, uuidKind types.UUIDKind, preKeyID int) (*libsignalgo.SignedPreKeyRecord, error)

func (*SQLStore) StoreContact

func (s *SQLStore) StoreContact(ctx context.Context, contact types.Contact) error

func (*SQLStore) StoreKyberPreKey

func (s *SQLStore) StoreKyberPreKey(ctx context.Context, id uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord) error

func (*SQLStore) StoreMasterKey

func (s *SQLStore) StoreMasterKey(ctx context.Context, groupID types.GroupIdentifier, key types.SerializedGroupMasterKey) error

func (*SQLStore) StorePreKey

func (s *SQLStore) StorePreKey(ctx context.Context, id uint32, preKeyRecord *libsignalgo.PreKeyRecord) error

func (*SQLStore) StoreProfileKey

func (s *SQLStore) StoreProfileKey(ctx context.Context, theirACI uuid.UUID, key libsignalgo.ProfileKey) error

func (*SQLStore) StoreSenderKey

func (s *SQLStore) StoreSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID, record *libsignalgo.SenderKeyRecord) error

func (*SQLStore) StoreSession

func (s *SQLStore) StoreSession(ctx context.Context, address *libsignalgo.Address, record *libsignalgo.SessionRecord) error

func (*SQLStore) StoreSignedPreKey

func (s *SQLStore) StoreSignedPreKey(ctx context.Context, id uint32, signedPreKeyRecord *libsignalgo.SignedPreKeyRecord) error

func (*SQLStore) UpdatePhone

func (s *SQLStore) UpdatePhone(ctx context.Context, theirUUID uuid.UUID, newE164 string) error

type SessionStoreExtras

type SessionStoreExtras interface {
	// AllSessionsForUUID returns all sessions for the given UUID.
	AllSessionsForUUID(ctx context.Context, theirUUID uuid.UUID) ([]*libsignalgo.Address, []*libsignalgo.SessionRecord, error)
	// RemoveSession removes the session for the given address.
	RemoveSession(ctx context.Context, address *libsignalgo.Address) error
	// RemoveAllSessions removes all sessions for our ACI UUID
	RemoveAllSessions(ctx context.Context) error
}

type StoreContainer

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

StoreContainer is a wrapper for a SQL database that can contain multiple signalmeow sessions.

func (*StoreContainer) DeleteDevice

func (c *StoreContainer) DeleteDevice(ctx context.Context, device *DeviceData) error

DeleteDevice deletes the given device from this database

func (*StoreContainer) DeviceByACI

func (c *StoreContainer) DeviceByACI(ctx context.Context, aci uuid.UUID) (*Device, error)

GetDevice finds the device with the specified ACI UUID in the database. If the device is not found, nil is returned instead.

func (*StoreContainer) GetAllDevices

func (c *StoreContainer) GetAllDevices(ctx context.Context) ([]*Device, error)

GetAllDevices finds all the devices in the database.

func (*StoreContainer) PutDevice

func (c *StoreContainer) PutDevice(ctx context.Context, device *DeviceData) error

PutDevice stores the given device in this database.

func (*StoreContainer) Upgrade

func (c *StoreContainer) Upgrade(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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