summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/store
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/store')
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/clientpayload.go35
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go10
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go36
3 files changed, 59 insertions, 22 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/store/clientpayload.go b/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
index 9a65f515..6ebf5d99 100644
--- a/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
+++ b/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
@@ -74,7 +74,7 @@ func (vc WAVersionContainer) ProtoAppVersion() *waProto.AppVersion {
}
// waVersion is the WhatsApp web client version
-var waVersion = WAVersionContainer{2, 2214, 12}
+var waVersion = WAVersionContainer{2, 2218, 8}
// waVersionHash is the md5 hash of a dot-separated waVersion
var waVersionHash [16]byte
@@ -122,7 +122,10 @@ var BaseClientPayload = &waProto.ClientPayload{
ConnectReason: waProto.ClientPayload_USER_ACTIVATED.Enum(),
}
-var CompanionProps = &waProto.CompanionProps{
+// Deprecated: renamed to DeviceProps
+var CompanionProps = DeviceProps
+
+var DeviceProps = &waProto.CompanionProps{
Os: proto.String("whatsmeow"),
Version: &waProto.AppVersion{
Primary: proto.Uint32(0),
@@ -134,10 +137,10 @@ var CompanionProps = &waProto.CompanionProps{
}
func SetOSInfo(name string, version [3]uint32) {
- CompanionProps.Os = &name
- CompanionProps.Version.Primary = &version[0]
- CompanionProps.Version.Secondary = &version[1]
- CompanionProps.Version.Tertiary = &version[2]
+ DeviceProps.Os = &name
+ DeviceProps.Version.Primary = &version[0]
+ DeviceProps.Version.Secondary = &version[1]
+ DeviceProps.Version.Tertiary = &version[2]
BaseClientPayload.UserAgent.OsVersion = proto.String(fmt.Sprintf("%d.%d.%d", version[0], version[1], version[2]))
BaseClientPayload.UserAgent.OsBuildNumber = BaseClientPayload.UserAgent.OsVersion
}
@@ -148,16 +151,16 @@ func (device *Device) getRegistrationPayload() *waProto.ClientPayload {
binary.BigEndian.PutUint32(regID, device.RegistrationID)
preKeyID := make([]byte, 4)
binary.BigEndian.PutUint32(preKeyID, device.SignedPreKey.KeyID)
- companionProps, _ := proto.Marshal(CompanionProps)
- payload.RegData = &waProto.CompanionRegData{
- ERegid: regID,
- EKeytype: []byte{ecc.DjbType},
- EIdent: device.IdentityKey.Pub[:],
- ESkeyId: preKeyID[1:],
- ESkeyVal: device.SignedPreKey.Pub[:],
- ESkeySig: device.SignedPreKey.Signature[:],
- BuildHash: waVersionHash[:],
- CompanionProps: companionProps,
+ deviceProps, _ := proto.Marshal(DeviceProps)
+ payload.DevicePairingData = &waProto.DevicePairingRegistrationData{
+ ERegid: regID,
+ EKeytype: []byte{ecc.DjbType},
+ EIdent: device.IdentityKey.Pub[:],
+ ESkeyId: preKeyID[1:],
+ ESkeyVal: device.SignedPreKey.Pub[:],
+ ESkeySig: device.SignedPreKey.Signature[:],
+ BuildHash: waVersionHash[:],
+ DeviceProps: deviceProps,
}
payload.Passive = proto.Bool(false)
return payload
diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
index 3150cfec..b7c0a7c4 100644
--- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
+++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
@@ -78,7 +78,7 @@ func NewWithDB(db *sql.DB, dialect string, log waLog.Logger) *Container {
const getAllDevicesQuery = `
SELECT jid, registration_id, noise_key, identity_key,
signed_pre_key, signed_pre_key_id, signed_pre_key_sig,
- adv_key, adv_details, adv_account_sig, adv_device_sig,
+ adv_key, adv_details, adv_account_sig, adv_account_sig_key, adv_device_sig,
platform, business_name, push_name
FROM whatsmeow_device
`
@@ -100,7 +100,7 @@ func (c *Container) scanDevice(row scannable) (*store.Device, error) {
err := row.Scan(
&device.ID, &device.RegistrationID, &noisePriv, &identityPriv,
&preKeyPriv, &device.SignedPreKey.KeyID, &preKeySig,
- &device.AdvSecretKey, &account.Details, &account.AccountSignature, &account.DeviceSignature,
+ &device.AdvSecretKey, &account.Details, &account.AccountSignature, &account.AccountSignatureKey, &account.DeviceSignature,
&device.Platform, &device.BusinessName, &device.PushName)
if err != nil {
return nil, fmt.Errorf("failed to scan session: %w", err)
@@ -178,9 +178,9 @@ const (
insertDeviceQuery = `
INSERT INTO whatsmeow_device (jid, registration_id, noise_key, identity_key,
signed_pre_key, signed_pre_key_id, signed_pre_key_sig,
- adv_key, adv_details, adv_account_sig, adv_device_sig,
+ adv_key, adv_details, adv_account_sig, adv_account_sig_key, adv_device_sig,
platform, business_name, push_name)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
ON CONFLICT (jid) DO UPDATE SET platform=$12, business_name=$13, push_name=$14
`
deleteDeviceQuery = `DELETE FROM whatsmeow_device WHERE jid=$1`
@@ -222,7 +222,7 @@ func (c *Container) PutDevice(device *store.Device) error {
_, err := c.db.Exec(insertDeviceQuery,
device.ID.String(), device.RegistrationID, device.NoiseKey.Priv[:], device.IdentityKey.Priv[:],
device.SignedPreKey.Priv[:], device.SignedPreKey.KeyID, device.SignedPreKey.Signature[:],
- device.AdvSecretKey, device.Account.Details, device.Account.AccountSignature, device.Account.DeviceSignature,
+ device.AdvSecretKey, device.Account.Details, device.Account.AccountSignature, device.Account.AccountSignatureKey, device.Account.DeviceSignature,
device.Platform, device.BusinessName, device.PushName)
if !device.Initialized {
diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go
index b98f2d61..37bd7c29 100644
--- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go
+++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go
@@ -16,7 +16,7 @@ type upgradeFunc func(*sql.Tx, *Container) error
//
// This may be of use if you want to manage the database fully manually, but in most cases you
// should just call Container.Upgrade to let the library handle everything.
-var Upgrades = [...]upgradeFunc{upgradeV1}
+var Upgrades = [...]upgradeFunc{upgradeV1, upgradeV2}
func (c *Container) getVersion() (int, error) {
_, err := c.db.Exec("CREATE TABLE IF NOT EXISTS whatsmeow_version (version INTEGER)")
@@ -56,6 +56,7 @@ func (c *Container) Upgrade() error {
}
migrateFunc := Upgrades[version]
+ c.log.Infof("Upgrading database to v%d", version+1)
err = migrateFunc(tx, c)
if err != nil {
_ = tx.Rollback()
@@ -212,3 +213,36 @@ func upgradeV1(tx *sql.Tx, _ *Container) error {
}
return nil
}
+
+const fillSigKeyPostgres = `
+UPDATE whatsmeow_device SET adv_account_sig_key=(
+ SELECT identity
+ FROM whatsmeow_identity_keys
+ WHERE our_jid=whatsmeow_device.jid
+ AND their_id=concat(split_part(whatsmeow_device.jid, '.', 1), ':0')
+);
+DELETE FROM whatsmeow_device WHERE adv_account_sig_key IS NULL;
+ALTER TABLE whatsmeow_device ALTER COLUMN adv_account_sig_key SET NOT NULL;
+`
+
+const fillSigKeySQLite = `
+UPDATE whatsmeow_device SET adv_account_sig_key=(
+ SELECT identity
+ FROM whatsmeow_identity_keys
+ WHERE our_jid=whatsmeow_device.jid
+ AND their_id=substr(whatsmeow_device.jid, 0, instr(whatsmeow_device.jid, '.')) || ':0'
+)
+`
+
+func upgradeV2(tx *sql.Tx, container *Container) error {
+ _, err := tx.Exec("ALTER TABLE whatsmeow_device ADD COLUMN adv_account_sig_key bytea CHECK ( length(adv_account_sig_key) = 32 )")
+ if err != nil {
+ return err
+ }
+ if container.dialect == "postgres" {
+ _, err = tx.Exec(fillSigKeyPostgres)
+ } else {
+ _, err = tx.Exec(fillSigKeySQLite)
+ }
+ return err
+}