store

package
v0.0.0-...-9e1ef92 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package store contains interfaces for storing data needed for WhatsApp multidevice.

Index

Constants

This section is empty.

Variables

View Source
var BaseClientPayload = &waProto.ClientPayload{
	ConnectType:   waProto.ClientPayload_WIFI_UNKNOWN.Enum(),
	ConnectReason: waProto.ClientPayload_USER_ACTIVATED.Enum(),
}
View Source
var SignalProtobufSerializer = serialize.NewProtoBufSerializer()

Functions

This section is empty.

Types

type AppStateMutationMAC

type AppStateMutationMAC struct {
	IndexMAC []byte
	ValueMAC []byte
}

type AppStateStore

type AppStateStore interface {
	PutAppStateVersion(name string, version uint64, hash [128]byte) error
	GetAppStateVersion(name string) (uint64, [128]byte, error)
	DeleteAppStateVersion(name string) error

	PutAppStateMutationMACs(name string, version uint64, mutations []AppStateMutationMAC) error
	DeleteAppStateMutationMACs(name string, indexMACs [][]byte) error
	GetAppStateMutationMAC(name string, indexMAC []byte) (valueMAC []byte, err error)
}

type AppStateSyncKey

type AppStateSyncKey struct {
	Data        []byte
	Fingerprint []byte
	Timestamp   int64
}

type AppStateSyncKeyStore

type AppStateSyncKeyStore interface {
	PutAppStateSyncKey(id []byte, key AppStateSyncKey) error
	GetAppStateSyncKey(id []byte) (*AppStateSyncKey, error)
}

type ChatSettingsStore

type ChatSettingsStore interface {
	PutMutedUntil(chat types.JID, mutedUntil time.Time) error
	PutPinned(chat types.JID, pinned bool) error
	PutArchived(chat types.JID, archived bool) error
	GetChatSettings(chat types.JID) (*types.LocalChatSettings, error)
}

type ContactStore

type ContactStore interface {
	PutPushName(user types.JID, pushName string) (bool, string, error)
	PutBusinessName(user types.JID, businessName string) error
	PutContactName(user types.JID, fullName, firstName string) error
	GetContact(user types.JID) (*types.ContactInfo, error)
	GetAllContacts() (map[types.JID]types.ContactInfo, error)
}

type Device

type Device struct {
	ID                          *types.JID
	NoiseKey                    *keys.KeyPair
	NoiseServerKey              *[32]byte
	Registered                  bool
	RegistrationID              uint32
	IdentityKey                 *keys.KeyPair
	SignedPreKey                *keys.PreKey
	PushName                    string
	Platform                    string
	Edge                        *[4]byte
	AppVersion                  string
	Mcc                         string
	Mnc                         string
	OsVersion                   string
	Manufacturer                string
	Device                      string
	OsBuildNumber               string
	PhoneId                     string
	LocaleLanguageIso6391       string
	LocaleCountryIso31661Alpha2 string
	DeviceBoard                 string

	AdvSecretKey []byte
	Account      *waProto.ADVSignedDeviceIdentity

	Initialized  bool
	Identities   IdentityStore
	Sessions     SessionStore
	PreKeys      PreKeyStore
	SenderKeys   SenderKeyStore
	AppStateKeys AppStateSyncKeyStore
	AppState     AppStateStore
	Contacts     ContactStore
	ChatSettings ChatSettingsStore
	Container    DeviceContainer
	Log          waLog.Logger
}

func (*Device) ContainsPreKey

func (device *Device) ContainsPreKey(preKeyID uint32) bool

func (*Device) ContainsSession

func (device *Device) ContainsSession(remoteAddress *protocol.SignalAddress) bool

func (*Device) ContainsSignedPreKey

func (device *Device) ContainsSignedPreKey(signedPreKeyID uint32) bool

func (*Device) Delete

func (device *Device) Delete() error

func (*Device) DeleteAllSessions

