store

package
v0.6.1-mod-1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: AGPL-3.0 Imports: 12 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 Container

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

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

func NewStore

func NewStore(db *dbutil.Database, log dbutil.DatabaseLogger) *Container

func (*Container) DeleteDevice

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

DeleteDevice deletes the given device from this database

func (*Container) DeviceByACI

func (c *Container) 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 (*Container) GetAllDevices

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

GetAllDevices finds all the devices in the database.

func (*Container) PutDevice

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

PutDevice stores the given device in this database.

func (*Container) Upgrade

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

type Device

type Device struct {
	DeviceData

	// libsignalgo store interfaces
	ACIPreKeyStore   PreKeyStore
	PNIPreKeyStore   PreKeyStore
	ACISessionStore  SessionStore
	PNISessionStore  SessionStore
	ACIIdentityStore libsignalgo.IdentityKeyStore
	PNIIdentityStore libsignalgo.IdentityKeyStore
	IdentityKeyStore IdentityKeyStore
	SenderKeyStore   libsignalgo.SenderKeyStore

	GroupStore     GroupStore
	RecipientStore RecipientStore
	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) IdentityStore

func (d *Device) IdentityStore(serviceID libsignalgo.ServiceID) libsignalgo.IdentityKeyStore

func (*Device) IsDeviceLoggedIn

func (d *Device) IsDeviceLoggedIn() bool

func (*Device) PreKeyStore

func (d *Device) PreKeyStore(serviceID libsignalgo.ServiceID) PreKeyStore

func (*Device) SessionStore

func (d *Device) SessionStore(serviceID libsignalgo.ServiceID) SessionStore

type DeviceData

type DeviceData struct {
	ACIIdentityKeyPair *libsignalgo.IdentityKeyPair
	PNIIdentityKeyPair *libsignalgo.IdentityKeyPair
	ACIRegistrationID  int
	PNIRegistrationID  int
	ACI                uuid.UUID
	PNI                uuid.UUID
	DeviceID           int
	Number             string
	Password           string
	MasterKey          []byte
}

func (*DeviceData) ACIServiceID

func (d *DeviceData) ACIServiceID() libsignalgo.ServiceID

func (*DeviceData) BasicAuthCreds

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

func (*DeviceData) PNIServiceID

func (d *DeviceData) PNIServiceID() libsignalgo.ServiceID

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 IdentityKeyStore

type IdentityKeyStore interface {
	SaveIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey) (bool, error)
	GetIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID) (*libsignalgo.IdentityKey, error)
	IsTrustedIdentity(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection) (bool, error)
}

type PreKeyStore

type PreKeyStore interface {
	libsignalgo.PreKeyStore
	libsignalgo.SignedPreKeyStore
	libsignalgo.KyberPreKeyStore
	ServiceScopedStore

	StoreLastResortKyberPreKey(ctx context.Context, preKeyID uint32, record *libsignalgo.KyberPreKeyRecord) error
	RemoveSignedPreKey(ctx context.Context, preKeyID uint32) error
	RemoveKyberPreKey(ctx context.Context, preKeyID uint32) error
	GetNextPreKeyID(ctx context.Context) (count, max uint32, err error)
	GetNextKyberPreKeyID(ctx context.Context) (count, max uint32, err error)
	IsKyberPreKeyLastResort(ctx context.Context, preKeyID uint32) (bool, error)
	AllPreKeys(ctx context.Context) ([]*libsignalgo.PreKeyRecord, error)
	AllNormalKyberPreKeys(ctx context.Context) ([]*libsignalgo.KyberPreKeyRecord, error)
	DeleteAllPreKeys(ctx context.Context) error
}

type RecipientStore

type RecipientStore interface {
	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)

	LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUID, updater RecipientUpdaterFunc) (*types.Recipient, error)
	LoadRecipientByE164(ctx context.Context, e164 string) (*types.Recipient, error)
	StoreRecipient(ctx context.Context, recipient *types.Recipient) error
	UpdateRecipientE164(ctx context.Context, aci, pni uuid.UUID, e164 string) (*types.Recipient, error)
}

type RecipientUpdaterFunc

type RecipientUpdaterFunc func(recipient *types.Recipient) (changed bool, err error)

type ServiceScopedStore

type ServiceScopedStore interface {
	GetServiceID() libsignalgo.ServiceID
}

type SessionStore

type SessionStore interface {
	libsignalgo.SessionStore
	ServiceScopedStore

	// AllSessionsForServiceID returns all sessions for the given service ID.
	AllSessionsForServiceID(ctx context.Context, theirID libsignalgo.ServiceID) ([]*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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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