Documentation
¶
Overview ¶
Package store contains interfaces for storing data needed for WhatsApp multidevice.
Index ¶
- Variables
- func SetOSInfo(name string, version [3]uint32)
- func SetWAVersion(version WAVersionContainer)
- type AllStores
- type AppStateMutationMAC
- type AppStateStore
- type AppStateSyncKey
- type AppStateSyncKeyStore
- type ChatSettingsStore
- type ContactEntry
- type ContactStore
- type Device
- func (device *Device) ContainsPreKey(preKeyID uint32) bool
- func (device *Device) ContainsSession(remoteAddress *protocol.SignalAddress) bool
- func (device *Device) ContainsSignedPreKey(signedPreKeyID uint32) bool
- func (device *Device) Delete() error
- func (device *Device) DeleteAllSessions()
- func (device *Device) DeleteSession(remoteAddress *protocol.SignalAddress)
- func (device *Device) GetClientPayload() *waWa6.ClientPayload
- func (device *Device) GetIdentityKeyPair() *identity.KeyPair
- func (device *Device) GetLocalRegistrationId() uint32
- func (device *Device) GetSubDeviceSessions(name string) []uint32
- func (device *Device) IsTrustedIdentity(address *protocol.SignalAddress, identityKey *identity.Key) bool
- func (device *Device) LoadPreKey(id uint32) *record.PreKey
- func (device *Device) LoadSenderKey(senderKeyName *protocol.SenderKeyName) *groupRecord.SenderKey
- func (device *Device) LoadSession(address *protocol.SignalAddress) *record.Session
- func (device *Device) LoadSignedPreKey(signedPreKeyID uint32) *record.SignedPreKey
- func (device *Device) LoadSignedPreKeys() []*record.SignedPreKey
- func (device *Device) RemovePreKey(id uint32)
- func (device *Device) RemoveSignedPreKey(signedPreKeyID uint32)
- func (device *Device) Save() error
- func (device *Device) SaveIdentity(address *protocol.SignalAddress, identityKey *identity.Key)
- func (device *Device) StorePreKey(preKeyID uint32, preKeyRecord *record.PreKey)
- func (device *Device) StoreSenderKey(senderKeyName *protocol.SenderKeyName, keyRecord *groupRecord.SenderKey)
- func (device *Device) StoreSession(address *protocol.SignalAddress, record *record.Session)
- func (device *Device) StoreSignedPreKey(signedPreKeyID uint32, record *record.SignedPreKey)
- type DeviceContainer
- type IdentityStore
- type MessageSecretInsert
- type MsgSecretStore
- type NoopStore
- func (n *NoopStore) DeleteAllIdentities(phone string) error
- func (n *NoopStore) DeleteAllSessions(phone string) error
- func (n *NoopStore) DeleteAppStateMutationMACs(name string, indexMACs [][]byte) error
- func (n *NoopStore) DeleteAppStateVersion(name string) error
- func (n *NoopStore) DeleteDevice(store *Device) error
- func (n *NoopStore) DeleteIdentity(address string) error
- func (n *NoopStore) DeleteSession(address string) error
- func (n *NoopStore) GenOnePreKey() (*keys.PreKey, error)
- func (n *NoopStore) GetAllContacts() (map[types.JID]types.ContactInfo, error)
- func (n *NoopStore) GetAppStateMutationMAC(name string, indexMAC []byte) (valueMAC []byte, err error)
- func (n *NoopStore) GetAppStateSyncKey(id []byte) (*AppStateSyncKey, error)
- func (n *NoopStore) GetAppStateVersion(name string) (uint64, [128]byte, error)
- func (n *NoopStore) GetChatSettings(chat types.JID) (types.LocalChatSettings, error)
- func (n *NoopStore) GetContact(user types.JID) (types.ContactInfo, error)
- func (n *NoopStore) GetLatestAppStateSyncKeyID() ([]byte, error)
- func (n *NoopStore) GetMessageSecret(chat, sender types.JID, id types.MessageID) ([]byte, error)
- func (n *NoopStore) GetOrGenPreKeys(count uint32) ([]*keys.PreKey, error)
- func (n *NoopStore) GetPreKey(id uint32) (*keys.PreKey, error)
- func (n *NoopStore) GetPrivacyToken(user types.JID) (*PrivacyToken, error)
- func (n *NoopStore) GetSenderKey(group, user string) ([]byte, error)
- func (n *NoopStore) GetSession(address string) ([]byte, error)
- func (n *NoopStore) HasSession(address string) (bool, error)
- func (n *NoopStore) IsTrustedIdentity(address string, key [32]byte) (bool, error)
- func (n *NoopStore) MarkPreKeysAsUploaded(upToID uint32) error
- func (n *NoopStore) PutAllContactNames(contacts []ContactEntry) error
- func (n *NoopStore) PutAppStateMutationMACs(name string, version uint64, mutations []AppStateMutationMAC) error
- func (n *NoopStore) PutAppStateSyncKey(id []byte, key AppStateSyncKey) error
- func (n *NoopStore) PutAppStateVersion(name string, version uint64, hash [128]byte) error
- func (n *NoopStore) PutArchived(chat types.JID, archived bool) error
- func (n *NoopStore) PutBusinessName(user types.JID, businessName string) (bool, string, error)
- func (n *NoopStore) PutContactName(user types.JID, fullName, firstName string) error
- func (n *NoopStore) PutDevice(store *Device) error
- func (n *NoopStore) PutIdentity(address string, key [32]byte) error
- func (n *NoopStore) PutMessageSecret(chat, sender types.JID, id types.MessageID, secret []byte) error
- func (n *NoopStore) PutMessageSecrets(inserts []MessageSecretInsert) error
- func (n *NoopStore) PutMutedUntil(chat types.JID, mutedUntil time.Time) error
- func (n *NoopStore) PutPinned(chat types.JID, pinned bool) error
- func (n *NoopStore) PutPrivacyTokens(tokens ...PrivacyToken) error
- func (n *NoopStore) PutPushName(user types.JID, pushName string) (bool, string, error)
- func (n *NoopStore) PutSenderKey(group, user string, session []byte) error
- func (n *NoopStore) PutSession(address string, session []byte) error
- func (n *NoopStore) RemovePreKey(id uint32) error
- func (n *NoopStore) UploadedPreKeyCount() (int, error)
- type PreKeyStore
- type PrivacyToken
- type PrivacyTokenStore
- type SenderKeyStore
- type SessionStore
- type WAVersionContainer
Constants ¶
This section is empty.
Variables ¶
var BaseClientPayload = &waWa6.ClientPayload{ UserAgent: &waWa6.ClientPayload_UserAgent{ Platform: waWa6.ClientPayload_UserAgent_WEB.Enum(), ReleaseChannel: waWa6.ClientPayload_UserAgent_RELEASE.Enum(), AppVersion: waVersion.ProtoAppVersion(), Mcc: proto.String("000"), Mnc: proto.String("000"), OsVersion: proto.String("0.1.0"), Manufacturer: proto.String(""), Device: proto.String("Desktop"), OsBuildNumber: proto.String("0.1.0"), LocaleLanguageIso6391: proto.String("en"), LocaleCountryIso31661Alpha2: proto.String("en"), }, WebInfo: &waWa6.ClientPayload_WebInfo{ WebSubPlatform: waWa6.ClientPayload_WebInfo_WEB_BROWSER.Enum(), }, ConnectType: waWa6.ClientPayload_WIFI_UNKNOWN.Enum(), ConnectReason: waWa6.ClientPayload_USER_ACTIVATED.Enum(), }
var DeviceProps = &waCompanionReg.DeviceProps{ Os: proto.String("whatsmeow"), Version: &waCompanionReg.DeviceProps_AppVersion{ Primary: proto.Uint32(0), Secondary: proto.Uint32(1), Tertiary: proto.Uint32(0), }, PlatformType: waCompanionReg.DeviceProps_UNKNOWN.Enum(), RequireFullSync: proto.Bool(false), }
var NoopDevice = &Device{ ID: &types.EmptyJID, NoiseKey: nilKey, IdentityKey: nilKey, Identities: nilStore, Sessions: nilStore, PreKeys: nilStore, SenderKeys: nilStore, AppStateKeys: nilStore, AppState: nilStore, Contacts: nilStore, ChatSettings: nilStore, MsgSecrets: nilStore, PrivacyTokens: nilStore, Container: nilStore, }
var SignalProtobufSerializer = serialize.NewProtoBufSerializer()
Functions ¶
func SetWAVersion ¶
func SetWAVersion(version WAVersionContainer)
SetWAVersion sets the current WhatsApp web client version.
In general, you should keep the library up-to-date instead of using this, as there may be code changes that are necessary too (like protobuf schema changes).
Types ¶
type AllStores ¶
type AllStores interface { IdentityStore SessionStore PreKeyStore SenderKeyStore AppStateSyncKeyStore AppStateStore ContactStore ChatSettingsStore MsgSecretStore PrivacyTokenStore }
type AppStateMutationMAC ¶
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 AppStateSyncKeyStore ¶
type AppStateSyncKeyStore interface { PutAppStateSyncKey(id []byte, key AppStateSyncKey) error GetAppStateSyncKey(id []byte) (*AppStateSyncKey, error) GetLatestAppStateSyncKeyID() ([]byte, error) }
type ChatSettingsStore ¶
type ContactStore ¶
type ContactStore interface { PutPushName(user types.JID, pushName string) (bool, string, error) PutBusinessName(user types.JID, businessName string) (bool, string, error) PutContactName(user types.JID, fullName, firstName string) error PutAllContactNames(contacts []ContactEntry) error GetContact(user types.JID) (types.ContactInfo, error) GetAllContacts() (map[types.JID]types.ContactInfo, error) }
type Device ¶
type Device struct { Log waLog.Logger NoiseKey *keys.KeyPair IdentityKey *keys.KeyPair SignedPreKey *keys.PreKey RegistrationID uint32 AdvSecretKey []byte ID *types.JID Account *waAdv.ADVSignedDeviceIdentity Platform string BusinessName string PushName string FacebookUUID uuid.UUID Initialized bool Identities IdentityStore Sessions SessionStore PreKeys PreKeyStore SenderKeys SenderKeyStore AppStateKeys AppStateSyncKeyStore AppState AppStateStore Contacts ContactStore ChatSettings ChatSettingsStore MsgSecrets MsgSecretStore PrivacyTokens PrivacyTokenStore Container DeviceContainer DatabaseErrorHandler func(device *Device, action string, attemptIndex int, err error) (retry bool) }
func (*Device) ContainsPreKey ¶
func (*Device) ContainsSession ¶
func (device *Device) ContainsSession(remoteAddress *protocol.SignalAddress) bool
func (*Device) ContainsSignedPreKey ¶
func (*Device) DeleteAllSessions ¶
func (device *Device) DeleteAllSessions()
func (*Device) DeleteSession ¶
func (device *Device) DeleteSession(remoteAddress *protocol.SignalAddress)
func (*Device) GetClientPayload ¶
func (device *Device) GetClientPayload() *waWa6.ClientPayload
func (*Device) GetIdentityKeyPair ¶
func (*Device) GetLocalRegistrationId ¶
func (*Device) GetSubDeviceSessions ¶
func (*Device) IsTrustedIdentity ¶
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) RemoveSignedPreKey ¶
func (*Device) SaveIdentity ¶
func (device *Device) SaveIdentity(address *protocol.SignalAddress, identityKey *identity.Key)
func (*Device) StorePreKey ¶
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 IdentityStore ¶
type MessageSecretInsert ¶
type MsgSecretStore ¶
type NoopStore ¶
type NoopStore struct {
Error error
}
func (*NoopStore) DeleteAllIdentities ¶
func (*NoopStore) DeleteAllSessions ¶
func (*NoopStore) DeleteAppStateMutationMACs ¶
func (*NoopStore) DeleteAppStateVersion ¶
func (*NoopStore) DeleteDevice ¶
func (*NoopStore) DeleteIdentity ¶
func (*NoopStore) DeleteSession ¶
func (*NoopStore) GetAllContacts ¶
func (*NoopStore) GetAppStateMutationMAC ¶
func (*NoopStore) GetAppStateSyncKey ¶
func (n *NoopStore) GetAppStateSyncKey(id []byte) (*AppStateSyncKey, error)
func (*NoopStore) GetAppStateVersion ¶
func (*NoopStore) GetChatSettings ¶
func (*NoopStore) GetContact ¶
func (*NoopStore) GetLatestAppStateSyncKeyID ¶
func (*NoopStore) GetMessageSecret ¶
func (*NoopStore) GetOrGenPreKeys ¶
func (*NoopStore) GetPrivacyToken ¶
func (n *NoopStore) GetPrivacyToken(user types.JID) (*PrivacyToken, error)
func (*NoopStore) GetSenderKey ¶
func (*NoopStore) IsTrustedIdentity ¶
func (*NoopStore) MarkPreKeysAsUploaded ¶
func (*NoopStore) PutAllContactNames ¶
func (n *NoopStore) PutAllContactNames(contacts []ContactEntry) error
func (*NoopStore) PutAppStateMutationMACs ¶
func (n *NoopStore) PutAppStateMutationMACs(name string, version uint64, mutations []AppStateMutationMAC) error
func (*NoopStore) PutAppStateSyncKey ¶
func (n *NoopStore) PutAppStateSyncKey(id []byte, key AppStateSyncKey) error
func (*NoopStore) PutAppStateVersion ¶
func (*NoopStore) PutArchived ¶
func (*NoopStore) PutBusinessName ¶
func (*NoopStore) PutContactName ¶
func (*NoopStore) PutMessageSecret ¶
func (*NoopStore) PutMessageSecrets ¶
func (n *NoopStore) PutMessageSecrets(inserts []MessageSecretInsert) error
func (*NoopStore) PutMutedUntil ¶
func (*NoopStore) PutPrivacyTokens ¶
func (n *NoopStore) PutPrivacyTokens(tokens ...PrivacyToken) error
func (*NoopStore) PutPushName ¶
func (*NoopStore) PutSenderKey ¶
func (*NoopStore) RemovePreKey ¶
func (*NoopStore) UploadedPreKeyCount ¶
type PreKeyStore ¶
type PrivacyTokenStore ¶
type PrivacyTokenStore interface { PutPrivacyTokens(tokens ...PrivacyToken) error GetPrivacyToken(user types.JID) (*PrivacyToken, error) }
type SenderKeyStore ¶
type SessionStore ¶
type WAVersionContainer ¶
type WAVersionContainer [3]uint32
WAVersionContainer is a container for a WhatsApp web version number.
func GetWAVersion ¶
func GetWAVersion() WAVersionContainer
GetWAVersion gets the current WhatsApp web client version.
func ParseVersion ¶
func ParseVersion(version string) (parsed WAVersionContainer, err error)
ParseVersion parses a version string (three dot-separated numbers) into a WAVersionContainer.
func (WAVersionContainer) Hash ¶
func (vc WAVersionContainer) Hash() [16]byte
Hash returns the md5 hash of the String representation of this version.
func (WAVersionContainer) IsZero ¶
func (vc WAVersionContainer) IsZero() bool
IsZero returns true if the version is zero.
func (WAVersionContainer) LessThan ¶
func (vc WAVersionContainer) LessThan(other WAVersionContainer) bool
func (WAVersionContainer) ProtoAppVersion ¶
func (vc WAVersionContainer) ProtoAppVersion() *waWa6.ClientPayload_UserAgent_AppVersion
func (WAVersionContainer) String ¶
func (vc WAVersionContainer) String() string
String returns the version number as a dot-separated string.