func (device *Device) DeleteAllSessions()

func (*Device) DeleteSession

func (device *Device) DeleteSession(remoteAddress *protocol.SignalAddress)

func (*Device) GetAndroidPayload

func (device *Device) GetAndroidPayload(registered bool) (*waProto.ClientPayload, error)

func (*Device) GetIdentityKeyPair

func (device *Device) GetIdentityKeyPair() *identity.KeyPair

func (*Device) GetLocalRegistrationId

func (device *Device) GetLocalRegistrationId() uint32

func (*Device) GetSubDeviceSessions

func (device *Device) GetSubDeviceSessions(name string) []uint32

func (*Device) IsTrustedIdentity

func (device *Device) IsTrustedIdentity(address *protocol.SignalAddress, identityKey *identity.Key) bool

func (*Device) LoadPreKey

func (device *Device) LoadPreKey(id uint32) *record.PreKey

func (*Device) LoadSenderKey

func (device *Device) LoadSenderKey(senderKeyName *protocol.SenderKeyName) *groupRecord.SenderKey

func (*Device) LoadSession

func (device *Device) LoadSession(address *protocol.SignalAddress) *record.Session

func (*Device) LoadSignedPreKey

func (device *Device) LoadSignedPreKey(signedPreKeyID uint32) *record.SignedPreKey

func (*Device) LoadSignedPreKeys

func (device *Device) LoadSignedPreKeys() []*record.SignedPreKey

func (*Device) RemovePreKey

func (device *Device) RemovePreKey(id uint32)

func (*Device) RemoveSignedPreKey

func (device *Device) RemoveSignedPreKey(signedPreKeyID uint32)

func (*Device) Save

func (device *Device) Save() error

func (*Device) SaveIdentity

func (device *Device) SaveIdentity(address *protocol.SignalAddress, identityKey *identity.Key)

func (*Device) StorePreKey

func (device *Device) StorePreKey(preKeyID uint32, preKeyRecord *record.PreKey)

func (*Device) StoreSenderKey

func (device *Device) StoreSenderKey(senderKeyName *protocol.SenderKeyName, keyRecord *groupRecord.SenderKey)

func (*Device) StoreSession

func (device *Device) StoreSession(address *protocol.SignalAddress, record *record.Session)

func (*Device) StoreSignedPreKey

func (device *Device) StoreSignedPreKey(signedPreKeyID uint32, record *record.SignedPreKey)

type DeviceContainer

type DeviceContainer interface {
	PutDevice(store *Device) error
	DeleteDevice(store *Device) error
}

type IdentityStore

type IdentityStore interface {
	PutIdentity(address string, key [32]byte) error
	DeleteAllIdentities(phone string) error
	DeleteIdentity(address string) error
	IsTrustedIdentity(address string, key [32]byte) (bool, error)
}

type PreKeyStore

type PreKeyStore interface {
	GetOrGenPreKeys(count uint32) ([]*keys.PreKey, error)
	GenOnePreKey() (*keys.PreKey, error)
	GetPreKey(id uint32) (*keys.PreKey, error)
	RemovePreKey(id uint32) error
	MarkPreKeysAsUploaded(upToID uint32) error
	UploadedPreKeyCount() (int, error)
}

type SenderKeyStore

type SenderKeyStore interface {
	PutSenderKey(group, user string, session []byte) error
	GetSenderKey(group, user string) ([]byte, error)
}

type SessionStore

type SessionStore interface {
	GetSession(address string) ([]byte, error)
	HasSession(address string) (bool, error)
	PutSession(address string, session []byte) error
	DeleteAllSessions(phone string) error
	DeleteSession(address string) error
}

Directories

Path Synopsis
Package sqlstore contains an SQL-backed implementation of the interfaces in the store package.
Package sqlstore contains an SQL-backed implementation of the interfaces in the store package.

Jump to

Keyboard shortcuts

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